]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf: Check validity of link->type in bpf_link_show_fdinfo()
authorHou Tao <houtao1@huawei.com>
Fri, 27 Dec 2024 06:04:35 +0000 (14:04 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Jan 2025 09:30:53 +0000 (10:30 +0100)
commit4e8074bb33d18f56af30a0252cb3606d27eb1c13
treef371c26bf767cc342c6e396538c3028ad58d9916
parentdb84cb4c8c565e6d4de84b23c2818b63991adfdd
bpf: Check validity of link->type in bpf_link_show_fdinfo()

commit 8421d4c8762bd022cb491f2f0f7019ef51b4f0a7 upstream.

If a newly-added link type doesn't invoke BPF_LINK_TYPE(), accessing
bpf_link_type_strs[link->type] may result in an out-of-bounds access.

To spot such missed invocations early in the future, checking the
validity of link->type in bpf_link_show_fdinfo() and emitting a warning
when such invocations are missed.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20241024013558.1135167-3-houtao@huaweicloud.com
[ shung-hsi.yu: break up existing seq_printf() call since commit 68b04864ca42
  ("bpf: Create links for BPF struct_ops maps.") is not present ]
Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/syscall.c