Linux Trace Kernel
 help / color / mirror / Atom feed
* [PATCH] tracing: Replace BUG_ON with lockdep_assert_held in uprobe_buffer functions
@ 2026-05-21 19:28 Yash Suthar
  2026-05-21 22:16 ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Yash Suthar @ 2026-05-21 19:28 UTC (permalink / raw)
  To: rostedt, mhiramat
  Cc: mathieu.desnoyers, linux-kernel, linux-trace-kernel, skhan,
	Yash Suthar

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.

Signed-off-by: Yash Suthar <yashsuthar983@gmail.com>
---
 kernel/trace/trace_uprobe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 2cabf8a23ec5..aee0960d0cf7 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -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)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tracing: Replace BUG_ON with lockdep_assert_held in uprobe_buffer functions
  2026-05-21 19:28 [PATCH] tracing: Replace BUG_ON with lockdep_assert_held in uprobe_buffer functions Yash Suthar
@ 2026-05-21 22:16 ` Steven Rostedt
  2026-05-25  7:42   ` Masami Hiramatsu
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2026-05-21 22:16 UTC (permalink / raw)
  To: Yash Suthar
  Cc: mhiramat, mathieu.desnoyers, linux-kernel, linux-trace-kernel,
	skhan

On Fri, 22 May 2026 00:58:46 +0530
Yash Suthar <yashsuthar983@gmail.com> wrote:

> 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.
> 
> Signed-off-by: Yash Suthar <yashsuthar983@gmail.com>

This looks good to me.

Acked-by: Steven Rostedt <rostedt@goodmis.org>

Masami, do you want to take this?

-- Steve

> ---
>  kernel/trace/trace_uprobe.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
> index 2cabf8a23ec5..aee0960d0cf7 100644
> --- a/kernel/trace/trace_uprobe.c
> +++ b/kernel/trace/trace_uprobe.c
> @@ -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)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tracing: Replace BUG_ON with lockdep_assert_held in uprobe_buffer functions
  2026-05-21 22:16 ` Steven Rostedt
@ 2026-05-25  7:42   ` Masami Hiramatsu
  0 siblings, 0 replies; 3+ messages in thread
From: Masami Hiramatsu @ 2026-05-25  7:42 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Yash Suthar, mhiramat, mathieu.desnoyers, linux-kernel,
	linux-trace-kernel, skhan

On Thu, 21 May 2026 18:16:01 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Fri, 22 May 2026 00:58:46 +0530
> Yash Suthar <yashsuthar983@gmail.com> wrote:
> 
> > 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.
> > 
> > Signed-off-by: Yash Suthar <yashsuthar983@gmail.com>
> 
> This looks good to me.
> 
> Acked-by: Steven Rostedt <rostedt@goodmis.org>
> 
> Masami, do you want to take this?

Yeah, let me pick this.

Thanks!

> 
> -- Steve
> 
> > ---
> >  kernel/trace/trace_uprobe.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
> > index 2cabf8a23ec5..aee0960d0cf7 100644
> > --- a/kernel/trace/trace_uprobe.c
> > +++ b/kernel/trace/trace_uprobe.c
> > @@ -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)
> 
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-25  7:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-21 19:28 [PATCH] tracing: Replace BUG_ON with lockdep_assert_held in uprobe_buffer functions Yash Suthar
2026-05-21 22:16 ` Steven Rostedt
2026-05-25  7:42   ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox