From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796202875; b=epoDWJuVsK3yqKkzZeIwLZmrMIARqoHbSMj7PfaI9IlvoE3V1ltUvj1Cr6wqg6Lc5rIS IS1hOJxpVSrTdXOeG5QzWSTy9xNA8lBfJNx+1Qd+7a8yipm4T9Zme/7NBJ/j/B0PSrEMp FPqHUUOIfKUoFOxg7lMbHIlrubdBCrSM8oFpzyxAkwXuSbnOg+QlPstTYGCjija6h6xeH 0B3pXbtM6vOMZbEkYptGRZKX5GLZGbowUUjjN41k9sJmZ+c9Zk7W7k7odFsbwQfqmDXth fN7Q3zj1pims8xhlRcSxBOVQflh9dxkH9MtkLxxtEqz4n6Y4D4o9lYYcLnj5nADvkGg== 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=ZySxqp9GBoTXwaR4vx2qWzZ+efJlbPxMf5NMt7nyTZ2IzgPE+epeJF+VK1c7rMbFqoPN E3vUX9zrfLcU9wwPgVa0so2YNgyLLrh28DvwX7GQSb2oQwPa/fH6l0qRIxkeZfKbaLjwj y7/1qeoh0MRk4oUcqKNo/e4WAkZbd0+hwJSmxPq5WNC7M/cXQRKxHXlC/xS0ED1Jhe0By kNcmta2UUZCLr0YA7rNqmeYVpY06s7XmOs13N7PJmn0g0bYLNSoOhMoTl4tYdvdBvPF0d pV2pYRRQzlQqKwtYh3D2e83LFqEax04EvIvFGUgXJzAl8Z6ljgPvAYqKgqjg6MIspvw== 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.49 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.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 C7194606A31A for ; Wed, 2 Dec 2026 09:14:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C7194606A31A 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-f49.google.com with SMTP id 5b1f17b1804b1-4bb6c7b6dbdso118260255e9.0 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=cCWNlyVGO3A5QwnCRohsnmw8IeSVFKrSYdLxWvNoS5eb/AZTcLD/ajrtMZ9u9b6hJV yGZ8GWF7QbbwqLweeYI2AOYTvCj8PADZ0t06HcwsUfrv6S9yGlxqZxKYUANN0yIU+tvi rL6FQNH2HDWVJ2d31ut5a/k5U8DiPeMnJFR1nFQ4dNSIhVp0v0LLHJzSCsM+zV7IgBHj 2X0P1QZu+czbQV3ZqN1X5M19EjoxeUo+uTSr5x895O0W6ZsjryP6FP8BM/8ZeVDoNQhw V9ogPGd/2iVLe65ldajWMKhE1aqmEv4mgH2XjXOilEZQSf5QNLnzaP0opKI4f/WHqE6y 6Kwg== X-Forwarded-Encrypted: i=1; AL+hErGzXZtwrKMK1wfigJ2/o+msY9MXyDTTrzBmRqC+RMvvnDi19q+AQo2pnHWtZXgfEO9LksGMFaM=@vger.kernel.org X-Gm-Message-State: APuU4Z9Nn6MAUW/8rGE7ENiG6tbZoFh50pQvMldCAiqog+XEgdaliMeH NIxLuPGBH6MRIVwSxapF7jWscXnzZfsqwV/hki7M3cvVnP0yqKurZqCpa5WUTQQmhng= X-Gm-Gg: AZFdTZdq3rKK4COI5k6/y+r0EkGEqpnSCmzoxQS6vUnj9c159V4ww1PJqIWXQwTIPcb 1DvwA5NCAghtMVZKfMKRNfi7PbYGsNjLydPPOkrnn4dt/iEB2dfhzcRee7/HcQOdtmVGnjC0+yr TaDTB6sTpo8xlsjao9aZbUPwrAfFal0A7cSflnGFZErAwIaesl5306aRM8iZGBGMuNeSAn8bVbi QdSXEBftOCU8YBjW3QnclMeNTXxPG0+3eaYs9hqixkgLnKvnox5wPsXfy+ToSoyY3Vkmkx3oR2B fifi+Xf2TtFIDD3Nd9yXdqHkaTXUW5KTdbkRRDtjqXjYVt5Xpnjwuxt158X/mqMcviMuyvtEhd7 7x5fJPAvTcBSJzJ0oBSzDs4iMeN5jCPNC3BIS4AIyo04gzpvSoCFHf8Rs8qdA6GT5ss1PvD2+Bj o9/kpo1+Drkeip17nQ4xFaumuikwEAlefgkPEU+7dtrqSjZ8UGvcBlBZYNdlnQPSqRzffU+UBOR EVWX76jtS68Lt0dtgZd+oc3X0S6e1078n8tD8x4CbjSuyNG0oDtb46oaXZOcvRgNYIolm05qpHc /BpS/vknbJ+eXtZMVXoDmb3ZyP+geF3K42JhogQ/nEsQqNFMa3qjzb0chezplUOTYrIFNJ4XvKf Z7aPL7foy1dTZwMwx 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: stable@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