]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net/sched: cls_bpf: reject dev-bound programs bound to a different device
authorJamal Hadi Salim <jhs@mojatatu.com>
Sun, 9 Aug 2026 09:44:18 +0000 (05:44 -0400)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 13 Aug 2026 09:08:39 +0000 (11:08 +0200)
commit120977e2c096deea4e866e4273be9220b957c29e
tree1a03859632a8800e49de9bbecf819e36b636bc4e
parent2bb155e92167cd5ad6aae312e83291da2454f8b0
net/sched: cls_bpf: reject dev-bound programs bound to a different device

cls_bpf_prog_from_efd() obtained a SCHED_CLS program via
bpf_prog_get_type_dev() but never verified that a device-bound (offloaded)
program's bound netdev matches the TC netdev the classifier is being
attached to. This let a program loaded with prog_ifindex for device A be
attached via cls_bpf + skip_sw to device B; deleting device A then
destroyed the program's offload state while it was still attached to
device B, triggering a netdevsim WARN (panic with panic_on_warn=1).

Mirror the XDP attach path (net/core/dev.c) and reject the attach with
-EINVAL when a dev-bound program's bound device does not match the
target device.

Fixes: 2b3486bc2d23 ("bpf: Introduce device-bound XDP programs")
Reported-by: vega@nebusec.ai
Tested-by: Victor Nogueira <victor@mojatatu.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://patch.msgid.link/20260809094418.901607-1-jhs@mojatatu.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/sched/cls_bpf.c