Netdev List
 help / color / mirror / Atom feed
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
Subject: Re: [PATCH net v2 2/2] mac802154: fix locking for association response TX
Date: Mon, 30 Nov 2026 14:04:01 +0000	[thread overview]
Message-ID: <179604744132.3146.2594446005888432082@kernel.org> (raw)
In-Reply-To: <179595738440.2351517.4063708511885871057@proton.me>

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 <leegun25@proton.me>
> 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 <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

  reply	other threads:[~2026-11-30 14:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 13:03 [PATCH net v2 1/2] mac802154: free the skb when MLME TX is rejected leegun25
2026-11-29 13:03 ` [PATCH net v2 2/2] mac802154: fix locking for association response TX leegun25
2026-11-30 14:04   ` netdev-bot+sashiko [this message]
2026-11-30 14:03 ` [PATCH net v2 1/2] mac802154: free the skb when MLME TX is rejected netdev-bot+sashiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179604744132.3146.2594446005888432082@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alex.aring@gmail.com \
    --cc=kuba@kernel.org \
    --cc=leegun25@proton.me \
    --cc=linux-wpan@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=stefan@datenfreihafen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox