kprobes: Fix to protect kick_kprobe_optimizer() by kprobe_mutex
[ Upstream commit 1a0aa991a6274161c95a844c58cfb801d681eb59 ]
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: cd7ebe2298
("kprobes: Use text_poke_smp_batch for optimizing")
Cc: Ingo Molnar <mingo@kernel.org>
Cc: "Gustavo A . R . Silva" <gustavoars@kernel.org>
Cc: Anders Roxell <anders.roxell@linaro.org>
Cc: "Naveen N . Rao" <naveen.n.rao@linux.ibm.com>
Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Cc: David Miller <davem@davemloft.net>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ziqian SUN <zsun@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
44f5e4fc26
commit
f637e2c75f
1 changed files with 2 additions and 1 deletions
|
@ -561,11 +561,12 @@ static void kprobe_optimizer(struct work_struct *work)
|
||||||
do_free_cleaned_kprobes();
|
do_free_cleaned_kprobes();
|
||||||
|
|
||||||
mutex_unlock(&module_mutex);
|
mutex_unlock(&module_mutex);
|
||||||
mutex_unlock(&kprobe_mutex);
|
|
||||||
|
|
||||||
/* Step 5: Kick optimizer again if needed */
|
/* Step 5: Kick optimizer again if needed */
|
||||||
if (!list_empty(&optimizing_list) || !list_empty(&unoptimizing_list))
|
if (!list_empty(&optimizing_list) || !list_empty(&unoptimizing_list))
|
||||||
kick_kprobe_optimizer();
|
kick_kprobe_optimizer();
|
||||||
|
|
||||||
|
mutex_unlock(&kprobe_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for completing optimization and unoptimization */
|
/* Wait for completing optimization and unoptimization */
|
||||||
|
|
Loading…
Add table
Reference in a new issue