linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Radoslaw Zielonek <radoslaw.zielonek@gmail.com>,
	mingo@redhat.com, acme@kernel.org,  namhyung@kernel.org,
	mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
	 jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com,
	 linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	 bpf@vger.kernel.org,
	syzbot+72a43cdb78469f7fbad1@syzkaller.appspotmail.com
Subject: Re: [PATCH] perf callchain: Fix suspicious RCU usage in get_callchain_entry()
Date: Thu, 18 Jul 2024 10:41:20 -0700	[thread overview]
Message-ID: <CAEf4BzaYL9zZN8TZyRHW3_O3vbHc7On+NSunrkDvDQx2=wwyRw@mail.gmail.com> (raw)
In-Reply-To: <20240715104719.GA14400@noisy.programming.kicks-ass.net>

On Mon, Jul 15, 2024 at 3:47 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Mon, Jul 15, 2024 at 12:23:27PM +0200, Radoslaw Zielonek wrote:
> > The rcu_dereference() is using rcu_read_lock_held() as a checker, but
> > BPF in bpf_prog_test_run_syscall() is using rcu_read_lock_trace() locker.
> > To fix this issue the proper checker has been used
> > (rcu_read_lock_trace_held() || rcu_read_lock_held())
>
> How does that fix it? release_callchain_buffers() does call_rcu(), not
> call_rcu_tracing().
>
> Does a normal RCU grace period fully imply an RCU-tracing grace period?

I don't think so, they are completely independent. So this change
doesn't seem correct. I think we should just ensure
rcu_read_lock()/rcu_read_unlock() before calling into perf_callchain
functionality.

Which is what I'm doing in [0]. Radoslaw, can you please help
validating if those changes are enough to fix this issue or we need to
do some more?

  [0] https://patchwork.kernel.org/project/netdevbpf/patch/20240709204245.3847811-10-andrii@kernel.org/

>
> > ---
> >  kernel/events/callchain.c | 11 +++++++++--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> >

[...]

      reply	other threads:[~2024-07-18 17:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-15 10:23 [PATCH] perf callchain: Fix suspicious RCU usage in get_callchain_entry() Radoslaw Zielonek
2024-07-15 10:47 ` Peter Zijlstra
2024-07-18 17:41   ` Andrii Nakryiko [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='CAEf4BzaYL9zZN8TZyRHW3_O3vbHc7On+NSunrkDvDQx2=wwyRw@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=radoslaw.zielonek@gmail.com \
    --cc=syzbot+72a43cdb78469f7fbad1@syzkaller.appspotmail.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;
as well as URLs for NNTP newsgroup(s).