Files
linux-rockchip/include/uapi/linux
Toke Høiland-Jørgensen 314dbee9fe bpf: Make sure internal and UAPI bpf_redirect flags don't overlap
[ Upstream commit 09d88791c7cd888d5195c84733caf9183dcfbd16 ]

The bpf_redirect_info is shared between the SKB and XDP redirect paths,
and the two paths use the same numeric flag values in the ri->flags
field (specifically, BPF_F_BROADCAST == BPF_F_NEXTHOP). This means that
if skb bpf_redirect_neigh() is used with a non-NULL params argument and,
subsequently, an XDP redirect is performed using the same
bpf_redirect_info struct, the XDP path will get confused and end up
crashing, which syzbot managed to trigger.

With the stack-allocated bpf_redirect_info, the structure is no longer
shared between the SKB and XDP paths, so the crash doesn't happen
anymore. However, different code paths using identically-numbered flag
values in the same struct field still seems like a bit of a mess, so
this patch cleans that up by moving the flag definitions together and
redefining the three flags in BPF_F_REDIRECT_INTERNAL to not overlap
with the flags used for XDP. It also adds a BUILD_BUG_ON() check to make
sure the overlap is not re-introduced by mistake.

Fixes: e624d4ed4a ("xdp: Extend xdp_redirect_map with broadcast support")
Reported-by: syzbot+cca39e6e84a367a7e6f6@syzkaller.appspotmail.com
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Closes: https://syzkaller.appspot.com/bug?extid=cca39e6e84a367a7e6f6
Link: https://lore.kernel.org/bpf/20240920125625.59465-1-toke@redhat.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-01 01:55:56 +01:00
..
2022-09-15 09:08:09 +02:00
2022-08-11 10:31:19 -07:00
2022-06-07 10:20:42 -07:00
2022-08-23 14:54:54 -05:00
2024-09-12 11:10:30 +02:00
2022-08-10 13:49:50 +01:00
2023-11-02 09:35:28 +01:00
2022-06-03 20:09:27 +08:00
2022-09-20 09:13:38 +02:00
2022-09-29 18:43:04 +02:00
2022-09-07 16:46:03 +02:00
2024-04-27 17:07:11 +02:00
2022-09-20 09:13:38 +02:00
2024-10-17 15:21:27 +02:00
2023-09-13 09:42:53 +02:00
2022-09-27 17:29:09 -07:00
2022-08-11 04:31:15 -04:00