Netdev List
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Kaiwen Shi <skwkevin@mail.ustc.edu.cn>
Cc: Alexander Aring <alex.aring@gmail.com>,
	 Stefan Schmidt <stefan@datenfreihafen.org>,
	 linux-wpan@vger.kernel.org,
	 "David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@google.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>,
	 Simon Horman <horms@kernel.org>,
	 netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	 stable@vger.kernel.org
Subject: Re: [PATCH net v2] mac802154: fix data race and NULL deref on local->assoc_dev
Date: Thu, 27 Aug 2026 11:11:37 +0200	[thread overview]
Message-ID: <878q5sdj1y.fsf@bootlin.com> (raw)
In-Reply-To: <20260826225959.682483-1-skwkevin@mail.ustc.edu.cn> (Kaiwen Shi's message of "Thu, 27 Aug 2026 06:59:59 +0800")

Hi Kaiwen,

>   - cache the coordinator extended address instead of retaining the
>     assoc_dev pointer, as suggested by Miquel;
>   - use a plain spinlock to serialize the cached address and associating
>     bit, including 64-bit address accesses on 32-bit architectures;

Can you justify the choice of a spinlock vs. mutex here? This is an open
question, not a request for changes.

>   - reset the completion under the same lock, recheck the associating bit
>     in the response handler, and complete before releasing the lock;
>   - use the response payload in the debug message;
>   - add Cc: stable@vger.kernel.org.
>

...

> --- a/net/mac802154/scan.c
> +++ b/net/mac802154/scan.c
> @@ -578,9 +578,11 @@ int mac802154_perform_association(struct ieee802154_sub_if_data *sdata,
>  		return ret;
>  	}
>  
> -	local->assoc_dev = coord;
> +	spin_lock(&local->assoc_lock);
>  	reinit_completion(&local->assoc_done);
> +	local->assoc_dev_extended_addr = coord->extended_addr;
>  	set_bit(IEEE802154_IS_ASSOCIATING, &local->ongoing);
> +	spin_unlock(&local->assoc_lock);
>  
>  	ret = ieee802154_mlme_tx_one_locked(local, sdata, skb);
>  	if (ret) {

Shouldn't we also make sure that accessing assoc_status/assoc_addr is
serialized? Typically, I believe the IS_ASSOCIATING bit should be
cleared earlier in mac802154_perform_association(), just after the
wait_for_completion call returns. This way, in case we get two responses
for the same request (maybe a malicious one), it will prevent the
possibility to get incoherent assoc_status and assoc_address.

Thanks,
Miquèl

  reply	other threads:[~2026-08-27  9:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 22:59 [PATCH net v2] mac802154: fix data race and NULL deref on local->assoc_dev Kaiwen Shi
2026-08-27  9:11 ` Miquel Raynal [this message]
2026-08-27 22:11   ` Kaiwen Shi

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=878q5sdj1y.fsf@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=alex.aring@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --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=skwkevin@mail.ustc.edu.cn \
    --cc=stable@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