🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #115

[PATCH net v3] net: fix NULL dereference in skb realloc fault injection devname filter

#115
From: Haishuang Yan
Date: Wed, 07 Oct 2026 00:41
63 lines
8641 bytes
When a device name filter is set in
/sys/kernel/debug/fail_skb_realloc/devname, should_fail_net_realloc_skb()
compares it with skb->dev->name without checking skb->dev first.

skb_might_realloc() is called from pskb_may_pull(), pskb_trim() and
pskb_trim_rcsum(), which also run on skbs that are not associated with
a device. One example is a netlink broadcast to a listener with a socket
filter attached, which goes through sk_filter_trim_cap(). With the
filter set, such an skb makes the kernel oops:

  KASAN: null-ptr-deref in range [0x0000000000000118-0x000000000000011f]
  pc : strncmp+0x50/0xf0
  lr : skb_might_realloc+0x58/0xa0
  Call trace:
   strncmp+0x50/0xf0 (P)
   skb_might_realloc+0x58/0xa0
   sk_filter_trim_cap+0x6a0/0x928
   do_one_broadcast+0x35c/0xb20
   netlink_broadcast_filtered+0x1a4/0x328
   netlink_sendmsg+0x724/0xa58

The fault is meant to be injected on network interfaces, so skip skbs
that are not associated with a device. Without a device name filter,
such skbs are no longer reallocated either.

Fixes: 12079a59ce52 ("net: Implement fault injection forcing skb reallocation")
Suggested-by: Breno Leitao <leitao@debian.org>
Assisted-by: LLM
Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
v3:
- Fix the list of functions that call skb_might_realloc() in the commit
  message (Sashiko). No code change.
- Post as a new thread, v2 was sent as a reply to v1 by mistake.
v2: https://lore.kernel.org/netdev/20261001182813.353004-1-yanhaishuang@cmss.chinamobile.com/
- Return early for skbs without a device, as suggested by Breno. Such
  skbs are now skipped whether or not a device name filter is set.
- Tested on arm64 (QEMU) with KASAN: the netlink broadcast reproducer no
  longer oopses with devname set, the devname filter still injects on
  the selected device, and without a filter skbs without a device are
  skipped while skbs on a device are still reallocated.
v1: https://lore.kernel.org/netdev/20260930122013.110284-1-yanhaishuang@cmss.chinamobile.com/

 net/core/skb_fault_injection.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/core/skb_fault_injection.c b/net/core/skb_fault_injection.c
index 4235db6bdfad..63a397f76113 100644
--- a/net/core/skb_fault_injection.c
+++ b/net/core/skb_fault_injection.c
@@ -18,6 +18,9 @@ static bool should_fail_net_realloc_skb(struct sk_buff *skb)
 {
 	struct net_device *net = skb->dev;
 
+	if (!net)
+		return false;
+
 	if (skb_realloc.filtered &&
 	    strncmp(net->name, skb_realloc.devname, IFNAMSIZ))
 		/* device name filter set, but names do not match */
-- 
2.43.0
Technical Details
Message-ID: <20261007004158.1266795-1-yanhaishuang@cmss.chinamobile.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-342259-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-342259-linux-kernel-netdev=dewy.ru
From: yanhaishuang@cmss.chinamobile.com (Haishuang Yan)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v3] net: fix NULL dereference in skb realloc fault injection devname filter
Date: Wed,  7 Oct 2026 08:41:58 +0800
Organization: Usenet Network
Message-ID: <20261007004158.1266795-1-yanhaishuang@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="611412"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:WZzfPJlmyGB8BhXRA7mighdMqYs= sha256:FLfTLlMecnHO9LoBSuiS9caWU/0DwWp2ki5IkK8uvFA=
	sha1:HRSNT07Wanc4O/dzN5ovmZDJnKU= sha256:otr/aySI4/8YOzklZqUGD/LVQiwYjj/BgKs/3YtVwGY=
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 ACBBD10F116; Wed,  7 Oct 2026 11:53:08 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: 0.653
X-Spam-Status: No, score=0.653 tagged_above=-9999 required=6.31
	tests=[DATE_IN_PAST_06_12=1.103, DCC_REPUT_70_89=0.1,
	DKIM_INVALID=0.1, DKIM_SIGNED=0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001]
	autolearn=no 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 QOaTZUudqXeQ;
	Wed,  7 Oct 2026 11:53:05 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-342259-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 04CED10F108; Wed,  7 Oct 2026 11:52:59 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id EB2D42E1ED; Wed,  7 Oct 2026 08:51:06 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id B838145A295;
	Wed,  7 Oct 2026 08:51:05 +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.b="c7BeIgB4"
X-Received: from cmccmta4.chinamobile.com (cmccmta4.chinamobile.com [111.22.67.137])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id CA3D73CAE7F;
	Wed,  7 Oct 2026 08:51:00 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=111.22.67.137
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791363065; cv=none; b=Sw9WO5d+JPnWvruK42nXKfO6JiV5Kf7HkE2AagGaRmghF5F35RGS9B0bfI7PSQRnOR5y2KkRUE/xOVUdHg0Wuq0iTmN86QR17vKuggyb/9dAbsX9uYCotc452uRW/5MmoVVyFpbdTnH3t8fcOctRjdn2OuHYQk5bXOlOZlTMcQ4=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791363065; c=relaxed/simple;
	bh=Sdm7fx+CqbHL0mnic7CuiQulX6tV0v32Bd0YOeucSqI=;
	h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=gpiJSMaa7ysPPM3iObhAGw32b8DOxoz6qByWT6vQFYCYBM5kAENC2gdir6QUVTrf1WHWIOu9z5OzZGJSMv3g7HzPeq1aRGyKTJe5TFEv7RYJ0q4VOke66VMWXmRgAAgPy3OHsrqx9SctSVMdcSYSt1gA+TefQUD4fcDMSBzLuU8=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com; spf=pass smtp.mailfrom=cmss.chinamobile.com; dkim=pass (1024-bit key) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.b=c7BeIgB4; arc=none smtp.client-ip=111.22.67.137
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=c7BeIgB4RRp46rdiqS38xX0sl2s0tKmq8DMleOZFR8N6tmAoxCqbe/qwBj1kTSLtOFH1DNOWy8NG+
	 3Rcp3QJQ2e0d3Ntj27SG6GR/UqDylbAsjEHLRfQRr5ZuwtYhCwA+uoV2iKKTjUtRYcLnhQHWEmN57D
	 I0pu8FRw0vGLhTKk=
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-app04-12004 (RichMail) with SMTP id 2ee46ac607ebb87-4ad88;
	Wed, 07 Oct 2026 16:50:52 +0800 (CST)
X-RM-TRANSID: 2ee46ac607ebb87-4ad88
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from openEuler-24.03 (unknown[112.22.250.209])
	by rmsmtp-syy-appsvr03-12003 (RichMail) with SMTP id 2ee36ac607df4de-dd28c;
	Wed, 07 Oct 2026 16:50:52 +0800 (CST)
X-RM-TRANSID: 2ee36ac607df4de-dd28c
X-Cc: Breno Leitao <leitao@debian.org>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Guillaume Nault <gnault@redhat.com>,
	Akinobu Mita <akinobu.mita@gmail.com>,
	linux-kernel@vger.kernel.org,
	Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
X-Mailer: git-send-email 2.43.0
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>