Netdev List
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Yifan Zhang <yfzhang23@stu.pku.edu.cn>
Cc: linux-wpan@vger.kernel.org,  netdev@vger.kernel.org,
	alex.aring@gmail.com,  stefan@datenfreihafen.org,
	 davem@davemloft.net, edumazet@kernel.org,  kuba@kernel.org,
	 pabeni@redhat.com, horms@kernel.org,  zihanx@nebusec.ai,
	 stable@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v3] mac802154: validate pinned interface before beacon transmission
Date: Mon, 16 Nov 2026 17:09:32 +0100	[thread overview]
Message-ID: <87y0aspxkz.fsf@bootlin.com> (raw)
In-Reply-To: <179378621331.55520.8126896786309171541@stu.pku.edu.cn> (Yifan Zhang's message of "Wed, 04 Nov 2026 17:56:53 +0800")

Hi,

> Changes in v3:
> - revalidate the request and pinned interface under RTNL
> - serialize beacon template access with request replacement
> - free the skb on every failure before the transmit-path handoff

I think on this point we should have something a bit unified with the
scan worker, because both handle similar situations. This is worth
fixing in another patch.

> --- a/net/mac802154/scan.c
> +++ b/net/mac802154/scan.c
> @@ -354,35 +354,31 @@ static int mac802154_transmit_beacon(struct ieee802154_local *local,
>  				     struct wpan_dev *wpan_dev)
>  {

...

> +	rtnl_lock();
> +	beacon_req = rtnl_dereference(local->beacon_req);
> +	if (unlikely(!beacon_req || beacon_req->wpan_dev != wpan_dev ||
> +		     !ieee802154_sdata_running(sdata) ||
> +		     !netif_running(sdata->dev))) {
> +		ret = -ECANCELED;

Since this is not an error, the caller should maybe not amit a log at
the error level. Again, not worth a change in this patch, but would be a
good follow-up.

> +		goto out_free;
>  	}
>  
> -	sdata = IEEE802154_WPAN_DEV_TO_SUB_IF(beacon_req->wpan_dev);
> +	/* Update the sequence number */
> +	local->beacon.mhr.seq = atomic_inc_return(&wpan_dev->bsn) & 0xFF;
>  	skb->dev = sdata->dev;
>  
> -	rcu_read_unlock();
> -
>  	ret = ieee802154_beacon_push(skb, &local->beacon);
> -	if (ret) {
> -		kfree_skb(skb);
> -		return ret;
> -	}
> +	if (ret)
> +		goto out_free;
>  
>  	/* Using the MLME transmission helper for sending beacons is a bit
>  	 * overkill because we do not really care about the final outcome.
> @@ -402,7 +398,16 @@ static int mac802154_transmit_beacon(struct ieee802154_local *local,
>  	 * transmissions, wich anyway does not have a huge impact on the
>  	 * performances given the current design of the stack.
>  	 */
> -	return ieee802154_mlme_tx(local, sdata, skb);
> +	ret = ieee802154_mlme_tx_locked(local, sdata, skb);
> +	rtnl_unlock();
> +
> +	return ret;
> +
> +out_free:
> +	rtnl_unlock();
> +	kfree_skb(skb);
> +
> +	return ret;
>  }
>  
>  void mac802154_beacon_worker(struct work_struct *work)

Again, not related to this patch, but existing issue: since you are
fixing the beacon path that is very close to the scan path that has
already been fixed, there may be a missing cancel_delayed_work_sync() in
mac802154_stop_beacons_locked() (the timer may still be pending when the
PHY is freed).

So for me the patch is correct, but follow-ups are needed.

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl

      parent reply	other threads:[~2026-11-16 16:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 15:47 [PATCH net v2] mac802154: use pinned interface for beacon transmission Yifan Zhang
2026-11-04  9:56 ` [PATCH net v3] mac802154: validate pinned interface before " Yifan Zhang
2026-11-04 10:03   ` netdev-bot+sinfo
2026-11-16 16:09   ` Miquel Raynal [this message]

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=87y0aspxkz.fsf@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=alex.aring@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wpan@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=stefan@datenfreihafen.org \
    --cc=yfzhang23@stu.pku.edu.cn \
    --cc=zihanx@nebusec.ai \
    /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