From: Pablo Neira Ayuso <pablo@netfilter.org>
To: "Xiang Mei (Microsoft)" <xmei5@asu.edu>
Cc: Andrea Mayer <andrea.mayer@uniroma2.it>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Ryoga Saito <contact@proelbtn.com>,
AutonomousCodeSecurity@microsoft.com,
tgopinath@linux.microsoft.com, kys@microsoft.com
Subject: Re: [PATCH net] seg6: fix NULL deref in input_action_end_dx{4,6}_finish() after nf hook
Date: Thu, 23 Jul 2026 19:22:51 +0200 [thread overview]
Message-ID: <amJN67Vtl0atkj7H@chamomile> (raw)
In-Reply-To: <20260720204430.1886091-1-xmei5@asu.edu>
On Mon, Jul 20, 2026 at 08:44:29PM +0000, Xiang Mei (Microsoft) wrote:
> When nf_hooks_lwtunnel is enabled, the End.DX4/End.DX6 actions dispatch
> the decapsulated inner packet through the NF_INET_PRE_ROUTING hook chain
> with input_action_end_dx{4,6}_finish() as the okfn. Both functions read
> the lwtunnel state via orig_dst = skb_dst(skb) and dereference
> orig_dst->lwtstate.
>
> A hook in that chain can legitimately drop the dst: nf_nat_ipv{4,6}_in()
> calls skb_dst_drop(skb) when a DNAT rule rewrites the destination
> address, leaving skb_dst(skb) NULL. The okfn then dereferences a NULL
> orig_dst, causing a general protection fault and a panic (the fault
> happens in softirq NAPI receive context).
>
> Free the skb and bail out when the dst was dropped, instead of
> proceeding with a lost lwtunnel state.
>
> Oops: general protection fault, probably for non-canonical address...
> KASAN: null-ptr-deref in range [0x0000000000000080-0x0000000000000087]
> RIP: 0010:input_action_end_dx6_finish (net/ipv6/seg6_local.c:912)
> Call Trace:
> input_action_end_dx6 (net/ipv6/seg6_local.c:946)
> seg6_local_input_core (net/ipv6/seg6_local.c:1621)
> seg6_local_input (net/ipv6/seg6_local.c:1643)
> lwtunnel_input (net/core/lwtunnel.c:465)
> ipv6_rcv (net/ipv6/ip6_input.c:351)
> __netif_receive_skb_core.constprop.0 (net/core/dev.c:6165)
> Kernel panic - not syncing: Fatal exception in interrupt
>
> Fixes: 7a3f5b0de364 ("netfilter: add netfilter hooks to SRv6 data plane")
> Reported-by: AutonomousCodeSecurity@microsoft.com
> Signed-off-by: Xiang Mei (Microsoft) <xmei5@asu.edu>
> ---
> net/ipv6/seg6_local.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
> index 2b41e4c0dddd..45e66ba306ca 100644
> --- a/net/ipv6/seg6_local.c
> +++ b/net/ipv6/seg6_local.c
> @@ -909,6 +909,11 @@ static int input_action_end_dx6_finish(struct net *net, struct sock *sk,
> struct in6_addr *nhaddr = NULL;
> struct seg6_local_lwt *slwt;
>
> + if (!orig_dst) {
This should be:
if (!skb_valid_dst(orig_dst)) {
> + kfree_skb(skb);
> + return -EINVAL;
> + }
> +
> slwt = seg6_local_lwtunnel(orig_dst->lwtstate);
>
> /* The inner packet is not associated to any local interface,
> @@ -962,6 +967,11 @@ static int input_action_end_dx4_finish(struct net *net, struct sock *sk,
> struct iphdr *iph;
> __be32 nhaddr;
>
> + if (!orig_dst) {
Same here.
> + kfree_skb(skb);
> + return -EINVAL;
> + }
> +
> slwt = seg6_local_lwtunnel(orig_dst->lwtstate);
>
> iph = ip_hdr(skb);
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-07-23 17:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 20:44 [PATCH net] seg6: fix NULL deref in input_action_end_dx{4,6}_finish() after nf hook Xiang Mei (Microsoft)
2026-07-23 17:09 ` Jakub Kicinski
2026-07-24 13:11 ` Andrea Mayer
2026-07-28 21:49 ` Xiang Mei
2026-07-30 15:16 ` Andrea Mayer
2026-07-30 15:23 ` Pablo Neira Ayuso
2026-07-30 22:50 ` Andrea Mayer
2026-07-28 21:16 ` Xiang Mei
2026-07-23 17:22 ` Pablo Neira Ayuso [this message]
2026-07-28 21:18 ` Xiang Mei
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=amJN67Vtl0atkj7H@chamomile \
--to=pablo@netfilter.org \
--cc=AutonomousCodeSecurity@microsoft.com \
--cc=andrea.mayer@uniroma2.it \
--cc=contact@proelbtn.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tgopinath@linux.microsoft.com \
--cc=xmei5@asu.edu \
/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