🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21551

Re: [BUG] xfrm: ESP SA in route optimization mode hits WARN_ON_ONCE in xfrm_state_mtu() and xfrm_input()

#21551
From: Steffen Klassert
Date: Tue, 24 Nov 2026 06:17
87 lines
12416 bytes
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!
Technical Details
Message-ID: <awUsEE7XZIFwc0Ws@gauss4>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370046-linux-kernel-netdev=dewy.ru
References: <179493154245.3969421.1349059390749040254@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370046-linux-kernel-netdev=dewy.ru
From: steffen.klassert@secunet.com (Steffen Klassert)
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <awUsEE7XZIFwc0Ws@gauss4>
References: <179493154245.3969421.1349059390749040254@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Injection-Info: usenet.network;
	logging-data="4068805"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:n5KkpgAFSaq4SFHeHbh2PscZ0mI= sha256:MkHNr4sAQjHT8vuxgJvG+kbz0+/+9m81rtyFws/KYD8=
	sha1:ofQxkpQhHk7YSQXQZ6ftj8Soj6Y= sha256:m/DpffQF2CMhw2r9Wgq6R8PYSMMZpDhhw5P9Hcm7uYU=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id C3CE5125DD3; Tue, 24 Nov 2026 09:18:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=secunet.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id ug-u_rQfYVme;
	Tue, 24 Nov 2026 09:18:08 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-370046-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=secunet.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 4A78F125DCC; Tue, 24 Nov 2026 09:18:00 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id F0E713184E; Tue, 24 Nov 2026 06:17:58 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795501078;
	b=kgyZhHk+g/9y64syjZy+mPPjRf9qnHO//5yYx2IPFUI79ycdDDOaC22zgncXX37Cs/Gb
	 7bCoIQx3fE9cLj3KnoYZYVGsKnlI45RTE/8blM+ppzur4tn1Gh3gL0hH7mG3yZw+AqOzR
	 qh+DRBVV8j+XMT2PCuQdIBLG8hSRrKA8NTWjxIUA2kjGoZFV1No/H3eXbudbmJzCoQ8jR
	 5OAIJ16iwYjRvAOhEGestdrkSgF/m9n7mXBLLDtDneeIwcAaOpLoBWk1tTCaRgdB0z+9i
	 xKb44IwE2NsFwBfK8Lpb0QlHyax4o8gRY5zWjau68nbCw2UCoNZhBzI6STQbkfN5u2w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795501078;
	h=X-Original-To:Received:DMARC-Filter:Received:X-Virus-Scanned:
	 Received:Received:DKIM-Filter:DKIM-Signature:Received:Received:Date:
	 From:To:CC:Subject:Message-ID:References:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:
	 X-ClientProxiedBy;
	bh=Fns5KSeLA1lAqdtuoDUdCMp8WJ8wrSCmXQUe1et8xFI=;
	b=bEkals9Uyg/fzQMbwCuOt3AaCCAmeGIu5nB59JAtVsruSXKYgJpKJV5REmucptLb7P3k
	 GnEClbocWcxAzuUmiQxpHJtdnvl9+NS8GFKEsVxlcbovL0ghCB51i9iTfNuC/kbV5DG4Y
	 z3CMAHeM1bomG5SMt3l6ujqCNhORS2c2P3NnfQHdhcaEEgnsEQwh5xFEBRknisurUwnoA
	 U1iVoLOLm/QMIfwBfXdFri7a2A+nXoSEm/sqB3wy4v/jXLRug5s+eS2Ma4u06dj/ObtLb
	 +8O0EX3y//tBp3aN7VuvqzRAkq3lOWwQWzUL3VBWLsRi11p3oTRDtWmqFT1GuTWBnGQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=CuMNmgBk;
	dmarc=pass header.from=secunet.com;
	spf=pass smtp.mailfrom=secunet.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 41B7F606A334;
	Tue, 24 Nov 2026 06:17:58 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=CuMNmgBk
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=62.96.220.36
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795501077;
	b=y17DMe6+4mCwogLvStZczhGe3uRWqjPJMN82e7crEG8TRYyJPtOZ8WfKa5Q7TTteDd/B
	 NTVneVWRJaNXGdjPAI8QOL3so00OhXZewoBu8qhqZKWUGYZS4OFSkA0KUQ8fnR5o3ML4z
	 BDi5cuaJcUfjkG61LeiVGx0P1MSn2Db05tzIkXbnlJMA0NjIP7PUGY19cTrwBCi5558DD
	 TeB4R/nLTPzQSpbevy6iCaDuA8n6fJVPwWcyAqPdbGXUafrh/wHYo2wyAUncAwwBN7YOU
	 Tpm4BunRHwbs8Ip5hjp4kXFXw0qeHyp3dU9OYITdFaI71aG1zps5fwXMUn/baOElUbA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795501077;
	h=DMARC-Filter:Received:X-Virus-Scanned:Received:Received:DKIM-Filter:
	 DKIM-Signature:Received:Received:Date:From:To:CC:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:
	 X-ClientProxiedBy;
	bh=Fns5KSeLA1lAqdtuoDUdCMp8WJ8wrSCmXQUe1et8xFI=;
	b=qHuJfeb+JirhuzX7H+573cDeeDRUggI4y+F3i2KOAQwzisgLexcol5a+i0kmiH/4/YO3
	 0eucuuL0QX3J3vHk9Tfl0U1Qud+eoAcfYW5ja96Qz9tAG2D3UiWOOnnux3PXZKAbQ4wRC
	 bwXY/bASJIthUss1KXQ2TEsXU1wr+GyPIuLawKS7GnL8wpp3TuJaJgIGfhrkMdKCAYHfe
	 LGHz+O0pADslJ9r4zcYGKDx0zKTiM4CwSoJBxmQL02/5SqUmP74YZNHYHKbKkdVEnVX/K
	 NzGz/UwUBtWGXrSoq4sSMRafrDjP8PSRLYtAXBmFcP2p3RuSj3JeA8kLqpf0soOBuqQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=secunet.com;
	spf=pass smtp.mailfrom=secunet.com;
	dkim=pass header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=CuMNmgBk;
	arc=none smtp.remote-ip=62.96.220.36
X-Received: from mx1.secunet.com (mx1.secunet.com [62.96.220.36])
	(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3425D606A321;
	Tue, 24 Nov 2026 06:17:55 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3425D606A321
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=secunet.com
X-Received: from localhost (localhost [127.0.0.1])
	by mx1.secunet.com (Postfix) with ESMTP id F0989206D0;
	Tue, 24 Nov 2026 07:17:53 +0100 (CET)
X-Virus-Scanned: by secunet
X-Received: from mx1.secunet.com ([127.0.0.1])
 by localhost (mx1.secunet.com [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 72SRn53h-tJp; Tue, 24 Nov 2026 07:17:53 +0100 (CET)
X-Received: from EXCH-01.secunet.de (rl1.secunet.de [10.32.0.231])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by mx1.secunet.com (Postfix) with ESMTPS id 580BD201C7;
	Tue, 24 Nov 2026 07:17:53 +0100 (CET)
X-DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com 580BD201C7
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secunet.com;
	s=202301; t=1795501073;
	bh=Fns5KSeLA1lAqdtuoDUdCMp8WJ8wrSCmXQUe1et8xFI=;
	h=Date:From:To:CC:Subject:References:In-Reply-To:From;
	b=CuMNmgBkP7qTfM6MdxNUQ6ZyVyFsrN51hj1M1RaCrS/5jRfJkAFbqvLG2UzS3NtM/
	 Lcg5KAuLcfVffLvgrX+EcXiVUgPrMB6Oenm9MyxVshBWaox4J5C6JNKRglv9dctAQw
	 5XJ0IxPDsK3bZEa1qDH/MWmz5iQF78pJFMvPRjp6bhKCFczY1u3b4ZqDbBkBs36oj/
	 BPhB8a9Ix0gI/uXi8R6tdQuT0h5c/Jv99Q6w98eIRyNkIEnzvHc1E5Wk2hf08UOwYJ
	 yQjiFDbvwvAA225xSuKdx17rxcb50t8f3ugwLxr2wZh0t7xClgswJGTE+v3rjaB3ev
	 Bkv3vBs4jrdSA==
X-Received: from gauss4 (10.182.7.102) by EXCH-01.secunet.de (10.32.0.171) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Tue, 24 Nov
 2026 07:17:51 +0100
X-Received: (nullmailer pid 3202217 invoked by uid 1000);
	Tue, 24 Nov 2026 06:17:52 -0000
X-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>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <179493154245.3969421.1349059390749040254@gmail.com>
X-ClientProxiedBy: EXCH-02.secunet.de (10.32.0.172) To EXCH-01.secunet.de
 (10.32.0.171)