* [PATCH ipsec] xfrm: allow route optimization mode only for DSTOPTS and ROUTING states
@ 2026-11-24 7:08 Kyuwon Cho
2026-11-24 10:13 ` Sabrina Dubroca
0 siblings, 1 reply; 3+ messages in thread
From: Kyuwon Cho @ 2026-11-24 7:08 UTC (permalink / raw)
To: Steffen Klassert, Herbert Xu
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Florian Westphal, Sabrina Dubroca, Hui Peng,
netdev, ipsec, linux-kernel
verify_newsa_info() accepts XFRM_MODE_ROUTEOPTIMIZATION with any
protocol. esp6_init_state() treats a mode it does not know as
transport, 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>
---
Steffen asked for this on our report:
https://lore.kernel.org/netdev/awUsEE7XZIFwc0Ws@gauss4/
Hui Peng posted a patch with this description in September, but its
diff changed attach_auth_trunc() instead:
https://lore.kernel.org/all/20260919215239.3471352-1-benquike@gmail.com/
The issue was found by an LLM-guided test generator that we are
developing as a research prototype. The patch was written with LLM
assistance; we reviewed and tested it. With it, the ESP state of the
reproducer is refused with -EINVAL and the warnings are gone, while
DSTOPTS and ROUTING states in route optimization mode and ESP states in
transport and tunnel mode are still accepted.
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
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH ipsec] xfrm: allow route optimization mode only for DSTOPTS and ROUTING states
2026-11-24 7:08 [PATCH ipsec] xfrm: allow route optimization mode only for DSTOPTS and ROUTING states Kyuwon Cho
@ 2026-11-24 10:13 ` Sabrina Dubroca
2026-11-24 10:18 ` Steffen Klassert
0 siblings, 1 reply; 3+ messages in thread
From: Sabrina Dubroca @ 2026-11-24 10:13 UTC (permalink / raw)
To: Kyuwon Cho
Cc: Steffen Klassert, Herbert Xu, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Florian Westphal,
Hui Peng, netdev, ipsec, linux-kernel
2026-11-24, 16:08:56 +0900, Kyuwon Cho wrote:
> verify_newsa_info() accepts XFRM_MODE_ROUTEOPTIMIZATION with any
> protocol. esp6_init_state() treats a mode it does not know as
> transport, so an ESP state in that mode is created, and the first
nit: I'd say it doesn't really "treat" it as transport, it accepts
everything and doesn't adjust header_len.
> 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:
Looking at the list of available modes (include/uapi/linux/xfrm.h),
what about XFRM_MODE_IN_TRIGGER?
> 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.
This is reasonable, but I think we should instead (or maybe "also")
add mode filtering to each ->init_state. Most already do it
(interestingly, ah6_init_state does but not ah_init_state, can AH4
also land in the same WARNs?), I think it's just ah4 and esp{4,6}
missing those.
--
Sabrina
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH ipsec] xfrm: allow route optimization mode only for DSTOPTS and ROUTING states
2026-11-24 10:13 ` Sabrina Dubroca
@ 2026-11-24 10:18 ` Steffen Klassert
0 siblings, 0 replies; 3+ messages in thread
From: Steffen Klassert @ 2026-11-24 10:18 UTC (permalink / raw)
To: Sabrina Dubroca
Cc: Kyuwon Cho, Herbert Xu, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Florian Westphal,
Hui Peng, netdev, ipsec, linux-kernel
On Tue, Nov 24, 2026 at 11:13:22AM +0100, Sabrina Dubroca wrote:
> 2026-11-24, 16:08:56 +0900, Kyuwon Cho wrote:
> > verify_newsa_info() accepts XFRM_MODE_ROUTEOPTIMIZATION with any
> > protocol. esp6_init_state() treats a mode it does not know as
> > transport, so an ESP state in that mode is created, and the first
>
> nit: I'd say it doesn't really "treat" it as transport, it accepts
> everything and doesn't adjust header_len.
>
> > 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:
>
> Looking at the list of available modes (include/uapi/linux/xfrm.h),
> what about XFRM_MODE_IN_TRIGGER?
>
> > 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.
>
> This is reasonable, but I think we should instead (or maybe "also")
> add mode filtering to each ->init_state.
I suggested to do it this way, but we also can do it on both sides.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-24 10:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 7:08 [PATCH ipsec] xfrm: allow route optimization mode only for DSTOPTS and ROUTING states Kyuwon Cho
2026-11-24 10:13 ` Sabrina Dubroca
2026-11-24 10:18 ` Steffen Klassert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®