All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steffen Klassert <steffen.klassert@secunet.com>
To: Kyuwon Cho <kyuwoncho18@gmail.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>, <netdev@vger.kernel.org>,
	<ipsec@lists.linux.dev>, <linux-kernel@vger.kernel.org>
Subject: Re: [BUG] xfrm: ESP SA in route optimization mode hits WARN_ON_ONCE in xfrm_state_mtu() and xfrm_input()
Date: Tue, 24 Nov 2026 07:17:52 +0100	[thread overview]
Message-ID: <awUsEE7XZIFwc0Ws@gauss4> (raw)
In-Reply-To: <179493154245.3969421.1349059390749040254@gmail.com>

On Tue, Nov 17, 2026 at 08:05:46AM -0800, Kyuwon Cho wrote:
> Hi Steffen, Herbert,
> 
> While testing v7.4-rc3 with an LLM-guided test generator that we are
> developing as a research prototype, we found that XFRM_MSG_NEWSA accepts
> an ESP state with mode XFRM_MODE_ROUTEOPTIMIZATION, and that one packet
> through it hits two WARN_ON_ONCE()s. An unprivileged user can do this
> from its own user and network namespace. Sending the packet:
> 
>   WARNING: net/xfrm/xfrm_state.c:3264 at xfrm_state_mtu+0x239/0x3d0, CPU#1: test/107
>   CPU: 1 UID: 65534 PID: 107 Comm: test Not tainted 7.4.0-rc3 #1 PREEMPT(lazy) 
>   RIP: 0010:xfrm_state_mtu+0x239/0x3d0
>   Call Trace:
>    <TASK>
>    xfrm_bundle_create+0x1560/0x2340
>    xfrm_resolve_and_create_bundle+0x158/0x2d0
>    xfrm_lookup_with_ifid+0x483/0x18e0
>    xfrm_lookup_route+0x1e/0x180
>    ip6_dst_lookup_flow+0x196/0x1e0
>    udpv6_sendmsg+0x163b/0x2d70
>    __sys_sendto+0x2b1/0x3c0
>    __x64_sys_sendto+0xdb/0x1b0
>    do_syscall_64+0x116/0x630
>    entry_SYSCALL_64_after_hwframe+0x77/0x7f
>    </TASK>
> 
> and receiving it:
> 
>   WARNING: net/xfrm/xfrm_input.c:449 at xfrm_input+0x2176/0x5f50, CPU#1: test/107
>   CPU: 1 UID: 65534 PID: 107 Comm: test Tainted: G        W           7.4.0-rc3 #1 PREEMPT(lazy) 
>   RIP: 0010:xfrm_input+0x2176/0x5f50
>   Call Trace:
>    <IRQ>
>    xfrm6_esp_rcv+0x83/0x1c0
>    ip6_protocol_deliver_rcu+0xc71/0x13d0
>    ip6_input_finish+0x192/0x3f0
>    ip6_input+0xcb/0x220
>    __netif_receive_skb_one_core+0x114/0x1b0
>    process_backlog+0x3c6/0x12c0
>    __napi_poll.constprop.0+0x9c/0x5c0
>    net_rx_action+0x48e/0xe30
>    handle_softirqs+0x22d/0x980
>    do_softirq+0x43/0xa0
>    </IRQ>
> 
> verify_newsa_info() accepts XFRM_MODE_ROUTEOPTIMIZATION for any
> protocol; only IP-TFS is limited to ESP. esp6_init_state() treats every
> mode other than BEET and TUNNEL as transport:
> 
> 	switch (x->props.mode) {
> 	case XFRM_MODE_BEET:
> 		...
> 	default:
> 	case XFRM_MODE_TRANSPORT:
> 		break;
> 
> so the state is created. The ESP paths then reach code that assumes
> route optimization never comes with ESP. xfrm_state_mtu() has no case
> for it and falls to:
> 
> 	default:
> 		if (x->mode_cbs && x->mode_cbs->get_inner_mtu)
> 			return x->mode_cbs->get_inner_mtu(x, mtu);
> 
> 		WARN_ON_ONCE(1);
> 
> and xfrm_inner_mode_input() has
> 
> 	case XFRM_MODE_ROUTEOPTIMIZATION:
> 		WARN_ON_ONCE(1);
> 		break;
> 
> The packet is dropped on input, so the effect is the warnings, which
> panic a machine with panic_on_warn. Both WARN_ON_ONCE()s date from the
> 2019 xfrm mode cleanup (c2d305e51038, c7b37c769d2a).
> 
> Accepting XFRM_MODE_ROUTEOPTIMIZATION only for the Mobile IPv6 types
> (IPPROTO_ROUTING and IPPROTO_DSTOPTS) in verify_newsa_info(), as it
> already limits IP-TFS to ESP, or rejecting it in esp6_init_state()
> (route optimization exists only for IPv6 states), should avoid it. We
> have not tested either change.

I think adding a guard to verify_newsa_info() makes sense. Can you
submit a fix?

Thanks!


      reply	other threads:[~2026-11-24  6:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 16:05 [BUG] xfrm: ESP SA in route optimization mode hits WARN_ON_ONCE in xfrm_state_mtu() and xfrm_input() Kyuwon Cho
2026-11-24  6:17 ` Steffen Klassert [this message]

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=awUsEE7XZIFwc0Ws@gauss4 \
    --to=steffen.klassert@secunet.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=horms@kernel.org \
    --cc=ipsec@lists.linux.dev \
    --cc=kuba@kernel.org \
    --cc=kyuwoncho18@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.