Skip to content

Commit c2f8030

Browse files
Hou Taoanakryiko
authored andcommitted
bpf: Add the missing BPF_LINK_TYPE invocation for sockmap
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: 699c23f ("bpf: Add bpf_link support for sk_msg and sk_skb progs") Signed-off-by: Hou Tao <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 9806f28 commit c2f8030

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

include/linux/bpf_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ BPF_LINK_TYPE(BPF_LINK_TYPE_XDP, xdp)
146146
BPF_LINK_TYPE(BPF_LINK_TYPE_NETFILTER, netfilter)
147147
BPF_LINK_TYPE(BPF_LINK_TYPE_TCX, tcx)
148148
BPF_LINK_TYPE(BPF_LINK_TYPE_NETKIT, netkit)
149+
BPF_LINK_TYPE(BPF_LINK_TYPE_SOCKMAP, sockmap)
149150
#endif
150151
#ifdef CONFIG_PERF_EVENTS
151152
BPF_LINK_TYPE(BPF_LINK_TYPE_PERF_EVENT, perf)

include/uapi/linux/bpf.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,9 @@ enum bpf_attach_type {
11211121

11221122
#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
11231123

1124+
/* Add BPF_LINK_TYPE(type, name) in bpf_types.h to keep bpf_link_type_strs[]
1125+
* in sync with the definitions below.
1126+
*/
11241127
enum bpf_link_type {
11251128
BPF_LINK_TYPE_UNSPEC = 0,
11261129
BPF_LINK_TYPE_RAW_TRACEPOINT = 1,

tools/include/uapi/linux/bpf.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,9 @@ enum bpf_attach_type {
11211121

11221122
#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
11231123

1124+
/* Add BPF_LINK_TYPE(type, name) in bpf_types.h to keep bpf_link_type_strs[]
1125+
* in sync with the definitions below.
1126+
*/
11241127
enum bpf_link_type {
11251128
BPF_LINK_TYPE_UNSPEC = 0,
11261129
BPF_LINK_TYPE_RAW_TRACEPOINT = 1,

0 commit comments

Comments
 (0)