Fix: trace sched switch start/stop refcount racy updates
Mathieu Desnoyers
reviewerPATCH 1/1 Fix: trace sched switch start/stop refcount racy updates
Reading the sched_cmdline_ref and sched_tgid_ref initial state within tracing_start_sched_switch without holding the sched_register_mutex is racy against concurrent updates, which can lead to tracepoint probes being registered more than once (and thus trigger warnings within tracepoint.c).
[ Compile-tested only. I suspect it might fix the following syzbot
report:
Signed-off-by Mathieu Desnoyers <[email protected]>
CC Steven Rostedt (VMware) <[email protected]>
CC Joel Fernandes (Google) <[email protected]>
CC Peter Zijlstra <[email protected]>
CC Thomas Gleixner <[email protected]>
CC Paul E. McKenney <[email protected]>
--- kernel/trace/trace_sched_switch.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/trace/trace_sched_switch.c +3 -1
@@ -89,8 +89,10 @@ static void tracing_sched_unregister(void)static void tracing_start_sched_switch (int ops) { -bool sched_register = (!sched_cmdline_ref && !sched_tgid_ref); +bool sched_register; +mutex_lock (&sched_register_mutex); + sched_register = (!sched_cmdline_ref && !sched_tgid_ref);switch (ops) {case RECORD_CMDLINE :
Signature · 1 line
2.11.0