* [PATCH -rc] [BUGFIX] kprobes: fix to use text_mutex around arm/disarm kprobe
@ 2009-05-07 20:28 Masami Hiramatsu
2009-05-08 5:13 ` [PATCH -rc] [BUGFIX] kprobes: fix to use text_mutex around arm/disarmkprobe Ananth N Mavinakayanahalli
0 siblings, 1 reply; 2+ messages in thread
From: Masami Hiramatsu @ 2009-05-07 20:28 UTC (permalink / raw)
To: Linus Torvalds
Cc: LKML, systemtap, Masami Hiramatsu, Mathieu Desnoyers,
Ananth N Mavinakayanahalli, Jim Keniston, Ingo Molnar
Fix kprobes to lock text_mutex around some arch_arm/disarm_kprobe() which
are newly added by commit de5bd88d5a5cce3cacea904d3503e5ebdb3852a2.
Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
---
kernel/kprobes.c | 31 ++++++++++++++++++++++---------
1 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index a5e74dd..c0fa54b 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -319,6 +319,22 @@ struct kprobe __kprobes *get_kprobe(void *addr)
return NULL;
}
+/* Arm a kprobe with text_mutex */
+static void __kprobes arm_kprobe(struct kprobe *kp)
+{
+ mutex_lock(&text_mutex);
+ arch_arm_kprobe(kp);
+ mutex_unlock(&text_mutex);
+}
+
+/* Disarm a kprobe with text_mutex */
+static void __kprobes disarm_kprobe(struct kprobe *kp)
+{
+ mutex_lock(&text_mutex);
+ arch_disarm_kprobe(kp);
+ mutex_unlock(&text_mutex);
+}
+
/*
* Aggregate handlers for multiple kprobes support - these handlers
* take care of invoking the individual kprobe handlers on p->list
@@ -538,7 +554,7 @@ static int __kprobes add_new_kprobe(struct kprobe *ap, struct kprobe *p)
ap->flags &= ~KPROBE_FLAG_DISABLED;
if (!kprobes_all_disarmed)
/* Arm the breakpoint again. */
- arch_arm_kprobe(ap);
+ arm_kprobe(ap);
}
return 0;
}
@@ -789,11 +805,8 @@ static int __kprobes __unregister_kprobe_top(struct kprobe *p)
* enabled and not gone - otherwise, the breakpoint would
* already have been removed. We save on flushing icache.
*/
- if (!kprobes_all_disarmed && !kprobe_disabled(old_p)) {
- mutex_lock(&text_mutex);
- arch_disarm_kprobe(p);
- mutex_unlock(&text_mutex);
- }
+ if (!kprobes_all_disarmed && !kprobe_disabled(old_p))
+ disarm_kprobe(p);
hlist_del_rcu(&old_p->hlist);
} else {
if (p->break_handler && !kprobe_gone(p))
@@ -810,7 +823,7 @@ noclean:
if (!kprobe_disabled(old_p)) {
try_to_disable_aggr_kprobe(old_p);
if (!kprobes_all_disarmed && kprobe_disabled(old_p))
- arch_disarm_kprobe(old_p);
+ disarm_kprobe(old_p);
}
}
return 0;
@@ -1364,7 +1377,7 @@ int __kprobes disable_kprobe(struct kprobe *kp)
try_to_disable_aggr_kprobe(p);
if (!kprobes_all_disarmed && kprobe_disabled(p))
- arch_disarm_kprobe(p);
+ disarm_kprobe(p);
out:
mutex_unlock(&kprobe_mutex);
return ret;
@@ -1393,7 +1406,7 @@ int __kprobes enable_kprobe(struct kprobe *kp)
}
if (!kprobes_all_disarmed && kprobe_disabled(p))
- arch_arm_kprobe(p);
+ arm_kprobe(p);
p->flags &= ~KPROBE_FLAG_DISABLED;
if (p != kp)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH -rc] [BUGFIX] kprobes: fix to use text_mutex around arm/disarmkprobe
2009-05-07 20:28 [PATCH -rc] [BUGFIX] kprobes: fix to use text_mutex around arm/disarm kprobe Masami Hiramatsu
@ 2009-05-08 5:13 ` Ananth N Mavinakayanahalli
0 siblings, 0 replies; 2+ messages in thread
From: Ananth N Mavinakayanahalli @ 2009-05-08 5:13 UTC (permalink / raw)
To: Masami Hiramatsu
Cc: Linus Torvalds, LKML, systemtap, Mathieu Desnoyers, Jim Keniston,
Ingo Molnar
On Thu, May 07, 2009 at 04:31:26PM -0400, Masami Hiramatsu wrote:
> Fix kprobes to lock text_mutex around some arch_arm/disarm_kprobe() which
> are newly added by commit de5bd88d5a5cce3cacea904d3503e5ebdb3852a2.
>
> Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
> Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
> Cc: Jim Keniston <jkenisto@us.ibm.com>
> Cc: Ingo Molnar <mingo@elte.hu>
Acked-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-05-08 5:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-07 20:28 [PATCH -rc] [BUGFIX] kprobes: fix to use text_mutex around arm/disarm kprobe Masami Hiramatsu
2009-05-08 5:13 ` [PATCH -rc] [BUGFIX] kprobes: fix to use text_mutex around arm/disarmkprobe Ananth N Mavinakayanahalli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).