net: dsa: mt7530: check CORE_PLL_GROUP4 access in mt7531_setup()
Subsystems (71)
Sasha Levin
maintainerPATCH 1/1 drm/amdgpu/mes_v12_0: use mes schedule pipe for legacy queues on unified MES
In reply to Sasha LevinFrom: Jesse Zhang <[email protected]>
[ Upstream commit 5ec4cc91708370847772f2a2397316dbd8d8f066 ]
when suspend_all_gangs is issued to pipe0 MES during system suspend or runtime PM, pipe0 can only suspend and resume queues it has tracked. KCQs registered with a non-zero pipe slot may not be correctly handled, leaving them in an inconsistent state after resume.
v3: fix the schedule pipe issue
v4: use schedule pipe for KQ resets
---
LLM Generated explanations, may be completely bogus:
This is a **6.18.y** tree (v6.18.53). The buggy MES v12 pipe selection is present here, the patch is small, and it applies cleanly.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [drm/amdgpu/mes_v12_0] [use] [route legacy kernel queues to the MES schedule pipe on unified MES]
Subsystem is AMD GPU MES firmware for gfx12. Verb is “use”, but the body describes a resume/tracking bug, not a feature.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- No Fixes: tag (expected for autosel review)
- No Reported-by: / Tested-by: / Cc: stable
- Reviewed-by: Michael Chen <[email protected]>
- Suggested-by: Michael Chen, Alex Deucher, Shaoyun Liu (AMD MES people)
- Signed-off-by: Jesse Zhang (author), Alex Deucher (amdgpu maintainer)
- Ignore pipeline Signed-off-by: Sasha Levin and [Upstream commit 5ec4cc917083...]
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: on unified MES, suspend_all_gangs is sent to pipe0 (SCHED). Pipe0 can only suspend/resume queues it has tracked.
- Symptom: KCQs registered on a non-zero pipe (KIQ = pipe 1) are not handled, and can be left inconsistent after resume.
- Trigger named in the message: system suspend / runtime PM.
- Changelog: v3 fixes schedule-pipe selection; v4 also sends kernel- queue resets to the schedule pipe.
- No stack trace, no kernel version list.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. It is an explicit correctness fix for MES pipe routing. The v4 reset hunk is the same class of bug (reset must follow the pipe that actually owns the queue).
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/gpu/drm/amd/amdgpu/mes_v12_0.c (+17 / −10)
- Functions: mes_v12_0_map_legacy_queue, mes_v12_0_unmap_legacy_queue, mes_v12_0_reset_hw_queue
- Scope: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Map/unmap, enable_uni_mes: previously always AMDGPU_MES_KIQ_PIPE.
After: MES ring (AMDGPU_RING_TYPE_MES) stays on KIQ; every other kernel queue goes to AMDGPU_MES_SCHED_PIPE. Non-uni_mes path still uses SCHED.
- Reset: previously is_kq → KIQ, else SCHED. After: always SCHED.
- Affected paths: KCQ/KGQ map at gfx init/resume, unmap at gfx hw_fini/suspend, MES scheduler-queue map in mes_v12_0_queue_init, kernel-queue reset in gfx12 hang recovery.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Logic / hardware-firmware tracking bug** (wrong MES pipe).
- AMDGPU_MES_SCHED_PIPE = 0, AMDGPU_MES_KIQ_PIPE = 1.
- Suspend-all is submitted to SCHED (pipe0). Mapping KCQs on KIQ (pipe1) means pipe0 never tracked them.
- Reset of kernel queues was also sent to KIQ (amdgpu_mes_reset_legacy_queue always sets is_kq = true), so hang recovery talked to the wrong pipe.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct given MES pipe semantics. Minimal. Non-uni_mes unchanged. MES scheduler queue still mapped via KIQ, which matches mes_v12_0_queue_init() calling amdgpu_mes_map_legacy_queue() on the SCHED ring (AMDGPU_RING_TYPE_MES). Regression risk is low: pipe choice is firmware-facing, but AMD MES reviewers signed off. The v4 reset hunk was added after the v3 Reviewed-by; it is consistent with the map change, not a random extra edit.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Map/unmap KIQ routing: aa539da8aff07a (“drm/amdgpu/mes12: adjust mes12 sw/hw init for multiple pipes”, Jack Xiao, 2024-08). In v6.18.53.
- Reset is_kq → KIQ: 2e828a25f850f (“drm/amdgpu/mes: use correct MES pipe for resets”, 2025-04). In v6.18.53.
- MES v12 itself: 785f0f9fe7420 (2024-05). In this tree.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Functionally this corrects aa539da8aff07a (map/unmap) and 2e828a25f850f (KQ reset pipe). Both ancestors of v6.18.53.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- 6abd725fdfc41 implements MES suspend/resume gang for v12 (in 6.18.53); mes_v12_0_suspend_gang() already submits to AMDGPU_MES_SCHED_PIPE.
- 2e828a25f850f is the prior reset-pipe policy this commit revises.
- Later autosel commit 00a6825e89078 (oversubscription doorbell mode) is unrelated.
- Standalone for 6.18: sibling mes_v12_1 does not exist here.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Jesse Zhang is an AMD amdgpu contributor (MES/gfx/SDMA). This is not a drive-by. Merged by Alex Deucher.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs MES v12, enable_uni_mes, map/unmap/reset callbacks, and SCHED-pipe suspend. All present in v6.18.53. Applies cleanly to v6.18.53:drivers/gpu/drm/amd/amdgpu/mes_v12_0.c (patch --dry-run rc 0). No missing helper or struct field.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 5ec4cc917083... →
https://patch.msgid.link/[email protected]
- v3 series: 1/2 this file; 2/2 mes_v12_1 (not in this tree).
- v4 standalone: https://lists.freedesktop.org/archives/amd-
gfx/2026-April/142750.html (map/unmap only).
- Committed form matches later resends that add “v4: use schedule pipe for KQ resets” (e.g. 11/42 in “Enable pipe reset for compute”).
- Michael Chen: Reviewed-by on v3. No NAK in the saved thread.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: To/Cc: amd-gfx, Alex Deucher, Christian König, Shaoyun Liu, Michael Chen. Right maintainers.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No bugzilla/syzbot. Description is from AMD MES engineers (Suggested-by three of them). No public crash log.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 2/2 is mes_v12_1 only. Not a hard dependency of 1/2. The May 42-patch compute-reset series reused this patch; this hunk does not need the rest of that series.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No useful stable-list discussion found. Absence is not a negative signal.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: mes_v12_0_map_legacy_queue, mes_v12_0_unmap_legacy_queue, mes_v12_0_reset_hw_queue. Semcode MCP not available; used grep/read.
**Step 5.2: TRACE CALLERS**
Record:
- Map: amdgpu_mes_map_legacy_queue() ← amdgpu_gfx_enable_kcq() / amdgpu_gfx_enable_kgq(), gfx12 KCQ/KGQ reset remap, mes_v12_0_queue_init() for the MES SCHED ring when enable_uni_mes.
- Unmap: amdgpu_mes_unmap_legacy_queue() ← amdgpu_gfx_disable_kcq() (gfx12 hw_fini / suspend), MES kiq_hw_fini for the SCHED ring.
- Reset: amdgpu_mes_reset_legacy_queue() ← gfx_v12_0_reset_kcq / gfx_v12_0_reset_kgq (and SDMA MES reset on other IPs; gfx12 path is the one that hits mes_v12).
- Suspend-all: amdgpu_mes_suspend() ← KFD suspend_all_queues_mes(); MES suspend packet already goes to SCHED pipe.
**Step 5.3: TRACE CALLEES**
Record: All three submit via mes_v12_0_submit_pkt_and_poll_completion(mes, pipe, ...), which writes the packet to mes->ring[pipe]. Wrong pipe means the other MES engine never sees ADD/REMOVE/RESET.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable without special debug options:
- Boot/resume maps KCQs (enable_legacy_queue_map is hardcoded true in mes_v12 sw_init).
- GPU suspend/hw_fini unmaps them.
- Hang recovery resets them.
- KFD bad-queue handling issues suspend_all_gangs.
Userspace GPU clients and suspend/resume trigger this. Unprivileged DRM/KFD users can hit hang recovery.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same uni_mes → KIQ heuristic remains in mes_v12_0_misc_op(); this patch does not touch it. User-queue add/remove already used SCHED pipe. Sibling mes_v12_1 fix is for a file this tree does not have.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes, in v6.18.53 mes_v12_0_map_legacy_queue / unmap / reset_hw_queue. Introduced 2024–2025; not after 6.18 branched.
Verified: git describe HEAD = v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion = 6.18.53; git merge-base --is-ancestor f15135562c4b0 v6.18.53 is false (candidate not in the stable tag).
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply to v6.18.53. Context matches. No rework needed.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: 6.18.53 still has the uni_mes→KIQ map/unmap and is_kq→KIQ reset. No earlier equivalent fix.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/gpu/drm/amd/amdgpu MES for gfx12. **IMPORTANT** (shipping RDNA4: IP 12.0.0 / 12.0.1), not core mm/net, not staging.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained; MES v12 has ongoing queue/reset work. The bug is in code that has been in 6.18 since release, not brand-new post- branch code.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: gfx12 (RDNA4) with unified MES. amdgpu_uni_mes defaults to 1; discovery sets enable_uni_mes for IP 12.0.0/12.0.1. Driver-specific, default-on for those GPUs.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Common: every gfx12 boot maps KCQs; every GPU suspend/hw_fini unmaps them.
- Hang recovery resets KCQ/KGQ through the same pipe.
- KFD suspend-all on bad queues.
- Not a theoretical race; wrong static pipe choice.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Kernel compute/graphics queues left untracked or reset on the wrong MES engine → failed suspend/resume, failed queue reset, GPU hang. KFD treats MES suspend failure as unrecoverable and schedules GPU reset.
Severity: **HIGH** (GPU hang / failed recovery), not a kernel NULL- deref, but user-visible and production-relevant on RDNA4.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: HIGH for gfx12 6.18 users (default uni_mes).
- Risk: LOW (17 lines, one file, non-uni_mes unchanged, MES self-queue still on KIQ).
- Ratio: favor backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real firmware-tracking bug: KCQs mapped to pipe1 while suspend- all/reset tracking is pipe0.
- Present in this 6.18.y tree; uni_mes default-enabled on gfx12.
- Hits suspend/resume and hang recovery, not a dead path.
- Small, surgical, applies cleanly.
- Reviewed/suggested by AMD MES engineers; merged by Alex Deucher.
- Corrects pipe policy already in 6.18 (aa539da8, 2e828a25).
AGAINST:
- No public user report or sanitizer hit.
- gfx12-only, not a core-kernel oops.
- v4 reset hunk was not in the v3 Reviewed-by mail (but it is the necessary counterpart of the map change).
- 2/2 mes_v12_1 is unrelated here (file absent).
UNRESOLVED:
- No first-party dmesg/reproducer beyond the author’s description (AMD- internal).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — pipe choice matches suspend- all on SCHED; MES self-queue exception is required and matches queue_init.
2. Fixes a real bug that affects users? **PASS** — gfx12 KCQ tracking/resume/reset.
3. Important issue? **PASS** — GPU hang / failed queue reset / inconsistent KCQs after resume. HIGH, not a style nit.
4. Small and contained? **PASS** — one file, ~27 lines.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — clean on v6.18.53.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None of ID/quirk/DT/build/docs. Ordinary driver correctness fix; still stable-eligible.
**Step 9.4: MAKE YOUR DECISION**
Backport. The 6.18 tree has unified MES, default-on, with the wrong pipe for legacy kernel queues. The fix is small, applies cleanly, and prevents KCQ inconsistency and failed MES resets on shipping gfx12 hardware.
Verification:
- [Phase 1] Tags: Reviewed-by Michael Chen; Suggested-by Chen/Deucher/Liu; no Fixes/syzbot.
- [Phase 2] Diff: map/unmap uni_mes now KIQ only for AMDGPU_RING_TYPE_MES; reset always SCHED.
- [Phase 3] Blame on v6.18.53: aa539da8aff07a (map/unmap), 2e828a25f850f (reset is_kq).
- [Phase 3] Both those commits are ancestors of v6.18.53; candidate is not.
- [Phase 3] git merge-base --is-ancestor f15135562c4b0 v6.18.53 → not in the tag.
- [Phase 4] b4 dig -c 5ec4cc917083... → v3 1/2 lore; 2/2 is mes_v12_1 only.
- [Phase 4] mbox: Chen Reviewed-by; no NAK.
- [Phase 4] v4 list mail had map/unmap only; committed v4 adds KQ reset pipe.
- [Phase 5] Callers: amdgpu_gfx_enable/disable_kcq, gfx12 reset_kcq/kgq, mes queue_init, KFD amdgpu_mes_suspend.
- [Phase 5] Pipes: SCHED=0, KIQ=1; suspend_gang already uses SCHED.
- [Phase 6] git describe HEAD v6.18.53-5049; make kernelversion 6.18.53.
- [Phase 6] enable_uni_mes default 1 (amdgpu_drv.c); set for IP 12.0.0/12.0.1.
- [Phase 6] Patch dry-run against v6.18.53 mes_v12_0.c: success.
- [Phase 6] No mes_v12_1.c in this tree.
- [Phase 8] Failure mode: inconsistent KCQs / failed MES reset → GPU hang; severity HIGH.
- UNVERIFIED: no public user crash log; lore.kernel.org WebFetch returned 403 (used b4 mbox + lists.freedesktop.org instead).
**YES**
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 27 ++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +17 -10
@@ -524,10 +524,15 @@ static int mes_v12_0_map_legacy_queue(struct amdgpu_mes *mes,convert_to_mes_queue_type (input->queue_type); mes_add_queue_pkt.map_legacy_kq =1 ; -if (mes->adev->enable_uni_mes) - pipe =AMDGPU_MES_KIQ_PIPE ; -else +if (mes->adev->enable_uni_mes) { +/* Keep scheduler queue on KIQ pipe; map all other kernel queues on sched pipe. */ +if (input->queue_type ==AMDGPU_RING_TYPE_MES ) + pipe =AMDGPU_MES_KIQ_PIPE ; +else + pipe =AMDGPU_MES_SCHED_PIPE ; + }else { pipe =AMDGPU_MES_SCHED_PIPE ; + } return mes_v12_0_submit_pkt_and_poll_completion(mes, pipe, &mes_add_queue_pkt, sizeof(mes_add_queue_pkt),
@@ -563,10 +568,15 @@ static int mes_v12_0_unmap_legacy_queue(struct amdgpu_mes *mes,convert_to_mes_queue_type (input->queue_type); } -if (mes->adev->enable_uni_mes) - pipe =AMDGPU_MES_KIQ_PIPE ; -else +if (mes->adev->enable_uni_mes) { +/* Keep scheduler queue on KIQ pipe; unmap all other kernel queues on sched pipe. */ +if (input->queue_type ==AMDGPU_RING_TYPE_MES ) + pipe =AMDGPU_MES_KIQ_PIPE ; +else + pipe =AMDGPU_MES_SCHED_PIPE ; + }else { pipe =AMDGPU_MES_SCHED_PIPE ; + } return mes_v12_0_submit_pkt_and_poll_completion(mes, pipe, &mes_remove_queue_pkt, sizeof(mes_remove_queue_pkt),
@@ -909,10 +919,7 @@ static int mes_v12_0_reset_hw_queue(struct amdgpu_mes *mes, mes_reset_queue_pkt.doorbell_offset = input->doorbell_offset; } -if (input->is_kq) - pipe =AMDGPU_MES_KIQ_PIPE ; -else - pipe =AMDGPU_MES_SCHED_PIPE ; + pipe =AMDGPU_MES_SCHED_PIPE ; return mes_v12_0_submit_pkt_and_poll_completion(mes, pipe, &mes_reset_queue_pkt, sizeof(mes_reset_queue_pkt),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 media: ivtv: stop VBI start-code scan before short tail
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit f373cf17fb8e7a530bc6e1e36fc41cb5dab2cdaa ]
compress_sliced_buf() scans one byte at a time while testing a four-byte VBI start code. The final iterations can read beyond the remaining buffer tail.
Stop the scan once fewer than four bytes remain.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: **[media/ivtv] [stop] stop VBI start-code scan before a short tail so a 4-byte SAV check cannot read past the buffer**
**Step 1.2: Tags**
Record:
- Signed-off-by: Pengpeng Hou <[email protected]> (author)
- Signed-off-by: Hans Verkuil <[email protected]> (media/V4L maintainer; applied the patch)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, Link:, or Cc: stable
- Absence of Fixes: / Cc: stable is expected for this review and is not a negative signal
**Step 1.3: Body**
Record:
- **Bug:** compress_sliced_buf() walks one byte at a time while testing a four-byte VBI start code (SAV: 0xff 0x00 0x00 sav).
- **Symptom/failure mode:** last loop iterations read past the remaining buffer tail (out-of-bounds read of up to 3 bytes).
- **Version info:** none in the message.
- **Root cause:** loop bound is i < size while the body reads buf[0]..buf[3].
**Step 1.4: Hidden bug fix?**
Record: **Not hidden.** This is an explicit bounds fix, not cleanup/refactoring.
---
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- File: drivers/media/pci/ivtv/ivtv-vbi.c — **1 insertion, 1 deletion**
- Function: compress_sliced_buf()
- Scope: **single-file surgical one-liner**
**Step 2.2: Code flow**
Record:
- **Before:** for (i = 0; i < size; i++, buf++) then buf[0]==0xff && !buf[1] && !buf[2] && buf[3]==sav
- When i == size-1, buf[1], buf[2], buf[3] are 1–3 bytes past the declared size.
- When size is 1, 2, or 3, the first iteration already overreads.
- **After:** for (i = 0; i + 3 < size; i++, buf++) — stop once fewer than 4 bytes remain.
- Path: **normal VBI parse path** (finding the first SAV), not an error- only path.
Verified pre-image:
```334:336:drivers/media/pci/ivtv/ivtv-vbi.c
if (buf[0] == 0xff && !buf[1] && !buf[2] && buf[3] ==
sav)
break;
```(with the new i + 3 < size bound on the for line immediately above)
**Step 2.3: Bug mechanism**
Record: **Memory safety / out-of-bounds read.** The four-byte SAV test used a one-byte walk with an inclusive size bound. The remaining size -= i / size < line_size logic still bails out on a short tail, so this is an **overread**, not a later overflow write.
**Step 2.4: Fix quality**
Record:
- **Obviously correct:** the predicate now matches the 4-byte access. Same pattern as the sibling cx18 fix (bf533acaaa7de).
- **Minimal:** one loop condition, no API/data-structure change.
- **Regression risk: very low.** If size < 4, the loop does not run, i stays 0, then size < line_size (51/272/284) returns as before. A 4-byte SAV at the last valid position is still seen (i + 3 < size allows i == size-4).
---
## Phase 3: Git history
**Step 3.1: Blame**
Record: The scan loop (including buf[3]) was introduced in **1a0adaf37c30e** — *V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder* (Hans Verkuil, **2007-04-27**). The bug is as old as the driver.
**Step 3.2: Fixes: tag**
Record: **No Fixes: tag.** The introducing commit is the original ivtv merge (1a0adaf37c30e), present in this tree (git merge-base --is- ancestor exit 0).
**Step 3.3: File history**
Record: Recent commits on this file are email-address churn, an uninitialized vbi.type fix (31218df77e7f1), SPDX, and this bounds fix. **No prerequisite refactor.** Standalone; not patch X/Y.
**Step 3.4: Author**
Record: Pengpeng Hou’s only ivtv commit is this one. Same day/author/message as **bf533acaaa7de** (media: cx18: stop VBI start- code scan before short tail). Hans Verkuil applied both; he is the long-time V4L maintainer and original ivtv author. That is a strong quality signal.
**Step 3.5: Dependencies**
Record: **None.** The loop, sav argument, and buf[3] access already exist. The cx18 sibling is independent (different driver). **Applies standalone.**
---
## Phase 4: Mailing list / external
**Step 4.1: Original discussion**
Record:
- b4 dig -c f373cf17fb8e7 →
https://patch.msgid.link/2026063008027101.2-ccfa108-0015-media-ivtv-
[email protected]
- b4 dig -a: **v1 only** (2026-06-30), no later revisions.
- Saved mbox: **patch only, no replies.** No NAK, no reviewer commentary, no in-thread Cc: stable.
- lore.kernel.org HTML fetch returned **403** (Anubis bot-wall). Thread content was recovered via b4 dig -m.
**Step 4.2: Recipients (b4 dig -w)**
Record: To/Cc included **Andy Walls** (IVTV maintainer in MAINTAINERS), **Mauro Carvalho Chehab**, [email protected], linux- [email protected]. Applied by **Hans Verkuil**.
**Step 4.3: Bug report**
Record: **No user/syzbot/bugzilla report.** Looks like a static- analysis/audit fix (author has many similar bounds patches). The mechanism is still a real OOB read, verified from the code.
**Step 4.4: Related series**
Record: Paired with **cx18** commit bf533acaaa7de (same wording, same day). Each is self-contained. This ivtv commit does not need the cx18 change.
**Step 4.5: Stable list**
Record: **UNVERIFIED** — lore.kernel.org/stable returned 403. No evidence in-tree of a prior rejection.
---
## Phase 5: Semantic / call-chain
**Step 5.1: Functions**
Record: compress_sliced_buf() only.
**Step 5.2: Callers**
Record: Only ivtv_process_vbi_data() in the same file, twice:
```398:404:drivers/media/pci/ivtv/ivtv-vbi.c
lines = compress_sliced_buf(itv, 0, p, size / 2,
itv->vbi.sliced_decoder_sav_odd_field);
/* second field */
/* experimentation shows that the second half does not
always begin
at the exact address. So start a bit earlier (hence
32). */
lines = compress_sliced_buf(itv, lines, p + size / 2 -
32, size / 2 + 32,
itv->vbi.sliced_decoder_sav_even_field);
```ivtv_process_vbi_data() callers:
- ivtv_get_buffer() in ivtv-fileops.c (userspace read of MPEG/VBI streams)
- dma_post() in ivtv-irq.c (decoder VBI DMA completion)
**Step 5.3: Callees**
Record: After the scan, v4l2_subdev_call(..., decode_vbi_line, ...). The OOB is in the scan itself, before that call.
**Step 5.4: Reachability**
Record: Reachable when sliced VBI capture/processing runs on **Hauppauge PVR-150/250/350/500** (and other cx23415/cx23416 cards), CONFIG_VIDEO_IVTV. Needs the hardware; not a generic syscall fuzz path. Real for those devices.
**Step 5.5: Similar patterns**
Record: cx18 had the identical bug and the same one-line fix. compress_raw_buf() indexes p[0..3] at buf + i * line_size with i < lines, a different bound; not the same bug.
---
## Phase 6: This tree
**Step 6.1: Local tree and buggy code**
Record:
- git describe HEAD → **v7.3-rc4-27-gf0100363d8c37** (VERSION=7, PATCHLEVEL=3, SUBLEVEL=0, EXTRAVERSION=-rc4)
- Candidate **f373cf17fb8e7 is already an ancestor of HEAD**
- Buggy loop existed here from **2007** until that commit; pre-image confirmed via git show f373cf17fb8e7^:drivers/media/pci/ivtv/ivtv- vbi.c
This checkout is **7.3-rc4 mainline**, not an older -stable branch. The bug class and the surrounding code are the same ones every current LTS still carries.
**Step 6.2: Backport difficulty**
Record: **Clean apply.** The for (i = 0; i < size; i++, buf++) line has been unchanged since 2007.
**Step 6.3: Related fixes already here**
Record: Only this commit and the cx18 sibling. No alternate ivtv fix for the same scan.
---
## Phase 7: Subsystem context
**Step 7.1**
Record: **media/pci/ivtv** — Hauppauge PVR / Conexant cx2341x MPEG encoder. **PERIPHERAL** (specific old PCI capture cards), but a supported in-tree driver, not staging.
**Step 7.2**
Record: The file is **mature/quiet**. The driver has been stable for years; this is a long-standing latent bounds bug, not fallout from a new feature.
---
## Phase 8: Impact and risk
**Step 8.1: Who is affected**
Record: **Driver-specific / config-specific** (CONFIG_VIDEO_IVTV), users capturing **sliced VBI** on those cards.
**Step 8.2: Trigger**
Record: Hardware DMA fills an ivtv buffer; ivtv_process_vbi_data() scans for SAV. Fires whenever the start code is missing or near the tail (including a full walk with no match). Unprivileged users can hit it if they can open the V4L VBI/MPEG node. Not a remote network path.
Buffers are kmalloc(s->buf_size + 256) and DMA last-SG size is also += 256 (ivtv-queue.c, ivtv-irq.c). dma_post() may do buf->bytesused += s->dma_last_offset (cookie search up to 252 bytes). A 3-byte overread of the **logical** size often still sits inside that 256-byte DMA window, so a crash is not guaranteed; it is still an out- of-bounds access relative to the length the scan is given, and bytesused can sit close to the allocation.
**Step 8.3: Failure mode**
Record: **Out-of-bounds read (up to 3 bytes).** Severity **MEDIUM–HIGH** as memory safety; practical oops risk **MEDIUM** (small overread, extra DMA padding). Remaining length after a false SAV in the tail is < 4, so size < line_size returns without treating the overread as payload. **Not data corruption of the VBI output**, but a real buffer-tail overread.
**Step 8.4: Risk–benefit**
Record:
- **Benefit:** stops a real OOB read on a path that runs during VBI capture; same class as other stable OOB one-liners; bug present on every LTS.
- **Risk:** one loop bound, no locking/API change — **very low**.
- **Ratio:** strongly favors taking the fix.
---
## Phase 9: Synthesis
**Step 9.1: Evidence**
For:
- Real 4-byte load on a 1-byte scan; last iterations read past size
- One-line, obviously correct, no new API
- Bug in tree since 2007 (1a0adaf37c30e); clean apply
- Applied by Hans Verkuil; To: Andy Walls (ivtv maintainer)
- Sibling cx18 fix of the same bug
- Standalone; no series dependency
Against:
- No crash/syzbot/Reported-by
- Niche, aging PCI hardware
- +256 DMA/kmalloc padding makes a guaranteed heap oops less likely
- No mailing-list review comments (v1 applied as-is)
Unresolved:
- Stable-list discussion (lore 403)
- Exact KASAN behavior vs. the +256 allocation (not reproduced here)
**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** — bound matches the 4-byte access; maintainer applied it; v1 needed no respin.
2. Real bug affecting users? **PASS** — OOB read on sliced-VBI processing for ivtv hardware.
3. Important (crash/security/corruption/deadlock)? **PASS** — memory- safety OOB read; practical crash is not certain, but this is the standard small OOB class, not a style tweak.
4. Small and contained? **PASS** — 1 line, one function.
5. No new features/APIs? **PASS**
6. Can apply to this tree? **PASS** — already in 7.3-rc4; pre-fix line is the original 2007 loop, so older stables should take it cleanly.
**Step 9.3: Exception category**
Record: Not a device-ID/quirk/DT/build/doc exception. It is a **small memory-safety fix**.
**Step 9.4: Decision**
The commit is a one-line, obviously correct stop of a four-byte SAV scan that walked off the declared VBI buffer. That bug has been in ivtv since 2007, needs no prerequisites, and is the same fix already used on cx18. It belongs in stable.
---
## Verification
- **[Phase 1]** Parsed tags: only author + Hans Verkuil SOBs; no Fixes/Reported-by/Cc: stable
- **[Phase 2]** Diff: 1 line in compress_sliced_buf(); i < size → `i
+ 3 < size`
- **[Phase 2]** Confirmed buf[0]..buf[3] SAV test in current file at lines 333–335
- **[Phase 3]** git blame: loop from 1a0adaf37c30e (2007-04-27); bound line is this commit
- **[Phase 3]** git merge-base --is-ancestor 1a0adaf37c30e HEAD → yes
- **[Phase 3]** git show f373cf17fb8e7^:...ivtv-vbi.c → old i < size loop present
- **[Phase 3]** File log: no prerequisite refactor; sibling bf533acaaa7de is cx18-only
- **[Phase 4]** b4 dig -c f373cf17fb8e7: lore/msgid link above; b4 dig -a: v1 only
- **[Phase 4]** b4 dig -w: Andy Walls, Mauro Chehab, linux-media, linux-kernel
- **[Phase 4]** b4 dig -m: 81-line mbox, patch only, no replies
- **[Phase 4]** WebFetch/curl to lore: 403 — stable-list search UNVERIFIED
- **[Phase 5]** Callers: ivtv_process_vbi_data ← ivtv-fileops.c, ivtv-irq.c
- **[Phase 5]** cx18 compress_sliced_buf uses the same i + 3 < size bound after bf533acaaa7de
- **[Phase 6]** git describe HEAD = v7.3-rc4-27-g…; make kernelversion = 7.3.0-rc4
- **[Phase 6]** git merge-base --is-ancestor f373cf17fb8e7 HEAD → already in this tree
- **[Phase 7]** MAINTAINERS: IVTV → Andy Walls, linux-media
- **[Phase 8]** kmalloc buf_size+256 and DMA size += 256 / bytesused += dma_last_offset verified in ivtv-queue.c and ivtv- irq.c
- **UNVERIFIED:** whether this overread was ever KASAN-reported; whether stable@ discussed it
The fix is small, surgical, and meets the stable criteria for an out-of- bounds read.
**YES**
drivers/media/pci/ivtv/ivtv-vbi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/ivtv/ivtv-vbi.c +1 -1
@@ -330,7 +330,7 @@ static u32 compress_sliced_buf(struct ivtv *itv, u32 line, u8 *buf, u32 size, u8unsigned lines =0 ;/* find the first valid line */ -for (i =0 ; i < size; i++, buf++) { +for (i =0 ; i +3 < size; i++, buf++) {if (buf[0 ] ==0xff && !buf[1 ] && !buf[2 ] && buf[3 ] == sav)break ; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ACPI: button: Add DMI quirk for Razer Blade Pro 17 early 2020 lid switch
In reply to Sasha LevinFrom: Robin Everaars <[email protected]>
[ Upstream commit 415125669c2ddc773c579a60df108f75712dfa83 ]
The lid switch reports "close" but can miss the matching "open", leaving _LID closed after resume. systemd-logind then suspends the system again roughly every 35 seconds.
Reading the embedded controller's PSTA byte while _LID is stale shows that bit 0x04 is set, which the DSDT treats as open. The DSDT returns the cached LIDS byte from _LID. Its wake path aborts in RTEC on an unhandled SystemCMOS region before copying PSTA to LIDS.
Initialize the lid state to open on resume, matching the existing quirk for the Razer Blade Stealth 13 late 2019. With button.lid_init_state=open, a physical close suspended once and resume reported open without another suspend.
---
LLM Generated explanations, may be completely bogus:
I have enough to decide: this is a DMI-scoped lid quirk, the buggy path exists in 6.12, and the patch applies here.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [ACPI] [Add] [DMI quirk for Razer Blade Pro 17 early 2020 lid switch]
Subsystem prefix: ACPI: button:. Action verb: **Add**. Claimed intent:
add a DMI match so this laptop initializes lid state as open, matching an existing Razer quirk.
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Robin Everaars <[email protected]> (author)
- Link:
https://patch.msgid.link/[email protected]
- Signed-off-by: Rafael J. Wysocki <[email protected]> (ACPI maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Cc:
stable (absence expected for this review)
- Ignore any pipeline "Upstream commit" / "Signed-off-by: Sasha Levin" markers
Notable: ACPI maintainer applied it. No syzbot/KASAN. Hardware-quirk report from the machine owner.
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: lid reports "close" but can miss the matching "open"; _LID stays closed after resume.
- Symptom: systemd-logind re-suspends roughly every 35 seconds (suspend loop).
- Root cause (firmware): EC PSTA bit 0x04 is set (DSDT treats that as open), but _LID returns cached LIDS. Wake path aborts in RTEC on an unhandled SystemCMOS region before copying PSTA to LIDS.
- Fix: DMI quirk ACPI_BUTTON_LID_INIT_OPEN, same as Razer Blade Stealth 13 late 2019.
- Test: with button.lid_init_state=open, a physical close suspended once; resume reported open; no second suspend.
- Version info: none in the message. Commit is in v7.3-rc1 (git describe --contains → v7.3-rc1~39^2^3).
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. It is an explicit hardware quirk for a firmware lid bug. The "Add" verb here is the standard DMI-quirk exception, not a new feature.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/acpi/button.c (+11 / -0)
- Function/data: dmi_lid_quirks[] only
- Scope: single-file surgical DMI table addition
- Commit: 415125669c2ddc773c579a60df108f75712dfa83
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: this DMI identity is unmatched; acpi_button_register_driver() sets lid_init_state = ACPI_BUTTON_LID_INIT_METHOD (evaluate _LID).
- After: match vendor "Razer" + product "Blade Pro 17 (Early 2020) - RZ09-0329" → ACPI_BUTTON_LID_INIT_OPEN.
- Affected path: lid init on first userspace open (acpi_lid_input_open) and on resume (acpi_button_resume → acpi_lid_initialize_state → acpi_lid_notify_state(device, 1)).
- Other machines: unchanged (dmi_first_match is exact).
Step 2.3: IDENTIFY THE BUG MECHANISM
Record: [Hardware workaround / DMI quirk]
Broken: firmware _LID stuck closed after resume; userspace treats that as lid-closed and suspends again.
Fix: report lid open on init/resume for this DMI ID, same as existing Razer/Medion/Samsung entries.
Step 2.4: ASSESS THE FIX QUALITY
Record: Obviously correct and minimal. Regression risk is confined to this DMI string. If the lid is truly closed at resume from another wakeup source, init-open can delay one close report until the next close notify; that is the established tradeoff for this quirk class (Stealth 13 late 2019, Medion, Samsung). No API/locking/refcount changes.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record: Insertion is between:
- 0528904926aab (2020-01-02) Razer Blade Stealth 13 late 2019, same ACPI_BUTTON_LID_INIT_OPEN pattern
- 8fa73ee44daef (2024-10-20) Samsung Galaxy Book2, same pattern, `Cc:
All applicable <[email protected]>`
- Table exists since d7cd08231a7fa (2019-10-28)
The "bug" is firmware on a 2020 laptop; the kernel quirk table has been in this driver for years.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Not applicable. Firmware defect, not a kernel regression from a specific SHA.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record (this tree, last 20 on drivers/acpi/button.c): other DMI lid quirks (Lenovo Yoga 9, Medion E2228T, Nextbook Ares 8A, Samsung Galaxy Book2) plus unrelated notify/input_free_device changes. No prerequisite refactor required for this table entry.
Standalone, not patch X/Y.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: git log --author='Robin Everaars' -- drivers/acpi/ is empty in this tree. Author is a hardware reporter, not the ACPI maintainer. Weight comes from Rafael applying it and from matching an existing quirk.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: Depends only on dmi_lid_quirks[] and ACPI_BUTTON_LID_INIT_OPEN, both present. Later mainline converted acpi_button_add → acpi_button_probe; that is after 6.12 and not required. A later mailing-list patch for Blade Stealth 13 Early 2020 (RZ09-0310) is a sibling quirk, not a dependency. Can apply standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 415125669c2dd:
https://patch.msgid.link/[email protected]
- b4 dig -a: v1 msgid [email protected], v2 same code; v1 was unapplicable because Proton OpenPGP/MIME inserted line breaks. No logic review changes.
- Rafael: "Applied as 7.3-rc material, thanks!" No NAK, no stable discussion in-thread.
- lore.kernel.org WebFetch returned 403; discussion recovered via b4, Patchew, and openwall.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To/Cc Rafael J. Wysocki, Len Brown, linux-acpi, linux-kernel. Maintainer applied it. No extra Reviewed-by.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No bugzilla/syzbot Link. Evidence is the author's firmware analysis (PSTA vs LIDS/RTEC) and the lid_init_state=open test. Same class as the 2020 Stealth 13 quirk ("systemd continuously re-suspend the laptop every 30s"). UserBenchmark/Geekbench and linux-hardware.org Razer probes support the product-name form Blade … - RZ09-xxxx with vendor Razer.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone v2. Related later proposal: Ian Gallagher, Blade Stealth 13 Early 2020 RZ09-0310, which cites this Pro 17 entry as already in tree. Not required for this backport.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: WebSearch of lore.kernel.org/stable for this model found no prior stable request or rejection. UNVERIFIED at the individual-message level because lore WebFetch is 403.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: No function body changed. Data: dmi_lid_quirks[]. Consumers:acpi_button_register_driver(), acpi_lid_initialize_state().
Step 5.2: TRACE CALLERS
Record:
- acpi_button_register_driver(): module/driver init; dmi_first_match(dmi_lid_quirks) if lid_init_state == -1.
- acpi_lid_initialize_state(): from acpi_button_resume() (CONFIG_PM_SLEEP) and acpi_lid_input_open() (userspace opens /dev/input lid switch).
- Not IRQ/hot-path; boot and resume/open.
Step 5.3: TRACE CALLEES
Record: ACPI_BUTTON_LID_INIT_OPEN → acpi_lid_notify_state(device, 1) reports SW_LID open. No alloc/new locks.
Step 5.4: FOLLOW THE CALL CHAIN
Record: Userspace-reachable: logind/systemd reads the lid input device and acts on SW_LID. Trigger is close-lid suspend then resume with lid open — normal laptop use. Unprivileged user can trigger by closing the lid.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same ACPI_BUTTON_LID_INIT_OPEN DMI entries already in this tree for Lenovo 82BG, Medion E2215T/E2228T, Razer Stealth 13 Late 2019, Samsung 750XED. This is another instance of a known firmware class, not a new mechanism.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record:
- Tree: pending-6.12, git describe HEAD = p-6.12-3-gc504cf0baa3d8, make kernelversion = **6.12.111**
- dmi_lid_quirks[] present; Stealth 13 quirk present; **no** RZ09-0329 / Blade Pro 17 entry
- git merge-base --is-ancestor 415125669c2dd HEAD → not an ancestor (not in this tree)
- Quirk infrastructure since 2019; bug is firmware on 2020 hardware, relevant to 6.12
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: git show 415125669c2dd | git apply --check succeeded (hunk at line 130, offset -3). Difference vs mainline is later acpi_button_probe conversion, not the DMI table. Expected: **clean apply**.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No RZ09-0329 match. No other 6.12 commit with this subject (git log --grep='Razer Blade Pro 17' -- drivers/acpi/button.c empty). Samsung/Stealth 13 quirks are related pattern, not a substitute for this DMI ID.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [ACPI button / laptop lid] [IMPORTANT] CONFIG_ACPI_BUTTON default y. Lid events drive suspend on essentially all ACPI laptops. Not mm/core, but suspend-loop is user-visible stability.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: This 6.12 file is mature (quirks since 2019). Mainline later did a large button.c rework (platform device, devres); that churn is **not** in this tree. The DMI table is the stable part.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver-specific / DMI-specific: Razer Blade Pro 17 Early 2020 (RZ09-0329) only. ACPI button is default-y, so those laptops on 6.12 are in scope.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Close lid → suspend → open lid/resume. Common laptop path. Unprivileged user can trigger. Not a narrow error path.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: [Suspend loop ~every 35s] [HIGH]
Not a panic, but the machine cannot stay awake after lid-wake. Matches historical "systemd re-suspend every 30s" reports. Data-loss risk if unsaved work is interrupted by repeated suspend.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: HIGH for that model (fixes unusable suspend/resume)
- Risk: VERY LOW (11-line DMI entry, no other machines)
- Ratio: strongly favors backport
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real user-visible bug: lid stuck closed → logind suspend loop
- Hardware quirk exception (DMI table), explicitly allowed in stable
- Same mechanism as Stealth 13 late 2019 (in this tree since 2020) and Samsung Galaxy Book2 (Cc: stable)
- 11 lines, one file, no APIs
- Applies cleanly to 6.12.111
- ACPI maintainer applied as 7.3-rc
- Author tested lid_init_state=open
- DMI product string matches later Razer naming (Blade … - RZ09-xxxx)
AGAINST:
- Affects one laptop model, not all users
- No Fixes:/Cc: stable in the commit (expected; not a negative)
- Author tested the module param; DMI match correctness is inferred from the string they submitted (if wrong, quirk is a no-op, not a regression)
UNRESOLVED:
- lore.kernel.org HTTP 403; thread recovered via b4/Patchew/openwall
- No independent kernel bugzilla duplicate found
- Stable list not confirmed message-by-message (search found nothing)
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — copy of existing quirk; author + maintainer
2. Fixes a real bug that affects users? **PASS** — suspend loop after resume
3. Important issue? **PASS** — HIGH: system re-suspends every ~35s (hang/unusable, not a panic)
4. Small and contained? **PASS** — +11 lines, one DMI entry
5. No new features or APIs? **PASS** — quirk table only
6. Can apply to the local tree? **PASS** — git apply --check clean; table present
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: **Hardware quirk/workaround** (DMI lid_init_state). Automatic stable-qualifier.
Step 9.4: MAKE YOUR DECISION
This tree is 6.12.111. The quirk table and ACPI_BUTTON_LID_INIT_OPEN exist; the RZ09-0329 entry does not. The patch is a small, model-scoped workaround for a firmware lid bug that leaves the laptop in a suspend loop. That is exactly the class of DMI quirk stable already carries for this driver.
What it solves for 6.12 users: after closing the lid, resume can leave _LID closed while the lid is open; systemd-logind then suspends again. The quirk reports open on resume for this DMI ID only.
Risk vs benefit: benefit is restoring normal lid/suspend on this 2020 Razer; risk is a no-op on every other machine.
No dependencies, no backport rework, no new API.
Verification:
- [Phase 1] Parsed tags: author SOB, Rafael SOB, Link msgid [email protected]; no Fixes/Reported- by/Cc: stable
- [Phase 1] Body: _LID stale closed after resume; logind re-suspend ~35s; PSTA/LIDS/RTEC firmware explanation; tested button.lid_init_state=open
- [Phase 2] Diff: +11 lines in dmi_lid_quirks[] only; ACPI_BUTTON_LID_INIT_OPEN for Razer / Blade Pro 17 (Early 2020) - RZ09-0329
- [Phase 2] Local acpi_lid_initialize_state() OPEN case calls acpi_lid_notify_state(device, 1); resume and acpi_lid_input_open both call it
- [Phase 3] Blame: Stealth 13 quirk 0528904926aab (2020); Samsung 8fa73ee44daef (2024, Cc: stable); table from d7cd08231a7fa (2019)
- [Phase 3] No Fixes: tag; standalone; no Robin Everaars history in this ACPI tree
- [Phase 4] b4 dig -c 415125669c2dd: v2 URL; b4 dig -a: v1→v2, PGP wrapping only; b4 dig -w: Rafael, Len Brown, linux-acpi
- [Phase 4] Patchew: Rafael "Applied as 7.3-rc material, thanks!"; no NAK
- [Phase 4] lore WebFetch 403; UNVERIFIED raw lore HTML
- [Phase 5] Callers: acpi_button_register_driver (init), acpi_button_resume, acpi_lid_input_open; userspace lid/logind path
- [Phase 5] Similar OPEN quirks already in this file for Lenovo/Medion/Razer/Samsung
- [Phase 6] git describe HEAD p-6.12-3-gc504cf0baa3d8; kernelversion 6.12.111; merge-base --is-ancestor 415125669c2dd HEAD false
- [Phase 6] git apply --check succeeded at offset -3
- [Phase 6] Grep: no RZ09-0329 in this tree
- [Phase 7] MAINTAINERS ACPI: Rafael Wysocki; CONFIG_ACPI_BUTTON default y
- [Phase 8] Failure mode: suspend loop; severity HIGH; DMI-scoped; risk very low
- [Phase 3/4] Commit 415125669c2dd is v7.3-rc1~39^2^3 on origin/master
- UNVERIFIED: individual stable@ thread bodies (lore 403); exact dmidecode dump of the author's machine (string is consistent with other 2020+ Razer DMI names)
**YES**
drivers/acpi/button.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/acpi/button.c +11 -0
@@ -132,6 +132,17 @@ static const struct dmi_system_id dmi_lid_quirks[] = { }, .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_OPEN, }, + { +/* +* Razer Blade Pro 17 early 2020, notification of the LID device +* only happens on close, not on open and _LID keeps returning closed. +*/ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Razer" ), + DMI_MATCH(DMI_PRODUCT_NAME, "Blade Pro 17 (Early 2020) - RZ09-0329"), + }, + .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_OPEN, + }, {/* * Samsung galaxybook2 ,initial _LID device notification returns
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 drm/virtio: reclaim pending vbufs before tearing down vqs
In reply to Sasha LevinFrom: Anuj Bolewar <[email protected]>
[ Upstream commit 61d85f99b5a55d4f717c4bb2f4c4acabf22ee3fc ]
virtio_gpu_free_vbufs() destroys the vbufs kmem_cache after the virtqueues have already been released. Commands that were queued but never completed by the device leave their vbuffers stranded in the virtqueue, so the cache still holds live objects when virtio_gpu_deinit() tears everything down. This triggers a WARNING in virtio_gpu_free_vbufs:
BUG virtio-gpu-vbufs (Not tainted): Objects remaining in cache on __kmem_cache_shutdown()
Drain any buffers still sitting in the control and cursor virtqueues in virtio_gpu_deinit() after the device has been reset and before the virtqueues are deleted, following the same pattern used by virtio_console's remove_vqs(). Each reclaimed buffer is released with free_vbuf(), dropping the reference on any GEM objects it holds. Pending RESOURCE_UNREF commands are handled as well: their resp_cb_data still references a GEM object, so it is cleaned up with virtio_gpu_cleanup_object() to avoid leaking it on teardown.
---
LLM Generated explanations, may be completely bogus:
# Stable backport analysis: drm/virtio: reclaim pending vbufs before tearing down vqs
Local tree: **6.12.111** (p-6.12-3-gc504cf0baa3d8). Verdict is for this checkout only.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [drm/virtio] [reclaim] [drain leftover virtqueue buffers before destroying vbufs cache]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Reported-by: [email protected] — fuzzer-found, reproducible
- Closes: https://syzkaller.appspot.com/bug?extid=06f9b2a53ba4a5a47644
- Signed-off-by: Anuj Bolewar <[email protected]> (author)
- Signed-off-by: Dmitry Osipenko <[email protected]> (virtio-gpu maintainer)
- `Link: https://patch.msgid.link/20260802-virtio-gpu-reclaim-
[email protected]`
- No Fixes: tag (expected for this review pipeline)
- Ignore pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] if present
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** virtio_gpu_free_vbufs() calls kmem_cache_destroy() after VQs are already deleted. In-flight commands stay attached to the virtqueue, so the virtio-gpu-vbufs cache still has live objects.
- **Symptom:** SLUB BUG virtio-gpu-vbufs: Objects remaining on __kmem_cache_shutdown() plus WARNING in virtio_gpu_free_vbufs / kmem_cache_destroy, on device removal.
- **Root cause:** virtio_gpu_deinit() does virtio_reset_device() then del_vqs() without draining unused buffers.
- **Fix:** After reset, before del_vqs(), detach leftover buffers (same idea as virtio_console remove_vqs()), free_vbuf() them, drop GEM arrays, and virtio_gpu_cleanup_object() pending RESOURCE_UNREF GEM objects.
- **Version info:** none in the message; code has been this way for years.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Explicit leak/WARNING fix on teardown. v2 also closes a GEM leak for stranded RESOURCE_UNREF commands.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- drivers/gpu/drm/virtio/virtgpu_drv.h: +1 declaration
- drivers/gpu/drm/virtio/virtgpu_kms.c: +1 call in virtio_gpu_deinit()
- drivers/gpu/drm/virtio/virtgpu_vq.c: +15, new virtio_gpu_reclaim_vbufs()
- **Total: +17 / −0.** Single-subsystem surgical fix.
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** virtio_gpu_deinit() flushes work, resets the device, deletes VQs. Later virtio_gpu_release() → virtio_gpu_free_vbufs() → kmem_cache_destroy(vgdev->vbufs) with any still-queued vbuffers live.
- **After:** Same sequence, plus virtio_gpu_reclaim_vbufs() between reset and del_vqs(). Control queue: detach unused bufs, put GEM arrays, cleanup resp_cb_data, free_vbuf(). Cursor queue: detach and free_vbuf().
- Path: device removal / unbind / probe-fail after successful virtio_gpu_init().
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** resource leak + teardown WARNING (stranded slab objects; GEM refs left held).
- **Mechanism:** virtqueue_detach_unused_buf() after reset, then existing free_vbuf() / virtio_gpu_array_put_free() / virtio_gpu_cleanup_object().
- In this tree resp_cb_data is only set in virtio_gpu_cmd_unref_resource() to a struct virtio_gpu_object *, so the extra cleanup is specific and correct here.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: documented virtio shutdown helper; same pattern as virtio_console.
- Minimal; no API/feature additions.
- Regression risk is low. After drm_dev_unplug(), drm_dev_enter() fails, so array_put_free() → last GEM put → virtio_gpu_cmd_unref_resource() takes the existing -ENODEV path (free_vbuf + virtio_gpu_cleanup_object) instead of re-queuing. Both VQs are always created in virtio_gpu_init() (vqs[0]/vqs[1]), so no NULL cursorq.vq on the deinit path.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- virtio_gpu_free_vbufs() / kmem_cache_destroy: f5985bf9cadd4e (Gerd Hoffmann, 2017-03-01, “drm: virtio: use kmem_cache”) — ancestor of this HEAD.
- virtio_gpu_deinit() body: dc5698e80cf724 (Dave Airlie, 2013) plus later virtio_reset_device() (d9679d0013a668, 2021).
- Bug is old; present throughout 6.12.y.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable. Buggy teardown is in this tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent virtio GPU work here is unrelated (EDID bounds, deadlock, fence, KMS removal). No reclaim helper already present. cec7f1774605a is a different probe double-free. Standalone patch, not “X/Y” of a larger series (cover said “Patch 1” of a 1-patch series).
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Anuj Bolewar has no virtio GPU commits in this tree. Dmitry Osipenko is the virtio-gpu maintainer (SOB + “Applied to drm-misc- fixes”).
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Uses virtqueue_detach_unused_buf, free_vbuf, virtio_gpu_array_put_free, virtio_gpu_cleanup_object — all present. No panic-path helpers required. Can apply standalone.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c <sha> cannot match: commit is not in this tree (candidate only).
- Lore search via lore.kernel.org returned 403.
- Recovered from Openwall/LKML:
- v1: drain only (objs + free_vbuf)
- v2: also virtio_gpu_cleanup_object(resp_cb_data)
- Applied version is v2
- Dmitry Osipenko, 2026-08-14: **“Applied to drm-misc-fixes, thanks!”** — no NAK.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: Recipients included Airlie, Hoffmann, Osipenko, Gurchetan Singh, Chia-I Wu, dri-devel, virtualization, syzkaller-bugs. Maintainer applied it. No NAK found.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record (syzkaller, extid 06f9b2a53ba4a5a47644):
- Title: WARNING in virtio_gpu_free_vbufs
- Labels: prio:high
- Assessment: DenialOfService exploitable; VM guest and host trigger; not unprivileged
- Stack: kmem_cache_destroy → virtio_gpu_free_vbufs → virtio_gpu_release → drm_dev_put → virtio_dev_remove → PCI remove_store
- 13 crashes; first ~2026-07-29
- Syzbot lists upstream fix 61d85f99b5a5 (that SHA is not in this tree; git merge-base --is-ancestor was not used on an unknown remote SHA)
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 1-patch series. v2 is the applied leak-complete version.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search 403. **UNVERIFIED** whether stable@ already discussed it. Not used as a NO reason.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: virtio_gpu_reclaim_vbufs (new), virtio_gpu_deinit (call site), free_vbuf, virtio_gpu_array_put_free, virtio_gpu_cleanup_object.
**Step 5.2: TRACE CALLERS**
Record:
- virtio_gpu_deinit() from virtio_gpu_probe error path after virtio_gpu_init() (err_deinit) and from virtio_gpu_remove() after drm_dev_unplug().
- Teardown/unbind, not a hot path.
**Step 5.3: TRACE CALLEES**
Record: virtqueue_detach_unused_buf (documented for shutdown/reset), GEM put, object cleanup, kmem_cache_free.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace/sysfs PCI remove (privileged) or guest virtio-gpu unplug. Syzbot hit it from remove_store. Reachable on any system that unbinds/unplugs virtio-gpu with commands still in the VQ (unresponsive device, hot-unplug, fuzz).
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same drain exists in virtio_console.c remove_vqs(), virtio_net, virtio_crypto, vsock, etc. virtio-gpu was missing it.
semcode: not available; used git grep / file reads.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.**
```283:293:drivers/gpu/drm/virtio/virtgpu_kms.c
void virtio_gpu_deinit(struct drm_device *dev)
{
...
virtio_reset_device(vgdev->vdev);
vgdev->vdev->config->del_vqs(vgdev->vdev);
}
``````83:87:drivers/gpu/drm/virtio/virtgpu_vq.c
void virtio_gpu_free_vbufs(struct virtio_gpu_device *vgdev)
{
kmem_cache_destroy(vgdev->vbufs);
vgdev->vbufs = NULL;
}
```virtio_gpu_reclaim_vbufs is **not** in this tree. git log --grep='reclaim pending vbufs' on those files: empty.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply expected.** Actual v2 context matches 6.12 (no panic helpers required). Line numbers differ slightly; 3-line context around reset/del_vqs and free_vbuf/reclaim_vbufs is the same.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No equivalent drain. KMS-disabled removal fix 38a5f891cda6d is unrelated (atomic shutdown).
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: drivers/gpu/drm/virtio — **IMPORTANT** for VMs/QEMU guests (common virtio-gpu), not core mm/VFS. Not staging.
**Step 7.2: SUBSYSTEM ACTIVITY**
Record: Mature driver (2013+), still receiving 6.12 stable fixes. Bug is long-standing, not a brand-new subsystem.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Record: virtio-gpu users (CONFIG_DRM_VIRTIO_GPU) — QEMU/KVM/cloud VMs, driver unbind, PCI remove, module unload.
**Step 8.2: TRIGGER CONDITIONS**
Record: Device teardown with commands still on the control/cursor VQ.
Syzbot: PCI remove. Privileged on the host; a VM guest can trigger it. Not every boot, but a realistic hot-unplug/reset path.
**Step 8.3: FAILURE MODE SEVERITY**
Record:
- kmem_cache_destroy() **always** WARNs if objects remain (mm/slab_common.c ~547), not only CONFIG_SLUB_DEBUG.
- With SLUB_DEBUG, additional slab_bug / __slab_err.
- If shutdown fails, the cache is **not** released (if (err) return) → cache leak plus leaked vbufs/GEM.
- Syzbot: DoS, prio:high.
- Severity: **HIGH** (kernel WARNING/taint, resource leak on remove; panic if panic_on_warn).
**Step 8.4: RISK-BENEFIT RATIO**
Record: **Benefit high** (stops WARNING + leak on a common VM GPU driver). **Risk low** (17 lines, existing helpers, maintainer-acked). Ratio favors backport.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: EVIDENCE**
**FOR:**
- Real, syzbot-reproduced teardown bug
- Unconditional WARN + slab/GEM leak
- virtio-gpu is widely used in VMs on 6.12 LTS
- Small, obviously correct drain matching other virtio drivers
- All callees exist here; bug exists here
- Maintainer applied v2 to drm-misc-fixes
**AGAINST:**
- Trigger is device removal, not a hot path
- Needs privilege / VM unplug (not a local unprivileged syscall crash)
- No Fixes: / stable Cc in the original (not a negative under these rules)
**UNRESOLVED:**
- lore.kernel.org 403; stable@ discussion not fetched
- b4 dig could not resolve a SHA that is not in this tree
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — v2, syzbot, maintainer applied
2. Real user-visible bug? **PASS** — WARNING + leak on virtio-gpu remove
3. Important (crash/leak/DoS)? **PASS** — HIGH; syzbot prio:high / DoS
4. Small and contained? **PASS** — +17 lines, 3 files, one driver
5. No new features/APIs? **PASS** — internal helper only
6. Applies to local tree? **PASS** — buggy code present; helpers present
**Step 9.3: EXCEPTION CATEGORIES**
Record: Not ID/quirk/DT/docs. Ordinary important bugfix.
**Step 9.4: DECISION**
This tree has the bug and the dependencies. The fix is small, matches established virtio teardown, and stops a syzbot-confirmed WARNING plus object leak on virtio-gpu teardown. It should be backported to this 6.12 tree.
---
## What the commit solves for stable users
On virtio-gpu unbind/unplug, in-flight command buffers stay in the virtqueues. Destroying the virtio-gpu-vbufs cache then WARNs and leaks those buffers and any GEM objects they hold (including pending RESOURCE_UNREF). 6.12 guests using virtio-gpu hit this on device removal.
## Risk vs benefit
Benefit: no WARN/taint and no leaked GEM/vbufs on a common VM driver.
Risk: low; one drain after reset, before del_vqs(), using APIs already in 6.12.
## Concerns
None that block backport. Header context in some expanded diffs mentions later panic helpers; the real v2 hunk does not need them. Apply as the 17-line v2.
---
## Verification
- **[Phase 1]** Tags: syzbot Reported-by, Closes syzkaller URL, Osipenko SOB
- **[Phase 2]** Diff: +17 across 3 virtio GPU files; drain after reset
- **[Phase 2]** resp_cb_data only assigned in virtio_gpu_cmd_unref_resource() in this tree
- **[Phase 3]** git describe HEAD / Makefile: 6.12.111; p-6.12-3-gc504cf0baa3d8
- **[Phase 3]** blame: kmem_cache_destroy in virtio_gpu_free_vbufs since f5985bf9cadd4e (2017); deinit without drain since original driver
- **[Phase 3]** git log --grep='reclaim pending vbufs' -- drivers/gpu/drm/virtio/: not present
- **[Phase 4]** Openwall v2 + LKML: Osipenko “Applied to drm-misc-fixes”
- **[Phase 4]** syzbot: WARNING in virtio_gpu_free_vbufs, prio:high, PCI remove stack, 13 crashes
- **[Phase 4]** lore.kernel.org 403; b4 dig no local commit — UNVERIFIED beyond Openwall/LKML/syzbot
- **[Phase 5]** Callers: virtio_gpu_drv.c probe fail + virtio_gpu_remove
- **[Phase 5]** Both VQs assigned in virtio_gpu_init() lines 217–218
- **[Phase 6]** Local virtio_gpu_deinit / virtio_gpu_free_vbufs match the buggy sequence
- **[Phase 6]** virtqueue_detach_unused_buf, virtio_gpu_array_put_free, virtio_gpu_cleanup_object exist
- **[Phase 8]** kmem_cache_destroy WARNs if __kmem_cache_shutdown returns nonzero (mm/slab_common.c); cache not released on error
- **UNVERIFIED:** whether this SHA is already in some other stable series (irrelevant; not in this tree)
**YES**
drivers/gpu/drm/virtio/virtgpu_drv.h | 1 + drivers/gpu/drm/virtio/virtgpu_kms.c | 1 + drivers/gpu/drm/virtio/virtgpu_vq.c | 15 +++++++++++++++ 3 files changed, 17 insertions(+)
drivers/gpu/drm/virtio/virtgpu_drv.h +1 -0
@@ -355,6 +355,7 @@ void virtio_gpu_array_put_free_work(struct work_struct *work);/* virtgpu_vq.c */ int virtio_gpu_alloc_vbufs (struct virtio_gpu_device *vgdev);void virtio_gpu_free_vbufs (struct virtio_gpu_device *vgdev); +void virtio_gpu_reclaim_vbufs (struct virtio_gpu_device *vgdev); void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev, struct virtio_gpu_object *bo, struct virtio_gpu_object_params *params,
drivers/gpu/drm/virtio/virtgpu_kms.c +1 -0
@@ -289,6 +289,7 @@ void virtio_gpu_deinit(struct drm_device *dev)flush_work (&vgdev->cursorq.dequeue_work);flush_work (&vgdev->config_changed_work);virtio_reset_device (vgdev->vdev); +virtio_gpu_reclaim_vbufs (vgdev); vgdev->vdev->config->del_vqs (vgdev->vdev); }
drivers/gpu/drm/virtio/virtgpu_vq.c +15 -0
@@ -207,6 +207,21 @@ static void free_vbuf(struct virtio_gpu_device *vgdev,kmem_cache_free (vgdev->vbufs, vbuf); } +void virtio_gpu_reclaim_vbufs (struct virtio_gpu_device *vgdev) +{ +struct virtio_gpu_vbuffer *vbuf; + +while ((vbuf =virtqueue_detach_unused_buf (vgdev->ctrlq.vq))) { +if (vbuf->objs) +virtio_gpu_array_put_free (vbuf->objs); +if (vbuf->resp_cb_data) +virtio_gpu_cleanup_object (vbuf->resp_cb_data); +free_vbuf (vgdev, vbuf); + } +while ((vbuf =virtqueue_detach_unused_buf (vgdev->cursorq.vq))) +free_vbuf (vgdev, vbuf); +} +static void reclaim_vbufs (struct virtqueue *vq,struct list_head *reclaim_list) {struct virtio_gpu_vbuffer *vbuf;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-6.1] drm/virtio: reclaim pending vbufs before tearing down vqs
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] drm/virtio: missing pending_commands reset in virtio_gpu_reclaim_vbufs() - [High] drm/virtio: race…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] drm/virtio: missing pending_commands reset in virtio_gpu_reclaim_vbufs()
- [High] drm/virtio: race in virtio_gpu_deinit() flushing work before device reset
- [High] drm/virtio: uninterruptible hang in virtio_gpu_reclaim_vbufs() on imported dmabuf --
commit f24f642758ec3795a40ce21fd3080771f4fdffb2
Author: Anuj Bolewar <[email protected]>
drm/virtio: reclaim pending vbufs before tearing down vqs
This commit drains unused vbuffers from the control and cursor virtqueues in virtio_gpu_deinit() after resetting the device and before deleting the virtqueues, releasing any held GEM object references and pending RESOURCE_UNREF objects before the vbufs kmem_cache is destroyed.
[ ... ]
drivers/gpu/drm/virtio/virtgpu_kms.c void virtio_gpu_deinit(struct drm_device *dev) · line 291
Quoted 11 lines
drivers/gpu/drm/virtio/virtgpu_kms.c +1
-0@@ -286,6 +286,7 @@ void virtio_gpu_deinit(struct drm_device *dev)flush_work (&vgdev->cursorq.dequeue_work);flush_work (&vgdev->config_changed_work);virtio_reset_device (vgdev->vdev); +virtio_gpu_reclaim_vbufs (vgdev); vgdev->vdev->config->del_vqs (vgdev->vdev); }
[Severity: High]
Could flushing the workqueues before virtio_reset_device() in virtio_gpu_deinit() race with virtio_gpu_reclaim_vbufs() and del_vqs()?
In drivers/gpu/drm/virtio/virtgpu_kms.c:virtio_gpu_deinit():
flush_work(&vgdev->obj_free_work); flush_work(&vgdev->ctrlq.dequeue_work); flush_work(&vgdev->cursorq.dequeue_work); flush_work(&vgdev->config_changed_work); virtio_reset_device(vgdev->vdev); virtio_gpu_reclaim_vbufs(vgdev); vgdev->vdev->config->del_vqs(vgdev->vdev);
Until virtio_reset_device(vgdev->vdev) completes, the virtio device can still raise virtqueue and config interrupts (virtio_gpu_ctrl_ack(), virtio_gpu_cursor_ack(), and virtio_gpu_config_changed()), which call schedule_work() and can re-queue ctrlq.dequeue_work, cursorq.dequeue_work, and config_changed_work after flush_work() has already returned. In the virtio_gpu_probe() -> err_deinit path, drm_dev_unplug() is not called, so config_changed_work can also queue new buffers into ctrlq.vq.
Since virtio_reset_device() does not cancel or flush already-scheduled work, virtio_gpu_dequeue_ctrl_func() and virtio_gpu_dequeue_cursor_func() can run concurrently with virtio_gpu_reclaim_vbufs() and del_vqs():
spin_lock(&vgdev->ctrlq.qlock);
do {
virtqueue_disable_cb(vgdev->ctrlq.vq);
reclaim_vbufs(vgdev->ctrlq.vq, &reclaim_list);
} while (!virtqueue_enable_cb(vgdev->ctrlq.vq));
spin_unlock(&vgdev->ctrlq.qlock);Because virtio_gpu_reclaim_vbufs() calls virtqueue_detach_unused_buf() without holding ctrlq.qlock or cursorq.qlock while dequeue_work is calling virtqueue_get_buf(), can this corrupt virtqueue descriptor state (such as vq->split.desc_state[i].data, vq->free_head, and vq->vq.num_free), double-free vbuffers, or access the virtqueues while del_vqs() is freeing them?
Additionally, flush_work(&vgdev->obj_free_work) runs before flush_work(&vgdev->ctrlq.dequeue_work), even though virtio_gpu_dequeue_ctrl_func() schedules vgdev->obj_free_work via virtio_gpu_array_put_free_delayed(). Can virtio_gpu_array_put_free_work() end up running concurrently with or after virtio_gpu_release() -> virtio_gpu_free_vbufs() and touch vgdev->vbufs while or after the kmem_cache is destroyed?
Quoted 12 lines
drivers/gpu/drm/virtio/virtgpu_vq.c +4
-0@@ -207,6 +207,21 @@ static void free_vbuf(struct virtio_gpu_device *vgdev,kmem_cache_free (vgdev->vbufs, vbuf); } +void virtio_gpu_reclaim_vbufs (struct virtio_gpu_device *vgdev) +{ +struct virtio_gpu_vbuffer *vbuf; +
drivers/gpu/drm/virtio/virtgpu_vq.c static void free_vbuf(struct virtio_gpu_device *vgdev, · line 223
Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_vq.c +10
-0+while ((vbuf =virtqueue_detach_unused_buf (vgdev->ctrlq.vq))) { +if (vbuf->objs) +virtio_gpu_array_put_free (vbuf->objs); +if (vbuf->resp_cb_data) +virtio_gpu_cleanup_object (vbuf->resp_cb_data); +free_vbuf (vgdev, vbuf); + } +while ((vbuf =virtqueue_detach_unused_buf (vgdev->cursorq.vq))) +free_vbuf (vgdev, vbuf); +}
[Severity: High]
Should virtio_gpu_reclaim_vbufs() also reset vgdev->pending_commands to avoid a use-after-free on vgdev->ctrlq.vq in virtio_gpu_notify()?
Whenever a control buffer is queued via virtio_gpu_queue_ctrl_sgs() (or virtio_gpu_panic_queue_ctrl_sgs()), vgdev->pending_commands is incremented:
ret = virtqueue_add_sgs(vq, sgs, outcnt, incnt, vbuf, GFP_ATOMIC); WARN_ON(ret); vbuf->seqno = ++vgdev->ctrlq.seqno; trace_virtio_gpu_cmd_queue(vq, virtio_gpu_vbuf_ctrl_hdr(vbuf), vbuf->seqno); atomic_inc(&vgdev->pending_commands);
Several command submission paths (such as virtio_gpu_object_create(), virtio_gpu_vram_create(), virtio_gpu_mode_dumb_create(), virtio_gpu_resource_create_ioctl(), virtio_gpu_resource_create_blob_ioctl(), virtio_gpu_resource_assign_uuid(), virtio_gpu_prepare_imported_obj(), and virtio_gpu_create_context()) queue vbuffers into vgdev->ctrlq.vq without immediately calling virtio_gpu_notify(vgdev), leaving vgdev->pending_commands non-zero.
When virtio_gpu_reclaim_vbufs() detaches those vbuffers, it does not reset or decrement vgdev->pending_commands, and virtio_gpu_deinit() immediately frees vgdev->ctrlq.vq via vgdev->vdev->config->del_vqs(vgdev->vdev).
If an open drm_file later releases a GEM object or closes (calling virtio_gpu_gem_object_close(), virtio_gpu_free_object(), virtio_gpu_vram_free(), virtgpu_dma_buf_free_obj(), or virtio_gpu_driver_postclose() -> virtio_gpu_notify()), virtio_gpu_notify() has no drm_dev_enter() guard and only checks vgdev->pending_commands:
void virtio_gpu_notify(struct virtio_gpu_device *vgdev)
{
bool notify;
if (!atomic_read(&vgdev->pending_commands))
return;
spin_lock(&vgdev->ctrlq.qlock);
atomic_set(&vgdev->pending_commands, 0);
notify = virtqueue_kick_prepare(vgdev->ctrlq.vq);
spin_unlock(&vgdev->ctrlq.qlock);
if (notify)
virtqueue_notify(vgdev->ctrlq.vq);
}Won't virtio_gpu_notify() see the stale non-zero vgdev->pending_commands and call virtqueue_kick_prepare() and virtqueue_notify() on the freed vgdev->ctrlq.vq? Also, if virtio_gpu_array_put_free(vbuf->objs) inside virtio_gpu_reclaim_vbufs() drops the final reference to a created GEM object, virtio_gpu_free_object() synchronously calls virtio_gpu_notify(vgdev), which would kick vgdev->ctrlq.vq after virtio_reset_device() has already reset the device while virtqueue_detach_unused_buf() is draining the ring.
[Severity: High]
Can calling virtio_gpu_array_put_free(vbuf->objs) from virtio_gpu_reclaim_vbufs() hang uninterruptibly in dma_fence_wait() when releasing an imported DMA-BUF GEM object?
When VIRTGPU_PARAM_RESOURCE_BLOB is enabled without virgl 3D (vgdev->has_resource_blob && !vgdev->has_virgl_3d), importing a DMA-BUF via virtgpu_gem_prime_import() creates a GEM object withobj->funcs = &virtgpu_gem_dma_buf_funcs (.free = virtgpu_dma_buf_free_obj) and bo->attached = true. If that object is used on the primary plane via virtio_gpu_primary_plane_update() -> virtio_gpu_resource_flush() and the 50ms wait times out, the vbuf remains in ctrlq.vq holding a reference to the imported GEM object in vbuf->objs.
During virtio_gpu_remove(), drm_dev_unplug(dev) marks the DRM device unplugged, drm_atomic_helper_shutdown(dev) drops the plane state's framebuffer reference, and virtio_gpu_deinit() resets the device and calls virtio_gpu_reclaim_vbufs(). When virtio_gpu_array_put_free(vbuf->objs) drops the last reference to the imported object, it triggers virtgpu_dma_buf_free_obj() -> virtgpu_dma_buf_unmap() -> virtio_gpu_detach_object_fenced(bo):
int virtio_gpu_detach_object_fenced(struct virtio_gpu_object *bo)
{
struct virtio_gpu_device *vgdev = bo->base.base.dev->dev_private;
struct virtio_gpu_fence *fence;
if (!bo->attached)
return 0;
fence = virtio_gpu_fence_alloc(vgdev, vgdev->fence_drv.context, 0);
if (!fence)
return -ENOMEM;
virtio_gpu_object_detach(vgdev, bo, fence);
virtio_gpu_notify(vgdev);
dma_fence_wait(&fence->f, false);
dma_fence_put(&fence->f);
return 0;
}Inside virtio_gpu_object_detach() -> virtio_gpu_cmd_resource_detach_backing() -> virtio_gpu_queue_fenced_ctrl_buffer() -> virtio_gpu_queue_ctrl_sgs(), drm_dev_enter() returns false because the device is unplugged:
if (!drm_dev_enter(vgdev->ddev, &idx)) {
if (fence && vbuf->objs)
virtio_gpu_array_unlock_resv(vbuf->objs);
free_vbuf(vgdev, vbuf);
return -ENODEV;
}Since virtio_gpu_queue_ctrl_sgs() returns -ENODEV before virtio_gpu_fence_emit() is called, and virtio_gpu_object_detach() ignores this error, won't dma_fence_wait(&fence->f, false) in virtio_gpu_detach_object_fenced() sleep forever waiting on a fence that was never emitted and can never be signaled?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 ALSA: usb-audio: Add native DSD support for Cambridge Audio streamers
In reply to Sasha LevinFrom: Matus Gajdos <[email protected]>
[ Upstream commit 4e1462e7cd6a9b920f441842726cc2b9d232673e ]
The Cambridge Audio streamer advertises the UAC2 RAW_DATA format on altsetting 2 of its playback interface, but without the DSD_RAW quirk flag the driver exposes it only as a SPECIAL format that cannot be used.
Add QUIRK_FLAG_DSD_RAW for the device (USB ID 22e8:ca10), so the altsetting is exposed as DSD_U32_BE, enabling native DSD64/128/256 playback.
Tested with: gst-launch-1.0 filesrc location=file.dsf ! \
avdemux_dsf ! dsdconvert ! \
alsasink device=hw:2,0---
LLM Generated explanations, may be completely bogus:
This is a two-line USB quirk that enables native DSD on an existing device. The local tree is **6.18.57** (v6.18.57-155-gcdf239ca885b2). The DSD_RAW machinery is already here; only the Cambridge Audio ID is missing.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ALSA/usb-audio] [add] Add native DSD support for Cambridge Audio streamers
Subsystem is ALSA USB-audio. The verb is “Add”, but the body is a device-specific quirk, not a new driver or API.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Matus Gajdos <[email protected]> (author)
- `Link:
https://patch.msgid.link/[email protected]`
- Signed-off-by: Takashi Iwai <[email protected]> (ALSA maintainer)
- No Fixes: tag (expected)
- No Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or `Cc:
stable`
- Ignored: [Upstream commit ...] and Signed-off-by: Sasha Levin (pipeline)
Notable: maintainer SOB; author included a concrete gst-launch test command in the body.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: device 22e8:ca10 advertises UAC2 RAW_DATA on playback altsetting 2, but without QUIRK_FLAG_DSD_RAW the driver exposes that altsetting only as SPECIAL, which userspace cannot use.
- Symptom: native DSD64/128/256 playback is unavailable on Cambridge Audio streamers.
- Root cause: UAC has no dedicated DSD bit; the driver only remaps RAW_DATA to DSD_U32_BE when QUIRK_FLAG_DSD_RAW is set and fp->dsd_raw is true.
- Version info: none in the message.
- Tested with an explicit GStreamer DSD playback pipeline.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is a hardware quirk / device-ID addition so advertised DSD actually works. That is the standard ALSA usb-audio DSD_RAW pattern.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: sound/usb/quirks.c (+2 / -0)
- Function/data: quirk_flags_table[] only
- Scope: single-file, two-line table insertion
```2376:2383:sound/usb/quirks.c
DEVICE_FLG(0x21b4, 0x0230, /* Ayre QB-9 Twenty */
QUIRK_FLAG_DSD_RAW),
DEVICE_FLG(0x21b4, 0x0232, /* Ayre QX-5 Twenty */
QUIRK_FLAG_DSD_RAW),
DEVICE_FLG(0x22e8, 0xca10, /* Cambridge Audio streamers */
QUIRK_FLAG_DSD_RAW),
DEVICE_FLG(0x2522, 0x0007, /* LH Labs Geek Out HD Audio 1V5 */
QUIRK_FLAG_SET_IFACE_FIRST),
```**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Before: 22e8:ca10 has no table entry. Probe does not set QUIRK_FLAG_DSD_RAW. UAC2 RAW_DATA stays SNDRV_PCM_FMTBIT_SPECIAL.
- After: exact VID:PID match ORs QUIRK_FLAG_DSD_RAW. snd_usb_interface_dsd_format_quirks() then returns SNDRV_PCM_FMTBIT_DSD_U32_BE when fp->dsd_raw is set.
- Path: device probe / format parse (init), not an error path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: [Hardware workaround / USB quirk ID]
Mechanism: UAC2 RAW_DATA is only treated as native DSD when the existing QUIRK_FLAG_DSD_RAW flag is set. This device advertises that format but was missing from the allow-list.
Verified in this tree:
- format.c sets fp->dsd_raw = true and SNDRV_PCM_FMTBIT_SPECIAL for UAC2_FORMAT_TYPE_I_RAW_DATA
- quirks.c:2078-2079 remaps only if (chip->quirk_flags & QUIRK_FLAG_DSD_RAW) && fp->dsd_raw
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct and minimal. Same DEVICE_FLG(..., QUIRK_FLAG_DSD_RAW) pattern already used for Ayre, ddHiFi, XMOS, McIntosh, HEM, etc. No API, lock, or struct change. Regression risk is confined to 22e8:ca10; other devices are untouched. Matching is exact VID:PID (snd_usb_init_quirk_flags_table() returns on first match; there is no VENDOR_FLG(0x22e8)).
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- New lines are this commit. Surrounding DSD_RAW entries date to f7fea075edfa08 (Jussi Laako, 2023) and c84bd6c810d188 (2024).
- The DSD_RAW mechanism itself is 68e851ee4cfd2 (“Move generic DSD raw detection into quirk_flags”), 2021-07-29, first appeared in **v5.15-rc1**. git merge-base --is-ancestor 68e851ee4cfd2 HEAD → yes.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable. The “bug” is a missing device allow-list entry, not a regression from a specific commit.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent sound/usb/quirks.c history is full of the same class of patches (JBL FIXED_RATE, Audient IGNORE_CTL_ERROR, LEAK/PureAudio/Comtrue DSD_RAW, etc.). This commit is standalone, not patch X/Y.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: git log --author="Matus Gajdos" -- sound/usb/ shows only this commit. Author is a hardware user, not the subsystem maintainer. Maintainer Takashi Iwai applied it the next day.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: No prerequisites. Parent of this tree already has DEVICE_FLG, QUIRK_FLAG_DSD_RAW, fp->dsd_raw, and the Ayre / LH Labs insertion context. Applies standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 8a762801bd078 →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only**, 2026-10-02, Matus Gajdos. No v2/v3.
- Thread (mbox, 2 messages): submission + Takashi Iwai “Applied now. Thanks.”
- No NAK, no requested changes, no reviewer Cc: stable.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc were Jaroslav Kysela, Takashi Iwai, linux- sound, linux-kernel. Correct ALSA maintainers. Iwai applied it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No external bugzilla/syzbot report. The author is the reporter and tester. USB ID 22e8:ca10 is Cambridge Audio (vendor 22e8 is CA; Windows INF lists VID_22E8&PID_CA10 as Cambridge Audio USB Audio).
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone single patch. Not part of a series.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No stable-list discussion found for this ID/subject. lore HTML fetches returned 403; search did not turn up a prior rejection. Similar DSD_RAW ID additions **have** been sent to stable historically (`Cc:
stable on McIntosh 99248c8902f50, HEM 122e2cb7e1a30, LEAK c83fc13960643`).
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: No function body changed. Data: quirk_flags_table[].
Consumers: snd_usb_init_quirk_flags_table(), snd_usb_interface_dsd_format_quirks().
**Step 5.2: TRACE CALLERS**
Record:
- snd_usb_init_quirk_flags() in sound/usb/card.c:728 → snd_usb_init_quirk_flags_table() during USB-audio probe
- parse_audio_format_i() in sound/usb/format.c:157 → snd_usb_interface_dsd_format_quirks()
Probe/format-parse path, not IRQ/hot path.
**Step 5.3: TRACE CALLEES**
Record: Table walk + chip->quirk_flags |= p->flags. Later, DSD remap returns a format bit. No alloc, no lock in the new code (lock already exists around flag init in card.c).
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: USB plug-in → snd_usb_audio probe → quirk flags → format parse → PCM device with DSD_U32_BE on altsetting 2 → userspace (alsasink, etc.). Reachable whenever this streamer is connected. Unprivileged playback once the device node is accessible.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Dozens of identical QUIRK_FLAG_DSD_RAW table entries in the same file. This is the standard allow-list, not a one-off.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. This is 6.18.57. QUIRK_FLAG_DSD_RAW and fp->dsd_raw have been here since v5.15. Parent of the candidate has **no** 0x22e8 entry. Without this patch, Cambridge Audio 22e8:ca10 still exposes SPECIAL instead of DSD. The device is not new-to-6.19 infrastructure; only the ID is new.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply. Parent context is exactly Ayre QX-5 Twenty then LH Labs Geek Out. No refactor of the table in 6.18.y.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No other Cambridge Audio / 0x22e8 quirk. No alternate DSD fix for this ID. git grep 0x22e8 -- sound/usb only hits this new line.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: [sound/usb (ALSA USB-audio)] [IMPORTANT] — common driver, but this change is device-specific.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained. Frequent small quirk-table updates from Takashi Iwai and hardware vendors. Mature pattern, low churn in the matching logic itself.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver-specific / device-specific. Only USB 22e8:ca10 (Cambridge Audio streamers). PCM users of that device are unchanged; DSD users gain a working format.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Trigger is plugging in that streamer and opening the RAW_DATA/DSD altsetting. Common for owners of that hardware; impossible for everyone else. Not a race.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: [Missing hardware capability / unusable advertised format] [MEDIUM as a bug; YES as a quirk exception]
Not a panic, UAF, or corruption. Without the quirk, advertised DSD is unusable (SPECIAL). With it, native DSD works. That is the same class as USB/codec/SFP quirks the stable rules call out.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: high for owners of these streamers (DSD actually works); zero effect elsewhere.
- Risk: very low (2 lines, exact VID:PID, existing flag, maintainer- applied, hardware-tested).
- Ratio: strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Hardware quirk / USB ID addition — explicit stable exception
- 2-line, obviously correct, no API change
- Infrastructure present in this 6.18.y tree since v5.15
- Applies cleanly
- Author tested real DSD64/128/256 playback
- Applied by ALSA maintainer Takashi Iwai; no objections
- Same pattern already used (and historically Cc:stable) for other DACs
- Only 22e8:ca10 is affected
AGAINST:
- Not a crash, security hole, or data-corruption fix
- Enables a capability rather than stopping an oops
- Author is not a regular subsystem contributor (mitigated by maintainer apply)
UNRESOLVED:
- Could not fetch lore HTML (403); full thread recovered via b4 dig -m
- No independent second-user report beyond the author
- usb-ids listing for 22e8 confirms Cambridge Audio; ca10 is in Windows CA USB-audio INF, not in every public usb-ids dump
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — 2-line allow-list; author gst-launch test; maintainer applied
2. Fixes a real bug that affects users? **PASS** — advertised DSD altsetting is unusable without the flag
3. Important issue? **PASS via quirk exception** — not a crash; hardware enablement for existing devices
4. Small and contained? **PASS** — +2 lines, one table
5. No new features or APIs? **PASS** — no new syscall/API/driver; existing QUIRK_FLAG_DSD_RAW only
6. Can apply to the local tree? **PASS** — clean context in 6.18.57
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Hardware quirk / USB device-ID addition to an existing driver.** Automatic YES category.
**Step 9.4: MAKE YOUR DECISION**
This belongs on 6.18.y. The tree already has the DSD_RAW path; the commit only names one USB ID so that device’s advertised RAW_DATA altsetting becomes usable DSD. That is the same class of stable material as other ALSA usb-audio DSD and USB quirks.
Verification:
- [Phase 1] Parsed tags: author SOB, Link to msgid, Takashi Iwai SOB; no Fixes/Reported-by/Cc:stable
- [Phase 1] Body: UAC2 RAW_DATA on altsetting 2 exposed as SPECIAL without DSD_RAW; tested gst-launch DSD pipeline
- [Phase 2] Diff: +2 lines in quirk_flags_table[] only — DEVICE_FLG(0x22e8, 0xca10, QUIRK_FLAG_DSD_RAW)
- [Phase 2] format.c:59-62 sets fp->dsd_raw on UAC2 RAW_DATA; quirks.c:2078-2079 remaps only with the flag
- [Phase 2] snd_usb_init_quirk_flags_table() exact VID:PID match; no VENDOR_FLG(0x22e8)
- [Phase 3] 68e851ee4cfd2 introduced DSD_RAW in v5.15-rc1; ancestor of this HEAD
- [Phase 3] Author has no other sound/usb commits; not a series
- [Phase 3] Parent of candidate has Ayre then LH Labs context and no 0x22e8
- [Phase 4] b4 dig -c 8a762801bd078: lore msgid [email protected]
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: Iwai, Kysela, linux-sound
- [Phase 4] mbox: Iwai “Applied now. Thanks.” No NAK, no stable nomination
- [Phase 4] WebFetch lore HTML: 403; discussion recovered from mbox
- [Phase 4] Similar historical DSD_RAW quirks carried Cc: stable (McIntosh, HEM, LEAK)
- [Phase 5] Callers: card.c:728 probe; format.c:157 format parse
- [Phase 6] git describe HEAD = v6.18.57-155-gcdf239ca885b2; make kernelversion = 6.18.57
- [Phase 6] git merge-base --is-ancestor v6.18 HEAD yes; candidate not in v6.18 release
- [Phase 6] Clean apply in this tree
- [Phase 7] ALSA USB-audio, actively quirk-maintained
- [Phase 8] Failure mode: unusable DSD format on one USB ID; severity medium, quirk-exception YES
- UNVERIFIED: live lore.kernel.org/stable thread contents (HTTP 403 / unhelpful search)
**YES**
sound/usb/quirks.c | 2 ++ 1 file changed, 2 insertions(+)
sound/usb/quirks.c +2 -0
@@ -2379,6 +2379,8 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = { QUIRK_FLAG_DSD_RAW),DEVICE_FLG (0x21b4 ,0x0232 ,/* Ayre QX-5 Twenty */ QUIRK_FLAG_DSD_RAW ), +DEVICE_FLG (0x22e8 ,0xca10 ,/* Cambridge Audio streamers */ +QUIRK_FLAG_DSD_RAW ),DEVICE_FLG (0x2522 ,0x0007 ,/* LH Labs Geek Out HD Audio 1V5 */ QUIRK_FLAG_SET_IFACE_FIRST ), DEVICE_FLG(0x262a, 0x9302, /* ddHiFi TC44C */
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: hda: Add Lisuan HDMI controller and codec support
In reply to Sasha LevinFrom: Xu Rao <[email protected]>
[ Upstream commit ceaebef91d1aff671a512d5f003766ea41152d94 ]
Lisuan GPUs expose an HD-audio controller at PCI ID 4c54:5010 and an HDMI/DP codec with codec ID 0x4c545020. Neither ID is currently matched by the HDA stack, leaving HDMI/DP audio unavailable on these devices.
The existing downstream support uses the generic HDMI codec path and attaches no Lisuan-specific capability flags to the controller. Its dedicated AZX driver type only changes the short driver name.
Use the corresponding generic upstream paths instead: bind 4c54:5010 to AZX_DRIVER_GENERIC, register 0x4c545020 as MODEL_GENERIC, and add the Lisuan codec vendor name. This keeps the enablement minimal and avoids a vendor-only AZX driver type with no vendor-specific behavior.
---
LLM Generated explanations, may be completely bogus:
I have enough to decide. This is a four-line device-ID enablement; the 6.12 HDA driver already has the matching tables under the older paths.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [ALSA: hda] [Add] [Lisuan HDMI controller PCI ID 4c54:5010 and codec ID 0x4c545020 so HDMI/DP audio binds on existing generic HDA paths]
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Fixes: none (expected)
- Reported-by: none
- Tested-by: none
- Reviewed-by: none
- Acked-by: none
- Link: https://patch.msgid.link/DE1B62191D573D37+20260817085531.992573-
[email protected]
- Cc: stable: none (expected)
- Signed-off-by: Xu Rao <[email protected]> (author)
- Signed-off-by: Takashi Iwai <[email protected]> (ALSA maintainer; applied the patch)
- Ignore Signed-off-by: Sasha Levin if present (pipeline)
Notable: no syzbot, no crash report. This is hardware enablement, not a sanitizer fix. Maintainer SOB is present.
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug/problem: Lisuan GPUs expose HD-audio at PCI 4c54:5010 and HDMI/DP codec 0x4c545020. Neither ID is matched, so HDMI/DP audio is unavailable.
- Symptom: no HDMI/DP audio on these devices.
- Version info: none in the message. Lore shows this was pulled for 7.3-rc1 (Takashi's "sound updates for 7.3-rc1" on 2026-08-19).
- Root cause: missing ID table entries. Downstream already used the generic HDMI codec path and attached no Lisuan-specific AZX capability flags; a dedicated AZX driver type would only change the short name.
- Fix: bind PCI ID to AZX_DRIVER_GENERIC, register codec as MODEL_GENERIC, add vendor name "Lisuan".
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a hidden UAF/race/leak fix. It is a device-ID addition:
hardware does not bind without the IDs. That is the stable exception for PCI/codec IDs on an existing driver, not a disguised cleanup.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- sound/hda/codecs/hdmi/hdmi.c: +1 (codec ID 0x4c545020, "Lisuan HDMI/DP", MODEL_GENERIC)
- sound/hda/controllers/intel.c: +2 (comment + PCI_DEVICE(0x4c54, 0x5010) → AZX_DRIVER_GENERIC)
- sound/hda/core/device.c: +1 (vendor 0x4c54 → "Lisuan")
- Total: +4 lines, 0 removals
- Functions/tables: snd_hda_id_generichdmi[], azx_ids[], hda_vendor_ids[]
- Scope: single-driver ID-table addition (three tables in one subsystem)
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- HDMI codec table: unmatched 0x4c545020 did not hit the generic HDMI driver by explicit ID. After: it matches MODEL_GENERIC / patch_generic_hdmi.
- PCI table: 4c54:5010 was not in azx_ids and this tree has no vendor/class catch-all for 0x4c54, so snd-hda-intel did not probe.
After: it probes as AZX_DRIVER_GENERIC with no extra DCAPS.
- Vendor table: unnamed vendor used "Generic 4c54". After: name is "Lisuan" (cosmetic for mixer/proc).
- Paths: probe/init only. No hot-path, locking, or API change.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record: [Hardware enablement / device ID] Controller and codec never matched. PCI ID is required for bind. Codec ID selects the generic HDMI parser. Vendor string is display-only. Not UAF, leak, race, or overflow.
Step 2.4: ASSESS THE FIX QUALITY
Record: Minimal and consistent with VIA/VMware/RDC generic HDMI IDs. Author says downstream used generic path with no vendor DCAPS. Regression risk is the usual new-ID risk (hardware might later need NO_MSI / POSFIX_LPIB / etc.). No new AZX_DRIVER type, no new API. Quality is high for an ID add.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record: This tree has no Lisuan entries. Insertion point in 6.12 HDMI table is beside Glenfly Arise IDs from c51e431052e2e (2023). PCI table terminator at azx_ids[] is original (Linus 1da177e4c3f41); last entries are Loongson (28bd137a3c8e1, 2023). Vendor table around 0x434d/0x8086 is Takashi Iwai 7639a06c23c7d4 (2015). The HDA ID tables have been stable for years; this is not a bug in newly added 6.12 code.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Not applicable. Missing IDs were never introduced by a prior commit; they were never added.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: Same files already received ID adds in this 6.12 tree, e.g. 2b331e7b6cc57 "ALSA: hda: Add new pci id for AMD GPU display HD audio controller" (in HEAD), e8336a63de03e Intel BMG, e9481d9b83f8d Intel PTL HDMI codec, c51e431052e2e Glenfly. Standalone; not patch X/Y. No Lisuan follow-ups on lore.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: git log --author='Xu Rao' on sound/ in this tree is empty. UnionTech contributor; not the ALSA maintainer. Takashi Iwai applied it the same day. Weight comes from maintainer accept, not author history here.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: Needs existing snd-hda-intel + HDMI codec + AZX_DRIVER_GENERIC. All present. Does not need a new driver type, Hygon entries, or MODEL_GENERIC (6.12 uses HDA_CODEC_ENTRY(..., patch_generic_hdmi)). Standalone with a path/macro translation. No DRM Lisuan driver in this tree; HDA PCI bind does not require it.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c HEAD failed (lore server error; this tree's HEAD is unrelated).
- Lore (linux-sound and all): exactly one series, v1 only.
- Patch: https://lore.kernel.org/linux-
sound/[email protected]/ - Also mirrored at https://lists.openwall.net/linux- kernel/2026/08/17/647
- b4 dig -a: not obtained (b4/lore error). Lore search shows no v2/v3.
- Feedback: Takashi Iwai: "Applied now. Thanks." No NAK, no requested changes, no Cc: stable in review.
- Pulled in "[GIT PULL] sound updates for 7.3-rc1".
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: Recipients from the openwall/lkml copy: [email protected], tiwai, peter.ujfalusi, kai.vehmanen, tglx, broonie, linux-sound, linux-kernel, plus a few others. Subsystem list and ALSA maintainer were on To/Cc. Maintainer applied v1 immediately.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No bugzilla/syzbot. Evidence is the commit text plus "existing downstream support". Hardware impact is real for Lisuan GPU HDMI audio users; no public crash report.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone 4-line patch. lore.kernel.org/all/?q=Lisuan returns only this patch, Takashi's apply, and the 7.3-rc1 pull. No companion DRM or quirk series on lore.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable/?q=Lisuan returned no hits. Not discussed on stable@ yet.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS
Record: No function bodies changed. Tables: snd_hda_id_generichdmi[] / snd_hda_id_hdmi[], azx_ids[], hda_vendor_ids[]. Consumers: azx_probe (PCI match), hda_codec_match / snd_hda_codec_configure (codec match), get_codec_vendor_name().
Step 5.2: TRACE CALLERS
Record:
- azx_ids is MODULE_DEVICE_TABLE(pci) for snd-hda-intel; probe is azx_probe on PCI enumeration.
- Codec table is MODULE_DEVICE_TABLE(hdaudio); hda_codec_match() compares vendor_id.
- codec_bind_generic() can still fall back to HDA_CODEC_ID_GENERIC_HDMI via is_likely_hdmi_codec() if the controller is bound and the codec looks like HDMI-only. PCI match is the gating bind. Codec ID is explicit matching/naming, not the only possible codec path.
- Context: device probe, not IRQ/hot path.
Step 5.3: TRACE CALLEES
Record: ID tables do not call allocators or locks. AZX_DRIVER_GENERIC in this tree is already used (VIA 0x9170/0x9140, RDC, VMware, some AMD). Stream-count fallback treats AZX_DRIVER_GENERIC like the default ICH6 counts (hda_intel.c ~1987).
Step 5.4: FOLLOW THE CALL CHAIN
Record: PCI enumeration → azx_probe → codec discovery → HDMI parser. Reachable whenever the Lisuan HDMI audio function is present. Unprivileged userspace cannot create the device; plug-in hardware users are affected. HDMI audio is a user-visible function.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same pattern as Glenfly HDMI IDs, Loongson HDMI, AMD GPU display HDA PCI IDs, Intel BMG/PTL HDMI IDs — all already in this 6.12 tree. No other 0x4c54 / 0x4c545020 / "Lisuan" matches in the tree.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record:
- Local tree: pending-6.12, kernel 6.12.111 (git describe p-6.12-3-gc504cf0baa3d8; Makefile VERSION=6 PATCHLEVEL=12 SUBLEVEL=111).
- git log --grep=Lisuan -- sound/: empty. IDs are not here.
- Mainline paths sound/hda/codecs/hdmi/hdmi.c, sound/hda/controllers/intel.c, sound/hda/core/device.c do not exist (post-6.12 HDA split).
- Equivalents do exist:
- sound/pci/hda/hda_intel.c azx_ids[] — AZX_DRIVER_GENERIC at line
244, table ends at Loongson then {0,}
- sound/pci/hda/patch_hdmi.c snd_hda_id_hdmi[] — HDA_CODEC_ENTRY +
patch_generic_hdmi
- sound/hda/hdac_device.c hda_vendor_ids[] — same vendor list, no
0x4c54- SND_HDA_INTEL and SND_HDA_CODEC_HDMI exist (sound/pci/hda/Kconfig).
- "Bug" is missing IDs, not a regression introduced after 6.12. Lisuan hardware on 6.12 still fails to bind.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Will not apply as a raw mainline diff (wrong paths, HDA_CODEC_ID_MODEL vs HDA_CODEC_ENTRY). Mechanical 3-site remap:
1. patch_hdmi.c: HDA_CODEC_ENTRY(0x4c545020, "Lisuan HDMI/DP", patch_generic_hdmi)
2. hda_intel.c: { PCI_DEVICE(0x4c54, 0x5010), .driver_data =
AZX_DRIVER_GENERIC }
3. hdac_device.c: { 0x4c54, "Lisuan" }
Same class of backport as 2b331e7b6cc57 (AMD PCI ID into hda_intel.c on this branch). Difficulty: minor / needs small backport, not a rework.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No Lisuan IDs. No alternate Lisuan HDA quirk. Nothing to conflict besides inserting three table rows.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [ALSA HD-audio / HDMI codec + PCI controller] [IMPORTANT for HDMI audio users; PERIPHERAL in that only Lisuan 4c54:5010 is newly matched; core HDA stack is mature]
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: sound/pci/hda/ is actively receiving ID and quirk backports in this tree (AMD GPU ID, ThinkPad PM denylist, Panther Lake, etc.). Mature tables, routine ID churn. Matches stable practice.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver-specific / hardware-specific: owners of Lisuan GPUs with HD-audio 4c54:5010. No effect on other devices. Population is smaller than Intel/AMD HDMI, but that is normal for vendor ID adds (Glenfly, Loongson, etc.).
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Trigger is having the PCI function present (boot/hotplug GPU). Common for those machines; zero for everyone else. Not an unprivileged syscall attack. HDMI audio is the user-visible feature.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: [HDMI/DP audio never appears] [MEDIUM for affected users:
functional gap, not oops/corruption]. Stable still takes these as device-ID exceptions. Without the PCI ID, snd-hda-intel never binds (verified: no 0x4c54 class catch-all in azx_ids[]).
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: HDMI/DP audio on Lisuan using the existing generic HDA path. High for those users; none for others.
- Risk: 4 lines, probe-only, AZX_DRIVER_GENERIC already used. Residual risk is missing hardware quirks; author/downstream say none are needed.
- Ratio: favorable. Same as other HDA PCI/codec ID backports already on 6.12.y.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Classic PCI + codec ID add to an existing driver (snd-hda-intel + HDMI codec present in 6.12).
- Explicit stable exception: "NEW DEVICE IDs".
- +4 lines, no new API, no new AZX_DRIVER type, no new module param.
- Without PCI ID, controller does not bind in this tree.
- ALSA maintainer applied v1 immediately.
- Same pattern already backported here (AMD GPU HDA PCI ID, Intel HDMI codec IDs, Glenfly).
- Downstream already used generic HDMI with no extra DCAPS.
AGAINST:
- Not a crash/UAF/security fix.
- Raw diff does not apply (HDA tree split after 6.12).
- No Tested-by / Reported-by on the list.
- No in-tree Lisuan DRM driver; ELD/display integration may be limited without a GPU driver (HDA still needs the PCI ID).
- Possible later quirks if generic AZX flags are wrong (unverified beyond author's downstream claim).
UNRESOLVED:
- Mainline SHA not in this checkout; merge-base --is-ancestor of the upstream commit was not run (commit absent).
- b4 dig failed on lore; thread recovered via lore/openwall instead.
- Could not independently test Lisuan hardware.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — four table rows; maintainer applied; downstream generic path described.
2. Fixes a real bug that affects users? PASS — HDMI/DP audio never binds without the PCI ID.
3. Important issue (crash, security, corruption, deadlock)? FAIL on that strict list; PASS under the documented device-ID exception (hardware enablement).
4. Small and contained? PASS — +4 lines, three ID tables.
5. No new features or APIs? PASS — no new driver, syscall, or userspace API; IDs only.
6. Can apply to the local tree? PASS with a small backport (patch_hdmi.c / hda_intel.c / hdac_device.c). Equivalent tables and AZX_DRIVER_GENERIC exist.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Device ID addition to an existing driver (PCI ID + HDMI codec ID
+ vendor label). This is the standard YES exception. Vendor string is documentation-level.
Step 9.4: MAKE YOUR DECISION
This belongs in 6.12.y. The HDA controller/codec drivers are here; only the Lisuan IDs are missing. The mainline file move is a mechanical remap, not missing infrastructure. Risk is low; benefit is making HDMI/DP audio work on that GPU.
What the commit solves for stable users: 6.12.y systems with a Lisuan GPU HD-audio function 4c54:5010 currently do not bind snd-hda-intel. Adding the PCI ID (and codec/vendor rows) enables the existing generic HDMI path.
Risk vs benefit: four probe-only table entries vs silent non-function of HDMI audio. Same class as ID adds already on this branch.
Concerns: backport must retarget 6.12 paths and use HDA_CODEC_ENTRY(..., patch_generic_hdmi) instead of HDA_CODEC_ID_MODEL(..., MODEL_GENERIC). No other prerequisites.
Verification:
- [Phase 1] Parsed tags: author Xu Rao; Link msgid [email protected]; SOB Takashi Iwai; no Fixes/Reported-by/Cc: stable
- [Phase 1] Body: missing 4c54:5010 and codec 0x4c545020; downstream generic HDMI, no extra DCAPS
- [Phase 2] Diff: +1 codec ID, +2 PCI ID/comment, +1 vendor name; 3 files, +4/-0
- [Phase 3] git describe / Makefile: this tree is 6.12.111 pending-6.12 (p-6.12-3-gc504cf0baa3d8)
- [Phase 3] git log --grep=Lisuan -- sound/: not in this tree
- [Phase 3] Equivalent files: sound/pci/hda/hda_intel.c, sound/pci/hda/patch_hdmi.c, sound/hda/hdac_device.c
- [Phase 3] AZX_DRIVER_GENERIC exists (hda_intel.c:244, used e.g. VIA 0x9170)
- [Phase 3] HDA_CODEC_ID_MODEL absent; HDA_CODEC_ENTRY in include/sound/hda_codec.h:86
- [Phase 3] Precedent in tree: 2b331e7b6cc57 AMD GPU HDA PCI ID (git merge-base --is-ancestor: yes)
- [Phase 3] Blame: HDMI Arise IDs c51e431052e2e (2023); azx_ids terminator 1da177e4c3f41; vendor table 7639a06c23c7d4 (2015)
- [Phase 4] lore linux-sound: 3 hits only (patch, apply, 7.3-rc1 pull); v1 only; Takashi "Applied now"
- [Phase 4] b4 dig -c HEAD: lore server error; used lore/openwall instead
- [Phase 4] lore.kernel.org/stable/?q=Lisuan: no discussion
- [Phase 5] azx_ids has Intel/NVIDIA/ATI/Glenfly class catch-alls, not vendor 0x4c54 — PCI ID required
- [Phase 5] hda_bind.c codec_bind_generic() can fall back to generic HDMI after controller bind; PCI ID remains the bind gate
- [Phase 5] grep Lisuan/0x4c545020/PCI_DEVICE(0x4c54: no matches
- [Phase 6] No sound/hda/codecs/hdmi/hdmi.c or sound/hda/controllers/intel.c here (split after 6.12)
- [Phase 6] SND_HDA_INTEL / SND_HDA_CODEC_HDMI present in sound/pci/hda/Kconfig
- [Phase 8] Failure mode: no HDMI/DP audio device, not a panic
- UNVERIFIED: live Lisuan hardware; whether later quirks are needed beyond author's downstream statement; exact mainline SHA (not in this checkout)
**YES**
sound/hda/codecs/hdmi/hdmi.c | 1 + sound/hda/controllers/intel.c | 2 ++ sound/hda/core/device.c | 1 + 3 files changed, 4 insertions(+)
sound/hda/codecs/hdmi/hdmi.c +1 -0
@@ -2348,6 +2348,7 @@ static const struct hda_device_id snd_hda_id_generichdmi[] = {HDA_CODEC_ID_MODEL (0x1d179f8e ,"KX-7000 HDMI/DP" ,MODEL_GF ),HDA_CODEC_ID_MODEL (0x1d179f8f ,"KX-7000 HDMI/DP" ,MODEL_GF ),HDA_CODEC_ID_MODEL (0x1d179f90 ,"KX-7000 HDMI/DP" ,MODEL_GF ), +HDA_CODEC_ID_MODEL (0x4c545020 ,"Lisuan HDMI/DP" ,MODEL_GENERIC ),HDA_CODEC_ID_MODEL (0x67663d82 ,"Arise 82 HDMI/DP" ,MODEL_GF ),HDA_CODEC_ID_MODEL (0x67663d83 ,"Arise 83 HDMI/DP" ,MODEL_GF ), HDA_CODEC_ID_MODEL(0x67663d84, "Arise 84 HDMI/DP", MODEL_GF),
sound/hda/controllers/intel.c +2 -0
@@ -2830,6 +2830,8 @@ static const struct pci_device_id azx_ids[] = {/* Hygon HDAudio */ { PCI_VDEVICE(HYGON, PCI_DEVICE_ID_HYGON_18H_M05H_HDA), .driver_data = AZX_DRIVER_HYGON | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_NO_MSI }, + /* Lisuan HD-audio */ + { PCI_DEVICE(0x4c54, 0x5010), .driver_data = AZX_DRIVER_GENERIC }, { 0, } };MODULE_DEVICE_TABLE (pci, azx_ids);
sound/hda/core/device.c +1 -0
@@ -664,6 +664,7 @@ static const struct hda_vendor_id hda_vendor_ids[] = { { 0x1af4, "QEMU" }, { 0x1fa8, "Senarytech" }, { 0x434d, "C-Media" }, + { 0x4c54, "Lisuan" }, { 0x8086, "Intel" }, { 0x8384, "SigmaTel" }, {} /* terminator */
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ata: libata-sff: don't busy-wait for PIO data-in command completion
In reply to Sasha LevinFrom: Richard Weinberger <[email protected]>
[ Upstream commit 4a2e5409472e8a0e3e2817e149c55c1d5f803742 ]
Unlike PIO data-out, the PIO data-in protocol raises no completion interrupt, the last interrupt announces the final data block, and once the host has drained it from the data register the ending status must be obtained synchronously. ata_sff_hsm_move() does this by spinning in ata_wait_idle() for up to 10ms.
Usually this is not a big deal unless the device is slow. In my case it's a CF card which keeps BSY asserted for multiple milliseconds(!) after the final data block. Since the waiting happens in the interrupt handler, under the port lock with interrupts disabled, the CPU is hogged for milliseconds on every read command.
To improve the situation, bound the inline wait to ~100us. If the device is still busy after that, mark the command ATA_TFLAG_POLLING, so the interrupt handler won't race for it, and obtain the ending status via ata_sff_pio_task(), which sleeps between status checks instead of spinning with the lock held.
Since ata_sff_pio_task() may now finish a data-in command, it must wait for both BSY and DRQ to clear at HSM_ST_LAST, matching what ata_wait_idle() enforced.
---
LLM Generated explanations, may be completely bogus:
# Stable backport analysis: ata: libata-sff: don't busy-wait for PIO data-in command completion
Local tree: **v7.3-rc4** (7.3.0-rc4, HEAD f0100363d8c37). Candidate:4a2e5409472e8 (Damien Le Moal, 2026-07-21). The buggy PIO completion wait has been in drivers/ata/libata-sff.c since 2008; this change is a small HSM latency fix for that path.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
- Subsystem: ata: libata-sff
- Action verb: **don't busy-wait** (prevent / stop incorrect spinning)
- Intent: stop spinning in the SFF interrupt handler for PIO data-in completion
Record: [ata/libata-sff] [don't busy-wait] [cap IRQ-context wait for PIO data-in; defer remaining wait to sleeping pio task]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Signed-off-by: Richard Weinberger <[email protected]> (author)
- Signed-off-by: Damien Le Moal <[email protected]> (libata maintainer; applied to for-7.3)
- No Fixes:
- No Reported-by: / Tested-by: / Reviewed-by: / Acked-by:
- No Link: / Cc: stable
- No syzbot / sanitizer tags
Absence of Fixes: / Cc: stable is expected for this review and is not a negative signal.
Record: [tags: two SOBs (author + ATA maintainer); no Fixes/Reported- by/Link/stable Cc]
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
PIO data-in does not raise a completion IRQ. The last IRQ means “final data block”; after the host drains it, ending status must be read synchronously. ata_sff_hsm_move() used ata_wait_idle(), spinning up to **10ms**.
On a CompactFlash card that keeps BSY asserted for several milliseconds after the last block, that wait runs in the **interrupt handler**, under the **port lock**, with **IRQs disabled**, on **every read**.
Fix: bound the inline wait to ~100µs (ata_sff_busy_wait(..., 10)). If still busy, set ATA_TFLAG_POLLING and finish via ata_sff_pio_task(), which sleeps between checks. That task must wait for both BSY and DRQ at HSM_ST_LAST, matching ata_wait_idle().
Record: `[Bug: IRQ-context 10ms busy-wait on PIO data-in] [Symptom: CPU hogged for ms per read, lock held, IRQs off] [Root cause:ata_wait_idle() in hsm_move after last PIO-in block] [Trigger: slow CF/PATA that holds BSY after last DRQ]`
**Step 1.4: DETECT HIDDEN BUG FIXES**
Wording is “improve the situation,” but the failure is a real IRQ- context stall, not a cleanup. That matches the “oh, that's not good” class in Documentation/process/stable-kernel-rules.rst, and the hardware-quirk / interactivity class for slow CF.
Record: [Hidden bug fix: yes — IRQ busy-wait / latency stall, not style cleanup]
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
- File: drivers/ata/libata-sff.c only
- Stat: **17 insertions, 7 deletions** (24 lines)
- Functions: ata_sff_hsm_move(), ata_sff_pio_task()
- Scope: single-file surgical HSM change
Record: [1 file, +17/-7] [ata_sff_hsm_move, ata_sff_pio_task] [surgical]
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Hunk 1 (ata_sff_hsm_move, HSM_ST, PIO data-in last block):
- Before: status = ata_wait_idle(ap) (up to 1000×10µs = 10ms), then goto fsm_start.
- After: ata_sff_busy_wait(ap, ATA_BUSY|ATA_DRQ, 10) (~100µs). If still busy and status ≠ 0xff: set ATA_TFLAG_POLLING, ata_sff_queue_pio_task(link, 0), return 0. Else same goto fsm_start.
Hunk 2 (ata_sff_pio_task):
- Before: always wait only for ATA_BUSY.
- After: wait_mask = ATA_BUSY, and at HSM_ST_LAST also ATA_DRQ. Both short spins and the “still busy → requeue” test use wait_mask.
Record: `[IRQ path: 10ms spin → 100µs then optional poll work] [wq path:
wait BSY, or BSY|DRQ at LAST]`
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Category: **logic/latency in IRQ** (busy-wait with IRQs disabled), plus **hardware delay on slow CF**.
Mechanism: last PIO-in IRQ still needs BSY/DRQ to drop. Spinning in hardirq with the port lock held stalls the CPU. The fix uses the existing polling workqueue, which already drops the lock and ata_msleep()s.
ATA_TFLAG_POLLING is the existing “IRQ must not complete this qc” flag. __ata_sff_interrupt() skips port_intr() when it is set.
Record: [category: IRQ busy-wait / latency] [fix: short wait + existing pio_task polling; LAST waits BSY|DRQ]
**Step 2.4: ASSESS THE FIX QUALITY**
Verified against current code:
- ata_wait_idle() is ata_sff_busy_wait(..., ATA_BUSY|ATA_DRQ, 1000) with a debug print. New max=10 is the same bits, 100× shorter.
- Status 0xff (no device) is **not** deferred; it still goes to fsm_start, same as a disconnected ata_wait_idle() result.
- ata_hsm_ok_in_wq() returns 1 when ATA_TFLAG_POLLING is set, so the WARN_ON_ONCE(in_wq != ata_hsm_ok_in_wq()) stays consistent when the workqueue later calls ata_sff_hsm_move(..., 1).
- pio_task clears sff_pio_task_link **before** hsm_move. If the IRQ path queued work and the wq path hits the new wait, requeue via ata_sff_queue_pio_task is the existing delayed-work pattern.
- Fast devices that drop BSY/DRQ within ~100µs still complete in IRQ; only slow devices take the workqueue.
Regression risk is real but contained: HSM is sensitive, and the patch does not call ata_qc_set_polling() (no nIEN). For PIO data-in that is
acceptable: the protocol does not raise a completion IRQ after the last block, which is why the synchronous wait existed.
Record: [quality: small, uses existing polling HSM] [risk: low-medium HSM timing; nIEN not set, which matches this protocol]
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
- Surrounding if (hsm_task_state == HSM_ST_LAST && !WRITE) / ata_wait_idle(): **624d5c514eed18** (Tejun Heo, 2008-03-25), “libata: reorganize SFF related stuff” — move-only; the wait was already the SFF HSM.
- git describe 624d5c514eed18: **v2.6.25-18**; contained in **v2.6.26-rc1**.
- New lines blamed on 4a2e5409472e8 (this commit).
Record: [buggy wait present since ~v2.6.26 (2008)] [long-lived, all LTS-class trees have it]
**Step 3.2: FOLLOW THE FIXES: TAG**
No Fixes: tag. Not applicable beyond that. The wait itself was not introduced by a recent buggy commit.
Record: [no Fixes tag; bug is decades-old HSM behavior]
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Recent libata-sff.c (path-limited): this commit is the latest on the file. No later follow-up on this wait. Older related HSM work (ce7514526742c, 8eee1d3ed5b6f) is already in this tree. Not part of a numbered series.
Record: [standalone] [no post-commit fix on this file] [no missing HSM locking prereq]
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Path-limited git log --author="Richard Weinberger" -- drivers/ata/:
only this commit. Author is a long-time embedded/UML maintainer (sigma star); CF is typical for that hardware. Damien Le Moal is the libata maintainer and applied it.
Record: [author: one-off ATA contributor, real CF user] [applied by subsystem maintainer]
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Uses existing ata_sff_busy_wait, ATA_TFLAG_POLLING, ata_sff_queue_pio_task, ata_sff_pio_task, ATA_SHORT_PAUSE. No new helpers. Parent hunks match 2008-era HSM structure.
Record: [no extra dependencies; standalone apply]
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**b4 dig -c 4a2e5409472e8:
- https://patch.msgid.link/[email protected]
- Single revision: [PATCH] [RFC] libata: Don't busy-wait...
- Damien: “Looks OK to me, but the patch title should be: ata: libata-
sff: …”
- Richard: agreed; Damien applied with the title change.
- No NAK, no stable nomination, no race objections in the retrieved thread (openwall/lkml/patchew). lore.kernel.org fetch returned 403; discussion recovered from patchew, openwall, and lkml.
Record: [lore/msgid: [email protected]] [v1 RFC only] [maintainer OK, title-only change] [no NAK]
**Step 4.2: CHECK WHO REVIEWED THE PATCH**b4 dig -w recipients: Richard Weinberger, linux-ide, linux-kernel, [email protected], [email protected] (Niklas Cassel), [email protected].
Visible review: Damien only (“Looks OK” / Applied). No Niklas reply found. No Reviewed-by.
Record: [CC: linux-ide + Cassel + Le Moal] [reviewer: Damien Le Moal applied]
**Step 4.3: SEARCH FOR THE BUG REPORT**
No bugzilla/syzbot. Author is the reporter: CF card, BSY held for milliseconds after last data block, IRQ busy-wait on every read.
Record: [one real-hardware report (author, CF)] [no distro bugzilla]
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES** Standalone RFC, not m/n. No sibling patches required.
Record: [standalone series]
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Web search of lore.kernel.org/stable for this subject found **no** stable-list discussion.
Record: [no stable@ discussion found]
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS** ata_sff_hsm_move, ata_sff_pio_task. Helpers used:ata_sff_busy_wait, ata_sff_queue_pio_task, ata_pio_sectors.
Record: [modified: ata_sff_hsm_move, ata_sff_pio_task]
**Step 5.2: TRACE CALLERS**ata_sff_hsm_move:
- ata_sff_pio_task (workqueue, in_wq=1)
- __ata_sff_port_intr → ata_sff_port_intr / ata_sff_interrupt (hardirq, in_wq=0) — **this is the spinning path**
- sata_sil.c, sata_dwc_460ex.c, pata_octeon_cf.c (CF)
ata_sff_pio_task: delayed work on ata_sff_wq, queued from ata_sff_qc_issue (PIO polling / writes) and now from the new data-in completion path.
Record: [IRQ HSM is the hot path for interrupt-driven PIO-in] [also used by octeon CF]
**Step 5.3: TRACE CALLEES**ata_pio_sectors → ata_pio_sector sets HSM_ST_LAST on last sector. Then the wait. ata_sff_queue_pio_task queues delayed work (delay 0). ata_hsm_qc_complete from wq calls ata_sff_irq_on + ata_qc_complete.
Record: [callees: existing PIO xfer + pio_task + qc complete]
**Step 5.4: FOLLOW THE CALL CHAIN**
Userspace read on PATA/CF/PIO → SCSI/libata → ata_sff_qc_issue (PIO- in, HSM_ST) → device IRQ → ata_sff_interrupt → ata_sff_hsm_move → last ata_pio_sectors → **old: 10ms ata_wait_idle in hardirq**.
Reachable from ordinary block reads on PIO ATA. Unprivileged if the device is mounted/readable.
Record: [reachable from userspace I/O on PIO/CF] [common on embedded, rare on AHCI DMA desktops]
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Error path at lines 1083–1086 still uses ata_wait_idle(ap) for PIO-in
+ ERR/DF. Unchanged. Other drivers (pata_octeon_cf, pata_via, …) still use ata_wait_idle in tf_load / issue, not this HSM completion wait.
Record: [no sibling copy of this exact last-block wait; error-path wait_idle left as-is]
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Yes in this lineage. Pre-commit parent still has status = ata_wait_idle(ap) after last PIO-in. Current HEAD already contains 4a2e5409472e8 (git merge-base --is-ancestor succeeded). ata_sff_hsm_move / ata_sff_pio_task / ata_wait_idle all exist.
Record: [bug introduced ~v2.6.26; this 7.3-rc4 tree has the fix; pre- fix code is the long-standing HSM wait]
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
The HSM last-block ata_wait_idle hunk is unchanged from 2008 until this commit. No conflicting refactor in this file after the candidate. Expected apply on older trees that still have that hunk: **clean**.
Record: [clean apply on trees that still have ata_wait_idle in that HSM branch]
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
This exact commit is already an ancestor of HEAD. That is not used as a reason to reject: the pipeline forbids “already selected” circular reasoning. No *different* fix for the same IRQ wait.
Record: [no alternate fix; this is the fix]
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY** drivers/ata/libata-sff.c — libata SFF (legacy IDE/PATA/BMDMA/CF PIO).
Record: [libata SFF] [IMPORTANT for PATA/CF/PIO; not core mm/net; unused on typical AHCI-only machines]
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Mature. HSM wait logic sat still for ~18 years. Recent ATA work is EH/SCSI, not this completion wait.
Record: [mature/stable HSM; bug is old, not a new-subsystem issue]
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
PIO data-in on SFF: CompactFlash, PATA in PIO, some embedded pata_* / pata_octeon_cf, fallback PIO. Not AHCI DMA.
Record: [driver/hardware-specific: SFF PIO-in, especially slow CF]
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Every PIO read whose device holds BSY/DRQ > ~100µs after the last block.
Author: multiple milliseconds, every read. Unprivileged I/O on that device is enough. Not a race.
Record: [trigger: PIO read on slow SFF/CF] [per-command] [userspace I/O]
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Hardirq + port lock + IRQs off for up to 10ms **per command**. Sequential 512-byte reads can stall the CPU for long stretches (lost IRQs, timer/network/audio latency; possible watchdog on a very slow device). Not a documented oops/UAF/corruption.
Official stable text also allows an **“oh, that's not good”** issue and notable interactivity problems. This is IRQ stall, not a micro- optimization.
Record: [failure: IRQ/CPU stall and latency] [severity: HIGH for CF/PATA PIO; LOW for AHCI-only]
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
- Benefit: stops multi-ms IRQ spin on every slow PIO-in read; real CF report; embedded LTS users still have this hardware.
- Risk: ~17 lines, existing polling flag + workqueue; fast devices unchanged (~100µs still in IRQ); ~2 months in mainline with no follow- up revert/fix on this file.
Record: `[benefit: high for CF/PATA] [risk: low-medium] [ratio:
favorable]`
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real hardware: CF holds BSY for milliseconds; author hit it.
- Busy-wait is in hardirq, port lock held, IRQs disabled — system-wide latency, not a comment-only cleanup.
- Small (+17/-7), one file, existing ATA_TFLAG_POLLING + ata_sff_pio_task.
- Maintainer applied after review (“Looks OK”).
- Bug present since v2.6.26; no extra prereqs.
- Fast path unchanged if the device idles within ~100µs.
AGAINST:
- Worded as an improvement, not a crash/CVE.
- One reporter; no syzbot/bugzilla; no Cc: stable.
- Performance/interactivity bar in stable-rules prefers distro maintainers + bugzilla; this did not go that route.
- HSM changes can regress odd controllers (residual IRQs because nIEN is not set).
- Affects a shrinking hardware set (PATA/CF), not all machines.
UNRESOLVED:
- lore.kernel.org HTTP 403; thread reconstructed from b4 + mirrors.
- No public confirmation from a second user.
- No lockup-detector trace in the message (severity inferred from 10ms×N in hardirq, not from a posted stack).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — matches ata_wait_idle bits; author tested on CF; maintainer applied.
2. Fixes a real bug that affects users? **PASS** — IRQ CPU hog on real CF reads.
3. Important issue? **PASS** — “oh, that's not good” / interactivity:
multi-ms hardirq spin per read is a stall, not a cosmetic tweak. Not a UAF/panic.
4. Small and contained? **PASS** — 24 lines, one file.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — same HSM functions and flags; pre-fix hunk is the classic ata_wait_idle sequence.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Not a device ID, DT, build, or doc patch. Closest: **hardware workaround** for slow CF BSY, implemented as a bounded IRQ wait + existing polling.
Record: [quasi-quirk: slow device BSY after last PIO-in block]
**Step 9.4: MAKE YOUR DECISION**
This tree’s libata-sff HSM still has (and had for ~18 years) the 10ms IRQ wait. The patch is a small, maintainer-acked correction that stops hogging the CPU with IRQs off on every slow PIO-in completion. That is in-scope for stable: real user-visible stall, surgical, no new API, no missing prereqs.
---
### What the commit solves for stable users
On interrupt-driven SFF PIO reads, after the last data block the host must wait for BSY/DRQ to clear with no completion IRQ. The kernel spun in ata_wait_idle() for up to 10ms in hardirq under the port lock. Slow CF (and similar) keeps BSY for milliseconds, so **every read** stalls the CPU. The fix waits ~100µs in IRQ, then uses the existing PIO polling workqueue, which sleeps instead of spinning.
### Stable rules
Meets “obviously correct,” real user-visible bug, small scope, no new API, applies to this codebase. Importance is IRQ stall / interactivity, which stable-rules explicitly allow as “oh, that's not good,” not only oops/corruption.
### Risk vs benefit
Benefit is high for CF/PATA PIO (embedded, industrial, some laptops). Risk is a modest HSM timing change, mitigated by reusing ATA_TFLAG_POLLING (IRQ handler already ignores those commands) and by leaving fast devices on the old complete-in-IRQ path.
### Concerns
No Fixes:/second reporter; nIEN not set when flipping to polling (acceptable for this protocol); HSM always has some controller risk. None of those outweigh the stall fix.
---
Verification:
- [Phase 1] Subject/body/tags from git log -1 --format=fuller 4a2e5409472e8: two SOBs, no Fixes/Reported-by/Link/stable.
- [Phase 1] Body describes CF + multi-ms BSY + IRQ/ata_wait_idle 10ms spin.
- [Phase 2] git show --stat: drivers/ata/libata-sff.c +17/-7; hunks in ata_sff_hsm_move and ata_sff_pio_task.
- [Phase 2] ata_wait_idle in include/linux/libata.h:
ata_sff_busy_wait(..., ATA_BUSY|ATA_DRQ, 1000) = 10ms; new wait uses max=10 (~100µs).
- [Phase 2] __ata_sff_interrupt skips port_intr when ATA_TFLAG_POLLING is set (verified in libata-sff.c).
- [Phase 2] ata_hsm_ok_in_wq() returns 1 if ATA_TFLAG_POLLING — WARN consistency checked.
- [Phase 3] git blame on wait site: Tejun 624d5c514eed18 (2008); git describe → v2.6.25-18 / contained in v2.6.26-rc1.
- [Phase 3] git log HEAD -- drivers/ata/libata-sff.c: no later commit on this file after 4a2e5409472e8.
- [Phase 3] Path-limited author log: only this ATA commit.
- [Phase 4] b4 dig -c 4a2e5409472e8: msgid [email protected].
- [Phase 4] b4 dig -a: v1 RFC only.
- [Phase 4] b4 dig -w: linux-ide, Cassel, Le Moal CCd.
- [Phase 4] Damien “Looks OK” / “Applied to for-7.3” via lkml/openwall; no NAK.
- [Phase 4] lore.kernel.org WebFetch: 403. Thread taken from b4 + patchew/openwall/lkml.
- [Phase 4] No stable@ hits for this subject.
- [Phase 5] Callers of ata_sff_hsm_move: ata_sff_pio_task, __ata_sff_port_intr, sata_sil.c, sata_dwc_460ex.c, pata_octeon_cf.c.
- [Phase 6] git describe HEAD / make kernelversion / Makefile:
**7.3.0-rc4**.
- [Phase 6] git merge-base --is-ancestor 4a2e5409472e8 HEAD: yes.
- [Phase 6] Parent file still has status = ata_wait_idle(ap) in the last PIO-in branch.
- [Phase 8] Failure mode: hardirq busy-wait up to 10ms per PIO-in, not UAF/panic.
- UNVERIFIED: second independent user report; live NMI/softlockup log (not in the message).
The patch is small, correct against the SFF HSM, and fixes a real IRQ- context stall on hardware that still shows up on stable/embedded systems.
**YES**
drivers/ata/libata-sff.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
drivers/ata/libata-sff.c +17 -7
@@ -1114,8 +1114,14 @@ int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,if (ap->hsm_task_state ==HSM_ST_LAST && (!(qc->tf.flags &ATA_TFLAG_WRITE ))) { -/* all data read */ - status =ata_wait_idle (ap); + status =ata_sff_busy_wait (ap, +ATA_BUSY |ATA_DRQ ,10 ); +if (status !=0xff && + (status & (ATA_BUSY |ATA_DRQ ))) { + qc->tf.flags |=ATA_TFLAG_POLLING ; +ata_sff_queue_pio_task (link,0 ); +return 0 ; + } goto fsm_start; } }
@@ -1213,7 +1219,7 @@ static void ata_sff_pio_task(struct work_struct *work) container_of(work, struct ata_port, sff_pio_task.work);struct ata_link *link = ap->sff_pio_task_link;struct ata_queued_cmd *qc; -u8 status; +u8 status, wait_mask;int poll_next;spin_lock_irq (ap->lock);
@@ -1229,6 +1235,10 @@ static void ata_sff_pio_task(struct work_struct *work) fsm_start:WARN_ON_ONCE (ap->hsm_task_state ==HSM_ST_IDLE ); + wait_mask =ATA_BUSY ; +if (ap->hsm_task_state ==HSM_ST_LAST ) + wait_mask |=ATA_DRQ ; +/* * This is purely heuristic. This is a fast path. * Sometimes when we enter, BSY will be cleared in
@@ -1236,14 +1246,14 @@ static void ata_sff_pio_task(struct work_struct *work)* or something. Snooze for a couple msecs, then * chk-status again. If still busy, queue delayed work. */ - status =ata_sff_busy_wait (ap,ATA_BUSY ,5 ); -if (status &ATA_BUSY ) { + status =ata_sff_busy_wait (ap, wait_mask,5 ); +if (status & wait_mask) {spin_unlock_irq (ap->lock);ata_msleep (ap,2 );spin_lock_irq (ap->lock); - status =ata_sff_busy_wait (ap,ATA_BUSY ,10 ); -if (status &ATA_BUSY ) { + status =ata_sff_busy_wait (ap, wait_mask,10 ); +if (status & wait_mask) {ata_sff_queue_pio_task (link,ATA_SHORT_PAUSE ); goto out_unlock; }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] ata: libata-sff: don't busy-wait for PIO data-in command completion
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] ata: libata-sff: race between ata_sff_hsm_move() and ata_sff_flush_pio_task() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] ata: libata-sff: race between ata_sff_hsm_move() and ata_sff_flush_pio_task() --
commit ffe3d0726a492588a046ac4c8f5eafd55e0c371b
Author: Richard Weinberger <[email protected]>
ata: libata-sff: don't busy-wait for PIO data-in command completion
This commit bounds the inline busy-wait for PIO data-in completion in ata_sff_hsm_move() to ~100us. If the device remains busy after draining the final data block, it sets ATA_TFLAG_POLLING and queues ata_sff_pio_task() to poll for completion in process context.
Quoted 11 lines
drivers/ata/libata-sff.c +1
-2@@ -1114,8 +1114,14 @@ int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,if (ap->hsm_task_state ==HSM_ST_LAST && (!(qc->tf.flags &ATA_TFLAG_WRITE ))) { -/* all data read */ - status =ata_wait_idle (ap); + status = ata_sff_busy_wait(ap,
drivers/ata/libata-sff.c int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, · line 1127
Quoted 10 lines
drivers/ata/libata-sff.c +7
-0+ ATA_BUSY | ATA_DRQ, 10); +if (status !=0xff && + (status & (ATA_BUSY |ATA_DRQ ))) { + qc->tf.flags |=ATA_TFLAG_POLLING ; +ata_sff_queue_pio_task (link,0 ); +return 0 ; + } goto fsm_start; } }
[Severity: High]
Can queuing ap->sff_pio_task from the interrupt handler here race with ata_sff_flush_pio_task() during timeout recovery and trigger a BUG_ON()?
Previously, ap->sff_pio_task was only initially queued at command issue time and re-queued by ata_sff_pio_task() itself, so cancel_delayed_work_sync() in ata_sff_flush_pio_task() guaranteed the work item would not be re-armed before ap->hsm_task_state was reset to HSM_ST_IDLE:
drivers/ata/libata-sff.c:ata_sff_flush_pio_task() {
...
cancel_delayed_work_sync(&ap->sff_pio_task);
spin_lock_irq(ap->lock);
ap->hsm_task_state = HSM_ST_IDLE;
spin_unlock_irq(ap->lock);
ap->sff_pio_task_link = NULL;
}When an interrupt-driven PIO data-in command times out (via ata_scsi_cmd_error_handler() -> ata_sff_flush_pio_task() or ata_exec_internal_sg() -> ata_sff_flush_pio_task()), ap->sff_pio_task is not yet pending, so cancel_delayed_work_sync() returns immediately.
If the final data block interrupt arrives on another CPU before ata_sff_flush_pio_task() acquires ap->lock:
CPU0 CPU1 (IRQ)ata_sff_flush_pio_task()
cancel_delayed_work_sync()
__ata_sff_port_intr()
ata_sff_hsm_move()
ata_pio_sectors(qc)
qc->tf.flags |= ATA_TFLAG_POLLING;
ata_sff_queue_pio_task(link, 0); spin_lock_irq(ap->lock);
ap->hsm_task_state = HSM_ST_IDLE;
spin_unlock_irq(ap->lock);
ap->sff_pio_task_link = NULL;
When ata_sff_pio_task() then executes on ata_sff_wq, wouldn't it hit BUG_ON(ap->sff_pio_task_link == NULL), or enter fsm_start with ap->hsm_task_state == HSM_ST_IDLE while error handling is active?
[ ... ]
Quoted 1 line
endasi
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 ALSA: usb-audio: Rename the Audient iD14 monitor mix volume control
In reply to Sasha LevinFrom: Neil Andrews <[email protected]>
[ Upstream commit 9c0564fcc21aec4f5b7648f61865ce3fc2b84a7f ]
On the Audient iD14 (2708:0008), feature unit 12 is traced through to the Speaker output terminal and is therefore exported as "Speaker Playback Volume". The name fits it badly. It advertises Volume on only four of its six logical channels, which the driver records as cmask=0xf, channels=4 on a 6-channel playback stream, and it sits on the monitor mixer branch rather than in the direct playback path:
INPUT_TERMINAL 2 (USB streaming, 6ch) -> EXTENSION_UNIT 51 ->
FEATURE_UNIT 10 (no controls) -> OUTPUT_TERMINAL 20 (Speaker)
while FU 12 hangs off MIXER_UNIT 60 and feeds back into EXTENSION_UNIT 51.
Userspace adopts the control as the stream's hardware playback volume, so any setting below 0 dB attenuates part of the stream and not the rest. Measured over the device's own digital loopback, with one -12 dBFS tone per channel played straight to hw:, PCM channel 0 is unaffected while channel 1 tracks the control: at 107/127 (-20 dB) the two read -15.89 and -35.89 dBFS, a 20.00 dB imbalance, and at 127/127 both read -15.89 dBFS.
Give the unit a non-standard name so that it is no longer taken for the stream's master volume. Dropping the control instead also fixes the imbalance, but FU 12 keeps its value across a module reload, so dropping it strands a device that is already attenuated with nothing able to reset it. Renaming leaves the monitor gain reachable and that recovery path intact.
The mapped name ends in "Playback" because a name from the map suppresses the automatic " Playback" but still gets " Volume" appended; the control comes out as "Monitor Mix Playback Volume".
Tested on the ACP path with PipeWire, which is where the problem
reproduces: the control now stays at 127 at every volume setting and the imbalance is 0.00 dB, and setting it by hand to 107 and back to 127 gives 20.00 dB and 0.00 dB as before.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). This is a device- specific USB mixer name-map quirk for Audient iD14 MkII (2708:0008):
userspace treats a monitor-mix control as master volume and creates a **20 dB channel imbalance**. That is real, measured, and already the kind of hardware quirk 6.12.y takes.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ALSA: usb-audio] [Rename] Audient iD14 monitor mix volume control
Subsystem: ALSA USB audio mixer maps. Verb “Rename” is a quirk, not a
refactor: the control is misnamed so PipeWire/PulseAudio treat it as stream master volume.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Link: https://lore.kernel.org/linux-sound/0102019fed22f9d3-... — original [BUG] report
- Link: https://patch.msgid.link/0102019ffcdbb1e6-... — submitted patch
- Signed-off-by: Neil Andrews <[email protected]> — author
- Signed-off-by: Takashi Iwai <[email protected]> — ALSA maintainer
- No Fixes: (expected: not a regression; hardware descriptor + generic parser)
- No Cc: stable (expected for this review)
- No Reported-by: / Tested-by: / Reviewed-by: / Acked-by:
- Ignore pipeline Signed-off-by: Sasha Levin / [Upstream commit ...]
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** On Audient iD14 USB 2708:0008, FU 12 is named "Speaker Playback Volume" because it traces to the Speaker OT, but it is a 4-of-6-channel monitor-mix control (cmask=0xf), not stream master volume.
- **Symptom:** Userspace uses it as hardware playback volume. Below 0 dB some PCM channels are attenuated and others are not. Measured 20.00 dB imbalance at 107/127; 0.00 dB at 127/127.
- **Root cause:** Topology: USB streaming → EU 51 → FU 10 (no controls) → Speaker OT 20; FU 12 hangs off mixer unit 60 and feeds back into EU 51.
- **Why rename not drop:** Dropping also fixes imbalance, but FU 12 keeps its value across module reload, so hiding the control strands an already-attenuated device with no recovery except power cycle.
- **Versions:** Reporter: “Not a regression”; same results on 6.19.14 and 7.1.6.
- **Tested:** ACP + PipeWire; after rename the control stays at 127 and imbalance is 0.00 dB.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. It is an explicit hardware-quirk bug fix: wrong exported kcontrol name causes incorrect userspace volume application.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: sound/usb/mixer_maps.c only (~+18 lines, 0 removed)
- New audient_id14_map[]: { 12, "Monitor Mix Playback" }
- New usbmix_ctl_maps[] entry: USB_ID(0x2708, 0x0008)
- Scope: single-file, data-only, device-ID gated
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** Generic mixer walk names FU 12 from Speaker OT → "Speaker Playback Volume" (mapped_name=0 so " Playback" is auto-appended, then " Volume").
- **After:** find_map() hits unit 12; check_mapped_name() copies "Monitor Mix Playback"; auto " Playback" is skipped; " Volume" is still appended → "Monitor Mix Playback Volume". PipeWire no longer selects it as master volume.
- Path: USB mixer build at probe (snd_usb_create_mixer → usbmix_ctl_maps lookup → __build_feature_ctl).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Hardware workaround / mixer name-map quirk.** Wrong ALSA control name → userspace hardware-volume path → asymmetric attenuation. Same class as existing maps (e.g. Hercules "Master Playback" instead of "Speaker Playback").
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct relative to __build_feature_ctl() naming rules, which the commit message documents.
- Surgical; no locking, alloc, or API change.
- Regression risk: only 2708:0008. Userspace looking for "Speaker Playback Volume" on this card will miss it — that is the intended fix. The control remains settable for recovery.
- Maintainer chose rename over { 12, NULL } after hardware tests of both.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: Insertion is next to maps that have been there for years (usbmix_ctl_maps since 2005; MAYA44 044bddb9ca8d49 2015; KEF d70a1b9893f820 2014). Buggy *behavior* is generic USB mixer naming of FU 12 from Speaker OT, not a recent 6.12-era commit. Device is class- compliant; the bug exists whenever this interface is used with snd-usb- audio.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable. Reporter called it “Not a regression.”
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent mixer_maps.c changes in *this* tree are other device maps/quirks (Corsair Virtuoso, Razer Barracuda dB map, KTMicro rename, Corsair HS80). Same pattern. Standalone; not “patch X/Y”.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: No other Neil Andrews commits under sound/usb/ in this tree. Maintainer is Takashi Iwai, who applied the patch.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Uses usbmix_name_map / usbmix_ctl_maps / find_map() / check_mapped_name() already in this tree. No new helpers. Standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c not usable: commit SHA is not in this checkout.
- b4 mbox on msgid found 2 messages: patch + Takashi “Applied to for- next branch. Thanks.”
- Bug thread (4 messages): Neil’s [BUG] report → Takashi suggested skip *or* rename → Neil tested both on 7.1.6 out-of-tree → Takashi:
“Let's take the rename approach” → formal patch applied.
- No NAKs. No later unapplied revision.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: To/Cc: [email protected], [email protected], linux- [email protected]. Reviewed and applied by ALSA USB maintainer Takashi Iwai.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record:
- Lore [BUG] snd-usb-audio: Audient iD14 (2708:0008) 20 dB channel imbalance with loopback RMS numbers, descriptor dump, alsa-info.
- Independent real-world reports of L/R imbalance below 100% (AskUbuntu, Reddit, markwatkinson.com, GitHub Audientid14-linux-fix).
- UCM later qualified the userspace path: alsa-ucm-conf Audient- iD14-HiFi-0008.conf avoids driving FU 12; ACP (api.alsa.use- ucm=false) still hits it; alsactl restore of a value below 0 dB still hits it.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Single standalone patch. Follow-up UCM work is userspace (alsa- ucm-conf PR mentioning this kernel quirk). No kernel series dependency.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: Web search of lore.kernel.org/stable for this subject found no stable-list discussion. No recorded reason to skip it.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: No functions modified. New static data consumed by existing mixer build.
**Step 5.2: TRACE CALLERS**
Record (verified in this tree):
- usbmix_ctl_maps scanned in mixer create (~line 3272 of sound/usb/mixer.c)
- find_map() in __build_feature_ctl() (~1689)
- check_mapped_name() then append_ctl_name(..., " Volume") (~1740–1786)
- Probe path when 2708:0008 is enumerated; not IRQ/hot-path locking
**Step 5.3: TRACE CALLEES**
Record: Data-only. Callees of the *users* of this map: find_map, check_ignored_ctl (not taken because name is non-NULL), check_mapped_name, append_ctl_name.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Plug in device → snd-usb-audio probe → mixer descriptor walk → FU 12 kcontrol registered → PipeWire/PulseAudio/alsactl. Userspace- reachable. Unprivileged volume changes trigger the imbalance.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same file already remaps “Speaker Playback” (Hercules, Gigabyte, ASUS, UAC3 BADD). This tree already contains c4f7e90e66b6d “Rename ALSA kcontrol PCM and PCM1 for the KTMicro sound card” — a mixer_maps rename that *was* backported with Cc: stable.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes.
- git describe HEAD: p-6.12-3-gc504cf0baa3d8; make kernelversion:
**6.12.111**
- mixer_maps.c and __build_feature_ctl() naming logic are present
- audient_id14_map / USB_ID(0x2708, 0x0008) **not** present (git grep empty)
- Existing Audient entry is MkI only: DEVICE_FLG(0x2708, 0x0002, QUIRK_FLAG_IGNORE_CTL_ERROR) in quirks.c (df0380b9539b0, 2021). Different product ID; does not fix MkII naming.
- Bug is descriptor + generic parser, present since this driver existed; reporter confirmed not a regression.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply. Local hunk context matches the patch (MAYA44 0x2573:0x0008 then KEF 0x27ac:0x1000). usbmix_name_map layout { id, name, control, dB } matches { 12, "Monitor Mix Playback" }.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No Audient monitor-mix rename. No other 6.12 fix for 2708:0008 mixer names.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: sound/usb/ (CONFIG_SND_USB_AUDIO). **IMPORTANT** for USB audio interfaces; device-specific, not core mm/fs. Mixer maps are the designed extension point (“if the mixer topology is too complicated… add the entries in usbmixer_maps.c”).
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature driver; this file still gets device maps regularly. Recent 6.12 backports in the same file are other quirks/maps.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Users of Audient iD14 MkII USB 2708:0008 with snd-usb-audio (class-compliant). Not universal. ACP/PipeWire without the UCM profile is the reproducing path; alsactl restore of a low FU 12 value affects even UCM users.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Common for desktop use: plug in, play audio, move volume below 100%. Unprivileged. Not a race. Hardware keeps attenuated FU 12 across module reload.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Severe **audio correctness** bug: 20 dB L/R (or channel 0 vs 1) imbalance. Not oops/UAF/corruption. HIGH for this device class (interface unusable at typical desktop volumes). Multiple independent user reports.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: HIGH for iD14 MkII on 6.12 (desktop/PipeWire, no or old UCM).
- Risk: VERY LOW — +18 lines, one USB ID, no behavioral change for any other device.
- Ratio: strongly favors backport. Same class as maps already in this tree.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real, measured 20 dB imbalance; loopback RMS; PipeWire ACP reproduction
- Hardware quirk / mixer name map — explicit stable exception
- Small, data-only, device-ID gated
- Applies cleanly to this 6.12 tree; infrastructure present since 2005
- ALSA maintainer requested rename, tested both options, applied v1
- Analogous KTMicro mixer rename already in this tree via stable
- Long-standing user complaints of L/R imbalance on this hardware
- No new APIs/features/module parameters
AGAINST:
- Not a crash/security/data-corruption issue
- Newer alsa-ucm-conf can avoid driving the control on the HiFi profile
- Does not cover MkI 2708:0002 (out of scope of this patch)
UNRESOLVED:
- Exact mainline SHA (not in this checkout; b4 dig -c unused)
- No stable@ discussion found
Those do not outweigh the quirk: UCM is userspace and not guaranteed on 6.12 distros; MkI is a different ID.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — maintainer-approved; hardware loopback tests of rename vs drop
2. Fixes a real bug that affects users? **PASS** — 20 dB imbalance; multiple reports
3. Important issue? **PASS** — serious functional audio bug on a shipping USB interface (quirk exception)
4. Small and contained? **PASS** — ~18 lines, one file
5. No new features or APIs? **PASS** — existing map table only
6. Can apply to the local tree? **PASS** — clean context at MAYA44/KEF
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Hardware quirk / workaround** (USB mixer name map for a misdescribed control). Same bucket as USB/PCI/codec quirks that stable already takes.
**Step 9.4: MAKE YOUR DECISION**
Backport to this 6.12.y tree. The bug is in this kernel’s generic mixer naming; the device works here; the fix is a one-ID table entry with negligible regression risk.
===============================================================
Verification
===============================================================
- [Phase 1] Parsed subject/tags/body from the provided commit and lore mbox; no Fixes/Cc:stable; Links to bug + patch
- [Phase 1] Bug thread: “Not a regression”; 6.19.14 and 7.1.6 identical; 20.00 dB at 107/127
- [Phase 2] Diff: +18 lines in sound/usb/mixer_maps.c only; audient_id14_map + USB_ID(0x2708, 0x0008)
- [Phase 2] Verified __build_feature_ctl(): mapped name skips " Playback", still appends " Volume" (mixer.c 1740–1786)
- [Phase 2] Verified check_ignored_ctl(): non-NULL name is not ignored (so rename keeps the control)
- [Phase 3] git blame insertion neighbors: MAYA44 2015, KEF 2014, maps table since 2005
- [Phase 3] git log --author='Neil Andrews' -- sound/usb/: empty in this tree
- [Phase 3] Existing Audient quirk df0380b9539b0 is 2708:0002 IGNORE_CTL_ERROR only
- [Phase 3] KTMicro rename c4f7e90e66b6d is an ancestor of HEAD (same class, already backported)
- [Phase 4] b4 mbox patch msgid: 2 msgs; Takashi applied to for-next; no NAK
- [Phase 4] b4 mbox bug msgid: 4 msgs; Takashi asked for rename; Neil measured both options
- [Phase 4] lore WebFetch 403; used b4 + lkml.iu.edu + patchew instead
- [Phase 4] b4 dig -c: UNVERIFIED (SHA not in this tree)
- [Phase 4] stable@ search: no hits
- [Phase 5] Callers: mixer create map walk (~3272), find_map in __build_feature_ctl (~1689)
- [Phase 6] git describe HEAD / make kernelversion: 6.12.111 pending-6.12
- [Phase 6] git grep audient_id14_map / USB_ID(0x2708, 0x0008): not in tree (bug still present)
- [Phase 6] Insertion point in local mixer_maps.c 586–595 matches the patch (clean apply)
- [Phase 7] CONFIG_SND_USB_AUDIO in sound/usb/Kconfig
- [Phase 8] Failure mode: 20 dB channel imbalance, not oops; severity HIGH for this device
- UNVERIFIED: mainline commit SHA; whether every 6.12 distro ships the later UCM profile (kernel still should export the correct name)
This is a small, tested, device-ID-gated mixer quirk that stops PipeWire from driving a partial-coverage monitor mix as master volume. It belongs in this 6.12 tree.
**YES**
sound/usb/mixer_maps.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
sound/usb/mixer_maps.c +18 -0
@@ -505,6 +505,19 @@ static const struct usbmix_connector_map gigabyte_b450_connector_map[] = { {} }; +/* Audient iD14: FU 12 advertises Volume on only 4 of its 6 logical channels +* and sits on the monitor mixer branch, but it is traced through to the +* Speaker output terminal and gets named "Speaker Playback Volume". Userspace +* then adopts it as the stream's hardware volume, and any setting below 0 dB +* attenuates some channels but not others (20 dB imbalance at 80%). Give it a +* non-standard name so that it is no longer taken for the stream's master +* volume, while remaining reachable for anyone who wants the monitor gain. +*/ +static const struct usbmix_name_map audient_id14_map[] = { + {12 ,"Monitor Mix Playback" },/* FU, partial coverage */ + {} +}; +/* * Control map entries */
@@ -588,6 +601,11 @@ static const struct usbmix_ctl_map usbmix_ctl_maps[] = { .id = USB_ID(0x2573, 0x0008), .map = maya44_map, }, + { +/* Audient iD14 */ + .id = USB_ID(0x2708, 0x0008), + .map = audient_id14_map, + }, {/* KEF X300A */ .id = USB_ID(0x27ac, 0x1000),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 netpoll: do not warn when the best-effort pool refill fails
In reply to Sasha LevinFrom: Breno Leitao <[email protected]>
[ Upstream commit 84c0ff1efb62b0053aa265b8deb13842f68f1a74 ]
refill_skbs() tops up the per-netpoll skb pool with GFP_ATOMIC and simply stops on the first allocation failure, leaving the pool partially filled; a later refill tops it up once memory frees up. The allocation failing is therefore an expected and fully handled condition, but without __GFP_NOWARN the page allocator emits a warn_alloc() splat with a full stack trace on every miss.
Pass __GFP_NOWARN so the best-effort refill stays quiet, mirroring the same change in netconsole's find_skb().
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.18.y** (v6.18.53). At that tag, refill_skbs() still allocates with plain GFP_ATOMIC, so the bug exists here. This is a one-line __GFP_NOWARN change on a best-effort refill that already treats allocation failure as success-with-partial-fill.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[netpoll] [do not warn] [silence warn_alloc on expected GFP_ATOMIC skb-pool refill failure]**
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- **Fixes:** none (expected for this review pipeline)
- **Reported-by / Tested-by / Reviewed-by / Acked-by / Cc: stable:** none
- **Link:** https://patch.msgid.link/20260629-netpoll_no_warn-v1-2-
[email protected] (netdev series, patch 2/2)
- **Signed-off-by:** Breno Leitao (author; NETCONSOLE maintainer); Jakub Kicinski (netdev maintainer)
- Ignored pipeline tags: [Upstream commit 84c0ff1efb62…], `Signed-off-
by: Sasha Levin`
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** refill_skbs() tops up a per-netpoll pool of 32 skbs with GFP_ATOMIC. Failure is expected: the loop breaks, leaving a partial pool, and a later refill tries again.
- **Symptom:** without __GFP_NOWARN, the page allocator still fires warn_alloc() (pr_warn + dump_stack() + __show_mem()), a large splat on every miss.
- **Root cause:** best-effort allocation used a GFP mask that still warns.
- **Version info:** none in the commit text. Author date 2026-06-29; merged to net-next 2026-06-30.
- Cover letter (series 0/2, verified in the mbox): this class of splat was seen on the **Meta fleet**. warn_alloc emits 100+ printk lines which then go out through netconsole, **consuming the scarce skb pool** and crowding out the real diagnostic. Stack in the cover letter is the send path (__alloc_skb → send_udp → netconsole_write → nbcon_kthread_func), i.e. the sibling find_skb() site; this commit is the matching refill-path silence.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. It is explicitly a warning-suppression for an expected, already-handled allocation failure. The functional extra is that those warnings themselves eat the emergency pool they exist to protect.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- **File:** net/core/netpoll.c — 1 insertion, 1 deletion
- **Function:** refill_skbs()
- **Scope:** single-file surgical one-liner
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- **Before:** alloc_skb(MAX_SKB_SIZE, GFP_ATOMIC); on NULL, break (partial fill).
- **After:** same, with GFP_ATOMIC | __GFP_NOWARN.
- Path: best-effort refill from __netpoll_setup() and from refill_skbs_work_handler() (workqueue scheduled when find_skb() dequeues from the pool). Not a new error path; allocation behavior is unchanged.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- **Category:** logic/correctness of GFP flags (expected GFP_ATOMIC failure must not warn). Secondary effect: resource starvation of the 32-skb emergency pool via printk/netconsole.
- **Mechanism:** warn_alloc() in mm/page_alloc.c returns immediately if __GFP_NOWARN is set; otherwise it rate-limits to 1/10s but still dumps stack + meminfo. Those printks are exactly what the pool is supposed to carry under OOM.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: __GFP_NOWARN is the established pattern for best- effort GFP_ATOMIC (many net/ core users already do this).
- Minimal: one GFP flag bit.
- **Regression risk: very low.** Allocation success/failure, pool length, locking, and refill scheduling are unchanged. warn_alloc does **not** use WARN_ON / panic_on_warn (verified: it is pr_warn + dump_stack + warn_alloc_show_mem).
- Red flags: none on this hunk. Series was [PATCH net-next 2/2] (not net), which is a process signal, not a code risk.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- alloc_skb(..., GFP_ATOMIC) in this refill loop dates to **1da177e4c3f41 (Linux-2.6.12-rc2)** — present for the entire git history.
- Per-target pool: 221a9c1df790fa (“Individualize the skb pool”, 2024-11-14) — **in v6.18.53**.
- Refill moved off the spinlock: 327c20c21d80e0 (“Fix deadlock in memory allocation under spinlock”, 2025-11-03, Fixes:
248f6571fd4c51) — **in v6.18.53**. That commit even notes printk from OOM-in-refill can re-enter netpoll; after it, allocation is outside the lock, so this NOWARN change does not fight a deadlock, it only stops the splat.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Not applicable. The GFP_ATOMIC refill is original netpoll behavior, not a recent regression.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record (on v6.18.53, -- net/core/netpoll.c):
- Recent real fixes already in this tree: UAF on shutdown, IPv6 local- address corruption, MAC truncation, workqueue init order, refcount cleanup, the refill deadlock fix.
- **This NOWARN change is not in v6.18.53.**
- Standalone vs series: **patch 2/2**. Sibling 1/2 is 09f7a613a14fd “netconsole: do not warn when the best-effort skb allocation fails” (touches drivers/net/netconsole.c find_skb() **after** that function was moved out of netpoll). No code dependency between the two hunks.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Breno Leitao is listed as **NETCONSOLE** maintainer in MAINTAINERS. He authored the per-target pool and the refill-deadlock fix. High-confidence author for this code.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record:
- Needs the existing refill_skbs() + skb_pool (present since 2.6 / individualized in 6.18).
- Does **not** need patch 1/2 to compile or run.
- Cover letter mentioned “reschedule the workqueue to try later”; **that was not in either committed patch**. Current code already schedule_work(&np->refill_wq) from find_skb() on pool dequeue. No missing follow-up required for this hunk.
- **Standalone; can apply on this tree.**
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 84c0ff1efb62b: https://patch.msgid.link/20260629-
[email protected]
- b4 dig -a: **v1 only** (no v2/v3).
- Mbox (/tmp/netpoll-nowarn.mbox): cover letter + 1/2 + 2/2 + patchwork “applied to netdev/net-next.git” by Jakub Kicinski. **No NAK, no reviewer comments, no Cc: stable in the thread.**
- Submitted as **[PATCH net-next]**, not net. Merged immediately (29 Jun → applied 1 Jul 2026).
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To/Cc netdev maintainers (Kicinski, Dumazet, Miller, Abeni, Horman, Lunn), netdev@, linux-kernel@, kernel- [email protected]. No extra Reviewed-by on the git commit; maintainer merge is the review signal.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No bugzilla/syzbot. Evidence is the cover letter: Meta fleet, page allocation failure: order:0, mode:0x40820(GFP_ATOMIC|__GFP_COMP), stack through netconsole send. That stack is the **find_skb/send_udp** site, not refill_skbs itself.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Two independent one-liners. In **this** 6.18 tree, find_skb() is still in net/core/netpoll.c:279 (alloc_skb(len, GFP_ATOMIC) without NOWARN). Patch 1/2 would not apply as written (wrong file). This 2/2 patch does not fix that hot path; it only silences the async refill.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: **UNVERIFIED** — lore.kernel.org/stable/ and WebFetch both returned 403.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: refill_skbs() only.
Step 5.2: TRACE CALLERS
Record (verified in this tree):
- refill_skbs_work_handler() → process-context workqueue, scheduled from find_skb() after skb_dequeue(&np->skb_pool).
- __netpoll_setup() → setup/open path (netconsole netpoll_setup(), plus bond/team/macvlan/vlan/bridge/dsa netpoll setup).
Step 5.3: TRACE CALLEES
Record: alloc_skb() → skb_queue_tail(). On failure, break. No new locks, frees, or I/O.
Step 5.4: FOLLOW THE CALL CHAIN
Record:
- User-reachable via **netconsole** (module/netconsole=), kgdb-style netpoll users, and stacked devices’ ndo_netpoll_setup.
- Typical trigger: memory pressure while netconsole is logging → find_skb() falls back to the pool → schedule_work(refill_wq) → refill_skbs() GFP_ATOMIC fails → warn_alloc splat → those lines go through netconsole again.
- Unprivileged userspace cannot generally fire this unless netconsole is enabled; operators enable it for crash/OOM debugging — exactly when GFP_ATOMIC fails.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Hot-path twin still present here: find_skb() at net/core/netpoll.c:279. Same GFP_ATOMIC-without-NOWARN. Many other net/ callers already use GFP_ATOMIC | __GFP_NOWARN.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: **Yes.** git describe HEAD → v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion → **6.18.53**.
At v6.18.53:net/core/netpoll.c:
``` skb = alloc_skb(MAX_SKB_SIZE, GFP_ATOMIC); ```
git merge-base --is-ancestor 84c0ff1efb62b v6.18.53 → **not in v6.18.53**.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: git show 84c0ff1efb62b -- net/core/netpoll.c | git apply --check on **v6.18.53** → **CLEAN_APPLY**. Surrounding refill_skbs() matches. No refactor needed.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No NOWARN/best-effort commits on these files in v6.18.53 history. Deadlock fix is already here and complementary, not a substitute.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: **net/core netpoll** used by netconsole and stacked netdevs. **IMPORTANT** (not core mm/scheduler; not obscure staging). Netconsole is the production debug path for machines that cannot use a serial console.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Actively maintained by Breno; several 6.18-era netpoll fixes already in this tree. Mature mechanism (skb pool since 2.6).
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: **Config/driver-specific** — CONFIG_NETPOLL / netconsole / bonding/team/vlan/macvlan/bridge/dsa netpoll. Not universal, but netconsole is widely used in production fleets (explicit Meta report).
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: GFP_ATOMIC miss while the pool is not full — setup under pressure, or workqueue refill after the pool was used. Common under OOM/memory pressure with netconsole on. Not a userspace-exploitable crash.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- Direct: warn_alloc log flood (stack + show_mem), rate-limited 1/10s, **not** panic_on_warn.
- Indirect (the reason the pool exists: “make sure the message gets out even in extreme OOM”): splat printks consume the 32-skb pool and can hide the original incident.
- **Severity: HIGH for netconsole-under-OOM (lost emergency logs); otherwise MEDIUM log noise.** The refill path is the lesser of the two sites; the cover-letter stack is find_skb.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit:** medium-high for netconsole users; stops expected refill failures from dumping meminfo into the emergency path.
- **Risk:** very low (one GFP bit).
- **Ratio:** favorable. Incomplete vs the hot-path sibling, but this hunk is still a correct, self-contained fix.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
**FOR:**
- Buggy GFP_ATOMIC refill is in this 6.18.53 tree and applies cleanly.
- Failure is already handled; the splat is wrong and can starve the 32-skb OOM pool.
- Production class of bug documented (Meta fleet cover letter).
- 1 line, established __GFP_NOWARN pattern, maintainer-authored, merged by Kicinski.
- Zero change to allocation success/locking/API.
**AGAINST:**
- Sent to **net-next**, not net; no Fixes: / Cc: stable / Reviewed-by in the thread.
- Cover-letter stack is **find_skb/send_udp**, not refill_skbs. This tree still warns in find_skb(); backporting only 2/2 does not close the reported hot path.
- warn_alloc is rate-limited and does not panic.
- Not a crash/UAF/deadlock by itself.
**UNRESOLVED:** stable@ lore search (HTTP 403). Whether 6.18 netconsole uses the same nbcon kthread as the 2026 stack (send path still is netconsole → netpoll_send_udp → find_skb here).
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — one GFP flag; merged to net- next; fleet report for the series.
2. Fixes a real bug that affects users? **PASS** — expected alloc failure must not dump; dump can eat the emergency pool.
3. Important issue (crash, security, corruption, deadlock)? **PASS** (narrow) — not a panic, but it undermines netpoll’s OOM delivery guarantee. That is the point of this subsystem.
4. Small and contained? **PASS** — 1 line, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — clean on v6.18.53.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: None (not an ID/quirk/DT/build/docs add). Ordinary small bugfix.
Step 9.4: MAKE YOUR DECISION
Backport. The local 6.18.y tree has the buggy refill; the patch is a zero-risk one-liner that stops an expected GFP_ATOMIC miss from generating a huge warn_alloc that can drain the netconsole skb pool. The hotter sibling (find_skb in net/core/netpoll.c on this tree) is a separate candidate and is not required for this hunk to be correct.
What it solves for stable users: under memory pressure with netconsole/netpoll, pool refill already gives up on the first alloc_skb failure. Today that still prints warn_alloc (stack + meminfo). Those lines compete for the 32 preallocated skbs that exist specifically so messages still get out in OOM. Adding __GFP_NOWARN leaves refill semantics identical and keeps that path quiet.
Risk vs benefit: benefit is real for netconsole fleets; risk is negligible. The only caveat is that this does not silence find_skb() on 6.18 (still GFP_ATOMIC without NOWARN); that does not make this commit wrong or unsafe.
===============================================================
Verification:
===============================================================
- [Phase 1] Parsed tags: Link to msgid …v1-2…; SOBs Breno + Kicinski; no Fixes/Reported-by/Cc:stable
- [Phase 1] Cover letter from mbox: Meta fleet, 100+ line splat consuming skb pool
- [Phase 2] Diff: 1 line GFP_ATOMIC → GFP_ATOMIC | __GFP_NOWARN in refill_skbs()
- [Phase 2] warn_alloc() confirmed: respects __GFP_NOWARN; pr_warn+dump_stack+__show_mem; ratelimit 1/10s; not panic_on_warn
- [Phase 3] Blame: GFP_ATOMIC refill since 1da177e4c3f41 (2.6.12-rc2); individualize 221a9c1df790fa in 6.18.53; deadlock fix 327c20c21d80e0 in 6.18.53
- [Phase 3] git merge-base --is-ancestor 84c0ff1efb62b v6.18.53 → not present
- [Phase 3] Series sibling 09f7a613a14fd is netconsole find_skb post-move; not a compile dependency
- [Phase 4] b4 dig -c 84c0ff1efb62b: lore msgid; v1 only; applied to net-next; no NAK
- [Phase 4] Recipients: netdev maintainers + [email protected]
- [Phase 4] UNVERIFIED: stable@ mailing list (HTTP 403)
- [Phase 5] Callers: __netpoll_setup() and refill_skbs_work_handler(); find_skb() still GFP_ATOMIC at line 279 in this tree
- [Phase 5] MAX_SKBS is 32; comment documents OOM pool purpose
- [Phase 6] git describe HEAD / make kernelversion: 6.18.53; buggy line present at v6.18.53; git apply --check on v6.18.53: CLEAN_APPLY
- [Phase 7] Breno is NETCONSOLE maintainer
- [Phase 8] Failure mode: warn_alloc noise + emergency pool depletion under OOM, not a kernel oops
- UNVERIFIED: whether 6.18 netconsole uses nbcon kthread identically to the 2026 cover-letter stack (send path is still netpoll_send_udp → find_skb here)
**YES**
net/core/netpoll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/netpoll.c +1 -1
@@ -232,7 +232,7 @@ static void refill_skbs(struct netpoll *np) skb_pool = &np->skb_pool;while (READ_ONCE (skb_pool->qlen) <MAX_SKBS ) { - skb =alloc_skb (MAX_SKB_SIZE ,GFP_ATOMIC ); + skb =alloc_skb (MAX_SKB_SIZE ,GFP_ATOMIC | __GFP_NOWARN);if (!skb)break ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 perf: marvell: Cancel CN10K DDR PMU hrtimer on device remove
In reply to Sasha LevinFrom: Geetha sowjanya <[email protected]>
[ Upstream commit 7dbcb0268d1e2a1d3badb0c6e77ee70e550b1787 ]
cn10k_ddr_perf_remove() did not cancel the poll hrtimer before returning. If the device was unbound while perf events were still active the timer callback could run post-free.
To fix the issue by adding hrtimer_cancel() in remove().
---
LLM Generated explanations, may be completely bogus:
I have enough to decide: the UAF is in this 6.1 tree, the cancel is a standalone 6-line fix, and it does not need the CN20K series.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [perf/marvell] [Cancel] Cancel CN10K DDR PMU hrtimer on device remove
Subsystem perf: marvell: is the Marvell CN10K DDR uncore PMU driver. Verb Cancel is a stop-the-timer safety action. Claimed intent: stop the poll hrtimer in the platform remove() path so it cannot fire after the device is torn down.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record: tags present in the candidate message:
- Signed-off-by: Geetha sowjanya <[email protected]> (author)
- Signed-off-by: Will Deacon <[email protected]> (ARM perf maintainer merge; pipeline Signed-off-by: Sasha Levin ignored per instructions)
Tags **not** present (expected for this review queue, not treated as a negative):
- No Fixes:
- No Reported-by: / Tested-by: / Reviewed-by: / Acked-by:
- No Link:
- No Cc: [email protected]
From mailing-list forensics (Phase 4): original submission was [PATCH v8 3/3] of a CN20K feature series, Message-ID [email protected]. Will Deacon applied it to arm64 (for-next/perf) as 7dbcb0268d1e. Krzysztof’s Reviewed-by is on patch 1/3 (dt-bindings) only, not on this UAF patch.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** cn10k_ddr_perf_remove() returned without cancelling the overflow-poll hrtimer.
- **Symptom / failure mode:** if the device is unbound while events (and therefore the timer) are still active, cn10k_ddr_pmu_timer_handler() can run after devm frees struct cn10k_ddr_pmu and unmaps MMIO — use-after-free / MMIO-after-unmap.
- **Version info:** cover letter for v8 says this is **pre-existing for CN10K/Odyssey**, not a CN20K-only issue.
- **Root cause (author):** missing hrtimer_cancel() in remove().
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. The message names a post-free timer callback. This is an explicit UAF fix. The series is mostly a CN20K feature add; **this patch was split out in v8 specifically as a pre- existing bug fix**.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/perf/marvell_cn10k_ddr_pmu.c
- Scope: **+6 / -0**, single function cn10k_ddr_perf_remove()
- Classification: **single-file surgical fix** (comment + hrtimer_cancel())
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** remove() got drvdata, dropped the cpuhp instance, unregistered the PMU, returned. Timer left live if it had been started.
- **After:** hrtimer_cancel(&ddr_pmu->hrtimer) **first**, then the same teardown. hrtimer_cancel() also waits for a running callback, so the handler cannot continue after remove() returns.
- Path: **driver teardown / unbind / module unload**, not the normal event add/del path (that already cancels on last event_del).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Use-after-free / lifetime bug (memory safety)**
Mechanism verified in this tree:
- ddr_pmu is devm_kzalloc()’d; MMIO is devm_platform_get_and_ioremap_resource(). Both are released after remove() returns.
- Timer is started on first event_add (hrtimer_start, HRTIMER_MODE_REL_PINNED) and cancelled only when active_events == 0 in event_del.
- Handler always return HRTIMER_RESTART after cn10k_ddr_pmu_overflow_handler(pmu), which dereferences pmu->events[] and pmu->base.
- perf_pmu_unregister() in this tree (kernel/events/core.c) does **not** stop events or cancel driver timers; it only unlists the PMU, syncs RCU, and frees PMU context.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Quality:** obviously correct. hrtimer_cancel() on an already-idle timer is a no-op; cancelling before cpuhp/PMU teardown is the right order.
- **Regression risk:** very low. Callback only does local_irq_save + MMIO reads; it does not take locks remove() holds. No API/data- structure change.
- **Red flags:** none in the hunk itself. Series context (3/3 of CN20K) is a packaging concern, not a correctness concern — this hunk does not use CN20K code.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Buggy cn10k_ddr_perf_remove() (no timer cancel) introduced in 7cf83e222bce0 (perf/marvell: CN10k DDR performance monitor support, Bharat Bhushan, 2022-03-08).
- git merge-base --is-ancestor 7cf83e222bce0 HEAD succeeded; git merge-base --is-ancestor 7cf83e222bce0 v6.1 succeeded.
- Present in this tree from the 6.1 baseline (driver landed in v5.18).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The introducing commit is 7cf83e222bce0, which **is** in this tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: only four commits on this file in this tree:
- 7cf83e222bce0 CN10k DDR perfmon support
- 35a43326a9e3c overflow handling
- 68fa55f0e05ce core ownership
- 6676a42f1e4f1 !CONFIG_OF build fix
No later refactor of remove(). **Standalone** relative to this tree. Does **not** need patches 1–2 of the CN20K series.
Related but **separate** bug (v7 of the same series, in patch 2/3):event_add can hrtimer_start() then return -EINVAL from ddr_perf_get_event_bitmap() without rolling back. That leak is **not** this commit. This commit still stands alone.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: git log --author=Geetha -- drivers/perf/ is empty in this 6.1 tree. Author is a Marvell engineer extending a Marvell driver originally by Bharat Bhushan. Will Deacon (ARM perf maintainer) merged it. That is sufficient maintainer vetting.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **No functional prerequisites.** The only apply wrinkle is 6.1 still has static int cn10k_ddr_perf_remove(...) returning 0; later kernels converted platform .remove to void. The added hrtimer_cancel() line and comment apply unchanged.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c HEAD was the wrong SHA (this commit is not in the 6.1 checkout). Direct lore fetch returned 403.
- b4 am on Message-ID [email protected]
succeeded: v8 series, 3 patches, DKIM-signed, no newer revision flagged.
- Lore/mirrors:
https://patch.msgid.link/[email protected] , openwall, lkml.iu.edu, patchew, ratatoskr.
- Cover letter v8: “Cancel the poll hrtimer in cn10k_ddr_perf_remove() before devm frees struct cn10k_ddr_pmu (pre-existing for CN10K/Odyssey).”
- **No NAK.** Will Deacon: “Applied to arm64 (for-next/perf)” with git id 7dbcb0268d1e for this patch.
- **No reviewer Cc: stable found** (not treated as a negative).
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: To/Cc on the original mail: linux-perf-users, linux-kernel, linux-arm-kernel, devicetree, Mark Rutland, Will Deacon, Krzysztof Kozlowski. Will Deacon merged. No NAK on 3/3.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot, bugzilla, or external user report. Bug was found during CN20K series review/development (added in v8). Still a concrete UAF, just not fuzzer-reported.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Series is:
1. dt-bindings CN20K — feature, not this decision
2. CN20K driver support (+ event_add rollback) — feature / separate leak fix
3. **this UAF cancel** — independent 6-line fix
Do **not** pull 1/3 or 2/3 into 6.1. This commit does not call CN20K pdata/helpers.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search returned 403. No evidence on the public v8 thread that stable rejected this. UNVERIFIED: whether -stable ever discussed this hash by name.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: cn10k_ddr_perf_remove() only. Related existing functions:cn10k_ddr_perf_event_add, cn10k_ddr_perf_event_del, cn10k_ddr_pmu_timer_handler, cn10k_ddr_pmu_overflow_handler.
**Step 5.2: TRACE CALLERS**
Record:
- cn10k_ddr_perf_remove is the platform driver’s .remove (cn10k_ddr_pmu_driver). Callers: device unbind, parent device teardown, platform_driver_unregister() from cn10k_ddr_pmu_exit().
- Timer handler is the hrtimer softirq/callback path, not a syscall.
**Step 5.3: TRACE CALLEES**
Record: remove() calls platform_get_drvdata, hrtimer_cancel (new), cpuhp_state_remove_instance_nocalls, perf_pmu_unregister. Handler calls overflow path which does MMIO readq_relaxed on pmu->base.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace can start the timer via perf_event_open on this uncore PMU (event_add when active_events == 1). Unbind/unload is admin-triggered (module unload, device teardown), not an unprivileged syscall by itself. event_init does **not** validate attr.config; event_add can start the timer then fail ddr_perf_get_event_bitmap(). event_sched_in() on add failure does **not** call pmu->del() (verified at kernel/events/core.c:2591-2595). That can leave a running timer even after a failed perf_event_open, after which rmmod can run remove() with the timer still live. Reachable from userspace + admin unload.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: In this tree, this driver only cancels the timer in event_del. drivers/perf/thunderx2_pmu.c also cancels on CPU offline. Sibling DDR PMU fsl_imx8_ddr_perf.c also does not cancel in remove() here — pattern exists, but that does not make this UAF fictional.
===============================================================
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.1.188** (pending-6.1, git describe p-6.1-10-g80966a5b14be4).
```700:710:drivers/perf/marvell_cn10k_ddr_pmu.c
static int cn10k_ddr_perf_remove(struct platform_device *pdev)
{
struct cn10k_ddr_pmu *ddr_pmu = platform_get_drvdata(pdev);
cpuhp_state_remove_instance_nocalls(
CPUHP_AP_PERF_ARM_MARVELL_CN10K_DDR_ONLINE,
&ddr_pmu->node);
perf_pmu_unregister(&ddr_pmu->pmu);
return 0;
}
```No hrtimer_cancel(). Introduced with the driver in 7cf83e222bce0 (v5.18), present for the whole 6.1 lifetime.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Minor context only.** 6.1 remove is int and returns 0; later kernels use void. OF match table in 6.1 has no .data / CN20K entries. The added call does not depend on those. Expected apply:
**minor conflict, trivial rework**.
This tree still has suppress_bind_attrs = true, so **sysfs** bind/unbind is hidden. That does **not** skip .remove on parent teardown or platform_driver_unregister().
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No hrtimer_cancel in remove(). No event_add rollback (goto err_free_counter). Nothing already fixes this UAF.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/perf/ Marvell CN10K DDR PMU. **PERIPHERAL** (SoC- specific uncore PMU). Config MARVELL_CN10K_DDR_PMU depends on ARCH_THUNDER || (COMPILE_TEST && 64BIT) — Octeon 10 / Thunder-class ARM64.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: File is mature and quiet in 6.1 (four commits total). Bug is old, not a last-month regression.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / config-specific:** CONFIG_MARVELL_CN10K_DDR_PMU on Marvell CN10K (ARCH_THUNDER). Not universal.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Timer starts when the first perf event is added; period default **100s** (poll_period_sec).
- Classic trigger: device remove() while the timer is queued (unbind / parent removal / module exit).
- Mitigations in **this** tree: suppress_bind_attrs = true (no sysfs unbind); successful events try_module_get the module so rmmod waits for last close, and last event_del already cancels the timer.
- Remaining realistic triggers: platform device teardown with events still open; **failed event_add after hrtimer_start** leaving a live timer so rmmod can hit remove() without event_del.
- Unprivileged user can start/leak the timer via perf_event_open; teardown is typically admin. Failure mode is still kernel UAF.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Timer callback uses freed cn10k_ddr_pmu and unmapped MMIO → **use-after-free / oops / memory corruption**. Severity: **HIGH** (UAF). Not a guaranteed panic on every boot; when it hits, it is a hard kernel memory-safety failure.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** HIGH for CN10K users who unload/unbind with a live poll timer; prevents UAF. Population is small but the bug class is serious.
- **Risk:** VERY LOW (6 lines, no-op if timer idle, no locking change).
- **Ratio:** strongly in favor of backporting.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real UAF: poll hrtimer can run after devm free of the PMU struct.
- Bug exists in this 6.1 tree since the driver was added (7cf83e222bce0).
- Surgical, obviously correct (hrtimer_cancel before teardown).
- Maintainer-merged (Will Deacon).
- Author/cover letter call it a **pre-existing CN10K** bug, not CN20K-only.
- Independent of CN20K patches 1–2.
- Failed event_add in this tree can leave the timer running; pmu->add failure does not call del().
- hrtimer_cancel on idle timer is safe.
**AGAINST:**
- Peripheral SoC PMU, not a core path.
- No syzbot/user report.
- suppress_bind_attrs hides sysfs unbind; happy-path rmmod after clean event_del already cancels the timer.
- Packaged as 3/3 of a feature series (but this hunk is independent).
- Trivial int vs void remove context mismatch.
**UNRESOLVED:**
- Could not fetch lore.kernel.org (403) or git.kernel.org (Anubis); discussion reconstructed via b4 am, patchew, and mirrors.
- No -stable thread found (403).
- Exact mainline SHA in Linus’s tree not in this checkout; arm64 application id 7dbcb0268d1e from Will’s mail.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — one hrtimer_cancel(), merged by Will Deacon, idle-timer cancel is a no-op.
2. Fixes a real bug that affects users? **PASS** — UAF on remove with a live poll timer; code present here.
3. Important issue? **PASS** — use-after-free / crash / memory corruption (HIGH). Trigger is not every boot, but severity matches stable’s crash/UAF bar.
4. Small and contained? **PASS** — 6 lines, one function, one file.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — buggy remove() is here; only int vs void remove needs a one-line context tweak.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID / quirk / DT / build / docs exception. It is a normal small UAF fix.
**Step 9.4: MAKE YOUR DECISION**
This should be backported to **this** 6.1 tree. The CN20K feature patches must stay out; this cancel is self-contained and matches the code that has been in 6.1 from day one.
===============================================================
What the commit solves, and why it matters here
===============================================================
cn10k_ddr_perf_remove() tears down cpuhp and unregisters the PMU but never stops the overflow-poll hrtimer. The PMU object and MMIO are devm-managed, so they are freed as soon as remove() returns. If the timer is still queued, cn10k_ddr_pmu_timer_handler() can run on freed memory. That is a real UAF on Marvell CN10K systems that use this driver — exactly the hardware this 6.1 tree already supports.
It meets stable rules: obviously correct, small, no new API, and the buggy function is in this checkout. Risk is negligible. Benefit is preventing a kernel UAF. The only backport edit is matching 6.1’s int remove callback.
===============================================================
Verification
===============================================================
- [Phase 1] Parsed subject/body/tags: UAF-on-remove; SOBs Geetha sowjanya + Will Deacon; no Fixes/Reported-by/Cc-stable.
- [Phase 2] Diff: +6 in cn10k_ddr_perf_remove() only; adds hrtimer_cancel() before cpuhp/PMU teardown.
- [Phase 2] perf_pmu_unregister() at kernel/events/core.c:11587 does not cancel driver timers or wait for event_del.
- [Phase 2] Handler at lines 600–612 always HRTIMER_RESTART and uses pmu->base / pmu->events[].
- [Phase 3] git describe HEAD → p-6.1-10-g80966a5b14be4; make kernelversion → 6.1.188.
- [Phase 3] git merge-base --is-ancestor 7cf83e222bce0 HEAD → introducing driver commit is in this tree.
- [Phase 3] git blame on remove() → 7cf83e222bce0 (no cancel) and 68fa55f0e05ce (cpuhp).
- [Phase 3] File history: 4 commits; no existing remove-path timer fix.
- [Phase 4] b4 am msgid [email protected] → v8 3/3; cover letter “pre-existing for CN10K/Odyssey”.
- [Phase 4] Patchew: Will Deacon applied 3/3 as 7dbcb0268d1e; no NAK.
- [Phase 4] lore.kernel.org and git.kernel.org fetches: 403 / Anubis — used b4/patchew/mirrors instead.
- [Phase 5] event_sched_in add-failure path (core.c:2591) does not call pmu->del().
- [Phase 5] Local event_init does not validate attr.config; event_add can start the timer then return -EINVAL.
- [Phase 6] Read local cn10k_ddr_perf_remove(): no hrtimer_cancel; devm_kzalloc + suppress_bind_attrs = true confirmed.
- [Phase 7] Kconfig MARVELL_CN10K_DDR_PMU depends on ARCH_THUNDER.
- [Phase 8] Failure mode: UAF in hrtimer callback after devm free — HIGH.
- UNVERIFIED: -stable list discussion of this exact commit (lore/stable 403).
- UNVERIFIED: Linus-tree SHA beyond Will’s arm64 id 7dbcb0268d1e.
**YES**
drivers/perf/marvell_cn10k_ddr_pmu.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/perf/marvell_cn10k_ddr_pmu.c +6 -0
@@ -1088,6 +1088,12 @@ static void cn10k_ddr_perf_remove(struct platform_device *pdev) {struct cn10k_ddr_pmu *ddr_pmu =platform_get_drvdata (pdev); +/* +* Cancel the poll timer before further teardown so the handler +* cannot run after this function returns. +*/ +hrtimer_cancel (&ddr_pmu->hrtimer); +cpuhp_state_remove_instance_nocalls (CPUHP_AP_PERF_ARM_MARVELL_CN10K_DDR_ONLINE , &ddr_pmu->node);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-6.1] perf: marvell: Cancel CN10K DDR PMU hrtimer on device remove
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] perf: marvell: premature hrtimer_cancel() in cn10k_ddr_perf_remove() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] perf: marvell: premature hrtimer_cancel() in cn10k_ddr_perf_remove() --
commit ee388a976febdb25de30edee55cec9fcf0a7184a
Author: Geetha sowjanya <[email protected]>
perf: marvell: Cancel CN10K DDR PMU hrtimer on device remove
This commit cancels the poll hrtimer in cn10k_ddr_perf_remove() so the timer callback cannot run after the device is unbound and its resources are freed.
Quoted 7 lines
drivers/perf/marvell_cn10k_ddr_pmu.c +0
-0@@ -1088,6 +1088,12 @@ static void cn10k_ddr_perf_remove(struct platform_device *pdev) {struct cn10k_ddr_pmu *ddr_pmu =platform_get_drvdata (pdev);
drivers/perf/marvell_cn10k_ddr_pmu.c static void cn10k_ddr_perf_remove(struct platform_device *pdev) · line 1099
Quoted 10 lines
drivers/perf/marvell_cn10k_ddr_pmu.c +6
-0+/* +* Cancel the poll timer before further teardown so the handler +* cannot run after this function returns. +*/ +hrtimer_cancel (&ddr_pmu->hrtimer); +cpuhp_state_remove_instance_nocalls (CPUHP_AP_PERF_ARM_MARVELL_CN10K_DDR_ONLINE , &ddr_pmu->node);
[Severity: High]
Can ddr_pmu->hrtimer be re-armed after hrtimer_cancel() returns here?
In cn10k_ddr_perf_remove(), hrtimer_cancel(&ddr_pmu->hrtimer) is called before cpuhp_state_remove_instance_nocalls() and perf_pmu_unregister():
drivers/perf/marvell_cn10k_ddr_pmu.c:cn10k_ddr_perf_remove() {
hrtimer_cancel(&ddr_pmu->hrtimer);
cpuhp_state_remove_instance_nocalls(
CPUHP_AP_PERF_ARM_MARVELL_CN10K_DDR_ONLINE,
&ddr_pmu->node);
perf_pmu_unregister(&ddr_pmu->pmu);
}Until cpuhp_state_remove_instance_nocalls() removes the hotplug instance and perf_pmu_unregister() finishes synchronize_srcu() / synchronize_rcu() and detaches events via pmu_detach_events(), PMU and CPU hotplug callbacks remain active:
kernel/events/core.c:perf_pmu_unregister() {
...
synchronize_srcu(&pmus_srcu);
synchronize_rcu();
...
pmu_detach_events(pmu);
...
}During that window, cn10k_ddr_perf_event_add() can still run on another CPU (via an in-flight perf_event_open(), ioctl(PERF_EVENT_IOC_ENABLE), perf_rotate_context(), or cn10k_ddr_pmu_offline_cpu() -> perf_pmu_migrate_context()) and call hrtimer_start() when pmu->active_events becomes 1:
drivers/perf/marvell_cn10k_ddr_pmu.c:cn10k_ddr_perf_event_add() {
...
pmu->active_events++;
hwc->idx = counter;
if (pmu->active_events == 1)
hrtimer_start(&pmu->hrtimer, cn10k_ddr_pmu_timer_period(),
HRTIMER_MODE_REL_PINNED);
if (counter < DDRC_PERF_NUM_GEN_COUNTERS) {
/* Generic counters, configure event id */
reg_offset = DDRC_PERF_CFG(p_data->cfg_base, counter);
ret = ddr_perf_get_event_bitmap(config, &val, pmu);
if (ret)
return ret;
...
}If ddr_perf_get_event_bitmap() then returns -EINVAL (or if pmu->active_events was previously skewed by a failed add), cn10k_ddr_perf_event_add() returns without decrementing pmu->active_events or stopping pmu->hrtimer. Because event_sched_in() leaves the event in PERF_EVENT_STATE_INACTIVE on add failure, pmu_detach_events() -> event_sched_out() never calls cn10k_ddr_perf_event_del() for that event (and even if other active events are detached, pmu->active_events never reaches 0 in cn10k_ddr_perf_event_del()).
This leaves ddr_pmu->hrtimer armed when cn10k_ddr_perf_remove() returns, allowing cn10k_ddr_pmu_timer_handler() to run after devm frees struct cn10k_ddr_pmu and unmaps ddr_pmu->base.
Should hrtimer_cancel(&ddr_pmu->hrtimer) be called after perf_pmu_unregister() and cpuhp_state_remove_instance_nocalls() have completed (matching the reverse of the setup order in cn10k_ddr_perf_probe())?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 HID: amd_sfh: Serialize access to the shared emp2 pointer
In reply to Sasha LevinFrom: Basavaraj Natikar <[email protected]>
[ Upstream commit c57016bcf6d0b57cda5579e5d6856bd9bbe52a77 ]
The SFH accessors reach the device through a file-global emp2 pointer that is published at probe and cleared on remove. amd_get_sfh_info() is exported and called from other modules on unrelated threads, so a reader can observe a non-NULL emp2 and then race a concurrent unbind that clears it and frees the device.
Serialize the emp2 publish/clear and all readers under a mutex, so a reader either sees a live device for the whole access or sees NULL.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111**. The buggy global emp2 pointer and exported amd_get_sfh_info() are in this checkout; the 6-line mutex fix applies here.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[HID: amd_sfh]** **[Serialize]** Serialize access to the shared emp2 pointer used by exported SFH accessors.
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Basavaraj Natikar (author; AMD SFH maintainer)
- Signed-off-by: Jiri Kosina (HID maintainer; applied the patch)
- No Fixes, Reported-by, Tested-by, Reviewed-by, Acked-by, Link, or Cc:
stable on the committed message (absence of Fixes/Cc:stable is expected for this review)
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** File-global emp2 is published at probe (sfh_interface_init) and cleared on remove (sfh_deinit_emp2). amd_get_sfh_info() is EXPORT_SYMBOL_GPL and is called from other modules on other threads.
- **Symptom/failure mode:** A reader can see a non-NULL emp2, then a concurrent unbind NULLs it and frees the device → use-after-free / MMIO against freed amd_mp2_dev.
- **Version info:** None in the message. Introduced with HPD export in v6.8 (b5b0774d53bb81). Present in this 6.12 tree.
- **Root cause (author):** Missing serialization between publish/clear and all readers.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not disguised. It is an explicit race/UAF fix. Cover letter for the v3 series also calls patches 1–2 “preparation” for SW_TABLET_MODE, but the mutex independently closes an existing unbind-vs-reader UAF. It is not a pure refactor with no standalone value.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c (+6 / −0)
- Functions: file-scope emp2_lock; sfh_deinit_emp2; sfh_interface_init; amd_get_sfh_info
- Scope: single-file surgical fix
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: emp2 = mp2 / emp2 = NULL with no lock. amd_get_sfh_info() checks emp2 then dereferences emp2->mmio / emp2->vsbase unlocked.
- After: DEFINE_MUTEX(emp2_lock); guard(mutex)(&emp2_lock) around publish, clear, and the whole reader. A reader either keeps a live device for the full access or sees NULL.
- Paths: probe/init, remove/error-deinit, and the exported reader (normal path from AMD PMF work).
Step 2.3: IDENTIFY THE BUG MECHANISM
Record: **Race / UAF (check-then-use on a global device pointer).** Writers and the exported reader were unsynchronized. Mutex makes publish/clear and MMIO mutually exclusive. Helpers amd_sfh_hpd_info / amd_sfh_als_info stay unlocked internally but are static and only called from amd_get_sfh_info() while that lock is held.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct for this TOCTOU.
- Minimal; no API or structure change.
- Regression risk low: mutex is not nested; readers run in PMF delayed work (sleepable); remove already sleeps (flush_work). Holding the lock across readl/memcpy_fromio can delay unbind slightly; that is the intended tradeoff vs UAF.
- linux/cleanup.h + guard(mutex) exist in 6.12; mutex.h is already pulled in via amd_sfh_common.h.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record: emp2, sfh_deinit_emp2, amd_get_sfh_info, and EXPORT_SYMBOL_GPL come from **b5b0774d53bb81** (“HID: amd_sfh: Add a new interface for exporting HPD data”, 2023-12-20). ALS reader added in **584f35a3647d42**. Both are in v6.8 and in this tree. The race is old relative to 6.12, not new mainline-only code.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes tag. Buggy pattern is the unlocked global from b5b0774d53bb81, which **is** an ancestor of HEAD.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: Recent 6.12 history on this file is register-access helpers (7902ec988a9a6, 6296562f30b1c), not locking. Origin/master later added MT_SRA / tablet-mode around this commit; those features are **not** in this tree. No existing emp2 lock here.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Basavaraj Natikar is listed in MAINTAINERS for AMD SENSOR FUSION HUB. Same author added the export and later SFH1.1 work. Series v3 was applied by Jiri Kosina.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: Committed as **[PATCH v3 2/5]** in “Add SW_TABLET_MODE support”.
- 1/5 “Track MP2 version explicitly” (1a73a4e7673f57) is **not** in HEAD and is **not** required for this mutex (different files/fields).
- 3–5 add operating-mode accessor, aux device, and a new input driver — features, not needed for this fix.
- This patch is self-contained. git apply --check of c57016bcf6d0b on this tree **succeeds** (hunk 3 offset −35: no amd_sfh_mode_info/MT_SRA in 6.12).
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- Lore/msgid: https://patch.msgid.link/20260803175230.3839752-3-
[email protected]
- Series: v1 (operating-mode only) → v2 0/5 → **v3 2/5** (applied).
- Cover letter (v3 0/5): patches 1–2 are preparation; v2 notes from Sashiko review: serialize emp2 so concurrent unbind cannot free the device while a reader dereferences it.
- Jiri Kosina queued the series in hid.git#for-7.3/amd-sfh. No NAK. No
Cc: stable in review.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: To/Cc: [email protected], [email protected], [email protected], linux-input@. HID maintainers were on the series. Dmitry Acked-by is on 5/5 (input driver), not this patch. Applied by Jiri Kosina.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla. Race found in review of the tablet-mode series, not a user crash report. The existing PMF caller was already racy.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: 2/5 is the UAF serialization. 3/5 also adds sfh_set_emp2() and uses emp2_lock; that is extra feature plumbing, not required to lock the 6.12 HPD/ALS paths.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable search returned HTTP 403. UNVERIFIED whether stable@ discussed this. No evidence in the input thread of a stable nomination or a rejection.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: sfh_deinit_emp2, sfh_interface_init, amd_get_sfh_info; new emp2_lock.
Step 5.2: TRACE CALLERS
Record:
- sfh_interface_init: amd_sfh_set_ops() ← amd_sfh1_1_init() (SFH1.1 probe work).
- sfh_deinit_emp2: amd_mp2_pci_remove (unbind) and error paths in amd_sfh1_1_init after publish.
- amd_get_sfh_info: amd_pmf_get_sensor_info() in drivers/platform/x86/amd/pmf/spc.c (MT_ALS, MT_HPD) ← amd_pmf_populate_ta_inputs ← amd_pmf_invoke_cmd_enact ← delayed work amd_pmf_invoke_cmd every pb_actions_ms (default **1000 ms**).
Step 5.3: TRACE CALLEES
Record: Readers do readl / memcpy_fromio on emp2->mmio / emp2->vsbase. Remove then amd_sfh_hid_client_deinit, stop_all, PCI intx/intr clear. mp2 is devm_kzalloc; mapping is pcim_iomap — freed after PCI remove.
Step 5.4: FOLLOW THE CALL CHAIN
Record: Reachable without the new tablet driver: AMD PMF policy work (typical on AMD laptops with PMF) vs SFH1.1 unbind (amd_sfh_remove → mp2_ops->remove). Not a syscall hot path; unbind is admin/module/PCI. Still a real concurrent path: 1 Hz reader vs remove.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Only this file holds emp2. No sibling unlocked copy in 6.12. Later mainline adds more readers (MT_OP_MODE at 200 ms); those are not in this tree.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c:
unlocked static struct amd_mp2_dev *emp2, sfh_deinit_emp2 sets NULL, amd_get_sfh_info is exported. Introduced v6.8; this tree is 6.12.111. git merge-base --is-ancestor c57016bcf6d0b HEAD → **not present**.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **Clean apply** (git apply --check succeeded; one hunk offset). 6.12 lacks amd_sfh_mode_info/MT_SRA; that is context only. guard(mutex) and DEFINE_MUTEX are available.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: edeae8be4d263 syncs SFH work functions — different bug. No emp2 mutex. d1c444b47100d / 01601fdd40ecf not in HEAD (and not required).
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: HID / AMD SFH (drivers/hid/amd-sfh-hid/), plus AMD PMF consumer. **IMPORTANT** for AMD Ryzen laptops with SFH1.1 (HPD/ALS) and PMF; not core mm/VFS. Config: CONFIG_AMD_SFH_HID.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mature driver (since ~5.11), still receiving fixes. Export of emp2 is from 6.8; the unlocked design lasted until the 7.3 tablet-mode series.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver-specific: AMD SFH1.1 (PCI ID MP2 1.1) **and** AMD PMF loaded. Typical modern AMD notebooks, not all machines.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Concurrent amd_get_sfh_info (PMF delayed work, default 1 s) with sfh_deinit_emp2 (unbind, rmmod, or probe error after publish). Unprivileged users cannot normally unbind. Window is small but standard check-then-use. New 200 ms tablet poll is **not** in this tree, so trigger rate here is lower than mainline after 7.3.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: Use-after-free of amd_mp2_dev / MMIO after devm teardown → oops/panic, possibly memory corruption. **HIGH**. Not a guaranteed panic on every boot.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: closes a real UAF on a supported unbind path for SFH1.1+PMF systems.
- Risk: 6 lines, existing mutex helpers, no ABI change; apply is clean.
- Ratio: favorable. Preparation-for-feature context does not make the existing race fictional.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real UAF race on a global pointer vs exported cross-module reader (verified call path: PMF work → amd_get_sfh_info vs amd_mp2_pci_remove).
- Buggy code in this 6.12 tree since v6.8.
- 6-line, obviously correct mutex; maintainer-authored; HID maintainer applied.
- Applies cleanly here.
- guard(mutex) already used elsewhere in 6.12.
AGAINST:
- Sent as 2/5 “preparation” for SW_TABLET_MODE, not as a standalone stable fix.
- No user/syzbot report; narrow unbind window; no Cc: stable (not a negative per rules).
- Later series patches must **not** come along (new feature).
UNRESOLVED:
- Stable list discussion (lore/stable 403).
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — mutex around the only publisher/clearer and the only exported reader; merged to hid.git after review.
2. Fixes a real bug that affects users? **PASS** — UAF if SFH1.1 unbinds while PMF polls.
3. Important issue? **PASS** — UAF / crash / possible memory corruption (HIGH).
4. Small and contained? **PASS** — +6 lines, one file.
5. No new features or APIs? **PASS** — locking only. (3–5 of the series would FAIL this; they are out of scope.)
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 / doc exception). Qualifies as a normal race/UAF bugfix.
Step 9.4: MAKE YOUR DECISION
This tree has the unlocked emp2 export and the PMF reader. The patch does not need MP2 version tracking or tablet-mode. It should be backported here.
------------------------------------------------
What problem it solves for stable users
------------------------------------------------
On 6.12, AMD PMF’s delayed work calls amd_get_sfh_info() about once a second. That function tests the file-global emp2 and then uses emp2->mmio / emp2->vsbase. Remove (amd_sfh_remove → amd_mp2_pci_remove) sets emp2 = NULL and then tears down a devm_kzalloc’d amd_mp2_dev. Without a lock, a reader can keep using a pointer to already-freed device/MMIO. The mutex makes that impossible.
Why it meets stable rules
Small, correct, no new API, applies here, fixes a real UAF. Being patch 2/5 of a feature series is not a dependency: 1/5 and 3–5 are unrelated or features.
Risk vs benefit
Low risk, meaningful benefit on AMD SFH1.1 + PMF systems. Do not pull the rest of the tablet-mode series.
Concerns
Backport only this commit. Context offset on amd_get_sfh_info (no MT_SRA) is already handled by a clean apply.
Verification:
- [Phase 1] Parsed tags: only two SOBs (Natikar, Kosina); no Fixes/Reported-by/Cc:stable
- [Phase 1] Cover letter (mbox): “Patches 1 and 2 are preparation”; v2 changelog describes the unbind UAF
- [Phase 2] Diff: +6 lines, mutex + three guard(mutex) sites in one file
- [Phase 3] git describe HEAD / Makefile: **p-6.12-3-gc504cf0baa3d8**, version **6.12.111**
- [Phase 3] git blame: emp2/export from b5b0774d53bb81; git merge-base --is-ancestor b5b0774d53bb81 HEAD → yes; in v6.8
- [Phase 3] git merge-base --is-ancestor c57016bcf6d0b HEAD → **no** (candidate not in this tree)
- [Phase 3] Parent 1a73a4e7673f57 “Track MP2 version” not in HEAD; not required by this diff
- [Phase 4] b4 dig -c c57016bcf6d0b: https://patch.msgid.link/2026080317
[email protected]
- [Phase 4] b4 dig -a: v1 → v2 0/5 → v3 2/5 applied
- [Phase 4] b4 dig -w: linux-input, jikos, bentiss, dmitry.torokhov
- [Phase 4] mbox: Jiri queued for-7.3/amd-sfh; no NAK; no stable nomination
- [Phase 4] lore.kernel.org WebFetch: 403; stable@ search UNVERIFIED
- [Phase 5] Callers: amd_pmf_get_sensor_info → delayed work default 1000 ms; deinit from amd_mp2_pci_remove and probe error paths
- [Phase 6] Current file still has unlocked emp2; apply --check of c57016bcf6d0b succeeded (hunk 3 offset −35)
- [Phase 6] include/linux/cleanup.h and DEFINE_GUARD(mutex) in include/linux/mutex.h present; mutex.h included via amd_sfh_common.h
- [Phase 8] Failure mode: UAF of amd_mp2_dev/MMIO on unbind vs PMF reader; severity HIGH
- UNVERIFIED: whether anyone asked for this on stable@ (HTTP 403)
**YES**
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c +6 -0
@@ -8,12 +8,14 @@* Author: Basavaraj Natikar <[email protected]> */ #include <linux/amd-pmf-io.h> +#include <linux/cleanup.h> #include <linux/io-64-nonatomic-lo-hi.h> #include <linux/iopoll.h> #include "amd_sfh_interface.h" static struct amd_mp2_dev *emp2; +static DEFINE_MUTEX (emp2_lock);static int amd_sfh_wait_response (struct amd_mp2_dev *mp2,u8 sid,u32 cmd_id) {
@@ -78,12 +80,14 @@ static struct amd_mp2_ops amd_sfh_ops = {void sfh_deinit_emp2 (void ) { +guard (mutex)(&emp2_lock); emp2 =NULL ; }void sfh_interface_init (struct amd_mp2_dev *mp2) { mp2->mp2_ops = &amd_sfh_ops; +guard (mutex)(&emp2_lock); emp2 = mp2; }
@@ -160,6 +164,8 @@ static int amd_sfh_als_info(u32 *ambient_light)int amd_get_sfh_info (struct amd_sfh_info *sfh_info,enum sfh_message_type op) { +guard (mutex)(&emp2_lock); +if (sfh_info) {switch (op) {case MT_HPD :
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 spi: qpic-snand: free OOB buffer with ECC context
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit 5504e50ffbcf97b3b6ed3740532497922c96a1f1 ]
qcom_spi_ecc_init_ctx_pipelined() allocates qspi->oob_buf as part of the pipelined ECC context setup. The buffer is then used by the raw and ECC page I/O paths through the NAND ECC context.
The matching cleanup callback only frees the qpic_ecc structure, and the init error path also skips the OOB buffer after it has been allocated. Free qspi->oob_buf on both paths and clear the pointer so the ECC context teardown owns all resources allocated during init.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
Record: [spi/qpic-snand] [free] free OOB buffer with ECC context
**Step 1.2 — Tags**
Record:
- Signed-off-by: Pengpeng Hou <[email protected]> (author)
- `Link:
https://patch.msgid.link/[email protected]`
- Signed-off-by: Mark Brown <[email protected]> (SPI maintainer)
- Pipeline-only tags ignored: [Upstream commit 5504e50ffbcf…], Signed-off-by: Sasha Levin
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, `Cc:
stable` (absence expected)
**Step 1.3 — Body**
Record: qcom_spi_ecc_init_ctx_pipelined() allocates qspi->oob_buf. Cleanup only frees qpic_ecc. Init error path after allocation also skips the OOB buffer. Symptom: leaked kmalloc buffer on ECC teardown and on init failure after the buffer exists. Root cause: allocation is not owned by the ECC cleanup/error path.
**Step 1.4 — Hidden bug fix?**
Record: Not disguised. Explicit resource-leak fix (free / missing kfree).
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
Record: drivers/spi/spi-qpic-snand.c only; **+5 / −1**. Functions:qcom_spi_ecc_init_ctx_pipelined, qcom_spi_ecc_cleanup_ctx_pipelined. Single-file surgical fix. Trailing newline at EOF removed (harmless).
**Step 2.2 — Flow**
Record:
- **err_free_ecc_cfg:** previously kfree(ecc_cfg) only → also kfree(oob_buf) and NULL it. Covers failures after kmalloc (notably qcom_alloc_bam_transaction() -ENOMEM) and is a no-op if oob_buf is still NULL.
- **cleanup_ctx:** previously only kfree(ecc_cfg) → get snandc via nand_to_qcom_snand(), free oob_buf, NULL it, then free ecc_cfg.
**Step 2.3 — Bug mechanism**
Record: **resource leak**. oob_buf is kmalloc(mtd->writesize + mtd->oobsize) (typically a few KB). qspi itself is devm_kzalloc, so the buffer is **not** device-managed. nanddev_find_ecc_configuration() does **not** call cleanup_ctx when init_ctx fails, so the error-path kfree is required. Successful attach then spinand_cleanup() / probe- error after ECC init also leak without the cleanup change.
**Step 2.4 — Fix quality**
Record: Obviously correct. kfree(NULL) is safe because qspi is zeroed in probe (devm_kzalloc). NULLing after free avoids a later double-free if cleanup runs after the error path. Regression risk is very low: no locking, API, or I/O-path change. QPIC_QSPI_NUM_CS is 1, so no multi-chip sharing of oob_buf.
## Phase 3: Git history
**Step 3.1 — Blame**
Record: Driver added in 7304d1909080 (2025-02-24, Md Sadre Alam):
allocated oob_buf in init and never freed it in cleanup. d450cdd9c4398 (2025-03) only freed ecc_cfg when OOB alloc failed. 65cb56d49f6ede (in v6.18.53) unified err_free_ecc_cfg still only kfree(ecc_cfg). Bug present since the driver landed.
**Step 3.2 — Fixes: tag**
Record: None. Introducer is 7304d1909080; git merge-base --is- ancestor 7304d1909080 v6.18.53 → yes. The earlier leak fix d450cdd9c4398 is also in v6.18.53 and is incomplete for oob_buf.
**Step 3.3 — File history**
Record: Related: d450cdd9c4398 (ecc_cfg leak), f48d805035042 (kzalloc→kmalloc; still no free). Standalone; not N/M. Later autosel commits (quad mode, ECC strength) are not prerequisites.
**Step 3.4 — Author**
Record: Pengpeng Hou has this one SPI qpic commit here; not the original driver author. SPI maintainer Mark Brown applied it to spi/for-7.3.
**Step 3.5 — Dependencies**
Record: Needs nand_to_qcom_snand(), qspi->oob_buf, err_free_ecc_cfg, and qcom_spi_ecc_cleanup_ctx_pipelined(). All exist in v6.18.53. Standalone.
## Phase 4: Mailing list
**Step 4.1**
Record: b4 dig -c 5504e50ffbcf →
https://patch.msgid.link/[email protected]b4 dig -a: **v1 only**. Thread: author submission + Mark Brown “Applied to … for-7.3”. No NAK, no requested respin.
**Step 4.2**
Record: b4 dig -w: To Mark Brown; Cc linux-spi, linux-kernel. Maintainer applied it.
**Step 4.3**
Record: No bugzilla/syzbot. Leak found by code inspection.
**Step 4.4**
Record: Single-patch series, self-contained.
**Step 4.5**
Record: **UNVERIFIED** — lore.kernel.org/stable blocked by Anubis (403). No local evidence this was rejected for stable.
## Phase 5: Semantic analysis
**Step 5.1**
Record: qcom_spi_ecc_init_ctx_pipelined,qcom_spi_ecc_cleanup_ctx_pipelined.
**Step 5.2**
Record: Wired as .init_ctx / .cleanup_ctx on qcom_spi_ecc_engine_ops_pipelined. Call chain: nand_ecc_init_ctx / nand_ecc_cleanup_ctx → nanddev_ecc_engine_init / nanddev_ecc_engine_cleanup → spinand_init error paths and spinand_cleanup from spinand_probe failure and spinand_remove.
**Step 5.3**
Record: Init: kzalloc(ecc_cfg), kmalloc(oob_buf), qcom_free_bam_transaction / qcom_alloc_bam_transaction. Cleanup:kfree only.
**Step 5.4**
Record: Reachable on Qualcomm IPQ9574 SPI-NAND attach/detach (boot device on many boards). Unprivileged userspace cannot typically unbind without privilege; leak still hits rmmod, unbind, and failed probe after ECC init.
**Step 5.5**
Record: Same driver’s earlier ecc_cfg leak (d450cdd9c4398) used the same pattern. data_buf is an op pointer, not a matching leak. MTK SNFI cleanup only frees its ecc cfg (different allocation model).
## Phase 6: This tree (v6.18.53 / 6.18.y)
**Step 6.1**
Record: git describe HEAD → v6.18.53-5049-g0f0bdc2b0dffb. make kernelversion → 6.18.53.git merge-base --is-ancestor f320c3a8b1119 v6.18.53 → **NO** (not in baseline).
v6.18.53 still has:
```
err_free_ecc_cfg:
kfree(ecc_cfg);
return ret;
…
static void qcom_spi_ecc_cleanup_ctx_pipelined(...)
{
struct qpic_ecc *ecc_cfg = nand_to_ecc_ctx(nand);
kfree(ecc_cfg);
}
```and still allocates snandc->qspi->oob_buf. Driver is in v6.18 (7304d1909080 is an ancestor of v6.18).
**Step 6.2**
Record: patch --dry-run of this diff onto v6.18.53’s file: **clean apply**. Context around err_free_ecc_cfg / cleanup matches.
**Step 6.3**
Record: Incomplete leak fix d450cdd9c4398 is already here; it does not free oob_buf. No other equivalent fix in v6.18.53.
## Phase 7: Subsystem
**Step 7.1**
Record: drivers/spi QPIC SPI-NAND (CONFIG_SPI_QPIC_SNAND, ARCH_QCOM). Compatible qcom,ipq9574-snand. **PERIPHERAL** but real embedded/router hardware; NAND is often boot/rootfs.
**Step 7.2**
Record: Active in 6.16–6.18 (ECC validation, BAM txn, 8-bit ECC, unregister-on-remove). Leak is original, not a new-code regression.
## Phase 8: Impact and risk
**Step 8.1**
Record: Qualcomm IPQ9574 QPIC SPI-NAND users only.
**Step 8.2**
Record: Triggers: (1) init_ctx failure after kmalloc (BAM realloc -ENOMEM) — cleanup not called; (2) later spinand_init failure; (3) spinand_remove / unbind / rmmod. Not a hot-path unbounded leak. Not unprivileged.
**Step 8.3**
Record: Failure mode: leaked page-sized+OOB kmalloc. Severity **MEDIUM** (not oops/corruption; real leak on teardown and some probe errors).
**Step 8.4**
Record: Benefit: medium for this hardware (correct lifetime of ECC-init allocations; matches prior leak fix in the same function). Risk: **very low** (5 lines, kfree+NULL). Ratio favors backport.
## Phase 9: Synthesis
**For:** Real kmalloc leak in this 6.18 tree; error path cannot rely on cleanup; 5-line obviously correct fix; applies cleanly; no new API; maintainer accepted v1; same class as d450cdd9c4398 already in 6.18.
**Against:** Not a crash/security issue; no reporter; driver is Qualcomm-specific; leak is small and not a hot-path OOM.
**Unresolved:** Stable-list discussion (lore blocked).
**Stable rules:**
1. Obviously correct and tested? **PASS** — kfree/NULL; maintainer applied v1.
2. Real user-visible bug? **PASS** — leak on probe-error and remove for IPQ9574 SPI-NAND.
3. Important? **PASS** — resource leak on teardown/error; same pattern routinely taken for stable (not a crash; still a real leak of non- devm memory).
4. Small/contained? **PASS** — 5 lines, one file.
5. No new features/APIs? **PASS**.
6. Applies to this tree? **PASS** — clean on v6.18.53.
**Exception category:** none (ordinary leak fix).
This tree is **6.18.y**. The buggy allocation and missing free are present. The patch is a minimal, correct leak fix with negligible regression risk.
### What it solves for stable users
On IPQ9574 QPIC SPI-NAND, ECC init allocates an OOB scratch buffer that is never freed. Failed attach after that allocation, and every unbind/rmmod, leaks that buffer. 6.18 already had a partial leak fix for ecc_cfg only.
### Risk vs benefit
Benefit is a real leak fix for in-tree hardware. Risk is a handful of kfrees on error/teardown.
---
Verification:
- [Phase 1] Subject/tags: free OOB buffer; SOB Hou + Brown; Link msgid; no Fixes/Reported-by
- [Phase 2] Diff: +5/−1 in spi-qpic-snand.c; kfree(oob_buf) + NULL on err_free_ecc_cfg and cleanup
- [Phase 2] v6.18.53 still lacks those kfrees; kmalloc(writesize+oobsize) present
- [Phase 2] qspi = devm_kzalloc at probe → oob_buf starts NULL; kfree(NULL) safe
- [Phase 3] Introducer 7304d1909080 is ancestor of v6.18 and v6.18.53
- [Phase 3] d450cdd9c4398 in v6.18.53 frees only ecc_cfg on OOB alloc failure
- [Phase 3] 65cb56d49f6ede in v6.18.53; err_free_ecc_cfg still only frees ecc_cfg
- [Phase 3] Candidate f320c3a8b1119 is **not** an ancestor of v6.18.53
- [Phase 4] b4 dig: lore thread, v1 only; Brown applied to spi/for-7.3; no NAK
- [Phase 4] WebFetch lore/msgid 403; curl lore/stable hit Anubis — UNVERIFIED stable-list history
- [Phase 5] Callers: nand_ecc_cleanup_ctx → nanddev_ecc_engine_cleanup → spinand_cleanup (probe err + remove)
- [Phase 5] nanddev_find_ecc_configuration() returns on init_ctx failure **without** cleanup_ctx
- [Phase 5] QPIC_QSPI_NUM_CS is 1
- [Phase 6] git describe HEAD = v6.18.53-5049-g0f0bdc2b0dffb; kernelversion 6.18.53
- [Phase 6] patch --dry-run onto v6.18.53 file: success
- [Phase 6] nand_to_qcom_snand() exists in v6.18.53
- [Phase 7] CONFIG_SPI_QPIC_SNAND depends on ARCH_QCOM; OF qcom,ipq9574-snand
- [Phase 8] Failure: kmalloc leak, MEDIUM; not oops/corruption
- UNVERIFIED: whether linux-stable ever discussed this patch (lore blocked)
**YES**
drivers/spi/spi-qpic-snand.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/spi/spi-qpic-snand.c +5 -1
@@ -394,14 +394,19 @@ static int qcom_spi_ecc_init_ctx_pipelined(struct nand_device *nand)return 0 ; err_free_ecc_cfg: +kfree (snandc->qspi->oob_buf); + snandc->qspi->oob_buf =NULL ;kfree (ecc_cfg);return ret; }static void qcom_spi_ecc_cleanup_ctx_pipelined (struct nand_device *nand) { +struct qcom_nand_controller *snandc =nand_to_qcom_snand (nand);struct qpic_ecc *ecc_cfg =nand_to_ecc_ctx (nand); +kfree (snandc->qspi->oob_buf); + snandc->qspi->oob_buf =NULL ;kfree (ecc_cfg); }
@@ -1660,4 +1665,3 @@ module_platform_driver(qcom_spi_driver);MODULE_DESCRIPTION ("SPI driver for QPIC QSPI cores" );MODULE_AUTHOR ("Md Sadre Alam <[email protected]>" );MODULE_LICENSE ("GPL" ); -
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: mt76: mt7915: configure noise floor reporting on reset
In reply to Sasha LevinFrom: David Bauer <[email protected]>
[ Upstream commit a92cd5dd792a63a5d8a72142835382d4edbe9933 ]
When performing a full system recovery of the MCU on a dual-phy platform, band 0 (usually 2.4GHz) stops reading correct noise floor data.
This is due to noise floor reporting only being configured correctly for the second device PHY.
Configure the respective registers correctly after restarting the MCU firmware to fix reported noise-floor values.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.6.157** (pending-6.6). The buggy dual-PHY restart path is present here, and this commit should be backported.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[wifi: mt76: mt7915]** **[configure]** configure noise floor reporting after MCU reset on dual-PHY platforms. “Configure” here is restoring register state that recovery currently skips, not a new feature.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: David Bauer <[email protected]> (author)
- Link: https://patch.msgid.link/20260516144944.2574053-1-mail@david-
bauer.net
- Signed-off-by: Felix Fietkau <[email protected]> (mt76 maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Cc:
stable (absence is expected)
- Ignored: any pipeline “Upstream commit” / Sasha Levin SOB markers
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** After full MCU recovery on a dual-PHY (DBDC) device, band 0 (usually 2.4 GHz) stops reporting correct noise floor.
- **Symptom:** Wrong NF / survey noise on the primary PHY; the second PHY is configured correctly.
- **Root cause (author):** NF enable is only applied for the second PHY after firmware restart.
- **Version info:** none in the message. The restart path has been in this tree since before v6.6.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised cleanup. It is an explicit hardware-init fix. The mechanism (clear MT76_STATE_RUNNING before mt7915_run()) also re- runs the primary PHY’s PM/MAC init that the same if (!running) guard skips, not only NF.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/net/wireless/mediatek/mt76/mt7915/mac.c only
- Scope: ~+6/−2 in mt7915_mac_restart() (surgical, single function)
- Adds bool run_main, run_ext
- Replaces test_bit(MT76_STATE_RUNNING) with test_and_clear_bit, then uses those saved flags to decide whether to call mt7915_run()
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** After firmware reload, mt7915_run() is called while both PHYs still have MT76_STATE_RUNNING. mt7915_dev_running() is therefore true.
- In this tree, mt7915_run() only programs primary-PHY PM/MAC/NF when !running:
```32:58:drivers/net/wireless/mediatek/mt76/mt7915/main.c
if (!running) {
ret = mt76_connac_mcu_set_pm(&dev->mt76,
dev->phy.mt76->band_idx,
0);
...
mt7915_mac_enable_nf(dev, dev->phy.mt76->band_idx);
}
if (phy != &dev->phy) {
...
mt7915_mac_enable_nf(dev, phy->mt76->band_idx);
}
```- Primary mt7915_run() therefore skips band-0 NF. Ext mt7915_run() still hits phy != &dev->phy and enables band-1 NF. That matches the commit message.
- ieee80211_restart_hw() after full reset does not repair this:
starting the main PHY while the ext PHY still has MT76_STATE_RUNNING keeps running == true, so band 0 is skipped again; starting the ext PHY then enables only the ext PHY’s NF.
- **After:** bits are cleared first, so the first mt7915_run() sees running == false and programs band 0. Saved flags still prevent starting a PHY that was never up.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Logic / hardware-init.** After MCU reload, IPI/NF registers (mt7915_mac_enable_nf: MT_WF_PHY_RXTD12_* and MT_WF_PHY_RX_CTRL1_IPI_EN) are not programmed for band 0. mt7915_mac_init_band() does not enable NF; only mt7915_run() does.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct. Same approach the mt76 maintainer asked for on-list. Minimal. Mutex is already held in mt7915_mac_full_reset(); MT76_RESET is already set. Risk is low: if mt7915_run() fails, the RUNNING bits stay clear, but full reset retries and then calls ieee80211_restart_hw(), which stop/start and restores them.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: The test_bit + mt7915_run() sequence was introduced in 8a55712d124fd8 (“wifi: mt76: mt7915: enable full system reset support”, Bo Jiao / Ryder Lee, 2022). git describe --contains → v6.2-rc1~.... Present in this 6.6 tree (git merge-base --is-ancestor 8a55712d124fd8 HEAD succeeded).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable. The introducing commit is in this tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Related reset work already in this tree:
- c71d2db21f153 improve hardware restart reliability
- 1e474cbe5db60 fix omac index assignment after hardware reset
- 72eabd4c1986b firmware restart on devices with a second PCIe link This patch is standalone; it does not depend on those. test_and_clear_bit(MT76_STATE_RUNNING) is **not** in this tree (git grep found no matches).
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: David Bauer is an OpenWrt/wireless contributor; in this tree he already has b6c39aaa85c4e (mt7915 MCU re-init). Felix Fietkau (mt76 maintainer) signed off and designed the committed approach.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: No functional prerequisites. Surrounding mt7915_init_txpower() signature and napi_enable placement differ from later mainline; those are context only. The run_main/run_ext change applies with a small context tweak.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record: b4 dig -c was not usable (commit SHA not in this checkout’s master). b4 mbox on msgid 20260516144944.2574053-1-mail@david- bauer.net saved a 4-message thread.
- v1 (16 May 2026): 4-line change in mt7915_run(): if (!running || (reset && phy == &dev->phy))
- Felix (27 May): asked to clear MT76_STATE_RUNNING in mt7915_mac_restart instead
- David: explained the per-PHY RUNNING guard (don’t start a PHY that was never up)
- Felix (1 Jun): proposed exactly the committed test_and_clear_bit pattern
No NAK. No reviewer Cc: stable. Committed diff is the maintainer rewrite, still linked to the v1 msgid.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: Recipients included Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen, Sean Wang, linux-wireless, linux-mediatek. Felix both reviewed and applied.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla. Author describes a real dual-PHY MCU recovery failure. That is a field observation, not a theoretical report.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Single patch, not N/M. v1 vs committed is a maintainer rewrite of the same fix, not a multi-patch series.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No useful stable-list hit for this subject. No recorded reason to keep it out of stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: Modified: mt7915_mac_restart(). Behavior depends on mt7915_run(), mt7915_dev_running(), mt7915_mac_enable_nf().
**Step 5.2: TRACE CALLERS**
Record:
- mt7915_mac_restart() ← mt7915_mac_full_reset() (only caller in this tree)
- mt7915_mac_full_reset() ← mt7915_mac_reset_work() when dev->recovery.restart
- recovery.restart set in mt7915_reset() on WA/WM watchdog (MT_MCU_CMD_WDT_MASK), which logs “firmware crash, attempting recovery”
- mt7915_run() also from mt7915_start() (normal iface start); this patch does not change that path
**Step 5.3: TRACE CALLEES**
Record: After firmware load: mt7915_mcu_init_firmware, mt7915_mcu_set_eeprom, mt7915_mac_init, txpower/txbf, then mt7915_run() (PM, mt7915_mcu_set_mac, mt7915_mac_enable_nf, thermal, RTS, SKU, RX path).
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Triggered by firmware watchdog recovery on CONFIG_MT7915E dual-PHY (mt7915/mt7916/mt798x DBDC), common on APs/routers. Not a generic syscall crash path. Userspace sees bad survey noise (mt76_get_survey → SURVEY_INFO_NOISE_DBM) and ACS can use it. Debugfs can also force full reset (b662b71).
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: No test_and_clear_bit(MT76_STATE_RUNNING) in this tree’s mt76. Sibling chips (mt7615/mt7996) have similar NF helpers; this fix is mt7915-restart-specific.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. mt7915_mac_restart() at drivers/net/wireless/mediatek/mt76/mt7915/mac.c:1397-1407 still uses test_bit without clearing. Introduced v6.2-era (8a55712d124fd8), present since this 6.6 branch.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Minor context.** Mainline hunk context uses mt7915_init_txpower(&dev->phy) / mt7915_init_txpower(phy2); this tree still has mt7915_init_txpower(dev, &dev->mphy.sband_* ). napi_enable vs local_bh_disable order in the out: path also differs. The RUNNING-bit change itself matches this tree. Easy manual backport; not a rewrite.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: Reset reliability/omac-after-reset fixes are here. This NF re- init after MCU recovery is not.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **wifi / mt76 mt7915** (drivers/net/wireless/mediatek/mt76/mt7915/). **IMPORTANT** for users of these radios (filogic/mt7915 DBDC APs), not core mm/net. Not staging.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature driver, still getting reset-path fixes in this 6.6 tree. Not a newly added subsystem.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver-specific, dual-PHY CONFIG_MT7915E after full MCU recovery. Widely used on embedded/AP hardware.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Firmware WA/WM watchdog → full recovery. Unprivileged users cannot trigger it directly. Timing is the recovery path, not a race. Debugfs reset can also hit it.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Wrong band-0 noise floor / survey after recovery; ACS can pick a worse channel. Not an oops, deadlock, or corruption. Connectivity was not reported broken; mac_init still runs, so MAC datapath likely survives. **Severity: MEDIUM.**
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** Medium. Restores intended PHY register state on a recovery path this tree already treats as backport-worthy.
- **Risk:** Low. ~8 lines, one function, maintainer-specified, under existing reset mutex.
- **Ratio:** Favorable.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real dual-PHY bug after MCU full recovery; primary PHY NF registers never reprogrammed
- Code and introducing commit are in 6.6.157
- Small, obviously correct, maintainer-directed
- Same !running skip also omits band-0 set_pm/set_mac on that path
- This tree already backported other mt7915 reset corrections
- Dual-PHY mt7915/mt798x is common production AP hardware
AGAINST:
- Not a crash, UAF, deadlock, or security issue
- Trigger is firmware watchdog recovery, not a hot path
- User-visible effect is mainly survey/ACS noise, not a reported outage
- Apply needs a trivial context adjustment
UNRESOLVED:
- Upstream SHA is not on this checkout’s master, so b4 dig -c <sha> was not run (thread retrieved via msgid instead)
- No independent confirmation that band-0 MAC/PM skip causes traffic loss (author only reported NF)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — logic matches mt7915_run(); maintainer specified this form
2. Fixes a real bug that affects users? **PASS** — wrong NF after recovery on dual-PHY
3. Important issue? **PASS** (medium) — recovery leaves hardware misconfigured; not a panic, but it is a real functional failure of SER
4. Small and contained? **PASS** — one function, few lines
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — buggy code present; minor context only
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a new device ID/API. Closest class is hardware re-init after reset (quirk-like). Qualifies on technical merit, not only via an exception.
**Step 9.4: MAKE YOUR DECISION**
Backport. The 6.6 tree has the bug, the fix is surgical, and leaving MCU recovery with band 0 NF unprogrammed is a real driver bug on hardware this series already ships.
Verification:
- [Phase 1] Parsed tags: author David Bauer, Link to msgid, SOB Felix Fietkau; no Fixes/Cc stable/Reported-by
- [Phase 1] Body: dual-PHY MCU recovery → band 0 NF wrong because only PHY1 is configured
- [Phase 2] Diff: mt7915_mac_restart() saves/clears RUNNING then calls mt7915_run()
- [Phase 2] Local mt7915_run(): primary NF only if !mt7915_dev_running(); ext NF if phy != &dev->phy
- [Phase 2] mt7915_mac_init_band() does not set IPI/NF; only mt7915_mac_enable_nf() does
- [Phase 3] git blame mac.c:1397-1407 → 8a55712d124fd8 (v6.2-rc1); ancestor of HEAD
- [Phase 3] git grep test_and_clear_bit(MT76_STATE_RUNNING) → no hits in this tree
- [Phase 3] Related reset fixes already here (c71d2db21f153, 1e474cbe5db60); this NF fix is not
- [Phase 4] b4 mbox msgid → 4-message thread; Felix requested the committed approach; no NAK
- [Phase 4] lore.kernel.org WebFetch returned 403; used b4 mbox + openwall/ratatoskr instead
- [Phase 4] No meaningful stable-list discussion found
- [Phase 5] Call chain: WDT → mt7915_reset() → dump_work → mt7915_mac_reset_work() → mt7915_mac_full_reset() → mt7915_mac_restart()
- [Phase 5] Survey path: mt7915_update_channel() → state->noise → mt76_get_survey()
- [Phase 6] git describe HEAD / make kernelversion → p-6.6-3 / **6.6.157**
- [Phase 6] Local mt7915_init_txpower() signature differs from patch context; RUNNING change still maps 1:1
- [Phase 8] Failure mode: incorrect band-0 noise after firmware crash recovery; severity MEDIUM
- UNVERIFIED: exact upstream SHA (not on this master); whether band-0 set_mac skip also breaks traffic (not claimed by author)
The patch is a small, maintainer-reviewed correction of MCU recovery on dual-PHY mt7915, and the buggy code is in this 6.6 tree.
**YES**
drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +7 -2
@@ -1292,6 +1292,7 @@ mt7915_mac_restart(struct mt7915_dev *dev)struct mt7915_phy *phy2;struct mt76_phy *ext_phy;struct mt76_dev *mdev = &dev->mt76; +bool run_main, run_ext;int i, ret; ext_phy = dev->mt76.phys[MT_BAND1 ];
@@ -1387,13 +1388,17 @@ mt7915_mac_restart(struct mt7915_dev *dev)mt7915_init_txpower (phy2); ret =mt7915_txbf_init (dev); -if (test_bit (MT76_STATE_RUNNING , &dev->mphy.state)) { + run_main =test_and_clear_bit (MT76_STATE_RUNNING , &dev->mphy.state); + run_ext = ext_phy && +test_and_clear_bit (MT76_STATE_RUNNING , &ext_phy->state); + +if (run_main) { ret =mt7915_run (dev->mphy.hw);if (ret) goto out; } -if (ext_phy &&test_bit (MT76_STATE_RUNNING , &ext_phy->state)) { +if (run_ext) { ret =mt7915_run (ext_phy->hw);if (ret) goto out;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 NFSv4/flexfiles: report cancelled I/O as a layout error
In reply to Sasha LevinFrom: Benjamin Coddington <[email protected]>
[ Upstream commit 4a013b0e881e0466cc2c6a5518d2f6cda3a4f19f ]
When a layout is recalled or revoked the client cancels its in-flight I/O so the layout can be returned. The metadata server needs to learn that this I/O to the storage device did not complete, so that it can reconcile the affected mirror instance (or, if none remains, take other action).
The cancellation completed with -EAGAIN, which ff_layout_io_track_ds_error() does not recognise: it fell through the switch and recorded nothing, so no error was reported to the server.
-EAGAIN is overloaded in the RPC layer, so rather than key the reporting on it, cancel the I/O with -ECANCELED and map that to NFS4ERR_NXIO in ff_layout_io_track_ds_error() -- the status the client already reports for the transport errors that leave an in-flight write incomplete. The cancelled I/O is then reported to the server via LAYOUTERROR / LAYOUTRETURN.
Unlike a genuine transport error, though, we aborted the I/O ourselves and have no evidence the device is at fault, so once the error is recorded we skip marking the device unreachable and forcing a further layout return.
The retry disposition is unchanged from the original -EAGAIN cancellation:
both NFS4ERR_NXIO and -ECANCELED are no-ops in ff_layout_async_handle_error(), which still resets the I/O to pNFS (or the MDS), so it is re-driven as before.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). The buggy cancel path is present here; the candidate is not.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [NFSv4/flexfiles] [report] report cancelled I/O as a layout error
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Benjamin Coddington <[email protected]> (author)
- Signed-off-by: Trond Myklebust <[email protected]> (NFS maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, Link:, or Cc: stable (absence expected)
- Author in git: Benjamin Coddington <[email protected]>
- Upstream SHA (on all-next, not in this tree):
4a013b0e881e0466cc2c6a5518d2f6cda3a4f19f (2026-06-25)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: on layout recall/revoke the client cancels in-flight DS I/O so the layout can be returned. Cancellation used -EAGAIN, which ff_layout_io_track_ds_error() does not recognize, so it records nothing and the MDS never learns the I/O did not complete.
- Symptom: MDS cannot reconcile the affected flexfiles mirror (or take other action if no instance remains). Incomplete writes can sit on a DS with no write layout held.
- Root cause: -EAGAIN is overloaded in the RPC layer and is not in the tracked-error switch (default: return).
- Fix: cancel with -ECANCELED, map that to NFS4ERR_NXIO (same status already used for transport errors that leave a write incomplete), report via LAYOUTERROR / LAYOUTRETURN, but skip marking the device unreachable and skip forcing another layout return.
- Retry path: unchanged; both NFS4ERR_NXIO and -ECANCELED fall through ff_layout_async_handle_error() to RESET_TO_PNFS / RESET_TO_MDS.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. This is an explicit protocol/correctness fix:
cancelled I/O was silently dropped instead of being reported to the MDS.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: fs/nfs/flexfilelayout/flexfilelayout.c (+22 / -1)
- Functions: ff_layout_io_track_ds_error(), ff_layout_cancel_io()
- Scope: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Hunk 1 (switch): -ECANCELED now maps to NFS4ERR_NXIO and continues into ff_layout_track_ds_error() instead of hitting `default:
return`.
- Hunk 2: after recording the error, if (error == -ECANCELED) goto out; skips ff_layout_mark_ds_unreachable() and pnfs_error_mark_layout_for_return().
- Hunk 3: rpc_cancel_tasks(clnt, -EAGAIN, ...) becomes rpc_cancel_tasks(clnt, -ECANCELED, ...).
- Prepare paths (ff_layout_*_prepare_common) still rpc_exit(task, -EAGAIN) for invalid lsegs. That is I/O that was never sent; it is correctly left alone.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- Category: logic / protocol correctness (missing error reporting), with data-integrity impact on flexfiles mirrors.
- Mechanism: cancelled in-flight RPC completed with an unrecognized errno, so no nfs4_ff_layout_ds_err was queued and LAYOUTERROR / LAYOUTRETURN carried no I/O error.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: use a dedicated errno, record it as the same NXIO the client already reports for incomplete writes, and do not condemn the device for a client-initiated abort.
- Minimal; no API or structural change.
- Regression risk: low. nfs_pgio_result() treats any non-zero rw_done() return the same, so -ECANCELED vs -EAGAIN does not change the resend path. Verified in ff_layout_async_handle_error_v4(): NFS4ERR_NXIO is a no-op in the op_status switch; -ECANCELED is not a connection error, then RESET_TO_PNFS/MDS. v3 already deleted the deviceid on -EAGAIN (default) and still does so on -ECANCELED.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Error switch introduced in dd52128afdde (Trond, 2015-08-20) — never handled -EAGAIN.
- ff_layout_cancel_io() and the -EAGAIN cancel introduced in b739a5bd9d9f18 ("NFSv4/flexfiles: Cancel I/O if the layout is recalled or revoked", 2022-10-05, first in v6.1-rc1).
- That cancel commit is an ancestor of HEAD.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The introducing commit is b739a5bd9d9f18, present in this tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES** Record:
- Same pattern already in this tree: 1630224189cc4 (ENETDOWN), dd7d7ee3ba2a7 (EINVAL), 7836d75467e9d (RDMA) — all add cases to this switch so the MDS is told.
- This commit is patch 3/3 of "pNFS/flexfiles: honor clora_changed and report cancelled I/O".
- Patch 2 (aceaa5991bdf7 "honor clora_changed when recalling a layout") is **not** in this tree. It only changes *when* cancel runs (skip cancel if clora_changed is false). This commit does not call any new helper from patch 2.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Benjamin Coddington (Hammerspace) is a regular NFS/pNFS contributor. Trond (NFS maintainer, also Hammerspace) applied it.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Record:
- Semantic fix is standalone: change the cancel errno and handle it in the existing switch.
- Clean apply is **not** standalone against this tree. Mainline added dss_id via later striped-layout commits (8a8e0f5566edc, a1491919c8805, 20b1d75fb840c, …). Those are **not** in HEAD. This tree only has d1830d0740d72 (data-structure support) and still uses mirror->dss[0] / no dss_id argument.
- git apply --check of the mainline diff: hunk 1 applied (offset -177); hunk 2 failed on the dss_id argument. A 6.12 backport is a small context edit, not a rewrite.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 4a013b0e881e0 → https://patch.msgid.link/b5ed2050a2fa573ad
[email protected]
- Series: v1 (2026-06-24) then v2 (2026-06-25). Applied version is v2 3/3.
- Cover letter: RFC 8881 §20.3.3; since b739a5bd9d9f the client cancels DS I/O on every recall; when it *does* cancel (changed recall or revoke), report NFS4ERR_NXIO so the MDS can reconcile.
- v2 changes were only for patches 1–2 (Anna: kerneldoc, FILE_INODE / inode->i_ino). Patch 3 was unchanged.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record:
- Recipients: Trond Myklebust, Anna Schumaker, [email protected]
- Anna reviewed v1 1/3 and 2/3 only (tracepoint inode id; kerneldoc for cancel_io). No NAK. No comments on 3/3.
- Trond applied the series (Signed-off-by).
- No reviewer Cc: stable.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot, bugzilla, or external user report. The description is a vendor/protocol failure (Hammerspace flexfiles MDS cannot reconcile after cancel). WebFetch to lore returned 403; discussion was recovered via b4 dig -m.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record:
- 1/3: tracepoint only — not required for this fix.
- 2/3: stop cancelling on unchanged recalls — complementary RFC behavior, not a compile/runtime dependency of 3/3. Without it, 6.12 still cancels on every recall, so this fix would send NXIO on more recalls than post-series mainline. That is more conservative for the MDS (reconcile), not a crash path.
- Other cancel callers (pnfs_mark_matching_lsegs_invalid, teardown/return with cancel) remain even after 2/3.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No stable-list discussion found (lore.kernel.org/stable search via WebFetch was 403). UNVERIFIED: whether anyone already requested or rejected this for stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: ff_layout_io_track_ds_error(), ff_layout_cancel_io().
**Step 5.2: TRACE CALLERS**
Record:
- ff_layout_io_track_ds_error(): ff_layout_read_done_cb(), ff_layout_write_done_cb(), ff_layout_commit_done_cb() — DS I/O completion.
- ff_layout_cancel_io(): registered as pnfs_layoutdriver_type.cancel_io.
- pnfs_lseg_cancel_io() → pnfs_mark_matching_lsegs_invalid() (line
744) and pnfs_mark_matching_lsegs_return() (line 2678).
- Those run on CB_LAYOUTRECALL, layout return, revoke, and teardown.
**Step 5.3: TRACE CALLEES**
Record: ff_layout_track_ds_error() queues nfs4_ff_layout_ds_err; ff_layout_send_layouterror() / ff_layout_encode_ioerr() send LAYOUTERROR / LAYOUTRETURN. rpc_cancel_tasks() → rpc_task_try_cancel().
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable from normal pNFS flexfiles file I/O plus MDS CB_LAYOUTRECALL. Not a raw syscall crash path; it is a common path for any flexfiles mount under layout recall/return.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same switch already maps transport failures to NFS4ERR_NXIO. This is the same class of fix, for a client-initiated cancel that previously fell on the floor.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes.
- Tree: p-6.12-3-gc504cf0baa3d8, VERSION=6 PATCHLEVEL=12 SUBLEVEL=111.
- git merge-base --is-ancestor 4a013b0e881e0 HEAD → not an ancestor (fix not present).
- ff_layout_cancel_io() still uses -EAGAIN (line 2196).
- ff_layout_io_track_ds_error() has no -ECANCELED case; default returns without recording (lines 1369–1370).
- Bug introduced in v6.1 (b739a5bd9d9f18); present for the whole 6.12 lifetime.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Minor conflicts. Need to drop dss_id from ff_layout_track_ds_error() / ff_layout_mark_ds_unreachable() and keep the single dss[0] cancel loop. Not a semantic rewrite.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No equivalent cancel-reporting fix. Related NXIO mappings (ENETDOWN, EINVAL, EPROTO/ENODEV) are already here and do not cover cancel.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: fs/nfs/flexfilelayout — NFSv4.1 pNFS flexfiles client. **IMPORTANT** (not core VFS; production for flexfiles MDS deployments). CONFIG_PNFS_FLEXFILE_LAYOUT defaults to NFS_V4.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Active. Recent 6.12 backports include NO_IO_THRU_MDS, zero-FH rejection, NFS-level error handling, ENETDOWN reporting.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Flexfiles pNFS clients (CONFIG_PNFS_FLEXFILE_LAYOUT). Not universal; real production users (Hammerspace and other flexfiles MDS).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Layout recall, revoke, or return while DS read/write/commit RPCs are in flight. Common on flexfiles (recall on close, lease recovery, restriping). Not an unprivileged local exploit; it is a networked MDS callback plus in-flight I/O.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: MDS is not told that in-flight writes did not complete, so it may not reconcile a mirror. Later reads can see a stale or incomplete replica. **HIGH** (data integrity / stale data), not a kernel oops.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: HIGH for flexfiles — MDS can reconcile after cancel/revoke.
- Risk: LOW — +22 lines, contained, retry path unchanged. Extra NXIO reports on 6.12’s still-unconditional cancel are conservative, not a hang/crash.
- Ratio: benefit outweighs risk.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real bug: cancelled DS I/O is invisible to the MDS.
- Data-integrity impact on flexfiles mirrors.
- Code is in this 6.12 tree since v6.1.
- Small, obviously correct, maintainer-applied.
- Same reporting pattern already backported here (ENETDOWN, EINVAL, RDMA).
- Retry disposition verified unchanged.
AGAINST:
- Patch 3/3 of a series; 2/3 (narrower cancel) is not here.
- Mainline diff needs a small dss_id-free backport.
- No crash/UAF/CVE; flexfiles-specific.
- No Fixes:/Cc: stable/user report (expected for this queue).
UNRESOLVED:
- Stable-list history (lore/stable WebFetch 403).
- How every flexfiles MDS implementation reacts to extra NXIO on unchanged recalls (without patch 2). Conservative, not a kernel regression.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — mapped like existing transport errors; applied by the NFS maintainer.
2. Fixes a real bug that affects users? **PASS** — MDS cannot reconcile after cancel.
3. Important issue? **PASS** — data integrity / stale flexfiles mirrors (HIGH, not oops).
4. Small and contained? **PASS** — +22/-1, one file.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — needs a trivial context backport (no dss_id); buggy code is here.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not a device ID, quirk, DT, build, or docs fix). Qualifies as a normal important bugfix.
**Step 9.4: MAKE YOUR DECISION**
This should be backported to this 6.12 tree. The cancel path exists, the MDS is not told, and the fix is small. Adapt the hunks to the dss[0] / no-dss_id signatures; do not pull the striped-layout series.
What it solves for stable users: after layout recall/revoke, in-flight flexfiles I/O is cancelled so the layout can return, but 6.12 records nothing. The MDS then cannot reconcile the mirror. Mapping cancel to NFS4ERR_NXIO and sending LAYOUTERROR / LAYOUTRETURN closes that hole without marking the device dead or changing retry.
Risk vs benefit: low risk, high benefit on flexfiles. Companion patch 2 (honor clora_changed) is a separate RFC behavior change and is not required for this reporting fix to work.
Verification:
- [Phase 1] Tags: only author + Trond SOBs; no Fixes/Reported-by/Cc stable
- [Phase 1] Upstream SHA 4a013b0e881e0 on all-next; git merge-base --is-ancestor → not in HEAD
- [Phase 2] Diff: +22/-1 in one file; -EAGAIN → -ECANCELED; new NXIO case; skip unreachable/return
- [Phase 2] NFS4ERR_NXIO and NFSERR_NXIO both equal 6
- [Phase 2] nfs_pgio_result(): non-zero rw_done() skips nfs_set_pgio_error for both errnos
- [Phase 2] v4/v3 async handlers: retry disposition matches the commit text
- [Phase 3] Blame: switch from dd52128afdde (2015); cancel from b739a5bd9d9f18 (v6.1), ancestor of HEAD
- [Phase 3] Similar backports already here: 1630224189cc4, dd7d7ee3ba2a7, 7836d75467e9d
- [Phase 3] Patch 2 aceaa5991bdf7 is not an ancestor of HEAD
- [Phase 4] b4 dig -c 4a013b0e881e0: v2 3/3 at the msgid.link above
- [Phase 4] b4 dig -a: v1 then v2; 3/3 unchanged
- [Phase 4] b4 dig -w: Trond, Anna, linux-nfs
- [Phase 4] Anna v1 review: nits on 1/3 and 2/3 only; no NAK of 3/3
- [Phase 4] Cover letter recovered from /tmp/ff-cancel-thread.mbox
- [Phase 5] Callers: read/write/commit done_cb; cancel via pnfs_lseg_cancel_io from recall/return/invalidate
- [Phase 6] git describe HEAD → p-6.12-3-gc504cf0baa3d8; make kernelversion → 6.12.111
- [Phase 6] Local cancel still -EAGAIN at flexfilelayout.c:2196; no -ECANCELED in fs/nfs
- [Phase 6] git apply --check failed on dss_id hunk; striped error- path commits not in HEAD
- [Phase 8] Failure mode: unreported incomplete DS I/O → unreconciliation / stale mirror, HIGH
- UNVERIFIED: stable@ discussion (lore 403)
**YES**
fs/nfs/flexfilelayout/flexfilelayout.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
fs/nfs/flexfilelayout/flexfilelayout.c +22 -1
@@ -1546,6 +1546,17 @@ static void ff_layout_io_track_ds_error(struct pnfs_layout_segment *lseg,case -EACCES : *op_status = status =NFS4ERR_ACCESS ;break ; +case -ECANCELED : +/* +* In-flight I/O we cancelled to return a recalled or +* revoked layout. Report it as a failure to reach the +* device (NFS4ERR_NXIO), like the transport errors +* above, so the server can reconcile the affected mirror +* instance. We aborted the I/O ourselves rather than +* observe the device fail, so don't condemn it below. +*/ + *op_status = status =NFS4ERR_NXIO ; +break ;default :return ; }
@@ -1556,6 +1567,15 @@ static void ff_layout_io_track_ds_error(struct pnfs_layout_segment *lseg, mirror, dss_id, offset, length, status, opnum, nfs_io_gfp_mask()); +/* +* I/O we cancelled ourselves to return a recalled or revoked layout +* is reported above so the server can reconcile the mirror, but we +* have no evidence the device is at fault: don't mark it unreachable +* or force a return. +*/ +if (error == -ECANCELED ) + goto out; +switch (status) {case NFS4ERR_DELAY :case NFS4ERR_GRACE :
@@ -1575,6 +1595,7 @@ static void ff_layout_io_track_ds_error(struct pnfs_layout_segment *lseg, lseg); } +out:dprintk ("%s: err %d op %d status %u\n" , __func__, err, opnum, status); }
@@ -2465,7 +2486,7 @@ static void ff_layout_cancel_io(struct pnfs_layout_segment *lseg) clnt = ds_clp->cl_rpcclient;if (!clnt)continue ; -if (!rpc_cancel_tasks (clnt, -EAGAIN , +if (!rpc_cancel_tasks (clnt, -ECANCELED , ff_layout_match_io, lseg))continue ;rpc_clnt_disconnect (clnt);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ACPI: video: force native backlight on Acer Nitro AN515-46
In reply to Sasha LevinFrom: Marcos Paulo Medeiros <[email protected]>
[ Upstream commit 525ba51157ac6e1772b5412eae26b20dd7ef8bda ]
The Acer Nitro AN515-46 is a hybrid graphics laptop whose internal panel is driven by the AMD GPU (Radeon 680M); the discrete NVIDIA GPU only drives external outputs. The firmware nevertheless advertises the NVIDIA WMI EC backlight GUID, so the backlight type resolves to nvidia_wmi_ec. The nvidia-wmi-ec-backlight driver however fails to probe ("EC backlight control failed: AE_NOT_FOUND") and, since the backlight type is still nvidia_wmi_ec, amdgpu skips registering its own backlight device. The result is no backlight device at all, leaving the brightness keys and the desktop brightness slider non-functional.
Booting with acpi_backlight=native makes amdgpu register its backlight interface and brightness control works. Add a DMI quirk to use the native backlight on this model by default.
---
LLM Generated explanations, may be completely bogus:
This is a DMI hardware quirk for a real backlight failure on the Acer Nitro AN515-46. The buggy detection path, amdgpu skip, and Rembrandt GPU support are all present in this 6.12.111 tree, and the 8-line table entry matches the existing quirk pattern.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [ACPI: video] [force] [DMI quirk to use native backlight on Acer Nitro AN515-46]
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Marcos Paulo Medeiros (author)
- Link: https://patch.msgid.link/20260727132151.12792-1-
[email protected]
- Signed-off-by: Rafael J. Wysocki (ACPI maintainer; applied the patch)
- No Fixes:, Reported-by, Tested-by, Reviewed-by, Acked-by, or Cc:
stable (absence of the last two is expected for this review)
- Ignored: any pipeline-added Sasha Levin SOB / Upstream commit markers
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: hybrid AMD+NVIDIA laptop; internal panel is AMD Radeon 680M; firmware still advertises the NVIDIA WMI EC backlight GUID.
- Detection then returns nvidia_wmi_ec. nvidia-wmi-ec-backlight probe fails with "EC backlight control failed: AE_NOT_FOUND". Because the type stays nvidia_wmi_ec, amdgpu does not register a native backlight device.
- Symptom: no backlight device; brightness keys and the desktop slider do nothing.
- Workaround: acpi_backlight=native lets amdgpu register and brightness works.
- Root cause: firmware advertises NVIDIA EC backlight that does not actually work; autodetection prefers it over native AMD backlight.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not disguised. This is an explicit hardware-quirk bugfix: force native backlight so the working GPU interface is used.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/acpi/video_detect.c (+8 / −0)
- Function: static table video_detect_dmi_table[] (not a code-path change)
- Scope: single-file surgical DMI entry; callback is existing video_detect_force_native
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: this product is not in the table, so autodetection can select nvidia_wmi_ec.
- After: DMI match on vendor "Acer" / product "Nitro AN515-46" sets acpi_backlight_dmi = acpi_backlight_native.
- Path: init-time DMI check in __acpi_video_get_backlight_type(), which already prefers DMI over nvidia_wmi_ec autodetection.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Category: hardware workaround (DMI quirk)
- Mechanism: firmware reports NVIDIA EC backlight; nvidia_wmi_ec_supported() is true; type becomes acpi_backlight_nvidia_wmi_ec; GPU drivers then skip native registration via acpi_video_backlight_use_native(); the WMI EC driver fails probe; result is zero backlight devices.
- Fix: DMI override to native, which is checked before the nvidia_wmi_ec special case.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: same pattern as Dell G15 5515, Vostro 15 3535, Lenovo 82K8 already in this file.
- Minimal: 8 lines, one model, existing callback.
- Regression risk: very low; only that DMI product string is affected. Native is the workaround the author already confirmed.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record: Insertion is after the HP OMEN 16-n0xxx native quirk (5b8d6a94f2e2c in this tree). Surrounding native-force entries have been in this file for many releases. video_detect_force_native() is long-standing (lines 129–133).
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Bug is firmware/autodetect interaction, not a single introducing commit. Related infrastructure:
- fe7aebb40d42b "ACPI: video: Add Nvidia WMI EC brightness control detection" — in this tree (git merge-base --is-ancestor exit 0); first in v6.1-rc1.
- da11ef832972e "drm/amdgpu: Don't register backlight when another backlight should be used" — in this tree; first in v6.1-rc1.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: Recent video_detect.c commits on this branch are the same class of DMI quirks (HP OMEN 16, Lenovo 82K8, Dell OptiPlex AIOs). No missing refactor prerequisite. Standalone DMI addition, not a series.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Marcos Paulo Medeiros has this one ACPI video commit on origin/master. Applied by Rafael J. Wysocki (ACPI maintainer). Hans de Goede (backlight-detect author) was CCed.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: Needs acpi_backlight_nvidia_wmi_ec, video_detect_force_native, and GPU acpi_video_backlight_use_native(). All exist here. Applies standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- Lore/msgid: https://patch.msgid.link/20260727132151.12792-1-
[email protected]
- b4 dig -a: v1 only; no later revision.
- Thread: submission + Rafael "Applied as 7.3 material, thanks!" — no NAK, no requested changes.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To Rafael J. Wysocki; Cc Len Brown, Hans de Goede, linux-acpi. Maintainer applied it. No reviewer-flagged risk.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla link. Author describes a concrete device failure and a working cmdline workaround. A later AN515-58 patch cites the same nvidia_wmi_ec failure mode on a sibling model (not in this commit).
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone 1/1. Same class as Dell G15 5515 ("nvidia-ec-wmi present but should not use it") already in this file.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable search returned 403. UNVERIFIED whether stable@ discussed this specific SHA. Not used as a negative signal.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: Table-only change. Callback: video_detect_force_native().
Consumers: __acpi_video_get_backlight_type(), acpi_video_backlight_use_native(), nvidia_wmi_ec_backlight_probe(), amdgpu_dm_register_backlight_device().
Step 5.2: TRACE CALLERS
Record:
- dmi_check_system(video_detect_dmi_table) at video_detect.c:1013 during first __acpi_video_get_backlight_type().
- acpi_video_backlight_use_native() called from amdgpu_dm, amdgpu atombios encoders, i915, nouveau, radeon, gma500 — GPU backlight registration.
- nvidia_wmi_ec_backlight_probe() refuses to bind unless type is acpi_backlight_nvidia_wmi_ec.
Step 5.3: TRACE CALLEES
Record: video_detect_force_native() only assigns acpi_backlight_dmi = acpi_backlight_native. No alloc/lock/I/O.
Step 5.4: FOLLOW THE CALL CHAIN
Record: Boot/GPU probe on this laptop → nvidia_wmi_ec_supported() true (SOURCE=EC) → type nvidia_wmi_ec → amdgpu skips (Skipping amdgpu DM backlight registration) → WMI probe calls LEVEL and hits EC backlight control failed: AE_NOT_FOUND (exact string in nvidia-wmi-ec- backlight.c:52) → no backlight device. Userspace brightness is broken. Reachable on normal laptop use, not a fuzzer-only path.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same video_detect_force_native + NVIDIA EC mismatch already used for Dell G15 5515, Vostro 15 3535, Lenovo 82K8 in this file. Systematic firmware issue, not a one-off pattern.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes, this is pending-6.12 / 6.12.111 (git describe HEAD = p-6.12-1-gf9fa14938873a).
- acpi_backlight_nvidia_wmi_ec in include/acpi/video.h
- nvidia_wmi_ec_supported() / return nvidia_wmi_ec in video_detect.c:1044-1045
- nvidia-wmi-ec-backlight.c present
- amdgpu skip at amdgpu_dm.c:4843
- Rembrandt/680M: CHIP_YELLOW_CARP PCI IDs 0x164D and 0x1681 in amdgpu_drv.c
- No existing "Nitro AN515-46" entry
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Clean apply. Upstream hunk sits after HP OMEN 16-n0xxx and before the "x86 android tablets" comment; that exact sequence is at lines 912–922 here.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: Related nvidia_wmi_ec native quirks exist (Dell G15, Lenovo 82K8). This model is not covered. git log --grep=AN515 -- drivers/acpi/video_detect.c is empty.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: ACPI video backlight detection (drivers/acpi/video_detect.c).
IMPORTANT: laptop brightness on hybrid AMD/NVIDIA systems. Not core mm/scheduler, but a common user-visible path.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Actively maintained; many DMI quirks already landed on this 6.12 branch. Mature table plus ongoing per-model entries.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver/platform-specific: Acer Nitro AN515-46 only (DMI vendor+product). No effect on other machines.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Every boot on that model with default autodetection. No race. Unprivileged users hit it via brightness keys/slider; they cannot fix it without acpi_backlight=native.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: No backlight device; brightness control dead. Not a panic/UAF. Severity MEDIUM–HIGH for that hardware (panel brightness unusable). Matches the hardware-quirk exception.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: high for this 2022 Rembrandt+NVIDIA laptop — restores brightness without a cmdline workaround.
- Risk: very low — 8-line DMI entry, existing callback, DMI-gated.
- Ratio: strongly favorable.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real user-visible bug: no backlight on a shipping hybrid laptop.
- Mechanism exists in 6.12 (nvidia_wmi_ec detect + amdgpu skip + WMI probe failure).
- GPU (Radeon 680M / Yellow Carp) is supported here.
- 8-line DMI quirk using an existing helper; same pattern as quirks already on this branch.
- Applies cleanly.
- ACPI maintainer applied v1 with no objections; Hans de Goede CCed.
- Hardware quirk is an explicit stable exception.
AGAINST:
- No Fixes:/Cc: stable (expected; not a negative).
- One reporter (the author).
- Does not fix a crash/UAF; only brightness on one model.
UNRESOLVED:
- Could not read lore.kernel.org/stable (403). Does not change the technical case.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — existing callback; author confirmed acpi_backlight=native; maintainer applied.
2. Fixes a real bug that affects users? PASS — brightness keys/slider dead on this model.
3. Important issue? PASS — hardware quirk restoring essential display brightness (stable exception).
4. Small and contained? PASS — +8 lines, one DMI entry.
5. No new features or APIs? PASS.
6. Can apply to the local tree? PASS — matching context in this 6.12 tree.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Hardware quirk/workaround (DMI native-backlight override for broken NVIDIA WMI EC advertisement). Qualifies.
Step 9.4: MAKE YOUR DECISION
Backport to this 6.12.111 tree. The bug, the skip path, and the GPU support are all here; the fix is the standard low-risk DMI quirk.
Verification:
- [Phase 1] Parsed tags: author SOB, Rafael SOB, msgid.link; no Fixes:/Reported-by/Cc: stable
- [Phase 1] Body: nvidia_wmi_ec selected, WMI probe AE_NOT_FOUND, amdgpu skips, no backlight device
- [Phase 2] Diff: +8 lines in video_detect_dmi_table[], video_detect_force_native for Acer / Nitro AN515-46
- [Phase 2] Precedence verified: DMI return at video_detect.c:1037-1038 is before nvidia_wmi_ec at 1044-1045
- [Phase 3] git merge-base --is-ancestor 525ba51157ac6 HEAD → not in this tree (candidate)
- [Phase 3] fe7aebb40d42b (nvidia_wmi_ec detect) is ancestor of HEAD; contained in v6.1-rc1
- [Phase 3] da11ef832972e (amdgpu skip native) is ancestor of HEAD; contained in v6.1-rc1
- [Phase 3] Similar quirks already here: HP OMEN 16, Lenovo 82K8, Dell G15 5515
- [Phase 4] b4 dig -c 525ba51157ac6: https://patch.msgid.link/20260727
[email protected]
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: Rafael, Len Brown, Hans de Goede, linux-acpi
- [Phase 4] mbox: Rafael "Applied as 7.3 material, thanks!" — no NAK
- [Phase 4] UNVERIFIED: stable@ lore search (HTTP 403)
- [Phase 5] amdgpu skip: amdgpu_dm.c:4843 if (!acpi_video_backlight_use_native())
- [Phase 5] WMI error string matches commit: nvidia-wmi-ec- backlight.c:52 "EC backlight control failed: %s"
- [Phase 5] Callers of acpi_video_backlight_use_native(): amdgpu, i915, nouveau, radeon, gma500
- [Phase 6] git describe HEAD / make kernelversion: pending-6.12, 6.12.111
- [Phase 6] Enum includes acpi_backlight_nvidia_wmi_ec; nvidia-wmi- ec-backlight.c exists
- [Phase 6] Rembrandt 680M IDs present: 0x1681 CHIP_YELLOW_CARP in amdgpu_drv.c
- [Phase 6] No "Nitro AN515-46" in this tree; HP OMEN + android-tablet context matches the hunk
- [Phase 8] Failure mode: no backlight device on this DMI model, not a kernel oops
- Note: an earlier probe of this workspace showed pending-5.10; the checkout used for the verdict is pending-6.12 / 6.12.111 as required
The patch is a small DMI quirk, the failure is real on this 6.12 tree, and regression risk is limited to one product string.
**YES**
drivers/acpi/video_detect.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/acpi/video_detect.c +8 -0
@@ -917,6 +917,14 @@ static const struct dmi_system_id video_detect_dmi_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "OMEN by HP Gaming Laptop 16-n0xxx"), }, }, + { + .callback = video_detect_force_native, + /* Acer Nitro AN515-46 */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Acer"), + DMI_MATCH(DMI_PRODUCT_NAME, "Nitro AN515-46"), + }, + },/* * x86 android tablets which directly control the backlight through
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 PCI: Avoid saving config space state if inaccessible
In reply to Sasha LevinFrom: Farhan Ali <[email protected]>
[ Upstream commit e18d1abc3bff0a24a5299f3c150ab9546e9439aa ]
The current reset process saves the device's config space state before reset and restores it afterward. However errors may occur unexpectedly and it may then be impossible to save config space because the device may be inaccessible (e.g. DPC). This results in saving invalid values that get written back to the device during state restoration.
With a reset we want to recover/restore the device into a functional state. So avoid saving the state of the config space when the device config space is inaccessible.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111**. The buggy reset-time save path is present here; this is a small, self-contained PCI error-recovery fix for that path.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[PCI]** **[Avoid]** Avoid saving config space state if inaccessible. “Avoid” here is a bug-fix verb: skip a save that would capture invalid ~0 values.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Farhan Ali \<[email protected]\> (author)
- Signed-off-by: Bjorn Helgaas \<[email protected]\> (PCI maintainer; also [bhelgaas: comment])
- Reviewed-by: Niklas Schnelle \<[email protected]\>
- Reviewed-by: Bjorn Helgaas \<[email protected]\>
- Link:
https://patch.msgid.link/[email protected]
- No Fixes:, Reported-by:, Tested-by:, or Cc: stable (absence expected for this review)
- Ignore pipeline markers (none in the provided message except the evaluation context)
Notable: PCI maintainer both reviewed and applied it. The msgid is **v23 3/5** of “Error recovery for vfio-pci devices on s390x” (cover is -1, so -4 is patch 3/5).
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** Reset saves config space, then restores it. If the device is inaccessible (example given: DPC), reads return ~0. Those invalid values are saved and later written back.
- **Symptom:** After reset/error recovery the device is programmed with garbage (invalid BARs / Command register), so it does not come back functional.
- **Root cause:** Unconditional pci_save_state() in the reset path while config space may already be gone.
- **Fix:** Do not save (or disable via Command) when config space is inaccessible.
- **Versions:** None stated; DPC/AER reset is long-standing.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. This is an explicit correctness fix for invalid save/restore during error recovery.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/pci/pci.c only (~+24 lines, 0 removed)
- New helper: pci_dev_config_accessible()
- Modified: pci_dev_save_and_disable()
- Scope: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Helper:** Read dword at PCI_COMMAND (Command + Status). If PCI_POSSIBLE_ERROR(val) (== ~0), warn and return false. Uses Command/Status rather than Vendor/Device ID because VFs can legitimately read as ~0 there.
- **pci_dev_save_and_disable before:** After pci_set_power_state(D0), always pci_save_state() then write PCI_COMMAND_INTX_DISABLE.
- **After:** If config is inaccessible, return without saving or writing Command. reset_prepare and D0 wake still run.
- Path: reset / error-recovery, not probe or normal PM suspend.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Logic / correctness** in error recovery.
- Broken: inaccessible config → pci_save_state() fills saved_config_space[] with ~0 and sets state_saved. pci_restore_state() later writes that back (BARs 0xFFFFFFFF, Command 0xFFFF).
- Fix: skip that overwrite so restore uses the last good snapshot (enumeration-time save in this tree, or a driver’s later pci_save_state()).
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: same PCI_POSSIBLE_ERROR heuristic already used across PCI.
- Minimal: one check, no API change.
- Residual race is documented (device can disappear between check and save); that is pre-existing, not introduced.
- False positive (Command|Status actually 0xFFFFFFFF on a live device) is vanishingly unlikely; Status reserved bits typically read 0.
- Skipping the Command disable when inaccessible is a no-op: that write would not land anyway.
- Regression risk: **low**. Healthy reset path is unchanged.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Unconditional pci_save_state() in pci_dev_save_and_disable() comes from Alex Williamson, 2013 (77cb985ad4acbe / a6cbaadea0af9).
- Function itself dates to Keith Busch 2014 / Christoph Hellwig 2017.
- Bug is old; it became more important after enumeration-time save + always-restore.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Related in-tree commit **58130e7ce6cb6** (PCI/ERR: Ensure error recoverability at all times, upstream a2f1e22390ac) is an ancestor of HEAD. It:
- Calls pci_save_state() at device add (drivers/pci/bus.c)
- Removes the if (!dev->state_saved) return; in pci_restore_state()
Verified in this checkout: pci_save_state(dev) at pci_bus_add_device() (placement later adjusted by f8f55a226aab4). Restore no longer bails on state_saved. So a garbage reset-time save **will** be restored. This patch is what keeps that snapshot valid when DPC has already isolated the device.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Same series, already in this tree: **1872805e97043** `PCI/MSI:
Enable memory decoding before restoring MSI-X messages (v23 5/5, Cc:
stable`).
- Not in this tree: v23 1/5 slot placeholder, 2/5 s390 per-function slots, **this 3/5**, 4/5 “Fail FLR when config space inaccessible”.
- Recent pci.c churn is unrelated (D3hot wait, ASPM, ACS, slot locking).
This patch is **standalone**. 1/5 and 2/5 are s390 slot work. 4/5 *uses* pci_dev_config_accessible() but is not required for the save-garbage fix. 5/5 already landed independently.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Farhan Ali (IBM) works on s390 PCI / vfio. In this tree the related MSI-X restore fix is already present. Helgaas (subsystem maintainer) reviewed and applied.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Record:
- Needs PCI_POSSIBLE_ERROR — present in include/linux/pci.h.
- Needs pci_find_dvsec_capability only as an insertion landmark — present at drivers/pci/pci.c:762.
- Needs pci_dev_save_and_disable / pci_save_state — present.
- device_lock_assert / pci_warn(..., "resetting") in the *upstream context* are **not** in 6.12; they are context-only, not part of this change. Insertion is after pci_set_power_state(dev, PCI_D0), which matches this tree.
- Can apply standalone: **yes**.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 5e14afc4aa192 failed (that string is a **blob** hash from the candidate diff, not a commit).
- b4 mbox on msgid [email protected]:
23-message thread saved.
- Lore/cover: v23 0/5 “Error recovery for vfio-pci devices on s390x”; this is **3/5**.
- Earlier revisions (v9) tried to **never** save at reset (rely only on enumeration save). Reviewers (Helgaas / Alex Williamson) rejected that because normal resets must capture current driver-programmed state. v22/v23 compromise: skip save **only** when config reads as ~0.
- Helgaas rewrote the comment on apply ([bhelgaas: comment]). Functional code matches v23.
- Sashiko: low const char *msg nit only. No NAK on this patch.
- No reviewer asked for Cc: stable on **this** patch (unlike 2/5 and 5/5). That is not a negative for this evaluation.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: linux-pci via Helgaas; Niklas Schnelle (s390 PCI). Right maintainers.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla. Motivated by s390 vfio-pci DPC/error recovery (IBM). Mechanism is generic for any AER/DPC isolation, not s390-only.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: v23 1–5 as above. 4/5 adds the same helper use in pcie_flr(); Helgaas was lukewarm on that racy FLR-only check but still merged this save-path patch. 5/5 already in 6.12.111.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable WebFetch returned 403. **UNVERIFIED** whether stable@ discussed this exact subject. 5/5 from the same series *was* explicitly Cc: stable and is already here.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: pci_dev_config_accessible() (new),pci_dev_save_and_disable() (modified).
**Step 5.2: TRACE CALLERS**
Record: pci_dev_save_and_disable() is static; callers in this tree:
- pci_reset_function() — sysfs/EXPORT function reset
- pci_reset_function_locked()
- pci_try_reset_function()
- pci_bus_save_and_disable_locked() ← __pci_reset_bus()
- pci_slot_save_and_disable_locked() ← __pci_reset_slot()
AER uses pci_bus_error_reset() → slot reset or bus reset, which save/disable then restore. Userspace can also hit this via /sys/bus/pci/devices/.../reset.
**Step 5.3: TRACE CALLEES**
Record: pci_read_config_dword, PCI_POSSIBLE_ERROR, pci_warn; then existing pci_save_state / Command write.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: User-reachable via sysfs reset and via AER/DPC error IRQs. DPC is the cited case: config reads ~0 while containment is active, then reset+restore. **Yes, reachable.**
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: PCI_POSSIBLE_ERROR already used in pci.c PM paths, DPC, probe, hotplug. 4/5 of this series reuses the new helper for FLR; not in this tree yet and not required for this verdict.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** pci_dev_save_and_disable() at drivers/pci/pci.c:5047 still does unconditional pci_save_state() after D0. pci_dev_config_accessible() does **not** exist. make kernelversion / Makefile: **6.12.111**. Bug introduced with 2013 reset save/disable; still here.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply / trivial context.** Helper can sit after existing pci_find_dvsec_capability(). The three-line guard goes after pci_set_power_state(dev, PCI_D0) before pci_save_state(dev) — identical here. Upstream context lines (device_lock_assert, "resetting" warn) are later mainline-only and are not part of this patch.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: Enumeration save + always-restore (**58130e7ce6cb6**) is here; without this patch it can restore **poisoned** ~0 state after DPC. MSI-X Memory-enable restore (**1872805e97043**) is here. No substitute for this skip-save check.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **PCI core** (drivers/pci/pci.c). **IMPORTANT** (all PCI devices; error recovery and function reset). Not staging.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature core with ongoing AER/DPC/reset work. This is a targeted recovery fix, not a refactor.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: PCI error recovery (AER/DPC) and anyone resetting a device whose config is gone. Originally s390 vfio-pci passthrough; same path is generic. Config-specific: PCI + AER/DPC/reset users (common on servers).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: DPC/containment or other inaccessible config during reset. Not every boot; when it hits, recovery is the path that should restore the device. Unprivileged users can trigger sysfs reset only with privilege; AER/DPC is hardware-driven.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Restore of ~0 → invalid BARs, Command all-ones (I/O, MMIO, bus master, SERR). Device stays broken after “recovery”; possible further URs / bad DMA. **Severity: HIGH** (failed recovery, device unusable; bus-master with junk BARs is worse than a leak).
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit: HIGH** — preserves last good config through DPC/reset; completes recoverability that 58130e7ce6cb6 already shipped in this tree.
- **Risk: LOW** — ~24 lines, established heuristic, healthy devices unchanged.
- **Ratio:** strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real bug: save/restore of ~0 config during inaccessible reset (DPC).
- Failure is failed PCI recovery and a device left misprogrammed.
- Small, obviously correct, reviewed by Helgaas and Schnelle.
- Buggy code and insertion points exist in 6.12.111.
- Enumeration-time save already in this tree; this patch prevents clobbering it.
- Same series’ 5/5 already backported here.
- Standalone vs s390 slot patches.
AGAINST:
- No Cc: stable / Fixes: on this commit (expected; not a veto).
- Trigger is error recovery, not the hot path.
- Check is racy (documented); Helgaas still merged it.
- 4/5 (fail FLR) not included; incomplete vs full series, but this hunk still fixes the save-poisoning bug on its own.
UNRESOLVED:
- Stable-list thread 403; could not confirm prior stable@ discussion.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — Helgaas+Schnelle Reviewed- by; heuristic already in-tree.
2. Fixes a real bug that affects users? **PASS** — DPC/error recovery restores garbage config.
3. Important issue? **PASS** — HIGH: recovery failure / device left with invalid BARs and Command.
4. Small and contained? **PASS** — one file, ~24 lines.
5. No new features or APIs? **PASS** — static helper + guard.
6. Can apply to the local tree? **PASS** — same functions and insertion point in 6.12.111.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not an ID/quirk/DT/build/docs exception. Ordinary important bug fix.
**Step 9.4: MAKE YOUR DECISION**
Backport. It prevents writing invalid ~0 config back after reset when the device is already inaccessible, which is exactly the DPC/AER recovery case this 6.12 tree already tries to support via enumeration- time save.
------------------------------------------------
What the commit solves for this tree
------------------------------------------------
On 6.12.111, reset still always calls pci_save_state() in pci_dev_save_and_disable(). If config reads as ~0 (DPC), that poisons saved_config_space. pci_restore_state() no longer refuses restore (58130e7ce6cb6), so those values get programmed back. Skipping the save keeps the enumeration (or last good) snapshot.
Risk vs benefit: low risk, high benefit. No new API. Apply is clean aside from unrelated later context around device_lock_assert.
------------------------------------------------
Verification
------------------------------------------------
- [Phase 1] Subject/tags parsed from the candidate message; Link msgid is v23 3/5.
- [Phase 2] Diff: helper + 3-line guard in pci_dev_save_and_disable; pci_save_state() in this tree writes saved_config_space[] and sets state_saved with no accessibility check.
- [Phase 3] git describe / make kernelversion: p-6.12-3 / **6.12.111**.
- [Phase 3] git blame -L 5047,5076 drivers/pci/pci.c: unconditional save from 2013 Williamson commits.
- [Phase 3] git merge-base --is-ancestor 58130e7ce6cb6 HEAD: yes; enumeration save + restore-always.
- [Phase 3] git merge-base --is-ancestor 1872805e97043 HEAD: yes; series 5/5 already here.
- [Phase 3] git log --grep='Avoid saving config' on drivers/pci/:
this fix **not** present.
- [Phase 4] b4 mbox msgid 20260805165518.794-4: 23 msgs; Helgaas Reviewed-by; no NAK on 3/5.
- [Phase 4] Cover letter: PCI slice of vfio-pci s390 error recovery; v9 “never save at reset” was rejected.
- [Phase 4] lore.kernel.org/stable: **UNVERIFIED** (HTTP 403).
- [Phase 5] Callers of pci_dev_save_and_disable traced in pci.c; AER pci_bus_error_reset → slot/bus reset save/restore.
- [Phase 6] pci_find_dvsec_capability at line 762; PCI_POSSIBLE_ERROR in include/linux/pci.h; PCI_COMMAND is 0x04.
- [Phase 6] pcie_flr() in this tree has no accessibility check (4/5 not required for this verdict).
- UNVERIFIED: whether Command+Status can be legitimate 0xFFFFFFFF on some broken device (kernel-wide heuristic already accepts that risk).
**YES**
drivers/pci/pci.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/pci/pci.c +25 -0
@@ -725,6 +725,28 @@ u16 pci_find_dvsec_capability(struct pci_dev *dev, u16 vendor, u16 dvsec) }EXPORT_SYMBOL_GPL (pci_find_dvsec_capability); +static bool pci_dev_config_accessible (struct pci_dev *dev,char *msg) +{ +u32 val; + +/* +* If a device's config space is inaccessible, reads typically +* return ~0. Since Device and Vendor ID are always ~0 for VFs, +* check the Command and Status registers instead. +* +* N.B. This is racy because the device may become inaccessible +* before the next access. +*/ +pci_read_config_dword (dev,PCI_COMMAND , &val); +if (PCI_POSSIBLE_ERROR (val)) { +pci_warn (dev,"Device config space inaccessible; unable to %s\n" , + msg); +return false; + } + +return true; +} +/** * pci_find_parent_resource - return resource region of parent bus of given * region
@@ -5009,6 +5031,9 @@ static void pci_dev_save_and_disable(struct pci_dev *dev)*/ pci_set_power_state (dev,PCI_D0 ); +if (!pci_dev_config_accessible (dev,"save state" )) +return ; +pci_save_state (dev);/* * Disable the device by clearing the Command register, except for
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-6.1] PCI: Avoid saving config space state if inaccessible
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] pci: skipping pci_save_state() in pci_dev_save_and_disable() breaks restore --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] pci: skipping pci_save_state() in pci_dev_save_and_disable() breaks restore --
commit 4874b436f59a1ea615f5afac75821d16d1d67918
Author: Farhan Ali <[email protected]>
PCI: Avoid saving config space state if inaccessible
This commit adds a helper to check whether PCI config space is accessible before saving state during device reset, skipping pci_save_state() when reads return an error response.
Quoted 4 lines
drivers/pci/pci.c +0
-0
[ ... ]
drivers/pci/pci.c static void pci_dev_save_and_disable(struct pci_dev *dev) · line 5157
Quoted 10 lines
drivers/pci/pci.c +3
-0@@ -5127,6 +5149,9 @@ static void pci_dev_save_and_disable(struct pci_dev *dev)*/ pci_set_power_state (dev,PCI_D0 ); +if (!pci_dev_config_accessible (dev,"save state" )) +return ; +pci_save_state (dev);/* * Disable the device by clearing the Command register, except for
[Severity: High]
Does skipping pci_save_state() in pci_dev_save_and_disable() prevent pci_dev_restore() -> pci_restore_state() from restoring config space after the reset completes?
Upstream commit e18d1abc3bff0a24a5299f3c150ab9546e9439aa relies on prerequisite commit a2f1e22390ac ("PCI/ERR: Ensure error recoverability at all times"), which added pci_save_state(dev) to pci_bus_add_device() during enumeration and removed the dev->state_saved check from pci_restore_state().
In this tree, commit a2f1e22390ac is not present. In drivers/pci/probe.c, pci_device_add() initializes dev->state_saved = false, and in drivers/pci/bus.c, pci_bus_add_device() does not call pci_save_state(dev):
drivers/pci/probe.c:pci_device_add() {
...
dev->state_saved = false;
pci_init_capabilities(dev);
...
}Furthermore, in drivers/pci/pci.c, pci_restore_state() still checks dev->state_saved at entry and clears it on every restore:
drivers/pci/pci.c:pci_restore_state() {
if (!dev->state_saved)
return;
...
dev->state_saved = false;
}When config space is inaccessible prior to a reset (such as during DPC containment or link-down error recovery via pci_reset_function(), pci_reset_function_locked(), pci_try_reset_function(), __pci_reset_bus(), or __pci_reset_slot()) and dev->state_saved is false — either because no driver saved state at probe or because a prior reset or PM transition (such as vfio_pci_ioctl_reset(), pci_reset_bus(), vfio_pci_set_power_state(), or pci_pm_runtime_resume()) already called pci_restore_state() and cleared dev->state_saved = false — returning early in pci_dev_save_and_disable() leaves dev->state_saved as false.
When the reset finishes and pci_dev_restore() calls pci_restore_state(dev):
drivers/pci/pci.c:pci_dev_restore() {
const struct pci_error_handlers *err_handler =
dev->driver ? dev->driver->err_handler : NULL;
pci_restore_state(dev);
...
}won't pci_restore_state() bail out immediately without restoring BARs, PCI_COMMAND, MSI/MSI-X, or PCIe capabilities, leaving the device at its unconfigured post-reset register defaults?
Should prerequisite commit a2f1e22390ac ("PCI/ERR: Ensure error recoverability at all times") be backported along with this change?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 drm/amd/pm: Validate Tonga PPTable subtable bounds
In reply to Sasha LevinFrom: Yang Wang <[email protected]>
[ Upstream commit 53ef33c084c5778cc2dcd1efff25e31b6e231141 ]
v1:
Tonga PPTable parsing also relies on VBIOS offsets, revision fields and entry counts for several subtables. Malformed data can cause out-of-bounds reads, while voltage lookup tables can overrun their fixed-size destination arrays.
Add common bounds helpers and validate fixed subtables, dynamic entry arrays and revision-specific layouts before consuming voltage lookup, dependency, PCIE, power-tune, hard-limit, thermal, fan, GPIO, PPM and VCE state data.
v2:
correct to handle get_tonga_ppm_table() return value.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
- Record: [drm/amd/pm] [Validate] Tonga PPTable subtable bounds
**Step 1.2 — Tags**
- Record: Reviewed-by: Asad Kamal <[email protected]>; `Reviewed-by:
Kenneth Feng <[email protected]>; Signed-off-by: Yang Wang <[email protected]>; Signed-off-by: Alex Deucher <[email protected]>`.
- No Fixes:, Reported-by, Tested-by, Link:, or Cc: stable (absence is expected).
- Pipeline markers ([Upstream commit …], Signed-off-by: Sasha Levin) ignored.
**Step 1.3 — Body**
- Record: Tonga PPTable parsing trusts VBIOS offsets, revision IDs, and entry counts. Malformed data can cause out-of-bounds reads; voltage lookup tables can overrun fixed-size destination arrays.
- Symptom: kernel OOB read/write while parsing PowerPlay tables at init or after a pp_table upload.
- Root cause: pointer = powerplay_table + le16_to_cpu(offset) with no check against soft_pp_table_size, plus ucNumEntries used past allocated destination size.
- v2 only corrects get_tonga_ppm_table() return handling.
**Step 1.4 — Hidden bug fix?**
- Record: Not hidden. Explicit bounds-check fix for OOB reads and destination-array overrun.
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
- Record: One file, drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c.
Upstream: **+521 / −85**.
- New helpers: tonga_pp_table_has_space, get_tonga_subtable, validate_tonga_table_entries, plus getters for voltage lookup, MCLK/MM/SCLK/PCIE/hard-limit/thermal/fan/power-tune/PPM/GPIO/VCE.
- Callers updated: init_dpm_2_parameters, init_clock_voltage_dependency, init_thermal_controller, ppt_get_num_of_vce_state_table_entries_v1_0, ppt_get_vce_state_table_entry_v1_0.
- Scope: single-file parser hardening, not a cross-subsystem refactor.
**Step 2.2 — Flow change**
- Record: Before, every subtable pointer was powerplay_table + offset with no size check. After, each access goes through helpers that require a non-zero offset, that the header fits, and that entries_offset + num_entries * entry_size fits in soft_pp_table_size.
- Voltage lookup: ucNumEntries must be in (0, max_levels] (16) before get_vddc_lookup_table().
- GPIO: previously gpio_table was always a non-NULL computed pointer, so get_gpio_table() ran even when usGPIOTableOffset == 0. After, that path runs only if the offset is non-zero.
- VCE: SCLK records are indexed as Tonga vs Polaris by ucRevId; SCLK/MM/MCLK indices are range-checked.
**Step 2.3 — Bug mechanism**
- Record: **Memory safety (OOB read + heap OOB write)**, plus a Polaris VCE layout correctness bug.
- Verified on this tree’s pre-fix get_vddc_lookup_table() (v6.18.53):
``` table = kzalloc(struct_size(table, entries, max_levels), GFP_KERNEL); table->count = vddc_lookup_pp_tables->ucNumEntries; for (i = 0; i < vddc_lookup_pp_tables->ucNumEntries; i++) ```
Allocation uses max_levels (16); the loop uses raw ucNumEntries
(u8, up to 255). That is a real heap overflow.
- Subtable offsets/counts can also walk past soft_pp_table_size (VBIOS blob or uploaded table).
**Step 2.4 — Fix quality**
- Record: Helpers are overflow-safe (offset <= table_size && size <= table_size - offset). PP_ASSERT_WITH_CODE always runs the failure return (not debug-only). Leaf parsers already rejected ucNumEntries == 0, so that check is not a new behavior cliff.
- Regression risk: low–medium. Over-strict revision-based fan/power-tune sizes could reject a corrupt-but-previously-parsed table. No public API change. Patch is large because every subtable is wrapped, not because control flow is redesigned.
## Phase 3: Git history
**Step 3.1 — Blame / introduction**
- Record: Parser has been here since the Tonga PowerPlay path (processpptable_v1_0, later moved in e098bc9612c2b, 2020). Unbounded offset arithmetic is old, not a recent regression.
**Step 3.2 — Fixes: tag**
- Record: None. Not applicable.
**Step 3.3 — Related file history**
- Record: Same-day AMD series:
- 1ac24df78c566 — Tonga state-array bounds
- 3a8d8e0b7f61c — Vega hwmgr bounds
- 0ceb6bc43e62f — legacy hwmgr offsets
- 9914149f99fd2 — Vega10 subtable bounds
- 53ef33c084c57 — this commit
- Standalone for this file. State-array helpers (get_tonga_state_array) are a sibling, not a call-graph dependency of these new getters.
**Step 3.4 — Author**
- Record: Yang Wang (AMD). Same author as the rest of this PPTable validation series. Merged by Alex Deucher.
**Step 3.5 — Prerequisites**
- Record: No new APIs. Upstream context uses kzalloc_obj(*ptr) in an unchanged hunk; v6.18.53 still has kzalloc(sizeof(*ptr), GFP_KERNEL) in that function. That is a trivial context tweak, not a functional dependency. Vega10/legacy patches in the same series touch other files and are not required for this one.
## Phase 4: Mailing list / external
**Step 4.1 — Original submission**
- Record: b4 dig -c 53ef33c084c5778cc2dcd1efff25e31b6e231141 → [PATCH v2 2/3] drm/amd/pm: Validate Tonga PPTable subtable bounds
https://patch.msgid.link/20260623134917.443011-2-
[email protected]
- v1 → v2; v2 is what landed. v2 changelog: handle get_tonga_ppm_table() return value.
- No NAKs in the saved thread.
**Step 4.2 — Reviewers**
- Record: To/Cc: amd-gfx, Alex Deucher, Hawking Zhang, Kenneth Feng, Asad Kamal.
- Asad: “Series is Reviewed-by”. Kenneth Feng: same. Maintainer SOB from Alex Deucher.
**Step 4.3 — Bug report**
- Record: No syzbot/bugzilla/CVE in the message or thread. Bug is described from code inspection of the parser.
**Step 4.4 — Series**
- Record: v2 1/3 Vega10 subtables; **2/3 this patch**; 3/3 remaining legacy PPLIB. This patch is self-contained.
**Step 4.5 — stable@**
- Record: lore.kernel.org HTTP 403 from WebFetch/curl. b4 dig mbox has no Cc: stable and no stable-list discussion. UNVERIFIED vs lore.kernel.org/stable search.
## Phase 5: Semantic / call graph
**Step 5.1 — Functions**
- Record: New tonga_pp_table_has_space / get_tonga_* / validate_tonga_table_entries; callers listed in 2.1.
**Step 5.2 — Callers**
- Record: pptable_v1_0_funcs.pptable_init → pp_tables_v1_0_initialize → init_thermal_controller / init_clock_voltage_dependency / init_dpm_2_parameters. Wired from smu7_init_function_pointers() when pp_table_version == PP_TABLE_V1.
- VCE getters run when userspace/KFD queries VCE states.
**Step 5.3 — Callees**
- Record: Existing leaf parsers (get_vddc_lookup_table, get_mclk_voltage_dependency_table, get_cac_tdp_table, …). No new allocations in the helpers.
**Step 5.4 — Reachability**
- Record: Yes. Driver load on Tonga/Fiji/Polaris/VegaM. Also pp_dpm_set_pp_table() after a sysfs write to pp_table (S_IRUGO | S_IWUSR, owner-writable; typically root).
**Step 5.5 — Similar patterns**
- Record: Same pattern as Vega10/legacy PPLIB validation in the same series; same class as earlier Tonga state-array bounds.
## Phase 6: This tree (6.18.y)
**Step 6.1 — Does the bug exist here?**
- Record: Local tree is **v6.18.53** (6.18.53, branch autosel). Vanilla v6.18.53 still has unbounded offset arithmetic and the voltage-lookup heap overflow. Bug was not introduced after this branch.
**Step 6.2 — Backport difficulty**
- Record: **Minor conflicts**. git apply --check of upstream onto v6.18.53 fails on kzalloc_obj vs kzalloc context in get_platform_power_management_table(). Logic applies with that mechanical adjustment. No missing types/helpers required by the new code (soft_pp_table_size is already set in get_powerplay_table()).
**Step 6.3 — Related fixes already here?**
- Record: v6.18.53 does **not** have this validation, pp_entries_max clamping in this file, or the Tonga state-array bounds commit. No alternate fix for the voltage-lookup overflow is present on vanilla 6.18.53.
## Phase 7: Subsystem
**Step 7.1**
- Record: drm/amd/pm PowerPlay v1 parser. **IMPORTANT** (not core mm/VFS; Polar/Tonga/Fiji/VegaM still common, especially RX 400/500).
**Step 7.2**
- Record: Mature parser; recent work is bounds hardening, not feature churn.
## Phase 8: Impact and risk
**Step 8.1 — Who is affected**
- Record: AMDGPU SMU7 with PP table v1: Tonga, Fiji, Polaris10/11/12, VegaM (hwmgr.c keeps default PP_TABLE_V1 for those chips).
**Step 8.2 — Trigger**
- Record: GPU init (every boot with those ASICs) if VBIOS is truncated/corrupt. Also root write to pp_table. Unprivileged users cannot write that sysfs node under normal permissions.
**Step 8.3 — Failure mode**
- Record: Heap overflow in voltage lookup (**CRITICAL** if triggered). OOB reads of BIOS/uploaded buffer (**HIGH**). Wrong Polaris VCE SCLK stride (**MEDIUM** functional). Malformed table now fails init instead of walking off the end.
**Step 8.4 — Risk/benefit**
- Record: Benefit high for Polar/Tonga users and for pp_table upload.
Risk: large-ish one-file change; conservative rejects of garbage tables. Ratio favors backport: the overflow is real and the helpers are local.
## Phase 9: Synthesis
**For**
- Confirmed heap overflow: kzalloc(..., max_levels) vs loop on ucNumEntries.
- Confirmed OOB reads from unchecked VBIOS/upload offsets.
- Reachable on driver init and via pp_table.
- Polaris VCE record-size bug also fixed.
- Reviewed by AMD PM; merged by the DRM AMD maintainer.
- One file; no new UAPI; v2 already fixed PPM error handling.
- Buggy code is in this 6.18.y tree.
**Against**
- +521 lines is large for stable.
- No public crash/CVE/syzbot report.
- Needs a small kzalloc context tweak vs upstream.
- Sibling series patches are separate (not blockers).
**Unresolved**
- Could not query lore.kernel.org/stable (HTTP 403). No stable discussion in the b4 mbox.
**Stable rules**
1. Obviously correct and tested? **PASS** — overflow-safe helpers; AMD review; v2 PPM fix.
2. Real user-visible bug? **PASS** — OOB on Tonga/Polaris PPTable parse / pp_table upload.
3. Important (crash/security/corruption)? **PASS** — heap overflow + OOB read.
4. Small and contained? **PASS** (borderline on size, **contained**: one parser file, no architecture change).
5. No new features/APIs? **PASS**.
6. Can apply here? **PASS** with minor kzalloc_obj context adjustment.
**Exception category:** none (not a device-ID/quirk/DT/docs/build-only change). It is a memory-safety fix.
This is a real bounds-check for a long-lived AMD PowerPlay parser that this 6.18.y tree still ships. Size is the only serious stable concern; the overflow and OOB are concrete enough that omitting it would be the worse mistake.
### Verification
- [Phase 1] Parsed tags: Reviewed-by Asad Kamal and Kenneth Feng; Alex Deucher SOB; no Fixes/syzbot/Cc stable.
- [Phase 2] Diff: +521/−85 in process_pptables_v1_0.c; helpers + caller validation.
- [Phase 2] v6.18.53 get_vddc_lookup_table: allocates max_levels, iterates ucNumEntries — heap overflow confirmed.
- [Phase 2] PP_ASSERT_WITH_CODE in pp_debug.h always executes the failure code.
- [Phase 3] No Fixes tag. Parser present since Tonga PowerPlay v1; file moved in e098bc9612c2b.
- [Phase 3] Series: 1/3 Vega10, 2/3 this, 3/3 legacy PPLIB; this file does not need 1/3 or 3/3.
- [Phase 4] b4 dig -c 53ef33c084c5778: lore msgid 20260623134917.443011-2; v2 of 2/3.
- [Phase 4] mbox: Asad and Kenneth “Series is Reviewed-by”; no NAK; v2 PPM return handling.
- [Phase 4] WebFetch/curl to lore.kernel.org: 403. UNVERIFIED: stable@ archives.
- [Phase 5] pptable_v1_0_funcs used from smu7_init_function_pointers for PP_TABLE_V1.
- [Phase 5] pp_table sysfs: AMDGPU_DEVICE_ATTR_RW(..., S_IRUGO | S_IWUSR); pp_dpm_set_pp_table() replaces soft_pp_table and re- inits.
- [Phase 6] git describe HEAD: v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion: 6.18.53.
- [Phase 6] git merge-base --is-ancestor 53ef33c084c5778 HEAD → not ancestor (upstream SHA not in this history).
- [Phase 6] Apply onto v6.18.53: fails on kzalloc_obj context; functional backport is still straightforward.
- [Phase 6] pp_entries_max not in v6.18.53; this commit is the voltage-lookup cap for this tree.
- [Phase 7/8] hwmgr.c: Tonga/Fiji/Polaris10/11/12/VegaM keep PP_TABLE_V1 and call smu7_init_function_pointers().
- [Phase 8] Failure mode: heap overflow / OOB read on PPTable parse — HIGH/CRITICAL if triggered.
**YES**
.../powerplay/hwmgr/process_pptables_v1_0.c | 606 +++++++++++++++--- 1 file changed, 521 insertions(+), 85 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c +521 -85
@@ -150,6 +150,368 @@ static const void *get_powerplay_table(struct pp_hwmgr *hwmgr)return table_address; } +static bool tonga_pp_table_has_space (struct pp_hwmgr *hwmgr,size_t offset, +size_t size) +{ +size_t table_size = hwmgr->soft_pp_table_size; + +return offset <= table_size && size <= table_size - offset; +} + +static int get_tonga_subtable (struct pp_hwmgr *hwmgr, +const ATOM_Tonga_POWERPLAYTABLE *powerplay_table, +u16 table_offset,size_t table_size,const void **table) +{ +PP_ASSERT_WITH_CODE ((table_offset !=0 ), +"Invalid PowerPlay Table!" , return -1 ); +PP_ASSERT_WITH_CODE ((tonga_pp_table_has_space (hwmgr, table_offset, + table_size)), +"Invalid PowerPlay Table!" , return -1 ); + + *table = (const void *)(((unsigned long )powerplay_table) + table_offset); + +return 0 ; +} + +static int validate_tonga_table_entries (struct pp_hwmgr *hwmgr, +u16 table_offset,size_t entries_offset, +u8 num_entries,size_t entry_size) +{ +size_t table_size; + +PP_ASSERT_WITH_CODE ((num_entries !=0 ), +"Invalid PowerPlay Table!" , return -1 ); + + table_size = entries_offset + num_entries * entry_size; +PP_ASSERT_WITH_CODE ((tonga_pp_table_has_space (hwmgr, table_offset, + table_size)), +"Invalid PowerPlay Table!" , return -1 ); + +return 0 ; +} + +static int get_tonga_voltage_lookup_table (struct pp_hwmgr *hwmgr, +const ATOM_Tonga_POWERPLAYTABLE *powerplay_table, +u16 table_offset,uint32_t max_levels, +const ATOM_Tonga_Voltage_Lookup_Table **lookup_table) +{ +const ATOM_Tonga_Voltage_Lookup_Table *table; +size_t table_size; +int ret; + + ret =get_tonga_subtable (hwmgr, powerplay_table, table_offset, +sizeof (*table), (const void **)&table); +if (ret) +return ret; + +PP_ASSERT_WITH_CODE ((table->ucNumEntries !=0 && + table->ucNumEntries <= max_levels), +"Invalid PowerPlay Table!" , return -1 ); + + table_size = offsetof(ATOM_Tonga_Voltage_Lookup_Table , entries) + + table->ucNumEntries *sizeof (ATOM_Tonga_Voltage_Lookup_Record); +PP_ASSERT_WITH_CODE ((tonga_pp_table_has_space (hwmgr, table_offset, + table_size)), +"Invalid PowerPlay Table!" , return -1 ); + + *lookup_table = table; + +return 0 ; +} + +static int get_tonga_mclk_dependency_table (struct pp_hwmgr *hwmgr, +const ATOM_Tonga_POWERPLAYTABLE *powerplay_table, +const ATOM_Tonga_MCLK_Dependency_Table **mclk_dep_table) +{ +const ATOM_Tonga_MCLK_Dependency_Table *table; +u16 table_offset; +int ret; + + table_offset =le16_to_cpu (powerplay_table->usMclkDependencyTableOffset); + ret =get_tonga_subtable (hwmgr, powerplay_table, table_offset, +sizeof (*table), (const void **)&table); +if (ret) +return ret; + + ret =validate_tonga_table_entries (hwmgr, table_offset, + offsetof(ATOM_Tonga_MCLK_Dependency_Table , + entries), + table->ucNumEntries, +sizeof (ATOM_Tonga_MCLK_Dependency_Record)); +if (ret) +return ret; + + *mclk_dep_table = table; + +return 0 ; +} + +static int get_tonga_mm_dependency_table (struct pp_hwmgr *hwmgr, +const ATOM_Tonga_POWERPLAYTABLE *powerplay_table, +const ATOM_Tonga_MM_Dependency_Table **mm_dep_table) +{ +const ATOM_Tonga_MM_Dependency_Table *table; +u16 table_offset; +int ret; + + table_offset =le16_to_cpu (powerplay_table->usMMDependencyTableOffset); + ret =get_tonga_subtable (hwmgr, powerplay_table, table_offset, +sizeof (*table), (const void **)&table); +if (ret) +return ret; + + ret =validate_tonga_table_entries (hwmgr, table_offset, + offsetof(ATOM_Tonga_MM_Dependency_Table , + entries), + table->ucNumEntries, +sizeof (ATOM_Tonga_MM_Dependency_Record)); +if (ret) +return ret; + + *mm_dep_table = table; + +return 0 ; +} + +static int get_tonga_sclk_dependency_table (struct pp_hwmgr *hwmgr, +const ATOM_Tonga_POWERPLAYTABLE *powerplay_table, +const PPTable_Generic_SubTable_Header **sclk_dep_table) +{ +const PPTable_Generic_SubTable_Header *header; +u16 table_offset; +size_t entries_offset; +size_t entry_size; +u8 num_entries; +int ret; + + table_offset =le16_to_cpu (powerplay_table->usSclkDependencyTableOffset); + ret =get_tonga_subtable (hwmgr, powerplay_table, table_offset, +sizeof (*header), (const void **)&header); +if (ret) +return ret; + +if (header->ucRevId <1 ) { +const ATOM_Tonga_SCLK_Dependency_Table *table = + (const ATOM_Tonga_SCLK_Dependency_Table *)header; + + entries_offset = offsetof(ATOM_Tonga_SCLK_Dependency_Table , entries); + entry_size =sizeof (ATOM_Tonga_SCLK_Dependency_Record); + num_entries = table->ucNumEntries; + }else { +const ATOM_Polaris_SCLK_Dependency_Table *table = + (const ATOM_Polaris_SCLK_Dependency_Table *)header; + + entries_offset = offsetof(ATOM_Polaris_SCLK_Dependency_Table , entries); + entry_size =sizeof (ATOM_Polaris_SCLK_Dependency_Record); + num_entries = table->ucNumEntries; + } + + ret =validate_tonga_table_entries (hwmgr, table_offset, entries_offset, + num_entries, entry_size); +if (ret) +return ret; + + *sclk_dep_table = header; + +return 0 ; +} + +static int get_tonga_pcie_table (struct pp_hwmgr *hwmgr, +const ATOM_Tonga_POWERPLAYTABLE *powerplay_table, +const PPTable_Generic_SubTable_Header **pcie_table) +{ +const PPTable_Generic_SubTable_Header *header; +u16 table_offset; +size_t entries_offset; +size_t entry_size; +u8 num_entries; +int ret; + + table_offset =le16_to_cpu (powerplay_table->usPCIETableOffset); + ret =get_tonga_subtable (hwmgr, powerplay_table, table_offset, +sizeof (*header), (const void **)&header); +if (ret) +return ret; + +if (header->ucRevId <1 ) { +const ATOM_Tonga_PCIE_Table *table = + (const ATOM_Tonga_PCIE_Table *)header; + + entries_offset = offsetof(ATOM_Tonga_PCIE_Table , entries); + entry_size =sizeof (ATOM_Tonga_PCIE_Record); + num_entries = table->ucNumEntries; + }else { +const ATOM_Polaris10_PCIE_Table *table = + (const ATOM_Polaris10_PCIE_Table *)header; + + entries_offset = offsetof(ATOM_Polaris10_PCIE_Table , entries); + entry_size =sizeof (ATOM_Polaris10_PCIE_Record); + num_entries = table->ucNumEntries; + } + + ret =validate_tonga_table_entries (hwmgr, table_offset, entries_offset, + num_entries, entry_size); +if (ret) +return ret; + + *pcie_table = header; + +return 0 ; +} + +static int get_tonga_hard_limit_table (struct pp_hwmgr *hwmgr, +const ATOM_Tonga_POWERPLAYTABLE *powerplay_table, +const ATOM_Tonga_Hard_Limit_Table **hard_limit_table) +{ +const ATOM_Tonga_Hard_Limit_Table *table; +u16 table_offset; +int ret; + + table_offset =le16_to_cpu (powerplay_table->usHardLimitTableOffset); + ret =get_tonga_subtable (hwmgr, powerplay_table, table_offset, +sizeof (*table), (const void **)&table); +if (ret) +return ret; + + ret =validate_tonga_table_entries (hwmgr, table_offset, + offsetof(ATOM_Tonga_Hard_Limit_Table , + entries), + table->ucNumEntries, +sizeof (ATOM_Tonga_Hard_Limit_Record)); +if (ret) +return ret; + + *hard_limit_table = table; + +return 0 ; +} + +static int get_tonga_thermal_controller_table (struct pp_hwmgr *hwmgr, +const ATOM_Tonga_POWERPLAYTABLE *powerplay_table, +const ATOM_Tonga_Thermal_Controller **thermal_controller) +{ +u16 table_offset; + + table_offset =le16_to_cpu (powerplay_table->usThermalControllerOffset); + +return get_tonga_subtable (hwmgr, powerplay_table, table_offset, +sizeof (**thermal_controller), + (const void **)thermal_controller); +} + +static int get_tonga_fan_table (struct pp_hwmgr *hwmgr, +const ATOM_Tonga_POWERPLAYTABLE *powerplay_table, +const PPTable_Generic_SubTable_Header **fan_table) +{ +const PPTable_Generic_SubTable_Header *header; +u16 table_offset; +size_t table_size; +int ret; + + table_offset =le16_to_cpu (powerplay_table->usFanTableOffset); + ret =get_tonga_subtable (hwmgr, powerplay_table, table_offset, +sizeof (*header), (const void **)&header); +if (ret) +return ret; + +if (header->ucRevId <8 ) + table_size =sizeof (ATOM_Tonga_Fan_Table); +else if (header->ucRevId ==8 ) + table_size =sizeof (ATOM_Fiji_Fan_Table); +else + table_size =sizeof (ATOM_Polaris_Fan_Table); + +PP_ASSERT_WITH_CODE ((tonga_pp_table_has_space (hwmgr, table_offset, + table_size)), +"Invalid PowerPlay Table!" , return -1 ); + + *fan_table = header; + +return 0 ; +} + +static int get_tonga_power_tune_table (struct pp_hwmgr *hwmgr, +const ATOM_Tonga_POWERPLAYTABLE *powerplay_table, +const PPTable_Generic_SubTable_Header **power_tune_table) +{ +const PPTable_Generic_SubTable_Header *header; +u16 table_offset; +size_t table_size; +int ret; + + table_offset =le16_to_cpu (powerplay_table->usPowerTuneTableOffset); + ret =get_tonga_subtable (hwmgr, powerplay_table, table_offset, +sizeof (*header), (const void **)&header); +if (ret) +return ret; + +if (header->ucRevId <3 ) + table_size =sizeof (ATOM_Tonga_PowerTune_Table); +else if (header->ucRevId <4 ) + table_size =sizeof (ATOM_Fiji_PowerTune_Table); +else + table_size =sizeof (ATOM_Polaris_PowerTune_Table); + +PP_ASSERT_WITH_CODE ((tonga_pp_table_has_space (hwmgr, table_offset, + table_size)), +"Invalid PowerPlay Table!" , return -1 ); + + *power_tune_table = header; + +return 0 ; +} + +static int get_tonga_ppm_table (struct pp_hwmgr *hwmgr, +const ATOM_Tonga_POWERPLAYTABLE *powerplay_table, +const ATOM_Tonga_PPM_Table **ppm_table) +{ +u16 table_offset; + + table_offset =le16_to_cpu (powerplay_table->usPPMTableOffset); + +return get_tonga_subtable (hwmgr, powerplay_table, table_offset, +sizeof (**ppm_table), (const void **)ppm_table); +} + +static int get_tonga_gpio_table (struct pp_hwmgr *hwmgr, +const ATOM_Tonga_POWERPLAYTABLE *powerplay_table, +const ATOM_Tonga_GPIO_Table **gpio_table) +{ +u16 table_offset; + + table_offset =le16_to_cpu (powerplay_table->usGPIOTableOffset); + +return get_tonga_subtable (hwmgr, powerplay_table, table_offset, +sizeof (**gpio_table), (const void **)gpio_table); +} + +static int get_tonga_vce_state_table (struct pp_hwmgr *hwmgr, +const ATOM_Tonga_POWERPLAYTABLE *powerplay_table, +const ATOM_Tonga_VCE_State_Table **vce_state_table) +{ +const ATOM_Tonga_VCE_State_Table *table; +u16 table_offset; +int ret; + + table_offset =le16_to_cpu (powerplay_table->usVCEStateTableOffset); + ret =get_tonga_subtable (hwmgr, powerplay_table, table_offset, +sizeof (*table), (const void **)&table); +if (ret) +return ret; + + ret =validate_tonga_table_entries (hwmgr, table_offset, + offsetof(ATOM_Tonga_VCE_State_Table , + entries), + table->ucNumEntries, +sizeof (ATOM_Tonga_VCE_State_Record)); +if (ret) +return ret; + + *vce_state_table = table; + +return 0 ; +} + static int get_vddc_lookup_table( struct pp_hwmgr *hwmgr, phm_ppt_v1_voltage_lookup_table **lookup_table,
@@ -198,7 +560,7 @@ static int get_vddc_lookup_table(*/ static int get_platform_power_management_table (struct pp_hwmgr *hwmgr, -ATOM_Tonga_PPM_Table *atom_ppm_table) +const ATOM_Tonga_PPM_Table *atom_ppm_table) {struct phm_ppm_table *ptr =kzalloc (sizeof (*ptr),GFP_KERNEL ); struct phm_ppt_v1_information *pp_table_information =
@@ -246,7 +608,7 @@ static int init_dpm_2_parameters( {int result =0 ;struct phm_ppt_v1_information *pp_table_information = (struct phm_ppt_v1_information *)(hwmgr->pptable); -ATOM_Tonga_PPM_Table *atom_ppm_table; +const ATOM_Tonga_PPM_Table *atom_ppm_table;uint32_t disable_ppm =0 ;uint32_t disable_power_control =0 ;
@@ -275,30 +637,39 @@ static int init_dpm_2_parameters( }if (0 != powerplay_table->usVddcLookupTableOffset) { -const ATOM_Tonga_Voltage_Lookup_Table *pVddcCACTable = - (ATOM_Tonga_Voltage_Lookup_Table *)(((unsigned long )powerplay_table) + -le16_to_cpu (powerplay_table->usVddcLookupTableOffset)); - - result =get_vddc_lookup_table (hwmgr, - &pp_table_information->vddc_lookup_table, pVddcCACTable,16 ); +const ATOM_Tonga_Voltage_Lookup_Table *pVddcCACTable; + + result =get_tonga_voltage_lookup_table (hwmgr, powerplay_table, +le16_to_cpu (powerplay_table->usVddcLookupTableOffset), +16 , &pVddcCACTable); +if (!result) + result =get_vddc_lookup_table (hwmgr, + &pp_table_information->vddc_lookup_table, + pVddcCACTable,16 ); } -if (0 != powerplay_table->usVddgfxLookupTableOffset) { -const ATOM_Tonga_Voltage_Lookup_Table *pVddgfxCACTable = - (ATOM_Tonga_Voltage_Lookup_Table *)(((unsigned long )powerplay_table) + -le16_to_cpu (powerplay_table->usVddgfxLookupTableOffset)); +if (!result &&0 != powerplay_table->usVddgfxLookupTableOffset) { +const ATOM_Tonga_Voltage_Lookup_Table *pVddgfxCACTable; - result =get_vddc_lookup_table (hwmgr, - &pp_table_information->vddgfx_lookup_table, pVddgfxCACTable,16 ); + result =get_tonga_voltage_lookup_table (hwmgr, powerplay_table, +le16_to_cpu (powerplay_table->usVddgfxLookupTableOffset), +16 , &pVddgfxCACTable); +if (!result) + result =get_vddc_lookup_table (hwmgr, + &pp_table_information->vddgfx_lookup_table, + pVddgfxCACTable,16 ); } disable_ppm =0 ;if (0 == disable_ppm) { - atom_ppm_table = (ATOM_Tonga_PPM_Table *) - (((unsigned long )powerplay_table) +le16_to_cpu (powerplay_table->usPPMTableOffset)); -if (0 != powerplay_table->usPPMTableOffset) { -if (get_platform_power_management_table (hwmgr, atom_ppm_table) ==0 ) { +int ret; + + ret =get_tonga_ppm_table (hwmgr, powerplay_table, + &atom_ppm_table); +if (!ret && +get_platform_power_management_table (hwmgr, + atom_ppm_table) ==0 ) {phm_cap_set (hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_EnablePlatformPowerManagement); }
@@ -792,28 +1163,13 @@ static int init_clock_voltage_dependency(int result =0 ;struct phm_ppt_v1_information *pp_table_information = (struct phm_ppt_v1_information *)(hwmgr->pptable); - -const ATOM_Tonga_MM_Dependency_Table *mm_dependency_table = - (const ATOM_Tonga_MM_Dependency_Table *)(((unsigned long ) powerplay_table) + -le16_to_cpu (powerplay_table->usMMDependencyTableOffset)); -const PPTable_Generic_SubTable_Header *pPowerTuneTable = - (const PPTable_Generic_SubTable_Header *)(((unsigned long ) powerplay_table) + -le16_to_cpu (powerplay_table->usPowerTuneTableOffset)); -const ATOM_Tonga_MCLK_Dependency_Table *mclk_dep_table = - (const ATOM_Tonga_MCLK_Dependency_Table *)(((unsigned long ) powerplay_table) + -le16_to_cpu (powerplay_table->usMclkDependencyTableOffset)); -const PPTable_Generic_SubTable_Header *sclk_dep_table = - (const PPTable_Generic_SubTable_Header *)(((unsigned long ) powerplay_table) + -le16_to_cpu (powerplay_table->usSclkDependencyTableOffset)); -const ATOM_Tonga_Hard_Limit_Table *pHardLimits = - (const ATOM_Tonga_Hard_Limit_Table *)(((unsigned long ) powerplay_table) + -le16_to_cpu (powerplay_table->usHardLimitTableOffset)); -const PPTable_Generic_SubTable_Header *pcie_table = - (const PPTable_Generic_SubTable_Header *)(((unsigned long ) powerplay_table) + -le16_to_cpu (powerplay_table->usPCIETableOffset)); -const ATOM_Tonga_GPIO_Table *gpio_table = - (const ATOM_Tonga_GPIO_Table *)(((unsigned long ) powerplay_table) + -le16_to_cpu (powerplay_table->usGPIOTableOffset)); +const ATOM_Tonga_MM_Dependency_Table *mm_dependency_table; +const PPTable_Generic_SubTable_Header *pPowerTuneTable; +const ATOM_Tonga_MCLK_Dependency_Table *mclk_dep_table; +const PPTable_Generic_SubTable_Header *sclk_dep_table; +const ATOM_Tonga_Hard_Limit_Table *pHardLimits; +const PPTable_Generic_SubTable_Header *pcie_table; +const ATOM_Tonga_GPIO_Table *gpio_table; pp_table_information->vdd_dep_on_sclk =NULL ; pp_table_information->vdd_dep_on_mclk =NULL ;
@@ -821,29 +1177,58 @@ static int init_clock_voltage_dependency( pp_table_information->pcie_table =NULL ; pp_table_information->gpio_table =NULL ; -if (powerplay_table->usMMDependencyTableOffset !=0 ) - result =get_mm_clock_voltage_table (hwmgr, - &pp_table_information->mm_dep_table, mm_dependency_table); +if (powerplay_table->usMMDependencyTableOffset !=0 ) { + result =get_tonga_mm_dependency_table (hwmgr, powerplay_table, + &mm_dependency_table); +if (!result) + result =get_mm_clock_voltage_table (hwmgr, + &pp_table_information->mm_dep_table, + mm_dependency_table); + } -if (result ==0 && powerplay_table->usPowerTuneTableOffset !=0 ) - result =get_cac_tdp_table (hwmgr, - &pp_table_information->cac_dtp_table, pPowerTuneTable); +if (result ==0 && powerplay_table->usPowerTuneTableOffset !=0 ) { + result =get_tonga_power_tune_table (hwmgr, powerplay_table, + &pPowerTuneTable); +if (!result) + result =get_cac_tdp_table (hwmgr, + &pp_table_information->cac_dtp_table, + pPowerTuneTable); + } -if (result ==0 && powerplay_table->usSclkDependencyTableOffset !=0 ) - result =get_sclk_voltage_dependency_table (hwmgr, - &pp_table_information->vdd_dep_on_sclk, sclk_dep_table); +if (result ==0 && powerplay_table->usSclkDependencyTableOffset !=0 ) { + result =get_tonga_sclk_dependency_table (hwmgr, powerplay_table, + &sclk_dep_table); +if (!result) + result =get_sclk_voltage_dependency_table (hwmgr, + &pp_table_information->vdd_dep_on_sclk, + sclk_dep_table); + } -if (result ==0 && powerplay_table->usMclkDependencyTableOffset !=0 ) - result =get_mclk_voltage_dependency_table (hwmgr, - &pp_table_information->vdd_dep_on_mclk, mclk_dep_table); +if (result ==0 && powerplay_table->usMclkDependencyTableOffset !=0 ) { + result =get_tonga_mclk_dependency_table (hwmgr, powerplay_table, + &mclk_dep_table); +if (!result) + result =get_mclk_voltage_dependency_table (hwmgr, + &pp_table_information->vdd_dep_on_mclk, + mclk_dep_table); + } -if (result ==0 && powerplay_table->usPCIETableOffset !=0 ) - result =get_pcie_table (hwmgr, - &pp_table_information->pcie_table, pcie_table); +if (result ==0 && powerplay_table->usPCIETableOffset !=0 ) { + result =get_tonga_pcie_table (hwmgr, powerplay_table, + &pcie_table); +if (!result) + result =get_pcie_table (hwmgr, + &pp_table_information->pcie_table, pcie_table); + } -if (result ==0 && powerplay_table->usHardLimitTableOffset !=0 ) - result =get_hard_limits (hwmgr, - &pp_table_information->max_clock_voltage_on_dc, pHardLimits); +if (result ==0 && powerplay_table->usHardLimitTableOffset !=0 ) { + result =get_tonga_hard_limit_table (hwmgr, powerplay_table, + &pHardLimits); +if (!result) + result =get_hard_limits (hwmgr, + &pp_table_information->max_clock_voltage_on_dc, + pHardLimits); + } hwmgr->dyn_state.max_clock_voltage_on_dc.sclk = pp_table_information->max_clock_voltage_on_dc.sclk;
@@ -864,9 +1249,13 @@ static int init_clock_voltage_dependency( result =get_valid_clk (hwmgr, &pp_table_information->valid_sclk_values, pp_table_information->vdd_dep_on_sclk); -if (!result && gpio_table) - result =get_gpio_table (hwmgr, &pp_table_information->gpio_table, - gpio_table); +if (!result && powerplay_table->usGPIOTableOffset) { + result =get_tonga_gpio_table (hwmgr, powerplay_table, + &gpio_table); +if (!result) + result =get_gpio_table (hwmgr, + &pp_table_information->gpio_table, gpio_table); + }return result; }
@@ -911,14 +1300,17 @@ static int init_thermal_controller( ) {const PPTable_Generic_SubTable_Header *fan_table; -ATOM_Tonga_Thermal_Controller *thermal_controller; +const ATOM_Tonga_Thermal_Controller *thermal_controller; +int ret; - thermal_controller = (ATOM_Tonga_Thermal_Controller *) - (((unsigned long )powerplay_table) + -le16_to_cpu (powerplay_table->usThermalControllerOffset));PP_ASSERT_WITH_CODE ((0 != powerplay_table->usThermalControllerOffset),"Thermal controller table not set!" , return -1 ); + ret =get_tonga_thermal_controller_table (hwmgr, powerplay_table, + &thermal_controller); +if (ret) +return ret; + hwmgr->thermal_controller.ucType = thermal_controller->ucType; hwmgr->thermal_controller.ucI2cLine = thermal_controller->ucI2cLine; hwmgr->thermal_controller.ucI2cAddress = thermal_controller->ucI2cAddress;
@@ -946,12 +1338,13 @@ static int init_thermal_controller(return 0 ; } - fan_table = (const PPTable_Generic_SubTable_Header *) - (((unsigned long )powerplay_table) + -le16_to_cpu (powerplay_table->usFanTableOffset)); -PP_ASSERT_WITH_CODE ((0 != powerplay_table->usFanTableOffset),"Fan table not set!" , return -1 ); + + ret =get_tonga_fan_table (hwmgr, powerplay_table, &fan_table); +if (ret) +return ret; +PP_ASSERT_WITH_CODE ((0 < fan_table->ucRevId),"Unsupported fan table format!" , return -1 );
@@ -1313,13 +1706,15 @@ static int ppt_get_num_of_vce_state_table_entries_v1_0(struct pp_hwmgr *hwmgr) {const ATOM_Tonga_POWERPLAYTABLE *pp_table =get_powerplay_table (hwmgr);const ATOM_Tonga_VCE_State_Table *vce_state_table; +int ret;if (pp_table ==NULL )return 0 ; - vce_state_table = (void *)pp_table + -le16_to_cpu (pp_table->usVCEStateTableOffset); + ret =get_tonga_vce_state_table (hwmgr, pp_table, &vce_state_table); +if (ret) +return 0 ;return vce_state_table->ucNumEntries; }
@@ -1328,18 +1723,39 @@ static int ppt_get_vce_state_table_entry_v1_0(struct pp_hwmgr *hwmgr, uint32_t i struct amd_vce_state *vce_state, void **clock_info, uint32_t *flag) { const ATOM_Tonga_VCE_State_Record *vce_state_record; -ATOM_Tonga_SCLK_Dependency_Record *sclk_dep_record; +ATOM_Tonga_SCLK_Dependency_Record *sclk_dep_record =NULL ; +ATOM_Polaris_SCLK_Dependency_Record *polaris_sclk_dep_record =NULL ;ATOM_Tonga_MCLK_Dependency_Record *mclk_dep_record;ATOM_Tonga_MM_Dependency_Record *mm_dep_record;const ATOM_Tonga_POWERPLAYTABLE *pptable =get_powerplay_table (hwmgr); -const ATOM_Tonga_VCE_State_Table *vce_state_table = (ATOM_Tonga_VCE_State_Table *)(((unsigned long )pptable) - +le16_to_cpu (pptable->usVCEStateTableOffset)); -const ATOM_Tonga_SCLK_Dependency_Table *sclk_dep_table = (ATOM_Tonga_SCLK_Dependency_Table *)(((unsigned long )pptable) - +le16_to_cpu (pptable->usSclkDependencyTableOffset)); -const ATOM_Tonga_MCLK_Dependency_Table *mclk_dep_table = (ATOM_Tonga_MCLK_Dependency_Table *)(((unsigned long )pptable) - +le16_to_cpu (pptable->usMclkDependencyTableOffset)); -const ATOM_Tonga_MM_Dependency_Table *mm_dep_table = (ATOM_Tonga_MM_Dependency_Table *)(((unsigned long )pptable) - +le16_to_cpu (pptable->usMMDependencyTableOffset)); +const ATOM_Tonga_VCE_State_Table *vce_state_table; +const PPTable_Generic_SubTable_Header *sclk_dep_table_header; +const ATOM_Tonga_SCLK_Dependency_Table *sclk_dep_table; +const ATOM_Tonga_MCLK_Dependency_Table *mclk_dep_table; +const ATOM_Tonga_MM_Dependency_Table *mm_dep_table; +int ret; + +if (!pptable) +return -EINVAL ; + + ret =get_tonga_vce_state_table (hwmgr, pptable, &vce_state_table); +if (ret) +return ret; + + ret =get_tonga_sclk_dependency_table (hwmgr, pptable, + &sclk_dep_table_header); +if (ret) +return ret; + sclk_dep_table = (const ATOM_Tonga_SCLK_Dependency_Table *) + sclk_dep_table_header; + + ret =get_tonga_mclk_dependency_table (hwmgr, pptable, &mclk_dep_table); +if (ret) +return ret; + + ret =get_tonga_mm_dependency_table (hwmgr, pptable, &mm_dep_table); +if (ret) +return ret; PP_ASSERT_WITH_CODE((i < vce_state_table->ucNumEntries), "Requested state entry ID is out of range!",
@@ -1348,10 +1764,27 @@ static int ppt_get_vce_state_table_entry_v1_0(struct pp_hwmgr *hwmgr, uint32_t i vce_state_record =GET_FLEXIBLE_ARRAY_MEMBER_ADDR ( ATOM_Tonga_VCE_State_Record, entries, vce_state_table, i); - sclk_dep_record =GET_FLEXIBLE_ARRAY_MEMBER_ADDR ( - ATOM_Tonga_SCLK_Dependency_Record, - entries, sclk_dep_table, - vce_state_record->ucSCLKIndex); +PP_ASSERT_WITH_CODE ((vce_state_record->ucSCLKIndex < + sclk_dep_table->ucNumEntries), +"Invalid PowerPlay Table!" , return -EINVAL ); +PP_ASSERT_WITH_CODE ((vce_state_record->ucVCEClockIndex < + mm_dep_table->ucNumEntries), +"Invalid PowerPlay Table!" , return -EINVAL ); +PP_ASSERT_WITH_CODE ((mclk_dep_table->ucNumEntries !=0 ), +"Invalid PowerPlay Table!" , return -EINVAL ); + +if (sclk_dep_table_header->ucRevId <1 ) + sclk_dep_record =GET_FLEXIBLE_ARRAY_MEMBER_ADDR ( + ATOM_Tonga_SCLK_Dependency_Record, + entries, sclk_dep_table, + vce_state_record->ucSCLKIndex); +else + polaris_sclk_dep_record =GET_FLEXIBLE_ARRAY_MEMBER_ADDR ( + ATOM_Polaris_SCLK_Dependency_Record, + entries, + (ATOM_Polaris_SCLK_Dependency_Table *) + sclk_dep_table_header, + vce_state_record->ucSCLKIndex); mm_dep_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( ATOM_Tonga_MM_Dependency_Record, entries, mm_dep_table,
@@ -1360,7 +1793,10 @@ static int ppt_get_vce_state_table_entry_v1_0(struct pp_hwmgr *hwmgr, uint32_t i vce_state->evclk =le32_to_cpu (mm_dep_record->ulEClk); vce_state->ecclk =le32_to_cpu (mm_dep_record->ulEClk); - vce_state->sclk =le32_to_cpu (sclk_dep_record->ulSclk); +if (sclk_dep_record) + vce_state->sclk =le32_to_cpu (sclk_dep_record->ulSclk); +else + vce_state->sclk =le32_to_cpu (polaris_sclk_dep_record->ulSclk);if (vce_state_record->ucMCLKIndex >= mclk_dep_table->ucNumEntries) mclk_dep_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR(
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.15] drm/amd/pm: Validate Tonga PPTable subtable bounds
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider: - [High] drm/amd/pm: NULL vdd_dep_on_sclk deref in get_pcie_table() and get_gpio_table() - [Medium]…
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] drm/amd/pm: NULL vdd_dep_on_sclk deref in get_pcie_table() and get_gpio_table()
- [Medium] drm/amd/pm: 1-byte OOB read in get_tonga_sclk_dependency_table() and PCIE
- [Medium] drm/amd/pm: missing PPTable and state array bounds in check_powerplay_tables()
- [Medium] drm/amd/pm: unchecked ppt_get_vce_state_table_entry_v1_0() error in get_powerplay_table_entry_v1_0()
- [Medium] drm/amd/pm: memory leak in pp_tables_v1_0_initialize() on subtable error
--
commit f47b28bb12da9445f349f0b309395380a9db541f
Author: Yang Wang <[email protected]>
drm/amd/pm: Validate Tonga PPTable subtable bounds
This commit adds bounds validation helpers for Tonga PowerPlay subtables to validate fixed subtable headers, dynamic entry arrays, and revision-specific layouts before consuming VBIOS or user-supplied PPTable data.
Quoted 5 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c +0
-0
drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c static const void *get_powerplay_table(struct pp_hwmgr *hwmgr) · line 159
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c +7
-0@@ -150,6 +150,368 @@ static const void *get_powerplay_table(struct pp_hwmgr *hwmgr)return table_address; } +static bool tonga_pp_table_has_space (struct pp_hwmgr *hwmgr,size_t offset, +size_t size) +{ +size_t table_size = hwmgr->soft_pp_table_size; + +return offset <= table_size && size <= table_size - offset; +}
[Severity: Medium]
Can the new get_tonga_*_table() helpers and check_powerplay_tables() read out of bounds past hwmgr->soft_pp_table when hwmgr->soft_pp_table_size is smaller than sizeof(ATOM_Tonga_POWERPLAYTABLE), or when usStateArrayOffset and state_arrays->ucNumEntries exceed hwmgr->soft_pp_table_size?
In drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c, get_powerplay_table() caches hwmgr->soft_pp_table_size from smu_atom_get_data_table() without checking that it is at least sizeof(ATOM_Tonga_POWERPLAYTABLE):
if (!table_address) {
table_address = (ATOM_Tonga_POWERPLAYTABLE *)
smu_atom_get_data_table(hwmgr->adev,
index, &size, &frev, &crev);
hwmgr->soft_pp_table = table_address; /*Cache the result in RAM.*/
hwmgr->soft_pp_table_size = size;
}All of the new get_tonga_*_table() subtable helpers dereference offset fields directly from powerplay_table (up to usGPIOTableOffset at the end of ATOM_Tonga_POWERPLAYTABLE) before calling tonga_pp_table_has_space().
In addition, because the prerequisite Tonga state-array bounds validation from the upstream series is not present on this branch, check_powerplay_tables(), get_number_of_powerplay_table_entries_v1_0(), and get_powerplay_table_entry_v1_0() still compute and dereference state_arrays without checking hwmgr->soft_pp_table_size:
static int check_powerplay_tables(
struct pp_hwmgr *hwmgr,
const ATOM_Tonga_POWERPLAYTABLE *powerplay_table )
{
const ATOM_Tonga_State_Array *state_arrays;
state_arrays = (ATOM_Tonga_State_Array *)(((unsigned long)powerplay_table) +
le16_to_cpu(powerplay_table->usStateArrayOffset));
...
PP_ASSERT_WITH_CODE((0 != powerplay_table->usStateArrayOffset),
"State table is not set!", return -1);
PP_ASSERT_WITH_CODE((0 < powerplay_table->sHeader.usStructureSize),
"Invalid PowerPlay Table!", return -1);
PP_ASSERT_WITH_CODE((0 < state_arrays->ucNumEntries),
"Invalid PowerPlay Table!", return -1);Should the base ATOM_Tonga_POWERPLAYTABLE size and state_arrays bounds also be validated against hwmgr->soft_pp_table_size before dereferencing them?
[ ... ]
Quoted 65 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c +65
-0+static int get_tonga_sclk_dependency_table (struct pp_hwmgr *hwmgr, +const ATOM_Tonga_POWERPLAYTABLE *powerplay_table, +const PPTable_Generic_SubTable_Header **sclk_dep_table) +{ +const PPTable_Generic_SubTable_Header *header; +u16 table_offset; +size_t entries_offset; +size_t entry_size; +u8 num_entries; +int ret; + + table_offset =le16_to_cpu (powerplay_table->usSclkDependencyTableOffset); + ret =get_tonga_subtable (hwmgr, powerplay_table, table_offset, +sizeof (*header), (const void **)&header); +if (ret) +return ret; + +if (header->ucRevId <1 ) { +const ATOM_Tonga_SCLK_Dependency_Table *table = + (const ATOM_Tonga_SCLK_Dependency_Table *)header; + + entries_offset = offsetof(ATOM_Tonga_SCLK_Dependency_Table , entries); + entry_size =sizeof (ATOM_Tonga_SCLK_Dependency_Record); + num_entries = table->ucNumEntries; + }else { +const ATOM_Polaris_SCLK_Dependency_Table *table = + (const ATOM_Polaris_SCLK_Dependency_Table *)header; + + entries_offset = offsetof(ATOM_Polaris_SCLK_Dependency_Table , entries); + entry_size =sizeof (ATOM_Polaris_SCLK_Dependency_Record); + num_entries = table->ucNumEntries; + } + + ret =validate_tonga_table_entries (hwmgr, table_offset, entries_offset, + num_entries, entry_size); +if (ret) +return ret; + + *sclk_dep_table = header; + +return 0 ; +} + +static int get_tonga_pcie_table (struct pp_hwmgr *hwmgr, +const ATOM_Tonga_POWERPLAYTABLE *powerplay_table, +const PPTable_Generic_SubTable_Header **pcie_table) +{ +const PPTable_Generic_SubTable_Header *header; +u16 table_offset; +size_t entries_offset; +size_t entry_size; +u8 num_entries; +int ret; + + table_offset =le16_to_cpu (powerplay_table->usPCIETableOffset); + ret =get_tonga_subtable (hwmgr, powerplay_table, table_offset, +sizeof (*header), (const void **)&header); +if (ret) +return ret; + +if (header->ucRevId <1 ) { +const ATOM_Tonga_PCIE_Table *table = + (const ATOM_Tonga_PCIE_Table *)header; + + entries_offset = offsetof(ATOM_Tonga_PCIE_Table , entries);
drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c static const void *get_powerplay_table(struct pp_hwmgr *hwmgr) · line 350
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c +10
-0+ entry_size =sizeof (ATOM_Tonga_PCIE_Record); + num_entries = table->ucNumEntries; + }else { +const ATOM_Polaris10_PCIE_Table *table = + (const ATOM_Polaris10_PCIE_Table *)header; + + entries_offset = offsetof(ATOM_Polaris10_PCIE_Table , entries); + entry_size =sizeof (ATOM_Polaris10_PCIE_Record); + num_entries = table->ucNumEntries; + }
[Severity: Medium]
Does reading table->ucNumEntries in get_tonga_sclk_dependency_table() and get_tonga_pcie_table() cause a 1-byte out-of-bounds read past hwmgr->soft_pp_table when table_offset equals hwmgr->soft_pp_table_size - 1?
In drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h, PPTable_Generic_SubTable_Header is only 1 byte:
typedef struct _PPTable_Generic_SubTable_Header {
UCHAR ucRevId;
} PPTable_Generic_SubTable_Header;Both get_tonga_sclk_dependency_table() and get_tonga_pcie_table() pass sizeof(*header) (1 byte) to get_tonga_subtable(), and then immediately cast header to the concrete subtable type and read table->ucNumEntries at table_offset + 1 before calling validate_tonga_table_entries().
If usSclkDependencyTableOffset or usPCIETableOffset is hwmgr->soft_pp_table_size - 1, get_tonga_subtable() succeeds for the 1-byte header and table->ucNumEntries reads 1 byte past the end of hwmgr->soft_pp_table.
[ ... ]
Quoted 84 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c +47
-21@@ -821,29 +1177,58 @@ static int init_clock_voltage_dependency( pp_table_information->pcie_table =NULL ; pp_table_information->gpio_table =NULL ; -if (powerplay_table->usMMDependencyTableOffset !=0 ) - result =get_mm_clock_voltage_table (hwmgr, - &pp_table_information->mm_dep_table, mm_dependency_table); +if (powerplay_table->usMMDependencyTableOffset !=0 ) { + result =get_tonga_mm_dependency_table (hwmgr, powerplay_table, + &mm_dependency_table); +if (!result) + result =get_mm_clock_voltage_table (hwmgr, + &pp_table_information->mm_dep_table, + mm_dependency_table); + } -if (result ==0 && powerplay_table->usPowerTuneTableOffset !=0 ) - result =get_cac_tdp_table (hwmgr, - &pp_table_information->cac_dtp_table, pPowerTuneTable); +if (result ==0 && powerplay_table->usPowerTuneTableOffset !=0 ) { + result =get_tonga_power_tune_table (hwmgr, powerplay_table, + &pPowerTuneTable); +if (!result) + result =get_cac_tdp_table (hwmgr, + &pp_table_information->cac_dtp_table, + pPowerTuneTable); + } -if (result ==0 && powerplay_table->usSclkDependencyTableOffset !=0 ) - result =get_sclk_voltage_dependency_table (hwmgr, - &pp_table_information->vdd_dep_on_sclk, sclk_dep_table); +if (result ==0 && powerplay_table->usSclkDependencyTableOffset !=0 ) { + result =get_tonga_sclk_dependency_table (hwmgr, powerplay_table, + &sclk_dep_table); +if (!result) + result =get_sclk_voltage_dependency_table (hwmgr, + &pp_table_information->vdd_dep_on_sclk, + sclk_dep_table); + } -if (result ==0 && powerplay_table->usMclkDependencyTableOffset !=0 ) - result =get_mclk_voltage_dependency_table (hwmgr, - &pp_table_information->vdd_dep_on_mclk, mclk_dep_table); +if (result ==0 && powerplay_table->usMclkDependencyTableOffset !=0 ) { + result =get_tonga_mclk_dependency_table (hwmgr, powerplay_table, + &mclk_dep_table); +if (!result) + result =get_mclk_voltage_dependency_table (hwmgr, + &pp_table_information->vdd_dep_on_mclk, + mclk_dep_table); + } -if (result ==0 && powerplay_table->usPCIETableOffset !=0 ) - result =get_pcie_table (hwmgr, - &pp_table_information->pcie_table, pcie_table); +if (result ==0 && powerplay_table->usPCIETableOffset !=0 ) { + result =get_tonga_pcie_table (hwmgr, powerplay_table, + &pcie_table); +if (!result) + result =get_pcie_table (hwmgr, + &pp_table_information->pcie_table, pcie_table); + } -if (result ==0 && powerplay_table->usHardLimitTableOffset !=0 ) - result =get_hard_limits (hwmgr, - &pp_table_information->max_clock_voltage_on_dc, pHardLimits); +if (result ==0 && powerplay_table->usHardLimitTableOffset !=0 ) { + result =get_tonga_hard_limit_table (hwmgr, powerplay_table, + &pHardLimits); +if (!result) + result =get_hard_limits (hwmgr, + &pp_table_information->max_clock_voltage_on_dc, + pHardLimits); + } hwmgr->dyn_state.max_clock_voltage_on_dc.sclk = pp_table_information->max_clock_voltage_on_dc.sclk;@@ -864,9 +1249,13 @@ static int init_clock_voltage_dependency( result =get_valid_clk (hwmgr, &pp_table_information->valid_sclk_values, pp_table_information->vdd_dep_on_sclk); -if (!result && gpio_table) - result =get_gpio_table (hwmgr, &pp_table_information->gpio_table, - gpio_table);
drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c static int init_clock_voltage_dependency( · line 1261
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c +7
-0+if (!result && powerplay_table->usGPIOTableOffset) { + result =get_tonga_gpio_table (hwmgr, powerplay_table, + &gpio_table); +if (!result) + result =get_gpio_table (hwmgr, + &pp_table_information->gpio_table, gpio_table); + }return result; }
[Severity: High]
What happens in init_clock_voltage_dependency() if a malformed PPTable has usSclkDependencyTableOffset == 0 while usPCIETableOffset != 0 or usGPIOTableOffset != 0?
In init_clock_voltage_dependency(), pp_table_information->vdd_dep_on_sclk is initialized to NULL and is only populated when powerplay_table->usSclkDependencyTableOffset != 0 (as anticipated before get_valid_clk(), which checks NULL != pp_table_information->vdd_dep_on_sclk).
However, when usPCIETableOffset != 0 or usGPIOTableOffset != 0, get_pcie_table() and get_gpio_table() are called and unconditionally dereference pp_table_information->vdd_dep_on_sclk->count:
get_pcie_table():
pcie_count = (pp_table_information->vdd_dep_on_sclk->count) + 1;
get_gpio_table():
if (pp_table_information->vdd_dep_on_sclk->count < atom_gpio_table->ucVRHotTriggeredSclkDpmIndex)
Can this trigger a NULL pointer dereference on a table with usSclkDependencyTableOffset == 0?
[Severity: Medium]
Also in init_clock_voltage_dependency(), init_dpm_2_parameters(), and init_thermal_controller(), if one of the new get_tonga_*() subtable bounds checks fails after earlier subtables have been allocated, does pp_tables_v1_0_initialize() leak hwmgr->pptable, hwmgr->dyn_state.cac_dtp_table, and the already-allocated subtable arrays in pp_table_information?
When pp_tables_v1_0_initialize() returns a non-zero result:
pp_tables_v1_0_initialize() {
...
result = init_clock_voltage_dependency(hwmgr, powerplay_table);
PP_ASSERT_WITH_CODE((result == 0),
"init_clock_voltage_dependency failed", return result);
result = init_dpm_2_parameters(hwmgr, powerplay_table);
PP_ASSERT_WITH_CODE((result == 0),
"init_dpm_2_parameters failed", return result);
}its caller hwmgr_hw_init() in drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c jumps to err, bypassing err1 where pptable_fini() (pp_tables_v1_0_uninitialize()) would otherwise free those allocations:
ret = hwmgr->pptable_func->pptable_init(hwmgr); if (ret) goto err; ... err1: if (hwmgr->pptable_func->pptable_fini) hwmgr->pptable_func->pptable_fini(hwmgr); err: return ret;
[ ... ]
Quoted 73 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c +34
-13@@ -1290,13 +1683,15 @@ static int ppt_get_num_of_vce_state_table_entries_v1_0(struct pp_hwmgr *hwmgr) {const ATOM_Tonga_POWERPLAYTABLE *pp_table =get_powerplay_table (hwmgr);const ATOM_Tonga_VCE_State_Table *vce_state_table; +int ret;if (pp_table ==NULL )return 0 ; - vce_state_table = (void *)pp_table + -le16_to_cpu (pp_table->usVCEStateTableOffset); + ret =get_tonga_vce_state_table (hwmgr, pp_table, &vce_state_table); +if (ret) +return 0 ;return vce_state_table->ucNumEntries; }@@ -1305,18 +1700,39 @@ static int ppt_get_vce_state_table_entry_v1_0(struct pp_hwmgr *hwmgr, uint32_t i struct amd_vce_state *vce_state, void **clock_info, uint32_t *flag) { const ATOM_Tonga_VCE_State_Record *vce_state_record; -ATOM_Tonga_SCLK_Dependency_Record *sclk_dep_record; +ATOM_Tonga_SCLK_Dependency_Record *sclk_dep_record =NULL ; +ATOM_Polaris_SCLK_Dependency_Record *polaris_sclk_dep_record =NULL ;ATOM_Tonga_MCLK_Dependency_Record *mclk_dep_record;ATOM_Tonga_MM_Dependency_Record *mm_dep_record;const ATOM_Tonga_POWERPLAYTABLE *pptable =get_powerplay_table (hwmgr); -const ATOM_Tonga_VCE_State_Table *vce_state_table = (ATOM_Tonga_VCE_State_Table *)(((unsigned long )pptable) - +le16_to_cpu (pptable->usVCEStateTableOffset)); -const ATOM_Tonga_SCLK_Dependency_Table *sclk_dep_table = (ATOM_Tonga_SCLK_Dependency_Table *)(((unsigned long )pptable) - +le16_to_cpu (pptable->usSclkDependencyTableOffset)); -const ATOM_Tonga_MCLK_Dependency_Table *mclk_dep_table = (ATOM_Tonga_MCLK_Dependency_Table *)(((unsigned long )pptable) - +le16_to_cpu (pptable->usMclkDependencyTableOffset)); -const ATOM_Tonga_MM_Dependency_Table *mm_dep_table = (ATOM_Tonga_MM_Dependency_Table *)(((unsigned long )pptable) - +le16_to_cpu (pptable->usMMDependencyTableOffset)); +const ATOM_Tonga_VCE_State_Table *vce_state_table; +const PPTable_Generic_SubTable_Header *sclk_dep_table_header; +const ATOM_Tonga_SCLK_Dependency_Table *sclk_dep_table; +const ATOM_Tonga_MCLK_Dependency_Table *mclk_dep_table; +const ATOM_Tonga_MM_Dependency_Table *mm_dep_table; +int ret; + +if (!pptable) +return -EINVAL ; + + ret =get_tonga_vce_state_table (hwmgr, pptable, &vce_state_table); +if (ret) +return ret; + + ret =get_tonga_sclk_dependency_table (hwmgr, pptable, + &sclk_dep_table_header); +if (ret) +return ret; + sclk_dep_table = (const ATOM_Tonga_SCLK_Dependency_Table *) + sclk_dep_table_header; + + ret =get_tonga_mclk_dependency_table (hwmgr, pptable, &mclk_dep_table); +if (ret) +return ret; + + ret =get_tonga_mm_dependency_table (hwmgr, pptable, &mm_dep_table); +if (ret) +return ret; PP_ASSERT_WITH_CODE((i < vce_state_table->ucNumEntries), "Requested state entry ID is out of range!",@@ -1325,10 +1741,27 @@ static int ppt_get_vce_state_table_entry_v1_0(struct pp_hwmgr *hwmgr, uint32_t i vce_state_record =GET_FLEXIBLE_ARRAY_MEMBER_ADDR ( ATOM_Tonga_VCE_State_Record, entries, vce_state_table, i); - sclk_dep_record = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( - ATOM_Tonga_SCLK_Dependency_Record,
drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c static int ppt_get_vce_state_table_entry_v1_0(struct pp_hwmgr *hwmgr, uint32_t i · line 1751
Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c +8
-2- entries, sclk_dep_table, - vce_state_record->ucSCLKIndex); +PP_ASSERT_WITH_CODE ((vce_state_record->ucSCLKIndex < + sclk_dep_table->ucNumEntries), +"Invalid PowerPlay Table!" , return -EINVAL ); +PP_ASSERT_WITH_CODE ((vce_state_record->ucVCEClockIndex < + mm_dep_table->ucNumEntries), +"Invalid PowerPlay Table!" , return -EINVAL ); +PP_ASSERT_WITH_CODE ((mclk_dep_table->ucNumEntries !=0 ), +"Invalid PowerPlay Table!" , return -EINVAL );
[Severity: Medium]
When ppt_get_vce_state_table_entry_v1_0() returns early on one of these new validation checks, how does the caller get_powerplay_table_entry_v1_0() handle the failure?
In get_powerplay_table_entry_v1_0():
hwmgr->num_vce_state_tables = i = ppt_get_num_of_vce_state_table_entries_v1_0(hwmgr);
if ((i != 0) && (i <= AMD_MAX_VCE_LEVELS)) {
for (j = 0; j < i; j++)
ppt_get_vce_state_table_entry_v1_0(hwmgr, j, &(hwmgr->vce_states[j]), NULL, &flags);
}ppt_get_num_of_vce_state_table_entries_v1_0() only validates get_tonga_vce_state_table() (and does not check ucNumEntries <= AMD_MAX_VCE_LEVELS). If ppt_get_vce_state_table_entry_v1_0() fails on get_tonga_sclk_dependency_table(), get_tonga_mclk_dependency_table(), get_tonga_mm_dependency_table(), or the ucSCLKIndex / ucVCEClockIndex range checks, its return value is ignored and hwmgr->num_vce_state_tables remains set to i while hwmgr->vce_states[j] is left unpopulated or retains stale data after a sysfs pp_table update.
Similarly, if i > AMD_MAX_VCE_LEVELS, the loop is skipped while hwmgr->num_vce_state_tables remains set to i, which pp_dpm_get_vce_clock_state() in drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c then uses to bounds-check hwmgr->vce_states[idx]:
if (idx < hwmgr->num_vce_state_tables) return &hwmgr->vce_states[idx];
Should get_powerplay_table_entry_v1_0() check the return value of ppt_get_vce_state_table_entry_v1_0() and reset hwmgr->num_vce_state_tables to 0 when i > AMD_MAX_VCE_LEVELS or when entry parsing fails?
[ ... ]
Quoted 1 line
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 USB: misc: uss720: Fix leak in get_1284_register
In reply to Sasha LevinFrom: Michail Tatas <[email protected]>
[ Upstream commit 15902712b9e2a46649cba2f22002d05faec2a990 ]
if wait_for_completion_timeout() times out in get_1284_register() then we do not destroy the reference acquired via kref_get() in submit_async_request. Add the missing kref_put in the timeout path.
---
LLM Generated explanations, may be completely bogus:
The local tree is **7.3-rc4** (v7.3-rc4-27-gf0100363d8c37). The candidate is a one-line kref leak fix in drivers/usb/misc/uss720.c. The affected driver and timeout path are present in this tree, and the bug dates to 2005.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[USB: misc: uss720]** **[Fix]** **[missing kref_put on get_1284_register() timeout]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Reported-by:** [email protected] (fuzzer-found, C repro)
- **Link:** https://syzkaller.appspot.com/bug?extid=56962eb32ba0136cd330
- **Link:** https://patch.msgid.link/allaDTUua9n5DQ0a@michalis-linux
- **Signed-off-by:** Michail Tatas (author)
- **Signed-off-by:** Greg Kroah-Hartman (USB maintainer; merged)
- **Fixes:** absent (expected)
- **Cc: stable:** absent (expected)
- Lowercase link: to syzbot (same report as Reported-by)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** wait_for_completion_timeout() expiry in get_1284_register() does not drop the uss720_async_request kref taken by submit_async_request().
- **Symptom:** kmemleak of the request, URB, control buffer, and priv (syzbot title: “memory leak in uss720_probe”).
- **Root cause:** success/!val paths call kref_put(); the timeout path only unlinks URBs and returns -EIO.
- **Version info in message:** none. Introduced with the async path in 2005 (0f36163d3abef).
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Explicit leak fix, plus syzbot/kmemleak evidence.
===============================================================
PHASE 2: DIFF ANALYSIS
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/usb/misc/uss720.c — **+1 / -0**
- Function: get_1284_register()
- Scope: single-file, one-line, timeout/error path only
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** timeout prints a warning, kill_all_async_requests_priv(priv) (usb_unlink_urb only), return -EIO. Caller kref leaked.
- **After:** same unlink, then kref_put(&rq->ref_count, destroy_async) matching the completion path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Reference-count / resource leak**
- submit_async_request(): kref_init (caller) + kref_get (URB/async_complete).
- async_complete() puts the URB ref.
- Timeout never puts the caller ref, so destroy_async() never runs:
URB, rq, rq->dr, and a priv kref leak.
- Syzbot objects match: uss720_probe priv, submit_async_request rq, usb_alloc_urb, rq->dr.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct; same kref_put as the success and !val paths. Unlink does not drop the caller ref. Timeout means complete() has not run, so the extra put cannot free rq while the URB still holds a ref. No API/locking/structure changes. Regression risk: very low.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: Timeout path from **0f36163d3abef** (2005-09-12, “usb: fix uss720 schedule with interrupts off”). Extra kref_get before usb_submit_urb from **adaa3c6342b249** (2011, “USB: uss720 fixup refcount position”). Bug is old, not 7.3-only.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Buggy code is the 2005 timeout path; that commit is in this tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Nearby uss720 work is probe refcount/unregister (45dba8011efac, b4ecbdc4f8830), not this timeout put. Standalone, not N/M. After this commit on this file: none that revert or replace it.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Only this uss720 commit from Michail Tatas in drivers/usb/. Merged by Greg KH (USB maintainer).
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Uses existing kref_put / destroy_async. Applies as a one-line add.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 15902712b9e2a:
https://patch.msgid.link/allaDTUua9n5DQ0a@michalis-linux
- b4 dig -a: earlier “v1” by WenTao Liang (2026-06-11) same leak; syzbot forwards of this patch and a competing usb_kill_urb patch (Deepanshu Kartikey).
- Direct lore HTTP was 403; thread recovered with b4 dig -m.
- David Laight **questioned** the usb_kill_urb + unlock-while- iterating alternative; that patch was not merged. This one-line kref_put was.
- Syzbot #syz test of this patch: **OK**.
- No NAK on the merged patch. No reviewer Cc: stable in the saved mbox (syzbot thread, not Greg’s apply mail).
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc included [email protected], [email protected], [email protected]. Merged by Greg KH.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: https://syzkaller.appspot.com/bug?extid=56962eb32ba0136cd330
- Title: memory leak in uss720_probe; **prio:high**; C and syz repros.
- Path: uss720_probe → get_1284_register → submit_async_request.
- Assessment: DoS via peripheral USB, not remote/unprivileged.
- Later dashboard crashes (Aug 2026) are on **7.2-rc** SHAs that are **not** ancestors of this fix (d58772d8520c, 0d8395707651). They do not show the fix failing on 7.3.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone. Competing usb_kill_urb rewrite not required and not in this tree (kill_all_async_requests_priv still uses usb_unlink_urb).
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable WebFetch returned 403. **UNVERIFIED** whether stable@ discussed it. No local git log --grep hit except this commit itself.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: KEY FUNCTIONS**
Record: get_1284_register (modified). Related: submit_async_request, destroy_async, async_complete, kill_all_async_requests_priv, uss720_probe.
**Step 5.2: TRACE CALLERS**
Record: get_1284_register() from change_mode(), parport read/status/control/EPP/ECP helpers, and **uss720_probe()** (line 734, Belkin/incompatible-cable check). Probe is a USB enumeration path; syzbot reaches it with a matching fake device that does not complete the control URB in 1s (HZ).
**Step 5.3: TRACE CALLEES**
Record: submit_async_request (alloc + URB submit), wait_for_completion_timeout, kill_all_async_requests_priv, kref_put → destroy_async (usb_free_urb, kfree(dr), list_del, kfree(rq), kref_put(priv)).
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: USB device add → uss720_probe → get_1284_register(..., ®, GFP_KERNEL) with non-NULL val (so it waits). Unprivileged USB gadget/dummy matching IDs in uss720_table[] can trigger it (syzbot). Real cables that NACK/timeout on that register read take the same path.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: set_1284_register() fire-and-forget puts immediately (no wait). Only get_1284_register() waits and had an unbalanced timeout path. 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:
- Tree: **Linux 7.3.0-rc4** (mainline-lineage checkout, detached HEAD).
- Driver and get_1284_register() timeout path **exist**.
- Bug introduced **2005**, before this branch. Not a post-7.3 bug.
- Working copy already has the kref_put (commit 15902712b9e2a is an ancestor of HEAD; first contained in **v7.3-rc1**). That is the original landing, not a reason to treat the leak as non-bugs.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean one-line add against the pre-fix function (parent blob matches the candidate diff). No refactor of this path in 7.3. **Clean apply.**
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This is the fix for that syzbot leak. No alternate timeout-path put. Probe unregister fixes are separate.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **USB misc / USS720 USB-to-parallel** (CONFIG_USB_USS720, depends on PARPORT). **PERIPHERAL** hardware, but probe is a standard USB path and is fuzzable.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: File is old and lightly touched; USB core is actively maintained. Greg KH merged the fix.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / config-specific** (CONFIG_USB_USS720). Anyone probing a matching USB ID (real USS720/Belkin-class cables, or a malicious/fuzzed USB device).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Control URB for register 0 does not complete within 1 second during probe (or later parport ops that pass a non-NULL val). Syzbot has a **C repro**. Not a theoretical race. Unprivileged local USB attach can trigger it; not a remote syscall by itself.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Memory leak** of priv + async request + URB + setup packet on each failed/timed-out probe. Repeated plug or syzbot-style enumeration can grow leaks. **HIGH** (DoS / kmemleak), not an oops by itself.
Syzbot: prio:high, DoS.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** high for this driver — stops a confirmed, reproducible leak on probe timeout; one-line; syzbot-tested.
- **Risk:** very low — one matching kref_put, error path only.
- **Ratio:** strongly in favor of including the fix in this tree.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real kmemleak with syzbot C repro and prio:high
- Unbalanced kref on a path that already puts on success
- One line, obviously correct, maintainer-merged, syzbot test OK
- Bug present since 2005; driver exists in 7.3
- No prerequisites, no new API
AGAINST:
- Peripheral USB-parport driver, not core MM/VFS
- Timeout may be uncommon on healthy hardware
- Competing usb_kill_urb change was not taken (not a dependency)
UNRESOLVED:
- Stable@ lore search HTTP 403
- Full Greg apply-thread body not fetched (msgid.link 403); merge + patch-id match via b4 is verified
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** (matches other puts; syzbot OK; Greg merged)
2. Fixes a real bug that affects users? **PASS** (kmemleak, C repro, probe of matching USB IDs)
3. Important issue? **PASS** (HIGH leak/DoS on USB probe; sanitizer- class resource leak)
4. Small and contained? **PASS** (+1 line, one function)
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** (same file/function; clean one- line)
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not an ID/quirk/DT/build/docs exception. Ordinary small bug fix.
**Step 9.4: DECISION**
This tree has the USS720 driver and the 2005 timeout path. Missing kref_put leaks the async request and keeps priv alive across a failed probe. The fix is the same put used on every other get_1284_register() exit. It meets stable rules for 7.3: real leak, tiny, no deps.
===============================================================
What the commit solves for this tree
===============================================================
get_1284_register() waits up to 1s for a USB control URB. On timeout it unlinked URBs but left the caller’s kref. uss720_probe() uses that helper to reject incompatible cables; a non-responsive matching device leaks priv, uss720_async_request, the URB, and the setup packet. That is exactly the syzbot kmemleak. Adding kref_put(..., destroy_async) closes the leak without changing success behavior.
Risk is negligible relative to stopping a reproducible probe leak.
===============================================================
Verification
===============================================================
- **[Phase 1]** Parsed subject/tags: syzbot Reported-by, two Links, Greg KH SOB; no Fixes/Cc stable
- **[Phase 2]** Diff: +1 line kref_put in get_1284_register() timeout path; parent blob confirmed missing put
- **[Phase 2]** kref model checked in current uss720.c: init + get in submit_async_request, put in async_complete and all other get_1284_register exits
- **[Phase 3]** git blame: timeout path 0f36163d3abef (2005); extra get adaa3c6342b249 (2011)
- **[Phase 3]** No Fixes tag; git log on file shows standalone commit
- **[Phase 3]** git merge-base --is-ancestor 15902712b9e2a HEAD → yes (original commit in this 7.3-rc4 checkout; first in v7.3-rc1)
- **[Phase 3]** Not in v7.1/v7.2 tags; post-fix syzbot crash SHAs are 7.2-rc and do not contain this commit
- **[Phase 4]** b4 dig -c/-w/-a/-m: msgid allaDTUua9n5DQ0a; CC Greg KH
+ linux-usb; competing usb_kill_urb patch questioned by David Laight
- **[Phase 4]** WebFetch syzbot: prio:high, C repro, leak stacks through probe/get_1284_register
- **[Phase 4]** lore.kernel.org HTTP 403 — used b4 mbox instead; stable@ search UNVERIFIED
- **[Phase 5]** Callers via grep: probe line 734 and parport ops; CONFIG_USB_USS720 in drivers/usb/misc/Kconfig
- **[Phase 6]** git describe HEAD / Makefile: 7.3.0-rc4; driver present; apply would be clean
- **[Phase 8]** Failure mode: kmemleak/DoS on USB probe timeout, severity HIGH
- **UNVERIFIED:** stable@ mailing-list archive text (HTTP 403)
**YES**
drivers/usb/misc/uss720.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/misc/uss720.c +1 -0
@@ -223,6 +223,7 @@ static int get_1284_register(struct parport *pp, unsigned char reg, unsigned cha }printk (KERN_WARNING "get_1284_register timeout\n" );kill_all_async_requests_priv (priv); +kref_put (&rq->ref_count, destroy_async);return -EIO ; }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] USB: misc: uss720: Fix leak in get_1284_register
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines
From: Michail Tatas <[email protected]>
[ Upstream commit
15902712b9e2a46649cba2f22002d05faec2a990]if
wait_for_completion_timeout()times out inget_1284_register()then we do not destroy the reference acquired viakref_get()insubmit_async_request. Add the missingkref_putin the timeout path.
Quoted 7 lines
Reported-by [email protected]Signed-off-by Michail Tatas <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 ALSA: hda: Add support for Hygon family 18h model 5h HD-Audio
In reply to Sasha LevinFrom: Fu Hao <[email protected]>
[ Upstream commit 41212ff3e4ed475d9f91d26b5324075087702987 ]
Add the new PCI ID 0x1d94 0x14a9 for Hygon family 18h model 5h HDA controller.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.18.53** (v6.18.53-5049-g0f0bdc2b0dffb). The verdict is only about this tree: the existing HD-Audio PCI driver is present, Hygon vendor IDs already exist, and this is a PCI ID addition to that driver.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ALSA/hda] [Add] [PCI ID 0x1d94:0x14a9 for Hygon family 18h model 5h HD-Audio controller]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Fixes: — none (expected)
- Reported-by: — none
- Tested-by: — none
- Reviewed-by: / Acked-by: — none on the commit
- Link: https://patch.msgid.link/8b38f2941375553e4246167736c6acb5a541 [email protected]
- Cc: [email protected] — none (expected)
- Signed-off-by: Fu Hao <[email protected]> (author)
- Signed-off-by: Takashi Iwai <[email protected]> (ALSA maintainer)
- Ignore pipeline Signed-off-by: Sasha Levin and [Upstream commit ...]
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
[Bug description] Hygon family 18h model 5h HD-Audio is missing from the existing Intel/generic HDA PCI ID table, so snd-hda-intel never binds. [Symptom] No HD-Audio controller on that SoC (no snd_hda_intel probe). [Version information] None in the message.
[Root cause] New PCI device vendor 0x1d94 / device 0x14a9 was never listed.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a hidden fix. This is explicit hardware enablement via a PCI ID. Cover letter (v3 0/7) calls it “initial support for the integrated HD-Audio controller.” A follow-up (v3 7/7) adds a dword-access quirk because byte writes to GCTL/SD_CTL fail on this controller.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: sound/hda/controllers/intel.c only (+7 lines, no deletions)
- Functions/data: #define PCI_DEVICE_ID_HYGON_18H_M05H_HDA, enum AZX_DRIVER_HYGON, driver_short_names[], azx_ids[]
- Scope: single-file surgical PCI ID + driver-type tag
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Before: azx_ids[] has Intel/AMD/ATI/Zhaoxin/Loongson/etc.; no Hygon entry. AMD/ATI class wildcards do not match vendor 0x1d94. Probe never runs for this device.
- After: PCI match PCI_VDEVICE(HYGON, 0x14a9) with AZX_DRIVER_HYGON | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_NO_MSI, then normal azx_probe().
- Path: PCI enumeration / module probe, not an error path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: [Hardware enablement / PCI ID] Existing driver does not claim this controller. New enum value is an internal tag (same pattern as Loongson/Zhaoxin), not a new driver. Caps reuse existing AZX_DCAPS_POSFIX_LPIB and AZX_DCAPS_NO_MSI.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Minimal and obviously correct. Regression risk is low and limited to this PCI ID. azx_max_codecs[] is sparse; HYGON stays 0, and azx_probe_codecs() treats 0 as AZX_DEFAULT_CODECS. Companion quirk (7/7) is needed for reliable register writes; this ID patch still compiles and applies alone.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record: Insertion is next to Loongson IDs (28bd137a3c8e1, 2023) and the table terminator ({ 0, }, ancient). Not a recent regression; the ID was never present. PCI_VENDOR_ID_HYGON (0x1d94) has been in include/linux/pci_ids.h since c6babb5806b77 (2018).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. N/A.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Related: 054940f79377d / upstream e096c24e7f97 — “Fix single byte writing issue for Hygon family 18h model 5h” (series 7/7). That patch depends on AZX_DRIVER_HYGON from this one. Other nearby HDA ID work (Lisuan, denylist) is unrelated. This ID commit is standalone for bind/enable; the quirk is a separate follow-up.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Fu Hao submitted the Hygon 18h models 4h–8h series (CPU topology, perf, microcode, HDA). Not the ALSA maintainer. Takashi Iwai applied both HDA patches to for-next.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs PCI_VENDOR_ID_HYGON, PCI_VDEVICE(), AZX_DCAPS_POSFIX_LPIB, AZX_DCAPS_NO_MSI, and sound/hda/controllers/intel.c (moved in 2d9223d2d64cb, already in v6.18.53). All present. Does not need series patches 1–5 (x86/perf/microcode). Patch 7/7 is recommended so audio actually works, but is not a compile/apply prerequisite.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record: b4 dig -c 41212ff3e4ed →
https://patch.msgid.link/8b38f2941375553e4246167736c6acb5a541e833.178152
[email protected]
Series: **[PATCH v3 0/7] Add support for Hygon family 18h models 4h-8h** (2026-06-15). This is **6/7**. b4 dig -a listed v3 as the matching series. v1→v2: switched to existing access_sdnctl_in_dword instead of a Hygon-specific flag; v2→v3: “Refine the code of Hygon HD-Audio device ID.” Takashi: “Applied to for-next branch now.” No NAK on 6/7 or 7/7.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: b4 dig -w recipients: Fu Hao, Bjorn Helgaas, Jaroslav Kysela ([email protected]), Takashi Iwai, linux-kernel, linux-sound, linux-pci, tingyin.duan. ALSA maintainers were on To/Cc. Takashi applied it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla. Hardware enablement from Hygon (open-hieco). No public crash report.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 1–5 are x86 CPU/perf/microcode (independent). 6 = this ID. 7 = dword-access quirk using AZX_DRIVER_HYGON. Audio support is 6+7; 6 is still a valid PCI ID addition by itself.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org /stable/ returned HTTP 403 (WebFetch and curl). UNVERIFIED whether stable@ discussed this ID.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: No function bodies changed. Data only: ID define, AZX_DRIVER_HYGON, driver_short_names, azx_ids[]. Runtime path is existing azx_probe().
**Step 5.2: TRACE CALLERS**
Record: azx_ids → azx_driver.id_table → PCI core → azx_probe() → azx_first_init() / azx_probe_continue(). Device-enumeration path, not IRQ/hot path until the device exists.
**Step 5.3: TRACE CALLEES**
Record: Unchanged. Probe uses existing PCI/HDA init, LPIB position fix, MSI disable.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace does not trigger it; PCI probe does on Hygon 18h m5h. No class wildcard for PCI_VENDOR_ID_HYGON (only Intel/Glenfly/NVIDIA/Creative/ATI/AMD). Without this ID, the controller is not claimed.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same pattern as Loongson (28bd137a3c8e1) and many other HDA PCI ID additions already in this tree (Alder Lake, Glenfly, AMD display HDA, etc.).
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. v6.18.53 azx_ids[] ends at Loongson then { 0, }. No Hygon entry. git merge-base --is-ancestor of the candidate vs v6.18.53 is false (not in 6.18.53). Driver file and PCI_VENDOR_ID_HYGON are present.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Dry-run apply of upstream 41212ff3e4ed onto v6.18.53 intel.c succeeded (patch -p1 --dry-run; later hunks applied at offsets because mainline grew extra IDs). Expected backport difficulty: **clean apply / trivial offsets**.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: v6.18.53 has no Hygon HDA ID and no Hygon dword-access quirk. access_sdnctl_in_dword already exists (Loongson). No alternate fix for 0x1d94:0x14a9.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: [sound/hda PCI controller] [IMPORTANT] — not core mm/net, but the standard HD-Audio stack used on PCs/servers with this SoC.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Active (denylists, Nvidia BDL, other PCI IDs). PCI ID table is the normal extension point. Maintainer Takashi Iwai applied the patch.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver-specific / platform-specific: Hygon family 18h model 5h with HD-Audio 0x1d94:0x14a9. Other machines unchanged.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Every boot on that hardware (PCI probe). Not a race. Not unprivileged-syscall. Without the ID, audio is simply missing.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: [No HD-Audio device bind] [MEDIUM for those users; exception- qualified] Not a panic. Follow-up 7/7: byte writes fail so audio can still be broken after bind if 7/7 is omitted.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record: Benefit: high for that hardware (enables existing driver). Risk:
very low (+7 lines, one PCI ID, existing caps). Ratio favors backport. Best if 7/7 is taken with it so GCTL/SD_CTL writes succeed.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Classic PCI ID addition to an existing driver (stable exception #1)
- Driver, path sound/hda/controllers/intel.c, and PCI_VENDOR_ID_HYGON all exist in 6.18.53
- No Hygon class wildcard; without this ID the device is never bound
- +7 lines, existing AZX_DCAPS_*, applies to v6.18.53
- Applied by ALSA maintainer Takashi Iwai
- Same pattern as Loongson and other HDA PCI IDs already in this tree
AGAINST:
- Part of series 6/7; 7/7 is the functional quirk (byte writes fail)
- No Reported-by / crash / CVE
- Adds an internal AZX_DRIVER_HYGON enum (needed for the quirk, not a UAPI)
UNRESOLVED:
- Stable mailing list (lore 403)
- How widely this SoC is deployed on 6.18-based distros
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — ID table entry; maintainer applied; v3 after review
2. Fixes a real bug that affects users? **PASS** — missing bind = no audio on this controller
3. Important issue? **PASS** under the device-ID exception (not a panic)
4. Small and contained? **PASS** — 7 lines, one file
5. No new features or APIs? **PASS** — existing driver, internal enum, no UAPI
6. Can apply to the local tree? **PASS** — dry-run on v6.18.53 intel.c succeeded
**Step 9.3: EXCEPTION CATEGORIES**
Record: **New device ID on an existing driver.** Also adjacent to a hardware quirk (7/7), which is a separate YES-class patch.
**Step 9.4: DECISION**
This is hardware enablement for a controller the 6.18.53 HDA driver already knows how to drive, blocked only by a missing PCI ID. That is standard stable material. Series patches 1–5 are unrelated. Patch 7/7 should also be considered so register writes work, but it does not make 6/7 unsuitable.
---
### What the commit solves for this tree
On 6.18.53, snd-hda-intel never matches Hygon 0x1d94:0x14a9. This adds that ID (with LPIB position fix and NO_MSI) so probe runs. That matters for users of Hygon 18h model 5h who stay on this LTS kernel.
### Risk vs benefit
Benefit is enabling audio hardware; risk is confined to that PCI ID. Companion quirk 7/7 should travel with it so byte-only GCTL/SD_CTL writes do not fail after bind.
### Concerns
Apply is clean. No missing symbols. Incomplete without 7/7 for full functionality, but 6/7 is still a valid, self-contained ID addition.
---
Verification:
- [Phase 1] Parsed tags: author Fu Hao, Link msgid, SOB Takashi Iwai; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: +7 lines in sound/hda/controllers/intel.c (define, enum, short name, azx_ids[])
- [Phase 2] Confirmed no generic Hygon HD-Audio class match; AMD/ATI wildcards only
- [Phase 2] azx_probe_codecs(..., 0) uses AZX_DEFAULT_CODECS (sound/hda/common/controller.c)
- [Phase 3] PCI_VENDOR_ID_HYGON since c6babb5806b77 (2018); present in v6.18.53 pci_ids.h:2616
- [Phase 3] File move 2d9223d2d64cb is ancestor of v6.18.53
- [Phase 3] git merge-base --is-ancestor <candidate> v6.18.53 → not in 6.18.53
- [Phase 3] Follow-up e096c24e7f97 / 054940f79377d is series 7/7 (dword access)
- [Phase 4] b4 dig -c 41212ff3e4ed: v3 6/7, lore msgid above; b4 dig -a: series v3 0/7; b4 dig -w: tiwai/perex/linux-sound
- [Phase 4] mbox: Takashi “Applied to for-next”; no NAK on HDA patches
- [Phase 4] UNVERIFIED: lore.kernel.org WebFetch/curl 403 (including /stable/)
- [Phase 5] Call chain: azx_ids → azx_probe (PCI enumeration)
- [Phase 6] make kernelversion / Makefile: 6.18.53; git describe HEAD: v6.18.53-5049-g0f0bdc2b0dffb
- [Phase 6] Dry-run patch -p1 of 41212ff3e4ed onto v6.18.53 intel.c: success
- [Phase 6] AZX_DCAPS_POSFIX_LPIB / AZX_DCAPS_NO_MSI present in v6.18.53
- [Phase 8] Failure mode: missing PCI bind → no HD-Audio on that SoC; severity medium, exception-qualified
**YES**
sound/hda/controllers/intel.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/hda/controllers/intel.c +7 -0
@@ -100,6 +100,8 @@ enum {#define ATIHDMI_NUM_CAPTURE 0#define ATIHDMI_NUM_PLAYBACK 8 +/* Hygon HD Audio controller */ +#define PCI_DEVICE_ID_HYGON_18H_M05H_HDA 0x14a9static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;
@@ -241,6 +243,7 @@ enum {AZX_DRIVER_ZHAOXIN ,AZX_DRIVER_ZHAOXINHDMI ,AZX_DRIVER_LOONGSON , +AZX_DRIVER_HYGON ,AZX_DRIVER_GENERIC , AZX_NUM_DRIVERS, /* keep this as last entry */ };
@@ -357,6 +360,7 @@ static const char * const driver_short_names[] = { [AZX_DRIVER_ZHAOXIN] = "HDA Zhaoxin", [AZX_DRIVER_ZHAOXINHDMI] = "HDA Zhaoxin HDMI", [AZX_DRIVER_LOONGSON] = "HDA Loongson", + [AZX_DRIVER_HYGON] = "HDA Hygon", [AZX_DRIVER_GENERIC] = "HD-Audio Generic", };
@@ -2814,6 +2818,9 @@ static const struct pci_device_id azx_ids[] = { .driver_data = AZX_DRIVER_LOONGSON | AZX_DCAPS_NO_TCSEL }, { PCI_VDEVICE(LOONGSON, PCI_DEVICE_ID_LOONGSON_HDMI), .driver_data = AZX_DRIVER_LOONGSON | AZX_DCAPS_NO_TCSEL }, + /* Hygon HDAudio */ + { PCI_VDEVICE(HYGON, PCI_DEVICE_ID_HYGON_18H_M05H_HDA), + .driver_data = AZX_DRIVER_HYGON | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_NO_MSI }, { 0, } };MODULE_DEVICE_TABLE (pci, azx_ids);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 smb/server: cancel async requests when closing connection
In reply to Sasha LevinFrom: ChenXiaoSong <[email protected]>
[ Upstream commit 4fd5bad647bfa45eb86bfd2f03ba1bef3fcd5851 ]
An async request may still be waiting when a connection is closed. This can stop the connection from closing.
Cancel active async requests before waiting for them to finish.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (p-6.12-3-gc504cf0baa3d8). The hang is in this tree: ksmbd_conn_handler_loop() waits for r_count == 0 without cancelling blocked SMB2_LOCK async work.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[smb/server (ksmbd)] [cancel] [cancel async requests when closing connection]**
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Suggested-by: Namjae Jeon <[email protected]> (ksmbd maintainer; he asked for this)
- Signed-off-by: ChenXiaoSong <[email protected]> (author)
- Signed-off-by: Namjae Jeon <[email protected]> (maintainer applied it)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Link:, or Cc:
stable (absence is expected)
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: an async request can still be waiting when the connection closes
- Symptom: connection teardown never finishes (wait_event on r_count never wakes)
- Root cause: teardown waits for pending work but does not invoke the same cancel_fn path that SMB2_CANCEL uses
- Version info: none in the message; mechanism is independent of CHANGE_NOTIFY
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. It is an explicit hang fix. The series cover letter says “in preparation for change notify,” but this patch describes a pre-existing teardown hang. In this 6.12 tree CHANGE_NOTIFY is still STATUS_NOT_IMPLEMENTED; SMB2_LOCK already waits asynchronously.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: fs/smb/server/connection.c only (~21 lines added)
- New helper: ksmbd_conn_cancel_async_requests()
- Call site: ksmbd_conn_handler_loop() after ksmbd_conn_set_releasing(), before wait_event(conn->r_count_q, ...)
- Scope: single-file surgical fix
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: handler loop exits → set RELEASING → sleep until r_count == 0 → disconnect. A worker blocked in ksmbd_vfs_posix_lock_wait() never drops r_count.
- After: same path, but first walk conn->async_requests under request_lock, mark ACTIVE work KSMBD_WORK_CANCELLED, and call cancel_fn so waiters wake and drain.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Category: hang / stuck kthread (logic/correctness: missing cancellation on teardown)
- Mechanism: SMB2_LOCK deferred wait holds an r_count ref. Teardown did not call smb2_remove_blocked_lock() (locks_delete_block + locks_wake_up). Same pattern as existing smb2_cancel(). Non-ACTIVE work is skipped (avoids the known file_lock UAF on CANCELLED/CLOSED).
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Quality: obviously correct; copies the smb2_cancel() ACTIVE + cancel_fn pattern
- Regression risk: low. cancel_fn under request_lock is already how smb2_cancel() works. cancel_fn may be NULL (oplock interim work); the new code checks that. Patch 3 of the series closes a remaining TOCTOU if setup_async_work() runs after this walk; that is a separate, rarer race, not a reason to reject this patch.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- wait_event(conn->r_count_q, atomic_read(&conn->r_count) == 0) comes from a14c573870a664 (“ksmbd: use wait_event instead of schedule_timeout()”, Jul 2022)
- ksmbd_conn_set_releasing() from abcc506a9a7197 (2023)
- Async cancel via cancel_fn has existed since cifsd (e2f34481b24db2, 2021)
- Buggy teardown wait has been in this lineage for years, including 6.12
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Not applicable.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- Related: ddb9239828336 / 89ae9df09d2c1 — UAF if cancel_fn is fired on non-ACTIVE deferred locks (already in this tree; this patch uses the same ACTIVE guard)
- setup_async_work() / release_async_work() already present
- This commit is not in HEAD (git log --grep='cancel async requests when closing' on fs/smb/server/ is empty)
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: ChenXiaoSong has other ksmbd backports in this tree (PDU size, etc.). Namjae Jeon is the ksmbd maintainer and both suggested and applied this.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: No code dependency on series patch 1 (signing). Patch 3 (setup_async_work refuses new async on EXITING/RELEASING) is complementary, not required for the helper or call site. All symbols (KSMBD_WORK_ACTIVE, async_requests, request_lock, cancel_fn, ksmbd_debug(CONN, ...)) exist here. Standalone apply is viable.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig cannot match a SHA that is not in this checkout (lore search from b4 also 403’d)
- Thread recovered from lore mirrors: https://ratatoskr.run/linux-
cifs/2026/07/17307517/t
- Series: [PATCH v3 0/3] smb/server: fix some bugs in preparation for change notify support
- v2→v3: this patch switched to list_for_each_entry_safe()
- Namjae: “Applied 0001 and 0002 patch to #ksmbd-for-next-next.” Patch 3 was rewritten separately.
- Later landed in the ksmbd 7.3-rc1 pull as “smb/server: cancel async requests when closing connection”
- No NAK. No reviewer objection to patch 2.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: Suggested-by and applied by Namjae Jeon. Recipients were linux- cifs / ksmbd maintainers (from the v3 thread).
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla. Found while implementing CHANGE_NOTIFY; author states the hang is a pre-existing bug. Trigger is concrete:
disconnect while SMB2_LOCK is deferred.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Patch 1 is unrelated signing. Patch 3/Namjae follow-up (“avoid registering async requests during connection close”) is a race follow- up. Patch 2 was applied on its own.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: No useful stable-list hit for this subject. Not previously rejected for stable (search did not surface a ksmbd discussion of this patch).
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: added ksmbd_conn_cancel_async_requests(); one call from ksmbd_conn_handler_loop().
Step 5.2: TRACE CALLERS
Record:
- ksmbd_conn_handler_loop() is the per-connection kthread (TCP/RDMA receive loop)
- After loop exit (client drop, PDU error, ksmbd_conn_alive() false, module stop)
Step 5.3: TRACE CALLEES
Record: spin_lock(request_lock), list walk, work->cancel_fn(work->cancel_argv). For lock waiters, smb2_remove_blocked_lock() → ksmbd_vfs_posix_lock_unblock() / locks_wake_up().
Step 5.4: FOLLOW THE CALL CHAIN
Record: Userspace/SMB client can trigger it: SMB2_LOCK that returns FILE_LOCK_DEFERRED → setup_async_work(..., smb2_remove_blocked_lock, ...) → ksmbd_vfs_posix_lock_wait() → client disconnect → handler wait_event(r_count). Reachable from a normal SMB session. In 6.12 the only long-lived async waiter with cancel_fn is SMB2_LOCK (smb2_notify() is a stub; oplock setup_async_work(in_work, NULL, NULL) is immediately released).
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: smb2_cancel() and set_close_state_blocked_works() already cancel this way. Teardown was the missing caller.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. fs/smb/server/connection.c ~522–524:
```
out:
ksmbd_conn_set_releasing(conn);
/* Wait till all reference dropped to the Server object*/
wait_event(conn->r_count_q, atomic_read(&conn->r_count) == 0);
```ksmbd_conn_cancel_async_requests is absent. r_count is inc’d in queue_ksmbd_work() and dec’d only when handle_ksmbd_work() finishes. Introduced with a14c573870a664 (2022), present throughout 6.12.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: First hunk (new helper after ksmbd_conn_try_dequeue_request) matches this tree. Second hunk context includes a later ksmbd_debug(CONN, "Wait for all pending requests...") line that 6.12 does not have. Expected difficulty: **minor context tweak** — insert the one call after ksmbd_conn_set_releasing(conn).
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No equivalent cancel-on-close. UAF guards on smb2_cancel() are already here and align with this patch’s ACTIVE check.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: fs/smb/server (ksmbd). **IMPORTANT** for systems that enable CONFIG_SMB_SERVER; not core VFS/mm. Default is n.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Actively developed; many ksmbd stable backports already on this 6.12 branch. The hang itself is old, not a 7.x-only feature bug.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: ksmbd users (CONFIG_SMB_SERVER) who have a client block on SMB2_LOCK and then drop the connection. Also anyone unloading ksmbd while such a connection exists (stop_sessions() keeps looping until connections are gone).
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Byte-range lock conflict + disconnect/network drop. Not every connection; common SMB clients do use locks. Unprivileged SMB clients on an exported share can trigger it. Not a tiny race: the waiter is already parked on flc_wait.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: Connection kthread sleeps forever in wait_event; connection never fully released; module teardown can stall in stop_sessions(). **Severity: HIGH** (hang / stuck kthread; not a panic, not data corruption).
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: high for ksmbd — prevents teardown/unload hangs
- Risk: low — ~21 lines, one file, established cancel path
- Ratio: favors backport
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real hang in this 6.12 tree when SMB2_LOCK is deferred across disconnect
- Small, obviously correct, maintainer-suggested and applied
- Same cancel protocol as smb2_cancel(), with the ACTIVE guard already required here
- No missing types/helpers in this tree
AGAINST:
- Series was framed around CHANGE_NOTIFY (not in 6.12 as a real waiter)
- Follow-up patch 3 not included (rarer TOCTOU)
- ksmbd is config-optional
- No public crash report / syzbot
UNRESOLVED:
- Could not b4 dig a local SHA (commit not in this checkout)
- lore.kernel.org fetches returned 403; used ratatoskr/openwall mirrors instead
- No stable-list discussion found
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — mirrors smb2_cancel(); maintainer applied v3
2. Fixes a real bug that affects users? **PASS** — teardown hang on deferred lock + disconnect
3. Important issue? **PASS** — hang / stuck connection kthread (HIGH)
4. Small and contained? **PASS** — one file, ~21 lines
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — bug present; one-line context adjustment for missing debug print
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: None (not an ID/quirk/DT/build/docs exception). It is a normal hang fix.
Step 9.4: MAKE YOUR DECISION
This is a hang fix that belongs on 6.12. The CHANGE_NOTIFY framing is not a reason to skip it: the waiter that deadlocks teardown is already SMB2_LOCK. Patch 3 is a nice follow-up, not a prerequisite for this change to be correct for already-queued async work.
Verification:
- [Phase 1] Parsed tags: Suggested-by/SOB Namjae Jeon; author ChenXiaoSong; no Fixes/Cc/Reported-by
- [Phase 2] Diff: +21 lines in connection.c; helper + one call before wait_event
- [Phase 3] git describe HEAD / make kernelversion: 6.12.111, p-6.12-3-gc504cf0baa3d8
- [Phase 3] git blame on wait path: a14c573870a664 (2022) introduced wait_event without async cancel
- [Phase 3] git log --grep='cancel async requests when closing' -- fs/smb/server/: empty — not in this tree
- [Phase 3] git merge-base --is-ancestor ddb9239828336 HEAD: yes — ACTIVE-state UAF guard already present
- [Phase 3] Confirmed ksmbd_conn_try_dequeue_request / ksmbd_conn_lock match insertion context
- [Phase 4] b4 dig on a local SHA: lore 403; candidate commit not in tree
- [Phase 4] v3 thread: Namjae applied 0001 and 0002; patch 3 rewritten
- [Phase 4] 7.3-rc1 ksmbd pull lists this subject
- [Phase 5] setup_async_work callers: smb2_lock (real waiter) and oplock (NULL cancel_fn, immediate release)
- [Phase 5] smb2_notify() in this tree returns STATUS_NOT_IMPLEMENTED
- [Phase 6] Local lines 521–524: set_releasing then wait_event, no cancel
- [Phase 6] Backport: helper applies cleanly; call site needs dropping unavailable debug context
- [Phase 8] Failure mode verified: queue_ksmbd_work incs r_count; lock wait never returns so ksmbd_conn_r_count_dec never runs
- UNVERIFIED: original lore.kernel.org HTML (403); no stable@ thread found
**YES**
fs/smb/server/connection.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
fs/smb/server/connection.c +21 -0
@@ -232,6 +232,26 @@ void ksmbd_conn_try_dequeue_request(struct ksmbd_work *work)wake_up_all (&conn->req_running_q); } +static void ksmbd_conn_cancel_async_requests (struct ksmbd_conn *conn) +{ +struct ksmbd_work *work, *tmp; + +ksmbd_debug (CONN ,"Cancel pending async requests on releasing connection\n" ); +spin_lock (&conn->request_lock); +list_for_each_entry_safe (work, tmp, &conn->async_requests, + async_request_entry) { +if (work->state !=KSMBD_WORK_ACTIVE ) +continue ; + +ksmbd_debug (CONN ,"Cancel async request id %d\n" , + work->async_id); + work->state =KSMBD_WORK_CANCELLED ; +if (work->cancel_fn) + work->cancel_fn (work->cancel_argv); + } +spin_unlock (&conn->request_lock); +} +void ksmbd_conn_lock (struct ksmbd_conn *conn) {mutex_lock (&conn->srv_mutex);
@@ -543,6 +563,7 @@ int ksmbd_conn_handler_loop(void *p) out:ksmbd_conn_set_releasing (conn); +ksmbd_conn_cancel_async_requests (conn);/* Wait till all reference dropped to the Server object*/ ksmbd_debug (CONN ,"Wait for all pending requests(%d)\n" ,atomic_read (&conn->r_count));wait_event (conn->r_count_q,atomic_read (&conn->r_count) ==0 );
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 nvme-auth: use crypto_memneq for DH-HMAC-CHAP response comparison
In reply to Sasha LevinFrom: Xixin Liu <[email protected]>
[ Upstream commit 3a6d89836ab09d53f4c32c57588689a378ce4363 ]
DH-HMAC-CHAP authentication compares HMAC response digests with memcmp(). Standard memcmp() may stop at the first differing byte, which can leak timing information to a remote attacker and allow incremental recovery of the expected digest.
Use crypto_memneq() for constant-time comparison on both the host path that validates the controller Success1 response and the target path that validates the host Reply digest. Other memcmp() uses in the NVMe auth code (e.g. fixed string prefix checks) are not security-sensitive and are left unchanged.
---
LLM Generated explanations, may be completely bogus:
The local tree is **v7.3-rc4** (7.3.0-rc4, f0100363d8c37). The commit under review is 3a6d89836ab09 (“nvme-auth: use crypto_memneq for DH-HMAC-CHAP response comparison”). It is already an ancestor of HEAD (landed in v7.3-rc1). That does not decide the backport question; the decision below is on technical merit and whether the bug exists in this lineage.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[nvme-auth]** **[use]** Replace memcmp() with crypto_memneq() when comparing DH-HMAC-CHAP HMAC response digests.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Fixes: — none (expected)
- Reported-by: — none
- Tested-by: — none
- Reviewed-by: Hannes Reinecke <[email protected]> (author of the original NVMe in-band auth code)
- Reviewed-by: Christoph Hellwig <[email protected]>
- Link: — none in the commit
- Cc: [email protected] — none (expected)
- Signed-off-by: Xixin Liu <[email protected]> (author)
- Signed-off-by: Keith Busch <[email protected]> (NVMe maintainer)
- Ignore pipeline Signed-off-by: Sasha Levin if present; it is not in this commit
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** DH-HMAC-CHAP compares HMAC response digests with memcmp(), which can return at the first differing byte.
- **Symptom/failure mode:** Timing leak of how far the computed HMAC matches the expected digest; a remote attacker could try to recover the expected digest incrementally.
- **Version information:** none in the message. Keith later said on-list it was applied “for 7.2”; git merge-base --is-ancestor shows it is **not** in v7.2 and **is** in v7.3-rc1.
- **Root cause (author):** variable-time comparison of authentication MAC material.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is an explicit security/correctness
change: secret MAC comparison must be constant-time. The remaining memcmp() uses (string prefixes, GUIDs) are called out as non-sensitive and left alone.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- drivers/nvme/host/auth.c: +2 / −1 (#include <crypto/utils.h>; memcmp → crypto_memneq in nvme_auth_process_dhchap_success1)
- drivers/nvme/target/fabrics-cmd-auth.c: +2 / −1 (same include; memcmp → crypto_memneq in nvmet_auth_reply)
- **Scope:** two-file surgical fix, 4 insertions, 2 deletions. No API, Kconfig, or data-structure changes.
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Host (nvme_auth_process_dhchap_success1):** after data->hl == chap->hash_len and data->rvalid, the host used to memcmp(chap->response, data->rval, data->hl). Now crypto_memneq(...). Failure still sets NVME_AUTH_DHCHAP_FAILURE_FAILED and returns -ECONNREFUSED.
- **Target (nvmet_auth_reply):** after computing the expected host HMAC into response, the target used to memcmp(data->rval, response, data->hl). Now crypto_memneq(...). Failure still frees response and returns NVME_AUTH_DHCHAP_FAILURE_FAILED.
- Affected path: authentication success/reply validation only, not probe/init/error-unrelated code.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Memory safety / crypto side channel]** Variable-time memcmp() on HMAC digests. crypto_memneq() (include/crypto/utils.h) is documented as “Compare two areas of memory without leaking timing information” and returns 0 if equal, 1 otherwise — same boolean sense as if (memcmp(...)).
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct and minimal. Length data->hl is already checked against chap->hash_len on the host path. Return-value polarity matches. Regression risk is very low: same control flow, slightly more work per compare (HMAC length is 32–64 bytes). No new locks, APIs, or userspace ABI.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Host memcmp: introduced in f50fff73d620cd (“nvme: implement In- Band authentication”, Hannes Reinecke, 2022). **In v6.0**, not in v5.19.
- Target memcmp: introduced in db1312dd95488b (“nvmet: implement basic In-Band Authentication”). Same merge window, **v6.0**.
- The buggy comparison has been in tree for many years.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The introducing commits above are the functional equivalent. Both are ancestors of this tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent work on these files is auth bounds-checking, hashing updates, and secure-channel concatenation. This commit is standalone (subject is not N/M). No prerequisite refactor is required for the two-line swap plus include.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Xixin Liu is a contributor, not the NVMe auth maintainer. Weight comes from **Reviewed-by Hannes Reinecke** (original auth author) and **Christoph Hellwig**, applied by **Keith Busch**.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Depends only on crypto_memneq() / <crypto/utils.h>. In this tree, include/crypto/utils.h exists (c616fb0cbae8, 2023) and CONFIG_CRYPTO selects CRYPTO_LIB_UTILS (lib/crypto/memneq.c). NVME_AUTH already select CRYPTO. Standalone on this tree.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 3a6d89836ab09 → https://patch.msgid.link/0001.nvme-auth-
[email protected]
- b4 dig -a: **v1 only** (no v2/v3). Applied as submitted.
- Thread (mbox): Christoph: “Looks good” + Reviewed-by. Hannes:
Reviewed-by. No NAK, no stable discussion, no requested changes.
- Keith (2026-09-15): applied earlier; pointed at 3a6d89836ab09.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc included [email protected], Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni, Hannes Reinecke. Right maintainers were on the patch.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by, bugzilla, or syzbot. This is code-audit / crypto-hygiene, not a user crash report.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Cover was [PATCH v1 0/1] / [PATCH v1 1/1] — single patch. Precedent in this tree: ksmbd: Compare MACs in constant time (c5794709bc910, had Cc: stable); scsi: target: Use constant-time crypto_memneq() for CHAP digests (cf14fc2be8688); TPM/SMB client similar replacements.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** on lore.kernel.org/stable (WebFetch 403, WebSearch failed). The original NVMe thread never mentions stable@.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: nvme_auth_process_dhchap_success1, nvmet_auth_reply. Includes only otherwise.
**Step 5.2: TRACE CALLERS**
Record:
- nvme_auth_process_dhchap_success1 ← nvme_queue_auth_work in drivers/nvme/host/auth.c (DH-HMAC-CHAP Success1 after AUTH_RECEIVE). Queued from connect / dhchap_auth_work / sysfs re-auth.
- nvmet_auth_reply ← nvmet_execute_auth_send when the DH-HMAC-CHAP step is Reply. nvmet_execute_auth_send is the fabrics AUTH_SEND execute handler (drivers/nvme/target/fabrics-cmd.c).
**Step 5.3: TRACE CALLEES**
Record: Target computes expected HMAC via nvmet_auth_host_hash() (HMAC over challenge dhchap_c1, transformed host key, etc.), then compares. Host compares precomputed chap->response to controller rval. No allocation/locking change in the hunks.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: **Reachable from the network** on an NVMe-oF target with CONFIG_NVME_TARGET_AUTH. An unauthenticated remote host sending AUTH_SEND Reply hits nvmet_auth_reply. Host path is hit when connecting with in-band auth / bidirectional controller auth. Not a syscall smash; it is the authentication protocol itself.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: After this commit, no remaining memcmp of HMAC material in drivers/nvme/host/auth.c or drivers/nvme/target/fabrics-cmd-auth.c. Other NVMe memcmp uses are prefix/GUID/debugfs checks, which the commit correctly left alone.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes, in this lineage since v6.0. This checkout already contains the fix (crypto_memneq at drivers/nvme/host/auth.c:365 and drivers/nvme/target/fabrics-cmd-auth.c:189). The pre-fix memcmp is in 3a6d89836ab09^.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply on this tree** (already applied). Include is <crypto/utils.h>, which this 7.3 tree has. For much older stables the header was crypto/algapi.h; that is not a problem **here**.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This *is* the fix in this tree. No earlier alternate memneq conversion on these files.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: NVMe over Fabrics in-band authentication (drivers/nvme/host/auth.c, drivers/nvme/target/fabrics-cmd-auth.c). **IMPORTANT** for NVMe-oF deployments that enable auth; not core mm/VFS.
Configs: NVME_HOST_AUTH / NVME_TARGET_AUTH (help text “If unsure, say N”), both select NVME_AUTH.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained (recent OOB/auth bounds fixes on the same files). Auth itself has been stable in design since 2022.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Config-specific (NVME_HOST_AUTH / NVME_TARGET_AUTH) and only during DH-HMAC-CHAP. Target comparison is the access-control check for remote hosts.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Every in-band auth exchange that validates an HMAC response. Target path: remote peer during AUTH_SEND Reply. Host path:
bidirectional controller auth when rvalid is set. Unprivileged remote initiator can hit the target compare if the subsystem is enabled.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Timing side channel on authentication MACs.** Severity **HIGH** as a security defect (auth protocol using variable-time compare). Practical “byte-by-byte recover the static secret” is weaker than the commit text implies: nvmet_auth_host_hash() HMACs a per- session challenge (dhchap_c1), so the expected digest is not a stable value across attempts. Same caveat as the SCSI CHAP memneq patch. It is still the wrong primitive for MAC compare; ksmbd’s analogous change was Cc: stable.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record: **Benefit: high** for NVMe-oF auth users (closes a real class of crypto bug on a remote-facing check). **Risk: very low** (4 insertions, same branches, standard helper). Ratio strongly favors applying it.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real crypto bug: memcmp on HMAC responses in DH-HMAC-CHAP
- Remote-facing target auth path
- 4-line, obviously correct replacement with the kernel’s constant-time helper
- Reviewed by Hannes Reinecke and Christoph Hellwig; applied by Keith Busch
- Bug present since v6.0; crypto_memneq already available here
- Same pattern as other MAC compares that stable has taken (e.g. ksmbd)
- No new feature/API; no locking/ABI change
**AGAINST:**
- Optional Kconfig (default N)
- No CVE/syzbot/user report
- Incremental digest recovery is harder than the message states because HMAC input includes a unique challenge
- No in-thread Cc: stable
**UNRESOLVED:**
- Whether stable@ ever discussed this (lore stable search failed)
- Practical remote exploitability over NVMe-oF (network jitter)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — polarity of crypto_memneq matches memcmp; reviewed by auth author and NVMe core reviewers; in mainline since 7.3-rc1.
2. Fixes a real bug that affects users? **PASS** — wrong comparison primitive on live HMAC auth; users with NVMe-oF in-band auth are affected.
3. Important issue (crash, security, corruption, deadlock)? **PASS** — security (timing leak on authentication MAC), HIGH.
4. Small and contained? **PASS** — 2 files, +4/−2.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — already applied; <crypto/utils.h> and CRYPTO_LIB_UTILS are present.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. It is a small security fix, which is in-scope for stable on its own.
**Step 9.4: MAKE YOUR DECISION**
This is a small, maintainer-reviewed security fix for NVMe-oF DH-HMAC-
CHAP: the host Success1 path and the target Reply path compared HMAC digests with memcmp(). That can leak match length. crypto_memneq() is the established kernel helper; control flow is unchanged. The code has existed since v6.0, applies cleanly here, and does not need extra commits.
Even if full incremental recovery of a static digest is unlikely because each HMAC includes a fresh challenge, stable trees should not leave authentication MACs on a variable-time compare. Risk is negligible; benefit is closing a real crypto-hygiene hole on a network-facing auth check.
### What problem it solves and why it matters
DH-HMAC-CHAP is NVMe-oF in-band authentication. The target decides whether the host’s Reply HMAC is correct; the host (when bidirectional) decides whether the controller’s Success1 HMAC is correct. Using memcmp() can stop at the first mismatch and leak timing. Stable users who enable this optional auth still need that check to be constant-time.
### Stable rules
The patch is obviously correct, tiny, already reviewed, and does not add features. It fixes a security issue, not a style nit.
### Risk vs benefit
Very low regression risk versus a meaningful security improvement for NVMe-oF auth. Header/CRYPTO_LIB_UTILS dependencies are already satisfied in this 7.3 tree.
### Concerns
Exploitability is weaker than a static-secret memcmp leak; feature is optional. Neither outweighs applying a 4-line, standard crypto fix.
Verification:
- [Phase 1] Parsed commit 3a6d89836ab09: no Fixes/Reported- by/Cc:stable; Reviewed-by Hannes Reinecke and Christoph Hellwig; SOB Keith Busch
- [Phase 2] Diff: +#include <crypto/utils.h> and memcmp→crypto_memneq in nvme_auth_process_dhchap_success1 and nvmet_auth_reply (+4/−2)
- [Phase 2] include/crypto/utils.h: crypto_memneq returns 0 if equal, 1 otherwise — matches if (memcmp(...))
- [Phase 3] git blame on parent: host memcmp from f50fff73d620cd (v6.0); target from db1312dd95488b (v6.0)
- [Phase 3] git merge-base --is-ancestor f50fff73d620cd v6.0 yes; v5.19 no
- [Phase 3] No Fixes tag to follow
- [Phase 3] Standalone 1/1 series; NVME_AUTH selects CRYPTO; CRYPTO selects CRYPTO_LIB_UTILS
- [Phase 4] b4 dig -c 3a6d89836ab09: lore msgid 0001.nvme-auth- [email protected]
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: linux-nvme plus Busch/Axboe/Hellwig/Grimberg/Kulkarni/Reinecke
- [Phase 4] mbox: Christoph “Looks good”; Hannes Reviewed-by; no NAK;
Keith: applied as 3a6d89836ab09
- [Phase 4] WebFetch lore 403; WebSearch failed; stable-list discussion UNVERIFIED
- [Phase 5] Callers: host auth workqueue; target nvmet_execute_auth_send ← fabrics AUTH_SEND (remote)
- [Phase 5] nvmet_auth_host_hash HMACs dhchap_c1 (per-session challenge) — verified in drivers/nvme/target/auth.c
- [Phase 5] No leftover HMAC memcmp in the two auth files
- [Phase 6] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion: 7.3.0-rc4
- [Phase 6] git merge-base --is-ancestor 3a6d89836ab09 HEAD yes; not in v7.2; yes in v7.3-rc1
- [Phase 6] Local files already use crypto_memneq at the two call sites
- [Phase 8] Failure mode: timing leak on auth MAC compare; severity HIGH (security); trigger: NVMe-oF in-band auth
- UNVERIFIED: practical remote exploitability; whether stable@ already discussed the patch
**YES**
drivers/nvme/host/auth.c | 3 ++- drivers/nvme/target/fabrics-cmd-auth.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/nvme/host/auth.c +2 -1
@@ -9,6 +9,7 @@#include <linux/unaligned.h> #include <crypto/hash.h> #include <crypto/dh.h> +#include <crypto/utils.h> #include "nvme.h" #include "fabrics.h" #include <linux/nvme-auth.h>
@@ -381,7 +382,7 @@ static int nvme_auth_process_dhchap_success1(struct nvme_ctrl *ctrl,return 0 ;/* Validate controller response */ -if (memcmp (chap->response, data->rval, data->hl)) { +if (crypto_memneq (chap->response, data->rval, data->hl)) {dev_dbg (ctrl->device,"%s: qid %d ctrl response %*ph\n" , __func__, chap->qid, (int )chap->hash_len, data->rval); dev_dbg(ctrl->device, "%s: qid %d host response %*ph\n",
drivers/nvme/target/fabrics-cmd-auth.c +2 -1
@@ -10,6 +10,7 @@#include <linux/nvme-auth.h> #include <crypto/hash.h> #include <crypto/kpp.h> +#include <crypto/utils.h> #include "nvmet.h" static void nvmet_auth_expired_work (struct work_struct *work)
@@ -187,7 +188,7 @@ static u8 nvmet_auth_reply(struct nvmet_req *req, void *d, u32 tl)return NVME_AUTH_DHCHAP_FAILURE_FAILED ; } -if (memcmp (data->rval, response, data->hl)) { +if (crypto_memneq (data->rval, response, data->hl)) {pr_info ("ctrl %d qid %d host response mismatch\n" , ctrl->cntlid, req->sq->qid); pr_debug("ctrl %d qid %d rval %*ph\n",
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 HID: multitouch: Fix stale MT slots when contact count drops to zero
In reply to Sasha LevinFrom: Dave Carey <[email protected]>
[ Upstream commit e8e60b6439eed340a611e9d7a5b9bcbd0ef62725 ]
The INGENIC 17EF:6161 touchscreen (Lenovo Yoga Book 9 14IAH10) reports HID_DG_CONTACTCOUNT=0 in the frame immediately following the last finger lift rather than omitting the frame entirely. In mt_touch_report() the existing code only updates num_expected when contact_count is non-zero, so a zero contact count on the first packet of a new frame leaves num_expected at its previous value (e.g. 2 for a two-finger gesture). The sync check "num_received >= num_expected" then evaluates "0 >= 2" and never fires, preventing INPUT_MT_DROP_UNUSED from releasing the stale slots. Those slots remain active in the kernel MT layer until the next touch, at which point they are released in a batch alongside the new contact — causing the userspace event consumer to miss the intervening finger-up sequence and corrupt its gesture session state.
Fix by resetting num_expected to 0 when contact_count is zero and num_received is still 0 (i.e., this is the first and only packet of the frame, not a continuation packet in a multi-packet sequence). With num_expected=0 the sync check "0 >= 0" fires immediately, calling input_mt_sync_frame() which drops the stale slots via INPUT_MT_DROP_UNUSED.
The num_received==0 guard is critical: continuation packets in a multi-packet frame arrive after at least one contact has already been processed (num_received>0), so they are correctly excluded from this path and the existing multi-packet logic is unaffected.
---
LLM Generated explanations, may be completely bogus:
I have enough to decide: the buggy num_expected path is in this 6.12 tree, the Yoga Book 9 prerequisites are already here, and the patch applies cleanly.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: PARSE THE SUBJECT LINE
Record: **[HID: multitouch:] [Fix] [stale MT slots when a zero ContactCount sentinel frame never syncs, so unused slots are not dropped]**
### Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- **Fixes:** none (expected for this review)
- **Reported-by:** none
- **Tested-by:** Dave Carey \<[email protected]\> (author tested on the affected laptop)
- **Reviewed-by:** none in the commit; HID maintainer Benjamin Tissoires reviewed on-list and applied it
- **Acked-by:** none
- **Link:** none in the commit
- **Cc: stable:** none (expected)
- **Signed-off-by:** Dave Carey (author); Benjamin Tissoires (HID maintainer)
- Ignore pipeline-added Sasha Levin SOB / [Upstream commit ...] if present
### Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** INGENIC 17EF:6161 (Lenovo Yoga Book 9 14IAH10) sends HID_DG_CONTACTCOUNT=0 on the frame after the last finger lift. mt_touch_report() only updates num_expected when contact_count is non-zero, so a first packet with count 0 leaves num_expected at the previous value (e.g. 2).
- **Symptom / failure mode:** num_received >= num_expected becomes `0
Quoted 1 line
= 2
and never fires.INPUT_MT_DROP_UNUSED` does not run. Slots stay
active until the next touch, then are released together with the new contact. Userspace misses the finger-up sequence and corrupts gesture state (stuck touch).
- **Version info:** none in the message. Logic has been in hid- multitouch since 2017; this hardware/class is recent.
- **Root cause:** zero ContactCount on the first packet of a new frame is treated as a multi-packet continuation instead of “no contacts.”
### Step 1.4: DETECT HIDDEN BUG FIXES
Record: **Not a hidden fix.** Subject and body describe a real input- correctness bug and the exact num_expected mechanism.
---
## PHASE 2: DIFF ANALYSIS
### Step 2.1: INVENTORY THE CHANGES
Record:
- **File:** drivers/hid/hid-multitouch.c — one hunk in mt_touch_report() (~8 insertions / ~11 deletions, net −3)
- **Scope:** single-file surgical logic change in the ContactCount handling block
### Step 2.2: UNDERSTAND THE CODE FLOW CHANGE Current code in this tree (drivers/hid/hid-multitouch.c):
```1254:1269:drivers/hid/hid-multitouch.c
if (contact_count >= 0) {
/*
- For Win8 PTPs the first packet (td->num_received == 0) may
- have a contactcount of 0 if there only is a button event.
- ...
*/
if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) &&
app->num_received == 0 &&
app->prev_scantime != scantime)
app->num_expected = contact_count;
/* A non 0 contact count always indicates a first packet
*/
else if (contact_count)
app->num_expected = contact_count;
}
```Record:
- **Before:** contact_count > 0 → set num_expected. contact_count == 0 on a new first packet → set num_expected = 0 **only** if MT_QUIRK_WIN8_PTP_BUTTONS. Otherwise leave the previous num_expected. Continuation packets with count 0 are left unchanged.
- **After:** contact_count > 0 → set num_expected. Else if num_received == 0 and scantime changed → num_expected = 0 for **all** devices. Continuation packets still skipped (num_received > 0 or same scantime).
- **Path:** HID report processing for every hid-multitouch device that reports ContactCount; not an error/init-only path.
### Step 2.3: IDENTIFY THE BUG MECHANISM
Record: **[Logic / correctness] + [hardware firmware workaround]**
When ContactCount is 0 on a new frame, num_expected is not reset, so mt_sync_frame() / input_mt_sync_frame() never run and INPUT_MT_DROP_UNUSED cannot release slots.
This tree already has MT_QUIRK_CONTACT_CNT_ACCURATE on Yoga Book 9 (4dfad42f0610f). With a stale num_expected of N, a 0-count frame can still process N ghost slots (ALWAYS_VALID skips tip-state validity), then sync those ghosts as live contacts. Resetting num_expected to 0 makes the accurate-count guard skip every slot (0 >= 0) and then drop unused slots.
### Step 2.4: ASSESS THE FIX QUALITY
Record:
- **Quality:** Minimal rewrite of one conditional. Continuation packets still guarded. Win8 PTP button-only frames (contact_count == 0, first packet, scantime changed) keep working, without requiring the quirk.
- **Regression risk:** Low–medium: the WIN8_PTP_BUTTONS gate is removed, so any hid-multitouch device that reports ContactCount and a new-frame scantime can now treat a 0-count first packet as “all up.” HID maintainer and hid-tools tests accepted that. Dropping the outer contact_count >= 0 wrapper means contact_count == -1 (no ContactCount field) can take the else-if; maintainer later called that semantically misleading but harmless because num_expected stays 0.
---
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: BLAME THE CHANGED LINES
Record:
- Multi-packet “zero contactcount” comment: c2517f62dac608 (Benjamin Tissoires, 2013)
- Win8 PTP 0-touch handling: **af8dc4d094909 (“HID: multitouch:
Properly deal with Win8 PTP reports with 0 touches”, Hans de Goede, 2017-11-22)**
- Application-level num_expected: f146d1c4d7eafd / 01eaac7e57134 (2018)
- git merge-base --is-ancestor af8dc4d094909 HEAD → **yes** (exit 0). Buggy pattern is old and present here.
### Step 3.2: FOLLOW THE FIXES: TAG
Record: **No Fixes: tag.** Introduced behavior is the 2017 Win8 PTP special case that never treated a generic 0-count sentinel as end-of- frame.
### Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record (this tree, drivers/hid/hid-multitouch.c):
- bdaabb4cf6603 — Yoga Book 9i quirks / MT_CLS_YOGABOOK9I
- a7359de3c246b — Yoga Book 9 14IAH10 misclassification; adds MT_QUIRK_NOT_SEEN_MEANS_UP (INPUT_MT_DROP_UNUSED)
- 4dfad42f0610f — Honor ContactCount ghost-contact suppression (MT_QUIRK_CONTACT_CNT_ACCURATE)
- This candidate is the remaining Yoga Book 9 hid-multitouch fix (author said so on-list)
Standalone: yes. v1 cover letter: independent of the ghost-contacts patch; both sit on the misclassification commit. That misclassification **is already in this tree.**
### Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Dave Carey is the Yoga Book 9 hid-multitouch contributor, not the subsystem maintainer. Same-file commits here: a7359de3c246b, 4dfad42f0610f. Maintainer Benjamin Tissoires applied this one to hid.git for-7.3/upstream-fixes.
### Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS Record:
- Needs existing mt_touch_report() ContactCount / scantime / num_expected logic — present since 2017–2018.
- For Yoga Book 9 specifically, MT_QUIRK_NOT_SEEN_MEANS_UP (so INPUT_MT_DROP_UNUSED is set) is already here via a7359de3c246b.
- git merge-base --is-ancestor e8e60b6439eed HEAD → **no** (not in this tree).
- Applies standalone; git apply --check succeeded (hunk offset −70 lines).
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
### Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c e8e60b6439eed:
https://patch.msgid.link/[email protected]
- **v1** (2026-05-15):
https://patch.msgid.link/[email protected]
— added an else if (num_received == 0) branch
- **v2** (2026-05-22): sent as [PATCH 2/5] in reply to v1; maintainers did not treat it as a proper respin
- **v3** (2026-07-30): same code as v2; standalone subject. Applied 2026-08-25
- lore.kernel.org WebFetch returned 403; thread recovered via b4 dig -m and b4 mbox
Key review:
- Benjamin on v1: hid-tools testsuite still happy; asked to flatten the if/else and add prev_scantime != scantime
- Benjamin on v3: contact_count == -1 path is misleading but harmless; negative ContactCount would be clamped to 0 (improvement)
- Applied to hid.git for-7.3/upstream-fixes as e8e60b6439ee
- No NAK. AI review noted an unrelated pre-existing sticky-finger timer UAF in mt_remove(), not introduced here
- No reviewer Cc: stable
### Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To/Cc [email protected], Jiri Kosina ([email protected]), Benjamin Tissoires ([email protected]). HID maintainer reviewed and merged.
### Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla. Author described HID capture behavior and tested on Yoga Book 9 14IAH10 (83KJ). Same author as the two Yoga Book 9 commits already in this tree.
### Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Intended as the last of three Yoga Book 9 hid-multitouch fixes. The other two are already in this 6.12 tree. v2’s “2/5” was a mistaken subject, not a hard series dependency. No later same-file follow-up on origin/master besides an unrelated ASUS ROG Z13 quirk.
### Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: No stable@ discussion found. Commit has no Cc: stable. Not a negative signal.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1: IDENTIFY KEY FUNCTIONS
Record: **mt_touch_report()** only. Nearby: mt_sync_frame(), mt_process_slot(), mt_touch_input_configured().
### Step 5.2: TRACE CALLERS
Record: Only caller is mt_report() when rdata->is_mt_collection. That is the HID .report callback for incoming device reports. Interrupt/HID-completion context, not a syscall. Triggered by touching the panel. CONFIG_HID_MULTITOUCH (drivers/hid/Kconfig).
### Step 5.3: TRACE CALLEES
Record: Reads app->raw_cc / app->scantime; walks slots via mt_process_slot(); then if (num_received >= num_expected) mt_sync_frame() → input_mt_sync_frame() + input_sync(). Yoga Book 9 sets INPUT_MT_DROP_UNUSED from MT_QUIRK_NOT_SEEN_MEANS_UP in mt_touch_input_configured().
### Step 5.4: FOLLOW THE CALL CHAIN
Record: USB/I2C HID report → mt_report() → mt_touch_report(). Userspace-visible via evdev. Unprivileged user touching the screen can trigger it.
### Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same 0-count first-packet case already existed for MT_QUIRK_WIN8_PTP_BUTTONS (af8dc4d094909). This generalizes that handling. No duplicate fix already in this tree (git log --grep for “stale MT” / “contact count drops” on the file: empty).
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:
- git describe HEAD → **p-6.12-3-gc504cf0baa3d8**
- make kernelversion → **6.12.111**
- Branch: **pending-6.12**
- Buggy block is at drivers/hid/hid-multitouch.c:1254-1268
- Yoga Book 9 class with NOT_SEEN_MEANS_UP | ALWAYS_VALID | CONTACT_CNT_ACCURATE is at lines 411–421
- Introduced in generic form in **v4.15-era (2017)**; this device class is already backported here
### Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **git apply --check succeeded** (hunk at line 1251, offset −70). Surrounding mt_touch_report() matches mainline. **Clean apply / trivial offset.**
### Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: Misclassification + ContactCount-accurate quirks are here. They do **not** reset num_expected on a 0-count sentinel. No equivalent of e8e60b6439eed is in this tree.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
### Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: **HID multitouch input driver** (drivers/hid/hid- multitouch.c). **IMPORTANT** (laptop touchscreens/touchpads), not core mm/fs. Affects all hid-multitouch devices for the ContactCount=0 path; the reported user is Yoga Book 9, already enabled here.
### Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Active (device IDs, quirks, Yoga Book 9, OOB fixes). This is a late correctness fix on long-standing frame-sync logic, not a refactor of new code.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: DETERMINE WHO IS AFFECTED
Record: **Driver-specific / hardware-specific** for the reported failure (Yoga Book 9 14IAH10, USB 17EF:6161). The code path is generic hid- multitouch. Users of this 6.12 tree already have the rest of that device’s support, so they can hit the leftover stuck-touch bug.
### Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Lift all fingers; firmware sends ContactCount=0 instead of omitting the frame. Common on this device (author: “immediately following the last finger lift”). Unprivileged physical touch. Timing:
every lift, not a rare race.
UNVERIFIED: firmware HID descriptor was not dumped here to prove HID_DG_SCANTIME exists. v3 includes the scantime-change guard and carries Tested-by on this hardware, so scantime almost certainly changes; the Yoga Book 9 report-descriptor fixup does not strip usage 0x56 (HID_DG_SCANTIME).
### Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: **Stuck/stale multitouch slots; missed finger-up; userspace gesture state corruption.** Not a kernel oops. **HIGH** for that hardware (touch becomes wrong after lift). Fits stable-rules “hardware quirk” / “oh, that's not good.”
### Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit:** Completes already-backported Yoga Book 9 support; stops stuck fingers and ghost slots on 0-count frames. Also helps any similar sentinel-frame firmware.
- **Risk:** Low. ~19-line logic change, continuation path preserved, hid-tools passed, maintainer reviewed the -1 ContactCount case.
- **Ratio:** Benefit outweighs risk on this tree.
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: COMPILE THE EVIDENCE
**FOR backporting:**
- Real user-visible bug on shipping hardware (Lenovo Yoga Book 9 14IAH10)
- This 6.12 tree already has the two prior Yoga Book 9 hid-multitouch fixes; without this, 0-count frames still leave slots active and can even feed CONTACT_CNT_ACCURATE with a stale expected count
- Small, obviously targeted change; applies cleanly
- Tested by the author; HID maintainer reviewed (v1 testsuite + v3 semantic check) and merged
- Matches stable rules’ hardware-quirk / input-correctness category
- Continuation / multi-packet path explicitly preserved
**AGAINST backporting:**
- Not a crash, UAF, or security issue
- Widens 0-count handling beyond MT_QUIRK_WIN8_PTP_BUTTONS
- No Fixes:/Cc: stable (not a negative by itself)
- Niche dual-screen laptop as the reporter
**UNRESOLVED:**
- No independent HID dump confirming scantime on this firmware (mitigated by Tested-by on v3)
- No distribution-kernel bugzilla
### Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — maintainer + hid-tools + author Tested-by
2. Fixes a real bug that affects users? **PASS** — missed finger-up / stuck slots on a supported laptop
3. Important issue? **PASS** — hardware input correctness / firmware quirk, not theoretical
4. Small and contained? **PASS** — one function, ~19 lines
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — git apply --check clean; prerequisites present
### Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Not a device-ID/DT/build/docs exception. Closest: **hardware firmware workaround** in an existing driver, which stable explicitly allows.
### Step 9.4: MAKE YOUR DECISION
This 6.12 tree already enables the Yoga Book 9 touchscreen and the ContactCount-accurate / DROP_UNUSED quirks. The remaining bug is that a firmware 0-count sentinel never completes the frame, so slots are not released. The fix is small, reviewed, tested, and applies here. Backport it.
---
### What the commit solves for stable users
On kernels that already have Yoga Book 9 hid-multitouch support (this tree does), lifting fingers can leave MT slots active because ContactCount=0 does not reset num_expected. Userspace then misses the up events. The patch forces a frame sync on a new 0-count packet so INPUT_MT_DROP_UNUSED runs.
### Stable rules / risk vs benefit
Meets the written rules: real bug, small, no new API, applies cleanly. Risk is a slightly broader 0-count interpretation; that was reviewed and is the same condition Win8 PTP already used for button-only frames.
### Concerns
No crash/CVE; generic path rather than a Yoga-Book-only quirk table entry. Still appropriate because the buggy code and the device class are both in this checkout.
---
Verification:
- [Phase 1] Parsed tags: Tested-by Dave Carey; SOB Dave Carey + Benjamin Tissoires; no Fixes/Reported-by/Cc: stable/Link
- [Phase 2] Diff: one hunk in mt_touch_report(); 0-count new frames set num_expected=0; Win8 PTP quirk gate removed
- [Phase 2] Local code at drivers/hid/hid-multitouch.c:1254-1268 matches pre-patch logic
- [Phase 2] Yoga Book 9 class at 411–421 has NOT_SEEN_MEANS_UP | ALWAYS_VALID | CONTACT_CNT_ACCURATE
- [Phase 3] git describe HEAD = p-6.12-3-gc504cf0baa3d8; make kernelversion = 6.12.111
- [Phase 3] blame: Win8 0-touch logic from af8dc4d094909 (2017); ancestor of HEAD
- [Phase 3] git merge-base --is-ancestor e8e60b6439eed HEAD = not present
- [Phase 3] Related commits in this tree: a7359de3c246b, 4dfad42f0610f, bdaabb4cf6603
- [Phase 3] Author’s other hid-multitouch commits: those two Yoga Book 9 fixes
- [Phase 4] b4 dig -c e8e60b6439eed: v3 at patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1 2026-05-15, v3 2026-07-30 (v2 mistagged 2/5)
- [Phase 4] b4 dig -w: linux-input, jikos, bentiss
- [Phase 4] mbox: Benjamin hid-tools OK on v1; requested scantime guard; v3 applied for-7.3/upstream-fixes; -1 contact_count called harmless
- [Phase 4] lore WebFetch 403; used b4 mbox instead
- [Phase 5] mt_touch_report only called from mt_report() on MT collections
- [Phase 5] INPUT_MT_DROP_UNUSED set from MT_QUIRK_NOT_SEEN_MEANS_UP in mt_touch_input_configured()
- [Phase 6] git apply --check of e8e60b6439eed succeeded at offset −70
- [Phase 6] no local equivalent fix (git log --grep on the file empty for this bug)
- [Phase 7] CONFIG_HID_MULTITOUCH in drivers/hid/Kconfig
- [Phase 8] Failure mode: stale MT slots / missed finger-up / gesture corruption, severity HIGH for that hardware
- UNVERIFIED: no firmware HID dump confirming scantime on 17EF:6161 (Tested-by on v3 is the evidence)
- UNVERIFIED: no stable@ thread (search not useful; lore fetch blocked)
**YES**
drivers/hid/hid-multitouch.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/hid/hid-multitouch.c +8 -11
@@ -1332,21 +1332,18 @@ static void mt_touch_report(struct hid_device *hid,* Includes multi-packet support where subsequent * packets are sent with zero contactcount. */ -if (contact_count >=0 ) { +if (contact_count >0 ) + app->num_expected = contact_count; +else if (app->num_received ==0 && app->prev_scantime != scantime) {/* +* New multi-report frame: +* * For Win8 PTPs the first packet (td->num_received == 0) may * have a contactcount of 0 if there only is a button event. -* We double check that this is not a continuation packet -* of a possible multi-packet frame be checking that the -* timestamp has changed. +* +* Some other devices use a sentinel frame with 0 to release all contacts */ -if ((app->quirks &MT_QUIRK_WIN8_PTP_BUTTONS ) && - app->num_received ==0 && - app->prev_scantime != scantime) - app->num_expected = contact_count; -/* A non 0 contact count always indicates a first packet */ -else if (contact_count) - app->num_expected = contact_count; + app->num_expected =0 ; } app->prev_scantime = scantime;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ksmbd: allow FSCTL_SET_SPARSE without input buffer
In reply to Sasha LevinFrom: Namjae Jeon <[email protected]>
[ Upstream commit 86c84cc760080929b7be44bceebe5854957b99da ]
FSCTL_SET_SPARSE without an input buffer sets a file sparse. Treat a zero-length input buffer as SetSparse=true and keep rejecting truncated non-empty buffers.
---
LLM Generated explanations, may be completely bogus:
Local tree is **6.12.111** (p-6.12-3-gc504cf0baa3d8). The candidate is mainline 86c84cc76008 (“ksmbd: allow FSCTL_SET_SPARSE without input buffer”). It is **not** in this checkout; the overly strict length check **is**.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[ksmbd] [allow] [accept FSCTL_SET_SPARSE with a zero-length input buffer]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Signed-off-by:** Namjae Jeon <[email protected]> (author and, on GitHub, committer)
- **No** Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, Link:, or Cc: stable
- Absence of Fixes/Cc: stable is expected for this review pipeline and is **not** a negative signal
- Ignore any “[Upstream commit …]” / “Signed-off-by: Sasha Levin” markers if present in candidate prep
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** MS-FSCC FSCTL_SET_SPARSE with no data element must set the sparse flag (SetSparse=TRUE). ksmbd currently rejects InputCount==0.
- **Symptom:** Client gets an invalid-parameter style failure (-EINVAL from this path) instead of marking the file sparse.
- **Root cause (from message + code):** A length check requires in_buf_len >= sizeof(struct file_sparse) (1 byte), so a spec-legal empty buffer is treated as truncated.
- **Version info in the message:** none
- **Failure mode:** interoperability / protocol reject, not a kernel oops
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not disguised cleanup.** Subject says “allow”, but this restores documented protocol behavior that the 2021 ioctl validation made too strict. It is a spec-compliance bug fix, not a new API.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** fs/smb/server/smb2pdu.c only (**+8 / −2** upstream)
- **Function:** smb2_ioctl(), case FSCTL_SET_SPARSE:
- **Scope:** single-file surgical change
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** if (in_buf_len < sizeof(struct file_sparse)) return -EINVAL; then pass buffer to fsctl_set_sparse().
- **After:** reject only **non-empty truncated** buffers; if in_buf_len == 0, pass a stack file_sparse with SetSparse=1; otherwise keep using the request buffer.
- **Path:** ioctl handling for one FSCTL; not init, not an error-path leak fix.
Verified current 6.12 code (exact pre-image of the patch):
```8496:8505:fs/smb/server/smb2pdu.c
case FSCTL_SET_SPARSE:
if (in_buf_len < sizeof(struct file_sparse)) {
ret = -EINVAL;
goto out;
}
ret = fsctl_set_sparse(work, id, (struct file_sparse
*)buffer);
if (ret < 0)
goto out;
break;
```struct file_sparse is a packed 1-byte SetSparse field (fs/smb/server/smb2pdu.h). in_buf_len is le32_to_cpu(req->InputCount) (unsigned int). For a 1-byte struct, in_buf_len && in_buf_len < 1 is never true; the real behavioral change is **InputCount == 0**.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** logic / protocol correctness (over-strict length check)
- **Mechanism:** 2021 validation blocked the documented empty-buffer form to avoid reading SetSparse from a zero-length buffer. The fix keeps that OOB protection (does not dereference buffer when in_buf_len == 0) and supplies SetSparse=true locally.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Obviously correct** vs MS-FSCC 2.3.83 and vs Samba vfswrap_fsctl() (set_sparse = true unless in_len >= 1 && in_data[0] == 0).
- **Minimal.** No unrelated edits.
- **Regression risk low:** existing 1-byte path unchanged; share/handle checks in fsctl_set_sparse() still apply (KSMBD_TREE_CONN_FLAG_WRITABLE and FILE_WRITE_DATA|FILE_WRITE_ATTRIBUTES, already in this tree via c5ab11263e3c8).
- *(u8 *)&sparse = 1 is equivalent to sparse.SetSparse = 1 for this struct.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- case FSCTL_SET_SPARSE: from e2f34481b24d (“cifsd: add server-side procedures for SMB3”, 2021) — **in this tree**
- Length check from f7db8fd03a4bc5 (“ksmbd: add validation in smb2_ioctl”, 2021-10-13) — **in this tree**
- Buffer base from c6cd2e8d2d9aa7 (InputOffset, not &req->Buffer[0])
- Bug has been present for the entire 6.12 lifetime (introduced 2021)
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Introducer of the too-strict check is f7db8fd03a4bc5, present here.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES** Record:
- Same-day mainline series around sparse (2026-07-08), including:
- 159e727f763d persist FSCTL_SET_SPARSE state
- 31169f41778a reject FSCTL_SET_SPARSE on directories
- 86c84cc76008 **this** empty-buffer change
- Those other patches change advertisement/persistence and directory rejection. **This hunk does not use those new structures.**
- Recent 6.12 ksmbd work on smb2pdu.c is unrelated (compound/query- info, leases, etc.).
- **Standalone** for backport of the empty-buffer check.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Namjae Jeon is the **ksmbd maintainer**. Many ksmbd fixes in this tree are his. That is a strong quality signal, not a substitute for importance.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Record:
- Needs existing fsctl_set_sparse(), struct file_sparse, and in_buf_len — all present.
- Does **not** require persist-xattr or directory-reject commits.
- git merge-base --is-ancestor 86c84cc76008 HEAD → **not an ancestor** (candidate not in this tree).
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 86c84cc76008 (and -a/-w): lore.kernel.org returned an error; **no thread matched**
- Direct lore fetch: **403 / Anubis bot wall**
- GitHub commit: https://github.com/torvalds/linux/commit/86c84cc7600809
29b7be44bceebe5854957b99da (2026-07-08 / committed 2026-08-17)
- **UNVERIFIED:** reviewer comments, v2/v3, NAKs, in-thread Cc: stable
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: Message has only the author’s SOB. Maintainer self-applied. **UNVERIFIED** original To/Cc list (b4 -w failed).
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by/Link. Bug is specified by protocol, not a syzbot crash.
Verified spec (MS-FSCC 2.3.83): *“The message either has no data elements at all or it contains a FILE_SET_SPARSE_BUFFER element. If there is no data element, the sparse flag for the file is set, exactly as if … SetSparse value of TRUE.”*
Win32 FSCTL_SET_SPARSE: *“If the lpInBuffer parameter is NULL, the operation will behave the same as if … SetSparse … were TRUE.”*
Samba vfs_default.c: empty/in_len==0 → file_set_sparse(..., true). smbtorture includes test_ioctl_sparse_set_nobuf.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Same-day sparse series exists; this patch is the empty-buffer piece and is **self-contained**. Later smb2pdu.c mainline commits (Aug–Sep 2026) do not revert or retune this hunk.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** (lore/stable search blocked). No evidence this was rejected for stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: smb2_ioctl() (modified); fsctl_set_sparse() (callee, unchanged by this patch).
**Step 5.2: TRACE CALLERS**
Record:
- smb2_ioctl registered as [SMB2_IOCTL_HE].proc in fs/smb/server/smb2ops.c
- Reachable from authenticated SMB2 IOCTL over the network (CONFIG_SMB_SERVER)
- Not interrupt context; request path from ksmbd workers
**Step 5.3: TRACE CALLEES**
Record: fsctl_set_sparse() looks up the handle, checks writability, sets/clears FILE_ATTRIBUTE_SPARSE_FILE_LE, optionally writes DOS xattr, ksmbd_fd_put().
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: SMB client → SMB2 IOCTL → smb2_ioctl → FSCTL_SET_SPARSE. **Yes, userspace/network reachable.** Linux CIFS client currently sends a 1-byte buffer (smb2_set_sparse → SMB2_ioctl(..., &setsparse, 1, ...)), so Linux-to-ksmbd already works. Windows DeviceIoControl with NULL buffer and Samba torture *_nobuf hit the broken path.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Other FSCTLs in the same switch still require a non-empty input struct (SET_ZERO_DATA, copychunk, duplicate extents). Only SET_SPARSE is specified as valid with no data element. No sibling copy-paste of this empty-buffer rule in 6.12 ksmbd.
===============================================================
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 smb2_ioctl() FSCTL_SET_SPARSE case, lines 8496–8505. Introduced 2021 (f7db8fd03a4bc5). Local version **6.12.111**.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Pre-image matches exactly (line numbers ~8496 vs mainline ~9470). **Expected clean apply** with only context offset. No struct/API mismatch.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE** Record:
- Permission checks: **yes** (c5ab11263e3c8)
- Empty-buffer handling: **no**
- Persist/advertise sparse overhaul (159e727f763d) and directory reject (31169f41778a): **not in this tree**, and **not required** for this fix
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **ksmbd** (fs/smb/server/, CONFIG_SMB_SERVER). **IMPORTANT** for SMB server deployments (Windows/macOS clients), not core mm/VFS. Not staging.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively patched in 6.12.y (leases, query-info, durable reconnect, SET_SPARSE permission). Mature server with ongoing protocol- correctness backports.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver/config-specific:** ksmbd (CONFIG_SMB_SERVER) users whose clients send FSCTL_SET_SPARSE with InputCount=0 (Windows NULL lpInBuffer, Samba torture nobuf). Not universal.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Trigger: SMB2 IOCTL FSCTL_SET_SPARSE with zero InputCount
- Common for **Windows** documented API; **not** the Linux CIFS client path (sends 1 byte)
- Authenticated client with a writable handle (existing checks)
- Not a race
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- **Failure:** request rejected; file not marked sparse
- **Not** oops, UAF, deadlock, or silent data corruption
- **Severity: MEDIUM** — user-visible protocol break for a documented, commonly used FSCTL
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** Windows/spec clients can set sparse the way MS-FSCC and Samba already do; smbtorture nobuf can pass
- **Risk:** very low (≈10-line ioctl case, no locking/API change, still go through fsctl_set_sparse())
- **Ratio:** favorable
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR backporting:**
- Real protocol bug: empty SET_SPARSE must set sparse (MS-FSCC + Win32 + Samba)
- Buggy length check has been in this tree since 2021
- Small, obviously correct; does not reintroduce the OOB the 2021 validation prevented
- Applies cleanly; no missing helpers
- ksmbd maintainer authored it
- Same class of ksmbd protocol-correctness fixes already land in 6.12.y
- Existing permission checks still gate the operation
**AGAINST:**
- Not a crash, UAF, leak, or CVE-class issue
- No user report / Tested-by / lore review recovered
- Same-day mainline series also changes sparse persistence/advertising; this patch is the least dependent piece of that work
- Linux CIFS client already sends a 1-byte buffer
- On 6.12, smb2_get_dos_mode() still ORs SPARSE onto every regular file when share_fake_fscaps has FILE_SUPPORTS_SPARSE_FILES, which can mask some client need to SET_SPARSE
**UNRESOLVED:**
- Mailing-list review, stable nomination, and whether a newer revision existed (b4/lore blocked)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — matches MS-FSCC/Samba; maintainer-authored. No independent Tested-by (typical for this size).
2. Fixes a real bug that affects users? **PASS** — spec-legal Windows/Samba requests fail on ksmbd.
3. Important issue? **PASS** (medium) — interoperability failure on a documented FSCTL, which stable-kernel-rules.rst here also covers as an “oh, that’s not good” user-visible bug; not a kernel panic.
4. Small and contained? **PASS** — one case in one file, +8/−2.
5. No new features or APIs? **PASS** — does not add a userspace API; restores required SMB behavior.
6. Can apply to the local tree? **PASS** — pre-image present, would apply with line-number offset only.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. Qualifies as a normal small protocol bugfix.
**Step 9.4: MAKE YOUR DECISION**
This should be backported to **this** 6.12.111 tree. The code the patch fixes is here, the change is surgical, and rejecting empty FSCTL_SET_SPARSE is a real Windows/Samba interoperability bug, not a new feature and not blocked by the later persist-sparse series.
What it solves for stable users: ksmbd no longer returns invalid parameter when a client sends the documented empty SET_SPARSE request; the file is marked sparse via the existing fsctl_set_sparse() path.
Risk vs benefit: very low risk, clear spec-backed benefit. No extra commits are required for the empty-buffer path to work here.
===============================================================
Verification
===============================================================
- [Phase 1] Parsed message/tags: only Namjae Jeon SOB; no Fixes/Reported-by/Cc: stable
- [Phase 2] Diff: +8/−2 in smb2_ioctl FSCTL_SET_SPARSE; empty buffer → stack SetSparse=1; non-empty path unchanged
- [Phase 2] Confirmed struct file_sparse is one packed __u8; in_buf_len is unsigned int from InputCount
- [Phase 2] Confirmed fsctl_set_sparse() already has share/handle write checks in this tree (c5ab11263e3c8)
- [Phase 3] git describe HEAD / Makefile: 6.12.111 (p-6.12-3-gc504cf0baa3d8)
- [Phase 3] git blame: length check from f7db8fd03a4bc5 (2021); case from e2f34481b24d; both ancestors of HEAD
- [Phase 3] git merge-base --is-ancestor 86c84cc76008 HEAD → not in this tree
- [Phase 3] Related mainline series (159e727f763d, 31169f41778a) not required; this hunk is independent
- [Phase 4] b4 dig -c/-a/-w 86c84cc76008: lore error, no thread — UNVERIFIED review
- [Phase 4] GitHub: commit 86c84cc760080929b7be44bceebe5854957b99da matches the candidate text
- [Phase 4] MS-FSCC 2.3.83 and Win32 FSCTL_SET_SPARSE: empty/NULL buffer = SetSparse TRUE
- [Phase 4] Samba vfswrap_fsctl FSCTL_SET_SPARSE: in_len==0 → set sparse true
- [Phase 5] Caller: smb2ops.c SMB2_IOCTL_HE → smb2_ioctl; Linux client sends 1-byte buffer in smb2_set_sparse()
- [Phase 6] Local pre-image unique match at smb2pdu.c 8496–8505; expected clean apply
- [Phase 7] Subsystem ksmbd / CONFIG_SMB_SERVER, actively maintained on this branch
- [Phase 8] Failure: client EINVAL, severity MEDIUM; not oops/UAF
- UNVERIFIED: lore/stable discussion and any mailing-list NAKs (lore
403)
**YES**
fs/smb/server/smb2pdu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/smb/server/smb2pdu.c +8 -2
@@ -8612,15 +8612,21 @@ int smb2_ioctl(struct ksmbd_work *work) rsp);break ;case FSCTL_SET_SPARSE : -if (in_buf_len <sizeof (struct file_sparse )) { + { +struct file_sparse sparse = {0 }; + +if (in_buf_len && in_buf_len <sizeof (struct file_sparse )) { ret = -EINVAL ; goto out; } - ret =fsctl_set_sparse (work, id, (struct file_sparse *)buffer); + *(u8 *)&sparse =1 ; + ret =fsctl_set_sparse (work, id, in_buf_len ? + (struct file_sparse *)buffer : &sparse);if (ret <0 ) goto out;break ; + }case FSCTL_SET_ZERO_DATA : {struct file_zero_data_information *zero_data;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 drm/etnaviv: force flush on power register ops
In reply to Sasha LevinFrom: Randolph Sapp <[email protected]>
[ Upstream commit c182a2ae13886463f7ae36e034449477306d182b ]
Add gpu_write_power_sync to verify that power register modifications have reached the endpoint device in sequence specific sections that do not validate device state.
These sequence specific areas have been detected experimentally with an am57xx-evm through numerous boot and module load+unload cycles.
---
LLM Generated explanations, may be completely bogus:
This is a hardware posted-write flush in the Vivante/etnaviv reset and init path. The local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The driver, the unsynced gpu_write_power() sites, and the helper this patch adds all exist here, so the question is whether this tree should take the fix on technical merit.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[drm/etnaviv] [force] [flush posted MMIO writes to GPU power registers]**
Subsystem: drm/etnaviv (Vivante GPU DRM driver). Action verb “force flush” is a hardware-workaround / correctness change, not a feature or refactor.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected for this review)
- **Reported-by:** none
- **Tested-by:** none (author states experimental detection on am57xx- evm)
- **Reviewed-by:** Lucas Stach <[email protected]> — **etnaviv maintainer** (MAINTAINERS: “DRM DRIVERS FOR VIVANTE GPU IP”)
- **Acked-by:** none
- **Link:** https://patch.msgid.link/[email protected] (patch **2** of a series)
- **Cc: stable:** none (expected; not a negative)
- **Signed-off-by:** Randolph Sapp <[email protected]> (author, TI); Lucas Stach (maintainer, applied it)
- Ignore pipeline SOBs; none of Sasha Levin’s are in the real commit c182a2ae13886
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** Power-register writels can remain posted on the interconnect, so later reset/init steps run before those writes reach the GPU.
- **Symptom:** Found on **am57xx-evm** across many **boot and module load+unload** cycles. The message does not include a stack trace or a named errno; the affected sequences are reset/init paths that “do not validate device state.”
- **Version info:** none in the message. AM57xx is a long-shipping TI Sitara platform (typically Vivante GC320).
- **Root cause (author):** Need a read-back so the write is visible at the endpoint before continuing.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not a disguised cleanup.** It is an explicit hardware posted- write barrier. Stable rules name **hardware quirk** as an accepted class (Documentation/process/stable-kernel-rules.rst).
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- drivers/gpu/drm/etnaviv/etnaviv_gpu.h: **+6** (new gpu_write_power_sync())
- drivers/gpu/drm/etnaviv/etnaviv_gpu.c: **+5 / -5** (five call sites switched)
- Functions: gpu_write_power_sync (new), etnaviv_hw_reset, etnaviv_gpu_enable_mlcg, etnaviv_gpu_setup_pulse_eater
- Scope: **single-driver surgical fix** (~11 insertions, 5 deletions). Under the 100-line stable limit.
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Helper:** gpu_write_power() was writel only. gpu_write_power_sync() does writel then readl of the same power register (classic posted-write flush).
- **etnaviv_hw_reset:** disable clock gating and the second pulse- eater write now flush. The first pulse-eater write stays unsynced; the following synced write to the same register is the barrier. Correct.
- **etnaviv_gpu_enable_mlcg:** POWER_CONTROLS and MODULE_CONTROLS writes flush before later init.
- **etnaviv_gpu_setup_pulse_eater:** final pulse-eater program flushes.
- **Unchanged:** perfmon pre/post still use plain gpu_write_power() (lines 1388, 1409). Intentional: those paths are not the unvalidated reset/init sequences.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Hardware workaround / posted MMIO write]** Power/clock-gating register updates may not have reached the GPU before isolate/soft-reset (etnaviv_hw_reset) or before FE start (etnaviv_gpu_hw_init). That matches the existing comment on b0da08559c749 (“MLCG and the pulse eater might interfere with the GPU reset”). Dummy readl after writel is the standard PCI/MMIO posting barrier; gpu_read() in the same header already does an extra readl for some FE registers.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: **Obviously correct and minimal.** Extra readl only on init/reset/resume, not on the submit hot path. Same registers are already read via gpu_read_power() in these functions, so a stuck read is not a new failure mode. No API, locking, or data-structure change. Regression risk **low**.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- etnaviv_hw_reset exists since a8c21a5451d831 (initial etnaviv, 2015).
- gpu_write_power introduced in 61a6920bb604d (“fix power register offset on GC300”), contained in **v6.2-rc1**.
- Reset-time MLCG/pulse-eater writes added in b0da08559c749 (“disable MLCG and pulse eater on GPU reset”), contained in **v6.9-rc1**.
- Bug is long-lived interconnect posting, not new 7.3 code.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Not applicable. Introducers above are in this tree (git merge-base --is-ancestor of those SHAs vs HEAD is implied by blame on this checkout).
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Immediate neighbors on this file:
- 1006d1f7c03d9 drm/etnaviv: check all modules for idle after reset
- 4720915ab4828 drm/etnaviv: check MMUv2 status after reset Those are **independent** Lucas Stach reset-validation patches. This commit only changes write helpers; it does not need those checks.
- msgid -2 suggests a series; **only this Randolph Sapp etnaviv commit is in git**. drm-misc-next pull lists this as his sole etnaviv change. Treat as **standalone** (patch 1 is likely a cover letter or was not applied).
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Randolph Sapp is a **TI** engineer, not the subsystem maintainer. Only this etnaviv commit. Weight comes from **Lucas Stach Reviewed-by + Signed-off-by** (maintainer).
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Depends only on existing gpu_write_power / gpu_read_power (since v6.2). **Can apply standalone** on this tree. Confirmed: git show c182a2ae13886^:drivers/gpu/drm/etnaviv/etnaviv_gpu.c already has every converted call site.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c c182a2ae13886 (and -a, -w): lore search errors; lookup of [email protected] → **404 / “not found”**.
- lore.kernel.org and patch.msgid.link: **403/503**.
- gnuweeb lore: msgid **not in the archive**.
- marc.info: **404**.
- **UNVERIFIED:** original dri-devel/etnaviv thread body, v1 vs v2, reviewer comments, Cc: stable in review.
- **Verified:** included in **[PULL] drm-misc-next** [email protected] (Thomas Zimmermann, 24 Jul 2026) as “etnaviv: force flush on power register ops”; applied 23 Jul 2026 by Lucas Stach.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: Maintainer **Lucas Stach** Reviewed-by and applied. Recipients of the original mail **UNVERIFIED** (b4 dig -w failed).
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No bugzilla/syzbot link. Evidence is the author’s **am57xx-evm** load/unload cycling. Severity from the report: **intermittent GPU bring- up / rebind**, not a sanitizer crash.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: drm-misc-next lists **one** Randolph Sapp etnaviv patch. Reset- check commits (1006d1f7, 4720915) are a **different** Lucas series (May 2026). **This patch is self-contained.**
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore-kernel.gnuweeb.org/stable/?q=etnaviv+force+flush did **not** hit this commit (noise from unrelated “flush” in stable reviews). **No stable NAK or prior request found.**
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: gpu_write_power_sync, etnaviv_hw_reset, etnaviv_gpu_enable_mlcg, etnaviv_gpu_setup_pulse_eater.
**Step 5.2: TRACE CALLERS**
Record (verified with rg on this tree):
- etnaviv_hw_reset ← etnaviv_gpu_init (probe, ~line 891) and etnaviv_gpu_recover_hang (~line 1530)
- etnaviv_gpu_enable_mlcg / etnaviv_gpu_setup_pulse_eater ← etnaviv_gpu_hw_init
- etnaviv_gpu_hw_init ← etnaviv_gpu_init, etnaviv_gpu_recover_hang, **etnaviv_gpu_hw_resume** (~line 1753)
- etnaviv_gpu_recover_hang ← etnaviv_sched.c hangcheck (etnaviv_sched timeout path)
- etnaviv_gpu_init ← etnaviv_drv.c bind/load
**Step 5.3: TRACE CALLEES**
Record: writel/readl via gpu_write_power/gpu_read_power/gpu_fix_power_address. No allocations, no locks added.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable from **device probe**, **runtime resume**, **module unload/reload** (matches the report), and **GPU hang recovery**. Userspace GPU use can trigger hang recovery. Not a theoretical-only path.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: gpu_read() already discards an extra readl for FE DMA registers (GC7000 consistency). Same class of MMIO quirk, localized to power registers here.
===============================================================
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**. git merge-base --is- ancestor c182a2ae13886 HEAD succeeds (the fix is already merged here as mainline). The **parent** still has unsynced gpu_write_power() at the five sites. Helpers gpu_write_power/gpu_read_power exist. Bug class (posted power-register writes on reset/init) is present in this codebase.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply on this tree.** Context in etnaviv_hw_reset matches. No conflicting local edits.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No earlier equivalent gpu_write_power_sync. Reset idle/MMU checks are separate, not substitutes for the flush.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **[drm/etnaviv] [IMPORTANT for Vivante GPU users, PERIPHERAL vs core kernel]**
Not mm/net/vfs. Real embedded/SoC users (i.MX, TI AM57xx, etc.).
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained (reset, PPU flop reset, scheduler). This particular path (etnaviv_hw_reset / power regs) is **mature** (2015/2022/2024), not brand-new 7.3 infrastructure.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / platform-specific.** Vivante GPU, observed on **TI am57xx-evm** (GC320-class). Other SoCs with posted interconnects to the GPU can hit the same reset/init window.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Boot, **module load/unload**, runtime resume (etnaviv_gpu_hw_resume → etnaviv_gpu_hw_init), GPU hang reset. Timing-dependent (posted write). Unprivileged GPU clients can cause hang recovery; probe/reload typically needs module/root. **Intermittent but real.**
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Failed etnaviv_hw_reset returns **-EBUSY**, probe logs “GPU reset failed” and **the GPU never comes up**. Hang recovery can leave the GPU **wedged**. Not a documented oops/KASAN. **Severity: HIGH** for that hardware (device unusable / hang not recovered), not a core panic.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** HIGH for AM57xx and similar — GPU init/reset/resume actually complete.
- **Risk:** VERY LOW — 6-line helper, 5 call-site swaps, extra MMIO read on cold paths.
- **Ratio:** strongly in favor of taking the fix.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR backporting:**
- Stable rules explicitly allow **hardware quirks**.
- Posted-write flush is the standard, obviously correct MMIO barrier.
- Reproduced on shipping TI hardware (boot + load/unload).
- Hits probe, resume, and hang recovery — GPU can fail to start or stay hung.
- Small (~11 insertions), driver-private helper, no UAPI.
- Reviewed and applied by the **etnaviv maintainer**.
- Code and call sites exist in **this** 7.3-rc4 tree; no missing prerequisites.
**AGAINST:**
- No Fixes/syzbot/stack trace; commit text is light on the exact user- visible failure.
- Original lore thread **not retrieved** (msgid absent from lore).
- Affects one DRM driver, not core kernel.
- msgid -2 without a recovered patch 1 (mitigated: only this patch landed).
**UNRESOLVED:** Full mailing-list review text; exact errno/log on am57xx; whether patch 1 was a cover letter.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — write+read barrier; maintainer review; experimental confirmation on am57xx-evm.
2. Fixes a real bug that affects users? **PASS** — GPU reset/init/resume can run before power-register writes complete.
3. Important issue? **PASS** — hardware quirk; failed reset → GPU unusable / hang unrecovered (HIGH, not a core oops).
4. Small and contained? **PASS** — two files, ~16 net lines in one driver.
5. No new features or APIs? **PASS** — private static inline only.
6. Can apply to the local tree? **PASS** — files, helpers, and call sites are here; parent matches the diff.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Hardware quirk/workaround** (posted MMIO flush). That class is intended for stable.
**Step 9.4: MAKE YOUR DECISION**
This tree has the Vivante driver and the unsynced power-register writes. The patch is a small, maintainer-reviewed posted-write flush that keeps GPU reset, init, and resume ordered on hardware that actually showed the problem. That meets the stable rules, including the hardware-quirk clause. It should be taken.
---
**What the commit solves:** writel to Vivante power/clock-gating registers can sit in the interconnect. Reset and init then proceed too early, so etnaviv_hw_reset can time out (-EBUSY / “GPU reset failed”) or hang recovery/resume can leave the GPU dead. Dummy readl after the write forces completion. That showed up on am57xx-evm across boot and module reload.
**Stable rules:** Obviously correct, real hardware bug, small, no new API, applies here.
**Risk vs benefit:** Extra MMIO reads only on init/reset/resume vs GPU never coming up. Benefit dominates.
**Concerns:** Lore thread missing; no crash dump in the message. Neither outweighs the quirk + maintainer review + tiny diff.
Verification:
- [Phase 1] Tags: Reviewed-by Lucas Stach (maintainer); Link msgid [email protected]; no Fixes/syzbot/stable Cc
- [Phase 1] MAINTAINERS: Lucas Stach maintains drivers/gpu/drm/etnaviv/
- [Phase 2] Diff: +6 helper, 5 gpu_write_power → gpu_write_power_sync; perfmon writes left unsynced
- [Phase 2] Helper is gpu_write_power + gpu_read_power (posted-write barrier)
- [Phase 3] git log/git blame on etnaviv_gpu.c: reset from a8c21a5451d831 (2015); gpu_write_power from 61a6920bb604d (v6.2-rc1); MLCG-on-reset from b0da08559c749 (v6.9-rc1)
- [Phase 3] git show c182a2ae13886: 11 insertions, 5 deletions, two files
- [Phase 3] Neighbor reset-check commits 1006d1f7/4720915 are independent
- [Phase 3] Only one Randolph Sapp etnaviv commit in this tree
- [Phase 4] b4 dig -c/-a/-w c182a2ae13886: lore errors, msgid not found — **UNVERIFIED original thread**
- [Phase 4] drm-misc-next pull 2026-07-24 lists this as the sole Randolph Sapp etnaviv change
- [Phase 4] stable lore search: no discussion of this patch
- [Phase 5] Callers: etnaviv_gpu_init, etnaviv_gpu_recover_hang ← sched hangcheck, etnaviv_gpu_hw_resume
- [Phase 6] git describe HEAD → v7.3-rc4-27-gf0100363d8c37; make kernelversion → 7.3.0-rc4
- [Phase 6] git merge-base --is-ancestor c182a2ae13886 HEAD → yes
- [Phase 6] Parent of c182 still has unsynced gpu_write_power at all five sites
- [Phase 7] Subsystem drm/etnaviv, driver-specific
- [Phase 8] Failure: reset timeout / GPU not usable / hang recovery fail; severity HIGH for that hardware
- [Phase 9] stable-kernel-rules.rst: hardware quirk is an accepted class
- UNVERIFIED: original mailing-list review comments; exact am57xx log line; identity of series patch 1
**YES**
drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 10 +++++----- drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 6 ++++++ 2 files changed, 11 insertions(+), 5 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +5 -5
@@ -543,13 +543,13 @@ static int etnaviv_hw_reset(struct etnaviv_gpu *gpu)u32 pulse_eater =0x01590880 ;/* disable clock gating */ -gpu_write_power (gpu,VIVS_PM_POWER_CONTROLS ,0x0 ); +gpu_write_power_sync (gpu,VIVS_PM_POWER_CONTROLS ,0x0 );/* disable pulse eater */ pulse_eater |=BIT (17 );gpu_write_power (gpu,VIVS_PM_PULSE_EATER , pulse_eater); pulse_eater |=BIT (0 ); -gpu_write_power (gpu,VIVS_PM_PULSE_EATER , pulse_eater); +gpu_write_power_sync (gpu,VIVS_PM_PULSE_EATER , pulse_eater);/* enable clock */ control =VIVS_HI_CLOCK_CONTROL_FSCALE_VAL (fscale);
@@ -660,7 +660,7 @@ static void etnaviv_gpu_enable_mlcg(struct etnaviv_gpu *gpu) gpu->identity.revision == 0x4302) ppc |=VIVS_PM_POWER_CONTROLS_DISABLE_STALL_MODULE_CLOCK_GATING ; -gpu_write_power (gpu,VIVS_PM_POWER_CONTROLS , ppc); +gpu_write_power_sync (gpu,VIVS_PM_POWER_CONTROLS , ppc); pmc =gpu_read_power (gpu,VIVS_PM_MODULE_CONTROLS );
@@ -704,7 +704,7 @@ static void etnaviv_gpu_enable_mlcg(struct etnaviv_gpu *gpu) pmc |=VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_RA_HZ ; pmc |=VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_RA_EZ ; -gpu_write_power (gpu,VIVS_PM_MODULE_CONTROLS , pmc); +gpu_write_power_sync (gpu,VIVS_PM_MODULE_CONTROLS , pmc); }void etnaviv_gpu_start_fe (struct etnaviv_gpu *gpu,u32 address,u16 prefetch)
@@ -770,7 +770,7 @@ static void etnaviv_gpu_setup_pulse_eater(struct etnaviv_gpu *gpu) pulse_eater |=BIT (18 ); } -gpu_write_power (gpu,VIVS_PM_PULSE_EATER , pulse_eater); +gpu_write_power_sync (gpu,VIVS_PM_PULSE_EATER , pulse_eater); }static void etnaviv_gpu_hw_init (struct etnaviv_gpu *gpu)
drivers/gpu/drm/etnaviv/etnaviv_gpu.h +6 -0
@@ -204,6 +204,12 @@ static inline u32 gpu_read_power(struct etnaviv_gpu *gpu, u32 reg)return readl (gpu->mmio +gpu_fix_power_address (gpu, reg)); } +static inline void gpu_write_power_sync (struct etnaviv_gpu *gpu,u32 reg,u32 data) +{ +gpu_write_power (gpu, reg, data); +gpu_read_power (gpu, reg); +} +int etnaviv_gpu_get_param (struct etnaviv_gpu *gpu,u32 param,u64 *value);int etnaviv_gpu_init (struct etnaviv_gpu *gpu);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 romfs: detect hard link cycles
In reply to Sasha LevinFrom: 이상호 <[email protected]>
[ Upstream commit d30b5a954e0a4dcc16bba9c310c13709a6169a52 ]
romfs_iget() follows on-disk hard link entries until it reaches a non-hard link inode:
pos = be32_to_cpu(ri.spec) & ROMFH_MASK;
The target position is image-controlled, and the loop does not detect cycles. A crafted romfs image can make the root inode a hard link. The hard link can point back to itself and leave mount(2) spinning in the kernel.
Reject excessive hard link indirection with -ELOOP. Normal romfs images do not need long hard link chains. This bounds corrupted-image traversal. Propagate romfs_iget() errors from lookup because hard link traversal can now fail with -ELOOP.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.1.188** (pending-6.1). The unbounded hard-link walk is present here; the fix is not.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
- Subsystem prefix: romfs:
- Action verb: detect (bug-fix language: find/stop a cycle that currently is not handled)
- Claimed intent: stop unbounded on-disk hard-link traversal
Record: **[romfs] [detect] [bound hard-link walk so a crafted image cannot spin forever]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Verified from d30b5a954e0a4 on origin/master (mainline), not from this 6.1 HEAD:
- Signed-off-by: 이상호 <[email protected]> — author
- `Link:
https://patch.msgid.link/[email protected]` — original submission
- Signed-off-by: Christian Brauner (Amutable) <[email protected]> — VFS maintainer applied it
- **No** Fixes: tag
- **No** Reported-by: / syzbot
- **No** Tested-by: / Reviewed-by: / Acked-by:
- **No** Cc: [email protected] (expected for this review pipeline)
Record: **Author SOB + VFS-maintainer SOB + lore Link. No syzbot, no Fixes, no stable CC.**
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Bug: romfs_iget() follows ri.spec while the entry type is ROMFH_HRD. The target is image-controlled. There is no cycle/depth check.
- Symptom: a crafted image can make the root inode a self-referential hard link; mount(2) never returns (kernel-side infinite loop).
- Fix: cap hard-link hops at 64 and return -ELOOP. Also return romfs_iget() errors from lookup so -ELOOP is visible to userspace.
- Author: normal images do not need long hard-link chains.
Record: **[crafted-image infinite hard-link walk] [mount hangs in kernel] [no version bound in message] [missing cycle/depth check on image-controlled spec]**
**Step 1.4: DETECT HIDDEN BUG FIXES**
Not hidden. The subject and body describe a hang. The lookup IS_ERR check is supporting error propagation, not cleanup-for-style.
Record: **Explicit hang fix, not a disguised cleanup.**
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Verified via git show --stat d30b5a954e0a4: **8 insertions, 0 deletions, one file fs/romfs/super.c.**
Functions:
- romfs_lookup() — after romfs_iget(), return ERR_CAST(inode) on error
- romfs_iget() — depth counter; abort after ROMFS_MAX_HARDLINK_DEPTH (64)
The provided candidate diff also shows inode_state_read_once(i) in **unchanged context**. That helper does **not** exist in this 6.1 tree (grep found zero hits). The **changed** lines do not use it.
Record: **[+8 / -0, one file] [romfs_lookup, romfs_iget] [single-file surgical fix]**
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Hunk 1 (romfs_lookup): on name match, optionally one hard-link hop, then romfs_iget(). Before: any ERR_PTR was passed to d_splice_alias(). After: lookup returns the error immediately.
Hunk 2 (romfs_iget): for (;;) reads the header, breaks only when type is not ROMFH_HRD, else sets pos from spec with no hop limit.
After: 65th hop returns -ELOOP.
Affected paths: mount (romfs_fill_super → romfs_iget) and lookup of hard-linked names.
Record: **[unbounded HRD walk → depth-capped walk; lookup now fails closed on iget errors]**
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Category: **logic / correctness plus unbounded iteration** (crafted- image hang). Not UAF, not a leak.
Mechanism: on-disk spec is trusted as the next header. A cycle (or a long in-image HRD chain) never hits a non-HRD type. romfs_dev_read() only fails on I/O or out-of-image pos (pos >= limit in fs/romfs/storage.c), so a **valid in-image cycle** never exits.
Record: **[unbounded image-controlled loop] [depth limit + -ELOOP]**
**Step 2.4: ASSESS THE FIX QUALITY**
Obviously correct: same pattern as symlink MAX_NESTED_LINKS / -ELOOP. 64 hops is generous (VFS symlink cap in this tree is 8). Legitimate genromfs images use hard links for . / .. (one hop), documented in Documentation/filesystems/romfs.rst.
Regression risk is low. The lookup IS_ERR check is slightly redundant here because d_splice_alias() already does if (IS_ERR(inode)) return ERR_CAST(inode); (fs/dcache.c:3147), but it is still correct.
Record: **[minimal, obviously correct] [low regression risk; 64 is well above real romfs usage]**
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
git blame fs/romfs/super.c around the loop:
- Hard-link walk in romfs_iget(): **da4458bda237aa** (David Howells, 2009-02-12), “NOMMU: Make it possible for RomFS to use MTD devices directly”
- git describe --contains da4458bda237aa → **v2.6.30-rc1**
- git merge-base --is-ancestor da4458bda237aa HEAD → **yes, in this tree**
The unbounded loop has been here for the entire 6.1 line.
Record: **[da4458bda237aa / v2.6.30] [buggy walk present in 6.1.188]**
**Step 3.2: FOLLOW THE FIXES: TAG**
No Fixes: tag. The introducing commit is identified by blame, not by the message.
Record: **[No Fixes tag] [introducer da4458bda237aa is in this tree]**
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Path-limited git log --oneline -- fs/romfs/super.c on this tree:
recent work is romfs: check sb_set_blocksize() return value (already here), read_folio, inode alloc. No prior cycle check.
On origin/master after this fix: merge of vfs-7.3 plus unrelated `fs:
add dedicated block device open helpers`. **No follow-up correction** of this patch.
40e2c71d57565 (“romfs: fix returm err while getting inode in fill_super”) already makes romfs_fill_super() check IS_ERR(root) — mount will fail with -ELOOP once romfs_iget() can return it.
Record: **[standalone; no prerequisite series; fill_super already propagates iget errors]**
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
git log --author="[email protected]" on this tree: Bluetooth HIDP payload/header validation. Same author pattern (image/packet bounds), not the romfs maintainer.
Record: **[contributor, not romfs maintainer] [applied by VFS maintainer Brauner]**
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
The patch is [PATCH] (single), not n/m. It only uses IS_ERR / ERR_PTR / ERR_CAST / ELOOP, all present in 6.1. It does **not** require inode_state_read_once.
Record: **[no dependencies] [can apply standalone to this tree]**
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
b4 dig -c <sha> cannot match a commit that is not HEAD. b4 mbox on Message-ID [email protected] saved /tmp/romfs-hardlink.mbox: **2 messages**.
1. Submission 2026-07-02 to linux-kernel and linux-fsdevel, subject [PATCH] romfs: detect hard link cycles
2. Christian Brauner 2026-07-03: applied to vfs-7.3.misc as c4d617e5d28d
No v2/v3. No NAK. No reviewer-requested respin. Direct-to-maintainer apply.
Record: **[lore thread via msgid [email protected]] [single revision] [applied by Brauner] [no NAK]**
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Original To/Cc: [email protected], linux- [email protected]. No extra reviewer list. Brauner applied it (VFS maintainer per MAINTAINERS: FILESYSTEMS (VFS and infrastructure)).
Record: **[linux-fsdevel + VFS maintainer apply; no Reviewed-by trailers]**
**Step 4.3: SEARCH FOR THE BUG REPORT**
No Reported-by or bugzilla/syzbot link. The hang is reasoned from the code, not from a public crash report.
lore.kernel.org HTTP fetches returned **403**; discussion was recovered via b4 mbox.
Record: **[no public bug report] [author describes mount hang from crafted root HRD cycle]**
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Standalone [PATCH] 1/1. No related romfs cycle patches in the mbox or in git log origin/master -- fs/romfs/super.c after it.
Record: **[standalone, not part of a multi-patch series]**
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
lore.kernel.org/stable search returned 403. git log origin/master --grep="detect hard link cycles" -- fs/romfs/super.c finds only the mainline commit. No evidence of a stable NAK.
Record: **[no stable-list discussion recovered; UNVERIFIED beyond 403 on lore/stable]**
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
romfs_lookup(), romfs_iget(). New macro ROMFS_MAX_HARDLINK_DEPTH.
**Step 5.2: TRACE CALLERS**
git grep romfs_iget in fs/romfs/super.c:
- romfs_lookup() — directory lookup (->lookup)
- romfs_fill_super() line 536 — get root inode during mount
romfs_lookup is romfs_dir_inode_operations.lookup.
**Step 5.3: TRACE CALLEES**
romfs_iget calls romfs_dev_read, romfs_dev_strnlen, iget_locked. romfs_dev_read rejects pos >= romfs_maxsize(sb) with -EIO, so **out-of-image** pointers stop; **in-image cycles** do not.
**Step 5.4: FOLLOW THE CALL CHAIN**
mount("romfs") → romfs_get_tree → romfs_fill_super → romfs_iget(root). If that root header is ROMFH_HRD pointing at itself, the syscall never returns.
Lookup of a cyclic hard link after a successful mount has the same hang in romfs_iget.
romfs_fs_type.fs_flags = FS_REQUIRES_DEV only — **no FS_USERNS_MOUNT**. Mount needs CAP_SYS_ADMIN (or equivalent). Still reachable from mount(2) on a loop/MTD/block image.
Record: **[reachable from mount and lookup] [needs mount privilege, not unprivileged userns]**
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
No ROMFS_MAX_HARDLINK elsewhere. VFS uses MAX_NESTED_LINKS = 8 in include/linux/namei.h. SMB client uses the same -ELOOP hop bound. This is the standard “bound image-controlled indirection” pattern.
Romfs docs (Documentation/filesystems/romfs.rst) say it is the **image creator’s** job not to make hard-link loops. The kernel still must not spin if they do.
Record: **[same class as VFS ELOOP bounds; romfs previously trusted the image]**
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Yes. Local fs/romfs/super.c:
```291:303:fs/romfs/super.c
for (;;) {
ret = romfs_dev_read(sb, pos, &ri, sizeof(ri));
if (ret < 0)
goto error;
nextfh = be32_to_cpu(ri.next);
if ((nextfh & ROMFH_TYPE) != ROMFH_HRD)
break;
pos = be32_to_cpu(ri.spec) & ROMFH_MASK;
}
```No ROMFS_MAX_HARDLINK_DEPTH. git merge-base --is-ancestor d30b5a954e0a4 HEAD is false. Introduced in v2.6.30, still here.
Record: **[yes, romfs_iget HRD loop] [since v2.6.30]**
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Local romfs_lookup / romfs_iget match the patch hunks. The only mainline-only context is inode_state_read_once, which this patch does not change. 6.1 still uses i->i_state & I_NEW.
Record: **[clean apply expected; no inode_state_read_once dependency]**
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
No cycle detection. Related: fill_super already returns PTR_ERR(root) (40e2c71d57565). Another crafted-image romfs fix (sb_set_blocksize) is already in this 6.1 tree — same class of image-validation bug.
Record: **[no existing cycle fix] [fill_super error path ready]**
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: SUBSYSTEM AND CRITICALITY**
fs/romfs/ — small read-only FS for initrd/embedded/MTD. **PERIPHERAL** relative to ext4/VFS, but it is a real in-tree filesystem used on 6.1 devices that enable CONFIG_ROMFS_FS.
**Step 7.2: SUBSYSTEM ACTIVITY**
Low churn. The HRD walk has been stable since 2009. That makes the hang long-lived, not a new-subsystem mismatch.
Record: **[romfs] [PERIPHERAL but long-present] [mature, little recent change]**
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Users who mount romfs (CONFIG_ROMFS_FS) from block or MTD. Not universal. Includes initrd, embedded, and anyone mounting an untrusted image (USB, loop).
**Step 8.2: TRIGGER CONDITIONS**
- Crafted image: root header type ROMFH_HRD, spec pointing at itself (or a cycle).
- Or lookup of a cyclic hard-link directory entry.
- Not every boot; only bad/malicious images.
- Unprivileged users cannot mount romfs in a user namespace (FS_REQUIRES_DEV only). Admins, installers, and fuzzers can.
**Step 8.3: FAILURE MODE SEVERITY**
Infinite loop in romfs_iget during mount(2) or lookup. After the first header is cached, romfs_dev_read is a tight CPU loop → hung task / soft lockup, one CPU stuck in kernel, mount never completes.
Record: **[kernel hang / soft lockup] [HIGH to CRITICAL for CONFIG_ROMFS_FS; local DoS with mount cap]**
**Step 8.4: RISK-BENEFIT RATIO**
- Benefit: stops a real hang on corrupted/malicious romfs images; 8 lines; same validation class already accepted in this tree (sb_set_blocksize).
- Risk: very low; depth 64 will not break genromfs images.
Record: **[high benefit for romfs users] [very low risk] [favor backport]**
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: EVIDENCE**
FOR:
- Real unbounded loop; image-controlled spec; self-loop hangs mount(2)
- Code is in this 6.1 tree since v2.6.30
- 8-line, one-file, obviously correct -ELOOP bound
- Applied by VFS maintainer; no NAK; no later revert/fix on mainline
- fill_super already handles IS_ERR from romfs_iget
- Applies without inode_state_read_once
- Important: hang/soft lockup, not a style tweak
AGAINST:
- romfs is niche
- Needs mount privilege (not unprivileged userns)
- No syzbot/Reported-by/Tested-by
- Lookup IS_ERR is redundant with d_splice_alias in 6.1
UNRESOLVED:
- lore.kernel.org HTTP 403; stable-list search not readable via WebFetch (mbox via b4 succeeded for the fsdevel thread)
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — trivial depth bound; applied by Brauner. Testing is implied by mainline merge, not by a Tested-by.
2. Fixes a real bug that affects users? **PASS** — crafted/corrupt romfs hangs mount/lookup.
3. Important (crash, security, corruption, deadlock)? **PASS** — kernel hang / soft lockup (local DoS).
4. Small and contained? **PASS** — 8 lines, one file.
5. No new features or APIs? **PASS**.
6. Can apply to this tree? **PASS** — buggy code present; hunks match 6.1 aside from unrelated inode_state_read_once context.
**Step 9.3: EXCEPTION CATEGORIES**
None of device-ID / quirk / DT / build / docs. Ordinary small hang fix.
**Step 9.4: DECISION**
This is a small, correct bound on image-controlled iteration that prevents a kernel hang on 6.1. Privilege to mount does not make an infinite kernel loop acceptable for stable. Backport it.
---
### What the commit solves for this tree
romfs_iget() walks on-disk hard links with no hop limit. A crafted image can make that walk a cycle, including at the root inode, so mount(2) spins in the kernel. 6.1.188 still has that loop. Returning -ELOOP after 64 hops stops the hang; lookup error propagation is a small companion change.
### Risk vs benefit
Benefit is avoiding a hung task on bad romfs images. Risk is near zero:
legitimate images do not need deep HRD chains, and the patch does not change data structures or APIs.
### Concerns
None material. Do not port inode_state_read_once; it is not part of the fix. No prerequisite commits.
---
### Verification
- **[Phase 1]** git describe HEAD → p-6.1-11-g10bc6eb33d95f; make kernelversion → **6.1.188**
- **[Phase 1]** git log origin/master -1 d30b5a954e0a4 — tags: author SOB, Brauner SOB, msgid Link; no Fixes/Reported-by/Cc:stable
- **[Phase 2]** git show --stat d30b5a954e0a4 — fs/romfs/super.c +8
- **[Phase 2]** Read local romfs_iget / romfs_lookup / romfs_fill_super / romfs_dev_read — unbounded HRD loop; out-of- image reads fail; in-image cycles do not
- **[Phase 2]** d_splice_alias in this tree already handles IS_ERR(inode) (fs/dcache.c:3147)
- **[Phase 3]** git blame — HRD walk from **da4458bda237aa** (v2.6.30); git merge-base --is-ancestor da4458bda237aa HEAD true
- **[Phase 3]** git merge-base --is-ancestor d30b5a954e0a4 HEAD false — fix **not** in this tree
- **[Phase 3]** grep ROMFS_MAX_HARDLINK fs/romfs/super.c — not present
- **[Phase 3]** git log origin/master d30b5a954e0a4^..origin/master -- fs/romfs/super.c — no follow-up fix
- **[Phase 3]** grep inode_state_read_once in this tree — **zero hits**
- **[Phase 4]** b4 mbox msgid [email protected] — 2-message thread; Brauner applied to vfs-7.3.misc
- **[Phase 4]** WebFetch lore.kernel.org / patch.msgid.link / git.kernel.org → **403** / bot page
- **[Phase 5]** Callers of romfs_iget: fill_super (mount) and lookup; fs_flags = FS_REQUIRES_DEV only
- **[Phase 5]** Docs: hard-link loops called out as image-creator responsibility, not kernel-enforced
- **[Phase 6]** Local loop at fs/romfs/super.c:291-303 matches the pre-patch code
- **[Phase 8]** Failure mode: infinite loop in kernel on mount/lookup of cyclic HRD
- **UNVERIFIED:** stable@ mailing-list archive (HTTP 403); no public crash ID beyond the commit text
**YES**
fs/romfs/super.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/romfs/super.c +8 -0
@@ -240,6 +240,8 @@ static struct dentry *romfs_lookup(struct inode *dir, struct dentry *dentry,if ((be32_to_cpu (ri.next) &ROMFH_TYPE ) ==ROMFH_HRD ) offset =be32_to_cpu (ri.spec) &ROMFH_MASK ; inode =romfs_iget (dir->i_sb, offset); +if (IS_ERR (inode)) +return ERR_CAST (inode);break ; }
@@ -262,6 +264,8 @@ static const struct inode_operations romfs_dir_inode_operations = { .lookup = romfs_lookup, }; +#define ROMFS_MAX_HARDLINK_DEPTH 64 +/* * get a romfs inode based on its position in the image (which doubles as the * inode number)
@@ -273,6 +277,7 @@ static struct inode *romfs_iget(struct super_block *sb, unsigned long pos)struct inode *i;unsigned long nlen;unsigned nextfh; +unsigned int depth =0 ;int ret;umode_t mode;
@@ -289,6 +294,9 @@ static struct inode *romfs_iget(struct super_block *sb, unsigned long pos)if ((nextfh &ROMFH_TYPE ) !=ROMFH_HRD )break ; +if (++depth >ROMFS_MAX_HARDLINK_DEPTH ) +return ERR_PTR (-ELOOP ); + pos =be32_to_cpu (ri.spec) &ROMFH_MASK ; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 fat: reject name longer than NAME_MAX in msdos_format_name()
In reply to Sasha LevinFrom: Zizhi Wo <[email protected]>
[ Upstream commit 9d7ed813ee5ff0d469bd99630828ed6fdef4e8da ]
msdos_format_name() performs no upper-bound check on the input name length. It silently truncates an arbitrarily long name into the 8.3 form (11 bytes) and returns success. The subsequent fat_scan() then matches only against these 11 truncated bytes, so it returns an inode as long as any entry with the same 8.3 name exists on disk.
For example, passing a 300-byte name of all 'A's returns 0 with res set to "AAAAAAAA" (8 'A's + 3 padding spaces), reporting success for a name far longer than NAME_MAX.
As a result, when a user calls open() on a path component longer than NAME_MAX (255) bytes, the VFS only enforces PATH_MAX, not the length of an individual component. The dentry keeps the original long name but gets an inode attached and becomes positive. Later in vfs_open() -> fsnotify_open() -> fanotify_info_copy_name() triggers WARN_ON_ONCE(), and the event is reported to userspace with an empty name.
vfat is not affected, as create goes through xlate_to_uni() which refuses names longer than FAT_LFN_LEN.
Fix this by checking 'len > NAME_MAX' at the entry of msdos_format_name(), the single entry point for all msdos name handling, aligning with the NAME_MAX check that xfs/9p/ceph/simple_lookup() perform at lookup.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.18.53**. The buggy msdos_format_name() path is present here and the three-line NAME_MAX check is a self-contained correctness fix for that code.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[fat]** **[reject]** Reject names longer than NAME_MAX in msdos_format_name(). Subsystem is the MS-DOS FAT namei path. Verb “reject” is a correctness/validation fix, not a feature add.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected for this review)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** none on the commit; mailing-list thread shows Brauner applied it
- **Acked-by:** none
- **Link:** https://patch.msgid.link/20260629130943.3671939-1-
[email protected]
- **Cc: stable:** none (expected)
- **Signed-off-by:** Zizhi Wo \<[email protected]\>; Christian Brauner (Amutable) \<[email protected]\>
- Pipeline Signed-off-by: Sasha Levin and [Upstream commit 9d7ed813ee5ff0d469bd99630828ed6fdef4e8da] ignored as candidate-prep markers
- Notable: VFS maintainer SOB; FAT maintainer Hirofumi was on the original To: list
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** msdos_format_name() has no upper bound on len. It truncates an arbitrary name to 8.3 (11 bytes) and returns 0. fat_scan() then matches those 11 bytes, so a 300-byte "AAA..." lookup can attach the inode for "AAAAAAAA".
- **Symptom:** open() of a component longer than NAME_MAX (255) succeeds because VFS only enforces PATH_MAX per path, not per component. The dentry keeps the long name, becomes positive, then vfs_open() → fsnotify_open() → fanotify_info_copy_name() hits WARN_ON_ONCE() and reports an empty name to userspace.
- **Version info:** none stated; code is ancient.
- **Root cause (author):** missing length check at the single MS-DOS name-formatting entry point. VFAT create is already guarded by xlate_to_uni() vs FAT_LFN_LEN.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is an explicit validation fix for silent truncation, a kernel WARN_ON_ONCE, and a broken fanotify event.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** fs/fat/namei_msdos.c (+3 / −0)
- **Function:** msdos_format_name()
- **Scope:** single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: Before, any length was accepted and folded into 8.3. After, `len
Quoted 1 line
NAME_MAXreturns-ENAMETOOLONG` before truncation. Callers:
- msdos_create / msdos_mkdir / rename: surface -ENAMETOOLONG
- msdos_find (lookup/unlink/rmdir): still maps any format error to -ENOENT (pre-existing), so lookup of a too-long name fails instead of matching a truncated 8.3 entry
- msdos_hash / msdos_cmp: fall back to the existing invalid-name path
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Logic / correctness** plus **memory-safety defensive path**. Missing bounds check let names longer than NAME_MAX become positive dentries. fanotify_info.name_len is a u8 (BUILD_BUG_ON(NAME_MAX > U8_MAX)), so fanotify refuses name->len > NAME_MAX with WARN_ON_ONCE and copies nothing.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct and minimal. Regression risk is very low: only names longer than 255 bytes change behavior, and those are not valid Unix names. No locking, no API, no data-structure change. Slight
incompleteness: lookup still reports -ENOENT rather than -ENAMETOOLONG because msdos_find() swallows format errors; that still stops the WARN and the wrong-inode match.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: On v6.18.53, msdos_format_name() starts at **1da177e4c3f41** (Linux-2.6.12-rc2, 2005). No NAME_MAX check. The bug is old, not new- in-6.19+.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent fs/fat/namei_msdos.c history on this series is unrelated (fat: avoid parent link count underflow in rmdir, mount- API/idmap ports). No “patch X/Y” series. Standalone.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: No other fs/fat/ commits by Zizhi Wo on master. Huawei contributor; the VFS maintainer applied the patch.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Diff uses existing NAME_MAX and -ENAMETOOLONG. No new helpers. Applies standalone. git diff v6.18.53 04dcdda681446 -- fs/fat/namei_msdos.c is exactly this 3-line hunk.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- Lore/msgid: https://patch.msgid.link/20260629130943.3671939-1-
[email protected]
- b4 dig -a: **v1 only**
- Thread: submission + Brauner “Applied to vfs-7.3.fat”. No NAKs, no requested revisions, no reviewer Cc: stable in the saved mbox.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc included Hirofumi (FAT maintainer), Brauner, linux-fsdevel, linux-kernel, [email protected], [email protected]. Brauner applied it the next day.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla link. Author describes a concrete open() + fanotify path. Openwall mirror matches the commit text; no extra reports.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Single-patch series [1/1]. No follow-up on fs/fat/ changing this check.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No relevant stable-list discussion found (search did not surface this subject). No known reason to exclude it.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: msdos_format_name() only.
**Step 5.2: TRACE CALLERS**
Record (all in fs/fat/namei_msdos.c):
- msdos_find() ← msdos_lookup, msdos_rmdir, unlink
- msdos_hash(), msdos_cmp() (dcache)
- msdos_create(), msdos_mkdir(), rename
Call context: VFS lookup/create from syscalls (open, stat, mkdir, …), not IRQ.
**Step 5.3: TRACE CALLEES**
Record: After the check, same 8.3 formatting and strchr() validation. Success path still feeds fat_scan(), which strncmp()s 11-byte names.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace open() → VFS lookup → msdos_lookup() → msdos_find() → msdos_format_name(). If format “succeeds” on a truncated name, fat_build_inode() + d_splice_alias() make a positive dentry; vfs_open() → fsnotify_open() can call fanotify_info_copy_name(). **Reachable from userspace** on CONFIG_MSDOS_FS. VFAT lookup uses vfat_find() → fat_search_long() / xlate_to_uni(), not this function.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same len > NAME_MAX → -ENAMETOOLONG exists in simple_lookup(), 9p (v9fs_vfs_lookup), ceph, autofs, configfs. Commit’s “xfs does this at lookup” is **not** visible as d_name.len > NAME_MAX under fs/xfs/ in this tree (minor message inaccuracy). VFAT xlate_to_uni() already returns -ENAMETOOLONG when Unicode length > FAT_LFN_LEN (255).
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** git describe HEAD = v6.18.53-5049-g0f0bdc2b0dffb, VERSION=6 PATCHLEVEL=18 SUBLEVEL=53. At **v6.18.53**, msdos_format_name() has no NAME_MAX check. git merge-base --is- ancestor 04dcdda681446 v6.18.53 is **NO**. Bug introduced at 2.6.12-era git genesis, still present on this 6.18.y base.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** Surrounding code at v6.18.53 matches the hunk context. No intervening refactor of this function.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No other NAME_MAX / msdos_format_name fix on this file in 6.18.53. fat: Fix statfs->f_namelen is unrelated.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **fs/fat (MS-DOS namei)**. Criticality **IMPORTANT** for CONFIG_MSDOS_FS users (USB/floppy/legacy FAT without long names), not core VFS. Not staging.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature; this function has been stable for decades. Low churn around the format loop. Typical “old bug, small late fix.”
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Filesystem/config-specific:** CONFIG_MSDOS_FS mounts (mount -t msdos). Not the common VFAT long-name driver. Still a real production config (Kconfig even says “If unsure, answer Y”).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Unprivileged user with access to an msdos mount calls open()/stat()/etc. with a component length 256..PATH_MAX, and a directory entry whose 8.3 name matches the truncated form. Fanotify WARN additionally needs a fanotify mark that reports names (typically privileged watcher). Trigger is uncommon but fully reachable; not a theoretical race.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- Kernel WARN_ON_ONCE (stack dump; panic if panic_on_warn) — **HIGH**
- fanotify userspace event with empty name (breaks monitors/security policy) — **MEDIUM-HIGH**
- Lookup/open of the wrong 8.3 file via an illegal Unix name — **MEDIUM**
Overall: **HIGH** (userspace-triggerable WARN + wrong-file match), not a default panic.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record: **Benefit high** relative to scope (stops WARN, empty fanotify names, illegal-name aliasing). **Risk very low** (3 lines, error return only). Ratio strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real bug: names > NAME_MAX truncated to 8.3 and treated as success
- Userspace-triggerable WARN_ON_ONCE in fanotify; empty name delivered to watchers
- fanotify_info.name_len is u8; the WARN is a hard length invariant
- Three-line check at the single MS-DOS format entry point
- Present in this 6.18.53 tree since 2.6.12-era code
- Applies cleanly; no prerequisites; no new API
- Applied by VFS maintainer; FAT maintainer was CC’d; v1 accepted as-is
AGAINST:
- Only CONFIG_MSDOS_FS, not VFAT
- No syzbot/Reported-by/explicit Cc: stable
- Lookup still maps the error to -ENOENT via msdos_find()
- Default severity is WARN + wrong lookup, not oops
UNRESOLVED:
- Direct lore.kernel.org HTTP fetch returned 403; thread recovered via b4 dig -m
- xfs lookup NAME_MAX check cited in the message is not in fs/xfs/ here
- No stable-list thread found
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — two-line check, Brauner applied v1
2. Fixes a real bug that affects users? **PASS** — wrong inode + fanotify WARN/empty name
3. Important issue? **PASS** — userspace-triggerable WARN_ON_ONCE; wrong-file match
4. Small and contained? **PASS** — +3 lines, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — clean on 6.18.53 namei_msdos.c
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not a device ID/quirk/DT/build/docs exception). Qualifies as a normal small bugfix.
**Step 9.4: MAKE YOUR DECISION**
This belongs on this 6.18.y tree. The buggy formatter is here, the fanotify WARN path is here, and the fix is a three-line -ENAMETOOLONG guard with negligible regression risk.
------------------------------------------------
What the commit solves for stable users
------------------------------------------------
On msdos mounts, VFS allows a path **component** up to nearly PATH_MAX (4096). The MS-DOS formatter then silently compresses that to 8.3 and can bind a long name to an existing short-name inode. Opening that dentry trips fanotify_info_copy_name()’s WARN_ON_ONCE(name->len > NAME_MAX) and reports an empty name. The patch rejects len > NAME_MAX at the only MS-DOS format entry point, matching 9p/ceph/simple_lookup().
------------------------------------------------
Verification
------------------------------------------------
- [Phase 1] Parsed subject/tags/body from git log -1 04dcdda681446; ignored pipeline SOB/Upstream markers
- [Phase 2] Diff is +3 lines in msdos_format_name(); callers grepped in fs/fat/namei_msdos.c
- [Phase 2] Confirmed fat_scan() matches 11-byte MSDOS_NAME; fanotify_info.name_len is u8
- [Phase 3] git blame v6.18.53 -L 19,45 -- fs/fat/namei_msdos.c → 1da177e4c3f41 (2.6.12-rc2)
- [Phase 3] No Fixes: tag; no series; git log master --author='Zizhi Wo' -- fs/fat/ empty
- [Phase 3] git diff v6.18.53 04dcdda681446 -- fs/fat/namei_msdos.c is only this hunk
- [Phase 4] b4 dig -c 9d7ed813ee5ff0d469bd99630828ed6fdef4e8da → msgid 20260629130943.3671939-1
- [Phase 4] b4 dig -a: v1 only; -w: Hirofumi + Brauner + linux- fsdevel; -m: Brauner applied to vfs-7.3.fat, no NAK
- [Phase 4] Openwall archive matches; lore HTTP 403; no stable-list hit for this subject
- [Phase 5] Call chain: msdos_lookup → msdos_find → msdos_format_name; VFAT uses xlate_to_uni/vfat_find
- [Phase 5] simple_lookup/9p/ceph have NAME_MAX checks; xfs claim unverified in this tree
- [Phase 6] git describe HEAD = v6.18.53-5049; make kernelversion = 6.18.53
- [Phase 6] v6.18.53:fs/fat/namei_msdos.c lacks the check; ancestor test vs v6.18.53 = NO
- [Phase 6] fanotify WARN present in v6.18.53:fs/notify/fanotify/fanotify.h
- [Phase 8] Failure mode: WARN_ON_ONCE + empty fanotify name + truncated 8.3 match; severity HIGH
- UNVERIFIED: xfs lookup NAME_MAX check as stated in the commit message
- UNVERIFIED: live reproduction of the fanotify WARN (code path verified, not executed)
The fix is small, surgical, present-bug in this tree, and meets stable criteria.
**YES**
fs/fat/namei_msdos.c | 3 +++ 1 file changed, 3 insertions(+)
fs/fat/namei_msdos.c +3 -0
@@ -29,6 +29,9 @@ static int msdos_format_name(const unsigned char *name, int len,unsigned char c;int space; +if (len >NAME_MAX ) +return -ENAMETOOLONG ; +if (name[0 ] =='.' ) {/* dotfile because . and .. already done */ if (opts->dotsOK) {/* Get rid of dot - test for it elsewhere */
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 comedi: ni_atmio16d: Add sanity check to interrupt handler
In reply to Sasha LevinFrom: Ian Abbott <[email protected]>
[ Upstream commit 13f4796223489a5349b466ce54bb868f46c9fefd ]
The driver requests an interrupt handler for the device, after setting device registers to disable interrupt generation. The interrupt handler should not be called prematurely unless the user-configured I/O port base address and/or IRQ number are incorrect or the hardware is bad.
For safety, check the dev->attached flag in the interrupt handler to ensure the device has been fully set up, avoiding a possible null pointer dereference of dev->read_subdev.
---
LLM Generated explanations, may be completely bogus:
I have the attach-vs-IRQ ordering, the KASAN report, and the mailing- list series. Compiling the full nine-phase verdict next.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[comedi / ni_atmio16d] [Add] [sanity check in IRQ handler to avoid using dev->read_subdev before attach completes]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Reported-by: Jaeyoung Chung <[email protected]>
- Reported-by: Sangyun Kim <[email protected]>
- Reported-by: Kyungwook Boo <[email protected]>
- Link: https://lore.kernel.org/lkml/20260610115912.780131-1- [email protected]/ (original bug report)
- Link:
https://patch.msgid.link/[email protected] (applied patch)
- Signed-off-by: Ian Abbott <[email protected]> (COMEDI maintainer)
- Signed-off-by: Greg Kroah-Hartman <[email protected]>
- No Fixes: tag (expected)
- No Cc: stable (expected; not a negative)
- Three independent reporters (SNU) — real-world/analysis report, not a drive-by cleanup
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** IRQ handler is registered in atmio16d_attach() before the device is fully set up (dev->attached still false, dev->read_subdev still NULL).
- **Symptom:** NULL deref of dev->read_subdev if an IRQ arrives early.
- **Author’s root cause:** request_irq() runs after the driver writes registers to disable interrupt generation, so a premature IRQ should only happen with a wrong I/O base/IRQ or bad hardware — still treated as a crash to guard against.
- **Version info:** none in the message. Git shows the commit is in this tree (v7.3-rc1 onward).
- Original report subject: comedi: KASAN null-ptr-deref in ISA driver IRQ handlers on early IRQ. It names ni_atmio16d.c / atmio16d_interrupt explicitly.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. It is an explicit NULL-deref guard. Cover letter
title: “Add/fix sanity check in ISA drivers to avoid null-ptr-deref”.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/comedi/drivers/ni_atmio16d.c — **+3 / −0**
- Function: atmio16d_interrupt()
- Scope: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: Before, the handler always did s = dev->read_subdev, inw(AD_FIFO_REG), comedi_buf_write_samples(s, ...), comedi_handle_events(dev, s). After, if !dev->attached it returns IRQ_NONE before those uses of s. Assigning s before the check is only a pointer copy, not a dereference (unlike sibling “Fix sanity check” patches that moved s->async loads).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **NULL pointer dereference (memory safety)** in IRQ context. comedi_buf_write_samples() calls comedi_get_is_subdevice_running(s), which does spin_lock_irqsave(&s->spin_lock, ...). If s is NULL, that is a KASAN null-ptr-deref / oops.
Mechanism: atmio16d_attach() calls request_irq() at line 597, then sets dev->read_subdev at line 634. Core sets dev->attached = true only later in comedi_device_postconfig(). Window: handler live, read_subdev still NULL.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct and matches the existing comedi pattern (if (!dev->attached) return IRQ_NONE in many drivers). Minimal. Regression risk is very low: at worst a premature IRQ during attach is ignored. No API/data-structure change. The check is the same idiom already used in ni_mio_common.c, das800.c, adv_pci1710.c, etc.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Handler dates to 2009 (2323b276308a5d, Chris R. Baugher).
- s = dev->read_subdev since bea70d0b2dc07 (2013).
- comedi_buf_write_samples() since 67fdc3073b785 (2014).
- Driver left staging in 8ffdff6a8cfbd (2021).
- Bug is long-standing, not new 7.x code.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable. Introduced by the historical IRQ- before-setup design, not a recent regression commit.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: This is **patch 5/11** of Ian Abbott’s series (standalone per driver). Related in this tree:
- 1ca4475191513 aio_iiro_16 Add sanity check
- e90d0550c5b30 das6402 Add sanity check
- 8dda63825752a dt2811 Fix sanity check (moves deref after attached check)
- e7356cdc7077a ni_at_a2150 Fix sanity check
- this commit
- f876cbfe3e066 pcm711 Fix sanity check
- others for pcl816/pcl818/pcmmio/pcmuio/quatech
- Earlier: 17221216ae8ce comedi_parport: deal with premature interrupt
No extra refactor is required for this 3-line change. Sibling “Fix sanity check” commits are for drivers that already had the flag test in the wrong place; this driver had no check.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Ian Abbott is listed as COMEDI maintainer in MAINTAINERS. This is a maintainer series fixing the reported drivers plus similar ones.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Uses existing dev->attached and request_irq/read_subdev. Can apply standalone. df05bcfcbd326 (I/O base sanity checks) is unrelated.
git merge-base --is-ancestor 13f4796223489 HEAD → yes (already in this 7.3-rc4 checkout). That is origin history, not a reason to reject on technical merit.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 13f4796223489 →
https://patch.msgid.link/[email protected]
- Subject on list: [PATCH 05/11] comedi: ni_atmio16d: Add sanity check to interrupt handler
- b4 dig -a: single series revision **v1** (11 patches), dated 2026-06-18. No v2/v3.
- Cover letter: “comedi: Add/fix sanity check in ISA drivers to avoid null-ptr-deref”
- Thread mbox: patch series only; no NAK, no reviewer risk flags in the saved thread.
- Greg KH committed the series into char-misc (2026-07-17).
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc were Ian Abbott, linux-kernel, Greg Kroah- Hartman, H Hartley Sweeten (other COMEDI maintainer), and the three reporters. Appropriate maintainers were on the patch. No Reviewed-by in the commit; Greg applied it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: Report from Jaeyoung Chung et al., 2026-06-10, lore msgid [email protected]. KASAN null-ptr-deref. It lists ni_atmio16d.c / atmio16d_interrupt and explains: request_irq then later dev->read_subdev = s; handler passes NULL into comedi_buf_write_samples() → comedi_get_is_subdevice_running(s) → &s->spin_lock. Suggested fix: move request_irq or guard the handler. Maintainer chose the established dev->attached guard.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 11 independent per-driver patches. This one does not need the others. comedi_parport was fixed earlier (17221216ae8ce).
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search for these terms did not surface a dedicated discussion of this patch (hits were unrelated stable release mails). No evidence it was rejected for stable. Absence of Cc: stable is expected for this review pipeline.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: atmio16d_interrupt() modified. Callers/setup:atmio16d_attach() via request_irq(..., atmio16d_interrupt, ...).
Core: comedi_device_postconfig() sets attached. Crash site:comedi_buf_write_samples() → comedi_get_is_subdevice_running().
**Step 5.2: TRACE CALLERS**
Record: Registered only from atmio16d_attach() when it->options[1] (IRQ) is non-zero. IRQ context. Attach is COMEDI_DEVCONFIG (do_devconfig_ioctl), which requires CAP_SYS_ADMIN.
**Step 5.3: TRACE CALLEES**
Record: inw(), comedi_buf_write_samples(), comedi_handle_events(). First of those that uses s is comedi_buf_write_samples → spin_lock on s->spin_lock.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace (admin) configures the ISA card with I/O base + IRQ → attach → request_irq → possible IRQ before read_subdev/attached. Reachable. Not a hot syscall path for unprivileged users, but a real attach-time oops.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same class of bug across the 11-driver series; many other comedi IRQ handlers already had if (!dev->attached). Systematic ISA attach- vs-IRQ issue.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Local tree is **v7.3-rc4** (VERSION=7 PATCHLEVEL=3 SUBLEVEL=0 EXTRAVERSION=-rc4, git describe HEAD = v7.3-rc4-27-gf0100363d8c37). File drivers/comedi/drivers/ni_atmio16d.c is present. Attach still does request_irq before read_subdev / attached. The 3-line guard is already in this checkout because the commit landed in **v7.3-rc1** (not in v7.2). The buggy pattern (IRQ registered before setup) is still the attach design; the handler is what this patch hardens. Driver exists here; patch applies conceptually with no missing APIs.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply. Surrounding handler is the same as the parent of 13f4796223489. No refactor blocking a 3-line insert.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This commit and the rest of the 11-patch series are already ancestors of HEAD (char-misc → 7.3). No alternate fix for atmio16d_interrupt besides this guard. That does not change technical merit; it is origin history, not a “already selected for stable” marker.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **comedi** (drivers/comedi/drivers/ni_atmio16d.c), National Instruments AT-MIO-16/16D ISA DAQ. **PERIPHERAL** (legacy ISA, CONFIG_COMEDI_NI_ATMIO16D, MAINTAINERS status “Odd Fixes”). Still a real in-tree driver with users who need it not to oops.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature/low-churn. Recent work is this sanity-check series plus I/O-base checks. Long-lived bug, not a rebase artifact.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / config-specific** — CONFIG_COMEDI_NI_ATMIO16D and an AT-MIO-16(D) with an IRQ configured.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: IRQ between request_irq() and full attach (attached / read_subdev). Author: wrong I/O port or IRQ, or bad hardware;
reporters: any early IRQ after request_irq. Needs CAP_SYS_ADMIN to attach. Not an unprivileged local DoS, still a kernel oops on a documented misconfig/race window.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **KASAN null-ptr-deref / oops in IRQ handler**. Severity **HIGH** (crash). Not silent corruption.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** Prevents oops on a real, reported path. High for users of this driver; limited population.
- **Risk:** Very low (3 lines, established pattern).
- **Ratio:** Favorable. Crash-prevention on existing driver code is what stable is for.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real KASAN null-ptr-deref, named for this driver
- Three reporters
- Maintainer-authored, applied by Greg KH
- 3-line, obviously correct, existing comedi idiom
- Bug present since ~2013 in this handler
- No new API/feature
- Applies cleanly; no prerequisites
- Failure mode is oops, not cosmetics
AGAINST:
- Niche ISA DAQ; “Odd Fixes”
- Trigger is attach-time / misconfig, not a hot unprivileged path
- No Cc: stable (not a valid negative here)
- 11-patch series, but this patch is self-contained
UNRESOLVED:
- No reviewer replies in the saved lore mbox (Greg still applied it)
- WebFetch to lore returned 403; report/thread recovered via b4 + curl /raw
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — 3-line attached check; maintainer series; Greg applied it.
2. Fixes a real bug that affects users? **PASS** — KASAN null-ptr-deref report listing this handler.
3. Important issue? **PASS** — oops in IRQ context (HIGH).
4. Small and contained? **PASS** — +3 lines, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — driver and handler match; no missing helpers.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary crash fix.
**Step 9.4: DECISION**
This tree is **Linux 7.3-rc4**. The driver and attach/IRQ ordering are here. The patch stops a confirmed NULL deref in atmio16d_interrupt() when an IRQ fires after request_irq() and before dev->attached / dev->read_subdev are valid. That is a small, contained, real crash fix with no new ABI and negligible regression risk. It belongs in this tree’s comedi ISA driver.
---
## What the commit solves (for this tree)
atmio16d_attach() registers atmio16d_interrupt before dev->read_subdev is set and before core sets dev->attached. An early IRQ calls comedi_buf_write_samples(NULL, ...), which takes &s->spin_lock and oopses. The patch returns IRQ_NONE until attach has finished. That matches other comedi handlers and the KASAN report.
Stable rules: real oops, tiny diff, no features, applies here. Benefit (no IRQ oops) outweighs risk.
---
## Verification
- [Phase 1] Tags: 3× Reported-by (SNU), two Link: URLs, Ian Abbott + Greg KH SOB; no Fixes:/Cc: stable
- [Phase 1] Cover letter: “avoid null-ptr-deref”; ni_atmio16d listed
- [Phase 2] Diff: +3 in atmio16d_interrupt() only
- [Phase 2] comedi_get_is_subdevice_running() does spin_lock_irqsave(&s->spin_lock) — NULL s is a deref
- [Phase 2] Attach order in this tree: request_irq ~597, read_subdev ~634; attached set in comedi_device_postconfig()
- [Phase 3] Blame: handler 2009, read_subdev 2013, comedi_buf_write_samples 2014
- [Phase 3] No Fixes: tag; git merge-base --is-ancestor 13f4796223489 HEAD succeeded (in v7.3-rc1, not v7.2)
- [Phase 3] Series 5/11, standalone; sibling “Fix sanity check” patches are other files
- [Phase 4] b4 dig -c 13f4796223489:
patch.msgid.link/20260618102949.26607-6; v1 only
- [Phase 4] b4 dig -w: Greg KH + Hartley Sweeten + reporters CC’d
- [Phase 4] b4 dig -a: one revision, 11 patches
- [Phase 4] Bug report /raw: KASAN null-ptr-deref; names atmio16d_interrupt
- [Phase 4] Stable lore search: no dedicated discussion of this patch
- [Phase 5] COMEDI_DEVCONFIG requires CAP_SYS_ADMIN (do_devconfig_ioctl)
- [Phase 5] Same dev->attached pattern in many drivers/comedi/drivers/*.c
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- [Phase 6] File present; pre-fix parent handler has no attached check
- [Phase 7] MAINTAINERS: Ian Abbott; status Odd Fixes; CONFIG_COMEDI_NI_ATMIO16D
- [Phase 8] Failure mode: IRQ-time NULL deref / oops, HIGH
- UNVERIFIED: full lore HTML (WebFetch 403); no on-list Reviewed-by found in mbox
**YES**
drivers/comedi/drivers/ni_atmio16d.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/comedi/drivers/ni_atmio16d.c +3 -0
@@ -223,6 +223,9 @@ static irqreturn_t atmio16d_interrupt(int irq, void *d)struct comedi_subdevice *s = dev->read_subdev;unsigned short val; +if (!dev->attached) +return IRQ_NONE ; + val =inw (dev->iobase +AD_FIFO_REG );comedi_buf_write_samples (s, &val,1 );comedi_handle_events (dev, s);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 PCI/portdrv: Allow probing even without child services
In reply to Sasha LevinFrom: Brian Norris <[email protected]>
[ Upstream commit 834171efeefffb1a0f2136f32e76669bbc11db86 ]
The PCIe port driver fails to probe if it finds no child services, presumably under the assumption that the driver is not useful in that case. However, the driver *can* still be useful for power management support -- namely, it still configures the port for runtime PM / D3, which may be important for allowing a bridge to enter low power modes.
Thus, allow probe to succeed even if no IRQs and no child services are available. This also mirrors existing behavior for ports that don't support any portdrv services (PCIe hotplug, AER, DPC, PME, bwctrl), where we'd also probe successfully.
This change is a bit more important after commit f5cd8a929c82 ("PCI: dwc:
Remove MSI/MSIX capability for Root Port if iMSI-RX is used as MSI controller"), because it's common for some DWC-based systems to:
1. have only the "aer" and "pcie_pme" port services available and
2. not define legacy INTx interrupts properly in their device tree.
After commit f5cd8a929c82, such systems may fail pcie_init_service_irqs() and so exit with -ENODEV.
---
LLM Generated explanations, may be completely bogus:
I have enough to judge this against 7.3-rc4: the probe-fail path, the DWC IRQ regression, and the mailing-list review are all in this tree.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [PCI/portdrv] [Allow] [succeed probe when no child port services can be registered, so runtime PM/D3 still works]
- Subsystem: PCI/portdrv (PCIe port bus driver)
- Action verb: **Allow** — relaxing an overly strict probe failure, not adding an API
- Claimed intent: keep pcieport bound even with no AER/PME/hotplug/DPC/bwctrl children
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- `Link: https://lore.kernel.org/all/nyada24tqwlkzdceyoxbzitzygvp4elvj5o
ajnqdwb33xkcdwk@76vnrx45fsfd/` — DWC iMSI-RX discussion where the probe-fail side effect was first identified
- Signed-off-by: Brian Norris <[email protected]> (author)
- [bhelgaas: reorder pcie_port_device_register() decls per Lukas]
- Signed-off-by: Bjorn Helgaas <[email protected]> (PCI maintainer)
- Reviewed-by: Lukas Wunner <[email protected]> (PCI PM reviewer)
- `Link: https://patch.msgid.link/20260722160942.v4.1.I5fd5d83f518681b39
49d8ab2f16ba8244fd3e774@changeid` (v4 submission)
Absent (expected): Fixes:, Cc: [email protected], Reported- by:, Tested-by:
Notable: maintainer SOB + expert Reviewed-by; no syzbot; Chrome OS author implies real hardware.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** pcie_port_device_register() returns an error (-ENODEV or IRQ-init errno) if no child services register, so pcieport does not bind.
- **Symptom:** Root/downstream ports never get portdrv runtime PM (pm_runtime_allow / autosuspend), so the bridge may never enter D3.
- **Root cause:** Probe treated “no child services” as “driver is useless.” That is wrong: PM lives on the parent pcieport driver, not on AER/PME children. It is also inconsistent with the existing if (!capabilities) return 0 path.
- **Version info:** Called out as more important after f5cd8a929c82 (DWC: strip RP MSI/MSI-X when iMSI-RX is the MSI controller). On DWC boards with only AER+PME and no working INTx in DT, pcie_init_service_irqs() fails and the whole port driver exits.
- **Author’s mechanism:** Always succeed after pci_enable_device(); drop failed services from the capability mask; if none remain, free IRQ vectors and pci_clear_master(), but do not pci_disable_device() / return error.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Yes, a real probe/PM failure framed as “allow.”** It is not style cleanup. “Allow probing” here means “stop returning -ENODEV when the driver still has a job (runtime PM).” That is a functional fix, especially as a follow-on to f5cd8a929c82.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/pci/pcie/portdrv.c — **+14 / −14** (net 0)
- Function: pcie_port_device_register() only
- Scope: **single-file surgical fix**
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record (before → after), all in pcie_port_device_register():
1. IRQ init fails and no hotplug left: goto error_disable → pci_disable_device() + return error → **goto out, still return 0**.
2. Service loop: count successes in nr_service; if zero, goto error_cleanup_irqs → **on pcie_device_init() failure, clear that service bit; never fail the whole register**.
3. Success path: return 0 with bus-master + IRQs kept even if unused → **out: if !capabilities, pci_free_irq_vectors() + pci_clear_master()**.
4. Error path pci_disable_device() + return status **removed**. Probe now fails only if pci_enable_device() fails. pcie_portdrv_remove() still calls pci_disable_device(), so enable/disable stays balanced when probe succeeds.
Normal path with working IRQs and at least one service: unchanged (still return 0 with master + IRQs).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** logic/correctness (wrong probe failure) + hardware workaround for DWC platforms that lose INTx after MSI cap removal
- **Mechanism:** “no child devices” was treated as fatal; that skipped pcie_portdrv_probe()’s runtime-PM setup (pci_bridge_d3_possible() → autosuspend/pm_runtime_allow). After f5cd8a929c82, that path is hit on common DWC RPs that only advertise AER/PME and have no usable INTx.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Quality:** High after v4. v1 ignored pcie_device_init() errors and leaked IRQ vectors; v4 checks the return, clears failed bits, and frees unused vectors. Matches the long-standing !capabilities success path.
- **Regression risk:** Low–medium, contained.
- Lukas noted they no longer pci_disable_device() immediately on IRQ-init failure; that is intentional (device stays bound). Remove still disables.
- Enabling runtime D3 without a PME *service* does not newly break PME
IRQs: those IRQs already failed, so PME children never bound before either.
- LS7A bus-master caveat was called out as **pre-existing**, not introduced here.
- No public API / data-structure change.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Fail-if-zero-services (status = -ENODEV; nr_service) introduced in **40717c39b1e6c** (“PCI: portdrv: minor cleanup…”, 2009).
- IRQ-fail → error_disable from **075b7d363c675** (2022 revert of “Do not setup IRQs if there are no users”).
- if (!capabilities) return 0 from **eca67315e0e0d** (2011).
- Buggy policy has been in-tree for many years; the **acute trigger** is f5cd8a929c82 (2025-12-18, in **v7.0**).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Related commit f5cd8a929c82 **is** an ancestor of this HEAD (git merge-base --is-ancestor exit 0). It is in v7.0, not v6.19.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record (recent portdrv.c):
- 834171efeefff — this commit (in **v7.3-rc1**)
- Later: 97ca178c899d0 PCI/DPC change — unrelated
- No follow-up fix series from Brian Norris on drivers/pci/
- **Standalone**, not patch N/M of a required series (subject is [PATCH v4], single patch)
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Brian Norris is a Chromium OS PCI contributor (Tested- by/Reviewed-by on the DWC MSI patch). Not the PCI maintainer; **Bjorn Helgaas applied it**, **Lukas Wunner reviewed it**. Only this portdrv commit from him in the recent window.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **None required.** The patch only rearranges existing pci_enable_device / pcie_init_service_irqs / pcie_device_init / pci_free_irq_vectors / pci_clear_master. It does not depend on applying f5cd8a929c82 first; that commit only raises the importance. **Can apply standalone.**
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **v4 (applied):** https://patch.msgid.link/20260722160942.v4.1.I5fd5d8
3f518681b3949d8ab2f16ba8244fd3e774@changeid
- Revisions: **v1 2026-01-09 → v2 2026-02-09 → v3 2026-05-08 → v4 2026-07-22** (applied version is latest)
- Bjorn: “Applied to pci/portdrv for v7.3”
- **No NAKs.** Review iterated on IRQ leak, pcie_device_init() errors, and pci_set_master() timing (v3 deferred master; v4 reverted that after MSI-drop concern)
- **No reviewer Cc: stable** found
- b4 dig lore fetch returned 503; discussion recovered from openwall/LKML/gnuweeb mirrors
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: To/Cc included **Bjorn Helgaas**, **Lukas Wunner**, **Manivannan Sadhasivam**, linux-pci@. Right maintainers. Lukas **Reviewed-by** on v4 (Christmas-tree nit; Bjorn reordered decls).
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: Origin is review of DWC patch 3/5 (f5cd8a929c82). Brian
Norris: platforms without INTx make pcie_init_service_irqs() fail, **“the port won’t be configured for runtime PM and won’t ever enter D3.”** Mani: **“Sounds logical”** because register already returns 0 when there are no port capabilities. **Severity:** functional PM/probe failure on DWC/Chromium test devices, not a panic.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone. b4 dig -a also listed Qiang Yu’s DWC 5-patch series because of the lore Link; that is the *motivation*, not a prerequisite series for this diff.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **No stable@ discussion found** for this subject. Not a negative signal (no automatic Cc: stable).
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: pcie_port_device_register() modified. Related:pcie_init_service_irqs(), pcie_device_init(), pcie_portdrv_probe(), pcie_portdrv_remove().
**Step 5.2: TRACE CALLERS**
Record:
- pcie_port_device_register() ← only pcie_portdrv_probe()
- pcie_portdrv_probe() is .probe of pcie_portdriver ("pcieport"), device_initcall
- Context: **PCI enumeration of every Root Port / Upstream / Downstream / RCEC** — common boot path, not an obscure ioctl
- semcode not available; callers confirmed with git grep
**Step 5.3: TRACE CALLEES**
Record: pci_enable_device, get_port_device_capability, pci_set_master, pcie_init_service_irqs (pci_alloc_irq_vectors MSI then INTx), pcie_device_init (device_register of service devices), pci_free_irq_vectors, pci_clear_master. After success, probe sets DPM flags and runtime autosuspend when pci_bridge_d3_possible().
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Boot/hotplug enumeration → pcieport probe → register services → PM setup. **Reachable without userspace.** Trigger on DWC: iMSI-RX MSI controller + missing/broken INTx in DT → pci_alloc_irq_vectors(..., PCI_IRQ_INTX) fails → previously whole probe failed.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same file already succeeds when get_port_device_capability() is 0. This change makes the IRQ-fail / all-pcie_device_init-fail paths match that. No sibling drivers with the same nr_service pattern.
---
## 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 (make kernelversion → 7.3.0-rc4)
- Current pcie_port_device_register() **already contains this fix** (landed **v7.3-rc1**, 834171efeefff; ancestor of HEAD)
- Pre-fix failure policy existed here until 7.3-rc1; **f5cd8a929c82 is in this tree (v7.0)**
- Buggy path: drivers/pci/pcie/portdrv.c pcie_port_device_register() — fail when IRQ init fails and no HP, or when nr_service == 0
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** on this tree’s pre-fix portdrv.c (single function, same structure). No conflicting later edits that would block it. kzalloc_obj in pcie_device_init is pre-existing, not part of this diff.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This *is* the fix. No alternate/earlier version of the same change. No follow-up reverting or tightening it.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM**
Record: **PCI Express port driver** (drivers/pci/pcie/portdrv.c). **IMPORTANT** — not mm/core, but every PCIe Root Port uses pcieport for AER/PME/hotplug **and** bridge runtime D3.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained (Helgaas). Recent portdrv work besides this:
DPC on downstream ports, bus-type conversions. Mature driver; this is a policy fix, not churn in new code.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / platform-specific.** All systems with PCIe ports run this probe; the *bug* bites when services exist on paper but IRQs cannot be allocated — especially **DWC iMSI-RX hosts without working INTx** (Qualcomm/Chrome OS class). Also any port whose child device_register all fail.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Trigger: port has AER/PME/etc. capability bits, but pcie_init_service_irqs() fails (no MSI after cap strip, INTx missing), **or** every pcie_device_init() fails
- Common on affected DWC boards at **every boot**
- Not a userspace-triggerable security path; enumeration-time
- Not a race
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- **Failure:** pcieport probe fails (-ENODEV / IRQ errno). No portdrv runtime PM. Bridges stay out of D3 (higher power). AER/PME children would not have IRQs anyway, so those services were already dead; the extra damage was losing **parent** PM.
- **Severity: MEDIUM** (functional probe/PM failure, not oops/corruption/deadlock). Still user-visible on real hardware, and a **regression relative to f5cd8a929c82** which this tree has.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** Restores pcieport bind + bridge D3/runtime PM on affected DWC/embedded systems; removes a 15-year inconsistent failure. **Medium–high** for those platforms.
- **Risk:** ~14-line change in one probe function; hot path is unchanged when services work. Reviewed through v4. **Low.**
- **Ratio:** Benefit outweighs risk on this tree because **f5cd8a929c82 is present**.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR backporting:**
- Real probe failure, not theoretical; Chrome OS/DWC hardware, described on list
- Regression amplifier f5cd8a929c82 **is in this 7.3 tree**
- Small, contained, obviously correct after v4
- PCI maintainer applied; Lukas Wunner Reviewed-by
- Aligns IRQ-fail path with existing !capabilities success
- No new API; pcie_portdrv_remove() still pci_disable_device()
- Frees leftover IRQ vectors (addresses Lukas’s SG2042-style vector hog)
**AGAINST:**
- Not crash/UAF/corruption/deadlock
- Verb is “Allow” — policy change vs classic sanitizer bug
- No Fixes: / no stable nomination in review
- Lukas noted enable/disable lifetime questions (not a NAK)
- Missing INTx is also a DT/platform gap; this is a kernel workaround
**UNRESOLVED:**
- Full lore.kernel.org threads 503/403; used mirrors (verified author, v1–v4, reviews)
- Exact Chromebook/SoC model list beyond “current test devices” not in the patch
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — v4, Helgaas + Wunner, applied to 7.3
2. Fixes a real bug that affects users? **PASS** — portdrv fails to bind; no RP runtime D3 on DWC without INTx
3. Important issue? **PASS** (MEDIUM, but a **probe/PM regression** after a commit that is in this tree — driver never attaches)
4. Small and contained? **PASS** — 14/14 lines, one function
5. No new features or APIs? **PASS** — same driver, looser failure condition; no sysfs/module param
6. Can apply to the local tree? **PASS** — code and trigger both exist here; patch is the current function body
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk table/DT/build/doc exception. It is a **driver probe/PM correctness fix** (related to a hardware IRQ-fallback limitation).
**Step 9.4: DECISION**
This tree is **7.3-rc4**. It contains both the DWC MSI-cap removal that makes pcie_init_service_irqs() fail on some RPs and the port driver that used to treat that as a fatal probe error. The result is a real, boot-time pcieport bind failure and missing bridge D3, not a cleanup. The change is small, reviewed, and matches behavior the driver already had when *no* services were advertised.
That meets stable criteria for **this** tree.
---
### What the commit solves (for this tree)
After f5cd8a929c82 (in v7.0, present here), DWC root ports using iMSI- RX lose MSI and must use INTx. If DT does not provide INTx, IRQ init fails. Old pcie_port_device_register() then disabled the device and returned an error, so **pcieport never bound** and **runtime PM/D3 was never enabled** — even though child AER/PME devices were impossible anyway without IRQs. The parent driver is still the one that programs autosuspend. Succeeding probe (and cleaning unused IRQs/master) restores that.
### Risk vs benefit
Low risk (probe error path only when services cannot start; working AER/PME/hotplug path unchanged) vs medium benefit (ports actually enter low power; driver attaches). Reviewed caveats do not block it.
### Concerns
None that block a backport here: no missing prerequisites, no series dependency, no API change. Lukas’s pci_disable_device note is handled by pcie_portdrv_remove().
---
### Verification
- **[Phase 1]** Parsed tags: two Link:s, SOB Norris + Helgaas, Reviewed-by Wunner; no Fixes/stable/syzbot
- **[Phase 1]** Body: probe -ENODEV vs PM; cites f5cd8a929c82
- **[Phase 2]** Diff: +14/−14 in pcie_port_device_register(); drop error_disable/nr_service; always return 0 after enable
- **[Phase 2]** Confirmed pcie_portdrv_probe() PM setup only runs if register succeeds (lines 701–720)
- **[Phase 2]** Confirmed pcie_portdrv_remove() still pci_disable_device() (line 736)
- **[Phase 3]** git describe HEAD → v7.3-rc4-27-gf0100363d8c37; Makefile 7.3.0-rc4
- **[Phase 3]** git show 834171efeefff — candidate SHA 834171efeefffb1a0f2136f32e76669bbc11db86
- **[Phase 3]** Blame parent: 40717c39b1e6c (2009 nr_service), 075b7d363c675 (IRQ fail path), eca67315e0e0d (no-caps return 0)
- **[Phase 3]** git merge-base --is-ancestor f5cd8a929c82 HEAD → 0 (present); not in v6.19; in v7.0
- **[Phase 3]** git merge-base --is-ancestor 834171efeefff HEAD → 0; git describe --contains → v7.3-rc1~71^2~30^2
- **[Phase 3]** No later Norris PCI follow-ups; standalone
- **[Phase 4]** b4 dig -c 834171efeefff — v4 msgid; lore 503
- **[Phase 4]** b4 dig -a — v1..v4 of this patch (plus unrelated DWC series via Link)
- **[Phase 4]** Openwall: Bjorn applied for v7.3; Lukas v4 Reviewed-by + LS7A/enable caveats
- **[Phase 4]** gnuweeb: original DWC thread; Norris reports D3 loss; Mani agrees success-with-no-services
- **[Phase 4]** WebSearch stable@ — no hits for this subject
- **[Phase 5]** Callers: only pcie_portdrv_probe → pcieport PCI driver; semcode unavailable
- **[Phase 5]** pcie_init_service_irqs() INTx fallback returns -ENODEV if pci_alloc_irq_vectors(..., PCI_IRQ_INTX) fails
- **[Phase 6]** Buggy fail path existed until 7.3-rc1; trigger commit in this tree
- **[Phase 8]** Failure mode: probe fail + no bridge D3, severity MEDIUM; regression given f5cd8a929c82
- **UNVERIFIED:** live lore.kernel.org HTML (403/503); exact product names beyond “test devices”
**YES**
drivers/pci/pcie/portdrv.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/pci/pcie/portdrv.c +14 -14
@@ -330,8 +330,8 @@ static int pcie_device_init(struct pci_dev *pdev, int service, int irq)*/ static int pcie_port_device_register (struct pci_dev *dev) { -int status, capabilities, i, nr_service;int irqs[PCIE_PORT_DEVICE_MAXSERVICES ]; +int status, capabilities, i;/* Enable PCI Express port device */ status =pci_enable_device (dev);
@@ -355,29 +355,29 @@ static int pcie_port_device_register(struct pci_dev *dev)if (status) { capabilities &=PCIE_PORT_SERVICE_HP ;if (!capabilities) - goto error_disable; + goto out; }/* Allocate child services if any */ - status = -ENODEV ; - nr_service =0 ;for (i =0 ; i <PCIE_PORT_DEVICE_MAXSERVICES ; i++) {int service =1 << i;if (!(capabilities & service))continue ; -if (!pcie_device_init (dev, service, irqs[i])) - nr_service++; +if (pcie_device_init (dev, service, irqs[i])) + capabilities &= ~service; } -if (!nr_service) - goto error_cleanup_irqs; -return 0 ; +out: +/* +* With no child services, we shouldn't need bus mastering or any IRQ +* vectors we allocated. +*/ +if (!capabilities) { +pci_free_irq_vectors (dev); +pci_clear_master (dev); + } -error_cleanup_irqs: -pci_free_irq_vectors (dev); -error_disable: -pci_disable_device (dev); -return status; +return 0 ; }typedef int (*pcie_callback_t )(struct pcie_device *);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] PCI/portdrv: Allow probing even without child services
Sashiko has reviewed this patch and found no issues.
Quoted 15 lines
From: Brian Norris <[email protected]>
[ Upstream commit
834171efeefffb1a0f2136f32e76669bbc11db86]The PCIe port driver fails to probe if it finds no child services, presumably under the assumption that the driver is not useful in that case. However, the driver *can* still be useful for power management support -- namely, it still configures the port for runtime PM / D3, which may be important for allowing a bridge to enter low power modes.
Thus, allow probe to succeed even if no IRQs and no child services are available. This also mirrors existing behavior for ports that don't support any portdrv services (PCIe hotplug, AER, DPC, PME, bwctrl), where we'd also probe successfully.
Quoted 6 lines
[ ... ][bhelgaas: reorder pcie_port_device_register() decls per Lukas]Signed-off-by Bjorn Helgaas <[email protected]>Reviewed-by Lukas Wunner <[email protected]>Link https://patch.msgid.link/20260722160942.v4.1.I5fd5d83f518681b3949d8ab2f16ba8244fd3e774@changeid open hereSigned-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 mmc: moxart: report DMA completion timeout
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit e29e650077e01dddf69bc8fac31e0cd60043aa7c ]
moxart_transfer_dma() waits for the DMA completion but ignores wait_for_completion_interruptible_timeout(). It then unconditionally reports the full transfer length in data->bytes_xfered.
Terminate the DMA channel and set data->error when the wait is interrupted or times out. Only report host->data_len as transferred after the completion is observed.
---
LLM Generated explanations, may be completely bogus:
The local tree is mainline **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The candidate is e29e650077e01 (“mmc: moxart: report DMA completion timeout”). Analysis below is of that commit against this checkout.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[mmc/moxart] [report] [DMA wait timeout was ignored; now surface it as an I/O error]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Pengpeng Hou \<[email protected]\> (author)
- Signed-off-by: Ulf Hansson \<[email protected]\> (MMC host maintainer; applied)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, Link:, or Cc: stable (absence is expected for this review)
- Notable: maintainer SOB only; no user/syzbot report
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** moxart_transfer_dma() calls wait_for_completion_interruptible_timeout() but discards the return value, then always sets data->bytes_xfered = host->data_len.
- **Symptom:** A timed-out or interrupted DMA transfer is reported as a full successful transfer.
- **Fix:** On timeout <= 0, dmaengine_terminate_sync(), set data->error, skip bytes_xfered update, still unmap.
- **Version info:** none in the message. Driver dates to v3.16 (1b66e94e6b999).
- **Root cause (author):** ignored wait status plus unconditional success accounting.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. Explicit timeout/error-path fix. Also stops DMA before dma_unmap_sg(), which is a memory-safety fix even though the subject only says “report”.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/mmc/host/moxart-mmc.c — **+9 / −2** (11-line net in one function)
- Function: moxart_transfer_dma()
- Scope: **single-file surgical fix**
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record (verified against e29e650077e01^):
- **Before:** map SG → optionally submit DMA → wait (return ignored) → always bytes_xfered = host->data_len → unmap. Timeout, signal, or failed dmaengine_prep_slave_sg() still looked like a full transfer, and unmap ran while DMA could still be active.
- **After:** same wait; if timeout <= 0, terminate the channel, set data->error to -ERESTARTSYS or -ETIMEDOUT, skip accounting, then unmap. Success path unchanged.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** logic/correctness (ignored wait) **plus** memory safety (unmap while DMA may still run) **plus** false success to the MMC block layer.
- **Mechanism:** wait_for_completion_interruptible_timeout() returns 0 on timeout, -ERESTARTSYS if interrupted, remaining jiffies on success (kernel/sched/completion.c). timeout ?: -ETIMEDOUT maps those correctly.
- MMC block completion uses bytes_xfered as success size (mmc_blk_mq_complete_rq()). A full bytes_xfered with no error completes the request as OK — silent data corruption on write, stale/wrong data on read.
- sh_mmcif.c already uses the same terminate + data->error pattern.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct and minimal. Matches documented wait return values and existing MMC DMA drivers.
- moxart_transfer_dma() is called with the host spinlock dropped (moxart_request()), so dmaengine_terminate_sync() is in process context as required.
- Residual issues (pre-existing, not introduced): still waits even if desc is NULL; PIO wait at line 436 still ignores its return. After DMA error, moxart_request() still waits for MASK_DATA. Harmless extra delay; data->error is already set.
- Regression risk: **low**.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Function and ignored wait: 1b66e94e6b999 (“mmc: moxart: Add MOXA ART SD/MMC driver”), **v3.16-rc1**.
- Unconditional bytes_xfered = host->data_len after wait:
54fd8cd617996 (2024, “Fix accounting in DMA transfer”) — moved the assignment after the wait but still did not check the wait result.
- Bug class (ignored wait + unmap-while-active) has been in the driver since introduction.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable. Introduced-by is 1b66e94e6b999; git merge-base --is-ancestor 1b66e94e6b999 HEAD succeeds.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Recent: platform helpers, devm_mmc_alloc_host, sg_miter revert, DMA accounting, moxart_use_dma().
- Not part of a numbered series. Standalone.
- Prerequisite for a clean textual apply of this exact hunk:
54fd8cd617996 (already in this tree). The timeout check itself does not depend on that accounting change.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record:
- Pengpeng Hou is not the MMC maintainer; many nearby commits are small correctness/ID-table patches.
- Ulf Hansson applied it (“Applied for next, thanks!”).
- Only this moxart change from the author in drivers/mmc/host/.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Record:
- Uses dmaengine_terminate_sync() from include/linux/dmaengine.h (added b36f09c3c441a, 2015). Present here; used by other MMC hosts.
- Standalone. No new helpers.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c e29e650077e01 →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only**, applied as submitted.
- Thread (saved via b4 dig -m): Ulf Hansson, 2026-07-06: “Applied for next, thanks!” No NAK, no requested changes, no Cc: stable from reviewers.
- lore WebFetch returned HTTP 403; discussion recovered from the mbox.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc Pengpeng Hou, Ulf Hansson, Binbin Zhou, Huacai Chen, linux-mmc, linux-kernel. Maintainer was the recipient and applied it. Zhou/Chen look like list/CC noise (Loongson MMC), not reviewers of this driver.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by, no bugzilla/syzbot link. Code-inspection fix, not a user report.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone v1. Same author also has mmc: sdhci-of-ma35d1: add missing MODULE_DEVICE_TABLE() — unrelated.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable WebFetch returned 403. git log --grep='DMA completion timeout' -- drivers/mmc/host/ only this commit. **UNVERIFIED:** no confirmation of a prior stable-list NAK.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: moxart_transfer_dma() only. Uses moxart_dma_complete() as DMA callback (complete(&host->dma_complete)).
**Step 5.2: TRACE CALLERS**
Record:
- Sole caller: moxart_request() (mmc_host_ops.request).
- Path: MMC core request → host .request → DMA if data_len > fifo_width && have_dma.
- Process context, lock dropped. Userspace block I/O to the SD card reaches this.
**Step 5.3: TRACE CALLEES**
Record: dma_map_sg / dmaengine_prep_slave_sg / dmaengine_submit / dma_async_issue_pending / wait / (new) dmaengine_terminate_sync / dma_unmap_sg.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable from normal MMC/SD reads and writes on MOXA ART (UC-7112-LX and related). Timeout is 1000 ms (host->timeout = msecs_to_jiffies(1000)). Unprivileged I/O on that hardware can hit it.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record:
- PIO path in the same file already sets data->error = -ETIMEDOUT on FIFO wait failure — DMA was inconsistent.
- moxart_request() still ignores the PIO completion wait return (line 436). Same class of bug, not this patch.
- sh_mmcif.c checks timeout/interrupt, zeros bytes_xfered on error, calls dmaengine_terminate_sync().
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. File and function have been here since v3.16. Pre-image confirmed at e29e650077e01^. git merge-base --is-ancestor e29e650077e01 HEAD succeeds (fix already on this mainline snapshot). Introduced ~v3.16.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Hunk is local to moxart_transfer_dma(). APIs used exist here. **Clean apply** on this tree (already applied). No conflicting later logic change except an unrelated platform-helper commit.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: 54fd8cd617996 only moved accounting after the wait; it did not check the wait. No other timeout fix for this DMA path.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY** Record:
- Subsystem: MMC host (drivers/mmc/host/moxart-mmc.c), CONFIG_MMC_MOXART, depends on ARCH_MOXART || COMPILE_TEST.
- Hardware: MOXA ART (Faraday FA526 ARMv4), UC-7101 / UC-7112-LX / UC-7110 / IA240 / IA241 / IA3341.
- Criticality: **PERIPHERAL** (legacy industrial SoC), but the bug is in the host’s main DMA I/O path.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Driver is mature (2014) with occasional fixes. Not an active rewrite. Long-standing bug.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / platform-specific** — MOXA ART boards with this MMC host and DMA enabled. Not universal.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Trigger: DMA completion misses the 1s wait, or the waiter is interrupted.
- Also: dma_map_sg/prep failure (completion never signaled) previously still reported a full transfer.
- Commonness: timeout is not every I/O; when it happens the old code treated it as success.
- Unprivileged userspace I/O on that hardware can reach it.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- False bytes_xfered + no data->error → block layer completes I/O as OK (mmc_blk_mq_complete_rq uses bytes_xfered). **Data corruption.**
- dma_unmap_sg() while the engine may still be running → DMA to unmapped memory, crash or memory corruption.
- Later moxart_wait_for_status(MASK_DATA) can still timeout and set data->error, but unmap already happened inside moxart_transfer_dma(), and if the controller finished while the DMA engine did not, MASK_DATA can succeed and the false-success path remains.
- Severity: **HIGH** (corruption / use of unmapped DMA buffers). Not a panic on every timeout, but the failure mode is serious.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** HIGH for MOXA ART users (correct I/O error, DMA stopped before unmap). LOW globally (few platforms).
- **Risk:** VERY LOW (9 lines, error path, maintainer-applied, same pattern as other hosts).
- **Ratio:** benefit outweighs risk for a stable backport of this driver fix.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR backporting:
- Real bug: ignored wait, fake full transfer, unmap while DMA may still run.
- Failure mode is data corruption and DMA-to-unmapped-memory, not cosmetics.
- Small (+9/−2), obviously correct, process-context terminate.
- PIO path already reports timeout; DMA did not.
- Bug present since v3.16; DMA I/O path of an in-tree driver.
- MMC maintainer applied v1 with no objections.
- dmaengine_terminate_sync and the surrounding function exist in this tree.
AGAINST:
- Niche ARMv4 industrial SoC; no Reported-by / syzbot.
- Author looks like an audit-style contributor; not a hardware user report.
- PIO completion wait still ignores its return (incomplete sibling).
- No Fixes:/Cc: stable (not a negative per the review rules).
UNRESOLVED:
- Stable-list discussion could not be fetched (HTTP 403).
- No public confirmation of how often DMA actually times out on UC-7112-LX hardware.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — return-value handling matches the API; maintainer applied it; same pattern as sh_mmcif.
2. Fixes a real bug that affects users? **PASS** — false success and unmap-while-active on this host’s DMA path.
3. Important issue? **PASS** — data corruption and DMA memory safety; HIGH, not a panic-on-boot.
4. Small and contained? **PASS** — one function, 9 insertions.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — pre-image and APIs are here; commit is already an ancestor of HEAD.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not a device ID, quirk, DT, build, or doc fix). Qualifies as a normal bugfix.
**Step 9.4: MAKE YOUR DECISION**
This tree has the buggy DMA path. The patch is a small, maintainer-acked correction of ignored DMA completion that otherwise reports a full transfer and unmaps buffers while the engine may still run. That is stable-worthy even on a niche host: the risk is negligible and the failure mode is corruption.
Verification:
- [Phase 1] Parsed tags: author + Ulf Hansson SOB only; no Fixes/Reported-by/Cc: stable
- [Phase 1] Body: ignored wait + unconditional bytes_xfered
- [Phase 2] Diff: +9/−2 in moxart_transfer_dma(); timeout<=0 → terminate_sync, set error, skip accounting
- [Phase 2] Pre-image at e29e650077e01^ confirmed ignored wait then bytes_xfered = host->data_len
- [Phase 2] wait_for_completion_interruptible_timeout returns -ERESTARTSYS / 0 / remaining jiffies (kernel/sched/completion.c)
- [Phase 2] mmc_blk_mq_complete_rq() completes OK when bytes_xfered != 0
- [Phase 3] Blame: wait from 1b66e94e6b999 (v3.16); accounting move 54fd8cd617996 still ignored wait
- [Phase 3] git merge-base --is-ancestor 1b66e94e6b999 HEAD and e29e650077e01 HEAD both true
- [Phase 3] dmaengine_terminate_sync added in b36f09c3c441a (2015); present in this tree
- [Phase 4] b4 dig: lore
https://patch.msgid.link/[email protected] ; v1 only
- [Phase 4] mbox: Ulf “Applied for next, thanks!”; no NAK; no Cc: stable
- [Phase 4] WebFetch lore/stable: HTTP 403 (UNVERIFIED stable-list history)
- [Phase 5] Only caller moxart_request(); lock dropped; 1s timeout
- [Phase 5] Sibling sh_mmcif uses the same terminate/error pattern
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- [Phase 6] Buggy DMA wait present before the commit; patch already on HEAD
- [Phase 7] CONFIG_MMC_MOXART / ARCH_MOXART (UC-7112-LX family)
- [Phase 8] Failure mode: false MMC success + DMA unmap while active; HIGH
- UNVERIFIED: frequency of DMA timeouts on real MOXA hardware; stable mailing-list discussion
The patch is small, correct, and fixes a real DMA-timeout path that can complete I/O as success and unmap live buffers. That meets stable criteria for this tree.
**YES**
drivers/mmc/host/moxart-mmc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/mmc/host/moxart-mmc.c +9 -2
@@ -264,6 +264,7 @@ static void moxart_transfer_dma(struct mmc_data *data, struct moxart_host *host)u32 len, dir_slave;struct dma_async_tx_descriptor *desc =NULL ;struct dma_chan *dma_chan; +long timeout;if (host->data_len == data->bytes_xfered)return ;
@@ -296,11 +297,17 @@ static void moxart_transfer_dma(struct mmc_data *data, struct moxart_host *host)dma_async_issue_pending (dma_chan); } -wait_for_completion_interruptible_timeout (&host->dma_complete, - host->timeout); + timeout =wait_for_completion_interruptible_timeout (&host->dma_complete, + host->timeout); +if (timeout <=0 ) { +dmaengine_terminate_sync (dma_chan); + data->error = timeout ?: -ETIMEDOUT ; + goto unmap; + } data->bytes_xfered = host->data_len; +unmap:dma_unmap_sg (dma_chan->device->dev, data->sg, data->sg_len,mmc_get_dma_dir (data));
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 fs/ntfs3: reserve NUL byte when converting UTF-16 names
In reply to Sasha LevinFrom: Kyle Zeng <[email protected]>
[ Upstream commit 4871fedaabbfd574ac0a075b80e75afdd532e11e ]
ntfs_utf16_to_nls() appends a trailing NUL to the converted output, but it passes the caller-supplied size directly to the conversion loop. For the UTF-8 path, utf16s_to_utf8s() can legitimately fill all buf_len bytes and return buf_len, after which ntfs_utf16_to_nls() writes the terminator one byte past the end of the destination buffer.
The same contract problem exists for the NLS path when a converted character consumes the last available byte.
Reserve one byte for the terminator before doing either conversion. The function continues to return the number of converted bytes, excluding the NUL terminator.
---
LLM Generated explanations, may be completely bogus:
The local tree is **v7.3-rc4** (7.3.0-rc4). ntfs_utf16_to_nls() is present here, and the bug is a real one-byte heap overflow on long reparse/symlink conversion. Below is the full checklist.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[fs/ntfs3] [reserve] reserve one NUL byte when converting UTF-16 names**
- Subsystem: fs/ntfs3
- Verb: “reserve” — a missing-safety-check fix (keep a terminator byte)
- Intent: stop ntfs_utf16_to_nls() from writing '\0' one byte past the caller buffer
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Assisted-by: Codex:gpt-5.5 — LLM-assisted; still needs code review (done below)
- Signed-off-by: Kyle Zeng <[email protected]> — author
- Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon- software.com> — ntfs3 maintainer
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, Link:, or Cc: stable (absence is expected for this review)
- Ignore any pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] — none on this commit
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** ntfs_utf16_to_nls() always stores a trailing NUL, but passes the full caller buf_len into conversion.
- **UTF-8 path:** utf16s_to_utf8s() may write buf_len bytes and return buf_len; then buf[ret] = '\0' is one past the end.
- **NLS path:** a converted character can consume the last byte; *op = '\0' is then one past the end.
- **Fix:** reject buf_len <= 0; do buf_len -= 1 before conversion; still return converted length **excluding** NUL.
- **Symptom:** 1-byte heap buffer overflow (memory corruption / KASAN slab-out-of-bounds write).
- **Versions in the message:** none.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. It is an explicit off-by-one / OOB write fix, not cleanup or a new feature.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: fs/ntfs3/dir.c — **+5 / −0**
- Function: ntfs_utf16_to_nls()
- Scope: single-function, surgical
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record (pre-fix from 4871fedaabbfd^):
``` ret = utf16s_to_utf8s(..., buf, buf_len); buf[ret] = '\0'; return ret; ```
and NLS loop using full buf_len, then *op = '\0'.
After: if buf_len <= 0 → -EINVAL; else buf_len -= 1; conversion and NUL write use the reduced size. Return value is still converted bytes without the terminator.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Memory safety — 1-byte out-of-bounds write.**
Verified utf16s_to_utf8s() in fs/nls/nls_base.c: it loops while (inlen > 0 && maxout > 0) and for ASCII does *op++ = ...; maxout--;. It can write exactly maxout bytes and return that count. buf[ret] = '\0' is then OOB.
NLS: uni2char() is called only when buf_len >= NLS_MAX_CHARSET_SIZE (6). If charlen == buf_len, remaining space becomes 0 and *op = '\0' is OOB. Same class of contract bug.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Correct and minimal: reserve the byte the function already uses for NUL.
- Return contract unchanged (length without NUL) — matches ntfs_dir_emit(), ntfs_readlink_hlp(), ADS listing.
- Regression risk: **low**. Worst case is truncating one extra byte on a max-length conversion instead of overflowing.
- buf_len <= 0 → -EINVAL is defensive; current callers pass PATH_MAX or PAGE_SIZE.
- No API/ABI/feature change.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Unconditional buf[ret] = '\0' / *op = '\0' from **4342306f0f0d5** (“fs/ntfs3: Add file operations and implementation”, 2021-08-13).
- Contained in **v5.15-rc1**.
- UTF-8 call adjusted in 2c69078851b3d (“Rework ntfs_utf16_to_nls”, 2021-10) but still passed full buf_len.
- Bug is old (since ntfs3 landed), not last-month code.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Buggy code is the original function body from 5.15, present in this tree’s ntfs3.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES** Record:
- Same-class NUL bug: a6cd43fe9b083 (“terminate the cached volume label after UTF-8 conversion”) — utf16s_to_utf8s() does not NUL- terminate; filling the buffer overruns %s.
- Related bounds: aa1bdbb39f49c (OOB **read** of names in ntfs_dir_emit) — different bug.
- Later be310476e8868 (ADS) adds a third caller; not a prerequisite.
- Standalone 5-line fix, not patch X/Y.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Only this ntfs3 commit from Kyle Zeng. Applied by **Konstantin Komarov** (ntfs3 maintainer) in the ntfs3_for_7.3 pull (dc83d18cdd904).
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Uses existing utf16s_to_utf8s() / NLS loop. Applies on top of the long-standing function.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 4871fedaabbfd →
https://patch.msgid.link/[email protected]
- Only **v1** (b4 dig -a); that version was applied.
- Lore HTTP fetch returned 403; full thread saved via b4 dig -m /tmp/ntfs3-nul.mbox.
- Maintainer (23 Jul 2026): “Your patch was applied, thank you.” **No NAK.**
- XIAO WU replied about a **different** remount/sbi->options UAF (getdents vs remount). That is not this overflow and is not caused by this patch. The nls load is unchanged.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To [email protected]; Cc maintainer Konstantin Komarov, LKML, [email protected]. Maintainer applied it. No extra Reviewed-by.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla/Reported-by. Bug is from code inspection. Reachability is from callers (Phase 5), not a public crash report.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone v1. Not part of a multi-patch series.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search via WebFetch → 403. No stable-list discussion in the saved mbox. **UNVERIFIED:** whether AUTOSEL already queued it for some -stable series (irrelevant to this tree’s technical decision).
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: ntfs_utf16_to_nls() only.
**Step 5.2: TRACE CALLERS**
Record (this tree):
1. **ntfs_dir_emit()** (fs/ntfs3/dir.c) — readdir/getdents. Buffer kmalloc(PATH_MAX) (PATH_MAX=4096). static_assert(NTFS_NAME_LEN * 4 < PATH_MAX) (NTFS_NAME_LEN=255 → max 1020 UTF-8 bytes). **This caller cannot fill PATH_MAX**, so the NUL OOB does not fire on normal filenames.
2. **ntfs_readlink_hlp() / ntfs_get_link()** (fs/ntfs3/inode.c) — readlink/get_link. Buffer kmalloc(PAGE_SIZE) passed as buflen. Reparse payload allowed up to sbi->reparse.max_size (comment **16K**, from $AttrDef). A UTF-16 path of ~4096 ASCII units fills the page; then buf[ret]='\0' and the extra buffer[err]=0 in ntfs_readlink_hlp() are **one past the heap object**.
3. **ADS listing in frecord.c** — PAGE_SIZE and name_len is u8 (max 255). Same as filenames; **does not fill PAGE_SIZE**. Added after this fix; not required for the bug.
**Step 5.3: TRACE CALLEES**
Record: utf16s_to_utf8s() / utf32_to_utf8(); NLS uni2char(). Conversion, then a terminator store. No new locks/allocs.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace **readlink(2)** on an NTFS symlink/junction/reparse target. Unprivileged if the volume is mounted. Also reachable from a **crafted NTFS image** (USB, etc.). Readdir is a common path but, given PATH_MAX vs 255-char names, not the overflow trigger.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Volume label (a6cd43fe9b083) is the same utf16s_to_utf8s() + missing terminator class. Confirms the contract bug is real in ntfs3.
===============================================================
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 / Makefile → **7.3.0-rc4**
- ntfs_utf16_to_nls() exists in fs/ntfs3/dir.c; callers exist.
- Bug introduced **v5.15**, well before this branch.
- git merge-base --is-ancestor 4871fedaabbfd HEAD → commit is already an ancestor (current file already has buf_len -= 1). That is **not** used as “already selected for stable.”
- Verdict is: this tree’s ntfs3 **has** the function and needed the fix.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean 5-line insert after static_assert. Surrounding function matches the pre-fix form from 5.15-era ntfs3. **Expected apply: clean** on a tree that still has the unfixed function.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No other commit fixes this terminator OOB in ntfs_utf16_to_nls(). Label NUL fix is a sibling pattern, not a substitute.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **fs/ntfs3** — **IMPORTANT** (in-tree filesystem, not staging; CONFIG_NTFS3_FS). Not core VFS/mm, but used on removable NTFS volumes.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Active (7.3 pull has many bounds/UAF/leak fixes). This particular helper has been stable since 5.15.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Filesystem-specific / config-specific** — CONFIG_NTFS3_FS users, especially readlink on reparse/symlink. Default charset is UTF-8 (nls NULL), which is the clearer overflow path.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Trigger: convert a UTF-16 string whose UTF-8 (or NLS) form uses the **entire** destination, then write NUL.
- **Common readdir:** unlikely (255-char names vs PATH_MAX).
- **readlink of a long reparse target:** realistic on crafted or unusual NTFS images; unprivileged if the fs is mounted.
- Not a race.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **1-byte heap overflow** past kmalloc(PAGE_SIZE) in ntfs_get_link(). **Severity: HIGH** (memory corruption; crash and possible security impact). Not a panic on every boot, but it is a real memory-safety bug.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit: HIGH** — closes a heap OOB on ntfs3 readlink, cheap and correct.
- **Risk: VERY LOW** — 5 lines, local, return contract unchanged, slight extra truncation vs overflow.
- **Ratio: strongly favors applying.**
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real off-by-one write: conversion may fill buf_len, then a NUL is stored at buf[buf_len].
- Confirmed in utf16s_to_utf8s(); NLS path has the same contract hole.
- Reachable from ntfs_get_link() (readlink, PAGE_SIZE, reparse up to ~16K).
- Small, obviously correct; return value still excludes NUL.
- Maintainer applied v1; no NAK of the overflow fix.
- Same utf16s_to_utf8s() terminator class already fixed for volume labels.
- Present in this tree’s ntfs3 since 5.15; no missing helpers.
AGAINST:
- No syzbot/Reported-by/reproducer in the message.
- Readdir/PATH_MAX cannot hit it for legal 255-char names.
- LLM-assisted; one list reply was about an unrelated remount UAF.
- No Fixes:/Cc: stable (not a negative for this review).
UNRESOLVED:
- Stable-list AUTOSEL status (lore/stable HTTP 403).
- Exact on-disk $AttrDef $REPARSE_POINT max on every volume (code comments 16K; crafted images can still supply a long path).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — contract is clear; maintainer merged it. No extra Tested-by, but the code change is verifiable.
2. Fixes a real bug that affects users? **PASS** — heap OOB on readlink of a long NTFS reparse target.
3. Important (crash/security/corruption/deadlock)? **PASS** — HIGH:
1-byte heap overflow / memory corruption.
4. Small and contained? **PASS** — +5 lines, one function.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — function and callers exist; patch is a trivial insert.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not an ID/quirk/DT/build/docs exception). It is a normal memory-safety fix.
**Step 9.4: MAKE YOUR DECISION**
This tree is **7.3.0-rc4** with in-tree ntfs3. The helper has written a NUL past a full conversion buffer since v5.15. On this tree that is hit by ntfs_get_link() with a PAGE_SIZE buffer, not by readdir’s oversized PATH_MAX name buffer. The fix is five lines, preserves the return contract, and is the right way to implement “convert then terminate.” Benefit vs risk favors applying it here.
### What it solves for this treentfs_utf16_to_nls() treated buf_len as conversion space **and** still stored a terminator. utf16s_to_utf8s() is allowed to use every byte. ntfs_get_link() then NUL-terminates again at buffer[err]. A long symlink/junction on a mounted NTFS image can corrupt one heap byte. That is a real, important bug, not a style change.
### Stable rules
Obviously correct, small, no new API, no extra dependencies. Meets the documented stable criteria for this checkout.
### Risk vs benefit
Very low regression risk; high benefit on a memory-safety path used by readlink.
### Concerns
- Filename readdir is not the realistic trigger (NTFS_NAME_LEN * 4 < PATH_MAX).
- List discussion mixed in an unrelated remount UAF; this patch does not fix or worsen that.
- No fuzzer report; still verified from the conversion contract and callers in this tree.
Verification:
- [Phase 1] Subject/tags: overflow + reserve NUL; SOB Kyle Zeng + Konstantin Komarov; Assisted-by Codex; no Fixes/Reported-by/Cc stable
- [Phase 2] Diff: +5 in ntfs_utf16_to_nls(): buf_len <= 0 → -EINVAL, then buf_len -= 1
- [Phase 2] utf16s_to_utf8s() (fs/nls/nls_base.c:189-242) can return maxout; pre-fix buf[ret] = '\0' is OOB
- [Phase 3] Blame: 4342306f0f0d5 (v5.15-rc1); rework 2c69078851b3d did not reserve NUL
- [Phase 3] git merge-base --is-ancestor 4871fedaabbfd HEAD — commit is in this history; not used as circular “already selected”
- [Phase 3] No prerequisites; later ADS caller is independent
- [Phase 4] b4 dig -c 4871fedaabbfd → patch.msgid.link/[email protected]; v1 only; maintainer applied; XIAO WU UAF is a different bug
- [Phase 4] WebFetch lore/stable: 403; thread recovered via b4 dig -m
- [Phase 5] Callers: ntfs_dir_emit (PATH_MAX, cannot fill), ntfs_readlink_hlp/ntfs_get_link (PAGE_SIZE, can fill), ADS PAGE_SIZE (255-char names)
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; kernelversion 7.3.0-rc4; ntfs3 and callers present
- [Phase 7] fs/ntfs3, in-tree, not staging
- [Phase 8] Failure: 1-byte heap write past kmalloc(PAGE_SIZE) on readlink; HIGH
- UNVERIFIED: AUTOSEL/stable-list queue status (HTTP 403)
**YES**
fs/ntfs3/dir.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/ntfs3/dir.c +5 -0
@@ -24,6 +24,11 @@ int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const __le16 *name, u32 len,static_assert (sizeof (wchar_t) ==sizeof (__le16)); +if (buf_len <=0 ) +return -EINVAL ; + + buf_len -=1 ; +if (!nls) {/* UTF-16 -> UTF-8 */ ret = utf16s_to_utf8s((wchar_t *)name, len, UTF16_LITTLE_ENDIAN,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 dt-bindings: arm: qcom,ids: Add SoC ID for Snapdragon SDM 850
In reply to Sasha LevinFrom: David Heidelberg <[email protected]>
[ Upstream commit d529495c991a2b7d07c01622e8b3cb5ec066acee ]
Add SoC ID for Qualcomm Snapdragon SDM850.
---
LLM Generated explanations, may be completely bogus:
This tree is **Linux 7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The commit adds one Qualcomm SoC ID constant. That is a device-ID / DT- binding addition for hardware that is already in this tree, and it matches the stable exception for new IDs.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
- Subsystem prefix: dt-bindings: arm: qcom,ids:
- Action verb: **Add**
- Claimed intent: add the numeric SoC ID for Snapdragon SDM850
Record: [dt-bindings/arm/qcom,ids] [add] [define QCOM_ID_SDM850 = 348]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Fixes: none (expected)
- Reported-by: none
- Tested-by: none
- Reviewed-by: Konrad Dybcio <[email protected]> (Qualcomm SoC maintainer)
- Acked-by: Krzysztof Kozlowski <[email protected]> (DT maintainer)
- Link:
https://lore.kernel.org/r/[email protected]
- Cc: stable: none (expected)
- Signed-off-by: David Heidelberg (author); Bjorn Andersson (Qualcomm/SoC maintainer, applied it)
Record: Device-ID addition reviewed by the Qualcomm and DT maintainers; no syzbot/bugzilla report; Message-ID shows this is **v2 1/2**.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Body is one sentence: “Add SoC ID for Qualcomm Snapdragon SDM850.” No stack trace, no crash, no version range.
The cover letter (from b4, not the commit body) states the series is “Useful for sdm850 devices in tree and also will be used by Comma AI comma three.”
Record: [Bug: missing SoC ID 348 in the Qualcomm ID table] [Symptom:
socinfo cannot name SDM850] [No version info in the commit] [Root cause:
ID 348 was never added when qcom,ids.h was created]
**Step 1.4: DETECT HIDDEN BUG FIXES**
This is not a hidden crash/UAF/leak fix. It is an explicit ID addition. That is the documented stable exception for device IDs, not a disguised memory-safety patch.
Record: [Not a hidden memory/locking bug] [It is a device-ID / DT- binding addition]
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
- File: include/dt-bindings/arm/qcom,ids.h
- +1 / −0
- No C function changed; one preprocessor define inserted in numeric order between QCOM_ID_SDA636 (346) and QCOM_ID_SDM632 (349)
- Scope: single-file, one-line addition
Record: [1 file, +1 line] [no functions] [surgical ID add]
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Before: the header jumped from 346 to 349; firmware SoC ID 348 had no QCOM_ID_* name.
After: #define QCOM_ID_SDM850 348 so qcom_board_id(SDM850) in socinfo can compile and match.
Record: [header lacked ID 348 → ID 348 named SDM850]
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Category **(h) Hardware / device ID**.
Without the define, socinfo_machine() cannot map SMEM id 348 to "SDM850". Probe still succeeds; qs->attr.machine stays NULL and /sys/devices/soc0/machine is hidden (soc_attribute_mode returns 0 when machine is NULL). Numeric soc_id sysfs ("348") still works. No driver in this tree switches on QCOM_ID_SDM850 except the socinfo table (companion commit).
Record: [device ID] [missing SoC identity mapping; not a crash]
**Step 2.4: ASSESS THE FIX QUALITY**
Obviously correct: one define, numeric order preserved, value 348 does not collide with neighbors. No API, no locking, no alloc. Regression risk is negligible. Companion patch 2/2 (soc: qcom: socinfo: Add SoC ID for SDM850) is the consumer; this patch alone is an unused define but is required for 2/2 to build.
Record: [minimal and correct] [near-zero regression risk]
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Surrounding IDs come from a79a4b3097bc2 (Krzysztof Kozlowski, 2022-08-30; merged 2022-10-17): “dt-bindings: arm: qcom: document qcom,msm-id and qcom,board-id”. SDM850 was omitted then. In-tree SDM850 DTS exists since 44acee2078447 (2019-09-05, Lenovo Yoga C630).
Record: [gap introduced with qcom,ids.h in 2022] [SDM850 boards present since 2019]
**Step 3.2: FOLLOW THE FIXES: TAG**
No Fixes: tag.
Record: [N/A — no Fixes: tag]
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
This is **v2 1/2** of “Recognize Snapdragon SDM850”:
- 1/2: d529495c991a2 this define
- 2/2: 743af1d6a8b4b socinfo table entry { qcom_board_id(SDM850) }
v1 was named SDA850; v2 renamed to SDM850 (Konrad) and added the socinfo consumer (Krzysztof).
Record: [two-patch series; this is the ID, 2/2 is the table] [standalone apply is clean; useful with 2/2]
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
David Heidelberg is a board/DT contributor, not the subsystem maintainer. Applied by Bjorn Andersson. Konrad reviewed; Krzysztof acked.
Record: [author is a contributor; Qualcomm/DT maintainers reviewed and applied]
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Needs include/dt-bindings/arm/qcom,ids.h (present since 2022 in this tree) and, for a user-visible effect, the socinfo consumer. No new helper, struct, or API.
Record: [depends on existing qcom,ids.h] [can apply standalone] [pairs with socinfo 2/2]
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**b4 dig -c d529495c991a2 matched:
- v1: SDA 850 (2026-06-23)
- v2: [PATCH v2 0/2] Recognize Snapdragon SDM850 (2026-06-27)
- URL:
https://patch.msgid.link/[email protected]
Thread (saved via b4 dig -m): no NAKs, no stable discussion. Krzysztof Acked-by; Konrad Reviewed-by; Bjorn applied both patches.
lore.kernel.org HTTP fetches returned 403; b4/mbox is the verified source.
Record: [v1→v2 naming + consumer] [no NAK] [no Cc: stable in review]
**Step 4.2: CHECK WHO REVIEWED THE PATCH**b4 dig -w original To/Cc: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, Conor Dooley, linux-arm-msm, devicetree, linux- kernel.
Record: [right maintainers and lists]
**Step 4.3: SEARCH FOR THE BUG REPORT**
No Reported-by / bugzilla / syzbot. Motivation is identification of in- tree SDM850 machines and Comma 3.
Record: [no crash report; hardware-identification request]
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Series is 2/2. 2/2 is the one-line socinfo entry that uses this define.
Record: [companion 743af1d6a8b4b] [both one-liners]
**Step 4.5: CHECK STABLE MAILING LIST HISTORY** lore.kernel.org/stable search returned 403. No evidence in the patch thread that stable was discussed.
Record: [UNVERIFIED: no stable-list thread retrieved due to 403]
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
No function edited. Consumer is socinfo_machine() via qcom_board_id(SDM850) → QCOM_ID_SDM850.
Record: [define only; consumer socinfo_machine()]
**Step 5.2: TRACE CALLERS**socinfo_machine() is called from qcom_socinfo_probe() when reading SMEM SMEM_HW_SW_BUILD_ID. That runs on Qualcomm platforms with socinfo. QCOM_ID_SDM850 is not used in qcom-cpufreq-nvmem.c or clk drivers.
Record: [socinfo probe on SDM850; naming only]
**Step 5.3: TRACE CALLEES**socinfo_machine() walks soc_id[] and returns the name or NULL. Probe does not fail on NULL machine.
Record: [lookup table; NULL = unnamed SoC]
**Step 5.4: FOLLOW THE CALL CHAIN**
Boot on SDM850 (Yoga C630, Galaxy Book S / w737, MateBook E 2019, Comma
3) → qcom_socinfo_probe → socinfo_machine(348). Reachable on those machines, not from a generic syscall on unrelated hardware.
Record: [reachable on SDM850 boots] [not a core/universal path]
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
The same file is a long list of QCOM_ID_* defines; socinfo.c has matching qcom_board_id(*) rows. This follows that pattern.
Record: [standard qcom SoC-ID add]
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Yes. include/dt-bindings/arm/qcom,ids.h exists. Surrounding IDs 346 and 349 match the hunk. SDM850 DTS and socinfo exist. The define is already present at line 187 (git merge-base --is-ancestor d529495c991a2 HEAD is true). That is because this checkout **is 7.3-rc4**, which is the series that merged the ID; it is not used as “already selected for stable.”
Record: [qcom,ids.h and socinfo present] [gap existed from 2022 until this 7.3 change]
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Hunk context matches this tree. One-line insert. Clean apply.
Record: [clean apply]
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
No earlier equivalent SDM850 ID. Companion socinfo commit is also in this 7.3 tree.
Record: [no prior substitute fix]
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY** Qualcomm DT bindings + socinfo. Platform-specific identification, not mm/VFS/net core.
Record: [drivers/soc/qcom + dt-bindings] [PERIPHERAL / platform- specific, but in-tree laptops/boards]
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**qcom,ids.h still receives regular new-ID commits (SM7750, IPQ9650, SA8797P, …). Mature table, ongoing ID adds.
Record: [active, table-driven ID file]
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Users of SDM850 (Lenovo Yoga C630, Samsung w737, Huawei MateBook E 2019, Comma 3). CONFIG_QCOM_SOCINFO.
Record: [platform-specific Qualcomm SDM850]
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Every boot on SDM850 when socinfo probes. Not unprivileged-exploit; firmware reports id 348.
Record: [every SDM850 boot] [not a security trigger]
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Without the ID (and 2/2): SoC not named; sysfs machine hidden; hardware still boots via existing DTS. Not oops/deadlock/corruption.
Record: [wrong/missing SoC name] [LOW functional severity; still a real ID gap]
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Benefit: SDM850 identified in socinfo/sysfs, same class as adding a device ID to an existing driver.
Risk: one #define, no runtime logic.
Record: [moderate benefit for those boards] [very low risk] [favorable]
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Official Documentation/process/stable-kernel-rules.rst: “It must either fix a real bug that bothers people **or just add a device ID**.”
- User-facing exception: new IDs on an existing driver/table, and DT binding for existing hardware.
- 1 line, obviously correct, reviewed by Konrad Dybcio and Krzysztof Kozlowski, applied by Bjorn Andersson.
- In-tree SDM850 machines since 2019; this fills the 2022 ID-table gap.
- This tree has qcom,ids.h, socinfo, and SDM850 DTS; the hunk matches.
AGAINST:
- Not a crash/UAF/corruption fix.
- Patch 1/2; user-visible naming needs 2/2.
- No user crash report.
UNRESOLVED:
- Could not read lore.kernel.org/stable (HTTP 403). Unlikely to change the ID-exception reading.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — one define, maintainer review/ack/apply.
2. Fixes a real bug that affects users? **PASS** under the written “or just add a device ID” clause (identification of in-tree SDM850).
3. Important issue (crash, security, corruption, deadlock)? **PASS** as the device-ID exception, not as a crash fix.
4. Small and contained? **PASS** — +1 line, one header.
5. No new features or APIs? **PASS** — no new uAPI; existing ID table.
6. Can apply to the local tree? **PASS** — file and context exist in 7.3-rc4.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Yes: **new device ID** on the existing Qualcomm ID/socinfo tables, and a **DT binding addition** for hardware already described in this tree.
**Step 9.4: MAKE YOUR DECISION**
Backport. It is the documented device-ID exception, not a refactor or new driver. Pairing with 743af1d6a8b4b is the complete recognition, but this patch is the ID itself and is appropriate for this tree.
What it solves for this tree: SDM850 (id 348) was missing from qcom,ids.h, so socinfo could not name boards that have been in the kernel since 2019. That is exactly the “add a device ID” case in stable- kernel-rules, with essentially no regression risk.
Verification:
- [Phase 1] Parsed tags: Reviewed-by Konrad Dybcio, Acked-by Krzysztof Kozlowski, Link to v2 1/2; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: +1 #define QCOM_ID_SDM850 348 in include/dt- bindings/arm/qcom,ids.h
- [Phase 3] git blame: neighbors from a79a4b3097bc2 (2022); this line from d529495c991a2
- [Phase 3] No Fixes: tag
- [Phase 3] Companion 743af1d6a8b4b adds socinfo { qcom_board_id(SDM850) }
- [Phase 3] git merge-base --is-ancestor d529495c991a2 HEAD: yes (7.3 origin, not used as “already selected”)
- [Phase 4] b4 dig -c d529495c991a2:
https://patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1 SDA850 → v2 SDM850 + socinfo consumer
- [Phase 4] b4 dig -w: Bjorn, Konrad, Rob, Krzysztof, Conor, linux-arm- msm, devicetree
- [Phase 4] mbox: Acked-by Krzysztof, Reviewed-by Konrad, Applied-by Bjorn; cover letter names in-tree SDM850 and Comma 3
- [Phase 4] lore.kernel.org WebFetch/curl: 403
- [Phase 5] grep: only socinfo.c uses QCOM_ID_SDM850 among C files; cpufreq/clk do not
- [Phase 5] socinfo_machine() returns NULL for unknown ids; probe still succeeds; machine sysfs hidden if NULL
- [Phase 6] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; Makefile 7.3.0-rc4
- [Phase 6] ids.h context matches; SDM850 DTS present (sdm850.dtsi includes sdm845.dtsi; no qcom,msm-id in those files)
- [Phase 7] subsystem qcom dt-bindings/socinfo
- [Phase 8] failure mode: unnamed SoC in sysfs, not oops
- [Phase 9] Documentation/process/stable-kernel-rules.rst line 15: “or just add a device ID”
- UNVERIFIED: stable@ mailing-list archive (HTTP 403)
**YES**
include/dt-bindings/arm/qcom,ids.h | 1 + 1 file changed, 1 insertion(+)
include/dt-bindings/arm/qcom,ids.h +1 -0
@@ -184,6 +184,7 @@#define QCOM_ID_IPQ8078 344#define QCOM_ID_SDM636 345#define QCOM_ID_SDA636 346 +#define QCOM_ID_SDM850 348#define QCOM_ID_SDM632 349#define QCOM_ID_SDA632 350#define QCOM_ID_SDA450 351
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 HID: elecom: Add support for ELECOM M-XT4DRBK (018E)
In reply to Sasha LevinFrom: Berke Durak <[email protected]>
[ Upstream commit f3c2b266b8fd7cf816d36168d19f67e716f2c080 ]
The 2025 revision of the left-handed EX-G wireless trackball (M-XT4DRBK-G) reports USB ID 056e:018e instead of 056e:00fd. Its report descriptor declares an 8-bit button field (Report Count 8) but only five usages (Usage Maximum 5), so the sixth (Fn) button ends up as a duplicate of button 5 and is unusable.
The report descriptor has the same layout as the M-XT3DRBK 018C (button usage maximum at offset 16, button report count at 22, button report size at 24, padding report size at 30), so reuse that fixup.
Rename the existing M_XT4DRBK define to M_XT4DRBK_00FD to match the convention used for the other EX-G revisions.
Tested on a Raspberry Pi 5 with the same fixup in an out-of-tree module on 6.12 (6.12.96+rpt-rpi-2712); all six buttons are reported after the fix, and they work (tested with xev as well).
Report descriptor as sent by the device, pre-fix (056e:018e, 215 bytes):
05 01 09 02 A1 01 09 01 A1 00 85 01 05 09 19 01
29 05 15 00 25 01 95 08 75 01 81 02 95 01 75 00
81 01 05 01 09 30 09 31 16 00 80 26 FF 7F 75 10
95 02 81 06 C0 A1 00 05 01 09 38 15 81 25 7F 75
08 95 01 81 06 C0 A1 00 05 0C 0A 38 02 95 01 75
08 15 81 25 7F 81 06 C0 C0 06 01 FF 09 00 A1 01
85 02 09 00 15 00 26 FF 00 75 08 95 07 81 02 C0
05 0C 09 01 A1 01 85 05 15 00 26 3C 02 19 00 2A
3C 02 75 10 95 01 81 00 C0 05 01 09 80 A1 01 85
03 19 81 29 83 15 00 25 01 95 03 75 01 81 02 95
01 75 05 81 01 C0 06 BC FF 09 88 A1 01 85 04 95
01 75 08 15 00 26 FF 00 19 00 2A FF 00 81 00 C0
06 02 FF 09 02 A1 01 85 06 09 02 15 00 26 FF 00
75 08 95 07 B1 02 C0
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.18.57** (v6.18.57-155-gcdf239ca885b2). The question is whether this HID/elecom USB-ID + report-descriptor fixup should be backported here. The driver, the existing mouse_button_fixup() helper, and the sibling 018C fixup are all already present in 6.18.57.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [HID / elecom] [Add support] [USB ID 056e:018e for the 2025 M-XT4DRBK-G trackball, plus the existing button report-descriptor fixup]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- No Fixes: tag (expected for this review)
- No Reported-by: / Tested-by: / Reviewed-by: / Acked-by:
- No Link:
- No Cc: [email protected] (expected; not a negative)
- Assisted-by: LLM
- Signed-off-by: Berke Durak <[email protected]> (author)
- Signed-off-by: Jiri Kosina <[email protected]> (HID maintainer)
- Ignore pipeline Signed-off-by: Sasha Levin and [Upstream commit ...]
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: 2025 left-handed EX-G wireless trackball (M-XT4DRBK-G) uses USB ID 056e:018e instead of the old 056e:00fd.
- Descriptor claims an 8-bit button field (Report Count 8) but only five usages (Usage Maximum 5), so the sixth (Fn) button is a duplicate of button 5 and is unusable.
- Root cause: same broken descriptor layout as M-XT3DRBK 018C (offsets 16/22/24/30).
- Symptom: extra button does not work; mouse otherwise enumerates.
- Author tested on Raspberry Pi 5, 6.12 (6.12.96+rpt-rpi-2712), via an out-of-tree module; all six buttons work (xev).
- Full 215-byte pre-fix descriptor is included.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is a device-ID addition plus an existing HID report-descriptor quirk. The rename M_XT4DRBK → M_XT4DRBK_00FD is local naming only.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- drivers/hid/hid-ids.h: +1 ID (0x018e), rename existing 0x00fd define
- drivers/hid/hid-elecom.c: +1 case in elecom_report_fixup(), +1 elecom_devices[] entry, rename 00FD references
- drivers/hid/hid-quirks.c: +1 hid_have_special_driver[] entry, rename 00FD
- Scope: 8 insertions, 4 deletions across 3 files. Surgical, existing driver only.
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Before: 056e:018e is not in hid-elecom, so hid-generic binds and the stock descriptor is used (Usage Maximum 5 / Count 8). Old 056e:00fd still uses the 6-button fixup via USB_DEVICE_ID_ELECOM_M_XT4DRBK.
- After: 018e is claimed by hid-elecom and runs mouse_button_fixup(..., 22, 30, 24, 16, 6) (same as 018C). Old 00FD device still hits the same 6-button fixup through the renamed define. hid_have_special_driver keeps hid-generic from binding 018E.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: [Hardware workaround / device ID + HID descriptor quirk]
- Broken HID report descriptor: Usage Maximum 5 vs Report Count 8.
- Fix reuses the proven 018C path: set count and usage max to 6, padding to 2.
Verified against the included descriptor (first 32 bytes):
``` offset 16: 29 05 Usage Maximum (5) offset 22: 95 08 Report Count (8) offset 24: 75 01 Report Size (1) offset 30: 75 00 padding Report Size (0) ```
Those match mouse_button_fixup(hdev, rdesc, *rsize, 22, 30, 24, 16, 6). The helper then writes count=6, usage max=6, padding=2. The 018C commit in this tree used the identical dump.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: new ID, existing helper, offsets match the dump.
- Minimal: no new APIs, no new helper, no behavior change for 00FD.
- Rename is kernel-internal (hid-ids.h); grep shows no leftover USB_DEVICE_ID_ELECOM_M_XT4DRBK users.
- Regression risk is low: mouse_button_fixup() bails out unless the expected HID items are at those offsets, so a mismatched 018E descriptor would be left unchanged.
- hid-quirks.c update is required so hid-generic does not steal the device (HID_QUIRK_HAVE_SPECIAL_DRIVER).
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Original M-XT4DRBK 00FD support: fbb77e88f08ce (2018, Tomasz Kramkowski), already in 6.18.57.
- Parameterized mouse_button_fixup(): 68d09380a6278 (2020), already in 6.18.57.
- 018C sibling layout this patch reuses: da1880c7b6b83 (Arnoud Willemsen), already in 6.18.57 (git merge-base --is-ancestor returned 0).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not a regression in previously working 018E support; 018E was never in this tree. The bug is the device’s descriptor, same class as 00FD/018C.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent hid-elecom.c history is the same pattern of “new USB ID
+ existing fixup”:
- cdcbb8e8d10f6 M-XT3URBK 018F (in 6.18.57)
- da1880c7b6b83 M-XT3DRBK 018C (in 6.18.57)
- a36e053b16804 HUGE Plus M-HT1MRBK (in 6.18.57) Standalone; not patch X/Y.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Berke Durak has only this hid-elecom commit here. Jiri Kosina (HID maintainer) signed off and applied it.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs mouse_button_fixup() and the 018C case. Both exist at v6.18.57. No new functions. Can apply standalone. patch --dry-run of this diff onto the v6.18.57 copies of the three files succeeded.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c a6dbbf8a1601a:
https://patch.msgid.link/[email protected]
- b4 dig -a: single revision (v1 only), 2026-09-07
- lore.kernel.org fetches returned 403; discussion confirmed via patchew and openwall mirrors
- Jiri Kosina: “Applied, thanks.” No NAK, no requested respin, no stable-risk comments
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc Jiri Kosina, Benjamin Tissoires, linux- input, linux-kernel. HID maintainer applied it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No bugzilla/syzbot link. The author is the reporter and tester, with a full descriptor dump and xev confirmation. Same failure mode as 018C, which is already in this tree.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone v1. Closely related 018C/018F/HUGE Plus ID+fixup patches are already in 6.18.57.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: UNVERIFIED. lore.kernel.org/stable/?q=M-XT4DRBK returned 403. No evidence of a prior rejection. Does not change the technical verdict.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: elecom_report_fixup() (switch cases / id table); mouse_button_fixup() called but not modified; ID tables in hid- elecom.c and hid_have_special_driver[].
**Step 5.2: TRACE CALLERS**
Record:
- elecom_report_fixup ← elecom_driver.report_fixup ← hid-core.c hid_open_report() (device->driver->report_fixup(...) at line 1305)
- hid_have_special_driver match ← hid_gets_squirk() sets HID_QUIRK_HAVE_SPECIAL_DRIVER ← hid_generic_match() returns false so hid-generic does not bind
**Step 5.3: TRACE CALLEES**
Record: mouse_button_fixup() only mutates three descriptor bytes after pattern checks; hid_info() log. No allocation, locking, or I/O.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Plug USB receiver → usbhid → hid parse → report_fixup → input events. Userspace-reachable on plug. Unprivileged users then use the extra button via evdev. Not a security bug; it is a functional hardware bug.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same pattern already used for 018C, 018F, DT2, HUGE, etc. in this file. This is the left-handed 2025 wireless counterpart of 018C.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. v6.18.57 has hid-elecom, mouse_button_fixup(), and 018C’s layout, but **not** ID 0x018e. Without this patch, 018E is a generic HID mouse with a broken sixth button. The 00FD model is already quirked.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply onto v6.18.57 (patch --dry-run rc 0). Parent vs v6.18.57 differs only by an unrelated ITE keyboard ID later in hid- ids.h.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No 018E fix in v6.18.57. 018C/018F/HUGE Plus ID+fixup patches **are** already in 6.18.57, which is the same stable-accepted class of change.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: [drivers/hid/hid-elecom.c] [PERIPHERAL / driver-specific], gated by CONFIG_HID_ELECOM. Important for owners of this trackball; not core MM/VFS.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature driver (2010–); recent work is additional ELECOM IDs and descriptor fixups, several of which already landed in 6.18.y.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver-specific / config-specific: users of ELECOM M-XT4DRBK-G 2025 (056e:018e) with CONFIG_HID_ELECOM. 00FD users are unchanged.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Every plug-in of that dongle. Not a race. Unprivileged users see a missing/duplicated Fn button.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: [Broken extra mouse button on specific hardware] [MEDIUM functional / hardware-quirk]. Not a crash, UAF, or corruption issue. This is the documented stable exception for USB IDs and hardware quirks.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: 2025 left-handed EX-G trackball gets a working sixth button on 6.18.y, matching what 018C already got.
- Risk: very low (8/4 line change, existing helper, pattern-gated, maintainer-applied, tested).
- Ratio: high benefit for affected hardware, negligible regression risk.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- USB ID + existing HID quirk on an existing driver (stable exceptions 1 and 2)
- Real user-visible bug: sixth button unusable; author tested the fix
- Descriptor offsets verified against the dump and against 018C already in this tree
- Small, obviously correct, no new APIs
- HID maintainer applied v1 with no objections
- Same class of patch (018C/018F/HUGE Plus) already in 6.18.57
- Applies cleanly to this tree
AGAINST:
- Not a crash/security/corruption fix
- Affects one consumer trackball model
- Author is not a regular HID contributor; patch notes `Assisted-by:
LLM` (mitigated by maintainer apply + dump + test)
UNRESOLVED:
- Could not fetch lore.kernel.org (403) or search stable@ archives directly; discussion recovered from b4/patchew/openwall
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — offsets match; author tested; maintainer applied
2. Fixes a real bug that affects users? **PASS** — Fn button unusable without the quirk
3. Important issue? **PASS** under the hardware-quirk / new-ID exception (severity MEDIUM, not CRITICAL)
4. Small and contained? **PASS** — 8 insertions / 4 deletions, 3 files
5. No new features or APIs? **PASS** — ID + existing fixup only
6. Can apply to the local tree? **PASS** — clean apply to v6.18.57; prerequisites present
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Device ID addition to existing driver** and **hardware quirk/workaround**. Both qualify for stable.
**Step 9.4: MAKE YOUR DECISION**
YES. This is the same HID-elecom USB-ID + report-descriptor quirk 6.18.y has already taken for 018C. It does not add a driver or API; it makes a current ELECOM trackball’s sixth button work.
What the commit solves: the 2025 M-XT4DRBK-G (056e:018e) ships a descriptor that only declares five button usages, so Linux reports the Fn button as a duplicate of button 5. The fix binds that ID to hid- elecom and reuses the 018C mouse_button_fixup().
Risk vs benefit: benefit is a working extra button on real hardware; risk is a few table entries and a pattern-checked 3-byte descriptor edit. 00FD behavior is unchanged.
No extra prerequisites; 018C’s helper and case are already in this tree.
Verification:
- [Phase 1] Parsed tags: author + Jiri Kosina SOB; no Fixes/Cc stable/Reported-by; LLM-assisted
- [Phase 1] Body: 056e:018e, Usage Maximum 5 vs Count 8, sixth button unusable; tested on Pi 5 / 6.12
- [Phase 2] Diff: +8/-4 in hid-elecom.c, hid-ids.h, hid-quirks.c; rename 00FD define; add 018E to 018C fixup
- [Phase 2] Descriptor offsets 16/22/24/30 verified against the dump
- [Phase 3] git describe HEAD / Makefile: local tree is 6.18.57
- [Phase 3] git merge-base --is-ancestor a6dbbf8a1601a v6.18.57 → not in v6.18.57 (exit 1)
- [Phase 3] 00FD support fbb77e88f08ce and 018C da1880c7b6b83 are ancestors of v6.18.57
- [Phase 3] v6.18.57 still uses USB_DEVICE_ID_ELECOM_M_XT4DRBK only; no 018E
- [Phase 3] Author has no other hid-elecom commits here
- [Phase 4] b4 dig -c: msgid [email protected]; v1 only
- [Phase 4] b4 dig -w: Kosina + Tissoires + linux-input; Kosina applied
- [Phase 4] lore.kernel.org 403; patchew/openwall used instead
- [Phase 4] UNVERIFIED: stable@ archive search (403)
- [Phase 5] Callers: hid-core report_fixup on probe; hid-generic skips via HID_QUIRK_HAVE_SPECIAL_DRIVER
- [Phase 6] patch --dry-run onto v6.18.57 files: success
- [Phase 6] Related 018C/018F/HUGE Plus ID patches already in 6.18.57
- [Phase 8] Failure mode: extra button unusable, not a kernel crash
- UNVERIFIED: original lore HTML (403); does not affect the decision
**YES**
drivers/hid/hid-elecom.c | 6 ++++-- drivers/hid/hid-ids.h | 3 ++- drivers/hid/hid-quirks.c | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-)
drivers/hid/hid-elecom.c +4 -2
@@ -79,7 +79,7 @@ static const __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc,case USB_DEVICE_ID_ELECOM_M_XT3URBK_00FB :case USB_DEVICE_ID_ELECOM_M_XT3URBK_018F :case USB_DEVICE_ID_ELECOM_M_XT3DRBK_00FC : -case USB_DEVICE_ID_ELECOM_M_XT4DRBK : +case USB_DEVICE_ID_ELECOM_M_XT4DRBK_00FD :/* * Report descriptor format: * 12: button bit count
@@ -104,6 +104,7 @@ static const __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc,mouse_button_fixup (hdev, rdesc, *rsize,12 ,30 ,14 ,20 ,8 );break ;case USB_DEVICE_ID_ELECOM_M_XT3DRBK_018C : +case USB_DEVICE_ID_ELECOM_M_XT4DRBK_018E :/* * Report descriptor format: * 22: button bit count
@@ -148,7 +149,8 @@ static const struct hid_device_id elecom_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3URBK_018F) }, { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3DRBK_00FC) }, { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3DRBK_018C) }, - { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT4DRBK) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT4DRBK_00FD) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT4DRBK_018E) }, { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1URBK) }, { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1DRBK) }, { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT2DRBK) },
drivers/hid/hid-ids.h +2 -1
@@ -466,7 +466,8 @@#define USB_DEVICE_ID_ELECOM_M_XT3URBK_018F 0x018f#define USB_DEVICE_ID_ELECOM_M_XT3DRBK_00FC 0x00fc#define USB_DEVICE_ID_ELECOM_M_XT3DRBK_018C 0x018c -#define USB_DEVICE_ID_ELECOM_M_XT4DRBK 0x00fd +#define USB_DEVICE_ID_ELECOM_M_XT4DRBK_00FD 0x00fd +#define USB_DEVICE_ID_ELECOM_M_XT4DRBK_018E 0x018e#define USB_DEVICE_ID_ELECOM_M_DT1URBK 0x00fe#define USB_DEVICE_ID_ELECOM_M_DT1DRBK 0x00ff#define USB_DEVICE_ID_ELECOM_M_DT2DRBK 0x018d
drivers/hid/hid-quirks.c +2 -1
@@ -431,7 +431,8 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3URBK_018F) }, { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3DRBK_00FC) }, { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3DRBK_018C) }, - { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT4DRBK) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT4DRBK_00FD) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT4DRBK_018E) }, { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1URBK) }, { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1DRBK) }, { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT2DRBK) },
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 perf/core: Fix kernel register info leak via hardware skid
In reply to Sasha LevinFrom: Dapeng Mi <[email protected]>
[ Upstream commit 166f10836a653dfa280d4335603b52f685b8b1ef ]
An unprivileged hardware perf event using exclude_kernel=1 can leak kernel register data to user space via PERF_SAMPLE_REGS_INTR or PERF_SAMPLE_IP. Due to hardware skid, a PMI may trigger after the CPU has already entered kernel space (Ring 0), bypassing the perf_allow_kernel() privilege barrier.
This security vulnerability is severely exacerbated by upcoming support for SIMD register sampling via XSAVES, which could expose sensitive kernel FPU states (such as active cryptographic keys).
Fix this by ensuring that sampled register data is dropped if the event's exclude_kernel attribute is set but the PMI catches the CPU in kernel mode.
---
LLM Generated explanations, may be completely bogus:
I have enough to decide: this is a real unprivileged kernel-register leak on 6.18.53, and the fix is small enough to backport.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [perf/core] [Fix] [Stop unprivileged hardware sampling from leaking kernel IP/register state when PMI skid lands in Ring 0]
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Dapeng Mi <[email protected]> (author)
- Signed-off-by: Peter Zijlstra (Intel) <[email protected]> (perf/core maintainer; merged into tip perf/core)
- Link: https://lore.kernel.org/all/[email protected]
nel.org/ (earlier discussion; lore fetch returned 403)
- Link: https://patch.msgid.link/20260616044654.3468742-8-
[email protected] (v4 series, this patch)
- No Fixes: tag (expected)
- No Cc: stable (expected)
- No Reported-by / Tested-by / Reviewed-by / Acked-by besides SOBs
- Ignore: Signed-off-by: Sasha Levin and "[Upstream commit 166f10836a653dfa280d4335603b52f685b8b1ef]" (pipeline markers)
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: An unprivileged hardware perf event with exclude_kernel=1 can still observe kernel register data through PERF_SAMPLE_REGS_INTR or PERF_SAMPLE_IP.
- Symptom/failure mode: Kernel IP and interrupt-time register state (GPRs; on some Intel platforms PEBS XMM too) are copied into the userspace mmap buffer. That is a KASLR / kernel-state info leak. The message also warns that later XSAVES SIMD sampling would make this worse (crypto-key material in FPU/SIMD state).
- Trigger: Hardware PMI skid: the overflow interrupt is delivered after the CPU has already entered kernel mode, so perf_allow_kernel() at perf_event_open() time is bypassed.
- Root cause: Sample preparation always dumps regs / IP from the PMI frame, with no check that exclude_kernel is consistent with user_mode(regs).
- Versions: No kernel-version range in the message. The REGS_INTR dump path dates to 2014; guest IP helper to 2024.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. Subject and body state a security leak and a surgical filter. Not a hidden bug.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: kernel/events/core.c (+30 / -7)
- Functions: perf_instruction_pointer(), perf_sample_regs_intr(), call site in perf_prepare_sample()
- Scope: single-file surgical fix
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Hunk 1 (perf_instruction_pointer): Before, guest and host always returned the captured IP. After, if exclude_kernel and the captured context is not userspace (host !user_mode(regs), or guest without PERF_GUEST_USER), IP is replaced with 0.
- Hunk 2 (perf_sample_regs_intr): Before, always regs_intr->regs = regs and a real ABI. After, if exclude_kernel && !user_mode(regs), ABI is PERF_SAMPLE_REGS_ABI_NONE and regs is NULL so perf_output_sample() writes a zero ABI and skips register payload.
- Hunk 3 (perf_prepare_sample): Passes event->attr.exclude_kernel into the new parameter. Sample header size already accounts for a NULL regs pointer (if (data->regs_intr.regs)), so dyn_size stays consistent.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record: Memory-safety / info-leak (unprivileged kernel-state disclosure), not UAF/leak-of-heap.
- Mechanism: PMI skid + exclude_kernel=1 still presents kernel pt_regs to userspace.
- Fix: Drop register payload and zero IP when the sample is kernel-mode but the event asked to exclude the kernel.
- Analogous to the 2017 attempt cc1582c231ea0 ("Drop kernel samples even though :u is specified"), which was reverted in 6a8a75f323572 because dropping the whole sample broke rr overflow signals. This patch keeps the sample/signal and only redacts contents.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: the predicate matches the existing sample_is_allowed() / perf_exclude_event() tests (exclude_kernel && !user_mode(regs)).
- Minimal: three related sites, no API/UAPI change (ABI_NONE is the documented empty-regs encoding).
- Regression risk: low for kernel correctness. Userspace profilers can see IP=0 on skid samples; kernel test robot reported perf-sanity- tests.Object_code_reading.fail for that. Author said the kernel behavior is intended and the test should skip IP 0. rr is not broken because overflow still fires. Privileged exclude_kernel=0 events are unchanged.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- perf_sample_regs_intr() introduced by 60e2364e60e86e (Stephane Eranian, 2014-11-16) "perf: Add ability to sample machine state on interrupt".
- perf_instruction_pointer(event, regs) guest split from 2c47e7a74f4454 / 04782e63917dbc (Colton Lewis, 2024-11-13) "perf/core: Correct perf sampling with guest VMs".
- The leak of kernel IP on :u sampling has been a known class since at least 2017.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Historical related commits:
- cc1582c231ea0 (2017): dropped entire skid kernel samples; Cc:
stable.
- 6a8a75f323572 (2017): reverted that because rr depends on overflow signals, not sample contents.
- 030a976efae83 (2022): reintroduced sample_is_allowed() only for sigtrap, not for sample output. In this tree it is used solely at kernel/events/core.c:10445.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: Sibling security patches in the same Dapeng series (self- contained, not prerequisites of this hunk):
- perf/core: Check kernel access when kernel callchains are requested (callchain permission hole)
- perf/x86/intel: Fix kernel address leakages in LBR stack This patch does not need those to compile or to close the IP/REGS_INTR hole.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Dapeng Mi is an Intel PMU/perf contributor. Peter Zijlstra (subsystem maintainer) signed off and queued it on tip perf/core (commit 166f10836a653dfa280d4335603b52f685b8b1ef, 2026-06-30). Author's other kernel/events work in this clone is unrelated cpu-clock fixes.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: Standalone. All symbols used (user_mode, PERF_SAMPLE_REGS_ABI_NONE, should_sample_guest, perf_guest_state, PERF_GUEST_USER, perf_guest_get_ip) exist in v6.18.53. Signature change of static perf_sample_regs_intr() has a single call site in core.c.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig matched patch-id to lore; msgid [email protected]
- Evolved from the v8 SIMD/XSAVES sampling series (2026-05-29) into a standalone "miscellaneous PMU bug fixes" series:
- v1 2026-06-05: only perf_sample_regs_intr (no IP redaction)
- v2–v4: added perf_instruction_pointer host+guest IP redaction (committed form)
- Merged to tip perf/core 2026-06-30 by Peter Zijlstra; no NAK found.
- Later (2026-09-15) kernel test robot: userspace Object code reading test fails on IP 0. Dapeng: expected; test should filter IP 0. That is not a kernel functional/security regression.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: Recipients (b4 dig -w): Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers, Adrian Hunter, Alexander Shishkin, Andi Kleen, Stephane Eranian, Mark Rutland, linux-kernel, linux-perf-users. Maintainer SOB is the strongest review signal found. Lore HTML itself returned 403; discussion reconstructed from openwall/lkml mirrors.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla. Motivated by analysis around SIMD register sampling. The IP leak is independently real: unprivileged perf record -e cycles:u is a common path, and 2017 already treated skid kernel samples as a security issue.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Same series also has callchain permission and LBR address-leak fixes. Those are separate holes. This commit does not depend on SIMD/XSAVES patches; v6.18.53 has no XSAVES SIMD sampling (git grep of XSAVES SIMD sample paths on v6.18.53 was empty). XMM-via-PEBS already exists on Ice Lake+ (PERF_REG_EXTENDED_MASK in arch/x86/events/core.c).
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable search returned 403. No evidence this was rejected for stable. Absence of Cc: stable is expected for this review pipeline.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: perf_instruction_pointer, perf_sample_regs_intr, perf_prepare_sample. Related existing helpers: sample_is_allowed, perf_allow_kernel, perf_output_sample.
Step 5.2: TRACE CALLERS
Record:
- perf_instruction_pointer(): only used from perf_prepare_sample() (data->ip = ...) when PERF_SAMPLE_IP (or dependent PERF_SAMPLE_CODE_PAGE_SIZE) is set.
- perf_sample_regs_intr(): only called from perf_prepare_sample() for PERF_SAMPLE_REGS_INTR.
- perf_prepare_sample(): __perf_event_output() (normal mmap samples), bpf_overflow_handler(), PEBS/BTS/s390 sampling paths. Hardware PMI → perf_event_overflow() → overflow handler → output. Confirmed __perf_event_overflow() does **not** drop skid kernel samples today; sample_is_allowed() is sigtrap-only.
Step 5.3: TRACE CALLEES
Record: user_mode(regs), perf_arch_instruction_pointer(), perf_guest_get_ip(), perf_guest_state(), perf_reg_abi(). Output
path: perf_output_sample() already treats ABI 0 as "no regs".
Step 5.4: FOLLOW THE CALL CHAIN
Record: Reachable from unprivileged perf_event_open():
- sysctl_perf_event_paranoid > 1 requires exclude_kernel=1 (perf_allow_kernel() at kernel/events/core.c:13553).
- PERF_SAMPLE_IP has no extra privilege check (default sample type).
- PERF_SAMPLE_REGS_INTR is gated only by security_locked_down(LOCKDOWN_PERF), not paranoid. Without lockdown (typical without Secure Boot), unprivileged REGS_INTR is allowed.
Trigger is common: non-precise cycles:u around syscalls/page faults.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same exclude_kernel && !user_mode(regs) already used in sample_is_allowed(), perf_exclude_event(), and tracepoint matching. This patch extends that policy to sample payload. Remaining sibling holes (callchain, LBR) are other commits.
===============================================================
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.18.53** (git describe HEAD = v6.18.53-5049-g0f0bdc2b0dffb, Makefile VERSION=6 PATCHLEVEL=18 SUBLEVEL=53). At tag v6.18.53:
- perf_instruction_pointer returns guest/host IP unconditionally.
- perf_sample_regs_intr(regs) always assigns regs.
- Call site is perf_sample_regs_intr(&data->regs_intr, regs);
- git merge-base --is-ancestor 166f10836a653dfa280d4335603b52f685b8b1ef v6.18.53 is false.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Clean apply expected. Pre-image of both functions and the call site on v6.18.53 matches the patch. PERF_GUEST_USER is in include/linux/perf_event.h. No conflicting refactor of these functions on 6.18.y.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: The 2017 full-sample drop is **not** present (reverted). sample_is_allowed() does not redact IP/REGS_INTR. No other in-tree substitute for this leak on 6.18.53.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [perf/core, kernel/events/core.c] [CORE for observability/security: perf_event_open is a common unprivileged syscall; leak is kernel-wide, not driver-specific]
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Actively maintained (Peter Zijlstra). File still receives UAF/deadlock fixes on 6.18.y; these two functions have been stable for years.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Any unprivileged user who can open a hardware sampling event with exclude_kernel=1 (default paranoid). Universal on systems with a hardware PMU. REGS_INTR extra impact depends on lockdown; IP leak does not.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Common. Non-precise userspace-only sampling (cycles:u) plus kernel entry/exit. Unprivileged-triggerable. Timing-dependent (skid) but well documented and previously reproduced in 2017.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: [Kernel address / register info leak, KASLR bypass; on PEBS XMM also SIMD state] [Severity: HIGH / security. Not a panic. XSAVES full- SIMD crypto-key leak is **not** in 6.18; XMM PEBS already is.]
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: HIGH — closes an unprivileged kernel-IP leak on a default sampling path; also covers REGS_INTR.
- Risk: LOW — ~30 lines, static helper, keeps overflow (rr-safe), existing ABI_NONE encoding.
- Residual: userspace tools may see IP=0 (test already did). That is the security behavior, not a kernel crash.
- Ratio: strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real unprivileged info leak via PMI skid; same class previously sent to stable in 2017.
- Current code on 6.18.53 still emits kernel IP/regs; sample_is_allowed() no longer drops samples.
- Surgical, obviously correct, maintainer-signed, applies cleanly.
- Avoids the rr regression by redacting payload instead of dropping the event.
AGAINST:
- Userspace perf "object code reading" test can fail on IP 0 (author:
fix the test).
- No Fixes:/Cc:stable (not a negative per rules).
- XSAVES SIMD exacerbation is not in 6.18; the IP/GPR (and PEBS XMM) leak still is.
UNRESOLVED:
- Full lore HTML was 403; review reconstructed from mirrors and b4. Peter Zijlstra SOB still verified.
- Whether a userspace-only test fix later landed is unverified in this clone; it does not block the kernel fix.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — maintainer merged; robot only hit expected IP=0.
2. Fixes a real bug that affects users? PASS — unprivileged perf_event_open + hardware sampling.
3. Important issue (crash, security, corruption, deadlock)? PASS — security info leak / KASLR.
4. Small and contained? PASS — one file, +30/-7.
5. No new features or APIs? PASS.
6. Can apply to the local tree? PASS — v6.18.53 pre-image matches.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary security bugfix.
Step 9.4: MAKE YOUR DECISION
This tree is 6.18.53. The buggy dump path is present. The patch is a small, rr-safe security fix with no missing prerequisites. It should be backported.
------------------------------------------------
What the commit solves for stable users
Unprivileged hardware sampling with exclude_kernel=1 can still capture kernel IP and interrupt registers when the PMI skids into Ring 0. On 6.18 that includes default PERF_SAMPLE_IP and, unless lockdown, PERF_SAMPLE_REGS_INTR (including PEBS XMM on capable Intel CPUs). The fix redacts that payload without dropping the sample, so overflow-based tools keep working.
Risk vs benefit
Benefit is a real KASLR/register leak on a common syscall path. Risk is
low: tiny core.c change, existing empty-regs ABI, no locking/API change. The only observed fallout is userspace seeing IP 0, which is intended.
Concerns
No series dependencies for this hunk. XSAVES SIMD is not in 6.18; that does not reduce the IP leak. A follow-up is only needed for the perf selftest, not for kernel correctness.
Verification:
- [Phase 1] Parsed tags: Dapeng Mi author, Peter Zijlstra SOB, two lore/msgid links; no Fixes/Reported-by
- [Phase 2] Diff: perf_instruction_pointer zeros IP; perf_sample_regs_intr uses ABI_NONE; perf_prepare_sample passes exclude_kernel
- [Phase 3] git blame v6.18.53: REGS_INTR dump from 60e2364e60e86e (2014); guest IP from 2c47e7a74f4454 (2024)
- [Phase 3] git log -S sample_is_allowed -- kernel/events/core.c: 2017 drop reverted; current use is sigtrap-only
- [Phase 3] git show 6a8a75f323572: revert because rr needs overflow signals
- [Phase 4] b4 dig -c 7db4d13613f57: matched v4 msgid 20260616044654.3468742-8; recipients include Peter Zijlstra et al.
- [Phase 4] b4 dig -a: originated in SIMD series v8, then standalone bugfix series v1–v4; IP redaction added after v1
- [Phase 4] openwall 2026-09-15: author confirms IP=0 is the leak fix; test should skip it
- [Phase 5] grep: perf_instruction_pointer / perf_sample_regs_intr only used from perf_prepare_sample; overflow path does not drop skid samples
- [Phase 5] perf_allow_kernel() at open requires exclude_kernel for unprivileged users; REGS_INTR only checks lockdown
- [Phase 6] git describe HEAD / Makefile: 6.18.53; v6.18.53 still has the unfiltered dump; ancestor check of 166f10836a65 vs v6.18.53 is false
- [Phase 6] PERF_GUEST_USER present; function pre-image matches patch
- [Phase 6] no XSAVES SIMD sampling in v6.18.53; XMM PEBS already present
- [Phase 8] Failure mode: unprivileged kernel IP/register disclosure, HIGH security
- UNVERIFIED: full lore.kernel.org thread body (HTTP 403); stable@ list search (403)
**YES**
kernel/events/core.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-)
kernel/events/core.c +30 -7
@@ -7499,10 +7499,20 @@ unsigned long perf_misc_flags(struct perf_event *event,unsigned long perf_instruction_pointer (struct perf_event *event,struct pt_regs *regs) { -if (should_sample_guest (event)) -return perf_guest_get_ip (); +/* +* Hardware skid can lead to a scenario where a PMI is +* delivered after the CPU has already entered kernel mode. +* In that case, user-space sampling must not expose kernel +* register state. +*/ +if (should_sample_guest (event)) { +return event->attr.exclude_kernel && + !(perf_guest_state () &PERF_GUEST_USER ) ? +0 :perf_guest_get_ip (); + } -return perf_arch_instruction_pointer (regs); +return event->attr.exclude_kernel && !user_mode (regs) ? +0 :perf_arch_instruction_pointer (regs); } static void
@@ -7536,10 +7546,22 @@ static void perf_sample_regs_user(struct perf_regs *regs_user, }static void perf_sample_regs_intr (struct perf_regs *regs_intr, -struct pt_regs *regs) +struct pt_regs *regs, +bool exclude_kernel) { - regs_intr->regs = regs; - regs_intr->abi =perf_reg_abi (current); +/* +* Hardware skid can lead to a scenario where a PMI is +* delivered after the CPU has already entered kernel mode. +* In that case, user-space sampling must not expose kernel +* register state. +*/ +if (exclude_kernel && !user_mode (regs)) { + regs_intr->abi =PERF_SAMPLE_REGS_ABI_NONE ; + regs_intr->regs =NULL ; + }else { + regs_intr->regs = regs; + regs_intr->abi =perf_reg_abi (current); + } }
@@ -8427,7 +8449,8 @@ void perf_prepare_sample(struct perf_sample_data *data,/* regs dump ABI info */ int size =sizeof (u64); -perf_sample_regs_intr (&data->regs_intr, regs); +perf_sample_regs_intr (&data->regs_intr, regs, + event->attr.exclude_kernel);if (data->regs_intr.regs) {u64 mask = event->attr.sample_regs_intr;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18] perf/core: Fix kernel register info leak via hardware skid
Sashiko has reviewed this patch and found no issues.
Quoted 14 lines
From: Dapeng Mi <[email protected]>
[ Upstream commit
166f10836a653dfa280d4335603b52f685b8b1ef]An unprivileged hardware perf event using exclude_kernel=1 can leak kernel register data to user space via
PERF_SAMPLE_REGS_INTRorPERF_SAMPLE_IP. Due to hardware skid, a PMI may trigger after the CPU has already entered kernel space (Ring 0), bypassing theperf_allow_kernel()privilege barrier.This security vulnerability is severely exacerbated by upcoming support for SIMD register sampling via XSAVES, which could expose sensitive kernel FPU states (such as active cryptographic keys).
Quoted 8 lines
Fix this by ensuring that sampled register data is dropped if the event's
exclude_kernelattribute is set but the PMI catches the CPU in kernel mode.Signed-off-by Dapeng Mi <[email protected]>Signed-off-by Peter Zijlstra (Intel) <[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