public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fprobe: add unlock to match a succeeded ftrace_test_recursion_trylock
@ 2023-07-03  7:16 Ze Gao
  2023-07-03  8:19 ` Masami Hiramatsu
  0 siblings, 1 reply; 3+ messages in thread
From: Ze Gao @ 2023-07-03  7:16 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Steven Rostedt, Ze Gao, linux-kernel, linux-trace-kernel, Ze Gao,
	Yafang

Fixes: 3cc4e2c5fbae ("fprobe: make fprobe_kprobe_handler recursion free")
Reported-by: Yafang <laoar.shao@gmail.com>
Closes: https://lore.kernel.org/linux-trace-kernel/CALOAHbC6UpfFOOibdDiC7xFc5YFUgZnk3MZ=3Ny6we=AcrNbew@mail.gmail.com/
Signed-off-by: Ze Gao <zegao@tencent.com>
---
 kernel/trace/fprobe.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c
index 18d36842faf5..93b3e361bb97 100644
--- a/kernel/trace/fprobe.c
+++ b/kernel/trace/fprobe.c
@@ -102,12 +102,14 @@ static void fprobe_kprobe_handler(unsigned long ip, unsigned long parent_ip,
 
 	if (unlikely(kprobe_running())) {
 		fp->nmissed++;
-		return;
+		goto recursion_unlock;
 	}
 
 	kprobe_busy_begin();
 	__fprobe_handler(ip, parent_ip, ops, fregs);
 	kprobe_busy_end();
+
+recursion_unlock:
 	ftrace_test_recursion_unlock(bit);
 }
 
-- 
2.40.1


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

* Re: [PATCH] fprobe: add unlock to match a succeeded ftrace_test_recursion_trylock
  2023-07-03  7:16 [PATCH] fprobe: add unlock to match a succeeded ftrace_test_recursion_trylock Ze Gao
@ 2023-07-03  8:19 ` Masami Hiramatsu
  2023-07-03  9:26   ` Ze Gao
  0 siblings, 1 reply; 3+ messages in thread
From: Masami Hiramatsu @ 2023-07-03  8:19 UTC (permalink / raw)
  To: Ze Gao; +Cc: Steven Rostedt, linux-kernel, linux-trace-kernel, Ze Gao, Yafang

On Mon,  3 Jul 2023 15:16:40 +0800
Ze Gao <zegao2021@gmail.com> wrote:

Good catch! but please add description here, something like;

----
Unlock ftrace recursion lock when fprobe_kprobe_handler() is failed
because another kprobe is running.
----

The code itself is OK to me.


> Fixes: 3cc4e2c5fbae ("fprobe: make fprobe_kprobe_handler recursion free")
> Reported-by: Yafang <laoar.shao@gmail.com>
> Closes: https://lore.kernel.org/linux-trace-kernel/CALOAHbC6UpfFOOibdDiC7xFc5YFUgZnk3MZ=3Ny6we=AcrNbew@mail.gmail.com/
> Signed-off-by: Ze Gao <zegao@tencent.com>
> ---
>  kernel/trace/fprobe.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c
> index 18d36842faf5..93b3e361bb97 100644
> --- a/kernel/trace/fprobe.c
> +++ b/kernel/trace/fprobe.c
> @@ -102,12 +102,14 @@ static void fprobe_kprobe_handler(unsigned long ip, unsigned long parent_ip,
>  
>  	if (unlikely(kprobe_running())) {
>  		fp->nmissed++;
> -		return;
> +		goto recursion_unlock;
>  	}
>  
>  	kprobe_busy_begin();
>  	__fprobe_handler(ip, parent_ip, ops, fregs);
>  	kprobe_busy_end();
> +
> +recursion_unlock:
>  	ftrace_test_recursion_unlock(bit);
>  }
>  
> -- 
> 2.40.1
> 


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

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

* Re: [PATCH] fprobe: add unlock to match a succeeded ftrace_test_recursion_trylock
  2023-07-03  8:19 ` Masami Hiramatsu
@ 2023-07-03  9:26   ` Ze Gao
  0 siblings, 0 replies; 3+ messages in thread
From: Ze Gao @ 2023-07-03  9:26 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Steven Rostedt, linux-kernel, linux-trace-kernel, Ze Gao, Yafang

Good suggestion! Will amend and push v2 ASAP.

Thanks,
Ze

On Mon, Jul 3, 2023 at 4:19 PM Masami Hiramatsu <mhiramat@kernel.org> wrote:
>
> On Mon,  3 Jul 2023 15:16:40 +0800
> Ze Gao <zegao2021@gmail.com> wrote:
>
> Good catch! but please add description here, something like;
>
> ----
> Unlock ftrace recursion lock when fprobe_kprobe_handler() is failed
> because another kprobe is running.
> ----
>
> The code itself is OK to me.
>
>
> > Fixes: 3cc4e2c5fbae ("fprobe: make fprobe_kprobe_handler recursion free")
> > Reported-by: Yafang <laoar.shao@gmail.com>
> > Closes: https://lore.kernel.org/linux-trace-kernel/CALOAHbC6UpfFOOibdDiC7xFc5YFUgZnk3MZ=3Ny6we=AcrNbew@mail.gmail.com/
> > Signed-off-by: Ze Gao <zegao@tencent.com>
> > ---
> >  kernel/trace/fprobe.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c
> > index 18d36842faf5..93b3e361bb97 100644
> > --- a/kernel/trace/fprobe.c
> > +++ b/kernel/trace/fprobe.c
> > @@ -102,12 +102,14 @@ static void fprobe_kprobe_handler(unsigned long ip, unsigned long parent_ip,
> >
> >       if (unlikely(kprobe_running())) {
> >               fp->nmissed++;
> > -             return;
> > +             goto recursion_unlock;
> >       }
> >
> >       kprobe_busy_begin();
> >       __fprobe_handler(ip, parent_ip, ops, fregs);
> >       kprobe_busy_end();
> > +
> > +recursion_unlock:
> >       ftrace_test_recursion_unlock(bit);
> >  }
> >
> > --
> > 2.40.1
> >
>
>
> --
> Masami Hiramatsu (Google) <mhiramat@kernel.org>

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

end of thread, other threads:[~2023-07-03  9:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-03  7:16 [PATCH] fprobe: add unlock to match a succeeded ftrace_test_recursion_trylock Ze Gao
2023-07-03  8:19 ` Masami Hiramatsu
2023-07-03  9:26   ` Ze Gao

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