user_events: Prevent dyn_event delete racing with ioctl add/delete
authorBeau Belgrave <beaub@linux.microsoft.com>
Thu, 10 Mar 2022 00:11:41 +0000 (16:11 -0800)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Fri, 11 Mar 2022 16:49:24 +0000 (11:49 -0500)
commit7e348b325bc40eb52aead4d57a1f90d33ea834fc
tree3cf73f757cbc4b1d1a483d8ad8e3fe7ee7306f09
parent3a73333fb370f7b65de9d94c53df503642bda789
user_events: Prevent dyn_event delete racing with ioctl add/delete

Find user_events always while under the event_mutex and before leaving
the lock, add a ref count to the user_event. This ensures that all paths
under the event_mutex that check the ref counts will be synchronized.

The ioctl add/delete paths are protected by the reg_mutex. However,
dyn_event is only protected by the event_mutex. The dyn_event delete
path cannot acquire reg_mutex, since that could cause a deadlock between
the ioctl delete case acquiring event_mutex after acquiring the reg_mutex.

Link: https://lkml.kernel.org/r/20220310001141.1660-1-beaub@linux.microsoft.com
Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/trace_events_user.c