]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Fix integer overflow in argument calculation for bpf_map_area_alloc
authorBui Quang Minh <minhquangbui99@gmail.com>
Sun, 13 Jun 2021 14:34:39 +0000 (21:34 +0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 22 Jun 2021 17:14:29 +0000 (10:14 -0700)
commitc2b208c2838f72f42b4cc7dd347c9129c07b42aa
tree15bd18fdc23176c4b1cc3bef90042a8a068dd22a
parent25478176f61ee06153e79653edc8d5a66f4891ec
bpf: Fix integer overflow in argument calculation for bpf_map_area_alloc

In 32-bit architecture, the result of sizeof() is a 32-bit integer so
the expression becomes the multiplication between 2 32-bit integer which
can potentially leads to integer overflow. As a result,
bpf_map_area_alloc() allocates less memory than needed.

Fix this by casting 1 operand to u64.

Fixes: 1686c1024e50 ("bpf: Eliminate rlimit-based memory accounting for sockmap and sockhash maps")
Fixes: 3f1777e4693a ("devmap: Use bpf_map_area_alloc() for allocating hash buckets")
Fixes: a6dd72d34c12 ("bpf: add devmap, a map for storing net device references")
Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210613143440.71975-1-minhquangbui99@gmail.com
kernel/bpf/devmap.c
net/core/sock_map.c