From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>, Hacking <eilaimemedsnaimel@gmail.com>
Subject: [PATCH nf] netfilter: bridge: ebt_redirect: don't assume bridge port exists
Date: Mon, 1 Jun 2026 11:50:00 +0200 [thread overview]
Message-ID: <20260601095000.595383-1-fw@strlen.de> (raw)
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.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: Hacking <eilaimemedsnaimel@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/bridge/netfilter/ebt_redirect.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/net/bridge/netfilter/ebt_redirect.c b/net/bridge/netfilter/ebt_redirect.c
index 307790562b49..379662961aeb 100644
--- a/net/bridge/netfilter/ebt_redirect.c
+++ b/net/bridge/netfilter/ebt_redirect.c
@@ -20,16 +20,25 @@ static unsigned int
ebt_redirect_tg(struct sk_buff *skb, const struct xt_action_param *par)
{
const struct ebt_redirect_info *info = par->targinfo;
+ const unsigned char *dev_addr;
if (skb_ensure_writable(skb, 0))
return EBT_DROP;
- if (xt_hooknum(par) != NF_BR_BROUTING)
- /* rcu_read_lock()ed by nf_hook_thresh */
- ether_addr_copy(eth_hdr(skb)->h_dest,
- br_port_get_rcu(xt_in(par))->br->dev->dev_addr);
- else
- ether_addr_copy(eth_hdr(skb)->h_dest, xt_in(par)->dev_addr);
+ if (xt_hooknum(par) != NF_BR_BROUTING) {
+ const struct net_bridge_port *port;
+
+ port = br_port_get_rcu(xt_in(par));
+ if (!port)
+ return EBT_DROP;
+
+ dev_addr = port->br->dev->dev_addr;
+ } else {
+ dev_addr = xt_in(par)->dev_addr;
+ }
+
+ ether_addr_copy(eth_hdr(skb)->h_dest, dev_addr);
+
skb->pkt_type = PACKET_HOST;
return info->target;
}
--
2.54.0
next reply other threads:[~2026-06-01 9:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 9:50 Florian Westphal [this message]
2026-06-01 10:29 ` [PATCH nf] netfilter: bridge: ebt_redirect: don't assume bridge port exists Pablo Neira Ayuso
2026-06-01 10:31 ` Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260601095000.595383-1-fw@strlen.de \
--to=fw@strlen.de \
--cc=eilaimemedsnaimel@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox