Skip to content

Commit 112a0e4

Browse files
mhiramatIngo Molnar
authored andcommitted
kprobes: Remove unnecessary module_mutex locking from kprobe_optimizer()
Since we already lock both kprobe_mutex and text_mutex in the optimizer, text will not be changed and the module unloading will be stopped inside kprobes_module_callback(). The mutex_lock() has originally been introduced to avoid conflict with text modification, at that point we didn't hold text_mutex. But after: f1c6ece ("kprobes: Fix potential deadlock in kprobe_optimizer()") We started holding the text_mutex and don't need the modules mutex anyway. So remove the module_mutex locking. [ mingo: Amended the changelog. ] Suggested-by: Ingo Molnar <[email protected]> Signed-off-by: Masami Hiramatsu <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Jarkko Sakkinen <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e89d4ca commit 112a0e4

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

kernel/kprobes.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,6 @@ static void kprobe_optimizer(struct work_struct *work)
598598
mutex_lock(&kprobe_mutex);
599599
cpus_read_lock();
600600
mutex_lock(&text_mutex);
601-
/* Lock modules while optimizing kprobes */
602-
mutex_lock(&module_mutex);
603601

604602
/*
605603
* Step 1: Unoptimize kprobes and collect cleaned (unused and disarmed)
@@ -624,7 +622,6 @@ static void kprobe_optimizer(struct work_struct *work)
624622
/* Step 4: Free cleaned kprobes after quiesence period */
625623
do_free_cleaned_kprobes();
626624

627-
mutex_unlock(&module_mutex);
628625
mutex_unlock(&text_mutex);
629626
cpus_read_unlock();
630627

0 commit comments

Comments
 (0)