Skip to content

Commit 354fb59

Browse files
mhiramatSasha Levin
authored andcommitted
kprobes: Fix to protect kick_kprobe_optimizer() by kprobe_mutex
[ Upstream commit 1a0aa99 ] In kprobe_optimizer() kick_kprobe_optimizer() is called without kprobe_mutex, but this can race with other caller which is protected by kprobe_mutex. To fix that, expand kprobe_mutex protected area to protect kick_kprobe_optimizer() call. Link: http://lkml.kernel.org/r/158927057586.27680.5036330063955940456.stgit@devnote2 Fixes: cd7ebe2 ("kprobes: Use text_poke_smp_batch for optimizing") Cc: Ingo Molnar <[email protected]> Cc: "Gustavo A . R . Silva" <[email protected]> Cc: Anders Roxell <[email protected]> Cc: "Naveen N . Rao" <[email protected]> Cc: Anil S Keshavamurthy <[email protected]> Cc: David Miller <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ziqian SUN <[email protected]> Cc: [email protected] Signed-off-by: Masami Hiramatsu <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 3f51fa2 commit 354fb59

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel/kprobes.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,12 @@ static void kprobe_optimizer(struct work_struct *work)
561561
do_free_cleaned_kprobes();
562562

563563
mutex_unlock(&module_mutex);
564-
mutex_unlock(&kprobe_mutex);
565564

566565
/* Step 5: Kick optimizer again if needed */
567566
if (!list_empty(&optimizing_list) || !list_empty(&unoptimizing_list))
568567
kick_kprobe_optimizer();
568+
569+
mutex_unlock(&kprobe_mutex);
569570
}
570571

571572
/* Wait for completing optimization and unoptimization */

0 commit comments

Comments
 (0)