Skip to content

Commit

Permalink
kprobes: Remove unnecessary module_mutex locking from kprobe_optimizer()
Browse files Browse the repository at this point in the history
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 <mingo@kernel.org>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Link: https://lore.kernel.org/r/20200728163400.e00b09c594763349f99ce6cb@kernel.org
  • Loading branch information
Masami Hiramatsu authored and Ingo Molnar committed Jul 28, 2020
1 parent e89d4ca commit 112a0e4
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,6 @@ static void kprobe_optimizer(struct work_struct *work)
mutex_lock(&kprobe_mutex);
cpus_read_lock();
mutex_lock(&text_mutex);
/* Lock modules while optimizing kprobes */
mutex_lock(&module_mutex);

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

mutex_unlock(&module_mutex);
mutex_unlock(&text_mutex);
cpus_read_unlock();

Expand Down

0 comments on commit 112a0e4

Please sign in to comment.