All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Ibrahim Hashimov <security@auditcode.ai>
Cc: alex.aring@gmail.com,  stefan@datenfreihafen.org,
	 horms@kernel.org, kuba@kernel.org,  linux-wpan@vger.kernel.org,
	 netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	 stable@vger.kernel.org
Subject: Re: [PATCH net v2] mac802154: lock rx_mac_cmd_list and drain it before freeing sdata
Date: Fri, 24 Jul 2026 11:31:06 +0200	[thread overview]
Message-ID: <87a4rgspid.fsf@bootlin.com> (raw)
In-Reply-To: <20260722101608.37744-1-security@auditcode.ai> (Ibrahim Hashimov's message of "Wed, 22 Jul 2026 12:16:08 +0200")


> rx_mac_cmd_list has no locking. The RX softirq producer in
> ieee802154_subif_frame() list_add_tail()s while the mac_wq worker
> list_del()s, and the worker dereferences mac_pkt->sdata with no
> liveness check.
>
> Removing an interface (or the phy) thus frees its sdata while a queued
> packet still points at it, and a later worker run reads freed memory: a
> KASAN use-after-free, reproduced by flooding a victim interface with MAC
> command frames and deleting it. Meanwhile sibling interfaces on the same
> phy keep adding to the list, corrupting it.
>
> Add rx_mac_cmd_lock around every access -- producer, worker (which now
> dequeues under the lock and processes the packet after) and the new
> mac802154_flush_queued_mac_cmds(). Drain the queue before the sdata is
> freed: from ieee802154_if_remove() after the RCU grace period (filtered
> to that sdata) and from ieee802154_unregister_hw(). The drain precedes
> cancel_work_sync() so a run that already dequeued a matching packet is
> waited out while its sdata is still alive.
>
> Fixes: d021d218f6d9 ("mac802154: Handle received BEACON_REQ")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ibrahim Hashimov <security@auditcode.ai>
> Assisted-by: AuditCode-AI:2026.07
> ---

Looks fine to me, but honestly this is flirting with the edge of my
human memory.

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

  reply	other threads:[~2026-07-24  9:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 10:16 [PATCH net v2] mac802154: lock rx_mac_cmd_list and drain it before freeing sdata Ibrahim Hashimov
2026-07-24  9:31 ` Miquel Raynal [this message]
2026-07-24 21:58 ` Jakub Kicinski

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=87a4rgspid.fsf@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=alex.aring@gmail.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=security@auditcode.ai \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.