]> git.proxmox.com Git - mirror_ubuntu-kernels.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)
commitff1c08e1f74b6864854c39be48aa799a6a2e4d2b
tree7d4474d2002747c76fcc5b312d60bbd59edd59f5
parent04ec044b7d30800296824783df7d9728d16d7567
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: d407bd25a204 ("bpf: don't trigger OOM killer under pressure with map alloc")
Fixes: c85d69135a91 ("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