From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796202875; b=cO7pk4lNhe8jx8XTzymwq+iO82wMs88z1N7f3VoRf6oIx8Oto1xzNaImY9SOxBAQrH5D rLUYyWSziyYSkFztSu6Cc2SCAAIXmeGIsE0fNszh4YFTb3bAY9/prvLPOXPNrzHGqA9ua AYVYK5UpngNxYDlWM5xhkpGbbO8NER+KKKMqUrW5JWqfYy0rXAzahcz/n++8ZHRpIaiZn k9OUr6apA1/x9fPUre8w2VoSAJBLP35Y42+MM7wjv8XeO7ZRFalfmEnwrarNS3fterHTn wLOf5pEWc5q0TSUYRFKYsyvOiMh7NRqEw3I6u+xEEXaN0Y8fsJR4leiuu7xHpY4QU5A== 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=zO60PKhoJqOrFsX+ONMjytve6oI4IM7lcxgw11JtJpPt7HmD+n4ykjoXpT2jJWU3AfSh gW9oy3JHBJCaYVWpkQqs1MV9zZE1SyLY4iU3whhDX8d0D/6M9ch+k5Bn8KjWyW7G6Xnhy l9m8wl8Tbu2KTrKkRlr7vjU+1din6bZRnFs2v4at/l+L0RKpsTpALg5IZq21oazGYgI1y TCp81AVotK/kZ/JF8Ay0DknQO3OqwQjslvtJ7FssrszRJK3BWY7s5FWUYq8qj8zQOIWrk x2CaVtrFljhi4X+HYDAIbX6DqqoRP+WvGXDoFgfTbN+rPa/6w5SQSCHhiQmSl/6JfKw== 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.52 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 D58DC606A323 for ; Wed, 2 Dec 2026 09:14:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D58DC606A323 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-f52.google.com with SMTP id 5b1f17b1804b1-4bb64c99d2fso112729915e9.3 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=rXe5fGm1HpifEHhZFadepfD8+M6niaSY6w4qUeC1IAj5mRK88O52rIWJ7bsZoIlsHE 1zqql8cDrC8/KWOIoTZa/AC4047diVxaBrSKZoidll6LBgd4U8cJmbOYi9aoAUQ21UZP TVUsj/NogtGd1pPKGkumbz2RzSxfyCgIlF2J1ZqE4V/yTuSRZN3NaTq4p2hOe6sDI8zR u/ZqD9+UFzzE366DBNp4TTN1QjJeLMs4B/5opWi8ZON7FGdLS3Mx74DSkjvjxmPaX1/L cJkQdPYWvKqS98KjjSalF9RrunmGodAN1x85Ee9GYhhZBf1QalqTFV/crftLJZVBGU5P 3cDA== X-Forwarded-Encrypted: i=1; AL+hErHpGEpNjG7pfa9gxi6/RRjbIYceSNvjuo8EhisWF1Qc91zV2LxbC/jCSIZlexj89gNj419oJMlmmOo=@vger.kernel.org X-Gm-Message-State: APuU4Z9u4G4pKvPZLdW7x9RefJXd/W6OlrRc8vtRVi0tcz3aEGJxb9Xe 1Xi1q4bLX3Y8qBxZFAlSry8VSp7wlAhzqgeVJJfMQl07TAT7mBASkFpwQMtYVSiTeAA= X-Gm-Gg: AZFdTZf4nAEZavg734emsm4XijeebPEJGCKburUaMhsTASIARQYZnLk45Rc7sOMt8tp FZUBRDQ/+w/XrqsRqZ232It5lDKGr37+SZlli8dNYL3h4AZEcUgcQKXWM7RMrHhJ8UnsVSM4CLg P3MQtb+z2nUGQ56eKxqyEviGntTpPhFcVMJVjbYzPpEYm+AKqvFgfYYQId9RTnMP087vTgw6fY5 1r9NzLhYiTp5e32ehGDwMN8Z5Ctta/wZeIRPDTES4DuBO6LHDZyhpv5pkxiGZUHBcokpyLAfeVJ 3/mCup4Uk4tyqReIoTMLqNrDiVTyXtXfEyLaaUEPuhkgARB/5bnKt1iAKmsEbVJa1n3Nlemq0pR uAber0LYjBK4BEf/OrRs1K4nR09MEE9kl+KAc7vS6qCniRYC6q03y9+g9s6OPa1Vt50lIJHpoBn FEQH4w+nkSlOIfrnXFOZ6/3iFAyqTl2kOqR/XJSQmUXtZ8XemngZiBIhfAfLMYfbqE04jWBnwde bZ5L+VTKrpPaZ2EF/i7koSpWSaTG63UicsOX3yK8bS8gIcOzE+QcLyv8QDvU21jFCrw/aZPfmyt LTfjY4jRyZLizOgwnc9Podxg/ws1Ahf7v7Lw5vWE3it7CUQZb4jyjBBp/jznE3LE+qpAPKue5Sg FzhHcaO7S8GTPRFmf 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-usb@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