Skip to content

wifi: apple: centauri: keep the station counter length with its record - #2908

Merged
RyanTheTide merged 2 commits into
mainfrom
hardening/centauri-station-stats-20261123
Nov 26, 2026
Merged

RyanTheTide merged 2 commits into
mainfrom
hardening/centauri-station-stats-20261123

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Every reply to the centauri statistics command overwrote stats_length, while station_stats_valid was only set by a station counter record of a supported length, so the two could disagree.

Problem

A later statistics reply carrying another record leaves the counters marked valid with a length that no longer describes them, and the debugfs and connection readers iterate by that length.

Change

  • Keep the accepted counter record's length in its own field, set together with station_stats_valid, and iterate over that.
  • Move the statistics reply handling into a helper so it can be tested, and add a KUnit case (CONFIG_APPLE_CENTAURI_KUNIT_TEST).

No gates; no new parameters.

Testing

  • KUnit apple-centauri-wifi passes (arm64 qemu, LLVM=1); with the fix reverted and the test kept, it fails.
  • arm64 W=1 build of drivers/net/wireless/apple/: no warnings; checkpatch clean apart from the MAINTAINERS note.

Still to run

  • A Mac with the centauri Wi-Fi (J813/J815/J873): join a network and read station_stats in debugfs. We have none in the lab; a row from someone who has one is welcome.
Reviewer detail

Every reply to the statistics command overwrites stats_length, while
station_stats_valid is only set by a station counter record of a
supported length. A later reply carrying another record leaves the
counters marked valid with a length that no longer describes them, and
the debugfs and connection readers then iterate past station_stats.

Record the length of the accepted counter record in its own field, set
together with station_stats_valid, and iterate over that. Move the
statistics reply handling into a helper so that it can be tested,
and add a KUnit case for it (CONFIG_APPLE_CENTAURI_KUNIT_TEST).

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at a789b5c.

Follow-up to the #2894 review, centauri part. This is the same commit that was reviewed there as good (same patch as e0b2c56, rebased), and it stands.

What it fixes: the debugfs and connection readers iterated station_stats (888 bytes) by stats_length, a 16-bit value that every later statistics reply overwrites. That was a real out-of-bounds read of struct centauri_wifi. The accepted record's length now lives in station_stats_len, set together with station_stats_valid (centauri_wifi.c:563-568), cleared with it (:2287-2288), and both readers use it (:1294, :2309). Only 752 and 888 are accepted (:561), and 888 is the array size (:162), so the loops stay inside the array.

Nothing new found. Two small remarks, neither blocking:

  1. The two log lines still print stats_length, the last reply's length, next to valid (:1292, :2307). After this change the record's own length is station_stats_len; printing that would be less confusing.
  2. The Kconfig help of the new test names a board ("the J813 Wi-Fi reply handler", drivers/net/wireless/apple/Kconfig:31). The handler is the chip's, and the T6050 device trees use the driver too; "the Centauri Wi-Fi reply handler" is more accurate.

Rows owed at this head (none run): one Mac with this Wi-Fi (J813/J815, or a T6050 Mac): join a network, read station_stats in debugfs twice with another statistics file read in between. The lab has none, so this needs an outside row.

@DjDeveloperr DjDeveloperr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formal adversarial §1–§6 pre-PR checklist review at a789b5ca16130b8e46998cb4f73311c6cf6270d6 (REQUEST_CHANGES — 0 code blockers; pending CI and owed §5 hardware row).

Checklist Summary

  • §1 (No model gating): Pass — no chip, SoC, board, or firmware-version gates.
  • §2 (Production-ready, no hacks): Pass — no new command-line or module parameters; clean extraction of record_stats_reply().
  • §3 (Safety — bounds, concurrency, memory): Pass — station_stats is u8[888] (0x378). record_stats_reply() (centauri_wifi.c:554-588) only sets station_stats_len (to 752 or 888) together with station_stats_valid = true after checking !status, stats_tag == 0xf928, and size >= 28 + wifi->stats_length (with size <= BUFFER_SIZE already bounded by drain_control()). query_station_stats() clears both fields (centauri_wifi.c:2287-2288), and both readers (connect_worker() :1294, station_stats_show() :2309) run under wifi->lock and iterate up to station_stats_len in 4-byte steps. The other stats decoders (rx_crypto_stats, dot11_mib_stats, tx_power_report) iterate over fixed array sizes. centauri_wifi_test.c exercises the 752-byte record, unrelated TLV with U16_MAX, 888-byte record, and rejected 900-byte record.
  • §4 (Clean-room & attribution): Pass — commit a789b5ca1613 carries human author/committer (Ryan Murray <[email protected]>) and human Signed-off-by: only (zero AI trailers in commits); PR body includes Assisted-by:.
  • §5 (Evidence): Blocked — see Blockers below.
  • §6 (Naming): Pass.

Blockers

  1. §5 (Owed hardware verification row): No on-hardware run has been recorded at a789b5ca1613. Owed: a Centauri Wi-Fi Mac (J813/J815/J873 or T6050) on the default command line joining a network and reading debugfs station_stats (including after another stats debugfs read), plus regression counts (0 SELinux denials, 0 failed units, 0 new kernel errors).
  2. CI pending: 4/7 green (source, host-tests, rust-build, DWC3/ATC modular-no-atc); 3/7 still queued (kunit, DWC3/ATC builtin-no-atc, DWC3/ATC builtin-modular-atc).

Non-blocking Notes

  • connect_worker() (centauri_wifi.c:1292) and station_stats_show() (centauri_wifi.c:2307) still print wifi->stats_length (the last reply's length) beside station_stats_valid rather than wifi->station_stats_len.
  • drivers/net/wireless/apple/Kconfig:31 help text mentions a specific board ("the J813 Wi-Fi reply handler"); since the driver is chip-level and also serves T6050 Macs, "the Centauri Wi-Fi reply handler" is cleaner.

The connection log line printed the last statistics reply's length next
to the station counters, which no longer has to be the counters' own
length. Print the kept counter length there, and add it to the debugfs
station_stats header as counters=, after the reply's own fields. Word
the KUnit option's help for the driver, not one board.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Both notes done at 6c2b438: the connection log line prints station_stats_len, the debugfs header gains counters= (the reply's own length= stays as it was), and the KUnit help text names the Centauri reply handler instead of a board. KUnit apple-centauri-wifi passes; W=1 and checkpatch clean. Still needs a centauri Mac row.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at 6c2b438.

Both remarks from a789b5c are done in the new commit:

  1. Log lines: fixed. The connection line now prints station_stats_len (centauri_wifi.c:1291-1293), and the debugfs header keeps the reply's own length= and adds counters= (:2307-2309), which is clearer than swapping the field. Anything that parses the debugfs header gets one more field at the end; nothing in the tree does.
  2. Kconfig help: fixed, it now names the Centauri reply handler (drivers/net/wireless/apple/Kconfig:31).

Nothing new in the diff: it is two format strings and help text. Commit trailers are fine.

Verdict: APPROVE on code. Rows owed at this head (none run): one Mac with this Wi-Fi (J813/J815, or a T6050 Mac) on the default command line: join a network and read station_stats in debugfs twice with another statistics file read in between. The lab has none, so this needs an outside row. CI is still running (4 pending).

@DjDeveloperr DjDeveloperr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formal adversarial §1–§6 re-review at 6c2b4388b5d82338ffa11105928cf3d4bfa418bb (REQUEST_CHANGES — 0 code blockers; both prior non-blocking notes cleanly resolved at 6c2b4388b5d8, still blocked on owed §5 Centauri hardware row and pending CI).

Update Verification (6c2b4388b5d8)

  • connect_worker() (centauri_wifi.c:1292-1293) now logs wifi->station_stats_len, and station_stats_show() (centauri_wifi.c:2307-2309) preserves the reply's length=%u while appending counters=%u (wifi->station_stats_len).
  • drivers/net/wireless/apple/Kconfig:36-38 help text now names "the Centauri Wi-Fi reply handler" instead of a single board.
  • Core bounds/locking fix from a789b5ca1613 (station_stats_len in {0, 752, 888}, station_stats[0x378], wifi->lock, KUnit test) remains clean.

Checklist Summary

  • §1 (No model gating): Pass.
  • §2 (Production-ready, no hacks): Pass.
  • §3 (Safety): Pass.
  • §4 (Clean-room & attribution): Pass — both commits (a789b5ca1613, 6c2b4388b5d8) carry human author/committer (Ryan Murray <[email protected]>) and human Signed-off-by: only (zero AI trailers in commits); PR body includes Assisted-by:.
  • §5 (Evidence): Blocked — see Remaining Blockers below.
  • §6 (Naming): Pass.

Remaining Blockers

  1. §5 (Owed Centauri hardware verification row): No on-hardware run recorded at 6c2b4388b5d8. Owed: a Centauri Wi-Fi Mac (J813/J815/J873 or T6050) on the default command line joining a network and reading debugfs station_stats twice with another statistics debugfs read in between, plus regression counts (0 SELinux denials, 0 failed units, 0 new kernel errors).
  2. CI pending: 4/7 green (host-tests, source, rust-build, DWC3/ATC builtin-no-atc); 3/7 still IN_PROGRESS/QUEUED (kunit, DWC3/ATC modular-no-atc, DWC3/ATC builtin-modular-atc).

@github-actions github-actions Bot added changes-requested A reviewer requested changes (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at 6c2b4388: ready to merge

Check Detail
CI at head ok 7 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok comment at 6c2b4388
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: none matched in CODEOWNERS
Merge: gh pr merge 2908 --merge (Owners and Core through the bypass: add --admin).

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH, then merge at 6c2b4388b5d8: the code is ready; it needs only a row at this head.

Blockers: none in the code. Missing row: one Centauri Wi-Fi Mac at this head (the J714s, or a J813/J815): join a network and read station_stats twice with another statistics read in between, with sane counters.

Checked: no Apple material, no gates. The station counter length is kept with its record. CI green.

@DjDeveloperr
DjDeveloperr dismissed stale reviews from themself November 25, 2026 04:10

Superseded by the review at 6c2b438

@github-actions github-actions Bot removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 25, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

6c2b438 J616s (T6040, M4 Pro) PASS: guarded one-shot combined batch (1c06fa69cde5 over main 8f99a85, 0 merge-tree diffs on 3 changed files, default cmdline, stock Stage 2 1.0.0b17, boot 1efdeb87-4c6d-44ed-9e5a-929ba5ed4c4f): 0 failed units, Enforcing, 0 new AVC, 0 GPU faults, 0 new kernel errors, eDP-1 connected, 25 thermal zones clean, Borealis VK api.smoke 8/8 pre/post 2/2 rtc1 s2idle, Wi-Fi 3/3 pre/post; stock 7.3.0-aurora-fleet89 restored.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Nov 26, 2026
@RyanTheTide
RyanTheTide merged commit 7fa72aa into main Nov 26, 2026
10 of 11 checks passed
@RyanTheTide
RyanTheTide deleted the hardening/centauri-station-stats-20261123 branch November 27, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-template PR body lacks Tested or Risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants