From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx1.secunet.com (mx1.secunet.com [62.96.220.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2ED12397ABA for ; Wed, 14 Jan 2026 12:18:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.96.220.36 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768393113; cv=none; b=Nyzpr7REVuWgXR42lUSjocNIUB0TgmlIN3SSolMB4oCH3vZRE5y20OWsxXBLh0wlSyPv9Ivci6dzecRNGN2MlQFW2cUqEgcHTZc+iC48o0ZBjsI9etbN/V5E4aWFxBzn1VCbiAzcOM6VqxbfCv4jMW9kDtHIIgHF+7yT++k1GZQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768393113; c=relaxed/simple; bh=1zmFnIEyGGi1Zyt2jtvrx4bTQY2HX9Eo0bVxLLcHuOw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jSnaBL4Q0APK6/0r+GIACDIFMHJkPn4BvoWXS9QrG7b62LdHUuN66KFlhsEuqy5ivj9teJhCSjx/OGL2ifBXefxngjrYGVJnKaYWXo+1Jix/di4teUWIqO2SMUeZaOs/Q0VqasONH90vt2WEcZOWtZnReQ13MomjyZrVz3DOM/Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com; spf=pass smtp.mailfrom=secunet.com; dkim=pass (2048-bit key) header.d=secunet.com header.i=@secunet.com header.b=I42Wf3oC; arc=none smtp.client-ip=62.96.220.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=secunet.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=secunet.com header.i=@secunet.com header.b="I42Wf3oC" Received: from localhost (localhost [127.0.0.1]) by mx1.secunet.com (Postfix) with ESMTP id 6C73B20839; Wed, 14 Jan 2026 13:18:24 +0100 (CET) X-Virus-Scanned: by secunet 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 LfbYO9ViOEYF; Wed, 14 Jan 2026 13:18:23 +0100 (CET) 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 CA69E2083B; Wed, 14 Jan 2026 13:18:23 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com CA69E2083B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secunet.com; s=202301; t=1768393103; bh=/vJCylyHjPsLmLdowF97VpdA5FDsw9tluxpO34e5qy8=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=I42Wf3oCUhrLiUpFKbyJ9N4smx+KLPu9RtcxPSe8+kSlUZbONuqpRWax467or9X2I yrYTZCnSDos2Z0I6TvMk4wLpFQJgL09cYHR11RlqnoldAj+XCc6szvhLPUJZseg3Nm O9/0fT7FK7PRDXmM7CdDwRX5Kbtmoy7uNrW6wZUvtyWDMXrTRGHR9pvuBev28PI/6A dcA4JpLWOACfHTsbfhc6cKcr2nMlZ+4Nx1DM8oClAJ0snAhESPF2RERkcKXu9r234U fwUMigEAByKbFgyY60uobRA+kGvm1pH6NVXv21UNqkuI1pLF1p+PlAGdbd85idzaGZ UNiuUEd+Jm4OQ== Received: from secunet.com (10.182.7.193) 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.17; Wed, 14 Jan 2026 13:18:23 +0100 Received: (nullmailer pid 1106330 invoked by uid 1000); Wed, 14 Jan 2026 12:18:20 -0000 From: Steffen Klassert To: David Miller , Jakub Kicinski CC: Herbert Xu , Steffen Klassert , Subject: [PATCH 1/2] xfrm: Fix inner mode lookup in tunnel mode GSO segmentation Date: Wed, 14 Jan 2026 13:18:08 +0100 Message-ID: <20260114121817.1106134-2-steffen.klassert@secunet.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260114121817.1106134-1-steffen.klassert@secunet.com> References: <20260114121817.1106134-1-steffen.klassert@secunet.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: EXCH-02.secunet.de (10.32.0.172) To EXCH-01.secunet.de (10.32.0.171) From: Jianbo Liu Commit 61fafbee6cfe ("xfrm: Determine inner GSO type from packet inner protocol") attempted to fix GSO segmentation by reading the inner protocol from XFRM_MODE_SKB_CB(skb)->protocol. This was incorrect because the field holds the inner L4 protocol (TCP/UDP) instead of the required tunnel protocol. Also, the memory location (shared by XFRM_SKB_CB(skb) which could be overwritten by xfrm_replay_overflow()) is prone to corruption. This combination caused the kernel to select the wrong inner mode and get the wrong address family. The correct value is in xfrm_offload(skb)->proto, which is set from the outer tunnel header's protocol field by esp[4|6]_gso_encap(). It is initialized by xfrm[4|6]_tunnel_encap_add() to either IPPROTO_IPIP or IPPROTO_IPV6, using xfrm_af2proto() and correctly reflects the inner packet's address family. Fixes: 61fafbee6cfe ("xfrm: Determine inner GSO type from packet inner protocol") Signed-off-by: Jianbo Liu Reviewed-by: Sabrina Dubroca Signed-off-by: Steffen Klassert --- net/ipv4/esp4_offload.c | 4 ++-- net/ipv6/esp6_offload.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/ipv4/esp4_offload.c b/net/ipv4/esp4_offload.c index 05828d4cb6cd..abd77162f5e7 100644 --- a/net/ipv4/esp4_offload.c +++ b/net/ipv4/esp4_offload.c @@ -122,8 +122,8 @@ static struct sk_buff *xfrm4_tunnel_gso_segment(struct xfrm_state *x, struct sk_buff *skb, netdev_features_t features) { - const struct xfrm_mode *inner_mode = xfrm_ip2inner_mode(x, - XFRM_MODE_SKB_CB(skb)->protocol); + struct xfrm_offload *xo = xfrm_offload(skb); + const struct xfrm_mode *inner_mode = xfrm_ip2inner_mode(x, xo->proto); __be16 type = inner_mode->family == AF_INET6 ? htons(ETH_P_IPV6) : htons(ETH_P_IP); diff --git a/net/ipv6/esp6_offload.c b/net/ipv6/esp6_offload.c index 22410243ebe8..22895521a57d 100644 --- a/net/ipv6/esp6_offload.c +++ b/net/ipv6/esp6_offload.c @@ -158,8 +158,8 @@ static struct sk_buff *xfrm6_tunnel_gso_segment(struct xfrm_state *x, struct sk_buff *skb, netdev_features_t features) { - const struct xfrm_mode *inner_mode = xfrm_ip2inner_mode(x, - XFRM_MODE_SKB_CB(skb)->protocol); + struct xfrm_offload *xo = xfrm_offload(skb); + const struct xfrm_mode *inner_mode = xfrm_ip2inner_mode(x, xo->proto); __be16 type = inner_mode->family == AF_INET ? htons(ETH_P_IP) : htons(ETH_P_IPV6); -- 2.43.0