]> git.baikalelectronics.ru Git - kernel.git/commit
tracing: Fix lock inversion in trace_event_enable_tgid_record()
authorPrateek Sood <prsood@codeaurora.org>
Tue, 10 Dec 2019 09:15:16 +0000 (09:15 +0000)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Sat, 21 Dec 2019 21:05:13 +0000 (16:05 -0500)
commit8e879786c0e35c8974a14e0d5d32f02b4d814180
tree21d329444d63cb7ad13f5b296166d201fb26f89e
parent1c3f3ebfebaede24ade387ca36c95d5b066c953e
tracing: Fix lock inversion in trace_event_enable_tgid_record()

       Task T2                             Task T3
trace_options_core_write()            subsystem_open()

 mutex_lock(trace_types_lock)           mutex_lock(event_mutex)

 set_tracer_flag()

   trace_event_enable_tgid_record()       mutex_lock(trace_types_lock)

    mutex_lock(event_mutex)

This gives a circular dependency deadlock between trace_types_lock and
event_mutex. To fix this invert the usage of trace_types_lock and
event_mutex in trace_options_core_write(). This keeps the sequence of
lock usage consistent.

Link: http://lkml.kernel.org/r/0101016eef175e38-8ca71caf-a4eb-480d-a1e6-6f0bbc015495-000000@us-west-2.amazonses.com
Cc: stable@vger.kernel.org
Fixes: a6c900751f23f ("tracing: Add support for recording tgid of tasks")
Signed-off-by: Prateek Sood <prsood@codeaurora.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/trace.c
kernel/trace/trace_events.c