From: Kyuwon Cho <kyuwoncho18@gmail.com>
To: Steffen Klassert <steffen.klassert@secunet.com>,
Herbert Xu <herbert@gondor.apana.org.au>
Cc: "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>, Florian Westphal <fw@strlen.de>,
Sabrina Dubroca <sd@queasysnail.net>,
Hui Peng <benquike@gmail.com>,
netdev@vger.kernel.org, ipsec@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: [PATCH ipsec v2 1/2] xfrm: allow route optimization mode only for DSTOPTS and ROUTING states
Date: Wed, 25 Nov 2026 11:42:27 +0900 [thread overview]
Message-ID: <c1901b79c9de8fad23fecb49f1d4ab7ecdf04f57.1795573672.git.kyuwoncho18@gmail.com> (raw)
In-Reply-To: <cover.1795573672.git.kyuwoncho18@gmail.com>
verify_newsa_info() accepts XFRM_MODE_ROUTEOPTIMIZATION with any
protocol. esp6_init_state() accepts any mode and only adjusts
header_len for the ones it knows, so an ESP state in that mode is
created, and the first packet through it hits the WARN_ON_ONCE()s in
xfrm_state_mtu() and xfrm_inner_mode_input(), which assume that route
optimization never comes with ESP:
WARNING: net/xfrm/xfrm_state.c:3264 at xfrm_state_mtu+0x239/0x3d0
RIP: 0010:xfrm_state_mtu (net/xfrm/xfrm_state.c:3264)
Call Trace:
<TASK>
xfrm_bundle_create (net/xfrm/xfrm_policy.c:3992 net/xfrm/xfrm_policy.c:2785)
xfrm_resolve_and_create_bundle (net/xfrm/xfrm_policy.c:2885)
xfrm_lookup_with_ifid (net/xfrm/xfrm_policy.c:3114 net/xfrm/xfrm_policy.c:3245)
xfrm_lookup_route (net/xfrm/xfrm_policy.c:3344 net/xfrm/xfrm_policy.c:3355)
ip6_dst_lookup_flow (net/ipv6/ip6_output.c:1299)
udpv6_sendmsg (net/ipv6/udp.c:1699)
WARNING: net/xfrm/xfrm_input.c:449 at xfrm_input+0x2176/0x5f50
RIP: 0010:xfrm_input (net/xfrm/xfrm_input.c:449 net/xfrm/xfrm_input.c:705)
Call Trace:
<IRQ>
xfrm6_esp_rcv (net/ipv6/xfrm6_protocol.c:119)
ip6_protocol_deliver_rcu (net/ipv6/ip6_input.c:479)
Accept the mode only for the Mobile IPv6 protocols, as IP-TFS mode is
already limited to ESP.
Fixes: c2d305e51038 ("xfrm: remove input indirection from xfrm_mode")
Fixes: c7b37c769d2a ("xfrm: remove get_mtu indirection from xfrm_type")
Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
---
net/xfrm/xfrm_user.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 217f65faa2bd..c4bbfd638d73 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -477,9 +477,16 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,
switch (p->mode) {
case XFRM_MODE_TRANSPORT:
case XFRM_MODE_TUNNEL:
- case XFRM_MODE_ROUTEOPTIMIZATION:
case XFRM_MODE_BEET:
break;
+ case XFRM_MODE_ROUTEOPTIMIZATION:
+ if (p->id.proto != IPPROTO_DSTOPTS &&
+ p->id.proto != IPPROTO_ROUTING) {
+ NL_SET_ERR_MSG(extack,
+ "Route optimization mode requires DSTOPTS or ROUTING");
+ goto out;
+ }
+ break;
case XFRM_MODE_IPTFS:
if (p->id.proto != IPPROTO_ESP) {
NL_SET_ERR_MSG(extack, "IP-TFS mode only supported with ESP");
--
2.43.0
next prev parent reply other threads:[~2026-11-25 2:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 2:37 [PATCH ipsec v2 0/2] xfrm: refuse route optimization mode for ESP Kyuwon Cho
2026-11-25 2:42 ` Kyuwon Cho [this message]
2026-11-25 2:42 ` [PATCH ipsec v2 2/2] xfrm: refuse modes that AH and ESP do not support Kyuwon Cho
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=c1901b79c9de8fad23fecb49f1d4ab7ecdf04f57.1795573672.git.kyuwoncho18@gmail.com \
--to=kyuwoncho18@gmail.com \
--cc=benquike@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=fw@strlen.de \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=ipsec@lists.linux.dev \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
--cc=steffen.klassert@secunet.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox