]> www.infradead.org Git - linux.git/commitdiff
bpf: Add the missing BPF_LINK_TYPE invocation for sockmap
authorHou Tao <houtao1@huawei.com>
Thu, 24 Oct 2024 01:35:57 +0000 (09:35 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 24 Oct 2024 17:17:12 +0000 (10:17 -0700)
There is an out-of-bounds read in bpf_link_show_fdinfo() for the sockmap
link fd. Fix it by adding the missing BPF_LINK_TYPE invocation for
sockmap link

Also add comments for bpf_link_type to prevent missing updates in the
future.

Fixes: 699c23f02c65 ("bpf: Add bpf_link support for sk_msg and sk_skb progs")
Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20241024013558.1135167-2-houtao@huaweicloud.com
include/linux/bpf_types.h
include/uapi/linux/bpf.h
tools/include/uapi/linux/bpf.h

index 9f2a6b83b49e144782f036f023f61b7674ad3ba7..fa78f49d4a9a640deb19376eaafe77cfe00420e1 100644 (file)
@@ -146,6 +146,7 @@ BPF_LINK_TYPE(BPF_LINK_TYPE_XDP, xdp)
 BPF_LINK_TYPE(BPF_LINK_TYPE_NETFILTER, netfilter)
 BPF_LINK_TYPE(BPF_LINK_TYPE_TCX, tcx)
 BPF_LINK_TYPE(BPF_LINK_TYPE_NETKIT, netkit)
+BPF_LINK_TYPE(BPF_LINK_TYPE_SOCKMAP, sockmap)
 #endif
 #ifdef CONFIG_PERF_EVENTS
 BPF_LINK_TYPE(BPF_LINK_TYPE_PERF_EVENT, perf)
index e8241b320c6d9ab3647ad7855c6949130866b97e..4a939c90dc2e4bce8c48212161d782acb4cb73a7 100644 (file)
@@ -1121,6 +1121,9 @@ enum bpf_attach_type {
 
 #define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
 
+/* Add BPF_LINK_TYPE(type, name) in bpf_types.h to keep bpf_link_type_strs[]
+ * in sync with the definitions below.
+ */
 enum bpf_link_type {
        BPF_LINK_TYPE_UNSPEC = 0,
        BPF_LINK_TYPE_RAW_TRACEPOINT = 1,
index e8241b320c6d9ab3647ad7855c6949130866b97e..4a939c90dc2e4bce8c48212161d782acb4cb73a7 100644 (file)
@@ -1121,6 +1121,9 @@ enum bpf_attach_type {
 
 #define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
 
+/* Add BPF_LINK_TYPE(type, name) in bpf_types.h to keep bpf_link_type_strs[]
+ * in sync with the definitions below.
+ */
 enum bpf_link_type {
        BPF_LINK_TYPE_UNSPEC = 0,
        BPF_LINK_TYPE_RAW_TRACEPOINT = 1,