Skip to content

Commit

Permalink
bpf: don't accept cgroup local storage with zero value size
Browse files Browse the repository at this point in the history
Explicitly forbid creating cgroup local storage maps with zero value
size, as it makes no sense and might even cause a panic.

Reported-by: syzbot+18628320d3b14a5c459c@syzkaller.appspotmail.com
Signed-off-by: Roman Gushchin <guro@fb.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
  • Loading branch information
Roman Gushchin authored and Daniel Borkmann committed Oct 2, 2018
1 parent 4288ea0 commit b0584ea
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kernel/bpf/local_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ static struct bpf_map *cgroup_storage_map_alloc(union bpf_attr *attr)
if (attr->key_size != sizeof(struct bpf_cgroup_storage_key))
return ERR_PTR(-EINVAL);

if (attr->value_size == 0)
return ERR_PTR(-EINVAL);

if (attr->value_size > PAGE_SIZE)
return ERR_PTR(-E2BIG);

Expand Down

0 comments on commit b0584ea

Please sign in to comment.