]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
netfilter: nft_fib: reject fib expression on the netdev egress hook
authorTheodor Arsenij Larionov-Trichkine <theodorlarionov@gmail.com>
Mon, 29 Jun 2026 10:53:11 +0000 (12:53 +0200)
committerFlorian Westphal <fw@strlen.de>
Tue, 30 Jun 2026 04:37:12 +0000 (06:37 +0200)
commitd07955dd34ecae17d35d8c7d0a273a3fba653a8c
tree68fd828631652f8e206adb5b9c8df7feb338765e
parentbf5355cfdede3e30b30e63a5a74f6bdaafb26082
netfilter: nft_fib: reject fib expression on the netdev egress hook

A fib expression in a netdev egress base chain dereferences nft_in(pkt),
NULL on the transmit path, causing a NULL pointer dereference at eval.
nft_fib_validate() masks the hook with NF_INET_* values, but netdev hook
numbers are a separate enum that aliases them (NF_NETDEV_EGRESS ==
NF_INET_LOCAL_IN), so an egress chain passes validation and then faults.

Add nft_fib_netdev_validate() that limits each result/flag to the netdev
hook where the device it reads exists: the input-device cases (OIF,
OIFNAME, ADDRTYPE with F_IIF) to ingress, the output-device case (ADDRTYPE
with F_OIF) to egress, ADDRTYPE with no device flag to both. Also restrict
nft_fib_validate() to NFPROTO_IPV4/IPV6/INET so its NF_INET_* masks are
not applied to another family's hooks.

Fixes: 42df6e1d221d ("netfilter: Introduce egress hook")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/netfilter-devel/ajxsjcDOnwllMfoR@strlen.de/
Signed-off-by: Theodor Arsenij Larionov-Trichkine <theodorlarionov@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/nft_fib.c
net/netfilter/nft_fib_netdev.c