From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Roman Gushchin <guro@fb.com>
Cc: Yonghong Song <yhs@fb.com>,
ast@fb.com, daniel@iogearbox.net, netdev@vger.kernel.org,
kernel-team@fb.com
Subject: Re: [PATCH bpf] bpf: fix a rcu usage warning in bpf_prog_array_copy_core()
Date: Wed, 15 Aug 2018 14:30:11 -0700 [thread overview]
Message-ID: <20180815213009.t2nhtoxlqpd2sgk4@ast-mbp> (raw)
In-Reply-To: <20180815000841.GA25304@castle.DHCP.thefacebook.com>
On Tue, Aug 14, 2018 at 05:08:44PM -0700, Roman Gushchin wrote:
> On Tue, Aug 14, 2018 at 04:59:45PM -0700, Alexei Starovoitov wrote:
> > On Tue, Aug 14, 2018 at 11:01:12AM -0700, Yonghong Song wrote:
> > > Commit 394e40a29788 ("bpf: extend bpf_prog_array to store pointers
> > > to the cgroup storage") refactored the bpf_prog_array_copy_core()
> > > to accommodate new structure bpf_prog_array_item which contains
> > > bpf_prog array itself.
> > >
> > > In the old code, we had
> > > perf_event_query_prog_array():
> > > mutex_lock(...)
> > > bpf_prog_array_copy_call():
> > > prog = rcu_dereference_check(array, 1)->progs
> > > bpf_prog_array_copy_core(prog, ...)
> > > mutex_unlock(...)
> > >
> > > With the above commit, we had
> > > perf_event_query_prog_array():
> > > mutex_lock(...)
> > > bpf_prog_array_copy_call():
> > > bpf_prog_array_copy_core(array, ...):
> > > item = rcu_dereference(array)->items;
> > > ...
> > > mutex_unlock(...)
> > >
> > > The new code will trigger a lockdep rcu checking warning.
> > > The fix is to change rcu_dereference() to rcu_dereference_check()
> > > to prevent such a warning.
> > >
> > > Reported-by: syzbot+6e72317008eef84a216b@syzkaller.appspotmail.com
> > > Fixes: 394e40a29788 ("bpf: extend bpf_prog_array to store pointers to the cgroup storage")
> > > Cc: Roman Gushchin <guro@fb.com>
> > > Signed-off-by: Yonghong Song <yhs@fb.com>
> >
> > makes sense to me
> > Acked-by: Alexei Starovoitov <ast@kernel.org>
> >
> > Roman, would you agree?
> >
>
> rcu_dereference_check(<>, 1) always looks a bit strange to me,
> but if it's the only reasonable way to silence the warning,
> of course I'm fine with it.
do you have better suggestion?
This patch is a fix for the regression introduced in your earlier patch,
so I think the only fair path forward is either to Ack it or
to send an alternative patch asap.
next prev parent reply other threads:[~2018-08-16 0:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-14 18:01 [PATCH bpf] bpf: fix a rcu usage warning in bpf_prog_array_copy_core() Yonghong Song
2018-08-14 23:59 ` Alexei Starovoitov
2018-08-15 0:08 ` Roman Gushchin
2018-08-15 21:30 ` Alexei Starovoitov [this message]
2018-08-15 21:37 ` Roman Gushchin
2018-08-16 0:17 ` Daniel Borkmann
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=20180815213009.t2nhtoxlqpd2sgk4@ast-mbp \
--to=alexei.starovoitov@gmail.com \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=guro@fb.com \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
--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