🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #5555

[PATCH net] net: shrink the payload-only part of skb dataref to one bit

#5555
From: Eric Dumazet
Date: Tue, 20 Oct 2026 15:19
75 lines
9314 bytes
skb_shinfo(skb)->dataref is split in two 16-bit halves: the lower
one counts all references, the upper one the payload-only (nohdr)
references.

__skb_clone() increments dataref without bound, and skb_cloned()
only checks the low 16 bits. With 65,537 references the low half
reads 1, the head looks private, and pskb_expand_head() (or
skb_unclone(), skb_cow(), ...) frees it while clones still point
to it.

An unprivileged user can reach this from a user and network namespace:
about 32,770 AF_PACKET sockets on lo bring dataref to 0x10001, then
any pskb_expand_head() on the receive path (here a pull of a large
IPv6 Hop-by-Hop header) frees the shared head:

BUG: KASAN: slab-use-after-free in _copy_to_iter+0x187/0x1330
Read of size 1590 at addr ff110001104a9002 by task dataref_wrap/87
 skb_copy_datagram_iter+0x60/0x190
 packet_recvmsg+0x1f5/0x12b0
 __sys_recvfrom+0x18d/0x290
Freed by task 87:
 kfree+0xf3/0x3b0
 pskb_expand_head+0x344/0xeb0
 __pskb_pull_tail+0xf9/0x1bf0
 ipv6_parse_hopopts+0x377/0x4f0
 ip6_rcv_core+0xc67/0x1620

The upper half never holds more than 1. It is only set by
__skb_header_release(), with atomic_set() on an skb owning its head
(TCP/SCTP output, and GRO which never sees cloned skbs).
__skb_clone() clears nohdr, and __copy_skb_header() does not copy it.

Move SKB_DATAREF_SHIFT to 30, so that the reference count gets 30 bits,
and dataref stays positive. Wrapping it would need 2^30 live clones of
a single skb, which socket buffer limits and memory make unreachable.

This issue was found by Anthropic using Claude, and validated by
Ada Logics.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: Stephan Lipp <Stephan@adalogics.com>
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
---
 include/linux/skbuff.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a3ff380d43f01db0b040573c9dd7acc4e2e2cda8..58007e5db61e0228e773dc9ee688fcd1d056a345 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -633,9 +633,9 @@ struct skb_shared_info {
  *
  * Transport layers send out clones of payload skbs they hold for
  * retransmissions. To allow lower layers of the stack to prepend their headers
- * we split &skb_shared_info.dataref into two halves.
- * The lower 16 bits count the overall number of references.
- * The higher 16 bits indicate how many of the references are payload-only.
+ * we split &skb_shared_info.dataref into two parts.
+ * The lower 30 bits count the overall number of references.
+ * Bit 30 indicates whether one of the references is payload-only.
  * skb_header_cloned() checks if skb is allowed to add / write the headers.
  *
  * The creator of the skb (e.g. TCP) marks its skb as &sk_buff.nohdr
@@ -655,7 +655,7 @@ struct skb_shared_info {
  * Having multiple payload-only skbs with different lengths of hdr_len is not
  * possible. The payload-only skbs should never leave their owner.
  */
-#define SKB_DATAREF_SHIFT 16
+#define SKB_DATAREF_SHIFT 30
 #define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1)
 
 
-- 
2.53.0
Technical Details
Message-ID: <20261020151954.22953-1-edumazet@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349357-linux-kernel-netdev=dewy.ru

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-349357-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] net: shrink the payload-only part of skb dataref to one bit
Date: Tue, 20 Oct 2026 17:19:54 +0200
Organization: Usenet Network
Message-ID: <20261020151954.22953-1-edumazet@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3882017"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:gYyWcrxLsJyyQL6DXslhv9yk1WI= sha256:ZzWUxJIUb51M9uiSeVGRfn3HTbK1yTETb6kjlBpfnec=
	sha1:twD+UZQ0V6j2ntvXuWbXaEXVwdA= sha256:Ab0VEoImvXZlLRMhwVIIxnz+/BlwYEZk7hZQtEDA5aI=
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 5540F110D4A; Tue, 20 Oct 2026 18:21:12 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.3
X-Spam-Status: No, score=-3.3 tagged_above=-9999 required=6.31
	tests=[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-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 yDV3L4CE8xxZ;
	Tue, 20 Oct 2026 18:21:09 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-349357-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id BDC7D110D47; Tue, 20 Oct 2026 18:21:06 +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 8B2D160D484; Tue, 20 Oct 2026 15:20:30 +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=1792509629;
	b=gChuYOB3E5D9njlOg+CqybIF1c80/rEbZ86gRzePN6GfCkO8jqHWtXJFnUfujuXNVnuq
	 NsYaJisFNAyq+9LI+P+0xtXH67Jto+XaTTj9Q+oxqt7XFiykr2GXcr7D/6dsVUuD0heRw
	 zKz8UHOtPxi5jfGxGur/Mu/RkJkUyCUwC9kPDvOFszla69Ab6Mm117A434FQWgp49tlRo
	 wIA9URbyK+UALYzhIdu43KY486mR8U/1Dnz7nVLz4LqtS+EiJGMfyAU+7pAwMrV8oMJ50
	 anWxwX1eo5rDDux4dUrEYFSoWw8Nisr1zb6Y5WVPKCb5LTtC3MvLgzZHvKLm/hAnZQQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792509629;
	h=X-Original-To:Received:Received:From:To:Cc:Subject:Date:Message-ID:
	 X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=p9TIKS8VDMW+tXGZ/hE86qwPZJdVFZaNx+Bs5qu9VnI=;
	b=BvbMu1NPGimSwOwi9Trf5XeLQJcccBc3Oh3IE9VpHCMeOtJZnrLUVm5yoBFqjTBtUz3d
	 AOMROMo7FDio/yN5J97jAOoqd23nKX8pzZsvsDgZSK9j0Nie88673ewGvikuP9Szbybji
	 M5zDqxk2IwxQlk77XTnQ9qehfY+YL3Dn38WfrJg8DM4HyL30fmrPvF83ld6/se+4XTmok
	 AJx5qUJxZ8ZkLVRU71+2Yal0Jyi3NxncO1A7MmGf9IEaCh6550bBPjXXyUH7uMk7tdxst
	 xwV1RwekLTA056EH5+XxOpDdSumJzsImxdcMvQEW776aRVT2SV+gdR+lCM3LGf4ukXA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	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 7ACD9606A33A;
	Tue, 20 Oct 2026 15:20:29 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792509628;
	b=bJ1Ov+BqclPatD0q748CedXZL3sqp+rLsbmhedwIOEuUUflE4hNBh6f0UEvIJArVa146
	 AezIjW2TLhiP9Rdl5mqYauk4mOmkd3FCb5d1LlrwwASE2pHC/xylBhhyCcLrO8Xx0bYCy
	 dP9wmYjhFKWfdpz/QRz08Ku1jVIW8KTZi0ynernz2oxIctSueh7RdAHWRxfycZ/OUEKxT
	 BO9TqGe263XJzJqCViitJ1vzc820FjbNKYxS0jrDy95Je9ikIa6RuIu6yPco/H8MjVwnX
	 uBLvSesIeO2CBRVBWverjBLBtrH8R8eRcONkz8SkPDctJkbKdrSHHc4nMxMNT9YLbPg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792509628;
	h=Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=p9TIKS8VDMW+tXGZ/hE86qwPZJdVFZaNx+Bs5qu9VnI=;
	b=AQp5WdnlAF4inT8VSYVKcL60rlrZd8LTUMCzk8dLbBpfBzlcfD/6IjSColM/c8S+fZyj
	 nnH3YbbavMwrpnfhZFgE2j1s65YTUm66GeWU1+mIZwqenVyymkHm6kUYeDza8/blTEJjr
	 iJTfot3VRkgsbVrla1BBB4T5AwZY5/ruoNXnFNOqPgra9MFyj8F6CXkOApIkiCxetMRLg
	 TYXP25k5gxu8RJOXWhptXZ2VC86EnWifb7DWfBcc9t8wEAvMONe5MiG6bD0pkj9O5IZ5B
	 VH1LxTDhOF6ot+lZBelIPxnXwPVLt0sL+9292Z9PnGxmBIX30CJCEgnbrpJAVnsVu9w==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E423606A31B
	for <netdev@vger.kernel.org>; Tue, 20 Oct 2026 15:20:28 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64BA91F000C4;
	Tue, 20 Oct 2026 15:20:26 +0000 (UTC)
X-Cc: Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org,
	Eric Dumazet <edumazet@kernel.org>,
	Stephan Lipp <Stephan@adalogics.com>
X-Mailer: git-send-email 2.53.0
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