* [PATCH net] seg6: fix NULL deref in input_action_end_dx{4,6}_finish() after nf hook
@ 2026-07-20 20:44 Xiang Mei (Microsoft)
2026-07-23 17:09 ` Jakub Kicinski
2026-07-23 17:22 ` Pablo Neira Ayuso
0 siblings, 2 replies; 3+ messages in thread
From: Xiang Mei (Microsoft) @ 2026-07-20 20:44 UTC (permalink / raw)
To: Andrea Mayer, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman
Cc: netdev, linux-kernel, Pablo Neira Ayuso, Ryoga Saito,
AutonomousCodeSecurity, tgopinath, kys, Xiang Mei (Microsoft)
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) {
+ 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) {
+ kfree_skb(skb);
+ return -EINVAL;
+ }
+
slwt = seg6_local_lwtunnel(orig_dst->lwtstate);
iph = ip_hdr(skb);
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] seg6: fix NULL deref in input_action_end_dx{4,6}_finish() after nf hook
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-23 17:22 ` Pablo Neira Ayuso
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2026-07-23 17:09 UTC (permalink / raw)
To: Xiang Mei (Microsoft)
Cc: Andrea Mayer, David S . Miller, Eric Dumazet, Paolo Abeni,
Simon Horman, netdev, linux-kernel, Pablo Neira Ayuso,
Ryoga Saito, AutonomousCodeSecurity, tgopinath, kys
On Mon, 20 Jul 2026 20:44:29 +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.
Per Sashiko's feedback - we need to validate not only that the dst
is there but also that it is of the expected type, no?
--
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] seg6: fix NULL deref in input_action_end_dx{4,6}_finish() after nf hook
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-23 17:22 ` Pablo Neira Ayuso
1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2026-07-23 17:22 UTC (permalink / raw)
To: Xiang Mei (Microsoft)
Cc: Andrea Mayer, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, netdev, linux-kernel, Ryoga Saito,
AutonomousCodeSecurity, tgopinath, kys
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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-23 17:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-23 17:22 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox