BPF List
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Jiri Olsa <olsajiri@gmail.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>, bpf <bpf@vger.kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>
Subject: Re: [PATCH 1/2] bpf: Disable preemption in bpf_perf_event_output
Date: Wed, 19 Jul 2023 23:21:22 +0200	[thread overview]
Message-ID: <ZLhT0t+8LPplOo3Y@krava> (raw)
In-Reply-To: <CAADnVQKvkGwpa46v80L4YFfJR-9CjYcUhhS84dGJqToSjbUipQ@mail.gmail.com>

On Wed, Jul 19, 2023 at 11:45:26AM -0700, Alexei Starovoitov wrote:
> On Wed, Jul 19, 2023 at 7:08 AM Jiri Olsa <olsajiri@gmail.com> wrote:
> >
> > now task-1 and task-2 share same bpf_trace_nest_level value and same
> > 'struct perf_sample_data' buffer on top of &sds->sds[1]
> >
> > I did not figure out yet the actual exact scenario/cause of the crash yet,
> > I suspect one of the tasks copies data over some boundary, but all the
> > ideas I had so far did not match the instructions from the crash
> >
> > anyway I thought that having 2 tasks sharing the same perf_sample_data
> > is bad enough to send the patch
> 
> It makes sense now. We forgot to update this part during
> transition from preempt_disable to migrate_disable.
> 
> But do you have PREEMPT_RCU in your kernel?

yes, I have that enabled and it's also enabled in the kernel
that originally hit this

> If not then the above race shouldn't be possible.
> Worth fixing anyway, of course.
> Can you repro with a crafted test?
> Multiple uprobes doing bpf_perf_event_output should be enough, right?
> For kprobes we're "lucky" due to bpf_prog_active.

right, I can reproduce it just with uprobe

I realized the changes are on top of bpf-next/master.. I'll rebase it
on top of bpf/master and send without RFC tag

thanks,
jirka

  reply	other threads:[~2023-07-19 21:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-17 11:17 [PATCH/RFC 0/2] bpf: Disable preemption in bpf_perf_event_output Jiri Olsa
2023-07-17 11:17 ` [PATCH 1/2] " Jiri Olsa
2023-07-19  0:59   ` Alexei Starovoitov
2023-07-19 14:08     ` Jiri Olsa
2023-07-19 18:45       ` Alexei Starovoitov
2023-07-19 21:21         ` Jiri Olsa [this message]
2023-07-17 11:17 ` [PATCH/RFC 2/2] bpf: Disable preemption in bpf_event_output Jiri Olsa
2023-07-19  1:01   ` Alexei Starovoitov

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=ZLhT0t+8LPplOo3Y@krava \
    --to=olsajiri@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=sdf@google.com \
    --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