]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
netfilter: revalidate bridge ports
authorFlorian Westphal <fw@strlen.de>
Tue, 2 Jun 2026 15:04:25 +0000 (17:04 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 10 Jun 2026 15:58:20 +0000 (17:58 +0200)
commitccb9fd4b87538ccf19ccff78ee26700526d94867
tree85002bc68f328b5d7c414d4157689881fa3d000f
parent4aacf509e537a711fa71bca9f234e5eb6968850e
netfilter: revalidate bridge ports

ebt_redirect_tg() dereferences br_port_get_rcu() return without a
NULL check, causing a kernel panic when the bridge port has been
removed between the original hook invocation and an NFQUEUE
reinject.

A mere NULL check isn't sufficient, however.  As sashiko review
points out userspace can not only remove the port from the bridge,
it could also place the device in a different virtual device, e.g.
macvlan.

If this happens, we must drop the packet, there is no way for us to
reinject it into the bridge path.

Switch to _upper API, we don't need the bridge port structure.
Also, this fix keeps another bug intact:

Both nfnetlink_log and nfnetlink_queue use CONFIG_BRIDGE_NETFILTER
too aggressive, which prevents certain logging features when queueing
in bridge family: NETFILTER_FAMILY_BRIDGE can be enabled while the old
CONFIG_BRIDGE_NETFILTER cruft is off.

Fixes tag is a common ancestor, this was always broken.

Fixes: f350a0a87374 ("bridge: use rx_handler_data pointer to store net_bridge_port pointer")
Reported-by: Ji'an Zhou <eilaimemedsnaimel@gmail.com>
Assisted-by: Claude:claude-sonnet-4-6
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/bridge/netfilter/ebt_dnat.c
net/bridge/netfilter/ebt_redirect.c
net/netfilter/nfnetlink_log.c
net/netfilter/nfnetlink_queue.c