From: Xuanqiang Luo <xuanqiang.luo@linux.dev>
To: linux-wpan@vger.kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
alex.aring@gmail.com, stefan@datenfreihafen.org,
miquel.raynal@bootlin.com, david.girault@qorvo.com,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, stable@vger.kernel.org,
Xuanqiang Luo <luoxuanqiang@kylinos.cn>
Subject: [PATCH net v2 0/2] mac802154: fix queued RX descriptor lifetime
Date: Thu, 3 Sep 2026 20:32:00 +0800 [thread overview]
Message-ID: <20260903123202.60152-1-xuanqiang.luo@linux.dev> (raw)
From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
mac802154 queues one descriptor per received beacon or MAC command, but
each worker invocation dequeues only one. Since queue_work() coalesces
attempts to queue the same pending work item, a burst can add more
descriptors than scheduled invocations. A later frame may schedule another
invocation, but also adds a descriptor, so it does not necessarily reduce
the backlog. Descriptors can therefore remain queued indefinitely once
reception stops. The RX path, workers, and scan cleanup also access the
descriptor lists without common synchronization.
A queued descriptor carries its receiving interface beyond the RCU
read-side critical section without holding a netdev reference. If the
interface is removed first, the worker can dereference freed memory.
Protect the descriptor lists with a spinlock and keep the workers running
until the queues are empty. Then hold the netdev for the lifetime of each
queued descriptor to prevent it from being freed too early.
This ordering is required. Without the queue-draining fix, a descriptor
stranded by queue_work() coalescing would also strand its netdev reference,
as netdev_put() runs only when the descriptor is released, leaving the
netdev pinned indefinitely.
---
Changes:
v2:
Patch 1 (new):
- Serialize descriptor list access and requeue each worker while another
descriptor remains.
- Detach queued beacons under the same lock before scan cleanup frees
them.
Patch 2:
- Replace the v1 drain_workqueue() approach, which does not cover work
queued after the drain or the DEL_INTERFACE path, with a netdev
reference held by each queued descriptor. (Sashiko.)
v1: https://lore.kernel.org/all/20260828101905.26865-1-xuanqiang.luo@linux.dev/
Xuanqiang Luo (2):
mac802154: serialize and drain queued RX descriptors
mac802154: pin netdevs for queued RX descriptors
include/net/cfg802154.h | 2 ++
net/mac802154/ieee802154_i.h | 2 ++
net/mac802154/main.c | 1 +
net/mac802154/rx.c | 36 ++++++++++++++++++++++++++++++------
net/mac802154/scan.c | 8 +++++++-
5 files changed, 42 insertions(+), 7 deletions(-)
base-commit: dc4b95b8fee95113587e93ca116356032d271371
--
2.43.0
next reply other threads:[~2026-09-03 12:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 12:32 Xuanqiang Luo [this message]
2026-09-03 12:32 ` [PATCH net v2 1/2] mac802154: serialize and drain queued RX descriptors Xuanqiang Luo
2026-09-04 16:27 ` Miquel Raynal
2026-09-03 12:32 ` [PATCH net v2 2/2] mac802154: pin netdevs for " Xuanqiang Luo
2026-09-04 16:27 ` Miquel Raynal
2026-09-05 6:02 ` [PATCH net v2 0/2] mac802154: fix queued RX descriptor lifetime Xuanqiang Luo
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=20260903123202.60152-1-xuanqiang.luo@linux.dev \
--to=xuanqiang.luo@linux.dev \
--cc=alex.aring@gmail.com \
--cc=davem@davemloft.net \
--cc=david.girault@qorvo.com \
--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=luoxuanqiang@kylinos.cn \
--cc=miquel.raynal@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--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