net: dsa: mt7530: check CORE_PLL_GROUP4 access in mt7531_setup()
Subsystems (71)
Sasha Levin
maintainerPATCH 1/1 comedi: pcm711: Fix sanity check in interrupt handler
In reply to Sasha LevinFrom: Ian Abbott <[email protected]>
[ Upstream commit f876cbfe3e066bc9e3f3210907bd534be82946c8 ]
The driver requests an interrupt handler for the device before it is fully set up.
For safety, the interrupt handler checks the dev->attached flag to ensure the device is fully set up, but it currently does that after dereferencing the dev->read_dev pointer which may be NULL if dev->attached is false. Move the check to avoid the possible null pointer dereference.
---
LLM Generated explanations, may be completely bogus:
The local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). This is a 3-line interrupt-handler reorder that stops a NULL dereference of dev->read_subdev / s->async if an IRQ fires during pcl711_attach(), before dev->attached is set.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [comedi/pcl711] [Fix] sanity check in interrupt handler
- Subsystem: comedi (COMEDI data-acquisition), driver pcl711 (Advantech PCL-711 / ADLink ACL-8112). Subject says pcm711; the file is pcl711.c (typo, same as other patches in the series).
- Action verb: **Fix** — explicit bug fix.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Fixes: — none (expected for this review)
- Reported-by: Jaeyoung Chung <[email protected]>
- Reported-by: Sangyun Kim <[email protected]>
- Reported-by: Kyungwook Boo <[email protected]>
- `Link: https://lore.kernel.org/lkml/20260610115912.780131-1-
[email protected]/` (original report)
- `Link:
https://patch.msgid.link/[email protected]`
(patch 06/11)
- Signed-off-by: Ian Abbott <[email protected]> (COMEDI maintainer)
- Signed-off-by: Greg Kroah-Hartman <[email protected]>
- No Cc: stable, no Tested-by, no Reviewed-by, no Acked-by
- Notable: **three reporters**; original mail describes a **KASAN null- ptr-deref / kernel panic**.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** IRQ handler is registered in pcl711_attach() before the device is fully set up. The handler already checks dev->attached, but only **after** cmd = &s->async->cmd, which dereferences dev->read_subdev (commit text says read_dev; code is read_subdev).
- **Symptom:** NULL pointer dereference in interrupt context → oops/panic. Original report: “triggering a KASAN null-ptr-deref”.
- **Root cause:** request_irq() runs before dev->read_subdev is assigned and before core postconfig sets dev->attached and allocates s->async.
- **Version info:** none in the message. The buggy deref has been in this handler since the 3.13/3.16-era staging rework.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Subject and body both say this is a null-ptr-deref fix. Cover letter: “Add/fix sanity check in ISA drivers to avoid null- ptr-deref”.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/comedi/drivers/pcl711.c (+2 / −1)
- Function: pcl711_interrupt()
- Scope: single-file surgical fix, 3 lines
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** s = dev->read_subdev; then immediately cmd = &s->async->cmd; then if (!dev->attached) return;. If s is NULL, that second line oopses. If s is set but s->async is not yet allocated (postconfig), same oops.
- **After:** declare cmd uninitialized; check dev->attached first; only then cmd = &s->async->cmd.
- Path: interrupt / attach-time error path, not the steady-state sample path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** NULL pointer dereference (memory safety)
- **Mechanism:** pcl711_attach() calls request_irq() at line 431, then later sets dev->read_subdev at line 457. Core sets dev->attached = true only in comedi_device_postconfig() after __comedi_device_postconfig_async() allocates s->async. A premature IRQ (pending line, wrong ISA IRQ/I/O config, leftover hardware state) hits the handler with read_subdev and/or s->async still NULL.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: the existing guard is just moved before the first dereference of s.
- Minimal; no API, locking, or data-structure change.
- Regression risk: very low. After attached is true, attach has assigned read_subdev (when IRQ was requested) and postconfig has allocated s->async.
- Residual: s = dev->read_subdev still runs before the check, but that is a pointer load, not a dereference. Same unlocked dev->attached read as the rest of COMEDI; this patch does not make that worse.
- Typos in subject/body (pcm711, read_dev) do not affect the code.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- if (!dev->attached): original handler, David Schleef, 2009 (456af2011ce33e).
- s = dev->read_subdev: 8f494fe626b473 (2013-09-25), first in **v3.13-rc1**.
- cmd = &s->async->cmd before the attached check: ae2348e2282452 (2014-05-27), first in **v3.16-rc1**.
- Long-standing bug, not recent code.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable. Introducers above are in this tree’s history.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES** Record:
- f876cbfe3e066 — this fix
- 7e33ddd6d0282 — I/O-base sanity checks (unrelated)
- No later commits on pcl711.c after this fix
- Sibling series (same author, same day): dt2811, ni_at_a2150, pcl816, pcl818, pcmmio, pcmuio, quatech_daqp_cs, aio_iiro_16, das6402, ni_atmio16d
- Standalone for this file: patch 06/11, no dependency on the other patches
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Ian Abbott is **COMEDI maintainer** (MAINTAINERS: COMEDI DRIVERS, status Odd Fixes). He wrote this series and the earlier 17221216ae8ce (comedi_parport: deal with premature interrupt) for the same report.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Uses dev->attached, read_subdev, s->async->cmd — all present for years. Applies standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c f876cbfe3e066:
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only** (11-patch series, 2026-06-18)
- Cover: “several comedi ISA drivers register their interrupt handler before initializing the subdevice … null pointer dereferences if the device raises an interrupt prematurely.”
- No NAKs, no review comments, no explicit Cc: stable in the thread (mbox is patches only, no replies)
- Applied as submitted by Greg KH (char-misc), 2026-07-17
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w):
- To: linux-kernel
- Cc: Greg Kroah-Hartman, H Hartley Sweeten (co-maintainer), the three reporters
- No Reviewed-by. Quality signal is that the **subsystem maintainer authored it** and Greg applied it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: Fetched https://lore.kernel.org/lkml/20260610115912.780131-1-
[email protected]/raw
- Jaeyoung Chung (SNU): several ISA drivers register the IRQ before read_subdev is set.
- “If the device raises an interrupt before the subdevice is initialized, the handler runs against an uninitialized subdevice, causing a **kernel panic**.”
- Names pcl711_interrupt() / pcl711_attach() explicitly; KASAN null- ptr-deref.
- Suggested fix: move request_irq() later **or** guard NULL read_subdev. Maintainer chose the existing dev->attached pattern.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 11 independent per-driver patches. This one only needs pcl711.c. comedi_parport was already fixed separately (17221216ae8ce).
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable searches for “pcm711”, “Fix sanity check in interrupt handler”, and “comedi null-ptr-deref” found **no discussion of this 2026 fix**. (Older “pcl711 sanity” hits are unrelated 2021 stable reviews.)
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: pcl711_interrupt() (handler); setup in pcl711_attach().
**Step 5.2: TRACE CALLERS**
Record:
- Registered via request_irq(..., pcl711_interrupt, 0, ...) in pcl711_attach() (non-shared).
- Invoked from IRQ context when the configured ISA IRQ fires.
- pcl711_interrupt has no other callers.
**Step 5.3: TRACE CALLEES**
Record: pcl711_ai_get_sample() (port I/O), comedi_buf_write_samples(), comedi_handle_events(), outb() to clear IRQ status. After the fix, those run only if dev->attached.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace COMEDI_DEVCONFIG → pcl711_attach() → request_irq(). Reachable from the comedi ioctl path when CONFIG_COMEDI_PCL711 is enabled and an IRQ is in the config options. Wrong ISA IRQ/I/O (the report’s realistic case) can fire the handler during that window. Unprivileged trigger: only if the user can configure the comedi device (typically privileged). Failure is still a kernel oops.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same bug class across the 11-driver series. ni_660x.c even comments “make sure dev->attached is checked before doing anything else.” This is a systematic COMEDI ISR pattern, not a one-off.
===============================================================
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 f876cbfe3e066 HEAD → yes. Fix landed in **v7.3-rc1** (not in v7.2).
- Driver and handler exist: drivers/comedi/drivers/pcl711.c. Pre-fix form (deref then attached check) is in f876cbfe3e066^.
- Bug introduced ~v3.13/v3.16; present in every current stable lineage that has this driver.
- HEAD already has the fixed handler (lines 183–209). That does not make the fix unsuitable for older trees of this lineage.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply. The function body has been stable since 2014 aside from this reorder. No conflicting local changes. CONFIG_COMEDI_PCL711 exists.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This commit is the fix; no later pcl711 ISR change. comedi_parport premature-IRQ fix is a sibling, not a substitute.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/comedi/ — ISA/PC-104 DAQ. **PERIPHERAL / config- specific** (CONFIG_COMEDI_PCL711, depends on ISA/PC104 + HAS_IOPORT). Not core mm/net/fs, but a real in-tree driver with users.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: “Odd Fixes”; Ian Abbott still sends targeted fixes. Mature driver, old bug, small patch.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Users of Advantech PCL-711/711B and ADLink ACL-8112 with IRQ enabled. Config- and hardware-specific, not universal.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Window: after request_irq() in pcl711_attach(), before read_subdev assignment and before dev->attached = true in postconfig.
- How common: not every boot; ISA leftover IRQ, wrong IRQ/I/O in comedi config, or a pending line. Cover letter/report treat that as the failure mode.
- Unprivileged: generally no (device config is privileged). Still a kernel oops if it fires.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: NULL deref in IRQ context → **oops/panic**. Original report:
kernel panic / KASAN null-ptr-deref. **Severity: HIGH** (crash; not a hot-path UAF, but a hard crash).
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** HIGH for affected hardware — prevents attach-time oops. Medium globally (small user base).
- **Risk:** VERY LOW — 3-line reorder of an existing check; no lock/API change.
- **Ratio:** benefit outweighs risk. Stable rules favor small crash fixes even in niche drivers.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR backporting:
- Real NULL deref in IRQ handler → kernel panic (KASAN report).
- Three reporters; maintainer-authored; Greg applied it.
- 3-line, obviously correct reorder of an existing guard.
- Bug present since ~2013/2014; driver exists in this tree.
- Standalone; no prerequisites; applies cleanly.
- Same pattern already used elsewhere in COMEDI (dev->attached first).
AGAINST:
- Niche ISA DAQ (CONFIG_COMEDI_PCL711); not a universal path.
- Trigger is attach-time premature IRQ, not every sample.
- No Fixes: / Cc: stable (not a negative under these rules).
- No mailing-list review beyond the maintainer.
UNRESOLVED:
- No on-list replies in the saved mbox (Greg applied v1). Does not change correctness.
- lore WebFetch returned 403; report body was retrieved via raw URL instead.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — reorder of an existing check; maintainer + three reporters.
2. Fixes a real bug that affects users? **PASS** — NULL deref / panic on premature IRQ during attach.
3. Important issue? **PASS** — kernel oops in interrupt context (HIGH).
4. Small and contained? **PASS** — +2/−1 in one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — same pcl711_interrupt() structure; this tree already contains equivalent code.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary small crash fix.
**Step 9.4: MAKE YOUR DECISION**
This is a surgical NULL-deref fix in an interrupt handler. The buggy code has been in this driver for over a decade, the failure is a kernel oops, and the patch only moves a check that was already there. It meets stable-kernel rules for this tree.
===============================================================
Why it matters to stable users
===============================================================
COMEDI attach registers pcl711_interrupt before read_subdev and s->async exist and before dev->attached is set. A premature IRQ then executes cmd = &s->async->cmd on a NULL pointer and panics. Moving the attached check first closes that window without changing normal sampling.
Risk vs benefit: three lines, no semantic change on the success path, crash avoided on the attach/error path. Safe to backport.
Verification:
- [Phase 1] Parsed tags: three Reported-by (SNU); lore link to original report; maintainer + Greg SOBs; no Fixes/Cc-stable
- [Phase 1] Cover letter: explicit null-ptr-deref if IRQ fires before subdevice init
- [Phase 2] Diff: +2/−1 in pcl711_interrupt(); delay cmd = &s->async->cmd until after dev->attached
- [Phase 2] Confirmed pre-fix parent still dereferenced s->async before the attached check
- [Phase 3] Blame: attached check 2009; read_subdev in ISR v3.13 (8f494fe626b473); cmd = &s->async->cmd v3.16 (ae2348e2282452)
- [Phase 3] No Fixes tag; git merge-base --is-ancestor f876cbfe3e066 HEAD succeeded
- [Phase 3] Author is COMEDI maintainer; series of 11 independent per- driver patches
- [Phase 4] b4 dig -c:
https://patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1 only, no later revision
- [Phase 4] b4 dig -w: Greg KH, Hartley Sweeten, reporters on Cc
- [Phase 4] Original report raw: names pcl711_interrupt, KASAN null- ptr-deref, kernel panic
- [Phase 4] stable list: no discussion of this 2026 fix
- [Phase 5] Only caller is request_irq in pcl711_attach() (line 431); read_subdev assigned at line 457; attached set in comedi_device_postconfig() after async alloc
- [Phase 5] No semcode MCP; used grep/read
- [Phase 6] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion: 7.3.0-rc4
- [Phase 6] Commit in v7.3-rc1, not v7.2; driver present; no post-fix pcl711 churn
- [Phase 8] Failure mode: IRQ-context NULL deref → oops/panic, severity HIGH
- UNVERIFIED: live hardware reproduction (code-path analysis + reporter KASAN writeup only)
- UNVERIFIED: lore HTML (403); raw mbox succeeded
**YES**
drivers/comedi/drivers/pcl711.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/comedi/drivers/pcl711.c +2 -1
@@ -181,7 +181,7 @@ static irqreturn_t pcl711_interrupt(int irq, void *d) {struct comedi_device *dev = d;struct comedi_subdevice *s = dev->read_subdev; -struct comedi_cmd *cmd = &s->async->cmd; +struct comedi_cmd *cmd;unsigned short data;if (!dev->attached) {
@@ -189,6 +189,7 @@ static irqreturn_t pcl711_interrupt(int irq, void *d)return IRQ_HANDLED ; } + cmd = &s->async->cmd; data =pcl711_ai_get_sample (dev, s);outb (PCL711_INT_STAT_CLR , dev->iobase +PCL711_INT_STAT_REG );
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 xhci: include all root port children in recovery prevention on link error
In reply to Sasha LevinFrom: Mathias Nyman <[email protected]>
[ Upstream commit e3d757dc9257f2638ca61eda4faef26c2daeea10 ]
Driver already prevents useless transfer retry and endpoint recovery for devices directly connected to a root port with link errors.
These devices are either disconnecting or will be reset. Link is gone.
Move the flag indicating link error from the xhci device structure to the root port strucure, allowing all child devices behind hubs to easily check for root port link errors, avoiding useless transfer retries and endpoint recovery.
This extends the previous endpoint recovery prevention in commit b8c3b718087b ("usb: xhci: Don't try to recover an endpoint if port is in error state.")
Only root port link errors can be detected early by xhci driver, not link errors between external hubs and their children.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
- Record: [xhci] [include] extend existing root-port link-error recovery skip from the directly attached device to every device under that root port.
**Step 1.2: Tags**
- Record:
- Tested-by: Xu Rao <[email protected]>
- Signed-off-by: Mathias Nyman <[email protected]> (xhci maintainer)
- `Link: https://patch.msgid.link/20260806142113.2436238-4-
[email protected]`
- Signed-off-by: Greg Kroah-Hartman <[email protected]>
- No Fixes: / Cc: stable (expected for this review)
- Pipeline Signed-off-by: Sasha Levin ignored
- Notable: maintainer-authored; tester is the person who hit the host- teardown bug.
**Step 1.3: Body**
- Record:
- **Bug:** On a root port in SS.Inactive, xhci already skips URB enqueue and endpoint reset for the device plugged into that port (VDEV_PORT_ERROR). Devices behind hubs never get that flag, so they still retry transfers and reset endpoints after the root-port link is gone.
- **Symptom:** Useless recovery while the hub driver is still sorting the port out. The existing comment on this path is “Can cause host hang.” The 2019 precursor (b8c3b718087b) documented host- controller stop after repeated endpoint resets on an inactive root port.
- **Root cause:** The error flag lives on xhci_virt_device, and handle_port_status() only sets it on xhci->devs[port->slot_id] (the device directly on the root port).
- **Fix:** Move the flag to xhci_port->link_inactive so every child
that already has `vdev->rhub_port` can see the same root-port state.
- **Limit:** Only root-port link errors are visible this way, not hub- to-child link errors.
**Step 1.4: Hidden bug fix?**
- Record: Not hidden. It is an explicit extension of a hang-prevention check. Moving the flag off vdev is a small structural change with standalone functional effect, not a pure cleanup.
## Phase 2: Diff analysis
**Step 2.1: Inventory**
- Record:
- drivers/usb/host/xhci-ring.c: xhci_handle_halted_endpoint(),
`handle_port_status()` (~15+/12-)
- `drivers/usb/host/xhci.c`: `xhci_urb_enqueue()`,
`xhci_discover_or_reset_device()` (1+ / 3-) - drivers/usb/host/xhci.h: drop vdev->flags / VDEV_PORT_ERROR; add xhci_port.link_inactive:1
- Net: 17 insertions, 23 deletions. Single-subsystem surgical change.
**Step 2.2: Control-flow change**
- Record:
- **Before:** Port event with PLS==XDEV_INACTIVE and no PORT_RESET
sets `vdev->flags |= VDEV_PORT_ERROR` on the directly attached slot
only. `PORT_RC` clears it. `reset_device` also zeros `vdev->flags`.
Halted-endpoint recovery and URB enqueue consult that per-device
flag. - **After:** If the port is not in reset, port->link_inactive = (pls == XDEV_INACTIVE). All devices whose rhub_port is that port skip recovery/enqueue. Device reset no longer clears the flag; port events drive it from real PLS.
**Step 2.3: Bug mechanism**
- Record: **Logic / correctness + hardware hang workaround.** Same class as the 2019 “don’t reset an endpoint on an inactive root port” fix. Also improves flag lifetime vs the stale-flag bug already fixed in this tree by d77efd7b3def7 (clearing is now “link is not Inactive”, not “PORT_RC or reset_device succeeded”).
**Step 2.4: Fix quality**
- Record: Obviously correct for the stated gap. Minimal. Regression risk is low: skipping recovery when the root-port link is gone is the intended policy; clearing is tied to actual port state, which is stricter and more accurate than clearing on reset_device while the port may still be Inactive. Theoretical rhub_port == NULL deref exists in the new loads; xhci_setup_addressable_virt_dev() sets rhub_port before normal URB traffic, and mainline has no follow-up NULL-check fix on this path.
## Phase 3: Git history
**Step 3.1: Blame**
- Record: Flag set/clear in handle_port_status() is d77efd7b3def7 (2025), which reworked b8c3b718087b (2019-06-18, v5.2-rc5 era, `Cc:
stable`). The hang-prevention hole for hub children has been in the driver since 2019.
**Step 3.2: Fixes: tag**
- Record: None. The message names b8c3b718087b, which **is** an ancestor of this 6.12 tree (git merge-base --is-ancestor exit 0).
**Step 3.3: Related file history**
- Record:
- d77efd7b3def7 “fix stale flag preventing URBs after link state error is cleared” — already in this tree; this commit supersedes its per-vdev flag management.
- Same-day series on origin/master: e3d757dc9257f (this) →
`042aad8d0db66` (disconnect) → `7e0ef4332ed9b` (`EP_DROP_PENDING`).
- None of those three are in this checkout.
**Step 3.4: Author**
- Record: Mathias Nyman is the xhci maintainer. This is his generic replacement for Xu Rao’s proposed XHCI_NO_SOFT_RETRY quirk on Renesas uPD720201.
**Step 3.5: Dependencies**
- Record: This patch does **not** need the later two to compile or to apply its own logic. The later two **do** need this (rhub_port->link_inactive). Local context differs (readl(port->addr) vs xhci_portsc_readl(), no xhci_sideband field); those are apply-noise, not semantic prerequisites. rhub_port itself (06790c19086fe) is already here.
## Phase 4: Mailing list
**Step 4.1: Original discussion**
- Record:
- b4 dig -c e3d757dc9257f: lore `https://patch.msgid.link/2026080614
[email protected]` - Applied version is **[PATCH 03/17] xhci features and fixes for usb- next** (Aug 6 2026). - First posting was **[RFT PATCH 1/3] xhci: avoid futile stop endpoint command and host teardown** (`20260629123031.142133-2`).
- Cover letter of that RFT: stop-endpoint timeout → xHCI host controller not responding, assume dead.
- No NAK. No reviewer Cc: stable on this specific patch.
**Step 4.2: Recipients**
- Record: b4 dig -w: Mathias Nyman, gregkh, linux-usb, Xu Rao. Right list and USB maintainer.
**Step 4.3: Bug report**
- Record: Xu Rao, Renesas uPD720201 (1912:0014), Genesys Logic hub + RTL8153. Repro: bring Ethernet up, hot-unplug hub. Log:
- Transfer error → Soft-reset ep → xHCI host not responding to stop endpoint command → assume dead → HC died.
- Xu tested the **3-patch RFT as a whole** and said the teardown is gone; he also said the EP_DROP_PENDING path (patch 3 of that series) was used on disconnect. He agreed the generic series made the XHCI_NO_SOFT_RETRY quirk unnecessary.
**Step 4.4: Series context**
- Record: Standalone for *link-error* hub children. The reported hot- unplug teardown is a **disconnect** path that also wants 042aad8d0db66 and 7e0ef4332ed9b. This commit is still the necessary first step and independently closes the Inactive-link gap.
**Step 4.5: stable@ discussion**
- Record: No stable-specific thread found for this SHA. The 2019 precursor and the 2025 stale-flag fix both went to stable.
## Phase 5: Semantic / call-path analysis
**Step 5.1: Functions**
- Record: xhci_handle_halted_endpoint(), handle_port_status(), xhci_urb_enqueue(), xhci_discover_or_reset_device(). Structs:
xhci_virt_device, xhci_port.
**Step 5.2: Callers of halted-endpoint recovery (this tree)**
- Record: transaction/babble/split errors, stall, bulk/interrupt soft- retry (process_bulk_intr_td), stream transferless events, stop-ep completion racing a stall. All of these run from xhci interrupt/event handling during normal USB I/O.
**Step 5.3: Callees**
- Record: xhci_reset_halted_ep() / xhci_queue_reset_ep() — the commands that, on a dead link, have hung or killed hosts.
**Step 5.4: Reachability**
- Record: Yes. Any USB transfer on a device under an xhci root port whose PLS is XDEV_INACTIVE. Hot-unplug / bad SuperSpeed link is a normal user action, not a debug path.
**Step 5.5: Similar patterns**
- Record: Same skip already exists for the directly attached device. Follow-up commits add port->connected and EP_DROP_PENDING for disconnect; they are not in this tree.
## Phase 6: This tree (6.12.111)
**Step 6.1: Buggy code present?**
- Record: **Yes.** p-6.12-3-gc504cf0baa3d8, VERSION=6 PATCHLEVEL=12 SUBLEVEL=111.
- xhci.h:753 VDEV_PORT_ERROR
- xhci-ring.c:943 and xhci.c:1572 still test vdev->flags
- xhci-ring.c:2024-2028 still sets the flag only on the directly attached vdev
- Candidate SHA e3d757dc9257f is **not** an ancestor of HEAD.
**Step 6.2: Backport difficulty**
- Record: **Minor context.** This tree still uses readl(port->addr) (not xhci_portsc_readl), xhci_get_usb3_hcd(), and has no xhci_sideband. The logic hunks (VDEV_PORT_ERROR → rhub_port->link_inactive, port-level PLS update, drop virt_dev->flags = 0) match this tree.
**Step 6.3: Related fixes already here**
- Record: b8c3b718087b and d77efd7b3def7 are here. They only cover the directly attached device. Disconnect/EP_DROP_PENDING follow-ups are not here. Renesas 0x0014 still has only XHCI_ZERO_64B_REGS, not XHCI_NO_SOFT_RETRY.
## Phase 7: Subsystem
**Step 7.1**
- Record: USB xhci host controller. **IMPORTANT** — default host on most PCs, many embedded SoCs, Android.
**Step 7.2**
- Record: Actively maintained; this is a targeted hang-prevention fix in a mature path, not a new subsystem.
## Phase 8: Impact and risk
**Step 8.1: Who is affected**
- Record: Users of xhci with a hub (or composite device with an integrated hub) under a root port that goes SS.Inactive, plus any topology that currently misses VDEV_PORT_ERROR. Confirmed hardware:
Renesas uPD720201 + Genesys hub + RTL8153; the mechanism is not vendor-specific.
**Step 8.2: Trigger**
- Record: Root-port link Inactive (cable/hub/link training). Common in the field. Unprivileged users can unplug USB devices. Full Xu Rao hot- unplug teardown also needs the later disconnect patches.
**Step 8.3: Failure mode**
- Record: Endpoint reset / soft-retry on a dead link → stop-endpoint timeout → **xHCI host controller not responding, assume dead** → entire xhci bus torn down. **CRITICAL** (host death, all USB on that controller gone). The 2019 write-up also described host stop after repeated endpoint resets.
**Step 8.4: Risk/benefit**
- Record: Benefit high (prevents host teardown on a realistic USB event; closes a 2019 hang hole for hub children). Risk low (~20-line xhci- only change, no API, policy already used for direct-attach devices). Ratio favors backport.
## Phase 9: Synthesis
**For:**
- Real hang/host-death class bug; xhci is widely deployed.
- Extends a fix that already went to stable in 2019.
- Small, maintainer-written, tester-acked as part of the hang series.
- Buggy code is in 6.12; apply needs only local context tweaks.
- Standalone value: hub children currently do not skip recovery on root- port Inactive.
**Against:**
- First of a 3-patch hang series; Xu Rao’s hot-unplug case also needs the disconnect + EP_DROP_PENDING patches.
- No Cc: stable on this commit (not a negative per the review rules).
- Tiny leftover: vdev is still fetched in handle_port_status() for later xhci_ring_device(), so it is not unused.
**Unresolved:** Whether rhub_port can be NULL at xhci_urb_enqueue() in some rare pre-address path — unverified as a real 6.12 trigger; not used as a NO reason.
**Stable rules**
1. Obviously correct and tested — **PASS** (maintainer + Tested-by)
2. Real user-visible bug — **PASS** (host teardown / hang)
3. Important — **PASS** (CRITICAL: xhci assumed dead)
4. Small and contained — **PASS**
5. No new features/APIs — **PASS**
6. Applies to this tree — **PASS** (minor context)
**Exception category:** None required; ordinary bugfix.
This should be backported to **this** 6.12 tree. It is not a new feature; it is the missing half of an existing hang-prevention check. The later two series patches are additional (disconnect) coverage, not a reason to keep this gap in 6.12.
## Verification
- [Phase 1] Parsed tags: Tested-by Xu Rao; Link msgid ...2436238-4; maintainer SOB; no Fixes/Cc:stable
- [Phase 2] Diff: move VDEV_PORT_ERROR from xhci_virt_device to xhci_port.link_inactive; 17+/23-
- [Phase 3] git describe HEAD / Makefile: **6.12.111** (p-6.12-3-gc504cf0baa3d8)
- [Phase 3] git merge-base --is-ancestor b8c3b718087b HEAD → yes; e3d757dc9257f → no
- [Phase 3] git blame on flag set/clear: d77efd7b3def7 (already in tree) over b8c3b718087b (2019)
- [Phase 3] git show d77efd7b3def7: stale-flag fix still uses per-vdev flag; this commit replaces that
- [Phase 4] b4 dig -c e3d757dc9257f: PATCH 03/17; earlier RFT 1/3
- [Phase 4] b4 mbox RFT cover: “stop endpoint command” / “assume dead”
- [Phase 4] Xu Rao: teardown gone after the 3-patch series; EP_DROP_PENDING used on unplug
- [Phase 4] Original report: Renesas 1912:0014, Genesys hub, RTL8153 hot-unplug
- [Phase 5] Callers of xhci_handle_halted_endpoint in xhci-ring.c (soft retry, stall, transaction error)
- [Phase 6] Local VDEV_PORT_ERROR still present; rhub_port present; Renesas 0x0014 lacks XHCI_NO_SOFT_RETRY
- [Phase 8] Failure mode verified in xhci-ring.c:1725 (“xHCI host not responding to stop endpoint command”)
- UNVERIFIED: lore.kernel.org HTTP fetch (403); used b4 instead
- UNVERIFIED: concrete 6.12 NULL rhub_port at enqueue; not used for the verdict
**YES**
drivers/usb/host/xhci-ring.c | 27 +++++++++++++++------------ drivers/usb/host/xhci.c | 4 +--- drivers/usb/host/xhci.h | 9 +-------- 3 files changed, 17 insertions(+), 23 deletions(-)
drivers/usb/host/xhci-ring.c +15 -12
@@ -1008,7 +1008,7 @@ static int xhci_handle_halted_endpoint(struct xhci_hcd *xhci,* Avoid resetting endpoint if link is inactive. Can cause host hang. * Device will be reset soon to recover the link so don't do anything */ -if (ep->vdev->flags &VDEV_PORT_ERROR ) +if (ep->vdev->rhub_port->link_inactive)return -ENODEV ;/* add td to cancelled list and let reset ep handler take care of it */
@@ -2007,13 +2007,15 @@ static void xhci_cavium_reset_phy_quirk(struct xhci_hcd *xhci)static void handle_port_status (struct xhci_hcd *xhci,union xhci_trb *event) {struct xhci_virt_device *vdev =NULL ; -struct usb_hcd *hcd; -u32 port_id; -u32 portsc, cmd_reg; -unsigned int hcd_portnum;struct xhci_bus_state *bus_state; -bool bogus_port_status = false;struct xhci_port *port; +struct usb_hcd *hcd; +bool bogus_port_status = false; +unsigned int hcd_portnum; +u32 cmd_reg; +u32 port_id; +u32 portsc; +u32 pls;/* Port status change events always have a successful completion code */ if (GET_COMP_CODE (le32_to_cpu (event->generic.field[2 ])) !=COMP_SUCCESS )
@@ -2050,6 +2052,7 @@ static void handle_port_status(struct xhci_hcd *xhci, union xhci_trb *event) bus_state = &port->rhub->bus_state; hcd_portnum = port->hcd_portnum; portsc =xhci_portsc_readl (port); + pls = portsc &PORT_PLS_MASK ;xhci_dbg (xhci,"Port change event, %d-%d, id %d, portsc: 0x%x\n" , hcd->self.busnum, hcd_portnum +1 , port_id, portsc);
@@ -2061,12 +2064,12 @@ static void handle_port_status(struct xhci_hcd *xhci, union xhci_trb *event)usb_hcd_resume_root_hub (hcd); } -if (vdev && (portsc &PORT_PLS_MASK ) ==XDEV_INACTIVE ) { -if (!(portsc &PORT_RESET )) - vdev->flags |=VDEV_PORT_ERROR ; - }else if (vdev && portsc &PORT_RC ) { - vdev->flags &= ~VDEV_PORT_ERROR ; - } +/* +* Tag broken links to avoid retries while hub driver sorts it out. +* Link status is not relible while port is in reset. +*/ +if (!(portsc &PORT_RESET )) + port->link_inactive = (pls ==XDEV_INACTIVE );if ((portsc &PORT_PLC ) && (portsc &PORT_PLS_MASK ) ==XDEV_RESUME ) {xhci_dbg (xhci,"port resume event for port %d\n" , port_id);
drivers/usb/host/xhci.c +1 -3
@@ -1674,7 +1674,7 @@ static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag goto free_priv; } -if (xhci->devs[slot_id]->flags &VDEV_PORT_ERROR ) { +if (xhci->devs[slot_id]->rhub_port->link_inactive) {xhci_dbg (xhci,"Can't queue urb, port error, link inactive\n" ); ret = -ENODEV ; goto free_priv;
@@ -4038,7 +4038,6 @@ static int xhci_discover_or_reset_device(struct usb_hcd *hcd, xhci_get_slot_state(xhci, virt_dev->out_ctx));xhci_dbg (xhci,"Not freeing device rings.\n" );/* Don't treat this as an error. May change my mind later. */ - virt_dev->flags =0 ; ret =0 ; goto command_cleanup;case COMP_SUCCESS :
@@ -4090,7 +4089,6 @@ static int xhci_discover_or_reset_device(struct usb_hcd *hcd, }/* If necessary, update the number of active TTs on this root port */ xhci_update_tt_active_eps (xhci, virt_dev, old_active_eps); - virt_dev->flags =0 ; ret =0 ; command_cleanup:
drivers/usb/host/xhci.h +1 -8
@@ -741,14 +741,6 @@ struct xhci_virt_device {struct xhci_port *rhub_port;struct xhci_interval_bw_table *bw_table;struct xhci_tt_bw_info *tt_info; -/* -* flags for state tracking based on events and issued commands. -* Software can not rely on states from output contexts because of -* latency between events and xHC updating output context values. -* See xhci 1.1 section 4.8.3 for more details -*/ -unsigned long flags; -#define VDEV_PORT_ERROR BIT(0)/* Port error, link inactive */ /* The current max exit latency for the enabled USB3 link states. */ u16 current_mel;
@@ -1469,6 +1461,7 @@ struct xhci_port {int hcd_portnum;struct xhci_hub *rhub;struct xhci_port_cap *port_cap; + unsigned int link_inactive:1; unsigned int lpm_incapable:1;unsigned long resume_timestamp;bool rexit_active;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18] xhci: include all root port children in recovery prevention on link error
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] xhci: stale port->link_inactive flag after port reset blocks URBs - [High] xhci: null pointer…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] xhci: stale port->link_inactive flag after port reset blocks URBs
- [High] xhci: null pointer dereference of rhub_port in xhci_urb_enqueue()
- [Medium] xhci: data race on xhci_port bitfields in handle_port_status() --
commit 4f9e83e35ad88ce35eba19f2dbcc0cb418ac035b
Author: Mathias Nyman <[email protected]>
xhci: include all root port children in recovery prevention on link error
This commit moves the link error flag from struct xhci_virt_device to struct xhci_port so that child devices behind hubs also avoid useless transfer retries and endpoint recovery when a root port has a link error.
Quoted 4 lines
drivers/usb/host/xhci-ring.c +0
-0
[ ... ]
Quoted 6 lines
drivers/usb/host/xhci-ring.c +0
-2@@ -2061,12 +2064,12 @@ static void handle_port_status(struct xhci_hcd *xhci, union xhci_trb *event)usb_hcd_resume_root_hub (hcd); } -if (vdev && (portsc &PORT_PLS_MASK ) ==XDEV_INACTIVE ) { -if (!(portsc &PORT_RESET ))
drivers/usb/host/xhci-ring.c static void handle_port_status(struct xhci_hcd *xhci, union xhci_trb *event) · line 2072
Quoted 10 lines
drivers/usb/host/xhci-ring.c +6
-4- vdev->flags |=VDEV_PORT_ERROR ; - }else if (vdev && portsc &PORT_RC ) { - vdev->flags &= ~VDEV_PORT_ERROR ; - } +/* +* Tag broken links to avoid retries while hub driver sorts it out. +* Link status is not relible while port is in reset. +*/ +if (!(portsc &PORT_RESET )) + port->link_inactive = (pls ==XDEV_INACTIVE );
[Severity: High]
Can port->link_inactive remain stuck at 1 after a port reset if reset completion does not generate a new Port Status Change Event TRB?
Commit b69dfcab6894b1 ("xhci: fix stale flag preventig URBs after link state error is cleared") previously addressed a scenario where a USB3 link enters XDEV_INACTIVE between two resets in hub_port_init() by clearing VDEV_PORT_ERROR in xhci_discover_or_reset_device().
When the port enters XDEV_INACTIVE, hardware sets PORT_PLC in PORTSC and generates a TRB_PORT_STATUS event, which runs handle_port_status() and sets port->link_inactive = 1 while leaving PORT_PLC set in PORTSC for USB3 ports.
Because the resetting thread holds port_dev->status_lock, port_event() cannot run to clear PORT_PLC before the subsequent hub_port_reset() issues USB_PORT_FEAT_BH_PORT_RESET or USB_PORT_FEAT_RESET:
drivers/usb/core/hub.c:hub_port_reset() {
for (i = 0; i < PORT_RESET_TRIES; i++) {
status = set_port_feature(hub->hdev, port1, (warm ?
USB_PORT_FEAT_BH_PORT_RESET :
USB_PORT_FEAT_RESET));
...
}As noted in the comment at the end of handle_port_status(), the xHC only generates a Port Status Change Event TRB when the logical OR of all PORTSC status-change bits transitions from 0 to 1:
drivers/usb/host/xhci-ring.c:handle_port_status() {
/*
* xHCI port-status-change events occur when the "or" of all the
* status-change bits in the portsc register changes from 0 to 1.
* New status changes won't cause an event if any other change
* bits are still set. When an event occurs, switch over to
* polling to avoid losing status changes.
*/
}
Since PORT_PLC is already 1 during the reset, reset completion (setting PORT_RC or PORT_WRC and transitioning PLS to XDEV_U0) will not generate a new Port Status Change Event TRB. With the flag clearing removed from xhci_discover_or_reset_device() and nothing in xhci_hub_control() updating port->link_inactive, won't port->link_inactive stay 1 and cause xhci_urb_enqueue() to reject all subsequent URBs for the port's devices with -ENODEV?
drivers/usb/host/xhci.c static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag · line 1677
Quoted 13 lines
drivers/usb/host/xhci-ring.c +0
-0if ((portsc &PORT_PLC ) && (portsc &PORT_PLS_MASK ) ==XDEV_RESUME ) {xhci_dbg (xhci,"port resume event for port %d\n" , port_id);drivers/usb/host/xhci.c +1
-1@@ -1674,7 +1674,7 @@ static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag goto free_priv; } -if (xhci->devs[slot_id]->flags &VDEV_PORT_ERROR ) { +if (xhci->devs[slot_id]->rhub_port->link_inactive) {
[Severity: High]
Could xhci->devs[slot_id]->rhub_port be NULL here, leading to a NULL pointer dereference?
In xhci_check_args(), the check succeeds as soon as udev->slot_id and xhci->devs[slot_id] are set with virt_dev->udev == udev:
drivers/usb/host/xhci.c:xhci_check_args() {
if (check_virt_dev) {
if (!udev->slot_id || !xhci->devs[udev->slot_id]) {
...
return -EINVAL;
}
virt_dev = xhci->devs[udev->slot_id];
if (virt_dev->udev != udev) {
...
return -EINVAL;
}
}
}However, xhci_alloc_dev() -> xhci_alloc_virt_device() allocates xhci->devs[slot_id] and sets udev->slot_id while leaving dev->rhub_port as NULL until xhci_setup_device() -> xhci_setup_addressable_virt_dev() runs:
drivers/usb/host/xhci-mem.c:xhci_setup_addressable_virt_dev() {
/* Find the root hub port this device is under */
dev->rhub_port = xhci_find_rhub_port(xhci, udev);
if (!dev->rhub_port)
return -EINVAL;
}For an already-enumerated device (where udev->state >= USB_STATE_DEFAULT), xhci_discover_or_reset_device() and xhci_setup_device() (on COMP_USB_TRANSACTION_ERROR) can call xhci_alloc_dev() before xhci_setup_addressable_virt_dev() is reached:
drivers/usb/host/xhci.c:xhci_discover_or_reset_device() {
virt_dev = xhci->devs[slot_id];
if (!virt_dev) {
...
ret = xhci_alloc_dev(hcd, udev);
if (ret == 1)
return 0;
else
return -EINVAL;
}
}For example, during system resume after xHCI power loss (where xhci_mem_cleanup() freed all virt_devices and zeroed udev->slot_id), resuming an external hub callsusb_reset_and_verify_device() -> hub_hc_release_resources(), which recursively invokes xhci_discover_or_reset_device() -> xhci_alloc_dev() on all child devices behind the hub before those children are reset or addressed:
drivers/usb/core/hub.c:hub_hc_release_resources() {
/* Release up resources for all children before this device */
for (i = 0; i < udev->maxchild; i++)
if (hub->ports[i]->child)
hub_hc_release_resources(hub->ports[i]->child);
if (hcd->driver->reset_device)
hcd->driver->reset_device(hcd, udev);
}If an URB is submitted to a child device before its xhci_setup_addressable_virt_dev() runs (for instance via usb_offload_check() in usb_resume_both(), via finish_port_resume() -> usb_get_std_status() if hub_activate() hit an earlier port status error, or from a concurrent driver workqueue/usbfs thread during slot reallocation), previously prepare_ring() rejected the URB with -ENOENT because the endpoint context was still in EP_STATE_DISABLED. Now xhci_urb_enqueue() dereferences xhci->devs[slot_id]->rhub_port before prepare_ring() is reached.
Quoted 23 lines
drivers/usb/host/xhci.c +0
-2xhci_dbg (xhci,"Can't queue urb, port error, link inactive\n" ); ret = -ENODEV ; goto free_priv;@@ -4038,7 +4038,6 @@ static int xhci_discover_or_reset_device(struct usb_hcd *hcd, xhci_get_slot_state(xhci, virt_dev->out_ctx));xhci_dbg (xhci,"Not freeing device rings.\n" );/* Don't treat this as an error. May change my mind later. */ - virt_dev->flags =0 ; ret =0 ; goto command_cleanup;case COMP_SUCCESS :@@ -4090,7 +4089,6 @@ static int xhci_discover_or_reset_device(struct usb_hcd *hcd, }/* If necessary, update the number of active TTs on this root port */ xhci_update_tt_active_eps (xhci, virt_dev, old_active_eps); - virt_dev->flags =0 ; ret =0 ; command_cleanup:drivers/usb/host/xhci.h +0
-0
[ ... ]
drivers/usb/host/xhci.h struct xhci_port { · line 1467
Quoted 8 lines
drivers/usb/host/xhci.h +1
-0@@ -1469,6 +1461,7 @@ struct xhci_port {int hcd_portnum;struct xhci_hub *rhub;struct xhci_port_cap *port_cap; + unsigned int link_inactive:1; unsigned int lpm_incapable:1;unsigned long resume_timestamp;bool rexit_active;
[Severity: Medium]
Can placing the link_inactive bitfield next to lpm_incapable cause a data race on the shared bitfield word?
In handle_port_status(), port->link_inactive is updated in interrupt context under xhci->lock:
drivers/usb/host/xhci-ring.c:handle_port_status() {
if (!(portsc & PORT_RESET))
port->link_inactive = (pls == XDEV_INACTIVE);
}Meanwhile, during USB3 shared_hcd registration in usb_add_hcd() and system resume after power loss in xhci_resume(), the controller and its interrupts are started before register_root_hub() or hub_activate() calls xhci_pci_update_hub_device() -> xhci_find_lpm_incapable_ports(), which writes to lpm_incapable in process context without holding xhci->lock:
drivers/usb/host/xhci-pci.c:xhci_find_lpm_incapable_ports() {
if (ret >= 0) {
rhub->ports[i]->lpm_incapable = ret;
continue;
}
}If a Port Status Change Event interrupt fires concurrently while xhci_find_lpm_incapable_ports() is running, could the non-atomic read-modify-write on the shared unsigned int clobber either link_inactive or lpm_incapable?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 ceph: do not cache negative dentries for snapped directories
In reply to Sasha LevinFrom: Xiubo Li <[email protected]>
[ Upstream commit af59562a5b3d34fb3aa7753f2543393578d06dbf ]
When a LOOKUP/LOOKUPSNAP in a snapped directory returns ENOENT without a trace, ceph_finish_lookup() creates a negative dentry via d_add(dentry, NULL). For live directories this is fine — the dentry naturally expires. But for snapped directories, ceph_d_revalidate() unconditionally trusts all cached dentries (valid = 1), so a negative dentry created by a transient error persists forever, hiding entries that genuinely exist in the snapshot.
Only cache negative dentries for live (non-snapshotted) parent directories. For snapped parents, skip the negative dentry so that VFS retries the lookup on the next access. Since the conditions that trigger a negative dentry (MDS transient error, local ENOENT shortcut, or MDS null dentry lease) are all rare in snapped directories, the performance impact of this change is negligible.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
- Record: [ceph] [do not cache] negative dentries for snapped directories
- Subsystem: CephFS kernel client (fs/ceph/)
- Action: “do not cache” is a prevent/avoid-style fix, not a feature
**Step 1.2: Tags**
- Link: https://tracker.ceph.com/issues/78529 (production bug tracker)
- Reported-by: Andras Pataki <[email protected]> (real CephFS user)
- Signed-off-by: Xiubo Li <[email protected]> (author; listed as Ceph FS client maintainer)
- Reviewed-by: Viacheslav Dubeyko <[email protected]>
- Signed-off-by: Ilya Dryomov <[email protected]> (Ceph maintainer who merged it)
- No Fixes: tag (expected; the d_add(..., NULL) path dates to 2009)
- No Cc: stable (expected for this review pipeline)
- Original submission also had `Closes:
https://tracker.ceph.com/issues/78529`; that was dropped at merge
- Ignore pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] if present
**Step 1.3: Body**
- Record: [Bug] LOOKUP/LOOKUPSNAP on a snapped directory can return -ENOENT with no trace. ceph_finish_lookup() then does d_add(dentry, NULL), caching a negative dentry. ceph_d_revalidate() unconditionally trusts snapped dentries (valid = 1), so that negative entry never expires.
- [Symptom] Snapshot paths return ENOENT for files/dirs that exist. readdir on the parent restores them.
- [Version] Reporter hit it on kernel 6.18.32 with Ceph squid 19.2.3. Same client caching logic is in this 6.12 tree.
- [Root cause] Negative dentries in snapped dirs are sticky, so a transient MDS ENOENT hides real snapshot entries forever.
**Step 1.4: Hidden bug fix?**
- Record: Not hidden. Explicit correctness fix for stale negative dentries. Not cleanup/refactor.
---
## Phase 2: Diff analysis
**Step 2.1: Inventory**
- Record: fs/ceph/dir.c (+8/-2), fs/ceph/inode.c (+2/-1). Net +10/-3.
- Functions: ceph_finish_lookup(), ceph_lookup(), ceph_fill_trace().
- Scope: single-subsystem surgical fix, three call sites that instantiate negative dentries.
**Step 2.2: Code flow**
1. ceph_finish_lookup(): on traceless -ENOENT, previously always d_add(dentry, NULL) for unhashed negatives. After: only if parent is missing or ceph_snap(parent) == CEPH_NOSNAP. Snapped parents skip d_add; VFS retries next access.
2. ceph_lookup() local ENOENT shortcut (DCACHE + complete dir + FILE_SHARED): add ceph_snap(dir) == CEPH_NOSNAP so snapped dirs never conclude ENOENT locally and cache it.
3. ceph_fill_trace() null-dentry + lease path: d_add(dn, NULL) only when parent is live (CEPH_NOSNAP).
**Step 2.3: Bug mechanism**
- Record: [Logic / dcache correctness]
- Mechanism: sticky negative dentry + “always trust snapped dentries” in ceph_d_revalidate() (this tree, fs/ceph/dir.c around the ceph_snap(dir) != CEPH_NOSNAP / valid = 1 path). Fix: do not instantiate those negatives.
**Step 2.4: Fix quality**
- Record: Minimal and obviously correct. Live-dir behavior unchanged. Regression risk is extra MDS lookups for true ENOENT in snapshots (author: rare). No locking/API/data-structure changes. Skipping d_add leaves the lookup dentry unhashed; VFS d_lookup_done() + dput() frees it, so the next access looks up again.
---
## Phase 3: Git history
**Step 3.1: Blame**
- Record: Negative d_add in ceph_finish_lookup() from Sage Weil 2817b000b02c5f (2009). Unconditional trust of snapped dentries also from that era (valid = 1 in bf1c6aca96c9d2, 2011). Present for the life of this filesystem client, not new 6.13+ code.
- Local wrappers if (d_unhashed(dentry)) come from 4179cc390dace (ceph: only d_add() negative dentries when they are unhashed), already in this tree.
**Step 3.2: Fixes: tag**
- Record: None. Introducer is the original 2009 lookup path, which is in this tree.
**Step 3.3: File history**
- Record: Recent related commit in this tree: 4179cc390dace (hash- corruption/RCU stall if d_add on already-hashed negatives). This fix builds on that d_unhashed guard and applies cleanly.
- Standalone; not patch X/Y. Mainline follow-ups on these files after af59562a5b3d3 are unrelated (ceph_trim_dentries, VFS mkdir/lookup churn).
**Step 3.4: Author**
- Record: Xiubo Li is a listed maintainer of CEPH DISTRIBUTED FILE SYSTEM CLIENT. Ilya Dryomov is co-maintainer and merged it. Strong subsystem ownership.
**Step 3.5: Dependencies**
- Record: Uses existing ceph_snap() / CEPH_NOSNAP. Needs the d_unhashed guards for a clean apply; those are already here. Standalone.
Original mainline SHA: af59562a5b3d34fb3aa7753f2543393578d06dbf (not an ancestor of this HEAD).
---
## Phase 4: Mailing list / external research
**Step 4.1: Original discussion**
- Record: b4 dig -c af59562a5b3d3 →
https://patch.msgid.link/20260723-b4-snap-negative-
[email protected]
- Only v1. Viacheslav Dubeyko: “Makes sense.” + Reviewed-by. No NAK, no stable objection, no later revision that superseded the committed diff.
**Step 4.2: Recipients (b4 dig -w)**
- Record: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko, Dhairya Parmar, ceph-devel@, linux-kernel@, reporter Andras Pataki. Right maintainers/list.
**Step 4.3: Bug report**
- Tracker 78529: snapshot paths return ENOENT; ls of parent restores visibility. Live tree had deleted the names after the snapshot.
- ceph-users thread documents a real backup/copy workload across parallel kernel mounts. Reproduced with ls -ld on snapshot paths.
- Tracker notes MDS path_traverse() is_complete() shortcut as the server-side trigger, and this kclient change as an independent defense so a transient ENOENT is not cached forever.
**Step 4.4: Series**
- Record: Single standalone patch. MDS/libcephfs fixes are userspace, not kernel prerequisites.
**Step 4.5: stable@**
- Record: UNVERIFIED. lore.kernel.org fetches returned 403. No evidence in the ceph-devel mbox of a stable NAK.
---
## Phase 5: Semantic analysis
**Step 5.1: Functions**
- Record: ceph_finish_lookup, ceph_lookup, ceph_fill_trace.
**Step 5.2: Callers**
- ceph_lookup is .lookup for ceph_dir_iops and ceph_snapdir_iops — every path walk, including .snap/....
- ceph_finish_lookup also from ceph_atomic_open() in fs/ceph/file.c.
- ceph_fill_trace processes MDS replies (lookup/link/unlink traces).
**Step 5.3: Callees**
- Record: d_add/d_unhashed/d_really_is_positive, ceph_snap(), __ceph_dir_is_complete(), lease updates. No alloc/lock changes.
**Step 5.4: Reachability**
- Record: Userspace-reachable via ordinary stat/open/cp/ls on snapshot paths. Not an obscure config hook. CONFIG_CEPH_FS is the only gate.
**Step 5.5: Similar patterns**
- Record: All three d_add(..., NULL) sites in fs/ceph/ are patched. No leftover sibling.
---
## Phase 6: This tree (pending-6.12 / 6.12.111)
**Step 6.1: Buggy code present?**
- Record: Yes.
- fs/ceph/dir.c ceph_finish_lookup(): unhashed negatives still d_add(dentry, NULL) with no snap check.
- ceph_lookup() local ENOENT shortcut has no ceph_snap(dir) == CEPH_NOSNAP.
- fs/ceph/inode.c ceph_fill_trace(): d_add(dn, NULL) on null dentry + lease, no snap check.
- ceph_d_revalidate() still: `if (ceph_snap(dir) != CEPH_NOSNAP)
valid = 1;`
- git merge-base --is-ancestor af59562a5b3d3 HEAD → not an ancestor (fix not already here).
**Step 6.2: Backport difficulty**
- Record: git show af59562a5b3d3 | git apply --check succeeded (inode.hunk offset −32). Clean apply.
**Step 6.3: Related fixes already here?**
- Record: 4179cc390dace only prevents d_add on already-hashed dentries (RCU stall). It does not skip snapped negatives. No duplicate of this fix.
---
## Phase 7: Subsystem context
**Step 7.1**
- Record: [Subsystem] CephFS client (fs/ceph/). [Criticality] IMPORTANT — not core VFS, but a production networked filesystem (MAINTAINERS: Supported). Snapshot lookups are a real backup/restore path.
**Step 7.2**
- Record: Mature client; this lookup/revalidate behavior has been stable for years. Not a fix to brand-new 7.x-only code.
---
## Phase 8: Impact and risk
**Step 8.1: Who is affected**
- Record: CephFS (CONFIG_CEPH_FS) users accessing snapshot trees (.snap/...), especially after live-tree deletes and MDS cache trim.
Reporter: parallel snapshot copies on kernel mounts.
**Step 8.2: Trigger**
- Record: LOOKUP of a snapshot name after MDS returns traceless ENOENT (complete-dir shortcut / trim). Then every later lookup hits the cached negative. Unprivileged users who can read the mount can trigger it. Not a tiny race window; once cached, it sticks until readdir/d_invalidate.
**Step 8.3: Failure mode**
- Record: Existing snapshot files/directories are invisible (ENOENT). Backup/copy can skip or fail. Not a panic, but filesystem data-access correctness. Severity: **HIGH**.
**Step 8.4: Risk/benefit**
- Benefit: high for CephFS snapshot users (broken snapshot access / incomplete backups).
- Risk: very low (10 lines, snap-only, no locks/APIs). Cost is extra lookups for true snapshot ENOENT.
- Ratio: strongly favors backport.
---
## Phase 9: Synthesis
**Step 9.1: Evidence**
FOR:
- Real production report (Flatiron Institute); tracker + ceph-users thread with repro.
- Sticky negative dentries make snapshot names disappear until readdir.
- Same client logic is in this 6.12 tree.
- Small, obviously correct, maintainer-authored and maintainer-merged.
- Applies cleanly; no series dependency.
- Independent of the MDS-side fix; still needed against older/unfixed MDS.
AGAINST:
- Not a crash/UAF/deadlock; tracker severity “3 - minor”.
- Primary trigger is MDS; workaround is ls on the parent.
- Only CephFS snapshot lookups.
UNRESOLVED:
- Whether stable@ already discussed this (lore HTTP 403).
**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** — reviewed, merged, matches the described mechanism in this tree.
2. Real bug affecting users? **PASS** — confirmed ENOENT for existing snapshot paths.
3. Important? **PASS** — filesystem returning ENOENT for data that exists, breaking snapshot copy/backup.
4. Small and contained? **PASS** — +10/-3, two files, three sites.
5. No new features/APIs? **PASS**
6. Applies to this tree? **PASS** — git apply --check clean; helpers already present.
**Step 9.3: Exceptions**
- Record: Not ID/quirk/DT/build/docs. Ordinary correctness fix.
**Step 9.4: Decision**
This tree should take it. The bug is here, the fix is surgical, and snapshot ENOENT-for-existing-files is a serious CephFS correctness issue for stable users still talking to MDS daemons that can emit that reply.
---
### What it solves for this tree
On 6.12 CephFS, a traceless snapshot LOOKUP ENOENT is cached as a negative dentry that ceph_d_revalidate() never invalidates. Users then cannot open snapshot files that still exist until someone does readdir. The patch stops caching those negatives for snapped parents.
### Risk vs benefit
Benefit is restoring snapshot access for a documented production failure mode. Risk is confined to extra lookups on snapshot ENOENT, with live- directory caching unchanged.
### Concerns
None that block backport. MDS userspace should still be fixed separately; this kernel change is the client-side defense and does not require those patches.
---
Verification:
- [Phase 1] Parsed tags: Reported-by Andras Pataki, Link tracker 78529, Reviewed-by Dubeyko, SOB Dryomov; no Fixes/Cc-stable
- [Phase 1] Tracker 78529 and ceph-users thread confirm ENOENT on snapshot paths, readdir workaround, kernel 6.18.32 / squid 19.2.3
- [Phase 2] Diff: three d_add(..., NULL) sites; snap check + skip cache; ceph_lookup local ENOENT gated on CEPH_NOSNAP
- [Phase 2] Confirmed ceph_d_revalidate() in this tree sets valid = 1 for ceph_snap(dir) != CEPH_NOSNAP
- [Phase 3] git describe HEAD / Makefile: pending-6.12, 6.12.111
- [Phase 3] git merge-base --is-ancestor af59562a5b3d3 HEAD → not present
- [Phase 3] Blame: d_add path from 2817b000b02c5f (2009); snap trust from 2009–2011
- [Phase 3] Prerequisite 4179cc390dace (d_unhashed before d_add) is already in this tree
- [Phase 4] b4 dig -c af59562a5b3d3: v1 only; lore msgid [email protected]
- [Phase 4] b4 dig -a/-w/-m: maintainer CC list; Dubeyko “Makes sense”
+ Reviewed-by; no NAK
- [Phase 4] WebFetch lore.kernel.org/patch.msgid.link: HTTP 403 (discussion recovered via b4 dig -m)
- [Phase 5] Callers: ceph_lookup is dir and snapdir .lookup; ceph_finish_lookup also from ceph_atomic_open
- [Phase 6] git apply --check of af59562a5b3d3 succeeded on this tree
- [Phase 6] All three local d_add(..., NULL) sites still lack the snap guard
- [Phase 7] MAINTAINERS: Ceph FS client Supported; author Xiubo Li is a listed maintainer
- [Phase 8] Failure mode: persistent ENOENT for existing snapshot names → HIGH filesystem correctness
- UNVERIFIED: stable@ mailing-list history (lore 403)
**YES**
fs/ceph/dir.c | 10 ++++++++-- fs/ceph/inode.c | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-)
fs/ceph/dir.c +8 -2
@@ -774,8 +774,13 @@ struct dentry *ceph_finish_lookup(struct ceph_mds_request *req,d_drop (dentry); err = -ENOENT ; }else { -if (d_unhashed (dentry)) -d_add (dentry,NULL ); +if (d_unhashed (dentry)) { +struct inode *parent = +d_inode (dentry->d_parent); +if (!parent || +ceph_snap (parent) ==CEPH_NOSNAP ) +d_add (dentry,NULL ); + } } } }
@@ -840,6 +845,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, dentry->d_name.len) && !is_root_ceph_dentry(dir, dentry) && ceph_test_mount_opt(fsc, DCACHE) && + ceph_snap(dir) == CEPH_NOSNAP && __ceph_dir_is_complete(ci) && __ceph_caps_issued_mask_metric(ci, CEPH_CAP_FILE_SHARED, 1)) {__ceph_touch_fmode (ci, mdsc,CEPH_FILE_MODE_RD );
fs/ceph/inode.c +2 -1
@@ -1783,7 +1783,8 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req)ceph_dir_clear_ordered (dir);d_delete (dn); }else if (have_lease) { -if (d_unhashed (dn)) +if (d_unhashed (dn) && +ceph_snap (dir) ==CEPH_NOSNAP )d_add (dn,NULL ); }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 greybus: manifest: validate string descriptor header
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit 18b6510f642dbcb856c3af8be974d1600f3ba2d3 ]
identify_descriptor() computes a string descriptor size from desc->string.length.
Require the descriptor to contain the fixed string descriptor header before reading the variable string length. The existing descriptor-size check then reports the short descriptor.
---
LLM Generated explanations, may be completely bogus:
The local tree is **v7.3-rc4** (mainline 7.3.0-rc4). Greybus manifest parsing exists here, the two-line size check is already the current code, and the same parser has been in the kernel since v4.9. The rest of this write-up is whether that fix is stable-worthy for this lineage.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[greybus/manifest] [validate] [require the fixed string- descriptor header before reading desc->string.length]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Fixes: — none (expected for this review path)
- Reported-by: — none
- Tested-by: — none
- Reviewed-by: — none
- Acked-by: — none
- Link:
https://patch.msgid.link/[email protected]
- Cc: [email protected] — none (expected)
- Signed-off-by: Pengpeng Hou <[email protected]> (author)
- Signed-off-by: Greg Kroah-Hartman <[email protected]> (greybus maintainer; ignore any Sasha Levin SOB — none present)
Notable pattern: no user/syzbot report; maintainer still took the patch.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** identify_descriptor() uses desc->string.length to compute expected size before the descriptor is known to contain the two-byte string header (length + id).
- **Symptom:** out-of-bounds / out-of-object read of length on a truncated GREYBUS_TYPE_STRING descriptor.
- **Failure mode:** malformed hardware manifest; heap OOB when remaining buffer is only the 4-byte generic header.
- **Version info:** none in the message.
- **Root cause (author):** read variable length before the fixed string header is present; the existing desc_size < expected_size path then reports the short descriptor.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not disguised.** Subject/body describe a bounds check. It *is* a real memory-safety fix, not cleanup.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES** Record:
- File: drivers/greybus/manifest.c — **+2 / -0**
- Function: identify_descriptor()
- Scope: **single-file surgical fix**
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: Before, GREYBUS_TYPE_STRING did expected_size += sizeof(struct greybus_descriptor_string) then immediately expected_size += desc->string.length. After, if desc_size < expected_size (header + 2-byte string header), it breaks into the existing “descriptor too small” -EINVAL path and never reads length.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Memory safety / OOB read]**. greybus_descriptor_header is 4 bytes; greybus_descriptor_string is 2 bytes plus a flexible array. A descriptor with size==4 and type==STRING is accepted by desc_size > size (4 is not greater than remaining size) but desc->string.length sits at offset 4. Manifest memory is kmalloc(size) in gb_interface_enable(), so when remaining length is 4 this is a **1-byte heap OOB read**.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: **Obviously correct and minimal.** Valid string descriptors already have desc_size >= 6 + length (then 4-byte aligned); the new check cannot fire on them. break (not return) reuses the existing error log. Regression risk is **very low**.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: The length access comes from **b09c94a1b71c82** (“greybus:
start improving manifest parsing”, 2014-10-01, **v4.9-rc1**). Padding/ALIGN later: fa2fbf16f6aaaa (Viresh Kumar, 2015). The two new lines are this commit (**18b6510f642dbc**, Pengpeng Hou, 2026-07-06). Long-lived bug, not new code.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** The introducing commit is b09c94a1b71c82, in this tree (git merge-base --is-ancestor 18b6510f642db HEAD succeeded). No intermediate fix of this specific hole.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent manifest.c history is alloc-style churn plus the 2019 staging move (8465def499c70, **v5.4-rc1**). Older related work:fa2fbf16f6aaa (padding), cbd0fd7b9b6fd (length field type). **Standalone**, not patch N/M.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Pengpeng Hou is not a Greybus maintainer. Other Greybus work:1214bf28965ce and cbc96a916b1a3 (BeaglePlay RX bounds). Pattern of bounds checks, not a prerequisite series for this hunk.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **No dependencies.** Uses existing desc_size, expected_size, and the existing too-small check. Can apply standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 18b6510f642db →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only** (2026-07-06)
- Thread (mbox): author patch + Greg KH: “Nice, but how was this tested? How was it found?”
- **No author reply found** on LKML, greybus-dev (Linaro), or the saved mbox.
- Greg still applied it (commit date 2026-07-17).
- No NAK. No reviewer Cc: stable.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc Johan Hovold, Alex Elder, Greg Kroah- Hartman, greybus-dev, linux-kernel — the GREYBUS SUBSYSTEM maintainers. Greg applied it; no Reviewed-by from Johan/Alex.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: **No bugzilla/syzbot/CVE.** Discovery method unanswered (likely static review). Severity is from code, not a user report.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: **Standalone v1.** Other Hou Greybus patches are BeaglePlay RX bounds, not needed here.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable/ returned **403**. No stable-thread hit via web search. **UNVERIFIED** whether stable@ discussed this.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: identify_descriptor() (modified). Callers/helpers:gb_manifest_parse(), gb_interface_enable(), gb_control_get_manifest_*().
**Step 5.2: TRACE CALLERS**
Record: identify_descriptor is static; only called from gb_manifest_parse() while walking descriptors. gb_manifest_parse is called from gb_interface_enable() (drivers/greybus/interface.c). That is used from gb_module_register_interface() and other enable/resume paths in interface.c. **Device enable**, not a syscall.
**Step 5.3: TRACE CALLEES**
Record: le16_to_cpu, dev_err/dev_warn, kzalloc_obj, list_add_tail. No new locks/allocs in the patch.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Greybus module/interface enable → control GET_MANIFEST_SIZE / GET_MANIFEST over the Greybus control CPort → kmalloc(size) → gb_manifest_parse. Trigger is **attached Greybus hardware** (BeaglePlay SVC, ES2 USB host, etc.), not unprivileged syscalls. Manifest bytes are **device-supplied**.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Other descriptor types only add a fixed sizeof() and do not read extra fields before the later size check. This hole is **string- specific**. gb_string_get() copies desc_string->length after identify; that path is only reached if identify accepted the descriptor.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** drivers/greybus/manifest.c identify_descriptor(); structs in include/linux/greybus/greybus_manifest.h. Bug since **v4.9**; core moved out of staging in **v5.4**. This checkout already contains **18b6510f642db**.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** — two lines in an unchanged switch arm. Surrounding code matches the pre-image (aside from later kzalloc_obj).
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No earlier equivalent check. No later manifest.c commits after this one.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **Greybus core parser** (drivers/greybus/). Criticality:
**PERIPHERAL/IMPORTANT** — not mm/VFS, but in-tree (not staging) core used by BeaglePlay and ES2. Parser of untrusted device blobs is the same class as USB descriptor parsing.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature; manifest.c is low-churn since the 2019 move. Bug is old, not a new-API refactor.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Config-specific + driver-specific** (CONFIG_GREYBUS, plus a module that supplies a manifest). Not universal.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Malformed string descriptor during interface enable. Needs Greybus hardware (or an equivalent host). **Not** a normal unprivileged syscall. Timing-independent. Commonness: rare (buggy/malicious module).
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **1-byte (typical) slab OOB read.** After the bad read, expected_size is still >= 8 when desc_size < 6, so the existing check still returns -EINVAL — the OOB does not accept the descriptor. Production effect is usually KASAN/syz-style detection, not a guaranteed panic. Severity: **HIGH** as memory safety on untrusted device data; practical crash risk **MEDIUM**.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** stops a real OOB in a device-blob parser; tiny; long- present bug.
- **Risk:** very low (2 lines, error path only, valid manifests unchanged).
- **Ratio:** **favorable**.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real OOB read of desc->string.length before the 2-byte string header is known to be in-bounds.
- Manifest is kmalloc’d to the device-reported size; last truncated STRING descriptor with desc_size == remaining == 4 is a heap OOB.
- Two-line, obviously correct check; valid descriptors unaffected.
- Bug in this tree’s lineage since ~2014 (v4.9).
- Maintainer Greg KH applied v1 after listing maintainers on CC.
- No new API/feature; applies cleanly; no prerequisites.
AGAINST:
- No Reported-by / syzbot / crash log.
- Author did not answer Greg’s “how tested / how found”.
- Greybus is niche; trigger needs hardware.
- OOB value is not used to accept the descriptor (still -EINVAL).
UNRESOLVED:
- lore.kernel.org HTTP 403; stable@ search not completed on lore.
- No public answer on how the bug was found.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** on correctness by inspection; testing story is thin, but the change is too small to need a complex repro.
2. Fixes a real bug that affects users? **PASS** — OOB on device- supplied manifests for CONFIG_GREYBUS users.
3. Important issue? **PASS** — memory-safety / OOB on untrusted hardware data (same bar as USB descriptor checks), not a style nit.
4. Small and contained? **PASS** — +2 lines, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — file and function exist; patch is already the current code here.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/docs exception. Ordinary small bugfix.
**Step 9.4: MAKE YOUR DECISION**
This is a classic stable backport: a long-standing bounds hole in a parser of device-provided descriptors, fixed in two lines with no behavioral change for valid input. Niche hardware lowers blast radius but does not make an OOB read unworthy of stable; USB-style descriptor checks are backported for the same reason. Greg’s unanswered testing question is a quality nit, not a reason to withhold a correct 2-line guard.
### What the commit solves for stable users
A Greybus interface enable path copies a hardware manifest into a kmalloc buffer and walks descriptors. For GREYBUS_TYPE_STRING it used to read desc->string.length as soon as the generic 4-byte header was present. If the descriptor claimed only those 4 bytes, that read is past the object (and past the allocation when this is the last remaining bytes). The fix refuses that descriptor via the existing “too small” path.
### Stable rules / risk vs benefit
Meets the stable bar: real bug, important (OOB), tiny, no features, applies here. Benefit is closing a memory-safety hole; risk is negligible.
### Concerns
No in-the-wild report; discovery method unknown. No extra backport glue needed on this tree.
Verification:
- [Phase 1] Parsed tags: author SOB, Greg KH SOB, Link to msgid; no Fixes/Reported-by/stable Cc
- [Phase 2] Diff: +2 in identify_descriptor() STRING case; break into existing desc_size < expected_size
- [Phase 2] Struct sizes from greybus_manifest.h: header 4, string fixed 2; length at offset 4
- [Phase 2] Pre-image via git show 18b6510f642db^:drivers/greybus/manifest.c: length read with no header-size gate
- [Phase 3] git describe HEAD / Makefile: **v7.3-rc4**, VERSION 7.3.0-rc4
- [Phase 3] git merge-base --is-ancestor 18b6510f642db HEAD: yes
- [Phase 3] blame: length use from b09c94a1b71c82 (v4.9-rc1); new lines from 18b6510f642dbc
- [Phase 3] No Fixes tag; introducing commit in this history
- [Phase 3] File log: standalone; later history has no further manifest.c fixes
- [Phase 4] b4 dig -c/-a/-w/-m: v1 only; maintainers CC’d; Greg asked how found; no NAK; applied 2026-07-17
- [Phase 4] lore.kernel.org WebFetch: **403**; used mbox + openwall/Linaro/lkml.iu.edu
- [Phase 4] No author reply to Greg found
- [Phase 5] Callers: gb_manifest_parse ← gb_interface_enable ← module/interface enable; manifest from gb_control_get_manifest_operation into kmalloc(size)
- [Phase 5] semcode: **unavailable**; used grep/read
- [Phase 6] Buggy parser present in this tree; apply would be clean
- [Phase 7] GREYBUS SUBSYSTEM maintainers: Hovold, Elder, Greg KH
- [Phase 8] Failure: heap OOB read, severity HIGH memory-safety / MEDIUM practical crash
- UNVERIFIED: stable@ lore discussion (403); exact discovery method (unanswered)
**YES**
drivers/greybus/manifest.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/greybus/manifest.c +2 -0
@@ -122,6 +122,8 @@ static int identify_descriptor(struct gb_interface *intf,switch (desc_header->type) {case GREYBUS_TYPE_STRING : expected_size +=sizeof (struct greybus_descriptor_string ); +if (desc_size < expected_size) +break ; expected_size += desc->string.length;/* String descriptors are padded to 4 byte boundaries */
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ASoC: codecs: max98396: Unwind supplies on resume failure
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit d20de7409dfa8e3341af7f157cd42130bd4ba3a7 ]
max98396_resume() enables the core, pvdd, and vbat supplies before leaving cache-only mode, resetting the device, and replaying cached register state. The function currently ignores regcache_sync() failures, and the optional pvdd/vbat enable failures return without unwinding supplies that were already enabled in this resume attempt.
Rework the function to use common error labels. This propagates sync failures, restores cache-only/dirty state on failed cache replay, and disables each supply acquired by this resume path before returning the error.
---
LLM Generated explanations, may be completely bogus:
The local tree is **v7.3-rc4** (7.3.0-rc4). The MAX98396 resume path has been in this lineage since v6.0, and this patch is a small, self- contained error-path fix for that path.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[ASoC/codecs/max98396] [Unwind] [Disable supplies and restore cache state if resume fails]**
Subsystem prefix ASoC: codecs: max98396:. Verb **Unwind** is error- path cleanup language; the body is a real leak/error-propagation fix, not a refactor.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected)
- **Reported-by / Tested-by / Reviewed-by / Acked-by:** none on the commit itself
- **Link:**
https://patch.msgid.link/[email protected]
- **Cc: stable:** none (expected)
- **Signed-off-by:** Pengpeng Hou (author); Mark Brown (ASoC maintainer). Ignore any Sasha Levin SOB from candidate prep.
No syzbot, no multi-user reports.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** max98396_resume() enables core / optional pvdd / vbat, then leaves cache-only, resets, and calls regcache_sync(). regcache_sync() errors are ignored. If optional pvdd/vbat enable fails, already-enabled supplies are not disabled.
- **Symptom:** Regulator enable-count leak after a failed resume; resume can report success while cached register state was not written back (codec left in reset/defaults → broken audio after suspend).
- **Version info:** none in the message.
- **Root cause:** Missing unwind and ignored regcache_sync() return.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Yes, a real bug fix described as error-path rework.** “Common error labels” is the usual shape of a leak fix: added goto cleanup, regulator_disable / regulator_bulk_disable, restore cache- only/dirty, propagate regcache_sync() failure.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** sound/soc/codecs/max98396.c — **+21 / −3** (git show --stat: 24 lines changed)
- **Function:** max98396_resume() only
- **Scope:** single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record (verified against 703ee0557f892 original resume and current max98396_resume()):
| Path | Before | After | |---|---|---| | core enable fails | return, nothing enabled | unchanged | | pvdd enable fails | **return with core still enabled** | `goto err_core_supplies` → disable core | | vbat enable fails | **return with core (+ pvdd) still enabled** | `goto err_pvdd` → disable pvdd if present, then core | | `regcache_sync()` fails | **ignored; return 0** | restore cache-only + mark dirty, unwind vbat/pvdd/core, **return error** | | success | return 0 | return 0 |
Error labels check optional regulators before disable (if (max98396->vbat) / if (max98396->pvdd)), so NULL optional supplies are not disabled.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** (a) error-path resource leak + (g) ignored return / incorrect success
- **Mechanism:** resume acquired regulators without matching disable on later failure; regcache_sync() failure was dropped so PM treated a failed register restore as success.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Unwind order matches enable order (core → pvdd → vbat). Labels are correct for optional supplies.
- Restoring regcache_cache_only(true) + regcache_mark_dirty() after a failed sync is the standard pattern so a later resume can retry.
- **Regression risk:** low. Error paths only. device_resume() in this tree sets dev->power.is_suspended = false **before** the callback (drivers/base/power/main.c line 1129), so a later suspend may regulator_disable() already-disabled supplies and warn. That class of imbalance already existed on some old failure paths; leaking enables (keeping rails on) is worse. Sibling ASoC patches in the same series use the same unwind-on-resume-fail pattern.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Driver added: b585811367705 (“ASoC: max98396: add amplifier driver”)
- Buggy regulator resume: **703ee0557f892 (“ASoC: max98396: add voltage regulators”, 2022-06-27)** — **present in v6.0** (git merge- base --is-ancestor 703ee0557f892 v6.0 succeeded; not in v5.19)
- Resume body was unchanged from that commit until this fix (blame:
Daniel Mack 2022 for enable/return, Pengpeng Hou 2026 for gotos)
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Introducing commit is 703ee0557f892, in this tree and in v6.0+.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Later history is probe/PM-macro/style (c009893bc5864 SYSTEM_SLEEP_PM_OPS, DAPM convert, named initializers). **No prerequisite refactor of resume.** **Standalone** for this file. Cover letter lists it as **18/19** of an independent per-codec series, not a stacked dependency.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Pengpeng Hou is **not** the ASoC maintainer. Same week: many Propagate regcache_sync() errors codec patches. Maintainer who applied this one: **Mark Brown**.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **None required.** Touches only max98396_resume(), existing regulator_* / regcache_* APIs. Can apply standalone. No follow-ups on this file after d20de7409dfa8.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **b4 dig:**
https://patch.msgid.link/[email protected]
- **Series:** v1 only, **[PATCH 00/19] ASoC: codecs: propagate regcache_sync() failures** (20260704034845.14291-1)
- Cover letter (from saved mbox): *“This series is source-audited only. I did not test on the affected hardware.”* Explicitly calls out max98396 as one of four patches that also unwind resources.
- **No NAK** on this patch. Richard Fitzgerald Reviewed-by on sibling Cirrus patches (wm2200/cs4349/wm8962). Mark Brown discussed revert-on- sync-fail for wm8962 and said not to over-engineer recovery without a real use case — **not a NAK of unwind/propagate**.
- Mark applied **18/19** (skipped 03/19 lpass-wsa-macro) to for-7.3.
- **No reviewer Cc: stable** on this patch.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: Recipients included Mark Brown, Liam Girdwood, linux-sound, codec vendors. **No Reviewed-by on the max98396 patch itself.** Applied by the ASoC maintainer.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: **No user/syzbot/bugzilla report.** Source audit only.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 19 independent per-driver patches. This one does not need the others.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** — lore.kernel.org HTTP search returned 403. Thread retrieved via b4 dig -m has no stable discussion.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
Record: max98396_resume() only. Helpers used:regulator_bulk_enable/disable, regulator_enable/disable, regcache_cache_only, regcache_mark_dirty, regcache_sync, max98396_reset().
**Step 5.2: TRACE CALLERS**
Record: Only wired through SYSTEM_SLEEP_PM_OPS(max98396_suspend, max98396_resume) → max98396_pm → i2c_driver.driver.pm. Called from **system sleep resume**, not a hot syscall path.
**Step 5.3: TRACE CALLEES**
Record: Regulator enable/disable and regmap cache replay after max98396_reset(). Probe enables the same supplies and uses devm_add_action_or_reset() to unwind; **resume has no equivalent** without this patch.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace suspend (/sys/power/state or equivalent) → dpm_resume → device_resume → driver resume. **Reachable on any machine with this codec that suspends.** Not unprivileged-exploit in the UAF sense; it is a normal PM path.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same author’s series applies the same propagate/unwind pattern across many ASoC codecs. This driver uniquely also unwinds three supplies.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** File sound/soc/codecs/max98396.c is present. Introducing commit 703ee0557f892 is an ancestor of HEAD. Bug since **v6.0**. Current HEAD already contains d20de7409dfa8 (the candidate); pre-image of resume matches the patch’s before-state.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** to this lineage’s pre-fix resume (identical to v6.0-era function). SYSTEM_SLEEP_PM_OPS conversion (c009893bc5864) did not change resume body. No conflicting local changes to that function.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No earlier alternate fix of this leak. No later revert/follow-up on this file.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **ASoC codec driver** (sound/soc/codecs/max98396.c). **PERIPHERAL / driver-specific** (MAX98396/MAX98397 speaker amps, I2C, ACPI IDs ADS8396/ADS8397). Not core mm/net/fs.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: ASoC codecs are actively developed; this file is **mature** (driver 2022, regulators 2022, few functional changes since). Long-lived bug, not a brand-new subsystem.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Record: **Driver-specific / config-specific** (CONFIG_SND_SOC_MAX98396). Implied by a large ASoC codec umbrella Kconfig; in-tree DT only has the binding example (no board .dts in this tree). ACPI/OF/I2C IDs exist for real hardware.
**Step 8.2: TRIGGER CONDITIONS**
Record:
- System suspend/resume with this codec bound.
- **pvdd/vbat enable fail:** uncommon (regulator failure).
- **regcache_sync() fail:** more realistic (I2C error after reset/power-up). Old code returned **0** in that case — **every such failure was silent**.
- Unprivileged user cannot typically force I2C failure; they can trigger suspend.
**Step 8.3: FAILURE MODE SEVERITY**
Record:
- Regulator leak / enable-count imbalance → **HIGH for that class, but rare trigger**
- Silent successful resume with unrestored registers → **broken audio after suspend**, device in reset defaults → **MEDIUM** (user-visible, not panic/corruption)
- **Overall severity: MEDIUM** (important for this hardware, not a kernel-wide crash)
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit:** medium for MAX98396/97 users (correct resume failure, no leaked supplies, cache left retryable)
- **Risk:** low (21 lines, one function, error paths, obvious labels)
- **Ratio:** favorable
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real bugs: leaked enabled regulators on resume failure; ignored regcache_sync() so resume can succeed with hardware not restored
- Small, contained, obviously correct unwind
- Bug in this tree since v6.0 (703ee0557f892)
- No extra APIs/features; no series dependency
- ASoC maintainer merged it; sibling patches reviewed
- Matches stable’s usual error-path leak / missing-cleanup pattern
**AGAINST:**
- Source-audited only; author did not test on hardware
- No user/syzbot reports
- Not a panic, UAF, or data-corruption bug
- Peripheral codec, not core
- Possible extra regulator_disable on the *next* suspend if PM still treats the device as resumed after a failed callback (pre-existing PM interaction, mild)
**UNRESOLVED:**
- lore.kernel.org search 403; no independent confirmation of stable-list discussion
- No in-tree board DT showing how widely this amp is shipped (ACPI IDs still indicate real products)
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** on correctness (labels match enable order). **Weak on hardware test** (source audit), but soak in this 7.3-rc tree and maintainer merge count as review, not a FAIL.
2. Fixes a real bug that affects users? **PASS** — leak + silent failed cache replay after suspend.
3. Important issue? **PASS at MEDIUM** — not crash/security, but broken- audio-after-resume and regulator leak on a production PM path. Error- path resource cleanup is an accepted stable class.
4. Small and contained? **PASS** — +21/−3, one function, one file.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — driver and buggy resume exist here; pre-fix code matches the hunk.
**Step 9.3: EXCEPTION CATEGORIES**
Record: None (not a device ID, quirk, DT, build, or docs-only change). Qualifies as a normal small bugfix.
**Step 9.4: DECISION**
This tree has the buggy resume path and the hardware driver. The patch is a surgical fix for a real resume leak and a real ignored-error success path. Conservative severity, but it meets the letter of the stable rules and the “error-path leak = backport” guidance. Risk is low enough to take it.
---
### What the commit solves for this tree
max98396_resume() can enable core (and maybe pvdd) supplies then return without disabling them, and it previously ignored regcache_sync(). After suspend, a failed I2C cache replay left the amp in reset/defaults while PM thought resume succeeded. The patch unwinds every supply this resume acquired, restores cache-only/dirty on sync failure, and returns the error.
### Stable-rules fit
Small, obviously correct, no new API, applies to this tree’s long- standing resume function. Importance is medium (driver PM error path), not a core crash, but it is a real user-visible resume bug plus a resource leak.
### Risk vs benefit
Benefit is correct suspend/resume for MAX98396/97. Risk is confined to failure paths already returning errors (except the newly propagated sync failure, which *should* fail).
### Concerns
Untested on hardware; no field reports. That is not enough to drop a 21-line leak/error-propagation fix for a driver this tree actually ships.
### Verification
- **[Phase 1]** Parsed subject/tags/body from git show d20de7409dfa8; no Fixes/Reported-by/Cc stable; Link to msgid 20260704040651.47558-1
- **[Phase 2]** Diff: +21/−3 in max98396_resume() only; compared to original resume in 703ee0557f892
- **[Phase 3]** git blame -L 1574,1634 sound/soc/codecs/max98396.c; introducer 703ee0557f892; in v6.0, not v5.19; git merge-base --is- ancestor for both introducer and fix vs HEAD
- **[Phase 3]** git log --oneline -- sound/soc/codecs/max98396.c; no resume prerequisites; no follow-ups after the fix
- **[Phase 3]** git describe HEAD / make kernelversion / Makefile:
**v7.3-rc4, 7.3.0-rc4**
- **[Phase 4]** b4 dig -c/-a/-w/-m: series 18/19, v1 only, cover letter “source-audited only”; Mark Brown applied to for-7.3; no NAK on this patch
- **[Phase 4]** lore HTTP search 403 — stable-list discussion **UNVERIFIED**
- **[Phase 5]** Callers: only SYSTEM_SLEEP_PM_OPS → i2c .pm; probe uses devm_add_action_or_reset for the same supplies
- **[Phase 6]** Buggy resume exists in this tree from v6.0; current file already has the fixed form
- **[Phase 8]** device_resume() sets is_suspended = false before the callback (main.c:1126–1129, 1192)
- **UNVERIFIED:** in-tree board usage (no .dts nodes; ACPI/OF IDs only)
**YES**
sound/soc/codecs/max98396.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
sound/soc/codecs/max98396.c +21 -3
@@ -1601,19 +1601,37 @@ static int max98396_resume(struct device *dev)if (max98396->pvdd) { ret =regulator_enable (max98396->pvdd);if (ret <0 ) -return ret; + goto err_core_supplies; }if (max98396->vbat) { ret =regulator_enable (max98396->vbat);if (ret <0 ) -return ret; + goto err_pvdd; }regcache_cache_only (max98396->regmap, false);max98396_reset (max98396, dev); -regcache_sync (max98396->regmap); + ret =regcache_sync (max98396->regmap); +if (ret <0 ) { +regcache_cache_only (max98396->regmap, true); +regcache_mark_dirty (max98396->regmap); + goto err_vbat; + } +return 0 ; + +err_vbat: +if (max98396->vbat) +regulator_disable (max98396->vbat); +err_pvdd: +if (max98396->pvdd) +regulator_disable (max98396->pvdd); +err_core_supplies: +regulator_bulk_disable (MAX98396_NUM_CORE_SUPPLIES , + max98396->core_supplies); + +return ret; }static const struct dev_pm_ops max98396_pm = {
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 HID: i2c-hid: Add i2c-hid-quirk-bad-input-size quirk for 0911:5288 device
In reply to Sasha LevinFrom: Youth Cao <[email protected]>
[ Upstream commit 58d97b45f3f43af0afd9c74e8480d22d36fd3f72 ]
I have recently acquired a cheap Apollo Lake-based laptop that uses a Hynitron CST128-A touchpad controller. While booting from a Debian LiveCD, the kernel log is flooded with the following error (though the touchpad works well):
i2c_hid_acpi i2c-ALPS0001:00: i2c_hid_get_input: incomplete report (27/42405)
The CST128-A was identified via ACPI as ALPS0001:00, and the I2C HID device ID (0911:5288) was shared with the Hantick 5288.
Add the I2C_HID_QUIRK_BAD_INPUT_SIZE quirk option to the existing Hantick 5288 quirk entry to suppress the kernel log flood.
---
LLM Generated explanations, may be completely bogus:
Local tree is **6.18.57** (v6.18.57-155-gcdf239ca885b2). This is a one-line HID i2c-hid hardware quirk for device 0911:5288. The quirk table, I2C_HID_QUIRK_BAD_INPUT_SIZE, and the Hantick 5288 entry are all already in this tree.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[HID/i2c-hid] [Add] hardware quirk I2C_HID_QUIRK_BAD_INPUT_SIZE for I2C HID ID 0911:5288 (Hantick 5288 / Hynitron CST128-A)**
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- **Fixes:** none (expected for this review)
- **Reported-by:** none (author is the reporter: “I have recently acquired…”)
- **Tested-by:** none
- **Reviewed-by:** none on the commit
- **Acked-by:** none
- **Link:** none on the commit; lore thread recovered via b4 dig
- **Cc: stable:** none (expected)
- **Signed-off-by:** Youth Cao (author); Jiri Kosina (HID maintainer, applied it)
- Ignore pipeline SOBs/Upstream markers as instructed
Notable: HID maintainer SOB. Single reporter, real hardware.
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** Hynitron CST128-A touchpad (ACPI ALPS0001:00, I2C HID ID 0911:5288) reports a bogus input length.
- **Symptom:** kernel log flooded with i2c_hid_get_input: incomplete report (27/42405). Touchpad still works.
- **Root cause:** device writes an invalid HID input length (42405 = 0xA5A5) while wMaxInputLength is 27.
- **Fix:** OR I2C_HID_QUIRK_BAD_INPUT_SIZE onto the existing Hantick 5288 quirk so the driver uses max input length instead of dropping the report and calling unratelimited dev_err().
- **Version info:** none in the message. Hardware is cheap Apollo Lake laptops; driver support for this ID dates to 2017.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. Explicit hardware quirk. Same class as USB/PCI/codec quirks that stable already takes.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- **File:** drivers/hid/i2c-hid/i2c-hid-core.c — 1 insertion, 1 deletion
- **Function / data:** i2c_hid_quirks[] table, Hantick 5288 entry
- **Scope:** single-file, one-line surgical quirk
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- **Before:** 0911:5288 only has I2C_HID_QUIRK_NO_IRQ_AFTER_RESET. In i2c_hid_get_input(), if ret_size > size || ret_size < sizeof(__le16), the IRQ path logs incomplete report via dev_err() (not ratelimited) and **returns without delivering the HID report**.
- **After:** same ID also has I2C_HID_QUIRK_BAD_INPUT_SIZE. On a bad size, the driver overwrites the length prefix with size (min(wMaxInputLength, bufsize)) and continues into hid_safe_input_report().
- **Path:** IRQ handler (i2c_hid_irq → i2c_hid_get_input), not probe/error-init. Only this VID/PID.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- **Category:** hardware workaround (quirk table)
- **Mechanism:** device reports garbage length (0xA5A5 / 42405). Without the quirk, every such IRQ logs and drops the report. The quirk is the existing BAD_INPUT_SIZE path added in 2019 for Lenovo Y720.
Verified BAD_INPUT_SIZE handler in this tree:
```561:570:drivers/hid/i2c-hid/i2c-hid-core.c
if (ret_size > size || ret_size < sizeof(__le16)) {
if (ihid->quirks & I2C_HID_QUIRK_BAD_INPUT_SIZE) {
*(__le16 *)ihid->inbuf = cpu_to_le16(size);
ret_size = size;
} else {
dev_err(&ihid->client->dev,
"%s: incomplete report (%d/%d)\n",
__func__, size, ret_size);
return;
```size is already capped to ihid->bufsize, so forcing ret_size = size does not overflow the input buffer.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: one flag on an existing table entry; handler already used by Lenovo Y720 (USB_VENDOR_ID_ITE / Legion Y720) in this tree.
- Minimal, no API/refactor.
- **Regression risk:** low. Quirk only runs when the length is already invalid. Well-formed reports for other 0911:5288 boards (Cube Thinker, EZBook 3 Pro, T-bao, etc. from Hans de Goede’s 2017 commit) are unchanged. Worst case on a truly truncated packet is processing a padded report instead of dropping it — same as Y720 since 2019.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Hantick 5288 table entry introduced by **402946a8ef71e** (Hans de Goede, 2017-11-07): HID: i2c-hid: Add no-irq-after-reset quirk for 0911:5288 device. Present in **v6.18.57**.
- I2C_HID_QUIRK_BAD_INPUT_SIZE introduced by **fd09137687016** (Pavel Balan, 2019-11-27) for Lenovo Y720 incomplete-report flood. Present in **v6.18.57**.
- Buggy combination (Hantick ID without BAD_INPUT_SIZE) has been in-tree for years.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Not applicable. The “broken” state is hardware, not a recent kernel regression.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- Same-file relatives: fd09137687016 (Y720 BAD_INPUT_SIZE), 402946a8ef71e (Hantick NO_IRQ_AFTER_RESET), fb6acf76c3fdd (Raydium incomplete-report flood).
- Not a numbered series. Standalone v1.
- Prerequisite code (quirk bit + table entry + handler) is in this tree. No missing helpers.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Youth Cao has only this commit under drivers/hid/i2c-hid/ here. Not the maintainer. Applied by Jiri Kosina, HID maintainer.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: None beyond 2017/2019 infrastructure already in 6.18.57. Standalone one-liner.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 58d97b45f3f43af0afd9c74e8480d22d36fd3f72 →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only** (2026-09-04). Applied as submitted.
- Thread: author submission; sashiko-bot flag of an **unrelated pre- existing DMA** issue in i2c_hid_fetch_hid_descriptor(); Jiri Kosina “Applied, thanks.” (2026-09-11).
- No NAK, no request for v2, no stable nomination in review.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To/Cc included Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel. Maintainer applied it. No extra Reviewed-by.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: The patch *is* the bug report. One user, Debian LiveCD, Apollo Lake + CST128-A. Concrete log line. Author says the touchpad “works well” aside from the flood.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone. Not 2/N. No sibling patches required.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: Web search of lore.kernel.org/stable for this subject/ID found no prior stable discussion (lore HTTP 403 from this environment; openwall/lkml used instead). **UNVERIFIED** that nobody requested it on stable@, but nothing found arguing against it.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: No function body changed. Data only: i2c_hid_quirks[]. Runtime effect is in i2c_hid_lookup_quirk() and i2c_hid_get_input().
Step 5.2: TRACE CALLERS
Record:
- i2c_hid_lookup_quirk() called from __i2c_hid_core_probe() (ihid->quirks = ...) — device probe, once per device.
- i2c_hid_get_input() called from i2c_hid_irq() — interrupt context, every input IRQ.
- Impact surface: only VID/PID 0911:5288.
Step 5.3: TRACE CALLEES
Record: After the quirk, path continues to hid_safe_input_report() (present in v6.18.57). Input buffer already sized; length forced to size ≤ bufsize.
Step 5.4: FOLLOW THE CALL CHAIN
Record: ACPI I2C HID enumeration (i2c-hid-acpi) → probe → IRQ on touchpad activity. Reachable on real laptops without special syscalls. CONFIG_I2C_HID is default y; I2C_HID_ACPI is the usual x86 laptop path.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same quirk already used for Lenovo Legion Y720. Same “incomplete report” flood class previously fixed (Y720, Raydium). Pattern is established, not experimental.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: **Yes.** At v6.18.57:
```
{ I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288,
I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
```IDs in drivers/hid/hid-ids.h: I2C_VENDOR_ID_HANTICK 0x0911, I2C_PRODUCT_ID_HANTICK_5288 0x5288. BAD_INPUT_SIZE bit and handler exist. Bug introduced with this hardware + the 2017 ID match, not after 6.18 branched.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **Minor context only.** git apply --check of the stored hunk onto v6.18.57 fails because context includes the later Yoga Slim 7x keyboard quirk line (I2C_DEVICE_ID_ITE_LENOVO_YOGA_SLIM_7X_G11_KEYBOARD), which is **not** in v6.18.57. The Hantick line itself matches. A 1-line context tweak applies cleanly. Not a semantic rework.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: Y720 BAD_INPUT_SIZE is present. Nothing else already adds BAD_INPUT_SIZE for 0911:5288 at v6.18.57. No alternate fix.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: **HID / i2c-hid** (drivers/hid/i2c-hid/). **IMPORTANT** for laptop input (touchpads/touchscreens), not core mm/fs. Peripheral in the sense of one cheap-laptop ID, but i2c-hid itself is common.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Actively maintained (Dell S4, Elan panel, QTEC, Goodix, buffer overflow fixes in recent 6.18 history). Quirk table is a mature, long- lived mechanism.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver/hardware-specific. Users of I2C HID 0911:5288 (Hantick 5288 clones, Hynitron CST128-A on cheap Apollo Lake laptops). CONFIG_I2C_HID / I2C_HID_ACPI.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Touchpad IRQs that carry a bogus length. Author saw it at boot on a Debian LiveCD, so it is not rare-on-error-only for this hardware. Unprivileged users generate IRQs by using the pad; they cannot change the VID/PID. Not a security trigger.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- **Failure mode:** unratelimited dev_err() from IRQ context → dmesg/journal flood; those reports are dropped.
- **Severity:** **MEDIUM** as a log flood; can still hurt (console spam, log wrap, hiding other messages). Not oops/deadlock/corruption. Author says the pad still works, so some reports are valid.
- Hardware-quirk exception still applies.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit:** medium for affected hardware (stops flood; may deliver reports that were dropped). Low for everyone else (no code path change).
- **Risk:** very low (1 line, existing quirk, ID-matched).
- **Ratio:** favorable. Classic stable quirk.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
**FOR:**
- Real hardware, real user log, concrete incomplete report (27/42405).
- Existing quirk infrastructure in 6.18.57; same pattern as Y720 (2019).
- One line, ID-scoped, no new API.
- HID maintainer applied v1 with no objections.
- Unratelimited dev_err in IRQ is a real nuisance on these machines.
- Stable exception: hardware quirk on an existing driver.
**AGAINST:**
- Not a crash, UAF, or data-corruption fix; author says the touchpad already works.
- Applies to every 0911:5288, not only CST128-A/ALPS0001 (mitigated:
quirk inert on valid lengths).
- Naive apply onto bare v6.18.57 needs a tiny context tweak (Yoga Slim line).
**UNRESOLVED:**
- Could not fetch lore.kernel.org (HTTP 403); used b4 dig mbox + Openwall/LKML.
- No stable@ thread found; absence not treated as a negative.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — one flag; author tested on the laptop; maintainer applied.
2. Fixes a real bug that affects users? **PASS** — log flood + dropped bad-size reports on real hardware.
3. Important issue? **PASS** under the hardware-quirk exception; severity MEDIUM, not CRITICAL.
4. Small and contained? **PASS** — 1 line, one table entry.
5. No new features or APIs? **PASS** — reuses I2C_HID_QUIRK_BAD_INPUT_SIZE.
6. Can apply to the local tree? **PASS** — code exists in 6.18.57; at most a context-line adjustment.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: **Hardware quirk/workaround** on an existing i2c-hid quirk table. Explicitly in-scope for stable.
Step 9.4: MAKE YOUR DECISION
This should be backported to this 6.18.y tree. The buggy Hantick entry and BAD_INPUT_SIZE handler are already here. The change is the standard way this driver papers over broken input-length hardware.
What it solves for stable users: cheap Apollo Lake machines with 0911:5288 (Hynitron CST128-A / Hantick clones) stop flooding the log on every bad-sized HID IRQ, matching the Y720 precedent.
Risk vs benefit: very low risk, localized benefit, no prerequisites missing.
Concerns: trivial hunk-context conflict with the Yoga Slim quirk line if applying the mainline diff onto unmodified v6.18.57; the Hantick line itself does not need rework.
Verification:
- [Phase 1] Parsed subject/tags/body from git show 245d6017beff2 / upstream 58d97b45f3f4; no Fixes/Reported-by/Cc:stable; SOB Youth Cao
+ Jiri Kosina
- [Phase 2] Diff is 1 line in i2c_hid_quirks[]; handler at i2c_hid_get_input() lines 561–570 verified; size capped to bufsize at 532–533
- [Phase 2] 42405 == 0xA5A5 verified arithmetically
- [Phase 3] git merge-base --is-ancestor 402946a8ef71e v6.18.57 YES; fd09137687016 YES; this commit NOT in v6.18.57
- [Phase 3] git blame -L 120,145 v6.18.57 -- drivers/hid/i2c-hid/i2c-hid-core.c: Hantick entry from 402946a8ef71e / 67b18dfb8cfc6d
- [Phase 3] Author git log --author='Youth Cao' only this i2c-hid commit
- [Phase 4] b4 dig -c 58d97b45f3f4 → msgid 20260903161444.786-1; -a v1 only; -w Kosina + Tissoires + linux-input; -m 3-message mbox
- [Phase 4] Openwall: Jiri Kosina “Applied, thanks.”; sashiko-bot pre- existing DMA note unrelated
- [Phase 4] lore.kernel.org WebFetch 403; stable@ search found no discussion of this ID
- [Phase 5] git grep callers: lookup at probe 1073; get_input from i2c_hid_irq 592
- [Phase 5] hid_safe_input_report ancestor of v6.18.57: YES
- [Phase 6] make kernelversion / Makefile: 6.18.57; Hantick IDs in v6.18.57 hid-ids.h 646–647
- [Phase 6] git apply --check of the stored hunk onto v6.18.57 fails on Yoga Slim context line; Hantick source line identical
- [Phase 7] Kconfig: I2C_HID default y; I2C_HID_ACPI for this ACPI path
- [Phase 8] Failure mode: IRQ dev_err flood + dropped reports; not oops
- UNVERIFIED: full lore.kernel.org HTML thread (403); whether any 0911:5288 unit is harmed by processing bad-size frames (no reports found)
**YES**
drivers/hid/i2c-hid/i2c-hid-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/i2c-hid/i2c-hid-core.c +1 -1
@@ -123,7 +123,7 @@ static const struct i2c_hid_quirks {__u32 quirks; } i2c_hid_quirks[] = { {I2C_VENDOR_ID_HANTICK ,I2C_PRODUCT_ID_HANTICK_5288 , - I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, + I2C_HID_QUIRK_NO_IRQ_AFTER_RESET | I2C_HID_QUIRK_BAD_INPUT_SIZE }, { I2C_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_VOYO_WINPAD_A15, I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, { I2C_VENDOR_ID_RAYDIUM, I2C_PRODUCT_ID_RAYDIUM_3118,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 hfsplus: validate extent record length before writing it back
In reply to Sasha LevinFrom: Jiaming Zhang <[email protected]>
[ Upstream commit 627b7865c062ff642c0000f3a4775f1a44b986a4 ]
__hfsplus_ext_write_extent() writes the cached extent record back into a B-tree node using fd->entrylength as the length, and fd->entrylength is derived in __hfs_brec_find() from two on-disk values:
fd->entrylength = len - keylen;
A crafted image can keep both len and keylen valid but make fd->entrylength negative (keylen > len). __hfsplus_ext_write_extent() doesn't check fd->entrylength before consuming it, and hfs_bnode_write() takes the length as u32, so the negative value turns into a huge one. The copy then reads data past the end of hip->cached_extents, which is only sizeof(hfsplus_extent_rec) bytes long, and leaks kernel memory into the image.
Reject an fd->entrylength that does not match sizeof(hfsplus_extent_rec) in __hfsplus_ext_write_extent(), mirroring the check already performed in __hfsplus_ext_read_extent().
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). The two-line write-side length check is missing here, the buggy path is present, and the patch applies cleanly.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[hfsplus] [validate] [reject a corrupt overflow-extent record length before writing it back into the extents B-tree]**
- Subsystem: hfsplus
- Verb: “validate” — a missing safety check, not a feature
- Intent: stop __hfsplus_ext_write_extent() from using an on-disk entrylength that does not match sizeof(hfsplus_extent_rec)
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Mainline commit: 627b7865c062ff642c0000f3a4775f1a44b986a4 (not in this tree).
Record:
- **Fixes:** none (expected for this review)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** Viacheslav Dubeyko <[email protected]> (HFS/HFS+ maintainer)
- **Acked-by:** none
- **Link:** https://lore.kernel.org/lkml/cbd7003314c530d4f910eacf019ff8 [email protected]/ (maintainer discussion that prompted the patch)
- **Link:** https://lore.kernel.org/r/20260810092422.1691377-1- [email protected] (patch submission)
- **Cc: stable:** none (expected)
- **Signed-off-by:** Jiaming Zhang (author); Viacheslav Dubeyko (maintainer)
Notable: the sent patch CCs [email protected]. No explicit syzbot hash in the committed message.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** __hfs_brec_find() sets fd->entrylength = len - keylen from two on-disk u16s. A crafted node can keep both values “valid” while keylen > len, so entrylength is negative.
- **Symptom:** __hfsplus_ext_write_extent() passes that signed length into hfs_bnode_write(), which takes u32 len. The negative value becomes a huge length. The copy reads past hip->cached_extents (only sizeof(hfsplus_extent_rec) bytes) and **writes kernel memory into the filesystem image**.
- **Version info:** none in the message. The write site has existed since early HFS+ code; hfs_bnode_write() taking u32 is already in this 6.12 tree.
- **Root cause:** write path never checks entrylength; the read path already does.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not hidden.** This is an explicit memory-safety / info-leak fix, described as such.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** fs/hfsplus/extents.c — **+2 / -0**
- **Function:** __hfsplus_ext_write_extent()
- **Scope:** single-file surgical fix (two lines)
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** on the existing-record path (!(extent_state & HFSPLUS_EXT_NEW)), a successful hfs_brec_find() is followed immediately by hfs_bnode_write(..., fd->entryoffset, fd->entrylength).
- **After:** if fd->entrylength != sizeof(hfsplus_extent_rec), return -EIO and do not write.
- **Path:** overflow-extent **update** (not the HFSPLUS_EXT_NEW insert path, which already passes sizeof(hfsplus_extent_rec)).
- Insert path is unchanged.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** memory safety — out-of-bounds read of kernel memory, leaked into the on-disk B-tree node (info leak + image corruption). Also a logic/correctness gap: write did not mirror the read-side check that has existed since 1da177e4c3f41 (Linux-2.6.12-rc2).
- **Mechanism verified in this tree:**
- fd->entrylength is int (fs/hfsplus/hfsplus_fs.h).
- __hfs_brec_find() does fd->entrylength = len - keylen with u16 len, keylen (fs/hfsplus/bfind.c). Integer promotions make keylen > len a **negative int**.
- hfs_bnode_write() takes u32 len (fs/hfsplus/bnode.c), already true here via 350183396918f (“hfs/hfsplus: prevent getting negative values of offset/length”).
- cached_extents is hfsplus_extent_rec = 8 × {start, count} =
**64 bytes**.
- check_and_correct_requested_length() caps the **destination** to the remaining node size, but memcpy_to_page() still reads len bytes from the **source** cached_extents. A huge/mismatched length over-reads adjacent inode-slab memory and writes it into the node.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Quality:** obviously correct. Same predicate as __hfsplus_ext_read_extent(). Valid HFS+ overflow records are a fixed 64-byte extent array; a different size is corrupt.
- **Minimal:** two lines, no unrelated edits.
- **Regression risk:** very low. Valid images already satisfy this on read; insert already uses sizeof. Invalid images now get -EIO instead of a kernel leak. HFSPLUS_EXT_DIRTY is left set, so a later write_inode can retry; that is existing dirty-extent behavior, not a new API.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- The hfs_bnode_write(..., fd->entrylength) site dates to 6af502de224c37 (Christoph Hellwig, 2010) in current blame; the surrounding write function is older (^1da177e4c3f41, 2.6.12).
- The matching **read-side** check is ^1da177e4c3f41 (2005). The write-side gap is long-standing.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Not applicable. Bug is missing validation on a path that has been in the tree for many releases, not a recently introduced regression.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Related in this tree: 99202d94909d3 (KMSAN in __hfsplus_ext_cache_extent), 350183396918f (signed offset/length → u32), c91bbd6193c70 / 7898beee166c1 (other on-disk record size checks).
- On origin: 00aedd67d75d7 “hfsplus: validate B-tree record offset table” is a **separate** larger patch, **not** in this tree and **not** required for these two lines.
- **Standalone.** Not patch X/Y of a series that must land together.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record:
- Author Jiaming Zhang has no other fs/hfsplus/ commits in this checkout.
- Reviewer/committer Viacheslav Dubeyko is the HFS maintainer; this tree already carries many of his HFS+ fuzz/corruption fixes.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record:
- No new helpers or structs.
- Relies on existing sizeof(hfsplus_extent_rec) and fd->entrylength.
- hfs_bnode_write() being u32 is already here; the check is valid even without that conversion.
- **git apply --check of 627b7865c062f succeeded** on this tree. The only nearby mainline difference (HFSPLUS_EXT_TREE_I extra set_bit) is **after** this hunk and does not block the apply.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 627b7865c062f → https://patch.msgid.link/20260810092422.1 [email protected]
- Direct lore/WebFetch returned **403**; thread was recovered with b4 dig -m.
- b4 dig -a shows earlier revisions were a **different** patch (“validate B-tree record offset table”, v1–v6). This extent-length check is a **new standalone v1** (2026-08-10), not a later revision of the offset-table series.
- Maintainer reply ([email protected]):
**“Looks good.”** + Reviewed-by. **No NAK, no stability concern.**
- No reviewer Cc: stable in the two-message thread (absence is not a negative).
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record:
- Recipients (from the mbox): Viacheslav Dubeyko, Yangtao Li, John Paul Adrian Glaubitz, linux-fsdevel, linux-kernel, syzkaller.
- Reviewed by the subsystem maintainer.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record:
- No syzbot hash / bugzilla in the commit.
- Body describes a crafted-image trigger; patch CCs syzkaller.
- Original Dubeyko lore URL could not be fetched (403). Unverified beyond the Link: tag existing.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record:
- Offset-table series is related thematically, not a dependency.
- No follow-up on origin/master after 627b7865c062f touching fs/hfsplus/extents.c.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search returned 403. **UNVERIFIED** whether stable@ already discussed this SHA. Decision does not depend on that.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
semcode MCP tools are **not available**; callers/callees traced with grep and file reads.
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: __hfsplus_ext_write_extent() only.
**Step 5.2: TRACE CALLERS**
Record:
- hfsplus_ext_write_extent_locked() → hfsplus_ext_write_extent() (hfsplus_write_inode in super.c) and hfsplus_file_extend() (insert_extent).
- __hfsplus_ext_cache_extent() writes a dirty cache before reading another extent; used from hfsplus_ext_read_extent() → hfsplus_get_block(), and from hfsplus_file_truncate().
- Context: inode writeback, file extend, truncate, block mapping — normal file I/O on HFS+, not init-only.
**Step 5.3: TRACE CALLEES**
Record: hfsplus_ext_build_key, hfs_brec_find, hfs_bmap_reserve / hfs_brec_insert (new records), hfs_bnode_write (updates). The new check sits immediately before hfs_bnode_write.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record:
- Userspace: mount HFS+ → write/truncate/fsync/umount on a file with overflow extents.
- Crafted images are the trigger (USB/disk image, fuzzing). Mount typically needs privilege, but that is the usual model for filesystem image bugs already backported here.
- **Reachable from VFS file ops**, not an obscure debug path.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record:
- Read path already has the identical check (extents.c ~170–171).
- Catalog paths already reject bad entrylength (dir.c, catalog.c, inode.c).
- This is the overflow-extent **write** hole in that same pattern.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** Local __hfsplus_ext_write_extent() still does:
```113:114:fs/hfsplus/extents.c
hfs_bnode_write(fd->bnode, hip->cached_extents,
fd->entryoffset, fd->entrylength);
```No length check. git merge-base --is-ancestor 627b7865c062f HEAD is false. Bug is old (write site 2010 / structure since 2.6.12). u32 conversion that turns a negative length into a huge copy **is already in this 6.12.111 tree**.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** (git apply --check on 627b7865c062f succeeded). Hunk context around hfs_bnode_write matches. No rework needed.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record:
- Read-side check: yes (since 2.6.12).
- Write-side check: **no**.
- 350183396918f changed the failure mode (negative int → huge u32) but did not add this check.
- No alternate fix for this write-side hole.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **fs/hfsplus** — Apple HFS+. **IMPORTANT** (not core MM/VFS, not staging). Used for Mac-formatted disks; this tree already backports many HFS+ crafted-image fixes.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature filesystem, still getting sanitizer/corruption fixes in 6.12.y. Not dead code.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Filesystem-specific / config-specific** (CONFIG_HFSPLUS_FS). Anyone who mounts HFS+ (including untrusted/crafted images).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Trigger: mount crafted HFS+ with a malformed extents overflow record (keylen > len or any entrylength != 64), then dirty and write back cached overflow extents (write, truncate, writeback).
- Not every boot; requires HFS+ + overflow extent writeback + corrupt record.
- Unprivileged users cannot usually mount; a privileged mount of untrusted media is still the standard stable threat model for these bugs.
- The write-side hfs_brec_find() is independent of the earlier read. A crafted tree (duplicate keys, confused search after splits) can present a bad entrylength on update even though the read path has a check. The code is also simply wrong: updates trust on-disk length instead of the known 64-byte record size.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- **Failure mode:** kernel out-of-bounds read of inode-adjacent memory; those bytes are written into the extents B-tree node (info leak on disk + corruption of the overflow tree). With KASAN this is an OOB report; without it, silent leak/corruption.
- **Severity: HIGH** (memory safety + info leak + image corruption). Not a guaranteed panic on production kernels, but not cosmetic.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** high for HFS+ users and for the same crafted-image class already being fixed in 6.12.y.
- **Risk:** very low (2 lines, same predicate as a 20-year-old read check, clean apply).
- **Ratio:** strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real bug: OOB read of cached_extents and kernel memory leaked into the image.
- Important: memory safety, info leak, B-tree corruption on crafted HFS+.
- Tiny, obviously correct, maintainer-reviewed.
- Buggy code and the u32 write signature are in **this** 6.12.111 tree.
- Applies cleanly; no prerequisites.
- Matches existing read-side check and other HFS+ validation backports already here.
**AGAINST:**
- HFS+ is not universal.
- No Fixes: / syzbot hash / Cc: stable (expected; not a reason to reject).
- Typical flow reads first, so a naive reading might call it “defensive.” That does not make the write path safe: find is redone, on-disk length is still trusted, and the maintainer accepted the leak description.
**UNRESOLVED:**
- Full original Dubeyko lore mail (403).
- Whether stable@ already discussed this SHA (403).
- No public reproducer in the two-message thread.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — mirrors the read check; maintainer Reviewed-by.
2. Fixes a real bug that affects users? **PASS** — crafted HFS+ image, kernel memory leak into the filesystem.
3. Important issue? **PASS** — OOB read / info leak / image corruption (HIGH).
4. Small and contained? **PASS** — +2 lines, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — git apply --check succeeded; buggy code present.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. It is a normal small bugfix.
**Step 9.4: MAKE YOUR DECISION**
Backport to this 6.12.111 tree. The hole is here, the u32 conversion that turns a negative length into a huge copy is here, and the fix is two lines that valid images already satisfy.
------------------------------------------------
What the commit solves for this tree
------------------------------------------------
__hfsplus_ext_write_extent() updates an overflow extent using fd->entrylength from on-disk B-tree fields. A crafted node can make that length negative or otherwise not 64. hfs_bnode_write() treats it as u32, over-reads the 64-byte cached_extents in the inode, and writes kernel memory into the image. The read path has rejected this since 2.6.12; the write path in 6.12.111 still does not.
It meets the stable rules: real bug, important (memory safety / leak / corruption), two lines, no new API, clean apply, no missing prerequisites.
Risk vs benefit: benefit is closing an HFS+ crafted-image leak already in this tree; risk is negligible because valid overflow records are fixed-size.
------------------------------------------------
Verification
------------------------------------------------
- **[Phase 1]** Parsed tags on 627b7865c062f: Reviewed-by Dubeyko; two
Link: URLs; no Fixes/Reported-by/Cc-stable.
- **[Phase 2]** Diff: +2 lines in __hfsplus_ext_write_extent() before hfs_bnode_write().
- **[Phase 2]** Confirmed entrylength is int; __hfs_brec_find() uses len - keylen; hfs_bnode_write(..., u32 len); cached_extents is 64 bytes; dest length is capped but source is not.
- **[Phase 3]** Blame: write uses entrylength since Hellwig 2010; read-side check since 1da177e4c3f41.
- **[Phase 3]** No Fixes: tag. Standalone, not the offset-table series.
- **[Phase 3]** git apply --check of 627b7865c062f on this tree:
success.
- **[Phase 4]** b4 dig -c 627b7865c062f: msgid [email protected]; maintainer “Looks good” + Reviewed-by. b4 dig -a: this is a new v1, not v7 of the offset-table patch.
- **[Phase 4]** lore WebFetch/curl: 403. Thread recovered via b4 dig -m.
- **[Phase 5]** Callers: hfsplus_write_inode, hfsplus_file_extend, __hfsplus_ext_cache_extent (get_block/truncate). semcode unavailable.
- **[Phase 6]** git describe HEAD: p-6.12-3-gc504cf0baa3d8; make kernelversion: 6.12.111.
- **[Phase 6]** git merge-base --is-ancestor 627b7865c062f HEAD: not an ancestor. Local write path still unchecked.
- **[Phase 6]** 350183396918f (u32 bnode lengths) **is** in HEAD.
- **[Phase 8]** Failure mode: OOB read + kernel memory leaked into the extents tree; severity HIGH.
- **UNVERIFIED:** original Dubeyko prompt mail body; stable@ archive discussion.
The fix is small, surgical, present-bug, and meets the stable criteria for this tree.
**YES**
fs/hfsplus/extents.c | 2 ++ 1 file changed, 2 insertions(+)
fs/hfsplus/extents.c +2 -0
@@ -110,6 +110,8 @@ static int __hfsplus_ext_write_extent(struct inode *inode, }else {if (res)return res; +if (fd->entrylength !=sizeof (hfsplus_extent_rec)) +return -EIO ;hfs_bnode_write (fd->bnode, hip->cached_extents, fd->entryoffset, fd->entrylength); hip->extent_state &= ~HFSPLUS_EXT_DIRTY ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 fbcon: Fix KASAN slab-out-of-bounds Read in fbcon_prepare_logo
In reply to Sasha LevinFrom: Helge Deller <[email protected]>
[ Upstream commit 94e6a058b16820e02f25e1221a4c4e713ba23550 ]
Ensure the logo will not exceed the screen size, which then should fix a reported KASAN: slab-out-of-bounds Read in fbcon_prepare_logo.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). The buggy logo_lines walk is present here, and the candidate is a 7-line KASAN bounds check that applies cleanly.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[fbcon] [Fix] [KASAN slab-out-of-bounds read in fbcon_prepare_logo]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Reported-by: [email protected]
- Signed-off-by: Helge Deller \<[email protected]\> (FRAMEBUFFER LAYER maintainer; applied the patch himself)
- No Fixes:, no Cc: stable, no Reviewed-by/Acked-by/Tested-by, no Link:
in the committed message (the syzbot-forwarded submission did include Link: https://syzkaller.appspot.com/bug?extid=0c815b25cdb3678e7083)
- Notable: syzbot + maintainer SOB; absence of Fixes/Cc:stable is expected for this review pipeline
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: calculated logo height can exceed the console buffer, then fbcon_prepare_logo() reads past it.
- Symptom: KASAN slab-out-of-bounds Read (also KFENCE OOB and UAF-class reports on the same syzbot bug).
- Version info in the message: none. Syzbot shows crashes from Feb 2025 through 2026 on upstream, and on linux-5.15.y / 6.1.y / 6.6.y.
- Root cause as stated: logo not clipped to screen size before the buffer walk.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a hidden fix. Explicit KASAN OOB fix. The later if (logo_lines > vc->vc_bottom) path already tried to disable an oversized logo, but only **after** the out-of-bounds walk.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/video/fbdev/core/fbcon.c (+7 / −0)
- Function: fbcon_prepare_logo()
- Scope: single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: After logo_lines = DIV_ROUND_UP(logo_height, vc->vc_font.height) the code immediately walked q - logo_lines * cols. Now it clamps logo_lines to rows and new_rows - 1, and if that leaves nothing, sets logo_shown = FBCON_LOGO_DONTSHOW and returns. Normal path with a logo that already fits is unchanged.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Memory safety / out-of-bounds.** fb_prepare_logo() returns a pixel height <= yres, but DIV_ROUND_UP(height, font_height) can be one larger than yres / font_height (new_rows). Example: yres=100, font=16 → logo_lines=7, new_rows=6. Then q - logo_lines * cols is one row before vc_origin, and scr_readw / scr_memcpyw go OOB. The existing logo_lines > vc->vc_bottom check runs too late.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct bounds clamp; 7 lines; no API change. new_rows == 0 yields new_rows - 1 == -1, then logo_lines <= 0 bails out. Regression risk is low: at worst the penguin is skipped on tiny/odd geometries instead of walking off the buffer. A 2025 RFC (Wang ShaoBo) described a related cols-mismatch after vc_resize(); this clamp does not fully cover that variant, but it does not worsen it, and syzbot named this commit as the fix for the 1873-crash report.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: The OOB walk (q - logo_lines * cols / scr_readw loop) is from **^1da177e4c3f41** (v2.6.12 era). logo_lines = DIV_ROUND_UP(...) is from **416e74ea781359** (Julia Lawall, 2008). This is long-standing code, not a recent 6.12-only bug.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The buggy pattern has been in the function for ~20 years. 6104c37094e7 ("fbcon: Make fbcon a built-time dependency for fbdev", 2017) is in this tree (merge-base --is-ancestor exit 0); Wang’s RFC cited it, but that is a different proposed patch.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Related but distinct history in this tree: a6a00d7e8ffd7 / 5c38052680f56 (kzalloc KMSAN false-positive, reverted); 250038f5a7207 (2007 vertical overflow when making space for the logo — different hunk). No prior clamp of logo_lines to rows/new_rows. Standalone, not patch N/M.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Helge Deller is FRAMEBUFFER LAYER maintainer (MAINTAINERS). He authors/applies fbdev fixes regularly in this tree.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Uses existing logo_lines, rows, new_rows, logo_shown, FBCON_LOGO_DONTSHOW. No new helpers. git apply --check succeeded (hunk at line 596, offset −64). Standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record: b4 dig -c 94e6a058b168 →
https://patch.msgid.link/[email protected]
(syzbot-forwarded #syz test from [email protected], 2026-08-22). b4 dig -a: v1 only. lore.kernel.org returned 403; openwall mirror confirms the same single-hunk patch. No NAK found. Applied two days later by Deller (commit date 2026-08-24).
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: b4 dig -w: recipients were syzbot and linux- [email protected] only. No public Reviewed-by. Weight comes from the maintainer applying it, not from a review thread.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: https://syzkaller.appspot.com/bug?extid=0c815b25cdb3678e7083
- Status: upstream, C repro, **prio:high**, **1873 crashes**, first 2025-02-25
- Fix commit listed: **94e6a058b168**
- Patched on 20/29 syzbot instances
- Stack: store_bind → vt_bind → do_bind_con_driver → visual_init → fbcon_init → fbcon_prepare_logo → scr_memcpyw
- Same title also on linux-5.15.y (C repro), linux-6.1.y, linux-6.6.y
- Syzbot security assessment: DenialOfService yes, Exploitable yes, Unprivileged no (sysfs bind is S_IWUSR)
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Not a series. Related RFC 2025-09-25 from Wang ShaoBo added a pointer-vs-vc_origin guard in the scroll loop; it was not applied in this tree or in the candidate’s parent. Older kzalloc change is unrelated (reverted KMSAN false positive).
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable 403. No evidence this 2026-08-24 commit was already discussed for 6.12.y. The same KASAN title is already reproduced on older stable CIs, which supports that 6.12 is affected.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: fbcon_prepare_logo() only. Semcode MCP not available.
**Step 5.2: TRACE CALLERS**
Record: Two call sites in this tree:
1. con2fb_init_display() (line 826) — console mapped to a framebuffer, show_logo.
2. fbcon_init() (line 1155) — after setting/resizing the VC, if logo is set.
fbcon_init is con_init for fbcon, called from visual_init() during bind/takeover. store_bind is the syzbot trigger (root sysfs write). Also runs on normal fbcon takeover at boot when the logo is enabled (!MODULE).
**Step 5.3: TRACE CALLEES**
Record: fb_prepare_logo(), scr_readw/scr_memcpyw/scr_memsetw, kmalloc/kfree, update_screen. The new code only uses min() and existing logo_shown.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace (root) → sysfs vtconN/bind → fbcon_init → fbcon_prepare_logo. Also boot-time logo on CONFIG_FRAMEBUFFER_CONSOLE && !MODULE. Path is real and reproduced.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: The too-late logo_lines > vc->vc_bottom check is the same bug class, just after the OOB. No sibling drivers copy this logo-scroll logic.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. drivers/video/fbdev/core/fbcon.c lines 597–604 compute logo_lines and walk q - logo_lines * cols with no clamp. git merge- base --is-ancestor 94e6a058b168 HEAD is **false** — the fix is not in 6.12.111. Bug introduced long before 6.12.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: git apply --check **clean** (offset −64 from surrounding-line drift / fbcon_ops→fbcon_par rename already in this tree). Expected
difficulty: **clean apply**.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No logo_lines = min(...) in this file. The 2007 Geert overflow tweak and the kzalloc revert do not clamp logo lines.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **fbcon** (drivers/video/fbdev/core/fbcon.c), the framebuffer console used with CONFIG_FRAMEBUFFER_CONSOLE (default follows DRM_FBDEV_EMULATION). Criticality: **IMPORTANT** — not mm/core, but default console path on many DRM/fbdev systems.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature; still receiving OOB/NULL/font fixes in this tree (51b8258efe254, b5bb2c696e140, ac970358c5ca0). Not staging.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Users with framebuffer console (typical desktop/embedded DRM fbdev emulation, vkms/syzbot, classic fbdev). Config-specific (FRAMEBUFFER_CONSOLE), not universal.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: (1) Console bind/takeover with a logo taller than the text grid after integer rounding; (2) syzbot C repro via vtcon bind. Common on fuzzing and on small/rotated/odd modes. Unprivileged users cannot write bind (S_IWUSR); boot-time logo does not need that.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: KASAN slab-out-of-bounds **read** (and related UAF/KFENCE reports). Can oops under KASAN/KFENCE; without sanitizers it is still an invalid buffer walk. Severity: **HIGH** (memory-safety crash; syzbot marked exploitable but not unprivileged).
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record: Benefit **high** (stops a reproducible KASAN OOB in a common console path). Risk **very low** (7-line clamp, early return already used elsewhere in the same function). Ratio strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real, syzbot-reproduced KASAN OOB with C repro, 1873 crashes, prio:high
- Same bug title on 5.15.y / 6.1.y / 6.6.y — this 6.12 tree still has the unclamped walk
- Syzbot lists 94e6a058b168 as the fix commit
- Maintainer-authored, 7 lines, applies cleanly here
- Fixes a rounding hole (DIV_ROUND_UP vs yres / font_height) plus any logo taller than the VC
- No new API/feature; existing FBCON_LOGO_DONTSHOW path
AGAINST:
- Short commit message, no public review, no Fixes:
- Does not fully address the Wang RFC cols-mismatch-after-resize case
- Trigger via sysfs bind is root-only (boot logo path still matters)
UNRESOLVED:
- Could not read lore.kernel.org (403); used b4 + openwall instead
- Could not confirm whether post-fix syzbot “last: 2d” crashes are only on the 9 unpatched instances (likely, given 20/29 patched)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — clamp is local and readable; syzbot C repro; maintainer applied it
2. Fixes a real bug that affects users? **PASS** — KASAN OOB, thousands of syzbot hits, stable-tree crashes
3. Important issue (crash, security, corruption, deadlock)? **PASS** — HIGH memory-safety OOB
4. Small and contained? **PASS** — +7 lines, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — buggy code present; git apply --check clean
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/docs exception. It is a normal memory- safety bug fix.
**Step 9.4: MAKE YOUR DECISION**
This is a small, correct bounds check for a long-standing fbcon OOB that syzbot can hit on this class of kernels. It belongs in 6.12.y.
Verification:
- [Phase 1] Parsed tags: syzbot Reported-by; Helge Deller SOB; no Fixes/Cc:stable/review tags in the committed message
- [Phase 2] Diff: +7 lines in fbcon_prepare_logo() after DIV_ROUND_UP; clamp logo_lines then early return
- [Phase 3] git describe HEAD / Makefile: **6.12.111**, branch pending-6.12
- [Phase 3] git blame: OOB loop from ^1da177e4c3f41; DIV_ROUND_UP from 416e74ea781359 (2008)
- [Phase 3] git merge-base --is-ancestor 94e6a058b168 HEAD → not an ancestor (fix absent here)
- [Phase 3] git apply --check of 94e6a058b168 → clean, offset −64
- [Phase 3] Confirmed no logo_lines = min already in this file
- [Phase 4] b4 dig -c 94e6a058b168 → msgid [email protected]; v1 only
- [Phase 4] Syzbot extid 0c815b25cdb3678e7083: C repro, prio:high, 1873 crashes, Fix commit 94e6a058b168
- [Phase 4] Same KASAN title on linux-5.15.y / 6.1.y / 6.6.y
- [Phase 5] Callers: fbcon_init (line 1155), con2fb_init_display (line 826); bind path store_bind is S_IWUSR
- [Phase 6] Local function still matches the pre-patch walk at lines 597–604
- [Phase 7] Helge Deller listed as FRAMEBUFFER LAYER maintainer
- [Phase 8] Failure mode: slab-out-of-bounds read in scr_memcpyw/scr_readw; severity HIGH
- UNVERIFIED: full lore.kernel.org thread (HTTP 403); whether every post-Aug-24 syzbot crash is on unpatched instances only
The patch is a 7-line clamp in fbcon_prepare_logo() that stops a syzbot-reproduced KASAN out-of-bounds read. The buggy walk is in this 6.12 tree, the fix applies cleanly, and the risk is limited to skipping the boot logo when it cannot fit.
**YES**
drivers/video/fbdev/core/fbcon.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/video/fbdev/core/fbcon.c +7 -0
@@ -600,6 +600,13 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info, erase &= ~0x400 ; logo_height =fb_prepare_logo (info, par->rotate); logo_lines =DIV_ROUND_UP (logo_height, vc->vc_font.height); + logo_lines =min (logo_lines, rows); + logo_lines =min (logo_lines, new_rows -1 ); +if (logo_lines <=0 ) { + logo_lines =0 ; + logo_shown =FBCON_LOGO_DONTSHOW ; +return ; + } q = (unsigned short *) (vc->vc_origin + vc->vc_size_row * rows); step = logo_lines * cols;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 pinctrl: sx150x: add missing MODULE_DEVICE_TABLE()
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit 5fe4b12c087db3e565f53b87f1dafdf2f0d1ee0f ]
The driver has a match table for the i2c bus wired into its driver structure, but the table is not exported with MODULE_DEVICE_TABLE().
Add the missing MODULE_DEVICE_TABLE() entry so module alias information is generated for automatic module loading.
This is a source-level fix. It does not claim dynamic hardware reproduction; the evidence is the driver-owned match table, its use by the driver registration structure, and the missing module alias publication.
---
LLM Generated explanations, may be completely bogus:
I have enough to judge this: a one-line I2C alias export on a driver that is modular in this tree, with OF autoload already working.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[pinctrl/sx150x] [add] [export the existing I2C match table via MODULE_DEVICE_TABLE() so module aliases are generated]**
- Subsystem prefix: pinctrl: sx150x:
- Action verb: **add**
- Claimed intent: publish missing I2C module aliases for automatic loading
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Commit: 5fe4b12c087db3e565f53b87f1dafdf2f0d1ee0f
Record:
- **Fixes:** none (expected)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** none
- **Acked-by:** none
- **Link:** none in the git commit (lore exists; see Phase 4)
- **Cc: stable:** none (expected)
- **Signed-off-by:** Pengpeng Hou <[email protected]> (author); Linus Walleij <[email protected]> (pinctrl maintainer)
- Ignored pipeline markers: none present on this commit
Notable pattern: no user/syzbot report; maintainer SOB only.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** sx150x_id[] is wired as sx150x_driver.id_table but not exported with MODULE_DEVICE_TABLE(i2c, ...).
- **Symptom:** depmod/udev never get i2c:sx1501q … i2c:sx1509q aliases, so the module does not autoload for I2C-name instantiation.
- **Version info:** none in the message.
- **Root cause (author):** match table is used at registration but not published for file2alias / modules.alias.
- Author states this is a **source-level** finding with **no hardware reproduction**.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not a disguised cleanup.** It is an explicit autoload/metadata fix. The “source-level” wording means the author inferred the bug from the missing macro, not from a crash.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/pinctrl/pinctrl-sx150x.c — **+1 / −0**
- Function/data: none; one statement after sx150x_id[]
- Scope: **single-file surgical fix**
```850:856:drivers/pinctrl/pinctrl-sx150x.c
{ .name = "sx1509q", .driver_data =
(kernel_ulong_t)&sx1509q_device_data },
{ }
};
MODULE_DEVICE_TABLE(i2c, sx150x_id);
```**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** OF table already had MODULE_DEVICE_TABLE(of, sx150x_of_match). I2C table was registered via .id_table but not aliased.
- **After:** scripts/mod/file2alias.c do_i2c_entry() emits i2c:<name> aliases (I2C_MODULE_PREFIX is "i2c:").
- Path affected: **module build / depmod / udev autoload**, not probe/runtime logic.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** hardware enablement / module autoload (same family as device-ID publication)
- **Mechanism:** without MODULE_DEVICE_TABLE(i2c, sx150x_id), file2alias never sees the I2C table. DT devices still autoload via OF aliases (i2c_device_uevent() prefers of_device_uevent_modalias()). Non-DT instantiation (new_device, i2c-USB, board info) emits MODALIAS=i2c:<name> and would fail to autoload.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: matches Documentation/i2c/writing-clients.rst.
- Minimal: one line, no API/locking/data-structure change.
- Regression risk: **very low** (modinfo aliases only; no runtime path change).
- Red flags: none.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- sx150x_id[] introduced in 9e80f9064e73f (**2016**, v4.10-era):
“pinctrl: Add SX150X GPIO Extender Pinctrl Driver”. That commit **removed** MODULE_DEVICE_TABLE because the driver was bool (citing gpio-sx150x module.h cleanup).
- I2C MODULE_DEVICE_TABLE added only by this commit (5fe4b12c087db, 2026-07-10).
- Modularization: fe2e8f17a56fe (2025-08-19) made PINCTRL_SX150X **tristate** and added **only** MODULE_DEVICE_TABLE(of, ...).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Buggy omission is from fe2e8f17a56fe (incomplete modularization), not from a tagged regression. fe2e8f17a56fe is an ancestor of this HEAD.
**Step 3.3: CHECK FILE HISTORY**
Record:
- Related: fe2e8f17a56fe (tristate + OF aliases); dbbb19b8e412f (allow depends on I2C so it can be =m when I2C is a module, landed later in 7.3).
- Standalone one-liner; not patch X/Y.
- Prerequisite for *meaning*: driver must be buildable as a module (fe2e8f17a56fe). That is in this tree.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Pengpeng Hou is **not** the pinctrl maintainer. Large sweep of “add missing MODULE_DEVICE_TABLE()” across rtc/vdpa/watchdog/clk/soc/etc. This is a systematic metadata sweep, applied here by Linus Walleij.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: No new helpers. Applies anywhere sx150x_id[] exists (since 2016). Standalone. User-visible only when PINCTRL_SX150X=m.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **Lore:**
https://patch.msgid.link/[email protected]
- **Revisions:** v1 only (b4 dig -a)
- Thread (mbox via b4 dig -m): submission + Linus Walleij **“Patch applied!”**
- No NAK, no review changes, **no Cc: stable** from author or maintainer
- WebFetch of lore.kernel.org returned **403**; discussion read from the saved mbox instead
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To Linus Walleij; Cc linux-gpio, linux-kernel. Maintainer applied it. No other reviewers.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: **No bugzilla/syzbot/user report.** Author: source-level only.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone v1. Same author has many sibling MODULE_DEVICE_TABLE patches; none are prerequisites for this hunk.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** on lore.kernel.org/stable (HTTP 403). No `Cc:
stable` in commit or mbox.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
Record: No functions changed. Touches sx150x_id[] publication.
Related: sx150x_driver, sx150x_init() → i2c_add_driver().
**Step 5.2: TRACE CALLERS**
Record:
- sx150x_init() is subsys_initcall / module init; only caller of i2c_add_driver(&sx150x_driver).
- sx150x_probe() is the I2C probe (line 1123). Bound via OF match or id_table.
- Not IRQ/hot-path; device enumeration / module autoload.
**Step 5.3: TRACE CALLEES**
Record: MODULE_DEVICE_TABLE is a build-time alias for file2alias. No allocations, locks, or I/O.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record:
- DT boards (qcs615-ride, imx8mp-aristainetos3, kirkwood-l-50, vf610-zii, at91-natte, …): uevent uses **OF** modalias; already covered.
- Non-DT: i2c_device_uevent() falls through to MODALIAS=i2c:<client->name>. Original 2016 commit tested **x86_64 I2C-USB** as well as BeagleBone DT — that path needs I2C aliases.
- Userspace new_device can also trigger it.
- Reachable: yes, from device enumeration / sysfs, not a syscall crash path.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same missing-macro pattern across many drivers in this cycle. OF table in this file already had the macro; I2C table was the gap.
semcode MCP: **not available**; used git/grep/read.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record:
- Local tree: **v7.3-rc4-27-gf0100363d8c37**, make kernelversion = **7.3.0-rc4**, detached HEAD on mainline.
- Driver file present; Kconfig is tristate; both MODULE_DEVICE_TABLE lines present **because this commit is already in HEAD**.
- Bug existed in this lineage from fe2e8f17a56fe (in v6.18) until 5fe4b12c087db (first in **v7.3-rc1**).
- git merge-base --is-ancestor 5fe4b12c087db HEAD → **yes**.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** Single line after sx150x_id[]. Pre-fix parent still has the table and OF MODULE_DEVICE_TABLE. Context around named initializers (84c0fe4a2085f) does not affect the added line.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: OF aliases already added by fe2e8f17a56fe. No other I2C alias fix. This is the remaining hole, not a duplicate.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: **pinctrl / I2C GPIO expander driver** (drivers/pinctrl/pinctrl-sx150x.c). Criticality: **PERIPHERAL** (specific Semtech SX150x chips on a handful of boards). Not mm/fs/net core.
**Step 7.2: SUBSYSTEM ACTIVITY**
Record: pinctrl is actively developed (frequent 7.3 merges). This driver is mature (2016); the modularization is recent (6.18).
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Record: **Driver-specific / config-specific:** CONFIG_PINCTRL_SX150X=m, and instantiation **without** a working OF (or ACPI) modalias — I2C name match. DT users already autoload via OF.
**Step 8.2: TRIGGER CONDITIONS**
Record:
- Trigger: module not loaded; I2C client named sx1501q…sx1509q appears (sysfs new_device, non-DT board, I2C-USB).
- Commonness: **low** on in-tree DT boards; **real** for the non-OF path the driver was written to support.
- Unprivileged trigger: no (needs device creation / root sysfs).
**Step 8.3: FAILURE MODE SEVERITY**
Record:
- Failure: GPIO/pinctrl expander **does not bind** until manual modprobe. No oops, deadlock, or corruption.
- Severity: **MEDIUM** for affected modular non-DT users; **LOW** for typical DT boards.
- Not CRITICAL.
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit:** modest — restores I2C autoload for a modular driver that documents non-OF use.
- **Risk:** very low — one compile-time alias line.
- **Ratio:** favorable. Same class as publishing device IDs.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR backporting:**
- Real autoload bug once the driver is a module (this tree: tristate).
- One line, obviously correct, maintainer-applied.
- Zero runtime regression risk.
- Same user-visible class as device-ID additions (module aliases).
- I2C id_table is actually used (.id_table = sx150x_id); OF aliases do not cover the i2c: modalias path.
- Original driver was tested on non-OF x86 I2C-USB.
**AGAINST:**
- Not a crash/UAF/security/corruption/deadlock issue.
- No user report; author says source-level only.
- DT autoload already works via OF MODULE_DEVICE_TABLE.
- Peripheral expander, small user set.
- Automated MODULE_DEVICE_TABLE sweep, not a targeted production incident.
**UNRESOLVED:**
- Whether stable@ already discussed this (lore 403).
- How many distros set PINCTRL_SX150X=m vs =y.
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — correct by construction; maintainer applied. Hardware test not claimed.
2. Fixes a real bug that affects users? **PASS** — missing I2C aliases prevent autoload for non-DT / i2c: modalias.
3. Important issue? **PASS** (as device-ID / enablement, not as crash).
User-visible: device never probes until manual modprobe. Stable text allows “add a device ID”; this publishes existing IDs.
4. Small and contained? **PASS** — +1 line, one file.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — applies cleanly; this checkout already contains the equivalent change.
**Step 9.3: EXCEPTION CATEGORIES**
Record: **Device ID / module alias publication** (not a new driver). Closest exception: adding/exporting IDs on an existing driver so hardware binds automatically.
**Step 9.4: DECISION**
This tree is **7.3-rc4 mainline**, where PINCTRL_SX150X is tristate and the I2C table is live. The patch does not change runtime logic; it only emits the aliases file2alias needs for i2c:sx150*q. That is a real, contained autoload fix with essentially no regression risk. DT boards already worked; the I2C table still matters for the non-OF path this driver has supported since 2016.
It meets stable rules as a small, obviously correct hardware-binding fix, not as a crash fix.
---
### What the commit solves (for this tree)
When built as a module, udev/modprobe cannot match MODALIAS=i2c:sx1509q (and siblings) because those aliases were never generated. Probe itself was fine if the module was loaded by hand or via OF. The one-line MODULE_DEVICE_TABLE(i2c, sx150x_id) closes that gap.
### Risk vs benefit
Benefit is autoload for modular, non-DT (or sysfs-instantiated) SX150x users. Risk is negligible. That trade-off is acceptable for stable.
### Concerns
No Fixes:/Cc: stable (not a negative by itself). Impact is not a panic. Prerequisite modularization is already in this lineage. No backport rework needed.
---
### Verification
- **[Phase 1]** Parsed 5fe4b12c087db: subject/body/SOBs; no Fixes/Reported-by/stable Cc
- **[Phase 2]** Diff: +1 MODULE_DEVICE_TABLE(i2c, sx150x_id) in pinctrl-sx150x.c
- **[Phase 2]** Confirmed OF table already has MODULE_DEVICE_TABLE(of, sx150x_of_match) (line 870)
- **[Phase 2]** Confirmed .id_table = sx150x_id (line 1281)
- **[Phase 3]** git blame: table from 9e80f9064e73f (2016); OF macro from fe2e8f17a56fe; I2C macro from this commit
- **[Phase 3]** git show fe2e8f17a56fe: tristate + OF MODULE_DEVICE_TABLE + MODULE_LICENSE; I2C table omitted
- **[Phase 3]** git log --author=Pengpeng Hou: many sibling MODULE_DEVICE_TABLE commits
- **[Phase 4]** b4 dig -c 5fe4b12c087db: lore msgid [email protected]
- **[Phase 4]** b4 dig -a: v1 only
- **[Phase 4]** b4 dig -w: Linus Walleij + linux-gpio
- **[Phase 4]** mbox: “Patch applied!”; no NAK; no stable nomination
- **[Phase 4]** WebFetch lore/stable: **403 UNVERIFIED**
- **[Phase 5]** i2c_device_uevent: OF, then ACPI, then i2c: name (drivers/i2c/i2c-core-base.c:163-176)
- **[Phase 5]** do_i2c_entry emits i2c:%s (scripts/mod/file2alias.c:855-860)
- **[Phase 5]** In-tree DTS uses semtech,sx150xq compatibles
- **[Phase 5]** No ACPI table in this driver
- **[Phase 6]** git describe HEAD = v7.3-rc4-27-gf0100363d8c37; kernelversion 7.3.0-rc4
- **[Phase 6]** git merge-base --is-ancestor 5fe4b12c087db HEAD → yes
- **[Phase 6]** Tags: fix first in v7.3-rc1; tristate in v6.18; missing in v7.2
- **[Phase 6]** Kconfig in this tree: tristate depends on I2C
- **[Phase 8]** Failure mode: module not autoloaded; severity MEDIUM/LOW, not crash
- **UNVERIFIED:** stable@ archive discussion; distro =m vs =y prevalence
- **UNVERIFIED:** semcode MCP not present
The fix is small, surgical, and meets stable criteria as module-alias / device-ID enablement.
**YES**
drivers/pinctrl/pinctrl-sx150x.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/pinctrl-sx150x.c +1 -0
@@ -850,6 +850,7 @@ static const struct i2c_device_id sx150x_id[] = { {"sx1509q", (kernel_ulong_t) &sx1509q_device_data }, {} }; +MODULE_DEVICE_TABLE (i2c, sx150x_id);static const struct of_device_id sx150x_of_match[] = { { .compatible = "semtech,sx1501q", .data = &sx1501q_device_data },
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 rtc: brcmstb-waketimer: add missing MODULE_DEVICE_TABLE()
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit 402c89d28fecd28652a4bfe997f08f6544836381 ]
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 **6.12.111** (pending-6.12). The one-line OF alias publication is missing here, the match table is present, and the original mailed hunk applies cleanly.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[rtc / brcmstb-waketimer] [add] [publish missing OF MODULE_DEVICE_TABLE so the module can autoload]**
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- **Link:**
https://patch.msgid.link/[email protected]
- **Signed-off-by:** Pengpeng Hou (author)
- **Signed-off-by:** Alexandre Belloni (RTC maintainer; applied)
- **No Fixes:** (expected for this review)
- **No Cc: stable** (expected)
- **No Reported-by / Tested-by / Reviewed-by / Acked-by / syzbot**
- Pipeline markers ([Upstream commit ...], Sasha Levin SOB) ignored per instructions
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** OF match table is wired to .of_match_table but not exported with MODULE_DEVICE_TABLE(), so modpost never emits of:N*T*Cbrcm,brcmstb-waketimer aliases.
- **Symptom:** When CONFIG_RTC_DRV_BRCMSTB=m, udev/kmod cannot autoload rtc-brcmstb-waketimer.ko from the DT compatible string. The wake-timer/RTC does not bind unless the module is loaded by hand.
- **Version info:** none in the message. Driver has been in tree since v4.13.
- **Root cause (author):** missing module-alias publication, evidenced by the driver-owned table and its use by the platform driver. Explicitly a source-level finding, not a live hardware repro.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: **Not disguised.** It is a real autoload bug, same class as adding/publishing a device ID. Not style-only.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- **File:** drivers/rtc/rtc-brcmstb-waketimer.c (+1 / −0)
- **Function/site:** after brcmstb_waketmr_of_match[] (not inside a function)
- **Scope:** single-file, one-line surgical change
- **Upstream SHA (verified):** 402c89d28fecd28652a4bfe997f08f6544836381
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- **Before:** table exists and is assigned to .of_match_table via of_match_ptr(). Built-in matching still works. Modular autoload does not, because file2alias never sees the table.
- **After:** MODULE_DEVICE_TABLE(of, brcmstb_waketmr_of_match) creates __mod_of__brcmstb_waketmr_of_match_device_table as an alias when MODULE is set (include/linux/module.h). scripts/mod/file2alias.c do_of_entry_multi() then emits MODULE_ALIAS("of:N*T*Cbrcm,brcmstb- waketimer").
- **Path affected:** module install / depmod / udev autoload only. Probe, PM, and built-in bind paths are unchanged. When !MODULE, the macro is empty.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record: **[Hardware enablement / missing device ID publication]**
- Category (h): OF alias not published, so modular bind fails.
- Not UAF, leak, race, NULL deref, or crash.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- **Quality:** obviously correct; this is the standard pattern (dozens of RTC drivers already have MODULE_DEVICE_TABLE(of, ...) in this tree).
- **Regression risk:** very low. Compile-time alias only. __maybe_unused on the table remains valid: built-in + !CONFIG_OF still has no C reference; as a module the alias references the table, which is intended.
- **No API, locking, or data-structure changes.**
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Match table and .of_match_table introduced in **c4f07ecee22ec7** (“rtc: brcmstb-waketimer: Add Broadcom STB wake-timer”, Brian Norris, 2017) — first appears **v4.13-rc1**. Present in this tree (git merge- base --is-ancestor succeeded).
- __maybe_unused added in **ae1247f79ddf8** (v5.12 era) for !CONFIG_OF compile-test. That did not add MODULE_DEVICE_TABLE.
- Bug has been present for the entire life of the driver.
Step 3.2: FOLLOW THE FIXES: TAG
Record: **No Fixes: tag.** The introducing commit is c4f07ecee22ec7, which is in this tree. No later intermediate autoload fix on this file.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record (this tree, path-limited):
- e005a9b35b464 level alarm_irq
- d64906b320ce6 .remove → .remove_new
- 24304a87158aa non-wake alarm
- None of these publish OF aliases.
- **Standalone** one-line patch; not “X/Y” of a series that this file depends on. Parent of upstream 402c89d28fec is a sibling RTC autoload fix (rtc: s32g), not a prerequisite for this driver.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Pengpeng Hou is not the RTC maintainer. In this tree the only other drivers/rtc/ commit from that author is unrelated (`rtc: zynqmp:
Return optional clock lookup errors`). Alexandre Belloni (RTC maintainer) applied the patch. Florian Fainelli / Broadcom were on To/Cc.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: **None.** Needs only MODULE_DEVICE_TABLE and the existing of_device_id table, both present since the driver was added. **Can apply standalone.**
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- **b4 dig -c 402c89d28fec:**
https://patch.msgid.link/[email protected]
- **b4 dig -a:** single **v1**, 2026-07-04; no v2/v3.
- Thread (3 messages): original patch; Sashiko bot “no issues”; Alexandre Belloni **“Applied, thanks!”** pointing at https://git.kernel.org/abelloni/c/402c89d28fec.
- **No NAK, no stable nomination, no reviewer risk flags.** WebFetch to lore returned 403; thread recovered via b4 mbox.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To/Cc included Alexandre Belloni (RTC maintainer), Florian Fainelli, bcm-kernel-feedback-list, linux-rtc, linux-arm-kernel, linux-kernel. Maintainer applied it. No human Reviewed-by.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: **No user/syzbot/bugzilla report.** Author states it is source- level. Severity from reporters: N/A. Users affected: anyone building this driver as a module on DT platforms with brcm,brcmstb-waketimer.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Wave of the same one-line OF-alias pattern. This 6.12 tree already contains:
- 330fdd1fb7d09 drm/tve200: add OF module alias for autoloading
- 2260191fbf7c6 crypto: keembay - publish OF module alias for OCS AES/SM4
Those are the same bug class, already accepted here. This brcmstb patch does not depend on them.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable search via WebFetch returned 403. **UNVERIFIED** whether this exact patch was discussed on stable@. No local evidence it was rejected.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: **No function body changed.** Site is brcmstb_waketmr_of_match / brcmstb_waketmr_driver. Related runtime function:brcmstb_waketmr_probe.
Step 5.2: TRACE CALLERS
Record: brcmstb_waketmr_probe is only referenced as .probe on brcmstb_waketmr_driver, registered via module_platform_driver(). Called from platform/OF device bind (kernel boot or module load), not from a syscall directly. Userspace trigger is: DT node present + module autoload (or manual modprobe).
Step 5.3: TRACE CALLEES
Record: Probe ioremaps, allocates an RTC device, requests IRQs, device_init_wakeup(). The new line calls nothing at runtime.
Step 5.4: FOLLOW THE CALL CHAIN
Record: DT compatible = "brcm,brcmstb-waketimer" (in-tree on several BMIPS boards, e.g. arch/mips/boot/dts/brcm/bcm7435.dtsi) → OF match → probe. **Reachable on real STB hardware.** Autoload is the broken hop when =m.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Many RTC drivers already export OF tables (rtc-zynqmp.c, rtc- mt7622.c, …). Historical RTC fixes of the same kind: 206e04ec7539e (mxc_v2), 3fc990a5dbfff (mt7622). Systematic missing-alias class, not a one-off.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: **Yes.** drivers/rtc/rtc-brcmstb-waketimer.c:413-424 has the table and .of_match_table and **no** MODULE_DEVICE_TABLE. git merge-base --is-ancestor 402c89d28fec HEAD failed (fix not here). Introduced v4.13, long before 6.12.
Kconfig in this tree (drivers/rtc/Kconfig):
```
config RTC_DRV_BRCMSTB
tristate "Broadcom STB wake-timer"
depends on ARCH_BRCMSTB || BMIPS_GENERIC || COMPILE_TEST
default ARCH_BRCMSTB || BMIPS_GENERIC
```Explicitly modular. Default y on the SoCs that have the IP, so the common defconfig path is built-in; =m is still a supported and documented config.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **Clean apply.** Original mailed hunk (3 lines of context through .probe) — git apply --check **rc 0** on this tree. .remove vs .remove_new is later in the struct and is not in the original hunk. No rework needed.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: **No** commit on this file adds MODULE_DEVICE_TABLE. Sibling OF-alias backports exist for other drivers (tve200, keembay), not a substitute for this one.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: **[drivers/rtc — Broadcom STB wake-timer] [PERIPHERAL]** for most 6.12 users; **IMPORTANT** on BCM7xxx set-top boxes (alarm/S2/S3/S5 wake). Not mm/net/block core.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Driver is mature (2017). Recent local commits are PM/IRQ and platform-remove conversion, not a rewrite. Low churn around the match table.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: **Driver-specific / config-specific.** Users of Broadcom STB wake-timer with CONFIG_RTC_DRV_BRCMSTB=m. In-tree DT nodes are on BMIPS boards (bcm7346/7358/7360/7362/7425/7435). ARCH_BRCMSTB also exists on ARM and arm64; this tree’s ARM/arm64 dtsi files do not contain the compatible string (vendor DTs may). Built-in (=y, the Kconfig default on those arches) is unaffected.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record:
- Trigger: modular driver + OF device present + reliance on autoload (normal distro/udev path).
- Commonness: uncommon vs default =y; real whenever someone chooses =m (help text documents that).
- Unprivileged userspace cannot exploit this; it is bind/enablement, not a crash primitive.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: **[RTC/wake-timer never binds when built as a module] [MEDIUM]**
- Not oops/deadlock/corruption/CVE.
- On affected boxes, RTC alarm and suspend wake from this block can fail to be available until a manual modprobe.
- Fits stable-rules “device ID” / “oh, that’s not good” more than “oops”.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit:** medium for modular STB configs (hardware actually gets its driver); low for default =y defconfigs.
- **Risk:** very low (1 line, modpost alias, no runtime behavior change for built-in).
- **Ratio:** favorable. Same class already merged in this 6.12.y tree.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
**FOR:**
- Real autoload bug: OF table used, aliases never generated.
- One line, obviously correct, maintainer-applied.
- Driver and buggy code exist in 6.12.111 since v4.13.
- Original patch applies cleanly here.
- Device-ID / hardware-enablement exception; wake-timer matters for STB suspend/resume.
- Identical OF-alias one-liners already in this tree (tve200, keembay).
- Zero runtime regression path for the default built-in config.
**AGAINST:**
- Not a crash, UAF, deadlock, or security hole.
- No user report; source-level scan.
- Kconfig default is built-in on the SoCs that have the hardware, so many production images never hit autoload.
- Peripheral driver, not core.
**UNRESOLVED:**
- Whether this SHA was already discussed on stable@ (lore 403).
- Whether vendor ARM/arm64 brcmstb DTs (not in this tree) also use this compatible.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — standard macro; RTC maintainer applied v1 with no objections.
2. Fixes a real bug that affects users? **PASS** — modular OF autoload does not work; Kconfig allows =m.
3. Important issue? **PASS** (device-ID / hardware-enablement class; functional miss for modular STB RTC/wake). Severity MEDIUM, not CRITICAL.
4. Small and contained? **PASS** — +1 line, one file.
5. No new features or APIs? **PASS** — publishes an alias for an existing match table.
6. Can apply to the local tree? **PASS** — git apply --check succeeded; code present; no missing prereqs.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: **Device ID / OF module alias publication for an existing driver** (stable-rules: “or just add a device ID”). Closest match to the documented ID-addition exception.
Step 9.4: MAKE YOUR DECISION
Backport. The bug is in this tree, the fix is the usual one-line alias export, it applies cleanly, and it matches both the written device-ID exception and OF-alias fixes already on 6.12.y. Default-y only reduces how often it bites; it does not make the modular path fictional.
------------------------------------------------
What the commit solves for this tree
The 6.12 rtc-brcmstb-waketimer driver matches brcm,brcmstb-waketimer but never asks modpost to emit that alias. Built as a module, the wake- timer will not autoload. Adding MODULE_DEVICE_TABLE(of, ...) is the complete fix.
Risk vs benefit
Benefit is restoring bind on modular STB configs; risk is essentially nil. Context around .remove_new does not affect the original hunk.
------------------------------------------------
Verification:
- [Phase 1] Parsed tags: Link to msgid, SOB Pengpeng Hou + Alexandre Belloni; no Fixes/Cc stable/Reported-by
- [Phase 1] Body: missing OF alias; source-level, no hardware repro claimed
- [Phase 2] Diff: +1 line MODULE_DEVICE_TABLE(of, brcmstb_waketmr_of_match) after the match table
- [Phase 2] include/linux/module.h: macro is alias-for-modpost if MODULE, empty otherwise
- [Phase 2] scripts/mod/file2alias.c do_of_entry_multi(): emits of:N*T*C<compatible>
- [Phase 3] git blame: table from c4f07ecee22ec7 (v4.13-rc1); __maybe_unused from ae1247f79ddf8
- [Phase 3] git merge-base --is-ancestor c4f07ecee22ec HEAD: intro commit is in this tree
- [Phase 3] git merge-base --is-ancestor 402c89d28fec HEAD: fix is **not** in this tree
- [Phase 3] git show 402c89d28fec: confirmed same +1 line, author/date/message
- [Phase 3] git log --oneline -20 -- drivers/rtc/rtc-brcmstb- waketimer.c: no prior MODULE_DEVICE_TABLE on this file
- [Phase 4] b4 dig -c 402c89d28fec: lore URL + v1-only series
- [Phase 4] b4 dig -a: only v1, 2026-07-04
- [Phase 4] b4 dig -w: Belloni, Fainelli, bcm-kernel-feedback-list, linux-rtc CC’d
- [Phase 4] b4 mbox: Belloni “Applied, thanks!”; Sashiko no issues; no NAK
- [Phase 4] WebFetch lore: 403; used b4 instead
- [Phase 4] UNVERIFIED: stable@ thread for this exact subject
- [Phase 5] Probe only used as platform .probe; DT compatible present in arch/mips/boot/dts/brcm/*.dtsi
- [Phase 6] make kernelversion / Makefile: **6.12.111**; git describe HEAD: p-6.12-3-gc504cf0baa3d8
- [Phase 6] Local file lines 413–424: table present, MODULE_DEVICE_TABLE absent
- [Phase 6] git apply --check of original hunk: **success (rc 0)**
- [Phase 6] Same-class already in tree: 330fdd1fb7d09, 2260191fbf7c6
- [Phase 7] MAINTAINERS: RTC subsystem maintained by Alexandre Belloni
- [Phase 8] Kconfig tristate + default y on ARCH_BRCMSTB/BMIPS_GENERIC verified via blame
- [Phase 8] Failure mode: missing modular bind, not a crash
**YES**
drivers/rtc/rtc-brcmstb-waketimer.c | 1 + 1 file changed, 1 insertion(+)
drivers/rtc/rtc-brcmstb-waketimer.c +1 -0
@@ -413,6 +413,7 @@ static const __maybe_unused struct of_device_id brcmstb_waketmr_of_match[] = { { .compatible = "brcm,brcmstb-waketimer" }, { /* sentinel */ }, }; +MODULE_DEVICE_TABLE (of, brcmstb_waketmr_of_match);static struct platform_driver brcmstb_waketmr_driver = { .probe = brcmstb_waketmr_probe,
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] rtc: brcmstb-waketimer: add missing MODULE_DEVICE_TABLE()
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines
From: Pengpeng Hou <[email protected]>
[ Upstream commit
402c89d28fecd28652a4bfe997f08f6544836381]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.
Quoted 8 lines
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.
Signed-off-by Pengpeng Hou <[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 tpm: atmel: depend on X86
In reply to Sasha LevinFrom: Karl Mehltretter <[email protected]>
[ Upstream commit 4bfacee94f309346bef0b598ea091088b9150af9 ]
tpm_atmel probes for the chip at fixed x86 Super-I/O ports (0x4e) with inb()/outb(), so it only works on x86. TCG_ATMEL nevertheless depends only on HAS_IOPORT_MAP/HAS_IOPORT, which arm and arm64 also satisfy. There the probe is useless, and on platforms whose unbacked I/O access faults it oopses in init_atmel() at boot (e.g. arm/versatile):
Unable to handle kernel paging request at virtual address fee0004e PC is at init_atmel+0x34/0x244
TCG_NSC and TCG_TIS already "depends on X86" (commit 2f592f2a7d74 ("TPM:
NSC and TIS drivers X86 dependency fix")); TCG_ATMEL was missed. Add the same dependency.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
Record: [tpm / TCG_ATMEL] [depend] Restrict the Atmel TPM driver to x86 because it probes Super-I/O ports.
**Step 1.2 — Tags**
Record:
- Reviewed-by: Jarkko Sakkinen <[email protected]> (TPM maintainer)
- `Link: https://lore.kernel.org/r/20260712183234.23125-1-
[email protected]`
- Signed-off-by: Karl Mehltretter (author)
- Signed-off-by: Jarkko Sakkinen (maintainer)
- No Fixes:, no Reported-by:, no Cc: stable (absence is expected for this review)
- Ignore any pipeline Signed-off-by: Sasha Levin / [Upstream commit …] markers
**Step 1.3 — Body**
Record:
- Bug: tpm_atmel probes Super-I/O at 0x4e with inb()/outb(). Kconfig only required HAS_IOPORT_MAP/HAS_IOPORT, which ARM/arm64 also satisfy.
- Symptom: boot oops, Unable to handle kernel paging request at virtual address fee0004e, PC is at init_atmel+0x34/0x244 (example:
arm/versatile).
- Root cause: unbacked PCI I/O window access on non-x86.
- Same class of fix as 2f592f2a7d74 (TCG_NSC / TCG_TIS depends on X86); TCG_ATMEL was missed.
**Step 1.4 — Hidden bug fix?**
Record: Not hidden. Explicit crash fix via Kconfig dependency. Not cleanup or a new feature.
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
Record: One file, drivers/char/tpm/Kconfig. TCG_ATMEL: replace depends on HAS_IOPORT_MAP + depends on HAS_IOPORT with depends on X86. Scope: single-file, two-line Kconfig change.
**Step 2.2 — Code flow**
Record: Before: any arch with I/O-port mapping can build/enable tpm_atmel; init_atmel() always probes 0x4e. After: the driver is not built on non-x86. Affected path: module/builtin init, not a hot path.
**Step 2.3 — Bug mechanism**
Record: Kconfig/hardware-scope bug that produces a NULL/unmapped I/O dereference. On ARM, inb(0x4e) becomes a load at PCI_IO_VIRT_BASE+0x4e (0xfee0004e). If that page is not mapped, the kernel oopses.
**Step 2.4 — Fix quality**
Record: Obviously correct for the Super-I/O probe. Minimal. No runtime locking/API change. Regression risk is only over-restricting platforms that still have a working non-x86 path. That matters on **this** tree (see Phase 6): PPC64 OF support is still present, so the backport must be depends on X86 || PPC64, not bare depends on X86.
## Phase 3: Git history
**Step 3.1 — Blame**
Record: TCG_ATMEL dates to 1da177e4c3f41 (Linux 2.6.12-rc2). Local depends lines:
- depends on PPC64 || HAS_IOPORT_MAP — ce816fa88cca0 (2014; rename of HAS_IOPORT → HAS_IOPORT_MAP)
- depends on HAS_IOPORT — 6155153601183 (“char: tpm: handle HAS_IOPORT dependencies”, 2024; **in this tree**)
The Super-I/O probe in tpm_atmel.h (#else of CONFIG_PPC64) has been there for the life of the driver.
**Step 3.2 — Fixes: tag**
Record: None. Related historical commit 2f592f2a7d74 (2011, **in this tree**) added depends on X86 for NSC/TIS after PPC oopses; Atmel was not included.
**Step 3.3 — Related file history**
Record: 5578b4347bb5d (“tpm: atmel: Drop PPC64 specific MMIO setup”, 2024-11-22) is **not** an ancestor of this checkout (git merge-base --is-ancestor exit 1). It is an ancestor of the candidate. That commit changed Kconfig to depends on HAS_IOPORT_MAP only; the candidate then changed that to depends on X86.
**Step 3.4 — Author**
Record: Karl Mehltretter — this is the only Atmel TPM commit from that author on origin/master. Jarkko Sakkinen (TPM maintainer) reviewed and applied it.
**Step 3.5 — Prerequisites**
Record: The **verbatim** diff assumes PPC64 was already dropped. That drop is not in 6.12. The **semantic** fix does not need that drop: this tree can use depends on X86 || PPC64 and keep the existing OF path. Standalone with that one-line adaptation. Do not pull in 5578b4347bb5d (feature removal, ~140 lines).
## Phase 4: Mailing list / external
**Step 4.1 — Original discussion**
Record: b4 dig -c 4bfacee94f309 →
https://patch.msgid.link/[email protected]b4 dig -a: single revision (v1 only).
Thread (mbox): author patch + Jarkko Reviewed-by. No NAK, no stable debate, no risk flags.
**Step 4.2 — Recipients** (b4 dig -w)
Record: Jarkko Sakkinen, Peter Huewe, Jason Gunthorpe, linux- integrity, linux-kernel. Right maintainers/list.
**Step 4.3 — Bug report**
Record: No syzbot/bugzilla. Concrete oops in the commit message; PC and fault address match ARM inb(0x4e).
**Step 4.4 — Series**
Record: Standalone, not patch x/y.
**Step 4.5 — Stable list**
Record: No stable-specific thread found. lore.kernel.org HTTP fetch returned 403; discussion recovered via b4 dig -m. UNVERIFIED: whether anyone later nominated it on stable@.
## Phase 5: Semantic / call surface
**Step 5.1 — Functions**
Record: No C functions changed. Runtime path gated: init_atmel() → atmel_get_base_addr() → atmel_verify_tpm11() → tpm_read_index() → outb/inb at TPM_ADDR (0x4E in drivers/char/tpm/tpm.h).
**Step 5.2 — Callers**
Record: module_init(init_atmel) — builtin boot or modprobe tpm_atmel.
**Step 5.3 — Callees**
Record: Super-I/O index/data ports; no allocation/locking in the faulting probe.
**Step 5.4 — Reachability**
Record: Yes, if CONFIG_TCG_ATMEL=y/m. Not a syscall. User/config must enable an x86 Super-I/O TPM driver. arch/parisc/configs/generic-64bit_defconfig sets CONFIG_TCG_ATMEL=m. ARM allyesconfig/custom configs can set it =y and oops at boot.
**Step 5.5 — Similar patterns**
Record: TCG_NSC already depends on X86 in this tree. TCG_TIS is depends on X86 || OF here (OF added later; not Super-I/O).
## Phase 6: This checkout (6.12.y)
**Step 6.1 — Does the buggy code exist?**
Record: Yes.
- Tree: git describe → p-6.12-3-gc504cf0baa3d8, make kernelversion → **6.12.111**
- Candidate 4bfacee94f309 is **not** in HEAD
- Local Kconfig:
```164:171:drivers/char/tpm/Kconfig
config TCG_ATMEL
tristate "Atmel TPM Interface"
depends on PPC64 || HAS_IOPORT_MAP
depends on HAS_IOPORT
```- Non-PPC64 tpm_atmel.h still does Super-I/O inb/outb at TPM_ADDR.
- arch/arm/Kconfig select HAS_IOPORT. HAS_IOPORT_MAP defaults y unless NO_IOPORT_MAP. ARCH_VERSATILE does **not** select NO_IOPORT_MAP.
- ARM PCI_IO_VIRT_BASE is 0xfee00000; inb(0x4e) → 0xfee0004e, matching the oops.
**Step 6.2 — Backport difficulty**
Record: Exact hunk will not apply (this tree still has PPC64 || HAS_IOPORT_MAP). Trivial adaptation:
``` depends on X86 || PPC64 ```
Do **not** apply bare depends on X86; that would disable the still- present PPC64 OF path (CONFIG_PPC64 in tpm_atmel.h).
**Step 6.3 — Related fixes already here?**
Record: No other Atmel X86-dependency fix. 2f592f2a7d74 only covered NSC/TIS.
## Phase 7: Subsystem context
**Step 7.1**
Record: drivers/char/tpm — TPM. Criticality: **IMPORTANT** for TPM users; Atmel Super-I/O is a legacy path. Still a driver that can be built into generic/distro kernels.
**Step 7.2**
Record: TPM core is active (HMAC, new backends). tpm_atmel itself is mature/legacy.
## Phase 8: Impact and risk
**Step 8.1 — Who is affected**
Record: Config-specific: CONFIG_TCG_ATMEL on non-x86 (ARM/arm64 with PCI I/O, parisc defconfig, etc.). Not all 6.12 users.
**Step 8.2 — Trigger**
Record: Boot if builtin; module load if =m. Unprivileged users cannot trigger unless the module is loaded. Commonness: low on production ARM, high on allyesconfig / mistaken enablement. Author hit it on versatile.
**Step 8.3 — Failure mode**
Record: Kernel paging-request oops in init_atmel. Severity:
**CRITICAL** when the driver is enabled (boot crash if =y).
**Step 8.4 — Risk/benefit**
Record:
- Benefit: stops a real oops; Kconfig-only.
- Risk: very low if PPC64 is preserved; **high if applied verbatim** (would hide tpm_atmel on PPC64 while the OF code remains).
- Ratio: favorable **with** X86 || PPC64.
## Phase 9: Synthesis
**Evidence FOR**
- Documented boot oops; fault address verified against ARM inb().
- Same bug class already fixed for NSC/TIS in this tree.
- One-file Kconfig change; TPM maintainer Reviewed-by.
- Buggy probe is in this 6.12 tree.
- Fits “build/Kconfig dependency” stable exception; prevents a crash, adds no API.
**Evidence AGAINST**
- Verbatim patch does not apply; depends on PPC64-drop 5578b4347bb5d which is **not** in 6.12.
- TCG_ATMEL is not in ARM defconfigs; impact is config-selected.
- Bare depends on X86 would be a PPC64 regression on this tree.
**Unresolved**
- UNVERIFIED: whether any live PPC64 machine still uses AT97SC3201 via OF (Rob Herring later found no in-tree powerpc configs; that drop is still not in 6.12, so this backport should keep PPC64).
- UNVERIFIED: stable@ discussion (lore HTTP 403).
**Stable rules**
1. Obviously correct and tested? **PASS** (Kconfig restrict + maintainer review; oops matches code).
2. Real user-visible bug? **PASS** (boot oops).
3. Important (crash)? **PASS** when the option is enabled.
4. Small and contained? **PASS** (1–2 Kconfig lines).
5. No new features/APIs? **PASS**.
6. Apply to this tree? **PASS with backport** (depends on X86 || PPC64); **FAIL** if taken verbatim.
**Exception category:** Kconfig/build dependency fix that prevents a crash.
The 6.12 bug is real: TCG_ATMEL can still be enabled on ARM/arm64/parisc, and init_atmel() will touch 0x4e and oops on unbacked I/O. Restricting the symbol is the right stable fix. Use depends on X86 || PPC64 so the still-present PowerPC OF path is not dropped.
Verification:
- [Phase 1] Tags: Reviewed-by Jarkko; lore Link; no Fixes/Cc:stable
- [Phase 2] Diff: Kconfig only, HAS_IOPORT* → X86
- [Phase 3] git describe / make kernelversion: 6.12.111
- [Phase 3] git merge-base --is-ancestor 4bfacee94f309 HEAD: not in tree
- [Phase 3] git merge-base --is-ancestor 5578b4347bb5d HEAD: PPC64 drop not in tree
- [Phase 3] git merge-base --is-ancestor 2f592f2a7d74 HEAD: NSC/TIS X86 dep is in tree
- [Phase 3] git blame drivers/char/tpm/Kconfig: HAS_IOPORT added by 6155153601183
- [Phase 4] b4 dig -c 4bfacee94f309: v1 only; Jarkko Reviewed-by; no NAK
- [Phase 4] lore WebFetch: 403; thread read from b4 dig -m
- [Phase 5] init_atmel → atmel_verify_tpm11 → tpm_read_index(TPM_ADDR=0x4E)
- [Phase 6] Local Kconfig still PPC64 || HAS_IOPORT_MAP; ARM PCI_IO_VIRT_BASE=0xfee00000 matches oops
- [Phase 6] ARCH_VERSATILE does not select NO_IOPORT_MAP; HAS_IOPORT selected by ARM
- [Phase 8] parisc generic-64bit_defconfig has CONFIG_TCG_ATMEL=m
- UNVERIFIED: live PPC64 Atmel hardware; stable@ thread beyond b4 mbox
**YES**
drivers/char/tpm/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/char/tpm/Kconfig +1 -2
@@ -163,8 +163,7 @@ config TCG_NSC config TCG_ATMEL tristate "Atmel TPM Interface" - depends on HAS_IOPORT_MAP - depends on HAS_IOPORT + depends on X86 help If you have a TPM security chip from Atmel say Yes and it will be accessible from within Linux. To compile this driver
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 media: cx18: stop VBI start-code scan before short tail
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit bf533acaaa7dee21d49bcaabf8e813ea36bddcd8 ]
compress_sliced_buf() scans one byte at a time while testing a four-byte VBI start code. The final iterations can read beyond the remaining buffer tail.
Stop the scan once fewer than four bytes remain.
---
LLM Generated explanations, may be completely bogus:
The local tree is **v7.3-rc4** (mainline 7.3.0-rc4). The candidate is bf533acaaa7de (“media: cx18: stop VBI start-code scan before short tail”). It is a one-line bounds fix for a four-byte VBI start-code scan that can read past bytesused.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: **[media/cx18] [stop] [stop VBI start-code scan before a short 4-byte tail]**
- Subsystem: media: cx18
- Verb: **stop** (prevent incorrect continuation) — a bug-fix verb even without “fix”
- Intent: do not scan a 4-byte EAV/start code when fewer than 4 bytes remain
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- **Signed-off-by:** Pengpeng Hou <[email protected]> (author)
- **Signed-off-by:** Hans Verkuil <[email protected]> (media maintainer; applied the patch)
- **No Fixes:**
- **No Reported-by / Tested-by / Reviewed-by / Acked-by / Link / Cc:
stable**
- Absence of Fixes/Cc:stable is expected for this pipeline and is not a negative signal
- Ignored: any Sasha Levin SOB / “[Upstream commit …]” (none in the real commit)
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** compress_sliced_buf() walks one byte at a time and tests buf[0]..buf[3]. The last iterations can read past the remaining tail.
- **Symptom:** out-of-bounds **read** of 1–3 bytes past size (the caller’s buf->bytesused).
- **Failure mode:** memory-safety defect (possible slab/page over-read if bytesused equals the allocation; otherwise a logical over-read of DMA payload).
- **Version info:** none in the message. History shows the loop since 2008/2009.
- **Root cause (author):** loop condition i < size does not leave four readable bytes.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: **Not disguised.** It is an explicit bounds fix. Not cleanup/refactor.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- **File:** drivers/media/pci/cx18/cx18-vbi.c — **1 insertion, 1 deletion** (2 +-)
- **Function:** compress_sliced_buf()
- **Scope:** single-file, single-line surgical fix
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- **Before:** for (i = hdr_size, buf += hdr_size; i < size; i++, buf++) then buf[0]..buf[3]. When i is size-3, size-2, or size-1, buf[3] is at size, size+1, or size+2 — past the valid tail.
- **After:** i + 3 < size so the last readable index is i+3 <= size-1.
- **Path:** sliced-VBI start-code search (not probe init). Only the “no start code until EOF” path actually hits the tail; a successful match breaks earlier.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- **Category:** **(d) memory safety** — buffer over-read / out-of-bounds
- **Mechanism:** 4-byte peek with a 1-byte stride and an exclusive size bound.
- **Fix:** require four remaining bytes (i + 3 < size), the same pattern as the sibling ivtv change.
If no start code is found:
- Old: i == size, then size -= (i - hdr_size) → remaining hdr_size
(12)
- New: i == size - 3 (when size is large enough), remaining hdr_size + 3 (15)
Both are still < line_size (272/284), so the function still returns 0. A 4-byte code cannot sit in the last 3 bytes, so no false negative.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- **Obviously correct.** Classic need N bytes remaining bound.
- **Minimal.** One condition, no API/locking/structure change.
- **Regression risk: very low.** False match in the old over-read tail still left remaining size ≪ line_size. i starts at hdr_size (12) and only increments; i + 3 < size with u32 size is safe for realistic DMA sizes.
- **Red flags:** none.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Loop introduced in **1c1e45d17b663d** (Hans Verkuil, 2008-04-28) — original cx18 driver, for (i = 0; i < size; i++, buf++).
- Current form (i = hdr_size, buf += hdr_size; i < size) from **4ab9b256b5908a** (Andy Walls, 2009-03-14) — “Optimize processing of VBI buffers”.
- Bug present ~17 years. Bound fixed in **bf533acaaa7de** (Pengpeng Hou, 2026-06-30; Hans Verkuil commit).
Step 3.2: FOLLOW THE FIXES: TAG
Record: **No Fixes: tag.** N/A. Introducer is 4ab9b256b5908a / original 1c1e45d17b663d, both ancestors of this tree.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- Recent cx18-vbi.c: this fix, email/SPDX/typo/whitespace. No refactor of the scan.
- **Sibling (same author, same day, same maintainer):** f373cf17fb8e7 media: ivtv: stop VBI start-code scan before short tail — same one- line change in drivers/media/pci/ivtv/ivtv-vbi.c.
- **Standalone.** Not “patch X/Y”. ivtv is a parallel clone, not a prerequisite.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record:
- Pengpeng Hou: several small media correctness patches (ivtv twin, cec, v4l2-ctrls, stm32 resume errors). Not the cx18 maintainer.
- **Andy Walls** is listed maintainer for CX18; **Hans Verkuil** applied this (media co-maintainer). That is a strong apply-path signal.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: **None.** Touches only the for-condition. Parent still has compress_sliced_buf(), sliced_vbi_eav_rp[], and i < size. Applies standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- **b4 dig -c bf533acaaa7de:** match
https://patch.msgid.link/2026063007035519.3-ccfa108-0014-media-
[email protected]
- **b4 dig -a:** **v1 only** (2026-06-30). Applied version is that v1.
- **b4 dig -m:** mbox is the original submission only — commit body + 1-line diff. **No replies, NAK, or on-list review.**
- lore.kernel.org HTTP: Anubis 403. Discussion beyond the mbox is **UNVERIFIED** via WebFetch.
- Hans Verkuil’s SOB is the review/apply signal.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (**b4 dig -w**):
- To: Andy Walls (CX18 maintainer), Mauro Carvalho Chehab
- Cc: linux-media, linux-kernel
- Applied by Hans Verkuil. Right lists/maintainers were CCd.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: **No Reported-by, no syzbot, no bugzilla Link.** Looks like static/code inspection, not a user crash. Twin ivtv patch supports that.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Independent [PATCH] plus independent ivtv twin (…-0015-media- ivtv-…). No hidden series dependency. This commit is self-contained.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: **UNVERIFIED** (lore/stable search blocked). Local history has no stable-discussion commit for this subject. No evidence it was rejected for stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: **compress_sliced_buf()** only.
Step 5.2: TRACE CALLERS
Record (grep, not semcode — semcode MCP not available):
- compress_sliced_buf() ← _cx18_process_vbi_data() when **not** raw VBI
- _cx18_process_vbi_data() ← cx18_process_vbi_data() per buffer on a VBI MDL
- cx18_process_vbi_data() ← cx18_fileops.c on userspace read of VBI, or internal VBI while reading MPEG (CX18_F_S_INTERNAL_USE)
- **Context:** process context, V4L2 read/DQBUF — not IRQ. User- reachable with sliced VBI capture on cx18.
Step 5.3: TRACE CALLEES
Record: start-code compare; later v4l2_subdev_call(..., decode_vbi_line) and memcpy of 42 bytes. The changed loop only searches; it does not decode until a full line is found.
Step 5.4: FOLLOW THE CALL CHAIN
Record:VIDIOC_QBUF/read → cx18_dequeue → cx18_process_vbi_data → _cx18_process_vbi_data → compress_sliced_buf
- **Userspace-reachable:** yes, with this card and sliced VBI.
- Unprivileged: only with access to the V4L device node (typical video group / capture app).
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same bug in **ivtv** compress_sliced_buf(); already fixed with i + 3 < size. No other i + 3 < size hits under drivers/media. Systematic cloned-driver bug, both fixed.
===============================================================
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 and function exist: drivers/media/pci/cx18/cx18-vbi.c
- **This commit is already an ancestor of HEAD** (git merge-base --is- ancestor bf533acaaa7de HEAD succeeded)
- First mainline tag containing it: **v7.3-rc1** (git describe --contains --match 'v*')
- **Buggy bound i < size is in the parent** bf533acaaa7de^; it is not a post-7.3 invention
- Introduced **2008/2009**, so every current stable series that still has cx18 has the bug unless this commit was backported
- Already-in-HEAD on **mainline 7.3-rc4** is expected; it is not “already selected for stable”
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **Clean apply.** Surrounding function is stable since 2009 aside from macros/email/SPDX. Stable trees with i < size get a 1-line conflict-free change.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: This is the fix. No earlier alternate bound check. ivtv twin is a different driver.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record:
- **Subsystem:** media / PCI V4L2 — Conexant CX23418 (Hauppauge HVR-1600 and similar)
- **Criticality: PERIPHERAL** — old PCI capture card, not mm/net/VFS
- CONFIG_VIDEO_CX18; maintainer Andy Walls; list linux-media
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: **Mature/quiet.** Recent cx18 commits are treewide/API; this is one of the few real local bugfixes. Long-lived bug, not churn from a rewrite.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: **Driver-specific / config-specific:** CONFIG_VIDEO_CX18, sliced VBI (not raw). Population is small (HVR-1600-class cards) but real.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record:
- Trigger: sliced VBI processing when the 4-byte EAV (0xff 00 00 {0xb0,0xf0}) is not found before the tail — then the loop runs to EOF and over-reads
- How common: every sliced-VBI buffer that lacks a match in-range; with valid hardware the match is usually early
- Unprivileged: only via the V4L node, not a generic syscall primitive
- Not a race
Default buffer sizing (verified):
- stream_buf_size[VBI] = VBI_ACTIVE_SAMPLES * 36 = **1444 × 36 = 51984**
- Sliced MDL: NTSC **9792**, PAL **12496**; bufs_per_mdl = 1
- buf->buf = kmalloc(s->buf_size) (51984); DMA/bytesused ≈ mdl_size (~10–12K)
- Default: 1–3 bytes past bytesused are **still inside the kmalloc object** (not a KASAN slab redzone hit)
- If bytesused == buf_size (full buffer), it **would** be a true allocation over-read
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- **Failure mode:** 1–3 byte read past valid DMA bytesused while matching start codes (result not copied to userspace)
- Default config: no crash, no leak to userspace, no functional change (tail false-match still leaves size ≪ line_size)
- Edge: true slab/page OOB / oops if used size equals allocation
- **Severity: MEDIUM** as memory-safety/correctness; **not CRITICAL** (no demonstrated panic/corruption). Still a real OOB class bug.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit:** closes a long-standing OOB read on a live capture path; low user count
- **Risk: very low** (1 line, loop bound only)
- **Ratio:** favorable — tiny risk, real bounds bug, same pattern already used on ivtv
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
**FOR backporting:**
- Real 4-byte peek past size; classic OOB-read class used in stable
- One line, obviously correct, no API/feature
- Code has been in-tree since 2008/2009; no missing prereqs
- Userspace-reachable sliced VBI on cx18
- Applied by Hans Verkuil; CX18 maintainer CCd
- Twin ivtv fix confirms the pattern
- Regression risk essentially zero
**AGAINST:**
- No syzbot/user/crash report
- Peripheral 2008 PCI encoder, small population
- Default kmalloc (52K) ≫ typical bytesused (~10K), so default may not oops
- No Fixes/Cc:stable (not a veto here)
- Not core mm/fs/net
**UNRESOLVED:**
- lore/stable threads beyond b4 mbox (Anubis)
- No sanitizer report found
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — bound is locally checkable; accepted by media maintainer (no extra Tested-by)
2. Fixes a real bug that affects users? **PASS** — over-read of the VBI payload bound on a real capture path
3. Important issue? **PASS** (medium) — memory-safety OOB; crash only if used size equals allocation; still the OOB class stable takes as small driver fixes
4. Small and contained? **PASS** — 1 line, 1 function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — already in this 7.3-rc4 tree; parent form applies cleanly wherever i < size remains
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: **None** (not ID/quirk/DT/build/doc). Qualifies as a normal small bugfix.
Step 9.4: MAKE YOUR DECISION
This tree is mainline **7.3-rc4**, which already contains the fix (landed in **v7.3-rc1**). The evaluation is technical merit for stable, not “re-apply on 7.3”.
The bug is a one-byte-stride scan of a four-byte start code with i < size, present since 2008/2009. The patch is the standard remaining- bytes fix. It does not add features, does not need other commits, and will not regress the later line parser.
Default cx18 VBI buffers make a crash unlikely, but it is still a real bounds bug on a user-triggerable path, with ~zero backport risk. That is enough for YES on this tree’s stable-candidate criteria.
------------------------------------------------
What the commit solves for stable users compress_sliced_buf() must see buf[0]..buf[3]. With i < size, the last three iterations read past bytesused. Stopping at i + 3 < size prevents that. Users with Hauppauge HVR-1600-class cx18 cards doing sliced VBI (or MPEG with inserted VBI) no longer walk off the valid DMA tail.
Stable rules / risk
Meets the rules: obvious, small, no new API, real OOB. Benefit is modest (niche driver, default alloc has slack); risk is negligible. Prefer taking a 1-line memory-safety fix over leaving a 17-year over-read.
Concerns
None for apply/prereqs. Not a sanitizer/CVE-backed crash. ivtv twin is separate. This 7.3-rc4 checkout already has the commit; older stables still on i < size are the backport targets.
Verification:
- [Phase 1] Subject/tags: media/cx18 “stop”; SOBs Hou + Verkuil; no Fixes/Reported-by/Link/Cc:stable
- [Phase 2] Diff: drivers/media/pci/cx18/cx18-vbi.c compress_sliced_buf() i < size → i + 3 < size (1/1)
- [Phase 2] Confirmed buf[0]..buf[3] vs exclusive size; post-loop size < line_size still holds if no match
- [Phase 3] git blame: loop from 1c1e45d17b663d (2008) / 4ab9b256b5908a (2009); fix bf533acaaa7de
- [Phase 3] git show bf533acaaa7de^: parent still has i < size
- [Phase 3] Sibling f373cf17fb8e7 ivtv same change; author log shows both
- [Phase 4] b4 dig -c: lore msgid 2026063007035519.3-ccfa108-0014-…; v1 only; mbox = patch, no replies
- [Phase 4] b4 dig -w: Walls, Chehab, linux-media, linux-kernel
- [Phase 4] WebFetch/WebSearch lore: **UNVERIFIED** (Anubis 403)
- [Phase 5] Callers: _cx18_process_vbi_data ← cx18_process_vbi_data ← cx18-fileops.c VBI/MPEG read
- [Phase 5] i + 3 < size only in cx18-vbi.c and ivtv-vbi.c
- [Phase 6] git describe HEAD v7.3-rc4-27; kernel 7.3.0-rc4; merge- base --is-ancestor bf533acaaa7de HEAD true; --contains v7.3-rc1
- [Phase 6] File present; apply would be clean on i < size
- [Phase 7] CONFIG_VIDEO_CX18; MAINTAINERS Andy Walls; mature driver
- [Phase 8] buf_size 1444*36=51984; sliced mdl_size 9792/12496; kmalloc(buf_size) so default over-read stays in-object
- [Phase 8] Failure: OOB read, severity MEDIUM; risk very low
- UNVERIFIED: on-list review beyond Hans’s SOB; stable@ discussion; KASAN/syzbot report
**YES**
drivers/media/pci/cx18/cx18-vbi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/cx18/cx18-vbi.c +1 -1
@@ -135,7 +135,7 @@ static u32 compress_sliced_buf(struct cx18 *cx, u8 *buf, u32 size, : VBI_HBLANK_SAMPLES_50HZ;/* find the first valid line */ -for (i = hdr_size, buf += hdr_size; i < size; i++, buf++) { +for (i = hdr_size, buf += hdr_size; i +3 < size; i++, buf++) {if (buf[0 ] ==0xff && !buf[1 ] && !buf[2 ] && (buf[3 ] == sliced_vbi_eav_rp[0 ] || buf[3 ] == sliced_vbi_eav_rp[1 ]))
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 net: mvneta_bm: add suspend/resume support to prevent crash after resume
In reply to Sasha LevinFrom: Yun Zhou <[email protected]>
[ Upstream commit 140be217df577961bea1ca36240439a463026cbd ]
The mvneta driver uses the hardware Buffer Manager (BM) for RX buffer allocation. During suspend, mvneta disables its clock, causing BM to lose all buffer address state. On resume, mvneta_bm_port_init() re- attaches the BM pool to the NIC, but BM hardware returns stale/garbage buffer addresses. When NAPI poll processes these buffers, DMA cache sync hits an invalid virtual address causing a kernel panic:
Unable to handle kernel paging request at virtual address b0000080 PC is at v7_dma_inv_range Call trace: v7_dma_inv_range from arch_sync_dma_for_cpu+0x94/0x158 arch_sync_dma_for_cpu from __dma_sync_single_for_cpu+0xc4/0x15c __dma_sync_single_for_cpu from mvneta_rx_swbm+0x6c8/0xf48 mvneta_rx_swbm from mvneta_poll+0x6fc/0x70c mvneta_poll from __napi_poll.constprop.0+0x2c/0x1e0 __napi_poll.constprop.0 from net_rx_action+0x160/0x2c4 net_rx_action from handle_softirqs+0xd8/0x2b8 handle_softirqs from run_ksoftirqd+0x30/0x94 run_ksoftirqd from smpboot_thread_fn+0x100/0x204 smpboot_thread_fn from kthread+0xf4/0x110 kthread from ret_from_fork+0x14/0x28
Fix by adding suspend/resume callbacks to the BM driver:
- suspend: drain all buffers (with DMA unmapping), free the BPPE regions, and reset pool state to FREE before stopping BM and gating the clock.
- resume: enable the clock, reinitialize BM defaults, and restore pool read/write pointers and size registers. Pool allocation and buffer refill are handled by mvneta_resume() through the normal mvneta_bm_port_init() path, which sees pools as FREE and performs full initialization identical to probe.
Add a device_link (DL_FLAG_AUTOREMOVE_CONSUMER) in mvneta_probe to guarantee BM resumes before mvneta and suspends after mvneta. If the link cannot be created, fall back to SW buffer management to avoid a potential crash on resume due to unordered PM transitions.
---
LLM Generated explanations, may be completely bogus:
This is a real resume panic in an existing driver, and the local 7.3-rc4 tree already has the affected mvneta/mvneta_bm code. The patch is a contained PM completion, not a new API.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [net/mvneta_bm] [add] add suspend/resume support to prevent crash after resume
Subsystem prefix is net: mvneta_bm. The verb is “add”, but the rest of the subject names a crash after resume. That is a bug fix framed as adding the missing PM callbacks.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Yun Zhou <[email protected]> (author)
- `Link: https://patch.msgid.link/20260630060311.4072140-1-
[email protected]`
- Signed-off-by: Paolo Abeni <[email protected]> (netdev maintainer, applied it)
- No Fixes: tag (expected for this review)
- No Cc: [email protected] (expected)
- No Reported-by:, Tested-by:, Reviewed-by:, or Acked-by:
- Notable: author is Wind River, so this came from a commercial embedded product, not a theoretical cleanup
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** Marvell NETA hardware Buffer Manager (BM) has no suspend/resume. mvneta_suspend() gates the NETA clock; BM loses buffer-address state. On resume, mvneta_bm_port_init() reattaches pools while BM still returns stale/garbage addresses.
- **Symptom:** kernel panic: Unable to handle kernel paging request at virtual address b0000080 in v7_dma_inv_range ← arch_sync_dma_for_cpu ← __dma_sync_single_for_cpu ← mvneta_rx_swbm ← mvneta_poll.
- **Version info:** none in the message. BM exists since v4.6; mvneta PM exists since v4.12.
- **Root cause (author):** clock gating drops BM register/pool state; resume reuses that garbage in NAPI RX DMA sync.
- **Fix:** BM suspend drains/unmaps/frees pools and sets type FREE; BM resume re-clocks and restores registers; mvneta_resume() then re- inits pools via the existing mvneta_bm_port_init() path. A device_link orders BM before mvneta on resume.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a hidden fix. The subject says “add … support”, but the body is an oops-on-resume report with a full ARM stack. Adding PM callbacks here is completing missing power-management, which is an allowed stable class (hardware/PM workaround), not a new userspace feature.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- drivers/net/ethernet/marvell/mvneta.c: +18 (probe only)
- drivers/net/ethernet/marvell/mvneta_bm.c: +72
- Total: **90 insertions, 0 deletions** (under the stable ~100-line guideline)
- Functions: mvneta_probe; new mvneta_bm_suspend, mvneta_bm_resume; mvneta_bm_pool_create error paths; mvneta_bm_driver.driver.pm
- Scope: single-subsystem surgical change (Marvell NETA + its BM companion)
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
1. **mvneta_probe BM attach:** after successful mvneta_bm_port_init(), add device_link_add(mvneta, BM, DL_FLAG_AUTOREMOVE_CONSUMER). On failure, destroy long/short pools, mvneta_bm_put(), clear pp->bm_priv and fall back to SW BM.
Before: HW BM could be used with unordered PM vs BM.
2. **mvneta_bm_pool_create error paths:** after dma_free_coherent(), set bm_pool->virt_addr = NULL. Before: dangling pointer; suspend’s dma_free_coherent() could double-free.
3. **New mvneta_bm_suspend:** for each non-FREE pool, mvneta_bm_bufs_free(), disable pool, free BPPE, mutex_destroy(&buf_lock), set type FREE; then MVNETA_BM_STOP_MASK and clk_disable_unprepare(). Before: BM had no suspend; clock/state left live or stale.
4. **New mvneta_bm_resume:** clk_prepare_enable(), mvneta_bm_default_set(), restore per-pool read/write pointers and size, MVNETA_BM_START_MASK. Pool refill stays in existing mvneta_resume() → mvneta_bm_port_init().
5. **Driver .pm:** DEFINE_SIMPLE_DEV_PM_OPS + pm_sleep_ptr().
Before: no PM ops on the BM platform driver.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: [Hardware PM / stale DMA addresses after resume] plus a small [double-free hardening] on virt_addr.
Mechanism: BM hardware state does not survive clock/power loss. Resume still programmed the NIC to consume BM buffers, so NAPI DMA-synced garbage (b0000080) and oopsed. Suspend now tears pools down to FREE; resume brings BM up first (device_link); mvneta_bm_pool_use() sees FREE and does full probe-style alloc/fill.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Quality is good after v2–v6. Drain + unmap, BPPE free, type reset, clock error check, register restore, device_link with SW-BM fallback, mutex_destroy paired with mutex_init in mvneta_bm_pool_use(), and virt_addr NULL on alloc failure are all consistent with existing mvneta_bm_pool_destroy() / probe paths.
Regression risk is **low–medium**: new PM callbacks can leak if drain is incomplete (dev_warn if buf_num remains), and mutex_destroy assumes no concurrent hwbm_pool_add() (the device_link is what makes that true). No public API or core-kernel change. Paolo applied it; no NAK in the thread.
Verified call order with the link (consumer=mvneta, supplier=BM):
mvneta suspends first, BM suspends second; BM resumes first, mvneta resumes second. That matches the code: mvneta_suspend() does **not** destroy BM pools; mvneta_bm_suspend() does; mvneta_resume() calls mvneta_bm_port_init() only after BM resume.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- BM attach in probe: dc35a10f68d37 (Marcin Wojtas, 2016-03-14) “net:
mvneta: bm: add support for hardware buffer management”, **v4.6-rc1**
- Probe BM get/init structure: 965cbbec7f207 (Gregory CLEMENT, 2018-07-18)
- mvneta suspend/resume: 9768b45ceb0bc “net: mvneta: support suspend and resume”, **v4.12-rc1**
- Buggy situation (PM on neta, none on BM) has been in tree since **v4.12** (~2017)
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The missing BM PM has been there since 9768b45ceb0bc (v4.12) against BM from dc35a10f68d37 (v4.6). Both are ancestors of this checkout (git merge-base --is-ancestor not needed for those; they are in file history here).
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES** Record:
- Same author, nearby: fd398d6480987 “net: mvneta: re-enable percpu interrupt on resume” (independent resume IRQ bug, already in this tree)
- After this commit: ede0f99cef53a “net: mvneta: bm: fix device reference leak on failed lookup” — different mvneta_bm_get() leak, not a revert/fix of this PM code
- No “patch X/Y” on this commit. Standalone.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Yun Zhou is not the mvneta maintainer; two recent mvneta resume fixes in this tree. Original BM author Marcin Wojtas was on Cc. Applied by Paolo Abeni.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Record:
- mutex_destroy on hwbm_pool.buf_lock needs the mutex conversion 6dcdd884e2a4b (**v5.3-rc1**). Present here (include/net/hwbm.h has struct mutex buf_lock).
- DEFINE_SIMPLE_DEV_PM_OPS / pm_sleep_ptr: 1a3c7bb088266 (**v5.17**). Present here.
- DL_FLAG_AUTOREMOVE_CONSUMER: renamed in **v4.19**. Present here.
- priv->pdev is set in mvneta_bm_probe() before drvdata is published, so pp->bm_priv->pdev->dev in device_link_add is valid.
- Can apply standalone **in this tree**. No missing helpers.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 140be217df577: https://patch.msgid.link/20260630060311.407
[email protected]
- Series: **v2 → v6** (no v1 in b4’s match list)
- v2 2026-06-14, v3 06-16, v4 06-18, v5 06-25, v6 06-30
- Changelog (from v6 mbox): v2 added drain/device_link; v3 restored pool registers and DEFINE_SIMPLE_DEV_PM_OPS; v4 SW-BM fallback if link fails; v5 disable-before-free; v6 mutex_destroy + virt_addr = NULL
- Applied to **netdev/net-next.git**, not net (feature-sized PM addition, but still a crash fix)
- No NAK. Paolo’s only follow-up: sashiko flagged **pre-existing** issues, asked for a later follow-up — not a NAK of this patch
- No reviewer Cc: stable in the v6 thread
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): Yun Zhou; Marcin Wojtas; Andrew Lunn; Dave Miller; Eric Dumazet; Jakub Kicinski; Paolo Abeni; netdev; linux-kernel. Right lists/maintainers. Human review of earlier versions was mostly sashiko notes forwarded by Simon Horman (v2) and Jakub Kicinski (v5) as “plausible”. Paolo applied v6.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No bugzilla/syzbot link. Evidence is the ARM oops in the commit and Wind River authorship. lore.kernel.org HTTP fetch returned 403; thread was recovered via b4 dig -m.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Single-patch series. Related but independent: fd398d6480987 (percpu IRQ on resume). Not a prerequisite for this diff.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable HTTP 403. Local git log on these files shows no stable-list discussion of this subject. UNVERIFIED whether anyone already requested/rejected it on stable@.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: mvneta_probe, mvneta_bm_pool_create, mvneta_bm_suspend (new), mvneta_bm_resume (new), mvneta_bm_driver pm pointer.
**Step 5.2: TRACE CALLERS**
Record:
- mvneta_bm_suspend/resume: platform PM via dev_pm_ops (system suspend/hibernate)
- mvneta_bm_port_init ← mvneta_probe and mvneta_resume (verified in mvneta.c)
- mvneta_bm_pool_use ← only mvneta_bm_port_init (long and short pools)
- mvneta_poll ← NAPI; chooses mvneta_rx_hwbm if pp->bm_priv else mvneta_rx_swbm
**Step 5.3: TRACE CALLEES**
Record: suspend uses mvneta_bm_bufs_free (DMA unmap + hwbm_buf_free), mvneta_bm_pool_disable, dma_free_coherent, mutex_destroy, clk_disable_unprepare. Resume uses clk_prepare_enable, mvneta_bm_default_set, register writes, BM START.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace/system suspend on Armada 38x/XP with CONFIG_MVNETA_BM and a DT buffer-manager phandle. Reachable on real HW (Wind River). Not a syscall fuzz path; it is a common S2R path on those boards.
Note on the stack naming: mvneta_poll uses mvneta_rx_hwbm when bm_priv is set. The oops shows mvneta_rx_swbm. Verified that mvneta_swbm_rx_frame() does dma_sync_single_for_cpu(..., rx_desc->buf_phys_addr, ...) and can be inlined into mvneta_rx_swbm. That matches DMA-sync-of-garbage if resume fell back to SW BM (mvneta_resume clears bm_priv when mvneta_bm_port_init fails) while RX descriptors still held stale phys addrs, or if the reporter’s kernel named the RX path differently. The BM clock-loss story is still consistent with “invalid address in DMA sync after resume”.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: mvneta already had SIMPLE_DEV_PM_OPS(mvneta_pm_ops, ...). BM was the missing half. No sibling Marvell BM driver in this path. device_link_add is used only in this probe site under drivers/net/ethernet/marvell/.
===============================================================
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** (git describe HEAD = v7.3-rc4-27-gf0100363d8c37, VERSION=7 PATCHLEVEL=3 SUBLEVEL=0 EXTRAVERSION=-rc4).
- 140be217df577 **is** an ancestor of HEAD (git merge-base --is- ancestor succeeded).
- Files drivers/net/ethernet/marvell/mvneta.c and mvneta_bm.c exist; BM probe/remove, mvneta_suspend/mvneta_resume, and mvneta_bm_port_init are present.
- Bug class (BM without PM while neta has PM) dates to v4.12.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean in this tree** — the commit is already applied. Probe BM block has been stable in shape since 2018. Helpers used by the patch exist here.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This fix is already on HEAD. No alternate older fix for BM resume. Follow-up ede0f99cef53a is a different mvneta_bm_get() ref leak, not a replacement for this change.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: [net/ethernet/marvell mvneta + mvneta_bm] [IMPORTANT] — not core mm/VFS, but the onboard NIC on Armada 370/38x/XP/3700. BM is **32-bit only** (depends on !64BIT), Armada 38x/XP. Crash takes down networking after resume on those SoCs.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature driver (2016 BM, 2017 PM). Recent churn is resume fixes (fd398d6480987, this commit), not a rewrite. Long-present bug, not a brand-new subsystem.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **driver-specific / config-specific / platform-specific** — CONFIG_MVNETA + CONFIG_MVNETA_BM on 32-bit Armada 38x/XP with DT buffer-manager. That is exactly Wind River / NAS / router class hardware. SW-BM-only boards are unaffected except for the new device_link failure path (falls back to SW BM).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: System suspend/resume with HW BM in use. Common on embedded devices that sleep. Not unprivileged-syscall; still a production resume path. Not a tiny race window.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: [Kernel paging request / panic in NAPI RX] [CRITICAL]
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit: high** — prevents oops and dead NIC after resume on affected Marvell SoCs.
- **Risk: low–medium** — 90 lines, two files, new PM callbacks but they mirror existing destroy/probe; device_link fallback is fail-safe (SW BM).
- **Ratio:** benefit outweighs risk. Fits “oops / hardware PM” stable policy.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Documented kernel panic with stack after resume
- Real product kernel (Wind River)
- Bug present since v4.12; code is in this tree
- 90 lines, two files, no new UAPI
- Completes PM that mvneta already had; allowed hardware/PM class
- v6 addressed drain, ordering, mutex, dangling virt_addr
- Accepted by Paolo Abeni; no NAK
- Under the documented ~100-line stable size cap
AGAINST:
- Landed in **net-next**, not net (looks feature-sized)
- “add support” wording; new callbacks rather than a 5-line tweak
- Six revisions; not trivial at v1
- No Tested-by besides the author
- Oops symbol is mvneta_rx_swbm while HW BM poll uses mvneta_rx_hwbm (explained above, not a reason to drop a panic fix)
- Sashiko noted other pre-existing issues (not shown to break this patch)
UNRESOLVED:
- Could not read lore.kernel.org/stable (HTTP 403)
- Could not open sashiko’s full pre-existing-issue list (Paolo linked it; described as pre-existing)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — v6 matches existing destroy/probe; author hit the panic; maintainer applied it.
2. Fixes a real bug that affects users? **PASS** — resume oops on Armada
+ BM.
3. Important issue? **PASS** — kernel panic / paging request (CRITICAL).
4. Small and contained? **PASS** — 90 insertions, 2 files, one driver pair.
5. No new features or APIs? **PASS** — no UAPI; PM ops are the missing half of existing suspend/resume (hardware/PM workaround exception).
6. Can apply to the local tree? **PASS** — already in v7.3-rc4; helpers exist.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Hardware/PM workaround (missing suspend/resume causing a crash). Not a new driver, not a new userspace API.
**Step 9.4: MAKE YOUR DECISION**
This tree is v7.3-rc4 and already contains the mvneta BM driver, mvneta PM, and this commit’s helpers. The change fixes a user-visible panic on resume, is contained, and is the correct completion of PM for a driver that already suspends. It should be backported.
------------------------------------------------
What problem it solves for stable users
------------------------------------------------
On 32-bit Marvell Armada boards that use hardware buffer management, suspend gates clocks and the BM forgets buffer addresses. Resume reattaches the NIC to that hardware and NAPI DMA-syncs garbage, panicking in v7_dma_inv_range. After resume, Ethernet is dead and the kernel has oopsed. Stable users of these SoCs (embedded, NAS, Wind River-style products) hit this on ordinary S2R.
------------------------------------------------
Risk vs benefit
------------------------------------------------
Benefit is a panic fix on a real resume path. Risk is a modest amount of new PM code, already iterated through v6 and aligned with mvneta_bm_pool_destroy() / mvneta_bm_pool_use(). Device-link failure falls back to SW BM instead of leaving a crashy configuration.
------------------------------------------------
Verification
------------------------------------------------
- [Phase 1] Parsed tags: Yun Zhou SOB, Paolo Abeni SOB, msgid.link; no Fixes/Cc-stable/Reported-by
- [Phase 1] Body: ARM paging oops in DMA sync during mvneta_poll after resume
- [Phase 2] Diff: +18 mvneta.c (device_link + SW BM fallback), +72 mvneta_bm.c (PM ops + virt_addr NULL)
- [Phase 2] mvneta_poll HW vs SW split and dma_sync_single_for_cpu in mvneta_swbm_rx_frame verified in source
- [Phase 3] BM introduced dc35a10f68d37 (v4.6-rc1); mvneta PM 9768b45ceb0bc (v4.12-rc1)
- [Phase 3] git merge-base --is-ancestor 140be217df577 HEAD → IS ancestor
- [Phase 3] hwbm mutex: 6dcdd884e2a4b (v5.3);
DEFINE_SIMPLE_DEV_PM_OPS: 1a3c7bb088266 (v5.17)
- [Phase 3] Follow-up ede0f99cef53a is a different leak, not a fix/revert of this patch
- [Phase 4] b4 dig -c 140be217df577: v2–v6, applied to net-next; no NAK; Paolo asked about pre-existing sashiko issues
- [Phase 4] b4 dig -w: netdev maintainers on To/Cc
- [Phase 4] b4 dig -m: v6 changelog + Paolo reply parsed from mbox
- [Phase 4] lore HTTP 403; stable@ search UNVERIFIED via WebFetch
- [Phase 5] Callers: mvneta_bm_port_init from probe and mvneta_resume only
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- [Phase 6] BM and mvneta PM files present; commit already on this branch
- [Phase 7] Kconfig: MVNETA_BM depends on !64BIT; Armada 38x/XP
- [Phase 8] Failure mode: kernel paging request in RX NAPI after resume, CRITICAL
- UNVERIFIED: full sashiko finding list; whether stable@ already discussed this patch
**YES**
drivers/net/ethernet/marvell/mvneta.c | 18 ++++++ drivers/net/ethernet/marvell/mvneta_bm.c | 72 ++++++++++++++++++++++++ 2 files changed, 90 insertions(+)
drivers/net/ethernet/marvell/mvneta.c +18 -0
@@ -5684,6 +5684,24 @@ static int mvneta_probe(struct platform_device *pdev) "use SW buffer management\n");mvneta_bm_put (pp->bm_priv); pp->bm_priv =NULL ; + }else if (!device_link_add (&pdev->dev, + &pp->bm_priv->pdev->dev, +DL_FLAG_AUTOREMOVE_CONSUMER )) { +/* +* Link guarantees BM resumes before mvneta. +* Without it, BM may not be ready when +* mvneta_bm_port_init() runs on resume, +* causing stale buffer addresses and a crash. +* Fall back to SW management to be safe. +*/ +dev_warn (&pdev->dev, +"failed to link to BM, use SW buffer management\n" ); +mvneta_bm_pool_destroy (pp->bm_priv, + pp->pool_long,1 << pp->id); +mvneta_bm_pool_destroy (pp->bm_priv, + pp->pool_short,1 << pp->id); +mvneta_bm_put (pp->bm_priv); + pp->bm_priv =NULL ; } }/* Set RX packet offset correction for platforms, whose
drivers/net/ethernet/marvell/mvneta_bm.c +72 -0
96 lines not on this page · raw message
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ASoC: cs35l56: Add support for CS35L62 for SoundWire
In reply to Sasha LevinFrom: Stefan Binding <[email protected]>
[ Upstream commit 3330b5f6d8dea66df51c07362f01a39ad9845aad ]
CS35L62 uses the same control and regmap interface as CS35L63 so support for it can be added into the CS35L56 driver.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
- Record: [ASoC/cs35l56] [add] [enable CS35L62 on SoundWire by reusing CS35L63 paths]
**Step 1.2 — Tags**
- Record:
- Fixes: none (expected)
- Reported-by: none
- Tested-by: none
- Reviewed-by: none on the commit
- Acked-by: none
- `Link: https://patch.msgid.link/20260715120135.939280-2-
[email protected]`
- Cc: [email protected] none (expected)
- Signed-off-by: Stefan Binding (author)
- Signed-off-by: Richard Fitzgerald (Cirrus; submitted the series)
- Signed-off-by: Mark Brown (ASoC maintainer)
- Ignore any Sasha Levin SOB if present — pipeline noise
**Step 1.3 — Body**
- Record: No bug, crash, leak, or regression is described. Claimed intent is hardware enablement: CS35L62 shares CS35L63’s control/regmap interface, so it can live in the existing cs35l56 driver. Symptom without the patch: a CS35L62 SoundWire amp is not matched (-ENODEV / unknown DEVID). Root cause: missing part ID and type cases. No version range is given. Mark Brown applied it to for-7.3 as merge-window material, not as a bugfix.
**Step 1.4 — Hidden bug fix?**
- Record: No. Wording is “Add support”, not cleanup/locking/error-path repair. This is new silicon enablement, not a disguised UAF/leak/race fix.
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
- Record: 3 files, **+7 / −0**, single-driver surgical change.
- sound/soc/codecs/cs35l56-sdw.c (+2): cs35l56_sdw_probe(),
`cs35l56_sdw_id[]`
- `sound/soc/codecs/cs35l56-shared.c` (+4): `cs35l56_set_patch()`,
`cs35l56_set_fw_reg_table()`, `cs35l56_system_reset()`,
`cs35l56_hw_init()` - sound/soc/codecs/cs35l56.c (+1): _cs35l56_component_probe()
- Scope: device-ID addition to an existing codec driver.
**Step 2.2 — Flow**
- Before: SoundWire ID 0x01FA:0x3562 is unmatched; type 0x62 / DEVID 0x35A620 fall through to -ENODEV or skip CS35L63 firmware/reset/controls.
- After: ID binds; all CS35L63-specific switches also accept CS35L62 and reuse cs35l63_regmap_sdw, cs35l63_patch_fw, cs35l63_fw_reg, cs35l63_system_reset_seq, cs35l63_calibration_controls, cs35l63_controls.
- Path: probe/init only for the new part. Existing 0x54/56/57/63 paths are unchanged.
**Step 2.3 — Bug mechanism**
- Record: [Hardware enablement / SoundWire device ID] not a memory- safety or locking bug. Mechanism: add SDW_SLAVE_ENTRY(0x01FA, 0x3562, 0x3562) and sibling case labels so CS35L62 is treated as CS35L63.
**Step 2.4 — Fix quality**
- Record: Obviously correct given the stated aliasing. Minimal. No public API, no new driver. Regression risk for existing chips is very low (new cases only). Completeness: other type switches in this driver already use default: for CS35L63-class silicon, so they pick up 0x62 without extra cases. I2C/SPI tables are intentionally untouched (series is SoundWire-only). KUnit still special-cases only 0x63 in one test; that is test-only.
## Phase 3: Git history
**Step 3.1 — Blame**
- Record: CS35L63 cases/IDs came from 978858791ceda (“Add initial support for CS35L63…”, 2025-04-07). That commit is an ancestor of HEAD and is in v6.16. cs35l56 itself dates to e496112529006 (2023-03-20). The CS35L62 lines are this commit (3330b5f6d8dea).
**Step 3.2 — Fixes: tag**
- Record: None. There is no “buggy commit”; support was simply never added. N/A.
**Step 3.3 — File history / series**
- Record: Patch **1/2**. Companion 0306d21155819 (“ASoC: sdw_utils:
Add codec info for CS35L62”) adds the SOF/generic machine-driver table entry. Cover letter: chip IDs in the codec driver **and** sdw_utils. Follow-up 998b8a6c8aff2 sorted the SDW ID table (addresses Pierre- Louis Bossart’s nit). Later cs35l56 changes are independent (IRQ, probe deadlock, pm_runtime).
**Step 3.4 — Author**
- Record: Stefan Binding is a regular Cirrus cs35l56/cs35l41 contributor (including the original CS35L63 support). Submitted via Richard Fitzgerald; applied by Mark Brown. High confidence in the ID mapping.
**Step 3.5 — Prerequisites**
- Record: Needs CS35L63 symbols (cs35l63_regmap_sdw, patch/fw/reset/calibration/controls). Those exist in this checkout. Standalone for the codec driver; SOF auto-wiring wants patch 2/2 as well.
## Phase 4: Mailing list / external
**Step 4.1 — b4 dig**
- Record: Lore/thread: https://patch.msgid.link/20260715120135.939280- [email protected]
- Series: **v1 only** (no v2/v3). Applied as submitted.
- Review: Pierre-Louis Bossart (SoundWire) only nitted sort order (62 after 63). No NAK, no stable nomination, no functional concern.
- Mark Brown: applied to for-7.3, with the standard note that merge- window patches go in the next window “or sooner **if it is a bug fix**” — i.e. this was **not** treated as a bugfix.
**Step 4.2 — Recipients (b4 dig -w)**
- Record: [email protected], [email protected], linux- [email protected], [email protected]. Maintainer applied it.
**Step 4.3 — Bug report**
- Record: None. No syzbot, bugzilla, or user crash report.
**Step 4.4 — Related patches**
- Record: [PATCH 0/2] + [PATCH 2/2] sdw_utils codec_info. Both applied together (3330b5f6d8dea, 0306d21155819).
**Step 4.5 — stable@**
- Record: lore.kernel.org/stable WebFetch returned 403. **UNVERIFIED** whether stable@ discussed it. Unlikely: 7.3 is still rc4 and this was merge-window work.
## Phase 5: Semantic / call graph
**Step 5.1 — Functions**
- Record: cs35l56_sdw_probe, cs35l56_sdw_id[], cs35l56_set_patch, cs35l56_set_fw_reg_table, cs35l56_system_reset, cs35l56_hw_init, _cs35l56_component_probe.
**Step 5.2 — Callers**
- Record: cs35l56_sdw_probe is the sdw_driver.probe (SoundWire enumeration). cs35l56_common_probe() is called from SDW/I2C/SPI probe. cs35l56_hw_init / cs35l56_set_patch are called from the codec init path in cs35l56.c. _cs35l56_component_probe is the ALSA component probe. Not a syscall hot path; probe/runtime of this amp.
**Step 5.3 — Callees**
- Record: devm_regmap_init_sdw, cs35l56_common_probe, regmap_register_patch, regmap_multi_reg_write_bypassed, snd_soc_add_component_controls. No new helpers.
**Step 5.4 — Reachability**
- Record: Reachable when a CS35L62 SoundWire slave enumerates (laptops/SOF). Unprivileged userspace cannot trigger a crash path here; without the ID the device simply does not bind.
**Step 5.5 — Similar patterns**
- Record: Same pattern as CS35L63 (978858791ceda) and CS35L57 IDs. Remaining case 0x57 blocks use default: for CS35L63-class parts, so CS35L62 is covered there.
## Phase 6: This tree
**Step 6.1 — Local tree and whether the code exists**
- Record: git describe HEAD = **v7.3-rc4-27-gf0100363d8c37**; make kernelversion = **7.3.0-rc4**. This is mainline 7.3-rc, not an LTS branch.
- Driver, CS35L63 paths, and the new IDs all exist here. git merge-base --is-ancestor 978858791ceda HEAD succeeds. git merge-base --is- ancestor 3330b5f6d8dea HEAD succeeds. CS35L62 first appears in **v7.3-rc1**, not v7.2.
**Step 6.2 — Backport difficulty**
- Record: Context here already includes later IRQ/ID-sort changes, but the hunks are trivial case/ID inserts. Expected apply: clean or trivial reorder. **Low difficulty.**
**Step 6.3 — Related fixes already here**
- Record: No alternate CS35L62 fix. Support is this series. ID table sort came after.
## Phase 7: Subsystem
**Step 7.1**
- Record: [ASoC codec driver, Cirrus CS35L56 family] [IMPORTANT — common laptop speaker amps, not core mm/fs; not staging]
**Step 7.2**
- Record: Actively maintained (many 2026 probe/IRQ/pm fixes). CS35L56 is mature; CS35L62 is a small ID alias on top of CS35L63.
## Phase 8: Impact and risk
**Step 8.1 — Who is affected**
- Record: Driver-specific / config-specific (CONFIG_SND_SOC_CS35L56_SDW). Only CS35L62 SoundWire hardware. Existing CS35L54/56/57/63 behavior unchanged.
**Step 8.2 — Trigger**
- Record: Device enumeration of part 0x3562. Not a race. Not unprivileged exploit surface.
**Step 8.3 — Failure mode without the patch**
- Record: Device does not probe; no speaker amp. Severity **LOW** as a kernel bug (no oops/corruption), **HIGH** as hardware enablement for those machines.
**Step 8.4 — Benefit vs risk**
- Record: Benefit: CS35L62 SoundWire amps work on this kernel. Risk:
very low (7 lines, additive cases). Ratio: favorable **if** treating this as a device-ID exception; poor **if** requiring a crash/security bug.
## Phase 9: Synthesis
**Step 9.1 — Evidence**
For:
- Matches the documented **new device ID** exception (SoundWire ID + cases routing to existing CS35L63 code).
- Small (7 lines), obviously correct, maintainer-applied.
- Driver and CS35L63 prerequisites exist in this 7.3 tree.
- No change to existing IDs’ control flow.
- Author is the Cirrus driver owner.
Against:
- Subject/body are **new feature**, not a bugfix. No crash, leak, UAF, deadlock, or CVE.
- Mark Brown applied it to **for-7.3 merge window**, not as a stable bugfix.
- Patch 1/2; SOF machine auto-config also wants 0306d21155819.
- No Reported-by / no in-field bug.
- Stable rules 2 and 3 fail unless the ID exception is used.
Unresolved:
- stable@ lore search could not be fetched (403).
**Step 9.2 — Stable rules checklist**
1. Obviously correct and tested? **PASS** — aliasing is local and reviewed; applied by broonie. Only review comment was sort order.
2. Fixes a real bug that affects users? **FAIL** as a defect; **PASS** only under the device-ID exception (unsupported CS35L62).
3. Important issue (crash/security/corruption/deadlock)? **FAIL**
4. Small and contained? **PASS** (7 lines, one driver)
5. No new features or APIs? **FAIL** as a feature; **PASS** under device-ID exception (no new driver/API, only an ID)
6. Can apply to the local tree? **PASS** — CS35L63 paths present on 7.3-rc4
**Step 9.3 — Exception**
- Record: **NEW DEVICE IDs** on an existing driver. Same class as adding a PCI/USB ID. Not a new driver, not a new uAPI.
**Step 9.4 — Decision**
This tree is **7.3.0-rc4**. The cs35l56 driver and CS35L63 handling are present, so the patch is applicable here. It does not fix a stability bug, but it is the standard “add ID to existing driver” pattern the stable rules explicitly allow: one SoundWire ID and a handful of case labels so CS35L62 reuses CS35L63. Risk to current users is negligible. Companion sdw_utils entry is separate and not required for the codec to bind.
### What it solves for users of this tree
Without the ID, a CS35L62 SoundWire amp never matches the driver. With it, the existing CS35L63 path runs. That is hardware enablement, not a crash fix.
### Rules / risk
Meets “small, obviously correct, no new API”. Importance is hardware support, covered by the device-ID exception. Backport/apply risk is very low.
---
Verification:
- [Phase 1] Parsed tags: SOB Binding/Fitzgerald/Brown; Link to patch 1/2; no Fixes/Reported-by/stable Cc
- [Phase 2] Diff: +7 lines, ID 0x3562 + cases 0x62/0x35A620 reusing CS35L63
- [Phase 3] git blame: CS35L63 from 978858791ceda (v6.16); CS35L62 from 3330b5f6d8dea
- [Phase 3] git merge-base --is-ancestor 978858791ceda HEAD: CS35L63 in this tree
- [Phase 3] git merge-base --is-ancestor 3330b5f6d8dea v7.3-rc1: first in 7.3-rc1; not in v7.2
- [Phase 3] Series: 1/2 codec IDs, 2/2 0306d21155819 sdw_utils
- [Phase 4] b4 dig -c 3330b5f6d8dea: v1 only; URL patch.msgid.link/20260715120135.939280-2-…
- [Phase 4] b4 dig -a: no later revision
- [Phase 4] b4 dig -w: broonie + linux-sound
- [Phase 4] mbox: Bossart sort-order nit only; Brown applied to for-7.3
- [Phase 4] WebFetch lore.kernel.org: 403; used b4 mbox + openwall instead
- [Phase 5] grep callers: SDW probe → cs35l56_common_probe; hw_init/set_patch from codec init
- [Phase 5] Other case 0x63 sites updated; remaining type switches use default: for L63-class
- [Phase 6] git describe HEAD / make kernelversion: v7.3-rc4 / 7.3.0-rc4; files present
- [Phase 8] Failure mode: no bind for CS35L62, not an oops; existing IDs unchanged
- UNVERIFIED: stable@ mailing list (lore 403)
**YES**
sound/soc/codecs/cs35l56-sdw.c | 2 ++ sound/soc/codecs/cs35l56-shared.c | 4 ++++ sound/soc/codecs/cs35l56.c | 1 + 3 files changed, 7 insertions(+)
sound/soc/codecs/cs35l56-sdw.c +2 -0
@@ -529,6 +529,7 @@ static int cs35l56_sdw_probe(struct sdw_slave *peripheral, const struct sdw_devi regmap_config = &cs35l56_regmap_sdw;break ;case 0x3563 : +case 0x3562 : regmap_config = &cs35l63_regmap_sdw;break ;default :
@@ -582,6 +583,7 @@ static const struct sdw_device_id cs35l56_sdw_id[] = {SDW_SLAVE_ENTRY (0x01FA ,0x3556 ,0x3556 ),SDW_SLAVE_ENTRY (0x01FA ,0x3557 ,0x3557 ),SDW_SLAVE_ENTRY (0x01FA ,0x3563 ,0x3563 ), +SDW_SLAVE_ENTRY (0x01FA ,0x3562 ,0x3562 ), {}, };MODULE_DEVICE_TABLE (sdw, cs35l56_sdw_id);
sound/soc/codecs/cs35l56-shared.c +4 -0
@@ -86,6 +86,7 @@ int cs35l56_set_patch(struct cs35l56_base *cs35l56_base) ARRAY_SIZE(cs35l56_patch_fw));break ;case 0x63 : +case 0x62 : ret =regmap_register_patch (cs35l56_base->regmap, cs35l63_patch_fw,ARRAY_SIZE (cs35l63_patch_fw));break ;
@@ -370,6 +371,7 @@ static void cs35l56_set_fw_reg_table(struct cs35l56_base *cs35l56_base) }break ;case 0x63 : +case 0x62 : cs35l56_base->fw_reg = &cs35l63_fw_reg;break ; }
@@ -576,6 +578,7 @@ void cs35l56_system_reset(struct cs35l56_base *cs35l56_base, bool is_soundwire) }break ;case 0x63 : +case 0x62 :regmap_multi_reg_write_bypassed (cs35l56_base->regmap, cs35l63_system_reset_seq,ARRAY_SIZE (cs35l63_system_reset_seq));
@@ -1080,6 +1083,7 @@ int cs35l56_hw_init(struct cs35l56_base *cs35l56_base) cs35l56_base->calibration_controls = &cs35l56_calibration_controls;break ;case 0x35A630 : +case 0x35A620 : cs35l56_base->calibration_controls = &cs35l63_calibration_controls; devid = devid >>4 ;break ;
sound/soc/codecs/cs35l56.c +1 -0
@@ -968,6 +968,7 @@ static int cs35l56_component_probe(struct snd_soc_component *component) ARRAY_SIZE(cs35l56_controls));break ;case 0x63 : +case 0x62 : ret =snd_soc_add_component_controls (component, cs35l63_controls,ARRAY_SIZE (cs35l63_controls));break ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: iwlwifi: mld: reset the driver state upon firmware recovery
In reply to Sasha LevinFrom: Emmanuel Grumbach <[email protected]>
[ Upstream commit 71ac392d8b5c23c45c66f30eff1c319580ada4da ]
Just like we did in iwlmvm, we also need to clear the mld state when the firmware was killed because of the device being powered off during suspend.
---
LLM Generated explanations, may be completely bogus:
I have enough of the tree, the sibling mvm fix, and the lore series to judge this on merit. Writing the full phase-by-phase analysis next.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[iwlwifi/mld] [reset] [clear MLD driver state when firmware is killed because the device was powered off during suspend]**
- Subsystem: wifi: iwlwifi: mld
- Action verb: **reset** (correctness / recovery, not a feature)
- Intent: after firmware recovery from a power-off-during-suspend, wipe MLD software state the same way iwlmvm already does
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record (from git show 71ac392d8b5c2):
- **Fixes:** none (expected for this review pipeline)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** none on the commit itself
- **Acked-by:** none
- **Link:** https://patch.msgid.link/20260714165826.ff1c9e05e0a9.I8df8d 4a0384065fd2a32cf258339be77084c55bd@changeid
- **Cc: stable:** none (not a negative signal)
- **Signed-off-by:** Emmanuel Grumbach (author); Miri Korenblit (iwlwifi maintainer)
- Ignore pipeline markers: none present on the original commit
Notable: Intel iwlwifi developers; maintainer SOB; no syzbot/user reports.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** When firmware is killed because the NIC was powered off in suspend, MLD driver state is left as if the firmware were still configured.
- **Symptom:** After that resume path, software IDs/keys/scan/FTM/internal STAs no longer match a freshly started firmware image. Connection/recovery after suspend can fail; later FW commands can error or WARN.
- **Version info:** none in the message. Analog is explicit: “Just like we did in iwlmvm”.
- **Root cause (author):** device_powered_off stopped firmware (iwl_mld_stop_fw) and cleared in_d3, but never ran the existing restart cleanup that zeros restart-sensitive state and walks vifs/stations.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not disguised.** It is a real recovery-path correctness fix. “Reset the driver state” is the missing counterpart of iwl_mld_restart_cleanup() already used from iwl_mld_mac80211_start() when in_hw_restart is set. The mvm sibling (0a00c3ec2db76) states the same problem more clearly: after power-off, firmware must be reloaded **and reconfigured**.
---
## PHASE 2: DIFF ANALYSIS - LINE BY LINE
**Step 2.1: INVENTORY THE CHANGES**
Record:
- drivers/net/wireless/intel/iwlwifi/mld/mac80211.c:
iwl_mld_restart_cleanup un-static’d (static void → void) — **3 +/− lines net**
- drivers/net/wireless/intel/iwlwifi/mld/mac80211.h: export prototype; copyright year — **+2**
- drivers/net/wireless/intel/iwlwifi/mld/mld.c: one call iwl_mld_restart_cleanup(mld); in iwl_mld_device_powered_off — **+1**
- Totals: **+4 / −2**, three files, one function body unchanged
- Scope: **single-subsystem, surgical**
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Hunk 1 (mac80211.c): iwl_mld_restart_cleanup still does iwl_cleanup_mld → iterate vifs (iwl_mld_cleanup_vif) → iterate stations (iwl_mld_cleanup_sta) → iwl_mld_ftm_restart_cleanup. Only linkage changes (now callable from mld.c).
Hunk 2 (mac80211.h): prototype so mld.c can call it. mld.c already includes mac80211.h.
Hunk 3 (mld.c iwl_mld_device_powered_off, CONFIG_PM_SLEEP):
**Before:**
``` wiphy_lock iwl_mld_stop_fw(mld) // abort waits, stop device, fw_status.running = false in_d3 = false wiphy_unlock ```
**After:** same, plus iwl_mld_restart_cleanup(mld) between stop_fw and clearing in_d3.
Path: PCI resume when scratch/MAC grab shows the device was powered off (iwl_op_mode_device_powered_off from pcie/drv.c). Not the happy wowlan-keep-alive path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Logic / correctness — stale driver state after firmware death]**
Without cleanup, iwl_mld_mac80211_start sees in_d3 == false, skips D3 resume, and calls iwl_mld_start_fw() **without** iwl_mld_restart_cleanup(). Firmware is empty; driver still holds:
- zeroed_on_hw_restart groups (phy, scan, iface, link, sta, txq)
- firmware station IDs / internal STAs
- keys
- FTM initiator request
iwl_mld_cleanup_vif frees internal STAs and keys; skipping it on this path is a leak plus ID mismatch. Category is **incomplete error/recovery handling**, not a new feature.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Obviously correct:** reuses the function already used on HW restart; mvm does the same from iwl_op_mode_mvm_device_powered_off (iwl_mvm_restart_cleanup).
- **Minimal:** one call + un-static.
- **Regression risk low:** already runs under wiphy_lock from iwl_mld_mac80211_start; device_powered_off already takes wiphy_lock. Cleanup is largely idempotent (CLEANUP_STRUCT memset, sta_id != IWL_INVALID_STA guards). FTM abort on a dead NIC during resume is appropriate.
- **Redundant** in_d3 = false after iwl_cleanup_mld also clears it — harmless.
- No public API / data-structure change except making an existing helper non-static.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Buggy iwl_mld_device_powered_off introduced in **d1e879ec600f9** (wifi: iwlwifi: add iwlmld sub-driver, 2025-03-05; that commit’s Makefile is **6.14.0-rc4**).
- Merged to this lineage via c73ebc0dbb6ed (iwlwifi- next-2025-06-25).
- Intermediate: 7aeec8c8d63bf removed system_pm_mode assignment; still no cleanup.
- iwl_mld_restart_cleanup existed as **static** since MLD introduction; this commit only exports it.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Bug is original MLD device_powered_off (omit cleanup). Target d1e879ec600f9 **is** an ancestor of this tree (git merge-base --is-ancestor).
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- **71ac392d8b5c2** — this fix (in tree)
- **0a00c3ec2db76** — mvm analog, same day/author/series (14/15 vs 15/15)
- **1c031ac5a39eb** — later “do not cleanup FW state when device is dead”; **different path** (chanctx unassign / NULL link), not a revert of this call
- **c99bc4d4e0ba6** — cancel wiphy work before free (same series, 08/15); not a prerequisite for this hunk
Standalone: no other series patch is required for this one-line call.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Emmanuel Grumbach is a long-time Intel iwlwifi developer. Same- day pair: mvm cleanup + this MLD mirror. Maintainer Miri Korenblit SOB’d both. Weight: **high**.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs iwl_mld_restart_cleanup, iwl_mld_device_powered_off, MLD op_mode — all present since MLD add. mld.c already #include "mac80211.h". **Applies standalone** on this tree.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 71ac392d8b5c2 → **https://patch.msgid.link/20260714165826. ff1c9e05e0a9.I8df8d4a0384065fd2a32cf258339be77084c55bd@changeid**
- **v2**, [PATCH v2 iwlwifi-next 15/15]; v2 cover: resend so next contains an unrelated compile fix (too long hcmds), **not** a redesign of this patch
- Cover: “Usual fixed, cleanups and features from our internal tree.” This commit listed under Emmanuel’s fixes.
- Saved mbox: **16 messages, all series posts, zero review replies / NAKs / Cc: stable**
- lore.kernel.org / patch.msgid.link HTTP fetch: **403** — discussion taken from b4 dig -m mbox instead
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc **Johannes Berg**, **linux- [email protected]**, Miri Korenblit, Emmanuel Grumbach. No Reviewed-by on 15/15 (several other series patches have Johannes R-b). Applied via iwlwifi-next (905b418df8af2, 2026-07-23). Maintainer-tree merge is the review signal.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: **No user/syzbot/bugzilla report.** Bug is reasoned from the mvm gap. Severity from code: stale FW IDs after D3cold/hibernate-style power-off — WiFi may not come back cleanly.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 15-patch iwlwifi-next dump. **14/15 is the mvm twin** (independent). This patch does **not** depend on 01–13. Mix of features and fixes; this hunk is a self-contained fix.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: Web search found **other** iwlwifi MLD restart patches in stable (e.g. “stop TX during firmware restart” for 6.18/7.0). **No hit** for this subject on stable@. UNVERIFIED: whether anyone already nominated this exact commit for older -stable.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: iwl_mld_restart_cleanup (export), iwl_mld_device_powered_off (call site). Unchanged callees: iwl_cleanup_mld, iwl_mld_cleanup_vif, iwl_mld_cleanup_sta, iwl_mld_ftm_restart_cleanup.
**Step 5.2: TRACE CALLERS**
Record:
- iwl_mld_restart_cleanup: iwl_mld_mac80211_start (if in_hw_restart); **now** iwl_mld_device_powered_off
- iwl_mld_device_powered_off: op_mode .device_powered_off → iwl_op_mode_device_powered_off → **_iwl_pci_resume** in pcie/drv.c when restore or scratch says powered off
- Context: **PM resume**, process context, already holds wiphy_lock
- Reachable on Intel WiFi 7 / MLD laptops that D3cold the NIC or hibernate
**Step 5.3: TRACE CALLEES**
Record: stop_fw (trans stop, abort waits); cleanup zeros restart groups; frees internal STAs/keys; may call ieee80211_remain_on_channel_expired; FTM reports failure to cfg80211. Side effects are the intended reset.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: **Userspace-reachable** via suspend/resume (and hibernate), not a syscall bug. Trigger is common on laptops that cut WiFi power. Unprivileged users typically cannot force PCI D3cold, but they **do** suspend.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: **Exact mvm analog** 0a00c3ec2db76 — same author, same series. Pattern is systematic (mvm had the cleanup; mld was missed at introduction).
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record:
- Local tree: **git describe HEAD = v7.3-rc4-27-gf0100363d8c37**, make kernelversion = **7.3.0-rc4**
- MLD files present under drivers/net/wireless/intel/iwlwifi/mld/
- **git merge-base --is-ancestor 71ac392d8b5c2 HEAD succeeds** — this fix is **already in this checkout**
- Pre-fix body (parent of 71ac392d8b5c2) had device_powered_off without cleanup; current mld.c:750 has the call
- Bug introduced with MLD (d1e879ec600f9, ~6.14 development / 2025); **not** after 7.3 branched
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** on this tree (already applied). Context around iwl_mld_device_powered_off matches the candidate diff. No conflicting refactor.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This fix **is** here. mvm analog **is** here. No earlier different MLD-powered-off cleanup. Follow-up 1c031ac5a39eb is unrelated chanctx/dead-device WARN, not a replacement.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **iwlwifi MLD** (CONFIG_IWLMLD) — Intel Wi-Fi 7 / MLO devices. **IMPORTANT** (very common laptop NIC), not core mm/VFS. Affects all IWLMLD users on PM sleep.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: **Active** (regular iwlwifi-next pulls). Bug is an original omission in a still-young op_mode (~1.5 years), not bitrot in abandoned code.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific + config-specific:** CONFIG_IWLWIFI + CONFIG_IWLMLD + CONFIG_PM_SLEEP. Intel BE200/BE201-class Wi-Fi 7. Population is large for a driver fix.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Trigger: resume after the transport decides the device was powered off (scratch bits, 0xFFFFFFFF, or failed NIC grab) — **hibernate, D3cold, some s2idle**
- Not every suspend (wowlan-alive path skips this)
- Not a userspace exploit path
- Timing: deterministic once the platform cuts power
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- **Failure:** driver/firmware state desync after resume; commands with stale IDs; possible internal-STA/key leak; FTM requests left hanging; Wi-Fi may not recover without reload
- Not shown as oops/UAF/CVE in the message (UNVERIFIED as crash)
- **Severity: HIGH** for affected hardware (broken Wi-Fi after suspend), **not CRITICAL** (no verified panic/corruption)
Stable-rules fit: **“oh, that’s not good”** / hardware resume quirk, not theoretical.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit: high** for IWLMLD + PM — resume actually reconfigures like mvm
- **Risk: very low** — +1 call to existing helper, same lock as start path
- **Ratio: strongly favorable**
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR backporting to this 7.3 tree:**
- Real resume bug: firmware stopped, MLD software state not reset
- Same fix already proven in mvm (0a00c3ec2db76)
- Tiny, obviously correct; helper already used on HW restart
- Intel Wi-Fi 7 is common; suspend/resume is a user-facing path
- MLD and the buggy function exist in this tree; no extra prereqs
- Maintainer-tree merge; Johannes on Cc
- Matches stable rule of a real bug that bothers people (Wi-Fi dead/wrong after power-off suspend)
**AGAINST:**
- No Reported-by / syzbot / stack trace
- Brief commit message
- 15/15 of a mixed “updates” series, not a dedicated stable submission
- No explicit crash/security
- Power-off-during-suspend is not every resume (wowlan-alive OK)
**UNRESOLVED:**
- Exact user-visible rate (no public bugzilla)
- lore HTTP 403; no on-list NAK found in mbox
- No stable@ discussion of this exact subject
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — mirrors mvm; merged to iwlwifi-next/mainline; logic is a single missing call.
2. Fixes a real bug that affects users? **PASS** — stale MLD state vs empty firmware after D3cold/hibernate resume.
3. Important issue? **PASS** — user-visible Wi-Fi recovery failure (HIGH, not panic). Fits “oh, that’s not good” / resume hardware path.
4. Small and contained? **PASS** — ~4 insertions, one subsystem.
5. No new features or APIs? **PASS** — export existing helper + call it.
6. Can apply to the local tree? **PASS** — code present; patch already applies (already in v7.3-rc4).
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **None** (not a device ID / quirk table / DT / build / docs). Qualifies as a normal small bugfix.
**Step 9.4: MAKE YOUR DECISION**
This tree is **7.3.0-rc4**. The MLD device_powered_off path exists here and omitted restart cleanup until 71ac392d8b5c2. The commit is a 4-line, low-risk fix for a real suspend/resume correctness bug on Intel MLD hardware. It should be in this tree’s stable stream.
### What the commit solves (for 7.3 users)
On PCI resume, if the NIC was powered off, MLD only stopped firmware and cleared in_d3. iwl_mld_mac80211_start then did a cold iwl_mld_start_fw() **without** iwl_mld_restart_cleanup(), so firmware IDs, keys, scan, and internal STAs stayed live in software. Wi- Fi 7 devices can fail to recover after that suspend. The fix is the same cleanup mvm already does.
Risk is a single call under the lock already used for restart cleanup. Benefit is working wireless after D3cold/hibernate on common Intel hardware.
---
Verification:
- [Phase 1] git show 71ac392d8b5c2: subject/tags/body as above; SOB Grumbach + Korenblit; Link msgid; no Fixes/Reported-by/Cc stable
- [Phase 2] Diff: un-static iwl_mld_restart_cleanup, header prototype, +1 call in iwl_mld_device_powered_off; +4/−2
- [Phase 2] Parent of commit: device_powered_off was stop_fw + in_d3=false only
- [Phase 2] Current mld.c:743-753: call present under wiphy_lock
- [Phase 2] iwl_cleanup_mld / iwl_mld_cleanup_vif / iwl_mld_cleanup_sta / iwl_mld_ftm_restart_cleanup read in tree
- [Phase 3] git log -L on iwl_mld_device_powered_off: d1e879ec600f9 → 7aeec8c8d63bf → 71ac392d8b5c2
- [Phase 3] d1e879ec600f9 Makefile 6.14.0-rc4; ancestor of HEAD
- [Phase 3] git show 0a00c3ec2db76: mvm analog same day
- [Phase 3] git log -S iwl_mld_restart_cleanup -- mld/: only MLD add + this commit
- [Phase 3] 1c031ac5a39eb is a different chanctx/dead-device WARN, not a revert
- [Phase 4] b4 dig -c/-a/-w/-m: v2 15/15 iwlwifi-next; recipients Johannes + linux-wireless; mbox 16 series mails, no NAK
- [Phase 4] WebFetch lore/msgid: 403; used mbox instead
- [Phase 4] WebSearch stable@: other MLD restart fixes, not this subject
- [Phase 5] git grep iwl_op_mode_device_powered_off: pcie/drv.c:1281 from _iwl_pci_resume when powered off
- [Phase 5] mld.c includes mac80211.h
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion 7.3.0-rc4
- [Phase 6] git merge-base --is-ancestor 71ac392d8b5c2 HEAD: yes
- [Phase 8] Failure mode inferred from code + mvm message (reload **and** reconfigure); no crash dump in commit (stated)
- UNVERIFIED: public user reports; whether older LTS without this commit would be in scope (out of band — this verdict is 7.3-rc4 only)
**YES**
drivers/net/wireless/intel/iwlwifi/mld/mac80211.c | 3 +-- drivers/net/wireless/intel/iwlwifi/mld/mac80211.h | 2 ++ drivers/net/wireless/intel/iwlwifi/mld/mld.c | 1 + 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/mld/mac80211.c +1 -2
@@ -483,8 +483,7 @@ iwl_mld_mac80211_tx(struct ieee80211_hw *hw,iwl_mld_tx_skb (mld, skb,NULL ); } -static void -iwl_mld_restart_cleanup (struct iwl_mld *mld) +void iwl_mld_restart_cleanup (struct iwl_mld *mld) {iwl_cleanup_mld (mld);
drivers/net/wireless/intel/iwlwifi/mld/mac80211.h +2 -0
@@ -1,6 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ /* * Copyright (C) 2024 Intel Corporation +* Copyright (C) 2026 Intel Corporation */ #ifndef __iwl_mld_mac80211_h__#define __iwl_mld_mac80211_h__
@@ -9,5 +10,6 @@int iwl_mld_register_hw (struct iwl_mld *mld);void iwl_mld_recalc_multicast_filter (struct iwl_mld *mld); +void iwl_mld_restart_cleanup (struct iwl_mld *mld);#endif /* __iwl_mld_mac80211_h__ */
drivers/net/wireless/intel/iwlwifi/mld/mld.c +1 -0
@@ -739,6 +739,7 @@ static void iwl_mld_device_powered_off(struct iwl_op_mode *op_mode)wiphy_lock (mld->wiphy);iwl_mld_stop_fw (mld); +iwl_mld_restart_cleanup (mld); mld->fw_status.in_d3 = false;wiphy_unlock (mld->wiphy); }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 misc: rp1: clear chained IRQ handlers on teardown
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit 82aa033fef523ab4f0165afbc1c1fb0dadb89f94 ]
rp1_probe() installs a chained handler for each parent MSI-X vector and stores the rp1 device pointer as handler data. rp1_unregister_interrupts() then disposes the child IRQ mappings, removes the IRQ domain, and frees the PCI IRQ vectors without first removing those chained handlers.
If a teardown path runs after the handlers have been installed, a later parent IRQ can still call rp1_chained_handle_irq() with stale handler data and a removed IRQ domain. Clear the chained handlers before disposing mappings and freeing the vectors.
---
LLM Generated explanations, may be completely bogus:
This is a 3-line IRQ teardown UAF fix in the Raspberry Pi 5 RP1 driver. The local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The RP1 driver exists here (since v6.17), and the buggy teardown path is the original driver code.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[misc: rp1:] [clear] [chained IRQ handlers on teardown]**
- Subsystem: misc: rp1 (Raspberry Pi RP1 PCI misc driver)
- Verb: “clear” — teardown/cleanup of leftover IRQ state, not a feature add
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected for this review)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** Andrea della Porta <[email protected]> (RP1 maintainer per MAINTAINERS)
- **Acked-by:** none
- **Link:** https://patch.msgid.link/[email protected]
- **Cc: stable:** none (expected; not a negative)
- **Signed-off-by:** Pengpeng Hou (author); Greg Kroah-Hartman (char- misc)
- Ignore pipeline SOBs (none present on this commit)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** rp1_probe() installs chained handlers on parent MSI-X vectors with rp1 as handler data. rp1_unregister_interrupts() disposes mappings, removes the IRQ domain, and frees PCI vectors without uninstalling those handlers.
- **Failure mode:** A later parent IRQ can still call rp1_chained_handle_irq() with stale handler data and a removed IRQ domain → use-after-free / invalid irq_find_mapping() / crash.
- **Version info:** none in the message. Driver introduced in 49d63971f9634 (first in v6.17). Fix landed in v7.3-rc1.
- **Root cause:** missing irq_set_chained_handler_and_data(..., NULL, NULL) before domain teardown / pci_free_irq_vectors().
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is an explicit teardown bug fix (stale chained IRQ handler). Same class as many irqchip/PCI host drivers that clear chained handlers on remove.
===============================================================
PHASE 2: DIFF ANALYSIS
===============================================================
**Step 2.1: INVENTORY THE CHANGES** Record:
- File: drivers/misc/rp1/rp1_pci.c — **+3 / -0**
- Function: rp1_unregister_interrupts()
- Scope: single-file, surgical
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: Before: unregister disposed child mappings, irq_domain_remove(), then pci_free_irq_vectors(), leaving parent MSI-X vectors still pointing at rp1_chained_handle_irq + rp1. After:
those chained handlers/data are cleared first, then mappings/domain/vectors are torn down.
Callers of unregister (verified in this tree):
- rp1_probe() error path err_unregister_interrupts (domain create fail, mid-loop mapping fail, of_platform_default_populate fail)
- rp1_remove() after of_platform_depopulate()
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Memory safety / UAF + stale IRQ dispatch**
- rp1_chained_handle_irq() does irq_desc_get_handler_data(desc) then irq_find_mapping(rp1->domain, hwirq).
- After irq_domain_remove() that domain is gone; after unbind, rp1 is devm_kzalloc memory that will be freed.
- Mechanism of the fix: standard irq_set_chained_handler_and_data(irq, NULL, NULL) uninstall (kernel converts NULL → handle_bad_irq, masks, drops chained action). Verified in kernel/irq/chip.c.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct and the established pattern (many drivers do the same: pcie-mediatek, gpio-rockchip, irq-lan966x-oic, etc.). Minimal, no API change.
Regression risk: **low**. Clearing handlers that were never installed (domain-create failure before the install loop) is the same pattern other drivers use. irq_chip_pm_put() on uninstall is a no-op when irq_get_pm_device() is NULL, which is typical for these MSI-X vectors. pci_alloc_irq_vectors failure already goes to err_out, not unregister, so pci_irq_vector() is only used after vectors exist.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: Buggy rp1_unregister_interrupts() (and the chained-handler install loop) came from **49d63971f9634** (“misc: rp1: RaspberryPi RP1 misc driver”, Andrea della Porta, 2025-05-29). First contained in **v6.17**. Long-lived relative to 7.3; not last-month code.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Introduced-by is the original driver commit above. git merge-base --is-ancestor 49d63971f9634 HEAD is true in this tree.
**Step 3.3: CHECK FILE HISTORY**
Record: File history is small (8 commits). Related later commits (0764fd10406f3 OF-node put, d7f0b6a15dde2 irq_domain_create_linear) are independent, not prerequisites of this 3-line change. Standalone, not “patch X/Y”.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Pengpeng Hou is a contributor, not the RP1 maintainer. Same-area
follow-up: 0764fd10406f3 (separate OF refcount bug). Weight comes from **Reviewed-by Andrea della Porta** (listed maintainer) and Greg KH applying it.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Uses irq_set_chained_handler_and_data and pci_irq_vector, both long-standing. Applies standalone. No series.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 82aa033fef523 →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only**, no later revisions
- Thread (saved mbox): Andrea della Porta replied with **Reviewed-by** only. No NAK, no stable tag request, no risk flags.
- lore WebFetch returned 403; discussion recovered via b4 dig -m.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc included Andrea della Porta, Arnd Bergmann, Greg Kroah-Hartman, linux-kernel. Maintainer reviewed; Greg merged via char-misc.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla/Reported-by. Bug is from code inspection of the probe/remove teardown path. Still a real reachable path (probe error after handler install, and rp1_remove).
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone v1. Not part of a multi-patch series.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable WebFetch returned 403. **UNVERIFIED** whether stable@ already discussed this; no local git log --grep hit besides the commit itself.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: KEY FUNCTIONS**
Record: Modified: rp1_unregister_interrupts(). Related:rp1_chained_handle_irq(), rp1_probe(), rp1_remove().
**Step 5.2: TRACE CALLERS**
Record:
- rp1_probe() → err_unregister_interrupts (device enumeration / PCI probe; error after IRQ setup)
- rp1_remove() (module unload / PCI unbind)
Impact surface is this driver only. CONFIG_MISC_RP1 on Raspberry Pi 5.
**Step 5.3: TRACE CALLEES**
Record: pci_get_drvdata, irq_set_chained_handler_and_data, pci_irq_vector, irq_find_mapping, irq_dispose_mapping, irq_domain_remove, pci_free_irq_vectors. No new locks/allocs.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable from PCI probe and driver remove. Not a syscall hot path. Root/module unload or probe failure after MSI-X setup can trigger it. rp1_chained_handle_irq is hardirq/chained context — a stale call is an oops, not a recoverable error.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Clearing chained handlers with (irq, NULL, NULL) is widespread (PCI hosts, GPIO, irqchip). RP1 was missing that standard teardown.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** drivers/misc/rp1/rp1_pci.c is present. Install of chained handlers is still at probe lines 263–264. The missing-clear bug was in this file from 49d63971f9634 (v6.17). This checkout already contains the fix (82aa033fef523 is an ancestor of HEAD; first in **v7.3-rc1**). That is the mainline landing, not a reason to treat the bug as imaginary.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** to this tree’s RP1 file. Hunk is isolated in rp1_unregister_interrupts(). Later irq_domain_create_linear() switch does not conflict. Unregister body before the fix matches the posted diff.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This exact fix is already in this 7.3-rc4 checkout (mainline). No alternate/competing fix. Later OF-node and irq_domain commits do not supersede it.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: **drivers/misc/rp1** — RP1 PCI bridge on Raspberry Pi 5 (Ethernet, USB, I2C, SPI, UART). **IMPORTANT** (popular board, not core mm/net), not staging.
**Step 7.2: SUBSYSTEM ACTIVITY**
Record: Mature-enough but still receiving correctness fixes. Maintainer:
Andrea della Porta. Reviewed this patch.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: WHO IS AFFECTED**
Record: **Driver-specific / config-specific:** CONFIG_MISC_RP1, Raspberry Pi 5 (and any board with RP1 PCI ID PCI_VENDOR_ID_RPI / PCI_DEVICE_ID_RPI_RP1_C0).
**Step 8.2: TRIGGER CONDITIONS**
Record:
- Probe failure after chained handlers are installed (mapping fail mid- loop, DT populate fail)
- Device remove / module unload / PCI unbind after successful probe Not every boot. Not unprivileged-userspace-triggerable in the usual config (needs probe fail or admin unbind). Timing: any parent MSI-X after domain removal.
**Step 8.3: FAILURE MODE SEVERITY**
Record: Stale chained handler → rp1_chained_handle_irq() on removed domain / freed rp1 → **oops / UAF**. Severity: **HIGH** (crash; UAF is also a memory-safety issue).
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- Benefit: **high** for RP1/Pi 5 users (prevents IRQ oops/UAF on failed probe and unbind)
- Risk: **very low** (3 lines, standard API, maintainer-reviewed)
- Ratio: strongly in favor of including the fix in trees that have this driver
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR backporting:
- Real bug: chained IRQ handlers left installed across domain/vector teardown
- Failure is oops/UAF in hardirq context, not cosmetic
- Reachable on probe error and rp1_remove()
- 3-line, obviously correct, matches in-tree teardown idiom
- Reviewed by the RP1 maintainer; merged by Greg KH
- Driver exists in this tree; patch applies cleanly
- Raspberry Pi 5 is a widely deployed platform
AGAINST:
- No user/syzbot report (inspection-driven)
- No Fixes:/Cc: stable (expected here; not a veto)
- Peripheral misc driver, not core kernel
- Trigger is teardown/error, not the steady-state IRQ path
- lore.kernel.org/stable search could not be fetched (403)
UNRESOLVED:
- Whether stable@ already discussed this (WebFetch 403)
- No runtime reproduction log in the thread (reviewer still acked)
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — 3-line standard uninstall; maintainer Reviewed-by; in mainline since 7.3-rc1
2. Fixes a real bug that affects users? **PASS** — leftover chained handler on RP1 unbind/probe fail
3. Important issue? **PASS** — oops/UAF, HIGH (not a hang/corruption of fs, but crash/memory safety)
4. Small and contained? **PASS** — +3 lines, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — file/function exist; hunk matches; no missing helpers
**Step 9.3: EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary small bugfix.
**Step 9.4: DECISION**
This tree has the RP1 driver and the original teardown hole. The patch is a minimal, correct fix for a crash/UAF on IRQ teardown. It meets stable-kernel-rules. It should be in any tree that contains this driver — including this 7.3 lineage.
Verification:
- [Phase 1] Parsed tags: Reviewed-by Andrea della Porta (RP1 maintainer), Link to msgid 20260616151028.69890-1; no Fixes/Reported- by/Cc:stable
- [Phase 1] Body describes stale chained handler after domain/vector teardown
- [Phase 2] Diff: +3 lines in rp1_unregister_interrupts() only
- [Phase 2] Callers verified: rp1_probe error path line 276, rp1_remove line 286
- [Phase 2] Handler uses irq_desc_get_handler_data + irq_find_mapping(rp1->domain, ...) (rp1_pci.c 100–110)
- [Phase 2] irq_set_chained_handler_and_data(NULL) → __irq_do_set_handler uninstall path (kernel/irq/chip.c 950–988)
- [Phase 3] Blame: buggy unregister from 49d63971f9634; driver first in v6.17; git merge-base --is-ancestor 49d63971f9634 HEAD true
- [Phase 3] No Fixes: tag; no prerequisite series; later file commits unrelated
- [Phase 4] b4 dig -c 82aa033fef523: lore URL found; -a shows v1 only; -w lists Andrea/Arnd/Greg/lkml; mbox: Reviewed-by only, no NAK
- [Phase 4] lore WebFetch 403; stable@ search UNVERIFIED
- [Phase 5] Impact limited to MISC_RP1; chained handler in IRQ context
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4; origin is torvalds/linux.git
- [Phase 6] git merge-base --is-ancestor 82aa033fef523 HEAD true (fix in v7.3-rc1); buggy install loop still present; apply would be clean
- [Phase 7] MAINTAINERS: RASPBERRY PI RP1 PCI DRIVER → Andrea della Porta
- [Phase 8] Failure mode: oops/UAF on parent IRQ after teardown; severity HIGH; risk very low
- UNVERIFIED: stable mailing-list history (HTTP 403)
The fix is small, surgical, and meets all stable kernel criteria.
**YES**
drivers/misc/rp1/rp1_pci.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/misc/rp1/rp1_pci.c +3 -0
@@ -171,6 +171,9 @@ static void rp1_unregister_interrupts(struct pci_dev *pdev)struct rp1_dev *rp1 =pci_get_drvdata (pdev);int irq, i; +for (i =0 ; i <RP1_INT_END ; i++) +irq_set_chained_handler_and_data (pci_irq_vector (pdev, i),NULL ,NULL ); +if (rp1->domain) {for (i =0 ; i <RP1_INT_END ; i++) { irq =irq_find_mapping (rp1->domain, i);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 irqdomain: Plug leak in irq_domain_alloc_irqs_locked() error path
In reply to Sasha LevinFrom: Kemeng Shi <[email protected]>
[ Upstream commit 13856e22217fbf7c1200633716ff87ccb50fd89a ]
When irq_domain_trim_hierarchy() fails in irq_domain_alloc_irqs_locked(), the error handling path fails to undo the hierarchy allocations.
Add the missing cleanup.
[ tglx: Massage change log ]
---
LLM Generated explanations, may be completely bogus:
This 6.18.53 tree has the buggy irqdomain error path. The 4-line rollback is a real hierarchy-resource leak fix and should be backported.
## Phase 1: Commit message forensics
**Step 1.1:** Record: `[irqdomain] [Plug] leak inirq_domain_alloc_irqs_locked() error path`
**Step 1.2:** Record:
- No Fixes: on the committed message (v2 later added `Fixes:
55567976629e5`)
- No Reported-by / Tested-by / Reviewed-by / Acked-by / `Cc:
stable`
- Signed-off-by: Kemeng Shi, Signed-off-by: Thomas Gleixner
- `Link: https://patch.msgid.link/20260623075134.4432-2-
[email protected]`
- Ignore pipeline Signed-off-by: Sasha Levin and [Upstream commit ...]
**Step 1.3:** Record:
- Bug: after irq_domain_alloc_irqs_hierarchy() succeeds, a irq_domain_trim_hierarchy() failure skips domain->ops->free
- Symptom: parent-domain IRQ / irqchip resources stay allocated while virq descriptors are freed
- Root cause: error goto used out_free_irq_data instead of hierarchy free
- Original v1 text: “unlikely to fail, but there is no harm to add extra protection”
- tglx retitled it to a leak plug
**Step 1.4:** Record: Not disguised. It is an error-path resource-leak fix. The series cover called it a “minor” learning cleanup; the code change is still a real rollback hole.
## Phase 2: Diff analysis
**Step 2.1:** Record: kernel/irq/irqdomain.c only; +3/−1. Function:irq_domain_alloc_irqs_locked(). Surgical single-file change.
**Step 2.2:** Record: On trim failure the old path jumped to out_free_irq_data (irq_domain_free_irq_data + irq_free_descs).
After: jump to new out_free_irqs, which calls irq_domain_free_irqs_hierarchy() then falls through. Success path unchanged.
**Step 2.3:** Record: Error-path resource leak. Hierarchy ops->alloc already ran; missing ops->free. irq_domain_free_irq_data() only kfrees irq_data nodes and does not undo irqchip/parent mappings.
**Step 2.4:** Record: Obviously correct. Same order as irq_domain_free_irqs() (hierarchy free, then irq_data, then descs), minus irq_domain_remove_irq() because insert has not run. Only the trim-failure path. Low regression risk:irq_domain_free_irqs_hierarchy() already skips IRQs with no irq_data and no-ops if ops->free is NULL.
## Phase 3: Git history
**Step 3.1:** Record: Trim loop added in 55567976629e58 (“Allow partial trimming of irq_data hierarchy”), first in **v5.10-rc1**. Hierarchy alloc itself dates to f8264e34965aaf (v3.19). The broken goto is as old as the trim call.
**Step 3.2:** Record: Committed message has no Fixes tag. Author v2 added Fixes: 55567976629e5. That commit is an ancestor of this 6.18 tree (git describe --contains → v5.10-rc1~...).
**Step 3.3:** Record: Recent file history is irqdomain refactors plus this series. No extra prerequisite refactor needed. irq_domain_free_irqs_hierarchy() already exists here.
**Step 3.4:** Record: Kemeng Shi is not the irq maintainer; tglx applied it. Same series also has the helper-use and NULL-check cleanups (not required for this leak).
**Step 3.5:** Record: Standalone. Other series patches are cleanups. No new helpers.
## Phase 4: Mailing list
**Step 4.1:** Record: lore.kernel.org returned 403 (Anubis). Recovered via b4 + gnuweeb/ratatoskr/lkml.iu.edu.
- Cover: [PATCH 0/3] Minor fix and cleanups to genirq
- Patch 1/3 is this leak fix
- tglx merged v1 on 2026-06-29 as 13856e22217fbf7c1200633716ff87ccb50fd89a
- v2 (2026-07-02) only added Fixes + changelog; same diff; tglx had already taken v1
- No NAKs in the 7-message thread
**Step 4.2:** Record: To tglx, Cc linux-kernel. tip-bot also Cc’d maz and x86. Maintainer applied it.
**Step 4.3:** Record: No bugzilla/syzbot/user report. Code inspection while learning irq.
**Step 4.4:** Record: Series is 3 patches; only 1/3 is the leak fix. Independent.
**Step 4.5:** Record: No stable-list discussion found (commit is new relative to 6.18.53).
## Phase 5: Semantic analysis
**Step 5.1:** Record: irq_domain_alloc_irqs_locked() (hierarchy version under CONFIG_IRQ_DOMAIN_HIERARCHY).
**Step 5.2:** Record: Callers: __irq_domain_alloc_irqs() (public, irq_domain_alloc_irqs() wrapper) and OF/hierarchy mapping around kernel/irq/irqdomain.c:945. Used from MSI (kernel/irq/msi.c), IPI, x86 IOAPIC, GIC, gpiolib, many irqchips.
**Step 5.3:** Record: irq_domain_alloc_irqs_hierarchy → domain->ops->alloc; trim; insert. Locked with domain->root->mutex.
**Step 5.4:** Record: Reachable from device probe / irq_create_fwspec_mapping / MSI alloc. Unprivileged users do not call it directly; drivers do at probe. Trim failure is -EINVAL for invalid chip chain (NULL/ERR outermost chip, empty chip before a trim marker, chip after a trim marker, non--ENOTCONN marker). Disconnect users:
tegra PMC, qcom PDC/MPM.
**Step 5.5:** Record: Success-path irq_domain_free_irqs() already does hierarchy free. The alloc-failure path still skips ops->free because failed ops->alloc is expected to roll itself back. Trim failure is after a **successful** alloc, so it uniquely needs ops->free.
## Phase 6: Local tree (6.18.53)
**Step 6.1:** Record: git describe HEAD = v6.18.53-5049-g0f0bdc2b0dffb, make kernelversion = 6.18.53. At v6.18.53 the trim-failure path still goto out_free_irq_data. Bug exists here. Introduced v5.10.
**Step 6.2:** Record: Clean apply. Context matches 6.18.53 exactly.
**Step 6.3:** Record: No earlier equivalent fix in this tree. irq_domain_push_irq leak fix (0f394daef89b3) is a different bug.
## Phase 7: Subsystem
**Step 7.1:** Record: kernel/irq/ irqdomain. **CORE** for any hierarchical irqdomain (x86 selects IRQ_DOMAIN_HIERARCHY unconditionally; ARM GIC/MSI too).
**Step 7.2:** Record: Mature core code; trim path ~5.5 years old. Not a new subsystem.
## Phase 8: Impact and risk
**Step 8.1:** Record: Hierarchical irqdomain users (typical x86/ARM/MSI systems). Config-specific in theory; practically common.
**Step 8.2:** Record: Trigger is failed hierarchy validation after a successful ops->alloc. Uncommon on correct irqchip drivers. Author:
“unlikely to fail.” Not a hot path; probe/mapping time.
**Step 8.3:** Record: Failure mode = leak of parent IRQ / irqchip resources (not just kmalloc). Can exhaust parent IRQs and make later devices fail to allocate interrupts. Severity: **MEDIUM** (rare), **HIGH** if it hits because the resource is finite hardware state. Not a panic by itself.
**Step 8.4:** Record: Benefit medium (correct unwind of core IRQ alloc). Risk very low (4 lines, error path only, existing helper). Ratio favors backport.
## Phase 9: Synthesis
**For:**
- Confirmed missing rollback after successful hierarchy alloc
- Leaks irqchip/parent mappings, not only heap objects
- 4-line, obviously correct, matches irq_domain_free_irqs()
- Present since v5.10; present on 6.18.53; applies cleanly
- tglx accepted it; v2 named 55567976629e5 as the introducing commit
- No new API, no series dependency
**Against:**
- Author called it unlikely extra protection
- No user/syzbot reports
- Not a crash/UAF/deadlock
- Trigger is a malformed hierarchy, i.e. a driver/firmware mistake
**Unresolved:** Full lore HTML was 403; mirrors showed no review comments beyond tglx applying v1.
**Stable checklist:**
1. Obviously correct and tested? **PASS** (tglx applied; logic matches existing free path)
2. Real bug affecting users? **PASS** (leak of allocated hierarchy IRQs)
3. Important? **PASS** (finite irqchip resources; core alloc unwind; small enough that the bar is met)
4. Small and contained? **PASS** (+3/−1, one function)
5. No new features/APIs? **PASS**
6. Applies to this tree? **PASS** (clean on 6.18.53)
**Exception category:** none; ordinary error-path leak fix.
The path is rare, but the hole is real and the patch is the same cleanup irq_domain_free_irqs() already does. For this 6.18.y tree it is a safe, self-contained correctness fix.
Verification:
- [Phase 1] Tags: SOB Kemeng Shi + tglx; Link msgid 4432-2; no Fixes on committed text
- [Phase 1] v1 body: “unlikely to fail… extra protection”; tglx massaged to “Plug leak”
- [Phase 2] Diff: goto out_free_irqs + irq_domain_free_irqs_hierarchy(domain, virq, nr_irqs)
- [Phase 2] Confirmed irq_domain_free_irq_data() only kfree’s parent irq_data; does not call ops->free
- [Phase 3] blame: trim loop from 55567976629e58 (v5.10-rc1)
- [Phase 3] v6.18.53:kernel/irq/irqdomain.c still goto out_free_irq_data on trim failure
- [Phase 4] b4 dig → tip-bot merge 13856e22217fbf7c1200633716ff87ccb50fd89a; cover “Minor fix and cleanups”
- [Phase 4] lore 403; gnuweeb/ratatoskr recovered v1 and v2; v2 Adds
- [Phase 5] Callers: __irq_domain_alloc_irqs, OF map path, MSI, IOAPIC, GIC
- [Phase 5] Disconnect users: tegra PMC, qcom PDC/MPM
- [Phase 6] git describe HEAD = v6.18.53-5049; make kernelversion = 6.18.53
- [Phase 6] Clean apply vs v6.18.53; irq_domain_free_irqs_hierarchy already present
- [Phase 7] x86 select IRQ_DOMAIN_HIERARCHY
- [Phase 8] Severity: resource leak on rare -EINVAL trim; risk of later IRQ alloc failure
- UNVERIFIED: Could not load lore.kernel.org HTML due to 403; used b4 + mirrors instead
**YES**
kernel/irq/irqdomain.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/irq/irqdomain.c +3 -1
@@ -1621,7 +1621,7 @@ static int irq_domain_alloc_irqs_locked(struct irq_domain *domain, int irq_base,for (i =0 ; i < nr_irqs; i++) { ret =irq_domain_trim_hierarchy (virq + i);if (ret) - goto out_free_irq_data; + goto out_free_irqs; }for (i =0 ; i < nr_irqs; i++)
@@ -1629,6 +1629,8 @@ static int irq_domain_alloc_irqs_locked(struct irq_domain *domain, int irq_base,return virq; +out_free_irqs: +irq_domain_free_irqs_hierarchy (domain, virq, nr_irqs); out_free_irq_data:irq_domain_free_irq_data (virq, nr_irqs); out_free_desc:
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 net: stmmac: use dma_addr_t for DMA addresses
In reply to Sasha LevinFrom: Alex Elder <[email protected]>
[ Upstream commit 0c1f9020d2ada55aed8a2e055903ad9cd5d49dab ]
In jumbo_frm() (implemented in both "chain_mode.c" and "ring_mode.c"), an unsigned integer local variable is used to hold the value returned by dma_map_single(). On systems where a dma_addr_t is 64 bits, the subsequent dma_mapping_error() check of the returned value operates only on the low 32 bits (whose high bit won't be sign-extended). In this case, dma_mapping_error() would return 0 (no error) even if there were one.
Fix this in both spots by using a dma_addr_t for the local variable.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). The buggy unsigned int des2 path is present here, and this type-correctness fix should be backported.
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [net: stmmac] [use] [store dma_map_single() results as dma_addr_t in jumbo_frm()]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Reported-by: Sashiko <[email protected]> — static-analysis bot, not a user crash
- `Link: https://lore.kernel.org/linux-
devicetree/[email protected]/` — Sashiko report
- Reviewed-by: Maxime Chevallier <[email protected]> — stmmac/netdev reviewer
- Signed-off-by: Alex Elder <[email protected]> — author
- `Link:
https://patch.msgid.link/[email protected]` — v2 1/2 of a net-next series
- Signed-off-by: Jakub Kicinski <[email protected]> — net maintainer
- No Fixes: tag (expected)
- No Cc: stable (expected)
- Ignore pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] if present on a candidate wrapper
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** jumbo_frm() in chain_mode.c and ring_mode.c stores dma_map_single() in unsigned int des2. On 64-bit dma_addr_t, dma_mapping_error() only sees the low 32 bits.
- **Symptom:** a failed mapping is treated as success (dma_mapping_error() returns 0).
- **Root cause:** DMA_MAPPING_ERROR is ~(dma_addr_t)0 (0xFFFFFFFFFFFFFFFF on 64-bit). Truncating to unsigned int yields 0xFFFFFFFF, which promotes to 0x00000000FFFFFFFF and does not match all-ones.
- **Version info:** none in the message. The pattern dates to at least 2016 (f8be0d78be6e7).
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. It is an explicit correctness fix for a truncated DMA error check. Changing des2 to dma_addr_t also stops truncating the address stored in tx_skbuff_dma[].buf (dma_addr_t) used for later unmap.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- drivers/net/ethernet/stmicro/stmmac/chain_mode.c: +2/−1
- drivers/net/ethernet/stmicro/stmmac/ring_mode.c: +2/−1
- Functions: jumbo_frm() in both files
- Scope: single-function surgical type change in two parallel implementations (4 insertions, 2 deletions)
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** unsigned int des2 = dma_map_single(...); then cpu_to_le32(des2), dma_mapping_error(..., des2), tx_skbuff_dma[entry].buf = des2.
- **After:** dma_addr_t des2 so the error check and buf store use the full DMA address.
- Path: jumbo TX mapping in stmmac_xmit() when enh_desc is set and the frame is large enough (>= 4KiB ring / > 8KiB chain).
- Same local is reused for later dma_map_single() calls in those functions, so all mapping sites in jumbo_frm() are fixed.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** type / width bug that breaks error detection (and truncates unmap addresses).
- **Mechanism:** 32-bit truncation of a 64-bit dma_addr_t so dma_mapping_error() never sees DMA_MAPPING_ERROR.
- Verified in this tree:
```92:98:include/linux/dma-mapping.h
static inline int dma_mapping_error(struct device *dev, dma_addr_t
dma_addr)
{
debug_dma_mapping_error(dev, dma_addr);
if (unlikely(dma_addr == DMA_MAPPING_ERROR))
return -ENOMEM;
return 0;
}
```DMA_MAPPING_ERROR is ~(dma_addr_t)0. The current buggy locals:
```23:41:drivers/net/ethernet/stmicro/stmmac/chain_mode.c
unsigned int bmax, buf_len, des2;
...
des2 = dma_map_single(priv->device, skb->data,
buf_len, DMA_TO_DEVICE);
desc->des2 = cpu_to_le32(des2);
if (dma_mapping_error(priv->device, des2))
return -1;
tx_q->tx_skbuff_dma[entry].buf = des2;
```**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: use the type dma_map_single() actually returns.
- Minimal; no API or behavior change on the success path with a 32-bit DMA mask.
- Regression risk is low. desc->des2 is still __le32, so hardware still gets the low 32 bits (same as before). Maxime asked to make that truncation explicit; that is the follow-up c11c497af866c (lower_32_bits()), not required for this fix to be correct.
- cpu_to_le32() already casts to __u32 on little-endian; standalone apply should not break the build.
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- unsigned int ... des2 in ring_mode: f8be0d78be6e7 (2016-11-15, “change dma descriptors to __le32”).
- chain_mode declaration last touched by 2c91b39912278 (already in this tree: “fix integer underflow in chain mode”); that commit kept unsigned int des2.
- jumbo_frm() itself: 286a837217204 (2011).
- Bug is long-standing, not new in 6.12.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Introducer is the 2011/2016 DMA-descriptor code, present in this tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record (this tree):
- 2c91b39912278 net: stmmac: fix integer underflow in chain mode (already here)
- 133160135a6d7 STMMAC_GET_ENTRY rename
- Mainline follow-up: c11c497af866c net: stmmac: convert DMA address to lower 32 before assignment (clarity; not in this tree; not a functional prerequisite)
- This is standalone 1/2 of “DMA address handling fixes”; 2/2 is style/clarity.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Alex Elder is not the stmmac maintainer; two origin stmmac commits are this pair. Reviewed by Maxime Chevallier; applied by Jakub Kicinski.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: No new helpers. dma_addr_t and dma_mapping_error() exist here. git apply --check of 0c1f9020d2ada succeeded on this tree. Parent-tree vs this tree only differs in is_jumbo_frm() (untouched). Standalone apply: yes.
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 0c1f9020d2ada →
https://patch.msgid.link/[email protected]
- Series: v1 2026-08-11; v2 2026-08-12 `[PATCH net-next v2 0/2] net:
stmmac: DMA address handling fixes`
- Applied to **net-next** (not net) by Jakub on 2026-08-17
- Cover: “ensure DMA errors don't get lost due to casting the result to an integer of the wrong size”
- No NAKs. Maxime: “I think this is good as-is” + Reviewed-by
- Maxime noted cpu_to_le32(des2) still truncates into __le32 and doubted jumbo on true 64-bit descriptor addresses; that is pre- existing hardware-descriptor width, not a regression from this patch
- No reviewer Cc: stable
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): netdev maintainers (Kicinski, Dal, Pabeni, Lunn), STM32/stmmac (Torgue, Coquelin), Maxime Chevallier. Appropriate audience.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: Sashiko static analysis, not syzbot and not a user oops. The lore linux-devicetree link is a bot dump; no independent user reproduction was found. The bug is still visible in the code.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Companion 2/2 (c11c497af866c) only wraps cpu_to_le32(lower_32_bits(des2)). This commit is the actual fix.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org returned HTTP 403 via WebFetch. b4 thread has no stable discussion. UNVERIFIED: whether this hash was already requested on stable@; that does not change the technical verdict.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: jumbo_frm() in chain_mode.c and ring_mode.c.
**Step 5.2: TRACE CALLERS**
Record:
- stmmac_jumbo_frm() macro → hw->mode->jumbo_frm
- Only call site: stmmac_xmit() when priv->plat->enh_desc and is_jumbo_frm(skb->len)
- Context: process / NAPI TX, not IRQ
- dwmac4_ring_mode_ops (DWMAC ≥ 4.00) has no jumbo_frm; those chips do not use this path
- Affected: DWMAC100 / DWMAC1000 (and early DWMAC4 that still install ring_mode_ops/chain_mode_ops) with enhanced descriptors
**Step 5.3: TRACE CALLEES**
Record: dma_map_single(), dma_mapping_error(), cpu_to_le32(), stmmac_prepare_tx_desc(). On error, return -1 → stmmac_xmit goto dma_map_err.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: userspace send / jumbo MTU → ndo_start_xmit = stmmac_xmit → jumbo_frm. TSO/GSO with priv->tso uses stmmac_tso_xmit instead. Reachable from userspace on jumbo MTU. Mapping failure is an error path (IOMMU / swiotlb pressure).
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: non-jumbo TX in stmmac_xmit already uses dma_addr_t des. This is leftover jumbo-path width mismatch. Historical related fix in-
tree: 06a80a7d09cc3 (descriptor addresses >32-bit).
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. Local tree is **6.12.111** (p-6.12-3-gc504cf0baa3d8). Both files still have unsigned int ... des2. Introduced no later than 2016; present since this series branched. git merge-base --is-ancestor 0c1f9020d2ada HEAD is false (fix not here).
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Expected **clean apply**. git show 0c1f9020d2ada | git apply --check succeeded. Only unrelated is_jumbo_frm() signature drift vs mainline parent.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No dma_addr_t jumbo_frm fix in this tree. 2c91b39912278 is a different jumbo underflow fix and left des2 as unsigned int.
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/net/ethernet/stmicro/stmmac — Synopsys DWMAC, used on STM32, Rockchip, Allwinner, i.MX, Qualcomm, Intel, etc. Criticality:
**IMPORTANT** (common Ethernet), this path **PERIPHERAL-to-IMPORTANT** (older GMAC + jumbo).
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained, but chain_mode.c/ring_mode.c jumbo logic is mature (2011). This is an old bug, not churn from new code.
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver-specific, config CONFIG_STMMAC_ETH, older DWMAC with enh_desc, jumbo frames, **and** 64-bit dma_addr_t (typical arm64/x86_64). 32-bit dma_addr_t already compared equal to DMA_MAPPING_ERROR.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Jumbo TX (skb->len >= 4KiB ring / > 8KiB chain) plus dma_map_single() failure. Not every packet. Unprivileged users can send jumbo frames if MTU allows; they cannot force IOMMU exhaustion easily. Mapping failure is uncommon but real.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- Failed mapping treated as success
- Descriptor programmed with 0xFFFFFFFF
- NIC DMAs from that address (wrong memory / bus error / possible leak of physical memory onto the wire)
- tx_skbuff_dma[].buf also truncated, so unmap can be wrong
- Severity: **HIGH** (wrong DMA address / potential corruption). Not a guaranteed panic on every jumbo packet.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** medium-high for affected 64-bit DWMAC jumbo users; closes a real DMA error-handling hole
- **Risk:** very low (2-line type change per file, no locking/API change)
- **Ratio:** favorable
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real, verifiable type bug: truncated dma_mapping_error() on 64-bit dma_addr_t
- Failure can program the NIC with a bogus DMA address
- Also stores a full address in tx_skbuff_dma[].buf
- ~6 lines, obviously correct, reviewed, applied by net maintainer
- Buggy code is in this 6.12 tree and has been for years
- Patch applies cleanly
- Same driver already uses dma_addr_t on the normal TX path
AGAINST:
- Submitted to **net-next**, not net (not treated as an urgent regression)
- Sashiko/static analysis, no user oops
- Jumbo + older GMAC + mapping failure is a narrow trigger
- Reviewer noted 32-bit descriptors cannot represent full 64-bit addresses (pre-existing)
- Companion lower_32_bits() patch is not included (optional clarity)
UNRESOLVED:
- Stable@ archives not readable via WebFetch (403)
- Exact Sashiko warning text in the large 47-message dump was not isolated beyond the type issue this patch names
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — type matches DMA API; reviewed; in mainline since 2026-08-17
2. Fixes a real bug that affects users? **PASS** — missed DMA mapping errors on 64-bit dma_addr_t
3. Important issue? **PASS** — wrong DMA address on mapping failure (corruption / crash / possible leak), even if the window is uncommon
4. Small and contained? **PASS** — 6 lines, two files, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — git apply --check clean on 6.12.111
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not a device ID/quirk/DT/build/docs exception). Qualifies as a normal small bugfix.
**Step 9.4: MAKE YOUR DECISION**
The local 6.12 tree still truncates dma_map_single() to unsigned int in jumbo_frm(), so dma_mapping_error() cannot see DMA_MAPPING_ERROR on 64-bit dma_addr_t. That is a real DMA correctness bug, the fix is surgical, and it applies here without prerequisites. Narrow trigger does not outweigh the severity of programming a failed mapping into the NIC.
### What the commit solves and why it matters to stable users On 64-bit dma_addr_t platforms, a failed jumbo TX mapping is misclassified as success, and the MAC may DMA using 0xFFFFFFFF. 6.12 users of DWMAC1000-class stmmac with jumbo MTU on arm64/x86_64 are exposed.
### Stable rules / risk
Meets the stable bar: real bug, small, no new API, clean apply. Risk is a type change of a local. Benefit is correct mapping-error handling and a full-width unmap address.
### Concerns
Optional follow-up c11c497af866c only makes 32-bit descriptor truncation explicit; not required. No need to wait for other series patches.
## Verification
- [Phase 1] Parsed tags: Sashiko Reported-by, Maxime Reviewed-by, Jakub SOB; no Fixes/Cc stable
- [Phase 1] Body: truncated dma_mapping_error() on 64-bit dma_addr_t
- [Phase 2] Diff: unsigned int des2 → dma_addr_t des2 in both jumbo_frm() implementations (+4/−2)
- [Phase 2] include/linux/dma-mapping.h: dma_mapping_error() compares to DMA_MAPPING_ERROR (~(dma_addr_t)0)
- [Phase 2] Local chain_mode.c/ring_mode.c still use unsigned int des2; tx_skbuff_dma[].buf is dma_addr_t
- [Phase 3] Blame: f8be0d78be6e7 (2016) / 286a837217204 (2011); in this tree
- [Phase 3] Mainline SHA 0c1f9020d2ada; follow-up c11c497af866c is clarity-only
- [Phase 3] git merge-base --is-ancestor 0c1f9020d2ada HEAD → not in this tree
- [Phase 4] b4 dig -c 0c1f9020d2ada: lore/msgid v2 1/2 net-next series; applied to netdev/net-next
- [Phase 4] b4 dig -a: v1 then v2; Maxime suggested lower_32_bits(), still Reviewed-by on the type fix
- [Phase 4] b4 dig -w: netdev + STM32/stmmac CCs
- [Phase 4] mbox cover: “DMA errors don't get lost due to casting”
- [Phase 4] UNVERIFIED: stable@ mailing list (lore 403)
- [Phase 5] Callers: stmmac_xmit() → stmmac_jumbo_frm(); DWMAC4 ≥ 4.00 ops have no jumbo_frm
- [Phase 5] Non-jumbo TX already uses dma_addr_t des
- [Phase 6] git describe HEAD / make kernelversion: 6.12.111
- [Phase 6] git apply --check of 0c1f9020d2ada: success
- [Phase 6] git diff 0c1f9020d2ada^ -- chain_mode.c ring_mode.c: only is_jumbo_frm() drift
- [Phase 8] Failure mode: missed mapping error → NIC DMA at 0xFFFFFFFF; severity HIGH
- UNVERIFIED: isolated full text of the original Sashiko diagnostic line
**YES**
drivers/net/ethernet/stmicro/stmmac/chain_mode.c | 3 ++- drivers/net/ethernet/stmicro/stmmac/ring_mode.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/chain_mode.c +2 -1
@@ -20,9 +20,10 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, struct sk_buff *skb,unsigned int nopaged_len =skb_headlen (skb);struct stmmac_priv *priv = tx_q->priv_data;unsigned int entry = tx_q->cur_tx; -unsigned int bmax, buf_len, des2; +unsigned int bmax, buf_len;unsigned int i =1 , len;struct dma_desc *desc; +dma_addr_t des2; desc = tx_q->dma_tx + entry;
drivers/net/ethernet/stmicro/stmmac/ring_mode.c +2 -1
@@ -20,8 +20,9 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, struct sk_buff *skb,unsigned int nopaged_len =skb_headlen (skb);struct stmmac_priv *priv = tx_q->priv_data;unsigned int entry = tx_q->cur_tx; -unsigned int bmax, len, des2; +unsigned int bmax, len;struct dma_desc *desc; +dma_addr_t des2;if (priv->extend_desc) desc = (struct dma_desc *)(tx_q->dma_etx + entry);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ksmbd: fix heap out-of-bounds write in krb5_authenticate()
In reply to Sasha LevinFrom: Ilan Dudnik <[email protected]>
[ Upstream commit 23a0be6a84a38ac169eeab49017934e8e27c65f0 ]
In krb5_authenticate(), out_len is calculated to determine available headroom in response_buf for the incoming Kerberos AP-REP token. However, when SMB2_SESSION_SETUP is processed as a non-first element of a compounded SMB2 request, the calculation omits work->next_smb2_rsp_hdr_off.
This causes out_len to overstate remaining buffer headroom by the cumulative size of prior responses in the compound chain. Consequently, the length check in ksmbd_krb5_authenticate()
(*out_len <= resp->spnego_blob_len) passes erroneously, allowing memcpy() to write the AP-REP blob past the end of response_buf into adjacent kernel heap memory.
Fix this by subtracting work->next_smb2_rsp_hdr_off when computing out_len, ensuring it accurately reflects physical remaining buffer space.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). The buggy out_len math is present, and the one-line heap-OOB fix applies here.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ksmbd] [fix] heap out-of-bounds write in krb5_authenticate()
- Subsystem: ksmbd (in-kernel SMB3 server)
- Action verb: **fix**
- Claimed intent: stop a heap OOB write while building a Kerberos AP-REP in krb5_authenticate()
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Upstream commit: 23a0be6a84a38ac169eeab49017934e8e27c65f0 (verified via git show on origin/master)
Tags present:
- Signed-off-by: Ilan Dudnik \<[email protected]\> (author; SafeBreach threat research)
- Signed-off-by: Namjae Jeon \<[email protected]\> (ksmbd maintainer, committer)
Tags absent (expected for this review pipeline):
- No Fixes:
- No Cc: [email protected]
- No Reported-by: / Tested-by: / Reviewed-by: / Acked-by: / Link:
Notable: author is a security researcher; the ksmbd maintainer applied the patch directly.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** out_len is computed from work->response_sz minus SecurityBufferOffset + 4, and does not subtract work->next_smb2_rsp_hdr_off.
- **When:** SMB2 SESSION_SETUP as a **non-first** compound command (next_smb2_rsp_hdr_off > 0).
- **Symptom:** out_len overstates remaining heap by the size of prior compound responses. ksmbd_krb5_authenticate() then accepts a blob that does not actually fit, and memcpy() writes the AP-REP past response_buf.
- **Failure mode:** kernel **heap out-of-bounds write**.
- **Version info in message:** none. Code has been this way since ksmbd was added.
- **Root cause:** remaining-space calculation uses the start of the allocation, not the current compound slot.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Explicit heap-OOB write fix. Not cleanup/refactor.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: fs/smb/server/smb2pdu.c — **+1 / -1** (one line)
- Function: krb5_authenticate()
- Scope: **single-file surgical fix**
```2160:2164:fs/smb/server/smb2pdu.c
out_blob = (char *)&rsp->hdr.ProtocolId +
le16_to_cpu(rsp->SecurityBufferOffset);
- out_len = work->response_sz -
+ out_len = work->response_sz - work->next_smb2_rsp_hdr_off -
(le16_to_cpu(rsp->SecurityBufferOffset) + 4);
```**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** out_len = response_sz - (SecurityBufferOffset + 4) = space from the **start** of the SMB payload to the end of the allocation.
- **After:** also subtract next_smb2_rsp_hdr_off, i.e. space from the **current** compound response to the end of the allocation.
- Path: Kerberos SESSION_SETUP after ksmbd_ipc_spnego_authen_request() succeeds, immediately before memcpy(out_blob, ...).
- First-in-compound (next_smb2_rsp_hdr_off == 0): behavior unchanged.
Verified layout in this tree:
- ksmbd_resp_buf_next() = response_buf + next_smb2_rsp_hdr_off + 4
- WORK_BUFFERS uses that for non-first compound commands
- out_blob = rsp + SecurityBufferOffset
- Remaining bytes = response_sz - next_smb2_rsp_hdr_off - SecurityBufferOffset - 4
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** (d) memory safety — heap buffer overflow / OOB write
- **Mechanism:** length check *out_len <= resp->spnego_blob_len in ksmbd_krb5_authenticate() uses an inflated out_len. Check passes; memcpy(out_blob, resp->payload + session_key_len, resp->spnego_blob_len) writes off the end of response_buf.
- Confirmed memcpy in this tree:
```533:572:fs/smb/server/auth.c
if (*out_len <= resp->spnego_blob_len) {
ksmbd_debug(AUTH, "buf len %d, but blob len %d\n",
*out_len, resp->spnego_blob_len);
retval = -EINVAL;
goto out;
}
...
memcpy(out_blob, resp->payload + resp->session_key_len,
resp->spnego_blob_len);
```**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: remaining space must exclude prior compound responses.
- Minimal: one term added to one expression.
- Regression risk: **very low**.
- First command: next_smb2_rsp_hdr_off is 0 (work is zeroed).
- If out_len goes negative, *out_len <= blob_len is true → -EINVAL, no memcpy (fail closed).
- No API/data-structure/locking changes.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- out_len = work->response_sz - introduced in e2f34481b24db2 (“cifsd: add server-side procedures for SMB3”, 2021-05-10). Ancestor of HEAD.
- Offset term (SecurityBufferOffset + 4) from cb4517201b8acd (“ksmbd: remove smb2_buf_length in smb2_hdr”, 2021-11-11).
- Bug has been in ksmbd since it entered the kernel (~5.15), including 6.12.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Introducer is e2f34481b24db2, present in this tree (git merge-base --is-ancestor exit 0).
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- 98422bdd4cb3c “ksmbd: fix out of bounds read in smb2_sess_setup” (in this tree): compound SESSION_SETUP used smb2_get_msg() on the **start** of the buffer → OOB **read**. ZDI-CAN-21355. They passed req/rsp from WORK_BUFFERS but **did not** fix out_len.
- Other compound OOB fixes already in 6.12 (smb2_get_ea, QUERY_INFO, get_file_all_info) show this class of bug is real and has been backported before.
- This commit is standalone (not N/M).
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record:
- Ilan Dudnik: two ksmbd security fixes in 7.3 (23a0be6a84a38 and 29f74f0f2e6df UAF/double-free in lock publishing). Not a regular in- tree 6.12 contributor.
- Namjae Jeon is the ksmbd maintainer and committed this.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Record:
- Mainline krb5_authenticate() later grew channel_key / auth_key; **6.12 does not have those**. The changed out_len lines are the same.
- next_smb2_rsp_hdr_off exists in ksmbd_work.h here.
- git show 23a0be6a84a38 | git apply --check **succeeds** on this tree.
- Standalone: **yes**.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 23a0be6a84a38: lore returned errors; no thread match.
- curl lore linux-cifs / all for Ilan Dudnik and krb5_authenticate heap: **no public thread**.
- Likely private maintainer submission (typical for a security-firm heap overflow).
- Landed via ksmbd-for-7.3-rc1 pull (Namjae Jeon, 2026-08-23). Pull
text: “Fix heap out-of-bounds accesses … in authentication, Kerberos …”.
- Contained in v7.3-rc1~77^2~32.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: No public review trail. Signed off and committed by Namjae Jeon (MAINTAINERS: KERNEL SMB3 SERVER). That is maintainer-acked.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla/CVE found for **this** heap OOB (other 2026 ksmbd CVEs are different bugs). Author affiliation is independently verified (SafeBreach). UNVERIFIED: no public reproducer.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Same-author sibling 29f74f0f2e6df is a different bug (lock UAF). This out_len change does not depend on it.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore/stable hits are **other** ksmbd OOB patches (ZDI compound sess_setup OOB-read; stack channel_key overflow). **This** commit is not on stable@ yet. The 2023 compound sess_setup OOB-read **was** backported, which supports backporting this related compound-buffer bug.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: krb5_authenticate() (caller of ksmbd_krb5_authenticate()).
**Step 5.2: TRACE CALLERS**
Record:
- Only caller: smb2_sess_setup() when preferred_auth_mech includes KSMBD_AUTH_KRB5 | KSMBD_AUTH_MSKRB5.
- smb2_sess_setup is the SMB2 SESSION_SETUP handler (server.c __process_request loop).
- Compound: after each command, is_chained_smb2_message() advances next_smb2_rsp_hdr_off.
- smb2_check_user_session() returns 0 for SESSION_SETUP **without** requiring a session, so SESSION_SETUP as a later compound element is allowed.
**Step 5.3: TRACE CALLEES**
Record: ksmbd_krb5_authenticate() → ksmbd_ipc_spnego_authen_request() (netlink to ksmbd.mountd) → length check → memcpy of AP-REP into out_blob.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record:
- Reachable from the network on a ksmbd share with Kerberos (CONFIG_SMB_SERVER_KERBEROS5).
- memcpy runs only after userspace reports KSMBD_USER_FLAG_OK (successful Kerberos).
- Trigger is still realistic: compound a large command (e.g. QUERY_DIRECTORY / IOCTL, which use large_sz = 448 + max_trans_size with max_trans_size typically 1MB) then Kerberos SESSION_SETUP.
- is_chained_smb2_message() continues while remaining ≥ MAX_CIFS_SMALL_BUFFER_SIZE (**448**). After a ~72-byte SESSION_SETUP header, ~376 bytes remain for the blob.
- spnego_blob_len is __u16; IPC request blobs are capped at KSMBD_IPC_MAX_PAYLOAD (4096). A typical AP-REP is hundreds to thousands of bytes — larger than 376, smaller than the inflated out_len.
- Userspace-reachable: **yes** (SMB client with Kerberos). Unprivileged remote without tickets: memcpy does not run (auth fails first). Authenticated Kerberos user: **yes**.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record:
- smb2_resp_buf_len() correctly uses get_rfc1002_len(response_buf) for remaining space (QUERY_DIR/INFO). Kerberos setup does not.
- ntlm_negotiate() memcpy(rsp->Buffer, spnego_blob, spnego_blob_len) has no remaining-space check (separate issue, not this commit).
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** fs/smb/server/smb2pdu.c lines 1616–1617:
```
out_len = work->response_sz -
(le16_to_cpu(rsp->SecurityBufferOffset) + 4);
```git merge-base --is-ancestor 23a0be6a84a38 HEAD → **not in this tree** (exit 1).
Bug introduced ~v5.15 (e2f34481b24db2).
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** git apply --check of 23a0be6a84a38 succeeded. Surrounding krb5_authenticate() is simpler than mainline (no channel_key/auth_key); the out_len lines match.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: Compound req/rsp pointer fix (98422bdd4cb3c) is here; it does **not** correct out_len. No substitute for this overflow.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY** Record:
- Subsystem: fs/smb/server (ksmbd)
- Criticality: **IMPORTANT** — network-facing file server. Not core mm/VFS, but historically a high-CVE surface; enterprise/NAS use.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained. Many 6.12 ksmbd security backports already on this branch. Kerberos path is #ifdef CONFIG_SMB_SERVER_KERBEROS5 (default n).
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: ksmbd servers with CONFIG_SMB_SERVER_KERBEROS5=y (AD/Kerberos). Config- and driver-specific, not universal.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Compound SMB2 with SESSION_SETUP not first, Kerberos selected, userspace auth success, AP-REP larger than **actual** remaining heap.
- Common Windows NEGOTIATE+SESSION_SETUP often still has ~1MB remaining, so a small AP-REP may fit — **not** the only case.
- Crafted compound that leaves ~448 bytes (allowed by is_chained_smb2_message) **does** overflow for a normal-sized ticket.
- Unprivileged unauthenticated remote: memcpy not reached (UNVERIFIED as a pre-auth RCE).
- Authenticated Kerberos client: **yes** (reauth after a large compound command).
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- Failure mode: heap OOB write → memory corruption, oops/panic, possible code execution in ksmbd workqueue context.
- Severity: **CRITICAL** (network-facing heap write). Same class as prior ksmbd stable CVEs.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: **very high** for Kerberos ksmbd (stops kernel heap corruption).
- Risk: **very low** (1 line, first-command path unchanged, fail-closed if out_len is negative).
- Ratio: strongly in favor of backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real heap OOB write on a documented, previously attacked compound SESSION_SETUP path (ZDI-CAN-21355 was the OOB-read sibling).
- Network-facing ksmbd; memcpy after a broken length check.
- One-line, obviously correct, applies cleanly to 6.12.111.
- Bug present since ksmbd introduction; maintainer-signed; in v7.3-rc1.
- Fail-closed if out_len becomes negative.
- Author is a professional vulnerability researcher.
AGAINST:
- Kerberos is default n; only those builds.
- memcpy requires successful Kerberos (not a trivial pre-auth spray).
- No public lore thread, syzbot report, or CVE **for this SHA** (UNVERIFIED as assigned CVE).
- Happy-path NEGOTIATE+SESSION_SETUP may not overflow if the AP-REP fits in leftover 1MB.
UNRESOLVED:
- No public reproducer (lore empty; b4 failed).
- No CVE number found for this exact bug.
Those gaps do not outweigh a verified heap write with a one-line fix.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — arithmetic matches buffer layout; maintainer applied it; first-command behavior unchanged.
2. Fixes a real bug that affects users? **PASS** — compound Kerberos SESSION_SETUP overstates headroom; memcpy OOB is in this tree.
3. Important issue? **PASS** — heap OOB write / memory corruption (CRITICAL).
4. Small and contained? **PASS** — 1 line, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — git apply --check clean; buggy code present.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not ID/quirk/DT/docs. Ordinary security bugfix; no exception needed.
**Step 9.4: MAKE YOUR DECISION**
This is a one-line remaining-space correction that stops a kernel heap overflow in ksmbd’s Kerberos session-setup path. The buggy calculation exists in 6.12.111, the patch applies cleanly, and the downside is negligible. It belongs in this stable tree.
Verification:
- [Phase 1] Parsed message/tags: SOB Dudnik + Namjae Jeon; no Fixes/Cc stable/Reported-by. SHA 23a0be6a84a38ac169eeab49017934e8e27c65f0.
- [Phase 1] git show --no-walk --format=fuller 23a0be6a84a38:
AuthorDate 2026-08-07, CommitDate 2026-08-17, committer Namjae Jeon.
- [Phase 2] Diff: one line in krb5_authenticate() adding - work->next_smb2_rsp_hdr_off.
- [Phase 2] Read local ksmbd_resp_buf_next / WORK_BUFFERS / ksmbd_krb5_authenticate memcpy; remaining-space formula matches the fix.
- [Phase 3] git blame -L 1610,1630 fs/smb/server/smb2pdu.c: out_len from e2f34481b24db2 (2021).
- [Phase 3] git merge-base --is-ancestor e2f34481b24db2 HEAD → 0 (present). 23a0be6a84a38 → 1 (not in this tree).
- [Phase 3] Related: 98422bdd4cb3c compound sess_setup OOB-read (ZDI- CAN-21355) is in this tree; does not fix out_len.
- [Phase 4] b4 dig -c 23a0be6a84a38: lore errors, no match.
- [Phase 4] lore.kernel.org linux-cifs/all: no Ilan Dudnik / this subject thread.
- [Phase 4] ksmbd-for-7.3-rc1 pull lists this commit under heap- OOB/Kerberos security fixes; git describe --contains → v7.3-rc1~77^2~32.
- [Phase 4] lore/stable: other ksmbd OOB backports, not this SHA.
- [Phase 5] krb5_authenticate only from smb2_sess_setup; SESSION_SETUP skips session check; compound loop in server.c + init_chained_smb2_rsp.
- [Phase 5] MAX_CIFS_SMALL_BUFFER_SIZE 448; SMB3_DEFAULT_TRANS_SIZE 1MB; spnego_blob_len is __u16; IPC request cap 4096.
- [Phase 6] Local tree: git describe HEAD → p-6.12-3-gc504cf0baa3d8; make kernelversion → **6.12.111**.
- [Phase 6] Buggy out_len at smb2pdu.c:1616-1617; git apply --check of 23a0be6a84a38 **clean**.
- [Phase 7] MAINTAINERS: Namjae Jeon + Steve French, linux-cifs.
- [Phase 8] Heap OOB write after successful Kerberos on compound SESSION_SETUP; severity CRITICAL.
- UNVERIFIED: public reproducer, CVE ID, mailing-list review comments (no public thread).
The fix is small, surgical, and meets all stable kernel criteria.
**YES**
fs/smb/server/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/server/smb2pdu.c +1 -1
@@ -1607,7 +1607,7 @@ static int krb5_authenticate(struct ksmbd_work *work, in_len =le16_to_cpu (req->SecurityBufferLength); out_blob = (char *)&rsp->hdr.ProtocolId +le16_to_cpu (rsp->SecurityBufferOffset); - out_len = work->response_sz - + out_len = work->response_sz - work->next_smb2_rsp_hdr_off - (le16_to_cpu (rsp->SecurityBufferOffset) +4 ); retval = ksmbd_krb5_authenticate(sess, in_blob, in_len,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 media: i2c: ov8865: Program the sensor on stream start
In reply to Sasha LevinFrom: Jurison Murati <[email protected]>
[ Upstream commit 4e1446ac169a1a621ba90502ab8db3be821fe726 ]
The sensor registers are only written in the runtime PM resume handler; ov8865_set_fmt() merely stores the requested mode, relying on the sensor being runtime suspended between uses so that the next resume applies it.
That assumption breaks when something keeps the sensor powered. On IPU3 platforms, ipu_bridge instantiates the VCM device with a DL_FLAG_PM_RUNTIME device link to the sensor, so a userspace process holding the VCM subdev open (e.g. wireplumber's camera monitor) pins the sensor runtime-active. A subsequent set_fmt() then never reaches the hardware: the sensor keeps streaming the mode programmed on the last resume while the CSI-2 receiver expects the newly negotiated format.
On a Surface Book 2 (IPU3, ov8865 + dw9719 VCM), requesting the 3264x2448 mode while the hardware was left programmed for the 1632x1224 binned mode makes ipu3-cio2 report "frame sync error" and "payload length is 10340352, received 2585088" (exactly one binned frame) for every frame, and the inverse case stalls the stream after a single frame. Camera applications end up displaying one bogus frame forever.
Program the sensor configuration and apply the control values on stream start instead, where the negotiated mode is always current, and only write the configuration in the runtime PM resume handler when resuming with the stream already started.
---
LLM Generated explanations, may be completely bogus:
The local checkout is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The verdict is whether this ov8865 programming fix belongs **here**, not in other series.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [media: i2c: ov8865] [Program] Program the sensor on stream start — “Program” here is a correctness change: write the negotiated mode at s_stream, not only on runtime resume.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Jurison Murati <[email protected]> (author)
- Signed-off-by: Sakari Ailus <[email protected]> (media/I2C sensor maintainer; merger)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, `Cc:
stable, Link:`, or syzbot tags (absence expected)
- Mailing-list thread (Phase 4) has Reviewed-by: Daniel Scally on series patch 1/2 only, not on this 2/2 as merged
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: set_fmt() only stores the mode; registers are written in the runtime-PM resume handler. That assumes the sensor suspends between uses.
- Trigger: IPU3 ipu_bridge VCM device link (DL_FLAG_PM_RUNTIME) plus userspace holding the VCM subdev open (wireplumber camera monitor) keeps the sensor runtime-active, so resume never runs after set_fmt().
- Symptom: CSI-2 receiver (ipu3-cio2) sees a format mismatch. Full 3264×2448 vs leftover 1632×1224 binned mode → "frame sync error" and "payload length is 10340352, received 2585088"; the inverse stalls after one frame. Camera apps show one bogus frame forever.
- Hardware: Surface Book 2 (IPU3, ov8865 + dw9719 VCM).
- Fix: program + apply controls on stream start; resume only reprograms if already streaming (mid-stream suspend).
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Explicit functional bug: hardware left in the previous mode.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/media/i2c/ov8865.c (+25 / −9)
- Functions: ov8865_s_stream(), ov8865_resume()
- Scope: single-file, surgical
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- ov8865_s_stream(enable=1) before: pm_runtime_resume_and_get() then only ov8865_sw_standby(false). After: still resume_and_get, then always ov8865_sensor_init() + __v4l2_ctrl_handler_setup() then standby off. Stream-start path.
- ov8865_resume() before: always sensor_init + ctrl setup, then standby off if streaming. After: those writes only if state->streaming. Runtime-resume path; skipped when VCM merely pins power.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: [Logic / correctness] Mode was applied only on RPM resume. With an external RPM pin, set_fmt() never reached the sensor. Fix writes the current software mode at stream start. Category is not UAF/leak/race; it is a hardware/software format desync.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct. Matches the usual sensor pattern (configure at stream on). Extra I2C on every start is harmless (same work resume used to do). Resume still covers mid-stream suspend. int ret = 0 is required because disable no longer assigned ret before the new if (!ret) guard. Regression risk low; no API/lock change. Depends on sibling 1/2 (3fe797a12bfa9) for unified pm_runtime_put on sensor_init failure — that commit **is** in this tree.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Driver added in 11c0d8fdccc56 (“Add support for the OV8865 image sensor”, 2020-12-31, first in **v5.12-rc1**). Original s_stream only toggled standby after RPM get; resume always called sensor_init.
- Original ov8865_state_configure() **did** call ov8865_mode_configure() when the device was already runtime-active (!pm_runtime_suspended). That covered the VCM-pin case at set_fmt().
- da8f23e359166 (“move mode_configure out of state_configure”, 2025-09-09, contained in **v6.18-rc1**) removed that powered-path mode_configure. That is the regression this commit repairs. Present in this 7.3 tree.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The introducing commit is da8f23e359166. git merge-base --is-ancestor da8f23e359166 HEAD succeeded.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- 3fe797a12bfa9 — same author, same second, series 1/2: drop RPM count on stream failure. v2 changelog says 2/2 was rebased on that unified error path.
- 8e3e916e23f5a (2023-08-10) — ipu-bridge VCM DL_FLAG_PM_RUNTIME link (the pin).
- No follow-up/revert of 4e1446ac169a1 on this file after it landed.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Jurison Murati has these two ov8865 commits in-tree. Not the subsystem maintainer. Sakari Ailus merged both. Dan Scally (Intel IPU3/libcamera) reviewed the series.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Soft prerequisite: 3fe797a12bfa9 (already in HEAD). Without it, sensor_init failure after resume_and_get would leak the RPM ref. No new helpers. Standalone on this tree.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 4e1446ac169a1: https://patch.msgid.link/fa341298dfd2ba9ce4
[email protected]
- Series: v1 then v2 (2 patches).
- v1 1/2: “Program the mode on stream start if needed” — extra
`hw_mode`/`hw_mbus_code` state
- v1 2/2: RPM put on stream-start failure
- v2 1/2: RPM leak fix (reordered)
- v2 2/2: this commit (unconditional program at start; resume gated on streaming)
- Applied version is v2, latest. No NAK. Sakari: do not add more driver state; Dan: program unconditionally at s_stream and gate resume — that is what landed. Author retested on Surface Book 2 with the sensor held runtime-active; both modes worked; mid-stream resume still reprogrammed.
- No Cc: stable in the thread.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: b4 dig -w recipients: Sakari Ailus, Daniel Scally, Hans de Goede, Mauro Carvalho Chehab, linux-media. Right audience (sensor maintainer, IPU3/VCM authors).
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No bugzilla/syzbot. Concrete user-visible failure on Surface Book 2 with exact cio2 log lines. Author is the reporter; not a theoretical race.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 2/2 of a two-patch series. 1/2 is 3fe797a12bfa9, already in this tree. This hunk does not need other media patches.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: WebFetch of lore.kernel.org/stable returned 403. b4 mbox has no “stable” mention. UNVERIFIED whether stable@ discussed this later.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: ov8865_s_stream (modified), ov8865_resume (modified). Callees used: ov8865_sensor_init, __v4l2_ctrl_handler_setup, ov8865_sw_standby. ov8865_set_fmt → ov8865_state_configure is the path that only stores state->mode.
**Step 5.2: TRACE CALLERS**
Record: ov8865_s_stream is .s_stream on the V4L2 subdev. Called from the media pipeline when userspace starts/stops capture (libcamera / camera apps), not IRQ. ov8865_resume is SET_RUNTIME_PM_OPS runtime resume.
**Step 5.3: TRACE CALLEES**
Record: ov8865_sensor_init does sw reset, standby, chip-id, init sequence, then ov8865_mode_configure(sensor->state.mode, …) — so it programs the **currently negotiated** mode. That is why calling it from s_stream after set_fmt() is the right place.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace opens VCM (wireplumber) → ipu_bridge device_link_add(..., DL_FLAG_PM_RUNTIME) keeps sensor RPM-active → VIDIOC_S_FMT/set_fmt updates software mode only → s_stream(1) used to only leave standby, leaving old registers → ipu3-cio2 receives the wrong frame size. Unprivileged user with camera access can trigger it; wireplumber makes it the common case.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: ov5648_s_stream still only does standby after RPM get and always inits in resume — sibling still has the old pattern. Not a reason to reject this ov8865 fix. ipu-bridge.c:714 still has the VCM PM link.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- Tree: VERSION=7 PATCHLEVEL=3 SUBLEVEL=0 EXTRAVERSION=-rc4
- drivers/media/i2c/ov8865.c, VIDEO_OV8865, ipu3-cio2, ipu_bridge_instantiate_vcm_work + DL_FLAG_PM_RUNTIME all exist
- Regression da8f23e359166 is an ancestor of HEAD
- Pre-fix s_stream (parent of 4e1446ac169a1) only called ov8865_sw_standby; pre-fix resume always inited
- cio2 strings "frame sync error" and "payload length is %lu, received %u" match the report (ipu3-cio2.c)
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply on this tree. Prerequisite 3fe797a12bfa9 already present. Difficulty: clean.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No other fix for “wrong mode while RPM-pinned.” git merge-base --is-ancestor 4e1446ac169a1 HEAD is true — used only to confirm file state, not as “already selected for stable.”
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/media/i2c OmniVision OV8865. **IMPORTANT** for IPU3 laptops that use this sensor (Surface Book 2 and similar); not core mm/fs/net. Camera capture is a primary function of that hardware.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Driver is mature (v5.12). Recent changes are targeted fixes, not a rewrite. Bug is a 2025 regression in a long-lived driver.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Users of ov8865 with a VCM RPM device link (IPU3 + ipu_bridge), especially when wireplumber/PipeWire keeps the VCM open. Driver-specific / platform-specific, but real shipping laptops.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Common on affected machines: camera monitor holds VCM, then a capture app sets format and streams. Not a rare race. Unprivileged users with camera access can hit it.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Not oops/UAF/deadlock. Camera stream is wrong or stuck: cio2 frame-sync/payload errors, one frozen bogus frame, or stall after one frame. **HIGH** for those users (device unusable), **MEDIUM–HIGH** overall.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record: Benefit: restores working capture after a v6.18 regression.
Risk: low (~34-line, one driver, reviewed, retested). Ratio favors including the fix.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR backporting:
- Real, reproduced bug on Surface Book 2 with exact cio2 logs present in this tree
- Regression from da8f23e359166 (v6.18), which is in this tree; that commit removed the only powered-path mode_configure on set_fmt
- Trigger is ordinary (wireplumber + IPU3 VCM PM link, also in this tree)
- Small, obviously correct, no new API
- v2 matches maintainer (Sakari) and IPU3 reviewer (Dan Scally) feedback; retested
- Prerequisite RPM error-path fix is already here
AGAINST backporting:
- Not a kernel crash, UAF, or security hole
- Affects one sensor + IPU3/VCM, not all users
- No explicit Cc: stable (not a negative by itself)
- Merged 2/2 has no in-commit Reviewed-by (review happened on the list)
UNRESOLVED:
- lore.kernel.org WebFetch 403; thread recovered via b4 dig -m
- Whether stable@ later discussed this (no hit in the patch mbox)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — v2 as Dan/Sakari asked; author retested both modes and mid-stream resume on SB2
2. Fixes a real bug that affects users? **PASS** — camera unusable when VCM pins the sensor
3. Important issue? **PASS** — serious functional failure of the laptop camera (wrong CSI-2 format / stuck frame), not cosmetic
4. Small and contained? **PASS** — +25/−9, one file, two functions
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — same functions; 3fe797a12bfa9 present
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None of ID/quirk/DT/build/docs. It is a normal driver correctness fix (plus the spirit of a hardware-path workaround for the VCM PM link).
**Step 9.4: MAKE YOUR DECISION**
This tree has the ov8865 driver, the v6.18 mode_configure removal that dropped the powered set_fmt path, and the IPU3 VCM RPM pin that makes that path the default with wireplumber. The result is a format mismatch that breaks capture. The fix is small, reviewed, and tested. It meets stable rules for this checkout.
Verification:
- [Phase 1] Parsed tags: author + Sakari SOB only; no Fixes/Reported- by/syzbot/Cc:stable
- [Phase 2] Diff: ov8865_s_stream always inits+ctrl setup on enable; ov8865_resume inits only if state->streaming
- [Phase 3] Blame: s_stream/resume from 11c0d8fdccc56 (v5.12); powered set_fmt mode_configure removed by da8f23e359166 (v6.18-rc1)
- [Phase 3] git merge-base --is-ancestor da8f23e359166 HEAD succeeded; 3fe797a12bfa9 also ancestor
- [Phase 3] git show da8f23e359166: removed if (!pm_runtime_suspended) ov8865_mode_configure() from ov8865_state_configure
- [Phase 4] b4 dig -c 4e1446ac169a1: v2 2/2 at patch.msgid.link/fa341298…; v1 added hw_mode state; Sakari objected; Dan proposed this design
- [Phase 4] Author reply: retested SB2 with sensor held runtime-active
- [Phase 4] b4 dig -w: Sakari, Dan Scally, Hans de Goede, Mauro, linux-media
- [Phase 4] lore/stable WebFetch: 403; mbox has no “stable”
- [Phase 5] ov8865_set_fmt → ov8865_state_configure only stores state->mode; sensor_init calls ov8865_mode_configure(state->mode)
- [Phase 5] ipu-bridge.c:714 device_link_add(..., DL_FLAG_PM_RUNTIME)
- [Phase 6] Makefile/describe: 7.3.0-rc4; VIDEO_OV8865 present
- [Phase 6] cio2: "frame sync error" and "payload length is %lu, received %u" in ipu3-cio2.c
- [Phase 8] Failure: wrong/stalled camera frames, not oops; HIGH for affected IPU3+ov8865 users
- UNVERIFIED: later stable@ discussion (lore 403)
The patch is a real, tested regression fix for this tree’s ov8865 + IPU3 VCM PM link path.
**YES**
drivers/media/i2c/ov8865.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-)
drivers/media/i2c/ov8865.c +25 -9
@@ -2609,7 +2609,7 @@ static int ov8865_s_stream(struct v4l2_subdev *subdev, int enable) {struct ov8865_sensor *sensor =ov8865_subdev_sensor (subdev);struct ov8865_state *state = &sensor->state; -int ret; +int ret =0 ;if (enable) { ret =pm_runtime_resume_and_get (sensor->dev);
@@ -2618,7 +2618,23 @@ static int ov8865_s_stream(struct v4l2_subdev *subdev, int enable) }mutex_lock (&sensor->mutex); - ret =ov8865_sw_standby (sensor, !enable); + +/* +* The sensor may have been kept powered by something else (e.g. the +* VCM's runtime PM device link on IPU3 platforms), in which case +* runtime resume did not run and the hardware may still be +* configured for a previous mode. Always program the negotiated +* configuration on stream start. +*/ +if (enable) { + ret =ov8865_sensor_init (sensor); +if (!ret) + ret =__v4l2_ctrl_handler_setup (&sensor->ctrls.handler); + } + +if (!ret) + ret =ov8865_sw_standby (sensor, !enable); +mutex_unlock (&sensor->mutex);if (ret || !enable)
@@ -2914,15 +2930,15 @@ static int ov8865_resume(struct device *dev)if (ret) goto complete; - ret =ov8865_sensor_init (sensor); -if (ret) - goto error_power; +if (state->streaming) { + ret =ov8865_sensor_init (sensor); +if (ret) + goto error_power; - ret =__v4l2_ctrl_handler_setup (&sensor->ctrls.handler); -if (ret) - goto error_power; + ret =__v4l2_ctrl_handler_setup (&sensor->ctrls.handler); +if (ret) + goto error_power; -if (state->streaming) { ret =ov8865_sw_standby (sensor, false);if (ret) goto error_power;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 HID: logitech-hidpp: Add support for G502 X Plus USB mouse
In reply to Sasha LevinFrom: Stuart Hayhurst <[email protected]>
[ Upstream commit 6f4b44abe4ccdcfdab75c9493b8c7634fee37133 ]
The wireless dongle is already supported, this adds detection for the mouse in wired mode. Supports battery reporting.
---
LLM Generated explanations, may be completely bogus:
The local checkout is **pending-5.15** (kernel **5.15.221**). This is a two-line USB ID addition to an existing HID++ driver, which stable rules explicitly allow.
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: **[HID / logitech-hidpp] [Add] [USB detection for G502 X Plus wired mouse]**
**Step 1.2: Tags**
Record:
- Signed-off-by: Stuart Hayhurst \<[email protected]\> (author)
- Reviewed-by: Bastien Nocera \<[email protected]\> (HID++ reviewer)
- Signed-off-by: Jiri Kosina \<[email protected]\> (HID maintainer)
- No Fixes: tag (expected)
- No Cc: stable (expected)
- No Reported-by / Tested-by / Link:
- Ignore any pipeline “Upstream commit” / Sasha Levin SOB if present
**Step 1.3: Body**
Record: [Bug/gap: G502 X Plus is detected on the Lightspeed dongle but not when plugged in over USB.] [Symptom: no HID++ binding in wired mode, so no kernel battery reporting.] [No version range in the message.] [Root cause: missing HID_USB_DEVICE(..., 0xC095) in hidpp_devices[].]
**Step 1.4: Hidden bug fix?**
Record: Not a disguised leak/race fix. It is a **new device ID** for existing driver code.
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record: drivers/hid/hid-logitech-hidpp.c only; **+2 / -0**. Function:hidpp_devices[] ID table. Scope: single-file surgical ID add.
**Step 2.2: Code flow**
Record: Before: USB 046d:c095 is not matched by logitech-hidpp and is handled by hid-generic (mouse works; no HID++ battery). After:hidpp_probe() binds with driver_data = 0 (same as G403/G703/G903 USB entries). Path: device enumeration / probe, not an error path.
**Step 2.3: Bug mechanism**
Record: **Hardware ID / quirk table (h).** Missing product ID; adding HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC095).
**Step 2.4: Fix quality**
Record: Obviously correct; matches neighboring Lightspeed USB mice. No API, locking, or structure change. Regression risk is low; the 2019 G502 revert was for **different** PIDs (Hero/Proteus 0xC07D/0xC332/0xC08B), not this Lightspeed X device.
## Phase 3: Git history
**Step 3.1: Blame**
Record: USB HID++ IDs in this tree come from 91cf9a98ae4127 (2019) and 27fc32fd941796 (2019), plus G915 TKL fd41646d43504 (backported 2023). Table has been stable for years.
**Step 3.2: Fixes: tag**
Record: None. This does not revert a bug-introducing commit; it adds an ID.
**Step 3.3: Related file history**
Record: Related mainline IDs: a343a7682acc5 (G502 Lightspeed 0xC08D, 2023) and fce551616dfa4 (G502 X Lightspeed 0xC098, 2026). Neither is in this tree. Not a numbered series; standalone v1. Same-author companion 456d506b6041d (duplicate G703 ID) is unrelated cleanup.
**Step 3.4: Author**
Record: Stuart Hayhurst is a regular HID++ ID contributor. Same author/reviewer pair already landed G915 TKL IDs in **this** 5.15 tree (fd41646d43504).
**Step 3.5: Dependencies**
Record: No new helpers. Needs existing hidpp_devices[] / HID_USB_DEVICE / battery init. Unified Battery 0x1004 (e037acf0b1aed) **is** an ancestor of this tree. G502 Lightspeed 0xC08D is only nearby context, not a functional prerequisite. Standalone.
## Phase 4: Mailing list / external
**Step 4.1: Original discussion**
Record: b4 dig -c 6f4b44abe4ccd → https://patch.msgid.link/20260721171
[email protected]b4 dig -a: **v1 only**. Thread: Bastien Reviewed-by; Jiri “Applied, thanks.” No NAK, no stable concern.
**Step 4.2: Recipients (b4 dig -w)**
Record: Jiri Kosina, Benjamin Tissoires, Bastien Nocera, Filipe Laíns, linux-input, linux-kernel.
**Step 4.3: Bug report**
Record: No syzbot/bugzilla. Author describes wired detection + battery. Libratbag also lists G502 X Plus wired 0xC095 (external confirmation of the PID).
**Step 4.4: Series**
Record: Subject is [PATCH], not X/Y. Later G502 X Lightspeed ID (fce551616dfa4) is a separate author/date.
**Step 4.5: stable@**
Record: lore.kernel.org WebFetch returned 403. UNVERIFIED on stable@ archives. Documentation/process/stable-kernel-rules.rst line 24: “New device IDs and quirks are also accepted.”
## Phase 5: Semantic / call graph
**Step 5.1: Functions**
Record: hidpp_devices[] only. Consumed by hidpp_driver.id_table → hidpp_probe().
**Step 5.2: Callers**
Record: HID core match → hidpp_probe() → hidpp_connect_event() → hidpp_initialize_battery(). Userspace-visible on USB plug-in.
**Step 5.3: Callees**
Record: Unchanged. Battery path already tries 0x1000, then 0x1004, then 0x1001.
**Step 5.4: Reachability**
Record: Yes, from plugging the mouse in over USB. Unprivileged physical access; not a syscall fuzzer path.
**Step 5.5: Similar patterns**
Record: Same pattern as G403/G703/G903 USB IDs already here, and G915 TKL already backported here.
## Phase 6: This tree (5.15.221)
**Step 6.1: Does the gap exist?**
Record: Yes. hidpp_devices[] around drivers/hid/hid-logitech- hidpp.c:4354 has G403 0xC082 then G703 0xC087. **No 0xC095.** git merge-base --is-ancestor 6f4b44abe4ccd HEAD → not ancestor. Wireless still covered by LDJ_DEVICE(HID_ANY_ID) at line 4338.
**Step 6.2: Backport difficulty**
Record: **Minor context tweak.** Upstream hunk sits after G502 Lightspeed 0xC08D, which is not in 5.15. Insert after G403 / before G703. Two lines.
**Step 6.3: Related fixes already here?**
Record: No 0xC095. G915 TKL IDs are present (same class of HID++ ID add). Unified Battery is present.
## Phase 7: Subsystem
**Step 7.1:** Record: **HID / logitech-hidpp**. Criticality:
**IMPORTANT** (common USB HID, not core mm/net). CONFIG_HID_LOGITECH_HIDPP.
**Step 7.2:** Record: Mature driver; ID table is the usual extension point. Still receiving stable HID++ fixes on this branch.
## Phase 8: Impact / risk
**Step 8.1:** Record: **driver-specific / hardware-specific** — Logitech G502 X Plus in **wired USB** mode.
**Step 8.2:** Record: Trigger = plug in with cable. Common for charging/wired use. Not remotely triggerable.
**Step 8.3:** Record: Without the ID, generic HID still moves the cursor. With the ID, HID++ battery sysfs works. Severity **MEDIUM** as a bug, but this is the **device-ID exception**, not a crash fix.
**Step 8.4:** Record: Benefit: battery/HID++ for a shipping 2022 mouse on 5.15 LTS. Risk: very low (2 lines, no quirks). Same shape as G915 TKL already on this tree. Ratio: **favorable**.
## Phase 9: Synthesis
**Evidence FOR**
- Stable rules explicitly accept new device IDs (stable-kernel- rules.rst).
- Driver and battery stack (including 0x1004) exist in 5.15.221.
- +2 lines, no new API, no quirks.
- Reviewed by Bastien Nocera; applied by Jiri Kosina.
- Precedent on this tree: G915 TKL USB/BT IDs (fd41646d43504), same author, same “battery on top of hid-generic” rationale.
- 0xC095 is unused by other HID drivers here.
**Evidence AGAINST**
- Not a crash/UAF/security fix; mouse already works via hid-generic.
- 2019 G502 USB IDs were reverted for timeouts — **different PIDs**.
- Hunk context needs a tiny edit because 0xC08D is missing.
**Unresolved**
- Could not fetch lore/stable HTML (403). Thread recovered via b4 mbox.
- Did not physically test a G502 X Plus on 5.15.
**Stable rules checklist**
1. Obviously correct and tested? **PASS** (trivial ID; author + HID++ reviewer).
2. Fixes a real user-visible gap? **PASS** (wired HID++/battery).
3. Important? **PASS** under the device-ID exception (not a panic).
4. Small and contained? **PASS** (+2 lines, one table).
5. No new features/APIs? **PASS** (existing probe/battery only).
6. Applies to this tree? **PASS** with trivial context adjust.
**Exception category:** New USB device ID on an existing driver.
This belongs on 5.15.y: the hardware is real, the driver already handles this class of Lightspeed USB mice, and the change is the same kind of ID add this tree has already taken.
Verification:
- [Phase 1] Tags: author SOB, Bastien Reviewed-by, Jiri SOB; no Fixes/Cc stable
- [Phase 2] Diff: +2 lines in hidpp_devices[], USB 0xC095, no quirks
- [Phase 3] Mainline SHA 6f4b44abe4ccdcfdab75c9493b8c7634fee37133; not ancestor of HEAD
- [Phase 3] Unified Battery e037acf0b1aed **is** ancestor of HEAD
- [Phase 3] G502 Lightspeed a343a7682acc5 is **not** in this tree (context only)
- [Phase 4] b4 dig -c 6f4b44abe4ccd: lore match; v1 only; Reviewed-by
+ Applied
- [Phase 4] WebFetch lore/stable: 403; thread read from /tmp/g502xplus.mbox
- [Phase 5] ID table → hidpp_probe → hidpp_initialize_battery (0x1000/1004/1001)
- [Phase 6] git describe HEAD: p-5.15-2-g9a29d9b0f9507; make kernelversion: 5.15.221; branch pending-5.15
- [Phase 6] No 0xC095 in hidpp_devices[]; LDJ_DEVICE(HID_ANY_ID) present
- [Phase 6] G915 TKL IDs already backported here (fd41646d43504)
- [Phase 7] CONFIG_HID_LOGITECH_HIDPP; Kconfig selects POWER_SUPPLY
- [Phase 8] Failure mode: missing HID++/battery in wired mode, not oops
- UNVERIFIED: stable@ archive search (HTTP 403); no hardware test on 5.15
**YES**
drivers/hid/hid-logitech-hidpp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hid/hid-logitech-hidpp.c +2 -0
@@ -4615,6 +4615,8 @@ static const struct hid_device_id hidpp_devices[] = { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC082) }, {/* Logitech G502 Lightspeed Wireless Gaming Mouse over USB */ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC08D) }, + { /* Logitech G502 X Plus Wireless Gaming Mouse over USB */ + HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC095) }, { /* Logitech G703 Gaming Mouse over USB */ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC087) }, { /* Logitech G703 Hero Gaming Mouse over USB */
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: iwlwifi: mld: support aborting an ongoing ftm request
In reply to Sasha LevinFrom: Avraham Stern <[email protected]>
[ Upstream commit ef704fc32ae1a519801ac4a06aa290fece5f403c ]
Add support for aborting an ongoing FTM request.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1: Subject line**
Record: **[iwlwifi/mld]** **[support]** add abort for an in-flight FTM (Fine Timing Measurement / peer measurement) request.
**Step 1.2: Tags**
Record:
- Signed-off-by: Avraham Stern <[email protected]> (author)
- Signed-off-by: Miri Korenblit <[email protected]> (iwlwifi maintainer)
- Link: https://patch.msgid.link/20260715220243.340040bdc6a3.Ifbbf70021e
42bf1d59db6ec45a73f1806a1c2289@changeid
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Cc:
stable (absence of the last two is expected for this review)
**Step 1.3: Body**
Record:
- Bug description from message: none. One sentence: “Add support for aborting an ongoing FTM request.”
- Symptom/failure mode: not stated
- Version information: none
- Root-cause explanation: none
**Step 1.4: Hidden bug fix?**
Record: **Yes.** The wording is feature-like, but the MLD path already stores mld->ftm_initiator.req and later dereferences it. cfg80211 frees that object on abort whether or not the driver implements abort_pmsr. Missing abort is a use-after-free / stuck-FTM hole, not a new userspace API.
## Phase 2: Diff analysis
**Step 2.1: Inventory**
Record:
- drivers/net/wireless/intel/iwlwifi/mld/ftm-initiator.c: +21 (new iwl_mld_ftm_abort)
- drivers/net/wireless/intel/iwlwifi/mld/ftm-initiator.h: +1 (prototype)
- drivers/net/wireless/intel/iwlwifi/mld/mac80211.c: +10 (iwl_mld_abort_pmsr + .abort_pmsr ops)
- Total: **+32 / −0**, single-driver surgical change
**Step 2.2: Code flow**
Record:
- Before: .start_pmsr was wired; .abort_pmsr was NULL. On netlink close or wdev teardown, cfg80211 still kfree()s the request while the driver keeps the pointer and firmware keeps ranging.
- After: abort sends TOF_RANGE_ABORT_CMD, cancels queued FTM RX notifications, then iwl_mld_ftm_reset() NULLs req/req_wdev.
- Path: abort/teardown only, not the normal completion path.
**Step 2.3: Bug mechanism**
Record: **Use-after-free + leftover firmware ranging**, fixed by implementing the existing mac80211 abort_pmsr op (same pattern as MVM). Also prevents the next iwl_mld_ftm_start() from returning -EBUSY forever because ftm_initiator.req stayed non-NULL after the object was freed.
**Step 2.4: Fix quality**
Record: Obviously correct relative to iwl_mvm_ftm_abort(). Minimal. Regression risk is low: new code runs only on abort; on firmware abort failure it still resets local state (the UAF-critical part). Helpers it calls already exist in this tree.
## Phase 3: Git history
**Step 3.1: Blame / introduction**
Record: Buggy pattern came in with **d1e879ec600f9** (“wifi: iwlwifi:
add iwlmld sub-driver”, 2025-02-16). FTM start stored req and registered RX_HANDLER_OF_FTM_REQ / IWL_MLD_OBJECT_TYPE_FTM_REQ from day one, but never called cancel/abort. MVM has had abort since **fc36ffda32670** (2019, “support FTM initiator”).
**Step 3.2: Fixes: tag**
Record: None. Not applicable.
**Step 3.3: File history**
Record: Recent FTM-initiator commits are unrelated (location BW encoding, switch indentation). Neighbor **71ac392d8b5c2** (FW recovery reset) is a different path. No prerequisite refactor for this hunk.
**Step 3.4: Author**
Record: Avraham Stern is a regular iwlwifi FTM contributor. Maintainer Miri Korenblit signed off. Related later Stern commits in this tree are MEI length checks, not FTM abort follow-ups. **No follow-up fix** to iwl_mld_ftm_abort after this commit.
**Step 3.5: Dependencies**
Record: Standalone. Uses existing iwl_mld_send_cmd_pdu, iwl_mld_cancel_notifications_of_object, IWL_MLD_OBJECT_TYPE_FTM_REQ, iwl_mld_ftm_reset, TOF_RANGE_ABORT_CMD. Series membership is **01/15 of an iwlwifi-next “updates” dump**; other patches (MEI, WoWLAN, LARI, etc.) are unrelated. Can apply alone.
## Phase 4: Mailing list / external
**Step 4.1: Original discussion**
Record:
- b4 dig -c ef704fc32ae1a: https://patch.msgid.link/20260715220243.340
040bdc6a3.Ifbbf70021e42bf1d59db6ec45a73f1806a1c2289@changeid
- Cover: [PATCH iwlwifi-next 00/15] wifi: iwlwifi: updates - 07-15-2026 — “Cleanups, features, and fixes from our internal tree.”
- b4 dig -a: **v1 only**, this is the applied version
- No reviewer comments, NAKs, or Cc: stable on this patch in the saved thread
- lore.kernel.org WebFetch returned 403; thread recovered via b4 dig -m
**Step 4.2: Recipients**
Record: To Johannes Berg; Cc linux-wireless, Avraham Stern. Subsystem maintainer (Miri) submitted the series.
**Step 4.3: Bug report**
Record: None. No syzbot/bugzilla.
**Step 4.4: Series**
Record: Mixed iwlwifi-next batch. This patch does not depend on 02–15.
**Step 4.5: Stable list**
Record: No stable-list discussion found (search did not surface this subject).
## Phase 5: Semantic / call-chain
**Step 5.1: Functions**
Record: iwl_mld_ftm_abort (new), iwl_mld_abort_pmsr (new), iwl_mld_hw_ops.abort_pmsr assignment.
**Step 5.2: Callers**
Record:
- cfg80211_release_pmsr() from nl80211.c on netlink port release
- cfg80211_pmsr_wdev_down() from net/wireless/core.c on wdev teardown
- both → cfg80211_pmsr_process_abort() → rdev_abort_pmsr() → ieee80211_abort_pmsr() → drv_abort_pmsr() → iwl_mld_abort_pmsr()
- drv_abort_pmsr only calls the driver if local->ops->abort_pmsr is set; cfg80211 **always kfree()s** afterward (pmsr.c around the abort loop)
**Step 5.3: Callees**
Record: firmware abort PDU; iwl_mld_cancel_notifications_of_object(); iwl_mld_ftm_reset().
**Step 5.4: Reachability**
Record: Yes, from userspace: start peer measurement (NL80211_CMD_PEER_MEASUREMENT_START), then close the netlink socket or take the interface down while ranging is in progress. Typically privileged (nl80211), but a crashing location/RTT helper is a realistic trigger (Android Wi-Fi RTT uses this API).
**Step 5.5: Similar patterns**
Record: Only iwlwifi MVM/MLD and mac80211_hwsim implement .abort_pmsr. MVM has had it since FTM was added; MLD start without abort was the incomplete copy.
Verified UAF path in this tree:
```246:247:drivers/net/wireless/intel/iwlwifi/mld/ftm-initiator.c
if (mld->ftm_initiator.req)
return -EBUSY;
``````267:270:drivers/net/wireless/intel/iwlwifi/mld/ftm-initiator.c
if (!ret) {
mld->ftm_initiator.req = req;
mld->ftm_initiator.req_wdev =
ieee80211_vif_to_wdev(vif);
}
``````340:342:drivers/net/wireless/intel/iwlwifi/mld/ftm-initiator.c
if (IWL_FW_CHECK(mld, !mld->ftm_initiator.req,
"FTM response without a pending request\n"))
return;
```That NULL check does not save a dangling pointer. cfg80211_pmsr_process_abort() kfree’s the request after the (optional) abort op.
## Phase 6: This checkout
**Step 6.1: Local tree and buggy code**
Record:
- git describe HEAD: **v7.3-rc4-27-gf0100363d8c37**
- make kernelversion: **7.3.0-rc4**
- MLD FTM initiator **is present**. Bug introduced with MLD (d1e879ec600f9), long before 7.3 branched.
- Candidate SHA **ef704fc32ae1a**; git merge-base --is-ancestor ef704fc32ae1a HEAD → already in this mainline snapshot (landed in **7.3-rc1**, not in 7.2). Evaluation is still on technical merit, not “already selected.”
**Step 6.2: Backport difficulty**
Record: Clean apply on this tree. Structures and helpers match the hunk.
**Step 6.3: Related fixes already here**
Record: iwl_mld_ftm_restart_cleanup() covers FW restart only, not userspace abort. No earlier abort implementation.
## Phase 7: Subsystem context
**Step 7.1**
Record: **iwlwifi MLD** (Intel Wi-Fi 7 opmode). Criticality:
**IMPORTANT** (common client Wi-Fi driver), not core mm/VFS. FTM itself is a subset of users (RTT / indoor location).
**Step 7.2**
Record: Actively developed; MLD is the current Intel path. This is a missing piece from the original MLD port, not a brand-new subsystem.
## Phase 8: Impact and risk
**Step 8.1: Who is affected**
Record: Intel MLD devices using nl80211 peer measurement (FTM initiator). Not universal.
**Step 8.2: Trigger**
Record: Start FTM, then abort via socket close or iface down before firmware completes. Not every boot; realistic for location stacks and interface teardown. Unprivileged trigger: unverified (nl80211 PMSR is typically admin-capable).
**Step 8.3: Failure mode**
Record:
- Firmware response after abort: **UAF** of cfg80211_pmsr_request (crash / KASAN / potential memory corruption)
- Without a later notification: FTM stays “busy” (-EBUSY) until driver reset
- Firmware keeps ranging until timeout
Severity: **HIGH** (UAF), not a panic on every probe.
**Step 8.4: Risk/benefit**
Record: Benefit medium-high for MLD FTM users (UAF + stuck session). Risk **low** (32 lines, abort path only, same design as MVM). Ratio favors taking it.
## Phase 9: Synthesis
**Step 9.1: Evidence**
FOR:
- Verified UAF: driver borrows cfg80211’s request; abort path frees it without clearing the driver pointer
- Also stuck -EBUSY on later FTM starts
- Small, self-contained, copies a long-standing MVM abort
- Cancel infrastructure (IWL_MLD_OBJECT_TYPE_FTM_REQ) was already registered; abort was the missing caller
- Maintainer-signed; applies cleanly here
- Same class of “missing stop/abort op” that stable routinely takes
AGAINST:
- Message sells it as “add support,” no crash report, no Fixes/syzbot
- Sent to **iwlwifi-next** in a mixed updates series
- FTM is not a hot path for most desktops
- Adds a new ops pointer (looks like a feature if you only read the subject)
UNRESOLVED:
- Could not fetch lore HTML (403); used b4 mbox instead
- No evidence of a real-world crash report
- Unverified whether unprivileged users can start PMSR on typical distros
**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** (MVM analogue; Intel-authored)
2. Real user-visible bug? **PASS** (UAF / stuck FTM after abort)
3. Important (crash/security/corruption)? **PASS** (UAF is crash/memory- safety; FTM-specific but real)
4. Small and contained? **PASS** (32 lines, one driver)
5. No new features/APIs? **PASS** — implements an existing mac80211 op; not a new syscall/uAPI
6. Can apply to this tree? **PASS** (MLD FTM code is here; helpers exist)
**Step 9.3: Exception category**
Record: Not ID/quirk/DT/build/docs. Ordinary driver correctness fix.
**Step 9.4: Decision**
This is a missing abort handler on a driver that caches a cfg80211-owned object. That is a UAF fix, even though the subject says “support.” It is small, applies here, and does not need the rest of the 15-patch series.
### What it solves for this tree
On 7.3-rc4, iwlwifi MLD FTM start stores req and handles firmware range responses. Without abort, closing the measurement netlink socket or taking the wdev down frees req while the driver and firmware still use it. That is a use-after-free and can pin FTM at -EBUSY. The patch aborts firmware, drops queued FTM notifs, and clears driver state.
### Risk vs benefit
Low risk, high severity if the abort path is hit. Benefit is limited to Intel MLD + FTM users, which is enough given UAF.
Verification:
- [Phase 1] Parsed tags: SOB Stern + Korenblit; Link msgid; no Fixes/Reported-by/Cc stable
- [Phase 2] Diff: +32 lines, iwl_mld_ftm_abort + .abort_pmsr
- [Phase 3] git show ef704fc32ae1a; ancestor of HEAD; introduced with d1e879ec600f9; MVM abort fc36ffda32670
- [Phase 3] git merge-base --is-ancestor ef704fc32ae1a 8d3ae59288f1e → not in 7.2; in 7.3-rc1
- [Phase 3] No follow-ups on ftm-initiator.c after this commit
- [Phase 4] b4 dig -c/-a/-w/-m: v1 iwlwifi-next 01/15, To Johannes, no review replies in mbox
- [Phase 4] WebFetch lore/msgid.link → 403; used local mbox
- [Phase 5] Call chain: cfg80211_release_pmsr / cfg80211_pmsr_wdev_down → kfree after optional abort; iwl_mld_handle_ftm_resp_notif derefs ftm_initiator.req
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; kernelversion 7.3.0-rc4; MLD FTM present
- [Phase 8] Failure mode: UAF on FTM abort + -EBUSY stuck state, severity HIGH
- UNVERIFIED: unprivileged PMSR start; no user crash report
**YES**
.../intel/iwlwifi/mld/ftm-initiator.c | 21 +++++++++++++++++++ .../intel/iwlwifi/mld/ftm-initiator.h | 1 + .../net/wireless/intel/iwlwifi/mld/mac80211.c | 10 +++++++++ 3 files changed, 32 insertions(+)
drivers/net/wireless/intel/iwlwifi/mld/ftm-initiator.c +21 -0
@@ -449,3 +449,24 @@ void iwl_mld_ftm_restart_cleanup(struct iwl_mld *mld) mld->ftm_initiator.req, GFP_KERNEL);iwl_mld_ftm_reset (mld); } + +void iwl_mld_ftm_abort (struct iwl_mld *mld,struct cfg80211_pmsr_request *req) +{ +struct iwl_tof_range_abort_cmd cmd = { + .request_id = req->cookie, + }; + +lockdep_assert_wiphy (mld->wiphy); + +if (req != mld->ftm_initiator.req) +return ; + +if (iwl_mld_send_cmd_pdu (mld,WIDE_ID (LOCATION_GROUP , +TOF_RANGE_ABORT_CMD ), + &cmd)) +IWL_ERR (mld,"failed to abort FTM process\n" ); + +iwl_mld_cancel_notifications_of_object (mld,IWL_MLD_OBJECT_TYPE_FTM_REQ , + mld->ftm_initiator.req->cookie); +iwl_mld_ftm_reset (mld); +}
drivers/net/wireless/intel/iwlwifi/mld/ftm-initiator.h +1 -0
@@ -25,5 +25,6 @@ int iwl_mld_ftm_start(struct iwl_mld *mld, struct ieee80211_vif *vif,void iwl_mld_handle_ftm_resp_notif (struct iwl_mld *mld,struct iwl_rx_packet *pkt);void iwl_mld_ftm_restart_cleanup (struct iwl_mld *mld); +void iwl_mld_ftm_abort (struct iwl_mld *mld,struct cfg80211_pmsr_request *req);#endif /* __iwl_mld_ftm_initiator_h__ */
drivers/net/wireless/intel/iwlwifi/mld/mac80211.c +10 -0
@@ -2609,6 +2609,15 @@ static int iwl_mld_start_pmsr(struct ieee80211_hw *hw,return iwl_mld_ftm_start (mld, vif, request); } +static void iwl_mld_abort_pmsr (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct cfg80211_pmsr_request *request) +{ +struct iwl_mld *mld =IWL_MAC80211_GET_MLD (hw); + +iwl_mld_ftm_abort (mld, request); +} +static enum ieee80211_neg_ttlm_res iwl_mld_can_neg_ttlm (struct ieee80211_hw *hw,struct ieee80211_vif *vif,struct ieee80211_neg_ttlm *neg_ttlm)
@@ -2696,5 +2705,6 @@ const struct ieee80211_ops iwl_mld_hw_ops = { .prep_add_interface = iwl_mld_prep_add_interface, .set_hw_timestamp = iwl_mld_set_hw_timestamp, .start_pmsr = iwl_mld_start_pmsr, + .abort_pmsr = iwl_mld_abort_pmsr, .can_neg_ttlm = iwl_mld_can_neg_ttlm, };
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/realtek: Add quirk for Acer Nitro ANV16-42 headset mic
In reply to Sasha LevinFrom: Zhang Heng <[email protected]>
[ Upstream commit e00a6a89900dfa4cda3669558d2f3581cd41a656 ]
The Acer Nitro ANV16-42 (subsystem 0x1025:0x1909, Realtek ALC245) does not detect the headset microphone jack. Adding the ALC2XX_FIXUP_HEADSET_MIC quirk resolves the issue and restores proper headset mic functionality.
---
LLM Generated explanations, may be completely bogus:
The locally checked-out tree at decision time is **pending-6.12** (p-6.12-3-g710455e2077bb, kernel **6.12.111**). The candidate is mainline e00a6a89900dfa4cda3669558d2f3581cd41a656 and is not an ancestor of HEAD.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
- Subsystem prefix: ALSA: hda/realtek
- Action verb: **Add** (quirk)
- Claimed intent: enable headset-mic detection on Acer Nitro ANV16-42
Record: [ALSA/hda/realtek] [add] [PCI quirk so ANV16-42 headset mic is detected]
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
- Closes: https://bugzilla.kernel.org/show_bug.cgi?id=221623
- Signed-off-by: Zhang Heng \<[email protected]\> (author)
- Signed-off-by: Takashi Iwai \<[email protected]\> (ALSA/HDA maintainer, applied)
- Link:
https://patch.msgid.link/[email protected]
- No Fixes:, no Cc: stable, no Reported-by, no Tested-by, no Reviewed- by, no Acked-by
- (Ignore any Sasha Levin SOB / Upstream commit markers if present in candidates)
Record: [Closes bugzilla 221623] [author Zhang Heng] [maintainer SOB Takashi Iwai] [msgid link] [no Fixes/Cc-stable — expected]
Step 1.3: ANALYZE THE COMMIT BODY TEXT
The Acer Nitro ANV16-42 (SSID 0x1025:0x1909, Realtek ALC245) does not detect the headset microphone jack. ALC2XX_FIXUP_HEADSET_MIC restores it.
Bugzilla 221623 (verified): reporter samuelrenault37, 2026-06-08; status NEW; product Drivers / Sound(ALSA). Reporter states analog-input- headset-mic does not appear without this quirk, points at the same table line, cites sibling Acer Nitro entries, and says it was tested on Fedora 44, kernel 7.0.11. Zhang Heng replied 2026-08-06 that he would submit the patch.
Record: [Bug: headset mic jack not enumerated] [Symptom: no analog- input-headset-mic] [Root cause: missing PCI quirk for SSID 1025:1909] [User-tested]
Step 1.4: DETECT HIDDEN BUG FIXES
Not hidden. Explicit hardware quirk matching the documented stable exception for HDA codec quirks.
Record: [Not a disguised cleanup; it is a hardware quirk]
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Mainline diff: sound/hda/codecs/realtek/alc269.c +1 line. This 6.12 tree uses the pre-split file sound/pci/hda/patch_realtek.c.
Function: alc269_fixup_tbl[] (one SND_PCI_QUIRK entry).
Record: [1 file, +1 line] [alc269_fixup_tbl] [single-file surgical quirk]
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Before: SSID 0x1025:0x1909 has no table match; pin parse does not treat the jack as a headset mic.
After: snd_hda_pick_fixup() in patch_alc269() selects ALC2XX_FIXUP_HEADSET_MIC, which on this tree calls alc_fixup_headset_mic() at HDA_FIXUP_ACT_PRE_PROBE.
That function (verified identical to later alc2xx_fixup_headset_mic):
- applies pin 0x19 config 0x03a1103c
- updates coef 0x45
- sets HDA_PINCFG_HEADSET_MIC
Record: [probe-time pin/coef fixup for this SSID only]
Step 2.3: IDENTIFY THE BUG MECHANISM
Category (h): hardware workaround — PCI quirk table entry for a laptop whose BIOS pin config omits the headset mic.
Record: [Hardware quirk] [SSID 1025:1909 → existing ALC2XX_FIXUP_HEADSET_MIC]
Step 2.4: ASSESS THE FIX QUALITY
Obviously correct: same pattern already used in this tree for Acer Nitro 5 AN515-57/58 and AN517-55. Scope is one table row keyed by SSID, so it cannot affect other machines. Regression risk is very low.
Record: [Surgical, matches existing Acer Nitro entries] [Regression
risk: very low]
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
There is no “buggy line” to blame. The gap is a missing SSID. The fixup ID and function have been in this tree since 1c643c600407d (“Add new alc2xx-fixup-headset-mic model”, upstream 50db91fccea0, in 6.12.y as of 2025-01-09). alc_fixup_headset_mic dates to c8c0a03ec1be6.
Record: [Missing SSID, not a regression in existing code] [Fixup infrastructure present since early 6.12.y]
Step 3.2: FOLLOW THE FIXES: TAG
No Fixes: tag. Expected. This is enablement for a specific machine, not a revert of a bad commit.
Record: [No Fixes: tag; N/A]
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
This tree already contains the same class of backports:
- db8799e80cb73 ALSA: hda/realtek: Enable headset mic for Acer Nitro 5
- 04818a914fdce ALSA: hda/realtek: Add quirk for Acer Nitro AN517-55 Recent patch_realtek.c history is dominated by other one-line HDA quirks.
Record: [Standalone] [Precedent: sibling Acer Nitro headset-mic quirks already in 6.12.y]
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Zhang Heng has other Realtek quirk commits in this tree (e.g. 2362e35c63cae Samsung 750XBE/730XBE, 63a5bca438cfb ASUS UM6702RC). Regular HDA quirk contributor. Applied by Takashi Iwai.
Record: [Regular quirk contributor] [Maintainer applied]
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Submitted as patch 1/4 with three unrelated quirks (Acer Gadget E10 speaker, ASUS Vivobook S5406SA mic, Huawei Matebook Conexant). No shared code. On 6.12, ALC2XX_FIXUP_HEADSET_MIC already exists and points at alc_fixup_headset_mic, whose body matches mainline alc2xx_fixup_headset_mic. ALC245 (0x10ec0245) is already handled in patch_alc269().
Record: [Standalone] [No missing prerequisites in this tree]
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSIONb4 dig -c e00a6a89900dfa4cda3669558d2f3581cd41a656 matched
https://patch.msgid.link/[email protected]b4 dig -a: only v1 ([PATCH 1/4]). Thread saved to mbox. Takashi Iwai reply ([email protected]): “Applied all four patches now. Thanks.” No NAK, no requested changes, no Cc: stable discussion.
Record: [lore/msgid above] [v1 only, applied as submitted] [maintainer applied] [no NAKs]
Step 4.2: CHECK WHO REVIEWED THE PATCHb4 dig -w: To [email protected]; Cc [email protected], linux- [email protected].
Record: [ALSA maintainer was the To: recipient and applied the patch]
Step 4.3: SEARCH FOR THE BUG REPORT
Bugzilla 221623 fetched (HTTP 200 XML). Real user report, codec dump attached (dump itself is only the HDMI codec; the text still names ALC245 / 1025:1909). Author confirmed intent to patch. Reporter claimed the quirk works on their machine.
Record: [One user + author] [Severity: headset mic missing] [Tested by reporter]
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Series 1–4 are independent device quirks. This commit does not need 2/4–4/4.
Record: [Standalone despite 1/4 numbering]
Step 4.5: CHECK STABLE MAILING LIST HISTORY lore.kernel.org/stable search returned HTTP 403.
Record: [UNVERIFIED: no stable-list discussion retrieved]
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: [alc269_fixup_tbl entry only] [runtime: alc_fixup_headset_mic via ALC2XX_FIXUP_HEADSET_MIC]
Step 5.2: TRACE CALLERSpatch_alc269() (sound/pci/hda/patch_realtek.c:12416) calls snd_hda_pick_fixup(..., alc269_fixup_tbl, alc269_fixups) then snd_hda_apply_fixup(..., HDA_FIXUP_ACT_PRE_PROBE). That is the ALC269-family probe path, which includes ALC245 (0x10ec0245 at line 445).
Record: [Codec probe / device enumeration] [Only SSID 1025:1909]
Step 5.3: TRACE CALLEESalc_fixup_headset_mic → snd_hda_apply_pincfgs, alc_update_coef_idx, set spec->parse_flags |= HDA_PINCFG_HEADSET_MIC (defined in sound/pci/hda/hda_auto_parser.h).
Record: [Pin override + headset-mic parse flag]
Step 5.4: FOLLOW THE CALL CHAIN
Userspace does not trigger a special syscall; plugging a headset on this laptop hits the already-probed HDA jack path. Without the quirk the headset mic control never appears.
Record: [Reachable on this laptop at codec probe] [User-visible audio input]
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Same SSID vendor 0x1025 already has three ALC2XX_FIXUP_HEADSET_MIC Acer Nitro rows in this tree (0x1539, 0x159c, 0x1597).
Record: [Systematic Acer Nitro headset-mic pin-config bug; this is another SSID]
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Yes, functionally: quirk table + ALC2XX_FIXUP_HEADSET_MIC + ALC245 support are in sound/pci/hda/patch_realtek.c. The 0x1909 row is absent (git grep 0x1909 on that file: no match). git merge-base --is- ancestor e00a6a89900df HEAD failed.
Record: [Bug/gap exists here] [Introduced as missing hardware description, not by a post-6.12 commit]
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Mainline path is sound/hda/codecs/realtek/alc269.c (post-split). 6.12 still has sound/pci/hda/patch_realtek.c. Insertion context also
differs: 6.12’s last Acer 0x1025 rows are 0x1597 / 0x169a, then Dell 0x1028:0x0470; mainline inserts after 0x1844 Helios ZPS. Needs a trivial path + context backport, not a semantic rework. Exact insert in this
tree: after the 0x169a Acer Swift SFG16 line, before Dell M101z.
Record: [Minor conflicts: file path + nearby rows] [Otherwise clean one- liner]
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
No 0x1909 / ANV16-42 entry. Sibling Nitro quirks are present; they do not cover this SSID.
Record: [No existing fix for 1025:1909]
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [ALSA HD-audio Realtek codec] [IMPORTANT: common laptop audio; quirk is machine-specific]
Step 7.2: ASSESS SUBSYSTEM ACTIVITYpatch_realtek.c is actively receiving quirk backports on this branch (HP mute LED, Samsung, Victus, etc.). Mature table, high quirk churn by design.
Record: [Mature driver, active quirk additions — expected for stable]
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: [Driver-specific / DMI-SSID-specific: Acer Nitro ANV16-42 only]
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: [Every boot/probe on that laptop with a headset jack] [Common for owners of that model] [Unprivileged users hit it via Pulse/PipeWire/ALSA]
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Not a panic. Headset microphone is missing/unusable. That is a real functional regression versus Windows/firmware intent for that SKU. Severity MEDIUM for the platform, HIGH for affected users (basic audio input broken).
Record: [Failure: headset mic not detected] [Severity: MEDIUM (important hardware bug, not crash)]
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Benefit: restores headset mic on a shipping Acer Nitro using an existing, tested fixup. Risk: one SSID-keyed table entry; no API, no lock, no parser change for other IDs.
Record: [Benefit: high for that SKU] [Risk: very low] [Favor backport]
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Documented user bug (bugzilla 221623) with claimed test of this exact quirk
- Textbook hardware quirk / PCI ID exception for stable
- One line, existing ALC2XX_FIXUP_HEADSET_MIC / alc_fixup_headset_mic
- ALC245 already supported; sibling Acer Nitro quirks already in 6.12.y
- Applied by ALSA maintainer; no review objections
- Independent of the rest of the 4-patch series
AGAINST:
- File path/context need a trivial backport (driver split after 6.12)
- Bugzilla codec attachment is only HDMI (incomplete dump); identification still given in the report text
- lore.kernel.org/stable search was blocked (403) UNRESOLVED:
- Could not read stable mailing-list archives (HTTP 403)
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — same fixup as other Nitro rows; reporter tested; maintainer applied
2. Fixes a real bug that affects users? **PASS** — headset mic not enumerated
3. Important issue? **PASS** — hardware unusable (mic), not a crash; still the documented quirk exception
4. Small and contained? **PASS** — +1 line
5. No new features or APIs? **PASS** — existing quirk ID on existing driver
6. Can apply to the local tree? **PASS** — needs path/context adjustment only; semantics exist here
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: [Hardware quirk/workaround — SND_PCI_QUIRK in Realtek HDA table]
Step 9.4: MAKE YOUR DECISION
This is a one-line Realtek HDA PCI quirk for a user-reported broken headset mic, using a fixup already in 6.12.y. It should be backported to this tree.
Verification:
- [Phase 1] Subject/tags: Closes bugzilla 221623; SOB Zhang Heng + Takashi Iwai; msgid 20260807125857.678297-1; no Fixes/Cc-stable
- [Phase 1] Bugzilla XML HTTP 200: reporter samuelrenault37, ALC245 1025:1909, claimed test on Fedora 44 / 7.0.11
- [Phase 2] Diff: +1 SND_PCI_QUIRK(0x1025, 0x1909, ..., ALC2XX_FIXUP_HEADSET_MIC)
- [Phase 2] 6.12 fixup at patch_realtek.c:10552 uses alc_fixup_headset_mic; body matches later alc2xx_fixup_headset_mic (pin 0x19, coef 0x45, HDA_PINCFG_HEADSET_MIC)
- [Phase 3] git merge-base --is-ancestor e00a6a89900df HEAD → not in this tree
- [Phase 3] git grep 0x1909 -- sound/pci/hda/patch_realtek.c → no match
- [Phase 3] ALC2XX_FIXUP_HEADSET_MIC present; sibling Nitro quirks 0x1539/0x159c/0x1597 present
- [Phase 3] 1c643c600407d already in 6.12.y (alc2xx-fixup-headset-mic model)
- [Phase 3] ALC245 0x10ec0245 handled in patch_realtek.c:445
- [Phase 4] b4 dig -c e00a6a89900df → patch.msgid.link/20260807125857.678297-1; v1 only
- [Phase 4] b4 dig -w: To [email protected], Cc linux-sound
- [Phase 4] mbox: Iwai “Applied all four patches now”; series 2/4–4/4 are unrelated machines
- [Phase 4] lore.kernel.org and patch.msgid.link HTTP 403 from curl/WebFetch; used b4 mbox instead
- [Phase 4] UNVERIFIED: stable@ lore search (HTTP 403)
- [Phase 5] Caller: patch_alc269() → snd_hda_pick_fixup(..., alc269_fixup_tbl, ...)
- [Phase 6] git describe HEAD / Makefile: pending-6.12, 6.12.111; file is patch_realtek.c not alc269.c
- [Phase 6] Insertion point: after 0x169a Acer Swift SFG16, before Dell 0x1028:0x0470
- [Phase 8] Failure mode: missing headset mic on one laptop SKU, not a panic
- UNVERIFIED: bugzilla attachment is HDMI-only, so pin dump for ALC245 was not independently re-checked from that file
**YES**
sound/hda/codecs/realtek/alc269.c | 1 + 1 file changed, 1 insertion(+)
sound/hda/codecs/realtek/alc269.c +1 -0
@@ -6595,6 +6595,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x1025 ,0x1826 ,"Acer Helios ZPC" ,ALC287_FIXUP_PREDATOR_SPK_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x1025 ,0x182c ,"Acer Helios ZPD" ,ALC287_FIXUP_PREDATOR_SPK_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x1025 ,0x1844 ,"Acer Helios ZPS" ,ALC287_FIXUP_PREDATOR_SPK_CS35L41_I2C_2 ), +SND_PCI_QUIRK (0x1025 ,0x1909 ,"Acer Nitro ANV16-42" ,ALC2XX_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1028 ,0x0470 ,"Dell M101z" ,ALC269_FIXUP_DELL_M101Z ),SND_PCI_QUIRK (0x1028 ,0x053c ,"Dell Latitude E5430" ,ALC292_FIXUP_DELL_E7X ), SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 rtc: ab-eoz9: add missing MODULE_DEVICE_TABLE()
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit 7490b8356e52e09c196645912f2c054f79aa5f3a ]
The driver has a match table for the i2c bus wired into its driver structure, but the table is not exported with MODULE_DEVICE_TABLE().
Add the missing MODULE_DEVICE_TABLE() entry so module alias information is generated for automatic module loading.
This is a source-level fix. It does not claim dynamic hardware reproduction; the evidence is the driver-owned match table, its use by the driver registration structure, and the missing module alias publication.
---
LLM Generated explanations, may be completely bogus:
This is a one-line MODULE_DEVICE_TABLE(i2c, ...) addition on a driver that already exists in this 6.12 tree. The I2C ID table is wired up but never exported, so i2c-style module autoload is broken.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [rtc: ab-eoz9] [add] [export the existing I2C match table via MODULE_DEVICE_TABLE so aliases are generated for autoload]
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Pengpeng Hou <[email protected]> (author)
- Link:
https://patch.msgid.link/[email protected]
- Signed-off-by: Alexandre Belloni <[email protected]> (RTC maintainer)
- No Fixes: tag (expected for this review queue)
- No Cc: stable (expected)
- No Reported-by / Tested-by / Reviewed-by / Acked-by
- Ignore pipeline SOBs if present
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: abeoz9_id[] is used as id_table but never published with MODULE_DEVICE_TABLE(i2c, ...), so file2alias does not emit i2c:abeoz9 aliases.
- Symptom: when RTC_DRV_ABEOZ9=m, udev/modprobe will not autoload the module for a non-DT I2C instantiation (new_device, board info, etc.).
- Failure mode: driver stays unloaded; RTC does not appear until a manual modprobe rtc-ab-eoz9.
- Version info: none in the message.
- Root cause: missing alias publication, not a match-table or probe- logic error.
- Author explicitly calls this a source-level fix with no dynamic hardware repro.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not hidden. It is a missing-autoload bug. The “source-level” wording does not change that MODULE_DEVICE_TABLE is the documented way I2C drivers publish aliases (Documentation/i2c/writing-clients.rst).
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/rtc/rtc-ab-eoz9.c (+1 / -0)
- One line after abeoz9_id[]: MODULE_DEVICE_TABLE(i2c, abeoz9_id);
- No functions changed; table/registration data only
- Scope: single-file surgical fix
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: OF table already has MODULE_DEVICE_TABLE(of, abeoz9_dt_match). I2C table exists and is assigned to .id_table but is not exported.
- After: I2C table is also exported. Built-in builds are unchanged (MODULE_DEVICE_TABLE is empty when !MODULE in include/linux/module.h).
- Path affected: module-alias generation at build time, not probe/runtime.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Category: hardware enablement / missing device-ID alias (same class as adding IDs)
- Mechanism: without the export, i2c:abeoz9 never appears in module info. i2c_device_uevent() uses MODALIAS=i2c:<name> when OF/ACPI modalias is unavailable (drivers/i2c/i2c-core-base.c). Autoload then fails.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: one standard macro, same pattern as rtc- ab-b5ze-s3.c and most other I2C RTC drivers.
- Minimal: one line, no unrelated edits.
- Regression risk: very low. No locking, no probe/remove change, no ABI. Built-in is a no-op.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Driver added in 67075b63cce26 (“rtc: add AB-RTCMC-32.768kHz-EOZ9 RTC support”, Artem Panfilov, 2019-02-17).
- Present in v5.2. OF MODULE_DEVICE_TABLE was there from day one; I2C export was never added.
- abeoz9_id line { "abeoz9" } last touched by a47d377e22c4a (drop explicit driver_data = 0).
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Buggy pattern dates to the introducing commit 67075b63cce26, which is an ancestor of this HEAD.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- Recent file history is unrelated (temperature/undervoltage, probe style, IRQ flags).
- Not part of a numbered series. Standalone one-liner.
- Sibling Abracon driver rtc-ab-b5ze-s3.c already has both OF and I2C MODULE_DEVICE_TABLE.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record:
- Pengpeng Hou is not the RTC maintainer. Same-day pattern: `can:
ctucanfd: add missing MODULE_DEVICE_TABLE() is already in this tree as 877e99535dfb9 (upstream d937bdb244a7`, with Cc: stable).
- RTC maintainer Alexandre Belloni applied the rtc patch (SOB + “Applied, thanks!”).
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: None. Uses existing abeoz9_id and the existing MODULE_DEVICE_TABLE macro. Standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- lore fetch via WebFetch returned 403; retrieved with b4 mbox msgid [email protected].
- Thread: original patch + Sashiko bot “no issues” + Alexandre Belloni apply mail.
- Single revision (PATCH, not v2/v3). Applied as 7490b8356e52 in the RTC tree.
- Submitted context uses { "abeoz9" }, which matches this 6.12 file (the candidate blob with { .name = "abeoz9" } is a later-mainline context difference only).
- No NAK. No reviewer-requested Cc: stable.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: To: Alexandre Belloni; Cc: linux-rtc, linux-kernel. Maintainer applied it. No other human review comments.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No user/syzbot/bugzilla report. Author states source-level evidence only. No in-tree .dts user of abracon,abeoz9 besides trivial-rtc.yaml.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Batch of missing-MODULE_DEVICE_TABLE scans the same day (at least CAN PCI + this RTC). CAN one already backported here. This RTC patch is self-contained.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: No stable-list discussion found for this subject. Absence is expected; that is why it is in this review queue.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: No functions modified. Data: abeoz9_id[]. Consumers:abeoz9_driver.id_table. Macro: MODULE_DEVICE_TABLE.
Step 5.2: TRACE CALLERS
Record:
- abeoz9_probe is only referenced from abeoz9_driver.probe.
- I2C core calls it on match. Autoload is the gap before probe.
- i2c_device_uevent(): OF alias if of_node, else ACPI, else i2c: + client->name.
Step 5.3: TRACE CALLEES
Record: The new line does not call anything at runtime. file2alias consumes __mod_i2c__abeoz9_id_device_table.
Step 5.4: FOLLOW THE CALL CHAIN
Record:
- Userspace-reachable: instantiating abeoz9 on an I2C adapter (sysfs new_device, board info) with the driver as a module.
- DT path already autoloads via existing OF table.
- !CONFIG_OF / no of_node: I2C alias is the only autoload path, and it is missing.
- Driver does not require DT to probe (abeoz9_trickle_parse_dt returns 0 if the property is absent).
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Most I2C RTC drivers already have MODULE_DEVICE_TABLE(i2c, ...). This driver is the incomplete sibling of rtc-ab-b5ze-s3. Same- day CAN PCI fix already landed in this 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 (VERSION 6 / PATCHLEVEL 12 / SUBLEVEL 111).
- File present. MODULE_DEVICE_TABLE(of, ...) at line 567; abeoz9_id at 570–573; no MODULE_DEVICE_TABLE(i2c, ...).
- 7490b8356e52 is not an ancestor of HEAD (git merge-base --is- ancestor exit 1).
- Bug present since v5.2.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Original mailed patch context is { "abeoz9" }, which is exactly this tree. Clean apply. No refactor blocking it.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No equivalent fix on rtc-ab-eoz9.c. OF alias only.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: drivers/rtc/ I2C RTC. Criticality: PERIPHERAL / driver- specific. RTC still matters for wall-clock and wake on boards that use this Abracon part.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: RTC is mature and still getting stable-worthy fixes in this tree. This file itself is low-churn.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Users of Abracon AB-RTCMC-32.768kHz-EOZ9 with RTC_DRV_ABEOZ9=m. DT boards already autoload. Affected: non-DT I2C instantiation, or any path that emits i2c:abeoz9 rather than the OF modalias. Config-specific (=m only).
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record:
- Trigger: I2C client named abeoz9 appears while the driver is a module and no OF/ACPI modalias is used.
- Not every boot on DT systems.
- Unprivileged users cannot typically create I2C clients; this is not a security trigger.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- Failure: module not loaded; RTC absent until manual modprobe. No oops, UAF, or corruption.
- Severity: MEDIUM for affected hardware (device does not work automatically). LOW globally (niche chip, DT already covered).
- Still a real user-visible bug, same class as missing device IDs.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: medium-low population, high for anyone on the broken autoload path; restores hardware probe without manual load.
- Risk: very low (one line, no runtime code).
- Ratio: favorable. Same class already accepted here for ctucanfd.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real autoload bug: I2C ID table is used but not exported.
- One line, obviously correct, maintainer-applied.
- Driver and bug have been in this 6.12 tree since the v5.2 introduction.
- Original patch applies cleanly here.
- Zero runtime change for built-in; aliases only when =m.
- Stable rules allow device-ID additions; this publishes an existing ID.
- Sibling Abracon RTC already has the I2C export.
- Same-day CAN MODULE_DEVICE_TABLE fix is already in this tree.
AGAINST:
- No user report or syzbot; author says source-level only.
- Not a crash/security/deadlock.
- DT autoload already works; chip is mainly DT/embedded.
- No in-tree board DTS users of abracon,abeoz9.
UNRESOLVED:
- Could not fetch lore.kernel.org via WebFetch (403); thread recovered via b4 mbox.
- No stable-list thread found.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — one standard macro; maintainer applied; matches documented I2C driver pattern.
2. Fixes a real bug that affects users? PASS — missing i2c:abeoz9 alias; module does not autoload on the I2C path.
3. Important issue? PASS under the device-ID / hardware-enablement exception. User-visible: RTC module does not load. Not a panic.
4. Small and contained? PASS — +1 line, one file.
5. No new features or APIs? PASS — existing table, existing macro.
6. Can apply to the local tree? PASS — buggy code present; mailed context matches 6.12.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Device ID / module-alias publication for an existing driver. Not a new driver, API, or module parameter.
Step 9.4: MAKE YOUR DECISION
YES. The bug exists in this 6.12.111 tree, the fix is a one-line alias export with no runtime risk, and it is the same class of hardware- enablement stable already takes (including this author’s CAN patch already on this branch).
What the commit solves for stable users: if rtc-ab-eoz9 is built as a module, I2C instantiation that emits i2c:abeoz9 (non-DT) never autoloads the driver. DT boards already work via the OF table. The extra line closes the I2C alias gap.
Risk vs benefit: benefit is autoload for this RTC on the I2C path; risk is essentially nil. No prerequisites. Original mailed hunk matches this tree’s { "abeoz9" } initializer.
Verification:
- [Phase 1] Parsed tags: author SOB Pengpeng Hou; Link msgid; RTC maintainer SOB Alexandre Belloni; no Fixes/Cc:stable/Reported-by
- [Phase 1] Body: missing I2C MODULE_DEVICE_TABLE; source-level, no hardware repro claimed
- [Phase 2] Diff: +1 line MODULE_DEVICE_TABLE(i2c, abeoz9_id) after abeoz9_id[] in drivers/rtc/rtc-ab-eoz9.c
- [Phase 2] include/linux/module.h: macro is alias-only when MODULE, empty when built-in
- [Phase 3] blame: table from 67075b63cce26 (2019); OF export present then; I2C export never added
- [Phase 3] git merge-base --is-ancestor 67075b63cce26 HEAD:
introducing commit is in this tree; in v5.2
- [Phase 3] git log --oneline --grep='MODULE_DEVICE_TABLE' -- drivers/rtc/rtc-ab-eoz9.c: empty (fix not here)
- [Phase 3] Same-author 877e99535dfb9 can/ctucanfd MODULE_DEVICE_TABLE already in this tree
- [Phase 4] b4 mbox msgid [email protected]: 3 messages; maintainer applied as 7490b8356e52; mailed hunk uses { "abeoz9" }
- [Phase 4] WebFetch lore/msgid.link: 403; discussion recovered from mbox and openwall/lkml mirrors
- [Phase 5] i2c_device_uevent: OF first, then ACPI, then MODALIAS=i2c: + client name
- [Phase 5] grep: abeoz9_probe only from this driver; no in-tree DTS users besides trivial-rtc.yaml
- [Phase 5] rtc-ab-b5ze-s3.c already has both OF and I2C MODULE_DEVICE_TABLE
- [Phase 6] git describe HEAD: p-6.12-3-gc504cf0baa3d8; make kernelversion: 6.12.111
- [Phase 6] Local file lines 562–582: OF table exported; I2C table not; { "abeoz9" }
- [Phase 6] git merge-base --is-ancestor 7490b8356e52 HEAD: exit 1 (not in this tree)
- [Phase 7] Kconfig RTC_DRV_ABEOZ9 is tristate; not set in defconfigs searched
- [Phase 8] Failure mode: missing module autoload for I2C path, severity MEDIUM for that hardware, not a crash
- UNVERIFIED: live lore.kernel.org HTML (403); no stable-list hit for this subject
**YES**
drivers/rtc/rtc-ab-eoz9.c | 1 + 1 file changed, 1 insertion(+)
drivers/rtc/rtc-ab-eoz9.c +1 -0
@@ -549,6 +549,7 @@ static const struct i2c_device_id abeoz9_id[] = { { "abeoz9" }, { } }; +MODULE_DEVICE_TABLE (i2c, abeoz9_id);static struct i2c_driver abeoz9_driver = { .driver = {
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] rtc: ab-eoz9: add missing MODULE_DEVICE_TABLE()
Sashiko has reviewed this patch and found no issues.
Quoted 15 lines
From: Pengpeng Hou <[email protected]>
[ Upstream commit
7490b8356e52e09c196645912f2c054f79aa5f3a]The driver has a match table for the i2c bus wired into its driver structure, but the table is not exported with
MODULE_DEVICE_TABLE().Add the missing
MODULE_DEVICE_TABLE()entry so module alias information is generated for automatic module loading.This is a source-level fix. It does not claim dynamic hardware reproduction; the evidence is the driver-owned match table, its use by the driver registration structure, and the missing module alias publication.
Quoted 4 lines
Signed-off-by Pengpeng Hou <[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 exfat: keep FITRIM within the requested range
In reply to Sasha LevinFrom: Yang Wen <[email protected]>
[ Upstream commit 2de727471b3b13409466a4af4f8824a86073bf4b ]
exfat_find_free_bitmap() searches the entire allocation bitmap and may wrap around to its beginning. exfat_trim_fs() does not verify that the returned cluster is still within the requested FITRIM range.
As a result, a partial FITRIM operation may discard free clusters outside the user-specified range and report a trimmed length larger than the requested length.
Validate each returned cluster against the requested range and stop the search when it wraps around or passes the range end.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). The FITRIM range bug is in this checkout, and the fix applies cleanly.
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
- Record: **[exfat] [keep / constrain] keep FITRIM within the requested range**
- Subsystem: exfat. Action is “keep … within”, i.e. stop the ioctl from acting outside the caller’s range.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Commit 2de727471b3b13409466a4af4f8824a86073bf4b (mainline, contained in v7.3-rc1):
- Signed-off-by: Yang Wen \<[email protected]\> (author)
- Signed-off-by: Namjae Jeon \<[email protected]\> (exFAT maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, Link:, or Cc: stable (absence is expected for this review)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Record: **[Bug]** exfat_find_free_bitmap() walks the whole allocation bitmap and **wraps to cluster 2**. exfat_trim_fs() treats that result as the next hole to discard, without checking the FITRIM range.
- **[Symptom]** A **partial** FITRIM can sb_issue_discard() free clusters **outside** range->start/range->len, and write back a range->len **larger than requested**.
- **[Root cause]** Trim reused the allocator’s circular free-cluster search and never rejected a wrapped or out-of-range cluster.
- **[Versions]** Message does not name versions. FITRIM was added in 654762df2ec7d (v5.13); wrap-around has been in exfat_find_free_bitmap() since 1e49a94cf70720 (exFAT bitmap ops).
**Step 1.4: DETECT HIDDEN BUG FIXES**
- Record: **Not a disguised cleanup.** It is an explicit FITRIM correctness fix (wrong discard range + wrong reported length).
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
- Record: **fs/exfat/balloc.c only** — 19 insertions, 12 deletions (net +7). Function: exfat_trim_fs(). **Single-function surgical fix.**
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Local exfat_trim_fs() (lines 309–387) is **byte-identical** to the parent of 2de727471b3b1.
Before:
1. trim_begin = exfat_find_free_bitmap(sb, clu_start) — wrap is ignored.
2. Second search; EOF bails **before** remainder trim.
3. do { ... } while (next != EOF && next > trim_end) — wrap at the **end** of an iteration can exit, but if the wrapped cluster was **assigned** to trim_begin/trim_end, wrap detection is lost and the loop trims from the start of the volume.
4. next >= clu_end does not catch wrap-to-beginning.
After:
1. Reject first cluster if EOF or `trim_begin < clu_start || trim_begin
Quoted 1 line
clu_end`.
2. for (;;): stop when trim_end >= clu_end.
3. Reject next cluster if EOF, wrap (next <= trim_end), or next > clu_end.
4. Remainder trim still runs for the last in-range hole.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
- Record: **[Logic / correctness]** FITRIM range not enforced against a wrapping bitmap walk. Also a minor hole: old EOF-on-second-search skipped remainder trim of a valid in-range hole.
**Step 2.4: ASSESS THE FIX QUALITY**
- Record: **Obviously correct.** Range checks match FITRIM’s [clu_start, clu_end]. Wrap is next <= trim_end. Inclusive end:
trim_end++ only when next == trim_end+1 and next <= clu_end. fatal_signal_pending kept. No API/lock/structure changes. **Low regression risk** (tightens discard, does not expand it). Remainder after a range-validated hole cannot start outside the range.
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
- Record: Entire exfat_trim_fs() is **654762df2ec7d** (“exfat: add support ioctl and FITRIM function”, Hyeongseok Kim, 2021-03-04). Wrap in exfat_find_free_bitmap() is **1e49a94cf70720** (“exfat: add bitmap operations”). Bug is as old as FITRIM itself (**v5.13**).
**Step 3.2: FOLLOW THE FIXES: TAG**
- Record: **No Fixes: tag.** Introducer is 654762df2ec7d, **present in this tree** (git merge-base --is-ancestor succeeded).
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
- Record: Recent local fs/exfat/balloc.c commits are bitmap validation, soft lockup, leaks, ffs/hweight — **none change trim**. Mainline after this fix has **no further balloc.c commits**. **Standalone, not a series.**
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
- Record: **Yang Wen** has **no** prior fs/exfat/ commits in this tree. **Namjae Jeon** is the exFAT maintainer and applied the patch the next day.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
- Record: **None.** Uses existing exfat_find_free_bitmap, sb_issue_discard, clu_start/clu_end. git apply --check **succeeds** (hunks at offset −12).
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
- Record: **[Lore]**
https://patch.msgid.link/[email protected]
- **[Revisions]** **v1 only** (b4 dig -a). Applied as submitted.
- Maintainer reply (Namjae Jeon, 2026-08-14): **“Applied it to #dev. Thanks!”** — no NAK, no requested changes, no stable nomination in- thread.
- WebFetch/curl to lore.kernel.org hit Anubis bot-check (403). Thread recovered via **b4 dig -m**.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
- Record: To/Cc: Namjae Jeon, Sungjong Seo, Yuezhang Mo, [email protected], linux-kernel. **Maintainer applied v1.** No extra Reviewed-by on the commit.
**Step 4.3: SEARCH FOR THE BUG REPORT**
- Record: **No Reported-by / bugzilla / syzbot.** Analysis-driven, not a user crash report.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
- Record: **Standalone single patch.** No follow-up on origin/master for this function.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
- Record: lore.kernel.org/stable search **blocked** (Anubis). **UNVERIFIED** whether stable@ discussed this. Not used as a NO signal.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
- Record: **Modified:** exfat_trim_fs(). **Relies on:** exfat_find_free_bitmap() (wraps; unchanged).
**Step 5.2: TRACE CALLERS**
- Record: Only **exfat_ioctl_fitrim()** in fs/exfat/file.c (FITRIM ioctl). Requires **CAP_SYS_ADMIN**. Copies struct fstrim_range in/out; range.len is the trimmed-byte count userspace sees (fstrim -v).
**Step 5.3: TRACE CALLEES**
- Record: exfat_find_free_bitmap(), sb_issue_discard(), exfat_cluster_to_sector(), mutex_lock(&sbi->bitmap_lock), fatal_signal_pending().
**Step 5.4: FOLLOW THE CALL CHAIN**
- Record: ioctl(FITRIM) → exfat_ioctl() → exfat_ioctl_fitrim() → exfat_trim_fs(). Reachable from userspace **with CAP_SYS_ADMIN** (fstrim, systemd-fstrim, Android idle trim). **Not** an unprivileged path.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
- Record: **FAT** fat_trim_fs() walks **only** ent_start..ent_end (no wrap). exFAT is the outlier. FAT’s loop is the intended FITRIM contract.
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
- Record: **Yes.** fs/exfat/balloc.c exfat_trim_fs() matches the pre-fix function (SHA-1 of the function text identical to 2de727471b3b1^). Introduced **v5.13**, present in **6.12.111**. Candidate **not** an ancestor of HEAD.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
- Record: **Clean apply** (git apply --check, offset −12 from later bitmap-load changes that do not touch trim). **No rework needed.**
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
- Record: **No** other FITRIM-range fix in this tree. Only FITRIM commit is the original add (654762df2ec7d).
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: SUBSYSTEM AND CRITICALITY**
- Record: **[exFAT filesystem] [IMPORTANT]** — SD cards, USB sticks, Android/embedded. Not mm/VFS-core, but a widely shipped FS.
**Step 7.2: SUBSYSTEM ACTIVITY**
- Record: **Active** (bitmap validation, lockups, leaks). Trim loop itself has been **unchanged since 2021**.
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
- Record: **Filesystem-specific (exFAT) + ioctl path.** Anyone running **partial** FITRIM (fstrim -o/-l, chunked idle trim). Full-volume trim (start=0, len=ULLONG_MAX) sets clu_start to EXFAT_FIRST_CLUSTER, so wrap is inside the requested range — **default fstrim is largely unaffected**.
**Step 8.2: TRIGGER CONDITIONS**
- Record: CAP_SYS_ADMIN FITRIM with a **range that is not the whole volume**, and **no free cluster from clu_start to end of bitmap** (first search wraps), **or** a hole whose next free cluster is found only after wrap. Not a race (bitmap_lock held). Unprivileged users **cannot** trigger it.
**Step 8.3: FAILURE MODE SEVERITY**
- Record: **Wrong-range discard of free clusters** + **inflated range->len**. Not a panic/UAF. On SSDs: extra wear and extra latency. On thin/sparse LUNs: **unmap of the wrong region** (space accounting / unexpected hole punch of free space outside the requested byte range). File data in allocated clusters is not discarded. **Severity: MEDIUM** (contract + device-side unmap), not CRITICAL.
**Step 8.4: RISK-BENEFIT RATIO**
- Record: **Benefit: medium** (correct FITRIM; matters for ranged/chunked trim on exFAT). **Risk: very low** (~20-line single- function tighten). **Ratio: favorable.**
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real FITRIM bug: discard and reported length ignore the requested range when the bitmap search wraps.
- Present in this 6.12 tree since v5.13; function matches mainline parent.
- Small, obviously correct, applies cleanly; no new API.
- Maintainer applied v1 the next day; no follow-up revert/fix.
- FAT already confines trim to the range; this aligns exFAT with that contract.
- Extra/wrong-range discard is user-visible and can unmap the wrong thin-provisioned region.
AGAINST:
- Not a crash, UAF, or file-data corruption.
- Needs CAP_SYS_ADMIN; default full-FS fstrim rarely hits wrap.
- No Reported-by / Tested-by / syzbot.
- “Important” is a correctness/contract issue, not panic-class.
UNRESOLVED:
- Stable@ discussion (lore blocked).
- How often 6.12 users actually pass a partial FITRIM range.
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — logic is local and checkable; maintainer merged v1; in mainline as of v7.3-rc1. No separate Tested-by.
2. Fixes a real bug that affects users? **PASS** — ranged FITRIM discards the wrong free clusters and lies about len.
3. Important issue? **PASS** (MEDIUM) — wrong discard range / thin unmap / wrong userspace length, not a crash. Still a real FS ioctl bug, not a cleanup.
4. Small and contained? **PASS** — one function, +19/−12.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — git apply --check succeeded.
**Step 9.3: EXCEPTION CATEGORIES**
- Record: **None** (not a device ID/quirk/DT/build/doc exception). Qualifies as a normal bugfix.
**Step 9.4: DECISION**
This tree still has the original 2021 trim loop. The fix is a tight range/wrap check, not a refactor. For 6.12 users of exFAT FITRIM, especially chunked/partial trim, backporting prevents out-of-range discards with negligible risk.
### What the commit solves for this tree
Partial FITRIM on exFAT can discard free clusters **before** the requested offset after exfat_find_free_bitmap() wraps, and return a **larger** trimmed length than requested. That violates the ioctl contract and can TRIM the wrong region on SSDs/thin volumes. The code path exists here unchanged; the patch applies cleanly.
### Risk vs benefit
Benefit is correctness of a privileged but standard maintenance ioctl on a common removable/Android filesystem. Risk is very low: fewer discards, same locks, same helpers.
---
Verification:
- [Phase 1] git log -1 / git show 2de727471b3b1: subject/body/SOBs only; no Fixes/Reported-by/Cc stable
- [Phase 1] Local tree: git describe HEAD → p-6.12-3-gc504cf0baa3d8; make kernelversion → **6.12.111**
- [Phase 2] Diff is only exfat_trim_fs() in fs/exfat/balloc.c (+19/−12)
- [Phase 2] Read local exfat_trim_fs (balloc.c:309–387) and exfat_find_free_bitmap wrap (balloc.c:266–271)
- [Phase 2] Function SHA-1 of local trim == parent of 2de727471b3b1
- [Phase 3] git blame -L 309,387 fs/exfat/balloc.c → all 654762df2ec7d (v5.13 FITRIM)
- [Phase 3] git blame -L 266,274 wrap → 1e49a94cf70720
- [Phase 3] git merge-base --is-ancestor 654762df2ec7d HEAD → yes; 2de727471b3b1 → **not** in HEAD
- [Phase 3] git apply --check of 2de727471b3b1 → **success**, offset −12
- [Phase 3] git log origin/master -- fs/exfat/balloc.c after the fix → **empty** (no follow-up)
- [Phase 4] b4 dig -c 2de727471b3b1 →
https://patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1 only; -w: maintainer + Seo + Mo + exfat list
- [Phase 4] mbox: Namjae Jeon “Applied it to #dev”; no NAK/stable tag
- [Phase 4] lore WebFetch/curl: **403 Anubis** — stable@ search UNVERIFIED
- [Phase 5] Callers: only exfat_ioctl_fitrim(); capable(CAP_SYS_ADMIN)
- [Phase 5] FAT fat_trim_fs() already limits to ent_start..ent_end
- [Phase 6] Buggy loop present; no prior range fix in this tree
- [Phase 8] Failure: out-of-range discard + bad range->len; severity MEDIUM
- UNVERIFIED: whether this SHA was already discussed on stable@
The patch is a small, correctly scoped FITRIM range check for a bug that exists in this 6.12 tree and applies without prerequisites.
**YES**
fs/exfat/balloc.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)
fs/exfat/balloc.c +19 -12
@@ -327,14 +327,27 @@ int exfat_trim_fs(struct inode *inode, struct fstrim_range *range)mutex_lock (&sbi->bitmap_lock); trim_begin = trim_end =exfat_find_free_bitmap (sb, clu_start); -if (trim_begin ==EXFAT_EOF_CLUSTER ) +/* +* exfat_find_free_bitmap() may wrap around to the beginning of +* the bitmap. Reject a cluster outside the requested range. +*/ +if (trim_begin ==EXFAT_EOF_CLUSTER || + trim_begin < clu_start || trim_begin > clu_end) goto unlock; - next_free_clu =exfat_find_free_bitmap (sb, trim_end +1 ); -if (next_free_clu ==EXFAT_EOF_CLUSTER ) - goto unlock; +for (;;) { +if (trim_end >= clu_end) +break ; + + next_free_clu =exfat_find_free_bitmap (sb, trim_end +1 ); +/* +* Stop if the search wrapped around or moved beyond the requested +* FITRIM range. +*/ +if (next_free_clu ==EXFAT_EOF_CLUSTER || + next_free_clu <= trim_end || next_free_clu > clu_end) +break ; - do {if (next_free_clu == trim_end +1 ) {/* extend trim range for continuous free cluster */ trim_end++;
@@ -355,17 +368,11 @@ int exfat_trim_fs(struct inode *inode, struct fstrim_range *range) trim_begin = trim_end = next_free_clu; } -if (next_free_clu >= clu_end) -break ; -if (fatal_signal_pending (current)) { err = -ERESTARTSYS ; goto unlock; } - - next_free_clu =exfat_find_free_bitmap (sb, next_free_clu +1 ); - }while (next_free_clu !=EXFAT_EOF_CLUSTER && - next_free_clu > trim_end); + }/* try to trim remainder */ count = trim_end - trim_begin +1 ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 HID: wacom: avoid copying Bluetooth input reports
In reply to Sasha LevinFrom: Ruoyu Wang <[email protected]>
[ Upstream commit 8310cdeefc8a14d2093c3234b570c7805c20bcbf ]
wacom_intuos_bt_irq() duplicates the received Bluetooth report with kmemdup() so that it can pass 10-byte input report payloads to the common Intuos parser. The helper then copies each payload back into wacom->data before calling wacom_intuos_irq().
Avoid the allocation and copy by temporarily pointing wacom->data at the current 10-byte payload while the common parser runs, then restoring the original report pointer. The Bluetooth report parser keeps using the original report buffer for dispatch and battery parsing, while the common parser sees the same payload bytes as before.
This also removes the unchecked kmemdup() result from the Bluetooth IRQ path.
---
LLM Generated explanations, may be completely bogus:
Vanilla 6.18.53 still has the unchecked kmemdup(GFP_KERNEL) in this Bluetooth IRQ path. The rest of the walkthrough is below.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [HID: wacom] [avoid] [stop kmemdup/memcpy of Bluetooth Intuos reports by switching the parser onto the live 10-byte payload]
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Suggested-by: Jason Gerecke <[email protected]>
- Signed-off-by: Ruoyu Wang <[email protected]> (author)
- Reviewed-by: Jason Gerecke <[email protected]> (Wacom driver maintainer)
- Signed-off-by: Jiri Kosina <[email protected]> (HID maintainer)
- Ignore: [Upstream commit 8310cdeefc8a...], Signed-off-by: Sasha Levin
- No Fixes:, Reported-by:, Tested-by:, Link:, or Cc: stable (absence expected)
Notable: maintainer both suggested the approach and reviewed it.
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: wacom_intuos_bt_irq() kmemdup()s the Bluetooth report, then wacom_intuos_bt_process_data() memcpys each 10-byte payload into wacom->data for wacom_intuos_irq(). The kmemdup() result is not checked.
- Symptom: NULL deref of data[0] if allocation fails; also an allocation+copy on every report.
- Version info: none in the message. The kmemdup itself was added later (see Phase 3).
- Root cause: the copy exists only so the shared Intuos parser can see a 10-byte payload without destroying the packed Bluetooth report. The author replaces that with a temporary wacom->data pointer swap.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Yes. v1 on the list was explicitly HID: wacom: handle kmemdup failure in Bluetooth IRQ path (NULL check). v2, at Jason Gerecke’s request, removes the allocation instead. This is a crash fix written as “avoid copying.”
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/hid/wacom_wac.c (~5 insertions, 3 deletions; series mail said 8 lines)
- Functions: wacom_intuos_bt_process_data(), wacom_intuos_bt_irq()
- Scope: single-file surgical fix
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: wacom_intuos_bt_irq() does data = kmemdup(wacom->data, len, GFP_KERNEL) then switch (data[0]). Helper memcpy(wacom->data, data, 10) then wacom_intuos_irq(). kfree(data) at the end.
- After: data = wacom->data. Helper saves wacom->data, points it at the 10-byte slice, calls wacom_intuos_irq(), restores the original pointer.
- Path: HID input IRQ for INTUOS4WL (Wacom Intuos4 Wireless, USB ID 0xBD), not probe/error-only.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Category: NULL deref on failed kmemdup; GFP_KERNEL allocation on the HID input IRQ path.
- Mechanism: hid_irq_in() (USB URB complete) → hid_safe_input_report() → wacom_raw_event() → wacom_wac_irq() → wacom_intuos_bt_irq(). __hid_input_report() uses down_trylock() because this can run in atomic context. kmemdup(..., GFP_KERNEL) there can sleep or return NULL; switch (data[0]) then oopses. The pointer swap keeps the packed report intact without allocating.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Quality: small, equivalent for this device. wacom_intuos_inout() / wacom_intuos_general() / INTUOS4 pad parsing only read data[0]–data[9]. Restore of wacom->data is synchronous; nothing stashes the pointer.
- Regression risk: low-medium. Sashiko flagged unaligned be16_to_cpup((__be16 *)&data[2]) because payloads start at offset 1/11. Old memcpy landed those 10 bytes on the aligned URB buffer; the new pointer does not. Jason Gerecke treated that as non-blocking and asked for a later alignment cleanup. Intuos4 WL is a PC USB tablet, so strict-alignment ARM faults are unlikely. No API/data- structure change.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Bluetooth packing/memcpy helper: 81af7e61a774e6 (Benjamin Tissoires, 2014-08-06).
- kmemdup/kfree: 5e013ad206895e (“HID: wacom: Remove static WACOM_PKGLEN_MAX limit”, Jason Gerecke, 2025-03-03). That replaced a stack unsigned char data[WACOM_PKGLEN_MAX] + memcpy. First in v6.15 (in v6.15, not in v6.14). Present in this 6.18.53 tree.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Functionally this repairs 5e013ad206895e, which is an ancestor of this tree.
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- c8dc23c97680e “HID: wacom: fix out-of-bounds read in wacom_intuos_bt_irq” — length checks; already in v6.18.53.
- 74ec08f7b81c2 — Pro2 BT length validation, different function.
- Standalone; not patch x/y. No extra prereqs beyond the kmemdup code this tree already has.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Ruoyu Wang has this one wacom commit here. Jason Gerecke is the Wacom maintainer and both introduced the kmemdup and reviewed this fix.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: None. Uses existing wacom->data / wacom_intuos_irq(). Applies to v6.18.53 as written.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- Lore/msgid:
https://patch.msgid.link/[email protected]
- v1 (2026-06-06):
https://patch.msgid.link/[email protected] — NULL-check only.
- v2 (2026-06-17): pointer swap, as Jason asked.
- v1: Jason Reviewed-by + “do away with the kmemdup entirely.”
- v2: Sashiko unaligned-access warning; Jason: do not block; wants a later alignment cleanup; Reviewed-by.
- Jiri Kosina: “Applied, thanks.”
- No NAK. No reviewer Cc: stable.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: To/Cc: Ping Cheng, Jason Gerecke, Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel. Jason reviewed; Jiri applied.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No Reported-by / bugzilla / syzbot. Found by code review of the unchecked kmemdup.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: v1→v2 of one patch, not a multi-commit series. Related OOB fix already in this tree.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: UNVERIFIED — lore.kernel.org/stable returned 403. b4 thread has no stable discussion.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: wacom_intuos_bt_process_data(), wacom_intuos_bt_irq().
Step 5.2: TRACE CALLERS
Record:
- wacom_intuos_bt_irq() ← wacom_wac_irq() case INTUOS4WL (drivers/hid/wacom_wac.c).
- wacom_wac_irq() ← wacom_raw_event() (wacom_sys.c).
- USB: hid_irq_in() (drivers/hid/usbhid/hid-core.c) calls hid_safe_input_report() from URB complete (atomic/softirq).
- Bluetooth HIDP: hidp_process_report() from the l2cap/session path (process context). This device is USB ID 0xBD, so the USB IRQ path is the one that matters.
- Device table: wacom_features_0xBD / “Wacom Intuos4 WL”.
Step 5.3: TRACE CALLEES
Record: wacom_intuos_irq() → pad/inout/general parsers; wacom_notify_battery(); input_sync(). No alloc after the change.
Step 5.4: FOLLOW THE CALL CHAIN
Record: Reachable from normal USB HID input of Intuos4 Wireless. Unprivileged userspace is not required; hardware input is enough. Not a syscall fuzzer path.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Pro2 BT (wacom_intuos_pro2_bt_irq) does not kmemdup. This packed 10-byte copy was unique to Intuos4 WL.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. Local tree: 6.18.53 (autosel, v6.18.53-5049-g0f0bdc2b0dffb). v6.18.53:drivers/hid/wacom_wac.c still has kmemdup + memcpy + unchecked data[0]. Upstream fix 8310cdeefc8a is not an ancestor of v6.18.53.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Clean apply. Surrounding OOB length checks are already in 6.18.53.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: OOB length checks yes. No earlier version of this pointer- swap/NULL-check.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: HID / Wacom tablet driver. IMPORTANT for tablet users, PERIPHERAL overall (one 2010-era wireless Intuos4 model).
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Active (device IDs, BT OOB fixes, pktlen work). The kmemdup is from the v6.15 pktlen change, not ancient code.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver-specific — Intuos4 Wireless (INTUOS4WL, USB 0x056A:0x00BD).
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Every packed BT/WL input report allocates. Oops if kmemdup fails; GFP_KERNEL from USB complete is illegal even when the alloc hits the slab cache. Not a userspace-triggered security hole.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: NULL deref → oops (HIGH). GFP_KERNEL from URB complete → sleeping-in-atomic WARN/instability (HIGH). Practical hit rate is low (small alloc, old device), but the bug is on the live input path.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: medium — real IRQ-path crash/atomic-sleep fix, small user population.
- Risk: low — ~8 lines, maintainer-reviewed; unaligned be16_to_cpup is the main caveat and was accepted upstream.
- Ratio: benefit outweighs risk for 6.18.y.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Unchecked kmemdup NULL deref in this 6.18.53 tree.
- GFP_KERNEL on USB HID URB complete; 5e013ad replaced an atomic-safe stack buffer.
- v1 was an explicit crash fix; v2 is the maintainer-preferred form.
- Reviewed by Jason Gerecke, applied by Jiri Kosina.
- Small, no new API, applies cleanly, parsers only use 10 payload bytes.
AGAINST:
- Niche Intuos4 Wireless hardware.
- No user/syzbot report.
- Subject reads like an optimization.
- Unaligned access vs old memcpy-to-aligned-buffer; no follow-up alignment patch verified here.
UNRESOLVED:
- No stable@ thread (lore 403).
- No evidence of a field oops.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — pointer save/restore; Wacom maintainer Reviewed-by.
2. Fixes a real bug that affects users? PASS — NULL deref and GFP_KERNEL in IRQ on a shipping device path.
3. Important issue? PASS — oops / sleeping-in-atomic (HIGH), not a style cleanup.
4. Small and contained? PASS — one file, ~8 lines.
5. No new features or APIs? PASS.
6. Can apply to the local tree? PASS — buggy code is in v6.18.53; patch matches.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary bugfix.
Step 9.4: MAKE YOUR DECISION
This belongs on 6.18.53. The tree still does kmemdup(..., GFP_KERNEL) in wacom_intuos_bt_irq() and dereferences data[0] with no NULL check, on the USB HID complete path. Replacing that with a temporary wacom->data pointer is the same fix the maintainer asked for, and it applies here without extra commits.
Verification:
- [Phase 1] Tags: Suggested-by/Reviewed-by Jason Gerecke, SOB Ruoyu Wang and Jiri Kosina; no Fixes/Reported-by/Cc: stable
- [Phase 1] v1 subject from b4: “handle kmemdup failure in Bluetooth IRQ path”
- [Phase 2] Diff: drop kmemdup/kfree/memcpy; save/restore wacom->data around wacom_intuos_irq()
- [Phase 2] Parsers for INTUOS4WL use data[0]–data[9] only (inout/general/pad)
- [Phase 3] Blame: kmemdup from 5e013ad206895e (v6.15+); in HEAD and v6.18.53
- [Phase 3] git merge-base --is-ancestor 5e013ad206895e v6.18.53 → yes; 8310cdeefc8a → no
- [Phase 3] Related OOB fix c8dc23c97680e already in v6.18.53
- [Phase 4] b4 dig -c 8310cdeefc8a → v1+v2 msgid links; Jason reviewed both; Jiri applied v2
- [Phase 4] Sashiko unaligned warning; Jason said do not block
- [Phase 4] lore.kernel.org WebFetch 403; stable@ search UNVERIFIED
- [Phase 5] Call chain: hid_irq_in → hid_safe_input_report → wacom_raw_event → wacom_intuos_bt_irq; USB 0xBD Intuos4 WL
- [Phase 6] git describe HEAD → v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion → 6.18.53
- [Phase 6] git show v6.18.53:drivers/hid/wacom_wac.c still has kmemdup
- [Phase 8] Failure: NULL deref / GFP_KERNEL from URB complete; severity HIGH
- UNVERIFIED: whether this was already requested on stable@
**YES**
drivers/hid/wacom_wac.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/hid/wacom_wac.c +5 -3
@@ -1192,8 +1192,11 @@ static int int_dist(int x1, int y1, int x2, int y2)static void wacom_intuos_bt_process_data (struct wacom_wac *wacom,unsigned char *data) { -memcpy (wacom->data, data,10 ); +u8 *saved_data = wacom->data; + + wacom->data = data;wacom_intuos_irq (wacom); + wacom->data = saved_data;input_sync (wacom->pen_input);if (wacom->pad_input)
@@ -1202,7 +1205,7 @@ static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,static int wacom_intuos_bt_irq (struct wacom_wac *wacom,size_t len) { -u8 *data =kmemdup (wacom->data, len,GFP_KERNEL ); +u8 *data = wacom->data;int i =1 ;unsigned power_raw, battery_capacity, bat_charging, ps_connected;
@@ -1242,7 +1245,6 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)break ; } -kfree (data);return 0 ; }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18] HID: wacom: avoid copying Bluetooth input reports
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] HID: wacom: unaligned 16-bit reads in wacom_intuos_general() on BT reports --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] HID: wacom: unaligned 16-bit reads in wacom_intuos_general() on BT reports --
commit c4e8a30b627ffd270cacd2aea99e17a24a724562
Author: Ruoyu Wang <[email protected]>
HID: wacom: avoid copying Bluetooth input reports
This commit avoids duplicating Bluetooth reports with kmemdup() in wacom_intuos_bt_irq() by temporarily updating wacom->data to point at each 10-byte payload slice in wacom_intuos_bt_process_data() before calling wacom_intuos_irq().
Quoted 5 lines
drivers/hid/wacom_wac.c +0
-0
drivers/hid/wacom_wac.c static int int_dist(int x1, int y1, int x2, int y2) · line 1199
Quoted 9 lines
drivers/hid/wacom_wac.c +4
-1@@ -1192,8 +1192,11 @@ static int int_dist(int x1, int y1, int x2, int y2)static void wacom_intuos_bt_process_data (struct wacom_wac *wacom,unsigned char *data) { -memcpy (wacom->data, data,10 ); +u8 *saved_data = wacom->data; + + wacom->data = data;wacom_intuos_irq (wacom); + wacom->data = saved_data;
[Severity: Medium]
Could pointing wacom->data directly at the payload slice introduce unaligned 16-bit memory accesses in wacom_intuos_general()?
When an Intuos4 Wireless report 0x03 or 0x04 arrives in wacom_intuos_bt_irq(), it calls wacom_intuos_bt_process_data(wacom, data + i) with odd byte offsets (i = 1, 11, and 21):
drivers/hid/wacom_wac.c:wacom_intuos_bt_irq() {
...
switch (data[0]) {
case 0x04:
...
wacom_intuos_bt_process_data(wacom, data + i);
i += 10;
fallthrough;
case 0x03:
...
wacom_intuos_bt_process_data(wacom, data + i);
i += 10;
wacom_intuos_bt_process_data(wacom, data + i);
i += 10;
...
}Previously, memcpy(wacom->data, data, 10) copied each 10-byte payload to the start of the aligned wacom->data buffer. By setting wacom->data to data + 1, data + 11, or data + 21 directly, the call chain wacom_intuos_bt_process_data() -> wacom_intuos_irq() -> wacom_intuos_general() will dereference &data[2] and &data[4] at odd byte offsets (3, 5, 13, 15, 23, and 25) via be16_to_cpup():
drivers/hid/wacom_wac.c:wacom_intuos_general() {
...
x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1);
y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1);
...
}Since be16_to_cpup() expects natural 16-bit alignment, won't this trigger UBSAN alignment splats or alignment faults on strict-alignment architectures unless get_unaligned_be16() is used?
Quoted 3 lines
drivers/hid/wacom_wac.c +0
-0input_sync (wacom->pen_input);if (wacom->pad_input)
[ ... ]
Quoted 3 lines
[]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 wifi: mt76: mt76x02: report rx FCS errors to mac80211
In reply to Sasha LevinFrom: Devin Wittmayer <[email protected]>
[ Upstream commit ddae0bcb01e71c1184bb3f526f9622e31dc38f3b ]
When the fcsfail filter is enabled the hardware passes frames with a bad FCS up to the driver, but mt76x02_mac_process_rx() never checks MT_RXINFO_CRCERR and hands them to mac80211 without RX_FLAG_FAILED_FCS_CRC. In monitor mode the radiotap flags byte then never gets IEEE80211_RADIOTAP_F_BADFCS set and corrupted frames cannot be told apart from clean ones.
Set RX_FLAG_FAILED_FCS_CRC from the descriptor CRC error bit, matching mt7603, mt7615, mt7915, mt7921, mt7925 and mt7996.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1 — Subject**
- Record: [wifi: mt76: mt76x02] [report] [report rx FCS errors to mac80211]
- Subsystem is MediaTek mt76, mt76x02 family (mt76x0 / mt76x2 PCI and USB). “Report” here is a correctness fix: the driver already receives CRC-failed frames and must mark them.
**Step 1.2 — Tags**
- Record:
- Reported-by: 0072a70 <[email protected]> — real user hit
- Closes: https://github.com/morrownr/mt76/issues/38
- Tested-by: same reporter, on real hardware
- Signed-off-by: Devin Wittmayer (author)
- `Link: https://patch.msgid.link/20260613002544.27750-3-
[email protected]`
- Signed-off-by: Felix Fietkau (mt76 maintainer)
- No Fixes: tag (expected for this review)
- No Cc: stable (expected; not a negative)
- Ignore any pipeline Signed-off-by: Sasha Levin / `[Upstream commit
...]`
**Step 1.3 — Body**
- Record:
- **Bug:** With the fcsfail filter enabled, hardware delivers frames with MT_RXINFO_CRCERR set. mt76x02_mac_process_rx() never reads that bit, so mac80211 never gets RX_FLAG_FAILED_FCS_CRC.
- **Symptom:** In monitor mode, radiotap never sets IEEE80211_RADIOTAP_F_BADFCS; corrupted frames look identical to clean ones.
- **Root cause:** Missing descriptor-bit → rx_status translation. Other mt76 chips already do this.
- **Version info in the message:** none. Reporter used kernel 7.0.x; the code path is much older (see Phase 3).
**Step 1.4 — Hidden bug fix?**
- Record: Not disguised. It is an explicit missing-flag fix that implements the documented mac80211 contract for FIF_FCSFAIL.
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
- Record: one file, drivers/net/wireless/mediatek/mt76/mt76x02_mac.c. Three lines added, none removed. Function: mt76x02_mac_process_rx(). Surgical single-file change.
**Step 2.2 — Flow**
- Record: After the existing MT_RXINFO_L2PAD check, if rxinfo & MT_RXINFO_CRCERR, set status->flag |= RX_FLAG_FAILED_FCS_CRC. Normal RX is unchanged for clean frames. Error/monitor path for CRC- failed frames is now marked.
**Step 2.3 — Bug mechanism**
- Record: **Logic / correctness** (driver contract). Hardware already passes CRC-failed frames when FIF_FCSFAIL is on (MT76_FILTER(FCSFAIL, MT_RX_FILTR_CFG_CRC_ERR) in mt76x02_configure_filter()). The driver failed to set the flag mac80211 requires (include/net/mac80211.h: *“pass frames with failed FCS (but you need to set RX_FLAG_FAILED_FCS_CRC for them)”*).
Verified mac80211 consequences in this tree:
- ieee80211_add_rx_radiotap_header() sets IEEE80211_RADIOTAP_F_BADFCS only if that flag is present (net/mac80211/rx.c).
- should_drop_frame() treats RX_FLAG_FAILED_FCS_CRC as drop-from- cooked-path. Without it, ieee80211_rx_monitor() copies the frame to monitor and **returns the original skb** to __ieee80211_rx_handle_packet(). FCS-failed frames can therefore enter the cooked RX path whenever fcsfail is enabled (including concurrent monitor + STA/AP).
**Step 2.4 — Fix quality**
- Record: Obviously correct; same pattern as mt7603/mt7615/mt7915/mt7921/mt7996 in this tree. Minimal. Regression risk is low: only CRCERR frames get a flag they should already have. Clean frames are untouched. Does not add APIs or change locking.
## Phase 3: Git history
**Step 3.1 — Blame**
- Record: Insertion point is the 2018 mt76x02_mac_process_rx() body from d9f8934ed147b3 (“mt76: move mt76x02_mac_process_rx in mt76x02-lib module”), 2018-10-04, first contained in **v4.20-rc1**. MT_RXINFO_CRCERR is defined in mt76x02_mac.h:54 since 5327b5ea13910d (2018-09-04). The bit has been defined for years and never consumed in RX processing.
**Step 3.2 — Fixes: tag**
- Record: None. The omission dates to the original mt76x02 RX path, not a later regression.
**Step 3.3 — File history**
- Record: Same-function sibling from the same series is already in this
tree: b6e7958602bd1 (“do not WARN on invalid rx descriptor length”). That is patch 1/2 of [PATCH 0/2] wifi: mt76: mt76x02: rx fixes for fcsfail monitor mode. This candidate is patch 2/2. They touch different lines; this one does not depend on patch 1. git apply --check of this hunk on HEAD is **clean**. No other FCS reporting commit exists on this file.
**Step 3.4 — Author**
- Record: Devin Wittmayer; not the subsystem maintainer. Maintainer Felix Fietkau signed off. Author also submitted the sibling WARN fix. Related author commits in this tree: b6e7958602bd1, plus unrelated mt7615/mt7921 TXRX_NOTIFY drops.
**Step 3.5 — Prerequisites**
- Record: None beyond symbols already in 6.6: MT_RXINFO_CRCERR, RX_FLAG_FAILED_FCS_CRC, status->flag. Commit text mentions mt7925; that chip need not exist here — it is comparison only. Standalone
apply: yes.
## Phase 4: Mailing list / external research
**Step 4.1 — Original discussion**
- Record: b4 dig -c <sha> cannot match because this commit is not in the local history. Fallback: b4 mbox [email protected].
- Cover: https://patch.msgid.link/20260613002544.27750-1-
[email protected]
- Series: v1 only (b4 am --check-newer-revisions: no later revision).
- Two patches; this is 2/2.
- Cover: tested on MT7612U and MT7610U; fcsfail monitor captures get BADFCS on corrupted frames, clean frames unchanged.
- No NAKs in the retrieved thread (cover + 2 patches, no review replies). Applied by Felix Fietkau.
- Lore HTTP fetch returned 403; b4 was used instead.
**Step 4.2 — Recipients**
- Record: To Felix Fietkau, Lorenzo Bianconi; Cc Ryder Lee, Shayne Chen, Sean Wang, linux-wireless, linux-kernel. Right maintainers/lists.
**Step 4.3 — Bug report**
- Record: GitHub issue #38 (closed). Hardware: Alfa AWUS036ACM, mt7612u, driver mt76x2u. With iw set monitor fcsfail, radiotap flags were always 0x00; radiotap.flags.badfcs == 1 matched 0 of 2978 frames. After this exact three-line change: 956/7353 frames had BADFCS 0x40, clean frames stayed 0x00. Confirmed on-list/issue by the reporter (Tested-by).
**Step 4.4 — Series context**
- Record: Patch 1 (WARN on bogus MPDU length under fcsfail) is already in this 6.6 tree. Patch 2 is the functional reporting fix. Independent; both target the same user-visible fcsfail path.
**Step 4.5 — stable@ discussion**
- Record: lore.kernel.org/stable HTTP 403. No separate stable-thread evidence retrieved. Absence is not a negative for this review.
## Phase 5: Semantic / call-chain analysis
**Step 5.1 — Functions**
- Record: mt76x02_mac_process_rx().
**Step 5.2 — Callers**
- Record: Only mt76x02_queue_rx_skb() in mt76x02_txrx.c (data RX, not MCU queue). That is the USB/PCI RX completion path for mt76x0 and mt76x2.
**Step 5.3 — Callees (relevant)**
- Record: Sets struct mt76_rx_status in skb->cb, then mt76_rx() → mac80211. mt76_rx() already counts RX_FLAG_FAILED_FCS_CRC for testmode FCS stats (mac80211.c).
**Step 5.4 — Reachability**
- Record: Userspace-reachable: iw set type monitor + iw set monitor fcsfail (nl80211 NL80211_MNTR_FLAG_FCSFAIL → ieee80211_adjust_monitor_flags() → fif_fcsfail → FIF_FCSFAIL → hardware CRC filter cleared). Common on USB adapters used for capture (Alfa AWUS036ACM and similar).
**Step 5.5 — Similar patterns**
- Record: Same status->flag |= RX_FLAG_FAILED_FCS_CRC already present in this tree for mt7603, mt7615, mt7915, mt7921, mt7996. mt76x02 is the gap. MT_RXINFO_ICVERR / MT_RXINFO_MICERR are also unused here; out of scope for this patch.
## Phase 6: This tree (6.6.157 / pending-6.6)
**Step 6.1 — Does the buggy code exist?**
- Record: Yes. mt76x02_mac_process_rx() at mt76x02_mac.c:794–797 has L2PAD then DECRYPT; no CRCERR check. MT_RXINFO_CRCERR is defined. git merge-base --is-ancestor d9f8934ed147b3 HEAD succeeded. Bug present since ~v4.20, so it is in 6.6.y.
Local tree identity:
- git describe HEAD → p-6.6-3-g04810563abb71
- make kernelversion → **6.6.157**
- Branch: pending-6.6
**Step 6.2 — Backport difficulty**
- Record: **Clean apply.** Context matches; git apply --check succeeded. Surrounding code is the same as the patch’s index.
**Step 6.3 — Related fixes already here**
- Record: No existing CRCERR → RX_FLAG_FAILED_FCS_CRC translation. Sibling WARN fix b6e7958602bd1 is present (different hunk). 63fe66f102837 (mt7996 FCS bit in wrong RXD word) is a different chip.
## Phase 7: Subsystem context
**Step 7.1**
- Record: drivers/net/wireless/mediatek/mt76 — **IMPORTANT** (widely used WiFi, not core mm/vfs). Covers MT76x0U/E and MT76x2U/E (Kconfig MT7610/MT7612 USB and PCIe). Peripheral relative to core kernel, but these USB NICs are common in the field.
**Step 7.2**
- Record: mt76 is active; mt76x02 RX processing itself has been stable for years. This is a long-standing omission, not churn from a new subsystem.
## Phase 8: Impact and risk
**Step 8.1 — Who is affected**
- Record: Users of mt76x0/mt76x2 (USB and PCIe) who enable monitor fcsfail. Normal STA/AP-only operation keeps the hardware CRC filter on, so those users are not on this path. Mixed monitor+managed on the same phy is affected for cooked RX.
**Step 8.2 — Trigger**
- Record: Explicit monitor fcsfail (and typically a busy channel). Not every boot. Unprivileged users cannot enable monitor without privileges, so this is not a generic local-priv-esc path; it is a privileged capture/correctness bug.
**Step 8.3 — Failure mode**
- Record:
- Monitor: corrupted frames indistinguishable from good ones (broken advertised filter). **MEDIUM** for dedicated capture.
- Cooked path: FCS-failed frames can be processed as valid 802.11 when fcsfail is on. That is frame-integrity / stack-correctness, not a panic. **MEDIUM–HIGH** in mixed-iface setups; not a guaranteed oops.
- Overall severity: **MEDIUM**, with a real user-visible functional break and a documented driver-API violation.
**Step 8.4 — Risk vs benefit**
- Record: **Benefit: medium** (correct FCS reporting; stop garbage frames leaking into cooked RX). **Risk: very low** (3 lines, same pattern as sibling chips, no lock/API change). Ratio favors backport.
## Phase 9: Synthesis
**Step 9.1 — Evidence**
For:
- Real, reproduced bug (GitHub #38; Tested-by on MT7612U; author also tested MT7610U).
- Violates mac80211 FIF_FCSFAIL contract; radiotap BADFCS never set.
- FCS-failed frames can continue into __ieee80211_rx_handle_packet() without the flag.
- Three-line, obviously correct, matches every other mt76 MAC in this tree.
- Applies cleanly to 6.6.157; symbols and call path exist.
- Maintainer SOB (Felix Fietkau).
- Popular USB hardware (e.g. Alfa AWUS036ACM).
Against:
- Not a crash/UAF/deadlock; mainly monitor-mode correctness plus cooked- path leakage only when fcsfail is enabled.
- No Fixes: (omission from original driver, not a later regression).
- Affects a subset of mt76x02 users, not all machines.
Unresolved:
- Direct lore.kernel.org HTTP was 403; discussion recovered via b4.
- No independent stable@ thread found.
**Step 9.2 — Stable rules**
1. Obviously correct and tested? **PASS** — 3 lines, hardware-tested, maintainer-acked.
2. Real bug affecting users? **PASS** — reporter could not tell bad-FCS frames apart; contract violation is in-tree.
3. Important issue? **PASS** (medium) — broken advertised monitor filter plus cooked-path delivery of CRC-failed frames. Not a panic, but it is a real correctness/integrity bug, not a feature.
4. Small and contained? **PASS** — +3 lines, one function.
5. No new features/APIs? **PASS** — sets an existing rx_status flag other mt76 chips already set.
6. Can apply to this tree? **PASS** — clean apply on 6.6.157.
**Step 9.3 — Exception category**
- Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary small driver correctness fix.
**Step 9.4 — Decision**
This tree is **6.6.157**. The buggy RX path, MT_RXINFO_CRCERR, and mac80211 flag handling are all present. The patch is a tiny, tested, maintainer-accepted fix for a user-visible bug on hardware this driver supports. Benefit clearly outweighs risk.
---
### What the commit solves for 6.6 users
mt76x02 already programs the hardware to deliver CRC-failed frames when monitor fcsfail is set, but never tells mac80211. Users of MT7610/MT7612 USB and PCIe adapters then see every frame as clean in radiotap, and those frames can also continue into the normal RX handlers. The fix sets RX_FLAG_FAILED_FCS_CRC from MT_RXINFO_CRCERR, which is what this tree already does for later mt76 chips.
### Stable-rule fit
Small, obviously correct, no new API, applies cleanly, real user-visible bug. Importance is monitor/FCS integrity rather than a panic; that is still within what stable takes for driver contract bugs of this size.
### Risk vs benefit
Very low risk (three lines, clean frames unchanged). Medium benefit for mt76x02 monitor users and mixed-iface setups.
### Concerns
No functional dependencies. Series mate (WARN drop) is already in this tree but is not required for this hunk. mt7925 in the commit message is comparison only.
---
Verification:
- [Phase 1] Parsed tags: Reported-by/Tested-by 0072a70, Closes github.com/morrownr/mt76/issues/38, Link msgid ...27750-3..., SOB Felix Fietkau; no Fixes/Cc:stable
- [Phase 2] Diff: +3 lines in mt76x02_mac_process_rx() after L2PAD; sets RX_FLAG_FAILED_FCS_CRC from MT_RXINFO_CRCERR
- [Phase 2] Confirmed mt76x02_configure_filter() maps FIF_FCSFAIL → clear MT_RX_FILTR_CFG_CRC_ERR
- [Phase 2] Confirmed mac80211 should_drop_frame() / radiotap BADFCS / ieee80211_rx_monitor() cooked-path return behavior in this tree
- [Phase 3] git blame: insertion region from d9f8934ed147b3 (2018); git merge-base --is-ancestor true; git describe --contains → v4.20-rc1
- [Phase 3] MT_RXINFO_CRCERR defined at mt76x02_mac.h:54; git grep shows it is unused in .c files in this tree
- [Phase 3] Sibling b6e7958602bd1 already in HEAD; this hunk independent; git apply --check CLEAN
- [Phase 4] b4 mbox saved 3-message series; cover tested MT7612U/MT7610U; b4 am --check-newer-revisions = v1 only, no NAKs
- [Phase 4] WebFetch of GitHub issue #38: reproduced 0 BADFCS; after patch 956/7353 frames flagged
- [Phase 4] lore.kernel.org WebFetch: 403 — UNVERIFIED via HTTP; recovered via b4
- [Phase 5] Only caller: mt76x02_queue_rx_skb(); chips: MT76x0U/E, MT76x2U/E
- [Phase 5] Same flag already set in mt7603/mt7615/mt7915/mt7921/mt7996 in this checkout
- [Phase 6] git describe HEAD p-6.6-3-g04810563abb71; make kernelversion 6.6.157; buggy code present; fix not applied
- [Phase 8] Failure mode: wrong radiotap + possible cooked-path delivery of CRC-failed frames; not a panic
- UNVERIFIED: stable@ mailing-list thread content (HTTP 403)
**YES**
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +3 -0
@@ -792,6 +792,9 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb,if (rxinfo &MT_RXINFO_L2PAD ) pad_len +=2 ; +if (rxinfo &MT_RXINFO_CRCERR ) + status->flag |=RX_FLAG_FAILED_FCS_CRC ; +if (rxinfo &MT_RXINFO_DECRYPT ) { status->flag |=RX_FLAG_DECRYPTED ; status->flag |=RX_FLAG_MMIC_STRIPPED ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/realtek: Add quirk for HP ENVY 13-aq1xxx
In reply to Sasha LevinFrom: Tarun Noonemunthala <[email protected]>
[ Upstream commit a01a223bd685be42e908d970de32eeb3646097f3 ]
The HP ENVY Laptop 13-aq1xxx (PCI SSID 103c:86ad) uses an ALC285 codec with two speaker pairs: front (pin 0x14) and bottom (pin 0x17).
The BIOS leaves pin 0x14 as [N/A] ("not connected"), so the generic parser never enables the front pair and only the bottom speakers are audible. The vendor driver (RTKVHD64.sys) programs that pin with the value 0x90170150 and runs the HP amplifier initialization, which is already implemented in the driver as ALC285_FIXUP_HP_GPIO_AMP_INIT.
Add a board fixup that applies the pin configuration for 0x14 and chains to the existing amplifier init fixup.
The pin value was recovered from the vendor driver's own configuration data. The patch and this changelog were prepared with an AI coding assistant (see the Assisted-by tag below); the change was reviewed and tested by the submitter on the affected machine.
Tested on an HP ENVY 13-aq1xxx by rebuilding snd-hda-codec-alc269 from the Fedora 7.1.10 source and loading it: the codec now reports "line_outs=2 (0x14/0x17)", pin 0x14 comes up as an output (Pin-ctls 0x40) with its amplifier unmuted, and both speaker pairs play.
---
LLM Generated explanations, may be completely bogus:
I have enough to decide: this is a scoped Realtek pin/amp quirk for one HP SSID, the 6.18.57 driver already has the helpers it needs, and the patch applies cleanly.
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ALSA/hda/realtek] [Add] [PCI SSID quirk so HP ENVY 13-aq1xxx front speakers are enabled]
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Assisted-by: OpenCode:deepseek-v4.1-flash checkpatch
- Signed-off-by: Tarun Noonemunthala <[email protected]> (author)
- `Link:
https://patch.msgid.link/[email protected]`
- Signed-off-by: Takashi Iwai <[email protected]> (ALSA maintainer)
- No Fixes: tag (expected; this is a BIOS/hardware workaround, not a regression from a prior kernel commit)
- No Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or `Cc:
[email protected]`
- Pipeline markers ([Upstream commit a01a223bd685be42e908d970de32eeb3646097f3], Signed-off-by: Sasha Levin) ignored per instructions
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** HP ENVY Laptop 13-aq1xxx, PCI SSID 103c:86ad, ALC285, two speaker pairs (front pin 0x14, bottom pin 0x17). BIOS marks pin 0x14 as [N/A] / not connected.
- **Symptom:** Generic parser never enables the front pair; only bottom speakers play.
- **Root cause:** Broken BIOS pin config. Vendor Windows driver (RTKVHD64.sys) programs pin 0x14 as 0x90170150 and runs HP amp init already present as ALC285_FIXUP_HP_GPIO_AMP_INIT.
- **Fix:** New board fixup applying that pin config and chaining to the existing amp-init fixup.
- **Version info:** Tested by rebuilding snd-hda-codec-alc269 from Fedora 7.1.10 source on the affected machine; codec then reports line_outs=2 (0x14/0x17), pin 0x14 output (Pin-ctls 0x40), amp unmuted, both pairs play.
- No stack traces (not a crash). No kernel-version range beyond “this laptop + this codec driver”.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is an explicit hardware quirk: pin override plus existing amp-init chain. That is the documented Realtek HDA workaround pattern.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: sound/hda/codecs/realtek/alc269.c (+11 lines, 0 removed)
- Functions/tables: enum { ... } (add ALC285_FIXUP_HP_ENVY_13AQ), alc269_fixups[], alc269_fixup_tbl[]
- Scope: single-file surgical hardware quirk
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
1. Enum: add ALC285_FIXUP_HP_ENVY_13AQ after ALC285_FIXUP_HP_ENVY_X360.
2. alc269_fixups[]: new HDA_FIXUP_PINS entry { 0x14, 0x90170150 }, chained to ALC285_FIXUP_HP_GPIO_AMP_INIT.
3. alc269_fixup_tbl[]: SND_PCI_QUIRK(0x103c, 0x86ad, "HP ENVY 13-aq1xxx", ALC285_FIXUP_HP_ENVY_13AQ) between 0x869d and 0x86c1.
Before: SSID 103c:86ad has no match; generic parser skips unused pin 0x14.
After: probe applies the speaker pin and the existing HP GPIO amp-init (and its existing LED chain).
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Hardware workaround (category h)** plus pin-config correctness. 0x90170150 decodes as fixed-function internal speaker (AC_JACK_PORT_FIXED + AC_JACK_SPEAKER + analog + AC_DEFCFG_MISC_NO_PRESENCE, assoc 5). Same speaker pincfg already used for HP Envy x360 pin 0x14 (B&O soundbar speakers) in alc285_fixup_hp_envy_x360().
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Minimal, table-driven, SSID-scoped. Uses existing HDA_FIXUP_PINS and ALC285_FIXUP_HP_GPIO_AMP_INIT. Regression risk is low and confined to PCI SSID 103c:86ad. Chain to ALC285_FIXUP_HP_GPIO_AMP_INIT also chains to ALC285_FIXUP_HP_GPIO_LED (alc_fixup_hp_gpio_led(..., 0x04, 0x01)); that is the established HP ALC285 amp-init pattern (same as Envy x360). Submitter tested both speaker pairs on the machine. No public API or data-structure change.
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record: Insertion points sit next to HP ALC285 fixups from aeeb85f26c3bb (“ALSA: hda: Split Realtek HD-audio codec driver”, Takashi Iwai, 2025-07-09). No prior 0x86ad entry; the “bug” is a missing quirk for BIOS-broken pin config, not a later regression. SSID 0x86ad is absent from v6.18.57.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable. This does not revert or patch a specific earlier commit.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: alc269.c regularly gets SSID quirks. Nearby HP entries already use ALC285_FIXUP_HP_GPIO_AMP_INIT (ZBook 17 G6 0x860c, ZBook 15 G6 0x860f, Elite Dragonfly G1 0x861f). Standalone, not patch X/Y.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Only this Realtek commit from Tarun Noonemunthala in this tree. Maintainer Takashi Iwai applied it (Signed-off-by + “Applied now. Thanks.”).
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Depends on ALC285_FIXUP_HP_GPIO_AMP_INIT / alc285_fixup_hp_gpio_amp_init(), alc269_fixups[], alc269_fixup_tbl[], and snd_hda_pick_fixup(). All present in v6.18.57. Applies standalone.
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c a01a223bd685be42e908d970de32eeb3646097f3 matched patch-id 273d83204a2340faba5eada8e1765ed331574a12
- Lore/msgid:
https://patch.msgid.link/[email protected]
- b4 dig -a: single **v1**, no later revisions
- Takashi Iwai, 2026-09-28: “Applied now. Thanks.” No NAK, no requested changes, no Cc: stable in the thread
- lore.kernel.org WebFetch returned 403; thread confirmed via b4 dig, openwall, and IU LKML mirrors
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To Takashi Iwai; Cc Jaroslav Kysela, linux- [email protected], [email protected]. Subsystem maintainer received and applied it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No bugzilla/syzbot link. Evidence is the submitter’s hardware test (codec dump + both speaker pairs). Web search did not find a separate public user-report thread beyond this patch.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone v1. Not part of a multi-patch series.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No stable-list discussion of this SSID/quirk found. Unverified whether anyone previously declined it; no evidence of a NAK.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: KEY FUNCTIONS**
Record: No new functions. Tables: alc269_fixups[], alc269_fixup_tbl[]. Runtime path uses snd_hda_pick_fixup(), __snd_hda_apply_fixup(), snd_hda_apply_pincfgs(), alc285_fixup_hp_gpio_amp_init(), alc285_fixup_hp_gpio_led().
**Step 5.2: TRACE CALLERS**
Record: Codec probe in alc269.c (~line 8557) calls snd_hda_pick_fixup(codec, alc269_fixup_models, alc269_fixup_tbl, alc269_fixups). Match is PCI subsystem ID via SND_PCI_QUIRK. HDA_FIXUP_PINS runs at HDA_FIXUP_ACT_PRE_PROBE (auto_parser.c). Amp init runs at HDA_FIXUP_ACT_INIT (msleep(100) then alc_write_coef_idx(codec, 0x65, 0x0)). Path is module/codec probe, not a hot syscall.
**Step 5.3: TRACE CALLEES**
Record: snd_hda_codec_set_pincfg() for pin 0x14; coef write 0x65; GPIO LED helper. No allocations, no new locks.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Boot / snd-hda-codec-realtek load → ALC269/ALC285 probe → SSID match 103c:86ad → pin override → generic parser sees a speaker at 0x14 → amp init. Reachable on that laptop without special userspace. Unprivileged users cannot trigger it on other machines (SSID match).
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same 0x90170150 speaker pincfg appears multiple times in alc269.c. Envy x360 uses it on pin 0x14 and also chains ALC285_FIXUP_HP_GPIO_AMP_INIT. This patch is the same class of fix, smaller (one pin, no extra coef/headset logic).
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- Tree: git describe HEAD = v6.18.57-155-gcdf239ca885b2; make kernelversion = 6.18.57
- sound/hda/codecs/realtek/alc269.c exists (split is in v6.18.57)
- v6.18.57 has no 0x86ad / ALC285_FIXUP_HP_ENVY_13AQ; BIOS-broken pin path is unquirked there
- Candidate overlay on current HEAD is ignored as selection evidence; the 6.18.57 baseline still needs the quirk
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: git apply --check of this diff onto the v6.18.57 copy of alc269.c succeeded (exit 0). Insertion context (enum after ALC285_FIXUP_HP_ENVY_X360, fixup after that entry, quirk between 0x869d and 0x86c1) matches. Expected backport difficulty: **clean apply**.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No other 0x86ad quirk. ALC285_FIXUP_HP_ENVY_X360 is a different SSID (0x85de) with extra pin/coef work. No alternate fix for 13-aq1xxx.
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: ALSA HD-audio Realtek codec (sound/hda/codecs/realtek/). **IMPORTANT** for laptop audio; **PERIPHERAL** in blast radius (one PCI SSID). Driver is common; this table entry is model-specific.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained; frequent Add quirk commits. Pattern is
mature: append enum + fixup + SND_PCI_QUIRK.
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: WHO IS AFFECTED**
Record: Driver-specific / platform-specific: HP ENVY 13-aq1xxx with HDA SSID 103c:86ad (vendor 0x103c = HP). No other 0x86ad uses in this tree.
**Step 8.2: TRIGGER CONDITIONS**
Record: Every codec probe on that laptop. Common for owners of that model; impossible for everyone else. Not a race. Not an unprivileged attack path.
**Step 8.3: FAILURE MODE SEVERITY**
Record: Front speakers stay silent; bottom pair still works. Not a panic/UAF. User-visible broken audio on shipping hardware. Severity **MEDIUM** as a crash, **HIGH** as a hardware-quirk enablement (laptop audio half-dead). Stable rules list “hardware quirk” as an accepted class.
**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit:** Restores front speakers on a real ALC285 HP laptop; tested on hardware; maintainer-applied.
- **Risk:** Very low — 11 lines, SSID-scoped, existing helpers only.
- **Ratio:** Strongly favors backport.
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: EVIDENCE**
For:
- Hardware quirk / pin override for existing Realtek HDA driver (stable- rules exception)
- Real user-visible bug: BIOS leaves pin 0x14 disconnected; front speakers silent
- Pin value taken from vendor driver; same 0x90170150 already used as HP internal speaker
- Chains to existing ALC285_FIXUP_HP_GPIO_AMP_INIT already in 6.18.57
- 11 lines, one file, SSID-scoped
- Tested on the affected machine (codec state + playback)
- Applied by Takashi Iwai after v1; no NAK
- Applies cleanly to this tree’s alc269.c
Against:
- Not a crash, UAF, or security fix
- Affects one laptop SSID
- Changelog mentions AI assistance (mitigated by maintainer apply + hardware test)
- No independent second reporter / bugzilla (unverified beyond submitter)
Unresolved:
- Direct lore.kernel.org fetch 403 (thread recovered via b4 and mirrors)
- No stable-list discussion found
- GPIO LED chain side-effect on this exact SKU not independently documented; same chain as other HP ALC285 amp-init boards, and the submitter tested playback
**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — standard pin table + existing chain; hardware-tested; maintainer applied
2. Fixes a real bug that affects users? **PASS** — silent front speakers on HP ENVY 13-aq1xxx
3. Important issue? **PASS** — hardware quirk (explicitly allowed); broken onboard speakers
4. Small and contained? **PASS** — +11 lines, one file
5. No new features or APIs? **PASS** — SSID quirk only; no new UAPI
6. Can apply to the local tree? **PASS** — file, enum, tables, and ALC285_FIXUP_HP_GPIO_AMP_INIT exist in 6.18.57; git apply --check clean
**Step 9.3: EXCEPTION CATEGORIES**
Record: **Hardware quirk / audio codec quirk** (and effectively a device-ID table addition to an existing driver). Automatic yes-class for stable.
**Step 9.4: DECISION**
This tree is 6.18.57. The Realtek ALC269/ALC285 quirk tables are present; SSID 103c:86ad is not. The patch is the usual HP pin+amp workaround, scoped to one subsystem ID, already used elsewhere in this driver. That is exactly the class of change stable is meant to take.
### What it solves for stable users
On HP ENVY 13-aq1xxx, BIOS marks the front-speaker pin unused, so Linux only drives the bottom pair. The quirk programs pin 0x14 as an internal speaker and runs the existing HP amp init so both pairs work. Without it, 6.18.y users of that laptop keep broken speaker output for the life of the LTS tree.
### Risk vs benefit
Benefit is real, hardware-tested audio on a shipping laptop. Risk is a 11-line SSID-local table addition with no locking, allocation, or API change.
### Concerns
None that block backport. GPIO LED chaining is inherited from ALC285_FIXUP_HP_GPIO_AMP_INIT and is the existing HP ALC285 pattern. No extra prerequisite commits are required.
Verification:
- [Phase 1] Parsed tags: author SOB, Takashi Iwai SOB, msgid Link; no Fixes/Reported-by/Cc: stable
- [Phase 1] Body: BIOS pin 0x14 N/A; vendor pincfg 0x90170150; tested line_outs=2 on HP ENVY 13-aq1xxx
- [Phase 2] Diff: +11 lines in alc269.c — enum, alc269_fixups[] pin table, SND_PCI_QUIRK(0x103c, 0x86ad, ...)
- [Phase 2] Pin 0x90170150 verified as fixed internal speaker via include/sound/hda_verbs.h; same value at Envy x360 pin 0x14
- [Phase 2] Chain target ALC285_FIXUP_HP_GPIO_AMP_INIT at lines 5704–5708; func alc285_fixup_hp_gpio_amp_init at 2827–2835
- [Phase 3] git describe HEAD = v6.18.57-155-gcdf239ca885b2; make kernelversion = 6.18.57
- [Phase 3] git merge-base --is-ancestor 2c9247c1739db v6.18.57 — not in v6.18.57 baseline
- [Phase 3] git grep 0x86ad v6.18.57 -- alc269.c — absent; ALC285_FIXUP_HP_GPIO_AMP_INIT present
- [Phase 3] Blame insertion neighbors: aeeb85f26c3bb (Realtek split), ancestor of v6.18.57
- [Phase 4] b4 dig -c a01a223bd685...: v1 only; maintainer To/Cc; Takashi “Applied now”
- [Phase 4] lore WebFetch 403; IU/openwall used instead
- [Phase 4] No stable-list hit for this model
- [Phase 5] Probe calls snd_hda_pick_fixup(..., alc269_fixup_tbl, alc269_fixups) ~line 8557; HDA_FIXUP_PINS in auto_parser.c:841-847
- [Phase 5] 0x86ad unique in tree
- [Phase 6] git apply --check of this diff onto v6.18.57 alc269.c:
exit 0
- [Phase 8] Failure mode: silent front speakers on one HP SSID, not a kernel oops
- UNVERIFIED: GPIO mute-LED wiring on this exact SKU (same inherited chain as other HP ALC285 amp-init boards; playback was tested)
This is a small, maintainer-applied hardware quirk that restores speakers on an existing Realtek codec in this 6.18.57 tree, with clean apply and SSID-local risk.
**YES**
sound/hda/codecs/realtek/alc269.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
sound/hda/codecs/realtek/alc269.c +11 -0
@@ -3774,6 +3774,7 @@ enum {ALC285_FIXUP_HP_SPECTRE_X360_EB1 ,ALC285_FIXUP_HP_SPECTRE_X360_DF1 ,ALC285_FIXUP_HP_ENVY_X360 , +ALC285_FIXUP_HP_ENVY_13AQ ,ALC288_FIXUP_DELL_HEADSET_MODE ,ALC288_FIXUP_DELL1_MIC_NO_PRESENCE , ALC288_FIXUP_DELL_XPS_13,
@@ -5981,6 +5982,15 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id = ALC285_FIXUP_HP_GPIO_AMP_INIT, }, + [ALC285_FIXUP_HP_ENVY_13AQ] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl []) { + {0x14 ,0x90170150 },/* front speakers */ + { } + }, + .chained = true, + .chain_id = ALC285_FIXUP_HP_GPIO_AMP_INIT, + }, [ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP] = { .type = HDA_FIXUP_FUNC, .v.func = alc285_fixup_ideapad_s740_coef,
@@ -6794,6 +6804,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x103c ,0x861f ,"HP Elite Dragonfly G1" ,ALC285_FIXUP_HP_GPIO_AMP_INIT ),SND_PCI_QUIRK (0x103c ,0x864f ,"HP Laptop 15-dy0xxx" ,ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 ),SND_PCI_QUIRK (0x103c ,0x869d ,"HP" ,ALC236_FIXUP_HP_MUTE_LED ), +SND_PCI_QUIRK (0x103c ,0x86ad ,"HP ENVY 13-aq1xxx" ,ALC285_FIXUP_HP_ENVY_13AQ ),SND_PCI_QUIRK (0x103c ,0x86c1 ,"HP Laptop 15-da3001TU" ,ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 ),SND_PCI_QUIRK (0x103c ,0x86c7 ,"HP Envy AiO 32" ,ALC274_FIXUP_HP_ENVY_GPIO ), SND_PCI_QUIRK(0x103c, 0x86c8, "HP Laptop 14s-dr1xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ASoC: tlv320aic26: remove keyclick sysfs file
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit ae375f8d063d71e598c0d7e14fc056154c84d7a7 ]
aic26_probe() creates the keyclick sysfs file on the component device. The file callback uses the ASoC component pointer stored in the driver private data.
There is no matching remove callback, so the sysfs file can remain after the component is removed while its backing component state is gone.
Add a component remove callback that removes the keyclick file.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.18.53**. The buggy device_create_file() path is present in v6.18.53; this 6-line remove-side cleanup is a real UAF/NULL-deref fix and applies cleanly here.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[ASoC / tlv320aic26] [remove] [tear down the keyclick sysfs attribute on component remove]**
The subject says “remove keyclick sysfs file”; the body is more precise:
the file is **not** deleted as a feature. A matching .remove callback is added so the existing debug attribute is unregistered when the component goes away.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Link:** https://patch.msgid.link/[email protected]
- **Signed-off-by:** Pengpeng Hou <[email protected]> (author)
- **Signed-off-by:** Mark Brown <[email protected]> (ASoC maintainer)
- **No Fixes:** tag (expected for this review)
- **No Cc: [email protected]** (expected)
- **No Reported-by / Tested-by / Reviewed-by / Acked-by / syzbot**
- Ignored pipeline tags ([Upstream commit …], Sasha Levin SOB) per instructions
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** aic26_probe() creates keyclick on component->dev. keyclick_show / keyclick_store use dev_get_drvdata() and then aic26->component. There is no matching remove.
- **Symptom:** After the ASoC component is removed, the sysfs file can still be there while the component / driver private state is gone.
- **Failure mode:** use of stale aic26 / aic26->component from sysfs (UAF or NULL deref).
- **Version info:** none in the message. The create-file path dates to the original 2008 driver.
- **Fix:** add aic26_remove() that calls device_remove_file() and wire it to snd_soc_component_driver.remove.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Yes — a real lifetime bug, not a feature deletion.** The subject is slightly misleading; this is the standard “create in probe, never remove” sysfs teardown hole.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** sound/soc/codecs/tlv320aic26.c (**+6 / −0**)
- **Functions:** new aic26_remove(); aic26_soc_component_dev gets .remove
- **Scope:** single-file surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** aic26_probe() (card bind) does device_create_file(component->dev, &dev_attr_keyclick) and returns 0 even if create fails. No .remove.
- **After:** card/component teardown calls aic26_remove() → device_remove_file().
- **Path:** component remove / card unbind / codec unregister — not the playback hot path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[UAF / NULL deref from leftover sysfs] [probe creates an unmanaged attribute; remove never tears it down]**
Verified mechanics in this tree:
1. component->dev is the SPI device (snd_soc_component_initialize() sets component->dev = dev; SPI probe passes &spi->dev).
2. keyclick_show / keyclick_store do dev_get_drvdata(dev) then snd_soc_component_read/update_bits(aic26->component, …).
3. aic26_probe() is only run from soc_probe_component() when a card binds.
4. soc_remove_component() calls snd_soc_component_remove() → driver->remove if set. Without this patch that is NULL, so the attribute stays on the still-live SPI device.
5. On SPI driver unbind, device_unbind_cleanup() runs devres_release_all() (frees aic26 via devm_kzalloc, unregisters the component) then dev_set_drvdata(dev, NULL). device_create_file() is **not** a managed resource, so keyclick remains.
6. Later sysfs access: NULL deref if drvdata is already NULL; UAF in the window while aic26 is freed and drvdata is not yet cleared; or concurrent show/store vs teardown because device_remove_file() is what waits out in-flight sysfs ops.
Sibling codecs already pair create/remove the same way (wm8962.c, cs42l52.c, cs42l56.c).
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Obviously correct:** matches the established ASoC pattern; device_remove_file() is the matching API.
- **Minimal:** 6 lines, no API/behavior change for working hardware.
- **Regression risk:** very low. If device_create_file() failed, device_remove_file() may emit a kernfs “failed to remove” warning; that is the same pattern as the sibling beep drivers and only on the already-failed create path. No new locking.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- **Introduced by:** d8e3bb7385da0 (“ALSA: ASoC: Add Texas Instruments TLV320AIC26 codec driver”, 2008-07-29)
- **Kernel version:** v2.6.27-era; present for the entire life of this 6.18 tree
- Sysfs create itself has been stable; later commits only reworked ASoC helpers (1514613a7a448 codec→component, 2eadc04d83f6c DEVICE_ATTR_RW, 1218d67d37615 sysfs_emit)
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Blame is sufficient: the hole is the original driver, not a recent regression.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES** Record:
- Recent on this file at v6.18.53: sysfs_emit, DAI naming, DEVICE_ATTR_RW — none add remove.
- Same author, same day: 02b2a3058912d / upstream ce3733792d38 “ASoC: sma1303: remove fault-check sysfs group on remove” — **parallel** fix in another codec, different msgid, not a prerequisite.
- **Standalone.**
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Pengpeng Hou is a regular ASoC codec contributor (error-path / lifetime fixes). Not the subsystem maintainer. Maintainer **Mark Brown** applied the patch.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **None.** .remove is already void (*remove)(struct snd_soc_component *) in include/sound/soc-component.h on this tree. No new helpers.
===============================================================
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)
- **Thread (mbox via b4 dig -m):** 2 messages — submission and Mark Brown’s apply to broonie/sound.git for-7.3
- **No NAK, no review comments, no Cc: stable in-thread**
- Direct lore HTTP fetch returned **403**; discussion was recovered from the mbox, not from the web UI
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc included Mark Brown, Liam Girdwood, Takashi Iwai, Jaroslav Kysela, TI codec contacts, linux-sound, linux-kernel. Applied by the ASoC maintainer. No extra Reviewed-by.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: **No user/syzbot/bugzilla report.** Code-analysis fix. No evidence of a field crash report.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Same-day sma1303 sysfs-remove patch is a sibling, not a dependency. This patch is [PATCH] (not n/N).
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** for lore.kernel.org/stable (HTTP 403). No in-tree discussion of a reason to skip this on 6.18.y.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: aic26_remove (new), aic26_soc_component_dev table; related
existing: aic26_probe, keyclick_show, keyclick_store, aic26_spi_probe
**Step 5.2: TRACE CALLERS**
Record:
- aic26_probe ← snd_soc_component_probe() ← soc_probe_component() (card bind)
- aic26_remove ← snd_soc_component_remove() ← soc_remove_component() ← soc_remove_link_components() / error unwind; also via card unbind when the component is unregistered (snd_soc_del_component_unlocked() → snd_soc_unbind_card())
- Sysfs callbacks: userspace read/write of keyclick (mode 0644 via DEVICE_ATTR_RW)
**Step 5.3: TRACE CALLEES**
Record: device_remove_file() only. Show/store use snd_soc_component_read / update_bits on aic26->component.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record:
- Bind: SPI probe → devm_snd_soc_register_component → later card bind → aic26_probe → sysfs create
- Unbind: card/component teardown should drop the file; SPI unbind then frees aic26 and clears drvdata
- **Reachable from userspace:** yes, via sysfs after bind. After broken unbind, any reader of that 0644 file can oops. Unprivileged read is possible; write is typically root. Trigger is teardown (rmmod / unbind / card removal), not every PCM period.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: In-tree ASoC codecs that create device sysfs files already remove them (wm8962, cs42l52, cs42l56). This driver was the outlier. sma1303 got the same class of fix the same day.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** git describe HEAD → v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion → **6.18.53**.
- git grep aic26_remove v6.18.53 -- sound/soc/codecs/tlv320aic26.c → **not present**
- v6.18.53:sound/soc/codecs/tlv320aic26.c still has create in aic26_probe() and no .remove
- Bug introduced in 2008; present for all of 6.18.y
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** to the v6.18.53 copy of the file (patch --dry-run return code 0). Surrounding probe/driver table matches the hunk. .remove is already void here.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No earlier tlv320aic26 sysfs-remove fix at v6.18.53. sysfs_emit conversion does not close the lifetime hole.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **ASoC codec driver (sound/soc/codecs/)** — **PERIPHERAL**
- CONFIG_SND_SOC_TLV320AIC26 is a **promptless** tristate, depends on SPI
- Only in-tree imply is SND_SOC_ALL_CODECS, which **depends on COMPILE_TEST**
- Grep of the whole tree: no machine driver, DTS, or defconfig selects this codec
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: ASoC is active; **this file is mature/quiet**. Last functional churn is ASoC API modernization, not new features. Long-lived bug.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / config-specific.** Production 6.18 configs will not enable this unless they set the hidden CONFIG_SND_SOC_TLV320AIC26 (out-of-tree board, explicit fragment). Compile-test “all codecs” builds can include it.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Requires the codec bound to a card (so probe created the file), then component/driver teardown, then sysfs access — or concurrent access during unbind
- Not every-boot; **module unload / card unbind**
- Unprivileged users can **read** the leftover 0644 file (DoS oops), not typically write
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **NULL deref / UAF → kernel oops** — **HIGH** (crash; theoretically memory-safety). Not silent corruption. No syzbot/CVE.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** medium-low population, high severity *if* the driver is used; prevents oops/UAF on teardown
- **Risk:** very low (6 lines, standard API, no locking/ABI)
- **Ratio:** favorable for stable — cheap crash fix
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real probe/remove mismatch: unmanaged sysfs vs component/driver lifetime
- Failure is oops/UAF, a class stable regularly takes
- 6 lines, obviously correct, same pattern as wm8962/cs42l52/cs42l56
- Bug present since 2008; code exists in this 6.18.53 tree; patch applies cleanly
- No prerequisites; void (*remove) already matches
- ASoC maintainer applied v1 with no objections
AGAINST:
- No field report / syzbot / Fixes / Cc: stable
- Obscure codec: no in-tree card, hidden Kconfig, only implied under COMPILE_TEST
- Debug sysfs, not the PCM path
- Tiny warning risk if create failed and remove still runs
UNRESOLVED:
- Stable-list discussion (lore HTTP 403)
- Whether any distro/out-of-tree 6.18 config actually sets CONFIG_SND_SOC_TLV320AIC26
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — standard device_remove_file pairing; maintainer applied; in-tree siblings already do this
2. Fixes a real bug that affects users? **PASS** — leftover sysfs after remove is a real lifetime bug (population is small, but the bug is real)
3. Important issue (crash, security, corruption, deadlock)? **PASS** — UAF/NULL deref oops on a world-readable sysfs file after unbind
4. Small and contained? **PASS** — +6 lines, one codec
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — applies to v6.18.53 tlv320aic26.c; .remove type matches
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Not** an ID/quirk/DT/build/doc exception. Ordinary small bugfix.
**Step 9.4: MAKE YOUR DECISION**
This is a small, correct teardown fix for a use-after-free / NULL deref. The driver is obscure, but the rules and the usual stable practice still take this class of probe/remove hole: crash on unbind, surgical change, no dependencies, clean apply to **this** 6.18.53 tree. Benefit is limited by who enables the codec; risk is negligible. That is a YES.
------------------------------------------------
What the commit solves for stable users
------------------------------------------------aic26_probe() publishes keyclick on the SPI device. Show/store use driver private data and aic26->component. Nothing ever calls device_remove_file(). After card/component teardown or rmmod, the attribute can remain while aic26 is freed and drvdata is cleared. A later read oopses. The patch adds the missing component .remove.
------------------------------------------------
Stable rules / risk vs benefit
------------------------------------------------
Meets the bar: obviously correct, real crash-class bug, tiny, no new API, applies here. User set is small (hidden Kconfig, no in-tree machine), but regression risk is near zero. No extra commits needed.
------------------------------------------------
Verification
------------------------------------------------
- **[Phase 1]** Tags: Link msgid, SOB Hou + Brown; no Fixes/Reported- by/syzbot/Cc:stable
- **[Phase 2]** Diff: +6 lines, aic26_remove + .remove = aic26_remove
- **[Phase 2]** keyclick_show/store use dev_get_drvdata then aic26->component (file read)
- **[Phase 2]** Siblings wm8962/cs42l52/cs42l56 already device_remove_file in remove
- **[Phase 3]** Blame: create-file from d8e3bb7385da0 (2008); no Fixes tag
- **[Phase 3]** Author also fixed sma1303 sysfs on remove the same day; independent
- **[Phase 4]** b4 dig -c ae375f8d063d…: lore msgid 20260615064549.34110-1; v1 only
- **[Phase 4]** b4 dig -w: Brown, Girdwood, Iwai, Kysela, linux-sound CC’d
- **[Phase 4]** b4 dig -m: 2-message thread; Brown applied to for-7.3; no NAK
- **[Phase 4]** lore.kernel.org / patch.msgid.link HTTP **403**; used mbox instead
- **[Phase 5]** probe via soc_probe_component; remove via soc_remove_component
- **[Phase 5]** device_unbind_cleanup (drivers/base/dd.c):
devres_release_all then dev_set_drvdata(NULL)
- **[Phase 5]** DEVICE_ATTR_RW → 0644 (include/linux/device.h)
- **[Phase 6]** git describe HEAD = v6.18.53-5049-g0f0bdc2b0dffb; kernelversion 6.18.53
- **[Phase 6]** aic26_remove **absent** from v6.18.53; patch dry-run against that file **succeeds**
- **[Phase 6]** git merge-base --is-ancestor ae375f8d063d HEAD → not ancestor (upstream 7.3 material)
- **[Phase 7]** CONFIG_SND_SOC_TLV320AIC26 promptless; only imply from SND_SOC_ALL_CODECS (depends on COMPILE_TEST); no DTS/board/defconfig
- **[Phase 8]** Failure mode: oops/UAF after unbind; severity HIGH; population small
- **UNVERIFIED:** stable@ lore discussion (HTTP 403); whether any 6.18 distro enables this hidden symbol
**YES**
sound/soc/codecs/tlv320aic26.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/soc/codecs/tlv320aic26.c +6 -0
@@ -320,8 +320,14 @@ static int aic26_probe(struct snd_soc_component *component)return 0 ; } +static void aic26_remove (struct snd_soc_component *component) +{ +device_remove_file (component->dev, &dev_attr_keyclick); +} +static const struct snd_soc_component_driver aic26_soc_component_dev = { .probe = aic26_probe, + .remove = aic26_remove, .controls = aic26_snd_controls, .num_controls =ARRAY_SIZE (aic26_snd_controls), .dapm_widgets = tlv320aic26_dapm_widgets,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 virtio_console: fix control queue race during restore
In reply to Sasha LevinFrom: Sungho Bae <[email protected]>
[ Upstream commit 952261953cf79820aa4350679882db0d4f71f493 ]
In virtcons_restore(), after virtio_device_ready() sets DRIVER_OK, the device becomes active. If the control receive queue (c_ivq) is populated immediately, the host can instantly deliver pending control messages (e.g., VIRTIO_CONSOLE_PORT_REMOVE).
This triggers the control_work_handler(), which can modify the portdev->ports list concurrently with the unprotected list_for_each_entry loop in virtcons_restore(), leading to list corruption or Use-After-Free.
Fix this by deferring the population of the control receive queue (fill_queue for c_ivq) until after the list iteration is complete. This ensures the host cannot inject control messages during the vulnerable window.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.6.157** (pending-6.6). The buggy restore path is present, the patch applies cleanly, and it is a self-contained UAF/list- corruption fix.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[virtio_console] [fix] [control queue race during restore]**
- Subsystem: virtio_console (guest virtio-serial/console driver)
- Action verb: **fix** — explicit bug fix
- Claimed intent: close a restore-time race between filling the control receive queue and iterating portdev->ports
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected for this review pipeline)
- **Reported-by:** none
- **Tested-by:** none on the commit itself; the v3 cover letter says it was runtime-tested on arm64 S4 with no_console_suspend
- **Reviewed-by / Acked-by:** none
- **Link:** https://patch.msgid.link/[email protected] (v3 3/4 of a 4-patch series)
- **Cc: stable:** none (expected; not a negative)
- **Signed-off-by:** Sungho Bae <[email protected]> (author); Greg Kroah-Hartman (char-misc maintainer). Ignore any Sasha Levin SOB from candidate prep.
- Mainline SHA (from fixes-next, not from candidate markers):
952261953cf79820aa4350679882db0d4f71f493
- AuthorDate: 2026-06-04; CommitDate: 2026-07-31
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** After virtio_device_ready() sets DRIVER_OK, immediately fill_queue(c_ivq) lets the host deliver control packets (e.g. VIRTIO_CONSOLE_PORT_REMOVE) while virtcons_restore() is still walking portdev->ports with unlocked list_for_each_entry.
- **Symptom / failure mode:** control_work_handler() → handle_control_message() → unplug_port() does list_del + kref_put concurrently with that walk → **list corruption or use- after-free**.
- **Version info:** none in the message. The restore path dates to 2011; virtio_device_ready() before queue use dates to 2014 (see Phase 3).
- **Root cause (author):** host can inject control messages as soon as c_ivq has buffers after DRIVER_OK.
- **Fix:** move fill_queue(portdev->c_ivq) until after the list walk.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Subject and body describe a UAF/list-corruption race. The extra comment is documentation of that race, not a cleanup disguised as a fix.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/char/virtio_console.c only
- Scope: **+12 / −3** (net +9, one function)
- Function: virtcons_restore()
- Classification: **single-file surgical fix**
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: **Before** (this tree, virtcons_restore at lines 2201–2235):
1. init_vqs(portdev)
2. virtio_device_ready() → DRIVER_OK, notifications enabled
3. fill_queue(c_ivq) if multiport → host can write control packets
4. Unlocked list_for_each_entry over portdev->ports: rebind vqs, fill_queue(in_vq), PORT_READY / PORT_OPEN
**After:** steps 3 and 4 swap. Control IN buffers are added only after the walk finishes.
Affected path: **PM restore** (CONFIG_PM_SLEEP), not probe. Probe already fills c_ivq before ports exist, so it does not have this walk.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Race / UAF / list corruption]**
Verified chain in this tree:
- control_intr() (drivers/char/virtio_console.c:1792) → schedule_work(&portdev->control_work)
- control_work_handler() (:1696) → handle_control_message()
- VIRTIO_CONSOLE_PORT_REMOVE (:1597) → unplug_port()
- unplug_port() (:1507) takes ports_lock, list_del(&port->list), later kref_put
- PORT_ADD (:1580) can add_port() → list_add_tail under ports_lock (:1445)
- virtcons_restore() walks the same list **without** ports_lock (:2218)
Other walkers (find_port_by_id, find_port_by_devt_in_portdev) do take ports_lock. Restore is the unprotected one.
Without c_ivq buffers, the host cannot complete used descriptors on the control IN queue, so control_intr cannot fire. Deferring fill_queue(c_ivq) closes the window. send_control_msg() uses c_ovq only (__send_control_msg at :541), so PORT_READY/OPEN still go out during the loop; host replies wait until IN buffers exist.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Obviously correct:** same two calls, safer order. Matches how virtio queues work (no IN buffers ⇒ no host-to-guest control).
- **Minimal:** no API, no new fields, no locking change.
- **Regression risk:** low. Host replies to PORT_READY are delayed until c_ivq is filled; that is normal virtio backpressure. Probe already sends DEVICE_READY only after fill_queue(c_ivq) (:2089–2118); restore now fills c_ivq after PORT_READY, which is slightly different timing but still valid.
- Residual: the restore walk still does not take ports_lock. After this patch the only concurrent list mutator on this path is host control, which cannot run until c_ivq is filled. Device remove is serialized with PM restore via the driver/device lock. That is enough for this bug.
- Patch 4 of the same series (pm_freezing) is a **different** freeze/TX race and is not required for this reorder.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Unlocked restore loop and fill_queue(c_ivq) before it:
**2b8f41d846990c** (Amit Shah, 2011-12-22) “Add freeze and restore handlers to support S4”. Present in this tree (git merge-base --is- ancestor succeeded).
- virtio_device_ready() immediately before fill_queue(c_ivq):
**401bbdc901b268** (Michael S. Tsirkin, 2014-10-15) “enable VQs early on restore”. Also an ancestor of HEAD. That is when the host can legally deliver as soon as buffers are posted.
- Race has existed in this form since ~2014; this is old code, not a recent-mainline-only bug.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The enabling commit is 401bbdc901b268, which is in this tree. No intermediate fix of this same race on drivers/char/virtio_console.c in this checkout (git log --grep="control queue race" empty on HEAD).
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent local history (git log --oneline -20 -- drivers/char/virtio_console.c) is unrelated (control-out free, endian/cols-rows, probe bugs). This commit is **not** in HEAD (git merge-base --is-ancestor 952261953cf79 HEAD failed).
On fixes-next the series is:
1. fc220d6be3c7e refactor __send_to_port() buffer ownership
2. a616ad344d9f7 hot-unplug races in TX paths
3. **952261953cf79 this commit**
4. b187532ac6dba hvc put_chars vs freeze teardown (pm_freezing)
Patches 1–2 do not touch virtcons_restore. Patch 4 adds pm_freezing clear after the moved fill_queue; it does not change this race fix. **Standalone.**
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Sungho Bae has no commits on this file in the 6.6 tree. On fixes-next he authored this 4-patch virtio_console PM/hot-unplug set. Maintainer of record is Amit Shah; the patch was To: [email protected], arnd, gregkh and applied by Greg.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Diff uses only virtio_device_ready, use_multiport, fill_queue, c_ivq / c_ivq_lock, all present. git show 952261953cf79 | git apply --check **applies cleanly**. No prerequisite.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 952261953cf79: match at
https://patch.msgid.link/[email protected]
- b4 dig -a: only **v3** of [PATCH v3 0/4] virtio_console: fix suspend/resume and hot-unplug races
- v3 change note: split a monolithic patch for grouping/bisectability
- v1
(https://patchew.org/linux/[email protected]/)
was only the freeze/pm_freezing fix; **this restore reorder is new in the split v3**
- Saved mbox: five messages (0/4–4/4), **no replies, no NAK, no Cc:
stable**
- Greg applied it 2026-07-31
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc Amit Shah, Arnd Bergmann, Greg Kroah- Hartman, [email protected], linux-kernel. Appropriate lists/maintainers. No public Reviewed-by; Greg’s SOB is the merge.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot, bugzilla, or user crash report. Cover letter: found while investigating the freeze/put_chars race; runtime-tested on arm64 S4 with no_console_suspend. Mechanism is verified in code (Phase 2/5), not only asserted.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Series of 4; this is 3/4 and is self-contained. Patch 4 is a separate freeze BUG_ON and does not need to ride along. Later fixes- next commits (allocate the port_buffer with the caller's gfp, do not free control-out buffers on remove) do not revert this reorder. virtcons_restore on fixes-next still has fill-c_ivq-after-loop.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable/ fetch returned 403. No stable-thread evidence in the v3 mbox. **UNVERIFIED** whether anyone already asked for or rejected this on stable@. Absence of that discussion is not a reason to skip a UAF fix that applies here.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: virtcons_restore() only. Related callees: fill_queue, use_multiport, send_control_msg, virtio_device_ready. Related concurrent path: control_work_handler / unplug_port / add_port.
**Step 5.2: TRACE CALLERS**
Record: virtcons_restore is .restore of struct virtio_driver virtio_console (:2247–2249), compiled under CONFIG_PM_SLEEP. Invoked from virtio PM restore (guest S3/S4 / hibernation restore of the virtio-console device). Not a syscall hot path; **reachable on any guest that suspends/hibernates with this driver**.
**Step 5.3: TRACE CALLEES**
Record:
- init_vqs registers control_intr for the control IN vq (:1876)
- virtio_device_ready sets VIRTIO_CONFIG_S_DRIVER_OK (include/linux/virtio_config.h:270–297)
- fill_queue allocates PAGE_SIZE IN buffers and add_inbuf under the given lock (:1323)
- send_control_msg → __send_control_msg kicks **c_ovq** only
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Guest suspend/resume or hibernation of a VM using multiport virtio-console/serial. Host can have pending PORT_REMOVE (port gone while guest was down) or reply to PORT_READY with PORT_ADD/REMOVE/NAME. Userspace in the guest does not need to issue a special syscall; PM restore plus host control is enough. Unprivileged guest users do not directly trigger it; the **hypervisor/host** does. Severity is still guest kernel UAF.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: virtcons_freeze() also walks portdev->ports unlocked (:2186), but first virtio_reset_device + virtqueue_disable_cb(c_ivq) + cancel_work_sync(&control_work) (:2173–2184), so control work cannot run. Probe fills c_ivq before any ports are on the list. Restore was the inconsistent path.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** drivers/char/virtio_console.c:2213–2234 still does virtio_device_ready → fill_queue(c_ivq) → unlocked list_for_each_entry. Tree: pending-6.6, make kernelversion **6.6.157**, git describe p-6.6-4-gaf85e5fc2f380. Bug introduced ~2014 (401bbdc901b268), long before 6.6.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** (git apply --check on 952261953cf79 succeeded). Surrounding virtcons_restore matches the pre-image. No refactor gap.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This SHA is not an ancestor of HEAD. No other “control queue race” commit on this file in this tree. Freeze-path callback disable is present and unrelated.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **virtio_console** (drivers/char/virtio_console.c, CONFIG_VIRTIO_CONSOLE). **IMPORTANT** for KVM/QEMU/cloud/embedded guests (virtio-serial, guest console). Not mm/core, but not staging/obscure. Maintainers: Amit Shah; virtio core: MST / Jason Wang.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature. Freeze/restore since 2011; little churn on this function in 6.6. Long-lived bug, not a new-subsystem mismatch.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific + config-specific:** CONFIG_VIRTIO_CONSOLE + CONFIG_PM_SLEEP + multiport (VIRTIO_CONSOLE_F_MULTIPORT, normal for virtio-serial). Guest suspend/hibernate/restore users.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Guest PM restore while host delivers control messages (pending PORT_REMOVE, or replies to PORT_READY). Window includes fill_queue(c_ivq) (many PAGE_SIZE allocations) plus the port loop. Not every boot; **realistic on S3/S4 of VMs with virtio-serial**. Guest userspace need not be malicious; the host is the other party (trusted in the virtio model, but still a crash in the guest).
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Use-after-free and list corruption** → oops/panic, possible memory corruption. **Severity: HIGH** (CRITICAL if the UAF is hit). Not a WARN-only issue.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** HIGH — prevents UAF/list corruption on a common VM driver during restore; code has been wrong for years in this tree.
- **Risk:** VERY LOW — 9-line reorder, same helpers, applies cleanly, no new API/locking.
- **Ratio:** strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real race: unlocked list walk vs unplug_port/add_port from control work
- Failure is UAF / list corruption (stable-class bug)
- Buggy code is in this 6.6 tree and has been since ~2014
- Fix is a 9-line reorder; git apply --check clean
- No dependency on series patches 1/2/4
- Applied by Greg to char-misc; later fixes-next still has this order
- Author tested related PM paths on arm64 S4
**AGAINST:**
- No Reported-by / syzbot; found during investigation
- Restore-only (S3/S4), not every boot
- No public review comments in the v3 mbox
- Part of a 4-patch series (but this hunk is independent)
**UNRESOLVED:**
- Stable@ discussion (lore/stable 403)
- No independent crash log attached to this specific UAF (mechanism still verified in tree)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — reorder is locally checkable; series was S4-tested; merged by Greg
2. Fixes a real bug that affects users? **PASS** — restore + multiport virtio-console is a real guest path
3. Important issue? **PASS** — UAF / list corruption, HIGH
4. Small and contained? **PASS** — one function, +12/−3
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — clean apply; all symbols exist
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. It qualifies as a normal **small race/UAF fix**.
**Step 9.4: MAKE YOUR DECISION**
This should be backported to **this** 6.6 tree. The bug exists here, the fix is surgical and independent of the rest of the series, and the downside is a mild delay of host control replies until after ports are rebound — which is the intended barrier.
------------------------------------------------
What it solves for stable users
------------------------------------------------
On guest suspend/resume or hibernation restore, virtcons_restore() currently posts control IN buffers while still walking portdev->ports without ports_lock. A host PORT_REMOVE/PORT_ADD can then free or insert list nodes under that walk. 6.6 guests using virtio-serial (the usual QEMU multiport setup) can oops or corrupt kernel memory. Moving fill_queue(c_ivq) after the loop removes that window without changing APIs.
Risk vs benefit: benefit is avoiding a restore-time UAF; risk is a small, obviously correct reorder that already applies.
------------------------------------------------
Verification
------------------------------------------------
- [Phase 1] Parsed subject/tags: fix, Link msgid 20260603183757.21587-4, SOB Sungho Bae + Greg; no Fixes/Reported- by/stable Cc
- [Phase 1] Mainline SHA from fixes-next:
952261953cf79820aa4350679882db0d4f71f493 (not treated as “already selected”)
- [Phase 2] Diff: only virtcons_restore(); move fill_queue(c_ivq) after unlocked list_for_each_entry
- [Phase 2] control_intr → control_work_handler → PORT_REMOVE → unplug_port list_del; restore walk has no ports_lock (lines 1507–1511, 1597–1598, 2218)
- [Phase 2] __send_control_msg uses c_ovq only (line 551)
- [Phase 3] Blame: loop/fill_queue from 2b8f41d846990c (2011); virtio_device_ready from 401bbdc901b268 (2014); both ancestors of HEAD
- [Phase 3] git merge-base --is-ancestor 952261953cf79 HEAD → NOT in this tree
- [Phase 3] Series 1–2 do not touch virtcons_restore; patch 4 is a separate pm_freezing freeze race
- [Phase 4] b4 dig -c 952261953cf79 → v3 3/4 lore URL; -a only v3; -w amit/arnd/gregkh/virtualization; mbox has no replies
- [Phase 4] v1 patchew: freeze-only; this reorder appeared in v3
- [Phase 4] UNVERIFIED: stable@ archives (HTTP 403)
- [Phase 5] virtio_device_ready sets DRIVER_OK (include/linux/virtio_config.h:297); init_vqs registers control_intr
- [Phase 6] git describe HEAD p-6.6-4-gaf85e5fc2f380; make kernelversion 6.6.157; buggy order at lines 2213–2234
- [Phase 6] git show 952261953cf79 | git apply --check → APPLIES CLEANLY
- [Phase 8] Failure mode: UAF/list corruption on PM restore; severity HIGH
- UNVERIFIED: no captured crash log for this exact UAF (code path still verified)
The patch is small, surgical, and meets the stable criteria for this tree.
**YES**
drivers/char/virtio_console.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/char/virtio_console.c +12 -3
@@ -2172,9 +2172,6 @@ static int virtcons_restore(struct virtio_device *vdev)virtio_device_ready (portdev->vdev); -if (use_multiport (portdev)) -fill_queue (portdev->c_ivq, &portdev->c_ivq_lock); -list_for_each_entry (port, &portdev->ports, list) { port->in_vq = portdev->in_vqs[port->id]; port->out_vq = portdev->out_vqs[port->id];
@@ -2191,6 +2188,18 @@ static int virtcons_restore(struct virtio_device *vdev)if (port->guest_connected) send_control_msg(port, VIRTIO_CONSOLE_PORT_OPEN, 1); } + +/* +* Populate the control receive queue only after the list iteration +* is complete. If we fill this queue before iterating, the host could +* immediately deliver a VIRTIO_CONSOLE_PORT_REMOVE message. +* This would trigger the control workqueue, which modifies the +* portdev->ports list concurrently with the unprotected loop above, +* leading to a Use-After-Free and list corruption. +*/ +if (use_multiport (portdev)) +fill_queue (portdev->c_ivq, &portdev->c_ivq_lock); +return 0 ; }#endif
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] virtio_console: fix control queue race during restore
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] virtio_console: dropped host control replies in virtcons_restore() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] virtio_console: dropped host control replies in virtcons_restore() --
commit 896c2558dbc3180e4d84cf033ee9bf699250ed69
Author: Sungho Bae <[email protected]>
virtio_console: fix control queue race during restore
This commit defers populating the control receive queue (portdev->c_ivq) in virtcons_restore() until after iterating over portdev->ports to prevent concurrent list modification from control_work_handler().
Quoted 23 lines
drivers/char/virtio_console.c +5
-3@@ -2136,9 +2136,6 @@ static int virtcons_restore(struct virtio_device *vdev)virtio_device_ready (portdev->vdev); -if (use_multiport (portdev)) -fill_queue (portdev->c_ivq, &portdev->c_ivq_lock); -list_for_each_entry (port, &portdev->ports, list) { port->in_vq = portdev->in_vqs[port->id]; port->out_vq = portdev->out_vqs[port->id];@@ -2155,6 +2152,18 @@ static int virtcons_restore(struct virtio_device *vdev)if (port->guest_connected)send_control_msg (port,VIRTIO_CONSOLE_PORT_OPEN ,1 ); } + +/* +* Populate the control receive queue only after the list iteration +* is complete. If we fill this queue before iterating, the host could +* immediately deliver a VIRTIO_CONSOLE_PORT_REMOVE message.
drivers/char/virtio_console.c static int virtcons_restore(struct virtio_device *vdev) · line 2169
Quoted 10 lines
drivers/char/virtio_console.c +7
-0+* This would trigger the control workqueue, which modifies the +* portdev->ports list concurrently with the unprotected loop above, +* leading to a Use-After-Free and list corruption. +*/ +if (use_multiport (portdev)) +fill_queue (portdev->c_ivq, &portdev->c_ivq_lock); + return 0; }#endif
[Severity: High]
Won't deferring fill_queue(portdev->c_ivq, &portdev->c_ivq_lock) until after the loop cause the host's control replies to be dropped during restore?
During freeze, virtcons_freeze() clears port->host_connected for every port and destroys all virtqueues:
drivers/char/virtio_console.c:virtcons_freeze() {
...
list_for_each_entry(port, &portdev->ports, list) {
virtqueue_disable_cb(port->in_vq);
virtqueue_disable_cb(port->out_vq);
/*
* We'll ask the host later if the new invocation has
* the port opened or closed.
*/
port->host_connected = false;
remove_port_data(port);
}
remove_vqs(portdev);
...
}In virtcons_restore(), the list_for_each_entry() loop queries the host for each port's open/close status via send_control_msg() -> __send_control_msg():
drivers/char/virtio_console.c:virtcons_restore() {
...
list_for_each_entry(port, &portdev->ports, list) {
...
/* Get port open/close status on the host */
send_control_msg(port, VIRTIO_CONSOLE_PORT_READY, 1);
...
}
}Because __send_control_msg() kicks portdev->c_ovq and busy-waits synchronously until the host consumes the VIRTIO_CONSOLE_PORT_READY request:
drivers/char/virtio_console.c:__send_control_msg() {
...
if (virtqueue_add_outbuf(vq, sg, 1, &portdev->cpkt, GFP_ATOMIC) == 0) {
virtqueue_kick(vq);\
while (!virtqueue_get_buf(vq, &len)
&& !virtqueue_is_broken(vq))
cpu_relax();
}
...
}the host processes VIRTIO_CONSOLE_PORT_READY and immediately attempts to send back VIRTIO_CONSOLE_PORT_OPEN (along with VIRTIO_CONSOLE_CONSOLE_PORT and VIRTIO_CONSOLE_PORT_NAME) on portdev->c_ivq before __send_control_msg() returns.
If fill_queue(portdev->c_ivq, &portdev->c_ivq_lock) has not been called yet, portdev->c_ivq has zero receive buffers when the host replies, causing those VIRTIO_CONSOLE_PORT_OPEN replies to be dropped and leaving port->host_connected permanently stuck at false after restore (which causes port_fops_write() to block or fail with -EAGAIN, port_fops_read() to return EOF, and port_fops_poll() to report EPOLLHUP).
Would it work to keep fill_queue(portdev->c_ivq, &portdev->c_ivq_lock) before the loop, but disable the c_ivq callback or defer scheduling control_work until the loop finishes so the host has receive buffers available while list traversal is still protected from concurrent control_work_handler() runs?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 ALSA: hda: Check snd_hda_power_pm construct error before executing verb
In reply to Sasha LevinFrom: Bob Song <[email protected]>
[ Upstream commit df27e4dc80c4a30ad206432cb848aab00de22ca7 ]
When userspace writes 1 to /sys/bus/pci/devices/XX/remove to remove HDA PCI device, the HDA hardware control path is shut down and devres unmaps the BAR virtual address bus->remap_addr automatically during driver removal.
If a delayed HDA verb command arrives after the MMIO region is unmapped, the driver will access invalid virtual addresses and trigger a page fault splat.
So add an error check right after constructing snd_hda_power_pm.
---
LLM Generated explanations, may be completely bogus:
Local tree is **7.3-rc4** (v7.3-rc4-27-gf0100363d8c37). The HDA CLASS(snd_hda_power_pm) path exists here, and this is a real page- fault on PCI unbind. Analysis below is for this checkout only.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[ALSA: hda:] [Check] [bail out of verb execution if snd_hda_power_pm construction failed and the controller is already stopped]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Bob Song <[email protected]> (author)
- `Link: https://patch.msgid.link/20260717024948.506335-1-
[email protected]` (v2 submission)
- Signed-off-by: Takashi Iwai <[email protected]> (ALSA/HDA maintainer)
- No Fixes:, no Reported-by:, no Tested-by:, no Cc: stable (absence expected)
- Pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] ignored
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** After echo 1 > /sys/bus/pci/devices/XX/remove, the HDA control path is torn down and devres unmaps bus->remap_addr.
- **Symptom:** A later HDA verb still runs, touches the unmapped BAR, **page fault / splat**.
- **Root cause (author):** CLASS(snd_hda_power_pm, pm)(codec) can fail; the old code ignored pm.err and still called snd_hdac_bus_exec_verb_unlocked().
- **Version info:** none in the message.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Explicit crash-avoidance check. The v1 lore text is even clearer: constructor fails, code still issues verbs, then MMIO after iounmap.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: sound/hda/common/codec.c — **+6 / -0**
- Function: call_exec_verb()
- Scope: **single-file surgical fix**
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** CLASS(snd_hda_power_pm, pm)(codec) then immediately guard(mutex) and snd_hdac_bus_exec_verb_unlocked() — pm.err unused.
- **After:** if pm.err < 0 && !bus->core.chip_init, warn and return pm.err; skip MMIO.
- Path: verb send after power-up, specifically when the controller is already stopped.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** memory-safety / invalid MMIO after teardown (page fault).
- **Mechanism:** snd_hdac_bus_send_cmd_corb() does snd_hdac_chip_readw(bus, CORBWP) via bus->remap_addr with **no chip_init guard**. azx_send_cmd() only checks chip->disabled. After snd_hdac_bus_stop_chip() sets chip_init = false, a delayed verb still MMIO’s the BAR. Power-up failure (pm_runtime_get_sync error while the device is going away) is the signal that hardware is no longer usable.
- **Note:** CLASS destructor still runs on the early return, so the get/put pair stays balanced (pm_runtime_get_sync still bumps the usage count on error).
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Quality:** Small, matches the header note (“If the error handling is needed, refer pm.err”). HDMI already checks pm.err (sound/hda/codecs/hdmi/hdmi.c).
- **Conservative:** both pm.err < 0 **and** !chip_init — v1’s pm_runtime_status_suspended() false-positive on platform devices without RPM was why v1 was dropped.
- **Residual hole:** if power-up fails but chip_init is still true, verbs still run; if chip_init is false but power-up succeeded, verbs still run. Incomplete, not wrong.
- **Regression risk:** low for this v2 form. codec_warn on a teardown race is acceptable.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- CLASS(snd_hda_power_pm, pm)(codec) introduced in **8dad6b3dac279** (“ALSA: hda/common: Use cleanup macros for PM controls”, 2025-08-29) — in this tree.
- Before that, codec_exec_verb() called snd_hda_power_up_pm() and **also ignored the return value** (664c715573c2c, 2015). Ignoring power-up failure is old; pm.err only became easy to check after CLASS.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Closest introducer of this exact shape is 8dad6b3dac279 (CLASS refactor, “no functional changes”). Present in this 7.3 tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES** Record:
- Immediate parents of call_exec_verb: 8dad6b3dac279 (extract + CLASS), 62dd3851d2450 (guard(mutex)).
- Follow-ups on this file after the fix (ba4239b6d8e1b, 7284788743121) are unrelated.
- Standalone 6-line patch, not patch X/Y.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Bob Song is a regular HDA contributor (quirks, NULL checks), not the maintainer. Maintainer is Takashi Iwai, who applied the patch.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Record:
- Needs CLASS(snd_hda_power_pm) / struct __hda_power_obj.err from **5d8c9c987fbdd** + **8dad6b3dac279**.
- Needs sound/hda/common/codec.c (moved in **05be28fe8521f**, 2025-07).
- **All of that is in this 7.3-rc4 tree.** Applies standalone here.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- Lore (via b4 dig): https://patch.msgid.link/20260717024948.506335-1-
[email protected]
- **v1** (2026-07-13): pm.err < 0 && pm_runtime_status_suspended(...). Takashi applied, then **author asked to drop it**: platforms without RPM keep runtime_status == suspended, so verbs would be blocked. Takashi dropped it.
- **v2** (2026-07-17): pm.err < 0 && !bus->core.chip_init. Takashi:
“Applied to for-next branch.” **This is the committed version.**
- **v3** (same day): only !bus->core.chip_init (no pm.err). **Not applied.**
- No NAKs on v2. No Cc: stable in review.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: To/Cc: Takashi Iwai, Jaroslav Kysela, linux-sound, linux-kernel. Subsystem maintainer applied v2 after the v1 false-positive.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No bugzilla/syzbot. Trigger described as sysfs PCI remove. No stack dump in the thread. **UNVERIFIED** how many users hit it beyond the author (Kylinos).
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone. HDMI already has similar pm.err checks; ca0132/realtek CLASS sites were not changed.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search returned a bot wall (403). **UNVERIFIED** whether stable@ already discussed this. No local git log --grep hits besides this commit.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: call_exec_verb(); helper for codec_exec_verb().
**Step 5.2: TRACE CALLERS**
Record:
- codec_exec_verb is codec->core.exec_verb (snd_hda_codec_device_new).
- snd_hdac_exec_verb() uses that; fallback is snd_hdac_bus_exec_verb().
- Reachable from mixer/jack/HDMI/proc/hwdep/regmap — **normal HDA I/O**, not an obscure helper.
**Step 5.3: TRACE CALLEES**
Record: snd_hda_power_up_pm → pm_runtime_get_sync; snd_hdac_bus_exec_verb_unlocked → bus->ops->command (azx_send_cmd → snd_hdac_bus_send_cmd_corb) which **MMIO’s remap_addr**.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record:
- Everyday verbs: yes, from ALSA ioctls (often unprivileged for the audio device).
- **The crash path** is teardown: PCI remove / snd_card_free / azx_free → azx_stop_chip() (chip_init = false) then pcim BAR unmap. Needs a verb still in flight (jack work, unsol work, a racing ctl).
- echo 1 > .../remove is admin; **VFIO GPU passthrough** also unbinds the HDA function. Userspace-reachable as a privileged/hotplug path, not a syzbot syscall smash.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: HDMI already checks pm.err. USB mixer code widely checks pm.err < 0 after CLASS. This call_exec_verb site was the hole for generic HDA verbs.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** sound/hda/common/codec.c call_exec_verb() uses CLASS; chip_init and pm.err exist. Parent of df27e4dc80c4a had no check. Bug is this tree’s HDA code (CLASS era, ~6.18+; this is 7.3).
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** on this tree: same function, same CLASS, same bus->core.chip_init.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No earlier alternate fix. HDMI’s pm.err checks do not cover call_exec_verb.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **ALSA HD-audio codec core** (sound/hda/common/). **IMPORTANT** — Intel/AMD/NVIDIA HDA is on most PCs, not core mm/sched.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Active (CLASS/guard cleanups, HDMI, Realtek). Maintainer-acked.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific** — HDA users who unbind/remove the PCI function (sysfs remove, VFIO, hotplug, driver rebind). Not all boots.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Timing-dependent: delayed verb vs. chip stop / BAR unmap. Privileged/hotplug, not a typical unprivileged mixer write while the device is live.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Page fault / oops** (author; lore v1 said “page fault BUG”). **Severity: HIGH** (oops on unbind; panic if panic_on_oops). Not filesystem corruption.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** HIGH for unbind/VFIO/hotplug — avoids oops.
- **Risk:** LOW — 6 lines, v1 regression already filtered, maintainer applied v2.
- **Ratio:** favorable.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real oops: MMIO after HDA BAR unmap / chip stop.
- snd_hdac_bus_send_cmd_corb() has no chip_init/remap_addr validity check — verified.
- 6-line, no new API, CLASS destructor still balances PM.
- Maintainer applied v2 after a real v1 false-positive on no-RPM platform devices.
- All prerequisites exist in **this** 7.3-rc4 tree.
- HDA + PCI unbind (including GPU audio / VFIO) is a real production path.
**AGAINST:**
- No stack trace, syzbot, or extra Reported-by.
- Trigger is teardown, not playback.
- Check is incomplete (pm.err XOR chip_init).
- v3 was not taken; v2 is what mainline has.
**UNRESOLVED:**
- Exact delayed-verb source (jack vs unsol vs racing ctl) not dumped.
- stable@ discussion unverified (lore blocked).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — v2 after v1 drop; maintainer applied.
2. Fixes a real bug that affects users? **PASS** — oops on PCI remove.
3. Important issue? **PASS** — kernel page fault / oops (HIGH, not idle WARN).
4. Small and contained? **PASS** — +6 lines, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — CLASS/pm.err/chip_init/call_exec_verb all present.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not a device ID/quirk/DT/build/doc). It is a normal crash fix.
**Step 9.4: MAKE YOUR DECISION**
For **this 7.3-rc4 tree**, the bug is present, the patch is self- contained, and it prevents a verified MMIO-after-teardown oops. It meets stable rules here.
**What it solves for this tree:** A delayed HDA verb after controller stop / BAR unmap used to ignore snd_hda_power_pm failure and hit unmapped MMIO. Skipping the verb when power-up failed **and** chip_init is false stops that oops without the v1 “platform device never left RPM_SUSPENDED” regression.
**Risk vs benefit:** Low risk, clear oops-avoidance benefit on unbind/hotplug.
---
Verification:
- [Phase 1] Tags: author Bob Song; Link to v2 msgid; SOB Takashi Iwai; no Fixes/Reported-by/Cc:stable
- [Phase 1] Body: PCI sysfs remove → BAR unmap → delayed verb → page fault
- [Phase 2] Diff: +6 in call_exec_verb(); pm.err < 0 && !bus->core.chip_init then return
- [Phase 2] snd_hdac_bus_send_cmd_corb() uses snd_hdac_chip_readw on remap_addr with no chip_init check (sound/hda/core/controller.c)
- [Phase 2] azx_send_cmd() only checks chip->disabled
- [Phase 2] Header documents pm.err (include/sound/hda_codec.h)
- [Phase 2] CLASS destructor still snd_hda_power_down_pm on early return (RAII)
- [Phase 3] Blame: CLASS in 8dad6b3dac279 (2025-08-29); this tree has it (git merge-base --is-ancestor 0)
- [Phase 3] Pre-CLASS codec_exec_verb also ignored snd_hda_power_up_pm() return (git show 8dad6b3dac279)
- [Phase 3] CLASS macros: 5d8c9c987fbdd; file move: 05be28fe8521f; both in this tree
- [Phase 3] No follow-up fix of this check after df27e4dc80c4a
- [Phase 4] b4 dig -c df27e4dc80c4a: v1/v2/v3; committed = v2
- [Phase 4] mbox: v1 applied then dropped (no-RPM platform false positive); v2 applied; v3 not applied
- [Phase 4] Recipients: tiwai, perex, linux-sound
- [Phase 4] lore WebFetch 403; stable@ search unverified (bot wall)
- [Phase 5] codec_exec_verb set as codec->core.exec_verb; used via snd_hdac_exec_verb
- [Phase 5] HDMI already checks pm.err (hdmi.c)
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- [Phase 6] Pre-image of call_exec_verb confirmed via git show df27e4dc80c4a^:sound/hda/common/codec.c
- [Phase 6] azx_free() stops chip when bus->chip_init (intel.c); azx_remove() → snd_card_free
- [Phase 8] Failure mode: page fault on unmapped BAR; trigger: PCI remove / unbind
- UNVERIFIED: exact delayed-verb producer; number of users; stable@ thread
The fix is small, matches this tree’s CLASS-based HDA code, and prevents a real oops on device teardown.
**YES**
sound/hda/common/codec.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/hda/common/codec.c +6 -0
@@ -39,6 +39,12 @@ static int call_exec_verb(struct hda_bus *bus, struct hda_codec *codec,int err;CLASS (snd_hda_power_pm, pm)(codec); +if (pm.err <0 && !bus->core.chip_init) { +codec_warn (codec, +"Failed to send cmd 0x%x ret=[%d], hda control stopped\n" , + cmd, pm.err); +return pm.err; + }guard (mutex)(&bus->core.cmd_mutex);if (flags &HDA_RW_NO_RESPONSE_FALLBACK ) bus->no_response_fallback =1 ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 firmware: imx: scu: manage mailbox channels and global handle
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit 55c748d596f841a18cf659ce0999f64029a5c88c ]
imx_scu_probe() requests mailbox channels with the non-managed mbox_request_channel_byname() helper and then publishes sc_ipc through the global imx_sc_ipc_handle. Later probe failures, including child population failure, can leave the channels and global handle live after the probe has failed.
Register devres actions to free each mailbox channel and clear the global handle. Also depopulate partially created child devices when devm_of_platform_populate() reports an error.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1:** Record: [firmware/imx SCU] [manage] Register managed cleanup for mailbox channels and the global IPC handle, and depopulate children if probe fails.
**Step 1.2:** Tags present:
- Signed-off-by: Pengpeng Hou <[email protected]> (author)
- Signed-off-by: Frank Li <[email protected]> (i.MX maintainer who applied it)
No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, Link:, or Cc: stable. Absence of those tags is expected for this review and is not treated as a negative signal.
**Step 1.3:** Record:
- **Bug:** imx_scu_probe() uses unmanaged mbox_request_channel_byname() and then publishes sc_ipc via the global imx_sc_ipc_handle. Later probe failures, including devm_of_platform_populate(), leave channels allocated and the global handle set.
- **Symptom:** Leaked mailbox channels after a failed probe; a live global handle to an object that devm_kzalloc then frees; partial child devices left behind.
- **Version info:** None in the message. Driver originated in v4.20 (edbee095fafb4).
- **Root cause:** Non-devm mailbox requests plus a global pointer with no rollback on the remaining error paths.
**Step 1.4:** Record: This is an explicit probe-error-path resource-leak / dangling-pointer fix, not a disguised cleanup. The wording matches the diff.
## Phase 2: Diff analysis
**Step 2.1:** Record:
- File: drivers/firmware/imx/imx-scu.c (+24 / −1)
- Functions added: imx_scu_free_mbox_chan(), imx_scu_clear_handle()
- Function modified: imx_scu_probe()
- Scope: single-file surgical fix
**Step 2.2:** Before → after:
1. After a successful mbox_request_channel_byname(), the channel was never registered with devres. Mid-loop failure (-EPROBE_DEFER, -ENOMEM from kasprintf, later channel failure) returned without mbox_free_channel(). After: each channel is wrapped in devm_add_action_or_reset(..., imx_scu_free_mbox_chan, ch).
2. imx_sc_ipc_handle = sc_ipc was published with no undo. After: a matching devm_add_action_or_reset(..., imx_scu_clear_handle, sc_ipc) NULLs it on unwind if it still points at this object.
3. return devm_of_platform_populate(dev) could fail after of_platform_populate() had already created some children (devm_of_platform_populate() does **not** depopulate on failure; it only devres_free()s the tracking pointer). After: explicit of_platform_depopulate(dev) on that error.
**Step 2.3:** Record: [error-path resource leak + dangling global pointer]
- Mailbox leak: unmanaged mbox_request_channel_byname() with no free on later probe failure.
- Retry hazard: __mbox_bind_client() returns -EBUSY if chan->cl is already set, so a later probe retry can stick forever.
- Handle leak / UAF: sc_ipc is devm_kzalloc’d; probe failure releases it while imx_sc_ipc_handle still points at it. Other i.MX drivers call imx_scu_get_handle().
- Child leak: failed of_platform_populate() still sets OF_POPULATED_BUS and can leave partial children.
**Step 2.4:** Record: The mailbox and handle devres actions are obviously correct (devm_add_action_or_reset runs the action immediately if registration fails). Calling of_platform_depopulate() only on populate failure is the right API:devm_of_platform_depopulate() would WARN because the managed resource was never added. Regression risk is low. Remaining related leaks (gip3, soc_device, secondary static handles) are pre-existing and not introduced here.
## Phase 3: Git history
**Step 3.1:** Record: Unmanaged mbox_request_channel_byname() and imx_sc_ipc_handle = sc_ipc come from edbee095fafb4 (“firmware: imx:
add SCU firmware driver support”, 2018-10-08), first contained in **v4.20-rc1**. The bug is long-standing.
**Step 3.2:** No Fixes: tag. Not applicable.
**Step 3.3:** Related commits on this file:
- 89f12d6509bff — kasprintf leak in the same probe loop (same class of bug)
- fbf10b86f6057 — OF node leak in probe
- 97a07dd2b559d — devm_mutex_init (adjacent context; not a functional prerequisite)
- ff79af939d847 — suppress_bind_attrs = true
This is a standalone v1 patch, not part of a series. No follow-ups to this file after 55c748d596f84.
**Step 3.4:** Pengpeng Hou has only this commit in drivers/firmware/imx/. Frank Li (NXP i.MX maintainer) applied it. Author is a contributor; the applying maintainer is the subsystem owner.
**Step 3.5:** No hard dependencies. devm_add_action_or_reset() is in include/linux/device/devres.h in this tree. Applies standalone.
## Phase 4: Mailing list and external research
**Step 4.1:** Record:
- Lore / msgid:
https://patch.msgid.link/[email protected]
- Series: v1 only (b4 dig -a)
- Maintainer apply: Frank Li, “Applied, thanks!” (24 Jul 2026), commit 55c748d596f84
- No NAK. No Cc: stable suggestion in the thread.
- Sashiko bot flagged **pre-existing** incomplete cleanup (gip3, soc_device, secondary handles, RPC timeout). Those are not regressions from this patch.
**Step 4.2:** Recipients (b4 dig -w): Frank Li, Sascha Hauer, Pengutronix, Fabio Estevam, [email protected], linux-arm-kernel, linux-kernel. Appropriate i.MX maintainers were on To/Cc.
**Step 4.3:** No bugzilla / syzbot / user Reported-by. Bug is from code inspection of the probe error path.
**Step 4.4:** Standalone 1/1 patch. No series dependencies.
**Step 4.5:** Record: UNVERIFIED for lore.kernel.org/stable (Anubis bot wall). Original imx thread has no stable discussion.
## Phase 5: Code semantic analysis
**Step 5.1:** Record: imx_scu_free_mbox_chan, imx_scu_clear_handle, imx_scu_probe.
**Step 5.2:** imx_scu_probe() is the platform probe for fsl,imx-scu. imx_scu_get_handle() is called from clk-scu, scu-pd, thermal, rtc, pinctrl, nvmem, GPIO, reset, FEC, FlexCAN, remoteproc, DRM, SOF, and others. Impact is every i.MX8QM/QXP SCU consumer.
**Step 5.3:** Probe allocates sc_ipc, requests MU mailbox channels, publishes the global handle, then populates child devices. Callees:mbox_request_channel_byname, mbox_free_channel, devm_of_platform_populate, of_platform_depopulate.
**Step 5.4:** Reachable at boot on SCU SoCs (subsys_initcall_sync). Not a syscall, but it is the firmware IPC path those boards need to bring up clocks, power domains, and peripherals. Unprivileged userspace cannot poke it directly.
**Step 5.5:** Same driver already had a kasprintf leak fix in this probe. imx_scu_enable_general_irq_channel() still requests unmanaged gip3 (pre-existing, not this patch).
## Phase 6: Local tree
**Step 6.1:** Local tree is **7.3.0-rc4** (git describe HEAD = v7.3-rc4-27-gf0100363d8c37). Buggy pattern was introduced in v4.20 and is in this lineage. git merge-base --is-ancestor 55c748d596f84 HEAD succeeds. Pre-fix probe is in 55c748d596f84^.
**Step 6.2:** Expected apply: clean on this tree (devm_mutex_init context matches).
**Step 6.3:** No alternate fix for mailbox/handle cleanup. Prior leak fixes (89f12d6509bff, fbf10b86f6057) do not cover this.
## Phase 7: Subsystem context
**Step 7.1:** Record: [drivers/firmware/imx] [IMPORTANT] — i.MX8QM/QXP System Controller IPC. Not core mm/net, but it is the firmware bus those SoCs use for clocks, PD, pinmux, thermal, RTC.
**Step 7.2:** Mature driver (2018), occasional probe-correctness fixes. Not a new subsystem.
## Phase 8: Impact and risk
**Step 8.1:** i.MX8QM/QXP (and similar SCU) users with CONFIG_IMX_SCU. Driver-specific / SoC-specific.
**Step 8.2:** Trigger is probe failure **after** some channels were
requested: mid-loop kasprintf -ENOMEM, a later mbox_request_channel_byname() failure, devm_mutex_init() failure, or devm_of_platform_populate() failure. First-channel -EPROBE_DEFER does **not** leak (nothing held yet). Not userspace-triggerable except via boot / driver bind.
**Step 8.3:** Failure mode:
- Leaked MU channels → retry gets -EBUSY → SCU never probes → clocks/PD/peripherals fail (**HIGH**, can make the board unusable)
- Dangling imx_sc_ipc_handle after devm frees sc_ipc (**HIGH** UAF if another driver then calls imx_scu_get_handle())
- Orphan child devices after failed populate (**MEDIUM**)
Happy-path probe is unchanged.
**Step 8.4:** Benefit: prevents stuck SCU probe and a global-handle UAF on real error paths. Risk: ~24 lines, probe error path only, standard devres pattern. Ratio: favorable.
## Phase 9: Synthesis
**Evidence FOR:**
- Real leak of exclusive mailbox channels; __mbox_bind_client() returning -EBUSY can permanently break SCU probe retry.
- Global handle left pointing at devm-freed sc_ipc after populate failure (UAF for every imx_scu_get_handle() caller).
- of_platform_depopulate() on failed devm_of_platform_populate() is correct (verified against drivers/of/platform.c).
- Small, single-file, no new API.
- Applied by the i.MX maintainer; v1 accepted as-is.
- Same probe function already needed leak fixes; this is the mailbox/handle analogue.
- Code and helpers exist in this 7.3-rc4 tree; no missing prerequisites.
**Evidence AGAINST:**
- No user/syzbot report; author-found error-path bug.
- Trigger is uncommon (not the first-channel -EPROBE_DEFER case).
- Incomplete: gip3, soc_device, and secondary IPC statics still leak (pre-existing).
- Affects SCU i.MX8 platforms only.
**Unresolved:** lore.kernel.org/stable search blocked (Anubis). Thread via b4 dig had no stable nomination.
**Stable rules:**
1. Obviously correct and tested? **PASS** — standard devres unwind; maintainer applied it; no NAK.
2. Real bug affecting users? **PASS** — leaked exclusive channels and a dangling global IPC handle on failed probe.
3. Important (crash/security/corruption/deadlock)? **PASS** — -EBUSY probe stall can prevent SCU bring-up; dangling handle is a UAF. Severity HIGH, not a happy-path panic.
4. Small and contained? **PASS** — 24 insertions, one file.
5. No new features/APIs? **PASS**
6. Can apply to this tree? **PASS** — context matches; helpers present.
**Exception category:** none; this is a normal error-path leak/UAF fix.
The local tree is 7.3-rc4. The SCU driver and the buggy unmanaged mailbox/handle pattern are in this lineage (since v4.20). The fix is a small, correct rollback of probe resources. Remaining gip3/soc_dev gaps are not a reason to keep the main channel/handle leak.
Verification:
- [Phase 1] Parsed tags: only author + Frank Li SOBs; no Fixes/Reported- by/Cc: stable
- [Phase 2] Diff: +24/−1 in imx_scu_probe(); devm_add_action_or_reset for mbox + handle; of_platform_depopulate on populate failure
- [Phase 2] devm_of_platform_populate() on failure does devres_free(ptr) without depopulate; of_platform_populate() still sets OF_POPULATED_BUS — explicit depopulate is required and not a double-free
- [Phase 2] __mbox_bind_client() returns -EBUSY if chan->cl is set — verified in drivers/mailbox/mailbox.c
- [Phase 3] Blame: bug from edbee095fafb4 (v4.20-rc1); git merge-base --is-ancestor 55c748d596f84 HEAD true
- [Phase 3] No Fixes: tag; no follow-up commits on this file
- [Phase 4] b4 dig -c 55c748d596f84:
https://patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1 only; b4 dig -w: Frank Li / Sascha Hauer / imx list CC’d
- [Phase 4] mbox: Frank Li “Applied, thanks!”; Sashiko noted pre- existing gaps, no NAK
- [Phase 4] lore.kernel.org/stable: UNVERIFIED (bot challenge)
- [Phase 5] Callers of imx_scu_get_handle() span clk, pd, net, thermal, rtc, drm, etc.
- [Phase 6] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion: 7.3.0-rc4; buggy probe exists in parent of this commit
- [Phase 8] Failure mode: mailbox leak → stuck probe / dangling handle UAF; severity HIGH
**YES**
drivers/firmware/imx/imx-scu.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
drivers/firmware/imx/imx-scu.c +24 -1
@@ -82,6 +82,17 @@ static int imx_sc_linux_errmap[IMX_SC_ERR_LAST] = {static struct imx_sc_ipc *imx_sc_ipc_handle; +static void imx_scu_free_mbox_chan (void *data) +{ +mbox_free_channel (data); +} + +static void imx_scu_clear_handle (void *data) +{ +if (imx_sc_ipc_handle == data) + imx_sc_ipc_handle =NULL ; +} +static inline int imx_sc_to_linux_errno (int errno) {if (errno >=IMX_SC_ERR_NONE && errno <IMX_SC_ERR_LAST )
@@ -321,6 +332,11 @@ static int imx_scu_probe(struct platform_device *pdev)dev_dbg (dev,"request mbox chan %s\n" , chan_name);/* chan_name is not used anymore by framework */ kfree (chan_name); + + ret =devm_add_action_or_reset (dev, imx_scu_free_mbox_chan, + sc_chan->ch); +if (ret) +return ret; } sc_ipc->dev = dev;
@@ -328,6 +344,9 @@ static int imx_scu_probe(struct platform_device *pdev)init_completion (&sc_ipc->done); imx_sc_ipc_handle = sc_ipc; + ret =devm_add_action_or_reset (dev, imx_scu_clear_handle, sc_ipc); +if (ret) +return ret; ret =imx_scu_soc_init (dev);if (ret)
@@ -340,7 +359,11 @@ static int imx_scu_probe(struct platform_device *pdev)dev_info (dev,"NXP i.MX SCU Initialized\n" ); -return devm_of_platform_populate (dev); + ret =devm_of_platform_populate (dev); +if (ret) +of_platform_depopulate (dev); + +return ret; }static const struct of_device_id imx_scu_match[] = {
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] firmware: imx: scu: manage mailbox channels and global handle
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] firmware: imx: scu: missing irq channel cleanup in imx_scu_probe() - [High] firmware: imx: scu…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] firmware: imx: scu: missing irq channel cleanup in imx_scu_probe()
- [High] firmware: imx: scu: unmanaged soc_device in imx_scu_soc_init()
--
commit b4c62f6aa45071e2c25e829dc030f6a6f0c1e4ec
Author: Pengpeng Hou <[email protected]>
firmware: imx: scu: manage mailbox channels and global handle
This commit registers devres actions in imx_scu_probe() to release requested mailbox channels and clear imx_sc_ipc_handle on probe failure, and depopulates child devices if devm_of_platform_populate() fails.
Quoted 4 lines
drivers/firmware/imx/imx-scu.c +0
-0
[ ... ]
drivers/firmware/imx/imx-scu.c static int imx_scu_probe(struct platform_device *pdev) · line 352
Quoted 10 lines
drivers/firmware/imx/imx-scu.c +3
-0@@ -328,6 +344,9 @@ static int imx_scu_probe(struct platform_device *pdev)init_completion (&sc_ipc->done); imx_sc_ipc_handle = sc_ipc; + ret =devm_add_action_or_reset (dev, imx_scu_clear_handle, sc_ipc); +if (ret) +return ret; ret =imx_scu_soc_init (dev);if (ret)
[Severity: High]
If devm_of_platform_populate(dev) fails later in imx_scu_probe(), does imx_scu_soc_init(dev) leave behind an unmanaged soc_device whose attributes point to freed devm memory?
In drivers/firmware/imx/imx-scu-soc.c, imx_scu_soc_init() caches sc_ipc in imx_sc_soc_ipc_handle, allocates soc_dev_attr, soc_dev_attr->revision, and soc_dev_attr->serial_number using devm on the SCU device, and registers the SoC device with the unmanaged soc_device_register():
drivers/firmware/imx/imx-scu-soc.c:imx_scu_soc_init() {
ret = imx_scu_get_handle(&imx_sc_soc_ipc_handle);
if (ret)
return ret;
soc_dev_attr = devm_kzalloc(dev, sizeof(*soc_dev_attr),
GFP_KERNEL);
...
soc_dev_attr->revision = devm_kasprintf(dev, GFP_KERNEL, "%d.%d",
(val >> 4) & 0xf, val & 0xf);
...
soc_dev_attr->serial_number = devm_kasprintf(dev, GFP_KERNEL,
"%016llX", uid);
...
soc_dev = soc_device_register(soc_dev_attr);
}In drivers/base/soc.c, soc_device_register() stores the soc_dev_attr pointer directly in soc_dev->attr.
When devm_of_platform_populate(dev) fails, devres_release_all(dev) frees soc_dev_attr, revision, serial_number, and sc_ipc while soc_dev remains registered on soc_bus_type and imx_sc_soc_ipc_handle stays set to the freed sc_ipc. Reading /sys/bus/soc/devices/socX/* via soc_info_show() or calling soc_device_match() will then dereference freed memory.
Should imx_scu_soc_init() also register devres cleanup to call soc_device_unregister(soc_dev) and clear imx_sc_soc_ipc_handle?
drivers/firmware/imx/imx-scu.c static int imx_scu_probe(struct platform_device *pdev) · line 367
Quoted 11 lines
drivers/firmware/imx/imx-scu.c +5
-1@@ -340,7 +359,11 @@ static int imx_scu_probe(struct platform_device *pdev)dev_info (dev,"NXP i.MX SCU Initialized\n" ); -return devm_of_platform_populate (dev); + ret =devm_of_platform_populate (dev); +if (ret) +of_platform_depopulate (dev); + +return ret; }
[Severity: High]
Similarly, when devm_of_platform_populate(dev) fails here after imx_scu_enable_general_irq_channel(dev) has succeeded, doesn't the unmanaged state in drivers/firmware/imx/imx-scu-irq.c remain active while its devm-allocated backing structures are freed?
Before devm_of_platform_populate(dev) is called, imx_scu_probe() invokes imx_scu_enable_general_irq_channel(dev):
drivers/firmware/imx/imx-scu-irq.c:imx_scu_enable_general_irq_channel() {
ret = imx_scu_get_handle(&imx_sc_irq_ipc_handle);
if (ret)
return ret;
cl = devm_kzalloc(dev, sizeof(*cl), GFP_KERNEL);
if (!cl)
return -ENOMEM;
cl->dev = dev;
cl->rx_callback = imx_scu_irq_callback;
/* SCU general IRQ uses general interrupt channel 3 */
ch = mbox_request_channel_byname(cl, "gip3");
...
INIT_WORK(&imx_sc_irq_work, imx_scu_irq_work_handler);
if (!of_parse_phandle_with_args(dev->of_node, "mboxes",
"#mbox-cells", 0, &spec))
i = of_alias_get_id(spec.np, "mu");
...
wakeup_obj = kobject_create_and_add("scu_wakeup_source", firmware_kobj);
...
ret = sysfs_create_file(wakeup_obj, &wakeup_source_attr.attr);
}If devm_of_platform_populate(dev) fails, devres frees cl and sc_ipc and clears imx_sc_ipc_handle, but nothing tears down the state created in imx_scu_enable_general_irq_channel():
1. The "gip3" mailbox channel ch is not freed with mbox_free_channel(ch), leaving chan->cl pointing to the freed mbox_client cl (which causes a use-after-free in imx_scu_irq_callback() on a gip3 interrupt and causes __mbox_bind_client() to return -EBUSY on any later probe retry), and imx_sc_irq_work is not cancelled.
2. imx_sc_irq_ipc_handle remains non-NULL and points to the freed sc_ipc, so callers such as imx_scu_irq_group_enable() pass the !imx_sc_irq_ipc_handle check and dereference freed memory in imx_scu_call_rpc().
3. wakeup_obj and wakeup_source_attr are leaked under /sys/firmware/scu_wakeup_source (in addition to spec.np from of_parse_phandle_with_args() never being released with of_node_put()).
Could imx_scu_enable_general_irq_channel() register devres actions to clean up the gip3 channel, imx_sc_irq_work, imx_sc_irq_ipc_handle, and wakeup_obj when probe fails?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 drm/amdkfd: use node XCC count for v9 CRIU control stack restore
In reply to Sasha LevinFrom: Yongqiang Sun <[email protected]>
[ Upstream commit 1a0aa3c4cb207fcbf7ebd2d9ed9f1cfb4560bd2c ]
set_queue_properties_from_criu() divided the checkpointed control stack size by NUM_XCC(adev->gfx.xcc_mask) (whole GPU), while the checkpoint size was recorded, the MQD buffer allocated, and the control stack restored using the per-node mask NUM_XCC(mm->dev->xcc_mask). On spatially partitioned GFX9.4.3 (CPX/QPX) these differ, so the per-XCC control stack size used for the restore memcpy could exceed the region sized for the MQD allocation, writing past the BO into adjacent kernel memory; it also broke legitimate restore on partitioned parts.
Divide by the per-node XCC count so allocation and copy agree, leaving kfd_queue_acquire_buffers() to bound the size against the node's advertised control stack size.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.18.53** (Makefile VERSION=6 PATCHLEVEL=18 SUBLEVEL=53, git describe v6.18.53-5049-g0f0bdc2b0dffb, branch autosel). The verdict is only for this 6.18.y checkout.
Upstream 1a0aa3c4cb20 is not an ancestor of v6.18.53. The buggy line is present at v6.18.53.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[drm/amdkfd] [use] [use node XCC count for v9 CRIU control stack restore]**
- Subsystem: drm/amdkfd (AMD KFD compute)
- Verb: “use” — here it is a correctness fix (wrong XCC divisor), not a feature
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- No Fixes: tag (expected)
- No Reported-by:, Tested-by:, Link:, Cc: stable
- Reviewed-by: David Francis <[email protected]>
- Signed-off-by: Yongqiang Sun <[email protected]> (author)
- Signed-off-by: Alex Deucher <[email protected]> (amdgpu maintainer)
- Pipeline Signed-off-by: Sasha Levin / [Upstream commit 1a0aa3c4cb20...] ignored per instructions
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** CRIU restore divides checkpointed control-stack size by whole-GPU NUM_XCC(adev->gfx.xcc_mask), while checkpoint, MQD allocation, and restore memcpy use per-node NUM_XCC(mm->dev->xcc_mask).
- **Symptom:** On spatially partitioned GFX9.4.3 (CPX/QPX) the two counts differ. Restore memcpy can write past the MQD BO into adjacent kernel memory; legitimate restore on a partition also fails.
- **Root cause:** Wrong XCC divisor in set_queue_properties_from_criu().
- **Fix:** Divide by per-node NUM_XCC(pdd->dev->xcc_mask); kfd_queue_acquire_buffers() still checks against the node’s advertised control-stack size.
- No version range in the message.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Explicit buffer-overrun + broken restore. Not cleanup/refactor.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c (1 insertion, 1 deletion)
- Function: kfd_criu_restore_queue()
- Scope: single-file, one-line surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** set_queue_properties_from_criu(&qp, q_data, NUM_XCC(pdd->dev->adev->gfx.xcc_mask)); → qp.ctl_stack_size = q_data->ctl_stack_size / whole_GPU_xcc
- **After:** NUM_XCC(pdd->dev->xcc_mask) → divide by this node’s XCC count
- Path: CRIU queue restore (AMDKFD_IOC_CRIU_OP), compute queues only (KFD_QUEUE_TYPE_COMPUTE in set_queue_properties_from_criu)
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Buffer overflow / OOB kernel write] + [logic/correctness]**
Verified chain:
1. Checkpoint (get_checkpoint_info in kfd_mqd_manager_v9.c):
*ctl_stack_size = m->cp_hqd_cntl_stack_size * NUM_XCC(mm->dev->xcc_mask) (node).
2. allocate_mqd() sizes the GTT BO from q->ctl_stack_size (the divided per-XCC value) × NUM_XCC(node->xcc_mask).
3. create_queue_nocpsch / create_queue_cpsch pass **qd->ctl_stack_size** (full user/checkpoint size) into restore_mqd().
4. restore_mqd_v9_4_3() copies ctl_stack_size / NUM_XCC(mm->dev->xcc_mask) bytes per XCC with unbounded memcpy in restore_mqd() to *mqd + PAGE_SIZE.
On CPX/QPX, GPU XCC count > node XCC count. A crafted q_data->ctl_stack_size = node_props.ctl_stack_size * GPU_xcc makes qp.ctl_stack_size pass kfd_queue_acquire_buffers()’s equality check, then restore copies GPU_xcc/NODE_xcc times too much → write past the BO.
A legitimate checkpoint (ctl_stack_size = per_xcc * NODE_xcc) yields a too-small qp.ctl_stack_size, so acquire_buffers returns -EINVAL and restore is broken.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct: same NUM_XCC(dev->xcc_mask) as checkpoint/allocate/restore. Minimal. No API/locking change. Regression risk very low (only partitioned restore, which is currently wrong). pdd->dev->xcc_mask exists on struct kfd_node in this tree.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record: At v6.18.53, line 1065 was introduced by **f6c0f3d24478a** (drm/amdkfd: Fix checkpoint-restore on multi-xcc, David Yat Sin, 2025-07-16). That commit added the num_xcc argument and used **adev->gfx.xcc_mask**. It is an ancestor of v6.18.53 and was itself Cc: [email protected] (cherry-pick of a578f2a58c3a).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The introducing commit is f6c0f3d24478a, present in this tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES** Record (file-limited git log):
- c6c290e408fe3 drm/amdkfd: Properly acquire queue buffers in CRIU restore — **in v6.18.53**; this patch depends on that bound
- fd1691ec62701 bounds on CRIU queue type/mqd size — already here
- f6c0f3d24478a multi-xcc CRIU — introduced the bug
- Later clamp/bound CRIU patches from the same author are **not** in this tree; they are extra hardening, not prerequisites
Standalone given acquire_buffers is already here.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Yongqiang Sun has other amdkfd CRIU/safety work. Not the subsystem maintainer. Review is from David Francis; merge SOB from Alex Deucher.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs set_queue_properties_from_criu(..., num_xcc) (f6c0f3d24478a) and kfd_queue_acquire_buffers() (c6c290e408fe3). Both are in v6.18.53. pdd->dev->xcc_mask exists. Applies standalone on this tree.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION** Record:
- b4 dig -c 1a0aa3c4cb20 failed: lore.kernel.org returned server errors (UNVERIFIED via b4)
- Thread found on amd-gfx: https://ratatoskr.run/amd-
gfx/2026/06/17177385 (2026-06-25)
- Single-patch submission, not v2/v3
- Same one-line diff as committed
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: David Francis: “Nice catch” + Reviewed-by. No NAK. Alex Deucher SOB on the commit. Recipients: amd-gfx; maintainers listed include Felix Kuehling, Alex Deucher.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla. Author-found mismatch. Same month as related CRIU bound/clamp patches.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Same author, June 2026 amd-gfx:
- clamp v9 CRIU control stack checkpoint copy to BO size
- bound v9 CRIU control stack restore to allocated MQD region
- this divisor fix
Complementary, not a numbered series. drm-next 7.3 pull listed this under CRIU fixes. This line does not need the clamp/bound patches to be correct.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search returned **403**. No stable-list discussion verified. No evidence it was rejected for stable.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: kfd_criu_restore_queue() (call site); set_queue_properties_from_criu() (consumer of num_xcc); downstream kfd_queue_acquire_buffers, pqm_create_queue → restore_mqd / restore_mqd_v9_4_3.
**Step 5.2: TRACE CALLERS**
Record:
- kfd_criu_restore_queue ← criu_restore_objects() ← kfd_ioctl_criu via AMDKFD_IOC_CRIU_OP
- Ioctl flag KFD_IOC_FLAG_CHECKPOINT_RESTORE: CAP_CHECKPOINT_RESTORE or CAP_SYS_ADMIN
- Userspace-reachable, privileged
**Step 5.3: TRACE CALLEES**
Record: set_queue_properties_from_criu → kfd_queue_acquire_buffers (must match node_props.ctl_stack_size) → pqm_create_queue → allocate_mqd + restore_mqd(..., qd->ctl_stack_size).
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Privileged CRIU restore ioctl → kernel memcpy into MQD GTT. Triggered by GPU container checkpoint/restore on partitioned GFX9.4.3 (MI300 family). Unprivileged users cannot call it.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Rest of KFD uses dev->xcc_mask / mm->dev->xcc_mask. This restore call was the odd adev->gfx.xcc_mask user in this path. kfd_device.c sets node->xcc_mask from XCP when partitioned, else from whole-GPU mask — they only differ with spatial partitions.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** v6.18.53:kfd_process_queue_manager.c:1065:set_queue_properties_from_criu(&qp, q_data, NUM_XCC(pdd->dev->adev->gfx.xcc_mask));
Introduced f6c0f3d24478a (2025-07-16), present in 6.18.y.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply. Surrounding function at 6.18.53 matches the hunk (kfd_queue_acquire_buffers already there). pdd->dev->xcc_mask is in kfd_priv.h:279 at 6.18.53.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: acquire_buffers bound is already in 6.18.53. Clamp/bound memcpy patches are not; they are extra, not a substitute. No other fix of this divisor mismatch.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **amdkfd (AMD GPU compute)** — **IMPORTANT** for ROCm/HPC, not core mm/VFS. CRIU restore is a real production path for GPU containers.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Active (many recent CRIU bound-check fixes). This is a follow-on to the multi-xcc CRIU work already in stable.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver/config-specific: CONFIG_HSA_AMD + KFD CRIU restore + GFX9.4.3 spatial partition (CPX/QPX). MI300-class HPC/AI systems.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Legitimate: CRIU restore of a compute queue on a partitioned node → restore fails (-EINVAL from acquire_buffers)
- Malicious/crafted checkpoint: size chosen so the wrong divisor equals node_props.ctl_stack_size → OOB memcpy
- Requires CAP_CHECKPOINT_RESTORE or CAP_SYS_ADMIN
- Unprivileged users cannot trigger it
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- OOB write past MQD BO into adjacent kernel (TTM/GTT) memory → **HIGH** (corruption/crash; privileged)
- Broken legitimate CRIU restore on partitioned parts → **HIGH** for those users (functional failure, not a panic on the happy path)
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** Fixes kernel OOB write and restores CRIU on partitioned GFX9.4.3; the buggy multi-xcc CRIU code is already in this stable tree
- **Risk:** Very low (one identifier change, same pattern as the rest of KFD)
- **Ratio:** Strongly favors backport
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real bug: wrong XCC divisor vs checkpoint/allocate/restore
- Kernel memory overwrite via unbounded memcpy in restore_mqd()
- Broken CRIU restore on CPX/QPX GFX9.4.3
- Introducing commit already in 6.18.y and was Cc: stable
- 1-line, obviously correct, reviewed by David Francis, SOB Alex Deucher
- Prerequisites (f6c0f3d24478a, kfd_queue_acquire_buffers) present
- Applies cleanly
AGAINST:
- Privileged ioctl only
- Only partitioned multi-XCC GFX9.4.3 + CRIU
- No syzbot / no Fixes: / no explicit stable Cc on this commit
- Complementary clamp/bound patches not in this tree (hardening, not required)
UNRESOLVED:
- b4 dig / lore.kernel.org stable search failed (server 403/error)
- No public reproducer beyond code inspection (commit describes the mechanism)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — 1-line mask fix; Reviewed-by
+ maintainer SOB
2. Fixes a real bug that affects users? **PASS** — partitioned CRIU restore wrong; OOB on crafted size
3. Important issue? **PASS** — kernel OOB write + failed restore (HIGH, privileged)
4. Small and contained? **PASS** — 1 line, one file
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — buggy line and dev->xcc_mask exist at 6.18.53
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not an ID/quirk/DT/build/docs exception. Ordinary important bugfix.
**Step 9.4: MAKE YOUR DECISION**
This belongs on 6.18.y. The bug is in this tree because multi-xcc CRIU was already backported with the wrong divisor. The fix is minimal and matches every other XCC user in the restore path.
---
### What the commit solves for stable users
On 6.18.53, KFD CRIU restore still divides by the whole-GPU XCC mask. Checkpoint, MQD BO size, and restore_mqd_v9_4_3() use the **node** mask. On GFX9.4.3 CPX/QPX those differ, so restore either fails or (with a crafted privileged checkpoint) memcpys past the MQD BO into kernel GTT. Switching to pdd->dev->xcc_mask makes allocation and copy agree; acquire_buffers already pins the per-XCC size to the node’s advertised control-stack size.
### Risk vs benefit
Benefit is high for MI300 CRIU/partition users and closes an OOB write. Risk is a one-token change with no locking/API impact.
### Concerns
Clamp/bound memcpy patches are not required for this to be correct. CRIU is privileged, which lowers exploitability but does not make the overflow or the broken restore acceptable on stable.
---
Verification:
- [Phase 1] Tags: Reviewed-by David Francis; SOB Yongqiang Sun, Alex Deucher; no Fixes/Reported-by/Cc:stable
- [Phase 1] Body: OOB write past MQD BO + broken partitioned restore; wrong GPU vs node XCC divisor
- [Phase 2] Diff: 1 line in kfd_criu_restore_queue():
adev->gfx.xcc_mask → dev->xcc_mask
- [Phase 2] allocate_mqd uses q->ctl_stack_size * NUM_XCC(node->xcc_mask); restore_mqd uses qd->ctl_stack_size; restore_mqd_v9_4_3 divides by mm->dev->xcc_mask; memcpy unbounded
- [Phase 2] kfd_queue_acquire_buffers requires ctl_stack_size == node_props.ctl_stack_size (present at 6.18.53)
- [Phase 3] Blame at v6.18.53: f6c0f3d24478a introduced NUM_XCC(pdd->dev->adev->gfx.xcc_mask); Cc: stable; ancestor of v6.18.53
- [Phase 3] git merge-base --is-ancestor 1a0aa3c4cb20 v6.18.53 → not present; buggy code is present
- [Phase 3] Prerequisites f6c0f3d24478a and c6c290e408fe3 are in v6.18.53
- [Phase 4] b4 dig: lore server error — UNVERIFIED via b4
- [Phase 4] amd-gfx thread 2026-06-25; David Francis “Nice catch” + Reviewed-by; no NAK
- [Phase 4] lore.kernel.org/stable: 403 — UNVERIFIED
- [Phase 5] Caller: AMDKFD_IOC_CRIU_OP with CAP_CHECKPOINT_RESTORE or CAP_SYS_ADMIN
- [Phase 5] kfd_device.c: node->xcc_mask from XCP vs adev->gfx.xcc_mask when unpartitioned
- [Phase 6] git describe HEAD / make kernelversion: 6.18.53; line 1065 at v6.18.53 is the buggy call; kfd_node.xcc_mask exists
- [Phase 6] Clean apply: surrounding code at v6.18.53 matches the hunk
- [Phase 8] Failure: kernel OOB write (HIGH) + CRIU restore failure on CPX/QPX; privileged trigger
- UNVERIFIED: b4/lore.kernel.org availability; no runtime reproducer executed
**YES**
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +1 -1
@@ -1062,7 +1062,7 @@ int kfd_criu_restore_queue(struct kfd_process *p, ctl_stack = mqd + q_data->mqd_size;memset (&qp,0 ,sizeof (qp)); -set_queue_properties_from_criu (&qp, q_data,NUM_XCC (pdd->dev->adev->gfx.xcc_mask)); +set_queue_properties_from_criu (&qp, q_data,NUM_XCC (pdd->dev->xcc_mask)); ret =kfd_queue_acquire_buffers (pdd, &qp);if (ret) {
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: ath11k: fix resource leak on error in ext IRQ setup
In reply to Sasha LevinFrom: ZhaoJinming <[email protected]>
[ Upstream commit 8ab38bbac02298e3fb03008ed4a0227485c0fd62 ]
In ath11k_ahb_config_irq(), when a CE request_irq() fails, the function returns the error immediately without freeing the CE IRQs that were successfully registered in previous loop iterations. The probe error path does not call ath11k_ahb_free_irq() either, so the previously registered CE IRQ handlers remain attached to the interrupt lines and are never released.
In ath11k_ahb_config_ext_irq(), when an external request_irq() fails, the error is only logged and the loop continues. The function then returns 0 indicating success, leaving the device in a partially configured state where some external IRQs are not registered. This causes enable_irq()/disable_irq()/free_irq() to be called on unregistered IRQs during runtime and remove/shutdown, triggering WARN_ON(!desc->action), and missing interrupt handlers lead to data loss.
Additionally, if alloc_netdev_dummy() fails for a later IRQ group, the function returns -ENOMEM without freeing the ext IRQs and napi_ndev that were successfully set up for earlier groups.
Fix all three issues: propagate the error up to the caller and unwind all successfully registered IRQs and allocated resources on failure. Also move ab->irq_num[irq_idx] assignment after request_irq() succeeds in the ext IRQ path to match the CE IRQ path and avoid storing a stale IRQ number on failure.
---
LLM Generated explanations, may be completely bogus:
# Stable backport analysis: 8ab38bbac022 (“wifi: ath11k: fix resource leak on error in ext IRQ setup”)
Local tree: **Linux 6.1.188** (p-6.1-11-gffee1c0de6cf2). The candidate is **not** an ancestor of HEAD. Verdict is for this 6.1.y tree only.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1 — Subject**
- Record: **[wifi: ath11k]** **[fix]** resource leak on error in AHB ext IRQ setup.
**Step 1.2 — Tags**
- Record:
- Reviewed-by: Rameshkumar Sundaram <[email protected]> (Qualcomm ath11k reviewer)
- Reviewed-by: Baochen Qiang <[email protected]> (Qualcomm ath11k reviewer)
- `Link: https://patch.msgid.link/20260729020005.219253-1-
[email protected]`
- Signed-off-by: ZhaoJinming <[email protected]> (author)
- Signed-off-by: Jeff Johnson <[email protected]> (ath11k maintainer, applied)
- No Fixes:, Reported-by:, Tested-by:, Cc: stable (absence is expected for this pipeline)
- No syzbot / sanitizer tags
**Step 1.3 — Body**
The commit describes three bugs in ath11k_ahb_config_irq() / ath11k_ahb_config_ext_irq():
1. **CE request_irq() fail:** returns immediately; previously registered CE IRQs are not freed. Probe err_ce_free does **not** call ath11k_ahb_free_irq(), so those handlers stay attached.
2. **Ext request_irq() fail:** error is logged only; function still returns 0. Device probes in a partial-IRQ state. Later enable_irq() / disable_irq() / free_irq() on unregistered lines trigger WARN_ON(!desc->action); missing handlers cause data loss.
3. **alloc_netdev_dummy() fail** on a later group: -ENOMEM without freeing earlier groups’ ext IRQs / dummy netdevs.
Fix: propagate errors, unwind registered IRQs/resources, assign ab->irq_num[irq_idx] only after a successful request_irq().
- Record: **[Bugs: IRQ leak, swallowed setup error, dummy-netdev leak]** **[Symptoms: leaked IRQ handlers; WARN_ON; missing datapath IRQs / data loss]** **[No version bounds in the message]** **[Root cause:
missing unwind + ignored request_irq() failure]**
**Step 1.4 — Hidden bug fix?**
- Record: **No.** This is an explicit error-path / resource-leak fix, not cleanup disguised as a fix.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1 — Inventory**
- Record: **1 file**, drivers/net/wireless/ath/ath11k/ahb.c, **+55 / −24**.
- Functions: ath11k_ahb_free_ext_irq split into ath11k_ahb_free_ext_irq_grp + wrapper; new ath11k_ahb_free_ce_irqs; ath11k_ahb_free_irq uses the new helpers; ath11k_ahb_config_ext_irq and ath11k_ahb_config_irq grow unwind paths.
- Scope: **single-file surgical fix** (small helper extract, no API change).
**Step 2.2 — Flow change**
- **free_ext_irq:** all-groups cleanup → per-group helper so a failed group can be unwound without touching later groups.
- **config_ext_irq request_irq fail:** log and continue / return 0 → set num_irq = j, free current group, unwind prior groups, return error.
- **alloc_netdev_dummy fail:** immediate -ENOMEM → same unwind of prior groups.
- **irq_num store:** before request_irq → after success (avoids a stale IRQ number used by later enable/disable/free).
- **config_irq CE fail:** bare return ret → ath11k_ahb_free_ce_irqs(ab, i) then return.
- **config_irq ext fail:** return ret with CE IRQs still held → free all CE IRQs then return.
**Step 2.3 — Bug mechanism**
- Record: **[Error-path resource leak + logic/correctness (swallowed error)]**
- CE leak = missing free_irq on probe failure.
- Ext path = ignored request_irq error so probe “succeeds” with unregistered IRQs; ath11k_ahb_ext_grp_enable() then calls enable_irq() over irq_grp->num_irq.
- Dummy-netdev leak is mainline-only (see Phase 6).
**Step 2.4 — Fix quality**
- Record: **Obviously correct for the two request_irq bugs.** Helpers match existing free loops. num_irq = j before freeing the failed group is right (only successful IRQs). err_request_irq does i-- so the current group is not double-freed. **Regression risk is low** if adapted; **high if the mainline diff is applied blindly** because it calls free_netdev(irq_grp->napi_ndev) and napi_ndev is an embedded struct net_device here, not a pointer.
---
## PHASE 3: GIT HISTORY
**Step 3.1 — Blame / introduction**
- Record: Buggy CE early-return and swallowed ext request_irq error are in the original driver **d5c65159f2895 (2019-11-23, “ath11k:
driver for Qualcomm IEEE 802.11ax devices”)**. Present since before v5.6; certainly in 6.1.
**Step 3.2 — Fixes: tag**
- Record: **No Fixes: tag.** Original buggy commit is d5c65159f2895, which **is** in this tree.
**Step 3.3 — File history on this tree**
- Record: Recent 6.1.y ahb.c commits are unrelated (IPQ5018 CE remap, rproc defer, fw deinit, platform_get_irq for MSI). Related older commit **22b59cb965f79** added netif_napi_del() on free to fix a reload oops — same area, does **not** fix these leaks. **Standalone candidate**, not patch X/Y.
**Step 3.4 — Author**
- Record: ZhaoJinming has **no other ath11k commits in this 6.1 tree**. Review/apply came from Qualcomm (Baochen Qiang, Rameshkumar Sundaram, Jeff Johnson).
**Step 3.5 — Prerequisites**
- Record: Mainline diff **depends on bca592ead8252 (2024-04-22, dynamic dummy netdev)** for alloc_netdev_dummy / free_netdev. That commit is **not** in 6.1 (git merge-base --is-ancestor failed). CE/ext request_irq unwind does **not** need that commit. **Cannot apply the mainline diff standalone; a 6.1-shaped backport can.**
---
## PHASE 4: MAILING LIST / EXTERNAL
**Step 4.1 — Original discussion**
- Record: b4 dig -c 8ab38bbac0229 → lore thread
https://patch.msgid.link/20260728031335.3818736-1-
[email protected]
- Revisions: **v1 (2026-06-22) through v7 (2026-07-28)**; committed message id is a follow-up of v7. Review drove: move irq_grp to function scope, init ret on ENOMEM, unwind CE IRQs on ext failure, extract per-group/CE free helpers, drop an unreachable napi_ndev NULL guard, store irq_num only after success.
- **No NAK.** Baochen’s v7 comment was process-only (don’t put old- version Link: in the commit body). **No reviewer Cc: stable.**
**Step 4.2 — Recipients (b4 dig -w)**
- Record: Jeff Johnson, Baochen Qiang, [email protected], [email protected], [email protected]. Right maintainers were on the thread.
**Step 4.3 — Bug report**
- Record: **No user/syzbot/bugzilla report.** Analysis-driven. Severity claimed by the author is verified in this tree’s code (Phase 6).
**Step 4.4 — Series**
- Record: **Single-patch series** (v1–v7 are revisions of the same change). No sibling patches required.
**Step 4.5 — Stable list**
- Record: **UNVERIFIED.** lore.kernel.org/stable fetch returned HTTP
403. No stable-list discussion found via b4.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1 — Functions**
- Record: ath11k_ahb_free_ext_irq_grp (new), ath11k_ahb_free_ext_irq, ath11k_ahb_free_ce_irqs (new), ath11k_ahb_free_irq, ath11k_ahb_config_ext_irq, ath11k_ahb_config_irq.
**Step 5.2 — Callers (this tree)**
- ath11k_ahb_config_irq() — only from ath11k_ahb_probe() (ahb.c:1219).
- ath11k_ahb_free_irq() — from ath11k_ahb_free_resources() on remove/shutdown (ahb.c:1268), **not** from probe err_ce_free.
- ath11k_ahb_ext_grp_enable() — from ath11k_ahb_ext_irq_enable() / NAPI complete; walks irq_grp->num_irq and enable_irq().
- Hybrid WCN6750 uses ath11k_pcic_config_irq() instead (PCI probe **does** have err_free_irq).
**Step 5.3 — Callees**
- Record: request_irq, free_irq, platform_get_irq_byname, irq_set_status_flags, netif_napi_add / netif_napi_del, init_dummy_netdev (6.1) vs alloc_netdev_dummy / free_netdev (mainline).
**Step 5.4 — Reachability**
- Record: Probe / start / remove of CONFIG_ATH11K_AHB devices (IPQ8074/6018/5018 and similar). Userspace cannot hit it via a normal syscall; it runs on device bind, ath11k_ahb_start(), and unbind. **Reachable on every AHB ath11k probe.** The *failure* path needs request_irq() to fail (missing DT IRQ, IRQ alloc failure).
**Step 5.5 — Similar patterns**
- Record: ath11k_pcic_ext_irq_config() **does** return request_irq errors; PCI probe frees IRQs on error. AHB is the inconsistent path. Same swallowed-request_irq pattern has been in AHB since 2019.
---
## PHASE 6: THIS TREE (6.1.188)
**Step 6.1 — Does the buggy code exist?**
Yes, two of three bugs:
```617:624:drivers/net/wireless/ath/ath11k/ahb.c
if (ret) {
ath11k_err(ab, "failed request_irq for
%d\n",
irq);
}
}
}
return 0;
```num_irq is set to the **full** count **before** that loop (ahb.c:605), and ab->irq_num[irq_idx] = irq is stored **before** request_irq() (ahb.c:612). ath11k_ahb_ext_grp_enable() then enable_irq()s every entry (ahb.c:247-248).
```649:650:drivers/net/wireless/ath/ath11k/ahb.c
if (ret)
return ret;
```Probe error path:
```1219:1230:drivers/net/wireless/ath/ath11k/ahb.c
ret = ath11k_ahb_config_irq(ab);
if (ret) {
ath11k_err(ab, "failed to configure irq: %d\n", ret);
goto err_ce_free;
}
...
err_ce_free:
ath11k_ce_free_pipes(ab);
```No ath11k_ahb_free_irq() on that path.
**Third bug does not exist here.** Dummy NAPI netdev is embedded:
```172:172:drivers/net/wireless/ath/ath11k/core.h
struct net_device napi_ndev;
```Setup uses init_dummy_netdev(&irq_grp->napi_ndev) (ahb.c:558). No alloc_netdev_dummy, no free_netdev.
- Record: **Bugs 1 and 2 present since 2019. Bug 3 introduced in 2024; not in 6.1.**
**Step 6.2 — Backport difficulty**
- git show 8ab38bb | git apply --check **fails**: context expects free_netdev(irq_grp->napi_ndev).
- Needed 6.1 backport: same error propagation and CE/ext unwind; **omit** free_netdev and the alloc_netdev_dummy ENOMEM path; keep netif_napi_del only.
- Record: **Needs rework (not a clean cherry-pick).** Blind apply would not compile.
**Step 6.3 — Related fixes already here?**
- Record: **No equivalent fix.** 22b59cb965f79 only added netif_napi_del on the success/remove free path.
---
## PHASE 7: SUBSYSTEM CONTEXT
**Step 7.1**
- Record: **drivers/net/wireless/ath/ath11k (AHB HIF).** Criticality:
**IMPORTANT** — Qualcomm Wi-Fi 6 on IPQ SoCs used in routers/APs; not core mm/net, but common on 6.1 LTS embedded/enterprise images. CONFIG_ATH11K_AHB.
**Step 7.2**
- Record: Mature driver (2019). 6.1.y still receives targeted ath11k backports (rproc defer, fw deinit, IPQ5018 CE remap). Not a staging or newly added subsystem.
---
## PHASE 8: IMPACT AND RISK
**Step 8.1 — Who is affected**
- Record: **Driver-specific / config-specific:** CONFIG_ATH11K_AHB (IPQ8074/6018/5018 class). Hybrid WCN6750 uses the PCI-common path and is not fixed (or broken) by this change.
**Step 8.2 — Trigger**
- Record: request_irq() failure during probe (bad/missing DT interrupt, IRQ exhaustion). **Uncommon on a correct board DT**, but then **every** subsequent enable/disable/free and datapath completion is wrong. Not an unprivileged syscall primitive; bind is typically module load / boot. **Unprivileged users do not directly trigger it.**
**Step 8.3 — Failure mode**
- Swallowed ext IRQ error: **WARN_ON(!desc->action)** plus missing TX/RX completion IRQs → **data loss / broken Wi-Fi while probe reports success**. Severity: **HIGH**.
- CE IRQ leak on failed probe: leaked IRQ actions, messy rebind.
Severity: **MEDIUM–HIGH** (reload already oopsed in this area before 22b59cb).
- Dummy-netdev leak: **N/A on this tree**.
**Step 8.4 — Risk vs benefit**
- Benefit: **High** for AHB boards if request_irq fails (WARN_ON + silent datapath loss is worse than a clean probe failure).
- Risk of a **correct 6.1 backport**: **Low** (error paths + helper split; success path behavior unchanged).
- Risk of the **raw mainline patch**: **High** (free_netdev on an embedded net_device).
- Ratio: **favorable if adapted; do not cherry-pick as-is.**
---
## PHASE 9: SYNTHESIS
**Step 9.1 — Evidence**
**For:**
- Real bugs in **this** 6.1 tree (CE leak; swallowed ext request_irq).
- User-visible: kernel WARN_ON, missing datapath IRQs, data loss, leaked IRQ handlers.
- Small, one-file, no new API/feature.
- Logic checked against probe/remove and enable_irq paths in this checkout.
- Present since 2019; reviewed by Qualcomm ath11k reviewers; applied by Jeff Johnson.
- PCI sibling already returns request_irq errors; AHB is the hole.
**Against:**
- Mainline diff **does not apply**; it assumes alloc_netdev_dummy / pointer napi_ndev (bca592ead8252 not in 6.1).
- Third issue is **not** in 6.1.
- Trigger is uncommon (needs request_irq failure).
- No Reported-by / syzbot / stable-list nomination (stable search UNVERIFIED).
- Author is not an ath11k regular on this tree.
**Unresolved:** stable@ discussion (HTTP 403).
**Step 9.2 — Stable rules**
1. Obviously correct and tested? **PASS** for the two applicable bugs (review + maintainer apply). The shipped diff is **not** drop-in correct on 6.1.
2. Real bug affecting users? **PASS** (WARN_ON, data loss, IRQ leak on AHB probe/remove).
3. Important (crash / warn / data loss / leak)? **PASS** — HIGH for swallowed ext IRQ failure.
4. Small and contained? **PASS** (one file, ~50 lines of logic).
5. No new features/APIs? **PASS**.
6. Can apply to this tree? **FAIL** as a raw cherry-pick; **PASS** as a small mechanical backport (drop free_netdev / alloc_netdev_dummy ENOMEM path).
**Step 9.3 — Exception category**
- Record: **None** (not a device ID, quirk, DT, build, or doc fix). Qualifies as a normal error-path / correctness bug fix.
**Step 9.4 — Decision**
The two bugs that matter on 6.1 are in this tree, are real, and are serious when they fire. The mainline commit also cleans up a later dummy-netdev leak that 6.1 does not have; that does not erase the AHB request_irq holes. A 6.1 backport must **not** call free_netdev on the embedded napi_ndev. With that adjustment, this belongs on 6.1.y.
---
## What the commit solves for 6.1 users
On IPQ AHB ath11k, a failed request_irq() for an ext IRQ is ignored and probe still succeeds. Start/remove then enable_irq/free_irq unregistered lines (WARN_ON) and drop datapath interrupts. A failed CE request_irq() also leaks earlier CE handlers because probe’s err_ce_free never calls ath11k_ahb_free_irq(). Both are old, contained, and worth fixing on this LTS tree. The dummy-netdev part of the mainline patch is irrelevant here and must be omitted.
---
## Verification
- [Phase 1] Parsed tags: Reviewed-by Rameshkumar Sundaram, Baochen Qiang; SOB ZhaoJinming + Jeff Johnson; Link msgid 20260729020005; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: +55/−24 in ahb.c; helper split + error unwind; irq_num assigned after success
- [Phase 3] git log on ahb.c: swallowed ext error and CE early- return since d5c65159f2895 (2019-11-23)
- [Phase 3] No Fixes: tag; bca592ead8252 is **not** an ancestor of HEAD
- [Phase 3] git log --author=ZhaoJinming on ath11k in this tree: no other commits
- [Phase 4] b4 dig -c 8ab38bbac0229: thread https://patch.msgid.link/2
[email protected]
- [Phase 4] b4 dig -a: v1–v7; committed version is latest content (v6+irq_num ordering, v7 resend)
- [Phase 4] b4 dig -w: Jeff Johnson, Baochen Qiang, ath11k and linux- wireless lists
- [Phase 4] mbox: Baochen process comment only; no NAK; no Cc:stable
- [Phase 4] lore.kernel.org WebFetch: HTTP 403; stable-list search UNVERIFIED
- [Phase 5] Callers: ath11k_ahb_probe → config_irq; enable path ath11k_ahb_ext_grp_enable uses num_irq
- [Phase 6] git describe HEAD / Makefile: **6.1.188** (p-6.1-11-gffee1c0de6cf2); v6.1.188 is ancestor
- [Phase 6] git merge-base --is-ancestor 8ab38bbac0229 HEAD: **not present**
- [Phase 6] Read ahb.c 545–659 and 1219–1230: bugs 1 and 2 present; init_dummy_netdev / embedded napi_ndev
- [Phase 6] git apply --check of 8ab38bb: **does not apply** (expects free_netdev)
- [Phase 8] Failure mode verified: enable_irq on stored irq_num after ignored request_irq → WARN_ON / data loss
- UNVERIFIED: whether stable@ already discussed this commit (lore 403)
The two AHB request_irq bugs exist in 6.1.188, are user-visible when they trigger, and a small adapted backport (no free_netdev) is the right way to take this commit.
**YES**
drivers/net/wireless/ath/ath11k/ahb.c | 79 +++++++++++++++++++-------- 1 file changed, 55 insertions(+), 24 deletions(-)
drivers/net/wireless/ath/ath11k/ahb.c +55 -24
@@ -431,36 +431,44 @@ static void ath11k_ahb_init_qmi_ce_config(struct ath11k_base *ab) ab->qmi.service_ins_id = ab->hw_params.qmi_service_ins_id; } -static void ath11k_ahb_free_ext_irq (struct ath11k_base *ab) +static void ath11k_ahb_free_ext_irq_grp (struct ath11k_base *ab, +struct ath11k_ext_irq_grp *irq_grp) { -int i, j; - -for (i =0 ; i <ATH11K_EXT_IRQ_GRP_NUM_MAX ; i++) { -struct ath11k_ext_irq_grp *irq_grp = &ab->ext_irq_grp[i]; +int j; -for (j =0 ; j < irq_grp->num_irq; j++) -free_irq (ab->irq_num[irq_grp->irqs[j]], irq_grp); +for (j =0 ; j < irq_grp->num_irq; j++) +free_irq (ab->irq_num[irq_grp->irqs[j]], irq_grp); -netif_napi_del (&irq_grp->napi); -free_netdev (irq_grp->napi_ndev); - } +netif_napi_del (&irq_grp->napi); +free_netdev (irq_grp->napi_ndev); } -static void ath11k_ahb_free_irq (struct ath11k_base *ab) +static void ath11k_ahb_free_ext_irq (struct ath11k_base *ab) { -int irq_idx;int i; -if (ab->hw_params.hybrid_bus_type) -return ath11k_pcic_free_irq (ab); +for (i =0 ; i <ATH11K_EXT_IRQ_GRP_NUM_MAX ; i++) +ath11k_ahb_free_ext_irq_grp (ab, &ab->ext_irq_grp[i]); +} -for (i =0 ; i < ab->hw_params.ce_count; i++) { +static void ath11k_ahb_free_ce_irqs (struct ath11k_base *ab,int max_idx) +{ +int irq_idx, i; + +for (i =0 ; i < max_idx; i++) {if (ath11k_ce_get_attr_flags (ab, i) &CE_ATTR_DIS_INTR )continue ; irq_idx =ATH11K_IRQ_CE0_OFFSET + i;free_irq (ab->irq_num[irq_idx], &ab->ce.ce_pipe[i]); } +} + +static void ath11k_ahb_free_irq (struct ath11k_base *ab) +{ +if (ab->hw_params.hybrid_bus_type) +return ath11k_pcic_free_irq (ab); +ath11k_ahb_free_ce_irqs (ab, ab->hw_params.ce_count);ath11k_ahb_free_ext_irq (ab); }
@@ -524,20 +532,25 @@ static irqreturn_t ath11k_ahb_ext_interrupt_handler(int irq, void *arg)static int ath11k_ahb_config_ext_irq (struct ath11k_base *ab) {struct ath11k_hw_params *hw = &ab->hw_params; +struct ath11k_ext_irq_grp *irq_grp;int i, j;int irq;int ret;for (i =0 ; i <ATH11K_EXT_IRQ_GRP_NUM_MAX ; i++) { -struct ath11k_ext_irq_grp *irq_grp = &ab->ext_irq_grp[i];u32 num_irq =0 ; + irq_grp = &ab->ext_irq_grp[i]; + irq_grp->ab = ab; irq_grp->grp_id = i; irq_grp->napi_ndev =alloc_netdev_dummy (0 ); -if (!irq_grp->napi_ndev) -return -ENOMEM ; +if (!irq_grp->napi_ndev) { + ret = -ENOMEM ; + irq_grp->num_irq =0 ; + goto err_request_irq; + }netif_napi_add (irq_grp->napi_ndev, &irq_grp->napi, ath11k_ahb_ext_grp_napi_poll);
@@ -585,14 +598,11 @@ static int ath11k_ahb_config_ext_irq(struct ath11k_base *ab) } } } - irq_grp->num_irq = num_irq; - -for (j =0 ; j < irq_grp->num_irq; j++) { +for (j =0 ; j < num_irq; j++) {int irq_idx = irq_grp->irqs[j]; irq =platform_get_irq_byname (ab->pdev, irq_name[irq_idx]); - ab->irq_num[irq_idx] = irq;irq_set_status_flags (irq,IRQ_NOAUTOEN |IRQ_DISABLE_UNLAZY ); ret = request_irq(irq, ath11k_ahb_ext_interrupt_handler, IRQF_TRIGGER_RISING,
@@ -600,11 +610,24 @@ static int ath11k_ahb_config_ext_irq(struct ath11k_base *ab)if (ret) {ath11k_err (ab,"failed request_irq for %d\n" , irq); + irq_grp->num_irq = j; +ath11k_ahb_free_ext_irq_grp (ab, irq_grp); + goto err_request_irq; } + ab->irq_num[irq_idx] = irq; } + + irq_grp->num_irq = num_irq; }return 0 ; + +err_request_irq: +for (i--; i >=0 ; i--) { + irq_grp = &ab->ext_irq_grp[i]; +ath11k_ahb_free_ext_irq_grp (ab, irq_grp); + } +return ret; }static int ath11k_ahb_config_irq (struct ath11k_base *ab)
@@ -629,16 +652,24 @@ static int ath11k_ahb_config_irq(struct ath11k_base *ab) ret =request_irq (irq, ath11k_ahb_ce_interrupt_handler,IRQF_TRIGGER_RISING , irq_name[irq_idx], ce_pipe); -if (ret) +if (ret) { +ath11k_err (ab,"failed request_irq for %d\n" , irq); +ath11k_ahb_free_ce_irqs (ab, i);return ret; + } ab->irq_num[irq_idx] = irq; }/* Configure external interrupts */ ret =ath11k_ahb_config_ext_irq (ab); +if (ret) { +ath11k_err (ab,"failed to configure ext irq: %d\n" , ret); +ath11k_ahb_free_ce_irqs (ab, ab->hw_params.ce_count); +return ret; + } -return ret; +return 0 ; } static int ath11k_ahb_map_service_to_pipe(struct ath11k_base *ab, u16 service_id,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ext4: reject mount if clusters/inodes per group are not 8-aligned
In reply to Sasha LevinFrom: Baokun Li <[email protected]>
[ Upstream commit d42dc7726a003262b73ffef2b744ff57a5488799 ]
The block and inode bitmap checksums are computed over a whole number of
bytes: ext4_inode_bitmap_csum_*() use EXT4_INODES_PER_GROUP(sb) >> 3 and ext4_block_bitmap_csum_*() use EXT4_CLUSTERS_PER_GROUP(sb) / 8 as the length passed to ext4_chksum().
If s_inodes_per_group or s_clusters_per_group is not a multiple of 8, the trailing fractional bits are excluded from the checksum. Those bits are then unprotected, and any incremental csum update path that assumes a byte-aligned bitmap can compute a checksum inconsistent with the full recalculation, corrupting the on-disk bitmap checksum.
Reject such filesystems at mount time by adding the missing " & 7" alignment checks alongside the existing range validation.
---
LLM Generated explanations, may be completely bogus:
This is a small ext4 mount-time geometry check. Local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The candidate is d42dc7726a003. The checksum path still uses byte-truncated lengths, so the bug this closes is real in this tree.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[ext4] [reject] reject mount if clusters/inodes per group are not 8-aligned**
Subsystem ext4. Verb reject is a defensive mount-time check, not a feature or refactor.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Suggested-by:** Theodore Ts'o <[email protected]> (ext4 maintainer)
- **Link:** https://patch.msgid.link/h3n7jlfhyna64dn5o76qxcspnhxdddcs6c rpxftmy7gnl7b3sx@jenszfpcsnit (Ted’s suggestion)
- **Reported-by:** Sashiko <[email protected]> (static-analysis bot, not syzbot)
- **Closes:** sashiko.dev URL pointing at RFC series part 10
- **Signed-off-by:** Baokun Li <[email protected]> (author)
- **Reviewed-by:** Jan Kara <[email protected]> (ext4 co-maintainer)
- **Reviewed-by:** Zhang Yi <[email protected]>
- **Link:** https://patch.msgid.link/20260608111150.827117-2- [email protected] (v2 1/3)
- **Signed-off-by:** Theodore Ts'o <[email protected]> (applied)
- **No Fixes:** tag (expected)
- **No Cc: stable** (expected)
- Ignore pipeline markers: none of [Upstream commit] / Sasha Levin SOB on this commit
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** inode/block bitmap checksums hash a whole number of bytes (EXT4_INODES_PER_GROUP >> 3, EXT4_CLUSTERS_PER_GROUP / 8). If those counts are not multiples of 8, the last 1–7 bits are omitted from the CRC.
- **Symptom:** those bits are unprotected; an incremental CRC path that assumes byte alignment can disagree with a full recalculation and write a bad on-disk bitmap checksum.
- **Version info:** none in the message.
- **Root cause (author):** missing & 7 checks next to the existing range checks in ext4_handle_clustersize() / ext4_block_group_meta_init().
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not hidden.** Explicit mount rejection for invalid superblock geometry. Cover letter ([PATCH v2 0/3]) states the series prevents crafted images from causing bitmap checksum corruption, integer overflow, or OOB inode-table access. This patch is the checksum/alignment piece.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** fs/ext4/super.c only (+6 / -4)
- **Functions:** ext4_handle_clustersize(), ext4_block_group_meta_init()
- **Scope:** single-file surgical fix, two existing if conditions
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Hunk 1 (ext4_handle_clustersize):** previously rejected only s_clusters_per_group > blocksize * 8. After: also reject s_clusters_per_group & 7. Error text becomes "invalid #clusters per group".
- **Hunk 2 (ext4_block_group_meta_init):** previously rejected inodes- per-group outside [inodes_per_block, blocksize*8]. After: also reject s_inodes_per_group & 7. Trailing \n in the format string dropped.
- **Path:** mount / __ext4_fill_super() only. Legitimate 8-aligned filesystems are unchanged.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Logic / correctness + metadata integrity]**
Verified in fs/ext4/bitmap.c:
```31:31:fs/ext4/bitmap.c
sz = EXT4_INODES_PER_GROUP(sb) >> 3;
``````68:68:fs/ext4/bitmap.c
int sz = EXT4_CLUSTERS_PER_GROUP(sb) / 8;
```Set and verify use the same truncated length, so kernel-internal CRC is consistent. Trailing bits are still live inode/cluster bits (ext4_set_bit in alloc/free) but are **not** covered by metadata_csum. ialloc.c zeros with (EXT4_INODES_PER_GROUP(sb) + 7) / 8 (round up) while CRC uses >> 3 (round down).
The “incremental csum update” failure mode is what Sashiko flagged in **unmerged** RFC helper ext4_inode_bitmap_csum_set_fast(). crc32c_flip_range is **not** in this tree. The gap that **is** in this tree is unprotected trailing bitmap bits plus disagreement with any tool that hashes a different length.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Quality:** obviously correct. & 7 matches the CRC byte length. Same style as the existing upper-bound checks.
- **Regression risk:** only rejects non-8-aligned geometries. Ted documented that old Android make_ext4fs could emit those; he also said that was fixed more than a decade ago and those devices should be gone. Follow-up a34de48f329b2 only adds another conjunct on the same if; it does not revert this check.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Cluster range check introduced in 40da553f5da02 (“ext4: verify s_clusters_per_group even without bigalloc”, 2024-03-07, Jan Kara).
- Inode range check lived in this helper since 107d2be90116a (2023 factor-out); the blocksize * 8 bound is older (c8267c51425ab moved a local).
- Bitmap CRC with / 8 / >> 3 dates to 41a246d1ff75a / fa77dcfafeaa6 (2012, metadata_csum).
- Alignment checks themselves are d42dc7726a003 (this commit).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Buggy assumption is as old as metadata_csum (2012), not a recent regression.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Same series, independent patches:
- d42dc7726a003 — this commit (v2 1/3)
- afa3caf2fbc41 — max cluster size (v2 2/3)
- a34de48f329b2 — inodes_per_group % inodes_per_block (v2 3/3)
- Cover letter: patches 2 and 3 are “independent of Patch 1”.
- This patch does not need 2/3.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Baokun Li is a regular ext4 contributor (many DIO/DAX and validation patches). Not the maintainer; Ted applied it. Jan Kara and Zhang Yi reviewed.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **Standalone.** Touches existing ifs in helpers that exist here (ext4_handle_clustersize at super.c:4461, ext4_block_group_meta_init at super.c:5294). No new helpers, no incremental CRC.
git merge-base --is-ancestor d42dc7726a003 HEAD → **yes** (exit 0). Already in this checkout via ext4_for_linus-7.3-rc1.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **b4 dig -c d42dc7726a003:** https://patch.msgid.link/20260608111150. [email protected]
- **Revisions:**
- v1 RFC: part of 17-patch incremental CRC series (`lib/crc: add
crc32c_flip_range()`), 2026-05-08
- v2: `[PATCH v2 0/3] ext4: tighten mount-time superblock geometry
validation`, 2026-06-08 (this is what landed)- v2 vs v1 for **this** patch: only dropped a spurious \n in the error format.
- **Reviews:** Zhang Yi “Looks good”; Jan Kara “Looks good”; Ted “Applied, thanks!” with the three SHAs.
- **No NAKs.** No reviewer asked for Cc: stable.
- lore.kernel.org HTTP **403**; thread recovered via b4 dig -m.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (**b4 dig -w**): linux-ext4, Ted Ts'o, Andreas Dilger, Jan Kara, Zhang Yi, Ojaswin Mujoo, Ritesh, Sashiko. Subsystem maintainers were on To/Cc. Jan Kara and Zhang Yi reviewed this patch; Ted applied it.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: Sashiko High finding on RFC 10/17 ext4_inode_bitmap_csum_set_fast(): incremental CRC would corrupt the checksum if INODES_PER_GROUP is not a multiple of 8.
Ted’s reply (verified from mbox h3n7jlfhyna64dn5o76qxcspnhxdddcs6crpxftmy7gnl7b3sx@jenszfpcsnit):
- Kernel historically **did not** enforce 8-alignment because old Android make_ext4fs (MIT, pre-e2fsprogs) sometimes created non- multiples of 8.
- That hit e2fsck ([sourceforge e2fsprogs bug 292](https://sourceforge.net/p/e2fsprogs/bugs/292/)).
- “Fixed long ago (over a decade ago)… any such mobile handsets are in the landfill, so we probably should fix this by adding a check in ext4_fill_super().”
So this is maintainer-directed policy: stop mounting geometries e2fsck already treats as invalid.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: v2 is three independent mount checks. Incremental CRC RFC was **not** merged (crc32c_flip_range absent). This patch does not pull in that series.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** — lore.kernel.org/stable returned 403. No stable discussion in the ext4 mbox.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: ext4_handle_clustersize, ext4_block_group_meta_init.
Supporting: ext4_inode_bitmap_csum_{set,verify}, ext4_block_bitmap_csum_{set,verify}.
**Step 5.2: TRACE CALLERS**
Record: both are called only from __ext4_fill_super() (super.c:5443 and 5451). Mount path, not hot I/O. Reaching the bug is “mount this filesystem” (loop, USB, etc.).
**Step 5.3: TRACE CALLEES**
Record: read superblock fields, ext4_msg, return -EINVAL. No alloc, no new locks.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: mount / fsopen → ext4_fill_super → these checks. Unprivileged users can hit it with a crafted image on a loop device if they can mount (or via automount). **Userspace-reachable.**
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: same file already rejects other invalid geometry (blocks vs clusters, inodes_per_block). Series patch 3 adds % inodes_per_block on the same inode if. ext4_count_free() debug paths also use / 8, so free-count vs last bits can disagree on unaligned groups.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** This tree is **7.3.0-rc4**. bitmap.c still uses >> 3 and / 8. The alignment checks are already present at super.c:4494-4498 and 5327-5333 because d42dc7726a003 is an ancestor of HEAD. The bug the commit addresses (CRC length vs bit count) is inherent in that checksum code, which has been here since metadata_csum.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply on this tree** — already applied; helpers and surrounding checks match the diff. (Older stables that still have these checks inline in ext4_fill_super would need context adjustment; that is **not** this checkout.)
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: this exact fix is in the tree. No alternate fix. a34de48f329b2 extends the inode if but does not replace the & 7 check.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **ext4 (fs/ext4/) — IMPORTANT.** Default Linux filesystem; corruption/integrity issues matter to a large user base.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: active (recent 7.3 merges, DIO/DAX, writeback, fastcommit). Superblock validation is mature; this fills a long-standing hole.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **filesystem-specific**, ext4 with metadata_csum (and bitmap ops generally). Trigger is a superblock with s_inodes_per_group or s_clusters_per_group not divisible by 8. Normal mke2fs images are 8-aligned (group size blocksize * 8). Population: crafted/fuzzed images, plus theoretically ancient Android make_ext4fs images Ted believes are gone.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: mount of such an image. Not every boot of a normal distro disk. Unprivileged trigger if the user can mount a file. Not a race.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- **Without the check:** trailing bitmap bits omitted from metadata_csum → integrity hole; debug free-counts ignore those bits; incremental CRC (not in this tree) could write a wrong checksum.
- **With the check:** mount fails with -EINVAL and a clear error.
- **Severity: MEDIUM–HIGH** for crafted images (metadata integrity / checksum vs tools). **Not** a panic on a normal disk. Fits the stable “oh, that’s not good” / data-integrity class more than oops/deadlock.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** stops mounting invalid geometry; closes unprotected bitmap bits; matches e2fsck/Ted’s request. High for anyone mounting untrusted ext4 images; low for typical servers with mke2fs disks.
- **Risk:** very low on this tree — 6 lines, mount-time only, no locking/API change. Residual risk is refusing a 10+ year-old Android image; maintainer explicitly accepted that.
- **Ratio:** favorable.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR backporting**
- Real metadata-integrity bug: CRC covers n/8 bytes, bitmaps have n bits.
- Crafted-image mount path is userspace-reachable.
- 6-line, obviously correct addition to existing validation.
- Suggested and applied by Ted Ts'o; Reviewed-by Jan Kara and Zhang Yi; no NAKs.
- Independent of the rest of the v2 series and of the unmerged CRC RFC.
- Code and helpers exist in this 7.3-rc4 tree; patch applies as written.
- Cover letter: “preventing crafted filesystem images from causing bitmap checksum corruption”.
**AGAINST**
- Incremental CRC that would *write* a wrong checksum is **not** in this kernel.
- No production oops/syzbot repro on a normal filesystem.
- Possible mount refusal of ancient make_ext4fs images (Ted:
landfill).
- Sashiko is static analysis, not a user crash.
**UNRESOLVED**
- Stable list archives (lore 403).
- Current e2fsprogs source not in this repo (Ted’s historical e2fsck conflict is documented).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — & 7 next to existing bounds; reviewed by two ext4 developers; applied by maintainer.
2. Fixes a real bug that affects users? **PASS** — unprotected bitmap bits and crafted-image checksum/integrity mismatch; maintainer treated it as a real fill_super hole.
3. Important issue (crash, security, corruption, deadlock)? **PASS** — metadata checksum integrity / crafted-image corruption; not a panic, but on-disk checksum and metadata_csum bypass for trailing bits.
4. Small and contained? **PASS** — 6 insertions / 4 deletions, one file.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — already applies; context matches.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: none (not a device ID, quirk, DT, build, or docs patch). Qualified on the normal bug-fix path.
**Step 9.4: MAKE YOUR DECISION**
This belongs on this tree: the checksum code still truncates to whole bytes, mount already validates these fields, and adding & 7 is the missing invariant the CRC and bitmaps assume. It is small, maintainer- directed, and does not depend on the incremental-CRC series that never landed.
### What problem it solves and why it matters here
metadata_csum hashes inode/block bitmaps in byte units. A superblock with inodes or clusters per group not divisible by 8 leaves up to 7 bits out of the CRC while alloc/free still uses those bits. That is an integrity hole and a footgun for any checksum updater that assumes byte alignment. Rejecting that geometry at mount is the same class of check this file already does for “too big” groups.
### Risk vs benefit
Benefit is closing that hole and refusing crafted images. Risk is a failed mount of a pathological superblock. Ted already signed off that remaining Android make_ext4fs cases are historical.
---
Verification:
- [Phase 1] Parsed tags: Suggested-by Ted Ts'o; Reported-by Sashiko; Reviewed-by Jan Kara, Zhang Yi; msgid 827117-2; no Fixes/Cc-stable
- [Phase 1] Cover letter in mbox: crafted images → bitmap checksum corruption / overflow / OOB inode table
- [Phase 2] Diff: +6/-4 in fs/ext4/super.c; s_clusters_per_group & 7 and s_inodes_per_group & 7
- [Phase 2] bitmap.c: >> 3 and / 8 confirmed; set and verify share length
- [Phase 2] ialloc.c:173: memset uses (n+7)/8 vs CRC >> 3
- [Phase 2] crc32c_flip_range: no matches — incremental CRC not in this tree
- [Phase 3] git describe HEAD / make kernelversion: **v7.3-rc4 / 7.3.0-rc4**
- [Phase 3] git merge-base --is-ancestor d42dc7726a003 HEAD: yes
- [Phase 3] blame: cluster bound 40da553f5da02 (2024); inode bound via 107d2be90116a; CRC since 41a246d1ff75a (2012)
- [Phase 3] series: afa3caf2fbc41 and a34de48f329b2 independent; cover letter says so
- [Phase 4] b4 dig -c: patch.msgid.link/20260608111150.827117-2-…; v1 RFC 17-patch CRC, v2 3-patch validation
- [Phase 4] b4 dig -a/-w/-m: Zhang Yi + Jan Kara R-b; Ted applied; recipients linux-ext4 + maintainers
- [Phase 4] Ted mbox: Android make_ext4fs history; add fill_super check
- [Phase 4] lore HTTP 403; used b4 instead
- [Phase 5] callers: only __ext4_fill_super at lines 5443 and 5451
- [Phase 6] local super.c already has both & 7 checks; bitmap CRC still truncated
- [Phase 7] ext4, important, actively merged in 7.3
- [Phase 8] failure mode: unprotected trailing bitmap bits / crafted- image integrity; mount-time -EINVAL after fix
- [Phase 8] stable-kernel-rules.rst: oops/hang/corruption/security/“oh, that’s not good”; 100-line cap
- UNVERIFIED: stable@ lore search (403); live e2fsprogs source not in tree
The patch is a 6-line, maintainer-reviewed mount check that enforces an invariant the bitmap checksum code has assumed since 2012. It is in scope for this 7.3-rc4 tree and meets stable criteria.
**YES**
fs/ext4/super.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
fs/ext4/super.c +6 -4
@@ -4431,8 +4431,9 @@ static int ext4_handle_clustersize(struct super_block *sb) sbi->s_cluster_bits =0 ; } sbi->s_clusters_per_group =le32_to_cpu (es->s_clusters_per_group); -if (sbi->s_clusters_per_group > sb->s_blocksize *8 ) { -ext4_msg (sb,KERN_ERR ,"#clusters per group too big: %lu" , +if (sbi->s_clusters_per_group > sb->s_blocksize *8 || + sbi->s_clusters_per_group &7 ) { +ext4_msg (sb,KERN_ERR ,"invalid #clusters per group: %lu" , sbi->s_clusters_per_group);return -EINVAL ; }
@@ -5230,8 +5231,9 @@ static int ext4_block_group_meta_init(struct super_block *sb, int silent)return -EINVAL ; }if (sbi->s_inodes_per_group < sbi->s_inodes_per_block || - sbi->s_inodes_per_group > sb->s_blocksize *8 ) { -ext4_msg (sb,KERN_ERR ,"invalid inodes per group: %lu\n" , + sbi->s_inodes_per_group > sb->s_blocksize *8 || + sbi->s_inodes_per_group &7 ) { +ext4_msg (sb,KERN_ERR ,"invalid inodes per group: %lu" , sbi->s_inodes_per_group);return -EINVAL ; }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-6.12] ext4: reject mount if clusters/inodes per group are not 8-aligned
Sashiko has reviewed this patch and found no issues.
Quoted 18 lines
From: Baokun Li <[email protected]>
[ Upstream commit
d42dc7726a003262b73ffef2b744ff57a5488799]The block and inode bitmap checksums are computed over a whole number of
bytes: ext4_inode_bitmap_csum_*() useEXT4_INODES_PER_GROUP(sb)>> 3 and ext4_block_bitmap_csum_*() useEXT4_CLUSTERS_PER_GROUP(sb)/ 8 as the length passed toext4_chksum().If
s_inodes_per_groupors_clusters_per_groupis not a multiple of 8, the trailing fractional bits are excluded from the checksum. Those bits are then unprotected, and any incremental csum update path that assumes a byte-aligned bitmap can compute a checksum inconsistent with the full recalculation, corrupting the on-disk bitmap checksum.Reject such filesystems at mount time by adding the missing " & 7" alignment checks alongside the existing range validation.
Quoted 10 lines
Suggested-by Theodore Ts'o <[email protected]>Link https://patch.msgid.link/h3n7jlfhyna64dn5o76qxcspnhxdddcs6crpxftmy7gnl7b3sx@jenszfpcsnit open hereReported-by Sashiko <[email protected]>Signed-off-by Baokun Li <[email protected]>Reviewed-by Jan Kara <[email protected]>Reviewed-by Zhang Yi <[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 Bluetooth: btnxpuart: Fix use-after-free in probe error path
In reply to Sasha LevinFrom: Zhao Dongdong <[email protected]>
[ Upstream commit a2b3b4f00403a3a40c5627d1bf537c8fb166e221 ]
In nxp_serdev_probe(), if hci_register_dev() succeeds but ps_setup() fails, the error path jumps to 'probe_fail' which only calls hci_free_dev() and asserts the reset GPIO, but does NOT call hci_unregister_dev() first.
This leaves the HCI device registered in the system with its backing memory freed, leading to a use-after-free when userspace subsequently accesses the device (e.g. via hciconfig or bluetoothd).
Fix by adding a 'probe_fail_unregister' label that calls hci_unregister_dev() before falling through to the existing 'probe_fail' label. The original 'probe_fail' label is preserved for the case where hci_register_dev() itself fails (device was never registered, so no unregister is needed).
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.18.53** (pending-6.18). The probe-path UAF is present here, the fix is a 3-line unregister-before-free, and it should be backported.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[Bluetooth / btnxpuart] [Fix] [use-after-free in nxp_serdev_probe() when ps_setup() fails after a successful hci_register_dev()]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected for this review pipeline)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** Neeraj Sanjay Kale <[email protected]> (listed MAINTAINERS co-maintainer of NXP Bluetooth)
- **Acked-by:** none
- **Link:** none
- **Cc: stable:** none (expected; not a negative)
- **Signed-off-by:** Zhao Dongdong <[email protected]> (author); Luiz Augusto von Dentz <[email protected]> (Bluetooth maintainer)
- Pipeline SOBs (Sasha Levin / Upstream commit markers): ignored per instructions
Notable: maintainer review + Bluetooth maintainer SOB. No syzbot tag.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** After hci_register_dev() succeeds, ps_setup() failure jumps to probe_fail, which asserts reset and calls hci_free_dev() without hci_unregister_dev().
- **Symptom:** HCI device stays registered after its driver backing is torn down; userspace (hciconfig, bluetoothd) can then UAF.
- **Version info:** none in the message.
- **Root cause (author):** missing unregister on the post-register error path; probe_fail is correct only when registration itself failed.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not a hidden fix.** Subject and body explicitly describe a UAF. The code change matches that description.
---
## PHASE 2: DIFF ANALYSIS - LINE BY LINE
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** drivers/bluetooth/btnxpuart.c only
- **Scope:** +3 / −1 (one function)
- **Function:** nxp_serdev_probe()
- **Classification:** single-file surgical error-path fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record (verified against this tree at nxp_serdev_probe()):
**Before** (local drivers/bluetooth/btnxpuart.c lines 1919–1935):
```
if (hci_register_dev(hdev) < 0)
goto probe_fail;
if (ps_setup(hdev))
goto probe_fail; // registered, but treated as never-
registered
...
probe_fail:
reset_control_assert(nxpdev->pdn);
hci_free_dev(hdev);
return -ENODEV;
```**After:**
- ps_setup() failure → probe_fail_unregister → hci_unregister_dev(hdev) then fall through
- hci_register_dev() failure still goes to probe_fail only (never registered)
**Path affected:** probe error path only, after successful HCI registration.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** use-after-free / lifetime bug (error-path cleanup)
- **Mechanism:** hci_register_dev() (net/bluetooth/hci_core.c) does device_add(), hci_dev_hold(), and queue_work(..., &hdev->power_on). hci_free_dev() is only put_device(). Skipping unregister leaves hdev on hci_dev_list and in sysfs.
- **Worse than the message states (verified):** nxpdev is devm_kzalloc() at probe start. Probe returning -ENODEV releases managed resources, so nxpdev is freed while a still-registered hdev has hci_set_drvdata(hdev, nxpdev). HCI callbacks (btnxpuart_open, nxp_setup, power-on work) then dereference freed driver state.
- **Fix:** same unregister-then-free order as nxp_serdev_remove() (local lines 1959–1962).
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: pairs register with unregister; preserves the never-registered path.
- Minimal: 3 insertions, 1 deletion, no API/struct changes.
- Regression risk: low. hci_unregister_dev() is the designed teardown (cancels power_on via disable_work_sync). Probe failure means remove() is not called, so no double-unregister.
- Does not call ps_cleanup() on this path: correct, because ps_setup()’s only error return is devm_gpiod_get_optional() failure **before** INIT_WORK / timer_setup / mutex_init (local lines 511–517 vs 557–561). Calling ps_cleanup() there would operate on uninitialized state.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Buggy if (ps_setup(hdev)) goto probe_fail; introduced by **c135a5bc34a89a75a739d07964ff3d1c4fa1b154** (“Bluetooth: btnxpuart:
Add GPIO support to power save feature”, Neeraj Sanjay Kale, committer date 2024-11-14).
- That commit changed ps_setup() from void to int and added the probe_fail label that frees without unregister.
- git merge-base --is-ancestor c135a5bc34a89a HEAD → **yes**. Makefile at that commit is **6.12.0-rc6**; this 6.18.53 tree contains the bug.
- Driver itself: 689ca16e523278 (2023-04-23). Original probe had ps_setup() as void after register, so it could not fail after register until c135a5bc34a89.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The real introducer is c135a5bc34a89, not the original driver add. A later duplicate patch (Myeonghun Pak) incorrectly tagged Fixes: 689ca16e5232. Absence of Fixes here does not change the local-tree fact: the buggy goto is in this checkout.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Recent btnxpuart.c work is firmware dump, OOB, IRQ, baudrate, coredump — none of it unregisters on the ps_setup() fail path.
- git log --grep="use-after-free" -- drivers/bluetooth/btnxpuart.c → empty.
- probe_fail_unregister is **not** in this tree.
- Standalone; not “patch X/Y”. v2 changelog was SubjectPrefix; v3 was gitlint. Same 3-line diff.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: git log --author="Zhao Dongdong" -- drivers/bluetooth/ in this tree has no btnxpuart commits (author is not the NXP driver maintainer). Weight comes from **Reviewed-by: Neeraj** (NXP maintainer) and **SOB:
Luiz** (Bluetooth maintainer). Neeraj is the author of the introducing commit and of most later btnxpuart work.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: No new helpers. Uses existing hci_unregister_dev(). Local probe matches the hunk (same ps_setup / hci_devcd_register / probe_fail sequence). **Can apply standalone.**
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c <msgid> for v1 msgid [email protected] → no matching **commit** in this tree (expected: candidate not merged here).
- Lore.kernel.org fetches returned **403**.
- Discussion reconstructed from ratatoskr / spinics / lkml.iu.edu:
- v1/v2/v3 by Zhao Dongdong, mid-May 2026, linux-bluetooth
- v3: https://ratatoskr.run/linux-bluetooth/2026/05/9706550
- Luiz replied 2026-05-15; Neeraj reviewed 2026-06-03
- Revisions were cosmetic (prefix, gitlint), not logic changes
- **UNVERIFIED:** exact text of Luiz’s review comment (patchwork presented a bot wall; lore 403)
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: Recipients/maintainers from public threads: Luiz von Dentz, Marcel Holtmann, Amitkumar Karwar, Neeraj Kale, linux-bluetooth. Committed form has Neeraj Reviewed-by and Luiz SOB. No NAK found.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla link. Independent second patch (Myeonghun Pak / Ijae Kim, 2026-06-26, “unregister HCI device on probe failure”) describes the same bug. Neeraj told them Zhao’s patch was already approved and waiting on Luiz. Two independent submissions = real issue, not one-off theory.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone. Duplicate later patch is the same 3-line change with a different label name (unregister_dev vs probe_fail_unregister). No series dependency.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: WebFetch of lore.kernel.org/stable returned 403. **UNVERIFIED:** whether stable@ already discussed this specific commit. No evidence it was rejected for stable.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: nxp_serdev_probe() only. Calls added: hci_unregister_dev().
**Step 5.2: TRACE CALLERS**
Record: .probe = nxp_serdev_probe in the serdev driver (local ~line 2030). Invoked on UART child-device bind (compatible = "nxp,88w8987-bt" / "nxp,88w8997-bt"), not a syscall. Userspace reaches the **aftermath** via HCI (bluetoothd, hciconfig) once the device is left registered.
**Step 5.3: TRACE CALLEES**
Record:
- hci_register_dev(): device_add, list insert, hci_dev_hold, queue_work(power_on)
- hci_unregister_dev(): HCI_UNREGISTER, list_del, disable_work_sync(power_on), close, mgmt removal
- hci_free_dev(): put_device
- ps_setup(): optional GPIO; only hard-fail is IS_ERR(devm_gpiod_get_optional(...))
**Step 5.4: FOLLOW THE CALL CHAIN**
Record:
1. Serdev probe for NXP UART BT
2. hci_register_dev → hci0 visible; power_on queued
3. ps_setup fails
4. Probe returns error without unregister → devm frees nxpdev
5. HCI core / userspace / leftover power_on uses hdev callbacks → UAF
Reachable on any board using this driver with device-wakeup-gpios that fails to resolve (property present, GPIO unavailable / -EPROBE_DEFER converted to -ENODEV). Binding:Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml documents that GPIO. In-tree users of the compatible include i.MX 91/93/95 EVKs, i.MX8MP, TI Verdin AM62, Kobo Clara 2E.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Other Bluetooth UART drivers typically only hci_free_dev() when **register** fails. This driver’s bug is specifically “work after register that can fail.” Remove path already had the correct unregister/free order.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** pending-6.18, make kernelversion = **6.18.53**. Exact snippet at lines 1924–1935 of drivers/bluetooth/btnxpuart.c. Introduced in c135a5bc34a89 (~6.13 era); present here. Candidate fix **not** an ancestor of HEAD.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** Surrounding code matches the supplied hunk (hci_register_dev / ps_setup / hci_devcd_register / probe_fail + reset_control_assert). Line numbers differ slightly from the candidate blob; context is the same. No conflicting refactor.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No unregister-on-ps_setup-fail fix. Other btnxpuart stable- style fixes in this tree (OOB firmware read, FW dump header length) are unrelated.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record:
- **Subsystem:** Bluetooth device driver (drivers/bluetooth/btnxpuart.c)
- **Criticality:** **IMPORTANT** (not core mm/VFS). Real shipping hardware (NXP 88W8987/8997 on i.MX and TI K3). CONFIG_BT_NXPUART depends on BT_HCIUART and SERIAL_DEV_BUS.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained (many 2025 btnxpuart commits in this tree). Bug is in a 2024 error-path addition that has sat unfixed.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / config-specific:** CONFIG_BT_NXPUART users with NXP UART Bluetooth, especially DTs that include device-wakeup- gpios.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Trigger: ps_setup() returns non-zero after successful hci_register_dev().
- In this tree that is devm_gpiod_get_optional("device-wakeup") returning IS_ERR (GPIO specified but cannot be acquired). IRQ setup failures are ignored, not a probe fail.
- Not every boot. GPIO probe deferral / missing controller / bad DT are realistic.
- Unprivileged userspace does not need to *cause* the probe fail; once it happens, bluetoothd/hciconfig can trip the UAF. Concurrent power_on work can trip it without userspace.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- **Failure mode:** UAF of btnxpuart_dev (devm-freed) and/or HCI object lifetime violation while hciX remains registered; possible oops; power_on work not cancelled.
- **Severity: HIGH** (UAF / crash). Not a panic on every boot, but classically stable-worthy.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** HIGH for affected hardware — prevents UAF/oops on a real probe failure.
- **Risk:** VERY LOW — 3 lines, existing API, same order as remove(), error path only.
- **Ratio:** strongly favors backport.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Confirmed UAF / lifetime bug in this 6.18.53 tree
- Small, obviously correct unregister-before-free
- Matches nxp_serdev_remove()
- Cancels power_on work that hci_register_dev() queued
- NXP driver maintainer Reviewed-by; Bluetooth maintainer SOB
- Independent duplicate patch
- Clean apply; no prerequisites
- Real in-tree hardware (i.MX, TI K3)
**AGAINST:**
- Driver-specific, not core kernel
- Trigger is an error path (ps_setup GPIO get fail), not every probe
- No syzbot/CVE/Reported-by
- No Fixes tag (not a reason to reject)
**UNRESOLVED (do not drive the verdict):**
- Exact Luiz review comment text
- Mainline SHA of the candidate (not in this tree)
- stable@ discussion (lore 403)
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — pairing is the documented HCI lifetime; reviewed by driver + Bluetooth maintainers.
2. Fixes a real bug that affects users? **PASS** — registered HCI left after probe fail; UAF via callbacks/userspace.
3. Important issue? **PASS** — UAF / crash, HIGH (not deadlock/corruption, still stable-class).
4. Small and contained? **PASS** — 3 lines, one function.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — buggy code present; hunk matches.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not ID/quirk/DT/build/docs. It is a **normal UAF bugfix**, which is in-scope without an exception.
**Step 9.4: MAKE YOUR DECISION**
This 6.18.53 tree has the buggy ps_setup() → probe_fail path from c135a5bc34a89. The fix is the missing hci_unregister_dev() before hci_free_dev(). That is required HCI lifetime management, matches remove(), and prevents UAF of devm-managed driver state while hciX stays registered. Scope and risk are appropriate for stable.
---
### What the commit solves for this tree
On NXP UART Bluetooth probe, if HCI registration succeeds and then power-save GPIO setup fails, 6.18.53 currently frees the HCI object (and, via devm, the driver private data) without unregistering. Userspace and the queued power_on work can then use freed memory. The backport adds one unregister on that path only.
### Stable rules / risk vs benefit
Meets all six criteria. Benefit is preventing a UAF on a shipping driver; risk is a 3-line error-path change that uses the existing unregister helper.
### Concerns
None that block backport. Trigger is uncommon (GPIO get failure), but the failure mode is severe enough. No extra commits needed.
---
### Verification
- **[Phase 1]** Parsed subject/tags/body: UAF fix; Reviewed-by Neeraj; SOB Luiz; no Fixes/syzbot/Cc-stable
- **[Phase 2]** Diff: +3/−1 in nxp_serdev_probe(); ps_setup fail now unregisters before free
- **[Phase 2]** Read local probe/remove/ps_setup: bug and GPIO-only fail return confirmed
- **[Phase 2]** Read hci_register_dev/hci_unregister_dev/hci_free_dev: register queues power_on and holds refs; free is put_device only
- **[Phase 3]** git describe HEAD / make kernelversion:
p-6.18-1-g03b85e06ca9bf, **6.18.53**
- **[Phase 3]** git blame -L 1915,1940: buggy goto from c135a5bc34a89
- **[Phase 3]** git merge-base --is-ancestor c135a5bc34a89a HEAD: yes
- **[Phase 3]** git show c135a5bc34a89a: introduced int ps_setup + goto probe_fail without unregister
- **[Phase 3]** Original driver 689ca16e523278: ps_setup could not fail after register
- **[Phase 3]** git log --grep="use-after-free" on this file: empty; fix not in tree
- **[Phase 4]** b4 dig on v1 msgid: no commit in this tree
- **[Phase 4]** lore.kernel.org: 403 — UNVERIFIED full thread body
- **[Phase 4]** ratatoskr v3 + lkml.iu.edu: v1–v3 standalone; Neeraj approved; duplicate June 2026 patch
- **[Phase 5]** Callers: serdev .probe; nxpdev is devm_kzalloc
- **[Phase 5]** DTS: nxp,88w8987-bt on i.MX and TI boards; binding documents device-wakeup-gpios
- **[Phase 6]** Exact buggy snippet present; probe_fail_unregister absent
- **[Phase 8]** Failure: UAF/oops on probe error after register; severity HIGH
- **UNVERIFIED:** Luiz comment text; candidate mainline SHA; stable@ archive
The fix is small, surgical, already in the local probe shape, and addresses a real UAF.
**YES**
drivers/bluetooth/btnxpuart.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/bluetooth/btnxpuart.c +3 -1
@@ -1924,13 +1924,15 @@ static int nxp_serdev_probe(struct serdev_device *serdev) }if (ps_setup (hdev)) - goto probe_fail; + goto probe_fail_unregister;hci_devcd_register (hdev, nxp_coredump, nxp_coredump_hdr, nxp_coredump_notify);return 0 ; +probe_fail_unregister: +hci_unregister_dev (hdev); probe_fail:reset_control_assert (nxpdev->pdn);hci_free_dev (hdev);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 smb: server: Make sure that passkey is not leaked on the heap in user_config.c
In reply to Sasha LevinFrom: Thomas Huth <[email protected]>
[ Upstream commit 2c5a176882695f73b52482df03b0017b006ef2d1 ]
Use kfree_sensitive() to free the user->passkey (and the struct ksmbd_login_response in ksmbd_login_user() that contains the same information) to avoid that this information could leak somewhere else via the heap.
---
LLM Generated explanations, may be completely bogus:
I have enough to decide: the NTLM passkey wipe is present in this 6.12 tree, the helpers already exist, and the change is a three-line secret- clearing fix. Fetching the series cover letter wrapped up the remaining mailing-list context.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[smb: server:] [Make sure] [passkey is not leaked on the heap in user_config.c]**
- Subsystem: smb: server: (ksmbd in-kernel SMB3 server)
- Action verb: “Make sure” — safety/correctness language, not a feature
- Claimed intent: wipe user->passkey (and the IPC login response that holds the same hash) before returning the memory to the heap
**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 on the commit itself
- **Acked-by:** none
- **Link:** none in the commit message
- **Cc: stable:** none (expected; not a negative signal)
- **Signed-off-by:** Thomas Huth \<[email protected]\> (author); Namjae Jeon \<[email protected]\> (ksmbd maintainer). Ignore any Sasha Levin SOB from candidate preparation.
Notable pattern: no syzbot/CVE/reporter tags. This came from a maintainer-applied hardening series, not a crash report.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** user->passkey and struct ksmbd_login_response (which contains hash[]) are freed with ordinary kfree()/kvfree(), so the NTLM password hash remains in the slab until the object is reused.
- **Symptom/failure mode:** heap leftover of authentication secret material; a later kmalloc of the same cache can return pages still holding the hash (classic kfree-vs-kfree_sensitive info leak).
- **Version information:** none in the message.
- **Root cause (author):** passkey-bearing objects were not cleared before free.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. The message is explicit about a secret leak. It is a security hygiene fix (wipe-before-free), not a crash/UAF. Still a real bug class the kernel already treats as such via kfree_sensitive().
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: fs/smb/server/mgmt/user_config.c only
- Scope: **3 substitutions, ~3 lines**, single-file surgical
- Functions: ksmbd_login_user(), ksmbd_alloc_user() error path, ksmbd_free_user()
- Surrounding mainline context in the candidate (hash_sz bounds check, kmalloc_obj) is **not** part of this commit’s semantic change; it is later-tree context.
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
1. ksmbd_login_user() out: path: kvfree(resp) → kvfree_sensitive(resp, sizeof(*resp)). This is the **normal** login path (and the login-failure path). resp is the IPC login response from ksmbd.mountd and contains hash[].
2. ksmbd_alloc_user() err_free:: kfree(user->passkey) → kfree_sensitive(user->passkey). **Error** path after the hash was copied into user->passkey.
3. ksmbd_free_user(): same kfree → kfree_sensitive for user->passkey. **Normal** session teardown / reauth mismatch path.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** security / sensitive-data leak (heap residual), not UAF/race/crash
- **Mechanism:** resp->hash is the NT hash (KSMBD_REQ_MAX_HASH_SZ is 18; auth uses CIFS_ENCPWD_SIZE of 16 as HMAC-MD5 key in calc_ntlmv2_hash()). After kfree/kvfree, that hash stays in the slab. kfree_sensitive() does memzero_explicit() over ksize() then kfree(). kvfree_sensitive() does memzero_explicit(addr, len) then kvfree().
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: drop-in replacement; kfree_sensitive(NULL) is a documented no-op (needed on err_free when passkey alloc failed); kvfree_sensitive skips ZERO_OR_NULL_PTR.
- Minimal: three call-site changes, no API/structure change.
- Regression risk: **very low**. Same free, plus a small memzero_explicit. passkey is ~16 bytes; sizeof(*resp) is a fixed login-response struct. No lock/order/API change.
- Incomplete vs the rest of ksmbd (auth.c still kvfree(resp) on the SPNEGO path) — that is a **sibling** series patch, not a dependency of this one.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- kvfree(resp): introduced as cifsd code in 79f6b11a104f3a (“cifsd:
remove wrappers of kvmalloc/kvfree”, 2021) on top of e2f34481b24db2 (“cifsd: add server-side procedures for SMB3”, 2021-05-10).
- kfree(user->passkey) in ksmbd_free_user(): 822bc8ea514ecd (“cifsd: use kfree to free memory allocated by kmalloc or kzalloc”, 2021) — switched from kvfree wrappers to kfree.
- kfree(user->passkey) on err_free: a77e0e02af1c2 (“ksmbd: add support for supplementary groups”, 2024-10-11).
- The leak has been in the SMB server **since cifsd/ksmbd was merged (~v5.15 era)**. Present in this 6.12 tree.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable. The buggy free sites predate this tree’s branch point and are in HEAD.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record (this tree, -- fs/smb/server/mgmt/user_config.c):
- c9f2872e91b9f — leak of ksmbd_ipc_login_request_ext() buffer (already in this tree; candidate context includes kvfree(resp_ext)).
- 7dd0c858e1909 — ipc_validate_msg size checks
- a77e0e02af1c2 — supplementary groups
- No existing kfree_sensitive conversion in this file.
- Standalone relative to later hash_sz/kmalloc_obj work (those strings are **absent** here).
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Thomas Huth has **no** other commits under fs/smb/ in this checkout (series is newer than 6.12). Namjae Jeon is the ksmbd maintainer and signed the patch off. Cover letter: 5-patch series “Clear sensitive data before freeing it”; this is **v2 2/5**.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record:
- Needs kfree_sensitive() / kvfree_sensitive() — both exist in this tree (include/linux/slab.h, implemented in mm/slab_common.c / mm/util.c).
- Does **not** need kmalloc_obj or the hash_sz guard (those are only nearby mainline context).
- Other patches in the series (auth.c, user_session.c, connection.c, smb2pdu.c) are independent per-file wipes. This file’s change applies **standalone**.
- user_config.c already includes <linux/slab.h>.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c <sha>: **not run** — the candidate SHA is not in this checkout (evaluating a candidate, not an in-tree commit).
- Found via search: **[PATCH v2 2/5]** Message-ID [email protected]
- Cover:
https://patchew.org/linux/[email protected]/
- Openwall: https://lists.openwall.net/linux-kernel/2026/08/11/1820
- v2 vs v1: cover letter says v2 fixed kvfree_sensitive **size in patch 1 (auth.c)**, added a connection.c hunk, and added the smb2pdu.c patch. **This user_config.c patch was not the one that needed a size- calculation fix.**
- Namjae Jeon: “Applied them to #ksmbd-for-next-next.” No NAK found.
- Author framed it as “good security practice”; spots found with AI, patches written by hand; asked for careful review. Maintainer still applied the series.
- No reviewer Cc: stable found.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: To/Cc from the v2 mail: Namjae Jeon (ksmbd maintainer), Steve French (CIFS/SMB maintainer), linux-kernel, Sergey Senozhatsky, Tom Talpey. Maintainer applied it. No separate Reviewed-by on this patch.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot, bugzilla, or user crash. This is proactive secret- wipe, not a reported oops. Severity from the author: heap leftover of passkey/hash.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Series of 5 independent kfree_sensitive/memzero_explicit patches:
1. auth.c stack/heap
2. **user_config.c passkey (this one)**
3. user_session.c
4. connection.c
5. smb2pdu.c Preauth_HashValue
This patch does not depend on 1/3/4/5 applying first.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No stable-list hit for this passkey wipe (search did not turn up a prior stable request or a rejection). UNVERIFIED that a later stable thread exists beyond what search returned. lore.kernel.org fetches returned 403 in this environment; discussion was recovered from patchew/openwall.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: ksmbd_login_user, ksmbd_alloc_user, ksmbd_free_user
**Step 5.2: TRACE CALLERS**
Record (this tree):
- ksmbd_login_user() ← session_user() in fs/smb/server/smb2pdu.c ← SMB2 SESSION_SETUP / ntlm_authenticate(). **Network-reachable** on every NTLM login.
- ksmbd_alloc_user() ← ksmbd_login_user() and ksmbd_krb5_authenticate() in auth.c (CONFIG_SMB_SERVER_KERBEROS5).
- ksmbd_free_user() ← session teardown in user_session.c; reauth mismatch / anonymous reuse in smb2pdu.c; kerberos reauth in auth.c.
**Step 5.3: TRACE CALLEES**
Record:
- ksmbd_ipc_login_request() → netlink to ksmbd.mountd; response allocated with kvzalloc(sz) in handle_response() (transport_ipc.c:294), so kvfree/kvfree_sensitive is the right family.
- user->passkey = kmalloc(resp->hash_sz, ...) then memcpy from resp->hash — kfree_sensitive is the right family.
- calc_ntlmv2_hash() uses user_passkey() as HMAC-MD5 key (CIFS_ENCPWD_SIZE). Confirmed: this is the NT hash, not a username.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Unprivileged SMB client sends SESSION_SETUP → kernel looks up user via IPC → hash lives in resp then user->passkey → on logout/free, hash is currently left in the slab. Path is **reachable from the network** whenever ksmbd is enabled and serving NTLM users. Not a syscall-from-unprivileged-local-only issue; it is a **server-side credential residual**.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: The SMB **client** in this same tree already uses kfree_sensitive widely for passwords/auth_key (fs/smb/client/smb2pdu.c, sess.c, fs_context.c, misc.c, …). ksmbd server side in this tree still uses plain kfree/kvfree for passkey (only auth.c has one kfree_sensitive(ctx_arc4)). Same bug class, server lagging the client.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** Local tree is **6.12.111** (pending-6.12, p-6.12-3-gc504cf0baa3d8).
```31:31:fs/smb/server/mgmt/user_config.c
kvfree(resp);
``````74:74:fs/smb/server/mgmt/user_config.c
kfree(user->passkey);
``````84:84:fs/smb/server/mgmt/user_config.c
kfree(user->passkey);
```No kvfree_sensitive / kfree_sensitive in this file today. Bug introduced with cifsd (2021), long before 6.12.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Minor context, not semantic.** This tree has kmalloc(sizeof(struct ksmbd_user), ...) not kmalloc_obj, and **no** hash_sz > sizeof(resp->hash) guard. The three substitution sites exist verbatim (kvfree(resp); ×1, kfree(user->passkey); ×2). A 3-line backport applies; a raw mainline patch with 41-line context around ksmbd_alloc_user would conflict. kvfree(resp_ext) from c9f2872e91b9f is already here, matching the candidate’s ksmbd_login_user shape.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No passkey wipe already in this file. Client-side kfree_sensitive does not cover ksmbd server objects.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **ksmbd (CONFIG_SMB_SERVER)** under fs/smb/server/. **IMPORTANT** (not core mm/VFS): optional in-kernel SMB3 server used on NAS/embedded; default n. Network-facing auth path.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained (many recent ksmbd fixes on this branch:
OOB, ACL, session, credit). Mature enough that the passkey free path has been stable since 2021.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **config-specific / driver-specific:** systems with CONFIG_SMB_SERVER (ksmbd) and live SMB sessions. Distros that ship ksmbd for NAS (openSUSE, some embedded, ksmbd-tools users).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Trigger: **every successful NTLM login** (ksmbd_login_user always frees resp containing the hash) and **every ksmbd_free_user** (session destroy / failed reauth).
- Common on any ksmbd server with password auth.
- Local unprivileged userspace does not need to call a special syscall; a remote SMB client causes the kernel to hold then free the hash. Recovering the leftover bytes still needs another heap-read primitive or slab reuse that exposes old contents — that is the usual kfree_sensitive threat model.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Failure mode:** NT hash residual in kmalloc/kvmalloc heap. **Severity: HIGH** (credential/info leak; pass-the-hash material). Not a panic. Not theoretical-only in kind: this is why kfree_sensitive exists, and the CIFS client already wipes the same class of secrets.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** HIGH for ksmbd users — wipes NTLM hashes that currently survive free on a hot auth path.
- **Risk:** VERY LOW — 3 lines, existing helpers, NULL-safe, no behavior change except zeroing freed secret bytes.
- **Ratio:** strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real leftover NT hash (resp->hash / user->passkey) on heap after login IPC and session free
- Reachable from SMB SESSION_SETUP on deployed ksmbd
- 3-line, obviously correct, uses APIs that exist in 6.12
- Buggy frees present in this tree since 2021
- Maintainer (Namjae Jeon) applied the series
- Same pattern already used by fs/smb/client/ in this tree
- kfree_sensitive(NULL) safe on the alloc-failure path
**AGAINST:**
- Hardening / defense-in-depth, no CVE/syzbot/user report
- Part of a 5-patch series (others also wipe secrets; this file does not need them)
- ksmbd is optional (default n)
- Raw mainline hunk context includes later kmalloc_obj / hash_sz check (needs a tiny backport, not the later features)
**UNRESOLVED:**
- Could not run b4 dig against a local SHA (candidate not in this git object store)
- lore.kernel.org HTTP 403; discussion recovered from patchew/openwall
- No evidence this was previously rejected for stable
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — drop-in sensitive-free; maintainer applied v2.
2. Fixes a real bug that affects users? **PASS** — NTLM hash left in slab after ksmbd login/logout.
3. Important issue? **PASS** — security info leak of auth material (HIGH, not a crash).
4. Small and contained? **PASS** — 3 lines, one file.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — sites and helpers exist; context tweak only (no kmalloc_obj required).
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. Qualifies as a **small security fix** (secret wipe), which stable regularly takes.
**Step 9.4: MAKE YOUR DECISION**
This should be backported to **this** 6.12 tree. The bug is here, the helpers are here, and the change is a surgical wipe of NTLM passkeys that ksmbd currently leaves in the heap after every login IPC and session free. Risk is negligible; benefit is wiping high-value credential material on a network-facing path.
### What the commit solves for this tree
On 6.12.111 ksmbd still does kvfree(resp) on the login response (which includes hash[KSMBD_REQ_MAX_HASH_SZ]) and kfree(user->passkey) after copying that hash. Those bytes are the NT hash used as the NTLMv2 HMAC key. Switching to kvfree_sensitive / kfree_sensitive zeros them before the slab can reuse the object. That matches what the SMB client in this same tree already does for passwords.
### Risk vs benefit
Benefit is wiping secrets on a common ksmbd auth path. Risk is a few extra memzero_explicit bytes on free. No locking, no API, no control- flow change.
### Concerns
A verbatim mainline apply may need a 3-line backport because this tree lacks kmalloc_obj and the later hash_sz cap; those are **not** prerequisites. Sibling series patches (auth.c SPNEGO kvfree(resp), session/connection/preauth) are independent and do not block this file’s fix.
Verification:
- [Phase 1] Parsed subject/body/tags: no Fixes/Reported-by/Cc:stable; SOBs Thomas Huth + Namjae Jeon
- [Phase 2] Diff: 3 substitutions in user_config.c; kvfree(resp) and two kfree(user->passkey)
- [Phase 2] Confirmed KSMBD_REQ_MAX_HASH_SZ is 18 and calc_ntlmv2_hash() uses user_passkey() as HMAC-MD5 key (CIFS_ENCPWD_SIZE 16)
- [Phase 3] git blame: kvfree(resp) from 2021 cifsd (79f6b11a104f3a / e2f34481b24db2); passkey kfree from 822bc8ea514ecd / a77e0e02af1c2
- [Phase 3] git merge-base --is-ancestor of those SHAs vs HEAD: all present (exit 0)
- [Phase 3] git log --author="Thomas Huth" -- fs/smb/: empty in this tree (series is newer)
- [Phase 4] Patchew/openwall: v2 2/5 of “Clear sensitive data before freeing it”; Namjae applied to ksmbd-for-next-next; no NAK
- [Phase 4] lore.kernel.org WebFetch: 403; b4 dig: no local candidate SHA — discussion recovered from patchew/openwall
- [Phase 5] Callers: smb2pdu.c SESSION_SETUP session_user()/ntlm_authenticate(), auth.c krb5 path, user_session.c teardown
- [Phase 5] handle_response() uses kvzalloc — kvfree_sensitive is the correct free family
- [Phase 6] git describe HEAD / make kernelversion: **6.12.111** (pending-6.12); buggy kfree/kvfree still in file; kfree_sensitive/kvfree_sensitive declared in include/linux/slab.h
- [Phase 6] Local file has no kmalloc_obj / hash_sz cap; three target call sites exist verbatim
- [Phase 8] Failure mode: NT-hash residual in heap after login/free; severity HIGH; regression risk very low
- UNVERIFIED: full lore mailbox / b4 patch-id match; whether a later CVE was assigned
**YES**
fs/smb/server/mgmt/user_config.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/smb/server/mgmt/user_config.c +3 -3
@@ -28,7 +28,7 @@ struct ksmbd_user *ksmbd_login_user(const char *account) user =ksmbd_alloc_user (resp, resp_ext);kvfree (resp_ext); out: -kvfree (resp); +kvfree_sensitive (resp,sizeof (*resp));return user; }
@@ -82,7 +82,7 @@ struct ksmbd_user *ksmbd_alloc_user(struct ksmbd_login_response *resp, err_free:kfree (user->name); -kfree (user->passkey); +kfree_sensitive (user->passkey);kfree (user);return NULL ; }
@@ -92,7 +92,7 @@ void ksmbd_free_user(struct ksmbd_user *user)ksmbd_ipc_logout_request (user->name, user->flags);kfree (user->sgid);kfree (user->name); -kfree (user->passkey); +kfree_sensitive (user->passkey);kfree (user); }
Signature · 1 line
2.53.0