[PATCH 4/5][RFC] kprobes: Inverse taking of module_mutex with kprobe_mutex

From: Steven Rostedt
Date: Wed Aug 10 2011 - 12:30:47 EST

From: Steven Rostedt <srostedt@xxxxxxxxxx>

Currently module_mutex is taken before kprobe_mutex, but this
can cause issues when we have kprobes register ftrace, as the ftrace
mutex is taken before enabling a tracepoint, which currently takes
the module mutex.

If module_mutex is taken before kprobe_mutex, then we can not
have kprobes use the ftrace infrastructure.

There seems to be no reason that the kprobe_mutex can't be taken
before the module_mutex. Running lockdep shows that it is safe
among the kernels I've run.

Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
kernel/kprobes.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index b30fd54..e6c25eb 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -561,9 +561,9 @@ static __kprobes void kprobe_optimizer(struct work_struct *work)

+ mutex_lock(&kprobe_mutex);
/* Lock modules while optimizing kprobes */
- mutex_lock(&kprobe_mutex);

* Step 1: Unoptimize kprobes and collect cleaned (unused and disarmed)
@@ -586,8 +586,8 @@ static __kprobes void kprobe_optimizer(struct work_struct *work)
/* Step 4: Free cleaned kprobes after quiesence period */

- mutex_unlock(&kprobe_mutex);
+ mutex_unlock(&kprobe_mutex);

/* Step 5: Kick optimizer again if needed */
if (!list_empty(&optimizing_list) || !list_empty(&unoptimizing_list))

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/