]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Change size to u64 for bpf_map_{area_alloc, charge_init}()
authorBjörn Töpel <bjorn.topel@intel.com>
Tue, 29 Oct 2019 15:43:07 +0000 (16:43 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 31 Oct 2019 20:41:33 +0000 (21:41 +0100)
commit4c5c8b78fcc6e37834deec53c5ebf6fec002afce
tree7d4474d2002747c76fcc5b312d60bbd59edd59f5
parent248a8e09eb3c74409573253ba3c276646030a336
bpf: Change size to u64 for bpf_map_{area_alloc, charge_init}()

The functions bpf_map_area_alloc() and bpf_map_charge_init() prior
this commit passed the size parameter as size_t. In this commit this
is changed to u64.

All users of these functions avoid size_t overflows on 32-bit systems,
by explicitly using u64 when calculating the allocation size and
memory charge cost. However, since the result was narrowed by the
size_t when passing size and cost to the functions, the overflow
handling was in vain.

Instead of changing all call sites to size_t and handle overflow at
the call site, the parameter is changed to u64 and checked in the
functions above.

Fixes: f432613492bd ("bpf: don't trigger OOM killer under pressure with map alloc")
Fixes: e650ab9e53b9 ("bpf: move memory size checks to bpf_map_charge_init()")
Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Link: https://lore.kernel.org/bpf/20191029154307.23053-1-bjorn.topel@gmail.com
include/linux/bpf.h
kernel/bpf/syscall.c