bpf: Add missed allocation hint for bpf_mem_cache_alloc_flags()
authorHou Tao <houtao1@huawei.com>
Sat, 11 Nov 2023 04:38:21 +0000 (12:38 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 27 Nov 2023 02:00:26 +0000 (18:00 -0800)
commit75a442581d05edaee168222ffbe00d4389785636
tree6e7f8564ef1db21b3c0ab3e335142df1d53a6065
parentc0c6bde586c7dce82719b4ff32a2db6af9ee3d65
bpf: Add missed allocation hint for bpf_mem_cache_alloc_flags()

bpf_mem_cache_alloc_flags() may call __alloc() directly when there is no
free object in free list, but it doesn't initialize the allocation hint
for the returned pointer. It may lead to bad memory dereference when
freeing the pointer, so fix it by initializing the allocation hint.

Fixes: 822fb26bdb55 ("bpf: Add a hint to allocated objects.")
Signed-off-by: Hou Tao <houtao1@huawei.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20231111043821.2258513-1-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/memalloc.c