projects
/
wrapfs-5.3.y.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3fcc1c3
)
bpf: Check for integer overflow when using roundup_pow_of_two()
author
Bui Quang Minh
<minhquangbui99@gmail.com>
Wed, 27 Jan 2021 06:36:53 +0000
(06:36 +0000)
committer
Greg Kroah-Hartman
<gregkh@linuxfoundation.org>
Tue, 23 Feb 2021 12:59:16 +0000
(13:59 +0100)
[ Upstream commit
6183f4d3a0a2ad230511987c6c362ca43ec0055f
]
On 32-bit architecture, roundup_pow_of_two() can return 0 when the argument
has upper most bit set due to resulting 1UL << 32. Add a check for this case.
Fixes: d5a3b1f69186 ("bpf: introduce BPF_MAP_TYPE_STACK_TRACE")
Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link:
https://lore.kernel.org/bpf/20210127063653.3576-1-minhquangbui99@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/stackmap.c
patch
|
blob
|
history
diff --git
a/kernel/bpf/stackmap.c
b/kernel/bpf/stackmap.c
index a2a232dec2363137c0b30851fda9106dd465f48d..2fdf6f96f9762431fc9857ac4fddbe6d89474c5e 100644
(file)
--- a/
kernel/bpf/stackmap.c
+++ b/
kernel/bpf/stackmap.c
@@
-70,6
+70,8
@@
static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
/* hash table size must be power of 2 */
n_buckets = roundup_pow_of_two(attr->max_entries);
+ if (!n_buckets)
+ return ERR_PTR(-E2BIG);
cost = n_buckets * sizeof(struct stack_map_bucket *) + sizeof(*smap);
if (cost >= U32_MAX - PAGE_SIZE)