From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796047442; b=HF6cu0X26BCklWljBCn6DN7rG46AdFAqQZ1Q7pCUghFFZl8H0Hc9UpusNwT3TB8O9QpJ F14WE1f5nucz75CLsnHzm16o//nIK5MDM+UgTeR9cfDPwDZJAdLJQe8yDGoXCcivk+Ipr 2D06/KC16P8cIezS6OYw4uCHHhyLhp9bdek1IBp+PDKvQdgA43oGnRTHAnUtLHJB+jcNT 2WbGoQadBFO3WKeSk6n5iiPXVw40e10fN0UK9OsyEiSnkPlo6iAOtbB4j2vjlT35cAyIo VZ8/OYQw4o6/RA9rzdGrpyIxIIxjuCDwVYbm49n+49KVNpoXMnCUG4gKKxzhPNvycOQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796047442; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=44vxtQcVp4rVpol3z1KBPfk5dgwuh+G0o8Z7bnFjXtA=; b=hb/0JABAk7x4r86f8aSWcEtPKrfA2Q+R9Z3r3AkxPrfbOugXRvkLE/FO+aLcOQWydfDu yVCPNoAG5WExzsprv0gmCVpKW3r1N3rb1iLzBs0SF80WEcicebunjEo1PVW7fvNlrqpj6 UWow9GEh0xbP/jzFUNIajhRATMzeIgnZpEjASpa0xFJkP1wfsglKibXOWE2jem0T/Fj+y pzwOkX5J8ld9OWnftZGddmJAqxW1eAP+uDAB60Yh7IHxzF4C9xKC5cZ0vG2gNFiHd0FuB 9aDLEtV59P7DwZo/Ot60seWC0Uzqmdv4Pr1YlCZUzfhgeT82Na4WYH+Qc28pJEGRvnQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NniOo5Ip; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F364606A32D; Mon, 30 Nov 2026 14:04:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NniOo5Ip Received: by smtp.kernel.org (Postfix) with ESMTPSA id C57DF1F0089A; Mon, 30 Nov 2026 14:04:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796047442; bh=44vxtQcVp4rVpol3z1KBPfk5dgwuh+G0o8Z7bnFjXtA=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=NniOo5IpaIxQPoYflSo+YWpHfx2V/HkM5ArIB8Y5udq1876HiDgQzDsuPJXonQYgE 7YS02YPhQ2/DoZwikqS5PPqedHWgi8ozXnUzVkn10SQeoZOSUYvMBexQ+iaNKZjAXq TGdYdp1+mCUoNTlNGom0ndqqLrALxEKwgXe5l/R3V/wvnMVin9pzh4JuhSDNpBlv5O hKw5BOfxG+Tabq/LDR1nfmSL74KI7UTwPwdJaWwRHJhPiZoVyFpztuAE+IA1yy4kFr nLlxgxWiYFMlv6v6lut1T+6MRD8PopQfEycytPDTiVIntFJTGnIZYgeMf7a4T9Qy2D IS5xwbLy4OpYA== Subject: Re: [PATCH net v2 2/2] mac802154: fix locking for association response TX From: netdev-bot+sashiko@kernel.org To: leegun25@proton.me Cc: miquel.raynal@bootlin.com, alex.aring@gmail.com, stefan@datenfreihafen.org, linux-wpan@vger.kernel.org, netdev@vger.kernel.org, kuba@kernel.org Date: Mon, 30 Nov 2026 14:04:01 +0000 Message-ID: <179604744132.3146.2594446005888432082@kernel.org> In-Reply-To: <179595738440.2351517.4063708511885871057@proton.me> References: <179595738440.2351517.4063708511885871057@proton.me> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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 Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 1 · Low: 2 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] mac802154: unsynchronized TX and stop paths in ieee802154_mlme_tx_hw() - [Medium] The new local->hw_mutex replaces the RTNL requirement that ieee802154_mlme_tx_locked() used to assert. - [Low] The patch makes several behaviour and naming changes that the commit message does not mention: - In ieee802154_mlme_tx_hw() it drops… - [Low] The commit was created from a mangled mbox. -- mac802154: fix locking for association response TX This patch adds a per-PHY hw_mutex that serializes MLME TX with interface open and close, so the association response worker no longer needs RTNL. ieee802154_mlme_tx_locked() is renamed to ieee802154_mlme_tx_hw(). The new function holds hw_mutex from the interface state check until TX completes. > mac802154: fix locking for association response TX > > >>From c5f32daa0f9e2322ad7ff5f098946d4364e8bb65 Mon Sep 17 00:00:00 2001 > From: Lee Keon-Hyeong > Date: Fri, 27 Nov 2026 11:42:51 +0900 > Subject: [PATCH net v2 2/2] mac802154: fix locking for association response TX [Severity: Low] This isn't a bug, but it looks like the patch was applied from a mangled mbox. The format-patch headers ended up in the commit message body. Because the ">>From" line comes first, the in-body From: was not picked up. As a result, the git author is "leegun25@proton.me " with no real name, which doesn't match the Signed-off-by name "Lee Keon-Hyeong". The author date is also the apply time rather than the date of the patch. The sibling commit "mac802154: free the skb when MLME TX is rejected" seems to have the same problem. Could these be resubmitted with git send-email, or fixed up when applied? > diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c > index af5003b931bb0..baff40bac4427 100644 > --- a/net/mac802154/tx.c > +++ b/net/mac802154/tx.c > @@ -137,31 +137,26 @@ int ieee802154_mlme_op_pre(struct ieee802154_local *local) > return ieee802154_sync_and_hold_queue(local); > } > > -int ieee802154_mlme_tx_locked(struct ieee802154_local *local, > - struct ieee802154_sub_if_data *sdata, > - struct sk_buff *skb) > +int ieee802154_mlme_tx_hw(struct ieee802154_local *local, > + struct ieee802154_sub_if_data *sdata, > + struct sk_buff *skb) > { > - /* Avoid possible calls to ->ndo_stop() when we asynchronously perform > - * MLME transmissions. > - */ > - ASSERT_RTNL(); > + int ret; > > - /* Ensure the device was not stopped, otherwise error out */ > - if (!local->open_count) { > - kfree_skb(skb); > - return -ENETDOWN; > - } > + mutex_lock(&local->hw_mutex); > > - /* Warn if the ieee802154 core thinks MLME frames can be sent while the > - * net interface expects this cannot happen. > - */ > - if (WARN_ON_ONCE(!netif_running(sdata->dev))) { > + if (!local->open_count || !ieee802154_sdata_running(sdata)) { [Severity: High] Does hw_mutex serialize this transmission against normal data TX? mac802154_send_association_resp_locked() calls ieee802154_mlme_tx_hw() directly. It does not use the ieee802154_mlme_op_pre() and ieee802154_mlme_op_post() pair that ieee802154_mlme_tx_one_locked() uses. Inside ieee802154_mlme_tx_hw(), ieee802154_tx() runs first. ieee802154_sync_queue() only waits for ongoing_txs afterwards. Data frames reach the driver without taking hw_mutex: ieee802154_subif_start_xmit() ieee802154_hot_tx() ieee802154_tx() ieee802154_tx() stops the netdev queues while a frame is in flight. The MLME path calls ieee802154_tx() directly and ignores the queue state. If a data frame is still in flight when an ASSOC REQ arrives, the rx_mac_cmd worker hands a second frame to the driver. The core and the transceiver drivers only expect one in-flight frame per PHY. With xmit_sync drivers such as adf7242 or cc2520, the second call overwrites local->tx_skb and leaks the first skb. It also raises phy->ongoing_txs to 2. If sync_tx_work is still pending, queue_work() is a no-op and only one completion follows. With xmit_async drivers such as atusb, drv_xmit_async() overwrites atusb->tx_skb and resubmits tx_urb while it is still active. Once ongoing_txs is stuck above zero, the worker sleeps forever in the wait_event() in ieee802154_sync_queue(). It does so while holding hw_mutex and wpan_dev->association_lock. The next mac802154_slave_close() would then block on hw_mutex with RTNL held. The direct call without op_pre predates this patch. However, the commit message says hw_mutex serializes MLME TX, and this path now runs without RTNL by design. Should the response path also drain and hold the queue? One option is to call ieee802154_mlme_op_pre() and ieee802154_mlme_op_post() from mac802154_send_association_resp_locked(). Another is to do it inside ieee802154_mlme_tx_hw() under hw_mutex. ieee802154_mlme_tx_one_locked() and mac802154_trigger_scan_locked() also run ieee802154_mlme_op_pre() outside hw_mutex. The suspend and scan cleanup paths also stop the device without taking it. Given that, it isn't clear which TX and device state hw_mutex is meant to protect. Could the commit message spell that out? [Severity: Low] This isn't a bug, but the commit message doesn't mention several of the changes here: - the WARN_ON_ONCE(!netif_running(sdata->dev)) diagnostic is dropped, so the function now returns -ENETDOWN silently - the netif_running() check is replaced with SDATA_STATE_RUNNING - ieee802154_mlme_tx_locked() is renamed to ieee802154_mlme_tx_hw() - ieee802154_mlme_tx_one_locked() gains a new ASSERT_RTNL() Dropping the WARN looks justified. __dev_close_many() clears __LINK_STATE_START before ndo_stop, and the worker can now race with close. Could the commit message say so? Also, mac802154_send_association_resp_locked() keeps its _locked suffix. In scan.c and tx.c that suffix means RTNL is held, but this function now runs without RTNL by design. Would renaming it avoid misleading future readers? > kfree_skb(skb); > - return -ENETDOWN; > + ret = -ENETDOWN; > + goto out; > } > > ieee802154_tx(local, skb); > - return ieee802154_sync_queue(local); > + ret = ieee802154_sync_queue(local); [Severity: Medium] Does hw_mutex cover every path that ASSERT_RTNL() used to exclude here? Only mac802154_slave_open() and mac802154_slave_close() take hw_mutex. Other paths stop and restart the transceiver with only RTNL held. wpan_phy_suspend() takes rtnl_lock() and then calls ieee802154_suspend(): net/mac802154/cfg.c:ieee802154_suspend() { ... ieee802154_sync_and_hold_queue(local); synchronize_net(); /* stop hardware - this must stop RX */ ieee802154_stop_device(local); suspend: local->suspended = true; ... } ieee802154_resume() also calls drv_start() with only RTNL held. So does mac802154_scan_cleanup_locked(), which is reached from mac802154_abort_scan_locked() via the abort-scan op or via slave_close: net/mac802154/scan.c:mac802154_scan_cleanup_locked() { ... drv_stop(local); synchronize_net(); sdata->required_filtering = sdata->iface_default_filtering; drv_start(local, sdata->required_filtering, &local->addr_filt); ... } Suspend leaves open_count and SDATA_STATE_RUNNING unchanged. The new check also doesn't look at local->suspended, although mac802154_beacon_worker() and mac802154_scan_worker() both check it. local->mac_wq is not freezable. Could an ASSOC REQ from a remote peer, handled by the rx_mac_cmd worker, then reach the driver while the transceiver is stopped? mac802154_rx_mac_cmd_worker() mac802154_process_association_req() mac802154_send_association_resp_locked() ieee802154_mlme_tx_hw() ieee802154_tx() drv_xmit_async() On mac802154_hwsim this would hit WARN_ON(current_phy->suspended) in hwsim_hw_xmit(), because hwsim_hw_stop() sets suspended to true. Some drivers drop the completion once stopped. With those, ongoing_txs never returns to zero. The worker would then sleep forever in the wait_event() in ieee802154_sync_queue() while holding hw_mutex and wpan_dev->association_lock. Would the next mac802154_slave_close() then block in mutex_lock(&local->hw_mutex) with RTNL held? The header comment above mac802154_scan_cleanup_locked() states: Concurrent modifications to the PHY, the interfaces or the hardware is in general prevented by the rtnl. The commit message doesn't mention suspend/resume or scan abort. RTNL excluded the scan cleanup window and a suspend in progress. Sending after a completed suspend without checking local->suspended was already possible before this patch. > + > +out: > + mutex_unlock(&local->hw_mutex); > + return ret; > } [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179595738440.2351517.6900122072700162037%40proton.me