Repository navigation
wifi: cfg80211: send the held-back scan message of a stale request - #2110
Conversation
When a netdev goes down while its driver is still scanning, NETDEV_DOWN completes the scan for cfg80211 with ___cfg80211_scan_done(rdev, false). That parks the result message in rdev->scan_msg, to be sent once the driver is done, and, because the driver still owns the request, only marks the request stale. When the driver later calls cfg80211_scan_done(), the stale path frees the request and returns without queueing scan_done_wk, the only place that sends and clears rdev->scan_msg. The message then stays forever, and nl80211_trigger_scan(), cfg80211_conn_scan() and the internal scans all fail with -EBUSY while it is set: no scan or connect works on that wiphy until the driver is reloaded. Queue scan_done_wk from the stale path as well, so the parked message is sent. Since a run queued this way may find that the message has already gone out and a newer scan is in progress, make the work function return when there is no message to send and the current request has not yet been completed by the driver. Seen on a MacBook Pro (M6, J804) with the Centauri driver, on an earlier base (integration/aurora f5fa539): NetworkManager takes the interface down for a lid-close sleep while a wpa_supplicant scan runs, and after the wake every scan failed with "CTRL-EVENT-SCAN-FAILED ret=-16" until reboot. With this change (and scan abort and interface-down handling in that driver), Wi-Fi reconnected within 2 s after each of two lid sleeps, with no failed scan. Signed-off-by: LiamRay11 <[email protected]>
sithglan
left a comment
There was a problem hiding this comment.
Test report, 2026-11-17: Apple Mac mini M6 (J873g/T8152, board 0x24). PR revision tested: 517dd2f1d5602720d72b0b6d7eca3ce6d9a58012.
Host validation used the combined #2105–2108/#2110–2112 series (54742c617db4 on 677be395b9d2) with Clang 22. All changed driver objects built with W=1 and no new warnings; two pre-existing DART unused-helper warnings were unchanged.
net/wireless/scan.o built with Clang 22 and W=1 with no new warnings. This patch was also applied to the separate M6 hardware-test kernel; Wi-Fi scans completed successfully, returning 10 and 19 BSS entries in the two smoke runs.
The scan-versus-NETDEV_DOWN / held-back stale-request race was not deliberately triggered. This is build and ordinary scanning smoke coverage, not a reproduction of the race or proof that every ordering is fixed.
|
Blockers: 1. The fix is right as far as I can see. Since dab68a7 ("wifi: cfg80211: don't free driver-owned scan requests"), NETDEV_DOWN parks the message in
HW row: J804 with the Centauri driver on current integration/aurora plus this commit only (no driver scan-abort changes), default command line: take the interface down while a scan runs (e.g. Assisted-by: LLM (Claude:Opus 5.5) |
|
Merge-train adversarial review (MERGETRAIN-LINUX2) at 517dd2f: NO BLOCKERS. Code read only, nothing built here. Before the merge it still needs Dj's verdict at this head; the missing rows are listed below. Full review#2110 wifi: cfg80211: send the held-back scan message of a stale request @517dd2f1VERDICT: NO BLOCKERS Code checks out:
Nits:
Missing rows:
|
There was a problem hiding this comment.
Formal §1–§6 pre-PR review at verified live head 517dd2f1d5602720d72b0b6d7eca3ce6d9a58012 (base integration/aurora 70a00e583b03; not superseded; MERGEABLE/clean; live CI Host tests run 43992647221: PASS).
Technical Assessment (§1–§3, §6 Sound)
- Correctness & concurrency (
net/wireless/scan.c, +19/-1): Verified against livenet/wireless/scan.candnet/wireless/core.c.NETDEV_DOWN(core.c:1786-1792) and P2P stop (core.c:271-276) call___cfg80211_scan_done(rdev, false), parking the completion skb inrdev->scan_msgand marking a driver-owned requeststale = true. Queueingwiphy_work_queue(&rdev->wiphy, &rdev->scan_done_wk)on theintreq->stalepath incfg80211_scan_done()closes the permanent-EBUSY/-EAGAINwedge innl80211_trigger_scan(),cfg80211_conn_scan(), andcfg80211_wext_siwscan():rdevis captured fromrequest->wiphyprior tokfree(intreq)(no UAF).wiphy_work_queue()is atomic-context safe and runs__cfg80211_scan_done()underrdev->wiphy.mtx, guaranteeing serialization afterNETDEV_DOWNstoresrdev->scan_msg = msg.- The guard
if (!rdev->scan_msg && req && !req->notified) return;in__cfg80211_scan_done()prevents a stray stale-path work run from prematurely completing a newly started scan (including part 2 of aWIPHY_FLAG_SPLIT_SCAN_6GHZsplit scan) while never dropping a normal completion (which setsintreq->notified = truebefore queueingscan_done_wk).
- §1 / §2 / §3 / §6: Generic
cfg80211fix, no model gating, default-cmdline safe, naming clean.
Blockers Before APPROVE
- §4 Attribution — AI commit trailer present (hard rule):
- Commit
517dd2f1d560carriesCo-Authored-By: Claude Opus 5.5 <[email protected]>. Per §4, commits must carry human author/committer and humanSigned-off-by:only, with zero AI commit trailers. Drop theCo-Authored-By:trailer from the commit, and replace the PR body'sGenerated with [Claude Code]footer with a plainAssisted-by:line.
- Commit
- §5 Exact-head hardware reproduction & regression triad missing:
- Neither the J804
pm_test=devicesrun nor the J873g smoke test actually triggered theNETDEV_DOWN-during-active-scan race on this head (the olderf5fa539run also carried out-of-tree Centauri scan-abort patches), and neither includes the §5 regression health triad (0 SELinux denials[orN/A],0 failed units,0 new kernel errors). - Because this changes core
net/wireless/scan.c(shared bybrcmfmac,mt7932, andcentauri), please post an exact-head run on default cmdline (without out-of-tree scan-abort workarounds) reproducingip link set <iface> downmid-scan -> link up -> subsequent scan/connect succeeding with0-EBUSY/CTRL-EVENT-SCAN-FAILED ret=-16wedge, along with the §5 regression triad (0 SELinux denials, 0 failed units, 0 new kernel errors), and confirm or request a no-regression check on abrcmfmac/mt7932Mac per §1.
- Neither the J804
- §6 CI coverage after re-push:
.github/workflows/mt7932-kunit.yml(which triggers onnet/wireless/**) landed onintegration/auroraafter517dd2f1d560; once re-pushed with the §4 fix, bothHost testsandMT7932 KUnitmust finish green.
Non-Blocking Note
- Since upstream commit
dab68a74e90b ("wifi: cfg80211: don't free driver-owned scan requests")introduced this behavior, adding aFixes:tag (and using a real name inSigned-off-by:) will make upstreaming tolinux-wireless/stable clean.
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 517dd2f1d560
Blockers:
- Commit
517dd2f1carries aCo-Authored-By:trailer that names an AI tool. We keep tool attribution out of commits. The commands below drop that line only; yourSigned-off-bystays. The row stays valid after that push, because the code doesn't change.
git fetch origin
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch -f --msg-filter "grep -viE '^(assisted-by:|(co-authored-by|signed-off-by):.*(claude|copilot|codex|gemini|cursor|openai|anthropic)|[^a-z]*generated with)' | git stripspace" origin/main..HEAD
git push --force-with-leaseChecked: no Apple material, no gates, generic cfg80211 fix. The stale path in cfg80211_scan_done() now queues scan_done_wk, and the new early return in __cfg80211_scan_done() can't skip a normal completion, because that path sets notified before it queues the work. Rows at this head on J873g (sithglan) and J804. CI green. This replaces my earlier review: the extra race-reproduction run and the regression checklist it asked for aren't needed to merge, and I removed the tool footer from the PR body myself.
Evidence
Read the diff against net/wireless/scan.c and core.c (NETDEV_DOWN and p2p stop park the message; the stale path was the only completion that never sent it). A run on a brcmfmac Mac is a check after the merge. Nit: a Fixes: dab68a74e90b tag would help upstreaming.
Superseded by the review at 517dd2f
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
517dd2f to
6c02e96
Compare
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: approve at 6c02e964c9b0. The one blocker from my earlier review is fixed, so I'm dismissing it.
Fixed: the tool-attribution trailer. 6c02e964c9b0 is the same change with the Co-Authored-By: line removed and your Signed-off-by kept.
Code unchanged: it has the same parent (bf423bf0e42c) and the same tree (273cd4060218) as the reviewed 517dd2f1. So the J873g and J804 rows and my earlier read of cfg80211_scan_done()/__cfg80211_scan_done() still apply.
Checked: CI is green at this head (host tests, KUnit, pr-text, readiness), and the PR body carries no attribution.
Not blocking: a Fixes: dab68a74e90b tag would still help upstreaming.
Merging is left to the PR Merge Lane.
Superseded by the review at 6c02e96
|
J700 (Neo, A18 Pro): forced scan abort with this fix What was tested: this PR's diff (head Before the abort: wld0 connected; two root scans returned 7 and 9 BSS. Boot error lines: 11, with 0 Wi-Fi and 0 PCIe (the stock boot has 12, 0 Wi-Fi, 0 PCIe). The trigger, as in the PR: run from a detached root unit:
Results
Not covered: a stock-kernel run of the same trigger. If the bug reproduces there, it would cut the Neo's only network link until reboot. So this row shows that the fixed kernel recovers; it does not show that stock wedges. |
|
Merging at |
Summary
A generic cfg80211 fix. If a netdev goes down while its driver is still scanning, every later scan and connect on that wiphy fails with -EBUSY until the driver is reloaded.
The bug
___cfg80211_scan_done(rdev, false). That parks the result message inrdev->scan_msgand, because the driver still owns the request, only marks the request stale.cfg80211_scan_done(), the stale path frees the request and returns without queueingscan_done_wk. That work is the only place that sends and clearsrdev->scan_msg.nl80211_trigger_scan(),cfg80211_conn_scan()and the internal scans return -EBUSY while it is set.The fix
Queue
scan_done_wkfrom the stale path too, so the parked message is sent. A run queued this way may find that the message is already gone and a newer scan is running, so the work function now returns when there is no message to send and the current request has not been completed by the driver.Testing
On hardware: MacBook Pro 14-inch (M6, J804), 2026-11-16, tested by LiamRay11.
bf423bf0ewith all nine J804 linux PRs merged (t8152-mailboxes, dart-gen3, dt-board, centauri, g18-fast-retire, cfg80211-stale-scan, smc, cs42l84-jack, and an NVMe PR that is not sent yet), plus retest-only device-tree changes that are not part of these PRs: SSD nodes (ANS mailbox, SART, NVMe), PCIe port 0 with the N1 Wi-Fi, the USB0 gadget console, and aread-onlyNVRAM partition. Those nodes were needed to reach the root filesystem and SSH.systemctl rebootfrom this kernel (watchdog restart) returned to the installed system.Results for this PR (smoke test only):
pm_test=devicessuspend cycle, Wi-Fi stayed connected, a rescan listed 39 networks, and there were 0CTRL-EVENT-SCAN-FAILED/ -16 messages.pm_test=devicesdoes not take the interface down during a running scan, so it does not reproduce the lid-sleep race this fixes. That kernel did not carry the Centauri scan-abort changes either.Earlier, with the Centauri driver on an older base (integration/aurora f5fa539): NetworkManager takes the interface down for a lid-close sleep while a wpa_supplicant scan runs. Without the fix, every scan after the wake failed with
CTRL-EVENT-SCAN-FAILED ret=-16until reboot. With the fix, Wi-Fi reconnected within 2 s after each of two lid sleeps. That run also had the Centauri scan-abort and interface-down handling, which is not upstream and not in this PR.Checks on this base:
net/wireless/scan.obuilds withW=1without warnings.integration/aurora has since moved to
677be395b; this branch still merges into it without conflicts.Notes for reviewers
ndo_stop. The cfg80211 state is still wrong afterwards: one latecfg80211_scan_done()should not wedge the wiphy.