Article View: linux.kernel.netdev
Article #6013[PATCH net-next v2 07/15] net: skbuff: let skb_zerocopy() copy a short skb without head_frag
From: Josef Bacik
Date: Wed, 21 Oct 2026 13:46
Date: Wed, 21 Oct 2026 13:46
76 lines
14876 bytes
14876 bytes
Commit 433380f5ab8f ("net: skbuff: don't BUG() on a missing head_frag in
skb_zerocopy()") turned the BUG_ON(!from->head_frag && !hlen) into an
-EFAULT return, but left it ahead of the small-payload path. That path
copies everything with skb_copy_bits() and never references the head
as a page, so the check doesn't apply to it.
Open vSwitch gets there with an ordinary request.
OVS_PACKET_CMD_EXECUTE allocates the packet with __dev_alloc_skb(...,
GFP_KERNEL), which gives it a kmalloc'd head without head_frag. A
POP_ETH action on a 14 byte frame leaves it empty, and a USERSPACE
action then queues it with queue_userspace_packet(), which calls
skb_zerocopy(user_skb, skb, 0, 0). That used to BUG(), and now the
upcall fails and the packet is counted as lost, with a WARN on
CONFIG_DEBUG_NET kernels. OVS_PACKET_CMD_EXECUTE only needs
CAP_NET_ADMIN in the user namespace that owns the network namespace,
so with the openvswitch module loaded any user can do this from their
own namespace.
Move the check below the small-payload path, so a zero-length copy
succeeds the same way it does for an skb with a head_frag, and document
the -EFAULT case.
Found by the Sashiko AI review of v2 of the series that made the
change.
Fixes: 433380f5ab8f ("net: skbuff: don't BUG() on a missing head_frag in skb_zerocopy()")
Link: https://lore.kernel.org/all/179173804997.434549.4450793967361922984@kernel.org/
Assisted-by: LLM
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
net/core/skbuff.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 3b2a3747f009..735dd25213bb 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4014,8 +4014,9 @@ EXPORT_SYMBOL_GPL(skb_zerocopy_headlen);
* Return value:
* 0: everything is OK
* -ENOMEM: couldn't orphan frags of @from due to lack of memory
- * -EFAULT: skb_copy_bits() found some problem with skb geometry, or readable head
- * payload would be mixed with unreadable frags.
+ * -EFAULT: skb_copy_bits() found some problem with skb geometry, @from has
+ * no head_frag and @hlen is 0 while @len doesn't fit in @to's tailroom,
+ * or readable head payload would be mixed with unreadable frags.
*/
int
skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)
@@ -4026,15 +4027,18 @@ skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)
struct page *page;
unsigned int offset;
+ /* dont bother with small payloads */
+ if (len <= skb_tailroom(to))
+ return skb_copy_bits(from, 0, skb_put(to, len), len);
+
+ /* Without a head_frag the head can't be referenced as a page, so the
+ * caller has to ask for it to be copied.
+ */
if (unlikely(!from->head_frag && !hlen)) {
DEBUG_NET_WARN_ON_ONCE(1);
return -EFAULT;
}
- /* dont bother with small payloads */
- if (len <= skb_tailroom(to))
- return skb_copy_bits(from, 0, skb_put(to, len), len);
-
if (hlen) {
ret = skb_copy_bits(from, 0, skb_put(to, hlen), hlen);
if (unlikely(ret))
--
2.55.0
Technical Details
Message-ID:
<20261021-b4-skbuff-bug-on-followups-v2-7-2aa780a03524@toxicpanda.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-350032-linux-kernel-netdev=dewy.ruReferences:
<20261021-b4-skbuff-bug-on-followups-v2-0-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-350032-linux-kernel-netdev=dewy.ru
From: josef@toxicpanda.com (Josef Bacik)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v2 07/15] net: skbuff: let skb_zerocopy() copy a
short skb without head_frag
Date: Wed, 21 Oct 2026 13:46:51 +0000
Organization: Usenet Network
Message-ID: <20261021-b4-skbuff-bug-on-followups-v2-7-2aa780a03524@toxicpanda.com>
References: <20261021-b4-skbuff-bug-on-followups-v2-0-2aa780a03524@toxicpanda.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="4157073"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Q9PlzvDuU76iCe4FEo/D38LYQNM= sha256:BHvPcCtzYUT+QDXbUXAsPNuo2AfJcuVElkvsMkEYERs=
sha1:rrSWurQ2VKhnILGtguUIMzuTy2A= sha256:bC5X55f3S38TXoHuwp20qGSOwHaoJnxwDEYyp1Usz4g=
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 0B62D111019; Wed, 21 Oct 2026 16:48:45 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.149
X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31
tests=[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=toxicpanda.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 kaObQikMCPpy;
Wed, 21 Oct 2026 16:48:42 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-350032-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=toxicpanda.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
by mail.dewy.ru (Postfix) with ESMTPS id 0B207111017; Wed, 21 Oct 2026 16:48:33 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sto.lore.kernel.org (Postfix) with ESMTP id 31D7F6153DD; Wed, 21 Oct 2026 13:47:40 +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=1792590443;
b=Aj3ws5Yi1/YROPg7fWQhrlK1NBXMrlI83S2O6caqylTS2gpFkbA1IuSysbBvkWUVqF92
CmHSfDP2ixFkOYqwLYbG7Xicqzdjy9Fk8DlwkqqKKzwSJFlxDuspe4uVWqPfWbSSgjZ/G
wZ0l9m8+o5PAAh6BhgxQz54yxvOArZOqJO0DUfF3o1Gnx401Kk3wllcvintIolMO+CHL5
2j2lhYWI1gbQ/y3yeZitkr6MTcrDGLEu0ScwFwT88n+j0J1p/KacMQnDQbYHQSZxd6zAH
qm5/2dRdKNuuoXGHXZZSCKyZek2yRse0o+3R4IgKHc/eR+2QiANy5R83u3xi1jOi9LQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792590443;
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:From:Date:Subject:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding:
Message-Id:References:In-Reply-To:To:Cc:X-Mailer:
X-Developer-Signature:X-Developer-Key;
bh=YbXvQLGgZpsimSrfs+W8d8Jbr4mc/fISMihOBkAlu6E=;
b=XdB9G86ymJVeIslpt9hHDPs6I/z2LduGibog2EwG5i4UQDH4t8zPugybyz1Szpe8tl5R
PgBj7PbmYW4PuR/3plwjpP+T4Gqp4WPkKvJ6cAZZ10AdvbLMk3/uMZA6hclp3Fmms81lM
pOMfpaV3ESuULPHtWehPUa0ZAgQx1tfIr/u6xNOJoSZcasZOxionIVG4XhpXD6gY79uPt
GNdFsGuEP3gPMOlDui9Lafkzd6ICGN3132ttAR605VVaygnWjV7h943vHKYESvQYOyzNU
rGXEdXXBxpZ5kMsZPOTEcgBdgq5WCt5BTIUWy7d8nk/sdyDNtVm4YQlKeKVmEI2H1TQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=toxicpanda.com header.i=@toxicpanda.com header.a=rsa-sha256 header.s=google header.b=nP1k35NF;
dmarc=none header.from=toxicpanda.com;
spf=pass smtp.mailfrom=toxicpanda.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 E32A460A2608;
Wed, 21 Oct 2026 13:47:22 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=toxicpanda.com header.i=@toxicpanda.com header.a=rsa-sha256 header.s=google header.b=nP1k35NF
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.172
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1792590442;
b=gW72gd+mgDCs0f5o7qakOeF9E4iEVPmXx21EkcRrlgBQBZj/xCClKQ9iIEvDdbVWNT8z
sPfHLi5T844E52TmtMZOlehIIHJMiLcVLAnt0c33YxP5luo24mOWMOLSVQC8Xy579Z1Jn
GQVswGdM8gyLwvpup4SpYEWOXLpiHgffss1WrGmzfTmFxP02sLhaanlo0marWAfNYmp4b
tMEJEcOdMGZI2fvXZsetlLWX7oTcvh/vFs0KKXZC8VSSN3eY5kk6brk/8J9mSG2dnp7qk
pqU14hOMN4x6Sl0dN2WRvcjQIINMKaOFex+ki8WTgHdwZk1k9r0brEClfKba2k8w3Uw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792590442;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:
Message-Id:References:In-Reply-To:To:Cc:X-Mailer:
X-Developer-Signature:X-Developer-Key;
bh=YbXvQLGgZpsimSrfs+W8d8Jbr4mc/fISMihOBkAlu6E=;
b=wu/Q4YKjE2Y1p7z7oflgN23dSGyZk4rNcHwxJHqJBte7JpzHXiOOiSpZm9xNojcvVIsR
xHeL5J3+LW9NrjojuWpQ430rONYigcJTamemhG8ycIVojcRKORmN0/SNJukrxKnY1B2HP
sOqwvof6Z4ODRTodwjlx2u85kxEiz+h+ULy1fd6w8n1XO7rW+x//ZmLx7D/3ChNdhr/Hr
m7/c5f/BvBkMccmayqPbrzOpR0FE5XgGLMMmur0wBxqP4JjxigGnsrAVACFFYKCgzUYlq
PL5iMCTsCXsqzjI++6K3Ic7fq23BJUSIAfljC4WzR+0BC1W+YEMb3mNax6nTGGFMzcA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=none header.from=toxicpanda.com;
spf=pass smtp.mailfrom=toxicpanda.com;
dkim=pass header.d=toxicpanda.com header.i=@toxicpanda.com header.a=rsa-sha256 header.s=google header.b=nP1k35NF;
arc=none smtp.remote-ip=209.85.160.172
X-Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172])
(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 B0F3C60A2604
for <netdev@vger.kernel.org>; Wed, 21 Oct 2026 13:47:21 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B0F3C60A2604
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=toxicpanda.com
X-Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-53648215f9dso6083841cf.2
for <netdev@vger.kernel.org>; Wed, 21 Oct 2026 06:47:21 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=toxicpanda.com; s=google; t=1792590440; x=1793195240; darn=vger.kernel.org;
h=cc:to:in-reply-to:references:message-id:content-transfer-encoding
:content-type:mime-version:subject:date:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=YbXvQLGgZpsimSrfs+W8d8Jbr4mc/fISMihOBkAlu6E=;
b=nP1k35NFaawkKzouM3+/BGOSEqB5dbv3yH5MfvEk8wfy09JySEYZVij9q9X35HBIiq
fTNwQ5k+XuIQJ+SjJqohpaAVKpDurLHWUf1HCWXKzqsWEIbwJGGe4A2SGt374I6/sG9m
OZgZ92jvIFtoz7GaX62LUuyl0t9r+PS4IudSoJVqUqapL5ZqxXvo1hCuvPtq0VnwzCEX
WN5lUYSKF7d3U/dv6lv0oGeNeNxCY9BY5GmatNxSQHvwveFS81jK1TJyadIyMJwnZHPD
kB14YqnWeXDiRQYVYT3AG+YH8bHG4G48N0wkti5H81tN4YtMt2Mc3npZ2xZf7yupS71C
Wc6Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792590440; x=1793195240;
h=cc:to:in-reply-to:references:message-id:content-transfer-encoding
:content-type:mime-version:subject:date:from:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message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rRwBXROgS04KyV37ZZ1Dbo/9goG3dNhEAWb+G6
oqxIqneBdVj9+95msqA0+IoygWqDiYpvohWhlOyQySqzxM60Wz9kt2gJWcKa3iRbNba6vAST1c+
cu/GfpkZwb7m/NXYkJAc5/2DGok0qCGCfjrI4VNgcrWkvQDtG1rJC/v5L8zR9DFspwx1WCV
X-Received: by 2002:ac8:59c9:0:b0:535:1a91:1d24 with SMTP id d75a77b69052e-5369b7f388fmr31766751cf.43.1792590440431;
Wed, 21 Oct 2026 06:47:20 -0700 (PDT)
X-Received: from toxicpanda.com ([153.61.196.246])
by smtp.gmail.com with ESMTPSA id d75a77b69052e-536ab6f1cd7sm99741cf.10.2026.10.21.06.47.19
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 21 Oct 2026 06:47:19 -0700 (PDT)
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: <20261021-b4-skbuff-bug-on-followups-v2-0-2aa780a03524@toxicpanda.com>
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, Josef Bacik <josef@toxicpanda.com>
X-Mailer: b4 0.15.2
X-Developer-Signature: v=1; a=openssh-sha256; t=1792590423; l=3126;
i=josef@toxicpanda.com; h=from:subject:message-id;
bh=p1EJ3Mjc5nJGteUiFCelu7Pkg91i/fkjkkkh/ts8Tfs=;
b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUBr36M/n0nWN0DNbnxwzIiCZez6MG
JiruuNaSCI/zXsAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA
QNjL87kVYWUrnftY9mKgbby2CAWEAfeQsOPkOxYJxwdVe1tb8PkhdyoBdSvFLiY/y+B7u4uFDoJ
YD3tF1Z8SYAA=
X-Developer-Key: i=josef@toxicpanda.com; a=openssh;
fpr=SHA256:C8kOX2QUJCMqnCX+KEeoqRAjLo9L+ELOSH2NSAJHqGA