🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #13702

[PATCH net v2 0/2] net: do not run out of frags in alloc_skb_with_frags()

#13702
From: Haishuang Yan
Date: Tue, 10 Nov 2026 15:46
39 lines
10491 bytes
alloc_skb_with_frags() can fail with -ENOBUFS for a data_len that passed
its own size check: it splits the tail into one frag per bit set in its
page count, and when a high-order allocation fails it lowers the order
without checking that the frags left can still hold the rest. With
vhost-net + tun, a guest that sends a GSO packet above 64K can then make
the vhost worker retry that packet forever (100% CPU, device dead).
Patch 1 fixes both cases; patch 2 adds a KUnit test for the tail case.

The issues were found with the help of an AI coding assistant.

Changes in v2:
- Patch 1: also fix the fallback after a failed high-order allocation:
  only lower the order while the frags left can hold the rest, else
  retry the same order once with direct reclaim (reported by the netdev
  AI review of v1). Changelog and test notes updated, including fault
  injection results.
- Patch 1: reword the comment as suggested by Narcisa, and compute the
  page count with DIV_ROUND_UP() to keep the line within 80 columns.
- Patch 1: say in the changelog that this only fixes the frag accounting;
  larger frames failing in tun_alloc_skb() are a separate problem.
- Patch 2: skip the test instead of failing it when no order-3 page can
  be had, and name the fix by its subject. Dropped Narcisa's Reviewed-by
  since the test changed.

v1: https://lore.kernel.org/netdev/20261108100617.23840-1-yanhaishuang@cmss.chinamobile.com/

Haishuang Yan (2):
  net: do not run out of frags in alloc_skb_with_frags()
  net: add a KUnit test for the alloc_skb_with_frags() tail split

 net/core/net_test.c | 35 +++++++++++++++++++++++++++++++++++
 net/core/skbuff.c   | 30 ++++++++++++++++++++++++++++--
 2 files changed, 63 insertions(+), 2 deletions(-)


base-commit: a45dbf182137275f44ad7c8bc8acd23f7af6b2cf
-- 
2.43.0
Technical Details
Message-ID: <20261110154701.26310-1-yanhaishuang@cmss.chinamobile.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359947-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359947-linux-kernel-netdev=dewy.ru
From: yanhaishuang@cmss.chinamobile.com (Haishuang Yan)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2 0/2] net: do not run out of frags in alloc_skb_with_frags()
Date: Wed, 11 Nov 2026 00:46:59 +0900
Organization: Usenet Network
Message-ID: <20261110154701.26310-1-yanhaishuang@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="553342"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:KDpnKnVsDKQVQ3Wa8jcrdz5HPrg= sha256:SdXSt6r/CBwb2Kw0iScsT59uR5EwBQRVu1oe4YWTq0Y=
	sha1:s4dZx22YPxWXC4Hzy6sGXK9FeMI= sha256:6LtLwUK+uhRGsiYJEnuz+09NRUaD8Gq7aJsLB0WSSuE=
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 AA7DD1139D8; Tue, 10 Nov 2026 10:56:04 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.749
X-Spam-Status: No, score=-2.749 tagged_above=-9999 required=6.31
	tests=[DATE_IN_FUTURE_06_12=0.001, DCC_REPUT_70_89=0.1,
	DKIM_INVALID=0.1, DKIM_SIGNED=0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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=fail (1024-bit key)
	reason="fail (body has been altered)" header.d=cmss.chinamobile.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 4bxEsZQYiINh;
	Tue, 10 Nov 2026 10:55:59 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-359947-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=cmss.chinamobile.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id C595C113A6D; Tue, 10 Nov 2026 10:55:48 +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 C450D43BAB; Tue, 10 Nov 2026 07:54:59 +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=1794297215;
	b=DQo7TG4VEMvTtvLhVyh5BCvtMvh3zcKt6b/MADWq33kjILhl8K7A1FQpmRFLvWUuWzbQ
	 Wboy0vYodgtzqk9bea8IQDTlUejzZNK7RYA/HS1JGpzQhirBrY8/FMr35d/QDcHlKn3k4
	 lW0eHg6dwVHJZ9xvLLjrUc4UGisrql6jXIgSHzR7ca2AL1vLwAYbwEG9UZbJNgu68myrQ
	 TxTvhSWzZ8dnlKIbTIEdo9srKHQp3Eqyx6L1Gl2Hinod8QSA12SaBIMktPDdTiYHxUyEm
	 cD+1XHAvC5qVqP5Z9r52HLJn3AtheMvy0in5df6zgUI9gr5l4B6vUjhINlnTm8Z/5OQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794297215;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-RM-TagInfo:
	 X-RM-SPAM-FLAG:Received:X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:
	 Received:X-RM-TRANSID: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=VHS9PME+lj3sobM0nuC4YjIOUceVBhWAlwGY7ffSBGc=;
	b=G4z85n9+3HaABVIG6iO8SN65YgNTJgCwoJ5m8Q9fYH77ldLqOb0OYjNRSj4BXbBY6v56
	 xvysFeJZtHigHT8DkHrre1qL3gyvqRkhvmX8tw3iQFZfaHB2OGGS2+pPKKpjQ8NzPde+x
	 ze1ZRrSzj6UFkdkvYIgZoHM3E98lDx/P3Q577jVAuPYyf1JNEREDUtQeHLLA8eLY2NJvG
	 Jo7gJvDj9Z0o4Qn+PeAjXE/P/0pzJA4cEj459XTEbNf/tmZBSIwEYS6eIAOn/dSUqrMH/
	 TCYeoEskX3SYBFZH8JR0Y7ReCL1Lri0c6VJ4PEL4kOXpG1nPYM7BoChTI9KjX2GUOwQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b="mW9Vdaz/";
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.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 34D84606A337;
	Tue, 10 Nov 2026 07:53:35 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=mW9Vdaz/
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.139
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794297209;
	b=EGMfALqxikwABBhjW1zP7lV73foPnooL0RR8Boujje8sEPPn8TKYC74KQVDlsTXmvs9o
	 02Soa0HhlyY84hcjAmhGFRma8rQlNzY6eTES4PSQ37KwQAg1tts4Fo0We+Wbr+5U7yA0W
	 WJ+tp/uukCXV5e8GgCbUnPbp7aI+F2l1KS6lK6m+PhLQuzmIxvEBVjPMt/tPEiazHeUzk
	 dbKI060xj+pih16zKESBNMd481V3Qa6i9ryQoQkqWaCQhT/D0n8DuoJyJRI1cySYynkhr
	 Hh/NgMCjc7dl3p1Rrt5l3XsLy3u4U9bFwh95Rz6yzzRgSXBAAyXzxGP2BYf+fuYx9oA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794297209;
	h=DMARC-Filter:DKIM-Signature:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:
	 X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:X-RM-TRANSID:From:
	 To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=VHS9PME+lj3sobM0nuC4YjIOUceVBhWAlwGY7ffSBGc=;
	b=qZJ1Bmg8bj6QEkl1xpNoIN9m3q3UZUQO73C3e9BFLxoW55ze7nMAa2eyKHPS8yTA/XG/
	 TOGjVHt0Xf06hFXprc9BpD4frxcb54JaBvMWS8Rfkr5zpv0R+5dVwYtBnKrV9Q+eIpAn5
	 uK+GG2rEdL7oy1FqdFZm/ORXxoa+4gEj9Em5ax76ij6nnmDzwnhdVh3wpS7PkKz7eMCnd
	 8mDNNB+8dgoNotoSTOJyD4L2kHywHz3TX/ESuNCAzLJQC/mSYsYH/y1azCCG762Z7Zf+U
	 LnmjAbKD3odNOv6rtW2AarAz8Du6L626n+qN5B5zRIKNJlHMtSSJvMYjwGEI3aKGucg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b="mW9Vdaz/";
	arc=none smtp.remote-ip=111.22.67.139
X-Received: from cmccmta6.chinamobile.com (cmccmta6.chinamobile.com [111.22.67.139])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 47E8F606A334;
	Tue, 10 Nov 2026 07:53:27 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 47E8F606A334
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=cmss.chinamobile.com; s=default; l=0;
	h=from:subject:message-id:to:cc:mime-version;
	bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=;
	b=mW9Vdaz/XA64uN17RQ32bPeGIIjIymPZen9zbHpQhcnKphIVWNrXqQI87jol9aa9OHd/sDHIwLkU+
	 Q6Xsq3th3d78FGntJMNlfvXbJmenqhc1cpN2lLHKNEEz2WYpfu/KLrvZjzdV/ItPQe5NidzXQuJDvf
	 SsmfGU/4TrgYLW9c=
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from spf.mail.chinamobile.com (unknown[10.188.0.87])
	by rmmx-syy-dmz-app05-12005 (RichMail) with SMTP id 2ee56af2cd76a68-c9fd9;
	Tue, 10 Nov 2026 15:53:26 +0800 (CST)
X-RM-TRANSID: 2ee56af2cd76a68-c9fd9
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from openEuler-24.03.03 (unknown[74.82.203.40])
	by rmsmtp-syy-appsvr07-12007 (RichMail) with SMTP id 2ee76af2cd6bd67-acb02;
	Tue, 10 Nov 2026 15:53:26 +0800 (CST)
X-RM-TRANSID: 2ee76af2cd6bd67-acb02
X-Cc: yanhaishuang@cmss.chinamobile.com,
	davem@davemloft.net,
	edumazet@kernel.org,
	kuba@kernel.org,
	pabeni@redhat.com,
	horms@kernel.org,
	almasrymina@google.com,
	daniel@iogearbox.net,
	willemb@google.com,
	willemdebruijn.kernel@gmail.com,
	mst@redhat.com,
	jasowangio@gmail.com,
	eperezma@redhat.com,
	narcisav.kernel@gmail.com,
	linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.43.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