Article View: linux.kernel.netdev
Article #6264Re: [PATCH net-next v2 11/15] net: skbuff: refuse to segment a nested frag_list
From: Willem de Bruijn
Date: Thu, 22 Oct 2026 01:47
Date: Thu, 22 Oct 2026 01:47
91 lines
14688 bytes
14688 bytes
Josef Bacik wrote:
> skb_segment() walks head_skb's frag_list, but for each member it only
> looks at the linear part and frags[], never at the member's own
> frag_list. head_skb->len still counts those bytes, so with a nested
> frag_list the walk runs out of members while it still owes data, sets
> list_skb to NULL, and dereferences it on a later pass, before any of
> the layout checks get a chance to catch it. When the member is taken
> whole with skb_clone(), the pskb_trim() that follows also drops its
> nested data.
>
> Nothing in the tree is known to build such an skb; GRO flushes instead
> of chaining an skb that already has a frag_list. Check each member as
> the walk takes it, in the GSO_BY_FRAGS, clone and frag paths, and fail
> the segmentation with -EINVAL if there's no member left or it has its
> own frag_list, with a DEBUG_NET_WARN_ON_ONCE() for debug kernels, like
> the other frag_list layout checks. Without SG the payload is copied
> with helpers that do recurse into nested frag_lists, so that path is
> left alone.
>
> Suggested-by: Willem de Bruijn <willemb@google.com>
> Assisted-by: LLM
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
> net/core/skbuff.c | 22 ++++++++++++++++++++--
> 1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 56cec58bccb7..c5e28a52114b 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -5087,6 +5087,15 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
> int size;
>
> if (unlikely(gso_by_frags)) {
> + /* The walk only goes one level deep: running out of
> + * members, or finding one with its own frag_list, means
> + * a nested frag_list that head_skb->len counts.
> + */
> + if (unlikely(!list_skb || skb_has_frag_list(list_skb))) {
> + DEBUG_NET_WARN_ON_ONCE(1);
> + err = -EINVAL;
> + goto err;
> + }
This patch became quite a bit more complex because of my request.
More than I anticipated.
Are you sure this first block is needed?
> len = list_skb->len;
> } else {
> len = head_skb->len - offset;
> @@ -5096,9 +5105,11 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
>
> hsize = skb_headlen(head_skb) - offset;
>
> - if (hsize <= 0 && i >= nfrags && skb_headlen(list_skb) &&
> + if (hsize <= 0 && i >= nfrags && list_skb &&
this test for list_skb != NULL is new. Previously this code already
tested skb_headlen(list_skb) without it. Likely not needed for
anything new in this patch?
> + skb_headlen(list_skb) &&
> (skb_headlen(list_skb) == len || sg)) {
> - if (unlikely(skb_headlen(list_skb) > len)) {
> + if (unlikely(skb_headlen(list_skb) > len ||
> + skb_has_frag_list(list_skb))) {
> DEBUG_NET_WARN_ON_ONCE(1);
> err = -EINVAL;
> goto err;
> @@ -5216,6 +5227,13 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
>
> while (pos < offset + len) {
> if (i >= nfrags) {
> + if (unlikely(!list_skb ||
> + skb_has_frag_list(list_skb))) {
> + DEBUG_NET_WARN_ON_ONCE(1);
> + err = -EINVAL;
> + goto err;
> + }
> +
> if (skb_orphan_frags(list_skb, GFP_ATOMIC) ||
> skb_zerocopy_clone(nskb, list_skb,
> GFP_ATOMIC))
>
> --
> 2.55.0
>
Technical Details
Message-ID:
<willemdebruijn.kernel.11bad1f39601b@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-350342-linux-kernel-netdev=dewy.ruReferences:
<20261021-b4-skbuff-bug-on-followups-v2-0-2aa780a03524@toxicpanda.com> <20261021-b4-skbuff-bug-on-followups-v2-11-2aa780a03524@toxicpanda.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-350342-linux-kernel-netdev=dewy.ru
From: willemdebruijn.kernel@gmail.com (Willem de Bruijn)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2 11/15] net: skbuff: refuse to segment a nested
frag_list
Date: Wed, 21 Oct 2026 21:47:15 -0400
Organization: Usenet Network
Message-ID: <willemdebruijn.kernel.11bad1f39601b@gmail.com>
References: <20261021-b4-skbuff-bug-on-followups-v2-0-2aa780a03524@toxicpanda.com>
<20261021-b4-skbuff-bug-on-followups-v2-11-2aa780a03524@toxicpanda.com>
MIME-Version: 1.0
Content-Type: text/plain;
charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="106952"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:u32rIsZVrwncZi5th6XnobiPx6w= sha256:H5v1eGThPOli16G8BPqgycP5klCA5a3/jnvBfm92IZo=
sha1:6CEmKPinCPGgdxckLz6WDw2k7Fk= sha256:H0Tk8G3dGZLupblkajm0j1OXhgqCjiU5+/lMmjniWaw=
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 A2A4D111179; Thu, 22 Oct 2026 04:47:37 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 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, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham 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 wbGYfZhkHZge;
Thu, 22 Oct 2026 04:47:35 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-350342-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id C713210E488; Thu, 22 Oct 2026 04:47:26 +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 4EFFA391BD; Thu, 22 Oct 2026 01:47:19 +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=1792633638;
b=Jx8zr6p5+44ANBGJmsiW0YKCeG/1nLuz+c3g13hqDdf3za6U+cEf2J0QvBjlWBWtGe3P
HDfcYVs+g373blTHiCxOMf9/V5+Wk3w1xZ/dAefgSIjV7DfgmG5vdz5lAnWU2ncyElORD
vgv6pXiy6HhBvqMJm+7cnOGGuio3QVZod5hoKDsJXLZMh1krIkPabga/vTUnGF+Xmr16k
JCtPx1F5TJL6z28ziY4Jmo5ouWvi1hZmtHsq1REjnhtJJgkDQza8uaj2d1inzNHPeIB5g
E1gkxF6l0eEvofK34AYy5DqAetAiGFXxwLSGH9eXObWaDTeb9KTeFc+MaH4ly38ZCwg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792633638;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:Date:From:To:Cc:Message-ID:In-Reply-To:
References:Subject:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Type:Content-Transfer-Encoding;
bh=jCKRYOUlKmoPJSnDi6pvpqUte660v3ToEOh1Wa/1TdM=;
b=xdogjRwqosKya7ifUCronnqLdANMW1PLjMfaEi5iTPgvqQ2N1Pwdj7LtLQ04JBPqBRMt
28ZK6MC34bx8YZZus3GGMPUyN59A3z7/EhO16AqqJyqOzoE2aSF97szqVtTeuMVaKja9N
iQNGby44osJHR/FzwT9kQM5w9m1VkstEX8vEMPxLADZX/bkj0yeDhb6PAItLwsuPScDPF
Hpgn+dliA/5Q3TEv7qcZR2foUaZySfCo/7wRMCYHTBzERCQHnk9iQCGCMp2c1l6zjS447
IavSfvZ0xByTjQfAR9306Kjj+fUVy7cpEZir7f6z4XZohxfrRft74StqcNrdtBRoWFQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=e8bkoLYx;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.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 974FA606A320;
Thu, 22 Oct 2026 01:47:18 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=e8bkoLYx
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.173
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1792633637;
b=D9AhJ71kwCjo2C7BuZ5rI46GTbzKtX74AbRiYoYFo1n9whhKbNANHQ/+R6c0WufSAcWA
2U/d1ngM/qxEzYE1a/Lz0GzxY1+ato7yUR1EtlUk+97A6poCaibN2rReOET+QjHiv4W93
mVkWB83FmQWeNtNUqLEHKWyeMvrEWheeJOwlBBT0is+LqniqKQOv6TdhrIqL7d+ACKbTk
nE6ZW6+tqXZZTV6li75gp24Y1a8M0ezwocSgPOD+vcKdzY71r83PXSnBiQzfxSW9eueMA
J+uzNHUFN3bkV+d/MD3hJDLXu/G4N+zS/mhWZe42+45MQhgQAK3IzNjzqiKSMWw3Wew==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792633637;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject:
MIME-Version:Content-Type:Content-Transfer-Encoding;
bh=jCKRYOUlKmoPJSnDi6pvpqUte660v3ToEOh1Wa/1TdM=;
b=SK6eb8vq5EVLJ4qfjbEZOjKFQZjQlA/8P9noXev7Cxgd7Il4HelWoPD1BK+SHUlH83Ms
m2py4gauynLvC52Cr1BwcGomi3LwJZGj4u+UpO95llwM4M6qRZFJOMp5ROLIiHj06SfaN
RN87iFWZFAre4rzckX47JI6Yb+hgyiVzx0Ohpr+/5GhabHyHrhvYqdgMiIsI9CEufk2Q3
dxuAts4rrzEPqIk0ZlGocgHpBjUR5jCwL6ooT8MC9trz3Wy2cXpQ4i5+iAfL14VYds9Z0
l5tbQjZ08Beq6OoGi0SpFz/kpJDwjkeQonnMFxVepjkzYQtqCrbYlUX4hbU2HRz7VzA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=e8bkoLYx;
arc=none smtp.remote-ip=209.85.221.173
X-Received: from mail-vk1-f173.google.com (mail-vk1-f173.google.com [209.85.221.173])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5554B606A319
for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 01:47:17 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5554B606A319
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-vk1-f173.google.com with SMTP id 71dfb90a1353d-5eaefe5b523so845885e0c.0
for <netdev@vger.kernel.org>; Wed, 21 Oct 2026 18:47:17 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1792633636; x=1793238436; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:mime-version:subject
:references:in-reply-to:message-id:cc:to:from:date:from:to:cc
:subject:date:message-id:reply-to:content-type;
bh=jCKRYOUlKmoPJSnDi6pvpqUte660v3ToEOh1Wa/1TdM=;
b=e8bkoLYx7ax0rHmA5TVR5sVFCMou4ByuTnwIf3iAcEpdWK+SFphmKlwpW7HJBj8mn2
eH5E+xrhrJjWibsOnefdCOeheNZyN0+D/b8y09ssUcRUmEIw7iBrsgZrT9icLNw1BJMR
MSdImODSw8S5llUMVkn4uKfDZ9il1/XKx6cwK89XvSDs+/lrSk3jZVKMsHdBhJYBnkmq
wz2N41cM1YyT2pP3WKb9J4bINV0gLk3WepaRZ34hDCh7hqImMZ+98sa6ExwpRUw7A5W5
lnU2RJiZPAdgX25/0JNNuKea0G2V3cyP8LjSfWjerY5bYBcz/Hyrk5O9q7QbCP/D7s64
/xAg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792633636; x=1793238436;
h=content-transfer-encoding:content-type:mime-version:subject
:references:in-reply-to:message-id:cc:to:from:date:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=jCKRYOUlKmoPJSnDi6pvpqUte660v3ToEOh1Wa/1TdM=;
b=GZOvIPh+1ChOi+v0U1OpD4Mkfm61/CkzogJqhQLKp9UVbSRupQrSdkMLgmpxNTR4vE
kL3bejujw+JaBCdtxp5K/g7w0RvtQFoKGDmyqRnTxzwOuGvPyCkOvctW+CxPYvgbedfR
U8e3D8vCw1p+O24emukox1qfmd8dJJfwKzMPMwFWB6Opae1QzHEOw4annB5MsECyVhs1
8UT/7UomAmr9aCmkuekBFZBAT+rM6gWpVhvaKK/kERwYxDJWdDz+499oPoOsmCMfWrKR
upPfzZ3DFa2Iv5xMDp1jpSCjU+JgE5coXD5PyZkwD7R7O9tRNRLSFl6WQ8bTydxfAnWS
MV7w==
X-Forwarded-Encrypted: i=1; AKwUvBwvQMlh+hrzFdKb0BGqTOCfuvhgqJ/A0m6LGX0wCfWmX184eChZSscWoJMcdiAgycswonYqhgE=@vger.kernel.org
X-Gm-Message-State: AFq9FYJ+ze5dv9GQeF8+BJZUROl/8h2S4TXMVjyvjYHwIIGTMhI0OhHi
tdOJO3Yf4de659hlSDq50gfBjMrJArBe5OBG0JhzKEwutgiw9z4osZIo
X-Gm-Gg: AYBFou36r5awL31iZoqhGKbGlDoipZGWimH70mx/Rn4F+iGdbrHgJ3m+FiBN13gshBm
PPw8mC7xJny3Y2VaN0kfMOw3kui9exipSOm1Fy6EUFkMn9QUKyqa1u7lWhRkxIi3PV3fHmEUKfq
DdcMmD7W/T8564C5RWZpJMqbrk9Qj5jPyq/z9HdIK45a6ir/+n0e3gxch5otN2ZH16v0IQRyl8K
DpimCauMz3AErFdoOr4fhpo545G5Je/d1LBbtTsS9OyJceZ/co3u54gxnpVYDk11VTeXF9mHO8M
3cH7lQ4tK2OKOOQNQvJiLYTnwENRnVj1zIXaUron+LU1aNMvn5nBXSZlkGiGacfkP34xqwAHNpc
x9OwLReI1IkqiWQx9f/qsDtQTZ9leVQfEqTNd58Z9jDMWXx3VWOcy8PJNzrDFlSlCysBqHe3FvE
/EQqvhs+Ht9dLJRaYwF6AUug5nZ/oF++2Rzad9dpu0Ma+rwHAlICpnQt118oMBJrz1HG0e4tqPc
QUKl5Jxeurh/tKlfycPWVpxmT2pXmkvTDDfSVuawDfAQ8T/XO0Ak1rKyX7vEOisViKZzysy50Bu
t6FnVWUruNICmppLdvwMWfkCF4VtFs4l/MaUCAxtCIyTThG0YqXC0z7OMHYP5UjopQN83GDBgrX
Ap+35gUwwmpAtONX94W0=
X-Received: by 2002:a05:6122:1d9f:b0:5e6:82ca:c551 with SMTP id 71dfb90a1353d-5eaebef16acmr1695454e0c.22.1792633636272;
Wed, 21 Oct 2026 18:47:16 -0700 (PDT)
X-Received: from gmail.com (111.46.245.35.bc.googleusercontent.com. [35.245.46.111])
by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5eae980f64esm5275613e0c.13.2026.10.21.18.47.15
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 21 Oct 2026 18:47:15 -0700 (PDT)
X-Cc: Juergen Gross <jgross@suse.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
Fernando Fernandez Mancera <fmancera@suse.de>,
Mina Almasry <almasrymina@google.com>,
David Laight <david.laight.linux@gmail.com>,
netdev@vger.kernel.org,
xen-devel@lists.xenproject.org,
Willem de Bruijn <willemb@google.com>,
Josef Bacik <josef@toxicpanda.com>
X-In-Reply-To: <20261021-b4-skbuff-bug-on-followups-v2-11-2aa780a03524@toxicpanda.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