🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #16616

[PATCH v2] net: hso: fix tx skb leak and a race on the stashed skb

#16616
From: Aibing Chen
Date: Sun, 15 Nov 2026 10:16
92 lines
11865 bytes
hso_net_start_xmit() stashes the skb in odev->skb_tx_buf and stops the
queue when hso_get_activity() reports -EAGAIN, which happens when the
USB device is suspended or no longer configured.  If the interface is
then brought down, or the device is disconnected, that skb is simply
left behind: hso_net_close() and hso_free_net_device() never release
it, and hso_net_open() clears the pointer, so the skb and its data
buffer are leaked.

hso_resume() loses a frame in the same way when the device is still not
ready: it passes skb_tx_buf to hso_net_start_xmit() and then clears the
pointer unconditionally, so a frame stashed again by that call is never
freed.

Free the pending skb in hso_net_close() and take ownership of the
pointer with xchg() in both places, so that only one of the close and
resume paths can obtain it.  hso_resume() also drops the frame instead
of transmitting it when the interface has already been stopped.

Reported-by: syzbot+bf62ca9997f43d2fa521@syzkaller.appspotmail.com
Link: https://lore.kernel.org/all/6af74e31.fe96acdb.12252b.0009.GAE@google.com/
Fixes: 72dc1c096c70 ("HSO: add option hso driver")
Fixes: c213f286f2cf ("[netdrvr] hso: dev_kfree_skb crash fix")
Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
---
v2:
- take the stashed skb with xchg() in hso_net_close() and hso_resume(),
  so that only one path can free it (race reported by sashiko).
- drop the frame in hso_resume() instead of transmitting it after the
  interface was stopped.
- add the two Fixes tags.

 drivers/net/usb/hso.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 71caa3764..ba59bdefd 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -720,6 +720,7 @@ static int hso_net_open(struct net_device *net)
 static int hso_net_close(struct net_device *net)
 {
 	struct hso_net *odev = netdev_priv(net);
+	struct sk_buff *skb;
 
 	/* we don't need the queue anymore */
 	netif_stop_queue(net);
@@ -728,6 +729,14 @@ static int hso_net_close(struct net_device *net)
 
 	hso_stop_net_device(odev->parent);
 
+	/*
+	 * Take ownership of a frame stashed by hso_net_start_xmit() and drop it.
+	 * hso_resume() takes it the same way, so only one of the two paths frees
+	 * it.
+	 */
+	skb = xchg(&odev->skb_tx_buf, NULL);
+	dev_kfree_skb(skb);
+
 	/* done */
 	return 0;
 }
@@ -3032,6 +3041,7 @@ static int hso_resume(struct usb_interface *iface)
 {
 	int i, result = 0;
 	struct hso_net *hso_net;
+	struct sk_buff *skb;
 
 	/* Start all serial ports */
 	for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
@@ -3054,13 +3064,17 @@ static int hso_resume(struct usb_interface *iface)
 			if (hso_net->flags & IFF_UP) {
 				/* First transmit any lingering data,
 				   then restart the device. */
-				if (hso_net->skb_tx_buf) {
+				skb = xchg(&hso_net->skb_tx_buf, NULL);
+				if (skb) {
 					dev_dbg(&iface->dev,
 						"Transmitting"
 						" lingering data\n");
-					hso_net_start_xmit(hso_net->skb_tx_buf,
-							   hso_net->net);
-					hso_net->skb_tx_buf = NULL;
+					if (test_bit(HSO_NET_RUNNING,
+						     &hso_net->flags))
+						hso_net_start_xmit(skb,
+								   hso_net->net);
+					else
+						dev_kfree_skb(skb);
 				}
 				result = hso_start_net_device(network_table[i]);
 				if (result)
Technical Details
Message-ID: <20261115101646.244-1-chenaibing@cmss.chinamobile.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363657-linux-kernel-netdev=dewy.ru
References: <20261114093133.465-1-chenaibing@cmss.chinamobile.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363657-linux-kernel-netdev=dewy.ru
From: chenaibing@cmss.chinamobile.com (Aibing Chen)
Newsgroups: linux.kernel.netdev
Subject: [PATCH v2] net: hso: fix tx skb leak and a race on the stashed skb
Date: Sun, 15 Nov 2026 18:16:46 +0800
Organization: Usenet Network
Message-ID: <20261115101646.244-1-chenaibing@cmss.chinamobile.com>
References: <20261114093133.465-1-chenaibing@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1771519"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:IZFkT0B7acEdTU/vrBIOAyokmCA= sha256:dfS4m3FuriglqTqkn5nZQqr1ISuN0HkxjZARgtwFBg4=
	sha1:oeC471hDdKyLSSJhhbKWdRgqVQI= sha256:QF+VIaybbrm0fEO1zvXGoJDtpi9JOOCDydlXBb/CmiI=
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 2CFAB1149A0; Sun, 15 Nov 2026 13:17:21 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.751
X-Spam-Status: No, score=-2.751 tagged_above=-9999 required=6.31
	tests=[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]
	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 3LAPWuqyHpl1;
	Sun, 15 Nov 2026 13:17:16 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-363657-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 56BA411499D; Sun, 15 Nov 2026 13:17:06 +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 BE6F13D196; Sun, 15 Nov 2026 10:16: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=1794737818;
	b=MAepQQv1VD+CxtVTXAPadwKHpW01l5+vL17WQhLFmXY4QPfLNQSJ8OeVQoR3EjttfBvu
	 6aWjEbanoqZ4LX6PBt3Rq3cXOWT58Rutyjykh5CcIy7bZ0CHh8up5aUKqCbm23mNccpeB
	 nU0BnV66nFTd64jSXlOevULfoSzwkeQdaSDIAFzLR0jMnxsIMIa7OLBgo+wHfBnj7ITaE
	 9W2C3tTX/84DIfGwHap5bIN4cOnh+8/dmKWSKt2IYs1fC8EQe6yki7v+KMW6IWYnQxMnr
	 bpYnGA/G9Rq+DAupZEamQ7Pvf3DnPPFN/GDCcYRUi/8gkzRcXyYu9EZrDvzibFPMAPg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794737818;
	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:
	 In-Reply-To:References:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=cbIBX/u18CTG47SpI1ezRb64cX82qK6+CTmQksOFjn0=;
	b=EvadPifFVg5yRZkGb5e9bwSwu8b6eDVsbd3/RdGPWfb0OfgtQ4Q+vMaUB0l8z2tsJYPZ
	 Dj8zFIpR54YR/tidIuffyRsZfjT1LdNZzVZQGXco872/6Le2N0dbHTiZEZLF7Nubg4xsC
	 LgmrqBcsyYzZB8MU2dLrQT0r0rzc+qO5I43g6ksuur2pZNDTIcCjtslNnPfBjHEfihjo4
	 PnfKd5gIwrXVxp6Qdm+q7xo3xGhpqG9J5YG9FSfsqr4VI+SgJDKhqw6lPcOC25BqgZP2g
	 EAkGpTnFbsrVBeUb51G/d9BtARHOPQimyqf9A81tNOOW0eLeyAVS0HMqU+/fht/TWSQ==
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=dhZrIw99;
	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 48107606A334;
	Sun, 15 Nov 2026 10:16:58 +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=dhZrIw99
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=1794737817;
	b=5MyasK6XdjaaOdUuAVWN1i4M5Ez25csz44fP5eKMkmP9jgaJxdlE8jNyaKHvHeHXUXNn
	 OexhIwP8yXTAyBTUmq9y9Nt2w1pvIUuZa+4LhKz5F++IuKkgpyCHy2Bmuyr/w8+3hJF/o
	 EKZJwFGbLsDp2v8AGjFiJuCnMDcGHV68Hq6dvr1dvxjzhz8M556dVhTQ2zbXcu/v/Y4XJ
	 jylzAmypss8+Wz9aHS5dX5zwQLivhMxb1isHpfBGiSMyrBa+0mFBA2LyVFoW4wtInLk2V
	 13Fou74eGeXxl/5bEvlIqZ5DFV1x/eKryFkTS+PJ/hLSTKmmdILTBbqmrrGewb+9Osw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794737817;
	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:In-Reply-To:References:
	 MIME-Version:Content-Transfer-Encoding;
	bh=cbIBX/u18CTG47SpI1ezRb64cX82qK6+CTmQksOFjn0=;
	b=wGHhCy0higJpvR5sP9WXyUDUqHWG2waJNrHr5bgYRiYqh70mA9x4XbcHtxV5k4maCDHg
	 evRq7ttYtS/VVftQbVumuhTybGwb/XpHw2v0nJWvWpJQrrTzcUdgUoWbRQ1KqGghHiImQ
	 ptAZ+Ny9D9fK/RIwOCQbWxVUklL+fFS2X88nMKwq1mTo9RrQmP7y+4LVO+dpQ3aqy8yDn
	 t70thLYphy2cIONAwpQKFHU/Tu/kzEHmETkBJ7UcaSWgM3ejzYl4mFYnlAiNolQkeW0jH
	 2svQsYpnjZCEGm5pSuqS9/hhABkVHkggknJ9GHFdzatfbz/va3PeSGCz5ywjCNosGew==
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=dhZrIw99;
	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 DEFC2606A31F;
	Sun, 15 Nov 2026 10:16:52 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DEFC2606A31F
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=dhZrIw99afblWNJB8lLoZ9wljNP+6opFQYD86wK1PsgBSFDZ9Hnp2sSE5lqgnJfqono6NAFHrQOgy
	 dv/TaL7bC0g3bTdx6WLvk1Jmh39fDTs/O/7NCKfH8qMx3KAhrIEvkSy3l4oymJbQMM+B7wGNe59tty
	 /7rK3imCArqCTId4=
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-app09-12009 (RichMail) with SMTP id 2ee96af9868aed2-fb459;
	Sun, 15 Nov 2026 18:16:49 +0800 (CST)
X-RM-TRANSID: 2ee96af9868aed2-fb459
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from FHD-W7400297 (unknown[10.55.1.70])
	by rmsmtp-syy-appsvr03-12003 (RichMail) with SMTP id 2ee36af9868f834-6066e;
	Sun, 15 Nov 2026 18:16:49 +0800 (CST)
X-RM-TRANSID: 2ee36af9868f834-6066e
X-Cc: linux-usb@vger.kernel.org,
	netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.50.1.windows.1
X-In-Reply-To: <20261114093133.465-1-chenaibing@cmss.chinamobile.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