Article View: linux.kernel.netdev
Article #5923Re: [PATCH net] xfrm: iptfs: do not seek the sequential skb reader backwards
From: Steffen Klassert
Date: Wed, 21 Oct 2026 08:44
Date: Wed, 21 Oct 2026 08:44
90 lines
12635 bytes
12635 bytes
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
commit d3c6d0500e742002c13ba4e7b9eff45bdb2c394b
Author: Jun Yang <junvyyang@tencent.com>
xfrm: iptfs: do not seek the sequential skb reader backwards
iptfs_reassem_cont() can underflow its offset arithmetic when reading
a saved runt if the sequential reader stepped, leading to an out-of-bounds
memcpy. This patch aborts and restarts the sequence read to avoid backwards
seeks. It also fixes a sibling parser to use offset 0 when restarting.
> diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
> index 6920940a35b49..751cceab738a1 100644
> --- a/net/xfrm/xfrm_iptfs.c
> +++ b/net/xfrm/xfrm_iptfs.c
[ ... ]
> @@ -1046,7 +1052,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) {
Does this code introduce a data race that corrupts reassembly?
When __input_process_payload() saves a runt, it calls iptfs_input_save_runt()
without acquiring xtfs->drop_lock or any other SA-level lock:
net/xfrm/xfrm_iptfs.c:__input_process_payload() {
...
/* save the bytes we have, advance data and exit */
iptfs_input_save_runt(xtfs, seq, hbytes, remaining);
...
}
This locklessly modifies xtfs->ra_runt, xtfs->ra_runtlen, and
xtfs->ra_wantseq.
Concurrently, another CPU processing packets for the same IP-TFS SA might
execute iptfs_input_ordered() and read xtfs->ra_runtlen locklessly, then
acquire drop_lock for iptfs_reassem_cont():
net/xfrm/xfrm_iptfs.c:iptfs_input_ordered() {
...
/* check before locking i.e., maybe */
if (blkoff || xtfs->ra_runtlen || xtfs->ra_newskb) {
spin_lock(&xtfs->drop_lock);
/* check again after lock */
if (blkoff || xtfs->ra_runtlen || xtfs->ra_newskb) {
data = iptfs_reassem_cont(xtfs, seq, &skbseq, skb, data,
blkoff, &sublist);
}
spin_unlock(&xtfs->drop_lock);
}
...
}
Because iptfs_input_save_runt() does not hold drop_lock, the lockless read
and locked memcpy of xtfs->ra_runt race directly with the lockless writes.
Can this cause memory corruption, torn reads, and packet corruption?
Can this code cause a lock context violation on PREEMPT_RT kernels?
In iptfs_input_ordered(), a sleepable spinlock is acquired while a
kmap_atomic mapping might still be held:
net/xfrm/xfrm_iptfs.c:iptfs_input_ordered() {
...
if (skb_copy_seq_read(&skbseq, 0, ipth, sizeof(*ipth))) {
...
if (blkoff || xtfs->ra_runtlen || xtfs->ra_newskb) {
spin_lock(&xtfs->drop_lock);
...
}
If the packet is non-linear and the header resides in a paged fragment,
skb_copy_seq_read() maps the fragment using kmap_atomic() and leaves
skbseq.frag_data actively mapped.
Acquiring spin_lock(&xtfs->drop_lock) without first aborting the sequence
read violates lock context rules, as spinlock_t maps to a sleepable rt_mutex
on PREEMPT_RT.
Could this lead to a 'sleeping in atomic context' bug?
Technical Details
Message-ID:
<ath7c-r2GuDm5Xo4@secunet.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-349895-linux-kernel-netdev=dewy.ruReferences:
<20261015021747.30346-1-juny24602@gmail.com>Show 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-349895-linux-kernel-netdev=dewy.ru From: steffen.klassert@secunet.com (Steffen Klassert) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] xfrm: iptfs: do not seek the sequential skb reader backwards Date: Wed, 21 Oct 2026 10:44:35 +0200 Organization: Usenet Network Message-ID: <ath7c-r2GuDm5Xo4@secunet.com> References: <20261015021747.30346-1-juny24602@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Injection-Info: usenet.network; logging-data="4080683"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:wfkRG+WIcQEL1rackAZqsO05BlE= sha256:XCvP8DaebdN+aajHKVZZur+t1xa4biEL+WrgAB7fpAM= sha1:nfjf29zrt+mOxhq8KMYagHoo49Q= sha256:JVdwQIfIcZyNvtEAcDfmeXAEivR4IfYAllMKW0v7O4A= Content-Disposition: inline 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 3DB1B110F7F; Wed, 21 Oct 2026 11:47:54 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.049 X-Spam-Status: No, score=-3.049 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, HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=secunet.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 LwHPDt6Bxvo4; Wed, 21 Oct 2026 11:47:50 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-349895-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=secunet.com X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 37240110F68; Wed, 21 Oct 2026 11:47:41 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id B2E31418FE; Wed, 21 Oct 2026 08:44:47 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792572287; b=PK9sKDwDCKhmRhI3KZEtgY/fhBRBLJGEnFuf7oxu6jrqGqltANyRaZ3M91XNwuxCEqiD k9VxWoorRyaWK8xe7S9NUFzw8q4S5pfGu6QnZSWDcGi2VwJI8IZfCrXGDQXFpP0PBi1v+ JSMpX+YVkYzV2RxtXq8HIjQK3Cw+xcTuA4Vtm/kslLyGhrFOw3DThDF3jSI1pqC/3yvxs dLuSexhz74J/46SRI4x5X9JhFshqcT7bqEF3c7std3JCayt+xuwGDDMWFArbgBGEcMqol wKCCLaC2w3se6h/YQkGFbLVKg8Uu+tZUpuePrMhNdR/gfL9AO0n1k0GGvhGlWyN9MYQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792572287; h=X-Original-To:Received:DMARC-Filter:Received:X-Virus-Scanned: Received:Received:DKIM-Filter:DKIM-Signature:Received:Received:Date: From:To:CC:Subject:Message-ID:References:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Disposition:In-Reply-To: X-ClientProxiedBy; bh=Ryt79vtuqgO6oO1oeL3ZfN3BiPEbp12hL9M4yl8jSjo=; b=YLgJ0oQvtPZQ73TQtTZfYCGrMibAOrMYliVtfjDnJ3h3lLDbweuaHfAsJOjhHqZukdfm 3N9zTSTtuEab+rMd75bVKwmz53E7PhtgDbgZnLmzC8eLW2HTQyJtz3fl3n0b8oTli43Fx WxKFqFzHODXKXfO8eM5tjs6RTjPydyt2+pj2wgK+4ihLNk4ViIUt6OIh4qn63ljKDlf4+ atkA+Azcwo5O00FW84TznvA8XTlRaZpsBfMiTifGB1S76ZpTY8BY0Lj7WCQnQEJzCv6Nm 85j5kqXfyujCaOaRA1k9Faq0seMNBUJTq2enfHNe3/9ipL69bj6cHVvTEpO48fryH9Q== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=fyFDjeCM; dmarc=pass header.from=secunet.com; spf=pass smtp.mailfrom=secunet.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 88611606A31F; Wed, 21 Oct 2026 08:44:47 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=fyFDjeCM X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=62.96.220.36 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792572286; b=OoFoFFLSg4OdQ5v+wNZ6O+wu/6OgvnT5JKnmImMfV4f0QFoQPQ7+Eqwxu6DPnLrhgPaA npnKIDa9IH75aUe1VS3/OZ5T/3DfT49h5auHOC+yfXB+34oMLzM+//cA5qf+gq4c6t71Q d8RZGDWbSDoCH8p2jI4XUw1F6mFznmixAotaeMJjiaUJP4s0y8Fz5254G4FJo2u0IADNm rDRq2pMWiVXR5T4oygXEslns/1zDuJ8si1YDeWaYHt/jY8xZJc48TyR/Z68ypYRBA388T PdwrkSmxAFibdlBVIv4H6rbmHPMxMVcfZjSoP97QHRpL/ZwGIU1oZE43zngI4L8bXHw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792572286; h=DMARC-Filter:Received:X-Virus-Scanned:Received:Received:DKIM-Filter: DKIM-Signature:Received:Received:Date:From:To:CC:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To: X-ClientProxiedBy; bh=Ryt79vtuqgO6oO1oeL3ZfN3BiPEbp12hL9M4yl8jSjo=; b=QxOPfiL5SDOBhJsAArrDrMCcJrXb6OLhb+C0fxk/BfruOnlS+pVnQI+W/3734tl3Cyx/ MiPzwDKjwGJb4WDs9ez7lM/x8yWBv5Q2Jah0NxJd98LfGJ4jWP5rjX7qgItu7DQbr3IXA zUnmXoq74SZO6/op7UkqPITpM4cXs9BUGam1rltWh+J4mxvXCGrjgRKUwelD1kqzAM15K YXUU2qJ0IaqWhnahOlIx2B8n9oFelBuwoD98Mv+mU5qeKB0fd5/lIIQZXvTtyGHO4dE6l 8WrhvWV8nRA804ERAFr6lKhOCEoaViEkQYK6iOWcO6TM9UaW7MNzyfOT27uD5D3akBg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=secunet.com; spf=pass smtp.mailfrom=secunet.com; dkim=pass header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=fyFDjeCM; arc=none smtp.remote-ip=62.96.220.36 X-Received: from mx1.secunet.com (mx1.secunet.com [62.96.220.36]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8ADB606A31C for <netdev@vger.kernel.org>; Wed, 21 Oct 2026 08:44:44 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D8ADB606A31C X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=secunet.com X-Received: from localhost (localhost [127.0.0.1]) by mx1.secunet.com (Postfix) with ESMTP id 50609207E3; Wed, 21 Oct 2026 10:44:37 +0200 (CEST) X-Virus-Scanned: by secunet X-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 kVjeeb5hzzRi; Wed, 21 Oct 2026 10:44:36 +0200 (CEST) X-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 5811B207A4; Wed, 21 Oct 2026 10:44:36 +0200 (CEST) X-DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com 5811B207A4 X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secunet.com; s=202301; t=1792572276; bh=Ryt79vtuqgO6oO1oeL3ZfN3BiPEbp12hL9M4yl8jSjo=; h=Date:From:To:CC:Subject:References:In-Reply-To:From; b=fyFDjeCMgoqE+WxSbghr8jX/ZnuNig8IL2sPlBucAhxzBTcgnmI4779btlxNoBO4l Lyl5YOlCczOXQut69sfLM23zQnWyvEY2rNSgbaYvi63rNyctSS9ME/jNYb+LDbVsax A1+SDMKrtpbVb6I+POtI4Bve70akz8qByxzw93hgnCDeNkkDANsXkrjb6tGN/r7wLK dVe3OXj4VFU93D8458FddXra8FFJcAWRgLDY01pNuloS9oUAvcVtF1Jck1cDe6TnAf pleMQ3J4RqK9+Y1oi+puw7+UNiv0e8Ku2tJP9E3YUn+R5HPjM+LOlNZo1GnyBU8ZdJ 1v3Dd+VZ92Qqw== X-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.49; Wed, 21 Oct 2026 10:44:35 +0200 X-Received: (nullmailer pid 2570425 invoked by uid 1000); Wed, 21 Oct 2026 08:44:35 -0000 X-CC: <herbert@gondor.apana.org.au>, <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-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261015021747.30346-1-juny24602@gmail.com> X-ClientProxiedBy: EXCH-02.secunet.de (10.32.0.172) To EXCH-01.secunet.de (10.32.0.171)