From: Joel Fernandes <joel@joelfernandes.org>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Daniel Colascione <dancol@google.com>,
Joel Fernandes <joelaf@google.com>,
LKML <linux-kernel@vger.kernel.org>,
Tim Murray <timmurray@google.com>,
netdev <netdev@vger.kernel.org>,
Lorenzo Colitti <lorenzo@google.com>,
Chenbo Feng <fengc@google.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Alexei Starovoitov <ast@fb.com>,
Daniel Borkmann <daniel@iogearbox.net>,
stable@vger.kernel.org
Subject: Re: [PATCH v4] Wait for running BPF programs when updating map-in-map
Date: Thu, 18 Oct 2018 16:36:33 -0700 [thread overview]
Message-ID: <20181018233633.GA89903@joelaf.mtv.corp.google.com> (raw)
In-Reply-To: <20181018154657.ehgj3ozy62zy47hi@ast-mbp.dhcp.thefacebook.com>
On Thu, Oct 18, 2018 at 08:46:59AM -0700, Alexei Starovoitov wrote:
> On Tue, Oct 16, 2018 at 10:39:57AM -0700, Joel Fernandes wrote:
> > On Fri, Oct 12, 2018 at 7:31 PM, Alexei Starovoitov
> > <alexei.starovoitov@gmail.com> wrote:
> > > On Fri, Oct 12, 2018 at 03:54:27AM -0700, Daniel Colascione wrote:
> > >> The map-in-map frequently serves as a mechanism for atomic
> > >> snapshotting of state that a BPF program might record. The current
> > >> implementation is dangerous to use in this way, however, since
> > >> userspace has no way of knowing when all programs that might have
> > >> retrieved the "old" value of the map may have completed.
> > >>
> > >> This change ensures that map update operations on map-in-map map types
> > >> always wait for all references to the old map to drop before returning
> > >> to userspace.
> > >>
> > >> Signed-off-by: Daniel Colascione <dancol@google.com>
> > >> ---
> > >> kernel/bpf/syscall.c | 14 ++++++++++++++
> > >> 1 file changed, 14 insertions(+)
> > >>
> > >> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> > >> index 8339d81cba1d..d7c16ae1e85a 100644
> > >> --- a/kernel/bpf/syscall.c
> > >> +++ b/kernel/bpf/syscall.c
> > >> @@ -741,6 +741,18 @@ static int map_lookup_elem(union bpf_attr *attr)
> > >> return err;
> > >> }
> > >>
> > >> +static void maybe_wait_bpf_programs(struct bpf_map *map)
> > >> +{
> > >> + /* Wait for any running BPF programs to complete so that
> > >> + * userspace, when we return to it, knows that all programs
> > >> + * that could be running use the new map value.
> > >> + */
> > >> + if (map->map_type == BPF_MAP_TYPE_HASH_OF_MAPS ||
> > >> + map->map_type == BPF_MAP_TYPE_ARRAY_OF_MAPS) {
> > >> + synchronize_rcu();
> > >> + }
> > >
> > > extra {} were not necessary. I removed them while applying to bpf-next.
> > > Please run checkpatch.pl next time.
> > > Thanks
> >
> > Thanks Alexei for taking it. Me and Lorenzo were discussing that not
> > having this causes incorrect behavior for apps using map-in-map for
> > this. So I CC'd stable as well.
>
> It is too late in the release cycle.
> We can submit it to stable releases after the merge window.
>
Sounds good, thanks.
- Joel
next prev parent reply other threads:[~2018-10-18 23:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAKOZuesQ6GdNTGDFsNi4o8LYzxLBtYZ=Cz4=aZbqqCNia+QFnQ@mail.gmail.com>
2018-07-29 20:58 ` [PATCH v3] Add BPF_SYNCHRONIZE_MAP_TO_MAP_REFERENCES bpf(2) command Daniel Colascione
2018-07-30 10:04 ` Daniel Borkmann
2018-07-30 10:25 ` Daniel Colascione
2018-07-31 0:26 ` Jakub Kicinski
2018-07-31 0:33 ` Daniel Colascione
2018-07-31 0:45 ` Jakub Kicinski
2018-07-31 0:50 ` Daniel Colascione
2018-07-31 1:14 ` Jakub Kicinski
2018-07-31 8:34 ` Daniel Borkmann
2018-07-31 9:36 ` Daniel Colascione
2018-08-10 22:52 ` Alexei Starovoitov
2018-08-14 20:37 ` Daniel Colascione
2018-08-16 4:01 ` Alexei Starovoitov
2018-10-12 10:54 ` [PATCH v4] Wait for running BPF programs when updating map-in-map Daniel Colascione
2018-10-12 20:54 ` Joel Fernandes
2018-10-13 2:31 ` Alexei Starovoitov
2018-10-16 17:39 ` Joel Fernandes
2018-10-18 15:46 ` Alexei Starovoitov
2018-10-18 23:36 ` Joel Fernandes [this message]
2018-11-10 2:01 ` Chenbo Feng
2018-11-10 15:22 ` Greg KH
2018-11-10 18:58 ` Chenbo Feng
[not found] ` <CAKOZues6SE_c=ix7ap6QaJHqd1TmYpWWMJiu3=TtuqgKuqOUCA@mail.gmail.com>
2018-08-10 22:29 ` [PATCH v3] Add BPF_SYNCHRONIZE_MAP_TO_MAP_REFERENCES bpf(2) command 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=20181018233633.GA89903@joelaf.mtv.corp.google.com \
--to=joel@joelfernandes.org \
--cc=alexei.starovoitov@gmail.com \
--cc=ast@fb.com \
--cc=dancol@google.com \
--cc=daniel@iogearbox.net \
--cc=fengc@google.com \
--cc=joelaf@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo@google.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=timmurray@google.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).