Article View: linux.kernel.netdev
Article #25624[PATCH net] usbnet: don't lose rx mode updates that arrive during set_rx_mode()
From: Mahdi Yari
Date: Wed, 02 Dec 2026 06:05
Date: Wed, 02 Dec 2026 06:05
76 lines
13922 bytes
13922 bytes
usbnet_deferred_kevent() tests EVENT_SET_RX_MODE, calls the
minidriver's set_rx_mode() and only then clears the bit. set_rx_mode()
may sleep in a control transfer. If the rx mode changes meanwhile,
usbnet_set_rx_mode() sets the bit and requeues the kevent, but the
trailing clear_bit() wipes that request, so the rerun finds the bit
clear and the new filter is never sent.
This was observed on a machine in real use: an OpenWrt router whose LAN
port, an ASIX AX88179A (0b95:1790) on cdc_ncm, is bridged with a WiFi
AP. After boot or a USB replug, WiFi clients could not reach hosts
behind the USB port. The bridge enables allmulti and promisc while the
first SET_ETHERNET_PACKET_FILTER is in flight, and usbmon shows that
request as the only one, without promisc:
S Co:1:009:0 s 21 43 000e 0000 0000 0
so the adapter keeps dropping unicast for other MACs. Setting promisc
by hand afterwards (ip link set eth1 promisc on) sends 000f and fixes
it. The cause was found by reading usbmon traces and the code, with
the help of an AI coding assistant (Claude), which also helped write
and test this patch.
Reproducing it needs no kernel changes: add the cdc_ncm port to a
bridge, replug the adapter (or reload the usbnet modules) and watch
usbmon for "s 21 43" requests. The race does not hit every time.
Clear the bit with test_and_clear_bit() before calling set_rx_mode(),
so a request made while it runs is handled by the requeued kevent.
test_and_clear_bit() is fully ordered, so set_rx_mode() reads the
netdev flags only after the bit is cleared. No retry is lost: the bit
was already cleared whether or not set_rx_mode() succeeded.
Tested with that reproducer on the same hardware (Intel Atom x5-Z8350,
AX88179A on cdc_ncm) running OpenWrt 25.12.5, kernel 6.12.94, with
this change backported. In runs where the race hit, the unpatched
kernel never sent promisc (4 of 4 module reloads) and bridged traffic
failed. With the fix the requeued kevent sent it (3 of 3 reloads, 2 of
2 replugs) and bridged traffic worked. Not run-tested on net and not
tested with kernel selftests. On net, usbnet.o builds with W=1 for
allmodconfig and allyesconfig without new warnings.
Fixes: 1efed2d06c70 ("usbnet: add a callback for set_rx_mode")
Cc: stable@vger.kernel.org
Signed-off-by: Mahdi Yari <m.yary16@gmail.com>
---
Note: in net-next, commit 7d573278f9a5 ("ax88179_178a: Add HW support
for AX179A-based chips") moves the AX88179A off cdc_ncm. The race
still affects every usbnet minidriver using set_rx_mode: cdc_ether,
cdc_ncm and int51x1.
drivers/net/usb/usbnet.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 97a30dd..74c100c 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1184,8 +1184,6 @@ static void __handle_set_rx_mode(struct usbnet *dev)
{
if (dev->driver_info->set_rx_mode)
(dev->driver_info->set_rx_mode)(dev);
-
- clear_bit(EVENT_SET_RX_MODE, &dev->flags);
}
/* work that cannot be done in interrupt context uses keventd.
@@ -1295,7 +1293,7 @@ skip_reset:
if (test_bit(EVENT_LINK_CHANGE, &dev->flags))
__handle_link_change(dev);
- if (test_bit(EVENT_SET_RX_MODE, &dev->flags))
+ if (test_and_clear_bit(EVENT_SET_RX_MODE, &dev->flags))
__handle_set_rx_mode(dev);
Technical Details
Message-ID:
<20261202060513.660741-1-m.yary16@gmail.com>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375576-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375576-linux-kernel-netdev=dewy.ru
From: m.yary16@gmail.com (Mahdi Yari)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] usbnet: don't lose rx mode updates that arrive during set_rx_mode()
Date: Wed, 2 Dec 2026 09:35:13 +0330
Organization: Usenet Network
Message-ID: <20261202060513.660741-1-m.yary16@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="1902980"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:IqM+9tSMRiiXodwIZ55XCierHUw= sha256:Ufwzw/utLNhJbj4/ganPgUe1urZBeLUIKE+z4calCr0=
sha1:dS0wCkNdP1CrBEFOKH4QiQyMobM= sha256:6ACio3915TV3g3y71RDQBrVfZ3dMh1M5yxoNNItP9XI=
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 82DD9117567; Wed, 2 Dec 2026 09:08:22 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.049
X-Spam-Status: No, score=-2.049 tagged_above=-9999 required=6.31
tests=[DCC_CHECK=1.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, 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=pass (2048-bit key)
header.d=gmail.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 jC17S-mU7_qw;
Wed, 2 Dec 2026 09:08:15 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-375576-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 7E284117551; Wed, 2 Dec 2026 09:08:04 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id 6FF5727D63; Wed, 2 Dec 2026 06:08:02 +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=1796191681;
b=wzQbaoNDVvx7Kf+asTSolKqAk+cVLLzW6/GBRMBHO7qSQaIFdoJbAN22+EiSmFbGFiOU
3MpU5TbB32IpTW79IMe1rC6S3dn0CX+j6XBuyWbfvikKmxq7Mkd9Xwlq0811hcCIaBYsh
datOqejxbJOo2x6aDvkA0Z77r+o7DmrJfVmYjtL/BZrQTw/wqdR6DkJ4m2cq5zGMZ9qsJ
5o/r61n9kIN4uEjPOhnWcGcSAWWqLmupec9LQc6xPempTb0+jxNsvUrZD0/l58C3iaV00
eB05P+FDQyB1ijDdUHE8rDFAcMEDJONG8fs67AgOXR38FEwBLv/CEUg/zUs4Wy0OBHA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796191681;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-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=Y0cZaVhzHE157HwI02HB5SAotteDxM6C2ULM3SD6T7E=;
b=b2erB/5jnlv0DxXQNq9kctQU8qYR0K4vYk+9+cB6Enx0sOhdTUgvmwG4I7Di285I5tBF
BYDo6AHeXqbMuYryQKLU1hZF5degAPqSbM32odFLwGH/r5zjttKY9PVcKMwdgOsjTf1i5
epqWjtD/jN9RYz/RPWnfyeqyOi1Nr2vUXvFY3quB4wlXR/eE8dsk7Y+dl60T2UKRcUFcT
dL346rRwOX4eyX9BNImGHr+fLO2fJkT1e5/zKUTIAx6WOp8ZkHNStTU7M0uUf3ifP4W1t
roUJbw5un3FnTJLoj3A2X+S0dqS/QC/KOltgoNQFtyNnL5SyTMYUkIOP1zf5wrnlWfw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=qJNi5Eot;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.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 78A4D606A31A;
Wed, 2 Dec 2026 06:08:01 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=qJNi5Eot
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.51
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796191680;
b=zgr/IJtVAZYdKdA/vBiKMSeL6+rDqvQ7HNFMaM/96tebcFiMwmGQ7x7hBdU1wqU4oCHR
N9LJqVbqcnE4zcmQxBxQ6d9m3Hu75h/HGbFlFrRH64AEXkwtetc+v4y/PC+gK5OYn8/R8
UvUHmyQbhfbvlMI1CWZ1liZ+IK1AnGuLqu0IfyVBmgqmoVNnp8xaHEOtIVFTjrTCkdN/G
FI6HL4lr6YuHSlAvojxR30dwjrmCdNNZSxsCRMo84d07dCGYDEMyxDFmuS0+Q7FkkADqO
3PQvMsoaxSYEwqvIyX+lxf73bcdaxKDCjlZrD569nP7bM9Pcnc5LlX/gWb5/LGZvBEQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796191680;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
Content-Transfer-Encoding;
bh=Y0cZaVhzHE157HwI02HB5SAotteDxM6C2ULM3SD6T7E=;
b=aSvOinruU7C2zcV5+IFIi/62Gjz3j0NBQgfoKCbDNqeCEJXarAle4CA033h9ahe9VXt/
VR759NH3KG3k37z4JhJ26K4rnt089EFmtNVVmVtRn2MZkiKrcNW6s2YkXpyuwI/RBcF+5
bpcsyW1VSPKxPWoWwPY+huPNIFtB5APaIZ3s5om6Zh/afEFKHObtMlONJe8rfCrB9KaE9
om8qdCCeXohOmPqhzJAoPOm4DGnhQZIOBzA+5+J8kZY0cauRrezKqEN4lJbSlClKYJvFr
DcM5WJo+8KqX7DNxBoiyUh79i/cHIMFJfahrC4r9VEcQStpu3SbP9sSg4ySDr6b8urA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=qJNi5Eot;
arc=none smtp.remote-ip=209.85.128.51
X-Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id F11AC606A329
for <netdev@vger.kernel.org>; Wed, 2 Dec 2026 06:07:59 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F11AC606A329
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4ba013938d7so117480395e9.2
for <netdev@vger.kernel.org>; Tue, 01 Dec 2026 22:07:59 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796191678; x=1796796478; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=Y0cZaVhzHE157HwI02HB5SAotteDxM6C2ULM3SD6T7E=;
b=qJNi5EotbYLqiTscihChQwXSNTzfYSKt5pH2oq2DFdbcWPr9P46lfUG6M182ix2xBM
vqAoC8Z/a49lEuhGo9TfZnYKgpqQLSaWPaZGybHUks8oVsroK1x5JjvlChDdYCnYCdi3
oikn4PCm/KYR1Ry8NB8m6bWqfyvAvRtc/fBZ4A+fQea6tGjwsZw2a7nJQERVkuoahf7M
DuK+67a5Zs6/Fn8DomNtsoNem5gFaF3iPbRXEGTtTiyU5fVH2w7bnJNWAZP+iNNww64p
3Hub/YdLk+8uPM4eHqmAwKkv7oglF6+t1YWJWJ6U3qwvK+ve1RTZZuAi5lXASDKLb9lY
miQA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796191678; x=1796796478;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=Y0cZaVhzHE157HwI02HB5SAotteDxM6C2ULM3SD6T7E=;
b=lyZcLYFjeWySaIqIz86+L4uocUmTcwEjU9wv2tLgIaLeY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EU9pVSovroDoV6xI
BD/o3q9pXwv1NSIU1eyg12IdCnR0tiCbzCGGFcwmrkeegKIfVn3SMU+y8+3oAM5YjBBjV9xTSHq
mGUgCwgZVeBrZQrmEctWzptVi7A=
X-Received: by 2002:a05:600c:6290:b0:4bb:741d:eba with SMTP id 5b1f17b1804b1-4bb88824a5bmr752355365e9.13.1796191678147;
Tue, 01 Dec 2026 22:07:58 -0800 (PST)
X-Received: from federation.lan ([194.105.5.28])
by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb906817ccsm688956195e9.5.2026.12.01.22.07.55
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Tue, 01 Dec 2026 22:07:57 -0800 (PST)
X-Cc: oneukum@suse.com,
netdev@vger.kernel.org,
linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org,
Mahdi Yari <m.yary16@gmail.com>,
stable@vger.kernel.org
X-Mailer: git-send-email 2.56.1
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