* [PATCH] ftrace/direct: Fix lockup in modify_ftrace_direct_multi
@ 2021-11-09 11:42 Jiri Olsa
2021-11-09 16:02 ` Steven Rostedt
0 siblings, 1 reply; 3+ messages in thread
From: Jiri Olsa @ 2021-11-09 11:42 UTC (permalink / raw)
To: Steven Rostedt, Ingo Molnar; +Cc: lkml
We can't call unregister_ftrace_function under ftrace_lock.
Fixes: ed29271894aa ("ftrace/direct: Do not disable when switching direct callers")
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
kernel/trace/ftrace.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index b4ed1a301232..fc49e8809a56 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -5602,10 +5602,11 @@ int modify_ftrace_direct_multi(struct ftrace_ops *ops, unsigned long addr)
}
}
+ mutex_unlock(&ftrace_lock);
+
/* Removing the tmp_ops will add the updated direct callers to the functions */
unregister_ftrace_function(&tmp_ops);
- mutex_unlock(&ftrace_lock);
out_direct:
mutex_unlock(&direct_mutex);
return err;
--
2.32.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ftrace/direct: Fix lockup in modify_ftrace_direct_multi
2021-11-09 11:42 [PATCH] ftrace/direct: Fix lockup in modify_ftrace_direct_multi Jiri Olsa
@ 2021-11-09 16:02 ` Steven Rostedt
2021-11-09 18:04 ` Jiri Olsa
0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2021-11-09 16:02 UTC (permalink / raw)
To: Jiri Olsa; +Cc: Ingo Molnar, lkml
On Tue, 9 Nov 2021 12:42:17 +0100
Jiri Olsa <jolsa@redhat.com> wrote:
> We can't call unregister_ftrace_function under ftrace_lock.
Ouch.
Do you have a sample module that triggers this?
I thought we had something that tested this code, but I don't see it in my
tree.
-- Steve
>
> Fixes: ed29271894aa ("ftrace/direct: Do not disable when switching direct callers")
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
> kernel/trace/ftrace.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index b4ed1a301232..fc49e8809a56 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -5602,10 +5602,11 @@ int modify_ftrace_direct_multi(struct ftrace_ops *ops, unsigned long addr)
> }
> }
>
> + mutex_unlock(&ftrace_lock);
> +
> /* Removing the tmp_ops will add the updated direct callers to the functions */
> unregister_ftrace_function(&tmp_ops);
>
> - mutex_unlock(&ftrace_lock);
> out_direct:
> mutex_unlock(&direct_mutex);
> return err;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ftrace/direct: Fix lockup in modify_ftrace_direct_multi
2021-11-09 16:02 ` Steven Rostedt
@ 2021-11-09 18:04 ` Jiri Olsa
0 siblings, 0 replies; 3+ messages in thread
From: Jiri Olsa @ 2021-11-09 18:04 UTC (permalink / raw)
To: Steven Rostedt; +Cc: Ingo Molnar, lkml
On Tue, Nov 09, 2021 at 11:02:37AM -0500, Steven Rostedt wrote:
> On Tue, 9 Nov 2021 12:42:17 +0100
> Jiri Olsa <jolsa@redhat.com> wrote:
>
> > We can't call unregister_ftrace_function under ftrace_lock.
>
> Ouch.
>
> Do you have a sample module that triggers this?
>
> I thought we had something that tested this code, but I don't see it in my
> tree.
I triggered that with my bpf batch changes
there's not test for modify at the moment,
just register/unregister I'll add one
jirka
>
> -- Steve
>
> >
> > Fixes: ed29271894aa ("ftrace/direct: Do not disable when switching direct callers")
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> > kernel/trace/ftrace.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> > index b4ed1a301232..fc49e8809a56 100644
> > --- a/kernel/trace/ftrace.c
> > +++ b/kernel/trace/ftrace.c
> > @@ -5602,10 +5602,11 @@ int modify_ftrace_direct_multi(struct ftrace_ops *ops, unsigned long addr)
> > }
> > }
> >
> > + mutex_unlock(&ftrace_lock);
> > +
> > /* Removing the tmp_ops will add the updated direct callers to the functions */
> > unregister_ftrace_function(&tmp_ops);
> >
> > - mutex_unlock(&ftrace_lock);
> > out_direct:
> > mutex_unlock(&direct_mutex);
> > return err;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-09 18:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-09 11:42 [PATCH] ftrace/direct: Fix lockup in modify_ftrace_direct_multi Jiri Olsa
2021-11-09 16:02 ` Steven Rostedt
2021-11-09 18:04 ` Jiri Olsa
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.