kernel_optimize_test/kernel/bpf
Björn Töpel ff1c08e1f7 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: d407bd25a2 ("bpf: don't trigger OOM killer under pressure with map alloc")
Fixes: c85d69135a ("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
2019-10-31 21:41:33 +01:00
..
arraymap.c
bpf_lru_list.c
bpf_lru_list.h
btf.c bpf: Clean up indentation issue in BTF kflag processing 2019-09-26 17:09:18 +02:00
cgroup.c bpf: Allow narrow loads of bpf_sysctl fields with offset > 0 2019-10-30 12:49:13 -07:00
core.c bpf: Fix use after free in subprog's jited symbol removal 2019-10-22 11:26:09 -07:00
cpumap.c
devmap.c xdp: Handle device unregister for devmap_hash map type 2019-10-21 15:51:41 -07:00
disasm.c
disasm.h
hashtab.c
helpers.c
inode.c vfs: Convert bpf to use the new mount API 2019-09-18 22:35:31 -04:00
local_storage.c
lpm_trie.c
Makefile btf: expose BTF info through sysfs 2019-08-13 16:14:15 +02:00
map_in_map.c
map_in_map.h
offload.c
percpu_freelist.c
percpu_freelist.h
queue_stack_maps.c
reuseport_array.c
stackmap.c
syscall.c bpf: Change size to u64 for bpf_map_{area_alloc, charge_init}() 2019-10-31 21:41:33 +01:00
sysfs_btf.c btf: fix return value check in btf_vmlinux_init() 2019-08-15 22:18:17 -07:00
tnum.c
verifier.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next 2019-09-16 16:02:03 +02:00
xskmap.c bpf/xskmap: Return ERR_PTR for failure case instead of NULL. 2019-09-25 22:14:16 +02:00