Skip to contentSkip to conversation

bpf: Add missing BPF_LINK_TYPE invocations

PATCH In review Ignat Korchagin 2 participants 2 messages May 21, 2024 – May 23, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: Add missing BPF_LINK_TYPE invocations

From: Jiri Olsa <[email protected]>

commit 117211aa739a926e6555cfea883be84bee6f1695 upstream.

Pengfei Xu reported [1] Syzkaller/KASAN issue found in bpf_link_show_fdinfo.

The reason is missing BPF_LINK_TYPE invocation for uprobe multi link and for several other links, adding that.

[1] https://lore.kernel.org/bpf/[email protected]/

Fixes 89ae89f53d20 ("bpf: Add multi uprobe link")
Fixes e420bed02507 ("bpf: Add fd-based tcx multi-prog infra with link support")
Fixes 84601d6ee68a ("bpf: add bpf_link support for BPF_NETFILTER programs")
Fixes 35dfaad7188c ("netkit, bpf: Add bpf programmable net device")

---
Hi,

We have experienced a KASAN warning in production on a 6.6 kernel, similar to [1]. This backported patch was adjusted to apply onto 6.6 stable branch: the only change is dropping the BPF_LINK_TYPE(BPF_LINK_TYPE_NETKIT, netkit) definition from the header as netkit was only introduced in 6.7 and 6.7 has the backport already.

I was not able to run the syzkaller reproducer from [1], but we have not seen the KASAN warning in production since applying this patch internally.

Regards,
Ignat

 include/linux/bpf_types.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/bpf_types.h +3 -0
index fc0d6f32c687..dfaae3e3ec15 100644
@@ -142,9 +142,12 @@ BPF_LINK_TYPE(BPF_LINK_TYPE_ITER, iter)
 #ifdef CONFIG_NET
 BPF_LINK_TYPE(BPF_LINK_TYPE_NETNS, netns)
 BPF_LINK_TYPE(BPF_LINK_TYPE_XDP, xdp)
+BPF_LINK_TYPE(BPF_LINK_TYPE_NETFILTER, netfilter)
+BPF_LINK_TYPE(BPF_LINK_TYPE_TCX, tcx)
 #endif
 #ifdef CONFIG_PERF_EVENTS
 BPF_LINK_TYPE(BPF_LINK_TYPE_PERF_EVENT, perf)
 #endif
 BPF_LINK_TYPE(BPF_LINK_TYPE_KPROBE_MULTI, kprobe_multi)
 BPF_LINK_TYPE(BPF_LINK_TYPE_STRUCT_OPS, struct_ops)
+BPF_LINK_TYPE(BPF_LINK_TYPE_UPROBE_MULTI, uprobe_multi)
Signature · 1 line
2.39.2
#1 lore raw
Quoted 26 lines · Ignat Korchagin

From: Jiri Olsa <[email protected]>

commit 117211aa739a926e6555cfea883be84bee6f1695 upstream.

Pengfei Xu reported [1] Syzkaller/KASAN issue found in bpf_link_show_fdinfo.

The reason is missing BPF_LINK_TYPE invocation for uprobe multi link and for several other links, adding that.

[1] https://lore.kernel.org/bpf/[email protected]/

Fixes 89ae89f53d20 ("bpf: Add multi uprobe link")
Fixes e420bed02507 ("bpf: Add fd-based tcx multi-prog infra with link support")
Fixes 84601d6ee68a ("bpf: add bpf_link support for BPF_NETFILTER programs")
Fixes 35dfaad7188c ("netkit, bpf: Add bpf programmable net device")

---
Hi,

Quoted 8 lines

We have experienced a KASAN warning in production on a 6.6 kernel, similar to [1]. This backported patch was adjusted to apply onto 6.6 stable branch: the only change is dropping the BPF_LINK_TYPE(BPF_LINK_TYPE_NETKIT, netkit) definition from the header as netkit was only introduced in 6.7 and 6.7 has the backport already.

I was not able to run the syzkaller reproducer from [1], but we have not seen the KASAN warning in production since applying this patch internally.

Looks good, thanks for the backport, now queued up.

greg k-h