Skip to content

xfrm: refuse route optimization mode for ESP

Kyuwon Cho ipsec lkml netdev 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 0 repliesNew
  2. v11 patch 2 repliesSuperseded

Changes in v2 from the cover letter

- Patch 1: say that esp6_init_state() accepts any mode instead of "treats" an unknown mode as transport (Sabrina).
- Patch 2 is new (Sabrina, Steffen).
v1: https://lore.kernel.org/netdev/[email protected]/

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2xfrm: allow route optimization mode only for DSTOPTS and ROUTING statesnet/xfrm/xfrm_user.c+8 -10 replies
2/2xfrm: refuse modes that AH and ESP do not supportnet/ipv4/ah4.c net/ipv4/esp4.c net/ipv6/esp6.c+30 -50 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH ipsec v2 0/2] xfrm: refuse route optimization mode for ESP

From: ChoKyuWon <[email protected]>

An ESP state in route optimization mode can be created, and its first packet hits the WARN_ON_ONCE()s in xfrm_state_mtu() and xfrm_inner_mode_input(). Patch 1 accepts the mode in verify_newsa_info() only for DSTOPTS and ROUTING, as in v1. Patch 2, as Sabrina suggested, also makes ah_init_state(), esp_init_state() and esp6_init_state() refuse the modes they do not support, like ah6_init_state() already does.

To Sabrina's questions: XFRM_MODE_IN_TRIGGER is already refused by verify_newsa_info() ("Unsupported mode"). AH or ESP over IPv4 cannot get route optimization mode at all: xfrm4_mode_map has no entry for it, so __xfrm_init_state() fails with -EPROTONOSUPPORT before ah_init_state() runs. So only ESP over IPv6 reaches these WARNs, and the IPv4 part of patch 2 is for consistency.

The issue was found by an LLM-guided test generator that we are developing as a research prototype.

v2:
- Patch 1: say that esp6_init_state() accepts any mode instead of "treats" an unknown mode as transport (Sabrina).
- Patch 2 is new (Sabrina, Steffen).
v1: https://lore.kernel.org/netdev/[email protected]/

The patches were written with LLM assistance; we reviewed and tested them on the ipsec tree. ESP over IPv6 in route optimization mode is refused with -EINVAL with patch 1, with patch 2 alone, and with both, and the reproducer no longer warns. ESP and AH in transport, tunnel and BEET mode over IPv4 and IPv6, and DSTOPTS and ROUTING states in route optimization mode, are still accepted.

Kyuwon Cho (2):
xfrm: allow route optimization mode only for DSTOPTS and ROUTING
states
xfrm: refuse modes that AH and ESP do not support

 net/ipv4/ah4.c       | 11 ++++++++++-
 net/ipv4/esp4.c      | 18 +++++++++++++++---
 net/ipv6/esp6.c      |  6 +++++-
 net/xfrm/xfrm_user.c |  9 ++++++++-
 4 files changed, 38 insertions(+), 6 deletions(-)
Signature · 1 line
2.43.0