net: dsa: mt7530: check CORE_PLL_GROUP4 access in mt7531_setup()
Subsystems (71)
Sasha Levin
maintainerPATCH 1/1 net: dsa: mt7530: check CORE_PLL_GROUP4 access in mt7531_setup()
From: Daniel Golle <[email protected]>
[ Upstream commit 1ae63b018d3d70e96d420b59a1334860cf232bc6 ]
mt7531_setup() reads CORE_PLL_GROUP4 through the MT7531 indirect c45 PHY access, modifies it and writes it back to enable the PHY core PLL, but checks neither the read nor the write. Now that the indirect access functions propagate command-write failures, a failed read returns a negative errno that would be bit-modified and written back into the PLL register, and a failed write-back would go unnoticed. Check both and bail out. The adjacent EEE advertisement writes push a constant value and cannot corrupt state, so they are left as is.
---
LLM Generated explanations, may be completely bogus:
This is a real, small error-path fix for this 6.12 tree: an unchecked CORE_PLL_GROUP4 RMW can write a negative errno into the MT7531 PHY PLL. The buggy code is present here, and a related callee change already landed.
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
Record: [net: dsa: mt7530] [check] Check CORE_PLL_GROUP4 read/write results in mt7531_setup(). “check” is used as a missing-return-value fix, not a feature add.
**Step 1.2 — Tags (from the candidate message)**
Record:
- Signed-off-by: Daniel Golle <[email protected]> (author)
- `Link: https://patch.msgid.link/a7dfe3b66ea6ac1ae7915034de0527060e6ddc
[email protected]`
- Signed-off-by: Jakub Kicinski <[email protected]> (netdev maintainer applied it)
Ignored per instructions: any pipeline “already selected” markers.
Original mailing-list version (openwall/lkml, same msgid) also had:
- Fixes: c288575f7810 ("net: dsa: mt7530: Add the support of MT7531 switch")
- No Cc: stable, no Reported-by, no Reviewed-by on this patch itself
Cover letter for the series: Andrew Lunn’s Reviewed-by was collected on patches 1–3 and 6, not on this one (it was new in v2).
**Step 1.3 — Body**
Record:
- Bug: mt7531_setup() RMW of CORE_PLL_GROUP4 via mt7531_ind_c45_phy_read/write does not check either result.
- Failure mode: a failed read returns a negative errno that is bit- modified and written into the PHY core PLL; a failed write is ignored.
- Author’s framing: this became acute once the indirect helpers propagate command-write failures.
- Adjacent EEE advertisement writes are constant 0, so they cannot corrupt RMW state and are left alone.
**Step 1.4 — Hidden bug fix?**
Record: Not hidden. It is an explicit missing-error-check fix. The “now that …” wording is series context (patch 3/6), not a cleanup-only change.
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
Record:
- File: drivers/net/dsa/mt7530.c only
- Function: mt7531_setup()
- ~10 insertions, ~4 deletions (candidate hunk); net +6 lines of checks
- Scope: single-file surgical caller fix
**Step 2.2 — Flow**
Record: Before, u32 val = mt7531_ind_c45_phy_read(...) then OR/AND bits and write back, ignoring errors. After, store the int in ret, return if ret < 0, copy into val only on success, check the write, return on write failure. Probe/sw_setup fails instead of programming PLL from an errno.
**Step 2.3 — Bug mechanism**
Record: **Logic / error-path correctness**, specifically “treat errno as register data.”
- mt7531_ind_c45_phy_read() returns int (PHY data or negative errno).
- Assigned to u32 val, then modified (MT7531_RG_SYSPLL_DMY2 | MT7531_PHY_PLL_BYPASS_MODE, clear MT7531_PHY_PLL_OFF).
- Written through mt7531_ind_c45_phy_write(..., u16 data), so a value such as (u32)-ETIMEDOUT (0xFFFFFF92) truncates to 0xFF92/0xFFD2 and is programmed into the PHY PLL.
- Write errors (already returned on poll timeout in this tree) are ignored.
**Step 2.4 — Fix quality**
Record: Obviously correct. ret is already declared in mt7531_setup(). No API/locking/data-structure change. Regression risk is that a failing MDIO access now fails switch setup instead of continuing with a bogus PLL; that is the intended behavior. Risk of the fix itself is very low.
## Phase 3: Git history
**Step 3.1 — Blame**
Record:
- Unchecked RMW originates in c288575f7810 (Landen Chao, 2020-09-14):
“Add the support of MT7531 switch”.
- Helper names/MT753X_CTRL_PHY_ADDR from later Arınç ÜNAL refactors (868ff5f4944aa9, 06dfcd4098cfdc, 2024).
- Poll path in this tree already uses regmap_read_poll_timeout() from 96e0f5184af69 (Daniel Golle, applied 2026-08-09): “error out on failed reads in MT7531 PHY polling”.
**Step 3.2 — Fixes: target**
Record: c288575f7810 **is** an ancestor of this tree. The original MT7531 support (and this RMW) has been here since well before 6.12.
**Step 3.3 — Related file history**
Record:
- 96e0f5184af69 — already in this tree. Makes poll/read failures return negative errno instead of continuing with garbage “success” data.
- 93d46870c5440 — already in this tree. Same class: do not treat bus->read() errno as register data.
- This candidate is the missing **caller** check for the one in-driver RMW of mt7531_ind_c45_phy_read().
**Step 3.4 — Author**
Record: Daniel Golle is a regular MT7530 contributor (PLL/PHY access, MT7988, MT7531BE). Same author as the already-backported poll-error fix.
**Step 3.5 — Prerequisites**
Record: This is patch **4/6** of “fix remaining swallowed MDIO access errors”. Patch 3 (error out on failed PHY_IAC command writes, upstream 1c95dcb7e923) is **not** in this tree. It is not required to compile or to apply this hunk: the helpers already return int, and mt7531_ind_c45_phy_read/write already return negative errno on regmap_read_poll_timeout() failure. Patch 3 only adds extra error returns from discarded mt7530_mii_write() of MT7531_PHY_IAC. Standalone apply: **yes**.
## Phase 4: Mailing list / external
**Step 4.1 — Original discussion**
Record:
- b4 dig on the msgid failed (Cannot find a commit matching …).
- lore.kernel.org fetches returned 403.
- Fallback: openwall + lkml + cover letter.
- Lore/openwall URL: msgid a7dfe3b66ea6ac1ae7915034de0527060e6ddcd4.178 [email protected] (Tue 4 Aug 2026).
- Cover: https://lists.openwall.net/netdev/2026/08/04/90
- This patch was **new in v2**, flagged by Sashiko AI review of v1 as another swallowed MDIO error.
- Cover letter: “the call site exposed once patch 3 makes the MT7531 indirect c45 access propagate command-write failures.”
- Applied by Jakub Kicinski; patchwork bot lists upstream as 1ae63b018d3d.
- No NAK found in the material that could be retrieved.
**Step 4.2 — Recipients**
Record: To/Cc included Andrew Lunn, Vladimir Oltean, netdev maintainers, MediaTek/DSA people, netdev@, linux-mediatek@. Appropriate audience. Andrew reviewed 1–3 and 6; this patch 4 had no Reviewed-by in the submission.
**Step 4.3 — Bug report**
Record: No syzbot/bugzilla. Found by AI review of the MDIO-error series, not a user crash report.
**Step 4.4 — Series**
Record: v2 6-patch series. Patches 1, 2, 3, 5, 6 are **not** in this tree. This patch is self-contained at the mt7531_setup() call site.
**Step 4.5 — Stable list**
Record: No stable-specific discussion found (lore.kernel.org/stable search did not return this subject). UNVERIFIED: whether anyone later nominated it on stable@.
## Phase 5: Code semantic analysis
**Step 5.1 — Functions**
Record: mt7531_setup() only. Helpers mt7531_ind_c45_phy_read/write are not modified.
**Step 5.2 — Callers**
Record:
- mt7531_setup is .sw_setup for ID_MT7531 only (mt753x_table).
- mt753x_setup() calls priv->info->sw_setup(ds) and aborts on error.
- mt753x_setup is .setup in mt7530_switch_ops → DSA switch setup / probe.
- MT7988/EN7581 use mt7988_setup() → mt7531_setup_common(); they do **not** run this PLL RMW.
**Step 5.3 — Callees**
Record: mt7531_ind_c45_phy_read/write lock the MDIO mutex, write MT7531_PHY_IAC, poll MT7531_PHY_ACS_ST. On poll/read failure they goto out and return negative ret. mt7530_mii_write() already returns regmap_write errors, but those returns are still discarded in this tree (patch 3).
**Step 5.4 — Reachability**
Record: Probe-time only, when an MT7531 DSA switch is instantiated (CONFIG_NET_DSA_MT7530). Not a syscall hot path. Userspace cannot trigger it except by causing device probe. Trigger is MDIO/regmap failure or IAC poll timeout during setup.
**Step 5.5 — Similar patterns**
Record: The only in-driver mt7531_ind_c45_phy_read() call site is this PLL RMW. Other mt7531_ind_c45_phy_write() uses in the same function are constant EEE-adv 0. Phylib also uses these as .phy_read_c45 / .phy_write_c45.
## Phase 6: Local tree (6.12.111 / pending-6.12)
**Step 6.1 — Buggy code present?**
Record: **Yes.** drivers/net/dsa/mt7530.c mt7531_setup() still does:
```2665:2672:drivers/net/dsa/mt7530.c
val = mt7531_ind_c45_phy_read(priv,
MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
MDIO_MMD_VEND2, CORE_PLL_GROUP4);
val |= MT7531_RG_SYSPLL_DMY2 | MT7531_PHY_PLL_BYPASS_MODE;
val &= ~MT7531_PHY_PLL_OFF;
mt7531_ind_c45_phy_write(priv,
MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
MDIO_MMD_VEND2, CORE_PLL_GROUP4, val);
```Bug introduced with MT7531 support (c288575f7810, v5.10-era). Present in 6.12.
**Step 6.2 — Backport difficulty**
Record: **Clean apply** aside from line-number offset (2665 here vs 2764 in the candidate diff). Surrounding comments and EEE loop match. ret is already in scope.
**Step 6.3 — Related fixes already here**
Record: 96e0f5184af69 already backported. That change makes failed IAC polls/reads return errno into this unchecked caller, so this tree already has the callee half of the fix without the caller half. No equivalent caller check exists yet.
## Phase 7: Subsystem context
**Step 7.1**
Record: drivers/net/dsa/mt7530.c — MediaTek MT7530/MT7531 DSA. **IMPORTANT** for MediaTek routers/SBCs (MT7621/MT7622/MT7531), not core mm/vfs. CONFIG_NET_DSA_MT7530.
**Step 7.2**
Record: File is actively maintained; recent 6.12 backports already include two MDIO-error fixes from the same author.
## Phase 8: Impact and risk
**Step 8.1 — Who is affected**
Record: Driver-specific: MT7531 switch users (common on MediaTek ARM routers). Not MT7988/EN7581 setup (mt7988_setup).
**Step 8.2 — Trigger**
Record: MDIO/regmap failure or PHY_IAC poll timeout during dsa_switch setup. Uncommon on healthy hardware. Not an unprivileged syscall trigger. After 96e0f5184af69, a failed bus read during poll is a **negative errno**, not silent garbage success — so this caller bug is easier to hit than before that backport.
**Step 8.3 — Failure mode**
Record: Hardware misconfiguration: PHY core PLL programmed from a truncated errno instead of a real CORE_PLL_GROUP4 value, then setup continues. Switch can probe “successfully” with PHYs/PLL in a bad state. Not a KASAN crash. Severity: **HIGH** for that hardware (silent wrong PLL), not a generic kernel panic. Failing probe is the correct outcome.
**Step 8.4 — Risk/benefit**
Record:
- Benefit: medium-high for MT7531 — closes a hole opened/worsened by the already-applied poll-error backport; avoids writing errno into PLL.
- Risk: very low (6 lines of if (ret < 0) return ret).
- Ratio: favorable.
## Phase 9: Synthesis
**Evidence FOR**
- Real bug: negative errno used as PLL register data, then written back.
- Buggy RMW is in this 6.12 tree; Fixes: target c288575f7810 is here.
- Companion to 96e0f5184af69, already in this tree: that commit made failed reads return errno; this caller still treats the result as PHY data.
- Small, obviously correct, no new API, applies cleanly.
- Same class as other swallowed-MDIO fixes already accepted here (93d46870c5440, 96e0f5184af69).
- Author intended it as a bug fix (Fixes: c288575f7810 on the list).
- Applied to mainline by Jakub Kicinski (1ae63b018d3d).
**Evidence AGAINST**
- Error path only; no syzbot/user crash report.
- Driver-specific, probe-time, not a UAF/panic/CVE.
- Series patch 4/6; Andrew Lunn did not Reviewed-by this specific patch.
- Patch 3 (PHY_IAC command-write checks) is not in this tree; the author’s “now that writes propagate” story is only fully true after patch 3.
**Unresolved / UNVERIFIED**
- Full lore thread (403); no individual review replies beyond cover letter and patchwork apply notice.
- Whether patch 3 will be evaluated separately for this tree (not required for this hunk).
**Stable rules**
1. Obviously correct and tested? **PASS** — trivial return-value checks; merged to net by Kicinski.
2. Real bug affecting users? **PASS** — MT7531 setup can program PHY PLL from errno on MDIO/poll failure.
3. Important? **PASS** — hardware PLL corruption and silent “success” after a failed access; worsened by an already-backported callee fix. Not a generic oops, but it is serious for this switch.
4. Small and contained? **PASS** — one function, ~6 net lines.
5. No new features/APIs? **PASS**.
6. Can apply to this tree? **PASS**.
**Exception category:** none (not a device ID/quirk/DT/build/docs exception). It qualifies on ordinary bug-fix rules.
The missing patch 3 does not make this a NO: poll timeout and failed regmap_read_poll_timeout() already return errno here, and those values are what get written into CORE_PLL_GROUP4 today.
### What it solves for this tree
On MT7531 probe, a failed indirect C45 read of CORE_PLL_GROUP4 is currently folded into the PLL enable RMW and written back. This tree already backported the helper change that returns those failures as errno. Without this caller check, 6.12 can program the PHY core PLL from that errno and keep going. The fix fails setup instead. It is small, matches local code, and does not need the rest of the series.
Verification:
- [Phase 1] Parsed subject/tags/body; list version has `Fixes:
c288575f7810`; candidate message has Link + Golle/Kicinski SOBs
- [Phase 2] Diff: mt7531_setup() only; check read and write; ret already declared
- [Phase 3] git blame on 2660–2686: RMW from c288575f7810; helpers renamed later; poll uses 96e0f5184af69
- [Phase 3] git merge-base --is-ancestor c288575f7810 HEAD → yes
- [Phase 3] git merge-base --is-ancestor 96e0f5184af69 HEAD → yes (callee error propagation already here)
- [Phase 3] git log --grep="PHY_IAC command writes" → patch 3 **not** in this tree
- [Phase 3] git show 96e0f5184af69 confirms regmap_read_poll_timeout() returns negative on failed reads
- [Phase 4] b4 dig on msgid failed; lore 403; used openwall/lkml/cover letter; upstream SHA 1ae63b018d3d; v2 new patch; Andrew reviewed 1–3 and 6 only
- [Phase 4] UNVERIFIED: full review-reply text; stable@ thread
- [Phase 5] grep: only in-driver mt7531_ind_c45_phy_read call is this RMW; .sw_setup = mt7531_setup for ID_MT7531; mt753x_setup() returns that error
- [Phase 6] git describe HEAD → p-6.12-4-gbf6fcdf761abd; make kernelversion → 6.12.111; buggy code at mt7530.c:2665–2672
- [Phase 6] Pre-image matches the candidate hunk; clean apply expected
- [Phase 8] Failure mode: PHY PLL programmed from truncated errno on probe MDIO failure; severity HIGH for MT7531, trigger uncommon but real after 96e0f5184af69
**YES**
drivers/net/dsa/mt7530.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/net/dsa/mt7530.c +10 -4
@@ -2758,14 +2758,20 @@ mt7531_setup(struct dsa_switch *ds)* phy_[read,write]_mmd_indirect is called, we provide our own * mt7531_ind_mmd_phy_[read,write] to complete this function. */ - val =mt7531_ind_c45_phy_read (priv, + ret =mt7531_ind_c45_phy_read (priv,MT753X_CTRL_PHY_ADDR (priv->mdiodev->addr),MDIO_MMD_VEND2 ,CORE_PLL_GROUP4 ); +if (ret <0 ) +return ret; + + val = ret; val |=MT7531_RG_SYSPLL_DMY2 |MT7531_PHY_PLL_BYPASS_MODE ; val &= ~MT7531_PHY_PLL_OFF ; -mt7531_ind_c45_phy_write (priv, -MT753X_CTRL_PHY_ADDR (priv->mdiodev->addr), -MDIO_MMD_VEND2 ,CORE_PLL_GROUP4 , val); + ret =mt7531_ind_c45_phy_write (priv, +MT753X_CTRL_PHY_ADDR (priv->mdiodev->addr), +MDIO_MMD_VEND2 ,CORE_PLL_GROUP4 , val); +if (ret <0 ) +return ret;/* Disable EEE advertisement on the switch PHYs. */ for (i = MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 iommu/rockchip: Clear stale page faults before enabling stall
From: Jiaxing Hu <[email protected]>
[ Upstream commit b10d5920cafa292ee3cab9c20f813da4fe4f00b8 ]
Boot firmware can leave an IOMMU bank in PAGE_FAULT_ACTIVE before the driver has configured paging:
PAGE_FAULT_ACTIVE=1 STALL_ACTIVE=0 IDLE=1
Such a bank ignores CMD_ENABLE_STALL and never reaches STALL_ACTIVE, so rk_iommu_enable_stall()'s readx_poll_timeout() spins until it times out (seen on the RK3576 NPU, whose MMUs share this poll across banks).
Rather than special-casing these banks in the stall path, acknowledge the stale fault with CMD_PAGE_FAULT_DONE before enabling stall, so every bank starts from a clean state and the normal stall sequence applies to all of them. Banks without a pending fault are untouched.
---
LLM Generated explanations, may be completely bogus:
The local checkout is mainline **7.3-rc4**. The stall-timeout path is in this tree, and the 13-line firmware leftover workaround is a real IOMMU enable failure, not a new API.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[iommu/rockchip] [Clear] [acknowledge leftover PAGE_FAULT_ACTIVE so stall enable does not poll-timeout]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Jiaxing Hu \<[email protected]\> (author)
- Signed-off-by: Will Deacon \<[email protected]\> (IOMMU maintainer; applied the patch)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, Link:, or Cc: stable (absence of Fixes/Cc:stable is expected for this review)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** Boot firmware can leave an IOMMU bank in PAGE_FAULT_ACTIVE=1, STALL_ACTIVE=0, IDLE=1 before the driver configures paging.
- **Symptom:** That bank ignores CMD_ENABLE_STALL and never reaches STALL_ACTIVE. rk_iommu_enable_stall()’s readx_poll_timeout() fails. Observed on the RK3576 NPU, whose MMUs share the stall poll across banks (rk_iommu_is_stall_active() ANDs every bank).
- **Root cause:** Stale firmware page-fault state blocks the stall command.
- **Fix:** Issue CMD_PAGE_FAULT_DONE on any bank that still has PAGE_FAULT_ACTIVE, then use the normal stall sequence. Banks without a pending fault are untouched.
- **Version info in message:** none beyond RK3576 NPU.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. This is an explicit hardware/firmware leftover workaround that prevents a stall-enable timeout.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/iommu/rockchip-iommu.c — **+13 / -0**
- Function: rk_iommu_enable_stall()
- Scope: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** If stall is not already active and paging is enabled, broadcast CMD_ENABLE_STALL and poll until every bank reports STALL_ACTIVE (1 ms timeout, RK_MMU_POLL_TIMEOUT_US=1000). One stuck bank fails the whole poll.
- **After:** Same path, but first walk each bank; if RK_MMU_STATUS_PAGE_FAULT_ACTIVE is set, write RK_MMU_CMD_PAGE_FAULT_DONE to that bank’s command register, then enable stall as before.
- Path: initialization / attach / resume (rk_iommu_enable → rk_iommu_enable_stall), and also disable/suspend (return value ignored there).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Hardware workaround / logic correctness]** Firmware leaves PAGE_FAULT_ACTIVE. Hardware ignores CMD_ENABLE_STALL in that state. rk_iommu_enable() treats stall timeout as fatal (if (ret) goto out_disable_clocks), so the IOMMU never reaches rk_iommu_force_reset() / paging setup and **device attach fails**. The fix acks the leftover fault with the same command the IRQ handler already uses (RK_MMU_CMD_PAGE_FAULT_DONE).
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Minimal and readable. Gated on PAGE_FAULT_ACTIVE, so idle banks are unchanged. Uses the existing command encoding. Regression risk is low; the only flagged concern is not also writing RK_MMU_INT_CLEAR (see Phase 4), which is incomplete-ack, not a new deadlock or API change.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- rk_iommu_enable_stall() introduced in **c68a292152d32** (iommu/rockchip: rk3288 iommu driver, 2014) — contained in **v3.19-rc1**.
- Multi-bank num_mmu loop: **cd6438c5f8446**, contained in **v4.6-rc1**.
- readx_poll_timeout: **0416bf6479acef**, contained in **v4.17-rc1**.
- The 13-line ack loop is this commit (**b10d5920cafa2**).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable. Buggy interaction is firmware leftover vs stall path that has existed for years.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Immediate parent on the file: **841363ebb5082** iommu/rockchip: Take all DT clocks — same author, same RFC series (patch 4/8). Different problem (extra clocks so DTE_ADDR writes land). **Not a code dependency** of the stall ack.
- No later commits on this file after b10d5920cafa2 in this tree.
- Standalone IOMMU change; Will applied 4/8 and 5/8 without the rest of the NPU series.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Jiaxing Hu is not the IOMMU maintainer. In this tree, two rockchip-iommu commits (clocks + this). Will Deacon applied both.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Diff only needs rk_iommu_enable_stall, num_mmu, RK_MMU_STATUS_PAGE_FAULT_ACTIVE, RK_MMU_CMD_PAGE_FAULT_DONE — all present long before 7.3. **Can apply standalone.**
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- Lore (via b4):
https://patch.msgid.link/[email protected]
- Series: **[RFC PATCH v2 0/8] accel/rocket: RK3576 NPU (RKNN) enablement**
- This patch is **v2 5/8**. v1 had two “skip orphaned-fault banks” patches; v2 replaced them with this fault-ack after Chaoyi Chen asked whether clearing the fault avoids skipping banks.
- Will Deacon (2026-07-26): “Applied driver changes to iommu (rockchip)” for 4/8 and 5/8. No NAK on this patch.
- Cover letter: NPU bring-up is still incomplete (“full inference is not correct yet”). This IOMMU fix was still taken on its own.
- v3 of the wider series was not out when Will applied this; applied version is the latest for this hunk.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: Recipients included Will Deacon, Joerg Roedel, Robin Murphy, Heiko Stuebner, [email protected], linux-rockchip. No human Reviewed-by on 5/8 in the thread. Will applied it. Sashiko bot (automated) commented.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla. Author hit it on a Radxa ROCK 4D while bringing up the RK3576 NPU IOMMUs. Cover letter lists “clearing a stale firmware page fault” as required for those IOMMUs to come up.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: RFC 8-patch NPU enablement. Only the two IOMMU driver patches were merged. NPU DT/driver patches are **not** in this tree (no NPU IOMMU nodes in rk3576.dtsi). This stall patch does not depend on them.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search returned HTTP 403. **UNVERIFIED** whether stable@ discussed this. No in-tree grep hit except this commit.
Sashiko bot concern (verified from mbox): CMD_PAGE_FAULT_DONE without RK_MMU_INT_CLEAR might leave a raw IRQ pending. On rockchip,disable- mmu-reset instances (in-tree: px30, rk3288, rk3368, rk3399, rk356x, rk3576 vdec), rk_iommu_force_reset() is skipped, then RK_MMU_INT_MASK is programmed in rk_iommu_enable(). A leftover raw bit could fire a page-fault IRQ. The existing IRQ handler already logs, optionally report_iommu_fault(), zaps cache, issues PAGE_FAULT_DONE, and clears INT_STATUS. That is a possible spurious IRQ/log, not a verified panic. No follow-up commit addressed it; Will still applied the patch.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: rk_iommu_enable_stall() (modified). Helpers used:rk_iommu_read, rk_iommu_is_stall_active, rk_iommu_is_paging_enabled, rk_iommu_command.
**Step 5.2: TRACE CALLERS**
Record:
- rk_iommu_disable() line 928 — detach / runtime suspend. Return ignored.
- rk_iommu_enable() line 950 — attach / runtime resume. **Failure aborts enable.**
- rk_iommu_enable() called from rk_iommu_attach_device() (line 1064) and rk_iommu_resume() (line 1349).
**Step 5.3: TRACE CALLEES**
Record: MMIO status/command. No allocation, no new locks. writel(RK_MMU_CMD_PAGE_FAULT_DONE, base + RK_MMU_COMMAND) matches rk_iommu_base_command().
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace/DMA attach or runtime PM resume → rk_iommu_attach_device / rk_iommu_resume → rk_iommu_enable → rk_iommu_enable_stall. Reachable on Rockchip SoCs with CONFIG_ROCKCHIP_IOMMU. Trigger is firmware leftover + paging already enabled. Not a syscall fuzz path; it is device bring-up.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: IRQ path already does RK_MMU_CMD_PAGE_FAULT_DONE (line 642) plus RK_MMU_INT_CLEAR. No other stall-path fault ack. In-tree RK3576 vdec_mmu is two-bank (reg two regions), so the AND-poll issue is not NPU-only in principle.
===============================================================
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 = **v7.3-rc4-27-gf0100363d8c37**, make kernelversion = **7.3.0-rc4**. rk_iommu_enable_stall() is present; this commit is already an ancestor of HEAD (git merge-base --is-ancestor b10d5920cafa2 HEAD succeeded). Landed via iommu-updates-v7.3 (not in v7.2). Stall path itself dates to v3.19.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Hunk is a contiguous insert after the paging-enabled check. Expected apply: **clean** on trees that have the 2016 multi-bank num_mmu loop (v4.6+). No conflicting later edits on this function in this checkout.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This is the only “stale page fault” commit. No alternate fix. Sibling clocks change is independent.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **drivers/iommu/rockchip-iommu.c** — Rockchip IOMMU.
Criticality: **IMPORTANT** (platform IOMMU for multimedia/NPU DMA; not core mm/VFS, but attach failure takes down the consumer device).
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature driver (2014), still receiving Rockchip bring-up fixes. Joerg’s v7.3 pull: “Rework Rockchip state handling and fix clock, probe and stale-fault handling.”
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **driver-specific / platform-specific** — CONFIG_ROCKCHIP_IOMMU on Rockchip. Practical trigger reported on RK3576 NPU MMUs (those DT nodes are **not** in this tree). Any multi- bank instance whose firmware leaves PAGE_FAULT_ACTIVE can hit the same poll (e.g. in-tree RK3576 vdec_mmu has two banks).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Boot firmware leftover fault, then first stall enable while paging is still enabled. Timing: probe/attach or resume, not a hot path. Unprivileged users do not trigger it directly; it is firmware × driver init. No public reproducer beyond the author’s ROCK 4D bring-up.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **IOMMU enable fails after a 1 ms poll** (RK_MMU_POLL_TIMEOUT_US=1000). Attach returns error; the DMA device does not get a working IOMMU. **Not** a panic, hang, UAF, or corruption.
Severity: **HIGH** for the affected device (non-functional), **MEDIUM** system-wide (1 ms timeout + error, rest of the machine continues).
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** Hardware/firmware workaround so stall enable succeeds; IOMMU attach can proceed. High for RK3576 NPU users; modest for other Rockchip boards unless firmware leaves the same bit.
- **Risk:** 13 lines, status-gated. Theoretical spurious IRQ if INT_STATUS is not cleared on disable-mmu-reset devices. No new locks/APIs.
- **Ratio:** Benefit outweighs risk. Same class as other hardware leftover/quirk fixes.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real, explained failure: stall poll times out, rk_iommu_enable() aborts, device attach fails.
- Small (+13), contained, status-gated.
- Same command the IRQ handler already uses.
- Will Deacon applied it independently of the unfinished NPU RFC.
- v7.3 IOMMU pull listed stale-fault handling as a fix.
- Driver and stall path exist in this tree since v3.19 / v4.6.
- Hardware/firmware workaround (stable exception category).
- No new APIs or features.
AGAINST:
- Originated in an RFC series to enable RK3576 NPU; NPU IOMMU DT is still not in this tree.
- Observed on that NPU, not reported on long-shipped VOP/VDEC.
- Not crash/security/corruption; 1 ms timeout then enable failure.
- Sashiko noted missing INT_CLEAR; unaddressed.
- No Fixes:/Cc:stable (not a negative by itself).
UNRESOLVED:
- lore.kernel.org/stable search HTTP 403.
- Whether in-tree vdec/vop firmware also leaves PAGE_FAULT_ACTIVE (author only cited NPU).
- Whether a leftover INT_STATUS after PAGE_FAULT_DONE actually fires on disable-mmu-reset hardware.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — logic matches the described hardware state; author tested on ROCK 4D; IOMMU maintainer applied it.
2. Fixes a real bug that affects users? **PASS** — stall timeout prevents IOMMU enable/attach.
3. Important issue? **PASS** — device IOMMU never comes up (not a panic, but hardware non-functional). Severity HIGH for that device.
4. Small and contained? **PASS** — 13 lines, one function.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — stall path and symbols are here; hunk is a clean insert.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Hardware quirk/workaround** — firmware leftover PAGE_FAULT_ACTIVE so stall commands work. Not a new driver, not a new userspace API.
**Step 9.4: MAKE YOUR DECISION**
This tree is 7.3-rc4; the stall path is old and the bug is a firmware leftover vs that path, not a 7.3-only feature. The patch is a small, maintainer-acked workaround that stops IOMMU attach from failing. Origin in an unfinished NPU RFC does not make it a new API; Will merged it as a standalone IOMMU fix. Missing INT_CLEAR is a residual IRQ-ack concern, not a reason to drop a stall-timeout fix that already uses the documented fault-done command.
Verification:
- [Phase 1] Parsed tags: only author SOB + Will Deacon SOB; no Fixes/Reported-by/Cc:stable
- [Phase 1] Body: PAGE_FAULT_ACTIVE leftover → ENABLE_STALL ignored → poll timeout on RK3576 NPU multi-bank poll
- [Phase 2] Diff: +13 in rk_iommu_enable_stall(); loop acks PAGE_FAULT_ACTIVE with CMD_PAGE_FAULT_DONE
- [Phase 2] rk_iommu_enable() returns on stall timeout before force_reset (line 950-952) — attach fails
- [Phase 3] git blame: function from c68a292152d32 (v3.19); poll from 0416bf6479acef (v4.17); multi-mmu cd6438c5f8446 (v4.6)
- [Phase 3] git merge-base --is-ancestor b10d5920cafa2 HEAD: yes; not in v7.2; in v7.3-rc1
- [Phase 3] Sibling 841363ebb5082 is clocks-only; not required for this hunk
- [Phase 4] b4 dig -c b10d5920cafa2:
https://patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: RFC v1 (skip banks) → v2 (this ack); Will applied v2 4/8 and 5/8
- [Phase 4] b4 dig -w: iommu maintainers + rockchip list on CC
- [Phase 4] mbox: Will “Applied driver changes to iommu (rockchip)”; Sashiko INT_CLEAR warning; no human NAK
- [Phase 4] lore.kernel.org WebFetch/curl: HTTP 403 — stable-list discussion UNVERIFIED
- [Phase 5] Callers: disable (unchecked) and enable (fatal); enable from attach_device and resume
- [Phase 5] IRQ handler already issues PAGE_FAULT_DONE at line 642
- [Phase 6] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; Makefile 7.3.0-rc4; file present
- [Phase 6] No NPU IOMMU nodes in arch/arm64/boot/dts/rockchip/rk3576.dtsi; vdec_mmu is two-bank + disable-mmu-reset
- [Phase 7] iommu-updates-v7.3 merge text: “fix clock, probe and stale- fault handling”
- [Phase 8] Failure: 1 ms poll then IOMMU enable/attach failure; not oops/UAF
- UNVERIFIED: whether firmware leaves this bit on in-tree vdec/vop; whether INT_STATUS spurious IRQ reproduces; stable@ thread
The fix is small, surgical, and meets the stable criteria as a hardware leftover workaround in a long-lived driver.
**YES**
drivers/iommu/rockchip-iommu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/iommu/rockchip-iommu.c +13 -0
@@ -422,6 +422,19 @@ static int rk_iommu_enable_stall(struct rk_iommu *iommu)if (!rk_iommu_is_paging_enabled (iommu))return 0 ; +/* +* Boot firmware can leave a bank in PAGE_FAULT_ACTIVE with no handler +* (PAGE_FAULT_ACTIVE & !STALL_ACTIVE & IDLE). Such a bank ignores +* CMD_ENABLE_STALL and never reaches STALL_ACTIVE, timing out the poll +* below. Acknowledge any stale fault first so every bank starts clean. +*/ +for (i =0 ; i < iommu->num_mmu; i++) { +if (rk_iommu_read (iommu->bases[i],RK_MMU_STATUS ) & +RK_MMU_STATUS_PAGE_FAULT_ACTIVE ) +writel (RK_MMU_CMD_PAGE_FAULT_DONE , + iommu->bases[i] +RK_MMU_COMMAND ); + } +rk_iommu_command (iommu,RK_MMU_CMD_ENABLE_STALL ); ret = readx_poll_timeout(rk_iommu_is_stall_active, iommu, val,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 docs: update the unmount propagation rule
In reply to Sasha LevinFrom: Christian Brauner <[email protected]>
[ Upstream commit 3f5dc09141a7bfe286620a6869d1d70ffe32d6b8 ]
Section 5f still describes the rule propagate_umount() used before commit f0d0ba19985d ("Rewrite of propagate_umount()"). It states that a mount that receives the unmount by propagation is left alone as soon as it has any submount. That's not true anymore.
A propagated unmount unmounts a mount with sub-mounts as long as every sub-mount gets unmounted together with it. This is the case when the sub-mounts are unmounted by the same propagation. Only a sub-mount that cannot be unmounted keeps its parent mounted.
The section also only describes a single mount without sub-mounts. But lazy unmounts take a tree and every mount of the tree propagates its unmount from its parent mount.
---
LLM Generated explanations, may be completely bogus:
This is a documentation-only correction of stale unmount-propagation text. The local tree is **6.18.57** (v6.18.57-155-gcdf239ca885b2). The rewrite it documents is already in that tree, so the question is whether this docs update belongs here.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[docs]** **[update]** Update the unmount propagation rule in shared-subtree documentation.
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Link: https://patch.msgid.link/20260923-work-mount- [email protected]
- Signed-off-by: Christian Brauner (Amutable) \<[email protected]\>
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Cc:
stable on this patch itself
- Cover letter of the same series ([PATCH 0/8] mount: a few gnarly fixes) did Cc stable; this 8/8 docs patch did not
- Ignore pipeline tags: [Upstream commit 3f5dc09141a7…], `Signed-off-
by: Sasha Levin`
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** Section 5f of sharedsubtree.rst still describes pre-rewrite propagate_umount(): a receiver with any sub-mount is left mounted.
- **Symptom:** Documentation disagrees with current kernel behavior. A propagated unmount may take a mount that has children if those children are also unmounted by the same propagation. Only a child that cannot be unmounted keeps its parent.
- **Also missing:** Lazy MNT_DETACH unmounts a tree; every mount in that tree propagates from its own parent.
- **Version info:** Behavior changed in f0d0ba19985d (“Rewrite of propagate_umount()”).
- **Root cause:** Overview docs were not updated when propagate_umount() was rewritten.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a hidden runtime fix. It is an explicit documentation correction of obsolete unmount semantics. No code, locking, or error- path change.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: Documentation/filesystems/sharedsubtree.rst (+14 / −6)
- One section: “f) Unmount semantics”
- Scope: single-file documentation, surgical
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: receivers at dentry b are unmounted only if they have no sub-mounts. Any child on C2/C3 blocks that receiver; C1 with sub- mounts fails the whole umount.
- After: receivers are unmounted if every mount below them is also unmounted. A child unmounted by the same propagation does not pin its parent. Adds lazy-umount tree propagation and a pointer to Documentation/filesystems/propagate_umount.txt.
- Path affected: documentation of umount/propagation semantics only.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Category: documentation correctness (obsolete comment/docs)
- Mechanism: overview text still described the old “any sub-mount blocks the receiver” rule. Code after f0d0ba19985d unmounts a receiver when remaining children are themselves candidates (trim_one() / non- shifting set).
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct relative to this tree’s propagate_umount() and propagate_umount.txt
- Minimal; no unrelated edits
- Regression risk: none (no executable code)
- Red flags: none
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Original unmount-semantics prose: 9cfcceea8f7e8f (Ram Pai, 2005-11-07, Documentation/sharedsubtree.txt)
- ReST conversion/formatting: Bagas Sanjaya, 2025-08 (a8886b42d57b8, b293fd55a1b89)
- Behavior change that made the text wrong: f0d0ba19985d (Al Viro, 2025-06-29, ~v6.17)
- That rewrite **is** an ancestor of this 6.18.y tree
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Expected. The related behavioral commit is f0d0ba19985d, already in v6.18.57.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- Recent sharedsubtree.rst work is formatting/ReST, not semantics
- Precise rules already live in Documentation/filesystems/propagate_umount.txt (added by the rewrite)
- Standalone: patch 8/8 of Brauner’s “mount: a few gnarly fixes”; this hunk does not depend on patches 1–7
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record:
- Author is VFS maintainer (FILESYSTEMS (VFS and infrastructure) in MAINTAINERS)
- Same series includes real umount/mount bugfixes (busy propagated umount, unbindable copy, etc.)
- This patch is the docs companion, not one of those code fixes
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS Record:
- Depends only on the rewrite already present here, and on propagate_umount.txt, which exists at v6.18.57
- Can apply 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 3f5dc09141a7… matched patch-id 0b2df883901084c2…
- Lore URL: https://patch.msgid.link/20260923-work-mount-
[email protected]
- Series: v1 only ([PATCH 8/8] docs: update the unmount propagation rule), 2026-09-23
- Cover letter: [PATCH 0/8] mount: a few gnarly fixes
- Direct replies in the saved thread are about patch 5/8 (fs: don't silently unmount busy mounts), not this docs patch
- No NAK, no reviewer concern, no stable nomination on 8/8 itself
- WebFetch of lore.kernel.org returned 403; thread recovered via b4 dig -m
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w):
- Recipients: Christian Brauner, linux-fsdevel, Linus Torvalds, Alexander Viro, Jan Kara
- Right maintainers/lists. No extra Reviewed-by on 8/8. Brauner is both author and VFS maintainer.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No user/syzbot report for the docs. The body is the author’s observation that section 5f lagged the rewrite. Severity is documentation inaccuracy, not a crash.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record:
- Series of 8: unbindable copy, MOVE_MOUNT_SET_GROUP, busy propagated umount, migrating-task ref, plus selftests, plus this docs update
- 8/8 does not implement those fixes; it only restates propagate_umount() after the 2025 rewrite
- Self-contained
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record:
- Cover letter Cc’d [email protected]
- Patches 1/8 and 5/8 had explicit Cc: stable in the body; 8/8 did not
- Direct lore.kernel.org/stable search was blocked (bot challenge). No additional stable-thread evidence beyond the series headers.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: None. Documentation only. Semcode tools are not available.
Step 5.2: TRACE CALLERS
Record: N/A for the diff. Documented behavior is implemented by propagate_umount() in fs/pnode.c, called from fs/namespace.c (umount_tree / do_umount path).
Step 5.3: TRACE CALLEES
Record: propagate_umount() gathers candidates, trim_one() / trim_ancestors() enforce the non-shifting set, handle_locked() enforces locked-mount (non-revealing) rules. That matches “unmount a parent if every child is also unmounted; a child that cannot be unmounted keeps the parent.”
Step 5.4: FOLLOW THE CALL CHAIN
Record: Reachable from umount(2) / umount2(MNT_DETACH) on shared/slave mounts. Common container/namespace path. The **patch** itself is not on that path; it only describes it.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Detailed rules already in Documentation/filesystems/propagate_umount.txt. This change makes the overview consistent with that file instead of contradicting it.
===============================================================
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 (v6.18.57-155-gcdf239ca885b2)
- Stale section 5f is present at v6.18.57:Documentation/filesystems/sharedsubtree.rst (identical to the candidate’s pre-image)
- Rewrite f0d0ba19985d **is** in v6.18.57
- So this tree’s kernel already uses the new rule, while the overview still documents the old one
- Bug introduced (as a docs mismatch) when the rewrite landed (~v6.17), i.e. before this 6.18 branch
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Clean apply. diff of v6.18.57 vs the candidate pre-image is empty (both 994 lines). Context matches.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record:
- Precise notes (propagate_umount.txt) already here
- Related code fix bf2c8dec26fb7 (“fs: don't silently unmount busy mounts”) is already in v6.18.57; that does not replace this overview correction
- No earlier equivalent rewrite of section 5f
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record:
- Subsystem: VFS / mount namespace documentation (Documentation/filesystems/)
- Documents CORE mount/umount propagation used by containers
- The change itself is docs, not core code
- Criticality of the **text**: IMPORTANT for people who rely on shared- subtree docs; runtime criticality: none
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mount/namespace code is actively maintained (Brauner/Viro). sharedsubtree.rst itself is old and mostly formatting churn; the semantics gap dates to the 2025 rewrite.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Anyone reading shared-subtree unmount docs (container/namespace users and developers). No runtime user population is changed.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Not a runtime trigger. The mismatch is visible whenever someone reads section 5f and compares it to umount on shared mounts with nested children.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- Failure mode: incorrect documentation of umount(2) propagation
- Userspace that trusts the old “any child blocks the receiver” rule can mis-predict which mounts disappear
- Accurate rules already exist in propagate_umount.txt
- Severity: **LOW** for runtime; **MEDIUM** as a docs bug about user- visible mount semantics
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: overview matches this tree’s actual propagate_umount(); avoids a documented lie about umount
- Risk: none (14 insertions / 6 deletions, docs only)
- Ratio: favorable — small, zero-risk correction of obsolete docs for behavior that is already here
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Section 5f is factually wrong in this 6.18.y tree because f0d0ba19985d is present
- Stable exception for documentation/comment fixes applies
- Small, contained, maintainer-authored
- Applies cleanly to v6.18.57
- Points at propagate_umount.txt, which already exists here
- Zero runtime regression risk
AGAINST:
- No crash, UAF, deadlock, corruption, or security fix
- This patch was not itself Cc’d to stable (1/8 and 5/8 were)
- Precise behavior is already documented in propagate_umount.txt
- No user report of the docs bug
UNRESOLVED:
- lore.kernel.org HTTP fetch returned 403; thread was recovered with b4 dig
- Could not search lore.kernel.org/stable beyond a bot wall
- No Reviewed-by on 8/8 (unverified whether silent acks existed off- thread)
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — text matches propagate_umount() / propagate_umount.txt in this tree
2. Fixes a real bug that affects users? **PASS** — obsolete description of user-visible umount semantics (not a runtime bug)
3. Important issue (crash, security, corruption, deadlock)? **FAIL** as a runtime issue; **PASS** under the documentation exception
4. Small and contained? **PASS** — +14/−6, one rst file
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — context at v6.18.57 is identical
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: **Documentation fix** — correcting obsolete comments/docs. Zero runtime risk.
Step 9.4: MAKE YOUR DECISION
The rewrite this documents is already in 6.18.y, the overview is still wrong, and the patch is a tiny docs-only correction that applies cleanly. That is exactly the documentation exception. It should be backported to this tree.
Verification:
- [Phase 1] Parsed subject/tags: docs update; Link to patch 8/8 of work- mount-fixes; no Fixes/Reported-by/Cc:stable on this patch
- [Phase 1] Cover letter Cc’d stable; patches 1/8 and 5/8 had `Cc:
stable` in the body; 8/8 did not
- [Phase 2] Diff: Documentation/filesystems/sharedsubtree.rst +14/−6; section 5f only
- [Phase 3] git describe HEAD / Makefile: 6.18.57
- [Phase 3] git merge-base --is-ancestor f0d0ba19985d v6.18.57:
rewrite is in this tree
- [Phase 3] Blame: original text Ram Pai 2005; stale vs rewrite 2025-06
- [Phase 3] git show v6.18.57:Documentation/filesystems/sharedsubtree.rst: old “any sub- mounts” wording still present
- [Phase 4] b4 dig -c 3f5dc09141a7:
https://patch.msgid.link/20260923-work-mount-
[email protected]
- [Phase 4] b4 dig -a: v1 only, series of 8
- [Phase 4] b4 dig -w: vfs maintainers + linux-fsdevel
- [Phase 4] mbox: no NAK on 8/8; discussion was about 5/8
- [Phase 4] WebFetch lore: 403; UNVERIFIED beyond b4 mbox
- [Phase 5] Semcode unavailable; propagate_umount()/trim_one() in fs/pnode.c match the new wording
- [Phase 6] File at v6.18.57 identical to candidate pre-image (994 lines, empty diff) — clean apply
- [Phase 6] propagate_umount.txt exists at v6.18.57
- [Phase 7] Author is VFS maintainer in MAINTAINERS
- [Phase 8] Failure mode: stale umount-propagation docs; severity LOW runtime / docs exception
- UNVERIFIED: stable-list discussion beyond series headers
This is a small, obviously correct documentation fix for mount-namespace behavior that this tree already implements. Risk is zero.
**YES**
Documentation/filesystems/sharedsubtree.rst | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
Documentation/filesystems/sharedsubtree.rst +14 -6
@@ -564,8 +564,8 @@ f) Unmount semantics where 'A' is a mount mounted on mount 'B' at dentry 'b'. If mount 'B' is shared, then all most-recently-mounted mounts at dentry - 'b' on mounts that receive propagation from mount 'B' and does not have - sub-mounts within them are unmounted. + 'b' on mounts that receive propagation from mount 'B' are unmounted as + well, if every mount below them is also unmounted. Example: Let's say 'B1', 'B2', 'B3' are shared mounts that propagate to each other.
@@ -584,10 +584,18 @@ f) Unmount semantics So all 'C1', 'C2' and 'C3' should be unmounted. - If any of 'C2' or 'C3' has some child mounts, then that mount is not - unmounted, but all other mounts are unmounted. However if 'C1' is told - to be unmounted and 'C1' has some sub-mounts, the umount operation is - failed entirely. + If any of 'C2' or 'C3' has a child mount that cannot be unmounted + then that mount is not unmounted. But all other mounts are unmounted. + A child mount that is itself unmounted by the same unmount + propagation does not keep its parent mounted. However if 'C1' is + supposed to be unmounted and 'C1' has some sub-mounts, the unmount + fails. + + A lazy umount (MNT_DETACH) takes a whole tree. Every mount of the + tree then propagates its unmount from its own parent as described + above, so the mounts that receive propagation lose the corresponding + trees as well. Documentation/filesystems/propagate_umount.txt has the + precise rules, including the ones for locked mounts. g) Clone Namespace
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 mmc: cqhci: fix to missed endian conversions
In reply to Sasha LevinFrom: Ben Dooks <[email protected]>
[ Upstream commit 0aae2c73175821a71c0e20607f8e333be5b71940 ]
Fix two places where the wrong type or conversion of little-endian types to fix the following sparse warnings:
drivers/mmc/host/cqhci-core.c:487:15: warning: incorrect type in assignment (different base types)drivers/mmc/host/cqhci-core.c:487:15: expected restricted __le32 [usertype]drivers/mmc/host/cqhci-core.c:487:15: got intdrivers/mmc/host/cqhci-core.c:566:19: warning: incorrect type in assignment (different base types)drivers/mmc/host/cqhci-core.c:566:19: expected unsigned long long [usertype] *task_descdrivers/mmc/host/cqhci-core.c:566:19: got restricted __le64 [usertype] *
---
LLM Generated explanations, may be completely bogus:
This is a real missed little-endian conversion in CQHCI DMA descriptors, not a sparse-only cleanup. The local tree is mainline 7.3-rc4; the bug has been in this file since v4.16.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[mmc / cqhci] [fix] missed little-endian conversions on CQHCI descriptors**
**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:** Adrian Hunter \<[email protected]\> (CQHCI/SDHCI expert)
- **Link:** none in the commit; mailing-list thread recovered via b4 dig
- **Cc: stable:** none (not a negative signal here)
- **Signed-off-by:** Ben Dooks \<[email protected]\> (author); Ulf Hansson \<[email protected]\> (MMC maintainer). Ignore any Sasha Levin SOB.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug described:** two assignments use the wrong type / omit cpu_to_le* when writing __le32 / __le64 CQHCI descriptors.
- **Symptom in the message:** sparse type warnings only. No stack trace, no reproducer, no user report.
- **Failure mode implied by the code (not stated in the message):** on a big-endian CPU, transfer-descriptor attributes (including CQHCI_DAT_LENGTH) and DCMD task descriptors are stored in CPU byte order instead of the little-endian layout the CQHCI controller expects.
- **Version info:** none in the message.
- **Root cause as given:** missed endian conversion / wrong pointer type.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Yes, this is a hidden functional endian fix.** The subject says “fix” but the body only cites sparse. The same file already converts sibling descriptor fields with cpu_to_le32/cpu_to_le64. Omitting that on __le32 *attr and __le64 *task_desc is a hardware- descriptor bug on BE, not a warning-only cleanup.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** drivers/mmc/host/cqhci-core.c — 7 insertions, 7 deletions (14 lines touched).
- **Functions:** cqhci_set_tran_desc(), cqhci_prep_dcmd_desc().
- **Scope:** single-file surgical fix.
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Hunk 1 (cqhci_set_tran_desc):** before, *(__le32 *)attr was assigned a native int bitfield (VALID|END|INT|ACT|DAT_LENGTH). Address words already used cpu_to_le64/cpu_to_le32. After, the attribute word is wrapped in cpu_to_le32(). Path: every CQE data transfer descriptor (normal I/O path).
- **Hunk 2 (cqhci_prep_dcmd_desc):** before, task_desc was u64 * and *task_desc |= data mixed a CPU-endian u64 into memory obtained as __le64. After, task_desc is __le64 * and the OR uses cpu_to_le64(data). Path: CQE direct commands (DCMD), e.g. cache flush / status when MMC_CAP2_CQE_DCMD is set.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Type / endianness]** CQHCI descriptors in memory are little- endian. CQHCI_DAT_LENGTH lives in bits 16–31; DCMD CMD_INDEX/CMD_TIMING/RESP_TYPE live in bits 16–24. Those fields do not fit in byte 0, so a native store is wrong on BE. The controller would see a swapped length and scrambled DCMD opcode/timing. The fix is the same conversion already used in cqhci_prep_task_desc() (task_desc[0] = cpu_to_le64(desc0)).
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct and minimal. On little-endian, cpu_to_le32/cpu_to_le64 are no-ops, so the common CQHCI population does not change. Regression risk is very low. No API, locking, or structure-layout change. update_dcmd_desc still mutates the CPU-endian u64 data before conversion (Tegra’s callback is consistent with that).
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: Buggy assignments come from **a4080225f51dce** (“mmc: cqhci:
support for command queue enabled host”, Venkat Gopalakrishnan, 2017-11-29), first in **v4.16-rc1**. Address-field conversions were already present then; the attribute/DCMD stores were the miss. Code has been in-tree for many years.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The introducing commit is a4080225f51dce (v4.16). Intermediate related work: **ee49d0321f025** (Eric Biggers, 2021) converted cqhci_prep_task_desc() to __le64 * + cpu_to_le64 and did not fix DCMD / transfer-attr stores.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent cqhci-core.c work is halt/recovery/callback related, not endian. Not a numbered series. Standalone.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Ben Dooks is a regular MMC endian/sparse contributor (dw_mmc LE descriptor fixes, endian-agnostic IO). Not the MMC maintainer. Ulf Hansson applied it; Adrian Hunter acked it.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: No functional prerequisite. cqhci_set_tran_desc was exported in **52bf134fca61f** (v6.11) for DWCMSHC; the body bug is independent of that. File rename cqhci.c → cqhci-core.c (**0653300224a69**) is a path tweak only for older trees. Can apply standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- Lore URL from b4 dig -c 0aae2c73175821: https://patch.msgid.link/202
[email protected]
- **Series:** v1 only (b4 dig -a). Applied version is that v1.
- **Review:** Adrian Hunter Acked-by. Ulf Hansson: “Applied for next, thanks!”
- **NAKs / stable nominations:** none in the thread.
- WebFetch of lore.kernel.org returned 403; thread was read from b4 dig -m mbox instead.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc included Adrian Hunter, Asutosh Das, Ritesh Harjani, Ulf Hansson, linux-mmc, linux-kernel. Right maintainers were on the original mail.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by, bugzilla, or syzbot link. Trigger was sparse, not a user crash report.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone single patch. Not 2/N.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** (lore.kernel.org/stable WebFetch 403). Original thread did not mention stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: cqhci_set_tran_desc, cqhci_prep_dcmd_desc. Callers also
involved: cqhci_prep_tran_desc, cqhci_request, dwcmshc_set_tran_desc.
**Step 5.2: TRACE CALLERS**
Record:
- cqhci_set_tran_desc: cqhci_prep_tran_desc (default), dwcmshc_set_tran_desc in sdhci-of-dwcmshc.c (Rockchip/DWC MSHC).
- cqhci_prep_dcmd_desc: cqhci_request() when !mrq->data.
- cqhci_request is .cqe_request — MMC command-queue I/O, not init- only.
**Step 5.3: TRACE CALLEES**
Record: Bitfield macros, get_desc(), optional update_dcmd_desc (Tegra only), cpu_to_le32/cpu_to_le64. No alloc/lock changes.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace block I/O on CQE eMMC → MMC core → cqe_request → descriptor prep → doorbell. Reachable on any CQHCI host (Qualcomm, i.MX, Tegra, MTK, Broadcom STB, Arasan, Intel GLK, TI AM654, Rockchip DWCMSHC, etc.). BE vs LE is a kernel endian config, not a separate code path.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: cqhci_prep_task_desc already converts correctly. setup_trans_desc() still writes VALID|ACT|END through a u8 *; those bits fit in byte 0, so a LE controller still sees the correct LSB regardless of CPU endianness. The two sites this patch touches are the ones that put multi-byte fields into __le32/__le64 words.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: This checkout is **v7.3-rc4** (7.3.0-rc4, HEAD f0100363d8c37, origin/master). Commit **0aae2c73175821 is already an ancestor of HEAD** (merged in mmc-v7.3). Pre-fix code is in 0aae2c73^. The unconverted stores existed from v4.16 until this commit. The bug is in this tree’s history and in any stable series that still has the old assignments.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply on this tree (already applied). Older stables may still name the file cqhci.c and may still have a static cqhci_set_tran_desc; that is a trivial context/path adjustment, not a semantic rework.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No earlier equivalent DCMD/attr conversion. ee49d0321f025 only fixed cqhci_prep_task_desc.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **MMC host / CQHCI** (drivers/mmc/host/). **IMPORTANT** — eMMC command queue on widely used SoCs and some PCI hosts. Not core mm/VFS, not staging.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained (halt, recovery, crypto, DWCMSHC callbacks). CQHCI itself is mature (2017).
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: CQHCI users on **big-endian** kernels. In-tree supports-cqe DT is ARM64 (Qualcomm, Rockchip, Tegra, …). ARM64 has CONFIG_CPU_BIG_ENDIAN. No MIPS supports-cqe DT. Little-endian CQHCI (the usual phone/board case) is unaffected.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Any CQE data transfer (cqhci_set_tran_desc) or DCMD (cqhci_prep_dcmd_desc) on BE. Common path if CQE is enabled. Not a race. Unprivileged I/O can exercise it if the device is mounted/accessible.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Wrong LE descriptor in DMA memory → controller misreads length / DCMD fields → **I/O failure and possible data corruption**. **Severity:
HIGH** on BE CQHCI; **none** on LE.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record: **Benefit:** high for BE CQHCI (makes CQE descriptors spec- correct); none for LE. **Risk:** very low (7 lines, LE no-op, no locking/API). **Ratio:** favorable. This is the usual justification for descriptor endian fixes in stable.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR backporting:**
- Real missed cpu_to_le* on hardware DMA/task descriptors, present since v4.16.
- Sibling cqhci_prep_task_desc and the address fields in the same function already convert; these two stores were the hole.
- On BE, DAT_LENGTH and DCMD opcode/timing/response type would be byte-swapped → CQE malfunction / corruption risk.
- 7-line, obviously correct, LE no-op.
- Acked by Adrian Hunter; applied by Ulf Hansson.
- Matches the endianness/type-bug class used in stable.
**AGAINST backporting:**
- Commit text only mentions sparse; no user report, no Fixes:, no `Cc:
stable`.
- Typical CQHCI hardware is ARM64/x86 LE, so most stable users see no runtime change.
- Author did not describe a user-visible failure.
**UNRESOLVED:**
- Whether this was discussed on stable@ (lore 403).
- Whether any production BE CQHCI board is in the wild (in-tree CQE DT is ARM64; ARM64 BE exists but is uncommon).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — mechanical cpu_to_le* to match existing descriptor stores; maintainer ack.
2. Fixes a real bug that affects users? **PASS** — wrong CQHCI descriptor endianness on BE is a real protocol/hardware bug, not whitespace.
3. Important issue? **PASS** — wrong transfer length / DCMD fields can break CQE I/O or corrupt data. Sparse is how it was found, not the user-visible impact.
4. Small and contained? **PASS** — 7 lines, one file, two functions.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — already present on this 7.3-rc4 tree; the pre-fix pattern is the long-standing one.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/docs exception. Closest adjacent class is **endianness correctness** (and incidentally a sparse warning). Not a reason to reject.
**Step 9.4: MAKE YOUR DECISION**
The local tree is mainline **7.3.0-rc4**, which already contains the fix. The evaluation is whether that fix should also be selected for
stable: the buggy stores have been in CQHCI since **v4.16**, the change is self-contained, and it corrects hardware-visible descriptors. Sparse was the detector; the bug is endian-incorrect DMA descriptors. Risk on the LE majority is zero. That is appropriate for stable.
===============================================================
What the commit solves and why it matters
===============================================================
CQHCI transfer and DCMD descriptors are little-endian in memory. Two writes used native CPU values: transfer attributes (VALID/END/ACT/DAT_LENGTH) and the DCMD task word. On big-endian that swaps the length and command fields the controller DMA-reads, so command-queue I/O can fail or transfer the wrong size. Little-endian kernels are unchanged. The patch is small, already reviewed by the CQHCI expert, and needs no extra commits.
Risk vs benefit: very low risk, real correctness fix for BE CQHCI, no behavior change for typical LE devices.
===============================================================
Verification
===============================================================
- [Phase 1] Parsed commit 0aae2c73175821: Acked-by Adrian Hunter; SOB Ben Dooks, Ulf Hansson; no Fixes/Reported-by/Cc: stable.
- [Phase 2] Diff: 7+/-7 in cqhci_set_tran_desc and cqhci_prep_dcmd_desc only.
- [Phase 2] Confirmed CQHCI_DAT_LENGTH is bits 16–31 and DCMD fields are bits 16+ in cqhci.h.
- [Phase 2] Pre-fix parent still assigned native ints/u64 into __le* memory; addresses already used cpu_to_le*.
- [Phase 3] git blame: buggy code from a4080225f51dce (v4.16-rc1).
- [Phase 3] cqhci_prep_task_desc conversion added in ee49d0321f025 (2021); DCMD/attr left unconverted.
- [Phase 3] Author history on drivers/mmc/: several real dw_mmc endian fixes.
- [Phase 3] git merge-base --is-ancestor 0aae2c73175821 HEAD → commit is in this tree.
- [Phase 4] b4 dig -c/-a/-w/-m: v1-only thread; Hunter ack; Ulf “Applied for next”; lists linux-mmc + Hunter/Hansson.
- [Phase 4] lore WebFetch 403; used local mbox. Stable@ search UNVERIFIED (403).
- [Phase 5] Callers: cqhci_request → prep_tran_desc/prep_dcmd_desc; dwcmshc_set_tran_desc calls cqhci_set_tran_desc.
- [Phase 5] No semcode MCP; used git grep.
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4.
- [Phase 6] Fix merged via f96718fc1f614 (mmc-v7.3).
- [Phase 6] In-tree supports-cqe is ARM64-only; no MIPS matches.
- [Phase 7] CQHCI selected by MSM, i.MX, Tegra, MTK, brcmstb, Arasan, DWCMSHC, AM654, SDHCI PCI.
- [Phase 8] Failure mode: BE descriptor corruption → CQE I/O failure / possible data corruption; LE no-op.
- UNVERIFIED: production BE CQHCI user reports; stable@ discussion.
The patch is small, obviously correct, and fixes a real hardware- descriptor endian bug that has been in this tree’s CQHCI code since v4.16.
**YES**
drivers/mmc/host/cqhci-core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/mmc/host/cqhci-core.c +7 -7
@@ -484,11 +484,11 @@ void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool end, {__le32 *attr = (__le32 __force *)desc; - *attr = (CQHCI_VALID (1 ) | -CQHCI_END (end ?1 :0 ) | -CQHCI_INT (0 ) | -CQHCI_ACT (0x4 ) | -CQHCI_DAT_LENGTH (len)); + *attr =cpu_to_le32 ((CQHCI_VALID (1 ) | +CQHCI_END (end ?1 :0 ) | +CQHCI_INT (0 ) | +CQHCI_ACT (0x4 ) | +CQHCI_DAT_LENGTH (len)));if (dma64) {__le64 *dataddr = (__le64 __force *)(desc +4 );
@@ -542,7 +542,7 @@ static int cqhci_prep_tran_desc(struct mmc_request *mrq,static void cqhci_prep_dcmd_desc (struct mmc_host *mmc,struct mmc_request *mrq) { -u64 *task_desc =NULL ; +__le64 *task_desc =NULL ;u64 data =0 ;u8 resp_type;u8 *desc;
@@ -574,7 +574,7 @@ static void cqhci_prep_dcmd_desc(struct mmc_host *mmc, CQHCI_CMD_TIMING(timing) | CQHCI_RESP_TYPE(resp_type));if (cq_host->ops->update_dcmd_desc) cq_host->ops->update_dcmd_desc (mmc, mrq, &data); - *task_desc |= data; + *task_desc |=cpu_to_le64 (data); desc = (u8 *)task_desc;pr_debug ("%s: cqhci: dcmd: cmd: %d timing: %d resp: %d\n" ,mmc_hostname (mmc), mrq->cmd->opcode, timing, resp_type);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ext4: use FGP_WRITEBEGIN for tail block zeroing
In reply to Sasha LevinFrom: Zhang Yi <[email protected]>
[ Upstream commit e1cf7b5f5c8ad1e00d00c50c61c3e8fdc79cd422 ]
ext4_load_tail_bh() returns a locked folio that callers immediately mutate through folio_zero_range() and mark_buffer_dirty(). Use FGP_WRITEBEGIN so that, on backing devices that require stable writes, __filemap_get_folio() waits for writeback to finish before returning the folio; on regular devices the wait is a no-op.
---
LLM Generated explanations, may be completely bogus:
I have enough to decide: this is a one-line stable-writes data-integrity fix in a userspace-reachable ext4 tail-zeroing path, and the helper and FGP_WRITEBEGIN both exist in this 7.3-rc4 tree.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[ext4] [use] use FGP_WRITEBEGIN for tail block zeroing**
Subsystem prefix ext4:. Verb is “use” (correctness change of folio-get flags, not a feature). Claimed intent: get the tail folio with the write-begin flag set so writeback finishes before the folio is mutated.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Verified from git show e1cf7b5f5c8ad1e00d00c50c61c3e8fdc79cd422:
- **Fixes:** none (expected for this review pipeline)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** Jan Kara \<[email protected]\> (ext4 co-maintainer)
- **Acked-by:** none
- **Link:** https://patch.msgid.link/20260714080044.4038124-2-
[email protected]
- **Cc: stable:** none (expected; not a negative signal)
- **Signed-off-by:** Zhang Yi \<[email protected]\> (author); Theodore Ts'o \<[email protected]\> (ext4 maintainer)
No syzbot, no kernel-test-robot, no multiple reporters.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** ext4_load_tail_bh() returns a locked folio that callers immediately mutate with folio_zero_range() and mark_buffer_dirty(), without waiting for in-flight writeback.
- **Symptom/failure mode:** On backing devices that require stable writes, page-cache contents can change while DMA/writeback is in progress, which can corrupt the in-flight write or break integrity checksums. On ordinary devices the extra wait is a no-op.
- **Version information:** none in the message. History shows the helper landed in v7.1-rc1 and this fix in v7.3-rc1.
- **Root cause:** folio obtained with FGP_LOCK | FGP_ACCESSED | FGP_CREAT (no FGP_STABLE / FGP_WRITE).
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Yes, this is a real bug fix**, not cleanup. The cover letter for the series (v4) states it explicitly: “Add patch 1 to use FGP_WRITEBEGIN in ext4_load_tail_bh(), fixing a pre-existing stable- writes bug exposed by patch 4's reordering.”
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: fs/ext4/inode.c — **1 insertion, 1 deletion**
- Function: ext4_load_tail_bh()
- Scope: **single-file surgical fix** (one flag expression)
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
**Before:** __filemap_get_folio(..., FGP_LOCK | FGP_ACCESSED | FGP_CREAT, ...). Locks/creates the folio and marks it accessed. Does **not** wait for writeback.
**After:** __filemap_get_folio(..., FGP_WRITEBEGIN | FGP_ACCESSED, ...).
FGP_WRITEBEGIN is defined in include/linux/pagemap.h as:
FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE
Net additions: FGP_WRITE and FGP_STABLE. FGP_STABLE calls folio_wait_stable() after the folio is locked (mm/filemap.c). That waits for writeback only if mapping_stable_writes() is set.
Path affected: every caller of ext4_load_tail_bh() immediately zeros the folio (ext4_block_do_zero_range(), ext4_block_journalled_zero_range()). This is a **normal mutator path**, not an error-only path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** memory-safety / data integrity (stable-pages race with writeback), plus a small GFP/idle-flag side effect from FGP_WRITE
- **Mechanism:** On AS_STABLE_WRITES mappings, in-flight writeback DMA’s from page cache. Zeroing the folio without folio_wait_stable() can mix old and new contents in the I/O. FGP_WRITEBEGIN is the established write-begin flag set that waits first.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Quality:** obviously correct. Same flags every ->write_begin implementation uses. folio_wait_stable() is a no-op when mapping_stable_writes() is false, so typical disks are unchanged.
- **Regression risk:** very low. Waiting while the folio is locked is the documented write-begin pattern (folio_wait_stable comment: if unlocked, writeback can restart). FGP_ACCESSED | FGP_WRITEBEGIN still takes the FGP_ACCESSED branch in __filemap_get_folio(), so idle-flag clearing does not change vs the old flags; FGP_WRITE only adds __GFP_WRITE on allocation.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Current line is e1cf7b5f5c8ad (this commit).
- Same flags were already in __ext4_block_zero_page_range() before the helper was factored out (3b312a6f510ca, v7.1-rc1, “ext4: factor out journalled block zeroing range”).
- Folio conversion 9d3973de9a374 (“ext4: Convert __ext4_block_zero_page_range() to use a folio”, v6.4 era) replaced find_or_create_page() with FGP_LOCK | FGP_ACCESSED | FGP_CREAT. find_or_create_page() also did **not** wait for stable writeback, so the gap is older than the helper.
- Helper ext4_load_tail_bh first appeared in **v7.1-rc1** (3b312a6f510ca).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Not applicable. The immediate pre-image is the helper as introduced in 3b312a6f510ca, which copied the old flags.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: This is **patch 1/9** of Zhang Yi’s series “ext4: fix unaligned edge handling in FALLOC_FL_WRITE_ZEROES”, landed together around 2026-07-22:
1. e1cf7b5f5c8ad this commit
2. 2fff82f081401 skip tail zeroing for inline data
3. 705a3fd3bac16 check ext4_get_block() return
4. b16e9d27a643a move partial zeroing earlier in ext4_zero_range() (the reorder that **exposes** the stable-writes bug)
5–9. WRITE_ZEROES edge-handling / orphan-list work
This patch does **not** depend on 2–9. Later patches that increase tail- zeroing (especially 4) depend on this one for correctness on stable- write devices.
Related earlier commit df0b5afc62f33 (“ext4: remove the redundant folio_wait_stable()”) is a different path (ext4_da_write_begin); it only shows that ext4 already treats FGP_WRITEBEGIN as implying the stable wait.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Zhang Yi is a regular, high-volume ext4 contributor (tail- zeroing, WRITE_ZEROES, journal paths). This series was reviewed by Jan Kara and applied by Ted Ts'o. Related commits in the same week are the rest of the 1/9 series.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record:
- Prerequisite API: FGP_WRITEBEGIN from e999a5c5a19cf (“fs: Add FGP_WRITEBEGIN”), present since **v6.4-rc1**. Present in this tree.
- Prerequisite function: ext4_load_tail_bh() since **v7.1-rc1**. Present in this tree.
- **Can apply standalone:** yes. One flag change; no new helpers.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c e1cf7b5f5c8ad → https://patch.msgid.link/20260714080044.40
[email protected]
- Series revisions: **v3** (2026-07-08) and **v4** (2026-07-14). Cover
letter: v4 has **no code changes** vs v3; v2 **added this patch**.
- Cover letter quote (verified in saved mbox): “Add patch 1 to use FGP_WRITEBEGIN in ext4_load_tail_bh(), fixing a pre-existing stable- writes bug exposed by patch 4's reordering.”
- Ted Ts'o applied the series; patch 9 was dropped separately over error-handling concerns.
- No NAK on this patch. No reviewer asked for Cc: stable on patch 1 (patches 7/8 in the same mbox do have Cc: stable, for WRITE_ZEROES- specific bugs).
- WebFetch of lore.kernel.org returned **403**; discussion recovered via b4 dig -m /tmp/ext4-fgp.mbox.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
b4 dig -w recipients included linux-ext4, linux-fsdevel, tytso, adilger, Jan Kara, Ojaswin Mujoo, Ritesh Harjani, Huawei ext4 developers.
Record: **Jan Kara Reviewed-by** (in the patch); **Ted Ts'o** applied it. Right maintainers were on the thread.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: **No standalone bugzilla/syzbot report.** The bug was found while reworking WRITE_ZEROES unaligned edges. Severity from the author:
pre-existing **stable-writes data-integrity** bug.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone as a fix. The rest of 1/9 is WRITE_ZEROES contract work and two other pre-existing helper fixes (inline-data skip; propagate ext4_get_block() errors). This commit does not require those to be correct.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable WebFetch returned **403**. No evidence in the ext4 thread that this patch 1 was requested for stable or rejected for stable. **UNVERIFIED** whether linux-stable@ discussed it.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: **ext4_load_tail_bh()** only.
**Step 5.2: TRACE CALLERS**
Verified in this tree:
- ext4_block_do_zero_range() → folio_zero_range() + mark_buffer_dirty()
- ext4_block_journalled_zero_range() → journal write access + folio_zero_range()
- Both from ext4_block_zero_range()
- That is used by:
- ext4_block_zero_eof() — truncate (ext4_truncate), append (ext4_write_checks in fs/ext4/file.c), extent operations (fs/ext4/extents.c)
- ext4_zero_partial_blocks() — punch hole / zero_range / WRITE_ZEROES (ext4_punch_hole, ext4_zero_range, extents WRITE_ZEROES)
Record: **Common filesystem operations**, process context, folio locked. Not IRQ.
**Step 5.3: TRACE CALLEES**
Record: __filemap_get_folio() → on FGP_STABLE, folio_wait_stable() → folio_wait_writeback() if mapping_stable_writes(). Then create_empty_buffers / ext4_get_block / ext4_read_bh_lock as before.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: **Userspace-reachable** without privilege beyond write access to an ext4 file: truncate, fallocate(PUNCH_HOLE|ZERO_RANGE|WRITE_ZEROES), append write(). **HIGH** reachability.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Other ext4 write paths already use FGP_WRITEBEGIN (fs/ext4/inline.c, fs/ext4/move_extent.c) and/or explicit folio_wait_stable() (ext4_write_begin, ext4_page_mkwrite). Tail- block zeroing was the outlier.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record:
- Local tree: **git describe HEAD = v7.3-rc4-27-gf0100363d8c37**, VERSION=7 PATCHLEVEL=3 SUBLEVEL=0 EXTRAVERSION=-rc4. Origin is torvalds/linux (mainline), detached HEAD.
- ext4_load_tail_bh() exists at fs/ext4/inode.c (currently already using FGP_WRITEBEGIN | FGP_ACCESSED because e1cf7b5f5c8ad **is an ancestor of HEAD**).
- Buggy pre-image (helper with FGP_LOCK | FGP_ACCESSED | FGP_CREAT) existed from **v7.1-rc1** (3b312a6f510ca) until this fix in **v7.3-rc1**.
- FGP_WRITEBEGIN exists here (include/linux/pagemap.h:720).
The pipeline instruction is to ignore “already selected” markers, not to treat mainline already containing the original commit as a reason to reject a backport-worthy fix. The code and prerequisites are in this tree.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** on this tree (one-line flag change; FGP_WRITEBEGIN present). git log --oneline -10 -- fs/ext4/inode.c shows normal ext4 churn; nothing that would conflict with this hunk.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This exact change **is** HEAD’s current code (git blame on the flags line is e1cf7b5f5c8ad). No alternate fix for the same stable- writes hole in ext4_load_tail_bh(). Other folio_wait_stable() sites in ext4 do not cover this helper.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **Subsystem: fs/ext4. Criticality: IMPORTANT** (widely used filesystem; data-integrity on stable-write devices). Not core mm/VFS, but truncate/punch/zero are universal ext4 operations.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: **Actively developed** (WRITE_ZEROES series, iomap conversion, journal/writeback fixes in 7.3). The helper itself is recent (v7.1) but the missing stable wait is the same pattern as the older zero-page-range code.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **ext4 users whose backing device requires stable writes**, i.e. bdev_stable_writes(): integrity checksums (CONFIG_BLK_DEV_INTEGRITY) **or** BLK_FEAT_STABLE_WRITES.
Verified setters of BLK_FEAT_STABLE_WRITES in this tree include NVMe (when data_digest is enabled), RAID5 skip_copy, dm-integrity, zram, RBD, iSCSI TCP, MMC, DRBD. Superblock then sets SB_I_STABLE_WRITES and inode mappings get AS_STABLE_WRITES.
Not universal, but not a toy config: enterprise integrity, RAID, dm- integrity, some NVMe.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Trigger: tail/partial-block zeroing while that folio is under writeback.
- How common: truncate, punch, zero_range, append past EOF — **routine**. The race still needs concurrent writeback of that folio, so it is **timing-dependent**.
- Cover letter: patch 4’s reorder **widens** the window; the bug is still pre-existing without patch 4. This tree **already has patch 4** (b16e9d27a643a).
- Unprivileged users with write access **can** trigger the operations.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Failure mode: in-flight writeback sees torn folio contents / integrity checksum mismatch.** **Severity: CRITICAL** (data corruption), limited to stable-write devices. Not a panic path.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit: high** for ext4 on stable-write devices (prevents silent data corruption on common ops). **Low** for everyone else (wait is a no-op).
- **Risk: very low** (1 line, standard flags, no API change, no new locking order).
- **Ratio: strongly favors applying.**
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR backporting:**
- Author and cover letter call it a **pre-existing stable-writes bug**.
- Mutating a folio under writeback on AS_STABLE_WRITES is a known class of **data corruption**.
- Reachable from truncate / fallocate / append.
- One-line, matches FGP_WRITEBEGIN used everywhere else.
- Reviewed by Jan Kara; applied by Ted Ts'o.
- FGP_WRITEBEGIN and ext4_load_tail_bh() both exist in this 7.3-rc4 tree.
- This tree also has the later reorder (b16e9d27a643a) that **exposes** the race more.
**AGAINST backporting:**
- No Fixes tag, no user/syzbot report (not a valid NO by pipeline rules).
- Nested in a 9-patch WRITE_ZEROES series; later patches are feature- contract fixes. This patch is still self-contained.
- Author did not Cc: stable on patch 1 (other patches in the same series did).
- Bug existed in spirit since find_or_create_page(); field reports are absent, so the race may be rare without the v7.3 reorder.
**UNRESOLVED:**
- linux-stable@ archives could not be fetched (HTTP 403).
- Full v2 mailing-list review text for this hunk was not retrieved (lore 403); Jan’s Reviewed-by on the committed patch is verified.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — one flag change to the standard write-begin set; reviewed by Jan Kara; in mainline since v7.3-rc1.
2. Fixes a real bug that affects users? **PASS** — stable-writes devices (NVMe digest, RAID5 skip_copy, dm-integrity, zram, T10 PI, etc.).
3. Important issue? **PASS** — data corruption on in-flight writeback, not a crash, but explicitly in the stable rules list.
4. Small and contained? **PASS** — 1 line, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — FGP_WRITEBEGIN and ext4_load_tail_bh() are here; the hunk is identical to what already landed.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **None** (not a device ID, quirk, DT, build, or docs exception). It qualifies as a normal data-integrity bug fix.
**Step 9.4: MAKE YOUR DECISION**
This tree is **Linux 7.3-rc4** (Linus mainline). The helper lives here, FGP_WRITEBEGIN lives here, and callers still zero the folio immediately. The change is a one-line restoration of the stable-write wait that every other write-begin path already does. That is exactly the kind of small, important data-integrity fix stable trees should take. The surrounding WRITE_ZEROES series is not required for this hunk to be correct.
### What the commit solves
ext4_load_tail_bh() was grabbing a locked folio without FGP_STABLE. Callers then call folio_zero_range() and dirty the buffer. On devices that set AS_STABLE_WRITES (integrity checksums or BLK_FEAT_STABLE_WRITES), that can change page-cache bytes while writeback DMA is still running. Switching to FGP_WRITEBEGIN | FGP_ACCESSED waits for writeback first; elsewhere the wait is a no-op.
### Stable rules / risk vs benefit
Meets all six stable criteria. Benefit is preventing filesystem data corruption on a real (if not universal) device class; risk is a single established flag combination.
### Concerns
- Nested in a larger series, but this patch is standalone.
- No field report; the author found it while reordering zeroing. Still a concrete integrity bug, and this tree already contains the reorder that widens it.
- Lore stable-list search was blocked (403); that does not change the code-level conclusion.
Verification:
- [Phase 1] Parsed tags from git show e1cf7b5f5c8ad: Reviewed-by Jan Kara; Link msgid ...4038124-2...; no Fixes/Reported-by/Cc:stable
- [Phase 1] Cover letter in /tmp/ext4-fgp.mbox msg 5: “pre-existing stable-writes bug exposed by patch 4's reordering”
- [Phase 2] Diff: 1 line in ext4_load_tail_bh(); flags FGP_LOCK|FGP_ACCESSED|FGP_CREAT → FGP_WRITEBEGIN|FGP_ACCESSED
- [Phase 2] FGP_WRITEBEGIN = FGP_LOCK|FGP_WRITE|FGP_CREAT|FGP_STABLE (include/linux/pagemap.h:720)
- [Phase 2] __filemap_get_folio calls folio_wait_stable() when FGP_STABLE (mm/filemap.c:1986-1987)
- [Phase 2] folio_wait_stable() only waits if mapping_stable_writes() (mm/page-writeback.c:3105-3108)
- [Phase 3] git describe --contains --match 'v7.*' 3b312a6f510ca → v7.1-rc1 (helper introduced)
- [Phase 3] git describe --contains --match 'v7.*' e1cf7b5f5c8ad → v7.3-rc1 (this fix)
- [Phase 3] git merge-base --is-ancestor e1cf7b5f5c8ad HEAD true; 3b312a6f510ca also ancestor
- [Phase 3] git show 9d3973de9a374: folio conversion used the same non-stable flags; previously find_or_create_page()
- [Phase 3] git show 3b312a6f510ca: factor-out copied those flags into ext4_load_tail_bh()
- [Phase 4] b4 dig -c e1cf7b5f5c8ad: lore URL; v3 then v4; v4 no code change
- [Phase 4] b4 dig -w: linux-ext4, tytso, Jan Kara, adilger, Ojaswin, Ritesh on Cc
- [Phase 4] b4 dig -m /tmp/ext4-fgp.mbox: Ted applied 1–8; patch 9 dropped; no NAK on patch 1
- [Phase 4] WebFetch lore.kernel.org 403 — UNVERIFIED stable-list discussion
- [Phase 5] Callers: ext4_block_do_zero_range / ext4_block_journalled_zero_range → ext4_block_zero_range → ext4_block_zero_eof / ext4_zero_partial_blocks (truncate, punch, zero_range, WRITE_ZEROES, append)
- [Phase 5] Other ext4 write paths already use FGP_WRITEBEGIN or folio_wait_stable()
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; Makefile 7.3.0-rc4
- [Phase 6] Current fs/ext4/inode.c:4042-4043 already has FGP_WRITEBEGIN | FGP_ACCESSED
- [Phase 7] fs/ext4, important filesystem
- [Phase 8] bdev_stable_writes() = integrity csum OR BLK_FEAT_STABLE_WRITES (include/linux/blkdev.h:1410-1414)
- [Phase 8] BLK_FEAT_STABLE_WRITES set by nvme (data_digest), raid5 skip_copy, dm-integrity, zram, rbd, iscsi_tcp, mmc, drbd
- [Phase 8] Failure: data corruption on stable-write devices; wait is no-op otherwise
- UNVERIFIED: linux-stable mailing list history (HTTP 403)
- UNVERIFIED: full v2 review mail body for this hunk (lore 403); Reviewed-by on the commit is verified
**YES**
fs/ext4/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inode.c +1 -1
@@ -4092,7 +4092,7 @@ static int __ext4_block_zero_page_range(handle_t *handle,int err =0 ; folio =__filemap_get_folio (mapping, from >>PAGE_SHIFT , -FGP_LOCK |FGP_ACCESSED |FGP_CREAT , +FGP_WRITEBEGIN |FGP_ACCESSED ,mapping_gfp_constraint (mapping, ~__GFP_FS));if (IS_ERR (folio))return PTR_ERR (folio);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-6.6] ext4: use FGP_WRITEBEGIN for tail block zeroing
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines
From: Zhang Yi <[email protected]>
[ Upstream commit
e1cf7b5f5c8ad1e00d00c50c61c3e8fdc79cd422]
ext4_load_tail_bh()returns a locked folio that callers immediately mutate throughfolio_zero_range()andmark_buffer_dirty(). UseFGP_WRITEBEGINso that, on backing devices that require stable writes,__filemap_get_folio()waits for writeback to finish before returning the folio; on regular devices the wait is a no-op.
Quoted 5 lines
Signed-off-by Zhang Yi <[email protected]>Reviewed-by Jan Kara <[email protected]>Signed-off-by Theodore Ts'o <[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 RDMA/irdma: Suppress PF reset on HMC error
In reply to Sasha LevinFrom: Seyeong Kim <[email protected]>
[ Upstream commit 4dc9c884c0aafac1e8d37536d88d485135e26883 ]
The irdma driver currently issues an unconditional PF reset whenever the HMC Error interrupt (PFINT_OICR bit 26) fires:
if (event->reg & IRDMAPFINT_OICR_HMC_ERR_M) {
ibdev_err(&iwdev->ibdev, "HMC Error\n");
iwdev->rf->reset = true;
}request_reset() issues an IIDC_PFR to ice. In practice a single HMC_ERR can trigger cascading PF resets, IOMMU faults during teardown, and teardown of every RDMA connection on the device.
i40e handles the identically-named interrupt by reading PFHMC_ERRORINFO and PFHMC_ERRORDATA and logging them without touching device state; see commit 9c010ee0ea5f ("i40e: Suppress HMC error to Interrupt message level") which removed the reset as "not necessary". This patch mirrors that handling on irdma.
With this change, repeated HMC_ERR no longer produces a reset storm and RDMA traffic on the device continues uninterrupted.
---
LLM Generated explanations, may be completely bogus:
The local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The irdma GEN2 HMC-error path exists here, and this change is a real production fix for Intel E810 PF-reset storms. Analysis below is for this tree only.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[RDMA/irdma] [Suppress] [stop issuing a PF reset when the HMC Error interrupt fires]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected for this review)
- **Reported-by:** none in the commit message
- **Tested-by:** none tagged (author did describe hardware testing in the RFC/v2 cover)
- **Reviewed-by / Acked-by:** none
- **Link:** https://patch.msgid.link/20260619050044.1807044-1- [email protected]
- **Cc: stable:** none (expected)
- **Signed-off-by:** Seyeong Kim (author); Leon Romanovsky (RDMA maintainer). The pipeline’s “Sasha Levin” SOB is ignored.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** icrdma_iidc_event_handler() sets iwdev->rf->reset = true on IRDMAPFINT_OICR_HMC_ERR_M (PFINT_OICR bit 26). That calls request_reset() → ice_rdma_request_reset(..., IIDC_FUNC_RESET) → ICE_RESET_PFR.
- **Symptom:** cascading PF resets, IOMMU/DMAR faults during teardown, every RDMA connection on the device torn down. On newer NVM a single forced HMC_ERR still caused a full PF reset and aborted RDMA traffic.
- **Root cause (author):** HMC_ERR was treated as fatal; i40e stopped resetting on the same interrupt in 9c010ee0ea5f (“reset that was not necessary”).
- **Version info:** author tested Ubuntu 6.8 (NVM 3.10, cascading resets
+ DMAR) and mainline 7.1-rc4 (NVM 4.51, single reset). Driver path has existed since irdma GEN2 was added.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not hidden.** This is an explicit error-handling fix: stop a destructive reset. Diagnostic MMIO reads are extra, not a cleanup disguised as a fix.
===============================================================
PHASE 2: DIFF ANALYSIS
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- drivers/infiniband/hw/irdma/icrdma_if.c: HMC_ERR branch (stop reset; log errinfo/errdata)
- drivers/infiniband/hw/irdma/irdma.h: IRDMA_PFHMC_ERRORINFO, IRDMA_PFHMC_ERRORDATA before IRDMA_MAX_REGS
- drivers/infiniband/hw/irdma/icrdma_hw.h / icrdma_hw.c: GEN2 offsets 0x00520400 / 0x00520500
- drivers/infiniband/hw/irdma/i40iw_hw.c: matching 0xffffffff placeholders so GEN1 array length still matches the enum
**+15 / −3**, five files. **Surgical, single-subsystem.** Function:icrdma_iidc_event_handler.
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: **Before:** HMC_ERR → ibdev_err("HMC Error") → rf->reset = true → request_reset(). **After:** HMC_ERR → readl ERRORINFO/ERRORDATA → ibdev_warn → **do not set reset**. PE_CRITERR (except Q1 resource check) and PE_PUSH still reset.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Logic / hardware-error handling (over-aggressive recovery).** Unconditional PF reset on a non-fatal (or at least non-reset-worthy) interrupt causes reset storms, aux unplug, IOMMU faults, and full RDMA teardown. Fix: log-only, matching i40e. ice itself already only *forwards* HMC_ERR to the aux driver and does not reset on that bit.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Core change (clear rf->reset = true) is obviously correct relative to i40e/ice. Diagnostic register plumbing is extra; offsets were **inferred** from PFHMC_PDINV (+0x100/+0x200), same spacing as i40e’s PDINV/ERRORINFO/ERRORDATA. Forced-interrupt tests read back 0, so offsets are unverified against a datasheet, but they are **read-only** and not the recovery change. GEN1/GEN2 arrays were updated together; GEN3/GEN4 use ig3rdma_init_hw() and do not index IRDMA_MAX_REGS. **Regression risk:** leaving a true HMC failure running without reset — possible, but i40e has done this since 2014, ice does not reset on HMC_ERR, and PE_CRITERR/PE_PUSH still reset. **Low risk** for the reset- suppression itself.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: Unconditional HMC reset came from **8498a30e1b948** (“RDMA/irdma: Register auxiliary driver…”, 2021-06-02), moved into icrdma_if.c by **0c2b80cac96e1** (2025 refactor). Present since irdma GEN2 (~5.14-era), not new 7.3 code.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Related precedent **9c010ee0ea5f** (i40e, 2014) is in this tree (git merge-base --is-ancestor succeeded). i40e still logs HMC error info and does not reset.
**Step 3.3: CHECK FILE HISTORY**
Record: Recent irdma work is GEN3/GEN4 and udata hardening. This patch is **standalone**, not “X/Y”. Later commits do not revert or replace this HMC handling.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Seyeong Kim (Canonical) — one irdma commit here. Intel irdma maintainer is Tatyana Nikolova (CC’d). Applied by Leon Romanovsky.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs icrdma_if.c, IRDMA_GLINT_RATE in the enum (so new entries stay last), and ice IIDC_RDMA_EVENT_CRIT_ERR. All present in this 7.3 tree. **Applies standalone** here.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 4dc9c884c0aaf: RFC + v2. Applied version is **v2** (20260619050044.1807044-1).
- RFC: https://patch.msgid.link/20260416071541.3899471-1-
[email protected]
- v2: https://patch.msgid.link/20260619050044.1807044-1-
[email protected]
- RFC notes: offsets inferred; “every HMC_ERR is safe to continue” not datasheet-confirmed; repro via /dev/mem write to PFINT_OICR, not firmware HMC.
- May 22 follow-up: retested on **7.1-rc4**; patch applied unchanged.
- **No NAK** in the saved thread. lore.kernel.org HTML fetch returned 403; thread recovered via b4 dig -m.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): linux-rdma, Krzysztof Czurylo, Tatyana Nikolova, Jason Gunthorpe, Leon Romanovsky. **No Reviewed-by** in the mbox (RFC, author ping, then maintainer apply). Right maintainers were CC’d.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: Real-world HMC_ERR → “Requesting a reset” is widely reported:
- GitHub intel/ethernet-linux-ice#12: recurring OICR 0x06000803 / HMC Error / PF reset on multiple machines; workaround unload/blacklist irdma.
- Proxmox forum: E810 HMC Error → Corosync loss / node reboots.
- Alpine even blacklists irdma by default over this class of issue. Author also cites a **customer report on NVM 3.10** (cascading PFR + DMAR).
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Single patch (RFC → v2). Not a multi-patch series.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search **403**. No evidence this commit was NAK’d for stable. Unrelated 6.6 irdma reset patch (irdma_modify_qp_to_err) is a different bug.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: KEY FUNCTIONS**
Record: icrdma_iidc_event_handler (behavior). Arrays/enum:icrdma_regs, i40iw_regs, enum irdma_registers. Init:icrdma_init_hw / i40iw_init_hw walk IRDMA_MAX_REGS.
**Step 5.2: TRACE CALLERS**
Record: Registered as .event_handler on the GEN2 auxiliary driver. ice misc IRQ sets ICE_AUX_ERR_PENDING for PFINT_OICR_HMC_ERR_M; service task sends IIDC_RDMA_EVENT_CRIT_ERR with the OICR value. **Hardware/interrupt-driven**, not a syscall. Hits any system with ice + irdma loaded (E810 and similar), including hosts that are not running RDMA traffic.
**Step 5.3: TRACE CALLEES**
Record: After the patch, readl of two HMC diagnostic regs. Before, icrdma_request_reset → ice_rdma_request_reset → ice_schedule_reset(ICE_RESET_PFR) — full function reset, unplug aux, drop the NIC datapath.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: ice OICR → service task → aux event → irdma handler → (old) PF reset. Userspace cannot set OICR, but **firmware/hardware HMC_ERR is common** on E810. Forced-bit tests still prove the handler’s reset is what destroys connections.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same interrupt: i40e logs and does not reset; ice does not reset, only notifies aux. irdma PE_CRITERR already special-cases Q1 resource errors as non-fatal. This HMC change is the same pattern.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** icrdma_iidc_event_handler in drivers/infiniband/hw/irdma/icrdma_if.c. Pre-fix parent still had rf->reset = true on HMC_ERR. Bug introduced **2021** (8498a30e1b948), long before 7.3. Current HEAD already contains **4dc9c884c0aaf** (that is the mainline merge of this fix, not a reason to reject it on merit).
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply on this tree.** Context matches. GEN1 placeholders keep IRDMA_MAX_REGS arrays aligned. Would need more care on much older stables if IRDMA_GLINT_RATE or icrdma_if.c were missing; **not an issue here**.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This *is* the HMC-reset suppression. No alternate fix. i40e’s older analogous change is present.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: **RDMA/irdma (Intel E810 / ice GEN2).** **IMPORTANT** — not core mm/VFS, but E810 is common in servers/clusters. A PF reset takes down **Ethernet as well as RDMA**.
**Step 7.2: SUBSYSTEM ACTIVITY**
Record: Actively developed (GEN3/GEN4, udata). This handler itself has been stable since the 2021 introduction / 2025 file move.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: WHO IS AFFECTED**
Record: **Driver-specific** — ice + irdma (Intel E810 and related). Includes clusters that load irdma by default even when they do not use RDMA (Proxmox/ice GitHub reports).
**Step 8.2: TRIGGER CONDITIONS**
Record: Hardware HMC_ERR (OICR bit 26). Seen in the field without a special RDMA workload. Not a userspace-triggered security bug. **Common enough** that distros document blacklisting irdma.
**Step 8.3: FAILURE MODE SEVERITY**
Record: PF reset → link down, RDMA teardown, IOMMU faults, uverbs WARN during aux unplug, cluster partition / reboot in reports. **Severity:
HIGH (hang/datapath loss); CRITICAL in HA/cluster setups.**
**Step 8.4: RISK-BENEFIT RATIO**
Record: **Benefit: high** (stops reset storms on a widely deployed NIC). **Risk: low** for dropping the reset; **very low** extra risk from read- only diagnostic MMIO (wrong offset would log junk or, at worst, a bad read — tests did not blow up). Ratio favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real, user-visible bug: PF reset storm, IOMMU faults, full RDMA/Ethernet disruption on E810.
- Field reports (customer, Proxmox, ice GitHub); Canonical engineer with before/after on 6.8 and 7.1-rc4.
- Small (+15/-3), contained in irdma.
- Matches i40e (2014, Intel: reset “not necessary”) and ice (forwards HMC_ERR, does not reset).
- Fatal PE_CRITERR / PE_PUSH paths unchanged.
- RDMA maintainer applied it; Intel irdma maintainers were CC’d.
- Code and prerequisites exist in this 7.3 tree.
AGAINST:
- Diagnostic register offsets inferred, not datasheet-confirmed (reads were 0 on a *forced* interrupt).
- Author RFC: not proven every firmware HMC_ERR is safe to run through.
- Repro used /dev/mem OICR injection, not a firmware HMC event (customer logs still show the same handler path).
- No Fixes/Cc stable, no Reviewed-by (absence is not a no-vote per the rules).
UNRESOLVED:
- Full public review text beyond the RFC mbox (lore HTML 403).
- Whether stable@ discussed this specific patch (stable search 403).
- Exact meaning of HMC_ERR on E810 silicon.
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — drop destructive reset; tested on E810; i40e/ice precedent.
2. Fixes a real bug that affects users? **PASS** — production reset storms.
3. Important (crash/security/corruption/deadlock)? **PASS** — PF reset / datapath loss / IOMMU faults / cluster impact. HIGH.
4. Small and contained? **PASS** — 15 insertions, one handler.
5. No new features or APIs? **PASS** — error-path policy + diagnostic reads.
6. Can apply to the local tree? **PASS** — matching irdma GEN2 code in 7.3.0-rc4.
**Step 9.3: EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. It is a **hardware error-handling workaround** in an existing driver (same class as USB/PCI quirks: stop a harmful default for real devices).
**Step 9.4: DECISION**
This tree has the irdma GEN2 HMC path. Suppressing PF reset on HMC_ERR is a small, tested fix for a serious, widely seen E810 failure mode. Diagnostic MMIO is best-effort; the stable-worthy part is not resetting. Benefit clearly outweighs risk.
Verification:
- [Phase 1] Tags: Link to msgid 20260619050044; SOB Seyeong Kim + Leon Romanovsky; no Fixes/Reported-by/Cc stable
- [Phase 2] Diff: 5 files, +15/-3; HMC_ERR no longer sets rf->reset; GEN2 regs + GEN1 0xffffffff pads
- [Phase 2] Confirmed ice_rdma_request_reset(IIDC_FUNC_RESET) → ICE_RESET_PFR
- [Phase 3] Blame: reset from 8498a30e1b948 (2021); moved in 0c2b80cac96e1
- [Phase 3] git merge-base --is-ancestor 9c010ee0ea5f HEAD = YES; i40e still log-only
- [Phase 3] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- [Phase 3] git merge-base --is-ancestor 4dc9c884c0aaf HEAD = YES (mainline landing of this fix)
- [Phase 4] b4 dig -c 4dc9c884c0aaf: RFC then v2; v2 applied; -w CC’d Intel irdma + RDMA maintainers
- [Phase 4] b4 dig -m: RFC caveats + 7.1-rc4 retest; no NAK in mbox
- [Phase 4] External: ice GitHub #12 and Proxmox E810 HMC reset reports
- [Phase 4] lore.kernel.org WebFetch 403; stable@ search 403 — listed UNVERIFIED
- [Phase 5] Handler is ice aux .event_handler; GEN3/4 use a different event path (no HMC reset there)
- [Phase 6] Pre-fix HMC_ERR block present at 4dc9c884c0aaf^; arrays aligned with enum
- [Phase 8] Failure mode: PF reset / RDMA+Ethernet teardown / IOMMU faults, severity HIGH
- UNVERIFIED: datasheet-correctness of 0x00520400/0x00520500; public Intel Acked-by beyond CC
The patch is small, matches long-standing i40e/ice behavior, and prevents a real E810 reset storm that takes down RDMA and the PF.
**YES**
drivers/infiniband/hw/irdma/i40iw_hw.c | 4 +++- drivers/infiniband/hw/irdma/icrdma_hw.c | 2 ++ drivers/infiniband/hw/irdma/icrdma_hw.h | 2 ++ drivers/infiniband/hw/irdma/icrdma_if.c | 8 ++++++-- drivers/infiniband/hw/irdma/irdma.h | 2 ++ 5 files changed, 15 insertions(+), 3 deletions(-)
drivers/infiniband/hw/irdma/i40iw_hw.c +3 -1
@@ -29,7 +29,9 @@ static u32 i40iw_regs[IRDMA_MAX_REGS] = {I40E_PFHMC_PDINV ,I40E_GLHMC_VFPDINV (0 ),I40E_GLPE_CRITERR , -0xffffffff /* PFINT_RATEN not used in FPK */ +0xffffffff ,/* PFINT_RATEN not used in FPK */ +0xffffffff ,/* PFHMC_ERRORINFO not used in FPK */ +0xffffffff /* PFHMC_ERRORDATA not used in FPK */ }; static u32 i40iw_stat_offsets[] = {
drivers/infiniband/hw/irdma/icrdma_hw.c +2 -0
@@ -29,6 +29,8 @@ static u32 icrdma_regs[IRDMA_MAX_REGS] = {GLHMC_VFPDINV (0 ),GLPE_CRITERR ,GLINT_RATE (0 ), +PFHMC_ERRORINFO , + PFHMC_ERRORDATA, }; static u64 icrdma_masks[IRDMA_MAX_MASKS] = {
drivers/infiniband/hw/irdma/icrdma_hw.h +2 -0
@@ -40,6 +40,8 @@#define GLHMC_VFPDINV (_i) (0x00528300 + ((_i) * 4))/* _i=0...31 */ #define GLPE_CRITERR 0x00534000#define GLINT_RATE (_INT) (0x0015A000 + ((_INT) * 4))/* _i=0...2047 */ /* Reset Source: CORER */ +#define PFHMC_ERRORINFO 0x00520400 +#define PFHMC_ERRORDATA 0x00520500#define ICRDMA_DB_ADDR_OFFSET (8 * 1024 * 1024 - 64 * 1024)
drivers/infiniband/hw/irdma/icrdma_if.c +6 -2
@@ -91,8 +91,12 @@ static void icrdma_iidc_event_handler(struct iidc_rdma_core_dev_info *cdev_info, } }if (event->reg &IRDMAPFINT_OICR_HMC_ERR_M ) { -ibdev_err (&iwdev->ibdev,"HMC Error\n" ); - iwdev->rf->reset = true; +u32 hmc_errinfo =readl (iwdev->rf->sc_dev.hw_regs[IRDMA_PFHMC_ERRORINFO ]); +u32 hmc_errdata =readl (iwdev->rf->sc_dev.hw_regs[IRDMA_PFHMC_ERRORDATA ]); + +/* Log diagnostics; do not reset here. */ +ibdev_warn (&iwdev->ibdev,"HMC Error: errinfo=0x%08x errdata=0x%08x\n" , + hmc_errinfo, hmc_errdata); }if (event->reg &IRDMAPFINT_OICR_PE_PUSH_M ) {ibdev_err (&iwdev->ibdev,"PE Push Error\n" );
drivers/infiniband/hw/irdma/irdma.h +2 -0
@@ -66,6 +66,8 @@ enum irdma_registers {IRDMA_GLHMC_VFPDINV ,IRDMA_GLPE_CRITERR ,IRDMA_GLINT_RATE , +IRDMA_PFHMC_ERRORINFO , +IRDMA_PFHMC_ERRORDATA , IRDMA_MAX_REGS, /* Must be last entry */ };
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18] RDMA/irdma: Suppress PF reset on HMC error
Sashiko has reviewed this patch and found no issues.
Quoted 22 lines
From: Seyeong Kim <[email protected]>
[ Upstream commit
4dc9c884c0aafac1e8d37536d88d485135e26883]The irdma driver currently issues an unconditional PF reset whenever the HMC Error interrupt (
PFINT_OICRbit 26) fires:if (event->reg & IRDMAPFINT_OICR_HMC_ERR_M) { ibdev_err(&iwdev->ibdev, "HMC Error\n"); iwdev->rf->reset = true; }
request_reset()issues anIIDC_PFRto ice. In practice a singleHMC_ERRcan trigger cascading PF resets, IOMMU faults during teardown, and teardown of every RDMA connection on the device.i40e handles the identically-named interrupt by reading
PFHMC_ERRORINFOandPFHMC_ERRORDATAand logging them without touching device state; see commit9c010ee0ea5f("i40e: Suppress HMC error to Interrupt message level") which removed the reset as "not necessary". This patch mirrors that handling on irdma.
Quoted 7 lines
With this change, repeated
HMC_ERRno longer produces a reset storm and RDMA traffic on the device continues uninterrupted.Signed-off-by Seyeong Kim <[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 iommu/qcom: Enable clocks before hardware access in qcom_iommu_ctx_probe()
In reply to Sasha LevinFrom: Mukesh Ojha <[email protected]>
[ Upstream commit cb776a03a53429aa59e25a8cbc3d1a48bd11afdb ]
qcom_iommu_ctx_probe() reads and writes the CB_FSR register to clear any stale IRQ left by the bootloader. This happens during devm_of_platform_populate() which is called from the parent device's probe before any pm_runtime_get(). The parent's clocks (iface, bus, tbu) are therefore not guaranteed to be on, making the register access unreliable on rebind or after a suspend cycle.
Use pm_runtime_resume_and_get() on the parent device to ensure clocks are enabled before the register access, and release the reference immediately after.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: **[iommu/qcom] [Enable] clocks before hardware access in qcom_iommu_ctx_probe()**
“Enable” here is a missing power/clock step before MMIO, not a new feature.
**Step 1.2: Tags**
Record:
- Reviewed-by: Konrad Dybcio <[email protected]>
- Signed-off-by: Mukesh Ojha <[email protected]> (author)
- Signed-off-by: Will Deacon <[email protected]> (IOMMU/SMMU maintainer)
- No Fixes:, Reported-by:, Tested-by:, Acked-by:, Link:, or Cc: stable (absence is expected)
**Step 1.3: Body**
Record:
- **Bug:** qcom_iommu_ctx_probe() reads/writes CB_FSR to clear a stale bootloader IRQ during devm_of_platform_populate(), which runs from the parent probe **before** any pm_runtime_get(). Parent clocks (iface, bus, tbu) may be off.
- **Symptom:** Register access is **unreliable on rebind or after a suspend cycle**.
- **Root cause:** Child MMIO without a runtime-PM resume of the parent that actually enables the clocks.
- **Fix:** pm_runtime_resume_and_get(dev->parent) around the FSR access, then pm_runtime_put_sync().
- No stack trace, syzbot, or version range in the message.
**Step 1.4: Hidden bug fix?**
Record: Yes. The subject sounds like enablement, but this is a correctness fix for MMIO with clocks gated.
---
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- File: drivers/iommu/arm/arm-smmu/qcom_iommu.c (+6 / −1)
- Function: qcom_iommu_ctx_probe()
- Scope: single-file, surgical
**Step 2.2: Flow change**
Record: **Before:** if the context is not secure, immediately readl/writel ARM_SMMU_CB_FSR. **After:** same access, but only after a successful parent pm_runtime_resume_and_get(), then pm_runtime_put_sync(). Resume failure fails probe. This is the child probe path invoked from parent devm_of_platform_populate().
**Step 2.3: Bug mechanism**
Record: **Hardware access / PM correctness.** Clocks are enabled only in qcom_iommu_resume() via clk_bulk_prepare_enable(). Parent probe order is devm_pm_runtime_enable() then devm_of_platform_populate() — RPM enable does not turn clocks on. The parent already wraps its own SMMU_INTR_SEL_NS write with resume/get; the child FSR access did not.
**Step 2.4: Fix quality**
Record: Obviously correct and matches the parent’s existing pattern. pm_runtime_resume_and_get() drops the usage count on failure, so there is no extra put needed. Regression risk is low: resume runs after clocks/drvdata are set; multiple context banks each get/put independently. No API or data-structure change.
---
## Phase 3: Git history
**Step 3.1: Blame**
Record: FSR-clear comment and access come from **0ae349a0f33fb0 (“iommu/qcom: Add qcom_iommu”, Rob Clark, 2017-08-09)**, first in **v4.14-rc1**. Secure-ctx skip is from e30c960d3f44b7 (2023). The bug is old, not recent.
**Step 3.2: Fixes: tag**
Record: None. The introducing commit is 0ae349a0f33fb0, present in this tree (git merge-base --is-ancestor succeeded).
**Step 3.3: Related file history**
Record: Same-day series by Mukesh Ojha (v2 6/6 “Misc Fixes”):
1. 1f33b8208a197 inverted fault report
2. bf69e515b1802 devm_pm_runtime_enable() (cleanup)
3. e910315ae08a2 check RPM return on parent SMMU_INTR_SEL_NS write
4. 3c748a5554f96 pgtbl_ops leak
5. a05b67cd45ad0 pgtbl_ops publish vs mutex
6. **this commit** cb776a03a5342
This patch does not need 2–5. It only uses pm_runtime_resume_and_get(), present since dd8088d5a8969.
**Step 3.4: Author**
Record: Qualcomm engineer; series reviewed by Konrad Dybcio (Qualcomm) and applied by Will Deacon. Not a drive-by.
**Step 3.5: Dependencies**
Record: Standalone. Applies to the pre-commit ctx_probe body in this tree. No new helpers.
---
## Phase 4: Mailing list
**Step 4.1: Original discussion**
Record:
- Lore/msgid: https://patch.msgid.link/20260717144608.3216274-7-
[email protected]
- v1: [PATCH 7/8] 2026-06-23, same diff
- v2: [PATCH v2 6/6] 2026-07-17 (dropped unrelated 6/8 and 8/8)
- Cover: “Series to address fixes in legacy qcom_iommu driver”
- Konrad Reviewed-by on v1 7/8 with no requested changes; v2 unchanged
- Will: “Applied to iommu (arm/smmu/updates)”
- No NAK, no Cc: stable request
**Step 4.2: Recipients (b4 dig -w)**
Record: Will Deacon, Joerg Roedel, Robin Murphy, Rob Clark, Konrad Dybcio, [email protected], linux-arm-msm, linux-arm-kernel.
**Step 4.3: Bug report**
Record: No external bugzilla/syzbot. Qualcomm-authored; trigger described as rebind / post-suspend.
**Step 4.4: Series**
Record: Independent of the other five patches. Same pattern as patch 3/6 on the parent.
**Step 4.5: Stable list**
Record: **UNVERIFIED** — lore.kernel.org returned 403; no stable thread in the saved mbox.
---
## Phase 5: Code semantics
**Step 5.1: Functions**
Record: qcom_iommu_ctx_probe() only.
**Step 5.2: Callers**
Record: Sole caller is .probe = qcom_iommu_ctx_probe on qcom_iommu_ctx_driver. Invoked from qcom_iommu_device_probe() → devm_of_platform_populate(). Device-init / bind path, not a syscall hot path.
**Step 5.3: Callees**
Record: pm_runtime_resume_and_get(parent) → qcom_iommu_resume() → clk_bulk_prepare_enable() (and optional qcom_scm_restore_sec_cfg); then iommu_readl/iommu_writel ARM_SMMU_CB_FSR; then pm_runtime_put_sync().
**Step 5.4: Reachability**
Record: Yes, on every non-secure context probe for qcom,msm-iommu-v1 / v2. DT users include MSM8916/8917/8937/8939/8953/8976. First boot often still has bootloader clocks; **rebind, deferred probe after clk_disable_unused, and probe after suspend/remove** can have clocks off. Unprivileged users do not trigger this directly; driver bind/suspend does.
**Step 5.5: Similar patterns**
Record: Parent already does resume/get around SMMU_INTR_SEL_NS (e910315ae08a2). This is the matching child-side hole.
---
## Phase 6: This checkout
**Step 6.1: Buggy code in this tree?**
Record: **Yes.** Tree is **v7.3-rc4** (VERSION=7 PATCHLEVEL=3 SUBLEVEL=0 EXTRAVERSION=-rc4, git describe:v7.3-rc4-27-gf0100363d8c37). Driver and FSR-clear exist since v4.14. Candidate cb776a03a5342 is already an ancestor of HEAD (merged via iommu-updates-v7.3, in v7.3-rc1). Pre-commit code still has the unguarded FSR access.
**Step 6.2: Backport difficulty**
Record: Clean apply on this file’s ctx_probe. Needs linux/pm_runtime.h (already included) and pm_runtime_resume_and_get() (in this tree).
**Step 6.3: Related fixes already here**
Record: The candidate itself is already in this 7.3-rc4 tree. No alternate FSR-clock fix besides this commit.
---
## Phase 7: Subsystem
**Step 7.1**
Record: **iommu / Qualcomm legacy SMMU** (drivers/iommu/arm/arm- smmu/qcom_iommu.c). **IMPORTANT** for those SoCs (DMA/IOMMU), not core- mm/VFS. CONFIG_QCOM_IOMMU, depends on ARCH_QCOM.
**Step 7.2**
Record: Mature “legacy qcom_iommu” driver; low churn except this 2026 fix series.
---
## Phase 8: Impact and risk
**Step 8.1: Who**
Record: Qualcomm MSM IOMMU v1/v2 platforms (older/mid-range SoCs still in LTS images), not all machines.
**Step 8.2: Trigger**
Record: Child probe with parent clocks off: driver rebind, probe after pm_runtime_force_suspend on remove, deferred probe after unused clocks are gated. Not every boot. Not a userspace exploit path.
**Step 8.3: Failure mode**
Record: MMIO to a clock-gated SMMU context bank. On these platforms that is typically a **bus timeout / NOC hang / SError**, or a failed FSR clear so a bootloader IRQ fires as soon as devm_request_irq() runs.
Severity: **HIGH** (probe hang/abort), not a confirmed UAF/CVE.
**Step 8.4: Risk-benefit**
Record: **Benefit: medium-high** for affected hardware (prevents bad MMIO during probe). **Risk: low** (6 lines, existing RPM API, same pattern as parent). Ratio favors backport.
---
## Phase 9: Synthesis
**For:**
- Real bug: FSR MMIO before parent clocks are enabled; present since v4.14.
- Can hang or fail IRQ clear on rebind / post-suspend / deferred probe.
- 6-line, obviously correct; reviewed by Konrad, applied by Will.
- Standalone; no new API.
- Same RPM wrap the parent already uses for SMMU_INTR_SEL_NS.
- Driver still used (MSM8916-class DT).
**Against:**
- No Reported-by / syzbot / crash log.
- Message says “unreliable”, not “panic”.
- Not a universal hot path.
- Lore stable search could not be fetched (403).
**Unresolved:** Exact production crash vs silent bad read on every SoC variant — not verified beyond Qualcomm’s description.
**Stable rules:**
1. Obviously correct and tested? **PASS** (review + maintainer apply; pattern already in-tree)
2. Real user-facing bug? **PASS** (clock-gated MMIO on probe/rebind)
3. Important (crash/hang/corruption)? **PASS** (HIGH: interconnect hang / SError / stale IOMMU IRQ)
4. Small and contained? **PASS** (6 lines, one function)
5. No new features/APIs? **PASS**
6. Applies to this tree? **PASS** (driver and RPM API present)
**Exception category:** none (not an ID/quirk/DT/build/doc add). It is a normal small driver bugfix.
This tree is v7.3-rc4 and already contains cb776a03a5342; that is the upstream commit, not a reason to reject on merit. The buggy FSR-without- clocks path is in this driver and has been since v4.14. The fix is small, local, and prevents a real probe-time hardware access failure on Qualcomm IOMMU platforms.
### What it solves for stable users
Without the RPM get, context-bank probe can touch CB_FSR while iface/bus/tbu clocks are off. That is the same class of bug the parent already fixed for SMMU_INTR_SEL_NS. On rebind or after suspend/remove (and on deferred probe after unused clocks are disabled), that access is a hang or a missed IRQ clear, then a surprise fault IRQ.
### Risk vs benefit
Benefit is avoiding probe-time MMIO with clocks gated on still-shipping MSM IOMMU v1/v2 boards. Risk is a few lines of standard resume_and_get/put_sync around an existing register poke. No locking or API change.
### Concerns
No public reproducer. Independent of the rest of the “Misc Fixes” series. pm_runtime_resume_and_get() is already in this tree.
Verification:
- [Phase 1] Tags: Reviewed-by Konrad Dybcio; SOBs Mukesh Ojha, Will Deacon; no Fixes/Reported-by/Cc-stable
- [Phase 2] Diff: +6/−1 in qcom_iommu_ctx_probe() wrapping FSR MMIO with parent RPM get/put
- [Phase 3] Blame: FSR clear from 0ae349a0f33fb0 (v4.14-rc1); ancestor of HEAD
- [Phase 3] Series mates bf69e515b1802 / e910315ae08a2 are not prerequisites
- [Phase 3] pm_runtime_resume_and_get from dd8088d5a8969; ancestor of HEAD
- [Phase 4] b4 dig -c cb776a03a5342: https://patch.msgid.link/20260717
[email protected]
- [Phase 4] b4 dig -a: v1 7/8 identical diff; Konrad R-b; v2 applied by Will; no NAK
- [Phase 4] Cover letter: “fixes in legacy qcom_iommu driver”
- [Phase 4] UNVERIFIED: lore.kernel.org/stable HTTP 403
- [Phase 5] Only caller: platform .probe via devm_of_platform_populate() from parent probe
- [Phase 5] Resume path enables clocks in qcom_iommu_resume() → clk_bulk_prepare_enable()
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- [Phase 6] git merge-base --is-ancestor cb776a03a5342 HEAD succeeded (fix already in this 7.3 tree)
- [Phase 6] Pre-image of the commit still has unguarded iommu_writel/iommu_readl on ARM_SMMU_CB_FSR
- [Phase 8] Failure mode: clock-gated SMMU MMIO → hang/SError or stale fault IRQ; severity HIGH
- UNVERIFIED: no captured oops from a reporter
**YES**
drivers/iommu/arm/arm-smmu/qcom_iommu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/iommu/arm/arm-smmu/qcom_iommu.c +6 -1
@@ -704,8 +704,13 @@ static int qcom_iommu_ctx_probe(struct platform_device *pdev)/* clear IRQs before registering fault handler, just in case the * boot-loader left us a surprise: */ -if (!ctx->secured_ctx) +if (!ctx->secured_ctx) { + ret =pm_runtime_resume_and_get (dev->parent); +if (ret) +return ret;iommu_writel (ctx,ARM_SMMU_CB_FSR ,iommu_readl (ctx,ARM_SMMU_CB_FSR )); +pm_runtime_put_sync (dev->parent); + } ret = devm_request_irq(dev, irq, qcom_iommu_fault,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 net/rds: don't use unpin_user_pages_dirty_lock() from atomic context
In reply to Sasha LevinFrom: Allison Henderson <[email protected]>
[ Upstream commit d100966325f782aa7775e5f0e8fb04f66f56308e ]
rds_rdma_free_op() and rds_atomic_free_op() are reached from the IB send completion path via
rds_ib_tasklet_fn_send()
rds_ib_send_cqe_handler()
rds_message_put()
rds_message_purge()
rds_rdma_free_op() / rds_atomic_free_op()which runs in tasklet (softirq) context. Both functions unpin the user pages of the op with unpin_user_pages_dirty_lock(), which uses set_page_dirty_lock() and thus may take the folio lock and sleep. Sleeping in softirq context is not allowed and can deadlock or crash.
Dirtying the pages with the non-sleeping set_page_dirty() instead would just trade one bug for another, as pointed out during review:
the pinned range can be file-backed. rds_pin_pages() pins with FOLL_LONGTERM, which refuses fs-dax but takes the page-cache pages of a MAP_SHARED file mapping just fine, and RDS does not restrict what memory the caller registers as an RDMA destination.
For a file-backed page, set_page_dirty() from a tasklet can take non-irq-safe filesystem locks (e.g. mapping->i_private_lock and inode->i_lock in block_dirty_folio()) and deadlock against the task it interrupted. Without the folio lock, it races with truncation clearing folio->mapping, which is the race set_page_dirty_lock() exists to close. The pre-pin_user_pages() version of this code dirtied pages that way from the tasklet, so that bug is older than the sleeping unpin.
The page dirtying therefore has to move to process context, not merely avoid the folio lock. When the final rds_message_put() runs in atomic context, rds_rdma_free_op() and rds_atomic_free_op() now leave the op's pages pinned and flag the op. Later, rds_message_put() hands the message to a work item that unpins the flagged ops' pages and frees the message from process context. Here, unpin_user_pages_dirty_lock() is safe outside the atomic context. Everything else keeps running in the caller's context exactly as
before: the rest of the purge - the zerocopy completion, the socket put and the MR reference drops - as well as RDMA writes, whose pages the remote side only reads and which unpin without dirtying, everything on rds_tcp, and final puts that already happen in process context (socket close, connection teardown).
Deferring only the unpin means the work item touches nothing but the pinned pages and the rds module's own memory: it cannot call back into a transport module, so it changes nothing about the transports' shutdown and unload ordering. rds_exit() drains any pending unpin work via destroy_workqueue(rds_wq) before the module goes away.
The Oracle UEK kernel avoids the sleeping unpin by calling set_page_dirty() directly from the tasklet, which is subject to the file-backed page problem above, so this deliberately does not follow UEK here.
---
LLM Generated explanations, may be completely bogus:
This is a real sleep-in-softirq bug on the RDS IB completion path, and the buggy code is present in this 5.10.270 tree. The fix is self- contained and should be backported.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [net/rds] [don't use] don't call unpin_user_pages_dirty_lock() from atomic/softirq context. "don't use" is a prevent/avoid-style fix.
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Allison Henderson <[email protected]> (author; ignore pipeline SOB)
- Signed-off-by: Jakub Kicinski <[email protected]> (netdev maintainer)
- Link: https://patch.msgid.link/20260730041629.3512480-2- [email protected]
- No Reported-by, Tested-by, Reviewed-by, Acked-by, or Cc: stable in the provided message
- Mailing-list v4 **did** include Fixes: 0d4597c8c5ab ("net/rds: Track user mapped pages through special API"); that tag is in this tree (verified with git merge-base --is-ancestor)
- Message-ID -2 is patch 1/4 of [PATCH net v4 0/4] net/rds: Bug fix ports (cover letter is -1)
- Assisted-by Claude appears on the lore submission only
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: rds_rdma_free_op() / rds_atomic_free_op() run from the IB send tasklet and call unpin_user_pages_dirty_lock(), which uses set_page_dirty_lock() → lock_page(), which may sleep.
- Symptom: sleep in softirq → deadlock or crash.
- Switching to set_page_dirty() from the tasklet is also wrong for file-backed pins (FOLL_LONGTERM MAP_SHARED): non-irq-safe fs locks and truncation races.
- Fix: if the final put is atomic and pages need dirtying, leave them pinned, set op_unpin_deferred, and finish unpin+free on rds_wq.
- Author notes this is older than the pin API (pre-pin code already dirtied from the tasklet) and that UEK’s set_page_dirty()-from- tasklet approach is intentionally not followed.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not hidden. Explicit sleep-in-atomic / deadlock fix.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- net/rds/message.c: add rds_message_unpin_worker(), defer kfree from rds_message_put() when unpin was deferred
- net/rds/rdma.c: split unpin helpers; rds_rdma_free_op() / rds_atomic_free_op() unpin inline only when safe (in_task() or RDMA write)
- net/rds/rds.h: m_unpin_work, op_unpin_deferred bitfields, helper prototypes
- Scope: ~74 insertions / 11 deletions, three RDS files, surgical
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: final rds_message_put() always purges and unpins (possibly dirtying) in the caller’s context, including the send CQ tasklet.
- After: purge still runs in the caller (zerocopy, sock_put, MR krefs). Dirtying unpin is deferred to process context. RDMA writes still unpin immediately (no dirty). Process-context final puts still unpin immediately.
- Error path rds_cmsg_rdma_args() → rds_rdma_free_op() is sendmsg/process context, so in_task() is true and pages are not leaked.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record: [Deadlock / sleep-in-atomic] lock_page() from tasklet/softirq. Workqueue deferral is the correct class of fix; dirtying cannot stay in the tasklet.
Step 2.4: ASSESS THE FIX QUALITY
Record: v4 is the review-hardened design (v1 used set_page_dirty() in the tasklet; v2/v3 deferred the whole purge and needed extra IB-module flushes). Risk is the usual workqueue lifetime issues; mitigated because the worker only unpins pages and kfrees the message, and rds_exit() → rds_threads_exit() → destroy_workqueue(rds_wq) drains it. Messages are kzalloc’d, so new flags/work_struct start zeroed.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Sleeping unpin: 0d4597c8c5abd ("net/rds: Track user mapped pages through special API", Leon Romanovsky, 2020) — **in this tree**
- Call from tasklet: rds_rdma_free_op / rds_message_put date to 2009–2010 (Andy Grover)
- Pre-pin code already dirtied from this path
Step 3.2: FOLLOW THE FIXES: TAG
Record: 0d4597c8c5ab is an ancestor of HEAD (git merge-base --is- ancestor exit 0). No later in-tree substitute for this unpin-from- tasklet bug. 338a3ba30c5ef ("net:rds: Fix possible deadlock in rds_message_put") is a different lock-order bug in recv.c.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: Recent net/rds/ work here is unrelated (zerocopy, MR cleanup, tcp corruption). This is standalone, not patch 2-of-N that needs earlier series members.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Allison Henderson is a long-time RDS contributor; this tree already has several of her RDS fixes. Author is the right subsystem person.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: Series mates (socket ref on MR, send_xmit leak, MR teardown unpin) are independent bugs. Needed APIs exist here: in_task(), unpin_user_pages_dirty_lock(), rds_wq, pin_user_pages_fast() + FOLL_LONGTERM. No missing helpers.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 mbox on msgid [email protected]:
8-message thread
- Lore/WebFetch of lore.kernel.org and patch.msgid.link returned 403; discussion recovered via b4 + openwall
- Revisions: v1 2026-07-11, v2 2026-07-25, v3 2026-07-26, v4 2026-07-29 (applied)
- v1 NAK’d conceptually: set_page_dirty() from softirq can deadlock on fs locks and race truncation
- v3 extra rds_ib_exit() flushes dropped in v4 by deferring only unpin
- Applied to netdev/net-next as d100966325f7 (not this tree)
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: To/Cc included netdev, linux-rdma, Kicinski, Abeni, Dumazet, Horms. No subsystem Reviewed-by on v4. Kicinski: “I don't have much confidence in my ability to review this, so let's queue this for -next.” Author agreed they are old, non-simple bugs.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla in the thread. Motivation is code analysis + UEK carrying a related (weaker) fix. Oracle RDS/IB users are the affected population.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: 4-patch “Bug fix ports” series. This patch is 1/4 and does not depend on 2–4. Patch 4 is a separate pin-vs-put_page leak in __rds_ib_teardown_mr().
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: No useful hit on lore.kernel.org/stable for this subject (search was noisy/unrelated). Originally aimed at net because of Fixes:; moved to net-next. Absence of stable-list discussion is not a NAK.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: rds_message_unpin_worker (new), rds_message_put, rds_rdma_op_unpin_pages (new), rds_rdma_free_op, rds_atomic_op_unpin_page (new), rds_atomic_free_op
Step 5.2: TRACE CALLERS
Record:
- rds_message_put(): send.c, ib_send.c, ib_cm.c, message.c, loop.c, connection.c
- Confirmed atomic path: rds_ib_tasklet_fn_send() → poll_scq() → rds_ib_send_cqe_handler() → rds_message_put() (net/rds/ib_cm.c, ib_send.c)
- rds_rdma_free_op(): rds_message_purge() and rds_cmsg_rdma_args() error path (process context)
- rds_atomic_free_op(): only rds_message_purge()
Step 5.3: TRACE CALLEES
Record: unpin_user_pages_dirty_lock() → set_page_dirty_lock() → lock_page() (sleeping). Non-dirty path uses unpin_user_pages() only. Worker uses queue_work(rds_wq) / kfree.
Step 5.4: FOLLOW THE CALL CHAIN
Record: Userspace sendmsg with RDS_CMSG_RDMA_ARGS / atomic cmsg → IB RDMA READ or atomic WR → CQ completion in tasklet → final put. Reachable from sockets if CONFIG_RDS_RDMA. Not a theoretical path.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Local __rds_ib_teardown_mr() still does set_page_dirty() + put_page() (series patch 4). rds_info.c unpins from getsockopt (process context) — OK. Same class of bug is already treated as backport-worthy in this tree (88fdf5948f538 Don't sleep inside rds_ib_conn_path_shutdown).
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. This checkout is **5.10.270** (pending-5.10, git describe p-5.10-1-gce56b7a73b64b).
- net/rds/rdma.c:500 and :517 call unpin_user_pages_dirty_lock()
- rds_ib_tasklet_fn_send still a tasklet
- rds_pin_pages() uses FOLL_LONGTERM
- Introduced by 0d4597c8c5ab (v5.7-era), present on this branch
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Semantic apply is straightforward. rdma.c / rds.h match the old side of the diff. message.c context after rds_message_put() still assigns hdr->h_exthdr[0] instead of memset of the ext header — **minor context conflict**, not a rework. work_struct / queue_work / in_task() are available (rds.h → sock.h → netdevice.h → workqueue.h; hardirq.h → preempt.h). rds_wq is destroyed on module exit.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No equivalent deferred-unpin fix. 338a3ba30c5ef is a different deadlock.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [net/rds] IMPORTANT for RDS-over-IB (Oracle RAC / HPC). Not core networking; production users of 5.10 LTS do run this.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mature. Core free/put path has been stable for years; this is a long-standing latent bug, not churn on new code.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Config-specific / driver-specific: CONFIG_RDS + CONFIG_RDS_RDMA, IB completions of RDMA READ / atomic ops against pinned user memory (including MAP_SHARED file pages).
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Common on RDS RDMA READ completion. Timing-dependent on folio already locked (writeback). Unprivileged user with an RDS socket and registered memory can hit it. Not every boot.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: Sleep in softirq / lock_page() from tasklet → deadlock or crash. **CRITICAL**. File-backed set_page_dirty() alternative would also be CRITICAL (fs lock deadlock / mapping UAF).
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: high for RDS/IB users (prevents deadlock/oops on a real completion path)
- Risk: low–medium (workqueue deferral, ~70 lines, one subsystem; worker does not call into the IB module)
- Ratio: benefit outweighs risk. Larger than a 5-line NULL check, but the pattern is standard and v4 was specifically reduced to avoid unload races.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Sleep in softirq is a real, important bug
- Path exists on this 5.10 tree and is userspace-reachable via RDS RDMA
- Fixes target 0d4597c8c5ab is in the tree
- Small, RDS-only, no new uAPI
- Needed kernel APIs exist
- v4 design addresses earlier review NAKs
- destroy_workqueue(rds_wq) drains deferred work
- RDS maintainer-authored; netdev applied it upstream
AGAINST:
- ~70 lines and a new work item (not a one-liner)
- Queued to net-next; Kicinski was uneasy reviewing it
- No syzbot/Tested-by on the committed message
- Trivial message.c context tweak for rds_message_populate_header()
UNRESOLVED:
- Could not fetch lore.kernel.org in-browser (403); used b4 mbox instead
- No evidence of a later revert or follow-up for d100966325f7 (search did not turn one up)
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — v4 is the review-fixed design; mechanism matches the bug. (Confidence is “good”, not “trivial one-liner”.)
2. Fixes a real bug that affects users? **PASS**
3. Important issue? **PASS** — deadlock/crash, CRITICAL
4. Small and contained? **PASS** — 3 files, RDS only
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — code present; at most a minor context adjustment
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: None (not a device ID/quirk/DT/build/docs exception). Qualifies as a normal important bugfix.
Step 9.4: MAKE YOUR DECISION
This tree still unpins and dirties RDMA/atomic pages in the IB send tasklet. That can sleep. Deferring only that unpin onto existing rds_wq is the right fix here and does not need the rest of the v4 series.
What it solves for 5.10 users: RDS-over-InfiniBand RDMA READ/atomic completion can call lock_page() in softirq, which can deadlock or crash. That is exactly the class of bug stable is for.
Risk vs benefit: contained RDS change, process-context unpin, workqueue drained on unload. Benefit is preventing a serious completion-path failure.
Concerns: expect a small message.c context edit around rds_message_populate_header(); do not pull series patches 2–4 as prerequisites.
Verification:
- [Phase 1] Tags: SOB Henderson/Kicinski; Link msgid; lore v4 had Fixes:
0d4597c8c5ab
- [Phase 2] Diff: defer dirtying unpin via work item; RDMA write still unpins in caller
- [Phase 3] git describe / Makefile: 5.10.270; blame unpin lines → 0d4597c8c5ab; ancestor check exit 0
- [Phase 3] 338a3ba30c5ef is a different recv.c deadlock
- [Phase 4] b4 mbox: 8 msgs, v1–v4, applied as d100966325f7; Kicinski queued net-next
- [Phase 4] WebFetch lore/msgid.link: 403; discussion from b4 + openwall
- [Phase 5] Call chain verified in ib_cm.c / ib_send.c; set_page_dirty_lock() uses lock_page() in mm/page-writeback.c
- [Phase 5] Other rds_rdma_free_op() caller is process-context error path in rdma.c:796
- [Phase 6] Local rdma.c still has sleeping unpin; in_task() and rds_wq exist; messages kzalloc’d
- [Phase 6] Header context differs (h_exthdr[0] vs memset) — minor backport
- [Phase 8] Failure mode: sleep-in-softirq / deadlock, CRITICAL
- UNVERIFIED: live lore HTML; no later revert found
**YES**
net/rds/message.c | 26 +++++++++++++++++++++++++ net/rds/rdma.c | 49 ++++++++++++++++++++++++++++++++++++----------- net/rds/rds.h | 10 ++++++++++ 3 files changed, 74 insertions(+), 11 deletions(-)
net/rds/message.c +26 -0
@@ -180,6 +180,19 @@ static void rds_message_purge(struct rds_message *rm)kref_put (&rm->atomic.op_rdma_mr->r_kref, __rds_put_mr_final); } +static void rds_message_unpin_worker (struct work_struct *work) +{ + struct rds_message *rm = container_of(work, struct rds_message, + m_unpin_work); + +if (rm->rdma.op_unpin_deferred) +rds_rdma_op_unpin_pages (&rm->rdma); +if (rm->atomic.op_unpin_deferred) +rds_atomic_op_unpin_page (&rm->atomic); + +kfree (rm); +} +void rds_message_put (struct rds_message *rm) {rdsdebug ("put rm %p ref %d\n" , rm,refcount_read (&rm->m_refcount));
@@ -187,8 +200,21 @@ void rds_message_put(struct rds_message *rm)if (refcount_dec_and_test (&rm->m_refcount)) {BUG_ON (!list_empty (&rm->m_sock_item));BUG_ON (!list_empty (&rm->m_conn_item)); +rds_message_purge (rm); +/* A final put in atomic context cannot dirty the ops' +* user pages on unpin, so rds_rdma_free_op() and +* rds_atomic_free_op() deferred it. Finish the unpin, +* and the free, from process context. +*/ +if (rm->rdma.op_unpin_deferred || + rm->atomic.op_unpin_deferred) { +INIT_WORK (&rm->m_unpin_work, rds_message_unpin_worker); +queue_work (rds_wq, &rm->m_unpin_work); +return ; + } +kfree (rm); } }
net/rds/rdma.c +38 -11
73 lines not on this page · raw message
net/rds/rds.h +10 -0
@@ -424,6 +424,12 @@ struct rds_message {void *m_final_op; +/* Unpins the ops' user pages and frees the message from +* process context when the final put happens in atomic +* context: dirtying the pages on unpin can sleep. +*/ +struct work_struct m_unpin_work; + struct { struct rm_atomic_op { int op_type;
@@ -447,6 +453,7 @@ struct rds_message { unsigned int op_mapped:1; unsigned int op_silent:1; unsigned int op_active:1; + unsigned int op_unpin_deferred:1;struct scatterlist *op_sg;struct rds_notifier *op_notifier;
@@ -462,6 +469,7 @@ struct rds_message { unsigned int op_mapped:1; unsigned int op_silent:1; unsigned int op_active:1; + unsigned int op_unpin_deferred:1;unsigned int op_bytes;unsigned int op_nents;unsigned int op_count;
@@ -938,6 +946,8 @@ int rds_cmsg_rdma_map(struct rds_sock *rs, struct rds_message *rm, struct cmsghdr *cmsg);void rds_rdma_free_op (struct rm_rdma_op *ro);void rds_atomic_free_op (struct rm_atomic_op *ao); +void rds_rdma_op_unpin_pages (struct rm_rdma_op *ro); +void rds_atomic_op_unpin_page (struct rm_atomic_op *ao);void rds_rdma_send_complete (struct rds_message *rm,int wc_status);void rds_atomic_send_complete (struct rds_message *rm,int wc_status); int rds_cmsg_atomic(struct rds_sock *rs, struct rds_message *rm,
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] net/rds: don't use unpin_user_pages_dirty_lock() from atomic context
Sashiko has reviewed this patch and found no issues.
Quoted 13 lines
From: Allison Henderson <[email protected]>
[ Upstream commit
d100966325f782aa7775e5f0e8fb04f66f56308e]
rds_rdma_free_op()andrds_atomic_free_op()are reached from the IB send completion path via
rds_ib_tasklet_fn_send()rds_ib_send_cqe_handler() rds_message_put() rds_message_purge() rds_rdma_free_op() / rds_atomic_free_op()
Quoted 8 lines
which runs in tasklet (softirq) context. Both functions unpin the user pages of the op with
unpin_user_pages_dirty_lock(), which uses [ ... ]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 libbpf: Skip bpf_object__probe_loading() when BPF token is in use
In reply to Sasha LevinFrom: Yuan Chen <[email protected]>
[ Upstream commit d262a25d8b58b697b2a1a2fe4b0078446cc00e11 ]
bpf_object__probe_loading() tries to load trivial SOCKET_FILTER and TRACEPOINT programs to verify the BPF environment works. When a BPF token is in use with restricted program type permissions, these probe loads may fail because the token does not allow the specific program types, even though BPF loading is perfectly functional.
Fix by skipping the probe when a token FD is present: BPF token creation itself proves the kernel has a working BPF subsystem. Real BPF issues will be caught during actual program and map loading.
---
LLM Generated explanations, may be completely bogus:
This is a real libbpf load-path bug in this 6.18 tree: restricted BPF tokens make bpf_object__probe_loading() fail even when the actual programs would load. The change is small, already present in the matching 6.18 code, and is worth backporting.
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
- Record: [libbpf] [Skip] Skip bpf_object__probe_loading() when BPF token is in use
- Subsystem: libbpf (userspace library in tools/lib/bpf/)
- Verb “Skip” is a workaround/fix for a false-negative probe, not a feature.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Record:
- Signed-off-by: Yuan Chen <[email protected]> (author)
- Signed-off-by: Andrii Nakryiko <[email protected]> (libbpf/BPF maintainer)
- `Link: https://lore.kernel.org/bpf/20260610145059.113412-2-
[email protected]`
- No Fixes:, Reported-by, Tested-by, Reviewed-by, Acked-by, or Cc: stable in the committed message (absence of Fixes/Cc-stable is expected here)
- Mailing-list review did include Acked-by: Mykyta Yatsenko <[email protected]> (not copied into the final commit text)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Record:
- **Bug:** bpf_object__probe_loading() loads dummy SOCKET_FILTER and TRACEPOINT programs. With a BPF token whose allowed program types exclude those, the probe fails even though real loads would work.
- **Symptom:** bpf_object__load() / bpf_object__prepare() returns an error and warns that BPF/RLIMIT_MEMLOCK is broken. In-tree token selftests (obj_priv_map, obj_priv_prog, freplace, implicit- token, struct_ops BTF cases) hit this.
- **Cover letter (v3):** same probe can also drop the token path and then break later loads (struct_ops + global data: fd X is not pointing to valid bpf_map).
- **Root cause:** probe uses hardcoded program types and passes
`obj->token_fd`.
- **Fix:** skip the probe when `token_fd` is set; creating the token
already proves BPF syscalls work.
- **Versions:** no version list in the message. BPF tokens exist since
~6.9; this 6.18 tree has them.**Step 1.4: DETECT HIDDEN BUG FIXES**
- Record: Not a disguised cleanup. It is an explicit functional fix for a false probe failure. Skipping the probe is the fix, not a refactor.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
- Record:
- File: tools/lib/bpf/libbpf.c — 3 insertions, 7 deletions
- Function: bpf_object__probe_loading()
- Scope: single-file surgical change
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
- Record:
- **Before:** After bpf_object_prepare_token(), probe always runs (except gen_loader). It passes token_fd / BPF_F_TOKEN_FD into dummy SOCKET_FILTER then TRACEPOINT loads. Either failure aborts object prepare/load.
- **After:** If obj->token_fd is set, return 0 immediately (same as gen_loader). Dummy loads no longer use token opts (NULL opts).
- **Path:** initialization/prepare of every bpf_object load, not a rare error path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
- Record:
- **Category:** logic/correctness (false failure in a capability probe)
- **Mechanism:** probe assumes SOCKET_FILTER or TRACEPOINT is allowed. Restricted tokens are the whole point of BPF token delegation. Probe failure is treated as “BPF is unavailable,” so legitimate objects never load.
- Not UAF/leak/race/overflow.
**Step 2.4: ASSESS THE FIX QUALITY**
- Record:
- Obviously correct: token creation already used bpf_token_create(). Real map/prog errors still happen in the real load path.
- Minimal: one extra skip condition; dummy loads drop unused token opts.
- bpf_prog_load(..., NULL) is valid: OPTS_VALID treats NULL as OK;
`OPTS_GET` falls back to 0. Same as empty opts when `token_fd == 0`.
- Regression risk is low. Skipping bump_rlimit_memlock() in this function is fine: bpf_prog_load() still calls it, and tokens imply 6.9+ with memcg BPF accounting.
- Residual gap: series patch 2 (feature probes using hardcoded types) is **not** in this tree. This patch still stands alone for the probe_loading hard-fail.
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
- Record:
- Probe itself: Stanislav Fomichev, 2018 (47eff61777c7).
- Token opts in the probe: 6b434b61b4d9e (“libbpf: Wire up BPF token support at BPF object level”), Andrii Nakryiko, 2024-01-23 (kernel ~6.9).
- Buggy pattern has been in this 6.18 line since the branch, not a
post-6.18 introduction.
**Step 3.2: FOLLOW THE FIXES: TAG**
- Record: No Fixes: tag (Mykyta asked for one; it was never added). The introducing commit is 6b434b61b4d9e, which **is** in this tree (git merge-base --is-ancestor succeeded).
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
- Record:
- f9bceaa59c5c4 already skips this probe for light skeleton (gen_loader); this patch extends that idea to tokens.
- 1315c28ed8095 split load into bpf_object__prepare() / load; probe now runs from bpf_object_prepare().
- Series patch 2 (“fetch probeable prog type from token”) is **not** in this tree.
- Standalone: Andrii said this was the only v2 patch that should land on its own.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
- Record: Yuan Chen has another libbpf fix here (aa485e8789d56, NULL deref in btf_dump__free). Not the libbpf maintainer. Applied by Andrii Nakryiko.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
- Record: Needs obj->token_fd and bpf_object__probe_loading(), both present. No new helpers. Applies standalone. Patch 2 is a related but separate feature-probe issue.
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
- Record:
- b4 dig -c d262a25d8b58:
https://patch.msgid.link/[email protected]
- Revisions:
- v1 (2026-05-29): selftest workaround — add SOCKET_FILTER/TRACEPOINT to token tests
- v2 (2026-06-04): 3 patches; this skip plus selftest ARRAY map plus feature-probe skip
- [PATCH bpf] (2026-06-09): this patch alone after Andrii asked to resend it
- v3 (2026-06-10): 2 patches; this skip plus smarter feature probes — **this is what landed**
- Review:
- Mykyta: skip is correct; making the probe token-aware would be worse. Acked-by.
- Andrii: this is the only v2 patch that should apply; resend it alone.
- Mykyta on the bpf-tree resend: retarget **bpf-next**, add a Fixes tag, include Acks. No NAK.
- No reviewer Cc: stable. bpf-next targeting is a process note, not a statement that the bug is absent from 6.18.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
- Record: Recipients included Andrii Nakryiko, Alexei Starovoitov, Daniel Borkmann, Eduard Zingerman, Mykyta Yatsenko, [email protected]. Right maintainers. Applied by Andrii.
**Step 4.3: SEARCH FOR THE BUG REPORT**
- Record: No syzbot/bugzilla. Trigger is in-tree tools/testing/selftests/bpf/prog_tests/token.c: obj_priv_map (QUEUE map only), obj_priv_prog (XDP only), freplace, implicit-token struct_ops. Author hit failing tests; v1 tried widening token permissions instead of fixing libbpf.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
- Record: v3 2/2 is the feature-probe follow-up (features.c). Not required for this skip to be correct. Not in this tree.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
- Record: lore.kernel.org/stable search returned HTTP 403. UNVERIFIED whether stable@ discussed this. No in-tree evidence of a prior rejection.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
- Record: bpf_object__probe_loading() only.
**Step 5.2: TRACE CALLERS**
- Record: Single caller, bpf_object_prepare() (libbpf.c ~8705), which is called from:
- bpf_object_load() if state < OBJ_PREPARED
- public bpf_object__prepare()
- Every normal bpf_object__load() / skeleton load goes through this after token setup.
**Step 5.3: TRACE CALLEES**
- Record: bump_rlimit_memlock(), bpf_prog_load(), close(), pr_warn(). After the skip, those are not used when a token is present.
**Step 5.4: FOLLOW THE CALL CHAIN**
- Record: Userspace, reachable from any app using in-tree libbpf/bpftool/selftests with a BPF token (explicit bpf_token_path or implicit /sys/fs/bpf). Not a kernel oops path. Unprivileged user- namespace workloads with delegated tokens are the intended users.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
- Record: Same skip already exists for obj->gen_loader. tools/lib/bpf/features.c still hardcodes probe program types with token_fd — that is series patch 2, still open in this tree.
## 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 (Makefile 6.18.53, git describe HEAD =
`v6.18.53-5049-g0f0bdc2b0dffb`), branch `autosel`.
- v6.18:tools/lib/bpf/libbpf.c has the pre-fix probe: token opts + SOCKET_FILTER/TRACEPOINT.
- Pre-fix hunk md5 matches v6.18 exactly.
- Kernel BPF token (kernel/bpf/token.c, 35f96de04127d) is in 6.18.
- Bug introduced ~6.9 (6b434b61b4d9e), well before 6.18.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
- Record: Clean apply. Context around bpf_object__probe_loading() matches 6.18. No refactor in the way.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
- Record: No other skip of this probe for tokens. No equivalent feature- probe fix. Token selftests still omit SOCKET_FILTER/TRACEPOINT for obj_priv_*, so they still depend on this libbpf change.
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
- Record: tools/lib/bpf — IMPORTANT, not CORE kernel. Used by bpftool, selftests, and distro in-tree libbpf. BPF tokens are the supported unprivileged/container path.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
- Record: Active (recent libbpf mmap/percpu/relocation fixes). Token wiring itself has been stable since 6.9; this is a late correctness fix, not churn in brand-new code.
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
- Record: Config/driver-specific in the BPF-token sense: users of libbpf object load with a token whose allowed types exclude SOCKET_FILTER **and** TRACEPOINT. That includes the in-tree token selftests and container/user-ns setups that delegate only XDP, struct_ops, maps, etc.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
- Record: Trigger is common for token users: every bpf_object__load()/prepare(). Not a race. Unprivileged tasks in a delegated user ns can hit it; that is the token design.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
- Record: Object load/prepare fails outright with a misleading “Couldn't load trivial BPF program” warning. Not a kernel oops/corruption. **Severity: MEDIUM-HIGH** for token users (feature completely unusable), **LOW** for everyone else (token_fd == 0 path is unchanged).
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
- Record:
- **Benefit:** Restricted-token libbpf loads work; in-tree token tests can pass; matches the token least-privilege model.
- **Risk:** Very low (net −4 lines, one extra early return).
- **Ratio:** Strongly favorable for 6.18.
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real, reproducible false failure on every object load with a restricted token
- In-tree selftests exercise exactly this (XDP-only, map-only, struct_ops-only tokens)
- Buggy code is in 6.18; tokens are in 6.18
- 10-line, obviously correct skip; same pattern as gen_loader
- Acked by Mykyta Yatsenko; applied by Andrii Nakryiko
- Clean apply; no new API
- Andrii treated this patch as independently landable
AGAINST:
- Userspace libbpf, not a kernel oops/UAF/deadlock
- No Cc: stable; reviewers asked for bpf-next (process, not “bug absent from 6.18”)
- Series patch 2 (feature probes) is still missing; some struct_ops+global-data cases may still fail
- Specialized to BPF token users, not all machines
UNRESOLVED:
- Stable@ thread search failed (HTTP 403)
- Cover-letter claim that a failed probe “drops the token reference” in the kernel was not independently verified; the libbpf-level hard-fail is verified from code and tests
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — skip is the same idea as gen_loader; reviewed/acked; tests exist
2. Fixes a real bug that affects users? **PASS** — object load fails for valid token configs
3. Important issue? **PASS** (MEDIUM-HIGH for token users) — complete load failure, not theoretical; fits “oh, that's not good”
4. Small and contained? **PASS** — 3/7 lines, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — 6.18 source matches the pre- image
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
- Record: None (not a device ID, quirk, DT, build, or docs fix). Qualifies as a normal small bugfix.
**Step 9.4: DECISION**
6.18 ships BPF tokens and this probe. Without the skip, libbpf treats a least-privilege token as “BPF does not work” and aborts prepare/load. That is a real, user-visible break for the token feature and for in-tree tests, with a tiny, maintainer-reviewed fix and negligible regression risk.
### What the commit solves for this tree
Restricted BPF tokens cannot load objects through libbpf because a dummy SOCKET_FILTER/TRACEPOINT probe is not in the token’s allow-list. Skipping the probe when a token FD exists restores load/prepare for those objects.
### Stable rules / risk
Meets the written rules: small, obviously correct, real bug, no new API, applies cleanly to 6.18. Benefit is restoring a supported 6.18 feature; risk is an extra early return on a userspace probe.
### Concerns
Feature-probe hardcoded types (series patch 2) remain in this tree, so some token+global-data cases may still be incomplete. That does not remove the standalone value of stopping probe_loading from failing the whole load.
Verification:
- [Phase 1] Parsed tags: author Yuan Chen; SOB Andrii Nakryiko; lore link; no Fixes/Reported-by/Cc-stable in the commit
- [Phase 2] Diff: tools/lib/bpf/libbpf.c, bpf_object__probe_loading(), +3/−7; skip on obj->token_fd; dummy loads use NULL opts
- [Phase 2] Confirmed OPTS_VALID(NULL) is true in libbpf_internal.h
- [Phase 3] Blame: token opts added in 6b434b61b4d9e (2024-01-23); ancestor of this tree
- [Phase 3] No Fixes tag; introducing commit present; patch 2 not in this tree
- [Phase 4] b4 dig -c d262a25d8b58: lore
https://patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1 selftest workaround → v2 series → bpf-only resend → v3 1/2 (landed)
- [Phase 4] b4 dig -w: bpf maintainers on Cc
- [Phase 4] mbox: Mykyta Acked-by; Andrii asked to land this patch alone; later asked bpf-next + Fixes tag
- [Phase 5] Only caller is bpf_object_prepare() ← bpf_object_load() and bpf_object__prepare()
- [Phase 6] git describe HEAD / make kernelversion: 6.18.53; v6.18 file matches pre-fix hunk md5
- [Phase 6] Token selftests in this tree still use XDP-only / map-only tokens without SOCKET_FILTER/TRACEPOINT
- [Phase 8] Failure mode: userspace object load abort, not kernel oops; severity MEDIUM-HIGH for token users
- UNVERIFIED: stable@ mailing-list discussion (lore 403); kernel “drops token reference” cover-letter claim
**YES**
tools/lib/bpf/libbpf.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
tools/lib/bpf/libbpf.c +3 -7
@@ -5070,12 +5070,8 @@ bpf_object__probe_loading(struct bpf_object *obj) BPF_EXIT_INSN(), };int ret, insn_cnt =ARRAY_SIZE (insns); -LIBBPF_OPTS (bpf_prog_load_opts, opts, - .token_fd = obj->token_fd, - .prog_flags = obj->token_fd ? BPF_F_TOKEN_FD : 0, - ); -if (obj->gen_loader) +if (obj->gen_loader || obj->token_fd)return 0 ; ret =bump_rlimit_memlock ();
@@ -5084,9 +5080,9 @@ bpf_object__probe_loading(struct bpf_object *obj) errstr(ret));/* make sure basic loading works */ - ret =bpf_prog_load (BPF_PROG_TYPE_SOCKET_FILTER ,NULL ,"GPL" , insns, insn_cnt, &opts); + ret =bpf_prog_load (BPF_PROG_TYPE_SOCKET_FILTER ,NULL ,"GPL" , insns, insn_cnt,NULL );if (ret <0 ) - ret =bpf_prog_load (BPF_PROG_TYPE_TRACEPOINT ,NULL ,"GPL" , insns, insn_cnt, &opts); + ret =bpf_prog_load (BPF_PROG_TYPE_TRACEPOINT ,NULL ,"GPL" , insns, insn_cnt,NULL );if (ret <0 ) { ret = errno; pr_warn("Error in %s(): %s. Couldn't load trivial BPF program. Make sure your kernel supports BPF (CONFIG_BPF_SYSCALL=y) and/or that RLIMIT_MEMLOCK is set to big enough value.\n",
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ksmbd: skip fallocate for SMB2_CREATE_ALLOCATION_SIZE on a stream handle
In reply to Sasha LevinFrom: Gael Blivet <[email protected]>
[ Upstream commit bfdf81c62f4f52a3626ea62db0744def6778e83f ]
smb2_open() calls vfs_fallocate(fp->filp, ...) unconditionally when a client's CREATE request includes an AllocationSize create context. For a stream handle, fp->filp refers to the base file's data fork (streams are xattr-backed on the same underlying file, not separate files), so this pre-allocates storage on the base file's actual data instead of doing anything meaningful for the stream -- fallocate has no applicability to an xattr-backed stream at all.
Skip the fallocate call for stream handles.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111**. The buggy vfs_fallocate() on stream CREATEs is present here, and the skip is a small, self-contained correctness fix that applies to this checkout.
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
- Record: **[ksmbd] [skip] skip fallocate for SMB2_CREATE_ALLOCATION_SIZE on a stream handle**
- Subsystem: ksmbd (in-kernel SMB3 server). Verb “skip” here means “do not run a VFS operation that does not apply.”
**Step 1.2: Tags**
- Record:
- Assisted-by: Claude:claude-sonnet-5
- Signed-off-by: Gael Blivet <[email protected]>
- Acked-by: Namjae Jeon <[email protected]> (on e360be3d03f77; the candidate copy uses Signed-off-by: Namjae Jeon)
- Signed-off-by: Steve French (on the smb.git copy)
- No Fixes:, Reported-by:, Tested-by:, Cc: stable, or Link:
- Absence of Fixes:/Cc: stable is expected for this review pipeline
**Step 1.3: Body**
- Record:
- **Bug:** smb2_open() always calls vfs_fallocate(fp->filp, FALLOC_FL_KEEP_SIZE, …) when CREATE has an AllocationSize context.
- **Root cause:** For a named-stream handle, fp->filp is the **base file**. Streams are xattr-backed, not separate files.
- **Symptom:** Preallocation (and a level-II oplock break) hits the base file’s data fork instead of the stream.
- **Failure mode:** Wrong-file disk preallocation; unexpected oplock break on the base file.
- No stack trace, no version list, no user report.
**Step 1.4: Hidden bug fix?**
- Record: **Yes, this is an explicit bug fix**, not cleanup. Cover letter for series 8/8: opening a stream with AllocationSize “fallocates storage on the underlying base file’s actual data.”
## Phase 2: Diff analysis
**Step 2.1: Inventory**
- Record:
- File: fs/smb/server/smb2pdu.c only
- Scope: **+16 / −7** (net +9), one function: smb2_open()
- Classification: **single-file surgical fix**
**Step 2.2: Code-flow change**
- Record:
- **Before:** If CREATE has SMB2_CREATE_ALLOCATION_SIZE, always smb_break_all_levII_oplock(work, fp, 1) then vfs_fallocate(fp->filp, FALLOC_FL_KEEP_SIZE, 0, alloc_size). Failures are only debug-logged.
- **After:** Same path, but only when !ksmbd_stream_fd(fp). Stream handles skip both the oplock break and fallocate.
- Affected path: SMB2 CREATE with AllocationSize on a stream, after the file is already opened.
**Step 2.3: Bug mechanism**
- Record:
- **Category:** logic / correctness (wrong object for a VFS call), with resource side effects
- **Mechanism:** Stream fds share the base struct file. ksmbd_stream_fd() is fp->stream.name != NULL. Stream I/O already goes through xattrs (ksmbd_vfs_stream_read/_write); fallocate has no stream equivalent.
- FALLOC_FL_KEEP_SIZE does not change i_size, but it **does** allocate blocks on the base inode and can fill the filesystem. vfs_fallocate() also takes file_start_write() and may run for a long time on a large client-supplied size (bounded by s_maxbytes).
**Step 2.4: Fix quality**
- Record:
- Obviously correct: skip a VFS op that cannot apply to an xattr stream.
- Matches existing stream guards (read/write/copy-chunk).
- Regression risk is **very low**: regular-file CREATE is unchanged; stream CREATE only stops a harmful no-op-for-the-stream.
- Incomplete vs SET_INFO: set_file_allocation_info() in this tree still fallocates fp->filp with no stream check. That does not make this CREATE skip wrong.
## Phase 3: Git history
**Step 3.1: Blame**
- Record:
- Unconditional fallocate in smb2_open() comes from e8c061917133dd (“ksmbd: opencode to avoid trivial wrappers”, 2021-06-22), replacing ksmbd_vfs_alloc_size().
- That commit **is an ancestor of this HEAD**.
- ksmbd_stream_fd() is from f44158485826c0 (2021-03-16) and is also an ancestor.
- Bug has been in ksmbd for the lifetime of this 6.12 line.
**Step 3.2: Fixes: tag**
- Record: **N/A** (no Fixes:). Introducer is the original CREATE AllocationSize handling, present since cifsd/e8c0619.
**Step 3.3: Related file history**
- Record:
- a9f106c765c12 — “fix wrong allocation size update in smb2_open()” (response timing, not this bug).
- 2a4179c99bc6b — overflow in set_file_allocation_info() (already in this tree).
- 3b41d8b05dc89 — “return requested create allocation size” is **not** in this tree (merge-base --is-ancestor failed). Candidate parent uses outer-scope alloc_size; 6.12 still has a local loff_t alloc_size. Functional hunk still matches.
**Step 3.4: Author**
- Record: Gael Blivet, stream/AAPL/Time Machine work; maintainer Namjae Jeon acked and applied this patch. Not a drive-by.
**Step 3.5: Dependencies**
- Record:
- Cover: **“None of this depends on or touches the AAPL/Time Machine feature series.”**
- Needs only ksmbd_stream_fd(), which exists here.
- Series is **[PATCH 8/8]**; this hunk does not need patches 1–7.
- git apply --check of e360be3d03f77 on this tree: **Hunk #1
succeeded at 3593 (offset -504 lines).**
## Phase 4: Mailing list / external
**Step 4.1: Original discussion**
- Record:
- b4 dig -c e360be3d03f77 →
https://patch.msgid.link/[email protected] - Series: **[PATCH 0/8] ksmbd: follow-up fixes to previously-merged patches** (2026-07-09)
- Only **v1** found (b4 dig -a).
- Namjae Jeon: **“Applied them except 0002, 0005 patch”** — this is patch 8, so it was applied. No NAK on patch 8. No Cc: stable in review.
**Step 4.2: Recipients (b4 dig -w)**
- Record: Gaël Blivet-Bailly, Namjae Jeon, [email protected]. Maintainer was on To/Cc and acked.
**Step 4.3: Bug report**
- Record: No syzbot/bugzilla. Found by **Sashiko (LLM review)** of stream-handling code. Related real-world class: namjaejeon/ksmbd#507 (SetInfo/EOF on a stream truncated the **base** file because fp->filp is the base file). Same object-confusion pattern.
**Step 4.4: Series context**
- Record: Eight independent follow-ups. Patch 8 is standalone. Also listed in the 7.3-rc1 ksmbd pull under alternate-data-stream handling (e360be3d03f77).
**Step 4.5: Stable list**
- Record: lore.kernel.org/stable returned **403**. **UNVERIFIED** whether stable@ already discussed this; that does not change the technical verdict.
## Phase 5: Semantic / call-graph
**Step 5.1: Functions**
- Record: smb2_open() only. Helper used: ksmbd_stream_fd().
**Step 5.2: Callers**
- Record: fs/smb/server/smb2ops.c maps SMB2_CREATE_HE → smb2_open. Reachable from any authenticated SMB2 CREATE.
**Step 5.3: Callees**
- Record: smb2_find_context_vals(), smb_break_all_levII_oplock(), vfs_fallocate(). Stream CREATE still sets fp->stream.name via smb2_set_stream_name_xattr() **before** this block (around line 3485).
**Step 5.4: Reachability**
- Record: **Yes, from the network.** Requires:
1. CONFIG_SMB_SERVER
2. Share with KSMBD_SHARE_FLAG_STREAMS
3. CREATE of name:stream plus AllocationSize create context (AlSi)
- Windows ADS and macOS resource-fork/Finder streams are the usual clients. Unprivileged local syscall is not the path; an authenticated SMB client is.
**Step 5.5: Similar patterns**
- Record: ksmbd_vfs_read/write already branch on ksmbd_stream_fd(). ksmbd_vfs_copy_file_ranges() returns -EBADF for streams. This CREATE fallocate path was the missing guard. set_file_allocation_info() still unguarded in **this** tree.
## Phase 6: This tree (6.12.111)
**Step 6.1: Buggy code present?**
- Record: **Yes.** fs/smb/server/smb2pdu.c ~3596–3602:
```3592:3602:fs/smb/server/smb2pdu.c
alloc_size =
le64_to_cpu(az_req->AllocationSize);
ksmbd_debug(SMB,
"request smb2 create allocate size :
%llu\n",
alloc_size);
smb_break_all_levII_oplock(work, fp, 1);
err = vfs_fallocate(fp->filp,
FALLOC_FL_KEEP_SIZE, 0,
alloc_size);
if (err < 0)
ksmbd_debug(SMB,
"vfs_fallocate is failed :
%d\n",
err);
```- ksmbd_stream_fd() is in fs/smb/server/vfs_cache.h.
- Candidate SHAs e360be3d03f77 / bfdf81c62f4f are **not** ancestors of HEAD.
**Step 6.2: Backport difficulty**
- Record: **Clean apply with offset** (git apply --check succeeded at line 3593). Local loff_t alloc_size vs later outer-scope alloc_size does not conflict with the wrapped lines.
**Step 6.3: Related fixes already here?**
- Record: No skip of CREATE fallocate for streams. Overflow check in SET_INFO allocation is a different bug.
## Phase 7: Subsystem context
**Step 7.1**
- Record: **ksmbd (fs/smb/server)**, **IMPORTANT** (in-kernel SMB3 server for NAS/shares). Not mm/core, but network-facing and used in production.
**Step 7.2**
- Record: Actively backported on this branch (many ksmbd fixes in recent git log -- fs/smb/server).
## Phase 8: Impact and risk
**Step 8.1: Who is affected**
- Record: ksmbd users with **streams enabled**, when a client CREATEs a named stream with AllocationSize. Typical Windows/macOS interoperability.
**Step 8.2: Trigger**
- Record: Authenticated SMB CREATE of file:stream + AllocationSize. Not every open; common enough for ADS-aware clients. Same client could already write the file; unique harm is **wrong object** (base file) and a large fallocate without intending to preallocate the data fork.
**Step 8.3: Failure mode**
- Record:
- Preallocates blocks on the **base file** (FALLOC_FL_KEEP_SIZE → no size change, but real space use).
- Breaks level-II oplocks on the base file (other clients can lose caching).
- Large AllocationSize can run a long fallocate under file_start_write() (filesystem write exclusion).
- **Severity: HIGH** for disk/oplock side effects on a NAS; not a panic/UAF. Not content corruption of existing data.
**Step 8.4: Risk–benefit**
- Record:
- **Benefit:** Stops wrong-file preallocation and spurious oplock breaks; one if around existing code.
- **Risk:** Very low. Stream CREATE AllocationSize currently does the wrong thing; skipping is the correct xattr-stream behavior.
- **Ratio:** Favorable.
## Phase 9: Synthesis
**Step 9.1: Evidence**
**For:**
- Real wrong-file VFS operation, present since 2021, present in 6.12.111
- User-visible: disk on the base file, oplock disruption
- Small, obviously correct, applies with offset
- ksmbd_stream_fd() already here; no AAPL/Time Machine dependency
- Maintainer applied it (patch 8 of 8)
- Same stream/fp->filp confusion class as documented user bugs
**Against:**
- No crash/UAF/CVE; found by automated review, not a reporter
- SET_INFO allocation path still unfixed here
- Needs streams share flag
- lore stable search unverified (HTTP 403)
**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** — skip is correct; maintainer applied it.
2. Real bug affecting users? **PASS** — wrong-file fallocate on stream CREATE.
3. Important (crash/security/corruption/deadlock/etc.)? **PASS** — unexpected allocation and oplock break on the base file of a network file server; can consume substantial disk.
4. Small and contained? **PASS** — ~9 lines, one function.
5. No new features/APIs? **PASS**
6. Applies to this tree? **PASS** — git apply --check succeeded.
**Step 9.3: Exceptions**
- Record: Not a device-ID/quirk/DT/build/doc exception. Qualifies as a normal small bugfix.
**Step 9.4: Decision**
Backport to **this** 6.12.111 tree. The bug is here, the helper is here, the patch applies, and the change only disables a harmful path.
---
### What this solves for 6.12 users
On ksmbd shares with named streams, an SMB2 CREATE of an alternate data stream that includes AllocationSize currently calls vfs_fallocate() on the **base file**. That can allocate disk and break oplocks on the wrong object. Streams are xattr-backed; fallocate cannot apply to them. Skipping it is the correct, minimal fix.
### Verification
- **[Phase 1]** Parsed tags on e360be3d03f77 / bfdf81c62f4f (same patch-id 8e46981f5116…); no Fixes/Reported-by/Cc:stable
- **[Phase 2]** Diff: wrap fallocate + oplock break in if (!ksmbd_stream_fd(fp)) in smb2_open()
- **[Phase 3]** git blame: fallocate from e8c061917133dd (ancestor); ksmbd_stream_fd from f44158485826c0 (ancestor)
- **[Phase 3]** git merge-base --is-ancestor e360be3d03f77 HEAD → not in this tree
- **[Phase 3]** git merge-base --is-ancestor 3b41d8b05dc89 HEAD → later alloc_size-field commit not here
- **[Phase 4]** b4 dig -c e360be3d03f77 → lore msgid [email protected]; series 8/8
- **[Phase 4]** b4 dig -a: v1 only; b4 dig -w: linux-cifs + Namjae Jeon
- **[Phase 4]** mbox: Namjae “Applied them except 0002, 0005”; patch 8 applied; no NAK
- **[Phase 4]** Cover: independent of Time Machine/AAPL
- **[Phase 5]** SMB2_CREATE_HE → smb2_open; streams gated by KSMBD_SHARE_FLAG_STREAMS
- **[Phase 6]** git describe HEAD → p-6.12-3-gc504cf0baa3d8; make kernelversion → **6.12.111**
- **[Phase 6]** Buggy lines at smb2pdu.c:3596–3602; git apply --check succeeded at 3593
- **[Phase 8]** Failure mode: wrong-file preallocation + oplock break; severity HIGH for ksmbd/NAS, not a panic
- **UNVERIFIED:** stable@ lore search (HTTP 403); whether Windows always sends AllocationSize on ADS CREATE (bug is still real when it does)
**YES**
fs/smb/server/smb2pdu.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
fs/smb/server/smb2pdu.c +16 -7
@@ -3633,13 +3633,22 @@ int smb2_open(struct ksmbd_work *work)ksmbd_debug (SMB ,"request smb2 create allocate size : %llu\n" , alloc_size); -smb_break_all_levII_oplock (work, fp,1 ); - err =vfs_fallocate (fp->filp,FALLOC_FL_KEEP_SIZE ,0 , - alloc_size); -if (err <0 ) -ksmbd_debug (SMB , -"vfs_fallocate is failed : %d\n" , - err); +/* +* fp->filp is the base file's data fork for a stream +* handle (streams are xattr-backed on the same +* underlying file) -- fallocate has no meaning for a +* stream and would otherwise pre-allocate storage on +* the base file's data instead. +*/ +if (!ksmbd_stream_fd (fp)) { +smb_break_all_levII_oplock (work, fp,1 ); + err =vfs_fallocate (fp->filp,FALLOC_FL_KEEP_SIZE ,0 , + alloc_size); +if (err <0 ) +ksmbd_debug (SMB , +"vfs_fallocate is failed : %d\n" , + err); + } } context =smb2_find_context_vals (req,SMB2_CREATE_QUERY_ON_DISK_ID ,4 );
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 clk: clocking-wizard: fix clock difference detection
In reply to Sasha LevinFrom: Colin Foster <[email protected]>
[ Upstream commit 006ba909c240b832c876b7aed29c6beec9d1f5e5 ]
---
LLM Generated explanations, may be completely bogus:
The local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The change is a one-line restoration of abs() in Xilinx Clocking Wizard divisor search: unsigned wrap made frequencies below the request look like ~2^64 error, so they were ignored.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[clk / xilinx clocking-wizard] [fix] [clock difference detection]** — restore correct closest-match comparison when computed frequency is below the requested rate.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record (from git show 006ba909c240b):
- Reviewed-by: Shubhrajyoti Datta \<[email protected]\> (Xilinx/AMD clocking-wizard author)
- Reviewed-by: Brian Masney \<[email protected]\> (clk co-maintainer; also committer)
- Signed-off-by: Colin Foster \<[email protected]\> (author)
- Signed-off-by: Brian Masney \<[email protected]\>
- No Fixes:, Cc: stable, Reported-by, Tested-by, Link, or Acked-by in the **merged** commit
- Absence of Fixes/Cc:stable is expected for this review pipeline and is not a negative
The merged git message has **no body**. The mailing-list submission did (see Phase 4).
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Merged commit: subject + tags only.
Mailing-list body (from b4 mbox, not in git): unsigned “rollover” in diff = freq - rate. Frequencies below the request produced diffs like 18446744073708237796 (2^64 wrap) and were not considered. Author included before/after traces at 133312500 Hz / parent 99999000 Hz.
Cover letter: this is patch **1/3** of “clock-wizard fixups”. The series also optimizes exact-match search (2/3) and removes the 20 kHz WZRD_MIN_ERR cutoff (3/3). Cover letter: the 20 kHz check made **out- of-tree consumers fail clk_set_rate**; patch 1 is the separate difference-calculation bug.
Record: **[Bug: unsigned underflow when freq \< rate] [Symptom: wrong closest match and/or -EBUSY from set_rate/determine_rate] [Root cause:abs() dropped in a later refactor] [No version tags in the commit itself]**
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not hidden.** Subject says “fix”. It is a real comparison bug, not cleanup.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/clk/xilinx/clk-xlnx-clock-wizard.c — **1 insertion, 1 deletion**
- Function: clk_wzrd_get_divisors()
- Scope: **single-file surgical one-liner**
- Versal sibling clk_wzrd_get_divisors_ver() is **not** changed (already uses abs())
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Before: diff = freq - rate with freq/diff as u64. If freq < rate, subtraction wraps. best_diff starts at -1ULL. Wrapped diffs lose to any over-rate candidate; if every candidate is under-rate, best_diff stays huge and `return best_diff < WZRD_MIN_ERR ? 0 :
-EBUSY` returns **-EBUSY** (20 kHz threshold still present in the parent of this commit).
After: diff = abs(freq - rate) so both sides of the target compete; closest match wins.
Path: clock **determine_rate / set_rate** for non-Versal Clocking Wizard (dynamic reconfig / fractional M and O).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Logic / correctness + unsigned wrap]** — abs() was dropped when 7681f64e6404ed switched the search to u64 and best_diff. Original v6.4 code in 595c88cda65d30 used diff = abs(freq - rate). This restores that.
Kernel abs() on the u64 difference works here: wrap of a small Hz delta becomes a negative signed long long, then abs() yields the true delta. Clock Hz values are far below 2^63. Same pattern as the Versal function.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: **Obviously correct, minimal, matches the pre-regression and Versal code.** Regression risk is low: set_rate may now succeed with a slightly-below rate instead of failing or picking a worse over-rate. That is the intended fix. abs_diff() would be cleaner with matching types, but reviewers accepted abs(), and it matches the sibling.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Current abs() line: **006ba909c240b** (this commit), 2026-06-29
- Surrounding fractional search: **7681f64e6404ed** (“calculate dividers fractional parts”), 2025-01-06, **v6.13-rc1**
- Function introduced: **595c88cda65d30** (v6.4-rc1) **with abs() already**
- 7681f64e **removed** abs() and used diff = freq - rate
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Buggy commit is **7681f64e6404ed**, ancestor of HEAD (git merge-base --is-ancestor).
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: 3-patch series, same author/date:
1. **006ba909c240b** — this fix (1/3)
2. **9329714414d1f** — early-out on exact match (optimization, 2/3)
3. **54ed94b709e03** — drop 20 kHz WZRD_MIN_ERR (3/3)
This patch is **standalone**. It does not need 2/3 or 3/3. With the 20 kHz check still present, abs() is what lets a close **under**-rate pass best_diff < 20000 instead of wrapping to -EBUSY.
Related: **4adf593c6fc5a** overflow fix in the same file (Cc: stable,
the Versal path.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Colin Foster is not the historical driver author (that is Shubhrajyoti Datta / AMD). Datta reviewed this. Foster’s three clocking- wizard commits are this series.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs clk_wzrd_get_divisors() with u64 freq/diff as in 7681f64e. That is in this tree. **Applies standalone.** abs() is in include/linux/math.h.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 006ba909c240b →
https://patch.msgid.link/20260629205346.3228886-2-colin.foster@in-
advantage.com
- b4 dig -a: only **PATCH v2 1/3** (v2: rebase + signoffs). v1 not in the matched thread.
- Saved mbox: cover + 3 patches, **no reply NAKs** in that thread
- WebFetch/curl to lore.kernel.org: **403** — discussion beyond the mbox is UNVERIFIED
**Step 4.2: CHECK WHO REVIEWED THE PATCH**b4 dig -w To/Cc: linux-clk, linux-arm-kernel, linux-kernel, Shubhrajyoti Datta, Michal Simek, Brian Masney, Stephen Boyd, Michael Turquette.
Record: **Clk lists + clk maintainers CC’d; Reviewed-by from AMD driver author and Brian Masney.**
**Step 4.3: SEARCH FOR THE BUG REPORT**
No syzbot/bugzilla. Evidence is the author’s traces (unsigned wrap ~2^64) and cover-letter clk_set_rate failures.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: **v2 0/3 “clock-wizard fixups”.** 1/3 is this logic fix; 2/3 optimization; 3/3 policy (allow error ≥ 20 kHz). 1/3 does not depend on the others.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search returned **403**. UNVERIFIED whether stable@ discussed it.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
semcode MCP: **not available**. Used grep + callers in this file.
**Step 5.1: KEY FUNCTIONS**
Record: **clk_wzrd_get_divisors()** only.
**Step 5.2: TRACE CALLERS**
- clk_wzrd_dynamic_all_nolock() → clk_wzrd_dynamic_all() → clk_wzrd_clk_div_all_ops.set_rate
- clk_wzrd_determine_rate_all() → clk_wzrd_clk_div_all_ops.determine_rate
Versal ops use clk_wzrd_get_divisors_ver(), already using abs().
**Step 5.3: TRACE CALLEES**div64_u64, DIV_ROUND_CLOSEST_ULL, writes into divider->{m,m_frac,d,o,o_frac}. No allocation/locking inside the search.
**Step 5.4: FOLLOW THE CALL CHAIN**
Probe registers outputs with clk_wzrd_clk_div_all_ops for non-Versal dynamic-reconfig Clocking Wizard (xlnx,clocking-wizard, v5.2, v6.0). clk_set_rate / clk_round_rate from consumers (display pixel clocks were the reason fractional M/O were added).
Record: **Reachable from userspace/driver clock APIs on that IP. Not a syscall bug by itself; standard clk consumer path.**
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Versal clk_wzrd_get_divisors_ver() already has diff = abs(freq - rate) (e0a94c6bb5b48). Original non-Versal code had abs() until 7681f64e dropped it.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- Tree: **v7.3-rc4** / Makefile **7.3.0-rc4**
- File and clk_wzrd_get_divisors() **exist**
- HEAD already has diff = abs(freq - rate) because **006ba909c240b is an ancestor** (git merge-base --is-ancestor → yes). git describe --contains → **v7.3-rc1**
- Bug introduced **v6.13** (7681f64e), long before 7.3
- Pre-fix code (parent of 006ba909) still had diff = freq - rate and WZRD_MIN_ERR 20000
This is **not** “bug added after this branch.” The driver and the regression are part of this 7.3 line.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
On **this** checkout the one-liner is already applied; a second apply would not change anything. Against the pre-fix function the hunk is context-identical (one line). Expected difficulty: **clean apply** on a tree that still has diff = freq - rate.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This exact fix **is** in HEAD, plus 2/3 and 3/3. That is the mainline landing, not a separate in-tree workaround. No competing alternate fix.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **drivers/clk/xilinx/** — Xilinx Clocking Wizard (CONFIG_COMMON_CLK_XLNX_CLKWZRD, depends on OF). **PERIPHERAL / platform-specific** (FPGA/SoC), but it is the clock provider for that IP, including pixel-clock accuracy.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Active through 2025–2026 (fractional dividers, Versal, overflow fix, this series). Mature in-tree driver, not staging.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / config-specific** — COMMON_CLK_XLNX_CLKWZRD, non-Versal Clocking Wizard with dynamic reconfig / fractional search. Not universal.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: **clk_set_rate / determine_rate** when the closest achievable frequency is below the request, or when under-rate candidates must compete with worse over-rate ones. Common for arbitrary pixel/device rates. Unprivileged userspace can hit it if a consumer exposes clock control; typically a device driver at probe/modeset.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Wrong clock chosen or clk_wzrd_get_divisors() returns -EBUSY** so rate set fails. Not oops/UAF/deadlock. Author showed wraparound and clk_set_rate failure in the series. **Severity:
MEDIUM** (functional breakage on that hardware, including display clocks).
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record: **Benefit: medium** for Clocking Wizard users (correct closest rate; fewer false -EBUSY). **Risk: very low** (1 line, same as old/Versal code). **Ratio: favorable.**
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real unsigned wrap; traces show ~2^64 diffs for freq \< rate
- Regression: 595c88cd used abs(); 7681f64e dropped it in v6.13
- Restores closest-match; can avoid -EBUSY under the 20 kHz check
- 1 line, obviously correct
- Reviewed by AMD driver author and clk co-maintainer
- Driver and function exist in this 7.3 tree; bug predates 7.3
- Standalone; not a new API
AGAINST:
- Merged commit message has no body (explanation only on list)
- Not crash/security/corruption
- Peripheral Xilinx FPGA/SoC driver
- Cover letter also talks about OOT consumers and patch 3’s 20 kHz policy
- Author’s 133312500 Hz sample still picked the over-rate 19500 Hz candidate; abs() matters when the **best** match is below the request
- lore.kernel.org HTTP 403; no stable@ thread verified
UNRESOLVED:
- Full v1 review thread
- Whether stable@ already took this (403)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — wrap math is clear; author posted before/after; two Reviewed-by
2. Fixes a real bug that affects users? **PASS** — wrong diffs; set_rate can fail or pick a worse rate
3. Important issue? **PASS** (medium) — not a panic, but the driver’s job is correct rates; pixel-clock path was the reason fractional search exists
4. Small and contained? **PASS** — 1 line, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — same function is here; HEAD already contains this commit as of v7.3-rc1, which means 7.3’s own code already includes the fix. That does not make the fix unsuitable; it confirms the code matches.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **None** (not a device ID, quirk, DT, build, or docs exception). It is a normal small correctness fix.
**Step 9.4: MAKE YOUR DECISION**
This tree is 7.3-rc4 and already contains the line, because the commit landed in v7.3-rc1. The decision is still whether this is appropriate **for this tree’s code**, not whether the pipeline already “selected” it.
It is a **v6.13 regression** (accidental drop of abs()), one line, reviewed, and it fixes real closest-rate / -EBUSY behavior on Xilinx Clocking Wizard. That meets stable rules for this checkout. Later series patches (search micro-opt, dropping 20 kHz) are separate and not required.
===============================================================
DETAILED EXPLANATION
===============================================================
**Problem:** clk_wzrd_get_divisors() ranked candidates with unsigned freq - rate. Any frequency below the request wrapped to ~2^64, so those configs were ignored. Combined with best_diff < 20000, that yields **-EBUSY** when the only close match is slightly low, or a **worse higher** clock when a closer lower one exists. That is exactly the fractional-divider accuracy the v6.13 work was supposed to provide (pixel clocks).
**Why it matters here:** This 7.3 tree has that search (7681f64e). Consumers of xlnx,clocking-wizard that call clk_set_rate can fail or lock the IP to the wrong rate.
**Stable rules:** Small, obvious, real bug, no new API. Risk is a correct rate instead of failure/wrong rate.
**Concerns:** Empty merged commit message; not a crash. Series 3/3 is a policy change and should not be required. No backport rework is needed on a tree that still has diff = freq - rate.
===============================================================
Verification:
- [Phase 1] git show 006ba909c240b: subject+tags only; Reviewed-by Datta and Masney; no Fixes/stable
- [Phase 1] b4 mbox body: wraparound explanation and traces (133312500 Hz)
- [Phase 2] Diff: one line diff = freq - rate → diff = abs(freq - rate) in clk_wzrd_get_divisors
- [Phase 2] Parent still has `return best_diff < WZRD_MIN_ERR ? 0 :
-EBUSY with WZRD_MIN_ERR` 20000
- [Phase 2] include/linux/math.h: abs() signed conversion; Hz deltas fit
- [Phase 3] blame: abs line is 006ba909; search from 7681f64e6404ed (v6.13-rc1)
- [Phase 3] 595c88cda65d30 originally used diff = abs(freq - rate); 7681f64e removed it
- [Phase 3] git merge-base --is-ancestor 006ba909c240b HEAD → yes; --contains → v7.3-rc1
- [Phase 3] Series 006ba909, 9329714414d1f, 54ed94b709e03; this patch is 1/3 standalone
- [Phase 4] b4 dig -c:
patch.msgid.link/20260629205346.3228886-2-colin.foster@in- advantage.com
- [Phase 4] b4 dig -a: v2 1/3 only in match; cover v2 rebase + signoffs
- [Phase 4] b4 dig -w: linux-clk, Boyd, Turquette, Datta, Simek, Masney
- [Phase 4] WebFetch/curl lore: 403; stable@ discussion UNVERIFIED
- [Phase 5] Callers: clk_wzrd_dynamic_all_nolock, clk_wzrd_determine_rate_all (non-Versal ops)
- [Phase 5] Versal sibling already abs() via e0a94c6bb5b48 (v6.18-rc1)
- [Phase 6] git describe HEAD v7.3-rc4-27-gf0100363d8c37; make kernelversion 7.3.0-rc4
- [Phase 6] HEAD already has diff = abs(freq - rate) at lines 375 and 416
- [Phase 7] Kconfig COMMON_CLK_XLNX_CLKWZRD; compatibles xlnx,clocking-wizard{,-v5.2,-v6.0}
- [Phase 8] Failure mode: wrong rate or -EBUSY on set_rate; severity MEDIUM
- UNVERIFIED: v1 thread contents; stable@ history (lore 403)
===============================================================
**YES**
drivers/clk/xilinx/clk-xlnx-clock-wizard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/xilinx/clk-xlnx-clock-wizard.c +1 -1
@@ -406,7 +406,7 @@ static int clk_wzrd_get_divisors(struct clk_hw *hw, unsigned long rate,if (o < omin || o > omax)continue ; freq =DIV_ROUND_CLOSEST_ULL (vco_freq, o); - diff = freq - rate; + diff =abs (freq - rate);if (diff < best_diff) { best_diff = diff; divider->m = m >>3 ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 drm/amdgpu: add buf length check
In reply to Sasha LevinFrom: Gangliang Xie <[email protected]>
[ Upstream commit 473f99e4a262776141366f7fb10f101d0f22b019 ]
add buf length check before using it to access data
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.18.53** (v6.18.53-5049-g0f0bdc2b0dffb on autosel). The buggy debugfs TA load/invoke paths are in this tree; the length checks are not in the v6.18.53 tag. Verdict is for this checkout only.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [drm/amdgpu] [add] [buf length check before using a userspace- supplied length to copy/access data]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Fixes: — none (expected)
- Reported-by: — none
- Tested-by: — none
- Reviewed-by: Tao Zhou <[email protected]>
- Acked-by: — none
- Link: — none in the commit; lore found separately
- Cc: [email protected] — none (expected)
- Signed-off-by: Gangliang Xie <[email protected]> (author)
- Signed-off-by: Alex Deucher <[email protected]> (amdgpu maintainer)
- Ignore: [Upstream commit 473f99e4a262…], Signed-off-by: Sasha Levin (pipeline)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug description: userspace-supplied buffer lengths are used to copy/access data without enough validation
- Symptom: out-of-bounds access / invalid allocation when the length is too small or too large
- Version info: none in the message
- Root cause: ta_bin_len / shared_buf_len from copy_from_user are trusted after only a partial check (load has an upper bound; invoke has none)
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: This is a real bounds-check fix, not cleanup. “Add buf length check before using it to access data” is an OOB / crash-prevention patch.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c (+4 / -1)
- Functions: ta_if_load_debugfs_write(), ta_if_invoke_debugfs_write()
- Scope: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Load, before: reject only ta_bin_len > PSP_1_MEG (0x100000). ta_bin_len == 0 or smaller than struct common_firmware_header (32 bytes) still proceeds to memdup_user() then get_bin_version().
- Load, after: also reject ta_bin_len < sizeof(struct common_firmware_header).
- Invoke, before: shared_buf_len is copied from userspace and passed straight to memdup_user() with no min/max check.
- Invoke, after: reject shared_buf_len == 0 or shared_buf_len > PSP_1_MEG.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Memory safety / size validation (OOB read + unbounded copy).**
Load path (the crash):
- get_bin_version() does hdr->ucode_version at offset 16 of struct common_firmware_header.
- ta_bin_len == 0: memdup_user(..., 0) goes through kmalloc(0) → ZERO_SIZE_PTR ((void *)16). Reading ucode_version is a distinct fault.
- 0 < ta_bin_len < 32: allocated buffer is smaller than the header; reading ucode_version is an out-of-bounds read (KASAN OOB / slab overrun).
Invoke path:
- No upper bound: memdup_user() of a user-controlled uint32_t (up to ~4GiB). That is an unbounded kernel allocation. prep_ta_mem_context() later rejects lengths above shared_mem_size (PSP_RAS_SHARED_MEM_SIZE = 0x4000), so this is not an OOB write into TA shared memory, but it is still a large GFP_USER allocation from debugfs.
- Zero length: memcpy of 0 bytes would not crash; the !shared_buf_len check is defensive.
This completes c99769bceab4e (“Validate TA binary size” / “avoid OOB write”), which added only the load-path upper bound and was `Cc:
[email protected]`.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct, 4 lines, no API/locking/structure changes. Regression risk is very low: only rejects sizes that cannot be a valid firmware header or that exceed the existing 1MiB PSP cap. Invoke still allows up to 1MiB while shared mem is 16KiB; that is conservative, not wrong.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Buggy debugfs TA I/F: e50d9ba0d2cd0 (2022-04-21) “Add debugfs TA load/unload/invoke support” — in this tree (present since ~v5.19-era).
- Load upper bound: c99769bceab4e (2024-08-20) — in v6.18.
- memdup_user conversion: 99eeb8358e6cd (2025-09-08) — in v6.18; no functional change.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The incomplete prior fix is c99769bceab4e, which is in this tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent related commits on this file: locking (5c42d9f8b0049, not in v6.18.53), memdup_user, “Validate TA binary size”. This patch is standalone; it only tightens existing if checks and does not depend on the locking change. Dry-run apply of the upstream diff onto the v6.18.53 file succeeded.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Gangliang Xie is an AMD contributor with nearby hardening checks (add first record offset check, add check for xcp id). Not the subsystem maintainer. Maintainer Alex Deucher signed it off.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None required. The functions, PSP_1_MEG, memdup_user, and the load-path upper bound all exist in this tree. Standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 473f99e4a262:
https://patch.msgid.link/[email protected]
- b4 dig -a: single revision **v1 only** (2026-06-16), no v2/v3
- Thread: author patch + Reviewed-by: Tao Zhou. No NAK, no stable nomination in review, no discussion of risk
- lore.kernel.org HTTP fetch returned 403; thread recovered via b4 dig -m
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To [email protected]; Cc Hawking Zhang, Tao Zhou. Reviewed-by Tao Zhou; Signed-off-by Alex Deucher (amdgpu maintainer).
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by, syzbot, or bugzilla. Internal AMD hardening, not a public crash report.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone one-patch series. Sibling in-tree OOB fix c99769bceab4e was explicitly Cc: stable.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable HTTP 403. No evidence in the amd-gfx thread that this was rejected for stable. UNVERIFIED: no stable-list discussion recovered.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: ta_if_load_debugfs_write, ta_if_invoke_debugfs_write. Helpers used: get_bin_version, prep_ta_mem_context, memdup_user.
**Step 5.2: TRACE CALLERS**
Record: Only wired as .write in ta_load_debugfs_fops / ta_invoke_debugfs_fops. Created by amdgpu_ta_if_debugfs_init() from amdgpu_debugfs.c as:
- /sys/kernel/debug/dri/<N>/ta_if/ta_load (mode 0200)
- /sys/kernel/debug/dri/<N>/ta_if/ta_invoke (mode 0200) Under #if defined(CONFIG_DEBUG_FS).
**Step 5.3: TRACE CALLEES**
Record: copy_from_user → memdup_user → get_bin_version / prep_ta_mem_context → PSP TA load/invoke. psp_copy_fw() already uses if (!bin_size || bin_size > PSP_1_MEG) before memcpy into a 1MiB buffer — the same pattern this patch adds.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable from a write to those debugfs files. Not a syscall for unprivileged users; debugfs is typically root/CAP_SYS_ADMIN. Still a documented load path: writing a truncated TA blob follows the intended interface and oopses.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same 0 / PSP_1_MEG check already exists in psp_copy_fw(). The 2024 load-path upper bound was the same class of bug and went to stable.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. v6.18.53 has:
```
if (ta_bin_len > PSP_1_MEG)
return -EINVAL;
```and invoke memdup_user(&buf[copy_pos], shared_buf_len) with no length check. Bug introduced in 2022 (e50d9ba0d2cd0); load upper bound only since 2024.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply onto the v6.18.53 file (dry-run patch -p1 return 0). Context matches. No rework needed.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: Upper-bound-only fix c99769bceab4e is in this tree. This commit is the missing lower bound and the invoke-path check. No duplicate of this exact fix in v6.18.53.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/gpu/drm/amd/amdgpu — IMPORTANT (very common GPU driver), but this path is debugfs/CONFIG_DEBUG_FS, so impact is narrower than core amdgpu.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively developed; this file has had several stability fixes (NULL deref, locking, OOB size). Mature debugfs interface (since 2022), not brand-new code.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: AMDGPU users with CONFIG_DEBUG_FS, writing dri/<N>/ta_if/ta_load or ta_invoke. Driver-specific + config- specific (debugfs). Not universal.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Write a length field that is 0, smaller than the firmware header, or (invoke) larger than 1MiB. Easy to hit with a truncated TA binary on the documented load interface. Unprivileged users generally cannot; root/debugfs can.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY** Record:
- Load, ta_bin_len == 0: ZERO_SIZE_PTR deref → oops. **HIGH**
- Load, undersized header: OOB read. **HIGH**
- Invoke, huge length: large GFP_USER alloc, then -EINVAL from prep_ta_mem_context. **MEDIUM** (DoS-ish, privileged)
- Invoke, zero length: not a demonstrated crash. **LOW**
Overall severity: **HIGH** for the load-path oops/OOB; interface is privileged.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: prevents a kernel oops/OOB on a shipped debugfs firmware-load path; finishes a check that stable already accepted
- Risk: 4 lines, reject-only, very low
- Ratio: benefit > risk
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real OOB / ZERO_SIZE_PTR crash on load with a too-small ta_bin_len
- Invoke path had no length cap at all (unbounded memdup_user)
- Same file’s prior OOB size check was Cc: stable
- Same !size || size > PSP_1_MEG pattern already used in psp_copy_fw()
- 4-line, obviously correct, maintainer-acked
- Buggy code exists in this 6.18.53 tree; patch applies cleanly
- No new API/feature
AGAINST:
- debugfs, mode 0200, typically root-only
- No public reporter, syzbot, or crash log
- Sparse commit message; no Fixes:
- Invoke zero-length is not itself a crash
UNRESOLVED:
- Could not read lore.kernel.org/stable over HTTP (403)
- No evidence of an in-the-wild crash, only code-path analysis
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — reviewed, maintainer SOB, trivial predicates
2. Fixes a real bug that affects users? **PASS** — documented TA load path oopses on a truncated blob
3. Important issue (crash, security, corruption, deadlock)? **PASS** — kernel oops / OOB read (privileged debugfs, still a crash)
4. Small and contained? **PASS** — +4/-1, one file
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — clean apply to v6.18.53 file; all helpers present
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary small memory-safety fix.
**Step 9.4: MAKE YOUR DECISION**
This belongs in this 6.18.y tree. The load-path hole is a real oops, the invoke path was never given the cap that load got in 2024, and the patch is the smallest possible completion of that already-stable-worthy check.
What it solves for stable users: writing a too-small TA binary to ta_load no longer walks off a kernel buffer (or ZERO_SIZE_PTR); ta_invoke no longer memdup_users an unchecked userspace length.
Risk vs benefit: four reject-only lines vs. a debugfs-triggered oops on a common driver. Backport.
Verification:
- [Phase 1] Parsed tags: Reviewed-by Tao Zhou; SOB Alex Deucher; no Fixes/Reported-by/Cc:stable
- [Phase 1] Body: “add buf length check before using it to access data”
- [Phase 2] Diff: +4/-1 in amdgpu_psp_ta.c; load min-size; invoke 0/PSP_1_MEG
- [Phase 2] common_firmware_header is 32 bytes; ucode_version at offset 16 (amdgpu_ucode.h)
- [Phase 2] memdup_user() → kmem_buckets_alloc → kmalloc; kmalloc(0) returns ZERO_SIZE_PTR (include/linux/slab.h)
- [Phase 3] File added in e50d9ba0d2cd0 (2022); upper bound c99769bceab4e (Cc:stable, in v6.18); memdup_user 99eeb8358e6cd in v6.18
- [Phase 3] No Fixes tag; git merge-base --is-ancestor e50d9ba0d2cd0 HEAD yes
- [Phase 3] Author: AMD contributor; maintainer merged
- [Phase 4] b4 dig -c 473f99e4a262: msgid [email protected]
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: amd-gfx, Hawking Zhang, Tao Zhou
- [Phase 4] mbox: Reviewed-by only; no NAK
- [Phase 4] lore.kernel.org WebFetch 403; stable-list search UNVERIFIED
- [Phase 5] Callers: debugfs fops only; amdgpu_ta_if_debugfs_init() from amdgpu_debugfs.c
- [Phase 5] psp_copy_fw() already has !bin_size || bin_size > PSP_1_MEG
- [Phase 5] PSP_RAS_SHARED_MEM_SIZE = 0x4000
- [Phase 6] git describe HEAD → v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion → 6.18.53
- [Phase 6] v6.18.53 file lacks both new checks; dry-run apply of upstream diff: success
- [Phase 6] git merge-base --is-ancestor 473f99e4a262 HEAD no (upstream not in this history as that SHA); buggy code is still present at the v6.18.53 tag
- [Phase 8] Failure: load-path oops/OOB HIGH; invoke unbounded alloc MEDIUM; trigger is debugfs write
**YES**
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +4 -1
@@ -166,7 +166,8 @@ static ssize_t ta_if_load_debugfs_write(struct file *fp, const char *buf, size_tif (ret)return -EFAULT ; -if (ta_bin_len >PSP_1_MEG ) +if (ta_bin_len <sizeof (struct common_firmware_header ) || + ta_bin_len >PSP_1_MEG )return -EINVAL ; copy_pos +=sizeof (uint32_t );
@@ -321,6 +322,8 @@ static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf, size ret =copy_from_user ((void *)&shared_buf_len, &buf[copy_pos],sizeof (uint32_t ));if (ret)return -EFAULT ; +if (!shared_buf_len || shared_buf_len >PSP_1_MEG ) +return -EINVAL ; copy_pos +=sizeof (uint32_t ); shared_buf =memdup_user (&buf[copy_pos], shared_buf_len);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 drm/amd/pm: Validate Vega hwmgr PowerPlay table bounds
In reply to Sasha LevinFrom: Yang Wang <[email protected]>
[ Upstream commit 3a8d8e0b7f61cd759d5d4870b6220161f8a5b114 ]
The Vega hwmgr PowerPlay table parsers read fixed table fields, state array entries, or SMC PPT fields before validating that the VBIOS table buffer covers those structures. A truncated table can therefore lead to out-of-bounds reads during hwmgr initialization.
Reject tables smaller than the fixed PowerPlay table. For Vega10, also validate 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 6.18.53 tree still has the unvalidated Vega parsers, the patch applies cleanly, and it closes a real out-of-bounds read on init and pp_table upload.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [drm/amd/pm] [Validate] Vega hwmgr PowerPlay table bounds — add missing size/offset checks before parsing Vega10/12/20 PowerPlay tables.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Yang Wang <[email protected]> (author)
- Reviewed-by: Hawking Zhang <[email protected]> (AMD)
- Signed-off-by: Alex Deucher <[email protected]> (drm/amd maintainer)
- Pipeline-added tags ignored per instructions ([Upstream commit 3a8d8e0b7f61...], Signed-off-by: Sasha Levin)
- No Fixes:, Reported-by:, Tested-by:, Cc: stable, Link:, or syzbot tags (absence is expected)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: Vega hwmgr parsers read fixed PowerPlay fields, Vega10 state- array entries, or Vega12/20 SMC PPT fields without checking that soft_pp_table is large enough.
- Symptom: out-of-bounds reads during hwmgr initialization (GPU probe / table re-init).
- Root cause: truncated or offset-corrupt VBIOS/custom PPTable; pointer arithmetic from usStateArrayOffset and struct-sized reads happen before a size check.
- No specific kernel-version range in the message.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. Explicit memory-safety fix (OOB read). Also corrects entry_index <= ucNumEntries to < (off-by-one).
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- vega10_processpptables.c: +43/−21 (refactor check_powerplay_tables into get_vega10_state_array; reuse it from entry lookup)
- vega12_processpptables.c: +7
- vega20_processpptables.c: +7
- Net: 52 insertions, 21 deletions; three files, one subsystem
- Functions: get_vega10_state_array (new), check_powerplay_tables (all three), vega10_get_number_of_powerplay_table_entries, vega10_get_powerplay_table_entry
- Scope: surgical, same-family parsers only
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Vega10 before: check_powerplay_tables / entry getters add usStateArrayOffset to the table pointer, then read ucNumEntries with no size check. Offset/revision checks happen *after* that dereference.
- Vega10 after: require soft_pp_table_size >= sizeof(*powerplay_table); then offset <= table_size - sizeof(*state_arrays); then struct_size(..., ucNumEntries) <= remaining.
- Vega12/20 before: only format_revision / structuresize (and Vega20 SMC version).
- Vega12/20 after: also table_size >= offsetofend(..., smcPPTable) before those field reads.
- Vega10 entry lookup: entry_index <= ucNumEntries → entry_index < ucNumEntries.
- Path: init/error-reject of bad tables, not a new feature path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Memory safety / OOB read**, plus a **logic off-by-one**.
- Mechanism: VBIOS/custom table is smaller than the structures, or usStateArrayOffset/ucNumEntries describe data past the buffer. The driver still computed pointers and read them.
- Fix: reject before dereference using soft_pp_table_size (already filled by smu_atom_get_data_table / cached table).
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct integer bounds checks. Uses existing struct_size / offsetofend. Reject path is the same PP_ASSERT_WITH_CODE(... return -1) style already used. Regression risk is low: a genuine Vega PPTable is at least the header/SMC-PPT size. Worst case a truncated table that previously “worked” by reading adjacent BIOS bytes would now fail init instead of over-reading — that is the intended failure mode. No API/lock/data-structure changes.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Vega10 check_powerplay_tables: f83a9991648bb4 (Eric Huang, 2017-03-06)
- Vega12: 2cac05dee6e309 (Evan Quan, 2018-03-19)
- Vega20: da958630d53025 (Evan Quan, 2018-08-02)
- Bug is long-standing (4.x/5.x era), present throughout 6.18.y.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Same-author series (2026-06-23), of which this is **patch 4/5**:
1. Validate pp_table header before reading size (swsmu)
2. Use uploaded size for legacy custom PPTable (amd_powerplay.c)
3. Validate Tonga PowerPlay state array bounds
4. **This commit**
5. Validate legacy hwmgr PP table offsets
Follow-up (separate series): Validate Vega10 PPTable subtable bounds — more subtables, not a prerequisite for these checks.
None of 1–5 are in v6.18.53. This hunk does not need 1–3 to compile or
run: it only uses hwmgr->soft_pp_table_size, which get_powerplay_table() already sets in this tree.
**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 (fix pptable use-after-free is already in v6.18.53). Hawking Zhang reviewed; Alex Deucher merged.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Standalone for these three files. struct_size and offsetofend exist (include/linux/overflow.h, include/linux/stddef.h). Flexible-array states[] is already in v6.18.53 (bae82e8418234 is an ancestor). Patch 2/5 (upload size) makes short sysfs uploads match soft_pp_table_size; this patch still stops offsets past the *allocated* buffer on 6.18.53, because that tree keeps the original VBIOS size as the buffer size.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 3a8d8e0b7f61... → https://patch.msgid.link/20260623034151.
[email protected]
- Series: v1 [PATCH 1/5] ... [PATCH 5/5]; this is 4/5. b4 dig -a showed only this v1 (no later revision of *this* patch).
- Mbox: Hawking Zhang: “Series is Reviewed-by: Hawking Zhang”. No NAK, no stable-risk comments.
- lore.kernel.org HTTP fetch returned 403; discussion recovered via b4 dig -m.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc [email protected], Alex Deucher, Hawking Zhang, Kenneth Feng. Maintainer merge + AMD review.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by / bugzilla / syzbot. Author-driven audit of PPTable parsers, consistent with the rest of the series. Trigger is still real (init + sysfs upload), not speculative code.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Self-contained Vega header/state-array/SMC-PPT checks. Follow-up subtable patch is extra coverage, not required for these checks to be correct.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: UNVERIFIED — lore.kernel.org/stable/ returned 403. No evidence in-tree of a prior rejection.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: get_vega10_state_array, check_powerplay_tables (vega10/12/20), vega10_get_number_of_powerplay_table_entries, vega10_get_powerplay_table_entry.
**Step 5.2: TRACE CALLERS**
Record:
- check_powerplay_tables ← vega10_pp_tables_initialize / vega12/20 equivalents, and vega10_baco_set_cap
- pptable_init ← hwmgr.c during hwmgr init
- vega10_get_number_of_powerplay_table_entries / get_pp_table_entry ← psm_init_power_state_table() (for (i = 0; i < table_entries; i++))
- Context: process/workqueue GPU init, not IRQ. Also re-entered from pp_dpm_set_pp_table → amd_powerplay_reset → hwmgr_hw_init.
**Step 5.3: TRACE CALLEES**
Record: get_powerplay_table → smu_atom_get_data_table (pointer into ATOM BIOS + ATOM-reported size). PP_ASSERT_WITH_CODE warns and runs return -1. No new allocations/locks.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable on every Vega10/12/20 GPU probe. Also reachable from sysfs pp_table (AMDGPU_DEVICE_ATTR_RW → S_IRUGO | S_IWUSR, root write). Unprivileged users cannot write it; root/firmware can still drive the OOB.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same pattern in Tonga (process_pptables_v1_0.c) and legacy (processpptables.c) in the same series. Vega12 get_powerplay_table_entry still uses a raw offset after this patch; Vega10 is the family that actually walks a state array here. Remaining holes are why the follow-up exists; they do not invalidate this patch.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. Local tree is **6.18.53** (git describe HEAD → v6.18.53-5049-g0f0bdc2b0dffb, make kernelversion → 6.18.53). git merge-base --is-ancestor 10510a4c2c397 v6.18.53 is false. v6.18.53 check_powerplay_tables still dereferences the state array / SMC PPT with no size check.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply onto v6.18.53 file contents (patch --dry-run on the three files succeeded). git apply --check on current HEAD fails only because the candidate + follow-up are already stacked on the autosel branch.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: The older fix pptable use-after-free is in v6.18.53. No equivalent Vega bounds check is. v6.18.53 pp_dpm_set_pp_table still memcpys into a buffer sized from the original VBIOS table and does **not** shrink soft_pp_table_size.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/gpu/drm/amd/pm/powerplay — Vega PowerPlay table parsing. **IMPORTANT** (common AMD dGPU driver; Vega10/12/20 still in the field). Not core mm/net, not staging.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature parser (2017–2018) with recent bounds-hardening. Long- lived bug, not churn from a new subsystem.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver-specific: Vega10/Vega12/Vega20 amdgpu powerplay. Also anyone writing /sys/class/drm/card*/device/pp_table on those GPUs.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Normal good VBIOS: not triggered.
- Truncated/corrupt ATOM PPTable at probe: GPU init OOB.
- Root write of a crafted pp_table that re-inits hwmgr: same path.
- Unprivileged: no (sysfs is S_IWUSR).
- Off-by-one <= is latent: psm_init_power_state_table uses i < table_entries, so the common loop never passes entry_index == ucNumEntries. Still a real bounds bug if any caller passes ucNumEntries.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Kernel OOB read (KASAN/oops, possible info leak from adjacent BIOS/kmalloc). Init failure on reject is the safe outcome. Severity:
**HIGH** (memory safety). Not a guaranteed panic on every boot.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: HIGH for Vega + custom PPTable users; stops OOB on init.
- Risk: LOW (~50 lines, assert-and-return, no locking/API).
- Ratio: favorable.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real OOB read in GPU power-management init, present since 2017/2018 in this 6.18 tree
- Triggerable from truncated VBIOS and from root pp_table sysfs re- init
- Small, obviously correct bounds checks; AMD Reviewed-by + maintainer SOB
- Applies cleanly to v6.18.53; helpers already present
- Matches stable’s buffer-overflow / memory-safety class
AGAINST:
- No public crash/syzbot/CVE write-up
- Privileged sysfs / firmware trigger, not unprivileged
- Series 4/5; later patch covers more Vega10 subtables (not required for this hunk)
- Good VBIOS never hits it
UNRESOLVED:
- Stable-list discussion (lore.kernel.org/stable 403)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — integer bounds; reviewed and merged by AMD
2. Fixes a real bug that affects users? **PASS** — OOB read of PPTable buffer
3. Important issue? **PASS** — memory-safety OOB (HIGH), not a style fix
4. Small and contained? **PASS** — 3 files, ~50 net lines
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — v6.18.53 still has the bug; 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**
Backport. This tree still performs unvalidated Vega PPTable pointer math during hwmgr init. The patch is the minimal, already-reviewed guard for that path.
What it solves for 6.18.y users: Vega probe and pp_table reload can read past the PowerPlay buffer if the table is short or usStateArrayOffset/ucNumEntries (Vega10) / SMC PPT (Vega12/20) stick past soft_pp_table_size. That is an OOB read, not a feature.
Risk vs benefit: low-risk reject-invalid-table change vs stopping kernel over-reads on a supported amdgpu path.
Concerns: more complete subtable checks come later; v6.18.53 custom- upload still keeps the old VBIOS size (patch 2/5). Neither blocks this
patch: it still applies and still stops offsets past the allocated buffer.
Verification:
- [Phase 1] Tags: author Yang Wang; Reviewed-by Hawking Zhang; SOB Alex Deucher; no Fixes/syzbot
- [Phase 2] Diff: 52/21 across three Vega processpptables files; size/offset checks + off-by-one
- [Phase 3] Blame: Vega10 2017 (f83a9991648bb4), Vega12 2018, Vega20 2018; present in v6.18.53
- [Phase 3] Series 4/5; no code dependency on 1–3 for these files
- [Phase 3] struct_size/offsetofend and flexible states[] already in this tree
- [Phase 4] b4 dig -c 3a8d8e0b7f61... → msgid 20260623034151.263746-4; series R-b from Hawking; no NAK
- [Phase 4] lore.kernel.org HTTP 403; mbox via b4 dig -m used instead
- [Phase 5] Callers: pptable_init from hwmgr.c; psm_init_power_state_table; pp_dpm_set_pp_table reset
- [Phase 5] smu_atom_get_data_table returns BIOS pointer + ATOM size
- [Phase 6] git describe HEAD v6.18.53-5049; merge-base --is- ancestor vs v6.18.53: not present; buggy code confirmed in git show v6.18.53:...
- [Phase 6] patch --dry-run on v6.18.53 copies of the three files:
clean
- [Phase 8] Failure mode: OOB read during hwmgr init; sysfs pp_table is S_IWUSR
- UNVERIFIED: stable@ mailing-list thread (HTTP 403)
**YES**
.../powerplay/hwmgr/vega10_processpptables.c | 59 ++++++++++++------- .../powerplay/hwmgr/vega12_processpptables.c | 7 +++ .../powerplay/hwmgr/vega20_processpptables.c | 7 +++ 3 files changed, 52 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_processpptables.c +38 -21
@@ -63,14 +63,17 @@ static const void *get_powerplay_table(struct pp_hwmgr *hwmgr)return table_address; } -static int check_powerplay_tables ( -struct pp_hwmgr *hwmgr, -const ATOM_Vega10_POWERPLAYTABLE *powerplay_table) +static int get_vega10_state_array (struct pp_hwmgr *hwmgr, +const ATOM_Vega10_POWERPLAYTABLE *powerplay_table, +const ATOM_Vega10_State_Array **state_array) {const ATOM_Vega10_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_Vega10_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((powerplay_table->sHeader.format_revision >= ATOM_Vega10_TABLE_REVISION_VEGA10),
@@ -79,12 +82,34 @@ static int check_powerplay_tables( "State table is not set!", return -1);PP_ASSERT_WITH_CODE (powerplay_table->sHeader.structuresize >0 ,"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_Vega10_State_Array *)(((unsigned long )powerplay_table) + + state_array_offset);PP_ASSERT_WITH_CODE (state_arrays->ucNumEntries >0 ,"Invalid PowerPlay Table!" , return -1 ); + state_array_size =struct_size (state_arrays, states, 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_Vega10_POWERPLAYTABLE *powerplay_table) +{ +const ATOM_Vega10_State_Array *state_arrays; + +return get_vega10_state_array (hwmgr, powerplay_table, &state_arrays); +} +static int set_platform_caps (struct pp_hwmgr *hwmgr,uint32_t powerplay_caps) { set_hw_cap(
@@ -1249,15 +1274,14 @@ int vega10_get_number_of_powerplay_table_entries(struct pp_hwmgr *hwmgr) {const ATOM_Vega10_State_Array *state_arrays;const ATOM_Vega10_POWERPLAYTABLE *pp_table =get_powerplay_table (hwmgr); +int result;PP_ASSERT_WITH_CODE ((pp_table !=NULL ),"Missing PowerPlay Table!" , return -1 ); -PP_ASSERT_WITH_CODE ((pp_table->sHeader.format_revision >= - ATOM_Vega10_TABLE_REVISION_VEGA10), -"Incorrect PowerPlay table revision!" , return -1 ); - state_arrays = (ATOM_Vega10_State_Array *)(((unsigned long )pp_table) + -le16_to_cpu (pp_table->usStateArrayOffset)); + result =get_vega10_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); }
@@ -1308,17 +1332,11 @@ int vega10_get_powerplay_table_entry(struct pp_hwmgr *hwmgr,if (pp_table->sHeader.format_revision >= ATOM_Vega10_TABLE_REVISION_VEGA10) { - state_arrays = (ATOM_Vega10_State_Array *) - (((unsigned long )pp_table) + -le16_to_cpu (pp_table->usStateArrayOffset)); - -PP_ASSERT_WITH_CODE (pp_table->usStateArrayOffset >0 , -"Invalid PowerPlay Table State Array Offset." , - return -1 ); -PP_ASSERT_WITH_CODE (state_arrays->ucNumEntries >0 , + result =get_vega10_state_array (hwmgr, pp_table, &state_arrays); +PP_ASSERT_WITH_CODE ((result ==0 ),"Invalid PowerPlay Table State Array." , - return -1 ); -PP_ASSERT_WITH_CODE ((entry_index <= state_arrays->ucNumEntries), + return result); +PP_ASSERT_WITH_CODE ((entry_index < state_arrays->ucNumEntries),"Invalid PowerPlay Table State Array Entry." , return -1 );
@@ -1360,4 +1378,3 @@ int vega10_baco_set_cap(struct pp_hwmgr *hwmgr) PHM_PlatformCaps_BACO);return result; } -
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c +7 -0
@@ -64,6 +64,13 @@ static int check_powerplay_tables(struct pp_hwmgr *hwmgr, const ATOM_Vega12_POWERPLAYTABLE *powerplay_table) { + size_t smc_pptable_size = +offsetofend (ATOM_Vega12_POWERPLAYTABLE, smcPPTable); +size_t table_size = hwmgr->soft_pp_table_size; + +PP_ASSERT_WITH_CODE ((table_size >= smc_pptable_size), +"Invalid PowerPlay Table!" , return -1 ); +PP_ASSERT_WITH_CODE ((powerplay_table->sHeader.format_revision >=ATOM_VEGA12_TABLE_REVISION_VEGA12 ),"Unsupported PPTable format!" , return -1 );
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_processpptables.c +7 -0
@@ -66,6 +66,13 @@ static int check_powerplay_tables(struct pp_hwmgr *hwmgr, const ATOM_Vega20_POWERPLAYTABLE *powerplay_table) { + size_t smc_pptable_size = +offsetofend (ATOM_Vega20_POWERPLAYTABLE, smcPPTable); +size_t table_size = hwmgr->soft_pp_table_size; + +PP_ASSERT_WITH_CODE ((table_size >= smc_pptable_size), +"Invalid PowerPlay Table!" , return -1 ); +PP_ASSERT_WITH_CODE ((powerplay_table->sHeader.format_revision >=ATOM_VEGA20_TABLE_REVISION_VEGA20 ),"Unsupported PPTable format!" , return -1 );
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 clk: mediatek: mt6735-vencsys: add missing MODULE_DEVICE_TABLE()
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit 36cf8d279ff90835f4b002dec28eedb059554842 ]
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:
Connection lost, reconnecting to https://agentn.us.api5.cursor.sh
(attempt 1)...
Retry attempt 1...
This tree is **Linux 7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The driver exists here; the change is a one-line MODULE_DEVICE_TABLE(of, ...) so the vencsys clock module can autoload from DT.
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
- Record: [clk/mediatek] [add] add missing MODULE_DEVICE_TABLE() for mt6735-vencsys
**Step 1.2: Tags**
- Record:
- **Fixes:** none (expected for this review)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** Brian Masney <[email protected]> (COMMON CLK FRAMEWORK maintainer)
- **Acked-by:** none
- **Link:** none in the commit; mailing list found via b4 dig
- **Cc: stable:** none (not a negative signal)
- **Signed-off-by:** Pengpeng Hou <[email protected]> (author); Brian Masney <[email protected]> (clk maintainer who applied it)
- Notable: maintainer review + maintainer SOB; no user/syzbot report
**Step 1.3: Body**
- Record:
- **Bug:** OF match table is wired to .of_match_table but not exported with MODULE_DEVICE_TABLE(), so file2alias does not emit of: aliases.
- **Symptom:** when CONFIG_COMMON_CLK_MT6735_VENCSYS=m, udev/modprobe cannot autoload clk-mt6735-vencsys from mediatek,mt6735-vencsys.
- **Version info:** none in the message. Git: driver added in
**v6.13-rc1** (`0bd9b1211f741`); this fix first appears in
**v7.3-rc1**.- **Root cause:** omitted alias publication, not a runtime logic error.
**Step 1.4: Hidden bug fix?**
- Record: Not hidden. It is a real functional gap (module autoload), not a crash/UAF. The “source-level fix / no hardware reproduction” wording matches the original lore submission, not pipeline decoration.
## Phase 2: Diff analysis
**Step 2.1: Inventory**
- Record:
- drivers/clk/mediatek/clk-mt6735-vencsys.c: **+1 / -0**
- Function/data: of_match_mt6735_vencsys[] (file scope)
- Scope: single-file, one-line surgical change
**Step 2.2: Code flow**
- Record: Before, the table is only consumed by platform_driver.driver.of_match_table (bind if the module is already loaded or built-in). After, MODULE_DEVICE_TABLE(of, of_match_mt6735_vencsys) also creates a __mod_device_table alias so scripts/mod/file2alias.c do_of_entry() emits of:N*T*Cmediatek,mt6735-vencsys. Build-time metadata only; no probe- path change.
**Step 2.3: Bug mechanism**
- Record: **Hardware matching / module autoload** (same class as missing device IDs). Match table exists but is not published for modules.
**Step 2.4: Fix quality**
- Record: Obviously correct; matches sibling MT6735 files that shipped with MODULE_DEVICE_TABLE (apmixedsys, infracfg, pericfg, topckgen). No runtime lock/API/data-structure change. Regression risk is essentially none. imgsys and mfgcfg still lack the macro; this patch does not depend on those.
## Phase 3: Git history
**Step 3.1: Blame**
- Record: Match table and driver introduced by 0bd9b1211f741 (“clk:
mediatek: Add drivers for MT6735 syscon clock and reset controllers”, Yassine Oudjana, 2024-11-06, applied 2024-11-14). First in **v6.13-rc1**. MODULE_DEVICE_TABLE line is this commit 36cf8d279ff90.
**Step 3.2: Fixes: tag**
- Record: No Fixes: tag. The omission dates from the introducing commit 0bd9b1211f741, which **is** an ancestor of this tree.
**Step 3.3: File history**
- Record: Only two commits on this file: introducer + this fix. No later conflicting refactor. Sibling same-day commit 096ab64a0e694 does the same for clk-mt6735-vdecsys.c. Standalone; not patch 2/N.
**Step 3.4: Author**
- Record: Pengpeng Hou is not the MT6735 clk maintainer (that is Yassine Oudjana). Same author also added MODULE_DEVICE_TABLE in clk- mt6735-vdecsys.c and two i.MX clk drivers. Applied by clk co- maintainer Brian Masney.
**Step 3.5: Dependencies**
- Record: None. Uses existing MODULE_DEVICE_TABLE / of_device_id. Applies on top of the original driver with no prerequisites.
## Phase 4: Mailing list and external research
**Step 4.1: Original discussion**
- Record: b4 dig -c 36cf8d279ff90 →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only** (2026-07-04). Applied version is that v1.
- Thread (mbox): author patch + Brian Masney Reviewed-by. No NAK, no stable nomination, no risk discussion.
**Step 4.2: Recipients (b4 dig -w)**
- Record: Yassine Oudjana (MT6735 clk maintainer), Stephen Boyd, Brian Masney, Michael Turquette, Matthias Brugger, AngeloGioacchino Del Regno; linux-clk, linux-mediatek, linux-arm-kernel, linux- kernel. Right maintainers and lists.
**Step 4.3: Bug report**
- Record: No Reported-by, no syzbot, no bugzilla. Author states there was no hardware reproduction.
**Step 4.4: Series**
- Record: Independent single patches (vencsys + vdecsys), not a numbered series. This commit does not need the vdecsys patch.
**Step 4.5: Stable list**
- Record: **UNVERIFIED.** curl to lore.kernel.org/stable returned HTTP
403. No in-tree evidence this was rejected for stable.
## Phase 5: Code semantic analysis
**Step 5.1: Functions**
- Record: No function body changed. Adds MODULE_DEVICE_TABLE next to of_match_mt6735_vencsys[]. Driver still uses module_platform_driver → mtk_clk_simple_probe / mtk_clk_simple_remove.
**Step 5.2: Callers**
- Record: Platform core binds via OF compatible. Probe is boot/device- instantiation, not a syscall hot path. Impact is whether the **module is loaded at all**.
**Step 5.3: Callees**
- Record: Unchanged. mtk_clk_simple_probe() in clk-mtk.c registers the vencsys gates from vencsys_clks.
**Step 5.4: Reachability**
- Record: Reachable when DT has mediatek,mt6735-vencsys and the driver is a module. **No in-tree .dts/.dtsi uses that compatible** (only Documentation/devicetree/bindings/clock/mediatek,syscon.yaml). Users need out-of-tree DT (typical for older MT6735 phones). Built-in (=y) is unaffected.
**Step 5.5: Similar patterns**
- Record: Same omission still present in clk-mt6735-imgsys.c and clk- mt6735-mfgcfg.c. Four other MT6735 clk files had MODULE_DEVICE_TABLE from day one (43c04ed791892 for apmixedsys). Pattern is systematic but this patch is complete for vencsys.
## Phase 6: Local tree cross-reference
**Step 6.1: Buggy code in this tree?**
- Record: Yes. File exists; current tree already has the fix at line 40. Bug was the missing alias from v6.13 until v7.3-rc1. CONFIG_COMMON_CLK_MT6735_VENCSYS is **tristate**.
**Step 6.2: Backport difficulty**
- Record: **Clean apply.** File is essentially unchanged since introduction. One inserted line after the match table.
**Step 6.3: Related fixes already here**
- Record: This exact commit is already an ancestor of HEAD (git merge- base --is-ancestor 36cf8d279ff90 HEAD → yes). That is mainline history, not a reason to reject on merit. No alternate fix. Sibling vdecsys fix is also present; imgsys/mfgcfg still missing.
## Phase 7: Subsystem context
**Step 7.1: Subsystem / criticality**
- Record: drivers/clk/mediatek/ — SoC clock driver. **PERIPHERAL** (MT6735 video-encoder clocks only). Not mm/fs/net core.
**Step 7.2: Activity**
- Record: Mediatek clk is actively maintained; this file is not. Two commits total. Mature omission, not churn.
## Phase 8: Impact and risk
**Step 8.1: Who is affected**
- Record: Only MT6735 systems with CONFIG_COMMON_CLK_MT6735_VENCSYS=m and a DT node mediatek,mt6735-vencsys. Driver- and config-specific; small population (no in-tree board DTS).
**Step 8.2: Trigger**
- Record: Modular boot + OF device present. Not a race. Unprivileged users do not trigger it; udev autoload fails. Built-in and manual modprobe work.
**Step 8.3: Failure mode**
- Record: Module does not autoload → vencsys clocks (smi_larb3, venc, jpgenc, jpgdec) never register → video encode/JPEG on that SoC can fail. **Severity: MEDIUM** (functional miss, not oops/corruption/deadlock). Fits stable-rules “oh, that’s not good” and the device-ID-style enablement exception.
**Step 8.4: Risk-benefit**
- Record: **Benefit:** correct autoload for a supported tristate driver; one line. **Risk:** negligible (modinfo/depmod metadata only). Ratio favors applying it on trees that have this driver.
## Phase 9: Final synthesis
**Step 9.1: Evidence**
FOR:
- Real autoload bug: match table used, aliases not published
- One line, obviously correct, reviewed and applied by clk maintainer Brian Masney
- Driver is tristate; modular build is an intended config
- Same class as device-ID additions (publish existing OF IDs)
- Sibling MT6735 files already had the macro; this was an omission from 0bd9b1211f741
- Zero runtime regression risk; applies cleanly
- Driver and bug exist in this 7.3 tree (introduced v6.13)
AGAINST:
- Not a crash, UAF, deadlock, or security issue
- No user report and no hardware reproduction
- No in-tree DT consumer for this compatible
- Niche SoC; often clocks are built-in
UNRESOLVED:
- Whether this was discussed on the stable list (lore HTTP 403)
**Step 9.2: Stable rules checklist**
1. Obviously correct and tested? **PASS** — one-line, standard macro, maintainer Reviewed-by/SOB. No runtime test; correctness is mechanical.
2. Real bug that affects users? **PASS** — modular OF autoload is broken. User set is small but real if they use =m.
3. Important issue? **PASS** (low end of “oh, that’s not good” / hardware-enablement), not CRITICAL.
4. Small and contained? **PASS** — +1 line, one file.
5. No new features or APIs? **PASS** — publishes existing match table.
6. Can apply to this tree? **PASS** — file and table exist; patch is a clean one-liner.
**Step 9.3: Exception category**
- Record: Closest match is **device ID / hardware matching** (OF module aliases), not a new driver.
**Step 9.4: Decision**
Backport this. It is a one-line, obviously correct fix for failed OF module autoload on an existing tristate driver. That is the same kind of enablement stable already takes for new device IDs, with no runtime behavior change if the module is built-in or loaded by other means. This 7.3 tree has the driver (since v6.13); there are no missing prerequisites. Limited hardware and no crash report lower urgency, not correctness.
### What it solves for stable users
If clk-mt6735-vencsys is a module, userspace cannot match mediatek,mt6735-vencsys and load it. Video-encoder clocks then never appear. MODULE_DEVICE_TABLE(of, ...) generates the aliases file2alias already knows how to emit.
### Risk vs benefit
Benefit is correct autoload on MT6735 modular configs. Risk is
negligible: no probe, locking, or ABI change.
## Verification
- [Phase 1] Parsed tags: Reviewed-by + SOB Brian Masney; no Fixes/Reported-by/Cc:stable
- [Phase 1] git show -s 36cf8d279ff90: body matches the candidate; “source-level fix” is in the real commit and lore v1
- [Phase 2] Diff: +1 MODULE_DEVICE_TABLE(of, of_match_mt6735_vencsys) in clk-mt6735-vencsys.c
- [Phase 2] include/linux/module.h and scripts/mod/file2alias.c do_of_entry(): confirmed alias generation from that macro
- [Phase 3] git blame: table from 0bd9b1211f741 (v6.13-rc1); macro from 36cf8d279ff90
- [Phase 3] git describe --contains 0bd9b1211f741: v6.13-rc1; fix contained in v7.3-rc1; git merge-base --is-ancestor vs v7.2: not in v7.2
- [Phase 3] File log: only introducer + this commit; sibling 096ab64a0e694 for vdecsys
- [Phase 4] b4 dig -c/-a/-w/-m: v1 lore thread; Masney Reviewed-by; correct clk/mediatek CCs; no NAK
- [Phase 4] WebFetch lore/msgid.link: HTTP 403; used mbox instead
- [Phase 5] Kconfig: COMMON_CLK_MT6735_VENCSYS tristate; Makefile obj-$(CONFIG_COMMON_CLK_MT6735_VENCSYS)
- [Phase 5] mtk_clk_simple_probe in clk-mtk.c used unchanged
- [Phase 5] Grep: no in-tree dts/dtsi mediatek,mt6735-vencsys; binding in mediatek,syscon.yaml
- [Phase 5] imgsys/mfgcfg still lack MODULE_DEVICE_TABLE
- [Phase 6] make kernelversion / git describe HEAD: 7.3.0-rc4 / v7.3-rc4-27-gf0100363d8c37
- [Phase 6] File currently contains the macro; git merge-base --is- ancestor 36cf8d279ff90 HEAD = yes
- [Phase 7] MAINTAINERS: MT6735 clk → Yassine Oudjana; COMMON CLK → Stephen Boyd, Brian Masney, Jerome Brunet
- [Phase 8] Failure mode: missing module autoload, not oops; severity MEDIUM
- UNVERIFIED: stable@ lore discussion (HTTP 403)
**YES**
drivers/clk/mediatek/clk-mt6735-vencsys.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/mediatek/clk-mt6735-vencsys.c +1 -0
@@ -37,6 +37,7 @@ static const struct of_device_id of_match_mt6735_vencsys[] = { { .compatible = "mediatek,mt6735-vencsys", .data = &vencsys_clks }, {/* sentinel */ } }; +MODULE_DEVICE_TABLE (of, of_match_mt6735_vencsys);static struct platform_driver clk_mt6735_vencsys = { .probe = mtk_clk_simple_probe,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 selftests: net: reuseport_bpf_numa: consider cpuless numa node
In reply to Sasha LevinFrom: Feng Tang <[email protected]>
[ Upstream commit 88b8d85e889e2fe1cce3e66e50c3029dda94842a ]
reuseport_bpf_numa case failed when testing on a platform with CXL memory:
#./reuseport_bpf_numa
---- IPv4 UDP ----
send node 0, receive socket 0
./reuseport_bpf_numa: failed to pin to node: Invalid argument
The root cause is that the platform has 2 numa nodes: node 0 has both cpu and memory, while node 1 is a CXL node which only has memory, and caused numa_run_on_node() to fail.
Add sanity check to skip cpuless numa node for the numa binding test.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
- Record: [selftests: net] [consider] skip CPU-less NUMA nodes in reuseport_bpf_numa so the test does not abort when numa_run_on_node() cannot pin to a memory-only node.
**Step 1.2: Tags**
- Record: Reviewed-by: Simon Horman <[email protected]>; Link: https:/ /patch.msgid.link/[email protected]; Signed-off-by: Feng Tang <[email protected]>; `Signed-off-
by: Paolo Abeni <[email protected]>`.
- No Fixes:, no Reported-by:, no Tested-by:, no Cc: stable (absence is expected). Ignore any pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] markers.
**Step 1.3: Body**
- Record: On a 2-node CXL box, node 0 has CPU+memory and node 1 is memory-only. The test prints send node 0, receive socket 0 then dies with failed to pin to node: Invalid argument from numa_run_on_node(). Root cause is treating every bit in numa_nodes_ptr as a pin-able CPU node. Fix: skip CPU-less nodes.
**Step 1.4: Hidden bug fix?**
- Record: Yes. “Consider” is test-robustness language, but the program currently error(1, ...) and fails. This is a real false failure, not style cleanup.
## Phase 2: Diff analysis
**Step 2.1: Inventory**
- Record: One file, tools/testing/selftests/net/reuseport_bpf_numa.c. About +24 lines. New helper is_cpuless_node(); test() gains two continues. Surgical, single-file, userspace selftest only.
**Step 2.2: Flow**
- Record: Before: both forward and reverse loops skip only nodes unset in numa_nodes_ptr, then call send_from_node() which does numa_run_on_node() and aborts on failure. After: also skip nodes whose libnuma CPU mask has weight 0. Normal send/receive path for CPU- bearing nodes is unchanged.
**Step 2.3: Bug mechanism**
- Record: Logic/correctness in a selftest. Memory-only NUMA nodes are present in numa_nodes_ptr (the 2021 skip does not drop them) but have an empty CPU mask, so pinning returns EINVAL. is_cpuless_node() uses numa_allocate_cpumask() / numa_node_to_cpus() / numa_bitmask_weight(); on helper error it returns false (do not skip), which is conservative.
**Step 2.4: Fix quality**
- Record: Obviously correct and minimal. Skipping a CPU-less node is
right: bpf_get_numa_node_id() is the current CPU’s node, so a memory-only node can never be the sender. Regression risk is very low (userspace test only). Helper allocation failure still hits the old abort path.
## Phase 3: Git history
**Step 3.1: Blame**
- Record: Loops come from 3c2c3c16aaf6a (Daniel Borkmann, 2016-10-21, “reuseport, bpf: add test case for bpf_get_numa_node_id”), first contained in v4.10-rc1. The existing skip is a38bc45a08e97 (Kleber Sacilotto de Souza, 2021-11-01), contained in v5.16-rc1: skip nodes not in numa_nodes_ptr (non-consecutive IDs). That does not cover CPU-less memory nodes.
**Step 3.2: Fixes: tag**
- Record: None. Buggy assumption is in the original 2016 test, still present here.
**Step 3.3: File history**
- Record: This tree only has later 0273d10182ec4 (ARRAY_SIZE warning), then the 2021 skip, 2018 numa-skip-if-unavailable, SPDX, and the original test. No setup_netns() in this file (0 matches). Standalone; not patch X/Y.
**Step 3.4: Author**
- Record: Feng Tang has other tools/selftests work in this history (e.g. mm compaction_test) but no other net reuseport_bpf_numa commits. Not the net maintainer. Applied by Paolo Abeni after Simon Horman’s review.
**Step 3.5: Prerequisites**
- Record: Needs existing libnuma usage (numa_nodes_ptr, numa_run_on_node, -lnuma). All present. Makefile already has $(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma. No missing kernel APIs. Can apply standalone.
## Phase 4: Mailing list / external
**Step 4.1: Original discussion**
- Record: b4 mbox for msgid [email protected] returned 404; lore.kernel.org fetches returned 403. Recovered from Openwall/LKML/Patchew.
- v1 (20260730113040.75718-1-...): check inside send_from_node(), return -1, no NULL check on numa_allocate_cpumask().
- v2 ([PATCH net v2]): lift check into test(), add alloc-failure handling; typo “unlikeyly”; unnecessary inline.
- v3 ([PATCH net-next v3]): spelling + drop inline (Jakub, Sashiko). Committed version matches v3.
- No NAKs. No reviewer Cc: stable found.
**Step 4.2: Reviewers**
- Record: To/Cc included Jakub Kicinski, David Miller, Eric Dumazet, Paolo Abeni, Simon Horman, Shuah Khan, Andi Kleen, netdev, linux- kselftest, bpf. Jakub reviewed v2 (inline). Simon Horman Reviewed-by on v3. Paolo applied.
**Step 4.3: Bug report**
- Record: Author reproduced on CXL hardware; commit body has the exact abort. No syzbot/bugzilla. Severity for testers: hard FAIL after the first successful node-0 send.
**Step 4.4: Series**
- Record: Single patch, three revisions. No sibling patches required.
**Step 4.5: Stable list**
- Record: No stable-list hit found. UNVERIFIED that nobody asked for it on stable@ (lore 403).
## Phase 5: Semantic analysis
**Step 5.1: Functions**
- Record: Adds is_cpuless_node(). Touches test(). send_from_node() unchanged.
**Step 5.2: Callers**
- Record: is_cpuless_node only from test(). test() only from main() (IPv4/IPv6 × UDP/TCP). Userspace kselftest, not kernel.
**Step 5.3: Callees**
- Record: libnuma numa_allocate_cpumask, numa_node_to_cpus, numa_bitmask_weight, numa_bitmask_free. Already linked with -lnuma.
**Step 5.4: Reachability**
- Record: Triggered by running ./reuseport_bpf_numa on NUMA (CONFIG_NUMA=y in tools/testing/selftests/net/config) with at least one CPU-less node. Not a syscall/kernel path.
**Step 5.5: Similar patterns**
- Record: Same file already skips unavailable nodes (a38bc45a08e97). This is the CPU-less counterpart. No other numa_run_on_node selftests in this tree.
## Phase 6: This tree (6.12.111)
**Step 6.1: Buggy code present?**
- Record: Yes. Local tree is pending-6.12 / p-6.12-3-gc504cf0baa3d8, make kernelversion = **6.12.111**. File has the 2016 loops and the 2021 numa_nodes_ptr skip, and still calls send_from_node() without a CPU-less check (git merge-base --is-ancestor for both historical commits succeeded). git log --grep="consider cpuless" on this file is empty. CXL is in this tree (drivers/cxl/).
**Step 6.2: Backport difficulty**
- Record: Clean apply. The three functional contexts exist verbatim (helper insertion after attach_bpf(), two loop sites). Mainline trailing setup_netns() context is **not** in 6.12 and is not part of the v3 hunks. bool is already used in other net selftests here without extra headers.
**Step 6.3: Related fixes already here?**
- Record: Only the 2021 unavailable-node skip. It does not fix CXL memory-only nodes. No equivalent is_cpuless_node fix.
## Phase 7: Subsystem context
**Step 7.1:** Record: tools/testing/selftests/net — kselftest for SO_REUSEPORT + bpf_get_numa_node_id. Criticality: PERIPHERAL for production runtime; IMPORTANT for people who run net kselftests (this 6.12.y tree already took ~100 tools/testing/selftests/net commits since v6.12).
**Step 7.2:** Record: Net selftests are actively backported here (UAF in tests, br_netfilter false failures, HZ=100 skips, portable timeouts, etc.).
## Phase 8: Impact and risk
**Step 8.1:** Record: Testers running this binary on NUMA machines with CPU-less nodes (CXL memory, similar memory-only nodes). Not a production kernel path.
**Step 8.2:** Record: Trigger is running the selftest on that topology. First CPU node can succeed; the next CPU-less node aborts. Unprivileged if the test is run that way; not a kernel exploit path.
**Step 8.3:** Record: Failure mode = kselftest abort (error(1, errno, "failed to pin to node")). Severity LOW–MEDIUM for the kernel (no oops/corruption), HIGH for CI on those machines (hard fail).
**Step 8.4:** Record: Benefit medium for CXL/NUMA testers of 6.12.y; risk very low (userspace, +24 lines, no kernel change). Ratio favors backport on this tree, which already takes kselftest false-fail fixes.
## Phase 9: Synthesis
**For**
- Real, reproduced FAIL on CXL memory-only NUMA; 6.12 has both the test and CXL.
- Completes the 2021 skip: numa_nodes_ptr still includes CPU-less nodes.
- Small, reviewed, v3 is the applied form; no series deps.
- Applies cleanly here; zero kernel runtime risk.
- This tree regularly backports the same class (e.g. `selftests:
netfilter: packetdrill: avoid failure on HZ=100 kernel`, vxlan/br_netfilter false-fail fixes).
- v2 was sent to net as a bugfix.
**Against**
- Not a kernel crash, security hole, or data-corruption fix.
- Affects one selftest on a subset of NUMA topologies.
- Final submission was net-next; no Cc: stable in the thread I could read.
**Unresolved**
- Exact mainline SHA (not on this branch).
- lore.kernel.org / b4 thread dump (403/404).
- Whether stable@ ever discussed it.
**Stable rules checklist**
1. Obviously correct and tested? **PASS** (libnuma weight 0; Reviewed-by Horman; author reproduced).
2. Real bug that bothers people? **PASS** (hard selftest FAIL on real CXL hardware).
3. Important (crash/security/corruption/deadlock)? **PASS** under this tree’s documented “oh, that’s not good” / kselftest-false-fail practice; not a production oops.
4. Small and contained? **PASS** (~24 lines, one file).
5. No new features/APIs? **PASS**.
6. Can apply to this tree? **PASS** (contexts verified).
**Exception category:** none of ID/quirk/DT/build/docs; it is a kselftest correctness/robustness fix, which this 6.12.y tree already accepts.
The test in 6.12.111 still assumes every exposed NUMA node has CPUs. That is false on CXL memory-only nodes, so reuseport_bpf_numa aborts. The patch only skips those nodes and does not change kernel behavior. That is a contained, low-risk fix worth taking on this tree.
### Verification
- [Phase 1] Parsed tags: Reviewed-by Simon Horman; Link msgid; SOBs Feng Tang / Paolo Abeni; no Fixes/Reported-by/Cc:stable.
- [Phase 2] Diff: +24 lines, is_cpuless_node() + two continues in test(); send_from_node() still error(1) on pin failure.
- [Phase 3] git blame loops: 3c2c3c16aaf6a (2016) and a38bc45a08e97 (2021 skip). Both are ancestors of HEAD.
- [Phase 3] git describe --contains: original test v4.10-rc1; 2021 skip v5.16-rc1.
- [Phase 3] git log --grep="consider cpuless" on this file: empty (fix not in tree).
- [Phase 4] b4 mbox msgid: 404; lore WebFetch: 403; used Openwall/LKML/Patchew for v1–v3.
- [Phase 4] v1→v3: Sashiko NULL-check; lift skip out of send_from_node; Jakub spelling/inline; Horman Reviewed-by; no NAK.
- [Phase 5] Callers: main → test → send_from_node; userspace only. grep numa_run_on_node only this file under selftests.
- [Phase 6] git describe HEAD / make kernelversion: pending-6.12, 6.12.111. File matches patch contexts (hunk1 present, two loop sites). No setup_netns. drivers/cxl/ present. CONFIG_NUMA=y in net selftest config. -lnuma already in Makefile.
- [Phase 6] v6.12..HEAD -- tools/testing/selftests/net/: 100 commits, including false-fail/skip fixes.
- [Phase 8] Failure: selftest abort failed to pin to node: Invalid argument; not a kernel oops.
- UNVERIFIED: lore.kernel.org full thread; stable@ discussion; mainline SHA.
**YES**
.../selftests/net/reuseport_bpf_numa.c | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+)
tools/testing/selftests/net/reuseport_bpf_numa.c +24 -0
@@ -104,6 +104,26 @@ static void attach_bpf(int fd)close (bpf_fd); } +/* +* Return true if it is a cpuless node. Return false if it isn't or any +* error (very unlikely) happens during the libnuma calls. +*/ +static bool is_cpuless_node (int node_id) +{ +struct bitmask *cpumask; +bool ret = false; + + cpumask =numa_allocate_cpumask (); +if (!cpumask) +return ret; + +if (!numa_node_to_cpus (node_id, cpumask) && !numa_bitmask_weight (cpumask)) + ret = true; + +numa_bitmask_free (cpumask); +return ret; +} +static void send_from_node (int node_id,int family,int proto) {struct sockaddr_storage saddr, daddr;
@@ -213,6 +233,8 @@ static void test(int *rcv_fd, int len, int family, int proto)for (node =0 ; node < len; ++node) {if (!numa_bitmask_isbitset (numa_nodes_ptr, node))continue ; +if (is_cpuless_node (node)) +continue ;send_from_node (node, family, proto);receive_on_node (rcv_fd, len, epfd, node, proto); }
@@ -221,6 +243,8 @@ static void test(int *rcv_fd, int len, int family, int proto)for (node = len -1 ; node >=0 ; --node) {if (!numa_bitmask_isbitset (numa_nodes_ptr, node))continue ; +if (is_cpuless_node (node)) +continue ;send_from_node (node, family, proto);receive_on_node (rcv_fd, len, epfd, node, proto); }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 nvme: zns: cap zone report nr_zones by DMA buffer size
In reply to Sasha LevinFrom: Xixin Liu <[email protected]>
[ Upstream commit 09c9062d4f62199a634a45e2bb9e6e8e572cc78c ]
With Partial Report (PR=1), the Number of Zones (NZ) field in the report header must equal the number of zone descriptors fully transferred in the DMA buffer (ZNS Command Set Specification Rev 1.2, section 3.4.2).
nvme_ns_report_zones() does not cap the parse loop by max_in_buf derived from buflen. Cap nz with min3() over the device-reported count, nr_zones - zone_idx, and max_in_buf.
---
LLM Generated explanations, may be completely bogus:
The local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The candidate is 09c9062d4f621 (“nvme: zns: cap zone report nr_zones by DMA buffer size”). The ZNS report path has been here since v5.9; this is a small host-side bounds cap against a device-controlled zone count.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[nvme: zns:] [cap] [limit zone-report parse count by DMA buffer size]**
- Subsystem: NVMe host Zoned Namespace (ZNS) driver
- Verb “cap” is a bounds/safety fix, not a feature
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected for manual review)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** Christoph Hellwig <[email protected]> (NVMe/block maintainer)
- **Acked-by:** none
- **Link:** none
- **Cc: stable:** none (expected; not a negative)
- **Signed-off-by:** Xixin Liu <[email protected]> (author); Keith Busch <[email protected]> (NVMe maintainer)
- Ignore any Sasha Levin SOB / “Upstream commit” markers — none present on the real commit
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** nvme_ns_report_zones() trusts report->nr_zones from the device and caps only by the caller’s nr_zones, not by how many nvme_zone_descriptors fit in the allocated DMA/vmalloc buffer (buflen).
- **Spec:** With Partial Report (PR=1), NZ must equal descriptors fully transferred (ZNS Command Set Spec Rev 1.2 §3.4.2).
- **Symptom/failure mode:** parse loop report->entries[i] can walk past buflen → kernel out-of-bounds read (crash / KASAN / info leak). sector += zsze * nz can also advance by an inflated nz.
- **Version info in message:** none
- **Root cause:** missing cap derived from buflen
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not disguised.** Explicit bounds-cap of a device-provided count. Real memory-safety fix, not cleanup.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/nvme/host/zns.c — **+6 / −2** (8 lines in the commit)
- Function: nvme_ns_report_zones() only
- Scope: **single-file surgical fix**
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** after nvme_zns_alloc_report_buffer() and nvme_submit_sync_cmd(), nz = min(le64_to_cpu(report->nr_zones), nr_zones) then for (i = 0; i < nz && zone_idx < nr_zones; i++) reads report->entries[i].
- **After:** max_in_buf = (buflen - sizeof(nvme_zone_report)) / sizeof(nvme_zone_descriptor); nz = min3(device NZ, nr_zones - zone_idx, max_in_buf).
- Path: normal ZNS zone-report (probe/revalidate, BLKREPORTZONE ioctl, filesystems using blkdev_report_zones()).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Memory safety / OOB] [device-controlled length not capped by allocation]**
- nvme_zone_report is 64 bytes + flexible entries[]; each descriptor is 64 bytes (verified in include/linux/nvme.h).
- Buffer is often **smaller** than nr_zones descriptors:
nvme_zns_alloc_report_buffer() min()s against queue_max_hw_sectors, queue_max_segments << PAGE_SHIFT, and halves bufsize on vmalloc failure.
- Callers pass BLK_ALL_ZONES ((unsigned int)-1 / UINT_MAX) — e.g. disk->fops->report_zones(disk, 0, UINT_MAX, ...) in block/blk- zoned.c during zone revalidate. Then min(device_nz, UINT_MAX) == device_nz.
- If firmware reports total zones (or a huge NZ) instead of the partial- transfer count, the loop indexes past the allocation.
- Secondary: nr_zones - zone_idx keeps nz as remaining requested zones for sector += zsze * nz.
- Same buffer-derived cap already exists in the NVMe **target**:
get_nr_zones_from_buf() in drivers/nvme/target/zns.c.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Obviously correct:** min3 of device count, remaining request, and descriptors that fit in buflen.
- **Minimal:** two small hunks, no API/struct change.
- **Regression risk: very low.** Only **lowers** nz. Compliant PR=1 devices already set NZ ≤ max_in_buf, so behavior is unchanged on good hardware.
- min3() exists in include/linux/minmax.h in this tree.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Buggy pattern introduced in **240e6ee272c07** (“nvme: support for zoned namespaces”, Keith Busch, 2020-06-29).
- First contained in **v5.9-rc1**.
- Present for many years; not a recent-only bug.
- nz = min(device NZ, nr_zones) form after **936fab503ff4a** (“nvme:
fix error handling in nvme_ns_report_zones”), which still did not cap by buffer size.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Introduced by 240e6ee272c07 (v5.9). That commit **is** an ancestor of this tree (git merge-base --is-ancestor 240e6ee272c07 HEAD succeeded). Candidate **09c9062d4f621 is also already an ancestor of HEAD** (landed in **v7.3-rc1**). No later overlapping fix of the same nz cap.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Related: 936fab503ff4a (error handling), 8b4fb0f968ffe (split report_zones), fdb9aed869f34 (disk_report_zone() args).
- **Standalone:** this hunk does not need those refactors; it only changes how nz is computed.
- Sibling **3456b52552896** (v2 2/2) only adds zone index to an error log — **not a prerequisite**.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record:
- Author Xixin Liu: several NVMe patches (09c9062d4f621, 3456b52552896, plus tcp/rdma/auth). Not the subsystem maintainer.
- Applied by **Keith Busch**; reviewed by **Christoph Hellwig**. High maintainer weight.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **No functional prerequisites.** Uses existing min3, buflen, nvme_zone_report / nvme_zone_descriptor. Can apply standalone on any tree with this parse loop (since v5.9).
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 09c9062d4f621 → https://patch.msgid.link/8ed1b6a33454.v2.1
[email protected]
- Full thread saved via b4 dig -m /tmp/nvme-zns-thread.mbox
- **v1** (2026-06-24): combined bounds cap + log message change
- **v2** (2026-06-25): split per review; **1/2 is this fix**, 2/2 is logging
- Christoph on v1: log change “unrelated, please split”; **“The rest looks good as well.”**
- Christoph on v2 1/2: **“Looks good: Reviewed-by: Christoph Hellwig”**
- Keith Busch: **“Thanks, applied to nvme-7.3.”**
- **No NAK, no stable objection, no risk flags.** No explicit Cc: stable in the thread.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc linux-nvme, Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg, linux-kernel. Appropriate NVMe/block maintainers.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: **No syzbot, bugzilla, or user crash report.** Spec-driven host- side hardening. Still a real OOB if NZ exceeds the buffer (buggy/malicious NVMe, including fabrics/USB).
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: v2 is 2/2. **1/2 is self-contained.** 2/2 is optional logging, not required for the bounds fix.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: Web search of lore.kernel.org/stable for this subject found **no relevant discussion** (unrelated historical hits only). Not previously rejected for stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: **nvme_ns_report_zones()** (uses nvme_zns_alloc_report_buffer(), nvme_zone_parse_entry(), nvme_submit_sync_cmd()).
**Step 5.2: TRACE CALLERS**
Record:
- nvme_report_zones() in drivers/nvme/host/core.c — gendisk .report_zones (nvme_bdev_ops)
- nvme_ns_head_report_zones() in drivers/nvme/host/multipath.c — multipath head ops
Both under CONFIG_BLK_DEV_ZONED (zns.o is nvme- core-$(CONFIG_BLK_DEV_ZONED)).
Upper layer: blkdev_do_report_zones() → ioctl, blkdev_report_zones(), and **revalidate with UINT_MAX** (block/blk- zoned.c ~2354). Filesystems: zonefs, f2fs, btrfs, xfs zoned.
**Step 5.3: TRACE CALLEES**
Record: alloc buffer (vmalloc, queue limits), Zone Management Receive with NVME_REPORT_ZONE_PARTIAL, parse entries, disk_report_zone(), kvfree.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace BLKREPORTZONE / zoned FS mount / disk revalidate → disk->fops->report_zones → nvme_ns_report_zones. **Reachable from userspace and from device probe.** Unprivileged trigger depends on device node permissions; probe path is admin/boot. Malicious NVMe-over- Fabrics still in scope for some deployments.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: NVMe target already caps with get_nr_zones_from_buf(). SCSI sd_zbc.c uses report-length/nr_zones differently. Host ZNS was the missing cap.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- Tree: **Linux 7.3.0-rc4** (git describe HEAD = v7.3-rc4-27-gf0100363d8c37).
- File and function exist; current zns.c **already contains this cap** (commit is in HEAD).
- Bug introduced **v5.9** (240e6ee272c07); not after this branch point.
- This checkout is **mainline 7.3-rc**, not an older LTS cut, but the **same nvme_ns_report_zones loop** is what older stables still have without the cap.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** on this tree (already applied). Context around nz = min(...) is stable since the 2020 error-handling fix. No conflicting later rewrite of that assignment. Expected **clean or trivial** cherry-pick onto trees that still have nvme_ns_report_zones().
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This is the fix. No alternate max_in_buf cap. Sibling logging commit is independent.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **drivers/nvme/host/ ZNS** — **IMPORTANT** (storage; not core mm/VFS, but NVMe zoned devices used by zonefs/f2fs/btrfs/xfs). Config- gated by CONFIG_BLK_DEV_ZONED.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: NVMe host is actively maintained; zns.c itself is **mature** (ZNS since 2020). Long-lived bug, not churn from a new subsystem.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver/config-specific:** NVMe ZNS namespaces (CONFIG_BLK_DEV_ZONED). Not all NVMe users; all ZNS users on report/revalidate/ioctl/FS mount.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Common path: zone report / revalidate (UINT_MAX zones).
- Harmless on spec-compliant PR=1 devices (NZ already ≤ buffer).
- Harmful if firmware reports NZ larger than transferred descriptors (ignore PR, report total count, or malicious controller).
- Not a timing race. Device-controlled integer.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Out-of-bounds kernel read** of report->entries[i] past buflen → oops/KASAN, possible infoleak. **Severity: HIGH** (memory safety from device-provided length). Inflated nz can also skip zones in sector += if the loop continues; the OOB is the primary issue.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** HIGH for ZNS — prevents OOB on buggy/malicious controllers; correct remaining-count; matches target-side logic.
- **Risk:** VERY LOW — 6 insertions, only tightens a min(); no lock/API/hot-path change.
- **Ratio:** strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real OOB: parse count from device NZ not limited by DMA/vmalloc buffer
- Buffer is routinely smaller than requested nr_zones (queue limits, vmalloc backoff)
- Revalidate uses UINT_MAX, so min(NZ, nr_zones) does not cap
- Small (+6/−2), obviously correct min3
- Reviewed by Christoph Hellwig; applied by Keith Busch
- Same cap already in NVMe target
- Bug in tree since v5.9; no extra deps
- No new API/feature
AGAINST:
- No public crash/syzbot report (spec-compliant devices already set NZ)
- ZNS is a subset of NVMe users
- No Fixes:/Cc: stable (ignored per rules)
UNRESOLVED:
- Could not fetch lore.kernel.org HTML (403); thread recovered via b4 dig -m
- No stable-list discussion found
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — maintainer Reviewed-by; applied to nvme-7.3
2. Fixes a real bug that affects users? **PASS** — OOB if NZ exceeds buffer; reachable zone-report path
3. Important issue? **PASS** — HIGH memory-safety (OOB read), not cosmetic
4. Small and contained? **PASS** — 8 lines, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — code present; patch already applies here
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Not** a device-ID/quirk/DT/build/docs exception. Ordinary **memory-safety bug fix**.
**Step 9.4: MAKE YOUR DECISION**
This should be backported: it is a small, maintainer-acked cap that stops the ZNS host from walking off the report buffer when the device’s NZ is larger than what buflen can hold. On this 7.3-rc4 tree the ZNS report path exists and the same bug has been in nvme_ns_report_zones() since v5.9.
What it solves for stable users: kernel OOB on NVMe ZNS zone reports (ioctl, FS mount, disk revalidate), especially with BLK_ALL_ZONES and firmware that does not honor Partial Report.
Risk vs benefit: benefit is memory safety on a real I/O path; risk is a tighter min that is a no-op on compliant devices.
Concerns: none material. Sibling logging patch is not required. No missing prerequisites on this tree.
Verification:
- [Phase 1] Parsed subject/tags: Reviewed-by Christoph Hellwig; SOB Keith Busch; no Fixes/Reported-by/Cc:stable
- [Phase 1] Body: PR=1 / NZ vs DMA buffer; missing max_in_buf cap
- [Phase 2] Diff: drivers/nvme/host/zns.c +6/−2 in nvme_ns_report_zones(); min3(device NZ, nr_zones - zone_idx, max_in_buf)
- [Phase 2] Struct sizes: nvme_zone_report 64B, descriptor 64B (include/linux/nvme.h)
- [Phase 2] Alloc can shrink buffer: nvme_zns_alloc_report_buffer() hw_sectors/segments/vmalloc halving
- [Phase 3] git blame: loop from 240e6ee272c07 (v5.9-rc1)
- [Phase 3] git describe --contains 240e6ee272c07 → v5.9-rc1; 09c9062d4f621 → v7.3-rc1
- [Phase 3] git merge-base --is-ancestor both SHAs vs HEAD: success
- [Phase 3] No Fixes: tag; sibling 3456b52552896 is logging-only
- [Phase 4] b4 dig -c: msgid [email protected]
- [Phase 4] b4 dig -a: v1 then v2 (split log change)
- [Phase 4] b4 dig -w: linux-nvme, kbusch, axboe, hch, sagi
- [Phase 4] mbox: Christoph “Looks good” + R-b; Keith “applied to nvme-7.3”; no NAK
- [Phase 4] lore HTTP 403; used b4 mbox instead
- [Phase 4] stable list search: no relevant thread
- [Phase 5] Callers: core.c nvme_report_zones, multipath.c nvme_ns_head_report_zones; blk-zoned.c UINT_MAX revalidate
- [Phase 5] BLK_ALL_ZONES = (unsigned int)-1 in include/linux/blkdev.h
- [Phase 5] Target already has get_nr_zones_from_buf()
- [Phase 6] git describe HEAD: v7.3-rc4-27-g…; make kernelversion:
7.3.0-rc4
- [Phase 6] Current zns.c already has max_in_buf / min3
- [Phase 8] Failure: OOB read of report->entries[]; severity HIGH
- UNVERIFIED: live crash on specific firmware (no public repro); does not override code-level OOB
The patch is small, correct, and fixes a real device-controlled bounds bug in NVMe ZNS zone reporting.
**YES**
drivers/nvme/host/zns.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/nvme/host/zns.c +6 -2
@@ -178,7 +178,7 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,struct nvme_zone_report *report;struct nvme_command c = { };int ret, zone_idx =0 ; -unsigned int nz, i; +unsigned int max_in_buf, nz, i;size_t buflen;if (ns->head->ids.csi !=NVME_CSI_ZNS )
@@ -188,6 +188,9 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,if (!report)return -ENOMEM ; + max_in_buf = (buflen -sizeof (struct nvme_zone_report )) / +sizeof (struct nvme_zone_descriptor ); + c.zmr.opcode = nvme_cmd_zone_mgmt_recv; c.zmr.nsid =cpu_to_le32 (ns->head->ns_id); c.zmr.numd =cpu_to_le32 (nvme_bytes_to_numd (buflen));
@@ -207,7 +210,8 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector, goto out_free; } - nz =min ((unsigned int )le64_to_cpu (report->nr_zones), nr_zones); + nz =min3 ((unsigned int )le64_to_cpu (report->nr_zones), + nr_zones - zone_idx, max_in_buf);if (!nz)break ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: usb-audio: Add MIN_MUTE quirk for Creative Sound Blaster Play! 3
In reply to Sasha LevinFrom: Chad Talbott <[email protected]>
[ Upstream commit 352cef030f9036a658e6eb03d6bb85fa19c7c103 ]
The Creative Sound Blaster Play! 3 (041e:324d) exposes a Feature Unit volume control with a range of -44.00 dB .. 0.00 dB over raw values 0..88, but raw value 0 is in fact a hard mute rather than -44.00 dB.
Tested on hardware.
---
LLM Generated explanations, may be completely bogus:
This is a hardware quirk for an existing USB-audio device. The local tree is **6.12.111** (p-6.12-3-gc504cf0baa3d8). The MIN_MUTE machinery is already here; only the device ID is missing.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ALSA: usb-audio:] [Add] [MIN_MUTE quirk for Creative Sound Blaster Play! 3 (041e:324d)]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Chad Talbott <[email protected]> (author)
- `Link: https://patch.msgid.link/20260819003237.452807-1-
[email protected]`
- Signed-off-by: Takashi Iwai <[email protected]> (ALSA maintainer applied it)
- No Fixes:, no Reported-by:, no Cc: stable (absence is expected)
- Ignore any pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] markers
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: Play! 3 reports Feature Unit volume as -44.00 dB .. 0.00 dB over raw 0..88, but raw 0 is a **hard mute**, not -44 dB.
- Symptom: userspace (PulseAudio/PipeWire) treats the bottom of the slider as a quiet but audible level. Volume mapping is wrong; audio stays silent until the slider is raised well above 0.
- Version info: none in the message. The device is existing USB audio hardware, not a new kernel-era device.
- Root cause: device firmware lies about the meaning of the minimum volume value. The kernel must advertise DB_MINMAX_MUTE via TLV.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. This is an explicit hardware quirk. Same class as the C-Media min-mute fix (0f174b3525a43, 2017, originally `Cc:
stable`) and later MIN_MUTE device-ID additions already in this tree.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: sound/usb/quirks.c only (+2 lines)
- Function/table: quirk_flags_table[]
- Scope: single-file, two-line table entry
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Before: 041e:324d has no quirk-flag match. Probe still binds the generic USB-audio driver.
- After: snd_usb_init_quirk_flags() sets QUIRK_FLAG_MIXER_PLAYBACK_MIN_MUTE (mainline name) / QUIRK_FLAG_MIXER_MIN_MUTE (this tree).
- Path: mixer Feature Unit setup, playback volume TLV. Not an error path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- Category: **hardware workaround** (quirk table entry)
- Mechanism: snd_usb_mixer_fu_apply_quirk() sees the flag and, for controls whose name contains "Playback", sets cval->min_mute = 1. snd_usb_mixer_vol_tlv() then reports SNDRV_CTL_TLVT_DB_MINMAX_MUTE instead of a plain dB min/max.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: one VID:PID added next to other Creative 0x041e entries, using an existing flag.
- Minimal: no API, no data-structure, no locking changes.
- Regression risk: very low; the flag is scoped to this ID and only changes TLV metadata for playback volume. Other devices are untouched.
- Backport note: this tree uses QUIRK_FLAG_MIXER_MIN_MUTE, not QUIRK_FLAG_MIXER_PLAYBACK_MIN_MUTE. Same effect: the local handler already limits the flag to Playback controls.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: Insertion is between existing Creative entries:
- DEVICE_FLG(0x041e, 0x3000, /* Creative SB Extigy */) — 3c69dc9134130d (Takashi Iwai, 2021)
- DEVICE_FLG(0x041e, 0x4080, /* Creative Live Cam VF0610 */) — 4d4dee0aefec36 (Takashi Iwai, 2021)
The table and adjacent IDs have been stable for years. The Play! 3 ID is simply missing.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable. The “bug” is device firmware behavior, not a kernel regression.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Related commits already in this tree:
- c2564438d30a8 — “move mixer_quirks' min_mute into common quirk” (upstream 2c3ca8cc55a3)
- 2368ce440dfbc — “Add mute TLV for playback volumes on more devices” (same pattern: extra QUIRK_FLAG_MIXER_MIN_MUTE IDs)
- 0f174b3525a43 — original C-Media min-mute (2017, Cc: stable) Standalone device-ID addition, not part of a series.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: No other Chad Talbott / chad.talbott commits under sound/usb/ in this tree. One-off hardware report, applied by the ALSA maintainer.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Prerequisite is the MIN_MUTE flag. Confirmed present: git merge-base --is-ancestor c2564438d30a8 HEAD succeeds. QUIRK_FLAG_MIXER_MIN_MUTE is defined in sound/usb/usbaudio.h as (1U << 24). Can apply standalone after renaming the flag.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 mbox on msgid [email protected] saved /tmp/sbplay3 (2 messages).
- Original submission: 18 Aug 2026, To: Takashi Iwai, Jaroslav Kysela;
Cc: linux-sound, linux-kernel. Single patch, not a series.
- Reply from Takashi Iwai ([email protected], 19 Aug 2026):
**“Applied now. Thanks.”** No NAK, no requested revisions, no stable discussion.
- b4 dig -c was not usable: the commit is not in this checkout.
- Direct lore WebFetch returned HTTP 403; the mbox from b4 is the source of truth.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: Recipients were the ALSA maintainers and linux-sound. Maintainer applied v1 as-is.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No bugzilla/syzbot link. Evidence is the author’s “Tested on hardware” and the concrete VID:PID plus measured dB range.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone [PATCH], not X/Y. Thread has only the patch and the apply ack.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable WebFetch returned 403. No stable-list discussion found via git log --grep on sound/usb/. No evidence this was rejected for stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: No function body changed. Data consumed by snd_usb_init_quirk_flags() and snd_usb_mixer_fu_apply_quirk().
**Step 5.2: TRACE CALLERS**
Record:
- snd_usb_init_quirk_flags() called from sound/usb/card.c:666 during USB-audio probe.
- snd_usb_mixer_fu_apply_quirk() called from sound/usb/mixer.c:1818 while building Feature Unit controls.
- snd_usb_mixer_vol_tlv() is the TLV callback userspace reads.
**Step 5.3: TRACE CALLEES**
Record: The new row only sets chip->quirk_flags. Later, min_mute changes TLV type to SNDRV_CTL_TLVT_DB_MINMAX_MUTE (include/uapi/sound/tlv.h).
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Plug in Play! 3 → USB-audio probe → mixer create → userspace reads volume TLV. Reachable from normal device use, not a rare config.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same QUIRK_FLAG_MIXER_MIN_MUTE already used for Conexant, C-Media, Realtek, OnePlus, HECATE, HONOR, etc. in this tree’s quirk_flags_table. This is another instance of a known, already- backported pattern.
Semcode MCP tools: not available; used grep/read.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. USB-audio mixer + MIN_MUTE flag exist. 041e:324d is **not** in sound/usb/quirks.c (or elsewhere under sound/usb/). The device will enumerate as generic USB audio with the wrong mute TLV. Bug introduced by hardware, not by a post-6.12 kernel change.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Expected difficulty: **minor** (one-token rename).
- Insertion context 0x041e, 0x3000 then 0x041e, 0x4080 is present at quirks.c:2154-2157.
- QUIRK_FLAG_MIXER_PLAYBACK_MIN_MUTE is **not** defined here.
- Use QUIRK_FLAG_MIXER_MIN_MUTE instead; local snd_usb_mixer_fu_apply_quirk() already gates on "Playback".
- Nearby mainline-only entries (0x040b:0x0897, 0x045e:0x070f) are not required.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: MIN_MUTE infrastructure and other device IDs are here. No Play! 3 entry. No alternate fix for 041e:324d.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: sound/usb/ ALSA USB-audio. **IMPORTANT** for USB DACs/headsets; not core mm/fs. Play! 3 is a real consumer USB DAC.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained; this 6.12 tree already carries later USB- audio quirk backports (JBL FIXED_RATE, AB13X reset, DSD IDs, extra MIN_MUTE IDs). Quirk-table additions are routine here.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver-specific: owners of Creative Sound Blaster Play! 3 (041e:324d). Zero effect on other hardware.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Every time the device is used with a dB-aware mixer (PulseAudio/PipeWire). Not a race. Unprivileged users hit it via the volume slider. Very likely for this hardware.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Incorrect volume/mute mapping: silence at “low” volume, min position not treated as mute. Not a panic or corruption. **MEDIUM** functionally, but it is the standard USB-audio min-mute hardware bug. Original 2017 fix was stable-bound; later MIN_MUTE ID lists are already in 6.12.y.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: high for Play! 3 users (usable volume curve).
- Risk: very low (2 lines, ID-matched, TLV only).
- Ratio: strongly favors backport with the flag-name tweak.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Classic USB-audio hardware quirk (stable exception category).
- Real, tested-on-hardware volume/mute lie from the device.
- Two-line table add; no new APIs.
- MIN_MUTE flag and handler already in this 6.12.111 tree.
- Same pattern already backported (c2564438d30a8, 2368ce440dfbc).
- ALSA maintainer applied v1 with no concerns.
- Insertion point exists next to other Creative IDs.
AGAINST:
- Original patch uses QUIRK_FLAG_MIXER_PLAYBACK_MIN_MUTE (needs rename to QUIRK_FLAG_MIXER_MIN_MUTE).
- Not a crash/UAF/security issue.
- Affects one consumer DAC.
UNRESOLVED:
- Could not query lore.kernel.org/stable (HTTP 403). No indication of a prior reject.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — hardware-tested; maintainer applied.
2. Fixes a real bug that affects users? **PASS** — wrong mute/volume mapping on a real DAC.
3. Important issue? **PASS** under the hardware-quirk exception (not a crash).
4. Small and contained? **PASS** — +2 lines, one file.
5. No new features or APIs? **PASS** — existing quirk flag, new device ID only.
6. Can apply to the local tree? **PASS** with trivial backport (MIXER_PLAYBACK_MIN_MUTE → MIXER_MIN_MUTE).
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Hardware quirk/workaround** (USB-audio mixer min-mute), equivalent in spirit to USB/PCI quirk table additions.
**Step 9.4: MAKE YOUR DECISION**
Backport. The local tree already has the quirk flag; this only adds the Play! 3 ID. Rename the flag during apply.
------------------------------------------------
What problem it solves, and why it matters here
------------------------------------------------
Play! 3 reports -44 dB at raw 0, but raw 0 is mute. Without the TLV mute bit, PulseAudio/PipeWire keep the device “silent until ~30% volume.” That is the same class of bug already documented in this tree’s MIN_MUTE commit (PipeWire MR / Arch wiki). 6.12 users with this DAC still hit it.
Risk vs benefit: two-line, ID-scoped TLV change vs broken volume on a supported USB-audio device. Benefit wins.
Concerns: mechanical apply of the mainline diff will not compile until the flag is renamed. That is a one-token stable backport, not a missing- prerequisite situation.
Verification:
- [Phase 1] Parsed tags: author SOB, Link msgid, Takashi Iwai SOB; no Fixes/Reported-by/Cc:stable
- [Phase 1] Body: 041e:324d, -44 dB vs hard mute at raw 0, tested on hardware
- [Phase 2] Diff: +2 lines in sound/usb/quirks.c quirk_flags_table[]
- [Phase 2] Handler in this tree: mixer_quirks.c:4504-4506 sets cval->min_mute for Playback when QUIRK_FLAG_MIXER_MIN_MUTE is set
- [Phase 2] TLV: mixer.c:555-556 uses SNDRV_CTL_TLVT_DB_MINMAX_MUTE
- [Phase 3] Blame: Creative neighbors from 2021 (3c69dc9134130d, 4d4dee0aefec36)
- [Phase 3] git merge-base --is-ancestor c2564438d30a8 HEAD: MIN_MUTE infra **is** in this tree
- [Phase 3] 2368ce440dfbc already added more MIN_MUTE IDs to this tree
- [Phase 3] No Fixes: tag (N/A)
- [Phase 3] git log --author='Chad Talbott' -- sound/usb/: no other commits
- [Phase 4] b4 mbox msgid [email protected]: 2-message thread; Iwai “Applied now”
- [Phase 4] lore WebFetch 403; stable-list search 403
- [Phase 5] Callers: snd_usb_init_quirk_flags from card.c:666; snd_usb_mixer_fu_apply_quirk from mixer.c:1818
- [Phase 5] semcode unavailable
- [Phase 6] git describe HEAD → p-6.12-3-gc504cf0baa3d8; make kernelversion → 6.12.111
- [Phase 6] 0x324d absent; QUIRK_FLAG_MIXER_PLAYBACK_MIN_MUTE absent; QUIRK_FLAG_MIXER_MIN_MUTE present; sandwich context present
- [Phase 8] Failure mode: wrong volume/mute TLV on one USB DAC; not a kernel oops
- UNVERIFIED: full lore.kernel.org HTML thread (403); whether a later mainline commit renamed MIN_MUTE → PLAYBACK_MIN_MUTE (flag absent here; local Playback filter makes the names equivalent)
**YES**
sound/usb/quirks.c | 2 ++ 1 file changed, 2 insertions(+)
sound/usb/quirks.c +2 -0
@@ -2152,6 +2152,8 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = { QUIRK_FLAG_GET_SAMPLE_RATE | QUIRK_FLAG_MIC_RES_16),DEVICE_FLG (0x041e ,0x3000 ,/* Creative SB Extigy */ QUIRK_FLAG_IGNORE_CTL_ERROR ), +DEVICE_FLG (0x041e ,0x324d ,/* Creative Sound Blaster Play! 3 */ +QUIRK_FLAG_MIXER_PLAYBACK_MIN_MUTE ),DEVICE_FLG (0x041e ,0x4080 ,/* Creative Live Cam VF0610 */ QUIRK_FLAG_GET_SAMPLE_RATE ), DEVICE_FLG(0x045e, 0x083c, /* MS USB Link headset */
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/realtek: Fix speakers on ASUS ROG Zephyrus G14 GA403UM
In reply to Sasha LevinFrom: Garrett Blackmon <[email protected]>
[ Upstream commit 140fe610af607fd70da95c447943fc2690855519 ]
The GA403UM (SSID 1043:1044) uses the same ALC285 codec + dual CS35L56 I2C amplifier topology as the GA403U and GA403W variants, which already have quirk entries (1043:1b13, 1043:1024). Without the quirk, the woofers sit on a separate DAC from the tweeters, so the hardware volume control only scales part of the speaker system and the headset microphone pins are not configured.
Apply the existing ALC285_FIXUP_ASUS_GA403U_HEADSET_MIC fixup to the GA403UM as well.
---
LLM Generated explanations, may be completely bogus:
This is a one-line PCI SSID quirk for an existing Realtek fixup. The local tree is **6.12.111** (pending-6.12, p-6.12-3-g710455e2077bb). The GA403U fixup chain is already here; SSID 1043:1044 is not.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ALSA: hda/realtek] [Fix] speakers on ASUS ROG Zephyrus G14 GA403UM
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Garrett Blackmon <[email protected]> (author)
- `Link:
https://patch.msgid.link/[email protected]`
- Signed-off-by: Takashi Iwai <[email protected]> (ALSA maintainer)
- No Fixes: tag (expected)
- No Cc: stable (expected; not a negative)
- No Reported-by: / Tested-by: / Reviewed-by: / Acked-by:
- Ignore pipeline Signed-off-by: Sasha Levin if present; it is not on the mainline commit 140fe610af607
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** GA403UM (SSID 1043:1044) has ALC285 + dual CS35L56 I2C amps, same topology as GA403U (1043:1b13) and GA403W (1043:1024).
- **Symptom:** Without the quirk, woofers are on a different DAC from tweeters, so hardware volume only scales part of the speaker system; headset-mic pins are not configured.
- **Root cause:** Missing SND_PCI_QUIRK entry; the machine never gets ALC285_FIXUP_ASUS_GA403U_HEADSET_MIC.
- **Version info:** None in the message. Commit date is 2026-08-07 (after v6.12, 2024-11-17).
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. It is an explicit hardware-quirk fix for broken speakers/headset mic.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- Mainline file: sound/hda/codecs/realtek/alc269.c (+1 / -0)
- Function/table: alc269_fixup_tbl[]
- Scope: single-file, one-line PCI quirk addition
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** SSID 1043:1044 does not match; generic auto-parse leaves bass speaker NID 0x17 on a separate DAC and does not set headset-mic pins 0x19/0x1b.
- **After:** That SSID selects ALC285_FIXUP_ASUS_GA403U_HEADSET_MIC, which:
1. Sets pins {0x19, 0x03a11050} and {0x1b, 0x03a11c30}
2. Chains to ALC285_FIXUP_ASUS_GA403U_I2C_SPEAKER2_TO_DAC1
(`alc285_fixup_speaker2_to_dac1` forces NID `0x17` onto
DAC1/`0x02`) 3. Chains to ALC285_FIXUP_ASUS_GA403U (inv-dmic only if codec is not ALC285, for SSID reuse)
- Path: HDA probe / patch_alc269(), not an error path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Hardware workaround (PCI SSID quirk).** Missing table entry for a shipped laptop SKU. Not UAF/race/leak.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: reuse of an existing, already-shipped fixup.
- Minimal: one SND_PCI_QUIRK line.
- Regression risk: very low; the entry matches only vendor 0x1043, SSID 0x1044. 0x1044 is unused in this tree’s Realtek quirk table.
- SSID-reuse note: alc285_fixup_asus_ga403u already guards non-ALC285 hardware that reused 0x1b13. This new ID is a distinct SSID, not that reuse case.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Insertion sits between existing ASUS entries 0x103f (TX300, 2013) and 0x1054 (G614, 2025 backport).
- Buggy “code” is absence of 1043:1044, not a later regression in shared logic.
- The fixup being applied was introduced by 0672b017324b1 (“Fixes for Asus GU605M and GA403U sound”, 2024-04-18) and is in this tree.
- Earlier c33f0d4fcfe07 (2024-03-30) added CS35L56 laptop quirks and the GA403U SSID-reuse comment; also in this tree.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The functional prerequisite is 0672b017324b1, present here (git merge-base --is-ancestor → yes).
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Related in this tree: c33f0d4fcfe07, 0672b017324b1.
- Sibling mainline quirk cbd46cbc5470f (GA403W 1043:1024, 2026-01) is **not** in this tree. It is a parallel SKU entry, not a prerequisite for 1043:1044.
- Candidate 140fe610af607 is **not** an ancestor of HEAD.
- This 6.12 tree already backports many similar one-line Realtek quirks (recent log is almost entirely Add quirk for …).
- Standalone: one table line; no series (patch X/Y).
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Garrett Blackmon has this single Realtek commit on origin/master. Takashi Iwai applied it the same day. Author is a hardware user, not the subsystem maintainer; maintainer acked by applying.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Record:
- Needs ALC285_FIXUP_ASUS_GA403U_HEADSET_MIC and alc285_fixup_speaker2_to_dac1 — both exist in sound/pci/hda/patch_realtek.c.
- Needs CS35L56 HDA I2C sidecar — sound/pci/hda/cs35l56_hda_i2c.c is present.
- Does **not** need the GA403W 0x1024 entry.
- Cannot apply the mainline diff as-is: mainline file is sound/hda/codecs/realtek/alc269.c (split ~2025-07). This tree still has sound/pci/hda/patch_realtek.c. Backport is the same one line at the same SSID sort position (after 0x103f, before 0x1054).
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 140fe610af607 →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only** (2026-08-07), no later revisions.
- Thread: author submission + Takashi Iwai “Applied to for-next branch now. Thanks.”
- No NAK, no stable nomination in-thread, no risk discussion.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc [email protected], [email protected], linux- [email protected]. ALSA maintainers were on the patch; Iwai applied it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No bugzilla/syzbot link. The commit itself is the user report (author is fixing their GA403UM). Severity from the text: partial speaker volume + unconfigured headset mic.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone v1. Related sibling is GA403W cbd46cbc5470f (not required). No follow-up on origin/master that changes 1043:1044.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search returned HTTP 403. **UNVERIFIED** whether it was discussed on stable@. Not used for the verdict.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: No function body change. Adds one entry to alc269_fixup_tbl[]. Consumed fixups: ALC285_FIXUP_ASUS_GA403U_HEADSET_MIC → alc285_fixup_speaker2_to_dac1 → alc285_fixup_asus_ga403u.
**Step 5.2: TRACE CALLERS**
Record:
- patch_alc269() calls snd_hda_pick_fixup(..., alc269_fixup_tbl, alc269_fixups) at probe (sound/pci/hda/patch_realtek.c).
- patch_alc269 covers the ALC269 family, including ALC285 (0x10ec0285).
- Trigger: HD-audio codec probe on this laptop, not interrupt/hot path.
**Step 5.3: TRACE CALLEES**
Record: snd_hda_pick_fixup matches PCI SSID, then pin overrides + snd_hda_override_conn_list(codec, 0x17, …) so bass/woofer shares DAC1 with the main speakers.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: PCI/HDA enumeration → Realtek codec probe → patch_alc269 → quirk table. Reachable on every boot of a GA403UM. Not a syscall attack path; it is the normal audio device path.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same fixup already used for 0x1043, 0x1b13 (“ASUS U41SV/GA403U”). This commit extends that pattern to another SKU. This tree regularly takes the same class of one-line quirk.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes, as a missing SSID.
- Tree: 6.12.111 / pending-6.12.
- File: sound/pci/hda/patch_realtek.c.
- Fixup IDs and implementations are present (lines ~7529, ~6831, ~10586–10618).
- 0x1b13 is present (line 11257). 0x1044 is **not**.
- Candidate 140fe610af607 is not an ancestor of HEAD.
- Hardware is a 2026 G14 SKU; 6.12 is LTS, so users can run this kernel on that laptop.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Raw mainline patch does not apply (file was split to sound/hda/codecs/realtek/alc269.c after 6.12). Functional backport is
trivial: insert the same SND_PCI_QUIRK between 0x103f and 0x1054 in patch_realtek.c (lines 11185–11186). No data-structure or API gap.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: GA403U fixup yes; this SSID no. No alternate GA403UM fix. git grep 0x1044 in patch_realtek.c is empty.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: sound/pci/hda Realtek HD-audio. **IMPORTANT** (laptop audio), not core mm/fs. Maintainers: Takashi Iwai, Jaroslav Kysela (MAINTAINERS SOUND). Config: SND_HDA_CODEC_REALTEK.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Very active quirk table; recent 6.12 backports are mostly device-specific SND_PCI_QUIRK additions. Mature pattern, low novelty.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver/platform-specific: ASUS ROG Zephyrus G14 GA403UM, SSID 1043:1044, ALC285 + CS35L56. No effect on other machines.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Every boot / any speaker volume or headset-mic use on that model. Unprivileged user using audio. Not a race.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- Failure: woofers do not follow master volume (split DAC); headset mic pins unconfigured.
- **Severity: MEDIUM–HIGH** for that hardware (laptop audio effectively broken), not a kernel oops. This is the class of “device doesn’t work correctly without a quirk.”
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** High for GA403UM owners on 6.12.y (working speakers + headset pins).
- **Risk:** Very low (one SSID line, existing fixup, SSID unused).
- **Ratio:** Strongly favors backport. Matches the documented hardware- quirk exception.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real user-visible bug: incomplete speaker volume and unconfigured headset mic.
- One-line SND_PCI_QUIRK using a fixup already in 6.12.
- Prerequisite 0672b017324b1 is in this tree; CS35L56 HDA I2C is in this tree.
- ALSA maintainer applied v1 the same day; no NAK.
- Classic stable exception: PCI ID / hardware quirk for an existing driver.
- This tree already carries the same fixup for GA403U (0x1b13).
- Insertion point exists; 0x1044 is free.
AGAINST:
- Mainline patch path differs (alc269.c vs patch_realtek.c); needs a one-line backport, not a raw apply.
- No Reported-by besides the author; no syzbot/CVE.
- Not a crash/security bug.
- Sibling 0x1024 (GA403W) is absent — irrelevant; that SKU is independent.
UNRESOLVED:
- Stable@ lore search (HTTP 403).
- WebFetch of lore also 403; thread recovered via b4 dig -m.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — reuse of in-tree fixup; maintainer applied.
2. Fixes a real bug that affects users? **PASS** — broken volume/headset on GA403UM.
3. Important issue? **PASS** — hardware-quirk exception; audio broken on that laptop, not a panic.
4. Small and contained? **PASS** — 1 line.
5. No new features or APIs? **PASS** — existing quirk ID only.
6. Can apply to the local tree? **PASS** with trivial path adjustment (patch_realtek.c, same context).
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Hardware quirk / PCI SSID addition to an existing driver.** Automatic YES class.
**Step 9.4: MAKE YOUR DECISION**
The missing SSID is present as a gap in this 6.12 tree, the target fixup chain is complete, and the change cannot affect any other device. Backport it.
------------------------------------------------
What the commit solves for this tree
------------------------------------------------
On GA403UM, Linux never applies the GA403U speaker/mic fixup. Master volume then moves only tweeters (woofers stay on another DAC), and headset-mic pins stay wrong. Adding SND_PCI_QUIRK(0x1043, 0x1044, "ASUS GA403UM", ALC285_FIXUP_ASUS_GA403U_HEADSET_MIC) to alc269_fixup_tbl in sound/pci/hda/patch_realtek.c is the whole fix.
Risk vs benefit: benefit is working audio on that LTS laptop; risk is a single unused-SSID match. File-split means the mainline diff needs a one-line rewrite, which is normal for Realtek quirks on 6.12.
Verification:
- [Phase 1] Parsed tags on 140fe610af607: SOB Blackmon, Link msgid, SOB Iwai; no Fixes/stable/Reported-by
- [Phase 2] Diff: +1 line SND_PCI_QUIRK(0x1043, 0x1044, … ALC285_FIXUP_ASUS_GA403U_HEADSET_MIC)
- [Phase 3] git describe HEAD / make kernelversion:
p-6.12-3-g710455e2077bb, 6.12.111, branch pending-6.12
- [Phase 3] git merge-base --is-ancestor 140fe610af607 HEAD → not in tree
- [Phase 3] git merge-base --is-ancestor 0672b017324b1 HEAD → yes (GA403U fixup)
- [Phase 3] git merge-base --is-ancestor cbd46cbc5470f HEAD → no (GA403W 0x1024; not required)
- [Phase 3] Confirmed fixup chain and 0x1b13 in sound/pci/hda/patch_realtek.c; 0x1044 absent
- [Phase 4] b4 dig -c 140fe610af607 / -a / -w / -m: v1 only; Iwai applied; To linux-sound + maintainers
- [Phase 4] UNVERIFIED: lore.kernel.org WebFetch and stable@ search (HTTP 403)
- [Phase 5] patch_alc269() → snd_hda_pick_fixup(..., alc269_fixup_tbl, …) at codec probe
- [Phase 5] alc285_fixup_speaker2_to_dac1 overrides NID 0x17 to DAC 0x02
- [Phase 6] Insertion context 0x103f then 0x1054 present at lines 11185–11186
- [Phase 6] cs35l56_hda_i2c.c present
- [Phase 8] Failure mode: partial speaker volume + unconfigured headset mic on one laptop SSID
- UNVERIFIED: whether this SSID was already requested on stable@
**YES**
sound/hda/codecs/realtek/alc269.c | 1 + 1 file changed, 1 insertion(+)
sound/hda/codecs/realtek/alc269.c +1 -0
@@ -7094,6 +7094,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x1043 ,0x1034 ,"ASUS GU605C" ,ALC285_FIXUP_ASUS_GU605_SPI_SPEAKER2_TO_DAC1 ),SND_PCI_QUIRK (0x1043 ,0x103e ,"ASUS X540SA" ,ALC256_FIXUP_ASUS_MIC ),SND_PCI_QUIRK (0x1043 ,0x103f ,"ASUS TX300" ,ALC282_FIXUP_ASUS_TX300 ), +SND_PCI_QUIRK (0x1043 ,0x1044 ,"ASUS GA403UM" ,ALC285_FIXUP_ASUS_GA403U_HEADSET_MIC ),SND_PCI_QUIRK (0x1043 ,0x1054 ,"ASUS G614FH/FM/FP" ,ALC287_FIXUP_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x1043 ,0x106d ,"Asus K53BE" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST ), SND_PCI_QUIRK(0x1043, 0x106f, "ASUS VivoBook X515UA", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 perf/x86/intel/uncore: Fix PCI PMU cleanup on setup failure
In reply to Sasha LevinFrom: Zide Chen <[email protected]>
[ Upstream commit 003267cb94e21d762eb72d6977d84f44f1705bb7 ]
When uncore_pci_pmu_register() fails, pmu->boxes[die] is set to NULL before returning. In the uncore_pci_remove() path, this causes uncore_pci_pmu_unregister() to be skipped entirely, leaking pmu->activeboxes. In the uncore_bus_notify() path, uncore_pci_pmu_unregister() may still be called and must exit early when pmu->boxes[die] is NULL to avoid a NULL pointer dereference, and to ensure activeboxes is only decremented for a previously active box.
Additionally, since pci_get_drvdata() returns NULL on registration failure, uncore_pci_remove() can no longer treat NULL drvdata as an indicator of an auxiliary PCI device. Remove the associated WARN_ON_ONCE().
---
LLM Generated explanations, may be completely bogus:
The 6.18.53 file matches the pre-fix code exactly, so this is a clean, self-contained error-path leak and NULL-deref fix. Full phase walkthrough follows.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [perf/x86/intel/uncore] [fix] [PCI PMU cleanup on setup failure]
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Zide Chen (author)
- Signed-off-by: Peter Zijlstra (Intel) (perf/x86 maintainer)
- Reviewed-by: Dapeng Mi (Intel uncore reviewer)
- Link: https://sashiko.dev/#/patchset/20260512233048.9577-1-
[email protected]?part=1
- Link:
https://patch.msgid.link/[email protected]
- No Fixes: tag (expected)
- No Reported-by / Tested-by / syzbot
- No Cc: stable (expected)
- Ignore: [Upstream commit 003267cb94e21d762eb72d6977d84f44f1705bb7] and Sasha Levin SOB (pipeline)
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: when uncore_pci_pmu_register() fails, pmu->boxes[die] is NULLed and the box is freed, but pmu->activeboxes stays incremented.
- Symptoms: (1) uncore_pci_remove() skips unregister because drvdata is NULL → activeboxes leak; (2) uncore_bus_notify() still calls unregister → NULL deref of box; (3) false WARN_ON_ONCE() because NULL drvdata is no longer uniquely “extra PCI device”.
- Version info: none in the message. Code dates to 2020.
- Root cause: incomplete error-path rollback in uncore_pci_pmu_register(), and unregister not tolerating a NULL box.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not hidden. Explicit leak + NULL-deref + false-WARN fix. The “remove WARN_ON” piece is diagnostic, not a new feature.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: arch/x86/events/intel/uncore.c (+4 / −1)
- Functions: uncore_pci_pmu_register(), uncore_pci_pmu_unregister(), uncore_pci_remove()
- Scope: single-file surgical fix (5 lines)
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Hunk 1 (uncore_pci_pmu_register): first-box uncore_pmu_register() failure already NULLed boxes[die], exited and freed the box, but left activeboxes incremented. After: atomic_dec(&pmu->activeboxes) on that path.
- Hunk 2 (uncore_pci_pmu_unregister): previously always used box and decremented activeboxes. After: return immediately if box is NULL (no deref, no bogus decrement).
- Hunk 3 (uncore_pci_remove): drop WARN_ON_ONCE(i >= UNCORE_EXTRA_PCI_DEV_MAX) when drvdata is NULL.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Category: error-path resource leak + NULL pointer dereference (and a false WARN).
- Mechanism: atomic_inc_return(&pmu->activeboxes) runs before uncore_pmu_register(). On failure the box is torn down but the counter is not. Discovery/bus_notify still looks up the PMU by PCI identity and calls unregister, which does uncore_box_exit(box) on NULL (box->flags).
- Leak consequence: the next box of the same PMU sees activeboxes > 1 and skips uncore_pmu_register(), so the PMU never appears in perf.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Quality: obviously correct. Decrement matches the increment; NULL guard is the standard pattern; no API/data-structure change.
- Regression risk: very low. Sashiko noted that PCI probe failure does not call remove(), so the WARN removal is not strictly required for that path. That only drops a diagnostic; it does not create a crash. The NULL check is required for uncore_bus_notify(), which is independent of remove().
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Buggy register error path: 16fa64315c1bd (“Factor out uncore_pci_pmu_register()”), Kan Liang, 2020-09-14. First mainline:
v5.10-rc1.
- Unregister without NULL check: cdcce92a3a03bc (2020).
- WARN_ON_ONCE: 899396cf7b4b31 (Yan Zheng, 2013).
- Long-lived code, present in this 6.18 tree.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Introducer is 16fa64315c1bd, which **is** an ancestor of v6.18.53.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- This is v3 1/8 of “PMU setup robustness fixes”.
- Series: 1/8 this fix; 2/8 refcnt cleanup; 3/8 init_box errors; 4/8 keep PCI PMUs if MMIO/MSR alloc fails; 5/8 factor box setup; 6–8 flags/lazy setup.
- 4/8 (d623e292c6a4c) is already in v6.18.53. 2/8 and 5/8 are not.
- This patch does not depend on 2/8+; later patches build on it. Standalone.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Zide Chen is an active Intel uncore contributor on this tree (die-id, discovery, IMC events, etc.). Maintainer path: Peter Zijlstra SOB. Dapeng Mi Reviewed-by.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: No missing helpers or types. Parent of the candidate and v6.18.53:arch/x86/events/intel/uncore.c are byte-identical (same sha256). Applies standalone. Dry-run patch -p1 against the v6.18.53 file succeeded.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 540120722e9bf: [PATCH V3 1/8] perf/x86/intel/uncore: Fix PCI PMU cleanup on setup failure
- URL:
https://patch.msgid.link/[email protected]
- lore.kernel.org WebFetch returned 403; full thread saved via b4 dig -m (26 messages).
- V1/V2 existed; this patch was **new in v2** after Sashiko review of v1. v3 only added Reviewed-by. Applied version is latest.
- Cover letter: “PCI PMU cleanup on setup failure has activeboxes leaks and potential NULL pointer dereference in error paths.”
- No NAK. tip-bot applied it to perf/core (2026-06-30).
- Sashiko on v3: questioned WARN_ON removal (Medium); two High notes were pre-existing UAF/races, not introduced by this patch. No stable NAK.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: b4 dig -w recipients: Peter Zijlstra, Ingo Molnar, Arnaldo, Namhyung Kim, Ian Rogers, Adrian Hunter, Alexander Shishkin, Andi Kleen, Stephane Eranian, linux-kernel, linux-perf-users, Dapeng Mi. Dapeng Reviewed-by on the committed patch; Peter Zijlstra SOB.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla. Found by code review (Sashiko on v1 → new patch 1 in v2). Still a real, reachable error path, not a theoretical rewrite.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: 8-patch robustness series. This 1/8 is self-contained. 4/8 already landed in this 6.18.53 tree. Later patches are larger (broken- state, lazy MSR/MMIO) and are not required for this leak/NULL-deref fix.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable WebFetch returned 403. UNVERIFIED whether stable@ discussed it. Not used as a NO signal (absence of Cc: stable is expected).
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: uncore_pci_pmu_register, uncore_pci_pmu_unregister, uncore_pci_remove. Related: uncore_pci_probe, uncore_bus_notify, uncore_pci_pmus_register, uncore_pci_sub_driver_init.
Step 5.2: TRACE CALLERS
Record:
- uncore_pci_pmu_register: uncore_pci_probe (legacy uncore_pci_driver), uncore_pci_sub_driver_init (PCI sub-devices), uncore_pci_pmus_register (discovery; return value ignored).
- uncore_pci_pmu_unregister: uncore_pci_remove, uncore_bus_notify.
- uncore_bus_notify: PCI BUS_NOTIFY_DEL_DEVICE. Discovery always registers this notifier.
- Context: driver init / PCI probe / PCI device deletion. Not a syscall hot path, but boot and hot-unplug on Intel systems with uncore (default y).
Step 5.3: TRACE CALLEES
Record:
- uncore_pmu_register() → perf_pmu_register() (can fail: ENOMEM, sysfs/device_add, name collision).
- uncore_box_exit() at v6.18.53: test_and_clear_bit(..., &box->flags) — NULL box is a hard oops.
- kfree(NULL) is safe; the crash is uncore_box_exit.
Step 5.4: FOLLOW THE CALL CHAIN
Record:
- Modern Intel (no uncore_pci_driver): uncore_pci_init → uncore_pci_pmus_register → register (retval ignored) → bus_register_notifier. Failed first-box perf_pmu_register + later BUS_NOTIFY_DEL_DEVICE → uncore_pci_find_dev_pmu_from_types still finds the PMU → unregister(NULL) → oops.
- Same PMU, later boxes: activeboxes > 1 skips uncore_pmu_register → uncore PMU missing from perf.
- Reachable without a special debug option. CONFIG_PERF_EVENTS_INTEL_UNCORE defaults to y on Intel+PCI.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: MSR/MMIO setup is a different model; this series later factors PCI lazy registration for those paths. No duplicate of this exact PCI error-path bug in-tree. 2/8 adds refcnt decrement in unregister and is a follow-up cleanup, not a prerequisite.
===============================================================
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, make kernelversion 6.18.53.
- At v6.18.53, uncore_pci_pmu_register still omits atomic_dec on uncore_pmu_register() failure; unregister has no NULL check; WARN_ON_ONCE is present. Bug exists here.
- Introduced v5.10-rc1; not after 6.18 branched.
- git merge-base --is-ancestor 16fa64315c1bd v6.18.53 → yes.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Expected apply: **clean**. Candidate parent uncore.c sha256 equals v6.18.53 uncore.c. Dry-run apply succeeded.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No other “PCI PMU cleanup” fix in v6.18.53. 4/8 of the same series is already in 6.18.53 (d623e292c6a4c). That does not fix this leak/NULL deref.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [arch/x86/events/intel uncore PMU] [IMPORTANT — default-on Intel server/workstation perf, not core mm/sched, but widely enabled]
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mature (2012+) with ongoing platform adds (PTL, WCL, etc.). This bug is old incomplete error handling, not a brand-new driver.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Intel x86 with CONFIG_PERF_EVENTS_INTEL_UNCORE (default y). Driver-specific / config-default-on. Discovery platforms (newer Xeon) hit the bus-notify NULL deref path.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record:
- Trigger: first box of a PCI uncore PMU fails perf_pmu_register() (ENOMEM, sysfs failure, name clash).
- Not every boot, but a real error path. Discovery ignores register failure and still installs the notifier.
- Unprivileged users do not trigger it directly; PCI unbind/hotplug and boot setup do. Missing PMU is user-visible to perf.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- NULL deref in uncore_box_exit(NULL) on device delete → oops. **HIGH** (crash on error + unplug).
- activeboxes leak → later boxes skip PMU registration → uncore events absent. **MEDIUM–HIGH**.
- False WARN_ON. **LOW**.
- Overall: **HIGH** (crash on a reachable error path).
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: high — prevents oops and silently missing uncore PMUs after a failed first-box register.
- Risk: very low — 5 lines, no locking/API change, WARN removal is the only nit.
- Ratio: strongly favorable.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR backporting:
- Real leak of pmu->activeboxes on uncore_pmu_register() failure (code at v6.18.53 matches).
- Real NULL deref: discovery uncore_pci_pmus_register() ignores failure, uncore_bus_notify still unregisters, uncore_box_exit(NULL) oopses.
- Same leak causes later boxes to skip uncore_pmu_register(), so the PMU never shows up in perf.
- 5-line, obviously correct, no new API.
- Applies cleanly; file is identical to the pre-fix version.
- Bug present since v5.10; this 6.18 tree has it.
- Reviewed by Dapeng Mi; SOB Peter Zijlstra.
- Patch 1/8 is standalone; later series members not required.
- Same series 4/8 already in this 6.18.53 tree.
AGAINST:
- Trigger is an error path (perf_pmu_register failure), not a always- on boot crash.
- No user/syzbot report.
- Sashiko: WARN_ON removal is weakly justified for the pci_driver probe/remove model (probe failure does not call remove). Diagnostic- only concern.
- Later 2/8 refcnt cleanup is related but separate; not a blocker.
UNRESOLVED:
- Stable mailing list search via lore HTTP was 403 (mbox/review still obtained via b4).
- How often perf_pmu_register actually fails in production:
unverified, but ENOMEM/sysfs failure is a standard, reachable errno path.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — counter rollback + NULL guard; maintainer SOB; Dapeng review; in mainline perf/core.
2. Fixes a real bug that affects users? **PASS** — leak, skipped PMU registration, oops on device delete.
3. Important issue? **PASS** — NULL deref oops; missing uncore PMU. Severity HIGH.
4. Small and contained? **PASS** — 5 lines, one file.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — clean apply to v6.18.53 uncore.c.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary small bugfix; does not need an exception.
Step 9.4: MAKE YOUR DECISION
This belongs in 6.18.y: the buggy rollback is in this tree, the fix is surgical, and the failure mode is a kernel oops plus a stuck/missing PCI uncore PMU. WARN_ON removal is a minor diagnostic tradeoff, not a reason to reject the leak and NULL-deref fix.
What the commit solves for stable users: Intel uncore PCI PMU setup failure currently leaks activeboxes and can oops in uncore_bus_notify when the device goes away. Backporting restores counter balance, skips unregister when there is no box, and avoids a false WARN.
Risk vs benefit: benefit is crash/functional correctness on a default-on Intel perf driver; risk is a 5-line error-path change that applies with no prerequisites.
Verification:
- [Phase 1] Parsed tags: SOB Zide Chen, SOB Peter Zijlstra, Reviewed-by Dapeng Mi; Links to sashiko and patch.msgid.link; no Fixes/syzbot.
- [Phase 2] Diff: +atomic_dec on register failure; +if (!box) return in unregister; −WARN_ON_ONCE in remove. 4+/1− in uncore.c.
- [Phase 2] uncore_box_exit at v6.18.53 dereferences box->flags — NULL box is an oops.
- [Phase 3] blame: register failure path from 16fa64315c1bd (v5.10-rc1); present in v6.18.53.
- [Phase 3] git merge-base --is-ancestor 16fa64315c1bd v6.18.53 → yes. Candidate itself is not an ancestor of v6.18.53.
- [Phase 3] Parent uncore.c sha256 == v6.18.53 uncore.c; patch -p1 --dry-run succeeded.
- [Phase 3] Series 1/8 standalone; 4/8 d623e292c6a4c already in v6.18.53; 2/8 and 5/8 not in v6.18.53 and not required.
- [Phase 4] b4 dig -c 540120722e9bf: V3 1/8,
https://patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1→v3; this patch added in v2 after Sashiko; v3 is what landed.
- [Phase 4] b4 dig -w: perf maintainers CC’d; Dapeng Reviewed-by; no NAK.
- [Phase 4] mbox cover letter explicitly calls out activeboxes leak and NULL deref.
- [Phase 4] lore HTTP 403; discussion recovered from b4 mbox. Stable- list search UNVERIFIED (403).
- [Phase 5] Callers: probe, sub-driver init, discovery uncore_pci_pmus_register (ignores retval, always registers bus notifier).
- [Phase 5] uncore_pmu_register → perf_pmu_register can fail.
- [Phase 6] git describe HEAD = v6.18.53-5049-g0f0bdc2b0dffb; Makefile 6.18.53; buggy code at v6.18.53 lines 1166–1172 / 1229–1238 / 1257.
- [Phase 7] CONFIG_PERF_EVENTS_INTEL_UNCORE default y.
- [Phase 8] Failure mode: NULL deref oops + skipped PMU registration; severity HIGH.
- UNVERIFIED: production frequency of perf_pmu_register failure; stable@ lore thread (HTTP 403).
**YES**
arch/x86/events/intel/uncore.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/events/intel/uncore.c +4 -1
@@ -1165,6 +1165,7 @@ static int uncore_pci_pmu_register(struct pci_dev *pdev,/* First active box registers the pmu */ ret =uncore_pmu_register (pmu);if (ret) { +atomic_dec (&pmu->activeboxes); pmu->boxes[die] =NULL ;uncore_box_exit (box);kfree (box);
@@ -1230,6 +1231,9 @@ static void uncore_pci_pmu_unregister(struct intel_uncore_pmu *pmu, int die) {struct intel_uncore_box *box = pmu->boxes[die]; +if (!box) +return ; + pmu->boxes[die] =NULL ;if (atomic_dec_return (&pmu->activeboxes) ==0 )uncore_pmu_unregister (pmu);
@@ -1254,7 +1258,6 @@ static void uncore_pci_remove(struct pci_dev *pdev)break ; } } -WARN_ON_ONCE (i >=UNCORE_EXTRA_PCI_DEV_MAX );return ; }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.15] perf/x86/intel/uncore: Fix PCI PMU cleanup on setup failure
Sashiko has reviewed this patch and found no issues.
Quoted 17 lines
From: Zide Chen <[email protected]>
[ Upstream commit
003267cb94e21d762eb72d6977d84f44f1705bb7]When
uncore_pci_pmu_register()fails, pmu->boxes[die] is set to NULL before returning. In theuncore_pci_remove()path, this causesuncore_pci_pmu_unregister()to be skipped entirely, leakingpmu->activeboxes. In theuncore_bus_notify()path,uncore_pci_pmu_unregister()may still be called and must exit early when pmu->boxes[die] is NULL to avoid a NULL pointer dereference, and to ensure activeboxes is only decremented for a previously active box.Additionally, since
pci_get_drvdata()returns NULL on registration failure,uncore_pci_remove()can no longer treat NULL drvdata as an indicator of an auxiliary PCI device. Remove the associatedWARN_ON_ONCE().
Quoted 6 lines
Signed-off-by Zide Chen <[email protected]>Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Dapeng Mi <[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 perf/x86: Free hybrid state on PMU init failure
In reply to Sasha LevinFrom: Dapeng Mi <[email protected]>
[ Upstream commit 96746e731e1626545e343974ca4673739dceb31b ]
If PMU initialization fails, for example in check_hw_exists(), hybrid state can be left partially initialized: x86_pmu.hybrid_pmu is not freed and perf_is_hybrid remains set. This can leak memory and leave stale hybrid state reachable after a failed init path.
Add x86_pmu_free_hybrid() and use it on PMU init failure paths so all hybrid-related state is consistently reset.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). The hybrid PMU init/error path exists here, and this commit is a real error-path UAF/leak fix that belongs in this tree.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[perf/x86] [Free] [release hybrid PMU state when PMU init fails]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- No Fixes: tag (expected for this review pipeline)
- No Reported-by: / syzbot
- No Tested-by:
- Reviewed-by: Thomas Falcon <[email protected]>
- Reviewed-by: Zide Chen <[email protected]>
- Signed-off-by: Dapeng Mi <[email protected]> (author)
- Signed-off-by: Peter Zijlstra (Intel) <[email protected]> (perf maintainer)
- `Link: https://patch.msgid.link/20260717080342.1879573-3-
[email protected]`
- No Cc: stable (not a negative signal)
SHA on origin/master: 96746e731e1626545e343974ca4673739dceb31b (not an ancestor of HEAD).
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** On hybrid Intel PMU init failure (example:
check_hw_exists()), x86_pmu.hybrid_pmu is not freed and perf_is_hybrid stays enabled.
- **Symptom:** Memory leak plus leftover hybrid state after a failed init.
- **Root cause:** intel_pmu_init_hybrid() allocates hybrid_pmu and enables the static key; init_hw_perf_events() error paths memset(&x86_pmu, 0, ...) without freeing or disabling that key. The hybrid perf_pmu_register fail path kfree's too early and still leaves the static key set.
- **Version:** Hybrid PMUs exist since 2021; this tree has them.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. It is an explicit error-path leak/stale-state fix. The delayed kfree also removes a use-after-free on the hybrid register-fail path (see Phase 2/5).
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: arch/x86/events/core.c (+12 / −3)
- New helper: x86_pmu_free_hybrid()
- Modified: init_hw_perf_events() (hybrid register-fail block and out_bad_pmu)
- Scope: single-file surgical error-path fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Hunk 1:** Add x86_pmu_free_hybrid(): if hybrid_pmu is set, disable perf_is_hybrid, kfree the array, NULL it, set num_hybrid_pmus = 0.
- **Hunk 2 (before):** Hybrid perf_pmu_register failure kfree's the array, NULLs it, zeros the count, then goto out2 (cpuhp teardown, then memset).
- **Hunk 2 (after):** Only unregister already-registered PMUs and goto out2; free/reset happens later in out_bad_pmu.
- **Hunk 3:** out_bad_pmu calls x86_pmu_free_hybrid() **before** memset(&x86_pmu, 0, ...).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Error-path resource leak + UAF + stale static key**
Verified in this tree (init_hw_perf_events, intel_pmu_init_hybrid, intel_pmu_cpu_dead):
1. **Leak on early failure:** intel_pmu_init_hybrid() does kcalloc + static_branch_enable(&perf_is_hybrid). If check_hw_exists() then fails, 6.12 jumps to out_bad_pmu and only memsets x86_pmu, dropping the pointer without kfree. perf_is_hybrid stays enabled.
2. **UAF on hybrid register failure:** By the time perf_pmu_register runs, CPUHP_AP_PERF_X86_STARTING has already run intel_pmu_cpu_starting() → init_hybrid_pmu(), which sets cpuc->pmu into the hybrid_pmu array. Current 6.12 code kfrees that array **then** goto out2 → cpuhp_remove_state(CPUHP_PERF_X86_PREPARE) → x86_pmu_dead_cpu() → intel_pmu_cpu_dead():
```5209:5210:arch/x86/events/intel/core.c
if (is_hybrid() && cpuc->pmu)
cpumask_clear_cpu(cpu,
&hybrid_pmu(cpuc->pmu)->supported_cpus);
```is_hybrid() is still true and cpuc->pmu still points at freed memory. That is a use-after-free. Moving the free to after cpuhp teardown fixes it.
3. **Stale static key:** The old register-fail path never called static_branch_disable(&perf_is_hybrid).
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct and minimal. static_branch_disable + kfree
+ NULL during __init teardown is low risk. Free-after-cpuhp is the right order. No API change. Regression risk is low.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Hybrid register/kfree block: d9977c43bff89 (“perf/x86: Register hybrid PMUs”, 2021-04-19) — present in 6.12.
- intel_pmu_init_hybrid() alloc/static key: 97588df87b56e2 (Kan Liang, 2023-08-29) — present in 6.12.
- out_bad_pmu memset: 916e3a4f950eac (Paolo Bonzini, 2022) — present in 6.12.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Bug was introduced with hybrid PMU support (2021/2023), well before 6.12.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: This is v3 **2/8** of Dapeng Mi’s “Miscellaneous PMU bug fixes and optimizations”.
- Parent: 91787047b1dc5 “Unregister PMI handler on PMU init failure” (adds pmi_unregister:) — **not** in this tree.
- Next: 278a3731c9d08 “Guard intel_pmu_cpu_dead() against invalid hybrid PMU casts” — separate OOB/container_of bug; not required for this leak/UAF fix.
This patch is standalone: the helper only needs to run before memset at out_bad_pmu.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Dapeng Mi is an Intel perf contributor. Same series has several hybrid/error-path fixes. Applied by Peter Zijlstra.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Patch 1 is **not** a functional prerequisite. It only changes nearby labels (pmi_unregister, goto pmi_unregister instead of return err). x86_pmu_free_hybrid() can be added to 6.12’s existing out_bad_pmu. No new helpers or structs.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 96746e731e162 → https://patch.msgid.link/20260717080342.18
[email protected]
- Revisions: v1 (2026-07-10, 2/7), v2 (2026-07-13, 2/7), v3 (2026-07-17, 2/8). This hunk did not change across revisions.
- Cover letter: bugs found in review (Sashiko) of a later SIMD/eGPR sampling series, not from a production crash.
- Zide Chen: Reviewed-by for the whole series. Author called the series “low risky”. No NAKs found.
- Merged to tip perf/core 2026-08-12, then Linus.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers, Adrian Hunter, Alexander Shishkin, Andi Kleen, Stephane Eranian, linux-kernel, linux-perf-users, Zide Chen, Thomas Falcon. Maintainer applied it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla. Found by code review of hybrid init error paths.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone among 8 patches. Patch 1 (NMI unregister) and patch 3 (cpu_dead hybrid cast) are related but independent.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No stable-list discussion found for this subject. Not a reason to skip it.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: KEY FUNCTIONS**
Record: x86_pmu_free_hybrid() (new), init_hw_perf_events() (modified). Related existing: intel_pmu_init_hybrid(), intel_pmu_cpu_dead(), x86_pmu_dead_cpu().
**Step 5.2: TRACE CALLERS**
Record:
- init_hw_perf_events(): early_initcall, once at boot.
- x86_pmu_free_hybrid(): only out_bad_pmu.
- intel_pmu_cpu_dead(): x86_pmu.cpu_dead from x86_pmu_dead_cpu on CPUHP_PERF_X86_PREPARE teardown (init rollback and later CPU down).
- is_hybrid() used in get_possible_counter_mask(), is_x86_event(), allocate_fake_cpuc(), x86_pmu_event_init(), intel_pmu_cpu_starting(), intel_pmu_cpu_dead(), and hybrid() macros.
**Step 5.3: TRACE CALLEES**
Record: static_branch_disable(), kfree(). No locks, no I/O.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Boot-time hybrid Intel PMU init (Alder/Raptor/Meteor/Lunar/Arrow Lake in this tree). Triggered by check_hw_exists() failure (broken PMU, hypervisor without PMU) or perf_pmu_register() failure. Not a normal syscall path; it is a boot/error path. Register-fail UAF runs in cpuhp teardown while the array is already freed.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same series cleans other hybrid error paths (NMI leak, invalid hybrid_pmu() cast). 01c153956b443 (“Validate the return value of intel_pmu_init_hybrid()”) is a related NULL-deref fix and is **not** in this tree; not required here.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.**
- Tree: p-6.12-3-gc504cf0baa3d8, VERSION=6 PATCHLEVEL=12 SUBLEVEL=111
- git merge-base --is-ancestor 96746e731e162 HEAD → not an ancestor
- 6.12 init_hw_perf_events() still kfree's on register fail, then memsets at out_bad_pmu with no x86_pmu_free_hybrid() and no static_branch_disable
- intel_pmu_init_hybrid() still allocates and enables perf_is_hybrid
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Minor conflicts, easy backport.**
- git apply --check of the raw diff fails: x86_pmu_show_pmu_cap() log strings differ, and mainline has pmi_unregister: from patch 1.
- The real change is still: add the helper after x86_pmu_show_pmu_cap(), drop the three-line kfree in the register- fail block, call the helper just before memset at out_bad_pmu.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No x86_pmu_free_hybrid, no “Free hybrid state” commit. Register-fail still does the early kfree.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: **arch/x86/events (x86 perf PMU)** — **IMPORTANT**. Hybrid Intel CPUs are common (ADL/RPL/MTL/LNL/ARL). Not core mm/VFS, but production x86 hardware.
**Step 7.2: SUBSYSTEM ACTIVITY**
Record: Mature PMU core with ongoing hybrid work. Bug has been in hybrid support since it landed, not a last-month feature.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: WHO IS AFFECTED**
Record: Intel hybrid x86 systems where PMU init fails (VMs without a usable PMU, broken BIOS/MSRs, or perf_pmu_register failure). Not universal; config PERF_EVENTS + hybrid CPU models.
**Step 8.2: TRIGGER CONDITIONS**
Record:
- check_hw_exists() false after intel_pmu_init_hybrid() — leak + leftover perf_is_hybrid. Common-ish in hypervisors; uncommon on healthy bare metal.
- Hybrid perf_pmu_register failure after cpuhp STARTING — **UAF** in intel_pmu_cpu_dead(). Rare (ENOMEM/name clash) but a real error path.
Not unprivileged-syscall triggered.
**Step 8.3: FAILURE MODE SEVERITY**
Record:
- Register-fail + early kfree: **UAF** → crash/KASAN — **HIGH**
- Early check_hw_exists fail: small one-time leak of `num_hybrid_pmus
* sizeof(struct x86_hybrid_pmu) plus leftover is_hybrid() — **MEDIUM** (leak) / **MEDIUM-HIGH** if later hybrid() users run with a NULL/zeroed x86_pmu`
Overall: **HIGH** because of the UAF, not only the leak.
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- Benefit: closes UAF + leak + stale static key on hybrid init failure. High for those systems, zero for others.
- Risk: ~12 lines, __init error path only, no locking/API change. **Low**.
- Ratio: **favor backport**.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Buggy code is in this 6.12 tree (hybrid since 2021).
- Fixes a real leak (memset drops hybrid_pmu without kfree).
- Fixes a real UAF: kfree of hybrid_pmu before cpuhp_remove_state → intel_pmu_cpu_dead() → hybrid_pmu(cpuc->pmu).
- Also clears perf_is_hybrid, which the register-fail path never did.
- Small (12/−3), obviously correct, reviewed by Intel and applied by Peter Zijlstra.
- Standalone; patch 1 is only context.
AGAINST:
- No production/syzbot report; found in review.
- Register-fail UAF is a rare path.
- Raw mainline diff does not apply cleanly (log text + pmi_unregister).
- One-time init leak alone would be weak; the UAF is what makes it important.
UNRESOLVED:
- Could not fetch lore HTML (403); used b4 dig + Patchew instead. Reviews/NAKs still verified.
- Exact sizeof(struct x86_hybrid_pmu) not measured; leak is still a bounded boot-time allocation.
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — reviewed, tested (perf test on Diamond Rapids/Nova Lake), merged via tip.
2. Fixes a real bug that affects users? **PASS** — leak + UAF + stale hybrid key on hybrid init failure.
3. Important (crash/security/corruption/deadlock)? **PASS** — UAF on cpuhp rollback after hybrid register failure; leftover hybrid key after failed init.
4. Small and contained? **PASS** — one file, ~15 lines.
5. No new features or APIs? **PASS** — static helper on the existing error path.
6. Can apply to the local tree? **PASS** — needs a trivial backport (insert helper, drop 3 lines, call before memset); no missing APIs.
**Step 9.3: EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/docs exception. Ordinary error-path memory-safety fix.
**Step 9.4: DECISION**
This tree has the hybrid init bug. The patch is small, correct, and fixes UAF plus leak on failure. Context from later mainline (pmi_unregister) is not required. It should be backported to this 6.12 tree.
Verification:
- [Phase 1] Tags: Reviewed-by Falcon/Chen; SOB Zijlstra; Link msgid [email protected]; no Fixes/syzbot
- [Phase 1] SHA 96746e731e162 on origin/master; merge-base --is- ancestor vs HEAD = not present
- [Phase 2] Diff: +12/−3 in arch/x86/events/core.c; helper + delayed free + out_bad_pmu call
- [Phase 2] 6.12 init_hw_perf_events still early-kfrees at lines 2184–2186, then memset at 2200 with no static-key disable
- [Phase 2/5] intel_pmu_cpu_dead() uses hybrid_pmu(cpuc->pmu) when is_hybrid(); x86_pmu_dead_cpu is the PREPARE teardown
- [Phase 3] Hybrid register path blamed to d9977c43bff89 (2021); alloc/key to 97588df87b56e2 (2023)
- [Phase 3] Parent 91787047b1dc5 (NMI unregister) not in HEAD; not required
- [Phase 4] b4 dig -c 96746e731e162 matched v3 2/8; v1→v3 hunk unchanged; no NAK
- [Phase 4] Cover letter: review-found bugs; Zide Chen Reviewed-by for series
- [Phase 4] lore.kernel.org HTTP 403; Patchew used instead
- [Phase 5] intel_pmu_init_hybrid() enables perf_is_hybrid after kcalloc (this tree, ~6360)
- [Phase 6] git describe HEAD = p-6.12-3-gc504cf0baa3d8; make kernelversion = 6.12.111
- [Phase 6] git apply --check of raw commit fails on x86_pmu_show_pmu_cap context; logic still maps onto 6.12 out_bad_pmu
- [Phase 8] Failure mode: UAF in intel_pmu_cpu_dead after hybrid register fail; leak on check_hw_exists fail
- UNVERIFIED: live reproduction of perf_pmu_register failure; exact leaked byte count
The fix is small, matches this tree’s hybrid init code, and closes a real UAF/leak on PMU init failure.
**YES**
arch/x86/events/core.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
arch/x86/events/core.c +12 -3
@@ -2087,6 +2087,17 @@ void x86_pmu_show_pmu_cap(struct pmu *pmu)pr_info ("... global_ctrl mask: %016llx\n" ,hybrid (pmu, intel_ctrl)); } +static void x86_pmu_free_hybrid (void ) +{ +if (!x86_pmu.hybrid_pmu) +return ; + +static_branch_disable (&perf_is_hybrid); +kfree (x86_pmu.hybrid_pmu); + x86_pmu.hybrid_pmu =NULL ; + x86_pmu.num_hybrid_pmus =0 ; +} +static int __init init_hw_perf_events (void ) {struct x86_pmu_quirk *quirk;
@@ -2214,9 +2225,6 @@ static int __init init_hw_perf_events(void)for (j =0 ; j < i; j++)perf_pmu_unregister (&x86_pmu.hybrid_pmu[j].pmu);pr_warn ("Failed to register hybrid PMUs\n" ); -kfree (x86_pmu.hybrid_pmu); - x86_pmu.hybrid_pmu =NULL ; - x86_pmu.num_hybrid_pmus =0 ; goto out2; } }
@@ -2232,6 +2240,7 @@ static int __init init_hw_perf_events(void) pmi_unregister:unregister_nmi_handler (NMI_LOCAL ,"PMI" ); out_bad_pmu: +x86_pmu_free_hybrid ();memset (&x86_pmu,0 ,sizeof (x86_pmu));return err; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 drm/amdgpu: validate XCP topology counts before division
In reply to Sasha LevinFrom: Asad Kamal <[email protected]>
[ Upstream commit 0eda57ee303b4392057b7d4c32e8fda9d14cffad ]
In aqua_vanjaram_get_xcp_res_info(), max_res[i] can be zero. When res_lt_xcp is true the code divides num_xcp by max_res[i], causing a divide fault.
Skip the loop body for absent resources.
v2: Remove redundant checks (Lijo)
---
LLM Generated explanations, may be completely bogus:
This is a divide-by-zero oops in MI300 XCP sysfs init. The buggy loop is in this 6.18.y tree; the fix is a 3-line skip for a zero resource count.
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
- Subsystem: drm/amdgpu
- Action verb: validate (defensive correctness; body is an explicit divide-fault fix)
- Claimed intent: do not divide XCP topology counts when a resource count is zero
Record: [drm/amdgpu] [validate] [skip XCP resource loop when max_res[i]==0 to avoid divide-by-zero]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- No Fixes: tag (expected for this review pipeline)
- No Reported-by:, Tested-by:, Link:, or Cc: stable@
- Reviewed-by: Lijo Lazar <[email protected]> — original author of this function
- Reviewed-by: Hawking Zhang <[email protected]>
- Signed-off-by: Asad Kamal <[email protected]> (author)
- Signed-off-by: Alex Deucher <[email protected]> (amdgpu maintainer)
- Ignored pipeline tags: [Upstream commit 0eda57ee…], `Signed-off-by:
Sasha Levin`
Record: Author + two AMD reviewers + maintainer SOB. No syzbot/user report tag.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Bug: in aqua_vanjaram_get_xcp_res_info(), max_res[i] can be 0. When res_lt_xcp is true the code does num_xcp / max_res[i].
- Symptom: kernel divide fault (oops/exception).
- Fix: skip the loop body for absent resources.
- v2: Remove redundant checks (Lijo) — review-driven simplification.
Record: `[Bug: division by zero on zero resource counts] [Failure:
divide fault] [No version range stated] [Root cause: max_res[i]==0 with res_lt_xcp true]`
**Step 1.4: DETECT HIDDEN BUG FIXES**
Not hidden. The message names the divide fault and the skip.
Record: [Not a disguised cleanup; explicit divide-by-zero fix]
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
- File: drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c (+3/−1)
- Function: aqua_vanjaram_get_xcp_res_info()
- Scope: single-file, surgical
Record: [1 file, +3/-1, one function, surgical]
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Before (v6.18.53):
```
for each resource:
res_lt_xcp = max_res[i] < num_xcp;
set id;
num_inst = res_lt_xcp ? 1 : max_res[i] / num_xcp;
num_shared = res_lt_xcp ? num_xcp / max_res[i] : 1;
```
After:
```
for each resource:
set id;
if (!max_res[i]) continue; // leave num_inst/num_shared at 0
... same arithmetic ...
```The continue is on the per-resource fill path used at sysfs init and on partition-mode store.
Record: [zero count: divide -> skip and keep zeros]
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Category: logic / memory-safety adjacent (integer divide-by-zero).
max_res[] is = {} then filled from:
- XCC: NUM_XCC(adev->gfx.xcc_mask)
- DMA: adev->sdma.num_instances
- DEC: adev->vcn.num_vcn_inst
- JPEG: adev->jpeg.num_jpeg_inst
aqua_vanjaram_init_soc_config() sets VCN/JPEG counts from hweight32(inst_mask). Discovery starts vcn.inst_mask / jpeg.inst_mask at 0 and only sets bits when VCN IPs exist; harvest can clear those bits. If a count is 0 and num_xcp > 0 (SPX=1, DPX=2, TPX=3, QPX=4, CPX=XCC count), then res_lt_xcp is true and num_xcp / max_res[i] is a divide fault.
Record: [divide-by-zero] [absent VCN/JPEG/SDMA/XCC count vs non-zero partition count]
**Step 2.4: ASSESS THE FIX QUALITY**
Obviously correct: skip the division when the divisor is 0. xcp_cfg is kzalloc’d in amdgpu_xcp_cfg_sysfs_init(), so skipped entries keep num_inst/num_shared = 0, which matches “absent”. Sysfs still creates the dec/jpeg kobjects (id is still set); they report 0 instead of oopsing.
Regression risk is very low. No API/locking/refcount change. v2 dropped extra checks at Lijo’s request.
Record: [minimal, correct] [very low regression risk]
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
On v6.18.53, the loop is from f501057aff3357 (drm/amdgpu: Add callback get xcp resource info, Lijo Lazar, 2024-09-09). Present in v6.13; not in v6.12. Wrapper/NPS split later in 3aa37922c66a63 / e5ad71779df6f4; the divide itself is original.
Record: [f501057aff3357, first in v6.13; in this 6.18.y tree]
**Step 3.2: FOLLOW THE FIXES: TAG**
No Fixes: tag.
Record: [N/A — no Fixes tag; buggy commit identified by blame]
**Step 3.3: CHECK FILE HISTORY**
Recent v6.18.53 history on this file is XCP/NPS/partition work. No prior zero-divisor guard in this loop. Later autosel commit 9bd596d9e90da (Guard reads in pcie state readout) is unrelated.
Record: [standalone; no prerequisite series for this skip]
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Asad Kamal is an AMD amdgpu contributor. Lijo Lazar has 20 commits on this file in 6.18.y and wrote the function; his Reviewed-by is strong.
Record: [AMD author; reviewed by function author and amdgpu maintainer]
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Uses existing max_res[] loop only. Sibling mainline patch guard zero divisors in soc_v1_0 partition code is a different ASIC file; soc_v1_0 is **not** in this tree. This patch is self-contained.
Record: [no local dependencies; applies standalone]
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**b4 dig -c 0eda57ee… failed: lore.kernel.org returned an error.
Fallback: amd-gfx archives.
- v2 submission: https://lists.freedesktop.org/archives/amd-
gfx/2026-June/146963.html
- Hawking Reviewed-by: https://lists.freedesktop.org/archives/amd-
gfx/2026-June/146976.html
- May–July 2026 archives: only v2, no public v1 (v1 likely internal; message says Lijo asked to drop redundant checks)
- No NAK
Record: [amd-gfx v2 + Hawking RB; no NAK; v1 not on the public list]
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
v2 To/Cc: amd-gfx, Lijo Lazar, Hawking Zhang, Le Ma, Morris Zhang, Alex Deucher, Yang Wang. Right maintainers.
Record: [Lijo + Hawking reviewed; Deucher merged]
**Step 4.3: SEARCH FOR THE BUG REPORT**
No bugzilla/syzbot/Link. Hardware-path analysis by AMD, not a fuzzer ID.
Record: [no public crash dump; AMD-described divide fault]
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES** Standalone [PATCH v2], not n/N. Related only as the same round of divisor guards (soc_v1_0 not in 6.18.y).
Record: [standalone; soc_v1_0 sibling N/A here]
**Step 4.5: CHECK STABLE MAILING LIST HISTORY** lore.kernel.org/stable/?q=… returned 403. No evidence this was rejected for stable.
Record: [UNVERIFIED: stable list discussion (HTTP 403)]
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
Record: [aqua_vanjaram_get_xcp_res_info]
**Step 5.2: TRACE CALLERS**
Callback .get_xcp_res_info in aqua_vanjaram_xcp_funcs. Only call sites of amdgpu_xcp_get_res_info():
1. amdgpu_xcp_cfg_sysfs_init() — amdgpu_xcp_sysfs_init() ← amdgpu_device.c during device init
2. xcp_config_store() — sysfs xcp_config (__ATTR_RW_MODE(..., 0644)), typically CAP_SYS_ADMIN/root
Record: [GPU probe sysfs init + privileged sysfs store]
**Step 5.3: TRACE CALLEES** __aqua_vanjaram_get_px_mode_info() sets num_xcp to 1/2/3/4 or NUM_XCC. No alloc/lock in the changed loop.
Record: [fills xcp_cfg for sysfs; no new side effects]
**Step 5.4: FOLLOW THE CALL CHAIN**
Probe: discovery → aqua_vanjaram_init_soc_config() (GC 9.4.3 / 9.4.4 / 9.5.0) → later amdgpu_xcp_sysfs_init() → this function. Userspace can also write compute_partition_config/xcp_config.
Record: [reachable on MI300-class probe and partition sysfs; not a dead path]
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Only implementation of get_xcp_res_info in this tree. Mainline soc_v1_0 guard is a sibling, not present here.
Record: [no other local copy of this loop]
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Local tree: **v6.18.53** (VERSION=6 PATCHLEVEL=18 SUBLEVEL=53, git describe HEAD = v6.18.53-5049-g0f0bdc2b0dffb, branch autosel).
v6.18.53 aqua_vanjaram_get_xcp_res_info() still does num_xcp / max_res[i] with no zero check. Upstream 0eda57ee is **not** an ancestor of HEAD. Introducing commit f501057aff3357 **is** an ancestor of v6.18.53.
Record: [YES, buggy loop is in v6.18.53] [bug from v6.13 / f501057aff3357]
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
v6.18.53 loop matches the patch preimage exactly. Clean apply; no refactor in the way.
Record: [clean apply]
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE** No other zero-divisor fix for this loop in v6.18.53.
Record: [no substitute fix in this tree]
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: SUBSYSTEM AND CRITICALITY** drivers/gpu/drm/amd/amdgpu — AMD GPU driver, Aqua Vanjaram XCP (MI300/MI325/MI350-class, GC 9.4.3/9.4.4/9.5.0).
Record: [amdgpu XCP] [IMPORTANT — datacenter Instinct GPUs, not core mm/fs]
**Step 7.2: SUBSYSTEM ACTIVITY**
File is actively maintained (partition/NPS/XCP changes). The divide is old (6.13), not a last-week feature.
Record: [active driver; bug has been in-tree since v6.13]
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Users of amdgpu on Aqua Vanjaram ASICs (MI300A/X, MI325, GC 9.5.0) with XCP sysfs. Not universal.
Record: [driver-specific / platform-specific (MI300-class)]
**Step 8.2: TRIGGER CONDITIONS**
Always runs at XCP sysfs init if xcp_mgr exists. Faults when any max_res[i] is 0 — verified possible for VCN/JPEG via inst_mask==0 after discovery/harvest. Also on writing partition mode. Unprivileged users do not normally write that sysfs node (0400 resource attrs; store is 0644 on a root-owned kobject). Probe path does not need a user trigger.
Record: [probe + partition sysfs] [likely on harvested/no-VCN configs] [unprivileged write not required]
**Step 8.3: FAILURE MODE SEVERITY**
x86 #DE in kernel → oops. During device init this can fail GPU bring- up or panic if panic_on_oops. Not silent corruption.
Record: [kernel oops / GPU init crash] [CRITICAL/HIGH]
**Step 8.4: RISK-BENEFIT RATIO**
Benefit: stop a real divide oops on MI300-class XCP sysfs. Risk: 3 lines, skip-only, zeros already from kzalloc.
Record: [high benefit for affected GPUs] [very low risk] [favorable]
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real divide-by-zero; oops on XCP sysfs init / partition store
- Buggy code is in this v6.18.53 tree
- Counts can be 0 (VCN/JPEG inst_mask from discovery/harvest)
- 3-line skip; obviously correct; v2 reviewed by the function author and Hawking; merged by Deucher
- Clean apply; no new API; no series dependency
AGAINST:
- Affects only MI300-class XCP, not all machines
- No public reproducer/syzbot
- v1 mailing-list text not found
UNRESOLVED:
- Stable-list discussion (lore 403)
- Exact public v1 diff
- How often production MI300 SKUs have num_vcn_inst==0 (AMD still treated it as real)
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — skip on zero divisor; two AMD R-b, maintainer SOB
2. Real bug that affects users? **PASS** — divide fault in driver init/sysfs
3. Important (crash/security/corruption/deadlock)? **PASS** — kernel oops
4. Small and contained? **PASS** — +3/−1, one function
5. No new features or APIs? **PASS**
6. Can apply to local tree? **PASS** — v6.18.53 preimage matches
**Step 9.3: EXCEPTION CATEGORIES**
Not ID/quirk/DT/docs. Direct crash fix.
**Step 9.4: DECISION**
Backport. It is a small, obviously correct oops fix for code this tree actually runs.
### Why this matters for this tree
v6.18.y ships Aqua Vanjaram XCP resource sysfs. If VCN/JPEG/SDMA/XCC count is 0, num_xcp / max_res[i] oopses during amdgpu_xcp_cfg_sysfs_init() or a partition-mode store. Skipping empty resources stops the fault and reports 0 instances.
### Risk vs benefit
Benefit is avoiding a GPU-init oops on MI300-class systems. Risk is a continue that leaves kzalloc zeros. No locking or ABI change.
### Concerns
None material. soc_v1_0 sibling is not needed here. No follow-up on this loop in this tree.
Verification:
- [Phase 1] Tags: Reviewed-by Lijo Lazar, Hawking Zhang; SOB Alex Deucher; no Fixes/syzbot
- [Phase 2] Diff: +3/−1 in aqua_vanjaram_get_xcp_res_info(); if (!max_res[i]) continue before num_xcp / max_res[i]
- [Phase 3] git blame v6.18.53: loop from f501057aff3357 (in v6.13; not v6.12); git merge-base --is-ancestor f501057aff3357 v6.18.53 succeeded
- [Phase 3] No Fixes tag; no later related fix on this loop in v6.18.53
- [Phase 4] b4 dig -c 0eda57ee…: lore error; found v2 at lists.freedesktop.org/amd-gfx/2026-June/146963.html; Hawking RB 146976.html; no NAK
- [Phase 4] UNVERIFIED: stable@ thread (lore 403); public v1 body
- [Phase 5] Callers: amdgpu_xcp_cfg_sysfs_init (device init) and xcp_config_store (sysfs)
- [Phase 5] adev->vcn.inst_mask starts 0 in amdgpu_discovery.c; harvest can clear bits; aqua_vanjaram_init_soc_config sets num_vcn_inst = hweight32(inst_mask)
- [Phase 6] git describe HEAD: v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion: 6.18.53
- [Phase 6] v6.18.53 file has the unfixed loop (has skip? False); 0eda57ee is not an ancestor of HEAD
- [Phase 8] Failure mode: kernel divide fault / oops on XCP sysfs init, severity HIGH/CRITICAL
- UNVERIFIED: frequency of zero VCN/JPEG on shipping MI300 SKUs (does not override the verified divide path)
**YES**
drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c +3 -1
@@ -295,8 +295,10 @@ static int aqua_vanjaram_get_xcp_res_info(struct amdgpu_xcp_mgr *xcp_mgr, xcp_cfg->num_res =ARRAY_SIZE (max_res);for (i =0 ; i < xcp_cfg->num_res; i++) { - res_lt_xcp = max_res[i] < num_xcp; xcp_cfg->xcp_res[i].id = i; +if (!max_res[i]) +continue ; + res_lt_xcp = max_res[i] < num_xcp; xcp_cfg->xcp_res[i].num_inst = res_lt_xcp ?1 : max_res[i] / num_xcp; xcp_cfg->xcp_res[i].num_inst =
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/realtek: Add quirk for Lenovo IdeaPad Slim 3 15ABR8
In reply to Sasha LevinFrom: Zhang Heng <[email protected]>
[ Upstream commit be79a45e2ec289eb9fad519e8f5a3d4fc3789dd0 ]
The internal microphone on Lenovo IdeaPad Slim 3 15ABR8 (subsystem 17aa:3862) exhibits severe distortion at default gain levels. The Capture Volume is fixed at 63 (max) and cannot be lowered without explicit userspace intervention. The existing fixup ALC269_FIXUP_LIMIT_INT_MIC_BOOST limits the gain range and resolves the issue.
---
LLM Generated explanations, may be completely bogus:
This is a one-line Realtek HDA hardware quirk for a specific Lenovo laptop. The local tree is **6.12.111** (pending-6.12). The Realtek quirk table and ALC269_FIXUP_LIMIT_INT_MIC_BOOST already exist here; SSID 17aa:3862 does not.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
- Record: **[ALSA/hda/realtek] [Add] [quirk for Lenovo IdeaPad Slim 3 15ABR8]**
- Subsystem prefix: ALSA: hda/realtek
- Action verb: **Add** (hardware quirk table entry, not a new feature)
- Claimed intent: map PCI subsystem 17aa:3862 to an existing internal- mic boost limit fixup
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Record:
- Closes: https://bugzilla.kernel.org/show_bug.cgi?id=221891 — user- filed kernel.org bug
- Signed-off-by: Zhang Heng <[email protected]> — author
- `Link: https://patch.msgid.link/20260824123752.525173-1-
[email protected]` — original submission msgid
- Signed-off-by: Takashi Iwai <[email protected]> — ALSA HDA maintainer applied it
- No Fixes:, no Cc: stable, no Reported-by, no Tested-by, no Reviewed-by (absence of Fixes:/Cc: stable is expected for this review)
- Notable: maintainer SOB plus a Closes: bugzilla link
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Record:
- **Bug:** Internal mic on IdeaPad Slim 3 15ABR8 (17aa:3862) has severe distortion at default gain
- **Symptom:** Capture Volume stuck at 63 (max); cannot be lowered without explicit userspace intervention; captured audio is badly distorted
- **Root cause (author):** default amp/boost range is too high for this hardware
- **Fix:** reuse existing ALC269_FIXUP_LIMIT_INT_MIC_BOOST
- **Version info:** none in the message; laptop is a 2023 AMD IdeaPad, so 6.12 users are in the affected population
**Step 1.4: DETECT HIDDEN BUG FIXES**
- Record: Not a hidden fix. It is an explicit hardware quirk. The “Add” verb is the standard form for SND_PCI_QUIRK table entries that make existing hardware usable.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
- Record:
- File in the commit: sound/hda/codecs/realtek/alc269.c (**+1 /
−0**)
- Function/table: alc269_fixup_tbl[]
- Scope: **single-file surgical** — one SND_PCI_QUIRK line
- Local tree equivalent file: sound/pci/hda/patch_realtek.c (HDA codecs were not yet split out of sound/pci/hda/ in 6.12)
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
- Record: **Before** — SSID 17aa:3862 matches no quirk; probe uses generic auto-config; internal mic boost stays at the default wide range, Capture Volume sits at max, audio is distorted. **After** — snd_hda_pick_fixup() matches ALC269_FIXUP_LIMIT_INT_MIC_BOOST. At HDA_FIXUP_ACT_PROBE, alc269_fixup_limit_int_mic_boost() walks auto-config inputs, and for internal mic pins overrides amp caps to 0 offset, 1 step, step size 0x2f (boost limited to 0 or 1). Only the probe path for this SSID is affected.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
- Record: **[Hardware workaround / audio codec quirk]**
- Mechanism: Realtek codec exposes boost steps 2 and 3 that are too noisy on this chassis. The existing helper comments: “The mic boosts on level 2 and 3 are too noisy on the internal mic input. Therefore limit the boost to 0 or 1.”
- The new line only *selects* that already-present helper for one PCI subsystem ID.
**Step 2.4: ASSESS THE FIX QUALITY**
- Record: Obviously correct and minimal. Same pattern already used for ThinkPad T480, Positivo ARN50/N14AP7, several Asus/VAIO machines, etc.
- Regression risk: **very low**. Match is vendor+device SSID 17aa:3862 only. ALC269_FIXUP_LIMIT_INT_MIC_BOOST also chains to ALC269_FIXUP_THINKPAD_ACPI, but hda_fixup_thinkpad_acpi() returns immediately unless ACPI IDs LEN0068/LEN0268/IBM0068 exist, so LED binding does not run on an IdeaPad. alc_fixup_no_shutup() still runs (reduces click noise); that same chain is already used by other non-ThinkPad LIMIT_INT_MIC_BOOST quirks in this tree.
- No public API, no new fixup enum, no new module parameter.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
- Record: There is no “buggy line” in the table; the bug is a **missing** entry. Neighboring rows in this tree:
- 0x3855 Legion 7 16ITHG6 — 1e24881d8b2a7c (2022)
- 0x3865 Lenovo 13X — 25f46354dca912 (2024)
- Insertion sits in a long-stable Lenovo SSID block. The helper alc269_fixup_limit_int_mic_boost() was introduced in 3e0d611b2045b (2013-04-22, “Limit internal mic boost for a few Asus machines”) and has been in-tree for years.
**Step 3.2: FOLLOW THE FIXES: TAG**
- Record: No Fixes: tag. Not applicable. The “bug” is hardware that never had a quirk, not a regression from a prior commit.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
- Record: Recent patch_realtek.c history is almost entirely other SND_PCI_QUIRK additions (HP mute LED, Legion, Yoga, etc.). Same- fixup examples already in this 6.12 tree:
- 85981dfd6b0a0 Limit mic boost on T480 (Cc: stable)
- 86a433862912f Limit mic boost on N14AP7 (Cc: stable)
- d44418f5024f6 Limit mic boost on Positivo ARN50 (already
backported here as `[ Upstream commit 76b0a22d4cf7... ]`)
- Standalone. Not patch X/Y.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
- Record: Zhang Heng has other sound quirks in this tree (ASUS UM6702RC, Inspur S14-G1, Samsung 750XBE, AMD YC DMI quirks). Regular hardware- quirk contributor, not the subsystem maintainer. Maintainer Takashi Iwai applied it.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
- Record: None. Depends only on SND_PCI_QUIRK, ALC269_FIXUP_LIMIT_INT_MIC_BOOST, and alc269_fixup_tbl[], all present in 6.12. Can apply standalone with a path remap (alc269.c → patch_realtek.c).
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
- Record: b4 dig -c could not be used: this SHA is not in the local tree. Recovered via msgid [email protected].
- Submission: https://lists.openwall.net/linux-kernel/2026/08/24/1126
(also lkml.iu.edu/2608.3/00949.html) - Single-patch v1 only; diff is the same one-line quirk as committed - To: `[email protected]`; Cc: `linux-sound`, `linux-kernel` - Maintainer reply (Takashi Iwai, 2026-08-25): **“Applied now. Thanks.”** (lkml.iu.edu/2608.3/02564.html)
- No NAK, no requested respin, no stable discussion in the thread
- Lore.kernel.org itself returned Anubis/403 to automated fetch
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
- Record: Sent directly to Takashi Iwai (ALSA HDA maintainer) and linux- sound. Maintainer applied v1 as-is. No other reviewer comments found.
**Step 4.3: SEARCH FOR THE BUG REPORT**
- Record: Bugzilla 221891 was 403/Anubis; full comments **UNVERIFIED**. The Closes: tag plus the commit body (SSID, Capture Volume 63, distortion) are the verified description.
- Related real-world report: Ask Ubuntu “Audio issues on Lenovo Ideapad Slim 3 **16ABR8** — microphone distortion” (sibling ABR8 chassis, same symptom class). That report is 16ABR8, not 15ABR8/17aa:3862, so it does **not** prove this SSID, only that the product family has this class of mic problem.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
- Record: Standalone 1/1. No series. No extra Realtek patches required.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
- Record: lore.kernel.org/stable search blocked (Anubis). No evidence in this tree that this SSID was already requested or rejected. Identical LIMIT_INT_MIC_BOOST quirks have been accepted into this 6.12 tree before.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
- Record: No function body changed. New table entry in alc269_fixup_tbl[]. Runtime functions involved:
snd_hda_pick_fixup() → alc269_fixup_limit_int_mic_boost() (and chained alc_fixup_thinkpad_acpi()).
**Step 5.2: TRACE CALLERS**
- Record: alc269_fixup_tbl is passed from the ALC269-family probe path:
```12583:12584:sound/pci/hda/patch_realtek.c
snd_hda_pick_fixup(codec, alc269_fixup_models,
alc269_fixup_tbl, alc269_fixups);
```That runs during codec probe (device enumeration / module load), not a syscall hot path. Reachable on every boot for machines with a Realtek ALC269-family HDA codec.
**Step 5.3: TRACE CALLEES**
- Record: alc269_fixup_limit_int_mic_boost() uses snd_hda_codec_get_pincfg(), snd_hda_get_input_pin_attr(), snd_hda_override_amp_caps(). Probe-time mixer cap override only; no allocation, no new locks.
**Step 5.4: FOLLOW THE CALL CHAIN**
- Record: Userspace does not need a special trigger. Opening the capture device at default volume is enough. Unprivileged users of this laptop hit it (PulseAudio/PipeWire default capture). High user visibility, hardware-specific.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
- Record: Many SND_PCI_QUIRK(..., ALC269_FIXUP_LIMIT_INT_MIC_BOOST) entries already in this file (ThinkPads 0x2215/0x225d/0x5013/0x5026/0x5109, Asus 0x106d/0x115d/0x1c23, Positivo, VAIO). This is a systematic, well-worn workaround, not a one-off invention.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
- Record: **Yes, as a missing quirk.** Local tree:
p-6.12-3-gc504cf0baa3d8, VERSION=6 PATCHLEVEL=12 SUBLEVEL=111.
- sound/hda/codecs/realtek/ does **not** exist (split is post-6.12).
- sound/pci/hda/patch_realtek.c **does** exist; alc269_fixup_tbl[]
at line 10675; LIMIT_INT_MIC_BOOST at 8711–8716 and function at
6661–6691.
- `git grep 0x3862 -- sound/pci/hda/` : **no match**. Between 0x3855
and 0x3865 there is a hole exactly where the new line goes (lines
11565–11566).
- Bug “introduced”: never fixed here; hardware existed well before
v6.12 (released 2024-11-17).**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
- Record: **Minor path remap, otherwise clean.** Neighboring context in this tree is identical to the mainline hunk (0x3855 Legion then 0x3865 Lenovo 13X). Need to apply to sound/pci/hda/patch_realtek.c instead of sound/hda/codecs/realtek/alc269.c. No conflicting SSID, no missing helper.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
- Record: No IdeaPad Slim 3 15ABR8 and no 17aa:3862 in sound/pci/hda/. Sibling IdeaPad Slim 9i 14ITL5 is a different SSID/fixup. No earlier version of this fix.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
- Record: **[sound/pci/hda Realtek codec] [IMPORTANT]** — not core mm/vfs, but the default laptop audio stack. CONFIG_SND_HDA_CODEC_REALTEK is a standard distro config. Criticality is hardware-specific, not peripheral/staging.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
- Record: Very active: recent history is a stream of model quirks. Mature table, mature helper (2013). Quirk additions are the normal stable-friendly change in this file.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
- Record: **driver-specific / hardware-specific** — only PCI SSID 17aa:3862 (Lenovo IdeaPad Slim 3 15ABR8). Everyone else unchanged.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
- Record: Trigger is default capture on this laptop (every VoIP/recording session). Common for owners of this model. Unprivileged users can trigger it. Not a race.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
- Record: **[Internal mic unusable / severe distortion] [MEDIUM functionally; HIGH for that hardware]**
- Not panic, UAF, or data corruption
- Internal microphone is effectively broken at default settings; userspace volume workarounds are the only current escape
- This is the documented audio-codec quirk class, routinely taken into stable
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
- Record:
- **Benefit:** High for 15ABR8 owners on 6.12; mic works without mixer hacks
- **Risk:** Very low — 1 line, SSID-gated, helper used for a decade, same pattern already backported here
- **Ratio:** strongly in favor of backport
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real hardware bug with a kernel.org bugzilla Closes: (221891)
- Severe mic distortion; capture stuck at max gain
- Classic SND_PCI_QUIRK exception (explicitly stable-appropriate)
- 1 line, existing fixup from 2013
- Helper and table present in 6.12; SSID absent
- Maintainer (Takashi Iwai) applied v1 with no objections
- Identical LIMIT_INT_MIC_BOOST quirks already in this 6.12 tree (T480, N14AP7, Positivo ARN50)
AGAINST:
- Not a crash/security/deadlock (strict reading of “important issue”)
- Mainline path differs (alc269.c vs patch_realtek.c) — trivial remap
- Full bugzilla text could not be fetched (403)
- b4 dig could not run without a local SHA
UNRESOLVED:
- Full bugzilla 221891 comments
- Whether any other chassis silently shares SSID 17aa:3862 (no in-tree collision)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — one SSID line to a long-used helper; maintainer applied; same pattern proven in this tree
2. Fixes a real bug that affects users? **PASS** — unusable/distorted internal mic; bugzilla + concrete SSID
3. Important issue? **PASS via hardware-quirk exception** — not a kernel oops, but a device-breaking audio defect of the class stable already takes (SND_PCI_QUIRK in patch_realtek.c)
4. Small and contained? **PASS** — +1 line
5. No new features or APIs? **PASS** — table entry only
6. Can apply to the local tree? **PASS** — remap path to sound/pci/hda/patch_realtek.c; context around 0x3855/0x3865 matches
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
- Record: **AUDIO CODEC QUIRK / hardware workaround** — SND_PCI_QUIRK in the Realtek HDA table. This is an automatic YES category.
**Step 9.4: MAKE YOUR DECISION**
Backport. The bug exists on 6.12 for this laptop, the fix is the standard one-line quirk, and the only adjustment is the post-6.12 filename change.
------------------------------------------------
What the commit solves and why it matters here
------------------------------------------------
On IdeaPad Slim 3 15ABR8 the Realtek internal mic boost range is too high, so Capture Volume sits at 63 and recordings are badly distorted. 6.12 already has alc269_fixup_limit_int_mic_boost(); it just never binds it to 17aa:3862. Adding that binding restores usable capture for that model without touching any other machine.
Risk vs benefit: one SSID-gated line vs a broken laptop microphone. Benefit dominates. Backport applies to patch_realtek.c between the existing 0x3855 and 0x3865 rows.
------------------------------------------------
Verification
------------------------------------------------
- [Phase 1] Parsed tags: Closes: bugzilla 221891, msgid link, SOB Zhang Heng + Takashi Iwai; no Fixes/Cc-stable
- [Phase 2] Diff: +1 SND_PCI_QUIRK(0x17aa, 0x3862, ..., ALC269_FIXUP_LIMIT_INT_MIC_BOOST) in alc269_fixup_tbl
- [Phase 2] Read alc269_fixup_limit_int_mic_boost() at patch_realtek.c:6661-6691 — probe-time amp-cap override for internal mic pins
- [Phase 2] Read ALC269_FIXUP_LIMIT_INT_MIC_BOOST at 8711-8716 — chains to THINKPAD_ACPI
- [Phase 2] Read hda_fixup_thinkpad_acpi() / is_thinkpad() in thinkpad_helper.c — LED path skipped without ThinkPad ACPI IDs
- [Phase 3] git log -S ALC269_FIXUP_LIMIT_INT_MIC_BOOST -- sound/pci/hda/patch_realtek.c: introduced 3e0d611b2045b (2013)
- [Phase 3] Similar quirks already in this tree: T480 85981dfd6b0a0, N14AP7 86a433862912f, Positivo ARN50 d44418f5024f6
- [Phase 3] git log --grep='IdeaPad Slim 3 15ABR8' -- sound/pci/hda/:
empty
- [Phase 4] Openwall + IU LKML: v1 patch identical to commit; Takashi “Applied now. Thanks.”
- [Phase 4] lore.kernel.org and bugzilla HTML/REST: 403 Anubis — full bugzilla body UNVERIFIED
- [Phase 4] b4 dig -c: not run; commit SHA not in this checkout
- [Phase 5] Caller: snd_hda_pick_fixup(..., alc269_fixup_tbl, ...) at probe (patch_realtek.c:12583)
- [Phase 6] git describe HEAD → p-6.12-3-gc504cf0baa3d8; make kernelversion → 6.12.111
- [Phase 6] sound/hda/codecs/realtek missing; sound/pci/hda/patch_realtek.c present
- [Phase 6] git grep 0x3862 -- sound/pci/hda/: no hits; hole between 0x3855 and 0x3865 at lines 11565-11566
- [Phase 8] Failure mode: distorted/unusable internal mic, SSID- specific; severity medium globally, high for that laptop
- UNVERIFIED: full text of bugzilla 221891; whether any other product silently uses SSID 17aa:3862
**YES**
sound/hda/codecs/realtek/alc269.c | 1 + 1 file changed, 1 insertion(+)
sound/hda/codecs/realtek/alc269.c +1 -0
@@ -7515,6 +7515,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x3852 ,"Lenovo Yoga 7 14ITL5" ,ALC287_FIXUP_YOGA7_14ITL_SPEAKERS ),SND_PCI_QUIRK (0x17aa ,0x3853 ,"Lenovo Yoga 7 15ITL5" ,ALC287_FIXUP_YOGA7_14ITL_SPEAKERS ),SND_PCI_QUIRK (0x17aa ,0x3855 ,"Legion 7 16ITHG6" ,ALC287_FIXUP_LEGION_16ITHG6 ), +SND_PCI_QUIRK (0x17aa ,0x3862 ,"Lenovo IdeaPad Slim 3 15ABR8" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST ),SND_PCI_QUIRK (0x17aa ,0x3865 ,"Lenovo 13X" ,ALC287_FIXUP_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x17aa ,0x3866 ,"Lenovo 13X" ,ALC287_FIXUP_CS35L41_I2C_2 ), SND_PCI_QUIRK(0x17aa, 0x3869, "Lenovo Yoga7 14IAL7", ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 i2c: qup: Propagate clock enable failures
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit a477626332800942f463d76aa48db0c47f1dfd18 ]
The QUP I2C driver treats the core and iface clocks as required resources, but qup_i2c_enable_clocks() ignores clk_prepare_enable() failures. Probe can then continue to register the I2C adapter, and runtime/system resume can return success, even when a required clock transition failed.
Make the helper return an error, unwind a partially enabled clock, and propagate failures from probe and resume paths.
---
LLM Generated explanations, may be completely bogus:
The local checkout is **v7.3-rc4**. The driver and the ignored-clock- enable bug exist in this lineage (since v3.15); the fix is a small, self-contained error-path change that belongs in this tree.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[i2c: qup]** **[Propagate]** — make clk_prepare_enable() failures visible instead of swallowing them.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** Konrad Dybcio (Qualcomm / linux-arm-msm)
- **Acked-by:** none
- **Link:**
https://lore.kernel.org/r/[email protected]
- **Cc: stable:** none (expected)
- **Signed-off-by:** Pengpeng Hou (author); Andi Shyti (I2C maintainer)
- No syzbot / kernel test robot tags
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** qup_i2c_enable_clocks() treats core and iface clocks as required, but ignores clk_prepare_enable() return values.
- **Symptoms:** probe still registers the I2C adapter; runtime/system resume still return success after a required clock failed.
- **Version info:** none in the message. Git shows the ignore-return pattern since the driver was added.
- **Root cause:** void helper with unchecked clock enables; callers cannot fail.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. It is an explicit error-path fix: check returns, unwind a half-enabled clock, propagate from probe and resume.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** drivers/i2c/busses/i2c-qup.c — **+24 / −7** (31 lines)
- **Functions:** qup_i2c_enable_clocks, qup_i2c_probe, qup_i2c_pm_resume_runtime, qup_i2c_resume
- **Scope:** single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
1. **Helper:** void, two unchecked clk_prepare_enable() → int, abort on first failure, disable core clk if iface enable fails.
2. **Probe (DT path only):** ignore enable → ret = …; if (ret) goto fail_dma. ACPI path still skips this helper.
3. **Runtime resume:** always return 0 → return the helper’s error.
4. **System resume:** always pm_request_autosuspend() after resume → skip autosuspend request if clocks failed.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Error-path / ignored-return + resource leak.**
- Broken: required clocks can fail; driver still MMIO-resets the QUP (writel to QUP_SW_RESET immediately after enable in probe) and later runs I2C with clocks off; iface-fail leaves core clk enabled.
- Fix: fail probe/resume, unwind partial enable.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct and matches other I2C host drivers. goto fail_dma is the right label: fail: would call qup_i2c_disable_clocks() and MMIO/unprepare clocks that were never (or no longer) enabled. Regression risk is low: a real clock failure now fails probe/resume instead of continuing on dead hardware.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record: Ignored enables introduced in **10c5a8425968** (“i2c: qup: New bus driver…”, Bjorn Andersson, 2014). First contained in **v3.15-rc1**. git log -L :qup_i2c_enable_clocks: shows only that commit and this fix.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Original driver commit is an ancestor of HEAD.
**Step 3.3: CHECK FILE HISTORY**
Record: Recent related work is unrelated (pm_runtime_mark_last_busy, timeout loop, interconnect vote). Older related fix **3cf357dfb40b** already routed some probe errors to fail so clocks get released — this patch fills the missing enable-check. Standalone, not X/Y.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Pengpeng Hou has only this commit under drivers/i2c/. Reviewer is a Qualcomm platform maintainer; committer is the I2C maintainer.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: No new APIs or structs. Applies standalone on this tree. No follow-ups on i2c-qup.c after a477626332800.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **b4 dig:**
https://patch.msgid.link/[email protected]
- **Revisions:** v1 only (no v2/v3)
- **Review:** Konrad Dybcio Reviewed-by the same day; Andi Shyti merged to i2c/i2c (~2026-07-28). No NAK, no stable nomination in- thread.
- lore.kernel.org fetch returned 403; thread confirmed via gnuweeb, patchew, and openwall mirrors.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To Andi Shyti; Cc linux-arm-msm, linux-i2c, linux- kernel. Konrad was not in the original To/Cc but reviewed from linux- arm-msm.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No bugzilla/syzbot/user report. Issue is from code review of ignored returns.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Single standalone patch, not a series.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No discussion of this subject on stable@ found (lore.kernel.org/stable 403; web search did not hit this patch).
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
Record: qup_i2c_enable_clocks, qup_i2c_probe, qup_i2c_pm_resume_runtime, qup_i2c_resume. (semcode MCP not available.)
**Step 5.2: TRACE CALLERS**
Record: Only three call sites in this file:
- qup_i2c_probe (DT/clk path, boot / module load)
- qup_i2c_pm_resume_runtime (runtime PM; also used as RUNTIME_PM_OPS resume)
- qup_i2c_resume → that runtime helper (system sleep)
Not interrupt context. Reachable on every QUP I2C device probe and every resume.
**Step 5.3: TRACE CALLEES**
Record: clk_prepare_enable / clk_disable_unprepare only. Probe then clk_get_rate and writel(QUP_SW_RESET).
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Platform probe / PM resume. Userspace does not call this directly, but every Qualcomm QUP I2C bus (touch, sensors, PMICs, cameras on many phones and boards) goes through it. Unclocked MMIO after a failed enable is a hang path.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Most I2C hosts already check clk_prepare_enable (i2c-designware-common.c, i2c-exynos5.c, i2c-img-scb.c, etc.). A few still ignore it (i2c-mv64xxx.c, i2c-hix5hd2.c). This brings QUP in line with the common pattern.
---
## 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** (7.3.0-rc4, f0100363d8c37). Introducer 10c5a8425968 and fix a477626332800 are both ancestors of HEAD. Pre-fix helper in the parent of the fix is still the 2014 void ignore-return version. Driver: drivers/i2c/busses/i2c-qup.c.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply on this tree (same file, same functions). No extra prerequisites.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No alternate fix for ignored enable. 3cf357dfb40b only fixes a later probe unwind, not enable checking. No post-fix regressions on this file.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: **I2C host driver** (drivers/i2c/busses/i2c-qup.c), CONFIG_I2C_QUP (ARCH_QCOM || COMPILE_TEST). **IMPORTANT** for Qualcomm platforms (common on phones, boards, IoT); not core mm/VFS.
**Step 7.2: SUBSYSTEM ACTIVITY**
Record: Mature driver (2014), still getting occasional correctness fixes. Not a new subsystem.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Record: Qualcomm SoC users with QUP I2C (qcom,i2c-qup-v1.1.1 / v2.1.1 / v2.2.1). Driver- and config-specific, but a large device population.
**Step 8.2: TRIGGER CONDITIONS**
Record: clk_prepare_enable() failure on core or iface (probe, runtime resume, or system resume). Unprivileged users cannot poke the helper, but resume is a normal path. Failures are uncommon on healthy clocks; they do happen with power-domain / RPM / -ENOMEM issues. No public reproducer.
**Step 8.3: FAILURE MODE SEVERITY**
Record: Continuing after a failed enable then writel/readl on the QUP can hang the interconnect; resume success with clocks off breaks later transfers; iface-fail leaks a prepared core clk. **HIGH** when it triggers (hang / stuck I2C), **MEDIUM** overall because triggers are rare. Not a demonstrated CVE.
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit:** avoid unclocked MMIO and false-success resume on QUP I2C.
- **Risk:** very low (~24 insertions, error paths only, standard clk unwind).
- **Ratio:** favorable.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: EVIDENCE**
**For:**
- Real ignored-error bug on required clocks.
- Probe immediately MMIO-resets the block; clocks-off access can hang.
- Resume used to report success with clocks still off.
- Partial enable leaked the core clock.
- 24 insertions in one file; obviously correct; no new API.
- Reviewed by Konrad Dybcio, merged by Andi Shyti.
- Bug present since v3.15; no extra dependencies.
- Matches the usual I2C host-driver pattern.
**Against:**
- No user/syzbot report in ~12 years.
- Clock enable rarely fails on working hardware.
- No in-thread Cc: stable.
**Unresolved:** Direct lore.kernel.org/stable search 403; no evidence this was rejected for stable.
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — standard clk check/unwind; maintainer review/merge. No extra Tested-by.
2. Fixes a real bug that affects users? **PASS** — ignored required- clock failure on probe/resume.
3. Important issue? **PASS** — hang / dead I2C / clock leak on that path, not a style cleanup.
4. Small and contained? **PASS** — +24/−7, one file.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — driver and call sites match.
**Step 9.3: EXCEPTION CATEGORIES**
Record: None (not a device ID, quirk, DT, build, or doc fix). Qualifies as a normal error-path bugfix.
**Step 9.4: DECISION**
This is a small, correct fix for ignored required-clock errors. On this v7.3-rc4 tree the buggy helper and the QUP probe/resume paths are present; the change prevents probe/resume from continuing into unclocked MMIO. That is enough for stable, even without a field report.
---
### What it solves for this tree
qup_i2c_enable_clocks() used to ignore clk_prepare_enable(). Probe still registered the adapter and then writel’d QUP_SW_RESET; resume returned 0. If enable actually failed, that is unclocked MMIO (possible SoC hang) plus a clock leak when only the iface clock failed. The patch fails those paths and unwinds.
### Stable rules / risk
Meets the rules: real bug, small, no features, applies here. Benefit is avoiding hangs and false-success PM on Qualcomm QUP I2C; risk is low.
### Concerns
No Fixes: / user report (not a reason to reject). fail_dma on enable failure is correct. No follow-up fix found.
---
### Verification
- **[Phase 1]** Tags: Reviewed-by Konrad Dybcio; SOB Andi Shyti; Link lore msgid 20260624055237.29977-1; no Fixes/Reported-by/Cc:stable.
- **[Phase 2]** Diff: +24/−7 in i2c-qup.c; helper becomes int; probe/resume propagate; partial unwind on iface fail.
- **[Phase 2]** Pre-fix parent: void helper, probe qup_i2c_enable_clocks(qup) then writel(QUP_SW_RESET); resume always 0.
- **[Phase 2]** Post-fix probe uses goto fail_dma (not fail), so qup_i2c_disable_clocks() is not run on a failed enable.
- **[Phase 3]** git log -L :qup_i2c_enable_clocks: → 10c5a8425968 (v3.15-rc1) then a477626332800.
- **[Phase 3]** git merge-base --is-ancestor both SHAs vs HEAD: both in this tree.
- **[Phase 3]** Author: only this I2C commit; no later commits on this file after the fix.
- **[Phase 4]** b4 dig -c a477626332800: matched msgid; -a: v1 only; -w: Andi + linux-i2c/arm-msm.
- **[Phase 4]** Review: Konrad Reviewed-by; Andi “merged to i2c/i2c”; no NAK.
- **[Phase 4]** lore.kernel.org 403; gnuweeb/patchew/openwall used instead. Stable-list search: no hits for this subject.
- **[Phase 5]** Callers: probe, runtime resume, system resume only. Other I2C hosts already check clk_prepare_enable.
- **[Phase 6]** git describe HEAD → v7.3-rc4-27-gf0100363d8c37; make kernelversion → 7.3.0-rc4. Buggy code existed; driver present.
- **[Phase 7]** CONFIG_I2C_QUP depends on ARCH_QCOM; I2C maintainer Andi Shyti.
- **[Phase 8]** Failure mode: unclocked MMIO / false resume success; severity HIGH if triggered, uncommon trigger.
- **UNVERIFIED:** Could not fetch lore.kernel.org HTML directly (403). Thread content verified via b4 + mirrors.
**YES**
drivers/i2c/busses/i2c-qup.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-qup.c +24 -7
@@ -1657,10 +1657,21 @@ static const struct i2c_adapter_quirks qup_i2c_quirks_v2 = { .flags = I2C_AQ_NO_ZERO_LEN, }; -static void qup_i2c_enable_clocks (struct qup_i2c_dev *qup) +static int qup_i2c_enable_clocks (struct qup_i2c_dev *qup) { -clk_prepare_enable (qup->clk); -clk_prepare_enable (qup->pclk); +int ret; + + ret =clk_prepare_enable (qup->clk); +if (ret) +return ret; + + ret =clk_prepare_enable (qup->pclk); +if (ret) { +clk_disable_unprepare (qup->clk); +return ret; + } + +return 0 ; }static void qup_i2c_disable_clocks (struct qup_i2c_dev *qup)
@@ -1823,7 +1834,9 @@ static int qup_i2c_probe(struct platform_device *pdev) ret =PTR_ERR (qup->pclk); goto fail_dma; } -qup_i2c_enable_clocks (qup); + ret =qup_i2c_enable_clocks (qup); +if (ret) + goto fail_dma; src_clk_freq =clk_get_rate (qup->clk); } qup->src_clk_freq = src_clk_freq;
@@ -1975,8 +1988,7 @@ static int qup_i2c_pm_resume_runtime(struct device *device)struct qup_i2c_dev *qup =dev_get_drvdata (device);dev_dbg (device,"pm_runtime: resuming...\n" ); -qup_i2c_enable_clocks (qup); -return 0 ; +return qup_i2c_enable_clocks (qup); }static int qup_i2c_suspend (struct device *device)
@@ -1988,7 +2000,12 @@ static int qup_i2c_suspend(struct device *device)static int qup_i2c_resume (struct device *device) { -qup_i2c_pm_resume_runtime (device); +int ret; + + ret =qup_i2c_pm_resume_runtime (device); +if (ret) +return ret; +pm_request_autosuspend (device);return 0 ; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 sched_ext/scx_flatcg: expire cached hweights on weight changes
In reply to Sasha LevinFrom: Tao Cui <[email protected]>
[ Upstream commit 94c20e1fb334c2082b443c4470a86ad982f67282 ]
fcg_cgroup_set_weight() updates cgc->weight and the parent's child_weight_sum but doesn't bump hweight_gen, so the hweights cached by cgrp_refresh_hweight() stay stale until some task activation bumps the generation. For cgroups whose tasks never go through a 0->n runnable transition (e.g. persistently busy ones), a cpu.weight change never propagates to scheduling at all.
Bump hweight_gen on weight changes so the next refresh recomputes with the new weight.
Verified on a flatcg VM: a live cpu.weight 100->800 change on a busy cgroup leaves HWT update at 0 and the distribution unchanged; with it, hweight_gen increments and the refresh recomputes.
---
LLM Generated explanations, may be completely bogus:
I have enough to decide: the buggy path is in this 6.12 tree, the patch is a three-line cache-invalidation fix, and it applies here.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [sched_ext/scx_flatcg] [expire] [invalidate cached hierarchical weights when cpu.weight changes]
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Tao Cui <[email protected]> (author)
- Signed-off-by: Tejun Heo <[email protected]> (sched_ext maintainer; applied the patch)
- No Fixes: tag on the committed version (expected for this review pipeline)
- No Reported-by, Tested-by, Reviewed-by, Acked-by, Link, or Cc: stable
- BPF CI bot later suggested Fixes: a4103eacc2ab4 ("sched_ext: Add a cgroup scheduler which uses flattened hierarchy")
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: fcg_cgroup_set_weight() writes cgc->weight and the parent's child_weight_sum but does not bump hweight_gen. Cached hweights in cgrp_refresh_hweight() stay valid until some task activation changes the active set.
- Symptom: for cgroups that never go through a 0→n runnable transition (persistently busy ones), a live cpu.weight write never affects scheduling.
- Author verification: on a flatcg VM, cpu.weight 100→800 on a busy cgroup left HWT updates at 0 and the distribution unchanged; with the bump, hweight_gen increments and refresh recomputes.
- Root cause: generation counter used as a cache key is not invalidated on the weight-change path, even though the file comment says it "gets inc'd on weight tree changes".
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not hidden. This is an explicit correctness fix: a control knob is updated but the derived cached state is not expired.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: tools/sched_ext/scx_flatcg.bpf.c (+3 / -0)
- Function: fcg_cgroup_set_weight()
- Scope: single-file surgical fix (blank line, comment, one atomic increment)
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: lock; if the cgroup is active, adjust parent child_weight_sum; store new cgc->weight; unlock; return. Cached cgc->hweight is left tagged with the old hweight_gen.
- After: same updates, then __sync_fetch_and_add(&hweight_gen, 1) so the next cgrp_refresh_hweight() (called from try_pick_next_cgroup() / dispatch) misses the cache and recomputes hweight from the new weight.
- Path affected: cgroup cpu.weight write while scx_flatcg is loaded. Normal (not error) path.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Category: logic / correctness (stale cache)
- Mechanism: cgrp_refresh_hweight() returns early when cgc->hweight_gen == hweight_gen. hweight_gen is only bumped in update_active_weight_sums() when a cgroup's active membership actually changes. A weight write on an already-active cgroup never does that, so dispatch keeps charging with the old hierarchical share.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: it reuses the exact invalidation already used on the active-set path (__sync_fetch_and_add(&hweight_gen, 1) at the existing line 504).
- Minimal; no unrelated edits.
- Regression risk is very low: extra generation bumps only force more hweight refreshes, which the code already treats as the slow-but- correct path. No new locks, no API change.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record: The whole of fcg_cgroup_set_weight(), cgrp_refresh_hweight(), hweight_gen, and the existing bump in update_active_weight_sums() come from a4103eacc2ab4 (Tejun Heo, 2024-09-04), first contained in v6.12-rc1. The bug is as old as the example scheduler itself.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag on the commit. The introducing commit is a4103eacc2ab4, which is an ancestor of this tree (git merge-base --is- ancestor exit 0). No later in-tree commit already expires hweights on set_weight.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record (this tree, tools/sched_ext/scx_flatcg.bpf.c):
- 65e72372d5282 sched_ext/scx_flatcg: Fix cvtime true-up on slice expiry (already here; same author/thread)
- ab3d9439475a2 sched_ext/scx_flatcg: Fix cvtime_delta race and add hweight scaling to bypass charging
- c9c809f4137c3 scx_flatcg: Use a user DSQ for fallback instead of SCX_DSQ_GLOBAL
- a4103eacc2ab4 original addition
Standalone: one-line generation bump. Not patch N/M. The related cvtime true-up was discovered in the same mailing-list thread but is already in this tree.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Tao Cui has two origin/master commits on this file (this one and the cvtime true-up). Tejun Heo is the sched_ext maintainer and applied both. This tree already contains the cvtime true-up (65e72372d5282).
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: None. hweight_gen, __sync_fetch_and_add, and fcg_cgroup_set_weight() all exist unchanged in this checkout. git apply --check of 94c20e1fb334c succeeded (hunk offset 1 line from the already-backported cvtime fix).
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 94c20e1fb334c:
https://patch.msgid.link/[email protected]
- b4 dig -a: single v1 series; no later unapplied revision
- lore.kernel.org fetches returned 403; discussion recovered from patchew and openwall mirrors
- Tejun Heo: "Applied to sched_ext/for-7.3." No NAK
- BPF CI bot: "This looks like a bug fix. Should this include a Fixes:
tag..." suggesting a4103eacc2ab4
- No reviewer asked to keep it out of stable; no Cc: stable either (expected)
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To/Cc included [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]. Maintainer Tejun applied it.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla. Author follow-up: VM with A(100)→A1/A2(100) and D(varying weight), 3 busy tasks per leaf, 4 vCPUs. D=200 ≈ 47% CPU, D=800 ≈ 46% — weight changes did nothing. That is how the missing hweight_gen bump was found.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone v1. Same thread spawned the cvtime true-up fix (already in this tree as 65e72372d5282). Tejun noted that even after this cache fix, runnable-task limits still cap shares; that is a documented example-scheduler limitation, not a dependency of this patch.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable search returned 403. Local git log --grep='expire cached hweights' on this file is empty — not already in this tree. No local evidence of a prior rejection.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: fcg_cgroup_set_weight() (modified). Related:cgrp_refresh_hweight(), update_active_weight_sums(), try_pick_next_cgroup().
Step 5.2: TRACE CALLERS
Record:
- fcg_cgroup_set_weight is registered as .cgroup_set_weight in the BPF struct_ops (line 959).
- Kernel calls it from scx_group_set_weight() in kernel/sched/ext.c when cpu.weight / cpu.weight.nice changes and scx_flatcg is loaded (SCX_CALL_OP(..., cgroup_set_weight, ...)).
- Reachable from a privileged cgroupfs write, not from an unprivileged syscall.
Step 5.3: TRACE CALLEES
Record: find_cgrp_ctx, find_ancestor_cgrp_ctx, bpf_spin_lock/unlock(&cgv_tree_lock), and after the patch __sync_fetch_and_add(&hweight_gen, 1). No allocation.
Step 5.4: FOLLOW THE CALL CHAIN
Record: userspace writes cpu.weight → cpu_weight_write_u64 → scx_group_set_weight → BPF fcg_cgroup_set_weight. Dispatch later calls try_pick_next_cgroup() → cgrp_refresh_hweight(). If hweight_gen was not bumped, that refresh hits FCG_STAT_HWT_CACHE and keeps the old share. Users who load scx_flatcg and change cgroup weights can trigger this; busy cgroups are the common case where weights matter.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: The only other hweight_gen bump is in update_active_weight_sums() when nr_active crosses 0. That is the missing counterpart this patch adds on the weight-write path. No other copy of the same omission in this file.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. Local tree is pending-6.12, make kernelversion = 6.12.111, git describe HEAD = p-6.12-3-gc504cf0baa3d8. fcg_cgroup_set_weight() at lines 590–609 has the weight update and no hweight_gen bump. Introduced by a4103eacc2ab4 (in this tree). 94c20e1fb334c is not an ancestor (merge-base --is-ancestor exit 1).
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Clean apply. git show 94c20e1fb334c | git apply --check succeeded with hunk offset 1 (from the already-present cvtime true-up). No refactor of this function here.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No alternate hweight-expiry fix. Related accounting fixes (cvtime true-up, cvtime_delta race) are present and independent.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: tools/sched_ext example BPF scheduler (scx_flatcg), used only when CONFIG_SCHED_CLASS_EXT is enabled and this program is loaded.
Criticality: PERIPHERAL relative to core CFS, but IMPORTANT for anyone actually running this shipped scheduler — its whole job is hierarchical weight control. Not staging.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: sched_ext was new in 6.12; this file has a handful of later correctness backports in this tree. Mature enough that the bug is original, not from post-branch churn.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Config- and userspace-specific: CONFIG_SCHED_CLASS_EXT=y plus loading scx_flatcg. Not universal. This tree already ships that example and has been taking its correctness fixes.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Write cpu.weight on a cgroup whose tasks stay runnable. Common for exactly the workload the scheduler is meant to manage (competing busy cgroups). Requires privilege to write the cgroup knob. Not a race; it fails every time until some sibling goes idle.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: Failure mode = live cgroup CPU shares do not follow cpu.weight for busy groups (author: 100→800 left HWT updates at 0). No oops, deadlock, or corruption. Severity: MEDIUM–HIGH functional/fairness bug for that scheduler; LOW for the rest of the kernel.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: makes the primary fairness knob work for persistently busy cgroups on a scheduler this tree already ships and already patches.
- Risk: very low (3 lines, existing atomic, no lock/API change).
- Ratio: strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real, reproduced bug: busy-cgroup cpu.weight changes never reach scheduling.
- Matches the file's own cache-invalidation design; the set_weight path simply omitted the bump.
- 3-line, obviously correct, same primitive as the existing active-set path.
- Bug present since v6.12-rc1 in this tree; patch not yet here; applies cleanly.
- Maintainer applied it; author and maintainer both tested.
- Companion scx_flatcg correctness fixes are already in this 6.12 tree.
AGAINST:
- Example BPF scheduler in tools/, not CFS/core.
- No crash, UAF, deadlock, or CVE.
- Optional config; production SCX users often load schedulers from the out-of-tree scx repo.
- Residual share compression from window granting remains even after this fix (separate example-scheduler limit).
UNRESOLVED:
- lore.kernel.org and lore stable search returned 403; discussion taken from patchew/openwall. No evidence of a stable NAK.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — same generation bump as the other path; author + maintainer verified on a VM.
2. Fixes a real bug that affects users? PASS — cpu.weight ignored for busy cgroups; measured.
3. Important issue? PASS — fairness/control-knob failure of this scheduler (not a panic, but the feature is broken in the case that matters).
4. Small and contained? PASS — +3 lines, one function.
5. No new features or APIs? PASS.
6. Can apply to the local tree? PASS — --check succeeded.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: None (not a device ID, quirk, DT, build, or docs fix). Qualifies as a normal small correctness fix.
Step 9.4: MAKE YOUR DECISION
This tree is 6.12.y. The buggy example scheduler is here, the one-line invalidation is the intended cache protocol, and the only cost is extra hweight refreshes. That is a YES for this checkout.
What the commit solves for stable users:
Anyone on this 6.12 tree who loads the shipped scx_flatcg scheduler currently cannot change CPU shares of persistently busy cgroups through cpu.weight. That is the main knob the scheduler advertises. The patch expires the hweight cache so the next dispatch refresh uses the new weights.
Risk vs benefit:
Benefit is restoring advertised cgroup fairness for that scheduler; risk is a generation bump that already exists on another path. No prerequisites beyond code already in this tree.
Verification:
- [Phase 1] Parsed subject/body/tags from git log origin/master / git show 94c20e1fb334c; no Fixes:/Reported-by; Tejun SOB
- [Phase 2] Diff is +3 lines in fcg_cgroup_set_weight(); local function at lines 590–609 lacks the bump
- [Phase 2] Confirmed cgrp_refresh_hweight() cache test at lines 206–208 and existing bump at 503–504
- [Phase 3] git blame -L 590,609: a4103eacc2ab4; git describe --contains a4103eacc2ab4 = v6.12-rc1~111^2~20
- [Phase 3] git merge-base --is-ancestor a4103eacc2ab4 HEAD → 0 (bug in this tree)
- [Phase 3] git merge-base --is-ancestor 94c20e1fb334c HEAD → 1 (fix not in this tree)
- [Phase 3] git apply --check of 94c20e1fb334c succeeded (offset 1)
- [Phase 3] Author history on path: this commit + cvtime true-up (already 65e72372d5282 here)
- [Phase 4] b4 dig -c 94c20e1fb334c: msgid [email protected]; v1 only
- [Phase 4] b4 dig -w: Tejun and sched-ext/bpf lists on CC
- [Phase 4] patchew: Tejun applied to sched_ext/for-7.3; BPF CI asked for Fixes: a4103eacc2ab4
- [Phase 4] Author measurements: D=200 ~47% vs D=800 ~46% before the bump
- [Phase 4] lore.kernel.org 403 — UNVERIFIED on lore itself; recovered from patchew/openwall
- [Phase 5] Call path: scx_group_set_weight() in kernel/sched/ext.c:4113 → BPF cgroup_set_weight; refresh from try_pick_next_cgroup() line 677
- [Phase 6] git describe HEAD = p-6.12-3-gc504cf0baa3d8; make kernelversion = 6.12.111
- [Phase 7] README: scx_flatcg is the flattened hierarchical weight example
- [Phase 8] Failure: stale hweights → cpu.weight ignored for busy cgroups; severity MEDIUM–HIGH for that scheduler
- UNVERIFIED: whether this SHA was discussed on lore.kernel.org/stable (HTTP 403)
**YES**
tools/sched_ext/scx_flatcg.bpf.c | 3 +++ 1 file changed, 3 insertions(+)
tools/sched_ext/scx_flatcg.bpf.c +3 -0
@@ -605,6 +605,9 @@ void BPF_STRUCT_OPS(fcg_cgroup_set_weight, struct cgroup *cgrp, u32 weight) pcgc->child_weight_sum += (s64 )weight - cgc->weight; cgc->weight = weight;bpf_spin_unlock (&cgv_tree_lock); + +/* expire cached hweights so the new weight propagates */ +__sync_fetch_and_add (&hweight_gen,1 ); }static bool try_pick_next_cgroup (u64 *cgidp)
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 usb_string_copy: Use kzalloc() to avoid leaking old data
In reply to Sasha LevinFrom: David Laight <[email protected]>
[ Upstream commit 057df423bf4747091cf942af57307627e941e1fb ]
If the string is read while being updated (which is why the copy is done in place) and the new string is longer than the old one, then the reader can read memory that isnt part of either string.
Use memcpy() to copy the known length string instead of strcpy.
---
LLM Generated explanations, may be completely bogus:
# Stable backport analysis: usb_string_copy: Use kzalloc() to avoid leaking old data
Local tree: **v7.3-rc4** (7.3.0-rc4, HEAD f0100363d8c37). The commit under review is 057df423bf474. The buggy kmalloc + in-place strcpy path has been in this lineage since **v5.12** (98f153a10da403).
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
- Subsystem: USB gadget configfs (usb_string_copy in drivers/usb/gadget/configfs.c)
- Action verb: **Use** (kzalloc) / implied **avoid leaking**
- Claimed intent: stop readers from observing memory that is not part of either the old or new string when an in-place update lengthens the buffer
Record: [usb/gadget/configfs] [use/avoid] [zero the string buffer and copy a known length to prevent leaking heap bytes during in-place updates]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Signed-off-by: David Laight <[email protected]> (author)
- `Link: https://patch.msgid.link/20260608095523.2606-37-
[email protected]`
- Signed-off-by: Greg Kroah-Hartman <[email protected]> (USB maintainer applied it)
- No Fixes:, no Reported-by:, no Tested-by:, no Reviewed-by:, no Acked-by:, no Cc: stable (absence is expected)
- Message-Id 2606-37 = patch 37 of a large series
Record: Author SOB + Greg SOB + lore Link. No reporters. Hardening/USB lists were the original audience (confirmed in Phase 4).
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
The body describes a concurrent-read hole in the in-place update path:
if a reader walks the buffer while a longer string is being copied, it can pass the old NUL and consume bytes that belong to neither string. It also switches strcpy to memcpy of the already-computed length.
Record:
- Bug: kernel heap contents can be observed by a concurrent reader of a gadget string during an in-place lengthening update
- Symptom: leaked uninitialized kmalloc bytes (via configfs show or USB string descriptors)
- Version info: none in the message
- Root cause: first allocation used kmalloc (unzeroed tail); in-place strcpy of a longer string temporarily removes the old NUL before the new one is written
**Step 1.4: DETECT HIDDEN BUG FIXES**
This is not disguised cleanup. The subject states the leak. It *is* one patch in a treewide strcpy sweep, and memcpy is that sweep; kzalloc is the actual leak fix.
Record: [Not hidden. Real infoleak fix, bundled with strcpy- elimination.]
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
- File: drivers/usb/gadget/configfs.c (+2 / −2)
- Function: usb_string_copy()
- Scope: single-file, two-line surgical change
Record: [configfs.c +2/-2] [usb_string_copy] [single-file surgical]
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Before:
- First call: kmalloc(USB_MAX_STRING_WITH_NULL_LEN) then strcpy
- Later calls: reuse the same buffer (str = copy) and strcpy over it (the 2021 UAF workaround)
After:
- First call: kzalloc so the unused tail is zeros
- Copy: memcpy(str, s, ret + 1) (ret is strlen(s), so this includes the NUL)
Affected path: configfs store of manufacturer/product/serial/configuration strings (GS_STRINGS_W).
Record: [kmalloc+strcpy -> kzalloc+memcpy of known length; first-alloc and in-place update paths]
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Category: **uninitialized data / kernel infoleak** (with a concurrent- read window created by in-place update).
Mechanism, verified in this tree:
1. 98f153a10da403 (v5.12) stopped kfree+kstrdup and copies in place so USB host pointers stay valid.
2. First fill still used kmalloc, so bytes after the first NUL are heap residue.
3. Bind aliases those buffers into USB string tables:
- stringtab[...].s = language->manufacturer/product/serialnumber (configfs_attach_gadget_strings)
- cn->strings.s = cn->configuration (configfs_composite_bind)
4. usb_gadget_get_string() does strlen(s->s) then converts to UTF-16.
5. Configfs show is sprintf(page, "%s\n", gs->__name ?: "").
6. GS_STRINGS_W calls usb_string_copy() with **no** gi->lock. Host GET_DESCRIPTOR is not serialized against that store.
7. If a reader is in strlen/sprintf while strcpy lengthens the string, the old NUL is overwritten first; the walk continues into the unzeroed tail.
kzalloc makes that tail zeros, so a torn read stops instead of leaking heap. memcpy is equivalent to strcpy here (ret already came from strlen).
Record: [uninitialized kmalloc tail leaked across a designed concurrent-read window] [kzalloc zeros the tail; memcpy is strcpy replacement]
**Step 2.4: ASSESS THE FIX QUALITY**
Obviously correct. USB_MAX_STRING_LEN is 126, so max ret+1 is 127, matching USB_MAX_STRING_WITH_NULL_LEN. kzalloc is strictly safer than kmalloc. memcpy of strlen+1 matches strcpy for a C string.
Regression risk: very low. Remaining torn-string reads of *previous string contents* are the pre-existing in-place design, not introduced here.
Record: [minimal, correct] [regression risk very low]
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
- Function added: 88af8bbe4ef781 (2012, “the start of the configfs interface”) — originally kstrdup + kfree(old)
- In-place kmalloc + strcpy: 98f153a10da403 (2021-03-17, in v5.12) — **this is the buggy code**
- Empty-string guard: 6d3c721e686ea (2024, Cc: stable)
- This fix: 057df423bf474 (2026-06-08)
Record: [98f153a10da403, v5.12] [bug present for years in this lineage]
**Step 3.2: FOLLOW THE FIXES: TAG**
No Fixes: tag. The semantic Fixes target is 98f153a10da403, which **is** in this tree (git merge-base --is-ancestor succeeded). That commit was itself Cc: stable and exists because USB host string reads race with configfs stores.
Record: [No Fixes tag] [real introducer 98f153a is in this tree since v5.12]
**Step 3.3: CHECK FILE HISTORY**
Recent related commits on this file: OOB empty-string fixes (6d3c721e686ea, 3014168731b79), later f63edb54d8f73 (qw_sign, unrelated). No prerequisite refactor is required for these two lines. kmalloc_obj treewide conversion did **not** change this kmalloc call; the pre-image is still kmalloc(...).
Record: [standalone vs file history] [no blocking prerequisites in this tree]
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
David Laight is not the USB gadget maintainer. Around this commit he posted ~100 compile-tested strcpy replacements to linux-hardening / subsystem lists. Greg applied this one. Sibling leak-style changes exist (e.g. TIPC pad bytes).
Record: [regular contributor, hardening series] [Greg applied; not a maintainer-authored USB patch]
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Needs the in-place buffer (98f153a) to be meaningful; that is in this tree. Does not need 6d3c721e (empty-string check) for correctness; that only appears as nearby context. Applies standalone.
Record: [standalone on any tree that has the 2021 in-place copy] [can apply standalone here]
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**b4 dig -c 057df423bf474 matched:
https://patch.msgid.link/20260608095523.2606-37-
[email protected]
b4 dig -a: only **v1**, dated 2026-06-08, subject [PATCH next]. Saved mbox: patch only, **no replies**. Trailer notes:
- one of a group removing unbounded strcpy()
- **“all the changes are only compile tested”**
- ~100 patches sent individually
- “Apologies for the terse commit messages”
WebFetch to lore.kernel.org returned **403**. Discussion content was recovered via b4 dig -m.
Record: [lore msgid 20260608095523.2606-37] [v1 only, no review comments in thread] [no reviewer Cc: stable] [compile-tested series]
**Step 4.2: CHECK WHO REVIEWED THE PATCH**b4 dig -w original recipients: Kees Cook, linux-hardening, linux- kernel, linux-usb, Arnd Bergmann, Greg Kroah-Hartman. Greg’s merge SOB is the only review signal in git. No Reviewed-by/Acked-by on the commit.
Record: [USB + hardening lists and Greg CC’d; Greg applied; no written review in the thread]
**Step 4.3: SEARCH FOR THE BUG REPORT**
No Reported-by, no syzbot, no bugzilla. The race is inferred from code and from 98f153a’s real KASAN UAF on the same overlapping access.
Record: [no external bug report] [concurrent access is documented by the 2021 UAF fix, not by a new user report]
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Patch 37 of a ~100-patch strcpy series aimed at linux-next. This instance is one of the few that also changes allocation to kzalloc and describes a leak. No other series member is required for this function.
Record: [strcpy series; this patch is self-contained]
**Step 4.5: CHECK STABLE MAILING LIST HISTORY** lore.kernel.org/stable search via WebFetch and curl returned **403**. Cannot confirm a stable-list nomination or rejection.
Record: [UNVERIFIED: stable@ discussion]
---
## PHASE 5: CODE SEMANTIC ANALYSIS
semcode MCP is not available. Used grep + file reads.
**Step 5.1: KEY FUNCTIONS**
Record: [usb_string_copy]
**Step 5.2: CALLERS**
Direct calls only through GS_STRINGS_W in include/linux/usb/gadget_configfs.h, instantiated in configfs.c as:
- gadget_language_{manufacturer,product,serialnumber}_store
- gadget_config_name_configuration_store
Those are configfs attribute stores (privileged gadget setup). Host-side readers are usb_gadget_get_string() → strlen on the aliased buffers after bind.
Record: [configfs stores write; USB GET_STRING and configfs show read the same buffers]
**Step 5.3: CALLEES**strlen, kzalloc/kmalloc, memcpy/strcpy. No locks, no I/O.
Record: [string copy + slab alloc only]
**Step 5.4: CALL CHAIN / REACHABILITY**
Userspace with configfs gadget access: write(2) → configfs_write_file → GS_STRINGS_W → usb_string_copy. USB host: GET_DESCRIPTOR / string request → composite_setup → usb_gadget_get_string → strlen(s->s).
Reachable. Typical writers are root (Android/embedded gadgetd). The **host** is a different trust domain.
Record: [reachable from configfs writes and from USB host string reads] [host path is the security-relevant reader]
**Step 5.5: SIMILAR PATTERNS**
Same file already has other string-safety fixes (6d3c721e, 3014168731b79). Author’s series has other “don’t leak leftover bytes” patches. No second copy of this exact helper.
Record: [isolated helper; same file has prior stable-bound string bugs]
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Yes. Pre-image at 057df423bf474^ still has kmalloc + strcpy. Introduced v5.12, present through this 7.3-rc4 lineage until this commit.
Record: [yes, usb_string_copy in drivers/usb/gadget/configfs.c] [since v5.12 / 98f153a]
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Hunk is two lines inside a long-stable helper. Would apply cleanly here (and would apply to older trees that still have kmalloc+strcpy; empty-string check is only nearby context).
Record: [clean apply]
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE** 6d3c721e is a different bug (OOB on zero-length write). No other kzalloc leak fix for this helper.
Record: [no substitute fix already present before 057df423]
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: SUBSYSTEM AND CRITICALITY**
USB gadget configfs (CONFIG_USB_CONFIGFS). Used to compose gadgets from userspace (Android gadgets, gadgetfs-style gadgets, UDC testing). Not core mm/VFS, but a common embedded/Android path.
Record: [USB gadget configfs] [IMPORTANT for gadget/Android; PERIPHERAL for desktops without UDC]
**Step 7.2: SUBSYSTEM ACTIVITY**
File still receives security-relevant string fixes in 2024–2026. Mature interface, not staging.
Record: [mature, still getting bounded-string fixes]
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Gadget systems that set manufacturer/product/serial/configuration via configfs and have the gadget bound so a host can read string descriptors. Config-specific: CONFIG_USB_CONFIGFS.
Record: [driver/config-specific: USB gadget configfs users]
**Step 8.2: TRIGGER CONDITIONS**
Concurrent in-place store of a **longer** string while strlen/sprintf is walking the buffer. Window is a 127-byte copy — short, but the overlap is intentional (98f153a exists because host reads and configfs writes do overlap in practice). Unprivileged local users generally cannot write these attributes; a USB host can read the leaked bytes.
Record: [short race during string lengthening while gadget is live] [USB host can observe the leak]
**Step 8.3: FAILURE MODE SEVERITY**
Kernel heap infoleak (uninitialized kmalloc bytes), not a crash. Can cross to a USB host via string descriptors. That is a security issue, not a panic.
Record: [kernel heap infoleak to USB host / configfs reader] [HIGH for security, not CRITICAL crash]
**Step 8.4: RISK-BENEFIT RATIO**
- Benefit: closes a real infoleak on a path already known to race; 2 lines; kzalloc is the usual stable-grade fix
- Risk: negligible (kzalloc/memcpy behavior-preserving for this helper)
Record: [benefit high for gadget infoleak] [risk very low] [favorable]
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real uninitialized-kmalloc leak, not style-only
- Concurrent reader is why in-place copy exists (98f153a, KASAN UAF, Cc: stable)
- Host strlen on aliased pointers is a verified path
- Two-line, obviously correct change
- No new API/feature
- Bug present since v5.12 in this tree’s history
- Applied by Greg KH
AGAINST:
- Tiny race window; no syzbot/CVE/user report
- Series was compile-tested only, labeled [PATCH next]
- No mailing-list review comments
- Not a universal core-kernel path
- memcpy half is strcpy-hardening, not the leak fix
UNRESOLVED:
- Whether stable@ ever discussed this (lore 403)
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — correctness is local and obvious; series is compile-tested only, but the change cannot reasonably be wrong
2. Fixes a real bug that affects users? **PASS** — heap bytes can be read on a live gadget string update
3. Important issue? **PASS** — kernel infoleak (security), not a crash/deadlock
4. Small and contained? **PASS** — 2 lines, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — pre-image matches; no missing helpers
**Step 9.3: EXCEPTION CATEGORIES**
Not a device-ID/quirk/DT/build/docs exception. It is a small security/correctness fix.
**Step 9.4: DECISION**
This is a contained infoleak fix on a helper whose in-place update exists specifically so USB hosts can read strings while configfs writes them. kzalloc is the right, low-risk close of that hole. It meets stable rules for this tree.
---
## What the commit solves for stable users
After the 2021 UAF fix, gadget strings live in a reused kmalloc buffer. A host (or configfs reader) can walk that buffer while a longer string is copied in place, skip the old NUL, and return leftover heap data in a USB string descriptor. Zeroing on first allocation stops that leak. memcpy is a safe strcpy substitute given the existing strlen.
Risk vs benefit: two lines, no API change, no lock surgery, benefit is closing a kernel-memory leak on Android/embedded gadget configs.
---
## Verification
- [Phase 1] Parsed tags: author SOB, Greg SOB, lore Link; no Fixes/Reported-by/Cc: stable
- [Phase 2] Diff: kmalloc→kzalloc, strcpy→memcpy(str,s,ret+1) in usb_string_copy
- [Phase 2] Confirmed USB_MAX_STRING_LEN 126 and buffer size 127; ret+1 cannot overflow
- [Phase 3] git blame: in-place kmalloc from 98f153a10da403 (v5.12); function from 88af8bbe4ef781 (2012)
- [Phase 3] git merge-base --is-ancestor 98f153a10da403 HEAD — introducer is in this tree
- [Phase 3] git merge-base --is-ancestor 057df423bf474 HEAD — this commit is already in HEAD (ignored as “already selected”)
- [Phase 3] git describe HEAD / Makefile: local tree is **v7.3-rc4 / 7.3.0-rc4**
- [Phase 3] Pre-commit file still has kmalloc+strcpy
- [Phase 4] b4 dig -c 057df423bf474: msgid 20260608095523.2606-37, [PATCH next], v1 only
- [Phase 4] b4 dig -w: linux-usb, linux-hardening, Kees, Greg, Arnd
- [Phase 4] b4 dig -m: no replies; author said compile-tested only; ~100 strcpy patches
- [Phase 4] WebFetch lore.kernel.org: 403; used b4 instead
- [Phase 5] Callers: GS_STRINGS_W → manufacturer/product/serial/configuration stores
- [Phase 5] Host path: stringtab[].s and cn->strings.s alias the same buffers; usb_gadget_get_string uses strlen
- [Phase 5] GS_STRINGS_W does not take gi->lock
- [Phase 6] No other leak fix for this helper; 6d3c721e is a different OOB bug
- [Phase 6] Backport difficulty: clean 2-line apply
- [Phase 8] Failure mode: uninitialized heap infoleak, severity HIGH (security), not a crash
- UNVERIFIED: stable@ mailing-list discussion (lore 403)
- UNVERIFIED: no runtime reproduction performed here; race is from code
+ the 2021 UAF report, not a new reproducer
**YES**
drivers/usb/gadget/configfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/configfs.c +2 -2
@@ -125,11 +125,11 @@ static int usb_string_copy(const char *s, char **s_copy)if (copy) { str = copy; }else { - str =kmalloc (USB_MAX_STRING_WITH_NULL_LEN ,GFP_KERNEL ); + str =kzalloc (USB_MAX_STRING_WITH_NULL_LEN ,GFP_KERNEL );if (!str)return -ENOMEM ; } -strcpy (str, s); +memcpy (str, s, ret +1 );if (str[ret -1 ] =='\n' ) str[ret -1 ] ='\0' ; *s_copy = str;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] usb_string_copy: Use kzalloc() to avoid leaking old data
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines
From: David Laight <[email protected]>
[ Upstream commit
057df423bf4747091cf942af57307627e941e1fb]If the string is read while being updated (which is why the copy is done in place) and the new string is longer than the old one, then the reader can read memory that isnt part of either string.
Quoted 6 lines
Use
memcpy()to copy the known length string instead of strcpy.Signed-off-by David Laight <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 drm/panel-edp: Add BOE NE140QDM-NX2
In reply to Sasha LevinFrom: Weiji Wang <[email protected]>
[ Upstream commit 354b9c43d36ce9b41e48b2d67c5d9b953a0e9d64 ]
Add timing from datasheet for BOE NE140QDM-NX2.
edid-decode (hex):
00 ff ff ff ff ff ff 00 09 e5 f2 0a 00 00 00 00
20 1f 01 04 a5 1e 13 78 03 ee 96 a3 54 4c 99 26
0f 4e 51 00 00 00 01 01 01 01 01 01 01 01 01 01
01 01 01 01 01 01 60 d2 00 a0 a0 40 32 60 30 20
35 00 2e bd 10 00 00 18 c8 9d 00 a0 a0 40 32 60
30 20 35 00 2e bd 10 00 00 18 00 00 00 fd 00 30
78 c6 c6 36 01 0a 20 20 20 20 20 20 00 00 00 fe
00 4e 45 31 34 30 51 44 4d 2d 4e 58 32 20 01 f8
70 13 79 00 00 03 01 14 30 69 00 05 ff 09 9f 00
2f 00 1f 00 3f 06 31 00 02 00 04 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 4d 90
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: [drm/panel-edp] [Add] [one-line BOE NE140QDM-NX2 panel-id / delay table entry]
**Step 1.2: Tags**
Record:
- Signed-off-by: Weiji Wang <[email protected]> (author)
- Reviewed-by: Douglas Anderson <[email protected]> (listed R: for this driver in MAINTAINERS)
- Signed-off-by: Douglas Anderson <[email protected]> (applied via drm-misc)
- `Link: https://patch.msgid.link/82fc6395-3425-4f71-ba58-
[email protected]`
- No Fixes:, no Cc: stable, no Reported-by, no Tested-by tag (author later said they verified on next-20260726 in the v1 thread)
- Ignore pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] if present
**Step 1.3: Body**
Record:
- Claimed intent: add datasheet timing for BOE NE140QDM-NX2.
- Failure mode is not a crash dump; it is missing table data for a real eDP panel identified by EDID.
- Included raw EDID (base + CTA). Manufacturer 09 e5 is BOE; product f2 0a little-endian is 0x0af2; ASCII descriptor is NE140QDM-NX2.
- Root cause: generic edp-panel path looks up power-seq delays by panel ID; this ID was absent.
**Step 1.4: Hidden bug fix?**
Record: Not a disguised UAF/leak. It is hardware-table enablement. Without the row, generic_edp_panel_probe() hits WARN_ON(!panel->detected_panel) and falls back to conservative delays (2000 ms unprepare / 200 ms enable). That is a real user-visible issue for this panel (warning + slow suspend/resume), not style cleanup.
---
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- File: drivers/gpu/drm/panel/panel-edp.c (+1 / −0)
- Function/data: edp_panels[] only
- Scope: single-file, one table row
**Step 2.2: Code flow**
Record:
- Before: BOE IDs jump from 0x0ae8 (NV140WUM-N41) to 0x0b09 (NV140FHM-NZ). 0x0af2 is unknown.
- After: EDP_PANEL_ENTRY('B', 'O', 'E', 0x0af2, &delay_200_500_e50_p2e80, "NE140QDM-NX2").
- Path: probe of compatible "edp-panel" → generic_edp_panel_probe() → find_edp_panel() → copy *delay into desc. Modes still come from EDID (override_edid_mode is not set).
**Step 2.3: Bug mechanism**
Record: **Hardware ID / quirk table** (device-ID exception). Not a memory-safety bug. Missing identity causes:
1. WARN_ON splat at probe
2. panel_edp_set_conservative_timings(): unprepare=2000, enable=200, vs datasheet delays hpd_absent=200, unprepare=500, enable=50, prepare_to_enable=80
**Step 2.4: Fix quality**
Record: Obviously correct one-liner using an existing delay blob. Sorted by product ID. Regression risk is confined to this panel ID; other panels are untouched. Commit text says “timing” but the row only sets **power sequencing**; that matches the driver’s design comment “Update the delay; everything else comes from EDID”.
---
## Phase 3: Git history
**Step 3.1: Blame**
Record:
- New line is commit 354b9c43d36ce (Weiji Wang, 2026-07-28).
- Neighbors: 0x0ae8 from 993d36ac99efe (2024), 0x0b09 from c03dd019f0b56 (2025).
- delay_200_500_e50_p2e80 introduced in f4ccd9fea2270 (2023-12-14), present long before this change.
- Driver file from 5f04e7ce392db (2021-09-20).
**Step 3.2: Fixes: tag**
Record: None. Bug is “this panel ID was never listed”, not a regression from a specific SHA.
**Step 3.3: File history**
Record: Many similar drm/panel-edp: Add … one-liners. Standalone; not N/M. Parent eb7979f6014a1 already has the delay struct and surrounding BOE rows. git grep 0x0af2 on the parent: not present.
**Step 3.4: Author**
Record: Only this commit by Weiji Wang in drivers/gpu/drm/. Douglas Anderson is R: DRM DRIVER FOR GENERIC EDP PANELS and both reviewed and applied it.
**Step 3.5: Prerequisites**
Record: Needs EDP_PANEL_ENTRY, edp_panels[], and delay_200_500_e50_p2e80. All exist in this checkout. Applies standalone.
---
## Phase 4: Mailing list
**Step 4.1: Original discussion**
Record:
- b4 dig -c 354b9c43d36ce → https://patch.msgid.link/82fc6395-3425-
[email protected]
- v1: 2026-07-24, https://patch.msgid.link/697e79c2-98a9-4bb3-b5fb-
[email protected]
Used unsorted 0x0af2 with delay_200_500_e80.
- v2: 2026-07-28 (applied). Changelog: sort fix + delay_200_500_e50_p2e80.
- Doug on v2: mailer wrapped/tabs-to-spaces; he fixed and pushed to drm- misc-next as 354b9c43d36ce. Reviewed-by given. No NAK.
- v1 review: sort bug; asked if datasheet vs guess. Author: Panelook datasheet; T4+T5+T6+T8-min given. Doug recommended delay_200_500_e50_p2e80. Author confirmed T7/T8 match and verified on next-20260726.
- No reviewer Cc: stable.
**Step 4.2: Recipients (b4 dig -w)**
Record: Weiji Wang, Doug Anderson, [email protected], [email protected]. Right reviewer and list.
**Step 4.3: Bug report**
Record: No syzbot/bugzilla. Hardware addition from someone with the panel/datasheet. EDID in the message is the identification evidence.
**Step 4.4: Series**
Record: Single patch, v1→v2 only.
**Step 4.5: stable@**
Record: lore HTTP fetch returned 403. b4 threads have no stable discussion. Not used as a negative signal.
---
## Phase 5: Semantic analysis
**Step 5.1: Functions**
Record: No function body change. Data: edp_panels[]. Consumers:find_edp_panel(), generic_edp_panel_probe().
**Step 5.2: Callers**
Record:
- panel_edp_probe() if DT compatible is "edp-panel"
- panel_edp_platform_probe() / AUX-bus probe → panel_edp_probe()
- Context: device probe (boot / connector bring-up), not IRQ/hot path
**Step 5.3: Callees**
Record: find_edp_panel() walks edp_panels; on hit, desc->delay = *panel->detected_panel->delay.
**Step 5.4: Reachability**
Record: Yes, from normal laptop/embedded eDP probe when the panel EDID is BOE 0x0af2. Unprivileged users do not program the ID; it is firmware/EDID. Impact is display power-seq and a kernel warning at probe.
**Step 5.5: Similar patterns**
Record: The table is full of the same EDP_PANEL_ENTRY pattern (including other BOE NE140QDM parts, e.g. 0x0b1e NE140QDM-N6A). This is the standard way this driver is extended.
---
## Phase 6: Local tree (this checkout)
**Step 6.1: Does the code exist here?**
Record:
- Tree: git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- drivers/gpu/drm/panel/panel-edp.c present; CONFIG_DRM_PANEL_EDP in Kconfig
- delay_200_500_e50_p2e80 at lines 1768–1773
- edp_panels[] and WARN_ON unknown-panel path at 829–833
- Line 2060 already has this entry because 354b9c43d36ce **is an ancestor of HEAD**. That is mainline history, not a reason to treat the change as “already selected for stable”.
**Step 6.2: Backport difficulty**
Record: Clean apply: one sorted row, delay symbol already in this tree. No API/struct change.
**Step 6.3: Related fixes already here?**
Record: No other NE140QDM-NX2 / 0x0af2 commit besides this one. No alternate fix.
---
## Phase 7: Subsystem context
**Step 7.1:**
Record: DRM panel (drivers/gpu/drm/panel/). Criticality: **IMPORTANT** for systems using generic eDP (edp-panel), typical laptops/Chromebooks/ARM boards. Not mm/net core; not staging.
**Step 7.2:**
Record: Active table (many recent Add commits). Mature lookup/delay design since ~2021–2023.
---
## Phase 8: Impact and risk
**Step 8.1: Who is affected**
Record: Driver/config-specific: CONFIG_DRM_PANEL_EDP + DT "edp- panel" + BOE product ID 0x0af2. No effect on other panels.
**Step 8.2: Trigger**
Record: Every probe of that panel (boot / display init). Not a race. Not a syscall exploit path.
**Step 8.3: Failure mode**
Record:
- WARN_ON on unknown panel (MEDIUM as a warning, but intentional “please add this ID” splat)
- Conservative delays: extra ~1.5 s unprepare vs 500 ms (user-visible resume/power-off lag)
- Panel is still expected to work; this is enablement + warning/latency, not panic
- Severity: **MEDIUM** as a bug; **high value** as a device-ID exception
**Step 8.4: Risk-benefit**
Record:
- Benefit: correct power-seq and no warning for this hardware; same class as PCI/USB ID adds
- Risk: very low (1 line, ID-matched only)
- Ratio: favorable
---
## Phase 9: Synthesis
**Step 9.1: Evidence**
FOR:
- Existing driver; only a new panel ID + existing delay pointer
- Matches the documented **new device ID** / hardware-quirk exception
- Prevents WARN_ON + 2000 ms conservative unprepare for BOE NE140QDM- NX2
- 1 line, sorted, uses delay_200_500_e50_p2e80 already in this tree
- EDID in the message matches vendor/product/name
- Reviewed and applied by the panel-edp reviewer; v2 delay choice came from datasheet discussion
- Author verified on next-20260726
AGAINST:
- Not a UAF/crash/security fix
- Unknown panel still functions with conservative timings
- No Fixes: / Cc: stable (expected for this review path)
- Commit subject is enablement (“Add …”), not “fix”
UNRESOLVED:
- lore.kernel.org via WebFetch was 403; thread recovered with b4
- No stable@ thread found
- Exact laptop SKUs using this panel not identified beyond the EDID
**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** (1-line table add; maintainer review; author verified)
2. Real bug affecting users? **PASS** (missing ID → warning + wrong delays on real hardware)
3. Important (crash/security/corruption/deadlock)? **PASS via exception** (device ID / panel quirk; warning + bad power-seq). Not CRITICAL memory safety.
4. Small and contained? **PASS** (+1 line, one file)
5. No new features/APIs? **PASS** (no new driver, syscall, or userspace ABI; ID in existing table)
6. Can apply to this tree? **PASS** (driver, macro, delay struct, and sort neighbors all present)
**Step 9.3: Exception**
Record: **New device ID / hardware quirk** on an existing driver (EDP_PANEL_ENTRY is this driver’s ID table).
**Step 9.4: Decision**
This is the eDP equivalent of adding a PCI/USB ID: a one-line table entry so existing panel-edp uses datasheet power sequencing instead of the unknown-panel WARN_ON + conservative delays. This tree has every prerequisite. Benefit is real for owners of this panel; risk is negligible.
### What the commit solves for this tree
On v7.3-rc4, generic "edp-panel" devices read EDID and look up edp_panels[]. BOE 0x0af2 (NE140QDM-NX2) had no row, so probe warned and used 2000/200 ms conservative delays. The patch adds that row with delay_200_500_e50_p2e80. Display modes remain EDID-driven.
### Risk vs benefit
Very low risk, contained to one product ID. Benefit is working/faster power sequencing and no warning for that panel—standard stable device-ID material.
---
Verification:
- [Phase 1] Parsed subject/tags/body from git show 354b9c43d36ce; EDID 09 e5 f2 0a + NE140QDM-NX2 checked against the new BOE, 0x0af2 row
- [Phase 2] Diff is +1 line in edp_panels[]; generic_edp_panel_probe() / WARN_ON / panel_edp_set_conservative_timings() read in panel-edp.c
- [Phase 3] git blame -L 2058,2062; git log -L :delay_200_500_e50_p2e80:… → f4ccd9fea2270; parent has no 0x0af2; git merge-base --is-ancestor 354b9c43d36ce HEAD → yes
- [Phase 3] No Fixes:; author log only this DRM commit
- [Phase 4] b4 dig -c 354b9c43d36ce / -a / -w / -m; v1 mbox (7 messages) with Doug’s sort + delay review; v2 applied despite wrap
- [Phase 4] WebFetch lore → 403; discussion taken from b4 mboxes instead
- [Phase 5] Call path: "edp-panel" → panel_edp_probe() → generic_edp_panel_probe() → find_edp_panel()
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; VERSION=7 PATCHLEVEL=3 SUBLEVEL=0 EXTRAVERSION=-rc4; delay struct and table present
- [Phase 7] MAINTAINERS: R: Douglas Anderson for panel-edp.c; Kconfig DRM_PANEL_EDP
- [Phase 8] Failure mode verified: unknown panel → WARN_ON + unprepare 2000 / enable 200
- UNVERIFIED: stable@ archive (lore HTTP 403); specific machine models shipping this panel
**YES**
drivers/gpu/drm/panel/panel-edp.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/panel/panel-edp.c +1 -0
@@ -1989,6 +1989,7 @@ static const struct edp_panel_entry edp_panels[] = {EDP_PANEL_ENTRY ('B' ,'O' ,'E' ,0x0a6a , &delay_200_500_e80,"NV140WUM-N44" ),EDP_PANEL_ENTRY ('B' ,'O' ,'E' ,0x0ac5 , &delay_200_500_e50,"NV116WHM-N4C" ),EDP_PANEL_ENTRY ('B' ,'O' ,'E' ,0x0ae8 , &delay_200_500_e50_p2e80,"NV140WUM-N41" ), +EDP_PANEL_ENTRY ('B' ,'O' ,'E' ,0x0af2 , &delay_200_500_e50_p2e80,"NE140QDM-NX2" ),EDP_PANEL_ENTRY ('B' ,'O' ,'E' ,0x0b09 , &delay_200_500_e50_po2e200,"NV140FHM-NZ" ),EDP_PANEL_ENTRY ('B' ,'O' ,'E' ,0x0b1e , &delay_200_500_e80,"NE140QDM-N6A" ), EDP_PANEL_ENTRY('B', 'O', 'E', 0x0b34, &delay_200_500_e80_d50, "NV122WUM-N41"),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 misc: genwqe: handle a first DMA address of zero
In reply to Sasha LevinFrom: Yousef Alhouseen <[email protected]>
[ Upstream commit d401772a9e18e837631450844f835229354528a4 ]
genwqe_setup_sgl() uses zero as the initial previous DMA address. DMA address zero is valid, so a first entry at that address enters the merge path before last_s has been assigned and dereferences NULL.
Only merge adjacent mappings after an SGL data entry has been created.
---
LLM Generated explanations, may be completely bogus:
Confirmed GENWQE_EXECUTE_DDCB is unprivileged on a 0666 device node. Compiling the nine-phase analysis from the code, history, and review trail.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [misc: genwqe] [handle] [avoid NULL deref when the first SGL DMA address is zero]
Subsystem prefix misc: genwqe:. Verb “handle” is a fix-style verb. Claimed intent: stop treating DMA address 0 as “no previous mapping.”
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Yousef Alhouseen <[email protected]> (author)
- Link: https://patch.msgid.link/20260630104923.53827-1-
[email protected]
- Signed-off-by: Greg Kroah-Hartman <[email protected]> (char- misc maintainer; applied)
- No Fixes: tag (expected for this review pipeline)
- No Reported-by, Tested-by, Reviewed-by, Acked-by
- No Cc: [email protected] (expected; not a negative)
- Ignoring any Sasha Levin SOB (none on this commit)
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: genwqe_setup_sgl() initializes prev_daddr = 0. DMA address 0 is valid. If the first mapping is at 0, prev_daddr == daddr is true while last_s is still NULL.
- Symptom/failure mode: NULL pointer dereference of last_s->len (kernel oops).
- Version information: none in the message. History shows the pattern dates to the original GenWQE driver (v3.14).
- Root cause: 0 used as a sentinel for “no previous DMA address,” which collides with a valid IOVA/physical DMA address.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. It is an explicit NULL-deref fix. The wording “handle” / “only merge after an SGL data entry has been created” matches the one-line guard.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/misc/genwqe/card_utils.c (+1 / -1)
- Function: genwqe_setup_sgl()
- Scope: single-file, single-line surgical fix
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
Before: on every mapping, if (prev_daddr == daddr) merges into last_s. prev_daddr starts at 0, last_s starts NULL. First mapping at DMA 0 takes the merge path and dereferences NULL.
After: if (last_s && prev_daddr == daddr) — merge only after a data entry exists (last_s assigned at “start new entry”). First mapping always creates an entry.
Verified in the current function:
```379:439:drivers/misc/genwqe/card_utils.c
dma_addr_t prev_daddr = 0;
struct sg_entry *s, *last_s = NULL;
...
if (last_s && prev_daddr == daddr) {
u32 prev_len = be32_to_cpu(last_s->len);
...
}
/* start new entry */
s[j].target_addr = cpu_to_be64(daddr);
...
last_s = &s[j];
```Step 2.3: IDENTIFY THE BUG MECHANISM
Record: [NULL pointer dereference] [sentinel 0 vs valid DMA address 0]. last_s is only assigned when a new SG_DATA entry is created. Guarding the merge with last_s skips merge until there is a real previous entry.
Step 2.4: ASSESS THE FIX QUALITY
Record: Obviously correct. last_s == NULL means there is nothing to merge; skipping merge is the right first-entry behavior. One-line, no API/locking/structure changes. Regression risk is very low: the only new path is “first daddr==0 creates an entry instead of oopsing.” Later adjacent merges still work once last_s is set.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record: Buggy prev_daddr = 0, last_s = NULL, and if (prev_daddr == daddr) come from 67f4addbb8fe68 (“GenWQE Utility functions”, Frank Haverkamp, 2013-12-09). git describe --contains → v3.14-rc1~152^2~29. Present for ~12 years. The fix line is d401772a9e18e8 (this commit).
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Original buggy commit is 67f4addbb8fe68, confirmed ancestor of HEAD. No intermediate fix of this sentinel bug in drivers/misc/genwqe/.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: Recent card_utils.c history is mostly treewide MAX_ORDER/docs/DMA API churn. This commit is the only functional SGL- merge change. Standalone; not patch X/Y.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Yousef Alhouseen has this single genwqe commit. Not the listed maintainer (Frank Haverkamp). Greg KH applied it through char-misc. No related follow-up series from the same author in this tree.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: None. The change uses existing locals last_s and prev_daddr. Applies standalone on any tree that still has the 2013 genwqe_setup_sgl() merge loop.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c d401772a9e18e837631450844f835229354528a4 → https://patch.m
sgid.link/[email protected]
- b4 dig -a: v1 only, 2026-06-30; no v2/v3
- lore.kernel.org fetches returned 403; discussion recovered from
https://lkml.iu.edu/hypermail/linux/kernel/2606.3/11318.html and
https://lists.openwall.net/linux-kernel/2026/06/30/1334
- Message matches the committed diff. No NAK found in those archives. Greg applied it 2026-07-17 (char-misc), merged to Linus via char- misc-7.3-rc1 (93e4b3076b5f, 2026-08-25).
- No reviewer “Cc: stable” in the archives that were reachable.
- UNVERIFIED: full lore reply chain (403). No public replies found on IU/openwall for this Message-ID.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To/Cc Frank Haverkamp (GENWQE maintainer), Arnd Bergmann, Greg Kroah-Hartman, linux-kernel@. Applied by Greg (SOB). No Reviewed-by/Acked-by on the commit.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No Reported-by, syzbot, or bugzilla. Bug is from code inspection of the sentinel/NULL pattern, not a published crash report.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone v1 patch, not a series. git log --grep on drivers/misc/genwqe/ found no companion “DMA address zero” follow-up.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable search returned 403. UNVERIFIED whether stable@ already discussed this specific commit. No local evidence it was rejected for stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: genwqe_setup_sgl() only. semcode MCP not available; identified from the hunk header.
Step 5.2: TRACE CALLERS
Record: Single caller, ddcb_cmd_fixups() in drivers/misc/genwqe/card_dev.c (ATS_TYPE_SGL_RD / ATS_TYPE_SGL_RDWR), which is called from genwqe_execute_ddcb() → do_execute_ddcb() → ioctl GENWQE_EXECUTE_DDCB.
Verified: GENWQE_EXECUTE_DDCB does **not** check capable(CAP_SYS_ADMIN) (only GENWQE_EXECUTE_RAW_DDCB does). genwqe_devnode() sets the char device mode to 0666. With CONFIG_GENWQE and hardware present, an unprivileged process that can open /dev/genwqe* can reach this path.
Step 5.3: TRACE CALLEES
Record: Builds hardware SG entries from dma_list[] (from dma_map_page() in genwqe_map_pages()) or from sgl->fpage_dma_addr / sgl->lpage_dma_addr (dma_alloc_coherent()). first-page buffer:daddr = sgl->fpage_dma_addr + map_offs. dma_mapping_error() treats ~0 as error, not 0, so DMA address 0 is accepted as valid.
Step 5.4: FOLLOW THE CALL CHAIN
Record: userspace ioctl → ddcb_cmd_fixups → genwqe_setup_sgl. Reachable from userspace when the IBM GenWQE card is present. Trigger
is: first SGL data mapping has DMA address 0 (IOMMU IOVA 0, or coherent alloc at 0). Not every I/O; depends on the DMA API returning 0. Failure is an oops, not a WARN.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same file’s genwqe_unmap_pages() also treats dma_list[i] == 0 as end-of-list. That is a separate sentinel bug and is **not** fixed here. It does not make this last_s guard wrong: fpage_dma_addr does not go through dma_list, so a coherent mapping at 0 still hits the NULL deref. No sibling functions needed the same one-line change.
===============================================================
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 (Linus mainline, not a -stable series)
- Driver and genwqe_setup_sgl() exist. Bug introduced in v3.14 (67f4addbb8fe68), ancestor of HEAD.
- Candidate d401772a9e18 **is already an ancestor of HEAD** (expected:
candidates are taken from this mainline history). The pre-fix condition is the historical if (prev_daddr == daddr) in this lineage.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Surrounding function is essentially unchanged since 2014 (718f762efc4547 adjusted mapping sources). Expected apply: clean (1 line). No conflicting refactor in this file’s recent history.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: This commit is the fix. No earlier alternative for the same NULL deref. No later revert.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [drivers/misc/genwqe — IBM GenWQE PCIe accelerator] [PERIPHERAL]. CONFIG_GENWQE, depends on PCI && 64BIT. MAINTAINERS:
“Supported,” Frank Haverkamp.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Low churn; mostly treewide and small misc fixes. Mature driver, bug long-standing rather than a new-feature regression.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: driver-specific / config-specific: users with IBM GenWQE hardware and CONFIG_GENWQE. Not universal. Device node default 0666 widens who can issue the ioctl on those systems.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Trigger: SGL DDCB ioctl whose first mapped DMA address is 0. Uncommon without an IOMMU that issues IOVA 0; possible with dma_alloc_coherent/dma_map_page. Not every boot. Unprivileged users can issue GENWQE_EXECUTE_DDCB if they can open the device.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: [NULL deref → kernel oops] [CRITICAL for affected systems]. No data-corruption path identified beyond the crash itself.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: prevents oops on a valid DMA address; long-lived bug; ioctl- reachable. Benefit is high for GenWQE users, limited population.
- Risk: one-line pointer NULL check; very low.
- Ratio: favorable. Stable rules accept important crashes in drivers, not only core kernel.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR backporting:
- Real NULL deref, not style.
- DMA 0 is valid per the DMA API; using 0 as “no previous address” is wrong.
- One-line, obviously correct, no new API.
- Bug in code since v3.14; driver present in this tree.
- Userspace-reachable via GENWQE_EXECUTE_DDCB on a 0666 node without CAP_SYS_ADMIN.
- Applied by Greg KH; no NAK found.
- Applies cleanly; no prerequisites.
AGAINST:
- Peripheral IBM accelerator; few machines.
- No Reported-by/syzbot/crash log; trigger needs DMA address 0.
- Author is not the listed maintainer; no Reviewed-by.
- Separate dma_list[i]==0 unmap sentinel remains (not a reason to skip this fix).
UNRESOLVED:
- Full lore thread (403).
- Whether stable@ already queued/rejected it (403).
- How often GenWQE + IOVA 0 occurs in production (unverified frequency; mechanism is verified).
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — logic is local and correct; landed in char-misc/mainline. No extra Tested-by.
2. Fixes a real bug that affects users? PASS — NULL deref on a valid first DMA address 0.
3. Important issue? PASS — kernel oops (CRITICAL on that 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 — same genwqe_setup_sgl(); no missing helpers. (This checkout already contains the commit because it is 7.3-rc4 mainline; that does not change merit for stable.)
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary memory- safety bug fix.
Step 9.4: MAKE YOUR DECISION
This is a one-line NULL-deref fix in a driver that exists in this lineage since v3.14. The bug is real: prev_daddr is initialized to 0 while last_s is NULL, so a first mapping at DMA address 0 takes the merge path and crashes. That path is ioctl-reachable. The patch is minimal and does not need prerequisites. Peripheral hardware limits the user set, but stable regularly takes crash fixes in supported drivers. Benefit (oops avoided) outweighs risk (trivial guard).
What the commit solves for stable users: a kernel oops in genwqe_setup_sgl() when the first SGL fragment is at DMA address 0.
Meets stable rules: obviously correct, real crash, small, no new API, applies to this driver’s long-standing code.
Risk vs benefit: very low risk, meaningful crash fix for GenWQE systems.
Concerns: uncommon trigger; no user report. Those do not override a verified oops with a one-line fix. This 7.3-rc4 tree already contains the commit as mainline history; the evaluation is technical fitness for stable trees that still have the unguarded prev_daddr == daddr test. The surrounding function matches that old code, so a backport does not need extra commits.
Verification:
- [Phase 1] Parsed tags: author SOB, Greg KH SOB, msgid Link; no Fixes/Reported-by/Cc: stable
- [Phase 1] Body: first DMA 0 enters merge before last_s assigned → NULL deref
- [Phase 2] Diff: 1 line in genwqe_setup_sgl(): if (prev_daddr == daddr) → if (last_s && prev_daddr == daddr)
- [Phase 2] Read card_utils.c: prev_daddr = 0, last_s = NULL, last_s set only on new SG_DATA entry
- [Phase 3] git blame: buggy code from 67f4addbb8fe68 (v3.14-rc1); fix is d401772a9e18
- [Phase 3] git merge-base --is-ancestor 67f4addbb8fe68 HEAD: yes; d401772a9e18 also ancestor of HEAD
- [Phase 3] git log --oneline -20 -- drivers/misc/genwqe/card_utils.c:
no prerequisite series
- [Phase 3] Author log: only this genwqe commit
- [Phase 4] b4 dig -c d401772a9e18: lore msgid 20260630104923.53827-1; v1 only
- [Phase 4] b4 dig -w: Haverkamp, Arnd, Greg KH, linux-kernel@
- [Phase 4] IU/openwall: patch text matches commit; no NAK found
- [Phase 4] lore/stable WebFetch: 403 — UNVERIFIED full review thread and stable@ discussion
- [Phase 5] grep: only caller ddcb_cmd_fixups → GENWQE_EXECUTE_DDCB
- [Phase 5] GENWQE_EXECUTE_DDCB has no CAP_SYS_ADMIN; genwqe_devnode sets 0666
- [Phase 5] dma_map_page/dma_alloc_coherent + dma_mapping_error do not reject address 0
- [Phase 6] git describe HEAD: v7.3-rc4-27; kernelversion 7.3.0-rc4; driver present
- [Phase 6] Apply difficulty: clean 1-line change vs 2013/2014 function
- [Phase 7] MAINTAINERS: GENWQE Supported, Frank Haverkamp
- [Phase 8] Failure mode: NULL deref oops, severity CRITICAL on that path
- UNVERIFIED: production frequency of DMA address 0 on GenWQE; full lore replies
**YES**
drivers/misc/genwqe/card_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/genwqe/card_utils.c +1 -1
@@ -413,7 +413,7 @@ int genwqe_setup_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl, size -= size_to_map; map_offs =0 ; -if (prev_daddr == daddr) { +if (last_s && prev_daddr == daddr) {u32 prev_len =be32_to_cpu (last_s->len);/* pr_info("daddr combining: "
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/conexant: Add mute LED quirk for HP ProBook 440 G5
In reply to Sasha LevinFrom: Dmytro Moroziuk <[email protected]>
[ Upstream commit 191fe151eb85ff6cb24189fc88c970745497c057 ]
The HP ProBook 440 G5 requires the CXT_FIXUP_MUTE_LED_GPIO quirk to properly toggle the physical mute and mic-mute LEDs via the CX8200 codec. Without this quirk, the LEDs remain permanently dark.
---
LLM Generated explanations, may be completely bogus:
This is a one-line Conexant mute-LED quirk for HP ProBook 440 G5 (PCI SSID 0x103c:0x837b). The local tree is **6.12.111** (pending-6.12); the driver and sibling G4/G5 quirks are already here.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ALSA: hda/conexant] [Add] [mute LED quirk for HP ProBook 440 G5]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Dmytro Moroziuk \<[email protected]\> (author)
- Link:
https://patch.msgid.link/[email protected]
- Signed-off-by: Takashi Iwai \<[email protected]\> (ALSA maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Cc:
stable (absence is expected for this review)
- Ignore any pipeline-added Sasha Levin SOB / Upstream commit markers
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: HP ProBook 440 G5 mute and mic-mute LEDs stay off because the CX8200 codec is not wired to CXT_FIXUP_MUTE_LED_GPIO.
- Symptom: physical mute/mic-mute LEDs remain permanently dark.
- Root cause: missing SND_PCI_QUIRK for SSID 0x103c:0x837b.
- No stack traces, no kernel version range, no crash.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a hidden fix. It is an explicit hardware quirk / device- table addition.
===============================================================
PHASE 2: DIFF ANALYSIS
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- Upstream file: sound/hda/codecs/conexant.c (+1 / −0)
- Function/table: cxt5066_fixups[]
- Scope: single-file, one-line table insert
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Before: SSID 0x103c:0x837b matches no quirk; GPIO mute-LED setup is skipped.
- After: match applies CXT_FIXUP_MUTE_LED_GPIO → cxt_fixup_mute_led_gpio() at HDA_FIXUP_ACT_PRE_PROBE → cxt_setup_mute_led(codec, 0x01, 0x02).
- Path: codec probe / initialization only; no error-path or hot-path change.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: [Hardware workaround / codec quirk]
- Mechanism: missing PCI SSID in the existing Conexant quirk table.
- Fix: add one SND_PCI_QUIRK using the same CXT_FIXUP_MUTE_LED_GPIO already used by ProBook 440 G4 (0x822e), 455 G5 (0x836e), 470 G5 (0x837f), 450 G4 (0x8231).
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct; surgical; no API/locking/refcount change. Regression risk is limited to that SSID. 0x837b is unused in this tree’s quirk table.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: The new line did not exist here. Adjacent entries:
- 0x836e HP ProBook 455 G5 — present since at least Takashi Iwai 2021 (2e6a731296be9d)
- 0x837f HP ProBook 470 G5 — same
- 0x822e HP ProBook 440 G4 — ba92b11428797 (Kai-Heng Feng, 2017), originally Cc: stable # v4.12+CXT_FIXUP_MUTE_LED_GPIO itself dates to 5cd5b1bdfb013 (HP ZBook 15u G3, 2017).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The “bug” is a missing table entry, not a regression from a specific commit.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Same-file mute-LED quirks already in this tree include 440 G4, 450 G4 (1cce98bf41390, backported here with Cc: stable), 455 G5, 470 G5, 645 G4. Standalone, not a series.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: No prior Dmytro Moroziuk commits on sound/pci/hda/ in this tree. ALSA maintainer Takashi Iwai applied it the same day.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs CXT_FIXUP_MUTE_LED_GPIO / cxt_fixup_mute_led_gpio() / cxt5066_fixups[] — all present. Standalone. Path remapped from sound/hda/codecs/conexant.c (post-6.12 move) to sound/pci/hda/patch_conexant.c.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 191fe151eb85f →
https://patch.msgid.link/[email protected]
- Single v1 series; no v2/v3
- Thread: author submission + Takashi Iwai: “Thanks, applied to for-next branch now.”
- No NAK, no requested changes, no reviewer Cc: stable (common for one- line quirks)
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc [email protected], [email protected], linux- [email protected]. Right list and both ALSA maintainers.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No bugzilla/syzbot link. User-visible hardware issue stated in the commit; accepted by the subsystem maintainer.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone one-patch series. Later origin/master conexant commits (headset plugin, SN6140 S3) do not touch 0x837b.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No stable@ discussion found for this model/ID. Sibling quirks historically went to stable with explicit Cc.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: Table cxt5066_fixups[]; applied fixupcxt_fixup_mute_led_gpio().
**Step 5.2: TRACE CALLERS**
Record: patch_conexant_auto() → snd_hda_pick_fixup(..., cxt5066_fixups, ...) for codec IDs including default and CX8200 (HDA_CODEC_ENTRY(0x14f12008, "CX8200", patch_conexant_auto) at line 1305). Lookup is PCI subsystem vendor/device.
**Step 5.3: TRACE CALLEES**
Record: cxt_fixup_mute_led_gpio → cxt_setup_mute_led(codec, 0x01, 0x02) → snd_hda_gen_add_mute_led_cdev / snd_hda_gen_add_micmute_led_cdev. Existing, stable helpers.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Codec probe on matching HP laptop. Userspace mute/mic-mute then drives GPIO LEDs. Reachable on that hardware; not a generic syscall crash path.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same one-line pattern used for several HP ProBook G4/G5 Conexant machines; 450 G4 already backported into this 6.12 tree.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- Tree: p-6.12-3-gc504cf0baa3d8, make kernelversion = 6.12.111
- git merge-base --is-ancestor 191fe151eb85f HEAD → not present
- File here: sound/pci/hda/patch_conexant.c (no sound/hda/codecs/conexant.c)
- cxt5066_fixups[] exists; 0x837b / “HP ProBook 440 G5” absent
- CX8200 codec entry exists
- Bug is long-standing missing hardware enablement, not a post-6.12 regression
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Path remap required. Context matches. git apply --check after remapping to sound/pci/hda/patch_conexant.c: “Hunk #1 succeeded at 1105 (offset -2 lines).” Clean apply with trivial path change.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No 440 G5 / 0x837b entry. Related G4/G5 mute-LED quirks are already present.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: [sound/pci/hda Conexant codec] [IMPORTANT for laptop audio; quirk is machine-specific]
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature table; regular quirk additions. Recent local commits include other pin/quirk updates. Typical LTS candidate.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver-specific / platform-specific: HP ProBook 440 G5 (SSID 0x103c:0x837b) with CX8200, CONFIG_SND_HDA_CODEC_CONEXANT.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Every boot on that laptop. Mute/mic-mute keys do not light LEDs. Unprivileged users see dead LEDs; not a privilege issue.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Mute/mic-mute LEDs stay dark. Severity LOW as crash/corruption, but a real hardware bug that stable rules call out as a quirk.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: restores LED behavior on a shipping HP ProBook still used on 6.12 LTS; matches sibling models already in this tree.
- Risk: one table line, SSID-gated, existing fixup. Very low.
- Ratio: strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Explicit hardware quirk / PCI ID addition (stable-rules exception)
- Fixes user-visible broken mute/mic-mute LEDs on HP ProBook 440 G5
- One line, existing CXT_FIXUP_MUTE_LED_GPIO
- Same pattern as 440 G4 / 450 G4 / 455 G5 / 470 G5 already in this tree
- 450 G4 equivalent already backported here with Cc: stable
- Applied by ALSA maintainer; no NAK
- Applies here with only a path remap
- Documentation/process/stable-kernel-rules.rst: “fix a real bug … or just add a device ID” and “hardware quirk”
AGAINST:
- Not a crash, UAF, or security issue
- No Fixes:/Cc: stable (not a negative for this pipeline)
- Author is not a regular conexant contributor (mitigated by maintainer apply)
UNRESOLVED:
- Independently verifying the reporter’s hardware beyond SSID + maintainer accept: not possible from git/lore
- lore.kernel.org WebFetch returned 403; thread recovered via b4 dig -m
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? PASS — one-line table entry, maintainer applied
2. Fixes a real bug that affects users? PASS — LEDs stay dark on that laptop
3. Important issue? PASS as hardware quirk / device ID (not crash-level)
4. Small and contained? PASS — +1 line
5. No new features or APIs? PASS — existing fixup, new SSID only
6. Can apply to the local tree? PASS — context present; remap sound/hda/codecs/conexant.c → sound/pci/hda/patch_conexant.c
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Hardware quirk / codec quirk table entry (also a device-ID-style addition to an existing driver).
**Step 9.4: MAKE YOUR DECISION**
This belongs in 6.12.y. The driver, fixup, and neighboring ProBook G5 IDs are already here; only this SSID is missing. Risk is negligible.
------------------------------------------------
What the commit solves and why it matters
------------------------------------------------
Without the quirk, CX8200 GPIO mute/mic-mute LEDs on HP ProBook 440 G5 never toggle. That is a real hardware bug for owners of this 2018-era ProBook on LTS. The fix is the same one-line SSID mapping already used on 440 G4 and other G5 ProBooks.
Risk vs benefit: benefit is working LEDs on one laptop model; risk is confined to SSID 0x103c:0x837b. Backport needs only the file-path rename from the later HDA codec shuffle.
Verification:
- [Phase 1] Parsed tags: author SOB, Link msgid, Takashi Iwai SOB; no Fixes/Reported-by/Cc: stable
- [Phase 2] Diff: +1 SND_PCI_QUIRK(0x103c, 0x837b, "HP ProBook 440 G5", CXT_FIXUP_MUTE_LED_GPIO) in cxt5066_fixups[]
- [Phase 2] Local cxt_fixup_mute_led_gpio() at sound/pci/hda/patch_conexant.c:789 calls cxt_setup_mute_led(codec, 0x01, 0x02)
- [Phase 3] git blame -L 1098,1115: sibling G4/G5 quirks present; 440 G4 is ba92b11428797 with original Cc: stable
- [Phase 3] git show 1cce98bf41390: 450 G4 mute-LED quirk already in this 6.12 tree from upstream
- [Phase 3] git log --author="Dmytro Moroziuk" on sound/pci/hda/: no prior commits
- [Phase 4] b4 dig -c 191fe151eb85f: lore match; v1 only; recipients perex/tiwai/linux-sound
- [Phase 4] mbox: Iwai “Thanks, applied to for-next branch now.”; no NAK
- [Phase 4] WebFetch lore URLs: 403; thread recovered via b4
- [Phase 4] WebSearch stable@: no discussion of this model
- [Phase 5] CX8200 HDA_CODEC_ENTRY(0x14f12008, "CX8200", patch_conexant_auto) present; snd_hda_pick_fixup matches PCI SSID
- [Phase 6] git describe HEAD → p-6.12-3-gc504cf0baa3d8; make kernelversion → 6.12.111
- [Phase 6] git merge-base --is-ancestor 191fe151eb85f HEAD → not in tree
- [Phase 6] grep 0x837b / HP ProBook 440 G5 in conexant: no match
- [Phase 6] remapped git apply --check: hunk succeeded at 1105 (offset -2)
- [Phase 6] git log origin/master after the commit: later conexant changes do not touch 0x837b
- [Phase 7/8] Failure mode: dark mute/mic-mute LEDs on one HP model; quirk exception applies
- UNVERIFIED: physical confirmation of reporter’s 440 G5/CX8200 beyond commit + maintainer apply
- UNVERIFIED: lore.kernel.org HTML fetch (403); b4 mbox used instead
**YES**
sound/hda/codecs/conexant.c | 1 + 1 file changed, 1 insertion(+)
sound/hda/codecs/conexant.c +1 -0
@@ -1115,6 +1115,7 @@ static const struct hda_quirk cxt5066_fixups[] = {SND_PCI_QUIRK (0x103c ,0x829a ,"HP 800 G3 DM" ,CXT_FIXUP_HP_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x103c ,0x82b4 ,"HP ProDesk 600 G3" ,CXT_FIXUP_HP_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x103c ,0x836e ,"HP ProBook 455 G5" ,CXT_FIXUP_MUTE_LED_GPIO ), +SND_PCI_QUIRK (0x103c ,0x837b ,"HP ProBook 440 G5" ,CXT_FIXUP_MUTE_LED_GPIO ),SND_PCI_QUIRK (0x103c ,0x837f ,"HP ProBook 470 G5" ,CXT_FIXUP_MUTE_LED_GPIO ),SND_PCI_QUIRK (0x103c ,0x83b2 ,"HP EliteBook 840 G5" ,CXT_FIXUP_HP_DOCK ), SND_PCI_QUIRK(0x103c, 0x83b3, "HP EliteBook 830 G5", CXT_FIXUP_HP_DOCK),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 usb: typec: mux: tusb1046: add missing MODULE_DEVICE_TABLE()
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit 5e4eb5c96324b226220d29d025a334df28054ed3 ]
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 **v7.3-rc4**. The tusb1046 driver is present, and this is a one-line OF module-alias publication so udev can autoload the driver. That is a real modular-build bug, not a new feature.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[usb: typec: mux: tusb1046]** **[add]** missing MODULE_DEVICE_TABLE() so OF module aliases are generated.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected for this review)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** Romain Gantois \<[email protected]\> (driver author / listed maintainer)
- **Acked-by:** none in the commit; mailing-list thread also has **Reviewed-by: Heikki Krogerus** (USB Type-C maintainer) that did not land in the commit text
- **Link:**
https://patch.msgid.link/[email protected]
- **Cc: [email protected]:** absent (expected)
- **Signed-off-by:** Pengpeng Hou (author); Greg Kroah-Hartman (USB maintainer, merged)
- Ignore any pipeline “already selected” / Sasha Levin markers (none in this commit object)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** tusb1046_match_table is wired to .of_match_table but not exported with MODULE_DEVICE_TABLE(of, ...).
- **Symptom:** when CONFIG_TYPEC_MUX_TUSB1046=m, depmod does not emit of:N*T*Cti,tusb1046 aliases, so udev/kmod will not autoload the module when DT instantiates the I2C device.
- **Failure mode:** Type-C mux / orientation switch stays unbound until a manual modprobe. Built-in (=y) is unaffected.
- **Version info:** none in the message.
- **Root cause:** missing module alias publication; match table itself is correct.
- The “source-level fix / no dynamic hardware reproduction” sentence is in both the sent patch and the committed message.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. It is an explicit autoload/alias bug. Same class as device-ID publication: no new behavior, just making existing OF matching visible to userspace module loading.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** drivers/usb/typec/mux/tusb1046.c — **+1 / −0**
- **Function:** none; one line after tusb1046_match_table[]
- **Scope:** single-file, one-line surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** OF table exists and is used for in-kernel matching if the module is already loaded; file2alias never sees it.
- **After:** MODULE_DEVICE_TABLE(of, tusb1046_match_table) creates the __mod_of__tusb1046_match_table alias consumed by scripts/mod/file2alias.c.
- **Path:** build-time module metadata only; probe/remove/mux paths unchanged.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** hardware matching / module autoload (device-ID publication), not UAF/race/leak.
- **Mechanism:** OF compatible ti,tusb1046 was never exported in the module’s device table, so autoload could not work.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: this is the standard macro used by sibling Type-C mux drivers (fsa4480, ptn36502, it5205, nb7vpq904m, etc.).
- Minimal; no API, locking, or runtime change.
- Regression risk: negligible. Wrong table/type would be a build concern; here type of matches struct of_device_id.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Match table introduced in **7c561b8c3e836** (“usb: typec: mux: Add support for the TUSB1046 crosspoint switch”), **Romain Gantois**, 2024-10-24, first contained in **v6.13-rc1**.
- Original driver had .of_match_table = tusb1046_match_table and **no** MODULE_DEVICE_TABLE. Bug present from introduction.
- Candidate: **5e4eb5c96324b226220d29d025a334df28054ed3**, first contained in **v7.3-rc1**.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Buggy commit is the driver intro **7c561b8c3e836**, which **is** an ancestor of this HEAD.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record (on this file): driver add → dev_err_probe cleanup → include- header reshuffle → this alias fix. Standalone; not patch x/y. No prerequisite refactor required for the one-line add.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Pengpeng Hou is a contributor, not the Type-C mux maintainer. Nearby USB work is unrelated. Weight comes from **Romain Gantois** (driver maintainer) and **Heikki Krogerus** (Type-C) reviews, plus Greg KH merge.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. MODULE_DEVICE_TABLE exists in include/linux/module.h in this tree. Applies standalone on any tree that has tusb1046_match_table.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **b4 dig -c 5e4eb5c96324b:**
https://patch.msgid.link/[email protected]
- **b4 dig -a:** single **v1**, 2026-07-04, no later revision.
- Thread (mbox): Romain Gantois “LGTM, thanks!” + R-b (2026-07-07); Heikki Krogerus R-b (2026-07-13, after Greg’s 2026-07-08 commit). **No NAKs, no stable discussion, no risk flags.**
- WebFetch of lore.kernel.org returned **403**; thread recovered via b4 dig -m.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: **b4 dig -w** original To/Cc: Pengpeng Hou, Romain Gantois, Heikki Krogerus, Greg Kroah-Hartman, linux-usb, linux-kernel. Right maintainers were on the patch.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla/Reported-by. Justification is the missing macro vs an existing OF table. No in-tree DTS consumer of ti,tusb1046 (only Documentation/devicetree/bindings/usb/ti,tusb1046.yaml). User impact is boards that describe this chip in DT, including out-of-tree DTS.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone v1. Same pattern already used in this tree:
**15a34e5d4b23c** (“usb: typec: fix module autoloading”), **f27891abb7930** (“usb: typec: add missing MODULE_DEVICE_TABLE() to stusb160x”).
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** — lore.kernel.org/stable WebFetch 403; WebSearch failed. No stable nomination in the recovered linux-usb thread.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: No function body changed. Data: tusb1046_match_table; driver:tusb1046_driver / module_i2c_driver().
**Step 5.2: TRACE CALLERS**
Record: I2C core binds via module_i2c_driver. OF match is used once the module is loaded. Autoload is userspace (udev) using aliases from modules.alias. Reachable on DT platforms with compatible = "ti,tusb1046".
**Step 5.3: TRACE CALLEES**
Record: N/A for the added line. Macro expands to a static alias attribute for modpost.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: DT I2C instantiation → udev/kmod looks up OF alias → tusb1046 module → tusb1046_i2c_probe. Userspace cannot trigger a crash via this bug; the failure is **driver never loads**.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Other Type-C mux drivers already have MODULE_DEVICE_TABLE(of, ...). This driver was the one that omitted it. Semcode MCP not available; used git grep.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- **Tree:** git describe HEAD = **v7.3-rc4-27-gf0100363d8c37**; make kernelversion = **7.3.0-rc4**.
- Driver file exists; Kconfig TYPEC_MUX_TUSB1046 is **tristate**.
- Bug introduced **v6.13**; this 7.3 lineage includes that driver.
- **HEAD already contains 5e4eb5c96324b** (git merge-base --is- ancestor succeeded). Current file already has line 181 MODULE_DEVICE_TABLE(of, tusb1046_match_table). That is mainline history, not a reason to reject on technical merit.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: On **current HEAD**, git apply --check of the commit **fails** because the line is already present. Against the pre-fix file (parent of 5e4eb5c96324b) the hunk is a clean one-line insert after the match table. Any stable tree that still has the original tusb1046_match_table without the macro would take it cleanly.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This exact fix is already in HEAD. No alternate autoload workaround in the driver. Sibling Type-C autoload fixes are also present and do not replace this line.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **USB Type-C mux driver** (drivers/usb/typec/mux/). **PERIPHERAL** — one I2C crosspoint switch, not mm/VFS/net core. Still user-visible USB-C / DP altmode on boards that have the chip.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Type-C mux is actively developed (ps883x and related churn). tusb1046.c itself is low-churn since v6.13.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific + config-specific:** CONFIG_TYPEC_MUX_TUSB1046=m on OF/I2C systems with ti,tusb1046. Not universal. No in-tree DTS users found; out-of-tree / vendor DT is the realistic consumer.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Every boot/enumeration of that DT node when the driver is a module. Not a race. Unprivileged users do not exploit it; they just do not get the mux driver.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Failure mode:** module does not autoload; USB-C orientation/DP muxing does not come up until manual load. **Severity: MEDIUM** (functional hardware enablement, not oops/corruption/deadlock). Built-in
builds: no bug.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** high for TUSB1046 modular users (device actually probes); moderate overall (narrow hardware, no in-tree board).
- **Risk:** very low (1 line, metadata only).
- **Ratio:** favorable — same justification as adding a device ID to an existing driver.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR backporting:
- Real autoload bug for a tristate driver with an OF table.
- One line, obviously correct, no runtime path change.
- Reviewed by the driver author and Type-C maintainer; merged by Greg KH.
- Same pattern already used in this Type-C subsystem.
- Fits the stable exception for publishing match IDs so existing hardware actually binds.
- Driver and match table exist in this 7.3 tree (introduced v6.13).
AGAINST:
- Not a crash, UAF, deadlock, or security issue.
- No user Reported-by and no in-tree DTS enabling the compatible.
- “Tested” is source-level, not hardware reproduction.
- HEAD already contains the commit (expected on 7.3-rc; not a pipeline- selection marker).
UNRESOLVED:
- Could not query lore.kernel.org/stable (HTTP 403 / search failure).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — standard macro; maintainer R-b. Hardware test not claimed.
2. Fixes a real bug that affects users? **PASS** — modular OF autoload is broken.
3. Important issue? **PASS** as hardware enablement (autoload), analogous to new device IDs; not CRITICAL.
4. Small and contained? **PASS** — +1 line, one file.
5. No new features or APIs? **PASS** — exports an existing table.
6. Can apply to the local tree? **PASS** for this codebase (driver present). Re-applying on current HEAD conflicts only because the fix is already merged here; a tree that still lacks the line applies cleanly.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Device ID / module alias publication** for an existing driver (OF MODULE_DEVICE_TABLE). Also build-time metadata, not a new driver.
**Step 9.4: MAKE YOUR DECISION**
This tree has the TUSB1046 driver. Missing MODULE_DEVICE_TABLE(of, ...) prevents automatic loading of a modular Type-C mux, so USB-C/DP switching does not come up on DT systems until someone loads the module by hand. The fix is one obviously correct line with essentially no regression risk. That meets stable rules and the device-ID exception, so it should be backported to this tree’s stable series.
===============================================================
What the commit solves for stable users
===============================================================
With TYPEC_MUX_TUSB1046=m, kmod never learns the ti,tusb1046 OF alias, so the I2C Type-C mux never autoprobes. Distro/embedded kernels that ship this as a module then lose orientation switch and DisplayPort muxing on that hardware. The patch only emits the alias; it does not change probe logic.
Risk is negligible. Benefit is real for modular users of this chip. No extra commits are required beyond the driver that this 7.3 tree already has.
===============================================================
Verification
===============================================================
- [Phase 1] Parsed commit **5e4eb5c96324b**: R-b Romain Gantois; Link patch.msgid.link; no Fixes/Reported-by/Cc:stable.
- [Phase 2] Diff: **+1** MODULE_DEVICE_TABLE(of, tusb1046_match_table) in drivers/usb/typec/mux/tusb1046.c.
- [Phase 2] Confirmed sibling mux drivers already use MODULE_DEVICE_TABLE(of, ...).
- [Phase 3] git blame: table from **7c561b8c3e836** (v6.13-rc1); original add had no MODULE_DEVICE_TABLE.
- [Phase 3] git describe --contains 7c561b8c3e836 → v6.13-rc1; git describe --contains 5e4eb5c96324b → v7.3-rc1.
- [Phase 3] git merge-base --is-ancestor 5e4eb5c96324b HEAD → yes; 7c561b8c3e836 → yes.
- [Phase 3] git show 7c561b8c3e836 confirms OF table without the macro.
- [Phase 4] b4 dig -c/-a/-w/-m: v1 only; R-b Gantois + Krogerus; recipients include Type-C and USB maintainers; no NAK.
- [Phase 4] lore WebFetch 403; used mbox instead.
- [Phase 5] Kconfig TYPEC_MUX_TUSB1046 is tristate; Makefile builds tusb1046.o; DT binding ti,tusb1046.yaml exists.
- [Phase 5] git grep ti,tusb1046 arch/ → no in-tree DTS.
- [Phase 6] git describe HEAD = v7.3-rc4-27-g…; kernelversion 7.3.0-rc4.
- [Phase 6] HEAD already has the line; git apply --check of the patch on HEAD fails; parent of the commit lacks the macro.
- [Phase 7] MAINTAINERS: USB TYPEC TUSB1046 MUX DRIVER → Romain Gantois.
- [Phase 8] Failure = missing autoload, severity MEDIUM; risk very low.
- UNVERIFIED: stable@ discussion (lore/stable unreachable).
**YES**
drivers/usb/typec/mux/tusb1046.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/typec/mux/tusb1046.c +1 -0
@@ -179,6 +179,7 @@ static const struct of_device_id tusb1046_match_table[] = { {.compatible = "ti,tusb1046"}, {}, }; +MODULE_DEVICE_TABLE (of, tusb1046_match_table);static struct i2c_driver tusb1046_driver = { .driver = {
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18] usb: typec: mux: tusb1046: add missing MODULE_DEVICE_TABLE()
Sashiko has reviewed this patch and found no issues.
Quoted 14 lines
From: Pengpeng Hou <[email protected]>
[ Upstream commit
5e4eb5c96324b226220d29d025a334df28054ed3]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.
Quoted 5 lines
Signed-off-by Pengpeng Hou <[email protected]>Reviewed-by Romain Gantois <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/realtek: Add mute LED support for HP Pavilion 15-eh2xxx
In reply to Sasha LevinFrom: Luca Castaldini <[email protected]>
[ Upstream commit daf55a381dca9bda12cc8c3a47605698f2d560e9 ]
Add the subsystem ID 103c:8a0e to the ALC287 HP GPIO LED quirk table so the mute LED follows the speaker mute state.
Tested on HP Pavilion Laptop 15-eh2xxx with ALC287 codec. The mute LED now follows the speaker mute state.
---
LLM Generated explanations, may be completely bogus:
I have enough to decide: this is a one-line HP mute-LED quirk, the ALC287_FIXUP_HP_GPIO_LED helper already exists in 5.10, and this tree already takes the same class of Realtek ID additions.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [ALSA: hda/realtek] [Add] [mute LED support for HP Pavilion 15-eh2xxx by adding PCI subsystem ID 103c:8a0e to an existing GPIO LED quirk table]
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Fixes: none (expected for this review pipeline)
- Reported-by: none
- Tested-by: none as a tag; the body states the author tested it on the target laptop
- Reviewed-by: none
- Acked-by: none
- Link: https://patch.msgid.link/20260805122907.52302-1-
[email protected]
- Cc: [email protected]: absent (expected; not a negative signal)
- Signed-off-by: Luca Castaldini <[email protected]> (author)
- Signed-off-by: Takashi Iwai <[email protected]> (ALSA maintainer; applied the patch)
- Ignore any Sasha Levin SOB if present in candidate packaging
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug description: HP Pavilion Laptop 15-eh2xxx (ALC287) mute LED does not follow speaker mute because subsystem ID 103c:8a0e is missing from the ALC287 HP GPIO LED quirk table.
- Symptom/failure mode: mute LED stays out of sync with speaker mute (LED does not work as users expect). Audio playback itself is not described as broken.
- Version information: none in the message. Hardware is a 2021–2022 Pavilion (linux-hardware.org year 2021; retail listings 2022).
- Root cause: missing SND_PCI_QUIRK entry; the existing ALC287_FIXUP_HP_GPIO_LED fixup already implements GPIO mute LED control.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a hidden bug fix. It is an explicit hardware quirk / device- ID addition. The subject says "Add" rather than "fix", but this is the documented stable exception for audio codec quirks (SND_PCI_QUIRK for a specific laptop).
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- Files: sound/hda/codecs/realtek/alc269.c (+1 / -0)
- Function/table: alc269_fixup_tbl[] (static const struct hda_quirk / snd_pci_quirk)
- Scope: single-file, one-line surgical quirk addition
- Added line: SND_PCI_QUIRK(0x103c, 0x8a0e, "HP Pavilion Laptop 15-eh2xxx", ALC287_FIXUP_HP_GPIO_LED)
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: codec probe for PCI SSID 103c:8a0e does not match a quirk, so GPIO mute LED is not hooked to speaker mute.
- After: snd_hda_pick_fixup() matches 0x103c/0x8a0e and applies ALC287_FIXUP_HP_GPIO_LED, which calls alc287_fixup_hp_gpio_led() → alc_fixup_hp_gpio_led(..., mute_mask=0x10, micmute_mask=0), wiring GPIO bit 4 (0x10) as the mute LED.
- Path affected: HDA codec probe / LED classdev registration for this one SSID only.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Bug category: hardware workaround / audio codec quirk (SND_PCI_QUIRK)
- Mechanism: laptop mute LED is GPIO-driven; without the quirk the LED is not bound to mute state. The fix only adds the SSID to the existing table. No new fixup function.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: one ID, existing enum, existing function. Same pattern as many quirks already in this tree (e.g. 0x87cb/0x87cc Pavilion 15-eg0xxx).
- Minimal: one line, no unrelated changes, no API change.
- Regression risk: very low. Only machines with SSID 103c:8a0e are affected. Wrong GPIO would misdrive that laptop's LED, but the author tested ALC287 on this model and nearby Pavilion 14-ec1xxx (0x8a0f) uses the same fixup in mainline.
- Red flags: none (no new APIs, no locking, no refcount, no series dependency).
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- This tree does not have alc269.c; equivalent table is sound/pci/hda/patch_realtek.c.
- ALC287_FIXUP_HP_GPIO_LED and alc287_fixup_hp_gpio_led() were introduced by a0ccbc5319d57 ("ALSA: hda/realtek - Add supported mute Led for HP", Kailang Yang, 2020-11-06). That commit is an ancestor of HEAD.
- First table users of that fixup in this tree: 0x87f4/0x87f5 (same commit), later 0x87c8 (3e1bcaebe8b10, 2020-12), 0x87cc (d7e11de23f197, 2025-07), 0x87cb (471db5addec8c, 2026-03).
- 0x8a0e is not present in this checkout.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. The "bug" is a missing quirk for hardware that shipped after 5.10's original release, not a regression from a specific earlier commit.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- Recent patch_realtek.c history on this branch includes many mute-LED ID additions (4a660d1dc6a0f 14s-dr1xxx, 471db5addec8c 15-eg0xxx, d391901abfc67 15s-eq1xxx, etc.).
- Neighbor ID 0x8a0f ("HP Pavilion 14-ec1xxx") is in the candidate hunk context but is not in this 5.10 table.
- Related mainline commit 068641bc9dc3d adds 15-eh1xxx with a different codec/fixup (ALC245 / ALC245_FIXUP_HP_MUTE_LED_V1_COEFBIT). Not a prerequisite; different board (88D1 vs 8A0E). Not in this tree.
- Standalone: not patch X/Y.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: git log --author='Luca Castaldini' on this tree's sound/pci/hda/ returned no commits. First-time contributor for this ID. Maintainer Takashi Iwai applied it the same day.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record:
- Required symbols exist here: ALC287_FIXUP_HP_GPIO_LED enum, alc287_fixup_hp_gpio_led(), alc_fixup_hp_gpio_led(), alc269_fixup_tbl, snd_hda_pick_fixup() in alc269 probe.
- No new functions or structs.
- Path differs (mainline split Realtek into sound/hda/codecs/realtek/alc269.c; 5.10 still uses sound/pci/hda/patch_realtek.c). Standalone conceptually; apply needs a path/context tweak, not extra commits.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- Commit on all-next: daf55a381dca9bda12cc8c3a47605698f2d560e9 (not an ancestor of this HEAD).
- b4 dig -c daf55a381dca9: lore.kernel.org patch-id search errored; author/subject match succeeded.
- Lore/msgid: https://patch.msgid.link/20260805122907.52302-1-
[email protected]
- Mirrors: https://lkml.iu.edu/hypermail/linux/kernel/2608.0/08604.html
(patch), .../09065.html (Iwai reply)
- b4 dig -a: single v1 series, 2026-08-05. No v2/v3.
- Reviewer: Takashi Iwai applied to for-next the same day: "Applied to for-next branch now. Thanks." No NAK, no stable discussion, no risk flags.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: b4 dig -w recipients: Luca Castaldini, [email protected], [email protected], [email protected], linux- [email protected]. Correct ALSA maintainers and lists. Applied by Takashi Iwai.
Step 4.3: SEARCH FOR THE BUG REPORT
Record:
- No bugzilla or syzbot link.
- Author tested on HP Pavilion Laptop 15-eh2xxx with ALC287.
- linux-hardware.org probe 0510a78cfe confirms Pavilion Laptop 15-eh2xxx, motherboard 8A0E, PCI SSID 103c:8a0e, Ryzen HD Audio (snd_hda_intel), year ~2021, Ubuntu 22.04 / kernel 6.5 in that probe.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone v1. Related but independent: 15-eh1xxx quirk (068641bc9dc3d) uses ALC245, not this fixup. 14-ec1xxx (0x8a0f) is the table neighbor in mainline; not required here.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable fetch returned 403. Web search did not find a stable-list thread for 15-eh2xxx / 8a0e. UNVERIFIED that nobody requested or rejected it on stable@; no evidence of a NAK.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: No function body edited. Table alc269_fixup_tbl[]. Runtime
target: ALC287_FIXUP_HP_GPIO_LED → alc287_fixup_hp_gpio_led() → alc_fixup_hp_gpio_led().
Step 5.2: TRACE CALLERS
Record:
- alc269_fixup_tbl is passed to snd_hda_pick_fixup() from the ALC269-family probe in patch_realtek.c (around line 10471).
- alc287_fixup_hp_gpio_led is only referenced as that fixup's .v.func.
- Context: HDA codec probe (device enumeration), not IRQ/hot path. Userspace mute then drives the LED via the registered mute LED cdev.
Step 5.3: TRACE CALLEES
Record (this tree, alc_fixup_hp_gpio_led at 4431–4449):
- alc_fixup_gpio(codec, action, mute_mask | micmute_mask)
- On PRE_PROBE, if mute_mask: set spec->gpio_mute_led_mask and snd_hda_gen_add_mute_led_cdev(codec, gpio_mute_led_set)
- ALC287 variant uses mute_mask 0x10, micmute_mask 0
Step 5.4: FOLLOW THE CALL CHAIN
Record: PCI HDA probe → Realtek ALC269/ALC287 patch → snd_hda_pick_fixup(SSID) → GPIO LED hook. Reachable on this laptop whenever the HDA codec probes. Unprivileged users can toggle mute; they cannot widen the quirk to other SSIDs.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same ALC287_FIXUP_HP_GPIO_LED already used here for 0x87c8, 0x87cb, 0x87cc, 0x87f4, 0x87f5. This tree has a long history of HP mute- LED ID additions. Systematic, established pattern.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record:
- Local tree: pending-5.10, git describe p-5.10-2-g5aaf1e4e5aa4d, make kernelversion 5.10.270.
- Missing ID 103c:8a0e: confirmed (no 0x8a0e, no 15-eh2xxx, no 0x8a* HP entries at all).
- Fixup and driver: present. Without the ID, 5.10 will not enable the mute LED on this laptop.
- Introduced: missing-ID class; hardware ~2021–2022. 5.10 still ships this driver and already backports later Pavilion LED quirks.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Expected difficulty: minor conflicts / path remap, not rework.
- Mainline file sound/hda/codecs/realtek/alc269.c does not exist; use sound/pci/hda/patch_realtek.c.
- Hunk context (0x8a05/0x8a06/0x8a0f) is absent. Insert one SND_PCI_QUIRK among the 0x103c HP entries (table currently jumps 0x89aa → 0x8e1d).
- No structural conflict with ALC287_FIXUP_HP_GPIO_LED.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: 0x8a0e not present. No 15-eh2xxx/15-eh1xxx quirk. Similar Pavilion 15-eg0xxx IDs (0x87cb/0x87cc) already backported. This ID is new.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [sound/pci/hda Realtek codec / ALSA HDA] [IMPORTANT for laptop audio; this change is laptop-specific, not core MM/net]
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mature, still active on this 5.10 branch. Recent mute-LED quirks continue to land (2025–2026). MAINTAINERS: SOUND — Jaroslav Kysela, Takashi Iwai.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver-specific / platform-specific: only HP Pavilion 15-eh2xxx (PCI SSID 103c:8a0e). 5.10 users of that laptop (Debian 11-class LTS, appliances, custom 5.10 images) benefit. Everyone else unchanged.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Trigger is codec probe on that SSID, then mute/unmute. Common for owners of that model. Unprivileged users can toggle mute; not a security trigger.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: Mute LED does not track speaker mute. Not panic/UAF/corruption. Severity LOW–MEDIUM functionally, but this is the documented hardware- quirk exception (broken LED on a real laptop).
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: mute LED works on this Pavilion series; matches many quirks already accepted on this branch.
- Risk: very low (one SSID, existing fixup, author-tested, maintainer- applied).
- Ratio: high benefit for those users vs negligible regression risk.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR backporting:
- Explicit stable exception: audio codec SND_PCI_QUIRK / hardware quirk for an existing driver.
- One-line addition; ALC287_FIXUP_HP_GPIO_LED already in 5.10 since a0ccbc5319d57 (v5.10 era, Cc: stable originally).
- Real hardware, author-tested; SSID 103c:8a0e confirmed on linux- hardware.org.
- Applied by ALSA maintainer; no NAK.
- This 5.10 tree already backports the same class of HP mute-LED IDs.
AGAINST:
- Not a crash, UAF, or data-corruption fix (LED-only).
- Mainline path differs; hunk context IDs missing (trivial remap).
- Laptop postdates original 5.10 (2021–2022); still relevant because this LTS keeps taking such quirks.
- First-time author; mitigated by maintainer apply + identical existing fixup.
UNRESOLVED:
- lore.kernel.org/stable search 403; no confirmed stable-list thread.
- Could not confirm from this checkout whether every 15-eh2xxx SKU uses GPIO 0x10; author test and 14-ec1xxx using the same fixup support that choice.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — one ID, existing fixup, author tested, maintainer applied.
2. Fixes a real bug that affects users? PASS — mute LED does not follow mute on this laptop.
3. Important issue? PASS under the hardware-quirk exception (not a panic). Severity: broken LED on a specific model.
4. Small and contained? PASS — +1 line.
5. No new features or APIs? PASS — enables existing GPIO LED fixup for one SSID; no new userspace API.
6. Can apply to the local tree? PASS — equivalent table and fixup exist in patch_realtek.c; needs path/context adjustment only.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Hardware quirk / audio codec SND_PCI_QUIRK for an existing Realtek HDA driver. This is the category the rules call out as appropriate for stable.
Step 9.4: MAKE YOUR DECISION
This should be backported to this 5.10.270 tree. It is a one-line PCI quirk onto a fixup that already exists here, it fixes real mute-LED behavior on HP Pavilion 15-eh2xxx, and it matches quirks this branch already carries. Apply it in sound/pci/hda/patch_realtek.c's alc269_fixup_tbl[] as:
SND_PCI_QUIRK(0x103c, 0x8a0e, "HP Pavilion Laptop 15-eh2xxx", ALC287_FIXUP_HP_GPIO_LED),
placed among the other 0x103c HP entries (for example after 0x89aa, before 0x8e1d).
Verification:
- [Phase 1] Parsed tags: Link msgid [email protected]; SOB Luca Castaldini + Takashi Iwai; no Fixes/Reported-by/Cc:stable
- [Phase 1] Body: missing 103c:8a0e; mute LED should follow speaker mute; tested on Pavilion 15-eh2xxx ALC287
- [Phase 2] Diff: +1 SND_PCI_QUIRK in alc269_fixup_tbl; ALC287_FIXUP_HP_GPIO_LED
- [Phase 3] git describe HEAD: p-5.10-2-g5aaf1e4e5aa4d; make kernelversion 5.10.270; branch pending-5.10
- [Phase 3] glob: no alc269.c; equivalent sound/pci/hda/patch_realtek.c
- [Phase 3] git merge-base --is-ancestor a0ccbc5319d57 HEAD: YES (fixup introduced 2020-11-06)
- [Phase 3] git merge-base --is-ancestor daf55a381dca9 HEAD: NO (this ID not in 5.10 yet)
- [Phase 3] grep 0x8a0e / 15-eh2xxx / 0x8a0f: no matches in this tree
- [Phase 3] blame alc287_fixup_hp_gpio_led: a0ccbc5319d57; table already has 0x87cb/0x87cc/0x87c8/0x87f4/0x87f5
- [Phase 3] git log --author='Luca Castaldini' -- sound/pci/hda/: empty on this tree
- [Phase 4] b4 dig -c daf55a381dca9: msgid match; v1 only; Iwai applied same day
- [Phase 4] b4 dig -w: tiwai, perex, linux-sound, linux-kernel
- [Phase 4] lkml.iu.edu 08604/09065: patch + "Applied to for-next"; no NAK
- [Phase 4] linux-hardware.org probe 0510a78cfe: 103c:8a0e Pavilion 15-eh2xxx, board 8A0E
- [Phase 4] lore.kernel.org WebFetch 403; stable-list discussion UNVERIFIED
- [Phase 5] alc269_fixup_tbl used at patch_realtek.c:10471 via snd_hda_pick_fixup; alc_fixup_hp_gpio_led uses mute_mask 0x10
- [Phase 6] Insertion point: after 0x89aa / before 0x8e1d in alc269_fixup_tbl; path remap required
- [Phase 6] Related 15-eh1xxx 068641bc9dc3d not in this tree and uses a different fixup; not a dependency
- [Phase 7] SOUND maintainers Takashi Iwai / Jaroslav Kysela; this branch already lands mute-LED quirks
- [Phase 8] Failure mode: mute LED desync, not crash; quirk exception applies
- UNVERIFIED: GPIO 0x10 for every 15-eh2xxx SKU beyond the author's test; no stable@ thread due to 403
The patch is a one-line hardware quirk for an existing Realtek HDA fixup, it matches stable policy, and it applies to this 5.10 tree with only a path/context adjustment.
**YES**
sound/hda/codecs/realtek/alc269.c | 1 + 1 file changed, 1 insertion(+)
sound/hda/codecs/realtek/alc269.c +1 -0
@@ -6881,6 +6881,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x103c ,0x89e7 ,"HP Elite x2 G9" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8a05 ,"HP Dragonfly Folio G3 2-in-1" ,ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8a06 ,"HP Dragonfly Folio G3 2-in-1" ,ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8a0e ,"HP Pavilion Laptop 15-eh2xxx" ,ALC287_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8a0f ,"HP Pavilion 14-ec1xxx" ,ALC287_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8a1b ,"HP 255 15.6 inch G9 Notebook PC" ,ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 ), SND_PCI_QUIRK(0x103c, 0x8a1f, "HP Laptop 14s-dr5xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: brcmfmac: Set DMA direction for msgbuf packet IDs
In reply to Sasha LevinFrom: Can Peng <[email protected]>
[ Upstream commit f0ba5fd51ff23077ce66cb9be79d41a4b7c19c5e ]
brcmf_msgbuf_init_pktids() takes the DMA direction from its callers, but never stores it in the packet ID state. Since the state is zeroed, pktids->direction remains DMA_BIDIRECTIONAL for both the TX and RX packet ID pools.
All msgbuf packet ID map and unmap paths use pktids->direction. As a result, TX buffers requested with DMA_TO_DEVICE and RX buffers requested with DMA_FROM_DEVICE are mapped and unmapped as DMA_BIDIRECTIONAL instead.
Store the caller-provided direction when initializing the packet ID state.
---
LLM Generated explanations, may be completely bogus:
The local tree is **5.15.221** (pending-5.15). The missing pktids->direction store is present here, so this is a one-line DMA correctness fix for this tree.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[wifi / brcmfmac]** **[Set]** Store DMA direction on msgbuf packet ID pools so TX/RX map/unmap use the caller’s direction instead of the zeroed DMA_BIDIRECTIONAL default.
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
From the commit text under review:
- **Acked-by:** Arend van Spriel <[email protected]> (brcm80211 maintainer)
- **Link:** https://patch.msgid.link/[email protected]
- **Signed-off-by:** Can Peng <[email protected]> (author)
- **Signed-off-by:** Johannes Berg <[email protected]> (wireless maintainer)
- No **Fixes:** / **Cc: stable** / **Reported-by** in the applied message (expected for this review queue)
Original mailing-list submission (openwall / LKML, msgid [email protected]) **did** include:
- Fixes: 9a1bb60250d2 ("brcmfmac: Adding msgbuf protocol.")
- Cc: [email protected]
Those tags were dropped when the patch was applied. That is author/maintainer intent, not a pipeline “already selected” marker. Decision below is still on technical merit.
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
**Bug:** brcmf_msgbuf_init_pktids() takes enum dma_data_direction direction but never writes pktids->direction. pktids is zeroed, and DMA_BIDIRECTIONAL == 0.
**Symptom:** TX pools created with DMA_TO_DEVICE and RX pools with DMA_FROM_DEVICE are mapped/unmapped as bidirectional. **Version:** Introduced with msgbuf (2014); no version cutoff in the message.
**Root cause:** Missing store of a parameter that every map/unmap path already reads.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. It is an explicit DMA-direction correctness fix. The unused parameter plus zeroed field is the entire bug.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- **File:** drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
- **Scope:** +1 line in brcmf_msgbuf_init_pktids() (pktids->direction = direction;)
- **Classification:** single-file surgical fix
- Mainline hunk context uses kzalloc_objs / kzalloc_obj; this 5.15 tree uses kcalloc / kzalloc. The added line is the same.
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
**Before:** After allocating the array and pktids, only array and array_size are set. direction stays 0.
**After:** The caller-provided direction is stored. **Path:** Probe/init (brcmf_proto_msgbuf_attach), then every TX/RX dma_map_single / dma_unmap_single via pktids->direction.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record: **Logic / DMA API correctness** (with IOMMU and cache/bounce side effects).
Callers already pass the right direction:
```1580:1585:drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
msgbuf->tx_pktids = brcmf_msgbuf_init_pktids(NR_TX_PKTIDS,
DMA_TO_DEVICE);
if (!msgbuf->tx_pktids)
goto fail;
msgbuf->rx_pktids = brcmf_msgbuf_init_pktids(NR_RX_PKTIDS,
DMA_FROM_DEVICE);
```Map/unmap always use pktids->direction (brcmf_msgbuf_alloc_pktid, brcmf_msgbuf_get_pktid, brcmf_msgbuf_release_array). Verified DMA_BIDIRECTIONAL = 0 in include/linux/dma-direction.h.
Verified DMA consequences in this tree:
- **IOMMU:** dma_info_to_prot() maps BIDIRECTIONAL → IOMMU_READ | IOMMU_WRITE, TO_DEVICE → IOMMU_READ only, FROM_DEVICE → IOMMU_WRITE only (drivers/iommu/dma-iommu.c). TX SKBs currently get device **write** permission they should not have.
- **Docs:** Networking TX must be DMA_TO_DEVICE, RX DMA_FROM_DEVICE (Documentation/core-api/dma-api-howto.rst).
- **SWIOTLB / non-coherent:** direction selects bounce copy and arch_sync_dma_* behavior.
Step 2.4: ASSESS THE FIX QUALITY
Record: Obviously correct: the parameter exists only to be stored. One assignment, no API/lock/structure change. Regression risk is low: it uses the directions the callers already requested. Using stricter TX mapping (device read-only) is the intended, safer model.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record: Buggy code from **9a1bb60250d2** (“brcmfmac: Adding msgbuf protocol.”, Hante Meuleman, 2014-07-30). git describe --contains → v3.17-rc1. Field, parameter, and missing store have been this way since introduction. git merge-base --is-ancestor 9a1bb60250d2b HEAD succeeded.
Step 3.2: FOLLOW THE FIXES: TAG
Record: Applied commit has no Fixes tag. Original submission fixes **9a1bb60250d2**, which **is** in this tree. No later intermediate fix stores direction (git log --grep on this file found none).
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: Recent related commit already here: **ddb864ea9ca2e** (“wifi:
brcmfmac: unmap dma buffer in brcmf_msgbuf_alloc_pktid()”) — error-path unmap, still using pktids->direction. Standalone; not part of a numbered series.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Can Peng has **no** other commits in this 5.15 brcm80211 history. Arend van Spriel is the listed brcm80211 maintainer (MAINTAINERS) and **Acked-by** the patch.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: No new helpers. The one-line store applies on the existing kcalloc/kzalloc function. **Standalone.**
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record: b4 dig -c on this tree cannot target the mainline SHA (commit not present). lore.kernel.org fetch returned 403. Thread recovered from:
- https://lists.openwall.net/linux-kernel/2026/07/24/732 (v1 submission)
- https://lkml.iu.edu/hypermail/linux/kernel/2608.0/00969.html (Ack)
Single revision. No NAK. Maintainer ack only.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: To: Arend van Spriel. Cc: linux-wireless, brcm80211 lists, linux-kernel, **[email protected]**. Ack from the brcm80211 maintainer. Applied by Johannes Berg.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla/user crash in the message. Bug is from code inspection (parameter never stored).
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone 1-line patch, not N/M.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: Author Cc’d stable on submission. Targeted lore.kernel.org/stable search did not return a later rejection thread (lore 403 / search noise). **UNVERIFIED:** no explicit stable-list NAK found.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: brcmf_msgbuf_init_pktids() only. Consumers of the field:brcmf_msgbuf_alloc_pktid, brcmf_msgbuf_get_pktid, brcmf_msgbuf_release_array.
Step 5.2: TRACE CALLERS
Record:
- Init: brcmf_proto_msgbuf_attach() → TX DMA_TO_DEVICE, RX DMA_FROM_DEVICE.
- Alloc: TX from brcmf_msgbuf_txflow; RX from brcmf_msgbuf_rxbuf_data_fill and ioctl/event buffer post.
- Get/unmap: TX status and RX complete paths.
Hot path for **PCIe** brcmfmac (CONFIG_BRCMFMAC_PCIE selects BRCMFMAC_PROTO_MSGBUF). SDIO/USB use BCDC, not this file.
Step 5.3: TRACE CALLEES
Record: dma_map_single / dma_unmap_single with pktids->direction.
Step 5.4: FOLLOW THE CALL CHAIN
Record: Userspace networking on Broadcom FullMAC **PCIe** WiFi (TX/RX). Unprivileged traffic hits this path. Not an init-only leak.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: All four map/unmap sites in this file already use pktids->direction. No second missing store.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: **Yes.** msgbuf.c lines 294–313 omit the store. Introduced in v3.17, present for the entire 5.15 lifetime. git log --grep="Set DMA direction for msgbuf" on this file is empty.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **Clean apply** of the one added line. Context around allocators differs (kcalloc vs mainline kzalloc_objs); do not transplant the mainline hunk blindly—only add pktids->direction = direction;.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: Only the 2022 unmap-on-alloc-failure fix (ddb864ea9ca2e). Direction is still unset.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: **wifi / brcmfmac msgbuf (PCIe).** **IMPORTANT** — common laptop/embedded Broadcom FullMAC PCIe devices, not core mm/VFS.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mature driver (msgbuf since 2014). File still gets targeted fixes; this is an old latent bug, not churn from a new API.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: **Driver-specific / config-specific:** CONFIG_BRCMFMAC + CONFIG_BRCMFMAC_PCIE (msgbuf). Not SDIO/USB BCDC. Enabled in several ARM/arm64 defconfigs; widely used on x86 laptops with Broadcom PCIe WiFi.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Every TX map and RX buffer post for msgbuf. Common path. Unprivileged traffic can trigger it. Not a rare race.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- **IOMMU:** TX buffers mapped writable to the device → expanded DMA attack surface / isolation bug. **HIGH** (security-relevant).
- **Non-coherent / bounce DMA:** extra or wrong sync/copy vs the documented TX/RX directions → possible packet corruption. **HIGH** if it hits; **MEDIUM** on typical coherent x86 without IOMMU (BIDIRECTIONAL is documented to “work” at a cost).
- No oops in the commit message. Severity still **HIGH** because DMA permission and coherency are real user-visible classes, not style.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record: **Benefit: high** (correct DMA direction on every packet for a common WiFi driver; tighter IOMMU perms on TX). **Risk: very low** (one assignment of an already-passed enum). **Ratio: strongly favors backport.**
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
**FOR:**
- Real, long-standing bug: direction parameter never stored; field stays DMA_BIDIRECTIONAL.
- Code is in this 5.15 tree (9a1bb60250d2 is an ancestor).
- One-line, obviously correct, no new API.
- IOMMU maps BIDIRECTIONAL as R+W; TX should be device-read-only.
- DMA API requires precise TX/RX directions for networking.
- Maintainer Acked-by; original submission had Fixes + Cc: stable (dropped on apply).
- Applies here with only the one store.
**AGAINST:**
- No crash/syzbot report; driver has “worked” since 2014 on many coherent platforms.
- Affects PCIe msgbuf only, not all brcmfmac buses.
**UNRESOLVED:**
- Could not b4 dig the mainline SHA (not in this checkout); lore.kernel.org HTTP 403.
- No evidence of a stable-list rejection.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — missing store; maintainer ack.
2. Fixes a real bug that affects users? **PASS** — wrong DMA direction on live TX/RX.
3. Important issue (crash, security, corruption, deadlock)? **PASS** — IOMMU write on TX buffers; coherency/bounce mismatch.
4. Small and contained? **PASS** — +1 line, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — add the assignment after pktids->array_size = nr_array_entries;.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Not a device-ID/quirk/DT/docs exception. Ordinary correctness fix.
Step 9.4: MAKE YOUR DECISION
Backport. The bug exists in 5.15, the fix is the intended store of an existing parameter, and DMA direction is not optional cosmetics: it controls IOMMU prot and cache/bounce behavior on a production WiFi datapath.
What it solves for stable users: PCIe brcmfmac currently maps TX and RX SKBs as bidirectional. That grants the device write access to TX buffers under IOMMU and uses the wrong sync/bounce path. Storing the caller direction restores DMA_TO_DEVICE / DMA_FROM_DEVICE as the attach path already requests.
Risk vs benefit: one assignment vs a persistent DMA-permission/coherency bug. No prerequisites beyond code already in this tree.
Verification:
- [Phase 1] Tags on applied commit: Acked-by Arend van Spriel, Link msgid, SOBs Can Peng / Johannes Berg; no Fixes/Cc in applied text
- [Phase 1] Original mail: Fixes 9a1bb60250d2, Cc:
[email protected] (openwall 2026-07-24)
- [Phase 2] Diff: +1 line pktids->direction = direction; in brcmf_msgbuf_init_pktids
- [Phase 2] Local dma-direction.h: DMA_BIDIRECTIONAL = 0
- [Phase 2] dma_info_to_prot: BIDIRECTIONAL → READ|WRITE; TO_DEVICE → READ
- [Phase 3] git blame: missing store since 9a1bb60250d2 (v3.17-rc1)
- [Phase 3] git merge-base --is-ancestor 9a1bb60250d2b HEAD: yes
- [Phase 3] This fix not in tree (git log --grep empty on msgbuf.c)
- [Phase 3] Related: ddb864ea9ca2e already in tree; still uses unset direction
- [Phase 4] b4 dig: cannot run on missing mainline SHA; lore 403
- [Phase 4] Thread: v1 only; Ack 2026-08-02; no NAK
- [Phase 5] Callers: attach + TX flow + RX/ioctl/event buffer post; PCIe msgbuf hot path
- [Phase 6] git describe HEAD: p-5.15-2-g6703e5d2f3a29; make kernelversion: 5.15.221
- [Phase 6] Local init still lacks the store (lines 310–313)
- [Phase 8] Failure: wrong DMA dir / IOMMU TX writable; severity HIGH
- UNVERIFIED: full lore.kernel.org thread via b4; explicit stable-list NAK (none found)
**YES**
drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c +1 -0
@@ -310,6 +310,7 @@ brcmf_msgbuf_init_pktids(u32 nr_array_entries, } pktids->array = array; pktids->array_size = nr_array_entries; + pktids->direction = direction;return pktids; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/conexant: Add pin config quirk for Huawei Matebook
In reply to Sasha LevinFrom: Zhang Heng <[email protected]>
[ Upstream commit d152afd1cd7a69c752236b6e825c4e62a74788eb ]
The headphone jack is not detected on this Huawei Matebook (Conexant SN6140 codec). The BIOS incorrectly marks Pin 0x18 as [N/A], causing the driver to report hp_outs=0 and no "Headphones" output appears.
Override the pin configuration for NID 0x18 to set it as a headphone jack, which restores proper detection and audio routing.
---
LLM Generated explanations, may be completely bogus:
Local tree is **6.12.111** (pending-6.12). This is a Conexant SN6140 pin-config quirk for one Huawei PCI/codec SSID; the driver and SN6140 support are already here.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ALSA hda/conexant] [Add] pin config quirk for Huawei Matebook
Subsystem: ALSA HD-audio Conexant codec. Action: add a hardware quirk (not a feature). Intent: restore headphone jack detection on a specific laptop whose BIOS marks the jack pin as N/A.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Link: https://github.com/thesofproject/sof/issues/10687 — user bug report with codec dump
- Signed-off-by: Zhang Heng <[email protected]> — author
- Signed-off-by: Takashi Iwai <[email protected]> — ALSA maintainer applied it
- `Link:
https://patch.msgid.link/[email protected]`
— lore msgid; **patch 4/4** of a series
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, `Cc:
stable` (absence expected for this review)
- Ignore any pipeline Signed-off-by: Sasha Levin / [Upstream commit …]
Notable: GitHub issue is a concrete user report, not syzbot. Maintainer SOB is a strong quality signal.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** Huawei Matebook, Conexant SN6140. BIOS marks pin NID 0x18 as [N/A].
- **Symptom:** driver reports hp_outs=0; no "Headphones" sink; sound stays on internal speakers when a 3.5mm jack is plugged in.
- **Root cause:** wrong pin default so autoconfig never classifies a headphone output.
- **Fix:** override NID 0x18 to pin config 0x03211020 (headphone jack).
- **Version info in message:** none. GitHub issue (followed in Phase 4) used **Debian 13, kernel 6.12.73**.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a hidden fix. It is an explicit hardware quirk for a broken BIOS pin config. That is the documented stable exception for codec/PCI quirks.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File in the commit: sound/hda/codecs/conexant.c (+9 / −0)
- Local 6.12 path: sound/pci/hda/patch_conexant.c (codecs had not been moved yet)
- Functions/data: enum { … } last entry; cxt_fixups[]; cxt5066_fixups[]
- Scope: single-file surgical quirk; three tiny hunks
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
1. Enum: add CXT_FIXUP_HUAWEI_MATEBOOK_HP after CXT_FIXUP_ACER_SWIFT_HP (already the last entry in this tree at line 309).
2. cxt_fixups[]: HDA_FIXUP_PINS table { 0x18, 0x03211020 }.
3. cxt5066_fixups[]: SND_PCI_QUIRK(0x19e5, 0x3289, …) inserted after the Lenovo vendor catch-all and before Lemote 0x1c06.
Before: SN6140 probe hits default: in patch_conexant_auto(), picks cxt5066_fixups, no Huawei entry, BIOS pin 0x18 (0x40f001f0, connectivity N/A) is parsed, hp_outs=0.
After: SSID 19e5:3289 selects the new fixup. snd_hda_apply_fixup(PRE_PROBE) calls snd_hda_apply_pincfgs() and overrides pin 0x18 before snd_hda_parse_pin_defcfg().
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Hardware quirk / pin-config workaround (category h).** BIOS advertises the headphone pin as unconnected. The driver then never creates a Headphones path or jack-based speaker mute. Override is the standard HDA fix (HDA_FIXUP_PINS), same pattern as Acer Swift SF314 and Lenovo IdeaPad Slim 5 already in this file.
Pin default 0x03211020 = Jack, external left, HP Out, 1/8" stereo, black, association 2. Matches the GitHub user’s working hda-jack- retask firmware.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct and minimal. Scoped to one SSID. SND_PCI_QUIRK_VENDOR(0x17aa, …) cannot match Huawei 0x19e5. Regression risk is limited to machines that share 19e5:3289 and need a *different* pin 0x18 role — standard quirk risk, same as other SSID entries. No locking, no API, no extra module parameter.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: The bug is missing a table entry, not a newly introduced logic bug. SN6140 IDs exist since ca348e7fe1ab9 ("add a new hda codec SN6140") — **ancestor of this HEAD**. Pin parse / HDA_FIXUP_PINS is old (2011-era enum terminator still blamed on Takashi Iwai). Insertion
neighbors: Acer Swift (Feb 2026, already backported here as ab6a494abecb8b), Lemote quirks from 2012.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Expected. Nothing to follow. The “bug” is a BIOS pin default, not a kernel regression SHA.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES** Record (this tree, sound/pci/hda/patch_conexant.c):
- 775911e09ec28 pin config quirk for Lenovo IdeaPad Slim 5 16AKP10 (SN6140)
- ab6a494abecb8b Acer Swift headphone pin tweak
- 6e1664116a9609 MECHREVO headset-mic quirk
Same class of backports already landed in 6.12.y.
Standalone vs series: submitted as **4/4**. Patches 1–3 are Realtek alc269.c quirks for unrelated SSIDs. This hunk does not use any of them.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Zhang Heng has other ALSA quirk work in this tree (Realtek + Conexant mic-bias). Not the subsystem maintainer. Takashi Iwai applied the patch. That is the usual path for HDA quirks.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs existing HDA_FIXUP_PINS, cxt_fixups[], cxt5066_fixups[], SN6140 0x14f11f87, and snd_hda_pick_fixup(). All present. Does **not** need CXT_FIXUP_LENOVO_XPAD_ACPI (mainline context only). Can apply standalone with a path rename plus one-line context fuzz on the Lenovo vendor quirk string.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 am on msgid [email protected] matched the series:
https://patch.msgid.link/[email protected]
- Public copies: https://lists.openwall.net/linux-kernel/2026/08/07/1129
and https://lkml.iu.edu/hypermail/linux/kernel/2608.0/13447.html
- Single revision of this series (no v2 of 4/4 in the thread b4 analyzed)
- b4 dig -c on this SHA was not possible: the commit is not in this 6.12 object graph
- No NAK in the saved series mbox. Applied by Takashi (SOB on the commit under review)
- Lore HTTP fetch returned 403; used b4 + openwall/lkml mirrors instead
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 am headers): To [email protected]; Cc linux- [email protected], [email protected]. Correct maintainer and list. No extra Reviewed-by on the patch itself; maintainer SOB is the review signal.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record — GitHub thesofproject/sof#10687 (closed):
- Author ciniap, 2026-04-07; **Kernel 6.12.73+deb13-amd64**, Intel Alder Lake-P Huawei, SOF sof-hda-generic-2ch.tplg
- Codec dump: Node 0x18 Pin Default 0x40f001f0: [N/A]; dmesg hp_outs=0
- User fixed it with firmware pin override { 0x18 0x03211020 } — **same value as this patch**
- Impact: speakers stay on with headphones; no private listening
- Zhang Heng later commented that the upstream patch was sent
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 1/4 Acer Nitro Realtek headset mic; 2/4 Acer Gadget E10 speaker pin; 3/4 ASUS Vivobook Realtek headset mic; 4/4 this Conexant Huawei pincfg. Independent table rows. 4/4 does not need 1–3.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search returned 403. No evidence in-tree that this Huawei SSID was already selected. Similar Conexant pin quirks **were** already pulled into this 6.12 branch.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: No function bodies edited. Data consumed by snd_hda_pick_fixup(), __snd_hda_apply_fixup() / HDA_FIXUP_PINS, snd_hda_apply_pincfgs(), patch_conexant_auto().
**Step 5.2: TRACE CALLERS**
Record: patch_conexant_auto() is the SN6140 probe (HDA_CODEC_ENTRY(0x14f11f87, "SN6140", patch_conexant_auto)). Default branch uses cxt5066_fixups. Probe-time only, not IRQ/hot path.
**Step 5.3: TRACE CALLEES**
Record: snd_hda_codec_set_pincfg() per pin; then snd_hda_parse_pin_defcfg() / snd_hda_gen_parse_auto_config() build Headphones and auto-mute.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace-visible on boot of that laptop (codec probe). Original report is plugging headphones. Unprivileged user can trigger the broken behavior; the quirk itself is not a syscall attack surface.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same file already has CXT_FIXUP_ACER_SWIFT_HP ({ 0x16, 0x0321403f }) and Lenovo Slim 5 SN6140 pincfg. Realtek uses 0x03211020 widely for HP Out. Pattern is established.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** Tree is v6.12.111 (pending-6.12).
- Driver: sound/pci/hda/patch_conexant.c
- SN6140: HDA_CODEC_ENTRY(0x14f11f87, "SN6140", patch_conexant_auto) and is_cx11880_sn6140 for 0x14f11f87
- No CXT_FIXUP_HUAWEI_MATEBOOK_HP, no 0x19e5 in this file
- Reporter’s kernel was **6.12.73** — this series
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Minor conflicts, not a rewrite.**
- Path: sound/hda/codecs/conexant.c → sound/pci/hda/patch_conexant.c
- Enum/fixup table context matches (CXT_FIXUP_ACER_SWIFT_HP is last)
- Quirk-table context: 6.12 still has SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI) vs mainline Thinkpad/Ideapad + CXT_FIXUP_LENOVO_XPAD_ACPI. Insert still goes before SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", …).
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No Huawei Matebook Conexant pincfg. Acer Swift / IdeaPad Slim 5 / MECHREVO are different SSIDs. Not a duplicate.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: sound/pci/hda Conexant codec. **IMPORTANT** (common laptop audio), not core mm/VFS. User-visible breakage for that hardware.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Active enough that 6.12 already received several Conexant quirks in 2026. Mature table; this is another row, not a redesign.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver-specific / SSID-specific: Huawei machines with PCI or codec SSID **19e5:3289** and SN6140. snd_hda_pick_fixup() matches PCI SSID first, then codec SSID, so the GitHub codec SSID 0x19e53289 is covered even on SOF (ehdaudio0D0).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Every boot on that SKU; 100% repro in the bug report when plugging 3.5mm headphones. Not a race. Unprivileged user hits it by using the jack.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Headphones not enumerated; speakers keep playing. Not an oops/UAF. **MEDIUM** functional/hardware-enablement failure, the class stable already takes as audio quirks. Privacy impact (cannot mute speakers via jack) is real.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: high for that SKU (headphones/auto-mute restored); reporter was on 6.12.
- Risk: very low (≈9 lines, one SSID, existing HDA_FIXUP_PINS machinery).
- Ratio: strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real hardware bug with codec dump and 100% repro
- Reporter on **6.12.73**, this tree’s series
- Same pin value the user already verified via jack retask
- Textbook HDA pin quirk (stable exception)
- ~9 lines, no new API
- SN6140 + quirk tables already in 6.12
- Maintainer SOB (Takashi Iwai)
- Sibling Conexant pin quirks already in this branch
- Independent of series patches 1–3
AGAINST:
- Not a crash/security issue
- Path + one-line context need a trivial backport
- SSID-wide pin override could theoretically mis-configure another board sharing 19e5:3289 (normal quirk caveat; no such report found)
UNRESOLVED:
- Full lore thread replies (b4 mbox failed to write the file); no NAK found in the series mbox
- Stable list 403; no prior rejection found
- Exact Matebook marketing name beyond SSID 19e5:3289
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — standard pincfg; user- validated override; maintainer applied
2. Fixes a real bug that affects users? **PASS** — GitHub #10687, Debian 6.12
3. Important issue? **PASS** as hardware-enablement/quirk (headphones dead; speakers stay on), not CRITICAL oops
4. Small and contained? **PASS** — 9 lines, one file
5. No new features or APIs? **PASS** — table entry only
6. Can apply to the local tree? **PASS** — content matches; remap path to patch_conexant.c; fuzz the 17aa vendor line
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Hardware quirk/workaround** (HDA pin-config / PCI SSID quirk). Also the “device ID / quirk table” class used constantly in stable audio.
**Step 9.4: MAKE YOUR DECISION**
This belongs in this 6.12 tree. The Conexant SN6140 driver is here, the BIOS bug is here, and the original report is this stable series. Backport with the usual path adjustment.
Verification:
- [Phase 1] Tags: GitHub sof#10687, msgid 4/4, SOB Zhang Heng + Takashi Iwai; no Fixes/Cc:stable
- [Phase 1] Body: BIOS pin 0x18 N/A → hp_outs=0; override 0x03211020
- [Phase 2] Diff: +9 lines, enum + cxt_fixups + cxt5066_fixups; HDA_FIXUP_PINS
- [Phase 3] git merge-base --is-ancestor ca348e7fe1ab9 HEAD → SN6140 in tree (exit 0)
- [Phase 3] git log on patch_conexant.c: Acer Swift, IdeaPad Slim 5, MECHREVO already backported
- [Phase 3] Series 1–3 are Realtek-only; 4/4 standalone
- [Phase 4] b4 am found 4-patch series; openwall/lkml copies of 4/4; no NAK in series mbox
- [Phase 4] sof#10687: kernel 6.12.73, pin dump 0x40f001f0, working override 0x03211020
- [Phase 4] lore.kernel.org WebFetch 403; b4 dig -c N/A (commit not in this repo); b4 mbox traceback on output path
- [Phase 5] patch_conexant_auto default → cxt5066_fixups; PRE_PROBE snd_hda_apply_pincfgs
- [Phase 5] snd_hda_pick_fixup matches PCI SSID then codec SSID
- [Phase 6] git describe HEAD → p-6.12-3-g710455e2077bb; Makefile 6.12.111; file sound/pci/hda/patch_conexant.c
- [Phase 6] No 0x19e5 / CXT_FIXUP_HUAWEI in local conexant driver
- [Phase 6] Enum last entry is CXT_FIXUP_ACER_SWIFT_HP (clean insert); quirk insert before Lemote 0x1c06
- [Phase 8] Failure: missing Headphones + no auto-mute; severity MEDIUM; SSID-scoped
- UNVERIFIED: complete lore reply set after maintainer apply; whether any other SKU shares 19e5:3289 with a different pin 0x18 role
The patch is a small, SSID-scoped HDA pin quirk for a real headphone- detection failure that was reproduced on 6.12. It matches stable’s hardware-quirk exception and applies here with only a path remap.
**YES**
sound/hda/codecs/conexant.c | 9 +++++++++ 1 file changed, 9 insertions(+)
sound/hda/codecs/conexant.c +9 -0
@@ -298,6 +298,7 @@ enum {CXT_PINCFG_TOP_SPEAKER ,CXT_FIXUP_HP_A_U ,CXT_FIXUP_ACER_SWIFT_HP , + CXT_FIXUP_HUAWEI_MATEBOOK_HP, };/* for hda_fixup_thinkpad_acpi() */
@@ -1043,6 +1044,13 @@ static const struct hda_fixup cxt_fixups[] = { { } }, }, + [CXT_FIXUP_HUAWEI_MATEBOOK_HP ] = { + .type =HDA_FIXUP_PINS , + .v.pins = (const struct hda_pintbl []) { + {0x18 ,0x03211020 },/* Headphone */ + { } + }, + }, };static const struct hda_quirk cxt5045_fixups[] = {
@@ -1143,6 +1151,7 @@ static const struct hda_quirk cxt5066_fixups[] = {SND_PCI_QUIRK (0x17aa ,0x3978 ,"Lenovo G50-70" ,CXT_FIXUP_STEREO_DMIC ),SND_PCI_QUIRK (0x17aa ,0x397b ,"Lenovo S205" ,CXT_FIXUP_STEREO_DMIC ),SND_PCI_QUIRK_VENDOR (0x17aa ,"Thinkpad/Ideapad" ,CXT_FIXUP_LENOVO_XPAD_ACPI ), +SND_PCI_QUIRK (0x19e5 ,0x3289 ,"Huawei Matebook" ,CXT_FIXUP_HUAWEI_MATEBOOK_HP ),SND_PCI_QUIRK (0x1c06 ,0x2011 ,"Lemote A1004" ,CXT_PINCFG_LEMOTE_A1004 ),SND_PCI_QUIRK (0x1c06 ,0x2012 ,"Lemote A1205" ,CXT_PINCFG_LEMOTE_A1205 ), SND_PCI_QUIRK(0x1d05, 0x3012, "MECHREVO Wujie 15X Pro", CXT_FIXUP_HEADSET_MIC),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 drm/panel: simple: Add Kyocera tcg070wvlq panel
In reply to Sasha LevinFrom: Heiko Schocher <[email protected]>
[ Upstream commit 900517da69afca6f72dacf14278aee3b65275507 ]
Commit 922fb2db0287 ("dt-bindings: display: simple: Add Kyocera tcg070wvlq panel") added the compatible string for the Kyocera tcg070wvlq panel to the devicetree bindings documentation (panel-simple.yaml), but the corresponding entry was not added to the panel-simple driver.
Add the missing compatible entry to the driver.
---
LLM Generated explanations, may be completely bogus:
The local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). This commit is a 3-line of_device_id addition to the existing panel- simple driver. Official stable rules allow that class of change.
## Phase 1: Commit message forensics
**Step 1.1:** Record: [drm/panel: simple] [Add] [register OF compatible kyo,tcg070wvlq, reusing existing lg_lb070wv8 descriptor]
**Step 1.2:** Record: tags present:
- Reviewed-by: Neil Armstrong (drm/panel maintainer)
- Signed-off-by: Heiko Schocher (author); Neil Armstrong (applied to drm-misc)
- Link: https://patch.msgid.link/[email protected]
- No Fixes:, Reported-by, Tested-by, Cc: stable, or syzbot (absence expected)
Ignored pipeline markers: none in the provided text beyond the usual evaluation context.
**Step 1.3:** Record:
- Bug: commit 922fb2db0287 (v5.12-rc1) documented kyo,tcg070wvlq in panel-simple.yaml but never added the matching of_device_id entry.
- Symptom: a DT node whose only compatible is kyo,tcg070wvlq does not bind to panel-simple.
- Version info: bindings since v5.12; driver entry added 2026-07-22.
- Root cause: incomplete match-table vs documented binding, not a crash path.
**Step 1.4:** Record: Not a hidden crash/UAF/leak fix. It is hardware-ID enablement. The 2021 bindings commit said the panel “seems to be compatible with lg,lb070wv8” and added the string “only to the dt- binding documentation to fix the checkpatch warnings.”
## Phase 2: Diff analysis
**Step 2.1:** Record: drivers/gpu/drm/panel/panel-simple.c +3/−0. Function/table: platform_of_match[]. Scope: single-file surgical match-table insert.
**Step 2.2:** Record: Before, kyo,tcg070wvlq was not in platform_of_match. After, it matches and uses &lg_lb070wv8 (same timings/size/bus as lg,lb070wv8).
**Step 2.3:** Record: category **h) hardware / device ID**. Mechanism:
documented OF compatible now matches the existing panel descriptor.
**Step 2.4:** Record: Obviously correct (alias of an existing descriptor). Minimal. Regression risk very low: in-tree imx6dl- prtmvt.dts already has fallback lg,lb070wv8 pointing at the same data, so probe behavior is unchanged there.
## Phase 3: Git history
**Step 3.1:** Record: Missing driver ID is the gap left by 922fb2db0287 (v5.12-rc1). lg_lb070wv8 itself is dd0150026901b (v4.2-rc1). In-tree DTS usage is f3604ba14bd75e (v5.12-rc1):compatible = "kyo,tcg070wvlq", "lg,lb070wv8".
**Step 3.2:** Record: No Fixes: tag. The referenced bindings commit is an ancestor of HEAD.
**Step 3.3:** Record: Standalone; not patch X/Y. Nearby panel-simple commits are other panel IDs, not prerequisites.
**Step 3.4:** Record: Heiko originally added lg_lb070wv8 (2015) and this ID (2026). Neil Armstrong reviewed and applied it. Maintainer- acked.
**Step 3.5:** Record: Depends only on lg_lb070wv8 and platform_of_match, both present here. Applies standalone.
## Phase 4: Mailing list / external
**Step 4.1:** Record: b4 dig → v1 only,
https://patch.msgid.link/[email protected].
Thread: Heiko submit → Neil Reviewed-by → applied to drm-misc-next as 900517da69afc. No NAK, no stable discussion, no requested revisions.
**Step 4.2:** Record: Recipients included Neil Armstrong, Maxime Ripard, dri-devel, DRM maintainers, original bindings author Oleksij Rempel.
**Step 4.3:** Record: No bugzilla/syzbot. Motivation is binding/driver mismatch, not a crash report.
**Step 4.4:** Record: Single-patch series.
**Step 4.5:** Record: lore.kernel.org/stable search returned 403; no stable-list discussion verified. LKML mirrors confirm review-only thread.
## Phase 5: Code semantics
**Step 5.1:** Record: platform_of_match[] only.
**Step 5.2:** Record: Used as .of_match_table of panel_simple_platform_driver (panel_simple_platform_probe). Probe path on DT match.
**Step 5.3:** Record: Match data is existing lg_lb070wv8 (panel_desc
+ LVDS timings). No new alloc/lock/API.
**Step 5.4:** Record: Reachable when a DT node uses kyo,tcg070wvlq. In-tree board imx6dl-prtmvt already matches via fallback. Userspace does not trigger this except by using that panel.
**Step 5.5:** Record: Same file already has kyo,tcg121xglp and lg,lb070wv8. This is the standard panel-simple ID pattern.
## Phase 6: This checkout
**Step 6.1:** Record: Tree is 7.3.0-rc4. panel-simple.c, lg_lb070wv8, bindings kyo,tcg070wvlq, and DTS fallback all exist. Commit 900517da69afc is already an ancestor of HEAD (merged via drm- misc-next → drm-next before v7.3-rc1). The **match table and descriptor this patch needs are in this tree**.
**Step 6.2:** Record: Clean apply (already applied here). Insertion sits alphabetically between koe,tx31d200vm0baa and kyo,tcg121xglp.
**Step 6.3:** Record: No alternate fix. This *is* the driver-side completion of the v5.12 binding.
## Phase 7: Subsystem context
**Step 7.1:** Record: drivers/gpu/drm/panel — **PERIPHERAL** (one LVDS panel / Protonic MVT i.MX6 board).
**Step 7.2:** Record: panel-simple is mature and still gets ID additions; this is normal hardware enablement, not a new subsystem.
## Phase 8: Impact and risk
**Step 8.1:** Record: Driver/board-specific (CONFIG_DRM_PANEL_SIMPLE, DT with this compatible). Not universal.
**Step 8.2:** Record: Trigger is panel probe. Common for that one industrial board; otherwise only if DT lists kyo,tcg070wvlq. Not a syscall/security path.
**Step 8.3:** Record: Without the ID, a **primary-only** kyo,tcg070wvlq node fails to bind (no display). In-tree DTS still works via lg,lb070wv8. Severity **LOW** as a crash; **hardware enablement** under the device-ID rule.
**Step 8.4:** Record: Benefit = correct match for a documented compatible / existing panel. Risk = very low (3 lines, existing descriptor). Ratio favors taking it: official rules explicitly allow device IDs.
## Phase 9: Synthesis
**Evidence FOR:**
- Documentation/process/stable-kernel-rules.rst in this tree: “It must either fix a real bug that bothers people **or just add a device ID**.”
- Device-ID exception in the review criteria: ID-only change in an existing driver.
- 3 lines, reuses lg_lb070wv8 since v4.2, reviewed by the panel maintainer.
- Completes a compatible documented since v5.12.
**Evidence AGAINST:**
- Not a crash, UAF, deadlock, or corruption fix.
- In-tree imx6dl-prtmvt.dts already falls back to lg,lb070wv8, so this tree’s in-tree board already probes.
- 2021 bindings commit intentionally omitted the driver entry at first.
- No user/syzbot report.
**Unresolved:** Could not fetch lore.kernel.org/stable (403). No evidence this was rejected for stable.
**Stable checklist:**
1. Obviously correct and tested — **PASS** (maintainer Reviewed-by, applied to drm-misc-next)
2. Real bug that affects users — **PASS** as device ID (documented compatible did not match); in-tree fallback means limited user- visible delta
3. Important issue — **PASS via device-ID exception**, not via crash/security
4. Small and contained — **PASS** (+3)
5. No new features/APIs — **PASS** (no new descriptor, timings, or uAPI; match-table ID only)
6. Can apply to this tree — **PASS** (lg_lb070wv8 and platform_of_match present)
**Exception category:** New device ID (OF compatible) on an existing driver.
This is not a stability fix, but it is exactly the “just add a device ID” case the stable rules call out. Risk is negligible.
Verification:
- [Phase 1] Parsed tags: Reviewed-by Neil Armstrong; Link msgid 20260721041935.757240-1; no Fixes/syzbot
- [Phase 2] Diff: +3 in platform_of_match[]; .data = &lg_lb070wv8
- [Phase 3] git name-rev --tags 922fb2db02871 → v5.12-rc1; dd0150026901b → v4.2-rc1; f3604ba14bd75e DTS fallback
- [Phase 3] git merge-base --is-ancestor 922fb2db0287 HEAD exit 0; 900517da69afc ancestor of HEAD
- [Phase 4] b4 dig -c 900517da69afc / -a / -w / -m: v1 only; Neil review + apply; dri-devel CCd
- [Phase 4] lore.kernel.org WebFetch 403; LKML mirrors used instead
- [Phase 5] platform_of_match → panel_simple_platform_driver.of_match_table
- [Phase 6] git describe HEAD → v7.3-rc4-27-gf0100363d8c37; make kernelversion → 7.3.0-rc4
- [Phase 6] Grep: kyo,tcg070wvlq in driver, yaml, and imx6dl- prtmvt.dts
- [Phase 8] Failure mode: unmatched compatible → no panel probe; in-tree DTS still matches fallback
- [Phase 9] Read Documentation/process/stable-kernel-rules.rst lines 15–16: device IDs are allowed
- UNVERIFIED: stable@vger discussion (HTTP 403)
**YES**
drivers/gpu/drm/panel/panel-simple.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/panel/panel-simple.c +3 -0
@@ -5245,6 +5245,9 @@ static const struct of_device_id platform_of_match[] = { }, { .compatible = "koe,tx31d200vm0baa", .data = &koe_tx31d200vm0baa, + }, { + .compatible = "kyo,tcg070wvlq", + .data = &lg_lb070wv8, }, { .compatible = "kyo,tcg121xglp", .data = &kyo_tcg121xglp,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ACPI: FPDT: validate table and record lengths
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit 458b40fcdd04a9a0334830de5a536d8425454e4b ]
FPDT records are supplied by firmware and are walked through length fields stored in the table itself.
Check the main-table entry length before reading an entry, check the mapped subtable length before remapping it, and check each record length before saving a typed record pointer for sysfs.
This keeps malformed firmware records from being interpreted as complete resume, suspend, or boot records when the current item is shorter than the structure consumed by the driver.
---
LLM Generated explanations, may be completely bogus:
I have enough verified history, diff, and review context to judge this against the local 7.3-rc4 tree.
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: **[ACPI / FPDT] [validate] check firmware-supplied FPDT table/record lengths before walking them or exposing typed records via sysfs**
**Step 1.2: Tags**
Record:
- Signed-off-by: Pengpeng Hou <[email protected]> (author)
- `Link:
https://patch.msgid.link/[email protected]`
- Signed-off-by: Rafael J. Wysocki <[email protected]> (ACPI maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, or Cc: stable (absence expected here)
- Ignore any pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] markers
**Step 1.3: Body**
Record:
- **Bug:** FPDT entries/records are walked using length fields supplied by firmware. The driver previously trusted those lengths.
- **Symptom:** A truncated/malformed record can be treated as a full resume, suspend, or boot record. Sysfs then consumes a larger C struct than the firmware item actually occupies.
- **Root cause:** Missing bounds checks before mapping the subtable, before advancing the walker, and before storing typed pointers.
- **Versions:** none stated. Introduced with FPDT support, not by a later feature.
**Step 1.4: Hidden bug fix?**
Record: Not hidden. It is an explicit firmware bounds-check plus a signature-mismatch unmap. That is a real OOB/leak fix, not style cleanup.
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- File: drivers/acpi/acpi_fpdt.c only (+47 / -6)
- Functions: fpdt_process_subtable(), acpi_init_fpdt()
- Scope: single-file surgical fix
**Step 2.2: Code flow**
Record (verified against parent 458b40fcdd04a^):
1. **Signature mismatch:** mapped header was returned without unmap → now unmaps (fixes ioremap leak).
2. **Subtable remap:** length from firmware was passed to acpi_os_map_memory() with no lower bound → reject if length < sizeof(*subtable_header).
3. **Record walk:** header was read and offset += record_header->length before checking remaining space; only zero length was rejected (a83c68a3bf7c4) → require a full header, length >= sizeof(header), and length <= remaining; zero is still rejected because sizeof(*record_header) is 4.
4. **Typed records:** RECORD_S3_RESUME / SUSPEND / BOOT stored pointers used by sysfs (sizeof 24 / 20 / 48) with no size check → reject if the firmware length is smaller than the struct.
5. **Main FPDT table:** walker did offset += sizeof(*subtable) with no leftover-bytes check → reject truncated/invalid entry lengths, then advance by subtable->length (spec length field).
**Step 2.3: Bug mechanism**
Record:
- **Category:** memory safety (OOB read) + resource leak
- **Mechanism:** firmware-controlled lengths were used as cursor and as justification to treat a short blob as a full resume_performance_record / suspend_performance_record / boot_performance_record. Sysfs *_show helpers then read fields past the real record. Truncated headers could also read past the mapped subtable.
**Step 2.4: Fix quality**
Record: Obviously correct, localized, no API/feature change. Regression risk is low. The one behavioral change is walking the main table by subtable->length instead of a fixed 16-byte stride. Spec pointer records are 16 bytes (struct fpdt_subtable_entry / acpi_fpdt_boot_pointer). Firmware with a garbage non-zero length in an otherwise packed 16-byte table could now skip or fail FPDT init instead of parsing later entries; that fails closed (no FPDT sysfs), not a kernel crash. No follow-up on this file after 458b40fcdd04a.
## Phase 3: Git history
**Step 3.1: Blame**
Record: Buggy walker comes from d1eb86e59be09 (“ACPI: tables:
introduce support for FPDT table”, 2021-01-29), first in **v5.12-rc1**. Zero-length hang was later fixed by a83c68a3bf7c4 (2023), which did **not** check truncated non-zero lengths or typed-struct size.
**Step 3.2: Fixes: tag**
Record: none. The incomplete predecessor is a83c68a3bf7c4 (`Fixes:d1eb86e59be0, Cc: stable`). That confirms the class (malformed FPDT firmware) is real; this commit finishes the length checks.
**Step 3.3: File history**
Record (newest first):
- 458b40fcdd04a this commit
- 8dcb4485e7672 expose FBPT/S3PT via sysfs (already in this tree; ancestor of the fix)
- a83c68a3bf7c4 zero-length / invalid subtables
- 211391bf04b3c invalid phys address
- d1eb86e59be09 introduce driver
Standalone length-validation patch, not N/M.
**Step 3.4: Author**
Record: Pengpeng Hou; same period also 2c50ffdc73f3a “ACPI: processor:
validate MADT IOAPIC entry bounds” (same firmware-table bounds pattern). Not the ACPI maintainer; Rafael applied it.
**Step 3.5: Dependencies**
Record: No extra helpers. Needs the FPDT driver (d1eb86e59be09), present here. 8dcb4485e7672 is already an ancestor (git merge-base --is-ancestor succeeded). Can apply in this tree; it is already an ancestor of HEAD.
## Phase 4: Mailing list / external
**Step 4.1:** b4 dig -c 458b40fcdd04a →
https://patch.msgid.link/[email protected]b4 dig -a: **v1 only**. Thread saved to mbox (2 messages).
Rafael: **“Applied as 7.3 material, thanks!”** No NAK, no requested respin, no Cc: stable in review.
**Step 4.2:** b4 dig -w recipients: Pengpeng Hou, Rafael J. Wysocki, Len Brown, linux-acpi, linux-kernel. Maintainer was on To/Cc and merged it.
**Step 4.3:** No bugzilla/syzbot/Reported-by. No extra crash report beyond the commit text. Related real hardware: a83c68a3bf7c4 already documented buggy FPDT BIOS tables (zero-length S3PT record, duplicated FBPT signature).
**Step 4.4:** Not a multi-patch series.
**Step 4.5:** lore.kernel.org/stable search returned HTTP 403. **UNVERIFIED:** whether stable@ discussed this hash.
## Phase 5: Semantic / reachability
**Step 5.1:** fpdt_process_subtable, acpi_init_fpdt.
**Step 5.2:** acpi_init_fpdt is fs_initcall; only caller of fpdt_process_subtable is that init function. Boot path, not interrupt/hot path.
**Step 5.3:** acpi_get_table / acpi_os_map_memory / acpi_os_unmap_memory / sysfs_create_group. Records are later read by sysfs *_show using record_boot / record_suspend / record_resume.
**Step 5.4:** Reachable when CONFIG_ACPI_FPDT=y and firmware publishes FPDT. Userspace cannot craft the ACPI table on a locked-down platform; VMs and broken BIOS can. Sysfs is the consumer of the typed pointers.
**Step 5.5:** Same pattern as the author’s MADT IOAPIC length checks. Prior FPDT fix only handled length==0.
## Phase 6: This checkout
**Step 6.1:** git describe HEAD → **v7.3-rc4-27-gf0100363d8c37**. make kernelversion → **7.3.0-rc4**.git merge-base --is-ancestor 458b40fcdd04a HEAD → yes. Current drivers/acpi/acpi_fpdt.c already contains the new checks (lines 190–219, 223–226, 243–246, 262–265, 347–360, 374). Buggy walker has existed in this lineage since v5.12.
**Step 6.2:** Backport difficulty **clean apply** here (already merged). No later conflicting edits on this file.
**Step 6.3:** Related fix a83c68a3bf7c4 is present (zero-length only). It does not replace this patch.
## Phase 7: Subsystem
**Step 7.1:** ACPI FPDT driver under drivers/acpi/. **IMPORTANT** (common x86_64/ARM64/LOONGARCH firmware table), not mm/core. CONFIG_ACPI_FPDT is opt-in (bool, not default y); local .config has it unset. Not staging.
**Step 7.2:** File is mature (2021–2026, few commits). This is hardening of long-standing parse code, not a brand-new subsystem.
## Phase 8: Impact and risk
**Step 8.1:** Users who enable CONFIG_ACPI_FPDT on x86_64/ARM64/LOONGARCH and whose firmware exposes FPDT. Not universal.
**Step 8.2:** Trigger is boot-time FPDT parse (fs_initcall) with a malformed table. Unprivileged userspace cannot normally inject ACPI tables; broken BIOS and untrusted VM firmware can. Real malformed FPDT firmware is already documented.
**Step 8.3:** Failure mode:
- Read past mapped subtable → possible oops during boot (**HIGH/CRITICAL** if it faults)
- Short record accepted → sysfs reads adjacent firmware bytes (wrong data / info leak, **HIGH** memory-safety)
- Signature-mismatch ioremap leak at init (**LOW**, one-shot)
Severity: **HIGH** (firmware-controlled OOB on an enabled driver).
**Step 8.4:** Benefit high for FPDT-enabled systems with bad tables; risk low (47 lines, fail closed, maintainer-acked, no revert).
## Phase 9: Synthesis
**For backporting**
- Firmware-supplied lengths used as walk cursor and as struct size:
classic OOB.
- Completes a known FPDT firmware-bug class (a83c68a3bf7c4 already proved bad BIOSes and was sent to stable).
- Also fixes a real acpi_os_map_memory leak on signature mismatch.
- Small, single-file, obviously correct; Rafael merged it.
- Driver and buggy code exist in this tree; no missing prerequisites.
**Against**
- No crash log / syzbot / Fixes: / explicit stable nomination.
- CONFIG_ACPI_FPDT is opt-in, not defconfig.
- Rafael labeled it “7.3 material,” not stable, but that is merge-window wording, not a NAK of the bug.
- Main-table walk-by-length could hide later entries if firmware lies about length; fail-closed.
**Unresolved**
- UNVERIFIED: stable@ thread (lore 403).
- UNVERIFIED: which distros set CONFIG_ACPI_FPDT=y.
**Stable rules**
1. Obviously correct and tested? **PASS** (v1 applied as-is by ACPI maintainer; in 7.3-rc4 with no follow-up revert).
2. Real user-affecting bug? **PASS** (OOB + leak on firmware tables; prior FPDT BIOS bugs in the wild).
3. Important (crash/security/corruption/deadlock)? **PASS** (OOB read from firmware lengths; possible oops or sysfs leak).
4. Small/contained? **PASS** (+47/-6, one file).
5. No new features/APIs? **PASS**.
6. Applies to this tree? **PASS**.
**Exception category:** none required (not a device- ID/quirk/DT/build/doc exception). It is a straightforward memory-safety fix.
This tree is **7.3.0-rc4**. The FPDT walker has been here since v5.12, so the bug is in this lineage. The patch is small, correct, and prevents firmware-controlled out-of-bounds reads (and an ioremap leak) in acpi_init_fpdt. That meets stable criteria for this checkout.
### Verification
- [Phase 1] Parsed tags: author SOB, Rafael SOB, msgid Link; no Fixes/Reported-by/Cc stable
- [Phase 2] git show 458b40fcdd04a: +47/-6 in drivers/acpi/acpi_fpdt.c; parent walker lacked remaining/size checks; signature path leaked the map
- [Phase 2] Struct sizes: header 4, resume 24, suspend 20, boot 48, subtable entry 16
- [Phase 3] git blame: checks from 458b40fcdd04a; original walker d1eb86e59be09 (v5.12-rc1)
- [Phase 3] git merge-base --is-ancestor 458b40fcdd04a HEAD → 0 (present)
- [Phase 3] a83c68a3bf7c4 only handled zero length; Cc: stable on that older hang fix
- [Phase 3] 8dcb4485e7672 is ancestor; no later commits on this file
- [Phase 4] b4 dig -c/-a/-w/-m: v1 only; Rafael “Applied as 7.3 material, thanks!”; lists linux-acpi + Rafael + Len Brown
- [Phase 4] lore.kernel.org WebFetch/curl → 403; stable@ discussion UNVERIFIED
- [Phase 5] acpi_init_fpdt is fs_initcall; only caller of fpdt_process_subtable
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; current file already has the validation
- [Phase 7] CONFIG_ACPI_FPDT depends on X86_64||ARM64||LOONGARCH, not default y
- [Phase 8] Failure mode: firmware OOB on FPDT parse / sysfs typed reads
- UNVERIFIED: distro CONFIG_ACPI_FPDT defaults; stable@ mailing-list history
**YES**
drivers/acpi/acpi_fpdt.c | 53 +++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 6 deletions(-)
drivers/acpi/acpi_fpdt.c +47 -6
@@ -165,7 +165,7 @@ static int fpdt_process_subtable(u64 address, u32 subtable_type)struct fpdt_subtable_header *subtable_header;struct fpdt_record_header *record_header;char *signature = (subtable_type ==SUBTABLE_FBPT ?"FBPT" :"S3PT" ); -u32 length, offset; +u32 length, offset, remaining;int result;if (!fpdt_address_valid (address)) {
@@ -179,10 +179,17 @@ static int fpdt_process_subtable(u64 address, u32 subtable_type)if (strncmp ((char *)&subtable_header->signature, signature,4 )) {pr_info (FW_BUG "subtable signature and type mismatch!\n" ); +acpi_os_unmap_memory (subtable_header,sizeof (*subtable_header));return -EINVAL ; } length = subtable_header->length; +if (length <sizeof (*subtable_header)) { +pr_err (FW_BUG "Invalid FPDT subtable length %u.\n" , length); +acpi_os_unmap_memory (subtable_header,sizeof (*subtable_header)); +return -EINVAL ; + } +acpi_os_unmap_memory (subtable_header,sizeof (*subtable_header)); subtable_header =acpi_os_map_memory (address, length);
@@ -191,17 +198,29 @@ static int fpdt_process_subtable(u64 address, u32 subtable_type) offset =sizeof (*subtable_header);while (offset < length) { - record_header = (void *)subtable_header + offset; - offset += record_header->length; + remaining = length - offset; +if (remaining <sizeof (*record_header)) { +pr_err (FW_BUG "Truncated FPDT record header.\n" ); + result = -EINVAL ; + goto err; + } -if (!record_header->length) { -pr_err (FW_BUG "Zero-length record found in FPTD.\n" ); + record_header = (void *)subtable_header + offset; +if (record_header->length <sizeof (*record_header) || + record_header->length > remaining) { +pr_err (FW_BUG "Invalid FPDT record length %u.\n" , + record_header->length); result = -EINVAL ; goto err; } + offset += record_header->length;switch (record_header->type) {case RECORD_S3_RESUME : +if (record_header->length <sizeof (*record_resume)) { + result = -EINVAL ; + goto err; + }if (subtable_type !=SUBTABLE_S3PT ) {pr_err (FW_BUG "Invalid record %d for subtable %s\n" , record_header->type, signature);
@@ -218,6 +237,10 @@ static int fpdt_process_subtable(u64 address, u32 subtable_type) goto err;break ;case RECORD_S3_SUSPEND : +if (record_header->length <sizeof (*record_suspend)) { + result = -EINVAL ; + goto err; + }if (subtable_type !=SUBTABLE_S3PT ) {pr_err (FW_BUG "Invalid %d for subtable %s\n" , record_header->type, signature);
@@ -233,6 +256,10 @@ static int fpdt_process_subtable(u64 address, u32 subtable_type) goto err;break ;case RECORD_BOOT : +if (record_header->length <sizeof (*record_boot)) { + result = -EINVAL ; + goto err; + }if (subtable_type !=SUBTABLE_FBPT ) {pr_err (FW_BUG "Invalid %d for subtable %s\n" , record_header->type, signature);
@@ -289,7 +316,21 @@ static int __init acpi_init_fpdt(void) }while (offset < header->length) { +if (header->length - offset <sizeof (*subtable)) { +pr_err (FW_BUG "Truncated FPDT subtable entry.\n" ); + result = -EINVAL ; + goto err_subtable; + } + subtable = (void *)header + offset; +if (subtable->length <sizeof (*subtable) || + subtable->length > header->length - offset) { +pr_err (FW_BUG "Invalid FPDT subtable entry length %u.\n" , + subtable->length); + result = -EINVAL ; + goto err_subtable; + } +switch (subtable->type) {case SUBTABLE_FBPT :case SUBTABLE_S3PT :
@@ -302,7 +343,7 @@ static int __init acpi_init_fpdt(void)/* Other types are reserved in ACPI 6.4 spec. */ break ; } - offset +=sizeof (*subtable); + offset += subtable->length; }return 0 ; err_subtable:
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ACPI: sysfs: Properly map BERT and CCEL data to their ACPI tables
In reply to Sasha LevinFrom: Thomas Renninger <[email protected]>
[ Upstream commit e45ee607ca6f9f97a2f97be356d844a912971a16 ]
In the case of multiple BERT ACPI tables, one gets:
sysfs: cannot create duplicate filename '/firmware/acpi/tables/data/BERT'
This is because both:
/firmware/acpi/tables/BERT1
/firmware/acpi/tables/BERT2
are attempted to be mapped to the same data table:
/firmware/acpi/tables/data/BERT
Address this problem by passing and using the same filename for data tables.
---
LLM Generated explanations, may be completely bogus:
## Local tree
This checkout is **mainline 7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37, VERSION=7 PATCHLEVEL=3 SUBLEVEL=0 EXTRAVERSION=-rc4). The commit under review is already an ancestor of HEAD as e45ee607ca6f9. The verdict is whether this fix is suitable to backport, based on the code and history in this tree.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[ACPI sysfs] [Properly map] BERT and CCEL data sysfs names to the same instance filenames as the parent ACPI tables.** Subsystem prefix ACPI: sysfs:. “Properly map” is a correctness/fix verb even without “fix”.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected for this review pipeline)
- **Reported-by:** Michal Suchanek <[email protected]> (real distro report)
- **Closes:** https://bugzilla.suse.com/show_bug.cgi?id=1270211
- **Link:** https://patch.msgid.link/[email protected] (patch 2/2 of a series)
- **Cc: stable:** absent (expected; not a negative signal)
- **Signed-off-by:** Thomas Renninger <[email protected]> (author); Rafael J. Wysocki <[email protected]> (ACPI maintainer)
- **[ rjw: Subject and changelog edits ]** — maintainer edited the changelog before applying
- No Tested-by, Reviewed-by, Acked-by, or syzbot tags
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** With more than one BERT table, sysfs tries to create /firmware/acpi/tables/data/BERT twice.
- **Symptom:** sysfs: cannot create duplicate filename '/firmware/acpi/tables/data/BERT'. Table files are BERT1/BERT2; data files were all named BERT.
- **Failure mode:** sysfs_warn_dup() prints that warning and calls dump_stack() at boot. The second BERT (or CCEL) error region is never exported.
- **Version info:** none in the message.
- **Root cause:** acpi_bert_data_init / acpi_ccel_data_init hard- coded the bin-attribute name to "BERT" / "CCEL" instead of using the instance filename already computed for the table.
Cover letter (from the lore mbox) shows real firmware with two BERT tables:
``` ACPI: BERT ... (v01 AMD AMD BERT ...) ACPI: BERT ... (v01 AMI AMI.BERT ...) sysfs: cannot create duplicate filename '/firmware/acpi/tables/data/BERT' ```
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not hidden.** This is an explicit sysfs-name collision fix. It is not cleanup, refactor, or a new feature.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** drivers/acpi/sysfs.c only — **+5 / −4** (9 lines).
- **Functions:** acpi_bert_data_init, acpi_ccel_data_init, acpi_table_data_init, acpi_tables_sysfs_init.
- **Struct:** acpi_data_attr gains filename[].
- **Scope:** single-file surgical fix.
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** acpi_table_attr_init() already builds BERT vs BERT1/BERT2. acpi_table_data_init() then created data files with a hard-coded "BERT" / "CCEL" name.
- **After:** acpi_table_data_init(th, table_attr) copies table_attr->filename into data_attr->filename and uses that as the sysfs name. Data nodes match table nodes (BERT, or BERT1/BERT2).
- **Path:** boot-time ACPI sysfs init only (acpi_tables_sysfs_init). Return value of acpi_table_data_init is still ignored (pre- existing).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Logic / correctness]** Hard-coded sysfs names collide when ACPI has multiple tables of the same signature. Fix: reuse the already- instanced filename. Same pattern for BERT and CCEL.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Quality:** obviously correct. acpi_table_attr_init() runs first and fills table_attr->filename; then acpi_table_data_init() copies it. attr.name points at the heap data_attr->filename buffer, which lives as long as the bin attribute (same lifetime as the old string- literal names).
- **Single-table ABI:** unchanged. Instance suffix is added only when a second table exists (instance > 1 or acpi_get_table(..., 2, ...) succeeds), so a lone BERT still appears as /firmware/acpi/tables/data/BERT.
- **Regression risk:** very low. No locking, no public API, no new sysfs files in the common case.
- **Not introduced here:** if sysfs_create_bin_file() fails, data_attr is still leaked (return value ignored). This patch avoids the duplicate-name failure; it does not add that leak.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- BERT data sysfs: **7dae6326ed764** (“ACPI / sysfs: Extend ACPI sysfs to provide access to boot error region”), Tony Luck, **v4.14-rc1**. Hard-coded "BERT" is from that commit.
- CCEL: **4f855dcead6c5** (“ACPI: sysfs: Enable ACPI sysfs support for CCEL records”), **v6.4-rc1**. Copied the same hard-coded-name pattern.
- Table instance filenames: acpi_table_attr.filename since **1c8fce27e275fd** (v2.6.36-era sysfs) / **3278675567dfb9** (ACPI_NAMESEG_SIZE rename, 2019).
- Buggy pattern has been in tree for years, not last-month code.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Introducer is 7dae6326ed764 (BERT, v4.14) and 4f855dcead6c5 (CCEL, v6.4). Both are ancestors of this HEAD (git merge-base --is-ancestor exit 0).
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Immediate parent: **f45c999e67120** — series patch 1/2, BERT sizeof check (acpi_hest_generic_status → acpi_bert_region). Independent; this patch does not need it.
- No later commits on drivers/acpi/sysfs.c after e45ee607ca6f9 (no follow-up revert or fix).
- **Standalone** as a 2/2 series member: patch 1 is a separate size- check fix.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Thomas Renninger is a long-time ACPI contributor (SUSE). Same- day sibling is only the BERT sizeof patch. Merged by ACPI maintainer Rafael J. Wysocki.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **None required for the naming fix.** It uses existing table_attr->filename, strscpy, and acpi_table_attr_init. kzalloc_obj in surrounding lines is later mainline allocation API and is **not** introduced by this diff. On older trees the same hunks apply around kzalloc. strscpy has been in the kernel since v4.3.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **b4 dig:** series at https://patch.msgid.link/[email protected]
- Cover: [PATCH 0/2] Fix sysfs duplicate filename if multiple BERT tables exist
- This commit is **[PATCH 2/2]** (msgid ...72924-3...). Subject on the list differed slightly from the applied subject (rjw edited it).
- **v2:** cover says previously sent to linux-pm; v2 stopped using acpi_get_table inside data init and instead passes table_attr. Applied version is that v2.
- **Reviewer:** Rafael: “Applied (with some modifications in subjects/changelogs) as 7.3 material, thanks!” No NAK.
- **Stable nomination in review:** none found.
- lore.kernel.org WebFetch returned **403**; thread recovered via b4 dig -m.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: **b4 dig -w** recipients: Thomas Renninger, linux- [email protected], Saket Dumbre (Intel ACPI), Michal Suchanek (reporter). ACPI maintainer applied it. No separate Reviewed-by.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: SUSE bugzilla 1270211 WebFetch **403** (likely login-walled). Cover letter includes the reporter’s dmesg: two BERT tables (AMD + AMI) and the exact sysfs duplicate warning. That is enough to treat it as a real distro hit, not theoretical.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 2-patch series. Patch 1/2 (f45c999e67120) is an independent BERT region-size check. This 2/2 patch does not depend on it.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No stable@ discussion found (lore WebFetch 403; web search did not turn up a stable thread). **UNVERIFIED** whether anyone later asked for or rejected it on stable@.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
Record: acpi_bert_data_init, acpi_ccel_data_init, acpi_table_data_init, acpi_tables_sysfs_init. Struct field added on acpi_data_attr.
**Step 5.2: TRACE CALLERS**
Record:
- acpi_table_data_init — only caller: acpi_tables_sysfs_init
- acpi_tables_sysfs_init — only caller: acpi_sysfs_init (drivers/acpi/sysfs.c)
- acpi_sysfs_init — called from acpi_bus_init() in drivers/acpi/bus.c during ACPI boot
- acpi_sysfs_table_handler (hot-added tables) does **not** call acpi_table_data_init; BERT/CCEL data nodes are boot-only. Confirmed with grep: only those two sites.
**Step 5.3: TRACE CALLEES**
Record: kzalloc_obj / sysfs_attr_init / strscpy / sysfs_create_bin_file / acpi_os_map_iomem (read path). Init-time sysfs creation, then userspace reads of BERT/CCEL error regions.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: ACPI boot → acpi_bus_init → acpi_sysfs_init → acpi_tables_sysfs_init → per-table acpi_table_data_init. Triggered on every ACPI boot that has BERT or CCEL. Userspace RAS tools read /sys/firmware/acpi/tables/data/. Unprivileged users typically cannot read these (mode 0400). The **warning/dump_stack** happens in kernel init regardless.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Only BERT and CCEL are in acpi_data_objs[]. Both had the same hard-coded name. No other ACPI data table types in this file.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** BERT data sysfs since v4.14 (7dae6326ed764, ancestor). CCEL since v6.4 (4f855dcead6c5, ancestor). The fix is already applied here as e45ee607ca6f9. The bug is old, not introduced after 7.3 branched.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean / minor context.** Hunks are localized. Older trees may still use kzalloc instead of kzalloc_obj (adjacent lines only). Pre-v6.4 trees have no CCEL function; BERT hunks still apply. strscpy and filename on acpi_table_attr are present in long-term stables.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This is the fix. No earlier equivalent. No later follow-up on this file.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM**
Record: **ACPI sysfs** (drivers/acpi/sysfs.c). **IMPORTANT** (not mm/core, but ACPI boot sysfs on essentially all x86 and many ARM servers). BERT is RAS/boot-error; CCEL is confidential-computing event log.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature. BERT data mapping has been stable since 2017. Occasional sysfs/BERT/CCEL fixes, not high churn.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Record: **Firmware-specific.** Systems with **two or more BERT** (or CCEL) tables. Cover letter shows a real AMD + AMI dual-BERT OEM firmware. Single-table systems are unaffected (same sysfs name as before). CONFIG_ACPI.
**Step 8.2: TRIGGER CONDITIONS**
Record: **Every boot** on affected firmware. Not a race. Not unprivileged-triggerable for the data read (0400), but the kernel dump_stack() is automatic at init.
**Step 8.3: FAILURE MODE SEVERITY**
Record:
- sysfs_warn_dup() → pr_warn + **dump_stack()** (fs/sysfs/dir.c). Looks like a kernel bug in dmesg; panic_on_warn would panic (unverified whether any of these machines set that).
- Second BERT/CCEL error region is not in sysfs, so RAS tools can miss boot errors.
- Boot continues; acpi_table_data_init return is ignored.
- **Severity: MEDIUM** (boot warning + missing diagnostic RAS data). Not oops/corruption/deadlock, but a real distro-reported “oh, that’s not good” bug.
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit:** medium-high for dual-BERT firmware (every boot warning gone; both error regions exported). Zero change for the common single- table case.
- **Risk:** very low (5 insertions / 4 deletions, init-only naming).
- **Ratio:** favorable.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**For backporting:**
- Real bug on real hardware (AMD BERT + AMI BERT), SUSE bugzilla + dmesg.
- dump_stack() on every boot; second error region missing from sysfs.
- Tiny, obviously correct, ACPI-maintainer merged, v2 after review.
- Bug present since v4.14 (BERT) / v6.4 (CCEL).
- No new APIs; single-table sysfs ABI unchanged.
- Standalone; does not need series patch 1/2.
- Matches stable-kernel-rules: a real bug that bothers distro users, and an “oh, that’s not good” sysfs warning.
**Against:**
- Not a panic, UAF, deadlock, or data-corruption bug in normal configs.
- Only dual BERT/CCEL firmware hits it (uncommon, but not fictional).
- No Cc: stable (not a negative signal here).
- Rafael called it “7.3 material” without mentioning stable.
**Unresolved:**
- SUSE bugzilla body (403).
- Whether stable@ ever discussed this (403 / no hits).
- Whether affected machines use panic_on_warn.
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — naming logic is local and matches existing instance filenames; maintainer applied v2; reporter provided dmesg.
2. Fixes a real bug that affects users? **PASS** — distro report, dump_stack, missing BERT data node.
3. Important issue? **PASS** (medium) — boot dump_stack plus inaccessible RAS region; rules explicitly include “oh, that’s not good” and distro-reported issues.
4. Small and contained? **PASS** — 9 lines, one file.
5. No new features or APIs? **PASS** — corrects names of existing sysfs nodes.
6. Can apply to the local tree? **PASS** — already in this 7.3-rc4 tree; backport to older stables is clean or BERT-only on pre-CCEL trees.
**Step 9.3: EXCEPTION CATEGORIES**
Record: None (not a device ID, quirk, DT, build, or docs patch). Qualifies as a normal small bugfix.
**Step 9.4: DECISION**
This is a small, correct fix for a user-visible boot warning and a real RAS sysfs hole on multi-BERT firmware. The code has been wrong since v4.14, the patch is surgical, and the common single-table ABI is unchanged. That meets stable criteria.
---
## What the commit solves (for stable users)
On machines whose firmware publishes **two BERT tables** (seen with AMD
+ AMI), the kernel already creates /sys/firmware/acpi/tables/BERT1 and BERT2, but both data mappings used the name BERT. sysfs_create_bin_file() fails, sysfs_warn_dup() dumps a stack at every boot, and the second boot-error region is never exposed. The same bug exists for multiple CCEL tables. The fix copies the table’s instance filename onto the data node.
## Risk vs benefit
Benefit is removing a boot dump_stack and exporting all BERT/CCEL regions on affected firmware. Risk is negligible: init-only string copy, no locking, no ABI change when there is only one table.
## Concerns
Older stables without CCEL need the CCEL hunk dropped; BERT hunks still apply. Adjacent kzalloc_obj is not part of this patch. Series patch 1/2 is optional, not a prerequisite.
---
## Verification
- **[Phase 1]** Parsed tags: Reported-by Michal Suchanek (SUSE), Closes bugzilla 1270211, Link patch 2/2, SOB author + Rafael; no Fixes/stable/syzbot.
- **[Phase 2]** git show e45ee607ca6f9: drivers/acpi/sysfs.c +5/−4; add filename, stop hard-coding "BERT"/"CCEL", pass table_attr.
- **[Phase 2]** Read acpi_table_attr_init (instance suffix) and acpi_tables_sysfs_init (attr_init then data_init).
- **[Phase 2]** Read sysfs_warn_dup in fs/sysfs/dir.c: pr_warn + dump_stack().
- **[Phase 3]** Blame: BERT data 7dae6326ed764 (v4.14-rc1), CCEL 4f855dcead6c5 (v6.4-rc1).
- **[Phase 3]** git merge-base --is-ancestor 7dae6326ed764 HEAD and 4f855dcead6c5 HEAD and e45ee607ca6f9 HEAD: all 0 (present).
- **[Phase 3]** Sibling f45c999e67120 is independent sizeof fix; no later sysfs.c commits after this one.
- **[Phase 4]** b4 dig -c e45ee607ca6f9: lore thread; v2 cover + dmesg; Rafael applied as 7.3 material; no NAK.
- **[Phase 4]** b4 dig -w: linux-acpi, Saket Dumbre, reporter on CC.
- **[Phase 4]** b4 dig -m: full mbox; WebFetch lore/bugzilla 403.
- **[Phase 5]** grep: acpi_table_data_init only from acpi_tables_sysfs_init; acpi_sysfs_init from acpi_bus_init.
- **[Phase 6]** git describe HEAD → v7.3-rc4-27-gf0100363d8c37; make kernelversion → 7.3.0-rc4; buggy BERT/CCEL code in this lineage.
- **[Phase 8]** Failure mode: boot dump_stack + missing second data node; severity MEDIUM.
- **UNVERIFIED:** full SUSE bugzilla text; stable@ archives; panic_on_warn on affected hosts.
The patch is obviously correct, fixes a real distro-reported boot warning and missing RAS sysfs data, is nine lines in one file, and does not add features.
**YES**
drivers/acpi/sysfs.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/acpi/sysfs.c +5 -4
@@ -316,6 +316,7 @@ struct acpi_table_attr {struct acpi_data_attr {struct bin_attribute attr;u64 addr; +char filename[ACPI_NAMESEG_SIZE +ACPI_INST_SIZE ]; }; static ssize_t acpi_table_show(struct file *filp, struct kobject *kobj,
@@ -453,7 +454,6 @@ static int acpi_bert_data_init(void *th, struct acpi_data_attr *data_attr) } data_attr->addr = bert->address; data_attr->attr.size = bert->region_length; - data_attr->attr.attr.name ="BERT" ;return sysfs_create_bin_file (tables_data_kobj, &data_attr->attr); }
@@ -469,7 +469,6 @@ static int acpi_ccel_data_init(void *th, struct acpi_data_attr *data_attr) } data_attr->addr = ccel->log_area_start_address; data_attr->attr.size = ccel->log_area_minimum_length; - data_attr->attr.attr.name ="CCEL" ;return sysfs_create_bin_file (tables_data_kobj, &data_attr->attr); }
@@ -484,7 +483,7 @@ static struct acpi_data_obj {#define NUM_ACPI_DATA_OBJS ARRAY_SIZE(acpi_data_objs) -static int acpi_table_data_init (struct acpi_table_header *th) +static int acpi_table_data_init (struct acpi_table_header *th,struct acpi_table_attr *table_attr) {struct acpi_data_attr *data_attr;int i;
@@ -497,6 +496,8 @@ static int acpi_table_data_init(struct acpi_table_header *th)sysfs_attr_init (&data_attr->attr.attr); data_attr->attr.read = acpi_data_show; data_attr->attr.attr.mode =0400 ; +strscpy (data_attr->filename, table_attr->filename); + data_attr->attr.attr.name = data_attr->filename;return acpi_data_objs[i].fn (th, data_attr); } }
@@ -543,7 +544,7 @@ static int acpi_tables_sysfs_init(void)return ret; }list_add_tail (&table_attr->node, &acpi_table_attr_list); -acpi_table_data_init (table_header); +acpi_table_data_init (table_header, table_attr); }kobject_uevent (tables_kobj,KOBJ_ADD );
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 rtc: ds1307: fix RX8130 wakeup alarm WADA bit for day-of-month mode
In reply to Sasha LevinFrom: Robert Leussler <[email protected]>
[ Upstream commit 878d93aaa596a861dbc8d71f7c38e62a2e805f01 ]
The RX8130 wakeup alarm never fired when set via /sys/class/rtc/rtc0/wakealarm. The root cause is that the WADA bit (bit 3) in the Extension register (0x1c) was never set before programming the alarm registers.
Per the RX8130 datasheet:
WADA=0 - Week alarm: register 0x19 is compared against day-of-week WADA=1 - Day alarm: register 0x19 is compared against day-of-month
rx8130_set_alarm() always writes a BCD day-of-month value to alarm register 0x19, so WADA must be 1. With WADA=0 the hardware matched the day-of-month value (e.g. 15) as a day-of-week index, which is always out of range (valid weekdays are 0-6), so the alarm interrupt was never asserted.
Fix by setting the WADA bit in rx8130_set_alarm() before writing the Extension register back to the device.
This is consistent with rx8130_read_alarm(), which decodes the same register under the same assumption (24-hour and day-of-month mode).
---
LLM Generated explanations, may be completely bogus:
This is a one-line RX8130 wakeup-alarm fix. The buggy &= is present in this 6.12.111 tree, the datasheet matches the new polarity, and the patch applies cleanly.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: PARSE THE SUBJECT LINE
Record: **[rtc/ds1307] [fix] RX8130 wakeup alarm never fires because WADA is not set for day-of-month mode**
### Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- **Fixes:** none (expected for this review)
- **Reported-by:** none
- **Tested-by:** none (author is from Leica Geosystems; they hit this on hardware)
- **Reviewed-by:** none
- **Acked-by:** none
- **Link:** https://patch.msgid.link/20260721081907.3518648-1- [email protected]
- **Cc: stable:** none (expected)
- **Signed-off-by:** Robert Leussler (author); Alexandre Belloni (RTC maintainer). Ignore any Sasha Levin SOB if later added by the pipeline.
### Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** RX8130 wakeup alarm never fires when set via /sys/class/rtc/rtc0/wakealarm.
- **Symptom:** scheduled RTC wakeup does not occur; /IRQ is never asserted.
- **Root cause:** rx8130_set_alarm() writes BCD day-of-month to alarm register 0x19 but never sets WADA (Extension 0x1c bit 3). With WADA=0 the chip compares 0x19 as a week alarm.
- **Version info:** none in the message. Code has been in-tree since RX8130 support (v4.13); the current &= form dates to 2019.
- **Author’s fix:** ctl[0] &= WADA → ctl[0] |= WADA so WADA=1 (day- of-month), matching rx8130_read_alarm().
### Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not hidden. Explicit hardware-logic fix. The &= → |= change also stops wiping other Extension bits (FSEL/USEL/TE/TSEL), which is extra correctness, not a drive-by refactor.
---
## PHASE 2: DIFF ANALYSIS
### Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/rtc/rtc-ds1307.c — **1 line changed** (&= → |=)
- Function: rx8130_set_alarm()
- Scope: single-file surgical fix
### Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- **Before:** after reading Extension/Flag/Control0, ctl[0] &= BIT(3) keeps only the current WADA bit (typically 0 from POR) and **clears every other Extension bit**, then writes it back, then programs min/hour/**mday**.
- **After:** ctl[0] |= BIT(3) **sets WADA=1** and **preserves** FSEL/USEL/TE/TSEL, then programs the same mday alarm.
### Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- **Category:** logic / hardware-programming correctness (wrong alarm mode bit).
- **Mechanism:** RX8130 WADA selects week vs day comparison for register 0x19. Driver always writes bin2bcd(tm_mday) to 0x19, so WADA must be
1. WADA=0 makes the chip treat that BCD value as a week-alarm bitmap, so the alarm either never matches or matches the wrong weekdays.
Verified from Epson RX8130CE application manual (Table 23):
- WADA=0 → WEEK is the alarm target
- WADA=1 → DAY (day-of-month) is the alarm target
- Example “Day” settings explicitly use WADA=1
### Step 2.4: ASSESS THE FIX QUALITY
Record:
- **Quality:** obviously correct. One operator change; polarity matches the datasheet and the existing read path (tm_mday, comment “day-of- month modes”).
- **Regression risk:** very low. Only RX8130 set_alarm. |= is the correct RMW (old &= BIT(3) was also clobbering FSEL/TE/TSEL). No API/lock/struct change.
- The author’s “valid weekdays are 0-6, so mday 15 never matches” is slightly imprecise: week mode is a **bitmap**, so some BCD mday values can match the wrong weekdays. Failure mode is still “alarm broken,” possibly worse than “never fires.”
---
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: BLAME THE CHANGED LINES
Record:
- Buggy line ctl[0] &= RX8130_REG_EXTENSION_WADA introduced by **3f929cad94338** (“rtc: ds1307: rx8130: Fix alarm handling”, Uwe Kleine-König, 2019-01-25).
- First appeared: **v5.1-rc1**. Present in this tree (git merge-base --is-ancestor succeeded).
- RX8130 support itself: **ee0981be77045** (v4.13-rc1), which used ctl[0] &= ~WADA (explicitly **cleared** WADA).
### Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Historical introducer is 3f929cad94338, which is in this tree.
That 2019 commit **intended** to “clear WADA for day-of-month,” but:
1. Its datasheet polarity was inverted vs Epson (it treated WADA=1 as weekdays).
2. Its diff changed &= ~WADA to &= WADA (dropped ~), which does **not** clear WADA; it preserves WADA and zeros other Extension bits.
Original 2017 code already chose the wrong polarity for mday. The 2019 change left WADA at POR 0 and made Extension clobber worse.
### Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record (recent on this file in this tree):
- e0e6ddc431177 rtc: ds1307: Fix off-by-one issue with wday for rx8130 — **time** wday encoding, not alarm WADA. Independent; already here.
- 204756f016726 rtc: ds1307: Fix wday settings for rx8130 — also time, not alarm.
- 3f929cad94338 — the buggy alarm handling change.
Standalone one-line fix; not patch X/Y.
### Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Robert Leussler has no other rtc commits in this tree. Alexandre Belloni (RTC maintainer) signed off and applied it. Weight comes from maintainer application + hardware report, not from a regular-contributor history.
### Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: None. Diff only needs rx8130_set_alarm() and RX8130_REG_EXTENSION_WADA, both present. git show 878d93aaa596 | git apply --check **succeeded** on this tree.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
### Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 878d93aaa596 → https://patch.msgid.link/20260721081907.351
[email protected]
- b4 dig -a: **v1 only** (no v2/v3)
- Thread: submission (2026-07-21) → Sashiko AI note on pre-existing FLAG RMW → author reply (2026-08-10): FLAG issue is pre-existing and out of scope → **Alexandre Belloni: “Applied, thanks!”** (2026-08-20), no NAK
- lore.kernel.org WebFetch returned 403; thread recovered via b4 dig -m and openwall/spinics
### Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To/Cc were Alexandre Belloni, linux-rtc, linux- kernel. Maintainer applied it. No other human Reviewed-by.
### Step 4.3: SEARCH FOR THE BUG REPORT
Record: No bugzilla/syzbot. Concrete userspace trigger in the message (/sys/class/rtc/rtc0/wakealarm). Author is an RX8130 user (Leica Geosystems). Sashiko flagged a **pre-existing** write-0-to-clear FLAG RMW (VLF); author correctly kept that separate. That does not weaken this WADA fix.
### Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone 1/1. Not part of a multi-patch series.
### Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable WebFetch 403. No other evidence of a stable NAK. Absence of prior stable discussion is not a negative.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1: IDENTIFY KEY FUNCTIONS
Record: rx8130_set_alarm() only.
### Step 5.2: TRACE CALLERS
Record:
- Wired as rx8130_rtc_ops.set_alarm in drivers/rtc/rtc-ds1307.c
- RTC core: rtc_set_alarm() / __rtc_set_alarm() in drivers/rtc/interface.c
- Userspace: drivers/rtc/sysfs.c (wakealarm), plus RTC_WKALM_SET / RTC_ALM_SET ioctls
- Reachable whenever RX8130 alarm IRQ or wakeup-source is enabled (chip desc has .alarm = 1)
### Step 5.3: TRACE CALLEES
Record: regmap_bulk_read/write of Extension+Flag+Control0 and alarm min/hour/day, then optional Control0 AIE write. No alloc/locking in this function.
### Step 5.4: FOLLOW THE CALL CHAIN
Record: echo T > /sys/class/rtc/rtc0/wakealarm or rtcwake → rtc_set_alarm → rx8130_set_alarm. Unprivileged access depends on rtc device node permissions; typical embedded images use this for suspend wakeup. **Yes, userspace-reachable.**
### Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Sibling Epson/MicroCrystal chips also program WADA, with **chip- specific polarity** (RX8010 clears WADA while writing mday; RV8803/RV3028/RV3032 set WADA). Not a copy-paste of those; RX8130 datasheet is the authority. No second broken copy in rtc-ds1307.c.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
### Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE? Record:
- Tree: **git describe HEAD = p-6.12-3-gc504cf0baa3d8**, **make kernelversion = 6.12.111**
- Buggy code is here at drivers/rtc/rtc-ds1307.c:665: ctl[0] &= RX8130_REG_EXTENSION_WADA;
- git merge-base --is-ancestor 878d93aaa596 HEAD → **not an ancestor** (fix not in this tree)
- git merge-base --is-ancestor 3f929cad94338 HEAD → **yes** (bug is in this tree)
- Bug introduced v5.1 (wrong &= form); wrong polarity since v4.13
### Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **Clean apply** (git apply --check exit 0). Surrounding rx8130_set_alarm() matches the mainline hunk. No rework needed.
### Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: wday off-by-one (e0e6ddc431177) is already here and is a different bug. No existing WADA |= fix.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
### Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: **drivers/rtc** (Epson RX8130 in rtc-ds1307). Criticality:
**PERIPHERAL** for the kernel as a whole, **IMPORTANT** for boards that use this RTC as the wake source.
### Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: rtc-ds1307 still gets real fixes in this tree (OSF, max clock rate, wday). Mature driver; this is a long-standing programming error, not churn from new code.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: DETERMINE WHO IS AFFECTED
Record: **Driver-specific / config-specific** — CONFIG_RTC_DRV_DS1307
+ Epson RX8130 (epson,rx8130 / rx8130) with alarm/wakeup wired.
### Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Any set_alarm / wakealarm / rtcwake on RX8130. Common on embedded systems that sleep and wake on RTC. Not a rare error path.
### Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- Failure: RTC alarm IRQ//IRQ does not fire as intended → **system fails to wake from suspend** at the scheduled time (or wakes on the wrong weekday if the BCD mday happens to look like a week bitmap).
- Severity: **HIGH** for those devices (lost wakeup; device can stay asleep). Not a KASAN/UAF/panic.
### Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit:** high for RX8130 users — restores the documented alarm/wakeup path.
- **Risk:** very low — 1 line, polarity confirmed by datasheet, maintainer applied, no locking/API change.
- **Ratio:** strongly favors backport.
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: COMPILE THE EVIDENCE
**FOR:**
- Real user-visible bug: RX8130 wakealarm does not work
- Datasheet-confirmed WADA polarity (0=week, 1=day)
- Driver always writes tm_mday; WADA must be 1
- Buggy &= is in this 6.12.111 tree; fix is not
- 1-line, obviously correct; apply-check clean
- RTC maintainer applied after review window; no NAK
- Also stops Extension-register clobber of FSEL/TE/TSEL
- Standalone; no prerequisites missing here
**AGAINST:**
- Not a crash/security/corruption issue
- Only RX8130, not all rtc-ds1307 chips
- No Fixes:/Cc:stable (expected; not a negative)
- No second independent reporter beyond the author
**UNRESOLVED:**
- Could not fetch lore.kernel.org or lore.kernel.org/stable (403); thread recovered via b4/openwall
- Did not re-test on hardware (author did; commit describes /sys/class/rtc/rtc0/wakealarm)
### Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — datasheet + maintainer apply
+ hardware report
2. Fixes a real bug that affects users? **PASS** — wakeup alarm broken on RX8130
3. Important issue? **PASS** — failed RTC wakeup / wrong-day match; HIGH for this hardware
4. Small and contained? **PASS** — 1 line, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — clean apply; buggy code present
### Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary contained driver bugfix.
### Step 9.4: MAKE YOUR DECISION
This 6.12.111 tree has the 2019 &= WADA bug. The fix is the smallest possible correction so the chip compares day-of-month the way the driver already programs it. That is exactly the kind of hardware bug stable users of this RTC need.
Verification:
- [Phase 1] Parsed tags: Link to patch.msgid.link; SOBs Leussler + Belloni; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: 1 line in rx8130_set_alarm(), &= → |= on RX8130_REG_EXTENSION_WADA
- [Phase 2] Datasheet (Epson RX8130CE app manual Table 23): WADA=0 week, WADA=1 day — matches the patch
- [Phase 3] git blame: line from 3f929cad94338 (v5.1-rc1); original support ee0981be77045 (v4.13) used &= ~WADA
- [Phase 3] git show 3f929cad94338: dropped ~, inverted polarity vs datasheet
- [Phase 3] git merge-base --is-ancestor 3f929cad94338 HEAD: yes; 878d93aaa596 HEAD: no
- [Phase 4] b4 dig -c 878d93aaa596: lore msgid 20260721081907.3518648-1
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: Belloni + linux-rtc + linux-kernel
- [Phase 4] b4 mbox: Belloni “Applied, thanks!”; Sashiko FLAG note pre- existing, not a NAK
- [Phase 5] rx8130_set_alarm is rtc_class_ops.set_alarm; sysfs wakealarm calls rtc_set_alarm()
- [Phase 6] git describe HEAD: p-6.12-3-gc504cf0baa3d8; kernelversion 6.12.111; line 665 still &=
- [Phase 6] git apply --check of 878d93aaa596: clean
- [Phase 8] Failure mode: RTC wakeup does not fire (or fires on wrong weekdays); HIGH for RX8130 boards
- UNVERIFIED: live lore.kernel.org/stable HTML (HTTP 403); hardware retest in this environment
**YES**
drivers/rtc/rtc-ds1307.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-ds1307.c +1 -1
@@ -662,7 +662,7 @@ static int rx8130_set_alarm(struct device *dev, struct rtc_wkalrm *t)if (ret <0 )return ret; - ctl[0 ] &=RX8130_REG_EXTENSION_WADA ; + ctl[0 ] |=RX8130_REG_EXTENSION_WADA ; ctl[1 ] &= ~RX8130_REG_FLAG_AF ; ctl[2 ] &= ~RX8130_REG_CONTROL0_AIE ;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] rtc: ds1307: fix RX8130 wakeup alarm WADA bit for day-of-month mode
Sashiko has reviewed this patch and found no issues.
Quoted 22 lines
From: Robert Leussler <[email protected]>
[ Upstream commit
878d93aaa596a861dbc8d71f7c38e62a2e805f01]The RX8130 wakeup alarm never fired when set via
/sys/class/rtc/rtc0/wakealarm. The root cause is that the WADA bit (bit 3) in the Extension register (0x1c) was never set before programming the alarm registers.Per the RX8130 datasheet:
WADA=0 - Week alarm: register 0x19 is compared against day-of-week WADA=1 - Day alarm: register 0x19 is compared against day-of-month
rx8130_set_alarm()always writes a BCD day-of-month value to alarm register0x19, so WADA must be 1. With WADA=0 the hardware matched the day-of-month value (e.g. 15) as a day-of-week index, which is always out of range (valid weekdays are 0-6), so the alarm interrupt was never asserted.Fix by setting the WADA bit in
rx8130_set_alarm()before writing the Extension register back to the device.
Quoted 7 lines
This is consistent with
rx8130_read_alarm(), which decodes the same register under the same assumption (24-hour and day-of-month mode).Signed-off-by Robert Leussler <[email protected]>Signed-off-by Alexandre Belloni <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 wifi: iwlwifi: mvm: ignore sync frames when sync is disabled
In reply to Sasha LevinFrom: Emmanuel Grumbach <[email protected]>
[ Upstream commit a790f60cc4d7dc64a2d7cadb94a3d9f60392bed4 ]
Gate time-sync frame interception on the active flag so frames are not queued after time-sync teardown.
---
LLM Generated explanations, may be completely bogus:
The local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). This analysis is only about that checkout: the iwlwifi MVM time-sync path exists here, and the two-line guard is a real teardown leak/drop fix.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[iwlwifi/mvm] [ignore/gate] intercept time-sync frames only while time-sync is active**
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- **Assisted-by:** GitHubCopilot:GPT-5.3-Codex
- **Signed-off-by:** Emmanuel Grumbach (author)
- **Link:** https://patch.msgid.link/20260717172958.ac73ee199a25.Ic14892
44f9b02da93060f0a0e5b300a73527f265@changeid
- **Signed-off-by:** Miri Korenblit (iwlwifi maintainer)
- **No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Cc:
stable** (absence is expected for this pipeline)
- Ignored: any pipeline “already selected” markers (none present beyond a normal maintainer SOB)
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** After time-sync teardown, matching TM/FTM frames are still intercepted and queued.
- **Symptom:** Frames sit on frame_list instead of going through the normal RX/TX-status path; they are not consumed by firmware time-sync notifications once the feature is off.
- **Version info in message:** none.
- **Root cause (from message + code):** interception is keyed only on peer_addr, which is left set after disable.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: This is an explicit bug fix (not style). “Ignore … when disabled” / “frames are not queued after teardown” is incomplete disable handling, which produces an skb leak and dropped TM/FTM frames.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- **File:** drivers/net/wireless/intel/iwlwifi/mvm/time-sync.h (+4 / ~0; copyright year + 2-line guard)
- **Function:** iwl_mvm_time_sync_frame()
- **Scope:** single-file surgical fix
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- **Before:** If peer_addr matches and the skb is a TM or FTM action frame, queue it on mvm->time_sync.frame_list and return true (caller skips ieee80211_tx_status_skb / iwl_mvm_pass_packet_to_mac80211).
- **After:** If !mvm->time_sync.active, return false immediately so the frame takes the normal path.
- **Path:** RX NAPI and TX-status reclaim; not probe init.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- **Category:** logic/correctness + resource leak on teardown.
- **Mechanism:** iwl_mvm_time_sync_config() sets active = (protocols != 0) and purges frame_list when inactive, but still copies peer_addr. The interceptor never consulted active, so after disable it kept stealing matching frames.
- Compared with MLD: iwl_mld_time_sync_frame() already no-ops when mld->time_sync is NULL after iwl_mld_deinit_time_sync(). MVM stores time-sync in an embedded struct, so it needs the active flag.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: gate on the same flag config already uses.
- Minimal; no API/data-structure change.
- Regression risk is low. A remaining TOCTOU vs iwl_mvm_time_sync_config() (mutex vs RX/TX softirq, no READ_ONCE) is pre-existing; this closes the post-teardown window, which is the user-visible bug.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Interceptor introduced in **c7eca79def44f** (`wifi: iwlwifi: mvm:
report hardware timestamps in RX/TX status`, Avraham Stern, 2023-03-20).
- First appeared in **v6.4-rc1** (git describe --contains c7eca79def44f → v6.4-rc1~132^2~151^2~105).
- struct iwl_time_sync_data { frame_list, peer_addr, active } is from that same commit. The bug is old, not last-month code.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. The incomplete disable path is **cf85123a210fe** (wifi: iwlwifi: mvm: support enabling and disabling HW timestamping, also v6.4-rc1): it stopped auto-enabling on station add, added purge-on-disable, and removed iwl_mvm_time_sync_sta_rm(), but did not gate iwl_mvm_time_sync_frame().
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record (on this tree, path-limited):
- a790f60cc4d7d — this fix
- 08e6183ed2568 — wifi action-frame struct move
- cf85123a210fe — enable/disable HW timestamping
- a2f49f7d52a9e / c7eca79def44f — original time-sync Standalone. Series tag is **3/8** of an iwlwifi-next bundle; patches 1–2 and 4–8 touch other files. This hunk does not depend on them.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Emmanuel Grumbach is a long-time iwlwifi developer. Nearby July 2026 commits are other iwlwifi correctness fixes. Maintainer **Miri Korenblit** signed off and applied it.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: Needs mvm->time_sync.active and iwl_mvm_time_sync_frame(), both present since v6.4 and in this 7.3 tree. Applies standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c a790f60cc4d7 → https://patch.msgid.link/20260717172958.ac7
3ee199a25.Ic1489244f9b02da93060f0a0e5b300a73527f265@changeid
- b4 dig -a: single **v1** series `[PATCH iwlwifi-next 0/8] wifi:
iwlwifi: updates - 07-17-2026`
- Cover letter: “A couple of fixes, features and cleanups.” This patch is listed under Emmanuel’s fixes.
- Saved mbox: 9 messages (cover + 8 patches), **no review replies, NAKs, or Cc: stable**.
- WebFetch of lore returned **403**; discussion recovered via b4 dig -m.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): Miri Korenblit, Johannes Berg ([email protected]), linux-wireless, Emmanuel Grumbach. Right lists/maintainers; no extra Reviewed-by on this patch. Miri’s SOB is the maintainer merge.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No Reported-by / bugzilla / syzbot. Bug is from code inspection of teardown vs interceptor.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Mixed iwlwifi-next series. This patch only changes mvm/time- sync.h. Other patches are MLD/ACPI/debug and are **not** prerequisites.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: WebSearch of lore.kernel.org/stable for this subject found **no** discussion. UNVERIFIED beyond that search (lore HTML 403).
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: iwl_mvm_time_sync_frame() only.
Step 5.2: TRACE CALLERS
Record:
1. drivers/net/wireless/intel/iwlwifi/mvm/tx.c — TX-status reclaim: if interceptor returns true, skip ieee80211_tx_status_skb().
2. drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c — RX: if true, skip pass-to-mac80211.
Both are hot NAPI/TX-complete paths, but the match is rare (TM/FTM action frames to a configured peer).
Step 5.3: TRACE CALLEES
Record: ether_addr_equal(), ieee80211_is_timing_measurement(), ieee80211_is_ftm(), skb_queue_tail(). No alloc/locks in the inline itself. Disable path: iwl_mvm_time_sync_config() under mvm->mutex (from iwl_mvm_set_hw_timestamp() via mac80211 set_hw_timestamp).
Step 5.4: FOLLOW THE CALL CHAIN
Record:
- Enable/disable: userspace nl80211 SET_HW_TIMESTAMP → ieee80211_set_hw_timestamp() → iwl_mvm_set_hw_timestamp() → iwl_mvm_time_sync_config().
- After disable, any later TM/FTM RX/TX for that peer_addr hits the interceptor.
- Reachable from the air for RX (FTM/TM responses) once the feature was enabled then disabled. Not a general unprivileged syscall crash path.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: MLD already treats “no time_sync object” as inactive. No second MVM copy of this bug.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record:
- Tree: **7.3.0-rc4** (git describe HEAD = v7.3-rc4-27-gf0100363d8c37).
- git merge-base --is-ancestor a790f60cc4d7 HEAD succeeded (commit is in this lineage; expected for mainline, not used as “already selected”).
- Pre-fix interceptor and time_sync.active / peer_addr / frame_list all exist here. Bug introduced in v6.4, **not** after this tree.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Current time-sync.h matches the patched form. Against the pre- fix function (unchanged since c7eca79 except this guard), apply is **clean**.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: Only this commit implements the active gate. ead65aa2d5155 (“send time sync only if needed”) is unrelated.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: **wifi / iwlwifi MVM** (Intel wireless). **IMPORTANT** (very common hardware), not core mm/VFS. Time-sync/HW timestamping is a narrower slice of that driver.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: iwlwifi is actively developed (many 2026 commits). This particular file is mature (stable since 6.4 aside from the action-frame helper move).
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Intel iwlwifi **MVM** users who used nl80211 HW timestamping (TM/FTM) and then disabled it, while TM/FTM frames for that peer continue. Not universal.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record:
- Trigger: enable HW timestamp for a peer, then disable (protocols == 0). peer_addr stays set; active is false; interceptor still matched.
- Not every boot; requires that userspace API.
- After that, RX of matching FTM/TM frames from the network can keep filling frame_list.
- Enable/disable typically needs netlink admin; subsequent RX leak can be driven by frames on the air.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- Unbounded **skb leak** of intercepted frames (purge only runs on a later inactive config).
- **Dropped** TM/FTM frames that should have gone to mac80211.
- **Missing TX status** (ieee80211_tx_status_skb skipped) for intercepted TX frames.
- Not a panic, UAF, or filesystem corruption.
- **Severity: HIGH** for the leak/drop on a live packet path; feature is uncommon so blast radius is limited.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit:** stops post-disable frame theft, skb leak, and missing TX completion. Small but real.
- **Risk:** very low (2 functional lines, same flag already used in config).
- **Ratio:** favorable for any tree that has MVM time-sync (this 7.3 tree does).
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
**FOR backporting to this tree:**
- Real teardown bug: interceptor ignored active while peer_addr survived disable.
- Consequences: skb leak, silent TM/FTM drops, skipped TX status.
- Two-line, obviously correct guard; no new API.
- Bug in code present since v6.4; this 7.3 tree has that code.
- Author + iwlwifi maintainer SOB; sent to linux-wireless / Johannes Berg.
- Standalone; other 3/8 series patches not required.
- MLD already has the equivalent “don’t intercept after teardown” behavior.
**AGAINST:**
- No Fixes: / Reported-by / syzbot / stable discussion.
- Path is niche (HW timestamping), not a crash/CVE-class bug.
- Commit message is short and Copilot-assisted.
- Mixed “fixes + features” series with no extra review on this patch.
**UNRESOLVED:**
- lore HTML 403; used b4 mbox instead.
- No public user reports found.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — matches existing active flag; merged by iwlwifi maintainer (no separate Tested-by).
2. Fixes a real bug that affects users? **PASS** — post-disable intercept/leak/drop.
3. Important issue? **PASS** — unbounded skb leak and missing TX completion on a packet path (not a panic; still user-visible).
4. Small and contained? **PASS** — one inline, +2 functional lines.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — time_sync.active and callers exist; hunk is trivial.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: None (not a device ID / quirk / DT / build / docs exception). Ordinary small driver correctness fix.
Step 9.4: MAKE YOUR DECISION
This tree’s iwlwifi MVM time-sync stack still has the disable path that leaves peer_addr set. Without the active check, teardown is
incomplete: TM/FTM skbs are queued forever and never get TX status or mac80211 RX. The patch is the same check MVM config already uses and that MLD gets via a NULL time-sync object. That is in scope for this 7.3 tree and meets stable rules.
What it solves for users of this tree: after HW timestamping is turned off, FTM/TM frames are delivered normally instead of leaking on frame_list.
Risk vs benefit: two lines vs a real leak/drop; benefit wins.
No missing prerequisites in this checkout.
Verification:
- [Phase 1] Parsed tags: Assisted-by Copilot, SOB Grumbach + Korenblit, msgid.link; no Fixes/Reported-by/Cc stable
- [Phase 2] Diff: +2-line if (!mvm->time_sync.active) return false; in iwl_mvm_time_sync_frame()
- [Phase 2] Confirmed disable leaves peer_addr set in iwl_mvm_time_sync_config() (time-sync.c around the active = protocols != 0 assignment and skb_queue_purge)
- [Phase 3] git blame parent: interceptor from c7eca79def44f (v6.4-rc1); disable redesign cf85123a210fe (v6.4-rc1)
- [Phase 3] No Fixes: tag; related history limited to mvm/time-sync.*
- [Phase 3] git merge-base --is-ancestor a790f60cc4d7 HEAD — commit is in this 7.3 lineage
- [Phase 4] b4 dig -c/-a/-w/-m: v1 iwlwifi-next 3/8, no replies; recipients Korenblit, Johannes, linux-wireless
- [Phase 4] WebFetch lore 403; stable WebSearch found no thread
- [Phase 5] Callers: mvm/tx.c TX status, mvm/rxmq.c RX; userspace via set_hw_timestamp
- [Phase 5] MLD equivalent already NULL-checks time_sync after deinit
- [Phase 6] git describe HEAD = v7.3-rc4-27; make kernelversion = 7.3.0-rc4; feature present
- [Phase 8] Failure mode: skb leak + dropped TM/FTM + skipped TX status; severity HIGH on that path
- UNVERIFIED: public user reports; full lore HTML thread rendering
**YES**
drivers/net/wireless/intel/iwlwifi/mvm/time-sync.h | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/intel/iwlwifi/mvm/time-sync.h +4 -0
@@ -1,6 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ /* * Copyright (C) 2022 Intel Corporation +* Copyright (C) 2026 Intel Corporation */ #ifndef __TIME_SYNC_H__#define __TIME_SYNC_H__
@@ -19,6 +20,9 @@ int iwl_mvm_time_sync_config(struct iwl_mvm *mvm, const u8 *addr,static inline bool iwl_mvm_time_sync_frame (struct iwl_mvm *mvm,struct sk_buff *skb,u8 *addr) { +if (!mvm->time_sync.active) +return false; +if (ether_addr_equal (mvm->time_sync.peer_addr, addr) && (ieee80211_is_timing_measurement (skb) ||ieee80211_is_ftm (skb))) {skb_queue_tail (&mvm->time_sync.frame_list, skb);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/realtek: Add ALC235 support for headset mode
In reply to Sasha LevinFrom: Zeyu Li <[email protected]>
[ Upstream commit 9ee4266827cfb67b9fbb89136ea6a8f3d7809f5c ]
The ALC235 (0x10ec0235) is registered as the ALC255 codec variant in patch_alc269(), but the headset mode functions were missing a case for it, so the CTIA/OMTP jack type detection and routing never ran on this codec. As a result, a plugged-in headset is detected (jack presence works) but the microphone signal is never routed, leaving the capture stream permanently silent.
Verified on an ASUS M5451GA laptop (HDA:10ec0235,10431814): with the ALC255 coef sequence applied, the headset microphone works correctly.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
Record: **[ALSA/hda/realtek] [Add] Add ALC235 support for headset mode**
The verb is “Add”, but the body is a missing-ID fix: ALC235 is already treated as an ALC255 variant, and the headset-mode switches never included it.
**Step 1.2 — Tags**
Record:
- **Fixes:** none (expected for this review)
- **Reported-by:** none
- **Tested-by:** none (author states hardware verification in the body)
- **Reviewed-by / Acked-by:** none on the commit
- **Link:**
https://patch.msgid.link/[email protected]
- **Cc: stable:** none (expected)
- **Signed-off-by:** Zeyu Li (author); Takashi Iwai (ALSA maintainer)
- Pipeline tags ignored: [Upstream commit ...], Signed-off-by: Sasha Levin
**Step 1.3 — Body**
Record:
- **Bug:** ALC235 (0x10ec0235) is classified as ALC269_TYPE_ALC255 in patch_alc269(), but the six headset-mode helpers omit that vendor ID.
- **Symptom:** combo-jack presence works; headset capture stays silent because CTIA/OMTP detection and mic routing never run.
- **Root cause:** switch (codec->core.vendor_id) falls through with no match, so alc_process_coef_fw(codec, coef0255) is never applied.
- **Verification:** ASUS M5451GA (HDA:10ec0235,10431814); ALC255 coef sequence restores headset mic.
- **Version info:** none in the message. Codec ID has been in-tree since 2014.
**Step 1.4 — Hidden bug fix?**
Record: Not hidden. This is a hardware-routing bug written as “Add support”. It does not add a driver or API; it fills in a missing vendor- ID case in existing tables.
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
Record:
- **File:** sound/hda/codecs/realtek/realtek.c — **+6 / −0**
- **Functions:** alc_headset_mode_unplugged, alc_headset_mode_mic_in, alc_headset_mode_default, alc_headset_mode_ctia, alc_headset_mode_omtp, alc_determine_headset_type
- **Scope:** single-file, surgical. One case 0x10ec0235: added immediately above each existing case 0x10ec0255:.
**Step 2.2 — Flow change**
Record: Before, those switches did nothing for vendor 0x10ec0235. After, ALC235 uses the same ALC255 coefficient firmware already used for 0x10ec0255 (unplug, mic-in, default headphone, CTIA, OMTP, and type- detect).
Author-reported working values COEF 0x45=0xd489, 0x1b=0x0c2b match alc_headset_mode_ctia()’s coef0255 exactly.
**Step 2.3 — Bug mechanism**
Record: **Hardware workaround / missing codec ID** in existing headset- mode tables. Without the case, jack detect still works via generic HP automute, but combo-jack mic routing never happens.
**Step 2.4 — Fix quality**
Record: Minimal and obviously correct given that patch_alc269() already maps ALC235 → ALC255. Regression risk is low: the new cases only run when headset-mode hooks are installed (alc_fixup_headset_mode / alc_probe_headset_mode). Realtek confirmed compatibility (Phase 4). Residual incompleteness: alc255_set_default_jack_type() still has only 0x10ec0255; the author still got a working headset mic without that extra case.
## Phase 3: Git history
**Step 3.1 — Blame**
Record:
- Headset-mode switches (minus the new case) come from the 6.16-era Realtek split aeeb85f26c3bb (2025-07-11), itself a move of older patch_realtek.c logic.
- ALC235 vendor ID added in 92f974df34601 (2014-06-06, Kailang Yang):
“New vendor ID for ALC233 … compatible with ALC255. It is use for Lenovo.”
- Variant assignment added in ea04a1dbf8b1d (2018-04-25, Kailang Yang, already sent to stable). Maintainer note then: *“the chip is 10ec:0235 bonding for ALC233b, which is equivalent with ALC255. It's only used for Lenovo. The chip needs no alc_process_coef_fw() for headset unlike ALC255.”*
That 2018 note is why the ID was classified as ALC255 but **intentionally omitted** from headset coef switches. The 2026 report is an ASUS machine, not Lenovo, and Realtek later said the ALC255 sequence is compatible.
**Step 3.2 — Fixes tag**
Record: No Fixes: tag. The incomplete classification dates to ea04a1dbf8b1d (2018), which is in this tree.
**Step 3.3 — File history**
Record: Recent realtek.c / alc269.c history is the usual stream of laptop quirks. No prerequisite refactor is required. Not a patch X/Y series.
**Step 3.4 — Author**
Record: Zeyu Li has no other Realtek commits in this tree. This is a user-reported hardware fix reviewed by the ALSA maintainer and a Realtek engineer, not a maintainer-authored cleanup.
**Step 3.5 — Dependencies**
Record: Standalone. It only adds a case next to an existing 0x10ec0255 arm. Those functions and coef0255 already exist here. No new helpers.
## Phase 4: Mailing list / external research
**Step 4.1 — Original discussion**
Record:
- Lore/msgid:
https://patch.msgid.link/[email protected]
- b4 dig -c 9ee4266827cfb67b9fbb89136ea6a8f3d7809f5c matched that thread.
- Revisions: same patch sent twice (lkml + linux-sound). No v2/v3 code change.
- Takashi Iwai (28 Sep 2026): *“I'm not sure whether it's 100% safe… Kailang, could you check it? Can ALC235 be fully compatible in this manner?”*
- Author follow-up: jack sense and VREF were already correct; capture stayed silent until ALC255 CTIA coefs were applied.
- **Kailang Yang, Realtek (1 Oct 2026): “Yes, it's compatible.”**
- Takashi then applied the patch. No NAK.
**Step 4.2 — Recipients (b4 dig -w)**
Record: Zeyu Li; linux-sound; Takashi Iwai; Jaroslav Kysela. Realtek (Kailang) was added during review.
**Step 4.3 — Bug report**
Record: Reporter is the author, on a specific ASUS laptop. One machine, but a concrete silent-mic failure with before/after coefs. No syzbot/bugzilla.
**Step 4.4 — Series**
Record: Standalone single patch. No sibling commits required.
**Step 4.5 — Stable list**
Record: **UNVERIFIED** — lore.kernel.org/stable returned HTTP 403. No other evidence it was rejected for stable.
## Phase 5: Code semantic analysis
**Step 5.1 — Functions**
Record: the six headset-mode helpers listed in 2.1. They are called only from alc_update_headset_mode().
**Step 5.2 — Callers**
Record:
- alc_update_headset_mode() ← alc_update_headset_mode_hook (capture mux), alc_update_headset_jack_cb (HP jack), alc_fixup_headset_mode INIT, alc_probe_headset_mode (installs the hooks).
- Those hooks are installed only when a headset-mode fixup is active (ALC255_FIXUP_HEADSET_MODE, model=alc255-asus, etc.).
- This tree has **no** PCI/pin quirk for ASUS 1043:1814. Existing ALC235 pin quirks are Lenovo-only and do **not** enable headset mode. The author’s box therefore needed a headset-mode fixup or model= to hit this path. The commit still fixes every ALC235 device that already uses that path.
**Step 5.3 — Callees**
Record: alc_process_coef_fw, alc_write_coef_idx, alc_read_coef_idx, snd_hda_set_pin_ctl_cache. Codec coefficient writes plus pin VREF. No locking/alloc/API changes.
**Step 5.4 — Reachability**
Record: Userspace-reachable: plug a headset and select the headset-mic input on a machine whose quirk/model enables headset mode. Unprivileged audio use; not a syscall crash path.
**Step 5.5 — Similar patterns**
Record: Same table already groups sibling IDs (0x10ec0230/0236/0256, 0x10ec0234/0274/0294). Adding 0235 next to 0255 matches that pattern. The only remaining 0x10ec0255-only switch is alc255_set_default_jack_type() in alc269.c.
## Phase 6: This tree (6.18.y)
**Step 6.1 — Does the bug exist here?**
Record: **Yes.** Local tree is **6.18.57** (git describe:v6.18.57-155-gcdf239ca885b2; Makefile VERSION=6 PATCHLEVEL=18 SUBLEVEL=57).
Without this change (parent of the candidate):
- patch_alc269() already has case 0x10ec0235: → ALC269_TYPE_ALC255
- Headset-mode switches have only case 0x10ec0255:
- File path is already sound/hda/codecs/realtek/realtek.c (split commit is an ancestor)
The codec has been present since 2014; the ALC255 classification since 2018. This is not post-6.18 hardware enablement of a new driver.
**Step 6.2 — Backport difficulty**
Record: **Clean apply.** Same file, same six switches, same neighboring 0x10ec0255 cases. No structural conflict.
**Step 6.3 — Related fixes already here?**
Record: No other ALC235 headset-mode fix. No follow-up on realtek.c after this candidate that would supersede it.
## Phase 7: Subsystem context
**Step 7.1**
Record: **ALSA HD-audio / Realtek codec.** Criticality: **IMPORTANT** (common laptop audio), not core mm/VFS. Realtek HDA is the default codec path on a large fraction of x86 laptops.
**Step 7.2**
Record: Very active (many recent laptop quirks). That is normal for this file and is why codec-ID / quirk additions are routinely taken into stable.
## Phase 8: Impact and risk
**Step 8.1 — Who is affected**
Record: Users of Realtek ALC235 (CONFIG_SND_HDA_CODEC_REALTEK) whose machine enables headset mode (quirk or model=). Confirmed hardware:
ASUS M5451GA. Older Lenovo ALC235 boxes use other pin quirks and do not enter these switches.
**Step 8.2 — Trigger**
Record: Plug a CTIA/OMTP headset and use the headset mic. Common laptop action. Unprivileged.
**Step 8.3 — Failure mode**
Record: Headset playback/jack detect works; **headset microphone capture is permanently silent**. Severity: **HIGH** for affected laptops (broken input device), not a panic/UAF. This is the standard “audio hardware quirk” class.
**Step 8.4 — Risk vs benefit**
Record:
- **Benefit:** restores headset mic on ALC235 machines that already go through headset mode; Realtek-confirmed; hardware-tested.
- **Risk:** very low (6 fallthrough cases, existing coef table). Theoretical risk to old Lenovo ALC233b bonding is mitigated by (a) those quirks not enabling headset mode, and (b) Kailang’s 2026 “compatible” ack.
- **Ratio:** favorable.
## Phase 9: Synthesis
**Step 9.1 — Evidence**
For:
- Real user-visible bug (silent headset mic) on identified hardware
- 6-line vendor-ID addition to an existing driver table (hardware-quirk exception)
- Codec already present and classified as ALC255 in this 6.18 tree
- Applies cleanly; no new API; standalone
- Tested by the author; ALSA maintainer applied it after Realtek confirmation
- Same pattern as other Realtek headset vendor-ID additions that stable accepts
Against:
- Subject reads like a feature (“Add support”)
- 2018 Realtek note said this bonding originally needed **no** headset alc_process_coef_fw() (Lenovo-only)
- No machine-specific quirk for 1043:1814 in this tree, so the ASUS laptop may still need model=alc255-asus (or a later quirk) for the new cases to run
- alc255_set_default_jack_type() still omits ALC235
Unresolved:
- Stable-list discussion (lore 403)
The “against” items do not outweigh the fix. The 2018 note is superseded by the same Realtek engineer in 2026. Missing model=/quirk is a separate enablement issue; this commit is still the required routing fix once headset mode is on. Incomplete default-jack-type setup did not prevent the reported fix from working.
**Step 9.2 — Stable rules**
1. Obviously correct and tested? **PASS** — fallthrough onto the existing ALC255 path; hardware + Realtek + maintainer.
2. Real bug affecting users? **PASS** — silent headset capture.
3. Important? **PASS** — broken headset mic on laptop HDA; hardware- quirk class.
4. Small and contained? **PASS** — +6 lines, one file.
5. No new features/APIs? **PASS** — missing ID in existing tables, not a new driver.
6. Applies to this 6.18 tree? **PASS** — same file and switches.
**Step 9.3 — Exception**
Record: **Hardware quirk / missing codec ID** in an existing Realtek HDA driver. This is an allowed stable exception.
**Step 9.4 — Decision**
This tree is 6.18.y. The buggy omission exists here. The patch is the standard Realtek headset-ID fix, confirmed by Realtek, and is appropriate for this stable tree.
## What this means for 6.18 users
ALC235 has been registered for years and is already treated as ALC255, but the headset-mode coefficient path never ran. On machines that use that path, a plugged headset is detected and the mic stays silent. Adding 0x10ec0235 beside 0x10ec0255 is a 6-line, already-tested hardware quirk with no API change and a clean apply on this tree.
## Verification
- [Phase 1] Parsed tags: Link to msgid 20260926140336.27896-1; SOBs Zeyu Li + Takashi Iwai; no Fixes/Reported-by/Cc-stable
- [Phase 2] Diff: +6 case 0x10ec0235: lines in six headset-mode functions in sound/hda/codecs/realtek/realtek.c
- [Phase 2] coef0255 in alc_headset_mode_ctia() is WRITE_COEF(0x45, 0xd489) + WRITE_COEF(0x1b, 0x0c2b), matching the author’s test
- [Phase 3] git describe HEAD / make kernelversion: **6.18.57**
- [Phase 3] git show 92f974df34601: ALC235 ID added 2014 as ALC233/ALC255-compatible
- [Phase 3] git show ea04a1dbf8b1d: 2018 variant assignment + note that headset coefs were then thought unnecessary
- [Phase 3] Parent of candidate: headset switches have 0x10ec0255 only; patch_alc269() already has 0x10ec0235 → ALC269_TYPE_ALC255
- [Phase 3] git log --author="Zeyu Li": only this commit in-tree
- [Phase 4] b4 dig -c 9ee4266827cfb…: thread at patch.msgid.link/20260926140336.27896-1
- [Phase 4] b4 dig -a: same patch, no later revision
- [Phase 4] b4 dig -w: linux-sound, Takashi Iwai, Jaroslav Kysela
- [Phase 4] mbox: Takashi asked Realtek; Kailang: “Yes, it's compatible.”; Takashi applied
- [Phase 5] Callers of the six functions are only alc_update_headset_mode(); that is wired only by headset-mode fixups
- [Phase 5] No 1043:1814 / M5451 quirk in alc269.c; ASUS pin quirks match 0x10ec0255 only
- [Phase 6] File and buggy switches exist in this 6.18 checkout; Realtek split aeeb85f26c3bb is an ancestor
- [Phase 6] Expected apply: clean
- [Phase 8] Failure mode: silent headset mic, severity HIGH for affected laptops
- UNVERIFIED: lore.kernel.org/stable search (HTTP 403)
The patch is a small, tested hardware-quirk fix for a real silent-mic bug that exists in this 6.18 tree.
**YES**
sound/hda/codecs/realtek/realtek.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/hda/codecs/realtek/realtek.c +6 -0
@@ -1305,6 +1305,7 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec) }switch (codec->core.vendor_id) { +case 0x10ec0235 :case 0x10ec0255 :alc_process_coef_fw (codec, coef0255);break ;
@@ -1420,6 +1421,7 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin, };switch (codec->core.vendor_id) { +case 0x10ec0235 :case 0x10ec0255 :alc_write_coef_idx (codec,0x45 ,0xc489 );snd_hda_set_pin_ctl_cache (codec, hp_pin,0 );
@@ -1575,6 +1577,7 @@ static void alc_headset_mode_default(struct hda_codec *codec)alc_process_coef_fw (codec, coef0225);alc_hp_enable_unmute (codec,75 );break ; +case 0x10ec0235 :case 0x10ec0255 :alc_process_coef_fw (codec, coef0255);break ;
@@ -1676,6 +1679,7 @@ static void alc_headset_mode_ctia(struct hda_codec *codec) };switch (codec->core.vendor_id) { +case 0x10ec0235 :case 0x10ec0255 :alc_process_coef_fw (codec, coef0255);break ;
@@ -1793,6 +1797,7 @@ static void alc_headset_mode_omtp(struct hda_codec *codec) };switch (codec->core.vendor_id) { +case 0x10ec0235 :case 0x10ec0255 :alc_process_coef_fw (codec, coef0255);break ;
@@ -1894,6 +1899,7 @@ static void alc_determine_headset_type(struct hda_codec *codec) }switch (codec->core.vendor_id) { +case 0x10ec0235 :case 0x10ec0255 :alc_process_coef_fw (codec, coef0255);msleep (300 );
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 drm/amdgpu/gfx11: WARN() rather than BUG() for invalid SDMA engine
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit c24edbd5ae0e4f24e0179e8c9f22a867016177bb ]
There's no need to crash the kernel for these cases.
---
LLM Generated explanations, may be completely bogus:
I have enough context: this is a three-line BUG()-to-WARN() change on the GFX11 KFD SDMA path, already present in this 7.3-rc4 tree. The remaining question is whether it is a real panic-prevention fix worth keeping in stable.
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: [drm/amdgpu/gfx11] [WARN() rather than BUG()] [stop panicking on an invalid SDMA engine id in get_sdma_rlc_reg_offset()]
**Step 1.2: Tags**
Record:
- Reviewed-by: Kent Russell <[email protected]> (AMD GPU developer)
- Signed-off-by: Alex Deucher <[email protected]> (amdgpu maintainer; ignore any Sasha Levin SOB)
- No Fixes:, Reported-by:, Tested-by:, Link:, or Cc: stable (absence expected)
**Step 1.3: Body**
Record: Body is one sentence: “There's no need to crash the kernel for these cases.” No stack trace, no reproducer, no version range. Failure mode claimed: kernel crash via BUG(). Root cause as stated: invalid engine_id in get_sdma_rlc_reg_offset() was treated as fatal.
**Step 1.4: Hidden bug fix?**
Record: Not hidden. It is an explicit panic-to-warning conversion. It is also patch 15/43 of Alex Deucher’s amdgpu BUG()-removal series (later resent as 02/30). Same boilerplate appears on sibling gfx12/gfx12.1 patches. That is hardening of a driver BUG(), not a style-only rename.
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record: One file, drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v11.c.
Function: get_sdma_rlc_reg_offset(). Scope: +2/−1, single-file surgical change.
**Step 2.2: Code flow**
Record: Before: switch (engine_id) handles 0 and 1; default: calls BUG() and never returns. After: WARN(1, "Invalid SDMA engine id %d\n", engine_id); break; then the function still computes sdma_rlc_reg_offset from sdma_engine_reg_base (initialized to 0) and returns. Affected path: invalid engine id on SDMA queue load/dump/occupy/destroy.
**Step 2.3: Bug mechanism**
Record: Category **(g) logic / correctness** plus crash hardening. BUG() is a kernel panic (unless CONFIG_BUG is off). The fix stops the panic and logs. It does not add a hard error return; callers still RREG32/WREG32 using a 0 base.
**Step 2.4: Fix quality**
Record: Obviously correct as “don’t panic.” Minimal. Regression risk is
low: if the default branch is taken, the kernel continues and may program SDMA engine 0-ish registers instead of dying. That matches the older gfx9/gfx10.3 pattern (dev_warn + fallthrough to engine 0), though this gfx11 version warns and breaks with base = 0 rather than explicitly using the engine-0 SOC15_REG_OFFSET. No public API change.
## Phase 3: Git history
**Step 3.1: Blame**
Record: Function and original BUG() introduced in cc009e613de65 (“drm/amdkfd: Add KFD support for soc21 v3”, Mukul Joshi, 2022-05-04). That commit is an ancestor of v6.1 and v6.6 in this repo. The WARN() lines are from c24edbd5ae0e4 (Alex Deucher, 2026-06-15 / committed 2026-07-08).
**Step 3.2: Fixes: tag**
Record: No Fixes: tag. Buggy code is the original gfx11 KFD SDMA helper, not a later regression.
**Step 3.3: File history / series**
Record: Standalone for this file. Related siblings:
- 28cc342e2455c gfx12 same change
- 9f8032604b973 gfx12.1 same change
Part of the June/July 2026 amdgpu BUG() cleanup. No extra gfx11 refactor is required for this hunk.
**Step 3.4: Author**
Record: Alex Deucher is the amdgpu maintainer. Around the same dates he landed many BUG()/BUG_ON() → WARN()/-EINVAL conversions across gfx/sdma/psp.
**Step 3.5: Prerequisites**
Record: None. The function and BUG() existed since the file was added. Applies standalone.
## Phase 4: Mailing list / external
**Step 4.1: Original discussion**
Record: b4 dig -c c24edbd5ae0e4 matched patch-id 8e42a5ee823a482676f1d117737bc3f4d06296d3.
Lore/msgid: https://patch.msgid.link/20260615235645.737189-15-
[email protected]
Series: v1 [PATCH 15/43] 2026-06-15; later v2 [PATCH 02/30] 2026-07-07. Committed version matches the posted diff. No NAKs found. No reviewer Cc: stable on this patch. Cover-letter fetch from lore returned 403; mail-archive and Phoronix describe the series as removing amdgpu BUG() so the driver does not panic when it can continue.
**Step 4.2: Recipients (b4 dig -w)**
Record: Alex Deucher, [email protected]. Kent Russell’s Reviewed-by is on the git commit, not on the v1 mail-archive copy (review landed later / at commit time).
**Step 4.3: Bug report**
Record: None. No syzbot, bugzilla, or user panic report.
**Step 4.4: Related patches**
Record: Independent per-IP copies. This gfx11 hunk does not depend on the rest of the 43-patch series.
**Step 4.5: Stable list**
Record: No stable-thread hit found for this subject. UNVERIFIED:
lore.kernel.org/stable search was blocked (Anubis/403).
## Phase 5: Semantic / call graph
**Step 5.1: Functions**
Record: get_sdma_rlc_reg_offset() only.
**Step 5.2: Callers (this tree)**
Record:
- hqd_sdma_load_v11() — KFD SDMA queue load
- hqd_sdma_dump_v11() — dump (debug / dqm)
- hqd_sdma_is_occupied_v11()
- hqd_sdma_destroy_v11() — preempt/destroy
Those are gfx_v11_kfd2kgd ops. Load goes kfd_load_mqd_sdma() → hqd_sdma_load(). Dump is used from kfd_device_queue_manager.c.
**Step 5.3: Callees**
Record: SOC15_REG_OFFSET, register arithmetic, pr_debug. Callers then RREG32/WREG32 at the returned offset.
**Step 5.4: Reachability**
Record: Yes, from /dev/kfd queue create/destroy (needs KFD/render access, not a raw unprivileged syscall). engine_id comes from v11_sdma_mqd.sdma_engine_id, set in kfd_mqd_manager_v11.c from q->sdma_engine_id.
Kernel assignment (kfd_device_queue_manager.c):
- normal SDMA: sdma_id % kfd_get_num_sdma_engines()
- kfd_get_num_sdma_engines() is num_instances/num_nodes, or min(..., 2) if XGMI
Userspace KFD_QUEUE_TYPE_SDMA_BY_ENG_ID is range-checked against num_sdma + num_xgmi - 1 in kfd_ioctl_create_queue().
Verified: on typical GFX11 (2 SDMA, no XGMI) the id is 0 or 1, so default: is not the normal path. Unverified: whether any GFX11 SKU with XGMI and >2 SDMA instances can produce engine_id >= 2 and hit BUG().
**Step 5.5: Similar patterns**
Record: gfx9 and gfx10.3 already dev_warn + fallthrough to engine 0. gfx11/12/12.1 used BUG() until this series. This is aligning gfx11 with the safer sibling.
## Phase 6: This tree
**Step 6.1: Buggy code in this checkout?**
Record: Local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). File exists. Current get_sdma_rlc_reg_offset() already has WARN(1, ...). git merge-base --is-ancestor c24edbd5ae0e4 HEAD succeeds. The panic path is already gone here; the pre-fix BUG() is in the parent of that commit.
**Step 6.2: Backport difficulty**
Record: Clean apply. Hunk matches the original function from 2022; no conflicting refactor in that switch.
**Step 6.3: Related fixes already here**
Record: This exact fix is already ancestor of HEAD. Sibling gfx12/12.1 conversions are also present. No alternate gfx11 SDMA BUG() fix.
## Phase 7: Subsystem
**Step 7.1**
Record: drivers/gpu/drm/amd/amdgpu KFD GFX11. Criticality:
**IMPORTANT** (RDNA3 / RX 7000 / Phoenix, not core mm/vfs).
**Step 7.2**
Record: amdgpu/KFD is actively developed; this helper itself has been stable since 2022.
## Phase 8: Impact and risk
**Step 8.1: Who**
Record: Users of AMD GFX11 + KFD compute (ROCm / /dev/kfd), config CONFIG_HSA_AMD. Driver-specific, not universal.
**Step 8.2: Trigger**
Record: Invalid engine_id not in {0,1} on SDMA HQD load/dump/destroy. Common path uses kernel-assigned 0/1. Userspace engine id is validated for SDMA_BY_ENG_ID. Trigger is uncommon; not shown as a day-to-day ROCm failure. Not a fully unprivileged DoS on typical 2-engine GFX11.
**Step 8.3: Failure mode**
Record: Old: BUG() → kernel panic. Severity if hit: **CRITICAL**.
Likelihood: **LOW** on known 2-engine GFX11. After the fix: warning + possible wrong MMIO if the branch is taken.
**Step 8.4: Risk-benefit**
Record: Benefit: avoid an intentional driver panic on a bad engine id.
Risk: 3 lines, no locking/API change, very low. Ratio: favorable if the panic is treated as worth preventing; weaker if judged purely theoretical.
## Phase 9: Synthesis
**Step 9.1: Evidence**
FOR:
- Replaces BUG() (panic) with WARN() on a real KFD SDMA path.
- 3-line, obviously correct, reviewed by Kent Russell, written by the amdgpu maintainer.
- GFX11 KFD support has been in the kernel since 2022 (cc009e613de65, ancestor of v6.1).
- gfx9/gfx10.3 already refused to panic here; gfx11 was the harsh outlier.
- No prerequisites; applies cleanly to this file.
- Prompt’s crash/panic guidance favors inclusion.
AGAINST:
- No user report, syzbot, or demonstrated trigger.
- Official stable rule: not a “this could be a problem” patch without an exploit/trigger explanation.
- Identical one-line body across a 43-patch cleanup series, not a targeted production-crash fix.
- On typical GFX11, engine id is 0 or 1, so default: is largely defensive.
- After WARN(), execution continues with base = 0 rather than failing the ioctl.
UNRESOLVED:
- Whether any GFX11 product can assign engine_id >= 2 via XGMI extra SDMA engines.
- Full cover-letter text (lore 403).
- Stable-list discussion (lore/stable blocked).
**Step 9.2: Stable rules checklist**
1. Obviously correct and tested? **PASS** — 3-line substitution, reviewed, in mainline.
2. Fixes a real bug that affects users? **PASS** with caveat — it fixes a real panic *if* the branch runs; no evidence users hit it. Still a driver BUG() on a userspace-reachable KFD path.
3. Important (crash/security/corruption/deadlock)? **PASS** for the failure mode (panic). Likelihood is low.
4. Small and contained? **PASS** — +2/−1, one function.
5. No new features/APIs? **PASS**.
6. Can apply to this tree? **PASS** — file/function exist; hunk is identical. (Already applied on 7.3-rc4.)
**Step 9.3: Exception category**
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary robustness fix.
**Step 9.4: Decision**
This tree is 7.3-rc4 and already contains the commit; the evaluation is whether the change is stable-worthy for this codebase, not whether to re-apply it.
It should be. BUG() in get_sdma_rlc_reg_offset() is an intentional kernel panic on the GFX11 KFD SDMA load/destroy path. Replacing it with WARN() is the same policy older GFX generations already used, it is three lines, and it cannot introduce a new API or locking scheme. Lack of a public reproducer makes it a cleanup-shaped patch, but the user- visible failure if that branch ever runs is still a full panic, which is what stable is for.
### What it solves for stable users
Stops the GFX11 KFD SDMA helper from taking down the machine on an out- of-range engine id, instead of asserting.
### Rules
Small, obviously correct, no new API, applies to this file. It addresses a panic, not a feature.
### Risk vs benefit
Benefit is panic avoidance on AMD RDNA3 compute queues. Risk is negligible.
### Concerns
Trigger is uncommon; after WARN() the function still returns a 0-based offset. That is acceptable versus BUG(). No extra commits are required.
## Verification
- [Phase 1] Parsed subject/body/tags: one-sentence panic rationale; Reviewed-by: Kent Russell; no Fixes/Reported-by.
- [Phase 2] Diff: BUG() → WARN(1, ...) + break in get_sdma_rlc_reg_offset(); +2/−1.
- [Phase 3] git blame: BUG() from cc009e613de65 (2022-05-04); ancestor of v6.1 and v6.6.
- [Phase 3] git show c24edbd5ae0e4: matches the candidate diff.
- [Phase 3] git merge-base --is-ancestor c24edbd5ae0e4 HEAD: yes (already in this tree).
- [Phase 4] b4 dig -c c24edbd5ae0e4: msgid [email protected] (15/43).
- [Phase 4] b4 dig -a: v1 43-patch series 2026-06-15; v2 30-patch 2026-07-07.
- [Phase 4] b4 dig -w: To/Cc Alex Deucher + amd-gfx; no stable CC.
- [Phase 4] mail-archive: posted diff identical; no NAK in the copies read.
- [Phase 4] UNVERIFIED: lore.kernel.org cover letter and stable@ archive (403/Anubis).
- [Phase 5] Callers verified: hqd_sdma_load_v11 / dump / is_occupied / destroy; load via kfd_load_mqd_sdma.
- [Phase 5] engine_id from MQD ← q->sdma_engine_id; ioctl range check for SDMA_BY_ENG_ID; typical GFX11 stays 0/1.
- [Phase 5] gfx9/gfx10.3 already warn instead of BUG().
- [Phase 6] git describe HEAD / Makefile: 7.3.0-rc4; current file already has WARN().
- [Phase 8] Failure mode if hit: BUG() panic; trigger likelihood low on 2-engine GFX11.
- UNVERIFIED: GFX11 SKU with engine_id >= 2 in production.
**YES**
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v11.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v11.c +2 -1
@@ -139,7 +139,8 @@ static uint32_t get_sdma_rlc_reg_offset(struct amdgpu_device *adev, regSDMA1_QUEUE0_RB_CNTL) - regSDMA0_QUEUE0_RB_CNTL;break ;default : -BUG (); +WARN (1 ,"Invalid SDMA engine id %d\n" , engine_id); +break ; } sdma_rlc_reg_offset = sdma_engine_reg_base
Signature · 1 line
2.53.0