Skip to content

Commit

Permalink
bpf: harden flags check in cgroup_storage_update_elem()
Browse files Browse the repository at this point in the history
cgroup_storage_update_elem() shouldn't accept any flags
argument values except BPF_ANY and BPF_EXIST to guarantee
the backward compatibility, had a new flag value been added.

Fixes: de9cbba ("bpf: introduce cgroup storage maps")
Signed-off-by: Roman Gushchin <guro@fb.com>
Reported-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
  • Loading branch information
Roman Gushchin authored and Daniel Borkmann committed Sep 28, 2018
1 parent d4ce580 commit 4288ea0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/bpf/local_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static int cgroup_storage_update_elem(struct bpf_map *map, void *_key,
struct bpf_cgroup_storage *storage;
struct bpf_storage_buffer *new;

if (flags & BPF_NOEXIST)
if (flags != BPF_ANY && flags != BPF_EXIST)
return -EINVAL;

storage = cgroup_storage_lookup((struct bpf_cgroup_storage_map *)map,
Expand Down

0 comments on commit 4288ea0

Please sign in to comment.