* [PATCH] ftrace: Fix missing synchronize_rcu() removing trampoline from kallsyms
@ 2020-09-01 9:16 Adrian Hunter
2020-09-11 11:41 ` peterz
0 siblings, 1 reply; 5+ messages in thread
From: Adrian Hunter @ 2020-09-01 9:16 UTC (permalink / raw)
To: peterz, rostedt; +Cc: mingo, mhiramat, mbenes, linux-kernel
Add synchronize_rcu() after list_del_rcu() in
ftrace_remove_trampoline_from_kallsyms() to protect readers of
ftrace_ops_trampoline_list (in ftrace_get_trampoline_kallsym)
which is used when kallsyms is read.
Fixes: fc0ea795f53c8d ("ftrace: Add symbols for ftrace trampolines")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
kernel/trace/ftrace.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 275441254bb5..4e64367c9774 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2782,6 +2782,7 @@ static void ftrace_remove_trampoline_from_kallsyms(struct ftrace_ops *ops)
{
lockdep_assert_held(&ftrace_lock);
list_del_rcu(&ops->list);
+ synchronize_rcu();
}
/*
--
2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ftrace: Fix missing synchronize_rcu() removing trampoline from kallsyms
2020-09-01 9:16 [PATCH] ftrace: Fix missing synchronize_rcu() removing trampoline from kallsyms Adrian Hunter
@ 2020-09-11 11:41 ` peterz
2020-09-11 12:55 ` Adrian Hunter
0 siblings, 1 reply; 5+ messages in thread
From: peterz @ 2020-09-11 11:41 UTC (permalink / raw)
To: Adrian Hunter
Cc: rostedt, mingo, mhiramat, mbenes, linux-kernel, Paul McKenney
On Tue, Sep 01, 2020 at 12:16:17PM +0300, Adrian Hunter wrote:
> Add synchronize_rcu() after list_del_rcu() in
> ftrace_remove_trampoline_from_kallsyms() to protect readers of
> ftrace_ops_trampoline_list (in ftrace_get_trampoline_kallsym)
> which is used when kallsyms is read.
>
> Fixes: fc0ea795f53c8d ("ftrace: Add symbols for ftrace trampolines")
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> kernel/trace/ftrace.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 275441254bb5..4e64367c9774 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -2782,6 +2782,7 @@ static void ftrace_remove_trampoline_from_kallsyms(struct ftrace_ops *ops)
> {
> lockdep_assert_held(&ftrace_lock);
> list_del_rcu(&ops->list);
> + synchronize_rcu();
> }
Hurmph, we've just done a ton of that:
ftrace_shutdown()
synchronize_rcu_tasks_rude()
ftrace_trampoline_free()
ftrace_remove_trampoline_from_kallsyms()
So would it not be better to move that call before the existing
synchronize_rcu_tasks stuff rather than adding another synchronize_rcu()
call?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ftrace: Fix missing synchronize_rcu() removing trampoline from kallsyms
2020-09-11 11:41 ` peterz
@ 2020-09-11 12:55 ` Adrian Hunter
2020-09-11 13:26 ` peterz
0 siblings, 1 reply; 5+ messages in thread
From: Adrian Hunter @ 2020-09-11 12:55 UTC (permalink / raw)
To: peterz; +Cc: rostedt, mingo, mhiramat, mbenes, linux-kernel, Paul McKenney
On 11/09/20 2:41 pm, peterz@infradead.org wrote:
> On Tue, Sep 01, 2020 at 12:16:17PM +0300, Adrian Hunter wrote:
>> Add synchronize_rcu() after list_del_rcu() in
>> ftrace_remove_trampoline_from_kallsyms() to protect readers of
>> ftrace_ops_trampoline_list (in ftrace_get_trampoline_kallsym)
>> which is used when kallsyms is read.
>>
>> Fixes: fc0ea795f53c8d ("ftrace: Add symbols for ftrace trampolines")
>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
>> ---
>> kernel/trace/ftrace.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
>> index 275441254bb5..4e64367c9774 100644
>> --- a/kernel/trace/ftrace.c
>> +++ b/kernel/trace/ftrace.c
>> @@ -2782,6 +2782,7 @@ static void ftrace_remove_trampoline_from_kallsyms(struct ftrace_ops *ops)
>> {
>> lockdep_assert_held(&ftrace_lock);
>> list_del_rcu(&ops->list);
>> + synchronize_rcu();
>> }
>
>
> Hurmph, we've just done a ton of that:
>
>
> ftrace_shutdown()
> synchronize_rcu_tasks_rude()
> ftrace_trampoline_free()
> ftrace_remove_trampoline_from_kallsyms()
>
>
> So would it not be better to move that call before the existing
> synchronize_rcu_tasks stuff rather than adding another synchronize_rcu()
> call?
Doesn't that mean removing the symbol while the trampoline is potentially
still in use?
Could follow up the fix with a patch to allocate list nodes instead, and use
call_rcu() to free it, so another synchronize_rcu() is not needed.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ftrace: Fix missing synchronize_rcu() removing trampoline from kallsyms
2020-09-11 12:55 ` Adrian Hunter
@ 2020-09-11 13:26 ` peterz
2020-09-18 16:23 ` Steven Rostedt
0 siblings, 1 reply; 5+ messages in thread
From: peterz @ 2020-09-11 13:26 UTC (permalink / raw)
To: Adrian Hunter
Cc: rostedt, mingo, mhiramat, mbenes, linux-kernel, Paul McKenney
On Fri, Sep 11, 2020 at 03:55:22PM +0300, Adrian Hunter wrote:
> On 11/09/20 2:41 pm, peterz@infradead.org wrote:
> > On Tue, Sep 01, 2020 at 12:16:17PM +0300, Adrian Hunter wrote:
> >> Add synchronize_rcu() after list_del_rcu() in
> >> ftrace_remove_trampoline_from_kallsyms() to protect readers of
> >> ftrace_ops_trampoline_list (in ftrace_get_trampoline_kallsym)
> >> which is used when kallsyms is read.
> >>
> >> Fixes: fc0ea795f53c8d ("ftrace: Add symbols for ftrace trampolines")
> >> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> >> ---
> >> kernel/trace/ftrace.c | 1 +
> >> 1 file changed, 1 insertion(+)
> >>
> >> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> >> index 275441254bb5..4e64367c9774 100644
> >> --- a/kernel/trace/ftrace.c
> >> +++ b/kernel/trace/ftrace.c
> >> @@ -2782,6 +2782,7 @@ static void ftrace_remove_trampoline_from_kallsyms(struct ftrace_ops *ops)
> >> {
> >> lockdep_assert_held(&ftrace_lock);
> >> list_del_rcu(&ops->list);
> >> + synchronize_rcu();
> >> }
> >
> >
> > Hurmph, we've just done a ton of that:
> >
> >
> > ftrace_shutdown()
> > synchronize_rcu_tasks_rude()
> > ftrace_trampoline_free()
> > ftrace_remove_trampoline_from_kallsyms()
> >
> >
> > So would it not be better to move that call before the existing
> > synchronize_rcu_tasks stuff rather than adding another synchronize_rcu()
> > call?
>
> Doesn't that mean removing the symbol while the trampoline is potentially
> still in use?
Hurm.. potentially yes. OK, lets do this first.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ftrace: Fix missing synchronize_rcu() removing trampoline from kallsyms
2020-09-11 13:26 ` peterz
@ 2020-09-18 16:23 ` Steven Rostedt
0 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2020-09-18 16:23 UTC (permalink / raw)
To: peterz
Cc: Adrian Hunter, mingo, mhiramat, mbenes, linux-kernel, Paul McKenney
On Fri, 11 Sep 2020 15:26:24 +0200
peterz@infradead.org wrote:
>
> > Doesn't that mean removing the symbol while the trampoline is potentially
> > still in use?
>
> Hurm.. potentially yes. OK, lets do this first.
OK, I queued this up to be tested and sent out for urgent.
-- Steve
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-09-18 16:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01 9:16 [PATCH] ftrace: Fix missing synchronize_rcu() removing trampoline from kallsyms Adrian Hunter
2020-09-11 11:41 ` peterz
2020-09-11 12:55 ` Adrian Hunter
2020-09-11 13:26 ` peterz
2020-09-18 16:23 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®