net: dsa: mt7530: check CORE_PLL_GROUP4 access in mt7531_setup()
Subsystems (71)
Sasha Levin
maintainerPATCH 1/1 docs: block: fix dead http link in blk-mq.rst
In reply to Sasha LevinFrom: Jenson Johnathon Reggentin <[email protected]>
[ Upstream commit b40a680ea4efe4ef2addada63e304a94d19500d1 ]
The current link http://kernel.dk/blk-mq.pdf leads to a 404 error page.
https://www.kernel.dk/blk-mq.pdf leads to the correct document.
v2 to add the missing www. prefix in the actual file change.
Message-ID: <[email protected]>
---
LLM Generated explanations, may be completely bogus:
I have the tree identity, the dead URL in-tree, review history, and a clean apply. Next I’ll finish call-site and stable-rule checks, then give the backport verdict.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
Step 1.1: PARSE THE SUBJECT LINE
Record: [docs: block:] [fix] [dead HTTP link in blk-mq.rst] — documentation URL correction in the block multi-queue overview.
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Jenson Johnathon Reggentin <[email protected]> (author)
- Acked-by: Randy Dunlap <[email protected]> (docs reviewer)
- Signed-off-by: Jonathan Corbet <[email protected]> (docs maintainer, applied it)
- Message-ID: <[email protected]> (v2 submission)
- No Fixes: tag (expected)
- No Reported-by / Tested-by / Reviewed-by on the committed form (v1 had
Reviewed-by: Md Haris Iqbal; that tag was not carried to v2)
- No Cc: stable (expected; not a negative)
- Ignore any pipeline “Upstream commit” / “Signed-off-by: Sasha Levin” markers if present
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: http://kernel.dk/blk-mq.pdf in the “Further reading” section returns 404.
- Symptom: readers of blk-mq documentation cannot open the canonical blk-mq paper.
- Fix: switch to https://www.kernel.dk/blk-mq.pdf.
- v2 note: v1 used https://kernel.dk/blk-mq.pdf (missing www.), which still 404’d / had a bad cert; v2 adds www..
- No kernel version range given; no crash/trace.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a hidden runtime fix. It is exactly what it says: a documentation hyperlink correction. Not a leak/race/UAF disguised as cleanup.
---
## PHASE 2: DIFF ANALYSIS
Step 2.1: INVENTORY THE CHANGES
Record:
- File: Documentation/block/blk-mq.rst — 1 line changed (-1/+1)
- Functions: none
- Scope: single-file, surgical documentation edit
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: RST link target http://kernel.dk/blk-mq.pdf
- After: RST link target https://www.kernel.dk/blk-mq.pdf
- Path affected: documentation “Further reading” only; no execution path
Step 2.3: IDENTIFY THE BUG MECHANISM
Record: Not a memory-safety/locking/refcount bug. Category:
documentation correctness (dead external URL). Mechanism: site now requires HTTPS + www. hostname.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct once v2 uses the working URL.
- Minimal; no unrelated edits.
- Regression risk: none at runtime. Residual risk is only that the remote host could move again (same class of risk as any external link).
- v1 was wrong (Randy Dunlap reported continued 404 / bad SSL); committed v2 addresses that.
Verified live:
- http://kernel.dk/blk-mq.pdf → 404
- https://www.kernel.dk/blk-mq.pdf → PDF retrieved (51.5 KB)
---
## PHASE 3: GIT HISTORY INVESTIGATION
Step 3.1: BLAME THE CHANGED LINES
Record:
- Introduced in 46e906144c3f4b (“docs: block: Create blk-mq documentation”, André Almeida, 2020-06-19)
- First appeared: v5.9-rc1 (git describe --contains → v5.9-rc1~150^2~141)
- Present in this tree for the entire 6.12 lifetime
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. The introducing commit is the original documentation add, not a later regression in C code.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record (this tree, -- Documentation/block/blk-mq.rst):
- 41bd33df4e180 docs: correct places → place
- c19430eec84f7 Fix small typo
- 2bc602cb0e0d9 correct drive → driver
- 8ac867340bd8c / 9303c9d5e9883 Sphinx :c:type cleanup
- 46e906144c3f4b create the file
No later URL rewrite in this checkout. Standalone; not patch X/Y of a functional series.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: git log --author="Jenson Johnathon Reggentin" / [email protected] on this tree: no hits. One-off docs contributor, not the block maintainer. Applied by Jonathan Corbet; Acked-by Randy Dunlap.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: No new helpers, structs, or APIs. The hunk matches the current file byte-for-byte. Can apply standalone.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 mbox [email protected] saved 12-message thread (lore HTTP 403 from WebFetch; b4 succeeded).
- v1: https://kernel.dk/blk-mq.pdf (no www)
- v2 (applied): https://www.kernel.dk/blk-mq.pdf
- Randy Dunlap: v1 still 404 + invalid SSL; confirmed www. works; Acked-by on v2; asked changelog-after---- nit
- Haris Iqbal: Reviewed-by on v1; spotted missing www.
- Jonathan Corbet: asked for a version that actually works; applied v2 (“Applied, thanks.”)
- No NAK. No reviewer asked for Cc: stable.
- Included in Corbet’s [GIT PULL] Documentation stragglers for 7.3 (docs-7.3-2), described as late-arriving docs fixes, not a stable- critical runtime fix.
- Syzbot CI skipped both versions: “AI determined the patch has no functional impact”
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (syzbot CI Cc + thread):
- To/Cc: Jens Axboe, Jonathan Corbet, linux-block, linux-doc
- Reviewers who spoke: Randy Dunlap (ack), Md Haris Iqbal (v1 r-b), Jonathan Corbet (applied)
- Block maintainer was copied; no Axboe reply in the 12-message thread
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No bugzilla/syzbot crash. Author observed a 404. Confirmed independently in this analysis.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone. v1→v2 only to correct the hostname. No sibling functional patches required.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable WebFetch returned 403. UNVERIFIED that stable@ discussed this specific URL. No evidence in the docs thread of a stable nomination or of a reason to exclude it.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
Step 5.1: KEY FUNCTIONS
Record: None. Only an RST hyperlink.
Step 5.2: TRACE CALLERS
Record: N/A — not callable kernel code. Consumers are humans (and Sphinx HTML on kernel.org / distro doc packages).
Step 5.3: TRACE CALLEES
Record: N/A.
Step 5.4: FOLLOW THE CALL CHAIN
Record: Not reachable from syscalls. User impact is documentation-only. kernel.org v6.12 HTML is built from this tree, so the 404 is user- visible for people reading 6.12 docs.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: kernel.dk/blk-mq appears only in Documentation/block/blk- mq.rst in this tree. Other kernel.dk hits are emails/copyrights, not this PDF.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record:
- git describe HEAD → p-6.12-3-gc504cf0baa3d8
- make kernelversion / Makefile → **6.12.111**, branch pending-6.12
- Line 142 of Documentation/block/blk-mq.rst still has http://kernel.dk/blk-mq.pdf
- git merge-base --is-ancestor 46e906144c3f4b HEAD → yes
- Bug introduced v5.9-rc1 (2020); present here
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Surrounding hunk is identical to the patch context. Expected
apply: **clean**. git log v6.12..HEAD -- Documentation/block/blk- mq.rst is empty (no conflicting stable edits).
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: Replacement URL not present. No alternate rewrite of this link. Comparable docs-link backports **do** exist after v6.12 in this tree, e.g.:
- b23111ec50d86 docs: hwmon: fix link to g762 devicetree binding
- a7f28636da6f9 docs: media: update location of the media patches (explicit Cc: stable)
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
Step 7.1: SUBSYSTEM AND CRITICALITY
Record:
- Subsystem: Documentation for the block layer (Documentation/block/,
MAINTAINERS: BLOCK LAYER, Jens Axboe; docs tree via Corbet)
- Criticality of **blk-mq itself**: IMPORTANT (common block I/O)
- Criticality of **this change**: documentation-only, not the I/O path
Step 7.2: SUBSYSTEM ACTIVITY
Record: Documentation/block/ is mature; this file’s last change in- tree is a 2023 typo fix. The URL has been wrong/stale for years; the site layout change is what made http://kernel.dk/... a hard 404.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
Step 8.1: WHO IS AFFECTED
Record: Anyone reading in-tree or generated blk-mq docs (developers, distro doc packages, kernel.org HTML for 6.12). Not a runtime/driver/config population.
Step 8.2: TRIGGER CONDITIONS
Record: Opening the “Further reading” PDF link. Common for people studying blk-mq; never triggered by unprivileged syscalls. Not a race.
Step 8.3: FAILURE MODE SEVERITY
Record:
- Failure: HTTP 404 / cannot open the referenced paper
- Severity: **LOW** (incorrect documentation, no crash/corruption/hang)
- No kernel oops, leak, or security effect
Step 8.4: RISK-BENEFIT RATIO
Record:
- Benefit: working further-reading link in 6.12 docs; small but real for doc users
- Risk: **very low** (one RST URL; no code, locks, APIs)
- Ratio: favorable *if* documentation corrections are in scope; not a stability win
---
## PHASE 9: FINAL SYNTHESIS
Step 9.1: COMPILE THE EVIDENCE
FOR backporting:
- Dead link is real (404 verified); replacement URL works
- One-line, obviously correct v2 after review
- Docs maintainer applied it; Randy Dunlap Acked-by
- Buggy line exists in this 6.12.111 tree since v5.9; applies cleanly
- User-facing exception: documentation/comment fixes with zero runtime regression
- This same 6.12 tree already took other documentation link-location fixes
AGAINST backporting:
- Not a crash, deadlock, corruption, UAF, or security bug
- Official rule 3 (“important issue”) is not met in the runtime sense
- No functional kernel impact (syzbot CI skipped it for that reason)
- No Cc: stable; landed as docs-7.3 stragglers, not a hotfix
- Stable rules also discourage purely trivial edits; this is adjacent to that class
- Benefit is only to documentation readers, not production uptime
UNRESOLVED:
- Could not fetch lore.kernel.org or lore stable search via WebFetch (403); thread recovered via b4
- Commit SHA is not in this checkout’s master (that tip is ~7.2; patch went in docs-7.3-2)
Step 9.2: STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — v2 URL verified; Acked-by + maintainer apply
2. Fixes a real bug that affects users? **PASS** — 404 in shipped/generated docs, not a runtime bug
3. Important issue (crash, security, corruption, deadlock)? **FAIL** as runtime severity; **LOW** doc defect only
4. Small and contained? **PASS** — 1 line, one file
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — context identical, URL still old
Step 9.3: EXCEPTION CATEGORIES
Record: **Documentation fix** (incorrect/obsolete external link). That exception is why a LOW-severity, zero-runtime patch can still be appropriate for this tree.
Step 9.4: DECISION
The change does not stabilize running 6.12 systems, but it is a contained, verified correction of documentation this tree still ships, with no regression surface and with precedent for similar doc-link backports here. That matches the documentation exception, not a “new feature” or refactor.
What it solves for stable users: kernel.org / distro HTML for 6.12 currently points “Further reading” at a 404; after backport it points at Jens Axboe’s actual blk-mq PDF.
Risk vs benefit: negligible risk, modest doc benefit. No dependencies or backport rework.
---
## Verification
- [Phase 1] Tags: author SOB, Randy Dunlap Acked-by, Jonathan Corbet SOB, Message-ID v2; no Fixes/Reported-by/Cc-stable
- [Phase 2] Diff: single RST URL http://kernel.dk/blk-mq.pdf → https://www.kernel.dk/blk-mq.pdf
- [Phase 2] WebFetch: old URL 404; new URL returns the PDF
- [Phase 3] git blame line 142: 46e906144c3f4b (2020); git describe --contains → v5.9-rc1
- [Phase 3] git merge-base --is-ancestor 46e906144c3f4b HEAD succeeded
- [Phase 3] Author has no other commits in this tree; file history is typo/Sphinx-only
- [Phase 4] b4 mbox: 12-message v1/v2 thread; Randy caught v1 404/SSL; Corbet applied v2
- [Phase 4] LKML pull: included in Documentation stragglers for 7.3
- [Phase 4] Syzbot CI: skipped, no functional impact
- [Phase 4] UNVERIFIED: lore.kernel.org/stable search (HTTP 403)
- [Phase 5] No functions/callers; only docs consumers
- [Phase 6] git describe HEAD = p-6.12-3-gc504cf0baa3d8; kernelversion 6.12.111; dead URL still at blk-mq.rst:142
- [Phase 6] Apply would be clean; no post-v6.12 edits to this file
- [Phase 6] Precedent: docs: hwmon: fix link to g762... and `docs:
media: update location...` already in this 6.12 tree
- [Phase 8] Failure mode: documentation 404, severity LOW; runtime risk none
**YES**
Documentation/block/blk-mq.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/block/blk-mq.rst +1 -1
@@ -139,7 +139,7 @@ completed. Further reading --------------- -- `Linux Block IO: Introducing Multi-queue SSD Access on Multi-core Systems <http://kernel.dk/blk-mq.pdf>`_ +- `Linux Block IO: Introducing Multi-queue SSD Access on Multi-core Systems <https://www.kernel.dk/blk-mq.pdf>`_ - `NOOP scheduler <https://en.wikipedia.org/wiki/Noop_scheduler>`_
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 pNFS: honor clora_changed when recalling a layout
In reply to Sasha LevinFrom: Benjamin Coddington <[email protected]>
[ Upstream commit aceaa5991bdf744e9c3fa1e5ad73405b1801eaab ]
When the metadata server recalls a layout with clora_changed FALSE, the layout is not changing and the client may complete its modified writes to the storage devices before returning the layout (RFC 8881, Section 20.3.3). Only when clora_changed is TRUE -- the server is restriping, or a storage device has failed -- should the client stop writing to the storage devices and redirect through the metadata server.
Since commit b739a5bd9d9f ("NFSv4/flexfiles: Cancel I/O if the layout is recalled or revoked") the client cancels in-flight I/O on every recall, regardless of clora_changed. For an unchanged recall this abandons writes whose data may already have reached the storage device; such a write can then land after the LAYOUTRETURN, which the server sees as a write without a layout.
Pass the recall's clora_changed value through pnfs_mark_matching_lsegs_return() and only cancel in-flight I/O when the layout is actually changing. When it is not, the existing deferred return path waits for the in-flight writes to drain before sending the LAYOUTRETURN. Other callers, which are tearing down or returning the layout for their own reasons, continue to cancel as before.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). The buggy cancel-on- every-recall path is present here; the fix is not. It is a small protocol/data-integrity correction and applies cleanly.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[pNFS] [honor] honor clora_changed when recalling a layout**
Subsystem: NFS pNFS client. Verb “honor” is a correctness/protocol fix, not a feature add.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Signed-off-by:** Benjamin Coddington <[email protected]> (author; Hammerspace)
- **Signed-off-by:** Trond Myklebust <[email protected]> (NFS client maintainer)
- **No Fixes:** (expected; body names b739a5bd9d9f)
- **No Cc: stable** (expected)
- **No Reported-by / Tested-by / Reviewed-by / Link / Acked-by**
Mainline SHA (verified on origin/master):aceaa5991bdf744e9c3fa1e5ad73405b1801eaab
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** Since b739a5bd9d9f, CB_LAYOUTRECALL always cancels in- flight DS I/O, including when clora_changed is FALSE.
- **RFC 8881 §20.3.3:** FALSE means the layout is not changing; the client may finish modified writes to storage before LAYOUTRETURN. TRUE means restriping/device failure; cancel and go through the MDS.
- **Failure mode:** Cancelled writes may already have reached the DS, then complete after LAYOUTRETURN → server sees a write with no layout.
- **Fix:** Pass clora_changed into pnfs_mark_matching_lsegs_return(); cancel only when the layout is changing. Unchanged recalls use the existing drain-then-return path. Other callers still cancel.
- **Version info:** Bug since the 2022 cancel-I/O commit (v6.1-rc1).
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not a disguised cleanup.** It is an explicit protocol/correctness fix. The extra bool cancel_io on other call sites preserves existing teardown behavior.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- fs/nfs/callback_proc.c: +2 / −1 (initiate_file_draining)
- fs/nfs/pnfs.c: +13 / −9 (declaration, all callers, cancel gate)
- fs/nfs/pnfs.h: +1 / −1 (prototype)
- **Net: +16 / −11**, three files. Surgical, single-subsystem.
Functions: initiate_file_draining, nfs4_layout_refresh_old_stateid, pnfs_mark_layout_stateid_return, pnfs_layout_io_set_failed, _pnfs_return_layout, pnfs_layout_process, pnfs_mark_matching_lsegs_return, pnfs_mark_layout_for_return, pnfs_layout_return_unused_byserver.
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Recall path (initiate_file_draining):** passes args->cbl_layoutchanged instead of always cancelling.
- **pnfs_mark_matching_lsegs_return:** pnfs_lseg_cancel_io() only if cancel_io.
- **All other callers:** pass true → same as today.
- **Unchanged recall with I/O in flight:** still marks lsegs for return, returns -EBUSY, callback still NFS4_OK; deferred return waits for refs to drop (existing pnfs_put_lseg / LAYOUTRETURN path). nfs_commit_inode() after unlock is unchanged.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Logic / protocol correctness]** Unconditional I/O cancel on every recall. That races completed-on-wire writes vs LAYOUTRETURN. The fix restores RFC drain-before-return when clora_changed is false.
Not a leak, UAF, lock, or new API.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: **Obviously correct and minimal.** Only the CB_LAYOUTRECALL file path changes behavior. cbl_layoutchanged is already decoded (callback_xdr.c). Risk: unchanged recalls return the layout more slowly if DS I/O is stuck (RFC-intended; server may recall again). Tear- down still cancels. pnfs_mark_matching_lsegs_invalid() still always cancels (revoke). No public API change.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record: Unconditional pnfs_lseg_cancel_io() at fs/nfs/pnfs.c:2678 is from **b739a5bd9d9f** (“NFSv4/flexfiles: Cancel I/O if the layout is recalled or revoked”), 2022-10-05. git describe --contains:
**v6.1-rc1**. Present for the whole 6.12 lifetime.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Named commit **b739a5bd9d9f is an ancestor of HEAD** (git merge-base --is-ancestor exit 0). That commit added cancel in both pnfs_mark_matching_lsegs_return and pnfs_mark_matching_lsegs_invalid; this patch only gates the return path.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent 6.12 pNFS work (layout segment leak, EBUSY check, DRAIN wakeups) does not replace this fix. On origin/master this is **v2 2/3** of “pNFS/flexfiles: honor clora_changed and report cancelled I/O”:
- 1/3 ba0f097418c7d — tracepoint only; **not required**
- 2/3 **this commit**
- 3/3 4a013b0e881e0 — report cancelled I/O as LAYOUTERROR; **not required** for this behavior
Standalone for the recall-cancel bug.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Benjamin Coddington is a regular NFS/pNFS contributor (Hammerspace). Trond applied it. Anna’s v1 comments (kerneldoc, FILE_INODE) were addressed in v2.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs existing cbl_layoutchanged, pnfs_lseg_cancel_io(), and cancel_io on flexfiles — all in this tree. No new helpers. **Applies standalone.**
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- Lore/msgid: https://patch.msgid.link/05e93230d2f58d9d8b23b083d8d89b21c
[email protected]
- **v1 → v2**; applied version is v2.
- Cover: client has decoded cbl_layoutchanged but ignored it since b739a5bd9d9f; cancel can leave a DS write incomplete with no write layout.
- Saved mbox: cover + 1/3 + 2/3 + 3/3 only; **no NAK, no extra review mail in that match**.
- Trond’s nfs-for-7.3-1 pull listed it as *“Avoid cancelling in-flight I/O during a layout recall if the server doesn't require it”* under **Other bugfixes** (not the Cc:stable subset). That is tagging, not a NAK.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc Trond Myklebust, Anna Schumaker, linux- [email protected]. Maintainer SOB on the commit.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla. Vendor/protocol analysis (Hammerspace), not a crash repro.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 1/3 observability, 3/3 error reporting when cancel still happens. Neither is a functional prerequisite. Follow-ups on pnfs.c after this SHA (2035820177749 EBUSY, ee5a386cfe60f lseg leak) are independent.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** — lore.kernel.org/stable/?q=clora_changed returned 403. No evidence this was rejected for stable.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
Record: listed in 2.1. Behavioral change is **pnfs_mark_matching_lsegs_return + initiate_file_draining**.
**Step 5.2: TRACE CALLERS**
Record:
- File recall: nfs4_callback_layoutrecall → do_callback_layoutrecall → initiate_file_draining (MDS CB_LAYOUTRECALL, RETURN_FILE).
- Only flexfiles implements cancel_io (ff_layout_cancel_io → rpc_cancel_tasks / rpc_clnt_disconnect). Other layout types: no-op today.
- Remaining callers keep cancel_io=true (return/teardown/failure/new stateid).
**Step 5.3: TRACE CALLEES**
Record: pnfs_match_lseg_recall, mark_lseg_invalid, pnfs_lseg_cancel_io → layout-driver cancel_io. Flexfiles cancels matching RPCs with -EAGAIN and disconnects the DS client.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable in production: MDS sends CB_LAYOUTRECALL while the client has DS writes in flight. Common for pNFS flexfiles (layout recall on close, space management, etc.). Not a rare debug path. Unprivileged write traffic plus server recall.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Second cancel site in pnfs_mark_matching_lsegs_invalid() is left unconditional (correct for invalidate/revoke). cbl_layoutchanged is stored but otherwise unused in this tree — this patch is the first user for I/O policy.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** pending-6.12 / **6.12.111**. pnfs_lseg_cancel_io() is unconditional in pnfs_mark_matching_lsegs_return(). cbl_layoutchanged is decoded. git merge-base --is-ancestor aceaa5991bdf7 HEAD → **not an ancestor**. Bug since **v6.1-rc1**.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: git show aceaa5991bdf7 | git apply --check **succeeded** (hunk offsets only). **Clean apply.** All current callers are updated by the patch.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No honor clora_changed commit. No alternate fix. 6.12 already has later unrelated pNFS fixes (2ef79f5aa107a EBUSY, 7c5b0e813efd9 lseg leak).
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: **fs/nfs pNFS client**. **IMPORTANT** for NFSv4.1 pNFS (especially flexfiles). PNFS_FLEXFILE_LAYOUT **defaults to NFS_V4**. Not core mm/VFS, but production clustered NFS.
**Step 7.2: SUBSYSTEM ACTIVITY**
Record: Actively maintained; this is a targeted fix in mature recall code, not churn in new code.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Record: **Config/driver-specific:** NFSv4.1 pNFS flexfiles clients under CB_LAYOUTRECALL with in-flight DS writes. Enterprise/scale-out NFS (e.g. Hammerspace). Filesystems/block/files layouts without cancel_io are unchanged.
**Step 8.2: TRIGGER CONDITIONS**
Record: Server file layout recall with clora_changed=FALSE while DS writes are in flight. Common operational recall, not only device failure. Userspace writes plus MDS callback; timing-dependent.
**Step 8.3: FAILURE MODE SEVERITY**
Record: **Write-after-LAYOUTRETURN / write with no layout** → protocol violation, possible rejected/unaccounted DS write, MDS/DS inconsistency. Cover letter: incomplete DS write with no write layout. **Severity:
HIGH** (data integrity), not a panic.
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit: high** for pNFS flexfiles — stops abandoning in-flight writes on unchanged recalls.
- **Risk: low** — ~16 lines, one gated call, other paths unchanged, RFC- aligned, maintainer-acked, applies cleanly.
- **Ratio: favorable.**
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real protocol/data-integrity bug in this 6.12 tree
- Introduced v6.1, still present
- Small, obviously correct, RFC 8881 §20.3.3
- Maintainer SOB; described as a bugfix in nfs-for-7.3-1
- Clean apply; no prerequisites
- Flexfiles enabled by default with NFS v4
**AGAINST:**
- No crash/syzbot; pNFS-specific
- Series 2/3 (siblings not required)
- Not in the pull’s “Stable fixes” list (no Cc: stable)
- Unchanged recalls return the layout more slowly if DS I/O is stuck (intended)
**UNRESOLVED:** Stable-list archives (HTTP 403); no public review replies beyond v1→v2.
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — RFC behavior, maintainer SOB, mainline
2. Real bug affecting users? **PASS** — writes after LAYOUTRETURN on flexfiles
3. Important (crash/security/corruption/deadlock)? **PASS** — data/protocol integrity (HIGH)
4. Small and contained? **PASS** — +16/−11, three NFS files
5. No new features/APIs? **PASS** — uses existing decoded flag
6. Can apply to this tree? **PASS** — git apply --check clean
**Step 9.3: EXCEPTION CATEGORIES**
Record: None (not a device ID/quirk/DT/build/doc-only patch). Qualifies as a normal important bugfix.
**Step 9.4: DECISION**
Backport to this 6.12 tree. The cancel-always path is here; the fix is small and restores RFC drain-before-return for unchanged recalls, which otherwise can complete DS writes after LAYOUTRETURN.
---
### What the commit solves for 6.12 users
On pNFS flexfiles, every layout recall currently cancels in-flight DS I/O (ff_layout_cancel_io). For clora_changed=FALSE that is wrong:
those writes may already be on the DS and then finish after LAYOUTRETURN, which the server treats as I/O without a layout. The patch only stops cancelling in that recall case and lets the existing deferred LAYOUTRETURN wait for I/O to drain.
### Risk vs benefit
Benefit is data/protocol correctness for a default NFSv4.1 layout type. Risk is low: teardown still cancels; only the already-decoded recall flag changes the file-recall path; the patch applies without rework.
---
### Verification
- **[Phase 1]** Parsed tags: two SOBs (Coddington, Myklebust); no Fixes/Cc:stable; mainline aceaa5991bdf7
- **[Phase 2]** Diff: 16 insertions / 11 deletions; cancel gated; recall passes cbl_layoutchanged; other callers pass true
- **[Phase 3]** Blame: cancel line from b739a5bd9d9f (v6.1-rc1); ancestor of HEAD
- **[Phase 3]** git merge-base --is-ancestor aceaa5991bdf7 HEAD → not in this tree
- **[Phase 4]** b4 dig -c aceaa5991bdf7: v2 2/3, msgid above; v1→v2 (Anna: kerneldoc/FILE_INODE)
- **[Phase 4]** b4 dig -w: Trond, Anna, linux-nfs
- **[Phase 4]** b4 dig -m: series only, no NAK
- **[Phase 4]** Trond pull nfs-for-7.3-1 lists this under Other bugfixes
- **[Phase 5]** Call chain: CB_LAYOUTRECALL → initiate_file_draining; cancel only implemented in flexfiles
- **[Phase 5]** cbl_layoutchanged decoded in callback_xdr.c, unused for I/O policy in this tree
- **[Phase 6]** git describe HEAD: p-6.12-3-gc504cf0baa3d8; make kernelversion: 6.12.111
- **[Phase 6]** git apply --check of aceaa5991bdf7: success
- **[Phase 6]** 1/3 and 3/3 not required
- **[Phase 7]** PNFS_FLEXFILE_LAYOUT default NFS_V4
- **[Phase 8]** Failure: write without layout / incomplete DS write; HIGH integrity, not panic
- **UNVERIFIED:** lore.kernel.org/stable search (403)
**YES**
fs/nfs/callback_proc.c | 3 ++- fs/nfs/pnfs.c | 22 +++++++++++++--------- fs/nfs/pnfs.h | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-)
fs/nfs/callback_proc.c +2 -1
@@ -288,7 +288,8 @@ static u32 initiate_file_draining(struct nfs_client *clp,pnfs_set_layout_stateid (lo, &args->cbl_stateid,NULL , true);switch (pnfs_mark_matching_lsegs_return (lo, &free_me_list, &args->cbl_range, -be32_to_cpu (args->cbl_stateid.seqid))) { +be32_to_cpu (args->cbl_stateid.seqid), + args->cbl_layoutchanged)) {case 0 :case -EBUSY :/* There are layout segments that need to be returned */
fs/nfs/pnfs.c +13 -9
@@ -432,7 +432,8 @@ bool nfs4_layout_refresh_old_stateid(nfs4_stateid *dst, goto out; }/* Try to update the seqid to the most recent */ - err =pnfs_mark_matching_lsegs_return (lo, &head, &range,0 ); + err =pnfs_mark_matching_lsegs_return (lo, &head, &range,0 , + true);if (err != -EBUSY ) { dst->seqid = lo->plh_stateid.seqid; *dst_range = range;
@@ -486,7 +487,7 @@ static int pnfs_mark_layout_stateid_return(struct pnfs_layout_hdr *lo, .length = NFS4_MAX_UINT64, }; -return pnfs_mark_matching_lsegs_return (lo, lseg_list, &range, seq); +return pnfs_mark_matching_lsegs_return (lo, lseg_list, &range, seq, true); } static int
@@ -524,7 +525,7 @@ pnfs_layout_io_set_failed(struct pnfs_layout_hdr *lo, u32 iomode)spin_lock (&inode->i_lock);pnfs_layout_set_fail_bit (lo,pnfs_iomode_to_fail_bit (iomode)); -pnfs_mark_matching_lsegs_return (lo, &head, &range,0 ); +pnfs_mark_matching_lsegs_return (lo, &head, &range,0 , true);spin_unlock (&inode->i_lock);pnfs_free_lseg_list (&head); dprintk("%s Setting layout IOMODE_%s fail bit\n", __func__,
@@ -1461,7 +1462,7 @@ _pnfs_return_layout(struct inode *ino) } valid_layout =pnfs_layout_is_valid (lo);pnfs_clear_layoutcommit (ino, &tmp_list); -pnfs_mark_matching_lsegs_return (lo, &tmp_list, &range,0 ); +pnfs_mark_matching_lsegs_return (lo, &tmp_list, &range,0 , true);/* Don't send a LAYOUTRETURN if list was initially empty */
@@ -2603,7 +2604,7 @@ pnfs_layout_process(struct nfs4_layoutget *lgp) .iomode = IOMODE_ANY, .length = NFS4_MAX_UINT64, }; -pnfs_mark_matching_lsegs_return (lo, &free_me, &range,0 ); +pnfs_mark_matching_lsegs_return (lo, &free_me, &range,0 , true); goto out_forget; }else {/* We have a completely new layout */
@@ -2635,6 +2636,7 @@ pnfs_layout_process(struct nfs4_layoutget *lgp)* @tmp_list: list header to be used with pnfs_free_lseg_list() * @return_range: describe layout segment ranges to be returned * @seq: stateid seqid to match +* @cancel_io: signal io be cancelled * * This function is mainly intended for use by layoutrecall. It attempts * to free the layout segment immediately, or else to mark it for return
@@ -2649,7 +2651,7 @@ int pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo, struct list_head *tmp_list, const struct pnfs_layout_range *return_range, - u32 seq) + u32 seq, bool cancel_io) { struct pnfs_layout_segment *lseg, *next;struct nfs_server *server =NFS_SERVER (lo->plh_inode);
@@ -2675,7 +2677,8 @@ pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo,continue ; remaining++;set_bit (NFS_LSEG_LAYOUTRETURN , &lseg->pls_flags); -pnfs_lseg_cancel_io (server, lseg); +if (cancel_io) +pnfs_lseg_cancel_io (server, lseg); }if (remaining) {
@@ -2710,7 +2713,8 @@ pnfs_mark_layout_for_return(struct inode *inode,* segments at hand when sending layoutreturn. See pnfs_put_lseg() * for how it works. */ -if (pnfs_mark_matching_lsegs_return (lo, &lo->plh_return_segs, range,0 ) != -EBUSY ) { +if (pnfs_mark_matching_lsegs_return (lo, &lo->plh_return_segs, range,0 , + true) != -EBUSY ) {const struct cred *cred;nfs4_stateid stateid;enum pnfs_iomode iomode;
@@ -2825,7 +2829,7 @@ static int pnfs_layout_return_unused_byserver(struct nfs_server *server,pnfs_get_layout_hdr (lo);pnfs_set_plh_return_info (lo, range->iomode,0 );if (pnfs_mark_matching_lsegs_return (lo, &lo->plh_return_segs, - range,0 ) !=0 || + range,0 , true) !=0 || !pnfs_prepare_layoutreturn (lo, &stateid, &cred, &iomode)) {spin_unlock (&inode->i_lock);rcu_read_unlock ();
fs/nfs/pnfs.h +1 -1
@@ -301,7 +301,7 @@ int pnfs_mark_matching_lsegs_invalid(struct pnfs_layout_hdr *lo,int pnfs_mark_matching_lsegs_return (struct pnfs_layout_hdr *lo,struct list_head *tmp_list,const struct pnfs_layout_range *recall_range, -u32 seq); +u32 seq,bool cancel_io);int pnfs_mark_layout_stateid_invalid (struct pnfs_layout_hdr *lo,struct list_head *lseg_list); bool pnfs_roc(struct inode *ino, struct nfs4_layoutreturn_args *args,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 gpu: host1x: Wait for timeout worker completion on channel free
In reply to Sasha LevinFrom: Mikko Perttunen <[email protected]>
[ Upstream commit 7a39b9856acccc8e9b05845ca2bf62494fcd3dfa ]
cdma_timeout_destroy() used cancel_delayed_work() to cancel pending timeout work when destroying the CDMA. Usually this is fine, but there is a narrow race condition where the timeout handler has started execution but has not taken cdma->lock; the channel is freed causing cdma_stop to take cdma->lock and flush the channel; host1x_cdma_deinit then proceeds with deinitializing cdma while the handler is waiting to take cdma->lock.
Therefore change cdma_timeout_destroy to use cancel_delayed_work_sync instead to ensure any pending timeout work completes before proceeding.
---
LLM Generated explanations, may be completely bogus:
The local tree is **v7.3-rc4** (7.3.0-rc4). The host1x CDMA timeout path is present, and this is a one-line cancel_delayed_work → cancel_delayed_work_sync race/UAF fix that is standalone and meets stable criteria.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[gpu/host1x] [Wait / ensure completion] [Wait for timeout worker completion on channel free]**
Subsystem prefix gpu: host1x:. The verb is “Wait … on channel free”, i.e. synchronize teardown with a running work item. That is a teardown- race fix, not a feature.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected for this review path)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** none on the commit itself
- **Acked-by:** none
- **Link:** https://patch.msgid.link/20260609-b4-host1x-small-fixes- [email protected]
- **Cc: stable:** none (expected)
- **Signed-off-by:** Mikko Perttunen <[email protected]> (author); Thierry Reding <[email protected]> (Tegra/host1x maintainer). Ignored any Sasha Levin SOB (none on this commit).
- Series marker in the msgid: **patch 1/6** of host1x-small-fixes-a.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** cdma_timeout_destroy() used cancel_delayed_work(), which does not wait if the timeout work is already running.
- **Mechanism:** timeout handler has started but has not yet taken cdma->lock; channel free runs cdma_stop (takes the lock, flushes), then host1x_cdma_deinit() tears CDMA down while the handler is still waiting for that lock.
- **Symptom/failure mode:** use-after-free / use of a destroyed mutex and CDMA state from the timeout worker. That is a kernel crash / memory-safety bug, not a cosmetic issue.
- **Version info:** none in the message. The call has existed since host1x channel support.
- **Author’s root cause:** async cancel vs running work vs lock/deinit order.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. It is an explicit race/UAF fix. Cover letter (see Phase 4) calls patches 1–4 “logic issues that are unlikely to happen but technically possible.” Unlikely trigger does not make a UAF inapplicable to stable.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/gpu/host1x/hw/cdma_hw.c — **1 insertion, 1 deletion**
- Function: cdma_timeout_destroy()
- Scope: **single-file surgical fix** (one call-site change)
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** if cdma->timeout.initialized, cancel_delayed_work(&cdma->timeout.wq) then initialized = false. Pending work is cancelled; **running** work is not waited for.
- **After:** cancel_delayed_work_sync() — cancel pending work **and wait** if the handler is executing.
- **Path:** channel teardown / CDMA destroy, not the submit hot path.
Verified teardown order in this tree:
```102:113:drivers/gpu/host1x/channel.c
static void release_channel(struct kref *kref)
{
...
host1x_hw_cdma_stop(host, &channel->cdma);
host1x_cdma_deinit(&channel->cdma);
clear_bit(channel->id, chlist->allocated_channels);
}
``````528:541:drivers/gpu/host1x/cdma.c
int host1x_cdma_deinit(struct host1x_cdma *cdma)
{
...
host1x_pushbuffer_destroy(pb);
host1x_hw_cdma_timeout_destroy(host1x, cdma);
return 0;
}
```cdma_stop() takes cdma->lock, may wait for an empty sync queue, then unlocks. host1x_cdma_deinit() then runs **without** cdma->lock. That matches the commit’s race: stop can finish and deinit can proceed while cdma_timeout_handler() is between start and mutex_lock(&cdma->lock).
The window is larger than “a few instructions.” The handler dumps debug state **before** taking the lock:
```291:305:drivers/gpu/host1x/hw/cdma_hw.c
static void cdma_timeout_handler(struct work_struct *work)
{
...
host1x_debug_dump(cdma_to_host1x(cdma));
mutex_lock(&cdma->lock);
```host1x_debug_dump() walks every channel and dumps FIFOs (show_all(..., true)). A GPU timeout is also when userspace/driver often closes the channel. That is a realistic overlap, not only a one- instruction race.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** race + use-after-free / use of destroyed CDMA (mutex, push buffer, channel).
- **Mechanism:** non-synchronous delayed-work cancel on destroy. Fix is the standard cancel_*_sync teardown pattern.
- **Not** a leak, NULL check, or new API.
Related code that correctly stays **non-sync** (would deadlock if changed, because it runs under cdma->lock, which the handler also takes):
```293:297:drivers/gpu/host1x/cdma.c
static void stop_cdma_timer_locked(struct host1x_cdma *cdma)
{
cancel_delayed_work(&cdma->timeout.wq);
cdma->timeout.client = NULL;
}
```**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Quality:** obviously correct for the stated race. cancel_delayed_work_sync() is the documented way to wait for delayed work before freeing the object that work touches.
- **Minimal:** one identifier change.
- **Regression risk:**
- _sync can sleep. Callers of host1x_channel_put() → release_channel() are process-context (DRM ioctls/file close, client exit/unbind, debugfs). Sleeping is valid there.
- _sync is **not** called while holding cdma->lock (cdma_stop drops it first). No lock-vs-work deadlock on the free path described in the commit.
- Residual risk: if the timeout handler’s host1x_debug_dump() → host1x_channel_put() dropped the **last** channel ref, release_channel() would run on the same work and _sync could wait on itself. That path was already unsafe with async cancel (UAF after dump returns). No mailing-list NAK of this patch; maintainer applied it.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Buggy cancel_delayed_work() in cdma_timeout_destroy() comes from **6579324a41cc41** (“gpu: host1x: Add channel support”, Terje Bergstrom, 2013-03-22).
- First contained in **v3.10-rc1**. This is old, long-lived driver code, not a last-month addition.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The introducing commit is identified by blame, not by the message. git merge-base --is-ancestor 6579324a41cc41 HEAD succeeds — the introducing commit is in this checkout.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES** Record (recent drivers/gpu/host1x/hw/cdma_hw.c):
- 7a39b9856accc — this fix
- 60bca008dd789 — Tegra264 support (does not revert the _sync change; current file still has cancel_delayed_work_sync)
No prerequisite refactor. Standalone.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Mikko Perttunen is a regular NVIDIA host1x contributor (UAF, refcount, iommu, MLOCK, etc.). Same-series follow-ups are independent (double device_add, trace offset, debug stack over-read, pin_job return type, syncpoint wrap annotation). This patch does not depend on them.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. It only needs cdma_timeout_destroy() + cancel_delayed_work() / _sync, present since 2013. **Can apply standalone.**
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 7a39b9856accc matched **v1 only** (no v2/v3).
- Lore: https://patch.msgid.link/20260609-b4-host1x-small-fixes-
[email protected]
- Cover letter: https://patch.msgid.link/20260609-b4-host1x-small-fixes-
[email protected] — “Miscellaneous fixes”; patches 1–4 “unlikely to happen but technically possible.”
- Thierry Reding, 2026-07-16: **“Applied to drm-misc-next, thanks.”** No NAK, no stable discussion, no request for a different approach.
- sashiko-bot replied with **pre-existing** issues (update_work not cancelled in deinit; non-sync cancel in stop_cdma_timer_locked()). It did **not** reject this change. Those are separate bugs, not regressions of this one-liner.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc included Thierry Reding, David Airlie, Simona Vetter, dri-devel, linux-tegra, linux-kernel. Subsystem maintainer applied the series. No extra Reviewed-by on the commit.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot, bugzilla, or user crash report. Author-found race from code inspection. Severity still UAF if it hits.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Series is 6 independent small fixes. This is patch 1/6 and does not need 2–6.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: WebFetch to lore.kernel.org/stable/ returned 403. **UNVERIFIED** whether stable@ already discussed this specific commit. No Cc: stable on the patch.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: KEY FUNCTIONS**
Record: cdma_timeout_destroy (changed). Related:cdma_timeout_handler, cdma_timeout_init, host1x_cdma_deinit, release_channel, cdma_stop.
**Step 5.2: TRACE CALLERS**
Record:
- cdma_timeout_destroy via host1x_cdma_ops.timeout_destroy → host1x_hw_cdma_timeout_destroy() → **host1x_cdma_deinit()** only.
- host1x_cdma_deinit() from **release_channel()** (last host1x_channel_put()).
- host1x_channel_put() call sites (all process context):
- drivers/gpu/drm/tegra/uapi.c — channel close / ioctl error
- drm/tegra gr2d/gr3d/vic/nvdec — client exit / context close
- drivers/crypto/tegra/tegra-se-main.c — SE driver
- drivers/gpu/host1x/debug.c — debugfs dump
**Step 5.3: TRACE CALLEES**
Record: cancel_delayed_work_sync() only. Can sleep; flushes the delayed work.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace on Tegra DRM can trigger it: submit a job with a timeout → timeout work queued → close channel (DRM_TEGRA channel close / process exit) while the handler runs. Unprivileged on devices that expose tegra DRM. **Reachable from userspace.**
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: stop_cdma_timer_locked() still uses unsynchronized cancel **under the lock** (correct). cdma->update_work is still not cancelled in deinit (pre-existing, called out by sashiko-bot; **not** this patch).
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- git describe HEAD = **v7.3-rc4-27-gf0100363d8c37**; make kernelversion = **7.3.0-rc4**.
- Commit **7a39b9856acccc8e9b05845ca2bf62494fcd3dfa is already an ancestor of HEAD** (git merge-base --is-ancestor succeeded). Current cdma_timeout_destroy() already calls cancel_delayed_work_sync().
- The **bug** existed here until that commit: same function, same cancel_delayed_work(), since **v3.10**. This is mainline, so the fix is already applied; the question is whether the same change belongs on this tree’s stable-style policy given the code is the host1x driver this tree ships.
- Introducing commit **is** in this tree. This is not “bug added after this tree branched.”
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** Surrounding function is still the 2013 structure plus later whitespace. One-line identifier swap; no data- structure or API change.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This exact fix is already in HEAD (mainline). No alternate fix, no revert. No other commit on this file addresses the same cancel-vs- running-work race.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: **drivers/gpu/host1x** (NVIDIA Tegra host1x DMA/sync engine). **IMPORTANT** for Tegra (Android, Jetson, embedded), **PERIPHERAL** for generic x86. CONFIG_TEGRA_HOST1X depends on ARCH_TEGRA || COMPILE_TEST.
**Step 7.2: SUBSYSTEM ACTIVITY**
Record: Actively maintained (Tegra264, context devices, multiple 2026 fixes). Author is a core contributor; Thierry Reding applied the series.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: WHO IS AFFECTED**
Record: **Driver-specific / platform-specific** — Tegra SoCs using host1x (DRM 2D/3D/VIC/NVDEC, Tegra SE crypto). Not universal mm/net.
**Step 8.2: TRIGGER CONDITIONS**
Record:
- Job timeout work is running (or sitting in host1x_debug_dump before the lock).
- Concurrent last host1x_channel_put() (channel close, client unbind, process exit).
- Timing-dependent. Author: “narrow” / cover letter “unlikely” — but timeout + channel teardown is a real recovery path.
- Unprivileged userspace on Tegra DRM can close a channel; timeout is a driver-internal delayed work.
**Step 8.3: FAILURE MODE SEVERITY**
Record: Timeout handler runs against CDMA/channel that host1x_cdma_deinit() already tore down: destroyed mutex, freed push buffer, stale channel. **UAF / kernel oops.** Severity: **HIGH** (crash; possible memory-safety issue). Not a log-only bug.
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit:** High for Tegra users — prevents UAF on channel free vs timeout. Low for everyone else (config-gated).
- **Risk:** Very low — 1 line, standard API, no lock held, process context.
- **Ratio:** Benefit outweighs risk for any tree that still has the unsynchronized cancel.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR backporting:**
- Real race: running timeout work vs CDMA/channel destroy.
- Failure mode is UAF / oops, not style.
- One-line, obviously correct cancel_delayed_work_sync.
- Bug in code since **v3.10**; no missing helpers.
- Standalone; series mates not required.
- Maintainer (Thierry Reding) applied v1 with no objections.
- Teardown is reachable from userspace channel close on Tegra.
- debug_dump before the lock makes the window practical during GPU timeout recovery.
**AGAINST:**
- No Reported-by / syzbot / production stack trace.
- Author called it unlikely.
- Tegra-only.
- Cover letter grouped it with “miscellaneous” logic issues.
- sashiko-bot noted other incomplete teardown (update_work); this patch does not fix that (and does not need to).
- This checkout already contains the commit (it is mainline 7.3-rc4). That is not a reason the **fix** is wrong for trees that still have async cancel.
**UNRESOLVED:**
- Stable@ archive search via WebFetch: 403.
- No empirical reproduction here.
- Self-flush if last kref is dropped from inside debug_dump: analyzed from code, not discussed on list.
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — standard workqueue teardown; maintainer applied; in mainline since 2026-07.
2. Fixes a real bug that affects users? **PASS** — UAF on channel free vs timeout handler.
3. Important issue (crash, security, corruption, deadlock)? **PASS** — UAF/oops; **HIGH**.
4. Small and contained? **PASS** — 1 line, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — host1x CDMA timeout code is here; the change is trivial. (HEAD already has the post-image because this is the originating mainline tree.)
**Step 9.3: EXCEPTION CATEGORIES**
Record: None (not a device ID, quirk, DT, build, or docs exception). It qualifies as a normal small crash-class fix.
**Step 9.4: DECISION**
This tree has host1x and the historical bug. The fix is a textbook cancel-vs-running-work UAF close, one line, no prerequisites, no new API. Stable rules are satisfied. Unlikely trigger does not outweigh an oops/UAF on a path userspace can hit after a GPU timeout.
### What the commit solvescdma_timeout_destroy() cancelled timeout work asynchronously. If cdma_timeout_handler() was already running (especially in host1x_debug_dump() before cdma->lock), release_channel() could cdma_stop + host1x_cdma_deinit() and free CDMA while the handler still used it. cancel_delayed_work_sync() waits for that worker first.
### Stable rules / risk
Meets all six stable criteria. Risk is a possible extra wait on channel free (correct). Benefit is avoiding a kernel UAF on Tegra host1x.
### Concerns
No user report; Tegra-only; leftover update_work teardown is a separate bug. None of those block this one-liner.
### Verification
- **[Phase 1]** Parsed subject/tags/body from git log -1 + git show 7a39b9856accc; no Fixes/Reported-by/Cc-stable; Link msgid present.
- **[Phase 2]** Diff is one token in cdma_timeout_destroy; read handler, cdma_stop, host1x_cdma_deinit, release_channel.
- **[Phase 2]** Confirmed handler calls host1x_debug_dump() before mutex_lock; dump uses show_all(..., true).
- **[Phase 3]** git blame on parent: 6579324a41cc41 (2013); git describe --contains → v3.10-rc1.
- **[Phase 3]** git merge-base --is-ancestor 6579324a41cc41 HEAD and 7a39b9856accc HEAD both true.
- **[Phase 3]** git log --oneline on drivers/gpu/host1x/ for author and series; patch is standalone.
- **[Phase 4]** b4 dig -c/-a/-w/-m: v1 only; recipients include Thierry; mbox cover letter + “Applied to drm-misc-next”.
- **[Phase 4]** WebFetch lore/stable: 403 — listed UNVERIFIED.
- **[Phase 5]** git grep host1x_channel_put — DRM/crypto/debugfs, process context.
- **[Phase 6]** git describe HEAD / make kernelversion → v7.3-rc4; current file already has _sync.
- **[Phase 7]** drivers/gpu/host1x/Kconfig → CONFIG_TEGRA_HOST1X.
- **[Phase 8]** Failure mode from code: handler vs deinit = UAF; trigger = timeout work + last channel put.
**YES**
drivers/gpu/host1x/hw/cdma_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/host1x/hw/cdma_hw.c +1 -1
@@ -355,7 +355,7 @@ static int cdma_timeout_init(struct host1x_cdma *cdma)static void cdma_timeout_destroy (struct host1x_cdma *cdma) {if (cdma->timeout.initialized) -cancel_delayed_work (&cdma->timeout.wq); +cancel_delayed_work_sync (&cdma->timeout.wq); cdma->timeout.initialized = false; }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] gpu: host1x: Wait for timeout worker completion on channel free
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] gpu: host1x: self-deadlock in cdma_timeout_destroy() from timeout worker --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] gpu: host1x: self-deadlock in cdma_timeout_destroy() from timeout worker --
commit b332f714cbff777dfee1bb3478ceeef598654573
Author: Mikko Perttunen <[email protected]>
gpu: host1x: Wait for timeout worker completion on channel free
This commit updates cdma_timeout_destroy() to use cancel_delayed_work_sync() instead of cancel_delayed_work() so that any running timeout handler finishes before CDMA teardown proceeds.
drivers/gpu/host1x/hw/cdma_hw.c static int cdma_timeout_init(struct host1x_cdma *cdma) · line 358
Quoted 10 lines
drivers/gpu/host1x/hw/cdma_hw.c +1
-1@@ -355,7 +355,7 @@ static int cdma_timeout_init(struct host1x_cdma *cdma)static void cdma_timeout_destroy (struct host1x_cdma *cdma) {if (cdma->timeout.initialized) -cancel_delayed_work (&cdma->timeout.wq); +cancel_delayed_work_sync (&cdma->timeout.wq);
[Severity: High]
Can calling cancel_delayed_work_sync(&cdma->timeout.wq) here self-deadlock when invoked from within cdma_timeout_handler() itself?
Before taking cdma->lock, cdma_timeout_handler() runs without holding a reference of its own on struct host1x_channel and calls host1x_debug_dump():
drivers/gpu/host1x/hw/cdma_hw.c:cdma_timeout_handler() {
...
host1x_debug_dump(cdma_to_host1x(cdma));
mutex_lock(&cdma->lock);
...
}host1x_debug_dump() calls show_all(), which iterates over all channels, acquires a temporary kref via host1x_channel_get_index(), dumps the channel, and drops that reference via host1x_channel_put():
drivers/gpu/host1x/debug.c:show_all() {
...
for (i = 0; i < m->info->nb_channels; ++i) {
struct host1x_channel *ch = host1x_channel_get_index(m, i);
if (ch) {
show_channel(ch, o, show_fifo);
host1x_channel_put(ch);
}
}
...
}If the channel owner closes the channel and calls host1x_channel_put() while cdma_timeout_handler() is inside show_channel() holding that temporary reference on its own channel, the owner's kref_put() decrements ch->refcount from 2 to 1 and returns without releasing the channel.
When show_channel() finishes, the host1x_channel_put(ch) in show_all() drops ch->refcount from 1 to 0 and synchronously calls release_channel() from the cdma->timeout.wq worker context:
cdma_timeout_handler()
-> host1x_debug_dump()
-> show_all()
-> host1x_channel_put()
-> release_channel()
-> host1x_hw_cdma_stop()
-> host1x_cdma_deinit()
-> host1x_hw_cdma_timeout_destroy()
-> cdma_timeout_destroy()
-> cancel_delayed_work_sync(&cdma->timeout.wq)At that point, if cdma->sync_queue is not yet empty, host1x_hw_cdma_stop() blocks indefinitely waiting on CDMA_EVENT_SYNC_QUEUE_EMPTY; otherwise it proceeds to cdma_timeout_destroy(), where cancel_delayed_work_sync() waits for the currently executing cdma->timeout.wq work item to complete, deadlocking the worker thread.
Quoted 3 lines
drivers/gpu/host1x/hw/cdma_hw.c +0
-0cdma->timeout.initialized = false; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 ext4: check return value of ext4_get_block() in ext4_load_tail_bh()
In reply to Sasha LevinFrom: Zhang Yi <[email protected]>
[ Upstream commit 705a3fd3bac167f1dabe3d3bba46cd484c5528dd ]
ext4_load_tail_bh() ignores the return value of ext4_get_block(), so an I/O or allocation failure is silently discarded. buffer_mapped(bh) stays false and the function returns NULL, which callers such as ext4_block_do_zero_range() treat as "nothing to do" and return success. This can mask real failures during zero-range, truncate, or punch-hole operations, potentially exposing stale data if the block was not actually a hole and needed zeroing. So propagate the error to the callers.
---
LLM Generated explanations, may be completely bogus:
## Local tree
This checkout is **v7.3-rc4** (7.3.0-rc4, HEAD f0100363d8c37). ext4_load_tail_bh() exists here (since v7.1-rc1). The candidate 705a3fd3bac16 is already an ancestor of HEAD (merged in v7.3-rc1). The verdict is whether this fix belongs in **this** tree on technical merit, not because it was already applied.
---
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
- Record: **[ext4] [check] check return value of ext4_get_block() in ext4_load_tail_bh()**
- Verb “check” here means propagate a previously ignored error.
**Step 1.2 — Tags**
- Record:
- Signed-off-by: Zhang Yi <[email protected]> (author; ext4 reviewer in MAINTAINERS)
- Reviewed-by: Jan Kara <[email protected]> (ext4 reviewer)
- `Link: https://patch.msgid.link/20260714080044.4038124-4-
[email protected]` (v4 3/9)
- Signed-off-by: Theodore Ts'o <[email protected]> (ext4 maintainer)
- No Fixes:, no Cc: stable, no Reported-by, no syzbot. Absence of those tags is expected for this review.
**Step 1.3 — Body**
- Record: **Bug:** ext4_load_tail_bh() ignores ext4_get_block() errors. On failure buffer_mapped(bh) stays false, the helper returns NULL, and callers such as ext4_block_do_zero_range() treat that as “hole / nothing to do” and return success.
- **Symptom:** Silent success of zero-range, truncate, or punch-hole while the tail block was not zeroed.
- **Failure mode:** Stale data can later be exposed if the block was not a hole.
- **Root cause:** Error conflated with “unmapped hole”.
- **No version range** in the message.
**Step 1.4 — Hidden bug fix?**
- Record: **Not hidden.** It is an explicit error-propagation / stale- data fix. Cover letter later confirms patches 2 and 3 were “pre- existing fixes … originally going to be sent separately,” then folded into the WRITE_ZEROES series.
---
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
- Record: **One file**, fs/ext4/inode.c: **+3 / −1**. One function:
ext4_load_tail_bh(). Surgical, single-file.
**Step 2.2 — Flow**
- Record: **Before:** unmapped bh → ext4_get_block(..., create=0) return ignored → if still unmapped, goto unlock with err == 0 → return NULL.
- **After:** negative return sets err and goto unlock → existing return err ? ERR_PTR(err) : NULL.
- Path: mapping lookup on the tail block during partial-block zeroing (error path only).
**Step 2.3 — Bug mechanism**
- Record: **Logic / correctness (ignored error → false success).** Category closest to “return value checking / missing error handling.” Not UAF, leak, or race.
- Mechanism: I/O or allocation failure from ext4_get_block() is treated as a hole, so truncate/punch/zero-range skip tail zeroing and still succeed.
**Step 2.4 — Fix quality**
- Record: **Obviously correct.** Callers already do IS_ERR_OR_NULL(bh) / PTR_ERR_OR_ZERO(bh) (present since the helper was factored out). Unlock/put already runs on the unlock path. Regression risk is low **in this tree** because parent 2fff82f081401 skips inline-data EOF zeroing (otherwise append writes on inline files could see -ERANGE). No API change.
---
## Phase 3: Git history
**Step 3.1 — Blame**
- Record: Ignored ext4_get_block() call dates to **d863dc3614e489 (2013, Lukas Czerner)** inside __ext4_block_zero_page_range. Helper **ext4_load_tail_bh** was factored out in **3b312a6f510ca (“ext4:
factor out journalled block zeroing range”, Zhang Yi, 2026-03)** and kept the same ignored return. First in this lineage: **v7.1-rc1**.
**Step 3.2 — Fixes: tag**
- Record: **None.** Introducing commit for the helper is 3b312a6f510ca, ancestor of this HEAD. The ignored-return bug is older than the helper.
**Step 3.3 — File history**
- Record: Same v4 series around this commit:
1. e1cf7b5f5c8ad FGP_WRITEBEGIN
2. 2fff82f081401 skip inline-data tail zeroing **(prerequisite)**
3. **705a3fd3bac16 this fix**
4. b16e9d27a643a move partial zeroing earlier
5. 012e6a2c9ff4d comment-only return-semantics clarification 6–9. WRITE_ZEROES edge handling (some of those have Cc: stable)
- This patch is **standalone** given (2). (5) is comments only; 6–9 are WRITE_ZEROES, not required for this error check.
**Step 3.4 — Author**
- Record: **Zhang Yi** is an ext4 **Reviewer** in MAINTAINERS; 178 ext4 commits in this tree. Not a drive-by.
**Step 3.5 — Dependencies**
- Record: Needs ext4_load_tail_bh() + ERR_PTR return + IS_ERR_OR_NULL callers — all present since 3b312a6f510ca (v7.1). Needs **2fff82f081401** so inline-data append does not start failing. Both are in this tree. **Applies standalone on top of that parent.**
---
## Phase 4: Mailing list
**Step 4.1 — Original discussion**
- Record: b4 dig -c 705a3fd3bac16 → **https://patch.msgid.link/2026071 [email protected]**
- Series: **[PATCH v4 0/9] ext4: fix unaligned edge handling in FALLOC_FL_WRITE_ZEROES**
- Revisions: v1 → v4. v4 vs v3: **no code change** on this patch; v3 collected Jan’s R-b.
- Cover letter: patches 2 and 3 were **pre-existing fixes folded in**, not WRITE_ZEROES-only prep.
- No NAK found on this patch. Ted merged it.
**Step 4.2 — Recipients (b4 dig -w)**
- Record: linux-ext4, linux-fsdevel, **[email protected]**, **[email protected]**, adilger, libaokun, ojaswin, ritesh.list — maintainers/reviewers were on Cc. Jan reviewed; Ted committed.
**Step 4.3 — Bug report**
- Record: **No external bugzilla/syzbot report.** Issue found by code inspection (author). Severity is argued in the commit: silent success
+ possible stale data.
**Step 4.4 — Series**
- Record: 9 patches. This one is independently useful. Sibling patches 7–9 carry Cc: stable for WRITE_ZEROES; this one does not. That is **not** used as a NO vote (tags are expected to be absent here).
**Step 4.5 — stable@**
- Record: **UNVERIFIED.** lore.kernel.org WebFetch returned 403; no separate stable-thread confirmation. b4 dig matched the ext4 thread.
---
## Phase 5: Semantic / call graph
**Step 5.1 — Functions**
- Record: **ext4_load_tail_bh** only.
**Step 5.2 — Callers**
- Record (this tree):
- ext4_block_do_zero_range() → IS_ERR_OR_NULL / PTR_ERR_OR_ZERO
- ext4_block_journalled_zero_range() → same
- via ext4_block_zero_range():
- ext4_block_zero_eof() — truncate (ext4_truncate), setattr grow, append (ext4_write_checks in fs/ext4/file.c)
- ext4_zero_partial_blocks() — punch-hole (ext4_punch_hole), ext4_zero_range() / WRITE_ZEROES in fs/ext4/extents.c
**Step 5.3 — Callees**
- Record: __filemap_get_folio, ext4_get_block (lookup only), ext4_read_bh_lock, folio lock/put.
**Step 5.4 — Reachability**
- Record: **Yes, from userspace:** truncate/ftruncate, fallocate (punch/zero/WRITE_ZEROES), append write. Unprivileged processes on their own files can hit the path. The **error** itself needs ext4_get_block() failure (I/O error, ENOMEM, corruption), not a normal happy path.
**Step 5.5 — Similar patterns**
- Record: Same ignored return lived in __ext4_block_zero_page_range since 2013. No second copy of this exact bug in current ext4_load_tail_bh.
---
## Phase 6: This checkout
**Step 6.1 — Buggy code here?**
- Record: **Yes.** Helper is in fs/ext4/inode.c (~4033). Introduced **v7.1-rc1** (3b312a6f510ca). This 7.3-rc4 tree has that code. The ignored-return bug existed until 705a3fd3bac16 (v7.3-rc1).
**Step 6.2 — Backport difficulty**
- Record: **Clean apply** onto the parent in this tree (2fff82f081401). Three lines. Later b4e409c18c797 removed fs-layer fscrypt decrypt from this function; that is after/around the same merge window and does not change the get_block check.
**Step 6.3 — Related fixes already here?**
- Record: Prerequisite 2fff82f081401 is in HEAD. Follow-up 012e6a2c9ff4d is comments only. No competing alternate fix.
---
## Phase 7: Subsystem
**Step 7.1**
- Record: **ext4 (fs/ext4)** — **IMPORTANT** (default Linux filesystem; data integrity).
**Step 7.2**
- Record: **Active** in 7.3 (WRITE_ZEROES series, iomap, fastcommit, etc.). Helper itself is recent (7.1) but the ignored-return pattern is old.
---
## Phase 8: Impact and risk
**Step 8.1 — Who**
- Record: **Filesystem-specific:** ext4 users doing truncate, punch- hole, zero-range, append, WRITE_ZEROES.
**Step 8.2 — Trigger**
- Record: Partial-block zeroing **plus** ext4_get_block() failure. Uncommon (I/O error / ENOMEM / bad metadata). Unprivileged users can invoke the operations; they cannot usually force get_block failure except under memory/IO pressure.
**Step 8.3 — Failure mode**
- Record: **Stale data / false success** on truncate/punch/zero-range. Not a panic. **Severity: HIGH** for a filesystem (classic “truncate succeeded but tail not zeroed → later extend exposes old data”). Not CRITICAL (no oops/deadlock).
**Step 8.4 — Ratio**
- Record: **Benefit: high** for ext4 data integrity on error paths. **Risk: very low** (3 lines, existing ERR_PTR path, Jan + Ted). Prerequisite for inline data is already in this tree.
---
## Phase 9: Synthesis
**Step 9.1 — Evidence**
**For:**
- Real correctness bug: mapping lookup failure reported as success.
- Concrete data-integrity outcome on truncate/punch/zero-range.
- Userspace-reachable (common ext4 ops).
- 3-line, obviously correct; callers already handle ERR_PTR.
- Reviewed by Jan Kara, merged by Ted Ts'o; author is an ext4 reviewer.
- Cover letter: intended as a standalone pre-existing fix.
- Buggy helper **is in this 7.3 tree** (since 7.1).
- Prerequisite inline-data skip **is in this tree**.
**Against:**
- Error-path only; no syzbot/user Reported-by.
- Bundled in a 9-patch WRITE_ZEROES series (mitigated: explicitly called out as a separate pre-existing fix).
- Trigger requires get_block failure (rare).
**Unresolved:** stable@ archive (lore 403); full v1 review text beyond the on-commit Reviewed-by.
**Step 9.2 — Stable rules**
1. Obviously correct and tested? **PASS** (trivial check; R-b Jan; in 7.3-rc1)
2. Real bug affecting users? **PASS** (false success + possible stale data)
3. Important (crash/security/corruption/deadlock)? **PASS** (stale data / integrity, HIGH)
4. Small and contained? **PASS** (+3/−1, one function)
5. No new features/APIs? **PASS**
6. Can apply to this tree? **PASS** (helper + callers + prerequisite present)
**Step 9.3 — Exceptions**
- Record: **None** (not a device ID/quirk/DT/build/doc exception). Ordinary bugfix.
**Step 9.4 — Decision**
This is a small, reviewed ext4 integrity fix for code that exists in this 7.3-rc4 tree. Callers already propagate ERR_PTR. The inline-data prerequisite is present, so the change does not turn append-on-inline- data into -ERANGE. It meets stable criteria for **this** tree.
---
## Why it matters here
On this 7.3 tree, ext4_load_tail_bh() is the shared tail-zero helper for truncate, punch-hole, fallocate zero/WRITE_ZEROES, and post-EOF append. Ignoring ext4_get_block() makes a failed extent lookup look like a hole, so those operations can succeed without zeroing a mapped tail. Later grow/read can then expose stale bytes. Checking the return and using the existing ERR_PTR path is the right, minimal fix.
Risk is low: three lines, no locking/API change, prerequisite 2fff82f081401 already in this checkout.
---
## Verification
- **[Phase 1]** Parsed commit 705a3fd3bac167f1dabe3d3bba46cd484c5528dd: Zhang Yi, R-b Jan Kara, SOB Ted Ts'o, Link msgid …4038124-4…. No Fixes/Cc:stable/Reported- by.
- **[Phase 2]** git show 705a3fd3bac16: +3/−1 in ext4_load_tail_bh; err = ext4_get_block(...); if (err < 0) goto unlock.
- **[Phase 2]** Confirmed unlock already returns `err ? ERR_PTR(err) :
NULL before the patch (git show 705a3fd3bac16^:fs/ext4/inode.c`).
- **[Phase 2]** Callers at the fix: IS_ERR_OR_NULL / PTR_ERR_OR_ZERO (git grep on 705a3fd3bac16).
- **[Phase 3]** git blame 705a3fd3bac16^ around the call:
d863dc3614e489 (2013).
- **[Phase 3]** git log -S ext4_load_tail_bh -- fs/ext4/inode.c → 3b312a6f510ca; git describe --contains → **v7.1-rc1**.
- **[Phase 3]** git merge-base --is-ancestor 3b312a6f510ca HEAD true; 705a3fd3bac16 ancestor of HEAD true; **not** in v7.2; **in** v7.3-rc1.
- **[Phase 3]** Parent 2fff82f081401 documents -ERANGE on inline data if this check is added without the skip; that skip is in HEAD.
- **[Phase 4]** b4 dig -c 705a3fd3bac16 → v4 3/9 lore URL; -a showed v3 and v4; -w listed ext4 maintainers.
- **[Phase 4]** Cover letter (mbox): “Fold in two pre-existing fixes (now patches 2 and 3)”.
- **[Phase 4]** WebFetch lore/msgid.link: **403**. Stable-list search:
**UNVERIFIED**.
- **[Phase 5]** Grep callers: ext4_block_do_zero_range, ext4_block_journalled_zero_range → ext4_block_zero_eof / ext4_zero_partial_blocks → truncate, setattr, punch-hole, zero_range, file.c append.
- **[Phase 5]** Truncate: ext4_truncate → ext4_block_zero_eof; on error goto out_trace (does **not** keep shrinking after a failed zero). Punch-hole/ext4_zero_range return the error.
- **[Phase 6]** git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4.
- **[Phase 6]** Buggy helper present in this tree since v7.1; prerequisite and this commit both ancestors of HEAD.
- **[Phase 7]** MAINTAINERS: Zhang Yi is R: on EXT4; Jan Kara is R:; Ted is M:.
- **[Phase 8]** Failure mode verified from commit text + truncate/punch callers, not from a live repro (no reproducer in the message).
- **UNVERIFIED:** Whether ext4_get_block can return an error while leaving BH_Mapped set (fix still correct: any err < 0 is propagated). No live I/O-error repro.
The patch is a small, reviewed ext4 integrity fix for code that exists in this 7.3 tree, with callers already wired for ERR_PTR and the inline-data prerequisite present.
**YES**
fs/ext4/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/inode.c +3 -1
@@ -4119,7 +4119,9 @@ static int __ext4_block_zero_page_range(handle_t *handle, }if (!buffer_mapped (bh)) {BUFFER_TRACE (bh,"unmapped" ); -ext4_get_block (inode, iblock, bh,0 ); + err =ext4_get_block (inode, iblock, bh,0 ); +if (err <0 ) + goto unlock;/* unmapped? It's a hole - nothing to do */ if (!buffer_mapped (bh)) {BUFFER_TRACE (bh,"still unmapped" );
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] ext4: check return value of ext4_get_block() in ext4_load_tail_bh()
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] ext4: unchecked ext4_block_truncate_page() return in truncate callers --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] ext4: unchecked ext4_block_truncate_page() return in truncate callers --
commit 26fe59dd3c7737fcb95b3fe2c9732b862d57565e
Author: Zhang Yi <[email protected]>
ext4: check return value of ext4_get_block() in ext4_load_tail_bh()
This patch checks and propagates the return value of ext4_get_block() in __ext4_block_zero_page_range() so that I/O or allocation failures are not silently ignored as holes during zero-range, truncate, or punch-hole operations.
Quoted 5 lines
fs/ext4/inode.c +0
-0
fs/ext4/inode.c static int __ext4_block_zero_page_range(handle_t *handle, · line 4100
Quoted 10 lines
fs/ext4/inode.c +3
-1@@ -4092,7 +4092,9 @@ static int __ext4_block_zero_page_range(handle_t *handle, }if (!buffer_mapped (bh)) {BUFFER_TRACE (bh,"unmapped" ); -ext4_get_block (inode, iblock, bh,0 ); + err =ext4_get_block (inode, iblock, bh,0 ); +if (err <0 ) + goto unlock;/* unmapped? It's a hole - nothing to do */ if (!buffer_mapped (bh)) {BUFFER_TRACE (bh,"still unmapped" );
[Severity: Medium]
While this propagates the negative error from ext4_get_block() out of __ext4_block_zero_page_range() via ext4_block_zero_page_range(), ext4_block_truncate_page(), and ext4_zero_partial_blocks(), several truncate and fallocate callers ignore the returned error.
In fs/ext4/inode.c, a shrinking truncate via ext4_setattr()->ext4_truncate()->ext4_block_truncate_page() ignores the return value and proceeds with block truncation:
if (inode->i_size & (inode->i_sb->s_blocksize - 1)) ext4_block_truncate_page(handle, mapping, inode->i_size);
Similarly, an extending truncate in ext4_setattr() ignores the error from ext4_block_truncate_page() and proceeds to update i_disksize and i_size:
if (!shrink) {
inode_set_mtime_to_ts(inode,
inode_set_ctime_current(inode));
if (oldsize & (inode->i_sb->s_blocksize - 1))
ext4_block_truncate_page(handle,
inode->i_mapping, oldsize);
}And in fs/ext4/extents.c, an extending fallocate or zero-range preallocation in ext4_alloc_file_blocks() ignores the error returned by ext4_zero_partial_blocks() when zeroing the old EOF tail block:
if (epos > old_size) {
pagecache_isize_extended(inode, old_size, epos);
ext4_zero_partial_blocks(handle, inode,
old_size, epos - old_size);
}When the tail buffer_head is unmapped and ext4_get_block() fails, can these paths still silently discard the error, update the inode size, and return success with stale data left in the partial tail block?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 wifi: rtw89: wow: add QoS control field to WoWLAN ARP response for MLO
In reply to Sasha LevinFrom: Chin-Yen Lee <[email protected]>
[ Upstream commit 03a963f4aeda538acad50806e94ef25d95b78743 ]
Some MLO APs expect WoWLAN ARP response frames to be transmitted as QoS data frames and may discard frames that do not contain a QoS Control field.
Add a QoS Control field and use the QoS Data subtype when generating WoWLAN ARP responses for MLD vifs. Keep the existing frame format unchanged for non-MLO connections.
This allows WoWLAN ARP responses to be accepted by MLO APs while preserving compatibility with legacy APs.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: **[wifi: rtw89: wow:] [add] [QoS Control field on WoWLAN ARP responses for MLO]**
Subsystem is Realtek rtw89 WoWLAN. The verb is “add”, but the body is
interoperability: MLO APs drop ARP frames that are not QoS Data.
**Step 1.2: Tags**
Record:
- Signed-off-by: Chin-Yen Lee \<[email protected]\> (author)
- Signed-off-by: Ping-Ke Shih \<[email protected]\> (rtw89 maintainer)
- Link:
https://patch.msgid.link/[email protected]
(msgid …44808-10… → patch 09/10 of a 10-patch rtw-next series; 1-based msgid index)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Cc:
stable (absence is expected here)
- Ignore pipeline SOBs such as Sasha Levin (none on the real commit)
**Step 1.3: Body**
Record:
- **Bug:** Some MLO APs require WoWLAN ARP responses as QoS Data and discard frames without a QoS Control field.
- **Symptom:** ARP keep-alive / ARP offload during WoWLAN is ignored → AP can drop the STA while suspend/WoWLAN is active.
- **Root cause:** rtw89_arp_response_get() always built a non-QoS Data 3-address frame.
- **Fix:** For MLD vifs, set IEEE80211_STYPE_QOS_DATA and insert a 2-byte QoS Control field; leave non-MLO frames unchanged.
- **Versions:** none named in the message.
**Step 1.4: Hidden bug fix?**
Record: Yes. “Add QoS control field” is a protocol-format fix for an existing WoWLAN ARP template, not a new userspace API. Cover letter language (“support WoWLAN with MLO AP”) is feature-ish, but the driver already had MLO WoWLAN and ARP offload/keep-alive; this corrects the template those paths upload.
---
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- File: drivers/net/wireless/realtek/rtw89/fw.c (+24 / −7; git show --stat matches)
- Function: rtw89_arp_response_get() only
- Scope: single-file, single-function, surgical
**Step 2.2: Control flow**
Record (before → after):
- Allocate skb sized for 3-addr header + security header + ARP body → also reserve 2 bytes when ieee80211_vif_is_mld(vif).
- Frame control: Data+ToDS (+Protected if PTK) → same, plus QoS Data subtype for MLO, Data subtype for legacy.
- Always skb_put_zero(sec_hdr_len) → insert QoS Control (zeros) before IV if MLO; skip security bytes when sec_hdr_len == 0 (equivalent to skb_put_zero(0)).
- Debug print via str_yes_no(with_qos).
802.11 order is correct: 3-addr MAC header, QoS Control, IV, LLC+ARP. QoS Control of 0 is TID 0 / normal ACK, which is appropriate for ARP.
**Step 2.3: Bug mechanism**
Record: **Logic / protocol correctness + hardware interoperability.** MLO (802.11be) APs expect QoS Data; non-QoS keep-alive/offload templates are discarded. Not UAF, leak, race, or NULL deref.
**Step 2.4: Fix quality**
Record: Obviously correct and minimal. Non-MLO path is unchanged in substance (IEEE80211_STYPE_DATA is 0). Regression risk is low and confined to MLO WoWLAN ARP: a wrong QoS field could still be dropped, but zeroed QoS Control is the standard default. No public API or struct layout change.
---
## Phase 3: Git history
**Step 3.1: Blame**
Record:
- Function introduced in 58ed86e1666b3 (“wifi: rtw89: wow: add ARP offload feature”, 2024-05-02) — contained in v6.11-rc1 era (git describe --contains → x86_boot_for_v6.11_rc1~…).
- Link-aware rtwvif_link args: 2f7dae17c48cd1 (2024-09).
- Security header: 0065199f4303bc (2024-06).
- Keep-alive uses this template: dcf5c7262bffa (2026-05-25, in **v7.2-rc1**).
- MLD MAC in ARP: parent 76edcedda6437 (same series 08/10).
- This commit: 03a963f4aeda5, **contained in v7.3-rc1**.
**Step 3.2: Fixes: tag**
Record: None. Buggy behavior is the original ARP template never emitting QoS Data for MLD vifs after MLO WoWLAN existed.
**Step 3.3: Related file history**
Record: Same-day series (msgid 20260625061545.44808-*):
1. MAC finish active TX
2. pass chip version to FW
3. lower UDM1 debug level
4. drop pkt offload on H2C failure
5. disable sniffer RX filter (Wi-Fi 7)
6. PCI phy error / refclk
7. LPS MLO link ID fix
8. **MLD address in WoWLAN ARP** (parent)
9. **this patch**
10. RF init only on Wi-Fi 6 in WoW
This patch does not call or require patches 1–8/10. 08/10 only changes ARP hw addresses; 09/10 only changes frame control + QoS bytes. Standalone at the code level.
**Step 3.4: Author**
Record: Chin-Yen Lee (Realtek); maintainer Ping-Ke Shih signed off and applied the whole series to rtw-next. Nearby author work is other rtw89 WoWLAN/MLO fixes.
**Step 3.5: Prerequisites in this tree**
Record: Present here:
- rtwvif_to_vif() in core.h
- ieee80211_vif_is_mld() in include/net/mac80211.h
- str_yes_no() in include/linux/string_choices.h
- ARP offload + keep-alive both call rtw89_fw_h2c_add_general_pkt(…, RTW89_PKT_OFLD_TYPE_ARP_RSP, …)
Can apply standalone on this tree.
---
## Phase 4: Mailing list / external
**Step 4.1: b4 dig**
Record:
- Lore/msgid:
https://patch.msgid.link/[email protected]
- Subject: [PATCH rtw-next 09/10] wifi: rtw89: wow: add QoS control field to WoWLAN ARP response for MLO
- Series: v1 only (b4 dig -a); no v2/v3.
- Cover letter (00/10): “update some MAC, FW and WoWLAN settings”; “The last three patches are related to WoWLAN, and the first two are to support WoWLAN with MLO AP that uses MLD address.”
- Only reply in the saved mbox: Ping-Ke applying all 10 to rtw-next (no NAK, no reviewer comments on 09/10).
- No Cc: stable in the thread.
**Step 4.2: Recipients (b4 dig -w)**
Record: Ping-Ke Shih, linux-wireless, [email protected], [email protected], [email protected], [email protected]. Maintainer was To/Cc and applied it. No external review tags.
**Step 4.3: Bug report**
Record: No Reported-by, bugzilla, or syzbot. Vendor-described AP behavior only. Specific AP models for *this* QoS issue are not named (keep-alive predecessor named TP-Link Archer BE800).
**Step 4.4: Series**
Record: Mixed MAC/FW/WoW settings. 09/10 is self-contained; 08/10 is a related but independent MLO ARP address fix.
**Step 4.5: stable@**
Record: **UNVERIFIED** (lore.kernel.org/stable blocked by Anubis). Thread mbox has no stable discussion.
WebFetch of lore/msgid also returned 403; discussion was recovered via b4 dig -m.
---
## Phase 5: Semantic / call graph
**Step 5.1: Functions**
Record: rtw89_arp_response_get() only.
**Step 5.2: Callers**
Record:
- rtw89_fw_h2c_add_general_pkt() → RTW89_PKT_OFLD_TYPE_ARP_RSP
- rtw89_fw_h2c_keep_alive() (WoW keep-alive enable)
- rtw89_fw_h2c_arp_offload() (WoW ARP offload enable)
- rtw89_wow_fw_start() in wow.c enables both when the interface is linked
Path is WoWLAN firmware start on suspend (CONFIG_PM), not a syscall hot path.
**Step 5.3: Callees**
Record: rtwvif_to_vif, ieee80211_vif_is_mld, rtw89_wow_get_sec_hdr_len, dev_alloc_skb, skb_put_zero, cpu_to_le16, ether_addr_copy, str_yes_no (debug only).
**Step 5.4: Reachability**
Record: Userspace-reachable via suspend with WoWLAN on an rtw89 STA associated as an MLD. Not unprivileged kernel-memory corruption; it is a normal power-management / offload path.
**Step 5.5: Similar patterns**
Record: rtw89_sa_query_get() still builds a non-QoS mgmt action frame (correct for SA Query). No sibling ARP builders. Keep-alive commit dcf5c7262bffa is the same interoperability class (APs ignoring Null keep-alives).
---
## Phase 6: This checkout
**Step 6.1: Local tree and whether the bug exists**
Record:
- git describe HEAD: **v7.3-rc4-27-gf0100363d8c37**
- make kernelversion: **7.3.0-rc4**
- rtw89_arp_response_get() exists; MLO (ieee80211_vif_is_mld), WoW keep-alive, and ARP offload all exist.
- Without this change, MLO ARP templates are non-QoS Data. That is the bug this tree’s rtw89 WoW+MLO users hit.
- Commit 03a963f4aeda5 is an ancestor of HEAD (git merge-base --is- ancestor → yes) because it landed in **v7.3-rc1**. That is not used as “already selected for stable”; it only confirms the code and helpers are in this series.
**Step 6.2: Backport difficulty**
Record: Clean apply on this tree (hunk matches current fw.c). No refactor blocking it.
**Step 6.3: Other fixes here**
Record: No later follow-up rewriting this QoS logic (git log after the commit on this function is unrelated fw/coex/scan work). Parent MLD- address fix is already here and independent.
---
## Phase 7: Subsystem context
**Step 7.1**
Record: **drivers/net/wireless/realtek/rtw89** — important (common Wi-Fi 6/7 laptops), not core mm/fs. WoWLAN is CONFIG_PM.
**Step 7.2**
Record: Very active (frequent coex/MLO/WoW commits). This is a late correction to existing MLO WoW, not a brand-new subsystem.
---
## Phase 8: Impact and risk
**Step 8.1: Who**
Record: Driver-specific + config-specific: rtw89, MLO association, WoWLAN/suspend. Not universal.
**Step 8.2: Trigger**
Record: Suspend with WoWLAN while associated to an MLO AP that rejects non-QoS Data. Common for Wi-Fi 7 + lid-close. Unprivileged in the sense of normal laptop suspend, not an exploit primitive.
**Step 8.3: Failure mode**
Record: AP discards keep-alive and/or ARP offload → association can drop in suspend. **Severity: MEDIUM** (connectivity / suspend Wi-Fi, not oops/corruption). Matches stable-rules “hardware quirk” / “oh, that’s not good”, not crash/UAF.
**Step 8.4: Risk–benefit**
Record:
- Benefit: MLO WoWLAN keep-alive and ARP offload actually accepted; avoids silent disconnect on suspend for Wi-Fi 7 rtw89.
- Risk: ~24 lines, MLO-only, no locking/API. Low.
- Ratio: favorable for this tree, which already has MLO WoW + ARP templates.
---
## Phase 9: Synthesis
**Step 9.1: Evidence**
For:
- Real interoperability bug on an existing path (WoW ARP template), not a new driver or API.
- This 7.3 tree has MLO, rtw89_arp_response_get(), keep-alive, and ARP offload.
- Small, obviously correct, non-MLO behavior preserved.
- Maintainer SOB + applied to rtw.git.
- Official stable rules allow hardware quirks and “oh, that’s not good” issues; this is AP-side discard of malformed/non-QoS MLO data.
- Suspend/WoWLAN disconnect is user-visible on shipping Realtek Wi-Fi 7 hardware.
Against:
- Not oops/deadlock/corruption/security.
- rtw-next series titled “update some MAC, FW and WoWLAN settings”; cover letter says “support WoWLAN with MLO AP”.
- No external reporters, Tested-by, or Fixes: tag.
- Affects only MLO + WoWLAN.
Unresolved:
- Stable-list history (lore bot wall).
- Which exact APs need QoS (commit says “some MLO APs”).
**Step 9.2: Stable rules checklist** (Documentation/process/stable- kernel-rules.rst)
1. Obviously correct and tested? **PASS** — vendor + maintainer, tiny, protocol order verified in tree.
2. Real bug that bothers users? **PASS** — WoWLAN ARP ignored, possible disconnect in suspend on MLO.
3. Important (crash/security/corruption/deadlock **or** quirk / “oh that’s not good”)? **PASS** — quirk / connectivity, not CRITICAL crash.
4. Small and contained? **PASS** — one function, well under 100 lines.
5. No new features/APIs? **PASS** — frame format fix for existing offload, no new uAPI.
6. Applies to this tree? **PASS** — helpers and callers exist; hunk matches fw.c.
**Step 9.3: Exception category**
Record: Hardware/protocol quirk (MLO APs dropping non-QoS WoW ARP), analogous to other driver workarounds. Not a device-ID one-liner, but the same class.
**Step 9.4: Decision**
This tree is **7.3.0-rc4**. rtw89 already implements MLO WoWLAN and uploads ARP templates for keep-alive and ARP offload. Sending those as non-QoS Data is wrong for MLO APs and can drop the link in suspend. The patch is a small, MLO-only frame-format fix with low regression risk and no extra series dependencies. That is appropriate to have in this tree’s stable line.
### What it solves for users of this tree
WoWLAN keep-alive and ARP offload on rtw89 MLD vifs were built as ordinary Data frames. Some MLO APs drop those, so the AP may age out the STA during suspend. Adding QoS Control + QoS Data subtype makes those firmware-transmitted frames acceptable while leaving legacy associations unchanged.
### Risk vs benefit
Benefit is restoring Wi-Fi 7 WoWLAN connectivity on Realtek rtw89. Risk is a 2-byte header on the MLO path only. Non-MLO frame control stays Data+ToDS.
### Concerns
Cover letter frames this as MLO WoW “support” in a mixed rtw-next series, and there is no public reproducer. On this 7.3 tree those features already exist, so this is a contained correctness fix, not a new subsystem.
---
Verification:
- [Phase 1] Parsed subject/tags/body from git log -1 --format=fuller 03a963f4aeda5; msgid is 09/10 of 20260625061545.44808.
- [Phase 2] Diff vs current fw.c rtw89_arp_response_get(); +24/−7 in one function; QoS inserted after 3-addr header, before IV.
- [Phase 3] git merge-base --is-ancestor 03a963f4aeda5 HEAD → yes; git describe --contains → v7.3-rc1~…; blame shows intro 58ed86e1666b3; parent 76edcedda6437 is address-only.
- [Phase 3] git log --oneline --grep=20260625061545.44808 -- drivers/net/wireless/realtek/rtw89/ listed all 10 series commits.
- [Phase 4] b4 dig -c/-a/-w/-m: v1 rtw-next 10-patch series; applied by Ping-Ke; no NAK; no stable Cc. WebFetch lore 403; curl stable list Anubis-blocked.
- [Phase 5] Grep: ARP_RSP used from keep-alive and ARP offload; rtw89_wow_fw_start() enables both.
- [Phase 6] git describe HEAD = v7.3-rc4-27-g…; VERSION/PATCHLEVEL 7.3.0-rc4; MLO/WoW/ARP code present.
- [Phase 7] rtw89 Wi-Fi 6/7 driver, active history on fw.c.
- [Phase 8] Failure mode: AP drops WoW ARP → disconnect in suspend; not a kernel oops.
- [Phase 9] Checked Documentation/process/stable-kernel-rules.rst (quirk / “oh that’s not good”, ≤100 lines).
- UNVERIFIED: lore.kernel.org/stable archives (bot challenge).
- UNVERIFIED: exact AP models for the QoS requirement (not named in commit or mbox).
**YES**
drivers/net/wireless/realtek/rtw89/fw.c | 31 +++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-)
drivers/net/wireless/realtek/rtw89/fw.c +24 -7
@@ -2701,6 +2701,7 @@ static struct sk_buff *rtw89_sa_query_get(struct rtw89_dev *rtwdev,static struct sk_buff *rtw89_arp_response_get (struct rtw89_dev *rtwdev,struct rtw89_vif_link *rtwvif_link) { +struct ieee80211_vif *vif =rtwvif_to_vif (rtwvif_link->rtwvif);struct rtw89_vif *rtwvif = rtwvif_link->rtwvif;u8 sec_hdr_len =rtw89_wow_get_sec_hdr_len (rtwdev);struct rtw89_wow_param *rtw_wow = &rtwdev->wow;
@@ -2708,26 +2709,42 @@ static struct sk_buff *rtw89_arp_response_get(struct rtw89_dev *rtwdev,struct rtw89_arp_rsp *arp_skb;struct arphdr *arp_hdr;struct sk_buff *skb; -__le16 fc; +bool with_qos; +u16 fc; - skb =dev_alloc_skb (sizeof (*hdr) + sec_hdr_len +sizeof (*arp_skb)); + with_qos =ieee80211_vif_is_mld (vif); + +rtw89_debug (rtwdev,RTW89_DBG_WOW ,"[arp_reply] with qos field: %s\n" , +str_yes_no (with_qos)); + + skb =dev_alloc_skb (sizeof (*hdr) + sec_hdr_len +sizeof (*arp_skb) + + (with_qos ?2 :0 ));if (!skb)return NULL ; hdr =skb_put_zero (skb,sizeof (*hdr)); + fc =IEEE80211_FTYPE_DATA |IEEE80211_FCTL_TODS ; +if (rtw_wow->ptk_alg) - fc =cpu_to_le16 (IEEE80211_FTYPE_DATA |IEEE80211_FCTL_TODS | -IEEE80211_FCTL_PROTECTED ); + fc |=IEEE80211_FCTL_PROTECTED ; + +if (with_qos) + fc |=IEEE80211_STYPE_QOS_DATA ;else - fc =cpu_to_le16 (IEEE80211_FTYPE_DATA |IEEE80211_FCTL_TODS ); + fc |=IEEE80211_STYPE_DATA ; + + hdr->frame_control =cpu_to_le16 (fc); - hdr->frame_control = fc;ether_addr_copy (hdr->addr1, rtwvif_link->bssid);ether_addr_copy (hdr->addr2, rtwvif_link->mac_addr);ether_addr_copy (hdr->addr3, rtwvif_link->bssid); -skb_put_zero (skb, sec_hdr_len); +if (with_qos) +skb_put_zero (skb,sizeof (__le16)); + +if (sec_hdr_len) +skb_put_zero (skb, sec_hdr_len); arp_skb =skb_put_zero (skb,sizeof (*arp_skb));memcpy (arp_skb->llc_hdr, rfc1042_header,sizeof (rfc1042_header));
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 scsi: qla2xxx: Handle INTx not connected while passing through
In reply to Sasha LevinFrom: Shivaprasad G Bhat <[email protected]>
[ Upstream commit 7268e509b43ac1734e1bdb7d18553f7e1080dfb4 ]
The PCI_INTERRUPT_PIN reports if the device supports the INTx. However, when the device is assigned to a guest via vfio, the PCI_INTERRUPT_PIN is set to 0 (i.e none) if the line is not connected and/or the platform cannot route the interrupt.
In such cases, the guest PCI_INTERRUPT_PIN is 0 and the port number becomes -1 (255, uint8_t underflow) for qla[25|27|28]xx and qla2031 devices. The flt_region_nvram is never set, and subsequently the LUN detection fails. Below warnings show the NVRAM configuration failure:
[]-0073:1: Inconsistent NVRAM checksum=0xffffffc0 id=HCAM version=0x100. []-0074:1: Falling back to functioning (yet invalid -- WWPN) defaults. []-0076:1: NVRAM configuration failed.
Handle this case and set the port_no to devfn like its done everywhere else.
Reference: commit 2bd42b03ab6b ("vfio/pci: Virtualize zero INTx PIN if no pdev->irq")
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: [scsi/qla2xxx] [Handle] Handle INTx not connected while passing through
Subsystem is the QLogic Fibre Channel driver. The verb “Handle” is a correctness/workaround fix, not a feature add.
**Step 1.2: Tags**
Record:
- Reviewed-by: Kyle Mahlkuch <[email protected]>
- `Link: https://patch.msgid.link/177885270578.1573.14283751510936407585
[email protected]`
- Signed-off-by: Shivaprasad G Bhat <[email protected]> (author)
- Signed-off-by: Martin K. Petersen <[email protected]> (SCSI maintainer)
- Reference: commit 2bd42b03ab6b ("vfio/pci: Virtualize zero INTx PIN if no pdev->irq") (not a Fixes: tag)
- No Fixes:, no Cc: stable, no Reported-by/Tested-by on the committed version (those were requested on-list but not folded in)
- Ignore pipeline-added Sasha Levin SOB if present (not on this commit)
**Step 1.3: Body**
Record:
- **Bug:** Guest VFIO assignment virtualizes PCI_INTERRUPT_PIN to 0 when INTx is not connected / not routable.
- **Mechanism:** For qla25/27/28xx and qla2031, the driver does ha->port_no-- on that register. port_no is uint8_t, so 0 wraps to 255.
- **Symptom:** flt_region_nvram is never selected (only ports 0–3 are matched). NVRAM is read from the wrong/zero flash offset. Logs:
- Inconsistent NVRAM checksum=0xffffffc0 id=HCAM version=0x100
- Falling back to functioning (yet invalid -- WWPN) defaults
- NVRAM configuration failed
- **User-visible result:** LUN detection fails; the HBA does not present storage in the guest.
- **Fix:** If PIN is 0, set port_no from PCI_FUNC(devfn), matching other qla2xxx paths.
**Step 1.4: Hidden bug fix?**
Record: No. This is an explicit functional bug fix, not cleanup disguised as a fix.
---
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- File: drivers/scsi/qla2xxx/qla_os.c (+10 / −5)
- Function: qla2x00_set_isp_flags()
- Scope: single-file surgical change
**Step 2.2: Code flow**
Before (verified on 7268e509b43ac^):
```c
pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no);
if (IS_QLA25XX(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha) ||
IS_QLA28XX(ha))
ha->port_no--;
else
ha->port_no = !(ha->port_no & 1);
```After: if PIN is 0, ha->port_no = PCI_FUNC(ha->pdev->devfn); else keep the old mapping.
This is probe/init (qla2x00_probe_one → qla2x00_set_isp_flags), not an error path.
**Step 2.3: Bug category**
Record: **Logic / correctness + hardware/virt workaround**, with a **uint8_t underflow**.
Verified:
- qla_def.h: uint8_t port_no — decrement of 0 → 255.
- qla_sup.c qla2xxx_get_flt_info() only assigns flt_region_nvram when port_no is 0, 1, 2, or 3. 255 never matches.
- ha is kzalloc’d, so flt_region_nvram stays 0; NVRAM is then read from flash offset 0.
- qla81xx/27xx NVRAM path at qla_init.c:10044–10288 emits exactly log IDs 0x0073 / 0x0074 / 0x0076 from the commit message.
- Fallback WWPNs are invalid → LUN discovery fails.
**Step 2.4: Fix quality**
Record: Obviously correct. PIN 0 means “no INTx”; using PCI function number is already how this driver sets ha->portnum for 83xx/82xx/etc. Bare-metal cards with PIN 1–4 are unchanged. Regression risk is low: the new branch only runs when PIN is 0, which previously produced a useless port number (255) on the 25/27/28/2031 path.
---
## Phase 3: Git history
**Step 3.1: Blame**
Record:
- pci_read_config_byte(..., PCI_INTERRUPT_PIN, &ha->port_no) introduced in a9083016a5314b (2010, ISP82XX support).
- Decrement / !(pin & 1) mapping in f73cb695d3eccd (2014, ISP2071).
- The underflow is old; it became commonly hit after VFIO started virtualizing PIN as 0.
**Step 3.2: Fixes tag**
Record: No Fixes: tag. Related cause: 2bd42b03ab6b (`vfio/pci:
Virtualize zero INTx PIN if no pdev->irq, 2025-04-14). That commit **is** an ancestor of this tree (git merge-base --is-ancestor` exit 0). It was reported/tested by the same author (Shivaprasad G Bhat).
**Step 3.3: File history**
Record: Standalone one-patch series. Later 3571ef0515640 (QLA29xx support) merged this PIN==0 check with an extra IS_QLA29XX in the decrement branch. No prerequisite refactor is required for the original hunk.
**Step 3.4: Author**
Record: Shivaprasad G Bhat (IBM). Other nearby work is powerpc/vfio/iommu, not qla2xxx maintainer. Reviewer Kyle Mahlkuch is also IBM. SCSI maintainer Martin K. Petersen applied it.
**Step 3.5: Dependencies**
Record: Self-contained. No new APIs. Does not require vfio source changes; it only reacts to PIN=0 in config space. Can apply standalone to any tree that still has the old decrement logic.
---
## Phase 4: Mailing list / external
**Step 4.1: Original discussion**
Record:
- b4 dig -c 7268e509b43ac → https://patch.msgid.link/177885270578.1573
[email protected]
- b4 dig -a: **v1 only** (single standalone patch).
- Thread saved to mbox (lore HTTP 403 via WebFetch; mbox succeeded).
- Reviewer feedback:
- Priya A: tested, asked for Reported-by/Tested-by (not added in the committed version).
- Kyle Mahlkuch: “look reasonable and fix a known bug” + `Reviewed-
by`.
- Madhavan Srinivasan: ping for comments; no NAK.
- Martin K. Petersen: applied to **7.3/scsi-queue**.
- Author then asked to also land in **7.2**. Martin: left it in 7.3 because of conflict with a large qla2xxx update that cycle, and told the author they **can post a stable backport request** once Linus merged SCSI.
No NAKs. Maintainer explicitly treated this as stable-worthy.
**Step 4.2: Recipients (b4 dig -w)**
Record: Marvell qla2xxx maintainers ([email protected], GR-QLogic- [email protected]), James Bottomley, Martin K. Petersen, linux-scsi, Alex Williamson (vfio), Kyle Mahlkuch.
**Step 4.3: Bug report**
Record: Concrete guest logs in the commit. Independent tester Priya A confirmed it fixes LUN detection. This is a real IBM-reported VFIO passthrough failure, not theoretical.
**Step 4.4: Series**
Record: Standalone [PATCH], not N/M.
**Step 4.5: Stable list**
Record: lore.kernel.org/stable search returned HTTP 403. From the scsi thread, the maintainer invited a stable request; no evidence of a NAK against stable.
---
## Phase 5: Semantic analysis
**Step 5.1: Functions**
Record: qla2x00_set_isp_flags() only.
**Step 5.2: Callers**
Record: Called once from qla2x00_probe_one() (qla_os.c:3090), the PCI .probe callback (qla_os.c:8360). Probe context, once per adapter.
**Step 5.3: Callees**
Record: pci_read_config_byte(), PCI_FUNC(), ISP type macros. No alloc/lock changes.
**Step 5.4: Reachability**
Record: Yes. Trigger: VFIO-assign a QLogic 25/27/28xx or 2031 HBA into a guest whose kernel runs this driver, when the platform does not connect INTx (pdev->irq == 0 or IRQ_NOTCONNECTED). Confirmed in vfio_pci_config.c:1833–1835. Userspace (hypervisor admin) can trigger this; unprivileged guest users then just see missing LUNs.
**Step 5.5: Similar patterns**
Record: PCI_FUNC(ha->pdev->devfn) is already used for ha->portnum in qla_os.c (83xx and others) and qla_nx.c. The fallback matches existing driver convention.
---
## Phase 6: Local tree (this checkout)
**Step 6.1: Does the buggy code exist here?**
Record:
- Tree: **Linux 7.3.0-rc4** (git describe HEAD = v7.3-rc4-27-gf0100363d8c37).
- qla2xxx is present. port_no is still uint8_t. FLT NVRAM selection still keys off port_no 0–3.
- VFIO PIN=0 virtualization is present (2bd42b03ab6b is an ancestor).
- The underflow logic **did exist** on this 7.3 line before 7268e509b43ac; that commit is already an ancestor of HEAD. Current qla2x00_set_isp_flags() already has the PIN==0 fallback, plus a later IS_QLA29XX merge.
**Step 6.2: Backport difficulty**
Record: On this 7.3-rc4 tree the fix is already merged. Cherry-picking again would be a no-op / conflict with the already-applied hunk plus QLA29xx. For *this* tree, the code change is already in place; no extra backport rework is needed for 7.3.
**Step 6.3: Related fixes already here?**
Record: This is the fix. The only later related edit is QLA29xx extending the same else if (still keeps the PIN==0 path). No alternate/competing fix.
---
## Phase 7: Subsystem context
**Step 7.1:**
Record: drivers/scsi/qla2xxx — **IMPORTANT** (widely used FC HBA in servers/SAN, including VFIO passthrough). Not core mm/vfs, but storage init failure is user-visible and serious for those systems.
**Step 7.2:**
Record: Actively developed (QLA29xx series and hardening landed after this commit in 7.3). The buggy PIN mapping itself dates to 2010/2014.
---
## Phase 8: Impact and risk
**Step 8.1: Who is affected**
Record: Driver-specific + config-specific: CONFIG_SCSI_QLA_FC guests (and hosts) where PCI_INTERRUPT_PIN reads as 0. Primary real-world trigger is VFIO passthrough when INTx is not routed (IBM Power and similar). Dual-port 25/27/28xx and 2031 adapters.
**Step 8.2: Trigger**
Record: Adapter probe in the guest. Deterministic once PIN is 0 — not a race. Hypervisor admin can trigger it; then LUNs never appear.
**Step 8.3: Failure mode**
Record: HBA comes up with invalid NVRAM/WWPN; **LUN detection fails**. Not a panic/UAF. Severity: **HIGH** (device non-functional, storage unavailable). Matches stable-rules “hardware quirk” / “oh, that's not good”.
**Step 8.4: Risk-benefit**
Record:
- Benefit: high for VFIO+qla2xxx users (adapter actually works).
- Risk: very low (10 lines, PIN==0 only, existing PCI_FUNC convention).
- Ratio: strongly favors including the fix in this tree.
---
## Phase 9: Synthesis
**Evidence FOR:**
- Real, tested LUN-detection failure with matching driver logs.
- uint8_t underflow is verified in this tree’s types and FLT matching.
- Tiny, obviously correct, no new API.
- Reviewed, maintainer-applied to 7.3; maintainer invited a stable backport.
- This 7.3 tree has both qla2xxx and the VFIO PIN=0 behavior.
**Evidence AGAINST:**
- Not a crash, UAF, or CVE.
- Affects VFIO passthrough more than bare metal (PIN is usually 1–4 on real silicon).
- Committed message omitted the tester’s Reported-by/Tested-by (quality of tags, not of the fix).
**Unresolved:** HTTP 403 on lore WebFetch (mbox was used instead). Stable-list search unverified beyond the scsi thread.
**Stable rules checklist:**
1. Obviously correct and tested? **PASS** (review + Priya A test + maintainer apply)
2. Real bug affecting users? **PASS** (LUN detection fails)
3. Important? **PASS** (HBA/storage unusable in VFIO guests — HIGH)
4. Small and contained? **PASS** (~15 lines, one function)
5. No new features/APIs? **PASS**
6. Applies to this local tree? **PASS** (7.3 already contains the change; the surrounding driver is present)
**Exception category:** Hardware/virt workaround (handle virtualized INTx PIN=0), analogous to a device quirk.
This tree is **7.3-rc4**. The qla2xxx PIN-to-port_no bug and VFIO PIN virtualization both exist on this line. The patch is a small, tested correctness fix that restores NVRAM/LUN discovery for passed-through QLogic adapters. It meets stable-kernel rules and belongs in this tree.
Verification:
- [Phase 1] Parsed subject/tags/body from git log -1 on 7268e509b43ac; no Fixes/Cc-stable; Reference 2bd42b03ab6b.
- [Phase 2] Diff is 15 lines in qla2x00_set_isp_flags; parent blob still has unconditional --.
- [Phase 2] port_no is uint8_t in qla_def.h:4319; FLT NVRAM only matches ports 0–3 in qla_sup.c.
- [Phase 2] Log IDs 0x0073/0x0074/0x0076 verified in qla_init.c.
- [Phase 3] Blame: PIN read a9083016a5314b (2010); decrement f73cb695d3eccd (2014).
- [Phase 3] git merge-base --is-ancestor 2bd42b03ab6b HEAD = yes; same for 7268e509b43ac.
- [Phase 3] Author log: IBM powerpc/vfio contributor; one qla2xxx commit.
- [Phase 4] b4 dig -c/-a/-w/-m: v1 only; scsi CCs including vfio and Marvell; mbox has Priya test, Kyle R-b, Martin apply + stable-backport invitation.
- [Phase 4] lore WebFetch 403 — UNVERIFIED via HTTP; used mbox instead.
- [Phase 5] Only caller: qla2x00_probe_one; VFIO sets PIN=0 at vfio_pci_config.c:1833–1835.
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4; current qla_os.c already has the PIN==0 path.
- [Phase 8] Failure: NVRAM fail → invalid WWPN → no LUNs; not a panic.
- UNVERIFIED: whether a stable@vger thread was later posted (lore/stable HTTP 403).
**YES**
drivers/scsi/qla2xxx/qla_os.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +10 -5
@@ -2803,11 +2803,16 @@ qla2x00_set_isp_flags(struct qla_hw_data *ha)else {/* Get adapter physical port no from interrupt pin register. */ pci_read_config_byte (ha->pdev,PCI_INTERRUPT_PIN , &ha->port_no); -if (IS_QLA25XX (ha) ||IS_QLA2031 (ha) || -IS_QLA27XX (ha) ||IS_QLA28XX (ha)) - ha->port_no--; -else - ha->port_no = !(ha->port_no &1 ); +if (ha->port_no ==0 ) { +/* None of INT[A|B|C|D] may be virtualized by vfio */ + ha->port_no =PCI_FUNC (ha->pdev->devfn); + }else { +if (IS_QLA25XX (ha) ||IS_QLA2031 (ha) || +IS_QLA27XX (ha) ||IS_QLA28XX (ha)) + ha->port_no--; +else + ha->port_no = !(ha->port_no &1 ); + } } ql_dbg_pci(ql_dbg_init, ha->pdev, 0x000b,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 comedi: pcmuio: Add sanity check to interrupt handler
In reply to Sasha LevinFrom: Ian Abbott <[email protected]>
[ Upstream commit 6f6f6644e011fa910db744e9978127a443b94001 ]
The driver requests an interrupt handler for the device, after setting device registers to disable interrupt generation. The interrupt handler should not be called prematurely unless the user-configured I/O port base address and/or IRQ number are incorrect or the hardware is bad.
For safety, check the dev->attached flag in the interrupt handler pcmuio_interrupt() to ensure the device has been fully set up, avoiding a possible null pointer dereference of dev->subdevices by pcmuio_handle_asic_interrupt().
Also make use of the IRQ_HANDLED(x) macro for the normal return path of the interrupt handler.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
- Record: [comedi: pcmuio:] [Add] sanity check to interrupt handler.
Intent: guard pcmuio_interrupt() so it does not run against a device that is not fully attached.
**Step 1.2: Tags**
- Record:
- Signed-off-by: Ian Abbott <[email protected]> (COMEDI maintainer)
- `Link:
https://patch.msgid.link/[email protected]`
- Signed-off-by: Greg Kroah-Hartman <[email protected]>
- No Fixes:, no Cc: stable, no Reported-by on this specific commit (expected for this review pipeline)
- Original submission CCs: Greg KH, H Hartley Sweeten, Jaeyoung Chung, Sangyun Kim, Kyungwook Boo
- The series cover letter and patch 01/11 carry Reported-by for those SNU reporters; this pcmuio patch inherited them only as CCs, not as tags
**Step 1.3: Body**
- Record: [Bug] IRQ handler can run after request_irq() but before the device is fully set up. [Symptom] possible NULL deref of dev->subdevices in pcmuio_handle_asic_interrupt(). [Trigger] premature IRQ unless I/O base and/or IRQ are wrong or hardware is bad. [Root cause] handler registered before subdevices exist / before dev->attached is set. Also switches the return to IRQ_RETVAL() (commit text says IRQ_HANDLED(x); that is a typo — the diff uses IRQ_RETVAL).
**Step 1.4: Hidden bug fix?**
- Record: Not hidden. Cover letter is explicit: “avoid null-ptr-deref”. The IRQ_RETVAL swap is cosmetic and equivalent.
## Phase 2: Diff analysis
**Step 2.1: Inventory**
- Record: drivers/comedi/drivers/pcmuio.c only; +4/−1. Function:
pcmuio_interrupt(). Single-file surgical fix.
**Step 2.2: Code flow**
- Record: Before: handler always calls pcmuio_handle_asic_interrupt() if the IRQ matches dev->irq / devpriv->irq2. After: if !dev->attached, return IRQ_NONE immediately. Then return IRQ_RETVAL(handled) instead of handled ? IRQ_HANDLED : IRQ_NONE (same meaning: `#define IRQ_RETVAL(x) ((x) ? IRQ_HANDLED :
IRQ_NONE)`).
**Step 2.3: Bug mechanism**
- Record: [NULL pointer dereference] in IRQ context. pcmuio_attach() does request_irq() at lines 549–567, then comedi_alloc_subdevices() at line 570. dev->attached is set only later in comedi_device_postconfig(). pcmuio_handle_asic_interrupt() does s = &dev->subdevices[asic * 2] and pcmuio_handle_intr_subdev() then uses s->index and s->async.
**Step 2.4: Fix quality**
- Record: Obviously correct and matches the established comedi pattern (if (!dev->attached) return IRQ_NONE). Minimal. Regression risk is
low: returning IRQ_NONE during attach/detach is the intended safe path, and this IRQ is requested with flags 0 (not shared). IRQ_RETVAL is behavior-preserving.
## Phase 3: Git history
**Step 3.1: Blame**
- Record: Handler/request_irq before comedi_alloc_subdevices dates to Hartley Sweeten, 2013 (04426acfb86ad1). Subdevice indexing in the
handler: 741ba8cdf0e938 (2013-12-06). Driver added in 2009 (6baef150380d56). Long-standing.
**Step 3.2: Fixes: tag**
- Record: None. Bug is structural in the attach vs IRQ order, not a recent regression.
**Step 3.3: File history**
- Record: Recent: 3d4ab5484aa24 (I/O-base sanity checks) then this commit. I/O-base patch is a different series and is not required for this hunk. Standalone.
**Step 3.4: Author**
- Record: Ian Abbott is listed as COMEDI maintainer in MAINTAINERS. This is one of an 11-patch “Add/fix sanity check in ISA drivers to avoid null-ptr-deref” series.
**Step 3.5: Dependencies**
- Record: None. Touches only pcmuio_interrupt(). IRQ_RETVAL has long existed in include/linux/irqreturn.h. Applies standalone.
## Phase 4: Mailing list / external
**Step 4.1: Original discussion**
- Record: b4 dig -c 6f6f6644e011f →
https://patch.msgid.link/[email protected]
([PATCH 10/11]). b4 dig -a: single v1 series, no later revisions. Mbox has the 11 patches + cover letter and **no replies/NAKs**. Cover
letter: several ISA drivers register the IRQ handler before subdevices are initialized → null deref on a premature IRQ.
**Step 4.2: Recipients (b4 dig -w)**
- Record: Ian Abbott, Greg KH, Hartley Sweeten, linux-kernel, plus the SNU reporters. Right maintainers were on the patch.
**Step 4.3: Bug report**
- Record: Original report https://lore.kernel.org/lkml/20260610115912.78
[email protected]/ — subject “comedi: KASAN null-ptr-deref in ISA driver IRQ handlers on early IRQ”. Lists das6402, ni_atmio16d, aio_iiro_16, pcmmio, comedi_parport, pcl711. **pcmuio was not in that list**; Abbott added it as the same pattern. Related comedi_parport fix (17221216ae8ce) was syzbot + Cc: stable.
**Step 4.4: Series**
- Record: 11 independent per-driver patches. This one does not need the others.
**Step 4.5: Stable list**
- Record: lore.kernel.org/stable search returned HTTP 403. UNVERIFIED whether this hash was discussed on stable@. The parport sibling was explicitly nominated.
## Phase 5: Semantic analysis
**Step 5.1: Functions**
- Record: pcmuio_interrupt(); callee pcmuio_handle_asic_interrupt().
**Step 5.2: Callers**
- Record: Only request_irq(..., pcmuio_interrupt, ...) in pcmuio_attach() (IRQ 1 and optional IRQ 2). IRQ context after userspace COMEDI_DEVCONFIG attach.
**Step 5.3: Callees**
- Record: pcmuio_handle_asic_interrupt() → inb() of pending register, then pcmuio_handle_intr_subdev() which touches s->async / s->index.
**Step 5.4: Reachability**
- Record: Yes. CONFIG_COMEDI_PCMUIO, comedi_config options [0] I/O base, [1]/[2] IRQ. Attach ioctl is typically privileged, but a wrong I/O/IRQ (or syzkaller-style config) can fire the handler before comedi_alloc_subdevices().
**Step 5.5: Similar patterns**
- Record: Dozens of comedi drivers already check dev->attached in IRQ handlers. Same series adds/fixes aio_iiro_16, das6402, pcmmio, ni_atmio16d, etc.
## Phase 6: This tree
**Step 6.1: Local tree / buggy code**
- Record: git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4. File and attach-vs-IRQ order are present. git merge-base --is-ancestor 6f6f6644e011f HEAD is true (commit is in 7.3-rc1, not in v7.2). Evaluating technical need: the driver and the race exist on this lineage.
**Step 6.2: Backport difficulty**
- Record: Clean apply on this tree (hunk is isolated). No refactor of pcmuio_interrupt() between the 2013 code and this patch.
**Step 6.3: Related fixes already here**
- Record: This exact check is already the current code (because 7.3 already contains the commit). No alternate fix for pcmuio. That is not used as “already selected” circular reasoning; it only confirms the change matches the tree.
## Phase 7: Subsystem context
**Step 7.1**
- Record: [comedi / pcmuio ISA-PC/104 DIO] [PERIPHERAL] — Winsystems PCM-UIO48A/96A. Not core mm/net, but a real in-tree driver (out of staging).
**Step 7.2**
- Record: COMEDI status in MAINTAINERS: “Odd Fixes”. Recent burst is this ISA sanity-check series. Driver itself is mature (2009/2013).
## Phase 8: Impact and risk
**Step 8.1: Who is affected**
- Record: Users of CONFIG_COMEDI_PCMUIO who pass an IRQ into attach. Driver-specific, not universal.
**Step 8.2: Trigger**
- Record: Window after request_irq(), before comedi_alloc_subdevices() / dev->attached = true. Also misconfigured I/O base (garbage inb of pending bits) or bad hardware. Not every boot; attach-time. Usually requires CAP_SYS_ADMIN for comedi attach; still a kernel oops, and the same class was KASAN/syzbot-reachable on sibling drivers.
**Step 8.3: Failure mode**
- Record: KASAN/NULL deref in IRQ handler → oops/panic. `[Severity:
HIGH/CRITICAL] for that path. pcmuio_reset() clears PCMUIO_PAGE_ENAB` first, so a well-configured board is less likely to fire; wrong I/O/IRQ still makes pending-bit checks unsafe.
**Step 8.4: Risk-benefit**
- Record: Benefit: prevents IRQ-time oops on a reachable attach path.
Risk: four lines, established pattern, no API/locking change. Ratio is favorable.
## Phase 9: Synthesis
**Step 9.1: Evidence**
- FOR: Real NULL deref in IRQ context; KASAN-class bug reported for this ISA attach pattern; maintainer-authored; 4-line check used across comedi; sibling parport fix had syzbot + stable CC; driver and race exist in this tree; no series dependency.
- AGAINST: Peripheral PC/104 driver; IRQ support commented “untested”; pcmuio not named in the original SNU list (same bug, extra driver); no Fixes:/Cc: stable on this commit (not a negative per the rules); attach is typically privileged.
- UNRESOLVED: stable@ thread 403; no mailing-list replies in the saved mbox.
**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** — standard dev->attached guard; IRQ_RETVAL equivalent.
2. Real user-visible bug? **PASS** — NULL deref / oops if IRQ runs before subdevices exist.
3. Important (crash/security/corruption/deadlock)? **PASS** — IRQ- context oops.
4. Small and contained? **PASS** — +4/−1, one function.
5. No new features/APIs? **PASS**.
6. Applies to this tree? **PASS** — code is here; hunk is independent.
**Step 9.3: Exception category**
- Record: None needed; it is a normal crash fix.
**Step 9.4: Decision**
This tree is Linux 7.3.0-rc4. The pcmuio attach path registers pcmuio_interrupt before comedi_alloc_subdevices(), so a premature IRQ can take dev->subdevices while it is still NULL and oops in pcmuio_handle_intr_subdev(). The patch is a four-line dev->attached guard plus an equivalent IRQ_RETVAL return — the same pattern already used throughout comedi, written by the subsystem maintainer after a KASAN null-deref report on this ISA class. It is small, obviously correct, and worth having on this tree.
Verification:
- [Phase 1] Parsed tags: Ian Abbott SOB, Greg KH SOB, lore Link; no Fixes/Cc stable/Reported-by on this commit
- [Phase 1] Cover letter (mbox MSG 7): explicit null-ptr-deref series for ISA IRQ handlers
- [Phase 2] Diff: +4/−1 in pcmuio_interrupt(); IRQ_RETVAL confirmed in include/linux/irqreturn.h
- [Phase 2] pcmuio_attach(): request_irq at 551/563, comedi_alloc_subdevices at 570
- [Phase 2] comedi_device_postconfig() sets dev->attached = true only after attach returns
- [Phase 3] blame: request_irq-before-alloc from 04426acfb86ad1 (2013)
- [Phase 3] git merge-base --is-ancestor 6f6f6644e011f HEAD → yes; not ancestor of v7.2; is ancestor of v7.3-rc1
- [Phase 4] b4 dig -c 6f6f6644e011f: patch 10/11, msgid 20260618102949.26607-11
- [Phase 4] b4 dig -a: v1 only; b4 dig -w: Greg KH + Hartley Sweeten
+ SNU reporters
- [Phase 4] Original report fetched: KASAN null-ptr-deref in ISA IRQ handlers; pcmuio not listed, same attach order
- [Phase 4] lore.kernel.org/stable 403 — UNVERIFIED stable@ discussion
- [Phase 5] only caller is request_irq in pcmuio_attach
- [Phase 6] local tree v7.3-rc4-27-gf0100363d8c37 / 7.3.0-rc4; driver present
- [Phase 8] failure mode: NULL deref in IRQ handler → oops
- UNVERIFIED: whether anyone requested this exact hash on stable@
**YES**
drivers/comedi/drivers/pcmuio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/comedi/drivers/pcmuio.c +4 -1
@@ -362,12 +362,15 @@ static irqreturn_t pcmuio_interrupt(int irq, void *d)struct pcmuio_private *devpriv = dev->private;int handled =0 ; +if (!dev->attached) +return IRQ_NONE ; +if (irq == dev->irq) handled +=pcmuio_handle_asic_interrupt (dev,0 );if (irq == devpriv->irq2) handled +=pcmuio_handle_asic_interrupt (dev,1 ); -return handled ?IRQ_HANDLED :IRQ_NONE ; +return IRQ_RETVAL (handled); }/* chip->spinlock is already locked */
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 perf/arm-cmn: Add workarounds for CMN-S3 on Graviton5
In reply to Sasha LevinFrom: Aviv Bakal <[email protected]>
[ Upstream commit 9d0b1714e1af16622a2d0f7317ddaa9a4b27f353 ]
Graviton5 uses a customised CMN-S3 implementation where certain discovery registers report zeroed fields. Add the following workarounds:
- Introduce a dedicated ACPI HID to identify the Graviton5 CMN variant.
- Derive the DTC domain from the XP node ID, since the unit info register reports it as zero.
- Set the DTC logical ID from the XP's logical ID, since the node info register's logical ID field is also zeroed.
---
LLM Generated explanations, may be completely bogus:
The local tree is **v7.3-rc4** (kernel 7.3.0-rc4). The question is whether 9d0b1714e1af1 (perf/arm-cmn: Add workarounds for CMN-S3 on Graviton5) belongs in **this** tree on technical merit.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [perf/arm-cmn] [Add] [workarounds for a customised CMN-S3 on Graviton5]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Fixes: — none (expected)
- Reported-by: — none
- Tested-by: — none
- Reviewed-by: Robin Murphy <[email protected]> (arm-cmn maintainer)
- Reviewed-by: Ilkka Koskinen <[email protected]>
- Link: — none in the commit
- Cc: [email protected] — none (expected)
- Signed-off-by: Aviv Bakal <[email protected]> (author)
- Signed-off-by: Robin Murphy <[email protected]>
- Signed-off-by: Will Deacon <[email protected]>
- Ignored: any Sasha Levin SOB / Upstream-commit markers
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** Graviton5’s CMN-S3 zeros some discovery fields (DTC domain in unit info, logical ID in node info).
- **Symptom:** Standard discovery cannot identify DTC domains or DTC logical IDs; a 10×14 mesh also exceeds CMN_MAX_DIMENSION 12.
- **Version info:** none in the message.
- **Root cause:** custom silicon, not a kernel logic regression. Identified via ACPI HID AMZN0070.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is an explicit hardware workaround plus ACPI ID. Cover letter language is “adds support”; the mechanism is a quirk for broken discovery registers.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/perf/arm-cmn.c (+31 / −1)
- Functions: arm_cmn_graviton5_dtc_domain (new), arm_cmn_discover (workaround + DTC logid), arm_cmn_acpi_match[] (HID)
- Also: CMN_MAX_DIMENSION 12→14, PART_GRAVITON5
- Scope: single-file, surgical, driver-local
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Dimension cap 12→14 so a 10×14 mesh is not rejected.
- ACPI AMZN0070 → synthetic PART_GRAVITON5, then treated as PART_CMN_S3.
- DTC domain: from unit-info register → from XP node ID (x/5)+(y/7)*2 on the 10×14 mesh (domains 0–3).
- DTC logid: from node info → XP logid so sort order matches firmware IRQ order.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Hardware workaround + ACPI device ID.** Zeroed discovery fields would map every XP to DTC domain 0 and every DTC logid to 0. Mesh 10×14 fails max(mesh_x,mesh_y) > CMN_MAX_DIMENSION (36c0de02575ce, already in this tree).
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Quality: small, gated on AMZN0070 except the dimension bump. Maintainer R-b’d after review (v1 used xp->logid; v2 used xp->dtc; Robin required xp->logid because cmn->dtc[] is sorted by logid to match firmware IRQ order). Committed code matches that.
- Regression risk: low. Workaround is HID-gated. CMN_MAX_DIMENSION 14 only grows per-event bitmaps (CMN_MAX_XPS 144→196). Domain formula is Graviton5-specific; x,y are 4-bit so theoretical max domain is 7, but 10×14 yields 0–3 (CMN_MAX_DTCS is 4).
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Workaround and dimension bump introduced by 9d0b1714e1af1 itself (Aviv Bakal, 2026-06-30; merged 2026-07-21).
- Driver: long-standing. CMN-S3: 0dc2f4963f7ef (2024-09-04). ACPI ARMHC003: 8c138a189f6db (2025-05-19). Mesh reject: 36c0de02575ce (2026-02-03, Cc: stable).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not a regression from a specific kernel commit; hardware does not implement discovery as the driver expects.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- This is **v6 2/2**. Patch 1 is 56603c28d9169 (Move DTM index data out of hw_perf_event) — **already an ancestor of HEAD**. Needed because embedded dtm_idx/wp_idx in hw_perf_event were size- capped; growing CMN_MAX_DIMENSION without that move would fail static_assert(sizeof(struct arm_cmn_hw_event) <= offsetof(struct hw_perf_event, target)).
- Later 7.3 work (filter refactor, CMN S3 r2) does not revert the workaround. No graviton-specific follow-up.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Aviv Bakal (Amazon) — this is their only arm-cmn commit here. Robin Murphy is the driver author/maintainer and both reviewed and re- posted v6.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs CMN-S3, ACPI table, mesh-size check, and the DTM-index move. **All are in this 7.3-rc4 tree.** Standalone on this tree.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 9d0b1714e1af1 → https://patch.msgid.link/e9340d3a4385e6f1a
[email protected]
- Revisions: v1 (2026-05-03) → v2 → v3 (added DTM move) → v4 → v5 → **v6 applied** (Robin re-post, 2026-06-30)
- Robin on v2: use xp->logid not xp->dtc; “surprisingly pleasant and unobtrusive given that it's a pretty horrible hardware issue”
- No NAK. Applied version is latest.
- A sashiko-bot note about unbounded DTC domain / sort order is the opposite of Robin’s requested xp->logid behaviour; not a NAK from maintainers.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): Robin Murphy, Will Deacon, Mark Rutland, linux- arm-kernel, linux-perf-users, Amazon (zeev, blakgeof), Ilkka Koskinen. Right maintainers.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla. Amazon submitted from silicon bring-up.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Series is DTM-index move + this workaround. Patch 1 is in this tree. No extra ACPI docs/HID patch required (AMZN0070 is only in arm- cmn.c).
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search returned 403. **UNVERIFIED:** no confirmed stable-list nomination or rejection.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: arm_cmn_graviton5_dtc_domain, arm_cmn_discover, arm_cmn_acpi_match, arm_cmn_init_node_info (unchanged, still source of zeroed logid).
**Step 5.2: TRACE CALLERS**
Record: arm_cmn_discover() ← arm_cmn_probe() only. Probe runs when ACPI matches (including AMZN0070). Not IRQ/syscall hot path; boot/device-init.
**Step 5.3: TRACE CALLEES**
Record: arm_cmn_init_node_info, arm_cmn_dtc_domain / graviton5 variant, arm_cmn_init_dtm, then arm_cmn_init_dtcs (sort by type+logid, platform_get_irq by sort index).
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: ACPI AMZN0070 → probe → discover (workaround) → init DTCs/IRQs → register PMU. Userspace perf then uses the interconnect PMU. Reachable on Graviton5 with CONFIG_ARM_CMN.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same file already has AmpereOneX bogus-child-pointer handling and CMN-600AE aliasing. Same “quirks for broken discovery” pattern.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. drivers/perf/arm-cmn.c has CMN-S3, ACPI match, mesh-size reject. Without this commit, AMZN0070 would not bind; a 10×14 mesh would -ENODEV; zeroed DTC fields would mis-program the PMU. Introduced as hardware behaviour, not a post-7.3 commit.
git describe HEAD = v7.3-rc4-27-gf0100363d8c37. Commit is in v7.3-rc1 (not in v7.2). That is **not** used as “already selected”; it only shows 7.3 has the prerequisites.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean on this tree. Context still matches (graviton5 flag, ACPI HID, dimension 14). Later S3 r2/filter refactors left the workaround in place.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No alternate Graviton5 fix. No later graviton-specific patch in 9d0b1714e1af1..HEAD.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/perf/ — Arm CMN uncore PMU. **PERIPHERAL/IMPORTANT:** ARM64 servers with CMN; Graviton5-specific for the HID path. Not mm/sched/VFS.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Active in 7.3 (S3 r2, filters, DTM layout). Driver itself is mature (~CMN-600 era).
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: ACPI AMZN0070 / Graviton5 only, plus a small extra bitmap size for all CONFIG_ARM_CMN users.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Probe on Graviton5. Not unprivileged-triggerable beyond normal perf. Not a race. Common on that platform at boot.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Missing/wrong CMN PMU (no bind, -ENODEV, or events on the wrong DTC). Not panic/corruption/deadlock. **MEDIUM** for that hardware; still the documented quirk/ID exception.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: Graviton5 CMN perf actually works (HID + discovery + 10×14 mesh).
- Risk: low (~31 lines, HID-gated, maintainer-reviewed). Dimension bump is small and already paired with the DTM-index move in this tree.
- Ratio: favorable.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- ACPI ID + hardware quirk on an existing driver (stable exception).
- Real silicon: zeroed CMN-S3 discovery, 10×14 mesh.
- Small, single-file, obviously correct after maintainer review.
- Prerequisites present in 7.3-rc4.
- Robin Murphy: use xp->logid; workaround is unobtrusive.
**AGAINST:**
- Enablement/quirk, not a crash/security/corruption fix.
- Cover letter is “add support”.
- CMN_MAX_DIMENSION affects all CMN bitmap sizes (small).
- Series 2/2 (patch 1 already here).
- No Reported-by from production crashes.
**UNRESOLVED:**
- Stable list discussion (lore 403).
- No public Tested-by (author is Amazon; hardware access is plausible but unverified).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — maintainer R-b after v1–v6; IRQ/logid issue addressed as Robin specified.
2. Fixes a real bug that affects users? **PASS** — Graviton5 CMN PMU cannot enumerate correctly without it.
3. Important issue? **PASS** via quirk/ID exception (severity MEDIUM as a PMU, not a panic).
4. Small and contained? **PASS** — +31/−1, one file.
5. No new features or APIs? **PASS** — no new uAPI; HID + discovery workaround on existing PMU.
6. Can apply to the local tree? **PASS** — driver, CMN-S3, DTM-index move, mesh check all present.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **ACPI device ID** (AMZN0070) **and hardware quirk** for customised CMN-S3.
**Step 9.4: MAKE YOUR DECISION**
This tree is 7.3-rc4, which already contains CMN-S3 and the series prerequisite. The patch is the standard stable shape: ID + quirk so existing arm-cmn works on shipping Graviton5. Benefit is real for that platform; risk is low and mostly HID-gated.
---
## What the commit solves and why it matters here
Graviton5 implements CMN-S3 with discovery registers that read as zero and a 10×14 mesh. In this tree, arm_cmn_discover() would then put every XP in DTC domain 0, leave DTC logids at 0 (breaking IRQ sort order), and reject the mesh as larger than 12. Adding AMZN0070 and the three workarounds makes the existing CMN PMU usable on that hardware without new APIs.
It meets stable rules as a quirk/ID exception: small, reviewed, no uAPI, applies cleanly here because 56603c28d9169 already moved DTM arrays out of hw_perf_event.
Risk vs benefit: extra bitmap bytes for all CMN users vs a working interconnect PMU on Graviton5. Favorable.
Concerns: not a panic-class bug; depends on the DTM-index move (already in this tree). No stable-list confirmation (fetch failed).
---
## Verification
- [Phase 1] Parsed tags: R-b Robin Murphy + Ilkka Koskinen; SOB Aviv Bakal, Robin Murphy, Will Deacon; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: drivers/perf/arm-cmn.c +31/−1; HID AMZN0070, CMN_MAX_DIMENSION 14, DTC domain/logid workarounds
- [Phase 2] Current tree still has graviton5 paths at arm_cmn_discover / arm_cmn_graviton5_dtc_domain / ACPI table
- [Phase 3] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- [Phase 3] git merge-base --is-ancestor 9d0b1714e1af1 HEAD — yes; in v7.3-rc1, not v7.2
- [Phase 3] CMN-S3 0dc2f4963f7ef (2024-09-04) in tree; ACPI S3 8c138a189f6db in tree
- [Phase 3] Mesh reject 36c0de02575ce in tree; DTM move 56603c28d9169 in tree (series 1/2)
- [Phase 3] git blame on workaround lines → 9d0b1714e1af1
- [Phase 3] No graviton follow-ups in 9d0b1714e1af1..HEAD
- [Phase 4] b4 dig -c 9d0b1714e1af1 → v6 2/2 msgid e9340d3a4385e6f1a6 [email protected]
- [Phase 4] b4 dig -a: v1–v6; applied is v6
- [Phase 4] b4 dig -w: Will/Mark/Robin, linux-arm-kernel, linux-perf- users
- [Phase 4] Robin v2 review: must use xp->logid for firmware IRQ order (committed code does)
- [Phase 4] UNVERIFIED: lore.kernel.org/stable (403)
- [Phase 5] arm_cmn_discover only from arm_cmn_probe; ACPI match includes AMZN0070
- [Phase 6] Buggy discovery path and mesh check exist in this checkout; apply is clean
- [Phase 7] CONFIG_ARM_CMN depends on ARM64 || COMPILE_TEST
- [Phase 8] Failure: missing/wrong CMN PMU on Graviton5, not oops/deadlock; severity MEDIUM + quirk exception
- UNVERIFIED: Amazon Tested-by on silicon (not in tags)
**YES**
drivers/perf/arm-cmn.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)
drivers/perf/arm-cmn.c +31 -1
@@ -31,7 +31,8 @@#define CMN_CHILD_NODE_ADDR GENMASK(29, 0)#define CMN_CHILD_NODE_EXTERNAL BIT(31) -#define CMN_MAX_DIMENSION 12 +/* Some implementations use a mesh larger than the architectural max of 12 */ +#define CMN_MAX_DIMENSION 14#define CMN_MAX_XPS (CMN_MAX_DIMENSION * CMN_MAX_DIMENSION)#define CMN_MAX_DTMS (CMN_MAX_XPS + (CMN_MAX_DIMENSION - 1) * 4)
@@ -215,6 +216,8 @@ enum cmn_part {PART_CMN700 =0x43c ,PART_CI700 =0x43a ,PART_CMN_S3 =0x43e , +/* Synthetic part number, overridden to PART_CMN_S3 during discovery */ + PART_GRAVITON5 = 0xa5, };/* CMN-600 r0px shouldn't exist in silicon, thankfully */
@@ -2217,6 +2220,18 @@ static unsigned int arm_cmn_dtc_domain(struct arm_cmn *cmn, void __iomem *xp_regreturn FIELD_GET (CMN_DTM_UNIT_INFO_DTC_DOMAIN ,readl_relaxed (xp_region + offset)); } +static unsigned int arm_cmn_graviton5_dtc_domain (u16 xp_id) +{ +unsigned int x = (xp_id >>7 ) &0xf ; +unsigned int y = (xp_id >>3 ) &0xf ; + +/* +* The unit info register reads as zero; derive the DTC domain from +* the XP's mesh coordinates over the 10x14 mesh. +*/ +return (x /5 ) + (y /7 ) *2 ; +} +static void arm_cmn_init_node_info (struct arm_cmn *cmn,u32 offset,struct arm_cmn_node *node) {int level;
@@ -2262,6 +2277,7 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)u64 reg;int i, j;size_t sz; +bool graviton5_workaround = false;arm_cmn_init_node_info (cmn, rgn_offset, &cfg);if (cfg.type !=CMN_TYPE_CFG )
@@ -2272,6 +2288,13 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset) reg =readq_relaxed (cfg_region +CMN_CFGM_PERIPH_ID_01 ); part =FIELD_GET (CMN_CFGM_PID0_PART_0 , reg); part |=FIELD_GET (CMN_CFGM_PID1_PART_1 , reg) <<8 ; + +/* Graviton5 has a customised CMN-S3 which needs some fixups */ +if (cmn->part ==PART_GRAVITON5 ) { + cmn->part =PART_CMN_S3 ; + graviton5_workaround = true; + } +/* 600AE is close enough that it's not really worth more complexity */ if (part ==PART_CMN600AE ) part =PART_CMN600 ;
@@ -2361,6 +2384,8 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)if (cmn->part ==PART_CMN600 ) xp->dtc =-1 ; +else if (graviton5_workaround) + xp->dtc =arm_cmn_graviton5_dtc_domain (xp->id);else xp->dtc =arm_cmn_dtc_domain (cmn, xp_region);
@@ -2439,6 +2464,10 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)switch (dn->type) {case CMN_TYPE_DTC : +if (graviton5_workaround) { +/* Node info logical ID is zeroed; use the XP's */ + dn->logid = xp->logid; + } cmn->num_dtcs++; dn++;break ;
@@ -2671,6 +2700,7 @@ static const struct acpi_device_id arm_cmn_acpi_match[] = { { "ARMHC650" }, { "ARMHC700" }, { "ARMHC003" }, + { "AMZN0070", PART_GRAVITON5 }, {} };MODULE_DEVICE_TABLE (acpi, arm_cmn_acpi_match);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18] perf/arm-cmn: Add workarounds for CMN-S3 on Graviton5
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] perf/arm-cmn: CMN_MAX_DIMENSION bump breaks 32-bit COMPILE_TEST static_assert --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] perf/arm-cmn: CMN_MAX_DIMENSION bump breaks 32-bit COMPILE_TEST static_assert --
commit 27fbc22fac85b996ea007fe76c639085d36b43ec
Author: Aviv Bakal <[email protected]>
perf/arm-cmn: Add workarounds for CMN-S3 on Graviton5
This commit adds an ACPI HID and discovery workarounds for the customised CMN-S3 implementation on Graviton5, and raises CMN_MAX_DIMENSION from 12 to 14 to support its 10x14 mesh.
drivers/perf/arm-cmn.c line 37
Quoted 13 lines
drivers/perf/arm-cmn.c +2
-1@@ -31,7 +31,8 @@#define CMN_CHILD_NODE_ADDR GENMASK(29, 0)#define CMN_CHILD_NODE_EXTERNAL BIT(31) -#define CMN_MAX_DIMENSION 12 +/* Some implementations use a mesh larger than the architectural max of 12 */ +#define CMN_MAX_DIMENSION 14#define CMN_MAX_XPS (CMN_MAX_DIMENSION * CMN_MAX_DIMENSION)#define CMN_MAX_DTMS (CMN_MAX_XPS + (CMN_MAX_DIMENSION - 1) * 4)
[Severity: Medium]
Does raising CMN_MAX_DIMENSION to 14 break 32-bit builds when CONFIG_ARM_CMN is enabled under CONFIG_COMPILE_TEST?
Upstream commit 9d0b1714e1af1 ("perf/arm-cmn: Add workarounds for CMN-S3 on Graviton5") was patch 2/2 of a series depending on upstream commit 56603c28d9169 ("perf/arm-cmn: Move DTM index data out of hw_perf_event"), which moved dtm_idx and wp_idx out of struct arm_cmn_hw_event.
Without that prerequisite commit in this tree, struct arm_cmn_hw_event in drivers/perf/arm-cmn.c still embeds both arrays:
struct arm_cmn_hw_event {
struct arm_cmn_node *dn;
u64 dtm_idx[DIV_ROUND_UP(CMN_MAX_NODES_PER_EVENT * 2, 64)];
s8 dtc_idx[CMN_MAX_DTCS];
u8 num_dns;
u8 dtm_offset;
/*
* WP config registers are divided to UP and DOWN events. We need to
* keep to track only one of them.
*/
DECLARE_BITMAP(wp_idx, CMN_MAX_XPS);
bool wide_sel;
enum cmn_filter_select filter_sel;
};static_assert(sizeof(struct arm_cmn_hw_event) <= offsetof(struct hw_perf_event, target));
Increasing CMN_MAX_DIMENSION from 12 to 14 grows CMN_MAX_XPS and CMN_MAX_NODES_PER_EVENT from 144 to 196. That expands dtm_idx from 5 to 7 u64 elements (+16 bytes) and wp_idx on 32-bit architectures from 5 to 7 unsigned longs (+8 bytes), increasing sizeof(struct arm_cmn_hw_event) from 88 to 112 bytes (or from 80 to 104 bytes on i386).
On 32-bit architectures, unsigned long in struct hw_perf_event (include/linux/perf_event.h) is 4 bytes, so offsetof(struct hw_perf_event, target) is only 104 bytes (or 96 bytes on i386), causing the static_assert to fail at compile time.
Should upstream commit 56603c28d9169 ("perf/arm-cmn: Move DTM index data out of hw_perf_event") also be included as a prerequisite?
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH AUTOSEL 6.18] perf/arm-cmn: Add workarounds for CMN-S3 on Graviton5
In reply to Sasha LevinPlease drop this from AUTOSEL -- it's new-silicon enablement, and its parent commit 56603c28d916 isn't in 6.18.y, so the static_assert in arm-cmn.c would fail.
Thanks,
Aviv
Sasha Levin
maintainerRe: [PATCH AUTOSEL 6.18] perf/arm-cmn: Add workarounds for CMN-S3 on Graviton5
Quoted 3 lines · Aviv Bakal
Please drop this from AUTOSEL -- it's new-silicon enablement, and its parent commit
56603c28d916isn't in 6.18.y, so thestatic_assertinarm-cmn.cwould fail.
Dropped, thanks.
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 1/1 soc: mediatek: add missing MODULE_DEVICE_TABLE()
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit ec762057868d70d474a9816e9c293c2ef801c3c9 ]
The driver has an OF match table wired to .of_match_table, but does not export the table with MODULE_DEVICE_TABLE().
Add the missing MODULE_DEVICE_TABLE(of, ...) entry so module alias information is generated for OF based module autoloading.
This is a source-level fix. It does not claim dynamic hardware reproduction; the evidence is the driver-owned match table, its use by the platform driver, and the missing module alias publication.
---
LLM Generated explanations, may be completely bogus:
The local checkout is **7.3-rc4**. The DVFSRC driver is modular, had an OF match table, and did not publish aliases, so autoload is broken for CONFIG_MTK_DVFSRC=m. That is a real, one-line hardware-enablement bug.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[soc: mediatek] [add] [missing MODULE_DEVICE_TABLE() for OF module autoload]**
- Subsystem: soc: mediatek
- Verb: **add** (missing export; the body is a fix, not a feature)
- Intent: publish the existing OF match table as module aliases
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Verified from git show ec762057868d70:
- Signed-off-by: Pengpeng Hou \<[email protected]\> (author)
- Signed-off-by: AngeloGioacchino Del Regno \<[email protected]\> (MediaTek SoC maintainer; applied the patch)
- No Fixes:, Reported-by, Tested-by, Reviewed-by, Acked-by, Link:, or
Cc: stable
- Absence of Fixes:/Cc: stable is expected for this review and is not a negative
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** OF match table is wired to .of_match_table but not exported via MODULE_DEVICE_TABLE(of, ...)
- **Symptom:** depmod/file2alias never emit of:N*T*Cmediatek,mtXXXX-dvfsrc aliases, so udev/kmod will not autoload mtk-dvfsrc.ko
- **Version info:** none in the message. Driver landed in v6.13; this fix is in v7.3-rc4
- **Root cause:** forgotten alias publication on a tristate module_platform_driver
The extra “source-level fix / no dynamic hardware reproduction” paragraph is in the original lore submission as well (not a stable- pipeline marker).
Step 1.4: DETECT HIDDEN BUG FIXES
Record: **Not hidden.** It is an explicit autoload/modalias bug fix disguised only by the verb “add”. Same class as a missing device-ID table export.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/soc/mediatek/mtk-dvfsrc.c (**+1 / −0**)
- One line after mtk_dvfsrc_of_match[]
- Scope: **single-file surgical fix**
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- **Before:** match table exists and is used for platform binding, but no __mod_of__mtk_dvfsrc_of_match alias is generated
- **After:** MODULE_DEVICE_TABLE(of, mtk_dvfsrc_of_match) creates that alias for scripts/mod/file2alias.c
- Affected path: **module build / autoload**, not probe logic. Built-in (=y) is unchanged at runtime
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- **Category:** hardware enablement / missing module alias (OF equivalent of a missing device ID table)
- **Mechanism:** without MODULE_DEVICE_TABLE, kmod cannot map DT compatible to mtk-dvfsrc.ko. Probe never runs unless the module is loaded by hand
- Not UAF, leak, race, or locking
Step 2.4: ASSESS THE FIX QUALITY
Record:
- **Obviously correct:** one standard macro next to the table, same pattern as mtk-mmsys.c, mtk-svs.c, mtk-mutex.c in this tree
- **Regression risk: negligible.** No runtime code, locking, or API change; only .modinfo aliases when built as a module
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Match table introduced in **192514ae05687** (“Add MediaTek DVFS Resource Collector (DVFSRC) driver”, AngeloGioacchino Del Regno, 2024)
- Present in **v6.13-rc1**; **not** in v6.12 or v6.6
- Original file already had .of_match_table and module_platform_driver and **never** had MODULE_DEVICE_TABLE (git show 192514ae05687a:drivers/soc/mediatek/mtk-dvfsrc.c)
- The one-line fix is **ec762057868d70** (Pengpeng Hou, 2026-07-04; applied 2026-07-30)
Step 3.2: FOLLOW THE FIXES: TAG
Record: **No Fixes: tag.** Bug is the original omission in 192514ae05687, which **is** an ancestor of this tree.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: later DVFSRC work (MT6893, MT8196, bandwidth rework) only grew the match table. No prerequisite refactor is required for this one line. **Standalone.**
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Pengpeng Hou has a series of the same “add missing MODULE_DEVICE_TABLE()” fixes (rtc, vdpa, watchdog, hwmon, aspeed, ixp4xx). This is a systematic audit, not a one-off. The applying maintainer is the MediaTek SoC co-maintainer.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: **None.** Needs only mtk_dvfsrc_of_match and module.h, both present since the driver was added. Applies standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c ec762057868d70 →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only** (no v2/v3)
- Thread (saved via b4 dig -m): maintainer reply “Applied to v7.2-next/soc, thanks!” (commit 0ef07f74aff2 while in the MTK tree)
- No NAKs, no requested changes, no Cc: stable in review
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To/Cc included both MediaTek SoC maintainers (Matthias Brugger, AngeloGioacchino Del Regno) and linux-mediatek / linux-arm-kernel / linux-kernel. Applied by the subsystem maintainer.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: **No Reported-by / bugzilla / syzbot.** Evidence is the source mismatch (match table vs missing export), which is deterministic for =m builds.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: not a numbered series. Sibling same-cycle fixes exist (`soc:
aspeed, soc: ixp4xx: npe/qmgr). Each is self-contained. Historical MediaTek analogs: 6f42f5e73bb43 (mtk-svs), 10687632307c0` (mtk- mmsys).
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: **UNVERIFIED.** lore.kernel.org returned HTTP 403 for WebFetch and curl. No local evidence of a stable NAK.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: **No function body changed.** The new line is MODULE_DEVICE_TABLE(of, mtk_dvfsrc_of_match) beside the existing table. Related runtime entry is mtk_dvfsrc_probe.
Step 5.2: TRACE CALLERS
Record:
- module_platform_driver(mtk_dvfsrc_driver) → OF platform probe
- Exported mtk_dvfsrc_send_request / mtk_dvfsrc_query_info used by:
- drivers/interconnect/mediatek/icc-emi.c (INTERCONNECT_MTK_DVFSRC_EMI depends on MTK_DVFSRC)
- drivers/regulator/mtk-dvfsrc-regulator.c (REGULATOR_MTK_DVFSRC depends on MTK_DVFSRC)
- Probe also devm_of_platform_populate(), so child interconnect/regulator nodes never appear if this module never loads
Step 5.3: TRACE CALLEES
Record: probe does SMC init/start of the DVFSRC IP, clock enable, child populate. Autoload failure means that entire stack never starts.
Step 5.4: FOLLOW THE CALL CHAIN
Record: **Userspace-reachable via normal boot on MediaTek DT platforms** (kmod/udev matching compatible). Unprivileged users do not need a special syscall; they just boot. Trigger requires CONFIG_MTK_DVFSRC=m and a matching DT node.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: other drivers/soc/mediatek/ drivers already have MODULE_DEVICE_TABLE(of, ...). This was the omission.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record:
- git describe HEAD → **v7.3-rc4-27-gf0100363d8c37**; make kernelversion → **7.3.0-rc4**
- File and match table exist. Before ec762057868d70 there was **no** MODULE_DEVICE_TABLE (git show ec762057868d70^:...)
- Bug introduced with the driver in **v6.13** (192514ae05687)
- git merge-base --is-ancestor ec762057868d70 HEAD → yes (this checkout already contains the fix as mainline, which does not change whether the bug class is real)
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **clean apply.** One line after the sentinel entry. Compatible strings may differ on older stables, but the macro is independent of table contents.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: this is the fix. No earlier equivalent. Sibling SoC drivers already had the macro.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record:
- **Subsystem:** drivers/soc/mediatek (MediaTek SoC DVFS resource collector)
- **Criticality: IMPORTANT** on ARCH_MEDIATEK (Chromebooks/boards with MT8183/MT8195/MT8196/MT6893), **PERIPHERAL** globally
- Kconfig: config MTK_DVFSRC **tristate**, depends on ARCH_MEDIATEK
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: actively maintained (MT8196/DVFSRCv4, bandwidth rework, mmsys/cmdq work). DVFSRC itself is a few years old (6.13), not brand-new staging code.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: **platform-specific / config-specific** — ARCH_MEDIATEK + CONFIG_MTK_DVFSRC=m + DT compatible in the match table. Built-in configs are unaffected.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record:
- Trigger: boot (or DT overlay) with the module not already loaded
- Common on distro-style =m kernels; Chromebook/embedded images often use =y (then a no-op)
- Not a race; **100%** for modular builds
- Unprivileged user is not required beyond using the machine
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- **Failure:** DVFSRC module does not autoload → probe skipped → child devices not populated → interconnect EMI bandwidth votes and DVFSRC regulators return failure/-ENODEV
- Not an oops/UAF/corruption
- **Severity: MEDIUM** (device/stack does not come up; power/bandwidth management broken on those SoCs). For users who ship this as a module, it is a real “hardware doesn’t work” bug, in the same bucket as missing device IDs
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit:** high for modular MediaTek kernels; zero elsewhere
- **Risk:** very low (1 line, .modinfo only)
- **Ratio:** strongly favors including it
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real, deterministic autoload bug on a **tristate** driver that already has an OF table
- DVFSRC is the parent of interconnect and regulator children; missing autoload takes down that DVFS/bandwidth stack
- 1-line, standard MODULE_DEVICE_TABLE(of, ...) pattern already used by sibling MediaTek SoC drivers
- Applied by the MediaTek SoC maintainer; v1 accepted unchanged
- Same class as device-ID additions (explicit stable exception):
existing driver, existing hardware, missing match publication
- Driver has been in this lineage since v6.13; the omission is old, not a just-landed feature
AGAINST:
- No user/syzbot report; author describes it as source-level
- Not a crash, deadlock, or data-corruption fix
- =y builds are unaffected; no in-tree defconfig sets CONFIG_MTK_DVFSRC
- No Cc: stable (expected here; not used as a negative)
UNRESOLVED:
- lore.kernel.org stable-list search (HTTP 403)
- Whether a given distro actually builds this as =m (unverified)
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — one established macro; maintainer applied v1
2. Fixes a real bug that affects users? **PASS** — module will not autoload for OF devices (stable-kernel-rules.rst: “real bug that bothers people **or** just add a device ID”)
3. Important issue? **PASS** as hardware-does-not-bind / missing ID- table export, not as a panic. Severity MEDIUM but in the device-ID exception class
4. Small and contained? **PASS** — +1 line, one file
5. No new features or APIs? **PASS** — only publishes an existing table
6. Can apply to the local tree? **PASS** — file and table exist; the line is already the correct form here
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: **Device ID / match-table publication for an existing driver.** Closest documented exception: “just add a device ID.”
Step 9.4: MAKE YOUR DECISION
This is a one-line, obviously correct fix for a real modular-boot failure on MediaTek SoCs that already have this driver. Risk is negligible. It belongs in this tree’s stable lineage.
### What it solves for stable users
If mtk-dvfsrc is built as a module, kmod never gets of: aliases for mediatek,mt8183-dvfsrc and the other compatibles. The driver never probes, so DVFSRC children (EMI interconnect, DVFSRC regulators) never appear. Adding MODULE_DEVICE_TABLE is the supported way to generate those aliases (include/linux/module.h + scripts/mod/file2alias.c).
### Risk vs benefit
Benefit is restoring autoload for a SoC DVFS block; risk is a .modinfo addition with no runtime logic change.
### Concerns
Needs no extra commits. Older stables without mtk-dvfsrc.c (pre-6.13) would not apply; **this** checkout has the driver. Lore stable discussion could not be fetched (403).
Verification:
- [Phase 1] git show ec762057868d70: subject/tags/body as above; no Fixes/Cc stable/Reported-by
- [Phase 2] Diff is exactly +MODULE_DEVICE_TABLE(of, mtk_dvfsrc_of_match); in mtk-dvfsrc.c
- [Phase 3] Blame: table from 192514ae05687; MODULE_DEVICE_TABLE line from ec762057868d70
- [Phase 3] git show 192514ae05687a:drivers/soc/mediatek/mtk-dvfsrc.c:
of_match_table + module_platform_driver, no MODULE_DEVICE_TABLE
- [Phase 3] git merge-base --is-ancestor 192514ae05687 v6.13-rc1 yes; not in v6.12
- [Phase 3] git merge-base --is-ancestor ec762057868d70 HEAD yes
- [Phase 4] b4 dig -c/-a/-w/-m: lore msgid [email protected]; v1 only; maintainers CC’d; Angelo applied to v7.2-next/soc
- [Phase 4] lore.kernel.org HTTP 403 — stable-list discussion UNVERIFIED
- [Phase 5] Callers: icc-emi.c, mtk-dvfsrc-regulator.c; Kconfig depends on MTK_DVFSRC; probe uses devm_of_platform_populate
- [Phase 5] CONFIG_MTK_DVFSRC is tristate in drivers/soc/mediatek/Kconfig
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; kernelversion 7.3.0-rc4
- [Phase 6] Pre-commit file has match table and no MODULE_DEVICE_TABLE
- [Phase 7] MAINTAINERS: ARM/Mediatek SoC support → AngeloGioacchino Del Regno (applier)
- [Phase 8] Failure mode: module not autoloaded → DVFSRC/DVFS stack down; not an oops
- UNVERIFIED: distro =m vs =y defaults; stable@ lore thread
**YES**
drivers/soc/mediatek/mtk-dvfsrc.c | 1 + 1 file changed, 1 insertion(+)
drivers/soc/mediatek/mtk-dvfsrc.c +1 -0
@@ -562,6 +562,7 @@ static const struct of_device_id mtk_dvfsrc_of_match[] = { { .compatible = "mediatek,mt8195-dvfsrc", .data = &mt8195_data }, {/* sentinel */ } }; +MODULE_DEVICE_TABLE (of, mtk_dvfsrc_of_match);static struct platform_driver mtk_dvfsrc_driver = { .probe = mtk_dvfsrc_probe,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 apparmor: fix auditing of mount binary data
In reply to Sasha LevinFrom: John Johansen <[email protected]>
[ Upstream commit b9f2181b90ec047488dcb4fb1c631d417aff07e0 ]
AppArmor only mediates non-binary mount data, and should only audit the mount data if it is non-binary.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). The buggy audit_mount(..., data, ...) call is still present, and the two-line change applies onto the current match_mnt_path_str() code.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[apparmor] [fix] [do not audit mount data when it is binary]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Upstream commit: b9f2181b90ec047488dcb4fb1c631d417aff07e0 (John Johansen, 2026-07-28; merged via AppArmor v7.3 pull apparmor- pr-2026-08-26).
Record:
- **Fixes:** none (expected for this review pipeline)
- **Reported-by:** none
- **Tested-by:** none on the commit itself
- **Reviewed-by / Acked-by:** none on the commit
- **Link:** none
- **Cc: stable:** none (expected)
- **Signed-off-by:** John Johansen <[email protected]> (AppArmor maintainer). Ignore any Sasha Levin SOB.
Notable pattern: no user/syzbot report; maintainer-authored correctness fix. The v7.3 pull lists it under **Bug Fixes** (“auditing of mount binary data”), not Features/Cleanups.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** AppArmor mediates only non-binary mount data, but still passes binary data into audit_mount().
- **Symptom:** AppArmor audit records can include an options= field built by treating a binary blob as a C string (audit_log_untrustedstring() → strlen()).
- **Version info:** none in the message. The pattern dates to 2ea3ffb7782a84 (“apparmor: add mount mediation”, v4.14-rc2).
- **Root cause (author):** audit should follow the same !binary rule as mediation.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. Subject and body both say **fix**. It is a real audit-path bug, not a feature.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: security/apparmor/mount.c only (**−2 / +2**)
- Function: match_mnt_path_str()
- Scope: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Before (this tree, lines 346–349):
```346:349:security/apparmor/mount.c
audit:
return audit_mount(subj_cred, profile, OP_MOUNT, mntpnt,
devname,
type, NULL,
flags, data, AA_MAY_MOUNT, &perms, info,
error);
```After: pass !binary ? data : NULL instead of data.
match_mnt() only wraps match_mnt_path_str(), so both new-mount and remount paths are covered. aa_umount / aa_pivotroot already pass NULL data.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Logic / correctness in LSM audit** (binary blob treated as a string).
Verified mechanism:
- do_match_mnt() already skips matching when binary is set (data && !binary && (perms->allow & AA_MNT_CONT_MATCH)).
- audit_mount() still stores data if perms->audit & AA_AUDIT_DATA.
- audit_cb() then does audit_log_untrustedstring(ab, ad->mnt.data), which uses strlen().
FS_BINARY_MOUNTDATA filesystems in this tree: **NFS, NFS4, Btrfs, Coda**.
Not an unbounded OOB on the mount(2) path: path_mount() does ((char *)data_page)[PAGE_SIZE - 1] = 0 before security_sb_mount(). strlen() stays inside the copy_mount_options() page. The bug is wrong/garbled audit contents (and a possible hex dump of almost a full page if the blob has no interior NUL).
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct; mirrors the existing !binary mediation check. Minimal. Regression risk is low: binary options= simply disappears from AppArmor mount audit records, which is the intended policy. No API, locking, or data-structure change.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record: The flags, data, AA_MAY_MOUNT argument list is from **2ea3ffb7782a84** (John Johansen, 2017-07-18), described as v4.14-rc2. Wrapper cred-passing is from 90c436a64a6e20 (2022). The bug is old, not new 7.x code.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Buggy code is the original mount-mediation audit call. git merge-base --is-ancestor 2ea3ffb7782a84 HEAD → **yes, present**.
**Step 3.3: CHECK FILE HISTORY**
Record: Recent mount.c commits in this tree: nosymfollow audit flags, move_mount detached-source fix, mount mediation regression fix. No prior fix for binary-data auditing. Next mainline commit after this one is apparmor: refactory mount to use check_perms (large refactor). **This fix is standalone and comes before that refactor.**
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: John Johansen is the AppArmor maintainer. Same-file history is almost entirely his. Weight: high.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Diff uses existing binary parameter and existing audit_mount() signature. No new helpers. **Applies standalone.** The following mount refactor is not required.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c b9f2181b90ec047488dcb4fb1c631d417aff07e0 (and -w) → lore.kernel.org returned errors; **no thread recovered**.
- GitHub commit page confirms message/diff match the candidate.
- LKML pull: [GIT PULL] AppArmor updates for v7.3 (John Johansen, 2026-08-26) lists this under Bug Fixes and notes merge/build/regression testing plus linux-next and Ubuntu kernel testing.
UNVERIFIED: v1/v2 review comments, NAKs, reviewer-requested `Cc:
stable`.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: No Reviewed-by on the commit. Author is the subsystem maintainer. Recipients of the original mail **UNVERIFIED** (b4 -w failed).
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by, no bugzilla/syzbot link. Likely found while preparing the mount refactor (same-day neighbor commits on 2026-08-10).
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Same pull as refactory mount to use check_perms (cleanup, not a dependency) and add audit mode... (feature, unused by this fix). Self-contained.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No evidence this was NAK’d for stable. Search did not find a stable-specific discussion of this title.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
Record: match_mnt_path_str() modified; audit_mount(), audit_cb(), do_match_mnt(), aa_new_mount(), aa_remount(), apparmor_sb_mount() involved.
**Step 5.2: TRACE CALLERS**
Record:
- match_mnt() → match_mnt_path_str()
- aa_new_mount() → match_mnt / match_mnt_path_str (sets binary from FS_BINARY_MOUNTDATA)
- aa_remount() → match_mnt (same flag from superblock type)
- apparmor_sb_mount() → aa_new_mount / aa_remount from security_sb_mount() in path_mount()
**Step 5.3: TRACE CALLEES**
Record: audit_mount → aa_audit → audit_cb → audit_log_untrustedstring / strlen. Memory alloc/locks are unchanged.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace mount(2) / remount → path_mount → LSM sb_mount → AppArmor. Reachable from confined tasks that can mount (typically CAP_SYS_ADMIN, or a user namespace). **Yes, userspace-reachable.** This tree has no AppArmor fs_context hooks; the classic sb_mount path is the one that matters here.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Only this audit_mount call passes mount data. Mediation already had the !binary guard; audit did not. No sibling drivers with the same bug.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** make kernelversion = **6.12.111**; git describe HEAD = p-6.12-3-gc504cf0baa3d8. Exact before-context is in match_mnt_path_str(). Introduced **v4.14**. git merge-base --is- ancestor b9f2181b90ec HEAD → **not present**.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** Surrounding function signature (subj_cred, rules->policy, binary) already matches. Confirmed `old present:
True` in the current file.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: git log --grep='auditing of mount binary' on security/apparmor/ is empty. Closest related in-tree patch is 33be0cfa5ba52 (“apparmor: take nosymfollow flag into account”), which is also AppArmor **mount audit correctness** and was already taken for this series.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: **AppArmor LSM** (security/apparmor/). **IMPORTANT** (not core mm/VFS; default MAC on Ubuntu and several LTS distros). Mount mediation
+ audit are user-visible security/audit paths.
**Step 7.2: SUBSYSTEM ACTIVITY**
Record: Mature (~2017 mount mediation) with ongoing stable backports in this tree. Not a brand-new 7.x subsystem.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Record: Config-specific: CONFIG_SECURITY_APPARMOR, confined processes, filesystems with FS_BINARY_MOUNTDATA (NFS/Btrfs/Coda), and only when an AppArmor mount audit record is generated with AA_AUDIT_DATA in perms->audit.
**Step 8.2: TRIGGER CONDITIONS**
Record: Confined mount()/remount of NFS/Btrfs/Coda with non-NULL mount data, plus policy that produces a mount audit record with the data-audit bit. Not every boot; common on Ubuntu NFS/Btrfs systems with AppArmor. Unprivileged userns mounts can hit it if confined. Not a race.
**Step 8.3: FAILURE MODE SEVERITY**
Record:
- Failure: options= in AppArmor audit is a strlen() view of a binary blob (garbage, early truncate at first NUL, or hex dump of up to ~PAGE_SIZE-1).
- Not a panic: VFS NUL-terminates the last byte of the options page.
- **Severity: MEDIUM** (wrong LSM audit; possible bulky hex dump). Not crash/deadlock/corruption.
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit:** medium for AppArmor+NFS/Btrfs users (correct audit; no binary blob in logs). Same class as the in-tree nosymfollow audit fix.
- **Risk:** very low (2 lines, existing binary flag, no locking).
- **Ratio:** favorable.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real bug: audit disagrees with mediation on binary mount data.
- Maintainer-authored; v7.3 pull classified it as a bug fix; tested in linux-next/Ubuntu.
- Two-line, obviously correct, clean apply on 6.12.111.
- Buggy code present since v4.14.
- Touches a live LSM path (NFS/Btrfs).
- This tree already accepted a similar AppArmor mount-audit correctness fix (nosymfollow).
- No new APIs/features; no dependency on the later mount refactor.
**AGAINST:**
- No user report, syzbot, or CVE.
- Not a crash/deadlock/corruption; gated on AA_AUDIT_DATA.
- Short message; no Fixes:/Cc: stable.
- Present since 2017 without reports (low “bothers people” signal).
**UNRESOLVED:**
- Original lore review thread (b4/lore 403).
- Whether reviewers asked for Cc: stable.
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — two-line mirror of existing !binary check; maintainer + v7.3 testing.
2. Fixes a real bug that affects users? **PASS** — AppArmor mount audit of NFS/Btrfs/Coda can emit binary options=.
3. Important issue? **PASS** (medium) — LSM audit correctness / “oh, that’s not good”; not a panic. Precedent in this tree: nosymfollow mount-audit fix.
4. Small and contained? **PASS** — 2 lines, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS**.
**Step 9.3: EXCEPTION CATEGORIES**
Record: None (not a device ID, quirk, DT, build, or docs fix). Qualifies as a normal small bug fix.
**Step 9.4: DECISION**
Backport. The tree has the bug, the patch applies cleanly, it is a maintainer LSM audit fix with negligible regression risk, and 6.12 AppArmor users (especially Ubuntu) mount NFS/Btrfs under confinement.
What it solves for stable users: AppArmor will stop stuffing binary mount blobs into options= via strlen()/audit_log_untrustedstring(), matching the already-correct “don’t mediate binary data” rule.
Risk vs benefit: benefit is correct MAC audit on common filesystems; risk is essentially zero.
---
## Verification
- **[Phase 1]** Parsed tags: only author SOB; no Fixes/Reported-by/Cc stable. Upstream SHA b9f2181b90ec047488dcb4fb1c631d417aff07e0.
- **[Phase 1]** v7.3 pull (openwall/LKML, 2026-08-26) lists “auditing of mount binary data” under Bug Fixes.
- **[Phase 2]** Diff: match_mnt_path_str() passes `!binary ? data :
NULL; local file still passes data`.
- **[Phase 2]** do_match_mnt() already has data && !binary && (perms->allow & AA_MNT_CONT_MATCH).
- **[Phase 2]** audit_cb() uses audit_log_untrustedstring → strlen (kernel/audit.c).
- **[Phase 2]** path_mount() NUL-terminates data_page[PAGE_SIZE-1] — not an OOB on this path.
- **[Phase 2]** FS_BINARY_MOUNTDATA: nfs, nfs4, btrfs, coda.
- **[Phase 3]** git blame: line from 2ea3ffb7782a84 (v4.14-rc2); ancestor of HEAD.
- **[Phase 3]** git merge-base --is-ancestor b9f2181b90ec HEAD → not in this tree.
- **[Phase 3]** No Fixes: tag to follow.
- **[Phase 3]** Follow-up mainline commit is a mount refactor, not a prerequisite.
- **[Phase 4]** b4 dig -c/-w failed (lore 403). UNVERIFIED: review NAKs / stable nomination in the original thread.
- **[Phase 4]** No stable-list hit for this title.
- **[Phase 5]** Call chain: path_mount → apparmor_sb_mount → aa_new_mount/aa_remount → match_mnt_path_str → audit_mount.
- **[Phase 5]** Only one audit_mount site passes data.
- **[Phase 6]** git describe HEAD = p-6.12-3-gc504cf0baa3d8; make kernelversion = 6.12.111.
- **[Phase 6]** Python check: old snippet present, new snippet absent.
- **[Phase 6]** git log --grep='auditing of mount binary' -- security/apparmor/ empty.
- **[Phase 7]** CONFIG_SECURITY_APPARMOR exists; AppArmor is IMPORTANT.
- **[Phase 8]** Failure mode: garbled/hex options= in AppArmor audit, severity MEDIUM; not oops.
- **UNVERIFIED:** Original lore review comments; whether AA_AUDIT_DATA is set in typical Ubuntu mount policy (code path is real; frequency of the audit bit is policy-dependent).
The fix is small, surgical, present as a real bug in this 6.12 tree, and meets the stable criteria for an LSM audit correctness fix.
**YES**
security/apparmor/mount.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
security/apparmor/mount.c +2 -2
@@ -344,8 +344,8 @@ static int match_mnt_path_str(const struct cred *subj_cred, audit:return audit_mount (subj_cred, profile,OP_MOUNT , mntpnt, devname, - type,NULL , - flags, data,AA_MAY_MOUNT , &perms, info, error); + type,NULL , flags, !binary ? data :NULL , +AA_MAY_MOUNT , &perms, info, error); }/**
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-6.6] apparmor: fix auditing of mount binary data
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines
From: John Johansen <[email protected]>
[ Upstream commit
b9f2181b90ec047488dcb4fb1c631d417aff07e0]AppArmor only mediates non-binary mount data, and should only audit the mount data if it is non-binary.
Signed-off-by John Johansen <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 media: dvb-core: fix feed leak on failed DMX_ADD_PID
In reply to Sasha LevinFrom: Rituparna Warwatkar <[email protected]>
[ Upstream commit 9fa26c971ca310dd10a3bc0014f2fc7ea7167bba ]
dvb_dmxdev_add_pid() allocates a new dmxdev_feed, links it into filter->feed.ts and, when the filter is already running, immediately starts the feed.
If starting the feed fails, the newly allocated feed remains on the list. Subsequent restart and rollback paths may then operate on this stale entry, leaving feed resources allocated and causing leaks in drivers that allocate resources from ->start_feed() and release them from ->stop_feed().
Remove the feed from the list and free it whendvb_dmxdev_start_feed() fails.
Message-ID: <[email protected]>
---
LLM Generated explanations, may be completely bogus:
The local checkout is mainline **7.3.0-rc4**. The change is a small, syzbot-confirmed feed leak in dvb_dmxdev_add_pid(), present since 2009, and it belongs in this tree.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[media/dvb-core] [fix] feed leak on failed DMX_ADD_PID**
- Subsystem: media: dvb-core:
- Action verb: **fix** (explicit bug fix)
- Claimed intent: stop leaking a dmxdev_feed when DMX_ADD_PID fails to start a already-running filter
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Reported-by:** [email protected] (fuzzer-found, reproducible)
- **Closes:**
https://syzkaller.appspot.com/bug?extid=e9a1f5e196de6663631b
- **Signed-off-by:** Rituparna Warwatkar (author)
- **Link:**
https://patch.msgid.link/[email protected]
- **Signed-off-by:** Mauro Carvalho Chehab (media maintainer, committer)
- **Message-ID:** <[email protected]>
- **No Fixes:** tag (expected for this review pipeline)
- **No Cc: stable** (expected)
- **No Reviewed-by / Tested-by / Acked-by**
- Sasha Levin SOB: not present on this commit (ignored per instructions anyway)
Notable pattern: syzbot report + media maintainer SOB.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** dvb_dmxdev_add_pid() allocates a dmxdev_feed, links it onto filter->feed.ts, then (if the filter is already DMXDEV_STATE_GO) calls dvb_dmxdev_start_feed(). On start failure the object stays on the list.
- **Symptom:** leaked feed objects and leaked driver resources allocated in ->start_feed() and meant to be released in ->stop_feed().
- **Failure mode:** resource leak; subsequent restart/rollback walks the stale list entry.
- **Version info:** none in the message. History shows the pattern dates to 2009.
- **Root cause (author):** missing list_del + kfree on the dvb_dmxdev_start_feed() error path.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not disguised.** This is an explicit error-path leak fix (syzbot memory leak). Not a cleanup/refactor.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** drivers/media/dvb-core/dmxdev.c (+9 / −2; net +7)
- **Function:** dvb_dmxdev_add_pid() only
- **Scope:** single-file surgical error-path fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** if filter->state >= DMXDEV_STATE_GO, return dvb_dmxdev_start_feed(...) directly. On failure the feed is already on filter->feed.ts and is never unlinked or freed.
- **After:** capture the return value; on ret < 0, list_del(&feed->next), kfree(feed), then return the error. Success path still returns 0.
- **Path affected:** error path of DMX_ADD_PID while a PES filter is already running. Normal success path unchanged.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** error-path resource leak, with a follow-on NULL deref / UAF on close/stop
- **Mechanism:** list_add() happens before start. list_add() inserts at the **head**. dvb_dmxdev_start_feed() sets feed->ts = NULL then may fail in allocate_ts_feed() (ts stays NULL) or fail after release_ts_feed() (ts dangling). dvb_dmxdev_feed_stop() / dvb_dmxdev_filter_stop() then walk the list and call feed->ts->stop_filtering(feed->ts) without a NULL check. Close (dvb_dmxdev_filter_free) always calls those stop/reset paths. Because the stale feed is at the head, stop hits it first and never stops the original live feed — matching the syzbot vidtv start_feed leak (mux/PSI objects never destroyed). dvb_dmxdev_remove_pid() also skips entries with feed->ts == NULL, so userspace cannot recover via DMX_REMOVE_PID.
- **Fix:** unlink and free the new feed if start fails, restoring the list to the pre-ioctl state.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Quality:** obviously correct. Mirrors the existing success-cleanup in dvb_dmxdev_remove_pid() (list_del + kfree). dvb_dmxdev_start_feed() already releases a partially allocated TS feed on its own error paths, so this does not double-free driver TS feeds.
- **Minimal:** only the failure branch.
- **Regression risk:** very low. Does not change locking, APIs, or success behavior. A remaining unrelated weakness is that dvb_dmxdev_start_feed() does not NULL feed->ts after release_ts_feed() on set/start_filtering failure; this patch kfree’s the wrapper so that dangling pointer is discarded.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Buggy allocate/list_add/start pattern introduced in **1cb662a3144992** (“V4L/DVB (12275): Add two new ioctls:
DMX_ADD_PID and DMX_REMOVE_PID”), Andreas Oberritter, 2009-07-14.
- Contained in **v2.6.32-rc1**. Present in this tree and in every current LTS.
- Allocation line later became kzalloc_obj (bf4afc53b77ae, 2026); this patch does not depend on that.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Not applicable. The introducing commit is identified via blame as 1cb662a3144992, and git merge-base --is- ancestor is not needed for that SHA as a Fixes target; the buggy function is in this checkout.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Recent dmxdev.c commits are unrelated (ringbuffer reopen, kzalloc_obj conversion, vb2, mmap, UAF-on-release, etc.).
- No later follow-up on this function: git log 9fa26c971ca31..HEAD -- drivers/media/dvb-core/dmxdev.c is empty.
- **Standalone**, not patch X/Y.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Rituparna Warwatkar has this single commit under drivers/media/ in this tree. Not a subsystem maintainer. **Mauro Carvalho Chehab** (media maintainer) committed it, which is the relevant trust signal.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **None.** Uses existing list_del / kfree / dvb_dmxdev_start_feed(). Applies on top of the 2009 function. The current kzalloc_obj line is **not** part of the hunk.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 9fa26c971ca31 →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only**, single patch, not a series
- b4 dig -m: thread is **only the original submission**; no public replies, NAKs, or reviewer-added Cc: stable
- lore.kernel.org WebFetch returned **403**; discussion recovered from the mbox instead
- Applied as submitted by Mauro on 2026-07-27
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To Mauro Carvalho Chehab; Cc linux-media, linux- kernel, syzbot. No extra reviewers. Maintainer applied it (SOB as committer).
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record (syzkaller, fetched successfully):
- Title: **memory leak in vidtv_psi_registration_desc_init**
- Status: upstream reported, **C repro**
- Labels: **prio:high**
- Fix commit listed: 9fa26c971ca3
- Syzbot AI: DenialOfService exploitable, **Unprivileged: yes**
- Duplicate: “memory leak in vidtv_psi_sdt_service_init”
- Two crashes (2026-07-10, 2026-07-21) with C/syz reproducers
- Stack: vidtv_start_feed → dmx_ts_feed_start_filtering → dvb_dmxdev_start_feed → dvb_dmxdev_filter_start → dvb_demux_do_ioctl (ioctl path)
- Patch testing on upstream: **OK** (author + another tester)
The leak objects are vidtv PSI/mux allocations from ->start_feed(). That matches “drivers that allocate from start_feed and release from stop_feed” once stop never runs because the stale list head is hit first.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: standalone v1. Duplicate syzbot bug closed as dup. No sibling patches required.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable WebFetch returned **403**. **UNVERIFIED** whether stable@ discussed this. Absence of Cc: stable on the commit is expected and not used against the patch.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: dvb_dmxdev_add_pid() modified. Closely involved (not changed):dvb_dmxdev_start_feed(), dvb_dmxdev_feed_stop(), dvb_dmxdev_filter_stop(), dvb_dmxdev_filter_start(), dvb_dmxdev_filter_free(), dvb_dmxdev_remove_pid().
**Step 5.2: TRACE CALLERS**
Record:
- dvb_dmxdev_pes_filter_set() → dvb_dmxdev_add_pid() for the initial PID. At that point state is SET not GO, so the start-on-GO branch (the bug) is **not** taken there.
- dvb_demux_do_ioctl() DMX_ADD_PID → dvb_dmxdev_add_pid(). This **is** the GO-state path after DMX_START / immediate start.
- Context: userspace ioctl on /dev/dvb/adapterX/demuxY, under dmxdevfilter->mutex.
**Step 5.3: TRACE CALLEES**
Record: kzalloc_obj / historically kzalloc, list_add, dvb_dmxdev_start_feed() → allocate_ts_feed / tsfeed->set / tsfeed->start_filtering → driver start_feed (e.g. vidtv_start_feed increments nfeeds and may call vidtv_start_streaming).
**Step 5.4: FOLLOW THE CALL CHAIN**
Record:ioctl(DMX_SET_PES_FILTER) → start filter (DMXDEV_STATE_GO, driver start_feed) → ioctl(DMX_ADD_PID) → fail dvb_dmxdev_start_feed → stale list entry → close / filter_stop walks list.
**Userspace reachable: yes.** Syzbot C repro confirms it.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: dvb_dmxdev_filter_start() already rolls back with dvb_dmxdev_filter_stop() if a later PID’s start_feed fails. add_pid was the missing counterpart. remove_pid already does list_del+kfree. No other copy of this exact bug in dvb-core.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record:
- git describe HEAD → **v7.3-rc4-27-gf0100363d8c37**
- make kernelversion → **7.3.0-rc4** (mainline, not an LTS branch name)
- File and function exist at drivers/media/dvb-core/dmxdev.c
- Pre-fix body confirmed via git show 9fa26c971ca31^:...
- Bug introduced **v2.6.32-rc1** (1cb662a3144992); not a post-branch issue for this tree
- git merge-base --is-ancestor 9fa26c971ca31 HEAD → yes (the fix is already on this mainline checkout). That is **not** used as circular “already selected for stable” reasoning; it only confirms the code belongs here.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** Surrounding function has been stable since 2009 aside from the allocator rename, which this hunk does not touch. No conflicting later edits to this function.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: this *is* the fix. No alternate older fix for the same error path.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **media / DVB core demux (drivers/media/dvb-core/)**.
Criticality: **IMPORTANT** (shared by all DVB adapters; not mm/net core, not staging). UAPI ioctl DMX_ADD_PID in include/uapi/linux/dvb/dmx.h.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: dvb-core is mature; this function is ~17 years old. Occasional security/leak/UAF fixes. Not a newly added subsystem.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **driver/config-specific** — users of DVB demux (CONFIG via media/DVB stack), including the in-tree vidtv test adapter used by syzbot. Any hardware driver that allocates in start_feed and frees in stop_feed can leak the same way.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Trigger: DMX_ADD_PID while a PES TSDEMUX_TAP filter is running, and dvb_dmxdev_start_feed() fails (allocation busy, invalid frontend, driver -ENOMEM, etc.).
- How common: error path, but syzbot produced a **C repro**.
- Unprivileged: syzbot assessment says yes (device node permissions permitting).
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- Primary report: **memory leak** of driver streaming/PSI objects (and the dmxdev_feed itself)
- On close/stop: **NULL deref or UAF** walking feed->ts on the stale head entry; live feed never stopped
- Repeatable from ioctl → DoS via leak or oops
- Severity: **HIGH** (syzbot prio:high; leak + crash on teardown)
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit: high** — stops a userspace-triggerable leak/crash in DVB core, syzbot-confirmed, long-present bug
- **Risk: very low** — ~7 lines, error path only, maintainer-applied, syzbot patch test OK
- **Ratio: strongly favorable**
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR backporting:**
- Real, reproducible leak (syzbot C repro, prio:high)
- Userspace ioctl trigger; unprivileged DoS per syzbot
- Also creates a stale list head that feed_stop/filter_stop dereference (NULL/UAF) so the original feed is never stopped
- Bug in code from **2009** (v2.6.32); present in this tree
- 7-line, obviously correct error-path cleanup
- No new APIs/features; standalone; no prerequisites
- Media maintainer committed it; syzbot patch tests passed
**AGAINST:**
- No public review comments (v1 applied as-is)
- No Fixes/Cc: stable tags (expected here, not a negative)
- DVB is not a universal core path (still a shared subsystem, not staging)
**UNRESOLVED:**
- lore.kernel.org and stable@ WebFetch 403; thread recovered via b4 dig -m (no replies)
- Whether stable@ already discussed it: unverified, not used in the decision
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — local code matches the described leak; syzbot C repro + patch test OK; maintainer SOB
2. Fixes a real bug that affects users? **PASS** — kmemleak + ioctl repro
3. Important issue? **PASS** — HIGH: resource leak and teardown NULL deref/UAF, not a style cleanup
4. Small and contained? **PASS** — one function, +9/−2
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — same function, no missing helpers
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: not a device-ID/quirk/DT/build/docs exception. It is a normal important bugfix.
**Step 9.4: MAKE YOUR DECISION**
This is a small, correct error-path leak fix in DVB core, reachable from DMX_ADD_PID, present in this tree since the ioctl was added, and confirmed by syzbot. It meets stable rules for this checkout.
**What the commit solves for users of this tree:** a failed DMX_ADD_PID on a running filter left a dmxdev_feed on filter->feed.ts. Later stop/close walked that stale head entry, skipped ->stop_feed() for the live feed, and leaked driver allocations (vidtv PSI/mux in the repro) and could NULL-deref feed->ts.
**Risk vs benefit:** benefit is a real leak/crash fix; risk is a few lines on an ioctl error path.
**Concerns:** none for apply/prereqs on this tree. lore HTTP 403 did not block verification because b4 dig saved the thread.
Verification:
- [Phase 1] Parsed tags: Reported-by syzbot, Closes syzkaller URL, Link msgid, SOB author + Mauro Chehab; no Fixes/Cc:stable
- [Phase 2] Diff: dvb_dmxdev_add_pid() only; on dvb_dmxdev_start_feed() failure, list_del + kfree
- [Phase 2] Confirmed list_add inserts at head; dvb_dmxdev_feed_stop() does feed->ts->stop_filtering without NULL check; remove_pid skips ts == NULL
- [Phase 3] git blame: buggy pattern from 1cb662a3144992 (2009-07-14), contained in v2.6.32-rc1
- [Phase 3] No Fixes tag; no follow-ups on dmxdev.c after this commit; standalone
- [Phase 3] Author has one media commit; maintainer Mauro committed it
- [Phase 4] b4 dig -c 9fa26c971ca31:
https://patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: To Mauro, Cc linux-media/lkml/syzbot
- [Phase 4] b4 dig -m: submission only, no replies/NAKs
- [Phase 4] WebFetch syzbot: prio:high, C repro, DoS unprivileged, fix SHA 9fa26c971ca3, patch test OK
- [Phase 4] lore.kernel.org and lore.kernel.org/stable WebFetch: 403 — UNVERIFIED via HTTP; mbox used instead
- [Phase 5] Callers: DMX_ADD_PID ioctl and pes_filter_set (GO-state path is the ioctl)
- [Phase 5] vidtv start_feed/stop_feed nfeeds + mux alloc/free confirms leak if stop skipped
- [Phase 6] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; kernelversion 7.3.0-rc4
- [Phase 6] Pre-fix function verified with git show 9fa26c971ca31^:drivers/media/dvb-core/dmxdev.c
- [Phase 6] git merge-base --is-ancestor 9fa26c971ca31 HEAD: yes
- [Phase 8] Failure mode: leak + teardown NULL deref/UAF, severity HIGH
- UNVERIFIED: stable@ mailing-list discussion (HTTP 403); not used for the verdict
**YES**
drivers/media/dvb-core/dmxdev.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/media/dvb-core/dmxdev.c +9 -2
@@ -871,6 +871,7 @@ static int dvb_dmxdev_add_pid(struct dmxdev *dmxdev, struct dmxdev_filter *filter, u16 pid) {struct dmxdev_feed *feed; +int ret;if ((filter->type !=DMXDEV_TYPE_PES ) || (filter->state <DMXDEV_STATE_SET ))
@@ -888,8 +889,14 @@ static int dvb_dmxdev_add_pid(struct dmxdev *dmxdev, feed->pid = pid;list_add (&feed->next, &filter->feed.ts); -if (filter->state >=DMXDEV_STATE_GO ) -return dvb_dmxdev_start_feed (dmxdev, filter, feed); +if (filter->state >=DMXDEV_STATE_GO ) { + ret =dvb_dmxdev_start_feed (dmxdev, filter, feed); +if (ret <0 ) { +list_del (&feed->next); +kfree (feed); +return ret; + } + }return 0 ; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 net: dsa: mt7530: error out on failed PHY_IAC command writes
In reply to Sasha LevinFrom: Daniel Golle <[email protected]>
[ Upstream commit 1c95dcb7e923beebccdc79adc3dc1ec8c52295d0 ]
MT7531_PHY_ACS_ST is only ever set by the command write that precedes each poll in the MT7531 indirect PHY access functions, and that write's return value is discarded. A failed write leaves ACS_ST at 0 from the previous access, so the poll succeeds on its first iteration and the functions return stale IAC contents as if they were fresh PHY data. Check the writes and bail out before polling.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: **[net/dsa/mt7530] [error out] Check PHY_IAC command writes and abort on failure instead of polling stale IAC contents.**
**Step 1.2: Tags**
Record (candidate message, ignoring pipeline SOBs):
- **Reviewed-by:** Andrew Lunn <[email protected]> (DSA reviewer)
- **Link:** https://patch.msgid.link/c34602e63a20ebbfb97babd145c82832d7 [email protected]
- **Signed-off-by:** Daniel Golle (author; MediaTek switch co- maintainer)
- **Signed-off-by:** Jakub Kicinski (netdev)
- No Reported-by / Tested-by / syzbot / Cc: stable in the candidate text
Independent of the candidate text, the original LKML submission also had **Fixes: c288575f7810 ("net: dsa: mt7530: Add the support of MT7531 switch")**. That tag is not used as a “already selected” signal; it only identifies the introducing commit.
**Step 1.3: Body**
Record:
- **Bug:** MT7531_PHY_ACS_ST is set only by the command write before each poll. The write return is discarded.
- **Failure mode:** A failed write leaves ACS_ST at 0 from the previous access. The poll condition !(val & MT7531_PHY_ACS_ST) is already true, so the poll returns immediately and the helpers treat leftover IAC contents as a completed PHY access.
- **Symptom:** Reads return stale IAC data as PHY register values; writes return poll-success (0) even though the PHY was not written.
- **Root cause:** Missing error check on mt7530_mii_write() of MT7531_PHY_IAC.
- **Version info in body:** none. Introducing commit is from 2020.
**Step 1.4: Hidden bug fix?**
Record: **Not hidden.** This is an explicit error-propagation fix, not a cleanup.
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- **File:** drivers/net/dsa/mt7530.c only
- **Scope:** ~+12 / −6 (six identical two-line checks)
- **Functions:** mt7531_ind_c45_phy_read, mt7531_ind_c45_phy_write, mt7531_ind_c22_phy_read, mt7531_ind_c22_phy_write
- **Classification:** single-file surgical error-path fix
**Step 2.2: Code flow**
Record: each helper already polls until ACS_ST is clear, writes a command with ACS_ST set, then polls again. **Before:** mt7530_mii_write() result is ignored; polling always runs. **After:** a negative write return jumps to out, which already unlocks the MDIO mutex and returns ret.
**Step 2.3: Bug mechanism**
Record: **logic / error-path correctness.** ACS_ST is BIT(31) of MT7531_PHY_IAC (0x701C). Poll success is “bit clear.” A failed command write never sets that bit, so the poll succeeds on the first iteration.
Verified on the write helpers: after a successful poll, ret is 0 from regmap_read_poll_timeout(), so a failed PHY write is currently reported as **success**. On reads, ret = val & MT7531_MDIO_RW_DATA_MASK returns leftover IAC data as a 16-bit PHY value.
**Step 2.4: Fix quality**
Record: **obviously correct.** Same goto out path already used for poll failures. No new locks, APIs, or data structures. Regression risk is low: only failed bus writes change behavior, and they now return the real errno instead of fake success / stale data.
## Phase 3: Git history
**Step 3.1: Blame**
Record: the unchecked mt7530_mii_write(..., MT7531_PHY_IAC, ...) lines were introduced in **c288575f7810 (Landen Chao, 2020-09-11), “Add the support of MT7531 switch”**. mt7530_mii_write() has returned int since **a08c045580e060 (2023-04-03, regmap conversion)**. Both are in this tree.
**Step 3.2: Fixes: target**
Record: git merge-base --is-ancestor c288575f7810 HEAD succeeded. The bug is in this 6.12 tree. No later local commit already checks these writes (ret = mt7530_mii_write(priv, MT7531_PHY_IAC count is 0).
**Step 3.3: File history / related commits**
Record: this tree already contains the sibling **96e0f5184af69** (v6.12.103~217), “error out on failed reads in MT7531 PHY polling” (upstream 77a9ebe8818cf6). That converted the polls to regmap_read_poll_timeout() but left command writes unchecked. Also
present: **93d46870c5440**, “check bus->read() errors in the MDIO regmap backend” — same author, same class of swallowed MDIO errors.
**Step 3.4: Author**
Record: Daniel Golle is listed as a **MEDIATEK SWITCH DRIVER** maintainer. Other mt7530 error-propagation fixes by him are already in this tree.
**Step 3.5: Dependencies**
Record: **standalone.** Needs mt7530_mii_write() returning int and the existing goto out + mutex unlock — all present. It does **not** need the rest of the later 6-patch series (core_rmw, CORE_PLL_GROUP4, FDB/VLAN writes, IRQ serialization).
## Phase 4: Mailing list
**Step 4.1:** Candidate is not a local commit, so b4 dig -c on this SHA was not possible. b4 dig -c 96e0f5184af69 found the earlier poll- timeout series. This patch was submitted as **[PATCH net 3/4]** then **[PATCH net v2 3/6]** in “fix remaining swallowed MDIO access errors.”
Record: lore/msgid c34602e63a20ebbfb97babd145c82832d7a0b523.1785811140. [email protected]; LKML copy at
https://lkml.iu.edu/hypermail/linux/kernel/2608.0/04802.html. **v2: no changes** to this patch. Cover letter: this write check was a companion that had been folded into the already-applied PHY-polling patch and was split out. No NAKs found.
**Step 4.2:** Recipients included DSA/netdev maintainers (Lunn, Oltean, Kicinski, netdev). Andrew Lunn replied **Reviewed-by** with no requested changes (https://www.spinics.net/lists/kernel/msg6350713.html).
**Step 4.3:** No syzbot or bugzilla. Mechanism is from code review (cover letter: Sashiko AI review of the earlier series).
**Step 4.4:** Series mates are independent swallowed-error checks. This hunk set does not depend on them.
**Step 4.5:** Search of lore.kernel.org/stable for this subject found **no** prior stable discussion or rejection.
## Phase 5: Semantic / call graph
semcode MCP is not available; callers were found with grep.
**Step 5.1:** Functions listed in 2.1.
**Step 5.2: Callers**
- Wired as phy_read/write_c22/c45 for **ID_MT7531, ID_MT7988, ID_EN7581** in mt753x_table.
- MDIO bus ops: mt7530_setup_mdio() sets bus->read/write/read_c45/write_c45 to wrappers that call these helpers. That is the phylib/phylink path (link polling, PHY config).
- Direct: mt7531_setup() uses mt7531_ind_c45_phy_read/write for CORE_PLL_GROUP4 / EEE (those call sites still ignore the return; a later series patch addresses that and is **not** required for this MDIO-bus fix).
**Step 5.3: Callees**mt7530_mutex_lock/unlock, mt7530_mii_write → regmap_write, regmap_read_poll_timeout.
**Step 5.4: Reachability**
Yes, from userspace-visible networking: phylib MDIO reads/writes on MT7531/MT7988/EN7581 switch PHYs. Trigger is a failed switch register write (MDIO/MMIO/regmap error), not a rare debug ioctl.
**Step 5.5:** Same swallowed-error pattern already fixed for MDIO backend reads and PHY_IAC **polls** in this tree. This is the remaining write side of that PHY_IAC path.
## Phase 6: This tree (6.12.y)
**Step 6.1:** Local tree is **pending-6.12 / 6.12.111**. All six PHY_IAC command writes are still unchecked. Bug exists here.
**Step 6.2:** Current source matches the patch “before” context (including regmap_read_poll_timeout from 96e0f5184af69). **Expected
apply: clean.**
**Step 6.3:** No other local commit already checks these writes. The poll-timeout backport left this hole open; this is the companion.
## Phase 7: Subsystem
**Step 7.1:** drivers/net/dsa/mt7530.c — MediaTek DSA switch. **IMPORTANT** (not core mm/VFS, but common on MT7988/MT7531 routers, OpenWrt, embedded). Config: NET_DSA_MT7530.
**Step 7.2:** File is actively maintained; several mt7530 fixes already landed in this 6.12 branch.
## Phase 8: Impact and risk
**Step 8.1:** Users of MT7531, MT7988, and EN7581 switches (not MT7530/MT7621, which use nested mdiobus_* instead of these indirect helpers).
**Step 8.2:** Triggers on failed regmap_write of PHY_IAC. Unprivileged users do not need a special exploit; phylib link/config traffic hits this path. Frequency is error-path, but MDIO/MMIO glitches on these boards are real.
**Step 8.3:** Failure mode: **silent wrong PHY data / false write success**, not an oops. Phylib can see a live link or apply settings that never reached the PHY. Severity: **HIGH** for networking correctness on error; not a panic.
**Step 8.4:**
- **Benefit:** Completes the already-backported PHY_IAC poll hardening; stops fake-success writes and stale reads.
- **Risk:** Very low (12 lines, error path only).
- **Ratio:** Favorable.
## Phase 9: Synthesis
**For backporting**
- Real bug with a verified mechanism (ACS_ST only set by the discarded write).
- Write helpers currently return **0 on a failed PHY write**.
- Small, obviously correct, maintainer-authored, Reviewed-by Andrew Lunn.
- Buggy code and Fixes: target are in this 6.12 tree.
- Sibling poll-timeout fix is already here; this closes the remaining hole that series called out.
- Applies cleanly; no new API.
**Against**
- Error-path only (healthy bus never hits it).
- Driver-specific, not a universal crash/UAF.
- No user crash report; found by review.
**Unresolved**
- Could not b4 dig this exact SHA (not in the checkout); lore/LKML used instead.
- lore.kernel.org WebFetch returned 403; discussion taken from LKML/spinics.
**Stable rules**
1. Obviously correct and tested? **PASS** (Reviewed-by Lunn; merged via netdev)
2. Real user-visible bug? **PASS** (false MDIO success / stale PHY data)
3. Important? **PASS** (silent PHY misconfiguration; same class as already-backported mt7530 MDIO error fixes)
4. Small/contained? **PASS** (~12 lines, one file)
5. No new features/APIs? **PASS**
6. Applies to this tree? **PASS**
Not an ID/quirk/DT/docs exception; it qualifies as a normal contained bugfix.
This should be backported to this 6.12 tree: the bug is present, the fix is surgical, and it finishes error handling that 6.12 already took for the same helpers.
Verification:
- [Phase 1] Parsed candidate tags: Reviewed-by Andrew Lunn, msgid link, Golle/Kicinski SOBs; original LKML also had Fixes: c288575f7810
- [Phase 2] Diff: six ret = mt7530_mii_write(); if (ret < 0) goto out; in four PHY_IAC helpers
- [Phase 2] Header: ACS_ST is BIT(31); poll waits for it clear — confirmed in mt7530.h
- [Phase 2] Write helpers return poll ret (0 on success) — failed write currently looks successful
- [Phase 3] Blame: writes from c288575f7810 (2020); ancestor of HEAD
- [Phase 3] Sibling 96e0f5184af69 already in tree (v6.12.103~217); 93d46870c5440 MDIO read-error fix also in tree
- [Phase 3] git log --grep='PHY_IAC command writes' on this file:
empty
- [Phase 4] LKML v2 3/6: “v2: no changes”; Lunn Reviewed-by, no NAK
- [Phase 4] Cover letter: companion to already-applied PHY polling patch
- [Phase 4] stable@ search: no hits
- [Phase 5] Callers: mt753x_table ID_MT7531/MT7988/EN7581; bus->read/write in mt7530_setup_mdio
- [Phase 6] git describe HEAD / Makefile: 6.12.111 pending-6.12; six unchecked PHY_IAC writes remain
- [Phase 6] Current lines match the patch context (including regmap_read_poll_timeout)
- [Phase 7] MAINTAINERS: Daniel Golle is MediaTek switch co-maintainer
- [Phase 8] Failure: stale PHY data / false write success, not oops
- UNVERIFIED: b4 dig of this exact mainline SHA (commit not in checkout); lore.kernel.org 403
**YES**
drivers/net/dsa/mt7530.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/net/dsa/mt7530.c +18 -6
@@ -557,7 +557,9 @@ mt7531_ind_c45_phy_read(struct mt7530_priv *priv, int port, int devad, reg =MT7531_MDIO_CL45_ADDR |MT7531_MDIO_PHY_ADDR (port) |MT7531_MDIO_DEV_ADDR (devad) | regnum; -mt7530_mii_write (priv,MT7531_PHY_IAC , reg |MT7531_PHY_ACS_ST ); + ret =mt7530_mii_write (priv,MT7531_PHY_IAC , reg |MT7531_PHY_ACS_ST ); +if (ret <0 ) + goto out; ret =regmap_read_poll_timeout (priv->regmap,MT7531_PHY_IAC , val, !(val &MT7531_PHY_ACS_ST ),20 ,100000 );
@@ -568,7 +570,9 @@ mt7531_ind_c45_phy_read(struct mt7530_priv *priv, int port, int devad, reg =MT7531_MDIO_CL45_READ |MT7531_MDIO_PHY_ADDR (port) |MT7531_MDIO_DEV_ADDR (devad); -mt7530_mii_write (priv,MT7531_PHY_IAC , reg |MT7531_PHY_ACS_ST ); + ret =mt7530_mii_write (priv,MT7531_PHY_IAC , reg |MT7531_PHY_ACS_ST ); +if (ret <0 ) + goto out; ret =regmap_read_poll_timeout (priv->regmap,MT7531_PHY_IAC , val, !(val &MT7531_PHY_ACS_ST ),20 ,100000 );
@@ -602,7 +606,9 @@ mt7531_ind_c45_phy_write(struct mt7530_priv *priv, int port, int devad, reg =MT7531_MDIO_CL45_ADDR |MT7531_MDIO_PHY_ADDR (port) |MT7531_MDIO_DEV_ADDR (devad) | regnum; -mt7530_mii_write (priv,MT7531_PHY_IAC , reg |MT7531_PHY_ACS_ST ); + ret =mt7530_mii_write (priv,MT7531_PHY_IAC , reg |MT7531_PHY_ACS_ST ); +if (ret <0 ) + goto out; ret =regmap_read_poll_timeout (priv->regmap,MT7531_PHY_IAC , val, !(val &MT7531_PHY_ACS_ST ),20 ,100000 );
@@ -613,7 +619,9 @@ mt7531_ind_c45_phy_write(struct mt7530_priv *priv, int port, int devad, reg =MT7531_MDIO_CL45_WRITE |MT7531_MDIO_PHY_ADDR (port) |MT7531_MDIO_DEV_ADDR (devad) | data; -mt7530_mii_write (priv,MT7531_PHY_IAC , reg |MT7531_PHY_ACS_ST ); + ret =mt7530_mii_write (priv,MT7531_PHY_IAC , reg |MT7531_PHY_ACS_ST ); +if (ret <0 ) + goto out; ret =regmap_read_poll_timeout (priv->regmap,MT7531_PHY_IAC , val, !(val &MT7531_PHY_ACS_ST ),20 ,100000 );
@@ -646,7 +654,9 @@ mt7531_ind_c22_phy_read(struct mt7530_priv *priv, int port, int regnum) val =MT7531_MDIO_CL22_READ |MT7531_MDIO_PHY_ADDR (port) |MT7531_MDIO_REG_ADDR (regnum); -mt7530_mii_write (priv,MT7531_PHY_IAC , val |MT7531_PHY_ACS_ST ); + ret =mt7530_mii_write (priv,MT7531_PHY_IAC , val |MT7531_PHY_ACS_ST ); +if (ret <0 ) + goto out; ret =regmap_read_poll_timeout (priv->regmap,MT7531_PHY_IAC , val, !(val &MT7531_PHY_ACS_ST ),20 ,100000 );
@@ -681,7 +691,9 @@ mt7531_ind_c22_phy_write(struct mt7530_priv *priv, int port, int regnum, reg =MT7531_MDIO_CL22_WRITE |MT7531_MDIO_PHY_ADDR (port) |MT7531_MDIO_REG_ADDR (regnum) | data; -mt7530_mii_write (priv,MT7531_PHY_IAC , reg |MT7531_PHY_ACS_ST ); + ret =mt7530_mii_write (priv,MT7531_PHY_IAC , reg |MT7531_PHY_ACS_ST ); +if (ret <0 ) + goto out; ret =regmap_read_poll_timeout (priv->regmap,MT7531_PHY_IAC , reg, !(reg &MT7531_PHY_ACS_ST ),20 ,100000 );
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 gpio: mvebu: keep resume masks within the irqchip cache
In reply to Sasha LevinFrom: Rosen Penev <[email protected]>
[ Upstream commit 02af7eac17bc62a72335c1fc8c4af4471654f6cc ]
mvebu_gpio_resume() writes the edge/level mask registers saved at suspend time straight back to hardware, bypassing the irqchip's mask_cache_priv. genirq skips mask_irq() for a line it already considers masked, so restoring a bit in hardware that genirq thinks is still masked leaves that line unmasked behind genirq's back. An asserted level line then has nobody to ack it, and the moment interrupts are re-enabled the chained handler storms, hanging resume.
AND the restored mask values with the matching irqchip mask cache so only lines genirq currently considers unmasked are unmasked again. Read the caches under gc->lock to keep them consistent with the mask/unmask handlers.
Tested on Helios4 (armhf): 5 suspend cycles woken by magic packet, no hang; mvebu_gpio_resume() returns in 6 usecs.
---
LLM Generated explanations, may be completely bogus:
This is a real resume hang in gpio-mvebu: restoring stale mask bits can unmask a level line behind genirq and storm the chained handler. The buggy restore is in this 6.18.57 tree and the patch is small enough to backport.
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
- Record: [gpio/mvebu] [keep/prevent] keep resume masks within the irqchip cache — stop mvebu_gpio_resume() from writing suspend-time mask bits that genirq still considers masked.
**Step 1.2 — Tags**
- Record:
- Assisted-by: LLM
- Signed-off-by: Rosen Penev <[email protected]> (author)
- `Link:
https://patch.msgid.link/[email protected]`
- Signed-off-by: Bartosz Golaszewski <[email protected]> (GPIO maintainer)
- No Fixes:, Reported-by:, Tested-by:, Cc: stable (absence expected)
- Ignore [Upstream commit 02af7eac17bc...] and Signed-off-by: Sasha Levin
**Step 1.3 — Body**
- Record:
- **Bug:** mvebu_gpio_resume() writes saved edge/level mask registers straight to hardware, bypassing mask_cache_priv.
- **Symptom:** resume hang — an asserted level line is unmasked while genirq still thinks it is masked, so nobody acks it and the chained handler storms once IRQs are live.
- **Root cause (author):** mask_irq() is skipped when genirq already considers the line masked (irqd_irq_masked).
- **Fix:** AND restored values with the irqchip mask cache; read
caches under `gc->lock`.
- **Testing:** Helios4 (armhf), 5 suspend cycles woken by magic packet, no hang; mvebu_gpio_resume() ~6 µs.
- **Versions:** none named.
**Step 1.4 — Hidden bug fix?**
- Record: Not hidden. The subject uses “keep … within” but the body describes a resume hang from an IRQ storm. This is an explicit correctness fix.
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
- Record:
- File: drivers/gpio/gpio-mvebu.c (+27 / −6)
- Function: mvebu_gpio_resume() only
- Classification: single-file surgical fix
**Step 2.2 — Control flow**
- Record:
- **Before:** restore edge_mask_regs[] / level_mask_regs[] verbatim to hardware.
- **After:** if mvchip->domain is set, snapshot
`gc->chip_types[0].mask_cache_priv` (level) and `[1]` (edge) under
`gc->lock`, drop the lock, then write `saved & cache`. If there is
no domain, caches stay `~0U` so behavior is unchanged.
- Path: system resume of the GPIO platform device, after
`resume_device_irqs()`.**Step 2.3 — Bug mechanism**
- Record: **Logic / interrupt-state desync** that produces a **level IRQ storm / resume hang**.
- mask_irq() returns immediately if irqd_irq_masked() is already
set (`kernel/irq/chip.c`).
- handle_level_irq() does mask_ack_irq() then irq_can_handle(). If the line is disabled, it returns without running the handler. Level GPIO has no separate ack; masking is the ack.
- Blind restore can put 1s in the HW mask while genirq still has IRQD_IRQ_MASKED. The chained handler (mvebu_gpio_irq_handler) keeps seeing data_in & level_mask and storms.
**Step 2.4 — Fix quality**
- Record: Minimal and locally correct. chip_types[0] is level and [1] is edge in mvebu_gpio_probe() in this tree, matching the snapshot. Unlock-before-regmap_write is required because regmap_write() can take a sleepable lock on PREEMPT_RT (gc->lock is a raw_spinlock_t).
- Regression risk: low. AND can only clear extra bits, never unmask more than both the snapshot and genirq allow. The saved==0 && cache==1 “lost IRQ” case already wrote 0 before this patch. Remaining TOCTOU after dropping the lock is the same class of window v1 tried to close by holding the lock across regmap_write, which is illegal on RT; v2 is the applied compromise.
## Phase 3: Git history
**Step 3.1 — Blame**
- Record: Resume save/restore added by b5b7b487431b0 (“gpio: mvebu:
add suspend/resume support”, Thomas Petazzoni, 2014-10-24), first in **v3.19-rc1**. Present for a long time; this is not new 6.18-only code.
**Step 3.2 — Fixes: tag**
- Record: None. Buggy pattern is the 2014 suspend/resume support, not a recent regression commit.
**Step 3.3 — Related file history**
- Record:
- 6136c1474db88 gpio: mvebu: fix NULL pointer dereference in suspend/resume (PWM NULL) — related path, different bug.
- 3bfcce441c552 gpio: mvebu: free generic chips on unbind — same author, teardown leak, not a prerequisite.
- No later follow-up on this file after the candidate (`git log
cb5b039e115ea..HEAD -- drivers/gpio/gpio-mvebu.c` is empty).
**Step 3.4 — Author**
- Record: Rosen Penev is a regular contributor, not the GPIO maintainer. Two mvebu commits in this tree. Maintainer (Bartosz) applied it; Linus Walleij reviewed v1.
**Step 3.5 — Dependencies**
- Record: Standalone. Uses irq_get_domain_generic_chip(), mask_cache_priv, gc->lock, and mvchip->domain, all already in this tree. Not patch X/Y.
## Phase 4: Mailing list / external
**Step 4.1 — Original discussion**
- Record:
- Lore / msgid:
https://patch.msgid.link/[email protected] - **v1:** https://patch.msgid.link/[email protected] — held `gc->lock` across `regmap_write`.
- **v2 (applied):** unlock before regmap_write (changelog: “Unlock spinlock before regmap_write”).
- b4 dig -a found only v1 and v2. b4 mbox -c did not find a newer revision.
- Linus Walleij: Reviewed-by on v1.
- Bartosz: “Applied, thanks!”
- Sebastian Andrzej Siewior (RT): asked why the mask changes after suspend; later “This looks like a hack with no explanation about the root cause.” Not a NAK of the hang; complaint about the write-up.
- Rosen, after apply: “I had a v3 ready … to fix sashiko’s issue. I guess I’ll send it separately.” No v3 found in this tree or via b4.
- Sashiko bot flagged a TOCTOU after dropping the lock, and a pre- existing saved & cache lost-IRQ case. The lost-IRQ case is not made worse (see 2.4). No reviewer nominated Cc: stable.
**Step 4.2 — Recipients (b4 dig -w)**
- Record: [email protected], Linus Walleij, Bartosz Golaszewski, linux-kernel; v2 also CC’d Sebastian Siewior, Clark Williams, Steven Rostedt, linux-rt-devel because of the PREEMPT_RT lock/sleep issue.
**Step 4.3 — Bug report**
- Record: No syzbot/bugzilla link. Author reports Helios4 magic-packet wakeup hangs without the patch. arch/arm/boot/dts/marvell/armada-388-helios4.dts is in this tree.
**Step 4.4 — Series**
- Record: Standalone one-patch series. Not 2/3.
**Step 4.5 — Stable list**
- Record: lore.kernel.org/stable search returned HTTP 403. No stable discussion found via b4. **UNVERIFIED:** whether anyone already requested or rejected this on stable@.
## Phase 5: Semantic / call graph
**Step 5.1 — Functions**
- Record: only mvebu_gpio_resume().
**Step 5.2 — Callers**
- Record: platform_driver.mvebu_gpio_driver.resume. Reachable from system suspend/resume (dpm_resume → driver .resume), not from a syscall on a hot path.
**Step 5.3 — Callees**
- Record: irq_get_domain_generic_chip(), raw_spin_lock_irqsave/unlock, regmap_write(), optional mvebu_pwm_resume().
**Step 5.4 — Reachability**
- Record: Userspace triggers via /sys/power/state (or equivalent). Helios4 WOL GPIO is a typical level wakeup. CONFIG_GPIO_MVEBU is default y on ARCH_MVEBU/PLAT_ORION.
**Step 5.5 — Similar patterns**
- Record: No other gpio driver in this tree ANDs resume masks with mask_cache_priv. This is mvebu-specific because it saves/restores mask registers itself instead of using generic irqchip suspend/resume.
## Phase 6: This tree (6.18.y)
**Step 6.1 — Does the bug exist here?**
- Record: **Yes.** make kernelversion / Makefile: **6.18.57**. git describe HEAD: v6.18.57-155-gcdf239ca885b2.
- v6.18.57:drivers/gpio/gpio-mvebu.c mvebu_gpio_resume() writes mvchip->edge_mask_regs[] / level_mask_regs[] with **no** cache AND. Diff of that function vs the candidate’s parent is empty.
- Probe in v6.18.57 already has chip_types[0] level, chip_types[1] edge, and mvchip->domain.
**Step 6.2 — Backport difficulty**
- Record: **Clean apply.** Same resume function, same irqchip layout, same APIs.
**Step 6.3 — Related fixes already here?**
- Record: PWM NULL check in suspend/resume is present and different. Nothing else intersects mask-cache vs HW restore.
## Phase 7: Subsystem context
**Step 7.1**
- Record: drivers/gpio/gpio-mvebu.c — Marvell Orion/EBU GPIO irqchip. **IMPORTANT** for ARCH_MVEBU (Armada 370/XP/38x/8K, Helios4, Clearfog, etc.), not core mm/VFS.
**Step 7.2**
- Record: Mature driver (suspend/resume since 2014). Recent commits are small fixes, not a rewrite.
## Phase 8: Impact and risk
**Step 8.1 — Who is affected**
- Record: Platform-specific: CONFIG_GPIO_MVEBU (default on Marvell EBU). Users who suspend/resume, especially with GPIO/level wakeup (WOL).
**Step 8.2 — Trigger**
- Record: System suspend then resume with an asserted level GPIO (author: magic packet on Helios4). Not unprivileged-exploit in the syzbot sense; any user who can suspend can hit it. Timing-sensitive around genirq vs HW mask.
**Step 8.3 — Failure mode**
- Record: Chained IRQ storm → resume hang. **CRITICAL** for affected boards.
**Step 8.4 — Risk/benefit**
- Record: **Benefit high** (unhang resume on real hardware). **Risk low** (one function, conservative AND, tested, GPIO maintainer applied). Remaining TOCTOU is a small window required for RT, not a reason to keep the hang.
## Phase 9: Synthesis
**Step 9.1 — Evidence**
FOR:
- Resume hang / IRQ storm is a real user-visible failure.
- Author reproduced and tested on Helios4 (DT in this tree).
- Mechanism matches genirq: mask_irq() skip + handle_level_irq() + chained GPIO handler.
- Buggy restore is in **this** 6.18.57 tree; bug dates to v3.19.
- +27/−6, one function, no new API.
- Applies cleanly.
- Reviewed by Linus Walleij; applied by Bartosz Golaszewski.
AGAINST:
- Sebastian Siewior called the explanation a hack (write-up, not a demonstrated regression).
- Author mentioned an unsent v3 for a TOCTOU sashiko flagged; not in this tree.
- No Fixes: / syzbot / stable Cc (not a negative per the rules).
- Driver-specific, not universal.
UNRESOLVED:
- Stable@ discussion (lore 403).
- Whether v3 was ever posted after 2026-09-17.
**Step 9.2 — Stable rules**
1. Obviously correct and tested? **PASS** — AND with irqchip cache; Helios4 test; maintainer applied.
2. Real bug affecting users? **PASS** — resume hang on Marvell EBU boards.
3. Important (crash/hang/corruption/deadlock)? **PASS** — resume hang / IRQ storm.
4. Small and contained? **PASS** — one function, ~30 lines.
5. No new features/APIs? **PASS**.
6. Can apply to this tree? **PASS** — v6.18.57 resume path matches the parent.
**Step 9.3 — Exceptions**
- Record: None (not a device ID / quirk / DT / build / docs exception). Ordinary driver bugfix.
**Step 9.4 — Decision**
Backport to this 6.18.57 tree. The hang is in-tree, the fix is surgical, and the remaining RT lock-drop window is weaker than leaving resume broken.
### What the commit solves for this tree
On 6.18.57, mvebu_gpio_resume() still restores suspend-time EDGE/LEVEL mask registers blindly. If genirq has since masked a line (lazy disable, wakeup handling, in-progress level IRQ), that write unmasks hardware while mask_irq() is a no-op. An asserted level GPIO then has no ack path; mvebu_gpio_irq_handler storms and resume hangs. AND-ing with mask_cache_priv keeps hardware from going beyond what genirq currently has unmasked.
### Risk vs benefit
Benefit is an unhang of suspend/resume on in-tree Marvell EBU platforms (Helios4 and similar). Risk is a short snapshot-vs-write window (required so regmap_write is not called under a raw spinlock on PREEMPT_RT) and a theoretically more conservative mask; both are preferable to the current hang.
## Verification
- [Phase 1] Parsed tags: author Rosen Penev; Link msgid 20260915004406.115230-1; Bartosz SOB; no Fixes/Reported-by/stable Cc.
- [Phase 2] Diff: +27/−6 in mvebu_gpio_resume() only; AND saved masks with mask_cache_priv.
- [Phase 2] Probe in this tree: chip_types[0] level, chip_types[1] edge (drivers/gpio/gpio-mvebu.c ~1291–1305).
- [Phase 2] mask_irq() skips if irqd_irq_masked() (kernel/irq/chip.c:428–431).
- [Phase 2] handle_level_irq() → mask_ack_irq() then irq_can_handle(); disabled lines are not handled (chip.c:686–697, 544–552).
- [Phase 2] gc->lock is raw_spinlock_t (include/linux/irq.h:1052–1053).
- [Phase 3] Blame: resume path from b5b7b487431b0, contained in v3.19-rc1; ancestor of HEAD.
- [Phase 3] No follow-up on gpio-mvebu.c after this candidate.
- [Phase 4] b4 dig -c 02af7eac17bc...: v1 + v2; applied version is v2.
- [Phase 4] b4 dig -w: gpio lists + RT CCs on v2.
- [Phase 4] mbox: Linus Walleij Reviewed-by (v1); Bartosz applied; Siewior “hack” comment; Rosen mentioned unsent v3.
- [Phase 4] b4 mbox -c: no newer revision found.
- [Phase 4] lore.kernel.org WebFetch: 403. UNVERIFIED: stable@ thread.
- [Phase 5] Resume hooked from mvebu_gpio_driver.resume; CONFIG_GPIO_MVEBU default on ARCH_MVEBU (drivers/gpio/Kconfig:509–514).
- [Phase 6] make kernelversion: 6.18.57; git describe HEAD:
v6.18.57-155-gcdf239ca885b2.
- [Phase 6] git show v6.18.57:drivers/gpio/gpio-mvebu.c resume == candidate parent (clean apply).
- [Phase 6] Helios4 DT present:
arch/arm/boot/dts/marvell/armada-388-helios4.dts.
- [Phase 8] Failure mode: chained level IRQ storm → resume hang, severity CRITICAL for mvebu boards.
**YES**
drivers/gpio/gpio-mvebu.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-)
drivers/gpio/gpio-mvebu.c +27 -6
@@ -1006,6 +1006,8 @@ static int mvebu_gpio_suspend(struct platform_device *pdev, pm_message_t state)static int mvebu_gpio_resume (struct platform_device *pdev) {struct mvebu_gpio_chip *mvchip =platform_get_drvdata (pdev); +u32 edge_cache = ~0U , level_cache = ~0U ; +unsigned long flags;int i; regmap_write(mvchip->regs, GPIO_OUT_OFF + mvchip->offset,
@@ -1017,32 +1019,51 @@ static int mvebu_gpio_resume(struct platform_device *pdev)regmap_write (mvchip->regs,GPIO_IN_POL_OFF + mvchip->offset, mvchip->in_pol_reg); +/* +* genirq skips mask_irq() for a line it already considers masked, so +* unmasking one behind its back leaves an asserted level line that +* nobody masks. Restore only bits the irqchip cache still has set. +* +* Snapshot the caches under the raw spinlock, but release it before +* the regmap writes below: regmap_write() takes a sleepable lock on +* PREEMPT_RT. +*/ +if (mvchip->domain) { +struct irq_chip_generic *gc; + + gc =irq_get_domain_generic_chip (mvchip->domain,0 ); +raw_spin_lock_irqsave (&gc->lock, flags); + level_cache = gc->chip_types[0 ].mask_cache_priv; + edge_cache = gc->chip_types[1 ].mask_cache_priv; +raw_spin_unlock_irqrestore (&gc->lock, flags); + } +switch (mvchip->soc_variant) {case MVEBU_GPIO_SOC_VARIANT_ORION :case MVEBU_GPIO_SOC_VARIANT_A8K :regmap_write (mvchip->regs,GPIO_EDGE_MASK_OFF + mvchip->offset, - mvchip->edge_mask_regs[0 ]); + mvchip->edge_mask_regs[0 ] & edge_cache);regmap_write (mvchip->regs,GPIO_LEVEL_MASK_OFF + mvchip->offset, - mvchip->level_mask_regs[0 ]); + mvchip->level_mask_regs[0 ] & level_cache);break ;case MVEBU_GPIO_SOC_VARIANT_MV78200 :for (i =0 ; i <2 ; i++) {regmap_write (mvchip->regs,GPIO_EDGE_MASK_MV78200_OFF (i), - mvchip->edge_mask_regs[i]); + mvchip->edge_mask_regs[i] & edge_cache);regmap_write (mvchip->regs,GPIO_LEVEL_MASK_MV78200_OFF (i), - mvchip->level_mask_regs[i]); + mvchip->level_mask_regs[i] & level_cache); }break ;case MVEBU_GPIO_SOC_VARIANT_ARMADAXP :for (i =0 ; i <4 ; i++) {regmap_write (mvchip->regs,GPIO_EDGE_MASK_ARMADAXP_OFF (i), - mvchip->edge_mask_regs[i]); + mvchip->edge_mask_regs[i] & edge_cache);regmap_write (mvchip->regs,GPIO_LEVEL_MASK_ARMADAXP_OFF (i), - mvchip->level_mask_regs[i]); + mvchip->level_mask_regs[i] & level_cache); }break ;default :
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] gpio: mvebu: keep resume masks within the irqchip cache
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] gpio: mvebu: TOCTOU race in mvebu_gpio_resume() after dropping gc->lock - [High] gpio: mvebu…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] gpio: mvebu: TOCTOU race in mvebu_gpio_resume() after dropping gc->lock
- [High] gpio: mvebu: wrong regmap used for Armada XP masks in mvebu_gpio_resume() --
commit 3f933b6bd33ac55ae181080e42e681c5eace741e
Author: Rosen Penev <[email protected]>
gpio: mvebu: keep resume masks within the irqchip cache
This commit updates mvebu_gpio_resume() to mask the saved edge and level interrupt mask registers against the generic irqchip mask_cache_priv values before writing them back to hardware on resume.
Quoted 25 lines
drivers/gpio/gpio-mvebu.c +10
-0@@ -1006,6 +1006,8 @@ static int mvebu_gpio_suspend(struct platform_device *pdev, pm_message_t state)static int mvebu_gpio_resume (struct platform_device *pdev) {struct mvebu_gpio_chip *mvchip =platform_get_drvdata (pdev); +u32 edge_cache = ~0U , level_cache = ~0U ; +unsigned long flags;int i; regmap_write(mvchip->regs, GPIO_OUT_OFF + mvchip->offset,@@ -1017,32 +1019,51 @@ static int mvebu_gpio_resume(struct platform_device *pdev)regmap_write (mvchip->regs,GPIO_IN_POL_OFF + mvchip->offset, mvchip->in_pol_reg); +/* +* genirq skips mask_irq() for a line it already considers masked, so +* unmasking one behind its back leaves an asserted level line that +* nobody masks. Restore only bits the irqchip cache still has set. +* +* Snapshot the caches under the raw spinlock, but release it before +* the regmap writes below: regmap_write() takes a sleepable lock on +* PREEMPT_RT.
drivers/gpio/gpio-mvebu.c static int mvebu_gpio_resume(struct platform_device *pdev) · line 1039
Quoted 10 lines
drivers/gpio/gpio-mvebu.c +10
-0+*/ +if (mvchip->domain) { +struct irq_chip_generic *gc; + + gc =irq_get_domain_generic_chip (mvchip->domain,0 ); +raw_spin_lock_irqsave (&gc->lock, flags); + level_cache = gc->chip_types[0 ].mask_cache_priv; + edge_cache = gc->chip_types[1 ].mask_cache_priv; +raw_spin_unlock_irqrestore (&gc->lock, flags); + }
[Severity: High]
Can dropping gc->lock and restoring local interrupts before writing the hardware mask registers race with the irqchip mask and unmask callbacks?
The irqchip callbacks such as mvebu_gpio_level_irq_mask() and mvebu_gpio_level_irq_unmask() hold gc->lock across both updating ct->mask_cache_priv and updating the hardware mask register:
drivers/gpio/gpio-mvebu.c:mvebu_gpio_level_irq_mask() {
guard(raw_spinlock)(&gc->lock);
ct->mask_cache_priv &= ~mask;
mvebu_gpio_write_level_mask(mvchip, ct->mask_cache_priv);
}Since mvebu_gpio_resume() runs during dpm_resume() after dpm_resume_noirq() -> resume_device_irqs() has re-enabled device interrupts, if a level GPIO interrupt fires in the window between raw_spin_unlock_irqrestore() and regmap_write(), the interrupt path:
mvebu_gpio_irq_handler()
-> handle_level_irq()
-> mask_ack_irq()
-> mvebu_gpio_level_irq_mask()will clear the bit in ct->mask_cache_priv, mask the hardware register, and set IRQD_IRQ_MASKED in genirq. When mvebu_gpio_resume() then calls regmap_write() with its stale level_cache snapshot where the bit is still 1, won't it unmask the asserted level line in hardware behind genirq's back and cause the same unhandled level interrupt storm on resume?
Similarly, if an in-flight IRQF_ONESHOT threaded handler finishes via irq_finalize_oneshot() -> unmask_threaded_irq() or another CPU calls enable_irq() -> unmask_irq() during that window, the unmask callback will set the bit in ct->mask_cache_priv and unmask the hardware register under gc->lock. Won't mvebu_gpio_resume() then overwrite the hardware register with a stale 0 bit from level_cache or edge_cache, leaving the interrupt permanently masked in hardware while genirq considers it unmasked?
Quoted 25 lines
drivers/gpio/gpio-mvebu.c +5
-4+switch (mvchip->soc_variant) {case MVEBU_GPIO_SOC_VARIANT_ORION :case MVEBU_GPIO_SOC_VARIANT_A8K :regmap_write (mvchip->regs,GPIO_EDGE_MASK_OFF + mvchip->offset, - mvchip->edge_mask_regs[0 ]); + mvchip->edge_mask_regs[0 ] & edge_cache);regmap_write (mvchip->regs,GPIO_LEVEL_MASK_OFF + mvchip->offset, - mvchip->level_mask_regs[0 ]); + mvchip->level_mask_regs[0 ] & level_cache);break ;case MVEBU_GPIO_SOC_VARIANT_MV78200 :for (i =0 ; i <2 ; i++) {regmap_write (mvchip->regs,GPIO_EDGE_MASK_MV78200_OFF (i), - mvchip->edge_mask_regs[i]); + mvchip->edge_mask_regs[i] & edge_cache);regmap_write (mvchip->regs,GPIO_LEVEL_MASK_MV78200_OFF (i), - mvchip->level_mask_regs[i]); + mvchip->level_mask_regs[i] & level_cache); }break ;case MVEBU_GPIO_SOC_VARIANT_ARMADAXP :for (i =0 ; i <4 ; i++) {
drivers/gpio/gpio-mvebu.c static int mvebu_gpio_resume(struct platform_device *pdev) · line 1068
Quoted 10 lines
drivers/gpio/gpio-mvebu.c +2
-2regmap_write (mvchip->regs,GPIO_EDGE_MASK_ARMADAXP_OFF (i), - mvchip->edge_mask_regs[i]); + mvchip->edge_mask_regs[i] & edge_cache);regmap_write (mvchip->regs,GPIO_LEVEL_MASK_ARMADAXP_OFF (i), - mvchip->level_mask_regs[i]); + mvchip->level_mask_regs[i] & level_cache); }break ;
[Severity: High]
On MVEBU_GPIO_SOC_VARIANT_ARMADAXP, are these masked writes targeting the wrong regmap in mvebu_gpio_resume() (and similarly in mvebu_gpio_suspend())?
In mvebu_gpioreg_edge_mask(), mvebu_gpioreg_level_mask(), and mvebu_gpio_probe(), the per-CPU mask registers at GPIO_EDGE_MASK_ARMADAXP_OFF(cpu) and GPIO_LEVEL_MASK_ARMADAXP_OFF(cpu) live in mvchip->percpu_regs rather than mvchip->regs:
drivers/gpio/gpio-mvebu.c:mvebu_gpioreg_edge_mask() {
case MVEBU_GPIO_SOC_VARIANT_ARMADAXP:
cpu = smp_processor_id();
*map = mvchip->percpu_regs;
*offset = GPIO_EDGE_MASK_ARMADAXP_OFF(cpu);
break;
}drivers/gpio/gpio-mvebu.c:mvebu_gpio_probe() {
case MVEBU_GPIO_SOC_VARIANT_ARMADAXP:
regmap_write(mvchip->regs, GPIO_EDGE_CAUSE_OFF, 0);
regmap_write(mvchip->regs, GPIO_EDGE_MASK_OFF, 0);
regmap_write(mvchip->regs, GPIO_LEVEL_MASK_OFF, 0);
for (cpu = 0; cpu < 4; cpu++) {
regmap_write(mvchip->percpu_regs,
GPIO_EDGE_CAUSE_ARMADAXP_OFF(cpu), 0);
regmap_write(mvchip->percpu_regs,
GPIO_EDGE_MASK_ARMADAXP_OFF(cpu), 0);
regmap_write(mvchip->percpu_regs,
GPIO_LEVEL_MASK_ARMADAXP_OFF(cpu), 0);
}
break;
}By passing mvchip->regs instead of mvchip->percpu_regs here, won't mvebu_gpio_resume() leave the per-CPU mask registers in mvchip->percpu_regs unupdated while writing the edge_cache and level_cache masked values over the global GPIO registers at offsets 0x10..0x2c in mvchip->regs (such as GPIO_EDGE_CAUSE_OFF at 0x14, GPIO_LEVEL_MASK_OFF at 0x1c, and GPIO_BLINK_CNT_SELECT_OFF at 0x20)?
Quoted 1 line
drivers/gpio/gpio-mvebu.c +0
-0default :
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 kconfig: abort rather than loop for ever on EOF
In reply to Sasha LevinFrom: Simon Glass <[email protected]>
[ Upstream commit f915149f5cfbd0d4406ec0b0f57b1d2c8685ae55 ]
When a non-interactive 'make oldconfig' or 'syncconfig' meets a new int or hex symbol whose default cannot be applied, conf_string() reads a value from stdin. At end of file fgets() returns NULL, no value is set and the loop asks again. The result is an endless loop which fills the output until it exhausts memory, rather than a clean failure.
Detect this in conf_string(): if the value cannot be set and stdin is at end of file, stop with an error that names the symbol.
Note that a symbol with no default doesn't trigger this, since sym_calc_value() falls back to 0, which is accepted at end of file. The loop is triggered by a broken Kconfig file, with a default whose text fails sym_string_valid().
Such mistakes do creep in from time to time and are hard to debug, since the build fills the log with repeated prompts instead of pointing at the offending symbol. Some bad defaults draw a parse-time warning, but menu_validate_number() accepts a reference to any int or hex symbol, so a cross-type reference loops with no warning at all. For example, "0xff" is not a valid int value:
config HEXSYM
hex
default 0xff config VAL
int "Value"
default HEXSYM
Interactive use is unaffected, since feof() only becomes true once a read actually hits end of file: an invalid answer at a terminal still re-prompts, while Ctrl-D at such a prompt exits with the error instead of looping. bool and tristate symbols and choices already accept the default on an empty line, so they still take their defaults in a non-interactive build.
Tested with int and hex symbols carrying such defaults: with empty stdin, the code without this change produces around 190MB of repeated prompts within two seconds, while with the change it exits 1 naming the symbol. Piped and interactive (pty) sessions still re-prompt on an invalid answer and then accept a valid one. A new string symbol with no default still takes the empty string at end of file, since any text is valid for a string.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
Record: **[kconfig]** **[abort]** stop conf_string() from looping forever when stdin hits EOF.
**Step 1.2 — Tags**
Record:
- Signed-off-by: Simon Glass <[email protected]> (author)
- `Link:
https://patch.msgid.link/[email protected]`
- Signed-off-by: Nicolas Schier <[email protected]> (kbuild maintainer, applied)
- No Fixes:, Cc: stable, Reported-by, Tested-by, Reviewed-by, or Acked-by (absence of Fixes:/Cc: stable is expected for this review)
- Pipeline Signed-off-by: Sasha Levin / [Upstream commit …] ignored per instructions
**Step 1.3 — Body**
Record:
- **Bug:** non-interactive make oldconfig / syncconfig on a **new int or hex** symbol whose default fails sym_string_valid(); fgets() returns NULL at EOF; the value is never set; while (1) re- prompts.
- **Symptom:** endless loop; output grows until the host OOMs (~190MB of repeated prompts in two seconds without the fix).
- **Root cause:** broken Kconfig default (e.g. int defaulting to a hex symbol whose text is 0xff). menu_validate_number() accepts any int/hex symbol, so there is no parse-time warning for the cross- type case. A symbol with **no** default does not loop:
sym_calc_value() falls back to 0, which is valid.
- **Failure mode:** host-side hang + unbounded memory/log growth during config/build, not a runtime kernel oops.
- **Versions:** none named; the loop is in conf_string(), which has been in this form since the git import.
**Step 1.4 — Hidden bug fix?**
Record: **No disguise.** This is an explicit infinite-loop / OOM abort. Not cleanup or a feature.
---
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
Record:
- File: scripts/kconfig/conf.c only (+17 / -0 in the committed form)
- Function: conf_string()
- Scope: single-function, surgical
**Step 2.2 — Flow**
Record: After sym_set_string_value() fails, the loop used to retry forever. After the change, if feof(stdin) it prints error: no value for new symbol '%s' at end of input and exit(1). Interactive invalid input still re-prompts (feof is false until a real EOF). Ctrl-D now exits instead of spinning.
**Step 2.3 — Bug mechanism**
Record: **Logic / hang.** Host while (1) with no EOF termination. Not UAF, leak, race, or kernel memory unsafety.
Verified in this tree:
```77:161:scripts/kconfig/conf.c
static void xfgets(char *str, int size, FILE *in)
{
if (!fgets(str, size, in))
fprintf(stderr, "\nError in reading or end of file.\n");
if (!tty_stdio)
printf("%s", str);
}
// ...
static int conf_string(struct menu *menu)
{
// ...
while (1) {
// prompt + conf_askvalue() -> xfgets(stdin)
if (def && sym_set_string_value(sym, def))
return 0;
// no feof() check — loops forever
}
}
```conf_askvalue() pre-sets line[0] = '\n'. On EOF, fgets() fails, line stays "\n", the case '\n' path keeps the invalid default, sym_set_string_value() fails (sym_string_within_range() → sym_string_valid()), and the loop repeats. xfgets() also reprints the buffer when stdin is not a tty, which is why logs explode.
menu_validate_number() in scripts/kconfig/menu.c accepts any S_INT/S_HEX symbol, matching the commit’s “no parse-time warning” claim. sym_string_valid() for S_INT rejects a leading 0x form (0xff is not a valid int).
**Step 2.4 — Fix quality**
Record: **Obviously correct and minimal.** feof(stdin) after a failed set is the right abort. exit(1) matches other fatal kconfig paths in this file. Regression risk is **low**: valid defaults still apply on empty/EOF input; bool/tristate/choice are unchanged; strings still accept any text. Remaining gap (not a regression): a non-EOF fgets error (ferror without feof) would still loop — pre-existing.
---
## Phase 3: Git history
**Step 3.1 — Blame**
Record: The while (1) / sym_set_string_value loop in conf_string() is from **1da177e4c3f41 (Linux-2.6.12-rc2, 2005)**. It is not new code. This tree already has a related robustness backport in the same
file: 35d8e7e7da7a6 (kconfig: fix potential NULL pointer dereference in conf_askvalue).
**Step 3.2 — Fixes: tag**
Record: **None.** Bug is ancient, not tied to a later introducing commit.
**Step 3.3 — File history**
Record: Recent scripts/kconfig/conf.c work in this tree is small robustness/build fixes, not a refactor of conf_string(). No prerequisite series. Standalone.
**Step 3.4 — Author**
Record: Simon Glass (Chromium). No prior scripts/kconfig/ commits in **this** 5.10 history. Applied by kbuild maintainer Nicolas Schier.
**Step 3.5 — Dependencies**
Record: **None.** Uses existing feof, fprintf, exit, sym->name. conf_string() already prints sym->name unconditionally. **Can apply standalone.**
git merge-base --is-ancestor f915149f5cfbd0d4406ec0b0f57b1d2c8685ae55 HEAD → **not an ancestor** (not in this tree yet). Object exists in the repo but is not on pending-5.10.
---
## Phase 4: Mailing list / external
**Step 4.1 — Original discussion**
Record:
- Lore/msgid:
https://patch.msgid.link/[email protected]
- b4 dig -c f915149f5cfbd0d4406ec0b0f57b1d2c8685ae55 matched by patch- id
- b4 dig -a: **v1 only** (no v2/v3)
- Thread: 2 messages — patch + maintainer apply
- Nicolas Schier: “Applied to kbuild/linux.git (kbuild-next-unstable)” (https://git.kernel.org/kbuild/c/7b406f92)
- **No NAK**, no requested changes, no reviewer Cc: stable
**Step 4.2 — Recipients (b4 dig -w)**
Record: Simon Glass; LKML; **Nathan Chancellor**; **Nicolas Schier**; Xingjing Deng; **linux-kbuild**. Right kbuild maintainers were on the patch.
**Step 4.3 — Bug report**
Record: No syzbot/bugzilla. Author describes a reproducible host hang and measured 190MB/2s growth. Chromium kconfig/oldconfig is a realistic LTS-style workload.
**Step 4.4 — Series**
Record: **Standalone 1/1.** No sibling patches required.
**Step 4.5 — Stable list**
Record: **No stable-list discussion found** (lore.kernel.org HTTP 403 via WebFetch; web search of lore.kernel.org/stable did not hit this subject). Not treated as a negative.
No revert/follow-up found in search after the apply note.
---
## Phase 5: Semantic / call graph
**Step 5.1 — Functions**
Record: **conf_string()** only.
**Step 5.2 — Callers**
Record: In scripts/kconfig/conf.c, conf() calls conf_string() for S_INT / S_HEX / S_STRING. check_conf() (oldconfig/syncconfig restart loop at conf.c:687-690) calls conf(). nconf.c/mconf.c have **separate** conf_string() implementations; this patch does not touch those (ncurses/menuconfig UI).
**Step 5.3 — Callees**
Record: conf_askvalue() → xfgets() → fgets(stdin); sym_get_string_value(); sym_set_string_value() → sym_string_within_range() → sym_string_valid().
**Step 5.4 — Reachability**
Record: **Yes, from a normal kernel build.** Makefile includes auto.conf.cmd and runs **syncconfig** when Kconfig changes (Makefile ~706–732). oldconfig/syncconfig are everyday for CI and distro builds. Unprivileged userspace syscalls are irrelevant; this is **host kconfig**, triggered by make.
**Step 5.5 — Similar patterns**
Record: This tree already backported other kconfig infinite-loop fixes, e.g. 87ddba29e72be (macro expand at EOF) and cc1956f8b278d (nconf endless search). Same class of host hang.
---
## Phase 6: This tree (5.10.270 / pending-5.10)
**Step 6.1 — Buggy code present?**
Record: **Yes.** scripts/kconfig/conf.c conf_string() lines 130–161:
same while (1) without feof(). Introduced in 2.6.12-rc2; present for the entire 5.10 lifetime. feof(stdin) is **not** in this file today.
**Step 6.2 — Backport difficulty**
Record: **Clean apply.** Context around if (def && sym_set_string_value(sym, def)) return 0; matches; only line numbers differ (~158 here vs ~348 upstream).
**Step 6.3 — Alternate fix already here?**
Record: **No.** Grep for feof(stdin) and no value for new symbol in scripts/kconfig is empty. The conf_askvalue NULL-def fix is adjacent but does not stop the EOF loop.
---
## Phase 7: Subsystem context
**Step 7.1**
Record: **kbuild/kconfig** (scripts/kconfig/). **IMPORTANT** for anyone who **builds** this kernel (distros, CI, ChromeOS-style LTS, embedded). Not a runtime CORE path (mm/net/fs).
**Step 7.2**
Record: kconfig in this tree is mature; changes are occasional robustness backports, not active redesign. Long-lived bug, not a last- month feature.
---
## Phase 8: Impact and risk
**Step 8.1 — Who**
Record: **Config/build host users** of this 5.10 tree (oldconfig, syncconfig, automatic make syncconfig). Not running-system users. Distros and out-of-tree Kconfig (ChromeOS, vendor) are in the blast radius when they add int/hex symbols.
**Step 8.2 — Trigger**
Record: New visible int/hex symbol whose **default string fails validation**, plus **EOF on stdin** (non-interactive oldconfig/syncconfig, typical CI). Not every boot. Unprivileged kernel
syscall: no. **Kconfig authors and kernel builders:** yes. Author: these mistakes “creep in from time to time.”
**Step 8.3 — Severity**
Record: Host **infinite loop + unbounded memory/log growth** (OOM of conf, hung make). **HIGH** for the build, not a kernel panic. Vanilla 5.10 Kconfig may be clean **today**; the bug is in the **tool**, so the next bad default in a stable/Kconfig backport turns a warning- shaped mistake into a CI disk/memory incident.
**Step 8.4 — Risk vs benefit**
Record: **Benefit: high for builders** (fail fast, name the symbol). **Risk: very low** (~8 lines of real code + comment, error path only, no kernel ABI). Ratio favors backport.
---
## Phase 9: Synthesis
**For**
- Real, demonstrated infinite loop and memory blow-up in conf_string()
- Triggered by oldconfig/syncconfig, including automatic build-time syncconfig
- Buggy loop exists in this 5.10 tree since 2.6.12
- Tiny, obviously correct, maintainer-applied, author-tested
- Matches the **build-fix** exception (prevents a hung/OOM configurator)
- This tree already takes kconfig hang/crash backports, including in the same file
**Against**
- Host tool, not a runtime kernel crash
- Needs a **broken Kconfig default**, not a typical .config
- No Reported-by / syzbot / stable nomination
- No evidence of a currently broken in-tree 5.10 symbol (not searched exhaustively across all Kconfig files)
**Unresolved**
- Could not HTTP-fetch lore.kernel.org (403); thread recovered via b4 mbox
- Did not prove a current in-tree 5.10 Kconfig that trips sym_string_valid(); the tool bug is still present
**Stable rules**
1. Obviously correct and tested — **PASS** (v1 applied as-is; author tested empty/piped/pty)
2. Real bug affecting users — **PASS** (build hang/OOM; Chromium author)
3. Important (hang/OOM of configurator during make) — **PASS**
4. Small and contained — **PASS** (one function, +17)
5. No new features/APIs — **PASS**
6. Applies to this tree — **PASS** (clean)
**Exception:** build fix (stop compilation/config hang).
The patch should be backported to **this** 5.10.270 tree: the loop is here, the fix is surgical, and a silent spin that fills logs until OOM is exactly what stable builders cannot afford when a later Kconfig default is wrong.
Verification:
- [Phase 1] Tags: Glass SOB, msgid link, Schier SOB; no Fixes/Reported- by/Cc:stable
- [Phase 2] conf_string() in this tree: while (1) with no feof; xfgets prints on EOF; sym_string_valid(S_INT) rejects 0xff; menu_validate_number() accepts any int/hex
- [Phase 3] Blame: 1da177e4c3f41; git merge-base --is-ancestor f915149f5cfbd0d4406ec0b0f57b1d2c8685ae55 HEAD is false
- [Phase 3] Same-file backport already here: 35d8e7e7da7a6 conf_askvalue NULL def
- [Phase 4] b4 dig/b4 mbox: v1 only; Schier applied to kbuild-next- unstable; no NAK
- [Phase 4] Recipients: Nathan Chancellor, Nicolas Schier, linux-kbuild
- [Phase 5] Caller: conf() → conf_string(); Makefile runs syncconfig
- [Phase 6] git describe HEAD / make kernelversion: **5.10.270** pending-5.10; buggy code at conf.c:130-161
- [Phase 6] Apply context matches; no existing feof(stdin) in kconfig
- [Phase 8] Failure: host infinite loop + unbounded output; HIGH for builds
- UNVERIFIED: live lore.kernel.org HTML (403); whether any current 5.10 Kconfig default already fails sym_string_valid()
**YES**
scripts/kconfig/conf.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
scripts/kconfig/conf.c +17 -0
@@ -348,6 +348,23 @@ static int conf_string(struct menu *menu) }if (def &&sym_set_string_value (sym, def))return 0 ; + +/* +* A new int or hex symbol whose default fails validation +* cannot be set from an empty answer. When standard input is +* exhausted, as it is for a non-interactive oldconfig or +* syncconfig, re-asking would loop forever and grow the output +* until it exhausts memory. Stop with an error that names the +* symbol instead. String symbols accept any text, and bool and +* tristate symbols (conf_sym()) and choices (conf_choice()) +* accept the default on an empty line, so they are unaffected. +*/ +if (feof (stdin)) { +fprintf (stderr, +"\nerror: no value for new symbol '%s' at end of input\n" , + sym->name); +exit (1 ); + } } }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 tap: fix incorrect variable used for USO check in set_offload()
In reply to Sasha LevinFrom: Rongguang Wei <[email protected]>
[ Upstream commit fac7973f004de6dd51fb15a33e33ed37718e58bb ]
The USO features in set_offload() incorrectly uses feature_mask and features argument.
The USO feature was written to the local features variable instead of feature_mask. All other offload bits (TSO, TSO_ECN) are stored in feature_mask which becomes tap->tap_features and is used by tap_handle_frame() for GSO segmentation. Without NETIF_F_GSO_UDP_L4 in tap->tap_features, making USO on tap effectively non-functional.
Keeping the USO handling inside the TUN_F_CSUM block avoids enabling GRO/LRO when userspace requests USO without CSUM.
This has not worked since the beginning, so
commit 399e0827642f ("driver/net/tun: Added features for USO.")
---
LLM Generated explanations, may be completely bogus:
I have enough to decide: the buggy USO assignment is in this 6.12 tree, the patch applies, and it is a real offload correctness bug rather than a crash fix.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [tap] [fix] incorrect variable used for USO check in set_offload()
- Subsystem: tap (macvtap/ipvtap shared driver, drivers/net/tap.c)
- Verb: **fix** — explicit bug fix, not cleanup/refactor
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record (from the commit under review / fac7973f004de6dd51fb15a33e33ed37718e58bb):
- No Fixes: tag in the applied commit (the mailing-list v2 had `Fixes:
399e0827642f`; Jakub rewrote it to prose)
- No Reported-by:, Tested-by:, Acked-by:, `Cc:
[email protected]`
- Reviewed-by: Willem de Bruijn <[email protected]> (TUN/TAP maintainer)
- `Link:
https://patch.msgid.link/[email protected]`
- Signed-off-by: Rongguang Wei <[email protected]> (author, KylinOS)
- Signed-off-by: Jakub Kicinski <[email protected]> (netdev maintainer)
- Pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] ignored per instructions
Notable: original [PATCH net v2] submission **did** carry `Fixes:
399e0827642f`. Absence of that tag in the applied message is editorial, not evidence the bug is fictional.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** set_offload() writes NETIF_F_GSO_UDP_L4 into the local features copy instead of feature_mask. tap->tap_features = feature_mask, and tap_handle_frame() uses tap_features for GSO. USO therefore never lands in the forward feature mask.
- **Second bug (same hunk):** the GRO/LRO (RX_OFFLOADS) test compares feature_mask (NETIF_F_* bits) against TUN_F_USO4|TUN_F_USO6 (ioctl flags 0x20/0x40). That comparison is always false.
- **Symptom:** TUNSETOFFLOAD with USO is a no-op. UDP GSO superframes are software-segmented before userspace; USO on tap/macvtap/ipvtap has never worked.
- **Version info:** “has not worked since the beginning” — introduced by 399e0827642f (v6.2-rc1).
- **Root cause:** wrong destination variable plus type-confused bit test.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Subject, body, and diff all describe a real logic bug. Not style/cleanup.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/net/tap.c only
- Scope: **single-file surgical fix**, 2 insertions / 3 deletions (net +2 / −3)
- Function: set_offload()
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record, verified against local set_offload() atdrivers/net/tap.c:952:
Hunk 1 (USO assignment, inside if (arg & TUN_F_CSUM)):
- **Before:** features |= NETIF_F_GSO_UDP_L4 (features is a copy of tap->dev->features)
- **After:** feature_mask |= NETIF_F_GSO_UDP_L4 (same place TSO/TSO6/CSUM are recorded)
- Path: TUNSETOFFLOAD ioctl, not a hot RX path itself; result is consumed on every tap_handle_frame() RX.
Hunk 2 (RX_OFFLOADS / GRO+LRO decision):
- **Before:** enable RX_OFFLOADS if TSO is in feature_mask **or** if feature_mask has both TUN_F_USO* bits (impossible: those are ioctl flags, not netdev features)
- **After:** enable RX_OFFLOADS if feature_mask has TSO, TSO6, **or** NETIF_F_GSO_UDP_L4
- USO still only set inside the TUN_F_CSUM block, so USO-without-CSUM does not turn on GRO/LRO (v1 regression that v2 closed)
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Logic / correctness** (wrong variable + type-confused bit test).
- Mechanism: USO bit stored where update_features() later sees a device-feature snapshot, not in tap_features. tap_handle_frame() then calls netif_needs_gso() without NETIF_F_GSO_UDP_L4, so every SKB_GSO_UDP_L4 frame is split by __skb_gso_segment().
- The TUN_F_* test vs feature_mask is always false: TUN_F_USO4=0x20 is bit 5 (NETIF_F_HIGHDMA), TUN_F_USO6=0x40 is bit 6 (NETIF_F_FRAGLIST). feature_mask only ever holds HW_CSUM/TSO/TSO_ECN/TSO6.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct; mirrors TSO handling and tun.c’s working USO path. Minimal, no API change. Regression risk is low: typical QEMU already sets CSUM+TSO+USO together, so GRO/LRO was already on via TSO. After the fix, userspace that **asked** for USO actually receives UDP GSO frames — the documented TUNSETOFFLOAD contract. v2 specifically avoided enabling GRO/LRO for USO without CSUM.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: Both buggy lines introduced by 399e0827642f6 (“driver/net/tun:
Added features for USO.”), Andrew Melnychenko, 2022-12-07. Contained in v6.2-rc1 (git describe --contains → v6.2-rc1~99^2~30^2~3). Present and unchanged in this tree since then (git merge-base --is-ancestor 399e0827642f HEAD → yes).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: Applied commit has no Fixes: tag; mailing-list v2 named 399e0827642f. That commit **is** in this tree. It added USO to both tun.c and tap.c; tun.c stores USO in the mask that becomes tun->set_features (works). tap.c used the wrong variable (broken). No later same-issue fix in 399e0827642f..HEAD -- drivers/net/tap.c.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent tap.c history in this tree is unrelated (XDP skb->dev, page leaks, short-frame check). On origin/master after this fix: only an unrelated VLAN transport_header change. **Standalone**, not patch N/M.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Author is not the TUN/TAP maintainer (those are Willem de Bruijn and Jason Wang). git log --author='Rongguang Wei' -- drivers/net/ in this tree only shows an unrelated stmmac commit. Reviewer **is** the subsystem maintainer.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Diff uses existing feature_mask, NETIF_F_GSO_UDP_L4, TUN_F_USO4/6, RX_OFFLOADS. git apply --check of fac7973f004de succeeded (hunks at offset 92, matching local line numbers). Can apply standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c fac7973f004de →
https://patch.msgid.link/[email protected]
- Series: **v1** (2026-08-05) then **v2** (2026-08-07); v2 is what was applied.
- v1 only flipped the RX_OFFLOADS test from feature_mask to arg (incomplete; would enable GRO/LRO while still re-segmenting USO).
- Jakub’s review of v1 (https://lore.kernel.org/netdev/20260806163949.28
[email protected]/) flagged the **second** wrong-variable bug (features |= NETIF_F_GSO_UDP_L4 vs feature_mask) and explicitly
warned: *“a backporter reading the changelog would likely conclude USO on tap works afterwards.”* v2 is the complete fix those backporters would expect.
- Willem: Reviewed-by on v1 and again on v2 (“this patch LGTM”). No NAK.
- Patchwork applied it to **netdev/net-next** (fac7973f004d), not the net fixes tree, despite [PATCH net]. No reviewer Cc: stable.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc included Willem de Bruijn (TUN/TAP maintainer), Jakub Kicinski, Jason Wang, Andrew Lunn, netdev@. Right people. Willem re-acked v2.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot, bugzilla, or stack trace. Author is at kylinos.cn (distribution). Impact described by code analysis (Jakub): every USO superframe is segmented before userspace. Lore WebFetch to lore.kernel.org returned 403; thread recovered via b4 mbox instead.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: v1→v2 only; v2 supersedes v1. Willem asked about tun.c; author checked and tun.c is fine (all offload bits go into one features mask). No companion tun patch required. Later origin/master tap.c change is unrelated VLAN header handling.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No stable@ discussion found. UNVERIFIED that nobody requested this on stable@ (lore.kernel.org/stable WebFetch 403). Absence of discussion is not a NAK.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: set_offload() only.
**Step 5.2: TRACE CALLERS**
Record:
- set_offload() ← tap_ioctl() TUNSETOFFLOAD (drivers/net/tap.c:1111-1121), under rtnl_lock(). Userspace ioctl on the tap/macvtap/ipvtap fd (QEMU/libvirt typical).
- Consumers of tap->tap_features: tap_handle_frame() (drivers/net/tap.c:320), registered as RX handler from macvtap_newlink() and ipvtap_newlink().
**Step 5.3: TRACE CALLEES**
Record: rtnl_dereference, tap->update_features() (macvtap_update_features / ipvtap_update_features → netdev_update_features). No alloc/lock added by this patch.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace TUNSETOFFLOAD → set_offload → tap_features → host RX tap_handle_frame → netif_needs_gso / __skb_gso_segment. Reachable from QEMU virtio-net on macvtap/ipvtap with IFF_VNET_HDR. **Yes, userspace-reachable.** Not an interrupt-only or obscure-config path; CONFIG_MACVTAP/CONFIG_IPVTAP are common on virt hosts.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: tun.c set_offload() correctly does features |= NETIF_F_GSO_UDP_L4 then tun->set_features = features. macvtap/ipvtap TUN_OFFLOADS still omit NETIF_F_GSO_UDP_L4 at newlink; that only matters until TUNSETOFFLOAD overwrites tap_features. The ioctl path is the complete fix. No sibling leftover once this lands.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** Local tree is **pending-6.12** / make kernelversion **6.12.111** (git describe HEAD → p-6.12-3-gc504cf0baa3d8).
```977:978:drivers/net/tap.c
if ((arg & (TUN_F_USO4 | TUN_F_USO6)) == (TUN_F_USO4 |
TUN_F_USO6))
features |= NETIF_F_GSO_UDP_L4;
```
```989:990:drivers/net/tap.c
if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6) ||
(feature_mask & (TUN_F_USO4 | TUN_F_USO6)) == (TUN_F_USO4 |
TUN_F_USO6))
```git merge-base --is-ancestor fac7973f004de HEAD → **not an ancestor** (fix not present). Bug introduced v6.2-rc1, well before 6.12.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** (git apply --check succeeded; line offset only). Surrounding set_offload() body matches mainline. No conflicting 6.12 refactor.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: git log --grep='incorrect variable used for USO' -- drivers/net/tap.c empty. No alternate USO tap fix in this tree.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: Networking TAP/MACVTAP/IPVTAP (drivers/net/tap.c). **IMPORTANT** for virtualization (libvirt macvtap, KVM virtio-net), not core mm/VFS. Not staging.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature. USO addition is from 2022; set_offload() logic dates to the old macvtap path (2013). Low churn in the offload function itself.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / config-specific:** users of macvtap or ipvtap who issue TUNSETOFFLOAD with both USO4 and USO6 (typical QEMU virtio-net USO). tun/tap (drivers/net/tun.c) already works. Not universal.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Userspace sets TUN_F_CSUM|TUN_F_USO4|TUN_F_USO6 (usually with TSO). Then a GSO UDP packet arrives on the macvtap/ipvtap netdev with IFF_VNET_HDR. Not a race. Unprivileged user needs the tap fd (VM process). Common on virt hosts that enable guest USO; silent if nobody requests USO.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Failure mode:** USO advertised via ioctl does not work; kernel always software-segments UDP GSO before queueing to userspace. Packets are still delivered (not a drop/crash on the happy path). __skb_gso_segment() failure can drop a frame (SKB_DROP_REASON_SKB_GSO_SEG). No oops, deadlock, or filesystem corruption.
**Severity: MEDIUM** — functional/performance offload bug, “oh, that’s not good,” not CRITICAL.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** Medium. Restores a userspace-requested virt offload that 6.12 already advertises (TUN_F_USO4/6 accepted by TUNSETOFFLOAD). Helps macvtap UDP throughput (VXLAN/QUIC-style workloads). Distro author.
- **Risk:** Very low. Two-line logic fix, no locking/API/data-structure change, applies cleanly. Behavior change only for fds that **opt in** to USO.
- **Ratio:** Benefit outweighs risk for this LTS virt-host kernel.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR backporting:
- Real, verified logic bug; USO on tap has been a no-op since v6.2, and that code is in 6.12.111
- Tiny, obviously correct; matches working tun.c and TSO handling
- TUN/TAP maintainer Reviewed-by; netdev maintainer applied it
- v2 is complete (v1 would have been a bad backport)
- Userspace ioctl already accepts USO flags; this makes the existing ABI work
- Applies cleanly; no prerequisites
- KylinOS engineer / virt-relevant path (macvtap)
AGAINST:
- Not a crash, security hole, deadlock, or data-corruption bug
- Feature never worked; this is the first time 6.12 would actually pass UDP GSO to tap userspace
- Applied to net-next; Fixes: tag stripped in the git message
- No syzbot/user crash report; four years without a flood of reports
- Performance/offload; segmented delivery still works
UNRESOLVED:
- Could not fetch lore.kernel.org over HTTP (403); used b4 mbox instead
- Could not search stable@ archives the same way (UNVERIFIED no prior stable NAK)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — two-line logic fix, maintainer Reviewed-by, applied upstream.
2. Fixes a real bug that affects users? **PASS** — TUNSETOFFLOAD USO is silently ignored; virt userspace that requests it does not get USO frames.
3. Important issue? **PASS** (as “oh, that’s not good” / notable virt offload failure) — not crash/security. Official rules also allow that class.
4. Small and contained? **PASS** — one function, ~5 lines.
5. No new features or APIs? **PASS** — does not add ioctls or flags; implements flags this tree already accepts.
6. Can apply to the local tree? **PASS** — buggy code present; git apply --check clean.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not a device ID, quirk, DT, build, or doc fix). Qualifies as a normal small correctness fix.
**Step 9.4: MAKE YOUR DECISION**
This tree is 6.12.y. The bug exists here, the introducing commit is here, and the fix is self-contained. Stable users of macvtap/ipvtap who already request USO get a no-op today; backporting restores the intended offload with negligible regression risk. That meets the 6.12 bar even though it is not a panic-class bug.
Verification:
- [Phase 1] Parsed subject/tags/body: fix of wrong USO variable; Reviewed-by Willem; Link msgid 20260807070914.112698-1; no Cc: stable in applied message
- [Phase 2] Diff: features |= NETIF_F_GSO_UDP_L4 → feature_mask |= ...; RX_OFFLOADS test uses NETIF_F_GSO_UDP_L4. Confirmed against drivers/net/tap.c:952-1003
- [Phase 2] TUN_F_USO4/6 = 0x20/0x40 vs netdev bits 5/6 (HIGHDMA/FRAGLIST): check vs feature_mask always false. Confirmed in include/uapi/linux/if_tun.h and include/linux/netdev_features.h
- [Phase 3] git blame -L 976,990 drivers/net/tap.c: both lines from 399e0827642f6; git describe --contains → v6.2-rc1; ancestor of HEAD
- [Phase 3] git merge-base --is-ancestor fac7973f004de HEAD → no (fix not in this tree)
- [Phase 3] git show 399e0827642f6 -- drivers/net/tap.c: original USO addition used the wrong variable from day one
- [Phase 3] tun.c set_offload correctly stores USO in features / set_features (lines 2938-2950)
- [Phase 4] b4 dig -c fac7973f004de: lore thread found; -a showed v1 and v2; -w listed Willem/Jakub/Jason/netdev
- [Phase 4] b4 dig -m /tmp/tap-uso-thread.mbox: Willem LGTM; tun.c checked, no extra patch
- [Phase 4] v1 mbox: only the RX_OFFLOADS arg vs feature_mask flip; incomplete
- [Phase 4] Kuba 20260806163949: identified missing feature_mask |= NETIF_F_GSO_UDP_L4 and warned backporters about a half-fix
- [Phase 5] Callers: tap_ioctl TUNSETOFFLOAD; tap_handle_frame uses tap_features; registered from macvtap.c:101 and ipvtap.c:93
- [Phase 5] netif_needs_gso() in include/linux/netdevice.h:5115 — GSO skb segmented when features lack that GSO type
- [Phase 6] git describe HEAD / make kernelversion: p-6.12-3 / 6.12.111; buggy assignment present at tap.c:978
- [Phase 6] git show fac7973f004de -- drivers/net/tap.c | git apply --check → hunks succeeded at offset 92
- [Phase 7] MAINTAINERS: TUN/TAP driver, Willem de Bruijn + Jason Wang
- [Phase 8] Failure mode: USO non-functional / extra software GSO, not oops; severity MEDIUM
- UNVERIFIED: HTTP lore.kernel.org and lore.kernel.org/stable searches (403); content recovered via b4 instead
The problem is a two-line mix-up that makes tap/macvtap/ipvtap USO a no- op on this 6.12 tree. It meets stable rules: obviously correct, real bug, small, no new API, applies cleanly. Risk is very low because only USO-opt-in userspace changes behavior, and that change is the documented ioctl contract.
**YES**
drivers/net/tap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/tap.c +2 -3
@@ -883,7 +883,7 @@ static int set_offload(struct tap_queue *q, unsigned long arg)/* TODO: for now USO4 and USO6 should work simultaneously */ if ((arg & (TUN_F_USO4 |TUN_F_USO6 )) == (TUN_F_USO4 |TUN_F_USO6 )) - features |=NETIF_F_GSO_UDP_L4 ; + feature_mask |=NETIF_F_GSO_UDP_L4 ; }/* tun/tap driver inverts the usage for TSO offloads, where
@@ -894,8 +894,7 @@ static int set_offload(struct tap_queue *q, unsigned long arg)* When user space turns off TSO, we turn off GSO/LRO so that * user-space will not receive TSO frames. */ -if (feature_mask & (NETIF_F_TSO |NETIF_F_TSO6 ) || - (feature_mask & (TUN_F_USO4 |TUN_F_USO6 )) == (TUN_F_USO4 |TUN_F_USO6 )) +if (feature_mask & (NETIF_F_TSO |NETIF_F_TSO6 |NETIF_F_GSO_UDP_L4 )) features |=RX_OFFLOADS ;else features &= ~RX_OFFLOADS ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 HID: quirks: add ALWAYS_POLL quirk for AULA Mini 60 HE Pro Dongle
In reply to Sasha LevinFrom: Yuxiang Lin <[email protected]>
[ Upstream commit 2884e21b18613708f050ec75330b265dd07ecc03 ]
The AULA Mini 60 HE Pro wireless keyboard dongle (USB ID 0c45:fefe) becomes unresponsive after roughly one minute of idle. No error appears in dmesg; the only recovery is physically replugging the dongle.
This has been reproduced across kernels 6.8, 6.14 and 7.1.3.
Testing shows HID_QUIRK_ALWAYS_POLL alone resolves the issue, verified via usbhid.quirks=0x0c45:0xfefe:0x400.
---
LLM Generated explanations, may be completely bogus:
This is a hardware-quirk addition for a wireless keyboard dongle that stops responding after idle. The local tree is **5.15.221** (pending-5.15, git describe: p-5.15-2-g9a29d9b0f9507). Upstream commit is 2884e21b18613 (HID: quirks: add ALWAYS_POLL quirk for AULA Mini 60 HE Pro Dongle); git merge-base --is-ancestor confirms it is **not** in this tree.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[HID]** **[add]** **ALWAYS_POLL quirk for AULA Mini 60 HE Pro wireless dongle (USB 0c45:fefe)**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected)
- **Reported-by:** none
- **Tested-by:** none (author describes own testing in the body)
- **Reviewed-by:** none
- **Acked-by:** none
- **Link:** none in the commit; mailing-list Message-ID [email protected]
- **Cc: stable:** none (expected)
- **Signed-off-by:** Yuxiang Lin \<[email protected]\> (author); Jiri Kosina \<[email protected]\> (HID maintainer). Ignore any pipeline SOB.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** AULA Mini 60 HE Pro wireless dongle 0c45:fefe becomes unresponsive after ~1 minute idle.
- **Symptom:** No dmesg error; only recovery is physically replugging the dongle. Keyboard is dead until then.
- **Versions tested by author:** 6.8, 6.14, 7.1.3 (not 5.15 specifically).
- **Root cause (author):** device needs continuous interrupt polling; HID_QUIRK_ALWAYS_POLL alone fixes it, verified with usbhid.quirks=0x0c45:0xfefe:0x400.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is an explicit hardware quirk for a device that stops working. Matches the documented HID ALWAYS_POLL pattern (devices that hang when the host stops polling the interrupt endpoint).
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- drivers/hid/hid-ids.h: **+1** (USB_DEVICE_ID_AULA_MINI_60_HE_PRO 0xfefe under existing USB_VENDOR_ID_JESS 0x0c45)
- drivers/hid/hid-quirks.c: **+2** (one hid_quirks[] entry:
HID_QUIRK_ALWAYS_POLL)
- Total: **3 insertions**, 0 deletions, 2 files
- Functions: none modified; static ID table only
- Scope: **single-purpose surgical quirk addition**
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** dongle 0c45:fefe is a generic USB HID device. usbhid starts interrupt polling on open and may stop it on close / when not ALWAYS_POLL. After ~1 minute idle the firmware/hardware stops responding; unplug/replug required.
- **After:** hid_gets_squirk() / hid_lookup_quirk() matches this VID/PID and sets HID_QUIRK_ALWAYS_POLL (BIT(10) = 0x400). usbhid_start() starts the IN URB at probe and keeps HID_IN_POLLING set across close (usbhid_open/usbhid_close/usbhid_stop in this tree).
- Path: HID probe / usbhid start-stop, **not** an error path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **(h) Hardware workaround** — HID quirk table + device ID. Same class as USB/HID quirks that are routinely taken into stable. Not UAF, leak, race, etc.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: one ID + one table entry using an existing, well- tested quirk bit.
- Author empirically confirmed ALWAYS_POLL alone is sufficient.
- Regression risk is **low and device-scoped**: only 0c45:fefe. Cost is extra interrupt polling (power) on that dongle only.
- No API, locking, or data-structure changes.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- USB_VENDOR_ID_JESS 0x0c45 / USB_DEVICE_ID_JESS_YUREX:
6bc235a2e24a5 (Tomoki Sekiyama, 2010). Present in this tree at drivers/hid/hid-ids.h:695-698.
- Insertion point in hid_quirks[] (after INNOMEDIA, before KYE): table from d5d3e202753cc0 (Benjamin Tissoires, 2017).
- HID_QUIRK_ALWAYS_POLL introduced in 0b750b3baa2d6 (“HID: usbhid:
add always-poll quirk”, Johan Hovold, 2014-09-08). git merge-base --is-ancestor 0b750b3baa2d6 HEAD **succeeds**. Defined here as BIT(10) in include/linux/hid.h:373.
- The AULA ID itself is **new**; the bug is hardware/firmware plus long- standing usbhid idle/poll behavior, not a recent regression.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. N/A. Bug is device firmware vs existing usbhid poll-on-open behavior, not a specific introducing commit.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: This 5.15 tree already carries the same class of backports, e.g.:
- f9ad98cff302c HID: quirks: add HID_QUIRK_ALWAYS_POLL for 8BitDo Pro 3
- 16c2ca35257ed HID: Apply quirk HID_QUIRK_ALWAYS_POLL to Edifier QR30
- 5c46ec760d3be HID: quirks: Add ADATA XPG alpha wireless mouse support
- 9f093e15faee6 HID: add ALWAYS_POLL quirk for Apple kb Standalone; not patch N/M.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: git log --author="Yuxiang Lin" on drivers/hid/ in this tree:
**empty**. One-off device owner report. Weight comes from HID maintainer Jiri Kosina applying it, not from the author being a maintainer.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs only HID_QUIRK_ALWAYS_POLL, hid_quirks[], USB_VENDOR_ID_JESS, and usbhid ALWAYS_POLL handling — all present since well before 5.15. **Standalone.**
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 2884e21b18613 matched lore by patch-id:
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only** (2026-07-23). No v2/v3.
- Thread: submit → Jiri Kosina “Applied, thanks.” (2026-08-03). No NAK, no requested changes, no stable discussion in-thread.
- lore.kernel.org HTTP fetch returned 403; discussion recovered via b4 dig -m mbox and LKML mirrors.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To [email protected]; Cc Benjamin Tissoires, linux-input, linux-kernel. HID maintainers were on the original mail. Applied by Jiri Kosina.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No bugzilla/syzbot. The report **is** the patch: author reproduced hang on 6.8/6.14/7.1.3 and verified the quirk via module parameter. Single reporter; concrete hardware + recovery path.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone 1/1. Nearby mainline ALWAYS_POLL quirks (Beitong, SIGMACHIP, SDINNOVATION) are separate devices, not prerequisites.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search returned 403. No evidence in the linux-input thread of a stable NAK. UNVERIFIED: whether someone already requested this on stable@ (does not change the technical case).
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: No function bodies edited. New consumers of hid_gets_squirk() → hid_lookup_quirk(). Runtime effect is in usbhid: usbhid_open, usbhid_close, usbhid_start, usbhid_stop.
**Step 5.2: TRACE CALLERS**
Record (this tree):
- hid_lookup_quirk(): drivers/hid/hid-core.c (device add / quirk refresh), drivers/hid/usbhid/hid-core.c:992 (usbhid probe).
- ALWAYS_POLL consumers: usbhid_open (skip start-on-open), usbhid_close (keep polling), usbhid_start (start IN URB at probe), usbhid_stop (clear polling).
- Context: USB HID probe and open/close — **device enumeration / input**, not IRQ-unsafe new locking.
**Step 5.3: TRACE CALLEES**
Record: Table match only. ALWAYS_POLL path already calls usb_autopm_get_interface, hid_start_in, usb_kill_urb in this tree.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Plug dongle → usbhid probe → hid_lookup_quirk → generic HID input. Userspace (evdev) uses the keyboard. **Reachable from plugging the device;** unprivileged user of that keyboard hits the hang after idle. Not a syscall fuzzer path; real HID hardware path.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Dozens of HID_QUIRK_ALWAYS_POLL entries already in this tree’s hid_quirks[] (HP/Pixart mice, Corsair, Logitech, Lenovo, 8BitDo, Edifier, ADATA XPG, …). Same fix, new VID/PID. No 0xfefe HID ID already present (grep of drivers/hid empty).
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** usbhid ALWAYS_POLL vs poll-on-open logic is in drivers/hid/usbhid/hid-core.c (e.g. 687, 750, 754, 1183, 1232). Vendor ID USB_VENDOR_ID_JESS 0x0c45 exists; product 0xfefe is **not** quirked. The hang is firmware + this poll behavior; it is not a 6.x-only bug. Author listed 6.8+ because those are what they ran; 5.15 has the same usbhid mechanism (ALWAYS_POLL since 2014).
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record:
- hid-ids.h: git apply --check **clean** (USB_DEVICE_ID_REDRAGON_ASURA context matches).
- hid-quirks.c: **context mismatch** — 5.15 has extra KYE entries immediately after INNOMEDIA (KYE_EASYPEN_M610X …) vs mainline’s KYE PIXART mouse first. git apply --check fails on hid- quirks.c:113; 3-way reports a conflict there. Fix is insert the two JESS lines after the INNOMEDIA entry (alphabetically correct). **Minor backport, not a rework.**
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No AULA / 0xfefe HID quirk. No alternate fix for this dongle.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **HID / usbhid** (drivers/hid/). Criticality: **IMPORTANT** (common input stack), impact **driver-specific / device-specific**. Not core mm/net, but keyboards are user-visible and this tree already backports HID quirks.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature. hid-quirks.c still gets device-ID/quirk backports on 5.15. This is not a new subsystem.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / device-specific** — owners of AULA Mini 60 HE Pro wireless dongle 0c45:fefe. No effect on other HID devices. CONFIG_USB_HID (standard desktop/laptop configs).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Plug dongle, leave idle ~1 minute. Common for a wireless keyboard. Unprivileged user of the keyboard is affected. Not a timing race; firmware/idle-poll issue. Author reproduced on three kernel versions.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Input device **permanently unresponsive** until physical replug; no oops. **HIGH** for those users (keyboard dead; no software recovery). Not panic/corruption/CVE.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** restores a wireless keyboard on 5.15 LTS without a module-param workaround.
- **Risk:** 3 lines, one VID/PID, existing quirk bit. Possible extra USB polling/power on that dongle only. Context-hunk tweak in hid- quirks.c.
- **Ratio:** high benefit for affected hardware, very low regression risk.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real, reproduced hang: dongle dies after idle; only unplug recovers.
- Standard **HID hardware quirk** (HID_QUIRK_ALWAYS_POLL), the stable- rules exception for quirks/device IDs.
- 3 lines; no new APIs; no refactor.
- Infrastructure present in 5.15 since 2014; same quirk class already backported here.
- Empirically verified (usbhid.quirks=…:0x400 matches BIT(10)).
- HID maintainer applied v1 with no objections.
- Scoped to 0c45:fefe; no HID collision on 0xfefe in this tree.
AGAINST:
- Author did not list 5.15 among tested versions (tested 6.8+). Mechanism is the same.
- hid-quirks.c needs a tiny context adjustment.
- Single reporter; not a crash/security bug.
- Relatively new keyboard on an old LTS — still the usual reason HID ID/quirk backports exist.
UNRESOLVED:
- stable@ archive search (HTTP 403). Does not change the technical verdict.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — 3-line table add; author tested; maintainer applied.
2. Fixes a real bug that affects users? **PASS** — keyboard dies until replug.
3. Important issue? **PASS** — device unusable after idle (quirk exception; not a panic, but production-relevant for that hardware).
4. Small and contained? **PASS** — 3 lines, two HID files.
5. No new features or APIs? **PASS** — existing quirk bit + ID.
6. Can apply to the local tree? **PASS** — hid-ids.h clean; hid- quirks.c one-hunk context fix.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Hardware quirk / device ID on an existing driver** (HID usbhid). Automatic YES class.
**Step 9.4: DECISION**
Backport. The bug exists on this tree’s usbhid, the quirk bit exists, and this is the same pattern already used for 8BitDo/Edifier/ADATA on 5.15.
### What it solves for 5.15 users
Without ALWAYS_POLL, usbhid may stop interrupt polling; this Sonix-based dongle then wedges until replugged. Adding the ID makes 5.15 keep polling from probe, matching the module-param workaround.
### Risk vs benefit
Benefit is a working keyboard for that VID/PID. Risk is extra polling on that device only. hid-quirks.c needs the JESS line inserted after the INNOMEDIA entry because KYE rows differ from mainline.
### Concerns
None that block a YES: no missing prerequisites; not a new driver; apply conflict is mechanical.
Verification:
- [Phase 1] Tags: author + Jiri Kosina SOB; no Fixes/stable/Reported-by.
- [Phase 1] Body: idle hang, replug recovery, tested 6.8/6.14/7.1.3, usbhid.quirks=0x0c45:0xfefe:0x400.
- [Phase 2] Diff: +1 hid-ids.h, +2 hid-quirks.c; ALWAYS_POLL table entry.
- [Phase 2] HID_QUIRK_ALWAYS_POLL is BIT(10) = 0x400 in include/linux/hid.h:373.
- [Phase 3] git describe HEAD → p-5.15-2-g9a29d9b0f9507; make kernelversion → 5.15.221.
- [Phase 3] ALWAYS_POLL intro 0b750b3baa2d6 (2014) is ancestor of HEAD.
- [Phase 3] USB_VENDOR_ID_JESS blame 6bc235a2e24a5 (2010); lines 695-698 in this tree.
- [Phase 3] No AULA/0xfefe in drivers/hid; author has no HID commits here.
- [Phase 3] Similar 5.15 backports: f9ad98cff302c, 16c2ca35257ed, 5c46ec760d3be.
- [Phase 3] Upstream SHA 2884e21b18613708f050ec75330b265dd07ecc03; not ancestor of HEAD (exit 1).
- [Phase 4] b4 dig -c 2884e21b18613: lore match; To jikos, Cc bentiss/linux-input.
- [Phase 4] b4 dig -a: v1 only. Mbox: Jiri “Applied, thanks.” No NAK.
- [Phase 4] lore.kernel.org WebFetch 403; used b4 mbox + LKML/openwall mirrors.
- [Phase 5] hid_lookup_quirk used from hid-core.c and usbhid/hid- core.c:992.
- [Phase 5] ALWAYS_POLL in usbhid open/close/start/stop in this tree.
- [Phase 6] git apply --check: hid-ids.h clean; hid-quirks.c fails at line 113 (KYE order). 3-way conflict on quirks only.
- [Phase 7] HID usbhid; quirk table still receiving 5.15 backports.
- [Phase 8] Failure: keyboard dead until replug; severity HIGH for that device; risk very low.
- UNVERIFIED: stable@ mailing-list archive (403). Not used as a NO reason.
**YES**
drivers/hid/hid-ids.h | 1 + drivers/hid/hid-quirks.c | 2 ++ 2 files changed, 3 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -748,6 +748,7 @@#define USB_DEVICE_ID_JESS_YUREX 0x1010#define USB_DEVICE_ID_ASUS_MD_5112 0x5112#define USB_DEVICE_ID_REDRAGON_ASURA 0x760b +#define USB_DEVICE_ID_AULA_MINI_60_HE_PRO 0xfefe#define USB_VENDOR_ID_JESS2 0x0f30#define USB_DEVICE_ID_JESS2_COLOR_RUMBLE_PAD 0x0111
drivers/hid/hid-quirks.c +2 -0
@@ -113,6 +113,8 @@ static const struct hid_device_id hid_quirks[] = { { HID_USB_DEVICE(USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_PIXART_OEM_USB_OPTICAL_MOUSE_1f4a), HID_QUIRK_ALWAYS_POLL }, { HID_USB_DEVICE(USB_VENDOR_ID_IDEACOM, USB_DEVICE_ID_IDEACOM_IDC6680), HID_QUIRK_MULTI_INPUT }, { HID_USB_DEVICE(USB_VENDOR_ID_INNOMEDIA, USB_DEVICE_ID_INNEX_GENESIS_ATARI), HID_QUIRK_MULTI_INPUT }, + { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_AULA_MINI_60_HE_PRO), + HID_QUIRK_ALWAYS_POLL }, { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_PIXART_USB_OPTICAL_MOUSE_ID2), HID_QUIRK_ALWAYS_POLL }, { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M406), HID_QUIRK_MULTI_INPUT }, { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M506), HID_QUIRK_MULTI_INPUT },
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ksmbd: report actual xattr value length in stream enumeration
In reply to Sasha LevinFrom: Gael Blivet <[email protected]>
[ Upstream commit 689f1eb3719d61700b58f984ac8602837f004f8c ]
get_file_stream_info() (FileStreamInformation QUERY_INFO) reported each enumerated stream's StreamSize/StreamAllocationSize as stream_name_len -- the byte length of the stream's *name*, not its data. This is the same bug class already fixed for EndOfFile/ AllocationSize on an open stream handle (ksmbd_stream_eof()), just missed at this second site: a client enumerating streams sees a size derived from the name string length instead of the stream's actual content length, inconsistent with what querying the same stream by handle reports.
Compute the real value length the same way ksmbd_stream_eof() does, via ksmbd_vfs_casexattr_len() on the already-known xattr key.
---
LLM Generated explanations, may be completely bogus:
The patch applies cleanly on this 6.12 tree. I’ll now walk through the nine-phase analysis and the YES/NO decision.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ksmbd] [report] report actual xattr value length in stream enumeration
Subsystem prefix is ksmbd. The verb is “report” (correctness: the server currently reports the wrong length). Intent:
FileStreamInformation must return the stream’s data size, not the xattr name length.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record (from the candidate text and from 689f1eb3719d / 628ee3ef79ba3):
- Assisted-by: Claude:claude-sonnet-5
- Signed-off-by: Gael Blivet <[email protected]>
- Signed-off-by: Namjae Jeon <[email protected]> (candidate / ksmbd tree)
- Acked-by: Namjae Jeon + Signed-off-by: Steve French on 628ee3ef79ba3
- No Fixes: tag (expected)
- No Cc: stable (expected)
- No Reported-by, Tested-by, Reviewed-by, Link:
Notable: ksmbd maintainer sign-off/ack. No syzbot. Ignore any pipeline “Upstream commit” / Sasha Levin SOB.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** get_file_stream_info() (SMB2 QUERY_INFO FileStreamInformation) stores stream_name_len in StreamSize and StreamAllocationSize. That is the xattr *name* byte length, not the stream payload length.
- **Symptom:** A client enumerating ADS sees sizes derived from the name string (user.DosStream.<name>:$DATA), inconsistent with MS-FSCC and with querying the same stream by handle (after the related ksmbd_stream_eof() fix).
- **Failure mode:** Wrong stream sizes to Windows FindFirstStream / copy / backup. Clients that trust StreamSize can truncate ADS data.
- **Version info:** None in the message. The buggy assignment dates to the original cifsd SMB3 code (2021).
- **Root cause:** Name length reused as content size; second site of the same class as ksmbd_stream_eof().
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. Explicit protocol-correctness fix: report xattr **value** length instead of **name** length.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: fs/smb/server/smb2pdu.c only
- Scope: ~16 insertions, 2 deletions; one function
- Function: get_file_stream_info()
- Classification: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record (verified against this tree at lines 5173–5175):
- **Before:** After converting the stream name to UTF-16, set StreamSize = StreamAllocationSize = stream_name_len (stream_name_len = xattr name minus user.DosStream. prefix, e.g. "Zone.Identifier:$DATA").
- **After:** Call ksmbd_vfs_casexattr_len(file_mnt_idmap(fp->filp), path->dentry, stream_name, strlen(stream_name)+1), treat negative as 0, store that as both sizes.
- **Path:** Normal QUERY_INFO FILE_STREAM_INFORMATION for each ADS xattr. Unnamed ::$DATA still uses stat.size (unchanged, correct).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Logic / correctness (wrong field used as size).** Not UAF/leak/race. MS-FSCC FILE_STREAM_INFORMATION.StreamSize is “size in bytes of the stream.” The code used the key name length. Fix queries the xattr value length via existing ksmbd_vfs_casexattr_len() → vfs_getxattr(..., NULL, 0).
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: same helper already used for stream xattr lookup (smb2_set_stream_name_xattr, EA delete).
- v2 changelog (lore): strlen(stream_name)+1 so the match is exact, not a prefix match (strncasecmp in ksmbd_vfs_casexattr_len).
- Minimal; no API/structure changes.
- Regression risk: low. Extra listxattr+size probe per ADS (perf only). Lookup failure reports size 0 instead of name length (safer). Does not call ksmbd_stream_eof() (that helper is not in this tree).
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- git blame -L 5174,5175 fs/smb/server/smb2pdu.c → e2f34481b24db (“cifsd: add server-side procedures for SMB3”, Namjae Jeon, 2021-03-16 / committed 2021-05-10).
- Bug has been in ksmbd since the driver landed. git merge-base --is- ancestor e2f34481b24db HEAD → yes.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Introducer is e2f34481b24db, present in this tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Companion on origin/master: a9417bb1889e (“report actual xattr value length for stream EndOfFile/AllocationSize”) adds ksmbd_stream_eof(). **Not** in this 6.12 tree (git merge-base --is- ancestor a9417bb1889e3 HEAD failed).
- This enumeration patch does **not** call ksmbd_stream_eof(); it inlines the same ksmbd_vfs_casexattr_len pattern.
- Recent local smb2pdu.c work is other QUERY_INFO buffer/overflow fixes; nothing already corrects StreamSize.
- Standalone vs series: mailed as patch 3 of a 3-patch v2 set (lock on stream_del_pending, mdssvc log spam, this). Those other two are independent. This hunk does not need them.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Gael Blivet has no ksmbd commits in this 6.12 tree. On mainline, a batch of stream/protocol fixes for 7.3-rc1. Maintainer Namjae applied this immediately.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record:
- Needs ksmbd_vfs_casexattr_len() and file_mnt_idmap() — both exist here (vfs.h:108, include/linux/fs.h:2745, used throughout smb2pdu.c).
- Does **not** require ksmbd_stream_eof().
- git apply --check of 689f1eb3719d succeeded: hunks at 5110 and 5173 (offset −842).
Can apply standalone: **yes**.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 689f1eb3719d →
https://patch.msgid.link/[email protected]
- Thread saved to mbox (b4 dig -m).
- v1→v2: declare slen/ssize at function top; pass name length including NUL (exact match). Applied version is v2.
- Maintainer Namjae Jeon (2026-07-10): “Applied it to #ksmbd-for-next- next. Thanks!”
- No NAK, no stable nomination in the thread.
- Landed in ksmbd 7.3-rc1 pull (“Correct alternate-data-stream and named-stream handling”).
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc Namjae Jeon, [email protected]. Maintainer applied it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record:
- No Reported-by on the commit.
- GitHub namjaejeon/ksmbd#522 (“Unable to list streams”, 2026-01-07) notes dir /r vs Samba and guesses name/length mixup at the same lines. That report is about streams **not listing**; this patch only fixes **size**. I do **not** treat #522 as proof this patch restores listing. Independently, the size bug is visible in the code.
- Older related ADS bugs (e.g. #507 truncated files on SetInfo/EOF on a stream) show Windows clients really use stream size/EOF; wrong sizes are user-visible.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Independent of the lock and mdssvc patches in the same mail. Companion a9417bb1889e (ksmbd_stream_eof) is the same bug class on **open-handle** QUERY_INFO/CREATE. Not in 6.12; get_file_standard_info() here still uses stat.size even for stream FDs. This enumeration site is still wrong on its own and still worth fixing.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable fetch returned 403. UNVERIFIED whether stable@ already discussed this. Absence of Cc: stable is expected.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: get_file_stream_info(); new calls toksmbd_vfs_casexattr_len().
**Step 5.2: TRACE CALLERS**
Record:
- Only caller: smb2_get_info_file() switch FILE_STREAM_INFORMATION (smb2pdu.c:5476-5478).
- That is the SMB2 QUERY_INFO handler for FileStreamInformation (Windows FindFirstStreamW / copy / backup).
- Context: kernel SMB server, network/syscall-equivalent from SMB clients, not IRQ.
**Step 5.3: TRACE CALLEES**
Record: ksmbd_vfs_casexattr_len() (vfs.c:1775) lists xattrs, strncasecmp match, ksmbd_vfs_xattr_len() → vfs_getxattr(..., NULL, 0) for value length. Side effect: extra xattr probes; no lock/API change.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: SMB client → QUERY_INFO FileStreamInformation → get_file_stream_info. Reachable whenever ksmbd serves a share with ADS in user xattrs (user.DosStream.*). Unprivileged SMB users who can QUERY_INFO can trigger it.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same name-vs-value confusion: fp->stream.size is xattr **name** length (smb2_set_stream_name_xattr sets fp->stream.size = xattr_stream_size). Mainline ksmbd_stream_eof() fixes handle QUERY_INFO; this patch fixes enumeration. Default ::$DATA already uses stat.size.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record:
- git describe HEAD → p-6.12-3-gc504cf0baa3d8
- make kernelversion → **6.12.111**
- Branch: pending-6.12
- Buggy code is present:
```5173:5175:fs/smb/server/smb2pdu.c
file_info->StreamNameLength = cpu_to_le32(streamlen);
file_info->StreamSize = cpu_to_le64(stream_name_len);
file_info->StreamAllocationSize =
cpu_to_le64(stream_name_len);
```- Introduced in e2f34481b24db (v5.15-era cifsd), long before 6.12.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: git apply --check clean with line offset only. Surrounding get_file_stream_info body matches. Expected difficulty: **clean apply**.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No ksmbd_stream_eof, no “xattr value length” commits on fs/smb/server/ in this tree. Enumeration still uses stream_name_len.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: fs/smb/server (ksmbd). **IMPORTANT** for ksmbd deployments (NAS, embedded SMB), not core mm/VFS. CONFIG_SMB_SERVER default n.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively backported in this pending-6.12 tree (QUERY_INFO overflow, UAF, ACL, leases). Mature ADS path since 2021.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / config-specific:** ksmbd users, Windows/macOS clients using ADS (Zone.Identifier, Office streams, dir /r, copy/backup).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: QUERY_INFO FileStreamInformation on a file with user.DosStream.* xattrs. Common on Windows-facing shares. Unprivileged SMB users can trigger it. Not a race.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- Failure: wrong StreamSize/StreamAllocationSize (name length, typically tens of bytes, not payload size).
- Clients that size ADS copies from enumeration can **truncate stream data**.
- Not a kernel oops/deadlock.
- Severity: **HIGH** for ADS data integrity / protocol correctness; not CRITICAL kernel crash.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** Correct ADS sizes on a path Windows copy/backup uses; long-standing bug; small fix.
- **Risk:** Very low (~16 lines, existing helper, applies cleanly). Size 0 on xattr lookup failure is conservative.
- **Ratio:** Benefit outweighs risk for this 6.12 tree.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real, long-standing protocol bug in this tree (since cifsd 2021).
- Wrong ADS size can truncate stream copies (data integrity).
- Surgical, obviously correct; v2 matched ksmbd_vfs_casexattr_len NUL- length convention.
- Maintainer applied it with no objections.
- Helpers exist; git apply --check succeeds.
- Does not need ksmbd_stream_eof().
**AGAINST:**
- Not a crash/UAF/CVE.
- CONFIG_SMB_SERVER is optional.
- Companion handle-size fix (a9417bb1889e) is not in 6.12, so handle QUERY_INFO still reports stat.size for streams; enumeration vs handle remain inconsistent, but enumeration is independently wrong today.
- GitHub #522 listing failure is not verified as fixed by this change.
**UNRESOLVED:**
- lore.kernel.org HTTP 403; discussion recovered via b4 mbox.
- stable@ archives not fetched (403).
- Not verified that Windows copy always uses StreamSize rather than re-querying the handle.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — maintainer applied v2; logic matches existing xattr-length helper.
2. Fixes a real bug that affects users? **PASS** — FileStreamInformation returns name length as stream size; Windows ADS clients hit this path.
3. Important issue? **PASS** — ADS size lie can truncate stream data; protocol spec violation on a production SMB server. Not a panic, but data-integrity for named streams.
4. Small and contained? **PASS** — one function, ~16 lines.
5. No new features or APIs? **PASS** — only fills existing SMB2 fields correctly.
6. Can apply to the local tree? **PASS** — buggy code present; apply- check clean.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not a device ID, quirk, DT, build, or docs patch). Qualifies as a normal contained bugfix.
**Step 9.4: MAKE YOUR DECISION**
This 6.12 tree still reports ADS StreamSize as the xattr name length. The fix is the same ksmbd_vfs_casexattr_len() lookup already used in this tree, applies cleanly, and does not depend on later ksmbd_stream_eof(). That is appropriate for stable: real user-visible metadata/data-integrity bug, tiny scope, low regression risk.
------------------------------------------------
What the commit solves and why it matters here
------------------------------------------------
On 6.12.111, get_file_stream_info() still does cpu_to_le64(stream_name_len) for StreamSize/StreamAllocationSize. A stream named Zone.Identifier is reported as roughly the length of "Zone.Identifier:$DATA", not the xattr payload. SMB clients that enumerate streams and copy using that size can drop ADS content. ksmbd is used as a kernel SMB3 server; that is a real interoperability and data-integrity bug, not a cleanup.
------------------------------------------------
Stable rules / risk vs benefit
------------------------------------------------
Meets the rules: small, obviously correct, no new API, applies here. Benefit is correct ADS sizes on QUERY_INFO; risk is an extra xattr size probe per stream. Incomplete without the later handle ksmbd_stream_eof() fix, but this site is independently buggy and independently fixable.
------------------------------------------------
Verification
------------------------------------------------
- [Phase 1] Tags: no Fixes/Cc:stable/Reported-by; SOB Gael Blivet + Namjae Jeon; Assisted-by Claude.
- [Phase 2] Diff: 16+/2- in get_file_stream_info(); replace stream_name_len with ksmbd_vfs_casexattr_len() value length.
- [Phase 3] blame 5174-5175 → e2f34481b24db (2021); ancestor of HEAD.
- [Phase 3] Companion a9417bb1889e (ksmbd_stream_eof) **not** in HEAD; this patch does not call it.
- [Phase 3] git apply --check of 689f1eb3719d: both hunks apply (offset −842).
- [Phase 4] b4 dig -c 689f1eb3719d: lore msgid [email protected]; v2 applied by Namjae (“Applied it to #ksmbd-for-next-next”).
- [Phase 4] b4 dig -w: Namjae + linux-cifs; no NAK.
- [Phase 4] UNVERIFIED: stable@ discussion (HTTP 403).
- [Phase 5] Only caller smb2_get_info_file / FILE_STREAM_INFORMATION; helper exists in vfs.c:1775.
- [Phase 6] Tree is 6.12.111 (pending-6.12); buggy assignment present at 5174-5175.
- [Phase 6] file_mnt_idmap and ksmbd_vfs_casexattr_len present.
- [Phase 8] Failure mode: wrong ADS size → possible truncated stream copy; severity HIGH for ADS integrity, not kernel crash.
- UNVERIFIED: whether GitHub #522 (streams not listed) is the same bug; not used to drive YES.
**YES**
fs/smb/server/smb2pdu.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
fs/smb/server/smb2pdu.c +16 -2
@@ -5166,6 +5166,8 @@ static int get_file_stream_info(struct ksmbd_work *work,struct kstat stat;const struct path *path = &fp->filp->f_path;ssize_t xattr_list_len; +ssize_t slen; +loff_t ssize;int nbytes =0 , streamlen, stream_name_len, next, idx =0 ;int buf_free_len;int ret;
@@ -5227,8 +5229,20 @@ static int get_file_stream_info(struct ksmbd_work *work, streamlen *=2 ;kfree (stream_buf); file_info->StreamNameLength =cpu_to_le32 (streamlen); - file_info->StreamSize =cpu_to_le64 (stream_name_len); - file_info->StreamAllocationSize =cpu_to_le64 (stream_name_len); +/* +* stream_name_len is the byte length of the xattr's *name*, +* not its value -- same class of bug ksmbd_stream_eof() +* (smb2pdu.c) already fixes for EndOfFile/AllocationSize on +* a stream handle; this enumeration path needs the same +* real xattr value length, not the name length reused as a +* size. +*/ + slen =ksmbd_vfs_casexattr_len (file_mnt_idmap (fp->filp), + path->dentry, stream_name, +strlen (stream_name) +1 ); + ssize = slen <0 ?0 : (loff_t )slen; + file_info->StreamSize =cpu_to_le64 (ssize); + file_info->StreamAllocationSize =cpu_to_le64 (ssize); nbytes += next; buf_free_len -= next;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 fbdev: udlfb: validate vendor descriptor items
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit 3cc2fad376ac7360b4518277aa923752624db59c ]
dlfb_parse_vendor_descriptor() walks key-length-value items inside the DisplayLink vendor descriptor.
Require each item to contain its key, length and declared value bytes before reading item-specific fields such as max_area.
---
LLM Generated explanations, may be completely bogus:
This is a USB descriptor bounds-check for udlfb. The buggy parser is in this 6.12.111 tree, the patch applies cleanly, and the failure mode is an out-of-bounds read from device-controlled data.
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[fbdev/udlfb] [validate] [require each vendor-descriptor TLV item to contain key, length, and declared value bytes before reading fields such as max_area]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Pengpeng Hou \<[email protected]\> (author)
- Signed-off-by: Helge Deller \<[email protected]\> (fbdev maintainer; applied)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, Link:, or Cc: stable tags (absence is expected for this review)
- Ignore any pipeline “Upstream commit …” / Sasha Levin SOB markers; they are not evidence of selection
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: dlfb_parse_vendor_descriptor() walks DisplayLink vendor- descriptor key-length-value items without checking that key, length, and value bytes are still inside the descriptor.
- Symptom/failure mode: out-of-bounds read of max_area (and of the next key/length) when the remaining buffer is shorter than the declared item.
- Version information: none in the message. The parser has been in this file for many years (see Phase 3).
- Root cause: missing remaining-length checks before reading item fields.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. “Validate” is an explicit bounds-check fix for a USB descriptor parser. It is not cleanup, a new feature, or refactor- only.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/video/fbdev/udlfb.c — **+16 / −6** (22-line change)
- Function: dlfb_parse_vendor_descriptor()
- Scope: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Current code in this tree (drivers/video/fbdev/udlfb.c around the parse loop):
```1588:1612:drivers/video/fbdev/udlfb.c
while (desc < desc_end) {
u8 length;
u16 key;
key = *desc++;
key |= (u16)*desc++ << 8;
length = *desc++;
switch (key) {
case 0x0200: { /* max_area */
u32 max_area = *desc++;
max_area |= (u32)*desc++ << 8;
max_area |= (u32)*desc++ << 16;
max_area |= (u32)*desc++ << 24;
...
}
...
desc += length;
}
```Record, per hunk:
- Before: if desc is within desc_end, it always consumes 3 bytes (key+length) and, for key 0x0200, 4 more value bytes, with no remaining-length test. Then it still does desc += length.
- After: require at least 3 bytes left; parse key with get_unaligned_le16(); reject if length exceeds remaining bytes; for max_area, require length >= 4 and read via get_unaligned_le32(value) without advancing past the value twice; then desc += length.
- Path: USB probe / firmware descriptor parse (initialization), not a hot path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- Category: **memory safety / out-of-bounds read** of USB descriptor data (also a logic correction of the 2018 max_area pointer walk).
- Mechanism: a truncated or hostile descriptor can make desc_end - desc smaller than 3 (key+length) or smaller than length / sizeof(u32). The old loop still reads key, length, and max_area. The fix stops at unrecognized instead of reading past the buffer. unrecognized already exists and still returns true (driver still loads with the default SKU limit).
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Quality: obviously correct TLV remaining-length checks; get_unaligned_le16/le32 matches USB little-endian layout and the pre-2018 le16_to_cpu/le32_to_cpu reads. linux/unaligned.h is already included.
- Regression risk: low. Failures take the existing unrecognized path, which logs and still succeeds. The kernel is built with -funsigned- char, so switching from byte-or-shifts to get_unaligned_le* is not a signed-char behavior change. Restoring “read value, then desc += length” matches the original 2010 parser and the DRM udl parser in this tree.
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Loop introduced in 18dffdf8913ab9 (“staging: udlfb: enhance EDID and mode handling support”, 2010-09-05). Original max_area read did **not** advance desc before desc += length.
- Current byte-by-byte form introduced by 115e77597efcc9 (“video:
udlfb: Fix unaligned access”, 2018-03-12), which is an ancestor of this HEAD. That commit replaced le16_to_cpu/le32_to_cpu with *desc++ and accidentally advanced desc through the 4-byte value **and** still did desc += length.
- Bug class is old (2010 missing bounds; 2018 worse walk). Present in 6.12.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable beyond that. The intended target is the long-standing parser, last reshaped by 115e77597efcc9, which **is** in this tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent udlfb commits in this tree are independent (add vm_ops…, avoid divide-by-zero…). This is a standalone v1 patch, not “X/Y”. No prerequisite refactor is required.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Pengpeng Hou has no other udlfb commits in this tree. Helge Deller (fbdev maintainer) applied it. Related DRM work: df6dc12e5e6dd (“drm/udl: Validate length in vendor-descriptor parser”) on origin/master is the sibling hardening of the same protocol; it is **not** an ancestor of this HEAD.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Uses existing get_unaligned_le16/get_unaligned_le32 from include/linux/unaligned.h (already included as <linux/unaligned.h>). git apply --check of 3cc2fad376ac7 on this tree succeeded. Standalone.
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- Commit on origin/master: 3cc2fad376ac7360b4518277aa923752624db59c (not in this HEAD).
- b4 dig -c 3cc2fad376ac7:
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only** (no v2/v3). Applied version is that v1.
- Maintainer Helge Deller first asked whether LE reads were valid, then
retracted: “Your patch is of course correct! The patch is now added to fbdev git tree.”
- No NAK. No reviewer request for Cc: stable (not a negative).
- An automated Sashiko note flagged a **pre-existing** %11ph 11-byte dump when total_len can be 6; that is **not** introduced or fixed here.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): Pengpeng Hou; Bernie Thompson; Helge Deller; linux-fbdev; dri-devel; linux-kernel. Subsystem maintainer was on Cc and applied the patch.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla tag. Same bug class as DRM udl: Thomas Zimmermann’s drm/udl series (lore, April 2025) states the current parser “might read more bytes than available” / “out-of-bounds reads of the allocated buffer.” That is independent confirmation of the protocol bug, not a userspace crash report for udlfb.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone single patch. No later origin/master follow-up on udlfb.c after 3cc2fad376ac7. DRM equivalent is a larger 2025 refactor (udl_parse_key_value_pair); not a dependency of this fbdev patch.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: WebFetch of lore.kernel.org/stable returned 403. **UNVERIFIED** whether stable@ discussed this subject. No in-tree evidence of a prior rejection. The commit is simply not in this 6.12 checkout.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: dlfb_parse_vendor_descriptor() only.
**Step 5.2: TRACE CALLERS**
Record: Sole caller is dlfb_usb_probe() (drivers/video/fbdev/udlfb.c). Bound via .probe = dlfb_usb_probe for USB VID 0x17e9 + vendor-specific interface. Context: process-context USB probe, not IRQ.
**Step 5.3: TRACE CALLEES**
Record: usb_get_descriptor(), usb_get_extra_descriptor(), dev_info/dev_warn/dev_err, kfree. New: get_unaligned_le16, get_unaligned_le32. No new locks or allocations.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Plug in / enumerate a DisplayLink USB device (or a device spoofing VID 0x17e9) → dlfb_usb_probe → parser. Reachable without extra syscalls beyond USB enumeration. Unprivileged userspace cannot call it directly, but a physical USB device can.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: drivers/gpu/drm/udl/udl_main.c udl_parse_vendor_descriptor() in this tree still has the unbounded walk (desc += length with no remaining-length check). Same protocol bug. That does not block this udlfb-only fix.
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. Tree is **6.12.111** (git describe HEAD → p-6.12-3-gc504cf0baa3d8; VERSION/PATCHLEVEL/SUBLEVEL 6.12.111). Parser at dlfb_parse_vendor_descriptor() lines 1588–1612. git merge- base --is-ancestor 3cc2fad376ac7 HEAD → **not in this tree**. Bug present since 2010 / 2018, well before 6.12.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** git show 3cc2fad376ac7 -- drivers/video/fbdev/udlfb.c | git apply --check exit 0. Surrounding function matches the patch context. <linux/unaligned.h> already present.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: git log --grep='validate vendor descriptor' -- drivers/video/fbdev/udlfb.c empty. DRM Validate length in vendor- descriptor parser is not in this HEAD. No alternate udlfb bounds fix present.
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **fbdev USB framebuffer driver** (CONFIG_FB_UDL, drivers/video/fbdev/udlfb.c). Criticality: **PERIPHERAL / driver- specific**, but USB descriptor parsing is a standard untrusted-input path. DisplayLink USB 2.0 adapters are real hardware; the Kconfig help still describes this as the fbdev driver for those devices.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature. Parser largely unchanged since 2018 aside from later mmap/div-by-zero fixes. Low churn favors a small bounds-check backport.
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Users with CONFIG_FB_UDL and a DisplayLink USB 2.0 device (or a spoofed 0x17e9 device). Not universal.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Honest device with a well-formed descriptor: loop stays in-bounds (typical path).
- Truncated/malformed descriptor: OOB read of key/length/max_area.
- Malicious USB device matching the VID/class: can set bLength up to MAX_VENDOR_DESCRIPTOR_SIZE (256) so desc_end sits at the kzalloc edge, then emit a TLV length that walks off the buffer.
- Extra-descriptor fallback: __usb_get_extra_descriptor() bounds bLength to the extra blob, but item length can still push reads past that descriptor.
- Trigger is probe-time, not a timing race. Unprivileged software cannot hit it without USB device control.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **OOB read** of kernel memory during USB probe. Can KASAN-splat or oops if the read crosses an allocation/page boundary (total_len == 256 is the sharp heap case). Severity: **HIGH** (crash / infoleak from untrusted USB descriptor). Not a confirmed write, panic-on-boot for good hardware, or filesystem corruption.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: stops USB-descriptor OOB in a driver that is in this LTS tree; fail-open unrecognized path already exists.
- Risk: very low (16 insertions, existing helpers, existing error label, clean apply).
- Ratio: **favorable**.
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real OOB read of device-controlled USB descriptor data
- Same class already called out for DRM udl (“out-of-bounds reads of the allocated buffer”)
- Small, surgical, obviously correct remaining-length checks
- Code and bug exist in this 6.12.111 tree; fix is not in it
- Applies cleanly; get_unaligned_* already available
- Maintainer applied v1 after confirming LE reads are correct
- unrecognized still allows probe (low chance of breaking real adapters)
- No new API/feature
AGAINST:
- Driver-specific (DisplayLink fbdev), not core MM/VFS
- No syzbot/CVE/user oops in the commit message
- Honest devices with valid descriptors do not hit the bug
- Pre-existing %11ph dump issue is unfixed (not a reason to reject this)
UNRESOLVED:
- lore.kernel.org/stable search HTTP 403
- Exact TLV length byte on every DisplayLink SKU was not captured from a live device in this session; parser semantics match 2010 + current DRM udl, which is enough
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — bounds checks are local and reviewable; maintainer applied after LE confirmation.
2. Fixes a real bug that affects users? **PASS** — OOB read of USB descriptor memory; probe path for this driver.
3. Important issue? **PASS** — HIGH: crash/infoleak from untrusted USB descriptor (not a style cleanup).
4. Small and contained? **PASS** — one function, +16/−6.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — git apply --check clean on 6.12.111
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. It qualifies as a normal small security/robustness fix.
**Step 9.4: DECISION**
Backport to **this** tree. The buggy parser is here; the fix is small and applies; the impact is a USB OOB read.
Verification:
- [Phase 1] Parsed tags: author + Helge Deller SOB only; no Fixes/syzbot/Cc stable
- [Phase 2] Diff: +16/−6 in dlfb_parse_vendor_descriptor(); remaining- length checks + get_unaligned_le16/le32
- [Phase 2] Confirmed current 6.12 code still does unbounded *desc++ key/length/max_area reads
- [Phase 3] Blame: loop from 18dffdf8913ab9 (2010); byte-walk from 115e77597efcc9 (2018), both ancestors of HEAD
- [Phase 3] git merge-base --is-ancestor 3cc2fad376ac7 HEAD → not present
- [Phase 3] git apply --check of 3cc2fad376ac7 → clean
- [Phase 4] b4 dig -c 3cc2fad376ac7 → lore msgid [email protected]; v1 only
- [Phase 4] Thread: Helge questioned LE, then “patch is of course correct” and applied; no NAK
- [Phase 4] Sibling DRM commit df6dc12e5e6dd documents the same OOB; not in this HEAD
- [Phase 5] Only caller: dlfb_usb_probe / VID 0x17e9
- [Phase 5] include/linux/unaligned.h provides get_unaligned_le16/le32; already included
- [Phase 6] git describe HEAD = p-6.12-3-gc504cf0baa3d8; make kernelversion = 6.12.111
- [Phase 8] Failure mode: USB descriptor OOB read at probe; severity HIGH
- [Phase 8] Makefile has -funsigned-char (no signed-char regression from byte reads)
- UNVERIFIED: stable@ lore discussion (HTTP 403)
**YES**
drivers/video/fbdev/udlfb.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/video/fbdev/udlfb.c +16 -6
@@ -1586,19 +1586,29 @@ static int dlfb_parse_vendor_descriptor(struct dlfb_data *dlfb, desc +=5 ;/* the fixed header we've already parsed */ while (desc < desc_end) { +char *value;u8 length;u16 key; - key = *desc++; - key |= (u16)*desc++ <<8 ; +if (desc_end - desc <sizeof (key) +sizeof (length)) + goto unrecognized; + + key =get_unaligned_le16 (desc); + desc +=sizeof (key); length = *desc++; +if (length > desc_end - desc) + goto unrecognized; + + value = desc;switch (key) {case 0x0200 : {/* max_area */ -u32 max_area = *desc++; - max_area |= (u32)*desc++ <<8 ; - max_area |= (u32)*desc++ <<16 ; - max_area |= (u32)*desc++ <<24 ; +u32 max_area; + +if (length <sizeof (max_area)) + goto unrecognized; + + max_area =get_unaligned_le32 (value);dev_warn (&intf->dev,"DL chip limited to %d pixel modes\n" , max_area);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 udf: avoid recursive s_alloc_mutex deadlock when freeing AED blocks
In reply to Sasha LevinFrom: Deepanshu Kartikey <[email protected]>
[ Upstream commit 31e5e0c8c8e2617eb9f7a20c1cf5df23f592ade2 ]
udf_table_prealloc_blocks() and udf_table_new_block() call udf_delete_aext() on the unallocated-space-table inode while holding sbi->s_alloc_mutex. When the deleted allocation descriptor empties an allocation-extent (AED) block, udf_delete_aext() returns that block to free space via udf_free_blocks(). For a table-managed partition that path is udf_free_blocks() -> udf_table_free_blocks() -> mutex_lock(&sbi->s_alloc_mutex), i.e. the task tries to acquire a mutex it already holds.
On a PREEMPT_RT kernel the rtmutex deadlock detector reports this as -EDEADLK:
rtmutex deadlock detected
WARNING: kernel/locking/rtmutex.c:1698 at rt_mutex_handle_deadlock udf_table_free_blocks fs/udf/balloc.c:376 [inline] udf_free_blocks+0xa8c/0x1900 fs/udf/balloc.c:678 udf_delete_aext+0x4f5/0xc00 fs/udf/inode.c:2381 udf_table_prealloc_blocks fs/udf/balloc.c:544 [inline] udf_prealloc_blocks+0xbd4/0x10e0 fs/udf/balloc.c:702
On a non-RT kernel the same path is a hard self-deadlock (or a lockdep recursive-locking splat). It is reachable from a crafted UDF image via the write/sendfile path.
The allocator already refuses to recurse on the add side: see the comment in udf_table_free_blocks() explaining why it must not call udf_add_aext() while holding s_alloc_mutex. Apply the same rule to the delete side. Let udf_delete_aext() report the AED block it would otherwise free through a new out-parameter, and have the two callers that hold s_alloc_mutex free it after dropping the lock. The block is already unlinked from the inode's descriptor chain by then, so nothing can reference it in the meantime. All other callers pass NULL and keep freeing the block inline, exactly as before.
The out-parameter is pre-initialised with the reserved partition number 0xFFFF, which can never name a real block, so the caller can tell whether a block was handed back.
---
LLM Generated explanations, may be completely bogus:
This is a real UDF self-deadlock on s_alloc_mutex, found by syzbot with a C repro, and the local 7.3 tree has the same allocator path. It is a contained locking fix, not a feature.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [udf] [avoid] recursive s_alloc_mutex deadlock when freeing AED blocks. Subsystem is UDF (fs/udf). Verb “avoid” is a deadlock/safety fix, not a feature.
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Reported-by: [email protected] (fuzzer, C repro)
- Closes: https://syzkaller.appspot.com/bug?extid=6a680377e13041c19d50
- Link: same syzkaller URL
- Link:
https://patch.msgid.link/[email protected]
- Signed-off-by: Deepanshu Kartikey (author)
- Signed-off-by: Jan Kara (UDF maintainer)
- No Fixes: tag (expected)
- No Cc: stable (expected)
- Ignore pipeline SOBs / “[Upstream commit …]” if present; none on the real commit 31e5e0c8c8e2
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: udf_table_prealloc_blocks() / udf_table_new_block() call udf_delete_aext() while holding sbi->s_alloc_mutex. Emptying an AED block makes udf_delete_aext() call udf_free_blocks() → udf_table_free_blocks() → mutex_lock(&sbi->s_alloc_mutex) on a mutex the same task already holds.
- Symptom: PREEMPT_RT reports rtmutex deadlock detected / -EDEADLK; non-RT is a hard self-deadlock or lockdep recursive-lock splat.
- Trigger: crafted UDF image, write/sendfile.
- Root cause: delete-side recursion into the table allocator under the same mutex. Add-side already refuses this (udf_table_free_blocks()
comment: must not call udf_add_aext() while holding the mutex).
- Version info in the message: none. Stack points at fs/udf/balloc.c / inode.c.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. It is an explicit deadlock fix. The extra udf_delete_aext() argument is the mechanism, not a new user- visible API.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record: 4 files, +29 / −7 (12+19+2+3). Functions:udf_table_prealloc_blocks, udf_table_new_block, udf_delete_aext, udf_update_extents, udf_discard_prealloc, plus the prototype in udfdecl.h. Scope: single-subsystem surgical change.
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- udf_delete_aext(): when epos.bh != oepos.bh (AED block emptied), previously always called udf_free_blocks() inline. Now: if freed != NULL, copy epos.block to *freed; else free inline as before.
- udf_table_prealloc_blocks / udf_table_new_block: pass &freed (sentinel partitionReferenceNum = 0xFFFF), unlock s_alloc_mutex, then udf_free_blocks() if a real block was handed back.
- udf_update_extents / udf_discard_prealloc: pass NULL (unchanged inline free).
- Affected path: table-managed unallocated-space allocator, only when deleting an extent empties an AED block.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record: [Deadlock / recursive locking]. struct mutex s_alloc_mutex is non-recursive. Holding it and calling udf_free_blocks() on a UDF_PART_FLAG_UNALLOC_TABLE partition re-enters udf_table_free_blocks() which takes the same mutex. Fix defers that free until after unlock. The block is already unlinked from the descriptor chain, so it is temporarily orphaned (not in free space, not in the chain) until the post-unlock free; it cannot be double-allocated in the window.
Step 2.4: ASSESS THE FIX QUALITY
Record: Obviously correct and aligned with the existing add-side rule. All four call sites in this tree were updated. Sentinel 0xFFFF is a reserved partition number, so “was a block returned?” is unambiguous. Regression risk is low: NULL callers keep old behavior; lock-holding callers only change when an AED block is actually handed back. Pre- existing ignored udf_delete_aext() return values are not introduced here. Internal prototype change only (udfdecl.h, not UAPI).
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record: Mutex around prealloc: 1e7933defd0fce (2006, sem2mutex). udf_delete_aext() calling udf_free_blocks() on emptied AED: present at least since cb00ea3528eb3 (2007 lindent; logic is older). udf_delete_aext() signature last changed in 6c1e4d06a3808 (2018, drop unused args). This is a long-standing bug, not new 7.3 code.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Bug is the combination of non-recursive s_alloc_mutex (2006) and delete-aext freeing AED blocks (ancient UDF). Both exist in this tree’s lineage.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: Recent fs/udf/ work is hardening and writeout fixes. No prerequisite series for this deadlock. Follow-ups after 31e5e0c8c8e2 on these files (b8228f59dc58a, d95094d4c0a62, writeout series) do not revert or redo this locking change. Standalone.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Only this UDF commit by Deepanshu Kartikey in this tree. Accepted by Jan Kara (UDF maintainer; many contemporaneous UDF commits).
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: No functional dependencies. Uses existing struct kernel_lb_addr, udf_free_blocks(), s_alloc_mutex. Applies standalone on this tree. Context around mmb_mark_buffer_dirty is adjacent old code, not part of the change.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record: b4 dig -c 31e5e0c8c8e2 →
https://patch.msgid.link/[email protected].b4 dig -a: single v1 (plus a syzbot forward of the same subject). No v2/v3. Thread: author patch, Sashiko bot, Jan Kara “Thanks! I've added the patch to my tree.” No NAK. Direct lore.kernel.org fetch returned 403; full thread recovered via b4 dig -m.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: To: Jan Kara, RT maintainers (bigeasy, clrkwllms, rostedt). Cc:
linux-kernel, linux-rt-devel, syzbot. Appropriate: UDF maintainer + RT list because the splat was rtmutex. Maintainer applied it.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: syzbot “WARNING in udf_free_blocks (3)”, prio:high, C repro, first crash 2026-06-18. Status upstream, fix commit 31e5e0c8c8e2.
Assessment: DenialOfService exploitable as DoS, FilesystemTrigger,
Unprivileged: no (mount typically privileged). Stack: sendfile64 → udf_file_write_iter → udf_write_begin → udf_get_block → inode_getblk → udf_prealloc_blocks → udf_table_prealloc_blocks → udf_delete_aext → udf_free_blocks → udf_table_free_blocks.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone one-patch series. Not 2/N.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: UNVERIFIED for lore.kernel.org/stable (HTTP 403). No in-tree discussion that this was rejected from stable. Sashiko comments were pre-existing udf_delete_aext() error-handling/bh-leak notes, not objections to the deadlock fix.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: udf_delete_aext, udf_table_prealloc_blocks, udf_table_new_block, udf_update_extents, udf_discard_prealloc.
Step 5.2: TRACE CALLERS
Record:
- udf_table_prealloc_blocks ← udf_prealloc_blocks (UNALLOC_TABLE) ← udf_prealloc_extents ← inode_getblk ← udf_map_block / __udf_get_block ← udf_get_block ← udf_write_begin / splice / sendfile.
- udf_table_new_block ← udf_new_block (UNALLOC_TABLE) — allocation for new file blocks.
- NULL callers: extent update and prealloc discard; they do not hold s_alloc_mutex for this free.
Step 5.3: TRACE CALLEES
Record: udf_next_aext / udf_write_aext (unlink descriptors), then either udf_free_blocks or out-parameter. udf_free_blocks dispatches to bitmap or table; deadlock is table-only (UDF_PART_FLAG_UNALLOC_TABLE).
Step 5.4: FOLLOW THE CALL CHAIN
Record: Userspace-reachable: write/sendfile on a writable UDF mount with a table-managed partition and an AED block that becomes empty. Confirmed by syzbot C repro. Not interrupt context.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same file already special-cases add-side recursion (udf_table_free_blocks must not call udf_add_aext() under the mutex). This is the matching delete-side hole. Bitmap allocator does not take this path.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Local tree is v7.3-rc4-27-gf0100363d8c37 (make kernelversion 7.3.0-rc4). UDF table allocator, s_alloc_mutex, and udf_delete_aext → udf_free_blocks all exist in this lineage. Pre-image of 31e5e0c8c8e2 shows the exact deadlock (udf_free_blocks under the mutex). Bug introduced ~2006–2007, long before 7.3.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: On this tree the change matches current fs/udf/ (commit is already an ancestor). No missing helpers. Would apply as a small prototype-plus-call-site edit.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No earlier different deadlock fix for this path. 31e5e0c8c8e2 is the fix (git merge-base --is-ancestor 31e5e0c8c8e2 HEAD → yes). That is the original mainline merge, not a reason to treat the bug as unfix-worthy.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [fs/udf] [IMPORTANT]. Not mm/core, but a shipped writable filesystem. Deadlock/DoS on mount+write is in-scope for stable. CONFIG_UDF_FS.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mature (code from 2.6 era) with ongoing hardening. Not staging.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Users of writable UDF with unallocated-space *tables* (not bitmaps), including crafted images. Optical/ISO/USB-style UDF. Config- specific (CONFIG_UDF_FS).
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Mount UDF, write/sendfile so prealloc/new_block deletes an extent that empties an AED. Not every write; needs table partition + that extent layout. Syzbot reproduced it. Unprivileged mount is typically false; still a hang/DoS after a privileged mount of untrusted media.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: [self-deadlock / RT WARNING+EDEADLK] [CRITICAL]. Non-RT: task stuck in mutex_lock. RT: detected recursive deadlock. Hung writer; can make the filesystem/unmount path unusable.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record: Benefit high (prevents hang on a real, reproduced path). Risk low (~30 lines, UDF-internal, NULL callers unchanged, lock dropped before re-entry). Ratio strongly favors applying it.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real recursive mutex deadlock; non-RT hang, RT splat
- syzbot, C repro, prio:high, DoS
- Reachable from sendfile/write
- Small, contained, internal-only signature change
- Same rule as existing add-side comment
- Maintainer Jan Kara applied it
- Bug is decades old; this tree has the UDF path
AGAINST:
- Trigger needs table-managed UDF and a specific AED layout (narrower than “every UDF write”)
- Usually needs privilege to mount
- Sashiko noted pre-existing ignored returns / bh leak (not this patch; not a reason to skip the deadlock fix)
UNRESOLVED:
- lore.kernel.org/stable search (403)
- Direct lore HTML fetch (403); thread obtained via b4 mbox instead
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — logic matches add-side; syzbot + maintainer apply
2. Fixes a real bug that affects users? PASS — deadlock on write/sendfile, C repro
3. Important issue? PASS — hang/deadlock, CRITICAL
4. Small and contained? PASS — +29/−7, four UDF files
5. No new features or APIs? PASS — internal udf_delete_aext out- parameter only
6. Can apply to the local tree? PASS — UDF code present; patch is the natural fix for this tree’s allocator
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: None needed (not a device ID / quirk / DT / docs). It is a normal deadlock bugfix.
Step 9.4: MAKE YOUR DECISION
This tree is 7.3-rc4 mainline with full UDF table allocation. The deadlock is real, old, and user-reachable. The fix is small and correct. It should be applied on this tree’s stable lineage.
Verification:
- [Phase 1] Tags: syzbot Reported-by/Closes/Link; Jan Kara SOB; no Fixes/Cc-stable
- [Phase 2] Diff: +29/−7; defer udf_free_blocks after mutex_unlock in two table allocators; NULL at other callers
- [Phase 2] Pre-fix 31e5e0c8c8e2^: udf_delete_aext always called udf_free_blocks when epos.bh != oepos.bh
- [Phase 2] s_alloc_mutex is struct mutex in fs/udf/udf_sb.h:154 (non-recursive)
- [Phase 2] udf_free_blocks table branch at balloc.c:685-687 takes udf_table_free_blocks which locks the same mutex at line 376
- [Phase 3] Blame: mutex 1e7933defd0fce (2006); free-on-delete present by cb00ea3528eb3 (2007)
- [Phase 3] git merge-base --is-ancestor 31e5e0c8c8e2 HEAD → yes; git describe --contains → v7.3-rc1~118^2~14
- [Phase 3] No follow-up that replaces this locking approach
- [Phase 4] b4 dig -c 31e5e0c8c8e2: v1 only; Jan Kara accepted; Sashiko flags were pre-existing
- [Phase 4] syzbot: WARNING in udf_free_blocks, C repro, prio:high, DoS
- [Phase 5] Call chain: sendfile → udf_write_begin → udf_get_block → inode_getblk → udf_prealloc_blocks (verified in inode.c / file.c)
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4; UDF table path present
- [Phase 8] Failure mode: self-deadlock / RT -EDEADLK, severity CRITICAL
- UNVERIFIED: lore.kernel.org/stable HTML (403); does not change the deadlock evidence
The patch prevents a hard hang on a syzbot-reproduced UDF write path, is small, and matches how this allocator already avoids add-side recursion.
**YES**
fs/udf/balloc.c | 12 ++++++++++-- fs/udf/inode.c | 19 ++++++++++++++++--- fs/udf/truncate.c | 2 +- fs/udf/udfdecl.h | 3 ++- 4 files changed, 29 insertions(+), 7 deletions(-)
fs/udf/balloc.c +10 -2
@@ -502,6 +502,8 @@ static int udf_table_prealloc_blocks(struct super_block *sb,int8_t etype =-1 ;struct udf_inode_info *iinfo;int ret =0 ; +/* AED block freed by udf_delete_aext(), released after unlock */ +struct kernel_lb_addr freed = { .partitionReferenceNum =0xFFFF };if (first_block >= sbi->s_partmaps[partition].s_partition_len)return 0 ;
@@ -541,7 +543,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb,udf_write_aext (table, &epos, &eloc, (etype <<30 ) | elen,1 ); }else -udf_delete_aext (table, epos); +udf_delete_aext (table, epos, &freed); }else { alloc_count =0 ; }
@@ -552,6 +554,8 @@ static int udf_table_prealloc_blocks(struct super_block *sb,if (alloc_count)udf_add_free_space (sb, partition, -alloc_count);mutex_unlock (&sbi->s_alloc_mutex); +if (freed.partitionReferenceNum !=0xFFFF ) +udf_free_blocks (sb, table, &freed,0 ,1 );return alloc_count; }
@@ -560,6 +564,8 @@ static udf_pblk_t udf_table_new_block(struct super_block *sb, uint32_t goal, int *err) { struct udf_sb_info *sbi = UDF_SB(sb); +/* AED block freed by udf_delete_aext(), released after unlock */ +struct kernel_lb_addr freed = { .partitionReferenceNum =0xFFFF };uint32_t spread =0xFFFFFFFF , nspread =0xFFFFFFFF ;udf_pblk_t newblock =0 ;uint32_t adsize;
@@ -643,12 +649,14 @@ static udf_pblk_t udf_table_new_block(struct super_block *sb,if (goal_elen)udf_write_aext (table, &goal_epos, &goal_eloc, goal_elen,1 );else -udf_delete_aext (table, goal_epos); +udf_delete_aext (table, goal_epos, &freed);brelse (goal_epos.bh);udf_add_free_space (sb, partition,-1 );mutex_unlock (&sbi->s_alloc_mutex); +if (freed.partitionReferenceNum !=0xFFFF ) +udf_free_blocks (sb, table, &freed,0 ,1 ); *err =0 ;return newblock; }
fs/udf/inode.c +16 -3
@@ -1217,7 +1217,7 @@ static int udf_update_extents(struct inode *inode, struct kernel_long_ad *laarr,if (startnum > endnum) {for (i =0 ; i < (startnum - endnum); i++) -udf_delete_aext (inode, *epos); +udf_delete_aext (inode, *epos,NULL ); }else if (startnum < endnum) {for (i =0 ; i < (endnum - startnum); i++) { err = udf_insert_aext(inode, *epos,
@@ -2348,7 +2348,8 @@ static int udf_insert_aext(struct inode *inode, struct extent_position epos,return ret; } -int8_t udf_delete_aext (struct inode *inode,struct extent_position epos) +int8_t udf_delete_aext (struct inode *inode,struct extent_position epos, +struct kernel_lb_addr *freed) {struct extent_position oepos;int adsize;
@@ -2398,7 +2399,19 @@ int8_t udf_delete_aext(struct inode *inode, struct extent_position epos) elen =0 ;if (epos.bh != oepos.bh) { -udf_free_blocks (inode->i_sb, inode, &epos.block,0 ,1 ); +/* +* The block that held the now-empty allocation extent must be +* returned to free space. When the caller already holds +* s_alloc_mutex (the space-table allocator in balloc.c), +* freeing it inline would recurse through udf_free_blocks() +* into udf_table_free_blocks() and deadlock re-acquiring +* s_alloc_mutex. In that case report the block to the caller, +* which frees it after dropping the lock. +*/ +if (freed) + *freed = epos.block; +else +udf_free_blocks (inode->i_sb, inode, &epos.block,0 ,1 );udf_write_aext (inode, &oepos, &eloc, elen,1 );udf_write_aext (inode, &oepos, &eloc, elen,1 );if (!oepos.bh) {
fs/udf/truncate.c +1 -1
@@ -159,7 +159,7 @@ void udf_discard_prealloc(struct inode *inode)if (etype == (EXT_NOT_RECORDED_ALLOCATED >>30 )) { lbcount -= elen; -udf_delete_aext (inode, prev_epos); +udf_delete_aext (inode, prev_epos,NULL );udf_free_blocks (inode->i_sb, inode, &eloc,0 ,DIV_ROUND_UP (elen, bsize)); }
fs/udf/udfdecl.h +2 -1
@@ -169,7 +169,8 @@ extern int udf_add_aext(struct inode *, struct extent_position *, struct kernel_lb_addr *, uint32_t, int);extern void udf_write_aext (struct inode *,struct extent_position *,struct kernel_lb_addr *,uint32_t ,int ); -extern int8_t udf_delete_aext (struct inode *,struct extent_position ); +extern int8_t udf_delete_aext (struct inode *,struct extent_position , +struct kernel_lb_addr *);extern int udf_next_aext (struct inode *inode,struct extent_position *epos,struct kernel_lb_addr *eloc,uint32_t *elen,int8_t *etype,int inc);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 soundwire: dmi-quirks: Disable ghost Realtek on Asus ROG Zephyrus Duo
In reply to Sasha LevinFrom: Charles Keepax <[email protected]>
[ Upstream commit 5b08a3afd2995e5312c4c47ffea9d21b651e8e13 ]
The Asus ROG Zephyrus Duo also has a Realtek device in the ACPI that doesn't exist in the physical hardware. This confuses the machine driver into attempting to create DAI links for the device. Add a quirk to remove this device.
---
LLM Generated explanations, may be completely bogus:
I have enough to decide: this is a DMI-gated hardware quirk, ghost_realtek already exists in 6.12, and GX651AR is not listed yet.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [soundwire: dmi-quirks] [Disable] [DMI quirk to hide a phantom Realtek SoundWire device on Asus ROG Zephyrus Duo board GX651AR]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Suggested-by: Bard Liao <[email protected]>
- Signed-off-by: Charles Keepax <[email protected]> (author; Cirrus codec maintainer)
- Link: https://patch.msgid.link/20260807121425.1952003-1-
[email protected]
- Signed-off-by: Vinod Koul <[email protected]> (SoundWire maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Cc:
stable (absence expected)
- Ignored: any pipeline “Upstream commit” / “Signed-off-by: Sasha Levin” markers
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: Asus ROG Zephyrus Duo ACPI lists a Realtek SoundWire device that is not on the board.
- Symptom: the ASoC machine driver still builds DAI links for that ACPI node.
- Failure mode: wrong/extra DAI links; on the sibling GX651AX report, sof_sdw probe fails with -12 (ENOMEM) after duplicate SDW3-Playback- SimpleJack links.
- Root cause: firmware exposes a ghost RT722 (0x000330025d072201) on SoundWire link 3.
- Version info: none in this commit. A later sibling patch (GX651AX) used Cc: stable # 7.2.x; that does not describe this GX651AR change.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. It is an explicit hardware quirk: add one DMI match that reuses ghost_realtek.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/soundwire/dmi-quirks.c (+7 lines, 0 removed)
- Data only: one dmi_system_id entry in adr_remap_quirk_table[]
- No function body changes
- Scope: single-file surgical quirk
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Before: ASUS GX651AR does not match the remap table, so ACPI _ADR 0x000330025d072201 is used as-is.
- After: that board matches ghost_realtek, which remaps that _ADR to 0.
- Path: SoundWire ACPI slave discovery (sdw_dmi_override_adr → find_slave()). If addr is 0, find_slave() returns false and the slave is not registered.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- Category: hardware workaround (DMI quirk table)
- Mechanism: same as the existing ghost_realtek entries. find_slave():
```109:113:drivers/soundwire/slave.c
if (bus->ops->override_adr)
addr = bus->ops->override_adr(bus, addr);
if (!addr)
return false;
```Skipping the slave means it is not in ctx->ids (drivers/soundwire/intel_init.c), so SOF machine matching does not treat a phantom RT722 as present.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: one DMI match, existing ghost_realtek table, same pattern as UX5406AA / 83QK / 83SF already in this file.
- Regression risk: very low; only ASUS board name GX651AR.
- No API, locking, or allocator changes.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Local tree: p-6.12-3-gc504cf0baa3d8, Makefile VERSION=6 PATCHLEVEL=12 SUBLEVEL=111.
- ghost_realtek[] and the first DMI users come from 30e7fb61a64ba (“soundwire: dmi-quirks: Disable ghost Realtek devices”, 2026-05-20).
- adr_remap_quirk_table dates to 2021 (f6594cdfec4cd).
- GX651AR is not in this checkout.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Recent dmi-quirks.c history is other DMI remaps (HP Omen, NUC, Avell) plus the ghost-Realtek table.
- Not a numbered series (patch X/Y). Standalone DMI row.
- Mainline context includes B9406CAA and UX8407AA; those IDs are not in 6.12. They are independent rows, not code prerequisites.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record:
- Charles Keepax maintains Cirrus codecs (CS42L43 lives on this class of machines).
- Same author added the original ghost-Realtek table in this tree (30e7fb61a64ba).
- Suggested-by Bard Liao, SoundWire co-maintainer.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Record:
- Needs ghost_realtek[] and sdw_dmi_override_adr() — both present (git merge-base --is-ancestor 30e7fb61a64ba HEAD → yes).
- Upstream SHA 5b08a3afd2995e5312c4c47ffea9d21b651e8e13 is not an ancestor of HEAD (expected; this is the candidate).
- Can stand alone once the DMI entry is inserted next to UX5406AA.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 5b08a3afd2995e5312c4c47ffea9d21b651e8e13 → https://patch.m
sgid.link/[email protected]
- b4 dig -a: v1 only, 2026-08-07.
- Vinod Koul applied it (`commit:
5b08a3afd2995e5312c4c47ffea9d21b651e8e13`). No NAK, no revision churn.
- lore.kernel.org search URLs returned 403; discussion recovered from b4, patchew, LKML, and openwall.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To Vinod Koul; Cc Bard Liao, Pierre-Louis Bossart, linux-sound, linux-kernel, Cirrus patches. Right SoundWire people. No extra Reviewed-by on the committed message; maintainer applied it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record:
- No bugzilla/syzbot link on this patch.
- Sibling GX651AX (Ian Luites, 2026-08-31): ghost RT722 stays unattached, CS42L43 + two CS35L56 attach, duplicate SDW3-Playback- SimpleJack, sof_sdw probe -12. That is the same ACPI ghost class, different SKU.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone. Later GX651AX is another DMI row, not a dependency.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable returned 403. Web search found no stable- list discussion of GX651AR. UNVERIFIED: whether anyone asked for this on stable@ for 6.12.y.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: No function edited. Data consumed by sdw_dmi_override_adr().
**Step 5.2: TRACE CALLERS**
Record:
- sdw_dmi_override_adr ← bus->ops->override_adr in find_slave() (drivers/soundwire/slave.c)
- Intel sets .override_adr = sdw_dmi_override_adr in drivers/soundwire/intel_auxdevice.c
- find_slave() runs during ACPI SoundWire slave enumeration (probe/boot)
**Step 5.3: TRACE CALLEES**
Record: dmi_first_match() then remap. Remap-to-0 is handled by if (!addr) return false.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record:
ACPI scan → Intel SDW link probe → sdw_slave_add / find_slave → override_adr → skipped slave not on bus->slaves → not copied into ctx->ids → hda_sdw_machine_select() / snd_soc_acpi_sdw_link_slaves_found() never sees the ghost RT722 → sof_sdw does not build DAI links for it.
Reachable on any GX651AR that boots this kernel with Intel SoundWire + SOF. Not a syscall fuzzer path; firmware/hardware path.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same ghost_realtek already used for ASUS UX5406AA, Lenovo 83QK, Lenovo 83SF in this file. This is another ID in that set.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. ghost_realtek remaps RT722 0x000330025d072201 to 0. PTL tables include ptl_rt722_l3 for that address. GX651AR is not listed, so this laptop still exposes the ghost device. Bug introduced with the ACPI firmware + the existing remap-to-0 design (table added 2026-05-20, already in this 6.12.y checkout).
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Not a clean apply: mainline hunk context has B9406CAA before GX651AR; 6.12 goes from the “PTL devices” comment to UX5406AA. Backport is insert the same 7-line entry next to UX5406AA. Difficulty: minor context, no semantic rework.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: The generic ghost-Realtek table is here. No GX651AR/GX651AX/B9406CAA/UX8407AA rows. No alternate fix for this board.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: [drivers/soundwire DMI quirks + Intel SOF/ASoC] [IMPORTANT — laptop audio on Intel SoundWire machines; not core mm/fs, but user- visible “no sound / probe fail”]
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature DMI table (since 2021) with ongoing per-board additions. This is the usual stable-friendly pattern, not a new subsystem.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver/platform-specific: ASUS board GX651AR (ROG Zephyrus Duo) with Intel SoundWire. Everyone else is unchanged.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Every boot/probe on that laptop. Not a race. Unprivileged users do not trigger it; firmware does. Common for owners of that model.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- Failure: extra/wrong DAI links; sibling SKU: sof_sdw probe -ENOMEM; on this 6.12 tree, ptl_rt722_l3 can match a laptop that only has a ghost RT722 on link 3 and then load the wrong topology.
- Severity: HIGH for those machines (audio probe failure / wrong machine). Not a UAF/panic.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: high for GX651AR (and zero elsewhere). Same class as USB/PCI/DMI quirks that stable already takes; this tree already has three ghost_realtek IDs.
- Risk: very low (7 DMI lines, exact board match).
- Ratio: strongly favors backport.
Note: 6.12 PTL match tables have no CS42L43/CS35L56 entries, so this laptop may still lack a perfect SOF machine even after the quirk. The quirk still stops a false ptl_rt722_l3 match and is the same enablement already used for UX5406AA. It does not make other hardware worse.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real hardware ACPI bug on a shipping Asus laptop
- Classic DMI quirk exception in stable-kernel-rules
- 7 lines, existing table, DMI-gated
- Infrastructure (ghost_realtek, override_adr → skip addr==0) is in this 6.12 tree
- SoundWire maintainer applied; suggested by SoundWire co-maintainer
- Sibling SKU documents sof_sdw probe failure from the same ghost RT722
AGAINST:
- Fuzzy apply (missing B9406CAA context) — trivial to re-context
- No Fixes:/Cc: stable on this patch (not a negative under these rules)
- PTL Cirrus machine tables are thinner in 6.12 than mainline — audio may still be incomplete, but the quirk is still the correct filter
UNRESOLVED:
- Could not read lore.kernel.org/stable (403)
- No on-list Tested-by for GX651AR itself (author + Intel suggestion)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? [PASS — identical to existing entries; maintainer applied]
2. Fixes a real bug that affects users? [PASS — ghost ACPI device breaks machine/DAI setup]
3. Important issue? [PASS — audio probe failure / wrong topology on that laptop; HIGH]
4. Small and contained? [PASS — +7 lines, one file]
5. No new features or APIs? [PASS — DMI ID on existing quirk]
6. Can apply to the local tree? [PASS — needs trivial context adjustment, not missing code]
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Hardware quirk / DMI match on an existing driver. Automatic YES class.
**Step 9.4: MAKE YOUR DECISION**
This should be backported to this 6.12.y tree. It is a small, DMI-gated quirk using code already present here, and it prevents a phantom Realtek RT722 from participating in SoundWire/SOF setup on Asus GX651AR.
Verification:
- [Phase 1] Parsed tags: Suggested-by Bard Liao; SOBs Keepax + Vinod Koul; Link msgid 20260807121425.1952003-1; no Fixes/Reported-by
- [Phase 2] Diff: +7 lines in adr_remap_quirk_table for ASUS / GX651AR → ghost_realtek
- [Phase 2] Confirmed find_slave() drops addr==0 after override_adr
- [Phase 3] git describe HEAD / Makefile: 6.12.111 (p-6.12-3-gc504cf0baa3d8)
- [Phase 3] git blame: ghost_realtek from 30e7fb61a64ba; GX651AR absent
- [Phase 3] git merge-base --is-ancestor 30e7fb61a64ba HEAD: present; 5b08a3afd2995 not ancestor
- [Phase 3] git log --oneline -20 -- drivers/soundwire/dmi-quirks.c:
prior DMI remaps only
- [Phase 4] b4 dig -c 5b08a3afd2995: lore msgid above; v1 only; Vinod applied
- [Phase 4] b4 dig -w: To vkoul; Cc Liao, Bossart, linux-sound
- [Phase 4] Sibling GX651AX: duplicate SimpleJack DAI links, sof_sdw -12
- [Phase 4] UNVERIFIED: stable@ thread (HTTP 403)
- [Phase 5] Callers: intel_auxdevice.c .override_adr → find_slave → intel_init.c ctx->ids → hda.c machine select
- [Phase 6] Local file has UX5406AA/83QK/83SF, not GX651AR; PTL rt722_3 ADR matches the quirk
- [Phase 6] Apply: context conflict on B9406CAA, trivial insert beside UX5406AA
- [Phase 8] Failure: wrong/extra DAI links / failed sof_sdw probe; DMI- limited; very low regression risk
**YES**
drivers/soundwire/dmi-quirks.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/soundwire/dmi-quirks.c +7 -0
@@ -193,6 +193,13 @@ static const struct dmi_system_id adr_remap_quirk_table[] = { }, .driver_data = (void *)ghost_realtek, }, + { + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"ASUS" ), + DMI_MATCH(DMI_BOARD_NAME, "GX651AR"), + }, + .driver_data = (void *)ghost_realtek, + }, { .matches = { DMI_MATCH(DMI_SYS_VENDOR, "ASUS"),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 HID: i2c-hid: Add a quirk for a Cirque I2C device.
In reply to Sasha LevinFrom: Vadim Klishko <[email protected]>
[ Upstream commit 1c942462c3969b287a86ab6dbb143324289d564e ]
Cirque touchpads with PID D0C1 generate an error when probed by the I2C HID driver, resulting in no hidraw device created. Adding I2C_HID_QUIRK_NO_IRQ_AFTER_RESET fixes the issue.
---
LLM Generated explanations, may be completely bogus:
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
- Subsystem: HID: i2c-hid
- Action verb: Add (a quirk)
- Claimed intent: add I2C_HID_QUIRK_NO_IRQ_AFTER_RESET for Cirque I2C touchpad PID D0C1
Record: [HID/i2c-hid] [add] [hardware quirk so Cirque D0C1 touchpads probe successfully]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Signed-off-by: Vadim Klishko <[email protected]> (author; Cirque, the device vendor)
- Signed-off-by: Benjamin Tissoires <[email protected]> (HID maintainer; applied the patch)
- No Fixes: tag (expected)
- No Cc: [email protected] (expected)
- No Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Link: tags in the committed message
- v1/v2/v3 changelog (from mailing list, not the commit body): v2 added subsystem prefix and expanded the explanation; v3 was a Patchwork resend. No code changes across revisions.
Record: Author is the hardware vendor; HID maintainer SOB. No syzbot/stable tags.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Cirque touchpads with product ID D0C1 error during I2C-HID probe, so no hidraw node is created. Applying the existing I2C_HID_QUIRK_NO_IRQ_AFTER_RESET workaround fixes it.
Record:
- Bug: Cirque D0C1 fails I2C-HID probe
- Symptom: no hidraw device (touchpad unusable)
- Root cause (author): device needs the established “no IRQ after reset” quirk
- Version info: none in the message; submitted Jul 2026, applied to hid for-7.3/upstream-fixes
**Step 1.4: DETECT HIDDEN BUG FIXES**
Not disguised. It is an explicit hardware quirk, which the stable rules treat as a real-world device fix.
Record: Not a hidden bug fix; it is a straightforward hardware quirk.
---
## PHASE 2: DIFF ANALYSIS - LINE BY LINE
**Step 2.1: INVENTORY THE CHANGES**
- drivers/hid/hid-ids.h: +1 (#define I2C_PRODUCT_ID_CIRQUE_D0C1 0xD0C1) next to existing I2C_VENDOR_ID_CIRQUE / I2C_PRODUCT_ID_CIRQUE_1063
- drivers/hid/i2c-hid/i2c-hid-core.c: +2 (quirk table entry)
- Functions modified: none. Data only: ID macro + i2c_hid_quirks[] entry
- Scope: single-file-class surgical (2 files, 3 lines). No new quirk flag; reuses I2C_HID_QUIRK_NO_IRQ_AFTER_RESET (BIT(0)), already used for Hantick 5288, ITE Voyo Winpad A15, and Raydium 3118 in this tree.
Record: [+3 lines, 2 files] [no functions] [surgical hardware quirk]
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Before: D0C1 (vendor 0x0488, product 0xD0C1) has quirks 0. i2c_hid_parse() → i2c_hid_finish_hwreset() waits up to 1000 ms for a reset-ACK IRQ.
After: lookup returns I2C_HID_QUIRK_NO_IRQ_AFTER_RESET. i2c_hid_finish_hwreset() sleeps 100 ms and clears I2C_HID_RESET_PENDING instead of waiting for the IRQ.
Path: device probe / HID parse (and resume only if RESET_ON_RESUME is also set; this entry does not set that).
Record: [probe reset-wait → 100 ms sleep, skip IRQ wait, for VID 0x0488 / PID 0xD0C1 only]
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Category: **(h) Hardware workaround** (device ID + quirk table).
Mechanism: some I2C-HID devices never send the reset-complete interrupt. The same quirk is already documented for Hantick (402946a8ef71eb: bind fails with "failed to reset device"), ITE (fc6a31b007393: "can't add hid device: -61"), and Raydium (0c8432236dea2). Hans de Goede later made a missing ACK a warning rather than -ENODATA (7bcf9ebb50f2a, in this tree), but a device that emits a bogus IRQ during the wait can still break the following report-descriptor read (i2c_hid_parse logs "reading report descriptor failed" and hid_add_device fails → no hidraw). The vendor says this quirk fixes that on D0C1.
Record: [hardware quirk] [skip reset-ACK IRQ wait for Cirque D0C1]
**Step 2.4: ASSESS THE FIX QUALITY**
Obviously correct: additive, ID-matched, uses a long-standing quirk. Risk is confined to 0x0488:0xD0C1. No API, locking, or allocator changes. Same 3-line shape as prior stable-worthy i2c-hid quirks.
Record: [high quality, minimal] [regression risk very low, ID-scoped]
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
- Cirque 1063 ID + NO_SLEEP_ON_SUSPEND: 26dd6a5667f500 (Kai-Heng Feng, 2024-01-23) — already in this tree
- I2C_HID_QUIRK_NO_IRQ_AFTER_RESET handling in i2c_hid_finish_hwreset(): present (lines 500–502)
- Quirk table terminator { 0, 0 } from original table (71af01a8c85ad8, 2016)
The “buggy” behavior is the generic reset-ACK wait vs this panel’s firmware, not a recent regression. D0C1 is a new product ID of an existing vendor.
Record: [generic reset-ACK wait vs D0C1 firmware] [quirk infra since ~2017; Cirque vendor ID since 2024 / v6.8]
**Step 3.2: FOLLOW THE FIXES: TAG**
No Fixes: tag. Not applicable.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Recent i2c-hid-core.c work in this tree is unrelated (report- descriptor error text, Dell S4, buffer overflow). Not part of a numbered series.
Record: [standalone] [no prerequisites beyond existing quirk flag + Cirque vendor define, both present]
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**git log --author="Vadim Klishko" / "Klishko" in this tree: no commits. First-time contributor; affiliation is the touchpad vendor ([email protected], Google corp-partner address on the list). HID maintainer Benjamin Tissoires applied it (for-7.3/upstream-fixes, SHA 1c942462c396).
Record: [vendor patch, maintainer-applied] [no other related commits in this tree]
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Mainline context after the new entry mentions QTEC/I2C_HID_QUIRK_RE_POWER_ON and BLTP; those IDs are **not** in 6.12. The added lines do not use them. Required pieces in this tree:
- I2C_VENDOR_ID_CIRQUE (yes)
- I2C_HID_QUIRK_NO_IRQ_AFTER_RESET and its i2c_hid_finish_hwreset() handling (yes)
- i2c_hid_lookup_quirk() (yes)
Record: [standalone on 6.12] [QTEC/BLTP are context-only, not dependencies]
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**b4 dig -c 1c942462c396 matched patch-idd0e1a0779d3e935e26ea6a8cb93b1b9f683a32a4.
Revisions:
- v1: https://patch.msgid.link/[email protected]
(subject lacked HID: i2c-hid:)
- v2: https://patch.msgid.link/[email protected]
(subject + explanation; **no code change**)
- v3: https://patch.msgid.link/[email protected]
(Patchwork resend; **no code change**)
- Applied: Benjamin Tissoires, 2026-08-25, hid.git for-7.3/upstream- fixes (1c942462c396)
No NAKs in v1/v2/v3 archives (openwall/patchew). No reviewer-requested code changes. No explicit Cc: stable on the list.
Record: [lore/msgid as above] [v1→v3, code unchanged] [applied by HID maintainer] [no NAKs]
**Step 4.2: CHECK WHO REVIEWED THE PATCH**b4 dig -w original recipients: [email protected], [email protected], [email protected], [email protected]. v3 also CCd Benjamin Tissoires and Hans de Goede (i2c-hid quirk author). Apply mail CCd [email protected]. No written Reviewed-by, but the maintainer applied it.
Record: [HID maintainers Kosina/Tissoires; de Goede CCd; applied by Tissoires]
**Step 4.3: SEARCH FOR THE BUG REPORT**
No bugzilla/syzbot link. Evidence is the vendor’s report: probe error, no hidraw, quirk fixes it. Author is Cirque.
Record: [vendor-reported probe failure] [severity: device does not enumerate] [user count unverified beyond vendor]
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES** Standalone 1/1. Not a multi-patch series.
Record: [standalone]
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Web search of lore.kernel.org/stable for Cirque D0C1 i2c-hid did not turn up discussion of this patch (results were unrelated historical stable traffic).
Record: [no stable-list discussion found]
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
No function bodies changed. The new table entry is consumed by i2c_hid_lookup_quirk(), which feeds ihid->quirks, consumed by i2c_hid_finish_hwreset().
Record: [i2c_hid_quirks[] data; consumers: i2c_hid_lookup_quirk, i2c_hid_finish_hwreset]
**Step 5.2: TRACE CALLERS**
- i2c_hid_lookup_quirk(): only from __i2c_hid_core_probe() after reading the HID descriptor vendor/product — so the quirk is installed before hid_add_device() / parse.
- i2c_hid_finish_hwreset(): from i2c_hid_parse() (probe) and i2c_hid_core_resume() (only if I2C_HID_QUIRK_RESET_ON_RESUME; this ID does not set that).
Record: [probe path via hid_add_device → i2c_hid_parse] [resume reset path not used for this ID]
**Step 5.3: TRACE CALLEES**
With the quirk, i2c_hid_finish_hwreset() calls msleep(100) and clear_bit(I2C_HID_RESET_PENDING). Then, unless NO_WAKEUP_AFTER_RESET, i2c_hid_set_power(PWR_ON).
Record: [msleep + clear reset-pending; then existing PWR_ON]
**Step 5.4: FOLLOW THE CALL CHAIN**
ACPI/OF I2C-HID probe → __i2c_hid_core_probe (descriptor + quirk lookup) → i2c_hid_core_register_hid → hid_add_device → i2c_hid_parse → hwreset → read report descriptor → hidraw/input.
Reachable on boot for machines with this touchpad; not a syscall fuzz path, but a normal laptop input device.
Record: `[boot/probe of Cirque D0C1 I2C touchpad] [userspace-visible:
hidraw/input missing without quirk]`
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Same quirk already in this tree for Hantick, ITE Voyo, Raydium 3118. This is the same pattern, new ID.
Record: [three existing NO_IRQ_AFTER_RESET entries; this is a fourth ID]
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Local tree: pending-6.12, make kernelversion = **6.12.111**, git describe HEAD = p-6.12-3-gc504cf0baa3d8.
- I2C_PRODUCT_ID_CIRQUE_D0C1 is **absent** (git grep no matches)
- git merge-base --is-ancestor 1c942462c396 HEAD → not an ancestor (exit 1)
- Driver, quirk flag, lookup, and Cirque vendor ID **are** present
- Without the table entry, D0C1 takes the generic reset-ACK wait that the vendor says fails probe
Record: [yes, buggy generic path exists; D0C1 quirk not yet applied] [bug is device firmware vs long-standing reset wait]
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**hid-ids.h context around CIRQUE_1063 matches; should apply cleanly. i2c-hid-core.c: insertion after the 1063 entry matches; following context in mainline is QTEC (not in 6.12; here it is the ELAN comment). At most fuzz/trivial context adjust. No refactor of the quirk table.
Record: [clean or trivial fuzz] [no rework of logic]
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
No D0C1 ID. Cirque 1063 has a *different* quirk (NO_SLEEP_ON_SUSPEND). 7bcf9ebb50f2a only demotes missing ACK to a warning; vendor still needed this ID-specific quirk.
Record: [no existing D0C1 fix; 1063 quirk is unrelated]
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY** drivers/hid/i2c-hid/ — laptop/Chromebook I2C HID touchpads. Not mm/core, but a common input path.
Record: [HID i2c-hid] [IMPORTANT / driver-specific]
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Mature driver (2012+). Quirk table still gets ID additions; that is normal, not a rewrite.
Record: [mature; ID/quirk additions are the usual change]
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Only I2C-HID devices with HID descriptor VID/PID 0488:D0C1. Everyone else unchanged.
Record: [driver/hardware-specific: Cirque D0C1 touchpads]
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Every probe of that touchpad (boot). Not a race. Unprivileged users cannot trigger it beyond having the hardware.
Record: [every boot on affected machines] [common for those users] [not a syscall exploit path]
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Probe fails → no hidraw/input → touchpad dead. Not a panic. Matches ITE’s historic "can't add hid device" failure.
Record: [device fails to enumerate] [severity: HIGH for affected hardware, none otherwise]
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Benefit: touchpad works on 6.12 LTS (ChromeOS/enterprise/Ubuntu-class kernels still on 6.12).
Risk: 3 lines, existing quirk, ID-gated.
Record: [benefit high for D0C1 users] [risk very low] [favorable]
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Explicit hardware quirk; stable rules call these YES
- Real user-visible bug: probe error, no hidraw (vendor-confirmed)
- 3 lines, existing I2C_HID_QUIRK_NO_IRQ_AFTER_RESET
- Same shape as Hantick/ITE/Raydium quirks already in this tree
- HID maintainer applied it; author is Cirque
- Driver, quirk flag, and Cirque vendor ID exist in 6.12.111
- No new API/feature flag
AGAINST:
- No Fixes: / Cc: stable (not a negative per instructions)
- No public repro logs beyond the commit text
- 7bcf9ebb50f2a tried to reduce new NO_IRQ_AFTER_RESET quirks; this device still needed one
- Mainline hunk context (QTEC) differs; trivial apply fuzz only
- Affects one product ID, not all machines
UNRESOLVED:
- Exact errno/log line on D0C1 was not posted (only “error” / no hidraw)
- How many shipping systems use D0C1 is unverified
- lore.kernel.org WebFetch returned 403; discussion recovered via b4 dig
+ openwall/patchew
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — 3-line ID quirk; vendor- tested; maintainer applied
2. Fixes a real bug that affects users? **PASS** — probe failure, no hidraw
3. Important issue? **PASS** — input device does not work (hardware bug, not a panic)
4. Small and contained? **PASS** — +3 lines, two files
5. No new features or APIs? **PASS** — existing quirk + new device ID
6. Can apply to the local tree? **PASS** — logic applies; at most context fuzz around QTEC vs ELAN
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Yes: **hardware quirk** and **device ID addition to an existing driver**.
**Step 9.4: DECISION**
This is a textbook stable backport: a 3-line i2c-hid quirk so a Cirque D0C1 touchpad enumerates. The 6.12 tree already has the driver and quirk machinery; only the ID is missing. Benefit is restoring input on affected machines; regression risk is limited to that PID.
---
## What this solves for 6.12 users
Cirque D0C1 I2C touchpads fail I2C-HID probe, so hidraw/input never appear. The quirk skips waiting for a reset-ACK IRQ (100 ms sleep instead), which is the established workaround. On 6.12 that path still exists; without the ID, those panels stay dead.
## Risk vs benefit
Benefit is a working touchpad on affected laptops/Chromebooks still on 6.12. Risk is a 3-line, VID/PID-gated table addition using a quirk already used by three other devices in this tree.
## Concerns
Apply may need trivial context adjustment because 6.12’s quirk table does not yet have the later QTEC/BLTP entries. No functional dependencies. Exact probe errno was not published; the vendor statement plus matching historical quirks is enough.
---
Verification:
- [Phase 1] Parsed subject/tags/body: vendor SOB Vadim Klishko; maintainer SOB Benjamin Tissoires; no Fixes/stable/syzbot tags
- [Phase 2] Diff: +1 hid-ids.h define I2C_PRODUCT_ID_CIRQUE_D0C1 0xD0C1; +2 i2c_hid_quirks[] with I2C_HID_QUIRK_NO_IRQ_AFTER_RESET
- [Phase 2] Read i2c_hid_finish_hwreset(): quirk does msleep(100) vs 1000 ms wait_event_timeout
- [Phase 2] Confirmed I2C_HID_QUIRK_NO_IRQ_AFTER_RESET is BIT(0) at line 47
- [Phase 3] git describe HEAD / make kernelversion: pending-6.12, 6.12.111
- [Phase 3] git merge-base --is-ancestor 1c942462c396 HEAD: not in tree (exit 1)
- [Phase 3] git grep I2C_PRODUCT_ID_CIRQUE_D0C1: no matches
- [Phase 3] git blame hid-ids Cirque lines: 26dd6a5667f500 (2024, in tree)
- [Phase 3] git blame quirk table: Hantick/ITE/Raydium already have the same quirk
- [Phase 3] git log --author=Klishko: no commits in this tree
- [Phase 3] QTEC/BLTP/I2C_HID_QUIRK_RE_POWER_ON: absent; not required by this patch
- [Phase 3] Compared prior quirks: 0c8432236dea2 (Raydium), fc6a31b007393 (ITE), 402946a8ef71eb (Hantick) — same 2-file +3-line pattern
- [Phase 3] 7bcf9ebb50f2a in tree: missing ACK is a warning, not -ENODATA; vendor still needed the quirk
- [Phase 4] b4 dig -c 1c942462c396: patch-id match; v1/v2/v3 msgids listed above
- [Phase 4] b4 dig -a: v2 listed as series; v3 applied with no code changes from v1
- [Phase 4] b4 dig -w: To/Cc Jiri Kosina, linux-input, linux-kernel
- [Phase 4] Openwall/patchew: Tissoires applied to hid.git for-7.3/upstream-fixes; no NAKs
- [Phase 4] lore.kernel.org WebFetch: 403; used b4 + openwall/patchew instead
- [Phase 4] Stable-list search: no discussion of this patch found
- [Phase 5] Callers: i2c_hid_lookup_quirk from __i2c_hid_core_probe; i2c_hid_finish_hwreset from i2c_hid_parse and resume-with- RESET_ON_RESUME
- [Phase 5] Parse path: reset then i2c_hid_read_register of report descriptor; failure → no hid_add_device/hidraw
- [Phase 6] Local files match needed APIs; D0C1 ID missing
- [Phase 8] Failure mode: probe/enumeration failure for one touchpad PID, not a panic
- UNVERIFIED: exact dmesg/errno on D0C1; number of shipping units; live lore.kernel.org HTML (403)
**YES**
drivers/hid/hid-ids.h | 1 + drivers/hid/i2c-hid/i2c-hid-core.c | 2 ++ 2 files changed, 3 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -333,6 +333,7 @@#define I2C_VENDOR_ID_CIRQUE 0x0488#define I2C_PRODUCT_ID_CIRQUE_1063 0x1063 +#define I2C_PRODUCT_ID_CIRQUE_D0C1 0xD0C1#define USB_VENDOR_ID_CJTOUCH 0x24b8#define USB_DEVICE_ID_CJTOUCH_MULTI_TOUCH_0020 0x0020
drivers/hid/i2c-hid/i2c-hid-core.c +2 -0
@@ -136,6 +136,8 @@ static const struct i2c_hid_quirks { I2C_HID_QUIRK_BAD_INPUT_SIZE }, {I2C_VENDOR_ID_CIRQUE ,I2C_PRODUCT_ID_CIRQUE_1063 , I2C_HID_QUIRK_NO_SLEEP_ON_SUSPEND }, + { I2C_VENDOR_ID_CIRQUE, I2C_PRODUCT_ID_CIRQUE_D0C1, + I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },/* * Without additional power on command, at least some QTEC devices send garbage */
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 vdpa_sim: hold iommu_lock across dma_unmap passthrough transition
In reply to Sasha LevinFrom: Xiong Weimin <[email protected]>
[ Upstream commit 7b411448c668bfab0d0e572cee5a592cea396ce7 ]
vdpasim_dma_map() updates the IOTLB and the passthrough (iommu_pt) state under iommu_lock. vdpasim_dma_unmap() clears iommu_pt and resets the IOTLB before taking iommu_lock, then deletes the mapping while holding the lock.
A concurrent dma_map(), dma_unmap(), or reset path that also touches the same address space can therefore observe or modify the IOTLB and iommu_pt state without consistent locking.
Perform the passthrough transition and range deletion under the same iommu_lock scope, matching dma_map().
Tested-on: openEuler VM (6.16.8, /usr/src/linux-6.16.8)
Message-ID: <[email protected]>
---
LLM Generated explanations, may be completely bogus:
I have enough to judge this for 6.12: the buggy unlocked dma_unmap path is present, the race with the simulator datapath is real, and the fix is a one-lock-move. Compiling the nine-phase analysis next.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[vdpa_sim] [hold] [take iommu_lock for the full dma_unmap passthrough-to-custom IOTLB transition]**
- Subsystem: vdpa_sim (vDPA device simulator)
- Verb: “hold” — locking/correctness, not a feature
- Intent: make vdpasim_dma_unmap() lock the same way vdpasim_dma_map() already does
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Tested-on:** openEuler VM (6.16.8, /usr/src/linux-6.16.8)
- **Tested-by:** Xiong Weimin <[email protected]> (author; not independent)
- **Signed-off-by:** Xiong Weimin <[email protected]> (author)
- **Signed-off-by:** Michael S. Tsirkin <[email protected]> (vhost/vdpa maintainer; applied the patch)
- **Message-ID:** <[email protected]>
Absent (expected for this review pipeline, not a negative):
- No Fixes:
- No Cc: [email protected]
- No Reported-by: / syzbot
- No Reviewed-by: / Acked-by:
- No Link:
Ignored per instructions: any [Upstream commit …] / `Signed-off-by:
Sasha Levin` pipeline markers.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** vdpasim_dma_map() updates IOTLB + iommu_pt under iommu_lock. vdpasim_dma_unmap() clears iommu_pt and calls vhost_iotlb_reset() *before* taking the lock, then deletes the range under the lock.
- **Symptom / failure mode:** concurrent dma_map / dma_unmap / reset can observe or mutate IOTLB and iommu_pt without consistent locking. That is interval-tree mutation vs walk → corruption / UAF / crash, not a log-only issue.
- **Version info:** tested on 6.16.8; no “introduced in vX” text. The buggy passthrough logic is from v6.3 (see Phase 3).
- **Root cause (author):** passthrough-exit in dma_unmap is outside the lock that dma_map already uses.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not disguised.** This is an explicit locking/race fix. Subject uses “hold … across”, body describes a concurrent IOTLB/iommu_pt inconsistency. Hidden-fix heuristics are N/A.
---
## PHASE 2: DIFF ANALYSIS - LINE BY LINE
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** drivers/vdpa/vdpa_sim/vdpa_sim.c only
- **Scope:** ~1 insertion, ~2 deletions (move spin_lock up, drop a blank line)
- **Function:** vdpasim_dma_unmap()
- **Classification:** single-file surgical locking fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record — this tree today (vdpasim_dma_unmap):
```725:743:drivers/vdpa/vdpa_sim/vdpa_sim.c
static int vdpasim_dma_unmap(struct vdpa_device *vdpa, unsigned int
asid,
u64 iova, u64 size)
{
struct vdpasim *vdpasim = vdpa_to_sim(vdpa);
if (asid >= vdpasim->dev_attr.nas)
return -EINVAL;
if (vdpasim->iommu_pt[asid]) {
vhost_iotlb_reset(&vdpasim->iommu[asid]);
vdpasim->iommu_pt[asid] = false;
}
spin_lock(&vdpasim->iommu_lock);
vhost_iotlb_del_range(&vdpasim->iommu[asid], iova, iova + size -
1);
spin_unlock(&vdpasim->iommu_lock);
return 0;
}
```- **Before:** if still in passthrough (iommu_pt[asid]), reset the whole IOTLB interval tree and clear iommu_pt with **no lock**; then take iommu_lock only for vhost_iotlb_del_range().
- **After:** one spin_lock covers passthrough-exit (vhost_iotlb_reset + iommu_pt = false) **and** vhost_iotlb_del_range(), then unlock. Same shape as vdpasim_dma_map().
- **Path:** vhost-vdpa IOTLB invalidate / AS teardown (ops->dma_unmap), not probe init.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Synchronization / race] [IOTLB interval tree and iommu_pt mutated without iommu_lock]**
vhost_iotlb_reset() is vhost_iotlb_del_range(iotlb, 0, ~0ULL) — it walks and frees the rbtree (drivers/vhost/iotlb.c). The datapath walks that tree under iommu_lock via iotlb_translate() in drivers/vhost/vringh.c (spin_lock(vrh->iotlb_lock) then vhost_iotlb_itree_first()).
Unlocked reset vs locked walk is concurrent rbtree mutation → UAF / corruption / oops.
Same lock is used by vdpasim_dma_map(), vdpasim_set_map(), vdpasim_reset_map(), and vdpasim_do_reset().
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Quality:** obviously correct. It only moves an existing spin_lock so the passthrough block matches dma_map. No new APIs, no new state.
- **Regression risk:** very low. Same lock already used on the sibling path; no lock-order change vs vdpasim->mutex (unmap still does not take that mutex). No new sleep under spinlock (vhost_iotlb_reset/del_range are tree ops).
- **Red flags:** none. Independent of series patch 1/2 (pending_kick); cover letter calls them independent.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Unlocked iommu_pt / vhost_iotlb_reset in dma_unmap:
**6c3d329e6486dd** — vdpa_sim: get rid of DMA ops (Jason Wang, committed 2023-02-20).
- First in **v6.3-rc1** (git describe --contains → v6.3-rc1~84^2~23).
- spin_lock around del_range: **0ea9ee430e74b1** (Max Gurtovoy, 2020).
- Present in this 6.12 tree for the whole lifetime of 6.12.y.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** The introducing change is still **6c3d329e6486dd**, and git merge-base --is-ancestor 6c3d329e6486dd HEAD succeeded. No later fix of this lock split was found on this file.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record (recent drivers/vdpa/vdpa_sim/vdpa_sim.c):
- 05ddc94afb69e vdpa_sim: fix cleanup after worker creation failure
- 9588e7fc511f9 vdpa_sim: reset must not run
- 86f6c224c9791 vdpa_sim: implement .reset_map support
- 6c3d329e6486d vdpa_sim: get rid of DMA ops (introducer)
This commit is **standalone**. Cover letter: “[PATCH 0/2] vdpa_sim: fix suspend/reset and dma_unmap locking” — two independent bugs. Sibling clear pending_kick on device reset is **not** a prerequisite and is **not** in this tree.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: **Xiong Weimin** has no other vdpa_sim commits in this tree. Maintainer of record is **Michael S. Tsirkin** (SOB on apply) / historical authors Jason Wang, Eugenio Pérez, Si-Wei Liu. Author is a contributor, not the subsystem maintainer; MST still took the patch.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **None.** Needs only iommu_lock, iommu_pt, vhost_iotlb_reset, vhost_iotlb_del_range — all present. Applies as a lock-line move. **Can apply standalone.**
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 mbox for [email protected] saved the thread (3 messages).
- Cover: [PATCH 0/2] vdpa_sim: fix suspend/reset and dma_unmap locking
- This patch is **2/2** (-3 is cover+two patches).
- **No replies in the thread** (no NAK, no Cc: stable from reviewers, no v2).
- Committed Message-ID matches this v1 2/2; applied version is the submitted version.
- Lore HTML via WebFetch/curl: **403** — could not read lore web UI; thread content came from b4 mbox.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: Thread is author-only. **Michael S. Tsirkin** SOBed on merge (vhost/vdpa maintainer). No Reviewed-by on the list copy. Recipients of the original mail were not dumped (b4 dig -w needs a local commit SHA; this SHA is not in this tree).
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: **No external bug report.** No syzbot, bugzilla, or Reported- by. Evidence is code inspection plus author test that the module still loads on 6.16.8 — that does **not** prove the race was reproduced.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Two-patch series, independent. Patch 1/2 (pending_kick) is a different bug and is not required. No other series members needed.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: curl to lore.kernel.org/stable/?q=vdpa_sim+iommu_lock returned **403**. **UNVERIFIED:** whether stable@ already discussed this. No local git log --grep hit for this subject on this file.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: **vdpasim_dma_unmap()** only. Registered as .dma_unmap in vdpasim_config_ops / vdpasim_batch_config_ops.
**Step 5.2: TRACE CALLERS**
Record:
- vhost_vdpa_general_unmap() → ops->dma_unmap() (drivers/vhost/vdpa.c)
- Called from vhost_vdpa_pa_unmap() / vhost_vdpa_va_unmap() → vhost_vdpa_iotlb_unmap() → vhost_vdpa_unmap()
- Userspace: vhost_vdpa_process_iotlb_msg() VHOST_IOTLB_INVALIDATE under dev->mutex
- Teardown: vhost_vdpa_remove_as() → vhost_vdpa_iotlb_unmap() (release/cleanup, also under dev->mutex)
No other ops->dma_unmap users for this simulator in-tree.
**Step 5.3: TRACE CALLEES**
Record: vhost_iotlb_reset() → vhost_iotlb_del_range() → interval- tree delete/free; spin_lock/unlock on iommu_lock.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record:
- Reachable from **vhost-vdpa character-device IOTLB messages** (privileged userspace: QEMU/DPDK with vhost-vdpa).
- Simulator datapath: vdpasim_kick_vq() → kthread vdpasim_work_fn() → vdpa_sim_net/blk vringh_getdesc_iotlb() / vringh_iov_{pull,push}_iotlb() → iotlb_translate() under iommu_lock.
- **Yes, userspace can trigger both sides:** IOTLB invalidate vs running virtqueue processing.
**Nuance (verified):** vhost serializes dma_map, dma_unmap, and vdpa_reset with vdev.mutex. So **map vs unmap vs reset from vhost ioctls do not run together**. The commit text overstates that pair. The **verified** concurrent party is the **simulator worker**, which does **not** take vdev.mutex and walks the IOTLB under iommu_lock only.
This tree also advertises VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK (vdpasim getter at line 436), so DRIVER_OK / kicks can happen while still in passthrough (iommu_pt == true). First dma_unmap then takes the unlocked reset path while the worker may be in iotlb_translate().
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: dma_map, set_map, reset_map, and do_reset already take iommu_lock around iommu_pt and IOTLB updates. **dma_unmap is the only passthrough-exit that does not.** No sibling driver has this exact split; mlx5 has a different iommu_lock.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record:
- Tree: **Linux 6.12.111** (Makefile VERSION=6 PATCHLEVEL=12 SUBLEVEL=111; git describe HEAD → p-6.12-3-gc504cf0baa3d8; branch pending-6.12).
- Buggy code is in vdpasim_dma_unmap() as cited above.
- Introduced **v6.3**, so **before** 6.12 branched. Bug **does** exist here.
- This exact fix is **not** already applied (git log --grep empty for this subject).
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** Surrounding function matches the hunk exactly. No refactor of this path after 6.12. Expected difficulty: **clean apply**.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: Other vdpa_sim bugfixes are in this pending tree (worker- creation cleanup, sim_blk sector check, sim_net TX-pull check). **Nothing already fixes this lock split.** Sibling pending_kick fix is not here and is not required.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record:
- **Subsystem:** drivers/vdpa/vdpa_sim — vDPA **simulator** (net/blk loopback for testing).
- **Kconfig:** CONFIG_VDPA_SIM “vDPA device simulator core”, **depends on RUNTIME_TESTING_MENU**, help text: “testing, prototyping and development of vDPA”.
- **Criticality:** **PERIPHERAL** (not mm/VFS/net core). Not a production NIC/block driver. Still in-tree and used with vhost-vdpa in labs/CI (author: openEuler).
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature-but-active. Core simulator from ~2020; 6.12 still receives sim bugfixes (including 2026 worker-cleanup). Not a dead file.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **config-specific / driver-specific.** Only CONFIG_VDPA_SIM (and _NET/_BLOCK) plus vhost-vdpa IOTLB programming. Not universal. Production kernels often leave the module off; anyone who loads it (QEMU vDPA sim, distro debug kernels) can hit it.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- **Trigger:** IOTLB invalidate / unmap while iommu_pt[asid] is true, overlapping simulator worker IOTLB walk.
- **Likelihood:** not every boot; realistic with ENABLE_AFTER_DRIVER_OK and live IOTLB updates while VQs run. Hard to hit, timing-dependent.
- **Privilege:** vhost-vdpa + creating a sim device is typically **root**, not an unprivileged syscall primitive. Not a generic syzbot/LPE story.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- **Failure mode:** concurrent interval-tree reset vs walk → use-after- free / memory corruption / oops.
- **Severity:** **HIGH** (crash/UAF) on that config path; not a production-wide panic.
- Unlocked iommu_pt store vs locked readers is also a data race; the tree walk is the severe part.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** medium for sim users (prevents crash/UAF); low for generic 6.12 fleet that never loads vdpa_sim.
- **Risk:** **very low** (1–2 line lock move, matches existing dma_map protocol).
- **Ratio:** benefit exceeds risk. A no-op on systems without the module; cannot change unrelated drivers.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR backporting:**
- Real locking bug: IOTLB rbtree reset without the lock the walker uses
- Crash/UAF-class, not style
- Tiny, obviously correct, matches dma_map
- Buggy code present since v6.3; in this 6.12 tree
- Applies cleanly; no prerequisites
- Maintainer (MST) applied it in mainline
- This pending-6.12 tree already takes other vdpa_sim correctness fixes
- Race window is real against the kthread datapath (verified call chain)
**AGAINST:**
- Simulator behind RUNTIME_TESTING_MENU, not production hardware
- No syzbot / third-party crash report; Tested-by is the author
- No list review beyond maintainer SOB
- Commit’s “concurrent dma_map/dma_unmap/reset” is **overstated** given vhost dev->mutex
- Peripheral impact population
**UNRESOLVED:**
- Lore/stable HTML 403; no public stable@ discussion found
- Whether the author actually reproduced the race vs only smoke-tested module load
- b4 dig -w recipients (no local mainline SHA)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — lock move mirrors dma_map; author + maintainer SOB. Testing is light but the change is reviewable by inspection.
2. Fixes a real bug that affects users? **PASS** — unlocked IOTLB reset vs datapath walk. Affects vdpa_sim + vhost-vdpa users, which this tree already treats as in-scope.
3. Important issue (crash, security, corruption, deadlock)? **PASS** — UAF/oops on IOTLB tree; severity HIGH on that path.
4. Small and contained? **PASS** — ~2 lines, one function.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — context identical in 6.12.111
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **None** (not a device ID, quirk, DT, build, or doc-only change). It qualifies as a normal small race/crash fix.
**Step 9.4: MAKE YOUR DECISION**
This should be backported to **this** 6.12 tree. The bug is in this checkout, the fix is surgical, and the failure mode is memory-safety on a path this tree already ships. Simulator-only scope lowers fleet-wide benefit but does not make a 2-line IOTLB UAF fix inappropriate for stable, especially with near-zero regression risk.
---
### What the commit solves (for this tree)
vdpasim_dma_unmap() drops the whole passthrough IOTLB (vhost_iotlb_reset) and clears iommu_pt without iommu_lock, while dma_map and the vringh translator use that lock. A vhost-vdpa IOTLB unmap can therefore tear down the interval tree while the simulator worker is in iotlb_translate(). That is a kernel oops/UAF, not a benign inconsistency. Holding iommu_lock across that transition closes the hole.
### Stable rules / risk vs benefit
Meets the rules: real bug, small, no new API, applies here. Benefit is crash prevention for CONFIG_VDPA_SIM; risk is negligible. The missing Fixes:/Cc: stable tags are irrelevant to this pipeline.
### Concerns
- No independent repro; vhost mutex means map/unmap/reset do not race with each other — the datapath race is the one that matters and is verified.
- Patch 1/2 of the series is unrelated and must not be treated as a dependency.
- Peripheral testing driver; still in this tree and already receiving similar backports.
---
### Verification
- **[Phase 1]** Parsed subject/body/tags from the provided message and from b4 mbox (cover + 2/2). Tags: Tested-on/Tested-by/SOB author, SOB MST, Message-ID. No Fixes/Cc stable/Reported-by/Reviewed-by.
- **[Phase 2]** Read vdpasim_dma_unmap/vdpasim_dma_map in this tree; compared to the diff. Confirmed unlocked reset vs locked dma_map.
- **[Phase 2]** Read vhost_iotlb_reset/vhost_iotlb_del_range in drivers/vhost/iotlb.c (interval tree free).
- **[Phase 3]** git blame -L 725,743 → introducer 6c3d329e6486dd (Jason Wang, v6.3-rc1).
- **[Phase 3]** git merge-base --is-ancestor 6c3d329e6486dd HEAD → yes. git describe --contains → v6.3-rc1~84^2~23.
- **[Phase 3]** git show 6c3d329e6486dd — “get rid of DMA ops” added iommu_pt passthrough; unmap’s reset was left outside the lock.
- **[Phase 3]** git log --oneline -20 -- drivers/vdpa/vdpa_sim/vdpa_sim.c; --grep for this subject / pending_kick → fix not present; sibling not present.
- **[Phase 3]** git log --author="Xiong Weimin" -- drivers/vdpa/ — no vdpa_sim commits in this tree.
- **[Phase 4]** b4 mbox Message-ID → 3-message v1 series; no review replies; cover says issues are independent.
- **[Phase 4]** WebFetch/curl lore.kernel.org → 403. UNVERIFIED: stable@ archives and HTML lore UI.
- **[Phase 5]** Callers: ops->dma_unmap only from drivers/vhost/vdpa.c. Datapath: vdpa_sim_net.c/vdpa_sim_blk.c vringh_*_iotlb → iotlb_translate + iommu_lock.
- **[Phase 5]** vhost_vdpa_process_iotlb_msg holds dev->mutex — map/unmap/reset from vhost do not interleave (commit text overstated; datapath race still real).
- **[Phase 5]** VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK offered in this file (line 436).
- **[Phase 6]** head Makefile / git describe HEAD / make kernelversion → **6.12.111**, branch pending-6.12.
- **[Phase 6]** File context matches the hunk; fix not in tree.
- **[Phase 7]** drivers/vdpa/Kconfig: VDPA_SIM depends on RUNTIME_TESTING_MENU; testing/prototyping help text.
- **[Phase 8]** Failure mode: IOTLB rbtree UAF/oops, HIGH on that config; trigger: IOTLB unmap in passthrough vs worker.
- **UNVERIFIED:** lore web discussion beyond b4 mbox; whether author reproduced the race vs module-load smoke test; b4 dig -w recipient list.
The fix is small, correct, already matched by dma_map in this 6.12 tree, and prevents a real IOTLB UAF race on a driver this tree ships.
**YES**
drivers/vdpa/vdpa_sim/vdpa_sim.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/vdpa/vdpa_sim/vdpa_sim.c +1 -2
@@ -736,12 +736,11 @@ static int vdpasim_dma_unmap(struct vdpa_device *vdpa, unsigned int asid,if (asid >= vdpasim->dev_attr.nas)return -EINVAL ; +spin_lock (&vdpasim->iommu_lock);if (vdpasim->iommu_pt[asid]) {vhost_iotlb_reset (&vdpasim->iommu[asid]); vdpasim->iommu_pt[asid] = false; } - -spin_lock (&vdpasim->iommu_lock);vhost_iotlb_del_range (&vdpasim->iommu[asid], iova, iova + size -1 );spin_unlock (&vdpasim->iommu_lock);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-6.6] vdpa_sim: hold iommu_lock across dma_unmap passthrough transition
Sashiko has reviewed this patch and found no issues.
Quoted 16 lines
From: Xiong Weimin <[email protected]>
[ Upstream commit
7b411448c668bfab0d0e572cee5a592cea396ce7]
vdpasim_dma_map()updates the IOTLB and the passthrough (iommu_pt) state underiommu_lock.vdpasim_dma_unmap()clearsiommu_ptand resets the IOTLB before takingiommu_lock, then deletes the mapping while holding the lock.A concurrent
dma_map(),dma_unmap(), or reset path that also touches the same address space can therefore observe or modify the IOTLB andiommu_ptstate without consistent locking.Perform the passthrough transition and range deletion under the same
iommu_lockscope, matchingdma_map().
Quoted 7 lines
Tested-on: openEuler VM (6.16.8,
/usr/src/linux-6.16.8)Tested-by Xiong Weimin <[email protected]>Signed-off-by Xiong Weimin <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>Message-ID: <[email protected]>
Signed-off-by Sasha Levin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 bus: mhi: core: Fix sys error transition latency
In reply to Sasha LevinFrom: Qingtao Cao <[email protected]>
[ Upstream commit 22568e8f13a42ab69b7d624741768cbf15dded74 ]
Bring forward the idea to fix the power down latency in mhi_pm_disable_transition() further to mhi_pm_sys_error_transition() so that the transition into system error (triggered by AT!RESET) in the modems won't have to return only after the timeout of up to 24 seconds.
Once the device gets reset, there is no guarantee that it will send an interrupt to indicate the state transition. So polling is the sensible option here.
---
LLM Generated explanations, may be completely bogus:
I have the mailing-list thread, the 2021 sibling fix, and the local 7.3-rc4 code. Next I’ll write the full nine-phase verdict.
## Phase 1: Commit message forensics
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [bus: mhi: core:] [Fix] [sys error transition latency] — MHI host power-management: after a device SYSERR/RESET, the host was waiting on an interrupt-driven event that may never arrive, so recovery sat until timeout_ms (up to 24s).
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Qingtao Cao <[email protected]> (author)
- [mani: commit log] then Signed-off-by: Manivannan Sadhasivam <[email protected]> (MHI maintainer applied it and rewrote the log)
- Reviewed-by: Krishna Chaitanya Chundru <[email protected]> (Qualcomm MHI reviewer)
- `Link: https://patch.msgid.link/20260603011333.3306102-2-
[email protected]`
- No Fixes:, Reported-by:, Tested-by:, `Cc:
[email protected]`, or syzbot tags (absence of Fixes/Cc:stable is expected here)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** mhi_pm_sys_error_transition() waits with wait_event_timeout() for the MHI RESET bit to clear. After RESET, the device is not guaranteed to raise an interrupt, so the wait often runs to the full controller timeout.
- **Symptom:** SYSERR handling triggered by modem AT!RESET does not finish until timeout (commit text: up to 24 seconds).
- **Root cause:** interrupt-driven wait is the wrong primitive after RESET; polling the RESET bit is the correct approach (already used in mhi_pm_disable_transition()).
- **Version info in the message:** none. Thread later names a 5.17 test kernel and Sierra EM9291; the same wait lives in this tree.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. Subject and body both say “Fix”. It is a real timeout/hang-style bug, the same class as 44b1eba44dc53 (“Fix power down latency”), which had Cc: stable.
## Phase 2: Diff analysis
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/bus/mhi/host/pm.c — 3 insertions, 11 deletions (net −8)
- Function: mhi_pm_sys_error_transition()
- Scope: single-file surgical wait-primitive swap; error-path structure (MHI_PM_SYS_ERR_FAIL, BHI_INTVEC reprogram) unchanged
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: Inside if (reset_device) after mhi_set_mhi_state(..., MHI_STATE_RESET):
- **Before:** wait_event_timeout(state_event, mhi_read_reg_field(...) || !in_reset, timeout). wait_event_timeout() only rechecks on wakeup or timeout. After RESET, MSI is not expected, so the wait typically sleeps the full timeout_ms.
- **After:** mhi_poll_reg_field(..., MHICTRL_RESET_MASK, 0, 25000, mhi_cntrl->timeout_ms) — poll every 25ms until RESET clears or timeout. Failure still uses if (ret) → MHI_PM_SYS_ERR_FAIL.
Path: SYSERR recovery / RESET, not probe init.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Logic / correctness (wrong wait primitive after hardware RESET)** — not UAF/leak/race.
Mechanism: RESET drops device interrupt context; host waited for state_event. Nobody wakes it, so SYSERR recovery is delayed by the full timeout even though the device already cleared RESET. Polling matches power-down and power-up.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: same helper/interval already used in mhi_pm_disable_transition() and mhi_ready_state_transition() in this tree.
- Minimal: only the wait is replaced.
- Regression risk: low. Polling fsleep(25000) on a workqueue is the established pattern. Worst case is still timeout_ms, same as before. Does not change APIs or PM state machine.
## Phase 3: Git history
**Step 3.1: BLAME THE CHANGED LINES**
Record: Pre-fix wait_event_timeout block blamed to 556bbb442bbb44 (“Separate system error and power down handling”, 2020-11-18, first in **v5.11-rc1**). That split copied the wait into the new mhi_pm_sys_error_transition(). Surrounding reset-decision code later touched by 4d92e7c5ccadc (2025) and bce3f770684cc (MHI_PM_SYS_ERR_FAIL, 2024); those are not required for this hunk.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The incomplete sibling is 44b1eba44dc53 (2021-06-24, “Fix power down latency”) with Cc: stable and `Fixes:a6e2e3522f29. That commit converted **disable/power-down** to mhi_poll_reg_field and left **sys_error** on wait_event_timeout`. This commit finishes that leftover.
**Step 3.3: CHECK FILE HISTORY**
Record: Recent pm.c commits (753aa72545ce0 no-M3, aa1a0e93ed21a SYS_ERR power-up, 4d92e7c5ccadc power_up vs SYSERR) are unrelated. Standalone; not patch 2/N of a functional series.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Qingtao Cao has this single MHI commit in this tree. Applied by maintainer Manivannan Sadhasivam; reviewed by Krishna Chaitanya Chundru (Qualcomm).
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs mhi_poll_reg_field(..., delayus, timeout_ms) as in drivers/bus/mhi/host/main.c (this tree). Signature came from 1a42aef258805 plus later bitfield/timeout updates (d28cab4d4aa06, 6ab3d50b106c9). All present here. Applies standalone.
## Phase 4: Mailing list and external research
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 22568e8f13a42: https://patch.msgid.link/20260603011333.330
[email protected]
- b4 dig -a: single **v1**, subject `[v1 PATCH 1/1] bus: mhi: core:
fix sys error handling latency (msgid -2` is numbering, not a 2-patch series)
- Thread (5 messages via b4 mbox):
1. Qingtao: 24s SYSERR wait on AT!RESET
2. Krishna: initially “we should not see this delay”
3. Qingtao: Sierra Wireless EM9291, reused EM919x config (`timeout_ms
= 24000`); without patch ~24s, with patch ~11s; 5.17 test kernel
4. Krishna: device **does** clear RESET; **MSI is not expected after MHI RESET**; Reviewed-by
5. Qingtao: same issue as 44b1eba44dc53
6. Mani: applied as 22568e8f13a42
- No NAK. No reviewer Cc: stable. Maintainer improved the commit log (polling rationale).
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: b4 dig -w: To/Cc included [email protected] (maintainer), [email protected], [email protected], linux- [email protected], Krishna (review), Vivek Pernamitta. Right lists and maintainer.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No bugzilla/syzbot. Report is the patch author on real hardware (EM9291 / AT!RESET). Krishna confirmed it is generic MHI RESET behavior, not one broken device.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone 1/1. Related historical fix 44b1eba44dc53 already in this tree.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** — lore.kernel.org WebFetch returned 403; no stable@ discussion in the mbox. No evidence it was NAK’d for stable.
## Phase 5: Code semantic analysis
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: mhi_pm_sys_error_transition(); helper mhi_poll_reg_field().
**Step 5.2: TRACE CALLERS**
Record:
- mhi_pm_st_worker() → DEV_ST_TRANSITION_SYS_ERR → mhi_pm_sys_error_transition()
- mhi_pm_sys_err_handler() queues that transition
- mhi_pm_sys_err_handler() from drivers/bus/mhi/host/main.c: SYSERR in intvec, ctrl event ring MHI_STATE_SYS_ERR, IRQ with no events
Call path: device SYSERR / host RESET processing on the MHI high-prio workqueue. Reachable when a WWAN modem hits SYSERR or AT!RESET.
**Step 5.3: TRACE CALLEES**
Record: mhi_set_mhi_state(RESET), mhi_poll_reg_field → mhi_read_reg_field + fsleep, mhi_tryset_pm_state, mhi_write_reg(BHI_INTVEC). No new locks or allocations.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace (AT!RESET or modem crash) → device SYSERR → host IRQ/event → workqueue → this function. Unprivileged users typically cannot issue AT!RESET without modem access; operators and WWAN stacks can. Not a theoretical path.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same poll already in mhi_pm_disable_transition(), mhi_ready_state_transition(), and mhi_async_power_up() SYS_ERR reset. Remaining wait_event_timeout() uses are M0/M2/M3-style waits that still get IRQs — correctly left alone.
## Phase 6: Cross-referencing against the local tree
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record:
- Local tree: **v7.3-rc4** (VERSION=7 PATCHLEVEL=3 SUBLEVEL=0 EXTRAVERSION=-rc4, HEAD f0100363d8c37)
- File drivers/bus/mhi/host/pm.c exists; mhi_pm_sys_error_transition() exists
- Buggy wait_event_timeout present from v5.11 through parent of 22568e8f13a42; this commit is already on HEAD as a mainline merge (git merge-base --is-ancestor 22568e8f13a42 HEAD succeeded)
- EM929x uses modem_sierra_em919x_config with .timeout_ms = 24000 in pci_generic.c — same 24s the reporter hit
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply on this tree. mhi_poll_reg_field() 6-argument form matches. No conflicting refactor of this hunk.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: Power-down poll fix 44b1eba44dc53 is here. No other equivalent sys_error poll fix besides this commit.
## Phase 7: Subsystem and maintainer context
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/bus/mhi/host/ — MHI host bus for Qualcomm/Sierra/Telit WWAN modems. **IMPORTANT** (not core mm/VFS): common on laptops, embedded, Android with WWAN. Maintainer: Manivannan Sadhasivam.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained (recent no-M3, SYSERR/power_up, tracing, pci_generic). The wait itself is old (2020); this is a long-standing leftover, not churn in new code.
## Phase 8: Impact and risk
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver-specific: MHI host users (WWAN PCI modems). EM919x/EM929x and any controller that takes SYSERR + RESET. RDDM controllers skip mhi_pm_sys_err_handler(), so they are not on this path.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Modem SYSERR or AT!RESET. Not every boot; common for modem recovery/reset. Krishna: **no MSI after RESET is expected** — so the full-timeout wait is the normal case, not a rare race. Unprivileged trigger only with modem AT access.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Host sleeps in SYSERR recovery until timeout_ms (8s–24s typical, 50s–120s on some pci_generic configs) even after RESET has cleared. Not oops/corruption/UAF. User-visible: WWAN reset/recovery stalled for tens of seconds. **Severity: MEDIUM-HIGH** (hang-like timeout on a real device path). Measured: 24s → ~11s on EM9291.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** high for MHI modem users — removes a systematic multi- second stall on SYSERR/RESET. Same class as the 2021 stable-bound power-down fix.
- **Risk:** very low — 3 lines added / 11 removed, proven helper, error handling unchanged.
- **Ratio:** benefit ≫ risk.
## Phase 9: Final synthesis
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real, user-reported stall (Sierra EM9291 AT!RESET, 24s vs ~11s)
- Qualcomm reviewer: MSI after RESET is not expected — generic protocol bug
- Identical 2021 power-down fix (44b1eba44dc53) was Cc: stable
- Small, obviously correct, already used on the disable path in this tree
- Maintainer applied; Reviewed-by from Qualcomm
- Buggy wait present since v5.11; EM929x + 24000ms timeout exist in this tree
- mhi_poll_reg_field already here; applies cleanly
**AGAINST:**
- Not oops/UAF/corruption/security
- No Fixes: / Cc: stable (not a negative per the review rules)
- Author’s measurements were on 5.17; logic is unchanged in this tree
- Krishna first questioned the delay, then agreed and reviewed
**UNRESOLVED:**
- Whether stable@ ever discussed this (lore 403)
- Cover letter 3306102-1 body not fetched; series is 1/1 from b4
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — copies existing poll; author measured; maintainer + Qualcomm review
2. Fixes a real bug that affects users? **PASS** — 24s SYSERR recovery on real modem hardware
3. Important issue (crash, security, corruption, deadlock)? **PASS** — hang-like timeout on RESET; stable rules also cover hangs and “oh, that’s not good”; sibling fix was stable material
4. Small and contained? **PASS** — 14-line hunk, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — code, helper, and signature all present
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not a device ID, quirk table, DT, build, or docs patch). Qualifies as a normal bugfix.
**Step 9.4: MAKE YOUR DECISION**
This tree is v7.3-rc4. The SYSERR path still used interrupt wait after RESET until this change. That wait is wrong for MHI RESET, stalls recovery for the full controller timeout, and was already fixed the same way for power-down in 2021 (and sent to stable). The leftover in mhi_pm_sys_error_transition() is a small, proven, user-visible fix and belongs in this tree.
### What the commit solves for this tree
mhi_pm_sys_error_transition() issued MHI RESET then used wait_event_timeout() on state_event. After RESET the device drops interrupt context and does not send MSI, so the host slept until timeout_ms (24s on EM919x/EM929x). Switching to mhi_poll_reg_field() watches the RESET bit directly, which is what disable/power-up already do here.
### Stable rules / risk
Meets the rules: real hang-style bug, tiny, no new API, applies cleanly. Risk is a 25ms poll loop already used on adjacent paths. Benefit is much shorter modem SYSERR/AT!RESET recovery.
### Concerns
None that block this tree: helper signature matches; no series deps. Not a crash/CVE, but a systematic tens-of-seconds stall on a production WWAN path.
Verification:
- [Phase 1] Tags: SOB Qingtao + Mani, R-b Krishna, Link msgid; no Fixes/Cc:stable/syzbot
- [Phase 2] Diff: pm.c mhi_pm_sys_error_transition(), wait_event_timeout → mhi_poll_reg_field, 3+/11-
- [Phase 3] blame: 556bbb442bbb44 (v5.11-rc1) introduced the wait; 44b1eba44dc53 (2021, Cc:stable) fixed only disable
- [Phase 3] git merge-base --is-ancestor 22568e8f13a42 HEAD: yes; 44b1eba44dc53 and 556bbb442bbb44 also ancestors
- [Phase 3] mhi_poll_reg_field in main.c takes (mask, val, delayus, timeout_ms) matching the patch
- [Phase 4] b4 dig -c 22568e8f13a42: lore msgid 20260603011333.3306102-2; v1 only
- [Phase 4] b4 dig -a: 1/1 series; b4 dig -w: maintainer + mhi/linux-arm-msm lists
- [Phase 4] b4 mbox: Krishna confirmed no MSI after RESET; EM9291 24s→11s; Mani applied
- [Phase 4] WebFetch lore/patch.msgid.link: 403 — thread recovered via b4
- [Phase 5] callers: mhi_pm_st_worker / mhi_pm_sys_err_handler from SYSERR IRQ/event in main.c
- [Phase 6] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion: 7.3.0-rc4
- [Phase 6] pci_generic.c: EM929x shares EM919x config, timeout_ms = 24000
- [Phase 8] Failure: SYSERR recovery blocked until timeout; severity hang-like, not oops
- UNVERIFIED: stable@ lore discussion (HTTP 403)
- UNVERIFIED: cover letter body 3306102-1
**YES**
drivers/bus/mhi/host/pm.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/bus/mhi/host/pm.c +3 -11
@@ -651,21 +651,13 @@ static void mhi_pm_sys_error_transition(struct mhi_controller *mhi_cntrl)/* Trigger MHI RESET so that the device will not access host memory */ if (reset_device) { -u32 in_reset =-1 ; -unsigned long timeout =msecs_to_jiffies (mhi_cntrl->timeout_ms); -dev_dbg (dev,"Triggering MHI Reset in device\n" );mhi_set_mhi_state (mhi_cntrl,MHI_STATE_RESET );/* Wait for the reset bit to be cleared by the device */ - ret =wait_event_timeout (mhi_cntrl->state_event, -mhi_read_reg_field (mhi_cntrl, - mhi_cntrl->regs, -MHICTRL , -MHICTRL_RESET_MASK , - &in_reset) || - !in_reset, timeout); -if (!ret || in_reset) { + ret =mhi_poll_reg_field (mhi_cntrl, mhi_cntrl->regs,MHICTRL , +MHICTRL_RESET_MASK ,0 ,25000 , mhi_cntrl->timeout_ms); +if (ret) {dev_err (dev,"Device failed to exit MHI Reset state\n" );write_lock_irq (&mhi_cntrl->pm_lock); cur_state = mhi_tryset_pm_state(mhi_cntrl,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 net: dsa: mt7530: check bus->read() error in core_rmw()
In reply to Sasha LevinFrom: Daniel Golle <[email protected]>
[ Upstream commit 573d6e3afe3d01e34dc82c77bf22ca96a74d805e ]
core_rmw() accesses the MMD core registers directly rather than through the regmap and has the same unchecked bus->read() as the one just fixed in the MDIO regmap backend: a negative errno is consumed as register data, modified and written back to the switch. Check the read and bail out like the surrounding bus accesses do.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: [net: dsa: mt7530] [check] [detect bus->read() failure in core_rmw() instead of treating errno as register data]
**Step 1.2: Tags**
Record:
- Signed-off-by: Daniel Golle <[email protected]> (author)
- Reviewed-by: Andrew Lunn <[email protected]> (DSA co-maintainer)
- `Link: https://patch.msgid.link/48bb9f0b311a9efeda2a6b24a7e05d4792393a
[email protected]`
- Signed-off-by: Jakub Kicinski <[email protected]> (netdev maintainer)
- No Fixes: in the committed message
- Mailing-list submission **did** include `Fixes: b8f126a8d543 ("net-
next: dsa: add dsa support for Mediatek MT7530 switch")` (verified in the saved mbox); it was dropped before mainline
- No Reported-by:, Tested-by:, Cc: stable in the committed message (absence is expected)
**Step 1.3: Body**
Record:
- **Bug:** core_rmw() talks to MMD core registers via raw bus->read()/bus->write(), not regmap. A failed bus->read() returns a negative errno, which is used as the current register value, masked/ORed, and written back.
- **Symptom:** garbage RMW into switch MMD registers (clock-gate bits on this path).
- **Root cause:** same unchecked-read pattern as the MDIO regmap backend, which this tree already has as 93d46870c5440.
- **Version info:** none in the body. The inlined form is from 7c5e37d7ee78d (v6.11 era, present here). The mailing-list Fixes: points at the 2017 driver introduction; the old core_read_mmd_indirect() had the same unchecked read.
**Step 1.4: Hidden bug fix?**
Record: Not hidden. Explicit error-path correctness fix: missing check → errno treated as data → written to hardware.
---
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- File: drivers/net/dsa/mt7530.c
- Scope: ~5 insertions / 1 deletion in one function
- Function: core_rmw()
- Classification: single-file surgical fix
**Step 2.2: Code flow**
Record:
- **Before:** after three checked MMD address writes, val = bus->read(...). No check. val &= ~mask; val |= set; then bus->write(...).
- **After:** ret = bus->read(...); if ret < 0 goto the existing err path (log + unlock); else val = ret and continue the RMW.
- Path: error path of an MDIO read during RMW. Normal success path unchanged.
**Step 2.3: Bug mechanism**
Record:
- Category: logic / correctness on an error path (errno consumed as register data, then written back). Same class as the already-present MDIO regmap fix.
- mii_bus->read returns a 16-bit value or a negative errno (include/linux/mdio.h: “returns value or negative error code”). val is u32, so -ETIMEDOUT (-110) becomes 0xffffff92. bus->write() takes u16, so the switch sees 0xff92 with the intended bit tweaks, not the real register contents.
- Mechanism: check ret < 0 and skip the write, matching the surrounding writes.
**Step 2.4: Fix quality**
Record:
- Obviously correct; copies the existing write-error pattern in the same function.
- Minimal; no unrelated edits, no API change.
- Regression risk: very low. On read failure it no longer writes. core_rmw() is still void and still only logs (pre-existing); this patch does not invent a new return convention.
- val = ret after the check is safe: success values are 0..0xffff.
---
## Phase 3: Git history
**Step 3.1: Blame**
Record:
- Unchecked read at lines 155–156: 7c5e37d7ee78d (“simplify core operations”, Arınç ÜNAL, 2024-04-18).
- That commit inlined core_read_mmd_indirect(), which already returned bus->read() without checking. The defect dates to b8f126a8d543 (2017), driver introduction.
- Inlined form is in this tree (git merge-base --is-ancestor 7c5e37d7ee78d HEAD succeeded). git describe --contains places it around v6.11-rc1, so it is in 6.12.
**Step 3.2: Fixes: tag**
Record: No Fixes: on the committed patch. Submission tagged b8f126a8d543, which **is** an ancestor of this tree. Intermediate:7c5e37d7ee78d inlined the helper and kept the bug.
**Step 3.3: File history**
Record:
- This tree already has the sibling: 93d46870c5440 “check bus->read() errors in the MDIO regmap backend”.
- Also: 96e0f5184af69 “error out on failed reads in MT7531 PHY polling”.
- Candidate 573d6e3afe3d0 is **not** an ancestor of HEAD.
- Standalone vs series: mailing-list subject is [PATCH net v2 2/6]. Diff does not depend on 1/6 or 3–6/6.
**Step 3.4: Author**
Record: Daniel Golle is a regular MT7530 contributor (OpenWrt/MediaTek). Nearby commits by him in this tree are the other MDIO-error fixes. Reviewed by Andrew Lunn.
**Step 3.5: Dependencies**
Record: None for this hunk. It uses existing ret, goto err, and bus->read/bus->write. git apply --check succeeded (hunk offset 28 lines only).
---
## Phase 4: Mailing list / external research
**Step 4.1: Original discussion**
Record:
- b4 dig -c 573d6e3afe3d0 → https://patch.msgid.link/48bb9f0b311a9efed
[email protected]
- Series: [PATCH net v2 0/6] net: dsa: mt7530: fix remaining swallowed MDIO access errors
- v2: “no changes” for this patch; Andrew’s Reviewed-by kept.
- Cover letter: leftover companion of the first “swallowed MDIO read errors” series (already on net); this is the unchecked bus->read() in core_rmw().
- Sent to net (fixes), not net-next.
- No NAK in the saved mbox. Applied by Jakub Kicinski (0200d48477602 merge).
**Step 4.2: Recipients (b4 dig -w)**
Record: Andrew Lunn, Vladimir Oltean, netdev maintainers, MediaTek, netdev@, linux-mediatek@. Right audience. Lunn reviewed.
**Step 4.3: Bug report**
Record: No syzbot/bugzilla. Found by review of the same MDIO-error class (cover letter cites Sashiko AI review of the parent series).
**Step 4.4: Series**
Record: 6 patches. This is 2/6 and is self-contained. 3–5/6 are other swallowed-error sites; 1/6 is pcs-mtk-lynxi; 6/6 is IRQ-chip serialization. Not required for this hunk.
**Step 4.5: Stable list**
Record: **UNVERIFIED** — lore.kernel.org returned 403/503 to WebFetch/curl. No local evidence this was rejected for stable.
---
## Phase 5: Code semantics
**Step 5.1: Functions**
Record: core_rmw() only.
**Step 5.2: Callers**
Record:
- core_set() / core_clear() → core_rmw()
- mt7530_pll_setup(): clear/set REG_GSWCK_EN on CORE_TRGMII_GSW_CLK_CG (switch setup, 40 MHz XTAL)
- mt7530_setup_port6(): clear/set REG_TRGMIICK_EN (port 6 TRGMII clock)
- mt7530_pll_setup() from mt7530_setup() (~line 2422)
- mt7530_setup_port6() from mt7530_mac_config() when port == 6
**Step 5.3: Callees**
Record: mt7530_mutex_lock/unlock, bus->write, bus->read, dev_err.
**Step 5.4: Reachability**
Record: Yes, from DSA probe/setup and phylink MAC config on MT7530 (common in MediaTek routers). Not a syscall hot path; hit on bring-up and port-6 mode changes. Userspace/netlink can trigger mac_config.
**Step 5.5: Similar patterns**
Record: Same bug already fixed in mt7530_regmap_read() in this tree. core_write() only writes (no analogous read). Remaining siblings (PHY_IAC writes, CORE_PLL_GROUP4, FDB/VLAN cmd) are other series patches, not prerequisites.
---
## Phase 6: This tree (6.12.y)
**Step 6.1: Buggy code present?**
Record: Yes. Tree is pending-6.12 / 6.12.111 (p-6.12-4-gbf6fcdf761abd). Current core_rmw() still does val = bus->read(...) with no check (drivers/net/dsa/mt7530.c:155-156). 573d6e3afe3d0 is not an ancestor of HEAD.
**Step 6.2: Backport difficulty**
Record: Clean apply (git apply --check: hunk succeeded at offset 28). Surrounding core_rmw() matches the pre-image.
**Step 6.3: Related fixes already here?**
Record: Regmap-backend check is here; PHY polling check is here. This leftover core_rmw() instance is not. No alternate fix of this function.
---
## Phase 7: Subsystem context
**Step 7.1**
Record: drivers/net/dsa/mt7530.c — MediaTek MT7530 DSA. **IMPORTANT** (common embedded/router switch), not core mm/VFS, not staging.
**Step 7.2**
Record: Actively maintained; recent 6.12 backports already include other MT7530 MDIO-error and hardware fixes.
---
## Phase 8: Impact and risk
**Step 8.1: Who is affected**
Record: Driver-specific: CONFIG_NET_DSA_MT7530 (MDIO-attached MT7530/MT7531, common on MT7621/MT798x-class boards).
**Step 8.2: Trigger**
Record: bus->read() failure during PLL/clock RMW (timeout, NACK, flaky MDIO). Not every boot if the bus is healthy. Unprivileged users do not trigger MDIO failure directly; they can hit the RMW via interface/port config. Timing/hardware dependent.
**Step 8.3: Failure mode**
Record: On MDIO read failure, a truncated errno (e.g. 0xff92) is written to CORE_TRGMII_GSW_CLK_CG (core / TRGMII clock gates) instead of toggling bit 0 or 1. That can leave clocks misconfigured (no link / switch not forwarding) rather than failing closed. Severity: **HIGH** on that error path (hardware misconfiguration), not a panic/UAF.
**Step 8.4: Risk-benefit**
Record:
- Benefit: stops garbage writes to switch clock-gate MMDs; completes the same class already backported via the regmap patch.
- Risk: very low (4–5 lines, existing err path, no locking/API change).
- Ratio: favorable.
---
## Phase 9: Synthesis
**For backporting**
- Real bug: negative MDIO errno used as register data and written back.
- Consequence: corrupt RMW of switch clock-gate registers.
- Small, obviously correct, reviewed by Andrew Lunn, taken into net as a fix.
- Buggy code is in this 6.12 tree; patch applies cleanly.
- Same class as 93d46870c5440, already in this tree; this is the leftover core_rmw() site.
**Against**
- Error path only (MDIO must already be failing).
- Still void; errors are only logged (pre-existing).
- No syzbot/user crash report.
- Labelled 2/6, but this hunk does not need the rest.
**Unresolved**
- Stable-list discussion (lore 403/503). Does not change the technical case.
**Stable rules**
1. Obviously correct and tested? **PASS** — matches surrounding checks; Lunn Reviewed-by; in mainline net.
2. Real user-affecting bug? **PASS** — garbage written to MT7530 clock- gate MMDs on read failure.
3. Important (crash/security/corruption/deadlock)? **PASS** — hardware misconfiguration of switch clocks; same class already accepted in this tree.
4. Small and contained? **PASS** — ~5 lines, one function.
5. No new features/APIs? **PASS**.
6. Applies to this tree? **PASS** — git apply --check clean.
**Exception category:** none (not an ID/quirk/DT/build/doc exception). Qualifies as a normal small driver bugfix.
---
### What the commit solves for this tree
In 6.12, core_rmw() still assigns bus->read() to u32 val without checking. On timeout/NACK that errno is masked, OR’d, and written to CORE_TRGMII_GSW_CLK_CG during PLL setup and port-6 TRGMII clock enable. The fix bails out like the three preceding writes. It is the companion to the regmap-backend check already present here.
Risk is negligible; benefit is avoiding a bad clock-gate RMW when MDIO fails on a widely used MediaTek DSA switch.
Verification:
- [Phase 1] Parsed tags: Lunn Reviewed-by, msgid link; no committed Fixes:; mbox had Fixes: b8f126a8d543
- [Phase 2] Diff: 5 insertions in core_rmw(); check ret < 0 before RMW write
- [Phase 3] Blame: inlined by 7c5e37d7ee78d (v6.11, in this tree); original unchecked read in b8f126a8d543 (2017)
- [Phase 3] git merge-base --is-ancestor 573d6e3afe3d0 HEAD → not in tree; 7c5e37d7ee78d is in tree
- [Phase 3] Sibling 93d46870c5440 is in this tree
- [Phase 4] b4 dig -c 573d6e3afe3d0: v2 2/6 of “fix remaining swallowed MDIO access errors”; v2 no changes; Lunn review on 1–3 and 6
- [Phase 4] Cover letter: leftover core_rmw() companion of the first MDIO-error series
- [Phase 4] b4 dig -w: netdev + DSA + MediaTek CCs
- [Phase 4] lore WebFetch/curl 403/503; thread recovered via b4 dig -m
- [Phase 5] Callers: mt7530_pll_setup, mt7530_setup_port6 → DSA setup / mac_config
- [Phase 5] bus->read contract: value or negative errno (include/linux/mdio.h)
- [Phase 6] git describe HEAD: p-6.12-4-gbf6fcdf761abd; make kernelversion: 6.12.111; buggy val = bus->read still at mt7530.c:155
- [Phase 6] git apply --check of 573d6e3afe3d0: succeeded (offset
28)
- [Phase 8] Failure mode: truncated errno written to CORE_TRGMII_GSW_CLK_CG; severity HIGH on that error path
- UNVERIFIED: whether stable@ discussed this commit (lore unreachable)
**YES**
drivers/net/dsa/mt7530.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/dsa/mt7530.c +5 -1
@@ -124,8 +124,12 @@ core_rmw(struct mt7530_priv *priv, u32 reg, u32 mask, u32 set) goto err;/* Read the content of the MMD's selected register */ - val = bus->read (bus,MT753X_CTRL_PHY_ADDR (priv->mdiodev->addr), + ret = bus->read (bus,MT753X_CTRL_PHY_ADDR (priv->mdiodev->addr),MII_MMD_DATA ); +if (ret <0 ) + goto err; + val = ret; + val &= ~mask; val |= set;/* Write the data into MMD's selected register */
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 fbdev: maxine: fix 64-bit build error
In reply to Sasha LevinFrom: Randy Dunlap <[email protected]>
[ Upstream commit 3adec5c640dc09dca5605043e138412fd5a0629d ]
The KSEG1ADDR() macro is only defined for non-64BIT builds. Use the CKSEG1ADDR() macro instead.
In file included from ../drivers/video/fbdev/maxinefb.c:34:../drivers/video/fbdev/maxinefb.c: In function 'maxinefb_ims332_write_register':../include/video/maxinefb.h:16:41: error: implicit declaration of function 'KSEG1ADDR'; did you mean 'CKSEG1ADDR'? [-Wimplicit-function-declaration]
16 | #define MAXINEFB_IMS332_ADDRESS KSEG1ADDR(0x1c140000)../drivers/video/fbdev/maxinefb.c:66:49: note: in expansion of macro 'MAXINEFB_IMS332_ADDRESS'
66 | register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;../drivers/video/fbdev/maxinefb.c:66:40: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
66 | register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
---
LLM Generated explanations, may be completely bogus:
This tree is **6.12.111** (pending-6.12). The buggy KSEG1ADDR() use is still in include/video/maxinefb.h; the candidate is a two-line build fix and belongs in this tree.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [fbdev/maxine] [fix] [64-bit build error] — subsystem `fbdev:
maxine`, action verb **fix**, intent is to make the DECstation Maxine framebuffer driver compile on 64-bit MIPS.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Randy Dunlap <[email protected]> (author)
- Acked-by: Maciej W. Rozycki <[email protected]> (MIPS/DECstation expert)
- Signed-off-by: Helge Deller <[email protected]> (fbdev maintainer)
- No Fixes: tag (expected for this review)
- No Reported-by:, Tested-by:, Cc: stable, or Link:
- Ignore any pipeline Signed-off-by: Sasha Levin / [Upstream commit ...]
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** KSEG1ADDR() is used in include/video/maxinefb.h but is only defined when !CONFIG_64BIT in arch/mips/include/asm/addrspace.h.
- **Symptom:** compile failure:
error: implicit declaration of function 'KSEG1ADDR' plus `warning:
cast to pointer from integer of different size`.
- **Root cause:** 32-bit-only KSEG macros used in a driver that Kconfig allows on 64-bit MACH_DECSTATION.
- **Fix:** use CKSEG1ADDR(), which exists for both 32-bit and 64-bit.
- **Version info:** none in the message; series cover says the code is “from the beginning of git time.”
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. This is an explicit build-error fix, not a cleanup in disguise. It is patch 03/03 of “fbdev: maxine: clean up build issues”; patches 01/02 are warning/cleanup in maxinefb.c and are independent of this header change.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: include/video/maxinefb.h only
- Two #define substitutions: KSEG1ADDR → CKSEG1ADDR
- ~2 insertions / 2 deletions
- No functions added or rewritten; macros MAXINEFB_IMS332_ADDRESS and DS5000_xx_ONBOARD_FBMEM_START
- Scope: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Before: both MMIO/FB base macros expand via KSEG1ADDR(), which does not exist under CONFIG_64BIT.
- After: same physical addresses mapped through CKSEG1ADDR().
- Affected path: compile of maxinefb.c (register access and framebuffer base). Runtime on 32-bit is unchanged because the two macros are identical there.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- Category: **build / type correctness** (implicit declaration; 32-bit integer treated as a pointer on 64-bit).
- Mechanism: KSEG1ADDR is inside #else /* !CONFIG_64BIT */. CKSEG1ADDR is defined in both branches. On 32-bit, CKSEG1ADDR(a) is (CPHYSADDR(a) | KSEG1), same as KSEG1ADDR. On 64-bit it uses CKSEG1 (0xffffffffa0000000).
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: compiler even suggested CKSEG1ADDR.
- Minimal; no API or struct changes.
- Regression risk: very low. 32-bit generated addresses match. 64-bit previously did not compile, so there is no working 64-bit runtime to regress.
- Acked by the DECstation/MIPS expert.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record: Both macros come from 1da177e4c3f41 (“Linux-2.6.12-rc2”, 2005). Present since git history began. git merge-base --is-ancestor 1da177e4c3f41 HEAD succeeds.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable. The broken use is the original driver code, not a later regression.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record (this tree, path-limited):
- e4f10ea729670 fbdev/maxinefb: Use fbdev I/O helpers
- 6304da8a91da8 fbdev: Remove FBINFO_DEFAULT from static structs
- 8c13c9de80b51 fbdev: maxinefb: Remove trailing whitespaces
- plus older const/__initdata moves
None of these touch the KSEG1ADDR macros. Header last changed at git genesis. Standalone vs series: submitted as 03/03, but this hunk does not depend on 01/02.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Randy Dunlap has many fbdev build/Kconfig fixes in this tree (sh7760fb, hgafb, uvesafb, geode, atyfb, …). No prior maxinefb commit here. Helge Deller is the fbdev maintainer who merged it.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. CKSEG1ADDR has existed in addrspace.h for as long as this tree’s MIPS headers. The patch applies to the current header as-is. Cover letter patches 01/02 only change maxinefb.c (static, drop unused maxinefb_ims332_read_register).
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c <sha> cannot run: this commit is **not in the local tree**.
- b4 dig on Message-ID [email protected] also found no local commit.
- Original submission (13 Aug 2026): [PATCH 03/03] on linux-kernel; cover [PATCH 00/03] “fbdev: maxine: clean up build issues”. Randy:
“Now builds cleanly on 32-bit and 64-bit MACH_DECSTATION.”
- Helge’s fbdev pull for v7.3-rc1 lists it under **Fixes**: “maxine: fix 64-bit build error and code cleanups”.
- Review: Maciej Acked-by only; no NAK, no stable-tag request found in the retrieved thread text.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: To/Cc included Helge Deller, linux-fbdev, dri-devel, Maciej W. Rozycki. Maciej acked. Helge merged.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla. Failure is a compiler error reproduced in the commit message (typical Randy Dunlap / kbuild-style report).
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Series of 3 (+ later two maxine cleanups in the same pull: init return value, MODULE_LICENSE()). Only 03/03 is required to fix the implicit-declaration **error**. 01/02 are warning-level.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search returned **403**. UNVERIFIED whether stable@ already discussed this. Openwall/Indiana archives show no stable nomination in the review replies retrieved.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: No functions modified. Macros used in maxinefb_ims332_write_register(), maxinefb_ims332_read_register(), and maxinefb_init().
**Step 5.2: TRACE CALLERS**
Record:
- MAXINEFB_IMS332_ADDRESS / DS5000_xx_ONBOARD_FBMEM_START: only drivers/video/fbdev/maxinefb.c.
- maxinefb_ims332_write_register: maxinefb_setcolreg() and maxinefb_init() (cursor RAM wipe).
- maxinefb_ims332_read_register: defined, **never called** in this tree (that is series patch 02).
- maxinefb_init: module_init. Probe path after mips_machtype == MACH_DS5000_XX.
**Step 5.3: TRACE CALLEES**
Record: Direct volatile MMIO via the mapped KSEG1/CKSEG1 addresses; register_framebuffer() in init. No new callees.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable at boot on Personal DECstation 5000/xx with CONFIG_FB_MAXINE=y. The **compile** failure is reachable for any MACH_DECSTATION + 64BIT + FB_MAXINE config, including 64-bit R4x00 DECstation kernels that can still select this bool (Kconfig does not restrict it to R3000). Userspace does not trigger the compile error.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Other DECstation code already uses CKSEG1ADDR (e.g. drivers/net/ethernet/amd/declance.c). Remaining KSEG1ADDR in fbdev is au1100fb.c (Alchemy, 32-bit-oriented). This is the only use in include/video/.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** include/video/maxinefb.h lines 16 and 22 still use KSEG1ADDR. git describe HEAD → p-6.12-3-gc504cf0baa3d8; make kernelversion → **6.12.111**. Introduced at 2.6.12-rc2 genesis; present for the entire 6.12 life.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** Local header matches the patch context exactly. CKSEG1ADDR is already defined for both 32- and 64-bit in this tree’s addrspace.h.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: git log --grep="fix 64-bit build error" -- include/video/maxinefb.h is empty. No equivalent fix in this checkout.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/video/fbdev + include/video — MIPS DECstation onboard framebuffer. **PERIPHERAL** (vintage workstation). Still a real in-tree driver, not staging.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: maxinefb itself is dormant (whitespace/helpers only). MACH_DECSTATION is mature. fbdev still receives small fixes (this series landed in the v7.3 fbdev pull).
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Config-specific: CONFIG_MACH_DECSTATION && CONFIG_FB_MAXINE && CONFIG_64BIT. 32-bit Maxine builds already compile. 64-bit DECstation + this driver cannot build today.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Trigger is **building** that config, every time. Not a race. Unprivileged userspace is irrelevant. Valid Kconfig: MACH_DECSTATION selects SYS_SUPPORTS_64BIT_KERNEL; CPU_R4X00 selects CPU_SUPPORTS_64BIT_KERNEL; FB_MAXINE depends only on FB=y && MACH_DECSTATION.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Build error** — driver (and thus that kernel config) does not compile. Local Documentation/process/stable-kernel-rules.rst lists “a **build error** (but not for things marked CONFIG_BROKEN)” as a qualifying bug. FB_MAXINE is not BROKEN. Implicit declaration is a hard GCC error, independent of CONFIG_WERROR (which defaults to COMPILE_TEST in this tree).
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** 64-bit MACH_DECSTATION + Maxine fb builds again; 32-bit behavior unchanged.
- **Risk:** very low (2 equivalent-on-32-bit macro lines, expert ack).
- Ratio: favorable. Niche hardware, but build-break fixes are in-policy even for small drivers.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real compile failure with a pasted compiler log
- KSEG1ADDR confirmed undefined under CONFIG_64BIT in this tree
- CKSEG1ADDR is the portable replacement; 32-bit expansion is identical
- Two-line, single-file, applies cleanly
- Buggy code present since 2.6.12, still in 6.12.111
- Acked by Maciej W. Rozycki; merged by Helge Deller
- Stable rules in this tree explicitly allow build-error fixes
- Standalone vs the rest of the series
AGAINST:
- Very small user population (1990s Personal DECstation)
- Maxine silicon is R3000-class; 64-bit+FB_MAXINE is a Kconfig-legal combo more than a common production image
- No Cc: stable (not a negative per the review rules)
UNRESOLVED:
- Exact mainline SHA (commit not in this checkout)
- b4 dig / lore.kernel.org 403
- Whether stable@ already discussed it
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — compiler suggestion, Maciej ack, 32-bit equivalence verified in addrspace.h
2. Fixes a real bug that affects users? **PASS** — cannot build a valid 64-bit DECstation config with this driver
3. Important issue? **PASS** — build error, listed in this tree’s stable-kernel-rules
4. Small and contained? **PASS** — 2 lines, one header
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — identical context, prerequisite macro already present
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Build fix** — qualifies under the documented exception / “build error” clause.
**Step 9.4: MAKE YOUR DECISION**
Backport. The bug exists here, the fix is the standard MIPS portable mapping, and the stable rules call out build errors. Niche hardware does not outweigh a zero-risk compile fix that applies cleanly.
---
### What the commit solves for this tree
On 6.12, include/video/maxinefb.h still maps IMS332 MMIO and onboard FB memory with KSEG1ADDR(). That macro is compiled out for CONFIG_64BIT, while FB_MAXINE can still be enabled on MACH_DECSTATION 64-bit kernels. The result is an implicit-declaration error and a 32-vs-64 pointer-cast warning. CKSEG1ADDR() is already the 32/64-safe helper used elsewhere on DECstation.
### Stable-rules fit
Obviously correct, two lines, no new API, no prerequisites missing in 6.12, not CONFIG_BROKEN.
### Risk vs benefit
Benefit is restoring a previously impossible 64-bit DECstation+maxinefb build. Risk on 32-bit Maxine (the real hardware) is nil because the macros match.
### Concerns
None that block backport: series mates 01/02 are not required; header matches; CKSEG1ADDR exists.
---
Verification:
- [Phase 1] Parsed subject/tags/body: fix 64-bit build; SOB Randy Dunlap, Ack Maciej, SOB Helge Deller; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: two KSEG1ADDR → CKSEG1ADDR in include/video/maxinefb.h
- [Phase 2] addrspace.h: KSEG1ADDR only in #else of CONFIG_64BIT; CKSEG1ADDR in both; 32-bit expansions identical
- [Phase 3] git blame include/video/maxinefb.h: lines from 1da177e4c3f41 (2.6.12-rc2)
- [Phase 3] git merge-base --is-ancestor 1da177e4c3f41 HEAD: yes
- [Phase 3] git log --oneline -- include/video/maxinefb.h: only genesis; no later equivalent fix
- [Phase 3] No Fixes: tag to follow
- [Phase 4] Cover + 03/03 on lists.openwall.net (2026-08-13); Maciej Ack on lkml.indiana.edu 2608.2/02341
- [Phase 4] Helge GIT PULL lists this under Fixes for v7.3-rc1
- [Phase 4] b4 dig: no local commit (candidate not in tree); lore.kernel.org 403
- [Phase 5] Macros only used from maxinefb.c; FB_MAXINE depends on MACH_DECSTATION only
- [Phase 5] MACH_DECSTATION selects SYS_SUPPORTS_64BIT_KERNEL; CPU_R4X00 selects CPU_SUPPORTS_64BIT_KERNEL
- [Phase 6] git describe HEAD = p-6.12-3-gc504cf0baa3d8; make kernelversion = 6.12.111
- [Phase 6] Local file still has KSEG1ADDR; patch context matches
- [Phase 7] Peripheral fbdev driver, not staging
- [Phase 8] Failure: compile error; this tree’s stable-kernel-rules.rst line 19 includes “a build error”
- [Phase 8] CONFIG_WERROR defaults to COMPILE_TEST; implicit declaration is still a GCC error without it
- UNVERIFIED: exact upstream SHA; stable@ archives (lore 403); whether anyone already requested this for 6.12.y
**YES**
include/video/maxinefb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/video/maxinefb.h +2 -2
@@ -13,13 +13,13 @@/* * IMS332 video controller register base address */ -#define MAXINEFB_IMS332_ADDRESS KSEG1ADDR(0x1c140000) +#define MAXINEFB_IMS332_ADDRESS CKSEG1ADDR(0x1c140000)/* * Begin of DECstation 5000/xx onboard framebuffer memory, default resolution * is 1024x768x8 */ -#define DS5000_xx_ONBOARD_FBMEM_START KSEG1ADDR(0x0a000000) +#define DS5000_xx_ONBOARD_FBMEM_START CKSEG1ADDR(0x0a000000)/* * The IMS 332 video controller used in the DECstation 5000/xx series
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 drm/msm: Move nr_cmds initialization
In reply to Sasha LevinFrom: Rob Clark <[email protected]>
[ Upstream commit 9ee2884ed58e6b39da35732146446d5930e4746b ]
Previously if we entered an error path between these two points, we could leak the relocs tables due to submit->nr_cmds still being zero.
In practice, relocs are disallowed on a6xx+, and non-ancient userspace will not use relocs on earlier gens unless running on an ancient kernel. But userspace could use this to trigger a memory leak.
Patchwork: https://patchwork.freedesktop.org/patch/743085/
Message-ID: <[email protected]>
---
LLM Generated explanations, may be completely bogus:
The local checkout is mainline **v7.3-rc4**. The change is a real, user- triggerable reloc-table leak in MSM_GEM_SUBMIT; it is small, correct, and belongs in this tree.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[drm/msm] [Move] [initialize submit->nr_cmds earlier so error-path cleanup can free reloc tables]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Reported-by: Sashiko <[email protected]> — static-analysis bot, not syzbot
- Signed-off-by: Rob Clark <[email protected]> — msm maintainer / author (ignore any pipeline SOB)
- Patchwork: https://patchwork.freedesktop.org/patch/743085/
- Message-ID: <[email protected]> — v7 series, this is patch 5/17 (msgid -6 because -1 is the cover)
- No Fixes: tag (expected)
- No Cc: stable (expected)
- No Tested-by / Reviewed-by / Acked-by on the committed message
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** If submit hits an error between reloc kmalloc in submit_lookup_cmds() and the late submit->nr_cmds = args->nr_cmds, destroy walks nr_cmds == 0 and skips kfree(relocs).
- **Symptom:** Kernel memory leak; userspace can trigger it via DRM_IOCTL_MSM_GEM_SUBMIT.
- **Author’s caveat:** Relocs are disallowed on a6xx+; modern userspace does not use them on older gens. The author still states userspace can force the leak.
- **Version info:** None in the message. Introduced with reloc buffering in v5.11-rc1.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. It is an explicit error-path resource-leak fix (delayed counter vs allocated objects).
===============================================================
PHASE 2: DIFF ANALYSIS
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/gpu/drm/msm/msm_gem_submit.c (+3 / −2)
- Functions: submit_lookup_cmds(), msm_ioctl_gem_submit()
- Scope: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** submit_lookup_cmds() kmallocs cmd[i].relocs then copy_from_user. nr_cmds stays 0 (kzalloc) until after pin/reloc parsing, then submit->nr_cmds = args->nr_cmds. Any goto out in between skips that store. __msm_gem_submit_destroy() only frees i < nr_cmds.
- **After:** submit->nr_cmds = i + 1 immediately after a successful kmalloc, before copy_from_user. The late assignment is removed. Failed kmalloc does not bump the counter.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** error-path resource leak (ioctl-reachable, repeatable)
- **Mechanism:** counter used as the free loop bound is updated after the allocations. Verified destroy path:
```121:122:drivers/gpu/drm/msm/msm_gem_submit.c
for (i = 0; i < submit->nr_cmds; i++)
kfree(submit->cmd[i].relocs);
```allow_relocs is false on a6xx+ (adreno_gpu.c: gpu->allow_relocs = family < ADRENO_6XX_GEN1), but that check runs **after** lookup allocates. Userspace with nr_relocs > 0 allocates, then hits EINVAL “relocs not allowed” and (before this fix) leaked.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: free bound tracks allocated slots.
- Minimal; no API/data-structure change.
- Regression risk is low. Mid-ioctl code uses args->nr_cmds / cmds_to_parse, not submit->nr_cmds. msm_job_run() / GPU submit run only after a successful job push, when nr_cmds already equaled args->nr_cmds.
- Failed kmalloc still does not increment, so a NULL slot is not kfreed.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Reloc kmalloc + destroy kfree loop: 20224d715a882 (“drm/msm/submit: Move copy_from_user ahead of locking bos”), **2020-10-23**, in **v5.11-rc1** (git merge-base --is-ancestor vs v5.10 failed, vs v5.11-rc1 succeeded).
- Late submit->nr_cmds = args->nr_cmds: 2e6a8a1fe2b262 (“drm/msm:
Add VM_BIND ioctl”, 2025-06-29). Before that it was submit->nr_cmds = i **after** the parse loop; goto out inside that loop still skipped the store. The leak is older than VM_BIND.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Buggy pattern starts at 20224d715a882 (v5.11). That commit is an ancestor of this tree.
**Step 3.3: CHECK FILE HISTORY**
Record:
- Same-day series: 0369a2619c50b SIZE_MAX cleanup, 7aeada642ebfd overflow check — independent, not required for this leak fix.
- Related but different: ad70e46e130a7 submit error-path unpin order.
- Standalone for the leak; bundled as v7 05/17 “lazy-vm fixes” for convenience.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Rob Clark is the msm GEM/submit maintainer. Nearby work is other submit/VM fixes in the same series.
**Step 3.5: DEPENDENT/PREREQUISITE COMMITS**
Record: None for this hunk. It only moves an existing store. Applies standalone on this tree (already applied as 9ee2884ed58e6).
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 9ee2884ed58e6: https://patch.msgid.link/20260729155609.201
[email protected]
- [PATCH v7 05/17] drm/msm: Move nr_cmds initialization
- Cover: [PATCH v7 00/17] drm/msm: A couple lazy-vm fixes
- Revisions v1–v7 of a growing msm series; this leak fix is in v7. Applied version is latest.
- Lore HTTP fetch returned 403; full thread read from b4 dig -m mbox.
- Sashiko reply on this patch: only **pre-existing** issues (SIZE_MAX in submit_create, lazy ctx->vm NULL). No NAK of the nr_cmds move. Those other bugs are other patches in the same series.
- No reviewer Cc: stable in the thread.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To dri-devel; Cc linux-arm-msm, freedreno, Sashiko, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten, David Airlie, Simona Vetter. Subsystem maintainers were on the original mail. No human Reviewed-by on the git commit.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: Reporter is Sashiko (automated). No syzbot/bugzilla. Author independently describes a userspace-triggerable leak. That description matches the code.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 17-patch lazy-VM series. This patch does not need 01–04 (ctxlock/queuelock) or 06+ (SIZE_MAX / VM helpers). Standalone leak fix.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: Web search of lore.kernel.org/stable for this subject found no relevant thread.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: KEY FUNCTIONS**
Record: submit_lookup_cmds, msm_ioctl_gem_submit; cleanup via __msm_gem_submit_destroy.
**Step 5.2: TRACE CALLERS**
Record:
- msm_ioctl_gem_submit registered with DRM_RENDER_ALLOW in msm_drv.c (DRM_IOCTL_MSM_GEM_SUBMIT).
- Reachable from render-node ioctl; not irq, not module init.
**Step 5.3: TRACE CALLEES**
Record: kmalloc, copy_from_user, later submit_reloc / allow_relocs check. Destroy: kfree(relocs) gated by nr_cmds.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: userspace ioctl → drm_ioctl → msm_ioctl_gem_submit → submit_lookup_cmds → error goto out → submit_cleanup → msm_gem_submit_put → __msm_gem_submit_destroy. Unprivileged GPU clients (render node) can trigger it.
**Step 5.5: SIMILAR PATTERNS**
Record: submit_lookup_objects() already does submit->nr_bos = i on the way out so partial BO lookups are cleaned. Cmds did not have the analogous update. No sibling drivers with the same bug in this file.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes, in this lineage. git describe HEAD = v7.3-rc4-27-gf0100363d8c37, make kernelversion = 7.3.0-rc4. Parent of 9ee2884ed58e6 still has the late assignment and zero nr_cmds during lookup. Bug present since v5.11; this fix is already an ancestor of HEAD (git merge-base --is-ancestor 9ee2884ed58e6 HEAD succeeded). Decision is still whether the fix has technical merit for this tree, not whether a pipeline tag exists.
**Step 6.2: BACKPORT COMPLICATIONS**
Record: On this tree the hunk matches current msm_gem_submit.c (VM_BIND-era args->nr_cmds store). Clean apply. (Older pre-VM_BIND trees would delete submit->nr_cmds = i instead; that is not this checkout.)
**Step 6.3: RELATED FIXES ALREADY HERE**
Record: No earlier equivalent. Follow-ups 0369a2619c50b / 7aeada642ebfd are overflow cleanups, not another leak fix.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: **drm/msm GEM submit**. **IMPORTANT** (Qualcomm Adreno; Android phones and Snapdragon laptops). Not mm/core, but a common production GPU driver.
**Step 7.2: SUBSYSTEM ACTIVITY**
Record: Actively developed (VM_BIND, lazy VM, submit locking). Submit ioctl itself is old and long-lived.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: WHO IS AFFECTED**
Record: Driver-specific (CONFIG_DRM_MSM). Anyone who can open the msm render node.
**Step 8.2: TRIGGER CONDITIONS**
Record:
- Normal submits with nr_relocs == 0: kmalloc(0) is not a real leak.
- Trigger: nr_relocs > 0, then any error after allocation (bad copy, lock fail, invalid cmd size, **relocs not allowed on a6xx+**).
- Easy on modern Adreno: pass nonzero relocs; kernel allocates then rejects.
- Unprivileged with render-node access. Repeatable; size chosen by userspace.
**Step 8.3: FAILURE MODE SEVERITY**
Record: Kernel memory leak in a hot ioctl, unbounded. **HIGH** (DoS / memory exhaustion). Not panic/UAF/corruption.
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit:** Stops a userspace-triggerable leak on a widely used GPU ioctl. High for msm users.
- **Risk:** Very low (3 insertions, 2 deletions; error/cleanup accounting only).
- **Ratio:** Strongly favors applying.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real leak: destroy uses nr_cmds as the free count; that count was updated too late.
- User-triggerable via DRM_IOCTL_MSM_GEM_SUBMIT (DRM_RENDER_ALLOW).
- On a6xx+ the “relocs not allowed” path is after allocation, so modern hardware is included.
- Present since v5.11; still the same mechanism here until this commit.
- 5-line, obviously correct; msm maintainer authored it.
- Matches the common stable class of ioctl error-path leaks.
AGAINST:
- Not a crash/UAF; “only” a leak.
- Honest userspace rarely uses relocs on current gens.
- Found by Sashiko, not a user oops/syzbot.
- Shipped in a 17-patch series (but this patch is independent).
- No Fixes: / Cc: stable (not a negative per the rules).
UNRESOLVED:
- Lore.kernel.org HTTP 403; discussion recovered via b4 dig -m.
- Patchwork HTML was a bot-check page.
- No stable-list thread found.
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — maintains allocated-vs-freed invariant; maintainer-authored; in mainline since v7.3-rc1.
2. Fixes a real bug that affects users? **PASS** — ioctl-reachable leak.
3. Important (crash/security/corruption/deadlock)? **PASS** at HIGH — repeatable kernel memory leak / DoS, not CRITICAL crash.
4. Small and contained? **PASS** — +3/−2, one file.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — already the code in this checkout.
**Step 9.3: EXCEPTION CATEGORIES**
Record: None (not an ID/quirk/DT/build/doc exception). It qualifies as a normal leak fix.
**Step 9.4: DECISION**
This is a small, correct fix for a long-standing, userspace-triggerable kernel memory leak in msm GEM submit. It meets stable rules for this tree. Risk is negligible versus the DoS benefit.
------------------------------------------------
What the commit solves for this tree
------------------------------------------------submit_lookup_cmds() allocated per-cmd reloc arrays while submit->nr_cmds stayed 0 until much later in msm_ioctl_gem_submit(). Destroy only frees cmd[0..nr_cmds). Any error in that window leaked those allocations. Moving nr_cmds = i + 1 to right after kmalloc makes cleanup free what was allocated, including the common a6xx+ “relocs not allowed” failure.
------------------------------------------------
Verification
------------------------------------------------
- [Phase 1] Parsed tags: Sashiko Reported-by; Rob Clark SOB; Patchwork 743085; msgid 20190-6; no Fixes/Cc-stable
- [Phase 2] Diff: +3/−2 in msm_gem_submit.c; nr_cmds = i+1 after kmalloc; removed late nr_cmds = args->nr_cmds
- [Phase 2] Destroy loop confirmed at lines 121–122; allow_relocs set false for a6xx+ at adreno_gpu.c:1209; check is after lookup
- [Phase 3] git blame on parent: reloc alloc from 20224d715a882 (v5.11-rc1); late assign from VM_BIND 2e6a8a1fe2b262
- [Phase 3] git merge-base --is-ancestor 20224d715a882 v5.11-rc1 yes; vs v5.10 no
- [Phase 3] No Fixes: tag to follow
- [Phase 4] b4 dig -c 9ee2884ed58e6: lore msgid.link 20260729155609.20190-6; v7 05/17
- [Phase 4] b4 dig -a: v1–v7 series; applied = v7
- [Phase 4] b4 dig -w: dri-devel + msm maintainers CC’d
- [Phase 4] mbox: Sashiko comments were pre-existing issues, not a NAK of this change; no stable nomination
- [Phase 4] lore WebFetch 403; patchwork served bot-check; stable search found nothing relevant
- [Phase 5] Caller: DRM_IOCTL_DEF_DRV(..., DRM_RENDER_ALLOW) in msm_drv.c:804
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- [Phase 6] git merge-base --is-ancestor 9ee2884ed58e6 HEAD succeeded; parent still has the leak
- [Phase 8] Failure mode: ioctl-triggered kmalloc leak, severity HIGH
- UNVERIFIED: live lore.kernel.org HTML (403); patchwork page body; whether any human mailing-list Reviewed-by was dropped on commit
**YES**
drivers/gpu/drm/msm/msm_gem_submit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/msm_gem_submit.c +3 -2
@@ -260,6 +260,9 @@ static int submit_lookup_cmds(struct msm_gem_submit *submit, ret = -ENOMEM ; goto out; } + + submit->nr_cmds = i +1 ; + ret =copy_from_user (submit->cmd[i].relocs, userptr, sz);if (ret) { ret = -EFAULT ;
@@ -717,8 +720,6 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, goto out; } - submit->nr_cmds = args->nr_cmds; -idr_preload (GFP_KERNEL );spin_lock (&queue->idr_lock);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/conexant: Always enable the headset-mic pin on plugin
In reply to Sasha LevinFrom: Bob Song <[email protected]>
[ Upstream commit 9642a5e843758686e02a7f0d1df9eb0f7f96603c ]
Rename the function to cx_process_headset_detect_plug_type() to reflect that it only reports the detected plug type, and move the pin control write into cx_update_headset_mic_vref() so that node 0x19 is always set to enable the headset mic with the 80% VREF whenever the mic is present, regardless of the type detection result.
---
LLM Generated explanations, may be completely bogus:
Local tree is **6.12.111** (pending-6.12). The Conexant headset-mic VREF logic is present here; the commit is a small hardware fix for silent 3-pole mics on CX11880/SN6140.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ALSA: hda/conexant] [Always enable] [Always write PIN_WIDGET_CONTROL 0x24 on node 0x19 when a headset mic is present, not only when CTIA/OMTP type-detect succeeds]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Link: https://patch.msgid.link/20260826115344.2128835-1-
[email protected]
- Signed-off-by: Bob Song \<[email protected]\> (author)
- Signed-off-by: Takashi Iwai \<[email protected]\> (ALSA maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Cc:
stable (absence is expected)
- Ignore pipeline SOBs / Upstream markers
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
The v3 body is thin: rename cx_process_headset_plugin() to cx_process_headset_detect_plug_type(), and move the pin-control write so node 0x19 is always set to 0x24 when a mic is present.
The v1 body (same series) is the actual bug statement: *“For 3-pole headset microphones, the mic pin VREF must always be configured to 0x24 regardless of the headset type, otherwise the mic will not be able to record audio.”*
Record: [Bug: 3-pole mics that assert pin 0x19 presence but are not classified as CTIA/OMTP never get VREF 80%] [Symptom: headset mic cannot record] [Root cause: 0x24 write gated on type-detect bits] [No version info in the message]
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: [Yes — v3 is written as a rename/move, but it is a functional fix. Type detection becomes debug-only; the missing 0x24 write for the 3-pole/fallback case is the real change.]
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record: [1 file: sound/hda/codecs/conexant.c on mainline (~+6/-4).
Functions: cx_process_headset_plugin renamed; cx_update_headset_mic_vref changed. Surgical, single-file.]
In **this** 6.12 tree the same code lives in sound/pci/hda/patch_conexant.c (file not yet moved).
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE** Before (this tree, cx_update_headset_mic_vref):
- Pin 0x19 presence clear → write 0x20 (IN_EN, VREF off)
- Presence set → cx_process_headset_plugin():
- CTIA (val & 0x800) or OMTP (val & 0x400) → write 0x24
- else log “headphone plugin” and **do not** write 0x24
After:
- Presence clear → write 0x20 (unchanged)
- Presence set → still wait/log type, **then always write 0x24**
Record: [Plugin path: VREF 80% only for CTIA/OMTP → VREF 80% whenever pin 0x19 reports presence]
**Step 2.3: IDENTIFY THE BUG MECHANISM**0x24 = AC_PINCTL_IN_EN (0x20) | AC_PINCTL_VREF_80 (0x04) (include/sound/hda_verbs.h). 0x20 is input enable without bias.
The jack callback only runs after pin 0x19 presence. 4-pole CTIA/OMTP already got bias. 3-pole mics (and any detect timeout/misclassify into the else branch) did not, so the mic had no bias.
This is a **hardware workaround / logic correctness** fix, not UAF/leak/race.
Record: [Category: hardware workaround + logic] [Broken: 3-pole mic recording] [Fix: always enable VREF 80% when mic present]
**Step 2.4: ASSESS THE FIX QUALITY**
Obviously correct: init already does the same in cx_fixup_headset_recog() (presence → 0x24, else 0x20). The plugin path is being made consistent with that.
Regression risk is low: headphone-only plugs should not assert nid 0x19 presence (node 19 is mic-only per comments; Takashi raised this, author confirmed presence is checked first). Inner 0x24 write in the renamed function remains in v3 (redundant with the caller write); harmless.
Record: [Quality: small, correct, matches init path] [Risk: low; redundant inner write only]
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: [Introduced by 7aeb2590864874 (“ALSA: hda/conexant: Fix headset auto detect fail in cx8070 and SN6140”), 2024-01-08. Jack callback wiring later adjusted by e60dc981221105 (same author, 2024-07-26). Present since ~v6.8, well before 6.12.]
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: [No Fixes: tag. Introducing commit 7aeb259 is an ancestor of HEAD. Original intent of 7aeb259 was already “enable VREF when headset is present”; implementation gated it on CTIA/OMTP.]
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: [Related in this tree: e60dc981 (polling-mode detect), 86c11d5091e11 (remove mic-bias threshold override, Cc:stable, Fixes:
7aeb259), dd110cc00cf85 (jack-detect error check). Standalone fix; not patch X/Y.]
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: [Bob Song/songxiebing already authored e60dc981 on this exact callback. Kylin/Senarytech people maintain this CX11880/SN6140 quirk. Not the ALSA maintainer; Takashi applied it.]
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: [No missing helpers. v2 also merged CTIA/OMTP into val & 0xc00; that cleanup is **not** in 6.12 (git log -S 'val & 0xc00' -- sound/pci/hda/patch_conexant.c empty). Not required: the caller-side always-write is the fix. Applies standalone with a path/context tweak.]
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**b4 mbox on msgid [email protected]:
11-message thread.
- v1: “Set mic pin VREF to 0x24 on headset mic plug” — 3-pole mics cannot record
- Takashi: fallback was meant to be headphone-only; don’t enable mic there
- Author: nid 0x19 is the mic pin; callback already requires presence; 4-pole = CTIA/OMTP; 3-pole mic was the unhandled case
- Takashi: then type-detect is only debug; move the write to the caller and rename
- v2: that refactor + CTIA/OMTP merge; Takashi: doesn’t apply on latest (cleanup already landed)
- v3: rebase; Takashi: “Applied now. Thanks.”
- Landed in sound fixes for 7.3-rc1 as “Conexant headset plugin fixes”
Record: [Lore/msgid as above] [v1→v3] [No NAKs after explanation] [No
Cc: stable from reviewers] [Applied by maintainer]
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: [To: [email protected], [email protected]; Cc: linux-sound, linux- kernel. Reviewed in-thread by Takashi Iwai.]
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: [No syzbot/bugzilla. Author (Kylin) described 3-pole mic recording failure. Not a fuzzer crash.]
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: [Single patch, three revisions. v2’s 0xc00 merge is independent cleanup already on later mainline; 6.12 does not need it.]
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: [lore.kernel.org/stable fetch returned 403. No stable discussion in the sound thread. UNVERIFIED whether AUTOSEL already queued it.]
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: [cx_process_headset_plugin / rename;cx_update_headset_mic_vref]
**Step 5.2: TRACE CALLERS**
Record: [cx_update_headset_mic_vref registered only in patch_conexant_auto() for vendor IDs 0x14f11f86 (CX11880) and 0x14f11f87 (SN6140) via snd_hda_jack_detect_enable_callback(). Called from HDA jack unsol/poll (hda_jack.c call_jack_callback).]
**Step 5.3: TRACE CALLEES**
Record: [snd_hda_codec_read/write, msleep (up to 60 ms wait for type detect). Process context, already sleeping.]
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: [Reachable from userspace by plugging a headset on those codecs. Not a syscall crash path; common laptop jack path.]
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: [cx_fixup_headset_recog() already writes 0x24/0x20 from presence alone at init. Plugin path was the inconsistent copy.]
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: [Yes. sound/pci/hda/patch_conexant.c lines 216–256. 7aeb2590864874 and e60dc981221105 are ancestors of HEAD. Rename not present. Bug introduced 2024-01, in 6.12.]
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: [Minor: path sound/pci/hda/patch_conexant.c vs mainline sound/hda/codecs/conexant.c; 6.12 still has separate CTIA/OMTP branches instead of val & 0xc00. Semantic backport is a few lines in cx_update_headset_mic_vref. No API/struct dependency.]
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: [86c11d5091e11 and dd110cc00cf85 are related but different bugs. This always-enable-0x24 change is not in the tree.]
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: [ALSA HD-audio Conexant codec. IMPORTANT for users of those laptops; PERIPHERAL vs core mm/net. Config: SND_HDA_CODEC_CONEXANT.]
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: [Active quirk stream on this file (Lenovo pin cfg, mic-bias override, jack-detect error check). Mature driver, recent hardware- specific fixes.]
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: [Driver-specific: CX11880/SN6140 (0x14f11f86/0x14f11f87), typically laptop combo jacks.]
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: [Plug a 3-pole mic / headset that is not classified as CTIA/OMTP, or type-detect timeout (3×20 ms). Unprivileged user, physical jack. Common for those machines.]
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: [Headset microphone does not record. Not oops/deadlock/corruption. Severity: MEDIUM, user-visible audio breakage.]
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record: [Benefit: high for affected hardware (mic works). Risk: very low (few lines, same verb already used on the CTIA/OMTP path and at init).
Ratio: favorable.]
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real bug: 3-pole headset mics get no VREF 80%, so recording fails
- Same intent as 7aeb259, which is already in this tree and was AUTOSEL’d historically
- Matches cx_fixup_headset_recog() init behavior
- Small, obviously correct; maintainer reviewed and applied
- Hardware quirk class, routinely backported
- Sibling conexant headset fixes already in 6.12 (including Cc:stable mic-bias override)
AGAINST:
- Not crash/security/corruption
- Codec-specific
- v3 message dropped the 3-pole explanation; includes a rename
- v3 leaves a redundant inner 0x24 write
- Needs a trivial path/context adjustment
UNRESOLVED:
- Whether stable@ already discussed it (lore/stable 403)
- How many 6.12 systems ship CX11880/SN6140 (not quantified)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — maintainer applied; logic matches init path
2. Fixes a real bug that affects users? **PASS** — 3-pole mic cannot record
3. Important issue? **PASS** — broken recording on combo jack (hardware quirk; not a panic)
4. Small and contained? **PASS** — ~one function, few lines
5. No new features or APIs? **PASS** — pin-control write already used
6. Can apply to the local tree? **PASS** — buggy code present; minor path/context tweak
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: [Hardware quirk/workaround for Conexant combo-jack VREF. Qualifies.]
**Step 9.4: MAKE YOUR DECISION**
This belongs in 6.12. The bug is in this tree, the fix is surgical, and stable users with CX11880/SN6140 otherwise keep a dead headset mic on 3-pole plugs.
What it solves: on plugin, pin 0x19 presence no longer depends on CTIA/OMTP bits to get VREF 80% (0x24). That is required for 3-pole mics to record.
Risk vs benefit: benefit is working capture on those jacks; risk is a redundant codec verb write already used on the success path.
Concerns: backport to sound/pci/hda/patch_conexant.c and leave the existing CTIA/OMTP inner writes (or drop them; either is equivalent once the caller always writes 0x24).
Verification:
- [Phase 1] Parsed tags: Link msgid, SOB Bob Song + Takashi Iwai; no Fixes/Reported-by/Cc:stable
- [Phase 1] v1 on openwall/lkml: 3-pole mics cannot record without 0x24
- [Phase 2] Diff: rename + always-write 0x24 in cx_update_headset_mic_vref; inner CTIA/OMTP write kept in v3
- [Phase 2] 0x24/0x20 verified as IN_EN|VREF_80 vs IN_EN in include/sound/hda_verbs.h
- [Phase 3] blame: 7aeb2590864874 (2024-01-08); e60dc981221105 later; both ancestors of HEAD
- [Phase 3] git merge-base --is-ancestor 7aeb2590864874 HEAD true; same for e60dc981
- [Phase 3] git log -S 'val & 0xc00' -- sound/pci/hda/patch_conexant.c empty (no 0xc00 merge here)
- [Phase 4] b4 mbox 11-message thread; Takashi applied v3; no NAK after 3-pole explanation
- [Phase 4] lore.kernel.org/stable: 403, UNVERIFIED
- [Phase 5] only callers: patch_conexant_auto for 0x14f11f86/0x14f11f87 → jack callback
- [Phase 5] cx_fixup_headset_recog already presence→0x24 at init (lines 167–183)
- [Phase 6] git describe HEAD → p-6.12-3-gc504cf0baa3d8; make kernelversion → 6.12.111
- [Phase 6] buggy functions still named cx_process_headset_plugin / cx_update_headset_mic_vref in sound/pci/hda/patch_conexant.c
- [Phase 8] Failure mode: silent headset mic, severity MEDIUM, hardware- specific
**YES**
sound/hda/codecs/conexant.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
sound/hda/codecs/conexant.c +6 -4
@@ -213,7 +213,7 @@ static void cx_remove(struct hda_codec *codec)snd_hda_gen_remove (codec); } -static void cx_process_headset_plugin (struct hda_codec *codec) +static void cx_process_headset_detect_plug_type (struct hda_codec *codec) {unsigned int val;unsigned int count =0 ;
@@ -249,10 +249,12 @@ static void cx_update_headset_mic_vref(struct hda_codec *codec, struct hda_jack_* Check hp&mic tag to process headset plugin & plugout. */ mic_present =snd_hda_codec_read (codec,0x19 ,0 ,AC_VERB_GET_PIN_SENSE ,0x0 ); -if (!(mic_present &AC_PINSENSE_PRESENCE ))/* mic plugout */ +if (!(mic_present &AC_PINSENSE_PRESENCE )) {/* mic plugout */ snd_hda_codec_write (codec,0x19 ,0 ,AC_VERB_SET_PIN_WIDGET_CONTROL ,0x20 ); -else -cx_process_headset_plugin (codec); + }else { +cx_process_headset_detect_plug_type (codec); +snd_hda_codec_write (codec,0x19 ,0 ,AC_VERB_SET_PIN_WIDGET_CONTROL ,0x24 ); + } }static int cx_suspend (struct hda_codec *codec)
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 iio: accel: fxls8962af: clamp the device-reported FIFO sample count
In reply to Sasha LevinFrom: Bryam Vargas <[email protected]>
[ Upstream commit 2f8225b91eb478ca2e9aec8aaef4d229765bcebe ]
fxls8962af_fifo_flush() transfers the sample count the device reports in BUF_STATUS into an on-stack buffer sized for FXLS8962AF_FIFO_LENGTH (32) samples, but the count is a 6-bit field (0..63) that is only checked for zero. A device, or an attacker on the I2C/SPI bus, reporting 33..63 overflows the buffer by up to 186 bytes: a stack out-of-bounds write.
Clamp the count to FXLS8962AF_FIFO_LENGTH before the transfer, mirroring the clamp already applied in fxls8962af_set_watermark(). Conforming hardware reports at most that many samples and is unaffected.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.18.53**. The FIFO clamp is not in v6.18.53; the 32-sample stack buffer and 6-bit BUF_CNT path have been here since v5.14. That is a real stack out-of-bounds write, so this is a YES on technical merit.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[iio/accel/fxls8962af] [clamp] [bound device-reported FIFO sample count before stack transfer]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Reviewed-by:** Andy Shevchenko <[email protected]>
- **Signed-off-by:** Bryam Vargas <[email protected]> (author)
- **Signed-off-by:** Jonathan Cameron <[email protected]> (IIO maintainer)
- No **Fixes:**, **Cc: stable**, **Reported-by**, **Tested-by**, or **Link:** on the committed message (v1 had Fixes/Cc: stable; they were dropped after review)
- Ignore pipeline markers: [ Upstream commit 2f8225b91eb478ca2e9aec8aaef4d229765bcebe ], Sasha Levin SOB
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** fxls8962af_fifo_flush() copies BUF_STATUS BUF_CNT (GENMASK(5,0), 0..63) into u16 buffer[FXLS8962AF_FIFO_LENGTH * 3] (32 samples). Count is only checked for zero.
- **Symptom:** stack out-of-bounds write of up to 186 bytes (63×6=378 into 192-byte buffer), canary/return-address smash.
- **Root cause:** driver trusts a 6-bit device field against a 32-deep FIFO buffer. Watermark path already clamps; flush path does not.
- **Version:** unbounded since 79e3a5bdd9ef (“add hw buffered sampling”), 2021.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. It is a bounds-check / memory-safety fix. Review treated it as hardening against malformed device reports rather than a conforming-hardware bug.
===============================================================
PHASE 2: DIFF ANALYSIS
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/iio/accel/fxls8962af-core.c (+2 / −0)
- Function: fxls8962af_fifo_flush()
- Scope: single-file, two-line surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: After count = reg & FXLS8962AF_BUF_STATUS_BUF_CNT and the if (!count) return 0 check, add count = min(count, FXLS8962AF_FIFO_LENGTH) before timestamp math and fxls8962af_fifo_transfer(data, buffer, count). Normal path with count ≤ 32 is unchanged. Path with count 33..63 is capped at 32 instead of overflowing the stack buffer.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Buffer overflow / out-of-bounds write.** Device-reported length used as transfer size without clamping to the on-stack array. Fix is a bounds clamp (memory-safety / hardware-value validation).
Verified math:
- u16 buffer[32 * 3] → 192 bytes
- fxls8962af_fifo_transfer() reads count * 3 * sizeof(u16) = `count
* 6` bytes
- count=32 → 192 (fits); count=33 → 198 (6 past); count=63 → 378 (**186 past**), matching the message
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct and minimal. min() is valid here: count is u8, FXLS8962AF_FIFO_LENGTH is 32; this tree’s minmax.h promotes unsigned char to signed int. Regression risk is very low: conforming devices report ≤32. Clamping a wild count to 32 can leave unread FIFO data rather than crashing; that is safer than a stack smash. Maintainer later preferred dev_err + abort over a silent clamp, but the clamp still prevents the overflow.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: FIFO flush, stack buffer, and unclamped BUF_CNT came from **79e3a5bdd9ef** (Sean Nyekjaer, 2021-05-17), “iio: accel: fxls8962af:
add hw buffered sampling”. First appeared around **v5.14**. Long-lived in this tree.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes tag on the committed version. v1 tagged 79e3a5bdd9ef. That commit **is** an ancestor of HEAD and of v6.18.53.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Related: 1fe16dc1a2f50 (“Fix use after free in fxls8962af_fifo_flush”, CVE-2025-38485) — synchronize_irq() on predisable, **already in v6.18.53**. Different bug; does not bound FIFO count. Sibling **3e766526827ac** (bmc150 FIFO clamp) **is already in v6.18.53** with Cc: stable. This patch is standalone, not patch N/M.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Bryam Vargas is not the IIO maintainer. Same author submitted the bmc150 clamp (already in this tree). Driver author/regular is Sean Nyekjaer (CC’d). Applied by Jonathan Cameron.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Uses existing min(), FXLS8962AF_FIFO_LENGTH, and fxls8962af_fifo_flush(). Applies standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **v1:** https://lore.kernel.org/all/20260613-b4-disp-22362900-v1-1-
[email protected]/ (had Fixes + Cc: stable, used min_t(u8, ...))
- **v2:** https://lore.kernel.org/all/20260615-b4-disp-1a8c7886-v2-1-
[email protected]/
- **v3 (applied):** https://lore.kernel.org/all/20260616-b4-disp-
[email protected]/
- Jonathan on v1: *“This is hardening against broken devices. Nice to have, but not a fix and not back port material.”* Also asked for min() instead of min_t.
- Andy: shrink the AI-heavy commit message.
- Author dropped Fixes/Cc: stable for v2/v3. Andy **Reviewed-by** on v3. Jonathan applied to iio.git testing.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: To/Cc included Jonathan Cameron (maintainer), Andy Shevchenko, David Lechner, Nuno Sá, Sean Nyekjaer, linux-iio, linux-kernel. Maintainer applied it; Andy reviewed it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla/user crash. Author reproduced with a KASAN_STACK litmus (count=36 → write of size 216 past the 192-byte buffer) and a userspace ASan model (count=63). Not a field report.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Parallel bmc150 clamp (ce0e1cae2609 / 3e766526827ac in this tree) with Fixes + Cc: stable. Same author, same week. Jonathan agreed with that analysis and only nitted min() vs min_t.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: Duplicate sent to stable@ in Aug 2026 (Shengzhuo Wei). Jonathan:
not a fix, don’t hide it by clamping. After learning Bryam’s patch was already in mainline: *“Oops… didn’t think of it in the same way… not worth more churn for something we don’t really expect to see in practice.”* He did not NAK backporting Bryam’s already-merged clamp; he rejected the duplicate and a follow-up rework.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: KEY FUNCTIONS**
Record: fxls8962af_fifo_flush(); helper fxls8962af_fifo_transfer().
**Step 5.2: TRACE CALLERS**
Record: Only caller is fxls8962af_interrupt() when FXLS8962AF_INT_STATUS_SRC_BUF is set. IRQ is a threaded oneshot handler (devm_request_threaded_irq(..., NULL, fxls8962af_interrupt, ...)). Runs when the IIO buffer is enabled and the device signals FIFO/watermark.
**Step 5.3: TRACE CALLEES**
Record: regmap_read (BUF_STATUS), iio_get_time_ns, fxls8962af_fifo_transfer → regmap_raw_read (or I2C errata-3 per- sample reads), then iio_push_to_buffers_with_ts.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace enables the IIO buffer → hardware FIFO IRQ → flush. Not a syscall that feeds the count; the count comes from the device over I2C/SPI. Unprivileged userspace cannot set BUF_CNT without controlling the bus or the part.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same bug/fix in bmc150 (__bmc150_accel_fifo_flush). Watermark path already clamps to FXLS8962AF_FIFO_LENGTH. BUF_CNT is only consumed here.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** git describe HEAD → v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion → **6.18.53**. v6.18.53:drivers/iio/accel/fxls8962af-core.c has the 32-sample stack buffer and unclamped BUF_CNT. git merge-base --is-ancestor e25456b3011d9 v6.18.53 is false (candidate only on autosel). Introduced **v5.14** (79e3a5bdd9ef). Driver configs: FXLS8962AF_I2C / FXLS8962AF_SPI.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** git diff v6.18.53 e25456b3011d9^ -- drivers/iio/accel/fxls8962af-core.c is empty. Dry-run of the two-line hunk against the v6.18.53 file succeeded.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: UAF/CVE-2025-38485 fix is in v6.18.53; it does not clamp count. No earlier FIFO-count clamp. bmc150 analog **is** in v6.18.53.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: **IIO accelerometer driver** (drivers/iio/accel/). **PERIPHERAL / IMPORTANT for users of this NXP automotive accel** (FXLS8962AF/64/67/8974). Not core mm/net/fs.
**Step 7.2: SUBSYSTEM ACTIVITY**
Record: Mature driver (2021) with ongoing IIO-wide and device-specific fixes. FIFO flush logic is stable, not newly introduced in 6.18.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: WHO IS AFFECTED**
Record: **Driver-specific / config-specific** (CONFIG_FXLS8962AF_I2C or _SPI), when the IIO buffer is on.
**Step 8.2: TRIGGER CONDITIONS**
Record: FIFO IRQ with BUF_CNT in 33..63 and BUF_OVF clear. Conforming silicon: FIFO depth 32; overflow sets BUF_OVF and the driver returns -EOVERFLOW without transferring. Trigger needs a bad/malicious/counterfeit part, bus tampering, or a corrupted BUF_STATUS read (e.g. I2C bit error on bit 5, which adds 32 to a 1..31 count without setting OVF). Not reachable from syscalls alone. No field reports.
**Step 8.3: FAILURE MODE SEVERITY**
Record: **Stack out-of-bounds write** (up to 186 bytes) in IRQ-thread context → canary smash, oops, or worse. **Severity: HIGH** (CRITICAL if the bus is treated as adversarial). Conforming hardware: not hit.
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit:** stops a kernel stack smash on a wild FIFO count. Same class already shipped in this 6.18.53 tree for bmc150.
- **Risk:** very low (2 lines, min(), no API/locking/structure change; good devices unchanged).
- **Ratio:** high benefit/risk for a memory-safety clamp. Maintainer preference for “error out instead of clamp” is a design nit, not a regression.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real stack OOB: 6-bit count vs 32-sample stack buffer, overflow math verified (186 bytes).
- Bug exists in **this** 6.18.53 tree; driver since v5.14.
- Two-line, obviously correct clamp; min() is type-safe here.
- Applies cleanly; no prerequisites.
- KASAN_STACK reproduction of the overflow.
- Reviewed by Andy Shevchenko; applied by IIO maintainer.
- Identical bmc150 clamp already in v6.18.53.
- IRQ-time path, not dead init code.
AGAINST:
- Jonathan: hardening, *“not a fix and not back port material.”* Author dropped Cc: stable for that reason.
- No user/syzbot reports; needs non-conforming BUF_CNT (OVF already bails out on overflow).
- Later stable@ thread: prefer logging/error over silent clamp; “don’t expect this in practice.”
UNRESOLVED:
- No datasheet fetch here beyond driver comments (FXLS8962AF_FIFO_LENGTH 32, BUF_CNT GENMASK(5,0)). Driver and review agree on those numbers.
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — 2-line min(); KASAN litmus; W=1 clean; maintainer applied.
2. Fixes a real bug that affects users? **PASS** — driver uses an unvalidated 6-bit length as a 32-slot stack transfer size. That is a real memory-safety defect; analog already backported for bmc150 on this tree.
3. Important issue? **PASS** — stack smash / OOB write (HIGH). Not a userspace-only theoretical race; it is a missing bounds check on a device-supplied length.
4. Small and contained? **PASS** — +2 lines, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — v6.18.53 file matches pre- image; dry-run succeeded.
**Step 9.3: EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary memory- safety bounds check.
**Step 9.4: DECISION**
The IIO maintainer did not want this treated as a stable bug because conforming parts should never report >32 without BUF_OVF. That is why
Cc: stable was dropped; that absence is not a reason to reject it. In this 6.18.53 tree the buggy flush is present, the fix is two lines, and the same pattern was already taken for bmc150. A wild BUF_CNT still produces a kernel stack overflow. That is enough technical merit to backport.
Verification:
- [Phase 1] Parsed subject/tags/body from git log -1 e25456b3011d9 and the user-supplied message; Fixes/Cc: stable dropped after v1 review
- [Phase 2] Read fxls8962af_fifo_flush / fxls8962af_fifo_transfer; confirmed 192-byte buffer, count * 6 transfer, 186-byte max overflow
- [Phase 2] Confirmed min(u8, 32) is valid in this tree’s include/linux/minmax.h
- [Phase 3] git blame: buggy FIFO flush from 79e3a5bdd9ef (2021); git merge-base --is-ancestor 79e3a5bdd9ef HEAD true
- [Phase 3] UAF fix 1fe16dc1a2f50 is in v6.18.53; does not clamp count
- [Phase 3] bmc150 clamp 3e766526827ac is in v6.18.53 with Cc: stable
- [Phase 4] b4 dig -c 2f8225b91eb478ca2e9aec8aaef4d229765bcebe → v2/v3 lore; -a showed v3 applied; -w listed IIO maintainers
- [Phase 4] Fetched Jonathan v1 review: “not a fix and not back port material”
- [Phase 4] Fetched v3 apply mail and Andy Reviewed-by
- [Phase 4] lore.kernel.org/stable search: Aug 2026 duplicate; Jonathan restated hardening stance, then dropped rework of Bryam’s already- merged clamp
- [Phase 5] Only caller: fxls8962af_interrupt on BUF status, threaded IRQ
- [Phase 6] make kernelversion / Makefile: 6.18.53; clamp **not** in v6.18.53; git diff v6.18.53 e25456b3011d9^ -- fxls8962af-core.c empty; patch dry-run against v6.18.53 file succeeded
- [Phase 7] Kconfig: FXLS8962AF I2C/SPI, automotive accelerometer
- [Phase 8] Failure mode: stack OOB write in IRQ thread, HIGH
- UNVERIFIED: live NXP datasheet fetch (FIFO=32 / BUF_CNT width taken from in-tree defines and review, which agree)
The patch is a two-line bounds clamp on a stack FIFO flush that exists in this 6.18.53 tree. It prevents a kernel stack out-of-bounds write if BUF_CNT is 33..63, applies cleanly, and matches a clamp already present here for bmc150.
**YES**
drivers/iio/accel/fxls8962af-core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/accel/fxls8962af-core.c +2 -0
@@ -970,6 +970,8 @@ static int fxls8962af_fifo_flush(struct iio_dev *indio_dev)if (!count)return 0 ; + count =min (count,FXLS8962AF_FIFO_LENGTH ); + data->old_timestamp = data->timestamp; data->timestamp =iio_get_time_ns (indio_dev);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 media: go7007: s2250: propagate control I/O failures
In reply to Sasha LevinFrom: Yousef Alhouseen <[email protected]>
[ Upstream commit 59dc14a6cb5ff1ae5ce2f6ebf51fe0139e1c0623 ]
The brightness and contrast paths use oldvalue after read_reg_fp() without checking whether the read succeeded. A failed read leaves oldvalue uninitialized and can write arbitrary reserved register bits.
Return read and write errors from every control path so failed hardware access cannot be reported as a successful control update.
---
LLM Generated explanations, may be completely bogus:
The local tree is mainline **7.3.0-rc4**. The Sensoray 2250 control path is present here, and the change is a small, real error-path fix: a failed read_reg_fp() left oldvalue uninitialized and could program reserved VPX322 bits while still reporting success to V4L2.
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: **[media/go7007/s2250] [propagate] Return control I/O errors so brightness/contrast do not use an uninitialized register image**
**Step 1.2: Tags**
Record:
- **Signed-off-by:** Yousef Alhouseen (author)
- **Signed-off-by:** Hans Verkuil (media/GO7007 maintainer; applied the patch)
- **No** Fixes, Reported-by, Tested-by, Reviewed-by, Acked-by, Link, or
Cc: stable (absence of Fixes/Cc stable is expected for this review)
- Not a syzbot report; not a kernel test robot report
**Step 1.3: Body**
Record:
- **Bug:** brightness/contrast call read_reg_fp() then use oldvalue without checking the read.
- **Symptom:** a failed read leaves oldvalue uninitialized; the following write can poke **arbitrary reserved register bits**. Failed I/O is still reported as a successful control update.
- **Version info:** none in the message. Commit 59dc14a6cb5ff was applied 2026-07-27 and is an ancestor of v7.3-rc1 (this checkout is v7.3-rc4-27-gf0100363d8c37). It is **not** an ancestor of v7.2.
- **Root cause (author):** missing error checks on FP register read/write in s2250_s_ctrl().
**Step 1.4: Hidden bug fix?**
Record: **Yes, and it is not hidden.** The subject uses “propagate” rather than “fix”, but the body is an uninitialized-use / false-success bug. Saturation/hue changes are the same class: swallow write errors and return 0.
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- **File:** drivers/media/usb/go7007/s2250-board.c — **+33 / −21** (54 lines with context; under the 100-line stable cap)
- **Function:** s2250_s_ctrl() only
- **Scope:** single-file surgical fix
**Step 2.2: Code flow**
Record (before → after), all in s2250_s_ctrl():
- **Brightness / contrast:** read_reg_fp() / write_reg_fp() results ignored; always break then return 0 → each call’s return is checked; first failure is returned; last write’s status is returned.
- **Saturation / hue:** write ignored, return 0 → return write_reg_fp(...).
- **Normal path:** unchanged when I/O succeeds (still RMW reserved bits, then write 0x140).
- **Error path:** now fails the V4L2 set instead of committing a fake success.
**Step 2.3: Bug mechanism**
Record: **Uninitialized data + ignored I/O errors (logic/correctness).**
Verified in this tree: read_reg_fp() writes *val only after a successful USB vendor request:
```249:286:drivers/media/usb/go7007/s2250-board.c
static int read_reg_fp(struct i2c_client *client, u16 addr, u16 *val)
{
// ...
if (go == NULL)
return -ENODEV;
if (go->status == STATUS_SHUTDOWN)
return -EBUSY;
// kzalloc / mutex_lock_interruptible / usb_control_msg failures
// all return without *val = ...
*val = (buf[0] << 8) | buf[1];
kfree(buf);
return 0;
}
```write_reg_fp() likewise returns 0 or a negative errno, never a positive byte count, so if (ret) is equivalent to if (ret < 0).
On a failed read, oldvalue is stack garbage. The write is ctrl->val | (oldvalue & ~0xff) (brightness) or ... & ~0x3f (contrast), so reserved bits come from that garbage.
**Step 2.4: Fix quality**
Record: **Obviously correct and minimal.** No API/data-structure change. Regression risk is low: VIDIOC_S_CTRL that used to return 0 on hardware failure now returns the errno. That is the intended V4L2 behavior (try_or_set_cluster() only copies new values after s_ctrl succeeds). Partial updates if a later write fails were already possible; the patch does not add locking or new control IDs.
## Phase 3: Git history
**Step 3.1: Blame**
Record:
- Unchecked read_reg_fp() + oldvalue RMW: **05d76f2da1e5cc** (“s2250: subdev conversion”, 2009; contained in **v2.6.33-rc1**)
- Driver itself: **b11869dbb6cc4** (v2.6.29-rc1 era staging)
- Control-framework conversion: **d3b2ccd9e307ea** (2013) kept the same ignore-errors pattern
- Bug is old, not recent churn
**Step 3.2: Fixes: tag**
Record: **None.** No Fixes SHA to follow. The buggy pattern is the 2009 subdev conversion, not a recent regression.
**Step 3.3: File history**
Record: Recent s2250-board.c work is i2c probe conversions and a probe leak fix, not a series this patch depends on. **Standalone.** Same-day sibling by the same author: 41f82777e5477 (“avoid undefined shifts in MPEG-4 headers”) — different file (go7007-driver MPEG path), not a prerequisite.
**Step 3.4: Author**
Record: Yousef Alhouseen is not the subsystem maintainer. Two media/go7007 correctness patches on 2026-06-30; Hans Verkuil applied both. Maintainer SOB is a positive quality signal.
**Step 3.5: Dependencies**
Record: **None.** Uses existing read_reg_fp() / write_reg_fp() and s2250_s_ctrl(). **Applies standalone.**
## Phase 4: Mailing list / external
**Step 4.1:**
Record:
- **b4 dig -c 59dc14a6cb5ff** → https://patch.msgid.link/20260630105015.
[email protected]
- **b4 dig -a:** **v1 only** (committed diff matches v1)
- **b4 dig -m:** thread is the patch mail only — **no replies, no NAK, no Cc: stable**
- lore.kernel.org HTTP fetches returned **403**; discussion content was recovered via b4
**Step 4.2:**
Record: **b4 dig -w** recipients: Hans Verkuil, Mauro Chehab, linux- media, linux-kernel. Appropriate lists/maintainers. Hans’s SOB on the git commit is the review signal.
**Step 4.3:**
Record: **No bugzilla/syzbot/user report.** Finding is from code inspection.
**Step 4.4:**
Record: Standalone v1 patch, not part of a numbered series. Sibling MPEG-4 shift patch is independent.
**Step 4.5:**
Record: **UNVERIFIED** whether linux-stable ever discussed this (lore.kernel.org 403; no local hit on this file’s history besides the mainline commit).
## Phase 5: Semantic / call graph
**Step 5.1:**
Record: Modified function: **s2250_s_ctrl**. Helpers used:read_reg_fp, write_reg_fp.
**Step 5.2: Callers**
Record: Wired as s2250_ctrl_ops.s_ctrl. Invoked from:
- try_or_set_cluster() → call_op(master, s_ctrl) (v4l2-ctrls- core.c)
- __v4l2_ctrl_handler_setup() during control setup
- Userspace: v4l2_s_ctrl() / VIDIOC_S_CTRL / VIDIOC_S_EXT_CTRLS
**Step 5.3: Callees**
Record: USB vendor requests via go7007_usb_vendor_request() → usb_control_msg(). Also mutex_lock_interruptible() (can return **-EINTR**).
**Step 5.4: Reachability**
Record: **Yes, from userspace** if CONFIG_VIDEO_GO7007_USB_S2250_BOARD is enabled and a Sensoray 2250/2251 is present. Realistic failure that still continues into the write: **EINTR on the read’s mutex**, then a successful write mutex — two separate mutex_lock_interruptible() calls. ENOMEM on the read’s kzalloc with a later successful write alloc is also possible. STATUS_SHUTDOWN/go == NULL fail both read and write before hardware access, so those paths do not program garbage.
**Step 5.5: Similar patterns**
Record: s2250_s_std, s2250_set_fmt, and s2250_s_video_routing still ignore write_reg_fp() results. This patch does not claim to fix those; they have no uninitialized oldvalue. Not a series dependency.
semcode MCP: **not available**; used git grep / file reads.
## Phase 6: This checkout
**Step 6.1:**
Record:
- Tree: **v7.3-rc4-27-gf0100363d8c37**, make kernelversion = **7.3.0-rc4**
- File and s2250_s_ctrl() **exist**
- Buggy ignore-error RMW existed in this lineage from 2009 until **59dc14a6cb5ff** (merged for **v7.3-rc1**)
- Current HEAD source already contains the fixed function (commit is an ancestor of HEAD and of v7.3-rc4)
- Bug was **not** introduced after this tree; it is old. This 7.3 snapshot already includes the fix as a mainline merge, not as a stable cherry-pick.
**Step 6.2:**
Record: **Clean apply** to this file’s s2250_s_ctrl() shape (same switch, same register macros). No conflicting refactor in this tree.
**Step 6.3:**
Record: No alternate fix for this oldvalue bug. Only this commit changes those checks.
## Phase 7: Subsystem context
**Step 7.1:**
Record: **media / USB V4L2 driver** (drivers/media/usb/go7007/). **PERIPHERAL** — Sensoray 2250/2251 only (CONFIG_VIDEO_GO7007_USB_S2250_BOARD). Maintainer: Hans Verkuil, linux-media.
**Step 7.2:**
Record: File is mature/low-churn (last functional s2250 work before this was older i2c/probe fixes). Not a newly added subsystem.
## Phase 8: Impact and risk
**Step 8.1:**
Record: **Driver-specific / config-specific** (VIDEO_GO7007_USB_S2250_BOARD). Not universal. Small user population (legacy USB MPEG capture box).
**Step 8.2:**
Record:
- Trigger: VIDIOC_S_CTRL for brightness/contrast (and sat/hue for the false-success half)
- Common on a working device: **no** (happy path already initialized oldvalue)
- Realistic error: **signal interrupting the read lock**, USB control- msg failure, or alloc failure
- Unprivileged user with the video node can issue the ioctl
**Step 8.3:**
Record:
- **Failure mode:** uninitialized stack bits written into VPX322 reserved fields; V4L2 still treats the set as success and publishes the new control value
- **Not** an oops, deadlock, filesystem corruption, or a demonstrated CVE
- **Severity: MEDIUM** (hardware misprogramming + lying to userspace). On shutdown-only failures, writes also fail first, so those are lower impact.
**Step 8.4:**
Record:
- **Benefit:** medium-low globally, high for the few users of this board if a control set races with EINTR/USB error
- **Risk:** **very low** (33 lines, error returns only, maintainer- applied)
- **Ratio:** favorable for a tiny correctness fix; the weak point is “important issue” given niche hardware and no reports
## Phase 9: Synthesis
**Step 9.1: Evidence**
**For backporting**
- Verified uninitialized oldvalue when read_reg_fp() fails
- Verified reserved-bit RMW from that garbage
- Verified V4L2 commits the new value if s_ctrl returns 0
- Realistic EINTR window (separate interruptible locks)
- Small, obviously correct, maintainer SOB
- No new API; under 100 lines
- Driver and function exist in this tree
**Against**
- Niche, aging Sensoray 2250/2251 hardware
- No user/syzbot/KMSAN report
- Not a crash, hang, or user-data corruption
- Looks like a static-analysis sweep (two go7007 patches the same day)
- Sibling functions still ignore I/O errors
- Official rule text wants a bug that “bothers people” or an “oh, that’s not good” issue — this is the latter, not a production fire
**Unresolved**
- Could not read lore.kernel.org in the browser (403); no on-list review beyond Hans applying v1
- Did not compile to confirm -Wmaybe-uninitialized
- No evidence of prior stable-list discussion
**Step 9.2: Stable rules checklist** (this tree)
1. Obviously correct and tested? **PASS** — mechanical error returns; applied by Hans Verkuil. No extra Tested-by.
2. Real bug that affects users? **PASS** — uninit RMW and false ioctl success on a reachable control path.
3. Important (crash/security/corruption/deadlock)? **PASS** (weak) — hardware register corruption and incorrect V4L2 success fall under “oh, that’s not good”, not oops/hang. Not a theoretical race without a trigger.
4. Small and contained? **PASS** — one function, +33/−21.
5. No new features/APIs? **PASS**
6. Can apply to this tree? **PASS** — same s2250_s_ctrl(); this 7.3-rc4 checkout already contains the commit as of v7.3-rc1.
**Step 9.3: Exception category**
Record: **None** (not a device ID, quirk, DT, build, or docs fix).
**Step 9.4: Decision**
This tree’s go7007/s2250 code is the long-standing buggy RMW path. The patch is a small, maintainer-applied fix for uninitialized reserved-bit writes and false VIDIOC_S_CTRL success. That is a real, user-visible device-control bug with very low regression risk. It is not a core- kernel crisis, but it is in-scope for stable as an “oh, that’s not good” driver correctness fix, and the code it needs is present here.
### What the commit solves for this trees2250_s_ctrl() used to ignore FP register I/O errors. On brightness/contrast, a failed read left oldvalue uninitialized and the next write could set reserved VPX322 bits while V4L2 still stored the new control. After the fix, those errors propagate so userspace is not told the hardware update succeeded.
### Risk vs benefit
Benefit is limited to Sensoray 2250/2251 users, but the downside of taking the patch is negligible. Returning errno instead of 0 on failed I/O is the correct userspace contract.
---
Verification:
- [Phase 1] Parsed commit 59dc14a6cb5ff; tags are author + Hans Verkuil SOB only
- [Phase 1] Confirmed no syzbot/Fixes/Link/Reported-by
- [Phase 2] Diff is only s2250_s_ctrl() in s2250-board.c (+33/−21)
- [Phase 2] Read read_reg_fp()/write_reg_fp(): *val set only on success; writes return 0 or negative
- [Phase 3] git blame on pre-patch function: ignore-errors RMW from 05d76f2da1e5cc (v2.6.33-rc1)
- [Phase 3] No Fixes tag; sibling 41f82777e5477 is a different go7007 issue, not a dep
- [Phase 3] git merge-base --is-ancestor 59dc14a6cb5ff v7.2 → not in 7.2; ancestor of v7.3-rc1 and of HEAD
- [Phase 4] b4 dig -c/-a/-w/-m: v1, Hans+media list, no thread replies, no stable nomination
- [Phase 4] WebFetch/curl to lore.kernel.org → 403; UNVERIFIED public review beyond the mbox
- [Phase 5] s2250_ctrl_ops.s_ctrl → try_or_set_cluster() / v4l2_s_ctrl(); userspace VIDIOC_S_CTRL
- [Phase 5] Confirmed try_or_set_cluster() does not publish new values if s_ctrl returns nonzero
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- [Phase 6] Current file already has the error checks; driver Kconfig VIDEO_GO7007_USB_S2250_BOARD exists
- [Phase 7] MAINTAINERS: GO7007 MPEG CODEC, Hans Verkuil
- [Phase 8] Failure mode: reserved-bit programming + false success; severity MEDIUM; EINTR path verified in read_reg_fp/write_reg_fp
- [Phase 9] Official stable-kernel-rules.rst read: ≤100 lines, real bug, “oh that’s not good”, no new API
- UNVERIFIED: compiler warning reproduction; stable mailing-list history
**YES**
drivers/media/usb/go7007/s2250-board.c | 54 ++++++++++++++++---------- 1 file changed, 33 insertions(+), 21 deletions(-)
drivers/media/usb/go7007/s2250-board.c +33 -21
@@ -365,36 +365,48 @@ static int s2250_s_ctrl(struct v4l2_ctrl *ctrl) struct s2250 *state = container_of(ctrl->handler, struct s2250, hdl);struct i2c_client *client =v4l2_get_subdevdata (&state->sd);u16 oldvalue; +int ret;switch (ctrl->id) {case V4L2_CID_BRIGHTNESS : -read_reg_fp (client,VPX322_ADDR_BRIGHTNESS0 , &oldvalue); -write_reg_fp (client,VPX322_ADDR_BRIGHTNESS0 , - ctrl->val | (oldvalue & ~0xff )); -read_reg_fp (client,VPX322_ADDR_BRIGHTNESS1 , &oldvalue); -write_reg_fp (client,VPX322_ADDR_BRIGHTNESS1 , - ctrl->val | (oldvalue & ~0xff )); -write_reg_fp (client,0x140 ,0x60 ); -break ; + ret =read_reg_fp (client,VPX322_ADDR_BRIGHTNESS0 , &oldvalue); +if (ret) +return ret; + ret =write_reg_fp (client,VPX322_ADDR_BRIGHTNESS0 , + ctrl->val | (oldvalue & ~0xff )); +if (ret) +return ret; + ret =read_reg_fp (client,VPX322_ADDR_BRIGHTNESS1 , &oldvalue); +if (ret) +return ret; + ret =write_reg_fp (client,VPX322_ADDR_BRIGHTNESS1 , + ctrl->val | (oldvalue & ~0xff )); +if (ret) +return ret; +return write_reg_fp (client,0x140 ,0x60 );case V4L2_CID_CONTRAST : -read_reg_fp (client,VPX322_ADDR_CONTRAST0 , &oldvalue); -write_reg_fp (client,VPX322_ADDR_CONTRAST0 , - ctrl->val | (oldvalue & ~0x3f )); -read_reg_fp (client,VPX322_ADDR_CONTRAST1 , &oldvalue); -write_reg_fp (client,VPX322_ADDR_CONTRAST1 , - ctrl->val | (oldvalue & ~0x3f )); -write_reg_fp (client,0x140 ,0x60 ); -break ; + ret =read_reg_fp (client,VPX322_ADDR_CONTRAST0 , &oldvalue); +if (ret) +return ret; + ret =write_reg_fp (client,VPX322_ADDR_CONTRAST0 , + ctrl->val | (oldvalue & ~0x3f )); +if (ret) +return ret; + ret =read_reg_fp (client,VPX322_ADDR_CONTRAST1 , &oldvalue); +if (ret) +return ret; + ret =write_reg_fp (client,VPX322_ADDR_CONTRAST1 , + ctrl->val | (oldvalue & ~0x3f )); +if (ret) +return ret; +return write_reg_fp (client,0x140 ,0x60 );case V4L2_CID_SATURATION : -write_reg_fp (client,VPX322_ADDR_SAT , ctrl->val); -break ; +return write_reg_fp (client,VPX322_ADDR_SAT , ctrl->val);case V4L2_CID_HUE : -write_reg_fp (client,VPX322_ADDR_HUE , ctrl->val); -break ; +return write_reg_fp (client,VPX322_ADDR_HUE , ctrl->val);default :return -EINVAL ; } -return 0 ; } static int s2250_set_fmt(struct v4l2_subdev *sd,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 Bluetooth: bfusb: validate received block boundaries
In reply to Sasha LevinFrom: Li Qiang <[email protected]>
[ Upstream commit 6afadcff79b157a4770c4e987a6005bff40a670b ]
The USB receive path trusts the block header to contain the required number of bytes and passes it to the reassembly routine. The routine also trusts a malformed HCI packet type and can append more data than the skb allocated from the advertised packet length. A malformed USB transfer can therefore cause out-of-bounds reads or an skb tail overwrite.
Validate block header availability, declared block size, packet type, and reassembly tailroom. Drop the partial frame on an invalid block.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.18.53** (pending-6.18). The buggy bfusb receive path is present here; the fix is not. This is a real USB OOB / skb_over_panic bug, and the patch applies cleanly.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[Bluetooth/bfusb] [validate] [check USB block headers and reassembly bounds before trusting them]**
- Subsystem prefix: Bluetooth: bfusb:
- Action verb: **validate** (safety check / missing bounds handling)
- Claimed intent: stop treating untrusted USB block headers as valid lengths
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record (from the candidate message and from git show b94bab6f1dd9):
- Signed-off-by: Li Qiang <[email protected]> — author
- Signed-off-by: Luiz Augusto von Dentz <[email protected]> — Bluetooth maintainer; applied to bluetooth-next
- No Fixes: tag (expected)
- No Cc: [email protected] (expected)
- No Reported-by: / Tested-by: / Reviewed-by: / Acked-by: / Link:
- Ignore any pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] markers
Notable pattern: maintainer SOB only; no syzbot/user report. The same driver already had a Cc: stable USB-descriptor panic fix (b5e6fa7a12572, division by zero on malicious wMaxPacketSize).
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** USB RX trusts the 2/3-byte block header and HCI packet type. Reassembly then copies len bytes into an skb sized from the advertised HCI length, with no tailroom check.
- **Symptom:** out-of-bounds URB reads and skb tail overwrite (skb_put() → skb_over_panic() → BUG()).
- **Version info:** none in the message. Blame shows the logic dates to 1da177e4c3f41 (Linux-2.6.12-rc2).
- **Root cause (author):** malformed USB transfer; missing validation of header availability, declared size, packet type, and reassembly tailroom. Invalid blocks should drop the partial frame.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not a hidden/cleanup-only change.** The subject is “validate”, but the body names OOB reads and skb overwrite. The diff adds bounds checks, a default: reject, and break on short/oversize blocks. This is an explicit memory-safety fix.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/bluetooth/bfusb.c only
- Scope: **+34 / −3**, single-file surgical fix
- Functions: bfusb_recv_block(), bfusb_rx_complete()
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record (before → after), verified against current bfusb.c in this tree:
1. **Unknown HCI packet type (start block):** switch has EVENT/ACL/SCO only, no default. pkt_len stays **0**. Code allocates bt_skb_alloc(0), then skb_put_data(..., len) with the remaining block. → **default: returns -EILSEQ** before alloc.
2. **Reassembly copy:** any continuation (or start payload) is copied with skb_put_data with no tailroom check. → **if len > skb_tailroom(reassembly), free skb, return -EILSEQ**.
3. **Block header parse loop:** while (count) always does hdr = buf[0] | (buf[1] << 8) and, unless bit 0x4000, buf[2]. No `count
Quoted 1 line
= 2
/count >= 3` checks. → **short-header checks; drop reassembly
and break**.
4. **count < len:** only logs "block extends over URB buffer ranges", then still calls bfusb_recv_block and does count -= len. → **free reassembly and break**.
5. **Error accounting:** bfusb_recv_block return was ignored. → **on < 0, data->hdev->stat.err_rx++**.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Memory safety: OOB read + skb overflow panic] [plus infinite loop in URB complete]**
Verified mechanism in this tree:
```355:376:drivers/bluetooth/bfusb.c
while (count) {
hdr = buf[0] | (buf[1] << 8);
...
len = (buf[2] == 0) ? 256 : buf[2];
...
if (count < len)
bt_dev_err(data->hdev, "block extends over URB
buffer ranges");
if ((hdr & 0xe1) == 0xc1)
bfusb_recv_block(data, hdr, buf, len);
count -= len;
buf += len;
}
```- count is int urb->actual_length. If count < len, count -= len goes **negative**. while (count) is then true forever → **hard lockup in USB completion**.
- skb_put_data() calls skb_put(), which panics if skb->tail > skb->end:
```2574:2592:net/core/skbuff.c
- This function extends the used data area of the buffer. If this would
- exceed the total buffer size the kernel will panic.
...
if (unlikely(skb->tail > skb->end))
skb_over_panic(skb, len, __builtin_return_address(0));
```skb_over_panic() → skb_panic() → BUG().
Unknown packet type: pkt_len initialized to 0, no default, then bt_skb_alloc(0) and skb_put_data of the rest of the block → same panic.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Quality:** obviously correct. Same pattern as existing skb_tailroom checks in btusb.c / hci_h4.c.
- **Minimal:** only RX validation and error accounting; no API/structure changes.
- **Regression risk: low.** default: cannot reject ISO (HCI_ISODATA_PKT 0x05) on this 2003-era AVM dongle (VID 0x057c, PID 0x2200); previously unknown types already panicked. Short-header break only stops already-corrupt URBs. kfree_skb(NULL) is safe if reassembly is already NULL.
- **Red flags:** labeled [PATCH 1/5], but the other four patches touch **different files** (btmrvl, hci_bcsp, hci_ldisc, hci_qca). This one is standalone.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Core RX loop / bfusb_recv_block: 1da177e4c3f41 (Linus, 2005-04-16, Linux-2.6.12-rc2)
- Function split/cleanup: 9c724357f432df (Marcel Holtmann, 2006)
- skb_put_data: 59ae1d127ac0ae (2017) — same overflow semantics as old skb_put+memcpy
- bt_dev_err conversion: 2a4f3909d0fbda (2020)
- Brace removal on the count < len log: 461159ece0586 (2025) — style only; did **not** add a break
Buggy pattern has been in the tree for ~20 years.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Introducer is 1da177e4c3f41, which **is** an ancestor of this tree (git merge-base --is-ancestor 1da177e4c3f41 HEAD succeeded).
Related unmerged attempt: Seungjin Bae, Oct 2025, “Fix buffer over-read in rx processing loop” — only the count < 3 / buf[2] case. Not in this tree. This commit is a superset.
**Step 3.3: CHECK FILE HISTORY**
Record (recent git log --oneline -20 -- drivers/bluetooth/bfusb.c):
- b5e6fa7a12572 — bfusb: fix division by zero in send path (`Cc:
stable`, malicious USB descriptors)
- 461159ece0586 — brace style on the exact count < len line
- No existing bounds-check fix for this RX loop
Standalone: yes. Series mates are other drivers.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Li Qiang has **no** other drivers/bluetooth/ commits on this branch. Luiz von Dentz is a Bluetooth maintainer (MAINTAINERS:
BLUETOOTH DRIVERS / SUBSYSTEM) and applied the patch to bluetooth-next (commit date Mon Jul 20 2026).
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **None required.** Uses existing skb_tailroom, bt_skb_alloc, bt_dev_err, kfree_skb. git show b94bab6f1dd9 -- drivers/bluetooth/bfusb.c | git apply --check → **clean apply**.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c b94bab6f1dd9: https://patch.msgid.link/1f79f2f12306c15d6f6
[email protected]
- Cover: [PATCH 0/5] Bluetooth: harden packet and transport parsing (2026-07-16)
- b4 dig -a: **v1 only**; applied as submitted
- Applied to bluetooth-next as b94bab6f1dd9 by Luiz (patchwork-bot, 2026-07-20)
- Networking pull for **7.3** (Jakub Kicinski, 2026-08-18) — **not** in 6.18
- No NAK on this patch. Samsung review (0eec0c0d-636b-...) is about **patch 2/5 btmrvl**, not bfusb.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): [email protected], Marcel Holtmann, Luiz von Dentz, LKML. Maintainer applied it. No extra Reviewed-by on this hunk.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: no syzbot/bugzilla/Reported-by. Independent earlier report:
Seungjin Bae described the buf[2] over-read / panic (Oct 2025). Trigger is a malformed USB bulk IN, not a syscall fuzzer.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 5 independent driver hardenings. Patch 1/5 is self-contained. Patch 5/5 (hci_qca) was **not** applied. No bfusb follow-up found.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search for this subject did not turn up a prior stable discussion or a reason to skip it. UNVERIFIED in the sense that lore.kernel.org itself returned 403; used mirrors + web search instead.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
Record: bfusb_recv_block(), bfusb_rx_complete().
**Step 5.2: TRACE CALLERS**
Record:
- bfusb_recv_block — only from bfusb_rx_complete
- bfusb_rx_complete — URB complete from bfusb_rx_submit() (usb_fill_bulk_urb(..., bfusb_rx_complete, skb))
- bfusb_rx_submit — bfusb_open() (HCI start) and resubmit in bfusb_rx_complete
Context: USB completion (atomic/BH). An infinite while (count) here is a **hard lockup**, not a sleepable hang.
**Step 5.3: TRACE CALLEES**
Record: bt_skb_alloc, skb_put_data/skb_put, hci_recv_frame, kfree_skb, usb_submit_urb. No new callees in the fix (skb_tailroom is an existing inline).
**Step 5.4: FOLLOW THE CALL CHAIN**
Record:
USB plug of 0x057c:0x2200 → bfusb_probe → BlueZ opens HCI → bfusb_open → bulk IN URBs → bfusb_rx_complete.
Reachable from: a matching (or spoofed) USB device plus HCI running. Not a random syscall; **local USB attack surface**, same class as the prior Cc: stable bfusb descriptor fix.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: btusb.c, hci_h4.c, btmtk.c already check skb_tailroom before appending. err_rx++ on parse failure is standard (btusb, btsdio, bpa10x, …). bfusb was missing both.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** drivers/bluetooth/bfusb.c still has the unvalidated loop and no default: / tailroom check (lines 245–376). git describe HEAD = p-6.18-1-g03b85e06ca9bf; make kernelversion = **6.18.53**. git merge-base --is-ancestor b94bab6f1dd9 HEAD → **not in this tree**. Introduced in 2.6.12-rc2; present for the entire 6.18 lifetime.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** git apply --check on the exact commit diff succeeded. Surrounding code matches the hunks (including post-461159ece0586 braceless if (count < len)).
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: Seungjin Bae over-read patch is **not** here. No other RX-bounds fix in this file. The send-path div-by-zero fix **is** here; it does not cover this RX bug.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **Bluetooth USB driver (drivers/bluetooth/bfusb.c)**.
Criticality: **PERIPHERAL** hardware (AVM BlueFRITZ! USB only), but the failure is a **kernel panic / lockup** on untrusted USB data. Kconfig:BT_HCIBFUSB, depends on USB. Enabled as =m in several defconfigs (e.g. omap2plus, exynos, loongson3, pmac32).
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Bluetooth core is active; **bfusb itself is mature/mostly idle**. Recent file commits are isolated fixes/style. Long-lived bug, not churn from a new feature.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Record: **driver-specific** — AVM BlueFRITZ! USB (USB_DEVICE(0x057c, 0x2200)), plus any system with the module that binds a spoofed VID/PID. Not universal.
**Step 8.2: TRIGGER CONDITIONS**
Record:
- Requires this driver bound and HCI running (HCI_RUNNING).
- Trigger: truncated/malformed bulk IN (device bug, USB fuzzing, malicious dongle).
- Not a normal healthy-traffic path.
- Unprivileged userspace cannot hit it without the device; a **USB attacker** can.
**Step 8.3: FAILURE MODE SEVERITY**
Record:
- skb_put overflow → skb_over_panic → **BUG() / panic** — **CRITICAL**
- while (count) with negative count → **infinite loop in URB complete** — **CRITICAL**
- Short-header buf[0]/buf[1]/buf[2] — **OOB read** — **HIGH**
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit: high for affected systems** (panic/lockup prevention). Population is small, but the same driver already got stable treatment for malicious USB descriptors.
- **Risk: very low** — 37-line, single-file, validated by maintainer, applies cleanly, error-path only.
- **Ratio: favor backport.**
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real OOB read + skb overflow BUG() + possible hard lockup, verified in this tree’s code
- Bug present since 2.6.12; definitely in 6.18.53
- Small, obviously correct, no new APIs
- Applies cleanly; no prerequisites
- Bluetooth maintainer applied it
- Same driver already had a stable USB-malice panic fix
- Independent of the rest of the 5-patch series
**AGAINST:**
- Niche 2000s dongle; few users
- No syzbot / production Reported-by
- Series framed as “harden”
- Patch 2/5 (btmrvl) later needed a fix — **does not apply to this file**
**UNRESOLVED:**
- Could not fetch lore.kernel.org directly (403); used b4 dig + mirrors
- No scan of every post-b94bab6f1dd9 bluetooth-next follow-up (object is not on HEAD); no evidence of a bfusb revert/fixup
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — maintainer-applied; logic matches existing Bluetooth RX checks
2. Fixes a real bug that affects users? **PASS** — malformed USB RX panics/lockups this driver
3. Important issue? **PASS** — kernel BUG() / hard lockup / OOB (CRITICAL), even though the driver is niche
4. Small and contained? **PASS** — +34/−3, one file
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — git apply --check succeeded; buggy code present; fix not present
**Step 9.3: EXCEPTION CATEGORIES**
Record: none (not a device ID / quirk / DT / build / doc exception). Qualifies as a **normal memory-safety bug fix**.
**Step 9.4: DECISION**
Backport to **this** 6.18.53 tree. The receive path here still trusts USB block lengths; that can panic or lock up the USB completion path. The fix is surgical and already matches this file.
### What the commit solves for stable users
On AVM BlueFRITZ! USB (or a spoofed 057c:2200), a short or lying block header can over-read the URB buffer, skb_put() past the reassembled HCI skb (BUG()), or drive count negative and spin forever in bfusb_rx_complete. This tree still has that code. The patch only adds header/size/type/tailroom checks and drops the partial frame.
### Risk vs benefit
Benefit is preventing panic/lockup on untrusted USB RX. Risk is low:
error-path validation, no locking/API change, clean apply. Niche hardware lowers breadth of impact but does not make a USB-triggered BUG() unsuitable for stable.
---
## Verification
- **[Phase 1]** Parsed subject/body/tags from the candidate text and git show b94bab6f1dd9; no Fixes/Cc:stable/Reported-by; Luiz SOB confirmed
- **[Phase 2]** Read bfusb_recv_block / bfusb_rx_complete in this tree; confirmed missing default, no tailroom check, log-only count < len, signed count loop
- **[Phase 2]** Read skb_put / skb_put_data / skb_panic: overflow → BUG()
- **[Phase 3]** git blame on both functions: core logic 1da177e4c3f41 (2.6.12-rc2)
- **[Phase 3]** git merge-base --is-ancestor 1da177e4c3f41 HEAD — introducer in this tree
- **[Phase 3]** git merge-base --is-ancestor b94bab6f1dd9 HEAD — fix **not** in this tree (exit 1)
- **[Phase 3]** git log --oneline -20 -- drivers/bluetooth/bfusb.c — no prior RX-bounds fix; b5e6fa7a12572 is a different (send-path) USB panic
- **[Phase 4]** b4 dig -c b94bab6f1dd9 — lore msgid 1f79f2f12306c15d6f686348bb79d8e6839968d2.1784191283
- **[Phase 4]** b4 dig -a — v1 only
- **[Phase 4]** b4 dig -w — linux-bluetooth, Holtmann, von Dentz
- **[Phase 4]** Cover letter / patchwork-bot: applied to bluetooth-next 2026-07-20; networking pull for 7.3
- **[Phase 4]** Samsung mail is about btmrvl 2/5, not this patch
- **[Phase 5]** Callers: only URB complete ← bfusb_rx_submit ← bfusb_open / resubmit
- **[Phase 5]** git grep skb_tailroom in drivers/bluetooth — sibling drivers already check
- **[Phase 6]** git describe HEAD / make kernelversion: 6.18.53; grep found no “block exceeds packet length” in this tree
- **[Phase 6]** git apply --check of b94bab6f1dd9 — success
- **[Phase 7]** Kconfig BT_HCIBFUSB; MAINTAINERS lists Luiz; defconfigs enable it as a module
- **[Phase 8]** Failure mode verified: panic (BUG) and infinite URB- complete loop
- **UNVERIFIED:** direct lore.kernel.org HTTP (403); exhaustive post- merge bfusb follow-ups on branches not in HEAD
**YES**
drivers/bluetooth/bfusb.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-)
drivers/bluetooth/bfusb.c +34 -3
@@ -301,6 +301,11 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned chreturn -EILSEQ ; }break ; + +default : +bt_dev_err (data->hdev,"unknown packet type 0x%02x" , + pkt_type); +return -EILSEQ ; } skb =bt_skb_alloc (pkt_len,GFP_ATOMIC );
@@ -319,6 +324,13 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch } } +if (len >skb_tailroom (data->reassembly)) { +bt_dev_err (data->hdev,"block exceeds packet length" ); +kfree_skb (data->reassembly); + data->reassembly =NULL ; +return -EILSEQ ; + } +if (len >0 )skb_put_data (data->reassembly, buf, len);
@@ -353,6 +365,13 @@ static void bfusb_rx_complete(struct urb *urb)skb_put (skb, count);while (count) { +if (count <2 ) { +bt_dev_err (data->hdev,"short block header" ); +kfree_skb (data->reassembly); + data->reassembly =NULL ; +break ; + } + hdr = buf[0 ] | (buf[1 ] <<8 );if (hdr &0x4000 ) {
@@ -360,16 +379,28 @@ static void bfusb_rx_complete(struct urb *urb) count -=2 ; buf +=2 ; }else { +if (count <3 ) { +bt_dev_err (data->hdev,"short block header" ); +kfree_skb (data->reassembly); + data->reassembly =NULL ; +break ; + } + len = (buf[2 ] ==0 ) ?256 : buf[2 ]; count -=3 ; buf +=3 ; } -if (count < len) +if (count < len) {bt_dev_err (data->hdev,"block extends over URB buffer ranges" ); +kfree_skb (data->reassembly); + data->reassembly =NULL ; +break ; + } -if ((hdr &0xe1 ) ==0xc1 ) -bfusb_recv_block (data, hdr, buf, len); +if ((hdr &0xe1 ) ==0xc1 && +bfusb_recv_block (data, hdr, buf, len) <0 ) + data->hdev->stat.err_rx++; count -= len; buf += len;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 regmap: maple: Workaround for another false-positive compiler warning
In reply to Sasha LevinFrom: Uwe Kleine-König (The Capable Hub) <[email protected]>
[ Upstream commit dffd32eb2b0e714a8ae23f98518ad7152cb06369 ]
Similar to the issue fixed in commit 542440fd7b30 ("regmap: maple: work around gcc-14.1 false-positive warning"), I see an uninitialized warning for upper_index and upper_last.
Happens with arc-linux-gnu-gcc (Debian 15.3.0-1) 15.3.0 on an allmodconfig for ARCH=arc.
---
LLM Generated explanations, may be completely bogus:
I have the tree version, the pre-image at v6.18.53, the lore thread, and the call-path context. Compiling the nine-phase analysis next.
---
## Phase 1: Commit message forensics
**Step 1.1: Subject**
Record: [regmap: maple:] [Workaround] [silence a gcc false-positive -Wuninitialized on upper_index/upper_last]
**Step 1.2: Tags**
Record:
- Link: https://patch.msgid.link/20260626060427.2548578-2-u.kleine-
[email protected]
- Signed-off-by: Uwe Kleine-König (author)
- Signed-off-by: Mark Brown (regmap maintainer)
- No Fixes:, Reported-by, Tested-by, Reviewed-by, Acked-by, or Cc:
stable (absence expected)
- Mentions prior commit 542440fd7b30
**Step 1.3: Body**
Record: [Bug] gcc 15.3.0 on ARCH=arc allmodconfig reports -Wuninitialized for upper_index and upper_last in regcache_maple_drop(). Same class as the gcc-14.1 false-positive already worked around for lower_index/lower_last. [Symptom] compiler warning; with CONFIG_WERROR it is a hard build failure (-Werror=uninitialized). [Versions] gcc 15.3.0 (Debian), ARCH=arc allmodconfig. [Root cause] compiler cannot see that those locals are only read after they are assigned (guarded by if (upper)).
**Step 1.4: Hidden bug fix?**
Record: Not a hidden runtime bug. It is an explicit compiler-warning workaround. It is a **build fix**, which the stable rules treat as an allowed exception.
---
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record: drivers/base/regmap/regcache-maple.c — 1 line changed (+1/-1). Function: regcache_maple_drop(). Scope: single-file, one- line surgical change.
**Step 2.2: Flow**
Record: Before: unsigned long upper_index, upper_last; uninitialized.
After: = 0 on both. No control-flow change. upper_index/upper_last are assigned at lines 146–147 only when mas.last > max, which is also when upper is allocated; they are consumed only under if (upper) (line 171). Initializing to 0 is a dead store on the real path.
**Step 2.3: Bug mechanism**
Record: [Category] Build / compiler false-positive (not a runtime uninitialized use). [Mechanism] gcc 15 cannot prove initialization through the maple-tree loop and warns; with Werror that fails the build.
Fix: same dummy init already used for lower_index/lower_last.
**Step 2.4: Fix quality**
Record: Obviously correct; matches the existing comment and the gcc-14 workaround. Zero runtime behavior change. Regression risk: negligible (0 is never consumed unless upper is set, and that path always assigns first).
---
## Phase 3: Git history
**Step 3.1: Blame**
Record: regcache_maple_drop() introduced in f033c26de5a57 (“regmap:
Add maple tree based register cache”, 2023-03-30, ~v6.4). lower_index dummy init: 542440fd7b309 (2024-07-19, in this tree). upper_index was left uninitialized until this commit.
**Step 3.2: Fixes: tag**
Record: None. Related original: 542440fd7b309, already an ancestor of HEAD and of v6.18.53.
**Step 3.3: File history**
Record: Recent real fixes in this file (00bb549d7d63a cache corruption, eaa03486d9325 uninitialized ret, f08f2d2907675 leak on store failure) are independent. This commit is standalone, not patch X/Y of a functional series.
**Step 3.4: Author**
Record: Uwe Kleine-König is a regular driver-core contributor, not the regmap maintainer. Mark Brown applied it. No other related maple commits by this author.
**Step 3.5: Dependencies**
Record: Needs the maple cache (present since v6.4) and the existing lower_* init comment (present). Applies standalone. No new helpers or struct fields.
---
## Phase 4: Mailing list
**Step 4.1: Original discussion**
Record: [Lore]
https://patch.msgid.link/20260626060427.2548578-2-u.kleine-
[email protected]
[Revisions] v1 only (b4 dig -a). Thread: submission + Mark Brown “Applied to broonie/regmap.git for-7.3”. No NAKs, no stable nomination, no reviewer risk flags.
**Step 4.2: Recipients (b4 dig -w)**
Record: To: Mark Brown. Cc: Greg Kroah-Hartman, Rafael Wysocki, Danilo Krummrich, linux-kernel, driver-core. Maintainer received and applied it.
**Step 4.3: Bug report**
Record: Author-reported compiler warning on arc-linux-gnu-gcc 15.3.0 allmodconfig. No syzbot/bugzilla. Severity: build warning/error, not a runtime crash.
**Step 4.4: Series**
Record: msgid …2548578-2 but subject is [PATCH v1] and Mark applied it as [1/1]. Standalone.
**Step 4.5: Stable list**
Record: No lore.kernel.org/stable discussion of this specific fix found.
---
## Phase 5: Semantic analysis
**Step 5.1: Functions**
Record: regcache_maple_drop() only.
**Step 5.2: Callers**
Record: Wired as regcache_ops.drop. Reached via regcache_drop_region() (exported). Callers: regmap core, kunit tests, various drivers. The *warning* triggers at compile time whenever this file is built, independent of runtime callers.
**Step 5.3: Callees**
Record: maple-tree mas_*, kmemdup_array, kfree. Unchanged.
**Step 5.4: Reachability**
Record: Compile-time: drivers/base/regmap/regcache-maple.c is built with CONFIG_REGMAP (common). Runtime drop path is not relevant to the failure mode.
**Step 5.5: Similar patterns**
Record: Same function already initializes lower_index/lower_last for the same reason (542440fd7b309) and ret for smatch (eaa03486d9325). This completes the remaining pair.
---
## Phase 6: Local tree (this checkout)
**Step 6.1: Does the buggy code exist?**
Record: Local tree is **6.18.53** (git describe:
v6.18.53-5049-g0f0bdc2b0dffb; Makefile VERSION=6 PATCHLEVEL=18 SUBLEVEL=53). At **v6.18.53**:
``` unsigned long upper_index, upper_last; ```
exists; lower_index = 0 is already present. Upstream dffd32eb2b0e is **not** an ancestor of v6.18.53. Maple cache has been here since ~v6.4.
**Step 6.2: Backport difficulty**
Record: Clean apply on v6.18.53. Surrounding function matches the hunk. No refactor in the way.
**Step 6.3: Related fixes already here?**
Record: gcc-14 lower_* workaround is in v6.18.53. Nothing already initializes upper_*.
---
## Phase 7: Subsystem context
**Step 7.1**
Record: [Subsystem] drivers/base/regmap (maple register cache). [Criticality] IMPORTANT — used by many hardware drivers; this change is compile-time only.
**Step 7.2**
Record: Mature cache implementation (since v6.4), modest ongoing churn. Not staging.
---
## Phase 8: Impact and risk
**Step 8.1: Who is affected**
Record: Anyone compiling this file with gcc that emits the warning. Documented trigger: ARCH=arc, gcc 15.3.0, allmodconfig. CONFIG_WERROR defaults to COMPILE_TEST (init/Kconfig); allmodconfig enables that, so the warning becomes -Werror=uninitialized (same diagnostic the gcc-14 commit showed as a hard error). Distro production configs usually have WERROR=n, so they see a warning rather than a failed build.
**Step 8.2: Trigger**
Record: Compile of regcache-maple.c. Not a runtime race. Not userspace-triggerable.
**Step 8.3: Failure mode**
Record: Build warning, or build *error* when WERROR is on. Severity:
MEDIUM for CI/allmodconfig (broken compile), LOW at runtime (no functional bug).
**Step 8.4: Risk-benefit**
Record: Benefit: restores allmodconfig/WERROR builds on gcc 15 (and likely similar compilers). Risk: very low — one-line initializer, proven pattern in the same function. Ratio: favorable.
---
## Phase 9: Synthesis
**Step 9.1: Evidence**
FOR:
- Explicit **build-fix** exception (compilation warnings/errors).
- Reproduced: gcc 15.3.0, ARCH=arc allmodconfig.
- With CONFIG_WERROR this is a hard build failure (-Werror=uninitialized), same class as 542440fd7b309, which is already in this tree.
- One line, obviously correct, no runtime change.
- Buggy (uninitialized) locals exist in v6.18.53; patch applies cleanly.
- Maintainer (Mark Brown) applied it; no NAKs.
AGAINST:
- Not a runtime crash/corruption/security bug.
- Applied to for-7.3 (merge window), not a -fixes pull, so not treated as urgent by the maintainer.
- Narrowest documented trigger is ARC + gcc 15 + allmodconfig.
- No Cc: stable (expected; not a negative).
UNRESOLVED:
- Whether gcc 15 also warns on x86/arm allmodconfig for 6.18 was not reproduced here (author only cited ARC).
- lore.kernel.org HTTP fetch returned 403; discussion recovered via b4 dig -m and openwall/patchew mirrors.
**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** — dummy init; author built ARC allmodconfig; maintainer applied.
2. Real bug affecting users? **PASS** as a build break under WERROR/allmodconfig; not a runtime bug.
3. Important (crash/security/corruption/deadlock)? **FAIL** as a runtime issue; **PASS** under the build-fix exception.
4. Small and contained? **PASS** — 1 line, 1 file.
5. No new features/APIs? **PASS**.
6. Can apply to this tree? **PASS** — v6.18.53 has the pre-image.
**Step 9.3: Exception**
Record: **Build fix** (compiler warning that becomes a compile error with WERROR).
**Step 9.4: Decision**
This is a one-line, zero-risk workaround for a real gcc 15 false- positive that breaks CONFIG_WERROR builds of a file this 6.18.y tree already ships. It matches the gcc-14 workaround already present here. It meets the build-fix exception and applies cleanly.
---
### What the commit solves for this tree
v6.18.53 still declares upper_index/upper_last uninitialized in regcache_maple_drop(). gcc 15.3.0 (ARC allmodconfig) warns; with WERROR that fails the kernel build. Initializing them to 0, as already done for lower_index/lower_last, silences the diagnostic without changing runtime behavior.
### Risk vs benefit
Benefit is restoring compiles for WERROR/allmodconfig (and silencing the warning otherwise). Risk is a dead store of 0. No prerequisites beyond code already in 6.18.y.
### Verification
- [Phase 1] Parsed tags: Link to msgid, SOBs from Uwe Kleine-König and Mark Brown; no Fixes/Reported-by/Cc: stable
- [Phase 2] Diff: 1 line in regcache_maple_drop(); upper_index, upper_last → = 0
- [Phase 2] Read function: upper_* assigned only when mas.last > max, used only under if (upper)
- [Phase 3] blame: maple cache f033c26de5a57 (v6.4); lower_* init 542440fd7b309 (in this tree)
- [Phase 3] git merge-base --is-ancestor 542440fd7b309 HEAD → yes; dffd32eb2b0e vs v6.18.53 → not ancestor
- [Phase 3] git show 542440fd7b309: same -Werror=uninitialized class for lower_index
- [Phase 4] b4 dig -c dffd32eb2b0e: lore msgid 20260626060427.2548578-2; v1 only; applied for-7.3
- [Phase 4] b4 dig -w: Mark Brown, Greg KH, driver-core CC’d
- [Phase 4] mbox: Mark Brown applied [1/1]; no NAK, no stable Cc
- [Phase 4] WebFetch lore/msgid.link: 403; recovered via openwall + patchew + mbox
- [Phase 5] callers: regcache_ops.drop → regcache_drop_region(); warning is compile-time
- [Phase 6] git describe HEAD / make kernelversion: 6.18.53
- [Phase 6] v6.18.53:drivers/base/regmap/regcache-maple.c still has unsigned long upper_index, upper_last;
- [Phase 7] init/Kconfig: config WERROR default COMPILE_TEST; Makefile.extrawarn adds -Werror
- [Phase 8] Failure mode: compile warning/error, not runtime oops
- UNVERIFIED: whether gcc 15 warns on non-ARC 6.18 allmodconfig (author only reported ARC)
**YES**
drivers/base/regmap/regcache-maple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/regmap/regcache-maple.c +1 -1
@@ -112,7 +112,7 @@ static int regcache_maple_drop(struct regmap *map, unsigned int min,unsigned long *entry, *lower, *upper;/* initialized to work around false-positive -Wuninitialized warning */ unsigned long lower_index =0 , lower_last =0 ; -unsigned long upper_index, upper_last; +unsigned long upper_index =0 , upper_last =0 ;int ret =0 ; lower =NULL ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ASoC: codecs: uda1342: Leave cache-only mode before syncing
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit 29da72e58fde87e632f2fa43e448fcd1e3ab31b0 ]
uda1342_suspend() puts the regmap into cache-only mode. uda1342_resume() marks the cache dirty and syncs it, but does not first leave cache-only mode and ignores sync failures.
Leave cache-only mode before syncing the dirty cache, propagate sync failures, and restore cache-only/dirty state on failure.
---
LLM Generated explanations, may be completely bogus:
The local tree is **v7.3-rc4**. The UDA1342 resume path never left cache-only mode, so after suspend the codec stays cache-only and later register writes never reach hardware.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[ASoC/codecs/uda1342] [Leave / prevent incorrect PM cache state] [Disable cache-only mode before regcache_sync() on resume, and fail resume if sync fails]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS** Record:
- **Fixes:** none (expected for this review)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** none
- **Acked-by:** none
- **Cc: stable:** none (expected)
- **Link:**
https://patch.msgid.link/[email protected]
- **Signed-off-by:** Pengpeng Hou (author); Mark Brown (ASoC maintainer). Ignore any Sasha Levin SOB if present.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** uda1342_suspend() sets regcache_cache_only(..., true). uda1342_resume() marks the cache dirty and calls regcache_sync() without leaving cache-only mode, and ignores the sync return value.
- **Symptom:** After suspend/resume the map stays cache-only, so later regmap writes update only the cache. On this tree, regcache_sync() also WARN_ONs and returns -EINVAL if cache_only is still set.
- **Version info in message:** none
- **Root cause (author):** resume never disables cache-only before sync, and never reports sync failure.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is an explicit PM correctness fix (leave cache-only, propagate errors, restore dirty/cache-only on failure).
===============================================================
PHASE 2: DIFF ANALYSIS
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: sound/soc/codecs/uda1342.c (+8 / -1)
- Function: uda1342_resume()
- Scope: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** regcache_mark_dirty() then regcache_sync() with cache_only still true; return 0 always.
- **After:** regcache_cache_only(..., false), mark dirty, ret = regcache_sync(). On failure, re-enter cache-only, mark dirty, return ret.
- Path: system-sleep resume (and the runtime-resume callback used by pm_runtime_force_resume()).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** logic / PM correctness (cache-only left enabled; ignored error)
- **Mechanism:** suspend enables cache-only. Resume must disable it before sync so writes hit I2C. Leaving it set means _regmap_write() takes the cache-only early return and never calls map->reg_write(). This tree also has WARN_ON(map->cache_only) in regcache_sync(), so the old resume warns and returns -EINVAL without restoring hardware.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Matches the usual ASoC pattern (tas2552_runtime_resume() and many others).
- Minimal, obviously correct.
- Failure unwind matches other codecs: stay cache-only and dirty so a later resume can retry.
- Regression risk is low: one driver, resume path only, no API change.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Buggy resume introduced in de0fb25e37aae (“ASoC: codecs: Add uda1342 codec driver”, Binbin Zhou, 2024-10-09).
- First appeared in **v6.13-rc1**. Present in this 7.3-rc4 tree.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Introducer is de0fb25e37aae, confirmed ancestor of HEAD.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Only four commits on the file: driver add, two i2c_device_id cleanups, then this fix. Standalone, not patch X/Y.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Pengpeng Hou is a regular small-fix contributor, not the UDA1342 author. Original driver is Binbin Zhou (Loongson). Mark Brown applied the patch. Related work around the same time: many ASoC “propagate regcache_sync() errors” patches.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Uses regcache_cache_only / regcache_mark_dirty / regcache_sync, all long-standing. Applies standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 29da72e58fde8 →
https://patch.msgid.link/[email protected]
- b4 dig -a: only **v1**
- Thread: submission + Mark Brown “Applied to sound.git for-7.3”. No NAK, no requested revisions, no reviewer Cc: stable.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai, Linus Walleij, Charles Keepax, Uwe Kleine-König, linux- sound, linux-kernel. Maintainer Mark Brown applied it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by, syzbot, or bugzilla. Bug is from code inspection. Driver was added for **Loongson-2K1000** (7d04763cae994
series: “Add uda1342 codec required on Loongson-2K1000”), so there are real boards, even with no in-tree .dts match for nxp,uda1342.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone v1. Same resume pattern exists across ASoC codecs.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable returned 403. No evidence this was discussed on stable (UNVERIFIED beyond the 403).
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: uda1342_resume(); uda1342_suspend() unchanged.
**Step 5.2: TRACE CALLERS**
Record:
- Wired via DEFINE_RUNTIME_DEV_PM_OPS(uda1342_pm_ops, uda1342_suspend, uda1342_resume, NULL):
- system sleep: pm_runtime_force_suspend / pm_runtime_force_resume
- runtime: uda1342_suspend / uda1342_resume
- .pm = pm_sleep_ptr(&uda1342_pm_ops) so system sleep uses these ops.
- Probe never calls pm_runtime_enable(), so runtime autosuspend is unused. System suspend still calls GET_CALLBACK(dev, runtime_suspend/resume) from pm_runtime_force_* (drivers/base/power/runtime.c).
**Step 5.3: TRACE CALLEES**
Record: regcache_cache_only, regcache_mark_dirty, regcache_sync. Sync uses maple ops (REGCACHE_MAPLE) and _regmap_write.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record:
- Userspace: suspend/resume (or hibernation) with CONFIG_SND_SOC_UDA1342 and a nxp,uda1342 I2C device.
- After a “successful” old resume, uda1342_mute() / uda1342_hw_params() → regmap_update_bits() → _regmap_write() cache-only early return → no I2C write.
- Reachable on real Loongson-2K1000 hardware; not a syscall fuzzer path.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same leave-cache-only-then-sync pattern in many codecs (tas2552.c, wm8962.c, etc.). This driver was the one that omitted it.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- git describe HEAD → **v7.3-rc4-27-gf0100363d8c37**
- make kernelversion → **7.3.0-rc4**
- Driver present: sound/soc/codecs/uda1342.c
- git merge-base --is-ancestor de0fb25e37aae HEAD → yes
- Bug introduced in v6.13-rc1, still in this lineage. Current file already has the fixed resume (expected: this is the mainline commit under review).
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply. Surrounding resume/probe code is the original driver plus trivial i2c_device_id init cleanups. No refactor.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No earlier equivalent fix. Later 86fc3483a4d60 (“regcache:
Warn if regcache_sync() is called in cache_only mode”, also v7.3-rc1) makes the old resume a WARN_ON + -EINVAL on this tree.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **ASoC codec driver** (sound/soc/codecs/). Criticality:
**PERIPHERAL** (one NXP codec, Loongson-2K1000). Not core mm/fs/net.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: ASoC codecs are actively developed. This file itself is quiet (four commits). Mature for this driver: the PM bug was present from introduction.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Users of **CONFIG_SND_SOC_UDA1342** / nxp,uda1342 (documented for Loongson-2K1000). Driver- and config-specific, not universal.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Trigger: system suspend/resume with this codec.
- Common on any machine that sleeps.
- Not an unprivileged syscall exploit path.
- Not a timing race.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- On this tree: WARN_ON in regcache_sync() and resume returns -EINVAL → hardware not restored.
- Even without that warn: cache-only left set → mute/volume/hw_params never programmed to the chip; audio broken after resume.
- Severity: **HIGH** for those devices (broken audio / failed resume), not a panic or filesystem corruption.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** medium-high for UDA1342 boards; zero elsewhere.
- **Risk:** very low (8 lines, one function, standard pattern).
- **Ratio:** favorable.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real suspend/resume bug: cache-only never cleared, so post-resume register writes never hit I2C.
- On this 7.3-rc4 tree, regcache_sync() additionally WARNs and fails if cache-only is still set.
- Small, surgical, matches other ASoC codecs; maintainer applied v1 with no objections.
- Driver exists here since v6.13; no extra prerequisites.
- Error return lets the PM core fail resume instead of pretending it succeeded.
AGAINST:
- Peripheral codec, no in-tree DTS, no user/syzbot report.
- Author is not the original driver author; no Tested-by.
- Not a security/UAF/deadlock class issue.
UNRESOLVED:
- Stable list search on lore returned 403.
- No public confirmation of a user-reproduced resume failure (code analysis only).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — standard pattern; applied by Mark Brown. No extra tester tag.
2. Fixes a real bug that affects users? **PASS** — resume leaves the codec in cache-only; Loongson-2K1000 uses this codec.
3. Important issue? **PASS** — broken audio / failed resume after sleep; WARN_ON on this tree. Not a panic, but user-visible PM breakage.
4. Small and contained? **PASS** — 8 insertions, 1 deletion, one function.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — file and helpers exist; context matches.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not a device ID / DT / build / docs exception). It is a normal small bug fix.
**Step 9.4: MAKE YOUR DECISION**
This tree has the UDA1342 driver and the broken resume. The patch is the usual, low-risk ASoC fix: leave cache-only, sync, report errors. That is appropriate to backport here.
**What the commit solves for this tree:** After suspend, resume never turns cache-only off. Sync then either WARNs/-EINVAL (this 7.3 code) or leaves later regmap writes stuck in the cache. Audio after sleep is wrong. The patch restores hardware and reports I2C/sync failure.
**Stable rules:** Small, obviously correct, no new API, applies cleanly, real PM bug.
**Risk vs benefit:** Very low regression risk vs fixing resume for this codec.
**Concerns:** Niche hardware, no tester tag. Not enough to reject a 9-line resume fix whose code is present in this checkout.
Verification:
- [Phase 1] Parsed tags: Link to msgid 20260704072140.67222-1; SOBs Hou and Brown; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: uda1342_resume() +8/-1; add regcache_cache_only(false), check regcache_sync(), unwind on error
- [Phase 2] _regmap_write(): cache_only + !cache_bypass returns 0 without reg_write (verified in drivers/base/regmap/regmap.c)
- [Phase 2] regcache_sync(): WARN_ON(map->cache_only) returns -EINVAL (verified line 437 of regcache.c)
- [Phase 3] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion: 7.3.0-rc4
- [Phase 3] git blame on parent: buggy resume is de0fb25e37aae (v6.13-rc1)
- [Phase 3] git merge-base --is-ancestor de0fb25e37aae HEAD: yes
- [Phase 3] git merge-base --is-ancestor 29da72e58fde8 HEAD: yes (mainline commit under review)
- [Phase 3] File log: four commits, no series dependency
- [Phase 4] b4 dig -c 29da72e58fde8: lore msgid match; -a: v1 only; -w: ASoC maintainers CC’d; mbox: Brown applied, no NAK
- [Phase 4] lore.kernel.org/stable: 403 — UNVERIFIED
- [Phase 5] DEFINE_RUNTIME_DEV_PM_OPS + pm_sleep_ptr; pm_runtime_force_suspend/resume call the runtime callbacks
- [Phase 5] Probe does not pm_runtime_enable() — system sleep still uses pm_runtime_force_*
- [Phase 5] 7d04763cae994: driver added for Loongson-2K1000
- [Phase 6] Pre-fix resume read from 29da72e58fde8^: mark dirty + sync, no cache_only(false)
- [Phase 6] WARN_ON added in 86fc3483a4d60 (v7.3-rc1), present in this tree
- [Phase 8] Failure: WARN + failed resume / cache-only stuck; severity HIGH for this device
- UNVERIFIED: whether this was already requested on the stable list (HTTP 403)
**YES**
sound/soc/codecs/uda1342.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
sound/soc/codecs/uda1342.c +8 -1
@@ -308,9 +308,16 @@ static int uda1342_suspend(struct device *dev)static int uda1342_resume (struct device *dev) {struct uda1342_priv *uda1342 =dev_get_drvdata (dev); +int ret; +regcache_cache_only (uda1342->regmap, false);regcache_mark_dirty (uda1342->regmap); -regcache_sync (uda1342->regmap); + ret =regcache_sync (uda1342->regmap); +if (ret) { +regcache_cache_only (uda1342->regmap, true); +regcache_mark_dirty (uda1342->regmap); +return ret; + }return 0 ; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: iwlwifi: mld: validate D3_END notif size
In reply to Sasha LevinFrom: Emmanuel Grumbach <[email protected]>
[ Upstream commit 4e777dcdfe70d9b3ddf38cb49de9e30306889b18 ]
Check D3_END_NOTIFICATION payload length before reading notif->flags. On short payloads, mark notif handling as failed.
Avoid out-of-bounds reads from malformed notifications.
---
LLM Generated explanations, may be completely bogus:
Local tree is **Linux 7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The iwlwifi MLD D3 resume path is present here, and this is a small bounds check that stops an out-of-bounds read of firmware notification data.
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
Record: **[iwlwifi/mld]** **[validate]** Check D3_END_NOTIFICATION payload size before reading notif->flags.
**Step 1.2 — Tags**
Record:
- Assisted-by: GitHubCopilot:gpt-5.3-codex
- Signed-off-by: Emmanuel Grumbach <[email protected]> (author)
- `Link: https://patch.msgid.link/20260714165826.db2df8b6b6bb.I6163bbdf4
33379bf1dbf9eb46fb9562892217bd7@changeid`
- Signed-off-by: Miri Korenblit <[email protected]> (iwlwifi maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, `Cc:
stable` (absence of Fixes/Cc-stable is expected for this review)
- Sasha Levin SOB ignored per pipeline rules
**Step 1.3 — Body**
Record: Firmware D3_END_NOTIFICATION payload length is not checked before le32_to_cpu(notif->flags). A short payload is an out-of-bounds read. On failure, handling is marked failed (notif_handling_err).
Symptom: OOB read of firmware RX data during D3/WoWLAN resume. No stack trace, reproducer, or version range in the message. Root cause: missing length check vs sizeof(struct iwl_d3_end_notif).
**Step 1.4 — Hidden bug fix?**
Record: Not hidden. The subject/body state a bounds check to avoid OOB reads. Copilot assistance does not change that.
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
Record:
- File: drivers/net/wireless/intel/iwlwifi/mld/d3.c (+9 / −1)
- Function: iwl_mld_handle_d3_notif()
- Scope: single-file, one switch case (WIDE_ID(PROT_OFFLOAD_GROUP, D3_END_NOTIFICATION))
**Step 2.2 — Control flow**
Record: Before, the handler always did resume_data->d3_end_flags = le32_to_cpu(notif->flags) from pkt->data with no length check, then set IWL_D3_NOTIF_D3_END_NOTIF. After, it computes len = iwl_rx_packet_payload_len(pkt) and uses IWL_FW_CHECK(mld, len < sizeof(*notif), ...). Short payload: log, set notif_handling_err = true, skip the flags read. Valid payload: same flags assignment as before. In both cases it still sets IWL_D3_NOTIF_D3_END_NOTIF so the wait completes. Error path only for truncated firmware notifications.
**Step 2.3 — Bug mechanism**
Record: **Memory safety / out-of-bounds read.** struct iwl_d3_end_notif is a packed __le32 flags (4 bytes). Reading notif->flags when payload_len < 4 reads past the declared RX payload. Same class of check already used in mvm/d3.c.
**Step 2.4 — Fix quality**
Record: Obviously correct: compare payload length to sizeof(*notif) before dereference, using existing IWL_FW_CHECK / iwl_rx_packet_payload_len. Surgical, no API change. Regression risk is
low: valid 4-byte notifications behave as before. Truncated ones fail resume with -EIO via notif_handling_err instead of using garbage d3_end_flags (which can spuriously set or miss IWL_D0I3_RESET_REQUIRE). The API struct always includes flags; MVM already rejects short D3_END payloads, so empty notifications are not a valid firmware contract.
## Phase 3: Git history
**Step 3.1 — Blame**
Record: Unchecked notif->flags read was introduced with d1e879ec600f9 (wifi: iwlwifi: add iwlmld sub-driver, 2025-02-16). git describe --tags d1e879ec600f9 → v6.14-rc4-1062-gd1e879ec600f9 (iwlmld landed for ~6.15). The bug has been in this driver since it was added.
**Step 3.2 — Fixes: tag**
Record: No Fixes: tag. Introducing commit is d1e879ec600f9, which **is** an ancestor of this tree (git merge-base --is-ancestor succeeded).
**Step 3.3 — Related file history**
Record: Same-day MVM sibling c1a1dc162870a (`wifi: iwlwifi: mvm: d3:
validate D3 resume notification payloads) documents “buffer underread on malformed or truncated notifications.” Later MLD D3 checks (validate WoWLAN notif header, wake-packet reads) are independent siblings, not prerequisites. Follow-up 4f5384b58b483` disconnects on D3 resume failure; this patch does not depend on it.
**Step 3.4 — Author**
Record: Emmanuel Grumbach is a long-time iwlwifi developer. Applied by maintainer Miri Korenblit. Same author wrote the MVM D3 payload validation.
**Step 3.5 — Dependencies**
Record: Standalone. Uses existing iwl_rx_packet_payload_len (iwl- trans.h), IWL_FW_CHECK (fw/dbg.h, included by d3.c; macro since 568db7fd27fad / ~v6.5), notif_handling_err, and struct iwl_d3_end_notif. No new helpers. It was **09/15** in an iwlwifi-next bundle of mixed fixes/features; this hunk has no code dependency on the other 14 patches.
## Phase 4: Mailing list / external research
**Step 4.1 — Original discussion**
Record: b4 dig -c 4e777dcdfe70d → https://patch.msgid.link/20260714165
826.db2df8b6b6bb.I6163bbdf433379bf1dbf9eb46fb9562892217bd7@changeid b4 dig -a: v1 and **v2**; applied version is **v2** [PATCH v2 iwlwifi-next 09/15]. Cover letter: “Usual fixed, cleanups and features from our internal tree.” v2 only resends after iwlwifi-next contained an unrelated compile-time hcmd-size check. No NAK, no reviewer concern, no Cc: stable on this patch. Direct lore.kernel.org fetch returned **403**; thread recovered via b4 dig -m.
**Step 4.2 — Recipients (b4 dig -w)**
Record: To Johannes Berg ([email protected]); Cc linux- [email protected], Emmanuel Grumbach. Correct wireless/iwlwifi audience. This patch itself has no extra Reviewed-by (unlike some series mates). Maintainer SOB is present.
**Step 4.3 — Bug report**
Record: No Reported-by, syzbot, or bugzilla. Firmware-malformed- notification hardening, not a user crash report.
**Step 4.4 — Series**
Record: 15-patch iwlwifi-next dump. This patch is an isolated length check in one case of iwl_mld_handle_d3_notif. Other patches add device IDs, LARI v14, TCM removal, etc. Not a multi-step refactor of this function.
**Step 4.5 — Stable list**
Record: lore.kernel.org/stable WebFetch returned **403**. No stable discussion in the saved mbox. **UNVERIFIED:** whether anyone already nominated this on stable@.
## Phase 5: Code semantic analysis
**Step 5.1 — Functions**
Record: iwl_mld_handle_d3_notif() only.
**Step 5.2 — Callers**
Record: Registered as the notification-wait callback from iwl_mld_wait_d3_notif(), itself called by:
- iwl_mld_no_wowlan_resume() → iwl_mld_mac80211_start() when fw_status.in_d3 (mac80211.c)
- iwl_mld_wowlan_resume() → iwl_mld_resume() mac80211 resume op
Context: process context, suspend/resume, CONFIG_PM_SLEEP (mld/Makefile: iwlmld-$(CONFIG_PM_SLEEP) += d3.o).
**Step 5.3 — Callees**
Record: iwl_rx_packet_payload_len(), IWL_FW_CHECK → IWL_ERR_LIMIT, le32_to_cpu(). No allocation, no new locks.
**Step 5.4 — Reachability**
Record: Yes, from userspace via suspend/resume (S3/WoWLAN) on Intel Wi- Fi 7 / MLD (CONFIG_IWLMLD). Unprivileged users typically cannot inject firmware RX payloads; trigger is firmware (or a compromised device). Still a real kernel OOB if firmware truncates the notif.
**Step 5.5 — Similar patterns**
Record: MVM iwl_mvm_wait_d3_notif already checks len < sizeof(*notif) before notif->flags. Other iwlwifi handlers use IWL_FW_CHECK(..., pkt_len < sizeof(...)). This closes a gap in the newer MLD copy of D3 resume.
## Phase 6: Local tree (7.3.0-rc4)
**Step 6.1 — Buggy code here?**
Record: Yes. drivers/net/wireless/intel/iwlwifi/mld/d3.c exists; iwl_mld_handle_d3_notif handles D3_END_NOTIFICATION. Pre-patch parent shows the unguarded le32_to_cpu(notif->flags). Bug introduced with iwlmld (d1e879ec600f9), ancestor of HEAD.
**Step 6.2 — Backport difficulty**
Record: Clean apply. Surrounding case statement matches the candidate diff. IWL_FW_CHECK and notif_handling_err are already in this tree.
**Step 6.3 — Related fixes already here?**
Record: No earlier MLD D3_END size check. MVM has its own check (c1a1dc162870a); that does not cover MLD.
## Phase 7: Subsystem / maintainer
**Step 7.1**
Record: **iwlwifi MLD** (drivers/net/wireless/intel/iwlwifi/mld/). **IMPORTANT** (not core mm/fs, but a widely used Intel Wi-Fi driver on current hardware). D3.c is only built with CONFIG_PM_SLEEP.
**Step 7.2**
Record: Active (frequent iwlwifi-next dumps). D3_END handling itself has been stable since the sub-driver was added.
## Phase 8: Impact and risk
**Step 8.1 — Who is affected**
Record: Users of Intel Wi-Fi MLD (CONFIG_IWLMLD) who suspend/resume or use WoWLAN. Driver- and config-specific, not universal.
**Step 8.2 — Trigger**
Record: D3 resume when firmware delivers D3_END_NOTIFICATION with payload < 4 bytes. Uncommon if firmware is healthy; realistic on firmware bugs. Not a normal userspace syscall; firmware-sourced.
**Step 8.3 — Failure mode**
Record: Out-of-bounds read of RX buffer / declared payload. Can be KASAN OOB, garbage d3_end_flags (wrong reset-on-resume), or a crash if the buffer is tightly sized. **Severity: HIGH** (OOB; resume correctness). Not a guaranteed panic on every resume.
**Step 8.4 — Risk vs benefit**
Record: **Benefit: high** for MLD laptop suspend/resume — prevents OOB and acting on garbage reset flags. **Risk: very low** — 9 lines, error path only, same pattern as MVM. Ratio favors backport.
## Phase 9: Synthesis
**Step 9.1 — Evidence**
For:
- Real OOB read of firmware notification payload
- Small, obviously correct check (len < sizeof(*notif))
- Matches established iwlwifi/IWL_FW_CHECK and MVM D3 handler
- D3/WoWLAN resume is a common path on laptops
- Garbage flags can mis-handle IWL_D0I3_RESET_REQUIRE
- Maintainer-applied; Johannes/linux-wireless were CCed
- Applies cleanly; no prerequisites missing in 7.3-rc4
- iwlmld and the buggy handler exist in this tree
Against:
- No user/syzbot report; Copilot-assisted
- Trigger needs truncated firmware, not a normal station
- Mixed 15-patch “updates” series, not explicitly Cc: stable
- No extra Reviewed-by on this patch
Unresolved:
- lore.kernel.org HTTP 403; stable@ search not confirmed beyond the mbox
**Step 9.2 — Stable rules**
1. Obviously correct and tested? **PASS** — length check before dereference; applied to iwlwifi-next by the maintainer.
2. Real bug affecting users? **PASS** — OOB on truncated D3_END; MLD D3 resume is a real path.
3. Important (crash/security/corruption/deadlock)? **PASS** — OOB read / possible bad resume flags; HIGH, not theoretical style-only.
4. Small and contained? **PASS** — +9/−1, one function, one case.
5. No new features/APIs? **PASS**.
6. Can apply to this tree? **PASS** — files, macros, and structures exist.
**Step 9.3 — Exceptions**
Record: Not a device-ID/quirk/DT/build/docs exception. It is a straightforward memory-safety fix.
**Step 9.4 — Decision**
This tree is 7.3-rc4 and contains iwlmld D3 resume. The patch is a 9-line firmware notification bounds check that stops an OOB read and avoids using garbage d3_end_flags. It meets stable criteria for this checkout.
### What it solves for this tree
On Intel MLD Wi-Fi, D3/WoWLAN resume handled D3_END_NOTIFICATION by reading a 4-byte flags field without checking payload length. A short firmware notification reads past valid RX data and can drive wrong reset-on-resume behavior. The fix logs via IWL_FW_CHECK, sets notif_handling_err (resume returns -EIO), and only then skips the flags read.
### Risk vs benefit
Benefit is preventing OOB and incorrect D3 resume on CONFIG_IWLMLD + CONFIG_PM_SLEEP. Risk is negligible: valid notifications are unchanged.
## Verification
- [Phase 1] Parsed tags: author Grumbach, maintainer Korenblit SOB, msgid.link; no Fixes/Reported-by/Cc-stable
- [Phase 2] Diff: +9/−1 in iwl_mld_handle_d3_notif D3_END case; length check then optional le32_to_cpu(notif->flags)
- [Phase 2] struct iwl_d3_end_notif is __le32 flags only (fw/api/d3.h)
- [Phase 2] IWL_FW_CHECK defined in fw/dbg.h; included from mld/d3.c
- [Phase 2] notif_handling_err forces ret = -EIO in iwl_mld_wait_d3_notif
- [Phase 2] d3_end_flags & IWL_D0I3_RESET_REQUIRE used in no-wowlan and wowlan resume
- [Phase 3] git describe HEAD / make kernelversion: **7.3.0-rc4**
- [Phase 3] Blame: unguarded read from d1e879ec600f9 (iwlmld add, ~v6.15)
- [Phase 3] git merge-base --is-ancestor d1e879ec600f9 HEAD: yes
- [Phase 3] Pre-patch: git show 4e777dcdfe70d^:.../mld/d3.c shows unguarded flags read
- [Phase 3] MVM sibling c1a1dc162870a same-day D3 payload validation
- [Phase 3] IWL_FW_CHECK from 568db7fd27fad (~v6.5)
- [Phase 4] b4 dig -c/-a/-w/-m: v2 09/15, linux-wireless + Johannes; no NAK in mbox
- [Phase 4] Cover letter: mixed iwlwifi-next updates; this patch listed under Grumbach fixes
- [Phase 4] UNVERIFIED: lore.kernel.org and stable@ HTTP 403
- [Phase 5] Callers: iwl_mld_no_wowlan_resume / iwl_mld_wowlan_resume from mac80211 start/resume
- [Phase 5] mld/Makefile: d3.o only with CONFIG_PM_SLEEP; CONFIG_IWLMLD
- [Phase 6] Buggy handler present; apply would be clean
- [Phase 8] Failure mode: OOB read of D3_END payload / garbage reset flags, severity HIGH
**YES**
drivers/net/wireless/intel/iwlwifi/mld/d3.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mld/d3.c +9 -1
@@ -1326,8 +1326,16 @@ static bool iwl_mld_handle_d3_notif(struct iwl_notif_wait_data *notif_wait, }case WIDE_ID (PROT_OFFLOAD_GROUP ,D3_END_NOTIFICATION ): {struct iwl_d3_end_notif *notif = (void *)pkt->data; +u32 len =iwl_rx_packet_payload_len (pkt); + +if (IWL_FW_CHECK (mld, len <sizeof (*notif), +"Invalid D3_END notification (expected=%zu got=%u)\n" , +sizeof (*notif), len)) { + resume_data->notif_handling_err = true; + }else { + resume_data->d3_end_flags =le32_to_cpu (notif->flags); + } - resume_data->d3_end_flags =le32_to_cpu (notif->flags); resume_data->notifs_received |=IWL_D3_NOTIF_D3_END_NOTIF ;break ; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: mt76: mt7603: free beacon SKB on error
In reply to Sasha LevinFrom: David Bauer <[email protected]>
[ Upstream commit 965cbdbdfbd37a659a05ff88e49c216975bd9d2e ]
The SKB containing the generated beacon is not freed when the beacon queue is deected stuck and scheduled for recovery.
Fixes potential memory leaks in case the beacon queue is detected stuck.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.6.157** (pending-6.6). The two-line SKB leak is present here, was introduced by a commit already in this tree, and applies cleanly.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[wifi: mt76: mt7603]** **[free]** **[free the generated beacon SKB when queue-stuck recovery bails out]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected for this pipeline)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** none
- **Acked-by:** none
- **Link:** https://patch.msgid.link/20260611215658.259324-1-mail@david- bauer.net
- **Cc: stable:** none (expected)
- **Signed-off-by:** David Bauer (author); Felix Fietkau (mt76 maintainer). Ignore any Sasha Levin SOB if present in candidate wrapping.
Mainline SHA (from origin/master):965cbdbdfbd37a659a05ff88e49c216975bd9d2e
AuthorDate: 2026-06-11; applied by Felix Fietkau 2026-07-31.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** After ieee80211_beacon_get(), if mt76_poll() times out on MT_DMA_FQCR0 (beacon/BMC queue flush stuck), the function goto out without freeing the SKB.
- **Symptom:** SKB leak whenever the beacon queue is detected stuck and recovery is scheduled. Commit message typo: “deected”.
- **Version info:** none in the message.
- **Root cause (author):** beacon SKB not freed on the stuck-queue error path.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. Explicit leak fix: two dev_kfree_skb(skb) calls on error paths.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/net/wireless/mediatek/mt76/mt7603/beacon.c (**+2 / -0**)
- Function: mt7603_update_beacon_iter()
- Scope: **single-file surgical fix**
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record (both hunks, same pattern):
Before: ieee80211_beacon_get() allocates skb. Flush BCN or BMC via MT_DMA_FQCR0. If poll times out: set dev->beacon_check = MT7603_WATCHDOG_TIMEOUT and goto out. Unlock. **SKB never queued and never freed.**
After: same, but dev_kfree_skb(skb) before goto out.
Success path unchanged: mt76_tx_queue_skb() still takes ownership.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** error-path resource leak (SKB)
- **Mechanism:** mac80211 docs: *“The driver is responsible for freeing the returned skb.”* Error goto skipped both queueing and free. Fix adds the missing free.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct; only the two error returns; no API/lock/structure change.
- **Regression risk:** very low. Success path still hands the SKB to DMA. dev_kfree_skb is consume_skb (stats slightly less precise than kfree_skb on a drop); maintainer accepted it. No double-free:
frees only happen before queueing.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Leak goto out introduced by **8caa9dd3d1a7c9** “wifi: mt76:
mt7603: improve stuck beacon handling” (Greg KH, 2023-11-20), stable rewrite of upstream **3176205933494** (Felix Fietkau, 2023-07-28).
- ieee80211_beacon_get(..., 0) from 6e8912a503759 (MLO 3-arg API); already in this tree.
- Driver added in c8846e1015022 (2018). Pre-2023 code queued the SKB even if poll failed; the 2023 change moved queueing after the polls and added the leaky goto.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Buggy commit in **this** tree is 8caa9dd3d1a7c9 (git merge-base --is-ancestor = yes). Upstream 3176205933494 is not an ancestor (stable SHA rewrite). No later origin/master commits touch this file after 965cbdbdfbd37.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record (this tree, path-limited): last functional change on this file is the stuck-beacon commit itself. Standalone; not patch X/Y.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: David Bauer already has mt76 commits in this tree (including mt7603 EEPROM ID). Felix Fietkau is listed maintainer and applied the patch.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Same function, same ieee80211_beacon_get(hw, vif, 0), same poll/goto out. git apply --check of 965cbdbdfbd37 succeeded. Standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 965cbdbdfbd37 →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only**
- Thread mbox: patch only, **no replies**, no NAK, no reviewer Cc:
stable
- lore.kernel.org WebFetch: **403** (used b4 + openwall/patchew mirrors)
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc included Felix Fietkau, Lorenzo Bianconi, MediaTek mt76 reviewers, linux-wireless. Applied by Felix with his SOB. No Reviewed-by.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by, syzbot, or bugzilla. Author-found leak on code inspection. Openwall/Ratatoskr confirm the same v1 text, no discussion.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone [PATCH mt76]. No series. No follow-up on origin/master for this file.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable WebFetch **403**. No stable discussion in the saved thread. UNVERIFIED whether anyone already asked stable@; absence is not a negative signal.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
semcode MCP: **not available**. Used grep/read.
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: mt7603_update_beacon_iter() only.
**Step 5.2: TRACE CALLERS**
Record:
- Called from mt7603_pre_tbtt_tasklet() via ieee80211_iterate_active_interfaces_atomic().
- Tasklet scheduled from mt7603_irq_handler() on MT_HW_INT3_PRE_TBTT0.
- Reachable whenever the device is an AP with beacons enabled (beacon_mask).
**Step 5.3: TRACE CALLEES**
Record: ieee80211_beacon_get (driver owns SKB), mt76_poll/mt76_wr, mt76_tx_queue_skb → mt76_dma_tx_queue_skb (takes SKB; error path uses ieee80211_tx_status_ext).
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: userspace/AP stack enables beaconing → hardware pre-TBTT IRQ → tasklet → iterator. Unprivileged clients do not trigger it directly; **any AP/router using this chip in AP mode can**. Stuck DMA/FQCR0 is the error trigger. mac_work runs every MT7603_WATCHDOG_TIME (100 ms) and treats beacon_check >= 10 as RESET_CAUSE_BEACON_STUCK.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Other mt76 chips use ieee80211_beacon_get_template / mt76x02_mac_set_beacon and do not share this FQCR0 poll/goto out pattern. mt76x02 has no equivalent leak.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** drivers/net/wireless/mediatek/mt76/mt7603/beacon.c lines 57–66: poll timeout → set watchdog → goto out with no free.
Local: git describe → p-6.6-3-g04810563abb71, make kernelversion → **6.6.157**. Bug since 8caa9dd3d1a7c9 (stuck-beacon handling). Candidate 965cbdbdfbd37 is **not** an ancestor of HEAD.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** (git show 965cbdbdfbd37 | git apply --check). Surrounding function matches mainline hunks.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No other “free beacon SKB” commit. Other mt76 leak fixes (ec4a608bca405 probe leak, etc.) are unrelated.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **wifi / mt76 / mt7603** (CONFIG_MT7603E: MT7603E PCIe and MT7628/MT7688 SoC WLAN). **IMPORTANT** for those devices (common OpenWrt APs), not CORE for every 6.6 user.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature driver (2018); this file is quiet. Bug is old (2023 stuck-beacon change), not a new-feature side effect.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / config-specific:** CONFIG_MT7603E, AP/beaconing. MT7628/MT7688 SoCs are widely deployed in consumer routers.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Trigger: FQCR0 poll timeout (5 ms) while updating beacons — the same stuck-beacon condition this driver already recovers from.
- Frequency: pre-TBTT (~beacon interval, typically ~100 ms) per AP vif (up to 4). Watchdog work every 100 ms usually resets after one such event, so **~1 SKB per vif per stuck incident** if recovery works; **recurring** if the MAC stays stuck.
- Unprivileged trigger: no (AP beacon path).
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **SKB leak**, not oops/UAF/corruption. **MEDIUM** (HIGH only if stuck-beacon storms on a low-RAM AP). Still a real leak on a path already considered serious enough to backport.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** stops leaking beacon frames on a known hardware-stuck path.
- **Risk:** very low (2 lines, error path only, clean apply).
- **Ratio:** favor backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Confirmed leak vs mac80211 SKB ownership.
- Buggy code is in this 6.6.157 tree (8caa9dd3d1a7c9).
- +2 lines, obviously correct, clean apply, no deps.
- Maintainer-applied.
- Same recovery path that already justified a stable backport.
- MT7603/MT76x8 used on production APs.
AGAINST:
- Error-path leak; volume per incident is small if watchdog resets.
- No crash/CVE/syzbot/user report.
- No Reviewed-by; mailing list silent.
- Not a core-kernel path.
UNRESOLVED:
- lore.kernel.org HTTP 403; stable@ search not fetched (b4/mbox used instead).
- Exact leak rate if reset fails repeatedly: not measured on hardware.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — ownership is documented; maintainer applied. No extra Tested-by.
2. Fixes a real bug that affects users? **PASS** — SKB leak on stuck- beacon recovery.
3. Important issue? **PASS** — resource leak on a periodic AP path (not a one-shot init leak). Severity medium, not a panic.
4. Small and contained? **PASS** — 2 lines, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — verified with git apply --check.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary small leak fix.
**Step 9.4: MAKE YOUR DECISION**
This is a two-line error-path kfree for a leak that exists in 6.6.157, introduced by a stuck-beacon change already on this branch. Risk is negligible; benefit is stopping SKB leaks on MT7603/MT76x8 APs when the beacon DMA path wedges. That meets stable rules for this tree.
------------------------------------------------
What the commit solves for this tree
------------------------------------------------
In mt7603_update_beacon_iter(), ieee80211_beacon_get() returns an SKB the driver must free. On FQCR0 poll timeout the function sets the beacon watchdog and returns without queueing or freeing. That path is the stuck-beacon recovery added in 8caa9dd3d1a7c9, which is already here. Each timeout leaks one beacon SKB per AP interface. The patch only adds dev_kfree_skb(skb) on those two returns.
Risk vs benefit: almost no regression surface; the leak is real whenever that recovery runs.
------------------------------------------------
Verification
------------------------------------------------
- [Phase 1] Tags: Link msgid 20260611215658.259324-1-mail@david- bauer.net; SOBs David Bauer + Felix Fietkau; no Fixes/Reported- by/Cc:stable.
- [Phase 1] Mainline commit 965cbdbdfbd37 on origin/master.
- [Phase 2] Diff: +2 dev_kfree_skb(skb) in mt7603_update_beacon_iter poll-fail paths; success path still mt76_tx_queue_skb.
- [Phase 2] include/net/mac80211.h: “The driver is responsible for freeing the returned skb.”
- [Phase 2] dev_kfree_skb → consume_skb in include/linux/skbuff.h.
- [Phase 3] git blame: leaky goto out from 8caa9dd3d1a7c9 (stable form of 3176205933494).
- [Phase 3] git merge-base --is-ancestor 8caa9dd3d1a7c9 HEAD → yes; 965cbdbdfbd37 → no; 3176205933494 → no (rewritten).
- [Phase 3] git show 8caa9dd3d1a7c9: moved mt76_tx_queue_skb after polls and added goto out without free.
- [Phase 4] b4 dig -c 965cbdbdfbd37: v1 only; no replies in mbox.
- [Phase 4] b4 dig -w: mt76 maintainers + linux-wireless on To/Cc.
- [Phase 4] lore WebFetch 403; openwall/patchew/ratatoskr match v1, no review replies.
- [Phase 5] Caller: mt7603_pre_tbtt_tasklet ← mt7603_irq_handler PRE_TBTT0.
- [Phase 5] Watchdog: MT7603_WATCHDOG_TIME 100 ms, timeout 10; mt7603_mac_work uses beacon_check with check == NULL.
- [Phase 6] git describe HEAD → p-6.6-3-g04810563abb71; make kernelversion → 6.6.157.
- [Phase 6] Local beacon.c still missing the kfrees (lines 57–66).
- [Phase 6] git apply --check of 965cbdbdfbd37 succeeded.
- [Phase 7] CONFIG_MT7603E; MAINTAINERS: Felix Fietkau.
- [Phase 8] Failure mode: SKB leak on stuck-beacon recovery; severity MEDIUM.
- UNVERIFIED: stable@ mailing-list archive (HTTP 403); hardware leak rate if reset keeps failing.
**YES**
drivers/net/wireless/mediatek/mt76/mt7603/beacon.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7603/beacon.c +2 -0
@@ -56,6 +56,7 @@ mt7603_update_beacon_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) FIELD_PREP(MT_DMA_FQCR0_TARGET_QID, MT_TX_HW_QUEUE_BCN));if (!mt76_poll (dev,MT_DMA_FQCR0 ,MT_DMA_FQCR0_BUSY ,0 ,5000 )) { dev->beacon_check =MT7603_WATCHDOG_TIMEOUT ; +dev_kfree_skb (skb); goto out; }
@@ -63,6 +64,7 @@ mt7603_update_beacon_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) FIELD_PREP(MT_DMA_FQCR0_TARGET_QID, MT_TX_HW_QUEUE_BMC));if (!mt76_poll (dev,MT_DMA_FQCR0 ,MT_DMA_FQCR0_BUSY ,0 ,5000 )) { dev->beacon_check =MT7603_WATCHDOG_TIMEOUT ; +dev_kfree_skb (skb); goto out; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 net/rds: unpin MR pages with unpin_user_pages_dirty_lock()
In reply to Sasha LevinFrom: Allison Henderson <[email protected]>
[ Upstream commit a507023e6ff1d0b4e7aac49b2f547fed0c21ea4e ]
The pages backing an RDS memory region are pinned in __rds_rdma_map() with rds_pin_pages(), which uses pin_user_pages_fast(): each page's refcount is biased by GUP_PIN_COUNTING_BIAS to account the pin. The scatterlist is then handed to the IB transport, and the transport releases the pages in __rds_ib_teardown_mr() with
set_page_dirty(page); put_page(page);
put_page() drops a single reference instead of removing the pin bias, so every MR teardown permanently strands the remaining references and the pages are never freed - a userspace-triggerable memory leak of up to RDS_MAX_MSG_SIZE per RDS_GET_MR/RDS_GET_MR_FOR_DEST call.
The conversion to the pin API updated the unpin sites in rdma.c but missed this one on the transport side. Release the pages with unpin_user_pages_dirty_lock(), which removes the pin bias and also dirties the page under the folio lock, closing the truncation race that a bare set_page_dirty() leaves open.
Dirtying under the folio lock can sleep, which is safe in every path that reaches __rds_ib_teardown_mr(): the registration-reuse path (rds_ib_map_frmr()) runs in syscall context, and the pool flush (rds_ib_unreg_frmr()) runs under pool->flush_lock, a mutex, and already sleeps in rds_ib_post_inv(). The WARN_ON that guarded the old irq-context set_page_dirty() case is dropped along with it.
---
LLM Generated explanations, may be completely bogus:
The local tree is **5.10.270** (pending-5.10). The buggy RDS IB teardown path is present here, the pin API mismatch is real, and the fix applies cleanly.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[net/rds] [unpin] [release MR pages with the pin-API unpin helper instead of put_page()]**
Subsystem prefix net/rds. Action verb is unpin (correctness of page release, not a feature). Claimed intent: MR pages pinned with pin_user_pages_fast() must be released with unpin_user_pages_dirty_lock(), not put_page().
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
From the candidate message:
- Signed-off-by: Allison Henderson <[email protected]> (author; Oracle RDS)
- `Link:
https://patch.msgid.link/[email protected]`
- Signed-off-by: Jakub Kicinski <[email protected]> (netdev merge)
- No Reported-by, Tested-by, Reviewed-by, Acked-by, Cc: stable in the candidate text
From the original lore submission (msgid [email protected]), these additional tags were present and stripped by candidate prep:
- Fixes: 0d4597c8c5ab ("net/rds: Track user mapped pages through special API")
- Assisted-by: Claude-Code:claude-fable-5
Record: Author is the RDS contributor who submitted a 4-patch bug-fix series. Netdev maintainer merged it. Original submission carried a Fixes: tag pointing at the 2020 pin-API conversion. Absence of `Cc:
stable` on the candidate is expected.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** __rds_rdma_map() pins pages with rds_pin_pages() → pin_user_pages_fast(). Teardown in __rds_ib_teardown_mr() does set_page_dirty() + put_page(). put_page() drops one ref; a FOLL_PIN pin adds GUP_PIN_COUNTING_BIAS (1024). Remaining refs are stranded.
- **Symptom:** Userspace-triggerable unreclaimable page leak, up to RDS_MAX_MSG_SIZE (1 MiB) per RDS_GET_MR / RDS_GET_MR_FOR_DEST. Same leak on every MR reuse/flush, not only the ioctl.
- **Root cause:** Pin-API conversion updated net/rds/rdma.c unpin sites and missed the IB transport teardown path.
- **Secondary fix:** unpin_user_pages_dirty_lock() dirties under the page/folio lock, closing the truncation race of bare set_page_dirty().
- **Sleeping:** Author claims every caller of __rds_ib_teardown_mr() is process context (syscall reuse path, or pool flush under flush_lock mutex which already wait_events in rds_ib_post_inv()).
- **Version info:** Bug introduced by the 2020 pin conversion (0d4597c8c5ab).
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Explicit memory-leak fix with a clear pin vs put mismatch. Not cleanup/refactor.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: net/rds/ib_rdma.c only (−3 / +1)
- Function: __rds_ib_teardown_mr()
- Scope: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: In the scatterlist-release loop, before: WARN_ON(!page->mapping && irqs_disabled()); set_page_dirty(page); put_page(page);. After:unpin_user_pages_dirty_lock(&page, 1, true);. DMA unmap, kfree(ibmr->sg), and pool accounting in rds_ib_teardown_mr() are unchanged. Normal teardown path, not an error-only path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** reference-counting / resource leak (FOLL_PIN bias not removed), plus initialization/dirtying correctness (set_page_dirty_lock vs set_page_dirty)
- **Mechanism:** pin_user_pages_fast() sets FOLL_PIN and bumps refcount by GUP_PIN_COUNTING_BIAS. put_page() subtracts 1, leaving 1023 refs. Pages never return to the allocator. unpin_user_page() / unpin_user_pages_dirty_lock() call put_compound_head(..., FOLL_PIN), which multiplies refs by the bias (or uses hpage_pincount_sub) and actually releases the pin.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct against the pin-API contract (mm/gup.c documents that FOLL_PIN pages must be released via unpin_user_page()). Same helper is already used in this tree in net/rds/rdma.c and net/rds/info.c. Minimal. Regression risk is sleep-in-atomic if teardown ever runs with IRQs off; verified callers already sleep (wait_event / mutex_lock). The dropped WARN_ON was a leftover from a 2015 BUG_ON(irqs_disabled()) downgrade; current callers take a mutex or run in syscall context.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- set_page_dirty + put_page in this function: 08b48a1ed84b19 (Andy Grover, 2009) — originally paired with get_user_pages.
- WARN_ON(!page->mapping && irqs_disabled()): 5c240fa2ab394a (2015), downgraded from BUG_ON(irqs_disabled()) because that assertion fired on “normal execution paths” (FMR-era). FMR support is already removed in this tree (07549ee21ce52).
- Pin conversion that made put_page wrong: 0d4597c8c5abd (2020-02-16), present in this tree.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: 0d4597c8c5abdeeaf50774066c16683f30184dc8 (“net/rds: Track user mapped pages through special API”) converted rds_pin_pages() to pin_user_pages_fast() and updated unpin sites in rdma.c only (rds_rdma_free_op, rds_atomic_free_op, error paths). It did **not** touch ib_rdma.c. git merge-base --is-ancestor 0d4597c8c5abd HEAD succeeded — the buggy conversion is in this 5.10 tree. Intermediate related fix already here: 91a44b406bc1f (“net: rds: fix MR cleanup on copy error”) — different bug (double-unpin on put_user failure), not a substitute for this leak.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent net/rds/ib_rdma.c history is unrelated (laddr check, FRMR reject, null deref). This is standalone vs local history. Upstream it is v4 4/4 of Allison Henderson’s series; patches 1–3 fix different RDS bugs (sleeping unpin from tasklet in rdma.c, socket UAF via MR, send-path message leak) and are **not** prerequisites for this hunk.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Allison Henderson has many RDS commits in this tree (locking, shutdown, zerocopy). Oracle RDS maintainer-side contributor. MAINTAINERS lists Santosh Shilimkar; Allison is a long-time RDS author. Related contemporaneous work is the rest of the v4 series, not a dependency of this patch.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs unpin_user_pages_dirty_lock() and pin_user_pages_fast() — both exist in 5.10 (mm/gup.c, EXPORT_SYMBOL). No new helper, no struct change. Can apply standalone. git apply --check succeeded (hunk offset +4 only).
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- Lore/thread via b4 am / b4 mbox: cover https://patch.msgid.link/2 [email protected]
- Patch: msgid [email protected] ([PATCH net v4 4/4])
- Openwall mirror: https://lists.openwall.net/netdev/2026/07/30/66
- Revisions: v1–v3 were a 3-patch series; **this leak fix is new in v4**. Applied version is v4.
- Merged to netdev/net-next.git as a507023e6ff1 (patchwork-bot, 2026-08-05)
- Jakub Kicinski: not a NAK — he said he lacked confidence reviewing RDS and queued the series for **-next** rather than net. Allison agreed (Fixes tags, but “not simple bugs” / “really old bugs”).
- No reviewer NAK, no request to drop patch 4, no flag that teardown can sleep in IRQ on current code.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: b4 recipients: netdev, linux-rdma, Pabeni, Edumazet, Kicinski, Horms; Cc John Hubbard and Leon Romanovsky (original pin-API authors). No Reviewed-by landed. Kicinski merged without a deep RDS review. Technical correctness of this hunk does not depend on that: it matches the pin API the Cc list designed.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla. Bug is from code inspection / UEK porting. Trigger is real (setsockopt(RDS_GET_MR) / MR reuse), not theoretical. No user-count from public reports.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone vs 1/4–3/4. Patch 1 is about rds_rdma_free_op() sleeping from the **send tasklet** — a different function already using unpin_user_pages_dirty_lock() in rdma.c. Backporting 4/4 does not require 1/4; it does not widen that tasklet bug.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search for this subject returned no discussion that this fix was rejected or already taken. UNVERIFIED that no private stable thread exists.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
Record: __rds_ib_teardown_mr() (changed); rds_ib_teardown_mr() (wrapper); rds_ib_map_frmr(), rds_ib_unreg_frmr() (callers).
**Step 5.2: TRACE CALLERS**
Record:
- rds_ib_map_frmr() → rds_ib_teardown_mr() — reuse/remap. Called from rds_ib_reg_frmr() → rds_ib_get_mr() → __rds_rdma_map() / cmsg RDMA map. Syscall (setsockopt / sendmsg). Already wait_events in rds_ib_post_reg_frmr().
- rds_ib_unreg_frmr() → __rds_ib_teardown_mr() — only from rds_ib_flush_mr_pool(), which takes pool->flush_lock (mutex). Callers of flush: delayed work rds_ib_mr_pool_flush_worker, rds_ib_try_reuse_ibmr (GFP_KERNEL alloc path), rds_ib_free_mr only if !in_interrupt(), rds_ib_flush_mrs() (socket close / RDS_FREE_MR), rds_ib_destroy_mr_pool(), rds_ib_conn_path_shutdown() (already wait_event_timeout). Interrupt free_mr queues flush_worker instead of flushing inline.
**Step 5.3: TRACE CALLEES**
Record: After the change, the loop calls unpin_user_pages_dirty_lock() → set_page_dirty_lock() (can sleep) + unpin_user_page(). Previously set_page_dirty() + put_page(). DMA unmap stays first.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable from userspace: rds_setsockopt → RDS_GET_MR / RDS_GET_MR_FOR_DEST → rds_get_mr() → __rds_rdma_map() → rds_pin_pages() → transport get_mr. Also RDMA cmsg on send. Requires CONFIG_RDS=y/m, CONFIG_RDS_RDMA, InfiniBand, and can_do_mlock(). Not universal, but a real syscall path. Unprivileged users typically need RLIMIT_MEMLOCK/CAP_IPC_LOCK to pin; RDS/IB cluster users have that.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same missed-unpin class was why rdma.c was converted in 2020. Remaining put_page in net/rds/message.c is for message payload pages (__free_page / zerocopy), not FOLL_PIN MR pages. IB umem/qib/hfi1 already use unpin_user_pages_dirty_lock(). This is the leftover RDS IB MR site.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. net/rds/ib_rdma.c lines 253–260 still have WARN_ON + set_page_dirty + put_page. rds_pin_pages() already uses pin_user_pages_fast() (net/rds/rdma.c:163). GUP_PIN_COUNTING_BIAS is (1U << 10) in include/linux/mm.h. Bug present since this series branched (v5.10 includes 0d4597c8c5ab from Feb 2020; v5.10 release is Dec 2020).
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** (git apply --check: hunk succeeded at offset 4). Surrounding function matches the mainline hunk. 5.10’s unpin_user_pages_dirty_lock() uses set_page_dirty_lock(), not folios; the public API and sleep/lock properties match what the patch needs. Commit-message “folio lock” is mainline wording; behavior here is the page lock, which is correct for 5.10.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No equivalent unpin in __rds_ib_teardown_mr(). 91a44b406bc1f is a different MR cleanup. git log --grep='unpin MR pages' -- net/rds is empty in this tree.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **net/rds** (Reliable Datagram Sockets), IB RDMA MR pool.
Criticality: **IMPORTANT** for RDS/IB users (Oracle RAC-style clusters); **PERIPHERAL** for everyone else (CONFIG_RDS_RDMA + InfiniBand). Not core mm/VFS, but pinned-page leaks are mm-visible (unreclaimable pages).
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature. The teardown loop dates to 2009; the pin mismatch has been wrong for the entire 5.10 lifetime. Low churn on ib_rdma.c relative to netdev core.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Record: Driver/config-specific: CONFIG_RDS + CONFIG_RDS_RDMA + IB hardware. TCP RDS (CONFIG_RDS_TCP) has no RDMA MRs and is unaffected.
**Step 8.2: TRIGGER CONDITIONS**
Record: Common for RDS RDMA: every MR map/reuse/teardown (RDS_GET_MR, RDMA cmsg, pool flush). Not a rare error path. Needs mlock capability. Not a timing race.
**Step 8.3: FAILURE MODE SEVERITY**
Record: Unreclaimable page leak (pin bias left behind). Repeated GET_MR/reuse can pin large amounts of RAM until OOM. **Severity: HIGH** (not a panic, but a userspace-triggerable leak of pinned pages; same class as other GUP pin leaks taken into stable). Secondary: dirty- without-lock truncation race on file-backed MRs (**MEDIUM** on that subset).
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit:** High for RDS/IB; stops a leak that has existed for the whole 5.10 life. Zero functional change for other configs.
- **Risk:** Very low — one call-site, existing exported helper, callers already sleepable. Does not add APIs or change userspace.
- **Ratio:** Strongly favors backport.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real FOLL_PIN vs put_page() leak; verified in 5.10 mm/gup.c and net/rds/rdma.c/ib_rdma.c
- Userspace-reachable (RDS_GET_MR / RDMA map)
- Fixes commit 0d4597c8c5ab is in this tree
- 1-file, 4-line change; unpin_user_pages_dirty_lock() already used elsewhere in RDS here
- Applies cleanly
- Author is RDS; merged by netdev
- Sleeping unpin is safe on verified 5.10 call chains
**AGAINST:**
- RDS/IB is not a universal path
- Kicinski did not deeply review and put the series in net-next
- No public crash/syzbot report
- Series mates 1–3 are separate bugs (not blockers)
**UNRESOLVED:** No stable@ thread found; WebFetch to lore HTML returned 403 (thread recovered via b4 + openwall + curl).
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — pin-API contract; same helper already in-tree RDS; merged to net-next
2. Fixes a real bug that affects users? **PASS** — pinned pages never freed on MR teardown
3. Important (crash/security/corruption/deadlock)? **PASS** — unreclaimable leak on a hot RDS RDMA path, up to 1 MiB per map plus reuse; eventual OOM
4. Small and contained? **PASS** — one function, −3/+1
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — git apply --check clean; helpers present
**Step 9.3: EXCEPTION CATEGORIES**
Record: None. Ordinary bug fix (not ID/quirk/DT/build/docs).
**Step 9.4: DECISION**
This is a small, obviously correct leak fix for a bug that has been in this 5.10 tree since day one. It does not need the rest of the v4 series. Benefit for RDS/IB users outweighs the low regression risk.
---
### What the commit solves for this tree
rds_pin_pages() already pins with pin_user_pages_fast() (FOLL_PIN, +1024 refs). IB teardown still put_page()s once, so every MR teardown permanently leaks those pages. Replacing that with unpin_user_pages_dirty_lock() restores the pin/unpin pairing and dirties under the page lock. That matters to 5.10 RDS-over-InfiniBand users (clusters using RDS_GET_MR / RDMA ops): memory is not optional reclaim, it is stuck until reboot.
### Risk vs benefit
Benefit is a real, repeating leak on a syscall-visible path. Risk is a one-line helper swap on paths that already take a mutex and wait_event. The patch applies without rework.
---
### Verification
- [Phase 1] Parsed candidate tags: Allison Henderson SOB, msgid.link, Kicinski SOB; lore copy also has Fixes: 0d4597c8c5ab
- [Phase 2] Diff: __rds_ib_teardown_mr() in net/rds/ib_rdma.c, replace WARN/set_page_dirty/put_page with unpin_user_pages_dirty_lock(&page, 1, true)
- [Phase 3] git describe/Makefile: local tree **5.10.270**, branch pending-5.10
- [Phase 3] git blame: put_page since 2009; WARN_ON from 5c240fa2ab394a (2015)
- [Phase 3] git show 0d4597c8c5abd: pin conversion of rdma.c only; git merge-base --is-ancestor → in HEAD
- [Phase 3] git show dbfe7d74376e1: only info.c, not this leak
- [Phase 3] Read mm/gup.c: pin_user_pages_fast() sets FOLL_PIN; unpin_user_pages_dirty_lock() / put_compound_head(..., FOLL_PIN) apply GUP_PIN_COUNTING_BIAS (1024)
- [Phase 3] Read local net/rds/rdma.c rds_pin_pages() and ib_rdma.c teardown: mismatch confirmed
- [Phase 4] b4 am/b4 mbox: v4 4/4 series; merged as a507023e6ff1; Kicinski queued for net-next; no NAK
- [Phase 4] Openwall https://lists.openwall.net/netdev/2026/07/30/66
matches the diff
- [Phase 4] lore HTML WebFetch: 403; thread recovered via b4
- [Phase 5] Callers: rds_ib_map_frmr (syscall), rds_ib_unreg_frmr via rds_ib_flush_mr_pool (mutex + workqueue); rds_ib_free_mr defers flush when in_interrupt()
- [Phase 5] RDS_MAX_MSG_SIZE = 1 MiB in net/rds/rds.h
- [Phase 6] Buggy code present at ib_rdma.c:258-260; git apply --check succeeded
- [Phase 6] unpin_user_pages_dirty_lock already used in net/rds/rdma.c and net/rds/info.c
- [Phase 7] MAINTAINERS: RDS supported (Santosh Shilimkar / Oracle)
- [Phase 8] Failure mode: unreclaimable FOLL_PIN leak, HIGH for RDS_RDMA
- UNVERIFIED: no public syzbot/user report; no stable@ thread found
**YES**
net/rds/ib_rdma.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/rds/ib_rdma.c +1 -3
@@ -251,9 +251,7 @@ void __rds_ib_teardown_mr(struct rds_ib_mr *ibmr)/* FIXME we need a way to tell a r/w MR * from a r/o MR */ -WARN_ON (!page->mapping &&irqs_disabled ()); -set_page_dirty (page); -put_page (page); +unpin_user_pages_dirty_lock (&page,1 , true); }kfree (ibmr->sg);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] net/rds: unpin MR pages with unpin_user_pages_dirty_lock()
Sashiko has reviewed this patch and found no issues.
Quoted 13 lines
From: Allison Henderson <[email protected]>
[ Upstream commit
a507023e6ff1d0b4e7aac49b2f547fed0c21ea4e]The pages backing an RDS memory region are pinned in
__rds_rdma_map()withrds_pin_pages(), which usespin_user_pages_fast(): each page's refcount is biased byGUP_PIN_COUNTING_BIASto account the pin. The scatterlist is then handed to the IB transport, and the transport releases the pages in__rds_ib_teardown_mr()withset_page_dirty(page); put_page(page);
Quoted 8 lines
put_page()drops a single reference instead of removing the pin bias, so every MR teardown permanently strands the remaining references and [ ... ]Signed-off-by Allison Henderson <[email protected]>Signed-off-by Jakub Kicinski <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/realtek: Add quirk for Acer Nitro AN515-45
In reply to Sasha LevinFrom: Zhang Heng <[email protected]>
[ Upstream commit 0d90a929836344f1d3b39f22f08ccecc62378a59 ]
The Acer Nitro AN515-45 requires ALC2XX_FIXUP_HEADSET_MIC to make the headset microphone work properly.
---
LLM Generated explanations, may be completely bogus:
This is a one-line Realtek HDA hardware quirk for Acer Nitro AN515-45. The local tree is **6.18.57** (v6.18.57-155-gcdf239ca885b2). The existing ALC2XX_FIXUP_HEADSET_MIC path is already in this tree; the SSID 1025:151e is not in v6.18.57.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [ALSA/hda/realtek] [Add] quirk for Acer Nitro AN515-45 — add an existing headset-mic fixup for one laptop SSID.
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Link: https://bugzilla.kernel.org/show_bug.cgi?id=221925 — user bug report
- Signed-off-by: Zhang Heng <[email protected]> — author
- `Link:
https://patch.msgid.link/[email protected]`
— patch 2/2
- Signed-off-by: Takashi Iwai <[email protected]> — ALSA maintainer
- No Fixes:, Reported-by:, Tested-by:, Cc: stable (absence is expected)
- Ignore pipeline [ Upstream commit ... ] and Signed-off-by: Sasha Levin
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: headset microphone on Acer Nitro AN515-45 does not work
- Symptom: combo-jack mic not detected / not created as an input
- Root cause (from bugzilla, not the short commit body): BIOS leaves pin 0x19 as N/A (Pin Default 0x411111f0); no headset-mic path is parsed
- Fix: apply existing ALC2XX_FIXUP_HEADSET_MIC for PCI/codec SSID 1025:151e
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. This is an explicit hardware quirk to make a broken jack work.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: sound/hda/codecs/realtek/alc269.c (+1 / −0)
- Function/table: alc269_fixup_tbl[]
- Scope: single-file, one-line table addition
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: SSID 0x1025:0x151e has no dedicated entry, so probe does not apply the headset-mic pincfg
- After: that SSID maps to ALC2XX_FIXUP_HEADSET_MIC
- Path: codec probe / pin parse (alc269_probe → snd_hda_pick_fixup)
- Not an error path or API change
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Category: hardware workaround (quirk table entry)
- Mechanism: alc2xx_fixup_headset_mic() at pre-probe sets pin 0x19 to 0x03a1103c, updates coef 0x45, and sets HDA_PINCFG_HEADSET_MIC so the combo-jack mic is parsed
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Minimal, same pattern as AN515-57 / AN515-58 / AN517-55 already in this tree
- Only the matching laptop is affected
- Regression risk is low; remaining auto-mic source-switch behavior is existing generic parser behavior, not introduced here
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Neighboring Acer entries come from aeeb85f26c3bbe (Realtek codec split, 2025-07-09) and later sibling quirks
- The missing-SSID bug is “no quirk for this board,” not a recently introduced logic bug
- ALC2XX_FIXUP_HEADSET_MIC itself dates to 2024 (5a69e3d0a1b0 / 50db91fccea0 era) and is present in v6.18.57
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Not applicable.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- Sibling: a9584e9e46448 “Enable headset mic for Acer Nitro 5” (AN515-57) is already in v6.18.57
- Same file routinely receives one-line SND_PCI_QUIRK additions
- Series is [PATCH 2/2]; patch 1/2 is an unrelated Lenovo ThinkBook G8+ quirk (17aa:38dc) and is not a prerequisite
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Zhang Heng submitted two independent one-line quirks. Takashi Iwai applied both. Author is a contributor; maintainer sign-off is the stronger signal.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: Standalone. Needs only alc269_fixup_tbl and ALC2XX_FIXUP_HEADSET_MIC, both present in this 6.18.y tree.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 0d90a929836344f1d3b39f22f08ccecc62378a59 matched [PATCH 2/2]
- Lore/msgid: https://patch.msgid.link/20260921124450.639601-2- [email protected]
- Only v1; no later revision
- Takashi Iwai: “Applied both patches. Thanks.” No NAK, no stable objection
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To [email protected]; Cc linux- [email protected], [email protected]. Subsystem maintainer applied it.
Step 4.3: SEARCH FOR THE BUG REPORT
Record (bugzilla 221925, fetched via curl; WebFetch returned 403):
- Title: ALC295 / Acer Nitro AN515-45 (1025:151e): headset mic not detected, BIOS disables pin 0x19
- Reporter: Rishikesh Jha, 2026-08-26, hardware AMD AN515-45, codec ALC295 0x10ec0295, subsystem 0x1025151e
- Symptom: speakers/headphones/internal mic work; combo-jack headset mic is not created
- Reporter verified a firmware pincfg plus headset-mode
- Zhang Heng asked for model=alc2xx-fixup-headset-mic; reporter confirmed the headset mic works
- Remaining userspace auto-mic mux limitation is explained as generic parser behavior, not a reason this quirk is wrong
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Patch 1/2 is a different machine/SSID/fixup. This commit does not depend on it.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: No useful lore.kernel.org/stable hit for this model. The original AN515-58 headset-mic quirk (5a69e3d0a1b0) was Cc: stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: Table alc269_fixup_tbl[] only. Consumed fixup:alc2xx_fixup_headset_mic().
Step 5.2: TRACE CALLERS
Record:
- alc269_probe() calls snd_hda_pick_fixup(..., alc269_fixup_tbl, alc269_fixups)
- That matches PCI SSID, then codec SSID
- Probe path for ALC269-family codecs including ALC295 (0x10ec0295)
Step 5.3: TRACE CALLEES
Record: alc2xx_fixup_headset_mic() → snd_hda_apply_pincfgs(), alc_update_coef_idx(), spec->parse_flags |= HDA_PINCFG_HEADSET_MIC
Step 5.4: FOLLOW THE CALL CHAIN
Record: Reachable on boot when this laptop’s HD-audio codec is enumerated. Userspace sees the missing capture device without the quirk. Not a syscall crash path; it is a real device-enablement path.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same fixup already used in this tree for AN515-57 (0x1539), AN515-58 (0x159c), AN517-55 (0x1597), plus other vendors.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. v6.18.57 has sound/hda/codecs/realtek/alc269.c, ALC2XX_FIXUP_HEADSET_MIC, and sibling Nitro entries, but **no** 0x1025, 0x151e / AN515-45 line. Headset mic stays broken on this model here.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Clean apply. Insert point is identical: after 0x1466 Aspire A515-56, before 0x1534 Predator PH315-54.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: Sibling Nitro headset-mic quirks are present. There is no earlier AN515-45-specific fix. (Ignore candidate-prep cherry-pick on current HEAD.)
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: ALSA HD-audio Realtek codec driver. Criticality: IMPORTANT for users of this common laptop audio stack; board-specific impact.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mature, actively receiving per-board quirks. This is the normal stable-safe pattern, not a new subsystem.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver-specific / hardware-specific: Acer Nitro AN515-45, SSID 1025:151e, Realtek ALC295.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Every boot / every headset plug on that machine. Unprivileged user cannot crash the kernel; they just cannot use the headset mic.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: Functional hardware failure (headset capture missing). Severity MEDIUM as a crash, HIGH as user-visible hardware breakage. Stable routinely takes these quirks.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: high for owners of this 2021-era Nitro 5; restores combo-jack mic
- Risk: very low (one table row, existing fixup, SSID-matched)
- Ratio: strongly favors backport
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real user bug (bugzilla 221925) with alsa-info and codec dump
- Reporter confirmed alc2xx-fixup-headset-mic makes the headset mic work
- One-line SND_PCI_QUIRK using a fixup already in 6.18.y
- Same fix already shipped here for sibling Nitro 5 models
- ALSA maintainer applied it; no NAK
- Explicit stable exception: hardware quirk for an existing driver
AGAINST:
- Not a crash/security/corruption fix
- Bugzilla still lists leftover auto-mic source-switch UX after the mic appears
- Patch 2/2 of a series (other patch is unrelated, not required)
UNRESOLVED:
- WebFetch of lore/bugzilla returned 403; bugzilla content was verified with curl instead
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — existing fixup; reporter tested the model; maintainer applied
2. Fixes a real bug that affects users? PASS — headset mic not detected
3. Important issue? PASS under the hardware-quirk exception (device does not work correctly)
4. Small and contained? PASS — +1 line
5. No new features or APIs? PASS — table entry only
6. Can apply to the local tree? PASS — clean insert into alc269_fixup_tbl on 6.18.y
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Hardware quirk / workaround for a broken BIOS pin config on existing hardware. This is a standard YES for stable.
Step 9.4: MAKE YOUR DECISION
Backport. This tree already has the Realtek driver and ALC2XX_FIXUP_HEADSET_MIC. Adding SSID 1025:151e is the same class of fix already present for AN515-57/58.
What it solves for 6.18.y users: on Acer Nitro AN515-45 the BIOS marks headset-mic pin 0x19 as N/A, so the kernel never creates a headset capture device. The quirk applies the existing pincfg/coef fixup so the combo jack mic works.
Risk vs benefit: one SSID-guarded line, reused fixup, verified on the machine. Benefit is real hardware enablement; regression surface is that one laptop.
Verification:
- [Phase 1] Parsed tags: bugzilla 221925, msgid ...639601-2..., SOB Takashi Iwai; no Fixes/Cc stable
- [Phase 2] Diff: +1 SND_PCI_QUIRK(0x1025, 0x151e, "Acer Nitro AN515-45", ALC2XX_FIXUP_HEADSET_MIC) in alc269_fixup_tbl
- [Phase 2] Read alc2xx_fixup_headset_mic(): sets pin 0x19 0x03a1103c, coef 0x45, HDA_PINCFG_HEADSET_MIC
- [Phase 3] make kernelversion / git describe HEAD: 6.18.57 / v6.18.57-155-gcdf239ca885b2
- [Phase 3] No Fixes tag to follow
- [Phase 3] Sibling AN515-57 quirk a9584e9e46448 is ancestor of v6.18.57
- [Phase 3] Series patch 1/2 is unrelated ThinkBook G8+ quirk
- [Phase 4] b4 dig -c 0d90a9298363: matched patch 2/2; only v1
- [Phase 4] b4 dig -w: To tiwai, Cc linux-sound
- [Phase 4] mbox: Takashi “Applied both patches”
- [Phase 4] curl bugzilla 221925: ALC295, SSID 1025:151e, pin 0x19 N/A; alc2xx-fixup-headset-mic confirmed working
- [Phase 4] lore/bugzilla WebFetch: 403 (used curl/b4 instead)
- [Phase 5] alc269_probe() → snd_hda_pick_fixup() uses this table on codec enumeration
- [Phase 6] git grep 0x151e v6.18.57 -- sound/hda/codecs/realtek/alc269.c: no match
- [Phase 6] git grep ALC2XX_FIXUP_HEADSET_MIC v6.18.57 -- .../alc269.c: present, including AN515-57/58
- [Phase 6] v6.18.57 insert point between 0x1466 and 0x1534 matches the patch
- [Phase 8] Failure mode: headset mic missing on that laptop, not a kernel oops
- UNVERIFIED: live reproduction on AN515-45 hardware (not available here)
**YES**
sound/hda/codecs/realtek/alc269.c | 1 + 1 file changed, 1 insertion(+)
sound/hda/codecs/realtek/alc269.c +1 -0
@@ -6615,6 +6615,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x1025 ,0x142b ,"Acer Swift SF314-42" ,ALC255_FIXUP_ACER_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1025 ,0x1430 ,"Acer TravelMate B311R-31" ,ALC256_FIXUP_ACER_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1025 ,0x1466 ,"Acer Aspire A515-56" ,ALC255_FIXUP_ACER_HEADPHONE_AND_MIC ), +SND_PCI_QUIRK (0x1025 ,0x151e ,"Acer Nitro AN515-45" ,ALC2XX_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1025 ,0x1534 ,"Acer Predator PH315-54" ,ALC255_FIXUP_ACER_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1025 ,0x1539 ,"Acer Nitro 5 AN515-57" ,ALC2XX_FIXUP_HEADSET_MIC ), SND_PCI_QUIRK(0x1025, 0x159c, "Acer Nitro 5 AN515-58", ALC2XX_FIXUP_HEADSET_MIC),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 scsi: snic: Fix SCSI host leak on workqueue allocation failure
In reply to Sasha LevinFrom: Chen Changcheng <[email protected]>
[ Upstream commit 12e67eb89eb2b9516685c744d3f7de0a2d1bd701 ]
In snic_add_host(), if scsi_add_host() succeeds but alloc_ordered_workqueue() fails, the function returns -ENOMEM with shost->work_q left as NULL. The caller's error path then calls snic_del_host(), which returns early when !shost->work_q without calling scsi_remove_host(). The Scsi_Host remains registered in sysfs as a zombie device even after the probe has failed. This causes:
- The leaked host remains visible in /sys/class/scsi_host/ after probe failure, with state "running".
- Subsequent SCSI host numbering is permanently shifted (the leaked host ID from ida_alloc() is never reclaimed).
- Memory leak: the Scsi_Host allocation can never be freed because device_add() took a reference that can only be released by device_del() inside scsi_remove_host().
Fix by adding scsi_remove_host() in the workqueue allocation failure path inside snic_add_host(), undoing the successful scsi_add_host() before returning the error. This is cleaner than modifying snic_del_host() because snic_del_host() is called from a shared error label that also serves paths where snic_add_host() was never invoked.
Reproducer (requires no real SNIC hardware):
- Build CONFIG_SCSI_SNIC=y (built-in)
- Add snic.test_mode=1 snic.inject_wq_fail=1 to kernel cmdline
- Boot with a PCI device matching the snic driver (e.g. QEMU edu device, PCI ID 0x1234:0x11e8, temporarily added to the driver's PCI ID table)
Before the fix:
# /sys/class/scsi_host/ contains a zombie host0: $ cat /sys/class/scsi_host/host0/proc_name snic_scsi $ cat /sys/class/scsi_host/host0/state running # ata_piix gets host1, host2 (host0 stuck): scsi host1: ata_piix scsi host2: ata_piix
After the fix:
# host0 is properly freed and reused by ata_piix: scsi host0: ata_piix scsi host1: ata_piix # No zombie host in /sys/class/scsi_host/
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). The buggy snic_add_host() / snic_del_host() error path is present here and the one-line fix applies cleanly.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [scsi: snic:] [Fix] [SCSI host leak when workqueue allocation fails after scsi_add_host() succeeds]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Fixes: **absent** (expected for this review pipeline)
- Cc: [email protected] **absent** (expected)
- Acked-by: Narsimhulu Musini <[email protected]> — original SNIC driver author / Cisco maintainer
- `Link: https://patch.msgid.link/20260727073438.209673-1-
[email protected]`
- Signed-off-by: Chen Changcheng <[email protected]> (author)
- Signed-off-by: Martin K. Petersen (Oracle) <[email protected]> (SCSI maintainer)
- Reported-by: none
- Tested-by: none (author included a concrete reproducer in the body)
- Ignore pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] if present
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** scsi_add_host() succeeds, then alloc_ordered_workqueue() fails. snic_add_host() returns -ENOMEM with shost->work_q == NULL. Probe goes to a shared error label that calls snic_del_host(), which returns immediately when !shost->work_q and **never** calls scsi_remove_host().
- **Symptoms:** zombie /sys/class/scsi_host/hostN with state running; SCSI host ID from ida_alloc() never reclaimed (later hosts are numbered higher); Scsi_Host never freed because device_add()’s reference is only dropped by device_del() inside scsi_remove_host().
- **Version info:** none in the message. Code dates to the original driver (v4.2).
- **Root cause:** error-path rollback does not undo a successful scsi_add_host() when workqueue alloc fails. Author correctly avoids changing snic_del_host() because that helper is also used on paths that never called snic_add_host().
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. Explicit leak/rollback fix with a documented failure mode and a reproducer.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/scsi/snic/snic_main.c — **+1 line**
- Function: snic_add_host()
- Scope: single-file surgical error-path fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** on !shost->work_q, log, set ret = -ENOMEM, return. Host stays registered.
- **After:** same path also calls scsi_remove_host(shost) before returning -ENOMEM.
- Path: probe error path only (snic_probe() → snic_add_host() after scsi_add_host() succeeded).
Verified call chain in this tree:
```642:649:drivers/scsi/snic/snic_main.c
ret = snic_add_host(shost, pdev);
if (ret) {
...
goto err_get_conf;
}
```err_get_conf later calls snic_del_host() (line 690). That helper still early-returns on !shost->work_q, so after this fix it will not call scsi_remove_host() a second time.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Error-path / resource leak.** Missing undo of scsi_add_host() when workqueue allocation fails. Adding scsi_remove_host() is the matching rollback. Also reclaims the host ID (ida_free() in scsi_host_dev_release() after device_del()).
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: one matching rollback for the successful scsi_add_host().
- Not changing snic_del_host() avoids calling scsi_remove_host() on hosts that were never added (err_get_conf is also used when snic_get_conf() fails **before** snic_add_host()).
- Regression risk: very low. scsi_remove_host() is the documented pairing of scsi_add_host(). No double-remove: snic_del_host() still skips when work_q is NULL. No lock, API, or data-structure change.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Buggy control flow introduced in c8806b6c9e824f (“snic: driver for Cisco SCSI HBA”, Narsimhulu Musini, 2015-05-29).
- First appeared: **v4.2-rc1**. Present in this tree (git merge-base --is-ancestor c8806b6c9e824f HEAD succeeded).
- Nearby alloc_ordered_workqueue() rewrite: 6411307b63286e (v6.12-rc1) — formatting only; the leak predates that.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Introducer is the original driver commit above, which **is** in this tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent snic_main.c history is workqueue-name cleanup (6411307b63286, b97c0741c7dcc), slab-name uniqueness, const template, SPDX. **No prior leak fix.** Standalone one-line patch, not “X/Y” of a series (msgid ...-1 is a single patch).
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: git log --author="Chen Changcheng" -- drivers/scsi/ in this tree is empty (author is not a historical SNIC contributor here). Weight
instead: **Acked-by original driver author** Musini, and SCSI maintainer Martin K. Petersen applied it.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Uses existing scsi_remove_host(). Reproducer mentions snic.test_mode / snic.inject_wq_fail; those parameters **do not exist in this tree** (local test harness only). The fix itself does not depend on them.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c <sha> cannot be used: the candidate is **not** in this checkout (and the first SHA tried was an unrelated merge).
- Submission: msgid [email protected], 2026-07-27.
- Thread: https://lists.openwall.net/linux-kernel/2026/07/27/428 and
https://lkml.iu.edu/hypermail/linux/kernel/2607.3/06578.html
- Single revision (no v2/v3). Diff matches the candidate (1 line).
- No NAK. Cisco maintainer Acked-by in-thread. No reviewer asked for Cc: stable.
- lore.kernel.org fetches returned HTTP 403 from this environment.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: To/Cc included Cisco SNIC maintainers (nmusini, kartilak, sebaddel), James Bottomley, Martin K. Petersen, linux-scsi. Ack from Musini; applied by Petersen.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla. Author-found with an injected workqueue-fail reproducer. Before/after sysfs and host-numbering evidence is in the message.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone [PATCH], not part of a multi-patch series.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** — https://lore.kernel.org/stable/?q=... returned 403. No evidence of a prior stable NAK.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: snic_add_host() (modified). Related: snic_del_host(), snic_probe(), scsi_add_host(), scsi_remove_host().
**Step 5.2: TRACE CALLERS**
Record:
- snic_add_host() — only from snic_probe() (PCI probe).
- snic_del_host() — snic_probe() error path (err_get_conf) and snic_remove().
- Reachable on Cisco SNIC PCI probe, including under memory pressure when alloc_ordered_workqueue() fails.
**Step 5.3: TRACE CALLEES**
Record: scsi_add_host(), alloc_ordered_workqueue(), scsi_remove_host() (new). scsi_remove_host() sets host state, unregisters transport, device_unregister(&shost->shost_dev), device_del(&shost->shost_gendev). Final free and ida_free(&host_index_ida, shost->host_no) happen in scsi_host_dev_release() once refs drop.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: PCI probe (snic_probe → snic_add_host). Not a syscall hot path. Userspace-visible effect when it fires: leftover /sys/class/scsi_host/ entry and shifted host numbers for **other** SCSI drivers (author showed ata_piix taking host1/host2 because host0 was stuck).
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: This if (!shost->work_q) return; before scsi_remove_host() is unique to snic. Sibling Cisco fnic adds the host later and has a dedicated err_out_scsi_add_host label. No duplicate snic copy of this bug.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** Local tree: p-6.12-3-gc504cf0baa3d8, **6.12.111**, branch pending-6.12.
```305:323:drivers/scsi/snic/snic_main.c
if (!shost->work_q) {
SNIC_HOST_ERR(shost, "Failed to Create ScsiHost wq.\n");
ret = -ENOMEM;
}
return ret;
} /* end of snic_add_host */
static void
snic_del_host(struct Scsi_Host *shost)
{
if (!shost->work_q)
return;
destroy_workqueue(shost->work_q);
shost->work_q = NULL;
scsi_remove_host(shost);
}
```Bug present since v4.2.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** Surrounding hunk matches the candidate exactly (old found: True, new already applied: False).
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: git log --grep for this leak / snic_add_host / “workqueue allocation failure” under drivers/scsi/ found **no** prior fix.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: SCSI driver drivers/scsi/snic/ (Cisco PCI-Express SCSI HBA, CONFIG_SCSI_SNIC). **PERIPHERAL** hardware, but host-number leak is **system-wide** for SCSI host IDs.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature/quiet. Driver added 2015; recent churn is mechanical SCSI-wide workqueue cleanup. Long-standing bug, not a new-code issue.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver-specific trigger (Cisco SNIC), **plus** any other SCSI host on the same machine (permanent host ID shift). Config:CONFIG_SCSI_SNIC.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Probe-time alloc_ordered_workqueue() failure (ENOMEM / workqueue creation failure). Uncommon, not a hot path, not unprivileged- syscall. Once it happens, the zombie host and ID leak persist until reboot.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- Failure: unreclaimable Scsi_Host, zombie sysfs device in SHOST_RUNNING, leaked host ID.
- Severity: **HIGH** for leak class (not a panic). Worse than a one-shot kfree leak because the object stays in sysfs and shifts numbering for later hosts.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** medium for SNIC users under memory pressure; also prevents global SCSI host-id skew.
- **Risk:** very low (1 line, error path only, standard SCSI rollback).
- **Ratio:** favorable.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real error-path leak with concrete sysfs + host-ID consequences, reproduced by the author
- Buggy code is in this 6.12 tree (since v4.2)
- One-line, obviously correct pairing of scsi_remove_host() with successful scsi_add_host()
- No double-remove on the shared err_get_conf path
- Applies cleanly; no prerequisites
- Acked by original driver author; applied by SCSI maintainer
- Probe-path resource leaks are a common, accepted stable class
AGAINST:
- Trigger is rare (workqueue alloc fail during probe)
- SNIC is a specialized Cisco HBA (small population)
- Not a crash, UAF, or security bug
- Reproducer uses out-of-tree inject knobs (does not affect the patch)
UNRESOLVED:
- Stable-list discussion (lore 403)
- Upstream SHA not in this checkout (b4 dig on a local commit was not possible)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — 1-line rollback; author showed before/after; maintainer Ack
2. Fixes a real bug that affects users? **PASS** — zombie sysfs host + leaked ID + unreclaimable Scsi_Host
3. Important issue? **PASS** — unrecoverable resource leak that also skews SCSI host numbering for other drivers
4. Small and contained? **PASS** — +1 line, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — code matches; clean apply
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary error- path leak fix.
**Step 9.4: MAKE YOUR DECISION**
This is a real, long-standing probe rollback bug in this 6.12 tree. The fix is minimal, already reviewed, and undoes scsi_add_host() exactly when that call succeeded and the workqueue did not. Risk of regression is negligible; leaving it out leaves a zombie SCSI host and a leaked host ID if SNIC probe hits ENOMEM.
===============================================================
Verification
===============================================================
- [Phase 1] Parsed tags: Acked-by Musini; Link msgid 20260727073438.209673-1; no Fixes/stable Cc (expected)
- [Phase 2] Diff: +1 line in snic_add_host() error path; scsi_remove_host(shost) before -ENOMEM
- [Phase 2] Confirmed snic_probe uses shared err_get_conf which calls snic_del_host() even when snic_add_host() was never invoked (lines 630–690)
- [Phase 2] Confirmed snic_del_host() early-return on !work_q skips scsi_remove_host() — the leak mechanism
- [Phase 3] git blame: buggy code from c8806b6c9e824f (v4.2-rc1); ancestor of HEAD
- [Phase 3] git log --oneline -20 -- drivers/scsi/snic/snic_main.c: no prior leak fix
- [Phase 3] git log --grep for this leak under drivers/scsi/: empty
- [Phase 3] git log --author="Chen Changcheng" -- drivers/scsi/: no prior commits in this tree
- [Phase 4] b4 dig -c on a tree SHA: not applicable (candidate not in checkout); used msgid/openwall/lkml instead
- [Phase 4] Openwall/lkml: single-version patch, Acked-by Musini, no NAK
- [Phase 4] lore.kernel.org and lore stable search: HTTP 403 — UNVERIFIED
- [Phase 5] Callers: snic_add_host only from snic_probe; snic_del_host from probe error + remove
- [Phase 5] scsi_remove_host() → device_del(); scsi_host_dev_release() does ida_free(host_no)
- [Phase 5] test_mode/inject_wq_fail not in this tree (reproducer- only)
- [Phase 6] git describe HEAD: p-6.12-3-gc504cf0baa3d8; make kernelversion: 6.12.111
- [Phase 6] Surrounding code identical to candidate hunk; patch not already applied
- [Phase 8] Failure mode: zombie sysfs SCSI host + permanent host-ID leak; severity HIGH for leak class, rare trigger
- UNVERIFIED: whether this was already discussed on stable@ (lore 403)
This meets stable-kernel rules for this tree: real leak, small contained fix, clean apply, no new API.
**YES**
drivers/scsi/snic/snic_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/snic/snic_main.c +1 -0
@@ -305,6 +305,7 @@ snic_add_host(struct Scsi_Host *shost, struct pci_dev *pdev)if (!shost->work_q) {SNIC_HOST_ERR (shost,"Failed to Create ScsiHost wq.\n" ); +scsi_remove_host (shost); ret = -ENOMEM ; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 drm/amdgpu: Fix kobject cleanup in xcp sysfs
In reply to Sasha LevinFrom: Lijo Lazar <[email protected]>
[ Upstream commit 62d8b452615fd7a61976a1372bb81937807968c3 ]
Fix the indexing issue. Release the kobject whose init/add failed, and unwind the successfully added ones.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.18.53**. The buggy XCP sysfs cleanup is present here; the patch is a small, obviously-correct error-path kobject leak/WARN fix, so it should be backported.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[drm/amdgpu] [Fix] kobject cleanup in xcp sysfs** — intended to correct failed/partial kobject teardown for compute-partition sysfs.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Reviewed-by:** Alex Deucher <[email protected]> (amdgpu maintainer)
- **Signed-off-by:** Lijo Lazar <[email protected]> (author)
- **Signed-off-by:** Alex Deucher <[email protected]>
- Ignore pipeline tags: [Upstream commit 62d8b452615fd7a61976a1372bb81937807968c3], Signed-off-by: Sasha Levin
- **No Fixes:, Reported-by, Tested-by, Link:, or Cc: stable** (absence is expected for this review)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** “indexing issue” in XCP sysfs kobject unwind; failed kobject_init_and_add() is not released; successfully added kobjects are not unwound.
- **Symptom:** leaked kobjects / leftover sysfs on the init error path; extra kobject_put() on the failed object when the loop runs with `i
Quoted 1 line
= 2`.
- **Version info in message:** none.
- **Root cause (author):** wrong index in the cleanup loop, plus missing kobject_put() for the kobject whose init/add failed.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. Subject and body state a real cleanup bug. The original loop for (j = 0; j < i; j++) { xcp_res = &xcp_cfg->xcp_res[i]; ... } using **i instead of j** is a copy-paste error, not style cleanup.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c — **+5 / −3** (net +2)
- **Function:** amdgpu_xcp_cfg_sysfs_init()
- **Scope:** single-file surgical error-path fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record (verified against parent 6a08c18ac122 / v6.18.53):
1. Drop unused j after the loop rewrite.
2. On kobject_init_and_add() failure: **before** goto err with no put; **after** kobject_put(&xcp_res->kobj) then goto err (matches kobject_init_and_add() docs: put is required even on failure because kobject_init() already ran).
3. Unwind loop: **before** for (j = 0; j < i; j++) always uses xcp_res[i] (the failed slot), never xcp_res[j]; **after** while (i--) puts indices i-1 … 0 (the successfully added ones).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Error-path resource leak + incorrect kobject put** (refcount WARN / leak).
- kobject_init_and_add() always inits; a failed add still needs one kobject_put().
- The old loop used i instead of j, so it never released successful children and, when i >= 2, put the **same** failed kobject i times.
- num_res is ARRAY_SIZE(max_res) = AMDGPU_XCP_RES_MAX = **4** (aqua_vanjaram_get_xcp_res_info()), so i can be 2 or 3.
- First extra put: kref hits 0 → kobject_cleanup() (name freed). Further puts: refcount_dec_and_test() on 0 → **refcount underflow WARN**. Successful children and the parent xcp_cfg leak because those child refs are never dropped.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct and minimal. Success path unchanged. while (i--) after putting the failed index is the usual pattern (i=0 does not unwind further). Regression risk is **low** (error path only; no API/lock/hot-path change). xcp_cfg_res_sysfs_ktype has no .release (embedded kobject); putting it only cleans kobject state, it does not kfree the parent — that is correct.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: Buggy loop introduced in **4ae86dc878504** (“drm/amdgpu: Add sysfs nodes to get xcp details”, Lijo Lazar, 2024-09-09). git describe → v6.11-rc7-1469-g4ae86dc878504; contained in **v6.12**. Present in this 6.18 tree (git merge-base --is-ancestor 4ae86dc878504 HEAD succeeded).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The introducing commit is in this tree. No later same-file fix for this indexing bug besides this candidate.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Nearby history is XCP sysfs feature work (10072642541bd, 04e9101766dfe, cbbab29246c8b) plus unrelated RAS/bounds fixes. This is **standalone**, not patch X/Y. No extra prerequisite refactor is required for the hunk.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Lijo Lazar is a regular amdgpu/XCP contributor and authored the original sysfs nodes. Alex Deucher (maintainer) reviewed and signed off. Related author work on this file is XCP feature/fix traffic, not a hidden series dependency for this hunk.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Diff only uses existing kobject_init_and_add / kobject_put and the existing err label. **Applies standalone.** Upstream SHA 62d8b452615fd7a61976a1372bb81937807968c3 is **not** an ancestor of this 6.18 HEAD (expected; it is a later mainline commit).
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 62d8b452… →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only** (2026-06-17), no v2/v3.
- Thread (mbox): body matches the committed message; **Alex Deucher Reviewed-by**; **no NAK**.
- WebFetch of lore.kernel.org returned **403**; discussion recovered via b4 dig -m.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To [email protected]; Cc Hawking Zhang, Alexander Deucher, Asad Kamal, Candice Li. Maintainer reviewed.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by / syzbot / bugzilla. Found by code inspection of the unwind path. No user crash log.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone single patch, not a multi-patch series.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** — lore.kernel.org/stable WebFetch returned 403. No Cc: stable in the amd-gfx mbox.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: amdgpu_xcp_cfg_sysfs_init() only.
**Step 5.2: TRACE CALLERS**
Record:
- amdgpu_xcp_cfg_sysfs_init() ← amdgpu_xcp_sysfs_init() (amdgpu_xcp.c)
- ← amdgpu_device.c (~line 4948) during device init, with other amdgpu sysfs setup
- Early-out if !adev->xcp_mgr
**Step 5.3: TRACE CALLEES**
Record: kobject_init_and_add, sysfs_create_files/sysfs_create_file, amdgpu_xcp_get_res_info, kobject_put, sysfs_remove_*. No new locks or allocations besides existing ones.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: GPU probe/init for devices that create xcp_mgr. That is **aqua_vanjaram_init_soc_config()**, only for **GC IP 9.4.3, 9.4.4, 9.5.0** (MI300/MI325/MI350-class Instinct). Userspace cannot directly call this; trigger is kobject_init_and_add() failure (ENOMEM / name collision) during driver load. Function is void; probe **continues** even on failure, so leaked objects live until unload/reboot.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: No remaining for (j = 0; j < i; j++) in this file. amdgpu_xcp_cfg_sysfs_fini() iterates 0 .. num_res-1 correctly. Bug is local to this init unwind.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** Tree is v6.18.53-5049-g0f0bdc2b0dffb (Makefile 6.18.53, branch autosel). v6.18.53:amdgpu_xcp.c still has int i, r, j, rid, mode;, if (r) goto err; without put, and for (j = 0; j < i; j++) using xcp_res[i]. Introduced in v6.12-era commit 4ae86dc878504, ancestor of 6.18.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** Same function, same loop, same identifiers. Context in 6.18 uses kzalloc(sizeof(*xcp_cfg), GFP_KERNEL) rather than a later kzalloc_obj helper; that is outside the hunk. No conflicting refactor in this file for these lines.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No other commit on this file fixes this indexing/put bug. v6.18.53 does not contain the fix (git merge-base --is-ancestor 4fbcdfa45e537 v6.18.53 failed).
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **drm/amdgpu XCP (compute partition) sysfs.** Criticality:
**IMPORTANT** for MI300-class GPU servers; **PERIPHERAL** for typical desktop/laptop amdgpu. Not mm/VFS/net core.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: amdgpu/XCP is actively developed in this tree, but this particular unwind has been wrong since the 6.12-era feature landed — a long-standing bug, not last-month code.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver/platform-specific** — AMD Instinct GC 9.4.3/9.4.4/9.5.0 with xcp_mgr. Consumer GPUs without XCP are unaffected (if (!adev->xcp_mgr) return).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: kobject_init_and_add() failure while creating compute_partition_config/{xcc,dma,dec,jpeg} during probe. **Uncommon** (ENOMEM or sysfs name clash). Not a hot path; not directly triggerable by an unprivileged syscall except via memory pressure during driver load. Timing race: no.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- Leak of child kobjects + parent xcp_cfg (sysfs leftovers; xcp_cfg never stored so fini cannot recover it).
- If failure is at i >= 2: **refcount underflow WARN** on repeated put of the failed kobject.
- Not a happy-path oops, deadlock, or filesystem corruption.
- Severity: **MEDIUM–HIGH** on that error path (WARN + leak), **LOW** frequency.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** medium for affected GPUs — correct teardown, no leftover sysfs, no refcount WARN; zero effect on the success path.
- **Risk:** very low — 5-line error-path-only change, maintainer- reviewed.
- **Ratio:** favorable for stable.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real, obvious bug: cleanup loop uses i not j.
- Missing kobject_put() after failed kobject_init_and_add() (documented API contract in lib/kobject.c).
- Can leak kobjects/sysfs and, for i >= 2 of 4 resources, trigger refcount underflow WARN.
- Tiny (+5/−3), success path untouched.
- Buggy code has been in tree since ~v6.12 and **is in 6.18.53**.
- Reviewed-by amdgpu maintainer; standalone; applies cleanly.
AGAINST:
- Error path only; kobject_init_and_add() rarely fails.
- Init function is void; probe does not fail, so users may not notice.
- Limited to XCP-capable Instinct GPUs.
- No syzbot/user report, no Fixes:/Cc: stable (not a negative by itself).
- One-time probe leak, not a hot-path leak.
UNRESOLVED:
- Could not query lore.kernel.org/stable (HTTP 403).
- Could not use semcode (namespace not present).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — logic matches kobject rules; maintainer Reviewed-by.
2. Fixes a real bug that affects users? **PASS** — wrong unwind is in 6.18; MI300-class systems hit this init.
3. Important issue? **PASS** — leak plus possible kernel refcount WARN; not a universal panic, but a real stability/correctness bug on a production GPU path.
4. Small and contained? **PASS** — 8-line hunk, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — buggy code is in v6.18.53; context matches.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary small bugfix.
**Step 9.4: MAKE YOUR DECISION**
This should be backported to **this** 6.18.y tree. The indexing bug is unambiguous, the missing put is required by the kobject API, the change is surgical, and the code has been wrong for the entire lifetime of this sysfs feature in 6.18.
**What it solves for stable users:** On MI300-class amdgpu probe, if creating a partition-config resource kobject fails, 6.18 currently leaks the kobjects that did get added (and can WARN on extra puts of the failed one). The fix releases the failed kobject and actually unwinds 0..i-1.
**Risk vs benefit:** Benefit is correct error-path teardown with no success-path behavior change; risk is negligible.
**Concerns:** Trigger is uncommon; impact is limited to XCP GPUs. That does not make the patch unsuitable — it applies cleanly and does not need other commits.
Verification:
- [Phase 1] Tags: Reviewed-by Alex Deucher; SOB Lijo Lazar + Deucher; no Fixes/Reported-by/Cc: stable
- [Phase 2] Diff: amdgpu_xcp_cfg_sysfs_init() +5/−3; add kobject_put on failed init/add; for (j=0;j<i;j++) + xcp_res[i] → while (i--)
- [Phase 2] Parent dump of amdgpu_xcp.c confirmed the i-instead- of-j bug
- [Phase 2] lib/kobject.c: kobject_init_and_add() inits then adds; comments require kobject_put() on error
- [Phase 2] Extra puts hit refcount_dec_and_test() underflow WARN (include/linux/refcount.h)
- [Phase 3] git blame on parent: lines from 4ae86dc878504 (v6.12 era)
- [Phase 3] git merge-base --is-ancestor 4ae86dc878504 HEAD → yes; 62d8b452 not ancestor of this 6.18 HEAD
- [Phase 3] git log --oneline -20 -- amdgpu_xcp.c: standalone, not a series
- [Phase 4] b4 dig -c 62d8b452: lore msgid [email protected]
- [Phase 4] b4 dig -a: v1 only; b4 dig -w: amd-gfx + Deucher et al.
- [Phase 4] mbox: Deucher Reviewed-by; no NAK; no stable nomination
- [Phase 4] lore.kernel.org WebFetch 403 — UNVERIFIED for stable@ archive
- [Phase 5] callers: amdgpu_xcp_sysfs_init ← amdgpu_device.c probe; xcp_mgr only from aqua_vanjaram_init_soc_config for GC 9.4.3/9.4.4/9.5.0
- [Phase 5] num_res = ARRAY_SIZE(max_res) = AMDGPU_XCP_RES_MAX = 4
- [Phase 5] no semcode — used grep/read
- [Phase 6] git describe HEAD = v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion 6.18.53
- [Phase 6] git show v6.18.53:amdgpu_xcp.c still has the buggy loop
- [Phase 8] Failure: leak + possible refcount WARN on probe error path; not a common-path oops
- UNVERIFIED: whether stable@ ever discussed this commit (lore 403)
**YES**
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +5 -3
@@ -901,7 +901,7 @@ static void amdgpu_xcp_cfg_sysfs_init(struct amdgpu_device *adev) {struct amdgpu_xcp_res_details *xcp_res;struct amdgpu_xcp_cfg *xcp_cfg; -int i, r, j, rid, mode; +int i, r, rid, mode;if (!adev->xcp_mgr)return ;
@@ -947,14 +947,16 @@ static void amdgpu_xcp_cfg_sysfs_init(struct amdgpu_device *adev) &xcp_cfg_res_sysfs_ktype, &xcp_cfg->kobj,"%s" , xcp_res_names[rid]); -if (r) +if (r) { +kobject_put (&xcp_res->kobj); goto err; + } } adev->xcp_mgr->xcp_cfg = xcp_cfg;return ; err: -for (j =0 ; j < i; j++) { +while (i--) { xcp_res = &xcp_cfg->xcp_res[i];kobject_put (&xcp_res->kobj); }
Signature · 1 line
2.53.0