]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tracing: Replace BUG_ON with lockdep_assert_held in uprobe_buffer functions
authorYash Suthar <yashsuthar983@gmail.com>
Mon, 1 Jun 2026 14:35:21 +0000 (23:35 +0900)
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>
Mon, 1 Jun 2026 14:35:21 +0000 (23:35 +0900)
Replace BUG_ON(!mutex_is_locked(&event_mutex)) with
lockdep_assert_held(&event_mutex) in uprobe_buffer_enable() and
uprobe_buffer_disable().

BUG_ON() will crash the kernel. mutex_is_locked() only checks
if any task holds lock,but not the caller task. lockdep_assert_held()
also check current task for lock and no crash on true condition.

Link: https://lore.kernel.org/all/20260521192846.8306-1-yashsuthar983@gmail.com/
Signed-off-by: Yash Suthar <yashsuthar983@gmail.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
kernel/trace/trace_uprobe.c

index c5ee7920dec6379c77a788b8c9d0988376816a46..c274346853d17d899653e4637e103fda791f1225 100644 (file)
@@ -912,7 +912,7 @@ static int uprobe_buffer_enable(void)
 {
        int ret = 0;
 
-       BUG_ON(!mutex_is_locked(&event_mutex));
+       lockdep_assert_held(&event_mutex);
 
        if (uprobe_buffer_refcnt++ == 0) {
                ret = uprobe_buffer_init();
@@ -927,7 +927,7 @@ static void uprobe_buffer_disable(void)
 {
        int cpu;
 
-       BUG_ON(!mutex_is_locked(&event_mutex));
+       lockdep_assert_held(&event_mutex);
 
        if (--uprobe_buffer_refcnt == 0) {
                for_each_possible_cpu(cpu)