* [PATCH] ftrace: Free the trampoline when ftrace_startup() fails
@ 2020-08-31 12:26 Miroslav Benes
2020-08-31 12:56 ` Miroslav Benes
0 siblings, 1 reply; 3+ messages in thread
From: Miroslav Benes @ 2020-08-31 12:26 UTC (permalink / raw)
To: rostedt, mingo
Cc: peterz, adrian.hunter, masami.hiramatsu.pt, linux-kernel, Miroslav Benes
Commit fc0ea795f53c ("ftrace: Add symbols for ftrace trampolines")
missed to remove ops from new ftrace_ops_trampoline_list in
ftrace_startup() if ftrace_hash_ipmodify_enable() fails there. It may
lead to BUG if such ops come from a module which may be removed.
Moreover, the trampoline itself is not freed in this case.
Fix it by calling ftrace_trampoline_free() during the rollback.
Fixes: fc0ea795f53c ("ftrace: Add symbols for ftrace trampolines")
Signed-off-by: Miroslav Benes <mbenes@suse.cz>
---
It would be fair to add
Fixes: f8b8be8a310a ("ftrace, kprobes: Support IPMODIFY flag to find IP modify conflict")
too. The situation was a bit more complicated back then though since
RCU-tasks support was missing.
kernel/trace/ftrace.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 275441254bb5..656d7cb5a78c 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2862,6 +2862,8 @@ int ftrace_startup(struct ftrace_ops *ops, int command)
__unregister_ftrace_function(ops);
ftrace_start_up--;
ops->flags &= ~FTRACE_OPS_FL_ENABLED;
+ if (ops->flags & FTRACE_OPS_FL_DYNAMIC)
+ ftrace_trampoline_free(ops);
return ret;
}
--
2.28.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ftrace: Free the trampoline when ftrace_startup() fails
2020-08-31 12:26 [PATCH] ftrace: Free the trampoline when ftrace_startup() fails Miroslav Benes
@ 2020-08-31 12:56 ` Miroslav Benes
2020-09-18 16:20 ` Steven Rostedt
0 siblings, 1 reply; 3+ messages in thread
From: Miroslav Benes @ 2020-08-31 12:56 UTC (permalink / raw)
To: rostedt, mingo; +Cc: peterz, adrian.hunter, linux-kernel, mhiramat
I used Masami's address which did not work. Sorry about that. Should be ok
now.
On Mon, 31 Aug 2020, Miroslav Benes wrote:
> Commit fc0ea795f53c ("ftrace: Add symbols for ftrace trampolines")
> missed to remove ops from new ftrace_ops_trampoline_list in
> ftrace_startup() if ftrace_hash_ipmodify_enable() fails there. It may
> lead to BUG if such ops come from a module which may be removed.
>
> Moreover, the trampoline itself is not freed in this case.
>
> Fix it by calling ftrace_trampoline_free() during the rollback.
>
> Fixes: fc0ea795f53c ("ftrace: Add symbols for ftrace trampolines")
> Signed-off-by: Miroslav Benes <mbenes@suse.cz>
> ---
>
> It would be fair to add
>
> Fixes: f8b8be8a310a ("ftrace, kprobes: Support IPMODIFY flag to find IP modify conflict")
>
> too. The situation was a bit more complicated back then though since
> RCU-tasks support was missing.
>
> kernel/trace/ftrace.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 275441254bb5..656d7cb5a78c 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -2862,6 +2862,8 @@ int ftrace_startup(struct ftrace_ops *ops, int command)
> __unregister_ftrace_function(ops);
> ftrace_start_up--;
> ops->flags &= ~FTRACE_OPS_FL_ENABLED;
> + if (ops->flags & FTRACE_OPS_FL_DYNAMIC)
> + ftrace_trampoline_free(ops);
> return ret;
> }
>
> --
> 2.28.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ftrace: Free the trampoline when ftrace_startup() fails
2020-08-31 12:56 ` Miroslav Benes
@ 2020-09-18 16:20 ` Steven Rostedt
0 siblings, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2020-09-18 16:20 UTC (permalink / raw)
To: Miroslav Benes; +Cc: mingo, peterz, adrian.hunter, linux-kernel, mhiramat
On Mon, 31 Aug 2020 14:56:57 +0200 (CEST)
Miroslav Benes <mbenes@suse.cz> wrote:
> I used Masami's address which did not work. Sorry about that. Should be ok
> now.
Thanks Miroslav,
I've queued this up to be tested and pushed as urgent.
-- Steve
>
> On Mon, 31 Aug 2020, Miroslav Benes wrote:
>
> > Commit fc0ea795f53c ("ftrace: Add symbols for ftrace trampolines")
> > missed to remove ops from new ftrace_ops_trampoline_list in
> > ftrace_startup() if ftrace_hash_ipmodify_enable() fails there. It may
> > lead to BUG if such ops come from a module which may be removed.
> >
> > Moreover, the trampoline itself is not freed in this case.
> >
> > Fix it by calling ftrace_trampoline_free() during the rollback.
> >
> > Fixes: fc0ea795f53c ("ftrace: Add symbols for ftrace trampolines")
> > Signed-off-by: Miroslav Benes <mbenes@suse.cz>
> > ---
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-18 16:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-31 12:26 [PATCH] ftrace: Free the trampoline when ftrace_startup() fails Miroslav Benes
2020-08-31 12:56 ` Miroslav Benes
2020-09-18 16:20 ` Steven Rostedt
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.