net: dsa: mt7530: check CORE_PLL_GROUP4 access in mt7531_setup()
Subsystems (71)
Sasha Levin
maintainerPATCH 1/1 mmc: dw_mmc: stop and complete DMA also in STATE_DATA_BUSY state
In reply to Sasha LevinFrom: Marek Szyprowski <[email protected]>
[ Upstream commit cb3fcb8d118b874178251d1f02613f60d25e4ddc ]
When transfer was stopped in STATE_DATA_BUSY state, there was no call to dma_ops->cleanup function, so the DMA mapped buffer was never properly unmapped. Fix this by calling dw_mci_stop_dma() function also in that state to ensure proper cleanup call when DMA transfer was used.
---
LLM Generated explanations, may be completely bogus:
The local checkout is mainline **v7.3-rc4** (origin/master). The candidate is cb3fcb8d118b8 (mmc: dw_mmc: stop and complete DMA also in STATE_DATA_BUSY state): a one-line DMA-cleanup hole in a host used on Exynos, Rockchip, and similar SoCs.
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
Record: **[mmc/dw_mmc] [stop and complete] Call DMA stop/cleanup in STATE_DATA_BUSY so mapped buffers are unmapped.**
**Step 1.2 — Tags**
Record:
- Signed-off-by: Marek Szyprowski (author; DMA-mapping maintainer)
- Reviewed-by: Shawn Lin (dw_mmc co-maintainer)
- Signed-off-by: Ulf Hansson (MMC maintainer)
- No Fixes:, Reported-by, Tested-by, Link:, or Cc: stable (absence is expected here)
**Step 1.3 — Body**
Record: **Bug:** finishing a transfer in STATE_DATA_BUSY never called dma_ops->cleanup, so a DMA-mapped SG list was left mapped. **Symptom:** DMA mapping leak (DMA-API/IOMMU leftover mappings). **Root cause:** dw_mci_stop_dma() already runs in the sending-data / error paths, but not in STATE_DATA_BUSY before host->data = NULL. **Versions:** none stated.
**Step 1.4 — Hidden bug fix?**
Record: **No disguise.** It is an explicit resource-cleanup fix.
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
Record: drivers/mmc/host/dw_mmc.c **+1 / −0**. Function:dw_mci_work_func(). **Single-file, one-line surgical fix.**
**Step 2.2 — Flow**
Record: In case STATE_DATA_BUSY:, after EVENT_DATA_COMPLETE and dw_mci_stop_fault_timer(), **before** host->data = NULL, the code now calls dw_mci_stop_dma(host). That function stops the DMA engine if host->using_dma and then runs dma_ops->cleanup(). Previously this state only nulled host->data and completed the request.
**Step 2.3 — Bug mechanism**
Record: **Resource leak / DMA mapping leak.** dw_mci_dma_cleanup() unmaps only when host->data is set and host_cookie == COOKIE_MAPPED. Clearing host->data first made later cleanup a no-op.
Verified paths:
- Success: IDMAC/EDMAC dw_mci_dmac_complete_dma() already calls cleanup, then EVENT_XFER_COMPLETE moves the machine into STATE_DATA_BUSY. Second cleanup is a no-op (COOKIE_UNMAPPED).
- Error from STATE_SENDING_DATA: already calls dw_mci_stop_dma().
- **DMA start failure then PIO fallback:** dw_mci_submit_data_dma() sets using_dma = 1 after a successful map, then on dma_ops->start() failure calls stop() but **not** cleanup, and **does not** clear using_dma. PIO then completes via STATE_DATA_BUSY. Without this line the mapping is left. Verified:
using_dma is assigned only at lines 998 and 1010; PIO fallback (lines 1070–1103) never clears it.
- COOKIE_PRE_MAPPED block I/O still unmaps in dw_mci_post_req(); this change does not double-unmap that path.
**Step 2.4 — Fix quality**
Record: **Obviously correct** and matches the other data-path states. Cleanup is idempotent. dw_mci_start_request() zeros pending_events, so the extra EVENT_XFER_COMPLETE bit from dw_mci_stop_dma() does not leak into the next request. **Regression risk: low.** dmaengine_terminate_async() / IDMAC reset after a completed transfer is the same stop used on errors; IDMAC start already resets the engine.
## Phase 3: Git history
**Step 3.1 — Blame**
Record: host->data = NULL in STATE_DATA_BUSY is from **f95f3850f7a9e1** (Will Newton, 2011-01-02), first in **v2.6.38**. The hole is old.
**Step 3.2 — Fixes: tag**
Record: **None.** Related older fix **faecf41106123** (“fix unmap sg twice when finding data err”, 2016) made cleanup skip IDMAC complete when EVENT_DATA_ERROR is set, so stop_dma() is the unmap path on errors. That makes missing stop_dma() in STATE_DATA_BUSY more important, not less.
**Step 3.3 — File history**
Record: Recent dw_mmc work is refactor (board struct, PM macros). This commit is standalone, not N/M. No follow-up in cb3fcb8d118b8..HEAD except an unrelated dw_mci_pmops move.
**Step 3.4 — Author**
Record: Marek Szyprowski is the DMA-mapping maintainer; first dw_mmc commit in this file. Shawn Lin (dw_mmc maintainer) reviewed it. Ulf Hansson applied it.
**Step 3.5 — Dependencies**
Record: **None.** It only calls existing dw_mci_stop_dma(). Applies standalone.
## Phase 4: Mailing list
**Step 4.1**
Record: https://patch.msgid.link/20260603083935.3201411-1-
[email protected]
**v1 only** (no v2/v3). Thread (3 messages via b4 dig -m):
1. Patch (3 Jun 2026)
2. Shawn Lin: Reviewed-by
3. Ulf Hansson: “Applied for next, thanks! Please, let me know if you think there is reason to tag this for stable kernels too.” **No reply** in the thread.
**Step 4.2**
Record: CCs were linux-mmc, Jaehoon Chung, Shawn Lin, Ulf Hansson — the right maintainers.
**Step 4.3**
Record: No syzbot/bugzilla. Author describes a mapping leak, not a crash log.
**Step 4.4**
Record: Standalone, not part of a series.
**Step 4.5**
Record: **UNVERIFIED** — lore.kernel.org/stable is behind bot protection (403/Anubis). linux-mmc thread has Ulf’s open stable question and no nomination.
## Phase 5: Code semantics
**Step 5.1**
Record: Modified: dw_mci_work_func. Callee: dw_mci_stop_dma → dma_ops->stop / dma_ops->cleanup (dw_mci_idmac_stop_dma or dw_mci_edmac_stop_dma, then dw_mci_dma_cleanup).
**Step 5.2**
Record: dw_mci_work_func is the host BH work (host->bh_work), queued from IRQ/timeout/DMA complete. Reachable on every data transfer for this host.
**Step 5.3**
Record: Completes MMC requests (dw_mci_data_complete, dw_mci_request_end → mmc_request_done).
**Step 5.4**
Record: Userspace (block I/O, ioctl, card init) triggers it via the MMC core. **Yes, reachable from userspace** on DW MMC hardware.
**Step 5.5**
Record: Same dw_mci_stop_dma() already used in STATE_SENDING_CMD (cmd+data error) and twice in STATE_SENDING_DATA. This fills the missing sibling.
## Phase 6: This tree
**Step 6.1**
Record: Tree is **v7.3-rc4** (git describe:v7.3-rc4-27-gf0100363d8c37, VERSION=7 PATCHLEVEL=3). Candidate **is an ancestor of HEAD**. Buggy pattern existed here before that commit; introduced in v2.6.38.
**Step 6.2**
Record: **Clean apply** on this tree (already applied). Context (dw_mci_stop_fault_timer then host->data = NULL) is present.
**Step 6.3**
Record: No other fix for this hole. faecf41106123 is a related double- unmap fix, not a substitute.
## Phase 7: Subsystem
**Step 7.1**
Record: **MMC host (Synopsys DesignWare).** **IMPORTANT** — eMMC/SD on Exynos, Rockchip, Hisilicon, StarFive, BlueField, K3 (MMC_DW_* in Kconfig). Not core mm/VFS, not staging.
**Step 7.2**
Record: File is actively maintained (refactors in 2026 plus this fix). The state machine itself is old and stable.
## Phase 8: Impact and risk
**Step 8.1**
Record: **Driver-specific / config-specific** (CONFIG_MMC_DW). Large ARM/embedded population.
**Step 8.2**
Record: Hits whenever STATE_DATA_BUSY finishes a DMA-using request that did not already go through stop_dma(). Common path still unmaps via the DMA complete callback or post_req. The leak is real on **DMA- submit failure → PIO**, and on any DATA_BUSY completion that never ran complete/stop. Unprivileged block I/O can reach the host.
**Step 8.3**
Record: **DMA mapping leak.** Leftover mappings: DMA-API warnings, IOMMU table growth, coherency issues if pages are reused while still mapped. **Severity: HIGH** on the leak path, **MEDIUM** overall because the hot success path already unmaps.
**Step 8.4**
Record: **Benefit: high** for DW MMC users (correct DMA lifetime, stop IDMAC after data-complete). **Risk: very low** (1 line, idempotent cleanup). **Ratio: favorable.**
## Phase 9: Synthesis
**For backporting**
- Real DMA-mapping leak; author is the DMA-mapping maintainer.
- One line, same helper already used in sibling states.
- dw_mmc co-maintainer Reviewed-by; MMC maintainer applied it.
- Hardware is common; bug dates to v2.6.38.
- Cleanup is idempotent; next request clears pending events.
- No series dependency, no follow-up revert.
**Against**
- No Fixes:/Cc: stable (expected in this pipeline).
- Ulf explicitly asked whether it belonged in stable; author never answered.
- No crash/syzbot report; success-path unmap often already happened.
- Leak is most clearly proven on the DMA-start-failure → PIO path, not every transfer.
**Unresolved**
- No stable@ discussion found (lore blocked).
- Exact reproducer Marek hit is not in the mail (only the mechanism).
**Stable rules**
1. Obviously correct and tested? **PASS** — 1-line, reviewed, in mainline since 2026-07-06.
2. Real user-affecting bug? **PASS** — leftover DMA mappings on DW MMC.
3. Important (crash/security/corruption/deadlock)? **PASS** — mapping leak can WARN, exhaust IOMMU, and cause coherency bugs; not a panic, but it is a real DMA-lifetime bug, not style.
4. Small and contained? **PASS** — +1 line, one file.
5. No new features/APIs? **PASS**.
6. Applies to this tree? **PASS**.
**Exception category:** none (not a device ID / quirk / DT / build / doc patch). It is a normal contained bugfix.
Ulf’s “tag for stable?” question is caution, not a NAK. The instructions say missing stable tags must not drive a NO. On technical merit this belongs in stable: tiny, correct, and it closes a DMA unmap hole in a widely deployed MMC host.
Verification:
- [Phase 1] Parsed tags: Marek SOB, Shawn Lin R-b, Ulf SOB; no Fixes/Reported-by/Cc: stable
- [Phase 2] Diff: +1 line dw_mci_stop_dma(host) in STATE_DATA_BUSY before host->data = NULL
- [Phase 2] dw_mci_stop_dma/dw_mci_dma_cleanup read; cleanup gated on COOKIE_MAPPED
- [Phase 2] IDMAC/EDMAC complete path already calls cleanup; using_dma not cleared on DMA-start failure (lines 998, 1010, 1039–1045, 1070)
- [Phase 3] blame: f95f3850f7a9e1 (v2.6.38); candidate cb3fcb8d118b8; related faecf41106123 double-unmap
- [Phase 3] git merge-base --is-ancestor cb3fcb8d118b8 HEAD — true; no follow-up fix on dw_mmc.c
- [Phase 4] b4 dig -c/-a/-w/-m: v1 only; Shawn R-b; Ulf applied and asked about stable; no author reply
- [Phase 4] lore WebFetch 403; mbox used instead
- [Phase 5] callers: BH work from IRQ/DTO/DMA complete; userspace via MMC core
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- [Phase 7] MAINTAINERS: Jaehoon Chung, Shawn Lin; Kconfig MMC_DW_* platforms
- [Phase 8] Failure mode: DMA mapping leak, severity HIGH on leak path
- UNVERIFIED: stable@ archive search (Anubis); exact runtime stack Marek saw
**YES**
drivers/mmc/host/dw_mmc.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/dw_mmc.c +1 -0
@@ -2213,6 +2213,7 @@ static void dw_mci_work_func(struct work_struct *t) }dw_mci_stop_fault_timer (host); +dw_mci_stop_dma (host); host->data =NULL ;set_bit (EVENT_DATA_COMPLETE , &host->completed_events); err =dw_mci_data_complete (host, data);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 libbpf: Fix ring buffer consumer loop on 32-bit position wrap
In reply to Sasha LevinFrom: Israel Téllez García <[email protected]>
[ Upstream commit fdd4fad0bbbd08501465c5f9b556963093c5d58a ]
ringbuf_process_ring() walks the records between the consumer and the producer with an ordering comparison:
while (cons_pos < prod_pos) {cons_pos and prod_pos mirror the kernel's ring positions and are unsigned long here too, so on 32-bit they wrap at 2^32 bytes of traffic. When producer_pos has wrapped and consumer_pos has not, prod_pos is the smaller of the two, the loop body never runs and no record is consumed. Since consumer_pos only advances inside that loop, it never wraps either and the consumer stops delivering samples for good, with no error returned to the caller: ring_buffer__poll() keeps reporting zero records while the kernel side fills up and starts dropping.
Compare the distance instead. The consumer never runs ahead of the producer, so prod_pos - cons_pos is the amount of unconsumed data and stays correct across the wrap.
64-bit hosts are unaffected in practice: the counters would need 16 EiB to wrap. This is the userspace counterpart of the kernel-side walk fixed in "bpf: Fix pending_pos walk on 32-bit ring position wrap"; a 32-bit consumer hits whichever of the two comes first.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[libbpf] [Fix] ring buffer consumer loop on 32-bit position wrap**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Signed-off-by:** Israel Téllez García <[email protected]> (author)
- **Signed-off-by:** Andrii Nakryiko <[email protected]> (libbpf/BPF maintainer)
- **Link:** https://lore.kernel.org/bpf/20260814124843.22041-5- [email protected]
- No Reported-by, Tested-by, Reviewed-by, Acked-by, or `Cc:
stable` on the original patch
- Original submission had **no Fixes: tag**. b4 am later attached a lore trailer: Fixes: bf99c936f947 ("libbpf: Add BPF ring buffer support") (DKIM/kernel.org). That SHA is the 2020 introduction of BPF ringbuf in libbpf, and it is in this tree.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** ringbuf_process_ring() uses while (cons_pos < prod_pos) on unsigned long positions. On 32-bit those wrap at 2^32 bytes. After producer wrap, prod_pos is small and cons_pos is still large, so the loop never runs.
- **Symptom:** ring_buffer__poll() / consume APIs keep returning 0 with no error; the kernel ring fills and drops samples permanently.
- **Root cause:** ordering comparison is not wrap-safe; consumer_pos only advances inside that loop, so it never wraps either.
- **Version info:** 64-bit is unaffected in practice (16 EiB to wrap). Explicitly the userspace counterpart of the kernel pending_pos walk. Field data for that sibling: four armv7 i.MX7 Dual devices on 6.6.52 stalled after exactly 4295491360 bytes (~2^32 + one 512 KiB ring).
- **Author’s fix:** prod_pos - cons_pos > 0 (unsigned distance).
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Subject and body describe a real wrap-induced stall. Not cleanup/refactor.
---
## Phase 2: Diff analysis
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: tools/lib/bpf/ringbuf.c — **1 line changed** (+1 / -1)
- Function: ringbuf_process_ring()
- Scope: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** while (cons_pos < prod_pos) — fails after producer wrap on 32-bit.
- **After:** while (prod_pos - cons_pos > 0) — unsigned modular distance; stays true while unconsumed data exists.
- Path: normal consume path (ring_buffer__poll / __consume / __consume_n / ring__consume*), not an error/init-only path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** logic/correctness (32-bit wrap / unsigned comparison)
- **Mechanism:** same class as kernel pending_pos. Unsigned unsigned long counters are documented to wrap (Documentation/bpf/ringbuf.rst). Distance arithmetic is already used in this tree in ring__avail_data_size() (return prod_pos - cons_pos) and kernel ringbuf_avail_data_sz().
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: matches the kernel-side pattern already in this tree (while (prod_pos - pend_pos > 0) in kernel/bpf/ringbuf.c).
- Minimal: one condition.
- Regression risk: low. On 64-bit equivalent until astronomical wrap. If consumer ever ran ahead of producer, the new check would wrap and keep looping; the author and kernel invariant say that does not happen. Same assumption the kernel pending_pos fix already shipped here.
---
## Phase 3: Git history investigation
**Step 3.1: BLAME THE CHANGED LINES**
Record: Buggy while (cons_pos < prod_pos) introduced in **bf99c936f9478** (“libbpf: Add BPF ring buffer support”, 2020-06-01) by Andrii Nakryiko. Present since BPF ringbuf existed. Surrounding `cnt
Quoted 1 line
= n
bits are later (13e8125a22763`, 2024) and unrelated.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: Original mail had no Fixes:. Trailer names bf99c936f947, which **is in this tree**. Kernel sibling 19de99ea47e3c (“bpf: Fix pending_pos walk on 32-bit ring position wrap”) **is already in this tree**; its Fixes: target cfa1a2329a691 is also here.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent tools/lib/bpf/ringbuf.c commits are consume_n overflow/return-value fixes, not wrap handling. This is standalone:
series patch 4/4. Cover letter: patches 1–3 are kernel; 4 is libbpf. Patches 2–3 are overwrite-mode ringbuf_avail_data_sz() — **overwrite_pos does not exist in this 6.12 tree**. Nakryiko dropped patch 3 anyway.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Israel Téllez García authored the kernel wrap fix already on this branch (19de99ea47e3c). Andrii Nakryiko (libbpf maintainer) applied both.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: No code dependency. One-line condition change in a function that already exists. git apply --check on the original mbox succeeded (exit 0). Does not need overwrite-mode patches.
---
## Phase 4: Mailing list and external research
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- Series: **[PATCH v2 bpf 0/4] bpf: Fix ring buffer position wrap handling on 32-bit**
- Lore: https://lore.kernel.org/bpf/20260814124843.22041-1- [email protected]
- This patch: [email protected] (4/4)
- v1: https://lore.kernel.org/bpf/20260806130214.66028-1- [email protected]/ (kernel pending_pos only; v2 added sites 2–4)
- v2 change for patch 1: drop (long) cast per Nakryiko; unsigned difference is enough
- Cover: patch 1 was the field-observed stall; patch 4 is the userspace counterpart. “A 32-bit consumer hits whichever of the two comes first.”
- No NAK on patch 4. Patch 3 was dropped by both author and Nakryiko (ordering of overwrite_pos loads).
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc included Andrii Nakryiko, Alexei Starovoitov, Daniel Borkmann, Eduard Zingerman, Martin KaFai Lau, Song Liu, Jiri Olsa, [email protected]. Applied by Nakryiko.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla for the libbpf loop itself. Field evidence is on the kernel sibling: four armv7 devices, exact 2^32-byte trigger, 8–17 h uptime, one patched device then passed 10 GiB. Cover: “Userspace kept consuming normally until the producer stopped” — meaning the kernel stall fired first. Once that kernel fix is in (it is, here), this libbpf loop is the next wrap failure.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record:
1. Kernel pending_pos — **already in this tree**
2. Overwrite-mode avail-data — **N/A here** (no overwrite_mode)
3. producer_pos vs overwrite_pos load order — dropped; **N/A here**
4. **This libbpf loop** — candidate
- User-ringbuf peek (u64 locals, cons_pos >= prod_pos) was called out as a separate issue and is **not** this commit. Confirmed still present at kernel/bpf/ringbuf.c:687.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** — lore.kernel.org/stable returned Anubis bot- challenge (403/HTML). No stable-list discussion retrieved.
---
## Phase 5: Code semantic analysis
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: ringbuf_process_ring() only. (semcode MCP not available; used hunk headers + grep.)
**Step 5.2: TRACE CALLERS**
Record: All in-tree callers of ringbuf_process_ring():
- ring_buffer__consume_n()
- ring_buffer__consume()
- ring_buffer__poll()
- ring__consume_n() / ring__consume()
These are the public libbpf ringbuf consume APIs. Reachable from any userspace consumer of BPF_MAP_TYPE_RINGBUF (tracing, networking, etc.). bpftool in this tree links tools/lib/bpf.
**Step 5.3: TRACE CALLEES**
Record: smp_load_acquire on positions/len, roundup_len(), r->sample_cb(), smp_store_release of consumer_pos. No allocation/locking in the changed condition.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace path: app/bpftool → ring_buffer__poll/consume → ringbuf_process_ring. Trigger: ~4 GiB cumulative ring traffic on 32-bit. Unprivileged if the process already has the map fd (typical tracing daemon). Not a kernel oops, but permanent event loss.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record:
- Same buggy compare in tools/testing/selftests/bpf/benchs/bench_ringbufs.c:305 (benchmark only; not this commit).
- Wrap-safe distance already in ring__avail_data_size() and kernel ringbuf_avail_data_sz().
- Kernel pending_pos already converted to distance in this tree.
---
## Phase 6: Cross-referencing against the local tree
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** Local tree is **6.12.111** (git describe:p-6.12-3-gc504cf0baa3d8, Makefile VERSION=6 PATCHLEVEL=12 SUBLEVEL=111).
```247:247:tools/lib/bpf/ringbuf.c
while (cons_pos < prod_pos) {
```struct ring uses unsigned long *consumer_pos / *producer_pos (lines 29–30). Bug introduced in v5.8-era libbpf ringbuf (bf99c936f9478), long before 6.12. Positions are still unsigned long in kernel struct bpf_ringbuf.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** git apply --check on the original patch mbox exited 0. Function shape matches the hunk (ringbuf_process_ring(struct ring *r, size_t n) with cons_pos/prod_pos as unsigned long).
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: Kernel pending_pos wrap fix **is** here (19de99ea47e3c). Userspace loop still has cons_pos < prod_pos. No alternate libbpf wrap fix in this file.
---
## Phase 7: Subsystem and maintainer context
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **libbpf** (tools/lib/bpf/) — userspace helper shipped with the kernel, used by bpftool and in-tree BPF tools. Criticality:
**IMPORTANT** for BPF users, especially 32-bit embedded collectors. Not core mm/sched, but this tree already backports libbpf ringbuf fixes (087d757fb4736, 00f0e08f23fc0).
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained; libbpf ringbuf APIs grew through 6.12 (ring__consume_n, etc.). The wrap bug is old (2020), not a new-feature leftover.
---
## Phase 8: Impact and risk assessment
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Config/platform-specific:** 32-bit hosts using in-tree libbpf to consume BPF_MAP_TYPE_RINGBUF (armv7/i.MX and similar LTS/embedded). 64-bit unaffected in practice.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: After ~4 GiB of ring traffic, if producer wraps while consumer still has unconsumed bytes. Common with epoll/batching. Timing-dependent at the wrap, then **sticky forever**. Unprivileged if the process already holds the map. The sibling bug was reproduced at 441–862 records/s over hours — not a theoretical corner.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Permanent silent stop of sample delivery; kernel then drops events; APIs return 0 with no error. **HIGH** data/event loss (not a kernel oops). Restart of the consumer is required.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit: high for 32-bit BPF consumers.** Kernel producer wrap is already fixed here, so this is now the remaining stall. Same class as a field-proven 6.6.52 armv7 outage.
- **Risk: very low.** One comparison, same idiom as kernel code already on this branch.
- Ratio: strongly favors backport.
---
## Phase 9: Final synthesis
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real wrap bug; documented that 32-bit positions wrap
- Permanent silent event loss, no error
- One-line, obviously correct, applies cleanly
- Kernel counterpart already in this 6.12.y tree — without this, producer keeps going and userspace is the next stall
- Field-proven sibling on armv7 (core LTS/embedded)
- Maintainer SOB (Nakryiko); v2 reviewed
- No new APIs; no overwrite-mode dependency
**AGAINST:**
- Userspace libbpf (some distros use github libbpf, not in-tree)
- 32-bit only in practice
- Original field report hit kernel pending_pos first
- No Cc: stable on the original mail (expected for this review queue; not a negative)
**UNRESOLVED:**
- Could not query lore.kernel.org/stable (bot wall)
- Could not confirm whether standalone libbpf already carries this (irrelevant: verdict is for in-tree tools/lib/bpf)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — same unsigned-distance idiom as kernel code already here; series tested on armv7 for the sibling; maintainer applied it.
2. Fixes a real bug that affects users? **PASS** — 32-bit ringbuf consumers stall after wrap.
3. Important issue (crash, security, corruption, deadlock)? **PASS** at HIGH — permanent silent event loss, not an oops, but equivalent operational failure for tracing/telemetry.
4. Small and contained? **PASS** — 1 line, 1 file.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — git apply --check succeeded; buggy loop present.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/docs exception. Ordinary small bugfix.
**Step 9.4: DECISION**
This belongs on **this** 6.12.y tree. The buggy cons_pos < prod_pos loop is here; the matching kernel wrap fix is already here; the one-line change applies cleanly and closes the remaining 32-bit stall for in-tree libbpf consumers.
### What the commit solves and why it matters here
On 32-bit, ring positions are 32-bit unsigned long and are documented to wrap. After producer wrap, the consumer loop never runs, never advances consumer_pos, and never recovers. ring_buffer__poll() reports 0 forever while the kernel drops samples. 6.12.y already contains the kernel pending_pos wrap fix, so a 32-bit producer can now wrap; this userspace loop is the next failure. 32-bit ARM collectors are a real LTS audience (the sibling was seen on i.MX7 Dual).
### Risk vs benefit
Benefit is high for 32-bit BPF ringbuf users; risk is a one-line comparison already used in-kernel on this branch.
---
### Verification
- **[Phase 1]** Parsed subject/tags/body from the candidate and from /tmp/ringbuf-mbox/wrap-p5; Fixes: only as a later lore trailer to bf99c936f947
- **[Phase 2]** Diff is one condition in ringbuf_process_ring(); current tree still has while (cons_pos < prod_pos) at line 247
- **[Phase 3]** git blame → bf99c936f9478 (2020); git merge-base --is-ancestor confirms that SHA, cfa1a2329a691, and kernel wrap fix 19de99ea47e3c are in HEAD
- **[Phase 3]** git log --oneline -- tools/lib/bpf/ringbuf.c — no userspace wrap fix present
- **[Phase 4]** b4 dig -c 19de99ea47e3c -a/-w → v2 4-patch series; this is 4/4
- **[Phase 4]** Cover letter and patches from /tmp/ringbuf- series/*.cover and .mbx; Nakryiko dropped patch 3 (/tmp/ringbuf- mbox/nakryiko)
- **[Phase 4]** lore.kernel.org HTTP 403 / Anubis; used b4 mboxes instead
- **[Phase 5]** grep callers of ringbuf_process_ring in tools/lib/bpf/ringbuf.c; public consume/poll APIs
- **[Phase 6]** git describe HEAD → p-6.12-3-gc504cf0baa3d8; make kernelversion → 6.12.111
- **[Phase 6]** git apply --check /tmp/ringbuf-mbox/wrap-p5 exit 0
- **[Phase 6]** overwrite_pos / overwrite_mode absent from kernel/bpf/ringbuf.c in this tree
- **[Phase 7/8]** Documentation/bpf/ringbuf.rst documents 32-bit wrap; kernel sibling commit describes four armv7 devices
- **UNVERIFIED:** stable@ lore discussion; whether distro standalone libbpf already has this
**YES**
tools/lib/bpf/ringbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/ringbuf.c +1 -1
@@ -244,7 +244,7 @@ static int64_t ringbuf_process_ring(struct ring *r, size_t n) do { got_new_data = false; prod_pos = smp_load_acquire(r->producer_pos); - while (cons_pos < prod_pos) { + while (prod_pos - cons_pos > 0) { len_ptr = r->data + (cons_pos & r->mask); len = smp_load_acquire(len_ptr);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: mt76: mt7921: fix memory leak when skb_linearize fails in mcu rx event
In reply to Sasha LevinFrom: Prashant Rahul <[email protected]>
[ Upstream commit 4361f1660101270611eb5dc39799f620b35f2e4d ]
The ownership of sk_buff skb is passed to mt7921_queue_rx_skb, each path inside it under the switch case handles cleaning of skb and it is true for mt7921_mcu_rx_event as well.
mt7921_mcu_rx_event, on a success path, either queues skb via mt76_mcu_rx_event or cleans it immediately inside mt7921_mcu_uni_rx_unsolicited_event.
However inside mt7921_mcu_rx_event, if skb_linearize fails, the function returns immediately and never bothers cleaning skb which leaks skb.
Since skb is fully owned at this point, it is safe to call dev_kfree_skb which fixes the leak.
Granted, the skb_linearize failure is rare as it can only fail under heavy memory usage, but at the same time, leaking memory under heavy memory usage can worsen the OOM condition.
---
LLM Generated explanations, may be completely bogus:
# Stable backport analysis: mt7921 MCU RX skb leak
**Tree decided:** pending-6.6 (6.6.157), SHA 04810563abb71. At the start of this evaluation git describe/make kernelversion reported **6.6.157**. The working copy later moved to v7.3-rc4; every presence/absence claim below was rechecked against **pending-6.6**, not that later checkout.
The candidate is mainline 4361f16601012 (wifi: mt76: mt7921: fix memory leak when skb_linearize fails in mcu rx event).
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1 — Subject**
Record: **[wifi: mt76: mt7921]** **[fix]** memory leak when skb_linearize fails in MCU RX event.
**Step 1.2 — Tags**
- Signed-off-by: Prashant Rahul <[email protected]> (author)
- `Link: https://patch.msgid.link/20260716-mt7921-mem-
[email protected]`
- Signed-off-by: Felix Fietkau <[email protected]> (mt76 maintainer; applied the patch)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, or Cc: stable (absence of Fixes/Cc-stable is expected for this review).
Record: Maintainer SOB; msgid shows **v1 patch 1/1** (standalone).
**Step 1.3 — Body**
Record:
- **Bug:** mt7921_queue_rx_skb transfers skb ownership into mt7921_mcu_rx_event. Success paths free or queue the skb. If skb_linearize() fails, the function returns without freeing.
- **Symptom:** skb leak. Author notes failure is rare (ENOMEM) but leaking under memory pressure can worsen OOM.
- **Root cause:** missing dev_kfree_skb on the linearize error path.
- **Version info in message:** none.
**Step 1.4 — Hidden bug fix?**
Record: **No disguise.** This is an explicit leak fix, not cleanup-as- fix.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1 — Inventory**
Record:
- File: drivers/net/wireless/mediatek/mt76/mt7921/mcu.c (**+3 / −1**)
- Function: mt7921_mcu_rx_event
- Scope: **single-file surgical fix**
**Step 2.2 — Flow**
Before (pending-6.6 mcu.c:312-313):
```
if (skb_linearize(skb))
return;
```After:
```
if (skb_linearize(skb)) {
dev_kfree_skb(skb);
return;
}
```Record: **error path only.** Success paths unchanged.
**Step 2.3 — Bug mechanism**
Record: **[resource leak]** On skb_linearize failure (-ENOMEM for nonlinear skbs), the still-owned skb is dropped. Caller mt7921_queue_rx_skb does not free after PKT_TYPE_RX_EVENT. Other switch arms in the same caller (dev_kfree_skb / napi_consume_skb) and other arms of mt7921_mcu_rx_event (dev_kfree_skb, mt76_mcu_rx_event queue) already consume the skb.
**Step 2.4 — Fix quality**
Record: **Obviously correct.** Matches established kernel pattern (if (skb_linearize(skb)) { dev_kfree_skb(_any)(skb); return; }). Same free helper already used in this MCU event path. No API/lock/data-structure change. Regression risk: **very low** (could only be a double-free if linearize already freed; it does not — see Phase 5).
---
## PHASE 3: GIT HISTORY
**Step 3.1 — Blame**
Record: Leak introduced by **f0ff5d3aa64812** (mt76: mt7921: make all event parser reusable between mt7921s and mt7921e, Sean Wang, 2021-10-19). That commit added skb_linearize + early return and never freed on failure. Present since ~5.16-era; **git merge-base --is- ancestor f0ff5d3aa64812 pending-6.6 succeeds.**
**Step 3.2 — Fixes: tag**
Record: **None.** Introducer identified by blame: f0ff5d3aa64812, which **is** in this 6.6 tree.
**Step 3.3 — File history (pending-6.6)**
Recent 6.6 work on this file is CLC firmware validation, not MCU RX. No competing leak fix. Record: **standalone**; not part of a multi-patch series.
**Step 3.4 — Author**
Prashant Rahul has **no other commits** in this tree’s mt76 history. Applied by **Felix Fietkau**, listed maintainer of MEDIATEK MT76 in MAINTAINERS. Record: one-off contributor; **maintainer-applied**.
**Step 3.5 — Dependencies**
The hunk only needs mt7921_mcu_rx_event + skb_linearize + dev_kfree_skb, all present. Mailing-list patch context matches 6.6 (the extra MCU_EVENT_RSSI_NOTIFY in later mainline is **below** the change). Record: **applies standalone**.
---
## PHASE 4: MAILING LIST / EXTERNAL
**Step 4.1 — Original discussion**
- b4 dig -c <msgid> / b4 mbox: no match (404).
- lore.kernel.org: **403**.
- Recovered from Openwall and Ratatoskr:
https://lists.openwall.net/linux-kernel/2026/07/16/1707
msgid [email protected]
Record: **v1, single patch**, applied as submitted (4361f16601012 matches that diff). No v2/v3.
**Step 4.2 — Recipients (b4 dig -w unavailable; headers from Openwall)**
To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen, Sean Wang (mt76 maintainers/reviewers), plus MediaTek ARM contacts. Cc: linux- wireless, linux-kernel, linux-mediatek, linux-arm-kernel. Record:
**correct maintainer set**.
**Step 4.3 — Bug report**
Record: **No syzbot/bugzilla.** Static ownership analysis; author states the leak is rare.
**Step 4.4 — Series**
Record: **1/1 standalone.** No sibling mt7925/mt7915 patches required for this tree (only mt7921 has this skb_linearize in pending-6.6).
**Step 4.5 — Stable list**
Search for this subject on lore stable returned unrelated hits. Record:
**no prior stable NAK found** (lore 403 limited this).
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1 — Functions**
Record: mt7921_mcu_rx_event only.
**Step 5.2 — Callers**mt7921_queue_rx_skb() (mac.c) case PKT_TYPE_RX_EVENT: calls it and does **not** free afterwards.
That rx_skb hook is registered for **PCIe, USB, and SDIO**:
- mt7921/pci.c, usb.c, sdio.c → .rx_skb = mt7921_queue_rx_skb
- Invoked from mt76_dma_rx_process (NAPI), mt76u USB RX, mt76s_process_rx_queue (SDIO)
Record: **hot RX path** for MT7921E/S/U.
**Step 5.3 — Callees**skb_linearize → __skb_linearize → __pskb_pull_tail; returns -ENOMEM on failure and **does not free** the skb (include/linux/skbuff.h: “If there is no free memory -ENOMEM is returned”). Success continues to mt7921_mcu_uni_rx_unsolicited_event / mt76_mcu_rx_event / mt7921_mcu_rx_unsolicited_event.
**Step 5.4 — Reachability**
Nonlinear MCU events are real:
- SDIO mt76s_build_rx_skb uses skb_add_rx_frag when payload > MT_SKB_HEAD_LEN — this is **why** f0ff5d3aa64812 added linearize (“paged fragment skb for the SDIO device”).
- USB mt76u_build_rx_skb same pattern.
- DMA mt76_add_fragment builds fraglists for multi-buffer RX.
Record: reachable from normal firmware MCU events; unprivileged users can generate MCU traffic by using WiFi. Failure needs **ENOMEM during linearize**.
**Step 5.5 — Similar patterns**
In pending-6.6, skb_linearize appears **only here** under mt76. No duplicate site left unfixed in this tree.
---
## PHASE 6: LOCAL TREE (pending-6.6 / 6.6.157)
**Step 6.1 — Buggy code present?**
Record: **Yes.** pending-6.6:drivers/net/wireless/mediatek/mt76/mt7921/mcu.c:312-313:
```
if (skb_linearize(skb))
return;
```git merge-base --is-ancestor 4361f16601012 pending-6.6 → **false** (fix not here).git merge-base --is-ancestor f0ff5d3aa64812 pending-6.6 → **true** (bug intro is here).
Bug age: **2021**, well before 6.6.
**Step 6.2 — Backport difficulty**
Submitted hunk is 4 lines around skb_linearize with context that matches 6.6 (struct mt76_connac2_mcu_rxd *rxd then the if). MCU_EVENT_RSSI_NOTIFY is later mainline-only context **below** the edit. Record: **clean apply / trivial**.
**Step 6.3 — Related fixes already here?**git log --grep=skb_linearize on mt76 in this tree: **empty**. No alternate fix. Record: **none**.
---
## PHASE 7: SUBSYSTEM CONTEXT
**Step 7.1**
Record: **wifi / mt76 / mt7921**. Criticality: **IMPORTANT** — MT7921E is a common laptop WiFi 6 adapter (PCIe); USB/SDIO variants exist (MT7921E/S/U in Kconfig). Not core mm/net, not staging.
**Step 7.2**
Record: Mature driver (MCU support from 1c099ab44727c8, 2021). 6.6 still receives mt76 bugfixes (CLC, etc.).
---
## PHASE 8: IMPACT AND RISK
**Step 8.1 — Who is affected**
Record: **driver-specific**, users with MediaTek MT7921 (very common on laptops). Config: CONFIG_MT7921E/S/U.
**Step 8.2 — Trigger**
Record: Firmware MCU RX event whose skb is nonlinear, **and** skb_linearize fails (GFP/ENOMEM). Unprivileged WiFi use can generate events; the failure itself is **uncommon**. SDIO long events are the originally cited nonlinear case; USB/DMA can also fragment.
**Step 8.3 — Failure mode**
Record: **skb leak under memory pressure**, which can deepen OOM. Not a panic/UAF. Severity: **MEDIUM–HIGH** (hot-path leak, not a one-time probe leak).
**Step 8.4 — Risk/benefit**
- Benefit: **medium** — stops a real leak on a widely shipped chip; most valuable when the system is already under memory pressure.
- Risk: **very low** — 3 lines, error path, same free as sibling paths.
- Ratio: **favor backport**.
---
## PHASE 9: SYNTHESIS
**Step 9.1 — Evidence**
**For:**
- Real leak with verified ownership (caller does not free).
- Code and introducer are in 6.6.157; fix is not.
- Tiny, obviously correct, maintainer-applied.
- MT7921 is production hardware, not staging.
- Leak on an RX path under OOM is a stability issue, not a style cleanup.
**Against:**
- Trigger is rare (skb_linearize ENOMEM).
- No crash/syzbot/CVE.
- No explicit Cc: stable (not a negative per the review rules).
**Unresolved:** Full lore thread (403/404); no reviewer comments beyond maintainer merge. Does not change the technical verdict.
**Step 9.2 — Stable rules**
1. Obviously correct and tested — **PASS** (3-line ownership fix; in mainline via Felix).
2. Real bug affecting users — **PASS** (skb leak on MT7921 MCU RX).
3. Important (crash/security/corruption/deadlock) — **PASS** as an RX- path leak that can worsen OOM; not a panic, but in the leak class stable regularly takes.
4. Small and contained — **PASS** (4 lines, one function).
5. No new features/APIs — **PASS**.
6. Can apply to this tree — **PASS** (hunk matches 6.6).
**Step 9.3 — Exceptions**
Record: none needed (not an ID/quirk/DT/build/doc exception). Ordinary small leak fix.
**Step 9.4 — Decision**
Backport to **this** 6.6.157 tree. The bug exists here, the fix is surgical, and regression risk is negligible.
---
## What the commit solves for stable users
On MT7921, firmware MCU events are handed to mt7921_mcu_rx_event with full skb ownership. Nonlinear events (especially SDIO, also USB/DMA fragments) are linearized first. If that allocation fails, 6.6 returns and leaks the skb. Under memory pressure that leak makes OOM worse. Adding dev_kfree_skb(skb) on that path closes the leak without changing success behavior.
## Risk vs benefit
Benefit is a real leak fix on a common WiFi chip; risk is a three-line error-path free that matches existing code in the same function.
## Concerns
None material: no prerequisites, no API change, no locking, expected clean apply. Trigger rarity is the only weak point and is not enough to reject a contained leak fix.
---
## Verification
- **[Phase 1]** Parsed tags: author SOB, Link msgid, Felix Fietkau SOB; no Fixes/Reported-by/Cc-stable.
- **[Phase 2]** Diff: +3/−1 in mt7921_mcu_rx_event; adds dev_kfree_skb on skb_linearize failure.
- **[Phase 3]** git blame on pending-6.6: leak from f0ff5d3aa64812 (2021-10-19); git merge-base --is-ancestor f0ff5d3aa64812 pending-6.6 true.
- **[Phase 3]** git show f0ff5d3aa64812: added if (skb_linearize(skb)) return; with no free.
- **[Phase 3]** git log --author=Prashant Rahul: no other mt76 commits in this history.
- **[Phase 4]** Openwall/Ratatoskr: v1 1/1, same diff as 4361f16601012; mt76 maintainers on To:.
- **[Phase 4]** b4 mbox msgid: 404; lore.kernel.org: 403. **UNVERIFIED:** full review replies / explicit stable nomination.
- **[Phase 5]** Callers: mt7921_queue_rx_skb (no free on PKT_TYPE_RX_EVENT); hooked from pci/usb/sdio .rx_skb.
- **[Phase 5]** skb_linearize documented to return -ENOMEM and not free; USB/SDIO skb_add_rx_frag makes nonlinear skbs.
- **[Phase 6]** git describe at start: p-6.6-3-g04810563abb71, make kernelversion 6.6.157.
- **[Phase 6]** git grep on pending-6.6: leak at mcu.c:312-313.
- **[Phase 6]** git merge-base --is-ancestor 4361f16601012 pending-6.6 false.
- **[Phase 8]** Failure mode: skb leak under ENOMEM on MCU RX; severity MEDIUM–HIGH.
- **UNVERIFIED:** complete lore thread text after 403.
The fix is small, matches stable leak-fix practice, and the buggy code is in this 6.6 tree.
**YES**
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +3 -1
@@ -354,8 +354,10 @@ void mt7921_mcu_rx_event(struct mt792x_dev *dev, struct sk_buff *skb) {struct mt76_connac2_mcu_rxd *rxd; -if (skb_linearize (skb)) +if (skb_linearize (skb)) { +dev_kfree_skb (skb);return ; + } rxd = (struct mt76_connac2_mcu_rxd *)skb->data;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 PCI: switchtec: Add Microchip PCI1008 device ID
In reply to Sasha LevinFrom: Logan Gunthorpe <[email protected]>
[ Upstream commit 0d8a6306c680ee534be131e360f0cafa2bada7be ]
Add the Microchip PCI1008 device ID to the core switchtec management driver's PCI ID table. Without it, the management endpoint on a PCI1008 switch is not bound by this driver, preventing userspace tools from configuring or monitoring the switch and leaving NTB functionality unavailable.
---
LLM Generated explanations, may be completely bogus:
This is a one-line PCI ID addition to an existing Switchtec driver. The local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). SWITCHTEC_PCI100X_DEVICE and the PCI1001–PCI1006 IDs are already here, so the patch is applicable.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [PCI: switchtec] [Add] [Microchip PCI1008 device ID to the existing switchtec management driver’s PCI ID table]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Logan Gunthorpe <[email protected]> (author; listed maintainer of PCI DRIVER FOR MICROSEMI SWITCHTEC)
- Signed-off-by: Bjorn Helgaas <[email protected]> (PCI maintainer)
- Link:
https://patch.msgid.link/[email protected]
- No Fixes: tag (expected)
- No Reported-by / Tested-by / Reviewed-by / Acked-by / Cc: stable on this commit
- Ignore any Sasha Levin SOB (none on the real commit)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: PCI1008 management endpoint is not bound because 0x1008 is missing from switchtec_pci_tbl.
- Symptom: userspace cannot configure/monitor the switch via /dev/switchtecX; NTB is unavailable (probe requests ntb_hw_switchtec only after this driver binds).
- Version info: series was based on v7.2-rc3; applied by Helgaas for v7.3.
- Root cause: incomplete ID table for a new PCI100x SKU, not a logic bug.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a hidden cleanup. It is an explicit device-ID enablement. Stable rules treat “just add a device ID” as an accepted class.
===============================================================
PHASE 2: DIFF ANALYSIS
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/pci/switch/switchtec.c (+1 / −0)
- Function/data: switchtec_pci_tbl[] (static PCI ID table)
- Scope: single-file, one-line surgical change
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Before: PCI1001–PCI1006 (vendor PCI_VENDOR_ID_EFAR / 0x1055) match via SWITCHTEC_PCI100X_DEVICE; 0x1008 does not.
- After: 0x1008 matches the same way as 0x1001–0x1006, with driver_data = SWITCHTEC_GEN4.
- Path: PCI enumeration → pci_driver.id_table match → switchtec_pci_probe().
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- Category: hardware enablement / device ID addition
- Mechanism: without the ID, the management function is unbound. Probe also does request_module_nowait("ntb_hw_switchtec") for PCI_CLASS_BRIDGE_OTHER, so NTB never attaches.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: same macro and generation as sibling PCI100x IDs.
- Minimal: one table line, no API/behavior change for other devices.
- Regression risk: very low; only PCI1008 (vendor 0x1055, device 0x1008) is newly bound.
- Red flags: none.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- PCI1001–PCI1006: a3282f84b2151 (“PCI: switchtec: Add Microchip PCI100X device IDs”, 2025-01-20), first described as v6.13-rc1-1-ga3282f84b2151.
- Sentinel {0}: original driver from 2017 (080b47def5e5e2).
- PCI1008 line: this commit 0d8a6306c680e.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES** Record:
- a3282f84b2151 added the PCI100X macro, IDs 0x1001–0x1006, and matching SWITCHTEC_PCI100X_QUIRK entries.
- Series companions (same author/date):
- 8b326de3cc02c dmaengine: switchtec-dma: Add PCI1008 device ID
(msgid -2)
- 00a479ba1d012 PCI: switchtec: Add Microchip PCI1008 to NTB DMA alias quirk (msgid -4)
- This commit is standalone for the management driver. The quirk is needed for NTB DMA under IOMMU; DMA ID is a different PCI function.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Logan Gunthorpe is a listed maintainer (MAINTAINERS: PCI DRIVER FOR MICROSEMI SWITCHTEC). He authored the original switchtec driver and this ID series.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Record:
- Needs SWITCHTEC_PCI100X_DEVICE and SWITCHTEC_GEN4 — both present here.
- Does not need the dmaengine or quirk commits to compile or bind the management device.
- Applies standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 0d8a6306c680e:
https://patch.msgid.link/[email protected]
- Series: v1 only, [PATCH v1 0/3] switchtec: add new device IDs (2026-07-14)
- Cover: IDs for PCI driver, DMA driver, and NTB quirk; based on v7.2-rc3; intended for the PCI tree
- Sashiko: “found no issues” on this patch
- Bjorn Helgaas (2026-07-17): “Applied to pci/switchtec for v7.3, thanks!”
- No NAKs. Unrelated Sashiko note on quirk_switchtec_ntb_dma_alias() pointer arithmetic was explicitly not a blocker.
- No Cc: stable in the thread.
**Step 4.2: CHECK WHO REVIEWED THE PATCH** Record (b4 dig -w):
- To: linux-pci, dmaengine, Vinod Koul, Bjorn Helgaas
- Cc: Frank Li, Kelvin Cao (Microchip)
- Vinod Acked-by on the dmaengine ID
- PCI maintainer applied the series
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No bugzilla/syzbot. Author is the subsystem maintainer adding a new SKU. Cover letter says Sashiko reminded him the management ID and NTB quirk were also required.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 3 independent one-line ID/quirk additions. This patch is 2/3 and self-contained. Companion quirk is valuable for PCI1008 NTB+IOMMU but is a separate candidate.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search returned HTTP 403. Thread mbox has no “stable” mentions. UNVERIFIED: whether -stable already discussed this ID.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: No function body changed. Data: switchtec_pci_tbl[].
Consumers: switchtec_pci_driver.id_table, MODULE_DEVICE_TABLE(pci, ...). Probe: switchtec_pci_probe().
**Step 5.2: TRACE CALLERS**
Record: PCI core matches id_table at enumeration/hotplug. Probe creates /dev/switchtecX, enables MRPC, and may load ntb_hw_switchtec. NTB uses class_interface on switchtec_class (no second PCI ID table).
**Step 5.3: TRACE CALLEES**
Record: Probe calls stdev_create, switchtec_init_pci, switchtec_init_isr, cdev_device_add. Existing paths; ID only selects them for this device.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable when a PCI1008 is present (CONFIG_PCI_SW_SWITCHTEC). Unprivileged users do not enumerate PCI IDs; impact is hardware owners of this switch.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same family already lists 0x1001–0x1006. DMA driver has 0x1008. quirks.c has SWITCHTEC_PCI100X_QUIRK(0x1008) from the companion commit.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. drivers/pci/switch/switchtec.c has SWITCHTEC_PCI100X_DEVICE and PCI1001–PCI1006. Without 0x1008, PCI1008 would not bind. Prerequisite a3282f84b2151 is an ancestor (git merge- base --is-ancestor succeeded). PCI100X support dates to v6.13-rc1.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply. Adjacent lines are the existing PCI100x block. No refactor conflicts in this checkout.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No alternate PCI1008 ID in switchtec.c besides this line. Companion DMA ID and NTB quirk are also present here as separate commits.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: [PCI switch management driver drivers/pci/switch/] [PERIPHERAL — specific Microchip/Microsemi Switchtec hardware; NTB/management users]
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature (driver since 2017). Recent work is mostly new IDs (Gen5, Gen6, PCI100x). Typical stable ID-table churn.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver-specific / config-specific (CONFIG_PCI_SW_SWITCHTEC). Only PCI1008 (0x1055:0x1008). Other Switchtec IDs unchanged.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Trigger is plugging/booting with a PCI1008. Common for that hardware; impossible otherwise. Not a userspace-triggerable crash.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Device not bound → no /dev/switchtecX, no NTB. Severity MEDIUM for those systems (hardware unusable for management/NTB), LOW for everyone else. Not a panic/UAF.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: high for PCI1008 owners (management + NTB enablement); documented stable exception.
- Risk: very low (one ID line, existing macro).
- Ratio: strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Stable rules: “fix a real bug … or just add a device ID” (Documentation/process/stable-kernel-rules.rst).
- Existing driver + PCI100X macro in this tree.
- One line, same pattern as PCI1001–PCI1006.
- Maintainer-authored, PCI maintainer applied, no NAKs.
- Real user impact: management chardev and NTB never attach without the ID.
AGAINST:
- Not a crash/security fix; new SKU enablement only.
- Affects a niche PCIe switch.
- Companion quirk is a separate patch (NTB DMA under IOMMU still incomplete without it). That does not make this ID wrong or unsafe.
UNRESOLVED:
- lore.kernel.org HTTP 403; stable@ discussion not verified beyond the saved thread (no “stable” hits there).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — identical to existing PCI100x entries; applied by PCI maintainer.
2. Fixes a real bug that affects users? **PASS** — PCI1008 otherwise unbound (or qualifies as a device ID addition).
3. Important issue? **PASS** under the device-ID exception (not a panic).
4. Small and contained? **PASS** — +1 line, one file.
5. No new features or APIs? **PASS** — ID only; no new ioctls/sysfs.
6. Can apply to the local tree? **PASS** — SWITCHTEC_PCI100X_DEVICE and sibling IDs present.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Device ID addition to an existing driver.
**Step 9.4: DECISION**
This is the standard stable device-ID case. The driver and PCI100x helper exist in this tree, the change is one table line, and without it PCI1008 management/NTB never bind. Risk is negligible.
The companion NTB DMA alias quirk is a separate one-line candidate; this ID patch does not depend on it.
Verification:
- [Phase 1] Parsed tags: Logan Gunthorpe SOB, Bjorn Helgaas SOB, lore Link; no Fixes/Reported-by/Cc: stable
- [Phase 1] git describe HEAD / Makefile: local tree is 7.3.0-rc4 (v7.3-rc4-27-gf0100363d8c37)
- [Phase 2] Diff: +1 line in switchtec_pci_tbl[] — SWITCHTEC_PCI100X_DEVICE(0x1008, SWITCHTEC_GEN4)
- [Phase 2] Confirmed probe uses id_table and requests ntb_hw_switchtec for bridge class
- [Phase 3] git blame: PCI1001–1006 from a3282f84b2151 (v6.13-rc1); PCI1008 from 0d8a6306c680e
- [Phase 3] git merge-base --is-ancestor a3282f84b2151 HEAD succeeded
- [Phase 3] Series companions: 8b326de3cc02c (DMA ID), 00a479ba1d012 (NTB quirk)
- [Phase 4] b4 dig -c 0d8a6306c680e: lore URL found; v1-only 3-patch series
- [Phase 4] b4 dig -w: linux-pci, Bjorn Helgaas, Vinod Koul, Microchip Cc
- [Phase 4] mbox: Helgaas applied for v7.3; Sashiko clean on this patch; Vinod Acked DMA ID; no NAK
- [Phase 4] UNVERIFIED: stable@ mailing list (lore HTTP 403)
- [Phase 5] NTB binds via switchtec_class class_interface; this ID is required for NTB attach
- [Phase 6] File in tree has PCI100x macro and IDs; patch applies cleanly
- [Phase 7] Maintainer entry: Logan Gunthorpe for Switchtec
- [Phase 8] Failure: device unbound, not a kernel crash; device-ID exception applies
- [Phase 9] stable-kernel-rules.rst line 15 explicitly allows device ID additions
**YES**
drivers/pci/switch/switchtec.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/switch/switchtec.c +1 -0
@@ -1874,6 +1874,7 @@ static const struct pci_device_id switchtec_pci_tbl[] = {SWITCHTEC_PCI100X_DEVICE (0x1004 ,SWITCHTEC_GEN4 ),/* PCI1004 16XG4 */ SWITCHTEC_PCI100X_DEVICE (0x1005 ,SWITCHTEC_GEN4 ),/* PCI1005 16XG4 */ SWITCHTEC_PCI100X_DEVICE (0x1006 ,SWITCHTEC_GEN4 ),/* PCI1006 16XG4 */ +SWITCHTEC_PCI100X_DEVICE (0x1008 ,SWITCHTEC_GEN4 ),/* PCI1008 16XG4 */ {0} };MODULE_DEVICE_TABLE (pci, switchtec_pci_tbl);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-6.1] PCI: switchtec: Add Microchip PCI1008 device ID
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines
From: Logan Gunthorpe <[email protected]>
[ Upstream commit
0d8a6306c680ee534be131e360f0cafa2bada7be]Add the Microchip PCI1008 device ID to the core switchtec management driver's PCI ID table. Without it, the management endpoint on a PCI1008 switch is not bound by this driver, preventing userspace tools from configuring or monitoring the switch and leaving NTB functionality unavailable.
Quoted 4 lines
Signed-off-by Logan Gunthorpe <[email protected]>Signed-off-by Bjorn Helgaas <[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 wifi: mac80211_hwsim: clear PMSR request state on abort
In reply to Sasha LevinFrom: Zhao Li <[email protected]>
[ Upstream commit 37a77bd1395e8261d1760ae39c7f5eb637300550 ]
mac80211_hwsim saves the in-flight cfg80211 PMSR request and its wdev in data->pmsr_request / data->pmsr_request_wdev when a measurement starts, and clears them only when it reports completion.
mac80211_hwsim_abort_pmsr() never cleared that saved state. cfg80211 owns the request and frees it once the abort callback returns (cfg80211_pmsr_process_abort() calls rdev_abort_pmsr() then kfree(req)), so after an abort data->pmsr_request dangles. A later hwsim PMSR report then dereferences the freed request in hwsim_pmsr_report_nl() and completes it; a use-after-free.
Clear data->pmsr_request and data->pmsr_request_wdev once the abort matches the active request. Move the wmediumd/virtio notification check below the clear so the saved state is dropped even when no notification is sent.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: **[wifi: mac80211_hwsim]** **[clear]** in-flight PMSR request pointers when abort matches, so cfg80211’s free cannot leave a dangling data->pmsr_request.
**Step 1.2: Tags**
Committed message (pipeline-stripped):
- Link: https://patch.msgid.link/20260708195911.84365-2- [email protected]
- Assisted-by: Codex:gpt-5, Claude:opus-4.8
- Signed-off-by: Zhao Li; Johannes Berg
- No Fixes:/Cc: stable/Reported-by in the committed text (expected for this pipeline)
Original mailing-list submission (from the saved mbox, not used as circular “already selected” evidence):
- Fixes: 5530c04c87c5 (“mac80211_hwsim: add PMSR request support via virtio”)
- Cc: [email protected]
- Cover letter: [PATCH 0/8] wifi: fix PMSR lifetime and frame validation issues
**Step 1.3: Body**
Record:
- **Bug:** mac80211_hwsim_abort_pmsr() never NULLs data->pmsr_request / data->pmsr_request_wdev. cfg80211 owns the request and kfree(req) after rdev_abort_pmsr().
- **Symptom:** later hwsim_pmsr_report_nl() uses the freed request → use-after-free. Abort also leaves a non-NULL pointer so a new start can see -EBUSY forever.
- **Root cause:** abort notifies wmediumd/virtio but does not drop saved state; an early return when wmediumd/virtio is absent skips even the mutex.
- **Version:** not stated in the message. Introduction is v6.4-rc1 (verified in Phase 3).
**Step 1.4: Hidden bug fix?**
Record: **No.** This is an explicit UAF fix, not cleanup disguised as a fix.
---
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- File: drivers/net/wireless/virtual/mac80211_hwsim_main.c (+7 / −3)
- Function: mac80211_hwsim_abort_pmsr() only
- Scope: single-file surgical fix
**Step 2.2: Flow change**
Record:
- **Before:** read data->wmediumd; if no wmediumd and no virtio, **return unlocked** with saved pointers intact. If notification is sent, still never NULL the pointers.
- **After:** take the mutex, match data->pmsr_request == request, then set both pointers to NULL **before** the notification check. Missing wmediumd/virtio is goto out (unlock), not an early return.
**Step 2.3: Bug mechanism**
Record: **Use-after-free / dangling pointer** (also a lifetime/refcount- style leak of a cfg80211-owned object). cfg80211 frees the request; hwsim keeps the pointer; hwsim_pmsr_report_nl() later calls cfg80211_pmsr_report() / cfg80211_pmsr_complete() on it.
**Step 2.4: Fix quality**
Record: Obviously correct: abort that matches the in-flight request must drop the saved pointers because cfg80211 will free the object. Mutex already covers start/abort/report. Regression risk is low: a late report after abort now hits if (!data->pmsr_request) return -EINVAL, which is the intended post-abort behavior. No API/data-structure change.
---
## Phase 3: Git history
**Step 3.1: Blame**
Record: Pre-fix abort body is entirely from **8ba1da95053e0** (“mac80211_hwsim: add PMSR abort support via virtio”, Jaewan Kim, 2023-03-22). Pointers are stored in **5530c04c87c59** (start/request support, same day). First appears in **v6.4-rc1**. Present for a long time in this lineage.
**Step 3.2: Fixes: target**
Record: Original Fixes: 5530c04c87c5 is an ancestor of HEAD (git merge-base --is-ancestor exit 0). Closest actual miss is abort itself (8ba1da95053e0), also an ancestor. Related: 2bef4d1fb8b34 (NULL deref in hwsim_pmsr_report_nl, 2023) — different bug, already here.
**Step 3.3: File history**
Record: Neighbor aeea930c7a878 (“authenticate PMSR report senders”) is series patch 2/8, parent of this commit, **independent** (touches hwsim_pmsr_report_nl(), not abort). File split 340f2ab83a5c9 / move f79cbc77abde2 already in this tree. No extra prerequisite for the abort clear.
**Step 3.4: Author**
Record: Zhao Li is not the wireless maintainer. Same-day sibling is the report-sender auth patch. Maintainer **Johannes Berg** applied this commit.
**Step 3.5: Dependencies**
Record: Standalone. Uses existing data->pmsr_request, data->mutex, hwsim_virtio_enabled. Series 1/8; does not need 2/8–8/8. Can apply without aeea930c7a878.
---
## Phase 4: Mailing list
**Step 4.1: Original discussion**
Record:
- Lore URL: https://patch.msgid.link/20260708195911.84365-2-
[email protected]
- Cover: https://patch.msgid.link/20260708195911.84365-1-
[email protected]
- Series: **v1 only** as this patch (b4 dig -a “v2” is a different nl80211 color-change patch; false match)
- Johannes on the cover (2026-07-21): will take the two hwsim patches for **wireless-next**; **“I don’t think hwsim is all that relevant in deployed systems.”** Not a NAK of the UAF. He did apply this patch the same day.
- No reviewer asked for changes to this hunk. Other series patches (probe-resp, S1G TWT) were called out as LLM-pattern issues; **this patch was not**.
**Step 4.2: Recipients (b4 dig -w)**
Record: linux-wireless, Johannes Berg, Jaewan Kim (original PMSR author), Intel/Qualcomm/Marvell names, **[email protected]**. Right lists for a hwsim UAF.
**Step 4.3: Bug report**
Record: No syzbot/bugzilla. Found by review. Cover letter: KASAN hwsim boot; after the fix, a stale REPORT_PMSR got -EINVAL with no KASAN splat. Author-tested, not an external user report.
**Step 4.4: Series**
Record: 8 patches, mixed subsystems. This one is self-contained. 2/8 (sender auth) is a separate spoofing fix, not required to stop the abort UAF (it only narrows who can fire hwsim_pmsr_report_nl()).
**Step 4.5: Stable list**
Record: lore.kernel.org returned HTTP 403 via WebFetch. Original submission **did** Cc stable. Johannes’s “not relevant in deployed systems” is the only maintainer comment on hwsim priority. **No NAK and no “do not backport” found in the mbox.**
---
## Phase 5: Semantic / call chain
**Step 5.1: Functions**
Record: mac80211_hwsim_abort_pmsr() only. Consumers of the pointers:mac80211_hwsim_start_pmsr(), hwsim_pmsr_report_nl().
**Step 5.2: Callers**
Record:
- ieee80211_ops.abort_pmsr → drv_abort_pmsr() → ieee80211_abort_pmsr() → rdev_abort_pmsr() → cfg80211_pmsr_process_abort() which **then kfree(req)**.
- Abort work: cfg80211_pmsr_free_wk / cfg80211_pmsr_wdev_down.
- Socket teardown: nl80211 URELEASE → cfg80211_release_pmsr().
**Step 5.3: Callees**
Record: mutex, genlmsg_new, mac80211_hwsim_send_pmsr_request, virtio/wmediumd unicast. After the fix, notification is best-effort; **state drop is not**.
**Step 5.4: Reachability**
Record: Yes, from userspace on this tree:
1. NL80211_CMD_PEER_MEASUREMENT_START (GENL_UNS_ADMIN_PERM) with PMSR capa on an hwsim radio (wmediumd or virtio).
2. Close the nl80211 socket or take the wdev down → abort → cfg80211 frees req.
3. HWSIM_CMD_REPORT_PMSR has **no** GENL_UNS_ADMIN_PERM (verified at the genl op). Combined with a leftover pointer, that is the UAF.
4. Extra path: wmediumd URELEASE sets data->wmediumd = 0 (hwsim_register_wmediumd(net, 0)). Old abort **returned immediately** and never cleared.
**Step 5.5: Similar patterns**
Record: Same lifetime bug described for iwlwifi MLD in series 3/8 (mld->ftm_initiator.req left dangling). hwsim abort was the incomplete half of start-saves/complete-clears.
---
## Phase 6: This checkout
**Step 6.1: Local tree and buggy code**
Record:
- git describe HEAD: **v7.3-rc4-27-gf0100363d8c37**
- make kernelversion: **7.3.0-rc4**
- Buggy abort (save on start, clear only in hwsim_pmsr_report_nl()) exists here; pre-image at 37a77bd1395e8^ still has the early return and no NULL. Introduced v6.4-rc1; **not after this branch point**.
**Step 6.2: Backport difficulty**
Record: **Clean apply** on this tree’s mac80211_hwsim_main.c. Function and fields (pmsr_request, pmsr_request_wdev, mutex) are present.
**Step 6.3: Related fixes already here**
Record: No earlier abort-clear. 2bef4d1fb8b34 is a different NULL check. aeea930c7a878 is sender auth, not this UAF.
---
## Phase 7: Subsystem
**Step 7.1**
Record: **drivers/net/wireless/virtual** (mac80211_hwsim). Kconfig:
“Simulated radio testing tool… not needed for normal wireless LAN usage.” Criticality: **PERIPHERAL** as hardware, but **IMPORTANT** as a virtual/test driver shipped as a module and used by CI/syzkaller/wmediumd.
**Step 7.2**
Record: File is actively developed (NAN, virtio, many 2026 hwsim fixes). PMSR abort itself has been unchanged since 2023 — a long-standing hole, not churn from last month.
---
## Phase 8: Impact and risk
**Step 8.1: Who**
Record: Users with CONFIG_MAC80211_HWSIM who start PMSR (wmediumd/virtio) and abort. Not general Wi-Fi laptops. Distros often ship the module; Android Cuttlefish / mac80211 selftests use it.
**Step 8.2: Trigger**
Record: Start PMSR, then abort (socket close / iface down), then a report **or** wmediumd disconnect so abort’s old early-return fires. Needs CAP_NET_ADMIN to **start**; report genl op is unrestricted. Timing-dependent if wmediumd still reports after abort; **deterministic** dangling pointer after abort regardless.
**Step 8.3: Failure mode**
Record: **Use-after-free** in cfg80211_pmsr_report / cfg80211_pmsr_complete (req->cookie, req->nl_portid, …). Severity:
**HIGH** (oops/KASAN; possible memory corruption). Secondary: stuck -EBUSY on later PMSR.
**Step 8.4: Risk vs benefit**
Record: Benefit **high** for anyone hitting hwsim PMSR abort (crash). Risk **very low**: ~10-line pointer clear under an existing mutex. Ratio favors taking it on this tree.
---
## Phase 9: Synthesis
**Step 9.1: Evidence**
For:
- Real UAF with a traced cfg80211 kfree(req) after rdev_abort_pmsr()
- Small, obviously correct, mutex-protected
- Bug in this tree since v6.4-rc1
- Standalone; no new API
- Author tested abort-then-report under KASAN
- Wireless maintainer applied it
- Original submission had Fixes: + Cc: stable
Against:
- Test/simulator driver; Johannes said hwsim is not very relevant on deployed systems
- No syzbot/external user report
- Start path needs admin + wmediumd/virtio
- LLM-assisted series (maintainer criticized *other* patches, not this one)
Unresolved: stable@ lore search (HTTP 403). Does not change the local- tree technical picture.
**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** (clear-on-abort; KASAN boot described)
2. Real user-visible bug? **PASS** (UAF / oops; also stuck PMSR)
3. Important (crash/security/corruption/deadlock)? **PASS** (UAF → HIGH)
4. Small and contained? **PASS** (+7/−3, one function)
5. No new features/APIs? **PASS**
6. Applies to this tree? **PASS** (code present; clean)
**Step 9.3: Exceptions**
Record: None (not a device ID/quirk/DT/build/doc exception). Qualifies as a normal memory-safety fix.
**Step 9.4: Decision**
This checkout is **v7.3-rc4**. The buggy hwsim PMSR abort path is here. The patch is a small UAF fix with no prerequisites. Maintainer skepticism about hwsim on production APs does not make a use-after-free in this tree’s driver “not a bug.” It should be taken.
---
## What the commit solves for this tree
mac80211_hwsim stores cfg80211’s PMSR request in data->pmsr_request. cfg80211 frees that object when abort finishes. This tree’s abort callback never dropped the pointer (and skipped all cleanup if wmediumd had already exited). A later HWSIM_CMD_REPORT_PMSR dereferences freed memory. Clearing the two pointers under data->mutex when abort matches is the whole fix.
## Risk vs benefit
Benefit: prevent a KASAN/UAF oops on PMSR abort and allow a later start.
Risk: negligible; notification becomes best-effort after the pointer is already gone, which is what cfg80211 requires.
## Concerns
None that block this tree: no missing helpers, no series dependency, file is already mac80211_hwsim_main.c. Johannes’s “deployed systems” comment is priority, not a correctness NAK.
---
## Verification
- **[Phase 1]** Parsed committed tags: Link msgid 20260708195911.84365-2; SOBs Zhao Li + Johannes Berg; no Fixes in committed text
- **[Phase 1]** mbox of original mail: Fixes 5530c04c87c5, Cc: stable
- **[Phase 2]** git show 37a77bd1395e8: +7/−3 in mac80211_hwsim_abort_pmsr only
- **[Phase 2]** Read current abort (lines 3848–3911) and hwsim_pmsr_report_nl (4213–4277): report uses data->pmsr_request then NULLs it
- **[Phase 2]** Read cfg80211_pmsr_process_abort():
rdev_abort_pmsr() then kfree(req)
- **[Phase 3]** git blame on pre-image: abort from 8ba1da95053e0; git describe --contains → v6.4-rc1
- **[Phase 3]** git merge-base --is-ancestor 5530c04c87c59 HEAD → 0; same for 8ba1da95053e0
- **[Phase 3]** git log --oneline --grep=pmsr -- drivers/net/wireless/virtual/: series neighbor aeea930c7a878 independent
- **[Phase 3]** git log --oneline -S mac80211_hwsim_abort_pmsr -- drivers/net/wireless/virtual/: only intro + this fix
- **[Phase 4]** b4 dig -c 37a77bd1395e8: patch.msgid.link …84365-2
- **[Phase 4]** b4 dig -a: v1 of this patch; “v2” is unrelated nl80211 color-change
- **[Phase 4]** b4 dig -w: linux-wireless, Johannes, Jaewan Kim, stable@
- **[Phase 4]** mbox msg from Johannes: wireless-next; hwsim “not all that relevant in deployed systems”; no NAK of this diff
- **[Phase 4]** WebFetch lore/stable: HTTP 403 — UNVERIFIED whether it was discussed on stable@ beyond original Cc
- **[Phase 5]** Grep: abort wired in ieee80211_ops; nl80211 URELEASE calls cfg80211_release_pmsr
- **[Phase 5]** HWSIM_CMD_REPORT_PMSR op has no GENL_UNS_ADMIN_PERM; NL80211_CMD_PEER_MEASUREMENT_START has it
- **[Phase 5]** wmediumd URELEASE zeros portid via hwsim_register_wmediumd(net, 0)
- **[Phase 6]** git describe HEAD v7.3-rc4-27-gf0100363d8c37; Makefile 7.3.0-rc4
- **[Phase 6]** git merge-base --is-ancestor 37a77bd1395e8 HEAD → 0 (present; judged on merit, not as “already selected”)
- **[Phase 6]** Pre-fix abort still has early return without NULL (shown at 37a77bd1395e8^)
- **[Phase 7]** Kconfig: test tool, module mac80211_hwsim
- **[Phase 8]** cfg80211_pmsr_complete() derefs req->cookie / req->nl_portid — UAF if abort already freed req
- **UNVERIFIED:** How many distro .configs enable MAC80211_HWSIM — not used to drive the verdict; UAF is in-tree regardless
The fix is small, surgical, and matches stable rules for a real use- after-free in code this tree has had since v6.4.
**YES**
drivers/net/wireless/virtual/mac80211_hwsim.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/wireless/virtual/mac80211_hwsim.c +7 -3
@@ -3654,9 +3654,6 @@ static void mac80211_hwsim_abort_pmsr(struct ieee80211_hw *hw,int err =0 ; data = hw->priv; - _portid =READ_ONCE (data->wmediumd); -if (!_portid && !hwsim_virtio_enabled) -return ;mutex_lock (&data->mutex);
@@ -3665,6 +3662,13 @@ static void mac80211_hwsim_abort_pmsr(struct ieee80211_hw *hw, goto out; } + data->pmsr_request =NULL ; + data->pmsr_request_wdev =NULL ; + + _portid =READ_ONCE (data->wmediumd); +if (!_portid && !hwsim_virtio_enabled) + goto out; + skb =genlmsg_new (GENLMSG_DEFAULT_SIZE ,GFP_KERNEL );if (!skb) { err = -ENOMEM ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/realtek: Limit mic boost on Positivo N15RPE-S
In reply to Sasha LevinFrom: Edson Juliano Drosdeck <[email protected]>
[ Upstream commit 253010acfc8ad908446347b30a613032d1517bb5 ]
The internal mic boost on the Positivo N15RPE-S is too high.
Fix this by applying the ALC269_FIXUP_LIMIT_INT_MIC_BOOST fixup to the machine to limit the gain.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). This is a one-line Realtek HDA PCI quirk for a laptop whose driver and existing mic-boost fixup are already in this tree.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [ALSA hda/realtek] [Limit] [apply existing ALC269_FIXUP_LIMIT_INT_MIC_BOOST to Positivo N15RPE-S because internal mic boost is too high]
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Edson Juliano Drosdeck (author)
- Link: https://patch.msgid.link/20260805154518.19093-1-
[email protected]
- Signed-off-by: Takashi Iwai (ALSA maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Cc:
stable
- Ignore pipeline markers (none present on the upstream commit 253010acfc8ad)
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: internal microphone boost on Positivo N15RPE-S is too high
- Symptom: excessive gain / noisy internal mic (the fixup comment says levels 2 and 3 are too noisy)
- Failure mode: hardware-specific unusable/noisy capture, not a kernel crash
- Root cause: this PCI SSID is not in the quirk table, so the existing boost limiter is not applied
- Version info: none stated
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. It is an explicit hardware quirk: map SSID 0x2782:0xa128 to an existing fixup.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- Files: sound/hda/codecs/realtek/alc269.c (+1 / -0)
- Function/table: alc269_fixup_tbl[]
- Scope: single-file, one-line surgical quirk addition
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: PCI SSID 0x2782:0xa128 has no match; codec uses default auto-config with full internal-mic boost range
- After: that SSID matches ALC269_FIXUP_LIMIT_INT_MIC_BOOST, which at probe overrides amp caps so internal-mic boost is only steps 0–1
- Path: codec probe (patch_alc269() → snd_hda_pick_fixup(..., alc269_fixup_tbl, ...))
Step 2.3: IDENTIFY THE BUG MECHANISM
Record: [Hardware workaround] Existing alc269_fixup_limit_int_mic_boost() already limits noisy boost levels 2 and 3. This commit only adds the PCI ID so that function runs on this laptop.
Verified function in this tree (sound/pci/hda/patch_realtek.c:6661-6690):
- Runs only on HDA_FIXUP_ACT_PROBE
- Walks auto-config inputs, keeps only AUTO_PIN_MIC with INPUT_PIN_ATTR_INT
- Calls snd_hda_override_amp_caps() with NUM_STEPS=1
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Quality: obviously correct; identical pattern already used for Positivo ARN50, Positivo N14AP7, VAIO VJFE-CL, several ThinkPads
- Minimal: one SND_PCI_QUIRK line, no API/data-structure change
- Regression risk: very low; only SSID 0x2782:0xa128 is affected. The chosen fixup is chained to ALC269_FIXUP_THINKPAD_ACPI, but that is the same chain used by the other Positivo/VAIO limit-boost entries already in this tree.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Insertion point in this tree is after SND_PCI_QUIRK(0x2782, 0x4900, "MEDION E15443", ...) (98b5ade3a44d8f, 2024)
- The buggy “missing ID” is not old code; the laptop simply was never listed
- The fixup itself dates to 3e0d611b2045b (“ALSA: hda - Limit internal mic boost for a few Asus machines”, 2013-04-22, contained in v3.10-rc1) and **is an ancestor of HEAD**
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Expected for a new device quirk. Not a negative signal.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- Related commits already in this tree:
- d44418f5024f6 ALSA: hda/realtek: Limit mic boost on Positivo ARN50 (same author, same fixup; already backported here)
- 86a433862912f ALSA: hda/realtek: Limit mic boost on N14AP7 (same author, same fixup; had Cc: stable)
- Standalone: not patch X/Y. No prerequisite series.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Edson Juliano Drosdeck has 10 commits in sound/pci/hda/patch_realtek.c on this tree, almost all Positivo/VAIO HDA quirks. Regular hardware-quirk contributor, not a one-off.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS Record:
- Depends only on ALC269_FIXUP_LIMIT_INT_MIC_BOOST and alc269_fixup_tbl[], both present
- Can apply standalone as a one-line quirk in sound/pci/hda/patch_realtek.c
- Mainline file path sound/hda/codecs/realtek/alc269.c is the post-6.12 HDA codec split; that path does **not** exist here. Equivalent table is alc269_fixup_tbl in patch_realtek.c
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 253010acfc8ad → https://patch.msgid.link/20260805154518.19
[email protected]
- b4 dig -a: only v1; no later revision
- Thread is two messages: the patch and Takashi Iwai “Applied to for- next branch. Thanks.”
- No NAK, no requested changes, no reviewer-flagged risk
- No explicit Cc: stable in the thread (absence expected)
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To Takashi Iwai ([email protected]); Cc Jaroslav Kysela ([email protected]), Realtek ([email protected]), linux-sound, linux-kernel. Subsystem maintainer received and applied it.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla link. Description is a hardware report from the same author who previously submitted verified Positivo quirks. No independent public bug count found.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone one-patch series. Same author’s ARN50/N14AP7 limit- boost quirks are the precedent; those are already in this tree.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable search returned HTTP 403. No stable-list discussion verified. No evidence this was rejected for stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: Table alc269_fixup_tbl[] only. Runtime function used by the new ID: alc269_fixup_limit_int_mic_boost(). Probe picker:snd_hda_pick_fixup() from patch_alc269().
Step 5.2: TRACE CALLERS
Record:
- patch_alc269() at sound/pci/hda/patch_realtek.c:12416 calls snd_hda_pick_fixup(codec, alc269_fixup_models, alc269_fixup_tbl, alc269_fixups) (line 12583)
- That is the ALC269-family codec probe path (CONFIG_SND_HDA_CODEC_REALTEK)
- Not IRQ, not syscall hot path; once at device probe
Step 5.3: TRACE CALLEES
Record: alc269_fixup_limit_int_mic_boost() → snd_hda_codec_get_pincfg(), snd_hda_get_input_pin_attr(), snd_hda_override_amp_caps(). No allocation, no new locks.
Step 5.4: FOLLOW THE CALL CHAIN
Record: Userspace cannot trigger a crash path. The ID is matched when this laptop’s Realtek HDA codec is probed. Reachable for owners of Positivo N15RPE-S with SND_HDA_CODEC_REALTEK. Unprivileged users then get a usable (non-blown-out) internal mic.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same ALC269_FIXUP_LIMIT_INT_MIC_BOOST already used for many IDs in this tree, including:
- 0x1c6c:0x122a Positivo N14AP7
- 0x2014:0x800a Positivo ARN50
- 0x2782:0x0214 VAIO VJFE-CL
This is a systematic hardware pattern, not a one-off experiment.
===============================================================
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-2-gd38d58a4e0359; make kernelversion = 6.12.111
- git merge-base --is-ancestor 253010acfc8ad HEAD → **not in this tree**
- 0xa128 is absent from patch_realtek.c (grep: no matches)
- The missing-ID bug exists here: the laptop would probe without the limiter
- Fixup and table exist since well before 6.12 (fixup from v3.10)
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Needs a trivial backport, not a clean git-am of the mainline diff:
1. Path: sound/hda/codecs/realtek/alc269.c → sound/pci/hda/patch_realtek.c
2. Context: mainline next line is Lunnen Ground 14 (0x2782, 0xa212), which is **not** in 6.12; insert after 0x2782, 0x4900 and before 0x7017, 0x2014
That is the same class of adjustment used for d44418f5024f6 (ARN50) on this tree.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No N15RPE-S entry. Nearby same-class quirks (ARN50, N14AP7) are present. No alternate fix for 0x2782:0xa128.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [sound/pci/hda Realtek codec] [IMPORTANT for laptop audio; PERIPHERAL in that only this PCI ID is affected]
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Very active: last 20 commits on patch_realtek.c are mostly more SND_PCI_QUIRK entries (HP, Lenovo, Samsung, MECHREVO, ASUS). Mature driver; this is the normal way hardware enablement/workarounds land.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver-specific / PCI-SSID-specific: only Positivo N15RPE-S (0x2782:0xa128) with Realtek ALC269-family HDA.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record:
- Trigger: every boot/probe on that laptop when using the internal mic at high boost
- Common for owners of that model; zero impact elsewhere
- Not a security trigger; not unprivileged-crash
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: [Noisy / overly boosted internal mic, capture quality unusable at high gain] [MEDIUM for those users; LOW globally]. Not panic/UAF/corruption, but it is a real hardware defect the existing quirk is designed to fix.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: high for N15RPE-S users on 6.12 (mic works as on later kernels)
- Risk: very low (one ID, existing fixup, same pattern already backported here)
- Ratio: strongly favors backport
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Explicit audio-codec hardware quirk (SND_PCI_QUIRK + existing fixup)
- Real user-visible bug (internal mic boost too high)
- One line, obviously correct, maintainer-applied
- Same author’s identical Positivo ARN50 quirk already in this 6.12 tree
- Fixup and quirk table already present
- No new API, no new driver, no behavioral change except this SSID
AGAINST:
- Not a crash/security/data-corruption bug
- Mainline path differs; needs 1-line context/path adjustment
- No independent public bugzilla/syzbot report
- Affected population is one laptop model
UNRESOLVED:
- Could not query lore.kernel.org/stable (HTTP 403)
- Could not independently verify the author’s hardware test beyond the commit text and maintainer apply
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — one ID, existing fixup, applied by Takashi Iwai
2. Fixes a real bug that affects users? PASS — excessive internal mic boost on this machine
3. Important issue? PASS under the hardware-quirk exception (audio codec quirk); severity MEDIUM for that model
4. Small and contained? PASS — +1 line
5. No new features or APIs? PASS — ID mapped to existing fixup
6. Can apply to the local tree? PASS — equivalent table exists; needs trivial path/context backport, same as prior quirks on this tree
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: **Hardware quirk / audio codec quirk** (SND_PCI_QUIRK in Realtek HDA). This is an explicit stable exception.
Step 9.4: MAKE YOUR DECISION
This should be backported to this 6.12 tree. It is the standard Realtek laptop quirk: add a PCI subsystem ID so an existing limiter runs. The driver, table, and ALC269_FIXUP_LIMIT_INT_MIC_BOOST are all here; only the N15RPE-S ID is missing. Risk is confined to that SSID.
------------------------------------------------
What problem it solves and why it matters
The Positivo N15RPE-S ships with an internal mic whose boost steps 2–3 are too hot. Without this ID, 6.12 users of that laptop keep the default full boost range. The commit maps 0x2782:0xa128 onto the long-standing limiter already used for other Positivo machines in this tree.
Stable-rules fit
It is small, obviously correct, does not add APIs, and is the documented audio-quirk exception. It is not a crash fix, but stable routinely takes these ID-only Realtek quirks.
Risk vs benefit
Benefit is a working internal mic for that model. Risk is a single-ID table entry using a fixup that has been in the kernel since v3.10 and is already applied to sibling Positivo IDs here.
Concerns
The mainline hunk will not git am cleanly because of the later HDA file split and a neighboring Lunnen Ground 14 entry that 6.12 lacks. The backport is still a one-line insert into alc269_fixup_tbl in sound/pci/hda/patch_realtek.c.
Verification:
- [Phase 1] Parsed tags on 253010acfc8ad: author SOB, maintainer SOB, msgid Link; no Fixes/Reported-by/Cc: stable
- [Phase 2] Diff: +1 SND_PCI_QUIRK(0x2782, 0xa128, "Positivo N15RPE-S", ALC269_FIXUP_LIMIT_INT_MIC_BOOST)
- [Phase 2] Read alc269_fixup_limit_int_mic_boost() at patch_realtek.c:6661-6690; confirmed it clamps internal-mic amp steps to 0–1
- [Phase 2] Confirmed [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] exists at line 8711 and chains to ALC269_FIXUP_THINKPAD_ACPI (same as other Positivo limit-boost entries)
- [Phase 3] git merge-base --is-ancestor 3e0d611b2045b HEAD — fixup present (v3.10)
- [Phase 3] git merge-base --is-ancestor 253010acfc8ad HEAD — candidate **not** in this tree
- [Phase 3] git log --grep=N15RPE -- sound/pci/hda/ — empty
- [Phase 3] Grep 0xa128 in patch_realtek.c — no match
- [Phase 3] Same-class commits in tree: d44418f5024f6 (ARN50), 86a433862912f (N14AP7)
- [Phase 3] Author has 10 Realtek HDA quirk commits in this tree
- [Phase 4] b4 dig -c 253010acfc8ad → msgid [email protected]
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: To tiwai, Cc linux-sound / perex / Realtek
- [Phase 4] LKML/Patchew: Takashi “Applied to for-next”; no NAK
- [Phase 4] UNVERIFIED: lore.kernel.org/stable search HTTP 403
- [Phase 5] patch_alc269() line 12583 uses alc269_fixup_tbl
- [Phase 6] git describe HEAD = p-6.12-2-gd38d58a4e0359; kernelversion 6.12.111
- [Phase 6] Local file is sound/pci/hda/patch_realtek.c; alc269.c does not exist; insert after 0x2782/0x4900 before 0x7017/0x2014
- [Phase 8] Failure mode: noisy/excessive internal mic boost on one laptop; not a crash
**YES**
sound/hda/codecs/realtek/alc269.c | 1 + 1 file changed, 1 insertion(+)
sound/hda/codecs/realtek/alc269.c +1 -0
@@ -7646,6 +7646,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x2782 ,0x1705 ,"MEDION E15433" ,ALC269VC_FIXUP_INFINIX_Y4_MAX ),SND_PCI_QUIRK (0x2782 ,0x1707 ,"Vaio VJFE-ADL" ,ALC298_FIXUP_SPK_VOLUME ),SND_PCI_QUIRK (0x2782 ,0x4900 ,"MEDION E15443" ,ALC233_FIXUP_MEDION_MTL_SPK ), +SND_PCI_QUIRK (0x2782 ,0xa128 ,"Positivo N15RPE-S" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST ),SND_PCI_QUIRK (0x2782 ,0xa212 ,"Lunnen Ground 14" ,ALC269VC_FIXUP_LUNNEN_GROUND_14 ),SND_PCI_QUIRK (0x7017 ,0x2014 ,"Star Labs StarFighter" ,ALC233_FIXUP_STARLABS_STARFIGHTER ), SND_PCI_QUIRK(0x8086, 0x2074, "Intel NUC 8", ALC233_FIXUP_INTEL_NUC8_DMIC),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 thunderbolt: xdomain: Notify peers after enumeration
In reply to Sasha LevinFrom: Milo Chen <[email protected]>
[ Upstream commit e027dba038f0008df9bc9575f5c3e803e90636c6 ]
Service drivers may register local XDomain properties while discovery is still in progress. This can cause the properties changed notification to be sent before the peer is ready to act on it.
If the peer has already read the local property block before the service was registered, it may keep using the old property generation and miss the newly registered service. With ThunderboltIP this can leave the network service half-discovered after a warm reboot and the login request eventually times out.
Queue another properties changed notification after the XDomain reaches ENUMERATED so the peer can re-read the final local properties.
---
LLM Generated explanations, may be completely bogus:
The local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The candidate is a one-line Thunderbolt XDomain handshake fix: after discovery reaches ENUMERATED, send another properties-changed notification so a peer can pick up services registered during discovery. That matches a real ThunderboltIP failure after warm reboot, and the surrounding helpers already exist here.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
- Record: [thunderbolt: xdomain:] [Notify] [send properties-changed to peers once XDomain discovery reaches ENUMERATED]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Record:
- Signed-off-by: Milo Chen <[email protected]> (author)
- Signed-off-by: Mika Westerberg <[email protected]> (Thunderbolt maintainer; applied the patch)
- No Fixes:
- No Reported-by: / Tested-by: / Reviewed-by: / Acked-by: /
`Link:` / `Cc: stable`
- Absence of Fixes: / Cc: stable is expected for this review and is not a negative signal
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Record:
- **Bug:** Service drivers may register local XDomain properties while discovery is still running. The properties-changed notification can go out before the peer can act on it.
- **Symptom:** Peer keeps an old property generation and misses the new service. With ThunderboltIP, the network service stays half- discovered after a **warm reboot** and the **login request times out**.
- **Root cause:** Notification is sent too early (during discovery); nothing is sent once the local host is fully enumerated.
- **Fix:** Queue another properties-changed notification when the XDomain reaches ENUMERATED.
- **Version info:** none in the message.
**Step 1.4: DETECT HIDDEN BUG FIXES**
- Record: Not a disguised cleanup. The message describes a concrete functional failure (ThunderboltIP login timeout) and a protocol-timing fix.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
- Record:
- File: drivers/thunderbolt/xdomain.c (+1 / -0)
- Function: tb_xdomain_state_work()
- Scope: single-file, one-line surgical change
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
- Record:
- **Before:** XDOMAIN_STATE_PROPERTIES success only sets xd->state = XDOMAIN_STATE_ENUMERATED.
- **After:** same, then tb_xdomain_queue_properties_changed(xd).
- Path: successful remote property fetch at the end of XDomain discovery (normal path, not an error path).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
- Record:
- **Category:** logic / protocol handshake correctness (missed peer notification).
- **Mechanism:** tb_xdomain_queue_properties_changed() already runs in XDOMAIN_STATE_INIT and after UUID. tb_register_property_dir() (used by thunderbolt-net) also notifies via update_all_xdomains(). If that happens while the peer is not ready, or after the peer already read the old block, the peer can stick on the old generation. There was no notify after local discovery finished. The new call reuses the existing notify helper at ENUMERATED so the peer re-reads the final block.
**Step 2.4: ASSESS THE FIX QUALITY**
- Record:
- **Quality:** Obviously correct relative to the described race. It reuses tb_xdomain_queue_properties_changed(), which already sends PROPERTIES_CHANGED_REQUEST with retries.
- **Minimal:** one call, no API/data-structure change.
- **Regression risk:** Low for the intended case. Extra notifies are already part of the protocol; the receiver path in tb_xdp_handle_request() treats PROPERTIES_CHANGED_REQUEST as “re-run state work / re-read properties.”
- **Noted risk (code-derived, not field-confirmed):** because XDOMAIN_STATE_ENUMERATED already re-enters PROPERTIES when a peer notify arrives, a successful re-read will now send another notify. Two Linux hosts both running this change could keep exchanging property updates. No follow-up revert/fix appears in this tree after the commit. Treat as theoretical unless proven in use.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
- Record:
- Surrounding state machine: 8e1de7042596ab (“thunderbolt: Add support for XDomain lane bonding”, 2022-05-05), first in **v5.19-rc1**.
- Notify helper and INIT/UUID notify sites: same commit.
- The added line is this candidate (e027dba038f000, Milo Chen,
2026-06-24).
- XDomain discovery protocol itself: `d1ff70241a275` (2017),
**v4.15-rc1**.**Step 3.2: FOLLOW THE FIXES: TAG**
- Record: No Fixes: tag. Not applicable. The missing notify at ENUMERATED dates to the 5.19 state machine.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
- Record:
- Related: abc27e5bfed2f (“Allow service drivers to specify their own properties”) — extra per-service properties, not required for this one-line call.
- 308092d080852 (“Restart XDomain discovery handshake after failure”) — nearby error-path change; not a prerequisite.
- Standalone. Not patch X/Y.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
- Record: Milo Chen has only this thunderbolt commit here. Applied by **Mika Westerberg**, Thunderbolt maintainer.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
- Record: Depends only on tb_xdomain_queue_properties_changed() and XDOMAIN_STATE_ENUMERATED, both present since 5.19. Applies standalone.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
- Record:
- b4 dig -c e027dba038f000… →
https://patch.msgid.link/[email protected] - **v1:** `[PATCH] thunderbolt: xdomain: notify peers after enumeration` (From: Rqirus) — https://patch.msgid.link/[email protected] - **v2:** same diff; changelog: “Use full name in From and Signed-off- by.” - Mika Westerberg on v2: **“Applied to thunderbolt.git/next, thanks!”** - No NAK. No request for `Cc: stable` in the saved thread. - lore.kernel.org HTTP fetch returned 403; discussion was recovered via `b4 dig -m`.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
- Record (b4 dig -w): To/Cc Mika Westerberg, Andreas Noever, Michael Jamet, Yehezkel Bernat, linux-usb, linux-kernel. Subsystem maintainers were on the original mail. Mika applied it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
- Record: No bugzilla/syzbot/Link. The commit text is the bug report:
ThunderboltIP half-discovered after warm reboot, login timeout. Severity from the author: networking service fails to complete discovery.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
- Record: Single-patch series (v1→v2, identical diff). Not part of a multi-patch set.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
- Record: Web search of lore.kernel.org/stable for this subject returned no relevant hits. **UNVERIFIED** that nobody asked for it on stable@; no evidence it was rejected either.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
- Record: tb_xdomain_state_work() modified; calls tb_xdomain_queue_properties_changed(); that queues tb_xdomain_properties_changed() → tb_xdp_properties_changed_request().
**Step 5.2: TRACE CALLERS**
- Record:
- tb_xdomain_state_work is delayed work started from start_handshake() / queue helpers; not a syscall.
- tb_xdomain_queue_properties_changed call sites: INIT (no UUID needed), UUID success, and (after this patch) PROPERTIES success.
- tb_register_property_dir() is called from drivers/net/thunderbolt/main.c (tbnet_init), drivers/thunderbolt/stream.c, drivers/thunderbolt/dma_test.c.
**Step 5.3: TRACE CALLEES**
- Record: Notify path allocates/sends an XDomain control packet with retries (XDOMAIN_RETRIES). Failure is logged; it does not unwind enumeration.
**Step 5.4: FOLLOW THE CALL CHAIN**
- Record: Reachable when two hosts do XDomain discovery over Thunderbolt/USB4 (cable/peer already present, including after warm reboot). Userspace does not need a special syscall; loading thunderbolt-net during boot vs in-progress discovery is the trigger.
Config: CONFIG_USB4 plus Thunderbolt networking.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
- Record: Same notify is already used at INIT/UUID and when property dirs are registered. This fills the gap at end-of-discovery. No sibling drivers needed the same hunk.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
- Record: Yes. drivers/thunderbolt/xdomain.c has the PROPERTIES → ENUMERATED transition. Parent of the candidate only sets xd->state = XDOMAIN_STATE_ENUMERATED with no notify. ThunderboltIP registers "network" via tb_register_property_dir() in this tree. Bug class has been present since the 5.19 state machine; this tree is 7.3-rc4, so the code is in-scope.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
- Record: Expected **clean apply**. Parent context around the hunk matches this tree’s pre-patch source. One added line, no helpers missing.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
- Record: No other commit on this file addresses “notify after enumeration” or the ThunderboltIP warm-reboot miss. abc27e5bfed2f is a separate feature (per-service properties), not a substitute.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
- Record: drivers/thunderbolt/ (USB4/Thunderbolt). **IMPORTANT** for USB4/TBT hosts, **PERIPHERAL** relative to mm/VFS. Affects Thunderbolt XDomain and ThunderboltIP (drivers/net/thunderbolt/), not all machines.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
- Record: Actively maintained (Mika Westerberg). Recent xdomain work includes UAF and bounds fixes. Mature protocol with ongoing fixes; this is not staging.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
- Record: Thunderbolt/USB4 hosts using XDomain, especially ThunderboltIP between two machines after warm reboot. Driver-specific / config- specific (CONFIG_USB4, thunderbolt-net).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
- Record: Warm reboot (or service driver registering properties during discovery). Timing-dependent. Unprivileged users do not trigger it via a random syscall; they hit it by using Thunderbolt networking. Common for that hardware/use case, rare globally.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
- Record: ThunderboltIP discovery incomplete; login times out; network over Thunderbolt does not come up. Not a panic, UAF, or corruption. **Severity: HIGH for ThunderboltIP users, MEDIUM overall** (feature broken, host stays up).
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
- Record:
- **Benefit:** Restores Thunderbolt networking after a realistic warm- reboot race. High for those users.
- **Risk:** Very low line count; extra notify is an existing protocol message. Theoretical Linux↔Linux notify loop is unverified in the field; no revert in this tree.
- **Ratio:** Benefit outweighs risk.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR backporting:**
- Real user-visible bug: ThunderboltIP half-discovered, login timeout after warm reboot.
- One-line, reuses an existing helper.
- Maintainer (Mika Westerberg) applied it with no technical objections.
- All needed symbols/state exist in this 7.3-rc4 tree (state machine since 5.19).
- Applies cleanly; not a new API/feature.
- Standalone; v2 only fixed the author’s From name.
**AGAINST backporting:**
- Not a crash, UAF, or security bug.
- Affects a subset (USB4/TBT XDomain / ThunderboltIP).
- No Reported-by besides the author’s scenario.
- Theoretical extra notify traffic between two patched Linux peers (unverified in production).
**UNRESOLVED:**
- Could not fetch lore over HTTP (403); used b4 mbox instead.
- Mika’s v1 mail body was not in the saved v2 mbox; v2 changelog says the only change was the From/SOB name.
- No stable@ thread found.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — one existing helper call; maintainer applied to thunderbolt.git/next.
2. Fixes a real bug that affects users? **PASS** — ThunderboltIP login timeout after warm reboot.
3. Important issue? **PASS** — service remains unusable (connectivity failure), not a panic; still a serious functional break for that hardware.
4. Small and contained? **PASS** — +1 line, one file.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — helpers and state machine are present; hunk context matches.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
- Record: None (not a device ID, quirk table, DT, build, or docs-only change). Qualifies as a normal small bugfix.
**Step 9.4: DECISION**
This tree has the buggy handshake. The patch is a minimal, maintainer- acked fix for a real ThunderboltIP discovery failure. That is appropriate to backport here.
---
### What the commit solves for this tree
On 7.3-rc4, XDomain discovery still notifies peers early and service drivers (notably thunderbolt-net) can still register the "network" property directory while handshake is in progress. Without a notify at ENUMERATED, a peer that already read the old block can miss the service; ThunderboltIP then sits half-discovered and login times out after warm reboot. One extra tb_xdomain_queue_properties_changed() at the end of discovery closes that window.
### Stable rules
The change is obviously correct, tiny, and does not add APIs. It fixes a real connectivity bug, not a refactor.
### Risk vs benefit
Benefit is restoring Thunderbolt networking after reboot. Risk is one extra protocol notify on a path that already sends that message. Residual ping-pong risk between two Linux peers is unverified and did not produce a follow-up fix in this tree.
### Concerns
No Fixes: tag (expected). Not a crash-class bug. Depends on Thunderbolt XDomain, which this tree has. No missing prerequisites.
---
Verification:
- [Phase 1] Parsed commit e027dba038f0008df9bc9575f5c3e803e90636c6:
subject/body/SOBs only; no Fixes/Reported-by/Cc stable
- [Phase 2] Diff: +1 line in tb_xdomain_state_work() after xd->state = XDOMAIN_STATE_ENUMERATED
- [Phase 2] Confirmed existing notifies at INIT (line 1739) and UUID success (line 1751); tb_register_property_dir() calls update_all_xdomains()
- [Phase 2] Confirmed thunderbolt-net tbnet_init() calls tb_register_property_dir("network", tbnet_dir)
- [Phase 2] Receiver of PROPERTIES_CHANGED_REQUEST queues state_work; ENUMERATED re-enters PROPERTIES (verified in xdomain.c)
- [Phase 3] git blame: state machine from 8e1de7042596ab (v5.19-rc1); XDomain protocol from d1ff70241a275 (v4.15-rc1)
- [Phase 3] git log --author="Milo Chen" -- drivers/thunderbolt/: only this commit
- [Phase 3] No later xdomain.c commit addresses this notify
- [Phase 4] b4 dig -c e027dba038f000…: lore match
https://patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1 and v2; v2 identical diff, From-name fix only
- [Phase 4] b4 dig -w: thunderbolt maintainers + linux-usb
- [Phase 4] mbox: Mika Westerberg “Applied to thunderbolt.git/next, thanks!”
- [Phase 4] WebFetch lore: 403; used b4 instead
- [Phase 4] Stable-list search: no relevant hits
- [Phase 5] Callers of tb_register_property_dir: thunderbolt-net, stream, dma_test (grep)
- [Phase 5] semcode MCP: not available; used git grep/read
- [Phase 6] make kernelversion / Makefile: 7.3.0-rc4; git describe HEAD: v7.3-rc4-27-gf0100363d8c37
- [Phase 6] Parent hunk lacks the notify; this tree has the helpers
- [Phase 6] git merge-base --is-ancestor e027dba038f000 HEAD: ancestor (original commit in this development tree; not used as “already selected for stable”)
- [Phase 7] MAINTAINERS: THUNDERBOLT DRIVER, Mika Westerberg
- [Phase 8] Failure mode: ThunderboltIP login timeout / half-discovered service, not oops
- UNVERIFIED: Mika v1 review body (not in v2 mbox); whether Linux↔Linux notify looping occurs in the field; whether stable@ ever discussed this patch
**YES**
drivers/thunderbolt/xdomain.c | 1 + 1 file changed, 1 insertion(+)
drivers/thunderbolt/xdomain.c +1 -0
@@ -1692,6 +1692,7 @@ static void tb_xdomain_state_work(struct work_struct *work)tb_xdomain_failed (xd); }else { xd->state =XDOMAIN_STATE_ENUMERATED ; +tb_xdomain_queue_properties_changed (xd); }break ;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-6.1] thunderbolt: xdomain: Notify peers after enumeration
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] thunderbolt: xdomain: infinite ping-pong loop in tb_xdomain_state_work() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] thunderbolt: xdomain: infinite ping-pong loop in tb_xdomain_state_work() --
commit e5f041d5682183591ea61bde27f0a9936f3beac3
Author: Milo Chen <[email protected]>
thunderbolt: xdomain: Notify peers after enumeration
This commit queues a properties-changed notification when the XDomain state machine reaches XDOMAIN_STATE_ENUMERATED so that the peer re-reads any local properties registered while discovery was in progress.
drivers/thunderbolt/xdomain.c static void tb_xdomain_state_work(struct work_struct *work) · line 1667
Quoted 12 lines
drivers/thunderbolt/xdomain.c +1
-0@@ -1661,6 +1661,7 @@ static void tb_xdomain_state_work(struct work_struct *work)tb_xdomain_failed (xd); }else { xd->state =XDOMAIN_STATE_ENUMERATED ; +tb_xdomain_queue_properties_changed (xd); }break ;
[Severity: Medium]
Won't unconditionally queuing a properties-changed notification on every transition from XDOMAIN_STATE_PROPERTIES to XDOMAIN_STATE_ENUMERATED cause an infinite protocol ping-pong loop between two connected peers running this code?
When the peer is already enumerated (so device_is_registered(&xd->dev) is true) and receives PROPERTIES_CHANGED_REQUEST, tb_xdp_handle_request() schedules xd->state_work:
drivers/thunderbolt/xdomain.c:tb_xdp_handle_request() {
...
case PROPERTIES_CHANGED_REQUEST:
tb_dbg(tb, "%llx: received XDomain properties changed request\n",
route);
ret = tb_xdp_properties_changed_response(ctl, route, sequence);
/*
* Since the properties have been changed, let's update
* the xdomain related to this connection as well in
* case there is a change in services it offers.
*/
if (xd && device_is_registered(&xd->dev))
queue_delayed_work(tb->wq, &xd->state_work,
msecs_to_jiffies(XDOMAIN_SHORT_TIMEOUT));
break;
...
}When tb_xdomain_state_work() runs in XDOMAIN_STATE_ENUMERATED, it calls tb_xdomain_queue_properties(xd), transitioning xd->state back to XDOMAIN_STATE_PROPERTIES and re-queuing xd->state_work:
drivers/thunderbolt/xdomain.c:tb_xdomain_state_work() {
...
case XDOMAIN_STATE_PROPERTIES:
ret = tb_xdomain_get_properties(xd);
if (ret) {
if (ret == -EAGAIN)
goto retry_state;
tb_xdomain_failed(xd);
} else {
xd->state = XDOMAIN_STATE_ENUMERATED;
tb_xdomain_queue_properties_changed(xd);
}
break;
case XDOMAIN_STATE_ENUMERATED:
tb_xdomain_queue_properties(xd);
break;
...
}Then in XDOMAIN_STATE_PROPERTIES, tb_xdomain_get_properties() returns 0 even when the remote property block generation has not changed:
drivers/thunderbolt/xdomain.c:tb_xdomain_get_properties() {
...
/* Only accept newer generation properties */
if (xd->remote_properties && gen <= xd->remote_property_block_gen) {
ret = 0;
goto err_free_block;
}
...
}Because ret is 0, XDOMAIN_STATE_PROPERTIES transitions back to XDOMAIN_STATE_ENUMERATED and calls tb_xdomain_queue_properties_changed(xd) again, sending a new PROPERTIES_CHANGED_REQUEST back to the first peer and repeating the cycle indefinitely.
Could this notification be sent only on the initial enumeration (or when local properties actually changed during discovery), rather than on every re-enumeration pass triggered by PROPERTIES_CHANGED_REQUEST?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 drm/amd/pm: derive stable PPT limits from PPTable
In reply to Sasha LevinFrom: Yang Wang <[email protected]>
[ Upstream commit 25f4a46b0c8acd77c9065b50a1fe48af27d91fdf ]
GetPptLimit reports mutable PMFW runtime state. Using that value for static capabilities causes two externally visible problems:
- A userspace override changes the default reported through hwmon.
- A firmware reset changes the advertised minimum or maximum range.
Derive platform defaults and supported ranges from the driver PPTable for Sienna Cichlid, Navi10, Arcturus, and Aldebaran. Reserve PMFW queries for the effective current limit.
Runtime policy can no longer redefine immutable platform capabilities.
---
LLM Generated explanations, may be completely bogus:
I have enough from the local 6.12 tree, the sibling SMU13/SMU14 backports, and the series context to decide. The remaining lore lookups failed with 403, so those are marked unverified.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [drm/amd/pm] [derive] [source immutable PPT default/min/max from the driver PPTable instead of PMFW GetPptLimit]
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Yang Wang <[email protected]> (author)
- Reviewed-by: Kenneth Feng <[email protected]> (AMD PM reviewer)
- Signed-off-by: Alex Deucher <[email protected]> (amdgpu maintainer)
- No Fixes:, Reported-by, Tested-by, Link:, or Cc: stable (absence expected)
- Ignore Sasha Levin SOB if present (pipeline)
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: GetPptLimit returns mutable PMFW runtime state, but the driver used that one value for current, default, min, and max.
- Symptoms: (1) a userspace power-cap override changes the default shown in hwmon; (2) a firmware/GPU reset changes the advertised min/max range.
- Failure mode: hwmon power1_cap_default / power1_cap_max / power1_cap_min stop being immutable platform capabilities. After reset, smu_set_power_limit() can reject a previously valid TDP because max was recomputed from the runtime value.
- Root cause: static capabilities were taken from PMFW instead of PPTable.
- Version info: none in the message. Upstream SHA from drm.git is 25f4a46b0c8acd77c9065b50a1fe48af27d91fdf (author 2026-07-30, committed 2026-08-06).
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. It is an explicit correctness fix. Navi10/Sienna also start using AC vs DC PPTable entries, matching the SMU13 pattern already in this tree.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- arcturus_ppt.c arcturus_get_power_limit: ~+12/-11
- navi10_ppt.c navi10_get_power_limit: ~+16/-12
- sienna_cichlid_ppt.c sienna_cichlid_get_power_limit: ~+16/-12
- aldebaran_ppt.c aldebaran_get_power_limit: ~+6/-2
- Scope: four ASIC PPT backends, one function each. Surgical, not a cross-subsystem refactor.
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: query GetPptLimit into power_limit; on failure fall back to PPTable; assign that same value to current, default, and (for Navi/Sienna) the OD min/max base.
- After: default/min/max come from PPTable (Navi/Sienna: AC or DC by adev->pm.ac_power). GetPptLimit is used only for current; on query failure current falls back to default.
- Arcturus: max becomes the PPTable default; min stays 0 (already true in this tree from 08e5f8e1a24fb).
- Aldebaran: max already came from pptable->PptLimit; default now does too, instead of the GetPptLimit result.
- Path: init via smu_late_init() → smu_get_asic_power_limits(), and GPU reset via smu_reset() which re-runs late_init. Also used when Sienna/Aldebaran re-query current.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record: [Logic / correctness] Using a mutable firmware PPT as the immutable hwmon default/range. Fix: PPTable owns capabilities; PMFW owns current.
Step 2.4: ASSESS THE FIX QUALITY
Record: Obviously correct and matches smu_v13_0_0_get_power_limit() / smu_v14_0_2_get_power_limit() already in this tree. Minimal. Regression risk is low: Navi/Sienna now pick DC limits on battery, which is the same rule SMU13 already uses here. Desktop ac_power is normally true, so those cards keep AC limits. No API or locking changes.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record: The GetPptLimit-as-everything pattern dates to 1e239fdd31cdf1 (Evan Quan, 2020-06-08, “maximize code sharing around power limit”). Min/max pointer args came from 1958946858a62b (Ma Jun, 2023-10-12). Present since well before 6.12.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. The real ancestor is the 2020 GetPptLimit sharing, which is in this tree.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- 08e5f8e1a24fb already in this tree: Arcturus min=0 (Cc: stable). This patch keeps that.
- b3498e00aff57 “fix smu13 power limit default/cap calculation” (Yang Wang, Cc: stable, in v6.12.94): same bug on SMU13.
- b3adc697752b9 follow-up SMU13 range fix (Cc: stable, Closes gitlab 5419).
- a322d276f3d10 SMU14 range fix (Cc: stable).
- This candidate is the remaining SMU11/Aldebaran analog; not already applied (git merge-base --is-ancestor 25f4a46b0c8acd HEAD failed).
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Yang Wang is a regular amd/pm contributor in this tree (SMU13/SMU14 power-limit fixes, pptable UAF, metrics). Kenneth Feng reviewed those as well.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: Standalone. No new helpers. SocketPowerLimitDc, GET_PPTABLE_MEMBER, and adev->pm.ac_power already exist here. Later drm-next-7.3 series (refactor by controller, OD percentage, save/restore, restore after reset) is a large follow-on and is not required for this hunk.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 25f4a46b0c8acd77c9065b50a1fe48af27d91fdf: lore.kernel.org returned server error; no match.
- lore.kernel.org WebFetch: 403.
- drm.git commit page confirms SHA, author, reviewer, committer.
- amd-gfx July 2026: related 4-patch “refactor PPT limit runtime policy” (Kenneth Feng reviewed). “derive stable PPT limits from PPTable” is listed first among Yang Wang’s five commits in the amd-drm-next-7.3 pull (mail-archive).
- UNVERIFIED: full review thread / NAKs / explicit Cc: stable for this exact patch (lore 403).
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: Kenneth Feng Reviewed-by; Alex Deucher signed off. Recipients from b4 dig -w unverified.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No Reported-by on this commit. Sibling SMU13 fix closed
https://gitlab.freedesktop.org/drm/amd/-/work_items/5227 (WebFetch 403; title/body unverified). Follow-up closed work item 5419.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: First of five PPT commits in amd-drm-next-7.3. Later four are a large policy refactor. This patch is self-contained.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: UNVERIFIED for this SHA (lore 403). The same class of fix for SMU13/SMU14 already landed in this 6.12 tree with Cc: stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: arcturus_get_power_limit, navi10_get_power_limit, sienna_cichlid_get_power_limit, aldebaran_get_power_limit.
Step 5.2: TRACE CALLERS
Record: Registered as .get_power_limit in each ppt_funcs table. Invoked via smu_get_asic_power_limits() from:
- smu_late_init() (boot and smu_reset()), filling smu->{current,default,max,min}_power_limit
- smu_get_power_limit() for CURRENT on Sienna-family (11.0.7/11/12/13) and Aldebaran (13.0.2)
Hwmon power1_cap{,_default,_max,_min} goes amdgpu_hwmon_show_power_cap_* → amdgpu_dpm_get_power_limit → smu_get_power_limit. Sets are range-checked against cached max_power_limit/min_power_limit in smu_set_power_limit().
Step 5.3: TRACE CALLEES
Record: smu_v11_0_get_current_power_limit() / smu_cmn_send_smc_msg(SMU_MSG_GetPptLimit) for current only; PPTable fields for defaults.
Step 5.4: FOLLOW THE CALL CHAIN
Record: Userspace-reachable via hwmon sysfs (typically root). GPU reset / late_init also refresh the caches. Reachable on Navi10 (RX 5700), Sienna (RX 6800/6900, 6000M), Arcturus (MI100), Aldebaran (MI200).
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: SMU13 (smu_v13_0_0, smu_v13_0_7) and SMU14 (smu_v14_0_2) already use PPTable + AC/DC for default/min/max in this tree. These four backends were the leftover GetPptLimit-for-everything copies.
===============================================================
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 / 6.12.111** (p-6.12-3-g88406e77611c6). The four *_get_power_limit functions match the patch “before” side. Bug introduced ~2020 (1e239fdd31cdf1), long before 6.12.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Clean apply expected. Navi10 context below the hunk differs (MAX_PCIE_CONF vs NUM_LINK_LEVELS) but that is outside this function. Arcturus min=0 already present.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: SMU13/SMU14 analogs are here; these four ASICs are not. No earlier version of this exact change.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [drm/amd/pm SWSMU] [IMPORTANT] — common AMD dGPU/instinct power management, not core mm/net, but widely used hardware.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Actively maintained; recent 6.12.y already took SMU13/SMU14 power-limit correctness fixes from the same author.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver-specific: Navi10/Navi14, Sienna Cichlid family, Arcturus, Aldebaran. Anyone using hwmon power cap (LACT, CoreCtrl, scripts) or hitting GPU reset.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record:
- Always at smu_late_init if PMFW current ≠ PPTable default (boot power source / firmware policy).
- GPU reset (smu_reset → late_init) refreshes default/max/min from GetPptLimit, so a runtime policy or leftover firmware value rewrites advertised range.
- In this 6.12 tree, DEFAULT/MAX/MIN hwmon reads use the cache, so a live userspace write to power1_cap does not immediately rewrite power1_cap_default unless late_init/reset re-runs. The commit’s first symptom is therefore mainly boot/reset, not every write. Still a real bug.
- Trigger is privileged sysfs or reset, not an unprivileged crash primitive.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: Incorrect hwmon capabilities; after reset, smu_set_power_limit() can reject a previously legal TDP because max was derived from the runtime PPT. No oops/UAF/corruption. Severity:
MEDIUM (functional / ABI), same class already accepted for this tree on SMU13.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record: Benefit medium-high for affected GPUs (correct caps, no trapped range after reset). Risk low (~40 net lines, four isolated functions, established pattern). Ratio favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real bug: mutable PMFW state used as immutable hwmon default/min/max.
- After GPU reset, cached max/min can shrink and block restoring the platform TDP.
- Same class already backported to this 6.12 tree for SMU13/SMU14 (b3498e00aff57, b3adc697752b9, a322d276f3d10), all Cc: stable.
- Small, obviously correct, no new APIs.
- Buggy code is in this tree; patch applies cleanly.
- Reviewed by Kenneth Feng, signed off by Alex Deucher.
AGAINST:
- Not a crash, security hole, or data corruption.
- First of a later 5-commit PPT series; later patches are large refactors (do not take those).
- Navi/Sienna AC/DC selection is extra vs the old always-AC fallback (same as already-stable SMU13).
- No Fixes:/Reported-by on this commit; lore thread unverified.
UNRESOLVED:
- Full amd-gfx review text / NAKs (lore 403, b4 failed).
- GitLab 5227 details (403).
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — matches SMU13/14 in this tree; AMD reviewer + maintainer.
2. Fixes a real bug that affects users? PASS — wrong hwmon caps; reset can trap the power range.
3. Important issue? PASS — not a panic, but the same issue was already treated as stable-worthy here for newer ASICs; user-visible PM/sysfs breakage on common GPUs.
4. Small and contained? PASS — four functions, ~70 lines.
5. No new features or APIs? PASS — corrects existing hwmon values; AC/DC uses existing PPTable fields.
6. Can apply to the local tree? PASS — buggy code present; clean apply expected.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: None of the automatic exceptions (device ID / quirk / DT / build / docs). Qualifies as a normal small correctness fix.
Step 9.4: MAKE YOUR DECISION
This should be backported to this 6.12 tree. It is the leftover SMU11/Aldebaran half of a power-cap reporting bug whose SMU13/SMU14 half is already in 6.12.y. Do not pull the later PPT refactor series with it.
Verification:
- [Phase 1] Parsed tags: author Yang Wang, Reviewed-by Kenneth Feng, SOB Alex Deucher; no Fixes/Reported-by/Cc stable
- [Phase 1] drm.git SHA 25f4a46b0c8acd77c9065b50a1fe48af27d91fdf confirmed via search snippet
- [Phase 2] Diff: four *_get_power_limit functions; PPTable for default/min/max, GetPptLimit only for current
- [Phase 3] git describe HEAD: p-6.12-3-g88406e77611c6; make kernelversion 6.12.111
- [Phase 3] git merge-base --is-ancestor 25f4a46b0c8acd HEAD: not an ancestor (not in this tree)
- [Phase 3] git blame: GetPptLimit pattern from 1e239fdd31cdf1 (2020); still present in all four files
- [Phase 3] Related stable commits in this tree: b3498e00aff57 (v6.12.94), b3adc697752b9, a322d276f3d10, 08e5f8e1a24fb
- [Phase 4] b4 dig -c 25f4a46b0c8acd: lore server error, no match
- [Phase 4] lore WebFetch 403; gitlab 5227 403
- [Phase 4] amd-gfx July 2026: 4-patch PPT refactor series by same author; drm-next-7.3 pull lists this commit first of five
- [Phase 5] Callers: smu_late_init, smu_reset, smu_get_power_limit, hwmon power1_cap*; range check in smu_set_power_limit
- [Phase 5] SMU13/SMU14 in this tree already implement the post-fix pattern
- [Phase 6] Read all four local functions: match the patch “before” side
- [Phase 6] GET_PPTABLE_MEMBER and SocketPowerLimitDc exist for Sienna and Beige Goby
- [Phase 8] Failure mode: wrong hwmon caps / possible -EINVAL on set after reset; not oops
- UNVERIFIED: original lore discussion, NAKs, gitlab 5227 body, whether SocketPowerLimitDc is zero on any Navi10 mobile SKU
This is a small, already-reviewed correction of hwmon PPT default/min/max on GPUs that still use GetPptLimit for those values. The same bug was already backported on SMU13/SMU14 in this 6.12 tree, the code is present, and the follow-on refactor series is not required.
**YES**
.../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 25 ++++++++------- .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 32 +++++++++++-------- .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 28 +++++++++------- .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 8 +++-- 4 files changed, 53 insertions(+), 40 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +13 -12
@@ -1329,24 +1329,25 @@ static int arcturus_get_power_limit(struct smu_context *smu, uint32_t *min_power_limit) {PPTable_t *pptable = smu->smu_table.driver_pptable; -uint32_t power_limit; +uint32_t current_limit, default_limit; -if (smu_v11_0_get_current_power_limit (smu, &power_limit)) { -/* the last hope to figure out the ppt limit */ -if (!pptable) { -dev_err (smu->adev->dev,"Cannot get PPT limit due to pptable missing!" ); -return -EINVAL ; - } - power_limit = - pptable->SocketPowerLimitAc[PPT_THROTTLER_PPT0 ]; +if (!pptable) { +dev_err (smu->adev->dev, +"Cannot get PPT limit due to pptable missing!" ); +return -EINVAL ; } + default_limit = pptable->SocketPowerLimitAc[PPT_THROTTLER_PPT0 ]; + +if (smu_v11_0_get_current_power_limit (smu, ¤t_limit)) + current_limit = default_limit; +if (current_power_limit) - *current_power_limit = power_limit; + *current_power_limit = current_limit;if (default_power_limit) - *default_power_limit = power_limit; + *default_power_limit = default_limit;if (max_power_limit) - *max_power_limit = power_limit; + *max_power_limit = default_limit;/* * No lower bound is imposed on the limit. Any unreasonable limit set * will result in frequent throttling.
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +18 -14
@@ -2393,22 +2393,26 @@ static int navi10_get_power_limit(struct smu_context *smu, (struct smu_11_0_powerplay_table *)smu->smu_table.power_play_table;struct smu_11_0_overdrive_table *od_settings = smu->od_settings;PPTable_t *pptable = smu->smu_table.driver_pptable; -uint32_t power_limit, od_percent_upper =0 , od_percent_lower =0 ; +uint32_t current_limit, default_limit; +uint32_t od_percent_upper =0 , od_percent_lower =0 ; -if (smu_v11_0_get_current_power_limit (smu, &power_limit)) { -/* the last hope to figure out the ppt limit */ -if (!pptable) { -dev_err (smu->adev->dev,"Cannot get PPT limit due to pptable missing!" ); -return -EINVAL ; - } - power_limit = - pptable->SocketPowerLimitAc[PPT_THROTTLER_PPT0 ]; +if (!pptable) { +dev_err (smu->adev->dev, +"Cannot get PPT limit due to pptable missing!" ); +return -EINVAL ; } + default_limit = smu->adev->pm.ac_power ? + pptable->SocketPowerLimitAc[PPT_THROTTLER_PPT0 ] : + pptable->SocketPowerLimitDc[PPT_THROTTLER_PPT0 ]; + +if (smu_v11_0_get_current_power_limit (smu, ¤t_limit)) + current_limit = default_limit; +if (current_power_limit) - *current_power_limit = power_limit; + *current_power_limit = current_limit;if (default_power_limit) - *default_power_limit = power_limit; + *default_power_limit = default_limit;if (powerplay_table) { if (smu->od_enabled &&
@@ -2422,15 +2426,15 @@ static int navi10_get_power_limit(struct smu_context *smu, }dev_dbg (smu->adev->dev,"od percent upper:%d, od percent lower:%d (default power: %d)\n" , - od_percent_upper, od_percent_lower, power_limit); + od_percent_upper, od_percent_lower, default_limit);if (max_power_limit) { - *max_power_limit = power_limit * (100 + od_percent_upper); + *max_power_limit = default_limit * (100 + od_percent_upper); *max_power_limit /=100 ; }if (min_power_limit) { - *min_power_limit = power_limit * (100 - od_percent_lower); + *min_power_limit = default_limit * (100 - od_percent_lower); *min_power_limit /=100 ; }
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +16 -12
@@ -632,20 +632,24 @@ static int sienna_cichlid_get_power_limit(struct smu_context *smu,struct smu_11_0_7_powerplay_table *powerplay_table = (struct smu_11_0_7_powerplay_table *)smu->smu_table.power_play_table;struct smu_11_0_7_overdrive_table *od_settings = smu->od_settings; -uint32_t power_limit, od_percent_upper =0 , od_percent_lower =0 ; -uint16_t *table_member; +uint32_t current_limit, default_limit; +uint32_t od_percent_upper =0 , od_percent_lower =0 ; +u16 *power_limit_ac, *power_limit_dc; -GET_PPTABLE_MEMBER (SocketPowerLimitAc, &table_member); +GET_PPTABLE_MEMBER (SocketPowerLimitAc, &power_limit_ac); +GET_PPTABLE_MEMBER (SocketPowerLimitDc, &power_limit_dc); -if (smu_v11_0_get_current_power_limit (smu, &power_limit)) { - power_limit = - table_member[PPT_THROTTLER_PPT0 ]; - } + default_limit = smu->adev->pm.ac_power ? + power_limit_ac[PPT_THROTTLER_PPT0 ] : + power_limit_dc[PPT_THROTTLER_PPT0 ]; + +if (smu_v11_0_get_current_power_limit (smu, ¤t_limit)) + current_limit = default_limit;if (current_power_limit) - *current_power_limit = power_limit; + *current_power_limit = current_limit;if (default_power_limit) - *default_power_limit = power_limit; + *default_power_limit = default_limit;if (powerplay_table) { if (smu->od_enabled &&
@@ -659,15 +663,15 @@ static int sienna_cichlid_get_power_limit(struct smu_context *smu, }dev_dbg (smu->adev->dev,"od percent upper:%d, od percent lower:%d (default power: %d)\n" , - od_percent_upper, od_percent_lower, power_limit); + od_percent_upper, od_percent_lower, default_limit);if (max_power_limit) { - *max_power_limit = power_limit * (100 + od_percent_upper); + *max_power_limit = default_limit * (100 + od_percent_upper); *max_power_limit /=100 ; }if (min_power_limit) { - *min_power_limit = power_limit * (100 - od_percent_lower); + *min_power_limit = default_limit * (100 - od_percent_lower); *min_power_limit /=100 ; }return 0 ;
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +6 -2
@@ -1281,8 +1281,12 @@ static int aldebaran_get_power_limit(struct smu_context *smu,if (current_power_limit) *current_power_limit = power_limit; -if (default_power_limit) - *default_power_limit = power_limit; +if (default_power_limit) { +if (pptable) + *default_power_limit = pptable->PptLimit; +else + *default_power_limit = power_limit; + }if (max_power_limit) {if (pptable)
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18] drm/amd/pm: derive stable PPT limits from PPTable
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] drm/amd/pm: aldebaran_get_power_limit() sets non-zero default on secondary die --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] drm/amd/pm: aldebaran_get_power_limit() sets non-zero default on secondary die --
commit e12c0e27cabe98103b51eb24b3ca4cb7b2a3ede8
Author: Yang Wang <[email protected]>
drm/amd/pm: derive stable PPT limits from PPTable
This commit updates the power limit query handlers for Sienna Cichlid, Navi10, Arcturus, and Aldebaran to derive platform default, minimum, and maximum PPT limits from the driver PPTable rather than mutable PMFW runtime state.
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0@@ -1281,8 +1281,12 @@ static int aldebaran_get_power_limit(struct smu_context *smu,
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_get_power_limit(struct smu_context *smu, · line 1289
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +6
-2if (current_power_limit) *current_power_limit = power_limit; -if (default_power_limit) - *default_power_limit = power_limit; +if (default_power_limit) { +if (pptable) + *default_power_limit = pptable->PptLimit; +else + *default_power_limit = power_limit; + }
[Severity: Medium]
On Aldebaran multi-die GPUs, could this cause the secondary die to report a non-zero default power limit in hwmon (power1_cap_default)?
Earlier in aldebaran_get_power_limit(), both the SMU_MSG_GetPptLimit query and the pptable->PptLimit fallback are guarded by aldebaran_is_primary(smu) (from commit 076f55a45e9e ("drm/amd/pm: Only primary die supports power data")):
/* Valid power data is available only from primary die.
* For secondary die show the value as 0.
*/
if (aldebaran_is_primary(smu)) {
ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetPptLimit,
&power_limit);
if (ret) {
/* the last hope to figure out the ppt limit */
if (!pptable) {
dev_err(smu->adev->dev,
"Cannot get PPT limit due to pptable missing!");
return -EINVAL;
}
power_limit = pptable->PptLimit;
}
}Similarly, aldebaran_set_power_limit() rejects changes on the secondary die:
/* Power limit can be set only through primary die */ if (aldebaran_is_primary(smu)) return smu_v13_0_set_power_limit(smu, limit_type, limit); return -EINVAL;
Because smu->smu_table.driver_pptable is allocated and populated on all dies via aldebaran_init_smc_tables() -> smu_v13_0_init_smc_tables() and aldebaran_store_powerplay_table(), pptable is non-NULL on the secondary die.
When smu_late_init() -> smu_get_asic_power_limits() calls aldebaran_get_power_limit(), *default_power_limit was previously set to power_limit (0 on the secondary die), whereas now it will be set to pptable->PptLimit without checking aldebaran_is_primary(smu). Should the pptable->PptLimit assignment for default_power_limit also be gated on aldebaran_is_primary(smu)?
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0if (max_power_limit) {if (pptable)
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 HID: universal-pidff: Add support for Turtle Beach VelocityOne Race
In reply to Sasha LevinFrom: Tomasz Pakuła <[email protected]>
[ Upstream commit 53f7f7955a684e820bdd6bd6792c45c4b434f637 ]
Add usb VID and device PID to hid-ids.h
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
- Record: [HID / universal-pidff] [Add] USB VID/PID so Turtle Beach VelocityOne Race binds to the existing hid-universal-pidff driver
**Step 1.2 — Tags**
- Record:
- Signed-off-by: Tomasz Pakuła <[email protected]> (author; co-author of this driver)
- Signed-off-by: Jiri Kosina <[email protected]> (HID maintainer)
- [Upstream commit 53f7f7955a684e820bdd6bd6792c45c4b434f637] and Signed-off-by: Sasha Levin ignored as pipeline markers
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, Link:, or Cc: stable (absence of the last two is expected)
**Step 1.3 — Body**
- Record: Body is one sentence: “Add usb VID and device PID to hid- ids.h”. No crash, leak, or corruption described. The claimed intent is hardware enablement for one USB HID device. No version range given. Root cause as stated: the IDs were missing from the existing driver’s table.
**Step 1.4 — Hidden bug fix?**
- Record: Not a disguised leak/race/UAF. It is a USB ID addition to an existing driver (stable exception category 1).
---
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
- Record:
- drivers/hid/hid-ids.h: +3 (two #defines plus a blank line)
- drivers/hid/hid-universal-pidff.c: +1 in
`universal_pidff_devices[]`
- Net +4 lines, two files, one table plus ID macros
- Classification: single-purpose, surgical device-ID add
**Step 2.2 — Code flow**
- Record:
- Before: 0x10f5:0x7077 is unmatched by this driver and falls through to generic HID.
- After: HID core matches HID_USB_DEVICE(USB_VENDOR_ID_TURTLE_BEACH, USB_DEVICE_ID_TB_VELOCITYONE_RACE) and calls universal_pidff_probe().
- Path: device enumeration / probe, not an error path. No driver_data quirks.
**Step 2.3 — Bug mechanism**
- Record: [Hardware enablement / USB device ID] — the driver already implements PID force-feedback wrapping; this only lists one more VID/PID. Not UAF, leak, race, overflow, or init-bug.
**Step 2.4 — Fix quality**
- Record: Obviously correct as an ID table add. Insertion sits alphabetically between TURBOX and TWINHAN. Vendor 0x10f5 already identifies Turtle Beach elsewhere (drivers/input/joystick/xpad.c uses 0x10f5 with other PIDs 0x7005/0x7008/0x7073). PID 0x7077 does not collide with those. No public API change. Regression risk is low: only this VID:PID binds; probe returns 0 even if the PID usage page is absent.
---
## Phase 3: Git history
**Step 3.1 — Blame**
- Record: New lines; they did not exist before this commit. Surrounding hid-ids.h TURBOX/TWINHAN macros date to 2008–2017. The device table terminator was last touched by 5b9cae8c6472e (clang-format, 2025). The driver itself was added in f06bf8d94fffb (“HID: Add hid- universal-pidff driver and supported device ids”, 2025-02-03; git describe of that commit is v6.13-4738-gf06bf8d94fffb).
**Step 3.2 — Fixes: tag**
- Record: No Fixes: tag. Not applicable.
**Step 3.3 — File history**
- Record: Recent related commits on this driver: Asetek ID adds (c385f61108d40), spelling/format nits, and 01d9874e84d3a (stop device on FF init failure). No prerequisite refactor is required for this ID. Standalone; not “patch X/Y”. No later follow-up on these files after this commit.
**Step 3.4 — Author**
- Record: Tomasz Pakuła is a listed MODULE_AUTHOR of hid-universal- pidff.c and a frequent hid-pidff contributor (overflow, NPD, playback, Asetek IDs). This is the subsystem’s own device-table maintainer, not a drive-by.
**Step 3.5 — Dependencies**
- Record: Needs hid-universal-pidff.c, USB_VENDOR_ID_* macros, and hid_pidff_init_with_quirks. All are in this tree. git merge-base --is-ancestor f06bf8d94fffb HEAD succeeds; git merge-base --is- ancestor f06bf8d94fffb v6.18 also succeeds. Can apply standalone.
---
## Phase 4: Mailing list / external research
**Step 4.1 — Original discussion**
- Record: b4 dig -c 53f7f7955a684e820bdd6bd6792c45c4b434f637 → https:/ /patch.msgid.link/20260922131758.1242755-1- [email protected]
- b4 dig -a: single v1 series only; no v2/v3.
- LKML: https://lkml.iu.edu/2609.2/17309.html (submission),
https://lkml.iu.edu/2609.2/21230.html (Jiri Kosina: “Applied, thanks.”)
- No NAK, no requested changes, no stable nomination in review. lore.kernel.org fetch returned 403; discussion confirmed via b4 dig
+ LKML/Patchew mirrors.
**Step 4.2 — Recipients (b4 dig -w)**
- Record: [email protected] (HID maintainer), [email protected] (co- author), [email protected], linux- [email protected]. Right lists and maintainer were on Cc; Kosina applied it.
**Step 4.3 — Bug report**
- Record: No Reported-by / syzbot / bugzilla. Phoronix (secondary, not a kernel bug tracker) notes basic HID input already worked and this listing improves FF for the VelocityOne Race. That is consistent with an ID add, not a crash fix.
**Step 4.4 — Series context**
- Record: Standalone one-patch series. Same pattern as earlier Asetek ID adds in this driver.
**Step 4.5 — Stable list**
- Record: WebFetch of https://lore.kernel.org/stable/?q=VelocityOne returned 403. Web search did not show a stable-list thread about this patch. UNVERIFIED that nobody discussed it on stable@; no evidence of a NAK there either.
---
## Phase 5: Code semantic analysis
**Step 5.1 — Functions**
- Record: No function body changed. Data only:
universal_pidff_devices[] plus two macros. Probe path that becomes
reachable: universal_pidff_probe → universal_pidff_input_mapping / universal_pidff_input_configured.
**Step 5.2 — Callers**
- Record: universal_pidff_probe is only the .probe of struct hid_driver universal_pidff, registered via module_hid_driver. Invoked by HID/USB enumeration when VID:PID matches. Not IRQ, not a syscall hot path.
**Step 5.3 — Callees**
- Record: hid_parse, hid_hw_start, hid_pidff_init_with_quirks, hid_hw_stop. Existing, already used by every other ID in the table.
**Step 5.4 — Reachability**
- Record: Reachable when a user plugs in 10f5:7077 and CONFIG_HID_UNIVERSAL_PIDFF is enabled (depends on USB_HID && HID_PID). Userspace cannot trigger it without that hardware.
**Step 5.5 — Similar patterns**
- Record: Same table already lists Moza, Cammus, VRS, FFBeast, Lite Star/PXN, Asetek. This is the established way this driver gains devices. Turtle Beach VID 0x10f5 is already used in xpad.c for other products; PID 0x7077 is unique.
---
## Phase 6: Local tree (this checkout)
**Step 6.1 — Does the code exist here?**
- Record: Local tree is **6.18.57** (make kernelversion; git describe HEAD = v6.18.57-155-gcdf239ca885b2). hid-universal-pidff.c exists. Driver intro f06bf8d94fffb is an ancestor of both HEAD and v6.18. Parent of this candidate still has the Asetek rows and the empty terminator; the ID macros were absent (git grep USB_VENDOR_ID_TURTLE on the parent was empty). The hardware and driver this listing targets are in this tree.
**Step 6.2 — Backport difficulty**
- Record: Clean apply. Parent context matches the provided diff (TURBOX block, then TWINHAN; Asetek entries then {}). No refactor gap.
**Step 6.3 — Related fixes already here?**
- Record: No other VelocityOne Race HID listing. No alternate fix for 10f5:7077 in HID. xpad.c does not claim PID 0x7077.
---
## Phase 7: Subsystem context
**Step 7.1**
- Record: [HID USB force-feedback helper] [IMPORTANT for owners of listed wheels; PERIPHERAL vs core kernel]. Not mm/fs/net core. Optional CONFIG_HID_UNIVERSAL_PIDFF.
**Step 7.2**
- Record: Actively maintained in 2025–2026 (quirks, Asetek IDs, pidff correctness fixes). Mature enough that ID adds are the normal extension mechanism.
---
## Phase 8: Impact and risk
**Step 8.1 — Who is affected**
- Record: Driver-specific / config-specific: users who own a Turtle Beach VelocityOne Race and enable this HID driver. Everyone else is unchanged.
**Step 8.2 — Trigger**
- Record: Plug in that USB wheel. Not a race. Unprivileged user can plug hardware; no syscall exploit surface beyond normal HID.
**Step 8.3 — Failure mode without the patch**
- Record: Device stays on hid-generic: basic input, missing this driver’s PID FF init and button-range mapping. Not oops/deadlock/corruption. Severity for those users: functional hardware gap (FF), **MEDIUM** as a bug, but it is the documented device-ID exception.
**Step 8.4 — Risk vs benefit**
- Record: Benefit: FF/PID support for this wheel on 6.18.y without a full kernel upgrade. Risk: very low (4 lines, match is VID+PID, no quirk, probe already tolerates missing PID page). Ratio: favorable for a device-ID add.
---
## Phase 9: Synthesis
**Step 9.1 — Evidence**
For:
- USB ID add to a driver that already exists in this 6.18 tree (stable exception 1).
- +4 lines, no new APIs, no new driver, no new sysfs/module params.
- HID maintainer applied v1 with no objections.
- Author maintains this driver.
- VID 0x10f5 is already Turtle Beach in-tree; PID does not clash with xpad entries.
- Applies cleanly here.
Against:
- Not a crash/security/corruption fix.
- Short commit message; no Reported-by.
- Niche ~$650 sim-racing hardware.
- Improves FF rather than repairing a generic HID oops.
Unresolved:
- lore.kernel.org HTTP 403; stable@ thread not confirmed.
- No in-tree test that this exact PID speaks USB PID FF (same as other IDs in this table).
**Step 9.2 — Stable rules**
1. Obviously correct and tested? **PASS** — mechanical ID add; maintainer applied it. No in-tree Tested-by, but the change is the same class as prior IDs in this file.
2. Real issue affecting users? **PASS** — without the ID, this wheel does not get the existing PID FF path.
3. Important (crash/security/deadlock) **or** listed exception? **PASS** — USB device ID on an existing driver.
4. Small and contained? **PASS** — 4 lines, two files.
5. No new features/APIs? **PASS** — no new driver, ioctl, or userspace ABI; only an ID in an existing table.
6. Applies to this tree? **PASS** — driver and insertion point are present on 6.18.57.
**Step 9.3 — Exception**
- Record: **NEW DEVICE ID** (USB VID/PID) on existing hid-universal- pidff.
**Step 9.4 — Decision**
This is exactly the device-ID class stable trees take. The driver is in 6.18; the patch is tiny and isolated to 10f5:7077. Benefit is real for owners of that wheel; risk to everyone else is negligible.
---
### What the commit does for this tree
It lists Turtle Beach VelocityOne Race (USB 10f5:7077) in hid- universal-pidff so 6.18 systems can use the PID force-feedback path already in this kernel, instead of generic HID only.
### Stable-rules fit
Meets the device-ID exception: existing driver, IDs only, clean apply, no new API.
### Risk vs benefit
Very low risk, localized hardware enablement. No locking or error-path change.
### Concerns
None that block backport. No extra quirks or follow-up commits required in this tree. Stable-list discussion could not be fetched (403).
---
Verification:
- [Phase 1] Parsed tags: author SOB + Jiri Kosina SOB; no Fixes/Reported-by/Cc:stable
- [Phase 1] Body is a one-line ID add, not a crash write-up
- [Phase 2] Diff: +3 hid-ids.h, +1 table row; no function logic change
- [Phase 2] No driver_data quirk on the new entry
- [Phase 3] git blame on new macros → this commit; surrounding IDs from 2008–2017
- [Phase 3] Driver intro f06bf8d94fffb (v6.13-4738-gf06bf8d94fffb); ancestor of HEAD and of v6.18
- [Phase 3] git log --oneline --author="Tomasz Pakuła" -- drivers/hid/: driver co-maintainer, many pidff commits
- [Phase 3] No later commits on these files after this ID add
- [Phase 4] b4 dig -c 53f7f7955a684e820bdd6bd6792c45c4b434f637: lore msgid [email protected]
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: [email protected], linux-input, co-author Oleg
- [Phase 4] LKML: Kosina “Applied, thanks.”
(https://lkml.iu.edu/2609.2/21230.html)
- [Phase 4] lore.kernel.org WebFetch: 403; used LKML/Patchew/b4 instead
- [Phase 5] Probe only via module_hid_driver; callees hid_parse/hid_hw_start/hid_pidff_init_with_quirks exist here
- [Phase 5] 0x10f5 in xpad.c for other PIDs; 0x7077 not used there
- [Phase 6] make kernelversion → 6.18.57; git describe HEAD → v6.18.57-155-gcdf239ca885b2
- [Phase 6] Parent of candidate: no USB_VENDOR_ID_TURTLE; Asetek rows present; apply context matches
- [Phase 8] Failure mode: missing FF/mapping for one USB wheel, not oops
- UNVERIFIED: stable@ archive (HTTP 403); no in-kernel confirmation the device implements USB PID (same as other table IDs)
**YES**
drivers/hid/hid-ids.h | 3 +++ drivers/hid/hid-universal-pidff.c | 1 + 2 files changed, 4 insertions(+)
drivers/hid/hid-ids.h +3 -0
@@ -1415,6 +1415,9 @@#define USB_DEVICE_ID_ASUS_MD_5110 0x5110#define USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART 0x7100 +#define USB_VENDOR_ID_TURTLE_BEACH 0x10f5 +#define USB_DEVICE_ID_TB_VELOCITYONE_RACE 0x7077 +#define USB_VENDOR_ID_TWINHAN 0x6253#define USB_DEVICE_ID_TWINHAN_IR_REMOTE 0x0100
drivers/hid/hid-universal-pidff.c +1 -0
@@ -187,6 +187,7 @@ static const struct hid_device_id universal_pidff_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_ASETEK, USB_DEVICE_ID_ASETEK_FORTE) }, { HID_USB_DEVICE(USB_VENDOR_ID_ASETEK, USB_DEVICE_ID_ASETEK_LA_PRIMA) }, { HID_USB_DEVICE(USB_VENDOR_ID_ASETEK, USB_DEVICE_ID_ASETEK_TONY_KANAAN) }, + { HID_USB_DEVICE(USB_VENDOR_ID_TURTLE_BEACH, USB_DEVICE_ID_TB_VELOCITYONE_RACE)}, {} };MODULE_DEVICE_TABLE (hid, universal_pidff_devices);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 nvme: bound ns descriptor header and body to identify buffer
In reply to Sasha LevinFrom: Hari Mishal <[email protected]>
[ Upstream commit 3c568b35a0d309acb40746552bec2af24cd550ef ]
nvme_identify_ns_descs() allocates a buffer and gives it to the controller, which populates it and then iterates the buffer with variable byte increments that vary by type and body size. But, there is no bounds check inside the iteration itself except the loop bound itself. Fix this by checking and stopping iteration if the next header or its declared body would go past the buffer itself.
---
LLM Generated explanations, may be completely bogus:
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[nvme]** **[bound]** bound namespace descriptor header and body to the Identify buffer so iteration cannot walk off the end.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Assisted-by:** gkh_clanker_t1000 (LLM-assisted; not a substitute for review)
- **Reviewed-by:** Christoph Hellwig \<[email protected]\> (NVMe maintainer)
- **Signed-off-by:** Hari Mishal \<[email protected]\> (author)
- **Signed-off-by:** Greg Kroah-Hartman \<[email protected]\> (submitted the series)
- **Signed-off-by:** Keith Busch \<[email protected]\> (NVMe maintainer; applied)
- **No Fixes:** tag (expected for this review pipeline)
- **No Cc: stable** (expected)
- **No Reported-by / Tested-by / Link / syzbot**
- Ignore pipeline markers: none in the supplied text beyond the usual SOBs
Notable: reviewed and applied by the two primary NVMe maintainers. Submitted as **[PATCH 1/2]** with an unrelated sibling (FDP clamp).
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** nvme_identify_ns_descs() allocates a 4096-byte Identify buffer, lets the controller fill it, then walks variable-length namespace ID descriptors. The only guard was pos < NVME_IDENTIFY_DATA_SIZE.
- **Symptom/failure mode:** out-of-bounds header/body access when a descriptor header sits near the end of the buffer, or nidl claims a body that extends past 4096 bytes. That is a heap OOB read (possible crash, KASAN report, or adjacent-heap leak via memcpy in nvme_process_ns_desc()).
- **Version info:** none in the message. The walker has existed since 2017.
- **Root cause:** device-controlled stride (sizeof(header) + nidl) with no check that the next header or declared body still fits in the allocation.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not a disguised cleanup.** It is an explicit bounds-check fix. The verb “bound” here means “do not read past the buffer.”
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** drivers/nvme/host/core.c — **+4 / −0**
- **Function:** nvme_identify_ns_descs()
- **Scope:** single-file surgical fix (two if + break pairs)
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: **Before:** loop at pos, form cur = data + pos, read cur->nidl immediately, then call nvme_process_ns_desc() which memcpys the body. **After:** (1) if the 4-byte header would pass the buffer, stop; (2) if nidl == 0, stop (unchanged); (3) if header+body would pass the buffer, stop; then process. Still an Identify/scan path, not an error-recovery rewrite. Stopping with break matches existing nidl == 0 / len < 0 handling (no new error code for a truncated trailing descriptor).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Memory safety / out-of-bounds]** Device-controlled OOB read.
Mechanism, verified against struct nvme_ns_id_desc (nidt, nidl, reserved — 4 bytes) and nvme_process_ns_desc():
- If pos is 4093–4095, reading the header itself is OOB.
- If the header fits but nidl does not leave enough remaining bytes, known-type memcpy (EUI64/NGUID/UUID/CSI) reads past the kzalloc(4096) buffer after the length-equals-expected check.
The fix stops before those accesses. Header check is first, so cur->nidl is only read when the header is in-bounds.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: **Obviously correct and minimal.** Check order is right. nidl is __u8 (max 255); pos is non-negative and < 4096; pos + 4 + nidl cannot overflow a 32-bit int. On spec-compliant lists that fit in 4096 bytes the new branches never fire. **Regression risk: very low.** Truncating a malformed last descriptor is safer than reading past the buffer. If CSI is truncated on a multi-CSS controller, the existing !csi_seen path can still return -EINVAL — that is the conservative failure.
No API, locking, or data-structure change.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record: Loop introduced by **3b22ba2682b432** (“nvme: get list of namespace descriptors”, Johannes Thumshirn, 2017-06-15) — first contained in **v4.13-rc1**. The two bounds checks are **3c568b35a0d309** (this commit, 2026-07-14). The walker has been in- tree for many years.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Buggy pattern comes from 3b22ba2682b432, which is an ancestor of this checkout.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Same-author sibling **bc7f75eba5001** — nvmet: passthru: fix OOB reads when parsing ns id descriptor list (same descriptor-list OOB class on the target passthru path). Independent file.
- Series sibling **29261f8bb4166** — nvme: clamp FDP nruhsd... is a different function (nvme_query_fdp_info). **This 1/2 does not depend on 2/2.**
- Later core.c changes (kmalloc_obj, unsigned nsid print, scan/SRCU/FDP) do not rewrite this loop. **Standalone.**
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Hari Mishal is not an NVMe maintainer; three NVMe commits, all device-controlled bounds issues. Weight comes from **Christoph Hellwig Reviewed-by** and **Keith Busch** applying it to nvme-7.3.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **None.** Adds checks in an existing loop. nvme_process_ns_desc(), NVME_IDENTIFY_DATA_SIZE (4096), and struct nvme_ns_id_desc already exist here. Applies standalone.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **b4 dig:** https://patch.msgid.link/2026070931-stopping-
cost-239a@gregkh
- **v1 only** (b4 dig -a); applied version is that v1
- Thread (mbox): Christoph: “Looks good: Reviewed-by”; Keith: “Thanks, series applied to nvme-7.3.”
- **No NAK, no stability concerns, no request for Cc: stable**
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/Cc included **linux-nvme**, **Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg** (all NVM EXPRESS DRIVER maintainers). Appropriate audience.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: **No user/syzbot/bugzilla report.** Found by analysis (Greg’s clanker + author). Still a real, reachable OOB given a malformed Identify NS descriptor list.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: **[PATCH 1/2]** / **[PATCH 2/2]** share an author and file but not code. 1/2 is self-contained. Target passthru fix is a related class, not a prerequisite.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable WebFetch **403**. **UNVERIFIED** whether stable@ already discussed this hash. Absence of Cc: stable is expected here and is not a negative.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
Record: **nvme_identify_ns_descs()** modified; **nvme_process_ns_desc()** callee (memcpy of descriptor bodies).
**Step 5.2: TRACE CALLERS**
Record:
- Only caller: nvme_scan_ns() in drivers/nvme/host/core.c
- nvme_scan_ns() ← nvme_scan_ns_async() / nvme_scan_ns_sequential()
- Those ← nvme_scan_work() on ctrl->scan_work
Context: **process-context workqueue**, NVMe namespace scan on probe, reset, and NS-changed AEN. Common path for NVMe hosts, not IRQ/hot- cache.
**Step 5.3: TRACE CALLEES**
Record: kzalloc / nvme_submit_sync_cmd / nvme_process_ns_desc / kfree. The OOB is in the parse loop and in nvme_process_ns_desc() memcpy, not in the admin command itself.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable on any NVMe 1.3+ controller (or multi-CSS) that does not have NVME_QUIRK_NO_NS_DESC_LIST. Userspace does not call this syscall-direct; a **malicious or buggy controller** (local PCIe or NVMe- oF target) controls the buffer. That is a standard untrusted-device memory-safety bug.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same class already bounded in drivers/nvme/target/passthru.c (pos + sizeof(*cur) and CSI body). Host-side nvme_identify_ns_descs() was the gap this commit closes.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record:
- Local tree: **git describe HEAD = v7.3-rc4-27-gf0100363d8c37**, **make kernelversion = 7.3.0-rc4**
- Function and loop exist at drivers/nvme/host/core.c (nvme_identify_ns_descs)
- Bug introduced **v4.13** (3b22ba2682b432), long before this branch
- The two checks are present on HEAD (this commit is an ancestor). That is historical fact, **not** used as “already selected for stable”
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** to this nvme_identify_ns_descs() shape. Context is the same 4.13-era loop; no extra helpers required. **Expected backport difficulty: clean apply** on trees that still have this function.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No earlier host-side equivalent. Passthru OOB fix is a different file. No conflicting alternate host fix.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: **NVMe host core** (drivers/nvme/host/core.c). **IMPORTANT** — common block/storage path, not mm/VFS core, but widely deployed (servers, laptops, NVMe-oF).
**Step 7.2: SUBSYSTEM ACTIVITY**
Record: Actively maintained (Keith Busch, Christoph Hellwig, et al.). This is a small correctness fix in old parse code, not a follow-on to a brand-new feature in 7.3.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Record: **Driver-specific, but broad:** NVMe hosts scanning namespaces (almost all NVMe users on 1.3+). Triggered by device Identify data, not a rare Kconfig.
**Step 8.2: TRIGGER CONDITIONS**
Record: Namespace scan (probe/reset/NS-changed). **Not** every I/O. Needs a **malformed descriptor list** (buggy firmware or untrusted target). Unprivileged local users typically cannot inject Identify payloads without device control; NVMe-oF to an untrusted target can. Timing-independent; deterministic given bad data.
**Step 8.3: FAILURE MODE SEVERITY**
Record: **Heap out-of-bounds read** → KASAN/oops, possible info leak, or silent heap corruption adjacent to the Identify buffer. **Severity:
HIGH.** Not a guaranteed panic on production kernels, but it is a real memory-safety bug in a storage driver.
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit: high** — stops device-controlled OOB on a common NVMe scan path; 4 lines; maintainers acked.
- **Risk: very low** — two range checks; no lock/API/behavior change for valid lists.
- **Ratio: strongly favors backport.**
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real OOB read from controller-controlled Identify NS descriptor list
- Path is namespace scan on ordinary NVMe hosts
- 4-line, obviously correct bounds checks; header checked before nidl
- Same bug class already recognized on the passthru parser
- Reviewed-by Christoph Hellwig; applied by Keith Busch
- Code has existed since v4.13; no missing prerequisites in this tree
- No new feature/API
**AGAINST:**
- No Fixes:/Cc: stable/syzbot/user report (not a negative per the rules)
- LLM-assisted origin (offset by maintainer review)
- Trigger needs a bogus/malicious controller, not typical I/O
- Series labeled 1/2 (sibling is independent)
**UNRESOLVED:**
- lore.kernel.org HTTP 403; thread recovered via b4 mbox
- Whether stable@ already discussed this commit: **UNVERIFIED**
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — two range checks; Reviewed- by maintainer; applied to nvme-7.3
2. Fixes a real bug that affects users? **PASS** — OOB parse of device Identify data
3. Important (crash/security/corruption/deadlock)? **PASS** — HIGH memory-safety (OOB read; crash/leak potential)
4. Small and contained? **PASS** — +4 lines, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — same function/context; no extra deps
**Step 9.3: EXCEPTION CATEGORIES**
Record: **None** (not an ID/quirk/DT/build/doc exception). It qualifies as a normal small memory-safety fix.
**Step 9.4: DECISION**
This is a surgical host-side bounds check for a long-standing, device- controlled OOB in NVMe namespace scanning. It meets stable rules for this checkout (7.3-rc4; buggy walker present since v4.13). Benefit is high; regression risk is very low.
---
### What the commit solves (for this tree)
nvme_identify_ns_descs() walks a 4096-byte Identify Namespace ID Descriptor List with a device-chosen stride. Without checking that the next 4-byte header and nidl body fit, a truncated or oversized last descriptor causes an out-of-bounds header read and/or memcpy in nvme_process_ns_desc(). That hits every NVMe scan of a 1.3+ (or multi- CSS) controller that returns a bad list. The patch stops the loop before those accesses. Compliant devices are unchanged.
### Risk vs benefit
Four lines of range checks, no locking or ABI change. Worst case on a truncated list is skipping remaining descriptors (already the nidl == 0 policy). Benefit is preventing a heap OOB in a widely used storage driver.
### Concerns
None that block backport: 1/2 is independent of the FDP 2/2 patch; no extra commits required; apply is clean against this nvme_identify_ns_descs().
---
### Verification
- **[Phase 1]** Parsed tags: Reviewed-by Christoph Hellwig; SOB Hari Mishal, Greg Kroah-Hartman, Keith Busch; Assisted-by gkh_clanker_t1000; no Fixes/Reported-by/Cc:stable/syzbot
- **[Phase 2]** Diff: +4 lines in nvme_identify_ns_descs(); two pos + sizeof(*cur) / + cur->nidl checks vs NVME_IDENTIFY_DATA_SIZE (4096). Confirmed struct nvme_ns_id_desc is 4 bytes; nidl is __u8
- **[Phase 2]** nvme_process_ns_desc() memcpy of EUI64/NGUID/UUID/CSI only after nidl matches expected length — body check is what keeps those copies in-buffer
- **[Phase 2]** Integer overflow: max pos+hdr+nidl ≈ 4354, no 32-bit overflow
- **[Phase 3]** git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- **[Phase 3]** Commit 3c568b35a0d309; git merge-base --is-ancestor → ancestor of HEAD
- **[Phase 3]** Blame: loop 3b22ba2682b432 (2017, v4.13-rc1); checks from this commit
- **[Phase 3]** Pre-image git show 3c568b35a0d30^:... matches the supplied diff (no header/body checks)
- **[Phase 3]** Sibling 29261f8bb4166 is nvme_query_fdp_info() only — not a prereq. Related bc7f75eba5001 is target passthru
- **[Phase 4]** b4 dig -c 3c568b35a0d309: lore/msgid 2026070931-stopping-cost-239a@gregkh; v1 only; CC linux-nvme + all NVMe maintainers
- **[Phase 4]** mbox: Hellwig Reviewed-by; Busch “series applied to nvme-7.3”; no NAK
- **[Phase 4]** WebFetch lore.kernel.org / patch.msgid.link / lore stable search: **403** — discussion taken from b4 mbox instead
- **[Phase 5]** Only caller nvme_scan_ns() → nvme_scan_work() (probe/reset/NS-changed scan)
- **[Phase 5]** Similar bounds already in drivers/nvme/target/passthru.c
- **[Phase 6]** Buggy walker exists in this tree’s history since v4.13; current file has the checks; apply would be clean
- **[Phase 6]** MAINTAINERS: NVM EXPRESS DRIVER — Busch, Axboe, Hellwig, Grimberg
- **[Phase 8]** Failure mode: heap OOB read on malformed Identify NS descriptor list; severity HIGH
- **UNVERIFIED:** whether stable@ already discussed this commit (lore stable HTTP 403)
**YES**
drivers/nvme/host/core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/nvme/host/core.c +4 -0
@@ -1564,8 +1564,12 @@ static int nvme_identify_ns_descs(struct nvme_ctrl *ctrl,for (pos =0 ; pos <NVME_IDENTIFY_DATA_SIZE ; pos += len) {struct nvme_ns_id_desc *cur = data + pos; +if (pos +sizeof (*cur) >NVME_IDENTIFY_DATA_SIZE ) +break ;if (cur->nidl ==0 )break ; +if (pos +sizeof (*cur) + cur->nidl >NVME_IDENTIFY_DATA_SIZE ) +break ; len =nvme_process_ns_desc (ctrl, &info->ids, cur, &csi_seen);if (len <0 )
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 udf: validate extent partition references in udf_current_aext()
In reply to Sasha LevinFrom: Kyle Zeng <[email protected]>
[ Upstream commit 120ec50984b8645232c2c004310dd94ceff5520e ]
Long allocation descriptors carry an on-disk extLocation.partitionReferenceNum. udf_current_aext() copies that value into a kernel_lb_addr and returns it to several consumers.
If the partition reference is outside s_partitions, callers can later index s_partmaps out of bounds. The truncate/free path can pass such an extent to udf_free_blocks(), where the invalid partition reference causes a slab out-of-bounds read.
Validate eloc->partitionReferenceNum in udf_current_aext() before returning a decoded extent. This rejects invalid file extents and indirect allocation descriptor extents in the common parser, so callers do not need to duplicate the partition-map bounds check.
---
LLM Generated explanations, may be completely bogus:
The local checkout is **v7.3-rc4** (7.3.0-rc4). This is a real UDF slab out-of-bounds on crafted long allocation descriptors; the vulnerable parser and udf_free_blocks() indexing both exist here, and the 7-line check is the right place to reject them.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [udf] [validate] reject out-of-range on-disk extent partition references in udf_current_aext()
- Subsystem: udf (UDF filesystem)
- Verb: validate — safety-check language; this is a bounds-check bug fix, not a feature
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Assisted-by: Codex:gpt-5.5 — LLM-assisted; not a quality veto by itself
- Signed-off-by: Kyle Zeng <[email protected]> — author
- `Link:
https://patch.msgid.link/[email protected]`
- Signed-off-by: Jan Kara <[email protected]> — UDF maintainer (listed in MAINTAINERS)
- No Fixes: tag (expected for this review queue)
- No Cc: [email protected] (expected)
- No Reported-by: / Tested-by: / Reviewed-by: / Acked-by:
- Ignore pipeline SOBs; none were present beyond author + maintainer
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** Long ADs copy on-disk extLocation.partitionReferenceNum into kernel_lb_addr. That value can be >= s_partitions.
- **Symptom:** Callers later index s_partmaps[] out of bounds. The truncate/free path passes the extent to udf_free_blocks(), which does a **slab out-of-bounds read**.
- **Root cause:** Common extent decoder does not bounds-check the partition reference.
- **Fix:** Check eloc->partitionReferenceNum >= s_partitions in udf_current_aext() and return -EFSCORRUPTED.
- **Version info in message:** none. Git shows the long-AD copy dates to 28de7948a89676 (contained in v2.6.23-rc1).
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. The message names a slab OOB and a concrete consumer (udf_free_blocks()). This is an explicit memory-safety fix.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: fs/udf/inode.c — **+7 / -0**
- Function: udf_current_aext() only
- Scope: single-file surgical fix
Committed form (Jan Kara dropped a misplaced sbi local from the mailed v2):
```2316:2321:fs/udf/inode.c
if (eloc->partitionReferenceNum >=
UDF_SB(inode->i_sb)->s_partitions) {
udf_debug("invalid partition reference %u (partitions
%u)\n",
eloc->partitionReferenceNum,
UDF_SB(inode->i_sb)->s_partitions);
return -EFSCORRUPTED;
}
```**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** After decoding a short or long AD, return 1 with eloc filled. Long ADs take partitionReferenceNum from disk (lelb_to_cpu(lad->extLocation)). Short ADs copy the inode’s already- checked location.
- **After:** Same decode, then reject partitionReferenceNum >= s_partitions with -EFSCORRUPTED.
- Path: every extent walk through udf_current_aext() / udf_next_aext(), including truncate, bmap, directory iteration.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Memory safety / out-of-bounds** (category d). Verified in this tree: udf_free_blocks() still indexes with no partition check:
```664:669:fs/udf/balloc.c
void udf_free_blocks(struct super_block *sb, struct inode *inode,
struct kernel_lb_addr *bloc, uint32_t offset,
uint32_t count)
{
uint16_t partition = bloc->partitionReferenceNum;
struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition];
```extent_trunc() in fs/udf/truncate.c passes eloc from udf_current_aext() into udf_free_blocks(). udf_get_pblock() already bounds-checks, so reads are safer; the crash is the free/truncate path.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: same pattern as udf_read_inode() (iloc->partitionReferenceNum >= sbi->s_partitions) and udf_get_pblock().
- Minimal: one check before the success return.
- Regression risk: **low**. Callers already treat ret <= 0 as failure (ee703a7068f95 / b405c1e58b739). Truncate does while (... > 0) then if (ret < 0) return ret. -EFSCORRUPTED is already used across fs/udf/.
- Short-AD false positives: unlikely; udf_read_inode() already validates i_location.partitionReferenceNum (1d82a56bc5bf8).
- Mailed v2 put sbi in udf_write_aext() (wrong function); LKP failed to compile. Jan applied the check with UDF_SB() inline. The commit under review is that corrected form.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Long-AD copy: 28de7948a89676 (Cyrill Gorcunov, 2007), contained in **v2.6.23-rc1**
- Function skeleton: ^1da177e4c3f41 (2.6.12-rc2)
- Error-return API: ee703a7068f95 (2024), contained in **v6.12-rc2**
- The new check: 120ec50984b86 (this commit), contained in **v7.3-rc1**
The buggy decode has been in UDF for a long time.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Introducer is the long-standing long-AD decode, not a recent regression.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- 1d82a56bc5bf8 — partition check in udf_read_inode() (v4.11-rc1); inode location only, not file extents
- ee703a7068f95 / b405c1e58b739 — udf_current_aext/udf_next_aext return -errno; **present in this tree** (prerequisite for a clean -EFSCORRUPTED return)
- 5f0419457f89d — related truncate OOB in udf_free_blocks() (wrong end-block vs partition length); **present**; still does not check partition index
- Standalone patch (v2 of a single patch), not X/Y
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Only this UDF commit from Kyle Zeng in this tree. Weight comes from **Jan Kara** applying it, not from the author being the maintainer.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs udf_current_aext() to return -errno (ee703a7068f95). That **is** in this tree. No missing helpers or struct fields. Can apply standalone here.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 120ec50984b86 →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v2** is the matching series ([PATCH v2] udf: validate extent partition references...)
- v1 (LKML): [PATCH] udf: validate partition reference before freeing blocks — check inside udf_free_blocks() instead
- Thread (/tmp/udf-thread.mbox): LKP compile errors from sbi declared in udf_write_aext and used in udf_current_aext
- Jan Kara (18 Jun 2026): “Thanks! I've added the patch to my tree (just deleting the spurious sbi variable addition).”
- No NAK. No reviewer Cc: stable. Maintainer accepted.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): Kyle Zeng, [email protected], Jan Kara, [email protected]. Jan is the UDF maintainer. linux-fsdevel was not on the original To/Cc; Jan still took the patch.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla Reported-by. The message describes a slab OOB on truncate/free of a crafted long AD. A sibling UDF truncate OOB (5f0419457f89d) documents ftruncate(2) after a user-mount of removable UDF (UDisks/polkit) as a local availability issue. Same trigger class; that report is for a different bounds bug, not this exact partition-index hole.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: v1 was a udf_free_blocks() defense; v2 moved the check to the common parser so all consumers are covered. Only v2 was merged. udf_free_blocks() in this tree still has no partition-index check, so this parser check is the defense for that OOB.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: Web search of lore.kernel.org/stable for this subject did not find a dedicated stable discussion. Absence of stable-list traffic is not a negative signal here.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: udf_current_aext()
**Step 5.2: TRACE CALLERS**
Record (verified with grep):
- udf_next_aext() — ret = udf_current_aext(...); if (ret <= 0) return ret;
- udf_truncate_extents() / tail of truncate loop — while ((ret = udf_current_aext(...)) > 0), then if (ret < 0) return ret
- __udf_add_aext setup in inode.c:2053 — if (err <= 0) goto err_out
udf_next_aext() is used from inode_bmap(), extent_trunc callers, directory.c, balloc.c, super.c. Impact surface is **all UDF extent walks**.
**Step 5.3: TRACE CALLEES**
Record: udf_get_fileshortad / udf_get_filelongad, lelb_to_cpu, UDF_SB(). No new locks or allocations.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace-reachable after a UDF mount: ftruncate / file delete / write that frees extents. inode_bmap() is also on read, but udf_get_pblock() already rejects a bad partition. The OOB is truncate/free. Mount often needs CAP_SYS_ADMIN; desktop udisks can still allow unprivileged mounts of removable UDF (documented on the sibling truncate OOB).
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same check already in udf_read_inode() and udf_get_pblock(). udf_free_blocks(), udf_prealloc_blocks(), and udf_new_block() still index s_partmaps[partition] without that check. Fixing the decoder covers those consumers.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.**
- git describe HEAD → v7.3-rc4-27-gf0100363d8c37
- make kernelversion → 7.3.0-rc4
- Long-AD decode and udf_free_blocks() OOB index are in this checkout
- Bug introduced ~v2.6.23, long before this branch
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** on this tree. udf_current_aext() already returns int / -errno. Context around the switch matches the hunk. git merge-base --is-ancestor ee703a7068f95 HEAD is true.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: 5f0419457f89d is here (partition *length* on free, not partition *index*). 1d82a56bc5bf8 only covers inode location. Nothing else closes this hole except this check.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: fs/udf/ — **IMPORTANT** (real filesystem, not core VFS; not staging). Data-path OOB on mountable media.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained by Jan Kara; recent 7.3 UDF work includes integrity, leaks, deadlock, and other OOB/corruption checks. Mature code with ongoing fuzz/LLM-found hardening.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Filesystem-specific / config-specific** (CONFIG_UDF_FS). Anyone who mounts UDF (optical, ISO, some USB). Not universal.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Crafted/corrupted image with long ADs and `partitionReferenceNum
Quoted 1 line
= s_partitions`, then truncate/free. Not every boot. Reachable from
ftruncate after mount. Unprivileged trigger if the image can be mounted without CAP_SYS_ADMIN (udisks/removable media).
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Slab out-of-bounds read in udf_free_blocks() → KASAN/oops/panic. **HIGH** (crash / local availability; not shown to be a write primitive). Sibling UDF truncate OOB was described as a local availability panic.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** High for UDF users — stops a kernel OOB on corrupted media
- **Risk:** Very low — 7 lines, existing error API, maintainer-applied
- **Ratio:** Strongly favors applying the fix on this tree
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real slab OOB in udf_free_blocks() when a long AD carries a bad partition index
- That index path is still unchecked in this tree
- Truncate/free is a normal file operation after mount
- 7-line decoder check; same pattern as existing UDF partition checks
- Maintainer applied it (after fixing the mailed unused/sbi mistake)
- Callers already propagate -errno
- Prerequisite error-return refactor is in this tree
- Bug is old (long ADs since ~2.6.23)
AGAINST:
- No Reported-by / syzbot for this exact hole
- LLM-assisted; mailed v2 did not compile until Jan edited it
- UDF is not a default desktop root filesystem
- No Cc: stable (not a negative under these rules)
UNRESOLVED:
- Could not fetch lore.kernel.org HTML (HTTP 403); thread recovered via b4 dig -m
- No dedicated stable-list thread found
- No in-tree reproducer; mechanism is verified from code, not from a crash log in the commit
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — bounds check matches existing UDF checks; maintainer applied the compile-fixed version
2. Fixes a real bug that affects users? **PASS** — OOB on crafted/corrupted UDF truncate/free
3. Important issue? **PASS** — slab OOB / crash, HIGH
4. Small and contained? **PASS** — +7 lines, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — udf_current_aext() and -errno callers exist here
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not an ID/quirk/DT/docs exception. It is a normal memory-safety filesystem fix.
**Step 9.4: MAKE YOUR DECISION**
This tree’s UDF decoder still hands untrusted long-AD partition references to udf_free_blocks(), which indexes s_partmaps[] with no partition bound. The check is small, already matches local error handling, and was accepted by the UDF maintainer. It should be in this tree.
------------------------------------------------
What the commit solves and why it matters here
------------------------------------------------
Long allocation descriptors store partitionReferenceNum on disk. udf_current_aext() used to copy that into eloc and return success. Truncate then calls extent_trunc() → udf_free_blocks(), which does s_partmaps[partition] with no s_partitions check. A crafted UDF image can produce a slab OOB read and a kernel oops. Validating the reference in the common parser rejects that extent once for every consumer.
------------------------------------------------
Stable rules / risk vs benefit
------------------------------------------------
The change is obviously correct, tiny, and does not add APIs. Benefit is preventing a UDF crash on corrupted media; risk is a rejected extent returning -EFSCORRUPTED on a path that already handles -errno. No missing prerequisites in this checkout.
------------------------------------------------
Concerns
------------------------------------------------
The mailed v2 was broken (sbi in the wrong function); the committed diff is the maintainer-corrected version, which is what this evaluation uses. Older kernels without ee703a7068f95 would need extra caller work; **this tree already has that refactor**, so it is not a blocker here.
===============================================================
Verification
===============================================================
- [Phase 1] Parsed tags: Assisted-by Codex, SOB Kyle Zeng, Link patch.msgid.link, SOB Jan Kara; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: +7 in udf_current_aext(); udf_free_blocks() still does s_partmaps[partition] with no index check (fs/udf/balloc.c:668-669); extent_trunc() calls udf_free_blocks() (fs/udf/truncate.c:37-54, 271)
- [Phase 3] git blame: long-AD copy 28de7948a89676 (v2.6.23-rc1); check is 120ec50984b86; error API ee703a7068f95 (v6.12-rc2)
- [Phase 3] No Fixes: tag; git merge-base --is-ancestor ee703a7068f95 HEAD true; 1d82a56bc5bf8 and 5f0419457f89d are ancestors and do not close this hole
- [Phase 4] b4 dig -c 120ec50984b86: lore URL found; -a: v2 only; -w: Jan Kara CC’d; -m: LKP unused/sbi errors; Jan: applied after deleting spurious sbi
- [Phase 4] lore.kernel.org WebFetch returned 403; bodies taken from mbox + openwall/LKML mirrors
- [Phase 4] Stable lore search: no dedicated discussion found
- [Phase 5] Callers: udf_next_aext, truncate loop, inode.c:2053; inode_bmap propagates err <= 0
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4; buggy decode and OOB index present
- [Phase 7] MAINTAINERS: UDF → Jan Kara; fs/udf/ actively patched in 7.3
- [Phase 8] Failure mode: slab OOB read on truncate/free of crafted long AD — HIGH
- UNVERIFIED: live KASAN reproducer for this exact image; unprivileged- mount path for *this* hole (documented only for the sibling truncate OOB)
**YES**
fs/udf/inode.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/udf/inode.c +7 -0
@@ -2312,6 +2312,13 @@ int udf_current_aext(struct inode *inode, struct extent_position *epos,return -EINVAL ; } +if (eloc->partitionReferenceNum >=UDF_SB (inode->i_sb)->s_partitions) { +udf_debug ("invalid partition reference %u (partitions %u)\n" , + eloc->partitionReferenceNum, +UDF_SB (inode->i_sb)->s_partitions); +return -EFSCORRUPTED ; + } +return 1 ; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ksmbd: handle empty QUERY_ALLOCATED_RANGES output
In reply to Sasha LevinFrom: Namjae Jeon <[email protected]>
[ Upstream commit 7f07791522a251e2be087d11ae9cd51eb3408f1d ]
FSCTL_QUERY_ALLOCATED_RANGES can be issued with a valid input buffer but without room for an output range. Do not reject the request before looking at the file layout. If the query would produce a range, return STATUS_BUFFER_TOO_SMALL. If it produces no ranges, return success with an empty output.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). The buggy in_count == 0 path is present here; the upstream fix is not. This is a small, spec- driven ksmbd protocol fix that applies cleanly.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[ksmbd] [handle] empty QUERY_ALLOCATED_RANGES output** — “handle” here means correct SMB2 status/output when the client supplies a valid input buffer but no room for an output range.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record: Tags on upstream 7f07791522a251e2be087d11ae9cd51eb3408f1d:
- Signed-off-by: Namjae Jeon <[email protected]> (ksmbd maintainer; also committer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, Link:, or Cc: stable
- The candidate copy’s [Upstream commit …] and Signed-off-by: Sasha Levin were ignored as pipeline markers
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** FSCTL_QUERY_ALLOCATED_RANGES is rejected when the output buffer cannot hold one FILE_ALLOCATED_RANGE_BUFFER (16 bytes), before the file layout is inspected.
- **Symptom:** Client gets a hard STATUS_INVALID_PARAMETER instead of STATUS_BUFFER_TOO_SMALL (ranges exist) or success with empty output (no ranges).
- **Root cause:** Early if (in_count == 0) return -EINVAL in fsctl_query_allocated_ranges().
- **No version range** in the message. Function dates to 2021 (e2f34481b24db2).
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is an explicit protocol-correctness
fix: wrong NTSTATUS for a documented FSCTL.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: fs/smb/server/smb2pdu.c — **+12 / −4** (16 lines)
- Function: fsctl_query_allocated_ranges() only
- Scope: **single-file surgical fix**
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** in_count == 0 (i.e. out_buf_len < sizeof(struct file_allocated_range_buffer)) returns -EINVAL immediately, mapped in smb2_ioctl() to STATUS_INVALID_PARAMETER. File is never looked at.
- **After:** Validate offset/length and look up the file. If in_count == 0, probe with a **stack** dummy range and in_count=1. If that probe fills a range, return -ENOSPC (STATUS_BUFFER_TOO_SMALL at line 8701–8702). If it fills nothing, return 0 with *out_count = 0. Non-zero in_count is unchanged.
- Path: normal FSCTL handling, not an init/error-only cleanup.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Logic / protocol correctness**, matching [MS-FSA] FSCTL_QUERY_ALLOCATED_RANGES:
- OutputBufferSize < sizeof(FILE_ALLOCATED_RANGE_BUFFER) **MUST** fail with STATUS_BUFFER_TOO_SMALL
- No allocated ranges → STATUS_SUCCESS, BytesReturned = 0
- Input Length == 0 → success with empty output
Using a stack dummy is required: calling ksmbd_vfs_fqar_lseek() with qar_rsp and in_count=1 when the real output buffer is shorter than 16 bytes would write past the ioctl response buffer.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct against MS-FSA and the existing -ENOSPC → STATUS_BUFFER_TOO_SMALL mapping. Minimal. Regression risk is low: fd get/put stay balanced; dummy is on-stack; *out_count is forced to 0 on the empty-output path. Slight error-code change for “bad fid **and** tiny output buffer” (-EINVAL → -ENOENT) is more correct.
Verified git apply --check on this tree: **hunks apply cleanly** (offset −891 lines only).
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record: The if (in_count == 0) return -EINVAL lines were introduced in **e2f34481b24db2** (“cifsd: add server-side procedures for SMB3”, 2021-05-10). Present for the entire ksmbd lifetime in this tree.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Introducing commit **is** an ancestor of HEAD (git merge-base --is-ancestor e2f34481b24db2 HEAD succeeded).
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Related later mainline work (not in this tree):
- 350684e049851 — dense-file SEEK_DATA handling (vfs.c)
- 25e414db70333 — holes / -E2BIG overflow (vfs.c + smb2pdu.c, larger)
- 3c707d4b3f926 — READ_DATA permission on this FSCTL
Those are **independent** bugs. This patch only changes the zero-output- buffer gate and does not need them.
Recent 6.12 ksmbd work on the same file includes other buffer-size protocol fixes already in this tree (fix partial file information responses, return buffer overflow for partial filesystem info, fix partial normalized name responses). Same class of bug.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Namjae Jeon is listed in MAINTAINERS as **KERNEL SMB3 SERVER (KSMBD)** maintainer. This landed in his 7.3-rc1 ksmbd pull (protocol- compat / smbtorture).
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Standalone. Calls existing ksmbd_vfs_fqar_lseek(). In this tree that helper still has if (!in_count) return 0, which is why the probe must pass in_count=1. No new helpers or struct fields. **Applies standalone.**
git merge-base --is-ancestor 7f07791522a251e2be087d11ae9cd51eb3408f1d HEAD → not in this tree.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 7f07791522a251e2be087d11ae9cd51eb3408f1d failed:
lore.kernel.org returned an error
- WebFetch of lore search URLs returned **403**
- **UNVERIFIED:** v1/v2 revisions, NAKs, reviewer-requested Cc: stable
- Verified via LKML: commit is in **[GIT PULL] ksmbd server update for 7.3-rc1** (Namjae Jeon, 2026-08-23), grouped with protocol- compatibility fixes “validated with smbtorture” and “allocated-range queries”
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: **UNVERIFIED** (b4 -w failed with lore). Commit is authored **and** committed by the ksmbd maintainer.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla tag. Behavior is specified in [MS-FSA] 2.1.5.10.22: too-small output **MUST** be STATUS_BUFFER_TOO_SMALL; empty result is success. Samba/Windows discussions distinguish that status from STATUS_BUFFER_OVERFLOW (partial fill) and from STATUS_INVALID_PARAMETER (hard fail).
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Sequential maintainer commits around 2026-07-09; next ones change vfs.c for dense files/holes. Not a numbered N/M series. This hunk is self-contained.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** (lore 403). Absence of Cc: stable is expected for this pipeline.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
Record: fsctl_query_allocated_ranges(); helper ksmbd_vfs_fqar_lseek(); dispatcher smb2_ioctl().
**Step 5.2: TRACE CALLERS**
Record:
- Sole caller: smb2_ioctl() case FSCTL_QUERY_ALLOCATED_RANGES (fs/smb/server/smb2pdu.c)
- smb2_ioctl is SMB2_IOCTL_HE in fs/smb/server/smb2ops.c
- Reachable from authenticated SMB2 clients over the network (not interrupt context)
**Step 5.3: TRACE CALLEES**
Record: ksmbd_lookup_fd_fast / ksmbd_fd_put; ksmbd_vfs_fqar_lseek → vfs_llseek(SEEK_DATA/SEEK_HOLE). Probe uses a stack buffer, not the response buffer.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace/network client → SMB2 IOCTL → FSCTL_QUERY_ALLOCATED_RANGES. **Yes, user-triggerable.** in_count == 0 when smb2_calc_max_out_buf_len() yields out_buf_len < 16 (MaxOutputResponse 0..15). Linux CIFS often asks for ≥16 bytes (smb2ops.c); Windows/smbtorture can send a smaller max output. That is a real client pattern for this FSCTL.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same file already special-cases -E2BIG → STATUS_BUFFER_OVERFLOW and -ENOSPC → STATUS_BUFFER_TOO_SMALL. This patch is the missing in_count==0 case of that protocol. Other ksmbd “too-small output buffer” fixes are already in this 6.12 tree.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** fs/smb/server/smb2pdu.c lines 8196–8198:
```8196:8211:fs/smb/server/smb2pdu.c
*out_count = 0;
if (in_count == 0)
return -EINVAL;
...
ret = ksmbd_vfs_fqar_lseek(fp, start, length,
qar_rsp, in_count, out_count);
```Local version: **6.12.111**. Bug introduced **v5.15-era ksmbd (2021)**.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** (git apply --check succeeded). Surrounding function matches the upstream pre-image besides line numbers.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No other commit in this tree greps to this subject/behavior. Dense-file / holes / extra permission commits are **not** ancestors of HEAD. Not required for this gate-fix.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM**
Record: **ksmbd** (fs/smb/server/). **IMPORTANT** (in-kernel SMB3
server: NAS, OpenWrt, appliances). Not core mm/VFS for all boots; network-facing for every ksmbd user. CONFIG_SMB_SERVER default n.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained; many ksmbd protocol fixes already on this branch.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Record: **Driver/config-specific:** ksmbd (CONFIG_SMB_SERVER) serving FSCTL_QUERY_ALLOCATED_RANGES (sparse-file tools, backup, smbtorture, some Windows APIs).
**Step 8.2: TRIGGER CONDITIONS**
Record: Valid QUERY_ALLOCATED_RANGES input **and** MaxOutputResponse < 16. Not every IOCTL; not unprivileged local syscalls except via an SMB session. Timing-independent.
**Step 8.3: FAILURE MODE SEVERITY**
Record: Wrong NTSTATUS → client treats a sizing/empty query as a **hard parameter error** instead of retry (BUFFER_TOO_SMALL) or empty success. Can fail sparse-file / backup / torture paths. **MEDIUM** (functional interoperability, not oops/UAF/corruption).
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit:** Medium — restores documented SMB status for a long- standing ksmbd FSCTL; clients can retry or accept empty results.
- **Risk:** Very low — 16 lines, existing error mapping, stack dummy, clean apply, no API/locking change.
- **Ratio:** Favorable.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real MS-FSA MUST violation: tiny output buffer returns STATUS_INVALID_PARAMETER instead of STATUS_BUFFER_TOO_SMALL / empty success
- User-visible: SMB clients abort instead of retrying or treating the file as having no ranges
- Present in this 6.12 tree since ksmbd was added
- 16-line surgical change; applies cleanly; no prerequisites
- Maintainer-authored; in 7.3 ksmbd pull as smbtorture protocol-compat
- Dummy buffer avoids a would-be response-buffer overflow
- Same class as buffer-size ksmbd fixes already on this branch
**AGAINST:**
- Not a crash, UAF, security hole, deadlock, or data corruption
- No syzbot/CVE/Reported-by
- Trigger is a small MaxOutputResponse, not the Linux CIFS client’s usual 16+-byte buffer
- Sibling dense-file/holes fixes remain separate (they do not block this one)
**UNRESOLVED:** lore/b4 review thread (403/server error); no explicit stable mailing-list discussion.
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — matches MS-FSA; maintainer commit; smbtorture-oriented 7.3 pull. Direct lore Tested-by unverified.
2. Fixes a real bug that affects users? **PASS** — wrong NTSTATUS on a reachable FSCTL.
3. Important issue? **PASS** (MEDIUM-HIGH for a network file server) — hard client failure vs retryable/empty result; not a panic.
4. Small and contained? **PASS** — one function, +12/−4.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — buggy code present; git apply --check clean.
**Step 9.3: EXCEPTION CATEGORIES**
Record: None (not a device ID / quirk / DT / build / docs patch). Qualifies as a normal contained bugfix.
**Step 9.4: DECISION**
Backport to **this** 6.12 tree. The bug exists here, the fix is standalone and low-risk, and returning the wrong SMB status on QUERY_ALLOCATED_RANGES is a real interoperability failure for ksmbd users.
---
### What the commit solves for stable users
On 6.12 ksmbd, a legal FSCTL_QUERY_ALLOCATED_RANGES with MaxOutputResponse smaller than one range is failed as STATUS_INVALID_PARAMETER before the file is examined. Windows/smbtorture expect STATUS_BUFFER_TOO_SMALL if ranges exist, or success with zero output if they do not. That mismatch can abort sparse- file queries instead of allowing a retry.
### Stable rules / risk
The change is obviously correct, small, and already wired to this tree’s -ENOSPC mapping. It does not need the later dense-file or holes vfs work. Risk is a slightly different (more accurate) status on a rare combined bad-fid + tiny-buffer case.
### Verification
- **[Phase 1]** Parsed upstream 7f07791522a251e2be087d11ae9cd51eb3408f1d: maintainer SOB only; no Fixes/Reported-by/Cc stable
- **[Phase 2]** Diff: +12/−4 in fsctl_query_allocated_ranges(); dummy stack probe; -ENOSPC when probe fills a range
- **[Phase 2]** Confirmed smb2_ioctl() maps -ENOSPC → STATUS_BUFFER_TOO_SMALL (lines 8701–8702)
- **[Phase 3]** git blame: in_count == 0 from e2f34481b24db2 (2021); ancestor of HEAD
- **[Phase 3]** git merge-base --is-ancestor 7f077915… HEAD → not in this tree
- **[Phase 3]** git apply --check of the upstream diff → clean (offset −891)
- **[Phase 3]** Sibling dense/holes/perms commits exist as objects, **not** ancestors of HEAD; vfs probe still works with 6.12 ksmbd_vfs_fqar_lseek
- **[Phase 4]** b4 dig lore error; lore WebFetch 403; LKML 7.3-rc1 ksmbd pull lists this subject
- **[Phase 4]** MS-FSA: too-small output MUST be STATUS_BUFFER_TOO_SMALL
- **[Phase 5]** Only caller is smb2_ioctl FSCTL_QUERY_ALLOCATED_RANGES; dispatched as SMB2_IOCTL_HE
- **[Phase 6]** git describe HEAD → p-6.12-3-gc504cf0baa3d8; make kernelversion → 6.12.111; buggy early -EINVAL still present
- **[Phase 7]** MAINTAINERS: Namjae Jeon is ksmbd maintainer
- **[Phase 8]** Failure mode: wrong NTSTATUS / client abort, not oops
- **UNVERIFIED:** lore reviewer comments, Tested-by, explicit stable nomination
**YES**
fs/smb/server/smb2pdu.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
fs/smb/server/smb2pdu.c +12 -4
@@ -8302,8 +8302,6 @@ static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id,int ret =0 ; *out_count =0 ; -if (in_count ==0 ) -return -EINVAL ; start =le64_to_cpu (qar_req->file_offset); length =le64_to_cpu (qar_req->length);
@@ -8315,8 +8313,18 @@ static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id,if (!fp)return -ENOENT ; - ret =ksmbd_vfs_fqar_lseek (fp, start, length, - qar_rsp, in_count, out_count); +if (!in_count) { +struct file_allocated_range_buffer range; + + ret =ksmbd_vfs_fqar_lseek (fp, start, length, &range,1 , + out_count); +if (!ret && *out_count) + ret = -ENOSPC ; + *out_count =0 ; + }else { + ret =ksmbd_vfs_fqar_lseek (fp, start, length, + qar_rsp, in_count, out_count); + }if (ret && ret != -E2BIG ) *out_count =0 ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 btrfs: fix memory barrier order in reloc_root_is_dead()
In reply to Sasha LevinFrom: Filipe Manana <[email protected]>
[ Upstream commit 6f1c97695a6e230ee15c9e052e1933bdccfd5fa3 ]
When we set a root's reloc_root to NULL, we do it like this:
static void clear_reloc_root(struct btrfs_root *root)
{
root->reloc_root = NULL;
/*
* Need barrier to ensure clear_bit() only happens after
* root->reloc_root = NULL. Pairs with have_reloc_root().
*/
smp_wmb();
clear_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state);
}So that a NULL reloc_root is always seen before seeing that the bit BTRFS_ROOT_DEAD_RELOC_TREE was cleared.
But on the read side we have:
static bool reloc_root_is_dead(const struct btrfs_root *root)
{
smp_rmb();
if (test_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state))
return true;
return false;
}And then callers of reloc_root_is_dead() access root->reloc_root.
Because the read memory barrier is placed before testing the bit, the CPU is completely free to speculatively reorder those two loads. It can read root->reloc_root before it actually checks the dead tree bit.
Sashiko reported this as an existing problem in another patch review, see the link in the Link tag below.
Fix this by moving the read memory barrier to happen after testing the bit and update the comment to reflect current reality.
---
LLM Generated explanations, may be completely bogus:
This tree is **Linux 6.18.53** (pending-6.18). The candidate is mainline 6f1c97695a6e2 (v7.3-rc1) and is **not** in this checkout. The misplaced smp_rmb() in reloc_root_is_dead() is still present, and the write-side half of the same series is already here.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [btrfs] [fix] — correct read-side memory-barrier order in reloc_root_is_dead() so the BTRFS_ROOT_DEAD_RELOC_TREE bit is observed before callers load root->reloc_root.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Link:** https://sashiko.dev/#/patchset/cf84f1a217c719e25b6b69e4298dd
7afd36c9427.1781194426.git.fdmanana%40suse.com (Sashiko review of a related UAF patch, where this read-side bug was flagged)
- **Reviewed-by:** Boris Burkov <[email protected]>
- **Signed-off-by:** Filipe Manana <[email protected]> (author), David Sterba <[email protected]> (btrfs maintainer)
- No **Fixes:**, **Reported-by:**, **Tested-by:**, **Cc: stable**, **Acked-by:**
- Ignore pipeline SOBs. Absence of Fixes/Cc-stable is expected.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** Writer does root->reloc_root = NULL; smp_wmb(); clear_bit(DEAD). Reader did smp_rmb(); test_bit(DEAD) and then callers loaded root->reloc_root.
- **Mechanism:** An smp_rmb() *before* the bit load does not order that load against the later reloc_root load. CPU/compiler may load reloc_root first.
- **Symptom:** Stale non-NULL reloc_root after the writer has NULLed it and cleared the dead bit, then btrfs_drop_snapshot() — use-after- free.
- **Root cause:** Classic MP (message-passing) pairing error:
smp_rmb() must sit *between* the two loads, not before both.
- **Version info:** Buggy helper dates to 6282675e6708ec (v5.5-rc7, 2020).
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Explicit barrier/UAF-class correctness fix, found by Sashiko on a related reloc-root series.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** fs/btrfs/relocation.c (+6 / −5)
- **Function:** reloc_root_is_dead()
- **Scope:** Single-function, surgical
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** smp_rmb(); if (test_bit(DEAD)) return true; return false;
- **After:** if (test_bit(DEAD)) return true; smp_rmb(); return false;
- **Affected path:** Any caller that, on a false result, then reads root->reloc_root (have_reloc_root(), btrfs_init_reloc_root(), btrfs_should_ignore_reloc_root()).
- Early return when the bit is set skips the rmb; those callers do not load reloc_root. That is correct.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** Synchronization / race (memory-barrier pairing); failure mode is UAF
- **Mechanism:** Writer: store reloc_root=NULL, smp_wmb(), clear_bit(DEAD). Required reader: load DEAD, smp_rmb(), load reloc_root. Current reader puts smp_rmb() *before* the bit load, so it does not pair. Compiler can hoist root->reloc_root above test_bit() after inlining (x86 included); weak memory models can also reorder the loads in hardware.
Verified against LKMM recipes (tools/memory- model/Documentation/recipes.txt, MP + smp_wmb/smp_rmb): the read barrier is between the two loads.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Minimal and matches documented pairing. No API/data-structure change. Regression risk is low: if the bit is set we return without rmb (callers do not touch reloc_root); if clear, rmb orders the subsequent load. David Sterba initially doubted the move; Filipe explained the pairing; David still merged with SOB.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Buggy smp_rmb() + test_bit(): 6282675e6708ec (“btrfs:
relocation: fix reloc_root lifespan and access”), Qu Wenruo, 2020-01-08, first in **v5.5-rc7**. That commit itself was CC: stable # 5.4+ to fix KASAN UAFs on balance+snapshot.
- Write-side clear_reloc_root(): fda1b6636ff184 in this tree (Upstream 83201804efa4a).
- Original commit text even said “the pairing read side is before test_bit” — that comment is what this patch corrects.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Introducer is 6282675e6708ec, present in this tree (git merge-base --is-ancestor exit 0). Independently identified in 2021 by Baptiste Lepers ([PATCH] btrfs: relocation: fix misplaced barrier in reloc_root_is_dead, 2021-05-26) with Fixes: 6282675e6708e; that patch was never merged.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Same-day 2-patch series [PATCH 0/2] btrfs: fix incorrect barrier usage in relocation:
- **1/2** b78fe9563e2d5 / this tree 63d6b1f04cd91 — write-side clear_reloc_root() in merge_reloc_roots(). **Already in this tree.**
- **2/2** this commit — read-side rmb. **Not in this tree.**
Prerequisite UAF helper clear_reloc_root (fda1b6636ff184) is also already here. No later mainline rewrite of reloc_root_is_dead() after 6f1c97695a6e2.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Filipe Manana is a core btrfs author (many reloc-root UAF/leak fixes). David Sterba (listed btrfs maintainer) signed off. Boris Burkov reviewed the series.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: This hunk only reorders smp_rmb() vs test_bit() in reloc_root_is_dead(). It does not call clear_reloc_root(). Standalone. git show 6f1c97695a6e2 | git apply --check succeeded (hunk offset −94 lines only).
The kbuild error on the series was clear_reloc_root undeclared when **1/2** was applied without the UAF series; that does not apply to **this** patch, and this 6.18.53 tree already has both the helper and 1/2.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **Lore/thread:** cover [email protected]; 2/2 msgid 62602395bf1488aa81645ea59e22405d6c06d3f7.1781263239.git.fdmanan [email protected]
- **Series:** v1 only (2026-06-12), two patches
- **b4 dig -c 6f1c97695a6e2** initially matched the related UAF v5 thread (same Link/Sashiko URL / similar patch-id). Direct msgid fetch recovered the real 0/2 series (9 messages).
- **Reviewer feedback:**
- Boris Burkov: Reviewed-by on the cover (both patches)
- David Sterba (2026-06-18): argued rmb-before-test_bit was intentional “to have up-to-date value”; said post-test rmb “is wrong, or at least not entirely correct”; suggested dropping barriers
- Filipe: pairing is load-bit / rmb / load-reloc_root against store- NULL / wmb / clear-bit; dropping barriers would regress the 2020 KASAN races
- David still merged (SOB on the commit)
- **kbuild:** false positive (1/2 vs missing helper on for-next vs Linus)
- **Stable nomination in thread:** none
- **NAKs:** no NAK; maintainer doubt was answered and the patch landed
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: To/Cc [email protected]. Boris reviewed. David (M:
in MAINTAINERS) engaged and merged.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot for this exact rmb placement. Sashiko flagged it while reviewing the insert_dirty_subvol UAF series. Original 2020 KASAN reports (Zygo Blaxell) are why the barriers exist. 2021 Baptiste patch:
same diagnosis; appears unreplied (odd To:), never applied.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Companion 1/2 already AUTOSEL’d and present in this 6.18 tree. This 2/2 is the unfinished read-side half. UAF series that introduced clear_reloc_root is also already here.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: Openwall/AUTOSEL traffic is for 1/2 and the UAF helper, not this subject. No stable-list rejection of 2/2 was found. lore.kernel.org search URLs returned 403; discussion was recovered via b4 mbox instead.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: reloc_root_is_dead() only.
**Step 5.2: TRACE CALLERS**
Record (this tree, fs/btrfs/):
- have_reloc_root() → btrfs_update_reloc_root(), btrfs_reloc_pre_snapshot(), btrfs_reloc_post_snapshot()
- btrfs_init_reloc_root() (direct) ← fs/btrfs/transaction.c when a shareable root is recorded in a transaction
- btrfs_should_ignore_reloc_root() ← fs/btrfs/backref.c during reloc backref walk
Contexts: relocation/balance, snapshot creation during balance, transaction join for subvolumes. Not interrupt. Reachable from BTRFS_IOC_BALANCE / snapshot ioctls.
**Step 5.3: TRACE CALLEES**
Record: test_bit(), smp_rmb(). Callers then read root->reloc_root and may dereference commit_root.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Writer clean_dirty_subvols() / clear_reloc_root(): save pointer, NULL reloc_root, wmb, clear DEAD, btrfs_drop_snapshot(). Concurrent reader: new transaction / snapshot / backref walk calling reloc_root_is_dead() then loading reloc_root. Original 2020 analysis called this the C–D window after btrfs_commit_transaction(). Userspace-reachable on btrfs balance+snapshot. Unprivileged users typically cannot ioctl-balance; a hit still crashes/corrals the filesystem.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same class of misplaced rmb in btrfs_record_root_in_trans (2021 Baptiste, later 2026 “btrfs: fix root-in-trans fast-path ordering”). Write-side pairing in this file is already correct (clear_reloc_root, btrfs_update_reloc_root set_bit+wmb).
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** fs/btrfs/relocation.c lines 246–257:
```246:257:fs/btrfs/relocation.c
static bool reloc_root_is_dead(const struct btrfs_root *root)
{
/*
- Pair with set_bit/clear_bit in clean_dirty_subvols and
- btrfs_update_reloc_root. We need to see the updated bit before
- trying to access reloc_root
*/
smp_rmb();
if (test_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state))
return true;
return false;
}
```Introduced v5.5; still wrong here. Write side already uses smp_wmb() in clear_reloc_root() (1460–1468). git merge-base --is-ancestor 6f1c97695a6e2 HEAD → not an ancestor.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** (git apply --check succeeded, offset only). No helper dependency. Surrounding have_reloc_root() / callers match mainline.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: 1/2 and clear_reloc_root UAF fix are here. This read-side reorder is not. No substitute fix.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **fs/btrfs** — **IMPORTANT** (filesystem integrity; reloc UAF can oops or corrupt during balance).
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Active. Multiple 2026 reloc-root UAF/leak/barrier fixes already landed in this 6.18.y tree.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Btrfs users who run balance/relocation, especially concurrent with snapshots/subvolume updates. Not universal, but a standard admin path.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Overlap of clear_reloc_root()/clean_dirty_subvols() with a reader of have_reloc_root() / btrfs_init_reloc_root() / btrfs_should_ignore_reloc_root(). Timing-dependent; same shape as the 2020 KASAN balance+snapshot reports. Typically privileged ioctls; impact is whole-fs.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Stale reloc_root used after btrfs_drop_snapshot() → **UAF / oops**, possible further refcount damage. **Severity: HIGH.**
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit: HIGH** — completes barrier pairing; write side already backported here, so this tree currently has an unpaired wmb.
- **Risk: LOW** — 11 lines, one static helper, no locking/API change.
- **Ratio:** Strongly favorable.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real MP barrier bug; UAF if reloc_root is loaded before test_bit during dead-bit clear
- Buggy code verified in this 6.18.53 tree since v5.5
- Write-side companion already in this tree → read side is the missing half
- LKMM pairing is unambiguous (smp_rmb between the two loads)
- Small, applies cleanly, reviewed (Boris), merged by maintainer (David)
- Same race family as the 2020 KASAN reloc-root lifespan fix
- Sashiko + independent 2021 diagnosis
**AGAINST:**
- No dedicated syzbot/user crash for this rmb placement
- David initially disputed the move (later merged)
- Original 2020 text claimed a transaction as a higher-level barrier (barriers still added for the C–D window; this patch is that window)
- 2021 patch sat unmerged (likely overlooked, not NAK’d)
**UNRESOLVED:** Could not fetch lore.kernel.org HTML (403). Thread recovered via b4 mbox. No evidence this 2/2 was rejected for stable.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — matches LKMM MP pairing; reviewed; in mainline as of v7.3-rc1
2. Fixes a real bug that affects users? **PASS** — unpaired barrier on a path built to stop reloc-root UAF
3. Important issue (crash, security, corruption, deadlock)? **PASS** — HIGH, UAF/oops during balance
4. Small and contained? **PASS** — +6/−5, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — clean apply; prerequisites already present
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: N/A — ordinary correctness fix.
**Step 9.4: MAKE YOUR DECISION**
This 6.18.53 tree still has smp_rmb() before test_bit() in reloc_root_is_dead(), so the write-side smp_wmb() already present in clear_reloc_root() does not pair. Moving the rmb after the bit test is the standard, small fix for a UAF-class race on btrfs relocation. It should be backported here.
===============================================================
Verification
===============================================================
- **[Phase 1]** Parsed subject/tags/body from git show 6f1c97695a6e2 on origin/master
- **[Phase 2]** Diff is +6/−5 in reloc_root_is_dead() only; compared to current fs/btrfs/relocation.c:246-257
- **[Phase 2]** Confirmed write side clear_reloc_root() at 1460–1468:
NULL → smp_wmb() → clear_bit
- **[Phase 2]** LKMM recipes.txt MP example: load y, smp_rmb(), load x
- **[Phase 3]** git blame -L 246,257: 6282675e6708ec (v5.5-rc7); git describe --contains 6282675e6708ec → v5.5-rc7~22^2~2
- **[Phase 3]** git merge-base --is-ancestor 6282675e6708ec HEAD → yes; 6f1c97695a6e2 → no
- **[Phase 3]** git merge-base --is-ancestor 63d6b1f04cd91 HEAD → 1/2 present; fda1b6636ff18 → clear_reloc_root present
- **[Phase 3]** git show 6f1c97695a6e2 | git apply --check → hunk succeeded at offset −94
- **[Phase 3]** git describe --contains 6f1c97695a6e2 → v7.3-rc1~117^2~66
- **[Phase 4]** b4 mbox of msgid 50682caa6bbf… → cover + 1/2 + 2/2 + Boris Reviewed-by + David concern + Filipe reply + kbuild false positive
- **[Phase 4]** 2021 Baptiste patch verified via openwall/lkml.iu (never in git log origin/master --author='Baptiste Lepers' -- fs/btrfs)
- **[Phase 4]** lore.kernel.org WebFetch 403; used b4 instead
- **[Phase 5]** git grep callers: have_reloc_root, btrfs_init_reloc_root, btrfs_should_ignore_reloc_root → transaction.c, relocation.c, backref.c
- **[Phase 6]** git describe HEAD / make kernelversion → p-6.18-1-g03b85e06ca9bf, **6.18.53**
- **[Phase 6]** git grep -A20 reloc_root_is_dead origin/master → mainline already has test_bit then rmb
- **[Phase 7]** MAINTAINERS: David Sterba is btrfs maintainer; he SOB’d the commit
- **[Phase 8]** Failure mode from original 6282675e6708ec KASAN stacks (balance+snapshot) plus C–D window vs drop_snapshot after clear_bit
- **UNVERIFIED:** Direct sashiko.dev review text (JS page had no static content); inferred from Link tag + cover letter + Filipe changelog
The patch is a small, obviously correct pairing fix for a reloc-root UAF race, the buggy code is in this 6.18.53 tree, and the write-side half is already here.
**YES**
fs/btrfs/relocation.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
fs/btrfs/relocation.c +6 -5
@@ -245,14 +245,15 @@ static struct btrfs_backref_node *walk_down_backref(static bool reloc_root_is_dead (const struct btrfs_root *root) { +if (test_bit (BTRFS_ROOT_DEAD_RELOC_TREE , &root->state)) +return true;/* -* Pair with set_bit/clear_bit in clean_dirty_subvols and -* btrfs_update_reloc_root. We need to see the updated bit before -* trying to access reloc_root +* Pairs with set_bit/clear_bit in clear_reloc_root() and +* btrfs_update_reloc_root(). We need to see the updated bit before +* trying to access root->reloc_root in our callers. */ smp_rmb (); -if (test_bit (BTRFS_ROOT_DEAD_RELOC_TREE , &root->state)) -return true; +return false; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 md: add cond_resched() to md_do_sync()'s skip path
In reply to Sasha LevinFrom: Yunye Zhao <[email protected]>
[ Upstream commit 162eb5ba791f6260fdaabae75fa2df20134f67d8 ]
When sync_request() reports a skipped region (*skipped == 1), md_do_sync()'s main loop advances the cursor and takes an early continue:
j += sectors; ... if (last_check + window > io_sectors || j == max_sectors) continue;
If the personality returns a small span per call (raid10 recovery returns only 128 sectors), syncing a large, mostly clean array iterates this branch an enormous number of times without ever yielding the CPU. On a non-preemptive kernel the resync thread then trips the soft-lockup watchdog:
watchdog: BUG: soft lockup - CPU#149 stuck for 313s! [mdX_resync] md_bitmap_start_sync+0x6f/0xe0 raid10_sync_request+0x2c9/0x1530 [raid10] md_do_sync+0x810/0x1030 md_thread+0xa7/0x150
Add a cond_resched(). This does not reduce the wasted iterations; the excessive iteration count is a raid10 problem addressed separately.
---
LLM Generated explanations, may be completely bogus:
The checked-out tree is **6.18.53** (pending-6.18). The skip path in md_do_sync() is present, has no yield, and matches this patch. That is a real soft-lockup fix.
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
- Record: [md] [add] add cond_resched() to md_do_sync()'s skip path
- Subsystem: MD RAID core. Verb “add” here is a yield on an existing loop, not a feature.
**Step 1.2 — Tags**
- Record:
- Signed-off-by: Yunye Zhao <[email protected]> (author)
- `Link: https://patch.msgid.link/20260723135535.101995-3-
[email protected]`
- Signed-off-by: Yu Kuai <[email protected]> (md maintainer; applied)
- No Fixes: / Reported-by: / Tested-by: in the committed text
- Original v2 submission **did** include Cc: [email protected]; Yu Kuai dropped it when applying (“Remove the cc stable as there is no fixtag”). That is process, not a technical NAK.
- Pipeline Signed-off-by: Sasha Levin / [Upstream commit …] ignored as instructed.
**Step 1.3 — Body**
- Record:
- **Bug:** when sync_request() returns *skipped == 1 with a small span (RAID10 recovery: 128 sectors), md_do_sync() takes continue and never reaches the existing cond_resched().
- **Symptom:** watchdog: BUG: soft lockup - CPU#149 stuck for 313s! [mdX_resync] with md_bitmap_start_sync → raid10_sync_request → md_do_sync → md_thread.
- **Trigger:** large, mostly-clean RAID10 recovery (author:
2^40-sector device → ~2^33 iterations).
- **Root cause of CPU burn:** RAID10 recovery discards the bitmap’s large clean span and returns 128; that is patch 3/3. This commit only yields.
- Author tested on 6.6.102 and mainline.
**Step 1.4 — Hidden bug fix?**
- Record: Not hidden. Explicit soft-lockup fix. Series cover letter calls it a “safety net, any personality/layout.”
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
- Record: drivers/md/md.c only; ~3 insertions / 1 deletion in md_do_sync(). Surgical, single-function.
**Step 2.2 — Flow**
- Record: **Before:** skip/early-continue path never yields. **After:** cond_resched() then continue. Normal I/O path still uses the later cond_resched() at the speed-limit check.
**Step 2.3 — Bug mechanism**
- Record: **Hang / soft-lockup** (non-preemptive). Skip path bypasses the yield that already exists later in the same loop.
Verified in this tree:
```9751:9753:drivers/md/md.c
if (last_check + window > io_sectors || j ==
max_sectors)
continue;
``````9779:9779:drivers/md/md.c
cond_resched();
```Skip continue never reaches line 9779. window is 32 * (PAGE_SIZE / 512) (256 sectors). If skipped, io_sectors does not increase, so last_check + window > io_sectors stays true.
RAID10 recovery still does max_sync = RESYNC_PAGES << (PAGE_SHIFT-9) (128 sectors). On a clean bitmap, biolist == NULL → giveup clamps to max_sync and, because max_sector is a parameter (not reset at skipped:), the call returns 128 to md_do_sync().
**Step 2.4 — Fix quality**
- Record: Obviously correct. Same primitive already used in this function. Process context (md_thread). No new API/locks. Regression risk very low. Might slightly slow tight skip loops; that is the goal.
## Phase 3: Git history
**Step 3.1 — Blame**
- Record: Skip continue dates to early MD (57afd89f98a99 / 2.6 era). Long-standing. RAID10 128-sector recovery cap is equally old (RESYNC_BLOCK_SIZE 64KiB).
**Step 3.2 — Fixes: tag**
- Record: None. Not a regression from a single later commit; interaction of skip-continue and RAID10 recovery skip size.
**Step 3.3 — Related commits**
- Record: Patch 2/3 of “md/raid10: fix recovery corruption and soft lockup on large arrays”.
- 1/3 md/raid10: fix still_degraded being inverted — **already in
this tree** (`0efabe6229dc6`). Independent.
- 3/3 md/raid10: skip clean regions in bulk — **not** in this tree. Independent; this yield still needed for far/offset layouts and other personalities.
- No cond_resched on this skip path in HEAD.
**Step 3.4 — Author**
- Record: Yunye Zhao (Alibaba). Applied by Yu Kuai (md maintainer).
**Step 3.5 — Dependencies**
- Record: Standalone. Uses existing cond_resched(). 6.18 md_do_sync() already has update:, MD_RESYNC_ACTIVE, and 4-arg sync_request() — same context as the patch. Clean apply.
## Phase 4: Mailing list
**Step 4.1 — Discussion**
- Record: https://lore.kernel.org/linux-
raid/[email protected]/ (also openwall mirrors).
- v1: single cond_resched patch. Yu Kuai initially thought it was a dead loop.
- v2: 3 patches; this one retitled; v1 “io_sectors never increases” claim corrected.
- Yu Kuai on v1 follow-up: “This patch is still valuable, even a 5s lockup is not acceptable.”
- Applied to md-7.3. No NAK on the yield itself.
**Step 4.2 — Recipients**
- Record: Song Liu, Yu Kuai; Cc Li Nan, Xiao Ni, linux-raid, linux- kernel.
**Step 4.3 — Bug report**
- Record: Author stack trace; 2^40-sector array; ~8.6e9 iterations; 313s. Cover letter: before patch 3, 37.2s 100% CPU on 8T-per-disk sparse recovery; softlockup_panic=1.
**Step 4.4 — Series**
- Record: 2/3 is the md-core safety net. Does not depend on 1/3 or 3/3.
**Step 4.5 — stable@**
- Record: No useful stable-list thread found (lore.kernel.org/stable 403). Maintainer dropped Cc: stable only for missing Fixes:.
## Phase 5: Semantics
**Step 5.1 — Functions**
- Record: md_do_sync().
**Step 5.2 — Callers**
- Record: Registered as the MD resync thread (md_register_thread(md_do_sync, …)). Kernel thread, not IRQ. Userspace triggers via array recovery/resync/check (mdadm).
**Step 5.3 — Callees**
- Record: pers->sync_request(), bitmap start/end, cond_resched(), speed-limit waits.
**Step 5.4 — Reachability**
- Record: Yes. Disk replace / rebuild / --syncaction on RAID10 with internal bitmap. Production path.
**Step 5.5 — Similar patterns**
- Record: Same file already yields on the I/O path. RAID1/5/10 use cond_resched() in other loops. Skip path was the hole.
## Phase 6: This tree (6.18.53)
**Step 6.1 — Buggy code present?**
- Record: **Yes.** drivers/md/md.c ~9752 skip continue with no yield. RAID10 giveup still advances by max_sync (128). git describe HEAD: p-6.18-1-g03b85e06ca9bf. make kernelversion:
6.18.53.
**Step 6.2 — Backport difficulty**
- Record: **Clean apply.** Local hunk matches the submitted diff (MD_RESYNC_ACTIVE, update:).
**Step 6.3 — Already fixed?**
- Record: No. 1/3 is in tree; 2/3 and 3/3 are not. Older 71e8e4f288e74 (bitmap size vs array size) is a different lockup.
## Phase 7: Subsystem
**Step 7.1**
- Record: drivers/md — **IMPORTANT** (enterprise RAID, dm-raid). Not staging.
**Step 7.2**
- Record: Active; recent RAID10/md fixes on this branch.
## Phase 8: Impact and risk
**Step 8.1 — Who**
- Record: MD/RAID users, especially RAID10 recovery of large mostly- clean arrays. Distro/enterprise kernels often PREEMPT_NONE / PREEMPT_VOLUNTARY.
**Step 8.2 — Trigger**
- Record: Recovery/resync of a large sparse array. Not unprivileged syscall; rebuild is a privileged/admin path. Common after disk replace. Timing-independent tight loop.
**Step 8.3 — Failure mode**
- Record: Soft lockup (313s in the report). With softlockup_panic=1, panic. **CRITICAL**.
**Step 8.4 — Risk vs benefit**
- Record: Benefit high (stops watchdog/panic). Risk very low (3 lines, existing helper). Ratio strongly in favor. Remaining CPU spin is patch 3; this still prevents the BUG.
## Phase 9: Synthesis
**For backporting**
- Real, reproduced soft lockup with stack trace.
- Hole is in this tree; patch matches.
- Tiny, obviously correct; maintainer applied it and called it valuable.
- Independent of 3/3; still needed after 1/3.
- Classic stable pattern: cond_resched() to stop a lockup.
**Against**
- Does not cut the 128-sector crawl (author is explicit).
- No Fixes: (maintainer dropped Cc: stable for that).
- Pre-existing md_new_event() spam on last_check == 0 (not introduced here).
**Unresolved:** none that change the verdict. Could not fetch lore.kernel.org/stable (403); discussion from the patch mbox is enough.
**Stable rules**
1. Obviously correct and tested — **PASS** (mainline + QEMU tests; maintainer applied).
2. Real user-visible bug — **PASS** (soft lockup on RAID10 recovery).
3. Important (crash/hang) — **PASS** (soft lockup / possible panic).
4. Small and contained — **PASS** (~3 lines, one function).
5. No new features/APIs — **PASS**.
6. Applies to this tree — **PASS** (clean).
**Exception category:** none required; it is a hang fix.
This matters on 6.18 because RAID rebuild of large arrays is normal operations, and a 5–313s lockup (or panic) is exactly what stable is for. The yield is the same one the I/O path already uses.
## Verification
- [Phase 1] Tags: author SOB, Yu Kuai SOB, msgid link; v2 had `Cc:
stable`, dropped on apply for missing Fixes.
- [Phase 2] Diff: 3 lines in md_do_sync() skip continue; 6.18 code at 9752–9753 / 9779 matches.
- [Phase 2] RAID10: max_sync = RESYNC_PAGES << (PAGE_SHIFT-9) = 128; biolist == NULL → giveup.
- [Phase 3] git describe HEAD / make kernelversion: 6.18.53, branch pending-6.18.
- [Phase 3] 1/3 already ancestor (0efabe6229dc6); this commit is not in HEAD.
- [Phase 4] b4 mbox 21-message thread; Yu Kuai: yield still valuable; applied to md-7.3.
- [Phase 5] Caller: md_register_thread(md_do_sync) resync thread.
- [Phase 6] Skip path present; context matches; expected clean apply.
- [Phase 8] Failure: soft lockup 313s; severity CRITICAL.
- UNVERIFIED: lore.kernel.org/stable search (HTTP 403). Does not change the verdict.
**YES**
drivers/md/md.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/md.c +3 -1
@@ -9751,8 +9751,10 @@ void md_do_sync(struct md_thread *thread)*/ md_new_event (); -if (last_check + window > io_sectors || j == max_sectors) +if (last_check + window > io_sectors || j == max_sectors) { +cond_resched ();continue ; + } last_check = io_sectors; repeat:
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 drm/msm/adreno: Add support for A704 GPU
In reply to Sasha LevinFrom: Aditya Sherawat <[email protected]>
[ Upstream commit 1f69339da06255a7f8560b4768fff83992c03deb ]
Adreno A704 GPU found in Shikra is an IP reuse of A702 GPU with very minimal changes. The only KMD facing difference is the chipid and the zap firmware which is specified via devicetree.
Just add the new chipid to enable support for A704 GPU in Shikra.
Patchwork: https://patchwork.freedesktop.org/patch/738931/
Message-ID: <[email protected]>
---
LLM Generated explanations, may be completely bogus:
The local checkout is **Linux 7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The commit is a one-line Adreno chip-id add on the existing A702 catalog entry; that is the textbook device-ID exception, so the rest of the write-up is the forensic checklist behind a YES for this tree.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[drm/msm/adreno] [Add] [register Adreno A704 chipid on the existing A702 catalog entry]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected; this is new hardware ID enablement, not a regression fix)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** Konrad Dybcio <[email protected]> (listed reviewer of the msm/adreno driver); Dmitry Baryshkov <[email protected]> (msm display maintainer)
- **Acked-by:** none
- **Link:** none in the commit body; **Patchwork:**
https://patchwork.freedesktop.org/patch/738931/; **Message-ID:** <[email protected]> (explicit **v6 1/7** of the Shikra GPU series)
- **Cc: stable:** none (expected)
- **Signed-off-by:** Aditya Sherawat (author); Akhil P Oommen (msm/adreno reviewer/maintainer, listed in MAINTAINERS); Rob Clark (DRM msm maintainer, committer)
- Pipeline markers such as Upstream commit / Signed-off-by: Sasha Levin were ignored per instructions; none were present on the git object itself
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug/problem:** Adreno A704 on Qualcomm **Shikra** is an IP reuse of A702. The kernel-facing difference is the chipid (0x07000400 vs 0x07000200); zap firmware is supplied via DT, not a new catalog firmware name.
- **Symptom:** without the chipid, adreno_info() does not match, adreno_has_gpu() warns Unknown GPU revision and returns false, and the GPU does not bind.
- **Version info:** none in the message. Git: commit is 1f69339da06255a7f8560b4768fff83992c03deb, first contained in **v7.3-rc1**.
- **Root cause as stated:** missing catalog chipid; A704 is not a new GPU family.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not a hidden bug fix.** The subject is honest new-hardware enablement. It still qualifies under the **new device-ID** stable exception (one ID on an already-supported driver), not as a crash/UAF/leak fix.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** drivers/gpu/drm/msm/adreno/a6xx_catalog.c — **1 insertion, 1 deletion** (2 lines changed, 1 file)
- **Function/object:** static const struct adreno_info a7xx_gpus[] — first entry (A702)
- **Scope:** single-file surgical ID add
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** that catalog entry matches only chip_ids = {0x07000200, 0}.
- **After:** {0x07000200, 0x07000400, 0}.
- **Path:** GPU probe / adreno_has_gpu() → find_chipid() (DT compatible qcom,adreno-07000400 or qcom,chipid) → adreno_info() walks chip_ids[]. A704 now returns the existing A702 adreno_info (same firmware a702_sqe.fw, same a6xx_gmuwrapper_funcs, same quirks). Systems without that chipid are unchanged.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Hardware / device-ID enablement]** not UAF/leak/race.
Mechanism: catalog match table omitted 0x07000400, so A704 never bound. Fix: append the ID to the existing A702 row. Same pattern as existing multi-id rows (e.g. A630 0x06030001, 0x06030002).
Verified detail: adreno_is_a702() compares gpu->info->chip_ids[0] == 0x07000200. A702 remains first, so A704 still takes the A702 code paths — consistent with “IP reuse”.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: **Obviously correct and minimal.** No API, locking, or struct- layout change. Regression risk is **very low**: unknown chipids still miss; only 0x07000400 newly matches, and it reuses the already-shipped A702 programming. Zap firmware override remains DT firmware-name (adreno_gpu.c).
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Current line is this commit (1f69339da06255).
- Surrounding A702 entry comes from catalog split **2e819c420e5b8** (Rob Clark, 2024-06-18) and A702 support **18397519cb622** (“drm/msm/adreno: Add A702 support”), first contained in **v6.9-rc1**.
- A702 code has been in-tree for many releases; this is not last-month- only infrastructure.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** N/A. There is no “introduced the bug” SHA; the gap is a new chipid on existing IP.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Immediate neighbors in a6xx_catalog.c: A810 support, A722 support, GBIF rename, A730 hwcg fix — unrelated GPU SKUs.
- **Series:** Message-ID is **v6 1/7** “drm/msm: Add support for Shikra GPU (A704)”. Rest of series: dt-binding qcom,adreno-07000400, SMMU binding, Shikra GPU/SMMU/cooling DT, EVK enable.
- Binding commit **9479a45e5f59c** is in this tree (qcom,adreno-07000400 in gpu.yaml).
- This catalog patch is **standalone** as a match-table add; it does not call new helpers.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Aditya Sherawat has this one msm/adreno commit in the path- limited log. Submitted via **Akhil P Oommen** (MAINTAINERS reviewer for Adreno) and merged by **Rob Clark**. Weight is from reviewer/maintainer trailers, not author volume.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record:
- Needs the A702 a7xx_gpus[] row and ADRENO_CHIP_IDS() — both present here.
- Does **not** need the rest of the 7-patch DT series to be correct or safe.
- Cover letter listed many Shikra SoC prerequisites; those apply to **board GPU bring-up**, not to appending a chipid.
- **Can apply standalone: yes.**
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 1f69339da06255: **[PATCH v6 1/7] drm/msm/adreno: Add support for A704 GPU** — https://patch.msgid.link/20260710-shikra-
[email protected]
- b4 dig -a: v1 (2026-06-09, 2 patches, bindings-first) through **v6 (2026-07-10, 7 patches)**. Applied version is latest (v6).
- Cover letter (v5 mbox, same change-id): A704 is A702 reuse; Mesa already merged (gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41762). DT bits added from v3.
- Reviews on this patch: R-b Konrad, R-b Dmitry. **No NAK** on the chipid patch. Dmitry’s only v5 comment was parsing of the **GPU cooling DT** commit (patch 6), unrelated to the chipid.
- **No reviewer Cc: stable** on this patch.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc included Rob Clark, Konrad Dybcio, Dmitry Baryshkov, Akhil P Oommen, linux-arm-msm, dri-devel, freedreno, DT list. Right maintainers and lists.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: **No syzbot/bugzilla/user crash.** Intent is enablement of Shikra A704, not a fuzzer bug. Cover letter is the “report”.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 7-patch Shikra GPU series. This commit is **1/7** and is the only KMD catalog change. Later patches are bindings/DT. Not a “2/3 logic fix that is incomplete alone”.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: https://lore.kernel.org/stable/?q=A704+adreno → **[No results found]**. No stable request and no documented rejection.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: No function body edited. Data: a7xx_gpus[]. Consumers:adreno_info(), adreno_has_gpu(), adreno_bind().
**Step 5.2: TRACE CALLERS**
Record:
- adreno_info(): used from adreno_has_gpu() and adreno_bind().
- adreno_has_gpu() / bind: OF GPU device probe (drm/msm), not a syscall-hot path.
- Context: platform probe, process context.
**Step 5.3: TRACE CALLEES**
Record: After match, info->funcs->init is existing &a6xx_gmuwrapper_funcs. No new callees.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: userspace cannot invent a chipid; DT/firmware describes the GPU. Reachable on Shikra (or any board with qcom,adreno-07000400). **Not** a universal mm/fs path. Without a GPU node the new ID is inert.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Multiple ADRENO_CHIP_IDS(id1, id2) rows already exist (A630 and others). This is the standard alias-SKU pattern.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record:
- Tree: **7.3.0-rc4** (mainline -rc, HEAD f0100363d8c37).
- a6xx_catalog.c A702 row exists; **this commit is already an ancestor of HEAD** (git merge-base --is-ancestor 1f69339da06255 HEAD → yes). Current source already has ADRENO_CHIP_IDS(0x07000200, 0x07000400).
- A702 support: **v6.9-rc1**; catalog file since **2e819c420e5b8**.
- Missing-id problem is real for any 7.3-based kernel that lacked this SHA; this checkout already contains the ID.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** onto the A702 row in this tree (already applied). No conflicting hunk. a6xx_gmuwrapper_funcs is present (491fadb2b818e).
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: Binding 9479a45e5f59c is here. Shikra shikra.dtsi has GPUCC but **no gpu@ / qcom,adreno-07000400 node** in this checkout — DT enablement from later series patches is incomplete here, which does **not** make the chipid harmful.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **drm/msm/adreno** (Qualcomm GPU). **IMPORTANT** for MSM/Adreno devices, not core mm/vfs. Peripheral relative to the whole kernel; important for Shikra and any other A704 SKU.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: **Active** — recent catalog churn (A810, A722, A840, X2-85). Maintained by Rob Clark / Akhil / Konrad. Mature A702 path since v6.9; this ID rides that path.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **driver/platform-specific** — Adreno A704 / Shikra. No effect on other GPUs. CONFIG_DRM_MSM users only.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Probe of a GPU node whose parsed chipid is 0x07000400. Common on that SoC, never on others. Unprivileged users do not trigger a new attack surface; they only get a working GPU after bind.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Without the ID: GPU not recognized, no bind, no display/compute on that SoC — **not** panic/UAF. **Severity: MEDIUM for those devices** (hardware dead), **LOW for everyone else**. Device-ID exception treats that as backport-worthy enablement.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** A704/Shikra GPU can bind using the already-supported A702 path; Mesa support already exists per cover letter.
- **Risk:** very low (1-token ID, existing row, no hot-path/locking).
- **Ratio:** high benefit for that hardware, negligible risk.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Classic **new device ID** on an existing driver (A702 since v6.9).
- One-line, obviously correct; A704 is documented IP reuse of A702.
- Matching already supports multiple chip_ids; A702 stays chip_ids[0] so adreno_is_a702() still works.
- Reviewed by Konrad Dybcio and Dmitry Baryshkov; signed off by Akhil P Oommen; merged by Rob Clark.
- Inert on machines without chipid 0x07000400.
- Local tree has the A702 catalog row, macros, and probe path; patch applies (and is already in 7.3-rc1+).
**AGAINST:**
- Not a crash/security/corruption fix; it is new SKU enablement.
- Part of a 7-patch Shikra GPU series (DT still incomplete in this dts).
- No syzbot/user crash, no Cc: stable, no stable@ discussion.
- Author is not a high-volume subsystem regular (mitigated by maintainer R-b/SOB).
**UNRESOLVED:**
- lore HTML for the v6 thread was 403 via WebFetch; discussion was recovered via b4 dig + mbox (v5 thread saved; v6 is the applied revision with the same chipid hunk).
- Whether every Shikra EVK DT patch is in 7.3-rc4: GPU node not found in shikra*.dts*; does not change chipid safety.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — one ID, two msm maintainers R-b, merged by drm/msm maintainer; Mesa noted as already merged.
2. Fixes a real bug that affects users? **PASS** (via device-ID exception) — without the ID, A704 never matches and the GPU does not probe.
3. Important issue (crash, security, corruption, deadlock)? **PASS** under the **new device-ID exception**, not as a critical memory- safety fix. Severity for A704 owners is missing GPU, not oops.
4. Small and contained? **PASS** — 1 file, +1/-1.
5. No new features or APIs? **PASS** — no new uAPI/driver; only a chipid alias on existing A702 code.
6. Can apply to the local tree? **PASS** — A702 row and ADRENO_CHIP_IDS exist; commit is already in this 7.3-rc4 history.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **NEW DEVICE ID on an existing driver** (Adreno catalog chipid ≡ PCI/USB ID add). DT exception would apply to later series patches, not this one.
**Step 9.4: MAKE YOUR DECISION**
This tree is **7.3.0-rc4**. The A702 driver and catalog entry are present. The patch is a one-line chipid add, which stable policy explicitly allows. It does not need the rest of the Shikra DT series to be correct. Benefit is enabling A704; risk is negligible. That is a YES for this tree.
---
**What the commit solves for users of this tree:** A704 reports chipid 0x07000400. Without it, drm/msm logs unknown revision and skips the GPU. With it, the existing A702 path runs (SQE firmware, GMU wrapper, quirks). Zap firmware stays DT-overridable.
**Stable rules:** small, reviewed, no new API; qualifies as a device-ID add, not as a sanitizer/crash fix.
**Risk vs benefit:** very low risk, real hardware enablement for Shikra/A704.
**Concerns:** series 1/7; DT GPU node may still be missing on Shikra in this checkout — that does not make the ID unsafe. No crash-fix urgency.
Verification:
- [Phase 1] Subject/tags: no Fixes/Reported-by/Cc:stable; R-b Konrad + Dmitry; SOB Akhil + Rob Clark; Message-ID v6-1/7
- [Phase 1] Body: A704 = A702 reuse; difference is chipid + DT zap
- [Phase 2] git show 1f69339da06255: a6xx_catalog.c +1/-1, ADRENO_CHIP_IDS(0x07000200, 0x07000400)
- [Phase 2] adreno_is_a702() uses chip_ids[0] == 0x07000200 — A702 remains first
- [Phase 2] adreno_info() matches any chip_ids[k] (adreno_device.c:59-61)
- [Phase 3] git describe --match 'v*' --contains 18397519cb622 → A702 in **v6.9-rc1**
- [Phase 3] git describe --match 'v*' --contains 1f69339da06255 → A704 in **v7.3-rc1**
- [Phase 3] blame: A702 row from 2e819c420e5b8; this line from 1f69339da06255
- [Phase 3] no Fixes: tag; standalone vs DT series
- [Phase 4] b4 dig -c: lore/msgid v6 1/7; -a: v1–v6; -w: msm maintainers + lists
- [Phase 4] mbox /tmp/a704-thread.mbox: v5 0–7/7 subjects; R-b on chipid; Dmitry comment only on cooling DT
- [Phase 4] lore.kernel.org/stable A704 adreno: no hits
- [Phase 4] WebFetch lore/patchwork: 403/Anubis; discussion taken from b4/mbox instead
- [Phase 5] probe path find_chipid → adreno_info → info->funcs->init; grep callers verified
- [Phase 5] similar multi-id: A630 0x06030001, 0x06030002
- [Phase 6] git describe HEAD → **v7.3-rc4-27-gf0100363d8c37**; make kernelversion → **7.3.0-rc4**
- [Phase 6] git merge-base --is-ancestor 1f69339da06255 HEAD → yes (already in this tree)
- [Phase 6] gpu.yaml contains qcom,adreno-07000400 via 9479a45e5f59c
- [Phase 6] no gpu@ / adreno compatible in arch/arm64/boot/dts/qcom/shikra*
- [Phase 7] MAINTAINERS: Rob Clark / Konrad / Akhil for drivers/gpu/drm/msm/adreno/
- [Phase 8] failure mode: unknown GPU, no bind; not oops; device-ID exception
- UNVERIFIED: full v6 lore HTML (403); whether Shikra EVK GPU DT landed under a different subject
**YES**
drivers/gpu/drm/msm/adreno/a6xx_catalog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_catalog.c +1 -1
@@ -1417,7 +1417,7 @@ DECLARE_ADRENO_REGLIST_LIST(a750_ifpc_reglist);static const struct adreno_info a7xx_gpus[] = { { - .chip_ids =ADRENO_CHIP_IDS (0x07000200 ), + .chip_ids =ADRENO_CHIP_IDS (0x07000200 ,0x07000400 ), .family =ADRENO_6XX_GEN1 ,/* NOT a mistake! */ .fw = { [ADRENO_FW_SQE ] ="a702_sqe.fw" ,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ata: pata_ep93xx: fix PIO fallback when DMA init fails
In reply to Sasha LevinFrom: Rosen Penev <[email protected]>
[ Upstream commit c303c3619a1d5cf7d4b457106062d16724724a80 ]
ep93xx_pata_dma_init() returns an error when dma_request_chan() fails, which causes ep93xx_pata_probe() to abort entirely. The probe function already has a PIO fallback path (it checks both channel pointers before enabling UDMA), so the DMA init should not fail the probe on non-fatal errors.
Propagate -EPROBE_DEFER, such that we allow the DMA controller driver to load, in case we got probed before the DMA controller driver. For all other failures (e.g. -ENODEV when the DMA controller is missing in the device tree), fall back to PIO.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
Record: [ata / pata_ep93xx] [fix] restore PIO fallback when DMA init fails so probe does not abort
**Step 1.2 — Tags**
Record:
- Assisted-by: Opencode:Big-Pickle
- Signed-off-by: Rosen Penev <[email protected]> (author)
- Signed-off-by: Damien Le Moal <[email protected]> (libata maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, Link:, or Cc: stable (absence of Fixes/Cc:stable is expected here)
- Notable: no user/syzbot report; maintainer SOB is present
**Step 1.3 — Body**
Record:
- **Bug:** ep93xx_pata_dma_init() treats any dma_request_chan() failure as fatal. ep93xx_pata_probe() then returns that error and never registers the ATA host.
- **Symptom:** PATA/IDE controller never appears; storage is unavailable. PIO fallback in probe (channel-pointer check before UDMA) is dead for this path.
- **Root cause:** after the OF DMA conversion, non-defer errors (e.g. -ENODEV) abort probe instead of continuing without DMA.
- **Intended fix:** propagate -EPROBE_DEFER; for other failures, warn and return 0 so the existing PIO path runs.
- **Version info in message:** none.
**Step 1.4 — Hidden bug fix?**
Record: Not hidden. The subject and body describe a real probe regression. The diff also NULLs error pointers and stops fail_release_rx from falling through into a second release.
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
Record:
- File: drivers/ata/pata_ep93xx.c (+21/−9, 30 lines)
- Function: ep93xx_pata_dma_init()
- Scope: single-file surgical error-path change
**Step 2.2 — Code flow**
Record (pre-image from c303c3619a1d5^):
- **rx dma_request_chan fail:** dev_err_probe() and return the error. Probe aborts. dma_rx_channel left as ERR_PTR.
- **tx dma_request_chan fail:** dev_err_probe(), goto fail_release_rx. That released rx, then **fell through** into fail_release_dma → ep93xx_pata_release_dma() with rx still non- NULL and tx still an error pointer.
- **dmaengine_slave_config fail:** dev_err_probe(), release both, **return ret** → probe aborts.
- **After:** non-defer failures NULL the pointers, warn, return 0. -EPROBE_DEFER still fails probe so the DMA driver can load. fail_release_rx no longer falls through.
**Step 2.3 — Bug mechanism**
Record:
- **Primary:** logic/error-path — optional DMA failure became a hard probe failure (regression of designed PIO fallback).
- **Secondary:** error-path resource handling — old tx-fail path could dma_release_channel() twice on rx and pass ERR_PTR into dma_release_channel() (chan->client_count dereference in drivers/dma/dmaengine.c).
**Step 2.4 — Fix quality**
Record: Obviously correct and minimal. Matches pre-v6.12 void dma_init (fail DMA, keep probing). Regression risk is low: happy path unchanged; -EPROBE_DEFER still delays probe; libata only sets udma_mask when both channels are non-NULL, so BMDMA ops are not used in PIO mode. No API/data-structure change.
## Phase 3: Git history
**Step 3.1 — Blame**
Record: The failing dma_request_chan() + return int behavior was introduced by 9963113e3a924 (“ata: pata_ep93xx: add device tree support”, 2024-09-12), contained in **v6.12-rc1**. Before that, ep93xx_pata_dma_init() was void and returned after releasing channels, leaving pointers NULL. Driver itself dates to 2fff27512600 (2012).
**Step 3.2 — Fixes: tag**
Record: No Fixes: tag. The commit that introduced the bug is 9963113e3a924. git merge-base --is-ancestor 9963113e3a924 HEAD succeeds in this tree.
**Step 3.3 — File history**
Record: Between the DT conversion and this fix: pinctrl/DT cleanup, remove() callback switch, COMPILE_TEST/type tweaks. No other DMA-init semantics change. Not patch X/Y. Standalone.
**Step 3.4 — Author**
Record: Rosen Penev is a regular ATA contributor. Damien Le Moal (libata maintainer) applied it to for-7.3.
**Step 3.5 — Dependencies**
Record: Needs the v6.12 dma_request_chan() conversion (9963113e3a924). That is in this tree. No extra helper/API required. Applies standalone on this code.
## Phase 4: Mailing list / external
**Step 4.1 — Original discussion**
Record:
- Lore/msgid:
https://patch.msgid.link/[email protected]
(v2, committed)
- v1: https://patch.msgid.link/[email protected]
- v1→v2: commit-message only (v2: fix EPROBE_DEFER description). Code unchanged.
- Niklas Cassel on v1: “This patch looks correct to me”, asked not to call -EPROBE_DEFER “fatal”.
- Damien on v2: “Applied to for-7.3. Thanks!”
- No NAK, no stable nomination, no reviewer risk flags.
**Step 4.2 — Recipients (b4 dig -w)**
Record: [email protected], Damien Le Moal, Niklas Cassel, linux-kernel. Right maintainers.
**Step 4.3 — Bug report**
Record: No Reported-by / bugzilla / syzbot. Bug is from code inspection of the DT conversion.
**Step 4.4 — Series**
Record: Single standalone patch, two revisions, message-only v2.
**Step 4.5 — stable@**
Record: No stable-list discussion found (lore HTML search was unusable; v2 mbox/thread had no stable Cc). UNVERIFIED beyond the v1/v2 linux-ide thread.
## Phase 5: Semantic / call chain
**Step 5.1 — Functions**
Record: ep93xx_pata_dma_init() only (callees: dma_request_chan, dmaengine_slave_config, dma_release_channel, ep93xx_pata_release_dma).
**Step 5.2 — Callers**
Record: Only ep93xx_pata_probe() (err = ep93xx_pata_dma_init(drv_data); if (err) return err;). Platform probe / device enumeration. Not IRQ/hot path.
**Step 5.3 — Callees**
Record: dma_request_chan() → of_dma_request_slave_channel(). Missing dmas returns -ENODEV (“Silently fail if there is not even the dmas property”). Missing controller while dmas is present returns -EPROBE_DEFER.
**Step 5.4 — Reachability**
Record: Reachable when CONFIG_PATA_EP93XX is enabled and the cirrus,ep9312-pata platform device probes. Userspace does not trigger it directly; boot/device probe does. On this tree the SoC dtsi node is status = "disabled" and no in-tree board enables &ide. Binding/example still has no dmas, so **any** DT that enables the node as documented hits -ENODEV and, before the fix, never binds.
**Step 5.5 — Similar patterns**
Record: Pre-6.12 driver already implemented this fallback. Probe still has if (drv_data->dma_rx_channel && drv_data->dma_tx_channel) before setting udma_mask.
## Phase 6: This tree (v7.3-rc4)
**Step 6.1 — Buggy code here?**
Record: Yes. Local tree: git describe HEAD = **v7.3-rc4-27-gf0100363d8c37**, make kernelversion = **7.3.0-rc4**. 9963113e3a924 is an ancestor. Pre-fix ep93xx_pata_dma_init() in c303c3619a1d5^ returns errors from dma_request_chan(). The candidate itself is also an ancestor of HEAD (already in 7.3); that does not change whether the bug class exists in this lineage.
**Step 6.2 — Backport difficulty**
Record: Clean apply on this tree’s pata_ep93xx.c (post-DT dma_request_chan shape). No conflicting local changes after the fix.
**Step 6.3 — Related fixes already here**
Record: This is the fix. No later follow-up on the file. 5c8121262484d (“pata_ep93xx: fix deferred probing”) only touches platform_get_irq(), not DMA init.
## Phase 7: Subsystem context
**Step 7.1**
Record: Subsystem drivers/ata (libata PATA). Criticality **PERIPHERAL/IMPORTANT**: storage driver, but only Cirrus EP93xx (CONFIG_PATA_EP93XX depends on ARCH_EP93XX || COMPILE_TEST).
**Step 7.2**
Record: File is mature (2012) with a burst of DT work in 6.12; otherwise low churn.
## Phase 8: Impact and risk
**Step 8.1 — Who is affected**
Record: EP93xx PATA users on DT kernels (6.12+). Not universal. In-tree boards do not enable the IDE node today; anyone enabling it per the binding (no dmas; additionalProperties: false) is affected.
**Step 8.2 — Trigger**
Record: Device probe. Common if the node is enabled: official dtsi/binding have no DMA properties, so dma_request_chan("rx") returns -ENODEV every boot. Unprivileged userspace cannot trigger it. Not a race.
**Step 8.3 — Failure mode**
Record:
- Main: probe fails → no ATA host → disk missing (boot/rootfs failure if PATA is the disk). Severity **HIGH** for those boards, not a kernel oops.
- Secondary (rx OK, tx fail): dma_release_channel(ERR_PTR) / double- release. Severity **HIGH** if hit; needs a DT with a working rx name and failing tx. Not the in-tree DT shape.
**Step 8.4 — Risk/benefit**
Record: Benefit medium-high for EP93xx DT PATA (driver actually binds). Risk very low (error path only, ~20 lines, maintainer-acked). Ratio favors backport.
## Phase 9: Synthesis
**Step 9.1 — Evidence**
FOR:
- Real v6.12 regression: DMA init errors abort probe; original design and probe still expect PIO fallback.
- In-tree binding/example/dtsi do not describe DMA, so -ENODEV is the realistic dma_request_chan() result if the node is enabled.
- Also closes a bad tx-fail cleanup (ERR_PTR / double-release).
- Small, obviously correct; Niklas: “looks correct”; Damien applied it.
- Prerequisites (dma_request_chan conversion) are in this tree.
AGAINST:
- Niche SoC; IDE node disabled in all in-tree boards — limited default user base.
- No crash/syzbot/user report.
- Not a new feature, but also not a universal core-kernel bug.
UNRESOLVED:
- Whether any production EP93xx DT out of tree enables this node (unverified).
- No stable@ thread found beyond linux-ide.
**Step 9.2 — Stable rules**
1. Obviously correct and tested? **PASS** — logic matches pre-6.12; v1 reviewed; maintainer applied. No separate hardware Tested-by.
2. Real bug affecting users? **PASS** — probe failure / non-working PATA when DMA is absent.
3. Important (crash/security/corruption/deadlock/etc.)? **PASS** — storage controller fails to register (boot-breaking if PATA is the disk). Not an oops, but functionally serious. Secondary error-path UAF-class DMA release if tx fails after rx.
4. Small and contained? **PASS** — one function, +21/−9.
5. No new features/APIs? **PASS**.
6. Can apply to this tree? **PASS** — same dma_request_chan code; DT conversion is present.
**Step 9.3 — Exception category**
Record: None (not an ID/quirk/DT/build/doc exception). Ordinary driver bugfix.
**Step 9.4 — Decision**
This tree is **7.3-rc4**. The v6.12 DT conversion is here, so the bug exists in this lineage. The patch restores the driver’s intended PIO fallback, keeps -EPROBE_DEFER, and is a small, reviewed error-path fix. It meets stable criteria for this checkout.
What it solves for stable users: after the 6.12 OF DMA switch, missing DMA (the documented DT) made pata_ep93xx fail probe instead of running PIO. That can leave the disk missing. Risk is low; no extra commits are required here.
Verification:
- [Phase 1] Parsed tags: author + Damien SOB only; no Fixes/Reported- by/Cc:stable
- [Phase 2] Diff: ep93xx_pata_dma_init() error paths; return 0 except -EPROBE_DEFER; NULL ERR_PTRs; split fail_release_rx from fail_release_dma
- [Phase 2] Parent file: git show c303c3619a1d5^:drivers/ata/pata_ep93xx.c confirms probe abort + fall- through release
- [Phase 2] dma_release_channel() dereferences chan->client_count — ERR_PTR would oops
- [Phase 3] Blame: buggy dma_request_chan from 9963113e3a924 (v6.12-rc1); git merge-base --is-ancestor 9963113e3a924 HEAD true
- [Phase 3] Pre-DT dma_init was void and already fell back to PIO
- [Phase 4] b4 dig -c c303c3619a1d5: v1 2026-06-01, v2 2026-07-19 (message-only)
- [Phase 4] Niklas Cassel: “looks correct”; Damien: “Applied to for-7.3”
- [Phase 5] Only caller: ep93xx_pata_probe(); of_dma_request_slave_channel returns -ENODEV without dmas
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; kernelversion 7.3.0-rc4
- [Phase 6] Binding cirrus,ep9312-pata.yaml: no dmas, additionalProperties: false; dtsi ide@800a0000 has no dmas, status disabled; no &ide enable in in-tree boards
- [Phase 8] Failure: probe fail / no disk; not an oops on the common -ENODEV path
- UNVERIFIED: out-of-tree boards enabling this node; stable@ mailing list beyond linux-ide
**YES**
drivers/ata/pata_ep93xx.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
drivers/ata/pata_ep93xx.c +21 -9
@@ -652,14 +652,22 @@ static int ep93xx_pata_dma_init(struct ep93xx_pata_data *drv_data)* start of new transfer. */ drv_data->dma_rx_channel =dma_request_chan (dev,"rx" ); -if (IS_ERR (drv_data->dma_rx_channel)) -return dev_err_probe (dev,PTR_ERR (drv_data->dma_rx_channel), -"rx DMA setup failed\n" ); +if (IS_ERR (drv_data->dma_rx_channel)) { + ret =PTR_ERR (drv_data->dma_rx_channel); + drv_data->dma_rx_channel =NULL ; +if (ret == -EPROBE_DEFER ) +return ret; +dev_warn (dev,"rx DMA unavailable, using PIO\n" ); +return 0 ; + } drv_data->dma_tx_channel =dma_request_chan (&pdev->dev,"tx" );if (IS_ERR (drv_data->dma_tx_channel)) { - ret =dev_err_probe (dev,PTR_ERR (drv_data->dma_tx_channel), -"tx DMA setup failed\n" ); + ret =PTR_ERR (drv_data->dma_tx_channel); + drv_data->dma_tx_channel =NULL ; +if (ret == -EPROBE_DEFER ) + goto fail_release_rx; +dev_warn (dev,"tx DMA unavailable, using PIO\n" ); goto fail_release_rx; }
@@ -670,7 +678,7 @@ static int ep93xx_pata_dma_init(struct ep93xx_pata_data *drv_data) conf.src_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; ret =dmaengine_slave_config (drv_data->dma_rx_channel, &conf);if (ret) { -dev_err_probe (dev, ret,"failed to configure rx dma channel" ); +dev_warn (dev,"failed to configure rx dma channel, using PIO\n" ); goto fail_release_dma; }
@@ -681,7 +689,7 @@ static int ep93xx_pata_dma_init(struct ep93xx_pata_data *drv_data) conf.dst_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; ret =dmaengine_slave_config (drv_data->dma_tx_channel, &conf);if (ret) { -dev_err_probe (dev, ret,"failed to configure tx dma channel" ); +dev_warn (dev,"failed to configure tx dma channel, using PIO\n" ); goto fail_release_dma; }
@@ -689,10 +697,14 @@ static int ep93xx_pata_dma_init(struct ep93xx_pata_data *drv_data) fail_release_rx:dma_release_channel (drv_data->dma_rx_channel); + drv_data->dma_rx_channel =NULL ; +if (ret == -EPROBE_DEFER ) +return ret; +return 0 ; + fail_release_dma:ep93xx_pata_release_dma (drv_data); - -return ret; +return 0 ; }static void ep93xx_pata_dma_start (struct ata_queued_cmd *qc)
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 iommu/amd: Fix missing CMD_COMPLETE_PPR response for invalid PPR requests
In reply to Sasha LevinFrom: Vasant Hegde <[email protected]>
[ Upstream commit bc1f5ec826bfa510e7138e2be5aad23907850874 ]
The AMD IOMMU spec, requires the host to respond with a CMD_COMPLETE_PPR command when an EVENT_TYPE_INV_PPR_REQ event is received with the RX bit cleared. This response was missing in the current implementation, leaving invalid PPR requests unacknowledged.
Introduce amd_iommu_report_ppr_err() to handle EVENT_TYPE_INV_PPR_REQ events. The new function logs the invalid PPR request and when the RX bit is cleared, sends CMD_COMPLETE_PPR response.
---
LLM Generated explanations, may be completely bogus:
I have enough to decide: the INV_PPR_REQ path is in this 6.12 tree, the completion helper already exists, and the fix is a small spec-compliance change to stop PRI stalls.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[iommu/amd] [Fix] missing CMD_COMPLETE_PPR response for invalid PPR requests.** The subject is an explicit bug fix in the AMD IOMMU driver: invalid PPR (Page Request) events were logged but not acknowledged to hardware.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Reported-by:** Gaultier Delbarre (AMD) — real hardware/spec issue found inside AMD, not a theoretical cleanup.
- **Co-developed-by / Signed-off-by:** Wei Huang (AMD), Vasant Hegde (AMD IOMMU maintainer/author).
- **Reviewed-by:** Ankit Soni (AMD).
- **Signed-off-by:** Joerg Roedel (IOMMU maintainer).
- **No Fixes: tag** (expected for this review pipeline).
- **No Cc: stable** (expected).
- **No syzbot, Link, Tested-by, or Acked-by.**
- Ignore any pipeline-added Sasha Levin SOB / Upstream commit markers.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** AMD IOMMU spec requires the host to issue CMD_COMPLETE_PPR when an EVENT_TYPE_INV_PPR_REQ event arrives with the RX bit **cleared**. The driver only printed INVALID_PPR_REQUEST and returned.
- **Symptom:** Invalid PPR/PRI requests stay unacknowledged. The device keeps the outstanding page-request slot; further PRI traffic can stall (DMA/GPU/SVA hang), rather than a kernel oops.
- **Root cause:** Event-log handler treated INV_PPR_REQ as log-only; the completion path used for valid PPR (amd_iommu_complete_ppr()) was never invoked.
- **Fix:** New amd_iommu_report_ppr_err() logs the event and, if RX=0, sends CMD_COMPLETE_PPR with IOMMU_PAGE_RESP_FAILURE.
- **Version info in message:** none.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not a hidden fix.** The subject and body state a spec-mandated missing hardware response. This is a protocol/hang fix, not a style cleanup.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- drivers/iommu/amd/amd_iommu_types.h: +1 (EVENT_FLAG_PPR_RX 0x001).
- drivers/iommu/amd/iommu.c: ~+33/-6. New amd_iommu_report_ppr_err(); iommu_print_event() INV_PPR_REQ case now calls it; unused local tag removed.
- **Scope:** single-driver surgical fix. ~38 lines net. No API/ABI change.
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** iommu_print_event() on type 0x9 extracted PASID/tag, dev_err(), break. No IOMMU command.
- **After:** same log, then if !(flags & EVENT_FLAG_PPR_RX) look up the PCI device, check IOMMU private data, call existing amd_iommu_complete_ppr(..., IOMMU_PAGE_RESP_FAILURE, tag).
- **Path:** threaded IRQ event-log poll (amd_iommu_int_thread_evtlog → iommu_poll_events → iommu_print_event), not a syscall hot path. Error/exception path for invalid hardware page requests.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Hardware protocol / hang (logic/correctness).** Missing command on an exception event. Analogous to Intel VT-d handle_bad_prq_event(), which already submits a page-group response for invalid PRQ. Not UAF/leak/race/overflow.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Obviously correct** for the common case: RX=0 → complete with FAILURE using the same helper as ppr.c already uses for “nobody cared” PPR entries.
- **Minimal:** one flag, one helper, one call-site change.
- **Regression risk: low.** Patterns match existing event/PPR handling (pci_get_domain_bus_and_slot + pci_dev_put already used from amd_iommu_report_page_fault() in this same function). iommu_queue_command() takes iommu->lock with raw_spin_lock_irqsave; iommu_print_event() does not hold that lock.
- **Known incompleteness (accepted in the committed form):** if pci_get_domain_bus_and_slot() fails or there is no IOMMU priv, it still returns without COMPLETE_PPR. Ankit Soni raised that on list; the committed diff still has those early returns, and Ankit still Reviewed-by. Those are devices not in the PCI tree / not bound — the PRI-using devices this matters for have both.
- **Follow-up in the same series (not this commit):** patch 4 rate- limits the log; patch 5 fixes GN derivation (pri_tlp vs v2 page- table). This commit uses existing amd_iommu_complete_ppr() (GN from pri_tlp), which is already how every COMPLETE_PPR in **this** tree is built. Not a new regression vs current 6.12 behavior.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- INV_PPR_REQ case introduced in **e7f63ffc1bf19** (“iommu/amd: Update logging information for new event type”, 2018-05-01, Gary R Hook) — log-only from the start.
- PASID extraction: 470eb3b31134ad (Suravee, 2019).
- Log format: later Vasant Hegde updates (b36a5b0f1cedbb / pci_seg).
- Buggy behavior (log, no COMPLETE_PPR) has been in-tree for years, including this 6.12 checkout.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** The missing response became operationally important once PRI/PPR completion existed: **978d626b8f1a2** (“iommu/amd: Add IO page fault notifier handler”, Wei Huang, 2024-04-18) added amd_iommu_complete_ppr() and PPR log handling. That commit **is an ancestor of HEAD**.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- This commit is **patch 3/5** of “iommu/amd: PRI related cleanup and fixes” (Vasant Hegde, 2026-07-27).
1. Device ID in invalid PASID log — **already in this tree**
(`5a5cd58b1533e`).
2. `PPR_TAG_LAST_PAGE()` macro — cleanup; **not required** for this
patch.
3. **This fix** — missing COMPLETE_PPR.
4. Rate-limit INVALID_PPR_REQUEST — depends on 3; current 6.12 already
logs unbounded `dev_err` here, so 3 alone is not a log-flood
regression.
5. GN bit in COMPLETE_PPR — separate correctness fix; refactors
`amd_iommu_complete_ppr()`.- Recent iommu.c churn is attach/flush locking, not this event case. **Standalone for the bug it fixes.**
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Vasant Hegde is the AMD IOMMU driver author on this tree (many drivers/iommu/amd/ commits). Wei Huang added the 2024 IOPF/PPR notifier. This is a maintainer-area fix, not a drive-by.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **Can apply standalone on this tree.** Required symbols all exist:
- amd_iommu_complete_ppr() (iommu.c ~1827, declared in amd_iommu.h)
- PPR_PASID(), IOMMU_PAGE_RESP_FAILURE, pci_get_domain_bus_and_slot, dev_iommu_priv_get, iommu->pci_seg
- EVENT_TYPE_INV_PPR_REQ case already present
- Patches 2/4/5 not required for this change to compile or to send a completion.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- Series: [PATCH 0/5] iommu/amd: PRI related cleanup and fixes, Vasant Hegde, 2026-07-27.
- Patch 3: https://ratatoskr.run/linux-iommu/2026/07/17321958
- Cover: https://ratatoskr.run/linux-iommu/2026/07/17321955
- Review: https://ratatoskr.run/linux-iommu/2026/07/17327932 (Ankit Soni, 2026-07-28): suggested issuing COMPLETE_PPR even when pdev/priv is missing, via build_complete_ppr()/iommu_queue_command(). **No NAK.** Committed code matches v1 (early returns kept) and carries Ankit’s Reviewed-by.
- **UNVERIFIED:** b4 dig -c needs a SHA not in this checkout. b4 mbox of msgid [email protected] returned an unrelated IRT-cache thread. lore.kernel.org search URLs returned **403**. No evidence of a later v2 that replaced this diff.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: Recipients/maintainers on the series include Joerg Roedel (SOB on the commit), Ankit Soni (Reviewed-by), Wei Huang (co-developer). Appropriate AMD IOMMU reviewers.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: Reporter is AMD (Gaultier Delbarre). No public syzbot/bugzilla link. This is spec non-compliance observed on AMD hardware/firmware, not a fuzzer crash.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 5-patch PRI series. Patch 1 already backported here. 2 is cosmetic. 3 is the hang/protocol fix. 4 is log-rate-limit on top of 3. 5 is GN-bit correctness for all COMPLETE_PPR, plus using event-flag GN on this new path. **This commit is self-contained;** 5 is a nice follow-up, not a hard apply dependency.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** — lore.kernel.org/stable returned 403. No local git log --grep=CMD_COMPLETE_PPR hits in this tree.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: Added amd_iommu_report_ppr_err(). Modified iommu_print_event(). Calls existing amd_iommu_complete_ppr().
**Step 5.2: TRACE CALLERS**
Record:
- iommu_print_event() ← iommu_poll_events() ← amd_iommu_int_thread_evtlog() / amd_iommu_int_thread() (threaded IRQ).
- amd_iommu_complete_ppr() already called from iommu_call_iopf_notifier() and amd_iommu_page_response() in ppr.c (same IRQ-thread class for PPR log).
**Step 5.3: TRACE CALLEES**
Record: PPR_PASID(), pci_get_domain_bus_and_slot(), dev_iommu_priv_get(), amd_iommu_complete_ppr() → build_complete_ppr() + iommu_queue_command() (command buffer, may udelay under iommu->lock on full buffer — existing behavior).
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: **Reachable in production** on AMD IOMMU hardware with PPR (Guest Translation + PPR + EPHSUP: amd_iommu_gt_ppr_supported()). PPR log is enabled in enable_iommus_ppr(). PRI is enabled on SVA-capable domain attach (pdev_enable_caps()). Userspace/devices that use SVA/PASID/PRI (AMD GPU SVM, some VFIO) can generate PPR; invalid ones produce INV_PPR_REQ in the event log. Not a syscall bug; a device DMA/PRI stall.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: ppr.c already completes invalid/unhandled PPR log entries with IOMMU_PAGE_RESP_FAILURE. Intel handle_bad_prq_event() always responds to invalid PRQ when LPIG is set. This patch closes the AMD event-log gap for the same class of bug.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** Local tree is **6.12.111** (p-6.12-3-gc504cf0baa3d8, Makefile VERSION/PATCHLEVEL/SUBLEVEL 6/12/111).
```973:979:drivers/iommu/amd/iommu.c
case EVENT_TYPE_INV_PPR_REQ:
pasid = PPR_PASID(*((u64 *)__evt));
tag = event[1] & 0x03FF;
dev_err(dev, "Event logged [INVALID_PPR_REQUEST ...
break;
```No EVENT_FLAG_PPR_RX, no amd_iommu_report_ppr_err(). Bug introduced as log-only in 2018; completion helper present since 978d626b8f1a2 (in this tree).
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Expected apply: clean or trivial context.** 6.12 iommu_print_event() lacks a later ctrl = readq(MMIO_CONTROL_OFFSET) local that appears in the mainline hunk context; the INV_PPR_REQ case, report_page_fault insertion point, and EVENT_FLAG_I site match. No conflicting local change to this switch arm.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No existing COMPLETE_PPR on INV_PPR_REQ. Related:5a5cd58b1533e (series patch 1, log-only), 1de4443f85e44 (pci_dev_put after PPR faults). **This specific bug is unfixed here.**
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **drivers/iommu/amd** — **IMPORTANT** (not core mm/VFS). AMD IOMMU is default DMA isolation on AMD x86; PRI/PPR is a subset (SVA/IOPF), but a hung PRI-capable device (GPU) is user-visible.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained in 6.12 (flush, attach locking, SNP log sizes, PPR). Mature driver; this event type is old. Fix is not for brand-new code missing from 6.12.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Platform/config-specific:** AMD IOMMU + PPR/PRI-capable devices (SVA/PASID). Not every AMD desktop, but real 6.12 users (ROCm/KFD SVM, IOMMU page-fault devices).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Hardware logs INV_PPR_REQ (invalid PRI/PPR). RX=0 means software **must** complete. Trigger is device-generated, not a userspace syscall. Unprivileged code on an SVA-bound device can cause invalid page requests. Timing: not a race; missing response every time RX=0.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Device/PRI hang (HIGH), not a kernel panic.** Unacked PRI consumes outstanding page-request slots (PRI enable uses 32 outstanding in pdev_enable_cap_pri()). Device DMA can stall; GPU/compute jobs hang. Matches stable-rules “hang” / hardware protocol failure. Reporter is AMD — they saw it.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit: high** for AMD PRI/SVA users (prevents stuck page-request state).
- **Risk: low** (~30 lines, existing helper, same IRQ-thread context as PPR completion, no lock-order novelty vs report_page_fault).
- **Ratio:** favorable. Worst extra load is queuing COMPLETE_PPR under a PPR flood; spec requires that, and command-buffer timeout already exists.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR backporting:**
- Real spec bug: missing CMD_COMPLETE_PPR for INV_PPR_REQ with RX=0.
- User-visible hang (PRI/DMA stall), reported by AMD.
- Buggy log-only path exists in this 6.12 tree; completion helper already here.
- Small, obviously correct, uses existing amd_iommu_complete_ppr().
- Reviewed by AMD; SOB from Joerg Roedel.
- Intel already answers invalid PRQ the same way.
- No new APIs/features.
**AGAINST:**
- Not a kernel oops/UAF; only PRI-capable AMD devices.
- Series follow-ups 4 (ratelimit) and 5 (GN bit) are not in this commit; 5 says pri_tlp is the wrong GN source — but that is **already** how 6.12 completes all PPRs.
- Corner-case still skips completion without pdev/priv.
- No Fixes:/Cc: stable (not a negative per pipeline rules).
**UNRESOLVED:**
- Exact mainline SHA (b4 dig -c not possible without it).
- Stable-list discussion (lore 403).
- Whether a v2 addressed Ankit’s always-complete suggestion (committed diff matches v1).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — spec-aligned; AMD- developed/reviewed; Joerg SOB. (Tested-by not in message; author + reviewer are the hardware vendor.)
2. Fixes a real bug that affects users? **PASS** — unacked invalid PPR; Reported-by AMD.
3. Important issue (crash, security, corruption, deadlock)? **PASS** — hang / hardware protocol stall (HIGH), not cosmetic.
4. Small and contained? **PASS** — ~30 lines, two files, one driver.
5. No new features or APIs? **PASS** — uses existing complete-PPR command.
6. Can apply to the local tree? **PASS** — buggy code and helpers present; apply should be clean or trivial context.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/doc exception. Qualifies as a **normal hang/protocol bug fix**.
**Step 9.4: MAKE YOUR DECISION**
This should be backported to **this** 6.12.y tree. The INV_PPR_REQ handler has never sent COMPLETE_PPR; 6.12 already has PRI/PPR completion for the PPR log. The patch is small, uses that helper, and prevents device-side PRI stalls on AMD IOMMU.
The problem is a missing hardware response, not a new feature. Stable users with AMD IOMMU + PRI/SVA can hang outstanding page requests; the fix is ~30 lines and matches code already used from ppr.c. Patch 5 (GN bit) is a separate improvement already latent in 6.12’s pri_tlp usage and is not required for this commit to help.
Verification:
- [Phase 1] Parsed tags: Reported-by Gaultier Delbarre (AMD); Co- developed-by Wei Huang; SOB Vasant Hegde + Joerg Roedel; Reviewed-by Ankit Soni; no Fixes/Cc:stable/syzbot.
- [Phase 2] Diff: +EVENT_FLAG_PPR_RX; new amd_iommu_report_ppr_err(); INV_PPR_REQ calls complete_ppr on RX=0; ~33/-6 lines.
- [Phase 3] git blame 973-979 iommu.c: e7f63ffc1bf19 (2018) introduced log-only INV_PPR_REQ.
- [Phase 3] 978d626b8f1a2 is ancestor of HEAD (git merge-base --is- ancestor succeeded); amd_iommu_complete_ppr exists at iommu.c:1827.
- [Phase 3] git log --oneline --grep=CMD_COMPLETE_PPR -- drivers/iommu/amd/: empty (fix not in this tree).
- [Phase 3] Series patch 1 already present: 5a5cd58b1533e.
- [Phase 4] Ratatoskr: series 0/5 17321955, patch 3 17321958, Ankit review 17327932 (corner case, no NAK).
- [Phase 4] b4 dig -c: **UNVERIFIED** (SHA not in tree). b4 mbox of 26cfa307-… pulled the wrong thread.
- [Phase 4] lore.kernel.org and lore stable search: **UNVERIFIED** (HTTP 403).
- [Phase 5] Callers: amd_iommu_int_thread_evtlog → iommu_poll_events → iommu_print_event (threaded IRQ). complete_ppr already used from ppr.c in the PPR IRQ thread.
- [Phase 5] Intel analog: handle_bad_prq_event() in drivers/iommu/intel/prq.c submits QI page-group response.
- [Phase 6] git describe HEAD: p-6.12-3-gc504cf0baa3d8; make
kernelversion: 6.12.111; buggy INV_PPR_REQ case present; EVENT_FLAG_PPR_RX absent.
- [Phase 6] 6.12 iommu_print_event lacks later ctrl MMIO read; INV_PPR_REQ hunk still matches.
- [Phase 7] Subsystem drivers/iommu/amd, IMPORTANT, actively maintained.
- [Phase 8] Failure mode: unacked PRI → device hang; severity HIGH; trigger AMD PPR/PRI hardware.
- UNVERIFIED: mainline SHA; v2 of series; stable@ discussion.
**YES**
drivers/iommu/amd/amd_iommu_types.h | 1 + drivers/iommu/amd/iommu.c | 38 ++++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 6 deletions(-)
drivers/iommu/amd/amd_iommu_types.h +1 -0
@@ -158,6 +158,7 @@#define EVENT_FLAGS_SHIFT 0x10#define EVENT_FLAG_RW 0x020#define EVENT_FLAG_I 0x008 +#define EVENT_FLAG_PPR_RX 0x001/* feature control bits */ #define CONTROL_IOMMU_EN 0
drivers/iommu/amd/iommu.c +32 -6
@@ -883,10 +883,40 @@ static void amd_iommu_report_page_fault(struct amd_iommu *iommu,pci_dev_put (pdev); } +static void amd_iommu_report_ppr_err (struct amd_iommu *iommu,volatile u32 *event, +u16 devid,u64 address,int flags) +{ +struct pci_dev *pdev; +struct device *dev = iommu->iommu.dev; +u32 pasid =PPR_PASID (*((u64 *)event)); +int tag = event[1 ] &0x03FF ; + +dev_err (dev,"Event logged [INVALID_PPR_REQUEST device=%04x:%02x:%02x.%x pasid=0x%05x address=0x%llx flags=0x%04x tag=0x%03x]\n" , + iommu->pci_seg->id,PCI_BUS_NUM (devid),PCI_SLOT (devid),PCI_FUNC (devid), + pasid, address, flags, tag); + +/* Skip COMPLETE_PPR_REQUEST response if RX=1 */ +if (flags &EVENT_FLAG_PPR_RX ) +return ; + + pdev =pci_get_domain_bus_and_slot (iommu->pci_seg->id,PCI_BUS_NUM (devid), + devid &0xff ); +if (!pdev) +return ; + +if (!dev_iommu_priv_get (&pdev->dev)) { +pci_dev_put (pdev); +return ; + } + +amd_iommu_complete_ppr (&pdev->dev, pasid,IOMMU_PAGE_RESP_FAILURE , tag); +pci_dev_put (pdev); +} +static void iommu_print_event (struct amd_iommu *iommu,void *__evt) {struct device *dev = iommu->iommu.dev; -int type, devid, flags, tag; +int type, devid, flags;volatile u32 *event = __evt;int count =0 ;u64 address, ctrl;
@@ -960,11 +990,7 @@ static void iommu_print_event(struct amd_iommu *iommu, void *__evt)amd_iommu_report_rmp_hw_error (iommu, event);break ;case EVENT_TYPE_INV_PPR_REQ : - pasid =PPR_PASID (*((u64 *)__evt)); - tag = event[1 ] &0x03FF ; -dev_err (dev,"Event logged [INVALID_PPR_REQUEST device=%04x:%02x:%02x.%x pasid=0x%05x address=0x%llx flags=0x%04x tag=0x%03x]\n" , - iommu->pci_seg->id,PCI_BUS_NUM (devid),PCI_SLOT (devid),PCI_FUNC (devid), - pasid, address, flags, tag); +amd_iommu_report_ppr_err (iommu, event, devid, address, flags);break ;default : dev_err(dev, "Event logged [UNKNOWN event[0]=0x%08x event[1]=0x%08x event[2]=0x%08x event[3]=0x%08x\n",
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: mt76: set the EOSP bit in the QoS header of the last released frame
In reply to Sasha LevinFrom: Felix Fietkau <[email protected]>
[ Upstream commit 0b8d2524716099ea4743fa65bc364f94b3106a31 ]
When the driver implements .release_buffered_frames, mac80211 leaves the U-APSD signalling entirely to the driver: "In this case it is also responsible for setting the EOSP flag in the QoS header of the frames" (include/net/mac80211.h). Only IEEE80211_TX_STATUS_EOSP was being set, which merely ends the service period inside mac80211, so on air the service period was never terminated. Clients that wait for EOSP before going back to doze keep the SP open and stop triggering, which stalls all downlink traffic for that station.
Set the wire EOSP bit on the last frame of a U-APSD service period. EOSP has no meaning for a PS-Poll response, so pass the release reason down and leave those frames alone.
---
LLM Generated explanations, may be completely bogus:
This is a real U-APSD protocol bug in mt76 that already exists in this 5.15.221 tree. The fix is small, applies here, and is independent of the rest of the series.
## Phase 1: Commit message forensics
**Step 1.1 — subject**
Record: [wifi: mt76:] [set] set the EOSP bit in the QoS header of the last released frame. “Set” here is a protocol-correctness fix, not a feature add.
**Step 1.2 — tags**
Record:
- Link: https://patch.msgid.link/[email protected]
(linux-wireless, series 04/10)
- Signed-off-by: Felix Fietkau <[email protected]> (mt76 maintainer; Sasha Levin SOB ignored per instructions)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, `Cc:
stable` (absence is expected)
Mainline SHA (from origin/master, path-limited log):0b8d2524716099ea4743fa65bc364f94b3106a31. First containing tag:v7.3-rc1. Not an ancestor of this HEAD.
**Step 1.3 — body**
Record:
- **Bug:** .release_buffered_frames means mac80211 does not set the on-air EOSP bit; the driver must. mt76 only set IEEE80211_TX_STATUS_EOSP (ends the SP inside mac80211).
- **Symptom:** U-APSD clients that wait for EOSP never see it, keep the service period open, stop triggering, **all downlink for that STA stalls**.
- **Root cause:** missing IEEE80211_QOS_CTL_EOSP on the last QoS frame of a U-APSD SP. PS-Poll must not get EOSP.
- **Version info:** none in the message. Buggy code dates to 2017.
**Step 1.4 — hidden fix?**
Record: Not hidden. Explicit protocol/connectivity fix.
## Phase 2: Diff analysis
**Step 2.1 — inventory**
Record:
- File: drivers/net/wireless/mediatek/mt76/tx.c (+12 / -4)
- Functions: mt76_queue_ps_skb, mt76_release_buffered_frames
- Scope: single-file surgical change. mt76_queue_ps_skb is static; exported mt76_release_buffered_frames signature already has reason.
**Step 2.2 — flow**
Record:
- Before: last PS-release frame gets IEEE80211_TX_STATUS_EOSP | IEEE80211_TX_CTL_REQ_TX_STATUS and More Data cleared. QoS Control on the wire is untouched.
- After: same flags, plus if reason == IEEE80211_FRAME_RELEASE_UAPSD and the frame is QoS data, OR IEEE80211_QOS_CTL_EOSP into the QoS control field. reason is passed through both call sites.
- Path: U-APSD/PS-Poll release via .release_buffered_frames, not the normal TX burst path.
**Step 2.3 — bug mechanism**
Record: **Logic / protocol correctness.** mac80211’s own release path (net/mac80211/sta_info.c) does *qoshdr |= IEEE80211_QOS_CTL_EOSP for U-APSD. Drivers that implement .release_buffered_frames must do the same (include/net/mac80211.h). mt76 did not.
**Step 2.4 — quality**
Record: Obviously correct and aligned with mac80211. Guards match the docs (U-APSD only; QoS data only). skb is exclusively owned after ieee80211_tx_dequeue. Header at skb->data matches existing mt76_skb_set_moredata(). Regression risk is low: PS-Poll unchanged; non-QoS last frames still lack wire EOSP (mac80211 already assumes drivers mostly buffer QoS-data, or add a QoS-Null themselves). Pre- existing unused more_data parameter is not changed.
## Phase 3: Git history
**Step 3.1 — blame**
Record: mt76_queue_ps_skb / mt76_release_buffered_frames introduced in 17f1de56df0512 (“mt76: add common code…”, 2017-12-07, **v4.16-rc1**). IEEE80211_TX_STATUS_EOSP added in 7267a7965dd7b (2018). Present for the entire 5.15 lifetime.
**Step 3.2 — Fixes: tag**
Record: None. Introducer is 17f1de56df0512, which **is** in this tree.
**Step 3.3 — related file history**
Record: Recent 5.15 tx.c work is unrelated (locking, UAF, queue id). This tree already has U-APSD AP support: b807b368c4f9b (mt76 AP U-APSD), 4bf04d33f5b7e (mt7915). No earlier EOSP-on-wire fix.
**Step 3.4 — author**
Record: Felix Fietkau is listed in MAINTAINERS as mt76 maintainer. Sibling series patch 05 (697badc27a9b3, mt7603 U-APSD termination) is a separate chip-specific fix, not a prerequisite.
**Step 3.5 — prerequisites**
Record: Series is **01–10**, but 04 does **not** depend on 01–03. Patch 01 (a547b414bf7ea) changes mt76_txq_send_burst / HW TIM buffering and does not touch mt76_queue_ps_skb. 02/03/09/10 are mt7915/mt7996/MLO (mt7996 is not in 5.15). 05–08 are mt7603-only. 04 is standalone. All helpers used (ieee80211_is_data_qos, ieee80211_get_qos_ctl, IEEE80211_QOS_CTL_EOSP, IEEE80211_FRAME_RELEASE_UAPSD) exist in this tree via mt76.h → <net/mac80211.h> / ieee80211.h.
## Phase 4: Mailing list / external
**Step 4.1 — original discussion**
Record: b4 dig -c 0b8d252471609 →
https://patch.msgid.link/[email protected]b4 dig -a: single **v1** series, 2026-08-01. Applied version is that v1. Thread has the 10 patches plus a kernel-test-robot build error on **10/10** (ieee80211_txq_aql_pending / patch 01), **not** on 04. No NAK, no reviewer concern about EOSP. Merged via wireless- next-2026-08-06 into v7.3-rc1.
**Step 4.2 — recipients (b4 dig -w)**
Record: Felix Fietkau, [email protected]. Maintainer- authored self-merge; no extra Reviewed-by. Normal for mt76.
**Step 4.3 — bug report**
Record: No syzbot/bugzilla. The series commit messages describe a concrete on-air failure (clients waiting for EOSP). Unverified: no public user stack trace beyond the author’s analysis.
**Step 4.4 — series context**
Record: 04 is the common-path EOSP fix. 05 is the mt7603 driver-PS-queue analogue. Taking 04 without 05 still fixes mac80211-buffered frames on **all** chips that use mt76_release_buffered_frames (mt76x0/x2, mt7615, mt7915, mt7921, and mt7603’s fallback).
**Step 4.5 — stable list**
Record: lore.kernel.org/stable/?q=mt76+EOSP+QoS → **No results found**. No recorded reason to skip it.
## Phase 5: Semantic / call graph
**Step 5.1 — functions**
Record: mt76_queue_ps_skb, mt76_release_buffered_frames.
**Step 5.2 — callers**
Record: mt76_queue_ps_skb only from mt76_release_buffered_frames. That is .release_buffered_frames for mt76x0, mt76x2, mt7615, mt7915, mt7921; mt7603 wraps it after draining msta->psq. mac80211 calls it from ieee80211_sta_ps_deliver_response() → drv_release_buffered_frames().
**Step 5.3 — callees**
Record: IEEE80211_SKB_CB, ieee80211_is_data_qos, ieee80211_get_qos_ctl, mt76_skb_set_moredata, __mt76_tx_queue_skb. No new locks/allocs.
**Step 5.4 — reachability**
Record: Yes, from the air. AP RX of a U-APSD trigger (ieee80211_sta_uapsd_trigger in mac80211.c / rx.c) → ieee80211_sta_ps_deliver_uapsd → driver release. This tree sets WIPHY_FLAG_AP_UAPSD. Typical trigger: a phone associated to an mt76 AP.
**Step 5.5 — similar patterns**
Record: mac80211 sta_info.c uses the same *qoshdr |= IEEE80211_QOS_CTL_EOSP. Sibling mt7603 patch 05 does the same for TXD- prefixed PS-queue frames (skb->data[MT_TXD_SIZE]). Common-path frames from ieee80211_tx_dequeue have the 802.11 header at skb->data (same as mt76_skb_set_moredata).
## Phase 6: This tree (5.15.221)
**Step 6.1 — buggy code present?**
Record: **Yes.** drivers/net/wireless/mediatek/mt76/tx.c mt76_queue_ps_skb() (lines 344–358) sets only IEEE80211_TX_STATUS_EOSP, not the QoS EOSP bit. Introduced v4.16; U-APSD AP enabled here since 2020.
git describe HEAD: p-5.15-2-g6703e5d2f3a29. make kernelversion:
**5.15.221**. git merge-base --is-ancestor 0b8d252471609 HEAD → **not present**.
**Step 6.2 — backport difficulty**
Record: **Clean apply.** git apply --check succeeded; hunks applied at offset −69 only because mt76_txq_dequeue still uses MT_TX_HW_QUEUE_EXT_PHY here vs FIELD_PREP(MT_TX_HW_QUEUE_PHY, …) upstream. That function is context, not part of the change.
**Step 6.3 — related fixes already here?**
Record: No. Only 7267a7965dd7b (TX status for the software EOSP flag), which is exactly the incomplete behavior this commit finishes.
## Phase 7: Subsystem
**Step 7.1**
Record: drivers/net/wireless/mediatek/mt76 — Wi-Fi driver. **IMPORTANT** (not core kernel, but widely used: OpenWrt/home routers, mt76x0/x2/7603/7615/7915/7921).
**Step 7.2**
Record: Mature driver; this PS-release path has been stable since 2017. Not a bug in brand-new code.
## Phase 8: Impact and risk
**Step 8.1 — who**
Record: Driver/config-specific: CONFIG_MT76* AP mode with U-APSD clients. Large real-world set (MediaTek AP SoCs).
**Step 8.2 — trigger**
Record: Associated STA in power-save using U-APSD (typical phones) sends a trigger; AP releases buffered QoS data. Not a rare error path. Unprivileged on the air (associated client). PS-Poll-only clients are unaffected by the new bit.
**Step 8.3 — failure mode**
Record: **Station downlink stall** until the client gives up the SP. Not a kernel oops. Severity: **HIGH** (loss of connectivity for that STA), not CRITICAL (no panic/corruption).
**Step 8.4 — risk/benefit**
Record: Benefit high for mt76 AP + U-APSD clients. Risk very low: ~12 lines, QoS bit only on last U-APSD QoS-data frame, same pattern as mac80211, clean apply, no API/struct change. Patch 01’s ieee80211_txq_aql_pending is **not** required.
## Phase 9: Synthesis
**Step 9.1 — evidence**
For:
- Real, documented 802.11 bug: missing on-air EOSP → downlink stall
- Code and AP U-APSD flag exist in 5.15.221
- Bug since v4.16
- Maintainer-authored, merged to mainline (v7.3-rc1), no revert, no later rewrite of this function
- 12 insertions / 4 deletions, clean apply
- Matches mac80211
- Standalone despite 04/10 numbering
Against:
- Not crash/security/corruption
- No Reported-by / syzbot
- No extra reviewer
- mt7603 hardware PS-queue still wrong without patch 05 (does not make 04 incorrect or unusable)
Unresolved: no independent end-user report found beyond the maintainer’s analysis.
**Step 9.2 — stable rules**
1. Obviously correct and tested? **PASS** — same as mac80211; in mainline since v7.3-rc1
2. Real bug affecting users? **PASS** — U-APSD clients on mt76 APs
3. Important? **PASS** — full downlink stall for the STA (HIGH)
4. Small/contained? **PASS** — one file, ~12 lines
5. No new features/APIs? **PASS** — sets a standard 802.11 bit the driver was already required to set
6. Applies to this tree? **PASS** — git apply --check clean
**Step 9.3 — exceptions**
Record: None (not an ID/quirk/DT/build/doc exception). Qualifies as a normal bugfix.
**Step 9.4 — decision**
This 5.15.221 tree has the buggy path, U-APSD AP support, and every API the patch needs. The change is a small, self-contained protocol fix for a serious AP-mode connectivity failure. It should be backported here.
---
### What it solves for 5.15 users
On MediaTek mt76 APs, U-APSD service periods never get the EOSP bit on the last released QoS frame. mac80211 thinks the SP ended (IEEE80211_TX_STATUS_EOSP), but the client never sees EOSP on the air, stops triggering, and **downlink to that station stalls**. Setting IEEE80211_QOS_CTL_EOSP on the last U-APSD QoS-data frame is what mac80211 already documents and implements when the driver does not take .release_buffered_frames.
### Stable rules / risk
Meets all six criteria. Benefit is restoring buffered downlink for U-APSD clients; risk is a one-bit header update on a path that already rewrites More Data. No series dependencies for this hunk. mt7603’s separate PS-queue EOSP bug is a sibling, not a blocker.
### Verification
- [Phase 1] Parsed tags: Link to 04/10, author SOB only; no Fixes/Reported-by/Cc:stable
- [Phase 1] git log origin/master --grep='set the EOSP bit' -- drivers/net/wireless/mediatek/mt76/: 0b8d252471609
- [Phase 1] git describe --contains --match 'v*' 0b8d252471609:
v7.3-rc1~133^2~99^2~15^2~8
- [Phase 2] Diff: mt76_queue_ps_skb + reason; EOSP OR on last U-APSD QoS-data frame; two call sites
- [Phase 2] Compared to net/mac80211/sta_info.c:1708 (*qoshdr |= IEEE80211_QOS_CTL_EOSP) — same mechanism
- [Phase 2] Confirmed include/net/mac80211.h requires the driver to set EOSP when .release_buffered_frames is implemented
- [Phase 3] git blame on tx.c 345–403: introduced 17f1de56df0512 (v4.16-rc1)
- [Phase 3] git log --grep='EOSP' -- drivers/net/wireless/mediatek/mt76/: only TX-status EOSP (7267a7965dd7b) in this tree
- [Phase 3] Patch 01 a547b414bf7ea does not touch mt76_queue_ps_skb (not a prerequisite)
- [Phase 4] b4 dig -c 0b8d252471609: lore URL above; b4 dig -a: v1 only; b4 dig -w: linux-wireless + author
- [Phase 4] 11-message mbox: no NAK on 04; kbuild error is on 10/10 / patch 01
- [Phase 4] curl stable lore for mt76 EOSP QoS: no results
- [Phase 5] Callers: mt76x0/x2, mt7615, mt7915, mt7921 ops; mt7603 wrapper; mac80211 drv_release_buffered_frames
- [Phase 5] This tree: WIPHY_FLAG_AP_UAPSD and ieee80211_sta_uapsd_trigger in mt76/mac80211.c
- [Phase 6] git describe HEAD: p-5.15-2-g6703e5d2f3a29; make kernelversion: 5.15.221
- [Phase 6] git merge-base --is-ancestor 0b8d252471609 HEAD: not in tree
- [Phase 6] git apply --check of 04/10: success, offset −69
- [Phase 6] APIs present: IEEE80211_QOS_CTL_EOSP 0x0010, ieee80211_get_qos_ctl, ieee80211_is_data_qos, IEEE80211_FRAME_RELEASE_UAPSD
- [Phase 8] Failure mode: STA downlink stall (HIGH), not oops
- UNVERIFIED: no independent user bugzilla/syzbot report; impact inferred from protocol + maintainer description
**YES**
drivers/net/wireless/mediatek/mt76/tx.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/tx.c +12 -4
@@ -415,16 +415,23 @@ mt76_txq_dequeue(struct mt76_phy *phy, struct mt76_txq *mtxq)static void mt76_queue_ps_skb (struct mt76_phy *phy,struct ieee80211_sta *sta, -struct sk_buff *skb,bool last) +struct sk_buff *skb,bool last, +enum ieee80211_frame_release_type reason) {struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv;struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb); +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; info->control.flags |=IEEE80211_TX_CTRL_PS_RESPONSE ; -if (last) +if (last) { info->flags |=IEEE80211_TX_STATUS_EOSP |IEEE80211_TX_CTL_REQ_TX_STATUS ; +if (reason ==IEEE80211_FRAME_RELEASE_UAPSD && +ieee80211_is_data_qos (hdr->frame_control)) + *ieee80211_get_qos_ctl (hdr) |=IEEE80211_QOS_CTL_EOSP ; + } +mt76_skb_set_moredata (skb, !last);__mt76_tx_queue_skb (phy,MT_TXQ_PSD , skb, wcid, sta,NULL ); }
@@ -457,14 +464,15 @@ mt76_release_buffered_frames(struct ieee80211_hw *hw, struct ieee80211_sta *sta, nframes--;if (last_skb) -mt76_queue_ps_skb (phy, sta, last_skb, false); +mt76_queue_ps_skb (phy, sta, last_skb, false, + reason); last_skb = skb; }while (nframes); }if (last_skb) { -mt76_queue_ps_skb (phy, sta, last_skb, true); +mt76_queue_ps_skb (phy, sta, last_skb, true, reason); dev->queue_ops->kick (dev, hwq); }else {ieee80211_sta_eosp (sta);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 pinctrl: npcm8xx: fix debounce register selection
In reply to Sasha LevinFrom: Tomer Maimon <[email protected]>
[ Upstream commit 602ee6c9447e4382c7e145b26a1c940813f2a144 ]
Each DBNCS register programs debounce source selection for 16 GPIOs. The current offset calculation advances the register address every four GPIOs, so offsets 4-15 and 20-31 end up touching the wrong selector register.
Advance the DBNCS offset per 16 GPIOs so each line uses the debounce selector bank that matches the hardware layout.
---
LLM Generated explanations, may be completely bogus:
The local checkout is **v7.3-rc4** (mainline 7.3.0-rc4). The candidate is a one-line DBNCS offset fix in the Nuvoton NPCM8XX pinctrl driver; the buggy formula has been in this file since the driver landed in v6.7.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[pinctrl/npcm8xx] [fix] [debounce DBNCS register offset is wrong for most GPIOs in a bank]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Tomer Maimon \<[email protected]\> (author; original NPCM8XX pinctrl driver author)
- Signed-off-by: Linus Walleij \<[email protected]\> (pinctrl 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)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** Each DBNCS register selects debounce source for 16 GPIOs. The driver advanced the register pointer every four GPIOs (gpio / 4 bytes).
- **Symptom:** GPIOs 4–15 and 20–31 program the wrong selector register (and, for most of those, an unaligned address).
- **Root cause:** Integer-division “simplification”: (gpio / 16) * 4 is not gpio / 4.
- **Version info:** None in the message. Driver introduced in v6.7-rc1.
- **Failure mode:** Hardware debounce source is programmed into the wrong MMIO location.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. Subject and body describe a register- selection bug. The 2022 pre-merge driver used gpio / 16 with a * 4 stride; mainline shipped the broken gpio / 4 form.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c (+2/−1)
- Function: debounce_timing_setting()
- Scope: single-file surgical fix (one expression)
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Hardware: NPCM8XX_GP_N_DBNCS0 at 0x80, DBNCS1 at 0x84; 2 bits per GPIO; 16 GPIOs per 32-bit register. Bit index (gpio % 16) * 2 was already correct.
- Before: base + 0x80 + (gpio / 4)
- gpio 0–3: 0x80 (DBNCS0, aligned)
- gpio 4–7: 0x81, 8–11: 0x82, 12–15: 0x83 (unaligned, inside DBNCS0)
- gpio 16–19: 0x84 (DBNCS1, accidentally correct)
- gpio 20–31: 0x85–0x87 (unaligned; 32-bit RMW can overlap DBNCP0 at
0x88)
- After: base + 0x80 + (gpio / 16) * 4 → 0x80 for 0–15, 0x84 for 16–31.
- Path: pinconf set of PIN_CONFIG_INPUT_DEBOUNCE only (not a probe/error-path change).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Logic / hardware programming]** Wrong MMIO offset. Matches the bit-field layout already in the same function. npcm_gpio_set() does iowrite32(ioread32(reg) | pinmask, reg) on that pointer.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct against DBNCS0/DBNCS1 at 0x80/0x84 and (gpio % 16) * 2. Minimal. Regression risk is very low: only the register address changes; GPIOs 0–3 and 16–19 keep the same address.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: Buggy line introduced in **acf4884a57170** (“pinctrl: nuvoton:
add NPCM8XX pinctrl and GPIO driver”, Tomer Maimon, 2023-09-11), contained in **v6.7-rc1**. Present until 602ee6c9447e4.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Bug is in the original driver merge, not a later regression.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Same-author series merged via pinctrl-v7.3-1 (drop RTS/CTS, RMII, RG2 drive strength, pending GPIO events, IRQ setup, pin flags, this debounce fix). This hunk does not depend on those other patches. Only other debounce commit on this path is the original driver add.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Tomer Maimon is the Nuvoton/NPCM pinctrl author. Linus Walleij applied the series. Recent npcm8xx work is a mix of pin-map corrections and one feature (RG2 drive strength). This commit is the debounce correctness fix.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Standalone. Uses NPCM8XX_GP_N_DBNCS0 and debounce_timing_setting() as they existed at driver introduction. No new helpers or struct fields.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 602ee6c9447e4 →
https://patch.msgid.link/[email protected]
- Subject: [PATCH v1 8/8] pinctrl: npcm8xx: fix debounce register selection (2026-07-15)
- b4 dig -a: only **v1**; applied version matches v1
- lore.kernel.org fetches returned **403**; patch text confirmed via LKML/openwall mirrors. No replies were visible on those mirror pages.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): [email protected], [email protected], [email protected], linux-gpio, openbmc, Nuvoton/Google BMC CCs. No Reviewed-by on the commit; maintainer SOB is Linus Walleij.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by, bugzilla, or syzbot link. Author-found hardware mapping error.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Patch 8/8 of an npcm8xx pin/group cleanup series. Other patches change groups, IRQ setup, or add RG2 drive strength. This offset change does not require them. Pre-merge 2022 v2 driver used int DBNCS_offset = gpio / 16 and DBNCS0 + (DBNCS_offset * 4) — the correct formula this commit restores.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search was not usable (403). No evidence this was discussed on stable@ from the mirrors that did load.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: debounce_timing_setting() only.
**Step 5.2: TRACE CALLERS**
Record:
- debounce_timing_setting() ← npcm_set_debounce() ← npcm8xx_config_set_one() on PIN_CONFIG_INPUT_DEBOUNCE ← npcm8xx_config_set() (pinconf_ops.pin_config_set)
- DT generic pinconf maps input-debounce to that param (pinconf- generic.c).
- **GPIO cdev debounce does not hit this path here:** gpio_generic_chip_init() does not set gc->set_config, and this driver never assigns gpiochip_generic_config. gpio_do_set_config() returns -ENOTSUPP; gpiolib-cdev then uses software debounce.
**Step 5.3: TRACE CALLEES**
Record: npcm_gpio_set() (32-bit RMW), iowrite32 of DBNCPx period registers, DIV_ROUND_CLOSEST for custom periods.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable when a pinctrl state applies input-debounce (boot DT or pin_config_set). No in-tree dts/dtsi uses input-debounce (verified). OpenBMC board DTs are often out of tree. Not a syscall hot path on this driver as wired today.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: npcm7xx has PIN_CONFIG_INPUT_DEBOUNCE cases but no DBNCS registers (NPCM8XX-specific adjustable debounce). No sibling 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. drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c is present. Pre-image at 602ee6c9447e4^ is + (gpio / 4). Bug since v6.7. This checkout already contains the fix (expected for a mainline candidate tree). PINCTRL_NPCM8XX depends on ARCH_NPCM || COMPILE_TEST.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply on the debounce formula. Surrounding gpio-generic API churn does not affect this one line. Expected backport difficulty:
**clean apply** on any tree that still has (gpio / 4) in debounce_timing_setting.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No earlier debounce-offset fix. git log --grep=debounce -- drivers/pinctrl/nuvoton/ only shows the original add and this commit.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **[pinctrl / Nuvoton NPCM8XX GPIO] [PERIPHERAL]** — Arbel BMC (ARM64 Cortex-A35), used on OpenBMC server BMCs. Not core mm/fs/net.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature driver (v6.7), recent concentrated npcm8xx pin-map/IRQ fixes in the 7.3 pinctrl pull. Debounce math had been unchanged since introduction.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Platform-specific:** NPCM8XX BMC boards that set pinctrl input-debounce. Not universal. No in-tree DT consumers found.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Applying hardware debounce via pinconf. Not every boot unless DT requests it. Unprivileged GPIO debounce ioctl does **not** reach this function on this driver (no set_config). Privilege/DT-dependent.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- Primary (author): wrong DBNCS register → debounce source not applied to the intended line; possible corruption of neighboring DBNCS/DBNCP fields via unaligned 32-bit RMW.
- Unaligned ioread32/iowrite32 on ARM64 Device mappings *can* alignment-fault; **no crash was reported**. Treat crash as possible, not verified.
- Severity: **MEDIUM** for functional debounce / adjacent-register corruption on this SoC; not a demonstrated panic/UAF/security hole.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** Makes hardware debounce match the documented 16-GPIO DBNCS banks for NPCM8XX users who enable it.
- **Risk:** Very low (one address expression; GPIOs that already hit 0x80/0x84 unchanged).
- **Ratio:** Favorable. Small correctness fix, not a feature.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR backporting:
- Real hardware programming bug, present since the driver was added (v6.7).
- Restores the mapping the author’s 2022 submission already used (gpio / 16 × 4-byte stride).
- Matches DBNCS0/DBNCS1 at 0x80/0x84 and the existing (gpio % 16) * 2 bit layout.
- 3-line, single-function, no API/feature change.
- Author is the driver writer; pinctrl maintainer applied it.
- Standalone; other 8/8 series patches not required.
- Applies on this tree’s pre-image without surrounding refactor.
AGAINST:
- Peripheral BMC pinctrl, not a core crash/security/corruption class as described.
- No Fixes/Cc:stable, no Reported-by/Tested-by (tags not required, but no field report).
- No in-tree input-debounce DT users; GPIO cdev debounce does not call this code.
- Series also contains non-stable material (e.g. RG2 drive strength); this patch itself is independent.
UNRESOLVED:
- Full lore thread (reviews/NAKs) unverified due to lore 403.
- Whether any OpenBMC DT actually sets input-debounce (not in this tree).
- Whether unaligned MMIO actually oopses on NPCM8XX (not reported).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — formula matches register layout; maintainer applied. No extra Tested-by.
2. Fixes a real bug that affects users? **PASS** — wrong DBNCS bank for 24/32 lines per bank when hardware debounce is configured.
3. Important issue (crash, security, corruption, deadlock)? **PASS** (borderline) — wrong MMIO and possible adjacent-register RMW; not a documented oops. Still a hardware-feature break on a production BMC SoC, which stable routinely takes in pinctrl/gpio.
4. Small and contained? **PASS** — +2/−1, one function.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — same file/function; pre-image is the buggy line.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary small driver correctness fix.
**Step 9.4: MAKE YOUR DECISION**
This tree has the NPCM8XX driver and the long-standing gpio / 4 bug. The patch is a minimal, obviously correct register-index fix with no dependencies. Benefit is limited to NPCM8XX debounce configuration, but the risk of taking it is negligible and the bug is real. That meets stable criteria for this checkout.
------------------------------------------------
What the commit solves, for stable users
------------------------------------------------
Hardware debounce on NPCM8XX is supposed to use DBNCS0 for GPIOs 0–15 and DBNCS1 for 16–31. Integer division turned (gpio / 16) * 4 into gpio / 4, so most lines wrote the wrong (often unaligned) address. Boards that set pinctrl input-debounce would not get the intended debounce source and could disturb neighboring debounce-period registers. The fix is one address expression.
Risk vs benefit: very low risk, modest but real benefit for NPCM8XX BMC GPIO debounce. No series dependencies.
Verification:
- [Phase 1] Parsed commit 602ee6c9447e4: SOB Tomer Maimon + Linus Walleij; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: one expression in debounce_timing_setting(); DBNCS0=0x80, DBNCS1=0x84 confirmed in this file
- [Phase 2] npcm_gpio_set() is 32-bit RMW at the computed pointer (lines 124–129)
- [Phase 3] git blame on parent: acf4884a57170 (v6.7-rc1) introduced (gpio / 4)
- [Phase 3] git merge-base --is-ancestor acf4884a57170 HEAD → yes; fix is ancestor of HEAD
- [Phase 3] git log --grep=debounce -- drivers/pinctrl/nuvoton/ → only driver add + this fix
- [Phase 4] b4 dig -c 602ee6c9447e4 → msgid 20260715122923.1938327-9; v1 8/8; recipients linusw, brgl, openbmc
- [Phase 4] Pre-merge 2022 v2 used gpio / 16 and * 4 (lists.ozlabs.org OpenBMC archive)
- [Phase 4] lore.kernel.org 403 — full review thread UNVERIFIED; LKML/openwall showed the patch text only
- [Phase 5] Callers: npcm_set_debounce ← npcm8xx_config_set_one PIN_CONFIG_INPUT_DEBOUNCE
- [Phase 5] This driver has no gc->set_config; GPIO cdev debounce does not reach this function
- [Phase 5] rg input-debounce on dts/dtsi: no matches
- [Phase 6] git describe HEAD → v7.3-rc4-27-gf0100363d8c37; make kernelversion → 7.3.0-rc4
- [Phase 6] Parent of fix still has (gpio / 4); apply is clean
- [Phase 8] Failure mode: wrong debounce MMIO; crash via unaligned access UNVERIFIED
- UNVERIFIED: OpenBMC out-of-tree DT debounce use; stable@ discussion; review NAKs
**YES**
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c +2 -1
@@ -2135,7 +2135,8 @@ static const struct pinmux_ops npcm8xx_pinmux_ops = {static int debounce_timing_setting (struct npcm8xx_gpio *bank,u32 gpio,u32 nanosecs) { -void __iomem *DBNCS_offset = bank->base +NPCM8XX_GP_N_DBNCS0 + (gpio /4 ); +void __iomem *DBNCS_offset = bank->base +NPCM8XX_GP_N_DBNCS0 + + (gpio /16 ) *4 ;int gpio_debounce = (gpio %16 ) *2 , debounce_select, i;u32 dbncp_val, dbncp_val_mod;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 exfat: write moved entry before removing source
In reply to Sasha LevinFrom: Yichong Chen <[email protected]>
[ Upstream commit 896fcc93574fd511ee04a4110e8ea59d6d8d43d7 ]
exfat_move_file() removes the old directory entry before the new entry has been written. If writing the new entry fails, rename returns an error after the source entry has already been marked deleted.
Write the new entry first, then remove the old entry and update the cached inode location. This keeps the source entry intact if creating the destination entry fails.
---
LLM Generated explanations, may be completely bogus:
This commit is a small filesystem data-loss fix: cross-directory rename deleted the source before the destination write succeeded. Local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37); the change is already in this history as 896fcc93574fd (v7.3-rc1). The question is whether it is technically worth sending to stable.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[exfat]** **[write … before]** write the destination directory entry before removing the source during a move.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Yichong Chen <[email protected]> (author)
- Signed-off-by: Namjae Jeon <[email protected]> (exFAT maintainer)
- 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 signal
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** exfat_move_file() marks the old directory entry deleted before the new entry is written.
- **Symptom:** A failed destination write still returns an error from rename, but the source is already gone.
- **Root cause:** Wrong operation order (remove source, then exfat_put_dentry_set() of the new set).
- **Fix:** Write the new entry first; only then remove the old entry and update the cached inode location.
- **Version info:** None in the message. Git: landed in v7.3-rc1; author date 2026-07-27.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. The message describes a real rename error-path data-loss bug.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: fs/exfat/namei.c only (5 insertions, 5 deletions)
- Function: exfat_move_file()
- Scope: single-file surgical reorder of existing statements; no new helpers or APIs
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: **Before** (parent of 896fcc93574fd):
1. Copy file/stream entries into the new set and call exfat_init_ext_entry()
2. exfat_remove_entries() on the source (mov_es)
3. Update ei->dir / ei->entry to the destination
4. exfat_put_dentry_set(&new_es, …) to write the destination
5. On failure: best-effort delete of the *new* entries, then goto put_mov_es (source already deleted in memory)
**After:** steps 4 then 2–3. Destination write is attempted first. On failure the source is still intact; only the incomplete destination is cleaned up.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** logic/correctness; filesystem metadata loss on I/O error
- **Mechanism:** exfat_remove_entries() only marks dentries TYPE_DELETED in the cached set (dir.c). Durability happens in exfat_put_dentry_set() → exfat_update_bhs(). That returns -EIO when sync is set (IS_DIRSYNC) and a buffer is not uptodate after wait. On error, exfat_put_dentry_set() bforget()s the destination buffers.
- Combined with 942296784b2a9 (v7.2-rc1), which added “best-effort delete” of the *new* entries on that failure: source already deleted **and** destination discarded/deleted → the file can disappear.
- Same-directory exfat_rename_file() already wrote the new set before removing the old one after 942296784b2a9. Only the cross-directory path was wrong.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: matches exfat_rename_file() and the pre-v6.9 write-then-remove order.
- Minimal: three statements moved, no unrelated edits.
- Residual risk: if the destination write succeeds and the source-delete write later fails, both names can exist (duplicate entries). That is better than losing the file. No new locks, APIs, or data structures.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Original 2020 exfat_move_file() (5f2aa075070cf, v5.7 era) wrote destination buffers with exfat_update_bh() **before** exfat_remove_entries().
- The inverted order was introduced by d97e060673906d (“exfat: convert exfat_init_ext_entry() to use dentry cache”, contained in **v6.9-rc1**). That commit batched destination writes into exfat_put_dentry_set(&new_es) but left exfat_remove_entries() *before* that put.
- 942296784b2a9 (v7.2-rc1) added the dest-cleanup error path while keeping the bad order, making loss complete on that path.
- 896fcc93574fd (Yichong Chen, 2026-07-27) restores write-then-remove.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The buggy conversion is d97e060673906d (v6.9-rc1), present in this tree (git merge-base --is-ancestor succeeded). 942296784b2a9 is also in this tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Immediate predecessor in fs/exfat/: 942296784b2a9 (preserve benign secondary entries; Cc: stable)
- Follow-ups by the same author, independent: ce12a39bed483 (free dir cluster on zeroing failure), 0901a71e8cff5 (cleanup on exfat_add_entry() write failure)
- Standalone ordering fix, not “patch X/Y”
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Yichong Chen is a recent exFAT contributor (three error-path fixes in this cycle), not the listed maintainer. Maintainer Namjae Jeon applied the patch.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record:
- Clean apply of *this* diff assumes 942296784b2a9 (4-arg exfat_init_ext_entry(), free_benign on exfat_remove_entries(), best-effort dest delete). Both are in this 7.3 tree.
- The reorder itself does not need new functions. It can stand alone here.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 896fcc93574fd: https://patch.msgid.link/20260727091214.355
[email protected]
- b4 dig -a: **v1 only**, no later revisions
- Thread (mbox): submission + maintainer reply. Namjae Jeon: “Applied it to #dev.” No NAK, no requested changes.
- lore.kernel.org / patch.msgid.link HTTP fetch returned 403; discussion recovered via b4 dig -m and public mirrors (spinics, LKML, Patchew).
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc Namjae Jeon, Sungjong Seo (maintainers), Yuezhang Mo (reviewer), [email protected], linux- [email protected]. Maintainer applied it; no extra Reviewed-by on the commit.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by or bugzilla/syzbot link. Bug found by code inspection of the error path, not a public crash report.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone v1. Related later patches target exfat_add_entry() / exfat_alloc_new_dir(), not this reorder.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No dedicated stable-list discussion of this subject was found. 942296784b2a9 (prerequisite context) *did* carry Cc: stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: exfat_move_file() only.
**Step 5.2: TRACE CALLERS**
Record:
- exfat_move_file() ← __exfat_rename() when new_parent_inode != old_parent_inode
- __exfat_rename() ← exfat_rename() (inode_operations.rename)
- Userspace trigger: rename() / mv across directories on an exFAT mount
- Same-directory rename uses exfat_rename_file(), already ordered correctly
**Step 5.3: TRACE CALLEES**
Record: exfat_init_ext_entry(), exfat_put_dentry_set() / exfat_update_bhs(), exfat_remove_entries(), exfat_get_dentry_set() on the error path. No allocations or new locks.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable from the rename syscall. Failure of exfat_put_dentry_set(&new_es) is a DIRSYNC/sync write -EIO (exfat_update_bhs() only waits when sync is set). That is the dirsync mount option or S_DIRSYNC on the directory. Unprivileged users with write access to the volume can hit the path; the I/O-error half needs a failed dest directory write.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: exfat_rename_file() already put the new set, then removed the old set, after 942296784b2a9. This commit makes exfat_move_file() match that.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes, in this tree’s history. d97e060673906d (v6.9) and 942296784b2a9 (v7.2) are ancestors of HEAD. Current fs/exfat/namei.c already has the fixed order at exfat_move_file() (write new, then exfat_remove_entries()).
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: On **this** 7.3-rc4 tree the patch applies (it is already merged). Context matches 942296784b2a9.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This exact fix is already HEAD-reachable (git merge-base --is- ancestor 896fcc93574fd HEAD). No later revert or competing fix on exfat_move_file().
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **exFAT** (fs/exfat/). **IMPORTANT** — not VFS core, but a widely used filesystem (SD cards, USB sticks, Android/Windows interchange). Metadata loss on rename is user-visible data loss.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained (Namjae Jeon / Sungjong Seo; frequent 7.2–7.3 exFAT pulls). This is a targeted error-path fix, not a drive-by refactor.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Users of CONFIG_EXFAT_FS who cross-directory rename/move. Default mounts without dirsync rarely take the -EIO return from exfat_put_dentry_set() (non-sync exfat_update_bhs() only dirties buffers). dirsync / S_DIRSYNC plus dest write failure is the concrete fail path.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Cross-directory rename() on exFAT
- Destination directory-entry write fails (IS_DIRSYNC + I/O error)
- Not a race; sequential error handling
- Unprivileged if they can write the volume
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Source directory entry marked deleted, destination write discarded (bforget), then best-effort delete of dest → **file disappears / orphaned clusters**. **Severity: CRITICAL** (data loss), even though the trigger is an I/O error path.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** Prevents losing a file when cross-dir rename hits a dest write error; also stops 942296784b2a9’s dest-cleanup from deleting the only remaining name.
- **Risk:** Very low (10-line reorder, same pattern as exfat_rename_file()).
- **Ratio:** High benefit / very low risk.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real filesystem data-loss bug, not style
- Small, obviously correct reorder
- Matches the already-correct exfat_rename_file() path
- Bug introduced in v6.9 (d97e060673906d); made worse in v7.2 (942296784b2a9, which was Cc: stable)
- Maintainer applied v1 with no objections
- No new features/APIs; applies in this tree’s code
- Reachable from rename(2)
AGAINST:
- No public user report / syzbot / Fixes: tag
- Trigger needs DIRSYNC (or equivalent) plus dest I/O error — uncommon
- No Tested-by
- This 7.3-rc4 checkout already contains the commit (does not reduce technical merit for stable)
UNRESOLVED:
- Could not HTTP-fetch lore.kernel.org (403); thread recovered via b4 dig -m and mirrors
- No evidence this was discussed on stable@ (search did not turn up this subject)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — ordering is clearly right; maintainer applied it. No extra tester tag, but the change is reviewable from the code.
2. Fixes a real bug that affects users? **PASS** — rename can drop the source name on dest write failure.
3. Important issue? **PASS** — data loss / missing directory entry. **CRITICAL**
4. Small and contained? **PASS** — ±5 lines, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — already present; context with 942296784b2a9 is here
**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 surgical fix for metadata loss on cross-directory exFAT rename. The wrong order has been in the dentry-cache path since v6.9 and became fully destructive with v7.2’s dest-cleanup. Benefit is preventing file disappearance; regression risk is negligible. It meets stable rules for this tree’s exFAT code.
Verification:
- [Phase 1] Parsed tags: only author + maintainer SOBs; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: 5+/5- in exfat_move_file(); moved exfat_remove_entries + ei->dir/ei->entry to after successful exfat_put_dentry_set(&new_es)
- [Phase 2] exfat_put_dentry_set/exfat_update_bhs: -EIO only when sync and buffer not uptodate; error path bforget()s dest buffers
- [Phase 3] git describe HEAD / make kernelversion: v7.3-rc4 / 7.3.0-rc4
- [Phase 3] git show 896fcc93574fd: commit 896fcc93574fd511ee04a4110e8ea59d6d8d43d7
- [Phase 3] git merge-base --is-ancestor 896fcc93574fd HEAD: yes (already in this tree)
- [Phase 3] git describe --contains 896fcc93574fd: v7.3-rc1~87^2~6
- [Phase 3] git merge-base --is-ancestor d97e060673906d HEAD: yes; contained in v6.9-rc1 (introduced remove-before-put)
- [Phase 3] git merge-base --is-ancestor 942296784b2a9 HEAD: yes; v7.2-rc1 (dest-cleanup error path)
- [Phase 3] git blame fs/exfat/namei.c around the hunk: reorder attributed to 896fcc93574fd; dest-cleanup to 942296784b2a9
- [Phase 3] Original 2020 exfat_move_file wrote dest with exfat_update_bh before exfat_remove_entries
- [Phase 4] b4 dig -c/-a/-w/-m: v1 only; maintainers CC’d; Namjae Jeon applied to #dev; no NAK
- [Phase 4] lore HTTP 403; mbox + Patchew/LKML/spinics confirm the same thread
- [Phase 4] No stable@ hit for this subject
- [Phase 5] Callers: only __exfat_rename() → exfat_rename() (VFS rename), cross-directory only
- [Phase 6] Current namei.c already has the fixed order; no later revert
- [Phase 7] MAINTAINERS: Namjae Jeon, Sungjong Seo; reviewer Yuezhang Mo
- [Phase 8] Failure mode verified in code: source deleted in cache, dest write failed/forgotten, then dest also removed
- UNVERIFIED: whether any particular older stable series already carried a handwritten equivalent (not needed for this 7.3 tree)
**YES**
fs/exfat/namei.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/exfat/namei.c +5 -5
@@ -1156,11 +1156,6 @@ static int exfat_move_file(struct inode *parent_inode,exfat_init_ext_entry (&new_es, num_new_entries, p_uniname, &mov_es, num_extra_entries); -exfat_remove_entries (parent_inode, &mov_es,ES_IDX_FILE , false); - - ei->dir = newdir; - ei->entry = newentry; - ret =exfat_put_dentry_set (&new_es,IS_DIRSYNC (parent_inode));if (ret) {/* Best-effort delete to avoid duplicate entries */
@@ -1174,6 +1169,11 @@ static int exfat_move_file(struct inode *parent_inode, goto put_mov_es; } +exfat_remove_entries (parent_inode, &mov_es,ES_IDX_FILE , false); + + ei->dir = newdir; + ei->entry = newentry; +return exfat_put_dentry_set (&mov_es,IS_DIRSYNC (parent_inode)); put_mov_es:
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 usb: fsl_qe_udc: check qe_alloc_request() failure in ch9getstatus()
In reply to Sasha LevinFrom: Haoxiang Li <[email protected]>
[ Upstream commit 612551bf7cf7113b8bbd5e8c1eea86d9427c2f95 ]
qe_alloc_request() may return NULL on allocation failure. ch9getstatus() passes the return value directly to container_of() and then immediately dereferences the resulting qe_req pointer. Check the allocation result before using it and stall the control request on failure.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: [usb / fsl_qe_udc] [check] check qe_alloc_request() failure in ch9getstatus() — USB gadget UDC driver; “check” here is a missing-NULL- check fix, not a feature.
**Step 1.2: Tags**
Record:
- Signed-off-by: Haoxiang Li <[email protected]> (author)
- `Link: https://patch.msgid.link/20260620120631.2894977-1-
[email protected]`
- Signed-off-by: Greg Kroah-Hartman <[email protected]> (USB maintainer applied it)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, or Cc: stable (absence expected)
**Step 1.3: Body**
Record:
- **Bug:** qe_alloc_request() can return NULL; that pointer is passed to container_of() and immediately dereferenced.
- **Symptom:** kernel oops / NULL deref on GET_STATUS when allocation fails.
- **Version info:** none in the message.
- **Root cause:** unchecked allocation result in ch9getstatus().
- **Fix:** test the pointer; stall EP0 on failure.
**Step 1.4: Hidden bug fix?**
Record: Not hidden. This is an explicit NULL-deref fix. The “stall on failure” path is the existing error path, not a new feature.
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- File: drivers/usb/gadget/udc/fsl_qe_udc.c (+6 / −2)
- Function: ch9getstatus()
- Scope: single-file surgical fix
**Step 2.2: Code flow**
Record: Before, container_of(qe_alloc_request(...), struct qe_req, req) ran unconditionally, then req->req.length = 2 and later __qe_ep_queue(). After, the result is stored in usb_req, NULL goes to the existing stall: label (dev_err + qe_ep0_stall()), and only a live request is converted with container_of.
**Step 2.3: Bug mechanism**
Record: **NULL pointer dereference** (memory safety). qe_alloc_request() does kzalloc_obj() and returns NULL on failure. struct qe_req has struct usb_request req as the first member, so container_of(NULL, ...) is still NULL, then req->req.length = 2 oopses.
**Step 2.4: Fix quality**
Record: Obviously correct; uses the existing stall path; no API/data- structure change. Regression risk is very low. Pre-existing issue not introduced here: if alloc succeeds and __qe_ep_queue() fails, the request is still not freed (leak on that older path). This patch does not make that worse.
## Phase 3: Git history
**Step 3.1: Blame**
Record: Unchecked container_of(qe_alloc_request(...)) comes from 3948f0e0c999a6 (“usb: add Freescale QE/CPM USB peripheral controller driver”, 2008-09-02), first in v2.6.28-rc1. The bug is ancient, not new 7.3 code.
**Step 3.2: Fixes: tag**
Record: No Fixes: tag. The introducing commit is 3948f0e0c999a6 (above). That commit is an ancestor of this tree.
**Step 3.3: File history**
Record: Related work on the same function: ce9daa2efc087 (2023) added pipe >= USB_MAX_ENDPOINTS before indexing udc->eps[] — that patch was AUTOSEL’d into stable 5.15. Recent file churn is kmalloc→kzalloc_obj conversion, not a refactor of ch9getstatus(). Standalone, not patch X/Y.
**Step 3.4: Author**
Record: Haoxiang Li has several USB NULL/leak-style fixes (mtu3, cdnsp, typec, renesas_usbhs). Not the UDC maintainer. Greg Kroah- Hartman applied this one. Similar sibling: 4ab2b48c98f2e (fsl_udc_core allocation check).
**Step 3.5: Dependencies**
Record: None. Uses existing qe_alloc_request(), stall: / qe_ep0_stall(), and container_of. Applies standalone. qe_alloc_request() still returns NULL on failure after the kzalloc_obj conversion.
## Phase 4: Mailing list / external
**Step 4.1: Original discussion**
Record: b4 dig -c 612551bf7cf71 → https://patch.msgid.link/20260620120
[email protected]b4 dig -a: **v1 only**, 2026-06-20, same subject. Mbox is the patch with **no replies**. LKML/Openwall mirrors match; no NAK, no v2, no `Cc:
stable` in review (there was no public review thread).
**Step 4.2: Recipients (b4 dig -w)**
Record: To: [email protected], [email protected]; Cc: linux- usb, linuxppc-dev, linux-kernel. USB maintainer was in To and committed it.
**Step 4.3: Bug report**
Record: No Reported-by / syzbot / bugzilla. Looks like static analysis (NULL after alloc), not a user crash report.
**Step 4.4: Series**
Record: Standalone v1. Not part of a multi-patch series.
**Step 4.5: Stable list**
Record: Direct lore.kernel.org fetches returned 403. No stable-list discussion found via b4 or web search. Precedent: the earlier ch9getstatus bounds check in this file **was** AUTOSEL’d to 5.15.
## Phase 5: Semantic / call-graph
**Step 5.1: Functions**
Record: ch9getstatus() only (uses qe_alloc_request, container_of, __qe_ep_queue, qe_ep0_stall).
**Step 5.2: Callers**
Record: Only setup_received_handle() on USB_REQ_GET_STATUS.
**Step 5.3: Callees**
Record: qe_alloc_request → kzalloc_obj; __qe_ep_queue; qe_ep0_stall; ownercomplete kfree’s the request on completion.
**Step 5.4: Call chain / reachability**
Record:qe_udc_irq (hardirq, spin_lock_irqsave(&udc->lock))
→ rx_irq → qe_ep0_rx → ep0_setup_handle → setup_received_handle → ch9getstatus
Reachable from USB host GET_STATUS during gadget enumeration. Unprivileged **host** can send it; not a typical local-syscall path. GFP_KERNEL under a spinlock in IRQ is a pre-existing atomic-sleep smell and makes NULL more plausible under memory pressure.
**Step 5.5: Similar patterns**
Record: qe_alloc_request() is only used here plus the usb_ep_ops.alloc_request hook. Sibling FSL UDC had the same class of alloc-check fix.
## Phase 6: This checkout
**Step 6.1: Does the buggy code exist?**
Record: Local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). Driver and ch9getstatus() are present. The unchecked alloc was introduced in v2.6.28 and lived until 612551bf7cf71 (v7.2-rc1-40, 2026-07-10). HEAD already has the fixed form (usb_req = qe_alloc_request...; if (!usb_req) goto stall). That is the mainline source of the candidate, not a reason to treat the bug as absent from this driver.
**Step 6.2: Backport difficulty**
Record: Surrounding ch9getstatus() matches the patch; git diff 612551bf7cf71 HEAD -- drivers/usb/gadget/udc/fsl_qe_udc.c is empty. Clean apply on this tree’s file; older stables still have the same container_of(qe_alloc_request(...)) shape from 2008.
**Step 6.3: Related fixes already here**
Record: Endpoint-index check ce9daa2efc087 is already in this file. No other fix covers the alloc NULL. This patch is the alloc-failure check, not a duplicate of that bounds check.
## Phase 7: Subsystem context
**Step 7.1:** Record: USB gadget UDC (drivers/usb/gadget/udc/). **PERIPHERAL** — Freescale QE/CPM USB device controller. CONFIG_USB_FSL_QE depends on FSL_SOC && (QUICC_ENGINE || CPM) and !64BIT || BROKEN (32-bit PowerPC QE/CPM, e.g. MPC8360/MPC8272).
**Step 7.2:** Record: Mature, low-churn driver (2008). Recent commits are conversions/typos plus this NULL check. Long-lived bug, not a new- subsystem issue.
## Phase 8: Impact and risk
**Step 8.1: Who is affected**
Record: Driver-specific / config-specific: USB gadget on 32-bit Freescale QE/CPM SoCs.
**Step 8.2: Trigger**
Record: Host sends standard GET_STATUS; qe_alloc_request(GFP_KERNEL) fails. Uncommon (memory pressure / atomic GFP_KERNEL), but the control request is a normal enumeration path. Host-triggered.
**Step 8.3: Failure mode**
Record: NULL deref → oops in hardirq UDC path. **Severity: HIGH** (crash of the gadget/UDC path; can take the machine down depending on panic_on_oops). Not silent corruption.
**Step 8.4: Risk vs benefit**
Record: **Benefit:** medium for those boards (prevents oops), low globally (niche HW). **Risk:** very low (6 net lines, existing stall path). Ratio favors taking it: same class of fix already AUTOSEL’d in this function.
## Phase 9: Synthesis
**Step 9.1: Evidence**
For:
- Real NULL deref on a live USB control path
- qe_alloc_request() documented to return NULL
- Tiny, obviously correct check + existing stall
- Bug present since 2008 in this driver
- USB maintainer merged it
- Same function already had a stable AUTOSEL bounds fix
- Call path is IRQ + spinlock, so GFP_KERNEL failure is not purely theoretical
Against:
- Niche 32-bit PowerPC QE/CPM gadget (BROKEN on 64-bit)
- No user/syzbot report; static-analysis style v1 with no mailing-list review
- No Tested-by
- Alloc-failure is uncommon
- Pre-existing queue-failure leak left unfixed (not a regression)
Unresolved: lore.kernel.org HTTP 403; no public review comments beyond the patch itself (confirmed via b4 mbox).
**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** on correctness (code is unambiguous). Testing is only “merged by Greg”; no hardware Tested- by, but the change does not need runtime proof beyond reading qe_alloc_request().
2. Real bug affecting users? **PASS** — oops if this UDC handles GET_STATUS and alloc fails.
3. Important (crash/security/corruption/deadlock)? **PASS** — kernel oops. Not a new API.
4. Small and contained? **PASS** — 8-line hunk, one function.
5. No new features/APIs? **PASS**
6. Can apply to this tree? **PASS** — file and function exist; context matches.
**Step 9.3: Exception category**
Record: None (not an ID/quirk/DT/build/doc exception). It is a normal crash fix.
**Step 9.4: Decision**
This is a textbook missing-NULL-check on a kmalloc-backed helper, in a path a USB host hits with GET_STATUS. It is small, applies to the driver in this tree, and prevents an oops. Niche hardware lowers population, not severity for the people who have it. It meets stable- kernel-rules.
### What it solves for stable users
Without the check, ch9getstatus() oopses when qe_alloc_request() returns NULL. With it, EP0 stalls and the gadget stays up. That matters on QE/CPM gadget devices under memory pressure, including in hardirq.
### Risk vs benefit
Very low risk, contained error-path change. Benefit is avoiding a real oops on existing hardware. Worth taking.
---
Verification:
- [Phase 1] Parsed tags: author SOB, Greg KH SOB, msgid link; no Fixes/Reported-by/Cc stable
- [Phase 2] Diff: +6/−2 in ch9getstatus(); NULL check then existing stall:
- [Phase 2] struct qe_req: req is first member (fsl_qe_udc.h:252-259); container_of(NULL) is NULL
- [Phase 2] qe_alloc_request() returns NULL after kzalloc_obj failure (lines 1669–1681)
- [Phase 3] git blame / git log -1 3948f0e0c999a6: buggy pattern from 2008, v2.6.28-rc1
- [Phase 3] No Fixes tag; introducing commit is in this tree
- [Phase 3] Related: ce9daa2efc087 bounds check in same function; AUTOSEL 5.15 (lkml archive)
- [Phase 3] Author USB fixes listed via git log --author="Haoxiang Li"
- [Phase 4] b4 dig -c 612551bf7cf71: lore msgid 20260620120631.2894977-1
- [Phase 4] b4 dig -a: v1 only; b4 dig -w: gregkh + kees + linux-usb
+ linuxppc-dev
- [Phase 4] mbox: patch only, no replies
- [Phase 4] lore WebFetch 403; LKML/Openwall mirrors used instead
- [Phase 5] Callers: only setup_received_handle for USB_REQ_GET_STATUS
- [Phase 5] Call chain: qe_udc_irq → rx_irq → qe_ep0_rx → ep0_setup_handle → setup_received_handle → ch9getstatus (spinlock held)
- [Phase 6] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion: 7.3.0-rc4
- [Phase 6] git merge-base --is-ancestor 612551bf7cf71 HEAD: yes (mainline already contains the candidate)
- [Phase 6] File at HEAD matches the fixed version; reverse-apply of the commit succeeds
- [Phase 7] Kconfig USB_FSL_QE: FSL_SOC QE/CPM, !64BIT || BROKEN
- [Phase 8] Failure mode: NULL deref oops in UDC IRQ, severity HIGH
- UNVERIFIED: full lore thread beyond the mbox (HTTP 403); whether any reviewer privately asked for Cc: stable
**YES**
drivers/usb/gadget/udc/fsl_qe_udc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/usb/gadget/udc/fsl_qe_udc.c +6 -2
@@ -1945,6 +1945,7 @@ static void ch9getstatus(struct qe_udc *udc, u8 request_type, u16 value, u16 index, u16 length) {u16 usb_status =0 ; +struct usb_request *usb_req;struct qe_req *req;struct qe_ep *ep;int status =0 ;
@@ -1983,8 +1984,11 @@ static void ch9getstatus(struct qe_udc *udc, u8 request_type, u16 value, } } - req =container_of (qe_alloc_request (&ep->ep,GFP_KERNEL ), - struct qe_req, req); + usb_req =qe_alloc_request (&ep->ep,GFP_KERNEL ); +if (!usb_req) + goto stall; + + req = container_of(usb_req, struct qe_req, req); req->req.length =2 ; req->req.buf = udc->statusbuf; *(u16 *)req->req.buf =cpu_to_le16 (usb_status);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] usb: fsl_qe_udc: check qe_alloc_request() failure in ch9getstatus()
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] usb: fsl_qe_udc: sleeping allocation in atomic context in ch9getstatus() - [Medium] usb…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] usb: fsl_qe_udc: sleeping allocation in atomic context in ch9getstatus()
- [Medium] usb: fsl_qe_udc: memory leak in ch9getstatus() when __qe_ep_queue() fails --
commit 130ef9b6cbb58e7a139f83239ccf232ff79a3793
Author: Haoxiang Li <[email protected]>
usb: fsl_qe_udc: check qe_alloc_request() failure in ch9getstatus()
This commit adds a NULL check for the return value of qe_alloc_request() in ch9getstatus() before passing it to container_of() and dereferencing it, stalling the endpoint on allocation failure.
Quoted 13 lines
drivers/usb/gadget/udc/fsl_qe_udc.c +1
-0@@ -1945,6 +1945,7 @@ static void ch9getstatus(struct qe_udc *udc, u8 request_type, u16 value, u16 index, u16 length) {u16 usb_status =0 ; +struct usb_request *usb_req;struct qe_req *req;struct qe_ep *ep;int status =0 ;
drivers/usb/gadget/udc/fsl_qe_udc.c static void ch9getstatus(struct qe_udc *udc, u8 request_type, u16 value, · line 1987
Quoted 6 lines
drivers/usb/gadget/udc/fsl_qe_udc.c +1
-2@@ -1983,8 +1984,11 @@ static void ch9getstatus(struct qe_udc *udc, u8 request_type, u16 value, } } - req =container_of (qe_alloc_request (&ep->ep,GFP_KERNEL ), - struct qe_req, req); + usb_req =qe_alloc_request (&ep->ep,GFP_KERNEL );
[Severity: High]
Should this allocation in ch9getstatus() use GFP_ATOMIC instead of GFP_KERNEL?
When a USB_REQ_GET_STATUS control request is received, ch9getstatus() is called from the hardware interrupt handler while holding udc->lock with interrupts disabled:
qe_udc_irq()
spin_lock_irqsave(&udc->lock, flags)
rx_irq()
qe_ep0_rx()
ep0_setup_handle()
setup_received_handle()
ch9getstatus()
qe_alloc_request(&ep->ep, GFP_KERNEL)
kzalloc(sizeof(*req), gfp_flags)Passing GFP_KERNEL here allows kzalloc() to sleep in atomic context.
drivers/usb/gadget/udc/fsl_qe_udc.c static void ch9getstatus(struct qe_udc *udc, u8 request_type, u16 value, · line 1994
Quoted 7 lines
drivers/usb/gadget/udc/fsl_qe_udc.c +4
-0+if (!usb_req) + goto stall; + + req = container_of(usb_req, struct qe_req, req); req->req.length =2 ; req->req.buf = udc->statusbuf; *(u16 *)req->req.buf =cpu_to_le16 (usb_status);
[Severity: Medium]
Can this path in ch9getstatus() also leak req if __qe_ep_queue() fails?
Just below this hunk, ch9getstatus() queues the allocated request:
drivers/usb/gadget/udc/fsl_qe_udc.c:ch9getstatus() {
...
status = __qe_ep_queue(&ep->ep, &req->req);
if (status == 0)
return;
stall:
dev_err(udc->dev, "Can't respond to getstatus request \n");
qe_ep0_stall(udc);
}In __qe_ep_queue(), if !udc->driver or udc->gadget.speed == USB_SPEED_UNKNOWN, it returns -ESHUTDOWN before adding req->queue to ep->queue, so ownercomplete() will never be called to free req:
drivers/usb/gadget/udc/fsl_qe_udc.c:__qe_ep_queue() {
...
if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN)
return -ESHUTDOWN;
...
}When __qe_ep_queue() returns a non-zero status, ch9getstatus() falls through to stall: without calling qe_free_request(&ep->ep, usb_req) or kfree(req).
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/realtek: add missing error checks for COEF index reads in alc269
In reply to Sasha LevinFrom: Bob Song <[email protected]>
[ Upstream commit 5b106b40ed22098f2bc049efb645148d038444bd ]
alc_read_coef_idx() and alc_read_coefex_idx() can return -1 on error via snd_hda_codec_read(). Several codec initialization and shutdown functions save these return values and later write them back to hardware registers without checking for errors, potentially corrupting COEF register state on a read failure.
Add error checks in:
- alc282_init() and alc282_shutup(): check coef78 before write-back
- alc285_hp_init(): check coef38/coef0d/coef36 before update, check val before write-back, and break polling loop on error
- alc294_hp_init(): break polling loop on read error
---
LLM Generated explanations, may be completely bogus:
This tree is **6.1.188**. The unguarded COEF save/restore paths are present in sound/pci/hda/patch_realtek.c, and the same class of bug already went to stable in 2014 because writing a failed COEF read can stall the codec.
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
Record: [ALSA/hda/realtek] [add] missing error checks for COEF index reads in alc269
**Step 1.2 — Tags**
Record:
- Signed-off-by: Bob Song <[email protected]> (author)
- `Link: https://patch.msgid.link/20260730015302.253008-1-
[email protected]`
- Signed-off-by: Takashi Iwai <[email protected]> (ALSA maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, `Cc:
stable` (absence expected)
- Ignore any pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] if present
**Step 1.3 — Body**
Record:
- Bug: alc_read_coef_idx() / alc_read_coefex_idx() can return -1 via snd_hda_codec_read(). Init/shutdown save that value and write it back.
- Symptom: COEF register corruption on read failure (wrong headphone-amp / depop state; historically this class of write can stall the codec).
- Root cause: missing != -1 checks on save/restore and on depop polling.
- No version bounds in the message.
**Step 1.4 — Hidden bug fix?**
Record: Yes. “Add missing error checks” is a real error-path fix, not style. Same pattern as alc_update_coefex_idx() and alc269_fill_coef() in this tree.
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
Record:
- File in the candidate: sound/hda/codecs/realtek/alc269.c (+14/-8)
- Functions: alc282_init, alc282_shutup, alc285_hp_init, alc294_hp_init
- Scope: single-file surgical fix
**Step 2.2 — Flow change**
Record:
- alc282_init / alc282_shutup: save coef 0x78, temporarily write 0x9004, then restore. After: restore only if coef78 != -1.
- alc285_hp_init: depop poll val & 0x8000 for up to 20×50ms, then write val and restore coef 0x38/0x0d/0x36. After: stop poll on -1; skip those writes if the saved/read value is -1.
- alc294_hp_init: same poll pattern on bit 0x0080; after: break on -1. No val write-back here.
**Step 2.3 — Bug mechanism**
Record: Logic / hardware-state corruption on error.
- codec_read() in this tree returns -1 when snd_hdac_exec_verb() fails (sound/hda/hdac_device.c).
- COEF payload is 16-bit, so -1 becomes 0xFFFF on write.
- alc_update_coef_idx(..., mask, coefXX) with coefXX == -1 does (current & ~mask) | 0xFFFFFFFF and sets every bit.
- val & 0x8000 is true for -1, so the depop loop always runs the full ~1s then writes 0xFFFF.
**Step 2.4 — Fix quality**
Record: Obviously correct and matches existing if (val != -1) guards. Success path unchanged. Regression risk is low: skipping a restore when there is no valid saved value is safer than writing 0xFFFF.
## Phase 3: Git history
**Step 3.1 — Blame / introduction**
Record:
- ALC282 save/restore: 7b5c7a0240b11 (2014) “Fix the noise after suspend and resume on ALC282 codec” — ancestor of this HEAD.
- ALC285 HP init: 3c24e48330adf (2021) — ancestor of this HEAD.
- 2014 COEF-guard: f3ee07d8b6e06 “Avoid setting wrong COEF on ALC269 & co” — ancestor of this HEAD; Cc: stable; documented that writing after a -1 read can stall the codec and broke resume on Acer AO725.
**Step 3.2 — Fixes: tag**
Record: None. The incomplete coverage of f3ee07d8b6e06 is the historical analogue.
**Step 3.3 — Related file history**
Record: Recent patch_realtek.c commits are quirks, not this fix. git log --grep="missing error checks" / "COEF index reads" on this file:
no hit. Candidate 5b106b40ed220 is **not** an ancestor of HEAD.
**Step 3.4 — Author**
Record: Bob Song (Kylinos), not the ALSA maintainer. Takashi Iwai applied it after a v1→v2 split.
**Step 3.5 — Dependencies**
Record: Standalone. Needs only alc_read_coef*_idx() returning -1, which this tree already has. No new helpers.
## Phase 4: Mailing list
**Step 4.1 — Original discussion**
Record: b4 dig -c 5b106b40ed220 →
https://patch.msgid.link/[email protected]
- v1 combined this with a codec->bus->pci NULL check.
- Takashi: “Could you split the NULL check to another patch? Basically it's a completely different sort of fix from others.”
- v2: this COEF patch only. Takashi: “Applied to for-next branch. Thanks.”
- No NAK, no stable nomination, no reviewer concern about the COEF checks.
**Step 4.2 — Recipients (b4 dig -w)**
Record: [email protected], [email protected], linux-sound@, linux- kernel@. Maintainer was To: and applied it.
**Step 4.3 — Bug report**
Record: No syzbot/bugzilla for *these* sites. The stall/resume failure for the same -1 write pattern is documented in f3ee07d8b6e06 / bugzilla 52181.
**Step 4.4 — Series**
Record: v2 series patch 1/2 is this fix; patch 2/2 is the PCI NULL check (separate). This patch is self-contained.
**Step 4.5 — Stable list**
Record: lore.kernel.org WebFetch returned 403 (Anubis). UNVERIFIED whether stable@ already discussed this specific commit. Full linux-sound thread was recovered via b4 dig -m.
## Phase 5: Code semantics (this tree)
**Step 5.1 — Functions**
Record: alc282_init, alc282_shutup, alc285_hp_init, alc294_hp_init in sound/pci/hda/patch_realtek.c.
**Step 5.2 — Callers (verified)**
Record:
- alc282_init / alc282_shutup: codec 0x10ec0282 (spec->init_hook / spec->shutup).
- alc285_hp_init: from alc225_init on boot and S3/S4 resume (skipped only for ALC287/ALC245).
- alc225_init: ALC215/245/285/289, ALC225/295/299, ALC287.
- alc294_hp_init: from alc294_init on boot / S4 restore; ALC234/274/294 and ALC700.
- alc_init() runs spec->init_hook; .init = alc_init.
- alc_suspend() → alc_shutup() → spec->shutup; alc_resume() → patch_ops.init.
**Step 5.3 — Callees**
Record: alc_read_coef*_idx, alc_write_coef*_idx, alc_update_coef*_idx, snd_hda_codec_write, msleep.
**Step 5.4 — Reachability**
Record: Yes. Probe, suspend, and resume on common Realtek laptop codecs. Not an obscure config path.
**Step 5.5 — Similar patterns**
Record: Already guarded in this file:
- __alc_update_coefex_idx(): if (val != -1)
- alc269_fill_coef(): if (val != -1 && ...) before write These four functions were the remaining save/restore holes.
## Phase 6: This checkout (6.1.188)
**Step 6.1 — Does the buggy code exist?**
Record: Yes. Unguarded write-backs:
```3429:3431:sound/pci/hda/patch_realtek.c
/* Headphone capless set to normal mode */
alc_write_coef_idx(codec, 0x78, coef78);
}
``````3465:3468:sound/pci/hda/patch_realtek.c
alc_auto_setup_eapd(codec, false);
alc_shutup_pins(codec);
alc_write_coef_idx(codec, 0x78, coef78);
}
``````3718:3727:sound/pci/hda/patch_realtek.c
val = alc_read_coefex_idx(codec, 0x58, 0x00);
for (i = 0; i < 20 && val & 0x8000; i++) {
msleep(50);
val = alc_read_coefex_idx(codec, 0x58, 0x00);
} /* Wait for depop procedure finish */
alc_write_coefex_idx(codec, 0x58, 0x00, val); /* write back the
result */
alc_update_coef_idx(codec, 0x38, 1<<4, coef38);
```Same unguarded poll in alc294_hp_init. Introduced 2014/2021; both are in this tree.
**Step 6.2 — Backport difficulty**
Record: Minor path rework. Candidate path sound/hda/codecs/realtek/alc269.c does not exist here; equivalent code is sound/pci/hda/patch_realtek.c. Function bodies match the pre-patch logic. Not a semantic conflict.
**Step 6.3 — Already fixed here?**
Record: No. git merge-base --is-ancestor 5b106b40ed220 HEAD failed. No later substitute fix in this file.
## Phase 7: Subsystem
**Step 7.1**
Record: ALSA HD-audio Realtek codec. **IMPORTANT** (default audio on a huge set of laptops).
**Step 7.2**
Record: Mature driver; current 6.1.y activity is mostly quirks. These init/shutup paths have been stable for years, which is why leftover -1 write-backs still matter.
## Phase 8: Impact and risk
**Step 8.1 — Who**
Record: Users of ALC282, ALC215/225/285/289, ALC225/295/299, ALC234/274/294, ALC700 — typical CONFIG_SND_HDA_CODEC_REALTEK x86 laptops.
**Step 8.2 — Trigger**
Record: Codec COEF read returns -1 (verb timeout, invalid COEF on a variant, flaky link during suspend/resume). Not an unprivileged syscall exploit; it is a common device PM path.
**Step 8.3 — Failure mode**
Record: Wrong COEF restore / depop result. Severity **HIGH** for audio:
headphone noise, failed depop, or codec stall (the failure f3ee07d8b6e06 already shipped to stable). Not a kernel oops by itself.
**Step 8.4 — Ratio**
Record: Benefit medium-high (PM path on common hardware, same class as a prior stable fix). Risk very low (~14 lines of != -1 guards, success path identical).
## Phase 9: Synthesis
**Evidence FOR**
- Real write of error sentinel -1/0xFFFF into codec COEF state.
- alc_update_coef_idx(..., saved) with saved == -1 sets all bits on a register that may still be readable.
- Depop poll treats -1 as “still busy” for a full second.
- Same class as f3ee07d8b6e06 (codec stall / resume failure, `Cc:
stable`).
- Small, obviously correct, maintainer-applied.
- Buggy functions exist in this 6.1.188 tree and are not fixed.
**Evidence AGAINST**
- No user report for these four sites.
- Exact patch needs a file-path backport (alc269.c → patch_realtek.c).
- Static-analysis style; trigger is an already-failing verb.
**Unresolved**
- lore.kernel.org HTTP 403 for stable@ search (thread itself was retrieved with b4).
**Stable rules**
1. Obviously correct and tested? **PASS** (maintainer applied v2; success path unchanged)
2. Real user-visible bug? **PASS** (bad COEF restore on init/suspend/resume)
3. Important (stall / broken audio / register corruption)? **PASS** (same class as the 2014 stable COEF-stall fix)
4. Small and contained? **PASS** (+14/-8, four local checks)
5. No new features/APIs? **PASS**
6. Can apply here? **PASS** with a trivial path backport to patch_realtek.c
**Exception category:** none (not an ID/quirk/DT/build/docs exception). It is a normal small bugfix.
This should go into this 6.1.188 tree. The bug is in the local alc282_* / alc285_hp_init / alc294_hp_init paths; the fix is a few != -1 guards that this tree already uses elsewhere.
Verification:
- [Phase 1] Parsed tags: author Bob Song; Link msgid; SOB Takashi Iwai; no Fixes/Reported-by/Cc stable
- [Phase 2] Diff: 14 insertions / 8 deletions; four functions; skip write-back and stop poll on -1
- [Phase 2] codec_read() in this tree returns -1 on snd_hdac_exec_verb() failure (sound/hda/hdac_device.c:988-997)
- [Phase 3] git merge-base --is-ancestor 7b5c7a0240b11 HEAD — yes (ALC282 write-back, 2014)
- [Phase 3] git merge-base --is-ancestor 3c24e48330adf HEAD — yes (alc285_hp_init, 2021)
- [Phase 3] git merge-base --is-ancestor f3ee07d8b6e06 HEAD — yes (2014 COEF-guard, Cc:stable, codec stall)
- [Phase 3] git merge-base --is-ancestor 5b106b40ed220 HEAD — no (fix not in this tree)
- [Phase 4] b4 dig -c 5b106b40ed220: v1 split requested, v2 applied; no NAK
- [Phase 4] UNVERIFIED: lore.kernel.org/stable search (HTTP 403)
- [Phase 5] Callers: alc_init → init_hook; alc_suspend → shutup; alc_resume → init; vendor IDs 0x10ec0282 / 0215 / 0225 / 0234 / 0285 / 0294 / …
- [Phase 6] git describe HEAD: p-6.1-2-g8ee893656ef69; make kernelversion: **6.1.188**
- [Phase 6] Buggy code present in sound/pci/hda/patch_realtek.c lines 3430, 3467, 3719-3727, 3992
- [Phase 6] Target file sound/hda/codecs/realtek/alc269.c missing here; equivalent functions exist
- [Phase 8] Failure mode: COEF corruption / possible codec stall on resume; severity HIGH for audio, not a kernel oops
**YES**
sound/hda/codecs/realtek/alc269.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
sound/hda/codecs/realtek/alc269.c +14 -8
@@ -296,7 +296,8 @@ static void alc282_init(struct hda_codec *codec)msleep (100 );/* Headphone capless set to normal mode */ -alc_write_coef_idx (codec,0x78 , coef78); +if (coef78 !=-1 ) +alc_write_coef_idx (codec,0x78 , coef78); }static void alc282_shutup (struct hda_codec *codec)
@@ -333,7 +334,8 @@ static void alc282_shutup(struct hda_codec *codec)alc_auto_setup_eapd (codec, false);alc_shutup_pins (codec); -alc_write_coef_idx (codec,0x78 , coef78); +if (coef78 !=-1 ) +alc_write_coef_idx (codec,0x78 , coef78); }static const struct coef_fw alc283_coefs[] = {
@@ -585,15 +587,19 @@ static void alc285_hp_init(struct hda_codec *codec)alc_write_coefex_idx (codec,0x58 ,0x00 ,0xf888 );/* HP depop procedure start */ val =alc_read_coefex_idx (codec,0x58 ,0x00 ); -for (i =0 ; i <20 && val &0x8000 ; i++) { +for (i =0 ; i <20 && val !=-1 && val &0x8000 ; i++) {msleep (50 ); val =alc_read_coefex_idx (codec,0x58 ,0x00 ); }/* Wait for depop procedure finish */ -alc_write_coefex_idx (codec,0x58 ,0x00 , val);/* write back the result */ -alc_update_coef_idx (codec,0x38 ,1 <<4 , coef38); -alc_update_coef_idx (codec,0x0d ,0x110 , coef0d); -alc_update_coef_idx (codec,0x36 ,3 <<13 , coef36); +if (val !=-1 ) +alc_write_coefex_idx (codec,0x58 ,0x00 , val);/* write back the result */ +if (coef38 !=-1 ) +alc_update_coef_idx (codec,0x38 ,1 <<4 , coef38); +if (coef0d !=-1 ) +alc_update_coef_idx (codec,0x0d ,0x110 , coef0d); +if (coef36 !=-1 ) +alc_update_coef_idx (codec,0x36 ,3 <<13 , coef36);msleep (50 );alc_update_coef_idx (codec,0x4a ,1 <<15 ,0 );
@@ -858,7 +864,7 @@ static void alc294_hp_init(struct hda_codec *codec)/* Wait for depop procedure finish */ val =alc_read_coefex_idx (codec,0x58 ,0x01 ); -for (i =0 ; i <20 && val &0x0080 ; i++) { +for (i =0 ; i <20 && val !=-1 && val &0x0080 ; i++) {msleep (50 ); val =alc_read_coefex_idx (codec,0x58 ,0x01 ); }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 Revert "namei: don't reveal overmounted entries in refwalk"
In reply to Sasha LevinFrom: Christian Brauner <[email protected]>
[ Upstream commit 214897acc8c2e5d6b63189d23ccaed6fa2af45a9 ]
This reverts commit 8189ab688f5a2c745dc90b63374da02f213d6994.
This bug class is bigger than can be fixed with this simple patch. Back out of it and give us some time to fix this properly.
---
LLM Generated explanations, may be completely bogus:
This revert should go into this 6.18.57 tree. The incomplete unlink_may_reveal() check is already in v6.18.57, the VFS maintainer pulled it back as an rc8 fix, and leaving it here regresses common unlink/open races.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [vfs/namei] [Revert] undo "don't reveal overmounted entries in refwalk"
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- No Fixes: tag on the revert itself (it names the reverted SHA in the body)
- No Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, Link:, or Cc: stable
- Signed-off-by: Christian Brauner <[email protected]> (VFS maintainer; ignore Sasha Levin SOB)
- Body: This reverts commit 8189ab688f5a2c745dc90b63374da02f213d6994
The original commit that is being reverted **did** have `Fixes:8ed936b5671b, Cc: [email protected], and Link:
https://patch.msgid.link/20261002-work-mount-
[email protected]`. That is why 8189ab68 already landed in this stable series; the revert is the follow-up.
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug description: the earlier “simple patch” does not cover this bug class
- Symptom/failure mode: not a crash; an incomplete pathwalk/mount-cover check that must be withdrawn
- Version information: none in the revert message
- Root cause (author): “This bug class is bigger than can be fixed with this simple patch. Back out of it and give us some time to fix this properly.”
Linus’s vfs-7.3-rc8.fixes pull restates the same thing: *Revert "namei: don't reveal overmounted entries in refwalk" from the rc7 fixes. The bug class is bigger than that patch.*
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not disguised cleanup. This is an explicit revert of a recently merged, incomplete VFS change. A later (unmerged) follow-up documented a real regression: any unlink/rename racing a refwalk returned -ESTALE and forced a full LOOKUP_REVAL walk, which on NFS/FUSE revalidates every path component.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: fs/namei.c only
- Mainline revert: remove unlink_may_reveal() (~27 lines) and its one call site (2 lines). Net −29
- Local 6.18.y equivalent of the original add is 5f97df8ca7fad; the revert is its inverse
- Functions: delete unlink_may_reveal; one call removed from step_into() (this tree) / step_into_slowpath() (mainline after a later split)
- Scope: single-file surgical revert
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before (v6.18.57): in the non-RCU / refwalk arm of step_into(), after handle_mounts(), unlink_may_reveal() returns true if the dentry is cant_mount() **and** d_unlinked(), the walk has not crossed a mount, and flags are not WALK_NOFOLLOW/LOOKUP_REVAL. It dput()s path->dentry and the caller returns -ESTALE.
- After: that check is gone; refwalk accepts the dentry as it did before 5f97.
- Path: common pathname lookup (open/stat/lookup), refwalk only (RCU walk already retries via d_seq/mount_lock).
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Category: revert of an incomplete logic/correctness change that also caused a lookup-retry regression
- Mechanism: dont_mount() runs on **every** successful vfs_unlink() / vfs_rmdir() / rename-over, not only mountpoints. Combined with d_unlinked(), the helper treated ordinary unlinks as “may reveal a covered file” and forced -ESTALE → LOOKUP_REVAL. That is far broader than the mount-cover race it meant to close, and it still did not cover the rest of the bug class.
Verified dont_mount() call sites in this tree: vfs_rmdir() ~4558, vfs_unlink() ~4679, vfs_rename() ~5230.
Verified ESTALE retry in this tree:
```2708:2709:fs/namei.c
if (unlikely(retval == -ESTALE))
retval = path_lookupat(&nd, flags | LOOKUP_REVAL, path);
```Same pattern in do_filp_open() / do_file_open_root(). The helper itself skipped the check when LOOKUP_REVAL was already set, which matches the “fail once, then full revalidate” behavior.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Quality: obviously correct as a revert — it is the exact inverse of 5f97 in this tree
- Regression risk of the revert: re-opens the remaining refwalk window where a walker that already held the dentry can see a file after its covering mounts were detached. That race is old (Fixes target 8ed936b5671b, 2014). 6.18.y lived with it until 6.18.57. A sibling backport, d29cd99db3db7 (“unhash a dentry before detaching the mounts”), remains and still shrinks the *new lookup* side of the race.
- Risk of keeping 5f97: extra LOOKUP_REVAL on common unlink/create storms; incomplete security fix in core pathwalk
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record: At v6.18.57, every unlink_may_reveal line and the step_into() call are 5f97df8ca7fad (Christian Brauner, 2026-10-02; committed to 6.18.y by Greg Kroah-Hartman on 2026-10-15). Surrounding step_into() logic is old Al Viro/Linus code (2011–2022).
Step 3.2: FOLLOW THE FIXES: TAG
Record: The revert has no Fixes tag. It reverts mainline 8189ab688f5a = local 5f97df8ca7fad.
- git merge-base --is-ancestor 5f97df8ca7fad v6.18.57 → yes (v6.18.57~479)
- git merge-base --is-ancestor 5f97df8ca7fad v6.18.56 → no
- Original 8189ab68 Fixes: 8ed936b5671b **is** an ancestor of this tree (2014-10-09)
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- d29cd99db3db7 namespace: unhash a dentry before detaching the mounts on it is also in v6.18.57 (same Greg KH batch, same original series). It stays; this revert does not undo it.
- No other unlink_may_reveal / DCACHE_UNCOVERED commits in this tree
- Standalone revert, not patch 2/N of something this tree still needs
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Christian Brauner is the VFS maintainer. Recent fs/namei.c work in this history includes the original add, this revert, and other VFS fixes. Weight: high.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: The only prerequisite is that 5f97 exists, which it does. The revert applies as the exact inverse of 5f97 (step_into, not mainline’s later step_into_slowpath). No new helpers. Standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 214897acc8c2 failed: lore.kernel.org returned errors (UNVERIFIED: no dedicated mailed revert thread found; Brauner likely committed this directly)
- WebFetch of lore.kernel.org returned 403 (UNVERIFIED: full lore thread)
- Original add was series work-mount-fixes-4 patch 02/21 (msgid [email protected]); also on lkml.iu.edu / patchew
- Linus merged the revert in 1dbb7422053fa *Merge tag 'vfs-7.3-rc8.fixes'* and called it out in the pull text
- An unmerged follow-up (syzbot CI series) explained the LOOKUP_REVAL regression and tried DCACHE_UNCOVERED; that approach was **not** merged — they reverted instead
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: b4 dig -w failed (lore error). Author is the VFS maintainer; Linus merged it as an rc8 VFS fix. That is stronger than a typical mailing-list Ack.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla on the revert. The **original** add included a userspace reproducer (unlink_covered) showing the mount-cover race (~27 hits/60s without widening). The unmerged follow-up’s unlink_storm reproducer showed 463 LOOKUP_REVAL retries in 16.8 million opens from the too-broad check.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Original add was 02/21 of a large mount-fixes series. Sibling unhash a dentry before detaching is already in 6.18.57 and is **not** reverted. No merged “proper” replacement for unlink_may_reveal exists in this tree or in the nearby mainline objects inspected.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable search could not be fetched (403). UNVERIFIED whether anyone separately requested this revert on the stable list. Not needed: the original went to 6.18.57 via Cc: stable, and the author immediately backed it out in mainline.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: unlink_may_reveal (removed), step_into (call removed). No semcode tools available.
Step 5.2: TRACE CALLERS
Record: step_into() callers in this tree:
- handle_dots() (WALK_NOFOLLOW — helper returned false anyway)
- walk_component() — every normal path component
- one more WALK_NOFOLLOW site ~2660
- open_last_lookups path ~3922 (WALK_TRAILING)
Impact surface: **every pathname lookup** that drops out of RCU-walk into refwalk.
Step 5.3: TRACE CALLEES
Record: Helper used cant_mount(), d_unlinked(), dput(no_free_ptr(path->dentry)). Returning -ESTALE skipped the normal dput(nd->path.dentry) / mntput in step_into(); terminate_walk() still owns nd->path. The extra dput was only on the ESTALE path.
Step 5.4: FOLLOW THE CALL CHAIN
Record: userspace open/openat/stat/fstatat/etc. → filename_lookup / do_filp_open → link_path_walk → walk_component → step_into. Unprivileged users trigger this constantly. The false ESTALE path is a realistic unlink vs open race, not only the exotic mount-cover case.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: No other unlink_may_reveal copies. cant_mount() remains in fs/namespace.c and fs/dcache.c for mount setup, which is correct and unrelated.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes, in **v6.18.57** (fs/namei.c unlink_may_reveal + call in step_into). Tree identity: git describe HEAD = v6.18.57-155-gcdf239ca885b2, make kernelversion = 6.18.57. Introduced here by 5f97 (upstream 8189ab68), first in 6.18.57, not 6.18.56.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Clean apply. Local revert hunks match 5f97 exactly (step_into, not step_into_slowpath). No conflicting namei refactor between 5f97 and v6.18.57.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No later replacement for this check. d29cd99 (unhash before detach) is present and complementary; it must stay. This revert does not remove it.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: fs/namei.c — VFS pathname lookup. **CORE**. Affects every user of every filesystem.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mature, still actively fixed (recent mount/namespace series). This is not staging/experimental code.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Universal for anyone running 6.18.57+. NFS/FUSE users feel the LOOKUP_REVAL retry cost most. Container/user-ns users care about the original mount-cover race; that race is only partially addressed by d29cd99 and was not fully fixed by 5f97.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record:
- False ESTALE: concurrent unlink/rename vs refwalk on any name (dont_mount is unconditional). Common.
- Original cover-reveal race: unlink of a mountpoint while another task walks the covering name. Narrow but real; original commit measured 27 hits/60s.
- Unprivileged users can trigger both (open/unlink). The cover case typically needs mount privileges or a shared mount namespace.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- Keeping 5f97: extra full-path revalidation (MEDIUM–HIGH on NFS/FUSE; LOW on local tmpfs except under unlink storms). Incomplete mount-cover fix (the author says the class is bigger).
- After revert: restore pre-6.18.57 step_into behavior; remaining cover-reveal race is the long-standing one (MEDIUM, security-adjacent, narrow), with d29cd99 still reducing new-lookup hits.
- Severity of **not** reverting a known-wrong core pathwalk change that already shipped in 6.18.57: HIGH (stable regression vs 6.18.56).
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: remove a too-broad ESTALE/LOOKUP_REVAL regression from core lookup; align 6.18.y with the VFS maintainer’s rc8 correction; drop an incomplete security bandage rather than pretend it closed the class
- Risk: very low — exact inverse of a 29-line function added in 6.18.57
- Ratio: strongly favors backporting the revert
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- The commit being reverted **is in this tree** (5f97, v6.18.57~479)
- VFS maintainer authored the revert; Linus merged it as vfs-7.3-rc8.fixes
- Documented too-broad check: every unlink/rename vs refwalk, not only overmounts
- Small, exact inverse, applies cleanly
- Sibling unhash-before-detach fix remains
- Revert of a stable-to-stable mistake (5f97 was itself a 6.18.57 backport)
AGAINST:
- Re-opens the remaining “walker already holds the dentry” cover-reveal window
- Original add had a reproducer and Cc: stable
UNRESOLVED:
- Full lore thread for the revert itself (b4/lore failed)
- Whether a later proper fix exists only on branches not in this object store (none found on 214897’s nearby history)
The “against” point is why 5f97 was written. The maintainer’s later judgment, merged by Linus, is that keeping that patch is worse than living with the old narrow race until a real fix exists. For stable, shipping 5f97 for a few days and then following the revert is the conservative choice.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — exact revert of a known SHA; merged as an rc8 VFS fix
2. Fixes a real bug that affects users? **PASS** — removes a too-broad ESTALE/LOOKUP_REVAL pathwalk regression introduced in 6.18.57
3. Important issue (crash, security, corruption, deadlock)? **PASS** — core VFS lookup regression; incomplete security check is worse than no check plus the remaining unhash fix
4. Small and contained? **PASS** — −29 lines, one file
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — inverse of 5f97 on step_into()
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Not a device-ID/quirk/DT/docs case. It is the documented revert
case: original commit **is** in this stable tree, so the revert is needed.
Step 9.4: MAKE YOUR DECISION
This tree is 6.18.57. It already contains the incomplete refwalk check. The revert is the maintainer’s correction of that 6.18.57 backport and should be applied here.
What it does for stable users: it takes unlink_may_reveal() out of step_into() so ordinary unlink/open races no longer force a full LOOKUP_REVAL walk, and it stops treating a known-incomplete mount- cover check as a finished fix. d29cd99 still unhashes before detaching mounts.
Risk vs benefit: benefit is high (undo a core-pathwalk regression that is only days old in 6.18.57); risk is very low (surgical revert).
Concerns: the original cover-reveal race is not fully solved; that is intentional per the author. No extra prerequisites.
Verification:
- [Phase 1] Parsed revert tags: Brauner SOB only; body reverts 8189ab688f5a; original add had Fixes/Cc stable/Link
- [Phase 1] Linus vfs-7.3-rc8.fixes pull explicitly names this revert
- [Phase 2] Diff: −29 lines in fs/namei.c; removes unlink_may_reveal + ESTALE return in step_into
- [Phase 2] Verified dont_mount() on vfs_unlink/vfs_rmdir/vfs_rename; ESTALE→LOOKUP_REVAL in filename_lookup/do_filp_open
- [Phase 3] git describe HEAD: v6.18.57-155-gcdf239ca885b2; kernelversion 6.18.57
- [Phase 3] git merge-base --is-ancestor 5f97df8ca7fad v6.18.57: yes; v6.18.56: no
- [Phase 3] git blame v6.18.57: unlink_may_reveal entirely 5f97df8ca7fad
- [Phase 3] 8ed936b5671b is an ancestor; d29cd99 unhash-before-detach is in v6.18.57 and stays
- [Phase 3] Local revert is the exact inverse of 5f97 on step_into (not step_into_slowpath)
- [Phase 4] b4 dig -c 214897acc8c2: lore server error — UNVERIFIED mailed thread
- [Phase 4] lore WebFetch 403 — UNVERIFIED lore discussion
- [Phase 4] Unmerged DCACHE_UNCOVERED follow-up documents LOOKUP_REVAL regression (syzbot CI / series text)
- [Phase 5] step_into callers: walk_component, handle_dots, open_last_lookups — core pathwalk
- [Phase 6] Buggy helper present at v6.18.57:fs/namei.c:1983; clean apply
- [Phase 8] Failure mode: extra LOOKUP_REVAL on unlink vs open; NFS/FUSE revalidate whole path
- UNVERIFIED: stable@ mailing list discussion of this specific revert
**YES**
fs/namei.c | 29 ----------------------------- 1 file changed, 29 deletions(-)
fs/namei.c +0 -29
@@ -1973,33 +1973,6 @@ static const char *pick_link(struct nameidata *nd, struct path *link,return NULL ; } -/* -* Be careful in case the dentry is unlinked or renamed. Any mounts -* stacked on top of it are going away. We need to make sure that we -* don't reveal the underyling dentry during refwalk. In rcuwalk we -* catch this via d_seq and another lookup for the name. Give the same -* guarantee in refwalk. -*/ -static bool unlink_may_reveal (struct nameidata *nd,int flags, -struct path *path,struct dentry *dentry) -{ -/* ".." and LOOKUP_DOWN may land on an unhashed directory */ -if (flags &WALK_NOFOLLOW ) -return false; -if (nd->flags &LOOKUP_REVAL ) -return false; -/* We crossed onto a mount and the name led us here while it still existed */ -if (path->mnt != nd->path.mnt) -return false; -/* only a name on its way out is flagged */ -if (likely (!cant_mount (dentry))) -return false; -if (!d_unlinked (dentry)) -return false; -dput (no_free_ptr (path->dentry)); -return true; -} -/* * Do we need to follow links? We _really_ want to be able * to do this check without having to look at inode->i_op,
@@ -2028,8 +2001,6 @@ static const char *step_into(struct nameidata *nd, int flags,if (unlikely (!inode))return ERR_PTR (-ENOENT ); }else { -if (unlikely (unlink_may_reveal (nd, flags, &path, dentry))) -return ERR_PTR (-ESTALE );dput (nd->path.dentry);if (nd->path.mnt != path.mnt)mntput (nd->path.mnt);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: rtlwifi: rtl8723be: Remove unnecessary irq save/restore in hw_init()
In reply to Sasha LevinFrom: William Hansen-Baird <[email protected]>
[ Upstream commit 1b4cd55626b6ffa93d18848412afb912a4add585 ]
rtl8723be hw_init() calls local_save_flags(flags) followed by local_irq_enable(). Later, local_irq_restore(flags) is called.
This causes warnings from Lockdep on boot and modprobe,
as local_irq_restore(flags) should only be called while irqs are disabled. The warning was introduced to detect this class of bug in [1].
With testing I found that all paths which call hw_init() have irqs already enabled for rtl8723be.
Furthermore, the calls were originally added for the rtl8192ce in commit f78bccd79ba3 ("rtlwifi: rtl8192ce: Fix too long disable of IRQs") before later being added to most other rtlwifi drivers.
Commit d3feae41a347 ("rtlwifi: Update power-save routines for 062814 driver") then replaces the call to spin_lock_irqsave() before hw_init(), and thus the codepath which caused irqs to be disabled in hw_init and prompted the original commit has been removed.
The same irq save/restore pattern is also present in the hw_init() of rtl8192ce, rtl8723ae, rtl8188ee, rtl8192se and rtl8192cu, however I don't have the hardware to test them,
so I did not include them in my changes.
Tested on a Razer Blade 14 2017.
Example of output from Lockdep prior to fix:
raw_local_irq_restore() called with IRQs enabled
...
Call Trace: <TASK> rtl8723be_hw_init+0x5992/0x7220 [rtl8723be] ? static_obj+0x61/0xa0 rtl_pci_start+0x222/0x5c0 [rtl_pci] rtl_op_start+0x128/0x1a0 [rtlwifi] ? __kasan_check_read+0x11/0x20 drv_start+0x16c/0x550 [mac80211]
...
irq event stamp: 887679 hardirqs last enabled at (887689): [<ffffffff96511170>] __up_console_sem+0x90/0xa0 hardirqs last disabled at (887698): [<ffffffff96511155>] __up_console_sem+0x75/0xa0 softirqs last enabled at (887670): [<ffffffff962f4675>] __irq_exit_rcu+0x175/0x2f0 softirqs last disabled at (887649): [<ffffffff962f4675>] __irq_exit_rcu+0x175/0x2f0 ---[ end trace 0000000000000000 ]---
[1] https://lore.kernel.org/all/[email protected]/
---
LLM Generated explanations, may be completely bogus:
The local tree is **v7.3-rc4** (mainline 7.3). The candidate is a six- line IRQ API fix in rtl8723be_hw_init() that stops a real WARN_ONCE on boot. Full phase walkthrough follows.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[wifi: rtlwifi: rtl8723be]** **[Remove]** unnecessary irq save/restore in hw_init(). Intent: drop a leftover local_save_flags / local_irq_enable / local_irq_restore sequence that is no longer valid.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Acked-by:** Ping-Ke Shih <[email protected]> (rtlwifi maintainer)
- **Signed-off-by:** William Hansen-Baird (author); Ping-Ke Shih (maintainer)
- **Link:** https://patch.msgid.link/20260609095359.2964193-1-
[email protected]
- No Fixes:, Reported-by:, Tested-by:, Cc: stable (absence expected)
- Ignore pipeline SOBs
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** rtl8723be_hw_init() does local_save_flags(flags); local_irq_enable(); … local_irq_restore(flags) while IRQs are already enabled.
- **Symptom:** WARN_ONCE from warn_bogus_irq_restore():
raw_local_irq_restore() called with IRQs enabled, on boot and modprobe. Stack: rtl8723be_hw_init → rtl_pci_start → rtl_op_start → drv_start.
- **Root cause:** The save/enable/restore was copied from rtl8192ce (f78bccd79ba3, 2014) to keep IRQs enabled during a long hw_init() that used to run under spin_lock_irqsave(). d3feae41a347 (2014) removed that irqsave around the power-save/hw_init path, so callers now enter with IRQs enabled. Restore of already-enabled flags is forbidden.
- **Version info:** Pattern present since the rtl8723be driver was added (a619d1abe20cc, 2014-02-28). Warning added in 997acaf6b4b59 (2021).
- **Author explanation:** All current rtl8723be hw_init() callers have IRQs enabled (tested on a Razer Blade 14 2017). Sibling chips still have the pattern but were left alone for lack of hardware.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Explicit lockdep/IRQ-restore warning fix. “Remove unnecessary” is accurate: the sequence became a no-op plus a warning after the 2014 caller change.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c — **6 deletions, 0 additions**
- Function: rtl8723be_hw_init()
- Scope: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** Save flags, force IRQs on for the whole init, restore flags at the exit: label (success and error).
- **After:** Init runs in the caller’s IRQ state; exit: only clears being_init_adapter.
- **Path:** Normal and error hw_init() (boot, modprobe, interface start, IPS nic-on).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Logic / IRQ-flag API misuse** (WARN_ON class). local_irq_restore() must be called with IRQs disabled (raw_check_bogus_irq_restore() in include/linux/irqflags.h). Callers already have IRQs enabled, so restore trips WARN_ONCE. Same class as 8b144dedb928e (“rtlwifi: rtl8192cu: Fix WARNING when calling local_irq_restore() with interrupts enabled”), which used local_irq_disable() before restore and was **Cc: stable**. Here the save/enable/restore is removed because it is no longer needed.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct if all callers have IRQs enabled (author tested; maintainer agreed; rtl_pci_start / rtl_op_start / rtl_ps_enable_nic are process-context, mutex/work, not spin_lock_irqsave).
- Minimal: six lines deleted, no unrelated edits.
- Regression risk: if some caller still had IRQs off, hw_init() could run ~hundreds of ms with IRQs disabled (the 2014 audio-underrun/clock- freeze bug). Verified not the case in this tree. Maintainer: “current hw_init() is not in scope of spin_lock_irqsave(), so irqs is not disabled.”
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record: IRQ save/restore was in rtl8723be from **a619d1abe20cc (“rtlwifi: rtl8723be: Add new driver”, 2014-02-28)**. Pattern copied from rtl8192ce f78bccd79ba3 (2014-02-01). Present for ~12 years.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Related history:
- f78bccd79ba3 — **in this tree** — added save/enable/restore because hw_init ran too long with IRQs off.
- d3feae41a347 — **in this tree** — replaced spin_lock_irqsave before hw_init with spin_lock / mutex; IRQ-disabled caller gone.
- 997acaf6b4b59 — **in this tree** — added the WARN_ONCE.
- 8b144dedb928e (2021) — **in this tree** — same warning on rtl8192cu; **Cc: stable**.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent rtl8723be/hw.c commits are unrelated (stack size, const arrays, LED, kfree_skb). Standalone; not patch X/Y in the committed form (v2 was a single patch).
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: William Hansen-Baird is a contributor, not the maintainer. Nearby work is separate ASPM quirks for the same chip (June 30), not prerequisites. Maintainer Ping-Ke Shih acked and applied it.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Deletes three API calls that have existed since 2014. Applies standalone.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- Lore/msgid: https://patch.msgid.link/20260609095359.2964193-1-
[email protected]
- v1: https://patch.msgid.link/20260608135345.2526325-3-
[email protected]
- v1 → v2: drop dmesg timestamps, [1] footnote, rtw-next subject prefix. **Code unchanged.**
- Maintainer: “I think removal is okay.” No NAK. No Cc: stable in review. Applied to rtw-next as 1b4cd55626b6.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: To/Cc: [email protected], linux-wireless, linux-kernel. Subsystem maintainer reviewed and Acked.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla for this exact chip. Author reproduced on a Razer Blade 14 2017 with a full lockdep-style trace. Same warning class was syzbot+stable for rtl8192cu in 2021.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: v1 msgid -3 looks like a series slot; v2 was sent standalone. Other June 2026 Hansen-Baird rtlwifi patches are ASPM, independent. Sibling drivers (rtl8192ce, rtl8723ae, rtl8188ee, rtl8192se, rtl8192cu) still have the pattern; not required for this chip’s fix.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No stable-thread discussion found for this subject. Precedent:8b144dedb928e was explicitly Cc: stable for the same warning.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: rtl8723be_hw_init() only.
**Step 5.2: TRACE CALLERS**
Record:
- rtl_pci_start() (pci.c:1737) ← rtl_op_start() (core.c:129, conf_mutex) ← mac80211 drv_start. Matches the reported stack. Process context, IRQs on.
- rtl_ps_enable_nic() (ps.c:26) ← _rtl8723be_phy_set_rf_power_state() IPS ERFON path (phy.c:2534) ← rtl_ps_set_rf_state() (plain spin_lock, not irqsave) ← rtl_ips_nic_on() (ips_mutex). Process/work context, IRQs on.
- USB rtl_usb_start() also calls hw_init; **RTL8723BE is PCIe-only** (CONFIG_RTL8723BE).
**Step 5.3: TRACE CALLEES**
Record: MAC/FW/PHY init, register I/O, rtl8723be_dm_init. Long- running, sleepable. Must not run with IRQs off for hundreds of ms — which is why 2014 added enable, and why it is safe to drop now that callers already have IRQs on.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace-reachable: interface up / module load / IPS wake. Unprivileged users who can bring the interface up can hit it. Debug kernels dump a warning on every start.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same save/enable/restore still in rtl8723ae, rtl8192ce, rtl8188ee, rtl8192se, rtl8192cu. rtl8192cu already does local_irq_disable() before restore (8b144dedb928e). Systematic leftover; this patch only fixes the tested chip.
---
## 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-27-gf0100363d8c37**, VERSION=7 PATCHLEVEL=3 (7.3.0-rc4).
- Driver and rtl8723be_hw_init() exist. Buggy sequence was here from 2014 until **1b4cd55626b6f**, which is already in **v7.3-rc1** (not in v7.2).
- Current hw.c has no local_save_flags (grep empty). Evaluation is of the fix’s merit for this lineage, where the bug lived for years and the code still matches.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Expected apply: **clean**. Six-line deletion of a pattern unchanged since 2014. No structural dependency on later rtlwifi refactors.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This exact fix is in 7.3-rc1. No alternate fix for rtl8723be. rtl8192cu’s 2021 workaround is a sibling, not a substitute.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **wifi / rtlwifi / rtl8723be** (Realtek RTL8723BE PCIe 802.11n). **IMPORTANT** (common 2014–2018 laptop WiFi: ThinkPads, Razers, etc.), not core mm/net.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature, low-churn vendor driver. Bug is old leftover, not a new- feature regression.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific**, CONFIG_RTL8723BE. Warning only with **CONFIG_DEBUG_IRQFLAGS** (selected by DEBUG_LOCKDEP). Debug/lockdep kernels, syzbot-style configs, panic_on_warn. Production distro kernels usually omit lockdep, so they would not print it — the API misuse is still present.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Every hw_init(): boot, modprobe, iface start. Not a race. Unprivileged users can trigger via network start if the module is loaded.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: WARN_ONCE in warn_bogus_irq_restore(). Not a panic/oops by default. Can panic if panic_on_warn. Mark Rutland’s 2021 commit notes restore-with-IRQs-enabled can desync IRQ-state tracing and break archs whose arch_local_irq_restore() assumes IRQs are off. **Severity:
MEDIUM** (WARN_ON), with a documented arch/lockdep correctness angle. Prompt lists WARN_ON triggers as a strong backport signal.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** Stops a boot-time warning on a common laptop chip; restores correct IRQ API use. Same class already taken into stable for rtl8192cu.
- **Risk:** Very low (6-line delete). Residual risk is long IRQ-off hw_init if some caller still had IRQs disabled — **not true in this tree**.
- **Ratio:** Favorable.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real, reproduced WARN_ONCE on boot/modprobe (Razer Blade 14 2017).
- Incorrect local_irq_restore() usage; can confuse lockdep and some arch restore paths.
- Six-line deletion, obviously correct once callers have IRQs enabled (verified in rtl_pci_start / rtl_op_start / IPS).
- Tested on hardware; Acked and applied by Ping-Ke Shih.
- Same warning on rtl8192cu was **Cc: stable** in 2021.
- Driver present since 2014; no missing prerequisites.
- WARN_ON is listed as a strong stable signal.
**AGAINST:**
- Warning is gated on CONFIG_DEBUG_IRQFLAGS; typical production kernels never print it.
- Not a crash, deadlock, corruption, or security hole in the default config.
- Sibling chips left unfixed (incomplete family-wide cleanup, not a dependency).
- Removing enable-IRQs-during-init would be harmful if an IRQ-disabled caller still existed (none found here).
**UNRESOLVED:** Could not fetch lore HTML (403); used b4 dig -m mbox instead. No stable@ thread found for this specific subject.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — hardware test + maintainer ack; callers have IRQs on.
2. Fixes a real bug that affects users? **PASS** — lockdep/debug warning on every start of this NIC.
3. Important issue? **PASS** (MEDIUM) — WARN_ONCE; same class previously shipped to stable; not a production panic.
4. Small and contained? **PASS** — 6 lines, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — code exists; deletion applies cleanly to the pre-fix file.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not a device ID, quirk table, DT, build, or docs-only change). Qualifies as a normal small bugfix.
**Step 9.4: MAKE YOUR DECISION**
This is a small, verified fix for a real IRQ-flag warning that fires on a common PCIe WiFi chip whenever hw_init() runs under debug IRQ/lockdep configs. Callers in this tree already have IRQs enabled, so deleting the leftover save/enable/restore is the right fix and does not reintroduce long IRQ-off init. Benefit clearly beats risk.
---
### What the commit solves for stable users
rtl8723be_hw_init() restored IRQ flags while IRQs were already enabled, which CONFIG_DEBUG_IRQFLAGS treats as broken and warns on every boot/modprobe. The enable/restore dance was only needed when hw_init() ran under spin_lock_irqsave(); that path has been gone since 2014. Users of RTL8723BE (many 2014–2018 laptops) on debug kernels get a stack dump at start; panic_on_warn would panic.
### Stable rules / risk vs benefit
Meets all six rules: tiny, tested, no new API, applies cleanly. Risk is a 6-line delete. Benefit is removing a boot-time WARN and illegal restore. Same bug class was already backported for rtl8192cu.
### Concerns
None that block a backport here: no extra commits required; sibling chips are independent; production kernels without DEBUG_IRQFLAGS simply never print the warning, but the misuse is still worth fixing.
---
Verification:
- [Phase 1] Parsed tags: Acked-by Ping-Ke Shih; Link msgid 20260609095359; no Fixes/Cc:stable/syzbot
- [Phase 1] Body: lockdep raw_local_irq_restore() called with IRQs enabled; stack rtl8723be_hw_init → rtl_pci_start → rtl_op_start
- [Phase 2] Diff: 6 deletions in rtl8723be_hw_init() only (git show 1b4cd55626b6f)
- [Phase 3] git merge-base --is-ancestor: f78bccd79ba3, d3feae41a347, 997acaf6b4b59, 8b144dedb928e all in HEAD
- [Phase 3] git log -S local_save_flags -- rtl8723be/hw.c: introduced in a619d1abe20cc (2014), removed in 1b4cd55626b6f
- [Phase 3] 8b144dedb928e: same warning on rtl8192cu, Cc: stable, added local_irq_disable() before restore
- [Phase 4] b4 dig -c 1b4cd55626b6f: lore match; v1→v2 message-only; maintainer ack, no NAK
- [Phase 4] b4 dig -m: saved /tmp/rtl8723be-thread.mbox (721 lines); WebFetch lore HTML 403
- [Phase 5] Callers: rtl_pci_start under conf_mutex; rtl_ps_enable_nic from IPS via spin_lock not irqsave
- [Phase 5] Grep: sibling drivers still have local_save_flags; rtl8723be file has none after the fix
- [Phase 6] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion 7.3.0-rc4
- [Phase 6] Commit in v7.3-rc1, not v7.2; current hw.c already patched
- [Phase 7] CONFIG_RTL8723BE PCIe 802.11n; driver added 2014
- [Phase 8] warn_bogus_irq_restore() is WARN_ONCE; DEBUG_LOCKDEP selects DEBUG_IRQFLAGS
- UNVERIFIED: no stable@ mailing-list thread for this exact subject (search not exhaustive beyond b4/git)
The fix is small, surgical, and meets the stable criteria for this tree.
**YES**
drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c +0 -6
@@ -1333,11 +1333,6 @@ int rtl8723be_hw_init(struct ieee80211_hw *hw)bool rtstatus = true;int err;u8 tmp_u1b; -unsigned long flags; - -/* reenable interrupts to not interfere with other devices */ -local_save_flags (flags); -local_irq_enable (); rtlhal->fw_ready = false; rtlpriv->rtlhal.being_init_adapter = true;
@@ -1443,7 +1438,6 @@ int rtl8723be_hw_init(struct ieee80211_hw *hw)rtl8723be_dm_init (hw); exit: -local_irq_restore (flags); rtlpriv->rtlhal.being_init_adapter = false;return err; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 netfilter: conntrack: tcp: use UNACK timeout for non-closing RST packets
In reply to Sasha LevinFrom: Minghao Zhang <[email protected]>
[ Upstream commit bf80e6802273a900311b44e47c9b1a59c6d2473c ]
Commit be0502a3f2e9 ("netfilter: conntrack: tcp: only close if RST matches exact sequence") keeps an established conntrack entry in ESTABLISHED when an in-window RST does not match the expected sequence number exactly, so the endpoint can validate the RST with a challenge ACK.
The timeout selection nevertheless uses the CLOSE timeout for every RST packet. The bug is that timeout selection is based on the packet type, not on the state transition result: even when RST validation keeps new_state in ESTABLISHED, the timeout is still forced to TCP_CONNTRACK_CLOSE.
Linux TCP independently rate limits challenge ACKs per socket. A second non-exact RST can therefore arrive after the first challenge ACK has restored the timeout but before the rate limit expires. The second RST lowers the timeout to 10 seconds again while the endpoint suppresses the second challenge ACK, allowing the conntrack entry to expire while both TCP endpoints remain established.
Using the ESTABLISHED timeout for such RSTs would avoid this short expiration window, but it could also retain stale entries for the five-day default because conntrack cannot reliably match the endpoint's exact TCP state.
Use the UNACK timeout for RST packets that leave the conntrack entry in TCP_CONNTRACK_ESTABLISHED. Exact-match RSTs and accepted RST packet trains still fall through to timeouts[new_state], which preserves the CLOSE timeout when conntrack accepts the RST as closing the flow.
This avoids the aggressive 10-second expiration window for non-exact RSTs while preserving the short timeout for RSTs that conntrack accepts as closing the flow.
---
LLM Generated explanations, may be completely bogus:
The evaluation is for the **6.6.y** tree this session opened on (pending-6.6 / 6.6.157). The bug is present there; the patch is a small, real conntrack timeout fix.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
- Record: **[netfilter/conntrack/tcp] [use] use UNACK timeout for non- closing RST packets**
- Subsystem: netfilter: conntrack: tcp:
- Verb: “use” here is a timeout-policy correction after RST validation already keeps the entry ESTABLISHED.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Record:
- **Suggested-by:** Florian Westphal <[email protected]> (conntrack maintainer)
- **Reported-by:** Minghao Zhang <[email protected]>
- **Reported-by:** Jianjun Chen <[email protected]> (two reporters)
- **Signed-off-by:** Minghao Zhang; Pablo Neira Ayuso (netfilter maintainer)
- **No Fixes: / Cc: stable in the committed text** (expected for this review queue)
- **v1 and v2 on the list both had** `Fixes: be0502a3f2e9 ("netfilter:
conntrack: tcp: only close if RST matches exact sequence")`. That tag was dropped when the patch was folded into an nf-next pull.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Record:
- **Bug:** After be0502a3f2e9, an in-window RST that does not match td_maxack leaves conntrack in ESTABLISHED so the peer can challenge-ACK. Timeout selection still keys off packet type (TCP_RST_SET) and always applies **CLOSE (10s)**.
- **Symptom:** A second non-exact RST can land after the first challenge ACK restored the timer, but while Linux still rate-limits challenge ACKs. The second RST drops the timer to 10s again; the suppressed challenge ACK never refreshes it; the conntrack entry expires while both TCP endpoints stay established. NAT/firewall then drop a live flow.
- **Root cause:** Timeout is chosen from the RST flag, not from the resulting state.
- **Fix:** RST that leaves new_state == TCP_CONNTRACK_ESTABLISHED uses **UNACK (5 min)**. Exact-match / RST-train RSTs still fall through to timeouts[new_state] (CLOSE).
- **Version info:** Tied to be0502a3f2e9 (2019-03-01), which is in
this 6.6 tree.
**Step 1.4: DETECT HIDDEN BUG FIXES**
- Record: **Not hidden.** It is a real timeout/state mismatch. v1/v2 called the 10s window **“exploitable”**. Pablo’s nf-next cover letter softened that to “more conservative timeout”; the failure mode is still live-session teardown through conntrack/NAT.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
- Record: **one file**, net/netfilter/nf_conntrack_proto_tcp.c; **~3 lines** in nf_conntrack_tcp_packet(). Surgical single-file logic fix.
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
- Record: After window validation, timeout selection:
- **Before:** any index == TCP_RST_SET → timeouts[TCP_CONNTRACK_CLOSE] (10s), even if new_state was forced back to ESTABLISHED (new_state = old_state at the non-exact RST path).
- **After:** only RST **and** new_state == TCP_CONNTRACK_ESTABLISHED → UNACK (5 min). Closing RSTs (tcp_conntracks[][] maps ESTABLISHED+RST → CLOSE, exact-seq / RST-train break without restoring ESTABLISHED) still get CLOSE.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
- Record: **[Logic / correctness]** plus a **security-relevant NAT teardown window**. Timeout no longer contradicts the RFC 5961 “stay ESTABLISHED for challenge ACK” path from be0502a3f2e9.
**Step 2.4: ASSESS THE FIX QUALITY**
- Record: **Obviously correct** for defaults (ESTABLISHED=5 days, UNACK=5 min, CLOSE=10s). Minimal. Regression risk is low:
- Dead flows after a bogus RST linger **5 min instead of 10s** (same UNACK used for unacked data / out-of-window FIN|RST).
- If sysctl sets ESTABLISHED **below** UNACK (e.g. 120s NAT boxes), this commit can **extend** the timer. Follow-up 73df81b38cb7f (timeouts[new_state] > timeouts[TCP_CONNTRACK_UNACK]) closes that.
Pablo: “Not a big deal… only affect timeout configurations where unack timeout is longer than established.” Defaults on 6.6 are fine.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
- Record: The unconditional RST→CLOSE timeout was added in **be0502a3f2e9** (Florian Westphal, 2019-03-01, v5.1 era). It is an ancestor of pending-6.6. Long-lived 6.6 code, not a new-mainline- only bug.
**Step 3.2: FOLLOW THE FIXES: TAG**
- Record: Committed message has **no Fixes:**. Submissions targeted **be0502a3f2e9**, which **is** in this tree (git merge-base --is- ancestor be0502a3f2e9 pending-6.6 → YES). That commit documented CLOSE timeout for non-exact RSTs as intentional; this patch revises that because challenge-ACK rate limiting makes the 10s window drop live flows.
**Step 3.3: CHECK FILE HISTORY**
- Record (on pending-6.6): related RST work includes 2bb6d82b586ea (invalid-seq RST direction check) and 628d694344a02 (UNACK for out- of-window FIN/RST). **Standalone** timeout change; not patch 2/N. Follow-up 73df81b38cb7f is **not** in pending-6.6 and should ride along once this is applied (it has Fixes: bf80e6802273).
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
- Record: Minghao Zhang / Jianjun Chen (Tsinghua) — reporters/researchers, not netfilter maintainers. Weight comes from **Suggested-by Florian** and **SOB Pablo**. No other Minghao commits on this file in 6.6.
**Step 3.5: DEPENDENT/PREREQUISITE COMMITS**
- Record: Needs the be0502 non-exact-RST ESTABLISHED path (present). Uses existing TCP_CONNTRACK_UNACK. **Applies standalone** on 6.6. Optional follow-up for inverted sysctl timeouts.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
- Record:
- b4 dig -c bf80e6802273a → v2: https://patch.msgid.link/20260729154
[email protected] - **v1** (2026-07-29): explicit CLOSE branch + UNACK fallback; **Fixes:** + “exploitable 10-second expiration window” - **v2:** Pablo/Florian simplification; UNACK only if `new_state == ESTABLISHED` - Florian (https://patch.msgid.link/[email protected]): asked to drop redundant CLOSE assignment and test a narrower condition. Author tested ESTABLISHED-only UNACK and sent v2. - **No NAK.** Queued in Pablo’s nf-next pull (patch 9/9), 2026-07-31: https://lists.openwall.net/netdev/2026/07/31/313
- Jakub forwarded an AI review
(https://lists.openwall.net/netdev/2026/08/05/12): should have Fixes:; CLOSE-for-inexact-RST was intentional in 2019; missing “only lower, never extend” guard; closing-RST CLOSE timeout not preserved for some non-default sysctls. The **extend** issue is exactly what 73df81b38cb7f later fixed.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
- Record (b4 dig -w): To/Cc **netfilter-devel**, **[email protected]**, **[email protected]**, Jianjun Chen. Right maintainers. Florian reviewed v1; Pablo merged.
**Step 4.3: SEARCH FOR THE BUG REPORT**
- Record: Dual Reported-by from Tsinghua. v1/v2 text: **exploitable** 10s window via RST + challenge-ACK rate limit. Concrete trigger, not syzbot. Syzbot CI on the series: **passed**
(https://ci.syzbot.org/series/36445e46-2abc-4e64-93d2-bb558ec1f53b).
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
- Record: Standalone nf-next patch (not a 9-patch dependency; the other 8 were unrelated flowtable/conncount work). Follow-up: 73df81b38cb7f / https://lists.openwall.net/netdev/2026/08/10/387 — “Reported by sashiko”.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
- Record: **No useful stable-list discussion found** for this subject (lore.kernel.org/stable search did not surface this patch). Not previously rejected for 6.6.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
- Record: **nf_conntrack_tcp_packet()** only.
**Step 5.2: TRACE CALLERS**
- Record: pending-6.6:net/netfilter/nf_conntrack_core.c:1897 — every tracked TCP packet. Softirq/hook path, not init-only.
**Step 5.3: TRACE CALLEES**
- Record: nf_ct_timeout_lookup(), tn->timeouts[], later nf_ct_refresh_acct(). Writes entry expiry.
**Step 5.4: FOLLOW THE CALL CHAIN**
- Record: Userspace/network reachable whenever CONFIG_NF_CONNTRACK tracks TCP (iptables/nftables/NAT, Docker, Kubernetes, firewalls). **High impact.** An on-path or in-window RST injector can hit it. Unprivileged remote: needs in-window (not exact) SEQ; that is the RFC 5961 threat model.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
- Record: Sibling branches already only **lower** timeout (RETRANS/UNACK/zero-window). This RST branch was the odd one-out. nf_tcp_handle_invalid() also uses UNACK for out-of-window FIN/RST (628d694).
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
- Record: **Yes on pending-6.6 / 6.6.157:**
```
else if (unlikely(index == TCP_RST_SET))
timeout = timeouts[TCP_CONNTRACK_CLOSE];
```at nf_conntrack_proto_tcp.c ~1327–1328. Non-exact RST still does new_state = old_state (~1260). be0502a3f2e9 is an ancestor. Candidate **bf80e6802273a is not** an ancestor of pending-6.6. Introduced with be0502 (2019), present for the whole 6.6 lifetime.
*(HEAD later detached at v7.3-rc4-70 during this session; that mainline tree already contains the fix. The stable tree this review is for remains 6.6.157 / pending-6.6, where the bug is still open.)*
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
- Record: **Clean apply.** Exact before-image on pending-6.6. No refactor of this hunk vs the candidate.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
- Record: 2bb6d82b586ea is a **different** RST CLOSE issue (SYN/RST direction). It does **not** change RST timeout selection. No earlier UNACK-for-non-closing-RST fix in 6.6.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: SUBSYSTEM AND CRITICALITY**
- Record: **netfilter conntrack TCP** — **IMPORTANT**. Core firewall/NAT path on virtually every router, distro firewall, and container host.
**Step 7.2: SUBSYSTEM ACTIVITY**
- Record: Mature tracker; this file still gets targeted RST/timeout fixes. Bug is old (be0502), not churn from a new subsystem.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
- Record: **Conntrack/NAT users** (CONFIG_NF_CONNTRACK) — default on most distro kernels. Not arch-specific.
**Step 8.2: TRIGGER CONDITIONS**
- Record: In-window, non-exact RST on an ESTABLISHED tracked flow. 6.6 still **per-socket** rate-limits challenge ACKs via __tcp_oow_rate_limited() and sysctl_tcp_invalid_ratelimit = HZ/2 (500ms), even with global tcp_challenge_ack_limit = INT_MAX. A second RST inside that window matches the commit’s scenario. Also:
single RST + lost/unseen challenge ACK (asymmetric routing) leaves a 10s expiry. **On-path attacker or sequence-in-window injection.**
**Step 8.3: FAILURE MODE SEVERITY**
- Record: **Live TCP dropped through NAT/firewall** after ~10s; endpoints stay ESTABLISHED. Not a panic. **HIGH** (session disruption / DoS on middleboxes). Authors called it **exploitable**.
**Step 8.4: RISK-BENEFIT RATIO**
- Record: **Benefit high** (stops silent NAT teardown of established sessions). **Risk low** (3-line, default UNACK < ESTABLISHED). Residual risk: short ESTABLISHED sysctl vs longer UNACK — mitigated by a one-line follow-up, not a reason to skip this fix.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: EVIDENCE**
**FOR:**
- Real, user-visible bug: conntrack expires while TCP stays up.
- Security-relevant (in-window RST + challenge-ACK throttle); v1/v2 said “exploitable”; had Fixes: be0502a3f2e9.
- be0502 and the buggy CLOSE timeout are in 6.6.
- Challenge-ACK **per-socket** throttle exists in 6.6 (HZ/2).
- Tiny, obviously correct for default timeouts; Florian suggested, Pablo merged, author tested v2.
- Applies cleanly to pending-6.6.
**AGAINST:**
- Merged via **nf-next**, not nf; committed text dropped Fixes: and “exploitable”.
- be0502 originally **meant** CLOSE timeout for non-exact RSTs (policy shift 10s → 5 min).
- Follow-up needed for ESTABLISHED < UNACK sysctl.
- Not a crash/corruption/deadlock.
**UNRESOLVED:** Full lore.kernel.org HTML was 403 (used b4 + openwall
+ local mbox instead). No CVE number found.
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — v2 tested by author; Florian/Pablo; syzbot CI passed.
2. Fixes a real bug that affects users? **PASS** — NAT/firewall drop of live TCP.
3. Important (crash/security/corruption/deadlock)? **PASS** — exploitable middlebox teardown / DoS, not a panic.
4. Small and contained? **PASS** — ~3 lines, one function.
5. No new features or APIs? **PASS** — existing UNACK timeout.
6. Can apply to this tree? **PASS** — exact match on pending-6.6.
**Step 9.3: EXCEPTION CATEGORIES**
- Record: None (not a device ID/quirk/DT/build/doc exception). Ordinary netfilter bugfix.
**Step 9.4: DECISION**
Backport. 6.6 has the 2019 RST-validation change **and** the 10s CLOSE timeout that undermines it. The 5-minute UNACK value is the same compromise already used for other “conntrack and endpoints disagree” cases. Take follow-up 73df81b38cb7f with it when possible; this commit is still right on default 6.6 timeouts without it.
---
## What the commit solves for stable users
On 6.6 firewalls/NAT, an in-window RST that is **not** the exact next SEQ leaves conntrack ESTABLISHED (RFC 5961) but still arms a **10s** timer. Linux then rate-limits challenge ACKs (~500ms per socket). A second such RST re-arms 10s with no refresh ACK, so conntrack deletes a flow that both endpoints still consider established. That is a real production failure and a plausible DoS on NAT.
## Stable rules / risk vs benefit
Meets the rules: small, tested, no new API, applies cleanly, fixes an important conntrack bug. Benefit is high for a common config; regression risk is a slightly longer hold of *stale* entries (5 min vs 10s), which is acceptable.
## Concerns
- Pair with 73df81b38cb7f so sysctl ESTABLISHED < UNACK cannot extend lifetime.
- Behavior change vs 2019 “intentional CLOSE timeout” is the point of the fix, not a blocker.
---
## Verification
- **[Phase 1]** Tags: Suggested-by Florian, two Reported-by, Pablo SOB; committed text has no Fixes:/Cc:stable; v1/v2 mbox **did** include Fixes: be0502a3f2e9 and “exploitable”.
- **[Phase 2]** Diff: 3-line change in nf_conntrack_tcp_packet() RST timeout arm; CLOSE preserved when new_state != ESTABLISHED.
- **[Phase 3]** be0502a3f2e9 is ancestor of pending-6.6; candidate is not. Blame: CLOSE-on-every-RST from be0502. Follow-up 73df81b38cb7f not in 6.6.
- **[Phase 3]** git show pending-6.6:net/netfilter/nf_conntrack_proto_tcp.c lines 1327–1328:
buggy index == TCP_RST_SET → CLOSE.
- **[Phase 4]** b4 dig -c bf80e6802273a: v1+v2; Florian review [email protected]; Pablo nf-next 9/9; Jakub AI review 2026-08-05; follow-up 2026-08-10 “Reported by sashiko”.
- **[Phase 4]** b4 dig -w: netfilter-devel, pablo, fw. b4 dig -a:
v1→v2 only.
- **[Phase 4]** lore.kernel.org WebFetch: **403**; used b4 mbox + openwall. Stable list: no hit on this subject.
- **[Phase 5]** Caller: nf_conntrack_core.c:1897 on every tracked TCP packet.
- **[Phase 6]** First probe: pending-6.6, make kernelversion 6.6.157. Later HEAD detached at v7.3-rc4-70 (mainline already has the fix). Re-checked **pending-6.6**: VERSION 6.6.157, buggy timeout present, exact before-image, candidate not ancestor.
- **[Phase 6]** 6.6 challenge ACK: __tcp_oow_rate_limited + sysctl_tcp_invalid_ratelimit = HZ/2; global limit INT_MAX does **not** disable per-socket limit.
- **[Phase 6]** Defaults on 6.6: ESTABLISHED 5 days, UNACK 5 min, CLOSE 10s.
- **[Phase 8]** Failure: NAT/conntrack drop of live TCP; severity HIGH / security-relevant.
- **UNVERIFIED:** CVE id (none found). Could not fetch lore HTML directly.
**YES**
net/netfilter/nf_conntrack_proto_tcp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_proto_tcp.c +3 -2
@@ -1325,8 +1325,9 @@ int nf_conntrack_tcp_packet(struct nf_conn *ct,if (ct->proto.tcp.retrans >= tn->tcp_max_retrans && timeouts[new_state] > timeouts[TCP_CONNTRACK_RETRANS ]) timeout = timeouts[TCP_CONNTRACK_RETRANS ]; -else if (unlikely (index ==TCP_RST_SET )) - timeout = timeouts[TCP_CONNTRACK_CLOSE ]; +else if (unlikely (index ==TCP_RST_SET && + new_state ==TCP_CONNTRACK_ESTABLISHED )) + timeout = timeouts[TCP_CONNTRACK_UNACK ];else if ((ct->proto.tcp.seen[0 ].flags | ct->proto.tcp.seen[1 ].flags) &IP_CT_TCP_FLAG_DATA_UNACKNOWLEDGED && timeouts[new_state] > timeouts[TCP_CONNTRACK_UNACK ])
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: ath10k: trigger hardware recovery upon rx failures
In reply to Sasha LevinFrom: Manikanta Pubbisetty <[email protected]>
[ Upstream commit f78210dd4bea09090b828adc2733cad4b9916306 ]
When an error occurs during RX packet processing (e.g., MSDU done failure), the driver sets rx_confused and drops all subsequent RX packets until a Wi-Fi ON/OFF cycle clears the flag. This can leave the device in a bad state where it cannot process RX data traffic.
Instead of leaving the device in such a state, trigger hardware recovery so that such an error state can be reset and the device can function again normally.
Tested-on: WCN3990 hw1.0 WLAN.HL.3.2.2.c10-00754-QCAHLSWMTPL-1
Tested-on: QCA6174 hw3.2 PCI WLAN.RM.4.4.1-00288-QCARMSWPZ-1
Tested-on: QCA6174 hw3.2 SDIO WLAN.RMH.4.4.1-00189
---
LLM Generated explanations, may be completely bogus:
The local tree is **Linux 7.3-rc4** (v7.3-rc4-27-gf0100363d8c37). The surrounding ath10k RX and recovery code is present, and this is a small, real device-hang fix.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[wifi/ath10k] [trigger] [start hardware recovery when RX processing fails instead of leaving the device stuck]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected)
- **Reported-by:** none
- **Tested-on:** WCN3990 hw1.0; QCA6174 hw3.2 PCI; QCA6174 hw3.2 SDIO (three hardware/firmware combinations)
- **Reviewed-by:** Rameshkumar Sundaram, Baochen Qiang (Qualcomm ath reviewers)
- **Acked-by:** none
- **Link:** https://patch.msgid.link/20260710060406.3323260-1-
[email protected]
- **Cc: stable:** none (expected)
- **Signed-off-by:** Manikanta Pubbisetty (author); Jeff Johnson (ath maintainer). Ignoring Sasha Levin SOB if present in pipeline copies; the tree copy has none.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** On RX processing errors (e.g. MSDU_DONE not set), the driver sets htt->rx_confused and then drops all further RX until a Wi-Fi ON/OFF cycle.
- **Symptom:** Device stays in a bad state and cannot process RX data traffic; connectivity is dead until the user toggles the interface.
- **Version info:** none in the message. The FIXME this removes dates to 2014 (e0bd7513bbc85, v3.19-rc1).
- **Root cause:** Error paths mark the ring confused but never reset hardware, so the device stays inoperable.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is an explicit functional fix:
replace “leave device inoperable” with the existing recovery path. The removed FIXME said the same thing since 2014.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/net/wireless/ath/ath10k/htt_rx.c — **3 insertions, 3 deletions** (git show --stat: 6 lines changed).
- Functions: ath10k_htt_rx_handle_amsdu(), ath10k_htt_rx_in_ord_ind() (two sites).
- Scope: single-file surgical error-path change.
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
1. ath10k_htt_rx_handle_amsdu() when ath10k_htt_rx_amsdu_pop() returns < 0: previously purged skbs, set rx_confused, returned. Now also calls ath10k_core_start_recovery(ar). FIXME removed.
2. ath10k_htt_rx_in_ord_ind() when pop-paddr-list fails: same recovery call after rx_confused = true.
3. Same function when ath10k_htt_rx_extract_amsdu() fails: same recovery call after purge + rx_confused.
All three are **error paths only**. Normal RX is unchanged.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Logic / hardware-stuck recovery.** After RX ring corruption the driver permanently refuses RX (if (htt->rx_confused) return -EIO). Recovery queues restart_work → ath10k_halt() → ieee80211_restart_hw() → ath10k_start() → ath10k_core_start() → ath10k_htt_rx_alloc(), which sets htt->rx_confused = false. That is the same recovery used on firmware crash and WMI timeout.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct and minimal. ath10k_core_start_recovery() only queues work (queue_work(ar->workqueue_aux, &ar->recovery_check_work) in this tree), so it is safe from NAPI. Existing consecutive-failure logic can WEDGE the device, so this does not create an infinite restart loop. Risk is a brief firmware restart on a path that was already dead. No API or data-structure changes.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Confused-without-reboot behavior introduced in **e0bd7513bbc85** (“ath10k: refactor htt->rx_confused”, 2014-11-20), first in **v3.19-rc1**.
- handle_amsdu error path from **18235664e7f9a** (Rajkumar Manoharan, 2016).
- In-order pop/extract error paths from **c545070e404bf** (“ath10k:
implement rx reorder support”, 2015), v4.1 era.
- Recovery calls added by this commit **f78210dd4bea0**.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Historical introducer is e0bd7513bbc85 (ancestor of HEAD). git merge-base --is-ancestor e0bd7513bbc85 HEAD is true.
**Step 3.3: CHECK FILE HISTORY**
Record: Related but independent: 7393878255e49 (skb leak on incomplete MSDU pop) is a different patch/date/msgid. This commit is standalone 1/1. No prerequisite refactor in htt_rx.c.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Manikanta Pubbisetty is a Qualcomm ath10k contributor (leak fix on the same file shortly before). Not the listed maintainer; maintainer Jeff Johnson applied it.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Record:
- ath10k_core_start_recovery() exists since **5dadbe4e3718** (v5.11-rc1) — ancestor of HEAD.
- Current implementation from **f35a07a4842a8** (Oct 2025) — ancestor of HEAD; queues work, does not block in the caller.
- Can apply standalone on this tree: the function, rx_confused, and both RX handlers exist.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- Lore/msgid: https://patch.msgid.link/20260710060406.3323260-1-
[email protected]
- b4 dig -a: **v1 only**, single patch, no v2/v3.
- Reviews: Baochen Qiang Reviewed-by; Rameshkumar Sundaram “Actual change looks fine” + Reviewed-by. No NAKs, no stable nomination, no risk flags.
- Jeff Johnson: “Applied, thanks!” (da5d73e12af2 in ath.git; mainline sha f78210dd4bea0).
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: b4 dig -w original To/Cc: author, [email protected], [email protected]. Applied by **Jeff Johnson**, listed ATH10K maintainer.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla. Qualcomm Tested-on on three chipsets implies they hit RX-stuck in product testing, not a theoretical FIXME-only cleanup.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone [ath-next] 1/1. The earlier skb-leak patch is not required for this change.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org HTTP fetch returned 403. b4 dig thread has no stable discussion. **UNVERIFIED** whether linux-stable ever discussed this specific patch; no evidence it was rejected.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
Record: ath10k_htt_rx_handle_amsdu, ath10k_htt_rx_in_ord_ind; callee ath10k_core_start_recovery.
**Step 5.2: TRACE CALLERS**
Record: Both called from ath10k_htt_txrx_compl_task() (NAPI poll): in- order queue then num_mpdus_ready loop. On -EIO it stops processing. That is the normal data RX completion path, not init-only.
**Step 5.3: TRACE CALLEES**
Record: ath10k_core_start_recovery() → queue_work(workqueue_aux, recovery_check_work) → may queue_work(workqueue, restart_work) → halt
+ ieee80211_restart_hw(). No lock taken in start_recovery. in_ord_ind holds rx_ring.lock while queuing work; that is safe.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace/network RX → mac80211 → NAPI → htt_rx. Reachable on any associated ath10k interface when firmware/DMA delivers a bad MSDU or corrupted ring. Unprivileged traffic can contribute; the actual trigger is firmware/hardware RX error, not a crafted syscall.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same ath10k_core_start_recovery() already used in pci.c (firmware crash), wmi.c (command timeout), sdio.c/snoc.c, debug.c. This patch extends that pattern to RX ring failure. All rx_confused = true sites in htt_rx.c are covered.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- git describe HEAD / make kernelversion: **7.3.0-rc4**.
- File and functions exist. rx_confused still used. Recovery API present.
- Bug introduced v3.19; long present in this lineage.
- Working tree already contains f78210dd4bea0 (git merge-base --is- ancestor exit 0). That is the mainline commit under review, not a reason to treat the bug as absent from this series’ code.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Hunks match this tree’s htt_rx.c. Recovery is the non-blocking workqueue form. Expected apply: **clean** on a 7.3-era tree that still has the pre-image; current HEAD is already post-image.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No earlier alternative fix for “reboot on rx_confused”. 51fc7d74ce4a1 only clears the flag on load. This is the fix that actually starts recovery.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: **drivers/net/wireless/ath/ath10k** — **IMPORTANT** (not core mm/fs, but QCA6174/WCN3990 are common laptop/phone Wi-Fi). Status inMAINTAINERS: Supported; maintainer Jeff Johnson.
**Step 7.2: SUBSYSTEM ACTIVITY**
Record: Actively maintained (Qualcomm patches through 2026). The stuck- RX behavior itself is old; the recovery helper is mature.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Record: **Driver-specific**, CONFIG_ATH10K*. QCA6174 is widely used in PCs; WCN3990 on Qualcomm platforms.
**Step 8.2: TRIGGER CONDITIONS**
Record: RX ring pop/extract failure (incomplete MSDU, corrupted ring). Not every packet; when it hits, RX stays dead until iface toggle. Not a userspace exploit path.
**Step 8.3: FAILURE MODE SEVERITY**
Record: **Wi-Fi RX permanently stopped** until ON/OFF. Not a panic/UAF, but the device is inoperable — the 2014 FIXME called it that. Severity **HIGH** (driver hang / loss of connectivity). Consecutive recovery failures can WEDGE, which is existing policy, not new.
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit:** Restores Wi-Fi after RX ring confusion without a manual toggle; uses the same recovery as firmware crash.
- **Risk:** Very low (3 calls to an existing queue_work helper; error paths only). Worst case is a restart of an already-dead radio.
- **Ratio:** Strongly favors taking the fix.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real user-visible bug: all RX dropped until Wi-Fi toggle.
- Acknowledged since 2014 in-tree FIXME.
- Small (3 calls, one file), obviously correct.
- Uses existing, NAPI-safe recovery.
- Tested on three chip/bus combinations.
- Reviewed and applied by ath maintainers; no NAKs.
- All rx_confused = true sites updated.
- Code and ath10k_core_start_recovery() exist in this 7.3-rc4 tree.
AGAINST:
- Not a crash, UAF, or security bug; workaround exists (iface bounce).
- Trigger is firmware/hardware RX error, not every boot.
- No Fixes:/Cc: stable (not a negative per the rules).
UNRESOLVED:
- lore.kernel.org WebFetch 403; thread recovered via b4 dig -m.
- No independent end-user bugzilla; product Tested-on only.
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — three Tested-on lines, two Reviewed-by, maintainer applied.
2. Fixes a real bug that affects users? **PASS** — RX stays dead until ON/OFF.
3. Important issue? **PASS** — device inoperable / connectivity hang, HIGH.
4. Small and contained? **PASS** — 3/3 lines, one file.
5. No new features or APIs? **PASS** — only calls existing recovery.
6. Can apply to the local tree? **PASS** — htt_rx.c and ath10k_core_start_recovery() match; this tree is 7.3-rc4.
**Step 9.3: EXCEPTION CATEGORIES**
Record: None (not a device ID/quirk/DT/build/doc). Qualifies as a normal bugfix.
**Step 9.4: DECISION**
This tree has the ath10k RX confused paths and the recovery helper. Leaving rx_confused set without restart makes the radio unusable; kicking ath10k_core_start_recovery() is the same response already used for firmware crash and is safe from NAPI. That is a contained, tested hang fix appropriate for this tree.
---
## What the commit solves for this tree
When htt RX pop/extract fails, ath10k previously set rx_confused and discarded all later RX until a full Wi-Fi cycle. Users see a dead receive path. The patch queues the existing hardware restart so ath10k_htt_rx_alloc() clears the flag and the device can RX again.
It meets stable rules: obviously correct, real hang, ~3 lines, no new API. Benefit is restoring Wi-Fi after ring confusion; risk is a restart of an already-stuck device.
---
## Verification
- **[Phase 1]** Tags: Tested-on ×3, Reviewed-by ×2, Link msgid; no Fixes/Reported-by/Cc:stable.
- **[Phase 2]** git show --stat f78210dd4bea0: htt_rx.c +3/-3; three ath10k_core_start_recovery() calls on error paths; FIXME removed.
- **[Phase 2]** Read ath10k_core_start_recovery() at core.c:2534 — queue_work only.
- **[Phase 2]** Read restart path: ath10k_core_restart → ieee80211_restart_hw → ath10k_start → ath10k_core_start → ath10k_htt_rx_alloc() sets rx_confused = false (htt_rx.c:796).
- **[Phase 3]** git log -S / git describe --contains e0bd7513bbc85:
FIXME from v3.19-rc1.
- **[Phase 3]** ath10k_core_start_recovery added in 5dadbe4e3718 (v5.11-rc1); ancestor of HEAD.
- **[Phase 3]** git merge-base --is-ancestor for f35a07a4842a8, 5dadbe4e3718, c545070e404bf, e0bd7513bbc85: all 0.
- **[Phase 3]** Related leak commit 7393878255e49 is a separate patch, not a prerequisite.
- **[Phase 4]** b4 dig -c f78210dd4bea0: msgid 20260710060406.3323260-1.
- **[Phase 4]** b4 dig -a: v1 only.
- **[Phase 4]** b4 dig -w: linux-wireless + ath10k lists.
- **[Phase 4]** b4 dig -m: Baochen/Rameshkumar Reviewed-by; Jeff Johnson applied; no NAK; no Cc:stable in thread.
- **[Phase 4]** WebFetch lore.kernel.org: 403. UNVERIFIED via HTTP; thread obtained via b4.
- **[Phase 5]** Callers: ath10k_htt_txrx_compl_task (htt_rx.c:4382–4395).
- **[Phase 5]** Grep: all three rx_confused = true sites got recovery; other start_recovery users are pci/wmi/sdio/snoc/debug.
- **[Phase 6]** git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion: 7.3.0-rc4.
- **[Phase 6]** git merge-base --is-ancestor f78210dd4bea0 HEAD: 0 (commit is in this tree’s history).
- **[Phase 7]** MAINTAINERS: ATH10K Supported, Jeff Johnson.
- **[Phase 8]** Failure mode: RX hung until iface toggle; recovery already rate-limited to WEDGED.
- **UNVERIFIED:** linux-stable mailing list (HTTP 403); no public non- Qualcomm reproducer.
The fix is small, surgical, and meets the stable criteria for this 7.3-rc4 tree.
**YES**
drivers/net/wireless/ath/ath10k/htt_rx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/htt_rx.c +3 -3
@@ -2345,10 +2345,8 @@ static int ath10k_htt_rx_handle_amsdu(struct ath10k_htt *htt)if (ret <0 ) {ath10k_warn (ar,"rx ring became corrupted: %d\n" , ret);__skb_queue_purge (&amsdu); -/* FIXME: It's probably a good idea to reboot the -* device instead of leaving it inoperable. -*/ htt->rx_confused = true; +ath10k_core_start_recovery (ar);return ret; }
@@ -3313,6 +3311,7 @@ static int ath10k_htt_rx_in_ord_ind(struct ath10k *ar, struct sk_buff *skb)if (ret <0 ) {ath10k_warn (ar,"failed to pop paddr list: %d\n" , ret); htt->rx_confused = true; +ath10k_core_start_recovery (ar);return -EIO ; }
@@ -3346,6 +3345,7 @@ static int ath10k_htt_rx_in_ord_ind(struct ath10k *ar, struct sk_buff *skb)ath10k_warn (ar,"failed to extract amsdu: %d\n" , ret); htt->rx_confused = true;__skb_queue_purge (&list); +ath10k_core_start_recovery (ar);return -EIO ; } }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 net: usb: qmi_wwan: add Rolling Wireless RN947R
In reply to Sasha LevinFrom: Reinhard Speyerer <[email protected]>
[ Upstream commit 7375d38364a9aa66fb31716bcefef38aecad75d8 ]
Add Rolling Wireless RN947R 0x9300 composition:
DIAG + ADB + NMEA + MODEM + RMNET + QDSS + ADPL
T: Bus=01 Lev=01 Prnt=01 Port=02 Cnt=02 Dev#= 6 Spd=480 MxCh= 0 D: Ver= 2.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=33f8 ProdID=9300 Rev= 0.00 S: Manufacturer=Rolling Wireless S: Product=RN947R S: SerialNumber=xxxxxxxxxxx C:* #Ifs= 7 Cfg#= 1 Atr=a0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=usbfs E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=84(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=86(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 8 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=50 Driver=qmi_wwan E: Ad=88(I) Atr=03(Int.) MxPS= 8 Ivl=32ms E: Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#=21 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=70 Driver=(none)
E: Ad=89(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#=22 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=80 Driver=(none)
E: Ad=8a(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
---
LLM Generated explanations, may be completely bogus:
This is a one-line USB ID addition to the existing qmi_wwan driver for Rolling Wireless RN947R (33f8:9300). That is a standard stable exception, and the ID table plus DTR quirk already exist in this 6.18.y tree.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [net: usb: qmi_wwan] [add] [USB device ID for Rolling Wireless RN947R]
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Link: https://patch.msgid.link/[email protected]
- Signed-off-by: Reinhard Speyerer <[email protected]> (author)
- Signed-off-by: Jakub Kicinski <[email protected]> (netdev maintainer, applied)
- No Fixes: tag (expected)
- No Reported-by / Tested-by / Reviewed-by / Acked-by
- No Cc: stable (expected)
- Ignored pipeline SOB / Upstream commit marker
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug description: RN947R USB WWAN modem (Vendor=33f8 ProdID=9300) is not in qmi_wwan’s ID table, so the RMNET/QMI network function does not bind.
- Symptom: no qmi_wwan netdev for this modem; cellular data does not come up out of the box.
- Version information: none stated.
- Root cause: missing USB ID / interface mapping. lsusb -t-style dump shows If#=8 Cls=ff Sub=ff Prot=50 as the QMI/RMNET function. Composition is DIAG + ADB + NMEA + MODEM + RMNET + QDSS + ADPL.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a hidden crash/leak fix. It is an explicit device-ID enablement, which stable rules treat as a first-class exception.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/net/usb/qmi_wwan.c (+1 / -0)
- Function/table: products[] (static const struct usb_device_id)
- Scope: single-file, one-line surgical ID addition
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: 33f8:9300 is unmatched; USB core does not probe qmi_wwan for interface 8.
- After: QMI_QUIRK_SET_DTR(0x33f8, 0x9300, 8) matches vendor/product/interface 8 and sets qmi_wwan_info_quirk_dtr.
- Path: USB enumeration / driver probe only. No error-path or hot-path logic change.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Category: hardware enablement / USB device ID (stable exception 1).
- Mechanism: QMI_QUIRK_SET_DTR expands to USB_DEVICE_INTERFACE_NUMBER plus DTR quirk driver_info. Interface 8 matches the dump (Prot=50, QMI/RMNET). DTR quirk is the same pattern as Rolling RW101 (33f8:0104) and other Qualcomm USB WWAN entries.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: VID/PID/interface taken from a real device dump; match is interface-number-specific so DIAG/ADB/NMEA/MODEM/QDSS/ADPL are not claimed.
- Minimal: one table entry, no API or structure change.
- Regression risk: very low; only 33f8:9300 is affected. Wrong interface number would be the main risk, and the dump confirms If#=8.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Insertion sits next to Rolling RW101: d362046021ea12 (“net:usb:qmi_wwan: support Rolling modules”, Vanillan Wang, 2024-04-16).
- That RW101 ID is in this tree’s v6.18.57 base (git merge-base --is- ancestor d362046021ea1 v6.18.57 succeeded).
- This is extending an existing vendor block, not introducing a new driver.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Not applicable. This does not revert or repair a prior logic bug.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- Recent qmi_wwan history is dominated by the same class of ID additions (Quectel, Telit, MeiG, Fibocom, SIMCom).
- No prerequisite refactor is required; products[] and QMI_QUIRK_SET_DTR are long-standing.
- Standalone: subject is not “patch X/Y”. b4 dig -a shows a single v1 patch.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record:
- Reinhard Speyerer has prior qmi_wwan ID/work in this history (e.g. Fibocom FG132 64761c980cbf7).
- Not the listed maintainer; maintainer is Bjørn Mork (MAINTAINERS:
USB QMI WWAN NETWORK DRIVER). The patch was mailed to [email protected].
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record:
- Depends only on QMI_QUIRK_SET_DTR / USB_DEVICE_INTERFACE_NUMBER, both present.
- No companion option.c change is in this series. Serial AT/NMEA/DIAG auto-bind is separate; this patch alone still enables the WWAN netdev. Can apply standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 7375d38364a9aa66fb31716bcefef38aecad75d8 matched
https://patch.msgid.link/[email protected]
- b4 dig -a: only v1, 2026-09-25, [PATCH net] net: usb: qmi_wwan: add Rolling Wireless RN947R
- Thread (saved via b4 dig -m): submission, then patchwork-bot “applied to netdev/net.git (main) by Jakub Kicinski”. No NAK, no review objections, no later revision.
- No reviewer Cc: stable in the thread.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To [email protected], Cc [email protected]. Subsystem maintainer was on To. Applied by netdev maintainer. No explicit Reviewed-by in the committed message.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla. Evidence of a real device is the author’s usb-devices dump (Manufacturer=Rolling Wireless, Product=RN947R, 33f8:9300). User population is owners of that modem.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Single-patch series. No option.c RN947R commit in this tree (git log --grep=RN947R -- drivers/ only finds this qmi_wwan change). Web search did not find a matching option serial patch.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: UNVERIFIED. WebFetch of lore.kernel.org/stable/?q=RN947R returned 403. No local evidence this ID was rejected for stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: No function body edited. Data change in products[], consumed as qmi_wwan_driver.id_table.
Step 5.2: TRACE CALLERS
Record:
- products -> qmi_wwan_driver.id_table -> USB core match -> qmi_wwan_probe() -> usbnet bind path (qmi_wwan_bind).
- Reachable on device plug-in / boot with the modem attached. Not interrupt or syscall hot path for other devices.
Step 5.3: TRACE CALLEES
Record: Unchanged. Bind still uses existing qmi_wwan_bind / DTR handling (qmi_wwan_change_dtr when QMI_WWAN_QUIRK_DTR or bcdUSB >= 0x0201). Dump has Ver= 2.10, so DTR would be set even with QMI_FIXED_INTF; QMI_QUIRK_SET_DTR matches sibling Rolling entries.
Step 5.4: FOLLOW THE CALL CHAIN
Record: Userspace-visible: plugging the modem should create a QMI WWAN netdev and cdc-wdm control node. Trigger is ordinary USB enumeration, not an obscure debug path.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same QMI_QUIRK_SET_DTR(vend, prod, intf) pattern is used throughout products[], including 33f8:0104 RW101. This is the established way to add Qualcomm RMNET compositions.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record:
- Local tree: git describe HEAD / make kernelversion => **6.18.57** (VERSION=6 PATCHLEVEL=18 SUBLEVEL=57).
- drivers/net/usb/qmi_wwan.c exists; CONFIG_USB_NET_QMI_WWAN exists; QMI_QUIRK_SET_DTR exists.
- git show v6.18.57:drivers/net/usb/qmi_wwan.c has Rolling RW101 (33f8:0104) and **does not** have 33f8:9300 / RN947R. The missing- ID problem exists on this 6.18.y base.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Clean apply. v6.18.57 context is identical around the insertion point:
```
{QMI_QUIRK_SET_DTR(0x33f8, 0x0104, 4)}, /* Rolling RW101 RMNET */
{QMI_FIXED_INTF(0x2dee, 0x4d22, 5)}, /* MeiG Smart SRM825L */
```No refactor between mainline hunk and this tree.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No other RN947R ID in this tree’s option.c or qmi_wwan.c on the v6.18.57 base. No alternate fix for 33f8:9300.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [drivers/net/usb/qmi_wwan] [IMPORTANT for WWAN users, peripheral for everyone else]. Mature, non-staging driver used by laptops and embedded LTE/5G modems.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Actively maintained via ID-table additions. Maintainer Bjørn Mork; netdev applies these routinely. Mature ID-table design.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver-specific / hardware-specific. Only Rolling Wireless RN947R (33f8:9300). Other USB devices unchanged.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Plug in the modem or boot with it attached. Common for those users. Unprivileged users do not get a new attack surface; this is bind- table matching.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: Without the ID, the RMNET function stays unbound; WWAN networking does not work. Not a panic/UAF. Severity MEDIUM as a functional hardware-support miss, and it still qualifies under the device-ID exception.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: HIGH for RN947R users (modem network interface works); zero effect on others.
- Risk: VERY LOW (1 line, existing macro, existing driver, VID:PID:interface match).
- Ratio: strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Explicit stable exception: USB ID added to an existing driver.
- One line, obviously correct, matches a real device dump (If#=8, Prot=50).
- Driver, macros, and Rolling vendor support already in 6.18.57.
- Applies cleanly next to RW101.
- Mailed to qmi_wwan maintainer, applied by netdev maintainer, v1 with no NAK.
- Same pattern as many other qmi_wwan ID additions.
AGAINST:
- Does not fix a crash, UAF, or corruption.
- No Tested-by/Reviewed-by tags.
- option.c still lacks 33f8:9300, so serial ports may need a separate ID or new_id; that does not block the netdev ID.
UNRESOLVED:
- lore.kernel.org WebFetch 403 for stable@ search.
- Whether an option serial companion exists upstream later than this tree.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — dump-backed ID, applied to netdev/net.
2. Fixes a real bug that affects users? PASS — modem otherwise has no QMI netdev.
3. Important issue? PASS under device-ID exception (hardware enablement for existing driver).
4. Small and contained? PASS — +1 line in one table.
5. No new features or APIs? PASS — no new driver, syscall, or userspace API; ID only.
6. Can apply to the local tree? PASS — v6.18.57 has identical context.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Device ID addition to existing driver (USB ID in qmi_wwan).
Step 9.4: MAKE YOUR DECISION
This should be backported to this 6.18.y tree. It is the standard, low- risk USB ID pattern stable already takes for qmi_wwan.
What problem it solves: RN947R owners on 6.18.y get a working QMI/RMNET interface instead of an unbound USB function.
Risk vs benefit: one matching table entry vs. a non-working WWAN modem. Benefit dominates.
Concerns: serial option binding is incomplete without a separate ID; that is independent and not a reason to drop this netdev ID.
Verification:
- [Phase 1] Parsed subject/tags/body: device-ID add; Link to patch.msgid.link; SOB Speyerer + Kicinski; no Fixes/syzbot.
- [Phase 2] Diff: +1 line in products[]; QMI_QUIRK_SET_DTR(0x33f8, 0x9300, 8) matches dump If#=8.
- [Phase 2] Read QMI_QUIRK_SET_DTR / qmi_wwan_info_quirk_dtr / DTR logic at bind (lines 804–825, 938–958).
- [Phase 3] git blame around insertion: RW101 from d362046021ea12 (2024); ancestor of v6.18.57.
- [Phase 3] git log --oneline -20 -- drivers/net/usb/qmi_wwan.c: many similar ID adds; this is standalone.
- [Phase 3] git log --author='Reinhard Speyerer' -- drivers/net/usb/:
prior qmi_wwan ID work.
- [Phase 4] b4 dig -c 7375d38364a9…: lore URL found; -a v1 only; -w To [email protected] Cc netdev; -m thread is submit + applied-bot, no NAK.
- [Phase 4] lore WebFetch 403; used b4 mbox instead.
- [Phase 4] WebSearch: no option.c RN947R companion found.
- [Phase 5] products -> qmi_wwan_driver.id_table -> qmi_wwan_probe; MODULE_DEVICE_TABLE(usb, products).
- [Phase 5] option.c has other 33f8 IDs, not 0x9300.
- [Phase 6] git describe HEAD / Makefile: 6.18.57. git show v6.18.57:drivers/net/usb/qmi_wwan.c has RW101, lacks RN947R. Apply context matches.
- [Phase 6] git merge-base --is-ancestor 7375d38364a9 HEAD is false (upstream SHA not this history); evaluate against local 6.18.y code, not that SHA.
- [Phase 7] MAINTAINERS: USB QMI WWAN NETWORK DRIVER, M: Bjørn Mork.
- [Phase 8] Failure mode: unbound RMNET on this VID:PID only; risk confined to that device.
- UNVERIFIED: stable@ lore discussion (HTTP 403).
**YES**
drivers/net/usb/qmi_wwan.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/usb/qmi_wwan.c +1 -0
@@ -1453,6 +1453,7 @@ static const struct usb_device_id products[] = { {QMI_QUIRK_SET_DTR(0x1546, 0x1312, 4)}, /* u-blox LARA-R6 01B */ {QMI_QUIRK_SET_DTR(0x1546, 0x1342, 4)}, /* u-blox LARA-L6 */ {QMI_QUIRK_SET_DTR(0x33f8, 0x0104, 4)}, /* Rolling RW101 RMNET */ + {QMI_QUIRK_SET_DTR(0x33f8, 0x9300, 8)}, /* Rolling RN947R RMNET */ {QMI_FIXED_INTF(0x2dee, 0x4d22, 5)}, /* MeiG Smart SRM825L */ {QMI_QUIRK_SET_DTR(0x2dee, 0x4d63, 0)}, /* MeiG SRM813Q w/ Modem(PPP) */ {QMI_QUIRK_SET_DTR(0x2dee, 0x4d64, 0)}, /* MeiG SRM813Q w/ NMEA */
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 usb: mtu3: Fix double dereference in TP_printk
In reply to Sasha LevinFrom: Vladimir Murzin <[email protected]>
[ Upstream commit cfb3293c4573289f11f913611f530ea6b1926d67 ]
Paul reported kernel splat:
[ 0.000000] TRACE EVENT ERROR: Event mtu3_gadget_ep_set_halt has double dereference in TP_printk: &REC->gpd_ring->dma [ 0.000000] ------------[ cut here ]------------ [ 0.000000] Event mtu3_gadget_ep_set_halt has double dereference in TP_printk: &REC->gpd_ring->dma [ 0.000000] WARNING: kernel/trace/trace_events.c:420 at test_double_dereference+0x144/0x14c, CPU#0: swapper/0/0 [ 0.000000] Modules linked in: [ 0.000000] CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 7.3.0-rc1 #15247 PREEMPT [ 0.000000] Hardware name: linux,dummy-virt (DT) [ 0.000000] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 0.000000] pc : test_double_dereference+0x144/0x14c [ 0.000000] lr : test_double_dereference+0x144/0x14c [ 0.000000] sp : ffffc80aa7633bf0 [ 0.000000] x29: ffffc80aa7633bf0 x28: ffffc80aa7c0f047 x27: 000508b58019388f [ 0.000000] x26: 0000000000000003 x25: 0000000000000007 x24: ffffc80aa5fceff8 [ 0.000000] x23: ffffc80aa7c0f05a x22: ffffc80aa64edfe8 x21: ffffc80aa7c0fce8 [ 0.000000] x20: ffffc80aa7c0f047 x19: 0000000000000013 x18: 0000000000000001 [ 0.000000] x17: 6572656420656c62 x16: 756f642073616820 x15: 746c61685f746573 [ 0.000000] x14: 0000000000000000 x13: ffff000139d90000 x12: 0000000000000045 [ 0.000000] x11: 00000000000000cf x10: ffff00013f546428 x9 : ffff000139d90000 [ 0.000000] x8 : 3fffffffffffc000 x7 : 0000000000000001 x6 : 0000000000000001 [ 0.000000] x5 : ffff00013f4e6440 x4 : 0000000000000000 x3 : 0000000000000000 [ 0.000000] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffffc80aa764a700 [ 0.000000] Call trace: [ 0.000000] test_double_dereference+0x144/0x14c (P) [ 0.000000] trace_event_raw_init+0x37c/0x5d8 [ 0.000000] event_init+0x34/0xc0 [ 0.000000] trace_event_init+0xec/0x588 [ 0.000000] trace_init+0x24/0x6e0 [ 0.000000] start_kernel+0x4a0/0x8ec [ 0.000000] __primary_switched+0x88/0x90 [ 0.000000] irq event stamp: 0 [ 0.000000] hardirqs last enabled at (0): [<0000000000000000>] 0x0 [ 0.000000] hardirqs last disabled at (0): [<0000000000000000>] 0x0 [ 0.000000] softirqs last enabled at (0): [<0000000000000000>] 0x0 [ 0.000000] softirqs last disabled at (0): [<0000000000000000>] 0x0 [ 0.000000] ---[ end trace 0000000000000000 ]--- [ 0.000000] TRACE EVENT ERROR: Event mtu3_gadget_ep_disable has double dereference in TP_printk: &REC->gpd_ring->dma [ 0.000000] TRACE EVENT ERROR: Event mtu3_gadget_ep_enable has double dereference in TP_printk: &REC->gpd_ring->dma
Which also observed by Mark and myself.
The splat it result of new check introduced by b5cc230af5e5 ("tracing:
Warn when an event dereferences a pointer in TP_printk()") which correctly catches issue with %pad dereferencing the address saved in the ring buffer. TP_fast_assign() logic gets executed when the tracepoint is triggered, however the TP_printk() is executed when the user reads the trace buffer which could be seconds, minutes, hours, days, even months later and nothing guarantee that __entry->gpd_ring pointer will still be pointing to what it was when it was recorded.
Fix the issue by capturing immediate value of gpd_ring.dma when trace point is triggered.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: **[usb/mtu3]** **[Fix]** Double dereference in TP_printk for the mtu3_log_ep trace class (mtu3_gadget_ep_enable/disable/set_halt).
**Step 1.2: Tags**
Record:
- **Reported-by:** Paul E. McKenney
- **Tested-by:** Mark Rutland
- **Reviewed-by:** Steven Rostedt (tracing maintainer)
- **Signed-off-by:** Vladimir Murzin (author); Paul E. McKenney (merged via his tree)
- **No Fixes:** tag (expected for this review)
- **No Cc: stable** (expected)
- No syzbot, no CVE, no bugzilla Link
- Ignore pipeline “Upstream commit” / Sasha Levin SOB
Notable: three independent observers (Paul, Mark, the author). Rostedt reviewed it.
**Step 1.3: Body**
Record:
- **Bug:** TP_printk uses %pad with &REC->gpd_ring->dma, i.e. it follows a pointer stored in the ring buffer when the trace is printed, not when it is recorded.
- **Symptom that motivated the patch:** boot WARNING in test_double_dereference() on 7.3.0-rc1 (linux,dummy-virt), events mtu3_gadget_ep_set_halt/disable/enable.
- **Root cause (author):** check added by b5cc230af5e5 (“tracing: Warn when an event dereferences a pointer in TP_printk()”). TP_fast_assign() runs at the tracepoint; TP_printk() can run much later, when __entry->gpd_ring may be stale.
- **Fix:** snapshot mep->gpd_ring.dma into a dma_addr_t field at assign time and print &__entry->gpd_ring_dma.
- **Versions in the message:** 7.3.0-rc1 only. Mailing list later says the splat was still present in 7.3-rc5/rc6.
Linus’s merge of 8fc6e594884a describes the same bug as pre-existing:
it can dump garbage traces because TP_printk() may run after the pointed-to memory is gone. Extra tracing checks only **exposed** it.
**Step 1.4: Hidden bug fix?**
Record: Not hidden. It is an explicit tracing UAF/stale-pointer fix. The boot WARN is how it was found; the real defect is delayed dereference of a saved kernel pointer.
---
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- File: drivers/usb/mtu3/mtu3_trace.h only (+3 / −1; 4-line class)
- Function/class: DECLARE_EVENT_CLASS(mtu3_log_ep) (shared by mtu3_gadget_ep_enable, mtu3_gadget_ep_disable, mtu3_gadget_ep_set_halt)
- Scope: single-file surgical tracing fix
**Step 2.2: Code flow**
Record: **Before:** TP_fast_assign stores __entry->gpd_ring = &mep->gpd_ring. TP_printk prints %p/%pad with __entry->gpd_ring, &__entry->gpd_ring->dma. **After:** also stores __entry->gpd_ring_dma = mep->gpd_ring.dma and prints &__entry->gpd_ring_dma. Affected path is trace **print**, not gadget I/O.
Verified in this tree’s lib/vsprintf.c address_val(): %pad does *(const dma_addr_t *)addr. The old argument therefore both follows gpd_ring and then dereferences .dma.
**Step 2.3: Bug mechanism**
Record: **Memory safety / delayed pointer dereference in tracing (UAF or garbage).** %p of the saved pointer is safe; %pad is not. gpd_ring is embedded in struct mtu3_ep (mtu3.h). mtu3_gpd_ring_free() memsets the ring on disable; the mtu3_ep itself is freed on unbind. Reading traces after unbind is a use-after-free. Reading after disable but before unbind can print a later (zeroed) DMA address instead of the recorded one.
**Step 2.4: Fix quality**
Record: Obviously correct and minimal. %pad still gets a dma_addr_t *, now into the ring-buffer entry. The missing semicolon on the new assign is harmless: TP_fast_assign is expanded with a trailing ;. No API/locking/hot-path change. Regression risk is very low. The leftover __field(struct mtu3_gpd_ring *, gpd_ring) is still only printed with %p.
---
## Phase 3: Git history
**Step 3.1: Blame**
Record: Buggy mtu3_log_ep pattern comes from 83374e035b628 (“usb:
mtu3: add tracepoints to help debug”, Chunfeng Yun, 2019-03-21). Present in this tree (git merge-base --is-ancestor 83374e035b628 HEAD succeeded). Long-lived, not recent code.
**Step 3.2: Fixes: tag**
Record: None on the merged commit. An earlier unused submission (Shixiong Ou, 2026-08-28) tagged Fixes: 83374e035b62. That introducing commit **is** in this tree.
**Step 3.3: File history**
Record (path-limited log):
- 83374e035b628 add tracepoints
- later style/__vstring/__assign_str churn
- this fix
Standalone; not patch X/Y. No prerequisite refactor in this file beyond what 6.18 already has (__assign_str(name) without a second argument is already here).
**Step 3.4: Author**
Record: Vladimir Murzin is not the mtu3 maintainer (that is Chunfeng Yun, CC’d). He is an ARM engineer fixing a splat he, Paul, and Mark hit. Rostedt reviewed. Paul merged it when USB maintainers were slow (splat still in 7.3-rc6).
**Step 3.5: Dependencies**
Record: None. Uses existing dma_addr_t, TP_*, and mep->gpd_ring.dma. No new tracing helpers. b5cc230af5e5 is the detector, **not** a prerequisite for the fix.
---
## Phase 4: Mailing list / external
**Step 4.1: Original discussion**
Record:
- b4 dig -c cfb3293c4573289f11f913611f530ea6b1926d67 → https://patch.m
sgid.link/[email protected]
- b4 dig -a: single revision (v1 only)
- Thread: ping for 7.3-rc5/rc6 splat; Paul offered to merge because the WARN broke his tests; later merged and Linus pulled it
- No NAK. No reviewer asked for Cc: stable
- lore.kernel.org fetch returned 403; thread recovered via b4 dig -m
**Step 4.2: Recipients (b4 dig -w)**
Record: linux-usb, linux-arm-kernel, linux-mediatek, linux-kernel, Chunfeng Yun, Greg KH, Steven Rostedt, Paul McKenney, Mark Rutland. Right lists and maintainers.
**Step 4.3: Bug report**
Record: Reproduced by Paul, Mark, and Vladimir on 7.3-rc1+ (dummy-virt). Independent earlier patch from Shixiong Ou describes the same WARN and the same stale-pointer/UAF. Severity for **those** kernels is a boot WARN whenever CONFIG_USB_MTU3 is built. That WARN is **not** in 6.18.y.
**Step 4.4: Series**
Record: Standalone. Duplicate independently submitted by Shixiong Ou (same approach, field named gpd_dma). Murzin’s version is what merged.
**Step 4.5: Stable list**
Record: No useful hit on lore stable for this subject. Not a documented “do not backport.”
---
## Phase 5: Semantic / call graph
**Step 5.1: Functions**
Record: mtu3_log_ep class; events mtu3_gadget_ep_enable, mtu3_gadget_ep_disable, mtu3_gadget_ep_set_halt.
**Step 5.2: Callers**
Record (this tree):
- mtu3_gadget_ep_enable() — drivers/usb/mtu3/mtu3_gadget.c:202
- mtu3_gadget_ep_disable() — line 214 (before mtu3_ep_disable() / mtu3_gpd_ring_free())
- mtu3_gadget_ep_set_halt() — line 404
These are USB gadget ep ops: enable/disable/halt from gadget drivers / configfs. Common on MediaTek gadget/OTG, not a syscall of its own.
**Step 5.3: Callees**
Record: TRACE_EVENT assign/print only. No alloc/lock/I/O in the changed code. %pad → address_val() → dereference dma_addr_t *.
**Step 5.4: Reachability**
Record: Recording: gadget ep enable/disable/halt with these events on.
Printing: reading the trace buffer. UAF: print after mtu3_ep is freed (driver unbind). Boot WARN: only if test_double_dereference() exists (it does not here). Unprivileged users normally cannot enable tracefs.
**Step 5.5: Similar patterns**
Record: Other mtu3 events print saved pointers with %p only (safe). Same class already in this 6.18.y tree: 0b0d2f9db2406 (“eth: ice:
don't dereference pointers from TP_printk()”), also written against b5cc230af5e5, and it **is** an ancestor of v6.18.57.
---
## Phase 6: This checkout only
**Step 6.1: Does the buggy code exist?**
Record: **Yes, in v6.18.57.** git describe HEAD → v6.18.57-155-gcdf239ca885b2; make kernelversion → **6.18.57**. v6.18.57 mtu3_trace.h still has __entry->gpd_ring, &__entry->gpd_ring->dma. Introduced 2019. git merge-base --is-ancestor dff6c93cf7131 v6.18.57 failed (fix not in 6.18.57). test_double_dereference is **absent** from kernel/trace/ (b5cc230af5e5 is not an ancestor of HEAD).
**Step 6.2: Backport difficulty**
Record: **Clean apply.** git diff v6.18.57 dff6c93cf7131 -- drivers/usb/mtu3/mtu3_trace.h is exactly this 4-line change. Context matches 6.18 (__assign_str(name) already present).
**Step 6.3: Related fix already here?**
Record: No other mtu3 TP_printk fix in v6.18..v6.18.57. The ice analogue **is** already in 6.18.57. That does not replace this mtu3 bug.
---
## Phase 7: Subsystem context
**Step 7.1**
Record: **drivers/usb/mtu3** — MediaTek USB3 dual-role. Criticality:
**PERIPHERAL/IMPORTANT for MTK** (CONFIG_USB_MTU3, depends on ARCH_MEDIATEK || COMPILE_TEST). Tracepoints compiled with the driver when CONFIG_TRACEPOINTS is on.
**Step 7.2**
Record: Mature driver (tracepoints since 2019). Recent 6.18.y mtu3 fixes include DMA unmap on queue failure and suspend-with-gadget. Not staging.
---
## Phase 8: Impact and risk
**Step 8.1: Who is affected**
Record: MediaTek USB3 gadget users who enable these ftrace events and later print the buffer. Distro kernels that build mtu3 for COMPILE_TEST do **not** get the 7.3 boot WARN here, because that check is missing.
**Step 8.2: Trigger**
Record: Not every boot on 6.18.y. Needs CONFIG_USB_MTU3 + tracepoints
+ enable these events + later print. UAF additionally needs the endpoint/device object to have been freed. Not unprivileged. The 7.3 boot WARN fires even on dummy-virt; **that path does not exist in this tree**.
**Step 8.3: Failure mode**
Record:
- On 7.3+: boot WARNING — **does not apply to 6.18.57**
- On this tree: delayed deref → **garbage DMA address in traces**, or **UAF/oops** if mtu3_ep was freed — severity **HIGH** when hit, **MEDIUM** overall because the trigger is a debug path
**Step 8.4: Risk vs benefit**
Record: **Benefit:** closes a real stale-pointer/UAF in mtu3 gadget traces; same class already taken for ice on this series. **Risk:** very low (3 insertions, print-time only). Ratio favors backport.
---
## Phase 9: Synthesis
**Step 9.1: Evidence**
For:
- Real delayed dereference of a kernel pointer from the trace buffer (%pad confirmed to dereference)
- Buggy code present in this 6.18.y tree since 2019
- Small, obviously correct, applies cleanly
- Reviewed by Rostedt; reported/tested by McKenney and Rutland
- Same class (TP_printk must not follow saved pointers) already in v6.18.57 for ice
- No new API/feature; no series dependency
Against:
- The boot splat that drove the patch **cannot happen here** (test_double_dereference / b5cc230af5e5 not in 6.18.y)
- Debug/tracing path, MediaTek-specific, needs events enabled
- Failure is often wrong trace text rather than a production USB failure
- No Cc: stable in review (not a negative per the rules)
Unresolved: lore.kernel.org HTTP 403 (thread read from b4 mbox instead).
**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** (Rostedt Reviewed-by, Mark Tested-by, logic is local)
2. Real bug that affects users? **PASS** (stale pointer / UAF when traces are printed)
3. Important (crash/security/corruption/deadlock)? **PASS** (UAF/oops possible on print after free; garbage traces otherwise). The 7.3 boot WARN is not the important part **for this tree**.
4. Small and contained? **PASS** (one header, 4 lines)
5. No new features/APIs? **PASS**
6. Can apply to this tree? **PASS** (clean vs v6.18.57)
**Step 9.3: Exception category**
Record: None (not a device ID/quirk/DT/build/docs exception). It is a normal small bugfix.
**Step 9.4: Decision**
The 7.3 boot WARN is not a reason to take this on 6.18.y. The reason to take it is the pre-existing TP_printk dereference, which **is** in this tree, is a real UAF/garbage-print bug, is a 4-line no-brainer, and matches a fix this series already accepted for ice.
---
## What this means for 6.18.y users
mtu3_log_ep stores &mep->gpd_ring and later does %pad on &gpd_ring->dma. Print can happen long after disable/unbind. That is a real bug in this tree. The patch only snapshots gpd_ring.dma at event time. It does not change gadget behavior.
## Verification
- **[Phase 1]** Parsed tags: Reported-by Paul McKenney, Tested-by Mark Rutland, Reviewed-by Steven Rostedt; no Fixes/Cc-stable
- **[Phase 2]** Diff: +gpd_ring_dma field, assign mep->gpd_ring.dma, print &__entry->gpd_ring_dma
- **[Phase 2]** %pad in lib/vsprintf.c address_val(): num = *(const dma_addr_t *)addr
- **[Phase 2]** struct mtu3_ep has embedded struct mtu3_gpd_ring gpd_ring; mtu3_gpd_ring_free() memsets it
- **[Phase 3]** Blame: 83374e035b628 (2019) introduced the pattern; ancestor of HEAD
- **[Phase 3]** git merge-base --is-ancestor b5cc230af5e5 HEAD failed; no test_double_dereference in this tree
- **[Phase 3]** Author log on drivers/usb/: this commit plus unrelated xhci work
- **[Phase 4]** b4 dig -c cfb3293c4573: msgid [email protected]; v1 only
- **[Phase 4]** b4 dig -w: USB/Mediatek lists, Greg KH, Chunfeng Yun, Rostedt
- **[Phase 4]** mbox: Paul merged after 7.3-rc5/rc6 pings; no NAK; no stable nomination
- **[Phase 4]** UNVERIFIED: live lore.kernel.org page (403)
- **[Phase 5]** Callers: mtu3_gadget_ep_enable/disable/set_halt in mtu3_gadget.c
- **[Phase 6]** git describe HEAD = v6.18.57-155-gcdf239ca885b2; kernelversion 6.18.57
- **[Phase 6]** v6.18.57 still has &__entry->gpd_ring->dma; fix not an ancestor of v6.18.57
- **[Phase 6]** File diff vs v6.18.57 is exactly this patch (clean)
- **[Phase 6]** ice TP_printk analogue 0b0d2f9db2406 **is** in v6.18.57
- **[Phase 8]** Boot WARN not reachable here; UAF/garbage on delayed print is
The fix is small, correct, already matches this tree’s context, and closes a real tracing UAF, not a 7.3-only WARN.
**YES**
drivers/usb/mtu3/mtu3_trace.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/mtu3/mtu3_trace.h +3 -1
@@ -224,6 +224,7 @@ DECLARE_EVENT_CLASS(mtu3_log_ep, __field(unsigned int, flags) __field(unsigned int, direction) __field(struct mtu3_gpd_ring *, gpd_ring) + __field(dma_addr_t, gpd_ring_dma) ),TP_fast_assign ( __assign_str(name);
@@ -235,12 +236,13 @@ DECLARE_EVENT_CLASS(mtu3_log_ep, __entry->flags = mep->flags; __entry->direction = mep->is_in; __entry->gpd_ring = &mep->gpd_ring; + __entry->gpd_ring_dma = mep->gpd_ring.dma ), TP_printk("%s: type %s maxp %d slot %d mult %d burst %d ring %p/%pad flags %c:%c%c%c:%c", __get_str(name), usb_ep_type_string(__entry->type), __entry->maxp, __entry->slot, __entry->mult, __entry->maxburst, - __entry->gpd_ring, &__entry->gpd_ring->dma, + __entry->gpd_ring, &__entry->gpd_ring_dma, __entry->flags & MTU3_EP_ENABLED ? 'E' : 'e', __entry->flags & MTU3_EP_STALL ? 'S' : 's', __entry->flags & MTU3_EP_WEDGE ? 'W' : 'w',
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] usb: mtu3: Fix double dereference in TP_printk
Sashiko has reviewed this patch and found no issues.
Quoted 15 lines
From: Vladimir Murzin <[email protected]>
[ Upstream commit
cfb3293c4573289f11f913611f530ea6b1926d67]Paul reported kernel splat:
[ 0.000000] TRACE EVENT ERROR: Event mtu3_gadget_ep_set_halt has double dereference in TP_printk: &REC->gpd_ring->dma [ 0.000000] ------------[ cut here ]------------ [ 0.000000] Event mtu3_gadget_ep_set_halt has double dereference in TP_printk: &REC->gpd_ring->dma [ 0.000000] WARNING: kernel/trace/trace_events.c:420 at test_double_dereference+0x144/0x14c, CPU#0: swapper/0/0 [ 0.000000] Modules linked in: [ 0.000000] CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 7.3.0-rc1 #15247 PREEMPT [ 0.000000] Hardware name: linux,dummy-virt (DT) [ 0.000000] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 0.000000] pc : test_double_dereference+0x144/0x14c
Quoted 6 lines
[ ... ]Tested-by Mark Rutland <[email protected]>Reviewed-by Steven Rostedt <[email protected]>Signed-off-by Vladimir Murzin <[email protected]>Signed-off-by Paul E. McKenney <[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 ksmbd: notify parent directory leases on child create
In reply to Sasha LevinFrom: Namjae Jeon <[email protected]>
[ Upstream commit abe5acb34282206c2a6303d0e09b3165b1addf0e ]
BVT_DirectoryLeasing_ReadWriteHandleCaching requires a parent directory lease break notification when another client creates a child in the leased directory. A child CREATE without a lease context did not notify the parent lease holders because the notification path expected a non-NULL lease context.
Allow the parent lease notification helper to handle a NULL child lease context and notify matching parent leases. Invoke it after a child is created without a lease context while preserving the existing lease-key filtering for requests that provide one.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). Directory leasing is already advertised here, and this patch fills a hole in that existing notification path.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[ksmbd] [notify] parent directory leases on child create**
- Subsystem: ksmbd (kernel SMB3 server)
- Verb: “notify” — protocol-correctness / missing-event fix, not a feature add
- Claimed intent: send a parent directory lease break when a child is created
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Verified from git log -1 --format='%B' abe5acb342822:
- **Signed-off-by: Namjae Jeon** <[email protected]> (author and committer; ksmbd maintainer)
- **No Fixes:** tag (expected for this review pipeline)
- **No Cc: stable** (expected)
- **No Reported-by / Tested-by / Reviewed-by / Acked-by / Link**
- Ignore pipeline-added Sasha Levin SOB / [Upstream commit …] if present on a candidate copy
Notable: maintainer-authored, no external review tags. The body cites Microsoft BVT BVT_DirectoryLeasing_ReadWriteHandleCaching.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** A child CREATE with no lease context never notifies holders of a parent directory lease, because smb_send_parent_lease_break_noti() assumed lctx was non-NULL.
- **Symptom:** Windows BVT BVT_DirectoryLeasing_ReadWriteHandleCaching fails; SMB3 clients with a directory lease keep a stale directory cache after another client creates a child.
- **Version info:** None in the message. Introducing code is from v6.7-rc6 (d47d9886aeef7).
- **Root cause:** Notification only ran on CREATE-with-lease-context; the helper immediately used lctx->version.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not a disguised cleanup.** This is an explicit protocol bug
fix: missing lease-break on a common CREATE path. Not a refactor or new API.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- fs/smb/server/oplock.c: +5/−4 in smb_send_parent_lease_break_noti()
- fs/smb/server/smb2pdu.c: +3 in smb2_open()
- **Scope:** 8 insertions, 4 deletions; single-subsystem surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Verified against local smb_send_parent_lease_break_noti() (fs/smb/server/oplock.c ~1214) and smb2_open() (~3521):
Hunk 1 (helper guard):
- **Before:** if (lctx->version != 2) return; — NULL lctx would crash; callers never passed NULL.
- **After:** if (lctx && lctx->version != 2) return; — NULL means “notify matching parent leases”.
Hunk 2 (filter condition):
- **Before:** Always used lctx->flags / lctx->parent_lease_key to skip the same parent lease.
- **After:** !lctx || (existing parent-key filter) — NULL child context breaks all active parent directory leases; lease-key filtering is unchanged when lctx is present.
Hunk 3 (smb2_open):
- **Before:** Parent notify only inside if (req_op_level == SMB2_OPLOCK_LEVEL_LEASE && lc).
- **After:** Also if (created && !lc) smb_send_parent_lease_break_noti(fp, NULL); in the oplocks-enabled branch.
created is set when smb2_creat() succeeds (smb2pdu.c ~3301–3313). lc is only set when a lease create context is parsed (~3017, ~3061). The two notify sites are mutually exclusive (!lc vs lc).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Logic / protocol correctness]** Directory leasing is advertised (SMB2_GLOBAL_CAP_DIRECTORY_LEASING in smb2ops.c; docs say “Directory leases(v2 lease) Supported”). CREATE without a lease context never broke the parent directory lease. The helper change is a NULL-safe call convention so that path can notify. Not UAF/leak/race/overflow by itself; the failure mode is stale client directory cache.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: short-circuit !lctx avoids lctx->flags deref; reuses the existing break helper.
- Minimal; no unrelated edits.
- Regression risk **low**: extra breaks only on real child create with no lease context, which MS-SMB2 requires. Locking matches the existing smb_send_parent_lease_break_noti(fp, lc) call a few lines later (p_ci->m_lock then oplock_break_drain_none()).
- No public API / data-structure change.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Buggy helper and the lease-context-only call site: **d47d9886aeef7** (“ksmbd: send v2 lease break notification for directory”, Namjae Jeon, 2023-12-08).
- First contained in **v6.7-rc6**. Present in this 6.12 tree (git merge-base --is-ancestor d47d9886aeef7 HEAD → yes).
- Directory leasing capability: **18dd1c367c31d** (“ksmbd: set v2 lease capability”), also in this tree.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** The incomplete behavior was introduced by d47d9886aeef7, which is in this tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Same class already in this tree: 3fc74c65b3674 “send lease break notification on FILE_RENAME_INFORMATION” (smb2.lease.v2_epoch2); 7f58458e9db92 “break RH leases before delete-on-close”.
- Later on all-next, 0e753899627b5 only changes oplock_break_drain_none(&brk_list) → (&brk_list, p_ci) — **already present locally** via 5de0527f78243. Not a prerequisite of this patch.
- git log all-next -S 'created && !lc' shows **only** abe5acb342822 — no follow-up rewrite of this call.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Namjae Jeon is listed as **KERNEL SMB3 SERVER (KSMBD)** maintainer in MAINTAINERS. Recent local ksmbd lease work includes lease lookup, RH lease break, lease context validation.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **Standalone.** Uses existing smb_send_parent_lease_break_noti(), created, and lc. git show abe5acb342822 | git apply --check **succeeds** on this tree (oplock.c offset −232, smb2pdu.c offset −1136).
Candidate SHA on all-next: **abe5acb342822** (in ksmbd- for-7.3-rc1, described as v7.3-rc1~77^2~20). **Not** in HEAD.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c abe5acb342822: lore search returned server errors; **no thread URL**.
- lore.kernel.org WebFetch: **403**.
- Found via LKML: [GIT PULL] ksmbd server update for 7.3-rc1 (Namjae Jeon, 2026-08-23) lists this commit and calls out **“parent directory lease notifications”** among protocol-compatibility fixes.
- Linus merge 61a09cfc12147 uses the same wording.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: No Reviewed-by. Author is the maintainer and committed it to the ksmbd tree. Recipients of the original mail **unverified** (lore 403 / b4 failure).
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla. Trigger is Microsoft BVT **BVT_DirectoryLeasing_ReadWriteHandleCaching** (Windows protocol test:
client A holds a directory RWH lease; client B creates a child without a lease context; A must get a break).
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Not labeled N/M. Adjacent commits are AppInstanceVersion takeover / durable reconnect — unrelated. Independent.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** (lore 403). No evidence it was rejected for stable. Absence of Cc: stable is expected here.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
Record: smb_send_parent_lease_break_noti(), smb2_open().
**Step 5.2: TRACE CALLERS**
Record (this tree, git grep):
- smb_send_parent_lease_break_noti — only smb2_open().
- After the patch: two sites in smb2_open (created && !lc, and existing lease-context path).
- smb2_open is the SMB2 CREATE handler — authenticated SMB clients.
Related: smb_lazy_parent_lease_break_close() on close after write (reserve_lease_break); not this CREATE gap.
**Step 5.3: TRACE CALLEES**
Record: ksmbd_inode_lookup_lock(parent), down_read(p_ci->m_lock), walk m_op_list, compare_guid_key(), oplock_break_add(), oplock_break_drain_none(), ksmbd_inode_put(). Same as today’s helper.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace SMB2 CREATE → smb2_open → (new) parent lease break. Reachable whenever ksmbd is running with leases/smb2 leases and a client holds a directory lease. Windows 8+ SMB3 clients request directory leases by default. **Yes, client-triggerable.**
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same missing-break pattern already fixed for rename (3fc74c65b3674, in this tree). Unlink/close uses smb_lazy_parent_lease_break_close. This patch is the CREATE-without- lease counterpart.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.**
```1221:1236:fs/smb/server/oplock.c
if (lctx->version != 2)
return;
// ...
(!(lctx->flags &
SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET_LE) ||
!compare_guid_key(opinfo, fp->conn->ClientGUID,
lctx->parent_lease_key))) {
``````3530:3541:fs/smb/server/smb2pdu.c
if (req_op_level == SMB2_OPLOCK_LEVEL_LEASE && lc) {
// ...
smb_send_parent_lease_break_noti(fp, lc);
```Bug introduced **v6.7** (d47d9886aeef7). Capability advertised in init_smb3_0_server() / init_smb3_02_server(). Docs: “Directory leases(v2 lease) Supported.”
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply with offset.** Local helper already has oplock_break_drain_none(&brk_list, p_ci) from 5de0527f78243; that line is outside the candidate hunks. git apply --check succeeded.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: Rename/delete-on-close lease-break fixes are here. **This CREATE-without-lease notify is not.** Subject grep found no equivalent.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **[ksmbd / fs/smb/server] [IMPORTANT]** — in-kernel SMB3 server for NAS/embedded. Not core VFS; not staging. Config SMB_SERVER, default n.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: **Actively developed.** This pending 6.12 tree already carries many ksmbd protocol and lease fixes (partial responses, RH lease break, lease context validation, oplock UAF). Mature enough that directory leasing has been “Supported” since ~6.7.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Config/driver-specific:** CONFIG_SMB_SERVER with SMB2 leases and SMB3 directory leasing. Affects Windows/SMB3 clients that cache directories against ksmbd.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Client A holds a v2 directory lease.
- Client B creates a child **without** a lease create context (created && !lc).
- Common for a second client or simple SMB CREATE; exactly the BVT setup.
- Authenticated SMB client, not a local unprivileged syscall.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Stale directory cache / protocol violation.** Not oops/deadlock/fs corruption. Clients can miss newly created names until some other break. **Severity: MEDIUM** (interoperability / user-visible wrong directory contents), same class as the rename lease-break fix already in this tree.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** High for ksmbd+Windows SMB3: advertised directory leasing actually invalidates on child create.
- **Risk:** Very low — ~8 lines, existing helper, applies cleanly, no new locks/APIs.
- **Ratio:** Favor backport.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real protocol bug in **advertised** directory leasing (docs + SMB2_GLOBAL_CAP_DIRECTORY_LEASING).
- User-visible: stale Windows directory cache; Microsoft BVT failure.
- Buggy code in this 6.12 tree since v6.7.
- Small, obviously correct, applies cleanly.
- Same class as 3fc74c65b3674 already in this tree.
- Maintainer-authored; in ksmbd-for-7.3-rc1 as a protocol- compatibility fix.
- No extra prerequisites.
**AGAINST:**
- Not a crash, UAF, or security issue.
- No Fixes:/Cc: stable (expected; not a negative).
- No public user bugzilla; test-suite driven.
- SMB_SERVER is optional.
**UNRESOLVED:** Original lore review thread (b4/lore 403). No NAK found in the 7.3-rc1 pull.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — logic is clear; cited BVT; maintainer committed it.
2. Fixes a real bug that affects users? **PASS** — missing required lease break; stale listings.
3. Important issue? **PASS** at protocol-correctness / “oh, that's not good” — not CRITICAL crash, but user-visible on an advertised file- server feature. Matches other ksmbd lease-break backports in this tree.
4. Small and contained? **PASS** — 2 files, ~8 lines.
5. No new features or APIs? **PASS** — completes existing notify helper; no new uAPI.
6. Can apply to the local tree? **PASS** — git apply --check succeeded.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not a device ID/quirk/DT/build/docs exception). Qualifies as a normal contained bugfix.
**Step 9.4: MAKE YOUR DECISION**
This should be backported to **this 6.12 tree**. Directory leasing is already on; CREATE without a lease context is a hole in the existing break path; the fix is tiny and applies cleanly. Treating it as a new feature would be wrong: the feature is already shipped and documented as supported.
---
## What the commit solves (and why it matters here)
On 6.12, ksmbd advertises SMB3 directory leasing. Parent breaks were only sent when the **child CREATE included a lease context**. A second client creating a file the usual way (no lease context) left the directory lease intact, so Windows clients could keep a cached listing that omitted the new name. That fails BVT_DirectoryLeasing_ReadWriteHandleCaching and breaks real SMB3 directory caching.
The patch (1) lets the existing helper accept lctx == NULL and break active parent leases, and (2) calls it after a successful create when !lc. Lease-key filtering for CREATE-with-lease is unchanged.
## Risk vs benefit
Benefit is correct directory invalidation for ksmbd users with Windows/SMB3 clients. Risk is extra lease breaks only when a child is actually created — required by the protocol. No new locking scheme; same helper already used in smb2_open.
## Concerns
- Context offset vs mainline (oplock_break_drain_none already takes p_ci here) — **does not block apply**.
- Remaining gap (pre-existing): CREATE with a **v1** lease still returns early (lctx->version != 2). This patch correctly does not expand that; it only adds the NULL-context path the BVT hits.
- Not a panic/UAF; still appropriate because this tree already backports the same kind of ksmbd lease-break completeness fixes.
---
## Verification
- **[Phase 1]** git log -1 --format='%B' abe5acb342822: only Namjae SOB; BVT named; no Fixes/Cc/Reported-by.
- **[Phase 1]** git describe HEAD / Makefile: **p-6.12-3 / 6.12.111**.
- **[Phase 2]** Read local smb_send_parent_lease_break_noti and smb2_open; confirmed NULL deref assumption and lease-context-only call.
- **[Phase 2]** Confirmed created set after smb2_creat; lc only from parse_lease_state.
- **[Phase 3]** git blame: helper/call site from d47d9886aeef7 (2023-12-08); git describe --contains → **v6.7-rc6**.
- **[Phase 3]** git merge-base --is-ancestor d47d9886aeef7 HEAD → yes; abe5acb342822 → **not** in HEAD.
- **[Phase 3]** git show abe5acb342822 | git apply --check --verbose → both files apply (offsets −232 / −1136).
- **[Phase 3]** git log all-next -S 'created && !lc' → only this commit; no follow-up.
- **[Phase 4]** b4 dig -c abe5acb342822 → lore errors, no match.
- **[Phase 4]** WebFetch lore.kernel.org → 403.
- **[Phase 4]** LKML GIT PULL 7.3-rc1 lists this commit; merge 61a09cfc12147 mentions parent directory lease notifications.
- **[Phase 5]** git grep smb_send_parent_lease_break_noti → only smb2_open + declaration.
- **[Phase 5]** smb2ops.c: SMB2_GLOBAL_CAP_DIRECTORY_LEASING set for SMB3.0/3.02 when leases enabled.
- **[Phase 6]** Docs ksmbd.rst: “Directory leases(v2 lease) Supported.”
- **[Phase 6]** Similar fix 3fc74c65b3674 is already an ancestor of HEAD.
- **[Phase 7]** MAINTAINERS: Namjae Jeon is ksmbd maintainer.
- **[Phase 8]** Failure mode verified from code + BVT name: stale directory lease, not a kernel oops.
- **UNVERIFIED:** Original lore review comments / NAKs (lore unavailable). Not used to drive the verdict; maintainer merge is verified.
The fix is small, applies to this tree, and closes a real hole in advertised SMB3 directory leasing.
**YES**
fs/smb/server/oplock.c | 9 +++++---- fs/smb/server/smb2pdu.c | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-)
fs/smb/server/oplock.c +5 -4
@@ -1271,7 +1271,7 @@ void smb_send_parent_lease_break_noti(struct ksmbd_file *fp,struct ksmbd_inode *p_ci =NULL ;LIST_HEAD (brk_list); -if (lctx->version !=2 ) +if (lctx && lctx->version !=2 )return ; p_ci =ksmbd_inode_lookup_lock (fp->filp->f_path.dentry->d_parent);
@@ -1284,9 +1284,10 @@ void smb_send_parent_lease_break_noti(struct ksmbd_file *fp,continue ;if (opinfo->o_lease->state !=SMB2_OPLOCK_LEVEL_NONE && - (!(lctx->flags &SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET_LE ) || - !compare_guid_key (opinfo, fp->conn->ClientGUID, - lctx->parent_lease_key))) { + (!lctx || + (!(lctx->flags &SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET_LE ) || + !compare_guid_key (opinfo, fp->conn->ClientGUID, + lctx->parent_lease_key)))) {if (!atomic_inc_not_zero (&opinfo->refcount))continue ;
fs/smb/server/smb2pdu.c +3 -0
@@ -3565,6 +3565,9 @@ int smb2_open(struct ksmbd_work *work) goto err_out1; } }else { +if (created && !lc) +smb_send_parent_lease_break_noti (fp,NULL ); +if (req_op_level ==SMB2_OPLOCK_LEVEL_LEASE && lc) {if (S_ISDIR (file_inode (filp)->i_mode)) { lc->req_state &= ~SMB2_LEASE_WRITE_CACHING_LE ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 media: em28xx: use vb2_video_unregister_device
In reply to Sasha LevinFrom: Hans Verkuil <[email protected]>
[ Upstream commit 7c8bf63b79371f5b57da1bd1401bd420180ac6e6 ]
Use vb2_video_unregister_device instead of video_unregister_device to ensure any streaming is correctly stopped at unregister time.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: [media: em28xx] [use] switch unregister to vb2_video_unregister_device so streaming is stopped at unbind
**Step 1.2: Tags**
Record:
- Signed-off-by: Hans Verkuil <[email protected]> (author; V4L2/videobuf2 maintainer)
- Tested-by: Hans Verkuil <[email protected]> (author tested; not an independent tester)
- Signed-off-by: Mauro Carvalho Chehab <[email protected]> (media maintainer)
- No Fixes:, Reported-by:, Link:, Cc: stable, Reviewed-by:, or Acked-by:
- Absence of Fixes: / Cc: stable is expected for this review and is not treated as a negative
**Step 1.3: Body**
Record:
- Bug: video_unregister_device() does not stop an active vb2 queue, so streaming can continue after the video node is unregistered.
- Symptom: capture still running across USB unbind / module unload / probe rollback.
- Root cause (from message + helper docs): drivers that use _vb2_fop_release() must use vb2_video_unregister_device() so the queue is released at unregister time.
- No stack trace, reproducer, or version range in the message.
**Step 1.4: Hidden bug fix?**
Record: Yes. “Use helper X” is a correctness fix, not a feature. The cover letter for the series is titled “fix lifecycle issues” and says this patch “ensures all streaming is stopped when the video device is unregistered.”
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- File: drivers/media/usb/em28xx/em28xx-video.c (+6 / -6)
- Functions: em28xx_v4l2_fini(), em28xx_v4l2_init() error path unregister_dev
- Six call sites: radio / VBI / video, in both fini and probe-error teardown
- Scope: single-file surgical substitution
**Step 2.2: Code flow**
Record:
- Before: video_unregister_device() only removes the node; the vb2 queue can remain in STREAMING.
- After: vb2_video_unregister_device() unregisters, then vb2_queue_release() (under the queue lock) which runs stop_streaming and returns buffers.
- Paths: USB disconnect / module unload (em28xx_v4l2_fini) and init failure (unregister_dev).
**Step 2.3: Bug mechanism**
Record: [logic / lifecycle] [use-after-unbind]
Verified disconnect order in this tree:
1. em28xx_usb_disconnect() sets disconnected, then em28xx_close_extension() → em28xx_v4l2_fini().
2. fini already calls em28xx_uninit_usb_xfer(), then unregisters nodes.
3. Then em28xx_release_resources() unregisters I2C and usb_put_dev().
4. Userspace may still hold the fd. Close calls em28xx_v4l2_close() → _vb2_fop_release() → vb2_queue_release() → em28xx_stop_streaming().
5. em28xx_stop_streaming() does v4l2_device_call_all(..., video, s_stream, 0) and em28xx_uninit_usb_xfer(). That runs **after** I2C/USB teardown if the queue was not stopped in fini.
Stopping the queue in fini keeps stop_streaming on the unbind side of I2C/USB teardown.
**Step 2.4: Fix quality**
Record:
- For video and VBI this is the documented vb2 pattern (include/media/videobuf2-v4l2.h: drivers using _vb2_fop_release() should use this helper). em28xx_v4l2_close() does call _vb2_fop_release().
- Video/VBI set vdev->queue (vb_vidq / vb_vbiq).
- Radio never sets vdev->queue. The helper does WARN_ON(!vdev->queue) then still calls video_unregister_device(). Two boards have radio (EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE, EM2860_BOARD_KAIOMY_TVNPC_U2).
- Probe error path: vdev->queue is assigned **before** em28xx_vb2_setup() / vb2_queue_init(). unregister_dev after a later video_register_device() or media-graph failure can call vb2_queue_release() on a zeroed queue (mutex_lock(&q->mmap_lock) in vb2_core_queue_release()). That is a real, but rare, teardown hazard.
- No API/feature additions. Regression risk is low on the disconnect path (queue is initialized); radio WARN_ON and probe-error queue release are the main nits.
## Phase 3: Git history
**Step 3.1: Blame**
Record:
- video_unregister_device() on these nodes comes from the embedded-video_device era (d4352f3639d780, 2015) and older Mauro unregister paths (2008/2013).
- Bug is long-standing, not new in 7.3.
**Step 3.2: Fixes: tag**
Record: None. Helper introduced in f729ef5796d82 (2020, around v5.10). git merge-base --is-ancestor f729ef5796d82 HEAD succeeds.
**Step 3.3: File history**
Record: Same-day series on this file:
1. 288254383674b media: em28xx: use v4l2_device release callback
2. de626073dfcbb media: em28xx: drop 'users' field
3. 7c8bf63b79371 **this commit**
4. Later: c132b07f7e585 (use-after-free of dev->intf in free), 67f87b104f4ef (requeue on start_streaming failure)
This is standalone at the diff level (only a symbol change). Series
context: patch 1 deferred v4l2_device_unregister() until last close, which makes a late stop_streaming() after I2C teardown more likely. This tree already contains patches 1 and 2.
**Step 3.4: Author**
Record: Hans Verkuil is the V4L2/videobuf2 maintainer. He added the helper in 2020 and converted au0828/usbtv/cxusb then (24b5836dbd45b). em28xx was not in that conversion.
**Step 3.5: Prerequisites**
Record: Needs vb2_video_unregister_device() (present). Needs em28xx vb2 video/VBI (present). em28xx.h already includes videobuf2-v4l2.h. Can apply standalone. This tree already has the helper and the driver.
## Phase 4: Mailing list / external
**Step 4.1: Original discussion**
Record: b4 dig -c 7c8bf63b79371 → https://patch.msgid.link/ad61b2c30cd
477599312e9d5c12045dcd05c8ecd.1779191683.git.hverkuil+cisco@kernel.org Saved thread: /tmp/em28xx-thread.mbox (cover + 3 patches, **no replies**).b4 dig -a: **v1 only**. Cover: [PATCH 0/3] media: em28xx: fix lifecycle issues. Quote: “the last patch switches video_unregister_device to vb2_video_unregister_device: this ensures all streaming is stopped when the video device is unregistered.” Also: “All this still needs to be tested on real hardware” at send time; the merged commit later has Tested-by: Hans Verkuil. No NAK, no Cc: stable in review (there was no review mail).
WebFetch of lore returned 403. Thread content was recovered via b4 dig -m.
**Step 4.2: Recipients (b4 dig -w)**
Record: Hans Verkuil, [email protected], Mauricio Faria de Oliveira <[email protected]>. No review mail in the mbox. Mauro applied it.
**Step 4.3: Bug report**
Record: No Reported-by / syzbot / bugzilla. No independent user report found in the thread.
**Step 4.4: Series**
Record: Explicit 3/3 of a lifecycle series. This hunk does not need patches 1–2 to compile. Those two are already in this tree.
**Step 4.5: Stable list**
Record: UNVERIFIED. lore.kernel.org/stable was blocked (Anubis bot- check). No stable discussion in the captured media thread.
## Phase 5: Semantic / call graph
**Step 5.1: Functions**
Record: em28xx_v4l2_fini, em28xx_v4l2_init (unregister_dev).
Callee: vb2_video_unregister_device → video_unregister_device + vb2_queue_release → em28xx_stop_streaming / em28xx_stop_vbi_streaming.
**Step 5.2: Callers**
Record:
- em28xx_v4l2_fini ← em28xx_close_extension() (em28xx-core.c) ← em28xx_usb_disconnect() (unplug) and em28xx_unregister_extension() (module unload).
- unregister_dev ← probe/init failures after a node is registered.
**Step 5.3: Callees**
Record: queue release, stop_streaming, em28xx_uninit_usb_xfer, v4l2_device_call_all(..., s_stream, 0).
**Step 5.4: Reachability**
Record: Yes. Unplug or rmmod while an analog capture app is streaming is a normal USB-TV / webcam path. Unprivileged userspace can hold the device open; unplug is a physical event.
**Step 5.5: Similar patterns**
Record: Same helper is used across USB/PCI/platform V4L2 drivers (uvc, au0828, usbtv, saa7134, vivid, …). em28xx was a leftover vs the 2020 USB conversion.
semcode MCP tools: not available; used git grep / file reads.
## Phase 6: This tree
**Step 6.1: Local tree and buggy code**
Record:
- git describe HEAD → v7.3-rc4-27-gf0100363d8c37
- make kernelversion / Makefile → **7.3.0-rc4** (mainline, not an LTS branch)
- git merge-base --is-ancestor 7c8bf63b79371 HEAD → yes (already in this checkout)
- Driver, helper, and _vb2_fop_release() close path all exist here
- Bug class (unregister without stopping vb2) has been in em28xx since ~2015; it was not introduced after this tree
**Step 6.2: Backport difficulty**
Record: Clean apply on this codebase (already applied). Helper and includes are present. No conflicting refactor of these call sites beyond the same series.
**Step 6.3: Related fixes already here**
Record: Lifetime callback + drop-users are already here. No alternate fix of these six call sites. Follow-up 67f87b104f4ef is a different start_streaming WARN, not a replacement for this change.
## Phase 7: Subsystem
**Step 7.1**
Record: [drivers/media/usb/em28xx] [IMPORTANT] — USB analog capture, not core mm/net, but a long-lived in-tree driver with real hardware users (CONFIG_VIDEO_EM28XX / VIDEO_EM28XX_V4L2).
**Step 7.2**
Record: Mature driver; recent work is lifecycle/vb2 correctness from the V4L2 maintainer, not a new subsystem.
## Phase 8: Impact and risk
**Step 8.1: Who is affected**
Record: Users of em28xx USB capture sticks (Hauppauge, Empia, etc.), analog video/VBI. Radio-only extra is two board entries.
**Step 8.2: Trigger**
Record: Unplug or unload while /dev/video* or VBI is streaming (or open with a live queue). Common for USB TV/webcam. Unprivileged process can keep the fd; disconnect is the trigger.
**Step 8.3: Failure mode**
Record: stop_streaming after I2C unregister / usb_put_dev → use of torn-down USB/I2C, hung DQBUF, possible UAF. Severity **HIGH**. Not a guaranteed panic on every unplug (URBs are already killed in fini), but the decoder s_stream(0) and second uninit run too late.
**Step 8.4: Risk/benefit**
Record:
- Benefit: high for em28xx users who unplug while capturing; matches the documented vb2 unbind contract.
- Risk: low on the disconnect path (6 substitutions, helper used since 2020). Medium-low on probe-error (uninitialized queue) and radio (WARN_ON).
- Ratio: benefit of stopping the queue at unbind outweighs those edge nits.
## Phase 9: Synthesis
**Step 9.1: Evidence**
FOR:
- Real unbind/lifecycle bug: vb2 stays STREAMING after node unregister; stop_streaming can run after I2C/USB teardown.
- Driver already uses _vb2_fop_release(); helper is the required API.
- Small (6 lines), no new API, helper present in this tree since 2020.
- V4L2 maintainer authored and tested; media maintainer applied.
- USB unplug while capturing is a realistic user path.
- Same conversion already done for sibling USB drivers.
AGAINST:
- No user crash log / syzbot.
- Patch 3/3 of a lifecycle series (self-contained, but series-scoped).
- Radio WARN_ON(!queue) on two boards.
- Probe unregister_dev can vb2_queue_release() before vb2_queue_init().
- Cover letter originally said hardware testing was still pending (later Tested-by is the author).
UNRESOLVED:
- lore.kernel.org HTTP 403 / stable list Anubis block; no independent stable-thread confirmation beyond the mbox (which had no replies).
**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** for video/VBI disconnect; nits on radio/probe-error do not make the core change wrong. Tested-by author.
2. Real bug affecting users? **PASS** — verified disconnect vs close ordering.
3. Important (crash/UAF/unbind)? **PASS** — HIGH, use-after-unbind / late s_stream on torn-down I2C/USB.
4. Small and contained? **PASS** — 6 lines, one file.
5. No new features/APIs? **PASS**.
6. Applies to this tree? **PASS** — helper, includes, and call sites exist here.
**Step 9.3: Exception category**
Record: None (not an ID/quirk/DT/build/docs exception). It is a normal small bugfix.
**Step 9.4: Decision**
This tree is 7.3-rc4 and already contains the helper and em28xx vb2 video. The change is a small, maintainer-tested fix for a real USB- unbind lifecycle hole: without it, analog streaming is not stopped when the node is unregistered, so stop_streaming can run after I2C/USB teardown. That is in scope for this codebase and meets the stable bar. Radio WARN_ON and a rare probe-error queue release are residual nits, not reasons to keep the disconnect bug.
### What the commit solves for this tree
On em28xx analog capture, em28xx_v4l2_fini() (USB disconnect / module unload) unregisters video/VBI with video_unregister_device() while the vb2 queue can still be STREAMING. Close later stops the queue via _vb2_fop_release(), but by then em28xx_release_resources() has already dropped I2C and the USB device. Switching to vb2_video_unregister_device() stops streaming during fini, while those objects are still valid.
### Risk vs benefit
Benefit is a real unbind UAF/use-after-teardown hole on a commonly unplugged USB capture driver. Risk is six call-site substitutions through a helper that has been in this tree for years. Residual radio WARN_ON and probe-error queue release are limited.
### Verification
- [Phase 1] Tags: author SOB + Tested-by Hans Verkuil, Mauro SOB; no Fixes/Reported-by/Link/Cc:stable
- [Phase 2] Diff: 6 video_unregister_device → vb2_video_unregister_device in em28xx_v4l2_fini and unregister_dev
- [Phase 2] Helper: vb2_video_unregister_device() unregisters then vb2_queue_release(); WARN_ON(!vdev->queue) confirmed
- [Phase 2] radio_dev never assigns .queue; video/VBI do (em28xx- video.c init)
- [Phase 2] em28xx_v4l2_close() calls _vb2_fop_release(filp, NULL)
- [Phase 2] em28xx_stop_streaming() calls s_stream(0) and em28xx_uninit_usb_xfer()
- [Phase 3] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; kernelversion 7.3.0-rc4
- [Phase 3] Commit 7c8bf63b79371 is ancestor of HEAD; helper f729ef5796d82 is ancestor
- [Phase 3] Series: 288254383674b, de626073dfcbb, this commit; 2020 USB conversion 24b5836dbd45b skipped em28xx
- [Phase 4] b4 dig -c 7c8bf63b79371: lore msgid ad61b2c30cd477599312e9d5c12045dcd05c8ecd…; v1-only 3-patch “fix lifecycle issues”
- [Phase 4] mbox: cover + 3 patches, zero replies; b4 dig -w: linux- media + Mauricio Faria de Oliveira
- [Phase 4] WebFetch lore 403; stable lore Anubis-blocked — UNVERIFIED beyond mbox
- [Phase 5] fini callers: em28xx_close_extension ← em28xx_usb_disconnect / em28xx_unregister_extension
- [Phase 6] em28xx.h includes videobuf2-v4l2.h; radio boards Leadtek Winfast USB II Deluxe, Kaiomy TVnPC U2
- [Phase 8] Disconnect then em28xx_release_resources() does em28xx_i2c_unregister + usb_put_dev before last close
- UNVERIFIED: independent hardware test besides author’s Tested-by; any stable@ thread
**YES**
drivers/media/usb/em28xx/em28xx-video.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/media/usb/em28xx/em28xx-video.c +6 -6
@@ -2243,17 +2243,17 @@ static int em28xx_v4l2_fini(struct em28xx *dev)if (video_is_registered (&v4l2->radio_dev)) {dev_info (&dev->intf->dev,"V4L2 device %s deregistered\n" ,video_device_node_name (&v4l2->radio_dev)); -video_unregister_device (&v4l2->radio_dev); +vb2_video_unregister_device (&v4l2->radio_dev); }if (video_is_registered (&v4l2->vbi_dev)) {dev_info (&dev->intf->dev,"V4L2 device %s deregistered\n" ,video_device_node_name (&v4l2->vbi_dev)); -video_unregister_device (&v4l2->vbi_dev); +vb2_video_unregister_device (&v4l2->vbi_dev); }if (video_is_registered (&v4l2->vdev)) {dev_info (&dev->intf->dev,"V4L2 device %s deregistered\n" ,video_device_node_name (&v4l2->vdev)); -video_unregister_device (&v4l2->vdev); +vb2_video_unregister_device (&v4l2->vdev); }v4l2_ctrl_handler_free (&v4l2->ctrl_handler);
@@ -2901,19 +2901,19 @@ static int em28xx_v4l2_init(struct em28xx *dev)dev_info (&dev->intf->dev,"V4L2 device %s deregistered\n" ,video_device_node_name (&v4l2->radio_dev)); -video_unregister_device (&v4l2->radio_dev); +vb2_video_unregister_device (&v4l2->radio_dev); }if (video_is_registered (&v4l2->vbi_dev)) {dev_info (&dev->intf->dev,"V4L2 device %s deregistered\n" ,video_device_node_name (&v4l2->vbi_dev)); -video_unregister_device (&v4l2->vbi_dev); +vb2_video_unregister_device (&v4l2->vbi_dev); }if (video_is_registered (&v4l2->vdev)) {dev_info (&dev->intf->dev,"V4L2 device %s deregistered\n" ,video_device_node_name (&v4l2->vdev)); -video_unregister_device (&v4l2->vdev); +vb2_video_unregister_device (&v4l2->vdev); }v4l2_ctrl_handler_free (&v4l2->ctrl_handler);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 pinctrl: qcom: Add irq_get/set_irqchip_state() for msm gpio irqchip
In reply to Sasha LevinFrom: Maulik Shah <[email protected]>
[ Upstream commit 1860fb0be224dec0e4d170f46d1cbbc77e25e09e ]
MPM irqchip monitors the interrupts during SoC sleep state and after wakeup replays the edge interrupt by making it pending at respective irqchip by invoking irq_set_irqchip_state() API. The msm gpio irqchip however do not implement this function making it impossible to replay the gpio interrupt on any MPM irqchip based SoC.
Add the missing irq_get/set_irqchip_state() APIs. Implement only IRQCHIP_STATE_PENDING case which MPM irqchip uses.
---
LLM Generated explanations, may be completely bogus:
The local tree is **7.3.0-rc4**. This commit fills in missing MSM GPIO irqchip ops so MPM can replay edge GPIOs after deep sleep. That is a real resume bug on Qualcomm MPM SoCs, and the change is small enough to be a stable candidate.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [pinctrl/qcom] [Add] Implement missing irq_get/set_irqchip_state() on the MSM GPIO irqchip
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Fixes: — none (expected)
- Reported-by: — none
- Tested-by: — none
- Reviewed-by: Navya Malempati <[email protected]>
- Acked-by: Linus Walleij <[email protected]> (pinctrl maintainer)
- `Link: https://patch.msgid.link/20260424-pinctrl_irqchip_states-v1-1-
[email protected]`
- Cc: [email protected] — none (expected)
- Signed-off-by: Maulik Shah (author)
- Signed-off-by: Sneh Mankad (submitter)
- Signed-off-by: Bartosz Golaszewski (Qualcomm pinctrl maintainer)
- Ignore pipeline Signed-off-by: Sasha Levin
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** After SoC sleep, MPM replays edge IRQs with irq_set_irqchip_state(..., IRQCHIP_STATE_PENDING, true). The MSM GPIO irqchip did not implement that op, so GPIO edges cannot be replayed on MPM SoCs.
- **Symptom:** Lost GPIO edge interrupts after deep sleep / resume (wakeup events never delivered to the GPIO irqchip).
- **Root cause:** Missing irq_chip.irq_{get,set}_irqchip_state on msmgpio.
- **Versions:** None stated. MPM has called this API since it was added (2022).
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. Subject says “Add”, but the body describes a real missing-op bug. Implementing existing irqchip callbacks is a completeness/correctness fix, not a new userspace API.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/pinctrl/qcom/pinctrl-msm.c — **+39 / -0**
- New: msm_gpio_irq_set_irqchip_state(), msm_gpio_irq_get_irqchip_state()
- Wired into msm_gpio_irq_chip
- Scope: single-file, surgical
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** irq_set_irqchip_state() walks the hierarchy from msmgpio. That chip had no callback, so it walked to MPM (also no callback). GPIO-only MPM pins disconnect GIC, so the call returns -EINVAL and the edge is never made pending.
- **After:** msmgpio writes/reads TLMM intr_status for IRQCHIP_STATE_PENDING. Other states and skip_wake_irqs pins (PDC- owned) return -EINVAL.
- Path: resume / MPM handler, not probe.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Logic / correctness (missing irqchip op)**, with a hardware- wakeup workaround flavor.
Mechanism: MPM’s qcom_mpm_handler() does irq_set_irqchip_state(d->irq, IRQCHIP_STATE_PENDING, true) for non- level IRQs. Without the GPIO callback, replay is impossible. The fix writes the GPIO status register (bit 0; intr_status_bit is 0 on all GPIO pingroups).
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Quality: sufficient for the MPM case. Only IRQCHIP_STATE_PENDING; PDC pins are rejected via skip_wake_irqs.
- Nits (not blockers): bool written as the full status register (OK because status bit is 0); no pctrl->lock (single writel/readl); redundant g assignment in get; get is unused by MPM but harmless.
- intr_ack_high platforms (msm8660/8960, ipq8064, …) would invert set vs ack; those SoCs do not use MPM.
- For skip_wake_irqs (PDC), the walk now stops at msmgpio and returns -EINVAL instead of forwarding to PDC/GIC. PDC SoCs do not use MPM replay; this is conservative, not the MPM bug.
- Regression risk: **low–medium**. Writing pending can inject an IRQ; that is the intended replay. Pinctrl maintainer initially called it “super dangerous”, then acked after Qualcomm review.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record: These callbacks are new. The irqchip struct dates to 69b78b8de65b (2014) / immutable chip 14dbe186b9d4 (2022). skip_wake_irqs dates to e35a6ae0eb3a (2019). MPM (a6199bb514d8, 2022-03-11, ~v5.18) is what started calling irq_set_irqchip_state() on wakeup.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Bug is omission vs MPM, not a regression from a later commit.
**Step 3.3: CHECK FILE HISTORY**
Record: No prerequisite series. v1-1 is standalone. No later commit in this tree patches these new functions.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Maulik Shah is a regular Qualcomm pinctrl/irqchip contributor (PDC, wakeup, irqchip flags). Related work is Qualcomm wakeup IRQ handling, not a hard dependency of this patch.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Uses existing msm_readl/writel_intr_status, skip_wake_irqs, and irq_chip ops. Can apply standalone to this file.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- Lore: https://patch.msgid.link/20260424-pinctrl_irqchip_states-v1-1-
[email protected]
- Single revision **v1** (no v2/v3).
- Linus Walleij (28 Apr 2026): “smart and also **super dangerous**” — wanted Qualcomm ACK/test before merge.
- Navya Malempati (16 Jul 2026): Reviewed-by.
- Linus (25 Jul 2026): Acked-by; asked Bartosz to queue it.
- Bartosz (27 Jul 2026): Applied as [1/1].
- No Cc: stable, no NAK after Qualcomm review.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: To/Cc: Bjorn Andersson, Linus Walleij, linux-arm-msm, linux- gpio, linux-kernel, Maulik Shah. Right lists and maintainers.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot, bugzilla, or public user report. Qualcomm-internal hardware knowledge. Severity from the message: **GPIO edges cannot be replayed after sleep on any MPM SoC**.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone 1/1. Same 7.3 pinctrl-qcom pull also had PDC work; this patch does not depend on those.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No stable@ discussion found. Merged via “Qualcomm pinctrl updates for v7.3-rc1”.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
Record: msm_gpio_irq_set_irqchip_state, msm_gpio_irq_get_irqchip_state; msm_gpio_irq_chip updated.
**Step 5.2: TRACE CALLERS**
Record:
- IRQ core: irq_set_irqchip_state() / irq_get_irqchip_state() (kernel/irq/manage.c) start at the leaf chip (msmgpio).
- Primary caller: qcom_mpm_handler() in drivers/irqchip/irq-qcom- mpm.c (RPM wakeup IRQ, resume).
- Also: irq_inject_interrupt() (debug), KVM vgic (unrelated host IRQs).
**Step 5.3: TRACE CALLEES**
Record: msm_writel_intr_status / msm_readl_intr_status — MMIO to TLMM per-pin status.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Sleep → MPM latches wakeup GPIO → resume → qcom_mpm_handler → irq_set_irqchip_state(PENDING) → **now** TLMM status. Triggered by hardware wakeup, not a raw syscall. User-visible: GPIO clients (keys, modem, sensors) miss the edge after suspend.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: PDC already has irq_chip_{get,set}_parent_state. GIC implements these ops. skip_wake_irqs is set only when parent is PDC (IRQ_DOMAIN_FLAG_QCOM_PDC_WAKEUP). MPM parent does **not** set that flag, so TLMM keeps handling those GPIOs — which is why MSM GPIO must implement the ops.
---
## 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-27-gf0100363d8c37**, VERSION=7 PATCHLEVEL=3 SUBLEVEL=0 EXTRAVERSION=-rc4.
- Driver, MPM (CONFIG_QCOM_MPM), skip_wake_irqs, and accessors all exist.
- Commit 1860fb0be224 **is already an ancestor of HEAD** (7.3 merge window). Unfixed code is not on HEAD; the same files still need this on any branch that predates 7.3.
- Bug present since MPM (v5.18), not introduced after 7.3 branched.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** onto this pinctrl-msm.c. One file, two new functions, two irq_chip pointers. skip_wake_irqs and status accessors are old.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No other fix for “MPM cannot replay GPIO pending”. No follow-up on these functions after 1860fb0be224.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: drivers/pinctrl/qcom + Qualcomm MPM irqchip. **IMPORTANT** (platform GPIO/wakeup), not core mm/vfs. Affects Qualcomm MPM boards (sdm660, sm6115/6125/6375, msm8996/8998, qcm2290, …), not PDC phones.
**Step 7.2: SUBSYSTEM ACTIVITY**
Record: Actively maintained (Bartosz / Qualcomm). This is a targeted irqchip-ops fill-in, not a refactor.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Record: **Platform-specific** — CONFIG_PINCTRL_MSM* + CONFIG_QCOM_MPM. Not universal. Still real products (older/mid Qualcomm, IoT, embedded).
**Step 8.2: TRIGGER CONDITIONS**
Record: SoC deep sleep, then an edge GPIO that MPM monitored. Common on suspend/resume. Not an unprivileged syscall exploit path.
**Step 8.3: FAILURE MODE SEVERITY**
Record: Lost GPIO edge after resume (keys, wake sources, peripherals). Not oops/UAF/corruption. **MEDIUM–HIGH** functional/suspend-resume, not CRITICAL crash.
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit:** High for MPM Qualcomm users (resume GPIO actually fires).
- **Risk:** Low–medium (39 lines, pending-bit write). Mitigated by PENDING-only and skip_wake_irqs. No lock/API/data-structure change.
- **Ratio:** Benefit outweighs risk for trees that still lack the ops.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Concrete bug: MPM cannot replay GPIO edges after sleep.
- User-visible resume failure on MPM SoCs.
- Small, one-file, existing irqchip API only.
- Prerequisites present here for years.
- Qualcomm Reviewed-by, Walleij Acked-by, Bartosz merged.
- No follow-up fix in this tree.
- Same class as hardware/suspend quirks that stable takes.
AGAINST:
- Worded as “Add”; implements new irqchip methods.
- Not crash/UAF/security.
- No public reporter / Tested-by.
- Walleij first called it “super dangerous”.
- Minor implementation nits.
UNRESOLVED:
- No public repro log (Qualcomm-described).
- lore HTTP 403; thread recovered via b4 dig -m.
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — PENDING-only, skip PDC pins; reviewed/acked. Initial “dangerous” concern addressed in review. No Tested-by, but mechanism matches MPM code.
2. Fixes a real bug that affects users? **PASS** — lost GPIO IRQs after sleep on MPM SoCs.
3. Important issue? **PASS** — suspend/resume IRQ loss (serious functional), not oops/CVE.
4. Small and contained? **PASS** — +39 lines, one file.
5. No new features or APIs? **PASS** — no new uAPI; fills existing irq_chip ops the core already calls.
6. Can apply to the local tree? **PASS** — same file/helpers; applies cleanly.
**Step 9.3: EXCEPTION CATEGORIES**
Record: Not a device-ID/DT/build/doc exception. Closest: **hardware wakeup workaround** (missing irqchip op so existing MPM hardware works after sleep).
**Step 9.4: DECISION**
This tree has the MSM GPIO irqchip, MPM, and skip_wake_irqs. The bug is missing ops, present since MPM (~v5.18), not a 7.3-only feature. The patch is a small, review-vetted fix for lost edge GPIOs after deep sleep. That meets stable rules for this checkout.
---
### What it solves for stable users
On Qualcomm MPM SoCs, an edge GPIO during sleep is latched in always-on MPM. On resume, MPM marks the leaf irqchip pending. Without these ops, msmgpio cannot accept that, so the edge is dropped. Users can miss keys, modem/Wi-Fi wake, sensors, etc. after suspend.
### Stable rules
Small, obviously aimed at one hardware path, no new uAPI, real resume bug. Risk is writing the GPIO pending bit; the patch limits that to IRQCHIP_STATE_PENDING and non-PDC pins.
### Risk vs benefit
Benefit is real on MPM platforms. Risk is contained. Quality nits do not break the MPM case (intr_status_bit == 0).
---
### Verification
- **[Phase 1]** Tags: Reviewed-by Navya, Acked-by Walleij, Link to msgid; no Fixes/Reported-by/Cc:stable.
- **[Phase 2]** Diff: +39 in pinctrl-msm.c; two callbacks + irq_chip pointers; msm_writel_intr_status(val) with bool; intr_status_bit is 0 on GPIO groups (verified across pinctrl-qcom).
- **[Phase 2]** qcom_mpm_handler confirmed to call irq_set_irqchip_state(..., IRQCHIP_STATE_PENDING, true) for non- level IRQs.
- **[Phase 2]** irq_set_irqchip_state() in kernel/irq/manage.c walks until a chip implements the op; qcom_mpm_chip does not.
- **[Phase 3]** MPM added a6199bb514d8 (2022); skip_wake_irqs from e35a6ae0eb3a (2019); no later fix to these functions.
- **[Phase 3]** git merge-base --is-ancestor 1860fb0be224 HEAD → yes (commit is in this 7.3-rc4 history). Decision is on technical merit, not “already selected”.
- **[Phase 4]** b4 dig -c 1860fb0be224 → v1 only; Walleij “super dangerous” then Acked-by; Bartosz applied 1/1.
- **[Phase 4]** b4 dig -w: linux-gpio, linux-arm-msm, Walleij, Andersson.
- **[Phase 4]** lore.kernel.org WebFetch 403; thread read from /tmp/pinctrl-irqchip.mbox.
- **[Phase 5]** PDC sets IRQ_DOMAIN_FLAG_QCOM_PDC_WAKEUP → skip_wake_irqs; MPM sets IRQ_DOMAIN_FLAG_QCOM_MPM_WAKEUP and does not skip TLMM.
- **[Phase 6]** git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4.
- **[Phase 8]** Failure: dropped GPIO edge after MPM wakeup; severity MEDIUM–HIGH functional, not crash.
- **UNVERIFIED:** Public reproducer / which exact board Qualcomm used (not in the thread).
The patch is a contained fix for a real resume IRQ-loss bug on hardware this tree already supports.
**YES**
drivers/pinctrl/qcom/pinctrl-msm.c | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
drivers/pinctrl/qcom/pinctrl-msm.c +39 -0
@@ -1289,6 +1289,43 @@ static int msm_gpio_irq_set_affinity(struct irq_data *d,return -EINVAL ; } +static int msm_gpio_irq_set_irqchip_state (struct irq_data *d, +enum irqchip_irq_state which,bool val) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (d); +struct msm_pinctrl *pctrl =gpiochip_get_data (gc); +const struct msm_pingroup *g = &pctrl->soc->groups[d->hwirq]; + +if (which !=IRQCHIP_STATE_PENDING ) +return -EINVAL ; + +if (test_bit (d->hwirq, pctrl->skip_wake_irqs)) +return -EINVAL ; + +msm_writel_intr_status (val, pctrl, g); + +return 0 ; +} + +static int msm_gpio_irq_get_irqchip_state (struct irq_data *d, +enum irqchip_irq_state which,bool *val) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (d); +struct msm_pinctrl *pctrl =gpiochip_get_data (gc); +const struct msm_pingroup *g = &pctrl->soc->groups[d->hwirq]; + +if (which !=IRQCHIP_STATE_PENDING ) +return -EINVAL ; + +if (test_bit (d->hwirq, pctrl->skip_wake_irqs)) +return -EINVAL ; + + g = &pctrl->soc->groups[d->hwirq]; + *val =msm_readl_intr_status (pctrl, g); + +return 0 ; +} +static int msm_gpio_irq_set_vcpu_affinity (struct irq_data *d,void *vcpu_info) {struct gpio_chip *gc =irq_data_get_irq_chip_data (d);
@@ -1377,6 +1414,8 @@ static const struct irq_chip msm_gpio_irq_chip = { .irq_request_resources = msm_gpio_irq_reqres, .irq_release_resources = msm_gpio_irq_relres, .irq_set_affinity = msm_gpio_irq_set_affinity, + .irq_set_irqchip_state = msm_gpio_irq_set_irqchip_state, + .irq_get_irqchip_state = msm_gpio_irq_get_irqchip_state, .irq_set_vcpu_affinity = msm_gpio_irq_set_vcpu_affinity, .flags = (IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_SET_TYPE_MASKED |
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-6.1] pinctrl: qcom: Add irq_get/set_irqchip_state() for msm gpio irqchip
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] pinctrl: qcom: missing parent delegation in msm_gpio_irq_set_irqchip_state() - [Medium] pinctrl…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] pinctrl: qcom: missing parent delegation in msm_gpio_irq_set_irqchip_state()
- [Medium] pinctrl: qcom: intr_ack_high ignored in msm_gpio_irq_set_irqchip_state() --
commit 301c33b42ee8c08eddc97fb199477c476ddbf18c
Author: Maulik Shah <[email protected]>
pinctrl: qcom: Add irq_get/set_irqchip_state() for msm gpio irqchip
This commit implements the .irq_get_irqchip_state and .irq_set_irqchip_state callbacks for msm_gpio_irq_chip to support replaying edge interrupts for IRQCHIP_STATE_PENDING after wakeup on MPM-based Qualcomm SoCs.
Quoted 10 lines
drivers/pinctrl/qcom/pinctrl-msm.c +2
-0@@ -1289,6 +1289,43 @@ static int msm_gpio_irq_set_affinity(struct irq_data *d,return -EINVAL ; } +static int msm_gpio_irq_set_irqchip_state (struct irq_data *d, +enum irqchip_irq_state which,bool val)
drivers/pinctrl/qcom/pinctrl-msm.c static int msm_gpio_irq_set_affinity(struct irq_data *d, · line 1303
Quoted 10 lines
drivers/pinctrl/qcom/pinctrl-msm.c +10
-0+{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (d); +struct msm_pinctrl *pctrl =gpiochip_get_data (gc); +const struct msm_pingroup *g = &pctrl->soc->groups[d->hwirq]; + +if (which !=IRQCHIP_STATE_PENDING ) +return -EINVAL ; + +if (test_bit (d->hwirq, pctrl->skip_wake_irqs)) +return -EINVAL ;
[Severity: High]
Does returning -EINVAL here and in msm_gpio_irq_get_irqchip_state() break parent interrupt state queries and updates on PDC-based Qualcomm SoCs?
In kernel/irq/manage.c, __irq_get_irqchip_state() and irq_set_irqchip_state() walk up data->parent_data and stop at the first irq_chip that defines the callback, without falling back to parent_data when -EINVAL is returned:
kernel/irq/manage.c:__irq_get_irqchip_state() {
...
do {
chip = irq_data_get_irq_chip(data);
if (WARN_ON_ONCE(!chip))
return -ENODEV;
if (chip->irq_get_irqchip_state)
break;
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
data = data->parent_data;
#else
data = NULL;
#endif
} while (data);
...
}On PDC-based SoCs (IRQ_DOMAIN_FLAG_QCOM_PDC_WAKEUP), msm_gpio_init() sets pctrl->skip_wake_irqs for wakeup-capable GPIOs because interrupt detection is handled by the parent hierarchy (msmgpio -> PDC -> GICv3), and qcom_pdc_gic_chip in drivers/irqchip/qcom-pdc.c explicitly wires:
.irq_get_irqchip_state = irq_chip_get_parent_state, .irq_set_irqchip_state = irq_chip_set_parent_state,
Previously, msm_gpio_irq_chip left both callbacks NULL, so calls walked past msmgpio to PDC and GICv3. With this change, when synchronize_irq(), disable_irq(), or __free_irq() calls __synchronize_hardirq() -> __irq_get_irqchip_state(irqd, IRQCHIP_STATE_ACTIVE, &inprogress), or when KVM vgic, machine_kexec_mask_interrupts(), or irq_inject_interrupt() queries or updates state on a PDC-routed GPIO, the walk stops at msmgpio and fails with -EINVAL.
Should msm_gpio_irq_set_irqchip_state() and msm_gpio_irq_get_irqchip_state() delegate to irq_chip_set_parent_state(d, which, val) and irq_chip_get_parent_state(d, which, val) when d->parent_data && test_bit(d->hwirq, pctrl->skip_wake_irqs), similar to msm_gpio_irq_set_affinity() and msm_gpio_irq_set_vcpu_affinity()?
Quoted 14 lines
drivers/pinctrl/qcom/pinctrl-msm.c +14
-0+ +msm_writel_intr_status (val, pctrl, g); + +return 0 ; +} + +static int msm_gpio_irq_get_irqchip_state (struct irq_data *d, +enum irqchip_irq_state which,bool *val) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (d); +struct msm_pinctrl *pctrl =gpiochip_get_data (gc); +const struct msm_pingroup *g = &pctrl->soc->groups[d->hwirq]; + +if (which !=IRQCHIP_STATE_PENDING )
drivers/pinctrl/qcom/pinctrl-msm.c static int msm_gpio_irq_set_affinity(struct irq_data *d, · line 1327
Quoted 10 lines
drivers/pinctrl/qcom/pinctrl-msm.c +10
-0+return -EINVAL ; + +if (test_bit (d->hwirq, pctrl->skip_wake_irqs)) +return -EINVAL ; + + g = &pctrl->soc->groups[d->hwirq]; + *val =msm_readl_intr_status (pctrl, g); + +return 0 ; +}
[Severity: Medium]
How does msm_gpio_irq_set_irqchip_state() behave on TLMM v2 SoCs where g->intr_ack_high is set (such as apq8064, ipq8064, mdm9615, msm8660, and msm8960), or if g->intr_status_bit is non-zero?
In drivers/pinctrl/qcom/pinctrl-msm.c, msm_ack_intr_status() clears a pending interrupt by accounting for both g->intr_ack_high and g->intr_status_bit:
static void msm_ack_intr_status(struct msm_pinctrl *pctrl,
const struct msm_pingroup *g)
{
u32 val = g->intr_ack_high ? BIT(g->intr_status_bit) : 0;
msm_writel_intr_status(val, pctrl, g);
}By passing the raw boolean val directly to msm_writel_intr_status(val, pctrl, g), won't calling irq_set_irqchip_state(irq, IRQCHIP_STATE_PENDING, true) on an intr_ack_high platform acknowledge and clear the pending interrupt instead of setting it pending, while passing false writes 0 and fails to clear it?
Also, in msm_gpio_irq_get_irqchip_state(), g = &pctrl->soc->groups[d->hwirq] is initialized twice, and *val = msm_readl_intr_status(pctrl, g) converts the full 32-bit register read to bool without masking with BIT(g->intr_status_bit) (unlike msm_gpio_irq_handler()). Should both functions mask/shift with BIT(g->intr_status_bit) and account for g->intr_ack_high?
[ ... ]
Quoted 4 lines
Signature · 2 lines
-- 2.34.1
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 udf: bound lengthAllocDescs from unallocated space entry
In reply to Sasha LevinFrom: Jay Vadayath <[email protected]>
[ Upstream commit b8228f59dc58aea06dc024efd8f64c2d048c4578 ]
udf_read_inode() copies the on-disk lengthAllocDescs field of a USE (unallocSpaceEntry) inode into iinfo->i_lenAlloc without checking that it fits in the i_data buffer that is subsequently allocated for the inode. udf_count_free_table(), called from udf_statfs(), then walks the allocation descriptor array up to i_lenAlloc bytes, so a crafted UDF image with lengthAllocDescs larger than (blocksize - sizeof(struct unallocSpaceEntry)) causes udf_get_fileshortad() to read past the end of the kmalloc'd i_data buffer.
KASAN report from mounting a crafted UDF image and calling statfs() from an unprivileged process:
BUG: KASAN: slab-out-of-bounds in udf_get_fileshortad+0x126/0x130 Read of size 4 at addr ffff8880042137d8 by task poc/65 Call Trace: dump_stack_lvl+0x53/0x70 print_report+0xce/0x610 kasan_report+0xce/0x100 udf_get_fileshortad+0x126/0x130 udf_current_aext+0x3c4/0xa10 udf_next_aext+0x241/0x440 udf_statfs+0xb7d/0x11c0 statfs_by_dentry+0x117/0x1e0 user_statfs+0xac/0x130 __do_sys_statfs+0x80/0xe0 do_syscall_64+0x102/0x5a0 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Reject USE inodes whose lengthAllocDescs would place descriptors past the end of the i_data buffer, mirroring the checks the rest of the UDF code performs on descriptor lengths.
This bug was discovered by Artiphishell's vTriage pipeline, which generated a userspace reproducer that reliably triggers the KASAN report on an unpatched kernel. The fix below was drafted with the Claude coding assistant; a userspace reproducer (and the crafted UDF image) is available on request.
---
LLM Generated explanations, may be completely bogus:
I have enough to decide: this is a four-line UDF bounds check for a KASAN out-of-bounds read on crafted images, and it applies to this tree.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[udf]** **[bound]** bound lengthAllocDescs from an unallocated space entry (USE) inode so descriptor walking cannot run past the i_data buffer.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Assisted-by:** LLM (drafted with Claude)
- **Signed-off-by:** Jay Vadayath \<[email protected]\> (author)
- **Link:**
https://patch.msgid.link/[email protected]
- **Signed-off-by:** Jan Kara \<[email protected]\> (UDF maintainer; applied the patch)
- **No Fixes:** tag (expected for this review)
- **No Cc: stable** (expected; absence is not a negative)
- **No Reported-by / Tested-by / Reviewed-by / Acked-by**
- Ignored: any pipeline “already selected” markers (none on the real commit)
Notable: no syzbot tag, but a concrete KASAN stack and a userspace reproducer are in the body. A later independent patch (Baul Lee, Cc:
stable) reports the same bug.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** udf_read_inode() copies on-disk lengthAllocDescs from a USE inode into iinfo->i_lenAlloc with no check that it fits in the later i_data allocation (bs - sizeof(struct unallocSpaceEntry)).
- **Symptom:** KASAN slab-out-of-bounds read in udf_get_fileshortad() after mount + statfs().
- **Failure path:** statfs → udf_statfs → udf_count_free_table → udf_next_aext → udf_current_aext → udf_get_fileshortad.
- **Trigger:** crafted UDF image; statfs() from an unprivileged process after the image is mounted.
- **Root cause:** USE branch returns before the FE/EFE lengthAllocDescs sanity checks.
- **Fix:** reject USE inodes whose lengthAllocDescs would extend past i_data.
- **Version info:** none in the message; the USE path dates to ~2008.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. Explicit KASAN OOB fix with a reproducer.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** fs/udf/inode.c — **+4 / −0**
- **Function:** udf_read_inode()
- **Scope:** single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record (USE branch in udf_read_inode):
- **Before:** set i_lenAlloc from on-disk lengthAllocDescs, allocate i_data of size bs - sizeof(struct unallocSpaceEntry), memcpy that many bytes, return 0. Oversized lengthAllocDescs is trusted.
- **After:** if i_lenAlloc > bs - sizeof(struct unallocSpaceEntry), return -EFSCORRUPTED via out: (which brelses bh). Check is **before** udf_alloc_i_data(), so no i_data leak on the new error path.
- **Path:** mount-time inode load for USE (unalloc space table), not a hot write path.
Verified pre-fix code at b8228f59dc58a^:
``` iinfo->i_lenAlloc = le32_to_cpu(... lengthAllocDescs); ret = udf_alloc_i_data(inode, bs - sizeof(struct unallocSpaceEntry)); ```
No bound check. FE/EFE checks at lines 1588–1592 are after this early return 0, so USE never hit them.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Memory safety — out-of-bounds read** of on-disk length.
Mechanism (verified in this tree):
1. udf_count_free_table() starts epos.offset = sizeof(struct unallocSpaceEntry), epos.bh = NULL.
2. udf_current_aext() (in-ICB) sets alen = udf_file_entry_alloc_offset(inode) + iinfo->i_lenAlloc. For USE, offset is sizeof(struct unallocSpaceEntry).
3. udf_get_fileshortad(ptr, alen, &offset, inc) only checks *offset + sizeof(struct short_ad) > maxoffset (alen). Inflated i_lenAlloc makes that check pass while ptr walks off the kmalloc’d i_data.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Quality:** Obviously correct. Same idea as the 2015 FE/EFE checks (udf_file_entry_alloc_offset() + i_lenAlloc > bs). Equal length is allowed (> not >=), matching a full-block descriptor array.
- **Jan Kara** changed the submitted goto out (ret still -EIO) to -EFSCORRUPTED, consistent with other UDF corruption returns in this tree.
- **Regression risk:** Low. Only crafted/corrupt USE inodes with lengthAllocDescs larger than remaining block space fail to load; mount then fails instead of later OOB. Valid images are unchanged.
- **No** public API / feature / locking change.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- USE branch and unvalidated lengthAllocDescs load: **Marcin Slusarz, 2008** (48d6d8ff7dca80 / 4b11111aba6c80), in **v2.6.25-rc1**.
- FE/EFE bounds checks that USE skips: **Jan Kara, 2015** (23b133bdc452aa “udf: Check length of extended attributes and allocation descriptors”), which itself had CC: stable.
- The four new lines: this commit (b8228f59dc58ae).
The hole is long-standing, not new-subsystem code.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Equivalent introduction is the 2008 USE caching plus the 2015 checks that never ran for USE. Both are ancestors of this HEAD.
A later duplicate patch used Fixes: 23b133bdc452. That commit is the missed-check explanation, not the only origin of the OOB.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- 3bd5e45c2ce30 (“fs: udf: fix OOB read in lengthAllocDescs handling”) — different bug (AED lengthAllocDescs vs bh->b_size in udf_current_aext). Already in this tree; not a substitute for the USE i_data check.
- d95094d4c0a62 (“udf: Fix bh leak for unallocated space entries”) — **after** this commit; adds brelse(bh) on the USE success path. Independent; this fix does not need it.
- Not a numbered series.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Jay Vadayath has this one UDF commit here. **Jan Kara** is the UDF maintainer (MAINTAINERS: UDF FILESYSTEM) and applied it.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Standalone. Uses existing i_lenAlloc, bs, unallocSpaceEntry, udf_alloc_i_data(), -EFSCORRUPTED. EFSCORRUPTED is used throughout fs/udf/ in this tree (3d2d7e61553db is an ancestor). No new helpers.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c b8228f59dc58ae:
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only** (no v2/v3).
- lore.kernel.org fetches returned **403**; original text verified via
Openwall: https://lists.openwall.net/linux-kernel/2026/07/17/2179
- Submitted 2026-07-17; applied by Jan Kara 2026-07-27.
- Submitted form: comment + goto out (ret -EIO). Committed form:
-EFSCORRUPTED, comment dropped. No NAK found.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): Jay Vadayath, **Jan Kara**, linux-kernel@. linux- fsdevel was not on the original To/Cc; the maintainer still applied it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No public syzbot/bugzilla link. Author cites Artiphishell vTriage + a reproducer. Independent report nine days later: Baul Lee / XBOW, https://lists.openwall.net/linux-kernel/2026/07/26/145 — same USE early-return hole, Cc: [email protected].
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Duplicate “udf: fix OOB read for a crafted unallocSpaceEntry” (2 lines, udf_file_entry_alloc_offset() + i_lenAlloc > bs). Jan Kara replied that **this** commit already handles it (Spinics/stable thread snippet). Equivalent fix, not a dependency.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: Duplicate was sent with Cc: stable. Jan pointed at b8228f59dc58. Related AED OOB (3bd5e45c2ce30) was already backported to 5.10/5.15. No NAK of *this* fix for stable. lore.kernel.org/stable
search: **403** (UNVERIFIED full stable archive).
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: udf_read_inode() only. Related: udf_count_free_table(), udf_current_aext(), udf_get_fileshortad(), udf_statfs(), __udf_iget().
**Step 5.2: TRACE CALLERS**
Record (grep in fs/udf/):
- udf_read_inode() ← __udf_iget()
- __udf_iget() ← udf_iget() / udf_iget_special()
- udf_iget_special() ← udf_load_partition path in super.c when unallocSpaceTable.extLength is set (line ~1163)
- udf_statfs is s_op->statfs → statfs(2)
**Step 5.3: TRACE CALLEES**
Record: new path only assigns ret and goto out → brelse(bh); return ret. No alloc/lock on the error path.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Mount UDF with a Type-1 partition unalloc space table → udf_iget_special → udf_read_inode USE branch. If the inode loads, unprivileged statfs(2) → udf_count_free() → udf_count_free_table() when UDF_PART_FLAG_UNALLOC_TABLE is set. **Reachable from userspace** after mount (optical/USB UDF, loop images, automount). After this fix, corrupt USE fails at mount (-EFSCORRUPTED).
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: FE/EFE already checked (2015). AED lengthAllocDescs vs bh size already checked (3bd5e45c2ce30). USE was the remaining hole because of the early return.
semcode MCP: **not available**; used grep/read.
---
## 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-27-gf0100363d8c37**, VERSION=7 PATCHLEVEL=3 SUBLEVEL=0 EXTRAVERSION=-rc4 (mainline 7.3-rc4, not an LTS branch).
- UDF USE handling **is** in fs/udf/inode.c.
- Bug introduced ~**v2.6.25** (2008); FE/EFE checks since **2015**. Both are ancestors of HEAD.
- The candidate commit **is** an ancestor of HEAD (git merge-base --is- ancestor b8228f59dc58a HEAD). That is expected on mainline and is **not** treated as “already selected for stable.”
- Without this check, the USE branch in this file is exactly the buggy pattern.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** on this tree: four lines in a USE branch that has been stable since 2008/2014. Later brelse on success (d95094d4c0a62) does not conflict. -EFSCORRUPTED is already used in fs/udf/ here.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: AED OOB fix is present but **does not** cover USE i_data. No earlier USE lengthAllocDescs bound. This is the USE-specific fix.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **fs/udf** — **IMPORTANT** (not mm/VFS core). UDF is used for DVD/CD-RW and some USB disks (fs/udf/Kconfig). Corrupt-image bugs still matter for automount and unprivileged statfs.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature but active under Jan Kara (writeback, extent, corruption checks in 7.x). This is a missing validation hole, not a refactor of new code.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Filesystem-specific** (CONFIG_UDF_FS): users who mount UDF (optical, some USB, disk images).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Crafted/corrupt USE lengthAllocDescs; partition has unalloc space **table** (not only bitmap). Walk happens on statfs if LVID free-space is 0 and bitmap path doesn’t apply. **Unprivileged statfs after mount.** Mount is usually privileged, but removable media is often automounted. Two independent finders with a reliable KASAN repro.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **KASAN slab-out-of-bounds read** past i_data. Without KASAN:
unstable read of adjacent slab (crash and/or info leak). **Severity:
HIGH** (memory safety, local after mount). Not a guaranteed privilege escalation by itself.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** High — stops a real, reproducible OOB on a user-reachable statfs path.
- **Risk:** Very low — 4 lines, error path only, same check style as existing UDF validation.
- **Ratio:** Strongly favors backport.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real KASAN OOB with stack and reproducer
- Unprivileged statfs after mounting crafted UDF
- Two independent reports; duplicate explicitly Cc: stable
- UDF maintainer applied it
- 4-line bounds check; no new API
- Bug in USE code since ~2008; this tree has that code
- FE/EFE already had the same class of check; USE skipped it
- New error path is before allocation; out: already releases bh
**AGAINST:**
- Affects UDF only, and mainly malicious/corrupt images
- Original submission was LLM-assisted (mitigated: maintainer applied; second reporter confirmed)
- No Fixes: / Cc: stable on the applied commit (not a negative under these rules)
**UNRESOLVED:**
- lore.kernel.org 403; discussion taken from b4 + Openwall
- Full stable@ archive not fetched; duplicate + Jan’s “already in my tree” reply was enough
- No public crafted image in-tree (author offered it on request)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — bound matches buffer size; KASAN repro; maintainer applied; second independent patch.
2. Fixes a real bug that affects users? **PASS** — OOB on mount + statfs.
3. Important issue? **PASS** — HIGH: slab OOB (crash / info leak), not a style tweak.
4. Small and contained? **PASS** — +4 lines, one function.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — USE path and -EFSCORRUPTED exist; hunk is self-contained.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. It is a normal **memory-safety bug fix**.
**Step 9.4: DECISION**
This tree (v7.3-rc4) contains the long-standing USE inode path. The commit closes a real out-of-bounds read with a minimal check that matches existing UDF validation. It should be backported to this tree’s stable lineage.
### What the commit solves and why it matters
Unallocated-space (USE) inodes trusted on-disk lengthAllocDescs and then walked that many bytes in a smaller i_data buffer. A crafted UDF image mounts, then statfs hits KASAN OOB in udf_get_fileshortad(). After the fix, those inodes fail load with -EFSCORRUPTED instead of reading off the end of the slab.
### Stable rules / risk vs benefit
Surgical, maintainer-acked, no new ABI. Benefit is stopping a user- reachable memory-safety bug; regression risk is limited to already- invalid images.
### Concerns
None that block backport here. Optional follow-up d95094d4c0a62 (bh leak on the USE success path) is separate. -EFSCORRUPTED is already used in this tree’s UDF code.
---
## Verification
- **[Phase 1]** Parsed commit b8228f59dc58aea06dc024efd8f64c2d048c4578: Assisted-by LLM, Link msgid, SOB Jay Vadayath + Jan Kara; no Fixes/Cc stable/Reported-by
- **[Phase 1]** Body includes KASAN stack: udf_get_fileshortad ← udf_current_aext ← udf_next_aext ← udf_statfs ← statfs
- **[Phase 2]** git show: +4 lines in udf_read_inode() USE branch only
- **[Phase 2]** Read fs/udf/inode.c USE path (~1475–1493) and FE/EFE checks (~1588–1592); USE return 0 skips those checks
- **[Phase 2]** Read udf_count_free_table() (super.c ~2508), udf_current_aext() (inode.c ~2269), udf_get_fileshortad() (directory.c ~500) — OOB mechanism confirmed
- **[Phase 2]** Error path is before udf_alloc_i_data; out: at 1666 does brelse(bh); return ret
- **[Phase 3]** git blame: USE lengthAllocDescs from 2008 (48d6d8ff7dca80); FE/EFE checks 23b133bdc452aa (2015)
- **[Phase 3]** git merge-base --is-ancestor 48d6d8ff, 23b133bd, 3d2d7e61, b8228f59 → all ancestors of HEAD
- **[Phase 3]** Related 3bd5e45c2ce30 is AED/bh OOB, not this USE i_data bug
- **[Phase 3]** Follow-up d95094d4c0a62 only adds brelse on success; not required for this fix
- **[Phase 4]** b4 dig -c: msgid [email protected]; -a v1 only; -w Jan Kara + LKML
- **[Phase 4]** Openwall original patch verified; committed version adds -EFSCORRUPTED
- **[Phase 4]** Duplicate patch 2026-07-26 by Baul Lee, Cc: stable;
Jan: this commit already handles it
- **[Phase 4]** lore.kernel.org HTTP 403 — UNVERIFIED full lore thread beyond b4/Openwall
- **[Phase 5]** Callers: __udf_iget → udf_iget_special at super.c:1163 for unalloc space table; udf_statfs is .statfs
- **[Phase 5]** semcode unavailable; used grep/read
- **[Phase 6]** git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- **[Phase 6]** Pre-fix parent b8228f59^ shows unvalidated i_lenAlloc then udf_alloc_i_data
- **[Phase 6]** -EFSCORRUPTED used in fs/udf/inode.c, super.c, namei.c, directory.c, balloc.c, symlink.c
- **[Phase 7]** MAINTAINERS: Jan Kara maintains fs/udf/
- **[Phase 8]** Failure mode: slab-OOB read, HIGH; trigger: crafted UDF
+ statfs
- **UNVERIFIED:** Public crafted ISO contents; complete lore.kernel.org/stable mailbox beyond the duplicate-patch snippet
The patch is a small, correct bounds check for a real KASAN OOB that this tree’s UDF USE path has had for years.
**YES**
fs/udf/inode.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/udf/inode.c +4 -0
@@ -1488,6 +1488,10 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode) iinfo->i_lenAlloc =le32_to_cpu ( ((struct unallocSpaceEntry *)bh->b_data)-> lengthAllocDescs); +if (iinfo->i_lenAlloc > bs -sizeof (struct unallocSpaceEntry )) { + ret = -EFSCORRUPTED ; + goto out; + } ret =udf_alloc_i_data (inode, bs -sizeof (struct unallocSpaceEntry ));if (ret)
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ASoC: rt712-sdca: Pull high JD2 to prevent from entering TV mode
In reply to Sasha LevinFrom: Jack Yu <[email protected]>
[ Upstream commit dfb8bc1d286fd97b7cf47e3af5df84cfb068d214 ]
Add a patch setting to prevent ALC712 from entering TV mode which may cause unexpected issues.
---
LLM Generated explanations, may be completely bogus:
Local tree is **6.12.111** (p-6.12-3-gc504cf0baa3d8). The candidate is mainline dfb8bc1d286fd97b7cf47e3af5df84cfb068d214. It is not in this checkout; the VB init path it patches is.
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
- Record: [ASoC/rt712-sdca] [Pull high] Pull JD2 high so ALC712 does not enter TV mode
**Step 1.2 — Tags**
- Record:
- Signed-off-by: Jack Yu <[email protected]> (vendor author)
- `Link: https://patch.msgid.link/20260820092415.2979641-1-
[email protected]`
- Signed-off-by: Mark Brown <[email protected]> (ASoC maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, or Cc: stable (absence is expected for this review)
- Pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] ignored
**Step 1.3 — Body**
- Record:
- Bug: ALC712 can enter **TV mode** if JD2 is not pulled high
- Symptom: “unexpected issues” only — no stack trace, no jack/audio failure description, no machine name
- Root cause (author): missing vendor register write during VB I/O init
- Version info: none in the message; change is only in
`rt712_sdca_vb_io_init()`, so version B only
**Step 1.4 — Hidden bug fix?**
- Record: Not disguised cleanup. It is a vendor hardware workaround worded as “add a patch setting.” That matches HDA/ASoC codec init quirks, not a refactor.
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
- Record:
- sound/soc/codecs/rt712-sdca.c: +1 (write in
`rt712_sdca_vb_io_init`)
- sound/soc/codecs/rt712-sdca.h: +1 (#define RT712_JD_CTL3 0x0b)
- Scope: single-driver, two-line surgical change
**Step 2.2 — Flow**
- Record: Before, VB init never programmed JD_CTL3. After, every rt712_sdca_vb_io_init() call writes NID RT712_VENDOR_REG (0x20), index 0x0b, value 0x7778 via existing rt712_sdca_index_write(). The write is unconditional (not gated on FUNCTION_NEEDS_INITIALIZATION), so it runs on first attach and later re-init. Normal init path, not an error path.
**Step 2.3 — Bug mechanism**
- Record: **Hardware workaround / codec quirk.** Jack-detect pin JD2 is pulled high so the analog frontend stays out of TV (CE) jack mode. The driver already uses JD1 for HP detection (rt712->jd_src = RT712_JD1; enum has no JD2). This is the same class of change as HDA Realtek pin/coef quirks.
**Step 2.4 — Fix quality**
- Record: Minimal and matches surrounding vendor init writes. Regression risk is low: one extra MBQ register write at SoundWire attach. Theoretical risk is a board that needed JD2 floating/low; this driver does not implement JD2 as a jack source, and Realtek submitted the value for all VB parts. Magic 0x7778 is undocumented but typical for this driver.
## Phase 3: Git history
**Step 3.1 — Blame**
- Record: Insertion point in this tree is after the func_status debug print, blamed to 936abb09c1c7c (“ASoC: rt712-sdca: add the function for version B”, Shuming Fan, 2024-06-20). RT712_JD_CTL1 came from that same commit. Driver itself landed in 6c39710da75ca (2023-02). VB init has been in 6.12 since the branch.
**Step 3.2 — Fixes: tag**
- Record: None. Missing init is the “bug”; there is no later bisect commit that introduced TV mode.
**Step 3.3 — File history**
- Record: Recent in this tree: 8ad30bd5c1088 (reset at io_init for silent headphone, already backported; that is VA calibration, not this JD2 write). No other JD_CTL3 work. Standalone, not patch X/Y.
**Step 3.4 — Author**
- Record: Jack Yu is a Realtek ASoC contributor ([email protected]). Other codec work in this tree includes rt722/rt5682s/rt5645 fixes. Recipients in the original mail include Shuming Fan and other Realtek codec people.
**Step 3.5 — Dependencies**
- Record: Needs rt712_sdca_index_write(), RT712_VENDOR_REG, and rt712_sdca_vb_io_init() — all present. No new helpers. Applies standalone.
## Phase 4: Mailing list / external
**Step 4.1 — Original discussion**
- Record: b4 dig -c dfb8bc1d286fd97b7cf47e3af5df84cfb068d214 →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only**, no later revision
- Thread (mbox): patch + Mark Brown “Applied to … for-7.3”. **No NAK, no review comments, no Cc: stable in review**
- Takashi Iwai then included it in **sound fixes for 7.3-rc1** (LKML pull, listed under “Codec fixes for … rt712 …”)
**Step 4.2 — Recipients (b4 dig -w)**
- Record: [email protected], [email protected], alsa-devel@alsa- project.org, Realtek codec engineers (shumingf, flove, oder_chiou, derek.fang), MediaTek Trevor.Wu. ASoC maintainers were on To.
**Step 4.3 — Bug report**
- Record: No bugzilla/syzbot/user report. Symptom stays vendor-stated “unexpected issues.”
**Step 4.4 — Series**
- Record: Standalone 1/1. Later mainline d56fe35 (“reconfigure PLL2 to fix calibration time-out”) is a **different** Jack Yu fix, not a prerequisite or revert of JD_CTL3.
**Step 4.5 — Stable list**
- Record: lore.kernel.org HTTP is 403 from this environment. No stable- thread evidence found via b4. UNVERIFIED: whether anyone already asked stable@ for this SHA.
## Phase 5: Semantic / call chain
**Step 5.1 — Functions**
- Record: rt712_sdca_vb_io_init() only (plus header define).
**Step 5.2 — Callers**
- Record: rt712_sdca_io_init() → if version_id != RT712_VA → rt712_sdca_vb_io_init(). rt712_sdca_io_init() is called from rt712_sdca_update_status() in rt712-sdca-sdw.c when the SoundWire slave is SDW_SLAVE_ATTACHED and hw_init is false. That is boot/resume enumeration, not a syscall hot path.
**Step 5.3 — Callees**
- Record: rt712_sdca_index_write() → regmap_write() on mbq_regmap. Same helper used throughout this file.
**Step 5.4 — Reachability**
- Record: Yes, from userspace-visible audio: plugging/using headset on Intel SoundWire laptops with RT712 VB (ACPI match tables exist for MTL/TGL/LNL in this tree). Unprivileged users do not program the register; they hit it by using audio after attach.
**Step 5.5 — Similar patterns**
- Record: Many sibling vendor rt712_sdca_index_write() calls in the same function. No other TV mode / JD_CTL3 in this tree. 0x7778 appears in HDA ALC256_FIXUP_ASUS_HPE as an unrelated EAPD coef — same number, different codec, not this bug.
## Phase 6: This tree (6.12.y)
**Step 6.1 — Buggy code present?**
- Record: Yes. rt712_sdca_vb_io_init() at sound/soc/codecs/rt712-sdca.c:1721 has the exact pre-patch context. RT712_JD_CTL3 is **not** defined. git merge-base --is-ancestor dfb8bc1d… HEAD fails (commit not here). 936abb09c1c7c **is** an ancestor. Bug/missing workaround exists since VB support (v6.11-era, in 6.12).
**Step 6.2 — Backport difficulty**
- Record: **Clean apply with line offset.** Mainline hunk is ~1779; here the same lines are ~1734. Context strings match; RT712_JD_CTL3 is free in the header.
**Step 6.3 — Related fixes already here?**
- Record: 8ad30bd5c1088 resets the codec for VA silent headphones. It does not pull JD2 / program JD_CTL3. No substitute for this workaround.
## Phase 7: Subsystem
**Step 7.1**
- Record: ASoC codec driver (sound/soc/codecs/). Criticality:
**IMPORTANT** for SoundWire Intel laptops with RT712; not core mm/fs. Peripheral relative to the whole kernel, but a shipping laptop codec.
**Step 7.2**
- Record: Driver is mature in 6.12 (added 2023, VB in 2024). This is a late vendor init correction, not churn from a brand-new subsystem.
## Phase 8: Impact and risk
**Step 8.1 — Who**
- Record: Config SND_SOC_RT712_SDCA_SDW + RT712/713/716/717 **version B** on SoundWire (Intel MTL/TGL/LNL match files in-tree). Not universal.
**Step 8.2 — Trigger**
- Record: Device attach / io_init. Common for those machines. Not a race. Not unprivileged memory-safety.
**Step 8.3 — Failure mode**
- Record: Author did not specify. For Realtek PC codecs, TV mode typically means **wrong jack detect / headset routing / analog misbehavior**, not an oops. Severity **MEDIUM** as described, **HIGH** if it silences the jack on real VB laptops. Exact user symptom is **not independently verified**.
**Step 8.4 — Benefit vs risk**
- Record: Benefit: hardware init correction from the vendor, 2 lines, same class as HDA/USB quirks that stable takes. Risk: very low (one init write, no locking/API change). Ratio favors backport.
## Phase 9: Synthesis
**Evidence FOR**
- Two-line vendor codec workaround; hardware-quirk exception in the stable rules
- Target function and surrounding init sequence exist in 6.12
- Applies with offset only
- ASoC maintainer applied it; it went in **sound fixes for 7.3-rc1**
- RT712 is used on current Intel SoundWire laptops; this tree already took a related headphone-init fix
- Driver defaults to JD1; pulling unused JD2 high is consistent with PC/laptop use
**Evidence AGAINST**
- Commit text is vague (“may cause unexpected issues”); no reporter, no machine, no crash
- Not a UAF/deadlock/corruption class bug
- Magic coef with no bit documentation
- VB-only (VA machines, e.g. some Lunar Lake ThinkPads, are unaffected)
**Unresolved**
- Exact user-visible TV-mode symptom (UNVERIFIED)
- Whether stable@ already discussed this SHA (lore HTTP 403)
**Stable rules checklist**
1. Obviously correct and tested? **PASS** — one existing helper write; vendor + Mark Brown; no NAK
2. Real bug affecting users? **PASS** — missing hardware init that lets the codec enter the wrong analog mode (vendor statement; typical jack/headset breakage, not proven with a public report)
3. Important? **PASS** under the **audio codec quirk** exception (headphone/JD misconfig), not as a panic/CVE
4. Small and contained? **PASS** — +2 lines, one driver
5. No new features/APIs? **PASS** — existing init path, existing write helper
6. Can apply to this tree? **PASS** — context matches; JD_CTL3 unused
**Exception category:** Hardware workaround / audio codec quirk (JD pin config), analogous to HDA Realtek coef/pin quirks.
This is a contained vendor register quirk for hardware that 6.12 already supports. Benefit is correct analog/jack behavior on RT712 VB; risk is a single init write. It should be backported to this tree.
Verification:
- [Phase 1] Parsed subject/tags/body from the provided message and GitHub dfb8bc1d286fd97b7cf47e3af5df84cfb068d214
- [Phase 2] Diff is +1 write in rt712_sdca_vb_io_init and +1 #define RT712_JD_CTL3 0x0b
- [Phase 3] git blame on this tree: insertion point from 936abb09c1c7c (2024-06-20); git merge-base --is-ancestor 936abb09c1c7c HEAD true
- [Phase 3] git merge-base --is-ancestor dfb8bc1d286fd97b7cf47e3af5df84cfb068d214 HEAD false (not in 6.12)
- [Phase 3] git log --oneline -20 -- sound/soc/codecs/rt712-sdca.c:
related 8ad30bd5c1088 is a different VA reset fix
- [Phase 4] b4 dig -c dfb8bc1d… / -a / -w / -m: v1, alsa-devel, applied by Mark Brown to for-7.3; no NAK
- [Phase 4] LKML: Takashi listed this under 7.3-rc1 sound fixes
- [Phase 4] lore.kernel.org WebFetch/curl: 403
- [Phase 5] Callers: rt712_sdca_update_status → rt712_sdca_io_init → rt712_sdca_vb_io_init; intel ACPI match files reference rt712
- [Phase 6] git describe HEAD / make kernelversion: 6.12.111; hunk context present; RT712_JD_CTL3 absent
- [Phase 8] Failure mode: TV-mode analog/JD misbehavior (vendor); not a kernel oops — UNVERIFIED exact symptom
- UNVERIFIED: datasheet meaning of 0x7778; whether every VB board needs it; stable@ discussion
**YES**
sound/soc/codecs/rt712-sdca.c | 1 + sound/soc/codecs/rt712-sdca.h | 1 + 2 files changed, 2 insertions(+)
sound/soc/codecs/rt712-sdca.c +1 -0
@@ -1786,6 +1786,7 @@ static void rt712_sdca_vb_io_init(struct rt712_sdca_priv *rt712)dev_dbg (dev,"%s jack/mic/amp func_status=0x%x, 0x%x, 0x%x\n" , __func__, jack_func_status, mic_func_status, amp_func_status); +rt712_sdca_index_write (rt712,RT712_VENDOR_REG ,RT712_JD_CTL3 ,0x7778 );/* DMIC */ if ((mic_func_status &FUNCTION_NEEDS_INITIALIZATION ) || (!rt712->first_hw_init)) {rt712_sdca_index_write (rt712,RT712_VENDOR_HDA_CTL ,RT712_DMIC2_FU_IT_FLOAT_CTL ,0x1526 );
sound/soc/codecs/rt712-sdca.h +1 -0
@@ -74,6 +74,7 @@ struct rt712_dmic_kctrl_priv {#define RT712_JD_PRODUCT_NUM 0x00#define RT712_ANALOG_BIAS_CTL3 0x04#define RT712_JD_CTL1 0x09 +#define RT712_JD_CTL3 0x0b#define RT712_IO_CTL 0x0c#define RT712_LDO2_3_CTL1 0x0e#define RT712_PARA_VERB_CTL 0x1a
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 uio: sercos3: add missing MODULE_DEVICE_TABLE()
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit a432f68c51fc6761658445e80a798b8425fdb3dc ]
The driver has a match table for the pci bus wired into its driver structure, but the table is not exported with MODULE_DEVICE_TABLE().
Add the missing MODULE_DEVICE_TABLE() entry so module alias information is generated for automatic module loading.
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 driver registration structure, and the missing module alias publication.
---
LLM Generated explanations, may be completely bogus:
Local tree is **v7.3-rc4** (mainline). The change is a one-line MODULE_DEVICE_TABLE() so PCI aliases are generated; that is a real autoload bug with no runtime risk.
## Phase 1: Commit message forensics
**Step 1.1: Subject**
Record: **[uio/sercos3] [add] [export the existing PCI ID table with MODULE_DEVICE_TABLE()]**
**Step 1.2: Tags**
Record:
- Signed-off-by: Pengpeng Hou <[email protected]> (author)
- `Link:
https://patch.msgid.link/[email protected]`
- Signed-off-by: Greg Kroah-Hartman <[email protected]> (UIO/char-misc maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, or Cc: stable (absence of the last two is expected for this review)
**Step 1.3: Body**
Record:
- **Bug:** sercos3_pci_ids is wired into sercos3_pci_driver.id_table but not published with MODULE_DEVICE_TABLE().
- **Symptom:** depmod/modpost emit no PCI aliases, so udev/kmod will not autoload uio_sercos3 when a matching card appears.
- **Version info:** none in the message. The ID table has been in the driver since 2008.
- **Root cause:** missing module-alias publication, not a wrong match table.
**Step 1.4: Hidden bug fix?**
Record: **No disguise.** It is an explicit metadata-export fix. The “source-level / no hardware reproduction” sentence is honesty about evidence, not a cleanup-only change. Without the macro, modular autoload is broken.
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- File: drivers/uio/uio_sercos3.c — **+1 / −0**
- Function/data: sercos3_pci_ids (static PCI ID table), immediately before sercos3_pci_driver
- Scope: **single-file surgical fix**
**Step 2.2: Code flow**
Record:
- **Before:** table exists and is used at runtime by PCI core *after* the module is already loaded (or if built-in).
- **After:** same runtime matching, plus MODULE_DEVICE_TABLE(pci, sercos3_pci_ids) so modpost/file2alias.c emits pci:v...d...sv...sd... aliases into the module.
- Path affected: **build-time module metadata / userspace autoload**, not probe/remove/IRQ.
**Step 2.3: Bug mechanism**
Record: **Hardware enablement / missing device-table export** (same family as adding PCI IDs).
- Mechanism: scripts/mod/file2alias.c do_pci_entry() only walks tables found via MODULE_DEVICE_TABLE(). No macro → no aliases → no autoload.
- Runtime id_table is unchanged, so probe matching is not altered.
**Step 2.4: Fix quality**
Record: **Obviously correct, one line, no unrelated edits.** Regression risk is **very low**: aliases match the same vendor/device/subvendor/subdevice entries the driver already uses. No locking, no API, no data-structure change.
## Phase 3: Git history
**Step 3.1: Blame**
Record: ID table and pci_driver come from **a6030fcc608bd** (“UIO:
add automata sercos3 pci card support”, John Ogness, 2008-09-18). That commit never added MODULE_DEVICE_TABLE(). The table was later made const in 511d7a35a438d (2025). The missing export has been present for the entire life of the driver.
**Step 3.2: Fixes: tag**
Record: **None.** Introduced by a6030fcc608bd (verified: parent of this fix has no MODULE_DEVICE_TABLE in this file). git grep on a432f68c51fc6^ -- drivers/uio/uio_sercos3.c returned no match.
**Step 3.3: File history**
Record: Recent commits on this file are constify, devm allocs, SPDX, module_pci_driver. **No prerequisite series.** Standalone one-liner.
Same class of UIO fix already exists historically: **912335c43bb10** (“UIO: fix specific device driver missing statement for depmod”, 2009) added MODULE_DEVICE_TABLE to uio_cif.c for the same depmod/alias reason.
**Step 3.4: Author**
Record: Pengpeng Hou is not the UIO maintainer. Same author has a batch of “add missing MODULE_DEVICE_TABLE()” patches (rtc, vdpa, watchdog, fbdev, soc, can, clk, power). Pattern is systematic and consistent. Maintainer of record is Greg Kroah-Hartman, who applied it.
**Step 3.5: Dependencies**
Record: **None.** Uses the long-standing MODULE_DEVICE_TABLE() macro in include/linux/module.h. Can apply standalone.
## Phase 4: Mailing list / external
**Step 4.1: Original discussion**
Record:
- b4 dig -c a432f68c51fc6 →
https://patch.msgid.link/[email protected]
- Openwall copy: https://lists.openwall.net/linux-kernel/2026/07/04/476
- b4 dig -a: **v1 only**, 2026-07-04. Applied version is that v1.
- No reviewer comments, NAKs, or Cc: stable suggestions found in the retrieved thread.
**Step 4.2: Recipients (b4 dig -w)**
Record: Pengpeng Hou, **Greg Kroah-Hartman**, linux- [email protected]. Correct maintainer was To:’d.
**Step 4.3: Bug report**
Record: **No user/syzbot/bugzilla report.** Author states source-level evidence only.
**Step 4.4: Series**
Record: **Standalone**, not N/M.
**Step 4.5: Stable list**
Record: **UNVERIFIED.** lore.kernel.org/stable and git.kernel.org fetches returned 403 (Anubis). Openwall search found the lkml submission only, not a stable-thread discussion.
## Phase 5: Semantic / impact
**Step 5.1: Functions**
Record: No function body changed. Data: sercos3_pci_ids; consumer:sercos3_pci_driver.
**Step 5.2: Callers**
Record:
- Runtime: PCI core uses .id_table from module_pci_driver(sercos3_pci_driver) → sercos3_pci_probe on match.
- Autoload: udev/kmod uses aliases generated from MODULE_DEVICE_TABLE.
- Not IRQ/hot path; module-load / device-enumeration path.
**Step 5.3: Callees**
Record: The new line expands to an alias symbol for modpost. No new runtime calls.
**Step 5.4: Reachability**
Record: **Yes, from userspace + hardware.** Trigger is a matching PLX 9030 + Sercos subsystem ID (0x1971 / 0x3530, 0x3535, 0x3780) with CONFIG_UIO_SERCOS3=m. Built-in (=y) never needed aliases.
**Step 5.5: Similar patterns**
Record: Sibling UIO PCI drivers already export tables: uio_cif.c, uio_netx.c, uio_mf624.c, uio_aec.c. uio_sercos3 was the outlier. OF/vmbus/dfl UIO drivers also use MODULE_DEVICE_TABLE.
## Phase 6: This checkout
**Step 6.1: Does the buggy code exist here?**
Record:
- Tree: **v7.3-rc4-27-gf0100363d8c37**, VERSION=7 PATCHLEVEL=3 SUBLEVEL=0 EXTRAVERSION=-rc4, origin torvalds/linux.git.
- File and PCI ID table exist (drivers/uio/uio_sercos3.c).
- At **HEAD**, MODULE_DEVICE_TABLE(pci, sercos3_pci_ids) is already at line 215 (git merge-base --is-ancestor a432f68c51fc6 HEAD succeeded). That is expected: this checkout is mainline after 7.3-rc1, i.e. the **source** of stable candidates, not a missing-driver stable branch.
- Bug introduced: **2008** (a6030fcc608bd). Not a post-branch feature.
**Step 6.2: Backport difficulty**
Record: **Clean apply.** Surrounding table/pci_driver layout matches the hunk. No refactor blocking a one-line insert.
**Step 6.3: Related fixes already here**
Record: This is the fix. No alternate alias-export for this driver. Historical analogue is uio_cif’s 2009 MODULE_DEVICE_TABLE addition.
## Phase 7: Subsystem
**Step 7.1:**
Record: **UIO PCI driver** (drivers/uio/). Criticality: **PERIPHERAL** — Automata Sercos III industrial card, CONFIG_UIO_SERCOS3 tristate, default n, depends on PCI.
**Step 7.2:**
Record: **Mature / low churn.** Driver added 2008; later commits are cleanup (module_pci_driver, SPDX, devm, constify). Not a new subsystem.
## Phase 8: Impact and risk
**Step 8.1: Who is affected**
Record: **Driver-specific / config-specific:** CONFIG_UIO_SERCOS3=m and a matching PCI card. Built-in and systems without the card are unaffected.
**Step 8.2: Trigger**
Record: PCI enumeration + udev module lookup. Common on modular distro kernels **if the hardware is present**. Unprivileged users cannot trigger it without the card. Not a race.
**Step 8.3: Failure mode**
Record: Module not autoloaded; card stays unbound until modprobe uio_sercos3. **Severity: MEDIUM** (real functional break, not oops/corruption/security). Workaround exists but is not how PCI drivers are supposed to load.
**Step 8.4: Risk-benefit**
Record:
- **Benefit:** restores autoload for existing IDs (same user-visible outcome as a device-ID addition).
- **Risk:** very low (one metadata line, no runtime change).
- **Ratio:** favorable.
## Phase 9: Synthesis
**Step 9.1: Evidence**
For:
- Real autoload bug: ID table registered, aliases never published.
- Same class as the stable “add a device ID” exception; IDs already exist, they were just invisible to kmod.
- One line, obviously correct, no API/feature.
- Sibling UIO PCI drivers already do this; uio_cif got the same depmod fix in 2009.
- Greg Kroah-Hartman applied v1 unchanged.
- Driver present since 2008; no missing prerequisites on this tree.
Against:
- Niche hardware; no Reported-by in ~18 years.
- Not a crash, deadlock, or security issue.
- Author did not reproduce on hardware (stated).
- Manual modprobe still works.
Unresolved:
- Stable mailing-list discussion (lore 403).
**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** — one-line, standard macro; Greg applied it. Hardware repro not required for alias generation.
2. Real bug affecting users? **PASS** — modular autoload fails for matching PCI devices.
3. Important? **PASS** (device-ID / hardware-enablement class) — not a panic, but it is the userspace half of PCI ID support; stable rules explicitly allow device-ID additions.
4. Small and contained? **PASS** — +1 line, one file.
5. No new features/APIs? **PASS** — publishes existing IDs.
6. Can apply to this tree? **PASS** — driver and table are here; hunk matches.
**Step 9.3: Exception**
Record: **Device ID / hardware-enablement.** Closest documented
exception: “just add a device ID.” This exports IDs the driver already matches.
**Step 9.4: Decision**
This tree has the driver and the ID table; the omission is a real modular-load bug, the patch is a one-line metadata export with no runtime risk, and it matches how other UIO PCI drivers (and stable’s device-ID exception) already work. It should be selected for stable.
---
**What it solves for stable users:** With CONFIG_UIO_SERCOS3=m, a Sercos III PLX 9030 card will not cause udev to load uio_sercos3 because modules.alias has no PCI entries. The line adds those aliases. Distro/LTS kernels typically ship such drivers as modules.
**Rules:** Small, correct, no new API; equivalent to enabling existing device IDs for autoload.
**Risk vs benefit:** Benefit is autoload on real hardware; risk is essentially zero.
**Concerns:** Niche card and no crash report, but that does not outweigh a zero-risk hardware-enablement one-liner that applies cleanly.
Verification:
- [Phase 1] Parsed tags: author SOB, Greg KH SOB, lore msgid Link; no Fixes/Reported-by/Cc: stable
- [Phase 2] Diff: +1 MODULE_DEVICE_TABLE(pci, sercos3_pci_ids) after sercos3_pci_ids[] in drivers/uio/uio_sercos3.c
- [Phase 2] Confirmed sercos3_pci_driver.id_table = sercos3_pci_ids and module_pci_driver(sercos3_pci_driver)
- [Phase 3] git blame: table from a6030fcc608bd (2008); this line from a432f68c51fc6
- [Phase 3] git grep on parent: no MODULE_DEVICE_TABLE in this file; HEAD has it at line 215
- [Phase 3] Historical analogue: 912335c43bb10 added the same macro to uio_cif.c for depmod
- [Phase 4] b4 dig -c a432f68c51fc6: lore/msgid match; -a: v1 only; -w: Greg KH + lkml
- [Phase 4] Openwall thread matches committed patch; no NAK found
- [Phase 4] lore.kernel.org WebFetch: 403 — stable-list discussion UNVERIFIED
- [Phase 5] MODULE_DEVICE_TABLE in include/linux/module.h; do_pci_entry() in scripts/mod/file2alias.c
- [Phase 5] Sibling UIO PCI drivers already have MODULE_DEVICE_TABLE
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- [Phase 6] git merge-base --is-ancestor a432f68c51fc6 HEAD exit 0 (commit is in this mainline checkout)
- [Phase 6] Commit not in v7.2; is in v7.3-rc1
- [Phase 7] CONFIG_UIO_SERCOS3 tristate, depends on PCI, module name uio_sercos3
- [Phase 8] Failure mode: no PCI aliases → no autoload; severity MEDIUM; risk very low
- UNVERIFIED: whether this hash was already applied on some older stable branch (not this checkout; not used for the verdict)
**YES**
drivers/uio/uio_sercos3.c | 1 + 1 file changed, 1 insertion(+)
drivers/uio/uio_sercos3.c +1 -0
@@ -212,6 +212,7 @@ static const struct pci_device_id sercos3_pci_ids[] = { }, { 0, } }; +MODULE_DEVICE_TABLE (pci, sercos3_pci_ids);static struct pci_driver sercos3_pci_driver = { .name ="sercos3" ,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 media: em28xx: requeue buffers if start_streaming fails
In reply to Sasha LevinFrom: Hans Verkuil <[email protected]>
[ Upstream commit 67f87b104f4ef3108607ac9d8fa2075b13ed314d ]
If start_streaming fails, then all queued buffers must be returned to vb2 in state QUEUED.
Otherwise it will trigger a WARN_ON.
---
LLM Generated explanations, may be completely bogus:
The local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The candidate is a real videobuf2 start_streaming error-path bug in em28xx: queued buffers were left driver-owned, which fires WARN_ON and can leave stale entries on dmaq->active.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[media/em28xx] [requeue] [return queued vb2 buffers when start_streaming fails]**
Subsystem media: em28xx. Action is “requeue” (correctness on failure, not a feature).
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- **Fixes:** none (expected for this review)
- **Reported-by:** none
- **Tested-by:** Hans Verkuil \<[email protected]\> (author tested it)
- **Reviewed-by / Acked-by:** none on the commit
- **Link:** none in the commit; lore found via b4 dig (Phase 4)
- **Cc: stable:** none (expected)
- **Signed-off-by:** Hans Verkuil (author); Mauro Carvalho Chehab (media maintainer). Ignore any Sasha Levin SOB if present — none on this commit.
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** If start_streaming fails, buffers already given to the driver via buf_queue are not returned to vb2 as VB2_BUF_STATE_QUEUED.
- **Symptom:** vb2 WARN_ON in vb2_start_streaming() when owned_by_drv_count != 0.
- **Version info:** none in the message.
- **Root cause (author):** driver violates the documented start_streaming contract.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: **Not hidden.** Explicit contract fix. Cover letter (Phase 4) also states this patch “correctly gives the vb2 buffers back … if start_streaming fails.”
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/media/usb/em28xx/em28xx-video.c — **+16 / −2**
- Function: em28xx_start_analog_streaming()
- Scope: **single-file surgical error-path fix**
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- **Before:** res_get() failure and em28xx_init_usb_xfer() failure both return rc immediately. Buffers already on vidq/vbiq active stay driver-owned.
- **After:** those paths goto exit, which under dev->slock walks dmaq->active, list_dels each buffer, and calls vb2_buffer_done(..., VB2_BUF_STATE_QUEUED). Success still increments streaming_users and returns 0.
- **Path affected:** STREAMON / qbuf-triggered start_streaming **error** path only.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record: **[Logic / vb2 contract] + memory-safety follow-on**
- vb2 calls __enqueue_in_driver() → buf_queue **before** start_streaming (videobuf2-core.c).
- buffer_queue / vbi_buffer_queue put buffers on dev->vidq.active / dev->vbiq.active.
- On failure the driver must vb2_buffer_done(..., QUEUED) (documented in videobuf2-core.h @start_streaming).
- Without that, vb2_start_streaming() does WARN_ON(owned_by_drv_count) and force-reclaims in vb2 **without** unlinking the driver’s list, so dmaq->active can keep dangling em28xx_buffer pointers. get_next_buf() later takes dma_q->active.next — **UAF** on a later successful stream.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- **Quality:** Matches em28xx_stop_streaming() and the standard V4L2 pattern. Author is V4L2 maintainer; self-tested.
- **Minimal:** only the failure cleanup.
- **Regression risk:** low (error path, same lock as stop). Minor
incompleteness: stop_streaming also completes usb_ctl.vid_buf; this path does not. em28xx_alloc_urbs() already NULLs those pointers before submit, and failed init_usb_xfer calls em28xx_uninit_usb_xfer(). Common failures (res_get -EBUSY, alloc/submit fail with empty in-flight slot) are covered. Incomplete vs. a rare in-flight URB does not make the patch wrong.
- **No API/feature changes.**
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- em28xx_start_analog_streaming comes from **d3829fadc461** (“\[media\] em28xx: convert to videobuf2”, 2013-01-05), contained in **v3.9-rc1**.
- Failure just return rc is that old. Bug is long-standing, not new-7.3 code.
Step 3.2: FOLLOW THE FIXES: TAG
Record: **No Fixes: tag.** Closest related error-path change:
**cc20e81da6d99** (“fix missing res_free() on init_usb_xfer failure”, 2026-05) added res_free() before return rc. This commit turns that return into goto exit. Complementary, not a substitute.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- Same series (lifecycle): 288254383674b, de626073dfcbb, 7c8bf63b79371, c132b07f7e585 — device lifetime/UAF, **not required** for this hunk.
- This is **standalone**: only the start_streaming returns change. Cover letter lists it as 6/6, but the diff does not use symbols those patches add.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Hans Verkuil is a V4L2 maintainer (not the em28xx MAINTAINERS entry; that is Mauro Chehab, who signed this off). Same class of fix
historically: e.g. **80b0963e1698e** “\[media\] pwc: fix WARN_ON” (QUEUED vs ERROR on start_streaming failure).
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: **No hard functional dependency.** Applies against the pre-fix function in this tree’s parent. Older stables without cc20e81 only need a trivial context adjust (return rc vs res_free+return rc). **Standalone.**
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 67f87b104f4ef: **[PATCHv2 6/6]** https://patch.msgid.link/
141d43a4860c6007269e9725cc717a556d22d2a4.1781615432.git.hverkuil+cisco @kernel.org
- b4 dig -a: v1 was a 3-patch lifecycle series (2026-05-19); v2 is **[PATCHv2 0/6] media: em28xx: fix lifecycle issues** (2026-06-16). Applied version is v2 patch 6.
- Cover letter: last patch returns buffers if start_streaming fails; **tested on author’s em28xx device**.
- **No NAK** on patch 6. Sakari Ailus only discussed patch 1 (v4l2-async).
- **No reviewer Cc: stable.** WebFetch to lore returned **403**; thread recovered via b4 dig -m.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To/Cc **linux-media**, Hans Verkuil, Mauricio Faria de Oliveira, Sakari Ailus. Merged by Mauro Chehab. No separate Reviewed-by on 6/6.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla. Author found it while testing the lifecycle series. Mechanism is specified in vb2 (WARN_ON comment names this exact driver bug class).
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Series 1–5 are separate lifecycle/UAF work. **6/6 is self- contained** and does not need 1–5 in this tree.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: No “stable” in the matched mbox. WebSearch did not find a stable-list thread for this subject (lore HTML 403). **No evidence it was rejected for stable.**
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: **em28xx_start_analog_streaming**. Helpers used: res_get, res_free, em28xx_init_usb_xfer, vb2_buffer_done.
Step 5.2: TRACE CALLERS
Record: Wired as .start_streaming in:
- em28xx_video_qops (em28xx-video.c)
- em28xx_vbi_qops (em28xx-vbi.c)
Callers are vb2 (vb2_start_streaming ← vb2_core_streamon / vb2_core_qbuf). **Userspace V4L2 STREAMON/QBUF.**
Step 5.3: TRACE CALLEES
Record: res_get can return **-EBUSY**. em28xx_init_usb_xfer can fail on URB alloc, usb_clear_halt, or usb_submit_urb (and then em28xx_uninit_usb_xfer). Those are realistic (disconnect, ENOMEM, USB error).
Step 5.4: FOLLOW THE CALL CHAIN
Record: Userspace ioctl → vb2 enqueues via buf_queue → start_streaming → on failure, buffers must be returned. **Reachable from userspace** with CONFIG_VIDEO_EM28XX / CONFIG_VIDEO_EM28XX_V4L2 and a device node.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Many drivers return VB2_BUF_STATE_QUEUED on start_streaming failure (uvc, pwc, gspca, hackrf, platform capture drivers). em28xx was missing that. Historical media commits: pwc, coda, cal, am437x-vpfe.
semcode MCP: **not available** in this session (only cursor dynamic tools). Used grep/read instead.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: **Yes.** This checkout is **7.3.0-rc4**. Commit **67f87b104f4ef** **is an ancestor of HEAD** (in since v7.3-rc1). Parent of the commit still has the bare return rc paths. Driver and em28xx_start_analog_streaming have been here since the vb2 conversion (**v3.9**). The bug is not “new after this branch.”
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: For **this** tree the patch is already applied and matches current em28xx-video.c. Against the pre-fix function it is a clean, 18-line change. No conflicting refactor in the start_streaming body itself.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: cc20e81da6d99 (res_free on USB-init failure) is in this tree. It does **not** requeue buffers. No other equivalent fix for this WARN_ON.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: **drivers/media/usb/em28xx** — USB analog/VBI capture (Empia, Hauppauge, etc.). **IMPORTANT** for users of that hardware, **PERIPHERAL** vs core mm/net. Not staging.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Actively maintained (lifecycle series, device IDs, UAFs in 2026). Mature driver, old bug. MAINTAINERS: Mauro Chehab; linux-media.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: **Driver-specific** (CONFIG_VIDEO_EM28XX / V4L2). Empia USB capture sticks and several Hauppauge devices. Not universal, but real hardware.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record:
- Trigger: VIDIOC_STREAMON (or qbuf that starts streaming) when res_get fails or USB xfer init fails.
- Commonness: error path, not every boot. USB submit/alloc failure and unplug-during-start are realistic.
- Unprivileged: yes if the user can open /dev/video* (typical video group).
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- Immediate: **WARN_ON** in vb2 (videobuf2-core.c around the “driver isn’t cleaning up properly after a failed start_streaming()” comment). panic_on_warn → panic.
- Follow-on: leftover dmaq->active entries after vb2 force-reclaim → **UAF** in get_next_buf() on retry.
- **Severity: HIGH** (WARN_ON + UAF on retry). Not a silent style issue.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit:** high for em28xx users (stops WARN_ON and dangling DMA list).
- **Risk:** very low (~16 lines, error path, same locking as stop).
- **Ratio:** favorable.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
**FOR:**
- Real vb2 contract violation; documented WARN_ON.
- Dangling active list can UAF on the next STREAMON.
- Small, obviously correct, matches driver stop path and many other V4L2 drivers.
- V4L2 maintainer authored and tested on real em28xx hardware; media maintainer merged it.
- Bug in code since ~v3.9; present in this tree’s pre-fix function.
- Standalone; no new API.
**AGAINST:**
- USB capture driver, not core; only hits failed STREAMON.
- No syzbot / external Reported-by.
- Patch 6/6 of a larger series (but this hunk does not depend on 1–5).
- Does not also complete usb_ctl.vid_buf (stop_streaming does); common fail paths still fixed.
**UNRESOLVED:**
- lore.kernel.org HTTP 403 for WebFetch; thread read via b4 mbox instead.
- No stable@ discussion found.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — contract match + Tested-by author on hardware.
2. Fixes a real bug that affects users? **PASS** — STREAMON failure on a used USB capture driver.
3. Important issue? **PASS** — WARN_ON; UAF on retry. HIGH, not cosmetic.
4. Small and contained? **PASS** — 16 insertions / 2 deletions, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — code is this driver; patch already applies here (it is in 7.3-rc1+). No missing prerequisites for *this* hunk.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: **None** (not an ID/quirk/DT/build/docs exception). It is a normal small bugfix.
Step 9.4: MAKE YOUR DECISION
This tree has the em28xx analog/VBI vb2 path. The fix is a classic, surgical start_streaming cleanup that prevents WARN_ON and leftover driver-owned buffers. It meets stable rules for this checkout.
What it solves for users of this tree: failed VIDIOC_STREAMON no longer trips vb2’s WARN_ON and no longer leaves capture buffers on dmaq->active for a later UAF.
Risk vs benefit: error-path only, low regression risk, meaningful correctness fix.
Concerns: none that block a backport here; series membership is packaging, not a code dependency.
Verification:
- \[Phase 1\] Parsed tags: Tested-by Hans Verkuil; SOB Hans + Mauro; no Fixes/Reported-by/Cc stable
- \[Phase 2\] Diff: +16/-2 in em28xx_start_analog_streaming; return rc → goto exit + vb2_buffer_done(QUEUED)
- \[Phase 2\] Confirmed vb2 contract and WARN_ON in vb2_start_streaming() (videobuf2-core.c ~1769–1815)
- \[Phase 2\] Confirmed buf_queue adds to vidq/vbiq active before start_streaming
- \[Phase 2\] Confirmed get_next_buf() uses dma_q->active.next (UAF if list not cleared)
- \[Phase 3\] git blame: function from d3829fadc461 (v3.9-rc1)
- \[Phase 3\] git merge-base --is-ancestor 67f87b104f4ef HEAD → yes (exit 0)
- \[Phase 3\] git describe HEAD → v7.3-rc4-27-gf0100363d8c37; make kernelversion → 7.3.0-rc4
- \[Phase 3\] Related: cc20e81da6d99 only adds res_free; does not requeue
- \[Phase 4\] b4 dig -c 67f87b104f4ef: PATCHv2 6/6; cover letter describes this exact fix; tested on em28xx
- \[Phase 4\] b4 dig -a: v1 3-patch → v2 6-patch lifecycle series; 6/6 standalone
- \[Phase 4\] b4 dig -w: linux-media, Sakari Ailus, Mauricio Faria de Oliveira
- \[Phase 4\] WebFetch lore/msgid.link: 403; used mbox instead
- \[Phase 5\] Callers: em28xx_video_qops and em28xx_vbi_qops .start_streaming
- \[Phase 5\] Failures: res_get -EBUSY; em28xx_init_usb_xfer alloc/halt/submit
- \[Phase 6\] Pre-fix parent still has bare return rc; this tree includes the fix
- \[Phase 7\] MAINTAINERS: EM28XX VIDEO4LINUX DRIVER, Mauro Chehab
- \[Phase 8\] Failure: WARN_ON + dangling list UAF; severity HIGH
- UNVERIFIED: stable@ mailing list (lore HTTP 403; no hit in matched mbox)
The patch is small, correct, and fixes a real WARN_ON/UAF class bug in code this tree carries.
**YES**
drivers/media/usb/em28xx/em28xx-video.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/media/usb/em28xx/em28xx-video.c +16 -2
@@ -1070,6 +1070,9 @@ int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count) {struct em28xx *dev =vb2_get_drv_priv (vq);struct em28xx_v4l2 *v4l2 = dev->v4l2; +struct em28xx_dmaqueue *dmaq = vq->type ==V4L2_BUF_TYPE_VBI_CAPTURE ? + &dev->vbiq : &dev->vidq; +unsigned long flags =0 ;struct v4l2_frequency f;struct v4l2_fh *owner;int rc =0 ;
@@ -1084,7 +1087,7 @@ int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count)*/ rc =res_get (dev, vq->type);if (rc) -return rc; + goto exit;if (v4l2->streaming_users ==0 ) {/* First active streaming user, so allocate all the URBs */
@@ -1107,7 +1110,7 @@ int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count) em28xx_urb_data_copy);if (rc <0 ) {res_free (dev, vq->type); -return rc; + goto exit; }/*
@@ -1132,7 +1135,18 @@ int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count) } v4l2->streaming_users++; +return 0 ; +exit: +spin_lock_irqsave (&dev->slock, flags); +while (!list_empty (&dmaq->active)) { +struct em28xx_buffer *buf; + + buf = list_entry(dmaq->active.next, struct em28xx_buffer, list); +list_del (&buf->list); +vb2_buffer_done (&buf->vb.vb2_buf,VB2_BUF_STATE_QUEUED ); + } +spin_unlock_irqrestore (&dev->slock, flags);return rc; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ksmbd: handle allocated range queries on dense files
In reply to Sasha LevinFrom: Namjae Jeon <[email protected]>
[ Upstream commit 350684e0498512d06963858b810101f58563810b ]
FSCTL_QUERY_ALLOCATED_RANGES currently relies on SEEK_DATA and SEEK_HOLE for every file. That works for files with holes, but it is not a good match for dense files.
A zeroed range in a dense file may be represented as an unwritten extent and skipped by SEEK_DATA. The server can then return no allocated ranges even though the file should still be treated as allocated from the protocol point of view.
For dense files, report the requested range clipped to EOF as allocated instead of probing holes. Keep using SEEK_DATA and SEEK_HOLE for files marked with FILE_ATTRIBUTE_SPARSE_FILE, and wait for writeback before probing so punch-hole updates are visible to the filesystem seek implementation.
This fixes the case where a query after zeroing data could return no ranges for a dense file.
---
LLM Generated explanations, may be completely bogus:
Connection lost, reconnecting to https://agentn.us.api5.cursor.sh
(attempt 1)...
Retry attempt 1...
Local tree is **6.12.111** (pending-6.12). The buggy ksmbd_vfs_fqar_lseek() path is in this checkout; the candidate is not.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[ksmbd] [handle] FSCTL_QUERY_ALLOCATED_RANGES on dense (non- sparse) files should not use SEEK_DATA/SEEK_HOLE**
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Namjae Jeon \<[email protected]\> (ksmbd maintainer)
- No Fixes, Reported-by, Tested-by, Reviewed-by, Acked-by, Link, or Cc:
stable
- Ignore pipeline markers (none in the provided message besides the evaluation copy)
- Notable: maintainer-authored; no syzbot/CVE tags
Upstream SHA recovered from GitHub:350684e0498512d06963858b810101f58563810b (Namjae Jeon, 2026-07-11; +26/-3 in fs/smb/server/vfs.c). Merged via ksmbd-for-7.3-rc1.
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** FSCTL_QUERY_ALLOCATED_RANGES always uses SEEK_DATA/SEEK_HOLE. After FSCTL_SET_ZERO_DATA on a dense file, ksmbd uses FALLOC_FL_ZERO_RANGE, which can leave unwritten extents. SEEK_DATA skips those, so the server can return **no allocated ranges**.
- **Symptom:** Protocol-incorrect empty range list after zeroing a dense file. Copy/backup clients that copy only allocated ranges can skip the zeroed region and leave **stale data** on the destination.
- **Root cause:** Linux SEEK_DATA treats unwritten extents as holes; SMB dense files must still be reported as allocated (MS-FSA).
- **Fix:** For non-sparse files, return the request clipped to EOF as one allocated range. For sparse files, keep SEEK_DATA/SEEK_HOLE and file_write_and_wait_range() first so punch-hole is visible.
- **Versions:** No version listed. Code has been in tree since cifsd file ops (2021).
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. Subject “handle” plus body “This fixes the case where a query after zeroing data could return no ranges” is an explicit protocol/correctness fix. Extra i_size clipping (start >= size, !length, i_size_read) is a real underflow/EOF-handling improvement in the same function.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: fs/smb/server/vfs.c only (+26/-3; GitHub)
- Function: ksmbd_vfs_fqar_lseek()
- Scope: single-function surgical change
- ksmbd_vfs_zero_data() is **not** modified (only described as context in the message)
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- **EOF clip (before):** if (start + length > inode->i_size) length = inode->i_size - start using unlocked inode->i_size. If start > i_size, length goes negative; the loop then does not run.
- **EOF clip (after):** size = i_size_read(inode); return 0 if `start
Quoted 1 line
= size
or!length; then cliplengthtosize - start`.
- **Dense path (before):** always SEEK_DATA/SEEK_HOLE.
- **Dense path (after):** if !(m_fattr & FILE_ATTRIBUTE_SPARSE_FILE_LE), write one FILE_ALLOCATED_RANGE_BUFFER for [query_start, query_length] and return.
- **Sparse path (after):** file_write_and_wait_range(f, start, end-1) then the existing SEEK loop.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- **Category:** logic/protocol correctness (allocated-range under- reporting), plus sparse writeback visibility
- **Mechanism:** iomap_seek_data() treats IOMAP_UNWRITTEN as a hole unless pagecache has data (fs/iomap/seek.c). FALLOC_FL_ZERO_RANGE on dense files creates unwritten extents → SEEK_DATA returns -ENXIO → empty SMB range list.
- MS-FSA (FSCTL_QUERY_ALLOCATED_RANGES): if Open.Stream.IsSparse is FALSE, return a single range of the requested offset/length. Win32:
non-sparse files return one entry covering the request.
- Sparse writeback: after punch-hole, seek can see stale extents until writeback.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Dense shortcut matches MS-FSA and is easy to verify.
- in_count is already rejected as 0 before ranges[0] is written.
- file_write_and_wait_range() exists in this tree (include/linux/fs.h) and vfs.c already includes linux/fs.h.
- **Regression risk:** non-sparse files that still have Linux holes (write-beyond-EOF, sparse attr cleared without materializing) will be reported as fully allocated. That matches Windows QUERY semantics; reads still return zeros. Bandwidth can increase for holey non-sparse files. Later mainline commit 25e414db7033 removed this shortcut for CIFS FIEMAP (see Phase 3).
- No new API, no lock-order change, no data-structure change.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- SEEK_DATA/SEEK_HOLE loop: f44158485826c0 (“cifsd: add file operations”, 2021-03-16; in tree 2021-05-10). Present since ksmbd was merged.
- vfs_llseek(..., SEEK_DATA/SEEK_HOLE): 067baa9a37b32b (2022).
- Dense vs sparse zeroing: original f44158485826c0 already used PUNCH_HOLE for sparse and ZERO_RANGE for dense. 18e39fb960e6a added FALLOC_FL_KEEP_SIZE.
- Bug is old, not post-6.12.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Buggy code is the original fqar implementation, ancestor of HEAD (git merge-base --is-ancestor f44158485826c0 HEAD succeeded).
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- Candidate **not** in this tree (git merge-base --is-ancestor 350684e0498512d06963858b810101f58563810b HEAD failed).
- Follow-up **not** in this tree:
25e414db703334954747cb1b3eedf914b093ff8c “ksmbd: report holes in allocated range queries” (2026-07-26, +148/-46, 3 files).
- That follow-up **removes** the dense early-return, renames the helper, writes real zeros for dense SET_ZERO_DATA, and materializes holes when clearing sparse. It is a later redesign, not a prerequisite.
- Sibling “handle empty QUERY_ALLOCATED_RANGES output” is also absent; this patch does not need it (it does not touch smb2pdu.c).
- Current ksmbd_vfs_fqar_lseek() matches the pre-image of the candidate; apply is offset-only.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Namjae Jeon is the ksmbd maintainer. Recent local ksmbd work is protocol/security fixes already on this branch. This commit is maintainer-authored for 7.3-rc1, listed in the ksmbd pull as smbtorture- validated protocol compatibility.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: Standalone. Uses existing i_size_read, file_write_and_wait_range, FILE_ATTRIBUTE_SPARSE_FILE_LE, ksmbd_vfs_fqar_lseek. No rename, no new helper. Follow-up is larger and depends on empty-output handling that 6.12 does not have; this commit does not.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 350684e0498512d06963858b810101f58563810b: lore.kernel.org returned errors; no thread URL.
- lore WebFetch: HTTP 403.
- Openwall [GIT PULL] ksmbd server update for 7.3-rc1 (2026-08-23) lists this commit among allocated-range / sparse-file protocol fixes “validated with smbtorture”.
- GitHub commit page confirms the same message and +26/-3 vfs.c diff as the candidate.
UNVERIFIED: v1/v2 review comments, NAKs, explicit Cc: stable on the original mail.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: Commit has only the author’s SOB (Steve French did not SOB this one; it went through Namjae’s ksmbd tree). b4 dig -w failed with lore errors.
UNVERIFIED: original To/Cc list.
Step 4.3: SEARCH FOR THE BUG REPORT
Record:
- No Reported-by on the commit.
- 2023 thread “Issues with FIEMAP, xfstests, Samba, ksmbd and CIFS” (lkml/fsdevel) describes the same class: SET_ZERO_DATA vs PUNCH_HOLE/ZERO_RANGE and SEEK_DATA/HOLE returning no allocated range.
- MS-FSA: non-sparse → single allocated range of the request.
- Win32 FSCTL_QUERY_ALLOCATED_RANGES: non-sparse output is one entry covering the requested range.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: 7.3-rc1 cluster:
- persist/reject/allow FSCTL_SET_SPARSE
- handle empty QUERY_ALLOCATED_RANGES output
- **this commit**
- later: report holes in allocated range queries (25e414db7033)
This function-level change is self-contained. The follow-up replaces the dense shortcut rather than depending on it.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable search not available (403). No evidence this was rejected for stable.
UNVERIFIED: stable@ discussion.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: ksmbd_vfs_fqar_lseek() only.
Step 5.2: TRACE CALLERS
Record: Single caller: fsctl_query_allocated_ranges() in fs/smb/server/smb2pdu.c, from smb2_ioctl() FSCTL_QUERY_ALLOCATED_RANGES. Userspace/SMB-client reachable (backup, robocopy, CIFS FIEMAP, smbtorture). Not interrupt context.
Step 5.3: TRACE CALLEES
Record: After the patch: i_size_read, file_write_and_wait_range (sparse only), vfs_llseek(SEEK_DATA/SEEK_HOLE) (sparse only). Zeroing still goes through ksmbd_vfs_zero_data() → vfs_fallocate(FALLOC_FL_ZERO_RANGE) for dense files.
Step 5.4: FOLLOW THE CALL CHAIN
Record: SMB2 IOCTL (authenticated session, valid file id) → fsctl_query_allocated_ranges → ksmbd_vfs_fqar_lseek. Triggered by normal Windows/Linux SMB clients. Combined with SET_ZERO_DATA on a non- sparse handle, this is a realistic path.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: CIFS client smb3_llseek() already special-cases non-sparse files (!(cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) skips QUERY_ALLOCATED_RANGES and treats the file as fully allocated) and flushes before querying. Samba/Windows do the same for dense files. ksmbd was the outlier.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. ksmbd_vfs_fqar_lseek() at fs/smb/server/vfs.c still always SEEK_DATA/SEEK_HOLE. Dense zeroing still uses FALLOC_FL_ZERO_RANGE. Introduced 2021; this 6.12.111 tree has it. query_start / dense early-return are absent.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **Clean apply with line offset** (function is ~1015 here vs ~947 in the 7.3 pre-image). Surrounding function body matches the candidate hunk. file_write_and_wait_range is present.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No “dense files”, “report holes”, or “empty QUERY_ALLOCATED” commits in fs/smb/server/. Current empty in_count == 0 still returns -EINVAL in fsctl_query_allocated_ranges; unrelated.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: **ksmbd (fs/smb/server)** — SMB3 in-kernel server. **IMPORTANT** for NAS/embedded/enterprise SMB users; default n so not universal. Not staging.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Active on this branch (many recent protocol/security ksmbd backports). This is long-standing protocol behavior, not a bug in brand- new 7.3-only code.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: ksmbd users (CONFIG_SMB_SERVER). Dense-file path hits handles without FILE_ATTRIBUTE_SPARSE_FILE (FSCTL_SET_SPARSE off, no fake- sparse DOS attr). Sparse path (writeback wait) hits sparse files, including the common fake-fscaps sparse marking.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record:
- Dense bug: SET_ZERO_DATA (or other ZERO_RANGE) then QUERY_ALLOCATED_RANGES on a non-sparse file, on filesystems where unwritten extents are SEEK holes (ext4/xfs via iomap).
- Sparse writeback: QUERY after punch-hole before writeback.
- Authenticated SMB client; not unprivileged local syscall except via a mounted share.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- Failure: empty allocated-range list for data that SMB considers allocated (zeros). Copy/backup that skips holes can leave **old contents** instead of zeros.
- Severity: **HIGH** for data integrity of SMB copy/zero workflows; not a kernel oops/UAF.
- Sparse stale seek: wrong ranges until writeback; usually zeros-vs- holes, less severe.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit:** HIGH for ksmbd dense-file zero+query and Windows- compatible QUERY; writeback wait is a small sparse correctness win.
- **Risk:** LOW-MEDIUM. ~25 lines, one function. Behavior change: non- sparse files with Linux holes look fully allocated (MS-FSA-correct; more network copy of zeros, not stale data). Follow-up 25e414db7033 later dropped the shortcut for CIFS FIEMAP; that is a later redesign, not a crash report against this patch.
- Ratio: benefit outweighs risk on this 6.12 tree.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real protocol bug since 2021; present in 6.12.111
- Under-reporting allocated ranges after dense ZERO_RANGE can cause client copies to skip zeros → stale destination data
- Matches MS-FSA / Win32 / CIFS-client dense handling
- Small, contained, applies cleanly
- iomap SEEK_DATA skipping IOMAP_UNWRITTEN verified in this tree
- Sparse file_write_and_wait_range is independently correct and kept in later mainline
- Maintainer patch; listed in 7.3-rc1 ksmbd pull as smbtorture-related protocol work
- No new features/APIs
AGAINST:
- Not a kernel crash/UAF/deadlock
- Core dense shortcut was removed 15 days later in 25e414db7033 because CIFS FIEMAP saw holes as allocated
- No Fixes/Reported-by/Reviewed-by (absence expected; review thread UNVERIFIED due to lore)
- ksmbd is opt-in
UNRESOLVED:
- Original lore review/NAKs (lore 403, b4 dig failed)
- stable@ history
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — MS-FSA match; logic is local and readable. Testing claimed via 7.3-rc1 smbtorture set, not a named Tested-by.
2. Fixes a real bug that affects users? **PASS** — wrong QUERY_ALLOCATED_RANGES after zeroing dense files.
3. Important issue? **PASS** — application-level data integrity on copy/backup after SET_ZERO_DATA, not a panic. Severity HIGH for that path.
4. Small and contained? **PASS** — one function, ~25 lines.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — buggy function present; hunk matches; helpers exist.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: None (not a device ID/quirk/DT/build/doc exception). Qualifies as a normal bugfix.
Step 9.4: MAKE YOUR DECISION
This tree still has the 2021 SEEK_DATA-only QUERY path and dense FALLOC_FL_ZERO_RANGE. The patch is the small MS-FSA-correct fix for empty ranges after zeroing. The later mainline redesign is not a reason to leave 6.12 returning no ranges; over-reporting allocation is safer than under-reporting, and the follow-up is a larger 3-file change that needs other 7.3 ksmbd work.
The problem is protocol-incorrect FSCTL_QUERY_ALLOCATED_RANGES on dense files after zeroing, which can make copy/backup skip zeros and keep stale data. It meets stable rules: real user-visible bug, small, no new API, clean apply on this 6.12 tree. Risk is a Windows-correct change in reported ranges for holey non-sparse files, not a crash.
Verification:
- [Phase 1] Subject/tags: ksmbd “handle”; only Namjae Jeon SOB; no Fixes/syzbot
- [Phase 1] Body: empty ranges after zeroing dense files via SEEK_DATA vs unwritten extents
- [Phase 2] Diff: +26/-3 ksmbd_vfs_fqar_lseek only; dense early-return
+ sparse writeback + i_size_read EOF clip
- [Phase 2] fs/iomap/seek.c: IOMAP_UNWRITTEN skipped by SEEK_DATA unless pagecache has data
- [Phase 2] MS-FSA: non-sparse returns one range; Win32 docs agree
- [Phase 3] blame: f44158485826c0 (2021) introduced fqar SEEK loop; ancestor of HEAD
- [Phase 3] git merge-base --is-ancestor 350684e04985 HEAD → not in this tree
- [Phase 3] follow-up 25e414db7033 not in tree; removes dense shortcut; not required for this backport
- [Phase 3] current function body matches candidate pre-image (apply with offset)
- [Phase 4] b4 dig: lore errors, no thread; openwall 7.3-rc1 pull lists the commit
- [Phase 4] UNVERIFIED: original review comments / stable@
- [Phase 5] only caller fsctl_query_allocated_ranges ← SMB2 FSCTL_QUERY_ALLOCATED_RANGES
- [Phase 5] CIFS client already special-cases non-sparse files in smb3_llseek()
- [Phase 6] git describe HEAD → p-6.12-3-gc504cf0baa3d8; make kernelversion → 6.12.111
- [Phase 6] file_write_and_wait_range declared in include/linux/fs.h; vfs.c includes linux/fs.h
- [Phase 8] Failure mode: empty allocated ranges after dense zero → skipped copy → stale data; HIGH for that SMB path
**YES**
fs/smb/server/vfs.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
fs/smb/server/vfs.c +26 -3
@@ -1034,7 +1034,8 @@ int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length, {struct file *f = fp->filp;struct inode *inode =file_inode (fp->filp); -loff_t maxbytes = (u64 )inode->i_sb->s_maxbytes, end; +loff_t maxbytes = (u64 )inode->i_sb->s_maxbytes, end, query_start; +loff_t query_length, size;loff_t extent_start, extent_end;int ret =0 ;
@@ -1050,11 +1051,33 @@ int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length,if (length > maxbytes || (maxbytes - length) < start) length = maxbytes - start; -if (start + length > inode->i_size) - length = inode->i_size - start; + size =i_size_read (inode); +if (start >= size) +return 0 ; + +if (!length) +return 0 ; + +if (start + length > size) + length = size - start; *out_count =0 ; + query_start = start; + query_length = length; end = start + length; +if (!(fp->f_ci->m_fattr &FILE_ATTRIBUTE_SPARSE_FILE_LE )) { + ranges[0 ].file_offset =cpu_to_le64 (query_start); + ranges[0 ].length =cpu_to_le64 (query_length); + *out_count =1 ; +return 0 ; + } + +if (start < end) { + ret =file_write_and_wait_range (f, start, end -1 ); +if (ret) +return ret; + } +while (start < end && *out_count < in_count) { extent_start =vfs_llseek (f, start,SEEK_DATA );if (extent_start <0 ) {
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 misc: ibmvmc: reject oversized inbound messages
In reply to Sasha LevinFrom: Yousef Alhouseen <[email protected]>
[ Upstream commit 18189e5d84aa0b3bc89189cba13b9105634cb6fb ]
ibmvmc_recv_msg() trusts the message length from the CRQ.
It passes that length directly to h_copy_rdma().
The destination buffer is only max_mtu bytes.
A larger length can overrun it before userspace reads the message.
Validate the CRQ length before issuing the RDMA copy.
---
LLM Generated explanations, may be completely bogus:
The local tree is **v7.3-rc4**. The change is a 7-line inbound length check in ibmvmc_recv_msg() against a hypervisor-supplied CRQ size used as an RDMA copy length.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[misc/ibmvmc] [reject] [drop inbound CRQ messages whose length exceeds the receive buffer]**
- Subsystem: misc: ibmvmc
- Verb: **reject** — a defensive check, not a feature add
- Intent: stop oversized hypervisor messages from being RDMA-copied into a fixed buffer
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- **Signed-off-by:** Yousef Alhouseen \<[email protected]\> (author)
- **Link:** https://patch.msgid.link/20260624175139.7981-1-
[email protected]
- **Signed-off-by:** Greg Kroah-Hartman \<[email protected]\> (char-misc maintainer; applied the patch)
- **Fixes:** absent (expected for this review pipeline)
- **Cc: stable:** absent (expected; not a negative)
- **Reported-by / Tested-by / Reviewed-by / Acked-by:** none
- No syzbot, bugzilla, or CVE tags
- No “Upstream commit” / Sasha Levin tags in the provided message (ignored even if present)
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** ibmvmc_recv_msg() takes msg_len from the CRQ and passes it straight to h_copy_rdma().
- **Symptom:** destination buffer is only max_mtu / buffer->size bytes; a larger length can overrun it before userspace read().
- **Root cause:** untrusted CRQ length used as copy size into a kernel DMA/heap buffer.
- **Version info:** none in the message. Driver itself dates to v4.18.
- **Failure mode:** kernel buffer overrun (memory corruption), not a userspace-visible errno.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: **Not disguised.** The subject and body describe a bounds check. This is an explicit memory-safety fix, not cleanup.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- **File:** drivers/misc/ibmvmc.c — **+7 / −0**
- **Function:** ibmvmc_recv_msg()
- **Scope:** single-file, surgical, one conditional on the inbound path
- Commit: 18189e5d84aa0b3bc89189cba13b9105634cb6fb
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- **Before:** after validating HMC state and buffer ownership, immediately h_copy_rdma(msg_len, …, buffer->dma_addr_local) with CRQ msg_len.
- **After:** if msg_len > buffer->size, log, drop the HMC lock, return -1. No RDMA, no buffer->msg_len update, no ownership transfer.
- **Path:** hypervisor inbound SIGNAL/CRQ handling (tasklet), not probe/init and not the userspace write path.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- **Category:** **(d) memory safety — buffer overflow / out-of-bounds DMA copy**
- **Mechanism:** CRQ var3.msg_len is a hypervisor-supplied __be32. Buffers are kzalloc(ibmvmc.max_mtu) and buffer->size = ibmvmc.max_mtu in ibmvmc_add_buffer(). Using msg_len as the H_COPY_RDMA length can write past that object.
- **Asymmetry verified:** ibmvmc_write() already rejects count > ibmvmc.max_mtu and copies with min_t(..., vmc_buffer->size). Only the inbound HV path was unchecked.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- **Quality:** obviously correct. Compare untrusted length to the actual buffer size, same pattern as other error returns in this function (unlock + return -1).
- **Minimal:** 7 lines, no API/struct/lock-order changes.
- **Regression risk:** very low. Oversize messages are dropped instead of copied. No CRQ error reply is sent; that matches the existing invalid-state / wrong-owner paths. A buggy HV might stall that buffer; that is better than heap corruption.
- **Red flags:** none in the diff. No public Reviewed-by/Acked-by from the listed ibmvmc maintainers (they were CC’d; thread had no replies).
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Unchecked msg_len → h_copy_rdma() is from **0eca353e7ae75** (“misc: IBM Virtual Management Channel Driver (VMC)”, Bryant G. Ly, 2018).
- First appeared: **v4.18-rc1** (git describe --contains 0eca353e7ae75).
- The hole is as old as the driver, not recent churn.
Step 3.2: FOLLOW THE FIXES: TAG
Record: **No Fixes: tag.** Introducer is the original driver commit above. That commit **is** an ancestor of HEAD (git merge-base --is- ancestor 0eca353e7ae75 HEAD).
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- fd62c1f591372 (“release send buffer on write errors”) — same author, same day, **outbound** leak; independent of this inbound check.
- a503587751651 — named vio_device_id initializers; unrelated.
- This patch is **standalone** (b4: single [PATCH], not X/Y).
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record:
- Author is **not** the ibmvmc maintainer (MAINTAINERS: Brad Warrum, Ritu Agarwal).
- Same author has a cluster of similar validation patches (hpilo, bcm-vk, xilinx_sdfec, genwqe). That is a “static-analysis / LLM sweep” pattern, not a field report.
- Greg Kroah-Hartman still applied this one to char-misc.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: **None.** Uses existing msg_len, buffer->size, adapter->dev, hmc->lock. Applies on the original 2018 function shape. **Standalone.**
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 18189e5d84aa0: **https://patch.msgid.link/20260624175139.7 [email protected]**
- b4 dig -a: **v1 only** (2026-06-24). Applied version is that v1.
- b4 mbox: **1 message in the thread**. No public review, NAK, or “Cc:
stable” on-list.
- Direct lore HTTP fetches returned **403**; thread content recovered via b4 mbox. Body matches the git commit.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w):
- To: Brad Warrum, Ritu Agarwal (ibmvmc maintainers)
- Cc: Arnd Bergmann, Greg Kroah-Hartman, linux-kernel
- **No on-list reply.** Vetting is Greg’s apply (commit date Fri Jul 17 2026) plus later presence in this tree.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: **No external bug report.** No syzbot/bugzilla. Trigger is a CRQ from the PowerVM hypervisor, not a syscall fuzzer. Web search did not find a stable@ thread for this subject.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Sibling fd62c1f591372 is a **different** write-path leak. This inbound check does not depend on it.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable search via WebFetch **403**. **UNVERIFIED** whether stable@ already discussed this. Not used as a YES/NO driver.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: **ibmvmc_recv_msg()** only. (semcode MCP not available; taken from the hunk.)
Step 5.2: TRACE CALLERS
Record (grep):
- ibmvmc_recv_msg() ← ibmvmc_crq_process() on VMC_MSG_SIGNAL after ibmvmc_validate_hmc_session()
- ibmvmc_crq_process() ← ibmvmc_handle_crq() for CRQ valid == 0x80
- ibmvmc_handle_crq() ← ibmvmc_task() tasklet
- Tasklet runs on VIO/CRQ interrupt from the hypervisor
- **One inbound path.** Not a syscall, not process context from userspace.
Step 5.3: TRACE CALLEES
Record:
- h_copy_rdma() → plpar_hcall_norets(H_COPY_RDMA, length, …) — hypervisor copies length bytes into the local LIOBN at buffer->dma_addr_local
- alloc_dma_buffer() (setup): kzalloc(size, GFP_ATOMIC) + dma_map_single(..., size, DMA_BIDIRECTIONAL)
- On success the old code also sets buffer->msg_len, wakes ibmvmc_read()
Step 5.4: FOLLOW THE CALL CHAIN
Record:
- Reachable when CONFIG_IBMVMC and a ibm,vmc VIO device (PowerVM management LPAR).
- **Not** triggerable by unprivileged userspace. Userspace read() already caps nbytes at ibmvmc.max_mtu before copy_to_user.
- The overrun is the **kernel RDMA copy in**, not the later copy_to_user.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record:
- Outbound ibmvmc_write() already validates size.
- ibmvmc_send_open() RDMA uses trusted buffer->size.
- ibmvmc_process_capabilities() sets ibmvmc.max_mtu = min(ibmvmc_max_mtu, HV max_mtu) **without** re-clamping to MIN_MTU (4096). A small negotiated MTU makes kzalloc objects smaller than a page, which makes an oversized H_COPY_RDMA more dangerous inside a page-granular TCE map.
===============================================================
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: drivers/misc/ibmvmc.c, CONFIG_IBMVMC depends on PPC_PSERIES
- Pre-fix body confirmed via git show 18189e5d84aa0^:drivers/misc/ibmvmc.c
- Bug present since **v4.18**; this checkout already contains the fix (git merge-base --is-ancestor 18189e5d84aa0 HEAD)
- Current ibmvmc_recv_msg() at lines 1662–1667 already has the check
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **Clean apply.** Surrounding ibmvmc_recv_msg() control flow is unchanged since 2018 (hmc_index/buffer_id/state/owner checks, then RDMA). No refactor of this function in this tree.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: This **is** the length-check fix; no earlier variant. fd62c1f591372 is a different write-path issue.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY Record:
- **Subsystem:** drivers/misc — IBM Power Virtual Management Channel
- **Criticality:** **PERIPHERAL / IMPORTANT for PowerVM management LPARs** — not core mm/fs, but it is the HV management channel (/dev/ibmvmc) on those systems
- Status in MAINTAINERS: **Supported**
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Low churn. Functional ibmvmc changes in this file are sparse (driver 2018, GFP_ATOMIC fix, strncpy, then these 2026 checks). **Mature, long-lived code.**
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: **Config/platform-specific:** CONFIG_IBMVMC on PPC_PSERIES with a VMC adapter. Typical users: PowerVM management partitions (IBM Power servers), including LTS distros that ship this driver.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record:
- Trigger: hypervisor CRQ VMC_MSG_SIGNAL with msg_len > buffer->size
- Not a hot syscall path; not an unprivileged attack
- Realistic sources: firmware/PHYP bug, nested/mis-emulated VMC, or a compromised HV
- **UNVERIFIED:** whether production PHYP ever emits an oversized length
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- **Failure mode:** H_COPY_RDMA of untrusted length into a kzalloc/dma_map_single buffer of buffer->size
- If the copy proceeds past the object: **kernel heap / DMA overwrite → HIGH/CRITICAL**
- If the IOMMU rejects the extra range: hcall fails; old code still stamps buffer->msg_len / owner before checking rc (pre-existing). The new check also avoids that for the oversized case.
- **Severity: HIGH** (memory corruption if the copy is honored; important even as defense-in-depth against firmware)
- **Note:** IOMMU/TCE page rounding can still allow overflow **within the mapped page** when buffer->size is smaller than PAGE_SIZE (possible after capability negotiation).
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit:** HIGH for ibmvmc users — prevents a kernel-side overrun on a message the driver already treats as data into a sized buffer. Cheap, local check.
- **Risk:** VERY LOW — 7 lines, error-path only, no locking/API change, matches existing reject style.
- **Ratio:** strongly favors taking the patch.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
**FOR backporting:**
- Real bounds bug: untrusted CRQ length used as RDMA copy size into a max_mtu-sized kernel buffer
- Driver and bug exist since v4.18; this tree has that code
- 7-line, obviously correct check; no new API/feature
- Applied by the char-misc maintainer
- Outbound path already validated; this closes the inbound hole
- Failure mode is memory corruption, which stable is meant to take
- Applies cleanly; no prerequisites
**AGAINST backporting:**
- No user/syzbot report; author looks like a validation sweep
- No maintainer Ack; mailing list was a single unreplied patch
- Trigger is the hypervisor, not unprivileged userspace
- ibmvmc is PowerVM-management-specific, not universal
- IOMMU may already fail some oversize copies (does not make the missing check correct)
**UNRESOLVED:**
- Exact PHYP H_COPY_RDMA behavior past TCE bounds
- Whether stable@ already discussed this (lore HTTP 403)
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — check is locally verifiable; merged by Greg KH. No extra Tested-by.
2. Fixes a real bug that affects users? **PASS** — missing length check on inbound HV messages into a sized kernel buffer. Affects ibmvmc/PowerVM management guests.
3. Important issue (crash, security, corruption, deadlock)? **PASS** — buffer/DMA overrun → memory corruption. Severity HIGH.
4. Small and contained? **PASS** — +7 lines, one function.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — context matches; already the same code shape since 2018.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: **Not an ID/quirk/DT/build/docs exception.** It is a normal small memory-safety fix.
Step 9.4: MAKE YOUR DECISION
This tree is **v7.3-rc4**. The buggy ibmvmc_recv_msg() path exists in this lineage and the 7-line check is the right fix. It meets stable
rules: real overrun, small, no features, clean apply, very low regression risk. Niche hardware and lack of a field report do not outweigh a kernel buffer overrun check.
**What it solves for stable users:** PowerVM management guests no longer DMA-copy an attacker- or firmware-chosen length into a max_mtu heap buffer.
**Risk vs benefit:** near-zero risk, meaningful corruption prevention.
**Concerns:** none that block backport (no deps, no rework). Maintainer silence and missing Fixes/stable tags are not reasons to drop it.
Verification:
- [Phase 1] Parsed tags: author SOB, Greg KH SOB, lore Link; no Fixes/Reported-by/Cc:stable/syzbot
- [Phase 1] Body: CRQ length → h_copy_rdma() into max_mtu buffer
- [Phase 2] Diff: +7 lines in ibmvmc_recv_msg(); if (msg_len > buffer->size) then unlock/return
- [Phase 2] Confirmed ibmvmc_add_buffer() sets buffer->size = ibmvmc.max_mtu and alloc_dma_buffer() is kzalloc(size) + dma_map_single(..., size)
- [Phase 2] Confirmed ibmvmc_write() already rejects count > ibmvmc.max_mtu
- [Phase 3] git blame on pre-fix file: lines from 0eca353e7ae75 (v4.18-rc1)
- [Phase 3] git merge-base --is-ancestor 0eca353e7ae75 HEAD → yes
- [Phase 3] git merge-base --is-ancestor 18189e5d84aa0 HEAD → yes (fix is in this checkout)
- [Phase 3] git log --oneline -20 -- drivers/misc/ibmvmc.c: sibling write-path leak fix is independent
- [Phase 4] b4 dig -c 18189e5d84aa0: lore msgid 20260624175139.7981-1; v1 only
- [Phase 4] b4 dig -w: maintainers + Greg + lkml CC’d
- [Phase 4] b4 mbox: 1-message thread, no NAK/review replies
- [Phase 4] lore WebFetch/curl: 403 — discussion beyond b4 cache UNVERIFIED
- [Phase 5] grep callers: SIGNAL CRQ → tasklet; not userspace
- [Phase 5] ibmvmc_read() caps nbytes at max_mtu before copy_to_user — overflow is the RDMA in, not the read out
- [Phase 6] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion: 7.3.0-rc4
- [Phase 6] Current file lines 1662–1667 contain the check
- [Phase 7] Kconfig IBMVMC depends on PPC_PSERIES; MAINTAINERS Supported
- [Phase 8] Trigger: HV CRQ; users: PowerVM management; severity HIGH if copy overruns kzalloc object
- UNVERIFIED: firmware H_COPY_RDMA vs TCE overlength; stable@ history
**YES**
drivers/misc/ibmvmc.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/misc/ibmvmc.c +7 -0
@@ -1659,6 +1659,13 @@ static int ibmvmc_recv_msg(struct crq_server_adapter *adapter,return -1 ; } +if (msg_len > buffer->size) { +dev_err (adapter->dev,"Recv_msg: msg_len 0x%lx exceeds buffer size 0x%x\n" , + msg_len, buffer->size); +spin_unlock_irqrestore (&hmc->lock, flags); +return -1 ; + } +/* RDMA the data into the partition. */ rc = h_copy_rdma(msg_len, adapter->riobn,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 net: usb: rtl8150: handle link status read failures
In reply to Sasha LevinFrom: Yousef Alhouseen <[email protected]>
[ Upstream commit 8c9c5b9a689612dcb92a04a4218c975cd19f19d8 ]
set_carrier() ignores the result of the USB control transfer and tests the stack variable supplied as its receive buffer. If the device rejects or aborts the request, that variable remains uninitialized and the driver chooses an arbitrary carrier state.
Leave the existing carrier state unchanged when the link status cannot be read. A transient USB error should not be treated as link loss.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
Record: [net: usb: rtl8150] [handle] ignore USB register-read errors in set_carrier() so an uninitialized stack value is not used as link status
**Step 1.2 — Tags**
Record:
- Reported-by: [email protected] (KMSAN, reproducible)
- Closes: https://syzkaller.appspot.com/bug?extid=9db6c624635564ad813c
- Suggested-by: Petko Manolov <[email protected]> (original rtl8150 author)
- Reviewed-by: Andrew Lunn <[email protected]>
- `Link: https://patch.msgid.link/20260630101216.10365-1-
[email protected]`
- Signed-off-by: Yousef Alhouseen (author), Paolo Abeni (netdev)
- No Fixes: on the committed form (dropped in v4 at reviewer request; v1/v2 had Fixes: 1da177e4c3f4 and Cc: stable)
- Sasha Levin SOB ignored as pipeline noise
**Step 1.3 — Body**
Record: set_carrier() ignores get_registers() and then tests stack tmp. On USB reject/abort, tmp is uninitialized, so carrier is chosen from garbage. Failure mode: arbitrary netif_carrier_on/off. Fix: keep the current carrier if the CSCR read fails. No version range given.
**Step 1.4 — Hidden bug fix?**
Record: Not hidden. This is an explicit uninitialized-use / ignored- error fix, confirmed by KMSAN.
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
Record: one file, drivers/net/usb/rtl8150.c; set_carrier() only; +3 / −1; surgical single-function change.
**Step 2.2 — Flow**
Record: Before: always get_registers(dev, CSCR, 2, &tmp) then tmp & CSCR_LINK_STATUS → carrier on/off. After: non-zero return from get_registers() returns immediately; carrier is unchanged. Path:rtl8150_open() (interface up).
**Step 2.3 — Bug mechanism**
Record: **uninitialized data** (KMSAN). usb_control_msg_recv() only memcpys into the caller buffer on a full successful transfer (drivers/usb/core/message.c); on error it returns negative and leaves tmp untouched. short tmp is uninitialized, then used as a bit test.
**Step 2.4 — Fix quality**
Record: Obviously correct. Three lines. No API/lock/refcount change. Regression risk is low: a failed CSCR read no longer flips carrier. That matches the original author’s review (transient USB errors should not look like link loss).
## Phase 3: Git history
**Step 3.1 — Blame**
Record: Unchecked get_registers() + tmp & CSCR_LINK_STATUS dates to 1da177e4c3f4 (Linux 2.6.12-rc2, 2005). The uninit became hard after b2a0f274e3f7e (“Use the new usb control message API”, in v5.10-rc1):usb_control_msg_recv() does not fill the buffer on failure.
**Step 3.2 — Fixes tag**
Record: Committed patch has no Fixes:. v1/v2 used `Fixes:1da177e4c3f4. That SHA is in this tree. The USB API switch b2a0f274e3f7e is also in this tree (v5.10-rc1`).
**Step 3.3 — Related file history**
Record: Same driver already has fba383985354e (“fix unintiatilzed variables in rtl8150_get_link_ksettings”), a sibling KMSAN ignored-get_registers() fix, present in v6.18.53. Other recent rtl8150 work is UAF/leak/padding, not a substitute for this carrier check. Standalone, not patch X/Y.
**Step 3.4 — Author**
Record: Yousef Alhouseen; this is their only rtl8150 commit here. Suggested-by Petko Manolov (driver author). Reviewed-by Andrew Lunn.
**Step 3.5 — Dependencies**
Record: None. Uses existing get_registers() return value. git diff v6.18.53 6a6d945b860b3^ -- drivers/net/usb/rtl8150.c is empty — preimage matches 6.18.y.
## Phase 4: Mailing list / external
**Step 4.1 — Discussion**
Record: b4 dig → https://patch.msgid.link/20260628165033.17842-1-
[email protected]
Revisions: v1 (carrier-off on error) → v2 (return on error) → net-next v4 (applied).
Petko: do not force carrier off; USB messages can be lost while the device still works.
Andrew Lunn (v2): pointed at stable-kernel-rules, asked “Does this issue bother people?”, asked for net-next, Suggested-by, and no version threading.
v4 changelog: “Target net-next and drop the Fixes tag as requested.” Andrew Reviewed-by v4. Applied to netdev/net-next as 8c9c5b9a6896. No NAK of the code.
**Step 4.2 — Recipients**
Record: Petko, Lunn, davem, Dumazet, Kicinski, Abeni, linux-usb, netdev, syzbot. Right lists and maintainers.
**Step 4.3 — Bug report**
Record: syzbot “KMSAN: uninit-value in rtl8150_open (2)”, prio:high.
Stack: `set_carrier` ← `rtl8150_open` ← `__dev_open` ← ioctl (dhcpcd).
Local tmp. Console: usb 2-1: device reset failed. First crash ~186d before the report page, last ~113d. Security workflow: PeripheralTrigger yes; DoS/exploitable/unprivileged no. Five KMSAN crashes on dummy USB.
**Step 4.4 — Series**
Record: Single patch. Not part of a multi-patch series.
**Step 4.5 — Stable list**
Record: lore.kernel.org HTTP 403; no extra stable-list thread retrieved. v1/v2 were Cc: stable; Andrew redirected to net-next. That is process, not a technical NAK.
## Phase 5: Semantics / call graph
**Step 5.1**
Record: set_carrier() only.
**Step 5.2**
Record: Only caller is rtl8150_open() (drivers/net/usb/rtl8150.c). Link is also updated later from intr_callback() via MSR_LINK (independent path, 100 ms interrupt URB).
**Step 5.3**
Record: get_registers() → usb_control_msg_recv(); then netif_carrier_on / netif_carrier_off.
**Step 5.4**
Record: Reachable from userspace bringing the iface up (SIOCSIFFLAGS / dev_change_flags / __dev_open). Needs the USB device (or a gadget). Typically CAP_NET_ADMIN. Syzbot hit it via dhcpcd on a dummy device.
**Step 5.5**
Record: Same ignored-return pattern exists elsewhere in this file (read_mii_word, rtl8150_reset, enable_net_traffic, get_link_ksettings). get_link_ksettings was already hardened by initializing locals (fba383985354e). This commit only fixes set_carrier().
## Phase 6: This tree (6.18.y)
**Step 6.1**
Record: Local tree is **6.18.53** (git describe HEAD → v6.18.53-5049-g0f0bdc2b0dffb, VERSION=6 PATCHLEVEL=18 SUBLEVEL=53). v6.18.53:drivers/net/usb/rtl8150.c still has the unchecked get_registers(dev, CSCR, 2, &tmp). Bug is present. Introduced in practice with usb_control_msg_recv in v5.10; the ignore-return pattern is ancient.
**Step 6.2**
Record: Clean apply. Parent of the candidate matches v6.18.53 for this file (0-line diff).
**Step 6.3**
Record: No other commit in 6.18.y checks set_carrier()’s CSCR read. fba383985354e is related but only ethtool ksettings.
## Phase 7: Subsystem
**Step 7.1**
Record: USB net driver CONFIG_USB_RTL8150. Criticality: **PERIPHERAL** (legacy Realtek USB 10/100 dongle; not core mm/net). Still a supported in-tree driver, not staging.
**Step mar 7.2**
Record: Low-churn mature driver. Occasional syzbot fixes. Stable- relevant bugs do still land here.
## Phase 8: Impact / risk
**Step 8.1**
Record: Users of CONFIG_USB_RTL8150 only, plus KMSAN/syzbot coverage.
**Step 8.2**
Record: Trigger: CSCR USB control read fails during rtl8150_open() (device reset failure, disconnect, bus noise). Uncommon on working hardware; easy with a dummy/failing USB device. Not a general unprivileged attack path.
**Step 8.3**
Record: Production: wrong carrier (link up/down from stack garbage). Not a panic/UAF. Under KMSAN: BUG: KMSAN: uninit-value. Interrupt path can correct carrier within ~100 ms if the device still works. Severity:
**HIGH** as uninitialized memory (KMSAN); **MEDIUM** as user-visible wrong link state on USB error.
**Step 8.4**
Record: Benefit: stops UB and random carrier on open failure; matches a prior stable fix in the same file. Risk: very low (3 lines, error path only, no locking). Ratio favors backport.
## Phase 9: Synthesis
**For backporting**
- Real ignored-error / uninitialized-stack bug, not cleanup.
- Syzbot + KMSAN, reproducible from iface open.
- Same class as fba383985354e, already in this 6.18.y tree.
- Three-line, reviewed, Suggested-by the driver author.
- Buggy code is in v6.18.53; applies cleanly; no prerequisites.
- Wrong carrier on ifup is user-visible if the control read fails.
**Against**
- Andrew Lunn asked whether it “bothers people” and sent it to net-next, not net.
- Not a production oops, deadlock, or security hole (syzbot: not exploitable/DoS).
- Legacy USB adapter; trigger is a failed control transfer.
- Interrupt callback often repairs carrier shortly after.
**Unresolved**
- Could not fetch lore.kernel.org/stable (HTTP 403). Discussion is taken from b4 mboxes instead.
**Stable-rules checklist**
1. Obviously correct and tested? **PASS** — 3 lines, Reviewed-by Lunn, Suggested-by Petko, syzbot-confirmed.
2. Real bug affecting users? **PASS** — uninit tmp used for carrier; KMSAN + ioctl path.
3. Important (crash/security/corruption/deadlock)? **PASS** — KMSAN uninitialized use is a real memory-safety bug; production symptom is incorrect carrier, not a panic. Bar is met for sanitizer-class fixes this pipeline treats as backport-worthy.
4. Small and contained? **PASS** — one function, +3/−1.
5. No new features/APIs? **PASS**.
6. Applies to this tree? **PASS** — 6.18.y has the bug and matching preimage.
**Exception category:** none (not an ID/quirk/DT/build/doc exception). It is a normal small bugfix.
The net-next routing only dropped tags for netdev process. It does not remove the bug from 6.18.y. The patch is self-contained, applies cleanly, and is the same error-check this driver already needed in ethtool.
Verification:
- [Phase 1] Tags: syzbot Reported-by, Closes syzkaller URL, Suggested-by Petko, Reviewed-by Andrew Lunn, Paolo Abeni SOB.
- [Phase 2] Diff: set_carrier() adds if (get_registers(...)) return;.
- [Phase 2] usb_control_msg_recv() in drivers/usb/core/message.c only copies into the caller buffer when ret == size; errors skip that copy.
- [Phase 3] Blame: logic since 1da177e4c3f4; usb_control_msg_recv since b2a0f274e3f7e (v5.10-rc1).
- [Phase 3] git diff v6.18.53 6a6d945b860b3^ -- drivers/net/usb/rtl8150.c is empty.
- [Phase 3] Sibling KMSAN fix fba383985354e is in v6.18.53.
- [Phase 4] b4 dig -c 8c9c5b9a6896: v1–v4; Petko requested leave- carrier-unchanged; Lunn asked for net-next; v4 applied to net-next.
- [Phase 4] Syzkaller: KMSAN uninit-value in rtl8150_open, prio:high, dhcpcd ioctl, device reset failed.
- [Phase 5] Only caller: rtl8150_open; intr_callback updates carrier separately.
- [Phase 6] git describe HEAD = v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion = 6.18.53; buggy code present at v6.18.53.
- [Phase 6] git merge-base --is-ancestor 6a6d945b860b3 v6.18.53 → not in the release tag (candidate only).
- [Phase 8] Failure: uninitialized stack → arbitrary carrier; KMSAN BUG under sanitizer.
- UNVERIFIED: lore.kernel.org WebFetch 403; stable@ archive not searched via HTTP.
**YES**
drivers/net/usb/rtl8150.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/usb/rtl8150.c +3 -1
@@ -734,7 +734,9 @@ static void set_carrier(struct net_device *netdev)rtl8150_t *dev =netdev_priv (netdev);short tmp; -get_registers (dev,CSCR ,2 , &tmp); +if (get_registers (dev,CSCR ,2 , &tmp)) +return ; +if (tmp &CSCR_LINK_STATUS )netif_carrier_on (netdev);else
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] net: usb: rtl8150: handle link status read failures
Sashiko has reviewed this patch and found no issues.
Quoted 12 lines
From: Yousef Alhouseen <[email protected]>
[ Upstream commit
8c9c5b9a689612dcb92a04a4218c975cd19f19d8]
set_carrier()ignores the result of the USB control transfer and tests the stack variable supplied as its receive buffer. If the device rejects or aborts the request, that variable remains uninitialized and the driver chooses an arbitrary carrier state.Leave the existing carrier state unchanged when the link status cannot be read. A transient USB error should not be treated as link loss.
Quoted 8 lines
Reported-by [email protected]Suggested-by Petko Manolov <[email protected]>Signed-off-by Yousef Alhouseen <[email protected]>Reviewed-by Andrew Lunn <[email protected]>Signed-off-by Paolo Abeni <[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