From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796202875; b=r4u6spstcH4lnuBuwTF6/hNayfOQWwPjLWf0WNxPI+4ulTSY21Rvm+07nocPHBh8cbzY x1sTtrWzSxMKYDcREjLmQC8q2nHWh9lT7qeH6Vy+fjiWQw8aKJZsTrgiEa82d4n57qCn3 2q8smDOAos36LJqZnM0T7W8/R0Op7YO1h46Tc9h1zLAiS5X3OOSuaeedFUV4/JXptf/b0 rPNlDN0Xx1qiDeQ2IAu55+uR+/XILhW4y2ticnJVBecOycTjxjjC01QK6dc/2UykDB8lP /8L5NSx92AixcGsh64JyMmYRBl9WPFLXrWQRiuzZxN3gqyCutmCM4VTrPJJ9jctOLww== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796202875; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=MegnQdgRjedNFEPD81wR6urSqCZtoQO2n3JVxpr0Qq4=; b=jnbsf/3kkT4sPnP1P+16SbkMr30W5RUstogYBtcLxCRJaKfs/uYkDJriZRqJBURx4uRJ NjibV3YDYdP184i0mvGEEdVT3zorpqO9dTHqb0rZw7sEFBCMpcKPLz0uY8jMD+4yUBaZ4 A5n9O5lwLBtwAheSUpxCSCR53n5YLAE8RR4hMs51u9Zzh7AnFHmLNUakWkilfLqdqrPVS 04b15R2WaAdUK1V176pWXSEtuNiXknc4pyu6NiVAlK6ZeijZLnQSPapsGg+BVIHOp8Q9+ VAKpYCD0jJWNLjKCWY1vA57ISlnAmkStG8Otewc+yW7PVsmVbBWCsYcgxKKiUBa/CuQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=google header.b=IAT+zUKB; arc=none smtp.remote-ip=209.85.128.51 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 D6D13606A325 for ; Wed, 2 Dec 2026 09:14:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D6D13606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=google header.b=IAT+zUKB Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4bb61185057so80584485e9.1 for ; Wed, 02 Dec 2026 01:14:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1796202873; x=1796807673; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=MegnQdgRjedNFEPD81wR6urSqCZtoQO2n3JVxpr0Qq4=; b=IAT+zUKBgxahSVpFSVzzJzfjOnw5+sNDzlij41mDQn43mYSs1Qoyu2AQv1Xo2Qtow5 5EUGCnmSpis9X77hseTNJYATIcMIGFF27WLJHzfLPYRmhTFYkOjKBFzmXlp1yz088cLU rApRC6xNNf2drmB5gOKAzelnjkLfHPuNlK5pD8KPUr4H5ThTr8cq4AU4BKhSwJppGVRW U68rwUcYRPA3cJqxgAqDiy4uIoY65SzGiMsdkE0jvXAm1rFIxbFTErLu3WDuz/FKJ2R7 x9PEoYPIBcLUoe7KDE431bPQm98HF3NZCBqqXphl1jZ7z43isxasKUDHuJ1ZzbLglpeN uZZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796202873; x=1796807673; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=MegnQdgRjedNFEPD81wR6urSqCZtoQO2n3JVxpr0Qq4=; b=ck3fusLx32NH7Knz00dKxxW7LSG4fwhiJd4x4GiFBCZO6t4bcYvmQd9cL/aV+kKDkh Psp+M1AZPKyyNQtNm/9K+pnn7xgy++EYX2wqkBo30+RcTIR0jzxXw9OoRF1a+mlsrW/X Vn7eH+/3EqQrv2NcvXyLqYfXcEa711mXgtkeKsDAt2tqXgOB6GBAa+N/1CJmcjY13YWb f6G0yX/Sjs21Ehf+v8FcxrzpZD5BtXsJZGATCLYlEJpdq8MzD3Wgai7Lh44+wGpxozzC 90C2ogRqs9dLbp3f8K3RMJOKGiXM13JjWi2ox2niyXLMXxn5dh08M6aMWzuarLvIi6ri airg== X-Forwarded-Encrypted: i=1; AL+hErHDdR8CLXFnMdPDVcCSpzL+JKe/A2IU1C6QQabiCzY+mg/70S1rEspPlwRk9r3IosvpDNSywQJqIKcLMRw=@vger.kernel.org X-Gm-Message-State: APuU4Z8Zkr/gcHO6erPY39rOMj64hHy10dh4aAkQb0EpyB4UiUKnFZm1 zGlZzZs4toySpGmmk70sYZXnDwjVZbDYMt1I5E7aZjj8ZABI978PeyesbTixDO87zYsu/SGcpJi 6ELui X-Gm-Gg: AZFdTZcSCTtfKtGwMC2wMIHzdpkz3m2vLUB2LzNafMcSMUkdhBLDlrCCyLzimslFWBH NzPehEiXLSq6Ufn99hB+Pp1WL1gXMo5gOm4g+HaIbDOwni0WJgqHUyKMKNBwmQ/2XTCshrP6Wgw 60Kr+qMVnYMvkNtFu7zdMRzRNEBs1GjSIBPEyWEr5ycQd+3hygL50uEEnBBEjNzolpEkXdgPtKD +IlcPMnMFDtRD6PtHjnDPIFOgs4xbpszCI8QzLv2Mf7MwXL4Zh4wi7E3ACdgZj1XbhylLbf8axo pFxOsp5I8Wz3PixH2DkKCbq3rFGp3UJ3g46zH/L8O93Qj5b3xW60k6C+khyIxRnbD9FwlHSeIhX /Kr6n9fJ3S1jDvYommYxSoxs+ADvrOEVrHy4QyvMqGtsLt81BcLSZBcFQ1lyCL5zJ+68lkou8I0 Y0a47eSvKSdZK0WP8jbD2BwtShmvSkn8VT3FGsYYnS7aShhxEYNJ3ipJHD+VtUvnU17MHy4vNve XC9q1OsKOrpuUf0+kZgLaS4tx1BhZiA6qTfp9CH3O0eEAMjKBs1HtJvxurgXK9SKisDySAVxwKK RTNeP3HOjbC97UpDBCkhNn0ASgTIXKv3HpFGWpgQeOI2hHdjqr8NGjCmEH2qYcko2UZnl95jiP6 wdlxMPMnm9kwD4yPd X-Received: by 2002:a05:600d:82c5:b0:4a3:5aee:2c25 with SMTP id 5b1f17b1804b1-4bb88822642mr902654015e9.31.1796202873192; Wed, 02 Dec 2026 01:14:33 -0800 (PST) Received: from ?IPV6:2a02:3033:27e:6449:f0e2:6233:74e1:8263? ([2a02:3033:27e:6449:f0e2:6233:74e1:8263]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbbaeb1e4csm361589785e9.13.2026.12.02.01.14.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Dec 2026 01:14:32 -0800 (PST) Message-ID: Date: Wed, 2 Dec 2026 10:14:30 +0100 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net] usbnet: don't lose rx mode updates that arrive during set_rx_mode() To: Mahdi Yari , andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20261202060513.660741-1-m.yary16@gmail.com> Content-Language: en-US From: Oliver Neukum In-Reply-To: <20261202060513.660741-1-m.yary16@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 02.12.26 07:05, Mahdi Yari wrote: > 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 Acked-by: Oliver Neukum