bpf: Check for integer overflow when using roundup_pow_of_two()
authorBui Quang Minh <minhquangbui99@gmail.com>
Wed, 27 Jan 2021 06:36:53 +0000 (06:36 +0000)
committerCosmin Tanislav <demonsingur@gmail.com>
Thu, 16 May 2024 07:58:23 +0000 (10:58 +0300)
commit5d3aa27e690cd2b01a66716b62312826deb7e4bf
tree4660d471b4dfd897e12e79db0c54d57ac593fdb9
parentc0621e5decc8bc2f9ff8ef7550bbad8582ad63a0
bpf: Check for integer overflow when using roundup_pow_of_two()

[ 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