android_kernel_motorola_sm6375/kernel/bpf
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Yuntao Wang 93c0f9d78d bpf: Fix excessive memory allocation in stack_map_alloc()
[ Upstream commit b45043192b3e481304062938a6561da2ceea46a6 ]

The 'n_buckets * (value_size + sizeof(struct stack_map_bucket))' part of the
allocated memory for 'smap' is never used after the memlock accounting was
removed, thus get rid of it.

[ Note, Daniel:

Commit b936ca643a ("bpf: rework memlock-based memory accounting for maps")
moved `cost += n_buckets * (value_size + sizeof(struct stack_map_bucket))`
up and therefore before the bpf_map_area_alloc() allocation, sigh. In a later
step commit c85d69135a ("bpf: move memory size checks to bpf_map_charge_init()"),
and the overflow checks of `cost >= U32_MAX - PAGE_SIZE` moved into
bpf_map_charge_init(). And then 370868107bf6 ("bpf: Eliminate rlimit-based
memory accounting for stackmap maps") finally removed the bpf_map_charge_init().
Anyway, the original code did the allocation same way as /after/ this fix. ]

Fixes: b936ca643a ("bpf: rework memlock-based memory accounting for maps")
Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20220407130423.798386-1-ytcoode@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-06-14 18:11:32 +02:00
..
arraymap.c
bpf_lru_list.c bpf_lru_list: Read double-checked variable once without lock 2021-03-04 10:26:16 +01:00
bpf_lru_list.h
btf.c
cgroup.c bpf, cgroup: Fix problematic bounds check 2021-02-10 09:25:27 +01:00
core.c bpf: Prevent increasing bpf_jit_limit above max 2021-11-17 09:48:20 +01:00
cpumap.c
devmap.c bpf: Fix integer overflow in argument calculation for bpf_map_area_alloc 2021-12-17 10:12:24 +01:00
disasm.c bpf: Introduce BPF nospec instruction for mitigating Spectre v4 2021-09-15 09:47:38 +02:00
disasm.h
hashtab.c
helpers.c bpf: Fix helper bpf_map_peek_elem_proto pointing to wrong callback 2021-01-23 15:57:56 +01:00
inode.c
local_storage.c
lpm_trie.c
Makefile
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 bpf: Fix excessive memory allocation in stack_map_alloc() 2022-06-14 18:11:32 +02:00
syscall.c bpf: Add kconfig knob for disabling unpriv bpf by default 2022-02-16 12:52:49 +01:00
sysfs_btf.c
tnum.c
verifier.c bpf: Fix the off-by-two error in range markings 2021-12-14 14:48:59 +01:00
xskmap.c