From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Edward Adam Davis <eadavis@qq.com>
Cc: syzbot+daba72c4af9915e9c894@syzkaller.appspotmail.com,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
mathieu.desnoyers@efficios.com, mhiramat@kernel.org,
rostedt@goodmis.org, syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] tracing: Fix filter logic error
Date: Tue, 24 Jun 2025 16:44:53 +0900 [thread overview]
Message-ID: <20250624164453.e982cae14fbf3b53d477e2be@kernel.org> (raw)
In-Reply-To: <tencent_4EF87A626D702F816CD0951CE956EC32CD0A@qq.com>
On Tue, 24 Jun 2025 14:38:46 +0800
Edward Adam Davis <eadavis@qq.com> wrote:
> If the processing of the tr->events loop fails, the filter that has been
> added to filter_head will be released twice in free_filter_list(&head->rcu)
> and __free_filter(filter).
>
> After adding the filter of tr->events, add the filter to the filter_head
> process to avoid triggering uaf.
Looks good to me.
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Thank you,
>
> Fixes: a9d0aab5eb33 ("tracing: Fix regression of filter waiting a long time on RCU synchronization")
> Reported-by: syzbot+daba72c4af9915e9c894@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=daba72c4af9915e9c894
> Tested-by: syzbot+daba72c4af9915e9c894@syzkaller.appspotmail.com
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> ---
> kernel/trace/trace_events_filter.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
> index 08141f105c95..3885aadc434d 100644
> --- a/kernel/trace/trace_events_filter.c
> +++ b/kernel/trace/trace_events_filter.c
> @@ -1436,13 +1436,6 @@ static void filter_free_subsystem_filters(struct trace_subsystem_dir *dir,
>
> INIT_LIST_HEAD(&head->list);
>
> - item = kmalloc(sizeof(*item), GFP_KERNEL);
> - if (!item)
> - goto free_now;
> -
> - item->filter = filter;
> - list_add_tail(&item->list, &head->list);
> -
> list_for_each_entry(file, &tr->events, list) {
> if (file->system != dir)
> continue;
> @@ -1454,6 +1447,13 @@ static void filter_free_subsystem_filters(struct trace_subsystem_dir *dir,
> event_clear_filter(file);
> }
>
> + item = kmalloc(sizeof(*item), GFP_KERNEL);
> + if (!item)
> + goto free_now;
> +
> + item->filter = filter;
> + list_add_tail(&item->list, &head->list);
> +
> delay_free_filter(head);
> return;
> free_now:
> --
> 2.43.0
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2025-06-24 7:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-23 23:58 [syzbot] [trace?] KASAN: slab-use-after-free Read in __free_filter syzbot
2025-06-24 6:10 ` Edward Adam Davis
2025-06-24 6:32 ` syzbot
2025-06-24 6:38 ` [PATCH] tracing: Fix filter logic error Edward Adam Davis
2025-06-24 7:44 ` Masami Hiramatsu [this message]
2025-06-24 19:17 ` Steven Rostedt
2025-06-24 8:25 ` [syzbot] [trace?] KASAN: slab-use-after-free Read in __free_filter Hillf Danton
2025-06-24 8:47 ` syzbot
2025-06-24 18:44 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250624164453.e982cae14fbf3b53d477e2be@kernel.org \
--to=mhiramat@kernel.org \
--cc=eadavis@qq.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=rostedt@goodmis.org \
--cc=syzbot+daba72c4af9915e9c894@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®