]> www.infradead.org Git - users/jedix/linux-maple.git/commit
net: xdp: Disallow attaching device-bound programs in generic mode
authorToke Høiland-Jørgensen <toke@redhat.com>
Mon, 27 Jan 2025 13:13:42 +0000 (14:13 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 30 Jan 2025 03:04:23 +0000 (19:04 -0800)
commit3595599fa8360bb3c7afa7ee50c810b4a64106ea
tree29bafb9277c7a37472b0c274620d3d64fd77f465
parent8c670bdfa58e48abad1d5b6ca1ee843ca91f7303
net: xdp: Disallow attaching device-bound programs in generic mode

Device-bound programs are used to support RX metadata kfuncs. These
kfuncs are driver-specific and rely on the driver context to read the
metadata. This means they can't work in generic XDP mode. However, there
is no check to disallow such programs from being attached in generic
mode, in which case the metadata kfuncs will be called in an invalid
context, leading to crashes.

Fix this by adding a check to disallow attaching device-bound programs
in generic mode.

Fixes: 2b3486bc2d23 ("bpf: Introduce device-bound XDP programs")
Reported-by: Marcus Wichelmann <marcus.wichelmann@hetzner-cloud.de>
Closes: https://lore.kernel.org/r/dae862ec-43b5-41a0-8edf-46c59071cdda@hetzner-cloud.de
Tested-by: Marcus Wichelmann <marcus.wichelmann@hetzner-cloud.de>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://patch.msgid.link/20250127131344.238147-1-toke@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/dev.c