Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH ipsec] xfrm: iptfs: report the too big error to the frame's own socket
@ 2026-11-27 14:25 Rustam Mustafin
  0 siblings, 0 replies; only message in thread
From: Rustam Mustafin @ 2026-11-27 14:25 UTC (permalink / raw)
  To: Steffen Klassert, Herbert Xu, David S. Miller
  Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn,
	Simon Horman, Christian Hopps, netdev, ipsec, linux-kernel,
	Rustam Mustafin, Sashiko, stable

iptfs_is_too_big() calls xfrm_local_error() when its sk argument is set,
but xfrm_local_error() reports to skb->sk and dereferences it. vxlan
passes its tunnel socket as sk for a forwarded frame that has no
skb->sk, so an oversized forwarded frame on an IP-TFS SA with dont-frag
oopses:

  KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
  RIP: 0010:xfrm_local_error+0x92/0x190
  Call Trace:
   iptfs_output_collect+0x2c2/0x1170
   udp_tunnel6_xmit_skb+0x713/0xd90
   vxlan_xmit_one+0x1ebc/0x3490
   ip6_forward+0x1573/0x35c0

Check the frame's own full socket instead, as xfrm4_tunnel_check_size()
does, so a forwarded frame gets the ICMP error. Drop the now unused sk
argument.

Reproduced on a KASAN kernel with vxlan forwarding over an IP-TFS SA;
with the fix the oops is gone and an ICMPv6 Packet Too Big is sent. The
xfrm_state.sh, xfrm_policy.sh, xfrm_policy_add_speed.sh,
vrf-xfrm-tests.sh, pmtu.sh and ipsec selftests pass with and without the
fix.

Fixes: 0e4fbf013fa5 ("xfrm: iptfs: add user packet (tunnel ingress) handling")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/all/179551712630.3135.52212996809224784@kernel.org/
Cc: stable@vger.kernel.org
Signed-off-by: Rustam Mustafin <rmustafin@cloudlinux.com>
---
Assisted by Claude Opus 5.5 (claude-opus-5-5).

A KASAN reproducer (single VM, vxlan forwarding over an IP-TFS SA) is
available on request.

 net/xfrm/xfrm_iptfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
index 0313a43aa8a9..ccdde630a825 100644
--- a/net/xfrm/xfrm_iptfs.c
+++ b/net/xfrm/xfrm_iptfs.c
@@ -1813,7 +1813,7 @@ static int iptfs_get_cur_pmtu(struct xfrm_state *x, struct xfrm_iptfs_data *xtfs
 	return pmtu;
 }
 
-static int iptfs_is_too_big(struct sock *sk, struct sk_buff *skb, u32 pmtu)
+static int iptfs_is_too_big(struct sk_buff *skb, u32 pmtu)
 {
 	if (skb->len <= pmtu)
 		return 0;
@@ -1824,7 +1824,7 @@ static int iptfs_is_too_big(struct sock *sk, struct sk_buff *skb, u32 pmtu)
 	if (skb->dev)
 		XFRM_INC_STATS(dev_net(skb->dev), LINUX_MIB_XFRMOUTERROR);
 
-	if (sk)
+	if (skb_to_full_sk(skb))
 		xfrm_local_error(skb, pmtu);
 	else if (ip_hdr(skb)->version == 4)
 		icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(pmtu));
@@ -1908,7 +1908,7 @@ static int iptfs_output_collect(struct net *net, struct sock *sk, struct sk_buff
 		/* If the user indicated no iptfs fragmenting check before
 		 * enqueue.
 		 */
-		if (xtfs->cfg.dont_frag && iptfs_is_too_big(sk, skb, pmtu)) {
+		if (xtfs->cfg.dont_frag && iptfs_is_too_big(skb, pmtu)) {
 			trace_iptfs_too_big(skb, xtfs, pmtu, was_gso);
 			kfree_skb_reason(skb, SKB_DROP_REASON_PKT_TOO_BIG);
 			continue;
-- 
2.52.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-27 14:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 14:25 [PATCH ipsec] xfrm: iptfs: report the too big error to the frame's own socket Rustam Mustafin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox