Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795056885; b=DkeBZWKyExjkHZodEoy31FXAfVAqFQl/Q4tkJnaWs+RFSgL896QL8RxU90flDP7L9zcW 52JVfI0/WGiwAFhVK4YgaeU+DHg6RHFacPE/qIVbrNOfpQlaBy3OLxOwMMBhHaf9ZsimV 5aIjBsUkkKxkk0AXtGfP/1FCS61JZnD+9mVgZdHCxTUQcp1tdv5W1lW3pPo4TmuOCfj5V vJU0UzH5PBDFi2+rEwLrIinVKSIO3kDDie9MwsNC2FKHx65F7ONgmxQ0dPc0EJB5JWsfe wtsNTM0xZ2/Vn7JUftWfB41YuPKA6l3O+UfFve/kVEKk+fB8/32WzvG4UijjzAcoYGQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795056885; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=gQztrw+NQaKPqJOM0Mt/DQVxLYy8+DfL58iOeDji00E=; b=X8u7KFDI5zdZhlTJfboWB+NjGrtEv2E/QnbYb+AYRs3Ib+0HewmPl4VvQkE+Exa3pch9 zy706/BW3314aApbmVtzGlefadmEl/oBbCpI4eEpchXgTLUE/IXO6tuSHkvBUpm++OSk/ 4IsJ8MDZApGzxOmdiwMdbr0KTxScPkzr5mCp/B51pNliWkQerY1dC6tsFhrMxdMm/YaQb E9iwHYCK2E2Nrr8HTYF6LIlZtC6ApDsiDSq4vk6tFeG3LF/E5xz2FCMv6nIE52UYMrzr6 OId7SSceJtObjYA5v4fuEmOL3lS8F97nl/FUeNRQRniBOEM8QOldZIOUeUVoxuNzGaQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=HTrjyGTf; arc=none smtp.remote-ip=100.103.45.18 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 DDAE9606A31C; Thu, 19 Nov 2026 02:54:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=HTrjyGTf Received: by smtp.kernel.org (Postfix) with ESMTPSA id E30121F000C4; Thu, 19 Nov 2026 02:54:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795056885; bh=gQztrw+NQaKPqJOM0Mt/DQVxLYy8+DfL58iOeDji00E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HTrjyGTfT+jk8yomTlGs7PS90eRAez+0iPp1xBhabvkZhFi1qmahuJ9WiR45HaOeM TQkcHzd8i76xLy0PBmnJjB81+IlXMwHzJK3jIO3+ygZxy6PWR2mhD/hBQYL3ftZEKH ePoGFIDcteMtsw8qeh27b2qsebUOlUf04d61QgEQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?=C3=96mer=20Mete=20Kaya?= , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 2147/2214] usbnet: fix EVENT_RX_PAUSED race in usbnet_skb_return() Date: Wed, 18 Nov 2026 16:03:43 +0100 Message-ID: <20261118150136.362774850@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150009.797899913@linuxfoundation.org> References: <20261118150009.797899913@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ömer Mete Kaya [ Upstream commit 67ae1b80cf73f592b35e4b5e5001a24d6d6c8637 ] On SMP, usbnet_skb_return() can observe EVENT_RX_PAUSED as set on CPU0 while usbnet_resume_rx() clears the flag and drains rxq_pause on CPU1. The skb can then be queued after the drain has completed and remain stranded until the next MTU change or device stop. Synchronize the EVENT_RX_PAUSED state transition and paused-queue dequeue operations with rxq_pause.lock. In usbnet_resume_rx() splice the paused queue into a local queue under the lock, then drain the local queue lock-free. In usbnet_skb_return() use a double-check pattern under rxq_pause.lock on the slow path, keeping the normal RX fast path lock-free. Use spin_lock_irqsave() to match the lockdep class shared with other sk_buff_head locks taken from hardirq context in defer_bh(). Discovered by Sashiko, not triggered, not tested on real hardware. Fixes: 43daa96b166c ("usbnet: Stop RX Q on MTU change") Signed-off-by: Ömer Mete Kaya Link: https://patch.msgid.link/20261024084538.256596-1-omermetekaya0@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/usb/usbnet.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index a3e07449e5e7a..884ce3a92fd44 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -335,9 +335,14 @@ void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb) unsigned long flags; int status; - if (test_bit(EVENT_RX_PAUSED, &dev->flags)) { - skb_queue_tail(&dev->rxq_pause, skb); - return; + if (unlikely(test_bit(EVENT_RX_PAUSED, &dev->flags))) { + spin_lock_irqsave(&dev->rxq_pause.lock, flags); + if (test_bit(EVENT_RX_PAUSED, &dev->flags)) { + __skb_queue_tail(&dev->rxq_pause, skb); + spin_unlock_irqrestore(&dev->rxq_pause.lock, flags); + return; + } + spin_unlock_irqrestore(&dev->rxq_pause.lock, flags); } /* only update if unset to allow minidriver rx_fixup override */ @@ -706,13 +711,20 @@ EXPORT_SYMBOL_GPL(usbnet_pause_rx); void usbnet_resume_rx(struct usbnet *dev) { + struct sk_buff_head q; struct sk_buff *skb; + unsigned long flags; int num = 0; + __skb_queue_head_init(&q); + local_bh_disable(); + spin_lock_irqsave(&dev->rxq_pause.lock, flags); clear_bit(EVENT_RX_PAUSED, &dev->flags); + skb_queue_splice_init(&dev->rxq_pause, &q); + spin_unlock_irqrestore(&dev->rxq_pause.lock, flags); - while ((skb = skb_dequeue(&dev->rxq_pause)) != NULL) { + while ((skb = __skb_dequeue(&q))) { usbnet_skb_return(dev, skb); num++; } -- 2.53.0