From: Peter Zijlstra <peterz@infradead.org>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Ingo Molnar <mingo@redhat.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>, Martin KaFai Lau <kafai@fb.com>,
Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH kernel] tracepoint: Fix race between tracing and removing tracepoint
Date: Tue, 2 Feb 2021 11:08:54 +0100 [thread overview]
Message-ID: <YBkkthjSsDXYxHKq@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20210202072326.120557-1-aik@ozlabs.ru>
On Tue, Feb 02, 2021 at 06:23:26PM +1100, Alexey Kardashevskiy wrote:
> When executing a tracepoint, the tracepoint's func is dereferenced twice -
> in __DO_TRACE() (where the returned pointer is checked) and later on in
> __traceiter_##_name where the returned pointer is dereferenced without
> checking which leads to races against tracepoint_removal_sync() and
> crashes.
>
> This adds a check before referencing the pointer in tracepoint_ptr_deref.
Agreed, a reload got added and it doesn't check the value again.
> Fixes: d25e37d89dd2f ("tracepoint: Optimize using static_call()")
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> it_func_ptr = \
> rcu_dereference_raw((&__tracepoint_##_name)->funcs); \
> + if (it_func_ptr) { \
> + do { \
> + it_func = (it_func_ptr)->func; \
> + __data = (it_func_ptr)->data; \
> + ((void(*)(void *, proto))(it_func))(__data, args); \
> + } while ((++it_func_ptr)->func); \
> + } \
> return 0; \
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
prev parent reply other threads:[~2021-02-02 10:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-02 7:23 Alexey Kardashevskiy
2021-02-02 10:08 ` Peter Zijlstra [this message]
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=YBkkthjSsDXYxHKq@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=aik@ozlabs.ru \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.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®