From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796202875; b=IQfyuZzVZZPS3Xj6YMVU6W5B9x8OZX/xCLzT22bN8iQw+WrSEsOpmMpjh/o6/MOmytf4 DIO5BqLophfk5X6WnGAt0/840J0n/7QoluDxDzhHypWumEYrbiqH2da3uBD0q2hpUaohO LjtQxT7xVjTztgt86/zzMXhIHbnttUgqVJ7WDIaZ6LRMmyQ/zdEe+8rKyNDSRgASSOg2a kGl2rLoy27tz3fCfy0viEcuRbU1ILiY/Jlu6TuTxNX7Cv0ibR9jE+7f53i8y5dKmtLStG xWgNviUP9YWc9ecDtnrvBe6Nqi81lUpX493/Y3E7oiSfcQrWLPbAhXyElnZVjB6+NGQ== 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-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=r/qKRGGXOqGa5P/HZ1R1YNnEeLbJpGqdggOLIzQpKt04XpVpXOvBmt5nYsiXc+tWb8r6 EXp1HoNMq+2OJ1OYIxLOImZavN5bXhzVSHdJk+uzOZ7kZScW7Ed4ASx+T2p1aknFs+Zxw /nIvdRPK950MvDnXlEeC9MOrw2jpRLk6T7dGwBaE1S/0NwwpjbRaiVi2zfRTum66MyknI 35fWGgZZo36uiQzxtoB66PglZEnIiOHFc4cksO7o5/7dOUnfJPjSUM9gfuGYqEZRNR8pD 40BmzeyB7/iaL9NITiQMu7QCyoFqpoWOT2tMvdFnt0IVJwL806kRb7D9JqU2sQtq6dg== 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.221.49 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 CFF05606A322 for ; Wed, 2 Dec 2026 09:14:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CFF05606A322 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-wr1-f49.google.com with SMTP id ffacd0b85a97d-4aa5833c263so12212045f8f.2 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=YXzs9TLQrWFpTyIsFD/YwClT+qHsRWKEEwZI9MlqwVk2wJPtIBb0kEsZBQfDrAMYOt mtqPkpNVqv5c70DvxkknAI0QKhn9NHSvvwKh6JuiTxUPsI3vQIhRHwoLz9rCyeQphvSd SFDdByqAo3m3ZCDjXLZwsWsVsWoIihs6vSIn17AXjwQViC4+7f4bcTJ9PAHApHw9SC/T xCdRybjIxZlQlIT5XuDJekJ3JCZ9u57y8x0g7YTswPwgmNcrEo0GP/UQuZRfZocKnolJ wvEH/bjPuzetjJ9txGVFD5pp0CRtKIDmJJVaTPw6bnYjxrtXxmc7no29LDeohwkh21Dv gv9w== X-Gm-Message-State: APuU4Z/sT9NeVrh09sFZJwuX0hBrBLok9KILooe+yQOCY2gCoh2S5ESr r/LXMjCg7IGbmyKePxyHM+r+gt9P3xMR7RTYpiSYbkTK8M6v3mkzGmrkvgnp1iFUbzg= X-Gm-Gg: AZFdTZfZYqtWNg6YdFAylxlSBi27d3g5XGUN2y6G/CeXBczU+9rc/CF2soDS0jYn4QN c8WZNeSA2eU6iWwK+uNdzH/6TebXo8QcTCGFogmIJqFedup6NfjidE/BvTCDg5j2lJzw5lSr4oR b3f3aI3HEtaoYxFLaLx84ffhbncvL5OtrCgyXANqDax5Xz4LsqOT5g/ADQc/7iiPbC26TXjNTWL fZt2lH4tz7BF7e7J9pOooTNBapzXtxtiUfQfHYLHxNAWTWAFhhYjzxzaU3kE7Xt+kNuOvKMRN5L 5A8muHstYeQF6RCF0XIrUxLlzBS+a5VEP6hRuxGFVwqmCMVLbvjouuhaX08Lw+ooZqvNeYTvKda KIqOwdVpvA2qtVpNGA+YHaab6smSQOuj9zNYN2VIM8+Uji9LxKe9++BXvhGzQSSsNTM99cvE1N7 xVoSGJprj82j9HXQnxu5RAPbUFsmgHsmwt11gYwgdltizfutqaGGtkC4pJo22T6Vdntr7QZPkaT QrtgKkjsa15LrXikwmKuBFe3HtVWwRim2uPzMXZrqk7Zp4uS9fGOtS4zc2PftwthVBhM1Vj2qq0 8gt7QcpA4AKj0oiYpj4W+RPR9n0Bj1r2zjUSC2mO1djCanzI4jQSANoNhh0sf4zVsSbJsHnyYpO uZD+GBXI7oHlF4xKl 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: netdev@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