* [PATCH net] mac802154: fix duplicate association handling
@ 2026-11-21 13:31 Lee Keon-Hyeong
2026-11-21 13:31 ` netdev-bot+sinfo
0 siblings, 1 reply; 3+ messages in thread
From: Lee Keon-Hyeong @ 2026-11-21 13:31 UTC (permalink / raw)
To: alex.aring, stefan, miquel.raynal; +Cc: linux-wpan, netdev
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.
*/
- tmp.mode = child->mode;
+ tmp.mode = IEEE802154_EXTENDED_ADDRESSING;
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);
--
2.55.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] mac802154: fix duplicate association handling
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 ` 이건형
0 siblings, 1 reply; 3+ messages in thread
From: netdev-bot+sinfo @ 2026-11-21 13:31 UTC (permalink / raw)
To: Lee Keon-Hyeong; +Cc: alex.aring, stefan, miquel.raynal, linux-wpan, netdev
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] mac802154: fix duplicate association handling
2026-11-21 13:31 ` netdev-bot+sinfo
@ 2026-11-21 14:00 ` 이건형
0 siblings, 0 replies; 3+ messages in thread
From: 이건형 @ 2026-11-21 14:00 UTC (permalink / raw)
To: netdev-bot+sinfo; +Cc: alex.aring, stefan, miquel.raynal, linux-wpan, netdev
Hi,
The issue was identified during an LLM-assisted code audit of the mac802154 association handling path. I focused on this path because unauthenticated ASSOC REQs can affect the coordinator's association state.
The audit revealed an incorrect address mode used for duplicate-child lookup, a missing kfree(), and an incorrect nchildren increment.
I set up a simulated IEEE 802.15.4 environment using mac802154_hwsim and wrote a reproducer that sends repeated ASSOC REQs. The unpatched kernel exhibited association slot exhaustion and memory leaks, while neither issue was reproduced after applying the patch.
Best regards,
Lee Keon-Hyeong
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-21 14:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` 이건형
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox