* [PATCH bpf-next] bpf: fix flags check in bpf_percpu_cgroup_storage_update()
@ 2018-09-28 11:06 Roman Gushchin
2018-09-28 12:11 ` Daniel Borkmann
0 siblings, 1 reply; 3+ messages in thread
From: Roman Gushchin @ 2018-09-28 11:06 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel-team, Roman Gushchin, Daniel Borkmann,
Alexei Starovoitov
Fix an issue in bpf_percpu_cgroup_storage_update(): it should return
-EINVAL on an attempt to pass BPF_NOEXIST rather than BPF_EXIST.
Cgroup local storage is automatically created on attaching of a bpf
program to a cgroup, and it can't be done from the userspace.
Fixes: 0daef9b42374 ("bpf: introduce per-cpu cgroup local storage")
Signed-off-by: Roman Gushchin <guro@fb.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Alexei Starovoitov <ast@kernel.org>
---
kernel/bpf/local_storage.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/bpf/local_storage.c b/kernel/bpf/local_storage.c
index c739f6dcc3c2..190535f6d5e2 100644
--- a/kernel/bpf/local_storage.c
+++ b/kernel/bpf/local_storage.c
@@ -191,7 +191,7 @@ int bpf_percpu_cgroup_storage_update(struct bpf_map *_map, void *_key,
int cpu, off = 0;
u32 size;
- if (unlikely(map_flags & BPF_EXIST))
+ if (map_flags & BPF_NOEXIST)
return -EINVAL;
rcu_read_lock();
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] bpf: fix flags check in bpf_percpu_cgroup_storage_update()
2018-09-28 11:06 [PATCH bpf-next] bpf: fix flags check in bpf_percpu_cgroup_storage_update() Roman Gushchin
@ 2018-09-28 12:11 ` Daniel Borkmann
2018-09-28 13:29 ` Roman Gushchin
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Borkmann @ 2018-09-28 12:11 UTC (permalink / raw)
To: Roman Gushchin, netdev; +Cc: linux-kernel, kernel-team, Alexei Starovoitov
On 09/28/2018 01:06 PM, Roman Gushchin wrote:
> Fix an issue in bpf_percpu_cgroup_storage_update(): it should return
> -EINVAL on an attempt to pass BPF_NOEXIST rather than BPF_EXIST.
>
> Cgroup local storage is automatically created on attaching of a bpf
> program to a cgroup, and it can't be done from the userspace.
>
> Fixes: 0daef9b42374 ("bpf: introduce per-cpu cgroup local storage")
> Signed-off-by: Roman Gushchin <guro@fb.com>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Alexei Starovoitov <ast@kernel.org>
> ---
> kernel/bpf/local_storage.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/local_storage.c b/kernel/bpf/local_storage.c
> index c739f6dcc3c2..190535f6d5e2 100644
> --- a/kernel/bpf/local_storage.c
> +++ b/kernel/bpf/local_storage.c
> @@ -191,7 +191,7 @@ int bpf_percpu_cgroup_storage_update(struct bpf_map *_map, void *_key,
> int cpu, off = 0;
> u32 size;
>
> - if (unlikely(map_flags & BPF_EXIST))
> + if (map_flags & BPF_NOEXIST)
> return -EINVAL;
Hmm, this is also incorrect as any future reserved flag would be accepted here and
couldn't be extended anymore. :/ And it looks like cgroup_storage_update_elem() is
doing the same today, given the cgroups local storage is still early, we should route
a patch to stable for fixing this.
Wrt this series, given the series is top of tree right now, I would prefer a fresh
respin so we have the fix integrated properly w/o follow-up. Perhaps this could also
incorporate Alexei's previous cleanup suggestions as well from today if you have a
chance.
Thanks,
Daniel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] bpf: fix flags check in bpf_percpu_cgroup_storage_update()
2018-09-28 12:11 ` Daniel Borkmann
@ 2018-09-28 13:29 ` Roman Gushchin
0 siblings, 0 replies; 3+ messages in thread
From: Roman Gushchin @ 2018-09-28 13:29 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: netdev, linux-kernel, kernel-team, Alexei Starovoitov
On Fri, Sep 28, 2018 at 02:11:48PM +0200, Daniel Borkmann wrote:
> On 09/28/2018 01:06 PM, Roman Gushchin wrote:
> > Fix an issue in bpf_percpu_cgroup_storage_update(): it should return
> > -EINVAL on an attempt to pass BPF_NOEXIST rather than BPF_EXIST.
> >
> > Cgroup local storage is automatically created on attaching of a bpf
> > program to a cgroup, and it can't be done from the userspace.
> >
> > Fixes: 0daef9b42374 ("bpf: introduce per-cpu cgroup local storage")
> > Signed-off-by: Roman Gushchin <guro@fb.com>
> > Cc: Daniel Borkmann <daniel@iogearbox.net>
> > Cc: Alexei Starovoitov <ast@kernel.org>
> > ---
> > kernel/bpf/local_storage.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/bpf/local_storage.c b/kernel/bpf/local_storage.c
> > index c739f6dcc3c2..190535f6d5e2 100644
> > --- a/kernel/bpf/local_storage.c
> > +++ b/kernel/bpf/local_storage.c
> > @@ -191,7 +191,7 @@ int bpf_percpu_cgroup_storage_update(struct bpf_map *_map, void *_key,
> > int cpu, off = 0;
> > u32 size;
> >
> > - if (unlikely(map_flags & BPF_EXIST))
> > + if (map_flags & BPF_NOEXIST)
> > return -EINVAL;
>
> Hmm, this is also incorrect as any future reserved flag would be accepted here and
> couldn't be extended anymore. :/ And it looks like cgroup_storage_update_elem() is
> doing the same today, given the cgroups local storage is still early, we should route
> a patch to stable for fixing this.
Fair enough, will post soon.
>
> Wrt this series, given the series is top of tree right now, I would prefer a fresh
> respin so we have the fix integrated properly w/o follow-up. Perhaps this could also
> incorporate Alexei's previous cleanup suggestions as well from today if you have a
> chance.
I'm not sure about merging copy() and update() functions, as large #define
blocks are really bad. So I'd think a bit more here. Will do the rest.
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-09-28 18:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-28 11:06 [PATCH bpf-next] bpf: fix flags check in bpf_percpu_cgroup_storage_update() Roman Gushchin
2018-09-28 12:11 ` Daniel Borkmann
2018-09-28 13:29 ` Roman Gushchin
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).