Linux IEEE 802.15.4 and 6LoWPAN development
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Lee Keon-Hyeong <leegun25@proton.me>
Cc: alex.aring@gmail.com,  stefan@datenfreihafen.org,
	linux-wpan@vger.kernel.org,  netdev@vger.kernel.org
Subject: Re: [PATCH net] mac802154: fix duplicate association handling
Date: Mon, 23 Nov 2026 09:48:34 +0100	[thread overview]
Message-ID: <87se0sue59.fsf@bootlin.com> (raw)
In-Reply-To: <20261121133101.240921-1-leegun25@proton.me> (Lee Keon-Hyeong's message of "Sat, 21 Nov 2026 13:31:08 +0000")

Hi Lee,

On 21/11/2026 at 13:31:08 GMT, Lee Keon-Hyeong <leegun25@proton.me> wrote:

> A retransmitted ASSOC REQ from an already known child is supposed to
> replace the old entry, but the lookup uses the new child's address mode.
> With alloc_addr=1 the new child has short-address mode and
> cfg802154_pan_device_is_matching() rejects short-mode queries, so the
> lookup never matches and every retransmission is appended as a new child,
> consuming an association slot and a short address.  With alloc_addr=0 the
> lookup matches, but the old entry is only list_del()'d without kfree(),
> leaking a kmalloc-32 object per retransmission, and nchildren is
> incremented again for the replacement.
>
> The ASSOC REQ source is always an extended address.  Look the existing
> child up by its extended address regardless of the short-address mode
> chosen for the new entry, free the replaced child, and count only
> genuinely new children.
>
> With max_associations=2, two association requests from the same peer
> exhaust all available slots and prevent another peer from associating.
> With alloc_addr=0, 300 repeated requests leak 300 kmalloc-32 objects and
> inflate nchildren; a subsequent disassociation leaves the counter
> inflated, and an interface down/up does not reset it.  Both behaviours
> were reproduced with a monitor/coordinator pair on mac802154_hwsim and
> are gone after this patch.
>
> Fixes: 601f160b61b2 ("mac802154: Handle association requests from peers")
> Signed-off-by: Lee Keon-Hyeong <leegun25@proton.me>
> ---
>  net/mac802154/scan.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/net/mac802154/scan.c b/net/mac802154/scan.c
> index d393b1f4e..ebef22e7e 100644
> --- a/net/mac802154/scan.c
> +++ b/net/mac802154/scan.c
> @@ -879,19 +879,23 @@ int mac802154_process_association_req(struct ieee802154_sub_if_data *sdata,
>  		"Successful association with new child %8phC\n", &ceaddr);
>  
>  	/* Ensure this child is not already associated (might happen due to
> -	 * retransmissions), in this case drop the ex structure.
> +	 * retransmissions), in this case replace the ex structure.  The ASSOC
> +	 * REQ source is always an extended address, so look the child up by it
> +	 * regardless of the short address mode chosen for the new
>  	entry.

Did you read back this comment and thought it was in any way useful?
Please drop.

>  	 */
> -	tmp.mode = child->mode;
> +	tmp.mode = IEEE802154_EXTENDED_ADDRESSING;

This is probably fine but an orthogonal change, so a separate patch, no?

>  	tmp.extended_addr = child->extended_addr;
>  	exchild = cfg802154_device_is_child(wpan_dev, &tmp);
>  	if (exchild) {
>  		dev_dbg(&sdata->dev->dev,
>  			"Child %8phC was already known\n", &ceaddr);
>  		list_del(&exchild->node);
> +		kfree(exchild);
> +	} else {
> +		wpan_dev->nchildren++;
>  	}
>  
>  	list_add(&child->node, &wpan_dev->children);
> -	wpan_dev->nchildren++;
>  
>  unlock:
>  	mutex_unlock(&wpan_dev->association_lock);

      parent reply	other threads:[~2026-11-23  8:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21 13:31 [PATCH net] mac802154: fix duplicate association handling Lee Keon-Hyeong
2026-11-21 13:31 ` netdev-bot+sinfo
2026-11-21 14:00   ` 이건형
2026-11-23  8:48 ` 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=87se0sue59.fsf@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=alex.aring@gmail.com \
    --cc=leegun25@proton.me \
    --cc=linux-wpan@vger.kernel.org \
    --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