]> www.infradead.org Git - linux.git/commit
bpf: Add bpf_mem_alloc_check_size() helper
authorHou Tao <houtao1@huawei.com>
Wed, 30 Oct 2024 10:05:13 +0000 (18:05 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 30 Oct 2024 19:13:46 +0000 (12:13 -0700)
commit62a898b07b83f6f407003d8a70f0827a5af08a59
treee101cca91dec00f46cc3a9e4aaeaf8cb6a451ca1
parent101ccfbabf4738041273ce64e2b116cf440dea13
bpf: Add bpf_mem_alloc_check_size() helper

Introduce bpf_mem_alloc_check_size() to check whether the allocation
size exceeds the limitation for the kmalloc-equivalent allocator. The
upper limit for percpu allocation is LLIST_NODE_SZ bytes larger than
non-percpu allocation, so a percpu argument is added to the helper.

The helper will be used in the following patch to check whether the size
parameter passed to bpf_mem_alloc() is too big.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20241030100516.3633640-3-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/bpf_mem_alloc.h
kernel/bpf/memalloc.c