OpenCloudOS-Kernel/kernel/bpf
Byeonguk Jeong 4dea7a47fa bpf: Fix out-of-bounds write in trie_get_next_key()
[ Upstream commit 13400ac8fb80c57c2bfb12ebd35ee121ce9b4d21 ]

trie_get_next_key() allocates a node stack with size trie->max_prefixlen,
while it writes (trie->max_prefixlen + 1) nodes to the stack when it has
full paths from the root to leaves. For example, consider a trie with
max_prefixlen is 8, and the nodes with key 0x00/0, 0x00/1, 0x00/2, ...
0x00/8 inserted. Subsequent calls to trie_get_next_key with _key with
.prefixlen = 8 make 9 nodes be written on the node stack with size 8.

Fixes: b471f2f1de ("bpf: implement MAP_GET_NEXT_KEY command for LPM_TRIE map")
Signed-off-by: Byeonguk Jeong <jungbu2855@gmail.com>
Reviewed-by: Toke Høiland-Jørgensen <toke@kernel.org>
Tested-by: Hou Tao <houtao1@huawei.com>
Acked-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/Zxx384ZfdlFYnz6J@localhost.localdomain
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
2024-11-27 15:13:06 +08:00
..
Makefile ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
arraymap.c bpf: Check percpu map value size first 2024-11-27 15:13:06 +08:00
bpf_inode_storage.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
bpf_iter.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
bpf_local_storage.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
bpf_lru_list.c bpf: Address KCSAN report on bpf_lru_list 2024-11-27 15:13:06 +08:00
bpf_lru_list.h bpf: Address KCSAN report on bpf_lru_list 2024-11-27 15:13:06 +08:00
bpf_lsm.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
bpf_struct_ops.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
bpf_struct_ops_types.h ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
btf.c tkernel: sync code to the same with tk4 pub/lts/0017-kabi 2024-06-12 13:13:20 +08:00
cgroup.c bpf: Don't EFAULT for getsockopt with optval=NULL 2024-11-27 15:13:05 +08:00
core.c tkernel: sync code to the same with tk4 pub/lts/0017-kabi 2024-06-12 13:13:20 +08:00
cpumap.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
devmap.c tkernel: sync code to the same with tk4 pub/lts/0017-kabi 2024-06-12 13:13:20 +08:00
disasm.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
disasm.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 295 2019-06-05 17:36:38 +02:00
dispatcher.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
hashtab.c bpf: Check percpu map value size first 2024-11-27 15:13:06 +08:00
helpers.c tkernel: sync code to the same with tk4 pub/lts/0017-kabi 2024-06-12 13:13:20 +08:00
inode.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
local_storage.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
lpm_trie.c bpf: Fix out-of-bounds write in trie_get_next_key() 2024-11-27 15:13:06 +08:00
map_in_map.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
map_in_map.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 206 2019-05-30 11:29:53 -07:00
map_iter.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
net_namespace.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
offload.c tkernel: add base tlinux kernel interfaces 2024-06-11 20:09:33 +08:00
percpu_freelist.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 206 2019-05-30 11:29:53 -07:00
percpu_freelist.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 206 2019-05-30 11:29:53 -07:00
prog_iter.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
queue_stack_maps.c bpf: Avoid deadlock when using queue and stack maps from NMI 2024-11-27 15:13:06 +08:00
reuseport_array.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
ringbuf.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
stackmap.c tkernel: sync code to the same with tk4 pub/lts/0017-kabi 2024-06-12 13:13:20 +08:00
syscall.c tkernel: sync code to the same with tk4 pub/lts/0017-kabi 2024-06-12 13:13:20 +08:00
sysfs_btf.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
task_iter.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
tnum.c tkernel: add base tlinux kernel interfaces 2024-06-11 20:09:33 +08:00
trampoline.c tkernel: sync code to the same with tk4 pub/lts/0017-kabi 2024-06-12 13:13:20 +08:00
verifier.c bpf: Fix precision tracking for BPF_ALU | BPF_TO_BE | BPF_END 2024-11-27 15:13:06 +08:00
xskmap.c ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00