Article View: linux.kernel.netdev
Article #3437[PATCH net] xfrm: iptfs: do not seek the sequential skb reader backwards
From: Jun Yang
Date: Thu, 15 Oct 2026 02:17
Date: Thu, 15 Oct 2026 02:17
76 lines
10676 bytes
10676 bytes
From: Jun Yang <junvyyang@tencent.com>
iptfs_reassem_cont() completes a saved runt by reading the missing bytes
at payload offset "data", and then reads from that same offset again to
fill the inner IP header, deliberately re-copying them.
skb_seq_read() is forward-only. Once a read has stepped past the current
segment of a non-linear skb, st->stepped_offset is larger than the offset
of the re-read, and
*data = st->cur_skb->data + (abs_offset - st->stepped_offset);
underflows in unsigned arithmetic. The companion return value
"block_limit - abs_offset" stays large and positive, so
skb_copy_seq_read() memcpy()s up to iphlen - runtlen bytes from about
4GiB past the skb data.
BUG: unable to handle page fault for address: ffffed1025327a04
Oops: 0000 [#1] SMP KASAN
RIP: 0010:kasan_check_range+0x1bd/0x220
Call Trace:
__asan_memcpy+0x23/0x60
skb_copy_seq_read+0x13a/0x150
iptfs_reassem_cont+0x363/0x1780
iptfs_input_ordered+0x673/0x880
iptfs_input+0x5f7/0xed0
xfrm_input+0x332b/0x7960
xfrm4_esp_rcv+0xb3/0x290
ip_local_deliver+0x1c3/0x600
The sibling parser __input_process_payload() already restarts the walk
when the reader has stepped; do the same after the runt fill. While here,
pass 0 rather than "data" as the new lower bound in that sibling, since
every caller keeps handing skb_copy_seq_read() absolute payload offsets
and skb_seq_read() adds lower_offset to them.
Fixes: 075694765446 ("xfrm: iptfs: handle received fragmented inner packets")
Cc: stable@kernel.org
Reported-by: TencentOS Corvus AI <corvus@tencent.com>
Assisted-by: tencentos-corvus-ai:hy4-preview
Signed-off-by: Jun Yang <junvyyang@tencent.com>
---
A KASAN reproducer for this issue is available if requested.
net/xfrm/xfrm_iptfs.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
index 597aedeac26e..c614f3483f78 100644
--- a/net/xfrm/xfrm_iptfs.c
+++ b/net/xfrm/xfrm_iptfs.c
@@ -845,6 +845,12 @@ static u32 iptfs_reassem_cont(struct xfrm_iptfs_data *xtfs, u64 seq,
*/
memcpy(skb_put(newskb, runtlen), xtfs->ra_runt,
sizeof(xtfs->ra_runt));
+
+ /* The re-read below cannot back up a stepped seq read. */
+ if (unlikely(st->stepped_offset)) {
+ skb_abort_seq_read(st);
+ skb_prepare_seq_read(skb, 0, skb->len, st);
+ }
}
/* Continue reassembling the packet */
@@ -1038,7 +1044,7 @@ static bool __input_process_payload(struct xfrm_state *x, u32 data,
struct sk_buff *save = skbseq->root_skb;
skb_abort_seq_read(skbseq);
- skb_prepare_seq_read(save, data, tail, skbseq);
+ skb_prepare_seq_read(save, 0, tail, skbseq);
}
if (first_skb) {
--
2.55.0
Technical Details
Message-ID:
<20261015021747.30346-1-juny24602@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-346523-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-346523-linux-kernel-netdev=dewy.ru
From: juny24602@gmail.com (Jun Yang)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] xfrm: iptfs: do not seek the sequential skb reader backwards
Date: Thu, 15 Oct 2026 10:17:31 +0800
Organization: Usenet Network
Message-ID: <20261015021747.30346-1-juny24602@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2433550"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:agrSdSSJ2KqIolHVzYlMRx/jonk= sha256:aDHoki/4zZ4PMQgXZLGE6xMEoYAoZUvjMQ9B7IG+71o=
sha1:2jroDs+Sz4mdtbnpsqShcOkJLPI= sha256:y1idLjwlmRJ/Pvhoi+/uC4xjOZYUebWEMtJmwLbjSRc=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 86A70110236; Thu, 15 Oct 2026 05:20:57 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: 0.51
X-Spam-Status: No, score=0.51 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_SBL_CSS=3.558,
SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=no autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id ngnlgI9Dy-ms;
Thu, 15 Oct 2026 05:20:55 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-346523-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
by mail.dewy.ru (Postfix) with ESMTPS id 9662E1101BF; Thu, 15 Oct 2026 05:20:45 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
by sin.lore.kernel.org (Postfix) with ESMTP id 34E1323B89; Thu, 15 Oct 2026 02:17:57 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F78E3D47A5;
Thu, 15 Oct 2026 02:17:56 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eekHr2dh"
X-Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B19633F8AD
for <netdev@vger.kernel.org>; Thu, 15 Oct 2026 02:17:54 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1792030676; cv=none; b=INPZ2EZp69Yrk1YxHsRn2M6VuNkIMRU0/TaFszHg7y6pEychJRWGC1Yr45uqAxT/U7T+L8HQi/PdKuliN4pfBXdkcw0UOMYiH0oQR+bSuAQLZ1ymYMVx5rXOf9MyWpCozFJi60vP+kbZe5wIFXLL9fa1ylwViuLO+JwkPrOwDTA=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1792030676; c=relaxed/simple;
bh=X+HCnHGvBi9HWjAtNmtWvZ3H76ZTR8nEk/L20woDDe8=;
h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=YOak/S6YOfI010ZstcfL+gPsZqf5jPDYiF6G7SMkI2d87IpOhMrxO+CM+vJKmfMi5fbMYQNexjmZLP9PV5KYqYYvG4bG+Wt0tB5XFSwdQP4/X2uG11AhCkInnO49pL6MVTtbfoIEjQRChLiOlnVMzPn+Xd1GdAbdok5SsX7RGWg=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eekHr2dh; arc=none smtp.client-ip=209.85.215.172
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-cd60c5da24cso2272406a12.0
for <netdev@vger.kernel.org>; Wed, 14 Oct 2026 19:17:54 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1792030674; x=1792635474; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=/Uj6IejyI7gw3UH5oRZnmPQkBvUb0bume0nMVbdbeS4=;
b=eekHr2dhBWSJ7GtQoWJ7SSZN8CXVsoMeHmq2yQHpVxsJWCuQvKnLM89xa7skwgy+lE
4IHndRB+Rt/wrHnXBG4i9O0v14umx61SjQx2F9MA3FygP27zkBJwhktHQ4/qNolR7Ief
e1WSrDoI7KBVEY3mZ3/BKd45VsWxaYzrynYco+QuiH1Hx3b0e11joegM1yjz+F11IBay
Fyt82VRSpdxyexg1T4LC7QHa94+EXmFjbxsoHAN0WYArfHsV98ZM3yipGM4LaBLyEVS7
+Wibxt/17d9TikBguoqiWZDKBtQdBk27ezvhLR98E0OyKpQCmKS+CL3jyCEZ5y80DD2Y
Tvzg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792030674; x=1792635474;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=/Uj6IejyI7gw3UH5oRZnmPQkBvUb0bume0nMVbdbeS4=;
b=Uu76Km5hVfvsWEji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iXJ2C6CGaL/ozD7z
MR4+sM56mEyyyUogXvQ2BDAPMyRKsWdoE42eqD+e/tXBg==
X-Received: by 2002:a17:90b:268f:b0:3a8:59d3:5317 with SMTP id 98e67ed59e1d1-3ab3a778a55mr15692854a91.32.1792030673922;
Wed, 14 Oct 2026 19:17:53 -0700 (PDT)
X-Received: from JUNVYYANG-MC1.tencent.com ([43.132.141.25])
by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3ac94798212sm1881727a91.14.2026.10.14.19.17.50
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Wed, 14 Oct 2026 19:17:53 -0700 (PDT)
X-Cc: davem@davemloft.net,
edumazet@kernel.org,
kuba@kernel.org,
pabeni@redhat.com,
horms@kernel.org,
chopps@labn.net,
netdev@vger.kernel.org,
Jun Yang <junvyyang@tencent.com>,
stable@kernel.org,
TencentOS Corvus AI <corvus@tencent.com>
X-Mailer: git-send-email 2.54.0
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>