net: dsa: mt7530: check CORE_PLL_GROUP4 access in mt7531_setup()
Subsystems (71)
Sasha Levin
maintainerPATCH 1/1 nvme: don't reference NS after unlocking in nvme_ns_head_ctrl_ioctl()
In reply to Sasha LevinFrom: John Garry <[email protected]>
[ Upstream commit 77c57daf98a2ad95ec9ac1371caeff8939cc1f58 ]
In nvme_ns_head_ctrl_ioctl(), once we drop the SRCU read lock we should not reference the NS to lookup the controller, so use the available controller pointer directly.
---
LLM Generated explanations, may be completely bogus:
The local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The candidate is a one-line use-after-unlock fix in the NVMe multipath ioctl path; the rest of this write-up is the forensic check of whether that fix belongs here as a stable backport.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [nvme] [don't reference] Avoid using the namespace object after dropping the SRCU lock in nvme_ns_head_ctrl_ioctl()
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Reviewed-by: Christoph Hellwig <[email protected]> (NVMe co-maintainer)
- Signed-off-by: John Garry <[email protected]> (author)
- Signed-off-by: Keith Busch <[email protected]> (NVMe maintainer; applied the patch)
- No Fixes: tag (expected for this review pipeline)
- No Cc: [email protected] (expected)
- No Reported-by:, Tested-by:, Link:, or syzbot tags
Later mailing-list review also produced Reviewed-by: Hannes Reinecke <[email protected]> (not copied into the committed message).
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** After srcu_read_unlock(&head->srcu), the code still did nvme_ctrl_ioctl(ns->ctrl, ...).
- **Symptom/failure mode:** Use of ns after the SRCU critical section ends. nvme_find_path() does not take an ns kref; SRCU is what keeps ns alive. After unlock, nvme_ns_remove() can finish synchronize_srcu(&ns->head->srcu) and nvme_put_ns() → kfree(ns). Loading ns->ctrl is then a use-after-free.
- **Version info:** None in the message. History shows the pattern dates to 48145b62563a9 (v5.13-rc1 era, 2021).
- **Root cause:** The function already saved struct nvme_ctrl *ctrl = ns->ctrl and used it for nvme_put_ctrl(ctrl), but the ioctl call still went through ns->ctrl after unlock.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. The subject is explicit. This is a real lifetime/UAF fix, not style cleanup. The local ctrl variable existed specifically to survive the unlock; the ioctl call was the leftover unsafe use.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/nvme/host/ioctl.c — 1 insertion, 1 deletion
- Function: nvme_ns_head_ctrl_ioctl()
- Scope: single-file, one-line surgical fix under CONFIG_NVME_MULTIPATH
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
Before:
``` struct nvme_ctrl *ctrl = ns->ctrl; nvme_get_ctrl(ns->ctrl); /* still under SRCU — OK */ srcu_read_unlock(&head->srcu, srcu_idx); ret = nvme_ctrl_ioctl(ns->ctrl, ...); /* ns used after unlock — BUG */ nvme_put_ctrl(ctrl); ``` After: ``` ret = nvme_ctrl_ioctl(ctrl, ...); /* uses the pointer saved under SRCU */ ```
The nvme_get_ctrl() before unlock keeps the controller object alive; only the namespace object was left unprotected.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** use-after-free / lifetime (memory safety), SRCU protection dropped too early relative to ns use
- **Mechanism:** Path lookup is SRCU-only. Callers drop SRCU *on purpose* before controller ioctls so a Delete Namespace passthrough cannot deadlock on synchronize_srcu (comment at the nvme_ns_head_ioctl call site). Concurrent nvme_ns_remove() can then free ns while the old code still loaded ns->ctrl.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: use the already-captured, refcounted ctrl.
- Minimal: one identifier change; no API, locking, or control-flow change.
- Regression risk: very low. ctrl is assigned under SRCU and pinned with nvme_get_ctrl() before unlock.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Buggy nvme_ctrl_ioctl(ns->ctrl, ...) after unlock introduced in 48145b62563a9 (nvme: fix controller ioctl through ns_head, Minwoo Im, 2021-04-22).
- First appeared around **v5.13** (tags/v5.13-rc1~19^2~1^2~6).
- struct nvme_ctrl *ctrl = ns->ctrl was added in that same commit — they saved ctrl for nvme_put_ctrl() but still passed ns->ctrl into the ioctl.
- The SRCU unlock in this function has been there since 3e7d1a55165bd / the 2021 rewrite. This is long-lived buggy code, not a recent regression.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The introducing commit is 48145b62563a9, and git merge-base --is-ancestor 48145b62563a9 HEAD succeeded, so the buggy code is in this lineage.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Nearby John Garry commits (627e8bb91a8fd requeue/SRCU order, a11e0a4cb4189 / 9952f3882ecba cdev lifetime) are **separate** bugs. This diff does not depend on them.
- Not labeled patch X/Y. Standalone one-liner.
- Later 86f9536c2d8f4 only changes the sparse annotation __releases → __releases_shared; not a prerequisite.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: John Garry is a regular NVMe contributor (Oracle). Around this date he also fixed related lifetime issues, but this patch is independent. Maintainers Christoph Hellwig, Keith Busch, and Hannes Reinecke all reviewed/acked it.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. The preimage already has ctrl, nvme_get_ctrl, and srcu_read_unlock. The patch applies standalone.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 77c57daf98a2ad: https://patch.msgid.link/20260706125402.61
[email protected]
- b4 dig -a: **v1 only**; committed version is that v1.
- Thread (saved via b4 dig -m):
- Christoph Hellwig: “Looks good:” + Reviewed-by
- Keith Busch: “Thanks, applied to nvme-7.3.”
- Hannes Reinecke: Reviewed-by: Hannes Reinecke <[email protected]>
- No NAKs, no requests for a v2, no reviewer concern about the approach.
- No explicit Cc: stable in the thread (not a negative; this pipeline expects that).
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc were [email protected], [email protected], [email protected], [email protected], [email protected]. Subsystem maintainers were on the original mail and reviewed it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by / syzbot / bugzilla. Found by code inspection (same author was auditing NVMe lifetime vs SRCU around the same time). The race is still concrete: ioctl + path removal.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone [PATCH], not a numbered series. Sibling lifetime patches are independent.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org /stable/ returned HTTP 403 from this environment. **UNVERIFIED:** no confirmed stable@ discussion. That is expected for a candidate that has not been auto-selected.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
semcode MCP tools are not available; callers/callees were traced with grep and file reads.
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: nvme_ns_head_ctrl_ioctl() only.
**Step 5.2: TRACE CALLERS**
Record:
- nvme_ns_head_ioctl() — block_device_operations.ioctl for the multipath ns-head disk (/dev/nvmeXnY)
- nvme_ns_head_chr_ioctl() — file_operations.unlocked_ioctl for the generic ns-head char device (/dev/ngXnY)
Both call it when is_ctrl_ioctl(cmd) is true: NVME_IOCTL_ADMIN_CMD, NVME_IOCTL_ADMIN64_CMD, or SED/opal ioctls.
**Step 5.3: TRACE CALLEES**
Record: nvme_get_ctrl / nvme_put_ctrl (get_device/put_device on ctrl->device), srcu_read_unlock, nvme_ctrl_ioctl (admin passthrough / SED).
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace ioctl on a multipath NVMe ns-head device. Reachable from userspace. Admin commands typically need privileges, but that does not make a kernel UAF acceptable; privileged management tools and path teardown are exactly the production workload.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Non-multipath nvme_ioctl() / nvme_ns_chr_ioctl() use ns->ctrl without this SRCU drop; those ns objects are tied to the open disk/cdev, so they are a different lifetime model. No second copy of this exact post-unlock ns->ctrl load in nvme_ns_head_ctrl_ioctl.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- Tree: **7.3.0-rc4** (git describe HEAD = v7.3-rc4-27-gf0100363d8c37)
- git merge-base --is-ancestor 77c57daf98a2ad HEAD → yes (the fix is already on this mainline snapshot)
- Preimage (77c57daf98a2ad^) still has nvme_ctrl_ioctl(ns->ctrl, ...) after unlock
- Introducing commit 48145b62563a9 is an ancestor; the bug has been in this lineage since ~v5.13
- Current ioctl.c already uses nvme_ctrl_ioctl(ctrl, ...)
This is a mainline 7.3-rc checkout, not a 6.x.y stable branch. The question is still whether the *fix* is stable-worthy for this codebase. The touched function, the ctrl local, and the SRCU unlock are all present. The bug was not introduced after this tree branched.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply on this code. The hunk is one argument change. Would also apply cleanly to any tree that still has the 2021 nvme_ns_head_ctrl_ioctl shape (the ctrl local + post-unlock ioctl).
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This is the fix. No alternate older fix of the same ns->ctrl load. Related commits fix different lifetime bugs.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/nvme/host — NVMe host ioctl/multipath. **IMPORTANT** (common storage stack; not core mm/vfs, but widely deployed). Gated on CONFIG_NVME_MULTIPATH (Kconfig: “If unsure, say Y.”).
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Active (io_uring passthrough, multipath, ioctl hardening). This particular function body has been stable in shape since 2021.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: NVMe **multipath** users who issue controller ioctls on the ns- head block or char device (NVME_IOCTL_ADMIN_CMD / ADMIN64 / SED). Datacenter NVMe-oF / dual-ported SSD setups.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- srcu_read_lock → nvme_find_path → controller ioctl → **intentional** srcu_read_unlock (to avoid deadlock with namespace delete) → old code loads ns->ctrl
- Concurrent nvme_ns_remove() (path loss, controller delete, admin Delete NS)
- Timing-dependent. Not every ioctl hits it; when it hits, it is a real UAF.
- Triggerable from userspace ioctl; typically privileged admin ioctls.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Use-after-free of struct nvme_ns → KASAN report / oops / potential memory corruption. **Severity: HIGH** (UAF in a production ioctl path).
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** High — closes a UAF that has existed since v5.13 in a standard multipath ioctl path.
- **Risk:** Very low — one-line substitution of an already-saved, refcounted pointer.
- **Ratio:** Strongly favors backporting.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real UAF: ns is SRCU-protected only; used after srcu_read_unlock
- nvme_find_path() does not take an ns kref (verified)
- nvme_ns_remove() does synchronize_srcu(&ns->head->srcu) then nvme_put_ns() → kfree(ns) (verified)
- Callers drop SRCU early on purpose so namespace delete can proceed — the window is intentional
- One-line, obviously correct, uses the pointer the original 2021 code already saved
- Reviewed by Hellwig, Busch, Reinecke; applied to nvme-7.3
- Bug present since ~v5.13; no extra prerequisites
- Userspace-reachable ioctl on common NVMe multipath hardware
AGAINST:
- No crash log / syzbot in the commit message (inspection-found)
- No Fixes:/Cc: stable (expected here; not a reason to reject)
- Gated on CONFIG_NVME_MULTIPATH
- This 7.3-rc4 snapshot already contains the commit (it landed for 7.3); that does **not** reduce technical merit for selecting it as a stable candidate
UNRESOLVED:
- Could not fetch lore.kernel.org in the browser (403); thread was recovered via b4 dig -m
- Could not search lore /stable/ (403)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — one identifier; reviewed by three NVMe maintainers
2. Fixes a real bug that affects users? **PASS** — UAF on ns-head controller ioctl vs path removal
3. Important issue (crash/security/corruption/deadlock)? **PASS** — UAF → oops/corruption; HIGH
4. Small and contained? **PASS** — 1 line, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — function and ctrl local exist; hunk is the existing post-fix form
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. It is a normal memory-safety bugfix.
**Step 9.4: MAKE YOUR DECISION**
This is a textbook stable candidate: a long-standing, small, obviously correct UAF fix in NVMe multipath ioctl handling, with maintainer review and no dependencies.
---
### What the commit solves (for stable users)
On CONFIG_NVME_MULTIPATH, controller ioctls on the namespace-head device drop head->srcu before running the ioctl so a Delete Namespace passthrough cannot deadlock. The namespace pointer is not refcounted across that unlock. Passing ns->ctrl into nvme_ctrl_ioctl() after unlock can dereference a freed nvme_ns if a path is removed concurrently. Using the ctrl pointer saved under SRCU (already pinned with nvme_get_ctrl()) closes that hole.
### Risk vs benefit
Benefit is a UAF/crash fix on a real ioctl path used with NVMe multipath. Risk is essentially nil.
### Concerns
None for applicability on this tree’s NVMe ioctl code. Nearby Garry lifetime patches are not required.
---
Verification:
- [Phase 1] Parsed commit 77c57daf98a2ad: subject, Hellwig Reviewed- by, Garry/Busch SOBs; no Fixes/Reported-by/Cc:stable
- [Phase 1] Body: only describes not using NS after SRCU unlock
- [Phase 2] git show 77c57daf98a2ad: 1 line in nvme_ns_head_ctrl_ioctl, ns->ctrl → ctrl after unlock
- [Phase 2] Read current drivers/nvme/host/ioctl.c: fix present; caller comment documents early SRCU drop to avoid delete-namespace deadlock
- [Phase 3] git blame -L 729,743 drivers/nvme/host/ioctl.c: buggy ioctl-through-ns-head from 48145b62563a9 (2021)
- [Phase 3] git name-rev --tags 48145b62563a9:
tags/v5.13-rc1~19^2~1^2~6
- [Phase 3] git merge-base --is-ancestor 48145b62563a9 HEAD: yes
- [Phase 3] Parent 627e8bb91a8fd is a different requeue/SRCU bug; not a dependency of this hunk
- [Phase 4] b4 dig -c 77c57daf98a2ad: lore at patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: linux-nvme + Hellwig/Busch/Grimberg/Axboe
- [Phase 4] b4 dig -m /tmp/nvme-ns-unlock.mbox: Hellwig R-b, Busch applied to nvme-7.3, Reinecke R-b; no NAK
- [Phase 4] WebFetch lore.kernel.org: 403 — UNVERIFIED via HTTP; thread recovered from mbox
- [Phase 5] grep: callers are nvme_ns_head_ioctl and nvme_ns_head_chr_ioctl; wired from multipath.c fops
- [Phase 5] nvme_find_path() returns path under SRCU only; no nvme_get_ns()
- [Phase 5] nvme_free_ns() kfree’s ns; nvme_ns_remove() synchronize_srcu then nvme_put_ns()
- [Phase 6] make kernelversion / Makefile: 7.3.0-rc4; git describe HEAD: v7.3-rc4-27-gf0100363d8c37
- [Phase 6] git merge-base --is-ancestor 77c57daf98a2ad HEAD: fix already in this mainline snapshot
- [Phase 6] Preimage git show 77c57daf98a2ad^:drivers/nvme/host/ioctl.c: confirmed nvme_ctrl_ioctl(ns->ctrl, ...) after unlock
- [Phase 7] drivers/nvme/host/Kconfig: NVME_MULTIPATH “If unsure, say Y”
- [Phase 8] Failure mode: UAF of struct nvme_ns on controller ioctl vs path remove — HIGH
- UNVERIFIED: stable@ mailing-list history (lore /stable/ HTTP 403)
- UNVERIFIED: no public crash reproducer attached to the patch (does not override the verified lifetime hole)
The patch is obviously correct, fixes a real UAF, is one line, and applies to this tree’s NVMe ioctl code.
**YES**
drivers/nvme/host/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/ioctl.c +1 -1
@@ -727,7 +727,7 @@ static int nvme_ns_head_ctrl_ioctl(struct nvme_ns *ns, unsigned int cmd,nvme_get_ctrl (ns->ctrl);srcu_read_unlock (&head->srcu, srcu_idx); - ret =nvme_ctrl_ioctl (ns->ctrl, cmd, argp, open_for_write); + ret =nvme_ctrl_ioctl (ctrl, cmd, argp, open_for_write);nvme_put_ctrl (ctrl);return ret;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 remoteproc: core: cancel crash_handler work in rproc_add() error path
In reply to Sasha LevinFrom: Jingyi Wang <[email protected]>
[ Upstream commit 0ec167625b4fea30b26da33c188e853ff25d5583 ]
Ensure crash_handler work is cancelled before tearing down rproc resources to avoid accessing freed memory.
---
LLM Generated explanations, may be completely bogus:
The local tree is **7.3-rc4**. This is a one-line UAF guard:rproc_add() must cancel crash_handler before it tears the device down, and that error path exists here.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[remoteproc/core] [cancel] cancel crash_handler work in rproc_add() error path** — “cancel” here is a safety action (flush pending work before teardown), not a feature.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Link:** https://lore.kernel.org/r/20260623-rproc-attach- [email protected] (patch 3/3 of v3 series)
- **Signed-off-by:** Jingyi Wang (author); Bjorn Andersson (remoteproc maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, or Cc: stable (absence is expected for this review)
- Ignore any pipeline SOBs
Notable: this is **v3 3/3**, titled on-list as “improve robustness for rproc_attach fail cases”.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** crash_handler can still be pending/running when rproc_add() unwinds.
- **Symptom:** use of rproc state after debugfs/device_del/char-dev teardown, and after the caller drops the last ref (rproc_type_release() does kfree(rproc) with no work cancel).
- **Failure mode:** use-after-free / use of a half-destroyed rproc from rproc_crash_handler_work().
- **Version info in the message:** none.
- **Root cause (author):** teardown without cancel_work_sync(&rproc->crash_handler).
Cover letter (verified in mbox): *“Failure in rproc_attach() path can cause issues like NULL pointer dereference when doing recovery and rproc_add() fail.”*
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. One-line UAF/lifetime fix. “Ensure … cancelled before tearing down” is explicit.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** drivers/remoteproc/remoteproc_core.c (+1, −0)
- **Function:** rproc_add()
- **Scope:** single-file, one-line surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: On rproc_trigger_auto_boot() failure, rproc_add() jumps to rproc_remove_dev, which used to rproc_delete_debug_dir() → device_del() → rproc_char_device_remove() and return. After the change, it **cancel_work_sync(&rproc->crash_handler) first**, then the same teardown. Success path is unchanged.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** use-after-free / lifetime (work vs teardown); also a resource-lifetime race.
- **Mechanism:** INIT_WORK(&rproc->crash_handler, …) happens in rproc_alloc(). rproc_report_crash() can queue_work(rproc_recovery_wq, &rproc->crash_handler) from IRQ/atomic context. rproc_crash_handler_work() then uses rproc (dev, lock, state, recovery). The rproc_add() error path unregisters the device but never waited for that work; callers then rproc_free()/put_device(), and rproc_type_release() kfree’s rproc with no cancel. Sibling patch 2’s stack shows rproc_crash_handler_work running because rproc_report_crash() fired during attach — so the work is not hypothetical.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct: cancel_work_sync is the standard “don’t free while work may run” pattern. Later rproc_del() uses the same cancel (plus deleting + pm_relax). Regression risk is very low:
cancel on idle work is a no-op. Minor incompleteness: this path does not pm_relax() if cancel returns true (unlike rproc_del()). That is a wakeup-source leak only if the work was actually queued, which is still far better than UAF. No API/data-structure change.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- rproc_remove_dev teardown: **7dbdb8bd7c028** (“Cleanup device in case of failure”, 2021-06-14, in **v5.14-rc1**).
- Auto-boot error goto: same era; auto_boot itself from **7a20c64ddb3dee** (2017).
- crash_handler: **8afd519c3470f** (2012).
- DETACHED sync attach in rproc_trigger_auto_boot(): **e3d2193959824** (2020-07-14).
Buggy combination (error-path teardown without cancelling crash work) has been present for years.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable beyond that.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Same series, same author/date, landed together in v7.3-rc1:
1. **026a3fada4326** (v3-1): async attach via attach_work so attach failure no longer fails rproc_add().
2. **f44ae8ce156a3** (v3-2): subdevs_started — real NULL deref in glink stop during crash recovery (stack trace).
3. **0ec167625b4fe** (this, v3-3): cancel crash work on rproc_add() error.
Later related: **74ee3b2f57674** “Prevent crash handling to race with rproc_del()” (Fixes: 8afd519c3470) — same class of bug on **remove**, not a substitute for this add-error-path cancel.
This line does **not** need patches 1–2 to compile or be correct. Patch 1 **shrinks** the window on this tree (DETACHED attach no longer takes rproc_remove_dev).
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Jingyi Wang is a Qualcomm remoteproc contributor (this series + PAS/attach work). Maintainer **Bjorn Andersson** applied the series. Co- maintainer **Mathieu Poirier** was on the original To/Cc.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None for this hunk. It only needs rproc->crash_handler and the rproc_remove_dev label, both present. Standalone 1-line apply.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **b4 dig -c 0ec167625b4fe:** https://patch.msgid.link/20260623-rproc- [email protected]
- **b4 dig -a:** v2 (2026-05-19) and v3 (2026-06-23). Patch 3 was **added in v2** (“Add change to cancel crash_handler work”). v3 kept it; v3 review comments were about patch 2’s flag placement, not this line.
- Applied version is latest (v3 3/3).
- Bjorn: “Applied, thanks!” — no NAK, no stable discussion in the thread.
- No reviewer Cc: stable on this specific patch.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: **b4 dig -w** recipients: Jingyi Wang; Bjorn Andersson; Mathieu Poirier; Qualcomm colleagues; [email protected]. Right maintainers were on the patch. No extra Reviewed-by on 3/3; maintainer still merged it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla for *this* line. The series cover letter and patch 2 document a real Qualcomm attach-crash NULL deref with a full stack through rproc_crash_handler_work. That is the same window this cancel is meant to close if rproc_add() then fails.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 3-patch robustness series. Patch 1 is a behavior change (async attach). Patch 2 is the NULL-deref fix. Patch 3 is independent UAF hygiene on the add error path. Not a “2/3 without 1/3 won’t build” situation.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** — lore.kernel.org/stable/ fetch returned HTTP
403. No local evidence this was rejected for stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: rproc_add() only. Related: rproc_crash_handler_work(), rproc_report_crash(), rproc_trigger_auto_boot(), rproc_del(), rproc_type_release().
**Step 5.2: TRACE CALLERS**
Record: rproc_add() / devm_rproc_add() are the register path for every remoteproc driver (qcom PAS/ADSP/MSS/WCSS/WCNSS, imx, omap, stm32, mtk, pru, k3, etc.). Called from probe. rproc_report_crash() is exported and used from IRQs (e.g. qcom_q6v5 wdog/fatal, requested in qcom_q6v5_init() **before** rproc_add()).
**Step 5.3: TRACE CALLEES**
Record: Error path: cancel_work_sync → rproc_delete_debug_dir → device_del → rproc_char_device_remove. Crash work: mutex, state, rproc_trigger_recovery(), pm_relax().
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable from driver probe (auto_boot). On this 7.3 tree, after 026a3fada4326, DETACHED attach is async and **does not** fail rproc_add(). The remaining goto rproc_remove_dev is request_firmware_nowait() failure. Crash work is still initialized; IRQs may already be requested. Userspace does not trigger this directly except via device probe/firmware-request failure. Severity if it hits:
UAF in workqueue context.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same cancel later in rproc_del() (74ee3b2f57674). rproc_type_release() still does not cancel works — so add-error-path cancel (and del cancel) are the actual guards.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. Tree is **v7.3-rc4-27-gf0100363d8c37** / **7.3.0-rc4**. rproc_add() error path and crash_handler are here. Candidate **0ec167625b4fe** is in **v7.3-rc1** (git describe --contains → v7.3-rc1~46^2~27). Evaluating merit as if selecting it for this tree:
the code it touches is present; the bug was **not** introduced after 7.3 branched.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply. One line at a stable label. No structural conflict in this file’s rproc_add().
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: 74ee3b2f57674 fixes rproc_del(), not this add-error path. No earlier equivalent cancel on rproc_remove_dev (git log -S shows this commit as the first).
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **drivers/remoteproc** — **IMPORTANT** on Qualcomm/embedded (modems, ADSP, CDSP, Wi-Fi firmware). Not CORE mm/VFS, but crash during probe/recovery is a host kernel oops, not “DSP-only.”
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Active (qcom PAS, crash/remove races, new platforms). Mature core with long-lived rproc_add/crash_handler.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **driver-specific / config-specific** (CONFIG_REMOTEPROC, especially auto_boot and attach/early-boot Qualcomm PAS). Not universal desktop, but common on phones and embedded SoCs.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: auto_boot + rproc_trigger_auto_boot() failure, with crash_handler already queued. On **this** tree, patch 1 removed the attach-fail → rproc_add()-fail path, so the remaining trigger is firmware-nowait failure (and any crash queued around probe). Unprivileged userspace does not have a clean repro; probe/firmware error
+ IRQ crash is the window. Sibling patch proves crash work **does** run during attach.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **UAF / oops in workqueue** if work runs after teardown/free. **Severity: HIGH** (crash; possible memory corruption). Not a guaranteed panic on every boot.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** medium–high if the race hits (UAF); on this tree the attach-fail window is smaller, so benefit is more “correct teardown” than “every Qualcomm boot.”
- **Risk:** very low (1 line, idle cancel is harmless).
- **Ratio:** favorable. Missing a 1-line UAF cancel is worse than applying it.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Explicit UAF/lifetime fix; author states freed-memory access.
- 1 line, obviously correct, same primitive later required in rproc_del().
- rproc_type_release() kfree’s without cancelling work — error-path cancel is necessary.
- Series documents real attach-time crash handling (NULL deref stack in 2/3).
- Maintainer merged; no NAKs.
- Code and error path exist in this 7.3 tree; applies cleanly; no new API.
- Independently correct without the rest of the series.
AGAINST:
- After 026a3fada4326 (already in this tree), DETACHED attach no longer fails rproc_add(), so the original attach-fail UAF is largely gone here; remaining trigger is request_firmware_nowait() failure.
- No Fixes:/Reported-by/syzbot for this exact line; commit body is one sentence.
- Incomplete vs rproc_del() (no pm_relax / deleting).
- Patch 3/3 of a robustness series, not a stand-alone user report.
UNRESOLVED:
- Stable list discussion (lore 403).
- Could not prove a live crash IRQ on the firmware-nowait-only error path on this tree.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — 1-line cancel_work_sync; merged by maintainer after v2/v3.
2. Fixes a real bug that affects users? **PASS** — UAF if crash work outlives rproc_add() failure teardown; work is known to run during attach (patch 2 stack).
3. Important issue? **PASS** — UAF/oops, HIGH; window on this tree is narrower than pre-async-attach but still the right fix for that error path.
4. Small and contained? **PASS** — +1 line, one function.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — rproc_add() / crash_handler / rproc_remove_dev all present.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not an ID/quirk/DT/build/doc exception). It is a normal small bugfix.
**Step 9.4: MAKE YOUR DECISION**
This belongs in this tree: a one-line, obviously correct cancel before teardown, preventing crash-handler UAF on the rproc_add() error path. Patch 1 reduced how often that path is taken for attach, but it did not make the cancel wrong or unnecessary, and it does not depend on the other series patches.
What it solves for users: if auto-boot registration fails after crash_handler was queued, the work can run against a deleted device and a soon-to-be-freed rproc. That is a host oops, not a DSP-only glitch.
Risk vs benefit: near-zero risk, real UAF class. Incomplete pm_relax is not a reason to drop the cancel.
### Verification
- [Phase 1] Tags: Link to v3-3 lore; SOBs Jingyi Wang, Bjorn Andersson; no Fixes/Reported-by/Cc stable.
- [Phase 1] Cover letter (mbox): attach-fail NULL deref **and** rproc_add() fail.
- [Phase 2] Diff: +1 cancel_work_sync(&rproc->crash_handler) at rproc_remove_dev in rproc_add().
- [Phase 2] Current rproc_add()/rproc_crash_handler_work()/rproc_re port_crash()/rproc_type_release() read in-tree.
- [Phase 3] git describe HEAD → v7.3-rc4-27-gf0100363d8c37; make kernelversion → 7.3.0-rc4.
- [Phase 3] Blame: teardown from 7dbdb8bd7c028 (v5.14-rc1); this cancel is 0ec167625b4fe.
- [Phase 3] git merge-base --is-ancestor 0ec167625b4fe, 026a3fada4326, 7dbdb8bd7c028, e3d2193959824 vs HEAD: all yes.
- [Phase 3] git describe --contains 0ec167625b4fe → v7.3-rc1~46^2~27.
- [Phase 3] git log -S cancel_work_sync(&rproc->crash_handler): only this commit and later 74ee3b2f57674 (rproc_del).
- [Phase 4] b4 dig -c/-a/-w/-m: v2+v3 series; patch 3 added in v2; Bjorn applied; no NAK on 3/3; Stephan Gerhold reviewed **patch 2** only.
- [Phase 4] lore WebFetch 403; stable list **UNVERIFIED**.
- [Phase 5] Callers: many rproc_add/devm_rproc_add probe sites; qcom_q6v5_init() requests wdog/fatal IRQs before rproc_add().
- [Phase 6] Buggy error path exists; apply would be clean; no other fix on this label.
- [Phase 8] Failure mode: workqueue UAF/oops, HIGH; trigger rarer here because of async attach.
The patch is small, correct, and closes a real lifetime hole on a path this tree still has.
**YES**
drivers/remoteproc/remoteproc_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/remoteproc/remoteproc_core.c +1 -0
@@ -2358,6 +2358,7 @@ int rproc_add(struct rproc *rproc)return 0 ; rproc_remove_dev: +cancel_work_sync (&rproc->crash_handler);rproc_delete_debug_dir (rproc);device_del (dev); rproc_remove_cdev:
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 nvmet: passthru: fix OOB reads when parsing ns id descriptor list
In reply to Sasha LevinFrom: Hari Mishal <[email protected]>
[ Upstream commit bc7f75eba50012ed447654d8ce169ebaba695193 ]
nvmet_passthru_override_id_descs() walks a namespace identification descriptor list populated from the underlying passthru controller's Identify response, which is device reported. The loop advanced pos by device controlled amounts (sizeof(*cur) + nidl) without checking that the next descriptor header actually fits inside the buffer, so a malicious device could push pos to within a few bytes of the buffer end and cause cur->nidl, cur->nidt or the reserved field to be read past the allocation.
Additionally, when a CSI descriptor lands exactly at the last valid header offset, cur + 1 points one byte past the end of the buffer. The unconditional memcpy(&csi, cur + 1, NVME_NIDT_CSI_LEN) could read that out-of-bounds byte and copy it back to the initiator via nvmet_copy_to_sgl(), leaking adjacent heap memory.
Bounds check both the descriptor header and the CSI value before dereferencing them.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). The buggy descriptor parser is present here; the fix is not. This is a small, obviously correct OOB-read/info-leak fix in NVMe target passthrough.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[nvmet/passthru] [fix] [OOB reads when parsing namespace ID descriptor list]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Hari Mishal \<[email protected]\> (author)
- Signed-off-by: Keith Busch \<[email protected]\> (NVMe maintainer, applied the patch)
- No Fixes:, Reported-by, Tested-by, Reviewed-by, Acked-by, Link:, or
Cc: stable tags (absence is expected for this review pipeline)
- Ignore any pipeline “Upstream commit” / Sasha Levin markers — none were on the upstream commit itself
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** nvmet_passthru_override_id_descs() walks a 4096-byte Identify NS descriptor list filled by the backend passthrough controller. The loop advances pos by sizeof(*cur) + nidl (nidl is device-controlled) without checking that the next descriptor header still fits in the buffer.
- **Symptom/failure:** OOB read of cur->nidl / cur->nidt / reserved past the allocation. If a CSI descriptor sits at the last valid header offset, memcpy(&csi, cur + 1, NVME_NIDT_CSI_LEN) reads one byte past the buffer and that byte can be copied to the initiator via nvmet_copy_to_sgl() — heap info leak.
- **Version info:** none in the message. Introducing code is from v5.19 (see Phase 3).
- **Root cause:** missing bounds checks on descriptor header and CSI payload before dereference.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. The subject and body describe a real OOB read / leak. The diff is only bounds checks.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/nvme/target/passthru.c — **+9 / -0** (upstream: 9 insertions)
- Function: nvmet_passthru_override_id_descs()
- Scope: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** loop for (pos = 0; pos < NVME_IDENTIFY_DATA_SIZE; pos += len) sets cur = data + pos, then immediately reads cur->nidl / cur->nidt. No check that pos + sizeof(*cur) is in range. CSI path does memcpy(&csi, cur + 1, NVME_NIDT_CSI_LEN) with no payload-size check.
- **After:**
1. If pos + sizeof(*cur) > NVME_IDENTIFY_DATA_SIZE, break (stop before OOB header read).
2. On CSI, if pos + sizeof(*cur) + NVME_NIDT_CSI_LEN > NVME_IDENTIFY_DATA_SIZE, break (stop before OOB CSI byte read).
- Path: Identify CNS=NS_DESC_LIST success path when clear_ids is set.
Fail-safe: truncated/malformed list → csi_seen stays false → buffer zeroed, CSI not echoed.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** memory safety — out-of-bounds read + heap info leak
- **Mechanism:** device-controlled nidl can place pos so a 4-byte struct nvme_ns_id_desc (nidt, nidl, __le16 reserved) does not fit. NVME_NIDT_CSI_LEN is 1; with header at offset 4092, cur + 1 is byte 4096 (one past a 4096-byte kzalloc). That byte can be returned to the initiator.
Verified sizes in this tree (include/linux/nvme.h):
- struct nvme_ns_id_desc = 4 bytes
- NVME_NIDT_CSI_LEN = 1
- NVME_IDENTIFY_DATA_SIZE = 4096
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: two breaks before dereference.
- Minimal: no unrelated changes.
- Regression risk: low. Breaking on a truncated list skips CSI override; clear_ids already zeros the rest of the list. Compliant devices put CSI well inside 4096 bytes.
- Host-side parser later also checks pos + sizeof(*cur) + cur->nidl; this passthru patch does not check non-CSI body size, but non-CSI payloads are not read here — only used to advance pos. Next iteration’s header check still stops OOB. Not a blocker.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Buggy function introduced by **34ad61514c4c3** (“nvmet: add a clear_ids attribute for passthru targets”, Alan Adamson, 2022-06-27).
- First appeared: **v5.19-rc2** (git describe:
v5.19-rc2-35-g34ad61514c4c3).
- **In this tree:** yes (git merge-base --is-ancestor 34ad61514c4c3 HEAD → yes). Blame on the local file still points every line of this function at that commit.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Bug introduced by 34ad61514c4c3, which is in this 6.12 tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Local recent history of passthru.c includes e38dad438fc08 (clear EUID/NGUID/UUID on loop) — does not change this loop.
- Upstream: bc7f75eba5001 is the latest change to this file on origin/master; **no follow-up** after it.
- Standalone, not “patch X/Y”. Sibling host fix 3c568b35a0d30 (“nvme:
bound ns descriptor header and body to identify buffer”) is a parallel pattern in drivers/nvme/host/core.c, **not a prerequisite** for this passthru patch.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record:
- Author is not the subsystem maintainer. Related upstream work: host NS descriptor bounds (3c568b35a0d30) and FDP clamp (29261f8bb4166).
- Applied by **Keith Busch** (NVMe maintainer). Weight is from maintainer application + Christoph Hellwig review, not author identity.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record:
- Uses existing NVME_IDENTIFY_DATA_SIZE, struct nvme_ns_id_desc, NVME_NIDT_CSI, NVME_NIDT_CSI_LEN — all in this tree.
- git apply --check of the upstream diff against this tree: **clean**.
- Can apply standalone. **No prerequisites.**
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c bc7f75eba5001 →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only** (single revision). Keith split the long line when applying (if (pos + sizeof(*cur) + NVME_NIDT_CSI_LEN > wrapped).
- b4 dig -m /tmp/nvmet-oob.mbox: full thread saved.
- Christoph Hellwig (20 Jul 2026): **“Overly long line here. Otherwise this looks sane.”** — no NAK.
- Keith Busch (10 Aug 2026): **“Thanks, applied to nvme-7.3 with fix to overly long line.”**
- No reviewer Cc: stable in the thread.
- WebFetch to lore.kernel.org returned **403**; discussion recovered via b4 dig -m.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc Hari Mishal, Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni, [email protected], linux- [email protected]. Hellwig reviewed; Busch applied. Appropriate NVMe maintainers.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by / syzbot / bugzilla. Found by code review (same author class as the host parser bounds fix). Bug is still real from reading the loop.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone v1. Related but independent: host 3c568b35a0d30 (not in this tree). Not required to land this passthru fix.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** — lore.kernel.org/stable via WebFetch returned
403. No stable discussion in the captured linux-nvme/lkml thread.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS IN THE DIFF**
Record: nvmet_passthru_override_id_descs() only.
**Step 5.2: TRACE CALLERS**
Record:
- Called from nvmet_passthru_execute_cmd_work() when Identify succeeds and cns == NVME_ID_CNS_NS_DESC_LIST.
- That work is used because nvmet_parse_passthru_admin_cmd() sets req->execute = nvmet_passthru_execute_cmd and req->p.use_workqueue = true for CNS CTRL/NS/NS_DESC_LIST.
- Reachable from an NVMe-oF initiator Identify command on a passthrough subsystem.
**Step 5.3: TRACE CALLEES**
Record: kzalloc(4096), nvmet_copy_from_sgl (backend Identify data), descriptor walk, memset + rebuild CSI, nvmet_copy_to_sgl (to initiator), kfree. No new locks/allocators in the patch.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record:
- Userspace/admin enables CONFIG_NVME_TARGET + CONFIG_NVME_TARGET_PASSTHRU, exports a backend NVMe controller.
- Function only runs if ctrl->subsys->clear_ids is set. Default **1 for loop** (core.c: “By default, set loop targets to clear IDS”); other transports via configfs clear_ids.
- Trigger: initiator Identify NS descriptor list. Backend-controlled bytes; initiator can receive leaked heap. Reachable from the fabrics initiator, not from an unprivileged syscall on the target without an NVMe-oF target setup.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same missing-bounds pattern in nvme_identify_ns_descs() (drivers/nvme/host/core.c) in this tree. Upstream fixed it separately (3c568b35a0d30). Confirms a systematic parser bug; this commit is the target/passthru instance.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** Local drivers/nvme/target/passthru.c lines 53–64 are the unbounded loop. git describe HEAD = p-6.12-3-gc504cf0baa3d8, make kernelversion = **6.12.111**. Upstream fix bc7f75eba5001 is **not** an ancestor of HEAD. Bug since v5.19.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** Surrounding function matches upstream pre-fix (aside from later mainline kmalloc_obj churn, which is after this fix and not in 6.12). git apply --check succeeded. Difficulty: clean apply.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No commit with this subject in this tree. Host-side sibling 3c568b35a0d30 also not in HEAD. No alternate fix for this passthru loop.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **NVMe target passthrough** (drivers/nvme/target/passthru.c). **IMPORTANT** for NVMe-oF target/passthru users (storage appliances, loop testing), not core mm/VFS. Not staging.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Active. This 6.12 tree already has many nvmet stable-style fixes (auth OOB, TCP PDU OOB, rdma leaks). Passthru file itself is relatively mature since 2022.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Config-specific / driver-specific:** CONFIG_NVME_TARGET=y/m and CONFIG_NVME_TARGET_PASSTHRU=y, and clear_ids enabled (default on loop; optional elsewhere). Not all 6.12 users, but real production NVMe- oF passthru and loop setups.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Identify NS descriptor list on a passthru namespace with clear_ids.
- Needs a backend that returns a truncated/malformed list (malicious or buggy NVMe device).
- Not a hot every-syscall path; realistic for passthru Identify.
- Unprivileged local user on the target: no, unless they are an initiator to that target. Remote initiator + malicious backend: yes, leak across the fabric.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- OOB read of header fields (KASAN / possible oops depending on slab).
- 1-byte heap leak to the initiator via Identify response.
- **Severity: HIGH** (memory safety + info leak). Not a universal panic, but security-class.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** high for passthru+clear_ids users — stops OOB read and initiator-visible leak. Same class as other nvmet bounds fixes already in this tree.
- **Risk:** very low — 9 lines, two bounds checks, fail-closed.
- **Ratio:** strongly favors backport.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real OOB read and heap leak, documented and confirmed in this tree’s code.
- Bug present since v5.19; fully present on 6.12.111.
- 9-line, obviously correct bounds checks; git apply --check clean.
- NVMe maintainer applied it; Christoph Hellwig: “looks sane.”
- No follow-up rework on origin/master.
- Fail-closed: malformed list just omits CSI, which matches clear_ids sanitizing.
**AGAINST:**
- Passthru is default n; needs clear_ids.
- No syzbot/CVE/Fixes/Cc: stable.
- Trigger is a malicious/buggy backend device, not a generic local syscall.
- Slightly weaker than the host parser (no nidl body check on skip).
**UNRESOLVED:**
- Stable list search (lore 403).
- No public reproducer beyond the described layout.
None of the against items outweigh a small, verified memory-safety fix whose buggy code is in this tree.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — Hellwig + Busch; logic verified against struct sizes.
2. Fixes a real bug that affects users? **PASS** — OOB read/leak on Identify for passthru+clear_ids.
3. Important issue? **PASS** — HIGH: OOB read + heap leak to initiator.
4. Small and contained? **PASS** — 9 lines, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — clean apply; code present; no missing deps.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. Qualifies as a normal security/memory-safety bug fix.
**Step 9.4: MAKE YOUR DECISION**
Backport to this 6.12 tree. The parser the commit fixes is here, the patch applies cleanly, and the failure is an OOB read that can leak heap to an NVMe-oF initiator.
---
## What the commit solves (for this tree)
nvmet_passthru_override_id_descs() copies a 4096-byte Identify NS descriptor list from the backend, walks it with device-controlled strides, and may reconstruct a CSI descriptor for the initiator when clear_ids is set. Without header/CSI bounds checks, a crafted list can read past the allocation and send that byte to the initiator. On 6.12 this is the original 2022 loop; two range checks close it.
## Stable rules / risk vs benefit
Meets stable rules: real, important, small, no new API, applies here. Benefit is stopping a leak/OOB on a path this tree already ships. Risk is two breaks on malformed input.
## Concerns
None that block backport. Host-side sibling 3c568b35a0d30 is a separate candidate, not a dependency. CONFIG_NVME_TARGET_PASSTHRU is optional; that narrows impact, not correctness.
---
## Verification
- [Phase 1] Parsed subject/body/tags from git show bc7f75eba5001;
tags: two SOBs only.
- [Phase 2] Diff: +9 in nvmet_passthru_override_id_descs(); compared to local lines 53–64.
- [Phase 2] Sizes: include/linux/nvme.h — desc 4 bytes, CSI len 1, Identify size 4096.
- [Phase 3] git blame -L 33,78 drivers/nvme/target/passthru.c → 34ad61514c4c3.
- [Phase 3] git describe 34ad61514c4c3 → v5.19-rc2-35; merge-base --is-ancestor 34ad61514c4c3 HEAD → yes.
- [Phase 3] merge-base --is-ancestor bc7f75eba5001 HEAD → no (not in this tree).
- [Phase 3] git log origin/master --oneline bc7f75eba5001..origin/master -- drivers/nvme/target/passthru.c → empty (no follow-up).
- [Phase 3] git show bc7f75eba5001 | git apply --check → clean.
- [Phase 4] b4 dig -c/-a/-w/-m: v1 only; lore URL; Hellwig “looks sane”; Busch applied to nvme-7.3.
- [Phase 4] WebFetch lore/patch.msgid.link: 403. Discussion from mbox, not WebFetch.
- [Phase 5] Callers: nvmet_passthru_execute_cmd_work ← Identify CNS_NS_DESC_LIST; parse path sets workqueue.
- [Phase 5] clear_ids default 1 for loop in drivers/nvme/target/core.c:1457-1459.
- [Phase 5] Host analog unbounded loop in this tree at nvme_identify_ns_descs(); upstream 3c568b35a0d30 not in HEAD.
- [Phase 6] git describe HEAD = p-6.12-3-gc504cf0baa3d8; make kernelversion = 6.12.111; branch pending-6.12.
- [Phase 6] Local function matches pre-fix; origin/master post-fix matches this commit.
- [Phase 8] Failure: OOB read + 1-byte heap leak to initiator; HIGH.
- UNVERIFIED: lore.kernel.org/stable discussion (HTTP 403). Not used to drive the verdict.
**YES**
drivers/nvme/target/passthru.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/nvme/target/passthru.c +9 -0
@@ -53,13 +53,22 @@ static u16 nvmet_passthru_override_id_descs(struct nvmet_req *req)for (pos =0 ; pos <NVME_IDENTIFY_DATA_SIZE ; pos += len) {struct nvme_ns_id_desc *cur = data + pos; +if (pos +sizeof (*cur) >NVME_IDENTIFY_DATA_SIZE ) +break ; +if (cur->nidl ==0 )break ; +if (cur->nidt ==NVME_NIDT_CSI ) { +if (pos +sizeof (*cur) +NVME_NIDT_CSI_LEN > +NVME_IDENTIFY_DATA_SIZE ) +break ; +memcpy (&csi, cur +1 ,NVME_NIDT_CSI_LEN ); csi_seen = true;break ; } + len =sizeof (struct nvme_ns_id_desc ) + cur->nidl; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 gre: fix ERSPAN o_flags race/corruption in xmit and fill_info
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 9958e69b98930834a576e156f6458166d1db1c02 ]
For IPv4 ERSPAN:
In erspan_xmit(), the driver clears IP_TUNNEL_SEQ_BIT (for version 0) and IP_TUNNEL_KEY_BIT directly in the shared tunnel->parms.o_flags structure. Since transmit paths can run locklessly and concurrently, this leads to a data race.
Furthermore, modifying tunnel->parms.o_flags permanently alters the tunnel configuration. To work around this, erspan_fill_info() (which reports config to userspace) was setting IP_TUNNEL_KEY_BIT back. If erspan_fill_info (running under RTNL) and erspan_xmit (running locklessly) race, erspan_xmit might see IP_TUNNEL_KEY_BIT set when it shouldn't, leading to GRE header corruption (injecting a key field into the ERSPAN GRE header).
Fix this by:
1) Passing flags as an argument to __gre_xmit().
2) Using local stack flags in ipgre_xmit(), gre_tap_xmit(), and erspan_xmit() to prevent TOCTOU data races with concurrent configuration updates, and passing them to __gre_xmit().
3) Removing the racy modification of t->parms.o_flags in erspan_fill_info().
4) Forcing IP_TUNNEL_KEY_BIT in the reported flags for ERSPAN locally in ipgre_fill_info().
For IPv6 ERSPAN:ip6erspan_tunnel_xmit() was locklessly clearing IP_TUNNEL_KEY_BIT in t->parms.o_flags even though it does not use these flags for building the GRE header (it uses local flags). This permanently corrupts the configuration and races with ip6gre_fill_info() which reads it.
Remove the redundant and racy modification.
This should remove false sharing in a fast path.
Add const qualifiers in ipgre_fill_info(), erspan_fill_info() and ip6gre_fill_info() to clarify that these methods are not supposed to write any live parameters.
---
LLM Generated explanations, may be completely bogus:
I have enough to decide: the buggy shared o_flags mutation is in this 6.12 tree, the APIs match, and the failure mode is GRE header corruption. Compiling the full analysis.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [gre] [fix] [ERSPAN o_flags race/corruption in xmit and fill_info]
Subsystem: GRE/ERSPAN tunnels (net/ipv4/ip_gre.c, net/ipv6/ip6_gre.c). Action verb is explicitly **fix**.
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record (from the candidate text and from the original mailing-list submission):
- Signed-off-by: Eric Dumazet <[email protected]> (author; networking core maintainer)
- Reviewed-by: Simon Horman <[email protected]>
- Link:
https://patch.msgid.link/[email protected]
- Signed-off-by: Jakub Kicinski <[email protected]> (netdev maintainer, applied to net-next)
- Ignore: pipeline "Signed-off-by: Sasha Levin" / "[Upstream commit ...]" if present
Original v4 submission (verified in /tmp/erspan_thread.mbox) also had:
- Fixes: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN")
- Fixes: ee496694b9ee ("ip_gre: do not report erspan version on GRE interface")
- Fixes: 5a963eb61b7c ("ip6_gre: Add ERSPAN native tunnel support")
v2 was sent to **net** with **Cc: [email protected]**. v4 dropped
Cc: stable and went to net-next after review. Absence of Cc: stable on the committed v4 is expected for this review pipeline and is not a negative signal.
No Reported-by / syzbot / Tested-by on this specific patch. Author found it while working on RTNL-less fill_info.
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: IPv4 erspan_xmit() locklessly clears IP_TUNNEL_SEQ_BIT (v0) and IP_TUNNEL_KEY_BIT in the **shared** tunnel->parms.o_flags. That permanently mutates tunnel config. erspan_fill_info() then writes IP_TUNNEL_KEY_BIT back so userspace dumps look correct.
- Symptom: TOCTOU data race between lockless xmit and RTNL fill_info. If xmit observes KEY_BIT set, gre_build_header() injects a GRE key field into the ERSPAN header (malformed GRE / header corruption).
- IPv6: ip6erspan_tunnel_xmit() also locklessly clears KEY_BIT on shared t->parms.o_flags even though it builds the GRE header from **local** flags. That is redundant, races with ip6gre_fill_info(), and causes false sharing on a fast path.
- Root cause: treating per-tunnel o_flags as scratch space from ndo_start_xmit.
- Versions: Fixes tags point at ERSPAN introduction (2017) and the fill_info KEY_BIT workaround (2022). All three are ancestors of this 6.12 tree.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not disguised. This is an explicit race + packet-corruption fix. Extra const on fill_info is documentation-only. Snapshotting flags in ipgre_xmit()/gre_tap_xmit() is extra TOCTOU hardening requested by Ido Schimmel, still a correctness fix, not a feature.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- net/ipv4/ip_gre.c: ~+23/-19 in __gre_xmit, ipgre_xmit, erspan_xmit, gre_tap_xmit, ipgre_fill_info, erspan_fill_info
- net/ipv6/ip6_gre.c: ~+2/-3 in ip6erspan_tunnel_xmit, ip6gre_fill_info
- Scope: single-purpose, two-file surgical fix. __gre_xmit is file- static; no public API.
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- __gre_xmit: no longer copies tunnel->parms.o_flags itself; callers pass a local flags snapshot.
- ipgre_xmit / gre_tap_xmit: copy o_flags once, use that copy for CSUM offload check and header build (closes TOCTOU vs concurrent changelink).
- erspan_xmit: copy flags, then __clear_bit KEY (and SEQ for v0) on the **stack copy**, pass that to __gre_xmit. Shared parms.o_flags is no longer written from xmit.
- erspan_fill_info: stop writing KEY_BIT into live t->parms.o_flags.
- ipgre_fill_info: if erspan_ver != 0 && !collect_md, set KEY_BIT on a **local** dump copy. Regular GRE/GRETAP keep erspan_ver == 0 (erspan_setup() is the only path that sets it to 1).
- ip6erspan_tunnel_xmit: delete the unused shared __clear_bit(IP_TUNNEL_KEY_BIT, t->parms.o_flags).
- fill_info functions: const on tunnel/parm pointers.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record: [Race + packet corruption + config corruption]
Mechanism: RMW of a shared bitmap from xmit (__clear_bit) vs fill_info (__set_bit). gre_build_header() then uses tun_hlen (8 for ERSPAN v1/v2) **and** the flags word. If KEY_BIT is set with SEQ, it writes key then seq into an 8-byte push, and the key write lands on the GRE flags/protocol word:
```102:144:include/net/gre.h
static inline void gre_build_header(struct sk_buff *skb, int hdr_len,
const unsigned long *flags, __be16
proto,
__be32 key, __be32 seq)
{
...
skb_push(skb, hdr_len);
...
if (ip_tunnel_flags_intersect(flags, cond)) {
__be32 *ptr = (__be32 *)(((u8 *)greh) + hdr_len - 4);
if (test_bit(IP_TUNNEL_SEQ_BIT, flags)) {
*ptr = seq;
ptr--;
}
if (test_bit(IP_TUNNEL_KEY_BIT, flags)) {
*ptr = key;
ptr--;
}
```With hdr_len == 8 and both SEQ and KEY, KEY overwrites the GRE base header. That is real on-wire corruption of mirrored traffic.
Step 2.4: ASSESS THE FIX QUALITY
Record: Obviously correct. Local snapshot + mutate the copy is the standard pattern (IPv6 xmit already used local flags). v4 dropped v2's gre_calc_hlen(flags) substitution after review showed it could emit a 4-byte GRE header when SEQ was absent from o_flags; v4 keeps tunnel->tun_hlen, which is the safer stable-friendly approach. Regression risk is low: no new locks, no API change, fill_info dump semantics preserved for ERSPAN KEY reporting.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record: Shared-flag mutation dates to ERSPAN introduction:
- f551c91de262ba (2017-12-13) / 84e54fe0a5ea (2017-08-22): IPv4 ERSPAN xmit
- 5a963eb61b7c / e41c7c68ea7716 (2017): IPv6 ERSPAN
- ee496694b9ee (2022-12-03): erspan_fill_info KEY_BIT restore workaround
- 5832c4a77d693 (2024-03-27): __be16 flags → bitmaps (__clear_bit/__set_bit); **in this tree**
Bug has been in the driver since 2017; bitmap conversion only changed the accessor.
Step 3.2: FOLLOW THE FIXES: TAG
Record: All three Fixes SHAs **are ancestors of HEAD**:
- 84e54fe0a5ea IS ancestor
- ee496694b9ee IS ancestor
- 5a963eb61b7c IS ancestor
Mainline commit 9958e69b9893 is **not** an ancestor of this checkout.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: Recent GRE work in this tree includes 9f948e9aede96 (restore GRE/GRETAP lltx) and capability checks. No prior fix of this o_flags xmit/fill_info race. Standalone commit (not patch X/Y). v1–v4 were revisions of the **same** patch.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Eric Dumazet is a net core maintainer with many GRE/tunnel commits here (erspan: make sure erspan_base_hdr is present, header robustness, etc.). High-confidence author.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: Needs IP_TUNNEL_DECLARE_FLAGS / ip_tunnel_flags_copy / ip_tunnel_parm_kern — all present (5832c4a77d693, 117aef12a7b1b). __gre_xmit is static to ip_gre.c. Can apply standalone.
Later mainline discussion (Sept 2026, net: erspan: set lltx to avoid sch_direct_xmit deadlock) names **this commit as a stable prerequisite** before enabling ERSPAN lltx. That later patch is not in this tree (erspan_tunnel_init still does not set dev->lltx). This fix is still valuable on its own because fill_info (RTNL) vs xmit (TX lock) already race.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig matched v4:
https://patch.msgid.link/[email protected]
- Revisions: v1 net-next (2026-06-15), v2 **net + Cc: stable** (2026-07-20), v3 net-next (2026-08-11), v4 net-next (2026-08-12, applied)
- v1 was sent to net-next because “7.1 was just released” (merge-window timing), not because it was considered a feature.
- v2 review (Sashiko): using gre_calc_hlen(flags) could emit a 4-byte GRE header when SEQ is missing from o_flags; tun_hlen previously forced 8 bytes. Eric marked CR (“What a mess”).
- v4 dropped that gre_calc_hlen change and kept tun_hlen.
- No NAK. Horman Reviewed-by. Jakub applied to netdev/net-next as 9958e69b9893.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: Recipients: davem, kuba, pabeni, horms, idosch, netdev. Ido asked v1 to snapshot flags in ipgre/gretap too (done in v4). Horman reviewed v4. Appropriate maintainers.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla for this race. Author discovered it while working on RTNL-less fill_info. Trigger is ordinary: ERSPAN TX plus ip -d link show / RTNL dump.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Single-patch series. Follow-up ERSPAN lltx deadlock fix depends on this for “no shared mutable o_flags in xmit.” Author agreed to list this as a stable prerequisite for that later patch.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: No lore.kernel.org/stable thread found that rejected this fix. v2 was explicitly Cc'd to stable. The later lltx discussion notes this commit was **not auto-queued** because v4 lacked Cc: stable — which is why it is in this evaluation pipeline.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: __gre_xmit, ipgre_xmit, erspan_xmit, gre_tap_xmit, ipgre_fill_info, erspan_fill_info, ip6erspan_tunnel_xmit, ip6gre_fill_info.
Step 5.2: TRACE CALLERS
Record:
- erspan_xmit / ipgre_xmit / gre_tap_xmit / ip6erspan_tunnel_xmit: ndo_start_xmit (hot path).
- ipgre_fill_info: GRE and GRETAP rtnl_link_ops.fill_info; also called from erspan_fill_info.
- erspan_fill_info / ip6gre_fill_info: netlink dump.
Step 5.3: TRACE CALLEES
Record: gre_build_header, gre_handle_offloads → iptunnel_handle_offloads, ip_tunnel_xmit / ip6_tnl_xmit, ip_tunnel_flags_copy, __clear_bit/__set_bit.
Step 5.4: FOLLOW THE CALL CHAIN
Record: Userspace-reachable: send on an ERSPAN/GRE/GRETAP netdev; dump via RTNL (ip link). Unprivileged users typically cannot create tunnels (needs CAP_NET_ADMIN), but once created, TX is a normal data path. Not theoretical.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: IPv6 native GRE already snapshots flags in __gre6_xmit. IPv6 fill_info already set KEY_BIT on a **local** copy. IPv4 ERSPAN was the inconsistent leftover that mutated live parms.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: **Yes.** Local tree is **6.12.111** (pending-6.12, p-6.12-3-gc504cf0baa3d8).
Verified present:
```746:747:net/ipv4/ip_gre.c
__clear_bit(IP_TUNNEL_KEY_BIT, tunnel->parms.o_flags);
__gre_xmit(skb, dev, &tunnel->parms.iph, proto);
```
```1603:1604:net/ipv4/ip_gre.c
if (t->erspan_ver != 0 && !t->collect_md)
__set_bit(IP_TUNNEL_KEY_BIT, t->parms.o_flags);
```
```999:999:net/ipv6/ip6_gre.c
__clear_bit(IP_TUNNEL_KEY_BIT, t->parms.o_flags);
```Bug introduced 2017; fill_info KEY restore 2022. Both long before 6.12.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Expected apply: **minor context fuzz**, not a rewrite. This tree’s gre_rcv drop path lacks dev_core_stats_rx_dropped_inc() that appears as context in the mainline hunk; __gre_xmit itself matches. All other hunks match current 6.12 code (IP_TUNNEL_DECLARE_FLAGS, ip_tunnel_parm_kern, function layout). No conflicting refactor.
Note: IPv4/IPv6 ERSPAN **do not** set dev->lltx here (erspan_tunnel_init / ip6erspan_tap_init). Concurrent xmit on one ERSPAN device is still serialized by _xmit_lock. The **fill_info (RTNL) vs xmit (TX lock)** race remains, and any future ERSPAN lltx backport would make concurrent xmit racy without this patch.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: git log --grep="fix ERSPAN o_flags race" on these files:
empty. No equivalent fix in this tree.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [net/ipv4 GRE + net/ipv6 GRE ERSPAN] [IMPORTANT] Not core mm/VFS, but a widely used tunnel type (SPAN/ERSPAN mirroring, cloud TAP, Kubernetes). Packet corruption on the mirror path is user- visible.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mature GRE/ERSPAN (since 4.x). Still receiving correctness fixes (lltx, headroom, capability checks). This is a long-standing bug, not churn from new code.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver/config-specific: IPv4 ERSPAN (primary), IPv6 ERSPAN (shared o_flags clear), plus GRE/GRETAP get a small TOCTOU snapshot. Anyone running ERSPAN mirrors plus netlink dumps.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Trigger: ERSPAN transmit concurrent with RTNL dump (ip -d link show, monitoring agents). Common in production TAP setups. Creating the tunnel needs CAP_NET_ADMIN; TX after that is the normal data path. Timing-dependent, but the window is every dump-vs-packet overlap, not a one-in-a-billion theoretical race.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: [GRE header corruption / wrong optional fields / overwrite of GRE flags+protocol when KEY is injected into an 8-byte header] [HIGH]
Also: permanent clear of KEY_BIT in live config until fill_info writes it back; data race on a bitmap word (KCSAN-class). Not a panic by itself, but corrupted mirrored packets and broken GRE layout. Stable rules treat this class of correctness bugs as important.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: HIGH for ERSPAN users (stops header corruption and config clobber; unblocks a correct lltx backport later).
- Risk: LOW (~25 net lines, local stack flags, no locking change, no uAPI change, reviewed by Horman/Ido, written by Dumazet).
- Ratio: strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real race: xmit mutates shared o_flags; fill_info writes KEY_BIT back under a different lock (RTNL vs TX lock).
- Concrete failure: KEY_BIT observed in gre_build_header() with tun_hlen==8 overwrites the GRE base header.
- Buggy code is in this 6.12 tree; Fixes commits are ancestors.
- Small, obviously correct, no new APIs.
- Author is a net maintainer; Horman Reviewed-by; Ido requested the GRE/GRETAP snapshot.
- v2 was Cc: stable; later ERSPAN lltx work calls this a stable prerequisite.
- v4 kept tun_hlen after review found v2’s gre_calc_hlen unsafe.
AGAINST:
- v4 landed in net-next without Cc: stable (timing/review, not a NAK).
- IPv4 ERSPAN is not yet lltx here, so concurrent xmit is serialized; the remaining race is dump vs TX (still real).
- First hunk may need trivial context adjustment around gre_rcv.
- Extra snapshots in ipgre_xmit/gre_tap_xmit are slightly broader than the ERSPAN-only bug, but they are the same pattern and low risk.
UNRESOLVED: none that affect the verdict. Could not fetch lore.kernel.org HTML (403); used b4 mbox + openwall mirrors instead.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — local snapshot, reviewed, applied upstream.
2. Fixes a real bug that affects users? **PASS** — ERSPAN GRE header/config corruption.
3. Important issue? **PASS** — HIGH: on-wire header corruption (not a panic, but not cosmetic).
4. Small and contained? **PASS** — ~25 lines, two files, static helper signature only.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — buggy code and bitmap APIs present; minor gre_rcv context at most.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary networking correctness fix.
Step 9.4: MAKE YOUR DECISION
This belongs in **this** 6.12 tree. The bug is here, the fix is small and correct, and it prevents GRE header corruption on ERSPAN plus shared-state races that a later lltx change would make worse.
What the commit solves for stable users: ERSPAN xmit must not clear KEY/SEQ in the live tunnel parms. Doing so races with netlink fill_info and can inject a GRE key into an 8-byte ERSPAN GRE header, corrupting mirrored packets. Snapshot flags on the stack and report KEY only on the dump copy.
Risk vs benefit: low risk, high benefit for ERSPAN. Apply with at most a small context tweak on the __gre_xmit hunk.
Verification:
- [Phase 1] Parsed subject/tags; original v4 mbox has Fixes:
84e54fe0a5ea, ee496694b9ee, 5a963eb61b7c; v2 had Cc: stable
- [Phase 2] Diff: local flags to __gre_xmit; stop mutating parms.o_flags in erspan_xmit/fill_info and ip6erspan xmit
- [Phase 2] gre_build_header() with hdr_len=8 + KEY+SEQ overwrites GRE base header — verified in include/net/gre.h
- [Phase 3] blame: mutation since 2017 ERSPAN; bitmap conversion 5832c4a77d693 in this tree
- [Phase 3] git merge-base --is-ancestor all three Fixes SHAs: yes; 9958e69b9893: no
- [Phase 4] b4 dig -c 9958e69b9893: lore msgid 20260812142257.21283-1; v2/v3/v4; Horman Reviewed-by; no NAK
- [Phase 4] Ido asked for ipgre/gretap snapshots; Sashiko caught v2 gre_calc_hlen malformation; v4 dropped that
- [Phase 4] Later lltx deadlock thread names this commit as stable prerequisite
- [Phase 5] Callers are ndo_start_xmit and RTNL fill_info
- [Phase 6] git describe HEAD: p-6.12-3-gc504cf0baa3d8; make kernelversion: 6.12.111; buggy __clear_bit/__set_bit present
- [Phase 6] ERSPAN init does not set lltx in this tree; fill_info vs xmit still races
- [Phase 8] Failure mode: GRE header corruption, severity HIGH
- UNVERIFIED: lore.kernel.org HTML 403 (used b4 + openwall); no stable- list rejection found
**YES**
net/ipv4/ip_gre.c | 42 +++++++++++++++++++++++------------------- net/ipv6/ip6_gre.c | 5 ++--- 2 files changed, 25 insertions(+), 22 deletions(-)
net/ipv4/ip_gre.c +23 -19
@@ -474,12 +474,9 @@ static int gre_rcv(struct sk_buff *skb)static void __gre_xmit (struct sk_buff *skb,struct net_device *dev,const struct iphdr *tnl_params, -__be16 proto) +__be16 proto,const unsigned long *flags) {struct ip_tunnel *tunnel =netdev_priv (dev); -IP_TUNNEL_DECLARE_FLAGS (flags); - -ip_tunnel_flags_copy (flags, tunnel->parms.o_flags);/* Push GRE header. */ gre_build_header(skb, tunnel->tun_hlen,
@@ -652,6 +649,7 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb, struct net_device *dev) {struct ip_tunnel *tunnel =netdev_priv (dev); +IP_TUNNEL_DECLARE_FLAGS (flags);const struct iphdr *tnl_params;if (!pskb_inet_may_pull (skb))
@@ -687,11 +685,12 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb, tnl_params = &tunnel->parms.iph; } -if (gre_handle_offloads (skb,test_bit (IP_TUNNEL_CSUM_BIT , - tunnel->parms.o_flags))) +ip_tunnel_flags_copy (flags, tunnel->parms.o_flags); + +if (gre_handle_offloads (skb,test_bit (IP_TUNNEL_CSUM_BIT , flags))) goto free_skb; -__gre_xmit (skb, dev, tnl_params, skb->protocol); +__gre_xmit (skb, dev, tnl_params, skb->protocol, flags);return NETDEV_TX_OK ; free_skb:
@@ -704,6 +703,7 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb, struct net_device *dev) {struct ip_tunnel *tunnel =netdev_priv (dev); +IP_TUNNEL_DECLARE_FLAGS (flags);bool truncate = false;__be16 proto;
@@ -727,10 +727,12 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb, truncate = true; } +ip_tunnel_flags_copy (flags, tunnel->parms.o_flags); +/* Push ERSPAN header */ if (tunnel->erspan_ver ==0 ) { proto =htons (ETH_P_ERSPAN ); -__clear_bit (IP_TUNNEL_SEQ_BIT , tunnel->parms.o_flags); +__clear_bit (IP_TUNNEL_SEQ_BIT , flags); }else if (tunnel->erspan_ver ==1 ) { erspan_build_header(skb, ntohl(tunnel->parms.o_key), tunnel->index,
@@ -745,8 +747,8 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb, goto free_skb; } -__clear_bit (IP_TUNNEL_KEY_BIT , tunnel->parms.o_flags); -__gre_xmit (skb, dev, &tunnel->parms.iph, proto); +__clear_bit (IP_TUNNEL_KEY_BIT , flags); +__gre_xmit (skb, dev, &tunnel->parms.iph, proto, flags);return NETDEV_TX_OK ; free_skb:
@@ -759,6 +761,7 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb, struct net_device *dev) {struct ip_tunnel *tunnel =netdev_priv (dev); +IP_TUNNEL_DECLARE_FLAGS (flags);if (!pskb_inet_may_pull (skb)) goto free_skb;
@@ -768,14 +771,15 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,return NETDEV_TX_OK ; } -if (gre_handle_offloads (skb,test_bit (IP_TUNNEL_CSUM_BIT , - tunnel->parms.o_flags))) +ip_tunnel_flags_copy (flags, tunnel->parms.o_flags); + +if (gre_handle_offloads (skb,test_bit (IP_TUNNEL_CSUM_BIT , flags))) goto free_skb;if (skb_cow_head (skb, dev->needed_headroom)) goto free_skb; -__gre_xmit (skb, dev, &tunnel->parms.iph,htons (ETH_P_TEB )); +__gre_xmit (skb, dev, &tunnel->parms.iph,htons (ETH_P_TEB ), flags);return NETDEV_TX_OK ; free_skb:
@@ -1571,12 +1575,15 @@ static size_t ipgre_get_size(const struct net_device *dev)static int ipgre_fill_info (struct sk_buff *skb,const struct net_device *dev) { -struct ip_tunnel *t =netdev_priv (dev); -struct ip_tunnel_parm_kern *p = &t->parms; +const struct ip_tunnel *t =netdev_priv (dev); +const struct ip_tunnel_parm_kern *p = &t->parms;IP_TUNNEL_DECLARE_FLAGS (o_flags);ip_tunnel_flags_copy (o_flags, p->o_flags); +if (t->erspan_ver !=0 && !t->collect_md) +__set_bit (IP_TUNNEL_KEY_BIT , o_flags); + if (nla_put_u32(skb, IFLA_GRE_LINK, p->link) || nla_put_be16(skb, IFLA_GRE_IFLAGS, gre_tnl_flags_to_gre_flags(p->i_flags)) ||
@@ -1619,12 +1626,9 @@ static int ipgre_fill_info(struct sk_buff *skb, const struct net_device *dev)static int erspan_fill_info (struct sk_buff *skb,const struct net_device *dev) { -struct ip_tunnel *t =netdev_priv (dev); +const struct ip_tunnel *t =netdev_priv (dev);if (t->erspan_ver <=2 ) { -if (t->erspan_ver !=0 && !t->collect_md) -__set_bit (IP_TUNNEL_KEY_BIT , t->parms.o_flags); -if (nla_put_u8 (skb,IFLA_GRE_ERSPAN_VER , t->erspan_ver)) goto nla_put_failure;
net/ipv6/ip6_gre.c +2 -3
@@ -967,7 +967,6 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,if (skb_cow_head (skb, dev->needed_headroom ?: t->hlen)) goto tx_err; -__clear_bit (IP_TUNNEL_KEY_BIT , t->parms.o_flags);IPCB (skb)->flags =0 ;/* For collect_md mode, derive fl6 from the tunnel key,
@@ -2116,8 +2115,8 @@ static size_t ip6gre_get_size(const struct net_device *dev)static int ip6gre_fill_info (struct sk_buff *skb,const struct net_device *dev) { -struct ip6_tnl *t =netdev_priv (dev); -struct __ip6_tnl_parm *p = &t->parms; +const struct ip6_tnl *t =netdev_priv (dev); +const struct __ip6_tnl_parm *p = &t->parms;IP_TUNNEL_DECLARE_FLAGS (o_flags);ip_tunnel_flags_copy (o_flags, p->o_flags);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 scsi: ibmvfc: free ibmvfc_target allocations with mempool_free
In reply to Sasha LevinFrom: Tyrel Datwyler <[email protected]>
[ Upstream commit 99143433f7f14139ac373c553ec8e1317d0ae58a ]
The ibmvfc_target *tgt structures for discovery are allocated using mempool_alloc but in turn free'd via kfree in ibmvfc_release_target breaking pool guarentees.
Fixup ibmvfc_release_target to call mempool_free instead so that memory is properly returned to the mempool instead of the general allocator.
---
LLM Generated explanations, may be completely bogus:
I have enough to decide: this is a one-line mempool/kfree mismatch in ibmvfc that can drain the target pool and hang discovery. The local 7.3-rc4 tree has the driver and the bug’s code path.
## Phase 1: Commit message forensics
**Step 1.1: Subject**
Record: [scsi/ibmvfc] [free] free ibmvfc_target allocations with mempool_free — claimed intent: stop freeing mempool-allocated target structs with kfree.
**Step 1.2: Tags**
Record:
- Signed-off-by: Tyrel Datwyler <[email protected]> (author; IBM ibmvfc maintainer)
- `Link:
https://patch.msgid.link/[email protected]`
- Signed-off-by: Martin K. Petersen <[email protected]> (SCSI maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, or Cc: stable (absence of the last two is expected for this review)
**Step 1.3: Body**
Record:
- Bug: ibmvfc_target objects are allocated with mempool_alloc() but released with kfree() in ibmvfc_release_tgt (message says ibmvfc_release_target; the function is ibmvfc_release_tgt).
- Symptom: “breaking pool guarantees” — reserved mempool elements never return to the pool.
- Root cause: allocator/free mismatch (mempool_alloc vs kfree).
- No stack trace, reproducer, or version range. Failure mode is implied (pool accounting), not a reported oops.
**Step 1.4: Hidden bug fix?**
Record: Not hidden. It is an explicit allocator-mismatch fix. The cover letter for the series later names it as one of four pre-existing bugs, not NVMe feature work.
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- File at commit time: drivers/scsi/ibmvscsi/ibmvfc.c (1 insertion, 1 deletion)
- Function: ibmvfc_release_tgt
- Scope: single-file, one-line surgical fix
**Step 2.2: Code flow**
Record:
- Before: last kref_put on a target calls kfree(tgt).
- After: same path calls mempool_free(tgt, tgt->vhost->tgt_pool).
- Path: target teardown / kref drain (discovery logout, rport delete, sysfs starget accessors, host teardown), not an error-only path.
**Step 2.3: Bug mechanism**
Record: [resource / mempool accounting] plus a possible [hang]
- Alloc: tgt = mempool_alloc(vhost->tgt_pool, GFP_NOIO) in ibmvfc_alloc_target.
- Pool: mempool_create_kmalloc_pool(IBMVFC_TGT_MEMPOOL_SZ, sizeof(struct ibmvfc_target)) with IBMVFC_TGT_MEMPOOL_SZ == 64.
- kfree of a reserved pool object returns that slab object to the page allocator without incrementing pool->curr_nr. After 64 alloc/free cycles the reserved pool is empty.
- mempool_alloc() with GFP_NOIO (__GFP_RECLAIM / __GFP_DIRECT_RECLAIM) first tries kmalloc; on failure it waits uninterruptibly on pool->wait until mempool_free refills. If nothing ever calls mempool_free, that wait never ends.
- Commit 5c66d9393f583 (2017) removed the NULL check on this mempool_alloc because “mempool_alloc() cannot fail when passed GFP_NOIO”. That is only true if the pool is actually returned to.
**Step 2.4: Fix quality**
Record: Obviously correct matching free. Minimal. tgt->vhost is set before kref_init, so the pool pointer is valid on the free path. Regression risk is low. Theoretical extra requirement vs kfree: the pool must still exist; ibmvfc_remove does fc_remove_host / scsi_remove_host and target kref_puts before ibmvfc_free_mem() → mempool_destroy(). No later revert of this change.
## Phase 3: Git history
**Step 3.1: Blame**
Record: kfree(tgt) in ibmvfc_release_tgt comes from b3c10489cb464b / original driver 072b91f9c6510 (“[SCSI] ibmvfc: IBM Power Virtual Fibre Channel Adapter Client Driver”, 2008-07-12, contained in v2.6.27-rc1). The mismatch is as old as the driver. tgt_pool was created in that same commit.
**Step 3.2: Fixes tag**
Record: None. Introducer is the original 2008 driver, present in this tree’s history.
**Step 3.3: File history**
Record: This commit is 99143433f7f14. Neighbors from the same submission:
- 9c2aa65000f6f 01/33 MAD send-failure deadlock
- 7e35396ec8539 02/33 rport_add_work_q teardown
- 0122eab60b151 03/33 NULL evt deref
- **this** 04/33 mempool_free
- de7ac0f3f08b1 05/33 move target list (NVMe prep, not required for this line)
Standalone relative to 05/33+. Later 848c70852e3fb split ibmvfc.c into ibmvfc-core.c; current tree has the fixed mempool_free in ibmvfc-core.c.
**Step 3.4: Author**
Record: Tyrel Datwyler is the IBM ibmvfc maintainer (majority of recent drivers/scsi/ibmvscsi/ commits). SCSI maintainer Martin K. Petersen applied the series.
**Step 3.5: Dependencies**
Record: None for the one-line change. It does not need NVMe/FC patches. mempool_free / tgt_pool / ibmvfc_release_tgt all exist in this tree.
## Phase 4: Mailing list
**Step 4.1: b4 dig**
Record:
- Lore:
https://patch.msgid.link/[email protected]
- Subject on list: [PATCH v2 04/33] ibmvfc: free ibmvfc_target allocations with mempool_free
- Series: [PATCH v2 00/33] ibmvfc: NVMe/FC support over IBM Virtual FC (2026-07-22)
- Cover letter (from saved mbox): “Patches 1-5: Bug fixes and preparatory refactoring. Four pre-existing bugs are fixed before any NVMe/FC work is introduced: … an allocator mismatch where mempool- allocated ibmvfc_target structs are freed via kfree rather than mempool_free.”
- Martin K. Petersen: “Applied to 7.3/scsi-staging, thanks!”
- No NAK on this patch. No reviewer asked for Cc: stable on this specific patch.
**Step 4.2: Recipients (b4 dig -w)**
Record: [email protected], [email protected], [email protected], linuxppc- [email protected], [email protected], [email protected]. Right SCSI/PPC/IBM lists.
**Step 4.3: Bug report**
Record: No Reported-by / Bugzilla / syzbot. Bug was found by the maintainer while preparing NVMe/FC.
**Step 4.4: Series**
Record: 33-patch NVMe/FC feature series. This patch is explicitly a pre- existing bugfix (phase 1, patches 1–4). Self-contained.
**Step 4.5: Stable list**
Record: UNVERIFIED. lore.kernel.org search hit Anubis bot-protection (403). No stable discussion in the saved scsi thread mbox.
## Phase 5: Semantic / call graph
**Step 5.1: Functions**
Record: ibmvfc_release_tgt only.
**Step 5.2: Callers**
Record: Many kref_put(&tgt->kref, ibmvfc_release_tgt) sites in ibmvfc-core.c and ibmvfc-nvme.c: starget node/port name/id sysfs, implicit logout / delete, PLOGI/PRLI, rport add/delete, host work thread, module remove. Reachable from FC discovery, link events, and sysfs.
**Step 5.3: Callees**
Record: container_of, then mempool_free. No new locks or allocations.
**Step 5.4: Reachability**
Record: Yes, from normal IBM Power virtual FC use (target discovery/logout and host removal). Not an obscure debug path. CONFIG_SCSI_IBMVFC depends on PPC_PSERIES.
**Step 5.5: Similar patterns**
Record: Only this kfree/mempool mismatch for targets. Event pools in the same driver already used mempool correctly. No follow-up fix after 99143433f7f14.
semcode MCP: not available in this session; used git grep / file reads.
## Phase 6: This tree
**Step 6.1: Local tree and buggy code**
Record:
- git describe HEAD: v7.3-rc4-27-gf0100363d8c37
- make kernelversion: 7.3.0-rc4
- git merge-base --is-ancestor 99143433f7f14 HEAD: yes — the fix is already in this checkout
- Current code (ibmvfc-core.c:1431-1434) already has mempool_free(tgt, tgt->vhost->tgt_pool)
- The mismatch existed here from v2.6.27 until this commit; the driver and tgt_pool still exist
**Step 6.2: Backport difficulty**
Record: Clean one-liner against pre-split ibmvfc.c. This 7.3-rc4 tree already contains it; later split to ibmvfc-core.c does not change the correctness of the fix.
**Step 6.3: Related fixes already here**
Record: The fix itself is here. 5c66d9393f583 (NULL-check removal) is also here, which makes restoring pool refill more important.
## Phase 7: Subsystem
**Step 7.1**
Record: SCSI LLD drivers/scsi/ibmvscsi/ — IBM Power Virtual FC.
Criticality: IMPORTANT for PPC_PSERIES storage (enterprise PowerVM), PERIPHERAL for everyone else.
**Step 7.2**
Record: Actively developed in 7.3 (large NVMe/FC series). The bug itself is old, not a new-subsystem issue.
## Phase 8: Impact and risk
**Step 8.1: Who is affected**
Record: Users of CONFIG_SCSI_IBMVFC on IBM POWER (pSeries) with Virtual Fibre Channel. Not universal.
**Step 8.2: Trigger**
Record: Target alloc/free churn (discovery, logout, rport delete, host reset). After 64 such cycles the reserved pool is empty. Hang requires subsequent mempool_alloc(GFP_NOIO) while kmalloc fails (memory pressure, no __GFP_FS reclaim). Unprivileged users do not call this directly; fabric events and scans do.
**Step 8.3: Failure mode**
Record: Permanent mempool drain; under memory pressure, uninterruptible hang in mempool_alloc during discovery (storage bring-up / recovery stuck). Severity: HIGH for that platform (hang / lost discovery), not a KASAN UAF from kfree of kmalloc-backed pool memory.
**Step 8.4: Risk-benefit**
Record: Benefit HIGH for ibmvfc users (restore mempool guarantees; avoid discovery hang). Risk VERY LOW (1 line, matching alloc/free, maintainer- authored, SCSI maintainer applied). Ratio favors including the fix.
## Phase 9: Synthesis
**Step 9.1: Evidence**
For:
- Real allocator mismatch present since 2008
- One-line, obviously correct mempool_free
- Can empty the 64-element pool and then hang mempool_alloc(GFP_NOIO) under memory pressure
- 2017 change already assumes mempool never fails on this path
- Cover letter labels it a pre-existing bug, independent of NVMe/FC
- IBM/SCSI maintainers; applied to 7.3 scsi-staging
- Driver and bug exist in this 7.3-rc4 tree
Against:
- No user/syzbot report in 18 years (may be rare or attributed to memory pressure)
- Sent as 04/33 of a feature series (the line itself does not depend on the rest)
- Platform-specific (PowerVM virtual FC only)
- No Fixes: / Cc: stable (not a negative per the review rules)
Unresolved:
- Stable-list discussion (lore search blocked)
**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** — matching free; applied by SCSI maintainer.
2. Real bug that affects users? **PASS** — pool contract broken on every target free; hang is a realistic stress case.
3. Important (crash/security/corruption/deadlock)? **PASS** — uninterruptible wait in discovery if the drained pool cannot be refilled; storage recovery hang.
4. Small and contained? **PASS** — 1 line, one function.
5. No new features/APIs? **PASS** — not the NVMe work; just the free path.
6. Can apply to this tree? **PASS** — code exists; commit is already an ancestor of HEAD; equivalent mempool_free is in ibmvfc-core.c.
**Step 9.3: Exception category**
Record: None needed (not a device ID/quirk/DT/build/doc exception). It is a normal bugfix.
**Step 9.4: Decision**
This should be backported to this tree. It is a one-line correction of a long-standing mempool leak/drain in IBM virtual FC target discovery, with hang potential under memory pressure, and no meaningful regression risk.
---
**What it solves for this tree:** ibmvfc_target objects come from vhost->tgt_pool but were kfreed, so reserved pool slots were permanently lost. After enough discovery/logout churn, mempool_alloc(GFP_NOIO) no longer has a reserved pool and can block forever if kmalloc fails. This 7.3-rc4 tree still has that driver; the one-line mempool_free restores the guarantee.
**Stable rules:** Small, obviously correct, no new API, real hang/discovery-failure bug, applies here.
**Risk vs benefit:** Very low risk, high benefit for PowerVM FC users.
**Concerns:** No field crash report; bug is old. That does not make the mismatch or the hang path hypothetical. No extra commits are required.
Verification:
- [Phase 1] Parsed tags: author Tyrel Datwyler, Link msgid ...969416-5, SOB Martin K. Petersen; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: 1 line in ibmvfc_release_tgt, kfree(tgt) → mempool_free(tgt, tgt->vhost->tgt_pool)
- [Phase 2] Confirmed alloc at ibmvfc_alloc_target:
mempool_alloc(vhost->tgt_pool, GFP_NOIO); pool size 64; GFP_NOIO is __GFP_RECLAIM
- [Phase 2] mm/mempool.c: mempool_alloc_noprof retries and waits on pool->wait when __GFP_DIRECT_RECLAIM is set; waiters woken from mempool_free
- [Phase 3] git blame: kfree(tgt) from original driver 072b91f9c6510 (2008, v2.6.27-rc1)
- [Phase 3] git merge-base --is-ancestor 99143433f7f14 HEAD: yes
- [Phase 3] Related: 5c66d9393f583 (v4.12-rc1) removed mempool_alloc NULL check
- [Phase 4] b4 dig -c 99143433f7f14: [PATCH v2 04/33]; cover letter lists this as a pre-existing bug; Martin: applied to 7.3/scsi-staging
- [Phase 4] b4 dig -w: linux-scsi, linuxppc-dev, Bottomley, Petersen, IBM
- [Phase 4] b4 dig -a: v2 of 33-patch NVMe/FC series; this patch is in the bugfix prefix
- [Phase 4] UNVERIFIED: lore.kernel.org/stable search (Anubis 403)
- [Phase 5] Callers: many kref_put(..., ibmvfc_release_tgt) in discovery/teardown/sysfs
- [Phase 6] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; kernelversion 7.3.0-rc4; current ibmvfc-core.c already uses mempool_free
- [Phase 7] CONFIG_SCSI_IBMVFC depends on PPC_PSERIES
- [Phase 8] Failure mode: mempool drain → possible D-state hang in target discovery under memory pressure; severity HIGH for that platform
- UNVERIFIED: whether a target kref can outlive mempool_destroy on remove (no evidence it does; remove deletes rports first)
**YES**
drivers/scsi/ibmvscsi/ibmvfc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ibmvscsi/ibmvfc.c +1 -1
@@ -1366,7 +1366,7 @@ static void ibmvfc_set_rport_dev_loss_tmo(struct fc_rport *rport, u32 timeout)static void ibmvfc_release_tgt (struct kref *kref) { struct ibmvfc_target *tgt = container_of(kref, struct ibmvfc_target, kref); -kfree (tgt); +mempool_free (tgt, tgt->vhost->tgt_pool); }/**
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 RDMA/rxe: Check PDs for memory window binds
In reply to Sasha LevinFrom: Zhiwei Zhang <[email protected]>
[ Upstream commit fbbe1d5cd7d400a98afcf337969cfdb808cb198f ]
The IBTA Software Transport Verbs specification requires the QP, Memory Window and Memory Region for a Bind Memory Window operation to belong to the same HCA and protection domain.
rxe only checked the QP and MW protection domain for type 2 MWs. Move the QP/MW PD check to the common bind path and also reject binding an MW to an MR from a different PD.
Invalid bind requests continue to fail with IB_WC_MW_BIND_ERR.
---
LLM Generated explanations, may be completely bogus:
The local tree is **7.3.0-rc4**. This is a small, spec-required PD isolation check in Soft-RoCE bind, and the buggy path exists in this tree.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[RDMA/rxe] [Check] Check PDs for memory window binds.** Completes IBTA C10-72 by validating that QP, MW, and MR share a protection domain on bind.
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- **Reviewed-by:** Zhu Yanjun <[email protected]>
- **Signed-off-by:** Zhiwei Zhang <[email protected]> (author)
- **Link:** https://patch.msgid.link/tencent_FD4FB25AA4FFA845E63F5AC36C [email protected]
- **Signed-off-by:** Leon Romanovsky <[email protected]> (RDMA maintainer)
- No **Fixes:**, **Reported-by:**, **Tested-by:**, **Acked-by:**, **Cc:
stable**, or syzbot tags (absence of Fixes/Cc-stable is expected for this review)
- Pipeline SOBs ignored per instructions
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** IBTA Software Transport Verbs require QP, MW, and MR of a Bind Memory Window to be on the same HCA and PD. rxe only compared QP vs MW PD, and only for type 2 MWs. It never compared QP/MW vs MR PD.
- **Symptom:** An invalid bind is accepted instead of completing with IB_WC_MW_BIND_ERR. After bind, the MW can point at an MR from another PD.
- **Version info in message:** none
- **Root cause (author):** type-2-only C10-72 check; missing MR PD check
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not disguised. It is an explicit spec/isolation check. The extra rxe_mw_pd() helper use is equivalent to to_rpd(mw->ibmw.pd) and is not a hidden refactor.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/infiniband/sw/rxe/rxe_mw.c — **+12 / -8** (net +4)
- Function: rxe_check_bind_mw()
- Scope: **single-file surgical fix**
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- **Hunk 1 (type 2 block):** Before, C10-72 qp->pd != to_rpd(mw->ibmw.pd) ran only for IB_MW_TYPE_2. After, that check is removed from the type-2-only block.
- **Hunk 2 (common path):** After type-1/type-2 state checks, **all** binds check qp->pd != rxe_mw_pd(mw) and fail with -EINVAL.
- **Hunk 3 (when MR present):** Before, a non-NULL MR skipped any PD comparison. After, qp->pd != mr_pd(mr) rejects a cross-PD MR. Zero- length/NULL-MR unbind still returns 0 after the QP/MW PD check.
- Path affected: BIND_MW work-request validation (rxe_bind_mw → rxe_check_bind_mw). Failures still become IB_WC_MW_BIND_ERR in rxe_do_local_ops().
Step 2.3: IDENTIFY THE BUG MECHANISM
Record: **Logic / correctness + isolation (memory safety via missing PD check).**
- Broken: rxe_bind_mw() looks up MW/MR by key in **device-global** pools (rxe_pool_get_index), then rxe_do_bind_mw() attaches mw->mr = mr. Remote access in rxe_resp.c uses mw->mr after rxe_lookup_mw(), which checks MW PD vs QP PD but **not** the bound MR’s PD. lookup_mr() does check mr_pd(mr) != pd, so the bind path was the hole around that check.
- Fix: enforce QP==MW PD for every MW type, and QP==MR PD whenever an MR is bound.
Step 2.4: ASSESS THE FIX QUALITY
Record: **Obviously correct and minimal.** Same -EINVAL / IB_WC_MW_BIND_ERR policy as existing bind failures. Regression risk is **low**: only previously illegal cross-PD binds start failing. rxe_mw_pd() / mr_pd() already existed on the parent.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record: Incomplete C10-72 check came from **32a577b4c3a9d (2021-06-07) “RDMA/rxe: Add support for bind MW work requests”**. Ancestor of **v5.14** (git merge-base --is-ancestor vs v5.13 failed, vs v5.14 succeeded). Bug is long-standing.
Step 3.2: FOLLOW THE FIXES: TAG
Record: **No Fixes: tag.** Buggy commit identified by history as 32a577b4c3a9d. That commit **is** an ancestor of this HEAD.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: Recent rxe_mw.c work includes access-flag and error-path bind fixes (425e1c9018fdf, 5c719d7aef298). Those do not replace this PD check. **Standalone**, not patch X/Y. No later commits on rxe_mw.c after this one on HEAD.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Zhiwei Zhang has **only this** rxe commit in this history. Reviewer Zhu Yanjun and applier Leon Romanovsky are established RDMA reviewers/maintainers.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: Parent already has rxe_mw_pd() and mr_pd() in rxe_verbs.h (cdd0b85675aec 2021, 1858d98b83940 2020). **Applies standalone** against this tree’s rxe MW code.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- **v1:** https://patch.msgid.link/tencent_88CB6CA0A60CDD53B24EA5E3A865E
[email protected] (2026-06-25)
- **v2 (applied):** https://patch.msgid.link/tencent_FD4FB25AA4FFA845E63
[email protected] (2026-06-26)
- v1→v2: Zhu asked only that the MR-mismatch dbg string say "attempt to bind MW/QP to MR with different PD" because QP/MW PD is already checked. No NAK. v2 applied as-is.
- Leon: “Applied, thanks!” → rdma git f58ea84a3584d1
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: Recipients included **Leon Romanovsky**, **Jason Gunthorpe**, **Zhu Yanjun**, [email protected]. Maintainer-reviewed.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No bugzilla/syzbot/user **Reported-by**. Issue is spec analysis (C10-72), not a crash report.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Single-patch series. v2 is the committed version.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: **UNVERIFIED.** lore.kernel.org/stable returned Anubis bot-check (403/challenge). No evidence in the linux-rdma mbox of a stable nomination or of a reason to withhold it.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: rxe_check_bind_mw() only. Callers/callees: rxe_bind_mw(), rxe_do_bind_mw(), rxe_do_local_ops(), rxe_lookup_mw().
Step 5.2: TRACE CALLERS
Record:
- rxe_bind_mw() ← rxe_do_local_ops() on IB_WR_BIND_MW (rxe_req.c)
- Userspace QPs: rxe_post_send() only schedules send_task; WQEs (including mw_rkey/mr_lkey in include/uapi/rdma/rdma_user_rxe.h) are written by userspace into the SQ. **Unprivileged RDMA userspace can post BIND_MW with arbitrary keys.**
Step 5.3: TRACE CALLEES
Record: Debug prints and PD helpers only. No alloc/lock changes. Bind still runs under spin_lock_bh(&mw->lock).
Step 5.4: FOLLOW THE CALL CHAIN
Record: userspace BIND_MW → requester local op → rxe_bind_mw (global pool lookup by key) → rxe_do_bind_mw (mw->mr = mr) → later RDMA to MW rkey in rxe_resp.c uses mw->mr **without** lookup_mr()’s PD check. **Userspace-reachable isolation hole.**
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: lookup_mr() already requires mr_pd(mr) == pd. rxe_lookup_mw() already requires rxe_mw_pd(mw) == pd. Bind was the inconsistent path. No sibling rxe function needs the same change.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: **Yes, in this 7.3 line.** git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4. MW bind exists since v5.14. Pre-fix rxe_check_bind_mw (parent of fbbe1d5cd7d40) had type-2-only QP/MW PD check and no MR PD check. This commit is an ancestor of HEAD (landed by v7.3-rc1; not in v7.2). Evaluating **this** checkout, the rxe MW bind code is present and the fix matches the local file (no later rxe_mw.c deltas).
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **Clean apply** on this tree. Helpers and function layout match. git diff fbbe1d5 HEAD -- drivers/infiniband/sw/rxe/rxe_mw.c is empty.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: Access-check and error-path bind fixes are already here; they do **not** implement C10-72 for type 1 or MR PD. No alternate PD-bind fix.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: **RDMA software RoCE (drivers/infiniband/sw/rxe)**, CONFIG_RDMA_RXE. **IMPORTANT** (not core mm/VFS): Soft-RoCE is a real verbs provider; PD is the IB isolation primitive. Not staging.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mature. MW bind from 2021; ongoing small correctness fixes. Not a brand-new subsystem on this branch.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: **Config/driver-specific:** users of Soft-RoCE (CONFIG_RDMA_RXE) who use memory windows. Multi-PD or multi-process sharing one rxe device is the interesting case.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Post IB_WR_BIND_MW with MW/MR keys from another PD. Userspace can do that; keys are index << 8 | u8 (rxe_get_next_key()). Trigger is **intentional/malicious or buggy app**, not every bind. Unprivileged verbs users **can** trigger it.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: **Not a crash.** Invalid bind **succeeds**, then RDMA through the MW rkey can touch another PD’s registered memory. **Severity: HIGH** (isolation/security), not panic/deadlock.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit: high** for rxe MW users — closes a PD bypass around lookup_mr().
- **Risk: very low** — ~12 lines, validation-only, same error code, no API/lock/structure change.
- **Ratio:** favor applying.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
**FOR:**
- Real IBTA C10-72 hole, not style
- Userspace-reachable via mapped SQ BIND_MW + global key lookup
- After bind, mw->mr is used without MR PD check → isolation bypass
- Tiny, obviously correct; maintainer applied; one-line v2 log tweak only
- Helpers already in this tree; applies cleanly
- Bug since v5.14 MW bind support
**AGAINST:**
- No crash/syzbot/CVE/user report
- rxe is not mlx5-class hardware; fewer production hosts
- Could be framed as spec hardening
**UNRESOLVED:**
- Whether stable@ already discussed this (lore/stable blocked)
- No public reproducer beyond code-path analysis (verified in-tree)
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — reviewed, v2 applied by Leon; logic matches existing checks
2. Fixes a real bug that affects users? **PASS** — invalid binds succeed; PD isolation not enforced on bind
3. Important (crash/security/corruption/deadlock)? **PASS** — PD bypass / unauthorized MR attach; HIGH isolation, not a panic
4. Small and contained? **PASS** — one function, +12/-8
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — file and helpers match; no rewrite needed
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: None (not a device ID, quirk, DT, build, or docs-only change). Qualifies as a normal bugfix.
Step 9.4: MAKE YOUR DECISION
This should be in this tree: it closes a long-standing Soft-RoCE bind isolation gap with a few lines of PD checks, no API change, and negligible regression risk. Missing crash reports does not make a skipped PD check “theoretical” when userspace supplies the keys and the data path then uses mw->mr.
Verification:
- [Phase 1] Tags: Reviewed-by Zhu Yanjun; SOB Zhiwei Zhang; Link msgid; SOB Leon; no Fixes/Reported-by/syzbot
- [Phase 1] Body: C10-72 QP/MW/MR same PD; type-2-only check; IB_WC_MW_BIND_ERR
- [Phase 2] Diff: rxe_check_bind_mw +12/-8; common QP/MW PD check; new QP vs mr_pd(mr)
- [Phase 2] Parent code: C10-72 only under IB_MW_TYPE_2; no MR PD check
- [Phase 2] rxe_do_local_ops: bind failure → IB_WC_MW_BIND_ERR (verified rxe_req.c)
- [Phase 3] git describe HEAD / make kernelversion: v7.3-rc4 / 7.3.0-rc4
- [Phase 3] git merge-base --is-ancestor fbbe1d5 HEAD → yes; vs v7.2 → no; vs v7.3-rc1 → yes
- [Phase 3] Buggy intro 32a577b4c3a9d is ancestor of v5.14, not v5.13
- [Phase 3] Parent has rxe_mw_pd / mr_pd in rxe_verbs.h
- [Phase 3] Author: only this rxe commit; not a series
- [Phase 4] b4 dig -c fbbe1d5: v2 msgid tencent_FD4FB25…; v1 tencent_88CB6CA0…
- [Phase 4] v1 review: Zhu requested dbg string only; Reviewed-by; no NAK
- [Phase 4] Leon applied to rdma tree; no stable nomination in that mbox
- [Phase 4] lore.kernel.org WebFetch 403; stable/? search hit Anubis — UNVERIFIED on stable@
- [Phase 5] Call chain: user SQ BIND_MW → rxe_bind_mw global pool lookup → mw->mr → rxe_resp.c uses mw->mr without lookup_mr() PD check
- [Phase 5] lookup_mr() already has mr_pd(mr) != pd (verified rxe_mr.c:713-716)
- [Phase 5] Userspace WQE fields mr_lkey/mw_rkey in rdma_user_rxe.h; rxe_post_send does not copy/validate them for user QPs
- [Phase 6] git diff fbbe1d5 HEAD -- rxe_mw.c empty; clean on this tree
- [Phase 8] Keys: index << 8 | rxe_get_next_key() (8-bit key); isolation severity HIGH
- UNVERIFIED: stable@ history; no in-tree test/reproducer for cross-PD bind
**YES**
drivers/infiniband/sw/rxe/rxe_mw.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/infiniband/sw/rxe/rxe_mw.c +12 -8
@@ -72,13 +72,6 @@ static int rxe_check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe,return -EINVAL ; } -/* C10-72 */ -if (unlikely (qp->pd !=to_rpd (mw->ibmw.pd))) { -rxe_dbg_mw (mw, -"attempt to bind type 2 MW with qp with different PD\n" ); -return -EINVAL ; - } -/* o10-37.2.40 */ if (unlikely (!mr || wqe->wr.wr.mw.length ==0 )) { rxe_dbg_mw(mw,
@@ -87,10 +80,21 @@ static int rxe_check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, } } -/* remaining checks only apply to a nonzero MR */ +/* C10-72 */ +if (unlikely (qp->pd !=rxe_mw_pd (mw))) { +rxe_dbg_mw (mw,"attempt to bind MW with qp with different PD\n" ); +return -EINVAL ; + } +if (!mr)return 0 ; +/* remaining checks only apply to a nonzero MR */ +if (unlikely (qp->pd !=mr_pd (mr))) { +rxe_dbg_mw (mw,"attempt to bind MW/QP to MR with different PD\n" ); +return -EINVAL ; + } +if (unlikely (mr->access &IB_ZERO_BASED )) {rxe_dbg_mw (mw,"attempt to bind MW to zero based MR\n" );return -EINVAL ;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-6.1] RDMA/rxe: Check PDs for memory window binds
Sashiko has reviewed this patch and found no issues.
Quoted 12 lines
From: Zhiwei Zhang <[email protected]>
[ Upstream commit
fbbe1d5cd7d400a98afcf337969cfdb808cb198f]The IBTA Software Transport Verbs specification requires the QP, Memory Window and Memory Region for a Bind Memory Window operation to belong to the same HCA and protection domain.
rxe only checked the QP and MW protection domain for type 2 MWs. Move the QP/MW PD check to the common bind path and also reject binding an MW to an MR from a different PD.
Quoted 7 lines
Invalid bind requests continue to fail with
IB_WC_MW_BIND_ERR.Reviewed-by Zhu Yanjun <[email protected]>Signed-off-by Zhiwei Zhang <[email protected]>Signed-off-by Leon Romanovsky <[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 s390/mm: Fix handling of vmalloc area in do_secure_storage_access()
In reply to Sasha LevinFrom: Heiko Carstens <[email protected]>
[ Upstream commit a2e5a9d853e015bc876399eb18435aa88101c60a ]
Secure storage access exceptions in vmalloc area need to be handled separately since virt_to_phys() does not work on such addresses. Given that there cannot be a valid access let such exceptions fail immediately. The kernel will either fixup or crash.
---
LLM Generated explanations, may be completely bogus:
I have enough history, the series context, and the local fault.c path to decide. The remaining work is to write the phase-by-phase analysis.
## Phase 1: Commit message forensics
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[s390/mm]** **[Fix]** handling of vmalloc addresses in do_secure_storage_access() — kernel secure-storage exceptions on vmalloc must not go through virt_to_folio() / virt_to_phys().
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Tested-by: Christian Borntraeger <[email protected]>
- Signed-off-by: Heiko Carstens <[email protected]> (author; s390 arch maintainer)
- Reviewed-by: Christian Borntraeger <[email protected]> (KVM/s390)
- Signed-off-by: Vasily Gorbik <[email protected]> (s390 tree maintainer)
- No Fixes: tag (expected for this review pipeline)
- No Reported-by:, Link:, or Cc: [email protected]
- Ignore any later Sasha Levin SOB / “Upstream commit” markers (none on the raw commit)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** PGM 0x3d (secure storage access) on a vmalloc address is fed to virt_to_folio() / virt_to_phys(), which are not valid for vmalloc.
- **Symptom:** wrong folio/PFN, then uv_convert_from_secure() on the wrong physical page, or a failed get and an unresolved fault (retry loop). Cover letter: kernel should fix up or crash, not convert a random page.
- **Version info in message:** none. Git places it in v7.3-rc1 (v7.3-rc1~73^2~35).
- **Root cause (author):** vmalloc is not a linear kernel mapping; there is no legitimate convert-from-secure for that address, so fail immediately via the existing fault-error path.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Subject and body say **Fix**. Cover letter for v4 of the series lists this as a real pre-existing bug, distinct from two later “cosmetics” patches the author explicitly said were not bug fixes.
---
## Phase 2: Diff analysis
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: arch/s390/mm/fault.c (+2 / −0)
- Function: do_secure_storage_access()
- Scope: **single-file surgical fix**, two lines in the kernel-fault branch
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** is_kernel_fault() → virt_to_folio((void *)addr) → folio_try_get → uv_convert_from_secure(folio_to_phys(folio)).
- **After:** if is_vmalloc_addr(addr), return handle_fault_error_nolock(regs, 0) (exception-table fixup, or oops/die). Linear-map kernel faults unchanged.
- Path: kernel (not user) PGM 0x3d on a vmalloc address.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** memory-safety / logic — invalid virt-to-phys on vmalloc; can become wrong-page UV export or an unresolved fault.
- **Mechanism:** virt_to_folio() uses virt_to_page() → __pa(). On s390 __pa() is identity/KASLR linear-map math (arch/s390/include/asm/page.h), not a page-table walk. A vmalloc address yields a bogus PFN. uv_convert_from_secure() then talks to the Ultravisor about that PFN.
- **Fix:** reject vmalloc up front; same helper already used on other kernel-fault failures in this file.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: vmalloc is not a valid convert-from-secure target; the author states there is no valid access.
- Minimal; no unrelated edits; no new API.
- Regression risk is low. Kernel-mode handle_fault_error_nolock(..., 0) does not take the user WARN_ON_ONCE(!si_code) path; it fixup_exception() or oopses. That matches “fixup or crash.”
- Follow-up ecb00aa6fb7f4 still keeps this check after switching to __pa(addr), which confirms the check is not a folio-API workaround.
---
## Phase 3: Git history investigation
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Handler introduced in 084ea4d611a3 (2020, “s390/mm: add (non)secure page access exceptions handlers”) — phys_to_page(addr) on KERNEL_FAULT (virt treated as phys).
- b95e0e792822b (v7.1-rc2) switched that to virt_to_folio() (“Fix phys_to_folio() usage”). Correct for the linear map, still wrong for vmalloc.
- The two new lines are this commit, a2e5a9d853e01 (Heiko Carstens, 2026-07-20).
- Current tree still has them (blame on arch/s390/mm/fault.c lines 440–441).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Closest introduction of the *current* wrong helper is b95e0e792822b; the vmalloc hole exists conceptually since 084ea4d611a3. Both are ancestors of this checkout.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Same-day series (AuthorDate 2026-07-20):
1. 7cf227b2707ed — NULL mm check (user path; Sashiko)
2. 79ef8d384fdfb — lock_mm_and_find_vma() (user path)
3. **a2e5a9d853e01 — this vmalloc check (kernel path)**
4. ecb00aa6fb7f4 — drop folio_try_get race; use __pa()
5. da1f5a7dcf182 / e462200886fb5 — author-labeled cosmetics
6. 656db3022083a — re-enable DCACHE_WORD_ACCESS
This hunk is on the kernel-fault branch only and does not depend on 1–2. Standalone as a two-line insert. handle_fault_error_nolock already existed (a5600f05d3d7a, v6.13 era) and was already used in this function (b00be77302d7e).
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Heiko Carstens is the s390 arch maintainer and owns most of this function’s recent history. Christian Borntraeger tested and reviewed. Not a drive-by.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs is_kernel_fault(), is_vmalloc_addr() (<linux/mm.h>, already included), and handle_fault_error_nolock(). All present here. Does **not** require re-enabling DCACHE_WORD_ACCESS. git merge-base --is-ancestor a2e5a9d853e01 HEAD succeeds — already in this tree as a historical fact, not as a selection marker.
---
## Phase 4: Mailing list and external research
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c a2e5a9d853e01 →
https://patch.msgid.link/[email protected]
- **[PATCH v4 4/8]** in “s390: Reintroduce support for DCACHE_WORD_ACCESS”
- Revisions: v1 (2026-07-16) → v2 → v3 → **v4 (applied)**
- v3 changelog: “Fix two more pre-existing bugs reported by Sashiko”
- Cover letter lists this as one of the real problems, separate from kcore VM_SPARSE and from the folio-race patch
- Direct review: Borntraeger Reviewed-by; no NAK
- Vasily Gorbik: “Applied, thank you!”
- lore.kernel.org HTTP fetch returned 403 (Anubis). Thread recovered via b4 dig -m.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): Heiko Carstens, Alexander Gordeev, Sven Schnelle, Vasily Gorbik, Christian Borntraeger, Janosch Frank, Claudio Imbrenda, David Hildenbrand; linux-s390@, kvm@, linux-kernel@. Right maintainers and lists.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla. Concrete trigger is documented in the **same series**:
- Cover letter: DCACHE_WORD_ACCESS was reverted in 37540b8c287fc because secure-storage handling was incomplete (endless exception loop); that revert had Cc: stable.
- Patch 1 (aab0734094cef): “The guest variable storage area is allocated with **vmalloc** and then donated to the ultravisor. Any kernel access to that area will result in a secure storage access exception.” /proc/kcore via vread_iter() was a known short- read/exception.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 8-patch v4 series. This patch is self-contained. Later ecb00aa6fb7f4 keeps the vmalloc check. Re-enabling DCACHE_WORD_ACCESS is a **feature** and is not required for this fix.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: Direct lore.kernel.org/stable search blocked (403). Unverified whether anyone mailed stable@ for this SHA. The related revert 37540b8c287fc **was** tagged Cc: stable, so stable trees that had word-at-a-time already treated this class of bug as important.
---
## Phase 5: Code semantic analysis
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: do_secure_storage_access() only.
**Step 5.2: TRACE CALLERS**
Record:
- arch/s390/kernel/traps.c program-check table [0x3d] = do_secure_storage_access
- Hardware PGM 0x3d (secure-storage access), not a syscall helper
- Compiled only under #if IS_ENABLED(CONFIG_KVM) in fault.c
**Step 5.3: TRACE CALLEES**
Record: is_vmalloc_addr(), handle_fault_error_nolock() → fixup_exception() / kfence_handle_page_fault() / die(). Pre-fix
callees: virt_to_folio, folio_try_get, uv_convert_from_secure, folio_put.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable from:
- Kernel access to UV-donated **vmalloc** (guest variable storage; kcore)
- load_unaligned_zeropad() spanning into a donated page once DCACHE_WORD_ACCESS is on (this tree has it again via 656db3022083a)
Unprivileged user can trigger kcore only with privilege; zeropad/dcache is a common kernel path (namei/dcache) and can touch adjacent pages. Protected-virt hosts are the affected population.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: No other virt_to_folio in this handler’s kernel-fault path after ecb00aa6fb7f4. uv_convert_from_secure() in arch/s390/kernel/uv.c takes a **physical** address; callers must not pass vmalloc virt.
---
## Phase 6: Cross-referencing against the local tree
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- git describe HEAD → **v7.3-rc4-27-gf0100363d8c37**; make kernelversion → **7.3.0-rc4**
- This is mainline 7.3-rc, not a -stable y-tree
- Function exists at arch/s390/mm/fault.c:408
- Current kernel-fault path still has the vmalloc check (lines 440–441) then __pa(addr)
- Bug is real in any tree that still does virt_to_folio/__pa on the fault address without a vmalloc guard — including this line of development before a2e5a9d853e01
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Against **this** checkout the patch is already applied; the surrounding kernel-fault if matches the parent of a2e5a9d853e01. Expected difficulty on a tree that still has folio = virt_to_folio((void *)addr); in that if: **clean apply**. Helpers exist here.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This exact fix is already an ancestor of HEAD. That is mainline history, not “already selected for stable.” No substitute vmalloc guard appears before a2e5a9d853e01.
---
## Phase 7: Subsystem and maintainer context
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **arch/s390 MM + KVM protected virtualization**. Criticality:
**IMPORTANT** for s390 KVM PV (Ultravisor / confidential guests) — not universal, but confidentiality and host stability for that platform.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained (Heiko/Vasily/Borntraeger). Handler dates to 2020; this is a long-standing hole, not a brand-new subsystem.
---
## Phase 8: Impact and risk assessment
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Platform-specific + config-specific:** s390, CONFIG_KVM, protected-virt host (pages donated to UV). Not all Linux users; all such hosts that can take PGM 0x3d on vmalloc.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Kernel access to UV-donated vmalloc (documented: former vmalloc stor_var + /proc/kcore)
- Word-at-a-time / zeropad crossing into donated memory (this tree has DCACHE_WORD_ACCESS again)
- Not a userspace-unprivileged primitive in the usual sense; kcore needs privilege; zeropad is kernel-internal but common on PV hosts
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- Wrong PFN → uv_convert_from_secure() on the **wrong** page: guest- confidentiality break / host page state corruption → **CRITICAL** on PV
- folio_try_get fail → silent return → instruction retry → **endless PGM 0x3d** (the failure mode that forced the DCACHE revert) → **CRITICAL** (lockup)
- Severity: **CRITICAL** when it hits; trigger is not every boot, but it is a documented real path
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** high for s390 PV — avoids wrong UV export and exception storms
- **Risk:** very low — two lines, existing helper, linear-map path unchanged
- **Ratio:** strongly favors backport
---
## Phase 9: Final synthesis
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real bug: virt_to_folio/__pa on vmalloc is invalid on s390
- Failure modes: wrong-page uv_convert_from_secure, unresolved fault / infinite PGM 0x3d
- Documented trigger: vmalloc UV storage; kcore; later zeropad
- 2-line, surgical, uses existing handle_fault_error_nolock
- Written/acked by s390 maintainers; Tested-by + Reviewed-by Borntraeger
- Author treated it as a bug fix, not as the DCACHE feature patch
- Follow-up kept the same check with __pa
- Code and helpers exist in this 7.3-rc4 tree
**AGAINST:**
- s390 + KVM PV only (smaller user base than core mm)
- Part of a larger DCACHE series — but this hunk does not enable that feature
- No Fixes: / Cc: stable (not a negative per the rules)
- Direct stable@ lore search could not be completed (403)
**UNRESOLVED:**
- Whether stable@ already discussed this exact SHA (lore HTTP blocked)
- Exact older-stable context outside this checkout — not used for the verdict
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — two-line guard; Tested-by Borntraeger
2. Fixes a real bug that affects users? **PASS** — wrong phys conversion / exception loop on PV hosts
3. Important (crash, security, corruption, deadlock)? **PASS** — UV export of the wrong page and/or host lockup
4. Small and contained? **PASS** — +2 lines, one function
5. No new features or APIs? **PASS** — not the DCACHE re-enable
6. Can apply to the local tree? **PASS** — helpers and call site exist; this checkout already contains the change as mainline history
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not a device-ID/quirk/DT/build/doc exception). Qualifies as a normal important bug fix.
**Step 9.4: MAKE YOUR DECISION**
This tree is **Linux 7.3-rc4** (v7.3-rc4-27-gf0100363d8c37). The surrounding handler, is_vmalloc_addr(), and handle_fault_error_nolock() are all here. The bug is using linear-map virt-to-phys on a vmalloc PGM 0x3d, which can export the wrong page from secure storage or never resolve the fault.
The patch is two lines, maintainer-written, tested, and independent of re-enabling DCACHE_WORD_ACCESS. Benefit is high for s390 protected- virt; regression risk is very low. It meets the stable-kernel rules for **this** checkout.
---
### What the commit solves (for this tree)
do_secure_storage_access() handled kernel PGM 0x3d by converting the fault address with virt_to_folio(). That is only valid for the identity/KASLR linear map. Vmalloc (including UV guest variable storage allocated with vmalloc, and later word-at-a-time probes) must not take that path. The fix fails those faults immediately so the kernel can exception-fixup or oops instead of converting a random physical page.
### Verification
- **[Phase 1]** Parsed tags: Tested-by/Reviewed-by Borntraeger; SOB Heiko + Vasily; no Fixes/Cc stable/syzbot
- **[Phase 2]** Diff: +2 lines in do_secure_storage_access() kernel- fault branch; is_vmalloc_addr then handle_fault_error_nolock
- **[Phase 2]** Read arch/s390/include/asm/page.h __pa_nodebug:
linear map only, not vmalloc
- **[Phase 2]** Read include/linux/mm.h virt_to_folio:
virt_to_page → __pa
- **[Phase 3]** git describe HEAD / make kernelversion: v7.3-rc4 / 7.3.0-rc4
- **[Phase 3]** git merge-base --is-ancestor a2e5a9d853e01 HEAD: yes (mainline ancestor, not a selection marker)
- **[Phase 3]** git show a2e5a9d853e01: matches the provided diff
- **[Phase 3]** git blame on fault.c 408–470: handler from 084ea4d611a3 (2020); vmalloc lines from this commit
- **[Phase 3]** git show b95e0e792822b: phys_to_folio → virt_to_folio in v7.1-rc2; vmalloc still wrong
- **[Phase 3]** git show ecb00aa6fb7f4: later __pa path **keeps** the vmalloc check
- **[Phase 3]** git show 37540b8c287fc: DCACHE revert; endless PGM 0x3d; Cc: stable
- **[Phase 4]** b4 dig -c/-a/-w/-m: v4 4/8; lore msgid [email protected]; v1–v4; s390/KVM CCs; Borntraeger R-b; Gorbik applied
- **[Phase 4]** WebFetch lore.kernel.org: 403; discussion taken from b4 mbox instead
- **[Phase 4]** Cover letter: this is a listed pre-existing bug, not cosmetics
- **[Phase 4]** git show aab0734094cef: stor_var was vmalloc then donated to UV; kernel access → PGM 0x3d
- **[Phase 5]** Callers: traps.c [0x3d]; #if IS_ENABLED(CONFIG_KVM)
- **[Phase 5]** Read handle_fault_error_nolock: kernel path fixup or die
- **[Phase 6]** Read current fault.c 439–449: vmalloc check still present
- **[Phase 8]** Failure mode: wrong UV export and/or infinite exception — CRITICAL for s390 PV
- **UNVERIFIED:** stable@ mailing-list threads for this SHA (lore 403)
The fix is small, obviously correct, and addresses a real crash/corruption/confidentiality bug on this tree’s s390 KVM PV path.
**YES**
arch/s390/mm/fault.c | 2 ++ 1 file changed, 2 insertions(+)
arch/s390/mm/fault.c +2 -0
@@ -433,6 +433,8 @@ void do_secure_storage_access(struct pt_regs *regs)panic ("Unexpected PGM 0x3d with TEID bit 61=0" ); }if (is_kernel_fault (regs)) { +if (is_vmalloc_addr ((void *)addr)) +return handle_fault_error_nolock (regs,0 ); folio =virt_to_folio ((void *)addr);if (unlikely (!folio_try_get (folio)))return ;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18] s390/mm: Fix handling of vmalloc area in do_secure_storage_access()
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines
From: Heiko Carstens <[email protected]>
[ Upstream commit
a2e5a9d853e015bc876399eb18435aa88101c60a]Secure storage access exceptions in vmalloc area need to be handled separately since
virt_to_phys()does not work on such addresses. Given that there cannot be a valid access let such exceptions fail immediately. The kernel will either fixup or crash.
Quoted 5 lines
Signed-off-by Heiko Carstens <[email protected]>Reviewed-by Christian Borntraeger <[email protected]>> ---Signed-off-by Vasily Gorbik <[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 netfilter: nf_tables: call skb_valid_dst() before skb_dst()
In reply to Sasha LevinFrom: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 689db98e535bf8efb5bc9c36f4fd3de3bd715eb6 ]
When fetching the dst_entry from the skb, check if it valid, ie. this is not a template dst, for extensions that can be used from the netdev ingress and egress chains.
---
LLM Generated explanations, may be completely bogus:
The evaluation target is **pending-6.6 (Linux 6.6.157)**. The live checkout later moved to mainline v7.3-rc4; all 6.6 findings below are from refs/heads/pending-6.6 (p-6.6-3-g04810563abb71).
Original commit: 689db98e535bf8efb5bc9c36f4fd3de3bd715eb6 (Pablo Neira Ayuso, 2026-07-31). It is **not** an ancestor of pending-6.6.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
- Record: **[netfilter/nf_tables] [call/check] [require a real routing dst, not a metadata template, before using skb_dst()]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Record:
- **Fixes:** none (expected for this review)
- **Reported-by / Tested-by / Reviewed-by / Acked-by:** none
- **Link:** none in the commit; mailing list found separately
- **Cc: stable:** none (expected)
- **Signed-off-by:** Pablo Neira Ayuso (netfilter maintainer). Ignore Sasha Levin SOB if present in a candidate wrapper.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Record:
- **Bug:** skb_dst() is used as if it were a real rtable/rt6_info. Packets on netdev/inet ingress/egress often carry a **DST_METADATA** template (tunnels, TC) instead.
- **Symptom:** nft rt / meta rtclassid / xfrm evaluate a template dst; nf_send_reset/nf_send_unreach skip filling a real route and treat the template as an rtable.
- **Version info:** none in the message. Buggy pattern is old; 6.6 still has it.
- **Root cause (author):** template dst is not a valid routing dst; must use skb_valid_dst() first.
**Step 1.4: DETECT HIDDEN BUG FIXES**
- Record: **Not hidden.** It is a real validity check. “Call X before Y” is a missing-check fix, not cleanup.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
- Record:
- net/ipv4/netfilter/nf_reject_ipv4.c (+4/−2)
- net/ipv6/netfilter/nf_reject_ipv6.c (+6/−2)
- net/netfilter/nft_meta.c (+4/−2)
- net/netfilter/nft_rt.c (+4/−2)
- net/netfilter/nft_xfrm.c (+8/−1)
- **~26 insertions, 9 deletions, 5 files**
- Functions: nf_reject_fill_skb_dst, nf_send_reset,
`nf_send_unreach`, `nf_reject6_fill_skb_dst`, `nf_send_reset6`,
`nf_send_unreach6`, `nft_meta_get_eval_rtclassid`,
`nft_rt_get_eval`, `nft_xfrm_get_eval_out`- **Scope:** small, same-subsystem, surgical
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
- Record:
- **Reject fill:** skb_dst_set() over a possible existing template → skb_dst_drop() then skb_dst_set() of a real route.
- **Reject send:** if (!skb_dst()) fill → if (!skb_valid_dst()) fill. Template dst no longer counts as “already routed.”
- **nft_meta / nft_rt / nft_xfrm:** skb_dst() then NULL check → skb_valid_dst() then skb_dst(). Template dst is treated as missing.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
- Record:
- **Category:** logic/correctness + type confusion (metadata dst used
as `rtable`/`xfrm_dst`).
- **Mechanism:** skb_valid_dst() is dst && !(dst->flags & DST_METADATA). Metadata dst is initialized with dst_blackhole_ops and **dev == NULL**. Using it as skb_rtable() reads rt_flags/rt_gw* from the metadata union; nft_xfrm would walk ((xfrm_dst *)dst)->child if dst->xfrm were set.
**Step 2.4: ASSESS THE FIX QUALITY**
- Record:
- **Quality:** obviously correct; same helper already used in ip_input, ip_tunnel, wireguard, xfrm.
- **Minimal:** yes. Include of net/dst_metadata.h is required for the helper.
- **Regression risk:** low. meta rtclassid on a metadata dst currently succeeds with tclassid == 0; after the fix it fails closed (NFT_BREAK). That is stricter and correct.
- **No API/feature additions.**
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
- Record:
- Reject !skb_dst() && fill: a0a3ace2a5788 (Florian Westphal, 2025-08-20) already **in 6.6** — “don’t leak dst refcount for loopback packets.” That made “any dst present” skip fill, including metadata dst.
- nft_rt_get_eval skb_dst check: 2fa841938c648 (2016), present since nft_rt was added.
- **Bug is in 6.6, not new mainline-only code.**
**Step 3.2: FOLLOW THE FIXES TAG**
- Record: **No Fixes: tag.** Not applicable. Introducer of the reject skip-fill logic **is** in this tree (a0a3ace2a5788).
**Step 3.3: CHECK FILE HISTORY**
- Record: Related 6.6 history includes a0a3ace2a5788 (reject dst leak) and e64a48c50a1ff (nf_conntrack_sip: validate skb_dst() for tc/OVS). Same class of bug already accepted into 6.6. This commit is standalone, not patch 2/N of a required series (it was 8/9 of an nf- next pull, but the diff does not depend on patches 1–7).
**Step 3.4: CHECK THE AUTHOR**
- Record: **Pablo Neira Ayuso is the netfilter maintainer.** Nearby work is normal nf-next flowtable/conncount material; this hunk is independent.
**Step 3.5: DEPENDENT/PREREQUISITE COMMITS**
- Record:
- skb_valid_dst() exists in 6.6 include/net/dst_metadata.h.
- No new helpers required.
- **Can apply standalone** with minor context (see Phase 6).
- No follow-ups on origin/master after 689db98e535bf.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
- Record:
- b4 dig -c 689db98e535bf: **failed** (lore.kernel.org 503).
- Fallback: [PATCH net-next 8/9]
https://lists.openwall.net/netdev/2026/07/31/304 - Cover: [PATCH net-next 0/9] https://lists.openwall.net/netdev/2026/07/31/319
- Submitted to **nf-next / net-next**, not net (fixes). Cover: “Call skb_valid_dst() before accessing skb_dst() to ensure dst_entry is not a template.”
- Syzbot CI on the nf-next posting: **passed**
(https://ci.syzbot.org/series/250b78fc-95ac-4f6f-8746-9f8d8777688b).
Not a syzbot crash report.
- No NAK found. No reviewer “Cc: stable” found.
**Step 4.2: CHECK WHO REVIEWED**
- Record: To/Cc: netfilter-devel, davem, kuba, pabeni, edumazet, [email protected], horms. **Florian Westphal (nf core) was CC’d.** Applied by Pablo himself. No extra Reviewed-by on the commit.
**Step 4.3: SEARCH FOR THE BUG REPORT**
- Record: **No user/syzbot/bugzilla report.** Author-driven correctness fix.
**Step 4.4: RELATED PATCHES AND SERIES**
- Record: Series 1–7 is flowtable/fill_forward_path work; patch 9 is conntrack TCP timeout. **This patch does not depend on them.** Same- class SIP helper fix already in 6.6.
**Step 4.5: STABLE MAILING LIST HISTORY**
- Record: lore.kernel.org/stable fetch returned **403**. **UNVERIFIED** whether stable@ discussed this SHA. No evidence it was rejected for stable.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
- Record: listed in 2.1.
**Step 5.2: TRACE CALLERS**
- Record (6.6):
- nf_send_unreach / nf_send_reset: nft_reject_ipv4_eval,
`nft_reject_inet_eval`, `ipt_REJECT`.
- IPv6 equivalents: nft reject ipv6/inet, ip6t_REJECT.
- **netdev reject does not use these**; it uses `nf_reject_skb_v4_*` /
`nf_reject_skb_v6_*` (unchanged). - nft_rt_get_eval: packet path for the rt expression; **family limited to ipv4/ipv6/inet** (not netdev).
- nft_xfrm_get_eval_out: ipv4/ipv6/inet, OUT hooks only.
- nft_meta_get_eval_rtclassid: **allowed on netdev** (no hook restriction for this key).
**Step 5.3: TRACE CALLEES**
- Record: skb_valid_dst, skb_dst_drop/skb_dst_set, nf_ip_route/nf_ip6_route, skb_rtable, icmp_send/icmpv6_send, ip_route_me_harder.
**Step 5.4: FOLLOW THE CALL CHAIN**
- Record: Reachable from nftables/iptables **REJECT** and from rt/xfrm/meta rtclassid eval. Userspace (nft/iptables) installs the rules. Overlay tunnels (VXLAN/GENEVE collect-md, TC tunnel_key) attach metadata dst, then the inner packet hits **inet ingress / PRE_ROUTING**. **Yes, reachable.**
**Step 5.5: SIMILAR PATTERNS**
- Record: Same skb_valid_dst pattern in net/ipv4/ip_input.c, ip_tunnel.c, xfrm_input.c. 6.6 already has nf_conntrack_sip dst validation for tc/OVS.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE (6.6.157)
**Step 6.1: DOES THE BUGGY CODE EXIST?**
- Record: **Yes.**
- nf_reject_ipv4.c: if (!skb_dst(oldskb) && nf_reject_fill_skb_dst...) and no skb_dst_drop before skb_dst_set.
- Same for IPv6 reject.
- nft_rt.c: dst = skb_dst(skb); if (!dst) goto err;
- nft_meta.c: const struct dst_entry *dst = skb_dst(skb); if (!dst) return false;
- nft_xfrm.c: const struct dst_entry *dst = skb_dst(pkt->skb);
then walk `dst->xfrm`.
- 6.6 **has** netdev **ingress and egress** (nft_chain_filter_netdev), **NF_INET_INGRESS** (inet reject validates it), and skb_valid_dst().
**Step 6.2: BACKPORT COMPLICATIONS**
- Record: **Minor context, not rework.**
- 6.6 nft_rt uses (const struct rtable *)dst not dst_rtable() (unchanged context).
- 6.6 nf_send_reset6 uses skb_dst(oldskb)->dev not skb_dst_dev() (unchanged context). skb_dst_dev() exists in 6.6 include/net/dst.h but is not used in this file.
- Functional hunks match 6.6.
**Step 6.3: RELATED FIXES ALREADY HERE**
- Record: a0a3ace2a5788 (reject dst leak) and e64a48c50a1ff (SIP skb_dst). **This metadata-vs-real-dst check is not already applied.** git merge-base --is-ancestor 689db98e535bf pending-6.6 → not ancestor.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: SUBSYSTEM AND CRITICALITY**
- Record: **netfilter / nf_tables + IPv4/IPv6 reject.** **IMPORTANT** (firewall/NAT on almost every server/router/container host). Not core mm/scheduler, but production-critical networking.
**Step 7.2: SUBSYSTEM ACTIVITY**
- Record: Mature and actively fixed. nft_rt dates to 2016; reject-at- prerouting to 2020 (f53b9b0bdc59). Long-lived code.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
- Record: **Config/driver-specific but common:** nftables/iptables REJECT, rt, meta rtclassid, xfrm, plus overlay/TC metadata dst (Kubernetes, OVN, VXLAN/GENEVE collect-md).
**Step 8.2: TRIGGER CONDITIONS**
- Record: Packet carries DST_METADATA **and** hits reject or those expressions. Common on inet ingress/PRE_ROUTING of collect-md tunnels. Unprivileged users cannot install nft rules (CAP_NET_ADMIN); they **can** send traffic that hits existing rules. Timing race: no.
**Step 8.3: FAILURE MODE SEVERITY**
- Record:
- **Verified:** type confusion (skb_rtable() on metadata dst); rt_flags/nexthop taken from the metadata union; reject may skip nf_reject_fill_skb_dst and feed icmp_send/ip_route_me_harder a template dst.
- **6.6 __icmp_send:** if (!rt) return is **not** enough (template
is non-NULL); `rt->dst.dev` NULL is handled, then `rt->rt_flags` is
still type-confused. - **Not a proven KASAN UAF.** Metadata dst uses dst_blackhole_ops, so ops->mtu is not NULL. dst->xfrm is NULL on metadata dst, so the xfrm walk typically does not follow a garbage child.
- **Severity: HIGH for firewall correctness** (wrong rt/meta match; REJECT may not emit RST/ICMP). **MEDIUM as a crash** (plausible UB/type confusion, not a demonstrated oops). Still a real bug in a hot firewall path.
**Step 8.4: RISK-BENEFIT**
- Record:
- **Benefit:** high for nft/iptables + overlay users; restores intended “no real route → lookup or fail closed.”
- **Risk:** low (26 lines, existing helper, fail closed).
- **Ratio:** favorable.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: EVIDENCE**
**FOR:**
- Real bug: template dst treated as a route.
- Present in 6.6; skb_valid_dst() already exists.
- Reject skip-fill was introduced/worsened by a commit **already in 6.6**.
- Small, maintainer-authored, obviously correct.
- Same class as SIP skb_dst validation already in 6.6 stable.
- Realistic trigger: collect-md tunnels + nft/iptables at ingress/prerouting.
- No follow-up reverting or rewriting this change.
**AGAINST:**
- Posted as net-next 8/9, not net.
- No Fixes/Cc: stable, no crash report.
- netdev-family reject does not call nf_send_*; nft_rt/nft_xfrm cannot be used on netdev family even in mainline.
- Crash is not as hard as a NULL ops deref (blackhole ops).
**UNRESOLVED:**
- lore.kernel.org was 503/403; no full review thread beyond Openwall. No stable@ discussion verified.
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — helper semantics are clear; syzbot CI passed; in mainline since 2026-07.
2. Fixes a real bug that affects users? **PASS** — metadata dst on ingress/tunnel paths is real; expressions/reject mishandle it.
3. Important (crash/security/corruption/deadlock)? **PASS** — firewall mis-eval and failed REJECT replies on overlay/ingress; type-confused rtable use. Not a proven panic, but important networking correctness.
4. Small and contained? **PASS** — 26/9 lines, five netfilter files.
5. No new features or APIs? **PASS**
6. Can apply to this tree? **PASS** — minor context (dst_rtable / skb_dst_dev in unchanged lines only).
**Step 9.3: EXCEPTION CATEGORIES**
- Record: none (not a device ID/quirk/DT/build/docs exception). Qualifies as a normal bugfix.
**Step 9.4: DECISION**
This is a small, correct check that 6.6 needs. The tree has the buggy !skb_dst() reject path, nft rt/meta/xfrm eval, inet ingress, and netdev ingress/egress. Benefit outweighs risk.
---
### What the commit solves for 6.6 users
Packets with a **metadata/template dst** (VXLAN/GENEVE collect-md, TC) make skb_dst() non-NULL, so reject never installs a real route and rt/meta rtclassid/xfrm inspect a non-route. Users see wrong nft matches and missing TCP RST / ICMP unreachable. The fix uses the existing skb_valid_dst() helper and drops any template dst before attaching a real one.
### Risk vs benefit
Low risk, high correctness value on firewall + overlay hosts. Apply may need a one-line context tweak in nft_rt.c and nf_reject_ipv6.c.
### Verification
- **[Phase 1]** Parsed subject/body; tags: only Pablo SOB; no Fixes/Reported-by/stable.
- **[Phase 2]** Diff: 5 files, +26/−9; skb_valid_dst + skb_dst_drop before skb_dst_set.
- **[Phase 3]** git describe of pending-6.6: p-6.6-3-g04810563abb71, Makefile 6.6.157.
- **[Phase 3]** git merge-base --is-ancestor 689db98e535bf pending-6.6 → not present.
- **[Phase 3]** Blame: reject condition a0a3ace2a5788 (in 6.6); nft_rt 2fa841938c648 (2016).
- **[Phase 3]** git show pending-6.6:include/net/dst_metadata.h:
skb_valid_dst() present.
- **[Phase 4]** b4 dig -c 689db98e535bf: lore 503, no match.
- **[Phase 4]** Openwall: net-next 8/9 and 0/9 cover; no NAK.
- **[Phase 4]** Syzbot CI series passed; not a syzbot bug report.
- **[Phase 4]** lore.kernel.org/stable: 403, UNVERIFIED.
- **[Phase 5]** Callers verified via git grep on pending-6.6:
ipt_REJECT, nft_reject_ipv4/inet; netdev reject uses nf_reject_skb_* (not this path).
- **[Phase 5]** nft_rt_validate / nft_xfrm_validate reject NFPROTO_NETDEV in both 6.6 and mainline.
- **[Phase 6]** Buggy !skb_dst() / raw skb_dst() still in pending-6.6 sources.
- **[Phase 6]** Context drift: dst_rtable and skb_dst_dev not used in 6.6 versions of those unchanged lines.
- **[Phase 7]** nf_tables + reject; important.
- **[Phase 8]** __icmp_send in 6.6 handles NULL dst->dev but still reads rt->rt_flags from a metadata object.
- **[Phase 8]** Metadata dst: dst_init(..., NULL, ...) + DST_METADATA + dst_blackhole_ops; xfrm == NULL.
- **UNVERIFIED:** full lore review replies (503); stable@ archive (403).
**YES**
net/ipv4/netfilter/nf_reject_ipv4.c | 6 ++++-- net/ipv6/netfilter/nf_reject_ipv6.c | 8 ++++++-- net/netfilter/nft_meta.c | 6 ++++-- net/netfilter/nft_rt.c | 6 ++++-- net/netfilter/nft_xfrm.c | 9 ++++++++- 5 files changed, 26 insertions(+), 9 deletions(-)
net/ipv4/netfilter/nf_reject_ipv4.c +4 -2
@@ -8,6 +8,7 @@#include <net/tcp.h> #include <net/route.h> #include <net/dst.h> +#include <net/dst_metadata.h> #include <net/netfilter/ipv4/nf_reject.h> #include <linux/netfilter_ipv4.h> #include <linux/netfilter_bridge.h>
@@ -263,6 +264,7 @@ static int nf_reject_fill_skb_dst(struct sk_buff *skb_in)if (!dst)return -1 ; +skb_dst_drop (skb_in);skb_dst_set (skb_in, dst);return 0 ; }
@@ -279,7 +281,7 @@ void nf_send_reset(struct net *net, struct sock *sk, struct sk_buff *oldskb,if (!oth)return ; -if (!skb_dst (oldskb) &&nf_reject_fill_skb_dst (oldskb) <0 ) +if (!skb_valid_dst (oldskb) &&nf_reject_fill_skb_dst (oldskb) <0 )return ;if (skb_rtable (oldskb)->rt_flags & (RTCF_BROADCAST |RTCF_MULTICAST ))
@@ -352,7 +354,7 @@ void nf_send_unreach(struct sk_buff *skb_in, int code, int hook)if (iph->frag_off &htons (IP_OFFSET ))return ; -if (!skb_dst (skb_in) &&nf_reject_fill_skb_dst (skb_in) <0 ) +if (!skb_valid_dst (skb_in) &&nf_reject_fill_skb_dst (skb_in) <0 )return ; if (skb_csum_unnecessary(skb_in) ||
net/ipv6/netfilter/nf_reject_ipv6.c +6 -2
@@ -8,6 +8,7 @@#include <net/ip6_route.h> #include <net/ip6_fib.h> #include <net/ip6_checksum.h> +#include <net/dst_metadata.h> #include <net/netfilter/ipv6/nf_reject.h> #include <linux/netfilter_ipv6.h> #include <linux/netfilter_bridge.h>
@@ -304,6 +305,7 @@ static int nf_reject6_fill_skb_dst(struct sk_buff *skb_in)if (!dst)return -1 ; +skb_dst_drop (skb_in);skb_dst_set (skb_in, dst);return 0 ; }
@@ -336,10 +338,12 @@ void nf_send_reset6(struct net *net, struct sock *sk, struct sk_buff *oldskb, fl6.fl6_sport = otcph->dest; fl6.fl6_dport = otcph->source; -if (!skb_dst (oldskb)) { +if (!skb_valid_dst (oldskb)) {nf_ip6_route (net, &dst,flowi6_to_flowi (&fl6), false);if (!dst)return ; + +skb_dst_drop (oldskb);skb_dst_set (oldskb, dst); }
@@ -440,7 +444,7 @@ void nf_send_unreach6(struct net *net, struct sk_buff *skb_in,if (hooknum ==NF_INET_LOCAL_OUT && skb_in->dev ==NULL ) skb_in->dev = net->loopback_dev; -if (!skb_dst (skb_in) &&nf_reject6_fill_skb_dst (skb_in) <0 ) +if (!skb_valid_dst (skb_in) &&nf_reject6_fill_skb_dst (skb_in) <0 )return ;icmpv6_send (skb_in,ICMPV6_DEST_UNREACH , code,0 );
net/netfilter/nft_meta.c +4 -2
@@ -20,6 +20,7 @@#include <net/dst.h> #include <net/ip.h> #include <net/sock.h> +#include <net/dst_metadata.h> #include <net/tcp_states.h> /* for TCP_TIME_WAIT */ #include <net/netfilter/nf_tables.h> #include <net/netfilter/nf_tables_core.h>
@@ -274,11 +275,12 @@ static bool nft_meta_get_eval_ifname(enum nft_meta_keys key, u32 *dest, static noinline boolnft_meta_get_eval_rtclassid (const struct sk_buff *skb,u32 *dest) { -const struct dst_entry *dst =skb_dst (skb); +const struct dst_entry *dst; -if (!dst) +if (!skb_valid_dst (skb))return false; + dst =skb_dst (skb); *dest = dst->tclassid;return true; }
net/netfilter/nft_rt.c +4 -2
@@ -8,6 +8,7 @@#include <linux/netfilter.h> #include <linux/netfilter/nf_tables.h> #include <net/dst.h> +#include <net/dst_metadata.h> #include <net/ip6_route.h> #include <net/route.h> #include <net/netfilter/nf_tables.h>
@@ -59,10 +60,11 @@ void nft_rt_get_eval(const struct nft_expr *expr,u32 *dest = ®s->data[priv->dreg];const struct dst_entry *dst; - dst =skb_dst (skb); -if (!dst) +if (!skb_valid_dst (skb)) goto err; + dst =skb_dst (skb); +switch (priv->key) {#ifdef CONFIG_IP_ROUTE_CLASSID case NFT_RT_CLASSID :
net/netfilter/nft_xfrm.c +8 -1
@@ -12,6 +12,7 @@#include <linux/netfilter/nf_tables.h> #include <net/netfilter/nf_tables_core.h> #include <net/netfilter/nf_tables.h> +#include <net/dst_metadata.h> #include <linux/in.h> #include <net/xfrm.h>
@@ -177,9 +178,15 @@ static void nft_xfrm_get_eval_out(const struct nft_xfrm *priv,struct nft_regs *regs, const struct nft_pktinfo *pkt) { - const struct dst_entry *dst = skb_dst(pkt->skb); + const struct dst_entry *dst;int i; +if (!skb_valid_dst (pkt->skb)) { + regs->verdict.code =NFT_BREAK ; +return ; + } + + dst =skb_dst (pkt->skb);for (i =0 ; dst && dst->xfrm; dst = ((const struct xfrm_dst *)dst)->child, i++) {if (i < priv->spnum)
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 crypto: sa2ul - use crypto_memneq() to compare AEAD tag
In reply to Sasha LevinFrom: "David C.C.M. Gall" <[email protected]>
[ Upstream commit 7064af16d2b418d61571dba9bb0116a547ade124 ]
Use crypto_memneq() for a constant-time comparison.
sa_aead_dma_in_callback() compares the computed authentication tag against the received tag with memcmp(), which short-circuits on the first differing byte. An attacker who can submit decrypt requests and observe completion latency could recover the expected tag byte by byte.
Valid tag forgery for AEAD breaks the INT-CTXT guarantee.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). The buggy memcmp() of the AEAD tag is present in sa_aead_dma_in_callback(), and this one- line constant-time swap should be backported here.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[crypto: sa2ul]** **[use]** use crypto_memneq() to compare AEAD tag. Subsystem is the TI K3 SA2UL hardware crypto driver. The verb is “use” with an explicit constant-time replacement; the body describes a timing leak.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected for this review pipeline)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** none
- **Acked-by:** none
- **Link:** none in the commit; lore found via b4 dig
- **Cc: stable:** none (expected)
- **Assisted-by:** gregkh_clanker_t1000 (tool-assisted; not a quality tag)
- **Signed-off-by:** David C.C.M. Gall (author); Herbert Xu (crypto maintainer)
- Ignore any pipeline “Upstream commit” / Sasha Levin SOB if present — they are not a selection signal
Notable: crypto maintainer SOB after applying v1 unchanged. No syzbot, no multi-user reports.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** sa_aead_dma_in_callback() compares the computed AEAD authentication tag to the received tag with memcmp(), which returns on the first mismatched byte.
- **Symptom / failure mode:** An attacker who can submit decrypts and observe completion latency can recover the expected tag byte-by-byte (timing side channel).
- **Consequence:** Valid tag forgery breaks AEAD **INT-CTXT** (integrity of ciphertext).
- **Version info:** none in the message.
- **Root cause:** non-constant-time tag compare on the AEAD decrypt completion path.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a hidden fix. This is an explicit crypto-security (timing) fix, same class as historical crypto_memneq() ICV/tag conversions.
---
## PHASE 2: DIFF ANALYSIS - LINE BY LINE
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/crypto/sa2ul.c — **+2 / −1** (net +1, 3-line change)
- Functions: include block; sa_aead_dma_in_callback()
- Scope: **single-file surgical fix**
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Hunk 1 (include):** add #include <crypto/utils.h> so crypto_memneq() is declared. include/crypto/utils.h exists in this tree; crypto/internal/aead.h already pulls crypto/algapi.h → crypto/utils.h, so the include is explicit but not a functional dependency.
- **Hunk 2 (decrypt completion):** on decrypt (!rxd->enc), after copying the received tag, replace
err = memcmp(&mdptr[4], auth_tag, authsize) ? -EBADMSG : 0 with
err = crypto_memneq(&mdptr[4], auth_tag, authsize) ? -EBADMSG : 0.
- Encrypt path is unchanged (it writes the tag out). Error/free/aead_request_complete() are unchanged.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** memory-safety / crypto correctness — **timing side channel** on AEAD tag compare (not UAF/leak/lock).
- **Mechanism:** memcmp() short-circuits; crypto_memneq() is documented as comparing without leaking timing (include/crypto/utils.h). Same boolean sense: 0 = equal, nonzero = not equal, so -EBADMSG vs 0 is preserved.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: drop-in replacement used throughout the crypto stack and other HW AEAD drivers (talitos, atmel-aes, nx, ccp, etc.).
- Minimal; no API/struct/locking changes.
- Regression risk: **very low**. Slightly more work per decrypt (constant-time over authsize, typically 12–32 bytes) is negligible vs DMA/IRQ.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Buggy memcmp() introduced in **d2c8ac187fc92** (“crypto: sa2ul - Add AEAD algorithm support”, Keerthy, 2020-07-23).
- Present since **v5.9-era** driver addition; in this 6.12 tree (git merge-base --is-ancestor d2c8ac187fc92 HEAD succeeded).
- Blame on the callback still shows that 2020 origin for the compare.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The introducing commit is d2c8ac187fc92, and it **is** in this tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent sa2ul.c work here is unrelated (probe pool failure, fallback names, MODULE_DESCRIPTION, setkey errors). No prerequisite refactor of the tag compare. Standalone.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Author is not the subsystem maintainer. Same-day sibling patches on origin/master: keembay CCM/GCM crypto_memneq() conversions (353b3a85136f2, ff2ac77a034e0). Herbert Xu applied this series. Historical precedent in **this** tree: 79960943fdc11 (talitos) and cb8affb55c7e6 (nx) — same bug class, both **Cc: stable**.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. crypto_memneq() lives in lib/crypto/memneq.c (CRYPTO_LIB_UTILS, selected by CRYPTO). Driver already select CRYPTO_ALGAPI. Patch applies standalone. git show 7064af16d2b41 | git apply --check **exit 0** on this tree. Commit **not** already an ancestor of HEAD.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 7064af16d2b418d61571dba9bb0116a547ade124 →
https://patch.msgid.link/anX9UKJ66Aak4ICV@fudgebox
- **v1 only** (b4 dig -a); committed version is v1.
- Thread: author submission (2026-08-07); Herbert Xu “Patch applied. Thanks.” (2026-08-15). **No NAK, no review risk comments, no Cc:
stable suggestion.**
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc Herbert Xu, David S. Miller, linux-crypto, linux-kernel, [email protected]. Subsystem maintainer applied it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by / Link / bugzilla / syzbot. Bug is from code review of the memcmp() decrypt path, not a field crash.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Same author, same day: keembay GCM/CCM crypto_memneq() patches. This sa2ul patch is self-contained; keembay is a different driver and is **not** a prerequisite. keembay is also not in this 6.12 tree.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** — lore.kernel.org/stable returned an Anubis bot challenge (HTTP 403 / JS gate). Original linux-crypto thread had no stable discussion.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: sa_aead_dma_in_callback(); crypto_memneq() (callee).
**Step 5.2: TRACE CALLERS**
Record:
- Callback assigned in sa_aead_run() (sa_req.callback = sa_aead_dma_in_callback).
- sa_aead_run() called from sa_aead_encrypt() / sa_aead_decrypt().
- Those are .encrypt / .decrypt for authenc(hmac(sha1),cbc(aes))-sa2ul and authenc(hmac(sha256),cbc(aes))-sa2ul (priority **3000**).
- Completes in DMA RX callback context, then aead_request_complete().
**Step 5.3: TRACE CALLEES**
Record: sa_sync_from_device, dmaengine_desc_get_metadata_ptr, scatterwalk_map_and_copy, sa_free_sa_rx_data, aead_request_complete. After the change, decrypt also calls crypto_memneq(). No new locks or allocations.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable from the kernel crypto AEAD API. Algorithms have CRYPTO_ALG_KERN_DRIVER_ONLY but **not** CRYPTO_ALG_INTERNAL. KERN_DRIVER_ONLY means “HW offload, not a CPU ISA helper” (include/linux/crypto.h); AF_ALG even allows that bit in salg_feat/salg_mask. Userspace **can** bind these algs when CRYPTO_USER_API_AEAD is enabled. Kernel users (e.g. IPsec ESP with authenc) can also select this high-priority driver.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same memcmp→crypto_memneq tag/ICV pattern already used in drivers/crypto/talitos.c, atmel-aes.c, nx-aes-gcm.c, nx-aes- ccm.c, ccp-ops.c, etc. Remaining memcmp of auth material in this
tree: drivers/crypto/qce/aead.c (different driver). sa2ul had the last such compare in this file.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** drivers/crypto/sa2ul.c line 1722:
err = memcmp(&mdptr[4], auth_tag, authsize) ? -EBADMSG : 0;
Introduced 2020 (d2c8ac187fc92); still here. Tree is 6.12.111. Upstream fix 7064af16d2b41 is **not** an ancestor of HEAD.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** (git apply --check succeeded). Include site and callback context match origin. include/crypto/utils.h exists (moved in c616fb0cbae8a, long before 6.12).
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No crypto_memneq sa2ul commit in this tree. No alternate tag- compare fix. nx/talitos timing-leak fixes are already present; they do not cover sa2ul.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **drivers/crypto/sa2ul.c** — TI K3 Security Accelerator. **IMPORTANT** for those platforms (crypto offload used by IPsec/VPN/etc.), **not CORE**. CONFIG_CRYPTO_DEV_SA2UL depends on ARCH_K3 || COMPILE_TEST; **CONFIG_CRYPTO_DEV_SA2UL=m is in arch/arm64/configs/defconfig**.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature driver (added 2020). Modest ongoing fixes in 6.12. This is a long-standing compare bug, not a regression from recent refactor.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / platform-specific:** TI K3 SoCs (AM62/AM64/AM65, J721e, etc.) with SA2UL AEAD offload enabled. Not universal.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Trigger is **every hardware AEAD decrypt** that takes the non- fallback path (sa_aead_dma_in_callback decrypt branch). Userspace can hit it via AF_ALG if user-API AEAD is enabled; kernel IPsec/authenc can hit it without userspace crypto. Timing exploitation needs many decrypts plus latency observation — classic, not a one-shot crash. Unprivileged trigger is possible where AF_ALG AEAD is exposed.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- **Failure mode:** timing leak of the expected authentication tag → theoretical **tag forgery**, breaking AEAD integrity.
- **Severity: HIGH** (crypto integrity / security). Not a panic/UAF. DMA/IRQ noise makes a practical oracle harder than a userspace memcmp of a hot buffer, but the kernel crypto API treats non- constant-time ICV checks as real bugs (talitos/nx were Cc: stable for the same reason). crypto_memneq() exists specifically for this.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** closes a known AEAD INT-CTXT hole on a defconfig-enabled ARM64 HW driver; matches established crypto policy.
- **Risk:** very low (one compare + include; return-value polarity matches).
- **Ratio:** benefit > risk for this stable tree.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real AEAD tag compare uses variable-time memcmp() on decrypt complete.
- Breaks INT-CTXT if exploited; same class previously backported (talitos, nx) with Cc: stable.
- Buggy code has been in this file since 2020 and is in 6.12.111.
- 3-line, obviously correct, applies cleanly; crypto_memneq() already in this tree.
- Crypto maintainer applied v1 with no objections.
- Driver is in arm64 defconfig; path is a real decrypt completion, not dead code.
**AGAINST:**
- No user report / CVE / syzbot.
- Practical timing through DMA+IRQ is noisy (harder oracle than a tight userspace loop).
- Affects TI K3 SA2UL users, not all 6.12 systems.
- No explicit Cc: stable (not a negative per the review rules).
**UNRESOLVED:**
- Whether this SHA was already discussed on stable@ (lore blocked).
- No measured exploit against sa2ul specifically.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — drop-in crypto_memneq(); maintainer applied; API used kernel-wide.
2. Fixes a real bug that affects users? **PASS** — non-constant-time AEAD tag verify on HW decrypt.
3. Important issue (crash, security, corruption, deadlock)? **PASS** — security (AEAD integrity / timing). Severity HIGH, not a panic.
4. Small and contained? **PASS** — 3 lines, one file, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — clean apply; helpers present.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID / quirk / DT / build / docs exception. Qualifies as a **small security correctness fix**.
**Step 9.4: MAKE YOUR DECISION**
This is a surgical, low-risk fix for a real AEAD tag timing leak in code that exists in 6.12.111. Stable policy has historically taken this exact class of change. Backport to this tree.
---
### What the commit solves for stable users
On TI K3 boards using SA2UL AEAD offload, decrypt completion compared the computed MAC to the packet tag with memcmp(). That can leak how many leading tag bytes matched via completion latency and, in the standard model, enable tag forgery (INT-CTXT failure). Replacing it with crypto_memneq() makes the compare constant-time without changing success/failure semantics.
### Stable rules / risk vs benefit
Meets all six criteria: small, obviously correct, no new API, applies cleanly here, fixes a crypto-integrity bug. Risk is essentially the cost of a 16–32 byte constant-time XOR loop. Benefit is aligning this long- lived driver with the rest of the crypto stack.
### Concerns
None that block backport: no missing prereqs, no follow-up that rewrote the callback, include header already in 6.12. Practical exploitability is not proven in the field; that does not make the compare correct.
---
Verification:
- [Phase 1] Parsed subject/tags/body from git show 7064af16d2b41; no Fixes/Reported-by/Cc: stable; SOB Herbert Xu; Assisted-by gregkh_clanker_t1000
- [Phase 2] Diff: drivers/crypto/sa2ul.c +2/−1; include crypto/utils.h; memcmp → crypto_memneq in sa_aead_dma_in_callback decrypt branch
- [Phase 2] Confirmed crypto_memneq returns 0 if equal, 1 otherwise (include/crypto/utils.h lines 56–70) — same ternary as memcmp
- [Phase 3] git describe HEAD / Makefile: **6.12.111**, branch pending-6.12
- [Phase 3] git merge-base --is-ancestor 7064af16d2b41 HEAD → not ancestor; d2c8ac187fc92 **is** ancestor
- [Phase 3] git log origin/master -S 'memcmp(&mdptr[4]' -- drivers/crypto/sa2ul.c → intro d2c8ac187fc92, fix 7064af16d2b41
- [Phase 3] Blame on local callback: memcmp path from 2020 AEAD add
- [Phase 3] Same-class stable precedent in this tree: 79960943fdc11 (talitos), cb8affb55c7e6 (nx), both Cc: stable
- [Phase 3] git apply --check of 7064af16d2b41 → success
- [Phase 4] b4 dig -c/-a/-w/-m: lore
https://patch.msgid.link/anX9UKJ66Aak4ICV@fudgebox ; v1 only; Herbert “Patch applied”; To linux-crypto + Herbert
- [Phase 4] WebFetch lore 403; stable@ search blocked by Anubis — UNVERIFIED for stable-list history
- [Phase 5] Callers: sa_aead_run ← sa_aead_encrypt/sa_aead_decrypt; algs authenc(hmac(sha1|sha256),cbc(aes))-sa2ul
- [Phase 5] CRYPTO_ALG_KERN_DRIVER_ONLY is not CRYPTO_ALG_INTERNAL; AF_ALG allows that flag (crypto/af_alg.c)
- [Phase 5] Other drivers already use crypto_memneq for AEAD tags under drivers/crypto/
- [Phase 6] Local line 1722 still memcmp; include/crypto/utils.h present; CRYPTO selects CRYPTO_LIB_UTILS; lib/crypto/memneq.c exports __crypto_memneq
- [Phase 6] arch/arm64/configs/defconfig has CONFIG_CRYPTO_DEV_SA2UL=m
- [Phase 7] Driver added 2020 (7694b6ca649fe); Kconfig CRYPTO_DEV_SA2UL depends on ARCH_K3
- [Phase 8] Failure mode: AEAD tag timing leak / INT-CTXT, severity HIGH; apply risk very low
- UNVERIFIED: stable@ mailing list discussion; real-world exploit of this specific DMA-callback timing channel
**YES**
drivers/crypto/sa2ul.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/sa2ul.c +2 -1
@@ -22,6 +22,7 @@#include <crypto/aes.h> #include <crypto/authenc.h> +#include <crypto/utils.h> #include <crypto/des.h> #include <crypto/internal/aead.h> #include <crypto/internal/hash.h>
@@ -1688,7 +1689,7 @@ static void sa_aead_dma_in_callback(void *data)scatterwalk_map_and_copy (auth_tag, req->src, start, authsize,0 ); - err =memcmp (&mdptr[4 ], auth_tag, authsize) ? -EBADMSG :0 ; + err =crypto_memneq (&mdptr[4 ], auth_tag, authsize) ? -EBADMSG :0 ; }sa_free_sa_rx_data (rxd);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: iwlwifi: validate UEFI reduced-power SKU TLV length
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit f051995c539582b05276abda4c5874fd4cafd2a5 ]
iwl_uefi_reduce_power_parse() reads an iwl_sku_id from an IWL_UCODE_TLV_PNVM_SKU payload after only checking that the generic TLV payload is present.
A short type-specific payload can therefore make the three data[] reads extend beyond the TLV. Reject SKU TLVs shorter than the structure before accessing it.
---
LLM Generated explanations, may be completely bogus:
This checkout is **v7.3-rc4** (mainline 7.3.0-rc4). The analysis below is only for this tree.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[iwlwifi / wifi]** **[validate]** — reject a UEFI reduced- power IWL_UCODE_TLV_PNVM_SKU payload shorter than struct iwl_sku_id before reading it. “Validate” here is a bounds check, not a feature add.
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- **Fixes:** none (expected for this review path)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** none on the commit; v1 was reviewed on-list by the iwlwifi maintainer
- **Acked-by:** none
- **Link:** https://patch.msgid.link/[email protected]
- **Cc: stable:** none (expected)
- **Signed-off-by:** Pengpeng Hou (author); Miri Korenblit (iwlwifi maintainer, applied it)
- Ignore pipeline SOBs. Pattern: two-patch series (24417-1 PNVM parser, 24417-2 this UEFI parser); no syzbot.
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** iwl_uefi_reduce_power_parse() treats a PNVM SKU TLV as struct iwl_sku_id after only checking that the generic TLV payload fits in the remaining buffer.
- **Symptom:** three data[] reads can extend past the TLV; if remaining bytes after the header are also < 12, that is a real out- of-bounds read of the UEFI blob.
- **Version info:** none in the message.
- **Root cause:** missing type-specific minimum length vs sizeof(struct iwl_sku_id) (__le32 data[3], 12 bytes).
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not disguised. It is an explicit length check before the three SKU word reads.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- **File:** drivers/net/wireless/intel/iwlwifi/fw/uefi.c — **+6 / −0**
- **Function:** iwl_uefi_reduce_power_parse()
- **Scope:** single-file surgical fix
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- **Before:** loop requires len >= sizeof(*tlv) (8-byte header). After subtracting the header it checks len < tlv_len (payload vs remaining buffer), then on IWL_UCODE_TLV_PNVM_SKU casts the payload to struct iwl_sku_id and reads data[0..2] even if tlv_len is 0–11.
- **After:** if tlv_len < sizeof(*tlv_sku_id) log and return -EINVAL before those reads.
- **Path:** firmware/UEFI parse during Intel WiFi PNVM/reduce-power load, not a hot datapath.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record: **Memory safety / out-of-bounds read.** Outer check only proves the claimed TLV payload is inside the remaining buffer, not that it is 12 bytes. If tlv_len=4 and remaining len=8, 8 < 4 is false, then 12 bytes are read from an 8-byte remainder → **allocation OOB**. If remaining len >= 12 but tlv_len < 12, the reads stay in the allocation but past this TLV.
Step 2.4: ASSESS THE FIX QUALITY
Record: Obviously correct and minimal (same pattern as the sibling PNVM check). Regression risk is low: a too-short SKU TLV cannot be used anyway; -EINVAL makes iwl_pnvm_load_reduce_power_to_trans() set failed_to_load_reduce_power_image and skip the table. No API or lock changes.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record: The parser dates to **9dad325f9d575** (“iwlwifi: support loading the reduced power table from UEFI”, 2021-06-21), first in **v5.14-rc1**. SKU access was later adjusted by **3a68ae0fa2ec13** (“wifi: iwlwifi:
remove sku_id from trans”, 2025-05-04). The six new lines are this commit (**f051995c53958**, 2026-07-15). The missing min-length check has been there since the parser was added.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Introduction commit **9dad325f9d575** is an ancestor of this HEAD. No intermediate SKU-length check on this function before this patch.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: Immediate parent is sibling **7410e4548a17b** (“wifi: iwlwifi:
validate PNVM SKU TLV length”) — same author, same date, same check in iwl_pnvm_parse(). Independent; this UEFI patch does not need that hunk. Nearby **daec24a5ed5da** is a different length check in iwl_pnvm_complete_fn(). Standalone as a 2/2 series member.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Pengpeng Hou has these two iwlwifi validation commits in this tree. Applied by **Miri Korenblit**, listed iwlwifi maintainer in MAINTAINERS.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: Uses existing tlv_sku_id, tlv_len, IWL_ERR, -EINVAL. No new helpers. Can apply standalone wherever iwl_uefi_reduce_power_parse() still has this loop.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- **v2 (applied):**
https://patch.msgid.link/[email protected]
- **v1:** 2026-06-30,
https://lore.kernel.org/all/2026063008051412.5-ccfa108-0020-wifi-
[email protected]/
- v1 used tlv_len < 3 * sizeof(__le32); Miri asked for sizeof(*tlv_sku_id); v2 did that. No NAK. b4 mbox for v2 is the patch only (no further replies).
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: To/Cc: Miri Korenblit, linux-wireless, linux-kernel. Maintainer reviewed v1 and applied v2.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot, bugzilla, or user crash report. Author-found parser hole. Syzbot CI on v2: KASAN build/boot passed; fuzz skipped.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Pair with **7410e4548a17b** (24417-1, iwl_pnvm_parse()). Same bug class, different file. This patch does not depend on that one.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: No stable-list discussion found for this subject. Absence of Cc: stable is expected here.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: iwl_uefi_reduce_power_parse() only.
Step 5.2: TRACE CALLERS
Record:
- Declared in fw/uefi.h under #ifdef CONFIG_EFI (stub -EOPNOTSUPP otherwise).
- Only caller: iwl_pnvm_load_reduce_power_to_trans() in fw/pnvm.c.
- That is called from iwl_pnvm_load(), exported and used from mvm/fw.c and mld/fw.c during firmware/PNVM init.
- Not IRQ; process context during WiFi bring-up.
Step 5.3: TRACE CALLEES
Record: Reads UEFI blob from iwl_uefi_get_reduced_power() → iwl_uefi_get_verified_variable() (kmalloc/kmemdup of EFI var). On SKU match, iwl_uefi_reduce_power_section(). Fix only adds a length check and error return.
Step 5.4: FOLLOW THE CALL CHAIN
Record: Device probe / firmware start → iwl_pnvm_load() → reduce-power UEFI parse. Not a syscall parser. Trigger needs Intel iwlwifi, CONFIG_EFI, runtime EFI GetVariable, and a Reduced Power variable with a short PNVM_SKU TLV. Unprivileged userspace cannot normally forge that; root/firmware can. Still a kernel OOB on bad firmware/BIOS data.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Identical hole and fix in iwl_pnvm_parse() (pnvm.c lines 208–212 in this tree). Same systematic miss.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. iwl_uefi_reduce_power_parse() is in uefi.c from v5.14. This tree is **v7.3-rc4**; the fix itself is already an ancestor (git merge-base --is-ancestor f051995c53958 HEAD succeeded) and first appeared in **v7.3-rc1**. The parser and the OOB path exist in this lineage.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **Clean apply** on this tree’s pre-image (original commit). Context is the long-standing TLV loop; no local conflicts.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: This is the fix. Sibling PNVM check is also here. No earlier substitute for the UEFI parser.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: **iwlwifi** (drivers/net/wireless/intel/iwlwifi/). **IMPORTANT** — common Intel WiFi driver, not core mm/VFS, not staging.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Actively developed (UEFI/PNVM/regulatory churn through 2026). The missing check is old (2021); this is hardening of mature parse logic, not a bug in brand-new code.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: **Driver-specific + config-specific:** Intel iwlwifi + CONFIG_EFI + platforms that expose the Reduced Power UEFI variable.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: WiFi firmware/PNVM load with a short IWL_UCODE_TLV_PNVM_SKU in that UEFI blob. Uncommon on good OEM tables; realistic with corrupt/malicious EFI data. Not a normal unprivileged syscall.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: Out-of-bounds **read** of up to ~12 bytes. Can KASAN/oops if the SKU TLV sits near the end of the kmemdup buffer; otherwise reads the next TLV and can mis-match SKU / skip reduce-power. **HIGH** for the true OOB case (crash on probe), not data corruption of user files.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit:** high for affected laptops/APs — avoids OOB during WiFi init on bad UEFI data; check is cheap.
- **Risk:** very low — 6 lines, error path only, maintainer-acked form.
- **Ratio:** favorable.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
**For:**
- Real type-specific length hole; OOB read of iwl_sku_id (12 bytes) is visible in the code.
- Six-line, obviously correct check; v2 matches maintainer review (sizeof(*tlv_sku_id)).
- iwlwifi maintainer applied it; same fix already used in iwl_pnvm_parse().
- Parser present since v5.14; this tree has it.
- Applies cleanly; no new API; no extra dependency for *this* hunk.
**Against:**
- No user/syzbot report; trigger is malformed UEFI, not a common syscall.
- Reduce-power table is not the data path; failed parse already degrades to skipping the image.
- CONFIG_EFI only.
**Unresolved:** lore.kernel.org HTML fetch returned 403; discussion recovered via b4 mbox, msgid.link, and LKML mirrors. No stable-list thread found.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — size check before data[0..2]; v2 from maintainer review; in iwlwifi-next then mainline.
2. Fixes a real bug that affects users? **PASS** — OOB read of a kernel buffer parsed at WiFi init.
3. Important issue? **PASS** — OOB can oops; severity HIGH, not LOW cosmetics.
4. Small and contained? **PASS** — +6 lines, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — this tree already contains the original commit; pre-image matches.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Not a device-ID/quirk/DT/docs exception. Ordinary memory-safety fix.
Step 9.4: MAKE YOUR DECISION
This tree’s iwlwifi UEFI reduce-power parser has the hole; the patch is a small, reviewed bounds check that prevents a real OOB read. That meets stable rules for **this** checkout.
What it solves for this tree: iwl_uefi_reduce_power_parse() can read 12 bytes from a PNVM SKU TLV whose declared length is shorter, and can walk off the UEFI blob when remaining length is also < 12. That matters on Intel WiFi + EFI machines with a bad Reduced Power variable (crash/KASAN on init). The change is six lines, no new ABI, no extra commits required, and the sibling PNVM check is independent.
Risk vs benefit: very low regression risk vs preventing an OOB on a widely used driver. Main caveat is the uncommon trigger; that does not make the hole theoretical in the code.
Verification:
- [Phase 1] Subject/body/tags: validate SKU TLV length; SOB Hou + Korenblit; Link 24417-2; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: +6 in iwl_uefi_reduce_power_parse(); if (tlv_len < sizeof(*tlv_sku_id)) return -EINVAL
- [Phase 2] struct iwl_sku_id is __le32 data[3] in fw/api/alive.h; iwl_ucode_tlv is 8-byte header + data[] in fw/file.h
- [Phase 3] git describe HEAD / Makefile: v7.3-rc4 / 7.3.0-rc4
- [Phase 3] git merge-base --is-ancestor f051995c53958 HEAD → yes
- [Phase 3] Blame: parser from 9dad325f9d575 (v5.14-rc1); fix lines from f051995c53958 (v7.3-rc1)
- [Phase 3] Sibling 7410e4548a17b is patch 1/2 on pnvm.c, not a apply- prereq
- [Phase 4] b4 dig -c f051995c53958: v1 2026-06-30, v2 2026-07-15; mbox is the patch
- [Phase 4] LKML mirror: Miri “Please use sizeof(*tlv_sku_id)”; no NAK
- [Phase 4] Stable lore search: no discussion of this subject
- [Phase 5] Only caller iwl_pnvm_load_reduce_power_to_trans ← iwl_pnvm_load ← mvm/mld fw init; gated on CONFIG_EFI
- [Phase 5] Buffer from iwl_uefi_get_reduced_power / verified EFI variable (kmalloc then kmemdup)
- [Phase 6] Buggy parser present; fix already in this tree; would apply cleanly
- [Phase 7] iwlwifi, maintainer Miri Korenblit
- [Phase 8] Failure: OOB read / possible oops on WiFi init; HIGH; trigger EFI-malformed
- UNVERIFIED: lore.kernel.org HTTP 403 on direct thread fetch; content recovered from b4 and LKML mirrors
**YES**
drivers/net/wireless/intel/iwlwifi/fw/uefi.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/intel/iwlwifi/fw/uefi.c +6 -0
@@ -248,6 +248,12 @@ int iwl_uefi_reduce_power_parse(struct iwl_trans *trans,IWL_DEBUG_FW (trans,"Got IWL_UCODE_TLV_PNVM_SKU len %d\n" , tlv_len); +if (tlv_len <sizeof (*tlv_sku_id)) { +IWL_ERR (trans,"invalid PNVM SKU TLV len: %u\n" , + tlv_len); +return -EINVAL ; + } + IWL_DEBUG_FW(trans, "sku_id 0x%0x 0x%0x 0x%0x\n", le32_to_cpu(tlv_sku_id->data[0]), le32_to_cpu(tlv_sku_id->data[1]),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: iwlwifi: mld: validate wake packet crypto overhead
In reply to Sasha LevinFrom: Emmanuel Grumbach <[email protected]>
[ Upstream commit c5cb9dd220ba9fdcf4ba485ce3d1d36ca32ac00b ]
Wake packet parsing only accounted for FCS and missed per-key IV/ICV overhead for protected data frames.
Prevent size underflow and bad packet trimming when notifications are malformed or truncated.
---
LLM Generated explanations, may be completely bogus:
The local checkout is **Linux 7.3.0-rc4**. The iwlwifi MLD WoWLAN path is present here, and this commit is a real memory-safety plus wake- packet correctness fix for that path.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[iwlwifi/mld]** **[validate]** — account for per-key IV/ICV when parsing WoWLAN wake packets, and reject truncated/malformed sizes.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Emmanuel Grumbach <[email protected]> (author; long-time iwlwifi developer)
- `Link: https://patch.msgid.link/20260717172958.e06595623533.Ie09494b7e
34e5872b750fd90e325648ee469d0da@changeid`
- Signed-off-by: Miri Korenblit <[email protected]> (iwlwifi maintainer, committer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, or Cc: stable (absence of Fixes/Cc:stable is expected for this review)
- No syzbot / KASAN / user crash tags
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** wake-packet parsing only subtracted FCS (4 bytes). It did not add the PTK/GTK IV and ICV lengths for protected data frames.
- **Symptom:** size underflow and incorrect trimming when the firmware wake-packet notification is malformed or truncated; userspace can get a bad or missing wakeup packet.
- **Version info:** none in the message. Code was introduced with iwlmld (d1e879ec600f9, v6.15).
- **Root cause (author):** missing per-key crypto overhead in iwl_mld_set_wake_packet().
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. It is an explicit validation/correctness fix. “Validate” plus “prevent size underflow” is a memory-safety fix, not a cleanup.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/net/wireless/intel/iwlwifi/mld/d3.c — **+57 / −6**
- New: struct iwl_mld_wake_pkt_iter_data, iwl_mld_wake_pkt_key_iter()
- Modified: iwl_mld_set_wake_packet()
- Scope: **single-file surgical fix** in the MLD D3/WoWLAN resume path
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
1. **Header size:** previously cast wake_packet to ieee80211_hdr with no length check. Now IWL_FW_CHECK if pkt_bufsize < sizeof(*hdr) and return.
2. **Protected data frames:** previously ivlen = 0, icvlen = 4 (FCS only). Now, if ieee80211_has_protected(), iterate keys and add key->iv_len / key->icv_len.
3. **Before skb_put_data:** new check pkt_bufsize <= hdrlen + ivlen + icvlen; skip copy if the buffer is too small.
4. **Non-data frames:** new check pkt_bufsize <= fcslen before subtracting FCS.
5. **Types:** pkt_bufsize / expected_pktlen / truncated changed from int to u32 so underflow cannot go negative and then be passed as a huge unsigned int length.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Memory safety (OOB / integer underflow) + logic/correctness**
Before, skb_put_data() takes unsigned int len. A signed pkt_bufsize that goes negative after pkt_bufsize -= hdrlen or -= ivlen + icvlen becomes a huge copy. skb_put() panics if hdrlen exceeds the skb tailroom (alloc_skb(pkt_bufsize) then skb_put_data(..., hdrlen)). Unchecked hdr->frame_control is an OOB read if the firmware buffer is shorter than an 802.11 header.
Missing IV/ICV on protected frames (the common WPA2/WPA3 case) also mis- trims the packet: ieee80211_data_to_8023() can fail, or userspace gets a corrupted wake packet.
The fix matches the long-standing MVM path in drivers/net/wireless/intel/iwlwifi/mvm/d3.c (IV/ICV from PTK vs GTK, plus IWL_FW_CHECK on size). MLD uses ieee80211_iter_keys() because it does not cache gtk_ivlen/ptk_ivlen like MVM.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: **Obviously correct, minimal, low regression risk.** It copies proven MVM logic. ieee80211_iter_keys() requires the wiphy mutex; iwl_mld_wowlan_resume() already has lockdep_assert_wiphy(), and the same resume path already calls ieee80211_iter_keys() in iwl_mld_update_sec_keys(). If no matching key is found, ivlen stays 0 and icvlen stays 4 — same as the old path. Early return after alloc_skb still sets *_pkt, and the caller kfree_skb()s it. No public API change.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record: Buggy iwl_mld_set_wake_packet() came in **d1e879ec600f9** (“wifi: iwlwifi: add iwlmld sub-driver”, 2025-02-16). Present since **v6.15**. Not recent one-off code.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Introduction commit is d1e879ec600f9. git merge-base --is-ancestor d1e879ec600f9 HEAD succeeds. Related later fix in the same file: c5aeb11489150 (“fix read in wake packet notification handler”) is an **ancestor** of this commit and is independent (it only reorders a length check in iwl_mld_handle_wake_pkt_notif()).
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Nearby D3 validation commits (validate WoWLAN notif header, validate D3_END notif size) are separate. This patch is **1/8** of an iwlwifi-next “updates” series; the other seven patches are unrelated (scan-abort init, time-sync, BIOS move, MCC v2, etc.). **Standalone.**
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Emmanuel Grumbach is a core iwlwifi author. Same week he also fixed MVM D3 FCS truncation (9119aeeddc210). Miri Korenblit committed the patch. Strong maintainer provenance.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs existing IWL_FW_CHECK, ieee80211_iter_keys(), and iwl_mld_set_wake_packet(). All exist in this tree. **Can apply standalone.**
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c c5cb9dd220ba9 → https://patch.msgid.link/20260717172958.e0
6595623533.Ie09494b7e34e5872b750fd90e325648ee469d0da@changeid
- b4 dig -a: **v1 only** ([PATCH iwlwifi-next 1/8])
- Cover: “A couple of fixes, features and cleanups.” This patch is one of the fixes.
- Saved mbox: **9 messages = cover + 8 patches, no review replies, no NAKs, no Cc: stable**
- HTTP lore fetch returned 403 (Anubis); discussion taken from the b4 mbox instead
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): Miri Korenblit, Johannes Berg ([email protected]), [email protected], Emmanuel Grumbach. Right lists/maintainers. Committed by Korenblit.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by: or bugzilla/syzbot link. Bug is described from code inspection, not a user crash.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Mixed 8-patch iwlwifi-next series. This hunk does not depend on 2/8–8/8. Related but independent: c5aeb11489150 (wake-pkt notif length), MVM D3 FCS fix 9119aeeddc210.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search returned **403**. **UNVERIFIED** whether stable@ already discussed this.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
Record: iwl_mld_wake_pkt_key_iter (new), iwl_mld_set_wake_packet (modified).
**Step 5.2: TRACE CALLERS**
Record:
- iwl_mld_set_wake_packet() ← iwl_mld_report_wowlan_wakeup() ← iwl_mld_process_wowlan_status() ← D3/WoWLAN resume
- Driver resume: iwl_mld_resume() → iwl_mld_wowlan_resume()
- mac80211: ieee80211_reconfig() → drv_resume() under lockdep_assert_wiphy()
- Context: process context on suspend/resume, not hardirq
**Step 5.3: TRACE CALLEES**
Record: ieee80211_iter_keys, ieee80211_hdrlen, ieee80211_has_protected, alloc_skb / skb_put_data, ieee80211_data_to_8023, IWL_FW_CHECK (log + boolean).
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable from userspace via WoWLAN (suspend with wowlan enabled, then a wake packet). Needs CONFIG_IWLMLD and CONFIG_PM_SLEEP (iwlmld-$(CONFIG_PM_SLEEP) += d3.o). Intel WiFi 7 / MLD hardware. Not a syscall fuzz path; **laptop suspend/resume**.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: MVM mvm/d3.c already applied IV/ICV + size check. MLD was a port that omitted that logic.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** Tree is v7.3-rc4-27-gf0100363d8c37 / 7.3.0-rc4. File drivers/net/wireless/intel/iwlwifi/mld/d3.c exists. Bug present from v6.15 (d1e879ec600f9) until this fix. git merge-base --is- ancestor d1e879ec600f9 HEAD is true. v7.2 has MLD but **not** this fix (c5cb9dd220ba9 is not an ancestor of v7.2).
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** on this tree. Surrounding iwl_mld_set_wake_packet() matches the parent hunk. IWL_FW_CHECK already used in this file.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: c5aeb11489150 is in HEAD (notif length). No alternate fix for IV/ICV in MLD set_wake_packet.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: **drivers/net/wireless/intel/iwlwifi/mld** — **IMPORTANT** (not core mm/fs, but a widely used Intel WiFi opmode for current silicon). WoWLAN is a production laptop path.
**Step 7.2: SUBSYSTEM ACTIVITY**
Record: **Active.** Many 2026 iwlwifi mld/mvm firmware-validation fixes. Mature enough that MVM already had this logic; MLD lagged.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Record: **Driver-specific / config-specific:** CONFIG_IWLMLD=y/m + CONFIG_PM_SLEEP, Intel MLD firmware devices, WoWLAN users.
**Step 8.2: TRIGGER CONDITIONS**
Record:
- Common functional bug: WoWLAN wakeup by a **protected data frame** (typical on WPA2/WPA3). Unprivileged users do not inject firmware notifications; they can suspend with wowlan.
- Memory-safety path: truncated/malformed WOWLAN_WAKE_PKT notification (buggy firmware or short DMA). Intel FW is signed, so this is robustness vs. firmware bugs, not a generic local exploit.
- How common: every encrypted wake-packet resume hits the IV/ICV miss; overflow needs a short/inconsistent notification.
**Step 8.3: FAILURE MODE SEVERITY**
Record:
- Short buffer + skb_put_data(hdrlen) → **skb over-panic / OOB** — **HIGH**
- Signed underflow into skb_put_data → **memory corruption** — **HIGH**
- Unchecked header parse → **OOB read** — **HIGH**
- Wrong/missing wakeup packet to cfg80211 — **MEDIUM** (userspace WoWLAN diagnostics)
**Step 8.4: RISK-BENEFIT RATIO**
Record: **Benefit: high** for Intel MLD WoWLAN (crash/corruption avoided, correct packet). **Risk: low** (one file, ~60 lines, same pattern as MVM, wiphy lock already held). Ratio favors backport.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real underflow/OOB in firmware wake-packet parsing (skb_put / memcpy)
- Protected-frame IV/ICV omitted since iwlmld was added (v6.15)
- Same logic already used and proven in MVM d3.c
- Small, one file, no new APIs
- Maintainer-authored and maintainer-committed
- Standalone (1/8 of a mixed series, no deps on the rest)
- Code exists in this 7.3-rc4 tree; IWL_FW_CHECK and ieee80211_iter_keys already used on this path
**AGAINST:**
- No user Reported-by / syzbot
- WoWLAN-only; overflow needs a bad/truncated notification
- ~57 lines, new helper (still contained)
- Cover letter mixed fixes with features (this patch itself is a fix)
**UNRESOLVED:**
- lore.kernel.org HTTP 403; no extra review mail beyond the b4 mbox
- Whether stable@ already discussed it
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — mirrors MVM; maintainer SOB; used IWL_FW_CHECK consistently
2. Fixes a real bug that affects users? **PASS** — wrong crypto stripping on encrypted wake packets; OOB on short buffers
3. Important issue? **PASS** — skb overflow / underflow is crash or memory corruption; HIGH
4. Small and contained? **PASS** — one file, +57/−6
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — file and helpers present, hunk matches
**Step 9.3: EXCEPTION CATEGORIES**
Record: None (not a device ID/quirk/DT/build/doc exception). Ordinary driver bugfix.
**Step 9.4: DECISION**
This tree has the buggy MLD D3 path. The patch is a small, correct fix for integer underflow and bad wake-packet trimming. It should be applied here.
---
### What the commit solves for users of this tree
On Intel MLD (WiFi 7) WoWLAN resume, iwl_mld_set_wake_packet() treated every data frame as having only a 4-byte FCS and never skipped 802.11 IV/ICV. Encrypted wake packets were mis-trimmed. Short or inconsistent firmware notifications could make pkt_bufsize go negative (int) and then be passed to skb_put_data(..., unsigned int), or skb_put more than alloc_skb reserved — kernel panic or memory corruption. The patch adds per-key IV/ICV (via ieee80211_iter_keys) and IWL_FW_CHECK size guards, matching MVM.
### Risk vs benefit
Low risk: one file, existing primitives, wiphy lock already asserted.
Benefit: avoid resume-path memory corruption and deliver a correct wakeup packet on encrypted networks.
### Concerns
No external reproducer; trigger for the overflow is a truncated FW notification. The IV/ICV miss still hits normal encrypted WoWLAN. No series dependency. Apply is clean on this tree.
---
### Verification
- **[Phase 1]** Parsed commit c5cb9dd220ba9: SOB Grumbach + Korenblit; Link msgid; no Fixes/Reported-by/Cc:stable
- **[Phase 2]** Diff: mld/d3.c +57/−6; new key iterator; size checks; int→u32; IV/ICV from key->iv_len/icv_len (u8 in ieee80211_key_conf)
- **[Phase 2]** Confirmed skb_put_data() uses unsigned int len and skb_put() (include/linux/skbuff.h)
- **[Phase 2]** Compared to mvm/d3.c ~1516–1555: same IV/ICV + IWL_FW_CHECK pattern
- **[Phase 3]** git blame on parent: buggy function from d1e879ec600f9 (2025-02-16)
- **[Phase 3]** git merge-base --is-ancestor d1e879ec600f9 HEAD true; c5cb9dd220ba9 not in v7.2; MLD present from v6.15
- **[Phase 3]** c5aeb11489150 is ancestor, independent notif-length fix
- **[Phase 4]** b4 dig -c/-a/-w/-m: v1 1/8 iwlwifi-next; recipients Korenblit/Berg/linux-wireless; mbox has no replies/NAKs
- **[Phase 4]** WebFetch/curl lore: 403 — UNVERIFIED extra review/stable@ mail
- **[Phase 5]** Call chain: ieee80211_reconfig → drv_resume → iwl_mld_wowlan_resume (lockdep_assert_wiphy) → iwl_mld_set_wake_packet
- **[Phase 5]** ieee80211_iter_keys docs: wiphy mutex; already used in iwl_mld_update_sec_keys()
- **[Phase 6]** git describe HEAD → v7.3-rc4-27-gf0100363d8c37; make kernelversion → 7.3.0-rc4; file present; d3.o behind CONFIG_PM_SLEEP
- **[Phase 7]** CONFIG_IWLMLD “Intel Wireless WiFi MLD Firmware support”
- **[Phase 8]** Failure mode verified from parent source: no pkt_bufsize < sizeof(*hdr) check; signed subtract then skb_put_data
**YES**
drivers/net/wireless/intel/iwlwifi/mld/d3.c | 63 +++++++++++++++++++-- 1 file changed, 57 insertions(+), 6 deletions(-)
drivers/net/wireless/intel/iwlwifi/mld/d3.c +57 -6
@@ -53,6 +53,30 @@ struct iwl_mld_suspend_key_iter_data {__le32 bigtk_cipher; }; +struct iwl_mld_wake_pkt_iter_data { +bool multicast; +u32 ivlen; +u32 icvlen; +}; + +static void +iwl_mld_wake_pkt_key_iter (struct ieee80211_hw *hw,struct ieee80211_vif *vif, +struct ieee80211_sta *sta, +struct ieee80211_key_conf *key,void *_data) +{ +struct iwl_mld_wake_pkt_iter_data *data = _data; +bool is_group_key = !sta; + +/* ignore anything that is not a PTK / GTK */ +if (key->keyidx >3 ) +return ; +if (is_group_key != data->multicast) +return ; + + data->ivlen = key->iv_len; + data->icvlen = key->icv_len; +} +struct iwl_mld_mcast_key_data {u8 key[WOWLAN_KEY_MAX_SIZE ];u8 len;
@@ -707,11 +731,17 @@ iwl_mld_set_wake_packet(struct iwl_mld *mld,struct cfg80211_wowlan_wakeup *wakeup, struct sk_buff **_pkt) { - int pkt_bufsize = wowlan_status->wake_packet_bufsize; -int expected_pktlen = wowlan_status->wake_packet_length; + u32 pkt_bufsize = wowlan_status->wake_packet_bufsize; +u32 expected_pktlen = wowlan_status->wake_packet_length;const u8 *pktdata = wowlan_status->wake_packet;const struct ieee80211_hdr *hdr = (const void *)pktdata; -int truncated = expected_pktlen - pkt_bufsize; +u32 truncated; + +if (IWL_FW_CHECK (mld, pkt_bufsize <sizeof (*hdr), +"pkt_bufsize is too short: %u\n" , pkt_bufsize)) +return ; + + truncated = expected_pktlen - pkt_bufsize;if (ieee80211_is_data (hdr->frame_control)) {int hdrlen =ieee80211_hdrlen (hdr->frame_control);
@@ -722,9 +752,18 @@ iwl_mld_set_wake_packet(struct iwl_mld *mld,if (!pkt)return ; -skb_put_data (pkt, pktdata, hdrlen); - pktdata += hdrlen; - pkt_bufsize -= hdrlen; +if (ieee80211_has_protected (hdr->frame_control)) { +struct iwl_mld_wake_pkt_iter_data iter_data = { + .multicast = +is_multicast_ether_addr (hdr->addr1), + }; + +ieee80211_iter_keys (mld->hw, vif, + iwl_mld_wake_pkt_key_iter, + &iter_data); + ivlen = iter_data.ivlen; + icvlen += iter_data.icvlen; + }/* if truncated, FCS/ICV is (partially) gone */ if (truncated >= icvlen) {
@@ -735,6 +774,13 @@ iwl_mld_set_wake_packet(struct iwl_mld *mld, truncated =0 ; } +if (IWL_FW_CHECK (mld, pkt_bufsize <= hdrlen + ivlen + icvlen, +"pkt_bufsize is too small %u\n" , pkt_bufsize)) +return ; + +skb_put_data (pkt, pktdata, hdrlen); + pktdata += hdrlen; + pkt_bufsize -= hdrlen; pkt_bufsize -= ivlen + icvlen; pktdata += ivlen;
@@ -756,6 +802,11 @@ iwl_mld_set_wake_packet(struct iwl_mld *mld, fcslen -= truncated; truncated =0 ; } + +if (IWL_FW_CHECK (mld, pkt_bufsize <= fcslen, +"pkt_bufsize is too small %u\n" , pkt_bufsize)) +return ; + pkt_bufsize -= fcslen; wakeup->packet = wowlan_status->wake_packet; wakeup->packet_present_len = pkt_bufsize;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 clk: mediatek: mt6735-vdecsys: add missing MODULE_DEVICE_TABLE()
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit 096ab64a0e69460bfb3557d09e17d2933280a1c6 ]
The driver has an OF match table wired to .of_match_table, but does not export the table with MODULE_DEVICE_TABLE().
Add the missing MODULE_DEVICE_TABLE(of, ...) entry so module alias information is generated for OF based module autoloading.
This is a source-level fix. It does not claim dynamic hardware reproduction; the evidence is the driver-owned match table, its use by the platform driver, and the missing module alias publication.
---
LLM Generated explanations, may be completely bogus:
The local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The vdecsys driver is present here; the change is a one-line MODULE_DEVICE_TABLE(of, ...) so OF module aliases are generated.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [clk: mediatek] [add] [missing MODULE_DEVICE_TABLE() for mt6735-vdecsys]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Pengpeng Hou \<[email protected]\> (author)
- Reviewed-by: Brian Masney \<[email protected]\> (clk co-maintainer; also committed the patch)
- Signed-off-by: Brian Masney \<[email protected]\>
- No Fixes:, Reported-by:, Tested-by:, Link:, or Cc: stable
- Ignore any pipeline-added Sasha Levin SOB (none on this commit)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: OF match table is wired to .of_match_table but not exported with MODULE_DEVICE_TABLE(), so modpost does not emit of: aliases.
- Symptom: when CONFIG_COMMON_CLK_MT6735_VDECSYS=m, udev/kmod cannot autoload clk-mt6735-vdecsys.ko from the DT compatible string; vdecsys clocks/resets never register unless the module is loaded by hand.
- Version info: none in the message. Driver introduced in 0bd9b1211f741 (contained in v6.13-rc1); this fix is contained in v7.3-rc1.
- Root cause: omission at driver introduction, not a later regression.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. It is an explicit autoload/alias publication fix. Author calls it a “source-level fix” with no hardware reproduction; that is accurate (the missing macro is visible in the file) and does not make the bug theoretical.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/clk/mediatek/clk-mt6735-vdecsys.c (+1 / -0)
- Function/data: file-scope after of_match_mt6735_vdecsys[]
- Scope: single-file, one-line surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: Before: match table exists and is used for in-kernel platform matching, but no module alias is published. After:MODULE_DEVICE_TABLE(of, of_match_mt6735_vdecsys) aliases the table for file2alias/modpost. Affects the modular autoload path only; probe/remove logic is unchanged.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: [Hardware enablement / module autoload] MODULE_DEVICE_TABLE is the OF analog of exporting PCI/USB IDs. Without it, modules.alias lacks of:N*T*Cmediatek,mt6735-vdecsys. Platform matching still works if the module is already loaded or built-in.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct; matches the established MediaTek clk pattern (65c9ad77cbc0e “Add MODULE_DEVICE_TABLE() where appropriate”). Compile-time alias generation only; no locking, no API, no runtime path change. Regression risk is negligible. Sibling clk-mt6735-imgsys.c / clk-mt6735-mfgcfg.c still lack the macro in this tree; that does not make this hunk wrong.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: Match table from 0bd9b1211f741 (Yassine Oudjana, 2024-11-06; contained in v6.13-rc1). MODULE_DEVICE_TABLE line is this commit 096ab64a0e694. Bug present from first introduction of the driver.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag on this commit. A later unrelated series ([PATCH 07/32] clk: mediatek: mt6735: Add missing MODULE_DEVICE_TABLE()) cited Fixes: 0bd9b1211f74 for the same omission across four files. Intro commit is an ancestor of HEAD.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Only two commits on this file: intro + this fix. Sibling same- day commit 36cf8d279ff90 does the same for vencsys. Standalone for vdecsys; no prerequisite refactor.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Pengpeng Hou is not the MT6735 clk maintainer (that is Yassine Oudjana). Same-day vencsys twin plus several other MODULE_DEVICE_TABLE additions (rtc, vdpa, watchdog). Brian Masney, clk co-maintainer, reviewed and applied it.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Macro has long existed in include/linux/module.h. Applies standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- Lore/msgid:
https://patch.msgid.link/[email protected]
- b4 dig -a: v1 only, applied as submitted
- Thread (mbox): author post + Brian Masney Reviewed-by: on 2026-07-06. No NAK, no stable nomination, no requested revisions.
- WebFetch of lore/spinics: 403/500; thread recovered via b4 dig -m.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): linux-clk, linux-mediatek, Stephen Boyd, Brian Masney, AngeloGioacchino Del Regno, Matthias Brugger, Yassine Oudjana. Review came from clk co-maintainer Brian Masney.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by, no bugzilla/syzbot. Author states source-level evidence only. No in-tree DTS uses mediatek,mt6735-vdecsys (binding only in Documentation/devicetree/bindings/clock/mediatek,syscon.yaml).
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Twin vencsys patch applied in the same pile. Later 07/32 series (Akari Tsuyukusa, Aug 2026) would have covered imgsys+mfgcfg+vdecsys+vencsys together; vdecsys/vencsys were already fixed here. This commit does not depend on that series.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No dedicated stable thread found for this subject. UNVERIFIED whether an AUTOSEL pick already exists; that must not drive the verdict.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: No function body changed. Added MODULE_DEVICE_TABLE next to of_match_mt6735_vdecsys. Driver uses mtk_clk_simple_probe / mtk_clk_simple_remove via module_platform_driver.
**Step 5.2: TRACE CALLERS**
Record: Probe is invoked by the platform core when a device matches mediatek,mt6735-vdecsys. Autoload (udev/kmod) is the path that was broken for =m. Built-in (=y) matching already worked via .of_match_table.
**Step 5.3: TRACE CALLEES**
Record: mtk_clk_simple_probe() (drivers/clk/mediatek/clk-mtk.c) registers the vdecsys gates and resets from vdecsys_clks. Unchanged by this patch.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: DT node compatible = "mediatek,mt6735-vdecsys" → (modular) udev alias lookup → clk-mt6735-vdecsys.ko → platform probe → video- decoder clocks. Reachable on MT6735 boards that describe that syscon; no in-tree board DTS. Unprivileged userspace cannot trigger it except by loading the module.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Most MediaTek clk drivers already have MODULE_DEVICE_TABLE. MT6735 core clocks (apmixedsys/infracfg/pericfg/topckgen) have it; imgsys and mfgcfg in this tree still do not. Same class of omission as the 2023 sweep 65c9ad77cbc0e.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. File exists; driver from 0bd9b1211f741 (v6.13-rc1). Kconfig COMMON_CLK_MT6735_VDECSYS is **tristate**, Makefile maps it to clk-mt6735-vdecsys.o. HEAD already contains 096ab64a0e694 (v7.3-rc1); the pre-fix omission is the code this candidate addresses.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply. One added line at a stable match-table site; no refactor around it.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This exact line is present (commit 096ab64a0e694). No alternate fix. imgsys/mfgcfg still missing aliases — separate omissions.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: [drivers/clk/mediatek] [PERIPHERAL] — SoC-specific video-decoder clock/reset driver for MT6735 (Helio T1 era). Not core mm/net/fs.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: MediaTek clk is actively developed; this file itself is quiet (two commits). MT6735 clk is listed Maintained (Yassine Oudjana).
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Users of MT6735 with CONFIG_COMMON_CLK_MT6735_VDECSYS=m. No in-tree defconfig enables COMMON_CLK_MT6735; no in-tree DTS instantiates the node. Built-in builds are unaffected.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Boot/enumeration with the DT node while the driver is a module. Not a race. Not unprivileged-exploitable. Workaround: modprobe clk- mt6735-vdecsys or build =y.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Video-decoder clocks/resets never appear unless the module is loaded manually → decode/VPU consumers fail clock lookup. Not panic/UAF/corruption. Severity: MEDIUM for modular MT6735 vdec; LOW overall population. Failure is “device feature does not come up,” same class as missing device IDs.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record: Benefit: modular autoload for this clock controller. Risk: very low (one compile-time alias line). Ratio: favorable because risk is essentially zero.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real autoload bug on a tristate, module_platform_driver clock driver
- One-line, obviously correct, clk co-maintainer Reviewed-by + applied
- Same class as device-ID / quirk enablement (OF alias publication)
- Established MediaTek clk precedent (65c9ad77cbc0e: “allow auto-load at boot”)
- Zero runtime/API/locking risk; applies cleanly
- Buggy driver exists in this 7.3 tree (since v6.13)
AGAINST:
- Not crash/security/corruption/deadlock
- No user report or hardware test
- Niche SoC; no in-tree DTS/defconfig
- Built-in configs already work
- Author framed it as source-level only
UNRESOLVED:
- Whether AUTOSEL/stable already discussed this hash (lore.kernel.org stable search not useful)
- Direct fetch of lore HTML (403)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — one-line alias export; reviewed by clk co-maintainer. No HW test, but correctness does not depend on runtime.
2. Fixes a real bug that affects users? **PASS** — modular OF autoload is broken by construction when the table is not exported.
3. Important issue? **PASS** (MEDIUM) — hardware clocks do not come up on the intended modular path; same practical class as missing device IDs, not a panic.
4. Small and contained? **PASS** — +1 line, one file.
5. No new features or APIs? **PASS** — publishes an existing match table.
6. Can apply to the local tree? **PASS** — file and match table exist; hunk is identical.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Device-ID / module-alias publication for an existing driver (OF MODULE_DEVICE_TABLE). That exception applies.
**Step 9.4: MAKE YOUR DECISION**
The bug is real for =m builds, the fix is trivial and already the subsystem’s standard pattern, and this tree has the driver. Conservative stable practice still takes this class because the downside is nil and the upside is the driver actually binding.
===============================================================
What the commit solves, and why it matters here
===============================================================
Without MODULE_DEVICE_TABLE(of, of_match_mt6735_vdecsys), modpost never emits the of:N*T*Cmediatek,mt6735-vdecsys alias. On this tree the Kconfig is tristate, so a modular vdecsys driver will not autoload; video-decoder clocks and resets never register until someone loads the module by name. Built-in matching via .of_match_table was already fine.
It meets stable rules: obviously correct, one line, no new API, no dependencies, and it is the OF equivalent of adding a device ID to an existing driver. Risk is compile-time alias generation only.
Concerns: no in-tree board uses this compatible, no reporter, not a crash. Those lower breadth of impact; they do not make the hunk unsafe or non-bugfix.
Verification:
- [Phase 1] Parsed commit 096ab64a0e694: SOB Pengpeng Hou; Reviewed- by/SOB Brian Masney; no Fixes/Reported-by/Cc: stable
- [Phase 2] Diff: +1 MODULE_DEVICE_TABLE(of, of_match_mt6735_vdecsys) in clk-mt6735-vdecsys.c
- [Phase 3] git blame: match table from 0bd9b1211f741; git describe --contains intro v6.13-rc1, fix v7.3-rc1
- [Phase 3] git merge-base --is-ancestor 0bd9b1211f741 HEAD and 096ab64a0e694 HEAD: both true
- [Phase 3] git log --oneline -- drivers/clk/mediatek/clk- mt6735-vdecsys.c: only intro + this fix
- [Phase 3] Sibling 36cf8d279ff90 vencsys same change; earlier sweep 65c9ad77cbc0e
- [Phase 4] b4 dig -c 096ab64a0e694: msgid [email protected]; v1 only
- [Phase 4] b4 dig -m: Brian Masney Reviewed-by; no NAK/stable discussion
- [Phase 4] WebFetch lore/spinics: 403/500; used mbox instead
- [Phase 5] Kconfig COMMON_CLK_MT6735_VDECSYS tristate; Makefile builds clk-mt6735-vdecsys.o; probe is mtk_clk_simple_probe
- [Phase 5] MODULE_DEVICE_TABLE in include/linux/module.h creates file2alias symbol
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- [Phase 6] No in-tree dts/dtsi for mt6735-vdecsys; binding listed in mediatek,syscon.yaml
- [Phase 6] No defconfig sets COMMON_CLK_MT6735
- [Phase 6] imgsys/mfgcfg still lack MODULE_DEVICE_TABLE (verified by grep)
- [Phase 7] MAINTAINERS: COMMON CLK FRAMEWORK includes Brian Masney; MT6735 CLOCK maintained by Yassine Oudjana
- [Phase 8] Failure mode: modular autoload miss → vdec clocks absent; severity MEDIUM/narrow
- UNVERIFIED: whether stable@ already queued this hash; lore stable search did not return this commit
**YES**
drivers/clk/mediatek/clk-mt6735-vdecsys.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/mediatek/clk-mt6735-vdecsys.c +1 -0
@@ -63,6 +63,7 @@ static const struct of_device_id of_match_mt6735_vdecsys[] = { { .compatible = "mediatek,mt6735-vdecsys", .data = &vdecsys_clks }, {/* sentinel */ } }; +MODULE_DEVICE_TABLE (of, of_match_mt6735_vdecsys);static struct platform_driver clk_mt6735_vdecsys = { .probe = mtk_clk_simple_probe,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 w1: ds2482: add OF device match table
In reply to Sasha LevinFrom: Kryštof Černý <[email protected]>
[ Upstream commit 53f33fd74d3993af0fbb5494b5be709f6ca6b712 ]
Add an of_device_id table and hook it into the i2c driver so the ds2482/ds2484 can be matched and auto-probed from Device Tree.
This allows automatic module loading when instantiated via DT.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.18.y** (v6.18.53 / make kernelversion = 6.18.53). At v6.18.53 the ds2482 driver, DT binding, and Tarragon DTS already exist, but the OF match table does not. This patch is the missing device-ID/autoload piece for that existing hardware.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[w1/ds2482] [add] [OF of_device_id table so ds2482/ds2484 match and autoload from Device Tree]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Link:** https://patch.msgid.link/20260612-w1-of- [email protected]
- **Signed-off-by:** Kryštof Černý <[email protected]> (author)
- **Signed-off-by:** Krzysztof Kozlowski <[email protected]> (W1 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)
- Pipeline-only tags ignored: [Upstream commit 53f33fd74d3993af0fbb5494b5be709f6ca6b712], Sasha Levin SOB
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** ds2482/ds2484 described in DT with maxim,ds2482 / maxim,ds2484 do not autoload the module.
- **Symptom:** 1-wire master never binds unless the module is loaded by hand or built-in.
- **Root cause (author):** no of_device_id table, so OF matching and OF module aliases are missing.
- **Version info:** none in the message. Upstream date is 12 Jun 2026 (after 6.18); this is a backport candidate into 6.18.y.
Cover-letter text (after ---, not in the git body) is more explicit:
without the OF table, “the driver is not matched because no of_device_id table is registered.” That is **partly overstated** for bind-after-load (see Phase 5); the autoload failure is real.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not a disguised cleanup.** It is an explicit hardware- match/autoload fix: add OF IDs to an existing I2C driver. Same class as PCI/USB/ACPI ID additions.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** drivers/w1/masters/ds2482.c — **+8 / -0**
- **Added:** ds2482_of_match[], MODULE_DEVICE_TABLE(of, ds2482_of_match)
- **Changed:** ds2482_driver.driver.of_match_table
- **Scope:** single-file surgical ID table; no probe/remove logic change
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** driver only has i2c_device_id (ds2482, ds2484) and MODULE_DEVICE_TABLE(i2c, ...). of_match_table is NULL.
- **After:** same probe/remove; OF compatible strings maxim,ds2482 / maxim,ds2484 are advertised and hooked into the I2C driver.
- **Path affected:** DT instantiation / module autoload, not the 1-wire transfer path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Hardware IDs / OF autoload]**
Verified I2C/OF behavior in this tree:
- i2c_device_uevent() (drivers/i2c/i2c-core-base.c) calls of_device_uevent_modalias() first. If the client has an of_node, that succeeds and **no** i2c: MODALIAS is added.
- of_modalias() emits of:N<name>T<type>C<compatible> (e.g. Cmaxim,ds2484).
- MODULE_DEVICE_TABLE(i2c, ds2482_id) only produces i2c:ds2482 / i2c:ds2484, which do **not** match that OF alias.
- Once the module **is** loaded, i2c_device_match() still falls through to i2c_match_id(); DT client->name is filled by of_alias_from_compatible() (maxim,ds2484 → ds2484). So bind works if someone modprobes. The break is **coldplug autoload**.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: **Obviously correct, minimal.** Compatible strings match Documentation/devicetree/bindings/w1/maxim,ds2482.yaml. of_device_id comes from linux/mod_devicetable.h via linux/i2c.h; no extra include. Probe is unchanged. Regression risk is **very low** (autoload of an already-supported driver).
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record: At v6.18.53 there is **no** OF table. Surrounding i2c_device_id / i2c_driver date to 50fa2951bd744d (2017). DS2484 I2C ID: 58ecb03fc74a5 (6 Apr 2023). DT binding: 22ab6c515d960 (same day, same series). The omission is the binding-without-OF-table gap since **2023**, well before 6.18.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Not applicable. Buggy state is long- standing missing OF aliases, not a recent regression commit.
**Step 3.3: CHECK FILE HISTORY**
Record (this tree, -- drivers/w1/masters/ds2482.c):
- 172f24df0dab4 signedness fix (in 6.18)
- 6e0bb206c6af6 regulator support (in 6.18)
- 58ecb03fc74a5 DS2484 I2C ID (in 6.18) Standalone; series name is w1-of-autoload-v1-1 (**1/1**). No prerequisite refactor.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Author is a contributor, not the W1 maintainer. Other ds2482 work includes regulator support and a datasheet URL fix. **Krzysztof Kozlowski** is MAINTAINERS owner for W1 DALLAS'S 1-WIRE BUS and applied this patch.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **None.** Uses existing of_device_id / MODULE_DEVICE_TABLE / i2c_driver.of_match_table. Compatible strings already documented. **Applies standalone.**
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 53f33fd74d3993af0fbb5494b5be709f6ca6b712 →
https://patch.msgid.link/20260612-w1-of-
[email protected]
- b4 dig -a: **v1 only**; that version was applied.
- Maintainer apply mail (29 Jun 2026): “Applied, thanks!” → https://git .kernel.org/krzk/linux-w1/c/53f33fd74d3993af0fbb5494b5be709f6ca6b712
- No NAK, no requested respin, no reviewer risk flags.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To **Krzysztof Kozlowski** (W1 maintainer); Cc Miroslav Ondra, linux-kernel. No separate Reviewed-by; maintainer applied it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No bugzilla/syzbot link. Cover letter describes DT autoload failure. Cc of Miroslav Ondra suggests a real user/context, but that is not a formal report.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: **Standalone 1/1.** Binding + I2C ID were added together in 2023 (22ab6c515d960 + 58ecb03fc74a5); this commit finishes the OF alias side.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search returned **403**. **UNVERIFIED** whether this hash was discussed on stable@ separately. Same *class* of fix is already in this 6.18.y tree, e.g. 039e490e3ac47 (“i3c: master:
adi: add OF module alias for autoloading”), 2e199e3ede9c1 (drm/tve200 OF alias), 1a2dc9bf3b15d (backlight ktz8866 autoload).
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: No function body edits. Data: ds2482_of_match, ds2482_driver. Probe remains ds2482_probe (does not use of_match_data).
**Step 5.2: TRACE CALLERS**
Record: I2C core i2c_device_match() / i2c_device_uevent() / modalias_show. Triggered when an I2C adapter walks DT children (of_i2c_register_devices). Not a syscall hot path; device enumeration / udev coldplug.
**Step 5.3: TRACE CALLEES**
Record: MODULE_DEVICE_TABLE → modpost aliases. of_match_table → of_match_device / i2c_of_match_device. No alloc/lock/I/O change.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: DT node compatible = "maxim,ds2484" → I2C client → uevent MODALIAS=of:...Cmaxim,ds2484 → kmod/udev. **Reachable on any DT board with this chip and CONFIG_W1_MASTER_DS2482=m.** Confirmed in this
tree: arch/arm/configs/imx_v6_v7_defconfig has CONFIG_W1_MASTER_DS2482=m; imx6ull-tarragon-common.dtsi has compatible = "maxim,ds2484" at onewire@18; four Tarragon .dts files include that.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Other W1 masters already ship OF tables (w1-gpio.c, w1-uart.c, mxc_w1.c, omap_hdq.c, amd_axi_w1.c). ds2482 was the I2C W1 master missing it.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes, at v6.18.53.** git grep of of_match / maxim,ds248 in drivers/w1/masters/ds2482.c at v6.18.53 is empty. Binding file and Tarragon DTS **are** in 6.18.53. Bug present since the 2023 binding/ID series.
(HEAD on autosel already contains candidate af5503abcf293; that is pipeline state, not a reason to skip the technical decision.)
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply with fuzz.** GNU patch --dry-run of the upstream hunk onto v6.18.53:drivers/w1/masters/ds2482.c: **Hunk #1 succeeded at 549 (offset 4 lines).** Context (MODULE_DEVICE_TABLE(i2c, ds2482_id) and .name = "ds2482") matches. Only nearby difference is { "ds2482" } vs { .name = "ds2482" }, outside the hunk.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: **No alternate OF table** at v6.18.53. I2C ID table is present but does not generate OF aliases.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **[drivers/w1 I2C master] [PERIPHERAL]** — 1-wire bridge used on specific boards (Tarragon i.MX6ULL industrial). Not core mm/net, but real shipping hardware.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature, low-churn driver (present since ~2005). Occasional fixes (signedness, regulator). Maintainer-applied patch.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / platform-specific.** Users with DS2482/DS2484 in DT and the driver as a module. In-tree: Tarragon (imx6ull-tarragon-*) plus any out-of-tree DT using the documented compatibles.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: **Every boot** on those boards if ds2482 is modular. Not a race. Unprivileged users cannot trigger a crash; they just never get 1-wire. Built-in (=y) already works via i2c_device_id.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Device does not probe until manual modprobe ds2482.** 1-wire sensors (e.g. w1_therm) stay missing. **Severity: MEDIUM** (functional hardware miss, not oops/corruption). Covered by the **device-ID / DT enablement** stable exception.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record: **Benefit: medium** for affected boards (hardware works out of the box). **Risk: very low** (8 lines, IDs only, probe unchanged). **Ratio: favorable.**
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR backporting:**
- Existing driver in 6.18.y; only OF IDs are new (device-ID exception).
- DT binding and Tarragon DTS already use maxim,ds2484; imx defconfig builds the driver as =m.
- Verified: DT I2C uevents use OF modalias only; without MODULE_DEVICE_TABLE(of) autoload fails.
- 8-line, obviously correct table matching the binding.
- Standalone v1, applied by the W1 maintainer; no NAKs.
- Same pattern already present in this 6.18.y series (OF module alias backports).
- Applies cleanly to v6.18.53.
**AGAINST:**
- Not a crash, UAF, deadlock, or CVE.
- Author slightly overstated “driver is not matched”; id_table still binds after a manual load.
- Peripheral W1 chip, limited population.
- Workaround: modprobe ds2482 or =y.
**UNRESOLVED:**
- lore.kernel.org/stable HTTP 403; no confirmation of a prior stable@ thread for this SHA.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — standard OF ID table; maintainer applied v1.
2. Fixes a real bug that affects users? **PASS** — modular DT boards do not autoload; Tarragon is in-tree.
3. Important issue? **PASS** under the device-ID/hardware-enablement exception (severity MEDIUM, not a panic).
4. Small and contained? **PASS** — +8 lines, one file.
5. No new features or APIs? **PASS** — IDs for hardware the driver already supports.
6. Can apply to the local tree? **PASS** — driver/bindings/DTS in 6.18.53; patch applies with offset 4.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **New device IDs (OF compatible strings) on an existing driver.** Also DT hardware enablement for boards already described in this tree.
**Step 9.4: DECISION**
This is the OF equivalent of adding PCI/USB IDs. The 6.18.y tree already documents and instantiates the device; the module simply never loads. That is a contained, low-risk fix that belongs in this stable tree.
---
### What the commit solves for this tree
On 6.18.y, maxim,ds2482/maxim,ds2484 are valid and used (Tarragon). The I2C core publishes an of: modalias for those nodes. Without of_match_table + MODULE_DEVICE_TABLE(of), kmod never loads ds2482.ko, so 1-wire stays dead until a manual modprobe. The patch does not add a new driver or API; it publishes the IDs the binding already defined.
Risk is an 8-line ID table with unchanged probe. Benefit is that existing DT hardware actually comes up on distro-style modular configs.
---
### Verification
- **[Phase 1]** Tags: Link msgid, SOB Černý + Kozlowski; no Fixes/Reported-by/Cc stable.
- **[Phase 1]** Cover letter (openwall/lkml): autoload/match claim; “driver not matched” is overstated vs id_table.
- **[Phase 2]** Diff: +8 in ds2482.c; table + of_match_table only.
- **[Phase 2]** i2c_device_uevent / of_device_uevent_modalias / of_modalias: OF alias only when of_node exists.
- **[Phase 2]** of_alias_from_compatible + i2c_match_id: bind still works after manual load.
- **[Phase 3]** git describe HEAD = v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion = 6.18.53.
- **[Phase 3]** git merge-base --is-ancestor af5503abcf293 v6.18.53 fails; v6.18.53 grep has no OF table.
- **[Phase 3]** Binding 22ab6c515d960 and I2C ID 58ecb03fc74a5 **are** ancestors of v6.18.53.
- **[Phase 3]** git blame on v6.18.53 driver struct: no of_match_table.
- **[Phase 4]** b4 dig -c 53f33fd74d39: lore msgid; -a v1 only; -w maintainer To:.
- **[Phase 4]** Kozlowski “Applied, thanks!” 29 Jun 2026.
- **[Phase 4]** lore.kernel.org/stable: **UNVERIFIED** (403).
- **[Phase 5]** imx_v6_v7_defconfig: CONFIG_W1_MASTER_DS2482=m; Tarragon DTS maxim,ds2484.
- **[Phase 5]** ds2482_probe does not use OF match data.
- **[Phase 6]** GNU patch onto v6.18.53 file: success, offset 4.
- **[Phase 8]** Failure mode: no autoload → 1-wire absent; not an oops.
- **UNVERIFIED:** stable@ mailing-list discussion of this specific commit.
**YES**
drivers/w1/masters/ds2482.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/w1/masters/ds2482.c +8 -0
@@ -549,9 +549,17 @@ static const struct i2c_device_id ds2482_id[] = { };MODULE_DEVICE_TABLE (i2c, ds2482_id); +static const struct of_device_id ds2482_of_match[] = { + { .compatible ="maxim,ds2482" , }, + { .compatible ="maxim,ds2484" , }, + { } +}; +MODULE_DEVICE_TABLE (of, ds2482_of_match); +static struct i2c_driver ds2482_driver = { .driver = { .name ="ds2482" , + .of_match_table = ds2482_of_match, }, .probe = ds2482_probe, .remove = ds2482_remove,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 exfat: free new directory cluster if zeroing fails
In reply to Sasha LevinFrom: Yichong Chen <[email protected]>
[ Upstream commit ce12a39bed483008683438962b3a605374e6f803 ]
exfat_alloc_new_dir() allocates a cluster for a new directory before zeroing it. If exfat_zeroed_cluster() fails, the function returns the error but leaves the allocated cluster in use.
Free the newly allocated cluster before returning the zeroing error.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: [exfat] [free] Free a newly allocated directory cluster if zeroing it fails.
**Step 1.2: Tags**
Record:
- Signed-off-by: Yichong Chen <[email protected]> (author)
- Signed-off-by: Namjae Jeon <[email protected]> (exFAT maintainer; applied the patch)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, Link:, or Cc: [email protected]
Absence of Fixes: / Cc: stable is expected for this review pipeline and is not a negative signal.
**Step 1.3: Body**
Record:
- **Bug:** exfat_alloc_new_dir() allocates a cluster, then zeros it. On exfat_zeroed_cluster() failure it returns the error and leaves the cluster marked allocated.
- **Symptom:** leaked cluster (allocation bitmap / used_clusters), not a crash.
- **Version info:** none in the message.
- **Root cause:** missing rollback of exfat_alloc_cluster() on the zeroing error path.
**Step 1.4: Hidden bug fix?**
Record: Not hidden. This is an explicit error-path resource-leak fix.
---
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- File: fs/exfat/dir.c (+7 / -1)
- Function: exfat_alloc_new_dir()
- Scope: single-file surgical error-path change
**Step 2.2: Code-flow change**
Record: **Before:** allocate one cluster; return exfat_zeroed_cluster(...). Zeroing failure returns -ENOMEM/-EIO with the cluster still in the bitmap. **After:** on zeroing failure, exfat_free_cluster(inode, clu) then return the original error. Success still returns 0.
**Step 2.3: Bug mechanism**
Record: **Error-path resource leak.** Cluster stays marked used with no directory entry pointing at it. exfat_alloc_cluster() does p_chain->size++ and sbi->used_clusters += p_chain->size, and can dirty/sync the allocation bitmap via exfat_set_bitmap(). The leak can persist on disk until fsck.
**Step 2.4: Fix quality**
Record: Obviously correct and minimal. Same rollback already exists in exfat_add_entry() when exfat_put_dentry_set() fails (fs/exfat/namei.c). exfat_alloc_cluster() drops bitmap_lock before returning, so calling exfat_free_cluster() here does not deadlock. Caller (exfat_add_entry) discards clu on error. Regression risk is low.
---
## Phase 3: Git history
**Step 3.1: Blame**
Record: The leak (return exfat_zeroed_cluster(inode, clu->dir)) was introduced in ca06197382bde0 (“exfat: add directory operations”, Namjae Jeon, 2020-03-02), described as v5.6-rc1-4-gca06197382bde (exFAT landed around v5.7). The exfat_alloc_cluster(..., false) argument is from 286ae368871d2 (2026 multi-cluster alloc); that is unrelated to the leak.
**Step 3.2: Fixes: tag**
Record: None. The introducing commit is ca06197382bde0. git merge- base --is-ancestor ca06197382bde0 HEAD is implied by the blame on this tree; the buggy pattern existed here from the start of in-tree exFAT.
**Step 3.3: File history**
Record: Recent fs/exfat/dir.c work is unrelated (overflow, uniname bounds, rename). Same-day follow-up 0901a71e8cff5 (“clean up new entry on add entry failure”) handles a *later* failure (exfat_put_dentry_set() after a successful exfat_alloc_new_dir()). Complementary, not a prerequisite.
**Step 3.4: Author**
Record: Yichong Chen has three recent exFAT error-path commits. Namjae Jeon is listed maintainer (MAINTAINERS: EXFAT FILE SYSTEM) and applied this patch.
**Step 3.5: Dependencies**
Record: Standalone. Uses existing exfat_free_cluster(). No new helpers or APIs. The leak-fix hunk does not depend on multi-cluster allocation.
---
## Phase 4: Mailing list / external research
**Step 4.1: Original discussion**
Record:
- Lore/msgid: https://patch.msgid.link/20260728042923.408237-1- [email protected]
- b4 dig -a: v1 only, committed as submitted
- Maintainer reply: “Applied it to #dev. Thanks!” No NAK, no requested changes, no Cc: stable in the thread.
**Step 4.2: Recipients (b4 dig -w)**
Record: Namjae Jeon, Sungjong Seo, Yuezhang Mo, [email protected], [email protected] — the MAINTAINERS set.
**Step 4.3: Bug report**
Record: No Reported-by / bugzilla / syzbot. Author-found by code inspection. Trigger is still real: exfat_zeroed_cluster() returns -ENOMEM on sb_getblk() failure, -EIO on out-of-range cluster, or a DIRSYNC sync_blockdev_range() error.
**Step 4.4: Series**
Record: Standalone one-patch series. Next-day 0901a71e8cff5 is a related but independent leak/cleanup.
**Step 4.5: Stable list**
Record: No stable-list discussion found. lore.kernel.org HTML fetch returned 403; thread was recovered via b4 dig -m. No evidence this was rejected for stable.
---
## Phase 5: Code semantic analysis
**Step 5.1: Functions**
Record: Modified: exfat_alloc_new_dir(). Callees:exfat_alloc_cluster, exfat_zeroed_cluster, exfat_free_cluster.
**Step 5.2: Callers**
Record: Only exfat_add_entry() in fs/exfat/namei.c (mkdir path, type == TYPE_DIR && !sbi->options.zero_size_dir). zero_size_dir defaults to false (`/* Support creating zero-size directory, default:
false */`).
Call chain: exfat_mkdir → exfat_add_entry → exfat_alloc_new_dir. exfat_mkdir is .mkdir in the inode operations. Userspace mkdir(2) on a writable exFAT mount reaches this. exfat_mkdir takes s_lock and sets the volume dirty *before* exfat_add_entry.
**Step 5.3: Callees**
Record: exfat_alloc_cluster marks bitmap + increments used_clusters. exfat_zeroed_cluster zeros every sector in the cluster. exfat_free_cluster takes bitmap_lock and clears the bitmap / decrements used_clusters.
**Step 5.4: Reachability**
Record: Yes, from mkdir(2) on exFAT (SD cards / USB sticks; CONFIG_EXFAT_FS). Unprivileged users can trigger it if they can mkdir on the mount. Failure of zeroing is an error path (memory pressure or I/O error), not every mkdir.
**Step 5.5: Similar pattern**
Record: fs/exfat/namei.c around the exfat_find_empty_entry() grow path still does exfat_alloc_cluster() then if (exfat_zeroed_cluster(...)) return -EIO; without freeing. That is a sibling leak, not a reason to drop this fix.
---
## Phase 6: Local tree (this checkout)
**Step 6.1: Does the buggy code exist here?**
Record: Local tree is **v7.3-rc4** (7.3.0-rc4, HEAD f0100363d8c37). git merge-base --is-ancestor ce12a39bed483 HEAD succeeded — this commit is already in HEAD. Pre-fix dir.c had the leak since ca06197382bde0 (v5.7-era). Current exfat_alloc_new_dir() already contains the free-on-zeroing-failure path.
**Step 6.2: Backport difficulty onto this tree**
Record: Already applied; context matches. On this 7.3 tree there is nothing left to apply.
**Step 6.3: Related fixes already here?**
Record: 0901a71e8cff5 is also in HEAD and covers a different failure (writeback of the new dentry set). No alternate fix of this zeroing-path leak.
The question for *this* tree is whether the fix is stable-worthy given that the bug and the code path exist here. It is not a “code missing from the tree” NO.
---
## Phase 7: Subsystem context
**Step 7.1:**
Record: fs/exfat/ — filesystem. **IMPORTANT** (not core VFS/mm, but a widely used removable-media FS).
**Step 7.2:**
Record: Actively maintained (Namjae Jeon, Sungjong Seo). The leak itself is old (2020), not a new-subsystem-only bug.
---
## Phase 8: Impact and risk
**Step 8.1: Who is affected**
Record: Users of CONFIG_EXFAT_FS who create directories (default zero_size_dir=false). Typical: SD cards, USB sticks.
**Step 8.2: Trigger**
Record: mkdir after a cluster was allocated, then exfat_zeroed_cluster() fails. Not every mkdir; needs ENOMEM/EIO/DIRSYNC write failure. Unprivileged if the mount is writable.
**Step 8.3: Failure mode**
Record: Persistent cluster leak (bitmap + used_clusters), lost free space until fsck. Volume is already marked dirty. Not a panic/UAF/corruption of existing files. **Severity: HIGH** for on-disk space leak; not CRITICAL crash/corruption.
**Step 8.4: Risk-benefit**
Record:
- **Benefit:** High for remount-surviving leaked clusters on a common removable FS; tiny, obviously correct rollback.
- **Risk:** Very low (7 lines, error path only, existing free helper, lock order already used elsewhere).
- **Ratio:** Favorable.
---
## Phase 9: Synthesis
**Step 9.1: Evidence**
FOR:
- Real leak: allocated cluster not freed when zeroing fails
- On-disk allocation bitmap can retain the leak
- Reachable from mkdir(2) on default exFAT mounts
- Present since exFAT was merged (~v5.7)
- 7-line surgical rollback; exfat_free_cluster() already used on similar error paths
- Maintainer applied v1 with no objections
- No new API/feature; no prerequisites in this tree
AGAINST:
- Error path, not a crash/UAF/CVE
- No syzbot/user report
- Sibling leak in namei.c grow path remains (does not invalidate this fix)
UNRESOLVED:
- Could not HTML-fetch lore.kernel.org (403); thread recovered with b4 dig -m
- No stable-list thread found
**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** — maintainer applied; logic matches existing cleanup in exfat_add_entry()
2. Real bug affecting users? **PASS** — leaked clusters on failed mkdir
3. Important? **PASS** — persistent FS space leak (not a crash, but more than cosmetic)
4. Small and contained? **PASS** — 7 insertions / 1 deletion, one function
5. No new features/APIs? **PASS**
6. Can apply to this tree? **PASS** — already in this 7.3-rc4 tree; the same rollback is what stable wants
**Step 9.3: Exception category**
Record: None required. Ordinary small leak fix.
**Step 9.4: Decision**
This is a classic stable leak fix: small, obviously correct, user- visible (lost clusters on exFAT mkdir error), and present for years. It should be selected for stable.
---
## What the commit solves for stable users
mkdir on exFAT allocates a directory cluster, then zeros it. If zeroing fails, the mkdir error is returned but the cluster stays allocated in the bitmap with no dentry. That can permanently shrink free space until fsck. The patch frees that cluster on the error path.
It meets the stable rules: real bug, small, no new API, already reviewed by the maintainer. Risk is low; benefit is preventing a persistent filesystem resource leak.
---
## Verification
- [Phase 1] Parsed commit ce12a39bed483; tags are author + maintainer SOB only
- [Phase 2] Diff is fs/exfat/dir.c exfat_alloc_new_dir(): add exfat_free_cluster() on exfat_zeroed_cluster() failure
- [Phase 2] Confirmed exfat_alloc_cluster() increments p_chain->size and used_clusters; exfat_free_cluster() no-ops if size == 0
- [Phase 2] Confirmed exfat_zeroed_cluster() can return -ENOMEM (sb_getblk), -EIO (range check), or DIRSYNC I/O error
- [Phase 3] git blame on parent: leak from ca06197382bde0 (2020-03-02, v5.6-rc1-4)
- [Phase 3] git merge-base --is-ancestor ce12a39bed483 HEAD → commit is in this tree
- [Phase 3] Follow-up 0901a71e8cff5 is a different failure path; not a prerequisite
- [Phase 4] b4 dig -c ce12a39bed483 → msgid [email protected]
- [Phase 4] b4 dig -a: v1 only; b4 dig -w: exFAT maintainers + list
- [Phase 4] mbox: Namjae Jeon “Applied it to #dev”; no NAK
- [Phase 4] WebFetch lore HTML: 403; used b4 dig -m instead
- [Phase 5] git grep exfat_alloc_new_dir: only exfat_add_entry() → exfat_mkdir
- [Phase 5] Default zero_size_dir is false, so mkdir uses this path
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- [Phase 6] Current fs/exfat/dir.c already contains the fixed function
- [Phase 7] MAINTAINERS: Namjae Jeon, Sungjong Seo; CONFIG_EXFAT_FS for SD/USB
- [Phase 8] Failure mode verified as cluster leak, not oops
- UNVERIFIED: stable@ mailing-list archive HTML (403)
The fix is small, surgical, and meets the stable criteria for this tree.
**YES**
fs/exfat/dir.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/exfat/dir.c +7 -1
@@ -310,7 +310,13 @@ int exfat_alloc_new_dir(struct inode *inode, struct exfat_chain *clu)if (ret)return ret; -return exfat_zeroed_cluster (inode, clu->dir); + ret =exfat_zeroed_cluster (inode, clu->dir); +if (ret) { +exfat_free_cluster (inode, clu); +return ret; + } + +return 0 ; }int exfat_calc_num_entries (struct exfat_uni_name *p_uniname)
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 scsi: ibmvfc: check for NULL evt in implicit LOGO and target delete path
In reply to Sasha LevinFrom: Tyrel Datwyler <[email protected]>
[ Upstream commit 0122eab60b151d7815f420a91c7315944a037714 ]
Unlike ibmvfc_tgt_implicit_logout the ibmvfc_tgt_implicit_logout_and_del path fails to check for a NULL evt returned from ibmvfc_get_reserved_event and passes that directly to ibmvfc_send_event which will unconditionally derefence the evt.
Check for a NULL evt and perform same escalation as ibmvfc_implicit_logout.
---
LLM Generated explanations, may be completely bogus:
This is a real NULL-deref crash fix in ibmvfc’s target-delete path. The local tree is **v7.3-rc4** (7.3.0-rc4); the driver and the buggy call path exist here, and the change is an 8-line match of the sibling logout error path.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
- Subsystem: scsi: ibmvfc
- Action verb: check (safety check; commit body describes a NULL deref)
- Intent: stop passing a NULL event into ibmvfc_send_event on the implicit-LOGO + delete path
Record: [scsi/ibmvfc] [check] [NULL evt before send on implicit logout/delete]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Signed-off-by: Tyrel Datwyler \<[email protected]\> (author; IBM ibmvfc maintainer/contributor)
- Link:
https://patch.msgid.link/[email protected]
- Signed-off-by: Martin K. Petersen \<[email protected]\> (SCSI maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Cc:
stable
- Ignore pipeline SOBs if present; none besides author + SCSI maintainer
Record: Author + SCSI maintainer SOB; lore/msgid link; no Fixes/Reported-by (expected)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Bug: ibmvfc_tgt_implicit_logout checks for NULL from event allocation; ibmvfc_tgt_implicit_logout_and_del does not
- Failure: NULL evt is passed to ibmvfc_send_event, which dereferences it
- Fix: same escalation as the sibling path (drop discovery thread, put kref, reset host)
Record: [NULL deref of evt] [kernel oops on target delete when reserved pool is empty] [no version pins in message] [missed sibling NULL check]
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Explicit NULL-deref fix.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
- File at commit: drivers/scsi/ibmvscsi/ibmvfc.c (+8 / -0)
- Function: ibmvfc_tgt_implicit_logout_and_del
- Scope: single-file surgical error-path
Record: [ibmvfc.c +8] [ibmvfc_tgt_implicit_logout_and_del] [surgical]
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Before: discovery_threads++ → __ibmvfc_tgt_get_implicit_logout_evt() → ibmvfc_send_event(evt) with no NULL test.
After: if !evt, decrement discovery_threads, ibmvfc_set_tgt_action(NONE), kref_put, __ibmvfc_reset_host, return.
Record: [error path only: unguarded send → guarded recovery matching sibling]
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Category: memory safety (NULL pointer dereference), plus leak/refcount on that path.
Verified mechanism:
- __ibmvfc_tgt_get_implicit_logout_evt() does kref_get then ibmvfc_get_reserved_event(); on failure it returns NULL (ibmvfc- core.c 4424–4427)
- __ibmvfc_get_event() can return NULL when the reserved pool is empty (1615–1630)
- ibmvfc_send_event() starts with *evt->xfer_iu = evt->iu (1787) — unconditional deref
Record: [NULL deref] [empty reserved event pool → NULL evt → oops; fix mirrors implicit_logout]
**Step 2.4: ASSESS THE FIX QUALITY**
Obviously correct as a crash fix: must not call ibmvfc_send_event(NULL), must undo discovery_threads++, must kref_put the get done inside the helper.
Caveat (verified in ibmvfc_set_tgt_action): this path is entered with tgt->action == IBMVFC_TGT_ACTION_LOGOUT_RPORT (set in ibmvfc_del_tgt). From that state, only LOGOUT_RPORT_WAIT or DEL_RPORT are accepted; ACTION_NONE is silently ignored. The send- failure arm already uses DEL_RPORT. An automated review (sashiko-bot) flagged this. It does not reintroduce the NULL deref: kref_put still balances the helper, and __ibmvfc_reset_host still runs. Worst case, the target stays in LOGOUT_RPORT and is retried after reset — far better than an oops.
Record: [minimal, matches sibling; ACTION_NONE is a no-op here but not a crash regression]
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
- ibmvfc_tgt_implicit_logout_and_del introduced in ed830385a2b1f (“Avoid loss of all paths during SVC node reboot”), contained in **v5.7-rc1**
- NULL-returning get_event and sibling check added in b39f2d10b86d0 (“Remove BUG_ON in the case of an empty event pool”), contained in **v6.7-rc1**. That commit updated __ibmvfc_tgt_get_implicit_logout_evt and ibmvfc_tgt_implicit_logout but **left and_del unchecked** (verified in the post-commit function body)
Record: [and_del: ed830385a2b1f / v5.7] [NULL return + incomplete call- site update: b39f2d10b86d0 / v6.7]
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Effective buggy change is b39f2d10b86d0 (in this tree; git merge-base --is-ancestor → YES)
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Series msgid …969416-4 is **[PATCH v2 03/33]** of “ibmvfc: NVMe/FC support over IBM Virtual FC”. Cover letter: patches 1–5 are **pre- existing bug fixes** so the series is bisect-safe. This patch does not depend on NVMe patches. Neighbors: 9c2aa65000f6f (MAD send deadlock), 7e35396ec8539 (teardown flush). Later 848c70852e3fb split ibmvfc.c → ibmvfc-core.c.
Record: [standalone bugfix in a feature series] [no functional prereq on later NVMe patches]
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Tyrel Datwyler is the ibmvfc author of the 2023 event-pool change and this follow-up, plus the NVMe/FC series. Martin K. Petersen applied it.
Record: [subsystem author] [completes his own 2023 call-site sweep]
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Needs __ibmvfc_tgt_get_implicit_logout_evt returning NULL, ibmvfc_send_event, __ibmvfc_reset_host. All present. Applies as 8 lines with no new APIs.
Record: [standalone vs current driver; prereq b39f2d10b86d0 is in this tree]
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
- b4 dig -c 0122eab60b151 → [PATCH v2 03/33],
https://patch.msgid.link/[email protected]
- b4 dig -a → v2 series only in the match: “NVMe/FC support over IBM Virtual FC” (2026-07-22)
- Cover letter: this is one of four pre-existing bugs (NULL event deref in and_del)
- Martin K. Petersen: “Applied to 7.3/scsi-staging, thanks!”
- Direct replies to 03/33: sashiko-bot only (ACTION_NONE concern). No human NAK.
Record: [lore msgid above] [v2 03/33] [SCSI maintainer applied] [AI note on ACTION_NONE, no NAK]
**Step 4.2: CHECK WHO REVIEWED THE PATCH**b4 dig -w: Tyrel Datwyler; James Bottomley; Martin K. Petersen; linux- scsi; linuxppc-dev; linux-kernel; Brian King; Dave Marquardt.
Record: [SCSI maintainers + IBM ibmvfc people + linuxppc-dev]
**Step 4.3: SEARCH FOR THE BUG REPORT**
No Reported-by / syzbot / bugzilla. Bug described by the driver author from code comparison with the sibling.
Record: [author-found incomplete 2023 update; no external repro]
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES** Standalone among 33; first four are bugfixes. Later patches are NVMe feature work and must not be required.
Record: [self-contained; do not pull the NVMe series]
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
WebSearch of lore for this subject did not find a stable@ thread. Direct lore.kernel.org fetches returned 403.
Record: [no stable-list hit found; lore HTTP 403 on direct fetch]
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: [ibmvfc_tgt_implicit_logout_and_del]
**Step 5.2: TRACE CALLERS**
- Declared static; ibmvfc_del_tgt() sets tgt->job_step = ibmvfc_tgt_implicit_logout_and_del when action becomes LOGOUT_RPORT (687–694)
- Work thread IBMVFC_HOST_ACTION_TGT_DEL / TGT_DEL_FAILED invokes tgt->job_step(tgt) for LOGOUT_RPORT targets (6085–6097)
Record: [ibmvfc_del_tgt → work queue TGT_DEL → and_del; host work thread, not IRQ]
**Step 5.3: TRACE CALLEES** __ibmvfc_tgt_get_implicit_logout_evt, ibmvfc_send_event, ibmvfc_set_tgt_action, kref_put/ibmvfc_release_tgt, __ibmvfc_reset_host
Record: [event alloc/send, tgt state, kref, host reset]
**Step 5.4: FOLLOW THE CALL CHAIN**
Trigger: target removal / path loss on IBM Virtual FC (the v5.7 commit was SVC node reboot / WWPN move). Userspace SCSI/FC path loss on a POWER guest can reach this. NULL only if reserved CRQ events are exhausted (IBMVFC_NUM_INTERNAL_REQ is small: 1+1+1+2+(disc_threads*2)). Unlikely but the 2023 change exists specifically because it can happen; without this check it is a hard oops rather than recovery.
Record: [reachable on target delete] [NULL when reserved pool empty] [oops from driver work thread]
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Sibling ibmvfc_tgt_implicit_logout already has the same 8-line guard (4458–4464). This is the missed twin.
Record: [same pattern already in implicit_logout; and_del was the hole]
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
- git describe HEAD: **v7.3-rc4-27-gf0100363d8c37**; make kernelversion: **7.3.0-rc4**
- Function lives in drivers/scsi/ibmvscsi/ibmvfc-core.c (file split after this commit)
- git merge-base --is-ancestor 0122eab60b151 HEAD → YES (landed in **v7.3-rc1**)
- Current ibmvfc_tgt_implicit_logout_and_del already has the NULL check (4530–4536)
- The hole existed from v6.7 until v7.3-rc1; this lineage had it and now has the fix
- CONFIG_SCSI_IBMVFC depends on PPC_PSERIES && SCSI
Record: [code path present in this tree] [bug from v6.7; fix already on this HEAD]
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Against this HEAD the original diff would not apply as-is (ibmvfc.c → ibmvfc-core.c, NVMe churn). Against a pre-split tree matching v6.7–v7.2, the hunk is a clean 8-line insert next to the sibling.
Record: [clean on pre-split ibmvfc.c; this HEAD already contains the equivalent]
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE** This exact fix is already an ancestor. Sibling NULL check from b39f2d10b86d0 is also here.
Record: [this fix already present; no alternate incomplete fix]
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: [SCSI ibmvfc / IBM POWER Virtual FC] [IMPORTANT for pseries guests, not core-universal]
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Mature client driver; recent NVMe/FC work. This NULL check is a pre- existing SCSI-path bug, not NVMe enablement.
Record: [mature; this fix is independent of NVMe feature work]
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: [platform-specific: PPC_PSERIES Virtual FC; enterprise POWER VMs]
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: [target delete / implicit LOGO while reserved event pool empty] [uncommon but real] [not a syscall smash; storage path loss on the guest]
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: [NULL deref in ibmvfc_send_event → oops] [CRITICAL/HIGH]
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Benefit: avoid host oops during target logout/delete. Risk: 8 lines, error path only; ACTION_NONE is a no-op from LOGOUT_RPORT but send- failure already recovers via reset/delete. No API change.
Record: [high benefit vs low risk]
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real NULL deref: ibmvfc_send_event uses evt without a check
- Incomplete 2023 call-site update left only and_del unguarded
- 8-line clone of the proven sibling path (thread count, kref, host reset)
- Author is the ibmvfc owner; SCSI maintainer applied it
- Cover letter calls this a pre-existing bug, not NVMe feature
- Reachable on IBM Virtual FC target delete (production POWER path)
AGAINST:
- Bundled as 03/33 of a large NVMe series (the patch itself is independent)
- No Fixes:/Cc:stable/user report (absence is expected)
- ACTION_NONE does not stick from LOGOUT_RPORT; DEL_RPORT would match the send-fail arm
- This HEAD already contains the commit (v7.3-rc1); original file name has changed
UNRESOLVED:
- Could not fetch lore.kernel.org HTML (403); used b4 mbox instead
- No stable@ discussion found
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — mirrors sibling; applied by SCSI maintainer
2. Fixes a real bug that affects users? **PASS** — oops on target delete if reserved events are gone
3. Important issue? **PASS** — NULL deref / oops
4. Small and contained? **PASS** — +8 lines, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** for this lineage (code exists; equivalent already in tree). A naive apply of the original ibmvfc.c diff onto current split sources would not be needed here.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: [none; ordinary crash fix]
**Step 9.4: MAKE YOUR DECISION**
This tree is Linux **7.3-rc4**. The ibmvfc client, and_del, and NULL- returning event allocator are all here. The bug is a missed NULL check that oopses in ibmvfc_send_event. The patch is small, matches existing recovery, and does not pull in NVMe/FC. The ACTION_NONE no-op is a minor state-machine nit, not a reason to withhold a crash fix.
------------------------------------------------
What the commit solves for stable users
------------------------------------------------
On IBM POWER Virtual FC, deleting a target does an implicit logout. If the reserved event pool is empty, allocation returns NULL. The sibling logout path handled that; the delete path did not, so the host work thread would oops. Users see a kernel crash during path loss / target teardown rather than a host reset.
------------------------------------------------
Stable rules / risk vs benefit
------------------------------------------------
Meets the rules: real oops, tiny, no features. Benefit is crash avoidance on a production pseries driver. Risk is low; recovery matches the sibling. Do not backport the rest of the 33-patch NVMe series with it.
------------------------------------------------
Concerns
------------------------------------------------ACTION_NONE is ignored from LOGOUT_RPORT; DEL_RPORT would be the closer match to the send-failure arm. Still prevents the oops. On this 7.3-rc4 tree the fix is already present (0122eab60b151); that is not “already selected by the pipeline,” it is the mainline landing. The driver code this commit exists to protect is in this tree.
Verification:
- [Phase 1] Subject/tags: scsi: ibmvfc NULL evt check; SOB Tyrel Datwyler + Martin K. Petersen; Link msgid 20260723000149.969416-4; no Fixes/Reported-by
- [Phase 2] Diff: +8 in ibmvfc_tgt_implicit_logout_and_del only
- [Phase 2] __ibmvfc_get_event can return NULL (ibmvfc-core.c 1615–1630); helper returns that NULL (4424–4427); ibmvfc_send_event derefs at 1787
- [Phase 2] ibmvfc_set_tgt_action: LOGOUT_RPORT allows only LOGOUT_RPORT_WAIT or DEL_RPORT (531–537)
- [Phase 3] and_del from ed830385a2b1f (v5.7-rc1); incomplete sweep b39f2d10b86d0 (v6.7-rc1); this fix 0122eab60b151 (v7.3-rc1)
- [Phase 3] git merge-base --is-ancestor b39f2d10b86d0 HEAD YES; 0122eab60b151 YES
- [Phase 3] After b39f2d10b86d0, and_del still called ibmvfc_send_event(evt) with no NULL check
- [Phase 4] b4 dig -c 0122eab60b151: v2 03/33 NVMe/FC series; cover letter lists this as a pre-existing NULL deref
- [Phase 4] b4 dig -w: linux-scsi, linuxppc-dev, James Bottomley, Martin Petersen, Brian King
- [Phase 4] b4 dig -m: Martin applied to 7.3/scsi-staging; sashiko-bot ACTION_NONE comment; no human NAK
- [Phase 4] lore HTML fetch 403; WebSearch found no stable@ thread for this subject
- [Phase 5] Caller: ibmvfc_del_tgt → TGT_DEL work → job_step
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; kernelversion 7.3.0-rc4; NULL check present at ibmvfc-core.c 4530–4536
- [Phase 7] CONFIG_SCSI_IBMVFC: PPC_PSERIES Virtual FC client
- [Phase 8] Failure mode: NULL deref oops; severity HIGH/CRITICAL
- UNVERIFIED: human-tested repro on hardware (author analysis + maintainer apply only)
**YES**
drivers/scsi/ibmvscsi/ibmvfc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/scsi/ibmvscsi/ibmvfc.c +8 -0
@@ -4403,6 +4403,14 @@ static void ibmvfc_tgt_implicit_logout_and_del(struct ibmvfc_target *tgt) evt =__ibmvfc_tgt_get_implicit_logout_evt (tgt, ibmvfc_tgt_implicit_logout_and_del_done); +if (!evt) { + vhost->discovery_threads--; +ibmvfc_set_tgt_action (tgt,IBMVFC_TGT_ACTION_NONE ); +kref_put (&tgt->kref, ibmvfc_release_tgt); +__ibmvfc_reset_host (vhost); +return ; + } +ibmvfc_set_tgt_action (tgt,IBMVFC_TGT_ACTION_LOGOUT_RPORT_WAIT );if (ibmvfc_send_event (evt, vhost, default_timeout)) { vhost->discovery_threads--;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] scsi: ibmvfc: check for NULL evt in implicit LOGO and target delete path
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] scsi: ibmvfc: invalid state transition in ibmvfc_tgt_implicit_logout_and_del() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] scsi: ibmvfc: invalid state transition in ibmvfc_tgt_implicit_logout_and_del() --
commit 99489de7e63442e984a1136b57de120f99e8b4e7
Author: Tyrel Datwyler <[email protected]>
scsi: ibmvfc: check for NULL evt in implicit LOGO and target delete path
This commit adds a NULL check for the event returned by __ibmvfc_tgt_get_implicit_logout_evt() in ibmvfc_tgt_implicit_logout_and_del() before passing it to ibmvfc_send_event().
drivers/scsi/ibmvscsi/ibmvfc.c static void ibmvfc_tgt_implicit_logout_and_del(struct ibmvfc_target *tgt) · line 4408
Quoted 11 lines
drivers/scsi/ibmvscsi/ibmvfc.c +3
-0@@ -4403,6 +4403,14 @@ static void ibmvfc_tgt_implicit_logout_and_del(struct ibmvfc_target *tgt) evt =__ibmvfc_tgt_get_implicit_logout_evt (tgt, ibmvfc_tgt_implicit_logout_and_del_done); +if (!evt) { + vhost->discovery_threads--; +ibmvfc_set_tgt_action (tgt,IBMVFC_TGT_ACTION_NONE );
[Severity: Medium]
Should this pass IBMVFC_TGT_ACTION_DEL_RPORT instead of IBMVFC_TGT_ACTION_NONE?
ibmvfc_tgt_implicit_logout_and_del() is installed as tgt->job_step in ibmvfc_del_tgt() when tgt->action is set to IBMVFC_TGT_ACTION_LOGOUT_RPORT:
drivers/scsi/ibmvscsi/ibmvfc.c:ibmvfc_del_tgt() {
if (!ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_LOGOUT_RPORT)) {
tgt->job_step = ibmvfc_tgt_implicit_logout_and_del;
tgt->init_retries = 0;
}
}and ibmvfc_do_work() only invokes it while tgt->action is IBMVFC_TGT_ACTION_LOGOUT_RPORT:
drivers/scsi/ibmvscsi/ibmvfc.c:ibmvfc_do_work() {
case IBMVFC_HOST_ACTION_TGT_DEL:
case IBMVFC_HOST_ACTION_TGT_DEL_FAILED:
list_for_each_entry(tgt, &vhost->targets, queue) {
if (tgt->action == IBMVFC_TGT_ACTION_LOGOUT_RPORT) {
tgt->job_step(tgt);
break;
}
}
if (ibmvfc_dev_logo_to_do(vhost)) {
spin_unlock_irqrestore(vhost->host->host_lock, flags);
return;
}
}However, in ibmvfc_set_tgt_action(), when tgt->action is IBMVFC_TGT_ACTION_LOGOUT_RPORT, only transitions to IBMVFC_TGT_ACTION_LOGOUT_RPORT_WAIT or IBMVFC_TGT_ACTION_DEL_RPORT are permitted:
drivers/scsi/ibmvscsi/ibmvfc.c:ibmvfc_set_tgt_action() {
switch (tgt->action) {
case IBMVFC_TGT_ACTION_LOGOUT_RPORT:
if (action == IBMVFC_TGT_ACTION_LOGOUT_RPORT_WAIT ||
action == IBMVFC_TGT_ACTION_DEL_RPORT) {
tgt->action = action;
rc = 0;
}
break;
}Passing IBMVFC_TGT_ACTION_NONE here returns -EINVAL without changing tgt->action, leaving the target in IBMVFC_TGT_ACTION_LOGOUT_RPORT instead of transitioning it to IBMVFC_TGT_ACTION_DEL_RPORT like the other error paths in ibmvfc_tgt_implicit_logout_and_del(). As a result, ibmvfc_dev_logo_to_do(vhost) continues to return 1 and blocks rport deletion in IBMVFC_HOST_ACTION_TGT_DEL / IBMVFC_HOST_ACTION_TGT_DEL_FAILED (including during adapter removal when vhost->state is IBMVFC_HOST_OFFLINE).
drivers/scsi/ibmvscsi/ibmvfc.c static void ibmvfc_tgt_implicit_logout_and_del(struct ibmvfc_target *tgt) · line 4416
Quoted 8 lines
drivers/scsi/ibmvscsi/ibmvfc.c +5
-0+kref_put (&tgt->kref, ibmvfc_release_tgt); +__ibmvfc_reset_host (vhost); +return ; + } +ibmvfc_set_tgt_action (tgt,IBMVFC_TGT_ACTION_LOGOUT_RPORT_WAIT );if (ibmvfc_send_event (evt, vhost, default_timeout)) { vhost->discovery_threads--;
I hope this helps!
Let me know if you need any further details.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 drm/amd/pm: Validate OD DPM triples before mutating tables
In reply to Sasha LevinFrom: Asad Kamal <[email protected]>
[ Upstream commit b390cb9d776039fc4f0be13b2649299079227d12 ]
vega10_odn_edit_dpm_table() and smu7_odn_edit_dpm_table() could mutate the live ODN table for valid triples, then return 0 after detecting a truncated buffer or out-of-range index. Validate all (index, clock, voltage) triples first and return -EINVAL on any failure; only then apply updates.
v2: Use distinct message for different error case, removed unused input_level from validation loop (Lijo)
v3: Reject negative level indices, input[] is long but was compared only against unsigned table bounds, so negative values could pass and truncate when assigned to uint32_t input_level.
Set DPMTABLE_OD_UPDATE_SCLK/MCLK only after validation passes, so a failed sysfs write does not leave need_update_dpm_table set for a later commit.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.18.53**. The buggy SMU7/Vega10 OverDrive edit path is present on that series, and the patch applies cleanly.
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[drm/amd/pm] [Validate] [reject invalid OD DPM (index, clock, voltage) triples before writing live tables]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- [Upstream commit b390cb9d776039fc4f0be13b2649299079227d12] — pipeline marker, ignored
- No Fixes: tag (expected)
- No Reported-by: / Tested-by: / Link: / Cc: stable
- Reviewed-by: Lijo Lazar <[email protected]>
- Reviewed-by: Hawking Zhang <[email protected]>
- Signed-off-by: Asad Kamal <[email protected]> (author)
- Signed-off-by: Alex Deucher <[email protected]> (amdgpu maintainer)
- Signed-off-by: Sasha Levin — pipeline marker, ignored
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** vega10_odn_edit_dpm_table() and smu7_odn_edit_dpm_table() apply valid triples immediately, then on a later truncated buffer or out-of-range index they return 0.
- **Symptom:** a failed pp_od_clk_voltage write can still change live clock/voltage tables, report success, and (Vega10) leave need_update_dpm_table set so a later echo c commits the partial change.
- **v3 extra:** input[] is long; comparing only against unsigned table size lets negative indices through, then assignment to uint32_t input_level truncates and indexes off the array.
- **Version info:** none in the message. Introducing code is from 2018 (v4.17/v4.18).
- **Root cause:** validate-and-mutate in one loop; wrong error return; missing signed-index check; Vega10 dirty-flag set before validation.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. Explicit correctness/safety fix (partial update + false success + OOB index). Not cleanup-only.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- smu7_hwmgr.c: +20/−14 in smu7_odn_edit_dpm_table()
- vega10_hwmgr.c: +23/−14 in vega10_odn_edit_dpm_table()
- Total: **43 insertions, 28 deletions**, two files, single-function surgical change per file.
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record (same pattern in both):
- **Before:** one loop: on truncated/out-of-range input, print and return 0 after earlier triples already wrote entries[] / dpm_levels[]. Invalid clock/voltage still returned -EINVAL but only after mutating that iteration’s predecessors. Vega10 ORs DPMTABLE_OD_UPDATE_SCLK/MCLK before the loop.
- **After:** first loop validates every triple (i+3 > size, input[i] < 0 || index >= count, clock/voltage via existing checkers) and returns -EINVAL with no writes. Only then set dirty flags (Vega10) and apply updates in a second loop.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** memory safety (OOB write) + logic/correctness (partial live-table mutation, false success, dirty-flag leak).
- **Mechanism:** long index vs uint32_t bound: on 64-bit, -1 >= count is false, then input_level = (uint32_t)-1 indexes entries[0xFFFFFFFF]. Arrays are 8 entries (MAX_REGULAR_DPM_NUMBER / phm_odn_clock_levels.entries[8]). Truncated writes previously returned 0 so amdgpu_set_pp_od_clk_voltage() treated them as success (return count).
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct two-pass validate-then-commit. Checker polarity preserved (smu7_check_clk_voltage_valid / vega10_check_clk_voltage_valid return true when valid; new code uses if (!check())). No API change. Regression risk is low: invalid writes now fail instead of succeeding-with-partial-state; valid writes still apply the same stores. Slight behavior change for tools that treated truncated writes as success is the intended fix.
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- SMU7 loop: 5e4d4fbea5573 (“drm/amd/pp: Implement edit_dpm_table on smu7”, 2018-02-19) — first in **v4.17-rc1**.
- Vega10 loop: c5a4484941be5 (“drm/amd/pp: Add OVERDRIVE support on Vega10”, 2018-05-15) — first in **v4.18-rc1**.
- Both ancestors of v6.18.53. Bug has been in this series since the branch point.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Introducing commits identified by blame; both present in this tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES** Record (on v6.18.53, those two files): recent powerplay work is unrelated (voltage lookup bounds, Hawaii SCLK cap, etc.). Related:d27252b5706e5 “amdgpu/pm: prevent array underflow in vega20_odn_edit_dpm_table()” (2022) — **already in v6.18.53**. Same class of sysfs-fed negative index. Standalone patch, not X/Y.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Asad Kamal is an AMD contributor; not the tree maintainer. Alex Deucher applied it. Lijo Lazar / Hawking Zhang reviewed (AMD PM). No other OD-triple commits by this author on v6.18.53 in this path.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Uses existing helpers and structs. No new functions. git apply --check of this diff onto v6.18.53 copies of both files: **clean**. Standalone.
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- Lore/msgid:
https://patch.msgid.link/[email protected]
- Revisions: v1 (2026-05-29) → v2 (2026-06-03) → **v3 applied** (2026-06-04)
- v1 Lijo: distinct error strings; unused input_level in the validate loop (style, addressed)
- v2 Lijo: Reviewed-by
- v3 Hawking: Reviewed-by
- No NAK. v3 added the negative-index check (the OOB hole). No reviewer Cc: stable in the saved threads.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: To/Cc: amd-gfx, Lijo Lazar, Hawking Zhang, Le Ma, Shiwu Zhang, Alex Deucher, Kevin Yang Wang. Right maintainers; two AMD R-b plus maintainer SOB.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by, syzbot, or bugzilla. Bug is described from code inspection. Direct lore HTTP search was bot-blocked; discussion recovered via b4.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone three-revision single patch, not a series. Later autosel commit 42ba4b5ff5278 (“validate vega10 profile mode inputs”) is a different function, not a prerequisite.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search was bot-walled. **UNVERIFIED** whether stable@ already discussed this; no in-tree evidence it was rejected.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: smu7_odn_edit_dpm_table(), vega10_odn_edit_dpm_table(). Helpers used unchanged: smu7_check_clk_voltage_valid(), vega10_check_clk_voltage_valid(), vega10_odn_update_soc_table().
**Step 5.2: TRACE CALLERS**
Record:
- Registered as .odn_edit_dpm_table in each hwmgr func table
- pp_odn_edit_dpm_table() in amd_powerplay.c
- amdgpu_dpm_odn_edit_dpm_table() under adev->pm.mutex
- amdgpu_set_pp_od_clk_voltage() sysfs store for pp_od_clk_voltage
**Step 5.3: TRACE CALLEES**
Record: table writes, clock/voltage range checks, Vega10 vega10_odn_update_soc_table(). No alloc/lock added.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace echo "s 0 900 820" > pp_od_clk_voltage (documented in amdgpu_pm.c). Sysfs is S_IRUGO | S_IWUSR (root write). Path requires hwmgr->od_enabled, set only if PP_OVERDRIVE_MASK (0x4000). Default amdgpu_pp_feature_mask = 0xfff7bfff **clears** that bit; OD is opt-in (ppfeaturemask), and enabling it taints the kernel. Still a real sysfs path for overclockers.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Vega20 already rejects bad indices (d27252b5706e5, in this tree). Newer swsmu ppt files have their own OD parsers. This patch only covers the two powerplay implementations that still mutate-then-return 0.
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes, on **v6.18.53**. Blame on that tag still has return 0 on truncated/out-of-range input and Vega10 dirty flags before the loop. Candidate 25b12527acd6c is **not** an ancestor of v6.18.53 (merge- base --is-ancestor exit 1). Introduced v4.17/v4.18.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** (git apply --check of this diff on v6.18.53 copies of both files, exit 0). Surrounding functions match the hunk context.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: Vega20 underflow fix is present. No equivalent two-pass validation for SMU7/Vega10 on v6.18.53.
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **drm/amd/pm powerplay** (SMU7 / Vega10 OverDrive). **IMPORTANT** for those GPUs, not core mm/scheduler. Polaris/Vega-class AMD GPUs still in production use.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Files still receive bounds-check and PM fixes on 6.18.y. OD edit logic itself has been stable since 2018.
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver-specific, config-specific: AMD SMU7 (CI/VI/Polaris) and Vega10 users with OverDrive enabled who write pp_od_clk_voltage.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Malformed or truncated sysfs payload (e.g. incomplete triple, negative level, mix of good then bad triples). Common for tools/scripts. Unprivileged users cannot write the attr (root/owner only). Not a default-boot path; OD is off unless ppfeaturemask sets bit 14.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- Negative index → **OOB write** into 8-entry arrays → memory corruption. **HIGH** (gated by OD + root).
- Partial table mutation + return 0 → userspace thinks commit-ready state is good; later c can program inconsistent clocks/voltages. **HIGH** for hardware (instability / out-of-spec clocks), **MEDIUM** as a kernel crash.
- Vega10 dirty-flag leak: failed write still causes a later commit to push SCLK/MCLK. **MEDIUM–HIGH**.
Overall: **HIGH**, not a panic-on-boot, but real memory safety + live PM table corruption.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** medium–high for OD users (OOB + wrong clocks); low for default configs.
- **Risk:** very low (small, local, validate-then-write, maintainer- reviewed, applies cleanly).
- **Ratio:** favor backport. Same class as the Vega20 underflow already on this tree.
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real OOB write (negative long index → uint32_t wrap)
- Partial mutation of live DPM tables with success return
- Vega10 can commit stale/partial OD state after a failed write
- Small, obviously correct, two-pass fix
- Reviewed by Lijo Lazar and Hawking Zhang; applied by Alex Deucher
- Applies cleanly to v6.18.53; no missing structs/helpers
- Bug present since v4.17/v4.18
- Precedent: Vega20 OD index underflow already in this tree
AGAINST:
- OverDrive off by default
- Sysfs store is root-only
- No syzbot/CVE/user crash report
- No Fixes: / Cc: stable (not a negative per the review rules)
UNRESOLVED:
- Whether stable@ already discussed this (lore stable search blocked)
- Unprivileged trigger only if something remaps sysfs mode (not verified; default is S_IWUSR)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — two-pass validation; R-b from AMD PM; polarity of existing checkers verified in tree
2. Fixes a real bug that affects users? **PASS** — OOB + false-success partial OD updates via documented sysfs
3. Important issue? **PASS** — OOB write and inconsistent GPU DPM/voltage tables (HIGH, gated)
4. Small and contained? **PASS** — ~70 line-churn, two functions
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 a device ID / quirk / DT / build / doc fix). Qualifies as a normal bugfix.
**Step 9.4: MAKE YOUR DECISION**
This belongs on 6.18.53. The local tree still has the 2018 validate- while-mutating loops. The patch closes an OOB write and stops failed OverDrive sysfs writes from leaving live SCLK/MCLK tables and Vega10 update flags half-applied. It is small, reviewed, and applies without prerequisites.
### What the commit solves for this tree
On 6.18.53, writing pp_od_clk_voltage can (1) store valid triples, then succeed on a truncated/out-of-range rest of the buffer; (2) turn a negative level into a huge uint32_t index and write off the 8-entry ODN arrays; (3) on Vega10, mark DPM tables dirty even when the write fails, so a later commit programs incomplete settings.
### Stable rules / risk
Meets all six criteria. Risk is a behavior change only for previously accepted-but-invalid writes. Benefit is memory safety and not programming a GPU with a half-edited OD table.
### Concerns
OD is opt-in and the node is root-writable, so this is not a default- boot crash. That does not make the OOB or live-table corruption unworthy of 6.18.y; the analogous Vega20 underflow is already here.
Verification:
- [Phase 1] Tags: R-b Lijo Lazar, R-b Hawking Zhang, SOB Alex Deucher; no Fixes/Reported-by
- [Phase 2] Diff: two-pass validate-then-mutate in smu7_odn_edit_dpm_table / vega10_odn_edit_dpm_table; -EINVAL instead of return 0; Vega10 dirty flags moved after validation; input[i] < 0 added
- [Phase 2] Checkers return true when valid (smu7_hwmgr.c ~5582–5616)
- [Phase 3] Blame v6.18.53: 5e4d4fbea5573 (v4.17-rc1), c5a4484941be5 (v4.18-rc1); both ancestors of v6.18.53
- [Phase 3] git merge-base --is-ancestor 25b12527acd6c v6.18.53 → not present; d27252b5706e5 Vega20 underflow **is** present
- [Phase 4] b4 dig -c b390cb9d7760: v1–v3; v3 msgid 20260604091915.1012329-1; Lijo then Hawking R-b; no NAK
- [Phase 4] UNVERIFIED: stable@ thread (HTTP 403/bot wall)
- [Phase 5] Call chain: sysfs amdgpu_set_pp_od_clk_voltage → amdgpu_dpm_odn_edit_dpm_table → hwmgr; attr S_IRUGO|S_IWUSR; OD mask 0x4000 cleared in default 0xfff7bfff
- [Phase 5] Arrays: entries[8] / MAX_REGULAR_DPM_NUMBER 8
- [Phase 6] git describe HEAD / Makefile: **6.18.53**; apply-check on v6.18.53 file copies: exit 0
- [Phase 8] Failure: OOB write + partial OD table / dirty-flag leak; severity HIGH (gated)
- UNVERIFIED: whether udev/distro remaps pp_od_clk_voltage to non-root write
**YES**
.../drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c | 34 ++++++++++------- .../drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c | 37 ++++++++++++------- 2 files changed, 43 insertions(+), 28 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c +20 -14
@@ -5661,23 +5661,29 @@ static int smu7_odn_edit_dpm_table(struct pp_hwmgr *hwmgr, }for (i =0 ; i < size; i +=3 ) { -if (i +3 > size || input[i] >= podn_dpm_table_in_backend->num_of_pl) { -pr_info ("invalid clock voltage input \n" ); -return 0 ; +if (i +3 > size) { +pr_info ("truncated clock/voltage input\n" ); +return -EINVAL ; } - input_level = input[i]; - input_clk = input[i+1 ] *100 ; - input_vol = input[i+2 ]; - -if (smu7_check_clk_voltage_valid (hwmgr, type, input_clk, input_vol)) { - podn_dpm_table_in_backend->entries[input_level].clock = input_clk; - podn_vdd_dep_in_backend->entries[input_level].clk = input_clk; - podn_dpm_table_in_backend->entries[input_level].vddc = input_vol; - podn_vdd_dep_in_backend->entries[input_level].vddc = input_vol; - podn_vdd_dep_in_backend->entries[input_level].vddgfx = input_vol; - }else { +if (input[i] <0 || input[i] >= podn_dpm_table_in_backend->num_of_pl) { +pr_info ("invalid clock/voltage level\n" );return -EINVAL ; } + input_clk = input[i +1 ] *100 ; + input_vol = input[i +2 ]; +if (!smu7_check_clk_voltage_valid (hwmgr, type, input_clk, input_vol)) +return -EINVAL ; + } + +for (i =0 ; i < size; i +=3 ) { + input_level = input[i]; + input_clk = input[i +1 ] *100 ; + input_vol = input[i +2 ]; + podn_dpm_table_in_backend->entries[input_level].clock = input_clk; + podn_vdd_dep_in_backend->entries[input_level].clk = input_clk; + podn_dpm_table_in_backend->entries[input_level].vddc = input_vol; + podn_vdd_dep_in_backend->entries[input_level].vddc = input_vol; + podn_vdd_dep_in_backend->entries[input_level].vddgfx = input_vol; }return 0 ;
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c +23 -14
@@ -5645,11 +5645,9 @@ static int vega10_odn_edit_dpm_table(struct pp_hwmgr *hwmgr,if (PP_OD_EDIT_SCLK_VDDC_TABLE == type) { dpm_table = &data->dpm_table.gfx_table; podn_vdd_dep_table = &data->odn_dpm_table.vdd_dep_on_sclk; - data->need_update_dpm_table |=DPMTABLE_OD_UPDATE_SCLK ; }else if (PP_OD_EDIT_MCLK_VDDC_TABLE == type) { dpm_table = &data->dpm_table.mem_table; podn_vdd_dep_table = &data->odn_dpm_table.vdd_dep_on_mclk; - data->need_update_dpm_table |=DPMTABLE_OD_UPDATE_MCLK ; }else if (PP_OD_RESTORE_DEFAULT_TABLE == type) {memcpy (&(data->dpm_table), &(data->golden_dpm_table),sizeof (struct vega10_dpm_table ));vega10_odn_initial_default_setting (hwmgr);
@@ -5667,21 +5665,32 @@ static int vega10_odn_edit_dpm_table(struct pp_hwmgr *hwmgr, }for (i =0 ; i < size; i +=3 ) { -if (i +3 > size || input[i] >= podn_vdd_dep_table->count) { -pr_info ("invalid clock voltage input\n" ); -return 0 ; +if (i +3 > size) { +pr_info ("truncated clock/voltage input\n" ); +return -EINVAL ; } - input_level = input[i]; - input_clk = input[i+1 ] *100 ; - input_vol = input[i+2 ]; - -if (vega10_check_clk_voltage_valid (hwmgr, type, input_clk, input_vol)) { - dpm_table->dpm_levels[input_level].value = input_clk; - podn_vdd_dep_table->entries[input_level].clk = input_clk; - podn_vdd_dep_table->entries[input_level].vddc = input_vol; - }else { +if (input[i] <0 || input[i] >= podn_vdd_dep_table->count) { +pr_info ("invalid clock/voltage level\n" );return -EINVAL ; } + input_clk = input[i +1 ] *100 ; + input_vol = input[i +2 ]; +if (!vega10_check_clk_voltage_valid (hwmgr, type, input_clk, input_vol)) +return -EINVAL ; + } + +if (type ==PP_OD_EDIT_SCLK_VDDC_TABLE ) + data->need_update_dpm_table |=DPMTABLE_OD_UPDATE_SCLK ; +else + data->need_update_dpm_table |=DPMTABLE_OD_UPDATE_MCLK ; + +for (i =0 ; i < size; i +=3 ) { + input_level = input[i]; + input_clk = input[i +1 ] *100 ; + input_vol = input[i +2 ]; + dpm_table->dpm_levels[input_level].value = input_clk; + podn_vdd_dep_table->entries[input_level].clk = input_clk; + podn_vdd_dep_table->entries[input_level].vddc = input_vol; }vega10_odn_update_soc_table (hwmgr, type);return 0 ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ksmbd: honor byte-range locks for zero data
In reply to Sasha LevinFrom: Namjae Jeon <[email protected]>
[ Upstream commit 8b57448a147d2378088e63cd473e7f2a967d6802 ]
FSCTL_SET_ZERO_DATA changes file allocation state and must respect byte-range locks over the affected part of the file. Check the requested range, clipped to EOF, before issuing the fallocate operation.
Return STATUS_FILE_LOCK_CONFLICT when the range conflicts with an existing lock. Ranges starting past EOF are left untouched by the lock check so they continue to succeed.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). The buggy FSCTL_SET_ZERO_DATA path is present here, the lock helper already exists, and the patch applies cleanly. This is a real lock-bypass data- integrity bug, not a new feature.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ksmbd] [honor] honor byte-range locks for FSCTL_SET_ZERO_DATA
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Original commit: 8b57448a147d2378088e63cd473e7f2a967d6802 (Namjae Jeon, 2026-08-17)
Tags present:
- Signed-off-by: Namjae Jeon <[email protected]> (author + ksmbd maintainer)
- No Fixes:, Cc: stable, Reported-by, Tested-by, Reviewed-by, Acked-by, or Link: (absence of Fixes/Cc:stable is expected for this review)
Record: Maintainer-authored; no user/syzbot report tags.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: FSCTL_SET_ZERO_DATA changes allocation (punch-hole / zero- range) without checking SMB byte-range locks.
- Symptom: a client can zero or punch a range another handle has locked; the locker does not get STATUS_FILE_LOCK_CONFLICT.
- Root cause: ksmbd_vfs_zero_data() calls vfs_fallocate() with no check_lock_range().
- Intentional edge: ranges starting past EOF skip the lock check so they still succeed.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. Explicit protocol/correctness fix:
missing lock enforcement on a mutating FSCTL.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- fs/smb/server/vfs.c: +12 in ksmbd_vfs_zero_data()
- fs/smb/server/smb2pdu.c: +6/-1 in smb2_ioctl() FSCTL_SET_ZERO_DATA
- Total: 18 insertions, 1 deletion
- Scope: single-subsystem, two-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **vfs.c before:** break Level II oplocks, then vfs_fallocate(PUNCH_HOLE or ZERO_RANGE | KEEP_SIZE) with no lock check.
- **vfs.c after:** same, but for non-POSIX shares, if off < i_size, call check_lock_range(filp, off, min(off+len, size)-1, WRITE) and return -EAGAIN on conflict.
- **smb2pdu.c before:** any ret < 0 goes to ioctl out, which maps unknown errors to STATUS_INVALID_PARAMETER.
- **smb2pdu.c after:** -EAGAIN sets STATUS_FILE_LOCK_CONFLICT, ret = 0, then goto out so the generic mapper does not overwrite the status.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- Category: logic / protocol correctness, with data-integrity impact.
- Mechanism: SMB byte-range locks in ksmbd are POSIX locks; vfs_fallocate() does not consult them (verified in fs/open.c:
permission/lease/overflow checks only). Read, write, truncate, and copychunk already call check_lock_range(); zero-data did not. A WRITE lock on another handle, or a READ lock vs this WRITE, is ignored and the range is zeroed/punched.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Quality: high. Same pattern as ksmbd_vfs_write() / ksmbd_vfs_truncate() / ksmbd_vfs_copy_file_ranges().
- posix_extensions skip matches those callers.
- Clipping to EOF avoids start > end if the request extends past EOF.
- Regression risk: low. Only behavioral change is rejecting previously- illegal zeroing of locked ranges. ret = 0 plus pre-set status is a bit awkward versus adding -EAGAIN in the ioctl out mapper, but it
works: out only overwrites status when ret < 0 || Status == 0, so STATUS_FILE_LOCK_CONFLICT is preserved and smb2_set_err_rsp() still runs.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- ksmbd_vfs_zero_data() introduced by Namjae Jeon in 2021 (fs/cifsd/vfs.c, blame f44158485826c0 / 64b39f4a2fd293).
- Never had a lock check. Present throughout 6.12.
- override_creds wrapper already in this tree via fb1cae6302d58 (ksmbd: use opener credentials for FSCTL mutations).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Buggy code is the original zero-data implementation, not a later regression.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Already in this tree: f751d6e39d4c9 “Do not skip lock checks for single-byte ranges”; ca53bb17f4e82 “add a permission check for FSCTL_SET_ZERO_DATA”; fe20d492a69a6 lock-owner tracking.
- On origin/master, parent 3c707d4b3f926 (“fix permission checks for file allocation ioctls”) is independent (SPARSE/QUERY_ALLOCATED_RANGES access bits), not required for this lock check.
- No patch X/Y in the subject. Standalone.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Namjae Jeon is the ksmbd maintainer (Signed-off-by on both authorship and merge). This tree already carries many of his ksmbd stable fixes.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. check_lock_range() is static in the same vfs.c (lines 325–358). STATUS_FILE_LOCK_CONFLICT already exists. posix_extensions and i_size_read/min() are present. git apply --check of 8b57448a147d2 succeeded (smb2pdu offset −1234, vfs.c offset +71).
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 8b57448a147d2: lore returned server errors; no thread URL.
- WebFetch of lore.kernel.org search URLs: HTTP 403.
- UNVERIFIED: reviewer comments, v2/v3 history, explicit Cc:stable in review.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: UNVERIFIED via b4. Commit is maintainer-authored and merged to origin/master.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by / bugzilla / syzbot. Bug is identified from protocol analysis, not a crash report.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Nearby origin/master ksmbd FSCTL work (support file level trim, allocation ioctl permission, allocated-range holes) is related thematically, not a hard dependency. Samba’s fsctl_zero_data() takes a WRITE strict lock and returns NT_STATUS_FILE_LOCK_CONFLICT on failure (source3/smbd/smb2_ioctl_filesys.c). That matches this fix.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: UNVERIFIED (lore 403). No local evidence this was rejected for stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: ksmbd_vfs_zero_data(), smb2_ioctl() (FSCTL_SET_ZERO_DATA), callee check_lock_range().
**Step 5.2: TRACE CALLERS**
Record:
- ksmbd_vfs_zero_data(): only smb2_ioctl() FSCTL_SET_ZERO_DATA (fs/smb/server/smb2pdu.c:8548).
- smb2_ioctl(): SMB2 command table SMB2_IOCTL_HE in fs/smb/server/smb2ops.c.
- Reachable from authenticated SMB clients issuing ioctl on an open writable handle.
**Step 5.3: TRACE CALLEES**
Record: check_lock_range() walks flc_posix under flc_lock; conflicts if overlapping READ lock vs WRITE, or WRITE lock owned by another filp. vfs_fallocate() does not check those locks.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: SMB2 IOCTL → smb2_ioctl → ksmbd_vfs_zero_data → vfs_fallocate (punch/zero). Userspace/network reachable on any ksmbd share without POSIX extensions (the common Windows-client case).
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same !posix_extensions + check_lock_range + -EAGAIN pattern in ksmbd_vfs_read (396–400), ksmbd_vfs_write (521–527), ksmbd_vfs_truncate (835–849), ksmbd_vfs_copy_file_ranges (1854–1866). Zero-data was the missing sibling. Read/write/setinfo already map -EAGAIN to STATUS_FILE_LOCK_CONFLICT; ioctl did not, which is why smb2pdu.c is patched.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. Local ksmbd_vfs_zero_data() at fs/smb/server/vfs.c:995-1013 has no lock check. git merge-base --is- ancestor 8b57448a147d2 HEAD failed (not in this tree). Bug present since ksmbd’s 2021 introduction; well before 6.12.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply with line offset. Local ioctl out mapper still lacks -EAGAIN, so both hunks are required. No refactor blocking the patch.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: Permission check for SET_ZERO_DATA is here (ca53bb17f4e82); lock-check skip-for-1-byte fix is here (f751d6e39d4c9). Neither implements this FSCTL lock check. No duplicate fix.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: ksmbd (fs/smb/server, CONFIG_SMB_SERVER, default n).
Criticality: IMPORTANT for ksmbd deployments (NAS, distros), not core mm/VFS. File-server data path.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained; this 6.12 tree already backports many ksmbd protocol, lock, and UAF fixes. Mature enough that missing lock checks are long-standing, not new-code churn.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: ksmbd users, non-POSIX SMB shares, clients that use byte-range locks and FSCTL_SET_ZERO_DATA (Windows sparse/zero APIs, some databases/backup tools).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Handle A holds an SMB lock; handle B (or another client) issues FSCTL_SET_ZERO_DATA overlapping that range with FILE_WRITE_DATA. Not every I/O, but a realistic multi-client/multi-handle case. Authenticated SMB user; not unprivileged local syscall.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Locked file data can be silently zeroed or punched. Failure
mode: data corruption / lock-semantics violation. Severity: HIGH (not a kernel oops).
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: high for ksmbd — restores lock integrity on a data-destroying FSCTL; aligns with Samba/Windows.
- Risk: very low — 18 lines, existing helper, applies cleanly, only rejects operations that should have failed.
- Ratio: strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real bug: SET_ZERO_DATA ignores byte-range locks while read/write/truncate/copychunk do not.
- User-visible: silent zero/punch of locked ranges (data integrity).
- Samba returns NT_STATUS_FILE_LOCK_CONFLICT for the same FSCTL.
- Small, obviously correct, maintainer-authored.
- Helpers and surrounding lock policy already in 6.12; patch applies cleanly.
- This tree already backported the same class (f751d6e39d4c9) and SET_ZERO_DATA access control (ca53bb17f4e82).
AGAINST:
- No crash/UAF/syzbot report.
- ksmbd is optional (CONFIG_SMB_SERVER).
- No mailing-list confirmation (lore unreachable).
- Slightly weaker than Samba on past-EOF ranges (intentional per commit message).
UNRESOLVED:
- Original lore thread / reviewer NAKs (b4 and lore failed).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — matches existing ksmbd lock checks; maintainer SOB. (No extra Tested-by.)
2. Fixes a real bug that affects users? **PASS** — lock bypass on a mutating FSCTL.
3. Important issue (crash, security, corruption, deadlock)? **PASS** — data corruption / exclusive-lock violation. HIGH, not panic.
4. Small and contained? **PASS** — 18/+1 lines, two files, one FSCTL.
5. No new features or APIs? **PASS** — enforces existing SMB lock rules.
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 important bugfix.
**Step 9.4: MAKE YOUR DECISION**
Backport. The 6.12 tree has the buggy path, the same check_lock_range() policy, and already takes ksmbd lock-correctness fixes. Benefit is lock-integrity on a data-destroying ioctl; risk is minimal.
### What the commit solves
On this 6.12 tree, FSCTL_SET_ZERO_DATA breaks oplocks and calls vfs_fallocate() without check_lock_range(). POSIX/SMB locks are not enforced by vfs_fallocate(), so another handle can zero or punch a locked range. The patch checks the range clipped to EOF and returns STATUS_FILE_LOCK_CONFLICT, matching Samba and ksmbd’s other mutating paths.
### Stable rules
Surgical, no new API, applies here, fixes real data-integrity/protocol failure. Not a feature add.
### Risk vs benefit
Benefit: prevent silent destruction of locked file data on ksmbd. Risk:
low; only newly failed requests are ones that violated locks.
### Concerns
Mailing-list review could not be fetched. Parent permission-ioctl commit is not required. ret = 0 before goto out is slightly unusual but correct given this ioctl error mapper.
Verification:
- [Phase 1] Parsed tags on 8b57448a147d2: only Namjae Jeon SOB; no Fixes/Cc:stable/Reported-by
- [Phase 1] git describe HEAD / Makefile: p-6.12-3-gc504cf0baa3d8, VERSION 6.12.111, branch pending-6.12
- [Phase 2] Diff: +12 vfs.c ksmbd_vfs_zero_data, +6/-1 smb2pdu.c FSCTL_SET_ZERO_DATA
- [Phase 2] Local smb2_ioctl out (8694–8708) maps unknown errors to STATUS_INVALID_PARAMETER, not lock conflict — smb2pdu hunk required
- [Phase 2] vfs_fallocate() in fs/open.c:246 has no posix-lock check
- [Phase 3] Blame: zero_data from 2021 cifsd; no lock check ever; git merge-base --is-ancestor 8b57448a147d2 HEAD → not ancestor
- [Phase 3] Related in-tree: f751d6e39d4c9 (1-byte lock skip), ca53bb17f4e82 (SET_ZERO_DATA FILE_WRITE_DATA)
- [Phase 3] Parent 3c707d4b3f926 is independent permission tweak, not a prerequisite
- [Phase 3] git apply --check of 8b57448a147d2: both hunks apply (offsets −1234 / +71)
- [Phase 4] b4 dig -c 8b57448a147d2: lore errors, no thread — UNVERIFIED review discussion
- [Phase 4] lore WebFetch 403 — UNVERIFIED stable-list discussion
- [Phase 4] Samba fsctl_zero_data uses STRICT_LOCK WRITE and returns NT_STATUS_FILE_LOCK_CONFLICT (web/source confirmation)
- [Phase 5] Only caller of ksmbd_vfs_zero_data is smb2_ioctl; dispatched via SMB2_IOCTL_HE
- [Phase 5] check_lock_range already used for read/write/truncate/copychunk in this tree
- [Phase 6] Local ksmbd_vfs_zero_data (vfs.c:995–1013) matches pre- patch; bug exists here
- [Phase 8] Failure mode: zero/punch of locked ranges → data integrity HIGH
- UNVERIFIED: original lore review comments and whether anyone nominated this for stable on the list
**YES**
fs/smb/server/smb2pdu.c | 7 ++++++- fs/smb/server/vfs.c | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-)
fs/smb/server/smb2pdu.c +6 -1
@@ -8665,8 +8665,13 @@ int smb2_ioctl(struct ksmbd_work *work) ret =ksmbd_vfs_zero_data (work, fp, off, len);ksmbd_fd_put (work, fp); -if (ret <0 ) +if (ret == -EAGAIN ) { + rsp->hdr.Status =STATUS_FILE_LOCK_CONFLICT ; + ret =0 ; goto out; + }else if (ret <0 ) { + goto out; + } }break ; }
fs/smb/server/vfs.c +12 -0
@@ -1003,6 +1003,18 @@ int ksmbd_vfs_zero_data(struct ksmbd_work *work, struct ksmbd_file *fp,int err;smb_break_all_levII_oplock (work, fp,1 ); +if (!work->tcon->posix_extensions) { +loff_t size =i_size_read (file_inode (fp->filp)); + +if (off < size) { + err =check_lock_range (fp->filp, off, +min (off + len, size) -1 , +WRITE ); +if (err) +return -EAGAIN ; + } + } + saved_cred =override_creds (fp->filp->f_cred);if (fp->f_ci->m_fattr &FILE_ATTRIBUTE_SPARSE_FILE_LE ) err = vfs_fallocate(fp->filp,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 platform/x86: msi-ec: Add MSI Katana GF76 11UEK EC firmware
In reply to Sasha LevinFrom: Yaroslav Dudkov <[email protected]>
[ Upstream commit 0b30e6e583b2988864ffa7aeb2905bc2d0c7d575 ]
Add the firmware string '17L1EMS1.107' to the ALLOWED_FW_13 array. This enables Embedded Controller support, including battery charge thresholds, for the MSI Katana GF76 11UEK (MS-17L1) laptop.
Tested on MSI Katana GF76 11UEK with EC firmware 17L1EMS1.107 and BIOS E17L1IMS.312.
---
LLM Generated explanations, may be completely bogus:
I have enough to decide: this is a one-line firmware-ID addition to an existing msi-ec table that already exists in this 6.12 tree.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
- Subsystem: platform/x86: msi-ec
- Action verb: **Add**
- Claimed intent: add EC firmware string for MSI Katana GF76 11UEK
Record: [platform/x86 msi-ec] [add] [allowlist EC firmware 17L1EMS1.107 for Katana GF76 11UEK]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Fixes: none (expected)
- Reported-by: none
- Tested-by: none as a tag; body says tested on the target laptop
- Reviewed-by: Ilpo Järvinen <[email protected]> (pdx86 maintainer)
- Acked-by: none
- Link: https://patch.msgid.link/20260807180553.869371-1- [email protected]
- Cc: stable: none (expected)
- Signed-off-by: Yaroslav Dudkov (author); Ilpo Järvinen (maintainer)
- Ignore: any Sasha Levin SOB / [Upstream commit ...] pipeline markers
Record: Author SOB + maintainer Reviewed-by/SOB + lore msgid link. No syzbot. No Fixes.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Bug: this laptop’s EC firmware is not in the driver’s allowlist, so msi-ec refuses to load.
- Symptom: no in-kernel EC extras, including battery charge thresholds.
- Version info: tested with EC 17L1EMS1.107, BIOS E17L1IMS.312, board MS-17L1.
- Root cause: firmware-string matching is how this driver binds; missing string means -EOPNOTSUPP.
Record: [unsupported firmware string] [driver does not load / no charge thresholds] [Katana GF76 11UEK] [allowlist gap, not a logic bug]
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: [Not a hidden UAF/race/leak fix. It is hardware enablement via firmware ID, which stable rules treat as a device-ID addition.]
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
- File: drivers/platform/x86/msi-ec.c
- +1 line, 0 removed
- Data only: ALLOWED_FW_13[]
- Scope: single-file, one-line table addition
Record: [msi-ec.c +1] [ALLOWED_FW_13] [surgical ID addition]
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Before: ALLOWED_FW_13 is only "1594EMS1.109" (Prestige 16 Studio A13VE).
After: also "17L1EMS1.107" (Katana GF76 11UEK).
Path: __init firmware match in load_configuration(). Other models unchanged.
Record: [init allowlist miss → exact-match bind to existing CONF13]
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Category: **h) Hardware workarounds / device ID addition**
Mechanism: driver matches EC firmware with match_string() against CONFIGS[]. Unknown FW logs Firmware version is not supported and returns -EOPNOTSUPP. Adding the string attaches this model to existing CONF13 (charge control at 0xd7, etc.).
Record: [device/firmware ID] [missing allowlist entry; add string to existing config]
**Step 2.4: ASSESS THE FIX QUALITY**
- Minimal, obviously correct as an ID add.
- Author tested on the machine; maintainer reviewed.
- Regression risk is confined to this firmware string. Wrong map could write bad EC registers, but the string is unique and the author tested it.
- No API, locking, or hot-path change.
Record: [high quality, 1-line] [risk limited to this FW ID]
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**git blame -L 1055,1058 -- drivers/platform/x86/msi-ec.c:
- ALLOWED_FW_13 and "1594EMS1.109" introduced in 8abba08944663 (Nikita Kravets, 2023-10-06), platform/x86: msi-ec: Add more EC configs.
- Driver itself: 392cacf2aa10d (2023-03-27), contained in v6.4-rc1.
Record: [allowlist table from 8abba08944663 / v6.7 era] [driver since v6.4; present in this 6.12 tree]
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: [No Fixes: tag; not applicable. This does not revert a regression; it adds an ID.]
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
This tree’s msi-ec.c history is short. Same pattern already present here:03f404cbe8e9e platform/x86: msi-ec: Add support for MSI Pulse GL66 12th Gen — one firmware string added to ALLOWED_FW_10.
Record: [related: Pulse GL66 one-line FW add already in this tree] [standalone, not patch X/Y]
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**git log --author='Yaroslav Dudkov' -- drivers/platform/x86/: empty in this tree.
Original recipients were [email protected] (msi-ec author), Hans de Goede, Ilpo Järvinen.
Record: [first-time contributor for this file here] [reviewed/applied by pdx86 maintainer]
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Needs ALLOWED_FW_13 / CONF13 / CONFIGS[] entry. All exist in this checkout. Context around the hunk matches the patch exactly.
Record: [no missing prereqs] [applies standalone]
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**b4 dig -c could not be used: original SHA ef2c7d3b75d9270979f9a3fb32edee811c383fbc is not in this repo (`fatal:
Not a valid commit name`).
Fallback: b4 mbox on msgid [email protected] — 2-message thread.
lore/openwall: https://lists.openwall.net/linux-kernel/2026/08/07/1803
Apply ack: https://lists.openwall.net/linux-kernel/2026/08/18/1409
Single v1 patch (not a series). Ilpo applied it unchanged to review- ilpo-next. No NAK, no v2.
Record: [v1 applied as-is] [commit ef2c7d3b75d9…] [no reviewer concerns]
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
To/Cc from the mbox: Nikita Kravets, Hans de Goede, Ilpo Järvinen, platform-driver-x86, linux-kernel.
Record: [pdx86 maintainers on To; Ilpo Reviewed-by and applied]
**Step 4.3: SEARCH FOR THE BUG REPORT**
No bugzilla/syzbot. Author is the tester. Downstream msi-ec issues show Katana GF76 17L1* users hitting “firmware not supported” (related 11UG/.106, not this exact .107/11UEK). Confirms the allowlist is how support is gated.
Record: [hardware enablement submitted by device owner] [same failure mode seen on sibling 17L1 models downstream]
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: [standalone 1/1; no series dependencies]
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Web search of lore.kernel.org/stable for this model/firmware returned unrelated hits.
Record: [no stable-list discussion found for this ID]
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Diff does not change functions. Runtime users of the table:load_configuration() via CONFIGS[i]->allowed_fw.
Record: [data: ALLOWED_FW_13] [consumer: load_configuration()]
**Step 5.2: TRACE CALLERS** load_configuration() is only called from msi_ec_init() (module_init). git grep found no other callers.
Record: [module init only; not IRQ/hot path]
**Step 5.3: TRACE CALLEES**ec_get_firmware_version() → ec_read_seq() → ec_read(). Match:match_string(). On success copies CONF13 into static conf and later battery_hook_register().
Record: [EC read + string match + optional battery hook]
**Step 5.4: FOLLOW THE CALL CHAIN**
Reachable when CONFIG_MSI_EC is enabled and DMI vendor is MSI (MICRO- STAR INT / Micro-Star International). Unprivileged userspace cannot crash other machines; only this FW string newly binds.
Record: [boot/module load on MSI laptops] [this ID only affects 17L1EMS1.107]
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Same file: many ALLOWED_FW_* arrays. This tree already has the Pulse GL66 one-line add to ALLOWED_FW_10.
Record: [standard msi-ec firmware-ID pattern]
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Local tree: branch pending-6.12, git describe HEAD = p-6.12-3-gc504cf0baa3d8, make kernelversion = **6.12.111**.
ALLOWED_FW_13 exists at drivers/platform/x86/msi-ec.c:1055 with only Prestige 1594EMS1.109. 17L1EMS1.107 is **not** present (git grep empty). git merge-base --is-ancestor ef2c7d3b… HEAD fails because that SHA is not in this object database.
Record: [yes, allowlist hole exists here] [CONF13 since 8abba08944663, in this 6.12 tree]
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Exact context is present; python check: exact context present: True. Would apply cleanly.
Record: [clean apply]
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
No Katana/17L1 string. Pulse GL66 is a sibling ID add, not a substitute.
Record: [this ID not already present]
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY** drivers/platform/x86/msi-ec.c, CONFIG_MSI_EC (ACPI + ACPI_BATTERY). Laptop EC extras: charge thresholds, etc.
Record: [platform/x86 msi-ec] [PERIPHERAL / driver-specific, but a documented device-ID exception]
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
File is mature in this tree (configs from 2023; occasional FW-ID adds).
Record: [stable driver; ID table is the ongoing extension point]
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Only MSI Katana GF76 11UEK with EC firmware 17L1EMS1.107. Everyone
else: no behavioral change.
Record: [driver-specific / one firmware ID]
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Trigger today: load msi-ec on that laptop → unsupported FW, module fails. After: driver binds, battery charge-threshold sysfs appears.
Record: [every boot/modprobe on that model] [not a security trigger for other users]
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Current: missing hardware support (charge threshold control), not oops/corruption.
Stable rules explicitly allow “just add a device ID” even without a crash.
Record: [missing device support] [MEDIUM for those users; exception category still qualifies]
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Benefit: enables EC/charge-threshold support on a real, tested laptop in 6.12.y.
Risk: one unique string; existing CONF13; no shared-path change. Residual risk is a wrong EC map for this ID only, mitigated by on- hardware testing + maintainer review.
Record: [benefit: hardware enablement] [risk: very low] [favorable]
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Documentation/process/stable-kernel-rules.rst: patches may “just add a device ID”; this driver’s IDs are EC firmware strings.
- Driver + CONF13 already in 6.12.111; only the ID is new.
- +1 line, exact context match, clean apply.
- Tested on the Katana GF76 11UEK; Reviewed-by pdx86 maintainer; applied as v1.
- No effect on other firmware versions.
- Same class of change already in this tree (Pulse GL66 → ALLOWED_FW_10).
AGAINST:
- Not a crash/UAF/corruption fix.
- Author is not the original msi-ec author (mitigated by maintainer review and testing).
- Wrong config would be bad for this model only (unverified beyond author’s test + review).
UNRESOLVED:
- Could not b4 dig -c the mainline SHA (not in this clone).
- lore.kernel.org HTTP fetch returned 403; used b4 mbox + openwall/LKML mirrors.
- No stable@ thread found.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — 1-line ID; tested on target; maintainer reviewed.
2. Fixes a real bug that affects users? **PASS** — as device-ID enablement; without it the driver refuses this laptop.
3. Important issue? **PASS** under the device-ID exception (not a panic).
4. Small and contained? **PASS** — +1 line, one file.
5. No new features or APIs? **PASS** — no new ABI; existing CONF13/sysfs for a new ID.
6. Can apply to the local tree? **PASS** — CONF13 present; context identical.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: [NEW DEVICE ID — EC firmware string on an existing driver/config]
**Step 9.4: MAKE YOUR DECISION**
This is a textbook stable device-ID addition. The local 6.12 tree already has msi-ec and ALLOWED_FW_13; the patch only names one more firmware. Benefit is real for Katana GF76 11UEK users; regression risk for everyone else is essentially zero.
Verification:
- [Phase 1] Parsed subject/tags/body: Add firmware ID; Reviewed-by Ilpo; Link msgid 20260807180553.869371-1; tested on 17L1EMS1.107 / BIOS E17L1IMS.312
- [Phase 2] Diff: +1 line in ALLOWED_FW_13[] in drivers/platform/x86/msi-ec.c
- [Phase 3] git blame -L 1055,1058: table from 8abba08944663 (2023-10-06); driver 392cacf2aa10d since v6.4
- [Phase 3] No Fixes: tag; sibling ID add 03f404cbe8e9e (Pulse GL66) already in this tree
- [Phase 3] git log --author='Yaroslav Dudkov' -- drivers/platform/x86/: empty here
- [Phase 4] b4 dig -c ef2c7d3b…: SHA not in this repo; used b4 mbox msgid instead (2 messages)
- [Phase 4] Maintainer applied v1 unchanged as ef2c7d3b75d9270979f9a3fb32edee811c383fbc; no NAK
- [Phase 4] Recipients: Kravets, de Goede, Järvinen, platform-driver-x86
- [Phase 4] No stable@ discussion found
- [Phase 5] Callers: load_configuration() ← msi_ec_init() only; match via match_string()
- [Phase 6] git describe HEAD: p-6.12-3-gc504cf0baa3d8; make kernelversion: 6.12.111
- [Phase 6] 17L1EMS1.107 absent; exact ALLOWED_FW_13 context present; would apply cleanly
- [Phase 7] CONFIG_MSI_EC in drivers/platform/x86/Kconfig; not staging
- [Phase 8] Failure mode: module load -EOPNOTSUPP / missing charge thresholds on one MSI model; severity MEDIUM, device-ID exception
- UNVERIFIED: exact EC-map correctness beyond author test + maintainer review; mainline object ef2c7d3b not fetchable from this clone
This one-line firmware-ID addition matches stable’s device-ID exception, applies cleanly to this 6.12 tree, and does not change behavior for any other hardware.
**YES**
drivers/platform/x86/msi-ec.c | 1 + 1 file changed, 1 insertion(+)
drivers/platform/x86/msi-ec.c +1 -0
@@ -1054,6 +1054,7 @@ static struct msi_ec_conf CONF12 __initdata = {static const char *const ALLOWED_FW_13 []__initconst = {"1594EMS1.109" ,// MSI Prestige 16 Studio A13VE +"17L1EMS1.107" ,// MSI Katana GF76 11UEK NULL };
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 comedi: pcmmio: Add sanity check to interrupt handler
In reply to Sasha LevinFrom: Ian Abbott <[email protected]>
[ Upstream commit ea72e2fc9026f375314421ddfa4dbdc49432a899 ]
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:
This is a 3-line IRQ-handler guard against a KASAN NULL deref in an existing COMEDI driver. The local tree is **Linux 7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The driver and the buggy attach/IRQ ordering are present here; the patch is self-contained.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[comedi: pcmmio:] [Add] [sanity check in interrupt_pcmmio() so a premature IRQ cannot dereference a NULL dev->read_subdev]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected for this review)
- **Cc: stable:** none (expected; not a negative signal)
- **Reported-by:** Jaeyoung Chung <[email protected]>; Sangyun Kim <[email protected]>; Kyungwook Boo <[email protected]> (three reporters)
- **Link:** https://lore.kernel.org/lkml/20260610115912.780131-1-
[email protected]/ (original KASAN/NULL-deref report)
- **Link:**
https://patch.msgid.link/[email protected]
(patch 09/11 of Ian Abbott’s series; msgid -10 is 0-based git-send- email numbering)
- **Signed-off-by:** Ian Abbott (author, COMEDI maintainer); Greg Kroah- Hartman (COMEDI co-maintainer / applied the patch)
- Ignore pipeline SOBs/upstream markers if present.
Notable: three reporters and an explicit KASAN NULL-deref report that names pcmmio.c.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** pcmmio_attach() calls request_irq() after disabling board interrupt generation, but **before** subdevices are allocated and before dev->read_subdev is set. dev->attached is only set later in comedi_device_postconfig().
- **Symptom:** premature IRQ → interrupt_pcmmio() uses a NULL read_subdev → NULL deref in pcmmio_handle_dio_intr().
- **Trigger (author):** should not happen on good hardware with a correct I/O base and IRQ; can happen if the user-configured I/O base/IRQ is wrong or the hardware is bad.
- **Root cause:** IRQ handler registered before the comedi device is fully set up.
- **Version info:** none in the message. Driver dates to 2009.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not a disguised cleanup.** Subject says “Add sanity check”; body describes a NULL deref. Cover letter: “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/pcmmio.c — **+3 / −0**
- **Function:** interrupt_pcmmio()
- **Scope:** single-file, surgical
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** handler always copies s = dev->read_subdev, then inb() of the pending register; if any pending bits are set, calls pcmmio_handle_dio_intr(dev, s, triggered).
- **After:** if !dev->attached, return IRQ_NONE before touching the pending register or s.
- **Path:** IRQ during attach (and any other time attached is false). Not a new userspace API.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[NULL pointer dereference / memory safety]**
- pcmmio_handle_dio_intr() does struct comedi_cmd *cmd = &s->async->cmd; as its first real use of s. If s is NULL, that is a kernel oops.
- s = dev->read_subdev is only a pointer copy; the crash is the later use. The attached check sits before that use.
- pcmmio_attach() order (verified in this tree): pcmmio_reset() → request_irq(..., interrupt_pcmmio, ...) → comedi_alloc_subdevices() → dev->read_subdev = s. comedi_device_attach() then calls comedi_device_postconfig(), which sets dev->attached = true last.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Quality:** matches the long-standing COMEDI pattern (if (!dev->attached) return IRQ_NONE;) used in many drivers (das800, comedi_parport, ni_660x, etc.).
- **Minimal:** three lines, no API/data-structure change.
- **Regression risk:** very low. Returning IRQ_NONE for an unattached device is correct (this IRQ is requested with flags 0, not shared).
- **Not a follow-up candidate:** sibling “Fix sanity check” patches moved an *existing* attached test *before* a real dereference (s->async->cmd). Here the new test is before s is used. No later pcmmio follow-up exists on this file.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Handler introduced with the driver: 6baef150380d5 (“Staging: comedi:
add pcmmio and pcmuio drivers”, 2009-04-03, contained in v2.6.30-rc1).
- s = dev->read_subdev from 19e0bf12358e59 (2013).
- Driver left staging in 8ffdff6a8cfbd (2021-04-15, v5.13).
- Buggy ordering (IRQ before read_subdev) has been in this code for many years, including this 7.3 tree.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Bug is the original attach/IRQ ordering, not a recent regression.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES** Record:
- Same-file recent commit: 78ba300a99917 “comedi: pcmmio: Add sanity checks for I/O base address” — **independent**; this IRQ patch does not use that helper.
- This commit is standalone. Cover letter lists it as **9/11**; each patch is a different driver. No shared helper, no data-structure prerequisite.
- No later pcmmio commits after ea72e2fc9026f on this file.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Ian Abbott is **the COMEDI maintainer**. Same-day series adds/fixes the same attached check in aio_iiro_16, das6402, dt2811, ni_at_a2150, ni_atmio16d, pcl711, pcl816, pcl818, pcmmio, pcmuio, quatech_daqp_cs. Earlier 17221216ae8ce (“comedi: comedi_parport: deal with premature interrupt”) is the same class, and that one had syzbot + Cc: stable.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **None required.** dev->attached and interrupt_pcmmio() exist in this tree. Patch applies as a 3-line insertion.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **b4 dig:**
https://patch.msgid.link/[email protected]
- **Series:** v1 only ([PATCH 01/11] … 11/11), 2026-06-18. No v2/v3.
- **Cover letter:** “comedi: Add/fix sanity check in ISA drivers to avoid null-ptr-deref”. Names pcmmio among the reported drivers.
- **Mbox:** 12 messages, all from the author (cover + 11 patches). **No replies, no NAK, no reviewer Cc: stable.** Greg applied the series.
- Lore HTML fetch returned **403**; discussion recovered via b4 dig -m and b4 mbox.
**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, and the three reporters. Maintainers were on the original mail. No extra Reviewed-by/Acked-by.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record (original mail, msgid [email protected]):
- Subject: **“comedi: KASAN null-ptr-deref in ISA driver IRQ handlers on early IRQ”**
- Explicitly lists **pcmmio.c / interrupt_pcmmio() / pcmmio_attach()**
- Mechanism: request_irq() before dev->read_subdev = s; handler then uses a NULL subdevice
- Suggested fix: move request_irq() later **or** guard the handler
- Ian chose the established attached-flag guard (same as many other COMEDI drivers)
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 11 independent per-driver patches. This one does not need the others. The parport sibling (17221216ae8ce) already has Cc: stable because syzbot hit comedi_parport. Same bug class.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** for lore.kernel.org/stable (HTTP 403). The submission mbox has no stable-list discussion.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: interrupt_pcmmio() modified; callees of interest:pcmmio_handle_dio_intr(), pcmmio_attach().
**Step 5.2: TRACE CALLERS**
Record:
- interrupt_pcmmio is registered only from pcmmio_attach() via request_irq(it->options[1], interrupt_pcmmio, 0, ...).
- Attach is reached from comedi_device_attach() ← do_devconfig_ioctl() (COMEDI_DEVCONFIG). That ioctl requires **CAP_SYS_ADMIN**.
- Context: hard IRQ. Not a hot syscall path for unprivileged users.
**Step 5.3: TRACE CALLEES**
Record: inb() of PCMMIO_INT_PENDING_REG; pcmmio_dio_read/write; pcmmio_handle_dio_intr() which immediately does &s->async->cmd.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record:
- Reachable from userspace **with CAP_SYS_ADMIN**: load pcmmio, COMEDI_DEVCONFIG with an IRQ in options[1].
- Crash window: IRQ between request_irq() and dev->attached = true.
- If the pending register reads as zero, the old handler returned IRQ_NONE without using s. The NULL deref needs a premature IRQ **and** a non-zero pending read (wrong I/O base returning garbage, or bad/mis-routed hardware). That is exactly the ISA comedi_config model, and it is how syzbot hit parport.
- **Not** unprivileged-triggerable. Still a real kernel oops on a supported ioctl.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: dozens of COMEDI IRQ handlers already check dev->attached. This is aligning pcmmio with that pattern, not inventing a new one.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.**
- Tree: **7.3.0-rc4** (mainline-like checkout, detached HEAD).
- drivers/comedi/drivers/pcmmio.c exists; pcmmio_attach() still requests the IRQ before read_subdev and before postconfig sets attached.
- Commit ea72e2fc9026f **is** an ancestor of HEAD (git merge-base --is-ancestor exit 0). That is expected for a mainline candidate; it is **not** used as “already selected for stable.”
- Bug introduced ~2009, not after this tree branched.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** Hunk is a 3-line insert into a handler whose shape has been stable since 2013. No refactor of this function in this tree beyond this commit.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This is the fix. No alternate pcmmio IRQ NULL-deref fix. The I/O-base check (78ba300a99917) is a different issue and is not required for this hunk.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **[drivers/comedi — COMEDI DAQ]** **[PERIPHERAL]** Winsystems PCM-MIO PC/104 board (CONFIG_COMEDI_PCMMIO). Niche industrial hardware, but a real in-tree driver (out of staging since v5.13).
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature. Ian Abbott still actively fixing ISA attach/IRQ races in 2026. Not staging.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **driver-specific / config-specific** — users who load pcmmio and attach it with an IRQ via comedi_config.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Trigger: attach with options[1] (IRQ) set; IRQ fires before attached; pending register reads non-zero.
- Likelihood on correctly jumpered good hardware: low (driver disables interrupt generation before request_irq()).
- Likelihood with wrong I/O base/IRQ (admin ioctl, fuzzer, bad card):
realistic. Original report treated it as a KASAN NULL deref across several ISA drivers, including this one.
- Unprivileged: **no** (CAP_SYS_ADMIN for COMEDI_DEVCONFIG).
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Kernel oops / KASAN null-ptr-deref** → **HIGH** (crash of the machine or at least the IRQ path; not data corruption on a mounted fs, but a serious crash).
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** prevents a documented NULL deref oops on a long-lived driver. High for anyone who hits it; population is small.
- **Risk:** very low (3 lines, established pattern, IRQ_NONE on unattached device).
- **Ratio:** favorable. Small crash fixes in obscure drivers are standard stable material.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR backporting:**
- Real NULL deref in an IRQ handler; original report is titled as KASAN null-ptr-deref and names this file.
- Three reporters; maintainer-authored; applied by Greg KH.
- 3-line, obviously correct, same pattern as many other COMEDI drivers.
- Buggy ordering has been in the driver since 2009; present in this tree.
- Standalone; no prerequisites; clean apply.
- Sibling parport fix of the same class was nominated for stable (syzbot).
- Sanitizer-class crash; stable rules treat serious crashes as in-scope even for niche drivers.
**AGAINST:**
- Niche PC/104 board; interrupt support in the driver comments is “untested.”
- Author frames it as “for safety” and says a premature IRQ needs bad config/hardware.
- Needs CAP_SYS_ADMIN to attach.
- No Fixes:/Cc: stable on this specific commit (absence is expected here; still a weaker signal than parport).
- No mailing-list review replies.
**UNRESOLVED:**
- Could not search lore.kernel.org/stable (403).
- Original report has no pcmmio-specific reproducer/stack in the mail body (code analysis + KASAN class).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — 3-line attached check, established COMEDI idiom; applied by subsystem maintainers.
2. Fixes a real bug that affects users? **PASS** — NULL deref if IRQ runs before attach completes; reported against this driver.
3. Important issue? **PASS** — kernel oops / KASAN null-ptr-deref (HIGH, not a core-mm panic, but a serious crash).
4. Small and contained? **PASS** — +3 lines, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — file and handler exist; hunk is trivial.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: none (not a device ID, quirk, DT, build, or docs exception). It qualifies as a normal crash fix.
**Step 9.4: MAKE YOUR DECISION**
This tree has the driver, the attach/IRQ race, and the NULL deref path. The patch is a minimal, standard guard. Privilege and niche hardware lower the blast radius; they do not make a KASAN NULL deref in an IRQ handler unsuitable for stable.
===============================================================
What the commit solves, and why it matters here
===============================================================
pcmmio_attach() registers interrupt_pcmmio before subdevices exist and before dev->attached is set. If that handler runs in that window and the pending register is non-zero, pcmmio_handle_dio_intr() dereferences a NULL read_subdev (s->async->cmd) and oopses. The patch returns IRQ_NONE until the device is fully attached.
That matches the original SNU report and the usual COMEDI IRQ-safety pattern. For this 7.3 checkout the code exists, the fix is three lines, and regression risk is negligible.
===============================================================
Verification
===============================================================
- **[Phase 1]** Parsed tags: three Reported-by; two Links; no Fixes:/Cc:
stable; SOBs Ian Abbott + Greg KH.
- **[Phase 1]** Cover letter (mbox): series is explicitly “avoid null- ptr-deref”; pcmmio is listed.
- **[Phase 2]** Diff: +3 lines in interrupt_pcmmio() only.
- **[Phase 2]** Read pcmmio_attach(): request_irq at line 688, read_subdev at 749; comedi_device_postconfig() sets attached after attach() returns.
- **[Phase 2]** Read pcmmio_handle_dio_intr(): first use of s is &s->async->cmd.
- **[Phase 3]** git blame: handler from 2009 (6baef150380d5); this check from ea72e2fc9026f.
- **[Phase 3]** git log --oneline -20 -- drivers/comedi/drivers/pcmmio.c: no later pcmmio follow-up.
- **[Phase 3]** No Fixes: tag to follow.
- **[Phase 4]** b4 dig -c ea72e2fc9026f: lore URL [email protected].
- **[Phase 4]** b4 dig -a: v1 series only, 11 patches.
- **[Phase 4]** b4 dig -w: Greg KH + Hartley Sweeten + reporters on Cc.
- **[Phase 4]** b4 mbox of [email protected]: KASAN report names interrupt_pcmmio.
- **[Phase 4]** UNVERIFIED: lore.kernel.org HTML and stable@ search (403).
- **[Phase 5]** Callers: only request_irq from pcmmio_attach; ioctl path needs CAP_SYS_ADMIN (do_devconfig_ioctl).
- **[Phase 6]** git describe HEAD / make kernelversion:
**7.3.0-rc4**.
- **[Phase 6]** git merge-base --is-ancestor ea72e2fc9026f HEAD: yes (candidate is in this history).
- **[Phase 8]** Failure mode: NULL deref oops in IRQ handler; severity HIGH.
- **UNVERIFIED:** live reproduction on PCM-MIO hardware (not available).
The fix is small, surgical, and meets the stable criteria for a real crash.
**YES**
drivers/comedi/drivers/pcmmio.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/comedi/drivers/pcmmio.c +3 -0
@@ -362,6 +362,9 @@ static irqreturn_t interrupt_pcmmio(int irq, void *d)unsigned int triggered;unsigned char int_pend; +if (!dev->attached) +return IRQ_NONE ; +/* are there any interrupts pending */ int_pend =inb (dev->iobase +PCMMIO_INT_PENDING_REG ) &0x07 ;if (!int_pend)
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 drm/virtio: abort virtqueue wait on device removal to avoid hung task
In reply to Sasha LevinFrom: Ryosuke Yasuoka <[email protected]>
[ Upstream commit a46991b334f663fa0e0e9c051e50587ef977ac8b ]
virtio_gpu_queue_ctrl_sgs() and virtio_gpu_queue_cursor() use wait_event() without any abort condition when waiting for virtqueue space. If the host device stops processing commands, these waits block indefinitely inside a drm_dev_enter/exit() critical section. Since drm_dev_unplug(), which is called in device removal and system shutdown call path, blocks on synchronize_srcu() until all critical sections complete, device removal and system shutdown also hang.
Add a vqs_released flag to virtio_gpu_device and include it in the wait_event() condition. Set the flag and wake up both queues in a new virtio_gpu_release_vqs() helper, called before drm_dev_unplug() in both virtio_gpu_remove() and virtio_gpu_shutdown(). When the flag is set, the wait returns immediately and the command is aborted, following the same cleanup path as drm_dev_enter() failure.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
Record: [drm/virtio] [abort] abort virtqueue wait on device removal to avoid hung task
**Step 1.2 — Tags**
Record:
- Signed-off-by: Ryosuke Yasuoka <[email protected]> (author)
- Signed-off-by: Dmitry Osipenko <[email protected]> (virtio-gpu maintainer)
- `Link: https://patch.msgid.link/20260601-virtio-
[email protected]`
- No Fixes:, Reported-by:, Cc: stable on the committed v3 (absence is expected here)
v2 originally had two syzbot Reported-by/Closes tags. v3 changelog:
*“Remove Reported-by and Closes tag from commit msg because they are not related to this fix.”* Those syzbot hung-task reports are a different probe-time deadlock, already fixed in this tree by 89890a5fcefad.
**Step 1.3 — Body**
Record:
- **Bug:** wait_event() on ctrl/cursor virtqueue space has no abort. If the host stops processing commands, the waiter stays in D-state inside drm_dev_enter()/drm_dev_exit().
- **Symptom:** drm_dev_unplug() (remove and shutdown) blocks forever on synchronize_srcu(), so device removal and system shutdown hang (INFO: task hung).
- **Root cause:** uninterruptible wait holds an SRCU critical section that unplug must drain.
- **Fix:** vqs_released flag + wake_up_all() before unplug; abort with the same cleanup as drm_dev_enter() failure (-ENODEV / free vbuf).
- **Versions:** none named in the message. The wait + drm_dev_enter wrapping has been in this driver since 2020.
**Step 1.4 — Hidden bug fix?**
Record: Not hidden. Subject and body describe a hang/deadlock. It is a real teardown hang, not cleanup-as-style.
---
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
Record:
- virtgpu_drv.c: +15 — new virtio_gpu_release_vqs(), called from virtio_gpu_remove() and virtio_gpu_shutdown()
- virtgpu_drv.h: +1 — bool vqs_released on struct virtio_gpu_device
- virtgpu_vq.c: +21/−2 — abort conditions in virtio_gpu_queue_ctrl_sgs() and virtio_gpu_queue_cursor()
- Scope: ~37 insertions, 2 deletions, three files, one driver. Surgical.
**Step 2.2 — Flow**
Record:
- **Before:** if vq->num_free is short, unlock, notify host, wait_event(ack_queue, num_free >= needed) with no timeout/abort, still inside drm_dev_enter().
- **After:** wait also succeeds when vqs_released. Then unlock resv if needed, free_vbuf(), drm_dev_exit(), return -ENODEV (ctrl) or return (cursor). Same path as drm_dev_enter() failure.
- **Teardown:** set flag, wake both ack queues, *then* drm_dev_unplug().
- Path affected: virtqueue-full wait during remove/shutdown, not the happy path.
**Step 2.3 — Bug mechanism**
Record: **Deadlock / hung-task (uninterruptible wait blocking SRCU unplug).** wait_event() is TASK_UNINTERRUPTIBLE. drm_dev_unplug() → drm_dev_synchronize_unplug() → synchronize_srcu(&drm_unplug_srcu) cannot finish while that section is held. Flag + wake_up_all() is a standard abort.
**Step 2.4 — Fix quality**
Record: Obviously correct and minimal. Abort cleanup matches existing drm_dev_enter() failure. Fence emit happens *after* the wait, so abort does not leak an emitted fence. vgdev is drmm_kzalloc()’d so vqs_released starts false. Flag is set only on remove/shutdown. Regression risk is low: happy-path wait is unchanged; abort only when tearing down. Remaining wait_event(resp_wq) in prime/vram is a separate issue (author and maintainer agreed to leave it).
---
## Phase 3: Git history
**Step 3.1 — Blame (v6.18.53)**
Record:
- Ctrl wait_event: 6ebe8661ebf27a (2020, Gerd/Chia-I) — `drm/virtio:
move locking into virtio_gpu_queue_ctrl_sgs`
- Wrapped in drm_dev_enter: b1df3a2b24a917 (2020) — drm/virtio: add drm_driver.release callback
- Cursor wait_event: d02d270014f70d (2018) / original queue from dc5698e80cf724 (2013)
- Bug has been in this driver for years; it is in 6.18.y.
**Step 3.2 — Fixes: tag**
Record: None. Introducing commits above exist in this tree.
**Step 3.3 — File history**
Record: Related in-tree: 89890a5fcefad (probe deadlock / syzbot hung task — different bug, already in v6.18.53). 2507789a724d6 implements virtio_gpu_shutdown (in v6.18.53). Later candidate 3cdc509eb471e reclaims leftover vbufs on teardown — complementary, not a prerequisite for this abort.
**Step 3.4 — Author**
Record: Ryosuke Yasuoka is a regular virtio-gpu contributor (drm_panic, the display_info deadlock fix). Signed off by maintainer Dmitry Osipenko.
**Step 3.5 — Dependencies**
Record: Standalone. Needs drm_dev_enter around queueing, virtio_gpu_remove/virtio_gpu_shutdown calling drm_dev_unplug, and ctrlq/cursorq ack waitqueues — all present at v6.18.53. No new APIs.
---
## Phase 4: Mailing list / external
**Step 4.1 — b4 dig**
Record:
- v2: https://patch.msgid.link/20260521-virtio-
[email protected]
- v3 (applied): https://patch.msgid.link/20260601-virtio-
[email protected]
- v1 used wait_event_timeout() (5s). v2/v3 switched to an explicit vqs_released flag (no arbitrary timeout). Applied version is v3.
**Step 4.2 — Recipients (b4 dig -w)**
Record: David Airlie, Gerd Hoffmann, Dmitry Osipenko, Gurchetan Singh, Chia-I Wu, drm-misc maintainers, dri-devel, [email protected]. Right people.
**Step 4.3 — Review**
Record (from saved v2 mbox):
- Dmitry: “What about other wait_event?” Author: those are resp_wq, not inside drm_dev_enter, different bug. Dmitry: leave for later.
- Dmitry could not reproduce on normal systemd shutdown and noted the syzbot stacks were not remove/shutdown. Later: *“the patch looks okay, but I'm not convinced that it fixes the reported issue.”*
- Author agreed syzbot was a probe deadlock (clientlist_mutex vs dequeue worker), dropped those tags, and described the real trigger:
host stops processing → guest waits in D-state inside drm_dev_enter → unplug’s synchronize_srcu never completes. systemd cannot kill D-state tasks.
- v3 dropped the unrelated tags; Dmitry still signed off.
**Step 4.4 — Series**
Record: Single-patch series. resp_wq abort and interruptible waits were explicitly deferred.
**Step 4.5 — stable@**
Record: lore.kernel.org/stable returned HTTP 403. UNVERIFIED whether it was already discussed on stable@.
Syzbot URLs from v2: hung in virtio_gpu_queue_fenced_ctrl_buffer during **probe** (virtio_gpu_probe → fbcon), not removal. Those are the deadlock already closed by 89890a5fcefad in this tree. They do **not** prove this particular hang, and they are not used as a YES signal for this commit.
---
## Phase 5: Semantic / call graph
**Step 5.1 — Functions**
Record: virtio_gpu_release_vqs (new), virtio_gpu_remove, virtio_gpu_shutdown, virtio_gpu_queue_ctrl_sgs, virtio_gpu_queue_cursor.
**Step 5.2 — Callers**
Record:
- virtio_gpu_queue_ctrl_sgs ← virtio_gpu_queue_fenced_ctrl_buffer ← nearly every virtio_gpu_cmd_* (ioctls, plane update/flush, GEM, etc.). Userspace and KMS both reach it.
- virtio_gpu_queue_cursor ← cursor plane updates.
- virtio_gpu_remove / virtio_gpu_shutdown are virtio .remove / .shutdown.
**Step 5.3 — Callees**
Record: drm_dev_enter/exit, wait_event, wake_up_all, free_vbuf, virtio_gpu_array_unlock_resv, virtio_gpu_notify. No new helpers outside this driver.
**Step 5.4 — Reachability**
Record: Yes. Any guest GPU submit that fills the virtqueue waits here. Unplug/shutdown is virtio remove or poweroff. Host-side virtio-gpu/virgl stall is the trigger.
**Step 5.5 — Similar patterns**
Record: wait_event(vgdev->resp_wq) in virtgpu_prime.c and virtgpu_vram.c still unbounded; not inside drm_dev_enter, so they do not block unplug. Same author deferred that.
---
## Phase 6: This tree (6.18.y)
**Step 6.1 — Buggy code present?**
Record: **Yes at v6.18.53.**
``` v6.18.53:virtgpu_vq.c:398: wait_event(vgdev->ctrlq.ack_queue, vq->num_free >= elemcnt); v6.18.53:virtgpu_vq.c:568: wait_event(vgdev->cursorq.ack_queue, vq->num_free >= outcnt); ```
vqs_released is **not** in v6.18.53. virtio_gpu_remove/shutdown call drm_dev_unplug() with no prior wake. drm_dev_synchronize_unplug() does synchronize_srcu. Bug introduced ~2020; 6.18 branched 2025-11-30.
Local tree: git describe HEAD → v6.18.53-5049-g0f0bdc2b0dffb; Makefile 6.18.53. Verdict is for **this 6.18.y tree only**.
**Step 6.2 — Backport difficulty**
Record: git apply --check of this patch onto v6.18.53 virtio files:
**clean apply**. Context differs slightly (DRIVER_ATOMIC guard around drm_atomic_helper_shutdown from 19a6a00ff50c2, already in v6.18.53); insertion is still immediately before drm_dev_unplug().
**Step 6.3 — Related fix already here?**
Record: Probe deadlock 89890a5fcefad is in v6.18.53 and does **not** abort virtqueue waits on removal. No equivalent abort exists. This is not a duplicate.
---
## Phase 7: Subsystem
**Step 7.1**
Record: drivers/gpu/drm/virtio — virtio-gpu DRM. **IMPORTANT** for VMs (QEMU/KVM, cloud, CrosVM), not core mm/VFS.
**Step 7.2**
Record: Mature driver, still getting targeted fixes. Not staging.
---
## Phase 8: Impact and risk
**Step 8.1 — Who**
Record: virtio-gpu guests (CONFIG_DRM_VIRTIO_GPU). Common in VMs, not every bare-metal box.
**Step 8.2 — Trigger**
Record: Host stops completing virtqueue commands (host renderer crash, hung device, hypervisor bug) **and** a guest command waits for ring space **and** then remove/shutdown. Not every boot. Cannot be signal- killed (TASK_UNINTERRUPTIBLE). Module unload, virtio reset, and poweroff all hit drm_dev_unplug().
**Step 8.3 — Failure mode**
Record: **Hung task / shutdown or unplug deadlock.** Severity: **HIGH** (system cannot finish shutdown/remove; D-state). Not a UAF or silent corruption.
**Step 8.4 — Risk vs benefit**
Record:
- Benefit: HIGH for virtio-gpu VMs that lose the host GPU and then reboot/unplug.
- Risk: LOW — ~35 lines, teardown-only flag, abort path copies existing -ENODEV cleanup.
- Ratio: favorable.
---
## Phase 9: Synthesis
**Step 9.1 — Evidence**
**For:**
- Real hang: uninterruptible wait inside drm_dev_enter blocks drm_dev_unplug()/synchronize_srcu.
- Confirmed in v6.18.53 source (wait_event without abort; unplug with no wake).
- Small, contained, no new API.
- Abort cleanup matches existing drm_dev_enter() failure.
- Maintainer signed off after review (v1 timeout → v3 flag).
- Applies cleanly to this tree’s virtio files.
- virtio-gpu is widely used; host GPU process failure is a realistic VM event.
**Against:**
- Trigger needs a stuck host plus a full virtqueue plus teardown — not a hot path.
- Syzbot tags were wrongly attached in v2 and correctly dropped; do not treat this as a syzbot backport.
- Incomplete vs all wait_events; resp_wq still unbounded (intentionally separate).
- Maintainer initially could not reproduce on a normal systemd shutdown.
**Unresolved:** stable@ archive 403; whether this hang has a public user report besides the author’s analysis.
**Step 9.2 — Stable rules**
1. Obviously correct and tested — **PASS** (standard wait/wake abort; maintainer SOB; v3 after review).
2. Real user-visible bug — **PASS** (remove/shutdown hang when host stops the vq).
3. Important (hang/deadlock) — **PASS** (HIGH: D-state blocks unplug/shutdown).
4. Small and contained — **PASS** (~37 lines, one driver).
5. No new features/APIs — **PASS**.
6. Applies to this tree — **PASS** (clean apply to v6.18.53 virtio files; all helpers present).
**Step 9.3 — Exceptions**
Record: None (not a device ID/quirk/DT/build/doc exception). Qualifies as a normal hang fix.
**Step 9.4 — Decision**
This belongs on 6.18.y. The bug is in this tree, the fix is surgical, and a stuck virtqueue otherwise makes guest unplug/shutdown hang forever.
---
## What the commit solves for this tree
On 6.18.y, virtio-gpu waits for virtqueue space with wait_event() inside drm_dev_enter(). If the host stops processing, that wait never ends, drm_dev_unplug() never gets past synchronize_srcu(), and remove/shutdown hang in D-state. The patch sets vqs_released, wakes both queues before unplug, and aborts the command like a failed drm_dev_enter().
That is a real hang, not a feature. Risk is low; the only extra behavior is on teardown.
---
## Verification
- **[Phase 1]** Parsed v3 message/tags; no Fixes/Reported-by on committed v3; v3 changelog documents dropping unrelated syzbot tags.
- **[Phase 2]** Diff: +37/−2 across three virtio-gpu files; abort copies drm_dev_enter() failure cleanup; fence emit is after the wait.
- **[Phase 3]** git blame on v6.18.53: wait from 6ebe8661ebf27a (2020) / cursor from 2013–2018; drm_dev_enter from b1df3a2b24a917 (2020).
- **[Phase 3]** git merge-base --is-ancestor 0ffdc5889ef64 v6.18.53 → **not** in v6.18.53; buggy wait **is** in v6.18.53.
- **[Phase 3]** Probe deadlock 89890a5fcefad **is** in v6.18.53 and closes the syzbot hung-task IDs; it does not abort vq waits on removal.
- **[Phase 3]** virtio_gpu_shutdown (2507789a724d6) **is** in v6.18.53.
- **[Phase 3]** vgdev allocated with drmm_kzalloc in virtgpu_kms.c — vqs_released starts false.
- **[Phase 4]** b4 dig -c a46991b334f663fa0e0e9c051e50587ef977ac8b matched v2/v3 lore; b4 dig -a showed v2 then v3; b4 dig -w listed virtio-gpu maintainers.
- **[Phase 4]** Mbox: Dmitry review; author explained syzbot mismatch and the real remove/shutdown hang; v3 dropped tags; Dmitry SOB on the commit.
- **[Phase 4]** WebFetch syzbot bugs d6dd6f86… / 908bd910…: hung during **probe/fbcon**, not unplug — not this bug.
- **[Phase 4]** lore.kernel.org and lore.kernel.org/stable: HTTP 403. UNVERIFIED for stable@ discussion. Used gitlab.freedesktop.org + openwall + mbox instead.
- **[Phase 5]** git grep: virtio_gpu_queue_ctrl_sgs is on ioctl/plane/GEM paths; dequeue wake_up(&ctrlq.ack_queue) only after host responses — if host is dead, waiters never wake without this patch.
- **[Phase 6]** git describe HEAD / Makefile: **6.18.53**. git apply --check of this patch onto archived v6.18.53 virtio files: **APPLY CLEAN**.
- **[Phase 6]** drm_dev_unplug at v6.18.53 calls drm_dev_synchronize_unplug() → synchronize_srcu.
- **[Phase 6]** wait_event() in include/linux/wait.h uses TASK_UNINTERRUPTIBLE.
- **[Phase 8]** Failure mode from code + commit: hung unplug/shutdown, severity HIGH.
- **UNVERIFIED:** public non-syzbot user report of this exact remove hang; stable@ archive (403).
The hang is in this 6.18.y tree, the patch is small and correct, and it should be backported.
**YES**
drivers/gpu/drm/virtio/virtgpu_drv.c | 15 +++++++++++++++ drivers/gpu/drm/virtio/virtgpu_drv.h | 1 + drivers/gpu/drm/virtio/virtgpu_vq.c | 23 +++++++++++++++++++++-- 3 files changed, 37 insertions(+), 2 deletions(-)
drivers/gpu/drm/virtio/virtgpu_drv.c +15 -0
@@ -118,10 +118,24 @@ static int virtio_gpu_probe(struct virtio_device *vdev)return ret; } +/* +* Release pending virtqueue waits so the drm_dev_enter/exit() critical +* sections complete before drm_dev_unplug() blocks on synchronize_srcu(). +*/ +static void virtio_gpu_release_vqs (struct drm_device *dev) +{ +struct virtio_gpu_device *vgdev = dev->dev_private; + + vgdev->vqs_released = true; +wake_up_all (&vgdev->ctrlq.ack_queue); +wake_up_all (&vgdev->cursorq.ack_queue); +} +static void virtio_gpu_remove (struct virtio_device *vdev) {struct drm_device *dev = vdev->priv; +virtio_gpu_release_vqs (dev);drm_dev_unplug (dev);if (drm_core_check_feature (dev,DRIVER_ATOMIC ))
@@ -135,6 +149,7 @@ static void virtio_gpu_shutdown(struct virtio_device *vdev) {struct drm_device *dev = vdev->priv; +virtio_gpu_release_vqs (dev);/* stop talking to the device */ drm_dev_unplug (dev); }
drivers/gpu/drm/virtio/virtgpu_drv.h +1 -0
@@ -260,6 +260,7 @@ struct virtio_gpu_device {struct virtio_gpu_queue ctrlq;struct virtio_gpu_queue cursorq; +bool vqs_released;struct kmem_cache *vbufs;atomic_t pending_commands;
drivers/gpu/drm/virtio/virtgpu_vq.c +21 -2
@@ -422,7 +422,19 @@ static int virtio_gpu_queue_ctrl_sgs(struct virtio_gpu_device *vgdev,if (vq->num_free < elemcnt) {spin_unlock (&vgdev->ctrlq.qlock);virtio_gpu_notify (vgdev); -wait_event (vgdev->ctrlq.ack_queue, vq->num_free >= elemcnt); +wait_event (vgdev->ctrlq.ack_queue, + vq->num_free >= elemcnt || vgdev->vqs_released); +/* +* Set by virtio_gpu_release_vqs() to unblock +* synchronize_srcu() wait in drm_dev_unplug(). +*/ +if (vgdev->vqs_released) { +if (fence && vbuf->objs) +virtio_gpu_array_unlock_resv (vbuf->objs); +free_vbuf (vgdev, vbuf); +drm_dev_exit (idx); +return -ENODEV ; + } goto again; }
@@ -592,7 +604,14 @@ static void virtio_gpu_queue_cursor(struct virtio_gpu_device *vgdev, ret =virtqueue_add_sgs (vq, sgs, outcnt,0 , vbuf,GFP_ATOMIC );if (ret == -ENOSPC ) {spin_unlock (&vgdev->cursorq.qlock); -wait_event (vgdev->cursorq.ack_queue, vq->num_free >= outcnt); +wait_event (vgdev->cursorq.ack_queue, + vq->num_free >= outcnt || vgdev->vqs_released); +/* See comment in virtio_gpu_queue_ctrl_sgs(). */ +if (vgdev->vqs_released) { +free_vbuf (vgdev, vbuf); +drm_dev_exit (idx); +return ; + }spin_lock (&vgdev->cursorq.qlock); goto retry; }else {
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18] drm/virtio: abort virtqueue wait on device removal to avoid hung task
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] drm/virtio: un-emitted fence on abort in virtio_gpu_queue_ctrl_sgs() - [Medium] drm/virtio: leak…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] drm/virtio: un-emitted fence on abort in virtio_gpu_queue_ctrl_sgs()
- [Medium] drm/virtio: leak of vbuf->objs on abort in virtio_gpu_queue_ctrl_sgs()
- [Medium] drm/virtio: unreclaimed vbufs in virtio_gpu_deinit() on device removal --
commit 81841bb63e995940f01c6fe877305de441ff0e80
Author: Ryosuke Yasuoka <[email protected]>
drm/virtio: abort virtqueue wait on device removal to avoid hung task
This commit adds a vqs_released flag to struct virtio_gpu_device and wakes up the control and cursor virtqueue wait queues during virtio_gpu_remove() and virtio_gpu_shutdown() so that threads waiting for virtqueue space exit their drm_dev_enter() critical sections and unblock drm_dev_unplug().
Quoted 19 lines
drivers/gpu/drm/virtio/virtgpu_drv.c +11
-0@@ -118,10 +118,24 @@ static int virtio_gpu_probe(struct virtio_device *vdev)return ret; } +/* +* Release pending virtqueue waits so the drm_dev_enter/exit() critical +* sections complete before drm_dev_unplug() blocks on synchronize_srcu(). +*/ +static void virtio_gpu_release_vqs (struct drm_device *dev) +{ +struct virtio_gpu_device *vgdev = dev->dev_private; + + vgdev->vqs_released = true; +wake_up_all (&vgdev->ctrlq.ack_queue); +wake_up_all (&vgdev->cursorq.ack_queue);
drivers/gpu/drm/virtio/virtgpu_drv.c static int virtio_gpu_probe(struct virtio_device *vdev) · line 141
Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_drv.c +3
-0+} +static void virtio_gpu_remove (struct virtio_device *vdev) {struct drm_device *dev = vdev->priv; +virtio_gpu_release_vqs (dev);drm_dev_unplug (dev);if (drm_core_check_feature (dev,DRIVER_ATOMIC ))
[Severity: Medium]
When virtio_gpu_release_vqs() wakes a thread blocked on a full virtqueue, the virtqueue itself still contains all of the previously queued struct virtio_gpu_vbuffer entries that the host stopped processing.
Once drm_dev_unplug() unblocks, virtio_gpu_remove() proceeds to virtio_gpu_deinit() and drm_dev_put() -> virtio_gpu_release():
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);
vgdev->vdev->config->del_vqs(vgdev->vdev);
}drivers/gpu/drm/virtio/virtgpu_kms.c:virtio_gpu_release() {
...
virtio_gpu_modeset_fini(vgdev);
virtio_gpu_free_vbufs(vgdev);
...
}Because flush_work() on dequeue_work only reclaims buffers that the host placed into the used ring via virtqueue_get_buf(), the unconsumed vbufs left in ctrlq.vq and cursorq.vq are never detached via virtqueue_detach_unused_buf() and freed before del_vqs() and virtio_gpu_free_vbufs() -> kmem_cache_destroy(vgdev->vbufs).
Will this leak those in-flight vbufs (along with their resp_buf, data_buf, and vbuf->objs references) and trigger a "Objects remaining on __kmem_cache_shutdown()" warning in kmem_cache_destroy()?
[ ... ]
Quoted 14 lines
drivers/gpu/drm/virtio/virtgpu_vq.c +5
-1@@ -422,7 +422,19 @@ static int virtio_gpu_queue_ctrl_sgs(struct virtio_gpu_device *vgdev,if (vq->num_free < elemcnt) {spin_unlock (&vgdev->ctrlq.qlock);virtio_gpu_notify (vgdev); -wait_event (vgdev->ctrlq.ack_queue, vq->num_free >= elemcnt); +wait_event (vgdev->ctrlq.ack_queue, + vq->num_free >= elemcnt || vgdev->vqs_released); +/* +* Set by virtio_gpu_release_vqs() to unblock +* synchronize_srcu() wait in drm_dev_unplug().
drivers/gpu/drm/virtio/virtgpu_vq.c static int virtio_gpu_queue_ctrl_sgs(struct virtio_gpu_device *vgdev, · line 439
Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_vq.c +8
-0+*/ +if (vgdev->vqs_released) { +if (fence && vbuf->objs) +virtio_gpu_array_unlock_resv (vbuf->objs); +free_vbuf (vgdev, vbuf); +drm_dev_exit (idx); +return -ENODEV ; + } goto again; }
[Severity: Medium]
Does this abort path leak vbuf->objs and the GEM object references it holds?
Callers that attach a struct virtio_gpu_object_array to vbuf->objs (such as virtio_gpu_cmd_submit(), virtio_gpu_cmd_transfer_to_host_2d(), virtio_gpu_cmd_transfer_to_host_3d(), virtio_gpu_cmd_resource_flush(), and virtio_gpu_cmd_create_resource()) transfer ownership of objs to the vbuf and ignore the return value of virtio_gpu_queue_fenced_ctrl_buffer() and virtio_gpu_queue_ctrl_buffer().
On normal completion in virtio_gpu_dequeue_ctrl_func(), vbuf->objs is released before free_vbuf():
drivers/gpu/drm/virtio/virtgpu_vq.c:virtio_gpu_dequeue_ctrl_func() {
...
list_for_each_entry_safe(entry, tmp, &reclaim_list, list) {
if (entry->objs)
virtio_gpu_array_put_free_delayed(vgdev, entry->objs);
list_del(&entry->list);
free_vbuf(vgdev, entry);
}
...
}However, free_vbuf() only frees vbuf->resp_buf, vbuf->data_buf, and vbuf:
drivers/gpu/drm/virtio/virtgpu_vq.c:free_vbuf() {
if (vbuf->resp_size > MAX_INLINE_RESP_SIZE)
kfree(vbuf->resp_buf);
kvfree(vbuf->data_buf);
kmem_cache_free(vgdev->vbufs, vbuf);
}When vgdev->vqs_released is true, virtio_gpu_queue_ctrl_sgs() unlocks the reservations on vbuf->objs when fenced, but never calls virtio_gpu_array_put_free() or virtio_gpu_array_put_free_delayed() on vbuf->objs.
[Severity: High]
What happens to callers that pass a non-NULL fence when virtio_gpu_queue_ctrl_sgs() aborts here before calling virtio_gpu_fence_emit()?
Because virtio_gpu_queue_fenced_ctrl_buffer() and its callers (such as virtio_gpu_cmd_resource_detach_backing(), virtio_gpu_cmd_transfer_to_host_2d(), and virtio_gpu_cmd_submit()) have void return types and drop the -ENODEV error, the caller is not aware that virtio_gpu_fence_emit() was skipped, leaving fence->f.seqno == 0 and the fence unqueued in vgdev->fence_drv.fences.
In virtio_gpu_detach_object_fenced(), the caller immediately waits uninterruptibly on the fence:
drivers/gpu/drm/virtio/virtgpu_object.c:virtio_gpu_detach_object_fenced() {
...
virtio_gpu_object_detach(vgdev, bo, fence);
virtio_gpu_notify(vgdev);
dma_fence_wait(&fence->f, false);
dma_fence_put(&fence->f);
}Similarly, virtio_gpu_cursor_plane_update() calls dma_fence_wait(&vgplane_st->fence->f, true) right after virtio_gpu_cmd_transfer_to_host_2d(). Since the fence was never emitted and will never be signaled, won't dma_fence_wait() in virtio_gpu_detach_object_fenced() sleep forever in TASK_UNINTERRUPTIBLE and cause another hung task?
In addition, in virtio_gpu_execbuffer_ioctl():
drivers/gpu/drm/virtio/virtgpu_submit.c:virtio_gpu_execbuffer_ioctl() {
...
virtio_gpu_submit(&submit);
virtio_gpu_install_out_fence_fd(&submit);
virtio_gpu_process_post_deps(&submit);
virtio_gpu_complete_submit(&submit);
cleanup:
if (ret && submit.out_fence && submit.out_fence->e) {
drm_event_cancel_free(dev, &submit.out_fence->e->base);
submit.out_fence->e = NULL;
}
virtio_gpu_cleanup_submit(&submit);
return ret;
}Because virtio_gpu_submit() does not propagate the abort error to ret:
1. submit.out_fence (with f.seqno == 0) is exported to userspace sync_file or syncobjs, which triggers WARN_ON_ONCE(f->seqno == 0) in virtio_gpu_fence_signaled() when queried.
2. drm_event_cancel_free() at cleanup is skipped because ret is 0, and because submit.out_fence is not in vgdev->fence_drv.fences, submit.out_fence->e is never sent or freed.
3. virtio_gpu_complete_submit() clears submit.buflist = NULL, so virtio_gpu_cleanup_submit() skips freeing submit.buflist (vbuf->objs).
[ ... ]
Quoted 3 lines
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 drm/amd/pm: Validate Tonga PowerPlay state array bounds
In reply to Sasha LevinFrom: Yang Wang <[email protected]>
[ Upstream commit 1ac24df78c566d767a5ef05a1fe0ecc55bac248d ]
process_pptables_v1_0.c builds the Tonga state array pointer from usStateArrayOffset before checking that the table buffer covers the referenced data. A truncated PowerPlay table can therefore lead to out-of-bounds reads while validating the state array.
Validate the fixed table size first, then check the state array offset and entry range before dereferencing the state array.
---
LLM Generated explanations, may be completely bogus:
I have enough to decide: the Tonga state-array OOB exists in this 6.18.53 tree, the patch is self-contained, and it applies cleanly.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [drm/amd/pm] [Validate] [Add bounds checks before using the Tonga PowerPlay state array pointer derived from usStateArrayOffset.]
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Yang Wang <[email protected]> (author)
- Reviewed-by: Hawking Zhang <[email protected]> (AMD GFX reviewer; mailing-list reply said the whole 5-patch series is Reviewed-by)
- Signed-off-by: Alex Deucher <[email protected]> (amdgpu maintainer)
- No Fixes:, Reported-by, Tested-by, Link:, or Cc: stable (absence expected)
- Ignore pipeline-added Upstream commit / Sasha Levin SOB
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: process_pptables_v1_0.c forms ATOM_Tonga_State_Array * from usStateArrayOffset before proving the PowerPlay buffer covers that object.
- Symptom: truncated/malformed PowerPlay table → out-of-bounds reads while validating the state array.
- Root cause: pointer arithmetic first, checks after (and the checks never used soft_pp_table_size).
- Fix: check fixed table size, then offset, then entry span, then dereference.
- No affected-version list in the message.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not disguised. Explicit OOB hardening. Also tightens entry_index <= ucNumEntries to entry_index < ucNumEntries (off-by- one on the index check).
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c (+40 / −22)
- Functions: check_powerplay_tables split into get_tonga_state_array
+ thin wrapper; get_number_of_powerplay_table_entries_v1_0; get_powerplay_table_entry_v1_0
- Scope: single-file surgical fix
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Hunk 1 (init validation): Before — compute state_arrays = table + usStateArrayOffset then assert revision/offset/size/ucNumEntries. After — require soft_pp_table_size >= sizeof(*powerplay_table), then existing header checks, then offset <= table_size - sizeof(*state_arrays), then dereference, then struct_size(...) <= remaining.
- Hunk 2 (get_number_of_powerplay_table_entries_v1_0): Before — same unvalidated pointer add, return ucNumEntries. After — shared helper; fail closed on invalid table.
- Hunk 3 (get_powerplay_table_entry_v1_0): Before — pointer add + offset/ucNumEntries checks after the add; entry_index <= ucNumEntries. After — helper first; entry_index < ucNumEntries.
- Paths: GPU powerplay init and power-state table walk (normal device bring-up), not a rare error-only path.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Category: memory safety — buffer overflow / OOB read of firmware (and optionally sysfs-uploaded) table data.
- Mechanism: usStateArrayOffset and ucNumEntries were trusted. A truncated blob or huge offset reads past the ATOM table. struct_size() is overflow-safe for the entries span.
- Also logic: exclusive vs inclusive index check.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: size → header → offset → header of subtable → full entries span.
- Underflow: table_size - sizeof(*state_arrays) is safe because the first check is table_size >= sizeof(*powerplay_table), and ATOM_Tonga_POWERPLAYTABLE is much larger than ATOM_Tonga_State_Array (header + two UCHARs + flex array).
- Regression: valid VBIOS tables should still pass if usStructureSize is the full PowerPlay blob (ATOM CU16(idx) / usStructureSize). That is the same size the later Tonga/Vega subtable helpers use; a header-only size would reject every Tonga GPU and would not have landed.
- No public API / locking / data-structure change. Stale kernel-doc above get_tonga_state_array still mentions check_powerplay_tables (later comment-only fix 4986757d); no runtime impact.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Buggy check_powerplay_tables body: c82baa28184356 (yanyang1, 2015-08-18), originally tonga_processpptables.c.
- File rename: f8a4c11b0a33f9 (2016).
- Bug has been in-tree since PowerPlay v1 (~4.x era), so it is in this 6.18 tree.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. N/A.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES Record:
- Same author/series (independent per-ASIC bounds work):
- 1/5 Validate pp_table header before reading size (SWSMU
`smu_sys_set_pp_table`)
- 2/5 `Use uploaded size for legacy custom PPTable`
(`pp_dpm_set_pp_table`) - **3/5 this commit**
- 4/5 Vega hwmgr bounds
- 5/5 legacy hwmgr offsets
- Follow-up (separate 2/3 series): Validate Tonga PPTable subtable bounds (~600 lines) for other subtables; later comment-align commit for this helper.
- This commit does not call pp_entries_max() (autosel parent helper). Standalone for the state-array OOB.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Yang Wang is an AMD PM contributor with a run of PPTable bounds/UAF fixes. Hawking Zhang reviewed; Alex Deucher merged.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record:
- Uses existing hwmgr->soft_pp_table_size (set in get_powerplay_table() from ATOM) and kernel struct_size (include/linux/overflow.h). Both exist in v6.18.53.
- 1/5 is a different file (SWSMU). 2/5 improves custom-upload size accounting in amd_powerplay.c but is not required to compile or to bound VBIOS tables.
- Can apply standalone. Confirmed with patch --dry-run against v6.18.53 file: clean.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 1ac24df78c566d767a5ef05a1fe0ecc55bac248d → [PATCH 3/5] htt ps://patch.msgid.link/[email protected]
- b4 dig -a: only v1 of this 5-patch series (no later rewrite of 3/5).
- Freedesktop: https://lists.freedesktop.org/archives/amd-
gfx/2026-June/147288.html
- Hawking on 1/5 (series Ack): “Series is Reviewed-by: Hawking Zhang” —
https://lists.freedesktop.org/archives/amd-gfx/2026-June/147299.html
- No NAK found. No Cc: stable in the submission.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: b4 dig -w To/Cc: amd-gfx, Alex Deucher, Hawking Zhang, Kenneth Feng. Maintainer merged.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla. Bug is described as truncated PowerPlay table OOB. Trigger is firmware parse at init, or root write to pp_table sysfs (documented in amdgpu_pm.c).
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: 5-patch OOB series plus a later Tonga subtable series. This patch is the Tonga *state array* piece and is self-contained. Other patches cover other table formats/subtables.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: UNVERIFIED — lore.kernel.org/stable returned HTTP 403. No evidence this was rejected for stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: get_tonga_state_array (new), check_powerplay_tables, get_number_of_powerplay_table_entries_v1_0, get_powerplay_table_entry_v1_0.
Step 5.2: TRACE CALLERS
Record:
- check_powerplay_tables ← pp_tables_v1_0_initialize ← pptable_v1_0_funcs.pptable_init ← SMU7 when pp_table_version == PP_TABLE_V1 (smu7_init_function_pointers).
- get_number_of_powerplay_table_entries_v1_0 ← smu7_get_number_of_powerplay_table_entries ← psm get_num_of_pp_table_entries.
- get_powerplay_table_entry_v1_0 ← smu7_get_pp_table_entry_v1 ← psm_init_power_state_table loop for (i = 0; i < table_entries; i++).
- Context: driver init / DPM bring-up, process context.
Step 5.3: TRACE CALLEES
Record: le16_to_cpu, struct_size, PP_ASSERT_WITH_CODE (warns and runs return -1 — real control flow, not a debug-only assert).
Step 5.4: FOLLOW THE CALL CHAIN
Record: Reachable on every boot of SMU7 PP_TABLE_V1 ASICs (Tonga/Fiji/Polaris/VegaM class in this hwmgr). Also reachable if root writes /sys/class/drm/cardX/device/pp_table (S_IRUGO | S_IWUSR), which copies into hardcode_pp_table and calls amd_powerplay_reset → re-init. Unprivileged users cannot write the sysfs node.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same unvalidated table + le16_to_cpu(offset) pattern in Vega/legacy processpptables; same author fixed those in 4/5, 5/5, and the later Tonga subtable patch.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record:
- Local tree: v6.18.53-5049-g0f0bdc2b0dffb, VERSION=6 PATCHLEVEL=18 SUBLEVEL=53, branch autosel.
- git merge-base --is-ancestor f29e53bc54611 v6.18.53 → **not in v6.18.53**.
- v6.18.53:process_pptables_v1_0.c still has the old check_powerplay_tables that adds usStateArrayOffset before any size check (lines 1116–1137).
- Bug introduced ~2015; present here.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Expected **clean apply**. Dry-run of this commit’s diff onto the v6.18.53 copy of the file succeeded. Mainline context uses kzalloc_obj; 6.18.53 uses kzalloc(sizeof(...)) — that line is not part of the hunks.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: v6.18.53 does **not** contain 1/5, 2/5, this commit, 4/5, or 5/5. No earlier Tonga state-array bounds helper. Follow-up subtable helpers (tonga_pp_table_has_space) are only on the autosel branch after later candidates — not in v6.18.53.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [drm/amd/pm powerplay] [IMPORTANT — widely used AMD GPU DPM for Tonga/Fiji/Polaris-era cards, not core mm/net, but real hardware in the field]
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Actively maintained; this is targeted firmware-table hardening, not a refactor of a brand-new subsystem.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver-specific: amdgpu SMU7 with PowerPlay table v1 (Tonga/Fiji/Polaris family). Config CONFIG_DRM_AMDGPU.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record:
- Always parsed at device init from VBIOS/ATOM (smu_atom_get_data_table → soft_pp_table_size = usStructureSize).
- Healthy firmware: no behavior change.
- Truncated/corrupt VBIOS or crafted table: OOB read.
- Sysfs pp_table store is root-only. On v6.18.53, short uploads memcpy into a buffer still sized as the original table (pp_dpm_set_pp_table); 2/5 would make soft_pp_table_size match the upload. This commit still stops offsets that run past soft_pp_table_size.
- Unprivileged users cannot trigger via sysfs.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: Kernel OOB read → KASAN/oops, possible info leak from adjacent BIOS/kernel memory if values are consumed. Severity: **HIGH** (memory safety). Not a confirmed remote unprivileged exploit.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: HIGH for Tonga/Polaris users with bad/truncated firmware or custom PP tables; fail closed instead of reading off the end of the ATOM blob.
- Risk: LOW (~40 lines, local helper, existing PP_ASSERT_WITH_CODE style).
- Ratio: favorable. Residual gap: other subtables still unchecked until the large follow-up; that is not a reason to skip this contained state-array fix.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real OOB read: pointer from firmware offset used before buffer coverage is proven (code from 2015, present in 6.18.53).
- Small, obviously correct, overflow-safe struct_size check.
- Reviewed by Hawking Zhang (series), merged by Alex Deucher.
- Applies cleanly to this tree; no missing types/helpers.
- Shared helper also closes the same hole in entry-count and entry-fetch paths.
- Fail closed: init returns error instead of walking garbage.
AGAINST:
- No crash report / syzbot / Fixes: tag.
- Part of 3/5; full PPTable hardening needs later larger patches.
- Sysfs path is root-only; VBIOS path needs a truncated/malformed table.
- Incomplete vs later 600-line subtable patch.
UNRESOLVED:
- Stable list discussion (lore 403).
- No production crash log attached to the patch.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — order of checks is sound; maintainer review; in mainline.
2. Fixes a real bug that affects users? **PASS** — OOB read of PowerPlay state array from truncated/malformed tables on a live init path.
3. Important issue? **PASS** — kernel OOB read / crash / info-leak class; HIGH, not a style cleanup.
4. Small and contained? **PASS** — one file, +40/−22.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — bug present in v6.18.53; dry- run apply clean.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Not a device-ID/quirk/DT/docs exception. Ordinary memory-safety bugfix.
Step 9.4: MAKE YOUR DECISION
This should be backported to **this** 6.18.y tree. The buggy pointer construction is in v6.18.53, the fix is small and independent of the rest of the 5-patch series, and it prevents out-of-bounds reads during amdgpu PowerPlay v1 init.
===============================================================
What the commit solves for this tree
===============================================================
On 6.18.53, check_powerplay_tables(), get_number_of_powerplay_table_entries_v1_0(), and get_powerplay_table_entry_v1_0() all do:
state_arrays = (ATOM_Tonga_State_Array *)(powerplay_table + le16_to_cpu(usStateArrayOffset))
and then read ucNumEntries / entries[i]. soft_pp_table_size is already known from ATOM usStructureSize but was unused. A truncated PowerPlay table or an offset past the blob is an out-of-bounds kernel read during GPU init (Polaris-class cards are still common). The patch adds the missing coverage checks and an exclusive entry-index test. It does not add APIs. 1/5 and 2/5 are related hardening but not compile/runtime prerequisites for this file.
Risk vs benefit: low risk of regressing good firmware; high value if the table is short or the offset is wrong.
Verification:
- [Phase 1] Tags: author Yang Wang; Reviewed-by Hawking Zhang; SOB Alex Deucher; no Fixes/syzbot/stable Cc
- [Phase 2] Diff: +40/−22 in process_pptables_v1_0.c; helper + three call sites; OOB bounds + off-by-one index
- [Phase 2] PP_ASSERT_WITH_CODE in pp_debug.h really pr_warn + executes return -1
- [Phase 3] Blame: c82baa28184356 (2015-08-18) introduced the unvalidated pointer add
- [Phase 3] No Fixes: tag
- [Phase 3] Series 1/5 and 2/5 touch other files; this commit does not use pp_entries_max()
- [Phase 3] struct_size in include/linux/overflow.h; soft_pp_table_size set in get_powerplay_table()
- [Phase 4] b4 dig -c 1ac24df78c566d767a5ef05a1fe0ecc55bac248d → PATCH 3/5 msgid 20260623034151.263746-3
- [Phase 4] b4 dig -a: v1 only for this series
- [Phase 4] b4 dig -w: amd-gfx, Deucher, Hawking, Kenneth Feng
- [Phase 4] Hawking: “Series is Reviewed-by”
https://lists.freedesktop.org/archives/amd-gfx/2026-June/147299.html
- [Phase 4] Patch body: https://lists.freedesktop.org/archives/amd-
gfx/2026-June/147288.html
- [Phase 5] Callers: pp_tables_v1_0_initialize, smu7_get_number_of_powerplay_table_entries, smu7_get_pp_table_entry_v1 ← psm_init_power_state_table
- [Phase 5] pptable_v1_0_funcs selected for PP_TABLE_V1 in smu7_init_function_pointers
- [Phase 5] sysfs pp_table is S_IRUGO | S_IWUSR (AMDGPU_DEVICE_ATTR_RW)
- [Phase 6] git describe HEAD = v6.18.53-5049-g0f0bdc2b0dffb; Makefile 6.18.53
- [Phase 6] commit **not** ancestor of v6.18.53; buggy function present at v6.18.53:1116
- [Phase 6] patch --dry-run of this diff onto v6.18.53 file: success
- [Phase 6] ATOM size is usStructureSize via amdgpu_atom_parse_data_header *size = CU16(idx)
- [Phase 8] Failure mode: OOB read on truncated PP table during amdgpu init; HIGH
- UNVERIFIED: lore.kernel.org/stable search (HTTP 403); no public crash repro attached to the patch
**YES**
.../powerplay/hwmgr/process_pptables_v1_0.c | 62 ++++++++++++------- 1 file changed, 40 insertions(+), 22 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c +40 -22
@@ -1113,15 +1113,17 @@ static int init_thermal_controller(* @powerplay_table: Pointer to the PowerPlay Table. * Exception: 2 if the powerplay table is incorrect. */ -static int check_powerplay_tables ( -struct pp_hwmgr *hwmgr, -const ATOM_Tonga_POWERPLAYTABLE *powerplay_table - ) +static int get_tonga_state_array (struct pp_hwmgr *hwmgr, +const ATOM_Tonga_POWERPLAYTABLE *powerplay_table, +const ATOM_Tonga_State_Array **state_array) {const ATOM_Tonga_State_Array *state_arrays; +u16 state_array_offset; +size_t state_array_size; +size_t table_size = hwmgr->soft_pp_table_size; - state_arrays = (ATOM_Tonga_State_Array *)(((unsigned long )powerplay_table) + -le16_to_cpu (powerplay_table->usStateArrayOffset)); +PP_ASSERT_WITH_CODE ((table_size >=sizeof (*powerplay_table)), +"Invalid PowerPlay Table!" , return -1 ); PP_ASSERT_WITH_CODE((ATOM_Tonga_TABLE_REVISION_TONGA <= powerplay_table->sHeader.ucTableFormatRevision),
@@ -1130,12 +1132,34 @@ static int check_powerplay_tables( "State table is not set!", return -1);PP_ASSERT_WITH_CODE ((0 < powerplay_table->sHeader.usStructureSize),"Invalid PowerPlay Table!" , return -1 ); + + state_array_offset =le16_to_cpu (powerplay_table->usStateArrayOffset); +PP_ASSERT_WITH_CODE ((state_array_offset <= + table_size -sizeof (*state_arrays)), +"Invalid PowerPlay Table!" , return -1 ); + + state_arrays = (ATOM_Tonga_State_Array *)(((unsigned long )powerplay_table) + + state_array_offset);PP_ASSERT_WITH_CODE ((0 < state_arrays->ucNumEntries),"Invalid PowerPlay Table!" , return -1 ); + state_array_size =struct_size (state_arrays, entries, state_arrays->ucNumEntries); +PP_ASSERT_WITH_CODE ((state_array_size <= table_size - state_array_offset), +"Invalid PowerPlay Table!" , return -1 ); + + *state_array = state_arrays; +return 0 ; } +static int check_powerplay_tables (struct pp_hwmgr *hwmgr, +const ATOM_Tonga_POWERPLAYTABLE *powerplay_table) +{ +const ATOM_Tonga_State_Array *state_arrays; + +return get_tonga_state_array (hwmgr, powerplay_table, &state_arrays); +} +static int pp_tables_v1_0_initialize (struct pp_hwmgr *hwmgr) {int result =0 ;
@@ -1239,17 +1263,16 @@ const struct pp_table_func pptable_v1_0_funcs = {int get_number_of_powerplay_table_entries_v1_0 (struct pp_hwmgr *hwmgr) { -ATOM_Tonga_State_Array const *state_arrays; +const ATOM_Tonga_State_Array *state_arrays;const ATOM_Tonga_POWERPLAYTABLE *pp_table =get_powerplay_table (hwmgr); +int result;PP_ASSERT_WITH_CODE ((NULL != pp_table),"Missing PowerPlay Table!" , return -1 ); -PP_ASSERT_WITH_CODE ((pp_table->sHeader.ucTableFormatRevision >= - ATOM_Tonga_TABLE_REVISION_TONGA), -"Incorrect PowerPlay table revision!" , return -1 ); - state_arrays = (ATOM_Tonga_State_Array *)(((unsigned long )pp_table) + -le16_to_cpu (pp_table->usStateArrayOffset)); + result =get_tonga_state_array (hwmgr, pp_table, &state_arrays); +PP_ASSERT_WITH_CODE ((result ==0 ), + "Invalid PowerPlay Table State Array.", return result);return (uint32_t )(state_arrays->ucNumEntries); }
@@ -1380,15 +1403,11 @@ int get_powerplay_table_entry_v1_0(struct pp_hwmgr *hwmgr,if (pp_table->sHeader.ucTableFormatRevision >= ATOM_Tonga_TABLE_REVISION_TONGA) { - state_arrays = (ATOM_Tonga_State_Array *)(((unsigned long )pp_table) + -le16_to_cpu (pp_table->usStateArrayOffset)); - -PP_ASSERT_WITH_CODE ((0 < pp_table->usStateArrayOffset), -"Invalid PowerPlay Table State Array Offset." , return -1 ); -PP_ASSERT_WITH_CODE ((0 < state_arrays->ucNumEntries), -"Invalid PowerPlay Table State Array." , return -1 ); -PP_ASSERT_WITH_CODE ((entry_index <= state_arrays->ucNumEntries), -"Invalid PowerPlay Table State Array Entry." , return -1 ); + result =get_tonga_state_array (hwmgr, pp_table, &state_arrays); +PP_ASSERT_WITH_CODE ((result ==0 ), + "Invalid PowerPlay Table State Array.", return result); +PP_ASSERT_WITH_CODE ((entry_index < state_arrays->ucNumEntries), +"Invalid PowerPlay Table State Array Entry." , return -1 ); state_entry = GET_FLEXIBLE_ARRAY_MEMBER_ADDR( ATOM_Tonga_State, entries,
@@ -1414,4 +1433,3 @@ int get_powerplay_table_entry_v1_0(struct pp_hwmgr *hwmgr,return result; } -
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/realtek: Fix speakers on ASUS PM3406CHA
In reply to Sasha LevinFrom: Muhtasham Nawr al-Mahmud <[email protected]>
[ Upstream commit 0eee030c2c09c7a44be778de5f451d9e7a2f09c1 ]
The ASUS ExpertBook PM3406CHA uses an ALC256 codec with subsystem ID 1043:1664. On Linux boot, the internal speakers are silent even though playback is routed to the codec and the speaker pin is configured for output.
The codec starts with coefficient 0x10 set to 0x1d20. Writing 0x7f20 to coefficient 0x10 immediately restores internal speaker output.
This was reproduced on the affected hardware from a fresh boot using hda-verb. Reducing a larger initialization sequence showed that this coefficient write alone is sufficient; no GPIO, EAPD, pin-control, or other coefficient changes are required. After applying the coefficient in userspace, speaker output also remains functional across suspend and resume.
Add a machine-specific HDA fixup that writes the required coefficient.
The fixup has been compile-tested, but could not be boot-tested because the affected hardware is no longer available.
---
LLM Generated explanations, may be completely bogus:
This is a machine-specific Realtek HDA quirk for silent speakers on one ASUS laptop. The local tree is **6.18.57**; the ALC256 driver and quirk tables are already here, and the SSID entry is not.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[ALSA: hda/realtek]** **[Fix]** **[restore internal speakers on ASUS ExpertBook PM3406CHA]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- `Closes: https://bugs.launchpad.net/ubuntu/+source/alsa-
driver/+bug/2162718` — Ubuntu bug with a real user report
- `Link: https://patch.msgid.link/20260924144512.3989-1-
[email protected]` — original submission
- Signed-off-by: Muhtasham Nawr al-Mahmud <[email protected]> — author
- Signed-off-by: Takashi Iwai <[email protected]> — ALSA maintainer applied it
- No Fixes: tag (expected: this is a missing hardware quirk, not a regression)
- No Cc: [email protected] (expected for this review queue)
- No Reported-by: / Tested-by: in the git message; the Launchpad thread supplies both in practice
- Ignore pipeline Signed-off-by: Sasha Levin / [Upstream commit ...]
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** ASUS ExpertBook PM3406CHA (ALC256, SSID 1043:1664) boots with internal speakers silent even though ALSA routes playback to the codec and the speaker pin is an output.
- **Symptom:** no audible speaker output; HDMI/Bluetooth still work (Launchpad).
- **Root cause:** vendor coefficient 0x10 comes up as 0x1d20. Writing 0x7f20 restores output. Isolated with hda-verb from a larger init sequence; GPIO/EAPD/pin-control/other coeffs were not required. After the userspace write, audio still worked across suspend/resume.
- **Version info:** Launchpad reporter: Ubuntu 24.04.4, kernel 7.0.0-28-generic; author also tested on 7.2.6-arch2-1.
- **Caveat in the message:** author compile-tested the kernel patch but no longer had the laptop for a kernel boot-test.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. This is an explicit hardware-quirk bug fix.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: sound/hda/codecs/realtek/alc269.c **+10 / -0**
- Functions/tables: enum { ... } (add ALC256_FIXUP_ASUS_PM3406CHA), alc269_fixups[], alc269_fixup_tbl[]
- Scope: **single-file surgical hardware quirk**
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
1. Enum: add a new fixup ID used as an index into alc269_fixups[].
2. Fixup table: HDA_FIXUP_VERBS writing nid 0x20 AC_VERB_SET_COEF_INDEX 0x10 then AC_VERB_SET_PROC_COEF 0x7f20.
3. Quirk table: SND_PCI_QUIRK(0x1043, 0x1664, "ASUS ExpertBook PM3406CHA", ALC256_FIXUP_ASUS_PM3406CHA).
Before: alc269_probe() has no PCI-SSID match for 1043:1664. Launchpad shows a pin-match fallback ("ALC256: picked fixup (pin match)" with empty name) that does not enable speakers.
After: PCI SSID match wins (snd_hda_pick_fixup runs first; snd_hda_pick_pin_fixup returns immediately if fixup_id is already set). Verbs are queued at HDA_FIXUP_ACT_PROBE via snd_hda_add_verbs() and executed in alc_init() after Realtek init, including resume.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Hardware workaround / codec quirk]**
Broken: ALC256 coef 0x10 left at 0x1d20 on this SKU, so the internal amp/output path stays muted.
Fix: machine-specific init/resume verb write of 0x7f20. Same pattern as ALC269_FIXUP_DELL_M101Z (speaker enable via coef verbs).
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct for this class of fix: one SSID, two verbs, existing HDA_FIXUP_VERBS machinery. Isolated to 1043:1664. ALSA maintainer accepted it. Low regression risk for other machines. Residual risk is headphone routing on this one SKU if coef 0x10 is also a HP/speaker switch on ALC256 (GX502/GU502 comments use 0x10 that way with different values). That is unverified on this SKU; Takashi still applied the patch, and the Launchpad reporter confirmed speakers work.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: There is no “introduced-by” regression. The bug is a **missing quirk**. Surrounding table entries (0x1043:0x1663 / 0x1683, ALC269_FIXUP_DELL_M101Z) already exist at v6.18.57. ALC256 (0x10ec0256) is a first-class ID in this file (HDA_CODEC_ID(0x10ec0256, "ALC256")).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable. This is new-hardware quirk coverage, not a revert of a bad change.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Related: 0156c22fb0ca8 “Add support for ASUS Commercial laptops using CS35L41 HDA” adds **PM3406CKA** (0x1043:0x1454) with ALC287_FIXUP_CS35L41_I2C_2. That is a **different SKU** with Cirrus companion amps. Copying it to CHA would be wrong.
- Similar silent-speaker quirk already in this tree: e561c2740b628 Higole F9B.
- Standalone 10-line patch, not X/Y of a series. No follow-up on this SSID after the candidate.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Only this commit by Muhtasham Nawr al-Mahmud under sound/hda/. Not the subsystem maintainer. Applied by Takashi Iwai (MAINTAINERS:
sound maintainer).
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Uses HDA_FIXUP_VERBS, SND_PCI_QUIRK, alc269_fixups[], alc269_fixup_tbl[] — all present at v6.18.57. Can apply standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 0eee030c2c09… matched msgid [email protected]
- Series: **v1 RFC only** (no v2/v3)
- LKML: https://lkml.iu.edu/2609.3/01658.html (patch),
https://lkml.iu.edu/2609.3/11978.html (reply)
- Takashi Iwai: “The code change looks OK, so I applied this now.” **No NAK, no requested changes.**
- lore.kernel.org fetches returned 403; discussion recovered via b4 dig, Patchew, and LKML IU.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): Muhtasham Nawr al-Mahmud; Jaroslav Kysela; Takashi Iwai; Kailang Yang (Realtek); [email protected]; linux- [email protected]. Subsystem maintainer reviewed and applied.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record (Launchpad #2162718):
- Reporter: Nguyễn Trọng Tuyền, 2026-08-03, ASUS ExpertBook P3 PM3406CHA, Ryzen 7 8840HS, ALC256, SSID 1043:1664.
- Thought it was the same as PM3406CKA (#2133791, 1043:1454); that SKU needed CS35L41, this one does not.
- Author isolated coef 0x10 on the hardware; reporter later: “It works perfectly on my laptop (Ubuntu 24.04.4, kernel 7.0.0-28). My speakers are finally working again!”
- Independent user confirmation of the userspace workaround. Kernel- patch Tested-by was offered but not in the commit.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone RFC. Not part of a multi-patch series. PM3406CKA CS35L41 quirk is a different machine and must not be reused.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No stable-list hit for PM3406CHA (lore.kernel.org/stable 403; web search did not show a stable NAK or prior rejection). UNVERIFIED that it was ever discussed on stable@; absence is not a negative.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: No function bodies changed. Data: ALC256_FIXUP_ASUS_PM3406CHA, alc269_fixups[], alc269_fixup_tbl[]. Consumers: alc269_probe() → snd_hda_pick_fixup() → snd_hda_apply_fixup(); alc_init() → snd_hda_apply_verbs().
**Step 5.2: TRACE CALLERS**
Record:
- alc269_probe() calls snd_hda_pick_fixup(..., alc269_fixup_tbl, alc269_fixups) then snd_hda_apply_fixup(..., HDA_FIXUP_ACT_PROBE).
- alc_init() (codec .init, including resume) calls snd_hda_apply_verbs() then HDA_FIXUP_ACT_INIT.
- HDA_FIXUP_VERBS are applied only at HDA_FIXUP_ACT_PROBE to **register** the list; documented to run at init and resume (snd_hda_add_verbs comment in auto_parser.c).
- Path: HD-audio codec probe on this laptop, then PCM playback. Not IRQ- hot.
**Step 5.3: TRACE CALLEES**
Record: snd_hda_sequence_write() of two vendor verbs on nid 0x20 (Realtek vendor processing node). No alloc/lock/API change.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Unprivileged playback on this laptop triggers the silent path today. After the quirk, probe/init writes the coef. Userspace-reachable on the affected SKU.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same file already uses coef-0x10 verbs (ALC269_FIXUP_ASUS_N7601ZM, ALC274_FIXUP_ASUS_ZEN_AIO_27) and speaker-enable verbs (ALC269_FIXUP_DELL_M101Z). This matches established Realtek practice.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- git describe HEAD → v6.18.57-155-gcdf239ca885b2
- make kernelversion / Makefile → **6.18.57**
- git merge-base --is-ancestor 97902f970e5cd v6.18.57 → **not an ancestor** (the quirk is **not** in the 6.18.57 baseline)
- At v6.18.57, alc269_fixup_tbl goes 0x1663 then 0x1683; **no 0x1664 / PM3406CHA**
- File sound/hda/codecs/realtek/alc269.c exists (split in aeeb85f26c3bb, long before 6.18)
- ALC256 ID table present at v6.18.57
- Bug is the missing SSID quirk; it exists on this 6.18.y tree
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply expected.** Insertion points at v6.18.57:
- enum: ALC269_FIXUP_DELL_M101Z then ALC269_FIXUP_SKU_IGNORE
- alc269_fixups[]: same pair of entries
- quirk table: 0x1663 then 0x1683
No struct/API mismatch.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No other PM3406CHA / 0x1043:0x1664 fix. PM3406CKA CS35L41 entry is a different SSID and amp topology.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **ALSA HD-audio Realtek codec** (sound/hda/codecs/realtek/). **IMPORTANT** for laptop audio, not core mm/VFS. Quirk-table maintenance is routine in stable.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: High churn of per-machine quirks (mute LEDs, SSIDs, silent speakers). Mature driver, new rows for new laptops. That is the intended stable pattern.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / SSID-specific.** Only ASUS ExpertBook PM3406CHA (PCI SSID 1043:1664, ALC256). No effect on other machines.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Every boot / every speaker playback on that laptop. Not a race. Unprivileged user playing audio. Reported on Ubuntu 24.04.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Internal speakers completely silent while the stack looks healthy. Not a panic/UAF. **MEDIUM–HIGH functional** for owners of that laptop (device unusable for built-in audio). HDMI/BT still work.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** High for that SKU (speakers work). Matches the stable hardware-quirk exception. User-confirmed.
- **Risk:** Very low: +10 lines, one SSID, existing verb mechanism, maintainer-acked. Possible headphone interaction on this SKU only (unverified).
- **Ratio:** Strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real user-visible bug: silent internal speakers
- Ubuntu Launchpad #2162718; original reporter confirmed the coef workaround
- Isolated, machine-specific HDA_FIXUP_VERBS + SND_PCI_QUIRK
- +10 lines, one file, no new API
- Driver, ALC256 support, and quirk tables already in 6.18.57
- Same pattern as existing speaker/coef quirks
- Takashi Iwai applied the RFC as-is
- Explicit stable exception: hardware quirk / SSID enablement for an existing driver
AGAINST:
- Not a crash, UAF, or security bug
- Author could not boot-test the kernel patch after losing the laptop (userspace path was tested; reporter confirmed it)
- Unverified headphone behavior if coef 0x10 is a HP/speaker mux on this SKU
UNRESOLVED:
- lore.kernel.org HTTP 403 (discussion recovered elsewhere)
- No stable@ thread found
- Headphone path on this SKU not documented
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — standard quirk; hda-verb isolation; Launchpad confirmation; maintainer applied
2. Fixes a real bug that affects users? **PASS** — silent speakers, filed and confirmed
3. Important issue? **PASS** for this class (hardware quirk / broken audio on a shipping laptop), not CRITICAL crash
4. Small and contained? **PASS** — 10 lines, one SSID
5. No new features or APIs? **PASS** — quirk only
6. Can apply to the local tree? **PASS** — 6.18.57 has the file and insertion context; SSID not already present
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Hardware quirk / existing-driver SSID enablement.** Automatic YES category in the stable rules given in the prompt.
**Step 9.4: MAKE YOUR DECISION**
This belongs on 6.18.y. The ALC256 Realtek driver already enumerates this laptop; without the SSID row, speakers stay silent. The change is a two-verb init/resume write gated to 1043:1664, the same style as other Realtek speaker quirks already in this file. It applies cleanly to this tree and does not need the unrelated PM3406CKA CS35L41 patch.
Verification:
- [Phase 1] Parsed tags: Closes: Launchpad 2162718; Link: patch msgid; SOB author + Takashi Iwai; no Fixes:/Cc: stable
- [Phase 1] Body: silent speakers; coef 0x10 0x1d20→0x7f20; hda- verb isolation
- [Phase 2] Diff: +10 in alc269.c; enum + HDA_FIXUP_VERBS + SND_PCI_QUIRK(0x1043,0x1664)
- [Phase 2] auto_parser.c: HDA_FIXUP_VERBS registered at PROBE, run from alc_init() after codec init and on resume
- [Phase 3] No Fixes: tag; missing-quirk, not a regression
- [Phase 3] Related 0156c22fb0ca8 is PM3406CKA CS35L41 (0x1454), different hardware
- [Phase 3] Author has only this hda commit; Takashi applied it
- [Phase 4] b4 dig -c 0eee030c2c09…: RFC v1 only; recipients include Iwai/Kysela/Realtek/linux-sound
- [Phase 4] Takashi: “The code change looks OK, so I applied this now.” No NAK
- [Phase 4] Launchpad: reporter confirmed speakers work with the coef write
- [Phase 4] lore.kernel.org direct fetch: 403; used b4/Patchew/LKML IU instead
- [Phase 5] Call chain: alc269_probe → snd_hda_pick_fixup → verbs → alc_init/snd_hda_apply_verbs
- [Phase 5] Pin-match cannot override once PCI SSID is set (snd_hda_pick_pin_fixup early return)
- [Phase 6] git describe HEAD = v6.18.57-155-gcdf239ca885b2; kernelversion 6.18.57
- [Phase 6] git merge-base --is-ancestor 97902f970e5cd v6.18.57 failed → quirk **not** in 6.18.57 baseline
- [Phase 6] git show v6.18.57:…alc269.c has 0x1663 then 0x1683, no 0x1664; DELL_M101Z/SKU_IGNORE insertion points exist
- [Phase 6] ALC256 0x10ec0256 present at v6.18.57
- [Phase 7] ALSA Realtek; Takashi Iwai in MAINTAINERS
- [Phase 8] Failure mode: silent speakers on one laptop SSID; severity MEDIUM–HIGH functional; risk very low
- UNVERIFIED: headphone interaction of coef 0x10 on this SKU; no stable@ discussion recovered
**YES**
sound/hda/codecs/realtek/alc269.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
sound/hda/codecs/realtek/alc269.c +10 -0
@@ -3678,6 +3678,7 @@ enum {ALC269_FIXUP_SONY_VAIO ,ALC275_FIXUP_SONY_VAIO_GPIO2 ,ALC269_FIXUP_DELL_M101Z , +ALC256_FIXUP_ASUS_PM3406CHA ,ALC269_FIXUP_SKU_IGNORE ,ALC269_FIXUP_ASUS_G73JW , ALC269_FIXUP_ASUS_N7601ZM_PINS,
@@ -4089,6 +4090,14 @@ static const struct hda_fixup alc269_fixups[] = { {} } }, + [ALC256_FIXUP_ASUS_PM3406CHA] = { + .type = HDA_FIXUP_VERBS, + .v.verbs = (const struct hda_verb []) { + {0x20 ,AC_VERB_SET_COEF_INDEX ,0x10 }, + {0x20 ,AC_VERB_SET_PROC_COEF ,0x7f20 }, + {} + } + }, [ALC269_FIXUP_SKU_IGNORE] = { .type = HDA_FIXUP_FUNC, .v.func = alc_fixup_sku_ignore,
@@ -7184,6 +7193,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x1043 ,0x1652 ,"ASUS ROG Zephyrus Do 15 SE" ,ALC289_FIXUP_ASUS_ZEPHYRUS_DUAL_SPK ),SND_PCI_QUIRK (0x1043 ,0x1662 ,"ASUS GV301QH" ,ALC294_FIXUP_ASUS_DUAL_SPK ),SND_PCI_QUIRK (0x1043 ,0x1663 ,"ASUS GU603ZI/ZJ/ZQ/ZU/ZV" ,ALC285_FIXUP_ASUS_HEADSET_MIC ), +SND_PCI_QUIRK (0x1043 ,0x1664 ,"ASUS ExpertBook PM3406CHA" ,ALC256_FIXUP_ASUS_PM3406CHA ),SND_PCI_QUIRK (0x1043 ,0x1683 ,"ASUS UM3402YAR" ,ALC287_FIXUP_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x1043 ,0x16a3 ,"ASUS UX3402VA" ,ALC245_FIXUP_CS35L41_SPI_2 ), SND_PCI_QUIRK(0x1043, 0x16b2, "ASUS GU603", ALC289_FIXUP_ASUS_GA401),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 net: stmmac: raise TX completion interrupt at the end of an xmit burst
In reply to Sasha LevinFrom: Johan Alvarado <[email protected]>
[ Upstream commit d21a374995df9d7cfd193427748a19dcc87956a9 ]
The TX mitigation logic only sets the Interrupt on Completion bit once every tx_coal_frames descriptors (STMMAC_TX_FRAMES = 25), with the tx_coal_timer hrtimer (STMMAC_COAL_TX_TIMER = 5000 us) as the only fallback. TX skbs are freed exclusively from the TX completion path, so any flow that keeps fewer than 25 frames in flight has all of its skbs held for up to 5 ms after transmission.
Paced flows never queue enough frames to reach the frame threshold:
TCP Small Queues caps the amount of unfreed data at roughly two pacing intervals worth, which at moderate pacing rates is only a couple of packets. Every small burst then stalls until the coalesce timer fires, and throughput collapses to approximately tsq_limit / tx_coal_timer regardless of link capacity.
This is easily reproducible with BBR, which paces its output and thus keeps only a few frames in flight at a time. On a YT6801 (dwmac-motorcomm) equipped Orange Pi 5 Pro, a BBR upload over a ~23 ms RTT path is capped at 5.24 Mbit/s, while CUBIC reaches 207 Mbit/s on the same path. BBR measures the stalled send rate as the path bandwidth and locks its estimate near the floor, so the connection never recovers. Lowering the coalesce settings with ethtool -C (tx-usecs 100 tx-frames 1) lifts the same transfer to 447 Mbit/s, confirming the mechanism.
Fix this by setting the IC bit on the last descriptor of every xmit burst, i.e. whenever netdev_xmit_more() reports that no further frames are pending in the current dequeue batch. Frame-based coalescing still applies within a burst, bulk traffic keeps batching through qdisc bulk dequeue and NAPI polling, and the coalesce timer becomes a pure fallback instead of the primary completion mechanism for lightly queued flows.
tx-frames 0 keeps its meaning of timer-based mitigation only.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111**. The TX-coalesce stall is in this checkout; the four-line IC-on-burst-end change is a real, tested fix for a severe paced-TCP collapse on stmmac.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [net: stmmac] [raise] [set TX Interrupt-on-Completion on the last descriptor of each xmit burst so lightly queued/paced flows are not stuck on the 5 ms coalesce timer]
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Link: https://patch.msgid.link/[email protected]
- Signed-off-by: Johan Alvarado \<[email protected]\> (author)
- Signed-off-by: Jakub Kicinski \<[email protected]\> (netdev maintainer, applied)
- No Reported-by / Tested-by / Reviewed-by / Acked-by / Cc: stable in the committed message
- No Fixes: in the committed message (expected for this pipeline)
Original mailing-list submission (v1 and RESEND) DID carry:
- Fixes: da2024510031 ("net: stmmac: Tune-up default coalesce settings") That tag is treated as technical evidence of the introducing commit, not as a “already selected for stable” marker.
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: TX IC is set only every tx_coal_frames descriptors (default 25). The 5 ms tx_coal_timer is the only fallback. TX skbs are freed only from the completion path, so a flow with fewer than 25 frames in flight holds those skbs for up to 5 ms.
- Symptom: TCP Small Queues + pacing (BBR) never queues 25 frames. Each small burst waits for the timer. Throughput collapses to ~tsq_limit / tx_coal_timer. BBR then treats that stalled rate as path bandwidth and never recovers.
- Measured on Orange Pi 5 Pro / YT6801: BBR 5.24 Mbit/s vs CUBIC 207 Mbit/s; ethtool -C tx-usecs 100 tx-frames 1 raises the same transfer to 447 Mbit/s.
- Root cause: coalescing designed for deep queues; lightly queued flows only complete via the timer.
- Fix: set IC when !netdev_xmit_more() (end of current dequeue batch). Frame coalescing still applies inside a burst; tx-frames 0 stays timer-only.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. Submitted as [PATCH net] (bugfix tree, not net-next). It is a logic/correctness fix for TX completion starvation interacting with TSQ, not a style change.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
- +4 / −0 (two identical two-line insertions)
- Functions: stmmac_tso_xmit(), stmmac_xmit()
- Scope: single-file surgical fix
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before (both functions): set_ic if HW timestamp, else if tx_coal_frames==0 never set IC, else if this skb’s descriptor count exceeds the threshold, else if the running modulo wrapped, else false. Then arm the 5 ms timer.
- After: same, plus else if (!netdev_xmit_more()) set_ic = true immediately after the tx_coal_frames==0 check, so the last skb of a dequeue batch gets IC unless the user asked for timer-only (tx-frames 0).
- Path: normal ndo_start_xmit, not an error/init path.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Category: logic / correctness (TX completion starvation vs TCP Small Queues)
- Mechanism: IC density was bounded by frame count only. Paced flows never reach 25 in-flight frames, so completion waits for the hrtimer. TSQ will not queue more until skbs are freed, so send rate is timer- capped. Setting IC on burst end completes those skbs promptly; intra- burst coalescing and the timer remain as fallback.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: netdev_xmit_more() is the standard “more packets in this dequeue” signal; many other NIC drivers already use it this way. Placement after !tx_coal_frames preserves timer-only mode.
- Minimal: four lines, no API/data-structure change.
- Regression risk: more TX IRQs on short bursts. Author measured ~3.3k IRQs/s (~12 packets/IRQ) at 447 Mbit/s. Bulk traffic still coalesces inside qdisc bulk dequeue / TSO. XSK/XDP paths intentionally unchanged (netdev_xmit_more() is not meaningful there; no TSQ). Maciej Fijalkowski asked whether coalescing could be dropped entirely; the author kept the frame bound so a bulk batch larger than the ring cannot drain with zero IC bits. Low regression risk.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Core IC logic: c2837423cb5455 (“net: stmmac: Rework TX Coalesce logic”, 2019-11-14)
- !tx_coal_frames / per-queue threshold: db2f2842e6f560 (2021-03-17)
- Default TX_FRAMES 1→25: da2024510031 (v5.5-rc1, 2019-11) — this is what made “every frame gets IC” into “every 25 descriptors”
- Timer 1 ms→5 ms: 039550960a223 (2023-10-19), present in this tree — same stall, worse ceiling
- Buggy pattern has been in tree since ~v5.5; this is long-standing, not new-in-6.13+ code
Step 3.2: FOLLOW THE FIXES: TAG
Record:
- Original submission tagged Fixes: da2024510031
- git merge-base --is-ancestor da2024510031 HEAD → yes (exit 0)
- That commit only retuned defaults (STMMAC_TX_FRAMES 1→25). Combined with timer-only fallback, that is exactly the stall.
- Intermediate related work already in this tree: c2837423cb5455 (rework), 2d1a42cf7f77c (timer arm vs NAPI, 2023), 039550960a223 (5 ms timer). None of those set IC at burst end.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- Recent stmmac_main.c work is TSO descriptor checks, PTP lock init, XDP, etc. Nothing equivalent to this IC-on-burst-end change.
- git log --grep=netdev_xmit_more -- drivers/net/ethernet/stmicro/stmmac/ → empty; the helper is unused in stmmac here.
- Standalone 4-line fix, not patch N/M.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record:
- Johan Alvarado has no prior stmmac commits in this tree (end-user reporter/fixer, not the subsystem maintainer).
- Maintainers CC’d on the list: Alexandre Torgue, Jose Abreu. Applied by Jakub Kicinski.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record:
- Needs netdev_xmit_more() — present in include/linux/netdevice.h (this tree).
- Needs the existing set_ic / stmmac_set_tx_ic / tx_coal_frames block — present in both xmit paths.
- Mainline context uses CIRC_CNT / stmmac_get_tx_desc; those helpers are not required. The added lines sit in context that is identical here:
else if (!priv->tx_coal_frames[queue]) set_ic = false;
- Applies standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig on the msgid did not resolve a local commit (this SHA is not in the 6.12 checkout). Fallback: openwall + patchew.
- v1: 2026-07-06, Message-ID 0100019f35ea26e0-42ad009c-01ab-4a8f-b126- [email protected]
- RESEND: 2026-07-31, msgid [email protected] after netdev queue overflow (Jakub asked for a repost). Author: no code changes vs v1.
- Reviewer Maciej Fijalkowski: agreed each TX batch should get IC at the end; asked if coalescing could be dropped. Author explained why the frame bound must stay (ring-full with xmit_more set on every frame until the queue stops → zero IC → timer stall on the bulk path). Kept the patch minimal for net.
- No NAK. No reviewer concern that the change is unsafe for the IC-on- burst-end approach.
- No explicit “Cc: stable” in the thread. Submitted to net as a bugfix.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record:
- To/Cc: netdev maintainers (Kicinski, Abeni, Dumazet, Daleck, Lunn), stmmac (Torgue, Abreu, Coquelin), Pavel Machek (historical reporter), linux-stm32, linux-arm-kernel.
- Substantive review: Maciej Fijalkowski. Applied by Jakub Kicinski.
Step 4.3: SEARCH FOR THE BUG REPORT
Record:
- Concrete iperf3 numbers from the author on real hardware (Orange Pi 5 Pro).
- Historical same class of bug: Pavel Machek 2016 UDP burst pauses (40 ms low-res timer); his “disable coalescing” patch was rejected in favor of a real solution. hrtimer conversion later fixed resolution but left timer-as-only-completion for light flows.
- Severity from reporter: BBR unusable (~5 Mbit/s vs hundreds).
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Single standalone patch. Author deferred any coalescing rework to net-next. XSK/XDP IC logic deliberately not included.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable search returned 403. No evidence on openwall/patchew that stable rejected this. UNVERIFIED that it was discussed on stable@ specifically.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: stmmac_tso_xmit, stmmac_xmit. Helper used:netdev_xmit_more. Callee already present: stmmac_set_tx_ic.
Step 5.2: TRACE CALLERS
Record:
- stmmac_xmit is ndo_start_xmit (stmmac_netdev_ops at line 7155).
- stmmac_tso_xmit is called from stmmac_xmit for TSO/GSO packets (lines 4529/4531).
- Context: process / softirq xmit (BH off). Userspace sockets, not probe-only.
Step 5.3: TRACE CALLEES
Record: stmmac_set_tx_ic sets the hardware IC bit; stmmac_tx_timer_arm still runs after xmit (lines 4461 and 4750). Timer remains the fallback if IC is not set or NAPI is not scheduled.
Step 5.4: FOLLOW THE CALL CHAIN
Record: userspace send/write → TCP → qdisc → ndo_start_xmit → stmmac_xmit / stmmac_tso_xmit. Reachable on every stmmac Ethernet device. Unprivileged users who can send on the interface (typical networked host) trigger it. BBR/pacing makes it easy to hit.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: netdev_xmit_more() is already used for doorbell/IC batching in many drivers in this tree (r8169, mlx5, virtio_net, qede, ionic, sfc, forcedeth, …). stmmac is the outlier. XSK/XDP in the same file still use frame-count-only IC; that is intentional and not a missed copy of this bug (no TSQ).
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. stmmac_tso_xmit ~4380–4390 and stmmac_xmit ~4645–4655:
same if/else IC logic, no netdev_xmit_more() branch. Defaults in this
tree: STMMAC_TX_FRAMES 25, STMMAC_COAL_TX_TIMER 5000 (common.h). git describe HEAD → p-6.12-2-gd38d58a4e0359; make kernelversion → 6.12.111.
dwmac-motorcomm / YT6801 is not in this tree; that was only the reporter’s NIC. The bug lives in common stmmac_main.c, which 6.12 already uses for dwmac-rk, dwmac-sunxi, dwmac-stm32, dwmac-intel, dwmac- imx, dwmac-qcom-ethqos, dwmac-ipq806x, dwmac-meson, etc.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Expected apply: clean for the four added lines. Surrounding mainline helpers (CIRC_CNT, stmmac_get_tx_desc) differ, but they are not part of this hunk. Insertion context matches 6.12 exactly.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: 2d1a42cf7f77c (don’t re-arm timer while NAPI is scheduled) and 039550960a223 (5 ms timer) are in this tree. They do not set burst-end IC. No equivalent fix present.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [net / stmmac Ethernet] [IMPORTANT — not mm/core, but the common DWMAC driver for a large set of ARM/x86 embedded and laptop NICs]
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Actively maintained (recent TSO, XDP, PTP, FPE fixes). Coalesce core has been stable since 2019 with only timer-arm tweaks in 2023.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver-specific, but a widely used driver. Anyone using stmmac with default coalescing and paced/TSQ-limited TCP (BBR is CONFIG_TCP_CONG_BBR in this tree). CUBIC is less affected because it queues more deeply (207 vs 5 Mbit/s in the report).
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Normal TCP upload with pacing/TSQ and default ethtool coalesce (tx-frames 25, tx-usecs 5000). Common on WAN/RTT paths, not a rare error path. Unprivileged users sending data can trigger it. Workaround exists (ethtool -C) but is not discoverable for most users.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: [TCP TX completion stall / order-of-magnitude throughput collapse; BBR bandwidth lock-in] [HIGH for affected workloads — not a panic/UAF/corruption, but the NIC is effectively unusable for paced TCP]
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: high for stmmac + BBR/pacing (5 → 447 Mbit/s in the report); restores TSQ-friendly completion.
- Risk: low (4 lines, well-known helper, coalescing preserved in-burst, tx-frames 0 unchanged). 2023 ipq806x pain was timer-arm frequency under bulk load; this patch does not change timer arming and keeps the 25-descriptor IC bound so a full ring cannot drain with zero IC.
- Ratio: benefit clearly outweighs risk.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real, measured bug: BBR ~5 Mbit/s vs CUBIC ~207 Mbit/s; ethtool experiment confirms mechanism.
- TSQ/pacing vs delayed TX completion is a known correctness class, not a micro-optimization.
- Introducing change da2024510031 (TX_FRAMES 1→25) is in this tree since v5.5; 5 ms timer (039550960a223) is also here.
- Four-line, obviously correct change; netdev_xmit_more() already in this tree.
- Applies on identical context in stmmac_xmit / stmmac_tso_xmit.
- [PATCH net], reviewed, applied by netdev maintainer; reviewer agreed IC belongs at batch end.
- Workaround requires non-default ethtool; default shipped settings are the broken ones.
AGAINST:
- Not a crash, UAF, deadlock, or security bug.
- Changes IRQ pattern (more interrupts on short bursts).
- Test NIC (dwmac-motorcomm) is not in 6.12 (common-path bug still is).
- Original thread did not Cc stable@.
- 2023 work raised the timer specifically to cut IRQ rate on some SoCs — theoretical regression if burst-end IC is too aggressive under bulk load. Mitigated by remaining in-burst coalescing and author’s IRQ measurements.
UNRESOLVED:
- Could not fetch lore.kernel.org (403) or spinics (500); used openwall/patchew instead.
- Could not search stable@ archives (403).
- No follow-up fix SHA in this tree (expected; this commit is not here).
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — 4 lines, list review, before/after iperf3, IRQ rate reported.
2. Fixes a real bug that affects users? PASS — paced TCP/TSQ stall with measured multi-10x drop.
3. Important issue? PASS — HIGH functional failure of a standard congestion controller on a common NIC; not a panic, but the device is unusable for that workload at default settings.
4. Small and contained? PASS — +4 lines, one file, two functions.
5. No new features or APIs? PASS — uses existing netdev_xmit_more() / IC bit.
6. Can apply to the local tree? PASS — buggy code and helper exist; insertion context matches.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: None of device-ID / quirk / DT / build / docs. Qualifies as a normal small net driver correctness fix.
Step 9.4: MAKE YOUR DECISION
This is a small, tested fix for a long-standing TX completion stall that makes paced TCP (notably BBR) collapse on stmmac at default coalesce settings. The buggy path and the only dependency (netdev_xmit_more) are in 6.12.y. Benefit to stable users is large; regression risk is low.
Verification:
- [Phase 1] Parsed subject/body/tags from the candidate message; Link msgid used to find the original [PATCH net] / RESEND threads.
- [Phase 1] Original list post (openwall/patchew) still had Fixes:
da2024510031; committed copy in the pipeline does not.
- [Phase 2] Diff is +4 lines in stmmac_tso_xmit and stmmac_xmit only; both insertions are else if (!netdev_xmit_more()) set_ic = true after the tx_coal_frames==0 check.
- [Phase 2] Read local stmmac_main.c 4380–4390 and 4645–4667: same IC ladder, no xmit_more branch; timer still armed at 4461 and 4750.
- [Phase 2] STMMAC_TX_FRAMES 25 and STMMAC_COAL_TX_TIMER 5000 confirmed in common.h.
- [Phase 3] git blame on those lines: c2837423cb5455 (2019) and db2f2842e6f560 (2021).
- [Phase 3] git merge-base --is-ancestor da2024510031 HEAD exit 0; git show da2024510031 changed TX_FRAMES 1→25.
- [Phase 3] git merge-base --is-ancestor 039550960a223 HEAD exit 0 (5 ms timer present).
- [Phase 3] git log --grep=netdev_xmit_more -- drivers/net/ethernet/stmicro/stmmac/ empty.
- [Phase 3] git describe HEAD → p-6.12-2-gd38d58a4e0359; kernelversion 6.12.111.
- [Phase 4] b4 dig on msgid: no local matching commit (expected).
- [Phase 4] Openwall RESEND and patchew v1: Maciej Fijalkowski review, Jakub apply-after-RESEND, no NAK; author kept frame coalescing for ring-full IC bound.
- [Phase 4] lore.kernel.org and stable@ fetches: 403. UNVERIFIED on stable@ specifically.
- [Phase 5] stmmac_xmit is ndo_start_xmit; stmmac_tso_xmit called from it; netdev_xmit_more() defined in include/linux/netdevice.h 4989–5002.
- [Phase 5] Grep: many other NIC drivers already use netdev_xmit_more(); stmmac does not.
- [Phase 6] Grep netdev_xmit_more under stmmac: no matches. Grep YT6801/dwmac-motorcomm: no matches. Glob dwmac-*.c: 25 platform files including dwmac-rk, dwmac-ipq806x, dwmac-intel, dwmac-stm32.
- [Phase 6] Insertion context in 6.12 matches the patch; CIRC_CNT/get_tx_desc differences are mainline-only context, not required.
- [Phase 7] MAINTAINERS: STMMAC ETHERNET DRIVER, Alexandre Torgue / Jose Abreu.
- [Phase 8] CONFIG_TCP_CONG_BBR exists in net/ipv4/Kconfig.
- UNVERIFIED: whether a later mainline follow-up refined this patch (not in this tree; lore search blocked).
The stall is in this 6.12 tree, the fix is four obviously correct lines, and paced TCP is a real user-visible failure at default coalesce settings.
**YES**
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -0
@@ -4400,6 +4400,8 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) set_ic = true; else if (!priv->tx_coal_frames[queue]) set_ic = false; + else if (!netdev_xmit_more()) + set_ic = true; else if (tx_packets > priv->tx_coal_frames[queue]) set_ic = true; else if ((tx_q->tx_count_frames %
@@ -4687,6 +4689,8 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) set_ic = true; else if (!priv->tx_coal_frames[queue]) set_ic = false; + else if (!netdev_xmit_more()) + set_ic = true; else if (tx_packets > priv->tx_coal_frames[queue]) set_ic = true; else if ((tx_q->tx_count_frames %
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ntfs3: initialize err in attr_wof_frame_info
In reply to Sasha LevinFrom: Ruoyu Wang <[email protected]>
[ Upstream commit dd64afb32c4d8d3c934ae84df59a2e463d6fa43c ]
attr_wof_frame_info() may reuse a cached offsets folio. In that case the loop can fill the output offsets without calling attr_load_runs_range() or ntfs_read_run(), leaving err uninitialized before the common return path. Initialize err to 0 for the successful cached path.
---
LLM Generated explanations, may be completely bogus:
The local checkout is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The change is a one-line init of err in attr_wof_frame_info() so a cached WOF offsets folio does not return stack garbage; that path is in this tree and is a real user-visible bug.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[ntfs3] [initialize] initialize err in attr_wof_frame_info**
- Subsystem: ntfs3 (NTFS3 filesystem)
- Action verb: **initialize** (classic uninitialized-variable fix language)
- Claimed intent: set err so the cached-folio success path does not return an uninitialized value
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- **Signed-off-by: Ruoyu Wang** (author)
- **Signed-off-by: Konstantin Komarov** (ntfs3 maintainer; applied the patch)
- **No Fixes:** tag (expected for this review pipeline)
- **No Reported-by / Tested-by / Reviewed-by / Acked-by**
- **No Link:** / **no syzbot**
- **No Cc: stable** (expected; not a negative)
- Ignore pipeline-added Sasha Levin SOB / Upstream markers (none present on the real commit)
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** attr_wof_frame_info() can reuse a cached offsets folio (ni->file.offs_folio). On that path the loop fills off[] from the cached page and never calls attr_load_runs_range() / ntfs_read_run(), so err is never written.
- **Symptom:** common return err then returns uninitialized stack memory. Callers treat any non-zero as failure → spurious I/O errors on WOF LZX/Xpress compressed files after the first cache hit.
- **Version info:** none in the message. Code is present since ntfs3 introduction.
- **Root cause:** int i, err; with err only assigned on I/O / alloc / corruption paths, not on cache-hit success.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: **Not disguised.** This is an explicit uninitialized-variable fix (Initialize X). Matches the KMSAN / uninit-use class even without a sanitizer tag.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: fs/ntfs3/attrib.c — **1 insertion, 1 deletion**
- Function: attr_wof_frame_info()
- Change: int i, err; → int i, err = 0;
- Scope: **single-file surgical fix** (one local initializer)
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record (verified in current fs/ntfs3/attrib.c):
- Resident attribute path returns 0 directly; unaffected.
- Non-resident path:
- Alloc fail: err = -ENOMEM; goto out;
- I/O / metadata fail: err = ...; goto out1;
- **Cache hit** (index == folio->index): loop reads offsets from the cached folio, never assigns err, then falls through to *vbo_data += off[0]; *ondisk_size = off[1] - off[0]; and return err;
- **Before:** cache-hit success returned uninitialized err
- **After:** that path returns 0
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- **Category:** (e) Initialization / uninitialized data use
- **Mechanism:** stack err used as the function return value without assignment on the cached-folio success path
- **Not** a leak, race, refcount, or API change
Step 2.4: ASSESS THE FIX QUALITY
Record:
- **Obviously correct:** initializing err = 0 is the right default; every error path still overwrites err before return
- **Minimal:** one token
- **Regression risk: very low** — does not change locking, structures, or successful I/O that already assigned err
- **Red flags:** none
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Current line is the fix: dd64afb32c4d8 (Ruoyu Wang, 2026-06-18)
- Uninitialized int i, err; dates to **be71b5cba2e648** (“fs/ntfs3:
Add attrib operations”, 2021-08-13)
- Contained in **v5.15-rc1** (git describe --contains be71b5cba2e648 → v5.15-rc1~...)
- Folio conversion c091354d6bf60e (2024) kept the same uninit err; it did not introduce the bug
- The cached offsets page/offs_folio reuse path existed from day one
Step 3.2: FOLLOW THE FIXES: TAG
Record: **No Fixes: tag.** Bug was in the original function, not a later regression commit.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- Nearby: 859d777646b56 (OOB write in same function), other ntfs3 bounds/init fixes
- This commit is **standalone**, not “patch X/Y”
- No prerequisite refactor required for the one-line init
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record:
- Ruoyu Wang: this is their only commit under fs/ntfs3/ in this tree
- Applied by **Konstantin Komarov** (ntfs3 maintainer) — maintainer- accepted
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record:
- Diff assumes only int err in attr_wof_frame_info() — present since v5.15
- **Applies standalone.** No new helpers or struct changes.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c dd64afb32c4d8 →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only** (no later revisions)
- Thread (mbox via b4 dig -m):
- Patch submitted 2026-06-17 by Ruoyu Wang
- Maintainer reply 2026-07-23: “The patch was applied, thank you.”
- **No NAK, no stable nomination, no reviewer risk flags**
- lore.kernel.org HTTP fetch returned **403**; thread recovered via b4 mbox (verified)
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w):
- To/Cc: Konstantin Komarov, [email protected], linux- [email protected]
- Subsystem maintainer was the recipient and applied it
- No extra Reviewed-by tags
Step 4.3: SEARCH FOR THE BUG REPORT
Record: **No Reported-by, no syzbot, no bugzilla.** Bug is from code inspection / static reasoning, confirmed by reading the cache-hit path. No user crash report found.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: **Standalone v1 patch**, not part of a series.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable HTTP search returned **403**. **UNVERIFIED** whether stable@ discussed this. b4 thread has no Cc:
stable. Absence of stable discussion is not a negative here.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: **attr_wof_frame_info()** only. Guarded by CONFIG_NTFS3_LZX_XPRESS.
Step 5.2: TRACE CALLERS
Record:
- Sole caller: ni_read_frame() in fs/ntfs3/frecord.c (~2379), WOF (Xpress/LZX) branch
- ni_read_frame() callers:
- ni_read_folio_cmpr() (frecord.c ~1987) — compressed read_folio
- ni_decompress_file() (frecord.c ~2087) — decompress on write/size change
- ntfs_file_write_iter path in file.c (~1056, ~1121) — extending valid size / writing compressed files
- ntfs_read_folio() (inode.c ~850) calls ni_read_folio_cmpr() when is_compressed(ni)
Step 5.3: TRACE CALLEES
Record (success cache path does not call these):attr_load_runs_range(), ntfs_read_run(), folio_alloc(), folio lock/unlock, down_write/up_write on ni->file.run_lock. Bug is return-value init, not those callees.
Step 5.4: FOLLOW THE CALL CHAIN
Record:
- Userspace read() → VFS read_folio → ntfs_read_folio() → ni_read_folio_cmpr() → ni_read_frame() → attr_wof_frame_info()
- **Reachable from userspace** on NTFS volumes with Windows 10+ compact.exe WOF files (CONFIG_NTFS3_LZX_XPRESS, Kconfig “recommended Y”)
- Cache is per-inode (ni->file.offs_folio); sequential reads of a compressed file hit the uninit path **after the first frame on that offsets page** (typical, not rare)
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: ntfs3 has many prior uninit fixes (5f33da04e6cee KMSAN, a8a3ca23bbd9d, 57ac2831c8e0f, etc.). Same class of bug; this instance was missed until 2026.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record:
- git describe HEAD = **v7.3-rc4-27-gf0100363d8c37**
- make kernelversion = **7.3.0-rc4**
- attr_wof_frame_info() is present; current code already has int i, err = 0; (this commit is an ancestor of HEAD)
- **Buggy pattern existed here** from v5.15 through parent of dd64afb32c4d8
- Bug was **not** introduced after this tree; it is native to this lineage
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **Clean apply.** One-line change to a declaration that has been int i, err; since 2021. Folio vs page rename does not affect this line.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: This exact fix **is** commit dd64afb32c4d8 in this checkout. No different competing fix for the same uninit err. Per instructions, that is not used as “already selected → skip”; it confirms the maintainer accepted the same one-line change.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY Record:
- **Subsystem:** fs/ntfs3 (NTFS3 filesystem)
- **Criticality:** **IMPORTANT** — not core VFS/mm, but a production filesystem used for Windows volumes, dual-boot, and some distros. Failure is I/O error / failed reads, not a global panic.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Active (regular ntfs3_for_7.x pulls, many 2026 fixes). This particular bug is **old** (2021), not a new-subsystem-only issue.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: **Filesystem-specific + config-specific:** CONFIG_NTFS3_FS + CONFIG_NTFS3_LZX_XPRESS, users reading WOF-compressed files (Windows 10 compact xpress4k/8k/16k/lzx).
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record:
- Trigger: read (or decompress-on-write) of a **non-resident** WOF compressed stream after offs_folio already holds the needed offsets page
- **Common** for sequential reads of a compressed file (page holds many 32/64-bit offsets)
- **Unprivileged users** can trigger it if they can read such files
- Not a race; deterministic once the folio is cached
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- Failure: return of uninitialized err to ni_read_frame() → if (err) goto out1;
- If stack garbage is non-zero: **read/decompress fails** (EIO-class userspace error) despite successful offset decode
- If garbage is zero: silent luck
- C2 unsafety / KMSAN-class uninit use
- **Severity: HIGH** (broken reads of compressed files; undefined behavior). Not a guaranteed oops, not data corruption of written data.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit:** high for ntfs3+WOF users — fixes real false I/O failures on a hot cached path
- **Risk:** very low (one initializer)
- **Ratio:** strongly favorable
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
**FOR backporting:**
- Real uninitialized return on a realistic, common cache-hit path (verified in source)
- Userspace-reachable via normal reads of WOF-compressed NTFS files
- One-line, obviously correct, maintainer-applied
- Code present in this tree since v5.15; no missing prerequisites
- Matches stable’s uninitialized-data / KMSAN class (even without a sanitizer report)
**AGAINST:**
- No crash/syzbot/CVE report; failure is typically spurious I/O error, not panic
- Limited to ntfs3 WOF (CONFIG_NTFS3_LZX_XPRESS), not all kernel users
- No explicit Cc: stable (not a valid NO reason in this pipeline)
**UNRESOLVED:**
- Could not HTTP-fetch lore.kernel.org (403); used b4 mbox instead
- No stable@ thread verified
- No KMSAN/syzbot report located for this exact function
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — one initializer; maintainer applied it
2. Fixes a real bug that affects users? **PASS** — uninit err on cached WOF reads
3. Important issue? **PASS** — HIGH: failed reads / UB on compressed files (not a panic, but user-visible breakage)
4. Small and contained? **PASS** — 1 line, 1 function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — declaration exists; applies cleanly
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Not a device-ID/quirk/DT/docs exception. It is a normal uninit bugfix.
Step 9.4: MAKE YOUR DECISION
This tree contains attr_wof_frame_info() and the cached-folio path. The one-line init is a real, contained fix for returning uninitialized error codes on WOF compressed reads. It meets stable-kernel rules for this checkout.
**What the commit solves:** On cache reuse, err was never set, so the function returned stack garbage. Callers abort the read. Initializing err = 0 makes the successful cached path return success.
**Risk vs benefit:** Benefit is fixing broken/undefined reads of WOF files; risk is a single local initializer.
**Concerns:** None on dependencies or apply difficulty. Impact is ntfs3+WOF only, which is acceptable for a filesystem correctness fix.
Verification:
- [Phase 1] Parsed tags: author + maintainer SOB only; no Fixes/syzbot/Cc stable
- [Phase 1] Subject/body: initialize err for cached offsets folio path
- [Phase 2] Diff: 1 line in attr_wof_frame_info(), int i, err → int i, err = 0
- [Phase 2] Confirmed cache-hit loop skips attr_load_runs_range/ntfs_read_run then return err
- [Phase 3] git blame: uninit err from be71b5cba2e648 (v5.15-rc1)
- [Phase 3] Folio conversion c091354d6bf60e kept uninitialized err
- [Phase 3] Author: one ntfs3 commit; applied by Konstantin Komarov
- [Phase 3] Standalone; git merge-base --is-ancestor dd64afb32c4d8 HEAD is true
- [Phase 4] b4 dig -c: lore msgid [email protected]
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: maintainer + ntfs3 list + lkml
- [Phase 4] mbox: maintainer “patch was applied”; no NAK
- [Phase 4] lore HTTP 403 — discussion via b4 only
- [Phase 5] Only caller ni_read_frame(); chain from ntfs_read_folio / ni_read_folio_cmpr
- [Phase 5] semcode MCP not available; used grep/read
- [Phase 6] Local tree v7.3-rc4; function present; parent still had int i, err;
- [Phase 7] fs/ntfs3, IMPORTANT, actively maintained
- [Phase 8] Trigger: cached WOF offset folio on compressed file read; severity HIGH
- UNVERIFIED: stable@ mailing list discussion (HTTP 403)
- UNVERIFIED: no KMSAN/syzbot report found for this exact bug
**YES**
fs/ntfs3/attrib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/attrib.c +1 -1
@@ -1410,7 +1410,7 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr,u8 bytes_per_off;char *addr;struct folio *folio; -int i, err; +int i, err =0 ;__le32 *off32;__le64 *off64;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ntfs3: fix info-leak in ntfs_rename()
In reply to Sasha LevinFrom: Konstantin Komarov <[email protected]>
[ Upstream commit 2fa56613b25d0c983ef3ff6d3e865d4254280abe ]
Hard to say about copy_to_user_iter(), but at least the first splat looks correct. At the end of fill_name_de(), data layout is:
struct NTFS_DE *e = buf;
...
|<- data_size + sizeof(struct NTFS_DE) ->|<- XXX ->|
buf |-----------------------------------------------------------
|<- ALIGN(data_size, 8) + sizeof(struct NTFS_DE) ->| ;; e->sizeIf 'buf' was allocated with kmalloc(), XXX remains uninitialized and passed as such to memcpy() called from hdr_insert_de().
So using kzalloc() for all buffers passed to fill_name_de() looks the simplest and most safe solution. OTOH if someone would have said that an overhead of PAGE_SIZE'd memset() is too large, more fine-granted solution is to memset() XXX only.
---
LLM Generated explanations, may be completely bogus:
This is a real KMSAN kernel infoleak in ntfs3 rename: 8-byte alignment padding in directory entries is copied from uninitialized kmalloc() memory onto the volume. The local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37); ntfs3 and fill_name_de() exist here, and the fix is small, correct, and reachable from rename(2).
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[ntfs3] [fix] info-leak in ntfs_rename()**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Reported-by:** [email protected] (syzbot / KMSAN)
- **Closes:** https://syzkaller.appspot.com/bug?extid=905d785c4923bea2c1db
- **Signed-off-by:** Dmitry Antipov (author of the analysis/patch); Konstantin Komarov (ntfs3 maintainer, applied it)
- **No Fixes:** tag on the committed version (v1 on-list had `Fixes:
ca2a04e84af7`, dropped later)
- **No Cc: stable** (expected for this review)
- **No Tested-by / Reviewed-by / Acked-by / Link:** (Closes URL is the bug tracker)
Notable: syzbot + maintainer SOB.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** After fill_name_de(), e->size is 8-byte-aligned (ALIGN(data_size, 8) + sizeof(NTFS_DE)). The pad between `data_size
+ sizeof(NTFS_DE) and that aligned size (XXX) is never written if buf came from kmalloc()`.
- **Failure mode:** That pad is memcpy()’d in hdr_insert_de(), written out with the index/MFT record, then observed as a **KMSAN kernel-infoleak** when the block is later read into userspace (copy_to_user_iter / filemap_read).
- **Root cause (author):** uninitialized alignment padding, not a rename() copy_to_user of the name buffer itself.
- **Fix chosen:** memset only XXX (0–7 bytes), instead of kzalloc(PATH_MAX) for every caller.
- **Version info in message:** none.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Subject and body describe a KMSAN infoleak. The “fine-grained memset” wording is the fix, not cleanup.
===============================================================
PHASE 2: DIFF ANALYSIS
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** fs/ntfs3/namei.c only (+7 / -2)
- **Function:** fill_name_de()
- **Scope:** single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** e->size = cpu_to_le16(ALIGN(data_size, 8) + sizeof(struct NTFS_DE)); with no write of the pad.
- **After:** compute real_size and aligned_size; if they differ, memset the pad; then set e->size to aligned_size.
- **Path:** every fill_name_de() caller (rename still uses kmalloc(PATH_MAX); create/link/unlink already kzalloc).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** uninitialized data / kernel infoleak (KMSAN)
- **Mechanism:** hdr_insert_de() does memcpy(before, de, de_size) with de_size = le16_to_cpu(de->size) including alignment pad. Pad bytes are slab leftovers. They land in the directory index, get written via ni_write_inode → ntfs_write_bh, then leak through blkdev_read_iter / filemap_read.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: pad length is ALIGN(x,8)-x ∈ [0,7]; memset only when needed.
- Minimal; no API/locking/refcount changes.
- Regression risk very low: those bytes were garbage; NTFS index entries are 8-byte aligned and pad should be zero.
- Completeness: this matches the KMSAN “Bytes 404-407 of 1536” (4-byte pad). ni_add_name() still fills ref/home/dup after fill_name_de(), so this is not trying to zero the whole ATTR_FILE_NAME.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Alignment-in-e->size comes from **4342306f0f0d5** (fs/ntfs3: Add file operations and implementation, 2021-08-13; originally QuadAlign(data_size)).
- **fa3cacf544636** only switched QuadAlign to ALIGN.
- Bug present since ntfs3 was added (**v5.15-era**).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: Committed version has **no Fixes:** tag. On-list v1 used `Fixes:ca2a04e84af7 (ntfs: ->d_compare() must not block), which swapped __getname() for kmalloc() — both uninitialized. That tag is **wrong**; the leak is as old as fill_name_de(). ca2a04e84af79` **is** an ancestor of this HEAD, but is **not** a prerequisite for the memset.
**Step 3.3: CHECK FILE HISTORY**
Record: Recent namei.c work is ADS, mkdir, vfs ->create. **No follow-up** to this infoleak. Not patch X/Y. Standalone.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Dmitry Antipov has no other recent ntfs3 commits in this history. Konstantin Komarov is the ntfs3 maintainer and applied the memset form.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Uses existing fill_name_de, ALIGN, fname_full_size, NTFS_DE. **Applies standalone.** ntfs_rename can keep kmalloc.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **b4 dig:**
https://patch.msgid.link/[email protected]
- **Series:** v1 only ([PATCH] ntfs3: fix info-leak in ntfs_rename()), 2026-06-09
- **v1 diff:** kmalloc → kzalloc in ntfs_rename only
- **Al Viro** asked how that buffer reaches copy_to_user_iter(), then guessed a deeper metadata/bh reuse bug
- **Dmitry** explained the pad/hdr_insert_de path and posted the memset version (what landed)
- **Konstantin (2026-07-15):** “The patch is applied, thank you.” No NAK. No Cc: stable in-thread.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (**b4 dig -w**): Dmitry Antipov, Konstantin Komarov, Al Viro, [email protected], [email protected], syzbot. Maintainer applied it after VFS questions.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record (syzkaller):
- Title: **KMSAN: kernel-infoleak in filemap_read**
- First crash 2023-12-20; C repro; **9090** crashes; prio:high
- Uninit created at kmalloc in ntfs_rename; stored in hdr_insert_de → indx_insert_into_root → ni_rename; written via ntfs_write_bh; copied out via blkdev_read_iter (sample: **udevd**)
- Syzbot lists **2fa56613b25d** as the fix commit
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone. Related local infoleak: 35d1ea92c7d94 (LZNT decompress) — different path.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** — lore.kernel.org/stable returned 403. No local evidence this was rejected for stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: KEY FUNCTIONS**
Record: fill_name_de(); leak sink hdr_insert_de(); user entry ntfs_rename() → ni_rename() → ni_add_name() → indx_insert_entry().
**Step 5.2: TRACE CALLERS**
Record (git grep):
- ntfs_rename() — rename(2); kmalloc(PATH_MAX) (**the syzbot path**)
- ntfs_create_inode() — create/mkdir/symlink; already kzalloc
- ntfs_link_inode() — link(2); already kzalloc
- ntfs_unlink_inode() — unlink/rmdir; already kzalloc
**Step 5.3: TRACE CALLEES**
Record: ntfs_nls_to_utf16 / memcpy for the name; fname_full_size; then memset of pad.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace rename() on ntfs3 → directory index insert → MFT/index write → later read() of the block device (udev) copies pad to userspace. **Reachable from a normal syscall** on a mounted ntfs3 volume.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Other fill_name_de callers already kzalloc. Rename is the remaining kmalloc caller; fixing fill_name_de covers all of them.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- Tree: **7.3.0-rc4** (git describe: v7.3-rc4-27-gf0100363d8c37)
- fs/ntfs3/namei.c and fill_name_de() exist
- Bug introduced **4342306f0f0d5** (ntfs3 add, ~5.15); **is ancestor of HEAD**
- Current fill_name_de() **already contains** this memset (git merge- base --is-ancestor 2fa56613b25d0 HEAD → yes)
- ntfs_rename still does de = kmalloc(PATH_MAX, GFP_KERNEL) — the memset is what stops the leak
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Hunk is local to fill_name_de and matches the long-standing function shape (QuadAlign/ALIGN + e->size). **Clean apply** on any tree with original fill_name_de. No structural prereq.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This **is** the fix (2fa56613b25d0). No later replacement. LZNT infoleak is separate.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: **fs/ntfs3** — **IMPORTANT** (in-tree RW NTFS since 5.15; not core VFS, but a real production FS). Not staging.
**Step 7.2: SUBSYSTEM ACTIVITY**
Record: Actively maintained (Paragon / Komarov); mix of features and sanitizer/bounds fixes.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: WHO IS AFFECTED**
Record: **Filesystem-specific** — CONFIG_NTFS3_FS users who rename on ntfs3. Trigger is rename, not an obscure ioctl.
**Step 8.2: TRIGGER CONDITIONS**
Record: rename(2) when the new name is inserted into a directory index. Common. Unprivileged users with write access to an ntfs3 mount can write slab leftovers into on-disk index entries. The syzbot read path is blkdev_read_iter (typically privileged udev), but the **confidentiality failure is writing kernel heap into the volume**.
**Step 8.3: FAILURE MODE SEVERITY**
Record: **KMSAN kernel-infoleak** of uninitialized kmalloc memory onto disk / into a later userspace read. **Severity: HIGH** (security infoleak; not a panic). Syzbot prio:high; C repro; thousands of crashes.
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit:** high — stops a real, fuzzer-reproduced kernel infoleak on a syscall path
- **Risk:** very low — 5-line memset of 0–7 pad bytes
- **Ratio:** strongly favors taking the fix
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Syzbot KMSAN kernel-infoleak with C repro and a clear kmalloc → hdr_insert_de → disk → copy_to_user chain
- Small, obviously correct memset of alignment padding
- ntfs3 maintainer applied it after discussion with Al Viro
- Bug present since ntfs3 introduction; code exists in this tree
- No new API, no locking, no series dependencies
- Rename still uses kmalloc; without this, the leak remains
AGAINST:
- Al Viro first wondered if copy_to_user meant a deeper metadata-reuse bug; Dmitry’s pad explanation is what was applied, and it matches the first splat
- Infoleak, not a crash (still stable-worthy)
- lore.kernel.org HTTP 403; stable-list history not independently fetched
UNRESOLVED:
- Whether older stable series already carried a different zeroing approach (not this 7.3 tree)
- Whether KMSAN instances still listed as “missing” are stale vs. a second leak
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — pad math is local; syzbot + maintainer apply
2. Fixes a real bug that affects users? **PASS** — KMSAN infoleak, C repro, udev read of written metadata
3. Important (crash/security/corruption/deadlock)? **PASS** — kernel infoleak / security, HIGH
4. Small and contained? **PASS** — fill_name_de only, ~5 lines
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — same function exists; no missing helpers
**Step 9.3: EXCEPTION CATEGORIES**
Record: None (not an ID/quirk/DT/build/doc exception). It is a normal memory-safety fix.
**Step 9.4: DECISION**
This tree has ntfs3 and the buggy fill_name_de/ntfs_rename design. The change is a contained KMSAN infoleak fix with a documented syscall trigger. It meets stable criteria on technical merit.
Verification:
- [Phase 1] Tags: syzbot Reported-by + Closes URL; maintainer SOB; no Fixes on committed form
- [Phase 2] Diff: +7/-2 in fill_name_de; memset of aligned_size - real_size
- [Phase 2] hdr_insert_de (index.c:873): memcpy(before, de, de_size) with de_size from de->size
- [Phase 3] Blame: 4342306f0f0d5 introduced QuadAlign size; fa3cacf544636 switched to ALIGN
- [Phase 3] git merge-base --is-ancestor 4342306f0f0d5 HEAD → 0 (bug origin in this tree)
- [Phase 3] git merge-base --is-ancestor 2fa56613b25d0 HEAD → 0 (this SHA is in HEAD)
- [Phase 3] Original v1 Fixes: ca2a04e84af79 is in HEAD but is not required for the memset
- [Phase 4] b4 dig -c 2fa56613b25d0: lore msgid [email protected]
- [Phase 4] b4 dig -a: v1 only; committed code is Dmitry’s follow-up memset, not v1 kzalloc
- [Phase 4] b4 dig -w: ntfs3 list, Komarov, Al Viro, syzbot, lvc- project
- [Phase 4] mbox: Viro questions; Dmitry pad diagram; Komarov “patch is applied”
- [Phase 4] WebFetch lore.kernel.org → 403; used b4 mbox instead
- [Phase 4] syzbot: KMSAN infoleak, C repro, uninit at ntfs_rename kmalloc, store at hdr_insert_de
- [Phase 5] Callers: rename (kmalloc), create/link/unlink (kzalloc)
- [Phase 5] ni_add_name fills ref/home/dup after fill_name_de; then indx_insert_entry
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- [Phase 6] Current namei.c lines 56–61 already have the memset
- [Phase 8] Failure mode: kernel heap bytes written into NTFS index and readable via blkdev read
- UNVERIFIED: stable@ mailing-list discussion (lore 403)
**YES**
fs/ntfs3/namei.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/ntfs3/namei.c +7 -2
@@ -22,7 +22,7 @@ int fill_name_de(struct ntfs_sb_info *sbi, void *buf, const struct qstr *name, {int err;struct NTFS_DE *e = buf; -u16 data_size; +u16 data_size, real_size, aligned_size;struct ATTR_FILE_NAME *fname = (struct ATTR_FILE_NAME *)(e +1 );#ifndef CONFIG_NTFS3_64BIT_CLUSTER
@@ -53,7 +53,12 @@ int fill_name_de(struct ntfs_sb_info *sbi, void *buf, const struct qstr *name, fname->type =FILE_NAME_POSIX ; data_size =fname_full_size (fname); - e->size =cpu_to_le16 (ALIGN (data_size,8 ) +sizeof (struct NTFS_DE )); + real_size = data_size +sizeof (struct NTFS_DE ); + aligned_size =ALIGN (data_size,8 ) +sizeof (struct NTFS_DE ); +if (aligned_size > real_size) +memset ((char *)buf + real_size,0 , aligned_size - real_size); + + e->size =cpu_to_le16 (aligned_size); e->key_size =cpu_to_le16 (data_size); e->flags =0 ; e->res =0 ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 drm/amd/pm: Guard VBIOS AC timing table walk
In reply to Sasha LevinFrom: Xiang Liu <[email protected]>
[ Upstream commit 2bf6867e5953a140fc91c3159987656e44ed29fb ]
Reject AC timing blocks with a stride smaller than a dword before walking VBIOS data. A zero stride can otherwise keep reg_data pinned on a nonmatching MEM_ID forever.
Also bound the data-block and END marker reads by the returned VRAM_Info table size so malformed index/data sizes do not push the timing walk past the table.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: [drm/amd/pm] [Guard] Reject undersized VBIOS AC timing strides and bound the table walk
Subsystem drm/amd/pm. Verb is **Guard** (defensive bounds / hang prevention), not a feature addition.
**Step 1.2: Tags**
Record:
- Signed-off-by: Xiang Liu <[email protected]> (author)
- Reviewed-by: Hawking Zhang <[email protected]> (AMD reviewer)
- Signed-off-by: Alex Deucher <[email protected]> (amdgpu maintainer)
- No Fixes:, Reported-by:, Tested-by:, Link:, or Cc: stable (absence is expected for this review)
- Pipeline markers ([ Upstream commit 2bf6867e5953... ], `Signed-off-
by: Sasha Levin`) ignored per instructions
**Step 1.3: Body**
Record:
- **Bug:** atomctrl_retrieve_ac_timing() walks VBIOS AC timing blocks using usRegDataBlkSize as the stride. A zero (or sub-dword) stride never advances reg_data. If the pinned dword’s MEM_ID does not match index, num_ranges never increases, so the VBIOS_MAX_AC_TIMING_ENTRIES cap never fires.
- **Symptom:** infinite loop / hang during GPU powerplay init.
- **Second bug:** index/data sizes can walk past the VRAM_Info table; unbounded dword reads of the END marker and per-entry payload.
- **Root cause:** firmware table walk trusts VBIOS sizes with no stride or table-end check.
- **Version info:** none in the message. Code has been in-tree since v4.5.
**Step 1.4: Hidden bug fix?**
Record: Not hidden. It is an explicit hang + OOB hardening of a firmware parser. “Guard” here means missing validation, not a cleanup.
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- File: drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c — **+22 / −6**
- Functions: atomctrl_retrieve_ac_timing, atomctrl_initialize_mc_reg_table, atomctrl_initialize_mc_reg_table_v2_2
- Scope: single-file surgical fix
**Step 2.2: Code flow**
Record:
1. atomctrl_retrieve_ac_timing: cache stride = le16_to_cpu(usRegDataBlkSize); **before:** walk with raw stride; **after:** -EINVAL if stride < 4.
2. Loop: **before:** while (*(u32 *)reg_data != END && num_ranges < 20); **after:** also require (u8 *)reg_data + 4 <= table_end before the read.
3. Inner DATA_FROM_TABLE copies: **before:** unbounded *((u32 *)reg_data + j); **after:** reject if that dword would pass table_end.
4. Advance: same addition, using cached stride.
5. Exit: **before:** PP_ASSERT_WITH_CODE that the current dword is END_OF_REG_DATA_BLOCK (0), which itself can read past the table; **after:** bounds-check then compare, return -EINVAL.
6. Callers: both init helpers already have size from smu_atom_get_data_table() but unused for the walk; they now set table_end = (u8 *)vram_info + size and pass it in.
**Step 2.3: Bug mechanism**
Record:
- **Category:** logic / memory-safety (infinite loop + OOB read)
- **Mechanism:** stride 0 pins reg_data. END_OF_REG_DATA_BLOCK is 0x00000000. If that dword is nonzero and MEM_ID ≠ index, the loop never terminates. Large stride or oversized index table walks off the claimed VRAM_Info blob into adjacent BIOS/kernel memory.
**Step 2.4: Fix quality**
Record: Obviously correct C short-circuit bounds checks. Minimal. No API change (atomctrl_retrieve_ac_timing is static). Regression risk is
low: a valid AC block must be at least one dword (MEM_ID + clock). table_end uses the ATOM header size already returned to these functions. Residual gap: atomctrl_set_mc_reg_address_table() and usMemClkPatchTblOffset are still unchecked; sibling parsers in amdgpu_atombios.c / radeon_atombios.c still have the old walk. That does not make this patch incorrect.
## Phase 3: Git history
**Step 3.1: Blame**
Record: Unbounded walk introduced in c82baa2818435 (“drm/amd/powerplay: add Tonga dpm support (v3)”, 2015-12-21), first in **v4.5-rc1**. Present on this 6.18 tree. Only later touch of the same
loop: 12c6967428a09 (2024) added if (i) for DATA_EQU_PREV OOB on mc_data[-1], not this stride/end-marker bug.
**Step 3.2: Fixes: tag**
Record: None. Buggy code is the original 2015 parser, not a recent regression.
**Step 3.3: File history**
Record: Recent related work on this file: NULL checks in atomctrl_initialize_mc_reg_table (820116a39f96b, already in v6.18.53). No prerequisite refactor. No “patch X/Y”. Standalone.
**Step 3.4: Author**
Record: Xiang Liu is an AMD drm/amdgpu contributor (many amdgpu commits). Hawking Zhang reviewed; Alex Deucher applied. Not a drive-by.
**Step 3.5: Dependencies**
Record: None. Uses existing smu_atom_get_data_table(..., &size, ...), existing structs, no new helpers. Applies standalone.
## Phase 4: Mailing list
**Step 4.1:** b4 dig -c 2bf6867e5953a140fc91c3159987656e44ed29fb
Record: lore URL https://patch.msgid.link/[email protected]. **v1 only** (no v2/v3). Thread: patch + Hawking Reviewed-by. No NAK, no stable debate, no requested rework. Direct WebFetch of lore.kernel.org returned **403**; thread recovered via b4 dig -m.
**Step 4.2:** b4 dig -w
Record: To [email protected]; Cc Hawking Zhang, Tao Zhou, Stanley Yang, YiPeng Chai. Right list and AMD PM reviewers.
**Step 4.3: Bug report**
Record: No Reported-by / syzbot / bugzilla. Author-described defect from code inspection. Unverified whether a specific card hung in the wild.
**Step 4.4: Series**
Record: Single standalone [PATCH], not N/M.
**Step 4.5: Stable list**
Record: lore.kernel.org/stable WebFetch 403. **UNVERIFIED** whether stable@ already discussed this; that does not change the technical verdict.
## Phase 5: Semantic / call graph
**Step 5.1: Functions**
Record: atomctrl_retrieve_ac_timing,atomctrl_initialize_mc_reg_table,atomctrl_initialize_mc_reg_table_v2_2.
**Step 5.2: Callers**
Record:
- tonga_initialize_mc_reg_table → atomctrl_initialize_mc_reg_table
- iceland_initialize_mc_reg_table → same
- ci_initialize_mc_reg_table → same
- polaris10_initialize_mc_reg_table → atomctrl_initialize_mc_reg_table_v2_2
- Those are .initialize_mc_reg_table in SMU7 smumgr; smum_initialize_mc_reg_table() is called from smu7_hwmgr.c during DPM enable (device init / resume), **without checking the return value**.
**Step 5.3: Callees**
Record: smu_atom_get_data_table() → amdgpu_atom_parse_data_header(); pointer is atom_context->bios + data_start; size is the ATOM table size.
**Step 5.4: Reachability**
Record: Yes, from normal amdgpu load on CI / Tonga / Iceland / Polaris (RX 400/500-class, still common). Not a syscall fuzzer path; firmware- driven probe/resume. Unprivileged users cannot craft VBIOS on a locked ROM, but custom/modded Polaris VBIOS is common, and a bad image hangs the kernel in this loop.
**Step 5.5: Similar patterns**
Record: Same unguarded walk remains in amdgpu_atombios_init_mc_reg_table() and radeon_atombios.c. This commit only hardens the powerplay copy. Sibling bugs are not a reason to reject this fix.
## Phase 6: This tree (6.18.53)
**Step 6.1:**
Record: Local tree is **6.18.53** (v6.18.53-5049-g0f0bdc2b0dffb, branch autosel).git merge-base --is-ancestor 2bf6867e5953... v6.18.53 → **not an ancestor**.
v6.18.53 still has the unguarded while (*(uint32_t *)reg_data != END_OF_REG_DATA_BLOCK && ...) in atomctrl_retrieve_ac_timing(). Bug exists here.
**Step 6.2:**
Record: git apply --check of the upstream diff onto a v6.18.53 copy of the file **succeeded** (exit 0). Clean apply. No structural drift.
**Step 6.3:**
Record: 12c6967428a09 and 820116a39f96b are in v6.18.53; they do not implement stride/table_end guards. No alternate fix present.
## Phase 7: Subsystem
**Step 7.1:**
Record: drivers/gpu/drm/amd/pm/powerplay — **IMPORTANT** (legacy GCN powerplay, not core mm/net, but production GPU init).
**Step 7.2:**
Record: File is mature (2015). Little recent churn besides docs, a NULL check, and the 2024 mc_data[i-1] guard. Long-lived bug, not a new- subsystem issue.
## Phase 8: Impact and risk
**Step 8.1:** Driver-specific: CI/Tonga/Iceland/Polaris via powerplay (CONFIG_DRM_AMDGPU, typically DRM_AMDGPU_CIK for CI). Polaris is still widely deployed.
**Step 8.2:** Trigger: GPU DPM bring-up when VRAM_Info AC timing has usRegDataBlkSize < 4 or truncated/malformed blocks. Common on **valid** VBIOS: no. Realistic on corrupted, truncated, or vendor-modded
VBIOS: yes. Not a userspace syscall primitive.
**Step 8.3:** Failure mode:
- Zero stride + nonmatching MEM_ID → **infinite loop in probe/resume** → **CRITICAL** hang
- Walk past table → **OOB read** → **HIGH** (crash / KASAN)
**Step 8.4:** Benefit: prevent hang/OOB on a long-lived parser used at init. Risk: ~22 lines, error-path only for bad firmware. Valid tables keep working. Ratio is favorable.
Ignored smum_initialize_mc_reg_table() return means a now-failing parse no longer hangs; MC timing table may stay empty. That is still better than a soft lockup, and matches other -EINVAL paths already in these helpers.
## Phase 9: Synthesis
**For:**
- Real hang (zero stride) and real OOB (unbounded VBIOS walk)
- Code present since v4.5; **present and unfixed in this 6.18.53 tree**
- Small, obviously correct, no new API
- Maintainer SOB + AMD review; v1 accepted as-is
- Clean apply to this tree; no prerequisites
- Polar / CI powerplay still used here
**Against:**
- No public reproducer / syzbot / CVE
- Trigger is malformed firmware, not every boot
- Sibling parsers not fixed in the same patch
- usMemClkPatchTblOffset still unchecked (pre-existing)
**Unresolved:** stable@ discussion (lore 403); whether a specific customer VBIOS hit this.
**Stable rules:**
1. Obviously correct and tested — **PASS** (reviewed, merged, logic is local bounds checks)
2. Real bug affecting users — **PASS** (hang/OOB on bad VBIOS; Polaris custom BIOS is a real population)
3. Important (crash/hang) — **PASS** (infinite loop in GPU init)
4. Small and contained — **PASS** (22/6, one file)
5. No new features/APIs — **PASS**
6. Applies to this tree — **PASS** (clean on v6.18.53)
**Exception category:** not a device-ID/quirk/DT/build/doc exception. It is a firmware-parser safety fix.
This meets stable rules for **this** 6.18.y tree: the buggy walk is here, the fix is surgical, and the failure mode is a hang or OOB during amdgpu powerplay init.
### What it solves for stable users
On CI/Tonga/Iceland/Polaris, powerplay walks the VBIOS AC timing table with a stride taken from the image. A zero stride can spin forever; a bad size can read past the table. The patch rejects sub-dword strides and caps every dword access by the ATOM-reported VRAM_Info size, turning a probe hang/OOB into -EINVAL.
### Risk vs benefit
Benefit is avoiding a hard-to-debug init hang and OOB on firmware that is already treated as untrusted input. Risk is a few bounds checks on an error path; valid VBIOS is unchanged. Residual unfixed copies elsewhere do not block this backport.
### Concerns
No Fixes: lineage; leftover unbounded walks in atomctrl_set_mc_reg_address_table and amdgpu_atombios.c. Neither is a dependency of this patch. Apply to 6.18.53 is clean.
Verification:
- [Phase 1] Parsed tags: author Xiang Liu, R-b Hawking Zhang, SOB Alex Deucher; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: +22/−6 in ppatomctrl.c; stride < sizeof(u32) reject; table_end on loop, payload, END marker
- [Phase 2] END_OF_REG_DATA_BLOCK is 0x00000000 in atombios.h:7486; zero stride + nonzero nonmatching MEM_ID loops forever
- [Phase 3] git blame on v6.18.53: walk from c82baa2818435 (v4.5-rc1)
- [Phase 3] git merge-base --is-ancestor 2bf6867e5953 v6.18.53 → not present in 6.18.53
- [Phase 3] 12c6967428a09 / 820116a39f96b do not implement this guard; latter is already in 6.18.53
- [Phase 4] b4 dig -c 2bf6867e5953: v1 only,
https://patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: single revision; b4 dig -w: amd-gfx + AMD reviewers; mbox: Hawking Reviewed-by, no NAK
- [Phase 4] WebFetch lore/stable: 403 — UNVERIFIED stable-list history
- [Phase 5] Callers: tonga/iceland/ci + polaris10 smumgr → smum_initialize_mc_reg_table from smu7_hwmgr.c:1582 (return ignored)
- [Phase 5] Same pattern still in amdgpu_atombios.c:1511 and radeon_atombios.c:4031
- [Phase 6] make kernelversion / git describe: 6.18.53; pre-image matches; apply --check on v6.18.53 copy exit 0
- [Phase 8] Failure: infinite loop or OOB at GPU DPM init; severity hang/crash
- UNVERIFIED: whether a specific shipping VBIOS has been observed with stride 0
**YES**
.../drm/amd/pm/powerplay/hwmgr/ppatomctrl.c | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c +22 -6
@@ -46,16 +46,22 @@ union voltage_object_info {static int atomctrl_retrieve_ac_timing (uint8_t index,ATOM_INIT_REG_BLOCK *reg_block, +u8 *table_end,pp_atomctrl_mc_reg_table *table) {uint32_t i, j; +u16 stride =le16_to_cpu (reg_block->usRegDataBlkSize);uint8_t tmem_id;ATOM_MEMORY_SETTING_DATA_BLOCK *reg_data = (ATOM_MEMORY_SETTING_DATA_BLOCK *) ((uint8_t *)reg_block + (2 *sizeof (uint16_t )) +le16_to_cpu (reg_block->usRegIndexTblSize));uint8_t num_ranges =0 ; -while (*(uint32_t *)reg_data !=END_OF_REG_DATA_BLOCK && +if (stride <sizeof (uint32_t )) +return -EINVAL ; + +while ((uint8_t *)reg_data +sizeof (uint32_t ) <= table_end && + *(uint32_t *)reg_data !=END_OF_REG_DATA_BLOCK && num_ranges <VBIOS_MAX_AC_TIMING_ENTRIES ) { tmem_id = (uint8_t )((*(uint32_t *)reg_data &MEM_ID_MASK ) >>MEM_ID_SHIFT );
@@ -67,6 +73,10 @@ static int atomctrl_retrieve_ac_timing(for (i =0 , j =1 ; i < table->last; i++) {if ((table->mc_reg_address[i].uc_pre_reg_data &LOW_NIBBLE_MASK ) ==DATA_FROM_TABLE ) { +if ((uint8_t *)reg_data + + (j +1 ) *sizeof (uint32_t ) > table_end) +return -EINVAL ; + table->mc_reg_table_entry[num_ranges].mc_data[i] = (uint32_t )*((uint32_t *)reg_data + j); j++;
@@ -81,11 +91,13 @@ static int atomctrl_retrieve_ac_timing( } reg_data = (ATOM_MEMORY_SETTING_DATA_BLOCK *) - ((uint8_t *)reg_data +le16_to_cpu (reg_block->usRegDataBlkSize)) ; + ((uint8_t *)reg_data + stride); } -PP_ASSERT_WITH_CODE ((*(uint32_t *)reg_data ==END_OF_REG_DATA_BLOCK ), -"Invalid VramInfo table." , return -1 ); +if ((uint8_t *)reg_data +sizeof (uint32_t ) > table_end || + *(uint32_t *)reg_data !=END_OF_REG_DATA_BLOCK ) +return -EINVAL ; + table->num_entries = num_ranges;return 0 ;
@@ -136,6 +148,7 @@ int atomctrl_initialize_mc_reg_table( {ATOM_VRAM_INFO_HEADER_V2_1 *vram_info;ATOM_INIT_REG_BLOCK *reg_block; +u8 *table_end;int result =0 ;u8 frev, crev;u16 size;
@@ -157,6 +170,7 @@ int atomctrl_initialize_mc_reg_table( }if (0 == result) { + table_end = (uint8_t *)vram_info + size; reg_block = (ATOM_INIT_REG_BLOCK *) ((uint8_t *)vram_info +le16_to_cpu (vram_info->usMemClkPatchTblOffset)); result =atomctrl_set_mc_reg_address_table (reg_block, table);
@@ -164,7 +178,7 @@ int atomctrl_initialize_mc_reg_table(if (0 == result) { result =atomctrl_retrieve_ac_timing (module_index, - reg_block, table); + reg_block, table_end, table); }return result;
@@ -177,6 +191,7 @@ int atomctrl_initialize_mc_reg_table_v2_2( {ATOM_VRAM_INFO_HEADER_V2_2 *vram_info;ATOM_INIT_REG_BLOCK *reg_block; +u8 *table_end;int result =0 ;u8 frev, crev;u16 size;
@@ -198,6 +213,7 @@ int atomctrl_initialize_mc_reg_table_v2_2( }if (0 == result) { + table_end = (uint8_t *)vram_info + size; reg_block = (ATOM_INIT_REG_BLOCK *) ((uint8_t *)vram_info +le16_to_cpu (vram_info->usMemClkPatchTblOffset)); result =atomctrl_set_mc_reg_address_table (reg_block, table);
@@ -205,7 +221,7 @@ int atomctrl_initialize_mc_reg_table_v2_2(if (0 == result) { result =atomctrl_retrieve_ac_timing (module_index, - reg_block, table); + reg_block, table_end, table); }return result;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.15] drm/amd/pm: Guard VBIOS AC timing table walk
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] drm/amd/pm: unchecked index table walk in atomctrl_set_mc_reg_address_table() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] drm/amd/pm: unchecked index table walk in atomctrl_set_mc_reg_address_table() --
commit a6c602ed4f05fc0e3395f511194128fee6bac1cc
Author: Xiang Liu <[email protected]>
drm/amd/pm: Guard VBIOS AC timing table walk
This commit rejects AC timing blocks with a stride smaller than a dword and bounds the data-block and END marker reads in atomctrl_retrieve_ac_timing() by the returned VRAM_Info table size.
Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c +0
-0
[ ... ]
Quoted 8 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c +1
-0@@ -157,6 +170,7 @@ int atomctrl_initialize_mc_reg_table( }if (0 == result) { + table_end = (uint8_t *)vram_info + size; reg_block = (ATOM_INIT_REG_BLOCK *) ((uint8_t *)vram_info +le16_to_cpu (vram_info->usMemClkPatchTblOffset)); result =atomctrl_set_mc_reg_address_table (reg_block, table);
drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c int atomctrl_initialize_mc_reg_table( · line 182
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c +1
-1}if (0 == result) { result =atomctrl_retrieve_ac_timing (module_index, - reg_block, table); + reg_block, table_end, table); }
[Severity: Medium]
The commit message notes that the reads are bounded by the returned VRAM_Info table size so malformed index/data sizes do not push the timing walk past the table.
However, in both atomctrl_initialize_mc_reg_table() and atomctrl_initialize_mc_reg_table_v2_2(), table_end is only passed to atomctrl_retrieve_ac_timing(). Prior to that call, reg_block is computed from vram_info->usMemClkPatchTblOffset and passed directly to atomctrl_set_mc_reg_address_table() without checking whether reg_block or its index table fits within table_end:
drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c:atomctrl_set_mc_reg_address_table() {
uint8_t i = 0;
uint8_t num_entries = (uint8_t)((le16_to_cpu(reg_block->usRegIndexTblSize))
/ sizeof(ATOM_INIT_REG_INDEX_FORMAT));
ATOM_INIT_REG_INDEX_FORMAT *format = ®_block->asRegIndexBuf[0];
num_entries--; /* subtract 1 data end mark entry */
PP_ASSERT_WITH_CODE((num_entries <= VBIOS_MC_REGISTER_ARRAY_SIZE),
"Invalid VramInfo table.", return -1);
/* ucPreRegDataLength bit6 = 1 is the end of memory clock AC timing registers */
while ((!(format->ucPreRegDataLength & ACCESS_PLACEHOLDER)) &&
(i < num_entries)) {...
}
In atomctrl_set_mc_reg_address_table(), there are a few issues when handling a malformed VBIOS table:
First, reg_block->usRegIndexTblSize is dereferenced and format->asRegIndexBuf is walked without validating against table_end.
Second, the while loop condition evaluates format->ucPreRegDataLength before checking i < num_entries, which reads one entry past num_entries when ACCESS_PLACEHOLDER is not encountered earlier.
Third, casting le16_to_cpu(reg_block->usRegIndexTblSize) / sizeof(ATOM_INIT_REG_INDEX_FORMAT) to uint8_t truncates the 16-bit entry count before decrementing num_entries and comparing against VBIOS_MC_REGISTER_ARRAY_SIZE.
Should reg_block and atomctrl_set_mc_reg_address_table() also be bounded by table_end, and should i < num_entries be checked before dereferencing format?
Quoted 2 lines
return result;
[ ... ]
Quoted 17 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c +1
-0@@ -198,6 +213,7 @@ int atomctrl_initialize_mc_reg_table_v2_2( }if (0 == result) { + table_end = (uint8_t *)vram_info + size; reg_block = (ATOM_INIT_REG_BLOCK *) ((uint8_t *)vram_info +le16_to_cpu (vram_info->usMemClkPatchTblOffset)); result =atomctrl_set_mc_reg_address_table (reg_block, table);drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c +1
-1}if (0 == result) { result =atomctrl_retrieve_ac_timing (module_index, - reg_block, table); + reg_block, table_end, table); }return result;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 net: pcs: mtk-lynxi: check regmap reads in mtk_pcs_lynxi_get_state()
In reply to Sasha LevinFrom: Daniel Golle <[email protected]>
[ Upstream commit 5cc65c01cdc577621d1320f4aa03a1382c5a4a45 ]
mtk_pcs_lynxi_get_state() ignores regmap_read()'s return value; a failed read leaves bm and adv holding uninitialized stack values which are then decoded into the reported link state. The regmaps backing the MT7531 SGMII PCS instances sit on an MDIO bus where reads can fail. Check both reads and report the link as down on error; phylink presets state->link before the callback, so a bare return would leave a failed read reported as link-up.
---
LLM Generated explanations, may be completely bogus:
This is a real uninitialized-data bug in MediaTek LynxI PCS link polling, and the buggy path exists in this 6.12 tree. It should be backported.
## Phase 1: Commit message forensics
**Step 1.1:** Record: [net: pcs: mtk-lynxi:] [check] [validate regmap_read() in mtk_pcs_lynxi_get_state() so failed MDIO reads are not decoded as link state]
**Step 1.2:** Record: tags in the candidate message:
- Signed-off-by: Daniel Golle <[email protected]> (author; driver co-maintainer)
- Reviewed-by: Andrew Lunn <[email protected]> (netdev/DSA reviewer)
- `Link: https://patch.msgid.link/fce70657fc03bbaf60a04c0fbf2f418531135c
[email protected]`
- Signed-off-by: Jakub Kicinski <[email protected]> (netdev maintainer)
- No Reported-by, Tested-by, Cc: stable in the candidate text (absence is expected)
- Original mailing-list submission **did** include Fixes: 4765a9722e09 ("net: pcs: add driver for MediaTek SGMII PCS"); that tag is not in the candidate body
**Step 1.3:** Record: [Bug: ignored regmap_read() errors leave bm/adv uninitialized and phylink decodes them as BMSR/LPA] [Symptom: false or garbage link/speed/duplex; failed read can be reported as link-up because phylink presets state->link] `[Version:
bug dates to driver introduction]` [Root cause: MDIO-backed MT7531 SGMII PCS regmaps can fail; output is not written on error]
**Step 1.4:** Record: [Not a disguised cleanup. This is an explicit missing-check / uninitialized-use fix. v2 of the patch added state->link = false after review, because a bare return left phylink's preset link-up.]
## Phase 2: Diff analysis
**Step 2.1:** Record: [drivers/net/pcs/pcs-mtk-lynxi.c: +5 / -2 in mtk_pcs_lynxi_get_state()] [single-file surgical fix]
**Step 2.2:** Record: [Before: two unchecked regmap_read()s, then phylink_mii_c22_pcs_decode_state() on bm/adv. After: if either read fails, set state->link = false and return; otherwise decode as before. Error path only.]
**Step 2.3:** Record: [Category: initialization / missing return-value check] [Mechanism: failed regmap_read() does not write *val; unsigned int bm, adv stay uninitialized; phylink_mii_c22_pcs_decode_state() does state->link = !!(bmsr & BMSR_LSTATUS) on that garbage. Fix matches phylink_mii_c22_pcs_get_state(), which already treats read errors as link-down.]
**Step 2.4:** Record: [Obviously correct, 5-line change, no API/locking/refcount changes.] [Regression risk: very low. Worst case is reporting link-down on a failed register read, which is the intended fail-safe.]
## Phase 3: Git history
**Step 3.1:** Record: `[Buggy reads introduced in 4765a9722e0976 ("net:
pcs: add driver for MediaTek SGMII PCS", Daniel Golle, 2023-03-19)]` [First appeared in v6.4-rc1; present for the life of this driver]
**Step 3.2:** Record: [Fixes target 4765a9722e0976 is an ancestor of HEAD. No later lynxi get_state error-handling in this tree.]
**Step 3.3:** Record: [File history on this tree: 4765a9722e097 (add driver), 3b2de56a146f3 (neg_mode), 90308679c297f (pcs_disable), be884c15de370 (MODULE_DESCRIPTION).] [Standalone functionally; series patch 1/6, other patches touch mt7530.c only.] `[Prerequisite already
here: 93d46870c5440 ("net: dsa: mt7530: check bus->read() errors in the MDIO regmap backend") — after that, a failed MDIO read returns an error and leaves the output unwritten instead of truncated garbage.]`
**Step 3.4:** Record: [Daniel Golle is listed as maintainer of MEDIATEK ETHERNET PCS DRIVER. Related MDIO error-propagation work on mt7530 is by the same author.]
**Step 3.5:** Record: [No missing functions. This tree's mtk_pcs_lynxi_get_state() still has the 6.12 signature (no neg_mode); the check itself is independent. Can apply standalone with a small context adaptation.]
## Phase 4: Mailing list
**Step 4.1:** Record: [Lore thread retrieved via b4 mbox: msgid fce7065 7fc03bbaf60a04c0fbf2f418531135c4f.1785811140.git.daniel@makrotopia.org] [v1 of this remaining-errors series was [PATCH net 1/4]; v2 is [PATCH net v2 1/6]. Applied version is v2.] [v2 change: set state->link = false because phylink presets link-up (Sashiko review).] [Andrew Lunn Reviewed-by on v1; author kept it on v2 for the small in-spirit change. No NAKs.] [Patchwork bot: applied by Jakub Kicinski as netdev commit 5cc65c01cdc5.]
**Step 4.2:** Record: [To/Cc included Andrew Lunn, Vladimir Oltean, Russell King, netdev, linux-mediatek, DSA and MediaTek maintainers. Right audience.]
**Step 4.3:** Record: `[No syzbot/bugzilla user report. Found during mt7530 MDIO error-handling review. Still a concrete, reachable bug:pcs.poll = true so this runs from phylink's 1 Hz poll.]`
**Step 4.4:** Record: [Series: "fix remaining swallowed MDIO access errors". Patch 1 is the only pcs-mtk-lynxi change and does not depend on patches 2–6.] [Earlier companion 93d46870c5440 / 96e0f5184af69 are already in this tree.]
**Step 4.5:** Record: [UNVERIFIED: lore.kernel.org/stable search blocked by Anubis. No stable-list discussion found via b4.]
## Phase 5: Semantic analysis
**Step 5.1:** Record: [Modified: mtk_pcs_lynxi_get_state. Wired as .pcs_get_state.]
**Step 5.2:** Record: [Callers: phylink_mac_pcs_get_state() → in-band resolve (MLO_AN_INBAND), ethtool phylink_ethtool_ksettings_get(), and MII emulation. mpcs->pcs.poll = true so phylink_fixed_poll runs phylink_run_resolve() every HZ.]
**Step 5.3:** Record: [Callees: regmap_read`,phylink_mii_c22_pcs_decode_state.]`
**Step 5.4:** Record: [Reachable from userspace: ethtool link settings, and continuously while the netdev is up in in-band SGMII/1000Base-X/2500Base-X.] [Hardware: MT7531 DSA ports 5/6 (mt7531_create_sgmii() uses an MDIO-backed regmap) and MediaTek SoC SGMII (mtk_eth_soc syscon/MMIO, rarely fails). The MDIO path is the one that matters.]
**Step 5.5:** Record: [Same pattern already handled in phylink_mii_c22_pcs_get_state() and phylink_mii_c45_pcs_get_state() in this tree. Lynx PCS uses those helpers; lynxi did not.]
## Phase 6: Local tree (6.12.111, pending-6.12)
**Step 6.1:** Record: [Yes. drivers/net/pcs/pcs-mtk-lynxi.c:98-99 still has unchecked regmap_read() into uninitialized bm/adv. Introduced v6.4, present here.] [Verified: git describe HEAD → p-6.12-4-gbf6fcdf761abd; make kernelversion → 6.12.111.]
**Step 6.2:** Record: [Minor context rework, not a semantic fork. This tree has no mtk_pcs_lynxi_inband_caps, no neg_mode argument, and phylink_mii_c22_pcs_decode_state(state, bmsr, lpa) not the later 4-arg form. The 5-line check ports 1:1 into the existing function body.]
**Step 6.3:** Record: [No lynxi get_state error-check already present. Prerequisite MDIO backend error propagation is already here, which is why this follow-up is needed: failed reads no longer write *val.]
## Phase 7: Subsystem context
**Step 7.1:** Record: [drivers/net/pcs + consumers in net/dsa/mt7530 and net/ethernet/mediatek] [IMPORTANT: common OpenWrt/router SGMII CPU ports, not core mm/VFS, but production networking]
**Step 7.2:** Record: [Driver is mature since v6.4; this file has only a handful of commits on this tree. Bug is long-standing, newly exposed as true uninitialized use after the MDIO backend fix.]
## Phase 8: Impact and risk
**Step 8.1:** Record: [Driver-specific: MT7531 SGMII (MDIO) and MediaTek SoC SGMII (MMIO).]
**Step 8.2:** Record: [Trigger: failed regmap_read on the PCS map. Common on flaky/timeout MDIO; not every boot. Unprivileged userspace can observe the result via ethtool/carrier; the poll path runs while the interface is up.]
**Step 8.3:** Record: [Failure mode: uninitialized stack decoded as link/speed/duplex; false carrier possible because phylink presets state->link = 1.] [Severity: HIGH for wrong datapath/carrier on MDIO error; not a panic. Uninitialized use is the same class as KMSAN-class bugs.]
**Step 8.4:** Record: [Benefit: high for MT7531 in-band SGMII — stops garbage link state after a bus error, especially now that the backend returns real errors.] [Risk: very low — 5 lines, fail-closed to link- down.] [Ratio: strongly favors backport.]
## Phase 9: Synthesis
**For backporting:**
- Real bug: uninitialized bm/adv decoded into phylink link state
- User-visible: false/garbage carrier, speed, duplex; ethtool reports it
- Tiny, obviously correct, matches phylink's own C22 helper
- Reviewed by Andrew Lunn, applied by Jakub Kicinski, written by the PCS maintainer
- Buggy code has been in this driver since v6.4 and is in 6.12.111
- Companion to MDIO error-propagation already in this tree (93d46870c5440); without this, a failed MT7531 PCS read now leaves stack garbage instead of even truncated-but-defined data
- No new API/feature
**Against:**
- Not a crash/UAF/deadlock
- Raw upstream hunk will not apply cleanly (later neg_mode / inband_caps context)
- No external user/syzbot report
- Series 1/6, but this patch does not need 2–6
**Unresolved:** stable-list discussion (lore/stable fetch blocked)
**Stable rules:**
1. Obviously correct and tested? **PASS** — same pattern as phylink_mii_c22_pcs_get_state(); Reviewed-by Andrew Lunn; merged
2. Fixes a real bug that affects users? **PASS** — wrong link state / uninitialized data on MDIO failure for MT7531 SGMII
3. Important issue? **PASS** — uninitialized memory used as live link state on a 1 Hz poll; can keep carrier up after a failed read
4. Small and contained? **PASS** — 5 lines, one function
5. No new features or APIs? **PASS**
6. Can apply to this tree? **PASS** — needs a trivial context backport, not missing code
**Exception category:** none (normal small correctness fix)
The problem for 6.12 users is that mtk_pcs_lynxi_get_state() still consumes uninitialized stack as BMSR/LPA. Phylink presets state->link = 1 (phylink.c:1328) and this PCS polls every second. After the already-landed MT7530 MDIO backend fix, a failed read returns an error and does not fill *val, so this is the necessary follow-up. Benefit is preventing false/garbage link state; risk is a fail-closed link-down on I/O error.
Verification:
- [Phase 1] Parsed candidate tags; original lore patch had `Fixes:
4765a9722e09`
- [Phase 2] Diff is 5 lines in mtk_pcs_lynxi_get_state() wrapping two regmap_read()s
- [Phase 2] Confirmed phylink_mac_pcs_get_state() sets state->link = 1 before the callback
- [Phase 2] Confirmed phylink_mii_c22_pcs_decode_state() uses bmsr for state->link and that phylink_mii_c22_pcs_get_state() already sets state->link = false on read failure
- [Phase 3] git blame on lines 98–99: 4765a9722e0976; git describe --contains → v6.4-rc1
- [Phase 3] git merge-base --is-ancestor 4765a9722e0976 HEAD succeeded
- [Phase 3] git merge-base --is-ancestor 93d46870c5440 HEAD succeeded (MDIO backend now returns errors without writing *val)
- [Phase 4] b4 mbox on the msgid: 8-message thread; series v2 1/6; Andrew Lunn Reviewed-by; no NAK
- [Phase 4] Cover letter: this check was added because a failed read can now leave output unwritten
- [Phase 4] UNVERIFIED: lore.kernel.org/stable search (Anubis 403)
- [Phase 5] Callers: phylink in-band resolve, ethtool get, 1 Hz link_poll; consumers mt7530-mdio.c and mtk_eth_soc.c
- [Phase 6] git describe HEAD / make kernelversion: 6.12.111 on pending-6.12; unchecked reads still at pcs-mtk-lynxi.c:98-99
- [Phase 6] Function signature here lacks neg_mode; backport is a local 5-line edit
- [Phase 8] Failure mode: uninitialized link state / possible false carrier, severity HIGH, not a panic
- UNVERIFIED: whether this SHA is already in some other stable series (decision is for this tree only)
**YES**
drivers/net/pcs/pcs-mtk-lynxi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/pcs/pcs-mtk-lynxi.c +5 -2
@@ -110,8 +110,11 @@ static void mtk_pcs_lynxi_get_state(struct phylink_pcs *pcs,unsigned int bm, adv;/* Read the BMSR and LPA */ -regmap_read (mpcs->regmap,SGMSYS_PCS_CONTROL_1 , &bm); -regmap_read (mpcs->regmap,SGMSYS_PCS_ADVERTISE , &adv); +if (regmap_read (mpcs->regmap,SGMSYS_PCS_CONTROL_1 , &bm) || +regmap_read (mpcs->regmap,SGMSYS_PCS_ADVERTISE , &adv)) { + state->link = false; +return ; + } phylink_mii_c22_pcs_decode_state(state, neg_mode, FIELD_GET(SGMII_BMSR, bm),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: iwlwifi: mld: Do not cleanup FW state when the device is dead
In reply to Sasha LevinFrom: Ilan Peer <[email protected]>
[ Upstream commit 1c031ac5a39ebcc3269eace8b606043adc398bfa ]
When a channel context is unassigned, there is a path to cleanup the FW state in case of NON MLO connection: remove the link and add it again. However, when the transport is dead, e.g., during device removal etc., this flow will fail and as a result the mld_vif->link[0] would be set to NULL. Later, when the interface is removed, iwl_mld_remove_link() would warn as the link is NULL.
Fix this by not doing the cleanup when the device is dead.
---
LLM Generated explanations, may be completely bogus:
Local tree is **Linux 7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The candidate is 1c031ac5a39eb and landed in v7.3-rc1. The iwlwifi MLD path it fixes is present here (MLD since v6.15-rc1).
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [wifi: iwlwifi: mld:] [Do not / Fix] [skip non-MLO FW link remove/re-add when the transport is dead]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Signed-off-by: Ilan Peer <[email protected]> (author)
- Signed-off-by: Miri Korenblit <[email protected]> (iwlwifi MLD maintainer)
- `Link: https://patch.msgid.link/20260715220243.89a0c44a72a3.I45cca8b84
a25943d5771199af6b0155dbac77b58@changeid`
- No Fixes:, no Reported-by:, no Tested-by:, no Reviewed-by:, no Acked-by:, no Cc: stable (absence expected)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** On non-MLO chanctx unassign, the driver remove/re-adds the link to reset FW state. If the transport is dead (device removal, etc.), that sequence fails and mld_vif->link[0] is left NULL.
- **Symptom:** Later iwl_mld_remove_link() during interface teardown hits WARN_ON(!link).
- **Root cause:** FW cleanup is attempted after the device can no longer accept commands; the software link pointer is cleared on the failed re-add.
- **Version info:** none in the message. MLD itself dates to v6.15.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Explicitly a teardown bug: failed FW cleanup → NULL link → WARN_ON.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/net/wireless/intel/iwlwifi/mld/mac80211.c (+4 / −2)
- Function: iwl_mld_unassign_vif_chanctx()
- Scope: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** For non-MLO, non-AP, not associated, not in HW restart:
always iwl_mld_remove_link() then iwl_mld_add_link().
- **After:** Same, but also skip when iwl_trans_is_dead(mld->trans).
- Path affected: chanctx unassign during device death / removal, not the normal associated-STA path (WARN_ON_ONCE(vif->cfg.assoc) already excludes that).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Logic / correctness** on a teardown path (NULL pointer → WARN_ON).
Verified in iwl_mld_remove_link() / iwl_mld_add_link() in mld/link.c:
1. iwl_mld_remove_link() always does RCU_INIT_POINTER(mld_vif->link[link_id], NULL) after the FW remove attempt.
2. iwl_mld_add_link() then talks to FW via iwl_mld_add_link_to_fw(). On failure it NULLs mld_vif->link[] again.
3. iwl_mld_mac80211_remove_interface() later calls iwl_mld_remove_link(mld, &vif->bss_conf).
4. That function does if (WARN_ON(!link || link->active)) return;.
iwl_trans_send_cmd() also WARN_ONCEs if trans->state != IWL_TRANS_FW_ALIVE, so the skip can avoid extra warnings while sending LINK_CONFIG_CMD on a dead device.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: same pattern as the existing !mld->fw_status.in_hw_restart skip.
- Minimal: one extra predicate using iwl_trans_is_dead() (present since v6.17).
- Regression risk is low: if the transport is dead, FW cleanup cannot succeed anyway.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Remove/re-add block introduced in d1e879ec600f9 (“wifi: iwlwifi: add iwlmld sub-driver”, 2025-03-05) → first in **v6.15-rc1**.
- Dead-device check added by this candidate (1c031ac5a39eb, 2026-07-16) → first in **v7.3-rc1**.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Buggy code is the original MLD unassign path, not a later regression.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Nearby commits in the same iwlwifi-next pull are unrelated (FTM abort, WoWLAN validation, mei overflow, etc.). No follow-up on this exact condition after 1c031ac5a39eb.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Ilan Peer is a regular Intel iwlwifi/MLD contributor. The patch was committed by Miri Korenblit (MLD maintainer).
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Record:
- Needs iwl_trans_is_dead() from 11c5cc9ec6d9e (v6.17-rc1). **Present in this 7.3-rc4 tree.**
- Series membership (14/15) is packaging only; this hunk does not depend on the other 14 patches.
- Standalone: yes.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 1c031ac5a39eb: https://patch.msgid.link/20260715220243.89a
0c44a72a3.I45cca8b84a25943d5771199af6b0155dbac77b58@changeid
- Cover: [PATCH iwlwifi-next 00/15] wifi: iwlwifi: updates - 07-15-2026 — “Cleanups, features, and fixes from our internal tree.”
- b4 dig -a: single v1 series; committed version matches v1. No later revision.
- Mbox has 16 messages (cover + 15 patches). **No replies, NAKs, or review comments** on this patch.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc were Miri Korenblit, Johannes Berg ([email protected]), [email protected], Ilan Peer. Maintainer-acked via Miri’s SOB; no public Reviewed-by.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by / bugzilla / syzbot. Looks like an internal Intel find. Trigger is still concrete (dead transport during unassign).
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Mixed 15-patch iwlwifi-next dump. This patch is self-contained (only the unassign condition). Other series items are unrelated mei/mvm/FTM/debug fixes.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org /stable/ search blocked by Anubis (403). **UNVERIFIED:** no confirmed prior stable-list discussion. b4/mbox showed no Cc: stable and no reviewer nomination.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: iwl_mld_unassign_vif_chanctx (modified). Callees of the skipped block: iwl_mld_remove_link, iwl_mld_add_link. Later WARN
site: iwl_mld_remove_link from iwl_mld_mac80211_remove_interface.
**Step 5.2: TRACE CALLERS**
Record:
- mac80211 op .unassign_vif_chanctx (mac80211 core on vif/chanctx unbind — ifdown, disconnect, unbind, restart).
- iwl_mld_switch_vif_chanctx_swap / iwl_mld_switch_vif_chanctx_reassign (CSA/channel switch).
**Step 5.3: TRACE CALLEES**
Record: deactivate link, optional monitor sta removal, TLC phy update, then optional remove/re-add. Remove/re-add issue LINK_CONFIG_CMD via iwl_mld_send_cmd → iwl_trans_send_cmd.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace-reachable: bring down wlan0, rmmod iwlwifi, PCI unbind/reset. STATUS_TRANS_DEAD is set in iwl_trans_pcie_reset() during PCI removal. Config: CONFIG_IWLMLD (BE200+ / Wi-Fi 7).
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same function already skips this cleanup on in_hw_restart. iwl_trans_is_dead() is already used in mld/mld.c (iwl_mld_nic_error). This is the same “don’t talk to a dead transport” pattern.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** drivers/net/wireless/intel/iwlwifi/mld/mac80211.c iwl_mld_unassign_vif_chanctx() contains the remove/re-add path. Bug present since v6.15; this checkout is 7.3-rc4.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply. Surrounding condition matches the parent of 1c031ac5a39eb. Helper iwl_trans_is_dead() exists in iwl-trans.h.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This is the only “cleanup FW state when the device is dead” change on this path. git merge-base --is-ancestor 1c031ac5a39eb HEAD is true because this is post-7.3-rc1 mainline; that is source presence, not a reason to reject on merit.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/net/wireless/intel/iwlwifi/mld/ — Intel Wi-Fi 7 (BE200+) opmode. **IMPORTANT** (not core mm/net, but a widely shipped wireless driver).
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively developed (frequent MLD commits through 2026). The buggy unassign cleanup has been there since the MLD introduction.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Users of Intel MLD devices (CONFIG_IWLMLD) with a non-MLO interface, when the transport dies or the device is removed while a chanctx is still assigned.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Device removal / PCI reset / unbind / rmmod with an active non-MLO vif. Not every packet path; teardown is still a common admin/user action. Unprivileged users typically cannot unbind PCI, but can trigger iface down; the commit’s example is device removal.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: WARN_ON(!link) in iwl_mld_remove_link() (stack dump, TAINT_WARN; panic if panic_on_warn). Possible extra WARN_ONCE from iwl_trans_send_cmd() for non-ALIVE state. Not a UAF or data-corruption bug. **Severity: MEDIUM–HIGH** (WARN_ON on a real teardown path).
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** Stops a reproducible WARN_ON (and likely extra host- command WARNs) on Intel MLD device teardown.
- **Risk:** Very low — one boolean on an already-gated cleanup.
- **Ratio:** Favorable.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real teardown bug with a traced mechanism (failed remove/re-add → NULL link[0] → WARN_ON).
- WARN_ON is an explicit strong-yes class of fix.
- Four-line, obviously correct, same idea as the existing restart skip.
- MLD + iwl_trans_is_dead() exist in this 7.3-rc4 tree; patch applies cleanly.
- Intel Wi-Fi 7 hardware is in production laptops.
**AGAINST:**
- No public reporter/syzbot/Fixes: tag.
- Failure is WARN_ON, not oops/UAF/corruption by default.
- Sent in a mixed iwlwifi-next dump, not a dedicated -fixes mail.
- No mailing-list review comments (only maintainer SOB).
**UNRESOLVED:**
- Stable-list history (lore blocked).
- No independent user report found.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — one predicate; in mainline since 7.3-rc1; maintainer SOB.
2. Fixes a real bug that affects users? **PASS** — WARN_ON on device/interface teardown for MLD hardware.
3. Important issue? **PASS** — WARN_ON on a reachable removal path (“oh, that’s not good” / WARN_ON class).
4. Small and contained? **PASS** — ~4 lines, one function.
5. No new features or APIs? **PASS** — uses existing iwl_trans_is_dead().
6. Can apply to the local tree? **PASS** — code and helper are here; context matches.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not a device-ID/quirk/DT/build/doc exception). It is a normal small driver bugfix.
**Step 9.4: MAKE YOUR DECISION**
This tree has the MLD unassign path. Skipping FW link recycle when the transport is already dead prevents a real WARN_ON during removal, with negligible regression risk.
---
## What the commit solves and why it matters here
On non-MLO Intel MLD interfaces, chanctx unassign recycles the FW link (remove + add). If the transport is dead, add fails and mld_vif->link[0] stays NULL. Interface removal then hits WARN_ON(!link) in iwl_mld_remove_link(). Users see a kernel warning (and a panic if panic_on_warn is set) when unbinding or resetting the Wi-Fi device. This 7.3-rc4 tree includes that MLD code, so the fix belongs here.
## Stable rules / risk vs benefit
The change is a one-condition skip, already used for HW restart, with no API or behavior change for live devices. Benefit is avoiding teardown WARNs on Intel Wi-Fi 7; risk is very low.
## Concerns
No Fixes:/Reported-by, and it rode in a mixed next-tree series. Neither undercuts the code-level bug. Prerequisite iwl_trans_is_dead() is already in this tree. No backport rework needed.
---
## Verification
- **[Phase 1]** Parsed tags: author Ilan Peer, SOB Miri Korenblit, msgid.link; no Fixes/Reported-by/Cc-stable.
- **[Phase 2]** Diff: +4/−2 in iwl_mld_unassign_vif_chanctx; adds !iwl_trans_is_dead(mld->trans).
- **[Phase 2]** iwl_mld_remove_link always NULLs mld_vif->link[]; iwl_mld_add_link NULLs it again if iwl_mld_add_link_to_fw fails; iwl_mld_remove_link WARNs on NULL.
- **[Phase 2]** iwl_trans_send_cmd WARNs if trans->state != IWL_TRANS_FW_ALIVE.
- **[Phase 3]** git blame: remove/re-add from d1e879ec600f9 (v6.15-rc1); fix is 1c031ac5a39eb (v7.3-rc1).
- **[Phase 3]** git describe --contains --match 'v*': MLD v6.15-rc1~...; helper 11c5cc9ec6d9e in v6.17-rc1; this commit v7.3-rc1~....
- **[Phase 3]** git merge-base --is-ancestor 1c031ac5a39eb HEAD → ancestor (expected on 7.3-rc4).
- **[Phase 4]** b4 dig -c: lore/msgid thread; -a: v1 only; -w:
Johannes Berg + linux-wireless; -m: 16 msgs, no replies/NAKs.
- **[Phase 4]** Cover letter: mixed “updates” series 14/15; this patch listed under Ilan Peer.
- **[Phase 4]** lore /stable/ search: UNVERIFIED (Anubis 403). WebFetch lore: 403.
- **[Phase 5]** Callers: mac80211 .unassign_vif_chanctx, plus two switch_vif_chanctx_* helpers. Teardown via iwl_mld_mac80211_remove_interface.
- **[Phase 5]** STATUS_TRANS_DEAD set in iwl_trans_pcie_reset() (pcie/gen1_2/trans.c).
- **[Phase 6]** git describe HEAD / make kernelversion: **v7.3-rc4 / 7.3.0-rc4**. Buggy MLD file present. iwl_trans_is_dead() present at iwl-trans.h:1127.
- **[Phase 8]** Failure mode: WARN_ON(!link) on iface removal after dead-transport unassign; severity MEDIUM–HIGH.
- **UNVERIFIED:** Prior discussion on the stable mailing list.
The fix is small, surgical, and meets the stable criteria for this tree.
**YES**
drivers/net/wireless/intel/iwlwifi/mld/mac80211.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/mld/mac80211.c +4 -2
@@ -1113,11 +1113,13 @@ void iwl_mld_unassign_vif_chanctx(struct ieee80211_hw *hw,RCU_INIT_POINTER (mld_link->chan_ctx,NULL );/* in the non-MLO case, remove/re-add the link to clean up FW state. -* In MLO, it'll be done in drv_change_vif_link +* In MLO, it'll be done in drv_change_vif_link. +* Do not do so during restart or in case the device is dead. */ if (!ieee80211_vif_is_mld (vif) && !mld_vif->ap_sta && !WARN_ON_ONCE (vif->cfg.assoc) && - vif->type !=NL80211_IFTYPE_AP && !mld->fw_status.in_hw_restart) { + vif->type !=NL80211_IFTYPE_AP && !mld->fw_status.in_hw_restart && + !iwl_trans_is_dead (mld->trans)) {iwl_mld_remove_link (mld, link);iwl_mld_add_link (mld, link); }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 spi: fsl-dspi: clean up after failed suspend and resume
In reply to Sasha LevinFrom: Jiawen Liu <[email protected]>
[ Upstream commit 2543355f3da56a297e3803ccb5d29f4dce5f18f1 ]
dspi_suspend() disabled the IRQ before spi_controller_suspend(), but ignored a suspend failure and kept tearing the device down. Restore the IRQ and return the error if suspend fails.
dspi_resume() also left the clock prepared if controller resume or hardware init failed. Route those failures through clock cleanup.
---
LLM Generated explanations, may be completely bogus:
I compared the pre-image to v6.18.53: the buggy suspend/resume path is there unchanged, so this is a standalone fix for this tree.
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
- Record: [spi: fsl-dspi:] [clean up] [restore IRQ / clocks after failed suspend and resume]
- Subsystem is Freescale DSPI. The verb is “clean up”, but the body describes ignored errors and missing rollback.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Record:
- Signed-off-by: Jiawen Liu <[email protected]> (author)
- `Link: https://patch.msgid.link/tencent_427FA55E3D59112524886E9C931C
[email protected]` - `Signed-off-by: Mark Brown <[email protected]>` (SPI maintainer) - No `Fixes:`, `Reported-by:`, `Tested-by:`, `Reviewed-by:`, `Acked- by:`, or `Cc: stable` (absence of those last two is expected for this review) - Pipeline-added `Signed-off-by: Sasha Levin` / `[ Upstream commit 2543355f3da5... ]` ignored per instructions
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Record: **Bug:** dspi_suspend() calls disable_irq() then spi_controller_suspend() but ignores a non-zero return and still disables the clock and selects the sleep pin state. **Symptom:** on a failed controller suspend the IRQ stays off, clocks are gated, pins go to sleep, and suspend is reported as success. **Resume bug:** clk_prepare_enable() is not undone if spi_controller_resume() or dspi_init() fails. **Root cause:** missing error checks and missing rollback. No version range in the message.
**Step 1.4: DETECT HIDDEN BUG FIXES**
- Record: Yes. “Clean up” is error-path recovery: re-enable IRQ and return the error on suspend failure; clk_disable_unprepare() on resume failure. That is a leak/imbalance fix, not style.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
- Record: drivers/spi/spi-fsl-dspi.c only; **+18 / −3**. Functions:
dspi_suspend(), dspi_resume(). Single-file surgical PM error-path fix.
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
- Record:
- **suspend before:** disable IRQ → ignore spi_controller_suspend() → always clk_disable_unprepare() → sleep pinctrl → return 0.
- **suspend after:** disable IRQ → if spi_controller_suspend() fails, enable_irq() and return ret (clocks/pinctrl untouched).
- **resume before:** enable clock → ignore spi_controller_resume() → on dspi_init() failure return with clock still prepared.
- **resume after:** those failures go to disable_clk (clk_disable_unprepare() + return ret). IRQ is still enabled only on the success path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
- Record: **Error-path / resource-leak / IRQ imbalance.** spi_controller_suspend() can return -EBUSY from spi_stop_queue() after a 5s wait (drivers/spi/spi.c). Continuing then gates the clock under a live controller and leaves the IRQ disabled. Resume can leak a prepared clock.
**Step 2.4: ASSESS THE FIX QUALITY**
- Record: Minimal and obviously correct; matches other SPI drivers that already check these returns. Regression risk is low: only error paths change. Idle suspend still returns 0 after stop-queue succeeds. Pre- existing IRQ-before-stop-queue ordering is not introduced here (Sashiko noted it as pre-existing). Resume still does not undo spi_controller_resume() on later dspi_init() failure; dspi_init() only fails on invalid trans_mode after a successful probe, so that path is essentially dead.
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
- Record: On v6.18.53, suspend/resume blame is c5412ec5f68773 (“Reinitialize DSPI regs after resuming for S32G”, 2025-05-22), which kept the ignore-error pattern. That pattern already existed before S32G (git show c5412ec5f68773^). Original driver 349ad66c0ab0b (Vybrid VF610) already ignored spi_master_suspend() and always disabled the clock. Bug is old, not post-6.18.
**Step 3.2: FOLLOW THE FIXES: TAG**
- Record: No Fixes: tag. Not applicable beyond that.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
- Record: Related: 3d87b613d6a3c (“Fix external abort on interrupt in resume or exit paths”) added disable_irq() in suspend because a shared IRQ after clocks-off caused an external abort on Vybrid. That makes restoring the IRQ on suspend failure required. 9bd77a9ce31dd only fixed a NULL drvdata in PM. This patch is standalone; later autosel b6d8099e44987 only switches PM macros.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
- Record: Jiawen Liu is not the SPI maintainer. Same series on this
tree: spi: atcspi200, spi: bcmbca-hsspi, spi: bcm-qspi, `spi:
bcm63xx-hsspi, spi: bcm63xx, plus spi: nxp-fspi` probe RPM. Each driver is independent. Mark Brown applied the series.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
- Record: No new helpers. Uses spi_controller_suspend/resume, enable_irq/disable_irq, clk_disable_unprepare already in 6.18. Standalone. Series 3/4 does not need 1/4 or 2/4 for this file.
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
- Record: b4 dig -c 2543355f3da5 → https://patch.msgid.link/tencent_42
[email protected]
- Series: v1 only, [PATCH 3/4]. Mark Brown applied all four to broonie/spi.git for-7.3. No NAK on this patch. Sashiko flagged two **pre-existing** ordering issues (IRQ before stop-queue; resume queue before dspi_init()), not regressions from this diff. No reviewer Cc: stable. Direct lore fetch returned 403; thread recovered via b4 dig -m.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
- Record: b4 dig -w: To Mark Brown; Cc linux-spi, linux-kernel, linux- arm-kernel, imx@, NXP (olteanv, han.xu, haibo.chen). No human Reviewed-by on this patch. Maintainer applied it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
- Record: No Reported-by / bugzilla / syzbot. Bug is from code inspection of ignored returns.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
- Record: 1/4 atcspi200, 2/4 bcmbca-hsspi, 3/4 this, 4/4 nxp-fspi (different bug: probe RPM). This hunk does not depend on the others. Frank Li replied only to 4/4.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
- Record: lore.kernel.org/stable search via WebFetch returned 403. UNVERIFIED whether stable@ discussed this SHA. No in-tree evidence it was rejected.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
- Record: dspi_suspend(), dspi_resume(). Callees of interest:
spi_controller_suspend(), spi_controller_resume(), dspi_init().
**Step 5.2: TRACE CALLERS**
- Record: Only SIMPLE_DEV_PM_OPS(dspi_pm, dspi_suspend, dspi_resume) on v6.18.53 → system-sleep PM for this platform device. Not a syscall hot path; triggered by suspend/resume on i.MX / Vybrid / LS1021A / S32 / ColdFire DSPI.
**Step 5.3: TRACE CALLEES**
- Record: spi_controller_suspend() → spi_stop_queue() (up to 500 × ~10ms, then -EBUSY) then __spi_mark_suspended(). dspi_transfer_one_message() waits on dspi->xfer_done when dspi->irq is set; completion is from dspi_interrupt(). DMA mode waits on DMA completions, not that IRQ.
**Step 5.4: FOLLOW THE CALL CHAIN**
- Record: Userspace/system suspend → driver PM → dspi_suspend(). Reachable whenever this hardware is present and CONFIG_PM_SLEEP. In- flight IRQ-mode transfer at suspend can make spi_stop_queue() fail; that is the interesting path.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
- Record: Many SPI drivers already check spi_controller_suspend() (omap2-mcspi, atmel, qup, rockchip, stm32, …). Same author fixed the ignored-return pattern in several Broadcom SPI drivers. Systematic, not one-off.
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
- Record: Local tree is **6.18.53** (git describe HEAD → v6.18.53-5049-g0f0bdc2b0dffb, VERSION=6 PATCHLEVEL=18 SUBLEVEL=53). At **v6.18.53**, dspi_suspend() still ignores the suspend return and dspi_resume() still returns from dspi_init() failure without clk_disable_unprepare(). Candidate 1248ec26ed99f is **not** an ancestor of v6.18.53. Bug present.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
- Record: Pre-image on v6.18.53 matches the patch (including #ifdef CONFIG_PM_SLEEP / SIMPLE_DEV_PM_OPS). Expected apply: **clean**. git apply --check on current autosel HEAD fails only because the candidate is already sitting on this working branch.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
- Record: 3d87b613d6a3c (IRQ disable in suspend) **is** in v6.18.53. No other fix for ignored spi_controller_suspend() on this file.
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
- Record: drivers/spi/spi-fsl-dspi.c. **IMPORTANT** (common NXP/Freescale SPI; not core mm/vfs). SPI_FSL_DSPI depends on ARCH_MXC || ARCH_NXP || M5441x || COMPILE_TEST. Kconfig: S32, VF610, LS1021A, ColdFire.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
- Record: File still gets platform and DMA work (S32G series in 2025). PM error handling itself is old and stale.
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
- Record: Driver-specific: boards with Freescale DSPI that suspend. Embedded/i.MX/Layerscape/S32 population, not all Linux systems.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
- Record: System suspend while spi_stop_queue() cannot drain (busy/queued messages for ~5s). IRQ-mode in-flight transfer is a realistic trigger because disable_irq() runs first and dspi_transfer_one_message() uses wait_for_completion(&dspi->xfer_done). Unprivileged users do not call this directly; a suspend with SPI activity can. Resume clock
leak: spi_controller_resume() -EBUSY or dspi_init() -EINVAL (latter essentially unreachable after probe).
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
- Record: Failed suspend that still gates clocks: possible MMIO abort / hang (this driver already hit “external abort on non-linefetch” when the IRQ ran after clocks off — 3d87b613d6a3c). IRQ left disabled while the device is still active: SPI completions never fire → hung transfers. Resume clock leak: extra power / unbalanced clk prepare. **Severity: HIGH** on the suspend path (hang / abort), **MEDIUM** on the resume leak.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
- Record: **Benefit:** high for DSPI suspend users — fail suspend instead of disabling clocks/IRQ incorrectly. **Risk:** low — 21 lines, error paths only, no API/struct change. If stop-queue fails, aborting suspend is the intended PM policy.
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real ignored-error bug: teardown after failed spi_controller_suspend().
- IRQ not restored → hung SPI (completion in dspi_interrupt()).
- Clock gated while the controller may still be busy → abort/hang; same class as the already-stable 3d87b613d6a3c abort fix.
- Resume path clock leak on error.
- Small, local, obviously correct; SPI maintainer applied it.
- Buggy code is in v6.18.53; no extra prerequisites.
- Same class of SPI PM error-path fixes already common in-tree.
AGAINST:
- No user/syzbot report.
- Worded as “clean up”; failure is an error path, not every suspend.
- dspi_init() resume failure is almost unreachable.
- Sashiko pre-existing ordering notes (not introduced here).
- Incomplete undo of spi_controller_resume() if dspi_init() failed (dead in practice).
UNRESOLVED:
- lore.kernel.org HTTP 403; stable@ discussion not independently fetched (thread was recovered with b4).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — mechanical error-return handling; applied by Mark Brown.
2. Fixes a real bug that affects users? **PASS** — IRQ/clock teardown on failed suspend; clk leak on resume.
3. Important issue? **PASS** — hang / possible bus abort, not a style nit.
4. Small and contained? **PASS** — +18/−3, one file.
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/doc exception. Qualifies as a normal bugfix.
**Step 9.4: DECISION**
This should be backported to **this 6.18.53 tree**. The important part is suspend: do not disable clocks and leave the IRQ off when spi_controller_suspend() fails. That is a real stability bug on a production NXP SPI controller, small enough for stable, and it applies cleanly here.
### What the commit solves for stable users
On Freescale DSPI, suspend currently disables the IRQ, then ignores spi_controller_suspend(). If the message queue does not stop (-EBUSY), the driver still turns off the clock and puts pins to sleep while reporting success. The IRQ stays disabled. That can hang in-flight transfers (wait_for_completion never completes) or MMIO-abort if the hardware is still live. Resume can also leave clk_prepare_enable() unbalanced. The patch stops teardown on suspend failure and unwinds the clock on resume failure.
### Risk vs benefit
Benefit is preventing a broken/hung SPI device and possible abort after a failed controller suspend. Risk is confined to those error returns; successful idle suspend is unchanged.
### Concerns
No extra commits are required. Do not confuse autosel already having this SHA with “already selected for 6.18.y”; v6.18.53 still has the bug.
Verification:
- [Phase 1] Subject/body/tags from git log -1 / git show 1248ec26ed99f: no Fixes/Reported-by; Link msgid; SOB Jiawen Liu + Mark Brown
- [Phase 2] Diff: +18/−3 in dspi_suspend/dspi_resume only
- [Phase 3] git blame on v6.18.53: c5412ec5f68773; ignore-error PM since 349ad66c0ab0b; 3d87b613d6a3c in this tree
- [Phase 3] git merge-base --is-ancestor 1248ec26ed99f v6.18.53 → no; ancestor of HEAD (autosel) → yes
- [Phase 3] Author series: several independent SPI PM error-path patches
- [Phase 4] b4 dig -c 2543355f3da5: patch 3/4 v1, lore msgid, applied to broonie for-7.3; Sashiko pre-existing notes only; no NAK
- [Phase 4] WebFetch lore/stable: 403 — UNVERIFIED stable@ thread
- [Phase 5] spi_controller_suspend → spi_stop_queue -EBUSY; DSPI IRQ path wait_for_completion / dspi_interrupt; PM ops only callers
- [Phase 6] git describe HEAD / Makefile: 6.18.53; v6.18.53 file matches patch pre-image
- [Phase 7] SPI_FSL_DSPI on ARCH_MXC/NXP
- [Phase 8] Failure: hung SPI / possible external abort; severity HIGH on suspend error path
**YES**
drivers/spi/spi-fsl-dspi.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/spi/spi-fsl-dspi.c +18 -3
@@ -1464,10 +1464,18 @@ static int dspi_init(struct fsl_dspi *dspi)static int dspi_suspend (struct device *dev) {struct fsl_dspi *dspi =dev_get_drvdata (dev); +int ret;if (dspi->irq)disable_irq (dspi->irq); -spi_controller_suspend (dspi->ctlr); + + ret =spi_controller_suspend (dspi->ctlr); +if (ret) { +if (dspi->irq) +enable_irq (dspi->irq); +return ret; + } +clk_disable_unprepare (dspi->clk);pinctrl_pm_select_sleep_state (dev);
@@ -1485,12 +1493,15 @@ static int dspi_resume(struct device *dev) ret =clk_prepare_enable (dspi->clk);if (ret)return ret; -spi_controller_resume (dspi->ctlr); + + ret =spi_controller_resume (dspi->ctlr); +if (ret) + goto disable_clk; ret =dspi_init (dspi);if (ret) {dev_err (dev,"failed to initialize dspi during resume\n" ); -return ret; + goto disable_clk; }dspi_set_mtf (dspi);
@@ -1499,6 +1510,10 @@ static int dspi_resume(struct device *dev)enable_irq (dspi->irq);return 0 ; + +disable_clk: +clk_disable_unprepare (dspi->clk); + return ret; }#endif /* CONFIG_PM_SLEEP */
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18] spi: fsl-dspi: clean up after failed suspend and resume
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] spi: fsl-dspi: premature disable_irq() and unroll gap in dspi_suspend() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] spi: fsl-dspi: premature disable_irq() and unroll gap in dspi_suspend() --
commit 7e693362fffc058a6e36cb3136ecf18f7eb1c968
Author: Jiawen Liu <[email protected]>
spi: fsl-dspi: clean up after failed suspend and resume
This commit checks the return values of spi_controller_suspend() in dspi_suspend() and spi_controller_resume() in dspi_resume(), restoring the IRQ or disabling the clock if an error occurs.
Quoted 10 lines
drivers/spi/spi-fsl-dspi.c +1
-0@@ -1464,10 +1464,18 @@ static int dspi_init(struct fsl_dspi *dspi)static int dspi_suspend (struct device *dev) {struct fsl_dspi *dspi =dev_get_drvdata (dev); +int ret;
drivers/spi/spi-fsl-dspi.c static int dspi_init(struct fsl_dspi *dspi) · line 1477
Quoted 10 lines
drivers/spi/spi-fsl-dspi.c +7
-1if (dspi->irq)disable_irq (dspi->irq); -spi_controller_suspend (dspi->ctlr); + + ret =spi_controller_suspend (dspi->ctlr); +if (ret) { +if (dspi->irq) +enable_irq (dspi->irq); +return ret; + }
[Severity: High]
When dspi_suspend() takes this new error return path after spi_controller_suspend() fails, does it leave SPI_CONTROLLER_SUSPENDED permanently set on dspi->ctlr->flags?
In drivers/spi/spi-fsl-dspi.c, dspi_suspend() calls disable_irq(dspi->irq) before calling spi_controller_suspend(dspi->ctlr). On platforms using DSPI_XSPI_MODE with an IRQ, in-flight or queued transfers in dspi_transfer_one_message() wait for dspi_interrupt() to signal dspi->xfer_done:
drivers/spi/spi-fsl-dspi.c:dspi_transfer_one_message() {
...
if (dspi->irq)
reinit_completion(&dspi->xfer_done);
dspi_fifo_write(dspi);
if (dspi->irq)
wait_for_completion(&dspi->xfer_done);
else
dspi_poll(dspi);
...
}Because disable_irq(dspi->irq) has already disabled the interrupt line, an in-flight IRQ-driven transfer cannot complete while spi_controller_suspend() waits in spi_stop_queue() for the queue to drain, causing spi_stop_queue() to time out after 5 seconds with -EBUSY.
In drivers/spi/spi.c, spi_controller_suspend() still calls __spi_mark_suspended(ctlr) unconditionally even when spi_stop_queue() fails:
drivers/spi/spi.c:spi_controller_suspend() {
...
if (ctlr->queued) {
ret = spi_stop_queue(ctlr);
if (ret)
dev_err(&ctlr->dev, "queue stop failed\n");
}
__spi_mark_suspended(ctlr);
return ret;
}When dspi_suspend() returns -EBUSY to device_suspend(), dev->power.is_suspended is not set, so device_resume() skips calling dspi_resume() during suspend-abort recovery. With nothing calling spi_controller_resume(dspi->ctlr) to clear SPI_CONTROLLER_SUSPENDED, wouldn't all subsequent synchronous SPI transfers in __spi_sync() fail with -ESHUTDOWN?
Should disable_irq(dspi->irq) be called after spi_controller_suspend() succeeds, or should the failure path also call spi_controller_resume()?
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 f2fs: avoid setting SBI_NEED_FSCK on transient resize failure
In reply to Sasha LevinFrom: Daeho Jeong <[email protected]>
[ Upstream commit 258c95150c26a30db1896eacd3bdef26314f2ca1 ]
When free_segment_range() fails in f2fs_resize_fs(), no on-disk superblock or filesystem metadata has been modified yet, and free_segment_range() safely restores all in-memory counters before returning.
However, the current error recovery path unconditionally sets the SBI_NEED_FSCK flag and prints a scary error message on any error, forcing an unnecessary and time-consuming fsck.f2fs repair on the subsequent mount/reboot.
Fix this by separating the error recovery path with a dedicated recover_user_blocks label to bypass setting SBI_NEED_FSCK on free_segment_range() failures.
---
LLM Generated explanations, may be completely bogus:
I have the local 6.12 code, the introducer, and the mailing-list review. Compiling the full nine-phase analysis next.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [f2fs] [avoid setting] Avoid setting SBI_NEED_FSCK when f2fs_resize_fs() fails in free_segment_range() before any on-disk metadata is modified.
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Daeho Jeong <[email protected]> (author, Google/Android f2fs)
- Signed-off-by: Sunmin Jeong <[email protected]>
- Reviewed-by: Chao Yu <[email protected]> (primary f2fs reviewer)
- Signed-off-by: Jaegeuk Kim <[email protected]> (f2fs maintainer)
- No Fixes: tag (expected)
- No Cc: stable (expected)
- No Reported-by / Tested-by / Link / syzbot
- Ignore pipeline-added Sasha Levin SOB / Upstream commit markers if present
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: f2fs_resize_fs() error recovery sets SBI_NEED_FSCK on any error after free_segment_range(), including failures that happen before update_sb_metadata() / f2fs_commit_super().
- Symptom: scary f2fs_err plus a persistent “need fsck” mark, so the next mount/reboot runs a long fsck.f2fs even though the filesystem is still consistent.
- Root cause: one shared recover_out label for both “GC/segment-free failed, nothing committed” and “superblock/checkpoint already changed.”
- Version info: none in the message. Code has been this way since online resize was added.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not hidden. It is an explicit error-path correctness fix: stop treating a transient resize failure as filesystem corruption.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: fs/f2fs/gc.c only (~6 insertions / 3 deletions in f2fs_resize_fs())
- Functions: f2fs_resize_fs()
- Scope: single-file surgical error-path change
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record (verified against local fs/f2fs/gc.c):
- Before: free_segment_range() error → goto recover_out → always set_sbi_flag(SBI_NEED_FSCK) + restore user_block_count.
- After: free_segment_range() error → goto recover_user_blocks → restore user_block_count / clear SBI_IS_RESIZEFS only.
- recover_out still used after f2fs_commit_super() / f2fs_write_checkpoint() failures (on-disk metadata already touched). It now also f2fs_bug_on(sbi, err == -EAGAIN) then sets SBI_NEED_FSCK, then falls through to restore user_block_count.
- Success path still falls through both labels with err == 0; no extra NEED_FSCK, no counter restore.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Category: logic / error-path correctness (false-positive corruption flag)
- Mechanism: free_segment_range() restores MAIN_SECS on every return (MAIN_SECS(sbi) += secs at its out: label). Callers have not yet called update_sb_metadata(). Marking NEED_FSCK is wrong for that path.
- Common trigger in this tree: f2fs_gc_range() returns -EAGAIN when valid blocks remain after one GC pass (gc.c “if (!dry_run && get_valid_blocks(...)) return -EAGAIN”).
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: splits “no metadata written” vs “metadata already updated.”
- Minimal; no API/data-structure change.
- Regression risk low. f2fs_bug_on(err == -EAGAIN) on recover_out is an invariant: with CONFIG_F2FS_CHECK_FS=n it WARNs and sets NEED_FSCK (already being set); with CHECK_FS it BUG_ONs only if checkpoint/super commit returned -EAGAIN, which that path should not.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Unconditional NEED_FSCK on resize failure introduced in 04f0b2eaa3b3ee (“f2fs: ioctl for removing a range from F2FS”, Qiuyang Sun, 2019).
- recover_out label from b4b10061ef98c5 (Jaegeuk Kim, 2020).
- Present in this 6.12 tree (git merge-base --is-ancestor 04f0b2eaa3b3ee HEAD succeeded).
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Introducer is the 2019 online-resize ioctl, confirmed in-tree.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- Related in-tree: 3b85edf3391f3 (migrate all curseg types in free_segment_range), 28fc4e9077ce5 (SBI_IS_RESIZEFS locking), 3ab0598e6d860 (resize panic). None already skip NEED_FSCK on free_segment_range() failure.
- Later mainline (f2fs-for-7.3-rc1, after this patch): “accurately adjust free_sections during free_segment_range” — separate accounting fix, not a prerequisite.
- Standalone.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Daeho Jeong is a regular Google/Android f2fs contributor in this tree (gc/zoned/sysfs work). Co-author Samsung. Maintainer Jaegeuk applied it.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: No new helpers. Uses existing set_sbi_flag / f2fs_bug_on / recover_out. Surrounding mainline context uses f2fs_down_write_trace and 3-arg thaw_super, which this tree does not have; those are context only, not dependencies of the logic change. Can apply standalone with a trivial context tweak.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c <sha> not used: candidate SHA is not in this checkout (b4 dig on the f2fs-for-7.3-rc1 merge 115bd364 rejected as a merge commit).
- b4 mbox msgid [email protected]:
5-message v1 thread saved.
- v1 (18 Aug 2026): skip NEED_FSCK only when err != -EAGAIN.
- Chao Yu: don’t key off -EAGAIN globally; it might come from other sites later.
- Daeho: any free_segment_range() error is pre-metadata; use a separate label.
- Chao: add f2fs_bug_on(sbi, err == -EAGAIN) on recover_out.
- v2 (20 Aug 2026): matches this candidate. Chao Reviewed-by. No NAKs. No Cc: stable in the thread.
- Landed in f2fs-for-7.3-rc1 (merged to mainline as 115bd364, “f2fs:
avoid setting SBI_NEED_FSCK on transient resize failure”).
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: linux-f2fs-devel, linux-kernel, [email protected]. Reviewed by Chao Yu; applied by Jaegeuk Kim.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla. Authors are Android/Samsung; the message describes forced fsck after a failed resize. No separate user bug URL found.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone (v1 then v2 of the same idea). Same 7.3 pull has other free_segment_range fixes; this one does not depend on them. “migrate all curseg types” is already here.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: Web search of lore.kernel.org/stable for this subject found no prior stable discussion or rejection. UNVERIFIED that no one privately requested it.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: f2fs_resize_fs(); closely related callees free_segment_range(), update_sb_metadata(), f2fs_commit_super(), f2fs_write_checkpoint().
Step 5.2: TRACE CALLERS
Record:
- f2fs_ioc_resize_fs() in fs/f2fs/file.c (F2FS_IOC_RESIZE_FS and compat). Requires CAP_SYS_ADMIN.
- Not interrupt/hot-path. Userspace-triggered admin ioctl (Android update_engine/vold online shrink is the main production use).
Step 5.3: TRACE CALLEES
Record: free_segment_range() temporarily drops MAIN_SECS, may move cursegs and GC, then always MAIN_SECS += secs before return. Only after success does f2fs_resize_fs() call update_sb_metadata() / f2fs_commit_super().
Step 5.4: FOLLOW THE CALL CHAIN
Record: ioctl → f2fs_resize_fs → freeze → user_block_count -= shrunk_blocks → free_segment_range. -EAGAIN when tail sections still have valid blocks is reachable and expected. After NEED_FSCK is set, a later resize hits is_sbi_flag_set(sbi, SBI_NEED_FSCK) and returns -EFSCORRUPTED. Checkpoint persists CP_FSCK_FLAG; remount restores NEED_FSCK.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: NEED_FSCK is used widely for real corruption. This was the only resize path that set it on a fully rolled-back in-memory failure. In- tree “f2fs: remove false alarm on iget failure during GC” is the same class of false NEED_FSCK.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. Local tree is pending-6.12, git describe HEAD = p-6.12-3-gc504cf0baa3d8, make kernelversion = 6.12.111.
```
2364: set_sbi_flag(sbi, SBI_IS_RESIZEFS);
2365: err = free_segment_range(sbi, secs, false);
2366: if (err)
2367: goto recover_out;
...
2388:recover_out:
2390: if (err) {
2391: set_sbi_flag(sbi, SBI_NEED_FSCK);
```Bug present since 2019 resize ioctl. recover_user_blocks is absent.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Functional hunk matches. Mainline context uses f2fs_down_write_trace (not in 6.12) and thaw_super(..., FREEZE_HOLDER_KERNEL, NULL) vs local two-arg FREEZE_HOLDER_USERSPACE. Expected difficulty: minor context adjustment, not a rework.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No. git log --grep on gc.c for this subject is empty. Resize- related commits here do not skip NEED_FSCK on free_segment_range() failure.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: f2fs (fs/f2fs/). IMPORTANT: not core VFS, but the default Android userdata filesystem; 6.12 LTS is used there.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Active (recent gc.c history is busy), but this bug is in long- stable resize recovery, not new 6.12-only code.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: f2fs users of F2FS_IOC_RESIZE_FS (Android virtual A/B / dynamic partitions, some embedded). Not universal. Config:CONFIG_F2FS_FS.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Shrink ioctl while tail sections still have valid blocks (-EAGAIN), or other free_segment_range() errors (-EIO, -ERESTARTSYS, allocate-segment failures). Common on a busy/full filesystem. Privileged only (CAP_SYS_ADMIN). Not a race; deterministic on that error path.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- False SBI_NEED_FSCK → next checkpoint writes CP_FSCK_FLAG → remount restores the flag → userspace fsck.f2fs.
- Further resize immediately -EFSCORRUPTED.
- fstrim warns and returns -EFSCORRUPTED; discard thread backs off.
- Severity: HIGH operational (forced long fsck, resize stuck). Not a panic, silent corruption, or UAF.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: high for Android/embedded f2fs-resize users on 6.12; stops a common -EAGAIN from pinning NEED_FSCK until fsck.
- Risk: very low (few lines, error path only, maintainer-acked).
- Ratio: favorable.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real, long-standing bug (2019) still in 6.12.111.
- Common -EAGAIN from GC during shrink is treated as corruption.
- Sticky NEED_FSCK blocks resize and can force a large-partition fsck.
- Small, obviously correct, reviewed by Chao Yu, applied by Jaegeuk.
- Google/Samsung authors; Android team on Cc.
- No missing helpers in this tree.
AGAINST:
- Not a crash, UAF, or on-disk corruption (it over-reports corruption).
- Privileged ioctl, not unprivileged.
- Exact mainline hunk needs trivial context (lock wrappers / thaw_super).
- No Fixes:/Cc: stable (not a negative per the rules).
UNRESOLVED:
- Exact mainline SHA not in this checkout (present in 7.3-rc1 f2fs pull).
- No stable-list thread found.
- Daeho mentioned restoring free_sections; 6.12 free_segment_range() only restores MAIN_SECS. That does not weaken the NEED_FSCK split.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — review-driven v2; logic matches free_segment_range() rollback.
2. Fixes a real bug that affects users? PASS — false NEED_FSCK / forced fsck / resize stuck.
3. Important issue? PASS — not a panic, but persistent false corruption flag plus -EFSCORRUPTED on later resize/fstrim is a serious availability bug on Android f2fs.
4. Small and contained? PASS — one function, ~9 lines.
5. No new features or APIs? PASS
6. Can apply to the local tree? PASS — buggy code present; needs only context adjustment.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: None of device-ID / quirk / DT / build / docs. Ordinary bugfix.
Step 9.4: MAKE YOUR DECISION
This belongs on 6.12. The bug exists here, the fix is surgical, and leaving it out keeps a production Android path where a retryable shrink failure marks the filesystem corrupted until fsck.
What it solves for stable users: a failed F2FS_IOC_RESIZE_FS that never committed superblock/FS metadata currently sets SBI_NEED_FSCK. That flag is checkpointed as CP_FSCK_FLAG, blocks later resize with -EFSCORRUPTED, and forces a long fsck.f2fs. The usual trigger is -EAGAIN from GC when the tail is not empty yet.
Risk vs benefit: a few error-path lines, fall-through restore preserved, NEED_FSCK still set after real super/checkpoint failures. Benefit is large for f2fs resize users on this LTS.
Concerns: apply with 6.12 lock/thaw context, not the mainline f2fs_down_write_trace / 3-arg thaw_super lines.
Verification:
- [Phase 1] Tags: Chao Reviewed-by, Jaegeuk SOB, Google+Samsung; no Fixes/syzbot
- [Phase 2] Diff: goto recover_user_blocks on free_segment_range() error; NEED_FSCK only on recover_out
- [Phase 2] Local free_segment_range(): MAIN_SECS += secs on all exits before update_sb_metadata()
- [Phase 2] Local f2fs_gc_range(): -EAGAIN if valid blocks remain
- [Phase 3] blame: NEED_FSCK from 04f0b2eaa3b3ee (2019); ancestor of HEAD
- [Phase 3] git merge-base --is-ancestor 04f0b2eaa3b3ee HEAD succeeded
- [Phase 3] No recover_user_blocks in this tree
- [Phase 4] b4 mbox msgid [email protected]:
v1, Chao review, label split
- [Phase 4] v2 + Chao Reviewed-by via lkml/openwall; no NAK
- [Phase 4] Pull f2fs-for-7.3-rc1 lists this subject
- [Phase 4] lore.kernel.org WebFetch 403; used b4 mbox + lkml mirrors instead
- [Phase 5] Caller: f2fs_ioc_resize_fs, CAP_SYS_ADMIN; NEED_FSCK blocks resize (gc.c:2293) and fstrim (segment.c:3400); checkpoint writes CP_FSCK_FLAG (checkpoint.c:1386-1387); remount restores it (super.c:4642-4643)
- [Phase 6] git describe HEAD p-6.12-3-gc504cf0baa3d8; make kernelversion 6.12.111
- [Phase 6] f2fs_down_write_trace absent; thaw_super is 2-arg
- [Phase 8] Failure: false NEED_FSCK, not oops; HIGH operational impact
- UNVERIFIED: exact mainline SHA (not in this checkout); no stable-list hit
**YES**
fs/f2fs/gc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
fs/f2fs/gc.c +6 -3
@@ -2415,7 +2415,7 @@ int f2fs_resize_fs(struct file *filp, __u64 block_count)set_sbi_flag (sbi,SBI_IS_RESIZEFS ); err =free_segment_range (sbi, secs, false);if (err) - goto recover_out; + goto recover_user_blocks;update_sb_metadata (sbi, -secs);
@@ -2437,11 +2437,14 @@ int f2fs_resize_fs(struct file *filp, __u64 block_count)f2fs_commit_super (sbi, false); } recover_out: -clear_sbi_flag (sbi,SBI_IS_RESIZEFS );if (err) { +f2fs_bug_on (sbi, err == -EAGAIN );set_sbi_flag (sbi,SBI_NEED_FSCK );f2fs_err (sbi,"resize_fs failed, should run fsck to repair!" ); - + } +recover_user_blocks: +clear_sbi_flag (sbi,SBI_IS_RESIZEFS ); +if (err) {spin_lock (&sbi->stat_lock); sbi->user_block_count += shrunk_blocks;spin_unlock (&sbi->stat_lock);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 perf/x86: Unregister PMI handler on PMU init failure
In reply to Sasha LevinFrom: Dapeng Mi <[email protected]>
[ Upstream commit 91787047b1dc52b1fee68b07f79af70aae5fce47 ]
Fix an NMI handler leak in init_hw_perf_events(). When PMU initialization fails after register_nmi_handler(), the error path exits without calling unregister_nmi_handler(), leaving a stale NMI_LOCAL "PMI" handler registered. Add the missing call before clearing x86_pmu state.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). The NMI-handler leak is in this checkout, and the four-line cleanup applies cleanly.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[perf/x86] [Unregister] Unregister PMI NMI handler when PMU init fails after register_nmi_handler()**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Dapeng Mi (author)
- Signed-off-by: Peter Zijlstra (Intel) (perf/x86 maintainer; merged to tip/perf/core)
- Reviewed-by: Thomas Falcon (Intel)
- Reviewed-by: Zide Chen (Intel)
- Link: https://patch.msgid.link/20260717080342.1879573-2-
[email protected]
- No Fixes:, Reported-by:, Tested-by:, Cc: stable, or syzbot tags (absence is expected)
- Pipeline markers ignored per instructions
- Tip merge SHA: 91787047b1dc52b1fee68b07f79af70aae5fce47 (not an ancestor of this tree)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** init_hw_perf_events() registers NMI_LOCAL handler "PMI" then can fail in cpuhp / perf_pmu_register without unregistering it.
- **Symptom:** stale NMI handler remains for the life of the kernel; first cpuhp failure also skips memset(&x86_pmu).
- **Version info:** none in the message. Code has been this way since the 2016 cpuhp conversion.
- **Root cause:** missing unregister_nmi_handler(NMI_LOCAL, "PMI") on post-register error paths.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. Explicit error-path resource-leak fix (NMI handler leak). Also completes the incomplete memset(&x86_pmu) on the first cpuhp_setup_state() failure, which today still return err.
===============================================================
PHASE 2: DIFF ANALYSIS
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: arch/x86/events/core.c only (+3 / −1; net +2)
- Function: init_hw_perf_events()
- Scope: single-file surgical error-path fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Hunk 1: cpuhp_setup_state(CPUHP_PERF_X86_PREPARE) failure currently return err (no NMI unregister, no memset). After: goto pmi_unregister.
- Hunk 2: new pmi_unregister: label after cpuhp teardown, before out_bad_pmu:. All later error paths (out/out1/out2) now unregister the PMI handler, then still memset(&x86_pmu, 0, ...).
- Early goto out_bad_pmu (no PMU driver / check_hw_exists() fail) stays before register_nmi_handler() and still skips unregister — correct.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Error-path resource leak.** register_nmi_handler() has no matching unregister_nmi_handler() if later init fails. Category (a) error-path leak; also incomplete cleanup of x86_pmu on the first cpuhp failure.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct. Success path still return 0 before the labels. First cpuhp failure still skips cpuhp_remove_state() (setup rolls back on failure). Early out_bad_pmu still does not unregister. Regression risk is very low; no API/locking/hot-path change.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- register_nmi_handler(..., "PMI"): 9c48f1c629ecfa (Don Zickus, 2011)
- cpuhp error paths including return err: 95ca792c7582fd (Thomas Gleixner, 2016; in v4.8-rc1)
- out_bad_pmu / memset(&x86_pmu): 916e3a4f950eac (Paolo Bonzini, 2022) — in this tree; message said hotplug install failure should clear x86_pmu, but the first return err was left uncleared
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Introducer of the leaky error path is 95ca792c7582fd, present in this tree (git merge-base --is-ancestor exit 0).
**Step 3.3: CHECK FILE HISTORY**
Record: Recent arch/x86/events/core.c changes are unrelated (callchain, hybrid, counters). No equivalent pmi_unregister commit. git log -S pmi_unregister -- arch/x86/events/core.c is empty here.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Dapeng Mi is a regular Intel perf/x86 contributor in this tree (PEBS, LBR, KASAN). Patch signed off by Peter Zijlstra.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Standalone. It is v3 1/8 of “Miscellaneous PMU bug fixes and optimizations”. Patch 2 (Free hybrid state on PMU init failure) *uses* the new pmi_unregister label but is a follow-up, not a prerequisite. unregister_nmi_handler() already exists (arch/x86/kernel/nmi.c). No new helpers required.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 91787047b1dc52b1fee68b07f79af70aae5fce47 matched the series (patch-id 48e634d2936fd149d8d36fbf100fd51c3fa0e39b)
- Lore/msgid: https://patch.msgid.link/20260717080342.1879573-2-
[email protected]
- v1→v3: this hunk is unchanged across revisions; later-series comments (hybrid cast, drain_pebs) do not affect this patch
- Merged to tip/perf/core 2026-08-10; no NAK found
- Cover letter: bugs found by Sashiko review of another series; tested on Diamonds/Novalake (perf test 119/155/156)
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: b4 dig -w recipients included Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, linux-kernel, linux-perf-users, plus Intel reviewers. Reviewed-by Thomas Falcon and Zide Chen; maintainer SOB from Peter Zijlstra.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla/user crash report. Found by static review (Sashiko), then coded as an explicit leak fix.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Series of 8; this patch is independent. Patch 2 is a related hybrid-state leak on the same function and can land later.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No useful stable-list hit that this was rejected or already queued. UNVERIFIED beyond search noise: lore.kernel.org returned 403 for direct thread fetch.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: init_hw_perf_events (modified). Related:perf_event_nmi_handler, unregister_nmi_handler, x86_pmu_prepare_cpu.
**Step 5.2: TRACE CALLERS**
Record: init_hw_perf_events is early_initcall — once at boot. x86_pmu_prepare_cpu is the PREPARE cpuhp callback; Intel/AMD cpu_prepare can return -ENOMEM (intel_cpuc_prepare kzallocs; amd_pmu_cpu_prepare kzallocs lbr_sel / amd_nb).
**Step 5.3: TRACE CALLEES**
Record: After register: cpuhp setup, perf_pmu_register. Handler perf_event_nmi_handler returns NMI_DONE if active_events==0, else static_call(x86_pmu_handle_irq).
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Not a syscall hot path. Reachable at boot if hardware PMU exists and later setup fails (ENOMEM in prepare, cpuhp failure, perf_pmu_register / hybrid register failure). Unprivileged users do not trigger it directly. If the handler is left registered after memset(&x86_pmu), a later NMI still walks it.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Other x86 NMI users (kgdb, IBS, nmi_selftest) pair register/unregister. This init path did not.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. arch/x86/events/core.c: register_nmi_handler at 2108; if (err) return err; at 2144–2145; out/out1/out2 then out_bad_pmu memset with no unregister. 91787047b1dc52b1fee68b07f79af70aae5fce47 is **not** an ancestor (merge-base --is-ancestor exit 1). Bug introduced with cpuhp conversion in v4.8 era.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: git apply --check of the two hunks against this tree: **clean apply** (rc 0). Surrounding init_hw_perf_events matches the patch.
Difficulty: clean apply.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: 916e3a4f950eac is present (clears x86_pmu on some fail paths) but still misses NMI unregister and the first return err. No later equivalent fix.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **perf/x86** (arch/x86/events/). **IMPORTANT** — x86 hardware performance monitoring, used by perf, KVM PMU (perf_get_x86_pmu_capability), and profiling. Not core mm/scheduler, not staging.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained (frequent intel/amd PMU commits). This leak is old (2016), not a brand-new subsystem.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: x86 systems with a hardware PMU whose **init fails after** NMI registration (ENOMEM in prepare, cpuhp setup fail, PMU register fail). Not every boot; not non-x86.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Boot-time only. Common “no/broken PMU” path (intel_pmu_init fail / check_hw_exists false) is **before** register, so it does not leak. The leak needs a later failure. intel_cpuc_prepare / amd_pmu_cpu_prepare returning -ENOMEM is a concrete trigger. Not unprivileged-triggerable.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Stale NMI_LOCAL handler remains; extra NMI-chain walk for the life of the system. If later paths memset x86_pmu while the handler is still registered, perf_event_nmi_handler can still run. If active_events==0 it returns NMI_DONE (typical after failed register). First cpuhp failure today also leaves x86_pmu populated, so perf_get_x86_pmu_capability() can report a live PMU after failed init — the case 916e3a4f950eac tried to close. Severity: **MEDIUM** (resource leak in NMI context; rare trigger; latent inconsistency more than a guaranteed oops).
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: medium for affected boots (correct NMI teardown + complete x86_pmu clear); modest globally because the path is rare
- Risk: very low (4-line error-path-only change, applies cleanly)
- Ratio: favorable — cheap correctness fix for a real leak
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real NMI handler leak on verified error paths in this 6.12 tree
- Also closes the leftover return err that skips memset(&x86_pmu) after PREPARE cpuhp failure
- Tiny, obviously correct, maintainer-acked, applies cleanly
- unregister_nmi_handler already exists; no new API
- Concrete -ENOMEM failure in Intel/AMD cpu_prepare
- Error-path leak cleanup is standard stable material
AGAINST:
- Rare one-time init path, not a hot-path leak
- No user/syzbot report; found by review
- Not a guaranteed panic/corruption on typical boots (active_events usually 0)
UNRESOLVED:
- Direct lore.kernel.org fetch returned 403; discussion reconstructed via b4, patchew, lkml.iu.edu
- No evidence this was rejected for stable
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — mechanical unregister; series tested; Peter Zijlstra merged it
2. Fixes a real bug that affects users? **PASS** — leaked NMI handler after failed x86 PMU init
3. Important issue? **PASS** — NMI-context resource leak plus incomplete PMU-state teardown; not a guaranteed panic, but more than cosmetic
4. Small and contained? **PASS** — +3/−1, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — git apply --check clean; buggy code present; fix not already here
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/docs exception. Ordinary small bugfix.
**Step 9.4: MAKE YOUR DECISION**
The leak exists in 6.12.111, the fix is surgical, and leaving an NMI handler registered after tearing down x86_pmu is a real stability defect even if the trigger is uncommon. Benefit/risk supports backport.
===============================================================
What the commit solves and why it matters here
===============================================================
On this tree, init_hw_perf_events() registers the "PMI" NMI handler, then sets up cpuhp states and registers the PMU. If any of those later steps fail, cpuhp is unwound (except the first PREPARE failure, which just returns) and x86_pmu is zeroed — but the NMI handler is left installed. That handler stays on the NMI_LOCAL list for the rest of the boot. The patch adds the missing unregister_nmi_handler() on those paths and routes the PREPARE failure through the same cleanup so x86_pmu is cleared consistently.
That matches stable rules: real bug, small, no new API, applies here without dependencies.
===============================================================
Verification
===============================================================
- [Phase 1] Parsed subject/tags: unregister PMI on init failure; SOB Dapeng Mi + Peter Zijlstra; R-b Falcon/Chen; Link msgid 20260717080342.1879573-2; no Fixes/syzbot
- [Phase 2] Diff: +3/−1 in init_hw_perf_events; return err → goto pmi_unregister; add unregister_nmi_handler(NMI_LOCAL, "PMI") before out_bad_pmu
- [Phase 3] Blame: leaky cpuhp errors from 95ca792c7582fd (v4.8); NMI register from 9c48f1c629ecfa (2011); memset from 916e3a4f950eac (2022), in this tree
- [Phase 3] git merge-base --is-ancestor 91787047b1dc52b1fee68b07f79af70aae5fce47 HEAD → not ancestor (fix absent)
- [Phase 3] git log -S pmi_unregister -- arch/x86/events/core.c → empty
- [Phase 4] b4 dig -c 91787047...: matched series; v1–v3 hunk unchanged; merged tip/perf/core 2026-08-10
- [Phase 4] Cover letter (lkml.iu.edu / patchew): Sashiko-found PMU bugs; this patch is 1/8 and standalone
- [Phase 4] b4 dig -w: Peter Zijlstra, Ingo, linux-perf-users CC’d; no NAK found
- [Phase 4] lore.kernel.org WebFetch 403; stable-list search did not show a rejection
- [Phase 5] intel_cpuc_prepare / amd_pmu_cpu_prepare return -ENOMEM — verified trigger for PREPARE cpuhp failure
- [Phase 5] perf_event_nmi_handler still callable if handler leaked; early-out if !active_events
- [Phase 6] git describe HEAD → p-6.12-3-gc504cf0baa3d8; make kernelversion → 6.12.111
- [Phase 6] Local code at arch/x86/events/core.c:2108 and :2144-2201 matches the buggy pattern
- [Phase 6] git apply --check of the two hunks → rc 0 (clean apply)
- [Phase 8] Failure mode: leaked NMI handler + incomplete x86_pmu clear; severity MEDIUM; trigger rare (init error)
- UNVERIFIED: full lore mbox body (403); whether linus.git mainline SHA differs from tip SHA 91787047 (tip merge confirmed)
The fix is small, surgical, present as a real bug in this 6.12 tree, and meets the stable criteria.
**YES**
arch/x86/events/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/events/core.c +3 -1
@@ -2175,7 +2175,7 @@ static int __init init_hw_perf_events(void) err =cpuhp_setup_state (CPUHP_PERF_X86_PREPARE ,"perf/x86:prepare" , x86_pmu_prepare_cpu, x86_pmu_dead_cpu);if (err) -return err; + goto pmi_unregister; err = cpuhp_setup_state(CPUHP_AP_PERF_X86_STARTING, "perf/x86:starting", x86_pmu_starting_cpu,
@@ -2229,6 +2229,8 @@ static int __init init_hw_perf_events(void)cpuhp_remove_state (CPUHP_AP_PERF_X86_STARTING ); out:cpuhp_remove_state (CPUHP_PERF_X86_PREPARE ); +pmi_unregister: +unregister_nmi_handler (NMI_LOCAL ,"PMI" ); out_bad_pmu:memset (&x86_pmu,0 ,sizeof (x86_pmu));return err;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-6.1] perf/x86: Unregister PMI handler on PMU init failure
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines
From: Dapeng Mi <[email protected]>
[ Upstream commit
91787047b1dc52b1fee68b07f79af70aae5fce47]Fix an NMI handler leak in
init_hw_perf_events(). When PMU initialization fails afterregister_nmi_handler(), the error path exits without callingunregister_nmi_handler(), leaving a staleNMI_LOCAL"PMI" handler registered. Add the missing call before clearingx86_pmustate.
Quoted 6 lines
Signed-off-by Dapeng Mi <[email protected]>Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Thomas Falcon <[email protected]>Reviewed-by Zide Chen <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 ksmbd: reject blocking compound lock requests
In reply to Sasha LevinFrom: Namjae Jeon <[email protected]>
[ Upstream commit 16a7f7c2ecf3c893b65f0fb78fa7a7171ae0ba9e ]
Clients set SMB2_LOCKFLAG_FAIL_IMMEDIATELY when a LOCK request contains multiple lock elements, and servers reject requests that omit it. Accepting such a request can leave earlier elements locked while a later element waits asynchronously, enabling prolonged partial lock ownership and avoidable deadlocks.
Return STATUS_INVALID_PARAMETER before processing any element when a multi-element lock request contains a blocking lock. Unlock arrays remain unaffected.
---
LLM Generated explanations, may be completely bogus:
This is a protocol-validation deadlock fix in ksmbd’s SMB2 LOCK path. It belongs in this 6.12 tree: the buggy loop has been here since ksmbd was added, and the change is a seven-line reject of a request the spec and Samba already forbid.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [ksmbd] [reject] [refuse multi-element SMB2 LOCK requests that omit SMB2_LOCKFLAG_FAIL_IMMEDIATELY]
“Reject” is a bug-fix verb: stop accepting invalid protocol that can hang the server.
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Namjae Jeon <[email protected]> (ksmbd maintainer; ignore any pipeline SOB)
- No Fixes:, Reported-by, Tested-by, Reviewed-by, Acked-by, Link:, or
Cc: stable
- Absence of Fixes/Cc:stable is expected for this review and is not a negative signal
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: a LOCK with more than one element may omit FAIL_IMMEDIATELY (a blocking lock). ksmbd currently processes elements in order, so earlier ranges can be granted while a later range waits asynchronously.
- Symptom: prolonged partial lock ownership and avoidable deadlocks.
- Spec intent: clients set FAIL_IMMEDIATELY on multi-element LOCK; servers reject requests that omit it with STATUS_INVALID_PARAMETER.
- Unlock arrays are intentionally left unchanged.
- No kernel-version range in the message.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. It is an explicit protocol/deadlock fix.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: fs/smb/server/smb2pdu.c only (~7 lines added, 0 removed)
- Function: smb2_lock()
- Scope: single-file surgical validation in the existing lock-element loop
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
Before: after building lock_list, the loop validates cmd/flags/mix, then may call vfs_lock_file(). A blocking element uses F_SETLKW/FL_SLEEP, can return FILE_LOCK_DEFERRED, send STATUS_PENDING, and ksmbd_vfs_posix_lock_wait(). Earlier elements already granted stay on rollback_list / conn->lock_list during that wait.
After: if lock_count > 1, the first element is not UNLOCK, and the current element lacks FAIL_IMMEDIATELY, set err = -EINVAL and goto out before vfs_lock_file() on that element. out/out2 already map -EINVAL to STATUS_INVALID_PARAMETER and roll back granted locks.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record: [Logic / protocol correctness + deadlock prevention]
- Spec (MS-SMB2 3.3.5.14.2): if Locks[] has more than one entry and any lacks FAIL_IMMEDIATELY, the server SHOULD fail with STATUS_INVALID_PARAMETER.
- Client rule (MS-SMB2 3.2.4.19): if Locks[] has more than one element, the client MUST set FAIL_IMMEDIATELY.
- Mechanism: reject blocking multi-element LOCKs so ksmbd cannot hold earlier ranges while waiting on a later one.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: same check Samba already does in smbd_smb2_lock_send().
- Minimal: one condition, existing error path.
- Regression risk: very low for compliant clients (they always set the flag). A non-compliant client that used blocking multi-locks would start getting STATUS_INVALID_PARAMETER — that is the intended spec behavior.
- Caveat: the check is inside the processing loop, so a later blocking element can still apply earlier FAIL_IMMEDIATELY locks and then roll them back. That matches existing out: rollback, not a new leak. Samba checks the whole array first; this is slightly later but still correct.
- The new if runs before list_del(&smb_lock->llist), so the current element is still on lock_list and is freed on out:. No leak.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record: The processing loop was introduced in e2f34481b24db (“cifsd:
add server-side procedures for SMB3”, 2021-05-10). git merge-base --is- ancestor e2f34481b24db HEAD succeeds. This has been in ksmbd since it landed, including this 6.12 tree.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Not applicable. The missing check dates to the original smb2_lock implementation.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: Recent smb2pdu.c work in this tree is other protocol/security fixes (partial info, leases, etc.), not this check. Related historical lock bugs already here include UAFs and leaks in deferred-lock/cancel (ddb9239828336, 89ae9df09d2c1, 463bbd7969851, a0609097fd10d). This patch is standalone, not “2/N”.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Namjae Jeon is the ksmbd maintainer. Many of this tree’s ksmbd stable-style fixes are his. The 7.3-rc1 ksmbd pull lists this commit among lock/async correctness updates.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: No new helpers or fields. It uses lock_count, lock_ele[0].Flags, smb_lock->flags, and SMB2_LOCKFLAG_*, all present here. Nearby 7.3 lock work (replay sequences, deferred-lock discard) is not required. Standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record: lore.kernel.org search returned 403; b4 dig -c needs a commit that is not in this checkout. The commit is listed in Namjae’s [GIT PULL] ksmbd server update for 7.3-rc1 (2026-08-23, Message-ID CAKYAXd8PROT1-3CXk2MnJco2KNKH_4iiN-Ypo5vOFWLPhRki4Q@mail.gmail.com), tag ksmbd-for-7.3-rc1. Full v1/v2 review thread: UNVERIFIED.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: UNVERIFIED for the original To/Cc list. It went through the ksmbd maintainer pull to Linus. No NAK found in the pull description.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla link. Motivation is MS-SMB2 + deadlock analysis, not a named CVE. Samba documents the same SHOULD-fail rule with a comment citing 3.3.5.14.2.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Same 7.3 pull also has lock-sequence replay, deferred-lock discard, and detach-before-free. Those are separate. This one is self- contained validation.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable search returned 403. No evidence this was already rejected for stable. UNVERIFIED whether AUTOSEL already queued it.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: smb2_lock() only.
Step 5.2: TRACE CALLERS
Record: Dispatched as smb2_0_server_cmds[SMB2_LOCK_HE].proc = smb2_lock in fs/smb/server/smb2ops.c. Reached from __handle_ksmbd_work() → cmds->proc(work) in fs/smb/server/server.c for any SMB2 LOCK on an authenticated session with a valid file id.
Step 5.3: TRACE CALLEES
Record: Existing path uses vfs_lock_file(), setup_async_work(), smb2_send_interim_resp(), ksmbd_vfs_posix_lock_wait(). The wait is wait_event(flock->c.flc_wait, !flock->c.flc_blocker) — uninterruptible. That is why a blocking multi-lock can pin a ksmbd worker while earlier ranges stay held.
Step 5.4: FOLLOW THE CALL CHAIN
Record: Userspace/network reachable: SMB client → TCP → ksmbd worker → smb2_lock(). Needs an authenticated session and open handle, not CAP_SYS_ADMIN. Typical NAS user can send it.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Samba source3/smbd/smb2_lock.c rejects in_lock_count > 1 when the first element is a blocking SHARED/EXCLUSIVE lock, then walks remaining elements and fails any without FAIL_IMMEDIATELY. Same bug class, already fixed in Samba.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. Local tree is **6.12.111** (pending-6.12, git describe p-6.12-3-gc504cf0baa3d8). smb2_lock() at fs/smb/server/smb2pdu.c:7535 still starts the loop at 7635 with no multi-element FAIL_IMMEDIATELY check. Bug introduced with ksmbd (v5.15-era e2f34481b24db), present here. git log --grep='reject blocking compound lock' -- fs/smb/server/ is empty.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Insertion point matches. Upstream hunk context uses smb2_lock_init(..., !lock_length, &lock_list); this tree still has smb2_lock_init(flock, cmd, flags, &lock_list). Expect a minor context conflict, trivial to apply by hand. No semantic dependency on the extra !lock_length argument.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No equivalent check. Existing FAIL_IMMEDIATELY use only skips connection-list conflict checks for blocking single locks (goto no_check_cl). That is the opposite of rejecting multi-element blocking locks.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [fs/smb/server (ksmbd)] [IMPORTANT for CONFIG_SMB_SERVER; default n]. Network-facing file server. Lock bugs affect all ksmbd shares.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Actively maintained; this 6.12 branch already carries many ksmbd protocol and UAF fixes. Mature lock path, old bug.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Config-specific: CONFIG_SMB_SERVER. Authenticated SMB clients of ksmbd NAS/embedded/Android-style servers.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: SMB2 LOCK with LockCount > 1 and at least one non-unlock element without FAIL_IMMEDIATELY. Windows/Samba clients must set the flag, so well-behaved traffic never hits it. A buggy or malicious authenticated client can. Unprivileged in the kernel sense; needs a ksmbd login and file handle.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: [Deadlock / worker hang / cross-client lock inversion] [HIGH] Not a KASAN crash. Holding range A while waiting uninterruptibly for range B is a real deadlock and can stall a ksmbd workqueue thread. That is why the protocol forbids it.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: high for ksmbd hosts — closes a remote deadlock/DoS via illegal LOCK arrays; aligns with Samba/MS-SMB2.
- Risk: very low — 7 lines, existing -EINVAL path, no ABI, no lock- order change.
- Ratio: strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real deadlock/partial-ownership bug on a network file server
- MS-SMB2 3.3.5.14.2 and Samba implement the same reject
- Tiny, obviously correct, uses existing error/rollback
- Buggy code present in this 6.12 tree since ksmbd introduction
- Maintainer-authored; in the 7.3-rc1 ksmbd pull
- Reachable by authenticated SMB clients
AGAINST:
- Spec is SHOULD, not MUST (footnote 373); Windows may differ
- Compliant clients never send this
- No Reported-by / syzbot / CVE
- Original lore review thread not retrieved
UNRESOLVED:
- Exact lore URL / series revisions (b4/lore 403)
- Whether AUTOSEL already picked it for some series
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — matches Samba; ksmbd maintainer; uses existing STATUS_INVALID_PARAMETER path
2. Fixes a real bug that affects users? PASS — deadlock/partial lock ownership on ksmbd
3. Important issue? PASS — deadlock / server-worker hang, not a style tweak
4. Small and contained? PASS — 7 lines, one function
5. No new features or APIs? PASS — validation only
6. Can apply to the local tree? PASS — same loop; at most a trivial smb2_lock_init context tweak
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: None. Qualifies as a normal important bug fix, not a device- ID/quirk/DT exception.
Step 9.4: MAKE YOUR DECISION
Backport to this 6.12 tree. The bug is here, the fix is surgical, and leaving ksmbd willing to block on multi-element LOCKs is a deadlock hazard for a network-facing server.
What it solves for stable users: ksmbd currently accepts multi-range LOCK requests that omit FAIL_IMMEDIATELY. It can grant earlier ranges, then sleep uninterruptibly on a later range (ksmbd_vfs_posix_lock_wait()), which enables lock-order deadlocks and stuck workers. The patch returns STATUS_INVALID_PARAMETER first (unlock arrays unchanged).
Risk vs benefit: benefit is deadlock prevention on ksmbd; risk is a one- condition reject of traffic no compliant client sends.
Concerns: apply context around smb2_lock_init() may need a one-line tweak; no other prerequisites.
Verification:
- [Phase 1] Tags: only Namjae Jeon SOB; no Fixes/Reported-by/Link
- [Phase 2] Diff: 7 lines in smb2_lock() loop; -EINVAL → STATUS_INVALID_PARAMETER at smb2pdu.c:7889-7891; check is before list_del/vfs_lock_file
- [Phase 2] Local blocking path: FILE_LOCK_DEFERRED → ksmbd_vfs_posix_lock_wait() at smb2pdu.c:7760-7788; wait is wait_event() in vfs.c:1894-1896
- [Phase 3] Blame: loop from e2f34481b24db (2021); ancestor of HEAD; fix not in this tree
- [Phase 3] No Fixes: tag to follow
- [Phase 3] Related history: deferred-lock UAFs already in tree; this check is independent
- [Phase 4] GIT PULL 7.3-rc1 lists this subject; lore/b4 thread UNVERIFIED (403 / no local SHA)
- [Phase 4] MS-SMB2 3.3.5.14.2 SHOULD-fail; 3.2.4.19 client MUST set FAIL_IMMEDIATELY on multi-element LOCK
- [Phase 4] Samba smb2_lock.c:342-378 implements the same INVALID_PARAMETER reject
- [Phase 5] Caller: smb2ops.c:187 SMB2_LOCK_HE → server.c:147 cmds->proc
- [Phase 6] make kernelversion 6.12.111; buggy loop at smb2pdu.c:7635; smb2_lock_init here has 4 args vs upstream 5 in hunk context
- [Phase 6] git log --grep='reject blocking compound lock' -- fs/smb/server/ empty
- [Phase 8] Failure mode: deadlock/worker hang, not oops; authenticated SMB client can trigger
- UNVERIFIED: original lore review comments, AUTOSEL status, Windows footnote 373 runtime behavior
**YES**
fs/smb/server/smb2pdu.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/smb/server/smb2pdu.c +7 -0
@@ -7748,6 +7748,13 @@ int smb2_lock(struct ksmbd_work *work) }list_for_each_entry_safe (smb_lock, tmp, &lock_list, llist) { +if (lock_count >1 && + !(le32_to_cpu (lock_ele[0 ].Flags) &SMB2_LOCKFLAG_UNLOCK ) && + !(smb_lock->flags &SMB2_LOCKFLAG_FAIL_IMMEDIATELY )) { + err = -EINVAL ; + goto out; + } +if (smb_lock->cmd <0 ) { err = -EINVAL ; goto out;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 nbcon/reboot: Switch NBCON consoles into the emergency mode in emergency_restart()
In reply to Sasha LevinFrom: Petr Mladek <[email protected]>
[ Upstream commit d8e5fc3002294a28af53e97f6c83a35956e738f3 ]
When the system is going down a normal way, the NBCON kthreads are flushed and stopped properly via a syscore shutdown callback, see printk_kthreads_shutdown().
One missing piece is emergency_restart() where the kthreads are not stopped. It might be called from several non-panic code paths, e.g. sysrq-o, kdb_reboot(), or some watchdogs.
Fix it by explicitly entering the emergency (atomic) mode and trying to flush the consoles there.
Note that printk_trigger_flush() must be used instead of pr_flush() because the later is not safe in an atomic context.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.18.57**. This is a real NBCON flush gap on emergency_restart(), the APIs already exist here, and the change is a small best-effort flush before reboot.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[nbcon/reboot] [Switch] Switch NBCON consoles into emergency (atomic) mode in emergency_restart()** so pending printk output is flushed instead of being left in kthreads that never get stopped.
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- **Reported-by:** kernel test robot <[email protected]>
- **Closes:** https://lore.kernel.org/all/[email protected]/
- **Suggested-by:** John Ogness <[email protected]>
- **Reviewed-by:** John Ogness <[email protected]>
- **Link:** https://patch.msgid.link/[email protected]
- **Signed-off-by:** Petr Mladek <[email protected]> (printk maintainer)
- No Fixes: tag (expected)
- No Cc: stable (expected)
- Ignore pipeline Signed-off-by: Sasha Levin / [Upstream commit ...]
Notable: LKP report plus review by the NBCON designer. Not syzbot/KASAN; this is a console-flush failure, not a memory-safety crash.
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** Normal reboot stops NBCON printer kthreads via printk_kthreads_shutdown() (syscore shutdown). emergency_restart() skips that path.
- **Symptom:** Last kernel messages may never appear on NBCON consoles before the machine resets (LKP: “kernel reboot-without-warning”).
- **Failure mode:** Lost diagnostic output on sysrq reboot, kdb reboot, watchdogs, and other non-panic emergency restart paths. The commit says “sysrq-o”; the actual sysrq reboot op in this tree is **sysrq-b** (drivers/tty/sysrq.c). That is a message inaccuracy, not a code issue.
- **Root cause:** With kthreads still running, flush stays in offload mode (nbcon_offload) instead of atomic mode (nbcon_atomic).
- **Fix:** Enter NBCON emergency mode, then printk_trigger_flush(). pr_flush() is not used because it is not atomic-safe; emergency_restart() is documented as IRQ-safe.
- **Version note:** Committed to printk for-7.3-hotfix. The same kthread/emergency infrastructure is already in 6.18.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. Explicit bug fix for missed console flush on emergency restart.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: kernel/reboot.c (**+9**, 0 removed in the functional hunk; plus #include <linux/console.h>)
- Function: emergency_restart()
- Scope: single-file surgical fix
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- **Before (v6.18.57):** kmsg_dump(KMSG_DUMP_EMERG) → system_state = SYSTEM_RESTART → machine_emergency_restart(). No console flush; kthreads are left running and then the CPU resets.
- **After:** same dump/state, then nbcon_cpu_emergency_enter() + printk_trigger_flush(), then machine_emergency_restart().
- Path affected: emergency restart only (sysrq-b, kdb, watchdogs, hangcheck, ocfs2 quorum, amdgpu RAS, hw-protection fallback). Not the orderly kernel_restart()/kernel_power_off() paths that already call syscore_shutdown().
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- **Category:** logic / correctness (console flush), with a hardware- observability effect
- **Mechanism:** printk_get_console_flush_type() uses nbcon_get_default_prio(). Normal prio with printk_kthreads_running sets nbcon_offload (wake kthreads). Emergency prio sets nbcon_atomic (flush via write_atomic() in the caller).
- nbcon_cpu_emergency_enter() raises per-CPU emergency nesting (and preempt_disable). printk_trigger_flush() then calls nbcon_atomic_flush_pending().
- No matching nbcon_cpu_emergency_exit():
machine_emergency_restart() is not expected to return. The RFC had an unreachable exit after it; v2 correctly dropped it.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: same emergency-enter pattern as oops_enter() / __warn().
- Minimal: two calls and one include.
- Regression risk: low. Best-effort atomic flush immediately before reboot. Nested enter from panic() → emergency_restart() is safe (nesting counter). If machine_emergency_restart() ever returned, preemption would stay disabled; that is already a “reboot failed” dead end (kdb_reboot() already spins). John Ogness noted it is still best-effort if another CPU owns the console.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- emergency_restart() itself: 15d94b82565eb (Robin Holt, 2013).
- The actual bug is the later NBCON kthread model, not that 2013 function.
- Introducers present in this tree:
- ecb5e1aa82c86 (2024-08-21) printk: nbcon: Implement emergency sections
- 76f258bf3f2aa (2024-09-04) printk: nbcon: Introduce printer kthreads
- 13189fa73afae (2024-09-04) printk: nbcon: Rely on kthreads for normal operation
- All three are ancestors of v6.18.57.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Not applicable. The missing piece is emergency_restart() vs printk_kthreads_shutdown(), which exists in this tree at kernel/printk/printk.c.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- Recent kernel/reboot.c history is reboot/hw-protection work, plus 6ea9a1781c70a “Flush console log from kernel_power_off()” (already in 6.18.57, uses pr_flush() on the orderly power-off path after syscore_shutdown()).
- Standalone v2. v1 also patched nbcon_get_default_prio() and orderly reboot/halt; John Ogness rejected that as too broad. v2 only touches emergency_restart(). No extra series patches required.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Petr Mladek is the printk maintainer. Related history is NBCON/panic/printk merge work. Suggested and reviewed by John Ogness (NBCON designer). Strong maintainer signal.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record:
- Needs nbcon_cpu_emergency_enter() (include/linux/console.h, stub if !CONFIG_PRINTK) — present in v6.18.57.
- Needs printk_trigger_flush() (include/linux/printk.h) — present in v6.18.57.
- printk_trigger_flush is already visible in reboot.c via linux/suspend.h → linux/printk.h. The new include is for nbcon_cpu_emergency_enter().
- Can apply standalone. Confirmed: git merge-base --is-ancestor b140889fb6c82 v6.18.57 is false (not in the 6.18.57 baseline); the function/APIs the patch uses are in that baseline.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- Lore/v2:
https://patch.msgid.link/[email protected]
- **v1:** https://lore.kernel.org/r/[email protected] (“Flush nbcon consoles synchronously on reboot”) — broader system_state > SYSTEM_RUNNING → NBCON_PRIO_EMERGENCY plus extra flushes on orderly restart/halt.
- John Ogness on v1: too general; orderly reboot already handled by syscore; only emergency_restart() needs emergency enter + flush. v2 is that narrower patch.
- No NAKs on v2. John Ogness Reviewed-by. Petr committed it to printk/linux.git branch **for-7.3-hotfix**.
- No reviewer Cc: stable in the thread.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): Petr Mladek, John Ogness, Sergey Senozhatsky, Steven Rostedt, Pavel Tikhomirov, Oleg Nesterov, Christian Brauner, Sebastian Andrzej Siewior, LKP, linux-serial, linux-kernel. Subsystem maintainers were on To/Cc. John Ogness reviewed.
Step 4.3: SEARCH FOR THE BUG REPORT
Record (from /tmp/lkp.mbox):
- LKP: BUG:kernel_reboot-without-warning_in_test_stage after d353934702 “serial: 8250: Switch to nbcon console, take 2” (linux- next, **not** in 6.18.57).
- John Ogness: kernel buffer not flushed before sysrq-triggered emergency restart; printk no longer blocks on UART TX once 8250 is NBCON.
- That 8250 conversion is **not** in this 6.18 tree (git merge-base --is-ancestor d353934702… v6.18.57 failed; 8250 still legacy here).
- The same flush hole still applies to **NBCON consoles that 6.18 does have**.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: v1 was replaced by this v2. No remaining series members needed. Orderly reboot/power-off already use syscore_shutdown() → printk_kthreads_shutdown().
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore stable/?q=nbcon+emergency_restart returned **no results**. No prior stable NAK or nomination found.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: emergency_restart() only. Callees added:nbcon_cpu_emergency_enter(), printk_trigger_flush().
Step 5.2: TRACE CALLERS
Record (this tree):
- drivers/tty/sysrq.c — sysrq-b reboot (userspace-reachable with sysrq)
- kernel/debug/kdb/kdb_main.c — kdb_reboot()
- kernel/panic.c — panic reboot (panic_timeout != 0)
- kernel/reboot.c — hardware-protection fallback
- Watchdogs: softdog, at91sam9, bd96801, eurotech, keembay, rzn1, sama5d4, wdt, wdt_pci
- drivers/char/hangcheck-timer.c
- fs/ocfs2/cluster/quorum.c, fs/ocfs2/stack_user.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c (RAS emergency restart)
- drivers/scsi/smartpqi/smartpqi_init.c
IRQ-safe by contract. Common production paths: sysrq, watchdogs, panic reboot.
Step 5.3: TRACE CALLEES
Record:
- nbcon_cpu_emergency_enter(): preempt_disable() + per-CPU nesting++
- printk_trigger_flush(): printk_get_console_flush_type() then atomic/offload/legacy flush
- After emergency enter: NBCON_PRIO_EMERGENCY → nbcon_atomic_flush_pending()
- machine_emergency_restart(): architecture reset, does not return in the success case
Step 5.4: FOLLOW THE CALL CHAIN
Record: Yes, userspace-reachable (sysrq-b, watchdog devices, kdb). Panic path already flushes more aggressively (console_flush_on_panic, nbcon_atomic_flush_unsafe) before calling emergency_restart(); this mainly helps **non-panic** emergency restarts.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same enter/flush pattern in oops_enter(), __warn(), RCU stall, lockdep. printk_kthreads_shutdown() is the orderly equivalent (stop kthreads + nbcon_atomic_flush_pending()). This is the missing emergency-restart counterpart, not a new design.
semcode MCP was not available; callers/callees were traced with git grep and direct reads.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: **Yes.** Local tree: git describe HEAD → v6.18.57-155-gcdf239ca885b2, make kernelversion → **6.18.57**.
- v6.18.57:kernel/reboot.c emergency_restart() has no emergency enter/flush.
- NBCON kthreads + emergency sections are in 6.18.57.
- NBCON consoles in 6.18.57: **amba-pl011, imx, sifive, tegra-utc, drm_log**, each with write_atomic. 8250 is still legacy here, so the LKP 8250 case is not this tree; ARM/i.MX/RISC-V/Tegra serial consoles still hit the hole.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **Clean apply.** v6.18.57 emergency_restart() matches the pre- patch function. Need #include <linux/console.h> (not present in v6.18.57 reboot.c). Context around includes differs slightly from mainline (rcupdate.h, sched/signal.h, __rcu cad_pid) but the hunk is local to emergency_restart() and applies cleanly.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: Orderly path already has printk_kthreads_shutdown and kernel_power_off()’s pr_flush(). No earlier equivalent for emergency_restart(). The candidate SHA on HEAD is pipeline application, not evidence the 6.18.57 baseline already had the fix (merge-base --is-ancestor vs v6.18.57 failed).
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: **printk / reboot (kernel/reboot.c + NBCON).** Criticality:
**IMPORTANT** (core reboot path; impact is console visibility, not mm/vfs data integrity).
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: NBCON/printk is actively developed, but the kthread model has been in this series since 6.12-era commits (2024). This is a leftover hole, not a brand-new 7.3-only subsystem.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Users of **NBCON consoles** on emergency restart. In **this 6.18 tree**: ARM PL011 (very common), i.MX UART, SiFive, Tegra UTC, DRM log. Not typical PC 8250 serial (still legacy). Config: CONFIG_PRINTK plus those drivers.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Any emergency_restart(): sysrq-b, watchdog timeout, kdb reboot, hangcheck, ocfs2 quorum, amdgpu RAS, hw-protection fallback, panic reboot. Common on broken/hung systems. Sysrq can be triggered from userspace if enabled. Timing: always on those paths when NBCON kthreads are running.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: Lost last console messages, then reset. System still reboots. **Severity: MEDIUM** (diagnostics / “reboot without warning”), not panic/UAF/corruption. High operational value on watchdog/sysrq because those last lines are why the box reset.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit:** Medium-high for 6.18 NBCON UART users (PL011/i.MX etc.); lower than 7.3 where 8250 is NBCON, but the hole is real here.
- **Risk:** Very low (9 lines, reboot-only, best-effort flush, does not return).
- **Ratio:** Favorable. Maintainers treated it as a 7.3 hotfix; same mechanics apply to 6.18 NBCON consoles.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
**FOR backporting:**
- Real bug in this tree: emergency_restart() never stops NBCON kthreads or forces atomic flush; printk_kthreads_shutdown() is only on syscore shutdown.
- User-visible: last messages dropped on sysrq-b / watchdog / kdb / similar. LKP reproduced “reboot-without-warning”; John Ogness confirmed the mechanism.
- APIs and NBCON kthreads exist in 6.18.57; PL011/i.MX/etc. already use CON_NBCON + write_atomic.
- Small, obviously correct, printk-maintainer authored, NBCON designer reviewed (v2 after rejecting a broader v1).
- Very low regression risk.
**AGAINST backporting:**
- Not a crash, UAF, deadlock, or data-corruption fix. Severity is diagnostic.
- The LKP 8250-nbcon trigger is **not** in 6.18; PC 8250 users here are unaffected.
- Flush remains best-effort if another CPU holds the console.
- No Cc: stable (not a negative by itself).
**UNRESOLVED:** None that block the decision. WebFetch to lore returned 403; threads were retrieved with b4/curl. No stable-list discussion found.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — reviewed by Ogness; LKP- motivated; v2 is the reduced form after review.
2. Fixes a real bug that affects users? **PASS** — lost last console output on emergency restart for NBCON consoles present in 6.18.
3. Important issue? **PASS** (medium-high operational: last logs on watchdog/sysrq/kdb; not a crash).
4. Small and contained? **PASS** — ~9 lines, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — clean apply to 6.18.57; prerequisites present.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: None (not a device ID, DT, quirk, build, or docs-only change). It is a normal small bugfix.
Step 9.4: MAKE YOUR DECISION
This should be backported to this 6.18.57 tree. The bug is here, the fix is surgical, and missing last-line console output on emergency restart is exactly when those messages matter. 8250 not being NBCON only reduces the affected population; it does not remove the bug for PL011/i.MX and the other NBCON consoles already in 6.18.
Verification:
- [Phase 1] Parsed tags: Reported-by LKP, Suggested/Reviewed-by John Ogness, Link msgid 20261013154141.94016-1; no Fixes/Cc:stable
- [Phase 1] Body: emergency_restart skips printk_kthreads_shutdown; use emergency mode + printk_trigger_flush
- [Phase 2] Diff: +include linux/console.h; +nbcon_cpu_emergency_enter(); +printk_trigger_flush() in emergency_restart()
- [Phase 2] printk_get_console_flush_type: NORMAL+kthreads → nbcon_offload; EMERGENCY → nbcon_atomic
- [Phase 3] git describe/make kernelversion: v6.18.57; Makefile 6.18.57
- [Phase 3] git merge-base --is-ancestor b140889fb6c82 v6.18.57 → not in 6.18.57 baseline
- [Phase 3] git show v6.18.57:kernel/reboot.c: emergency_restart has no flush
- [Phase 3] git merge-base --is-ancestor of ecb5e1aa82c86, 76f258bf3f2aa, 13189fa73afae vs v6.18.57 → all present
- [Phase 3] blame: emergency_restart from 15d94b82565eb (2013); NBCON kthread offload from 13189fa73afae (2024)
- [Phase 4] b4 dig -c d8e5fc300229: v2 at patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: only v2 matched this patch-id; v1 msgid 20261008150852.8286-1 was broader and replaced
- [Phase 4] b4 dig -w: printk maintainers CC’d; John Ogness reviewed
- [Phase 4] LKP mbox: reboot-without-warning after 8250 nbcon switch;
Ogness: buffer not flushed before sysrq emergency restart
- [Phase 4] v2 committed to printk for-7.3-hotfix; no NAKs
- [Phase 4] lore stable search: no results
- [Phase 5] callers: sysrq-b, kdb_reboot, panic, watchdogs, hangcheck, ocfs2, amdgpu RAS, smartpqi, hw-protection
- [Phase 5] sysrq reboot in this tree is sysrq-b, not sysrq-o
- [Phase 6] v6.18.57 CON_NBCON drivers: pl011, imx, sifive, tegra-utc, drm_log; 8250 not NBCON (d353934702 not ancestor)
- [Phase 6] v6.18.57 has nbcon_cpu_emergency_enter and printk_trigger_flush declarations
- [Phase 8] Failure mode: lost last console lines on emergency restart; severity MEDIUM; reboot still happens
- UNVERIFIED: WebFetch lore 403 (worked around with b4/curl)
- UNVERIFIED: semcode MCP not available (used git grep / file reads)
The patch is small, obviously correct, and closes a real console-flush hole that 6.18 NBCON serial consoles already have.
**YES**
kernel/reboot.c | 9 +++++++++ 1 file changed, 9 insertions(+)
kernel/reboot.c +9 -0
@@ -8,6 +8,7 @@#define pr_fmt (fmt) "reboot: " fmt#include <linux/atomic.h> +#include <linux/console.h> #include <linux/ctype.h> #include <linux/export.h> #include <linux/kexec.h>
@@ -94,6 +95,14 @@ void emergency_restart(void) {kmsg_dump (KMSG_DUMP_EMERG ); system_state =SYSTEM_RESTART ; + +/* +* NBCON kthreads won't be flushed and stopped properly in +* the emergency restart. Move them to the atomic mode. +*/ +nbcon_cpu_emergency_enter (); +printk_trigger_flush (); +machine_emergency_restart (); }EXPORT_SYMBOL_GPL (emergency_restart);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/realtek: Add quirk for Lenovo ThinkBook 16p Gen 3 ARH (21EK)
In reply to Sasha LevinFrom: KIM MinWoo <[email protected]>
[ Upstream commit 3867e38b2d4b844d89076f988c7b9741c87a9858 ]
The ThinkBook 16p Gen 3 ARH (SSID 17aa:3871) has a TI TAS2563 amplifier device on I2C, exposed by ACPI as INT8866, the same arrangement as the Yoga 7 14ARB7 (SSID 17aa:3870). Without a quirk, the codec falls back to the vendor-wide Lenovo quirk (ALC269_FIXUP_LENOVO_XPAD_ACPI), the amplifier is never bound, and the internal speakers stay silent while the headphone output works.
Reuse the Yoga 7 14ARB7 fixup, which binds the INT8866 device as a side codec. ALC287_FIXUP_TAS2781_I2C does not work on this machine because it looks for a TIAS2781 device.
---
LLM Generated explanations, may be completely bogus:
This is a one-line Realtek HDA quirk for ThinkBook 16p Gen 3 ARH. The Yoga 7 INT8866 fixup already exists in this 6.18.57 tree; without the new SSID the machine falls through to the Lenovo vendor quirk and internal speakers stay silent.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ALSA hda/realtek] [Add] [PCI/codec SSID quirk for Lenovo ThinkBook 16p Gen 3 ARH (21EK), SSID 17aa:3871]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Assisted-by: LLM
- Signed-off-by: KIM MinWoo <[email protected]> (author)
- Link:
https://patch.msgid.link/[email protected]
- Signed-off-by: Takashi Iwai <[email protected]> (ALSA maintainer; applied the patch)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Cc:
stable (absence expected)
- Ignore: [ Upstream commit 3867e38b2d4b844d89076f988c7b9741c87a9858 ] and Signed-off-by: Sasha Levin (pipeline markers)
Notable: ALSA maintainer SOB; hardware-tested in the mailing-list cover (see Phase 4). LLM assistance is disclosed; maintainer still applied it.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: ThinkBook 16p Gen 3 ARH (SSID 17aa:3871) has a TI TAS2563 amp on I2C, ACPI HID INT8866 — same as Yoga 7 14ARB7 (17aa:3870).
- Symptom: internal speakers silent; headphone jack works.
- Root cause: no machine-specific quirk, so the codec falls back to vendor-wide ALC269_FIXUP_LENOVO_XPAD_ACPI; the amp is never bound.
- Fix: reuse ALC287_FIXUP_YOGA7_14ARB7_I2C (binds INT8866 as a side codec). ALC287_FIXUP_TAS2781_I2C is the wrong HID (TIAS2781).
- Version info: none in the commit body; author tested on 7.2.6-arch2-1 (BIOS KCCN40WW) per mailing-list text.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Explicit hardware quirk for silent speakers. Classic stable exception (quirks/workarounds).
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: sound/hda/codecs/realtek/alc269.c (+1 / −0)
- Function/table: alc269_fixup_tbl[]
- One SND_PCI_QUIRK(0x17aa, 0x3871, "Lenovo ThinkBook 16p Gen 3 ARH", ALC287_FIXUP_YOGA7_14ARB7_I2C) next to the existing 0x3870 Yoga 7 entry
- Scope: single-file surgical quirk addition
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Before: 17aa:3871 is unmatched in alc269_fixup_tbl. snd_hda_pick_fixup() then hits alc269_fixup_vendor_tbl SND_PCI_QUIRK_VENDOR(0x17aa, ..., ALC269_FIXUP_LENOVO_XPAD_ACPI). That only runs alc_fixup_ideapad_acpi + ThinkPad ACPI; it does not bind INT8866. Speakers stay silent.
- After: 17aa:3871 selects ALC287_FIXUP_YOGA7_14ARB7_I2C → yoga7_14arb7_fixup_i2c() → comp_generic_fixup(..., "i2c", "INT8866", ...). Chained to ALC285_FIXUP_THINKPAD_HEADSET_JACK.
- Path: probe/init only, one SSID.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: [Hardware workaround / missing quirk]
Mechanism: companion TAS2563 never bound without a matching SSID. Fix reuses the existing INT8866 bind path. Confirmed:ALC287_FIXUP_TAS2781_I2C uses tas2781_fixup_tias_i2c() → HID TIAS2781; this machine is INT8866.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: one table entry, existing fixup, adjacent to 17aa:3870.
- Minimal; no API/structure change.
- Regression risk very low: only SSID 17aa:3871. No other 0x3871 quirk in this file. Distinct from ThinkBook 16P 17aa:38a9/38ab (CS35L41).
- Caveat (not a kernel regression): author notes TAS2XXX3871.bin is not in linux-firmware; speakers worked after symlink to Yoga TAS2XXX3870.bin. The quirk is still required for component bind; firmware is a separate userspace/linux-firmware issue.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Neighbor 17aa:3870 Yoga 7 14ARB7: present since b5cb53fd32779 (“ALSA: hda/tas2781: add fixup for Lenovo 14ARB7”, 2024-01-02, in v6.8-rc2 era).
- Fixup ALC287_FIXUP_YOGA7_14ARB7_I2C / yoga7_14arb7_fixup_i2c() present in this tree (moved into alc269.c by aeeb85f26c3bb, 2025-07).
- 3871 line is the candidate itself. Bug is missing table entry, not bad logic, and has existed since the Yoga 7 path landed.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Expected. Buggy “code” is the vendor fallback for unmatched Lenovo SSIDs, which is in this tree at alc269_fixup_vendor_tbl.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES** Record:
- Yoga 7 14ARB7 quirk is already here (SND_PCI_QUIRK(0x17aa, 0x3870, ...)).
- TAS2781 I2C side codec with INT8866 ACPI ID is already here (tas2781_hda_i2c.c).
- Standalone one-liner; not part of a numbered series.
- Recent alc269.c history is other machine quirks; no prerequisite refactor needed on this tree.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Only this commit under --author="KIM MinWoo" in sound/. Not the subsystem maintainer. Applied by Takashi Iwai (ALSA maintainer). Recipients included TI TAS2781 contact Shenghao Ding.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Record:
- Needs ALC287_FIXUP_YOGA7_14ARB7_I2C, yoga7_14arb7_fixup_i2c(), comp_generic_fixup(), and INT8866 in snd_hda_scodec_tas2781_i2c. All present in v6.18.57.
- git merge-base --is-ancestor b5cb53fd32779 v6.18.57 → yes.
- Can apply standalone. No series dependency.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 3867e38b2d4b844d89076f988c7b9741c87a9858 →
https://patch.msgid.link/[email protected]
- b4 dig -a: single v1 series; no later revision.
- Thread (mbox): author tested on hardware. Without patch: `ALC287:
picked fixup for PCI SSID 17aa:0000. With patch: picked fixup for codec SSID 17aa:3871 and bound i2c-INT8866:00 (ops tas2781_hda_comp_ops)`. Wrong TAS2781 fixup left component “not bound”. Headphones, mics, mute/volume keys still worked.
- Takashi Iwai 2026-09-28: “Applied now. Thanks.” No NAK, no stable discussion.
- Author cites Fang Junhua alsa-devel 2026-03-04:
“[ALSA][ALC287][TAS2781] Lenovo 21EK speakers silent on Linux, headphones work”, codec dump SSID 17aa:3871. Original Fang mail not independently fetched (lore HTTP 403).
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): KIM MinWoo; [email protected]; [email protected]; [email protected]; [email protected]. Right lists and maintainers. Applied by Takashi Iwai; no separate Reviewed-by.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: Cover letter is the primary report (silent speakers, kernel logs, TAS2781-I2C mismatch). Second user (Fang Junhua, machine type 21EK) cited; that lore fetch is UNVERIFIED beyond the cover letter. Symptom matches.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone v1. Reuses Yoga 7 14ARB7 fixup already in this tree. Not the Yoga Pro 9 16IMH9 TAS2781 PCI/codec collision (different SSID).
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: UNVERIFIED (lore.kernel.org/stable HTTP 403). Thread itself has no stable nomination or rejection.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: No function body change. Adds a row in alc269_fixup_tbl[]. Runtime path: snd_hda_pick_fixup() → ALC287_FIXUP_YOGA7_14ARB7_I2C → yoga7_14arb7_fixup_i2c() → comp_generic_fixup() / hda_component_manager_init().
**Step 5.2: TRACE CALLERS**
Record:
- alc269_probe-style init calls snd_hda_pick_fixup(codec, alc269_fixup_models, alc269_fixup_tbl, alc269_fixups) then vendor table if unmatched (alc269.c ~8557–8572).
- Probe/enumeration, not IRQ/hot path.
- Impact: only SSID 17aa:3871. snd_hda_pick_fixup() matches PCI SSID first, then codec SSID (auto_parser.c 1066–1087). Author’s PCI SSID 17aa:0000 still matches via codec SSID 17aa:3871.
**Step 5.3: TRACE CALLEES**
Record: yoga7_14arb7_fixup_i2c → comp_generic_fixup(..., "INT8866") → hda_component_manager_init. TAS2781 I2C driver matches ACPI {"INT8866", 0} and treats it as HDA_TAS2563.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: User-reachable on this laptop at codec probe (boot / module load). Unprivileged users get silent speakers, not a crash. Headset path already works.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same table is full of Lenovo SND_PCI_QUIRK / HDA_CODEC_QUIRK amp-bind entries. 17aa:3870 is the sibling. TAS2781-I2C entries use TIAS2781; this machine must not use those.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- Local tree: VERSION 6.18.57, git describe HEAD = v6.18.57-155-gcdf239ca885b2.
- make kernelversion = 6.18.57.
- In **v6.18.57** (without this candidate): 17aa:3870 Yoga 7 entry exists; **17aa:3871 does not**. Vendor Lenovo XPAD fallback exists. INT8866 TAS2563 side-codec exists.
- git merge-base --is-ancestor 2a2ad57597a9e v6.18.57 → not an ancestor (candidate is not in the 6.18.57 baseline).
- Bug exists here: unmatched 17aa:3871 → silent speakers.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply. File path sound/hda/codecs/realtek/alc269.c already used (HDA split aeeb85f26c3bb is in v6.18.57). Context around 3870 matches. Expected difficulty: clean apply.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: Yoga 7 14ARB7 (3870) is here. No other 3871 quirk. ThinkBook 16P 38a9/38ab is a different SSID/amp (CS35L41). No substitute fix for 21EK.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: [sound/hda Realtek codec quirks] [IMPORTANT] — common laptop audio, machine-specific. Not core mm/fs, but silent internal speakers is a real user-facing bug.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: High activity; alc269.c regularly gets SSID quirks. Mature table, well-understood pattern. Takashi Iwai maintains ALSA.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver/platform-specific: Lenovo ThinkBook 16p Gen 3 ARH (21EK), SSID 17aa:3871. CONFIG_SND_HDA_CODEC_REALTEK plus TAS2781 I2C side codec (already used for Yoga 7 14ARB7).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Every boot on that machine. Not a race. Not unprivileged- exploit. Author plus cited 21EK report.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Internal speakers silent (headphones work). Severity MEDIUM–HIGH for those users (device unusable for speaker audio), not panic/corruption. Standard stable quirk class.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: high for 21EK owners on 6.18.y; existing fixup already shipped for Yoga 7.
- Risk: very low (1 line, SSID-scoped, maintainer-applied, hardware- tested).
- Ratio: strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real hardware bug: silent internal speakers on ThinkBook 16p Gen 3 ARH.
- Hardware quirk exception in stable rules.
- 1-line reuse of fixup already in v6.18.57.
- Yoga 7 14ARB7 / INT8866 / TAS2563 path already present.
- Author kernel logs; ALSA maintainer applied v1; TI TAS2781 list CC’d.
- Applies cleanly; no new API/driver.
AGAINST:
- Affects one laptop SSID, not all users.
- TAS2XXX3871.bin may still be missing from linux-firmware (author used 3870 symlink). Does not make the quirk wrong or unsafe.
- Author is not the maintainer; LLM-assisted. Offset by hardware test and maintainer apply.
UNRESOLVED:
- Fang Junhua lore thread not independently fetched (403).
- No stable@ discussion found (lore 403).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? [PASS — 1-line table add; tested on 21EK; maintainer applied]
2. Fixes a real bug that affects users? [PASS — silent speakers]
3. Important issue? [PASS — hardware workaround / silent speakers; stable quirk exception]
4. Small and contained? [PASS — +1 line, one file]
5. No new features or APIs? [PASS — existing fixup, new SSID only]
6. Can apply to the local tree? [PASS — v6.18.57 has the file, fixup, and INT8866 driver]
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Hardware quirk/workaround (HDA SND_PCI_QUIRK). Qualifies automatically when the driver/fixup already exist.
**Step 9.4: MAKE YOUR DECISION**
Backport. The v6.18.57 tree already has the Yoga 7 INT8866 fixup and TAS2563 side codec; it lacks only SSID 17aa:3871, so this machine hits the Lenovo vendor fallback and never binds the amp. One matching table line is the correct, low-risk stable fix.
Verification:
- [Phase 1] Parsed tags: author SOB, Link to msgid, Takashi Iwai SOB; no Fixes/Cc:stable (expected)
- [Phase 2] Diff: +1 SND_PCI_QUIRK(0x17aa, 0x3871, ..., ALC287_FIXUP_YOGA7_14ARB7_I2C) in alc269_fixup_tbl
- [Phase 2] ALC287_FIXUP_TAS2781_I2C → tas2781_fixup_tias_i2c() HID TIAS2781; Yoga fixup HID INT8866 — mismatch confirmed in code
- [Phase 2] Vendor fallback SND_PCI_QUIRK_VENDOR(0x17aa, ..., ALC269_FIXUP_LENOVO_XPAD_ACPI) confirmed at alc269.c:7739
- [Phase 3] git describe HEAD / make kernelversion:
v6.18.57-155-gcdf239ca885b2 / 6.18.57
- [Phase 3] git merge-base --is-ancestor 2a2ad57597a9e v6.18.57: not in 6.18.57 baseline
- [Phase 3] v6.18.57 has 17aa:3870 and ALC287_FIXUP_YOGA7_14ARB7_I2C; does not have 17aa:3871
- [Phase 3] Yoga 7 fixup from b5cb53fd32779 (2024-01-02) is ancestor of v6.18.57
- [Phase 3] INT8866 in tas2781_hda_i2c.c present in v6.18.57 (ACPI match + HDA_TAS2563)
- [Phase 4] b4 dig -c 3867e38b2d4b...: lore msgid [email protected]
- [Phase 4] b4 dig -a: v1 only; b4 dig -w: linux-sound, tiwai, perex, [email protected]
- [Phase 4] mbox: hardware logs; Takashi “Applied now”; Fang Junhua 21EK citation
- [Phase 4] lore.kernel.org WebFetch 403 — stable@ search UNVERIFIED
- [Phase 5] snd_hda_pick_fixup() PCI then codec SSID; 17aa:0000 PCI still matches codec 17aa:3871
- [Phase 6] Clean apply on this tree’s alc269.c path; no 3871 collision
- [Phase 8] Failure: silent internal speakers on 21EK; not crash; quirk- scoped
- UNVERIFIED: Fang Junhua original mail body; linux-firmware TAS2XXX3871.bin status; stable@ archive
The patch is a one-line SSID quirk, reuses a fixup this tree already ships, and restores speaker amp bind on a real Lenovo model with maintainer ack.
**YES**
sound/hda/codecs/realtek/alc269.c | 1 + 1 file changed, 1 insertion(+)
sound/hda/codecs/realtek/alc269.c +1 -0
@@ -7527,6 +7527,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {HDA_CODEC_QUIRK (0x17aa ,0x38a7 ,"Legion Pro 7 16ARX8H" ,ALC287_FIXUP_TAS2781_I2C ),/* this must match before PCI SSID 17aa:386f below */ SND_PCI_QUIRK (0x17aa ,0x386f ,"Legion Pro 7i 16IAX7" ,ALC287_FIXUP_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x17aa ,0x3870 ,"Lenovo Yoga 7 14ARB7" ,ALC287_FIXUP_YOGA7_14ARB7_I2C ), +SND_PCI_QUIRK (0x17aa ,0x3871 ,"Lenovo ThinkBook 16p Gen 3 ARH" ,ALC287_FIXUP_YOGA7_14ARB7_I2C ),SND_PCI_QUIRK (0x17aa ,0x3874 ,"Legion 7i 16IAX7" ,ALC287_FIXUP_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x17aa ,0x3877 ,"Lenovo Legion 7 Slim 16ARHA7" ,ALC287_FIXUP_CS35L41_I2C_2 ), SND_PCI_QUIRK(0x17aa, 0x3878, "Lenovo Legion 7 Slim 16ARHA7", ALC287_FIXUP_CS35L41_I2C_2),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 net/rds: hold the socket while an rds_mr references it
In reply to Sasha LevinFrom: Håkon Bugge <[email protected]>
[ Upstream commit 9079adef042c1e7a6141dcdfd3041acd30607297 ]
Each rds_mr stores a bare back pointer to the socket that created it (mr->r_sock) but takes no reference on it. When the mr is destroyed it references the rs. Hence, provisions must be made to avoid the rs being destroyed before all mrs referencing it have been destroyed.
The MR itself is refcounted, and in-flight messages legitimately hold MR krefs that can outlive the socket: rds_release() drops the rb-tree references via rds_rdma_drop_keys(), but a send completion arriving afterwards drops the final message reference from the CQ handler and ends up in
rds_message_purge()
__rds_put_mr_final()
rds_destroy_mr() -> takes rs->rs_rdma_lockdereferencing a socket that may already have been freed.
Oracle UEK fixed the same use-after-free ("rds: Add proper refcnt when an RDS MR references an RDS Socket") after seeing crashes of the form:
PF: supervisor write access in kernel mode
_raw_spin_lock_irqsave+0x4a/0x6a __rds_put_mr_final+0x2c/0xe0 [rds] rds_message_purge+0x13c/0x150 [rds] rds_message_put+0x39/0x54 [rds] rds_ib_send_cqe_handler+0x147/0x3dd [rds_rdma]
To fix this, take a socket reference when an MR is created and drop it when the final MR kref goes away. The reference cycle is broken by rds_release(), which always runs rds_rdma_drop_keys() on close. So the socket reference held by an MR never prevents release, it only delays sk_free() until the last MR user is done.
The hold sits next to kref_init() at both allocation sites - __rds_rdma_map() and the on-demand-paging path in rds_cmsg_rdma_args() - so every MR owns exactly one socket reference from the moment it becomes kref-managed. For that to work on the ODP path, its get_mr() error handling is converted from a bare kfree() to kref_put(..., __rds_put_mr_final), with r_trans_private cleared first since it holds an ERR_PTR there; both sites then tear down through the same path and a future error-path change cannot silently leak or double-drop the reference.
[achender: port to net-next (sock_hold/sock_put in place of the UEK
rds_sock_addref/rds_sock_put helpers); also balance the reference on the rds_cmsg_rdma_args() ODP path and unify its error path with __rds_put_mr_final(); update commit message]
---
LLM Generated explanations, may be completely bogus:
This is a use-after-free in RDS MR teardown. The buggy path is in this 5.10 tree, the fix is small, and it should be backported.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[net/rds] [hold] hold the socket while an rds_mr references it**
- Subsystem: net/rds
- Action verb: “hold” (keep a missing reference so the socket outlives the MR)
- Claimed intent: an rds_mr keeps a counted socket reference for its lifetime
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record (from the candidate / merged 9079adef042c):
- **Fixes:** absent in the git commit. The v4 mailing-list post had Fixes: eff5f53bef75 ("RDS: RDMA support"). Absence in git is expected here and is not a negative.
- **Reported-by:** none. The body cites an Oracle UEK production crash.
- **Tested-by:** none
- **Reviewed-by / Acked-by:** none on the commit
- **Link:** https://patch.msgid.link/20260730041629.3512480-3- [email protected]
- **Cc: stable:** absent (expected)
- **Signed-off-by:** Håkon Bugge (Oracle, original); Allison Henderson (RDS, port); Jakub Kicinski (net maintainer, merge)
- Notable: Allison’s trailer says this is a UEK port (sock_hold/sock_put instead of UEK rds_sock_addref/rds_sock_put). This tree already has those helpers as thin wrappers around sock_hold/sock_put.
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** mr->r_sock is a bare back-pointer. rds_destroy_mr() takes rs->rs_rdma_lock after the socket may already be freed.
- **Symptom:** kernel oops: PF: supervisor write access in _raw_spin_lock_irqsave from __rds_put_mr_final ← rds_message_purge ← rds_message_put ← rds_ib_send_cqe_handler.
- **Root cause:** rds_release() drops rb-tree MR refs via rds_rdma_drop_keys(), but in-flight send completions still hold MR krefs. The CQ/tasklet path then destroys the MR against a freed socket.
- **Version info:** none beyond “Oracle UEK saw this.” The mechanism is as old as RDS RDMA (2009).
- **Fix:** sock_hold() at both MR alloc sites next to kref_init(); sock_put() in __rds_put_mr_final(). Cycle is broken because rds_release() always runs rds_rdma_drop_keys(), so the MR ref only delays sk_free(), it does not block release.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not disguised. Explicit UAF fix with a crash stack. The ODP kfree → kref_put change is part of making the hold/put pairing correct on the error path.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- net/rds/rdma.c: +13 / −1 (functional)
- net/rds/rds.h: +4 / −1 (comment on r_sock)
- **Functions:** __rds_put_mr_final(), __rds_rdma_map(), rds_cmsg_rdma_args()
- **Scope:** single-subsystem, surgical (~17 lines)
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- **__rds_put_mr_final:** after rds_destroy_mr(mr), add sock_put(rds_rs_to_sk(mr->r_sock)) before kfree(mr).
- **__rds_rdma_map:** after mr->r_sock = rs, add sock_hold(). This tree already kref_puts mr on every out: path (success and error), so the hold is paired.
- **ODP path in rds_cmsg_rdma_args:** sock_hold() next to kref_init(). On get_mr() failure, clear r_trans_private (it is an ERR_PTR) and kref_put(..., __rds_put_mr_final) instead of a bare kfree, so free_mr() is not called with an error pointer and the socket ref is dropped.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- **Category:** use-after-free / missing reference count
- **Mechanism:** MR outlives socket; destructor uses rs->rs_rdma_lock. Fix is one sock_hold per kref-managed MR, one sock_put on final kref.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: classic missing get/put; both alloc sites covered (only two kref_init of rds_mr in net/rds/).
- __rds_rdma_map already uses kref_put on out:; ODP error path is converted to the same destructor.
- Regression risk is low. sock_put from the send tasklet is already done in rds_message_purge() for rm->m_rs. rds_sock_destruct() is only a WARN_ON on an empty list.
- No API or data-structure layout change beyond a comment.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- mr->r_sock = rs and rds_destroy_mr() using that pointer:
eff5f53bef75 (“RDS: RDMA support”), 2009-02-26. Present in 5.10.
- __rds_put_mr_final / kref_init: e228a5d05e9ee (2020-04-09), in this tree.
- ODP alloc in rds_cmsg_rdma_args: 2eafa1746f178 (2020-01-18), in this tree.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: on the git commit. Mailing-list tag eff5f53bef75 **is** an ancestor of HEAD (git merge-base --is-ancestor exit 0). Merged mainline SHA 9079adef042c is **not** an ancestor of this tree (exit 1). No later sock-hold-on-MR commit exists in this tree.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- 91a44b406bc1f (“net: rds: fix MR cleanup on copy error”) is already here; it only stops double-free of pages/sg on put_user failure. It does not hold the socket.
- 2fabef4f65b46 (“Fix MR reference counting problem”) is about rds_free_mr() bypassing kref, not socket lifetime.
- This patch is standalone vs those.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Håkon Bugge has multiple RDS commits in this history. Allison Henderson is the RDS maintainer and ported the UEK fix. The original crash was seen in Oracle production.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: Submitted as **v4 2/4**. Siblings:
1. d100966325f7 — don’t unpin_user_pages_dirty_lock() from atomic context
3. message leak in rds_send_xmit() drop path
4. unpin MR pages with unpin_user_pages_dirty_lock() Those are separate bugs. This diff only needs sock_hold/sock_put, kref_put, and __rds_put_mr_final, all present here. **Can apply standalone.**
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 9079adef042c: v4 2/4,
https://patch.msgid.link/[email protected]
- Revisions: v1 (2026-07-10), v2, v3 (ODP hold after successful get_mr), v4 (hold next to kref_init, error path via __rds_put_mr_final) — applied version is v4.
- Cover letter: explicit UAF of the RDS socket through long-lived MR refs; UEK port https://github.com/oracle/linux-uek/commit/94549e4732d8
- No NAK found on this patch. Jakub applied the series to net-next on 2026-08-04 (9079adef042c).
- v4 changelog: ODP ref moved next to kref_init so both alloc sites share one ownership rule.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): netdev, linux-rdma, Paolo Abeni, Eric Dumazet, Jakub Kicinski, Simon Horman, John Hubbard, Leon Romanovsky. Applied by the net maintainer. No NAK located.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla link. Evidence is the UEK oops in the commit message, matching this tree’s call chain (rds_ib_tasklet_fn_send → rds_ib_send_cqe_handler → rds_message_put → rds_message_purge → __rds_put_mr_final).
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: 4 independent RDS bug-fix ports. This one does not need 1/3/4.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: **UNVERIFIED** — lore.kernel.org/stable fetch returned 403. No local evidence this was rejected for 5.10.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: __rds_put_mr_final, __rds_rdma_map, rds_cmsg_rdma_args (plus rds_destroy_mr as callee).
Step 5.2: TRACE CALLERS
Record:
- __rds_put_mr_final: kref_put from rds_rdma_drop_keys, rds_free_mr, rds_rdma_unuse, rds_rdma_free_op (ODP), rds_message_purge (op_rdma_mr / atomic MR), and __rds_rdma_map out:.
- __rds_rdma_map: rds_get_mr, rds_get_mr_for_dest, rds_cmsg_rdma_map (sendmsg cmsg). Userspace RDMA registration.
- rds_cmsg_rdma_args: rds_sendmsg path for RDS_CMSG_RDMA_ARGS.
Step 5.3: TRACE CALLEES
Record: rds_destroy_mr → spin_lock_irqsave(&rs->rs_rdma_lock) (the UAF); free_mr(); sock_hold/sock_put.
Step 5.4: FOLLOW THE CALL CHAIN
Record: Userspace maps an MR or sends RDMA, then closes the socket while a send is in flight. Completions run in rds_ib_tasklet_fn_send (softirq). Reachable from AF_RDS sockets with CONFIG_RDS + CONFIG_RDS_RDMA (InfiniBand). Typical Oracle RAC / IB RDS workload.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Only two kref_init sites for struct rds_mr. Both patched. rds_cmsg_rdma_dest only kref_gets an existing tree MR.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: **Yes.**
- Tree: pending-5.10, 5.10.270 (p-5.10-1-gce56b7a73b64b)
- net/rds/rdma.c: mr->r_sock = rs with no sock_hold (lines 243–246 and 735–738)
- __rds_put_mr_final has no sock_put (115–121)
- rds_release() still does rds_rdma_drop_keys() then sock_put(sk) (af_rds.c)
- Introduced 2009; ODP path 2020. Both in 5.10.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **Minor context only.** Mainline uses kzalloc_obj / kzalloc_objs; this tree uses kzalloc / kcalloc. The hold/put lines sit on identical kref_init / mr->r_sock / ODP get_mr error code. Local ODP error uses ret = IS_ERR(...) then overwrites with -EOPNOTSUPP; the patch uses PTR_ERR then the same overwrite. Semantic apply is straightforward.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No socket-hold-on-MR fix. 91a44b406bc1f is a different MR cleanup bug.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: **net/rds** — IMPORTANT, not core. RDS over IB is production for Oracle RAC and similar clusters. UAF is still a kernel oops for those users.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mature (2009). Occasional stable fixes in this tree (91a44b406bc1f in 2026). Not a new subsystem.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: **config/driver-specific:** CONFIG_RDS + RDMA (CONFIG_RDS_RDMA). Not all 5.10 boxes, but all RDS/IB RDMA users who close a socket with in-flight MRs.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Map MR or send RDMA, close socket before CQ completion. Timing- dependent but realistic (UEK crash). Needs an RDS socket; typical RDS users are cluster services.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: **Use-after-free → oops on spinlock of freed rds_sock.** Severity **CRITICAL/HIGH**. Same class as KASAN UAF; crash stack is real.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit:** high for RDS/IB — prevents a known UAF oops.
- **Risk:** low — ~17 lines, standard sock_hold/sock_put, both alloc sites, error path unified.
- **Ratio:** strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
**FOR:**
- Real UAF with production oops (Oracle UEK).
- Same call path exists in this 5.10 tree.
- Bug dates to 2009 RDMA support; ODP path also here.
- Small, obviously correct refcount fix; v4 review then net-maintainer merge.
- Standalone vs the rest of the series.
- __rds_rdma_map already drops the MR via kref_put on all exits, so the new hold is balanced.
**AGAINST:**
- RDS/IB is not universal.
- Patch was 2/4 of a series (siblings are independent).
- Minor kzalloc_obj vs kzalloc context when applying.
**UNRESOLVED:**
- Stable-list discussion (lore 403).
- No public syzbot repro (crash is still documented).
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — hold at kref_init, put in finalizer; merged to net-next; UEK precedent.
2. Fixes a real bug that affects users? **PASS** — production oops.
3. Important issue? **PASS** — UAF / kernel oops, HIGH/CRITICAL.
4. Small and contained? **PASS** — 2 files, ~17 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 device-ID/quirk/DT/build/docs exception. Ordinary memory- safety fix.
Step 9.4: MAKE YOUR DECISION
This 5.10 tree has the bare r_sock pointer, the CQ/tasklet free path, and no socket hold on MRs. The fix is the missing refcount. It should be backported.
===============================================================
What this solves for stable users
===============================================================
Closing an RDS socket while an RDMA MR is still referenced by an in- flight send can free rds_sock before __rds_put_mr_final → rds_destroy_mr takes rs->rs_rdma_lock. That is an oops. Holding the socket until the last MR kref drops keeps the lock valid; rds_rdma_drop_keys() in rds_release() still breaks the tree↔socket cycle.
Risk vs benefit: high benefit for RDS/IB, low regression risk. sock_put from this tasklet is already used for rm->m_rs. Backport may need trivial context adjustment (kzalloc vs kzalloc_obj); no missing helpers or types.
Verification:
- [Phase 1] Tags: Link msgid 20260730041629.3512480-3; SOB Bugge / Henderson / Kicinski; no Fixes in git; ML had Fixes: eff5f53bef75
- [Phase 2] Diff: sock_put in __rds_put_mr_final; sock_hold in __rds_rdma_map and ODP alloc; ODP error kfree → kref_put after NULL-out of ERR_PTR
- [Phase 2] Local __rds_rdma_map out: already kref_puts if mr non-NULL (rdma.c 348–351)
- [Phase 3] git blame: r_sock / rds_destroy_mr from eff5f53bef75 (2009); kref from e228a5d05e9ee (2020)
- [Phase 3] git merge-base --is-ancestor eff5f53bef75c0 HEAD → 0; 2eafa1746f178 → 0; 9079adef042c → 1 (not in this tree)
- [Phase 3] git describe HEAD / make kernelversion: pending-5.10, 5.10.270
- [Phase 3] Only two kref_init(&...r_kref) sites in net/rds/
- [Phase 4] b4 dig -c 9079adef042c: v4 2/4; recipients netdev/rdma/Kicinski/Dumazet/Abeni/Horman
- [Phase 4] b4 dig -a: v1→v4; v4 unifies ODP error path
- [Phase 4] Cover letter: UEK UAF port; applied as 9079adef042c
- [Phase 4] UNVERIFIED: stable@ thread (403)
- [Phase 5] Call chain confirmed: rds_ib_tasklet_fn_send → rds_ib_send_cqe_handler → rds_message_put → rds_message_purge → __rds_put_mr_final
- [Phase 5] rds_release calls rds_rdma_drop_keys then sock_put (af_rds.c 78, 89)
- [Phase 6] Local rdma.c has no sock_hold/sock_put; comment still says “back pointer”
- [Phase 8] Failure mode: UAF oops on rs_rdma_lock, HIGH/CRITICAL
- UNVERIFIED: whether an unprivileged process can open AF_RDS on a given distro; crash still confirmed for RDS/IB users
**YES**
net/rds/rdma.c | 14 +++++++++++++- net/rds/rds.h | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-)
net/rds/rdma.c +13 -1
@@ -117,6 +117,7 @@ void __rds_put_mr_final(struct kref *kref) struct rds_mr *mr = container_of(kref, struct rds_mr, r_kref);rds_destroy_mr (mr); +sock_put (rds_rs_to_sk (mr->r_sock));kfree (mr); }
@@ -243,7 +244,11 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,kref_init (&mr->r_kref);RB_CLEAR_NODE (&mr->r_rb_node); mr->r_trans = rs->rs_transport; +/* The MR can outlive its socket: a socket reference is held +* until the final kref is dropped in __rds_put_mr_final(). +*/ mr->r_sock = rs; +sock_hold (rds_rs_to_sk (rs));if (args->flags &RDS_RDMA_USE_ONCE ) mr->r_use_once =1 ;
@@ -762,7 +767,12 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm,RB_CLEAR_NODE (&local_odp_mr->r_rb_node);kref_init (&local_odp_mr->r_kref); local_odp_mr->r_trans = rs->rs_transport; +/* The MR can outlive its socket: a socket +* reference is held until the final kref is +* dropped in __rds_put_mr_final(). +*/ local_odp_mr->r_sock = rs; +sock_hold (rds_rs_to_sk (rs)); local_odp_mr->r_trans_private = rs->rs_transport->get_mr( NULL, 0, rs, &local_odp_mr->r_key, NULL,
@@ -771,7 +781,9 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm, ret =PTR_ERR (local_odp_mr->r_trans_private);rdsdebug ("get_mr ret %d %p\"" , ret, local_odp_mr->r_trans_private); -kfree (local_odp_mr); + local_odp_mr->r_trans_private =NULL ; +kref_put (&local_odp_mr->r_kref, + __rds_put_mr_final); ret = -EOPNOTSUPP ; goto out_pages; }
net/rds/rds.h +4 -1
@@ -299,7 +299,10 @@ struct rds_mr { unsigned int r_invalidate:1; unsigned int r_write:1; -struct rds_sock *r_sock;/* back pointer to the socket that owns us */ +struct rds_sock *r_sock;/* socket that owns us; counted +* reference, dropped by +* __rds_put_mr_final() +*/ struct rds_transport *r_trans;void *r_trans_private; };
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] net/rds: hold the socket while an rds_mr references it
Sashiko has reviewed this patch and found no issues.
Quoted 15 lines
From: Håkon Bugge <[email protected]>
[ Upstream commit
9079adef042c1e7a6141dcdfd3041acd30607297]Each
rds_mrstores a bare back pointer to the socket that created it (mr->r_sock) but takes no reference on it. When the mr is destroyed it references the rs. Hence, provisions must be made to avoid the rs being destroyed before all mrs referencing it have been destroyed.The MR itself is refcounted, and in-flight messages legitimately hold MR krefs that can outlive the socket:
rds_release()drops the rb-tree references viards_rdma_drop_keys(), but a send completion arriving afterwards drops the final message reference from the CQ handler and ends up in
Quoted 6 lines
[ ... ]
__rds_put_mr_final(); update commit message]Signed-off-by Allison Henderson <[email protected]>Signed-off-by Jakub Kicinski <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 ksmbd: reject SMB3.1.1 binding with mismatched cipher
In reply to Sasha LevinFrom: Namjae Jeon <[email protected]>
[ Upstream commit 7019a11f79dc408f2b47b1027240e7f198784c9a ]
SMB3.1.1 multichannel connections belonging to the same session must use the same negotiated encryption cipher.
ksmbd validates the dialect and client GUID during session binding, but does not compare the cipher negotiated by the new connection with the cipher used by the existing session channels. This allows a channel negotiated with AES-128-CCM to bind to a session using AES-128-GCM.
Compare the new connection's cipher with an existing session channel and return STATUS_INVALID_PARAMETER when they differ.
This fixes smb2.session.bind_negative_smb3encGtoCs.
---
LLM Generated explanations, may be completely bogus:
## Local tree
This checkout is **6.12.111** (pending-6.12, git describe = p-6.12-3-gc504cf0baa3d8). The verdict is only for this tree.
Upstream commit analyzed: 7019a11f79dc408f2b47b1027240e7f198784c9a (not in this tree). git apply --check of that diff against local fs/smb/server/smb2pdu.c succeeds.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: Subject**
Record: [ksmbd] [reject] SMB3.1.1 session binding must not succeed when the new connection negotiated a different encryption cipher
**Step 1.2: Tags**
Record:
- Signed-off-by: Namjae Jeon <[email protected]> (author and 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 path and is not treated as a negative signal
**Step 1.3: Body**
Record:
- Bug: SMB3.1.1 multichannel session binding checks dialect and client GUID, but not cipher. A connection that negotiated AES-128-CCM can bind to a session whose existing channel uses AES-128-GCM.
- Symptom: invalid bind is accepted; smbtorture smb2.session.bind_negative_smb3encGtoCs fails (expects STATUS_INVALID_PARAMETER).
- Root cause: missing comparison of conn->cipher_type against an existing session channel.
- Fix: under sess->chann_lock, compare ciphers and return -EINVAL → STATUS_INVALID_PARAMETER.
- No kernel-version range in the message.
**Step 1.4: Hidden bug fix?**
Record: Not hidden. Explicit protocol-validation fix for encryption- cipher mismatch on bind.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: Inventory**
Record:
- File: fs/smb/server/smb2pdu.c only (+15 lines)
- Function: smb2_sess_setup()
- Scope: single-file surgical insertion in the existing SMB 3.x multichannel binding branch, immediately after the dialect check
**Step 2.2: Code flow**
Record:
- Before: after conn->dialect != sess->dialect, binding proceeds to the signed-request and GUID checks.
- After: if dialect is SMB 3.1.1, take down_read(&sess->chann_lock), walk sess->ksmbd_chann_list, if conn->cipher_type != chann->conn->cipher_type set rc = -EINVAL, then up_read and goto out_err.
- Path: SESSION_SETUP with SMB2_SESSION_REQ_FLAG_BINDING on SMB 3.1.1 with multichannel enabled. Existing out_err maps -EINVAL to STATUS_INVALID_PARAMETER (local lines 1916–1917).
**Step 2.3: Bug mechanism**
Record:
- Category: protocol/crypto correctness (logic), not UAF/leak/race.
- Mechanism: cipher is per-connection (conn->cipher_type, set in decode_encrypt_ctxt() at NEGOTIATE). Session encryption/decryption keys are session-wide (sess->smb3encryptionkey / smb3decryptionkey) and are **not** regenerated on bind (generate_encryptionkey is skipped when SMB2_SESSION_REQ_FLAG_BINDING is set, local lines 1545–1546). ksmbd_crypt_message() then selects GCM vs CCM and 128 vs 256 from **this connection’s** cipher_type while using those shared session keys. Accepting a mismatched cipher therefore attaches a channel that will encrypt/decrypt with the wrong AEAD (and possibly the wrong key length) for the session keys.
- The break after the first channel is intentional: one existing channel is enough because all channels of a session are supposed to share one cipher.
**Step 2.4: Fix quality**
Record:
- Obviously correct: same lock and xa_for_each pattern as free_channel_list() / ksmbd_sessions_deregister(). Lock order matches existing smb2_sess_setup (ksmbd_conn_lock then chann_lock).
- Minimal: 15 lines, no API/struct change.
- Regression risk: low. Well-behaved clients already use one cipher for all channels; the new path only rejects invalid binds. chann->conn is set when the channel is allocated (chann->conn = conn in ntlm_authenticate) and the channel is erased under chann_lock before free.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: Blame**
Record:
- Binding path originates in f5a544e3bab7 (“ksmbd: add support for SMB3 multichannel”, 2021); it is an ancestor of this HEAD.
- Dialect check: af7c39d971e43c (2022); also an ancestor.
- Cipher field: connection.h cipher_type present in this tree.
- Missing cipher compare has been true for as long as ksmbd had SMB 3.1.1 encryption + multichannel, including all of 6.12.
**Step 3.2: Fixes: tag**
Record: none. No Fixes: follow-up required.
**Step 3.3: File history**
Record:
- Local recent smb2pdu.c work is other ksmbd validation/UAF fixes; none already implement this cipher compare (git log -S 'cipher_type != chann' on this file is empty here).
- On origin/master, the only commit with this compare is 7019a11f79dc4 itself (no later rework).
- Neighbor bind_negative work (f49bca41c12f9, 3e67423336f08, 1f12738b0ed7b, 1c5daa2ea924be) is **not** in this tree and is about signing of rejected responses / user mismatch, not a prerequisite for this hunk.
**Step 3.4: Author**
Record: Namjae Jeon is the ksmbd maintainer. Many of his protocol- validation commits are already in this 6.12 tree.
**Step 3.5: Dependencies**
Record: Standalone. Needs sess->chann_lock, sess->ksmbd_chann_list, struct channel { ... *conn }, conn->cipher_type, SMB311_PROT_ID — all present locally. Not labeled patch X/Y. 4b706360ffb7e (channel limit) is not required.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: Original discussion**
Record: b4 dig -c 7019a11f79dc4 (and -C) failed: lore.kernel.org returned an error. WebFetch of lore URLs returned 403. Mailing-list review text is **UNVERIFIED**.
**Step 4.2: Recipients**
Record: Could not run b4 dig -w successfully. Commit has only the maintainer’s SOB (author = committer).
**Step 4.3: Bug report / spec / test**
Record (verified):
- Samba smbtorture test_session_bind_negative_smb3encGtoCs (source4/torture/smb2/session.c): SMB 3.1.1, encryption required, channel 1 AES-128-GCM, bind channel AES-128-CCM, same ClientGUID, expects NT_STATUS_INVALID_PARAMETER.
- Microsoft Open Specifications blog “SMB 3.1.1 Encryption in Windows 10”: “Session binding (multichannel) requires that all channels bound to a given session negotiate the same encryption cipher as the master session’s connection” and that all channels share the same encryption keys.
- MS-SMB2 3.3.5.5 (SESSION_SETUP) documents dialect/GUID/signed/state checks that ksmbd already performs; the published HTML for that section does **not** spell out a CipherId compare (the Windows/Samba behavior and the blog do).
**Step 4.4: Series**
Record: Cluster of July 2026 bind_negative_* ksmbd fixes on origin/master. This commit is self-contained; it does not depend on the signing-response patches.
**Step 4.5: Stable list**
Record: lore.kernel.org/stable search not reachable (403). **UNVERIFIED** whether it was previously discussed for stable.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: Functions**
Record: smb2_sess_setup() only.
**Step 5.2: Callers**
Record: fs/smb/server/smb2ops.c command table [SMB2_SESSION_SETUP_HE] = { .proc = smb2_sess_setup }. Invoked for every SMB2 SESSION_SETUP on the ksmbd server. Network-reachable.
**Step 5.3: Callees**
Record: down_read/up_read, xa_for_each on sess->ksmbd_chann_list. Existing error path goto out_err.
**Step 5.4: Reachability**
Record: Yes, from a remote SMB client if CONFIG_SMB_SERVER and KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL are enabled. Trigger: SMB 3.1.1 session, then a second connection that negotiates a different cipher and sends a signed binding SESSION_SETUP. Unprivileged in the sense of “any client that can authenticate to ksmbd”; not a local syscall UAF.
**Step 5.5: Similar patterns**
Record: Dialect mismatch already rejected in the same function. Samba has a second test bind_negative_smb3encGtoCd (different GUID); this tree already rejects GUID mismatch via memcmp(conn->ClientGUID, sess->ClientGUID).
---
## PHASE 6: CROSS-REFERENCE AGAINST THIS TREE
**Step 6.1: Buggy code present?**
Record: Yes. Local smb2_sess_setup() at fs/smb/server/smb2pdu.c ~1743–1757 does dialect/GUID checks and has **no** cipher compare. 7019a11f79dc4 is not an ancestor of HEAD.
**Step 6.2: Backport difficulty**
Record: **Clean apply** (git apply --check exit 0). Line-number offset only vs mainline.
**Step 6.3: Related fixes already here?**
Record: No bind_negative ksmbd commits in this tree. No other cipher- on-bind check.
---
## PHASE 7: SUBSYSTEM CONTEXT
**Step 7.1**
Record: fs/smb/server (ksmbd). Criticality: **IMPORTANT** — in-kernel SMB3 server, remote attack surface, not core mm/VFS, not staging.
**Step 7.2**
Record: Actively maintained; this 6.12 tree already carries many ksmbd validation backports (reject repeated SMB2 NEGOTIATE, DACL bounds, etc.).
---
## PHASE 8: IMPACT AND RISK
**Step 8.1: Who is affected**
Record: Users of ksmbd with SMB3 multichannel enabled. Not universal.
**Step 8.2: Trigger**
Record: Uncommon for production Windows/Samba clients (they keep one cipher). Fully reachable from a custom or test client. Requires an existing authenticated session plus a signed bind (not an unauthenticated bypass).
**Step 8.3: Failure mode**
Record: Today the invalid bind **succeeds**. Later encrypt/decrypt on that channel uses the new connection’s AEAD with session keys derived for the original cipher → AEAD failure / broken encrypted I/O, not a demonstrated kernel oops. Spec/Windows require rejection with STATUS_INVALID_PARAMETER. Severity: **MEDIUM** (protocol/crypto invariant), not a panic/UAF.
**Step 8.4: Risk–benefit**
Record:
- Benefit: enforces a documented SMB 3.1.1 encryption invariant on a network server; matches Windows/Samba; tiny.
- Risk: very low — 15 lines, existing locks, rejects only illegal binds.
- Ratio: favorable for this tree because the code exists, the patch applies cleanly, and ksmbd crypto protocol holes are worth closing even when the trigger is rare.
---
## PHASE 9: SYNTHESIS
**Step 9.1: Evidence**
FOR:
- Real missing check: dialect is validated, cipher is not.
- Session keys are shared; cipher is per-connection; mismatch is a crypto/protocol bug, not cosmetic.
- Samba negative test and Microsoft encryption blog require same cipher on all bound channels.
- 15 lines, maintainer-authored, applies cleanly to 6.12.111.
- All data structures and the insertion site exist here; bug is old (multichannel + 3.1.1 encryption).
AGAINST:
- No crash, UAF, deadlock, or known CVE.
- Production clients typically never send this.
- No Reviewed-by; lore discussion could not be fetched.
- Adjacent bind_negative signing patches are not in this tree (not required for this hunk).
UNRESOLVED:
- Original mailing-list review / any NAK (lore unreachable).
- Whether MS-SMB2 3.3.5.5 normative text currently names CipherId (blog
+ Samba/Windows behavior still require the check).
**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** — small, same locking as existing channel walks; covered by smbtorture bind_negative_smb3encGtoCs.
2. Real bug affecting users? **PASS** — ksmbd accepts a bind the protocol forbids; encrypted traffic on that channel is then inconsistent.
3. Important (crash/security/corruption/deadlock)? **PASS** (lower end) — encryption-cipher invariant on a remote SMB server, not a panic. Important enough given ksmbd’s role and the size of the fix.
4. Small and contained? **PASS** — +15 lines, one function.
5. No new features/APIs? **PASS**.
6. Applies to this tree? **PASS** — clean apply; buggy code present.
**Step 9.3: Exception category**
Record: none (not a device ID/quirk/DT/build/docs exception). Qualifies as a normal small protocol/crypto bugfix.
**Step 9.4: Decision**
Backport to this 6.12 tree. The missing check is in this code, the fix is surgical, and rejecting mismatched SMB 3.1.1 ciphers on bind is the correct, low-risk behavior for stable ksmbd.
---
## Why this matters for 6.12 stable users
ksmbd already refuses a bind when the **dialect** does not match. It still allows a second SMB 3.1.1 channel to join the same session with a **different** negotiated cipher (e.g. AES-128-CCM vs AES-128-GCM). Encryption keys are session-scoped and not rebuilt on bind; each connection then picks GCM/CCM and key length from its own cipher_type. That is a protocol and crypto consistency bug on a network-facing server. The patch only adds the missing compare and returns STATUS_INVALID_PARAMETER, which is what Windows/Samba tests expect.
Risk is low: correct clients are unchanged. The hunk applies here without prerequisites.
### Verification
- [Phase 1] Parsed message/tags: maintainer SOB only; no Fixes/Cc/Reported-by.
- [Phase 2] Diff: +15 lines in smb2_sess_setup() binding branch; -EINVAL already maps to STATUS_INVALID_PARAMETER.
- [Phase 2] Confirmed bind skips generate_encryptionkey (local 1545–1546); ksmbd_crypt_message() uses conn->cipher_type (auth.c 1135–1155).
- [Phase 3] git describe HEAD / make kernelversion: 6.12.111. git merge-base --is-ancestor 7019a11f79dc4 HEAD → not in tree.
- [Phase 3] f5a544e3bab7 and af7c39d971e43c are ancestors; dialect check present, cipher check absent (local ~1754–1757).
- [Phase 3] git apply --check of 7019a11f79dc4 → clean.
- [Phase 3] No later origin/master rework of this compare; related bind_negative signing commits are not ancestors and are not required.
- [Phase 4] b4 dig lore error; lore WebFetch 403. Samba test and MS encryption blog fetched successfully.
- [Phase 5] Caller: smb2ops.c SESSION_SETUP proc. Channel lock/list/cipher_type exist in this tree.
- [Phase 6] Insertion site matches; no local substitute fix.
- [Phase 8] Failure mode: invalid encrypted channel accepted; AEAD mismatch on subsequent I/O. Severity MEDIUM, regression risk very low.
- UNVERIFIED: lore review thread, stable@ discussion, explicit CipherId sentence in current MS-SMB2 3.3.5.5 HTML.
**YES**
fs/smb/server/smb2pdu.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
fs/smb/server/smb2pdu.c +15 -0
@@ -1747,6 +1747,21 @@ int smb2_sess_setup(struct ksmbd_work *work) goto out_err; } +if (conn->dialect ==SMB311_PROT_ID ) { +struct channel *chann; +unsigned long index; + +down_read (&sess->chann_lock); +xa_for_each (&sess->ksmbd_chann_list, index, chann) { +if (conn->cipher_type != chann->conn->cipher_type) + rc = -EINVAL ; +break ; + } +up_read (&sess->chann_lock); +if (rc) + goto out_err; + } +if (!(req->hdr.Flags &SMB2_FLAGS_SIGNED )) { rc = -EINVAL ; goto out_err;
Signature · 1 line
2.53.0