]> git.baikalelectronics.ru Git - kernel.git/commitdiff
tracing: Fix sched switch start/stop refcount racy updates
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 17 Aug 2019 14:12:08 +0000 (10:12 -0400)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Thu, 30 Jan 2020 14:46:10 +0000 (09:46 -0500)
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).

[ May be the fix for this bug ]
Link: https://lore.kernel.org/r/000000000000ab6f84056c786b93@google.com
Link: http://lkml.kernel.org/r/20190817141208.15226-1-mathieu.desnoyers@efficios.com
Cc: stable@vger.kernel.org
CC: Steven Rostedt (VMware) <rostedt@goodmis.org>
CC: Joel Fernandes (Google) <joel@joelfernandes.org>
CC: Peter Zijlstra <peterz@infradead.org>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Paul E. McKenney <paulmck@linux.ibm.com>
Reported-by: syzbot+774fddf07b7ab29a1e55@syzkaller.appspotmail.com
Fixes: a6c900751f23f ("tracing: Add support for recording tgid of tasks")
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/trace_sched_switch.c

index e288168661e118c07ca5638bb2ddb3dd33fb1acc..e304196d7c2853ae0056c06c78d74819468265ca 100644 (file)
@@ -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: