Skip to contentSkip to conversation

net: dsa: mt7530: check CORE_PLL_GROUP4 access in mt7531_setup()

PATCH New Sasha Levin 9 participants 624 messages Oct 19 – Oct 28 Page 9 of 15

Subsystems (71)
lore
Share & tools
lore
author maintainer
#344 lore raw

PATCH 1/1 drm/sysfb: simpledrm: Validate mmap size against framebuffer size

In reply to Sasha Levin

From: Thomas Zimmermann <[email protected]>

[ Upstream commit 127d52f9c64b1d9aab6226c4a1f38c37fb7254dc ]

The size of the mmap'ed framebuffer could be smaller than the minimum required framebuffer size. Validate the resource size against the framebuffer size.

Buggy firmware that triggers this check should be fixed up with a quirk on a case-by-case base.

v3:
- fix size checks (Sashiko)
- improve error message for alignment check (Thierry)
- do not store aligned size value

---

LLM Generated explanations, may be completely bogus:

I have enough to decide: this is a 6.18.53 tree, the OOB check is missing there, and the patch is a small probe-time bounds fix.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**

Record: **[drm/sysfb / simpledrm] [Validate] [reject probe when firmware framebuffer size exceeds the mapped memory resource]**

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**

Record:
- **Fixes:** none (expected for this review)
- **Cc: stable:** none (expected; sibling patches in the same series *did* have it)
- **Suggested-by:** Sashiko <[email protected]> — static-analysis bot found the missing bounds check
- **Reviewed-by:** Thierry Reding, Maxime Ripard, Javier Martinez Canillas (DRM maintainers)
- **Link:** https://patch.msgid.link/[email protected] — v3 patch 5/7 of “Various improvements”
- **Signed-off-by:** Thomas Zimmermann (author/subsystem maintainer)
- **Reported-by / Tested-by:** none
- Ignored pipeline tags: [Upstream commit 127d52f9c64b…], `Signed-off-
by: Sasha Levin`

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**

Record:
- **Bug:** firmware/DT can advertise width/height/stride whose product is larger than the mmap’d IORESOURCE_MEM / reserved-memory region.
- **Symptom:** driver maps only resource_size(mem) but later draws height * stride bytes → out-of-bounds access of the mapping.
- **Author note:** firmware that trips this should get a quirk, not a silent OOB.
- **v3:** Sashiko fixed inverted size checks; Thierry improved the ALIGN error text; aligned size is no longer stored.
- **Versions:** none stated. Driver exists since 2021 (11e8f5fd223b, “drm: Add simpledrm driver”).

**Step 1.4: DETECT HIDDEN BUG FIXES**

Record: Not disguised. It is an explicit bounds check. Cover letter groups it with “improve validation of values provided by the device firmware.” Sashiko’s v1/v2 review called the missing/inverted check a **High** OOB kernel write.

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES**

Record:
- **File:** drivers/gpu/drm/sysfb/simpledrm.c — **+24 / −0**
- **Function:** simpledrm_device_create()
- **Scope:** single-file surgical probe-path validation
- Adds #include <linux/overflow.h> and local u64 size

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**

Record:
1. After stride is known: compute size = height * stride with check_mul_overflow; fail -EINVAL on overflow. Then ALIGN(size, PAGE_SIZE) < PAGE_SIZE catches wrap of page-align.
2. System-memory path (devm_memremap): if size > resource_size(mem), fail before mapping.
3. I/O-memory path (devm_ioremap_wc): same check after the optional devm_request_mem_region fallback.

Before: map whatever firmware gave, then blit using fb_pitch/height.
After: refuse to probe if the logical FB does not fit in the mapping.

**Step 2.3: IDENTIFY THE BUG MECHANISM**

Record: **Memory safety / out-of-bounds + integer overflow**
- drm_sysfb_plane_helper_atomic_update() → drm_fb_blit() into sysfb->fb_addr using sysfb->fb_pitch
- drm_sysfb_plane_helper_atomic_disable() memset_io over height lines of fb_pitch
- Mapping length is resource_size(mem), not height*stride
- v2 had the comparison **inverted** (resource_size(mem) > size); v3 is size > resource_size(mem)

**Step 2.4: ASSESS THE FIX QUALITY**

Record: Obviously correct after v3. Minimal. Probe-time only. Regression
risk: probe fail (no simpledrm display) on undersized firmware resources that “worked” while writing past the map. Author documents quirks. No API/locking/struct changes.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**

Record: Mapping code from Thomas Zimmermann / Thierry Reding (2022–2023, originally drivers/gpu/drm/tiny/simpledrm.c). Bug is **missing validation since the driver was added** (11e8f5fd223bd, 2021-05-01), not a recent regression.

**Step 3.2: FOLLOW THE FIXES: TAG**

Record: No Fixes: tag. Buggy behavior is the original probe path. Not introduced after 6.18 branched.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**

Same v3 series (msgid 20260625094509.157581):

| Patch | Subject | In v6.18.53? |
|---|---|---|
| 1/7 | Improve framebuffer-size validation | **YES** (`8d65b8d1722d8`,
Cc: stable v5.14+) |
| 2/7 | Improve panel-size validation | **YES** (`54e32ad5e0c74`, Cc:
stable v6.4+) |
| 3/7 | Inline `simplefb_get_validated_int()` | NO — cleanup only, not
required |
| 4/7 | Improve stride validation | **YES** (`6892f0a2f6b59`, Cc: stable
v6.1+) |
| **5/7** | **This mmap-size check** | **NO** |
| 6–7/7 | Panel orientation | new feature, not this commit |

Record: Standalone vs this tree. Inline helper is not a prerequisite (diff vs v6.18.53 does not touch those call sites).

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**

Record: Thomas Zimmermann authored simpledrm (2021) and maintains drm/sysfb. Related: ofdrm overflow used this same check_mul_overflow pattern.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**

Record: Needs check_mul_overflow / overflow.h (present in 6.18). Needs simpledrm_device_create layout after stride validation (present at v6.18.53). No new helpers. **Can apply standalone to this tree.**

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**

Record:
- b4 dig -c 127d52f9… →
https://patch.msgid.link/[email protected]
- Series: v1 (3 patches, 2026-06-19) → v2 (6, 2026-06-22) → v3 (7, 2026-06-25). Committed version is v3.
- v1: Sashiko asked to compare firmware size vs mapped resource (High:
OOB writes on plane update).
- v2: check added **inverted**; Sashiko: rejects valid larger resources, allows size > resource_size.
- v3: comparison corrected; ALIGN value not stored.
- lore.kernel.org / spinics WebFetch: 403/500. Content recovered via b4 dig, WebSearch snippets, and the ratatoskr thread archive.
- No NAK. No reviewer Cc: stable on this specific patch (unlike 1/7, 2/7, 4/7).

**Step 4.2: CHECK WHO REVIEWED THE PATCH**

Record (b4 dig -w): dri-devel; Thierry, Maxime, Javier, airlied, simona, Maarten Lankhorst, Neil Armstrong; Sashiko. Subsystem maintainers were on To/Cc and Reviewed-by.

**Step 4.3: SEARCH FOR THE BUG REPORT**

Record: No syzbot/bugzilla/user crash. Finding is Sashiko review of this series. Mechanism verified in tree (blit/memset past resource_size).

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**

Record: Patches 6–7 (panel orientation) are features, not needed. Patches 1/2/4 already in 6.18.53. Patch 3 is unused cleanup.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**

Record: lore.kernel.org/stable search not available (HTTP 403). Unverified whether stable@ discussed this SHA. Sibling validation patches were already taken into 6.18.53 via Cc: stable.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: KEY FUNCTIONS**

Record: simpledrm_device_create() (modified). Callers of the mapped
buffer: drm_sysfb_plane_helper_atomic_update, atomic_disable, get_scanout_buffer.

**Step 5.2: TRACE CALLERS**

Record:
- simpledrm_probe() → simpledrm_device_create() — platform probe for simple-framebuffer / sysfb
- Plane helpers in drm_sysfb_modeset.c — atomic update/disable on every scanout

Not IRQ. Probe + modeset. Userspace DRM clients and in-kernel fbdev/client setup trigger blits.

**Step 5.3: TRACE CALLEES**

Record: check_mul_overflow, ALIGN, resource_size, devm_memremap / devm_ioremap_wc. No new locks or allocations beyond existing probe.

**Step 5.4: FOLLOW THE CALL CHAIN**

Record: Reachable whenever CONFIG_DRM_SIMPLEDRM binds. DT simple- framebuffer (ARM/QEMU/etc.) and sysfb_create_simplefb() (EFI/VESA) both hit this function. **EFI/VESA path already checks height*stride vs VRAM in sysfb_create_simplefb()** (drivers/firmware/sysfb_simplefb.c lines 98–102). **DT reg / memory-region does not.** That is the hole.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**

Record:
- **vesadrm / efidrm:** drm_sysfb_get_visible_size_si(..., resource_size(res)) already caps visible size.
- **ofdrm:** check_mul_overflow(linebytes, height, &fb_size) — **already in v6.18.53** (ded6ad826fe0f, Cc: stable). Message says it matches simpledrm.c — i.e. this check in mainline — while 6.18.53 still lacks it in simpledrm.

---

## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**

Record:
- git describe HEAD → **v6.18.53-5049-g0f0bdc2b0dffb**; Makefile **6.18.53**
- git merge-base --is-ancestor 8f06389364d85 v6.18.53 → **not in 6.18.53**
- At v6.18.53, simpledrm_device_create() maps resource_size(mem) with **no** height*stride check (verified by reading that version of the file)
- Bug present since simpledrm (v5.14-era), well before 6.18

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**

Record: **Clean apply.** v6.18.53 already has stride/width/height validation; insertion point after stride = pitch matches. overflow.h exists. Only extra autosel commit is the unused inline cleanup.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**

Record: Dimension/stride caps yes; mmap-vs-resource check **no**. No alternate fix for this OOB.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: SUBSYSTEM AND CRITICALITY**

Record: **drm/sysfb / simpledrm** — generic firmware framebuffer. **IMPORTANT** (not core mm/net, but default/fallback display on many DT and some x86 firmware systems).

**Step 7.2: SUBSYSTEM ACTIVITY**

Record: Active in 2026 (validation series, ofdrm overflow, vesadrm). Driver itself is mature (2021).

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: WHO IS AFFECTED**

Record: **Driver-specific**, CONFIG_DRM_SIMPLEDRM. Highest relevance:
DT simple-framebuffer with mismatched memory-region/reg vs width/height/stride. EFI/VESA sysfb already rejects undersized VRAM before creating the device.

**Step 8.2: TRIGGER CONDITIONS**

Record: Probe + later plane update. Trigger is **buggy/mismatched firmware or DT**, not a normal userspace syscall. Unprivileged users do not invent the resource; they can trigger the blit after a bad probe succeeds. Not a timing race.

**Step 8.3: FAILURE MODE SEVERITY**

Record: **OOB write** into/beyond ioremap/memremap (drm_fb_blit / memset_io) → **HIGH** (crash, corruption, possible security). Overflow of height*stride → **HIGH** in principle; with U16 height and INT_MAX stride already in 6.18.53, u64 overflow is unlikely; the resource-size check is the real fix.

**Step 8.4: RISK-BENEFIT RATIO**

Record:
- **Benefit:** HIGH for mismatched DT/firmware; closes a hole sibling drivers already close; ofdrm’s copy of the overflow check is already in this tree.
- **Risk:** LOW–MEDIUM — 24 lines, probe-only; possible **black screen** if firmware resource is smaller than height*stride but the machine still “displayed something.” Author: add quirks. That is still better than kernel OOB writes.
- **Ratio:** benefit outweighs risk for 6.18.y.

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: EVIDENCE**

**FOR:**
- Real OOB on plane update when mapped size < height*stride (verified blit/memset paths)
- Sashiko High finding; v3 fixed inverted compare
- 24 lines, probe-time, no APIs
- Reviewed by DRM maintainers; author is simpledrm maintainer
- Same validation series already partly in 6.18.53
- ofdrm overflow backport in this tree explicitly follows simpledrm
- Code and context exist; applies cleanly; no extra series patches required

**AGAINST:**
- No Fixes: / no user crash dump (absence is not a veto per rules)
- Author did not Cc: stable (sibling patches did; likely because this check was added mid-series)
- Probe failure on quirky firmware
- No syzbot reproducer

**UNRESOLVED:**
- lore/stable HTTP fetch failed; no confirmation of stable@ discussion
- No evidence of a specific board that hits this today (unverified)

**Step 9.2: STABLE RULES CHECKLIST**

1. Obviously correct and tested? **PASS** — v3 comparison is correct; three DRM R-bs
2. Real bug affecting users? **PASS** — OOB if DT/firmware sizes disagree with the memory resource
3. Important (crash/security/corruption)? **PASS** — kernel OOB write, severity HIGH
4. Small and contained? **PASS** — +24 lines, one function
5. No new features/APIs? **PASS**
6. Can apply to this tree? **PASS** — present and matching at v6.18.53

**Step 9.3: EXCEPTION CATEGORIES**

Record: None (not a device ID/quirk/DT/build/doc exception). It is a normal memory-safety fix.

**Step 9.4: DECISION**

This is a small, reviewed bounds check for a real OOB in simpledrm’s probe/scanout path. The buggy code is in 6.18.53; prerequisites are already there; ofdrm already received the same overflow approach. Firmware-quirk probe failure is the main risk and is acceptable versus out-of-bounds kernel writes.

---

### What the commit solves for this tree

On **6.18.53**, simpledrm_device_create() still maps only resource_size(mem) and then drm_fb_blit() / memset_io() walk height * stride bytes. If DT simple-framebuffer (or other platform data not going through sysfb_create_simplefb()) gives a smaller resource, that is an out-of-bounds kernel write. This patch fails probe instead.

### Stable rules / risk

Meets the rules: small, obviously correct after v3, no new API, applies cleanly here. Benefit is preventing corruption/oops on mismatched firmware; risk is losing simpledrm on those same configs (quirks if needed).

### Concerns

- Not originally Cc: stable (do not treat as a no).
- Inline helper commit is **not** required.
- ALIGN overflow check is largely redundant after U16/INT_MAX caps already in 6.18.53; harmless.

---

Verification:
- [Phase 1] Tags: Suggested-by Sashiko; R-b Thierry, Maxime, Javier; Link patch 5/7 v3; no Fixes/Cc: stable
- [Phase 2] +24 lines in simpledrm_device_create: overflow + size > resource_size on both mem paths
- [Phase 3] git describe/Makefile: **6.18.53**; merge-base --is- ancestor 8f063893 v6.18.53 = not present; file at v6.18.53 lacks the check
- [Phase 3] Series 1/2/4 already in v6.18.53; patch 3 (inline) not needed (git diff v6.18.53 only inlines helpers)
- [Phase 3] Blame: mapping from 2022–23 simpledrm; driver 11e8f5fd223bd (2021)
- [Phase 4] b4 dig -c 127d52f9: lore msgid; v1→v3; inverted check in v2
- [Phase 4] WebSearch/ratatoskr: Sashiko High OOB; drm_fb_memcpy/blit past map
- [Phase 4] lore/spinics WebFetch 403/500 — UNVERIFIED full mbox; substance recovered from b4 + archives
- [Phase 4] stable@ search UNVERIFIED (lore 403)
- [Phase 5] simpledrm_probe → create; blit/memset in drm_sysfb_modeset.c use fb_addr/fb_pitch
- [Phase 5] sysfb_create_simplefb() already rejects length > size; DT simplefb_get_memory_of() does not
- [Phase 5] ofdrm check_mul_overflow **is** in v6.18.53 (ded6ad826fe0f)
- [Phase 6] check_mul_overflow in include/linux/overflow.h at v6.18.53
- [Phase 8] Failure: OOB write on plane update, HIGH; trigger = mismatched firmware/DT
- UNVERIFIED: specific product firmware known to undersize the resource

**YES**

 drivers/gpu/drm/sysfb/simpledrm.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/gpu/drm/sysfb/simpledrm.c +24 -0
index 22f8caab39be0..91f114ab99a3e 100644
@@ -5,6 +5,7 @@
 #include <linux/of_clk.h>
 #include <linux/minmax.h>
 #include <linux/of_reserved_mem.h>
+#include <linux/overflow.h>
 #include <linux/platform_data/simplefb.h>
 #include <linux/platform_device.h>
 #include <linux/pm_domain.h>
@@ -626,6 +627,7 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
 	u16 width_mm = 0, height_mm = 0;
 	struct device_node *panel_node;
 	const struct drm_format_info *format;
+	u64 size;
 	struct resource *res, *mem = NULL;
 	struct drm_plane *primary_plane;
 	struct drm_crtc *crtc;
@@ -716,6 +718,14 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
 		}
 		stride = pitch;
 	}
+	if (check_mul_overflow(height, stride, &size)) {
+		drm_err(dev, "framebuffer size exceeds maximum\n");
+		return ERR_PTR(-EINVAL);
+	}
+	if (ALIGN(size, PAGE_SIZE) < PAGE_SIZE) {
+		drm_err(dev, "page-aligned framebuffer exceeds maximum\n");
+		return ERR_PTR(-EINVAL);
+	}
 
 	sysfb->fb_mode = drm_sysfb_mode(width, height, width_mm, height_mm);
 	sysfb->fb_format = format;
@@ -741,6 +751,13 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
 
 		drm_dbg(dev, "using system memory framebuffer at %pr\n", mem);
 
+		if (size > resource_size(mem)) {
+			drm_err(dev,
+				"framebuffer size of %llu exceeds memory range %pr\n",
+				size, mem);
+			return ERR_PTR(-EINVAL);
+		}
+
 		screen_base = devm_memremap(dev->dev, mem->start, resource_size(mem), MEMREMAP_WC);
 		if (IS_ERR(screen_base))
 			return screen_base;
@@ -774,6 +791,13 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
 			mem = res;
 		}
 
+		if (size > resource_size(mem)) {
+			drm_err(dev,
+				"framebuffer size of %llu exceeds memory range %pr\n",
+				size, mem);
+			return ERR_PTR(-EINVAL);
+		}
+
 		screen_base = devm_ioremap_wc(&pdev->dev, mem->start, resource_size(mem));
 		if (!screen_base)
 			return ERR_PTR(-ENOMEM);
Signature · 1 line
2.53.0
author maintainer
#345 lore raw

PATCH 1/1 comedi: quatech_daqp_cs: Fix sanity check in interrupt handler

In reply to Sasha Levin

From: Ian Abbott <[email protected]>

[ Upstream commit 1bc9538df6be8dac8727179d8bcc0d880648361b ]

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:

I have the attach/IRQ window, the original KASAN report, and the 4-line reorder; compiling that against this 7.3-rc4 tree next.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**

Record: [comedi: quatech_daqp_cs] [Fix] [sanity check in interrupt handler is performed after a possible NULL deref]

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**

Record:
- Signed-off-by: Ian Abbott <[email protected]> — COMEDI maintainer (author)
- `Link:
https://patch.msgid.link/[email protected] — lore/patch-id; msgid -12` is cover+11 patches (this is 11/11)
- Signed-off-by: Greg Kroah-Hartman <[email protected]> — char-misc maintainer
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, or Cc: stable on the commit itself (absence of Fixes/Cc-stable is expected)

Cover-letter CC (from b4, not the commit): Jaeyoung Chung, Sangyun Kim, Kyungwook Boo (SNU) — original reporters of the sibling ISA-driver bugs.

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**

Record:
- **Bug:** IRQ handler is registered before the device is fully set up. The dev->attached guard exists but runs *after* dev->read_subdev is used.
- **Symptom/failure mode:** NULL pointer dereference in interrupt context (kernel oops/panic). Message says dev->read_dev; actual field is dev->read_subdev (typo in the message, verified in source).
- **Version info:** none in the commit.
- **Root cause:** local initializer cmd = &s->async->cmd evaluates at function entry, before if (!dev->attached).

**Step 1.4: DETECT HIDDEN BUG FIXES**

Record: Not hidden. Explicit NULL-deref fix; “sanity check” here means reorder of an existing guard.

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES**

Record:
- File: drivers/comedi/drivers/quatech_daqp_cs.c — +3 / −1
- Function: daqp_interrupt()
- Scope: single-file surgical fix

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**

Record (verified against 1bc9538df6be8^ and current file):

Before:

```c
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_cmd *cmd = &s->async->cmd;  /* deref s immediately */
...
if (!dev->attached)
    return IRQ_NONE;
```

After:

```c
struct comedi_subdevice *s = dev->read_subdev;  /* pointer copy only */
struct comedi_cmd *cmd;
...
if (!dev->attached)
    return IRQ_NONE;
cmd = &s->async->cmd;  /* only after attached */
```

Path: interrupt handler, probe/early-IRQ window (and analogously detach).

**Step 2.3: IDENTIFY THE BUG MECHANISM**

Record: **NULL pointer dereference** in IRQ context. s is NULL until dev->read_subdev is assigned in daqp_auto_attach() (line 734), which is *after* pcmcia_request_irq() (line 718). dev->attached is set only later in comedi_device_postconfig() (drivers/comedi/drivers.c:833). C evaluates the cmd initializer at block entry, so the attached check never ran in time.

**Step 2.4: ASSESS THE FIX QUALITY**

Record: Obviously correct reorder; no API/locking/behavior change on the normal path. Residual s = dev->read_subdev before the check is a pointer copy, not a deref. Regression risk: very low.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**

Record:
- s = dev->read_subdev and if (!dev->attached): c12717423e1c61 (2013-02, contained in **v3.9-rc1**)
- Buggy cmd = &s->async->cmd: 2d7840c70dcf52 “use comedi_async 'scans_done' to detect EOA” (2014-11, contained in **v3.19-rc1**)
- Driver itself: 62ed666238aba1 (2009)

Long-standing bug, not new-subsystem code.

**Step 3.2: FOLLOW THE FIXES: TAG**

Record: No Fixes: tag. Buggy commit identified by blame:
2d7840c70dcf52. That history is in this tree.

**Step 3.3: CHECK FILE HISTORY**

Record: After this fix, only older moves (df0e68c1e9945 headers, 8ffdff6a8cfbd out of staging). No conflicting refactors. Standalone vs this file.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**

Record: Ian Abbott is listed in MAINTAINERS for COMEDI (S: Odd Fixes). Same-day series of 11 independent IRQ-guard fixes (aio_iiro_16, das6402, dt2811, ni_at_a2150, ni_atmio16d, pcl711, pcl816, pcl818, pcmmio, pcmuio, this one).

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**

Record: No functional dependency on the other 10; each driver is self- contained. dev->attached / read_subdev / s->async->cmd all exist here. Can apply standalone.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**

Record:
- b4 dig -c 1bc9538df6be8:
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only**, [PATCH 11/11]
- Cover: “comedi: Add/fix sanity check in ISA drivers to avoid null-ptr- deref”
- Original report [1]: https://lore.kernel.org/lkml/20260610115912.78013
[email protected]/ — subject “KASAN null-ptr-deref in ISA driver IRQ handlers on early IRQ”
- No NAKs in the saved series mbox (12 messages: cover + 11 patches, no replies)

**Step 4.2: CHECK WHO REVIEWED THE PATCH**

Record (b4 dig -w): To/Cc linux-kernel, Greg KH, Ian Abbott, H Hartley Sweeten, SNU reporters. No extra Reviewed-by. Applied by Greg KH.

**Step 4.3: SEARCH FOR THE BUG REPORT**

Record (from /tmp/snu-report/...mbx): Jaeyoung Chung / Sangyun Kim / Kyungwook Boo. KASAN NULL deref if IRQ fires after request_irq and before dev->read_subdev is set. Listed ISA drivers: das6402, ni_atmio16d, aio_iiro_16, pcmmio, comedi_parport, pcl711. **quatech_daqp_cs was not in that list**; Abbott added it as the same pattern (PCMCIA pcmcia_request_irq before read_subdev). Suggested
fix: request IRQ later **or** guard the handler — this patch does the latter.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**

Record: 11 independent per-driver patches. This one does not need the others.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**

Record: **UNVERIFIED** — lore.kernel.org/stable search returned HTTP
403. No stable discussion in the series mbox.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: IDENTIFY KEY FUNCTIONS**

Record: daqp_interrupt() modified. Related: daqp_auto_attach(), comedi_device_postconfig().

**Step 5.2: TRACE CALLERS**

Record: daqp_interrupt is only passed to pcmcia_request_irq() in daqp_auto_attach() (quatech_daqp_cs.c:718). Hardware IRQ context, not a syscall. Probe-time and runtime IRQs.

**Step 5.3: TRACE CALLEES**

Record: After the guard: inb, daqp_ai_get_sample, comedi_buf_write_samples, comedi_handle_events. Those run only once attached is true.

**Step 5.4: FOLLOW THE CALL CHAIN**

Record:
pcmcia probe → comedi_auto_config() → daqp_auto_attach() → pcmcia_request_irq(daqp_interrupt) → later read_subdev = s → return → comedi_device_postconfig() sets attached = true.

Reachable when a DAQP-208/DAQP-308 PCMCIA card is inserted (CONFIG_COMEDI_QUATECH_DAQP_CS). Unprivileged userspace is not required; hardware IRQ during attach is enough. Same class as the KASAN- reported ISA siblings.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**

Record: Same reorder in pcl711.c and others in this series. ni_660x.c even comments “make sure dev->attached is checked before doing anything else”. Systematic COMEDI IRQ pattern.

---

## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**

Record:
- git describe HEAD: **v7.3-rc4-27-gf0100363d8c37**
- make kernelversion: **7.3.0-rc4**
- Driver present: drivers/comedi/drivers/quatech_daqp_cs.c
- git merge-base --is-ancestor 1bc9538df6be8 HEAD: yes (fix is already on this branch)
- Pre-fix form verified in 1bc9538df6be8^; bug introduced v3.19, driver since ~2009
- Current daqp_interrupt() already has the reordered check (lines 210–221)

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**

Record: Clean apply. Function has been stable since ~2015 (f676376d692d8e / 77e7c200f37536). No rework needed.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**

Record: This exact fix is already on HEAD. Sibling series commits are also here. No alternate/competing fix for this file.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**

Record: drivers/comedi/ — data-acquisition. **PERIPHERAL** (PCMCIA
DAQ: DAQP-208/308). Crash in IRQ handler is still a hard oops for those users.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**

Record: Mature, “Odd Fixes”. Recent work is this IRQ-guard series plus small cleanups. Not a new/experimental driver (left staging in 2021, 8ffdff6a8cfbd).

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: DETERMINE WHO IS AFFECTED**

Record: Driver-specific / config-specific:
CONFIG_COMEDI_QUATECH_DAQP_CS, Quatech DAQP PCMCIA cards.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**

Record: IRQ after pcmcia_request_irq and before attached/read_subdev. Window during attach (and similar on teardown). Not every boot; needs the card and a premature/spurious IRQ. SNU reported KASAN for the same pattern on ISA siblings; Abbott confirmed this driver has the same ordering.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**

Record: NULL deref in IRQ handler → oops/panic. **CRITICAL** for users of this driver. (Cover letter: “null-ptr-deref”; original report:
“kernel panic” / KASAN.)

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**

Record:
- Benefit: HIGH for affected hardware (prevents IRQ oops); population is small
- Risk: VERY LOW (4-line reorder, no lock/API change)
- Ratio: favorable

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

**FOR:**
- Real NULL deref in interrupt context; C initializer ran before dev->attached
- Attach path verified: IRQ requested before read_subdev and before attached = true
- Same class as KASAN-reported COMEDI IRQ bugs (SNU); maintainer included this driver
- Author is the COMEDI maintainer; Greg KH applied it
- 4 lines, one function, no new APIs, no dependencies
- Bug present since ~v3.19; driver exists in this 7.3-rc4 tree

**AGAINST:**
- Niche PCMCIA DAQ hardware
- quatech_daqp_cs was not in the original SNU driver list (pattern match by maintainer)
- No Fixes: / Cc: stable (expected, not a negative)

**UNRESOLVED:**
- No stable@ thread found (lore 403)
- No on-list review replies in the b4 mbox
- Not proven on this exact Quatech card that IRQ fires in the window (sibling ISA drivers were KASAN-reported)

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**

1. Obviously correct and tested? **PASS** — reorder of existing guard; applied to char-misc by Greg KH
2. Fixes a real bug that affects users? **PASS** — premature IRQ NULL deref; reported class, same code here
3. Important issue? **PASS** — oops/panic in IRQ handler (CRITICAL for this driver)
4. Small and contained? **PASS** — +3/−1, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — same function, clean; tree is 7.3-rc4 with this driver

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**

Record: None (not an ID/quirk/DT/build/doc exception). Ordinary crash fix.

**Step 9.4: DECISION**

This tree is **7.3.0-rc4**. The driver and the buggy ordering exist here. The patch is a 4-line, obviously correct NULL-deref fix in an IRQ handler. It meets stable criteria for this checkout.

## Why it matters

daqp_auto_attach() calls pcmcia_request_irq() before dev->read_subdev is set and before the core sets dev->attached. The handler used to do cmd = &s->async->cmd at declaration time, so a premature IRQ oopses instead of returning IRQ_NONE. Stable users with this card can panic on insert/probe.

Risk is negligible; benefit is avoiding a hard crash. No prerequisites.

## Verification

- [Phase 1] Tags: Ian Abbott SOB, Greg KH SOB, msgid 20260618102949.26607-12 (11/11). No Fixes/Reported-by/Cc-stable on the commit.
- [Phase 1] Message typo verified: text says read_dev; code uses read_subdev.
- [Phase 2] Diff: +3/−1 in daqp_interrupt(); cmd init moved after if (!dev->attached).
- [Phase 2] Pre-fix source from git show 1bc9538df6be8^:... confirms initializer before the guard.
- [Phase 3] Blame: cmd init 2d7840c70dcf52 (v3.19-rc1); attached check c12717423e1c61 (v3.9-rc1).
- [Phase 3] git merge-base --is-ancestor 1bc9538df6be8 HEAD → is ancestor.
- [Phase 3] Author is COMEDI maintainer (MAINTAINERS); 11-patch series, this file standalone.
- [Phase 4] b4 dig -c 1bc9538df6be8 → lore URL; -a → v1 only; -w → Greg KH, Hartley, SNU CCs.
- [Phase 4] Cover letter: explicit null-ptr-deref; cites SNU report.
- [Phase 4] Original report mbox: KASAN NULL deref / panic on early IRQ; quatech not named; Abbott added it.
- [Phase 4] UNVERIFIED: stable@ discussion (HTTP 403); review replies (none in series mbox).
- [Phase 5] Only caller: pcmcia_request_irq in daqp_auto_attach.
- [Phase 5] comedi_device_postconfig() sets dev->attached = true only after auto_attach returns.
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; kernelversion 7.3.0-rc4; file present.
- [Phase 6] Current daqp_interrupt() at lines 210–221 already contains the fix.
- [Phase 7] CONFIG_COMEDI_QUATECH_DAQP_CS — DAQP-208/308 PCMCIA.
- [Phase 8] Failure mode: NULL deref in IRQ → oops; severity CRITICAL for this driver; risk very low.
- UNVERIFIED: hardware demonstration that this specific PCMCIA card IRQs in the attach window.

**YES**

 drivers/comedi/drivers/quatech_daqp_cs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/comedi/drivers/quatech_daqp_cs.c +3 -1
index 2a76c75c513b8..d5e3e213e233b 100644
@@ -211,13 +211,15 @@ static irqreturn_t daqp_interrupt(int irq, void *dev_id)
 {
 	struct comedi_device *dev = dev_id;
 	struct comedi_subdevice *s = dev->read_subdev;
-	struct comedi_cmd *cmd = &s->async->cmd;
+	struct comedi_cmd *cmd;
 	int loop_limit = 10000;
 	int status;
 
 	if (!dev->attached)
 		return IRQ_NONE;
 
+	cmd = &s->async->cmd;
+
 	status = inb(dev->iobase + DAQP_STATUS_REG);
 	if (!(status & DAQP_STATUS_EVENTS))
 		return IRQ_NONE;
Signature · 1 line
2.53.0
author maintainer
#346 lore raw

PATCH 1/1 wifi: mt76: mt7603: add 0x7592 EEPROM chip ID

In reply to Sasha Levin

From: Ahmed Naseef <[email protected]>

[ Upstream commit d16447d7470502e998d82e806ca7ed49d1baa853 ]

Some EcoNet based routers ship an on-flash EEPROM whose chip-id is 0x7592 instead of the expected 0x7603. The device probes as PCI 14c3:7603 and the hardware MT_HW_CHIPID register reports 0x7603, independent of the EEPROM value.

This is seen across multiple EcoNet EN751221 and EN7528 based devices (for example the Genexis Platinum 4410).

---

LLM Generated explanations, may be completely bogus:

The evaluation target is **pending-6.6 (6.6.157)**. The mt7603 driver is present; the 0x7592 EEPROM ID is not. This is a one-line ID addition to an existing driver, which is a standard stable exception.

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

Step 1.1: PARSE THE SUBJECT LINE
Record: [wifi: mt76: mt7603] [add] [accept EEPROM chip ID 0x7592 in mt7603_check_eeprom]

Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Ahmed Naseef \<[email protected]\> (author)
- Link:
https://patch.msgid.link/[email protected]
- Signed-off-by: Felix Fietkau \<[email protected]\> (mt76 maintainer, applied the patch)
- No Fixes: tag (expected for this review queue)
- No Cc: stable (expected)
- No Reported-by / Tested-by / Reviewed-by / Acked-by
- No syzbot / KASAN tags
- Sasha Levin SOB not present on this commit

Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: EcoNet routers store chip-id 0x7592 in on-flash EEPROM instead of 0x7603/0x7628/0x7600.
- Hardware identity is still MT7603: PCI 14c3:7603, and MT_HW_CHIPID reads 0x7603.
- Symptom: driver treats a valid factory EEPROM as invalid.
- Devices: EcoNet EN751221 and EN7528, e.g. Genexis Platinum 4410.
- No stack trace; this is hardware recognition, not a crash fix.
- Root cause: mt7603_check_eeprom() whitelist is incomplete.

Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. It is an explicit EEPROM ID addition. When the ID is rejected and OTP exists, mt7603_eeprom_init() memcpy()s OTP over the flash EEPROM, so MAC/calibration from flash are discarded. That is a real functional bug for those boards, not a new API.

===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================

Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/net/wireless/mediatek/mt76/mt7603/eeprom.c
- +1 line, 0 removed
- Function: mt7603_check_eeprom()
- Scope: single-file, one-line surgical change

Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: switch accepts 0x7628, 0x7603, 0x7600; anything else returns -EINVAL.
- After: also accepts 0x7592.
- Path: probe → mt7603_register_device() → mt7603_init_hardware() → mt7603_eeprom_init().
- If check succeeds and OTP exists: apply cal-free OTP overlay onto flash EEPROM.
- If check fails and OTP exists: overwrite entire flash EEPROM with OTP (MAC, TX power, xtal data from flash lost).
- Probe does not fail on unknown EEPROM ID.

Step 2.3: IDENTIFY THE BUG MECHANISM
Record: [Hardware ID / quirk] [Whitelist used to decide whether on-flash EEPROM is trusted. Missing 0x7592 caused valid EcoNet EEPROMs to be discarded in favor of OTP.]

Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: same pattern as the existing 0x7600 case.
- Minimal: one case label.
- Regression risk: very low. A random EEPROM whose first LE16 is 0x7592 would be trusted; that is the same risk as the existing IDs.
- No API or data-structure change.

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

Step 3.1: BLAME THE CHANGED LINES
Record:
- mt7603_check_eeprom() introduced in c8846e1015022 ("mt76: add driver for MT7603E and MT7628/7688"), 2018, first released in v5.1-rc1.
- 0x7600 added by bf4a938ab2cf8 ("mt76: mt7603: add additional EEPROM chip ID"), 2020, same one-line pattern for TP-Link Archer C50 v4.
- Both commits are ancestors of pending-6.6.

Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Buggy whitelist dates to the original driver (v5.1), which is in this tree.

Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES Record:
- Related: bf4a938ab2cf8 already in 6.6 (precedent).
- Candidate d16447d747050 is not an ancestor of pending-6.6.
- Standalone; not patch X/Y.

Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record:
- Author Ahmed Naseef has no other mt76 commits on pending-6.6.
- Applied by Felix Fietkau, listed maintainer of MEDIATEK MT76.

Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS Record:
- No new helpers or struct fields.
- pending-6.6 vs patch parent only differs in SPDX and later chainmask/return of mt76_eeprom_override(); the switch hunk is identical.
- Can apply standalone with a clean hunk.

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c d16447d747050 →
https://patch.msgid.link/[email protected]
- b4 dig -a: single v1 series, no v2/v3.
- Thread mbox is the patch only; no replies, no NAK, no Cc: stable in review.
- Included in wireless-next-2026-08-06 pull (Johannes Berg).
- Syzbot CI: build/boot passed; fuzz skipped.

Step 4.2: CHECK WHO REVIEWED THE PATCH
Record:
- b4 dig -w: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen, Sean Wang, linux-wireless, linux-mediatek, linux-kernel.
- Applied by Felix Fietkau (maintainer SOB). No separate Reviewed-by.

Step 4.3: SEARCH FOR THE BUG REPORT
Record:
- No bugzilla/syzbot link.
- Commit cites multiple EcoNet EN751221/EN7528 devices, example Genexis Platinum 4410.
- OpenWrt mt76 tree already contains case 0x7592.
- No independent public crash report found (UNVERIFIED beyond the commit text and OpenWrt tree).

Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone one-patch series. Same pattern as bf4a938ab2cf8.

Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable returned 403. No stable discussion found via b4/mbox. UNVERIFIED whether anyone requested/rejected this for stable.

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: mt7603_check_eeprom() only.

Step 5.2: TRACE CALLERS
Record:
- Only caller: mt7603_eeprom_init() (same file).
- mt7603_eeprom_init() ← mt7603_init_hardware() ← mt7603_register_device()
- mt7603_register_device() ← mt76pci_probe() (PCI 14c3:7603) and mt76_wmac_probe() (mediatek,mt7628-wmac).
- Probe/init path, not hot path or IRQ.

Step 5.3: TRACE CALLEES
Record: get_unaligned_le16() on eeprom.data[0]. No alloc, lock, or I/O in the changed function.

Step 5.4: FOLLOW THE CALL CHAIN
Record:
- Reachable when an MT7603 PCI device or MT7628 WMAC probes with CONFIG_MT7603E.
- Not a syscall-triggered memory bug; firmware/EEPROM contents decide the branch.
- Unprivileged users cannot trigger it except by plugging/using the device.

Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record:
- Sibling drivers use the same EEPROM-ID switch (mt7615, mt76x0, mt76x2).
- This tree already backported other mt76 ID adds, e.g. efd75512e38ac (mt76x2u TP-Link USB ID).

===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================

Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record:
- Tree under evaluation: pending-6.6, 6.6.157 (git describe p-6.6-3-g04810563abb71).
- Yes. pending-6.6 eeprom.c switch has 0x7628/0x7603/0x7600 only.
- git merge-base --is-ancestor d16447d747050 pending-6.6 → not present.
- Bug present since v5.1 driver introduction.

Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Clean apply. Switch context matches. Later chainmask/license diffs are outside the hunk.

Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: 0x7600 ID is present. 0x7592 is not. No alternate fix.

Note: EcoNet SoC support landed in 6.16 (arch/mips/econet), not in 6.6. That lowers vanilla-6.6 user count; it does not remove the driver or the ID check. PCI 14c3:7603 still exists in this tree.

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [drivers/net/wireless/mediatek/mt76/mt7603] [IMPORTANT for MT7603/MT7628 users; PERIPHERAL relative to core kernel]

Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mature driver since v5.1. 6.6 still receives mt76 fixes. Maintainer is Felix Fietkau.

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver-specific / config-specific (CONFIG_MT7603E). Documented users are EcoNet EN751221/EN7528 routers with MT7603 PCI WiFi. Vanilla 6.6 cannot boot EcoNet SoCs; downstream 6.6 kernels and any other board with this EEPROM still benefit.

Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record:
- Trigger: probe of MT7603 when flash EEPROM starts with 0x7592 and OTP is present.
- Every boot on those devices, not a race.
- Not exploitable by unprivileged software alone.

Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: [Wrong EEPROM source: factory MAC/calibration replaced by OTP] [Severity: MEDIUM for those devices — broken/degraded WiFi or wrong MAC, not oops/corruption]

Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: medium for affected hardware (WiFi uses intended EEPROM); lower on vanilla 6.6 because EcoNet platform is later, but this is the usual device-ID case.
- Risk: very low (one case label, no locking/API).
- Ratio: favorable. Device-ID additions are accepted in stable for this reason.

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

Step 9.1: COMPILE THE EVIDENCE
FOR:
- One-line EEPROM/chip ID addition to an existing driver (stable exception).
- Same pattern as 0x7600, already in 6.6.
- Real boards named; hardware already binds as PCI 14c3:7603.
- Without it, valid flash EEPROM is discarded for OTP (MAC/cal).
- Maintainer applied it; applies cleanly here; no new API.
- This tree already contains similar mt76 ID backports.

AGAINST:
- Not a crash/security/deadlock.
- No Tested-by/Reviewed-by; mailing list had no discussion.
- EcoNet platform is not in 6.6, so vanilla 6.6 user count is small.
- No Fixes:/Cc: stable (expected, not a negative).

UNRESOLVED:
- Could not search lore.kernel.org/stable (403).
- No independent public repro beyond the commit and OpenWrt mt76 tree.

Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — one-line whitelist, maintainer- applied, syzbot CI build/boot passed.
2. Fixes a real bug that affects users? PASS — those boards trust OTP instead of factory EEPROM.
3. Important issue? PASS under the device-ID/quirk exception (functional WiFi/MAC on real hardware), even though not a panic.
4. Small and contained? PASS — +1 line, one file.
5. No new features or APIs? PASS — existing driver, additional ID only.
6. Can apply to the local tree? PASS — hunk matches pending-6.6.

Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Device ID addition to an existing driver (EEPROM chip ID, analogous to PCI/USB ID). Also a hardware quirk for boards whose EEPROM ID does not match MT_HW_CHIPID.

Step 9.4: MAKE YOUR DECISION
This belongs in 6.6.y. The driver and the incomplete whitelist are in this tree; the fix is the standard one-line ID addition stable already takes for mt76. EcoNet SoC support arriving later reduces vanilla-6.6 exposure but does not make the patch a new feature or a dependency-heavy backport.

What it solves for stable users: MT7603 devices whose flash EEPROM ID is 0x7592 keep factory MAC and calibration instead of having them replaced by OTP on probe.

Risk vs benefit: essentially no regression risk; benefit is enabling correct EEPROM use on existing hardware.

Verification:
- [Phase 1] Tags: author SOB, Felix Fietkau SOB, msgid link; no Fixes/Cc stable/Reported-by
- [Phase 2] Diff: +1 case 0x7592: in mt7603_check_eeprom()
- [Phase 2] Confirmed eeprom_init: fail → memcpy OTP over flash; success → cal-free overlay only
- [Phase 3] blame: function from c8846e1015022 (v5.1); 0x7600 from bf4a938ab2cf8; both in pending-6.6
- [Phase 3] git merge-base --is-ancestor d16447d747050 pending-6.6 → not in 6.6
- [Phase 3] git diff pending-6.6 vs parent: switch identical; only SPDX/chainmask elsewhere
- [Phase 4] b4 dig -c d16447d747050: lore msgid [email protected]
- [Phase 4] b4 dig -a: v1 only; mbox has no replies
- [Phase 4] b4 dig -w: mt76 maintainers + linux-wireless CC'd; Felix applied
- [Phase 4] wireless-next-2026-08-06 pull lists this commit
- [Phase 5] callers: mt7603_eeprom_init → init_hardware → register_device → pci/soc probe
- [Phase 6] pending-6.6 Makefile 6.6.157; switch lacks 0x7592; would apply cleanly
- [Phase 6] EcoNet arch not in 6.6 (added ~6.16) — lowers vanilla user count, code still present
- [Phase 7] MAINTAINERS: Felix Fietkau maintains mt76
- [Phase 8] Failure: OTP replaces flash EEPROM (MAC/cal); not oops
- UNVERIFIED: stable@ lore search (HTTP 403); no independent field crash report

**YES**

 drivers/net/wireless/mediatek/mt76/mt7603/eeprom.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/mediatek/mt76/mt7603/eeprom.c +1 -0
index 88382b537a33b..06f61988655e5 100644
@@ -142,6 +142,7 @@ static int mt7603_check_eeprom(struct mt76_dev *dev)
 	case 0x7628:
 	case 0x7603:
 	case 0x7600:
+	case 0x7592:
 		return 0;
 	default:
 		return -EINVAL;
Signature · 1 line
2.53.0
author maintainer
#347 lore raw

PATCH 1/1 PCI: vmd: Handle BUS_RESTRICT_CFG value 3 for Arrow Lake-HX

In reply to Sasha Levin

From: Ali Alaei <[email protected]>

[ Upstream commit 72b32eccbcd591b9606edacf3bd7c455176d7660 ]

On Intel Arrow Lake-HX systems (e.g. Core Ultra 9 275HX on Acer Predator PH16-73), the VMD controller reports BUS_RESTRICT_CFG = 3 in the VMCONFIG register. The existing switch statement only handled values 0, 1, and 2, causing vmd_get_bus_number_start() to return -ENODEV and aborting the entire VMD probe. This leaves NVMe drives behind the VMD controller invisible to the kernel.

Hardware registers (VMCAP/VMCONFIG at offsets 0x40/0x44):

VMD 0000:00:0e.0 (8086:ad0b): VMCAP=0x000f, VMCONFIG=0x03b8 BUS_RESTRICT_CFG(0x03b8) = (0x03b8 >> 8) & 0x3 = 3

Add cfg=3 as a fallthrough to cfg=2, setting busn_start=224, which is the correct bus number base for this hardware.

Also add a PCI_POSSIBLE_ERROR() guard after reading VMCONFIG: a failed config space read returns 0xFFFF, and BUS_RESTRICT_CFG(0xFFFF) = 3, so without this guard a removed or errored device would falsely match the new case 3 instead of being caught as an error.

---

LLM Generated explanations, may be completely bogus:

The local tree is **7.3.0-rc4**. This commit is a three-line VMD hardware workaround: Arrow Lake reports BUS_RESTRICT_CFG=3, probe used to abort with -ENODEV, and NVMe behind VMD disappeared. That is a real, user-visible bug and is appropriate for this tree.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**

Record: **[PCI: vmd]** **[Handle]** Handle BUS_RESTRICT_CFG value 3 for Arrow Lake-HX so VMD probe no longer fails.

Subsystem: PCI VMD controller (drivers/pci/controller/vmd.c). Verb “Handle” is a bug-fix verb: previously-unhandled hardware encoding.

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**

Record:
- **Reported-by:** Lin Mohan <[email protected]> (real user; also the bugzilla reporter)
- **Closes:** https://bugzilla.kernel.org/show_bug.cgi?id=221137 (Arrow- Lake-S)
- **Closes:** https://bugzilla.kernel.org/show_bug.cgi?id=221136 (Arrow- Lake-S)
- **Signed-off-by:** Ali Alaei (author); Manivannan Sadhasivam (PCI host/endpoint maintainer, applied); Bjorn Helgaas (PCI subsystem maintainer, committed)
- **Link:** https://patch.msgid.link/20260628143450.92492-1-
[email protected]
- **No Fixes:** tag (expected for this review)
- **No Cc: stable** (expected)
- Ignored pipeline SOBs if present; none from Sasha Levin on this commit

Notable: two independent Closes tags plus a Reported-by, plus PCI maintainer SOBs.

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**

Record:
- **Bug:** On Arrow Lake-HX (Core Ultra 9 275HX, Acer Predator PH16-73), VMD 8086:ad0b reports VMCONFIG=0x03b8 so BUS_RESTRICT_CFG = (0x03b8 >> 8) & 0x3 = 3. The switch only handled 0/1/2, so vmd_get_bus_number_start() returned -ENODEV and probe aborted.
- **Symptom:** NVMe behind VMD is invisible.
- **Root cause:** New 2-bit encoding (value 3) treated as unknown. BUS_RESTRICT_CFG is only 2 bits, so 3 is a legal value, not “reserved garbage.”
- **Fix:** Treat cfg=3 like cfg=2 (busn_start=224). Guard pci_read_config_word() with PCI_POSSIBLE_ERROR() because a failed read is 0xFFFF and BUS_RESTRICT_CFG(0xFFFF)=3, which would now look valid.
- **Version info in message:** none beyond Arrow Lake-HX/S hardware.

**Step 1.4: DETECT HIDDEN BUG FIXES**

Record: Not hidden. Explicit hardware-handling bug: probe fails, disks missing. The error-read guard is a real correctness fix that became necessary once case 3 was valid.

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES**

Record:
- File: drivers/pci/controller/vmd.c (+3 lines)
- Function: vmd_get_bus_number_start()
- Scope: **single-file surgical fix**

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**

Record:
- **Before:** After pci_read_config_word(VMCONFIG), switch on bits [9:8]. 0→bus 0, 1→128, 2→224, anything else (including 3) → pci_err
+ -ENODEV.
- **After:** If the word is 0xFFFF, return -ENODEV. Case 3 falls through to case 2 (busn_start=224).
- Path: VMD probe / domain setup, not a hot path and not an optional debug path.

**Step 2.3: IDENTIFY THE BUG MECHANISM**

Record:
- **Category:** Hardware workaround / logic correctness (unhandled register encoding), plus error-path guard.
- **Mechanism:** Firmware programs Dynamic Bus Offset / restriction mode
3. Driver rejected it, so the VMD domain never came up and child NVMe never enumerated.
- **Secondary:** Without the PCI_POSSIBLE_ERROR() check, a dead device (0xFFFF) would now be accepted as mode 3.

**Step 2.4: ASSESS THE FIX QUALITY**

Record:
- **Quality:** Minimal and locally obvious. Mask is & 0x3, so 3 is the last encoding; mapping it to the existing 224–255 window matches cfg=2 and matches the author’s dump plus tester reports.
- **Regression risk:** Low. Only devices that actually report cfg=3 change behavior (they used to fail probe). Other encodings unchanged. The 0xFFFF guard restores the old “abort on bad read” behavior for the new case.
- **Caveat (verified, not blocking):** An older Intel series treated cfg=3 as a *second* root bus (BUS0=224, BUS1=225). That series is **not** in this tree (bus1_rootbus / VMD_FEAT_HAS_BUS1_ROOTBUS absent). This 3-line mapping was tested on real Arrow Lake-HX and confirmed by the Arrow Lake-S bugzilla reporter. PCI maintainers merged it.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**

Record:
- Switch and helper: **2e1224183b1bec** (“PCI: vmd: Create bus offset configuration helper”, Jon Derrick, 2020) — first in **v5.10-rc1**.
- Even earlier, **51f939b11cb1c** / related bus-restriction decode treated case 3 as "Unknown Bus Offset Setting" + -ENODEV on purpose.
- Buggy “3 is unknown” behavior has been in the driver for years; it only bit users once Arrow Lake firmware started programming 3.

**Step 3.2: FOLLOW THE FIXES: TAG**

Record: **No Fixes: tag.** Not applicable. Introduction of the incomplete switch is 2e1224183b1bec (v5.10). Device ID 8086:ad0b added in **57a128acaba02** (“Add DID 8086:7D0B and 8086:AD0B for Intel MTL SKUs”, ~v6.0). PCI_POSSIBLE_ERROR from **57bdeef471668** (~v5.17).

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**

Record:
- Later on the same file: 2162572d34c50 (_OSC flags in guests), 55aa45154fe48 (Nova Lake / Dunlow IDs). Neither is a prerequisite or a revert.
- Parent b030905bf5a64 (BIOS-enumerated devices) does **not** change this switch; this commit is standalone.
- Not a “patch X/Y” series.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**

Record: Ali Alaei’s only commit under drivers/pci/controller/ is this one. Applied by Mani, committed by Bjorn. Intel VMD maintainers (Nirmal Patel, Jonathan Derrick) were CCed on v3; no NAK in the thread.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**

Record: None required. Uses existing vmd_get_bus_number_start(), existing BUS_RESTRICT_CFG(), existing PCI_POSSIBLE_ERROR(). Can apply standalone on this tree.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**

Record:
- **Lore (via b4 dig):** https://patch.msgid.link/20260628143450.92492-
[email protected]
- **Revisions:** v1 (2026-06-04, case 3 only) → v2 (same day, add PCI_POSSIBLE_ERROR) → **v3 applied** (changelog placement + CC VMD maintainers)
- v1 review (sashiko-bot) flagged exactly the 0xFFFF → case 3 issue; v2/v3 addressed it.
- Mani: style/CC nits on v2; **“Applied, thanks!”** on v3.
- Bjorn: asked whether it closes bugzilla 221136, noted lack of public spec, wanted Intel VMD maintainers to comment; still merged and added Reported-by/Closes.
- **No NAK.** No reviewer asked for Cc: stable (absence expected).

**Step 4.2: CHECK WHO REVIEWED THE PATCH**

Record (b4 dig -w): linux-pci, Bjorn Helgaas, Lorenzo Pieralisi, Nirmal Patel, Jonathan Derrick, Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring. Right lists and maintainers.

**Step 4.3: SEARCH FOR THE BUG REPORT**

Record:
- Bugzilla fetches returned **403**; full bug text **UNVERIFIED**.
- On-list, Lin Mohan confirmed both 221137 and 221136 are the same Mode 3 / Dynamic Bus Offset issue, including on 8086:09ab Arrow Lake-S, and asked for Closes tags after merge.
- Author tested Acer Predator PH16-73 / Core Ultra 9 275HX / 8086:ad0b.
- Multiple users/platforms: **HX laptop + S desktop**.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**

Record: Standalone 1/1. Older Intel “second rootbus” series on spinics is a large new feature and is **not** in this tree; not a dependency of this 3-line workaround.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**

Record: lore.kernel.org/stable search returned **403**. **UNVERIFIED** whether stable@ already discussed it. No evidence in the pci thread of a reason to keep it out of stable.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: IDENTIFY KEY FUNCTIONS**

Record: vmd_get_bus_number_start() only.

**Step 5.2: TRACE CALLERS**

Record:
- Called from vmd_prepare_offsets_and_bus() when VMD_FEAT_HAS_BUS_RESTRICTIONS.
- That is called from vmd_enable_domain().
- That is called from vmd_probe().
- Probe path during PCI enumeration of the VMD device. Not IRQ/hot path.

VMD_FEATS_CLIENT includes VMD_FEAT_HAS_BUS_RESTRICTIONS. Device 0xad0b uses VMD_FEATS_CLIENT. Several other client IDs do too, so any of those that firmware sets to cfg=3 hit this.

**Step 5.3: TRACE CALLEES**

Record: pci_read_config_word() (VMCAP 0x40, VMCONFIG 0x44), PCI_POSSIBLE_ERROR(), pci_err() on unknown values.

**Step 5.4: FOLLOW THE CALL CHAIN**

Record: Boot / device probe. Reachable whenever VMD is enabled (RST/VMD in firmware) on affected Intel client platforms. Unprivileged users do not trigger it via a syscall; they just lose NVMe. **User-visible and common on those laptops.**

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**

Record: Same PCI_POSSIBLE_ERROR() pattern already used in vmd_get_phys_offsets() for VMLOCK. No other unhandled BUS_RESTRICT_CFG sites.

---

## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**

Record:
- git describe HEAD → **v7.3-rc4-27-gf0100363d8c37**
- make kernelversion → **7.3.0-rc4**
- vmd_get_bus_number_start() is present; 0xad0b is in vmd_ids[]; PCI_POSSIBLE_ERROR is in include/linux/pci.h.
- Bug introduced with the 0/1/2-only switch (v5.10 helper); manifests on Arrow Lake once those IDs exist (~v6.0+).
- **Yes, the bug exists in this lineage.**

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**

Record: **Clean apply** on this tree. Hunk is isolated to the helper; surrounding refactor (vmd_prepare_offsets_and_bus) does not overlap.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**

Record: No other commit implements cfg=3. No revert. No dual-rootbus substitute.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**

Record: **PCI controller / Intel VMD.** Criticality **IMPORTANT** (not core mm/vfs, but VMD is how many Intel laptops expose NVMe). CONFIG_VMD depends on PCI_MSI && X86_64.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**

Record: Actively maintained (new device IDs, BIOS-scan feature, _OSC guest fix). The **switch itself** has been stable since 2020; this is a late hardware encoding, not churn in the helper.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: DETERMINE WHO IS AFFECTED**

Record: **Driver-specific / platform-specific:** x86_64 systems with Intel VMD and firmware BUS_RESTRICT_CFG=3 (Arrow Lake-HX confirmed; Arrow Lake-S reporter confirmed). Not universal.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**

Record: Every boot on affected machines with VMD enabled. Not a race. Not unprivileged-exploit; **storage simply missing.**

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**

Record: VMD probe fails (-ENODEV); NVMe behind VMD never appears. **HIGH** (loss of boot/root/data disks on common Intel client hardware). Not a panic, but production-breaking.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**

Record:
- **Benefit:** High for affected users (NVMe works).
- **Risk:** Very low (3 lines, probe-only, existing mapping, error-read guard).
- **Ratio:** Strongly in favor of applying it on this tree.

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

**For:**
- Real bug: VMD probe abort, NVMe invisible.
- Confirmed on Arrow Lake-HX (author) and Arrow Lake-S (bugzilla reporter).
- 3-line, obviously correct mapping of a 2-bit field.
- Extra PCI_POSSIBLE_ERROR() prevents a new false-positive on 0xFFFF.
- PCI maintainers applied/committed; v1 review hole fixed in v2/v3.
- Fits the stable **hardware quirk / existing-device enablement** exception.
- All helpers and IDs exist in **this** 7.3.0-rc4 tree; no missing prerequisites.

**Against:**
- Not a crash/UAF/security bug.
- No public VMD spec for mode 3; Bjorn noted a “new mode” might someday need more than a fallthrough (dual-rootbus series never landed here).
- Intel VMD maintainers were CCed but did not ack in the saved thread.

**Unresolved:**
- Full bugzilla pages (HTTP 403).
- stable@ archive search (HTTP 403).
- Whether every cfg=3 platform only needs bus 224 (empirically yes for the reported machines).

Those gaps do not outweigh the hardware reports and the size of the fix.

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**

1. Obviously correct and tested? **PASS** — register dump, author test, reporter confirmation, v3 review.
2. Fixes a real bug that affects users? **PASS** — NVMe missing on shipping Arrow Lake systems.
3. Important issue? **PASS** — HIGH: boot/storage devices not enumerated (not a panic, but not cosmetic).
4. Small and contained? **PASS** — +3 lines, one function.
5. No new features or APIs? **PASS** — no new ABI; handles a value the existing 2-bit field can already produce.
6. Can apply to the local tree? **PASS** — helper, IDs, and PCI_POSSIBLE_ERROR all present; apply is clean.

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**

Record: **Hardware quirk/workaround** (and the same class as device-ID enablement): existing driver, existing PCI ID, firmware encoding the driver rejected, so the device did not work.

**Step 9.4: MAKE YOUR DECISION**

This tree is 7.3.0-rc4. The VMD driver, Arrow Lake DID 0xad0b, bus- restriction feature flag, and the old 0/1/2-only switch all exist here. The patch is a small, tested workaround that restores NVMe on affected Intel VMD systems. It should be applied to this tree.

### What the commit solves
BUS_RESTRICT_CFG is two bits. Arrow Lake programs **3**. The driver treated 3 as unknown, failed VMD probe, and hid NVMe. Mapping 3 to the existing bus-224 window, and rejecting 0xFFFF config reads, is the correct local fix.

### Stable rules
Meets all six criteria. It is a hardware workaround, not a new API.

### Risk vs benefit
Benefit is high (disks appear). Risk is very low (three lines, probe- only).

### Concerns
Dual-rootbus would be a large new feature and is not in this tree; it is not required for the reported machines. PCI_POSSIBLE_ERROR is already here, so no extra backport of that helper is needed on this tree.

---

## Verification
- **[Phase 1]** Parsed commit 72b32eccbcd59: Reported-by Lin Mohan; Closes 221137/221136; SOB Ali Alaei, Mani, Bjorn Helgaas; Link to msgid 20260628143450.92492-1; no Fixes/Cc-stable.
- **[Phase 2]** Diff: +3 lines in vmd_get_bus_number_start():
PCI_POSSIBLE_ERROR + case 3: fallthrough to busn_start=224.
- **[Phase 2]** Confirmed BUS_RESTRICT_CFG is ((vmcfg >> 8) & 0x3) in vmd.c:32; 0xFFFF → 3.
- **[Phase 3]** git blame: switch from 2e1224183b1bec (v5.10-rc1); case 3 lines from this commit.
- **[Phase 3]** 0xad0b added in 57a128acaba02; PCI_POSSIBLE_ERROR in 57bdeef471668 (~v5.17); present in include/linux/pci.h:179.
- **[Phase 3]** git log --oneline -20 -- drivers/pci/controller/vmd.c:
no revert; later commits are IDs/_OSC only.
- **[Phase 3]** Author has no other VMD commits.
- **[Phase 4]** b4 dig -c 72b32eccbcd59: v3 at patch.msgid.link/[email protected]
- **[Phase 4]** b4 dig -a: v1 → v2 → v3; v3 is what was applied.
- **[Phase 4]** b4 dig -w: linux-pci + Helgaas, Pieralisi, Patel, Derrick, Wilczyński, Sadhasivam, Herring.
- **[Phase 4]** mbox: Mani applied; Bjorn discussed bugzilla; Lin Mohan confirmed both bugs; sashiko-bot caught the 0xFFFF issue on v1.
- **[Phase 4]** Bugzilla WebFetch 403 — full bug text UNVERIFIED; reporter confirmation verified from mbox.
- **[Phase 4]** lore.kernel.org/stable 403 — UNVERIFIED.
- **[Phase 5]** Call chain: vmd_probe → vmd_enable_domain → vmd_prepare_offsets_and_bus → vmd_get_bus_number_start.
- **[Phase 5]** 0xad0b in vmd_ids[] with VMD_FEATS_CLIENT including VMD_FEAT_HAS_BUS_RESTRICTIONS.
- **[Phase 5]** No bus1_rootbus in this tree.
- **[Phase 6]** git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion: 7.3.0-rc4.
- **[Phase 6]** git merge-base --is-ancestor 72b32eccbcd59 HEAD: yes; first contained in **v7.3-rc1**; not in v7.2.
- **[Phase 7]** CONFIG_VMD in drivers/pci/controller/Kconfig;
MAINTAINERS: Nirmal Patel / Jonathan Derrick.
- **[Phase 8]** Failure mode: VMD probe -ENODEV → NVMe not enumerated; severity HIGH.
- **UNVERIFIED:** Full bugzilla 221136/221137 bodies; any stable@ thread; whether cfg=3 ever needs a second root bus on unreported SKUs.

**YES**

 drivers/pci/controller/vmd.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/pci/controller/vmd.c +3 -0
index b4b62b9ccc45a..5d3e6cc7e4feb 100644
@@ -656,6 +656,8 @@ static int vmd_get_bus_number_start(struct vmd_dev *vmd)
 	pci_read_config_word(dev, PCI_REG_VMCAP, &reg);
 	if (BUS_RESTRICT_CAP(reg)) {
 		pci_read_config_word(dev, PCI_REG_VMCONFIG, &reg);
+		if (PCI_POSSIBLE_ERROR(reg))
+			return -ENODEV;
 
 		switch (BUS_RESTRICT_CFG(reg)) {
 		case 0:
@@ -664,6 +666,7 @@ static int vmd_get_bus_number_start(struct vmd_dev *vmd)
 		case 1:
 			vmd->busn_start = 128;
 			break;
+		case 3:
 		case 2:
 			vmd->busn_start = 224;
 			break;
Signature · 1 line
2.53.0
#348 lore raw

Re: [PATCH AUTOSEL 6.18-5.10] PCI: vmd: Handle BUS_RESTRICT_CFG value 3 for Arrow Lake-HX

Sashiko has reviewed this patch and found no issues.
Quoted 13 lines

From: Ali Alaei <[email protected]>

[ Upstream commit 72b32eccbcd591b9606edacf3bd7c455176d7660 ]

On Intel Arrow Lake-HX systems (e.g. Core Ultra 9 275HX on Acer Predator PH16-73), the VMD controller reports BUS_RESTRICT_CFG = 3 in the VMCONFIG register. The existing switch statement only handled values 0, 1, and 2, causing vmd_get_bus_number_start() to return -ENODEV and aborting the entire VMD probe. This leaves NVMe drives behind the VMD controller invisible to the kernel.

Hardware registers (VMCAP/VMCONFIG at offsets 0x40/0x44):

Quoted 8 lines

VMD 0000:00:0e.0 (8086:ad0b): VMCAP=0x000f, VMCONFIG=0x03b8 BUS_RESTRICT_CFG(0x03b8) = (0x03b8 >> 8) & 0x3 = 3

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author maintainer
#349 lore raw

PATCH 1/1 opp: Use clk_get_optional() to avoid leaving opp_table->clk as an error pointer

In reply to Sasha Levin

From: Praveen Talari <[email protected]>

[ Upstream commit 84f05af0975c9f9c8ffee0361d6f7cbb1f289231 ]

_update_opp_table_clk() uses clk_get(dev, NULL) to acquire the device's clock. On platforms where the perf domain device has no Linux clock and is instead managed entirely by firmware via devm_pm_opp_of_add_table() (through of_genpd_add_provider_simple()/onecell()), clk_get() returns -ENOENT. That case is treated as valid (the OPP table can still have entries sourced from firmware), but opp_table->clk is left holding ERR_PTR(-ENOENT) rather than being reset to NULL:

	opp_table->clk = clk_get(dev, NULL);
	ret = PTR_ERR_OR_ZERO(opp_table->clk);
	...
	if (ret == -ENOENT) {
		opp_table->clk_count = 1;
		return opp_table;   /* opp_table->clk is still ERR_PTR(-ENOENT) */
	}

Consumers that only check IS_ERR(opp_table->clk) treat this as a valid clk and pass it straight into the clk consumer API. In particular, dev_pm_opp_set_rate() calls clk_round_rate(opp_table->clk, target_freq), and clk_round_rate() only guards against a NULL clk, so it dereferences the error pointer to read clk->exclusive_count and crashes:

  Unable to handle kernel NULL pointer dereference at virtual
  address 000000000000002e
  ...
  pc : clk_round_rate+0x3c/0x188
  ...
  Call trace:
   clk_round_rate+0x3c/0x188 (P)
   dev_pm_opp_set_rate+0x114/0x33c

Rather than teaching every clk consumer API to special-case ERR_PTR(-ENOENT), fix it at the source: use clk_get_optional() instead of clk_get() in _update_opp_table_clk(), which already translates -ENOENT into a NULL clk. This documents that the clock is genuinely optional for such devices, and keeps opp_table->clk holding either a valid clk or NULL, never a lingering -ENOENT error pointer. _opp_config_clk_single() is only wired up via opp_table->config_clks when a clk was actually found, and every other opp_table->clk consumer already tolerates NULL through the standard clk API (which treats a NULL clk as a no-op), so no other call site needs to change.

---

LLM Generated explanations, may be completely bogus:

I have enough to decide: the crash path is in this 6.12 tree, the fix is small, and it should apply cleanly. Full analysis follows.

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

**Step 1.1: PARSE THE SUBJECT LINE**

Record: **[opp] [Use] Use clk_get_optional() so opp_table->clk is never left as ERR_PTR(-ENOENT).** Subsystem is the OPP core (drivers/opp/). “Use X to avoid Y” is a correctness fix, not a feature.

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**

Record:
- **Suggested-by:** Sebastian Reichel <[email protected]> (linux-pm / power maintainer)
- **Reviewed-by:** Sebastian Reichel <[email protected]>
- **Signed-off-by:** Praveen Talari <[email protected]> (author)
- **Signed-off-by:** Viresh Kumar <[email protected]> (OPP maintainer; applied the patch)
- **No Fixes:** tag (expected for this review pipeline)
- **No Cc: [email protected]** (expected; not a negative)
- **No Reported-by / Tested-by / Link / Acked-by**
- Pipeline markers ([Upstream commit …], Sasha Levin SOB) ignored per instructions

Upstream SHA (from public history, **not** in this tree):
84f05af0975c9f9c8ffee0361d6f7cbb1f289231.

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**

Record:
- **Bug:** _update_opp_table_clk() treats clk_get() returning -ENOENT as valid (firmware-managed / clockless OPP tables) but leaves opp_table->clk = ERR_PTR(-ENOENT).
- **Symptom:** kernel oops. dev_pm_opp_set_rate() calls clk_round_rate(opp_table->clk, …). clk_round_rate() only NULL- checks, then reads clk->exclusive_count. Error pointer wraps to a low address (000000000000002e in the report).
- **Stack:** clk_round_rate ← dev_pm_opp_set_rate
- **Trigger:** platforms whose perf-domain / OPP device has no Linux clock (devm_pm_opp_of_add_table() via of_genpd_add_provider_simple()/onecell()), then a consumer calls dev_pm_opp_set_rate().
- **Root cause:** consumers use IS_ERR() (true for -ENOENT) vs clk APIs that only accept NULL as “no clock”.
- **Fix:** clk_get_optional() maps -ENOENT → NULL at the source.

**Step 1.4: DETECT HIDDEN BUG FIXES**

Record: **Not hidden.** Explicit crash fix with a stack trace. Not cleanup/refactor-only.

===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================

**Step 2.1: INVENTORY THE CHANGES**

Record:
- **File:** drivers/opp/core.c only (+24 / -30 upstream)
- **Function:** _update_opp_table_clk()
- **Scope:** single-file surgical fix

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**

Record (this tree’s _update_opp_table_clk at
drivers/opp/core.c:1511):

**Before:**
1. opp_table->clk = clk_get(dev, NULL)
2. Success (ret == 0): set config_clks = _opp_config_clk_single, clk_count = 1
3. -ENOENT: set clk_count = 1, **leave clk as ERR_PTR(-ENOENT)**, return the table
4. Other errors: dev_pm_opp_put_opp_table(), dev_err_probe(), return ERR_PTR(ret)

**After:**
1. opp_table->clk = clk_get_optional(dev, NULL) (-ENOENT becomes NULL)
2. IS_ERR(clk): put table, dev_err_probe(), return ERR_CAST(clk) (real errors, e.g. -EPROBE_DEFER)
3. If clk is non-NULL: set config_clks
4. Always clk_count = 1 and return the table (clock present **or** optional-absent)

**Step 2.3: IDENTIFY THE BUG MECHANISM**

Record: **[Memory safety / NULL-vs-ERR_PTR] [Logic / correctness]**

Mechanism: ERR_PTR(-ENOENT) is not NULL. clk_round_rate() in this tree (drivers/clk/clk.c:1799) does if (!clk) return 0; then clk->exclusive_count. ERR_PTR(-2) plus offsetof(struct clk, exclusive_count) wraps to 0x2e, matching the oops. _find_current_opp and table release already use !IS_ERR(opp_table->clk) and therefore skip the error pointer; dev_pm_opp_set_rate() does not.

**Step 2.4: ASSESS THE FIX QUALITY**

Record:
- **Quality:** obviously correct. clk_get_optional() is the documented helper for this case (include/linux/clk.h:1195). config_clks is still only set when a real clk exists — same as before.
- **Surgical:** one helper, no API change.
- **Regression risk (low):**
- After NULL, early-return !IS_ERR(opp_table->clk) is true, so later lookups do not retry clk_get. Previously -ENOENT was IS_ERR and would retry. Correct for “no clock” devices.
- _find_current_opp may now call clk_get_rate(NULL) (returns 0)

    instead of skipping. Lowest available OPP vs first list entry;
    acceptable.

- Error path uses opp_table->clk **after** dev_pm_opp_put_opp_table(). Old code saved ret first. Theoretical UAF if the last ref frees the table before the PTR_ERR/ERR_CAST. Mainline accepted this; not the common -ENOENT success path.

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

**Step 3.1: BLAME THE CHANGED LINES**

Record:
- _update_opp_table_clk introduced in 32439ac7535a8 (“opp: Defer acquiring the clk until OPPs are added”, 2021-02-02).
- -ENOENT treated as valid in d4a4c7a41153d (“opp: Don't ignore clk_get() errors other than -ENOENT”, 2021-02-02) — **this is the commit that left the error pointer in the table**.
- ENOENT comment / clk_count = 1 / config_clks wiring from 2083da24eb56ce (“OPP: Allow multiple clocks for a device”, 2022-06-10).
- dev_pm_opp_set_rate() dropped its IS_ERR(clk) guard in 1d3c42cabbd35 (“opp: No need to check clk for errors”, 2021-01-20) — “Clock is not optional for users who call into dev_pm_opp_set_rate()”, which is false for firmware-managed clocks.

Bug present since ~v5.12, definitely in 6.12.

**Step 3.2: FOLLOW THE FIXES: TAG**

Record: **No Fixes: tag.** Introducers d4a4c7a41153d and 1d3c42cabbd35 **are both ancestors of HEAD**.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**

Record: Recent drivers/opp/core.c work is other OPP fixes (level, bandwidth, genpd). No later local rewrite of _update_opp_table_clk. **Standalone**, not “patch X/Y”.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**

Record: Praveen Talari has **no** prior commits in drivers/opp/ on this tree. Viresh Kumar (OPP maintainer) signed off and applied it. Sebastian Reichel suggested and reviewed.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**

Record:
- clk_get_optional() exists here: 60b8f0ddf1a92 (2019-02-06), include/linux/clk.h:1203.
- Function body in this tree **matches** the patch’s “before” hunk. **Standalone apply.**

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**

Record:
- b4 dig -c 84f05af0975c9f9c8ffee0361d6f7cbb1f289231 → https://patch.m
sgid.link/20260727-fix_ptr_check_on_clk-v4-1- [email protected]
- **v1:** guard clk_round_rate() against error pointers (and a drivers/clk/clk.c change)
- **v2:** per Reichel, fix OPP core with clk_get_optional(); drop clk- core change
- **v3:** add OPP maintainers
- **v4:** rebase; drop local ret (applied)
- Applied version is v4 (latest). No NAK. Viresh: “Applied. Thanks.” (only nit: extra --- in the changelog)

**Step 4.2: CHECK WHO REVIEWED THE PATCH**

Record (b4 dig -w): Viresh Kumar, Nishanth Menon, Stephen Boyd (OPP maintainers), Konrad Dybcio, Sebastian Reichel, linux-pm, linux-kernel, clk maintainer Boyd. Right audience.

**Step 4.3: SEARCH FOR THE BUG REPORT**

Record: No syzbot/bugzilla. Concrete oops in the message from a Qualcomm engineer. Real hardware, not theoretical.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**

Record: Single-patch series. v1’s clk-core change was dropped; this does not depend on other patches.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**

Record: **UNVERIFIED** for lore.kernel.org/stable (HTTP 403). No evidence this was rejected for stable.

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**

Record: _update_opp_table_clk() only.

**Step 5.2: TRACE CALLERS**

Record:
- Only caller: _add_opp_table_indexed() (core.c:1623)
- DT path _of_add_table_indexed() uses getclk=true (of.c:1150) — **every** dev_pm_opp_of_add_table() / devm_pm_opp_of_add_table() / genpd of_genpd_add_provider_simple() that adds an OPP table
- Also dev_pm_opp_add_dynamic() (core.c:2894, getclk=true)
- Crash consumer: dev_pm_opp_set_rate() (core.c:1352) — used by Qualcomm UART/SPI/MMC/GPU/Venus, Tegra, cpufreq-dt, panfrost/panthor/lima, etc.

**Step 5.3: TRACE CALLEES**

Record: clk_get → clk_get_optional; on hard error dev_pm_opp_put_opp_table + dev_err_probe. No new locks/allocs.

**Step 5.4: FOLLOW THE CALL CHAIN**

Record: Device probe (dev_pm_opp_of_add_table) → _update_opp_table_clk stores ERR_PTR(-ENOENT) → later dev_pm_opp_set_rate from driver/cpufreq/devfreq → oops. **Reachable from normal device operation**, not a debug-only path.

Verified clk NULL-safety in this tree:
- clk_round_rate: NULL → 0 (clk.c:1804)
- clk_get_rate: NULL → 0 (clk.c:2005)
- clk_set_rate: NULL → 0 (clk.c:2600)
- __clk_put: NULL returns immediately (clk.c:4748)

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**

Record: Other opp_table->clk users already use !IS_ERR() (_find_current_opp, kref release). set_rate is the one that passes the error pointer into clk APIs. Fixing storage is the right place (as Reichel requested).

===============================================================
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-2-gd38d58a4e0359). _update_opp_table_clk still uses clk_get(dev, NULL) and the -ENOENT early return (core.c:1526-1551). git merge-base --is-ancestor 84f05af0975c9f9c8ffee0361d6f7cbb1f289231 HEAD failed (not present). Bug since ~2021.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**

Record: **Clean apply.** Function text matches the patch context; only surrounding line numbers differ. clk_get_optional() already in include/linux/clk.h.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**

Record: d4a4c7a41153d (ENOENT allowed) and 1d3c42cabbd35 (set_rate dropped IS_ERR) are here. No clk_get_optional OPP commit. **No alternate fix.**

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**

Record: **OPP core** (drivers/opp/) — **IMPORTANT**. Shared by cpufreq, devfreq, DRM, MMC, serial, genpd performance states. Not staging.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**

Record: Mature (OPP since well before 6.12) with ongoing correctness fixes. This bug is old, not a brand-new subsystem.

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

**Step 8.1: DETERMINE WHO IS AFFECTED**

Record: **Config/driver-specific:** CONFIG_PM_OPP plus devices with an OPP table and **no** unnamed Linux clock, that then call dev_pm_opp_set_rate(). Includes firmware-managed perf domains (Qualcomm-class, genpd OPP). Not every box, but production SoCs.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**

Record: Probe adds OPP table (getclk=true); clk_get → -ENOENT; later dev_pm_opp_set_rate(). Common on clockless firmware DVFS, not every boot on x86. Not a syzbot/unprivileged syscall primitive; driver/cpufreq context.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**

Record: **Kernel oops / NULL deref** in clk_round_rate. **Severity:
CRITICAL** (crash; can strand DVFS/device).

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**

Record:
- **Benefit: HIGH** — prevents a real oops on clockless OPP devices; 6.12 LTS includes those platforms.
- **Risk: LOW** — ~50-line rewrite of one helper; clk_get_optional long-standing; success path equivalent except NULL vs ERR_PTR; clk APIs already NULL-safe.
- **Ratio: strongly favors backport.**

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

**Step 9.1: COMPILE THE EVIDENCE**

**FOR:**
- Real oops with stack trace (clk_round_rate ← dev_pm_opp_set_rate)
- Buggy pattern present in **this** 6.12 tree
- Small, obviously correct, no new API
- clk_get_optional already here
- Reviewed by Reichel; applied by Viresh
- Clean apply; no missing prerequisites

**AGAINST:**
- Affects firmware-managed / clockless OPP devices, not every machine
- Error-path opp_table->clk after put is slightly sloppier than the old local ret (not the crash path being fixed)
- No Fixes:/Cc:stable (irrelevant per pipeline rules)

**UNRESOLVED:**
- Could not fetch lore.kernel.org/stable (403)
- Could not fetch v1 body (403/404); changelog is enough
- Exact Qualcomm SoC in the oops not named in the v4 mail

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**

1. Obviously correct and tested? **PASS** — helper does exactly this; maintainer review + apply
2. Fixes a real bug that affects users? **PASS** — oops on clockless OPP
+ set_rate
3. Important issue? **PASS** — kernel crash (CRITICAL)
4. Small and contained? **PASS** — one function, one file
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — body matches; clk_get_optional present

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**

Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary crash fix; does not need an exception.

**Step 9.4: MAKE YOUR DECISION**

This is a real NULL-deref oops in OPP core that 6.12 still has. The fix maps “no clock” to NULL the way the clk API already documents, is tiny, and applies cleanly here. That is appropriate for this stable tree.

---

### What the commit solves (for this tree)

On 6.12.111, _update_opp_table_clk() still does clk_get(dev, NULL) and, on -ENOENT, keeps opp_table->clk as ERR_PTR(-ENOENT) while treating the table as valid. dev_pm_opp_set_rate() then passes that into clk_round_rate(), which only rejects NULL, and the kernel oopses. That is exactly the path firmware-managed / genpd OPP devices take when they have no Linux clock.

### Stable rules / risk

Meets the stable criteria: real crash, small, no new API, prerequisites already in 6.12. Benefit is avoiding an oops; risk is a one-function change whose success path is equivalent except storing NULL instead of an error pointer (what clk consumers already expect).

### Verification

- **[Phase 1]** Parsed tags: Suggested-by/Reviewed-by Reichel; SOB Talari + Viresh; no Fixes/Cc:stable
- **[Phase 1]** Body: oops at clk_round_rate ← dev_pm_opp_set_rate, address 0x2e
- **[Phase 2]** Diff: only _update_opp_table_clk; clk_get → clk_get_optional; -ENOENT → NULL; config_clks only if clk non- NULL
- **[Phase 2]** clk_round_rate in this tree: NULL check only, then clk->exclusive_count (clk.c:1804-1809)
- **[Phase 3]** Blame: -ENOENT keep-table from d4a4c7a41153d (in tree); set_rate dropped IS_ERR in 1d3c42cabbd35 (in tree)
- **[Phase 3]** clk_get_optional from 60b8f0ddf1a92 (2019), present
- **[Phase 3]** git merge-base --is-ancestor 84f05af HEAD → not in tree
- **[Phase 4]** b4 dig -c 84f05af → v4 msgid [email protected]
- **[Phase 4]** b4 dig -a: v1→v4; v2 switched to source fix per Reichel
- **[Phase 4]** b4 dig -w: OPP maintainers + linux-pm on To/Cc
- **[Phase 4]** mbox: Viresh “Applied. Thanks.”; no NAK
- **[Phase 5]** Caller: _add_opp_table_indexed ← DT add with getclk=true; crash via dev_pm_opp_set_rate
- **[Phase 5]** clk_get_rate/set_rate/put NULL-safe in this tree
- **[Phase 6]** git describe / Makefile: 6.12.111; buggy clk_get + -ENOENT block at core.c:1526-1551
- **[Phase 8]** Failure mode: oops, CRITICAL
- **UNVERIFIED:** stable@ lore (403); exact crash SoC; whether later mainline fixed the post-put opp_table->clk read

**YES**

 drivers/opp/core.c | 54 +++++++++++++++++++++-------------------------
 1 file changed, 24 insertions(+), 30 deletions(-)
drivers/opp/core.c +24 -30
index a179d57a5a150..a41ad136e90e0 100644
@@ -1579,8 +1579,6 @@ static struct opp_table *_update_opp_table_clk(struct device *dev,
 					       struct opp_table *opp_table,
 					       bool getclk)
 {
-	int ret;
-
 	/*
 	 * Return early if we don't need to get clk or we have already done it
 	 * earlier.
@@ -1589,39 +1587,35 @@ static struct opp_table *_update_opp_table_clk(struct device *dev,
 	    opp_table->clks)
 		return opp_table;
 
-	/* Find clk for the device */
-	opp_table->clk = clk_get(dev, NULL);
+	/*
+	 * There are few platforms which don't want the OPP core to manage
+	 * device's clock settings. In such cases neither the platform
+	 * provides the clks explicitly to us, nor the DT contains a valid
+	 * clk entry. The OPP nodes in DT may still contain "opp-hz" property
+	 * though, which we need to parse and allow the platform to find an
+	 * OPP based on freq later on.
+	 *
+	 * This is a simple solution to take care of such corner cases, i.e.
+	 * make the clk_count 1, which lets us allocate space for frequency
+	 * in opp->rates and also parse the entries in DT. Use
+	 * clk_get_optional() instead of clk_get() so opp_table->clk stays
+	 * NULL for such devices, instead of holding an ERR_PTR(-ENOENT) that
+	 * consumers must remember to special-case.
+	 */
+	opp_table->clk = clk_get_optional(dev, NULL);
 
-	ret = PTR_ERR_OR_ZERO(opp_table->clk);
-	if (!ret) {
-		opp_table->config_clks = _opp_config_clk_single;
-		opp_table->clk_count = 1;
-		return opp_table;
+	if (IS_ERR(opp_table->clk)) {
+		dev_pm_opp_put_opp_table(opp_table);
+		dev_err_probe(dev, PTR_ERR(opp_table->clk), "Couldn't find clock\n");
+		return ERR_CAST(opp_table->clk);
 	}
 
-	if (ret == -ENOENT) {
-		/*
-		 * There are few platforms which don't want the OPP core to
-		 * manage device's clock settings. In such cases neither the
-		 * platform provides the clks explicitly to us, nor the DT
-		 * contains a valid clk entry. The OPP nodes in DT may still
-		 * contain "opp-hz" property though, which we need to parse and
-		 * allow the platform to find an OPP based on freq later on.
-		 *
-		 * This is a simple solution to take care of such corner cases,
-		 * i.e. make the clk_count 1, which lets us allocate space for
-		 * frequency in opp->rates and also parse the entries in DT.
-		 */
-		opp_table->clk_count = 1;
-
-		dev_dbg(dev, "%s: Couldn't find clock: %d\n", __func__, ret);
-		return opp_table;
-	}
+	if (opp_table->clk)
+		opp_table->config_clks = _opp_config_clk_single;
 
-	dev_pm_opp_put_opp_table(opp_table);
-	dev_err_probe(dev, ret, "Couldn't find clock\n");
+	opp_table->clk_count = 1;
 
-	return ERR_PTR(ret);
+	return opp_table;
 }
 
 /*
Signature · 1 line
2.53.0
author maintainer
#350 lore raw

PATCH 1/1 selftests/filesystems/overlayfs: fix set_layers_via_fds link error

In reply to Sasha Levin

From: Christian Brauner <[email protected]>

[ Upstream commit e5804b1024193c91ff2648403beda882cb4f8b6c ]

set_layers_via_fds.c calls open_tree() directly, but that wrapper is not provided by all C libraries, so the test fails to link with "undefined reference to open_tree" on toolchains without it.

Use sys_open_tree() from ../wrappers.h, the syscall wrapper already used for move_mount(), fsmount() and friends here. This is also a prerequisite for building the new idmapped_mounts test added to this directory.

---

LLM Generated explanations, may be completely bogus:

I have enough to decide: this is a selftest link fix for code that already exists on 6.18.y, with a clean apply and no kernel runtime change.

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**
- Record: [selftests/filesystems/overlayfs] [fix] [replace libc open_tree() with sys_open_tree() so the test links]

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- `Link: https://patch.msgid.link/20260615-work-idmapped-
[email protected]` — lore/msgid for patch 8/10 of the idmapped overlayfs series
- Reviewed-by: Amir Goldstein <[email protected]> — overlayfs maintainer
- Signed-off-by: Christian Brauner (Amutable) <[email protected]> — VFS maintainer / author
- Pipeline-only (ignored for selection): [Upstream commit e5804b1024193c91ff2648403beda882cb4f8b6c], Signed-off-by: Sasha Levin
- Absent (expected): Fixes:, Cc: [email protected], Reported- by:, Tested-by:, syzbot

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Record: `[Bug] set_layers_via_fds.c calls libc open_tree(), which some C libraries do not provide. [Symptom] link failure: "undefined reference to open_tree". [Version info] none. [Root cause] the test already uses sys_fsopen/sys_fsmount/sys_move_mount from wrappers.h, but this one test used the libc name instead of sys_open_tree(). The message also says the change is a prerequisite for a new idmapped_mounts test.`

**Step 1.4: DETECT HIDDEN BUG FIXES**
- Record: `[Not a hidden fix] The subject and body state a link error. That is a real userspace build failure of an existing kselftest, not a disguised kernel runtime bug. The "prerequisite for idmapped_mounts" line is extra context for a later new test, not the bug being fixed here.`

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES**
- Record: `[Files] tools/testing/selftests/filesystems/overlayfs/set_layers_via_fds.c (+8/-8). [Function] TEST_F(set_layers_via_fds, set_layers_via_detached_mount_fds) only. [Scope] single-file surgical rename, 8 call sites.]`

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
- Record: `[Before] eight open_tree(dfd, path, OPEN_TREE_CLONE|OPEN_TREE_CLOEXEC) calls (libc symbol). [After] the same arguments via sys_open_tree(), the local syscall wrapper. [Path] userspace selftest setup for detached overlay layer mounts. No kernel path, no error-path logic change, no flag change.]`

**Step 2.3: IDENTIFY THE BUG MECHANISM**
- Record: `[Category] build / link error (portability). [Mechanism] unresolved libc symbol on C libraries without open_tree(); sys_open_tree() already exists in wrappers.h and issues syscall(__NR_open_tree, ...).]`

**Step 2.4: ASSESS THE FIX QUALITY**
- Record: `[Quality] obviously correct: same arguments, wrapper already used for the other new-mount syscalls in this file, OPEN_TREE_* already defined in wrappers.h. [Regression risk] very low. syscall() and libc open_tree() both return fd or -1/errno; the test already uses ASSERT_GE(fd, 0). No kernel ABI, locking, or API change.]`

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**
- Record: `[Introduced by] ccc829b15d48a ("selftests: add tests for using detached mount with overlayfs", 2025-02-12). [Present in this tree] yes (ancestor of v6.18.53). The test file itself dates to af9199145b197 (2024-10-14).]`

**Step 3.2: FOLLOW THE FIXES: TAG**
- Record: [N/A] No Fixes: tag. The intro commit is ccc829b15d48a, confirmed via blame on v6.18.53.]

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
- Record: `[Related] 0bd92b9fe538b moved wrappers.h to tools/testing/selftests/filesystems/wrappers.h (already in v6.18.53). Next commit 226c30d522a3b adds idmapped_mounts.c (new test, not in v6.18.53). [Standalone] this rename does not need the new test.]`

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
- Record: [Author] Christian Brauner, VFS maintainer, overlayfs contributor. [Related] authored the original detached-mount test and the later idmapped overlayfs series. Not a drive-by change.]

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
- Record: `[Dependencies] sys_open_tree() and #include "../wrappers.h" already exist at v6.18.53. Parent file vs v6.18.53 file: 0-line diff. [Standalone] yes for this tree. The new idmapped_mounts test is not required.]`

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
- Record: `[Lore] https://patch.msgid.link/20260615-work-idmapped-
[email protected] . [Series] v1 only (10 patches, "ovl: support idmapped overlay mounts"). This is 08/10. [Review] no NAK on this patch. Amir Goldstein Reviewed-by on the whole series ("the entire series looks good to me"). His risk comments were about FS_ALLOW_IDMAP on overlayfs itself, not this selftest rename. [Stable nomination] none in the thread.]`

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
- Record: [Recipients] Miklos Szeredi, Amir Goldstein, linux-unionfs, linux-fsdevel. [Reviewer] Amir Goldstein (overlayfs maintainer) gave series-wide Reviewed-by.]

**Step 4.3: SEARCH FOR THE BUG REPORT**
- Record: [No Reported-by / bugzilla / syzbot] The failure is described by the author as a link error. No independent user report found.]

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
- Record: `[Series] 01–07/10 and 10/10 are overlayfs idmapped-mount kernel/docs features. 09/10 is the new idmapped_mounts selftest. Those are new functionality and are not in v6.18.53 (no FS_ALLOW_IDMAP on overlay in this tree; no idmapped_mounts.c). This 08/10 patch is independently a fix to an existing test.]`

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
- Record: `[UNVERIFIED for lore.kernel.org/stable] WebFetch returned
403. b4 dig of the original thread found no stable@ discussion.]`

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: IDENTIFY KEY FUNCTIONS**
- Record: [Modified] TEST_F(set_layers_via_fds, set_layers_via_detached_mount_fds) in userspace kselftest. [Added] none. semcode MCP not available; identified from @@ hunks.]

**Step 5.2: TRACE CALLERS**
- Record: [Callers] kselftest harness TEST_HARNESS_MAIN / fixture runner when executing the set_layers_via_fds binary. Not in-kernel. Not interrupt or syscall-kernel context.]

**Step 5.3: TRACE CALLEES**
- Record: [sys_open_tree] syscall(__NR_open_tree, dfd, filename, flags) in wrappers.h. Same as other sys_* helpers already used in this file (sys_fsopen, sys_fsmount, sys_move_mount, sys_fsconfig).]

**Step 5.4: FOLLOW THE CALL CHAIN**
- Record: `[Reachability] only when a developer/CI builds and runs overlayfs kselftests (typically root, CONFIG_OVERLAY_FS). Not a production kernel path. The link failure happens at test build time, before the test runs.]`

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
- Record: `[This tree at v6.18.53] the only remaining libc open_tree() uses in tools/testing/selftests besides this file are landlock/fs_test.c, which defines its own local open_tree() wrapper. Overlayfs tests were already supposed to use sys_open_tree(). Earlier overlayfs selftest build fixes already in this tree: e8b8c5264d4eb (ppc64 format), 0f05ee447949c (mount.h / sys_mount).]`

## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
- Record: `[Tree] Makefile VERSION=6 PATCHLEVEL=18 SUBLEVEL=53; git describe HEAD = v6.18.53-5049-g0f0bdc2b0dffb; branch autosel. [v6.18.53] set_layers_via_fds.c exists and has all 8 open_tree() calls. wrappers.h already has sys_open_tree() and OPEN_TREE_CLONE/CLOEXEC. Include of ../wrappers.h is already present. [Bug introduced] ccc829b15d48a, in this series.]`

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
- Record: [Difficulty] clean apply. git diff v6.18.53 088318c9d7a6e^ -- set_layers_via_fds.c is empty. Applying the commit patch onto a copy of the v6.18.53 file: APPLY_CLEAN.]

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
- Record: [No equivalent fix in v6.18.53] still uses open_tree(). Candidate 088318c9d7a6e is on autosel only, not in v6.18.53 (git merge-base --is-ancestor 088318c9d7a6e v6.18.53 → not an ancestor).]

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
- Record: `[Subsystem] kselftests for overlayfs (tools/testing/selftests/filesystems/overlayfs/). [Criticality] PERIPHERAL for production runtime; IMPORTANT for overlayfs regression testing of this LTS tree. Overlayfs itself is a widely used fs (containers), but this commit does not touch fs/overlayfs/.]`

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
- Record: [Activity] overlayfs selftests were added/extended through 6.15 (fd mounts, detached mounts, override_creds). Relatively new tests, still the ones this 6.18.y tree ships. Kernel overlayfs is mature.]

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: DETERMINE WHO IS AFFECTED**
- Record: `[Affected] people/CI building overlayfs kselftests on a C library without libc open_tree() (author: "not provided by all C libraries"). Not universal kernel users. UNVERIFIED which specific libc versions still lack it in 2026; glibc added open_tree in 2.36, so musl/older glibc are the plausible cases.]`

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
- Record: `[Trigger] building TEST_GEN_PROGS set_layers_via_fds (Makefile already lists it). Common for anyone running these selftests. Unprivileged users are not a security concern; this is a link failure, not a runtime exploit.]`

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
- Record: `[Failure] userspace link error; the kernel still builds and boots. Test binary is not produced, so that overlayfs selftest cannot be run. [Severity] LOW for production runtime, MEDIUM for stable- kernel testability. Matches the documented "build error" class, not oops/corruption/deadlock.]`

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
- Record: `[Benefit] medium for testers of this tree (existing test becomes buildable everywhere the rest of this directory already builds). [Risk] very low: 8 identifier substitutions, no kernel change, wrapper already in tree. [Ratio] favorable if build fixes for existing selftests are in scope; this one is.]`

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

FOR backporting:
- Real link failure of an existing test in this 6.18.y tree
- Documentation/process/stable-kernel-rules.rst explicitly lists build errors as acceptable
- 8-line surgical change, obviously correct
- sys_open_tree() and wrappers.h already present; applies cleanly
- Overlayfs maintainer Reviewed-by
- Same class of fix as e8b8c5264d4eb / 0f05ee447949c already in this lineage
- No kernel runtime regression surface

AGAINST:
- Not a kernel crash, security hole, or data-corruption fix
- Lives in a 10-patch new-feature series; 09/10 and the kernel idmap work must not be pulled with it
- No independent user/syzbot report
- Only testers building kselftests benefit

UNRESOLVED:
- Exact C libraries that still lack open_tree() in 2026 (author claim, not independently enumerated)
- No stable@ thread found (lore stable search 403)

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — rename to an existing wrapper; reviewed by Amir Goldstein
2. Fixes a real bug that affects users? **PASS** — existing kselftest fails to link on some toolchains
3. Important issue (crash, security, corruption, deadlock)? **PASS** under the documented build-error clause, not under crash/security
4. Small and contained? **PASS** — 8 lines, one file, one test
5. No new features or APIs? **PASS** — no new test, no kernel API; the later idmapped_mounts test is a different commit
6. Can apply to the local tree? **PASS** — v6.18.53 file matches the parent; apply check clean

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
- Record: [Exception] BUILD FIX for an existing in-tree selftest. Not a device ID, quirk, DT, or docs-only change.]

**Step 9.4: MAKE YOUR DECISION**

This should be backported to this 6.18.y tree. The bug is in the tree, the wrapper is in the tree, and the patch only makes an existing overlayfs selftest match the sys_* calling convention the rest of the file already uses. The idmapped-overlay feature series around it is irrelevant here: that feature and its new test are not in v6.18.53 and are not part of this diff.

### What the commit solves and why it matters here set_layers_via_fds is already built on 6.18.y (TEST_GEN_PROGS += set_layers_via_fds). One fixture still calls libc open_tree(), so the binary fails to link where that symbol is missing. Switching to sys_open_tree() fixes that with no kernel change.

### Stable rules
It is small, obviously correct, and a build error. It does not add features or APIs.

### Risk vs benefit
Risk is negligible (userspace identifier change). Benefit is that overlayfs kselftests for this LTS tree can actually be built on the same toolchains the wrappers were written for.

### Concerns
Do not pull 09/10 (idmapped_mounts.c) or the overlay FS_ALLOW_IDMAP kernel patches with this; they implement a new feature this tree does not have. This commit does not require them.

Verification:
- [Phase 1] Parsed tags: Link to patch 8/10, Reviewed-by Amir Goldstein, SOB Christian Brauner; no Fixes/Cc:stable/Reported-by
- [Phase 1] Body: link error "undefined reference to open_tree"; also mentions idmapped_mounts prerequisite
- [Phase 2] Diff: 8 open_tree → sys_open_tree in set_layers_via_detached_mount_fds; +8/-8 one file
- [Phase 2] wrappers.h: sys_open_tree() = syscall(__NR_open_tree, ...); OPEN_TREE_CLONE/CLOEXEC defined
- [Phase 3] git describe HEAD: v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion 6.18.53
- [Phase 3] git merge-base --is-ancestor 088318c9d7a6e v6.18.53: NOT in v6.18.53
- [Phase 3] git blame v6.18.53: open_tree() lines from ccc829b15d48a (2025-02-12), present in this tree
- [Phase 3] git diff v6.18.53 vs commit parent for this file: 0 lines (identical)
- [Phase 3] idmapped_mounts.c: not in v6.18.53; FS_ALLOW_IDMAP not set on overlay in this tree
- [Phase 4] b4 dig -c e5804b1024193c91ff2648403beda882cb4f8b6c: matched 08/10 of ovl idmapped series
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: Miklos Szeredi, Amir Goldstein, linux-unionfs, linux-fsdevel
- [Phase 4] b4 dig -m: Amir series-wide Reviewed-by; risk comments were about kernel FS_ALLOW_IDMAP, not this patch; no NAK on 08/10
- [Phase 4] lore WebFetch 403; stable list search 403 — UNVERIFIED beyond the saved mbox
- [Phase 5] semcode unavailable; callers are kselftest harness only
- [Phase 5] git grep v6.18.53: only this file plus landlock (local wrapper) use open_tree() in selftests
- [Phase 6] v6.18.53 has the 8 open_tree() calls and ../wrappers.h include; patch apply onto that file: APPLY_CLEAN
- [Phase 7] tools/testing/selftests/filesystems/overlayfs; not fs/overlayfs
- [Phase 8] Failure mode: userspace link error; severity LOW runtime / build-error class
- UNVERIFIED: exact C libraries lacking open_tree() in 2026; no stable@ thread (403)

**YES**

 .../filesystems/overlayfs/set_layers_via_fds.c   | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
tools/testing/selftests/filesystems/overlayfs/set_layers_via_fds.c +8 -8
index dc0449fa628f8..d4a645ec88636 100644
@@ -624,7 +624,7 @@ TEST_F(set_layers_via_fds, set_layers_via_detached_mount_fds)
 
 	ASSERT_EQ(sys_move_mount(fd_tmpfs, "", -EBADF, "/set_layers_via_fds_tmpfs", MOVE_MOUNT_F_EMPTY_PATH), 0);
 
-	fd_tmp = open_tree(fd_tmpfs, "u", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
+	fd_tmp = sys_open_tree(fd_tmpfs, "u", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
 	ASSERT_GE(fd_tmp, 0);
 
 	layer_fds[0] = openat(fd_tmp, "upper", O_CLOEXEC | O_DIRECTORY | O_PATH);
@@ -633,25 +633,25 @@ TEST_F(set_layers_via_fds, set_layers_via_detached_mount_fds)
 	layer_fds[1] = openat(fd_tmp, "work", O_CLOEXEC | O_DIRECTORY | O_PATH);
 	ASSERT_GE(layer_fds[1], 0);
 
-	layer_fds[2] = open_tree(fd_tmpfs, "l1", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
+	layer_fds[2] = sys_open_tree(fd_tmpfs, "l1", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
 	ASSERT_GE(layer_fds[2], 0);
 
-	layer_fds[3] = open_tree(fd_tmpfs, "l2", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
+	layer_fds[3] = sys_open_tree(fd_tmpfs, "l2", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
 	ASSERT_GE(layer_fds[3], 0);
 
-	layer_fds[4] = open_tree(fd_tmpfs, "l3", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
+	layer_fds[4] = sys_open_tree(fd_tmpfs, "l3", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
 	ASSERT_GE(layer_fds[4], 0);
 
-	layer_fds[5] = open_tree(fd_tmpfs, "l4", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
+	layer_fds[5] = sys_open_tree(fd_tmpfs, "l4", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
 	ASSERT_GE(layer_fds[5], 0);
 
-	layer_fds[6] = open_tree(fd_tmpfs, "d1", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
+	layer_fds[6] = sys_open_tree(fd_tmpfs, "d1", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
 	ASSERT_GE(layer_fds[6], 0);
 
-	layer_fds[7] = open_tree(fd_tmpfs, "d2", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
+	layer_fds[7] = sys_open_tree(fd_tmpfs, "d2", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
 	ASSERT_GE(layer_fds[7], 0);
 
-	layer_fds[8] = open_tree(fd_tmpfs, "d3", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
+	layer_fds[8] = sys_open_tree(fd_tmpfs, "d3", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
 	ASSERT_GE(layer_fds[8], 0);
 
 	ASSERT_EQ(close(fd_tmpfs), 0);
Signature · 1 line
2.53.0
author maintainer
#351 lore raw

PATCH 1/1 nfc: mrvl: spi: Unregister dev on allocation fail

In reply to Sasha Levin

From: Griffin Kroah-Hartman <[email protected]>

[ Upstream commit d832b95697384a2b67f20b35106bbf925358cde9 ]

Call nfcmrvl_nci_unregister_dev() if nci_spi_allocate_spi() fails, unwrapping the previous call to nfcmrvl_nci_register_dev() during the nfcmrvl_spi_probe() function.

---

LLM Generated explanations, may be completely bogus:

This is a four-line probe error-path fix for a real NULL-deref in the Marvell NFC-over-SPI driver. The buggy code is in this 6.12 tree and has been there since v4.4.

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

Step 1.1: PARSE THE SUBJECT LINE
Record: [nfc: mrvl: spi:] [Unregister] [On nci_spi_allocate_spi() failure, unregister the NCI device previously registered in probe]

Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record: Tags from d832b95697384 (git show --format=fuller):
- Assisted-by: gkh-clanker-2000 (AI-assisted)
- Cc: David Heidelberg <[email protected]>
- Signed-off-by: Griffin Kroah-Hartman <[email protected]> (author)
- Signed-off-by: Greg Kroah-Hartman <[email protected]>
- Link: https://patch.msgid.link/2026070716-crucial-slouchy-b8a9@gregkh
- Signed-off-by: David Heidelberg <[email protected]> (applied)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Cc:
stable (absence expected)

Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: nfcmrvl_spi_probe() calls nfcmrvl_nci_register_dev(), then nci_spi_allocate_spi(), and ignores a NULL return.
- Symptom: probe still returns 0, so the SPI driver binds with drv_data->nci_spi == NULL. The NCI device stays registered. IRQ/nci_send then dereference NULL.
- Version info: none in the message. Introducer is caf6e49bf6d02e ("NFC: nfcmrvl: add spi driver"), first in v4.4-rc1.
- Root cause: missing failure check after nci_spi_allocate_spi(). The unregister is required because returning -ENOMEM skips nfcmrvl_spi_remove().

Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not disguised. It is an explicit error-path fix: missing allocation check plus missing rollback of nfcmrvl_nci_register_dev().

===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================

Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/nfc/nfcmrvl/spi.c (+4 / -0)
- Function: nfcmrvl_spi_probe()
- Scope: single-file surgical error-path fix

Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record: Current local probe (lines 160–174 of
drivers/nfc/nfcmrvl/spi.c):

```160:174:drivers/nfc/nfcmrvl/spi.c
        drv_data->priv = nfcmrvl_nci_register_dev(NFCMRVL_PHY_SPI,
                                                  drv_data, &spi_ops,
                                                  &drv_data->spi->dev,
                                                  pdata);
        if (IS_ERR(drv_data->priv))
                return PTR_ERR(drv_data->priv);

        drv_data->priv->support_fw_dnld = true;

        drv_data->nci_spi = nci_spi_allocate_spi(drv_data->spi, 0, 10,
                                                 drv_data->priv->ndev);

        /* Init completion for slave handshake */
        init_completion(&drv_data->handshake_completion);
        return 0;
```

Before: NULL from nci_spi_allocate_spi() is ignored; probe returns 0.
After: if NULL, call nfcmrvl_nci_unregister_dev(drv_data->priv) and return -ENOMEM.
Path: probe error path only, after a successful nfcmrvl_nci_register_dev().

Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Category: (a) error-path resource leak + (d) memory safety (NULL deref)
- Mechanism: nci_spi_allocate_spi() (net/nfc/nci/spi.c:124-143) is devm_kzalloc() and returns NULL on failure. The only caller is this probe. IRQ thread nfcmrvl_spi_int_irq_thread_fn does nci_spi_read(drv_data->nci_spi) with no NULL check; __nci_spi_read() then uses nspi->acknowledge_mode. nfcmrvl_spi_nci_send() / nfcmrvl_spi_nci_update_config() likewise dereference nci_spi. Returning -ENOMEM without unregister would leak the NCI device, GPIO, fw_dnld state, and kzalloc'd nfcmrvl_private (not devm-managed).

Step 2.4: ASSESS THE FIX QUALITY
Record: Obviously correct and minimal. Same nfcmrvl_nci_unregister_dev() already used in nfcmrvl_spi_remove(). IRQ is devm_request_threaded_irq, so it is released on probe failure. Regression risk is low. Residual window: IRQ can still fire between unregister and devm unwind (same pattern as remove). That is better than binding with a permanent NULL nci_spi.

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

Step 3.1: BLAME THE CHANGED LINES
Record: git blame on drivers/nfc/nfcmrvl/spi.c lines 160–174: all from caf6e49bf6d02e (Vincent Cuissard, 2015-10-26), "NFC: nfcmrvl: add spi driver". First tagged in v4.4-rc1. Present and unchanged in this tree.

Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Introducer identified by blame: caf6e49bf6d02e. git merge-base --is-ancestor caf6e49bf6d02e HEAD → in this tree. git merge-base --is-ancestor d832b95697384 HEAD → not in this tree.

Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: Recent local history of spi.c is style/DT/SPI-remove-void only (e3c95d56190c9, 5a478a653b4cc, a0386bba70934). No prior attempt to check nci_spi_allocate_spi(). Standalone; not patch X/Y. Follow-ups on origin/master after this commit are only ID-table style (777fd2dab4460 etc.), not corrections of this fix.

Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Griffin Kroah-Hartman is not the NFC maintainer. Same-day
sibling: 56345cea6a30d "nfc: nxp-nci: Add remove on IRQ error" (same AI assist, same applier). This 6.12 MAINTAINERS NFC entry is Krzysztof Kozlowski. The commit landed via Merge tag 'nfc-net-next-20260817' from codeberg.org/linux-nfc (David Heidelberg SOB).

Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: Uses only nfcmrvl_nci_unregister_dev() and nci_spi_allocate_spi(), both present here. git apply --check of d832b95697384 on this tree succeeded. Standalone.

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record: b4 dig -c d832b95697384 →
https://patch.msgid.link/2026070716-crucial-slouchy-b8a9@gregkh
- b4 dig -a: v1 only, 2026-07-07, from Greg Kroah-Hartman
- Saved mbox: only the original patch email; no replies, NAKs, or reviewer-requested Cc: stable
- Applied as submitted

Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: b4 dig -w recipients: Greg Kroah-Hartman, oe-linux- [email protected], [email protected], Griffin Kroah- Hartman, David Heidelberg. No Reviewed-by. David Heidelberg's SOB is the maintainer apply. Krzysztof Kozlowski was not on this patch's To/Cc (he was on the sibling nxp-nci patch).

Step 4.3: SEARCH FOR THE BUG REPORT
Record: No Reported-by, bugzilla, or syzbot. No user-filed report found. Bug is from code inspection.

Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Same-day Griffin/Greg NFC error-path patch 56345cea6a30d for nxp-nci. Not a functional dependency. nci_spi_allocate_spi() has no other callers.

Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: UNVERIFIED. lore.kernel.org/stable is behind Anubis (bot challenge). No stable discussion in the b4 mbox.

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: nfcmrvl_spi_probe() only. Calls added:
nfcmrvl_nci_unregister_dev().

Step 5.2: TRACE CALLERS
Record:
- nfcmrvl_spi_probe ← spi_driver.probe (nfcmrvl_spi_driver), device enumeration for marvell,nfc-spi / nfcmrvl_spi
- nfcmrvl_nci_unregister_dev already called from nfcmrvl_spi_remove, and from uart/i2c/usb counterparts
- IRQ nfcmrvl_spi_int_irq_thread_fn is the crash path if nci_spi is NULL after a “successful” probe

Step 5.3: TRACE CALLEES
Record: nfcmrvl_nci_unregister_dev() (main.c:182-197) calls nci_unregister_device, optional nfcmrvl_fw_dnld_abort, nfcmrvl_fw_dnld_deinit, GPIO free, nci_free_device, kfree(priv). Appropriate after a successful register.

Step 5.4: FOLLOW THE CALL CHAIN
Record: Probe of DT/SPI Marvell NFC (8897-class). Not a syscall. After a buggy successful probe, NFC netlink/userspace I/O and the falling-edge IRQ are live. Unprivileged trigger of the OOM itself: no. Crash after
bind: yes, if the chip asserts SPI_INT or userspace talks to the NFC device.

Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: i2c/usb/uart register last in probe, so they do not have this post-register allocation. This SPI path is unique. Same class of NFC error-path leaks already in this tree: 8a4d480702b71, e204ead35401a, bb55dc2ae4367.

===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================

Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. Tree is 6.12.111 (p-6.12-3-gc504cf0baa3d8). Buggy sequence is in drivers/nfc/nfcmrvl/spi.c:169-174. Introduced v4.4-rc1. Fix d832b95697384 is not an ancestor of HEAD (landed in v7.3-rc1).

Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Clean apply. git apply --check succeeded. Later mainline ID- table style commits do not touch this hunk.

Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No equivalent check. git log --grep on this path found no prior “nci_spi_allocate_spi fails” fix.

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [drivers/nfc/nfcmrvl] [PERIPHERAL] — Marvell NFC-over-SPI (CONFIG_NFC_MRVL_SPI), DT compatible marvell,nfc-spi. Not core mm/net, but a shipped production driver.

Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mature/low-churn. Driver added 2015; 6.12 changes are mostly style and small fixes. Bug is long-standing, not a new-code race.

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver-specific / config-specific: CONFIG_NFC_MRVL_SPI users with Marvell NFC SPI hardware (embedded/ARM boards using marvell,nfc- spi).

Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: devm_kzalloc(sizeof(struct nci_spi)) failure during probe (GFP_KERNEL). Rare except under memory pressure. Not unprivileged-OOM- as-exploit in the usual sense; once bound, IRQ or NFC I/O oopses.

Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- Failure: kernel oops (NULL nci_spi in IRQ/nci_spi_send/nci_spi_read)
- Secondary: if probe were failed without unregister, leaked registered NCI device + GPIO + priv
- Severity: HIGH on trigger (oops); trigger likelihood LOW

Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: medium for affected hardware (prevents oops and a leftover NFC device); population is small
- Risk: very low (4 lines, established unregister helper, error path only)
- Ratio: favorable — cheap, obviously correct crash/leak fix

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real bug in this tree: ignored NULL from nci_spi_allocate_spi(), probe returns 0
- Verified crash path: IRQ and send dereference nci_spi with no NULL check
- Unregister is required once probe fails, matching remove()
- 4 lines, applies cleanly, no new API, no prerequisites
- Bug present since v4.4
- Same unregister helper already in this tree (d270453a0d9ec reordering already applied)

AGAINST:
- Niche SPI NFC driver
- Trigger is a small GFP_KERNEL alloc failure
- No Reported-by / syzbot / Tested-by
- AI-assisted; mailing list thread has no review replies
- Not a hot path for most 6.12 users

UNRESOLVED:
- No stable-list discussion (lore Anubis)
- No public user report of this oops

Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — logic matches remove(); applied upstream by the NFC tree. No extra runtime test evidence.
2. Fixes a real bug that affects users? PASS — missing alloc check leaves a bound driver with NULL nci_spi.
3. Important issue? PASS — kernel oops on IRQ/send after a failed alloc; also a registered-device leak if probe is failed without rollback. Severity HIGH on trigger, rare.
4. Small and contained? PASS — +4 lines, 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: None (not an ID/quirk/DT/build/docs exception). Qualifies as a normal small bugfix.

Step 9.4: MAKE YOUR DECISION
This is a small, obviously correct error-path fix for a NULL dereference that exists in 6.12. Rarity of the alloc failure does not make the oops fictional, and the rollback is the same path remove() already uses. Benefit outweighs risk.

What it solves for stable users: if nci_spi_allocate_spi() fails during Marvell NFC SPI probe, 6.12 currently treats probe as success. The IRQ thread and NCI send path then oops on NULL. The patch fails probe with -ENOMEM and unregisters the NCI device so priv/GPIO/nci_dev are not left behind.

Risk vs benefit: four lines on an error path; apply is clean; no locking or API change. Niche hardware, but the failure mode is a crash, which stable is meant to take.

Verification:
- [Phase 1] git show d832b95697384 --format=fuller: tags listed above; no Fixes/Reported-by/Cc stable
- [Phase 1] make kernelversion / Makefile: 6.12.111; git describe HEAD: p-6.12-3-gc504cf0baa3d8
- [Phase 2] Read drivers/nfc/nfcmrvl/spi.c probe/IRQ/send; confirmed no NULL check on nci_spi
- [Phase 2] Read net/nfc/nci/spi.c nci_spi_allocate_spi: only failure is devm_kzalloc → NULL
- [Phase 2] Read nci_spi_read/__nci_spi_read: dereference nspi->acknowledge_mode with no NULL guard
- [Phase 2] Read nfcmrvl_nci_register_dev/unregister_dev: priv is kzalloc, not devm; unregister is the correct rollback
- [Phase 3] git blame -L 140,200 drivers/nfc/nfcmrvl/spi.c: introducer caf6e49bf6d02e (2015)
- [Phase 3] git describe --contains caf6e49bf6d02e: v4.4-rc1
- [Phase 3] git merge-base --is-ancestor caf6e49bf6d02e HEAD: yes; d832b95697384 HEAD: no
- [Phase 3] git describe --contains --match 'v*' d832b95697384:
v7.3-rc1~133^2~2^2~15
- [Phase 3] git log origin/master --oneline --grep="Unregister dev on allocation fail" -- drivers/nfc/nfcmrvl/spi.c: found d832b95697384
- [Phase 4] b4 dig -c/-a/-w/-m: v1-only thread, no replies in mbox
- [Phase 4] lore.kernel.org/stable via curl: Anubis challenge, UNVERIFIED
- [Phase 5] git grep nci_spi_allocate_spi: sole caller is this probe
- [Phase 6] git show d832b95697384 -- drivers/nfc/nfcmrvl/spi.c | git apply --check: clean
- [Phase 6] git diff HEAD origin/master -- drivers/nfc/nfcmrvl/spi.c:
only this hunk plus later ID-table style
- [Phase 8] Failure mode: NULL deref → oops after probe “succeeds”; severity HIGH, trigger LOW
- UNVERIFIED: whether this SHA was discussed on stable@; no user-visible oops report found

**YES**

 drivers/nfc/nfcmrvl/spi.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/nfc/nfcmrvl/spi.c +4 -0
index 9c8cde1250fb5..dad07c8e13b84 100644
@@ -168,6 +168,10 @@ static int nfcmrvl_spi_probe(struct spi_device *spi)
 
 	drv_data->nci_spi = nci_spi_allocate_spi(drv_data->spi, 0, 10,
 						 drv_data->priv->ndev);
+	if (!drv_data->nci_spi) {
+		nfcmrvl_nci_unregister_dev(drv_data->priv);
+		return -ENOMEM;
+	}
 
 	/* Init completion for slave handshake */
 	init_completion(&drv_data->handshake_completion);
Signature · 1 line
2.53.0
author maintainer
#352 lore raw

PATCH 1/1 gpio: pca9570: Use I2C match data

In reply to Sasha Levin

From: Pengpeng Hou <[email protected]>

[ Upstream commit 415c63896b76fd98883e190bc7518383cb01779c ]

The driver stores chip metadata in both the OF match table and the I2C id table, but probe currently reads it with device_get_match_data(). That helper only returns firmware-node match data, so an I2C-id/modalias match can leave chip_data NULL before the driver dereferences it to read ngpio.

Use i2c_get_match_data() so the I2C id table driver_data is consumed when firmware match data is not present.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit message forensics

**Step 1.1: Subject line**
- Record: [gpio/pca9570] [Use] Switch probe from firmware-only match data to I2C match data so I2C-id/modalias binds get chip metadata

**Step 1.2: Tags**
- Record:
- Fixes:: none (expected for this review)
- Reported-by:: none
- Tested-by:: none
- Reviewed-by:: none
- Acked-by:: none
- Link: https://patch.msgid.link/20260624053744.72612-1- [email protected]
- Cc: stable: none (expected)
- Signed-off-by: Pengpeng Hou <[email protected]> (author)
- Signed-off-by: Bartosz Golaszewski <[email protected]> (GPIO maintainer)
- Pipeline Signed-off-by: Sasha Levin / `[Upstream commit

    415c63896b76...]` ignored per instructions

**Step 1.3: Body**
- Record: [Bug] Probe uses device_get_match_data() while chip metadata lives in both OF and I2C id tables. That helper only returns firmware- node data. [Symptom] I2C-id/modalias bind leaves chip_data NULL; probe then reads chip_data->ngpio. [Versions] None stated. [Root cause] Wrong match-data helper; I2C id table driver_data is never consumed.

**Step 1.4: Hidden bug fix?**
- Record: This is an explicit bug fix, not cleanup. The subject says “Use” rather than “fix”, but the body describes a NULL dereference on probe.

## Phase 2: Diff analysis

**Step 2.1: Inventory**
- Record: [Files] drivers/gpio/gpio-pca9570.c: 1 insertion, 1 deletion [Function] pca9570_probe() [Scope] Single-file, one-line surgical change

The candidate as applied on this tree is exactly that one-line swap. Mainline context around devm_mutex_init() is not in 6.18.y (mutex_init() is still used here); it does not affect the hunk.

**Step 2.2: Code flow**
- Record: [Before] gpio->chip_data = device_get_match_data(&client->dev); then gpio->chip.ngpio = gpio->chip_data->ngpio; [After] Same dereference, but chip_data comes from i2c_get_match_data(client). Path: probe / initialization, not an error path.

**Step 2.3: Bug mechanism**
- Record: [Category] Memory safety — NULL pointer dereference `[Mechanism] device_get_match_data() is fwnode-only (drivers/base/property.c). i2c_device_match() can still bind via i2c_match_id() when there is no OF/ACPI data. Probe then dereferences NULL. i2c_get_match_data() tries firmware data first, then id_table->driver_data.`

Verified helper:

```121:137:drivers/i2c/i2c-core-base.c
const void *i2c_get_match_data(const struct i2c_client *client)
{
        struct i2c_driver *driver = to_i2c_driver(client->dev.driver);
        const struct i2c_device_id *match;
        const void *data;

        data = device_get_match_data(&client->dev);
        if (!data) {
                match = i2c_match_id(driver->id_table, client);
                if (!match)
                        return NULL;

                data = (const void *)match->driver_data;
        }

        return data;
}
```

The id table already stores the pointers probe needs:

```158:163:drivers/gpio/gpio-pca9570.c
static const struct i2c_device_id pca9570_id_table[] = {
        { "pca9570", (kernel_ulong_t)&pca9570_gpio},
        { "pca9571", (kernel_ulong_t)&pca9571_gpio },
        { "slg7xl45106", (kernel_ulong_t)&slg7xl45106_gpio },
        { /* sentinel */ }
};
```

**Step 2.4: Fix quality**
- Record: [Quality] Obviously correct; this is the I2C-core helper used by pca953x/pcf857x in this tree. `[Regression risk] Very low. Firmware path is unchanged (helper still calls device_get_match_data first). No locking, API, or data-structure change. Still no NULL check after the lookup; that is not a regression versus the OF path.`

## Phase 3: Git history

**Step 3.1: Blame**
- Record: [Introduced] Pointer dereference of match data: b8a34582c7f7f (“gpio: pca9570: add a platform data structure”, 2022-10-27, contained in v6.2-rc1). Before that, 16d44b6085c1d (2020) used (uintptr_t)device_get_match_data(), so a missing firmware match set ngpio = 0 instead of oopsing. The crash exists from v6.2 onward. Helper i2c_get_match_data(): 564d73c4d9201, contained in v6.5-rc1; present in this tree.

**Step 3.2: Fixes: tag**
- Record: No Fixes: tag. Buggy commit b8a34582c7f7f is an ancestor of HEAD.

**Step 3.3: File history**
- Record: Recent file commits are GPIO callback renames, kerneldoc, probe-style switch, chip_data rename, slg7xl45106/pca9571 support. No prerequisite refactor is required for this one-line swap. Standalone, not patch X/Y.

**Step 3.4: Author**
- Record: Pengpeng Hou has several GPIO fixes on this branch (MODULE_DEVICE_TABLE, probe-failure handling). Not the GPIO maintainer. Maintainer Bartosz Golaszewski applied the patch.

**Step 3.5: Dependencies**
- Record: Depends only on i2c_get_match_data(), which exists in v6.18.53 (include/linux/i2c.h and drivers/i2c/i2c-core-base.c). Can apply standalone. Applied commit f191ba12096a2 is a clean 2-line change on this tree.

## Phase 4: Mailing list / external

**Step 4.1: Original discussion**
- Record: `[Lore]
https://patch.msgid.link/[email protected]`
[Revisions] v1 only, single patch `[Feedback] Maintainer reply:
“Applied, thanks!” No NAK, no requested changes, no Cc: stable suggestion. Direct lore.kernel.org fetch returned 403; full thread recovered via b4 dig -m`.

**Step 4.2: Recipients (b4 dig -w)**
- Record: Linus Walleij, Bartosz Golaszewski, linux-gpio@, linux- kernel@. Correct GPIO maintainers and list. Applied by Bartosz.

**Step 4.3: Bug report**
- Record: No Reported-by / bugzilla / syzbot. Bug is deduced from the
code: I2C-id bind + firmware-only helper.

**Step 4.4: Series**
- Record: Standalone v1. Sibling GPIO conversions already in this tree:
ea05787136256 (pca953x) and db3b16dcc7e4f (pcf857x). Not prerequisites.

**Step 4.5: Stable list**
- Record: Original submission did not Cc stable. lore.kernel.org/stable search could not be fetched (HTTP 403). No stable-specific discussion in the recovered thread.

## Phase 5: Semantic analysis

**Step 5.1: Functions**
- Record: pca9570_probe() only.

**Step 5.2: Callers**
- Record: Only pca9570_driver.probe. Invoked from I2C core on client bind (boot DT, ACPI, i2c_new_client_device(), sysfs new_device). Not IRQ/hot-path.

**Step 5.3: Callees**
- Record: After the lookup, probe still uses chip_data->ngpio, devm_mutex_init/mutex_init, pca9570_read, devm_gpiochip_add_data. The only behavioral change is where match data comes from.

**Step 5.4: Reachability**
- Record: DT boards with compatible = "nxp,pca9570" (imx95-15x15-evk, imx8mp-dhcom-pdk3, stm32mp157c-lxa-tac-gen1) already get firmware match data and do not hit the bug. The broken path is I2C-id/modalias:
sysfs new_device, board-info, or any client without a firmware node. That is a supported I2C instantiation method (new_device_store in i2c-core). Needs privileges to write sysfs; still a deterministic probe oops for that path.

**Step 5.5: Similar patterns**
- Record: Same class of I2C GPIO expanders already use i2c_get_match_data() (gpio-pca953x.c, gpio-pcf857x.c). pca953x also NULL-checks; this patch does not add that check.

## Phase 6: Local tree (this checkout only)

**Step 6.1: Does the bug exist here?**
- Record: Local tree is **6.18.53** (git describe HEAD:
v6.18.53-5049-g0f0bdc2b0dffb; Makefile VERSION=6 PATCHLEVEL=18 SUBLEVEL=53). At v6.18.53, probe still does device_get_match_data() then chip_data->ngpio. Bug present. Candidate is **not** an ancestor of v6.18.53. Crash-introducing commit b8a34582c7f7f (v6.2) is in this tree.

**Step 6.2: Backport difficulty**
- Record: Clean apply. On this tree the change is exactly one call swap; no devm_mutex_init conflict.

**Step 6.3: Related fixes already here?**
- Record: No earlier pca9570 match-data fix. pca953x/pcf857x already converted; this driver was left on the firmware-only helper.

## Phase 7: Subsystem context

**Step 7.1**
- Record: [Subsystem] drivers/gpio (I2C GPO expander) [Criticality] PERIPHERAL / driver-specific — NXP PCA9570/PCA9571 and Dialog SLG7XL45106. Not core MM/VFS, but in-tree boards and CONFIG_GPIO_PCA9570 users exist.

**Step 7.2**
- Record: GPIO I2C expanders are mature. This file is low-churn except callback API updates. Long-standing bug (since v6.2), not churn from a new subsystem.

## Phase 8: Impact and risk

**Step 8.1: Who is affected**
- Record: Driver-specific / config-specific (CONFIG_GPIO_PCA9570). DT users are fine. Users instantiating via I2C id/modalias oops in probe.

**Step 8.2: Trigger**
- Record: [Trigger] Bind pca9570/pca9571/slg7xl45106 without firmware match data. [Likelihood] Uncommon vs DT, but 100% on that path (not a race). [Unprivileged?] No; sysfs new_device is privileged. Not a local-priv-esc issue.

**Step 8.3: Failure mode**
- Record: [Failure] NULL deref in pca9570_probe → kernel oops [Severity] HIGH (crash on probe for a supported bind method). Not data corruption or unprivileged security.

**Step 8.4: Risk vs benefit**
- Record: [Benefit] Prevents a deterministic probe oops; makes the existing I2C id table actually work. [Risk] Very low: one line, established helper, firmware path unchanged. [Ratio] Favorable.

## Phase 9: Synthesis

**Step 9.1: Evidence**

For:
- Real NULL deref when I2C-id matching; helper and dereference verified in this tree
- One-line, obviously correct; GPIO maintainer applied v1 with no objections
- i2c_get_match_data() already in 6.18.y; applies cleanly
- Same pattern already used by sibling GPIO I2C expanders
- In-tree DT users exist, so the driver is not dead; the I2C id table with driver_data is currently unused/wrong

Against:
- No user/syzbot report
- In-tree boards use DT, so they do not hit it
- Peripheral driver, not core
- Probe still does not NULL-check chip_data (pre-existing)

Unresolved:
- lore.kernel.org HTTP 403 for live HTML; thread recovered via b4 mbox
- No stable@ discussion found

**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** — one helper swap; maintainer applied; helper semantics verified
2. Fixes a real bug that affects users? **PASS** — NULL deref on a supported I2C bind path
3. Important (crash/security/corruption/deadlock)? **PASS** — probe oops (HIGH, not universal CRITICAL)
4. Small and contained? **PASS** — 1 line, one file
5. No new features/APIs? **PASS**
6. Can apply to this tree? **PASS** — clean on 6.18.53; helper present

**Step 9.3: Exception category**
- Record: None (not a device ID/quirk/DT/build/docs exception). It is a normal small crash fix.

**Step 9.4: Decision**
This belongs in this 6.18.y tree: the buggy code is here, the helper is here, and the fix is a one-line swap that stops a NULL deref on I2C-id probe.

## What the commit solves

pca9570_probe() treats device_get_match_data() as the source of struct pca9570_chip_data, then immediately reads ->ngpio. That helper only consults firmware nodes. I2C matching can still succeed from id_table (sysfs new_device, board info, modalias). chip_data is then NULL and probe oopses. i2c_get_match_data() keeps the DT path and consumes the id-table pointers this driver already stores.

For 6.18 stable users this is a small crash fix, not a feature. DT boards keep working; non-firmware instantiation stops oopsing.

## Verification
- [Phase 1] Parsed tags: author + GPIO maintainer SOB, lore Link; no Fixes/Reported-by/Cc: stable
- [Phase 2] Diff: 1 line in pca9570_probe(); device_get_match_data → i2c_get_match_data
- [Phase 2] device_get_match_data() is fwnode-only (drivers/base/property.c:1346)
- [Phase 2] i2c_get_match_data() falls back to id_table->driver_data (i2c-core-base.c:121)
- [Phase 2] i2c_device_match() binds OF, then ACPI, then I2C id (i2c-core-base.c:140)
- [Phase 3] Blame: crash introduced by b8a34582c7f7f (v6.2-rc1); helper from 564d73c4d9201 (v6.5-rc1)
- [Phase 3] git merge-base --is-ancestor b8a34582c7f7f HEAD → yes; helper ancestor → yes
- [Phase 4] b4 dig -c 415c63896b76: v1 only; recipients GPIO maintainers; mbox: “Applied, thanks!”
- [Phase 4] lore.kernel.org WebFetch: HTTP 403; used b4 mbox instead
- [Phase 5] pca9570_probe only used as i2c_driver.probe
- [Phase 5] DT users: imx95-15x15-evk, imx8mp-dhcom-pdk3, stm32mp157c-lxa-tac-gen1
- [Phase 6] git describe HEAD → v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion → 6.18.53
- [Phase 6] v6.18.53:drivers/gpio/gpio-pca9570.c still uses device_get_match_data; candidate not in v6.18.53
- [Phase 6] Applied form on this branch: clean 2-line change (f191ba12096a2)
- [Phase 8] Failure mode: NULL deref in probe → oops; DT path unaffected
- UNVERIFIED: live lore.kernel.org/stable HTML search (HTTP 403)

The patch is obviously correct, fixes a real probe oops, is one line, and applies cleanly to this 6.18.y tree.

**YES**

 drivers/gpio/gpio-pca9570.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-pca9570.c +1 -1
index c5a1287079a06..f7cc3fbf45336 100644
@@ -128,7 +128,7 @@ static int pca9570_probe(struct i2c_client *client)
 	gpio->chip.get = pca9570_get;
 	gpio->chip.set = pca9570_set;
 	gpio->chip.base = -1;
-	gpio->chip_data = device_get_match_data(&client->dev);
+	gpio->chip_data = i2c_get_match_data(client);
 	gpio->chip.ngpio = gpio->chip_data->ngpio;
 	gpio->chip.can_sleep = true;
 
Signature · 1 line
2.53.0
author maintainer
#353 lore raw

PATCH 1/1 smb: server: Free session data in user_session.c with kfree_sensitive()

In reply to Sasha Levin

From: Thomas Huth <[email protected]>

[ Upstream commit 9a4bd6507c21f66e84dc021705a4b9d84773111e ]

struct ksmbd_session contains some arrays with sensitive information, like sess_key, smb3encryptionkey, smb3decryptionkey and smb3signingkey. Thus let's make sure that this information cannot leak via the heap and use kfree_sensitive() to free it.

---

LLM Generated explanations, may be completely bogus:

I have the local 6.12.111 code, the upstream commit, and the mailing- list thread. Compiling the nine-phase analysis next.

## Phase 1: Commit message forensics

**Step 1.1: Subject line**
- Record: [smb/ksmbd server] [Free / use kfree_sensitive] Wipe ksmbd session objects (and Preauth_HashValue) so session keys cannot remain in freed heap memory

**Step 1.2: Tags** (from upstream d4a6d1c94f7a383c16fd5f5e912a39a640d1cb9d; ignore pipeline SOBs)
- No Fixes:
- No Reported-by: / Tested-by: / Reviewed-by: / Cc: stable
- Acked-by: Namjae Jeon <[email protected]> (ksmbd maintainer)
- Signed-off-by: Thomas Huth <[email protected]> (author)
- Signed-off-by: Steve French <[email protected]> (CIFS maintainer; present on the merged commit)
- Candidate-prep copy also had Signed-off-by: Namjae Jeon; merged form uses Acked-by instead
- Record: Maintainer ack, no user report, no syzbot, no CVE tag

**Step 1.3: Body**
- Record: `[Bug] ksmbd_session holds sess_key, smb3encryptionkey, smb3decryptionkey, smb3signingkey and a Preauth_HashValue buffer, then frees them with kfree(), so those secrets can remain in the slab. [Symptom] Potential heap disclosure of SMB session/crypto keys after session teardown. [Versions] None stated. [Root cause] Sensitive material is returned to the allocator without memzero_explicit.]`
- Cover letter (series v2 0/5): “It's good security practice to clear sensitive data… and to use kfree_sensitive() for data that is returned to the heap.”

**Step 1.4: Hidden bug fix?**
- Record: Not disguised cleanup. It is an explicit secret-wipe / heap- disclosure hardening change. Functional behavior of session teardown is unchanged except the object is zeroed before free.

## Phase 2: Diff analysis

**Step 2.1: Inventory**
- Record: [fs/smb/server/mgmt/user_session.c: 2 insertions, 2 deletions] [function: ksmbd_session_destroy] [scope: single-file, two- call-site surgical change]

**Step 2.2: Code flow**
- Record: Before, ksmbd_session_destroy() calls kfree(sess->Preauth_HashValue) then kfree(sess) after logoff/file- table/user/RPC/channel teardown. After, those two frees use kfree_sensitive(), which memzero_explicits the whole allocation then kfrees. Normal teardown path only; not an error-path restructure.

Verified in this tree at:

```159:175:fs/smb/server/mgmt/user_session.c
void ksmbd_session_destroy(struct ksmbd_session *sess)
{
        if (!sess)
                return;

        ksmbd_tree_conn_session_logoff(sess);
        ksmbd_destroy_file_table(sess);
        if (sess->user)
                ksmbd_free_user(sess->user);
        ksmbd_launch_ksmbd_durable_scavenger();
        ksmbd_session_rpc_clear_list(sess);
        free_channel_list(sess);
        kfree(sess->Preauth_HashValue);
        ksmbd_release_id(&session_ida, sess->id);
        ida_destroy(&sess->tree_conn_ida);
        kfree(sess);
}
```

Sensitive fields verified in struct ksmbd_session (user_session.h):
sess_key, smb3encryptionkey, smb3decryptionkey, smb3signingkey, plus Preauth_HashValue.

**Step 2.3: Bug mechanism**
- Record: [Memory safety / cryptographic material leftover] [kfree() does not clear; kfree_sensitive() zeros via memzero_explicit then frees. Category: information leak / CWE-226 class, not UAF/crash.]

**Step 2.4: Fix quality**
- Record: `[Obviously correct drop-in. kfree_sensitive() is NULL-safe like kfree(). Session is kzalloc'd, so ksize/kfree_sensitive is the right API. No API/lock/struct change.] [Regression risk: very low. Docs warn kfree_sensitive is not for hot paths; session destroy is logoff/expire/teardown, not a packet hot path.]`

## Phase 3: Git history

**Step 3.1: Blame**
- Record: ksmbd_session_destroy and kfree(sess->Preauth_HashValue) from e2f34481b24db2 (“cifsd: add server-side procedures for SMB3”), contained in v5.15-rc1. kfree(sess) from 822bc8ea514ecd (2021). Encryption key fields from 5a0ca7700591a5 (2021). Bug has been in this code since ksmbd entered mainline.

**Step 3.2: Fixes: tag**
- Record: No Fixes: tag. Not applicable. Introducer is the original ksmbd session code, which is in this tree (git merge-base --is- ancestor of those SHAs vs HEAD succeeded).

**Step 3.3: File history**
- Record: Recent 6.12.y ksmbd session work is lifetime/UAF/ida (e.g. 9d58ac0643e5b destroy tree_conn_ida, session leak/UAF fixes). None already switches these two kfrees. Not blocked by later refactor in this file.

**Step 3.4: Author**
- Record: Thomas Huth (Red Hat); not the ksmbd maintainer. Series of five independent kfree_sensitive conversions. Maintainer Namjae Jeon acked and applied to #ksmbd-for-next-next. Steve French signed off on the merge.

**Step 3.5: Dependencies**
- Record: Patch 3/5 of “Clear sensitive data before freeing it”. Sibling patches touch auth.c, user_config.c, connection.c, smb2pdu.c. This hunk does not call new helpers and does not depend on those other diffs. linux/slab.h already included. kfree_sensitive() exists in this tree (mm/slab_common.c, exported). Standalone apply: yes.

## Phase 4: Mailing list / external

**Step 4.1: Original discussion**
- Record: `[Lore]
https://patch.msgid.link/[email protected]`
- Series: v1 (4 patches, 2026-08-10) → v2 (5 patches, 2026-08-11). This file hunk is unchanged v1→v2.
- v1 review (Namjae): also wipe struct preauth_session in ksmbd_preauth_session_destroy(). That was handled in v2 patch 5 (smb2pdu.c session-setup paths), not in this commit. This commit is still self-contained.
- No NAK. No reviewer asked for Cc: stable. Maintainer: “Applied them to #ksmbd-for-next-next.”

**Step 4.2: Recipients (b4 dig -w)**
- Record: Thomas Huth; Namjae Jeon; Steve French; Sergey Senozhatsky; Tom Talpey; linux-kernel@. Subsystem maintainers were on To/Cc and the ksmbd maintainer acked.

**Step 4.3: Bug report**
- Record: No syzbot/bugzilla/CVE for this change. Author framed it as hygiene; spots “identified with AI” then written by hand.

**Step 4.4: Series context**
- Record: Five independent wipe sites. This one wipes the session object that actually embeds the SMB3 keys. Related remaining kfree(chann) of struct channel (contains smb3signingkey) is not part of this commit; that does not make this hunk incorrect.

**Step 4.5: Stable list**
- Record: No stable@ discussion found for this subject. Unverified that it was previously rejected for stable.

Upstream SHA (not in this branch):
d4a6d1c94f7a383c16fd5f5e912a39a640d1cb9d. git merge-base --is- ancestor d4a6d1c94f7a3 HEAD failed (exit 1).

## Phase 5: Semantic analysis

**Step 5.1: Functions**
- Record: ksmbd_session_destroy only.

**Step 5.2: Callers**
- Record: Same file: ksmbd_expire_session, ksmbd_sessions_deregister (two sites), ksmbd_user_session_put, __session_create error path.
- ksmbd_user_session_put is used from smb2pdu.c (session setup/logoff), server.c, auth.c, and register failure.
- Context: SMB session lifetime (logoff, expire, connection teardown, create failure). Not IRQ. Reachable from a connected SMB client.

**Step 5.3: Callees**
- Record: tree-connect logoff, file table destroy, ksmbd_free_user, durable scavenger, RPC clear, free_channel_list, then the two frees. Side effect of the patch is only the wipe-before-free.

**Step 5.4: Reachability**
- Record: Yes. Any ksmbd login then logoff/disconnect/expire hits this. CONFIG_SMB_SERVER (default n), module ksmbd. Network-facing when enabled.

**Step 5.5: Similar patterns**
- Record: CIFS client already uses kfree_sensitive widely for session keys/passwords in this tree. ksmbd server only uses it in auth.c (kfree_sensitive(ctx_arc4)). free_channel_list/ksmbd_chann_del still kfree channel objects that embed smb3signingkey. ksmbd_preauth_session_destroy still kfrees preauth_session (hash embedded). Same class of leftover secrets; this patch still covers the primary session key material.

## Phase 6: This tree (6.12.111)

**Step 6.1: Buggy code present?**
- Record: Yes. pending-6.12 / make kernelversion = 6.12.111. Exact kfree(sess->Preauth_HashValue) and kfree(sess) still in ksmbd_session_destroy. Introduced with ksmbd (v5.15), long before 6.12.

**Step 6.2: Backport difficulty**
- Record: Clean apply. Mailing-list hunk context (ksmbd_launch_ksmbd_durable_scavenger … ida_destroy) matches this tree. Upstream later added delete_proc_session(sess) above these lines; that symbol is absent here but is not in the 3-line context of the actual change. kfree_sensitive already declared in include/linux/slab.h.

**Step 6.3: Related fixes already here?**
- Record: No equivalent wipe of these two allocations. git log --grep=kfree_sensitive -- fs/smb/server has no matching session- destroy commit.

## Phase 7: Subsystem context

**Step 7.1**
- Record: `[ksmbd / fs/smb/server] [IMPORTANT for systems with
CONFIG_SMB_SERVER: NAS/embedded SMB3 server; not CORE for every 6.12 user]`

**Step 7.2**
- Record: Actively maintained; this 6.12.y branch already carries many ksmbd security/UAF backports. Code path itself is mature (since 5.15).

## Phase 8: Impact and risk

**Step 8.1: Who is affected**
- Record: Config-specific (CONFIG_SMB_SERVER). Users running ksmbd (SMB3 kernel server).

**Step 8.2: Trigger**
- Record: Session destroy on logoff, idle expire, connection teardown, or failed session create. Common on any real ksmbd workload. Triggering the leftover keys does not require a race; the wipe omission is deterministic. Reading the leftover keys does require another info leak, a dump, or similar.

**Step 8.3: Failure mode**
- Record: `[Residual SMB session/encryption/signing keys and preauth hash in slab after free] [Severity: MEDIUM as a standalone disclosure (needs another read of freed/reused heap), HIGH in combination with an uninitialized-kmalloc leak or memory dump because the secrets can decrypt prior SMB3 traffic or expose session key material]`

**Step 8.4: Risk-benefit**
- Record: [Benefit: medium for ksmbd deployments — clears the actual SMB3 key material on every session end] [Risk: very low — 2 lines, dedicated API, teardown path only] [Ratio: favorable]

## Phase 9: Synthesis

**Evidence FOR**
- Deterministic failure to clear SMB3 session keys, signing keys, encryption/decryption keys, and Preauth_HashValue on session destroy.
- kfree_sensitive() exists specifically for this; CIFS client in this tree already uses it for the same class of secrets.
- Two-line, obviously correct, maintainer-acked, already merged upstream.
- Applies cleanly to 6.12.111; no new API; no lock/data-structure change.
- ksmbd is a network-facing file server; leftover keys after logoff are real cryptographic material, not a style nit.
- Official stable rules include “a real security issue”; this is secret leftover in heap (CWE-226), not a feature.

**Evidence AGAINST**
- Cover letter calls it “good security practice,” not a demonstrated crash/CVE. No Reported-by, no exploit write-up.
- Official rule: no “this could be a problem” without how it is exploited. Direct userspace leak is not shown; it is residual data until slab reuse or a dump.
- Incomplete hygiene: channel objects and ksmbd_preauth_session_destroy() still use kfree in this file.
- CONFIG_SMB_SERVER defaults to n.

**Unresolved**
- No stable@ thread found (search quality limited; lore.kernel.org/stable returned unrelated hits).
- Semcode MCP not available; callers traced with git grep.

**Stable rules checklist**
1. Obviously correct and tested? **PASS** — drop-in kfree → kfree_sensitive; maintainer ack; applied upstream.
2. Fixes a real bug that affects users? **PASS** — session objects with live SMB3 keys are freed without wiping; that is leftover secret material on a path every ksmbd session takes.
3. Important issue? **PASS** (security: key leftover; not oops/deadlock). Severity is secret wipe, not a panic.
4. Small and contained? **PASS** — 2 lines, one function.
5. No new features/APIs? **PASS**.
6. Can apply to this tree? **PASS** — same function body aside from later delete_proc_session, which this hunk does not need.

**Exception category:** None of ID/quirk/DT/build/docs. Security wipe of existing allocations.

This is not a crash fix, but it is a small, obviously correct wipe of real SMB3 key material on session teardown, the code is present in 6.12.111, and regression risk is negligible. That meets the stable bar for a real security issue on ksmbd.

Verification:
- [Phase 1] Parsed subject/body/tags from candidate text and git log -1 d4a6d1c94f7a3; maintainer Acked-by; no Fixes/Reported-by/Cc: stable
- [Phase 2] Read ksmbd_session_destroy and struct ksmbd_session in this tree; confirmed two kfree sites and key arrays
- [Phase 2] Read kfree_sensitive() in mm/slab_common.c (zeros via memzero_explicit, then kfree)
- [Phase 3] git blame -L 159,175 user_session.c; introducer e2f34481b24db2 contained in v5.15-rc1
- [Phase 3] git merge-base --is-ancestor of introducer and of d4a6d1c94f7a3 vs HEAD: introducer yes, this fix no
- [Phase 3] git log --oneline -20 -- fs/smb/server/mgmt/user_session.c: no prior equivalent wipe
- [Phase 4] b4 dig -c d4a6d1c94f7a3 / -a / -w: v1 then v2; lore
https://patch.msgid.link/[email protected];
Namjae applied v2; no NAK; no stable nomination
- [Phase 4] Cover letter and v1 review (preauth_session) fetched from openwall/lkml/patchew
- [Phase 5] git grep ksmbd_session_destroy / ksmbd_user_session_put:
session logoff/expire/teardown/create-error
- [Phase 5] Confirmed __session_create uses kzalloc; user_session.c includes linux/slab.h
- [Phase 6] git describe HEAD → p-6.12-3-gc504cf0baa3d8; make kernelversion → 6.12.111
- [Phase 6] delete_proc_session absent here; does not block the two- line hunk
- [Phase 7] CONFIG_SMB_SERVER in fs/smb/server/Kconfig, default n
- [Phase 8] Failure mode: leftover session keys in slab after destroy
- UNVERIFIED: no dedicated stable@ discussion located

The two-line kfree_sensitive() conversion belongs in this 6.12 tree:
the buggy frees are here, the API is here, and it wipes real SMB3 session keys on teardown with negligible risk.

**YES**

 fs/smb/server/mgmt/user_session.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/server/mgmt/user_session.c +2 -2
index 3a2591434b5f8..973db0466575e 100644
@@ -168,10 +168,10 @@ void ksmbd_session_destroy(struct ksmbd_session *sess)
 	ksmbd_launch_ksmbd_durable_scavenger();
 	ksmbd_session_rpc_clear_list(sess);
 	free_channel_list(sess);
-	kfree(sess->Preauth_HashValue);
+	kfree_sensitive(sess->Preauth_HashValue);
 	ksmbd_release_id(&session_ida, sess->id);
 	ida_destroy(&sess->tree_conn_ida);
-	kfree(sess);
+	kfree_sensitive(sess);
 }
 
 struct ksmbd_session *__session_lookup(unsigned long long id)
Signature · 1 line
2.53.0
author maintainer
#354 lore raw

PATCH 1/1 memory: stm32_omm: initialize ret in stm32_omm_set_amcr

In reply to Sasha Levin

From: Ruoyu Wang <[email protected]>

[ Upstream commit 1527acf2295cf2d6e11e3e9b121d63709667e6e7 ]

stm32_omm_set_amcr() returns ret after checking whether the AMCR value matches the device tree description. On the normal matching path ret is not otherwise assigned, so initialize it to 0 before the checks.

---

LLM Generated explanations, may be completely bogus:

The local tree is **6.18.53**. stm32_omm_set_amcr() in that tree still returns uninitialized ret on the AMCR-match path, and the one-line init is a real probe/resume correctness fix.

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

**Step 1.1: PARSE THE SUBJECT LINE**
Record: [memory / stm32_omm] [initialize] [set ret=0 in stm32_omm_set_amcr so the AMCR-match success path does not return an uninitialized stack value]

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Reviewed-by: Patrice Chotard <[email protected]> (driver maintainer; MAINTAINERS lists him for ST STM32 OCTO MEMORY MANAGER)
- `Link:
https://patch.msgid.link/[email protected]`
- Signed-off-by: Ruoyu Wang <[email protected]> (author)
- Signed-off-by: Krzysztof Kozlowski <[email protected]> (memory- controller maintainer; applied the patch)
- No Fixes: tag (expected)
- No Cc: stable (expected)
- No Reported-by: / Tested-by: / syzbot / kernel test robot tags
- Pipeline-only tags ([Upstream commit ...], Signed-off-by: Sasha Levin) ignored

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: stm32_omm_set_amcr() returns ret after the AMCR vs DT check. On the matching (success) path, ret is not assigned -EINVAL and may never have been assigned at all.
- Symptom: the function can return a leftover stack value as an errno to probe/configure/resume. Callers treat any non-zero as failure, so garbage can fail device bring-up or resume; a lucky 0 would hide the mismatch path’s intent.
- Version info: none in the message.
- Root cause (author): success path does not initialize ret before return ret.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. This is an explicit uninitialized-variable fix (int ret → int ret = 0). Same class as KMSAN/compiler “used uninitialized” fixes even without a sanitizer tag.

===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/memory/stm32_omm.c (1 insertion, 1 deletion)
- Function: stm32_omm_set_amcr
- Scope: single-file, one-line surgical fix

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: Before, int ret, idx; then the loop may assign ret from of_address_to_resource(), mismatch sets ret = -EINVAL, and the function always return ret. After, ret starts at 0, so AMCR match returns success unless an earlier path already returned an error.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: Category **uninitialized data / logic correctness**. Mechanism:
ret is assigned only by a successful of_address_to_resource() (inside a loop that can continue) or by ret = -EINVAL on AMCR mismatch. The success return ret is therefore undefined if the loop never assigned ret. Fix: default ret = 0.

Verified from the pre-fix function (v6.18.53 and the original driver):

```50:50:drivers/memory/stm32_omm.c
        int ret = 0, idx;
```

(v6.18.53 still has int ret, idx; — confirmed via git show v6.18.53:drivers/memory/stm32_omm.c.)

Mismatch path:

```116:121:drivers/memory/stm32_omm.c
        if (amcr != read_amcr) {
                dev_err(dev, "AMCR value not coherent with DT memory-map
areas\n");
                ret = -EINVAL;
        }

        return ret;
```

**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct. Error returns in the loop are unchanged (return ret / return -EFAULT). AMCR mismatch still returns -EINVAL. Risk is negligible: initializing an errno to 0 cannot deadlock, cannot change a public API, and matches the intended success code.

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

**Step 3.1: BLAME THE CHANGED LINES**
Record: int ret, idx; and the return ret were introduced in 8181d061dcff1 (“memory: Add STM32 Octo Memory Manager driver”, 2025-04-28 / committed 2025-05-07). Present from the first version of the driver. Driver first appears in **v6.16**; still present in v6.17 and v6.18.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The introducing commit is 8181d061dcff1, which **is** an ancestor of v6.18 (git merge-base --is-ancestor 8181d061dcff1 v6.18 succeeded).

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record (path-limited git log --oneline -- drivers/memory/stm32_omm.c):
driver add, spelling, several probe/error-handling fixes, syscon_regmap_lookup_by_phandle_args, req2ack test fix. Intermediate commit 6d8b18ae647bb changed syscon lookup but left int ret, idx; and return ret in place. This init patch is standalone, not “patch X/Y”.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Ruoyu Wang has only this commit under drivers/memory/. The driver maintainer (Patrice Chotard) reviewed it. Memory-controller maintainer (Krzysztof Kozlowski) applied it.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. The hunk only changes a local int ret declaration. No new helpers, types, or APIs. Can apply standalone.

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 1527acf2295cf2d6e11e3e9b121d63709667e6e7 →
https://patch.msgid.link/[email protected]
- b4 dig -a: single revision **v1 only**; committed version is that v1
- Thread: author submission; Patrice Chotard Reviewed-by; Krzysztof “Applied, thanks!” (mem-ctrl commit 1527acf2295cf2d6e11e3e9b121d63709667e6e7)
- No NAK, no risk flags, no reviewer request for Cc: stable
- lore.kernel.org WebFetch returned 403; discussion recovered via b4 dig -m and openwall/lkml mirrors

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc included Patrice Chotard (driver maintainer), Krzysztof Kozlowski (memory controllers), Maxime Coquelin, Alexandre Torgue, linux-kernel, linux-stm32, linux-arm-kernel. Appropriate maintainers were on the patch and it was reviewed/applied.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by, no bugzilla/syzbot link. No verified kernel- test-robot mail in the thread. The author describes the uninit return from code inspection.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone [PATCH], not a series. No sibling patches required.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** for lore.kernel.org/stable (HTTP 403). Web search and the saved mbox show no stable-list discussion of this subject.

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: stm32_omm_set_amcr only. (semcode MCP not available; used hunk headers + rg.)

**Step 5.2: TRACE CALLERS**
Record (verified with rg on drivers/memory/stm32_omm.c):
1. stm32_omm_configure() → stm32_omm_set_amcr(dev, true) then returns that ret (probe, full firewall access)
2. stm32_omm_probe() → stm32_omm_set_amcr(dev, false) when OMM access is not granted; if (ret) return ret
3. stm32_omm_resume() → stm32_omm_set_amcr(dev, true); if (ret) return ret

All three are driver probe / system-resume paths, not an obscure debug hook.

**Step 5.3: TRACE CALLEES**
Record: of_property_match_string, of_parse_phandle, of_address_to_resource, syscon_regmap_lookup_by_phandle_args, regmap_update_bits / regmap_read. Side effects are DT parse + AMCR syscon R/W.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Platform probe of compatible = "st,stm32mp25-omm" (SoC node in arch/arm64/boot/dts/st/stm32mp251.dtsi, enabled on stm32mp257f-ev1.dts). Reachable on STM32MP25 boot and suspend/resume. Not a syscall fuzzer path; hardware/DT driven.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: No second copy of this AMCR helper. Binding example uses both ospi1 and ospi2 regions; in-tree board stm32mp257f-ev1.dts only sets memory-region-names = "ospi1". Binding **does not require** memory-region (required list is compatible/reg/clocks/resets/st,syscfg-amcr/ranges). Omitting memory- region-names is a valid DT; the loop then never assigns ret.

===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- git describe HEAD / make kernelversion: **v6.18.53** (branch autosel)
- git show v6.18.53:drivers/memory/stm32_omm.c has int ret, idx; and return ret after the AMCR compare
- Driver exists in v6.18 (git cat-file -e v6.18:drivers/memory/stm32_omm.c)
- Bug introduced with the driver in v6.16 (8181d061dcff1)

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply. The one-line int ret, idx; → int ret = 0, idx; is present exactly once in v6.18.53. Surrounding function matches the upstream hunk. No rework needed.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: git log --oneline --grep='stm32_omm' -- drivers/memory/ on this history shows other stm32_omm error-handling fixes, but none initialize ret in stm32_omm_set_amcr in v6.18.53. No alternate fix for this uninit.

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/memory/ STM32 Octo Memory Manager (OSPI mux / 256MB map split on STM32MP25). Criticality: **PERIPHERAL** (SoC-specific), but it sits under flash/OSPI bring-up for that platform, so probe/resume failure is user-visible there.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Modest, mature-enough driver (added v6.16, a handful of follow- up fixes). Not a staging driver. Maintainer-reviewed.

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Config-specific / platform-specific: CONFIG_STM32_OMM on STM32MP25 (st,stm32mp25-omm). Not universal.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Always runs during OMM probe (and again on system resume if restore_omm).
- Uninitialized return ret is **guaranteed** if the memory-region loop never assigns ret (optional DT property missing or names do not match ospi1/ospi2) **and** AMCR equals computed amcr (0 when no ospi2 region).
- On the in-tree ev1 board, ospi1 is present, so of_address_to_resource typically sets ret = 0 before the AMCR check; the uninit is then a maybe-uninitialized / custom-DT / failed- phandle path. Compilers still cannot prove assignment because of the continues.
- Not an unprivileged syscall trigger.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Returning uninitialized int as errno. Callers abort probe or resume on non-zero. Failure mode: OSPI/OMM device fails to probe or fails to resume (flash/memory-map unavailable). Severity **MEDIUM** (wrong control-plane result / possible resume failure; not a documented oops, but C undefined behavior). Garbage zero would incorrectly look like success on a path that never validated regions.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: prevents UB and spurious probe/resume failures on STM32MP25 OMM; makes the success path well-defined. Medium benefit for that platform, low global blast radius.
- Risk: **very low** (one initializer, no locking/API/data-structure change).
- Ratio: strongly favors backport.

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Real uninitialized return in a function whose callers treat ret as errno
- Reachable on probe and system resume
- DT binding leaves memory-region optional, so the loop is allowed to assign nothing
- 1-line, obviously correct, reviewed by the driver maintainer, applied by the subsystem maintainer
- Driver and buggy code exist in this 6.18.53 tree since the driver landed in v6.16
- Clean apply; no prerequisites
- Matches the uninitialized-data class that stable routinely takes

AGAINST:
- STM32MP25-only (narrow user set)
- No crash log, syzbot, or user Reported-by
- On the one in-tree board with memory-region-names = "ospi1", ret is often already 0 from of_address_to_resource
- Not CORE mm/net/fs

UNRESOLVED:
- Could not query lore.kernel.org/stable (403)
- No confirmed compiler-warning/KMSAN report in the thread (web-search snippets that mentioned kernel test robot were not backed by the actual mails)

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — one initializer; maintainer Reviewed-by; applied upstream
2. Fixes a real bug that affects users? **PASS** — uninitialized errno on OMM probe/resume
3. Important issue? **PASS** at MEDIUM — probe/resume malfunction and UB, not a documented panic; still a user-visible device failure mode
4. Small and contained? **PASS** — 1 line, 1 function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — v6.18.53 has the uninit declaration unchanged

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/docs patch. Closest extra: it also silences a typical -Wmaybe-uninitialized shape, but the decision is on the runtime uninit return, not on the build-fix exception.

**Step 9.4: MAKE YOUR DECISION**
Backport. The local 6.18.53 tree contains the driver and the bug; the fix is a one-line initialization of a returned errno with essentially no regression risk.

What this does for 6.18.y users: STM32MP25 Octo Memory Manager probe and resume no longer return a stack-garbage error code when AMCR matches DT and ret was never written. That is a real, contained correctness fix.

Risk vs benefit: benefit is defined success (0) vs undefined errno; risk is a single = 0.

### Verification
- [Phase 1] Parsed tags: Reviewed-by Patrice Chotard, Link msgid, SOBs Wang + Kozlowski; no Fixes/Cc-stable/Reported-by
- [Phase 2] Diff: int ret, idx → int ret = 0, idx in stm32_omm_set_amcr only
- [Phase 2] Pre-fix function: loop may skip all ret = of_address_to_resource stores; mismatch sets -EINVAL; success falls through to return ret
- [Phase 3] git blame on parent: uninit from 8181d061dcff1 (driver add, 2025)
- [Phase 3] Driver in v6.16+; git merge-base --is-ancestor 8181d061dcff1 v6.18 true
- [Phase 3] No series/prereqs; later 6d8b18ae647bb did not fix ret
- [Phase 4] b4 dig -c 1527acf2295cf2d6e11e3e9b121d63709667e6e7: lore msgid 20260617182202.961843-1
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: Chotard, Kozlowski, STM32/ARM lists CC’d
- [Phase 4] mbox: Reviewed-by Chotard; Applied by Kozlowski; no NAK
- [Phase 4] lore.kernel.org WebFetch 403; used openwall + mbox instead
- [Phase 5] Callers verified: stm32_omm_configure, stm32_omm_probe, stm32_omm_resume
- [Phase 5] Binding st,stm32mp25-omm.yaml: memory-region not in required:
- [Phase 5] Board DT stm32mp257f-ev1.dts has only ospi1 memory- region
- [Phase 6] git describe HEAD / Makefile: v6.18.53; git show v6.18.53:drivers/memory/stm32_omm.c still has int ret, idx;
- [Phase 6] Python check: old pattern present once in v6.18.53; initialized form absent
- [Phase 7] MAINTAINERS: Patrice Chotard owns drivers/memory/stm32_omm.c
- [Phase 8] Failure mode: garbage errno → probe/resume fail on STM32MP25 OMM
- UNVERIFIED: stable@ mailing-list thread (lore 403); no verified kernel-test-robot report

**YES**

 drivers/memory/stm32_omm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memory/stm32_omm.c +1 -1
index 5d06623f3f689..2a1af229d2444 100644
@@ -47,7 +47,7 @@ static int stm32_omm_set_amcr(struct device *dev, bool set)
 	struct device_node *node;
 	struct resource res, res1;
 	unsigned int syscon_args[2];
-	int ret, idx;
+	int ret = 0, idx;
 	unsigned int i, amcr, read_amcr;
 
 	for (i = 0; i < omm->nb_child; i++) {
Signature · 1 line
2.53.0
author maintainer
#355 lore raw

PATCH 1/1 staging: rtl8723bs: fix missing unregister_netdev on sdio_alloc_irq failure

In reply to Sasha Levin

From: Devansh Soni <[email protected]>

[ Upstream commit 51b554f1a758570159a770983c7a0ccd7c761491 ]

In rtw_drv_init(), if rtw_drv_register_netdev() succeeds but sdio_alloc_irq() fails, the error path jumps to free_if1 and calls rtw_sdio_if1_deinit(). However, rtw_sdio_if1_deinit() calls rtw_free_netdev() without a preceding unregister_netdev(), freeing a still-registered netdev but leaving stale sysfs entries behind.

---

LLM Generated explanations, may be completely bogus:

This checkout is **v7.3-rc4** (mainline 7.3). The patch is a 5-line probe error-path fix: after register_netdev() succeeds, a failed sdio_claim_irq() used to free_netdev() a still-registered netdev, which hits BUG_ON in free_netdev(). The buggy path exists in this tree (introduced by 618b4aec, which is in v7.0+ and was already taken to stable).

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[staging/rtl8723bs] [fix] missing unregister_netdev on sdio_alloc_irq failure**

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Devansh Soni <[email protected]> (author)
- `Link: https://patch.msgid.link/20260619125724.12458-1-
[email protected]`
- Signed-off-by: Greg Kroah-Hartman <[email protected]> (staging maintainer; applied)
- No Fixes:, no Reported-by:, no Tested-by:, no Reviewed-by:, no Cc: stable (absence of the last two is expected for this review)

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** rtw_drv_init() registers the netdev, then sdio_alloc_irq() fails, then rtw_sdio_if1_deinit() → rtw_free_netdev() without unregister_netdev().
- **Symptom:** freeing a still-registered netdev; stale sysfs entries. The commit understates the real failure: free_netdev() does BUG_ON(dev->reg_state != NETREG_UNREGISTERED).
- **Version info:** none in the message.
- **Root cause:** error path after successful rtw_drv_register_netdev() does not unregister before free.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. Explicit error-path crash/UAF/sysfs leak fix.

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/staging/rtl8723bs/os_dep/sdio_intf.c (+4 / −1)
- Function: rtw_drv_init()
- Scope: single-file surgical error-path fix

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** sdio_alloc_irq() failure → goto free_if1 → rtw_sdio_if1_deinit() → rtw_free_netdev() while still registered.
- **After:** same failure → goto free_netdev → rtw_unregister_netdevs(dvobj) then fall through to deinit/free. Success path still falls through both labels, but both are guarded by status != _SUCCESS.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** error-path resource teardown / memory safety (registered netdev freed).
- **Mechanism:** missing unregister_netdev() before free_netdev(). Fix matches the existing rtw_dev_remove() order.

**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: unregister-then-free is the same sequence as remove.
- Minimal; no API/data-structure changes.
- Regression risk is low: labels are status-guarded; rtw_unregister_netdevs() already exists and is used on remove.
- Fall-through on success is intentional and safe.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Probe skeleton: 554c0a3abf216 (Hans de Goede, 2017, “staging: Add rtl8723bs sdio wifi driver”).
- The crashy cleanup path was **activated** by 618b4aec12faa (Liang Jie, 2025-12-08, “fix missing status update on sdio_alloc_irq() failure”): that commit started storing sdio_alloc_irq()’s return in status, so failure actually runs free_if1. Before that, failure left status == _SUCCESS, skipped cleanup, and returned 0 (wrong, but no unregister/free crash).
- First appeared as this crash: **v7.0** (618b4aec is in v7.0; not in v6.19).

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The commit that made this path crash is 618b4aec12faa, which **is** an ancestor of this tree.

**Step 3.3: CHECK FILE HISTORY**
Record: Related: 618b4aec12faa (status update). Later style/rename commits on the same file. Standalone 1/1 patch, not “patch X/Y”.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Devansh Soni has two commits in this driver (this fix and an unrelated unused-buffer cleanup). Not the maintainer. Greg applied it.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs status = sdio_alloc_irq(dvobj) from 618b4aec and existing rtw_unregister_netdevs(). Both are in this v7.3 tree. Applies standalone here.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 51b554f1a7585 → https://patch.msgid.link/20260619125724.12
[email protected]
- b4 dig -a: **v1 only**, standalone.
- lore.kernel.org fetches returned **403**. lkml.iu.edu / openwall show the original mail only; **no replies, no NAK, no Cc: stable in review**.
- b4 dig -m matched the **wrong** thread (Alonso Garrigues style series). Treat that mbox as a tool miss, not discussion of this patch.

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: b4 dig -w: To/Cc were Greg KH, linux-staging, linux-kernel. No extra reviewers. Greg’s commit SOB is the only maintainer ack.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by, no syzbot, no bugzilla. Analysis-driven, not a user report.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Completes 618b4aec. That predecessor was sent to **6.19 stable** ([PATCH 6.19 368/844] staging: rtl8723bs: fix missing status update on sdio_alloc_irq() failure, Upstream 618b4aec). Trees that took that incomplete fix now have this BUG_ON path.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No stable thread found for *this* unregister follow-up (lore/stable search not usable here). Predecessor **was** selected for 6.19.y.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: KEY FUNCTIONS**
Record: rtw_drv_init(); calls rtw_unregister_netdevs(), rtw_sdio_if1_deinit(), sdio_alloc_irq().

**Step 5.2: TRACE CALLERS**
Record: rtw_drv_init is .probe of rtl8723bs_sdio_driver (sdio_intf.c). Runs on SDIO enumerate of IDs 0x024c:0523/0525/0623/0626. Module-only (depends on m).

**Step 5.3: TRACE CALLEES**
Record: sdio_alloc_irq() → sdio_claim_irq(). rtw_unregister_netdevs() → unregister_netdev() + rtw_wdev_unregister(). rtw_sdio_if1_deinit() → rtw_free_netdev() → free_netdev().

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace cannot call this directly; it runs on device probe. sdio_claim_irq() failure is uncommon (resource/hardware) but then the kernel **BUGs**. Reachable whenever this module probes a card and IRQ claim fails.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: rtw_dev_remove() already unregisters then deinits. _rtw_drv_register_netdev() failure still has a separate double-free concern (later syzbot-style patch by Yi Cong); **not** this hunk.

Verified free_netdev():

```12311:12311:net/core/dev.c
        BUG_ON(dev->reg_state != NETREG_UNREGISTERED);
```

NETREG_REGISTERED after register_netdev() makes that BUG_ON fire.

---

## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- Tree: **v7.3-rc4** (VERSION=7 PATCHLEVEL=3 SUBLEVEL=0 EXTRAVERSION=-rc4).
- Driver present: drivers/staging/rtl8723bs/.
- 618b4aec is an ancestor (in v7.0, v7.1, v7.2, v7.3-rc1).
- Candidate 51b554f1 is already in **v7.3-rc1** (not used as “already selected for stable”; it is in this 7.3 base).
- Pre-fix parent of 51b554f1 still had goto free_if1 on IRQ failure.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply on this tree. Context is the status = sdio_alloc_irq() form from 618b4aec. rtw_unregister_netdevs() has existed since the driver was added.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: 618b4aec is here (creates the crash). This follow-up is the missing unregister. No other equivalent unregister-on-IRQ-fail fix besides 51b554f1.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: **staging/rtl8723bs** (Realtek SDIO WiFi). Criticality **PERIPHERAL** as staging, but the chip is real (Kconfig: Intel Compute Stick, Atom/ARM boards). Greg maintains staging.

**Step 7.2: SUBSYSTEM ACTIVITY**
Record: High churn (style + several OOB fixes). Still staging since 2017 (TODO still lists MAC80211 conversion, leftover chip code).

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: WHO IS AFFECTED**
Record: Users with CONFIG_RTL8723BS=m and matching SDIO WiFi, only if probe gets past register_netdev() and then sdio_claim_irq() fails.

**Step 8.2: TRIGGER CONDITIONS**
Record: Probe error path; not hot. Unprivileged users do not trigger it except by plugging/having the device. Timing-independent.

**Step 8.3: FAILURE MODE SEVERITY**
Record: BUG_ON in free_netdev() → **kernel BUG / oops**. Also stale sysfs. **Severity: CRITICAL** if it fires; trigger is uncommon.

**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit:** high for this driver: prevents BUG on a path that 618b4aec (already in this tree, and in 6.19.y) made live.
- **Risk:** very low (4 insertions, error path only, same order as remove).
- **Ratio:** favorable.

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

**FOR:**
- Real bug: free_netdev() on NETREG_REGISTERED → BUG_ON.
- Small, obviously correct, matches rtw_dev_remove().
- Completes 618b4aec, which is in this tree and was already backported to 6.19.y — that incomplete stable fix **creates** this crash.
- No new API; error path only.
- rtw_unregister_netdevs() and the status = sdio_alloc_irq() form exist here.

**AGAINST:**
- Staging (usually not stable material).
- No user/syzbot report; rare IRQ-claim failure.
- No public review beyond Greg applying v1.
- This 7.3-rc4 checkout already contains 51b554f1 from v7.3-rc1 (not a reason to reject on merit).

**UNRESOLVED:**
- Full lore thread unreadable (403); no evidence of NAKs on IU/openwall mirrors.
- Whether every older LTS has 618b4aec is not this tree’s question; **this** tree does.

**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — logic matches remove; in mainline via Greg. No extra Tested-by.
2. Fixes a real bug that affects users? **PASS** — probe failure can BUG; hardware exists.
3. Important (crash/security/corruption/deadlock)? **PASS** — kernel BUG_ON.
4. Small and contained? **PASS** — 5 lines, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — applies; helpers and prerequisite are here.

**Step 9.3: EXCEPTION CATEGORIES**
Record: None (not an ID/quirk/DT/build/doc patch). Ordinary bug fix.

**Step 9.4: DECISION**

Staging would normally count against, but it does not win here: this is a crash fix on a path that a **already-stable** predecessor (618b4aec) opened, the change is four guarded lines, and this v7.3 tree has the buggy sequence. Benefit vs risk favors taking it.

---

### What the commit solves for this tree

rtw_drv_init() is the SDIO probe. After 618b4aec, a failed sdio_claim_irq() sets status to failure and tears down a **registered** netdev via rtw_free_netdev() → free_netdev() → BUG_ON. The patch unregisters first, same as remove.

### Stable rules / risk

Meets the written rules: small, no new API, real crash, applies here. Risk is the usual staging caution; this is not a style patch.

### Concerns

Depends on 618b4aec (present here). No reproducer. Staging. Those do not outweigh the BUG_ON.

---

Verification:
- [Phase 1] Tags: author SOB, Greg SOB, msgid Link; no Fixes/Reported- by/Cc: stable
- [Phase 2] Diff: +4/−1 in rtw_drv_init(); goto free_netdev + rtw_unregister_netdevs()
- [Phase 2] free_netdev(): BUG_ON(dev->reg_state != NETREG_UNREGISTERED) at net/core/dev.c:12311
- [Phase 3] Blame: crash path armed by 618b4aec12faa (2025-12); driver added 554c0a3abf216 (2017)
- [Phase 3] git merge-base --is-ancestor 618b4aec HEAD → yes; 51b554f1 in v7.3-rc1, not in v7.2; 618b4aec in v7.0+
- [Phase 3] Pre-fix parent still goto free_if1 on IRQ failure
- [Phase 4] b4 dig -c 51b554f1: msgid [email protected]; v1 only; To Greg + staging + lkml
- [Phase 4] lore 403; IU/openwall: patch only, no replies
- [Phase 4] b4 dig -m wrongly saved Alonso Garrigues style series — ignored
- [Phase 4] 618b4aec appeared as stable 6.19 patch 368/844
- [Phase 5] rtw_drv_init is rtl8723bs_sdio_driver.probe
- [Phase 5] rtw_unregister_netdevs() in os_intfs.c calls unregister_netdev()
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; Makefile 7.3.0-rc4
- [Phase 6] Local rtw_drv_init already has the fix; prerequisite and helper present
- [Phase 7] CONFIG_RTL8723BS tristate, depends on m; hardware listed in Kconfig
- [Phase 8] Failure: kernel BUG on probe IRQ-claim failure; severity CRITICAL if triggered
- UNVERIFIED: complete lore review thread (403); whether every LTS has 618b4aec (not required for this tree)

**YES**

 drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +4 -1
index ae379e99736ad..e9bf6c3b18af0 100644
@@ -379,10 +379,13 @@ static int rtw_drv_init(
 
 	status = sdio_alloc_irq(dvobj);
 	if (status != _SUCCESS)
-		goto free_if1;
+		goto free_netdev;
 
 	status = _SUCCESS;
 
+free_netdev:
+	if (status != _SUCCESS)
+		rtw_unregister_netdevs(dvobj);
 free_if1:
 	if (status != _SUCCESS && if1)
 		rtw_sdio_if1_deinit(if1);
Signature · 1 line
2.53.0
author maintainer
#356 lore raw

PATCH 1/1 iommu/arm-smmu-qcom: Add SM8450 MDSS compatible

In reply to Sasha Levin

From: Esteban Urrutia <[email protected]>

[ Upstream commit d149c8b2c0146a01f1be326ddb1e182b55aee638 ]

Add the compatible for the MDSS client on the Snapdragon 8 Gen 1 so it can be properly configured by the IOMMU driver.

Otherwise, there is an unhandled context fault, because the framebuffer is already configured in UEFI.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit message forensics

**Step 1.1: Subject line**
Record: [iommu/arm-smmu-qcom] [Add] SM8450 MDSS compatible so the Qualcomm SMMU driver can configure that display client

**Step 1.2: Tags**
Record:
- Reviewed-by: Konrad Dybcio <[email protected]> (Qualcomm SoC/display maintainer)
- Signed-off-by: Esteban Urrutia <[email protected]> (author)
- Signed-off-by: Will Deacon <[email protected]> (IOMMU/arm-smmu maintainer)
- No Fixes:, Reported-by:, Tested-by:, Link:, or `Cc:
[email protected]` (absence is expected for this review)

**Step 1.3: Body**
Record:
- Bug: SM8450 MDSS is missing from qcom_smmu_client_of_match, so it does not get the identity-domain workaround.
- Symptom: unhandled ARM SMMU context fault because UEFI already programmed the framebuffer with physical addresses.
- Root cause: without a match, qcom_smmu_def_domain_type() returns 0 and the IOMMU uses a translated DMA domain instead of identity mapping.
- Version info: none in the message. SM8450 display support has been in this tree since v6.3 (drm/msm: mdss add support for SM8450).

**Step 1.4: Hidden bug fix?**
Record: Not hidden. The subject says “Add”, but the body describes a real hardware workaround (IOMMU identity domain for a bootloader- configured display), not a new feature.

## Phase 2: Diff analysis

**Step 2.1: Inventory**
Record:
- File: drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c (+1 / −0)
- Function: static table qcom_smmu_client_of_match[]
- Scope: single-file, one-line compatible addition

**Step 2.2: Code flow**
Record: Before, of_match_device(qcom_smmu_client_of_match, dev) misses qcom,sm8450-mdss, so qcom_smmu_def_domain_type() returns 0. After, that compatible matches and the function returns IOMMU_DOMAIN_IDENTITY. Path: IOMMU default-domain selection at MDSS probe, not an error path.

**Step 2.3: Bug mechanism**
Record: Hardware workaround / device-ID (compatible) addition. MDSS streams keep using the UEFI framebuffer mapping. Without identity domain those accesses translation-fault (arm-smmu: Unhandled context fault). Same pattern as SM6115, SDM670, X1E80100, QCM2290, SC8280XP.

**Step 2.4: Fix quality**
Record: Obviously correct and minimal. Only devices with qcom,sm8450-mdss change behavior. Regression risk is very low; neighboring SoCs already use this table the same way. ACTLR table already listed qcom,sm8450-mdss; the client table was the omission.

## Phase 3: Git history

**Step 3.1: Blame**
Record:
- Table introduced in 0e764a01015df (2020, “Allow client devices to select direct mapping”).
- This line added by d149c8b2c0146 (2026-07-22).
- SM8450 MDSS driver: 80056d9ac47ab (2023-01-12, v6.3-rc1).
- SM8450 DT: a6dd1206e45a4 (2022-12-28).
- Bug window: from v6.3 until this commit (about three years).

**Step 3.2: Fixes: tag**
Record: No Fixes: tag. Implicit introducer is 80056d9ac47ab adding SM8450 MDSS without the IOMMU match. That driver and DT are in this tree.

**Step 3.3: File history**
Record: Several sibling “Add … MDSS compatible” commits (f7fa8520f3037 SM6115, 12721e6600579 X1E80100, 28af105cb6504 QCM2290, 270a1470408e4 SDM670, 617937d4d5533 Glymur). Standalone one-line table entries; SM6115 even had Cc: stable and crash logs. No extra prerequisite beyond the existing match table.

**Step 3.4: Author**
Record: Esteban Urrutia has only this IOMMU commit here. Reviewed by Konrad Dybcio; applied by Will Deacon. Not a drive-by unreviewed change.

**Step 3.5: Dependencies**
Record: Needs qcom_smmu_client_of_match / qcom_smmu_def_domain_type() and a qcom,sm8450-mdss client. All present. No new APIs. Applies as a one-line insert next to qcom,sm8250-mdss.

## Phase 4: Mailing list / external research

**Step 4.1: Original discussion**
Record:
- b4 dig -c d149c8b2c0146 →
https://patch.msgid.link/20260711-sm8450-qol-
[email protected]
- v1: 8-patch “sm8450-qol” series (2026-06-22)
- v2: this patch split out alone (2026-07-11)
- Will Deacon: “Applied to iommu (arm/smmu/updates), thanks!” — no NAK
- Cover note: “This patch allows the MDSS driver to properly function on SM8450 based devices.”
- lore.kernel.org fetches returned 403; content confirmed via patchew and LKML mirror.

**Step 4.2: Recipients (b4 dig -w)**
Record: Will Deacon, Robin Murphy, Joerg Roedel, Rob Clark, Konrad Dybcio; lists iommu@, linux-arm-msm@, linux-arm-kernel@, phone- devel@. Right maintainers and lists.

**Step 4.3: Bug report**
Record: No syzbot/bugzilla. Author describes the UEFI framebuffer context-fault. Same failure as SM6115 (f7fa8520f3037): flood of Unhandled context fault and failed DPU/GPU bind.

**Step 4.4: Series**
Record: v2 is standalone. Other v1 QoL patches (dispcc, dts, qmp) are not required for this one-line match.

**Step 4.5: Stable list**
Record: No stable-thread hit for this subject. Precedent: SM6115 equivalent was Cc: stable.

## Phase 5: Semantic analysis

**Step 5.1: Functions**
Record: Table qcom_smmu_client_of_match[] only. Consumer:
qcom_smmu_def_domain_type().

**Step 5.2: Callers**
Record: qcom_smmu_def_domain_type is .def_domain_type on the Qualcomm SMMU impls. arm_smmu_def_domain_type() in arm-smmu.c calls it; IOMMU core iommu_get_def_domain_type() uses that at device attach. Probe-time, not IRQ/hot path.

**Step 5.3: Callees**
Record: of_match_device() only.

**Step 5.4: Reachability**
Record: Yes, on Qualcomm SM8450 with MDSS enabled (iommus in sm8450.dtsi; &mdss { status = "okay"; } in sm8450-hdk.dts). Userspace does not need to do anything; boot + display probe is enough.

**Step 5.5: Similar patterns**
Record: Same omission pattern for many MDSS SoCs; several already patched. SM8450 was the gap between sm8250 and x1e80100.

## Phase 6: Local tree (this checkout)

**Step 6.1: Does the buggy code exist here?**
Record:
- git describe HEAD: v7.3-rc4-27-gf0100363d8c37
- make kernelversion: 7.3.0-rc4
- This is the 7.3-rc4 mainline checkout, not an older LTS branch.
- Match table, qcom_smmu_def_domain_type(), DRM qcom,sm8450-mdss, and DT node all exist.
- git merge-base --is-ancestor d149c8b2c0146 HEAD succeeded (commit is already in HEAD). That is ignored as “already selected”; it does not change technical merit.
- Without this line, SM8450 MDSS would still take a translated domain on this tree’s code.

**Step 6.2: Backport difficulty**
Record: Clean one-line apply against this file. Context around sm8250-mdss / x1e80100-mdss is stable.

**Step 6.3: Related fixes already here?**
Record: ACTLR prefetch entry for qcom,sm8450-mdss is already present (f91879fdf70bd). That does not set identity domain. No other fix covers this bug.

## Phase 7: Subsystem context

**Step 7.1**
Record: drivers/iommu/arm/arm-smmu/ Qualcomm implementation. IMPORTANT for ARM64 Qualcomm devices; not core mm/VFS, but IOMMU misconfig breaks display on those boards.

**Step 7.2**
Record: Actively maintained (recent Glymur, ACTLR, fastrpc fixes). The match-table mechanism itself dates to 2020 and is mature.

## Phase 8: Impact and risk

**Step 8.1: Who is affected**
Record: SM8450 (Snapdragon 8 Gen 1) boards with MDSS, e.g. sm8450-hdk.dts (status = "okay"). Config: CONFIG_ARM_SMMU + CONFIG_ARM_SMMU_QCOM (default y on ARCH_QCOM).

**Step 8.2: Trigger**
Record: Boot when UEFI left the framebuffer mapped and MDSS probes. Common on these phones/HDKs, not a rare race. Unprivileged userspace is not required.

**Step 8.3: Failure mode**
Record: Unhandled SMMU context faults; display init can fail (same class as SM6115: DPU/GPU bind errors). Severity: HIGH for those devices (broken display, fault spam). Not a universal panic.

**Step 8.4: Risk–benefit**
Record: Benefit high for SM8450 display. Risk very low (one compatible, existing quirk table). Ratio strongly favors backport.

## Phase 9: Synthesis

**Step 9.1: Evidence**

For:
- Real bug: missing identity-domain quirk → SMMU context faults / non- working MDSS
- Hardware quirk / compatible addition (stable exception)
- 1 line, obviously correct
- Reviewed by Konrad Dybcio, applied by Will Deacon
- Same class as SM6115, which was Cc: stable
- SM8450 MDSS has been in this lineage since v6.3
- No new API, no refactor, no extra dependencies

Against:
- No Fixes: / Cc: stable (expected here, not a negative)
- Affects one SoC family, not all machines
- Originally in a “QoL” series (v2 is a standalone bugfix)

Unresolved: lore.kernel.org 403 prevented reading every v1 reply; v2 application and Konrad’s Reviewed-by are verified via patchew/LKML/b4 dig.

**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** — one-line OF match; maintainer review/apply
2. Real user bug? **PASS** — context faults / MDSS broken on SM8450 with UEFI FB
3. Important (crash/security/corruption/deadlock)? **PASS** — unhandled SMMU faults and failed display; HIGH for that hardware
4. Small and contained? **PASS** — +1 line, one file
5. No new features/APIs? **PASS** — existing quirk table only
6. Can apply to this tree? **PASS** — table, MDSS driver, and DT are here

**Step 9.3: Exception**
Record: Device ID / hardware quirk on an existing driver. Automatic YES class.

**Step 9.4: Decision**
This tree (v7.3-rc4) has SM8450 MDSS and the Qualcomm SMMU client table. The patch is the standard identity-domain compatible for a bootloader-configured display. It should be treated as stable material.

Explanation: Without qcom,sm8450-mdss in qcom_smmu_client_of_match, MDSS is attached to a translated IOMMU domain while UEFI still owns a physically addressed framebuffer, which produces unhandled context faults and can prevent the display stack from coming up. Adding the compatible selects IOMMU_DOMAIN_IDENTITY, matching every other Qualcomm MDSS entry in that table. Benefit is working display on SM8450; risk is a single OF match that cannot affect other hardware.

Verification:
- [Phase 1] Parsed tags: Reviewed-by Konrad Dybcio; SOB Esteban Urrutia, Will Deacon; no Fixes/Cc stable
- [Phase 2] Diff: +1 line in qcom_smmu_client_of_match[]; qcom_smmu_def_domain_type() returns IOMMU_DOMAIN_IDENTITY on match
- [Phase 3] git log/git blame: table from 0e764a01015df (2020); SM8450 DRM 80056d9ac47ab (v6.3-rc1); this commit d149c8b2c0146
- [Phase 3] Sibling SM6115 commit f7fa8520f3037 had Cc: stable and context-fault logs
- [Phase 3] git merge-base --is-ancestor d149c8b2c0146 HEAD → yes (already in this checkout)
- [Phase 4] b4 dig -c d149c8b2c0146: v2 at patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1 8-patch QoL series → v2 standalone SMMU patch
- [Phase 4] b4 dig -w: Will Deacon, Robin Murphy, Rob Clark, Konrad Dybcio, iommu@ and linux-arm-msm@
- [Phase 4] patchew: Will Deacon applied; no NAK
- [Phase 4] lore.kernel.org WebFetch: 403 — UNVERIFIED full v1 reply text; v2 content verified via patchew/LKML
- [Phase 5] Callers: arm_smmu_def_domain_type → IOMMU default domain at probe
- [Phase 6] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion: 7.3.0-rc4
- [Phase 6] Confirmed qcom,sm8450-mdss in msm_mdss.c, sm8450.dtsi, HDK &mdss { status = "okay"; }
- [Phase 6] Pre-commit file still had ACTLR sm8450-mdss only; client table lacked it
- [Phase 7] CONFIG_ARM_SMMU_QCOM default y on ARCH_QCOM
- [Phase 8] Failure mode: unhandled SMMU context fault / broken MDSS on SM8450, severity HIGH for that platform
- [Phase 4.5] No stable-list discussion found for this specific commit

**YES**

 drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +1 -0
index f7cb7de80cfb9..b6493e92343be 100644
@@ -394,6 +394,7 @@ static const struct of_device_id qcom_smmu_client_of_match[] __maybe_unused = {
 	{ .compatible = "qcom,sm6375-mdss" },
 	{ .compatible = "qcom,sm8150-mdss" },
 	{ .compatible = "qcom,sm8250-mdss" },
+	{ .compatible = "qcom,sm8450-mdss" },
 	{ .compatible = "qcom,x1e80100-mdss" },
 	{ }
 };
Signature · 1 line
2.53.0
author maintainer
#357 lore raw

PATCH 1/1 ALSA: hda/realtek: Add mute LED quirk for HP Victus 15-fb2xxx

In reply to Sasha Levin

From: Krish Gulati <[email protected]>

[ Upstream commit c748c42abb9b549fc79c41ea55e1f220eadb60ec ]

The HP Victus 15-fb2xxx (PCI SSID 103c:8c2f) with the ALC245 codec does not turn on the mute LED when audio is muted.
Add a quirk entry to enable it.

---

LLM Generated explanations, may be completely bogus:

This is a one-line HP Realtek mute-LED quirk for an existing fixup. The local tree is **6.18.57** (v6.18.57-155-gcdf239ca885b2). The bug exists here: SSID 103c:8c2f is not in v6.18.57, while ALC245_FIXUP_HP_MUTE_LED_COEFBIT and sibling Victus entries already are.

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

Step 1.1: PARSE THE SUBJECT LINE
Record: **[ALSA: hda/realtek]** **[Add]** one-line PCI SSID quirk so the HP Victus 15-fb2xxx mute LED works.

Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- **Reported-by:** [email protected] (real user hit it)
- **Link:** https://bugzilla.kernel.org/show_bug.cgi?id=221946 (user bug report)
- **Link:**
https://patch.msgid.link/[email protected]
(submission)
- **Tested-by:** Raphael Briones \<[email protected]\> (reporter verified the fix)
- **Signed-off-by:** Krish Gulati \<[email protected]\> (author)
- **Signed-off-by:** Takashi Iwai \<[email protected]\> (ALSA maintainer)
- No **Fixes:** tag (expected)
- No original **Cc: stable** (expected; not a negative)
- Pipeline [Upstream commit c748c42abb9b549fc79c41ea55e1f220eadb60ec] and Sasha Levin SOB ignored per instructions

Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** HP Victus 15-fb2xxx, PCI SSID 103c:8c2f, ALC245 codec, mute LED stays off when audio is muted.
- **Symptom:** mute LED does not light (hardware indicator broken; audio itself is not described as broken).
- **Root cause (author):** this SSID is missing from the Realtek quirk table, so the existing ALC245 mute-LED coefbit fixup is never selected.
- **Version info:** none in the message. Reporter later said they tested on kernel 7.2.6-1-cachyos (from the lore thread, not the commit body).

Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a hidden fix. It is an explicit hardware quirk. Same class as the documented stable exception for SND_PCI_QUIRK / HDA codec quirks.

===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================

Step 2.1: INVENTORY THE CHANGES
Record:
- **File:** sound/hda/codecs/realtek/alc269.c (+1 / −0)
- **Function/data:** alc269_fixup_tbl[] only
- **Scope:** single-file, surgical, one table entry

Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- **Before:** snd_hda_pick_fixup() walks alc269_fixup_tbl at ALC269-family probe. SSID 103c:8c2f does not match, so no mute-LED coefbit setup runs.
- **After:** that SSID maps to ALC245_FIXUP_HP_MUTE_LED_COEFBIT, which calls alc245_fixup_hp_mute_led_coefbit() on HDA_FIXUP_ACT_PRE_PROBE and registers the mute LED cdev via snd_hda_gen_add_mute_led_cdev().
- **Path:** device probe / codec init only, and only for this SSID.

Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- **Category:** hardware workaround / existing-driver quirk (h)
- **Mechanism:** ALC245 mute LED on this HP board is driven by codec coef 0x0b bits, not the generic path. Without the quirk, the LED never turns on. The patch does not invent that logic; it reuses alc245_fixup_hp_mute_led_coefbit() already used by nearby Victus IDs (0x8c30 15-fb1xxx, 0x8c2d 15-fa1xxx, 0x8d07 another 15-fb2xxx board).

Verified fixup body in this tree:

```1566:1579:sound/hda/codecs/realtek/alc269.c
static void alc245_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
                                          const struct hda_fixup *fix,
                                          int action)
{
        struct alc_spec *spec = codec->spec;

        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
                spec->mute_led_polarity = 0;
                spec->mute_led_coef.idx = 0x0b;
                spec->mute_led_coef.mask = 3 << 2;
                spec->mute_led_coef.on = 2 << 2;
                spec->mute_led_coef.off = 1 << 2;
                snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
        }
}
```

Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: one SND_PCI_QUIRK(0x103c, 0x8c2f, ..., ALC245_FIXUP_HP_MUTE_LED_COEFBIT) in SSID order between 0x8c2d and 0x8c30.
- SND_PCI_QUIRK uses _SND_PCI_QUIRK_ID(vend, dev) with subdevice_mask = 0xffff, so it matches only this exact SSID.
- Regression risk is very low: no locking, no API, no shared-path logic change. Wrong-board risk is limited to 103c:8c2f. Reporter tested both hardware mute key and software mixer.

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

Step 3.1: BLAME THE CHANGED LINES
Record:
- Insertion sits between existing HP entries. Neighbor 0x8c30 “HP Victus 15-fb1xxx” comes from b474f60f6a0c9 (“Enable Mute Led for HP Victus 15-fb1xxx”, 2024-09-04), present in this tree.
- Mute-LED coefbit helper itself dates to 22c7f77247a84 (“Support mute led function for HP platform”, 2025-04-02), ancestor of v6.18.57.
- This is long-lived driver infrastructure, not post-6.18 code.

Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Not applicable. The “bug” is a missing SSID for hardware that already existed; there is no introducing-commit in the usual sense.

Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- Related: ce174b48aebb3 “Add mute LED support for HP Victus 15-fb2xxx” added **0x8d07** (MB 8D07), not 0x8c2f. That earlier patch even had Cc: [email protected]. Same product line, different motherboard SSID.
- v6.18.57 already has 0x8d07 and 0x8c30. 0x8c2f is the missing sibling.
- Standalone: not patch X/Y. One table line, no series.

Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Krish Gulati has this one Realtek commit in this tree. Not the subsystem maintainer. Weight comes from Takashi Iwai applying it and from the reporter’s Tested-by.

Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS Record:
- Needed pieces in v6.18.57: alc269.c, alc269_fixup_tbl, enum ALC245_FIXUP_HP_MUTE_LED_COEFBIT, alc245_fixup_hp_mute_led_coefbit(), snd_hda_pick_fixup().
- Confirmed present via git grep on v6.18.57.
- Can apply standalone.

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c c748c42abb9b549fc79c41ea55e1f220eadb60ec →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only**, 2026-09-21. No later revision.
- Thread:
1. Krish Gulati submits the one-line quirk.
2. Raphael Briones (reporter): applied on HP Victus 15-fb2xxx, ALC245, SSID 103c:8c2f, kernel 7.2.6-1-cachyos; mute LED works with hardware key and software mixer. Tested-by given.
3. Takashi Iwai (2026-09-28): “Applied now. Thanks.” No NAK, no stable objection.
- Lore HTML fetch returned 403 (Anubis). Thread recovered via b4 dig -m.

Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To/Cc included Jaroslav Kysela, Takashi Iwai, linux-sound, Realtek’s Kailang Yang, and the reporter. Maintainer applied it. No NAK.

Step 4.3: SEARCH FOR THE BUG REPORT
Record: Bugzilla 221946 is cited. Direct HTTP fetch was blocked by Anubis (403). Primary evidence of user impact is the lore Tested-by on the exact SSID, which is verified.

Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone v1. Precedent: ce174b48aebb3 did the same for 15-fb2xxx SSID 0x8d07 and nominated stable.

Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable HTML search also 403. UNVERIFIED whether stable@ discussed this exact 0x8c2f patch. The sibling 0x8d07 change was explicitly Cc’d to stable, which is verified from git.

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: No function body changed. Data: alc269_fixup_tbl[]. Runtime
path: snd_hda_pick_fixup() → ALC245_FIXUP_HP_MUTE_LED_COEFBIT → alc245_fixup_hp_mute_led_coefbit().

Step 5.2: TRACE CALLERS
Record:
- alc269_fixup_tbl is passed from ALC269-family probe in alc269.c (snd_hda_pick_fixup(codec, alc269_fixup_models, alc269_fixup_tbl, alc269_fixups) around line 8557).
- Called during HD-audio codec probe, not IRQ/hot path.
- Impact surface is this one PCI subsystem ID.

Step 5.3: TRACE CALLEES
Record: alc245_fixup_hp_mute_led_coefbit() writes spec->mute_led_* and calls snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set). Existing, already used by many HP entries in this tree.

Step 5.4: FOLLOW THE CALL CHAIN
Record: Userspace-reachable on machines with this laptop: codec probe at boot, then mute LED updates when the user mutes. Not a syscall crash path. Real user-visible hardware behavior.

Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same ALC245_FIXUP_HP_MUTE_LED_COEFBIT already used for many HP Victus SSIDs in v6.18.57 (0x88ee, 0x8a25, 0x8a26, 0x8a4f, 0x8a50, 0x8bbe, 0x8bc8, 0x8c2d, 0x8c30, 0x8d07, …). This is the established pattern, not a one-off experiment.

===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================

Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record:
- Local tree: **Linux 6.18.57** (git describe HEAD = v6.18.57-155-gcdf239ca885b2, VERSION/PATCHLEVEL/SUBLEVEL = 6/18/57).
- v6.18.57 **does not** contain 0x8c2f (git grep 0x8c2f v6.18.57 -- sound/hda/codecs/realtek/alc269.c empty).
- v6.18.57 **does** contain the insertion neighbors 0x8c2d and 0x8c30, and the fixup enum/function.
- Bug is a missing quirk for hardware that this driver already supports.

Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record:
- Mainline context after the new line includes 0x8c3f, which is **not** in v6.18.57 (8c2d is immediately followed by 8c30).
- Applying to v6.18.57 is a trivial one-line insert between those two existing entries (minor context fuzz, not a semantic conflict).
- File path sound/hda/codecs/realtek/alc269.c already exists here (Realtek split commit aeeb85f26c3bbe is in 6.18).

Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: 0x8d07 “HP Victus 15-fb2xxx (MB 8D07)” is already in v6.18.57. That does **not** cover 0x8c2f. No other fix for this SSID in 6.18.57.

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: **ALSA HD-audio / Realtek codec** (sound/hda/codecs/realtek/). **IMPORTANT** for laptop audio, not core mm/scheduler. Quirk tables in this driver are a standard stable target.

Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Actively receiving similar one-line HP mute-LED quirks (Pavilion, Victus, EliteBook). Mature table, same pattern repeated. This is not experimental code.

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver/config-specific: CONFIG_SND_HDA_CODEC_REALTEK users with PCI audio SSID **103c:8c2f** (HP Victus 15-fb2xxx). No effect on other machines.

Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Every boot on that laptop: mute LED stays dark when mute is engaged. Unprivileged users notice it; not a security trigger. Reporter reproduced it on real hardware.

Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: Mute LED does not light. **MEDIUM** functionally (broken hardware indicator, not oops/corruption). Still qualifies under the **hardware quirk exception**, which stable explicitly takes.

Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit:** high for owners of this common HP gaming laptop; restores LED using the same path already shipping for sibling Victus boards.
Precedent: 8d07 was sent to stable.
- **Risk:** very low (1 line, exact SSID match, existing fixup).
- **Ratio:** strongly favors backport.

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

Step 9.1: COMPILE THE EVIDENCE
**FOR:**
- Real user bug + Tested-by on the exact SSID
- Maintainer applied (Takashi Iwai)
- One-line SND_PCI_QUIRK — classic stable exception
- Fixup and neighboring Victus entries already in 6.18.57
- Sibling 15-fb2xxx 0x8d07 quirk was Cc:stable
- No new API, no new function, no shared-path logic change

**AGAINST:**
- Not a crash/security/corruption fix (mute LED only)
- Mainline context line 0x8c3f is absent here (trivial fuzz)

**UNRESOLVED:**
- Bugzilla 221946 page body (HTTP 403)
- Whether stable@ already discussed this exact hash (HTTP 403)

Those gaps do not change the decision: lore + git already show a tested, maintainer-accepted quirk whose prerequisites are in this tree.

Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — 1-line SSID add; reporter tested; maintainer applied
2. Fixes a real bug that affects users? **PASS** — mute LED broken on HP Victus 15-fb2xxx 103c:8c2f
3. Important issue? **PASS** under hardware-quirk exception (severity MEDIUM as a crash class, but explicit stable exception)
4. Small and contained? **PASS** — +1 line, one table
5. No new features or APIs? **PASS** — enables existing fixup for one more ID
6. Can apply to the local tree? **PASS** — file, table, and fixup exist in v6.18.57; insert between 0x8c2d and 0x8c30

Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: **Hardware quirk / SND_PCI_QUIRK for an existing HDA Realtek driver.** This is the documented YES class (audio codec quirks for specific laptop models).

Step 9.4: MAKE YOUR DECISION
Backport. The 6.18.y driver already has the mute-LED machinery and other Victus SSIDs; this only names the missing 103c:8c2f board.

What problem it solves: on HP Victus 15-fb2xxx (103c:8c2f, ALC245) the mute LED never turns on because the SSID is absent from alc269_fixup_tbl. Adding the existing ALC245_FIXUP_HP_MUTE_LED_COEFBIT entry enables the LED. That matters to stable users of this laptop and does not change any other machine.

Risk vs benefit: benefit is restoring a user-visible LED on a current HP model; risk is a single exact-SSID table line. Neighbor 0x8d07 for the same product name already went to stable.

Concerns: apply context may need dropping the mainline 0x8c3f line; that is a one-line mechanical insert, not a semantic dependency.

Verification:
- [Phase 1] Parsed tags: Reported-by, Tested-by (same user), bugzilla 221946, maintainer SOB Takashi Iwai
- [Phase 2] Diff: +1 SND_PCI_QUIRK(0x103c, 0x8c2f, ... ALC245_FIXUP_HP_MUTE_LED_COEFBIT) in alc269_fixup_tbl
- [Phase 2] SND_PCI_QUIRK uses subdevice_mask = 0xffff (include/sound/core.h) — exact SSID only
- [Phase 2] Read alc245_fixup_hp_mute_led_coefbit() at alc269.c:1566 — existing coef 0x0b LED setup
- [Phase 3] git describe HEAD / Makefile: this tree is 6.18.57
- [Phase 3] git merge-base --is-ancestor 22c7f77247a84 v6.18.57 — fixup helper is in 6.18.57
- [Phase 3] git grep 0x8c2f v6.18.57 -- sound/hda/codecs/realtek/alc269.c — empty; bug present
- [Phase 3] git grep on v6.18.57: 0x8c2d, 0x8c30, 0x8d07, ALC245_FIXUP_HP_MUTE_LED_COEFBIT all present
- [Phase 3] ce174b48aebb3 is a different SSID (0x8d07) for the same product line, Cc:stable
- [Phase 4] b4 dig -c c748c42...: lore
https://patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: linux-sound + Takashi Iwai + Jaroslav Kysela
- [Phase 4] mbox: reporter Tested-by on 103c:8c2f; Iwai “Applied now”; no NAK
- [Phase 4] UNVERIFIED: bugzilla HTML and stable@ lore (HTTP 403 / Anubis)
- [Phase 5] alc269_fixup_tbl selected from codec probe via snd_hda_pick_fixup() (alc269.c ~8557)
- [Phase 6] v6.18.57 table has 8c2d then 8c30; 8c3f not in this series — trivial context adjust
- [Phase 8] Failure mode: mute LED dark; severity MEDIUM; quirk exception applies

**YES**

 sound/hda/codecs/realtek/alc269.c | 1 +
 1 file changed, 1 insertion(+)
sound/hda/codecs/realtek/alc269.c +1 -0
index 0a3df8b78aae6..4eefd5d87f04b 100644
@@ -7004,6 +7004,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x103c, 0x8c17, "HP Spectre x360 2-in-1 Laptop 16-aa0xxx", ALC245_FIXUP_HP_SPECTRE_X360_16_AA0XXX),
 	SND_PCI_QUIRK(0x103c, 0x8c21, "HP Pavilion Plus Laptop 14-ey0XXX", ALC245_FIXUP_HP_X360_MUTE_LEDS),
 	SND_PCI_QUIRK(0x103c, 0x8c2d, "HP Victus 15-fa1xxx (MB 8C2D)", ALC245_FIXUP_HP_MUTE_LED_COEFBIT),
+	SND_PCI_QUIRK(0x103c, 0x8c2f, "HP Victus 15-fb2xxx", ALC245_FIXUP_HP_MUTE_LED_COEFBIT),
 	SND_PCI_QUIRK(0x103c, 0x8c30, "HP Victus 15-fb1xxx", ALC245_FIXUP_HP_MUTE_LED_COEFBIT),
 	SND_PCI_QUIRK(0x103c, 0x8c3f, "HP Victus 15-fa1xxx (MB 8C3F)", ALC245_FIXUP_HP_MUTE_LED_COEFBIT),
 	SND_PCI_QUIRK(0x103c, 0x8c46, "HP EliteBook 830 G11", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
Signature · 1 line
2.53.0
author maintainer
#358 lore raw

PATCH 1/1 wifi: mt76: mt7615: fix NULL deref in mt7615_mac_set_rates

In reply to Sasha Levin

From: Felix Fietkau <[email protected]>

[ Upstream commit 98aff74779da9f417386c589c36848e9c568f0f9 ]

mt7615_tx() falls back to the vif BSS wcid when mac80211 hands a frame over without a station, e.g. while a station is being torn down, and to the global wcid when there is no vif either. Both tx_prepare_skb implementations derive a mt7615_sta from that wcid unconditionally and, if the rate control probe flag is set, pass it to mt7615_mac_set_rates(), which dereferences the NULL vif backpointer of the per-vif embedded sta:

  Unable to handle kernel read from unreadable memory at virtual
  address 0000000000000002
  ...
  pc : mt7615_mac_set_rates
  lr : mt7615_tx_prepare_skb

Neither entry is rate controlled by mac80211: the embedded sta has an empty rate set, and for the global wcid the container_of does not yield a valid mt7615_sta at all. Only resolve the sta for wcids that belong to a station.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit message forensics

**Step 1.1 — Subject**
Record: [wifi: mt76: mt7615] [fix] [NULL deref in mt7615_mac_set_rates when TX uses a non-station wcid]

**Step 1.2 — Tags**
Record:
- Reported-by: Chad Monroe <[email protected]> — real user hit this
- `Link:
https://patch.msgid.link/[email protected]` — patch 23/29 of an mt76-next series
- Signed-off-by: Felix Fietkau <[email protected]> — mt76 maintainer
- No Fixes:, no Cc: stable (expected for this review)
- No Reviewed-by / Tested-by / Acked-by on the commit itself
- Ignore Signed-off-by: Sasha Levin / [Upstream commit ...] if present (pipeline)

**Step 1.3 — Body**
Record:
- Bug: mt7615_tx() falls back to the vif BSS wcid when mac80211 TX has no station (e.g. station teardown), and to global_wcid if there is no vif. Both tx_prepare_skb paths container_of that wcid into mt7615_sta and, if IEEE80211_TX_CTL_RATE_CTRL_PROBE is set, call mt7615_mac_set_rates().
- Symptom: kernel NULL deref / oops:
Unable to handle kernel read from unreadable memory at virtual address 0000000000000002, pc: mt7615_mac_set_rates, `lr:
mt7615_tx_prepare_skb`
- Root cause: BSS-embedded sta has a NULL vif backpointer; global_wcid is not a mt7615_sta at all. Neither is rate- controlled.
- Fix: only resolve msta when wcid->sta is set.

**Step 1.4 — Hidden bug fix?**
Record: Not hidden. Explicit crash fix with a stack trace and a reporter.

## Phase 2: Diff analysis

**Step 2.1 — Inventory**
Record:
- drivers/net/wireless/mediatek/mt76/mt7615/pci_mac.c:
mt7615_tx_prepare_skb — ~3 lines
- drivers/net/wireless/mediatek/mt76/mt7615/usb_sdio.c:
mt7663_usb_sdio_tx_prepare_skb — ~3 lines
- Scope: single-driver surgical fix, two TX prepare paths (PCIe/MMIO and USB/SDIO)

**Step 2.2 — Code flow**
Record: Before, any non-NULL wcid was treated as mt7615_sta. After, msta is set only if wcid && wcid->sta. The existing if (... RATE_CTRL_PROBE && msta) already skips mt7615_mac_set_rates() when msta is NULL.

**Step 2.3 — Bug mechanism**
Record: [NULL pointer dereference] — mt7615_mac_set_rates() does sta->vif->mt76.omac_idx. For the per-vif embedded sta, vif is never set. For global_wcid, container_of is invalid. The fix uses the existing wcid->sta flag.

**Step 2.4 — Fix quality**
Record: Obviously correct. Same pattern already used in this tree (wcid_to_sta(), mt76_connac_pm_dequeue_skbs(), mt7615_rx_get_wcid()). Skipping rate-probe setup for non-station wcids is intended: those entries are not rate-controlled. Regression risk is very low. No API change.

## Phase 3: Git history

**Step 3.1 — Blame**
Record: The incomplete NULL check is 8d3cdc1bbb1d3 (“mt76: mt7615: fix NULL pointer dereference in tx_prepare_skb()”, Lorenzo Bianconi, 2021). That only handled wcid == NULL (then global_wcid). The BSS-wcid fallback in mt7615_tx() is from 2019 (04b8e65922f631 / 2b8cdfb28d3402). The bug has been in this lineage since mt7615 TX was added.

**Step 3.2 — Fixes: tag**
Record: None. The incomplete 2021 fix is already in this tree (git merge-base --is-ancestor 8d3cdc1bbb1d3 HEAD succeeded). This commit closes the remaining hole.

**Step 3.3 — File history**
Record: Recent mt7615 changes in this tree are unrelated (runtime-pm timeout, TSF, DMA reset). No prerequisite refactor for this two-line guard. Standalone.

**Step 3.4 — Author**
Record: Felix Fietkau is the mt76 maintainer. Related earlier NULL-deref fix was also signed off by him.

**Step 3.5 — Dependencies**
Record: Patch 23/29 of an mt76-next batch, but the other patches are independent (mt7996/mt7915/scan/WED). This hunk only needs wcid->sta and the existing msta NULL check, both present here. Standalone.

## Phase 4: Mailing list / external

**Step 4.1 — Original discussion**
Record: b4 mbox saved the thread. Subject: `[PATCH mt76-next 23/29]
wifi: mt76: mt7615: fix NULL deref in mt7615_mac_set_rates. Sent 24 Jul 2026 by Felix to linux-wireless. 29-message thread is the series itself, not a v2/v3 of this patch. No NAK. No reviewer Cc: stable. Lore HTTP fetch returned 403; discussion was recovered via b4`.

**Step 4.2 — Recipients**
Record: To: [email protected]. Maintainer is the author.

**Step 4.3 — Bug report**
Record: Reported-by Chad Monroe with a concrete oops (`pc:
mt7615_mac_set_rates, lr: mt7615_tx_prepare_skb`). Chad also authored other patches in the same series, so this is a real device user, not a theoretical report.

**Step 4.4 — Series**
Record: Independent mt76 bug-fix dump. mt7996 patches are irrelevant to 5.15. This patch does not need 1–22 or 24–29.

**Step 4.5 — Stable list**
Record: UNVERIFIED — lore.kernel.org/stable HTTP 403. No evidence it was rejected for stable.

## Phase 5: Semantic / call-chain

**Step 5.1 — Functions**
Record: mt7615_tx_prepare_skb, mt7663_usb_sdio_tx_prepare_skb (callers of mt7615_mac_set_rates).

**Step 5.2 — Callers**
Record:
- PCIe/MMIO: mt7615_tx_prepare_skb via mt7615/mmio.c .tx_prepare_skb, from mt76_dma_tx_queue_skb (dma.c:409)
- USB: usb.c:917; SDIO: sdio.c:263
- Upstream of that: mt7615_tx() → mt76_tx() / mt76_connac_pm_queue_skb()

**Step 5.3 — Callees**
Record: mt7615_mac_set_rates() immediately uses sta->vif->mt76.omac_idx (mac.c:1063 in this tree).

**Step 5.4 — Reachability**
Record: Yes, from normal wireless TX. mt7615_tx():

```737:743:drivers/net/wireless/mediatek/mt76/mt7615/main.c
        if (vif && !control->sta) {
                struct mt7615_vif *mvif;
                mvif = (struct mt7615_vif *)vif->drv_priv;
                msta = &mvif->sta;
                wcid = &msta->wcid;
        }
```

mac80211 can pass control->sta == NULL while IEEE80211_TX_CTL_RATE_CTRL_PROBE is still set on a previously rate- controlled skb (station teardown). That is a userspace-reachable AP/client path.

**Step 5.5 — Similar patterns**
Record: Same wcid && wcid->sta guard already exists in mt76x02_mac.c, mt76_connac_mac.c, wcid_to_sta(). mt7615_rx_get_wcid() already refuses non-station wcids. wcid.sta = 1 is set only in mt7615_mac_sta_add(), not in mt7615_add_interface().

## Phase 6: Local tree (5.15.221 / pending-5.15)

**Step 6.1 — Buggy code present?**
Record: Yes.
- pci_mac.c:142: msta = wcid ? container_of(wcid, struct mt7615_sta, wcid) : NULL;
- usb_sdio.c:200: same
- mac.c:1063: u16 idx = sta->vif->mt76.omac_idx;
- add_interface sets mvif->sta.wcid but never mvif->sta.vif or wcid.sta
- wcid->sta exists in struct mt76_wcid (mt76.h:251)

**Step 6.2 — Backport difficulty**
Record: Minor context mismatch, easy rework. Mainline USB path has extra locals (key, pktid) and an in-function global_wcid fallback that 5.15 keeps in mt7663_usb_sdio_write_txwi(). PCIe path uses MT_TX_HW_QUEUE_EXT_PHY / mdev->phy2 here vs later phys[MT_BAND1]. The semantic change is the same two-line wcid->sta check. mt76_vif_link in the provided hunk context is *not* required.

**Step 6.3 — Related fixes already here?**
Record: 8d3cdc1bbb1d3 is present and is incomplete. No later mt7615_mac_set_rates NULL-deref fix in this tree.

## Phase 7: Subsystem context

**Step 7.1**
Record: [drivers/net/wireless/mediatek/mt76/mt7615] [IMPORTANT] — not core kernel, but a widely used 802.11ac chipset (MT7615E/MT7663E PCIe, MT7663U USB, MT7663S SDIO, MT7622 SoC WMAC). Common on routers and embedded boards, including 5.15 LTS/Android/OpenWrt-class systems.

**Step 7.2**
Record: Mature driver; this bug is old, not a new-subsystem issue.

## Phase 8: Impact and risk

**Step 8.1 — Who is affected**
Record: Users of MT7615/MT7663/MT7622 (CONFIG_MT7615E / CONFIG_MT7663U / CONFIG_MT7663S / CONFIG_MT7622_WMAC). Driver- specific, not universal.

**Step 8.2 — Trigger**
Record: TX without a station while IEEE80211_TX_CTL_RATE_CTRL_PROBE is set — typically station teardown / disconnect with a probe rate sample in flight. Not every packet, but a normal Wi-Fi event. Unprivileged clients disconnecting from an AP can induce it.

**Step 8.3 — Failure mode**
Record: [Kernel oops / NULL deref in hard TX path] [CRITICAL]

**Step 8.4 — Risk vs benefit**
Record: Benefit high for that hardware (prevents oops). Risk very low (~6 lines, existing flag, same pattern as sibling code). Skipping mac_set_rates on BSS/global wcid is the correct behavior.

## Phase 9: Synthesis

**Step 9.1 — Evidence**

FOR:
- Real oops with reporter and stack trace
- Bug and incomplete 2021 fix both exist in this 5.15 tree
- Small, obviously correct guard
- Maintainer-authored
- Matches stable rules (crash, contained, no new API)
- Hardware is common on 5.15-era devices

AGAINST:
- Driver-specific, not core
- Won’t git am cleanly (context only)
- Part of a 29-patch series (other patches are unrelated)
- No Fixes: / Cc: stable (not a negative under these rules)
- No mailing-list review tags on this specific patch

UNRESOLVED:
- Could not fetch lore/stable over HTTP (403); recovered the thread with b4
- Exact crash address ...0002 matches a newer vif layout; in 5.15 omac_idx is at offset 1. Same NULL vif deref either way.

**Step 9.2 — Stable rules**
1. Obviously correct and tested? **PASS** — maintainer fix; user- reported oops; logic matches existing wcid->sta usage
2. Real bug affecting users? **PASS** — Chad Monroe crash
3. Important (crash/security/corruption/deadlock)? **PASS** — kernel oops in TX
4. Small and contained? **PASS** — two functions, ~6 lines
5. No new features/APIs? **PASS**
6. Can apply to this tree? **PASS** — code is here; needs a trivial context tweak, not a rewrite

**Step 9.3 — Exceptions**
Record: None (not a device-ID/quirk/DT/build/docs exception). It qualifies as a normal crash fix.

**Step 9.4 — Decision**
This is a real NULL deref in the mt7615 TX path that 5.15 still has. The 2021 patch only covered a NULL wcid; the BSS-wcid fallback still crashes. Backport it.

## What the commit solves for this tree

On 5.15.221, mt7615_tx() still substitutes the per-vif embedded sta when mac80211 has no station. tx_prepare_skb still container_ofs that wcid and can call mt7615_mac_set_rates(), which immediately loads sta->vif->mt76.omac_idx while vif is NULL. That oopses. Restricting msta to wcid->sta stops it. Same change belongs in both PCIe and USB/SDIO prepare paths.

Risk is a skipped rate-probe update on wcids that were never valid for rate control. Benefit is avoiding a driver oops during client teardown.

## Verification
- [Phase 1] Parsed tags: Reported-by Chad Monroe; Link to 23/29 mt76-next; SOB Felix Fietkau; no Fixes/Cc stable
- [Phase 2] Diff: two msta assignments; require wcid->sta before container_of
- [Phase 3] Blame: 8d3cdc1bbb1d3 (2021) only NULL-wcid; BSS fallback since 2019
- [Phase 3] git merge-base --is-ancestor 8d3cdc1bbb1d3 HEAD: yes, incomplete fix is here
- [Phase 3] git log --grep="fix NULL deref in mt7615_mac_set_rates" -- mt7615/: not in this tree
- [Phase 4] b4 mbox [email protected]: 29-message independent mt76 series; this patch standalone; no NAK
- [Phase 4] lore HTTP 403; UNVERIFIED stable@ discussion
- [Phase 5] Call chain: mac80211 drv_tx → mt7615_tx → mt76_tx / DMA tx_prepare_skb → mt7615_mac_set_rates
- [Phase 5] mt7615_add_interface does not set mvif->sta.vif or wcid.sta; only mt7615_mac_sta_add sets wcid.sta = 1
- [Phase 6] make kernelversion / Makefile: **5.15.221**, branch pending-5.15
- [Phase 6] Buggy lines present in pci_mac.c:142 and usb_sdio.c:200; deref at mac.c:1063
- [Phase 6] Surrounding context differs (phy2 vs phys[MT_BAND1], USB locals); semantic apply is still two lines
- [Phase 8] Failure: NULL deref oops in TX; severity CRITICAL for MT7615/MT7663/MT7622 users

**YES**

 drivers/net/wireless/mediatek/mt76/mt7615/pci_mac.c  | 5 +++--
 drivers/net/wireless/mediatek/mt76/mt7615/usb_sdio.c | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/pci_mac.c +3 -2
index b795d11d943d0..61efdf59133f5 100644
@@ -68,10 +68,11 @@ int mt7615_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
 	int pid, id;
 	u8 *txwi = (u8 *)txwi_ptr;
 	struct mt76_txwi_cache *t;
-	struct mt7615_sta *msta;
+	struct mt7615_sta *msta = NULL;
 	void *txp;
 
-	msta = wcid ? container_of(wcid, struct mt7615_sta, wcid) : NULL;
+	if (wcid && wcid->sta)
+		msta = container_of(wcid, struct mt7615_sta, wcid);
 	if (!wcid)
 		wcid = &dev->mt76.global_wcid;
 
drivers/net/wireless/mediatek/mt76/mt7615/usb_sdio.c +3 -2
index 820b395900275..01e79f37649c1 100644
@@ -187,10 +187,11 @@ int mt7663_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
 	struct sk_buff *skb = tx_info->skb;
 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
 	struct ieee80211_key_conf *key = info->control.hw_key;
-	struct mt7615_sta *msta;
+	struct mt7615_sta *msta = NULL;
 	int pad, err, pktid;
 
-	msta = wcid ? container_of(wcid, struct mt7615_sta, wcid) : NULL;
+	if (wcid && wcid->sta)
+		msta = container_of(wcid, struct mt7615_sta, wcid);
 	if (!wcid)
 		wcid = &dev->mt76.global_wcid;
 
Signature · 1 line
2.53.0
author maintainer
#359 lore raw

PATCH 1/1 selftests/cgroup: Adjust cpu test duration based on HZ

In reply to Sasha Levin

From: Joe Simmons-Talbott <[email protected]>

[ Upstream commit a2703c2980c0776e9be7d8f9e144afd054dddb12 ]

For lower HZ values a quota of 1000us is much lower than the amount of microseconds per tick which makes the tests test_cpucg_max and test_cpugc_max_nested fail. Increase the test duration to accommodate for lower HZ values.

---

LLM Generated explanations, may be completely bogus:

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**
- Subsystem: selftests/cgroup
- Action verb: **Adjust** (makes tests pass on low-HZ kernels)
- Claimed intent: scale test_cpucg_max / test_cpucg_max_nested duration from CONFIG_HZ so a 1000µs quota is not smaller than one tick.

Record: [selftests/cgroup] [Adjust] [scale cpu.max test duration by HZ so tests do not fail on low-HZ kernels]

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- `Link: https://lore.kernel.org/lkml/20260625203307.1114538-1-
[email protected]/`
- Signed-off-by: Joe Simmons-Talbott <[email protected]> (author)
- Acked-by: Michal Koutný <[email protected]> (cgroup reviewer)
- Signed-off-by: Tejun Heo <[email protected]> (cgroup maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, `Cc:
stable` (absence expected)
- Ignoring pipeline Signed-off-by: Sasha Levin and [Upstream commit ...]

Record: Author Red Hat; Ack from Michal Koutný; applied by Tejun Heo; lore link present; no syzbot/CVE.

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
The body is two sentences: a 1000µs cpu.max quota is much smaller than microseconds-per-tick at low HZ, so test_cpucg_max and test_cpugc_max_nested (typo for test_cpucg_max_nested) fail. The fix is a longer run so averaging can absorb tick quantization.

Record:
- Bug: kselftest false FAIL on low CONFIG_HZ
- Symptom: test_cpu cpu.max cases fail
- Root cause: 1000µs quota vs tick (HZ=100 → 10ms/tick)
- No kernel oops/corruption described; kernel bandwidth behavior is expected

**Step 1.4: DETECT HIDDEN BUG FIXES**
Not disguised cleanup. It is an explicit test-robustness fix. Not a kernel bug.

Record: [Not a hidden kernel bug; it is a selftest false-failure fix]

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES**
- tools/testing/selftests/cgroup/lib/include/cgroup_util.h: +1 (NSEC_PER_USEC)
- tools/testing/selftests/cgroup/test_cpu.c: +38 / −6
- Functions: new get_config_hz(); modified test_cpucg_max(), test_cpucg_max_nested()

Record: [2 files, +38/−6] [get_config_hz, test_cpucg_max, test_cpucg_max_nested] [single-subsystem surgical selftest fix]

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Before: hog runs 1.0s wall time; expected usage = 10 periods × 1000µs = 10ms; pass if within 10% via values_close_report.
After: duration_usec = 1s * 1000 / hz (HZ=1000 → 1s; HZ=250 → 4s; HZ=100 → 10s). Hog timespec and expected-usage math both use the scaled duration.

Record: [normal test path only: 1s hog → HZ-scaled hog; expected usage scales with duration]

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Category: **logic / test correctness** (tick quantization vs tight 10% check).

Michal Koutný’s v2 review: tasks overrun quota on a long tick; CFS compensates over several periods; 1s is too short for that average to land inside 10%. Longer duration was chosen over changing the quota (so the same 1000µs quantity is still what is tested). Joe confirmed both approaches passed 10 iterations; they took the simpler duration approach.

Record: [test robustness] [quota < tick ⇒ usage noise; longer run shrinks relative error]

**Step 2.4: ASSESS THE FIX QUALITY**
- Small, reviewed, v1→v5, Acked, applied to cgroup/for-7.3.
- duration_usec % USEC_PER_SEC * NSEC_PER_USEC is left-to-right and correct.
- 1 * USEC_PER_SEC * 1000 fits in 32-bit long.
- Residual issues: get_config_hz() only reads /proc/config.gz; fallback HZ=1000 leaves duration at 1s, so kernels without CONFIG_IKCONFIG_PROC still fail (Tao Cui raised this on v2 for the old quota fallback; v5 still defaults to 1000). popen+grep is best-effort. Reviewer noted SMP noise may still need later work. No follow-up changed get_config_hz() on origin/master.

Record: [obviously correct for the stated goal; residual fallback limitation; userspace-only so kernel regression risk is none]

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**
test_cpucg_max added in 889ab8113ef13 (David Vernet, 2022-04). Duration/quota/10% check came from 954bacce36d97 (“selftests/cgroup:
fix cpu.max tests”, 2025-07, in v6.18). That commit replaced a broken inverted 95% check with a real 10% comparison, which is what makes low- HZ mismatch actually fail.

Record: `[buggy tightness: 954bacce36d97, in v6.18; tests themselves:
889ab8113ef13 / a79906570f964, v5.19 era]`

**Step 3.2: FOLLOW THE FIXES: TAG**
No Fixes: tag. N/A.

**Step 3.3: CHECK FILE HISTORY**
Recent related: 954bacce36d97 (cpu.max expected-usage math), 4cdde87d723a0 (values_close_report). Standalone; not patch X/Y.

Record: [standalone follow-on to the 2025 cpu.max test correction already in this tree]

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Joe Simmons-Talbott: this is the only cgroup selftest commit in this history. Michal Koutný Ack; Tejun Heo applied.

Record: [distro engineer + subsystem maintainer path]

**Step 3.5: DEPENDENT/PREREQUISITE COMMITS**
Needs values_close_report and the 2025 expected-usage math — both in v6.18.53. NSEC_PER_USEC is added here. BUF_SIZE vs PAGE_SIZE header rename (6e9f5c2eecd10) is **not** in v6.18.53 and is **not** required.

Record: [no missing prerequisites in this tree; can apply standalone]

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
b4 dig -c a2703c2980c0776e9be7d8f9e144afd054dddb12 matched:
- v3: https://patch.msgid.link/[email protected]
- v4 RESEND:
https://patch.msgid.link/[email protected]
- v5 (applied):
https://patch.msgid.link/[email protected]

v1/v2 changed **quota** to one tick. Michal asked not to change the tested value; Joe tried unaligned-expectation math and longer duration; both passed 10 runs; v3+ uses duration. v4 naming nits; v5 inlines timespec math. No NAKs. No Cc: stable in review.

Record: [v5 applied; no NAK; no stable nomination in thread]

**Step 4.2: CHECK WHO REVIEWED**
b4 dig -w: Tejun Heo, Johannes Weiner, Michal Koutný, Shuah Khan, cgroups@, linux-kselftest@. Michal Acked v5; Tejun: “Applied to cgroup/for-7.3.”

Record: [right lists; maintainer applied]

**Step 4.3: SEARCH FOR THE BUG REPORT**
No bugzilla/syzbot. Author hit it in testing. Tao Cui confirmed the low- HZ failure mode in review.

Record: [reproduced by author; 10 clean iterations after the duration change]

**Step 4.4: RELATED PATCHES AND SERIES** Standalone. Later origin/master commits on the same file (77bc7e952f660, 0c893d170ff8e) are unrelated.

Record: [standalone]

**Step 4.5: CHECK STABLE MAILING LIST HISTORY** lore.kernel.org returned 403; lei q hung and was killed.

Record: [UNVERIFIED: no stable@ thread retrieved; none in the cgroup thread]

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: KEY FUNCTIONS**
get_config_hz, test_cpucg_max, test_cpucg_max_nested.

**Step 5.2: TRACE CALLERS**
Both tests are registered with T(test_cpucg_max) / T(test_cpucg_max_nested) in test_cpu.c (v6.18.53 lines 791–792). Invoked only when running that kselftest as root. Not kernel, IRQ, or syscall.

**Step 5.3: TRACE CALLEES**
cg_create / cg_write("cpu.max") / cg_run(..., hog_cpus_timed) / cg_read_key_long("cpu.stat") / values_close_report. hog_cpus_timed burns CPU for the given timespec on CLOCK_MONOTONIC.

**Step 5.4: CALL CHAIN / REACHABILITY**
Userspace kselftest only. Trigger: run test_cpu on a low-HZ kernel with cgroup cpu controller. Unprivileged users do not hit this.

**Step 5.5: SIMILAR PATTERNS**
No other get_config_hz in this cgroup selftest dir. Michal noted BPF selftests have similar HZ helpers. No sibling drivers with the same bug.

---

## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Local tree: **v6.18.53** (VERSION=6, PATCHLEVEL=18, SUBLEVEL=53; git describe HEAD starts at v6.18.53).
v6.18.53 test_cpu.c still uses duration_seconds = 1 and quota_usec = 1000 in both tests. Upstream a2703c2980c0776e9be7d8f9e144afd054dddb12 is **not** an ancestor of v6.18.53.

Record: [yes, buggy 1s/1000µs tests are in v6.18.53]

**Step 6.2: BACKPORT COMPLICATIONS**
git show a2703c… | patch -p1 --dry-run on a v6.18.53 archive of tools/testing/selftests/cgroup succeeded on both files.

Record: [clean apply]

**Step 6.3: RELATED FIXES ALREADY HERE**
954bacce36d97 (correct expected-usage + 10% check) is in v6.18. No later HZ-duration fix. No equivalent workaround.

Record: [no substitute already present]

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: SUBSYSTEM AND CRITICALITY** tools/testing/selftests/cgroup — kselftests, not kernel/ or mm/.

Record: [kselftests / cgroup cpu controller] [PERIPHERAL for production runtime; IMPORTANT for distro/CI validation of this tree]

**Step 7.2: SUBSYSTEM ACTIVITY**
v6.18..v6.18.53 has **236** commits under tools/testing/selftests/, including cgroup ones (13cf95d19e84b, 0ef3f5629051f). This series already takes kselftest correctness/flake fixes.

Record: [this 6.18.y tree regularly backports selftest fixes]

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: WHO IS AFFECTED**
People running selftests/cgroup/test_cpu on CONFIG_HZ 100/250/300. Production cgroup cpu.max behavior is unchanged.

Record: [config-specific kselftest users / distro CI]

**Step 8.2: TRIGGER CONDITIONS**
Run the cpu.max tests on low HZ. Common on Debian-style HZ=250 and some servers at HZ=100. Not unprivileged. Not a race; quantization + short window.

**Step 8.3: FAILURE MODE SEVERITY**
False kselftest FAIL. Kernel stays up. No corruption/UAF.

Record: [false test failure] [LOW for runtime; MEDIUM for CI that gates 6.18.y]

**Step 8.4: RISK-BENEFIT**
- Benefit: stops known false FAILs on configs this tree still ships; matches other selftest backports already in 6.18.53.
- Risk: userspace-only; no kernel locking/alloc/API change. Worst case:
tests stay FAIL without /proc/config.gz, same as today; or tests run up to ~10s on HZ=100.

Record: [moderate CI benefit / very low risk]

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: EVIDENCE**

FOR:
- Real, reproduced failure of tests that exist in v6.18.53
- Small (+38/−6), clean apply, no kernel code
- v5 reviewed; Acked-by Michal Koutný; applied by Tejun Heo
- This 6.18.y tree already backports kselftest flake/correctness fixes
- Zero production regression surface

AGAINST:
- Not a kernel crash/security/corruption/deadlock
- Best-effort HZ probe; fallback HZ=1000 does not help without config.gz
- Reviewer expected possible later SMP tuning
- No Cc: stable in the thread (not used as a negative per instructions)

UNRESOLVED:
- Stable@ archive search (lore 403, lei hung)

**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — v5 after review; author ran 10 iterations; maintainer applied.
2. Fixes a real bug that affects users? **PASS** — false FAILs of in- tree tests on valid HZ; Red Hat author hit it.
3. Important issue? **PASS** under this tree’s practice (“oh, that’s not good” kselftest failures), not under oops/CVE. Analogous to flake fixes already in 6.18.y.
4. Small and contained? **PASS** — two selftest files, &lt;50 lines.
5. No new features or APIs? **PASS** — duration scaling only.
6. Can apply to the local tree? **PASS** — dry-run clean on v6.18.53; prerequisites present.

**Step 9.3: EXCEPTION CATEGORIES**
Not a device ID/quirk/DT/build/doc fix. Closest: isolated userspace test fix with the same risk profile as a build/doc fix.

**Step 9.4: DECISION**
The tests and the tight 10% check are in this 6.18.53 tree; the kernel bug is not, because there is no kernel bug. The patch only stops those tests from failing on low HZ, applies cleanly, and cannot regress kernel runtime. For this tree, that is enough.

What it solves for stable users: distro/CI test_cpu cpu.max cases on HZ&lt;1000. It meets the written rules as a small, tested, in-tree test fix. Risk is negligible versus the CI benefit.

---

## Verification

- [Phase 1] Parsed tags: Link to lore; SOB Joe Simmons-Talbott; Ack Michal Koutný; SOB Tejun Heo; no Fixes/Reported-by/Cc:stable
- [Phase 1] Body: low HZ + 1000µs quota ⇒ test_cpucg_max / nested fail
- [Phase 2] Diff: +NSEC_PER_USEC; +get_config_hz() via zcat /proc/config.gz; duration * 1000 / hz in both tests
- [Phase 2] Operator precedence of %/* verified; 1e9 fits in 32-bit long
- [Phase 3] git describe HEAD / Makefile: **6.18.53**
- [Phase 3] git merge-base --is-ancestor a2703c2980c0776e9be7d8f9e144afd054dddb12 v6.18.53 → not present
- [Phase 3] blame: tests 889ab8113ef13 / a79906570f964 (2022); 10% check 954bacce36d97 (in v6.18)
- [Phase 3] values_close_report present at v6.18.53 test_cpu.c:694,765
- [Phase 4] b4 dig -c a2703c…: v3/v4/v5 msgid links; b4 dig -a/-w/-m used
- [Phase 4] v2 thread: Michal proposed duration formula; Joe: both approaches passed 10 runs
- [Phase 4] v5: Michal Ack; Tejun applied to cgroup/for-7.3; no NAK; no stable Cc
- [Phase 4] lore.kernel.org WebFetch 403; lei stable search killed after 30s → UNVERIFIED stable@
- [Phase 5] Tests only in T(...) table; hog_cpus_timed is wall-clock hog
- [Phase 6] v6.18.53 still has duration_seconds = 1 / quota_usec = 1000
- [Phase 6] patch --dry-run of a2703c on v6.18.53 cgroup selftests:
clean
- [Phase 6] 6e9f5c2eecd10 BUF_SIZE rename not in v6.18.53; not required
- [Phase 6] no later get_config_hz change on origin/master
- [Phase 7] git log v6.18..v6.18.53 -- tools/testing/selftests/ → 236 commits
- [Phase 8] Failure = kselftest FAIL only; kernel path untouched
- UNVERIFIED: whether /proc/config.gz is typical on 6.18.y distro test images (fallback limitation stands either way)

The tests this commit repairs are in this 6.18.53 tree, the patch applies cleanly, and it does not touch kernel runtime.

**YES**

 .../cgroup/lib/include/cgroup_util.h          |  1 +
 tools/testing/selftests/cgroup/test_cpu.c     | 43 ++++++++++++++++---
 2 files changed, 38 insertions(+), 6 deletions(-)
tools/testing/selftests/cgroup/lib/include/cgroup_util.h +1 -0
index 7ab2824ed7b54..b9cd00e0e8349 100644
@@ -8,6 +8,7 @@
 
 #define MB(x) (x << 20)
 
+#define NSEC_PER_USEC	1000L
 #define USEC_PER_SEC	1000000L
 #define NSEC_PER_SEC	1000000000L
 
tools/testing/selftests/cgroup/test_cpu.c +37 -6

89 lines not on this page · raw message

Signature · 1 line
2.53.0
author maintainer
#360 lore raw

PATCH 1/1 ALSA: hda/intel: Add sanity check for BAR0 size

In reply to Sasha Levin

From: Takashi Iwai <[email protected]>

[ Upstream commit 9895573b0185f922be4cf500a0f2e5b9560ab1c3 ]

The recent reports from syzkaller showed that we can bind any wild PCI device to HD-audio controller, and if PCI BAR of the device is too small, it may lead to a crash, as the driver believes as if the full register range were accessible.

For avoiding such a problem, add a safeguard before the actual probe to check the available BAR0 size.

Note that the threshold (0x200) is chosen to cover all needed registers at probing. But this doesn't mean that it would cover fully for all features including the extended ones.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit message forensics

**Step 1.1: Subject line**
Record: [ALSA: hda/intel] [Add] sanity check for BAR0 size — safeguard in the Intel HD-audio PCI probe path.

**Step 1.2: Tags**
Record:
- Reported-by: [email protected]
- Closes: https://syzkaller.appspot.com/bug?extid=10cd2d1efe8eeb604bee
- Reported-by: [email protected]
- Closes: https://syzkaller.appspot.com/bug?extid=5ebe7cd17e48b4293660
- Link: https://patch.msgid.link/[email protected]
- Signed-off-by: Takashi Iwai <[email protected]> (ALSA maintainer; applied his own patch)
- No Fixes: tag (expected)
- No Cc: stable (expected)
- No Reviewed-by / Tested-by / Acked-by

Notable: two independent syzbot reports with C reproducers.

**Step 1.3: Body**
Record:
- **Bug:** binding a non-HD-audio / undersized-BAR PCI device to snd- hda-intel lets the driver treat BAR0 as a full HD-audio register window.
- **Symptom:** kernel paging oops while reading controller registers.
- **Root cause:** no check of pci_resource_len(pci, 0) before pcim_iomap_regions + MMIO reads.
- **Fix:** reject probe if BAR0 < 0x200.
- **Caveat:** 0x200 covers probe-time registers (GCAP at 0x00, LLCH at 0x14), not the full extended register set.
- No version range given.

**Step 1.4: Hidden bug fix?**
Record: Not hidden. It is an explicit crash-prevention check, even though the verb is “Add”.

## Phase 2: Diff analysis

**Step 2.1: Inventory**
Record:
- Upstream file: sound/hda/controllers/intel.c (+9 / −0)
- Function: azx_probe()
- Scope: single-file surgical check before snd_card_new()

**Step 2.2: Code flow**
Record:
Before: after the dmic_detect / DSP-driver selection block, probe continues into snd_card_new() → azx_create() → later azx_first_init(), which iomaps BAR0 and reads registers with no size check.
After: if BAR0 length < 512 bytes, log "Too small PCI BAR0" and return -EINVAL before allocating a card.

**Step 2.3: Bug mechanism**
Record: **Memory safety / out-of-bounds MMIO**. pcim_iomap_regions() maps whatever BAR0 exists. azx_readw(GCAP) and snd_hdac_bus_parse_capabilities() then readw past the mapping → #PF / oops. Category (g)+(h): logic/correctness guard plus a hardware/binding sanity check.

**Step 2.4: Fix quality**
Record: Obviously correct. pci_resource_len() is the standard helper. 0x200 is well below a real HD-audio BAR (typically 16KB / 0x4000 per spec); legitimate devices will not be rejected. Regression risk is very
low: only devices with BAR0 < 512 bytes fail probe, which could not work anyway. Incomplete vs. every later register (author notes that); still sufficient for the reported oops.

## Phase 3: Git history

**Step 3.1: Blame**
Record: Insertion point is immediately before snd_card_new() in azx_probe(), blamed to Takashi Iwai 2014 (60c5772b50fe) / original driver era (e58de7baf7de, ^1da177e4c3f41). The missing BAR check is not a recent regression; the driver has always assumed a full controller BAR.

**Step 3.2: Fixes: tag**
Record: None. The “bug” is long-standing missing validation, not a single introducing commit.

**Step 3.3: File history**
Record: Recent hda_intel.c commits in this tree are device IDs, denylist, and PM quirks. No prior BAR0 size check, no conflicting refactor of azx_probe(). Standalone, not patch X/Y.

**Step 3.4: Author**
Record: Takashi Iwai is the ALSA/HDA maintainer. He authored and committed the patch the same day (2026-08-13). Strong maintainer signal.

**Step 3.5: Dependencies**
Record: None. Uses pci_resource_len() (include/linux/pci.h in this tree). Surrounding azx_probe() context (dmic_detect warning, then snd_card_new) matches this checkout. Standalone.

Upstream SHA 9895573b0185 exists as an object but is **not** an ancestor of HEAD (git merge-base --is-ancestor exit 1).

## Phase 4: Mailing list / external

**Step 4.1: Original discussion**
Record: b4 dig -c 9895573b0185 →
https://patch.msgid.link/[email protected]
b4 dig -a: **v1 only**, no later revisions.
b4 dig -m: thread is the single patch email; **no replies, no NAK, no
Cc: stable suggestion**. Maintainer self-applied (~1 hour later).

Lore WebFetch returned 403; discussion was recovered from the b4 mbox instead.

**Step 4.2: Recipients**
Record (b4 dig -w): Takashi Iwai, [email protected] only. Appropriate list; author is the maintainer.

**Step 4.3: Bug reports**
Record (syzkaller, both marked **prio:high**, C repro, fix commit 9895573b0185):

1. extid=10cd2d1efe8eeb604bee — BUG: unable to handle kernel paging request in snd_hdac_bus_parse_capabilities

  RIP: `readw` of LLCH (`+0x14`) in `snd_hdac_bus_parse_capabilities`;
  caller `azx_first_init` → `azx_probe_work`.
  Security notes: DenialOfService yes, Exploitable yes, Unprivileged no,
  PeripheralTrigger yes, VMHostTrigger yes.

2. extid=5ebe7cd17e48b4293660 — BUG: unable to handle kernel paging request in azx_probe_work

  RIP: `azx_readw(GCAP)` in `azx_first_init`. Same workqueue path. DoS
  yes, unprivileged no.

**Step 4.4: Series**
Record: Standalone v1. No sibling patches required.

**Step 4.5: Stable list**
Record: lore.kernel.org/stable WebFetch 403. UNVERIFIED: no independent confirmation of a prior stable request/rejection. Absence of `Cc:
stable` is expected for this review pipeline.

## Phase 5: Semantic / call-chain

**Step 5.1: Functions**
Record: azx_probe() only (new early return). Crash site functions
unchanged: azx_first_init(), snd_hdac_bus_parse_capabilities().

**Step 5.2: Callers**
Record: azx_probe is azx_driver.probe (module_pci_driver(azx_driver)). Invoked on PCI bind of matching IDs, including the generic Intel class match:

```2595:2599:sound/pci/hda/hda_intel.c
        /* Generic Intel */
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_ANY_ID),
          .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8,
          .class_mask = 0xffffff,
          .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_NO_ALIGN_BUFSIZE },
```

Similar class catch-alls exist for NVIDIA/ATI/AMD. Binding also works via sysfs new_id / driver_override (privileged).

**Step 5.3: Callees of the crash path (this tree)**
Record: azx_first_init() does pcim_iomap_regions(pci, 1 << 0, ...), then snd_hdac_bus_parse_capabilities(bus) for SKL, then azx_readw(chip, GCAP) at offset 0x00. snd_hdac_bus_parse_capabilities() starts with snd_hdac_chip_readw(bus, LLCH) at 0x14. pcim_iomap_regions() does **not** require a minimum size.

**Step 5.4: Reachability**
Record: PCI probe / azx_probe_work workqueue. Reachable from:
- automatic bind of class 0x0403 devices (including fuzzed/malformed PCI devices)
- privileged new_id / driver_override
Not a normal unprivileged syscall. Still a real kernel oops, including in VMs (syzbot’s environment).

**Step 5.5: Similar patterns**
Record: Other ALSA PCI drivers already reject tiny BARs (e.g. sound/pci/oxygen/oxygen_lib.c compares pci_resource_len(pci, 0) < OXYGEN_IO_SIZE). HDA Intel was missing that class of check. This commit does not touch hda_tegra.c.

## Phase 6: This tree (6.12.y)

**Step 6.1: Buggy code present?**
Record: **Yes.** Local tree is **6.12.111** (p-6.12-3-gc504cf0baa3d8). File is sound/pci/hda/hda_intel.c (pre-rename). azx_probe() at 2116 has the same dmic_detect block and goes straight to snd_card_new() with **no** BAR0 check. azx_first_init() at 1854 performs the same iomap + GCAP/capability MMIO. "Too small PCI BAR0" is absent.

**Step 6.2: Backport difficulty**
Record: **Clean apply after path remap** (sound/hda/controllers/intel.c → sound/pci/hda/hda_intel.c). Hunk context is identical. No data-structure or helper prerequisites.

**Step 6.3: Related fixes already here?**
Record: No. git log --grep on those paths found no BAR0 sanity check. 9895573b0185 is not an ancestor of HEAD.

## Phase 7: Subsystem context

**Step 7.1**
Record: ALSA HD-audio PCI controller (sound/pci/hda). **IMPORTANT** — default audio driver on essentially all x86 laptops/desktops (CONFIG_SND_HDA_INTEL).

**Step 7.2**
Record: Mature, actively maintained. Probe path itself is old and stable; recent churn is IDs/quirks, not azx_probe() structure.

## Phase 8: Impact and risk

**Step 8.1: Who is affected**
Record: Users of snd-hda-intel (very common), plus anyone who can bind a PCI function with a tiny BAR0 (VM/PCI fuzzing, new_id, malformed/class-matching devices).

**Step 8.2: Trigger**
Record: PCI bind of a device whose BAR0 is smaller than the offsets the driver reads. Common in syzkaller/QEMU; uncommon on real ICH/PCH hardware (those BARs are ~16KB). Typically needs a matching class/ID or CAP_SYS_ADMIN for new_id. Unprivileged userspace cannot trigger it directly (syzbot: Unprivileged: no). Peripheral/VM-host injection is in the syzbot assessment.

**Step 8.3: Failure mode**
Record: Kernel oops (BUG: unable to handle kernel paging request) in azx_probe_work. **Severity: CRITICAL** (host/guest crash). DoS; one report also marked exploitable. Not filesystem corruption.

**Step 8.4: Risk-benefit**
Record:
- **Benefit:** High — prevents a documented, reproducible oops in a widely enabled driver.
- **Risk:** Very low — 9 lines, fail-closed on impossible hardware, no locking/API change.
- **Ratio:** Strongly favors backport.

## Phase 9: Synthesis

**Step 9.1: Evidence**

FOR:
- Two syzbot reports, C repros, prio:high, paging oops
- Real crash in azx_first_init / snd_hdac_bus_parse_capabilities — both exist here
- 9-line, obviously correct check
- ALSA maintainer authored and applied it
- Same probe context in 6.12; only the filename differs
- Spec-sized HD-audio BARs are far larger than 0x200

AGAINST:
- Trigger is not the everyday laptop codec path (needs a tiny BAR / wild bind)
- 0x200 is a floor, not full MMIO coverage
- No mailing-list review besides the maintainer
- Lore/stable-list HTTP 403 (discussion recovered via b4)

UNRESOLVED:
- Could not WebFetch lore.kernel.org or git.kernel.org (403/bot wall); b4 mbox and syzbot pages were sufficient
- No independent stable-list discussion found

**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** — maintainer patch; syzbot lists it as the fix commit and patched on upstream CI.
2. Real bug affecting users? **PASS** — reproducible kernel oops.
3. Important (crash/security/corruption/deadlock)? **PASS** — oops / DoS (CRITICAL).
4. Small and contained? **PASS** — +9 lines, one function.
5. No new features/APIs? **PASS**
6. Can apply to this tree? **PASS** — path remap only; context matches.

**Step 9.3: Exception category**
Record: Not an ID/quirk/DT/docs exception. It is a normal crash- prevention bugfix.

**Step 9.4: Decision**
This tree has the vulnerable probe path. The patch is a small, correct guard that stops a syzbot-proven oops. It should be backported to this 6.12 tree.

---

### What the commit solves, and why it matters here

snd-hda-intel maps BAR0 and then reads HD-audio registers (GCAP at 0x00, LLCH at 0x14, later stream descriptors). If BAR0 is too small — syzkaller binds a wild PCI function, or a class-0x0403 device has a truncated BAR — those readws walk off the iomap and oops the kernel in azx_probe_work. On 6.12 that is still azx_probe() in sound/pci/hda/hda_intel.c with no size check. The patch rejects BAR0 < 512 bytes before snd_card_new(), which is enough to stop the reported crash and will not reject real controllers.

### Stable-rules / risk vs benefit

Meets the rules: real oops, tiny diff, no API, applies with a filename change. Benefit is preventing a kernel crash in a default x86 audio driver; risk is an early -EINVAL only for hardware that could not function.

### Concerns

Need to drop the patch onto sound/pci/hda/hda_intel.c instead of sound/hda/controllers/intel.c. No other prerequisites. The 0x200 floor is incomplete for later registers; that is documented and does not block the oops fix.

### Verification
- [Phase 1] Parsed tags: two syzbot Reported-by/Closes, maintainer SOB, no Fixes/Cc:stable
- [Phase 2] Diff: +9 lines in azx_probe(), pci_resource_len(pci, 0) < 0x200 → -EINVAL
- [Phase 3] git describe HEAD / make kernelversion: **6.12.111** (p-6.12-3-gc504cf0baa3d8)
- [Phase 3] git merge-base --is-ancestor 9895573b0185 HEAD → not ancestor (exit 1); object exists
- [Phase 3] Blame around insertion: snd_card_new path dates to 2008–2014; no existing BAR check
- [Phase 3] git log --oneline -20 -- sound/pci/hda/hda_intel.c:
IDs/quirks only; no related fix
- [Phase 4] b4 dig -c 9895573b0185: lore URL [email protected]
- [Phase 4] b4 dig -a: v1 only; b4 dig -w: linux-sound + maintainer
- [Phase 4] b4 mbox: single email, no NAK/review replies
- [Phase 4] syzbot: paging oops in snd_hdac_bus_parse_capabilities and azx_probe_work; C repro; prio:high; fix 9895573b0185
- [Phase 4] WebFetch lore/stable/git.kernel.org: 403 — UNVERIFIED via HTTP; b4/syzbot used instead
- [Phase 5] Callers: PCI .probe = azx_probe; Intel/NVIDIA/ATI/AMD HD- audio class catch-alls
- [Phase 5] This tree azx_first_init: pcim_iomap_regions then azx_readw(GCAP) / snd_hdac_bus_parse_capabilities (LLCH 0x14)
- [Phase 5] pcim_iomap_regions() maps BAR as-is; no minimum size
- [Phase 6] Local azx_probe() at sound/pci/hda/hda_intel.c:2116 lacks the check; grep found no "Too small PCI BAR0"
- [Phase 6] Surrounding lines 2149–2160 match the upstream hunk — clean path-remap apply
- [Phase 8] Failure: kernel oops on probe workqueue; severity CRITICAL; unprivileged trigger not shown

**YES**

 sound/hda/controllers/intel.c | 9 +++++++++
 1 file changed, 9 insertions(+)
sound/hda/controllers/intel.c +9 -0
index f07fc5dc5cede..3ed33cba7d83f 100644
@@ -2155,6 +2155,15 @@ static int azx_probe(struct pci_dev *pci,
 		dev_warn(&pci->dev, "dmic_detect option is deprecated, pass snd-intel-dspcfg.dsp_driver=1 option instead\n");
 	}
 
+	/* A sanity check against wild device binding;
+	 * here the range 0x200 is enough for the registers used at probe,
+	 * but it doesn't mean covering all HD-audio registers
+	 */
+	if (pci_resource_len(pci, 0) < 0x200) {
+		dev_err(&pci->dev, "Too small PCI BAR0\n");
+		return -EINVAL;
+	}
+
 	err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
 			   0, &card);
 	if (err < 0) {
Signature · 1 line
2.53.0
author maintainer
#361 lore raw

PATCH 1/1 drm/panel-edp: Support MB116AS01'3 edp panel

In reply to Sasha Levin

From: Haikun Zhou <[email protected]>

[ Upstream commit 844e71ba7d7a50c5ffa29d147afaeaafb19b39e4 ]

MB116AS01'3 raw edid:
00 ff ff ff ff ff ff 00 21 63 03 12 00 00 00 00
00 23 01 04 95 1a 0e 78 23 e7 05 9c 5b 56 93 27
21 50 54 00 00 00 01 01 01 01 01 01 01 01 01 01
01 01 01 01 01 01 36 1c 56 92 50 00 1c 30 60 18
a8 00 00 90 10 00 00 18 00 00 00 fd 00 28 3c 30
30 07 01 0a 20 20 20 20 20 20 00 00 00 fe 00 48
4b 43 20 4d 59 20 20 20 20 0a 20 20 00 00 00 fe
00 4d 42 31 31 36 41 53 30 31 27 33 20 20 01 cb

70 20 79 02 00 22 00 14 1c 1a 01 84 55 05 91 00
5f 00 17 00 ff 02 1b 00 09 00 07 00 2b 00 06 27
00 28 3b 00 00 81 00 13 72 1a 00 00 03 01 28 3c
00 00 00 00 00 00 3c 00 00 00 00 25 01 09 1c 1a
01 1c 1a 01 28 3c 80 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 e7 90

---

LLM Generated explanations, may be completely bogus:

Local tree is **6.18.y** (v6.18.53, VERSION=6 PATCHLEVEL=18). The MB116AS01'3 table entry is **not** in v6.18.53. The driver, HKC table, delay_200_500_e80, and unknown-panel WARN_ON path are present. This is a one-line panel ID / quirk for an existing driver.

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

Step 1.1: PARSE THE SUBJECT LINE
Record: [drm/panel-edp] [Support] [add MB116AS01'3 eDP panel table entry]
- Subsystem: drm/panel-edp
- Verb: "Support" — hardware enablement / ID addition, not a refactor

Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Haikun Zhou <[email protected] partner.google.com> (author; Huaqin/Google partner)
- Reviewed-by: Douglas Anderson <[email protected]> (panel-edp reviewer in MAINTAINERS)
- Signed-off-by: Douglas Anderson <[email protected]> (maintainer applied it)
- `Link: https://patch.msgid.link/20260701013018.2621972-1-
[email protected]`
- No Fixes:, Reported-by:, Tested-by:, Cc: stable (absence expected for this review)
- Ignored: Signed-off-by: Sasha Levin and [Upstream commit ...] (pipeline markers)

Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug description: the panel is missing from edp_panels[]. The body is the raw EDID (base block + extension), not a crash log.
- Symptom: unmatched generic edp-panel uses conservative delays and hits WARN_ON(!detected_panel) at probe.
- Version info: none in the message. Author date is 2026-07-01; v6.18 is 2025-11-30, so this landed after this series branched.
- Root cause: HKC ID 0x1203 was not in the delay/quirk table.

Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. It is an explicit panel ID / power- sequencing quirk. That is the same class as PCI/USB ID additions.

===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================

Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/gpu/drm/panel/panel-edp.c (+1 / -0)
- Function/table: edp_panels[]
- Scope: single-file, one-line surgical addition

Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: HKC 0x1203 is not in edp_panels[]. find_edp_panel() returns NULL.
- After: match EDP_PANEL_ENTRY('H', 'K', 'C', 0x1203, &delay_200_500_e80, "MB116AS01'3").
- Path: panel_edp_probe() → compatible "edp-panel" → generic_edp_panel_probe() → EDID panel ID lookup.
- After match: desc->delay = *detected_panel->delay (hpd_absent=200, unprepare=500, enable=80).
- Unmatched: WARN_ON plus panel_edp_set_conservative_timings() (unprepare=2000, enable=200).

Step 2.3: IDENTIFY THE BUG MECHANISM
Record: **Hardware workaround / device ID** (category h).
- Mechanism: EDID mfg HKC (bytes 21 63) and product 0x1203 (bytes 03 12) were not mapped to delays. The panel name in EDID descriptor 0xFE is MB116AS01'3 (0x27 = ').
- Fix: add the existing delay_200_500_e80 preset (already used by many 11.6" BOE/CMN entries).

Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: one table row, sorted under existing HKC entries (0x1203 before 0x2d51).
- Minimal; no unrelated edits.
- Regression risk: very low. Lookup is ID-specific; other panels unchanged.
- delay_200_500_e80 already exists in this tree (verified at panel- edp.c:1760 on v6.18.53).

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

Step 3.1: BLAME THE CHANGED LINES
Record:
- Table introduced with panel-edp split: 5f04e7ce392db ("Split eDP panels out of panel-simple").
- HKC rows already in v6.18 / v6.18.53 (0x2d51, 0x2d5b MB116AN01, 0x2d5c MB116AN01-2).
- delay_200_500_e80 from 4d53cf8147950 ("Add several generic edp panels"), present in this tree.
- This ID is new; the table and delay helper are old.

Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. N/A. The gap is a missing table row, not a later regression.

Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- v6.18..v6.18.53 already contains many similar one-line panel adds (AUO, BOE, CSW, LG, Sharp, mt8189 Chromebook panels).
- Standalone; not patch X/Y.

Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record:
- Haikun Zhou has other panel-edp ID/delay commits (CSW MNB601LS1-4, CMN N116BCJ-EAK).
- Reviewer Douglas Anderson is R: for "DRM DRIVER FOR GENERIC EDP PANELS" in MAINTAINERS.

Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: None. Needs only EDP_PANEL_ENTRY, HKC table, and delay_200_500_e80, all in v6.18.53. Dry-run against the v6.18.53
blob: hunk applied (offset -5). Standalone apply: yes.

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 9e55b14301666: V2 at https://patch.msgid.link/202607010130
[email protected]
- b4 dig -a:
- v1 2026-06-29: MB116AS01-3 (hyphen), msgid

    `20260629012200.248066-1-...`

- v2 2026-07-01: MB116AS01'3 (apostrophe, matches EDID)
- Applied version is v2.
- Doug Anderson: Reviewed-by and pushed to drm-misc-next as 844e71ba7d7a.
- No NAK found.
- UNVERIFIED: exact v1 review text (lore 403, MARC 404). Name change v1→v2 is verified from the two patches.

Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w):
- To/Cc: [email protected], [email protected], [email protected], [email protected], linux- [email protected], [email protected], [email protected]
- Subsystem reviewer included and signed off.

Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla. Evidence is the EDID dump in the patch. Author is a hardware partner, typical for ChromeOS panel IDs.

Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone 1/1. drm-misc pull for 7.3-rc1 lists it under **panel-edp: quirks** with MB116AS01 (https://lists.openwall.net/linux-
kernel/2026/08/20/246).

Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable search returned 403. UNVERIFIED: no stable-list thread found. Official v6.18.53 already took the same class of panel-edp ID patches, so there is no local policy against this type.

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: No function body change. Data: edp_panels[]. Consumers:
find_edp_panel(), generic_edp_panel_probe().

Step 5.2: TRACE CALLERS
Record:
- find_edp_panel() ← generic_edp_panel_probe()
- generic_edp_panel_probe() ← panel_edp_probe() when OF compatible is "edp-panel"
- panel_edp_probe() ← panel_edp_platform_probe() / panel_edp_dp_aux_ep_probe()
- Context: device probe / display bring-up, not IRQ-hot.

Step 5.3: TRACE CALLEES
Record: Table is data only. Probe reads EDID, matches ID, copies panel_delay. Delays used in panel_edp_prepare_once() (hpd_absent) and panel_edp_enable() (enable).

Step 5.4: FOLLOW THE CALL CHAIN
Record: Userspace does not call this directly. Plug in the panel (Chromebook/laptop DT edp-panel on DP AUX) and it runs at probe/resume. Reachable on machines with this HKC panel.

Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same file is a long ID table. HKC already has three entries. Many sibling "Add … panel" commits are already in official 6.18.y.

===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================

Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. v6.18.53 has edp_panels[], HKC rows, find_edp_panel(), and:

```
if (WARN_ON(!panel->detected_panel)) {
    ... "Unknown panel ... using conservative timings"
```

MB116AS01 / 0x1203 is **not** in v6.18 or v6.18.53. Bug = missing quirk for hardware that this driver already enumerates.

Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Clean apply to v6.18.53 (dry-run succeeded, offset -5). Surrounding HKC context matches. Difficulty: clean apply.

Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No other MB116AS01'3 / HKC 0x1203 fix in this series. Nearby HKC MB116AN01 entries do not cover 0x1203.

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: drivers/gpu/drm/panel/ — DRM panel. Criticality: **IMPORTANT** for devices with this panel (blank/slow display, boot WARN_ON); **PERIPHERAL** for everyone else (ID match is a no-op).

Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mature table, still getting ID/quirk adds. Official 6.18.y already backports them. Not a new subsystem.

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver-specific / hardware-specific: machines whose eDP EDID is HKC 0x1203 (MB116AS01'3), typically ChromeOS/partner laptops. No effect on other panels.

Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Every probe of "edp-panel" with that EDID (boot and often resume). Not a race. Unprivileged users do not trigger it except by using the device.

Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- Without the entry: WARN_ON stack on probe (noisy, can trip panic-on- warn) **plus** conservative delays (2s unprepare vs 500ms; 200ms enable vs 80ms). Conservative path is designed so the panel still usually works.
- Failure mode: boot warning + slower power sequencing, not a universal oops.
- Severity: **MEDIUM** for affected hardware (warning + wrong timings); **LOW** globally.
- Still qualifies under the device-ID / quirk exception.

Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: high for that panel (correct T3/T12-style delays, no WARN_ON); zero for others.
- Risk: very low (1 line, existing delay struct, ID-gated).
- Ratio: strongly favors backport.

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

Step 9.1: COMPILE THE EVIDENCE
FOR:
- One-line ID/quirk in an existing driver (panel-edp.c / edp_panels[]).
- Matches stable exceptions: **device ID** and **hardware quirk** (drm- misc pull even labeled it "panel-edp: quirks").
- Avoids WARN_ON and 2s conservative unprepare on this panel.
- delay_200_500_e80, HKC table, and lookup path exist in this 6.18 tree.
- Reviewed and applied by the panel-edp maintainer.
- Official 6.18.y already contains many identical panel-edp ID backports.
- Applies cleanly to v6.18.53.

AGAINST:
- Not a UAF/crash/corruption fix for all users; unmatched panels usually still work with conservative delays.
- No Reported-by from end users; vendor EDID add.

UNRESOLVED:
- Exact v1 review comments (lore/MARC fetch failed).
- Whether this was discussed on stable@ (lore/stable 403).

Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — one sorted table row; maintainer Reviewed-by and merged.
2. Fixes a real bug that affects users? **PASS** — missing quirk:
WARN_ON + wrong power delays on this panel.
3. Important issue? **PASS** under the device-ID/quirk exception (boot warning + incorrect sequencing on real hardware). Not a core panic.
4. Small and contained? **PASS** — +1 line, one file.
5. No new features or APIs? **PASS** — no new driver, syscall, or userspace API; only a table ID.
6. Can apply to the local tree? **PASS** — dry-run against v6.18.53 succeeded.

Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: **Device ID addition to existing driver** and **hardware quirk/workaround**. Automatic YES class.

Step 9.4: MAKE YOUR DECISION
This tree is 6.18.y. The driver already identifies unknown eDP panels and warns. Adding HKC 0x1203 is the same kind of ID/quirk 6.18.y already takes. Benefit is real for that hardware; risk is negligible.

What it solves for stable users: Chromebook/laptop panels with EDID HKC 0x1203 get the intended 200/500/80 ms sequencing and stop hitting the unknown-panel WARN_ON.

Risk vs benefit: one ID-gated line vs boot warning and multi-second conservative delays. Favor backport.

Verification:
- [Phase 1] Tags: Haikun Zhou SOB, Douglas Anderson Reviewed-by + SOB, lore msgid link; no Fixes/Reported-by/Cc:stable
- [Phase 1] Body is raw EDID; decoded mfg HKC (0x2163) product 0x1203; name MB116AS01'3
- [Phase 2] Diff: +1 EDP_PANEL_ENTRY in edp_panels[]; delay &delay_200_500_e80
- [Phase 2] Unmatched path: WARN_ON + unprepare=2000/enable=200 in generic_edp_panel_probe() (verified in this tree and v6.18.53)
- [Phase 3] git describe HEAD → v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion → 6.18.53
- [Phase 3] git merge-base --is-ancestor 9e55b14301666 v6.18.53 → NO (not in official 6.18.53)
- [Phase 3] git grep MB116AS01 v6.18.53 -- panel-edp.c → not present; HKC 0x2d51/0x2d5b/0x2d5c present
- [Phase 3] delay_200_500_e80 present at line 1760 on v6.18.53
- [Phase 3] v6.18..v6.18.53 already has multiple drm/panel-edp: Add … panel commits
- [Phase 4] b4 dig -c: V2 lore URL; b4 dig -a: v1 hyphen name, v2 apostrophe; b4 dig -w: dianders, dri-devel, drm maintainers
- [Phase 4] LKML: Doug Reviewed-by, pushed 844e71ba7d7a to drm-misc- next
- [Phase 4] drm 7.3-rc1 pull lists MB116AS01 under panel-edp quirks
- [Phase 4] UNVERIFIED: v1 review text; stable@ discussion (HTTP 403/404)
- [Phase 5] Call chain: panel_edp_probe → generic_edp_panel_probe → find_edp_panel; delays used in prepare/enable
- [Phase 6] Dry-run patch --dry-run of this commit onto v6.18.53 panel-edp.c: succeeded (offset -5)
- [Phase 7] MAINTAINERS: Douglas Anderson is R: for panel-edp.c
- [Phase 8] Severity: WARN_ON + wrong delays on this panel; ID-gated so other hardware unaffected

**YES**

 drivers/gpu/drm/panel/panel-edp.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/panel/panel-edp.c +1 -0
index f2ae333a32d8c..0da04d75e4e96 100644
@@ -2061,6 +2061,7 @@ static const struct edp_panel_entry edp_panels[] = {
 
 	EDP_PANEL_ENTRY('E', 'T', 'C', 0x0000, &delay_50_500_e200_d200_po2e335, "LP079QX1-SP0V"),
 
+	EDP_PANEL_ENTRY('H', 'K', 'C', 0x1203, &delay_200_500_e80, "MB116AS01'3"),
 	EDP_PANEL_ENTRY('H', 'K', 'C', 0x2d51, &delay_200_500_e200, "Unknown"),
 	EDP_PANEL_ENTRY('H', 'K', 'C', 0x2d5b, &delay_200_500_e200, "MB116AN01"),
 	EDP_PANEL_ENTRY('H', 'K', 'C', 0x2d5c, &delay_200_500_e200, "MB116AN01-2"),
Signature · 1 line
2.53.0
author maintainer
#362 lore raw

PATCH 1/1 iommu/vt-d: Fix CACHE_TAG_NESTING_DEVTLB polluting shared variables in flush loop

In reply to Sasha Levin

From: Guanghui Feng <[email protected]>

[ Upstream commit 3846e469c1ba1407260066070bff5c88ee39a4c7 ]

In cache_tag_flush_range(), the CACHE_TAG_NESTING_DEVTLB case modifies the shared local variables 'addr' and 'mask' before falling through to CACHE_TAG_DEVTLB. This causes all subsequent CACHE_TAG_DEVTLB entries in the same loop iteration to incorrectly use the full-range flush parameters (addr=0, mask=MAX_AGAW_PFN_WIDTH) instead of the precisely calculated PSI range. This is not the intended behavior, as regular DEVTLB entries should always perform targeted range-based invalidation.

Fix this by having CACHE_TAG_NESTING_DEVTLB directly call cache_tag_flush_devtlb_psi() with the full-range constants and break, instead of modifying shared variables and falling through. This ensures CACHE_TAG_DEVTLB always uses the original calculated addr and mask for precise range flush.

This change slightly affects trace_cache_tag_flush_range() behavior. Previously, after addr/mask were overwritten, the tracepoint could record a full-range flush even when the caller requested a narrower range.

The tracepoint should reflect caller intent. Although this helper may widen the actual hardware invalidation range for implementation reasons, that does not change what the caller requested, so logging the requested range is the correct behavior.

If the actual invalidation range sent to hardware is needed, it is already visible via the qi_submit trace event, which records the invalidation descriptors emitted by the driver.

---

LLM Generated explanations, may be completely bogus:

The remaining thread parse confirms two vendors independently hit the same flush-loop bug. I’ll wrap the nine-phase analysis against this 6.12 tree only.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**

Record: **[iommu/vt-d] [Fix] [CACHE_TAG_NESTING_DEVTLB mutates shared addr/mask in cache_tag_flush_range(), so later tags in the same loop use a full-range flush instead of the calculated PSI range]**

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**

Record:
- **Signed-off-by:** Guanghui Feng (author, Alibaba), Guixin Liu (Alibaba), Lu Baolu (Intel VT-d maintainer), Joerg Roedel (IOMMU maintainer)
- **No Fixes:** tag (expected for this review pipeline)
- **No Cc: stable** (expected)
- **No Reported-by / Tested-by / Reviewed-by / Acked-by / Link** on the committed message
- Independent earlier submission of the same bug exists (Baidu; see Phase 4)

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**

Record:
- **Bug:** In cache_tag_flush_range(), CACHE_TAG_NESTING_DEVTLB writes addr = 0 and mask = MAX_AGAW_PFN_WIDTH then fallthroughs into CACHE_TAG_DEVTLB. Those locals are computed once before the loop, so every later tag sees the full-range values.
- **Symptom:** Regular DevTLB (and, in this tree, later IOTLB) invalidations become global/full-range instead of the caller’s PSI range. Tracepoint can also log a full-range flush when the caller asked for a narrower range.
- **Version info:** None in the message. Introduced with cache-tag helpers (v6.11); present in this 6.12 tree.
- **Root cause:** Shared loop variables overwritten for one tag type, then reused for all later tags.

**Step 1.4: DETECT HIDDEN BUG FIXES**

Record: **Not hidden.** Subject and body are an explicit logic-bug fix. The extra tracepoint paragraph is a side effect of stopping the overwrite, not the reason for the change.

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES**

Record:
- **File:** drivers/iommu/intel/cache.c only
- **Net:** 2 insertions, 3 deletions (5-line change)
- **Function:** cache_tag_flush_range()
- **Scope:** single-file surgical fix

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**

Record:
- **Before:** CACHE_TAG_NESTING_DEVTLB mutates addr/mask, falls through, flushes that tag as a full DevTLB, and leaves the mutated values for later iterations.
- **After:** That case calls cache_tag_flush_devtlb_psi(domain, tag, 0, MAX_AGAW_PFN_WIDTH) and breaks. Later CACHE_TAG_DEVTLB/CACHE_TAG_IOTLB tags keep the original PSI addr/mask.
- **Path:** mapping-change invalidation (intel_iommu_tlb_sync, superpage switch, SVM range invalidate), not probe/error-only.

Verified in this checkout (cache.c 437–478): the buggy addr = 0; mask = MAX_AGAW_PFN_WIDTH; fallthrough; is present.

**Step 2.3: IDENTIFY THE BUG MECHANISM**

Record: **[Logic / correctness]** Shared loop state is clobbered. Nested DevTLB still needs a full device-cache flush (comment is unchanged). The fallthrough was a convenient way to reuse the DevTLB helper and accidentally changed flush parameters for every later tag.

Consequence in this tree:
- Later CACHE_TAG_DEVTLB: full-range Dev-IOTLB instead of PSI (over- invalidation).
- Later CACHE_TAG_IOTLB / CACHE_TAG_NESTING_IOTLB:
cache_tag_flush_iotlb(..., addr, pages, mask, ih) with addr=0, mask=MAX_AGAW_PFN_WIDTH (52) and original pages. On the nest- parent S2 domain (use_first_level is false; see Phase 5/6) that typically becomes domain-selective IOTLB (mask > cap_max_amask_val) — still covering, but far broader than PSI.

**Step 2.4: ASSESS THE FIX QUALITY**

Record: **Obviously correct.** Same full-range DevTLB flush for nesting, without mutating shared locals. No new locking, APIs, or data structures. Regression risk is low: nested DevTLB still gets a full flush; other tags get the range the caller computed. Tracepoint then logs the requested range, which is the stated intent.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**

Record:
- Buggy addr/mask/fallthrough introduced in **c4d27ffaa8eb0** (“iommu/vt-d: Add cache tag invalidation helpers”, Lu Baolu, 2024-04-24).
- **git describe --contains c4d27ffaa8eb0:** x86_boot_for_v6.11_rc1~... → first appeared in **v6.11**.
- **git merge-base --is-ancestor c4d27ffaa8eb0 HEAD:** yes. Present for the whole 6.12 lifetime.

**Step 3.2: FOLLOW THE FIXES: TAG**

Record: **No Fixes: tag.** Equivalent “buggy commit” is c4d27ffaa8eb0, which is in this tree.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**

Record (recent drivers/iommu/intel/cache.c):
- ffd774c34774f qi_batch NULL with nested parent
- 705c1cdf1e73c batched cache invalidation
- 3297d047cd7f5 refactor IOTLB/Dev-IOTLB flush (this is why 6.12’s cache_tag_flush_iotlb still takes pages)
- c4d27ffaa8eb0 original helpers (bug intro)

Standalone fix, not patch 2/3 of a functional series. It was later folded as 03/19 in “Intel IOMMU updates for v7.3”, but it does not depend on the other patches in that pull.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**

Record: Guanghui Feng has 31fd1e0281621 (“Fix intel iommu iotlb sync hardlockup and retry”) in this Intel IOMMU tree. Guixin Liu has no other hits here. Lu Baolu is the VT-d maintainer and signed off. Two vendors independently posted the same bug (Alibaba and Baidu).

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**

Record: **No functional prerequisites.** cache_tag_flush_devtlb_psi(domain, tag, addr, mask) exists here with that signature. Surrounding context differs (pages still passed to IOTLB flush and the tracepoint; cache_tag_flush_all is still its own loop, not a wrapper). The 3-line change backports with a context tweak, not extra commits.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**

Record:
- Original: Message-ID [email protected] (2026-06-23), 3-message thread via b4 mbox.
- Lu Baolu (2026-06-27): same issue already posted by Baidu:
https://lore.kernel.org/linux- iommu/[email protected]/
- Lu Baolu (2026-07-27): **“Queued for v7.3-rc1.”**
- No NAKs. No reviewer concern about correctness.
- v2 of the Intel pull added the tracepoint clarification; the code change is unchanged from v1.

**Step 4.2: CHECK WHO REVIEWED THE PATCH**

Record: Recipients were the IOMMU maintainers (Woodhouse, Lu, Roedel, Deacon, Murphy) and [email protected]. Lu Baolu signed off and queued it; Joerg applied it. No separate Reviewed-by on the committed text. Kevin Tian was CCed on the pull, not recorded as a reviewer of this hunk.

**Step 4.3: SEARCH FOR THE BUG REPORT**

Record: No syzbot/bugzilla. **Two independent vendor patches:**
1. Li RongQing (Baidu), 2026-06-05: “Prevent variable pollution in cache_tag_flush_range()” — per-iteration flush_addr/flush_mask copies, including the IOTLB path.
2. Guanghui Feng (Alibaba), 2026-06-23 — the version that landed (direct full-range call + break).

Baidu pinged after 12 days; Lu queued it. That is “bothers people,” not a theoretical review nit.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**

Record: Landed as **03/19** of Lu Baolu’s “Intel IOMMU updates for v7.3”. Other patches in that series are unrelated (UCTP, tboot, context teardown, etc.). This hunk is self-contained. Several *other* fixes from that pull are already in this pending-6.12 tree; this one is not.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**

Record: lore.kernel.org/stable fetch returned 403. **UNVERIFIED** whether stable@ already discussed this specific subject. No evidence it was rejected for stable.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: KEY FUNCTIONS**

Record: cache_tag_flush_range(); helper cache_tag_flush_devtlb_psi() (unchanged).

**Step 5.2: TRACE CALLERS**

Record (this tree):
- intel_iommu_tlb_sync() in iommu.c — unmap/Iotlb gather; **common VFIO/iommufd map change path**
- switch_to_super_page() in iommu.c
- intel_nested_cache_invalidate_user() in nested.c — flushes the **nested S1 domain** (IOTLB/DEVTLB only; NESTING tags live on S2)
- intel_arch_invalidate_secondary_tlbs() in svm.c — SVA

The pollution matters when the domain being flushed **has CACHE_TAG_NESTING_DEVTLB on its list**, i.e. the **S2 nest-parent**, on S2 map changes (intel_iommu_tlb_sync on that domain).

**Step 5.3: TRACE CALLEES**

Record: calculate_psi_aligned_address → lock → per-tag cache_tag_flush_iotlb / cache_tag_flush_devtlb_psi → qi_batch_add_* / qi_submit_sync.

**Step 5.4: FOLLOW THE CALL CHAIN**

Record: Nested attach (cache_tag_assign_domain) puts NESTING_* tags on domain->s2_domain. Nest parent is allocated with paging_domain_alloc(dev, false) so **use_first_level is false**. Userspace (iommufd/VFIO nested vIOMMU) changing S2 mappings triggers intel_iommu_tlb_sync → cache_tag_flush_range on S2. **Reachable from VM/device assignment, not a debug-only path.**

Tag order (list_add_tail): per nested ATS device, NESTING_IOTLB then NESTING_DEVTLB. With **two or more** nested ATS devices, after the first NESTING_DEVTLB, later IOTLB/DEVTLB tags see polluted addr/mask. Mixed host-on-S2 + nested-on-S2 with nested attached first is the CACHE_TAG_DEVTLB case the commit describes.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**

Record: cache_tag_flush_all() in this tree already handles CACHE_TAG_DEVTLB and CACHE_TAG_NESTING_DEVTLB together via cache_tag_flush_devtlb_all() **without** mutating shared range locals. cache_tag_flush_range_np() does not touch DevTLB. The range path is the inconsistent one.

---

## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**

Record:
- **Tree:** pending-6.12, git describe HEAD = p-6.12-3-gc504cf0baa3d8, make kernelversion = **6.12.111**
- Buggy code: drivers/iommu/intel/cache.c lines 458–468
- Introduced v6.11 (c4d27ffaa8eb0), **before** 6.12 branched
- git log --grep='polluting shared' on this path: **empty** — fix **not** already applied

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**

Record: **Minor context rework, not a redesign.** This tree still has:
- cache_tag_flush_iotlb(domain, tag, addr, pages, mask, ih)
- trace_cache_tag_flush_range(tag, start, end, addr, pages, mask)
- a full cache_tag_flush_all() loop

Mainline hunk context dropped pages and collapsed cache_tag_flush_all into a wrapper. The three changed lines (addr/mask/fallthrough → direct call + break) match this file as-is.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**

Record: No equivalent fix. fallthrough at line 468 is still the only one in this file.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: SUBSYSTEM AND CRITICALITY**

Record: **Intel VT-d IOMMU cache invalidation.** Criticality:
**IMPORTANT** (DMA isolation / nested virtualization). Not core mm/VFS, but wrong Dev-IOTLB/IOTLB parameters affect VFIO/iommufd nested guests with ATS devices.

**Step 7.2: SUBSYSTEM ACTIVITY**

Record: Actively maintained; this pending-6.12 branch already carries other VT-d fixes from the same v7.3 era pull. Cache-tag code has been stable in structure since 6.11 aside from batching.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: WHO IS AFFECTED**

Record: **Config/driver-specific:** CONFIG_INTEL_IOMMU + nested translation (IOMMU_HWPT_ALLOC_NEST_PARENT / iommufd nested) + ATS devices so CACHE_TAG_*DEVTLB tags exist. Typical cloud VFIO/vIOMMU. Not every 6.12 box.

**Step 8.2: TRIGGER CONDITIONS**

Record: S2 mapping changes while nested ATS devices are attached and more than one relevant cache tag follows a NESTING_DEVTLB on the list (multiple nested ATS devices, or nested-then-host on the same S2). Privileged/VMM path (iommufd), not an unprivileged syscall smash. Easy to hit in production nested setups; two cloud vendors filed it independently.

**Step 8.3: FAILURE MODE SEVERITY**

Record: **Wrong IOMMU invalidation parameters → overly broad IOTLB/Dev- IOTLB flushes** (global Device-TLB / domain-selective IOTLB instead of PSI).

Verified **not** stale-translation under-invalidation on this tree’s nest parent: S2 is paging_domain_alloc(dev, false), so the first-level piotlb(addr=0, original pages) mis-flush does not apply.

Severity: **MEDIUM–HIGH** for nested ATS (I/O stalls, ATS storms, lost PSI benefit on a hot unmap path). Not oops/corruption in the verified 6.12 S2 path. Matches stable-rules **“oh, that's not good”** and, given Baidu+Alibaba, a **notable performance/correctness issue that bothers production users**.

**Step 8.4: RISK-BENEFIT RATIO**

Record:
- **Benefit:** Restore intended PSI DevTLB/IOTLB invalidation on nested S2 flushes; avoid global ATS invalidation for later devices; tiny, local change.
- **Risk:** Very low (3 lines, same helper, nesting still full-flushes).
- **Ratio:** Favorable for 6.12-stable.

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

**FOR:**
- Real logic bug in VT-d nested cache invalidation, present since v6.11, in this 6.12.111 tree
- Two independent vendor reports (Baidu 2026-06-05, Alibaba 2026-06-23); maintainer queued it
- 5-line, obviously correct; no new API
- User-visible extra global Device-TLB/IOTLB invalidations on nested S2 map updates
- cache_tag_flush_all() already avoided this pattern; range path did not
- No functional dependencies missing here

**AGAINST:**
- Not a crash, UAF, or proven stale-TLB corruption on this tree’s S2 path (error is conservative over-flush)
- Nested+ATS is not universal
- Hunk needs a small context backport (pages / cache_tag_flush_all shape)
- No Fixes/Cc: stable on the commit (not a negative per the pipeline rules)

**UNRESOLVED:**
- lore.kernel.org HTTP 403; stable@ history not fetched (thread recovered via b4 mbox)
- Exact mainline SHA not in this checkout (no git log --all)

**Step 9.2: STABLE RULES CHECKLIST**

1. Obviously correct and tested? **PASS** — maintainer queued; two vendors; trivial control-flow fix
2. Fixes a real bug that affects users? **PASS** — Baidu and Alibaba both submitted it
3. Important issue? **PASS** (with the documented “oh, that's not good” / notable nested-ATS invalidation impact) — not oops/corruption here, but wrong IOMMU flush parameters on a production nested path
4. Small and contained? **PASS** — 5 lines, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — buggy lines exist; needs minor context adjustment, not missing helpers

**Step 9.3: EXCEPTION CATEGORIES**

Record: None (not a device ID/quirk/DT/build/doc exception). Qualifies as a normal small bugfix.

**Step 9.4: DECISION**

This 6.12 tree has the bug. The fix is a three-line control-flow correction in Intel VT-d nested invalidation. It does not need later refactors. Over-flush is still a real, production-visible IOMMU bug (independent Alibaba and Baidu reports), and the patch is the lowest- risk way to restore the intended PSI range. It should be backported here.

---

## What the commit solves (for 6.12)

cache_tag_flush_range() computes one PSI addr/mask, then walks every cache tag. Nested DevTLB must flush the whole device cache, so the original code stuffed addr=0 / mask=MAX_AGAW_PFN_WIDTH into those shared locals and fell through. Later tags on that S2 domain (other nested ATS devices, or regular DevTLB) then issued a full-range invalidation instead of the range the caller asked for. On 6.12 that is extra-wide IOTLB/Dev-IOTLB traffic, not a verified stale-mapping hole, but it is incorrect invalidation on the nested map-update path.

## Risk vs benefit

Benefit is restoring targeted invalidation for a path cloud VFIO/iommufd actually uses. Risk is a 3-line change that keeps the nested full flush and only stops clobbering later tags.

## Concerns

Backport cannot be a blind git am of the mainline hunk: this tree still passes pages into cache_tag_flush_iotlb and the tracepoint, and cache_tag_flush_all() is still a separate loop. Edit only the CACHE_TAG_NESTING_DEVTLB arm.

---

Verification:
- [Phase 1] Parsed tags: SOBs Feng/Liu/Lu/Roedel; no Fixes/Reported- by/Cc:stable
- [Phase 2] Diff: 2+/3- in cache_tag_flush_range(); replace mutate+fallthrough with direct cache_tag_flush_devtlb_psi(..., 0, MAX_AGAW_PFN_WIDTH) + break
- [Phase 2] Read cache.c 437–510 in this tree: buggy fallthrough still at 466–468
- [Phase 3] git blame: intro c4d27ffaa8eb0 (v6.11); git merge-base --is-ancestor yes
- [Phase 3] git log --grep='polluting shared' on path: not present
- [Phase 3] cache_tag_flush_iotlb still has pages (3297d047cd7f5); no missing helper
- [Phase 4] b4 mbox original thread: Lu notes Baidu duplicate; queued for v7.3-rc1; no NAK
- [Phase 4] Baidu thread [email protected]:
same bug, IOTLB path included
- [Phase 4] UNVERIFIED: lore.kernel.org/stable HTTP 403
- [Phase 5] Callers: intel_iommu_tlb_sync, switch_to_super_page, nested user invalidate, SVM
- [Phase 5] Nest parent: paging_domain_alloc(dev, false) at iommu.c:3606 → use_first_level false
- [Phase 5] NESTING tags assigned to domain->s2_domain in cache_tag_assign_domain()
- [Phase 6] git describe HEAD p-6.12-3-gc504cf0baa3d8; make kernelversion 6.12.111
- [Phase 8] Failure mode: over-wide DevTLB/IOTLB invalidation; not verified as under-invalidate on this S2 path
- UNVERIFIED: mainline SHA (commit not in this checkout; --all not used)

**YES**

 drivers/iommu/intel/cache.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iommu/intel/cache.c +2 -3
index 385ae5cfb30d4..e6bc730fac3b0 100644
@@ -468,9 +468,8 @@ void cache_tag_flush_range(struct dmar_domain *domain, unsigned long start,
 			 * affected by a change in S2. So just flush the entire
 			 * device cache.
 			 */
-			addr = 0;
-			mask = MAX_AGAW_PFN_WIDTH;
-			fallthrough;
+			cache_tag_flush_devtlb_psi(domain, tag, 0, MAX_AGAW_PFN_WIDTH);
+			break;
 		case CACHE_TAG_DEVTLB:
 			cache_tag_flush_devtlb_psi(domain, tag, addr, mask);
 			break;
Signature · 1 line
2.53.0
author maintainer
#363 lore raw

PATCH 1/1 clk: zynq: handle kasprintf() failure in periph_clk registration

In reply to Sasha Levin

From: William Theesfeld <[email protected]>

[ Upstream commit d4d0d335e8d37c6c7e1c5664c7664288eca5a09b ]

zynq_clk_register_periph_clk() ignores the return value of the two kasprintf() calls used to build the mux and divider clock names, and passes the resulting (possibly NULL) pointers straight into clk_register_mux(), clk_register_divider() and clk_register_gate() as the clock '"'name'"' argument. On allocation failure that name later gets dereferenced by the clock framework (e.g. in debugfs name formatting), causing a NULL-pointer dereference.

Check both kasprintf() returns. On failure unwind any allocated name buffer and the spinlock, then fall through to the existing err label which sets clks[] to ERR_PTR(-ENOMEM). Freeing the spinlock on the error path is correct here because no clk_register_*() call has had a chance to take ownership of it; the success path intentionally hands it off to the registered clocks.

The neighbouring zynq_clk_register_fclk() in the same file already uses this per-allocation goto-label cleanup pattern; this change brings periph_clk into line with it.

---

LLM Generated explanations, may be completely bogus:

The local tree is **6.18.53**. The buggy zynq_clk_register_periph_clk() path is present here, and the patch is an 8-line error-path fix. Full nine-phase analysis follows.

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

**Step 1.1: PARSE THE SUBJECT LINE**
- Subsystem: clk: zynq
- Action verb: **handle** (bug-fix verb: missing failure handling)
- Intent: check kasprintf() in peripheral clock registration so a NULL name is not passed into the clock framework
- Record: [clk/zynq] [handle] [check kasprintf failure when registering periph clocks]

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Reviewed-by: Brian Masney <[email protected]> — clk co-maintainer; also final Signed-off-by into clk tree
- Reviewed-by: Michal Simek <[email protected]> — ARM/Zynq architecture maintainer
- Signed-off-by: William Theesfeld <[email protected]> — author
- Signed-off-by: Brian Masney <[email protected]> — maintainer merge
- No Fixes: tag (expected for this review pipeline)
- No Reported-by:, Tested-by:, Link:, or Cc: stable
- Pipeline-added markers ignored per instructions: [Upstream commit d4d0d335…], Signed-off-by: Sasha Levin
- Record: maintainer-reviewed, no syzbot/user report, no Fixes tag

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Bug: zynq_clk_register_periph_clk() ignores two kasprintf() results used as mux/divider names and passes them into clk_register_mux/divider/gate
- Claimed symptom: NULL name later dereferenced in CCF (commit cites debugfs name formatting) → NULL-pointer dereference
- Fix: check both returns; on failure free the other name buffer and the spinlock, then the existing err label sets clks[] = ERR_PTR(-ENOMEM)
- Author notes the sibling zynq_clk_register_fclk() already uses this goto-cleanup pattern
- Record: [Bug: unchecked kasprintf] [Symptom: NPD / broken clock init] [No version info] [Root cause: missing NULL checks before clk_register_*]

**Step 1.4: DETECT HIDDEN BUG FIXES**
- Not disguised. Explicit error-path fix. Also closes a spinlock leak on the failure path (lock is allocated before kasprintf; success hands it to registered clocks, so failure must kfree(lock)).
- Record: [Not hidden; allocation-failure / leak / NPD-class error-path fix]

===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================

**Step 2.1: INVENTORY THE CHANGES**
- File: drivers/clk/zynq/clkc.c — **+8 / -0**
- Function: zynq_clk_register_periph_clk()
- Scope: single-file surgical error-path fix
- Record: [clkc.c +8] [zynq_clk_register_periph_clk] [surgical]

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Verified against parent e3b8b15ec6f0a^:

Before:

```
mux_name = kasprintf(...);   /* unchecked */
div_name = kasprintf(...);   /* unchecked */
clk_register_mux(..., mux_name, ...);
clk_register_divider(..., div_name, mux_name, ...);
clks[clk0] = clk_register_gate(..., clk_name0, div_name, ...);
```

err was only used for kmalloc(lock) failure.

After: NULL mux_name → err_mux_name (kfree(lock)); NULL div_name → err_div_name (kfree(mux_name) then lock). Then err sets clks[clk0/clk1] = ERR_PTR(-ENOMEM). Success path unchanged.
- Record: [error path only: skip clk_register_* on kasprintf failure and unwind]

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Category: **error path / resource leak** plus **memory safety** (NULL name into CCF).

Verified CCF behavior in this tree (drivers/clk/clk.c):
- kstrdup_const(NULL) → kstrdup(NULL) returns NULL (mm/util.c:84)
- __clk_register then fails with -ENOMEM if core->name is NULL (clk.c:4435-4438)
- NULL **parent** name hits WARN(!parent_names[i], ...) then clk_cpy_name(..., true) returns -EINVAL (clk.c:4347-4351, 4307-4309)
- zynq_clk_setup() then does if (IS_ERR(clks[i])) BUG(); (clkc.c:570-575)

So a fully failed registration already BUG()s. The remaining hole is mixed failure (mux kasprintf fails, div succeeds): mux/div registration fails, gate may still register with a valid DT name and a never-created parent → no BUG(), broken UART/SDIO/SPI/LQSPI/SMC/PCAP clocks, and the spinlock can leak because err is not taken.
- Record: [error-path leak + WARN + inconsistent clks[] / possible silent broken periph clocks]

**Step 2.4: ASSESS THE FIX QUALITY**
- Matches the existing zynq_clk_register_fclk() pattern (present since f8fe36f6083a70, v3.13).
- kfree(lock) on this path is correct: no clk_register_* has run yet.
- Does not change the success path.
- Regression risk: very low. On failure, clks[] becomes ERR_PTR(-ENOMEM) and zynq_clk_setup() BUG()s — same policy this driver already uses for lock allocation / registration failure.
- Record: [obviously correct, 8 lines, error-path only; risk very low]

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

**Step 3.1: BLAME THE CHANGED LINES**
- Function introduced in 0ee52b157b8ed8 (“clk: zynq: Add clock controller driver”), 2013, contained in **v3.11-rc1**.
- kasprintf calls were unchecked from introduction until this fix.
- Record: [0ee52b157b8ed8 / v3.11] [bug present for the life of this driver]

**Step 3.2: FOLLOW THE FIXES: TAG**
- No Fixes: tag. Buggy commit is the original driver add, which **is** in this tree.
- Record: [no Fixes tag; original driver commit is in this tree]

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
- f8fe36f6083a70 (v3.13): same goto-cleanup for zynq_clk_register_fclk() kasprintf/kmalloc
- 7938e9ce39d67 (2024, in this tree): “Prevent null pointer dereference caused by kmalloc failure” in zynq_clk_setup()
- a6aa462c3efc1: parameter update to this function — not a prerequisite for these checks
- Standalone; not patch N/M
- Record: [standalone; sibling already had the pattern; related kmalloc NPD fix already here]

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
- Only this clk/zynq commit from William Theesfeld in this tree
- Weight comes from reviewers: Michal Simek (Zynq) and Brian Masney (clk)
- Record: [author not subsystem maintainer; both relevant maintainers reviewed]

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
- Uses existing kasprintf, kfree, goto err — all present
- Mainline context uses kmalloc_obj; this tree still uses kmalloc(sizeof(*lock), GFP_KERNEL). The hunk does not touch that line, so no kmalloc_obj dependency.
- Record: [no prerequisites; applies standalone against this tree’s kmalloc() form]

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
- b4 dig -c d4d0d335e8d37c6c7e1c5664c7664288eca5a09b →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only** (2026-06-01)
- Thread saved to mbox: Michal Simek Reviewed-by (2026-06-02); Brian Masney Reviewed-by (2026-06-15). No NAK, no requested respin, no Cc:
stable in review.
- Lore WebFetch returned 403; discussion read from b4 dig -m instead
- Record: [lore msgid [email protected]] [v1 applied] [no NAKs] [no stable nomination in thread]

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
- b4 dig -w recipients: Turquette, Boyd, Masney, Simek, linux-clk, linux-arm-kernel, linux-kernel
- Record: [clk maintainers + Zynq maintainer were on To/Cc; both Reviewed-by]

**Step 4.3: SEARCH FOR THE BUG REPORT**
- No Reported-by / Link / syzbot
- Record: [no external bug report; found by code inspection]

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
- Standalone v1 patch, not a series
- Record: [standalone]

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
- lore.kernel.org/stable/ fetch returned 403
- Record: [UNVERIFIED: stable-list discussion; not used for the verdict]

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

**Step 5.1: IDENTIFY KEY FUNCTIONS**
- Record: [zynq_clk_register_periph_clk (modified); zynq_clk_setup (caller)]

**Step 5.2: TRACE CALLERS**
Call sites in zynq_clk_setup() (CLK_OF_DECLARE "xlnx,ps7-clkc", every Zynq boot):
- lqspi, smc, pcap (single gate)
- sdio0/sdio1, uart0/uart1, spi0/spi1 (two gates)
- Record: [boot-time OF clock init for Zynq PS peripherals]

**Step 5.3: TRACE CALLEES**
- kasprintf, kmalloc/kfree, clk_register_mux/divider/gate
- Record: [name alloc + CCF register; gate clocks stored in clks[]]

**Step 5.4: FOLLOW THE CALL CHAIN**
- CLK_OF_DECLARE → zynq_clk_setup → zynq_clk_register_periph_clk during early boot on CONFIG_ARCH_ZYNQ
- CONFIG_ARCH_ZYNQ=y in arch/arm/configs/multi_v7_defconfig
- Not a syscall path; unprivileged users cannot trigger it except by booting the platform (possibly under memory pressure)
- Record: [reachable on every Zynq boot; not userspace-triggerable later]

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
- zynq_clk_register_fclk() already checks every kasprintf
- After this patch, no remaining unchecked kasprintf in drivers/clk/zynq/clkc.c
- Record: [sibling already fixed; this was the remaining hole]

===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
- git describe HEAD → **v6.18.53-5049-g0f0bdc2b0dffb**
- make kernelversion → **6.18.53**
- Parent of the candidate still has unchecked kasprintf in zynq_clk_register_periph_clk
- Driver built as obj-$(CONFIG_ARCH_ZYNQ) += zynq/
- Record: [yes, buggy code exists in 6.18.y zynq clkc; bug since v3.11]

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
- Surrounding function matches; only the 8 check/label lines are needed
- kmalloc_obj in the mainline diff context is **not** used in this file here
- Record: [clean apply / trivial context]

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
- 7938e9ce39d67 (kmalloc NPD in zynq_clk_setup) is already in this tree — different allocation
- fclk kasprintf checks already present
- No earlier equivalent of this periph_clk check besides the candidate itself
- Record: [no substitute fix for this function’s kasprintf]

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
- drivers/clk/zynq/ — platform clock provider for Xilinx Zynq-7000
- Criticality: **IMPORTANT** for Zynq (UART/SDIO/SPI clocks); **PERIPHERAL** vs core kernel
- Record: [clk/zynq] [IMPORTANT for affected SoC, not universal]

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
- File is mature (2013); recent commits are small correctness fixes, not refactors
- Record: [mature/stable platform driver]

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

**Step 8.1: DETERMINE WHO IS AFFECTED**
- Record: [platform-specific: CONFIG_ARCH_ZYNQ / xlnx,ps7-clkc]

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
- kasprintf(GFP_KERNEL, "%s_mux"/"%s_div", clk_name0) during __init (~tens of bytes)
- Trigger: allocation failure at boot (rare, but same class this file already treats as fatal via BUG())
- Not triggerable later from unprivileged userspace
- Record: [rare boot OOM; not a syscall race]

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Verified, not just the commit text:
- NULL clock **name**: CCF fails -ENOMEM (no debugfs NPD on that path in 6.18)
- NULL **parent** name: WARN() then -EINVAL
- Some combinations: clks[i] is ERR_PTR → existing BUG() in zynq_clk_setup
- Mixed success: possible boot with broken peripheral clocks + spinlock leak
- Author’s debugfs-NPD example is **overstated for this CCF**, but WARN / leak / inconsistent init are real
- Record: [WARN + leak + possible BUG() or silently broken UART/SDIO/SPI] [severity HIGH on trigger, trigger rare]

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
- Benefit: correct OOM handling for clocks used on every Zynq boot; closes leak; avoids WARN and half-registered trees
- Risk: 8 lines, error path only, same pattern already in-tree
- Record: [benefit medium-high if it fires; risk very low; ratio favors backport]

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Real missing error handling on kasprintf in a boot clock path that already BUG()s on IS_ERR(clks[i])
- Also a spinlock leak and a WARN() on NULL parent names
- 8-line, obviously correct, mirrors in-tree sibling
- Code and bug exist in this 6.18 tree since v3.11
- Applies without kmalloc_obj or other prereqs
- Reviewed by Zynq maintainer and clk maintainer
- Same file already received a 2024 allocation-failure NPD fix

AGAINST:
- Trigger is a tiny boot-time allocation failure (rare)
- No user/syzbot report
- Debugfs NPD claim is not how 6.18 CCF handles a NULL init.name (fails -ENOMEM first)
- Platform-specific, not core

UNRESOLVED:
- Stable mailing list search (lore 403)

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — matches existing fclk pattern; two maintainer Reviewed-by
2. Fixes a real bug that affects users? **PASS** — unchecked alloc, leak, WARN, inconsistent clks[] on Zynq boot
3. Important issue? **PASS** — boot WARN/BUG()/broken UART-SDIO-SPI clocks; same class as the in-tree kmalloc NPD fix
4. Small and contained? **PASS** — +8 lines, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — function and bug present; context is kmalloc(sizeof), not kmalloc_obj

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
- Not a device ID / quirk / DT / build / docs exception
- Record: [none; qualifies as a normal small bugfix]

**Step 9.4: MAKE YOUR DECISION**
The patch is a small, maintainer-reviewed error-path fix for code this 6.18 tree has had since v3.11. It does not add features. Risk is confined to the allocation-failure path. That is appropriate for this stable tree.

===============================================================
What problem it solves for this tree
===============================================================
zynq_clk_register_periph_clk() builds mux/divider names with kasprintf() and, on failure, still calls into the clock framework. That can WARN on a NULL parent, leak the per-clock spinlock, and either BUG() in zynq_clk_setup() or leave UART/SDIO/SPI/LQSPI clocks half-registered. The fix stops before clk_register_*, frees the lock/name, and reports -ENOMEM the way lock allocation already does.

===============================================================
Verification
===============================================================
- [Phase 1] Parsed tags: Reviewed-by Masney + Simek; no Fixes/Reported- by/Cc stable; ignored pipeline Upstream/Sasha SOB
- [Phase 1] Subject/body: handle kasprintf failure; claimed NPD; sibling fclk pattern
- [Phase 2] Diff: +8 in zynq_clk_register_periph_clk; parent still unchecked (git show e3b8b15^)
- [Phase 2] CCF: kstrdup(NULL) returns NULL (mm/util.c:84); __clk_register -ENOMEM on NULL name (clk.c:4435-4438); NULL parent WARN + -EINVAL (clk.c:4347-4351)
- [Phase 2] zynq_clk_setup BUG()s on IS_ERR(clks[i]) (clkc.c:570-575)
- [Phase 3] blame: function from 0ee52b157b8ed8 (v3.11-rc1); fclk checks from f8fe36f6083a70 (v3.13)
- [Phase 3] related 7938e9ce39d67 kmalloc NPD fix is ancestor of HEAD
- [Phase 3] no Fixes tag; original driver commit is in this tree
- [Phase 4] b4 dig -c d4d0d335…: lore msgid [email protected]
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: clk + Zynq maintainers on Cc
- [Phase 4] mbox: Simek and Masney Reviewed-by; no NAK
- [Phase 4] lore WebFetch 403; stable-list search UNVERIFIED
- [Phase 5] callers: lqspi/smc/pcap/sdio/uart/spi from zynq_clk_setup; CLK_OF_DECLARE(zynq_clkc, "xlnx,ps7-clkc")
- [Phase 5] CONFIG_ARCH_ZYNQ=y in multi_v7_defconfig; obj-$(CONFIG_ARCH_ZYNQ) += zynq/
- [Phase 6] git describe HEAD = v6.18.53-5049-g0f0bdc2b0dffb; kernelversion 6.18.53
- [Phase 6] buggy kasprintf present without this patch; no kmalloc_obj in this file
- [Phase 8] failure mode verified against CCF (debugfs NPD overstated); WARN/leak/BUG/broken periph clocks verified
- UNVERIFIED: whether this hash was discussed on stable@ (lore 403)

The fix is small, surgical, present in the affected 6.18 code, and meets the stable criteria.

**YES**

 drivers/clk/zynq/clkc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/clk/zynq/clkc.c +8 -0
index c28d3dacf0fb2..db40a9e7dd3d9 100644
@@ -186,7 +186,11 @@ static void __init zynq_clk_register_periph_clk(enum zynq_clk clk0,
 	spin_lock_init(lock);
 
 	mux_name = kasprintf(GFP_KERNEL, "%s_mux", clk_name0);
+	if (!mux_name)
+		goto err_mux_name;
 	div_name = kasprintf(GFP_KERNEL, "%s_div", clk_name0);
+	if (!div_name)
+		goto err_div_name;
 
 	clk_register_mux(NULL, mux_name, parents, 4,
 			CLK_SET_RATE_NO_REPARENT, clk_ctrl, 4, 2, 0, lock);
@@ -205,6 +209,10 @@ static void __init zynq_clk_register_periph_clk(enum zynq_clk clk0,
 
 	return;
 
+err_div_name:
+	kfree(mux_name);
+err_mux_name:
+	kfree(lock);
 err:
 	clks[clk0] = ERR_PTR(-ENOMEM);
 	if (two_gates)
Signature · 1 line
2.53.0
author maintainer
#364 lore raw

PATCH 1/1 HID: roccat: fix locking in roccat_connect() and roccat_disconnect()

In reply to Sasha Levin

From: Dmitry Antipov <[email protected]>

[ Upstream commit d76994443eed0af297cb82bd038ae9d76327ef90 ]

Extend critical section in roccat_connect() to ensure that partially initialized 'struct roccat_device' is never exposed in 'devices' list, and do the same in roccat_disconnect() to avoid racy 'devices' access against roccat_release().

---

LLM Generated explanations, may be completely bogus:

The local tree is **6.18.57** (v6.18.57-155-gcdf239ca885b2). The buggy locking is present at v6.18.57; this commit is not an ancestor of that tag.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**
- Subsystem: HID: roccat
- Action verb: **fix**
- Claimed intent: correct locking around roccat_connect() / roccat_disconnect() so a half-initialized device is not published and disconnect cannot race with roccat_release().
- Record: [HID/roccat] [fix] [locking around connect/disconnect vs devices[] publication]

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Upstream d76994443eed0af297cb82bd038ae9d76327ef90:
- Signed-off-by: Dmitry Antipov <[email protected]> (author)
- Signed-off-by: Jiri Kosina <[email protected]> (HID maintainer)
- No Fixes:, Reported-by:, Tested-by:, Link:, or Cc: stable (expected for this review)
- Ignore pipeline [Upstream commit ...] and Signed-off-by: Sasha Levin

The series cover letter for patch 2/2 (not this commit) had:
- Reported-by: [email protected]
- Closes: https://syzkaller.appspot.com/bug?extid=d632e93ffcd1452bc61e

A competing same-week patch for the same races (Deepanshu Kartikey) had:
- Reported-by: [email protected]
- Tested-by: syzbot
- Closes: https://syzkaller.appspot.com/bug?extid=c492a9e154f81127551f
Title: **KASAN: slab-use-after-free Read in roccat_disconnect**

Record: No tags on this commit itself; the same UAF is a documented syzbot KASAN crash.

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Bug: devices[minor] is published, then devices_lock is dropped before struct roccat_device is fully initialized. Disconnect also drops the lock between lookup and teardown, racing roccat_release().
- Symptom: concurrent open/ioctl/release vs probe/remove can use an uninitialized mutex or free the object while disconnect still reads device->open.
- Version: none stated. Blame shows the pattern since 2010 (206f5f2fcb5ff).
- Root cause (author): critical section too short.

Record: [UAF / uninitialized-mutex race] [KASAN UAF in disconnect; possible lock on uninit mutex in open] [present since 2010] [lock dropped too early]

**Step 1.4: DETECT HIDDEN BUG FIXES**
Not disguised. Record: [Not a hidden fix; explicit locking/race fix]

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY**
- File: drivers/hid/hid-roccat.c — 3 insertions, 5 deletions (net −2)
- Functions: roccat_connect(), roccat_disconnect()
- Record: [1 file, +3/-5] [roccat_connect, roccat_disconnect] [single- file surgical]

**Step 2.2: CODE FLOW CHANGE**

Hunk 1 — roccat_connect() at v6.18.57:
- Before: under devices_lock, slot devices[minor], device_create(), **unlock**, then init_waitqueue_head, mutex_init(readers_lock/cbuf_lock), set hid, exist, report_size.
- After: same work, but unlock only after those initializers.
- Path: probe / roccat_connect() from hid-roccat-* drivers.

Hunk 2 — roccat_disconnect():
- Before: lock, load devices[minor], **unlock**; exist=0; device_destroy(); lock, devices[minor]=NULL, unlock; then read device->open and either hid_hw_close+wakeup or roccat_free_device().
- After: one critical section covering lookup, exist=0, destroy, NULL slot, free-or-keep.
- Path: USB unplug / driver remove (savu_remove, kone_remove, etc.).

**Step 2.3: BUG MECHANISM**
Category: **race / UAF** plus **uninitialized mutex**.

Verified against v6.18.57:

1. Connect publishes devices[minor] then drops the lock before mutex_init(&device->readers_lock). roccat_open() takes devices_lock, then mutex_lock(&device->readers_lock). That is a lock on an uninitialized mutex if open wins the race after device_create().

2. Disconnect reads device and drops the lock. roccat_release() (also under devices_lock) can see exist==0 and open==0 and call roccat_free_device(). Disconnect then reads device->open at old line 382 — **KASAN slab-use-after-free**. Syzbot’s stack matches:
freed in roccat_release, use in roccat_disconnect.

Record: [race/UAF + uninit mutex] [extend devices_lock so publication and teardown are atomic vs open/release]

**Step 2.4: FIX QUALITY**
- Correct for the reported UAF: release and disconnect both need devices_lock for the whole free-or-keep decision. After this, they cannot interleave.
- Correct for the uninit-mutex race: open/ioctl wait on devices_lock until mutexes exist.
- Minimal; no API change.
- Residual issues (pre-existing, not introduced):
- If files are still open, disconnect NULLs devices[minor] and does not free. roccat_release() then sees NULL and returns -ENODEV without roccat_free_device() — **leak on unplug-while-open**. That was already the non-racy outcome of the old NULL-then-close sequence; the racy outcome was UAF. UAF → leak is an improvement.
- Patch 2/2 (kref) was meant to finish lifetime handling; Jiri Kosina did **not** apply it (kref accounting bugs).
- roccat_report_event() still loads devices[minor] without the lock (pre-existing).
- Regression risk: disconnect now holds devices_lock across device_destroy() and hid_hw_close(). roccat_release() already held that lock across hid_hw_close(). device_create() was already inside the lock. hidraw uses the same “hold table lock for the whole connect/disconnect” pattern.

Record: [obviously correct for the UAF; residual leak is pre-existing common path] [low regression risk]

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME**
- Buggy unlock-before-init in connect: 206f5f2fcb5ff (Stefan Achatz, 2010-05-19), v2.6.35-era.
- Disconnect split lock / devices[minor]=NULL: e6fa47af5542d (2011-01-30).
- Record: [206f5f2fcb5ff / e6fa47af5542d] [present since ~2010, including 6.18.y]

**Step 3.2: FIXES TAG**
None. Introducer is 206f5f2fcb5ff, which **is** in this tree.

**Step 3.3: FILE HISTORY**
At v6.18.57:
- da00eac19feef HID: roccat: free buffered reports when destroying device (already in 6.18.57; this patch only moves the existing roccat_free_device() call)
- 36bb2d0b91501 HID: roccat: fix use-after-free in roccat_report_event (CVE-2026-43111, already in 6.18.24+)

No later commit on this file after the candidate. Standalone 1/2; 2/2 not merged.

**Step 3.4: AUTHOR**
Dmitry Antipov — not the original driver author; HID maintainer Jiri Kosina applied 1/2. No other Antipov hid-roccat commits in this tree besides this one.

**Step 3.5: DEPENDENCIES**
- Uses existing devices_lock and roccat_free_device() (the latter from da00eac19feef, already in 6.18.57).
- Patch 2/2 is **not** required: maintainer applied 1/2 alone.
- Record: [standalone; applies on 6.18.57]

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: ORIGINAL DISCUSSION**
b4 dig -c d76994443eed0af297cb82bd038ae9d76327ef90:
- https://patch.msgid.link/[email protected]
- Series: **v1 only**, [PATCH 1/2] + [PATCH 2/2] HID: roccat: use kref to manage device instances

Jiri Kosina (11 Sep 2026): **applied 1/2**. On 2/2: “the issues that Sashiko pointed out with 2/2 are real, so please fix them and resubmit separately.”

Syzbot bug still listed, but Oct 8 upstream retests reported **no crash**; later Oct 16 tests are extra lifetime patches in hid.git for-7.4/roccat, not a revert of 1/2.

**Step 4.2: RECIPIENTS (b4 dig -w)**
Dmitry Antipov, Jiri Kosina, Benjamin Tissoires, linux-input@, lvc- project@. HID maintainers were on the To/Cc list.

**Step 4.3: BUG REPORT**
https://syzkaller.appspot.com/bug?extid=c492a9e154f81127551f
- KASAN slab-use-after-free Read in roccat_disconnect
- C repro, 20 crashes, prio:high
- Freed in roccat_release, used at if (device->open) in disconnect
- Trigger: USB disconnect vs close of the roccat char dev (syzbot USB gadget)
- Security assessment on the dashboard: DoS exploitable, peripheral trigger

**Step 4.4: RELATED SERIES**
- 2/2 kref: not applied (broken accounting / dangling devices[] pointer).
- Competing Kartikey patch: same disconnect lock extension; also inits the device **before** publishing. Maintainer took Antipov’s smaller 1/2 instead. Disconnect half is equivalent.

**Step 4.5: STABLE LIST**
No prior stable-thread rejection found (lore.kernel.org/stable search did not return a relevant hit). Absence of Cc: stable is expected.

Record: [lore thread via b4; 1/2 applied, 2/2 rejected; syzbot KASAN UAF with C repro]

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: FUNCTIONS**
roccat_connect(), roccat_disconnect().

**Step 5.2: CALLERS**
roccat_connect / roccat_disconnect from probe/remove of:
- hid-roccat-pyra, ryos, savu, arvo, isku, kone, koneplus, konepure, kovaplus

Syzbot crash: savu_remove → roccat_disconnect on USB disconnect workqueue vs roccat_release from __fput.

devices_lock also used by roccat_open, roccat_release, roccat_ioctl — those are the racing syscalls.

**Step 5.3: CALLEES**
device_create / device_destroy, hid_hw_close, wake_up_interruptible, roccat_free_device.

**Step 5.4: REACHABILITY**
Yes. Unprivileged USB gadget / physical unplug plus close of /dev/roccat*. Syzbot has a C repro.

**Step 5.5: SIMILAR PATTERNS**
hidraw holds minors_rwsem for the whole hidraw_connect() / hidraw_disconnect(). Same idea.

Record: [USB remove vs fput; userspace-reachable; HID-roccat family]

---

## PHASE 6: CROSS-REFERENCING AGAINST THIS TREE

**Step 6.1: BUGGY CODE IN THIS TREE?**
Yes, at v6.18.57:drivers/hid/hid-roccat.c roccat_connect() unlocks at old line 347 before init; roccat_disconnect() unlocks at old line 372 then later reads device->open.

git merge-base --is-ancestor 7e1d29620273b v6.18.57 → not an ancestor. git merge-base --is-ancestor d76994443eed v6.18.57 → not an ancestor.

**Step 6.2: BACKPORT DIFFICULTY**
patch --dry-run -p1 of the upstream diff against v6.18.57:drivers/hid/hid-roccat.c → **clean apply**.

**Step 6.3: RELATED FIXES ALREADY HERE**
- 36bb2d0b91501 — different UAF (readers list in roccat_report_event), already in 6.18.y.
- da00eac19feef — leak of cbuf reports, already in 6.18.y.
- This disconnect/open race is **not** fixed in 6.18.57.

Record: [bug present; clean apply; no substitute fix]

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1:** drivers/hid/hid-roccat.c — HID char device for Roccat mice/keyboards (CONFIG_HID_ROCCAT, depends on USB_HID). Criticality:
**PERIPHERAL**, but the UAF is real for those devices and for syzbot USB emulation.

**Step 7.2:** Driver is old (2010) and low-churn except recent UAF/leak fixes. Mature code with a long-standing race, not a new subsystem.

Record: [HID/roccat] [PERIPHERAL] [mature, recent UAF fixes]

---

## PHASE 8: IMPACT AND RISK

**Step 8.1:** Users of Roccat HID devices with CONFIG_HID_ROCCAT; also fuzzers/USB gadget. Not universal.

**Step 8.2:** Trigger: unplug (or driver unbind) while userspace has the char device open/closing. Timing-dependent but **reproduced** (syzbot C repro). Not a normal unprivileged syscall-only path without USB, but USB remove is a normal user action.

**Step 8.3:** Failure: KASAN UAF in roccat_disconnect on usb_hub_wq → kernel oops / memory corruption. Severity: **HIGH** (crash, potential memory-safety issue).

**Step 8.4:**
- Benefit: high for affected hardware / USB remove-vs-close; closes a confirmed UAF.
- Risk: low (8-line lock-scope change, same lock already used around hid_hw_close in release).
- Ratio: **benefit >> risk**. Residual leak on unplug-while-open is worse than nothing but far better than UAF.

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: EVIDENCE**

For:
- Confirmed KASAN UAF, syzbot C repro, crash on USB disconnect vs roccat_release
- Second race: open can lock uninitialized readers_lock
- Code in 6.18.57 matches the buggy version
- 8-line lock-scope change, clean apply
- HID maintainer applied 1/2 as a standalone fix
- No new API; not a feature
- Same class of fix already accepted for this file (CVE-2026-43111)

Against:
- Niche HID driver
- Incomplete lifetime (leak if unplug while fds remain); 2/2 kref not merged
- roccat_report_event() still lockless on devices[] (pre-existing)
- Connect still publishes the pointer before init, but now under the lock so open waits

Unresolved:
- Whether a later hid.git for-7.4 kref series will replace this; that does not make 1/2 unsafe for 6.18.y.

**Step 9.2: STABLE RULES**
1. Obviously correct and tested? **PASS** — lock covers the UAF window; syzbot repro exists; maintainer applied it.
2. Real bug affecting users? **PASS** — KASAN UAF on unplug vs close.
3. Important (crash/security/corruption)? **PASS** — UAF/oops, HIGH.
4. Small and contained? **PASS** — +3/−5, one file.
5. No new features/APIs? **PASS**.
6. Applies to local tree? **PASS** — clean on v6.18.57.

**Step 9.3: EXCEPTIONS**
Not an ID/quirk/DT/build/docs exception. It is a normal race/UAF fix.

**Step 9.4: DECISION**
Backport to this 6.18.y tree. The bug is here, the fix is small, and it addresses a real UAF, not a refactor.

---

### What the commit solves for 6.18.y users

On 6.18.57, roccat_disconnect() drops devices_lock and then reads device->open. Concurrent roccat_release() can free that object. Syzbot hits that as **KASAN slab-use-after-free in roccat_disconnect**. Connect also exposes the object before mutex init. Extending the existing devices_lock critical sections closes both windows. Remaining leak-if-still-open is the old non-racy path, not a new regression.

Risk vs benefit: a few lines of lock-scope change vs a demonstrated UAF. Patch 2/2 is not a prerequisite.

---

Verification:
- [Phase 1] Parsed upstream d76994443eed; tags: author SOB + Jiri Kosina SOB only
- [Phase 1] Series 2/2 has syzbot d632e93ffcd1452bc61e; competing patch has syzbot c492a9e154f81127551f
- [Phase 2] Diff +3/−5 in roccat_connect/roccat_disconnect; compared to v6.18.57:drivers/hid/hid-roccat.c
- [Phase 2] Confirmed open takes readers_lock after devices_lock; connect used to init that mutex after unlock
- [Phase 2] Confirmed disconnect old line 382 is if (device->open) — matches KASAN “Read of size 4”
- [Phase 3] git blame -L 309,387 v6.18.57 -- drivers/hid/hid-roccat.c:
2010/2011 introducers
- [Phase 3] git merge-base --is-ancestor 7e1d29620273b v6.18.57 → false; not in 6.18.57
- [Phase 3] da00eac19feef / 36bb2d0b91501 already in 6.18.57; different bugs
- [Phase 4] b4 dig -c d76994443eed → msgid [email protected]
- [Phase 4] b4 mbox thread: Jiri applied 1/2, rejected 2/2
- [Phase 4] b4 dig -w: Kosina, Tissoires, linux-input
- [Phase 4] WebFetch syzbot: KASAN UAF, C repro, 20 crashes; Oct 8 upstream retest no crash
- [Phase 5] grep callers: nine hid-roccat-* probe/remove paths; syzbot used savu
- [Phase 6] git describe HEAD → v6.18.57-155-gcdf239ca885b2; make kernelversion → 6.18.57
- [Phase 6] patch --dry-run -p1 of upstream diff on v6.18.57 file → success
- [Phase 7] Kconfig HID_ROCCAT depends on USB_HID
- [Phase 8] Failure mode verified from syzbot report, not inferred
- UNVERIFIED: later hid.git for-7.4 kref work (not in this tree; 2/2 was rejected from mainline)
- UNVERIFIED: lore.kernel.org HTTP fetch (403); used b4 + openwall/syzkaller instead

The patch is a small, correct UAF/race fix that applies cleanly to this 6.18.57 tree.

**YES**

 drivers/hid/hid-roccat.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/hid/hid-roccat.c +3 -5
index e54b6a8a92ef7..77042c7edf765 100644
@@ -344,8 +344,6 @@ int roccat_connect(const struct class *klass, struct hid_device *hid, int report
 		return temp;
 	}
 
-	mutex_unlock(&devices_lock);
-
 	init_waitqueue_head(&device->wait);
 	INIT_LIST_HEAD(&device->readers);
 	mutex_init(&device->readers_lock);
@@ -356,6 +354,7 @@ int roccat_connect(const struct class *klass, struct hid_device *hid, int report
 	device->cbuf_end = 0;
 	device->report_size = report_size;
 
+	mutex_unlock(&devices_lock);
 	return minor;
 }
 EXPORT_SYMBOL_GPL(roccat_connect);
@@ -369,15 +368,12 @@ void roccat_disconnect(int minor)
 
 	mutex_lock(&devices_lock);
 	device = devices[minor];
-	mutex_unlock(&devices_lock);
 
 	device->exist = 0; /* TODO exist maybe not needed */
 
 	device_destroy(device->dev->class, MKDEV(roccat_major, minor));
 
-	mutex_lock(&devices_lock);
 	devices[minor] = NULL;
-	mutex_unlock(&devices_lock);
 
 	if (device->open) {
 		hid_hw_close(device->hid);
@@ -385,6 +381,8 @@ void roccat_disconnect(int minor)
 	} else {
 		roccat_free_device(device);
 	}
+
+	mutex_unlock(&devices_lock);
 }
 EXPORT_SYMBOL_GPL(roccat_disconnect);
 
Signature · 1 line
2.53.0
author maintainer
#365 lore raw

PATCH 1/1 drm/etnaviv: check all modules for idle after reset

In reply to Sasha Levin

From: Lucas Stach <[email protected]>

[ Upstream commit 1006d1f7c03d92b28c252333836635df8e165401 ]

While the FE is an important part of the GPU, which needs to be idle after reset, all other modules should be idle after a proper reset. Check all present modules for being idle to determine whether the reset was successful.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit message forensics

**Step 1.1: Subject line**
Record: [drm/etnaviv] [check] [after GPU reset, require every present module idle, not only FE]

**Step 1.2: Tags**
Record:
- Reviewed-by: Christian Gmeiner <[email protected]> (etnaviv reviewer in MAINTAINERS)
- `Link: https://patch.msgid.link/20260511085148.652256-1-
[email protected]`
- Signed-off-by: Lucas Stach <[email protected]> (etnaviv maintainer)
- No Fixes:, Reported-by:, Tested-by:, Cc: stable, or syzbot tags (absence of Fixes/Cc-stable is expected here)

**Step 1.3: Body**
Record:
- Bug: reset success was decided only from the frontend (FE) idle bit.
- Symptom/failure mode: a reset that leaves other modules busy is treated as success; the driver then continues probe or hang recovery.
- Version info: none in the message.
- Root cause (author): after a proper reset every present module should be idle; FE-only is not enough.

**Step 1.4: Hidden bug fix?**
Record: Not disguised. It is an explicit correctness fix of reset- success detection. Verb is “check”, but it changes a control-flow condition that previously let a non-idle GPU leave the retry loop.

## Phase 2: Diff analysis

**Step 2.1: Inventory**
Record:
- File: drivers/gpu/drm/etnaviv/etnaviv_gpu.c (~3 lines changed, 3+/3-)
- Function: etnaviv_hw_reset()
- Scope: single-file surgical change

**Step 2.2: Code flow**
Record:
- Before: after gpu_read(VIVS_HI_IDLE_STATE), retry only if (idle & VIVS_HI_IDLE_STATE_FE) == 0.
- After: retry if (idle & gpu->idle_mask) != gpu->idle_mask.
- Path: hardware reset retry loop (1s timeout). Used from GPU init (etnaviv_gpu_init path) and hang recovery (etnaviv_gpu_recover_hang).

The loop already had a second check on VIVS_HI_CLOCK_CONTROL IDLE_3D/IDLE_2D. This change only widens the IDLE_STATE check from FE to idle_mask.

**Step 2.3: Bug mechanism**
Record: [Logic / correctness] Reset success was too weak. Incomplete reset could be accepted if FE was idle. Fix reuses gpu->idle_mask, already used by etnaviv_gpu_wait_idle() and RPM suspend.

**Step 2.4: Fix quality**
Record:
- Obviously correct relative to existing idle policy; same comparison as etnaviv_gpu_wait_idle().
- Minimal; no API/struct change.
- Regression risk: stricter success can turn a flaky reset into -EBUSY after 1s (probe fails). That is the intended failure if modules never go idle. idle_mask already accounts for GC300/GC600 absent-module bits (~AXI_LP elsewhere). No lock/API change.

## Phase 3: Git history

**Step 3.1: Blame**
Record:
- FE-only check: a8c21a5451d83 (“drm/etnaviv: add initial etnaviv DRM driver”, 2015).
- idle_mask field: same initial driver; default ~VIVS_HI_IDLE_STATE_AXI_LP moved earlier in 2b76f5be7c2778 (2018/2019, “initialize idle mask before querying the HW db”).
- Bug is long-standing, not new 7.3 code.

**Step 3.2: Fixes: tag**
Record: None. Introducer is the 2015 driver add, verified via blame/git log -S.

**Step 3.3: Related file history**
Record:
- 1006d1f7c03d9 — this commit
- 4720915ab4828 — patch 2/2, MMUv2 disabled-after-reset check (independent extra check)
- c182a2ae13886 — later power-register flush; not a prerequisite of this hunk
This commit is standalone. Patch 2 is related hardening, not required for this condition change.

**Step 3.4: Author**
Record: Lucas Stach is listed M: for “DRM DRIVERS FOR VIVANTE GPU IP”. Christian Gmeiner is R:. Recent etnaviv work by the same author includes hang-check and reset-related fixes.

**Step 3.5: Dependencies**
Record: Needs gpu->idle_mask and the reset retry loop. Both exist in this tree (and have since the original driver / 2019 idle_mask init). Applies standalone. Does not need gpu_write_power_sync from the later flush commit.

## Phase 4: Mailing list / external

**Step 4.1: Original discussion**
Record:
- b4 dig -c 1006d1f7c03d9 → https://patch.msgid.link/20260511085148.65
[email protected]
- b4 dig -a: single v1 series, two patches. Committed version matches v1.
- Reviewer: Reviewed-by only; no NAK, no stable nomination, no risk discussion.
- lore.kernel.org HTTP fetch returned 403; thread recovered via b4 dig -m.

**Step 4.2: Recipients (b4 dig -w)**
Record: Lucas Stach, [email protected], dri- [email protected], Christian Gmeiner. Right lists and reviewer.

**Step 4.3: Bug report**
Record: No Reported-by, bugzilla, or syzbot. No described repro. UNVERIFIED whether a specific hang prompted the series; message does not say.

**Step 4.4: Series**
Record: 1/2 idle-mask check; 2/2 MMUv2 disable check. Independent. 1/2 is self-contained.

**Step 4.5: Stable list**
Record: Web search of lore stable for this subject found no relevant thread. No evidence it was rejected for stable.

## Phase 5: Semantic / impact

**Step 5.1: Functions**
Record: etnaviv_hw_reset() only.

**Step 5.2: Callers**
Record:
- GPU identify/init: ret = etnaviv_hw_reset(gpu); — probe/init failure if reset times out.
- etnaviv_gpu_recover_hang() ← etnaviv_sched.c timed-out job path (drm_sched_stop → recover → resubmit). Return value of reset is ignored there (pre-existing). Benefit on that path is extra retries until modules are idle, not a new hard fail.

**Step 5.3: Callees**
Record: gpu_read(VIVS_HI_IDLE_STATE) unchanged; only the predicate changes.

**Step 5.4: Reachability**
Record: Yes. Init/reset on device bring-up; hang recovery from GPU scheduler after a stuck job (userspace GL/Vulkan/etnaviv DRM). Not syscall-direct memory corruption; it is a common driver path on Vivante / i.MX systems.

**Step 5.5: Similar patterns**
Record: etnaviv_gpu_wait_idle() already uses (idle & gpu->idle_mask) == gpu->idle_mask. RPM suspend uses idle_mask minus FE/MC. This aligns reset with those definitions.

## 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
- etnaviv_hw_reset, idle_mask, and the idle register exist here.
- git merge-base --is-ancestor 1006d1f7c03d9 HEAD → yes (commit already in this 7.3-rc4 lineage).
- Pre-commit code (parent 3e32e6672fa30) still had the FE-only test. Introduced 2015; not after this branch.

**Step 6.2: Backport difficulty**
Record: Clean 3-line predicate swap. No refactor of the surrounding reset function is required for this hunk. Expected: clean apply on trees that still have the FE-only check.

**Step 6.3: Related fixes already here**
Record: This exact change is already in HEAD. Follow-up MMUv2 check is also here; it is not a substitute for the idle_mask check.

## Phase 7: Subsystem

**Step 7.1**
Record: [drm/etnaviv] [IMPORTANT] — not core mm/net, but the Vivante GPU driver used on NXP i.MX and similar embedded SoCs, including display.

**Step 7.2**
Record: Actively maintained (recent reset/hang/cache commits). The FE- only check itself was untouched for ~10 years.

## Phase 8: Impact and risk

**Step 8.1: Who**
Record: Driver-specific: CONFIG_DRM_ETNAVIV / Vivante GPU users (embedded i.MX class).

**Step 8.2: Trigger**
Record: GPU soft-reset during init and after hangcheck. Incomplete module idle after reset is the hardware case the existing retry loop already exists for. Unprivileged GPU clients can trigger hang recovery via a stuck job; they cannot directly poke the idle register.

**Step 8.3: Failure mode**
Record: [incomplete reset treated as success] [HIGH for GPU, not kernel panic]. Probe can later use a GPU that is not fully idle; hang recovery can resubmit onto modules still busy → further hangs, failed jobs, possible display freeze. Not KASAN/UAF. Not a documented CVE.

**Step 8.4: Risk-benefit**
Record:
- Benefit: medium-high for etnaviv — reset/hang recovery actually waits for the same idle definition the rest of the driver uses.
- Risk: low — 3 lines, existing mask, maintainer + reviewer. Residual risk is probe -EBUSY if some chip never sets all idle_mask bits after reset; GC300/GC600 already have a reduced mask, and wait_idle/RPM have used this mask for years.
- Ratio: favorable.

## Phase 9: Synthesis

**Step 9.1: Evidence**

FOR:
- Real logic bug: reset-success ignored non-FE modules.
- Same idle_mask already used for wait_idle and RPM.
- 3-line, obviously correct, no new API.
- Hang recovery and init both go through this loop.
- Maintainer-authored, reviewed by listed reviewer.
- Code and prerequisites exist in this tree; bug dates to 2015.

AGAINST:
- No user report, repro, sanitizer hit, or described crash.
- Not a kernel oops/UAF/deadlock; GPU-side hang/recovery.
- CLOCK_CONTROL IDLE_2D/IDLE_3D already checked afterward.
- Patch 1/2 of hardening, not a smoking-gun “Fixes:”.

UNRESOLVED:
- No public report of a hang caused specifically by FE-idle / other- module-busy.
- lore.kernel.org HTTP 403; discussion taken from b4 dig mbox only.

**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** — predicate matches wait_idle; reviewed.
2. Real bug affecting users? **PASS** — false reset success on init/hang recover.
3. Important (crash/security/corruption/deadlock/hang)? **PASS** — failed GPU reset/hang recovery; UI/GPU freeze on this hardware, not a core panic.
4. Small and contained? **PASS** — 3 lines, one function.
5. No new features/APIs? **PASS**
6. Applies to this tree? **PASS** — driver, idle_mask, and reset loop are present.

**Step 9.3: Exception category**
Record: None (not an ID/quirk/DT/build/doc exception). It is a normal small driver correctness fix.

**Step 9.4: Decision**
This tree is 7.3-rc4 and already contains the change; the evaluation is whether this tree *should* have it on technical merit. It should. The FE-only test has been wrong for as long as the driver has reset hardware. The retry loop exists because reset is not always complete on the first try; ignoring other modules lets that loop exit too early, then init or hang recovery proceeds. The fix is the same idle definition already used elsewhere, tiny, and reviewed by the subsystem.

It is not a core memory-safety crash, but it is a contained, real reset bug on a production embedded GPU path, which is in scope for stable.

Verification:
- [Phase 1] Tags: Reviewed-by Christian Gmeiner; Link msgid 20260511085148.652256-1; maintainer SOB; no Fixes/Reported-by/syzbot
- [Phase 2] Diff: 3-line condition change in etnaviv_hw_reset(); FE bit → idle_mask
- [Phase 3] Blame: FE check from a8c21a5451d83 (2015); idle_mask init 2b76f5be7c2778
- [Phase 3] git log -S 'FE is not idle' / -S idle_mask limited to etnaviv_gpu.c
- [Phase 3] Series: 1/2 this commit, 2/2 4720915ab4828 MMUv2 check; standalone
- [Phase 4] b4 dig -c 1006d1f7c03d9: lore msgid link; v1 only; dri- devel/etnaviv CC; Reviewed-by; no NAK
- [Phase 4] b4 dig -m: 4 messages (2 patches + 2 R-b); WebFetch lore 403
- [Phase 4] Stable lore search: no relevant hits
- [Phase 5] Callers: init etnaviv_hw_reset at line 891; etnaviv_gpu_recover_hang from etnaviv_sched.c:84
- [Phase 5] wait_idle uses identical mask compare at line 1709
- [Phase 6] git describe HEAD v7.3-rc4-27-gf0100363d8c37; kernelversion 7.3.0-rc4
- [Phase 6] git merge-base --is-ancestor 1006d1f7c03d9 HEAD true; not ancestor of v7.2
- [Phase 7] MAINTAINERS: Lucas Stach M:, Christian Gmeiner R:
- [Phase 8] Failure: incomplete GPU reset / failed hang recovery, not kernel UAF
- UNVERIFIED: specific user-visible hang from FE-only success; lore.kernel.org page content besides b4 mbox

**YES**

 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +3 -3
index cf0d9049bcf1e..368e799fc0c5d 100644
@@ -582,9 +582,9 @@ static int etnaviv_hw_reset(struct etnaviv_gpu *gpu)
 		/* read idle register. */
 		idle = gpu_read(gpu, VIVS_HI_IDLE_STATE);
 
-		/* try resetting again if FE is not idle */
-		if ((idle & VIVS_HI_IDLE_STATE_FE) == 0) {
-			dev_dbg(gpu->dev, "FE is not idle\n");
+		/* try resetting again if any module is not idle */
+		if ((idle & gpu->idle_mask) != gpu->idle_mask) {
+			dev_dbg(gpu->dev, "GPU modules not idle\n");
 			continue;
 		}
 
Signature · 1 line
2.53.0
author maintainer
#366 lore raw

PATCH 1/1 fs/ntfs3: fix lseek EINVAL on sparse/compressed files with 64-bit clusters

In reply to Sasha Levin

From: Senjin <[email protected]>

[ Upstream commit 789af83e41aef54c1ff1cee16adc27822e0a0d71 ]

When CONFIG_NTFS3_64BIT_CLUSTER is enabled, sbi->maxbytes_sparse is set to -1. As a signed loff_t this is -1LL, the most negative value. Any lseek on a sparse or compressed file passes this as maxsize to vfs_setpos(), which returns -EINVAL whenever offset > maxsize, and since -1LL is less than any non-negative offset, every seek fails, including lseek(fd, 0, SEEK_SET).

The intent of -1 here appears to be "no limit" (matching the spirit of MAX_LFS_FILESIZE assigned to sbi->maxbytes and sb->s_maxbytes in the same block), but the signed type makes it the minimum instead of the maximum.

Fix by assigning MAX_LFS_FILESIZE to sbi->maxbytes_sparse in the 64-bit cluster path, consistent with the other two limits set there.

Observed on a 16 TB NTFS volume with 0xFFFFFEFF total clusters compiled with CONFIG_NTFS3_64BIT_CLUSTER=y. Sequential reads via dd/cp worked correctly; any lseek call on sparse files returned EINVAL, preventing archive managers and other tools from random-accessing files on the volume. The non-64-bit-cluster path correctly sets maxbytes_sparse to (1ull << (cluster_bits + 32)) - 1, a large positive value.

---

LLM Generated explanations, may be completely bogus:

This is a one-line NTFS3 correctness fix: with 64-bit clusters, sparse/compressed lseek was passing a signed -1 limit into vfs_setpos(), so every nonnegative seek returned -EINVAL. The local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37); the path and the bug both exist here.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**
Record: [fs/ntfs3] [fix] [lseek returns EINVAL on sparse/compressed files when CONFIG_NTFS3_64BIT_CLUSTER is set]

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Senjin <[email protected]> (author)
- Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon- software.com> (NTFS3 maintainer; listed in MAINTAINERS)
- 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:** With CONFIG_NTFS3_64BIT_CLUSTER, sbi->maxbytes_sparse is set to -1. Used as signed loff_t, that is -1LL. ntfs_llseek() passes it to vfs_setpos() / generic_file_llseek_size(), which rejects any offset > maxsize.
- **Symptom:** Every lseek on sparse/compressed files fails with EINVAL, including lseek(fd, 0, SEEK_SET). Sequential dd/cp still work. Archive managers cannot random-access those files.
- **Trigger:** Observed on a 16 TB NTFS volume (0xFFFFFEFF clusters) with CONFIG_NTFS3_64BIT_CLUSTER=y.
- **Root cause:** -1 was meant as “no limit” (same idea as MAX_LFS_FILESIZE for sb->s_maxbytes), but as a signed max it is the minimum, not the maximum.
- **Fix:** Assign MAX_LFS_FILESIZE instead, matching sb->s_maxbytes in the same #ifdef.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: [Not hidden] — subject and body describe a real, reproduced functional bug.

---

## PHASE 2: DIFF ANALYSIS - LINE BY LINE

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: fs/ntfs3/super.c — 1 insertion, 1 deletion
- Function: ntfs_init_from_boot()
- Scope: single-file surgical one-liner

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE** Record:
- **Before:** #ifdef CONFIG_NTFS3_64BIT_CLUSTER always does sbi->maxbytes_sparse = -1.
- **After:** sbi->maxbytes_sparse = MAX_LFS_FILESIZE.
- Path: superblock init at mount. Affects every later ntfs_get_maxbytes() use for sparse/compressed inodes.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: [Logic / type-signedness]

Verified types and call path:
- maxbytes_sparse is u64 (fs/ntfs3/ntfs_fs.h). Assigning -1 stores U64_MAX.
- ntfs_get_maxbytes() returns that as loff_t. U64_MAX → -1LL.
- ntfs_llseek() (fs/ntfs3/file.c) passes that to generic_file_llseek_size() / vfs_setpos().
- vfs_setpos_cookie() (fs/read_write.c) does if (offset > maxsize) return -EINVAL. For offset == 0 and maxsize == -1, 0 > -1 is true.

Same conversion also breaks ntfs_iomap_begin()’s IOMAP_REPORT check (offset > ntfs_get_maxbytes(ni)), so fiemap/bmap on those files can fail the same way.

The #else path already uses a large positive (1ull << (cluster_bits + 32)) - 1.

**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: MAX_LFS_FILESIZE is LLONG_MAX on 64-bit (include/linux/fs.h); this config is 64-bit-only (#error on 32-bit). Same constant is already assigned to sb->s_maxbytes in this block.
- Minimal: one assignment change, no API/struct change.
- Regression risk: very low. Limit goes from “every seek fails” to the VFS max file size. ntfs_set_size() / attrib insert compare against u64; LLONG_MAX is still a huge positive cap and matches VFS, vs the old U64_MAX which was accidentally unlimited on those u64 checks.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Buggy assignment introduced in 82cae269cfa95 (“fs/ntfs3: Add initialization of super block”, 2021-08-13), first in **v5.15-rc1**.
- Field has been u64 maxbytes_sparse since the original headers (4534a70b7056f).
- User-visible lseek breakage requires ntfs_llseek() using ntfs_get_maxbytes(), added in c613269677283 (“implement llseek SEEK_DATA/SEEK_HOLE…”), contained in **v7.0-rc1**. Before that, .llseek = generic_file_llseek used sb->s_maxbytes (MAX_LFS_FILESIZE in this config), so SEEK_SET worked.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: [N/A — no Fixes: tag]. Effective buggy commit for the reported symptom is c613269677283 (in this tree). The -1 store itself is from 82cae269cfa95 (also in this tree).

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Candidate: 789af83e41aef (2026-06-13 / committed 2026-07-24).
- Merged to Linus in dc83d18cdd904 (ntfs3_for_7.3, 2026-08-20); present in **v7.3-rc1**. **Not** in v7.2 / v7.1 / v7.0.
- Series sibling (v2 1/2): e31886cb6e0e1 (ATTR_BITMAP extents) is the git parent but touches fs/ntfs3/inode.c only. Independent of this hunk.
- No other maxbytes_sparse fix in this tree.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Senjin has this plus the ATTR_BITMAP mount fix on the same 16 TB volume. Konstantin Komarov is the NTFS3 maintainer (MAINTAINERS:
Supported) and committed both.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Standalone. Needs only CONFIG_NTFS3_64BIT_CLUSTER and MAX_LFS_FILESIZE, both present since ntfs3 was added. Does not need patch 1/2.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 789af83e41aef: [PATCH v2 2/2],
https://patch.msgid.link/[email protected]
- b4 dig -a: v1 was only the ATTR_BITMAP patch (2026-06-10); v2 added this as 2/2 (2026-06-13). Applied version is v2.
- lore.kernel.org / patch.msgid.link returned **403**; spinics ntfs3 thread returned **500**. Patch text confirmed via LKML IU and Openwall mirrors. Full reply thread: **UNVERIFIED**.

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): [email protected], [email protected], [email protected], linux- [email protected]. Maintainer list was CCed; maintainer signed off and merged. No NAK found in reachable archives.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla link. Author reports a real 16 TB volume; sequential I/O worked, lseek did not. Same volume as the ATTR_BITMAP mount failure.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: v2 1/2 is a different mount bug (inode.c). This 2/2 is self- contained. Linus’s ntfs3_for_7.3 pull lists “lseek EINVAL on sparse/compressed files with 64-bit clusters” under Fixed.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search did not turn up this subject (403/unrelated hits). **UNVERIFIED** whether anyone already requested/rejected it for stable.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: ntfs_init_from_boot() (assignment). Consumers:
ntfs_get_maxbytes() → ntfs_llseek(), ntfs_iomap_begin(); also raw sbi->maxbytes_sparse in ntfs_set_size() and attrib insert.

**Step 5.2: TRACE CALLERS**
Record:
- ntfs_init_from_boot() — mount/fill_super.
- ntfs_llseek — file_operations.llseek for regular ntfs3 files (syscall lseek/llseek).
- ntfs_iomap_begin — fiemap/bmap IOMAP_REPORT.
- Directory llseek still uses generic_file_llseek (dir.c); not this bug.

**Step 5.3: TRACE CALLEES**
Record: The changed line is an assignment. Downstream: vfs_setpos() / generic_file_llseek_size().

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace lseek → ntfs_llseek → ntfs_get_maxbytes → vfs_setpos. Reachable from unprivileged processes with a file open. Confirmed in-tree.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: sbi->maxbytes = -1 remains in the overflow branch (`clusters

Quoted 1 line

= 1ull << (64 - cluster_bits)`). Same signedness issue for *non-sparse*

files, but that volume size is far beyond the reported 16 TB / 0xFFFFFEFF clusters. Out of this patch’s scope.

---

## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. fs/ntfs3/super.c, ntfs_llseek, CONFIG_NTFS3_64BIT_CLUSTER, and ntfs_get_maxbytes() are all present. Current line is already the fixed assignment (sbi->maxbytes_sparse = MAX_LFS_FILESIZE at line 1214). Pre-fix -1 is in 789af83e41aef^. Bug introduction for lseek: v7.0; this checkout is 7.3-rc4.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply. Surrounding #ifdef CONFIG_NTFS3_64BIT_CLUSTER / sb->s_maxbytes = MAX_LFS_FILESIZE matches the hunk. No conflicting refactor in this function.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This commit *is* the fix (789af83e41aef is an ancestor of HEAD). No earlier substitute fix. That is origin-tree presence, not a reason to reject on merit.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: [fs/ntfs3] [IMPORTANT] — not core VFS, but a supported RW filesystem used for Windows/large volumes. Maintainer-supported.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained (regular ntfs3_for_* pulls, many 7.3 fixes). This is not staging.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Config-specific (CONFIG_NTFS3_64BIT_CLUSTER=y, 64-bit, recommended N in Kconfig) **and** sparse or compressed files. That option exists specifically for 16T+ volumes with 4K clusters (Windows ntfs.sys is 32-bit cluster). Real users of large NTFS volumes.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Any lseek (SEEK_SET/SEEK_END/nonzero SEEK_CUR) on a sparse/compressed file after mount. Common for archive tools, not rare error-path. Unprivileged if the user can open the file. Not a race.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: [Failure: all random access via lseek fails with EINVAL; sequential read still works] [Severity: HIGH]. Not a panic/UAF, but the filesystem is unusable for a normal class of tools. Also breaks fiemap/bmap IOMAP_REPORT on those inodes.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record: Benefit high for affected mounts (restores lseek). Risk very low (1 line, same constant already used for s_maxbytes). Ratio strongly favors backport.

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

**FOR:**
- Real user-visible bug on a 16 TB volume; lseek always EINVAL on sparse/compressed files.
- Mechanism verified in this tree (vfs_setpos offset > maxsize, signed -1).
- One-line, obviously correct, matches existing MAX_LFS_FILESIZE usage.
- Maintainer signed off and merged.
- Standalone; no new API/feature.
- Call path is a normal syscall.

**AGAINST:**
- Option defaults to N; smaller population.
- Not a crash/UAF/corruption.
- Series labeled 2/2 (sibling is unrelated and not required).
- Full lore review thread not readable (403/500).

**UNRESOLVED:** Full reviewer comments; any stable@ discussion.

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — type/vfs_setpos logic is clear; author observed it on real hardware; maintainer merged.
2. Fixes a real bug that affects users? **PASS** — reproduced; tools cannot seek.
3. Important issue? **PASS** — HIGH: filesystem random-access completely broken for sparse/compressed files on this config (not a panic, but a serious functional failure).
4. Small and contained? **PASS** — 1 line, one file, one assignment.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — hunk matches ntfs_init_from_boot() here.

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: [None] — ordinary bugfix, not a device-ID/quirk/DT/build/doc exception.

**Step 9.4: MAKE YOUR DECISION**
This tree has the ntfs3 64-bit-cluster init path and ntfs_llseek()/ntfs_get_maxbytes(). The signed -1 max makes every sparse/compressed seek fail. Replacing it with MAX_LFS_FILESIZE is the right, minimal fix and meets stable rules.

---

### What the commit solves and why it matters here
On CONFIG_NTFS3_64BIT_CLUSTER=y, sparse/compressed files cannot be seeked at all. That breaks archive managers and any random-access reader while sequential copy still works. This checkout is 7.3, which already has the 7.0 ntfs_llseek path, so the bug is in this codebase.

### Stable rules
Small, correct, user-reported functional failure, no new API, applies cleanly.

### Risk vs benefit
Very low risk, high benefit for large NTFS volumes built with 64-bit clusters.

### Concerns
Kconfig recommends N, so not every ntfs3 user. Patch 1/2 is not a dependency. Residual sbi->maxbytes = -1 overflow branch is a separate edge case.

---

Verification:
- [Phase 1] Parsed commit 789af83e41aef: SOB Senjin + maintainer Komarov; no Fixes/Cc stable/Reported-by
- [Phase 2] Diff: sbi->maxbytes_sparse = -1 → MAX_LFS_FILESIZE in ntfs_init_from_boot(); 1 line
- [Phase 2] Confirmed maxbytes_sparse is u64; ntfs_get_maxbytes() returns loff_t; vfs_setpos_cookie() rejects offset > maxsize
- [Phase 2] Confirmed ntfs_llseek() and ntfs_iomap_begin() consume that value
- [Phase 3] git blame: -1 from 82cae269cfa95 (v5.15-rc1); ntfs_llseek from c613269677283 (v7.0-rc1)
- [Phase 3] git merge-base --is-ancestor 789af83e41aef HEAD: yes; in v7.3-rc1; not in v7.2/v7.1/v7.0
- [Phase 3] Series 1/2 e31886cb6e0e1 touches inode.c only; not required
- [Phase 4] b4 dig -c/-a/-w: v2 2/2, maintainer+ntfs3 list CCed; lore fetch 403
- [Phase 4] LKML IU / Openwall: patch text matches; no NAK in those copies
- [Phase 4] UNVERIFIED: full lore thread, stable@ discussion
- [Phase 5] Callers: ntfs_llseek (syscall), ntfs_iomap_begin (fiemap)
- [Phase 6] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion: 7.3.0-rc4; current super.c:1214 already has the fix
- [Phase 6] CONFIG_NTFS3_64BIT_CLUSTER in fs/ntfs3/Kconfig, 64-bit only
- [Phase 7] MAINTAINERS: Konstantin Komarov, Supported
- [Phase 8] Failure: every sparse/compressed lseek → -EINVAL; severity HIGH; trigger is normal userspace seek

**YES**

 fs/ntfs3/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/super.c +1 -1
index 346c52f952076..dcf14410c6621 100644
@@ -1163,7 +1163,7 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
 #ifdef CONFIG_NTFS3_64BIT_CLUSTER
 	if (clusters >= (1ull << (64 - cluster_bits)))
 		sbi->maxbytes = -1;
-	sbi->maxbytes_sparse = -1;
+	sbi->maxbytes_sparse = MAX_LFS_FILESIZE;
 	sb->s_maxbytes = MAX_LFS_FILESIZE;
 #else
 	/* Maximum size for sparse file. */
Signature · 1 line
2.53.0
author maintainer
#367 lore raw

PATCH 1/1 md: skip bitmap accounting for empty write ranges

In reply to Sasha Levin

From: Yu Kuai <[email protected]>

[ Upstream commit 87c10252e3d6c28769d93bea9e6a9b592e5809d1 ]

mkfs.ext4 can submit zero-sector flush/FUA bios. These bios are WRITE bios for md_write_start() purposes, but they do not cover any data sector and must not dirty bitmap bits.

md bitmap accounting currently passes such bios to bitmap start_write(). For llbitmap this reaches llbitmap_start_write() with sectors == 0, which underflows the end chunk calculation.

Personality bitmap mapping can also turn a non-empty bio into an empty bitmap range when the requested sectors are outside the active bitmap geometry. Treat both cases as not started, so the completion path will not call end_write() for an empty range.

---

LLM Generated explanations, may be completely bogus:

The local tree is **6.18.53** (p-6.18). The empty-range skip is missing, and the llbitmap underflow path is present. Full analysis follows.

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

**Step 1.1: PARSE THE SUBJECT LINE**

Record: **[md] [skip] skip bitmap accounting for empty write ranges**
- Subsystem: md (MD RAID core)
- Action verb: **skip** (prevent incorrect handling)
- Intent: do not run bitmap start/end accounting when the write covers no data sectors

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**

Record:
- Tested-by: Mykola Marzhan <[email protected]> — independent hardware/user verification
- `Link:
https://patch.msgid.link/[email protected] — v5 series, patch 10/29 (msgid -11` is 1-based with cover)
- Signed-off-by: Yu Kuai <[email protected]> — author (MD contributor; ignore pipeline SoBs)
- No Fixes: tag (expected)
- No Cc: stable (expected)
- No Reported-by: / syzbot
- No Reviewed-by: on this revision (v1 had Reviewed-by from Su Yue on earlier series patches)

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**

Record:
- **Bug:** mkfs.ext4 can submit zero-sector flush/FUA bios. They are WRITE bios for md_write_start(), but they cover no data and must not dirty bitmap bits. They are still passed to bitmap start_write().
- **llbitmap failure mode:** llbitmap_start_write() with sectors == 0 underflows the end-chunk calculation (offset + sectors - 1).
- **Second case:** personality bitmap_sector() can map a non-empty bio to an empty bitmap range (outside active geometry). Completion must not call end_write() for a start that never ran / was empty.
- **Symptom:** bitmap accounting of a zero-length range → unsigned wrap in llbitmap, then a huge page/chunk walk (barriers + state machine), i.e. hang, bitmap corruption, or crash.
- **Version info:** none in the message; code is the post-6.14 upper- layer bitmap path + llbitmap (2025).

**Step 1.4: DETECT HIDDEN BUG FIXES**

Record: **Not hidden.** It is an explicit correctness fix: skip empty ranges so start/end stay balanced and llbitmap does not underflow.

===============================================================
PHASE 2: DIFF ANALYSIS
===============================================================

**Step 2.1: INVENTORY THE CHANGES**

Record:
- File: drivers/md/md.c only (~+7 / −2, four tight edits)
- Functions: md_bitmap_start(), md_end_clone_io(), md_clone_bio()
- Scope: **single-file surgical fix**

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**

Record:
1. **md_bitmap_start:** after optional bitmap_sector() remap, **return if sectors == 0** instead of calling start_write/start_discard.
2. **md_end_clone_io:** call md_bitmap_end() only if md_io_clone->sectors != 0 (paired with start).
3. **md_clone_bio:** set md_io_clone->sectors = 0 (mempool reuse). Skip the start path unless bio_sectors(*bio) != 0.
4. **Affected paths:** WRITE clone accounting (md_account_bio → md_clone_bio), including 0-sector flush/FUA and post-map empty ranges. Not a refactor of the hot data path.

**Step 2.3: IDENTIFY THE BUG MECHANISM**

Record:
- **Category:** logic / integer underflow (unsigned wrap) + start/end accounting mismatch
- **Mechanism:** llbitmap_start_write() does
end = (offset + sectors - 1) >> chunkshift.
sectors == 0 underflows. If offset == 0, end becomes a huge chunk index; the page_start <= page_end loop and llbitmap_state_machine() then walk a massive range.
- Legacy bitmap_start_write() uses while (sectors) and is a no-op for 0; the crash is **llbitmap-specific**, but the skip is correct for both backends.
- The sectors = 0 init is required: after skipping the start if, completion must not see a stale mempool sectors value.

**Step 2.4: ASSESS THE FIX QUALITY**

Record:
- **Obviously correct:** empty range → don’t start, don’t end, init sectors to 0.
- **Minimal:** four related edits, no API change.
- **Regression risk: low.** Worst case is skipping bitmap bits for a 0-sector I/O (correct). Start/end stay balanced.
- **Local extra path:** this tree’s md_free_cloned_bio() also calls md_bitmap_end() without a sectors check (raid5 reshape-wait abort). A faithful backport should add the same guard there. That is a small extra hunk, not a reason to reject.

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

**Step 3.1: BLAME THE CHANGED LINES**

Record:
- md_bitmap_start / clone accounting introduced by cd5fc65338181 (“md/md-bitmap: move bitmap_{start, end}write to md upper layer”, 2025-01-09) — **is an ancestor of this HEAD**.
- Discard ops wiring: ac9dad8faaa7b.
- else md_io_clone->start_time = 0 already here from d81822fd5fa81 (“md: avoid stale clone I/O accounting timestamps”).
- llbitmap: 5ab829f1971dc (“md/md-llbitmap: introduce new lockless bitmap”, 2025-09-06) — **present**.
- Bug is in **this** 6.18 tree, not only in later mainline.

**Step 3.2: FOLLOW THE FIXES: TAG**

Record: **No Fixes: tag.** Introducers are cd5fc65338181 (upper-layer accounting of all WRITE bios, including 0-sector) and 5ab829f1971dc (llbitmap underflow). Both are in this tree (git merge-base --is- ancestor exit 0 for cd5fc65338181).

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**

Record: recent drivers/md/md.c on this branch includes:
- 73881ff7a7591 md: wait for behind writes before destroying bitmap (v5 patch 6)
- d81822fd5fa81 md: avoid stale clone I/O accounting timestamps (v5 patch 7)

Same series already on this tree:
- 930cc4f1af5a1 md/md-llbitmap: prevent create failure bitmap UAF (patch 8)
- c55aa6c17f019 md/md-llbitmap: stop daemon timer rearm on destroy (patch 9)

This commit is **v5 10/29**, the next accounting fix. Standalone vs later reshape patches (11+). **No missing prerequisite** among 6–9 for this hunk.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**

Record: Yu Kuai is a primary MD/llbitmap author on this tree (bitmap move, llbitmap, this series). Weight: high.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**

Record: Needs md_bitmap_start / md_io_clone / bitmap_ops->start_write — all present. Does **not** need patch 12 (prepare_range / exact mapping); v5 commit text was updated to bitmap_sector so it stands alone. **Can apply standalone** with small context tweaks.

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**

Record:
- Lore msgid [email protected] (v5 10/29).
- Cover: [PATCH v5 00/29] md: improve lockless bitmap reshape support
https://lists.openwall.net/linux-kernel/2026/08/02/769
- Earlier: v1 2026-06-05, v2, v4 07/25, v5 10/29.
- Cover: patches 6–11 are “md core and llbitmap lifetime/accounting prerequisites”; this one is “empty bitmap ranges”.
- v5 note: “Fix patch 10 to keep empty-range handling valid before the exact mapping hook is introduced.”
- **No NAK** in the fetched cover/patch bodies.
- b4 mbox/b4 dig -c did not resolve without a mainline SHA (local master is older than this series). Thread recovered via gnuweeb/IU/openwall.

**Step 4.2: CHECK WHO REVIEWED THE PATCH**

Record: To/Cc Song Liu, Li Nan, Xiao Ni; lists linux-raid, linux-kernel. Tested-by Mykola Marzhan (v4, carried to v5). Su Yue Reviewed-by on v1 series (not re-stated on this hunk in v5).

**Step 4.3: SEARCH FOR THE BUG REPORT**

Record: No syzbot/bugzilla. Trigger described as **mkfs.ext4 zero-sector flush/FUA** — common userspace. Tested-by supports real-world impact. **UNVERIFIED:** did not reproduce mkfs.ext4 on this kernel.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**

Record: Independent of reshape (11+). Empty-range skip is valid before prepare_range. Same-series 6–9 already in this tree.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**

Record: gnuweeb /stable/?q=skip+bitmap+accounting... returned unrelated stable-rc noise, **no dedicated stable thread**. Not a negative signal.

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

**Step 5.1: KEY FUNCTIONS**

Record: md_bitmap_start, md_bitmap_end (unchanged body, callers gated), md_end_clone_io, md_clone_bio. Callee of interest:
llbitmap_start_write / bitmap_start_write. Local extra:
md_free_cloned_bio.

**Step 5.2: TRACE CALLERS**

Record:
- md_clone_bio ← md_account_bio
- md_account_bio ← raid0, raid1, raid10, raid5, md-linear make_request
- md_end_clone_io = clone bi_end_io
- md_free_cloned_bio ← raid5 STRIPE_WAIT_RESHAPE abort
- Context: block submit from userspace (mkfs, etc.), not init-only

**Step 5.3: TRACE CALLEES**

Record: md_bitmap_start → pers->bitmap_sector (raid5) → bitmap_ops->start_write (llbitmap_start_write or bitmap_start_write). llbitmap: unsigned end chunk, per-page barriers, llbitmap_state_machine(..., BitmapActionStartwrite).

**Step 5.4: FOLLOW THE CALL CHAIN**

Record: **Userspace-reachable.** raid1/raid5 still send PREFLUSH empty bios to md_flush_request(), which completes bio_sectors == 0 without accounting. FUA-only 0-sector WRITEs, or PREFLUSH that falls through (-EAGAIN journal fallback in raid5), hit md_account_bio. raid0/linear call md_account_bio on the I/O path. Confirmed in-tree:
raid5_make_request calls md_account_bio at line 6182 after flush handling.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**

Record: llbitmap_end_write / llbitmap_start_discard use the same offset + sectors - 1 pattern. This patch avoids calling them with 0. Legacy bitmap is safe via while (sectors). No duplicate core skip already present (rg found no if (!md_io_clone->sectors)).

===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**

Record: **Yes.**
- Tree: git describe HEAD → p-6.18-1-g03b85e06ca9bf; make kernelversion → **6.18.53**
- md_bitmap_start() at drivers/md/md.c:9261 calls fn() with no empty-range check
- md_clone_bio() at 9319 starts bitmap on every WRITE if bitmap enabled, including bio_sectors == 0
- llbitmap_start_write() at md-llbitmap.c:1074 does offset + sectors - 1
- raid5_bitmap_sector() can set *sectors = end - start to 0 when the mapped range is empty

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**

Record: **Minor conflicts / small extra hunk.**
- Local md_end_clone_io uses bio->bi_private as md_io_clone*; candidate uses container_of + reshape completion. The sectors && condition still matches.
- Local already has else start_time = 0 (patch 7).
- Add the same md_io_clone->sectors && guard to md_free_cloned_bio() (6.18-only helper).

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**

Record: Empty-range skip **not** present. Series patches 6–9 **are** present. No alternate fix for this underflow.

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

**Step 7.1: SUBSYSTEM AND CRITICALITY**

Record: **md (MD RAID bitmap accounting).** **IMPORTANT** — not core mm/vfs, but RAID+bitmap is widely used; mkfs on an MD device is a normal path. llbitmap is the lockless bitmap backend in 6.18.

**Step 7.2: SUBSYSTEM ACTIVITY**

Record: **Active** on this branch (llbitmap, clone accounting, this Yu Kuai series). Still a real bug in shipping 6.18 code, not a speculative cleanup.

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

**Step 8.1: WHO IS AFFECTED**

Record: **MD users with a bitmap enabled**, especially **llbitmap**. Triggered by 0-sector WRITE/flush/FUA (mkfs.ext4) or raid5 bitmap_sector mapping a request to an empty range. Config: CONFIG_MD
+ bitmap (llbitmap or classic).

**Step 8.2: TRIGGER CONDITIONS**

Record:
- Common: mkfs.ext4 / empty flush+FUA on an MD array with bitmap
- Also: raid5 geometry mapping to a zero bitmap range
- Unprivileged user with write access to the array (typical admin/mkfs)
- Not a narrow race; it is size==0 handling

**Step 8.3: FAILURE MODE SEVERITY**

Record:
- llbitmap: unsigned wrap → enormous chunk/page walk, barriers, state machine on invalid range → **hang, bitmap corruption, possible crash**
- Classic bitmap: while (sectors) no-op, but start/end still run with 0; skip is still correct
- Severity: **HIGH** (hang/corruption on a common mkfs path with llbitmap)

**Step 8.4: RISK-BENEFIT RATIO**

Record:
- **Benefit: high** — stops underflow/wrong bitmap updates on a real I/O pattern
- **Risk: very low** — ~7–10 lines, local to clone accounting, start/end remain paired
- **Ratio: strongly favors backport**

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

**Step 9.1: COMPILE THE EVIDENCE**

**FOR:**
- Real bug: 0-sector WRITE accounting into llbitmap underflow
- Common trigger (mkfs.ext4 flush/FUA), Tested-by
- Buggy path exists in this 6.18.53 tree (md_bitmap_start, llbitmap)
- Small, obviously correct, no new API
- Series patches 6–9 already here; this is the matching empty-range fix
- MD RAID data-integrity relevant

**AGAINST:**
- Part of a larger reshape series (but this hunk is standalone)
- md_free_cloned_bio needs the same sectors guard (small extra hunk)
- Context differs slightly (bi_private vs container_of)

**UNRESOLVED:**
- Did not run mkfs.ext4 against this build
- b4 dig -c had no mainline SHA in this clone; thread confirmed via other archives
- gnuweeb stable search was noisy, no dedicated nomination thread

**Step 9.2: STABLE RULES CHECKLIST**

1. Obviously correct and tested? **PASS** — paired start/end skip + Tested-by
2. Real bug affecting users? **PASS** — mkfs.ext4 0-sector WRITE + llbitmap wrap
3. Important (crash/corruption/hang)? **PASS** — HIGH (underflow walk / bitmap corruption)
4. Small and contained? **PASS** — one file, ~9 lines
5. No new features/APIs? **PASS**
6. Can apply to the local tree? **PASS** — logic matches; minor extra hunk on md_free_cloned_bio

**Step 9.3: EXCEPTION CATEGORIES**

Record: Not an exception category. Ordinary important bug fix.

**Step 9.4: DECISION**

This tree already moved bitmap accounting into md_clone_bio and has llbitmap. Empty WRITEs still call start_write(sectors == 0), which underflows llbitmap. The patch is the right, small fix and belongs on 6.18.y.

Verification:
- [Phase 1] Tags: Tested-by Mykola Marzhan; Link msgid 20260802195038.164272-11 (v5 10/29); author Yu Kuai; no Fixes/Cc- stable
- [Phase 2] Diff: md.c only; skip empty start; gate end on sectors; init sectors = 0; require bio_sectors before start
- [Phase 2] Confirmed llbitmap_start_write uses offset + sectors - 1 at md-llbitmap.c:1079
- [Phase 3] git merge-base --is-ancestor cd5fc65338181 HEAD → 0 (upper-layer bitmap in tree)
- [Phase 3] llbitmap file present; intro 5ab829f1971dc in history
- [Phase 3] Series 6–9 already on this branch (73881ff7, d81822fd, 930cc4f1, c55aa6c1)
- [Phase 3] No skip bitmap accounting commit in local git log -- drivers/md/
- [Phase 4] Cover letter: empty bitmap ranges as accounting prerequisite; v5 rebased so patch 10 does not need prepare_range
- [Phase 4] lore.kernel.org 403; recovered via gnuweeb + openwall + IU
- [Phase 4] No NAK in fetched cover/patch
- [Phase 5] Callers: raid0/1/5/10/linear md_account_bio; userspace block I/O
- [Phase 5] Legacy bitmap_start_write is while (sectors) — llbitmap is the underflow
- [Phase 6] git describe HEAD = p-6.18-1-g03b85e06ca9bf; make kernelversion = 6.18.53
- [Phase 6] Current md_bitmap_start has no empty return; md_clone_bio has no bio_sectors guard
- [Phase 6] Backport: add same sectors check to md_free_cloned_bio (raid5 reshape abort)
- [Phase 8] Failure: unsigned wrap → huge llbitmap walk; severity HIGH
- UNVERIFIED: live mkfs.ext4 reproduction; b4 dig match by commit SHA

**YES**

 drivers/md/md.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/md/md.c +7 -2
index 03d328506b285..ce3bd127e3bb3 100644
@@ -9266,6 +9266,8 @@ static void md_bitmap_start(struct mddev *mddev,
 		mddev->pers->bitmap_sector(mddev, &md_io_clone->offset,
 					   &md_io_clone->sectors);
 
+	if (!md_io_clone->sectors)
+		return;
 	fn(mddev, md_io_clone->offset, md_io_clone->sectors);
 }
 
@@ -9284,7 +9286,8 @@ static void md_end_clone_io(struct bio *bio)
 	struct bio *orig_bio = md_io_clone->orig_bio;
 	struct mddev *mddev = md_io_clone->mddev;
 
-	if (bio_data_dir(orig_bio) == WRITE && md_bitmap_enabled(mddev, false))
+	if (bio_data_dir(orig_bio) == WRITE && md_io_clone->sectors &&
+	    md_bitmap_enabled(mddev, false))
 		md_bitmap_end(mddev, md_io_clone);
 
 	if (bio->bi_status && !orig_bio->bi_status)
@@ -9308,12 +9311,14 @@ static void md_clone_bio(struct mddev *mddev, struct bio **bio)
 	md_io_clone = container_of(clone, struct md_io_clone, bio_clone);
 	md_io_clone->orig_bio = *bio;
 	md_io_clone->mddev = mddev;
+	md_io_clone->sectors = 0;
 	if (blk_queue_io_stat(bdev->bd_disk->queue))
 		md_io_clone->start_time = bio_start_io_acct(*bio);
 	else
 		md_io_clone->start_time = 0;
 
-	if (bio_data_dir(*bio) == WRITE && md_bitmap_enabled(mddev, false)) {
+	if (bio_data_dir(*bio) == WRITE && bio_sectors(*bio) &&
+	    md_bitmap_enabled(mddev, false)) {
 		md_io_clone->offset = (*bio)->bi_iter.bi_sector;
 		md_io_clone->sectors = bio_sectors(*bio);
 		md_io_clone->rw = op_stat_group(bio_op(*bio));
Signature · 1 line
2.53.0
#368 lore raw

Re: [PATCH AUTOSEL 6.18] md: skip bitmap accounting for empty write ranges

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] md: missing sectors check in md_free_cloned_bio() before md_bitmap_end() --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] md: missing sectors check in md_free_cloned_bio() before md_bitmap_end() --

commit 6836aa7ecbc70ba01261dda2960c8f2c78bf3f55
Author: Yu Kuai <[email protected]>

md: skip bitmap accounting for empty write ranges

This commit skips md bitmap start_write() and end_write() accounting when a write bio has zero sectors or when personality bitmap mapping turns the bio into an empty bitmap range.

Quoted 29 lines
drivers/md/md.c +5 -1
index 03d328506b285..ce3bd127e3bb3 100644
@@ -9266,6 +9266,8 @@ static void md_bitmap_start(struct mddev *mddev,
 		mddev->pers->bitmap_sector(mddev, &md_io_clone->offset,
 					   &md_io_clone->sectors);
 
+	if (!md_io_clone->sectors)
+		return;
 	fn(mddev, md_io_clone->offset, md_io_clone->sectors);
 }
 
@@ -9284,7 +9286,8 @@ static void md_end_clone_io(struct bio *bio)
 	struct bio *orig_bio = md_io_clone->orig_bio;
 	struct mddev *mddev = md_io_clone->mddev;
 
-	if (bio_data_dir(orig_bio) == WRITE && md_bitmap_enabled(mddev, false))
+	if (bio_data_dir(orig_bio) == WRITE && md_io_clone->sectors &&
+	    md_bitmap_enabled(mddev, false))
 		md_bitmap_end(mddev, md_io_clone);
 
 	if (bio->bi_status && !orig_bio->bi_status)
@@ -9308,12 +9311,14 @@ static void md_clone_bio(struct mddev *mddev, struct bio **bio)
 	md_io_clone = container_of(clone, struct md_io_clone, bio_clone);
 	md_io_clone->orig_bio = *bio;
 	md_io_clone->mddev = mddev;
+	md_io_clone->sectors = 0;
 	if (blk_queue_io_stat(bdev->bd_disk->queue))

drivers/md/md.c static void md_clone_bio(struct mddev *mddev, struct bio **bio) · line 9324

Quoted 10 lines
drivers/md/md.c +2 -1
 		md_io_clone->start_time = bio_start_io_acct(*bio);
 	else
 		md_io_clone->start_time = 0;
 
-	if (bio_data_dir(*bio) == WRITE && md_bitmap_enabled(mddev, false)) {
+	if (bio_data_dir(*bio) == WRITE && bio_sectors(*bio) &&
+	    md_bitmap_enabled(mddev, false)) {
 		md_io_clone->offset = (*bio)->bi_iter.bi_sector;
 		md_io_clone->sectors = bio_sectors(*bio);
 		md_io_clone->rw = op_stat_group(bio_op(*bio));

[Severity: High]
Should md_free_cloned_bio() in drivers/md/md.c also check md_io_clone->sectors before calling md_bitmap_end(), just like md_end_clone_io() does here?

In drivers/md/md.c, md_free_cloned_bio() still has:

	if (bio_data_dir(orig_bio) == WRITE && md_bitmap_enabled(mddev, false))
		md_bitmap_end(mddev, md_io_clone);

In raid5_make_request() -> md_account_bio() -> md_clone_bio(), the bio is cloned before calling make_stripe_request(). If make_stripe_request() returns STRIPE_WAIT_RESHAPE when a reshape is interrupted, raid5_make_request() aborts the cloned bio via md_free_cloned_bio():

	if (res == STRIPE_WAIT_RESHAPE) {
		md_free_cloned_bio(bi);
		return false;
	}

With this patch, there are two cases where md_bitmap_start() is skipped with md_io_clone->sectors == 0:

1. When bio_sectors(*bio) == 0 (for example, a zero-sector REQ_OP_WRITE | REQ_FUA bio, or a zero-sector REQ_OP_WRITE | REQ_PREFLUSH bio falling through log_handle_flush_request() with -EAGAIN), md_clone_bio() sets md_io_clone->sectors = 0 and skips initializing md_io_clone->offset and md_io_clone->rw (leaving stale contents from the mddev->io_clone_set mempool) and skips calling md_bitmap_start().

2. When bio_sectors(*bio) != 0, but mddev->pers->bitmap_sector() (raid5_bitmap_sector()) maps the range to md_io_clone->sectors == 0, md_bitmap_start() returns early without calling start_write() or start_discard().

If make_stripe_request() then returns STRIPE_WAIT_RESHAPE, md_free_cloned_bio() will unconditionally call md_bitmap_end(mddev, md_io_clone) with md_io_clone->sectors == 0 (and uninitialized offset and rw in the first case). For llbitmap, llbitmap_end_write() and llbitmap_end_discard() compute:

	unsigned long end = (offset + sectors - 1) >> llbitmap->chunkshift;

When sectors == 0, if offset == 0 this underflows to ULONG_MAX and walks llbitmap->pctl[] out of bounds, or if offset > 0 it calls llbitmap_release_barrier() to drop page barrier references on pctl->active that were never raised.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author maintainer
#369 lore raw

PATCH 1/1 ext4: guard against NULL s_group_info in ext4_get_group_info

In reply to Sasha Levin

From: Junzhe Yu <[email protected]>

[ Upstream commit 8f3901fbb40745046e513226ad84e8b84492632d ]

Resend: previous attempt was rejected by vger for containing HTML.

==================================================================

ext4_mark_group_bitmap_corrupted() already treats a NULL return from ext4_get_group_info() as "nothing to do", but ext4_get_group_info() indexes s_group_info without checking whether the array exists.

During mount, fast-commit replay runs inside jbd2_journal_load() from ext4_load_and_init_journal(), which is before ext4_mb_init() allocates s_group_info. Replaying an FC UNLINK for an inode whose bitmap bit is already clear takes:

  ext4_fc_replay_unlink -> iput -> ext4_evict_inode -> ext4_free_inode -> ext4_mark_group_bitmap_corrupted -> ext4_get_group_info

and faults on the NULL s_group_info base. Userspace only mounts a dirty ext4 image; this is a supported recovery path.

Return NULL when s_group_info (or the per-block grp_info row) is unset so the existing caller check is effective during early mount.

Tested on Linux v6.6.145 KASAN: crafted FC-unlink image previously triggered KASAN null-ptr-deref / panic in ext4_get_group_info; with this patch, mount succeeds (EXT4 "bit already cleared" may still log). Also observed on v6.6.144; still present on torvalds/linux as of f5098b6bae76 (2026-07-26).

A self-contained Docker/QEMU reproducer (craft + mount + patch verify) is available on request.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit message forensics

**Step 1.1 — Subject**
Record: **[ext4] [guard / prevent] NULL s_group_info dereference in ext4_get_group_info**. “Guard against” is a bug-fix verb: add a missing safety check.

**Step 1.2 — Tags**
Record:
- Signed-off-by: Yu Junzhe <[email protected]> (author)
- `Link: https://patch.msgid.link/65c955b0-716b-4599-b925-
[email protected]`
- Signed-off-by: Theodore Ts'o <[email protected]> (ext4 maintainer applied it)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, or Cc: stable (absence is expected in this pipeline)
- Upstream SHA after maintainer application:
8f3901fbb40745046e513226ad84e8b84492632d

**Step 1.3 — Body**
Record:
- **Bug:** ext4_get_group_info() indexes s_group_info without checking that the array exists.
- **Symptom:** KASAN null-ptr-deref / panic in ext4_get_group_info while mounting a dirty ext4 image that needs fast-commit UNLINK replay.
- **Path:** ext4_fc_replay_unlink → iput → ext4_evict_inode → ext4_free_inode → ext4_mark_group_bitmap_corrupted → ext4_get_group_info
- **Root cause:** FC replay runs inside jbd2_journal_load() from ext4_load_and_init_journal(), **before** ext4_mb_init() allocates s_group_info.
- **Author testing:** KASAN on v6.6.145 (also seen on v6.6.144); still present on torvalds/linux as of f5098b6bae76 (2026-07-26). Mount succeeds with the patch.

**Step 1.4 — Hidden bug fix?**
Record: Not hidden. This is an explicit NULL-deref fix. The “already- cleared bitmap bit” path looks like a recovery edge case, but it is a real oops on a supported mount/recovery path.

## Phase 2: Diff analysis

**Step 2.1 — Inventory**
Record:
- File: fs/ext4/balloc.c only (+4 / -0)
- Function: ext4_get_group_info()
- Scope: **single-file surgical fix**

**Step 2.2 — Code flow**
Record (verified against local fs/ext4/balloc.c):

Before:

```
if (group >= s_groups_count) return NULL;
indexv/indexh = ...
grp_info = sbi_array_rcu_deref(..., s_group_info, indexv);  //
NULL[index] if array missing
return grp_info[indexh];
```

After:

```
if (group >= s_groups_count) return NULL;
if (!s_group_info) return NULL;          // new
... deref row ...
if (!grp_info) return NULL;              // new
return grp_info[indexh];
```

This is an early-mount / missing-table path, not a new feature path.

**Step 2.3 — Bug mechanism**
Record: **NULL pointer dereference (memory safety)**. sbi_array_rcu_deref() does rcu_dereference(sbi->s_group_info)[index]. sbi is kzalloc’d, so s_group_info is NULL until ext4_mb_alloc_groupinfo() / rcu_assign_pointer. The per-row check covers ext4_mb_add_groupinfo() error paths that set group_info[idx] = NULL.

**Step 2.4 — Fix quality**
Record: Obviously correct. Matches the existing contract (ext4_get_group_info() may return NULL; ext4_mark_group_bitmap_corrupted() already does if (!grp || !gdp) return;). Four unlikely() lines, no API/lock/data-structure change. Regression risk is very low: after ext4_mb_init(), s_group_info is non-NULL and these checks are no-ops. Returning NULL instead of oopsing cannot be worse for callers that already handle NULL.

## Phase 3: Git history

**Step 3.1 — Blame**
Record: Current function body in this tree is from the 6.4-era change “allow ext4_get_group_info() to fail” (this history: b4319e457d6e3; mainline 5354b2af34064, 2023-05-13) plus fa285d799d1d5 (“drop ext4_error() from ext4_get_group_info()”). Those commits taught the helper to return NULL for a bad group number and taught callers to check NULL — but they never checked the array pointer itself.

**Step 3.2 — Fixes: tag**
Record: None. Reachability comes from fast-commit replay, added in 6866d7b3f2bb4 (“ext4 / jbd2: add fast commit initialization”, tags/v5.10-rc1~59^2~7). Journal load still runs before ext4_mb_init() in this tree.

**Step 3.3 — File history**
Record: Recent fs/ext4/balloc.c commits here are unrelated (capability-check reorder, fault-injection race, kunit stubs). No prerequisite series. Standalone 1/1 patch.

**Step 3.4 — Author**
Record: Yu Junzhe is not the ext4 maintainer. Theodore Ts’o applied it by hand after noting mangled whitespace, then posted “Applied, thanks!” with commit 8f3901fbb407.

**Step 3.5 — Dependencies**
Record: None. The helper, s_group_info, FC replay, and the caller NULL check all exist in this checkout. Applies standalone.

## Phase 4: Mailing list / external

**Step 4.1 — Original discussion**
Record:
- Lore/msgid: https://patch.msgid.link/65c955b0-716b-4599-b925-
[email protected]
- Direct lore WebFetch: **403** (could not read lore HTML)
- Openwall/LKML mirrors and b4 succeeded
- b4 dig -a: **v1 only** (no v2/v3)
- Thread: author submission; tytso note about gmail whitespace (still applied); tytso “Applied, thanks!” — **no NAK**
- No reviewer Cc: stable in the thread (tytso also did not add it when committing)

**Step 4.2 — Recipients (b4 dig -w)**
Record: Junzhe Yu, Theodore Ts’o, Andreas Dilger, linux-ext4, linux- kernel. Both ext4 maintainers were on the original To/Cc.

**Step 4.3 — Bug report**
Record: No syzbot/bugzilla link. Author reports KASAN on a crafted FC- unlink image and offers a Docker/QEMU reproducer. I did not run that reproducer (UNVERIFIED empirically; the code path is verified).

**Step 4.4 — Series**
Record: Standalone [PATCH] 1/1. Related-in-time FC-replay crashes (writeback rwsem not initialized, RO mount replay) are separate bugs, not prerequisites.

**Step 4.5 — Stable list**
Record: lore.kernel.org/stable WebFetch returned **403**. No stable-list discussion found via search. No evidence it was rejected for stable.

## Phase 5: Semantic / call-chain analysis

**Step 5.1 — Functions**
Record: ext4_get_group_info() only. (No semcode MCP in this environment; used git grep + reads.)

**Step 5.2 — Callers**
Record: Many, across fs/ext4/{balloc,ialloc,mballoc,super}.c. Almost all already handle NULL (if (!grp) / if (!grinfo)), because of the 6.4 “allow to fail” work. The crashing caller is ext4_mark_group_bitmap_corrupted() in fs/ext4/super.c, which already returns on NULL.

**Step 5.3 — Callees**
Record: sbi_array_rcu_deref() → rcu_dereference(s_group_info)[indexv]. That is the NULL deref.

**Step 5.4 — Reachability**
Record: User-reachable: mount an ext4 filesystem with a journal that still has fast-commit UNLINK tags, when the inode bitmap bit is already clear. ext4_fc_init() installs j_fc_replay_callback even if fast commit is currently off, so leftover FC blocks still replay. Mount of a dirty ext4 image is a normal recovery path (crash, unclean unmount, or an untrusted image). Typically needs mount privilege, but the failure is a **kernel oops**, not a userspace error.

Verified mount order in this tree (fs/ext4/super.c):
1. ext4_load_and_init_journal() → ext4_load_journal() → jbd2_journal_load() (FC replay)
2. much later: ext4_mb_init() (allocates s_group_info)

Verified free path: ext4_free_inode() skips the group-info corruption check under EXT4_FC_REPLAY, then on !cleared still calls ext4_error + ext4_mark_group_bitmap_corrupted().

**Step 5.5 — Similar patterns**
Record: ext4_count_free_clusters() already does if (EXT4_SB(sb)->s_group_info) before calling ext4_get_group_info(). Bitmap validators skip work under EXT4_FC_REPLAY. The hole is specifically the helper used by ext4_mark_group_bitmap_corrupted().

## Phase 6: This checkout (6.12.y)

**Step 6.1 — Does the buggy code exist here?**
Record: **Yes.** Local tree is **6.12.111** (pending-6.12; git describe was p-6.12-3-g88406e77611c6 at start). ext4_get_group_info() in fs/ext4/balloc.c still has only the s_groups_count check. git merge-base --is-ancestor 8f3901fbb407 HEAD → **not an ancestor**. git grep for the new !s_group_info guard → **not present**. Fast commit and the journal-before-mballoc order **are** present.

**Step 6.2 — Backport difficulty**
Record: **Clean apply.** Local function text matches the upstream hunk context exactly. Confirmed by reading the function and by comparing to git show 8f3901fbb407.

**Step 6.3 — Related fixes already here?**
Record: The “allow to fail” / drop-ext4_error work is here (b4319e457d6e3, fa285d799d1d5). That is why the caller already treats NULL as success-noop — and why this four-line guard is sufficient. No alternate fix for this crash is in the tree. origin/master has 8f3901fbb407 as the latest balloc.c change; no follow-up revert/amend on that function.

## Phase 7: Subsystem context

**Step 7.1**
Record: **ext4 (fs/ext4). Criticality: IMPORTANT** (default Linux filesystem; not quite mm/VFS core, but production-critical).

**Step 7.2**
Record: Actively maintained (tytso/Dilger, linux-ext4). The hole is old (FC since 5.10 + helper NULL contract since 6.4), not a brand-new subsystem.

## Phase 8: Impact and risk

**Step 8.1 — Who is affected**
Record: Anyone mounting an ext4 filesystem that still has fast-commit journal data to replay (crash recovery, or a crafted/dirty image). That is a large, real population — not an obscure driver.

**Step 8.2 — Trigger**
Record: Mount-time FC UNLINK replay when the inode bitmap bit is already clear. Not every boot, but a **supported recovery path**. Unprivileged users cannot usually mount; a user who can mount a malicious ext4 image (containers, loop, removable media with automount) can panic the kernel.

**Step 8.3 — Failure mode**
Record: **NULL deref → KASAN report / oops / panic during mount.**
Severity: **CRITICAL** (host crash while recovering a dirty filesystem).

**Step 8.4 — Risk/benefit**
Record: **Benefit: high** (prevents oops on ext4 recovery). **Risk: very low** (4 lines, existing NULL contract, hot path unchanged after ext4_mb_init()). Ratio strongly favors backport.

Note: ext4_error("bit already cleared...") can still log or remount-ro depending on errors=; the author states mount succeeds with this patch. That ext4_error is pre-existing, not introduced here.

## Phase 9: Synthesis

**Step 9.1 — Evidence**

FOR:
- Real NULL deref on a supported ext4 mount/recovery path
- KASAN-confirmed; author tested the patch
- Call path and journal-before-mb_init order verified in **this** 6.12 tree
- 4-line, obviously correct guard; callers already handle NULL
- Ext4 maintainer applied it upstream (8f3901fbb407); it is on origin/master
- No dependencies; applies cleanly
- Ext4 is widely used; FC exists since 5.10

AGAINST:
- No Fixes: / Cc: stable (expected; not a negative)
- Trigger is an FC replay edge (already-cleared bit), not every mount
- I did not run the author’s QEMU reproducer
- tytso did not nominate stable in the apply mail

UNRESOLVED:
- Empirical reproducer not run here
- lore.kernel.org HTML and stable-list search returned HTTP 403 (thread recovered via b4/openwall)

**Step 9.2 — Stable rules**
1. Obviously correct and tested? **PASS** (KASAN + maintainer apply; logic matches existing NULL contract)
2. Real bug affecting users? **PASS** (oops on dirty-ext4 mount / FC replay)
3. Important (crash/security/corruption/deadlock)? **PASS** — kernel oops/panic, severity CRITICAL
4. Small and contained? **PASS** — +4 lines, one function
5. No new features/APIs? **PASS**
6. Can apply to this tree? **PASS** — buggy code present, clean context

**Step 9.3 — Exceptions**
Record: Not an ID/quirk/DT/docs exception. It is a normal crash fix.

**Step 9.4 — Decision**
This tree is 6.12.y. The bug exists here; the fix is a four-line NULL guard with no prerequisites. It should be backported.

---

### What this solves for stable users

Mounting a dirty ext4 filesystem with leftover fast-commit UNLINK records can take ext4_free_inode() → ext4_mark_group_bitmap_corrupted() **before** mballoc has allocated s_group_info. The helper then does NULL[index] and oopses. The patch makes the helper return NULL so the existing caller check is a no-op and mount/recovery can continue.

### Risk vs benefit

Benefit is a real mount-time crash fix on the default Linux filesystem. Risk is a pair of unlikely() NULL returns in a helper that is already allowed to fail. After ext4_mb_init(), behavior is unchanged.

### Concerns

None that block backport. No missing commits, no API change, no follow- up on origin/master that reworks this function.

---

Verification:
- [Phase 1] Parsed subject/tags/body from the candidate message and from git show 8f3901fbb407
- [Phase 1] Confirmed no Fixes/Cc:stable; maintainer SOB present
- [Phase 2] Diff is +4 lines in ext4_get_group_info(); local function matches the hunk
- [Phase 2] sbi_array_rcu_deref indexes s_group_info without a NULL check (fs/ext4/ext4.h)
- [Phase 2] ext4_mark_group_bitmap_corrupted() already returns if !grp (fs/ext4/super.c)
- [Phase 3] Blame: helper NULL-for-bad-group from b4319e457d6e3 / fa285d799d1d5 in this history
- [Phase 3] Fast commit added in 6866d7b3f2bb4 (v5.10-rc1); present here
- [Phase 3] git log --grep on fs/ext4/: this subject is **not** in HEAD
- [Phase 4] b4 am / b4 dig -c 8f3901fbb407: thread at msgid [email protected]; v1 only
- [Phase 4] b4 dig -w: tytso + Dilger + linux-ext4 on the original mail
- [Phase 4] tytso applied as 8f3901fbb407; noted whitespace but no NAK
- [Phase 4] lore.kernel.org WebFetch: 403; used openwall + b4 mbox instead
- [Phase 5] Callers of ext4_get_group_info grepped; crashing caller checks NULL
- [Phase 5] ext4_free_inode() FC_REPLAY skip + “bit already cleared” → ext4_mark_group_bitmap_corrupted() verified
- [Phase 5] Mount order: jbd2_journal_load in ext4_load_journal() before ext4_mb_init() verified
- [Phase 5] sbi = kzalloc zeroes s_group_info; assigned later via rcu_assign_pointer in mballoc
- [Phase 6] make kernelversion / Makefile: **6.12.111**; branch pending-6.12
- [Phase 6] git merge-base --is-ancestor 8f3901fbb407 HEAD → not in this tree
- [Phase 6] Same SHA **is** an ancestor of origin/master; no later balloc.c follow-up on that fix
- [Phase 6] Clean apply context present in local ext4_get_group_info()
- [Phase 8] Failure mode: NULL deref oops on mount/recovery, severity CRITICAL
- UNVERIFIED: Did not run the author’s crafted-image/QEMU reproducer
- UNVERIFIED: Could not search lore.kernel.org/stable HTML (HTTP 403)

**YES**

 fs/ext4/balloc.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/ext4/balloc.c +4 -0
index c9329ed5c094e..08556dd45760d 100644
@@ -331,9 +331,13 @@ struct ext4_group_info *ext4_get_group_info(struct super_block *sb,
 
 	if (unlikely(group >= EXT4_SB(sb)->s_groups_count))
 		return NULL;
+	if (unlikely(!EXT4_SB(sb)->s_group_info))
+		return NULL;
 	indexv = group >> (EXT4_DESC_PER_BLOCK_BITS(sb));
 	indexh = group & ((EXT4_DESC_PER_BLOCK(sb)) - 1);
 	grp_info = sbi_array_rcu_deref(EXT4_SB(sb), s_group_info, indexv);
+	if (unlikely(!grp_info))
+		return NULL;
 	return grp_info[indexh];
 }
 
Signature · 1 line
2.53.0
#370 lore raw

Re: [PATCH AUTOSEL 6.18-5.10] ext4: guard against NULL s_group_info in ext4_get_group_info

Sashiko has reviewed this patch and found no issues.
Quoted 17 lines

From: Junzhe Yu <[email protected]>

[ Upstream commit 8f3901fbb40745046e513226ad84e8b84492632d ]

Resend: previous attempt was rejected by vger for containing HTML.

==================================================================

ext4_mark_group_bitmap_corrupted() already treats a NULL return from ext4_get_group_info() as "nothing to do", but ext4_get_group_info() indexes s_group_info without checking whether the array exists.

During mount, fast-commit replay runs inside jbd2_journal_load() from ext4_load_and_init_journal(), which is before ext4_mb_init() allocates s_group_info. Replaying an FC UNLINK for an inode whose bitmap bit is [ ... ]

Quoted 4 lines

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author maintainer
#371 lore raw

PATCH 1/1 netfilter: ebtables: bound num_counters like nentries in do_replace()

In reply to Sasha Levin

From: Jiayuan Chen <[email protected]>

[ Upstream commit 43ae85af154b27f9a0ff602f7a01e3a7583ffdab ]

do_replace_finish() allocates the counter buffer before it is validated:

   counterstmp = vmalloc_array(repl->num_counters, sizeof(*counterstmp));

do_replace() only checks num_counters against INT_MAX / sizeof(struct ebt_counter), so vmalloc_array() can be asked for up to 134217726 * 16 = 2147483616 bytes (~2 GiB).

num_counters must in fact equal nentries: do_replace_finish() later rejects the request when repl->num_counters != t->private->nentries. get_counters() folds the per-CPU counters back into one entry per rule, so what userspace gets is bounded by nentries, never by nentries * nr_cpus. Apply the same upper bound used for nentries (MAX_EBT_ENTRIES) to the incoming num_counters so the over-sized allocation can no longer be requested.

The allocation is still kept outside the ebt_mutex, since vmalloc() may sleep and trigger reclaim; only the bound is tightened.

---

LLM Generated explanations, may be completely bogus:

This is a real allocate-before-validate bound bug in legacy ebtables do_replace(). The local tree is **6.18.53**; the buggy checks are present here and the fix is small enough to apply cleanly.

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

Step 1.1: PARSE THE SUBJECT LINE
- Subsystem: netfilter: ebtables
- Action verb: **bound** (limit an existing userspace-controlled size)
- Intent: cap num_counters with the same ceiling already used for nentries in do_replace()
Record: [netfilter/ebtables] [bound] [tighten num_counters so do_replace() cannot request a ~2 GiB counter vmalloc]

Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
- Signed-off-by: Jiayuan Chen \<[email protected]\> (author)
- Signed-off-by: Florian Westphal \<[email protected]\> (netfilter/ebtables maintainer; applied the patch)
- Signed-off-by: Sasha Levin — **ignored** (pipeline)
- [Upstream commit 43ae85af154b…] — **ignored** (pipeline)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, Link:, or Cc: stable
Record: Author SOB + maintainer SOB only. Absence of Fixes/Cc-stable is expected and not a negative.

Step 1.3: ANALYZE THE COMMIT BODY TEXT
Bug: do_replace_finish() does vmalloc_array(repl->num_counters, sizeof(*counterstmp)) **before** checking repl->num_counters != t->private->nentries. do_replace() only rejects num_counters >= INT_MAX / sizeof(struct ebt_counter), so the allocation can be up to 134217726 * 16 = 2147483616 bytes (~2 GiB). Semantically num_counters must equal the current table’s nentries; get_counters() returns one summed entry per rule, not per-CPU.
Symptom: a crafted EBT_SO_SET_ENTRIES sockopt can force a huge vmalloc and reclaim/OOM, then the request is rejected. Root cause: allocate-then-validate; the nentries overflow formula is much tighter than the num_counters formula.
Record: [oversized counter vmalloc before validation] [memory exhaustion / reclaim DoS] [bug present since the 2010 overflow checks] [same MAX_EBT_ENTRIES ceiling as nentries]

Step 1.4: DETECT HIDDEN BUG FIXES
Not disguised. Explicit bound-check fix for a userspace-controlled allocation. Extracting the existing nentries formula into MAX_EBT_ENTRIES is mechanical, not a hidden refactor.
Record: [Direct bug fix, not a hidden cleanup]

===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================

Step 2.1: INVENTORY THE CHANGES
File: net/bridge/netfilter/ebtables.c — 6 insertions, 6 deletions.
Functions: file-scope #define MAX_EBT_ENTRIES; do_replace(); compat_copy_ebt_replace_from_user().
Record: [1 file, ±6 lines] [do_replace, compat_copy_ebt_replace_from_user] [single-file surgical fix]

Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Hunk 1: existing nentries overflow expression becomes MAX_EBT_ENTRIES (same formula).
Hunk 2 (do_replace): num_counters >= INT_MAX / sizeof(struct ebt_counter) → num_counters >= MAX_EBT_ENTRIES.
Hunk 3 (compat): same num_counters change.
Normal sockopt replace path, before any allocation of newinfo / counterstmp.
Record: [before: num_counters allowed up to ~134M; after: same ceiling as nentries]

Step 2.3: IDENTIFY THE BUG MECHANISM
Category: memory-safety / resource-exhaustion bound check (not UAF, leak, or race).
Mechanism: num_counters is independent of sockopt len (len only covers sizeof(ebt_replace) + entries_size). A small blob plus a huge num_counters still reaches vmalloc_array(). vmalloc_array() uses check_mul_overflow, so this is not an integer-wrap heap overflow; it is a ~2 GiB allocation request. Later do_replace_finish() rejects mismatched num_counters and vfrees the buffer.
Record: [resource exhaustion] [userspace size used for vmalloc before semantic validation]

Step 2.4: ASSESS THE FIX QUALITY
Obviously correct: num_counters must equal current nentries, and nentries was already capped by this formula. Kernel-registered initial tables (ebtable_filter etc.) have a handful of entries. No API/ABI change; oversized requests now get -ENOMEM earlier instead of allocating then -EINVAL. Allocation stays outside ebt_mutex (vmalloc may sleep). Regression risk is very low.
Record: [minimal, maintainer-applied] [very low regression risk]

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

Step 3.1: BLAME THE CHANGED LINES
The pair of overflow checks was added in e788759f44b2 (“netfilter:
ebtables: split do_replace into two functions”, Florian Westphal, 2010-02-04), first appearing around **v2.6.34-rc1**. The loose num_counters bound has been unchanged since then (aside from a 2015 revert of an unrelated num_counters == 0 check).
Record: [e788759f44b2, v2.6.34-rc1] [bug ~16 years old; present in this 6.18.y tree]

Step 3.2: FOLLOW THE FIXES: TAG
No Fixes: tag. The introducing commit is an ancestor of HEAD and of v6.18.53.
Record: [no Fixes tag] [introducing commit is in this tree] [no intermediate tightening of this bound]

Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Nearby ebtables work (terminate table name, zero chainstack, module names must be null-terminated) is independent. This commit is not patch N/M.
Record: [standalone] [no prerequisites beyond the 2010 overflow checks]

Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Jiayuan Chen is not the ebtables maintainer. Florian Westphal applied it. Same-period netfilter work from this author is unrelated (nft_ct).
Record: [regular contributor; maintainer SOB] [no dependent series]

Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS MAX_EBT_ENTRIES is introduced here from an in-tree formula. vmalloc_array() exists (mm/util.c). Compat path exists under CONFIG_NETFILTER_XTABLES_COMPAT. Applies standalone.
Record: [none] [standalone apply]

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
b4 dig -c 43ae85af154b →
https://patch.msgid.link/[email protected]
Subject: [PATCH nf-next] netfilter: ebtables: bound num_counters like nentries in do_replace()
v1 only (b4 dig -a). Mbox is the patch itself; **no replies, NAKs, or
Cc: stable**. Applied as-is by Florian on 2026-07-02. Merged via nf- next-26-07-02; pull text: “Bound num_counters in ebtables: do_replace() by MAX_EBT_ENTRIES to prevent oversized vmalloc_array() allocations.”
Record: [msgid 20260610030259.194456-1] [v1 only] [no review comments] [sent to nf-next, not nf] [no stable nomination in thread]

Step 4.2: CHECK WHO REVIEWED THE PATCH
b4 dig -w: To [email protected] and the author only. Florian’s SOB is the review.
Record: [netfilter-devel + maintainer applied]

Step 4.3: SEARCH FOR THE BUG REPORT
No Reported-by, syzbot, bugzilla, or CVE in the commit or thread. Bug is derived from code analysis in the message (exact 2 GiB arithmetic).
Record: [no external bug report] [mechanism documented in the patch]

Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Standalone v1. iptables still uses INT_MAX / sizeof(xt_counters) plus xt_counters_alloc()’s extra XT_MAX_TABLE_SIZE (512 MiB) cap. ebtables had no equivalent extra cap before this patch.
Record: [standalone] [iptables already had a tighter allocator cap]

Step 4.5: CHECK STABLE MAILING LIST HISTORY lore.kernel.org HTTP fetch returned 403. b4 dig mbox has no stable@ traffic. No evidence it was rejected for stable.
Record: [no stable-list discussion found; lore HTTP 403]

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: [do_replace, compat_copy_ebt_replace_from_user; allocation in do_replace_finish]

Step 5.2: TRACE CALLERS
do_ebt_set_ctl() (CAP_NET_ADMIN via ns_capable(net->user_ns, CAP_NET_ADMIN)) → EBT_SO_SET_ENTRIES → do_replace() / compat_do_replace() → compat_copy_ebt_replace_from_user() then do_replace_finish().
Record: [privileged sockopt; user_ns capable] [not IRQ; process context]

Step 5.3: TRACE CALLEES
vmalloc_array() → overflow-checked __vmalloc. get_counters() memcpy/sum into nentries slots. copy_to_user of num_counters entries only after the match check.
Record: [vmalloc_array, get_counters, copy_to_user]

Step 5.4: FOLLOW THE CALL CHAIN
Reachable from setsockopt with EBT_SO_SET_ENTRIES. len need not include the counter array. Unprivileged user namespaces that have CAP_NET_ADMIN in that netns can call it if CONFIG_BRIDGE_NF_EBTABLES_LEGACY is loaded. find_table_lock failure still happens **after** the counterstmp allocation.
Record: [userspace sockopt] [reachable; userns-relevant]

Step 5.5: SEARCH FOR SIMILAR PATTERNS
do_update_counters() also vmalloc_array(num_counters) but len must equal sizeof(hlp) + num_counters * sizeof(ebt_counter), so the sockopt size bounds it. copy_counters_to_user() allocates from validated nentries. Sibling not the same bug; this commit does not need to wait for a series.
Record: [replace path is the unbounded one]

===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================

Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Local tree: git describe HEAD = v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion = **6.18.53**; Makefile VERSION/PATCHLEVEL/SUBLEVEL = 6.18.53.
At v6.18.53, do_replace() still has the old INT_MAX / sizeof(struct ebt_counter) check. git merge-base --is-ancestor 43ae85af154b v6.18.53 fails (fix not in 6.18.53). Introducing commit **is** in 6.18.53.
Record: [yes, both native and compat replace] [introduced v2.6.34-rc1]

Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
The overflow-check lines at v6.18.53 match the pre-image of this patch. MAX_EBT_ENTRIES is new here. Clean apply expected.
Record: [clean apply]

Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
No earlier equivalent bound on num_counters. Name-termination commits nearby do not fix this.
Record: [no alternate fix in 6.18.y]

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY net/bridge/netfilter/ebtables.c, CONFIG_BRIDGE_NF_EBTABLES_LEGACY (default n). Still used by docker/libvirt/firewalld-style bridge filtering on distro kernels that enable it.
Record: [netfilter/ebtables legacy] [IMPORTANT for those configs, not core mm/VFS]

Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Mature (2002-era) with occasional correctness/security fixes. Not churny new code.
Record: [mature/stable]

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

Step 8.1: DETERMINE WHO IS AFFECTED
Systems with legacy ebtables loaded. Trigger is a sockopt, not data- plane forwarding.
Record: [config-specific / legacy-ebtables users]

Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Crafted EBT_SO_SET_ENTRIES: small entries_size, num_counters near INT_MAX/16. Cheap. Needs CAP_NET_ADMIN in the socket’s user_ns (ns_capable), so unprivileged userns can hit it when the module is present. Not every boot; attacker- or test-triggered.
Record: [malicious/buggy replace] [easy if capable] [userns-capable, not world-unprivileged without userns]

Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Success: ~2 GiB kernel vmalloc held through verify/translate, then freed — OOM/reclaim. Failure: -ENOMEM. Not UAF, not silent corruption, not a panic by itself. iptables caps similar allocations at 512 MiB; ebtables could request ~4× that.
Record: [local memory-exhaustion DoS] [HIGH, not crash/corruption CRITICAL]

Step 8.4: CALCULATE RISK-BENEFIT RATIO
Benefit: stops a documented ~2 GiB sockopt vmalloc on a long-lived path; high for hosts that ship legacy ebtables. Risk: 6-line bound change, same formula as nentries; very low.
Record: [high benefit for ebtables users] [very low risk] [favorable]

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real allocate-before-validate bug; commit shows the 2 GiB request
- Small (6/6), obviously correct, maintainer-applied
- Bug in this 6.18.y tree since v2.6.34; patch applies cleanly
- Reachable from setsockopt; ns_capable makes userns relevant
- Matches stable “oh, that’s not good” / security-DoS class
- Does not add features or APIs

AGAINST:
- Sent to **nf-next**, not nf (not treated as an urgent -rc fix)
- No user/syzbot/CVE report
- Legacy ebtables, Kconfig default n
- Requires CAP_NET_ADMIN in the netns user_ns
- Transient allocation (freed on the later -EINVAL path), not a leak

UNRESOLVED:
- lore.kernel.org WebFetch 403; thread recovered via b4 dig -m (patch- only)
- No stable@ discussion found

Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — same ceiling as nentries; maintainer applied v1
2. Fixes a real bug that affects users? **PASS** — oversized vmalloc from a sockopt field that is later rejected
3. Important (crash/security/corruption/deadlock)? **PASS** — local DoS / “oh, that’s not good” memory exhaustion, including userns CAP_NET_ADMIN; not a panic
4. Small and contained? **PASS** — 6 lines, one file
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — pre-image matches v6.18.53

Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Not a device ID, quirk, DT, build, or docs exception. Ordinary small bugfix.

Step 9.4: MAKE YOUR DECISION
nf-next targeting and lack of a reporter argue it is hardening rather than an emergency, but the defect is concrete, old, reachable, and the patch is the lowest-risk way to close a ~2 GiB kernel allocation. That is appropriate for 6.18.y.

What the commit solves for stable users: a crafted ebtables replace can ask vmalloc for up to ~2 GiB of counter scratch space before the kernel checks that num_counters equals the table’s nentries. Tightening that field to MAX_EBT_ENTRIES stops the request without moving vmalloc under ebt_mutex.

Risk vs benefit: benefit is preventing reclaim/OOM on a privileged (and userns-capable) sockopt; risk is a stricter -ENOMEM on values that could never succeed the later equality check.

Verification:
- [Phase 1] Parsed tags: author + Florian Westphal SOB only; no Fixes/Reported-by/Cc-stable
- [Phase 1] Body: 134217726 * 16 = 2147483616 documented; verified sizeof(struct ebt_counter) is two __u64 in ebtables.h
- [Phase 2] Diff: 6/6 in ebtables.c; do_replace + compat copy; MAX_EBT_ENTRIES is the old nentries formula
- [Phase 2] Pre-fix at c06e4b417f61^ and v6.18.53: num_counters >= INT_MAX / sizeof(struct ebt_counter)
- [Phase 2] do_replace_finish() still allocates then checks num_counters != t->private->nentries (lines 1025–1056)
- [Phase 2] get_counters() copies/sums nentries entries only (lines 992–1011)
- [Phase 3] git log -L on the overflow checks: introduced e788759f44b2 (2010-02-04); git describe --contains → v2.6.34-rc1
- [Phase 3] git merge-base --is-ancestor e788759f44b2 v6.18.53 exit 0; 43ae85af154b not ancestor of v6.18.53
- [Phase 3] No MAX_EBT_ENTRIES before this commit (git log -S MAX_EBT_ENTRIES)
- [Phase 4] b4 dig -c 43ae85af154b: msgid 20260610030259.194456-1; nf- next; v1 only
- [Phase 4] b4 dig -w: netfilter-devel only; b4 dig -m: 110-line mbox, no replies
- [Phase 4] Florian nf-next pull b73bc9ca3686b item 11 describes oversized vmalloc_array prevention
- [Phase 4] UNVERIFIED: stable@ lore search (HTTP 403)
- [Phase 5] Callers: do_ebt_set_ctl requires ns_capable(..., CAP_NET_ADMIN); EBT_SO_SET_ENTRIES
- [Phase 5] vmalloc_array uses check_mul_overflow (mm/util.c:656-662) — overflow-safe, still ~2 GiB
- [Phase 5] xt_counters_alloc extra cap XT_MAX_TABLE_SIZE 512 MiB; ebtables lacked that
- [Phase 6] git describe HEAD v6.18.53-5049; kernelversion 6.18.53
- [Phase 6] git show v6.18.53:net/bridge/netfilter/ebtables.c still has the loose num_counters checks at 1132 and 2275
- [Phase 7] obj-$(CONFIG_BRIDGE_NF_EBTABLES_LEGACY) += ebtables.o; Kconfig default n
- [Phase 8] Failure mode: vmalloc/reclaim/OOM DoS, not oops/corruption
- UNVERIFIED: whether a specific distro 6.18 config enables BRIDGE_NF_EBTABLES_LEGACY

The patch meets the stable rules for this 6.18.y tree: real, important, small, and it applies.

**YES**

 net/bridge/netfilter/ebtables.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
net/bridge/netfilter/ebtables.c +6 -6
index 96176aa881117..5266f4d021c6d 100644
@@ -39,6 +39,8 @@
 #define COUNTER_OFFSET(n) (SMP_ALIGN(n * sizeof(struct ebt_counter)))
 #define COUNTER_BASE(c, n, cpu) ((struct ebt_counter *)(((char *)c) + \
 				 COUNTER_OFFSET(n) * cpu))
+#define MAX_EBT_ENTRIES (((INT_MAX - sizeof(struct ebt_table_info)) / \
+			 NR_CPUS - SMP_CACHE_BYTES) / sizeof(struct ebt_counter))
 
 struct ebt_pernet {
 	struct list_head tables;
@@ -1126,10 +1128,9 @@ static int do_replace(struct net *net, sockptr_t arg, unsigned int len)
 		return -EINVAL;
 
 	/* overflow check */
-	if (tmp.nentries >= ((INT_MAX - sizeof(struct ebt_table_info)) /
-			NR_CPUS - SMP_CACHE_BYTES) / sizeof(struct ebt_counter))
+	if (tmp.nentries >= MAX_EBT_ENTRIES)
 		return -ENOMEM;
-	if (tmp.num_counters >= INT_MAX / sizeof(struct ebt_counter))
+	if (tmp.num_counters >= MAX_EBT_ENTRIES)
 		return -ENOMEM;
 
 	tmp.name[sizeof(tmp.name) - 1] = 0;
@@ -2269,10 +2270,9 @@ static int compat_copy_ebt_replace_from_user(struct ebt_replace *repl,
 	if (tmp.entries_size == 0)
 		return -EINVAL;
 
-	if (tmp.nentries >= ((INT_MAX - sizeof(struct ebt_table_info)) /
-			NR_CPUS - SMP_CACHE_BYTES) / sizeof(struct ebt_counter))
+	if (tmp.nentries >= MAX_EBT_ENTRIES)
 		return -ENOMEM;
-	if (tmp.num_counters >= INT_MAX / sizeof(struct ebt_counter))
+	if (tmp.num_counters >= MAX_EBT_ENTRIES)
 		return -ENOMEM;
 
 	memcpy(repl, &tmp, offsetof(struct ebt_replace, hook_entry));
Signature · 1 line
2.53.0
author maintainer
#372 lore raw

PATCH 1/1 Bluetooth: btusb: Add USB ID 13d3:3625 for MediaTek MT7922

In reply to Sasha Levin

From: Gustavo Evgucci <[email protected]>

[ Upstream commit 849a3bf1489093996859ba0c3c1c0cd314d6ff96 ]

The IMC Networks MT7922 Bluetooth adapter with USB ID 13d3:3625 is not recognized as a MediaTek device because it is missing from the btusb device ID table. As a result, btmtk firmware loading is never triggered and the HCI reset command times out with -ETIMEDOUT.

Add the device with BTUSB_MEDIATEK | BTUSB_WIDEBAND_SPEECH flags, consistent with the neighboring 13d3:3627, 13d3:3628 and 13d3:3630 entries which use the same chip.

Tested on: MediaTek MT7922 (Wi-Fi 6E combo card, IMC Networks BT USB interface), kernel 7.0.11-arch1-1.

/sys/kernel/debug/usb/devices:

T:  Bus=01 Lev=01 Prnt=01 Port=12 Cnt=03 Dev#=  4 Spd=480  MxCh= 0
D:  Ver= 2.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=13d3 ProdID=3625 Rev= 1.00
S:  Manufacturer=MediaTek Inc.
S:  Product=Wireless_Device
S:  SerialNumber=000000000
C:* #Ifs= 3 Cfg#= 1 Atr=e0 MxPwr=100mA
A:  FirstIf#= 0 IfCount= 3 Cls=e0(wlcon) Sub=01 Prot=01
I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=125us
E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
I:  If#= 1 Alt= 6 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  63 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  63 Ivl=1ms
I:  If#= 2 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=8a(I) Atr=03(Int.) MxPS=  64 Ivl=125us
E:  Ad=0a(O) Atr=03(Int.) MxPS=  64 Ivl=125us
I:* If#= 2 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=8a(I) Atr=03(Int.) MxPS= 512 Ivl=125us
E:  Ad=0a(O) Atr=03(Int.) MxPS= 512 Ivl=125us

---

LLM Generated explanations, may be completely bogus:

This is a two-line USB ID addition for an existing MediaTek btusb path. The local tree is **6.18.53** (pending-6.18); 13d3:3625 is missing here, while neighboring MediaTek IDs and BTUSB_MEDIATEK setup already exist.

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

**Step 1.1: PARSE THE SUBJECT LINE**

Record: [Bluetooth / btusb] [Add] [USB ID 13d3:3625 for MediaTek MT7922]
- Subsystem: Bluetooth USB driver (btusb)
- Action verb: **Add** (device ID to an existing driver)
- Claimed intent: enable an IMC Networks / MediaTek MT7922 adapter that is already bound by generic Bluetooth USB matching but is not treated as MediaTek

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**

Record:
- **Fixes:** none (expected)
- **Reported-by:** none
- **Tested-by:** none as a tag; body says tested on kernel 7.0.11-arch1-1
- **Reviewed-by:** Paul Menzel <[email protected]>
- **Acked-by:** none
- **Link:** none in the commit message
- **Cc: stable:** none (expected)
- **Signed-off-by:** Gustavo Evgucci <[email protected]> (author); Luiz Augusto von Dentz <[email protected]> (Bluetooth maintainer)
- Ignore: any pipeline “Upstream commit …” / Sasha Levin SOB if present

Notable: maintainer SOB plus an independent Reviewed-by. Bluetooth CI (bluez.test.bot) ran on v1 and v2.

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**

Record:
- **Bug:** USB ID 13d3:3625 is missing from the btusb ID/quirks table, so the adapter is not flagged BTUSB_MEDIATEK.
- **Symptom:** MediaTek firmware load (btmtk) never runs; HCI reset times out with -ETIMEDOUT (Opcode 0x0c03 failed: -110 in user reports).
- **Root cause:** generic Bluetooth class match binds btusb with driver_info == 0; MediaTek setup is skipped.
- **Fix:** add { USB_DEVICE(0x13d3, 0x3625), .driver_info = BTUSB_MEDIATEK | BTUSB_WIDEBAND_SPEECH } next to 13d3:3627/3628/3630.
- **Version info:** tested on 7.0.11-arch1-1; /sys/kernel/debug/usb/devices dump included (vendor 13d3, product 3625, Manufacturer=MediaTek Inc., class e0/01/01, Driver=btusb).

**Step 1.4: DETECT HIDDEN BUG FIXES**

Record: Not a disguised cleanup. It is an explicit hardware ID addition. That is a documented stable exception: new device IDs on an existing driver. It also fixes a real functional failure (HCI timeout, adapter unusable).

===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================

**Step 2.1: INVENTORY THE CHANGES**

Record:
- File: drivers/bluetooth/btusb.c only
- Scope: **+2 lines** in quirks_table[] (single-file surgical ID add)
- Functions: none; static usb_device_id table only
- Classification: single-file device ID addition

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**

Record:
- **Before:** 13d3:3625 is absent from quirks_table. Probe matches generic { USB_DEVICE_INFO(0xe0, 0x01, 0x01) } in btusb_table with empty driver_info. btusb_probe() only consults quirks_table when !id->driver_info (lines 4064–4069). No MediaTek match → hdev->setup is not set to btusb_mtk_setup.
- **After:** usb_match_id(intf, quirks_table) hits the new entry. id->driver_info & BTUSB_MEDIATEK is true, so probe sets hdev->setup = btusb_mtk_setup and related MTK callbacks (lines 4244–4258). BTUSB_WIDEBAND_SPEECH sets HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED (lines 4344–4345).
- Path affected: probe/init of this USB ID only.

**Step 2.3: IDENTIFY THE BUG MECHANISM**

Record: **Hardware workaround / device ID addition (category h)**
- Broken: MediaTek combo card enumerates as generic Bluetooth USB; firmware is never loaded; HCI reset times out.
- Fix: same flags as neighboring IMC/MediaTek entries already in this tree.

**Step 2.4: ASSESS THE FIX QUALITY**

Record:
- Obviously correct: two-line table entry matching established pattern.
- Minimal; no unrelated edits; no API/locking/data-structure change.
- Regression risk: **very low**, scoped to VID/PID 13d3:3625. Wrong flags would only affect that device; flags match 3627/3628/3630.
- Chip naming is slightly inconsistent in history (3627 subject says MT7925, body says MT7922); **flags are the same**, so the driver path is identical.

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

**Step 3.1: BLAME THE CHANGED LINES**

Record:
- Insertion sits between 13d3:3613 (Youn Mélois, 2025-04-01, bbf56029322c06) and 13d3:3627 (Chris Lu, 2025-09-04, 576952cf981b7).
- This is not a regression in old code; it is a **missing ID** for hardware that uses the long-standing MediaTek path.
- MT7922 USB support: 8c0401b7308cb (“Bluetooth: Add support for MediaTek MT7922 device”), contained in v6.11-rc1 era. Present in this 6.18 tree.

**Step 3.2: FOLLOW THE FIXES: TAG**

Record: No Fixes: tag. Not applicable. The “bug” is omission of this VID/PID, not a later regression.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**

Record:
- This tree already has many of the same class of commits, including:
- 576952cf981b7 13d3/3627
- f63f401130e5c 13d3/3628
- 5bd5c716f7ec3 13d3/3630
- 70cd38d22d465 13d3/3633 for MT7922
- Candidate ddd25808d4c2 is **not** an ancestor of HEAD (git merge- base --is-ancestor exit 1).
- Standalone; not patch X/Y.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**

Record: git log --author="Gustavo Evgucci" -- drivers/bluetooth/ is empty in this tree. Author is a first-time hardware-ID contributor, not the subsystem maintainer. Weight comes from Luiz’s merge and Paul Menzel’s Reviewed-by.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**

Record:
- Needs quirks_table, BTUSB_MEDIATEK, BTUSB_WIDEBAND_SPEECH, and btusb_mtk_setup. All exist here.
- CONFIG_BT_HCIBTUSB_MTK exists (drivers/bluetooth/Kconfig).
- No extra commits required.
- Can apply standalone. Parent of ddd25808d4c2 also has 13d3:3609, which this 6.18 tree lacks; that is **context only**. Insertion between 3613 and 3627 is valid here.

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**

Record:
- b4 dig -c ddd25808d4c2 matched patch-id ce1685f940593b167015292f6b73b7f2fc9ec8d9
- Lore/msgid:
https://patch.msgid.link/[email protected]
- Thread saved to /tmp/btusb-3625.mbox (7 messages)
- **v1** (2026-06-23): [PATCH] Bluetooth: btusb: Add IMC Networks MT7922 device 0x13d3:0x3625
- **v2** (2026-06-25): added usb/devices dump, Reviewed-by, full maintainer To/Cc. **Code hunk unchanged.**
- Applied to bluetooth-next as ddd25808d4c2 by Luiz (patchwork-bot, 2026-06-26).
- Review: Paul Menzel asked for usb/devices dump and get_maintainer.pl recipients; then Reviewed-by. **No NAK.**
- Bluetooth CI: v1 all PASS; v2 GitLint FAIL only for an 82-char notes line. Builds passed.
- No reviewer asked for Cc: stable.

**Step 4.2: CHECK WHO REVIEWED THE PATCH**

Record (b4 dig -w):
- Gustavo Evgucci (author)
- Luiz Augusto von Dentz (Bluetooth driver maintainer)
- Marcel Holtmann (Bluetooth maintainer)
- linux-bluetooth@, linux-kernel@
- Paul Menzel (reviewer)
Appropriate maintainers were on the thread; Luiz applied it.

**Step 4.3: SEARCH FOR THE BUG REPORT**

Record:
- User-tested on real hardware with a full usb/devices dump.
- External confirmation: DKMS workarounds for Mercusys MA80XE / IMC Networks 13d3:3625 (hci0: Opcode 0x0c03 failed: -110). That matches the commit’s -ETIMEDOUT description.
- Not syzbot; hardware enablement with a concrete timeout.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**

Record: Single-patch series (v1 → v2 documentation only). Neighboring IDs already in this tree.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**

Record: No useful stable@ thread found (lore.kernel.org/stable WebFetch blocked by anti-bot). Absence of prior stable discussion is not a negative signal for a device-ID add.

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

semcode MCP: not available. Used grep/read.

**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**

Record: No functions modified. Data: quirks_table[]. Consumers:
btusb_probe().

**Step 5.2: TRACE CALLERS**

Record:
- btusb_probe() ← USB core when btusb matches.
- Generic match: btusb_table { USB_DEVICE_INFO(0xe0, 0x01, 0x01) } (line 83), which matches this device’s If#0 Cls=e0 Sub=01 Prot=01.
- Then usb_match_id(intf, quirks_table) when driver_info is 0.

**Step 5.3: TRACE CALLEES**

Record: With the new flags, probe assigns btusb_mtk_setup, btusb_mtk_shutdown, btmtk_reset_sync, btmtk_set_bdaddr, btusb_send_frame_mtk, USB suspend/resume/disconnect MTK hooks.

**Step 5.4: FOLLOW THE CALL CHAIN**

Record: Userspace-reachable: plug in / boot with the adapter. Unprivileged users do not need a special syscall; udev/bluetoothd open the HCI device. High priority for owners of this card. Not a universal path.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**

Record: Dozens of USB_DEVICE(0x13d3, …) … BTUSB_MEDIATEK | BTUSB_WIDEBAND_SPEECH entries. Same pattern as 3627/3628/3630 already in this file. Systematic missing-ID class, not a one-off logic bug.

===============================================================
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 → p-6.18-1-g03b85e06ca9bf; make kernelversion → **6.18.53**; branch pending-6.18.
- 13d3:3625 is **not** in drivers/bluetooth/btusb.c (rg found only unrelated Realtek 0x3625:0x010b).
- quirks_table MediaTek block **is** here, with 3613 then 3627 (lines 787–794).
- Neighbor commits 3627/3628/3630 **are** ancestors of HEAD.
- Candidate ddd25808d4c2 is **not** an ancestor of HEAD.
- Driver support for MT7922 has been in this lineage since ~v6.11 (8c0401b7308cb).

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**

Record: **Clean / minor context fuzz.** Candidate parent has extra 13d3:3609 above 3613; 6.18 does not. Added lines themselves match. No refactor of quirks_table vs probe matching.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**

Record: No other 13d3:3625 MediaTek entry. d9da920233ec8 is Realtek 3625:010b (different vendor). Not a duplicate.

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**

Record: [drivers/bluetooth/btusb.c] [IMPORTANT]
- Common USB Bluetooth driver, not core mm/fs.
- MediaTek Wi-Fi 6E combo cards are widely used (laptops, USB adapters). Device-specific, but the class of fix is standard for stable.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**

Record: Active. Recent 6.18 history includes many VID/PID adds and btusb bugfixes. ID table is the normal place for this change.

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

**Step 8.1: DETERMINE WHO IS AFFECTED**

Record: Users of USB Bluetooth 13d3:3625 (IMC Networks / MediaTek MT7922, e.g. combo cards / Mercusys MA80XE). Others unchanged. Requires CONFIG_BT_HCIBTUSB and typically CONFIG_BT_HCIBTUSB_MTK.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**

Record: Every probe of this device (boot or plug-in). Not a race. Not unprivileged exploit; the device simply does not work. Reproduced by the author and by out-of-tree DKMS users.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**

Record: [Bluetooth adapter fails HCI reset / -ETIMEDOUT; no controller] [HIGH for affected hardware, LOW globally]
- Not a panic/UAF, but the device is dead without the ID. That is the usual severity for missing USB IDs.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**

Record:
- **Benefit:** High for holders of this adapter on 6.18; zero for everyone else.
- **Risk:** Very low (2 lines, existing flags, existing probe path).
- **Ratio:** Strongly favors backport. This is the textbook new-device- ID exception.

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Explicit stable exception: new USB ID on an existing driver
- Real user-visible bug: HCI reset -ETIMEDOUT, adapter unusable
- 2-line, obviously correct, same flags as 3627/3628/3630 already in this tree
- MTK setup path (btusb_mtk_setup) present
- Reviewed-by Paul Menzel; merged by Luiz von Dentz; CI built
- Author tested on hardware; usb/devices dump matches
- Independent DKMS users hit the same ID/symptom
- Applies with at most minor context adjustment (missing 3609)

AGAINST:
- Not a crash/security/corruption bug (hardware enablement)
- Author is not a regular Bluetooth contributor
- Chip labeled MT7922 vs some neighbor commits saying MT7925 (flags still match)
- No Cc: stable (not a negative under these rules)

UNRESOLVED:
- lore.kernel.org HTTP 403 for WebFetch; thread recovered via b4 dig -m
- No stable@ discussion found (search not useful)

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**

1. Obviously correct and tested? **PASS** — 2-line ID; hardware test; reviewer + maintainer
2. Fixes a real bug that affects users? **PASS** — missing ID → firmware never loads → HCI timeout
3. Important issue? **PASS** under the device-ID exception; adapter otherwise unusable
4. Small and contained? **PASS** — +2 lines, one table
5. No new features or APIs? **PASS** — ID only; no new driver/API
6. Can apply to the local tree? **PASS** — insertion point 3613/3627 exists; 3625 absent

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**

Record: **Device ID addition to existing driver** — automatic YES category.

**Step 9.4: MAKE YOUR DECISION**

Backport to this 6.18 tree. The bug exists here, the MediaTek path exists here, neighboring IDs exist here, and the change is a two-line USB ID with the established flags.

---

**What the commit solves for this tree**

On 6.18.53, 13d3:3625 still matches only the generic Bluetooth USB class, so btusb_probe() never sets BTUSB_MEDIATEK and never calls btusb_mtk_setup. HCI reset then times out. Adding the quirks_table entry with BTUSB_MEDIATEK | BTUSB_WIDEBAND_SPEECH is the same enablement already used for 3627/3628/3630 in this file.

**Risk vs benefit**

Benefit is making this MediaTek/IMC adapter work; risk is confined to that VID/PID. No locking, no API, no refactor.

**Concerns**

Parent context includes 13d3:3609, which 6.18 does not have. Insert between existing 3613 and 3627. No other prerequisites.

Verification:
- [Phase 1] Parsed subject/tags/body from git show -s ddd25808d4c2 and the supplied message: Add USB ID; Reviewed-by Paul Menzel; SOB Luiz; no Fixes/Cc stable
- [Phase 2] Diff: +2 lines in quirks_table; confirmed btusb_probe uses that table when !id->driver_info (btusb.c:4064–4069); MTK setup at 4244–4258; WBS quirk at 4344–4345
- [Phase 2] Generic match USB_DEVICE_INFO(0xe0, 0x01, 0x01) at line 83 matches the dumped interface class
- [Phase 3] git describe HEAD / make kernelversion: p-6.18-1 / 6.18.53
- [Phase 3] git merge-base --is-ancestor ddd25808d4c2 HEAD → not ancestor; 3627/3628/3630 commits are ancestors
- [Phase 3] rg 0x3625 drivers/bluetooth/btusb.c: no 13d3:3625; only Realtek 3625:010b
- [Phase 3] blame 785–796: 3613/3627/3628/3630 present as described
- [Phase 3] MT7922 intro 8c0401b7308cb contained around v6.11-rc1; present in this tree
- [Phase 3] author log empty in drivers/bluetooth/
- [Phase 4] b4 dig -c ddd25808d4c2 → msgid 20260625083230.300651-1; v1+v2; applied as ddd25808d4c2
- [Phase 4] b4 dig -a: v1 then v2 (docs only); b4 dig -w: Luiz, Marcel, linux-bluetooth, Paul Menzel
- [Phase 4] mbox: Paul Reviewed-by; CI pass (v2 gitlint notes-line only); no NAK
- [Phase 4] lore WebFetch 403; used b4 mbox instead. Stable list search:
no relevant hit
- [Phase 5] semcode unavailable; callers via grep: quirks_table → btusb_probe only
- [Phase 6] 3613 and 3627 present, 3625 absent — insertion point verified in this checkout
- [Phase 8] Failure mode: HCI -ETIMEDOUT / no controller for this USB ID; not a kernel oops
- UNVERIFIED: live lore.kernel.org HTML of the thread (403); chip MT7922 vs MT7925 labeling of neighbors (flags verified identical)

**YES**

 drivers/bluetooth/btusb.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
index 59fff918fd2de..9257341b01399 100644
@@ -788,6 +788,8 @@ static const struct usb_device_id quirks_table[] = {
 						     BTUSB_WIDEBAND_SPEECH },
 	{ USB_DEVICE(0x13d3, 0x3613), .driver_info = BTUSB_MEDIATEK |
 						     BTUSB_WIDEBAND_SPEECH },
+	{ USB_DEVICE(0x13d3, 0x3625), .driver_info = BTUSB_MEDIATEK |
+						     BTUSB_WIDEBAND_SPEECH },
 	{ USB_DEVICE(0x13d3, 0x3627), .driver_info = BTUSB_MEDIATEK |
 						     BTUSB_WIDEBAND_SPEECH },
 	{ USB_DEVICE(0x13d3, 0x3628), .driver_info = BTUSB_MEDIATEK |
Signature · 1 line
2.53.0
author maintainer
#373 lore raw

PATCH 1/1 ASoC: amd: yc: Add DMI entry for Alienware m18 R1 AMD

In reply to Sasha Levin

From: Zhang Heng <[email protected]>

[ Upstream commit fd8ed52ecea6b93e23d52cb2758fb4fb4029067f ]

Add DMI entry so the YC machine driver probes on this model and the internal DMIC works.

---

LLM Generated explanations, may be completely bogus:

This is a DMI quirk that enables the existing Yellow Carp DMIC driver on one Alienware laptop. The local tree is **6.12.111** (pending-6.12); the entry is not present here yet, and the surrounding driver/table are.

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

**Step 1.1: PARSE THE SUBJECT LINE**

Record: **[ASoC/amd/yc] [Add] Add DMI entry for Alienware m18 R1 AMD**

- Subsystem: ASoC: amd: yc: (ALSA SoC, AMD Yellow Carp ACP6x machine driver)
- Action verb: **Add** — here it is a DMI/quirk table addition, not a new driver
- Intent: make the YC machine driver probe on this model so the internal digital mic works

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**

Record (from git show fd8ed52ecea6b93e23d52cb2758fb4fb4029067f and the mailing-list mbox):

- **Closes:** https://bugzilla.kernel.org/show_bug.cgi?id=221485 — user-filed kernel.org bug
- **Link:** https://patch.msgid.link/20260824130302.553419-1- [email protected]
- **Signed-off-by:** Zhang Heng <[email protected]> (author)
- **Signed-off-by:** Mark Brown <[email protected]> (ASoC maintainer; applied to sound.git for-7.3)
- **No Fixes:** tag (expected)
- **No Cc: stable** (expected)
- **No Reported-by / Tested-by / Reviewed-by / Acked-by**
- Ignore pipeline SOB markers

Notable: Closes a public bugzilla; ASoC maintainer applied it. No syzbot/KASAN.

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**

Record:

- **Bug:** BIOS on Alienware m18 R1 AMD does not cause the YC machine driver to bind, so the internal DMIC is not registered.
- **Symptom:** internal microphone does not work (no ACP DMIC capture device).
- **Root cause (author):** missing DMI match in yc_acp_quirk_table[].
- **Version info:** none in the message. Driver exists since 2021 (fa991481b8b22).
- **Fix:** add DMI_BOARD_VENDOR "Alienware" + DMI_PRODUCT_NAME "Alienware m18 R1 AMD".

Same class as existing sibling entries already in this tree (m15 R7 AMD, m17 R5 AMD).

**Step 1.4: DETECT HIDDEN BUG FIXES**

Record: Not hidden. It is an explicit hardware-quirk / device-enablement fix. Stable exception category: DMI quirk for existing driver.

===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================

**Step 2.1: INVENTORY THE CHANGES**

Record:

- File: sound/soc/amd/yc/acp6x-mach.c — **+7 / -0**
- Function: none; one new initializer in yc_acp_quirk_table[]
- Scope: **single-file surgical quirk addition**

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**

Record:

- **Before:** dmi_first_match(yc_acp_quirk_table) in acp6x_probe() does not match this product. If ACPI _WOV / AcpDmicConnected also fail (typical on these Dell/Alienware BIOS images), platform_get_drvdata() is NULL and probe returns -ENODEV. No acp6x DMIC card.
- **After:** DMI matches, platform_set_drvdata(pdev, &acp6x_card), card registers. Log: Enabling ACP DMIC support via DMI.
- Path: probe/init only; no hot path, no locking, no API change.

Verified in this tree:

```817:826:sound/soc/amd/yc/acp6x-mach.c
check_dmi_entry:
        /* check for any DMI overrides */
        dmi_id = dmi_first_match(yc_acp_quirk_table);
        if (dmi_id)
                platform_set_drvdata(pdev, dmi_id->driver_data);

        card = platform_get_drvdata(pdev);
        if (!card)
                return -ENODEV;
        dev_info(&pdev->dev, "Enabling ACP DMIC support via %s", dmi_id
? "DMI" : "ACPI");
```

**Step 2.3: IDENTIFY THE BUG MECHANISM**

Record: **(h) Hardware workaround / DMI quirk**

BIOS does not advertise DMIC via ACPI; the machine must be listed. Without the entry, the existing ACP6x PDM path never registers. Mechanism is identical to m15 R7 / m17 R5 entries already here.

**Step 2.4: ASSESS THE FIX QUALITY**

Record:

- Obviously correct: same struct shape as every other table entry; driver_data = &acp6x_card.
- Minimal: 7 lines, one model.
- Regression risk: **very low**. Match is vendor+product-name specific. Other machines are unaffected. If this SKU has no ACP6x PCI device, acp6x_probe() never runs and the entry is inert.
- No public API, no data-structure layout change, no new Kconfig.

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

**Step 3.1: BLAME THE CHANGED LINES**

Record:

- Insertion is after the m17 R5 AMD entry, blamed to d40b6529c6269 (Brent Mendelsohn, 2022-10-24): “This model requires an additional detection quirk to enable the internal microphone - BIOS doesn't seem to support AcpDmicConnected”.
- m15 R7 AMD: c70f006356fac (already in this 6.12 tree).
- Machine driver introduced: fa991481b8b22 (2021-10-18, v5.16-era). Present long before 6.12.

The “bug” is absence of this SKU from a table that has existed for years.

**Step 3.2: FOLLOW THE FIXES: TAG**

Record: No Fixes: tag. N/A. Introduced-by is “never listed this DMI string,” not a later regression.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**

Record: This file on 6.12.y is a long series of standalone DMI additions (git log --oneline --grep='Add DMI' -- sound/soc/amd/yc/acp6x-mach.c → 24 commits). Parent of the candidate is e2aa5ad3be41a (“Add DMI entry for MSI Thin A15 B7UC”), already in this tree as aacaae0b94875. **Standalone, not patch X/Y.**

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**

Record: Zhang Heng is a regular DMI-quirk contributor in this same file on this tree (HP Victus 16-e1xxx, Thin A15 B7VF, ASUS EXPERTBOOK PM1503CDA, Acer TravelMate P216-41-TCO). Not the subsystem maintainer; Mark Brown applied the patch.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**

Record: None. Relies only on yc_acp_quirk_table and acp6x_card, both in this checkout. git merge-base --is-ancestor fd8ed52ecea6 HEAD is false (fix not yet here). No follow-up/revert grepping Alienware m18 on this path.

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**

Record:

- b4 dig -c fd8ed52ecea6 →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only** (no later revision)
- Thread (2 messages, saved via b4 mbox):
1. Zhang Heng, 2026-08-24: the patch
2. Mark Brown: **Applied** to

     `git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
     for-7.3` as `fd8ed52ecea6`

- No NAK, no requested changes, no reviewer concern about the DMI strings
- Also listed in sound fixes for 7.3-rc1 (lkml.iu.edu sound-fix pull)

**Step 4.2: CHECK WHO REVIEWED THE PATCH**

Record (b4 dig -w): To/Cc = Zhang Heng, [email protected], linux- [email protected], [email protected]. ASoC maintainer was the recipient and applied it. No extra reviewer Ack.

**Step 4.3: SEARCH FOR THE BUG REPORT**

Record:

- Closes bugzilla.kernel.org 221485.
- Direct fetch of bugzilla and lore HTML was blocked by Anubis (403 / PoW). **Full bugzilla comments UNVERIFIED.**
- Commit body + Closes: tag still document a real user-facing DMIC failure on this model.
- Unrelated Ubuntu bugs about Intel Alienware 18 Area-51 / SOF are a different machine; not this ACP6x DMI.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**

Record: Standalone [PATCH], not a series. Sibling Alienware YC entries already in this tree.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**

Record: Web search of lore.kernel.org/stable for this subject found **no** discussion. No record of a prior rejection. Absence is expected; this is why the commit is under review.

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

**Step 5.1: KEY FUNCTIONS**

Record: Table data only. Consumer: acp6x_probe().

**Step 5.2: TRACE CALLERS**

Record:

- acp6x_probe is .probe of platform_driver acp6x_mach_driver (name = "acp_yc_mach").
- Platform device created in sound/soc/amd/yc/pci-acp6x.c when ACP pin config is PDM mode (pdevinfo[2].name = "acp_yc_mach").
- Context: boot / ACPI+PCI enumeration. Not IRQ, not a syscall hot path.

**Step 5.3: TRACE CALLEES**

Record: dmi_first_match, platform_set_drvdata, devm_snd_soc_register_card. No alloc/lock change in this commit.

**Step 5.4: FOLLOW THE CALL CHAIN**

Record: PCI ACP6x device → create acp_yc_mach → acp6x_probe → DMI table → ALSA card acp6x / “DMIC capture”. Reachable on this laptop at boot. Userspace then sees a capture device. Unprivileged apps can use the mic once the card exists; they cannot trigger a kernel crash with this patch.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**

Record: Entire yc_acp_quirk_table[] (~200 DMI_MATCH lines) is this pattern. Same Alienware vendor/product matching is already used for m15 R7 and m17 R5.

===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**

Record:

- Tree: git describe HEAD → p-6.12-3-gc504cf0baa3d8; make kernelversion → **6.12.111**; branch pending-6.12.
- File and table exist. m15 R7 and m17 R5 entries exist. **Alienware m18 R1 AMD does not** (grep no matches).
- ACPI fallback (AcpDmicConnected / _WOV) is the same as mainline; this SKU still needs DMI.
- Driver since 2021; 6.12 is affected.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**

Record: **Clean apply / trivial offset.** Insertion is immediately after the m17 R5 AMD block, which is present at lines 503–509. The candidate’s 3-line context matches this file. Preceding MSI “Raider A18 HX A9WJG” from a later mainline snapshot is **not** required.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**

Record: No m18 R1 entry. No alternate fix for this product string. m15/m17 quirks do not cover m18 (exact DMI_PRODUCT_NAME match).

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**

Record: **ASoC AMD Yellow Carp (sound/soc/amd/yc/)** — **PERIPHERAL/driver-specific**, but the quirk table is the supported way to enable DMIC on YC laptops. Kconfig: SND_SOC_AMD_YC_MACH depends on SND_SOC_AMD_ACP6x && ACPI.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**

Record: Mature driver (2021), still actively receiving DMI quirks (many already on 6.12.y). This is the normal maintenance pattern, not a new subsystem.

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

**Step 8.1: DETERMINE WHO IS AFFECTED**

Record: **Driver-specific / DMI-specific.** Only systems whose DMI board vendor is Alienware and product name is Alienware m18 R1 AMD, and that actually instantiate acp_yc_mach. Everyone else: no code path change.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**

Record: Every boot on that laptop if ACP6x PDM mode is active. Not a race. Not unprivileged-exploit. Common for owners of that model; zero for others.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**

Record: Internal microphone missing (ALSA card never registered). **MEDIUM** functionally (hardware does not work), not a panic/UAF. Still the exact class stable accepts as a quirk.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**

Record:

- **Benefit:** restores internal mic on a shipping AMD Alienware laptop for 6.12.y users (enterprise/LTS kernels). Documented via bugzilla Closes.
- **Risk:** very low (7 lines, DMI-gated, existing table format, maintainer-applied).
- **Ratio:** strongly favors backport.

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

**Step 9.1: COMPILE THE EVIDENCE**

FOR:

- Real hardware bug: internal DMIC never enabled without DMI
- Closes kernel.org bug 221485
- Textbook stable exception: DMI quirk on an existing driver
- 7-line, obviously correct, matches m15/m17 entries already in 6.12
- File, probe path, and table exist here; patch applies
- Applied by Mark Brown; landed in sound 7.3-rc1 fixes
- Standalone; no prerequisites missing from this tree
- This tree already carries dozens of the same DMI additions

AGAINST:

- Not a crash/security/corruption issue
- No Tested-by/Reviewed-by besides maintainer apply
- Full bugzilla thread could not be fetched (Anubis)

UNRESOLVED:

- Exact bugzilla comments / reporter DMI dump (UNVERIFIED)
- Whether every m18 R1 AMD SKU is ACP6x vs a later ACP (if not, entry is a harmless no-op)

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**

1. Obviously correct and tested? **PASS** — identical to existing table entries; maintainer applied v1
2. Fixes a real bug that affects users? **PASS** — mic does not work; bugzilla Closes
3. Important issue? **PASS** as hardware-quirk exception (mic unusable on that model; not a panic)
4. Small and contained? **PASS** — +7 lines, one file
5. No new features or APIs? **PASS** — DMI ID on existing driver
6. Can apply to the local tree? **PASS** — YC driver + insertion point present

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**

Record: **Hardware quirk / DMI table entry for an existing driver.** Explicitly allowed.

**Step 9.4: DECISION**

Backport to this 6.12.y tree. It enables existing ACP6x DMIC support on one DMI-matched laptop, is tiny, and matches the quirk pattern already used here.

------------------------------------------------
What the commit solves for stable users
------------------------------------------------

On Alienware m18 R1 AMD, ACPI often does not flag the ACP DMIC. Without this DMI row, acp6x_probe() returns -ENODEV and there is no internal capture device. Adding the match makes the existing YC machine driver bind and register the DMIC card. 6.12 users of that laptop keep a broken mic until this lands.

Risk vs benefit: benefit is real hardware enablement; risk is confined to that DMI pair. No locking, allocation, or ABI change.

------------------------------------------------
Verification
------------------------------------------------

- [Phase 1] Parsed subject/tags from git show fd8ed52ecea6: Closes 221485, Link msgid, SOB Zhang Heng + Mark Brown; no Fixes/Cc-stable
- [Phase 2] Diff: +7 lines in yc_acp_quirk_table[] only
- [Phase 2] Read acp6x_probe() in this tree: DMI match sets drvdata; no match → -ENODEV
- [Phase 3] Blame: m17 R5 entry d40b6529c6269 (2022); driver fa991481b8b22 (2021); both ancestors of HEAD
- [Phase 3] git merge-base --is-ancestor fd8ed52ecea6 HEAD → not ancestor (not in this tree yet)
- [Phase 3] grep 'Alienware m18 R1 AMD' → no matches in acp6x-mach.c
- [Phase 3] Author history: several other YC DMI commits already on this branch
- [Phase 4] b4 dig -c fd8ed52ecea6: lore URL; v1 only; To/Cc include broonie and linux-sound
- [Phase 4] b4 mbox: Mark Brown applied to sound.git for-7.3; no NAK
- [Phase 4] Bugzilla HTML UNVERIFIED (Anubis 403). Closes: tag verified in commit and patch email
- [Phase 4] Stable list search: no prior discussion found
- [Phase 5] Callers: pci-acp6x.c creates acp_yc_mach in PDM mode; probe at boot
- [Phase 6] git describe HEAD / make kernelversion: **6.12.111**, branch pending-6.12
- [Phase 6] Insertion context after m17 R5 AMD present at lines 503–509; expected clean apply
- [Phase 8] Failure mode: missing internal mic, severity MEDIUM, quirk exception
- UNVERIFIED: full bugzilla comment text; whether every m18 R1 AMD SKU is ACP6x (mismatch would be inert)

**YES**

 sound/soc/amd/yc/acp6x-mach.c | 7 +++++++
 1 file changed, 7 insertions(+)
sound/soc/amd/yc/acp6x-mach.c +7 -0
index 666ac5b36e7d6..8e203c034851f 100644
@@ -514,6 +514,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m17 R5 AMD"),
 		}
 	},
+	{
+		.driver_data = &acp6x_card,
+		.matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Alienware"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m18 R1 AMD"),
+		}
+	},
 	{
 		.driver_data = &acp6x_card,
 		.matches = {
Signature · 1 line
2.53.0
author maintainer
#374 lore raw

PATCH 1/1 media: cec: stm32: return an error when log-address wait times out

In reply to Sasha Levin

From: Pengpeng Hou <[email protected]>

[ Upstream commit 3bc2e4a26465386332ee1a40219d8dafba335b0b ]

stm32_cec_adap_log_addr() waits for TXSOM to clear before disabling CEC and updating the logical address registers. The wait result is ignored, so a timeout can still be reported as a successful logical address update.

Return the polling error before touching the address registers. Compute the address mask only for valid logical addresses so the invalid-address path does not evaluate a shift based on CEC_LOG_ADDR_INVALID.

---

LLM Generated explanations, may be completely bogus:

This tree is **6.18.53** (v6.18.53-5049-g0f0bdc2b0dffb, branch autosel). The verdict is only for this checkout: the STM32 CEC timeout/shift bugs are present at v6.18.53, and the patch applies cleanly.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**

Record: [media/cec/stm32] [return] return an error when log-address wait times out

Subsystem prefix media: cec: stm32. Verb return is error-propagation language (equivalent to “handle/fix”). Intent: stop treating a timed-out TXSOM wait as a successful logical-address update.

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**

Record:
- Signed-off-by: Pengpeng Hou <[email protected]> (author)
- Signed-off-by: Hans Verkuil <[email protected]> (CEC framework maintainer; also the committer of upstream 3bc2e4a26465)
- Ignored pipeline tags: [Upstream commit 3bc2e4a26465386332ee1a40219d8dafba335b0b], Signed-off-by: Sasha Levin
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, Link:, or Cc: stable (absence expected for this review)

Notable: maintainer SOB, no syzbot/user report.

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**

Record:
- **Bug:** stm32_cec_adap_log_addr() polls for TXSOM to clear, then ignores the poll result and still disables CEC, writes OAR, re-enables CEC, and returns 0.
- **Symptom:** userspace/CEC core can be told a logical address was programmed when the wait timed out and the registers may not have been updated safely.
- **Second issue:** address mask (1 << logical_addr) << 16 is computed before the CEC_LOG_ADDR_INVALID check, so the invalid-address path still evaluates a shift of 0xff.
- **Root cause:** missing return-value check; mask computed too early.
- **Version info:** none in the message. Poll wait was added in 2019 (1a726df6078c2f, v5.2-rc1).

**Step 1.4: DETECT HIDDEN BUG FIXES**

Record: Not disguised. It is an explicit error-path and UB fix (“return the polling error”, “does not evaluate a shift”).

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES**

Record:
- File: drivers/media/cec/platform/stm32/stm32-cec.c — **+11 / −5** (16 lines in one function)
- Function: stm32_cec_adap_log_addr() only
- Scope: single-file surgical fix

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**

Record (verified against v6.18.53 and the candidate diff):

**Before** (at v6.18.53):

```c
u32 oar = (1 << logical_addr) << 16;
regmap_read_poll_timeout(...);  /* return value discarded */
regmap_update_bits(..., CECEN, 0);
if (logical_addr == CEC_LOG_ADDR_INVALID)
    clear OAR;
else
    set oar bits;
re-enable CECEN;
return 0;
```

**After:**
- Capture poll result; if nonzero, return it immediately (no CFGR write).
- Compute BIT(logical_addr) << 16 only in the valid-address branch.

Affected path: CEC logical-address claim and unconfigure (adap_log_addr), not probe/IRQ hot path.

**Step 2.3: IDENTIFY THE BUG MECHANISM**

Record:
- **(a) Error path:** ignored regmap_read_poll_timeout() result. Typical returns: -ETIMEDOUT or -EFAULT.
- **(g) Logic/correctness:** false success (return 0) after a failed wait.
- **(f/UBSAN):** (1 << logical_addr) with logical_addr == CEC_LOG_ADDR_INVALID (0xff in include/uapi/linux/cec.h) is an oversized shift (UB). Result is unused on that branch, but the expression is always evaluated first.

Hardware context (from 1a726df6078c2f): CFGR/OAR must be written only with CECEN=0, after TXSOM clears. On timeout the old code still toggled CECEN and wrote CFGR.

**Step 2.4: ASSESS THE FIX QUALITY**

Record:
- Obviously correct: check the value the wait already returned; don’t shift 0xff.
- Minimal; 1 << → BIT() is local to the valid-LA branch (BIT comes from linux/kernel.h → bitops.h → vdso/bits.h, already included).
- Regression risk: low. On timeout, cec_config_log_addr() already does if (err) return err. On unconfigure, cec_adap_unconfigure() does WARN_ON(call_op(..., CEC_LOG_ADDR_INVALID)), so a stuck TXSOM can now warn instead of silently returning 0. That is the existing core contract for a failed clear, not a new API. Timeout budget is CEC_XFER_TIMEOUT_MS = 2100 ms, so this is a stuck-TX path, not a normal claim.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**

Record:
- Function and return 0 / CECEN/OAR writes: d69ae57453c80a (“[media]
cec: add STM32 cec driver”, 2017) — first in **v4.13-rc1**.
- Poll without checking the result: 1a726df6078c2f (“media: platform:
stm32: wait end of transmission”, 2019) — first in **v5.2-rc1**.
- Buggy pattern has been in this line of kernels for years, including 6.18.y.

**Step 3.2: FOLLOW THE FIXES: TAG**

Record: No Fixes: tag. Buggy poll commit 1a726df6078c2f **is** an ancestor of HEAD and of v6.18.53. Intermediate related work on this
file: 0c260d3f97e52 (RX overflow OOB) is a separate bug, not a prerequisite.

**Step 3.3: CHECK FILE HISTORY**

Record: Recent file commits are cleanup/moves plus the RX OOB fix. This is standalone, not “patch X/Y”. No later follow-up on this function after the candidate.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**

Record: Pengpeng Hou is not the CEC maintainer. In this tree, the other hit under drivers/media/cec/ is unrelated (tegra MODULE_DEVICE_TABLE). Weight comes from **Hans Verkuil** (CEC FRAMEWORK maintainer in MAINTAINERS) signing off and committing upstream.

**Step 3.5: DEPENDENT/PREREQUISITE COMMITS**

Record: None. Uses existing regmap_read_poll_timeout, BIT(), CEC_LOG_ADDR_INVALID. Can apply standalone. Confirmed 1a726df6078c2f and d69ae57453c80a are in v6.18.53.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**

Record:
- b4 dig -c 3bc2e4a26465 →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only**, 2026-06-24, no later revisions
- lore.kernel.org fetches returned 403; discussion recovered from LKML/Openwall/Patchew mirrors. Patch body matches the commit. No replies on those archives.
- No reviewer NAK found. Hans Verkuil applied it (CommitDate Mon Jun 29 2026).

**Step 4.2: CHECK WHO REVIEWED THE PATCH**

Record (b4 dig -w): To/Cc included Hans Verkuil, Mauro Chehab, Maxime Coquelin, Alexandre Torgue, linux-media, linux-stm32, linux-arm- kernel, lkml. Right maintainers were on the submission. No extra Reviewed-by in the committed message.

**Step 4.3: SEARCH FOR THE BUG REPORT**

Record: No Reported-by / bugzilla / syzbot. Static/code-correctness fix, not a user crash report.

**Step 4.4: RELATED PATCHES AND SERIES**

Record: Standalone [PATCH], not a series. Sibling STM32 change 0c260d3f97e52 is a different RX OOB bug and already has Cc: stable.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**

Record: No usable stable-list hit for this subject (lore/stable blocked by anti-bot). UNVERIFIED that nobody previously rejected it for stable. No evidence of a known NAK.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: KEY FUNCTIONS**

Record: stm32_cec_adap_log_addr only. Registered as .adap_log_addr in stm32_cec_adap_ops.

**Step 5.2: TRACE CALLERS**

Record (call_op in drivers/media/cec/core/cec-priv.h):
- cec_config_log_addr() in cec-adap.c — claim path; error is returned to the config thread.
- cec_adap_unconfigure() — WARN_ON(call_op(..., CEC_LOG_ADDR_INVALID)); then core still marks the adapter unconfigured.

Called with adap->lock held from the CEC kthread / ioctl configuration path, not IRQ context.

**Step 5.3: TRACE CALLEES**

Record: regmap_read_poll_timeout, regmap_update_bits. Sleeps up to ~2.1 s. No alloc/new locks.

**Step 5.4: FOLLOW THE CALL CHAIN**

Record: Userspace CEC ioctls (CEC_ADAP_S_LOG_ADDRS / adapter enable- disable) → CEC core → adap_log_addr. Reachable on STM32 HDMI CEC (CONFIG_CEC_STM32, st,stm32-cec) without extra privilege beyond access to the CEC device node. Not a generic syscall bug on x86.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**

Record: Other platform CEC drivers (tegra, meson) check CEC_LOG_ADDR_INVALID before building a shift mask. Tegra still uses 1 << logical_addr only in the else branch. This STM32 driver was the one evaluating the shift first.

---

## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**

Record: **Yes**, at v6.18.53 in stm32_cec_adap_log_addr(). Introduced 2017 (shift) / 2019 (ignored poll). Upstream fix 3bc2e4a26465 is **not** an ancestor of HEAD (expected: it is a later mainline commit being evaluated). The autosel cherry-pick a1157fd7d1e0f is already on this branch; that is ignored as selection evidence.

**Step 6.2: BACKPORT COMPLICATIONS**

Record: **Clean apply.** Surrounding function at v6.18.53 matches the pre-image exactly. No refactor of this callback on 6.18.y.

**Step 6.3: RELATED FIXES ALREADY HERE**

Record: No earlier timeout-return or shift-guard on this function. RX OOB fix is independent.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: SUBSYSTEM AND CRITICALITY**

Record: drivers/media/cec/platform/stm32/ — STM32 HDMI CEC. **PERIPHERAL** (SoC HDMI-CEC), but a supported in-tree driver (CEC FRAMEWORK is Supported; Kconfig CEC_STM32 depends on ARCH_STM32 || COMPILE_TEST).

**Step 7.2: SUBSYSTEM ACTIVITY**

Record: File is mature (2017), low churn aside from tree-wide media cleanups and the recent RX OOB fix. This is an old bug, not a regression in brand-new code.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: WHO IS AFFECTED**

Record: Driver-specific / config-specific: STM32 boards with HDMI CEC (st,stm32-cec). Not universal.

**Step 8.2: TRIGGER CONDITIONS**

Record:
- **Timeout bug:** TXSOM stuck for >2.1 s while claiming or clearing a LA. Uncommon, but that is exactly the failure the 2019 wait was meant to cover. Unprivileged users with CEC device access can hit the claim path.
- **Shift UB:** every unconfigure (CEC_LOG_ADDR_INVALID = 0xff), a normal path when disabling/reconfiguring CEC.

**Step 8.3: FAILURE MODE SEVERITY**

Record:
- False-success LA update + CFGR write while TXSOM still set: CEC misconfiguration / possible controller or bus glitch. **MEDIUM** (functional/hardware-constraint), not a kernel oops.
- Shift UB on unconfigure: UBSAN-class undefined behavior; result unused on that branch, so not a typical oops. **MEDIUM**.

Not panic/UAF/corruption in the usual sense. Still a real correctness bug on a user-reachable path.

**Step 8.4: RISK-BENEFIT RATIO**

Record:
- **Benefit:** medium for STM32 CEC users — honest errors, no forbidden CFGR write after timeout, no 1 << 0xff.
- **Risk:** very low — ~16 lines, one function, no API/locking/data- structure change.
- Ratio: favorable. The new WARN_ON on unconfigure-timeout is the main behavioral change and only fires if the wait already failed.

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: EVIDENCE**

**FOR:**
- Real bugs: ignored poll error → false success and a CFGR write the driver itself documented as illegal during TX; UB shift of 0xff on unconfigure.
- Small, obviously correct, maintainer-acked (Hans Verkuil).
- Buggy code exists in this 6.18.y tree; applies cleanly; no prerequisites.
- Matches stable error-handling / UBSAN-shift patterns.

**AGAINST:**
- Peripheral STM32 HDMI CEC, not a core path.
- No user/syzbot report; timeout is rare.
- Failure is not a documented oops/CVE/deadlock.
- Unconfigure timeout can now WARN_ON (honest, but user-visible in dmesg).

**UNRESOLVED:**
- Full lore thread (403); no public review comments beyond maintainer application.
- Stable-list history not searchable here.

**Step 9.2: STABLE RULES CHECKLIST**

1. Obviously correct and tested? **PASS** — check existing return; maintainer merged it.
2. Fixes a real bug that affects users? **PASS** — false success and hardware-forbidden write; UB on unconfigure.
3. Important issue? **PASS** (medium) — not a panic, but incomplete timeout handling plus UBSAN-class shift on a normal unconfigure path. Driver fixes of this size are in-scope.
4. Small and contained? **PASS** — one function, +11/−5.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — pre-image matches v6.18.53.

**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**

Backport. The bugs exist in this 6.18 tree, the patch is surgical, and the risk is far smaller than leaving a wait whose result is discarded and a 1 << 0xff on every unconfigure.

---

### What the commit solves for this tree

On 6.18.53, stm32_cec_adap_log_addr() waits for TXSOM then always programs OAR and returns success. After a 2.1 s timeout that still writes CFGR, which the 2019 change said must not happen during transmit, and reports a successful LA update. Separately, unconfigure always evaluates (1 << 0xff) << 16 before the invalid-address check. The patch returns the poll error first and only builds the mask for valid LAs.

### Risk vs benefit

Benefit is correct CEC address programming and avoidance of a hardware- illegal register update and a shift UB. Risk is a few lines in one STM32 CEC callback; the only extra symptom is WARN_ON if unconfigure hits a stuck TXSOM.

---

### Verification

- **[Phase 1]** Parsed subject/tags from git log -1 / git show of a1157fd7d1e0f and upstream 3bc2e4a26465. No Fixes/Reported-by. Hans Verkuil SOB + committer.
- **[Phase 2]** Diff: +11/−5 in stm32_cec_adap_log_addr. Pre-image confirmed via git show v6.18.53:drivers/media/cec/platform/stm32/stm32-cec.c. CEC_LOG_ADDR_INVALID is 0xff.
- **[Phase 3]** git blame on the function: d69ae57453c80a (v4.13), poll 1a726df6078c2f (v5.2). git merge-base --is-ancestor of both vs v6.18.53 and HEAD: present. No Fixes: tag. No follow-ups after the candidate on this file.
- **[Phase 3]** git merge-base --is-ancestor 3bc2e4a26465 HEAD → not in this branch (mainline-only). Local cherry-pick is on autosel; ignored as selection evidence.
- **[Phase 4]** b4 dig -c/-a/-w: v1-only, msgid [email protected], correct maintainers CCed. lore.kernel.org 403; LKML/Openwall/Patchew matched the committed diff; no NAK found.
- **[Phase 4]** Stable-list search unusable (anti-bot). UNVERIFIED:
prior stable discussion.
- **[Phase 5]** Callers: cec_config_log_addr, cec_adap_unconfigure in cec-adap.c. call_op in cec-priv.h. Kconfig CEC_STM32.
- **[Phase 6]** git describe HEAD → v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion → 6.18.53. Buggy code at v6.18.53. Clean pre- image.
- **[Phase 7]** Peripheral STM32 CEC; maintainer Hans Verkuil.
- **[Phase 8]** Failure: false success + illegal CFGR write (MEDIUM); shift UB on unconfigure (MEDIUM). Risk very low.
- **UNVERIFIED:** live review comments on lore (403); whether UBSAN has actually fired on this shift in the field.

**YES**

 drivers/media/cec/platform/stm32/stm32-cec.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/media/cec/platform/stm32/stm32-cec.c +11 -5
index 8c2fc232202de..29418966a98ef 100644
@@ -194,18 +194,24 @@ static int stm32_cec_adap_enable(struct cec_adapter *adap, bool enable)
 static int stm32_cec_adap_log_addr(struct cec_adapter *adap, u8 logical_addr)
 {
 	struct stm32_cec *cec = adap->priv;
-	u32 oar = (1 << logical_addr) << 16;
 	u32 val;
+	int ret;
 
 	/* Poll every 100µs the register CEC_CR to wait end of transmission */
-	regmap_read_poll_timeout(cec->regmap, CEC_CR, val, !(val & TXSOM),
-				 100, CEC_XFER_TIMEOUT_MS * 1000);
+	ret = regmap_read_poll_timeout(cec->regmap, CEC_CR, val, !(val & TXSOM),
+				       100, CEC_XFER_TIMEOUT_MS * 1000);
+	if (ret)
+		return ret;
+
 	regmap_update_bits(cec->regmap, CEC_CR, CECEN, 0);
 
-	if (logical_addr == CEC_LOG_ADDR_INVALID)
+	if (logical_addr == CEC_LOG_ADDR_INVALID) {
 		regmap_update_bits(cec->regmap, CEC_CFGR, OAR, 0);
-	else
+	} else {
+		u32 oar = BIT(logical_addr) << 16;
+
 		regmap_update_bits(cec->regmap, CEC_CFGR, oar, oar);
+	}
 
 	regmap_update_bits(cec->regmap, CEC_CR, CECEN, CECEN);
 
Signature · 1 line
2.53.0
author maintainer
#375 lore raw

PATCH 1/1 ALSA: hda/realtek: Limit internal mic boost on HP Pavilion 15 (103c:2164)

In reply to Sasha Levin

From: Hernan Ganzo <[email protected]>

[ Upstream commit 786fb6b3f513937f712db5a9ba6a12cbc6982ba9 ]

The HP Pavilion 15 with the ALC3227 codec (SSID 103c:2164) exposes the full four-step internal mic boost on pin 0x12: nsteps=3 with stepsize=0x2f, that is 0, 12, 24 and 36 dB. Combined with the ADC capture gain of +30 dB the analogue cascade reaches 66 dB, and the internal microphone clips on the ambient noise of a quiet room; the upper two steps are unusable at any useful input level. This is the defect class ALC269_FIXUP_LIMIT_INT_MIC_BOOST exists for.

The machine matches no SSID quirk and falls through to the pin table, which selects ALC269_FIXUP_HP_MUTE_LED_MIC1 through a pin signature shared with several other HP models. Add an SSID entry instead, using ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED: the existing fixup that applies alc269_fixup_limit_int_mic_boost() and chains to the same mute LED fixup, as already done for 103c:218b. The boost becomes 0 or 12 dB and the LED handling is unchanged.

Tested on the affected machine by selecting the same fixup through the model string (snd-hda-intel.model), which bypasses the SSID and pin tables, with the driver confirming the selection:

snd_hda_codec_alc269 hdaudioC1D0: ALC3227: picked fixup limit-mic-boost (model specified)

With that, Internal Mic Boost reports Limits 0 - 1 (0 or 12 dB) instead of 0 - 3 (0 to 36 dB), so alc269_fixup_limit_int_mic_boost() clamps this codec's internal mic pin as intended. Note that /proc/asound/card1/codec#0 keeps printing the unclamped hardware caps (nsteps=0x03): that file reads codec parameters uncached by design, while the fixup overrides the driver's cached parameter that the control is built from.

This does not by itself make the default capture volume sane -- the remaining 12 dB on top of the +30 dB ADC gain is still hotter than this machine's usable operating point. It removes the two unusable steps from the hardware range, which is what a quirk of this class can do.

---

LLM Generated explanations, may be completely bogus:

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

Step 1.1: PARSE THE SUBJECT LINE
Record: [ALSA: hda/realtek] [Limit] [Add an SSID quirk so the HP Pavilion 15 (103c:2164) uses the existing internal-mic boost limiter plus mute-LED chain]

Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Link: https://patch.msgid.link/[email protected]
- Signed-off-by: Hernan Ganzo <[email protected]> (author)
- Signed-off-by: Takashi Iwai <[email protected]> (ALSA maintainer)
- Signed-off-by: Sasha Levin — ignored per instructions
- [ Upstream commit 786fb6b3f513937f712db5a9ba6a12cbc6982ba9 ] — ignored per instructions
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Cc:
stable (absence expected)

Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: HP Pavilion 15 ALC3227 (SSID 103c:2164) exposes a four-step internal mic boost (0/12/24/36 dB) on pin 0x12. With ADC capture gain of +30 dB the analogue cascade is 66 dB; the mic clips on quiet-room ambient noise. The top two steps are unusable.
- Symptom: Distorted/clipped internal-mic capture; Internal Mic Boost reports Limits 0–3.
- Root cause: No SSID quirk, so the machine falls through to the pin table and gets only ALC269_FIXUP_HP_MUTE_LED_MIC1 (mute LED, no boost clamp). This is the class ALC269_FIXUP_LIMIT_INT_MIC_BOOST exists for.
- Fix: Add SSID 103c:2164 using existing ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED (same as 103c:218b): clamp boost to 0 or 12 dB, keep mute LED.
- Tested on the affected machine via snd-hda-intel.model=limit-mic- boost; driver log confirmed the pick; mixer Limits became 0–1.
- Author notes the remaining 12 dB + 30 dB ADC is still hotter than ideal; the quirk only removes the two unusable steps.
- No kernel-version range given.

Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. It is an explicit hardware quirk: one SND_PCI_QUIRK for a known broken boost range.

===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================

Step 2.1: INVENTORY THE CHANGES
Record:
- File: sound/hda/codecs/realtek/alc269.c (+1 / −0)
- Function/table: alc269_fixup_tbl[] only
- Scope: single-file, one-line table insertion

Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Before: PCI SSID 103c:2164 is absent from alc269_fixup_tbl. snd_hda_pick_fixup() does not match; snd_hda_pick_pin_fixup() then selects ALC269_FIXUP_HP_MUTE_LED_MIC1 for a shared HP pin signature.
- After: SSID matches ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED. That fixup runs alc269_fixup_limit_int_mic_boost() and chains to ALC269_FIXUP_HP_MUTE_LED_MIC1.
- Path: codec probe / fixup selection. Other SSIDs unchanged.

Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Category: hardware workaround (quirk / device-ID table entry)
- Mechanism: hardware advertises nsteps=3, stepsize=0x2f. alc269_fixup_limit_int_mic_boost() calls snd_hda_override_amp_caps() on internal-mic pins so NUM_STEPS becomes 1 (0 or 12 dB). Without the SSID, that override never runs.

Verified in this tree (alc269.c):

```2371:2391:sound/hda/codecs/realtek/alc269.c
        /* The mic boosts on level 2 and 3 are too noisy
           on the internal mic input.
           Therefore limit the boost to 0 or 1. */
        ...
                snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
                                          (0x00 <<
AC_AMPCAP_OFFSET_SHIFT) |
                                          (0x01 <<
AC_AMPCAP_NUM_STEPS_SHIFT) |
                                          (0x2f <<
AC_AMPCAP_STEP_SIZE_SHIFT) |
                                          (0 << AC_AMPCAP_MUTE_SHIFT));
```

Chained fixup verified:

```4511:4516:sound/hda/codecs/realtek/alc269.c
        [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
                .type = HDA_FIXUP_FUNC,
                .v.func = alc269_fixup_limit_int_mic_boost,
                .chained = true,
                .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1,
        },
```

SSID lookup runs first; pin match is skipped once fixup_id is set (snd_hda_pick_pin_fixup() returns immediately if codec->fixup_id != HDA_FIXUP_ID_NOT_SET).

Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: reuses a 2013 combined boost+LED fixup already used for 103c:218b.
- Minimal: one sorted table line; no API, no new fixup enum.
- Regression risk: very low. Only SSID 103c:2164 is affected. Mute LED is the same chain the pin table already applied. Boost clamp only touches internal-mic amp caps at probe.
- Caveat (verified): on-machine testing used model string limit-mic- boost (ALC269_FIXUP_LIMIT_INT_MIC_BOOST, which chains ThinkPad ACPI, not HP mute LED). That proves the clamp works on this codec; SSID selection of the MUTE_LED variant is by construction (same boost function + same LED chain as the pin table).

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

Step 3.1: BLAME THE CHANGED LINES
Record:
- Insertion sits between 103c:18e6 (ALC269_FIXUP_HP_GPIO_LED) and 103c:218b (ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED).
- Combined fixup and 103c:218b come from 8e35cd4ac9967 (“ALSA: HDA - Limit mic boost and add mute LED for an HP machine”, 2013-11-06, David Henningsson / Takashi Iwai). That commit exists in this tree (git merge-base --is-ancestor 8e35cd4ac9967 HEAD → 0).
- Boost-limit helper has been in the Realtek HDA driver since that era; file later moved (6014e9021b28e) and split (aeeb85f26c3bb).

Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Not applicable. The “bug” is a missing per-board quirk, not a regression from a later commit.

Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: Recent alc269.c history is other per-machine quirks (HP mute LEDs, ASUS speakers, Star Labs mic boost). Same class of standalone entries. No prerequisite refactor needed for this one line.

Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Only this Realtek HDA commit from Hernan Ganzo in this tree. Signed off by Takashi Iwai, who maintains ALSA HDA and routinely merges these quirk lines.

Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: Standalone. Depends only on ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED, alc269_fixup_limit_int_mic_boost(), and alc269_fixup_tbl[], all present on v6.18.57. Neighboring 103c:18e6 / 103c:218b lines match the hunk context, so it applies cleanly to this series.

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 786fb6b3f513937f712db5a9ba6a12cbc6982ba9 →
https://patch.msgid.link/[email protected]
- b4 dig -a: single v1 series, 2026-09-21, Hernan Ganzo. No v2/v3.
- Thread (via b4 mbox): author patch + Takashi Iwai reply 2026-09-28:
“Applied now. Thanks.” No NAK, no requested changes, no stable discussion in-thread.
- lore WebFetch returned 403; thread recovered with b4 instead.

Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To/Cc [email protected], [email protected], [email protected]. Subsystem maintainer applied it. No other reviewers.

Step 4.3: SEARCH FOR THE BUG REPORT
Record: No bugzilla/syzbot/Launchpad link on this patch. Evidence is the author’s on-machine test (kmsg + mixer Limits). The 2013 sibling quirk 103c:218b had Launchpad 1248476 (same defect class: noisy internal mic + mute LED).

Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone, not part of a multi-patch series. Same table already has many ALC269_FIXUP_LIMIT_INT_MIC_BOOST* entries (ThinkPad, ASUS, Positivo, VAIO, Star Labs). 56b321df2863d “Limit Star Labs internal mic boost” is already in v6.18.57.

Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: UNVERIFIED. https://lore.kernel.org/stable/?q=... returned
403. No evidence in the sound thread that stable was discussed or rejected.

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: No function body changed. Data only: alc269_fixup_tbl[]. Runtime path: snd_hda_pick_fixup() → snd_hda_apply_fixup() → alc269_fixup_limit_int_mic_boost() + alc269_fixup_hp_mute_led_mic1().

Step 5.2: TRACE CALLERS
Record:
- alc269 probe (alc269.c ~8557) calls snd_hda_pick_fixup(codec, alc269_fixup_models, alc269_fixup_tbl, alc269_fixups).
- Then pin-table pick, which is a no-op once SSID matched.
- Probe/init path only, not IRQ or syscall hot path.

Step 5.3: TRACE CALLEES
Record: alc269_fixup_limit_int_mic_boost() uses snd_hda_codec_get_pincfg(), snd_hda_get_input_pin_attr(), snd_hda_override_amp_caps(). Mute LED helper registers LED cdev / power filter. All already used by other HP SSIDs.

Step 5.4: FOLLOW THE CALL CHAIN
Record: Reachable when this laptop enumerates HDA (boot / resume / module load). Not a userspace-exploit path; userspace mixer sees a smaller boost range. Unprivileged users benefit because capture is usable without a model= module option.

Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same table already maps 103c:218b to this exact fixup. Many other boards use ALC269_FIXUP_LIMIT_INT_MIC_BOOST. Systematic, well- worn pattern.

===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================

Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record:
- Local tree: v6.18.57-155-gcdf239ca885b2, make kernelversion = 6.18.57.
- Baseline v6.18.57: sound/hda/codecs/realtek/alc269.c exists; ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED exists; 103c:218b exists; **103c:2164 does not**.
- Without the line, this HP falls through to the pin table (ALC269_FIXUP_HP_MUTE_LED_MIC1 entries for codec 0x10ec0282 / vendor 0x103c are present). ALC3227 is the HP OEM name for 0x10ec0282 (realtek.c: { 0x10ec0282, 0x103c, 0, "ALC3227" }).
- Hardware defect is as old as the machine; software has never limited this SSID.

Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Clean apply. v6.18.57 context is identical to the hunk (0x18e6 then 0x218b). File path is already sound/hda/codecs/realtek/alc269.c on 6.18.y (move/split already landed).

Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No other 103c:2164 quirk. Sibling boost+LED fixup and Star Labs boost limit are already in v6.18.57. This SSID is the missing piece.

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: ALSA HD-audio Realtek codec (sound/hda/codecs/realtek/). IMPORTANT for laptop audio, not core mm/fs. Still a long-lived production driver.

Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: High activity: frequent one-line SND_PCI_QUIRK additions, routinely taken by Iwai. Mature quirk table; this is not new-subsystem code.

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver-specific / SSID-specific. Only HP Pavilion 15 with PCI SSID 103c:2164 (ALC3227). Other machines unchanged.

Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Always on that hardware: every probe, default mixer range includes 24/36 dB boost. No race. An unprivileged user using the internal mic hits it. Workaround today is snd-hda-intel.model=limit- mic-boost.

Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: Internal microphone clips / is unusable at the two highest boost steps (and noisy even at ambient). Not oops/deadlock/corruption.
Severity: MEDIUM for that machine, but it is a documented hardware quirk class that stable-kernel-rules explicitly include.

Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: high for owners of this SKU (usable capture range without a module option); zero for everyone else.
- Risk: very low (1 line, SSID-gated, existing fixup, maintainer- applied, tested).
- Ratio: strongly favorable.

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

Step 9.1: COMPILE THE EVIDENCE
FOR:
- One-line PCI/SSID quirk on an existing driver — stable-kernel-rules:
“fix a real bug that bothers people or just add a device ID”; “hardware quirk” is listed as in-scope.
- Real user-visible defect: 66 dB analogue cascade, clipping on quiet- room noise; author tested on the machine.
- Reuses ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED already in 6.18.y (103c:218b since 2013).
- Mute LED preserved via chain to the same pin-table fixup.
- Applies cleanly to v6.18.57; no new APIs; ALSA maintainer applied v1 with no objections.
- Same class as other boost-limit quirks already in this tree (e.g. Star Labs).

AGAINST:
- Not a crash/security/data-corruption fix; one laptop SKU.
- Author says remaining 12 dB + 30 dB ADC is still hotter than ideal (partial mitigation by design of this quirk class).
- Model-string test used limit-mic-boost, not the MUTE_LED SSID id (boost path still verified on hardware).

UNRESOLVED:
- Stable mailing-list search blocked (HTTP 403).
- lore WebFetch 403; discussion recovered via b4 mbox.

Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — one table line, existing fixup, on-machine test, maintainer “Applied now.”
2. Fixes a real bug that affects users? PASS — unusable internal-mic boost steps on this HP.
3. Important issue? PASS as hardware quirk (explicitly allowed); not CRITICAL crash.
4. Small and contained? PASS — +1 line, one file.
5. No new features or APIs? PASS — existing fixup ID only.
6. Can apply to the local tree? PASS — v6.18.57 has the file, fixup, and identical hunk context; 103c:2164 is missing on the 6.18.57 baseline.

Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Hardware quirk / device-ID addition to an existing driver. Automatic stable-qualifier.

Step 9.4: MAKE YOUR DECISION
This is a textbook stable HDA quirk: SSID-matched, one line, existing helper, real capture breakage on a shipping laptop, clean apply on 6.18.y. Include it.

What it solves for stable users: on HP Pavilion 15 103c:2164, Internal Mic Boost is clamped to 0/12 dB instead of 0–36 dB, so the mic no longer clips at the two hardware steps that this codec cannot use. Mute LED behavior stays the pin-table path.

Risk vs benefit: benefit is localized and real; risk is confined to that SSID and the helper has been in-tree for years.

Verification:
- [Phase 1] Parsed tags: Link msgid, SOB Ganzo + Iwai; no Fixes/Reported-by/Cc-stable
- [Phase 1] Body: 66 dB cascade, pin-table fallback to HP_MUTE_LED_MIC1, reuse of LIMIT_INT_MIC_BOOST_MUTE_LED
- [Phase 2] Diff: +1 SND_PCI_QUIRK(0x103c, 0x2164, ... LIMIT_INT_MIC_BOOST_MUTE_LED) in alc269_fixup_tbl
- [Phase 2] Read alc269_fixup_limit_int_mic_boost() and chained fixup in this tree
- [Phase 2] Read snd_hda_pick_fixup() / snd_hda_pick_pin_fixup():
SSID wins over pin table
- [Phase 3] git blame around insertion; git show 8e35cd4ac9967 (2013 218b/combined fixup); ancestor of HEAD
- [Phase 3] git log -S 'ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED' traces to 8e35cd4ac9967 via file moves
- [Phase 3] Author history: only this Realtek commit in-tree
- [Phase 4] b4 dig -c 786fb6b3...: lore URL; -a v1 only; -w linux- sound/tiwai/perex
- [Phase 4] b4 mbox: Iwai “Applied now. Thanks.”; no NAK
- [Phase 4] UNVERIFIED: lore WebFetch 403; stable list 403
- [Phase 5] Callers: alc269 probe → pick_fixup; clamp at HDA_FIXUP_ACT_PROBE
- [Phase 5] ALC3227 = 0x10ec0282 + HP 0x103c in realtek.c
- [Phase 6] git describe HEAD = v6.18.57-155-gcdf239ca885b2; make kernelversion = 6.18.57
- [Phase 6] git grep 0x2164 v6.18.57 -- alc269.c: absent; fixup and 218b present
- [Phase 6] Context at v6.18.57 matches the hunk (18e6 then 218b)
- [Phase 6] Star Labs boost-limit 56b321df2863d is ancestor of v6.18.57
- [Phase 7] ALSA HDA Realtek; quirk table still actively extended
- [Phase 8] Failure mode: clipped/unusable internal mic on one SSID; severity MEDIUM; hardware-quirk exception
- [Phase 9] Documentation/process/stable-kernel-rules.rst lines 15–20:
device ID / hardware quirk allowed

**YES**

 sound/hda/codecs/realtek/alc269.c | 1 +
 1 file changed, 1 insertion(+)
sound/hda/codecs/realtek/alc269.c +1 -0
index bc87062f86da7..10d930d8fed72 100644
@@ -6707,6 +6707,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
 	SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
 	SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
+	SND_PCI_QUIRK(0x103c, 0x2164, "HP Pavilion 15 Notebook PC", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
 	SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
 	SND_PCI_QUIRK(0x103c, 0x21f9, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
 	SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Signature · 1 line
2.53.0
author maintainer
#376 lore raw

PATCH 1/1 drm/panel: panel-edp: Adjust T8 timing for AUO B116XAK01.6 and B140XTK02.4

In reply to Sasha Levin

From: Dio Zhang <[email protected]>

[ Upstream commit 0d40cab39158704e372240ed9821a00bfe117125 ]

Screen garbage or flickering can be observed during mode changes (such as VT switches) on systems using the AUO B116XAK01.6 and B140XTK02.4 panels.

This occurs because the backlight is enabled before the video signal stabilizes. Waveform measurements show that the panel signal takes around 140ms to stabilize after a mode change, meaning the previous 50ms T8 timing was insufficient.

To resolve this issue, adjust the eDP panel delay entry from delay_200_500_e50 to delay_200_500_e200 (increasing T8 from 50ms to 200ms). This matches the updated panel specifications from AUO, which now formally define T8 as 200ms to mask any display abnormalities during mode changes.

---

LLM Generated explanations, may be completely bogus:

This checkout is **Linux 7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The change is a two-line eDP T8 delay quirk for two AUO panels. Both panel IDs and delay_200_500_e200 exist here; the fix is a hardware timing workaround, not a new API.

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

**Step 1.1: PARSE THE SUBJECT LINE**
Record: [drm/panel: panel-edp] [Adjust] [increase T8/enable delay from 50ms to 200ms for two AUO eDP panels]

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Dio Zhang <[email protected] partner.google.com> (author)
- Reviewed-by: Douglas Anderson <[email protected]> (panel-edp reviewer in MAINTAINERS)
- Signed-off-by: Douglas Anderson <[email protected]> (applied via drm-misc)
- `Link: https://patch.msgid.link/20260720025358.2781136-1-
[email protected]`
- No Fixes:, Reported-by:, Tested-by:, Acked-by:, or `Cc:
stable` (absence expected)
- Ignore any pipeline Upstream commit / Sasha Levin SOB (none present on the real commit)

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** On AUO B116XAK01.6 and B140XTK02.4, the backlight comes on before the video signal is stable after a mode change.
- **Symptom:** Screen garbage or flickering during mode changes (e.g. VT switches).
- **Root cause:** T8 (delay.enable) was 50ms; waveforms show ~140ms until the signal is stable. AUO’s updated spec now lists T8 as 200ms.
- **Fix:** Point those two EDP_PANEL_ENTRY rows at delay_200_500_e200 instead of delay_200_500_e50.
- **Versions:** none named in the message.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is an explicit hardware-timing fix for a user-visible display glitch.

===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/gpu/drm/panel/panel-edp.c — **2 insertions, 2 deletions** (4 lines with context).
- No functions rewritten; two table initializers in edp_panels[].
- Scope: single-file, surgical table tweak.

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Before: AUO 0x1ea5 (B116XAK01.6) and AUO 0x67a8 (B140XTK02.4) used delay_200_500_e50 (enable = 50).
- After: both use delay_200_500_e200 (enable = 200).
- Path: EDID-matched panel probe copies detected_panel->delay into desc->delay; panel_edp_enable() then msleep(delay.enable) before backlight-on. Only those two product IDs change.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** hardware workaround / timing quirk (T8 too short).
- **Mechanism:** backlight enabled while the panel still shows invalid frames; lengthening T8 masks the garbage until the signal is valid. Matches other delay_200_500_e200 users in the same table.

**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: reuses an existing delay struct; no new constants or control flow.
- Minimal; no unrelated edits.
- Regression risk is low and local: +150ms backlight-on delay only for those two EDID IDs. Maintainer Doug Anderson noted that longer delays “always stink, but sometimes is unavoidable,” then reviewed and applied the patch. No deadlock/API/locking change.

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Current lines are commit 0d40cab391587 (Dio Zhang, 2026-07-20) — this fix.
- B116XAK01.6 (0x1ea5) added in a70abdd994cb (“drm/panel-edp: Add AUO B116XAK01.6”, 2022-09-23) with delay_200_500_e50. Contained in v6.1-rc1.
- B140XTK02.4 (0x67a8) added in 4c34cdb93ea1 (2026-05-09) with delay_200_500_e50. Present in this 7.3 tree.
- delay_200_500_e200 first appeared in f6ff4570e567 (2022-07-20, “Add panel entry for R140NWF5 RH”), also v6.1-rc1 era.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable. The original panel-add commits used a conservative generic 50ms T8 that later proved too short for these two SKUs.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Same file has many “Fix delays for …” / “Modify … delay” commits (e.g. 43113fd4c5f56 INX N116BCA-EA2, 9abe13a0598a8 CMN 0x14d6). Established pattern.
- Follow-ups after 0d40cab are unrelated (I2C leak, new panel IDs, pre_unprepare).
- Standalone; not “patch X/Y”.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Dio Zhang has this one commit under drivers/gpu/drm/panel/. Douglas Anderson is the listed reviewer for DRM DRIVER FOR GENERIC EDP PANELS and authored/applied many panel-edp changes.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs edp_panels[], delay_200_500_e200, and the two EDP_PANEL_ENTRY rows. All exist in this tree. Standalone.

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 0d40cab391587: v2 at https://patch.msgid.link/202607200253
[email protected]
- b4 dig -a: v1 2026-07-17, v2 2026-07-20 (applied).
- v1 review (mbox): Doug asked only for a real name in SOB/authorship; no NAK; no stable debate.
- v2 review (mbox): Doug R-b’d, fixed subject to name both panels, noted it needed a trivial rebase onto drm-misc-next, pushed as 0d40cab391587.
- WebFetch of lore.kernel.org returned **403**; discussion recovered via b4 dig -m.

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc included [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], linux- [email protected]. Subsystem reviewer Doug Anderson both reviewed and applied it.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by / bugzilla / syzbot. Evidence is the author’s waveform measurements plus AUO’s updated T8=200ms spec. Compal/Google- partner author implies Chromebook-class hardware.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Single-patch series. v2 vs v1 is authorship/subject cleanup, same diff.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** — lore.kernel.org/stable WebFetch returned 403. No stable mention in the dri-devel mbox.

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: No function bodies edited. Runtime users of the table:
find_edp_panel(), panel identification in panel_edp_probe() path (desc->delay = *panel->detected_panel->delay), panel_edp_enable().

**Step 5.2: TRACE CALLERS**
Record:
- find_edp_panel() called from the generic eDP identification path (~line 820) after reading the EDID panel ID.
- panel_edp_enable is the DRM panel .enable callback (panel_edp_funcs).
- Called on modeset/enable (including VT switch), not a rare error path.

**Step 5.3: TRACE CALLEES**
Record: panel_edp_enable() uses msleep(delay) then panel_edp_wait() for prepare_to_enable / powered_on_to_enable. This change only increases the msleep for those two IDs.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace modeset / VT switch → DRM enable → panel_edp_enable() → extra 150ms wait → backlight. Reachable on any system whose eDP panel EDID is AUO 0x1ea5 or 0x67a8. CONFIG_DRM_PANEL_EDP (OF + backlight). Not a syscall memory-safety bug; it is a common display path for those laptops.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Many other panels already use delay_200_500_e200. Prior “Fix delays for …” commits in this file use the same table-pointer swap.

===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion: **7.3.0-rc4**.
- Both panel rows exist. git merge-base --is-ancestor 0d40cab391587 HEAD is true (this is mainline after the fix).
- Pre-fix state used delay_200_500_e50 for both IDs; that is the bug this tree’s history actually had. B116XAK01.6 has been in tree since v6.1-rc1; B140XTK02.4 since May 2026, also in 7.3.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Context in this tree matches the committed hunk (same vendor/product rows). delay_200_500_e200 is present. No structural mismatch. Forward git apply --check of the patch on current HEAD fails only because the after-image is already applied — expected on this mainline checkout.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This is the delay fix for those two IDs. No competing alternate T8 patch found on this file.

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/gpu/drm/panel/panel-edp.c — generic eDP panel driver. **IMPORTANT** for laptops/Chromebooks using generic eDP, not core mm/VFS. Peripheral relative to the whole kernel, but the driver is widely used.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively updated (panel IDs, delay tweaks, probe leak fixes). Mature table-driven delay model since ~2022.

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver-specific / hardware-specific: only EDID AUO 0x1ea5 and 0x67a8. No effect on other panels.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Mode changes such as VT switches (author). Common on laptops. Unprivileged users can trigger VT/modeset on typical distro setups. Not a security exploit path.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Screen garbage/flickering. Not oops/deadlock/corruption. **MEDIUM** user-visible display bug. Official stable rules explicitly list **hardware quirk** next to oops/hang as acceptable (Documentation/process/stable-kernel-rules.rst).

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** Stops garbage/flicker on two real AUO panels; matches vendor T8=200ms; waveform-backed (~140ms needed vs 50ms old).
- **Risk:** Very low — 2 pointer swaps, existing struct, +150ms enable delay only for those IDs.
- **Ratio:** Favorable. Same class as USB/PCI delay quirks that routinely go to stable.

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Real user-visible bug (garbage/flicker on VT/mode change), measured and spec-backed.
- Hardware quirk / timing workaround — allowed by stable-kernel-rules.
- 2-line table change; existing delay_200_500_e200; no new API/feature.
- Reviewed and applied by panel-edp reviewer Douglas Anderson.
- Both panel IDs and delay helper exist in this 7.3 tree.
- Isolated to two EDID IDs.

AGAINST:
- Not a crash, UAF, or data-corruption bug.
- +150ms backlight delay (maintainer accepted that tradeoff).
- No Reported-by from multiple end users / no syzbot.
- Stable list discussion could not be fetched (lore 403).

UNRESOLVED:
- Could not read lore.kernel.org/stable (HTTP 403).
- Could not independently view AUO datasheets (not in-tree).

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — reuses existing delay struct; maintainer review; author reports waveform data.
2. Fixes a real bug that affects users? **PASS** — garbage/flicker on mode change.
3. Important issue? **PASS** as hardware quirk (documented exception); severity MEDIUM visual, not CRITICAL crash.
4. Small and contained? **PASS** — 2 lines, one table.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — target rows, delay_200_500_e200, and enable path all exist here.

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Hardware quirk/workaround** (panel power-sequence delay, analogous to USB delay quirks).

**Step 9.4: MAKE YOUR DECISION**
This tree has the driver, both panel IDs, and the 200ms delay helper. The change is a small, reviewed T8 quirk that fixes real display garbage on mode changes. That meets stable rules for this checkout.

Verification:
- [Phase 1] Parsed tags: Reviewed-by/SOB Douglas Anderson; Link to msgid; no Fixes/Reported-by/Cc:stable
- [Phase 1] Body: VT-switch garbage; T8 50ms vs ~140ms measured; AUO spec T8=200ms
- [Phase 2] Diff: two EDP_PANEL_ENTRY pointer swaps in edp_panels[]; +2/-2
- [Phase 2] delay_200_500_e50.enable=50, delay_200_500_e200.enable=200 verified in panel-edp.c
- [Phase 2] panel_edp_enable() msleep(p->desc->delay.enable); probe copies detected_panel->delay
- [Phase 3] git show 0d40cab391587: confirmed subject/body/stat
- [Phase 3] git merge-base --is-ancestor 0d40cab391587 HEAD → yes (already in 7.3-rc4 history; not used as circular “already selected” reasoning)
- [Phase 3] git blame on the two rows: this commit; origins a70abdd994cb (v6.1-rc1) and 4c34cdb93ea1 (2026-05, in this tree)
- [Phase 3] delay_200_500_e200 introduced f6ff4570e567 (v6.1-rc1 era)
- [Phase 3] Similar delay-fix pattern: 43113fd4c5f56 and others in the same file
- [Phase 4] b4 dig -c 0d40cab391587: v2 lore URL; -a: v1+v2; -w:
dri-devel + dianders
- [Phase 4] mbox: v1 name-only feedback; v2 Reviewed-by + pushed to drm- misc-next; no NAK
- [Phase 4] WebFetch lore/stable: 403 — UNVERIFIED stable-list history
- [Phase 5] Call chain: EDID match → delay table → panel_edp_enable on modeset; CONFIG_DRM_PANEL_EDP
- [Phase 6] git describe HEAD / make kernelversion: 7.3.0-rc4; both IDs and e200 present
- [Phase 7] MAINTAINERS: Douglas Anderson reviewer for panel-edp.c
- [Phase 8] Failure mode: display garbage, MEDIUM; official rules include hardware quirk
- [Phase 9] stable-kernel-rules.rst lines 15–20: quirk is an accepted class
- UNVERIFIED: AUO datasheet text; stable@ mailing-list traffic

The fix is small, confined to two EDID entries, and is the usual panel- edp delay quirk pattern. Benefit outweighs the extra 150ms enable wait on just those panels.

**YES**

 drivers/gpu/drm/panel/panel-edp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/panel/panel-edp.c +2 -2
index 0da04d75e4e96..614c63e95c357 100644
@@ -1901,7 +1901,7 @@ static const struct edp_panel_entry edp_panels[] = {
 	EDP_PANEL_ENTRY('A', 'U', 'O', 0x145c, &delay_200_500_e50, "B116XAB01.4"),
 	EDP_PANEL_ENTRY('A', 'U', 'O', 0x1999, &delay_200_500_e50, "Unknown"),
 	EDP_PANEL_ENTRY('A', 'U', 'O', 0x1e9b, &delay_200_500_e50, "B133UAN02.1"),
-	EDP_PANEL_ENTRY('A', 'U', 'O', 0x1ea5, &delay_200_500_e50, "B116XAK01.6"),
+	EDP_PANEL_ENTRY('A', 'U', 'O', 0x1ea5, &delay_200_500_e200, "B116XAK01.6"),
 	EDP_PANEL_ENTRY('A', 'U', 'O', 0x203d, &delay_200_500_e50, "B140HTN02.0"),
 	EDP_PANEL_ENTRY('A', 'U', 'O', 0x208d, &delay_200_500_e50, "B140HTN02.1"),
 	EDP_PANEL_ENTRY('A', 'U', 'O', 0x235c, &delay_200_500_e50, "B116XTN02.3"),
@@ -1921,7 +1921,7 @@ static const struct edp_panel_entry edp_panels[] = {
 	EDP_PANEL_ENTRY('A', 'U', 'O', 0x635c, &delay_200_500_e50, "B116XAN06.3"),
 	EDP_PANEL_ENTRY('A', 'U', 'O', 0x639c, &delay_200_500_e50, "B140HAK02.7"),
 	EDP_PANEL_ENTRY('A', 'U', 'O', 0x643d, &delay_200_500_e50, "B140HAN06.4"),
-	EDP_PANEL_ENTRY('A', 'U', 'O', 0x67a8, &delay_200_500_e50, "B140XTK02.4"),
+	EDP_PANEL_ENTRY('A', 'U', 'O', 0x67a8, &delay_200_500_e200, "B140XTK02.4"),
 	EDP_PANEL_ENTRY('A', 'U', 'O', 0x723c, &delay_200_500_e50, "B140XTN07.2"),
 	EDP_PANEL_ENTRY('A', 'U', 'O', 0x73aa, &delay_200_500_e50, "B116XTN02.3"),
 	EDP_PANEL_ENTRY('A', 'U', 'O', 0x8594, &delay_200_500_e50, "B133UAN01.0"),
Signature · 1 line
2.53.0
author maintainer
#377 lore raw

PATCH 1/1 md/raid5: reject zero-sector reshape chunks

In reply to Sasha Levin

From: Yu Kuai <[email protected]>

[ Upstream commit a41bb2ee1aca486853e84920565e50c15f86fa5d ]

Sashiko reported that RAID5 can accept a reshape chunk size that becomes zero sectors. chunk_size_store() stores the sysfs byte value as n >> 9, so writing a value below 512 bytes sets mddev->new_chunk_sectors to zero. RAID5 then accepted that pending reshape geometry and raid5_start_reshape() installed it into conf->chunk_sectors, letting reshape code divide by zero.

Reject zero-sector chunks both in check_reshape(), where normal sysfs requests are validated, and in raid5_start_reshape(), so assembly/resume paths also cannot install zero chunk geometry.

Test script: in QEMU, create a plain three-disk RAID5 array with 64K chunks, write/read back a small pattern, write 1 to /sys/block/md0/md/chunk_size, add a fourth disk, and run mdadm --grow --raid-devices=4 --backup-file=... . The script scans dmesg for divide error/Oops/KASAN signatures.

Bad kernel, eb29914412c3:

  echo 1 > /sys/block/md0/md/chunk_size
  mdadm --grow /dev/md0 --raid-devices=4 --backup-file=/root/md0-grow.bak
  Oops: divide error: 0000 [#1] SMP KASAN NOPTI
  RIP: raid5_get_active_stripe+0x863/0xc10
  Call Trace:
   raid5_sync_request
   md_do_sync
   md_thread
  Kernel panic - not syncing: Fatal exception

Fixed kernel: echo 1 > /sys/block/md0/md/chunk_size bash: echo: write
error: Invalid argument chunk_write_rc=1 grow_rc=skipped RESULT:
REJECTED_ZERO_CHUNK_NO_OOPS

---

LLM Generated explanations, may be completely bogus:

This is a **5-line RAID5 input-validation fix** for a divide-by-zero panic during reshape. The local tree is **6.18.53** (pending-6.18); the buggy path is present and the patch applies.

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

Step 1.1: PARSE THE SUBJECT LINE
Record: **[md/raid5] [reject] reject zero-sector reshape chunks**

Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- **Tested-by:** Mykola Marzhan <[email protected]> (independent QEMU reproduction)
- **Link:** https://patch.msgid.link/[email protected] (v5 04/29)
- **Signed-off-by:** Yu Kuai <[email protected]> (MD RAID co-maintainer)
- No **Fixes:**, **Reported-by:**, **Cc: stable**, **Reviewed-by**, or **Acked-by** on the committed message (absence of Fixes/Cc:stable is expected for this review)
- Body names **Sashiko** as the reporter (test harness, not syzbot)
- Bad-kernel SHA cited: eb29914412c3

Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** chunk_size_store() does n >> 9. A sysfs write below 512 bytes stores mddev->new_chunk_sectors = 0. RAID5 accepts that geometry; raid5_start_reshape() copies it into conf->chunk_sectors.
- **Symptom:** Oops: divide error in raid5_get_active_stripe, call chain raid5_sync_request → md_do_sync → md_thread, then **kernel panic**.
- **Trigger:** RAID5 array, echo 1 > /sys/block/md0/md/chunk_size, then mdadm --grow --raid-devices=4.
- **Fix:** return -EINVAL in check_reshape() and raid5_start_reshape() when new_chunk_sectors is zero.
- **Fixed result:** sysfs write returns Invalid argument; grow is skipped; no oops.

Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not hidden. Explicit panic fix with a reproduction and a before/after result.

===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================

Step 2.1: INVENTORY THE CHANGES
Record:
- **File:** drivers/md/raid5.c only (**+5 / −0**)
- **Functions:** check_reshape(), raid5_start_reshape()
- **Scope:** single-file surgical validation

Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- **Hunk 1 (check_reshape):** after has_failed(), add if (!mddev->new_chunk_sectors) return -EINVAL. Sysfs/mdadm reshape checks that previously accepted 0 now fail. chunk_size_store() then restores new_chunk_sectors to the live chunk size.
- **Hunk 2 (raid5_start_reshape):** after MD_RECOVERY_RUNNING busy- check, same reject. Covers start-reshape, assembly, and resume so zero geometry cannot be installed into conf->chunk_sectors.

Step 2.3: IDENTIFY THE BUG MECHANISM
Record: **[Logic / correctness + divide-by-zero]** raid5_check_reshape() only validates chunk size when new_chunk > 0, so **0 skips the power-of-two / PAGE_SIZE checks**. check_reshape() then treats 0 != current chunk as a real reshape. raid5_start_reshape() does conf->chunk_sectors = mddev->new_chunk_sectors. stripe_set_idx() / raid5_compute_sector() then sector_div(..., conf->chunk_sectors) with divisor 0.

Step 2.4: ASSESS THE FIX QUALITY
Record: Obviously correct. Two -EINVAL guards, no API/locking/data- structure change. Regression risk is rejecting a reshape that previously panics. Normal grow does not use chunk size 0: setup_conf() already requires a non-zero chunk, and running arrays keep new_chunk_sectors == chunk_sectors.

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

Step 3.1: BLAME THE CHANGED LINES
Record:
- Zero-chunk reject in **setup_conf()** since **Andre Noll, 2009** (664e7c413f1e9) — array *start* is safe.
- raid5_check_reshape() if (new_chunk > 0) hole since **Neil Brown, 2009** (b3546035277847).
- chunk_size_store() n >> 9 since **2009**.
- conf->chunk_sectors = mddev->new_chunk_sectors in raid5_start_reshape() since **2009** (09c9e5fa1b93ad).
- Bug is long-standing, not new 6.18 code.

Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Introducer is the 2009 n >> 9 store plus the new_chunk > 0 skip, both in this tree.

Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- This tree **already has** series patch 05: `02c10581866d0 md/raid5:
round bitmap stripes with sector division (upstream 17ea021ae7498`).
- This commit (series 04, a41bb2ee1aca4) is **not** an ancestor of HEAD.
- Cover letter: first five patches are **standalone** RAID5/llbitmap correctness fixes. 04 does not depend on 05; 05 being present does not replace 04.

Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Yu Kuai is listed in MAINTAINERS as **SOFTWARE RAID** co- maintainer with Song Liu. Frequent drivers/md/raid5.c contributor.
Weight: high.

Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: None. Adds two comparisons on existing mddev->new_chunk_sectors. git apply --check of a41bb2ee1aca4 **succeeded** (hunks at 8445 and 8490, offset −103).

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- **b4 dig -c a41bb2ee1aca4:** [PATCH v5 04/29] md/raid5: reject zero- sector reshape chunks — https://patch.msgid.link/[email protected]
- Series: **v5 of 29**, “md: improve lockless bitmap reshape support”
- This check was **added in v3** (“Add patch 4 to reject zero-sector RAID5 reshape chunks”); v4/v5 keep the same diff.
- Cover letter: *“The first five patches fix standalone llbitmap and RAID5 correctness issues that are independent of reshape.”*
- No NAK found on patchew/LKML/openwall mirrors. lore.kernel.org fetch returned **403**; discussion taken from b4, patchew, LKML IU, and openwall.

Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: **b4 dig -w** To/Cc: Song Liu, Li Nan, Xiao Ni, linux-raid, linux-kernel, Mykola Marzhan, Su Yue. Subsystem maintainers were on the original mail. No Reviewed-by on this specific commit; series v1 had Reviewed-by from Su Yue on other patches.

Step 4.3: SEARCH FOR THE BUG REPORT
Record: Reproduced in QEMU with an oops/panic log. **Tested-by** Mykola Marzhan. Not syzbot. Trigger is crafted (write 1 then grow) but the oops is real.

Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: 29-patch llbitmap reshape series. **This patch is standalone (04/29).** Later patches add llbitmap reshape; they are not required for this reject.

Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: No stable@ thread found for this subject. UNVERIFIED beyond web search (lore.kernel.org/stable also 403).

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: check_reshape(), raid5_start_reshape(). Callers of the
first: raid5_check_reshape(), raid6_check_reshape() (raid4/5/6 pers->check_reshape).

Step 5.2: TRACE CALLERS
Record:
- check_reshape via sysfs: chunk_size_store(), layout_store(), raid_disks_store → update_raid_disks(), action_store (“reshape”), plus ioctl/md_check_recovery.
- raid5_start_reshape: pers->start_reshape from action/ioctl/assembly when a reshape starts or is resumed.
- Context: md thread / reconfig, not IRQ.

Step 5.3: TRACE CALLEES
Record: After the new checks, existing check_stripe_cache(), has_failed(), resize_chunks(), and geometry install. The dangerous callee is later sector_div on conf->chunk_sectors.

Step 5.4: FOLLOW THE CALL CHAIN
Record (verified in this tree):
1. chunk_size_store() (drivers/md/md.c:4492) `new_chunk_sectors = n

Quoted 1 line
Quoted 1 line

9 (write 1` → 0).

2. raid5_check_reshape() (8793) skips validation because `new_chunk

Quoted 1 line

0 is false (8805`).

3. check_reshape() (8436) has **no** zero reject; 0 != chunk_sectors so it does not take the “nothing to do” return.
4. mdadm --grow → raid5_start_reshape() (8533) conf->chunk_sectors = mddev->new_chunk_sectors (**0**).
5. Reshape sync: raid5_sync_request → raid5_get_active_stripe → init_stripe → stripe_set_idx (3576) **sector_div(stripe, sectors_per_chunk) with 0** → divide error.

Userspace-reachable via sysfs + mdadm; chunk_size is S_IWUSR (root).

Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: setup_conf() already rejects !new_chunk_sectors (7524). Reshape is the missing twin of that start-time check. new_chunk_sectors = 0 elsewhere is array teardown (md.c reset), not a live RAID5 reshape sentinel.

===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================

Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: **Yes.** Tree is **v6.18.53 / pending-6.18** (git describe:
p-6.18-1-g03b85e06ca9bf). a41bb2ee1aca4 is **not** an ancestor of HEAD. Hole is at check_reshape() 8436 and raid5_start_reshape() 8480; store is md.c:4492.

Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **Clean apply** (git apply --check exit 0, offset −103 only). Insertion points match: after has_failed() and after MD_RECOVERY_RUNNING.

Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No zero-sector reshape commit in this tree. Sibling 05 is present; it does not reject zero chunks. setup_conf() zero check does not cover reshape.

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: **md/raid5 (software RAID)** — **IMPORTANT**. RAID5 reshape is a production path (grow/shrink/layout change).

Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Actively maintained (raid5.c still getting lock/bitmap/discard fixes). This hole is old (2009), not a new-feature bug.

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

Step 8.1: DETERMINE WHO IS AFFECTED
Record: **Driver-specific:** RAID4/5/6 users who reshape (or resume a reshape) after a sub-512 chunk_size sysfs write, or with a superblock new_chunk that becomes 0.

Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Not every boot. Needs a running RAID5/6, privileged sysfs write < 512 to chunk_size, then reshape (or resume with zero new-chunk in metadata). Unprivileged users normally cannot write that sysfs file. Still a real panic for admins, scripts, and test/fuzz tools.

Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: **Kernel oops + panic (divide-by-zero).** **CRITICAL.**

Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record: **Benefit: high** (stops a proven panic). **Risk: very low** (5 lines, error-path -EINVAL only). Ratio strongly favors backport.

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

Step 9.1: COMPILE THE EVIDENCE

**FOR:**
- Proven divide-by-zero panic with call trace and QEMU repro.
- Same hole exists in this 6.18.53 tree (n >> 9, if (new_chunk > 0) skip, unconditional install in raid5_start_reshape).
- 5-line, obviously correct guards; apply-check clean.
- Standalone per author cover letter; no new APIs.
- MD co-maintainer author; Tested-by from a third party.
- setup_conf() already rejects 0; reshape was the gap.

**AGAINST:**
- Privileged, somewhat artificial trigger (echo 1 then grow).
- Nested in a 29-patch series (mitigated: explicitly standalone).
- No Fixes:/Cc:stable (expected here; not a negative).

**UNRESOLVED:**
- Full lore.kernel.org HTML was 403; used b4 + mirrors.
- No stable@ discussion found.

Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — two guards; Tested-by; before/after log.
2. Fixes a real bug that affects users? **PASS** — oops/panic on RAID5 reshape.
3. Important issue? **PASS** — **CRITICAL** kernel panic.
4. Small and contained? **PASS** — +5 lines, one file.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — apply-check succeeded; bug present.

Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Not an ID/quirk/DT/docs exception. It is a normal stability fix.

Step 9.4: MAKE YOUR DECISION
Backport to this 6.18.53 tree. It closes a long-standing validation hole that panics the kernel, with negligible regression risk.

===============================================================
What the commit solves for this tree
===============================================================

On 6.18.53, writing a sub-512 value to /sys/block/mdX/md/chunk_size stores zero sectors. RAID5 reshape validation treats 0 as “no chunk change” in raid5_check_reshape(), then accepts it in check_reshape(), and raid5_start_reshape() installs 0 into conf->chunk_sectors. Reshape then divides by zero in stripe_set_idx() / raid5_compute_sector() and panics.

The patch rejects that geometry at the two points that can install it. That matches setup_conf()’s existing start-time check and does not change normal mdadm --grow (which keeps the current non-zero chunk).

Risk vs benefit: five lines of -EINVAL versus a documented panic. Apply is clean. Series membership is not a blocker; the cover letter calls this patch standalone, and this tree already took the following patch (05) without this one.

===============================================================
Verification
===============================================================

- **[Phase 1]** Parsed tags: Tested-by Mykola Marzhan; Link msgid 20260802195038.164272-5; SoB Yu Kuai; no Fixes/Cc:stable. Subject/body describe divide-by-zero panic.
- **[Phase 2]** Diff: +5 in check_reshape and raid5_start_reshape only. Confirmed raid5_start_reshape assigns conf->chunk_sectors = mddev->new_chunk_sectors at raid5.c:8533.
- **[Phase 3]** git merge-base --is-ancestor a41bb2ee1aca4 HEAD → not in tree (exit 1). Blame: n >> 9 and new_chunk > 0 from 2009. Author is MD co-maintainer (MAINTAINERS SOFTWARE RAID).
- **[Phase 3]** git apply --check of a41bb2ee1aca4 → success, offset −103.
- **[Phase 3]** Sibling 05 02c10581866d0 is already in HEAD; 04 is not. Cover letter: first five patches standalone.
- **[Phase 4]** b4 dig -c a41bb2ee1aca4 → v5 04/29, msgid.link above. b4 dig -w → Song Liu, linux-raid, testers. Patch added in v3; v5 matches committed diff. lore.kernel.org WebFetch 403.
- **[Phase 4]** patchew/LKML/openwall: same patch text; Mykola Tested-by on the series; no NAK found.
- **[Phase 5]** Call path verified in this tree: chunk_size_store (md.c:4492) → raid5_check_reshape (if (new_chunk > 0) at 8805) → check_reshape (no zero check) → raid5_start_reshape install → stripe_set_idx sector_div at 3576. setup_conf already rejects 0 at 7524.
- **[Phase 6]** git describe HEAD = p-6.18-1-g03b85e06ca9bf; make kernelversion = **6.18.53**; branch pending-6.18. Buggy code present; no existing zero-sector reshape fix.
- **[Phase 7]** md/raid5, IMPORTANT, actively maintained.
- **[Phase 8]** Failure mode: divide error oops + panic. Severity CRITICAL. Trigger: privileged sysfs + reshape. Benefit high, risk very low.
- **UNVERIFIED:** Full lore.kernel.org thread HTML (HTTP 403); no stable@ hit beyond web search.

**YES**

 drivers/md/raid5.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/md/raid5.c +5 -0
index b7da2b83e1938..56d7e05e94ce6 100644
@@ -8437,6 +8437,8 @@ static int check_reshape(struct mddev *mddev)
 		return 0; /* nothing to do */
 	if (has_failed(conf))
 		return -EINVAL;
+	if (!mddev->new_chunk_sectors)
+		return -EINVAL;
 	if (mddev->delta_disks < 0 && mddev->reshape_position == MaxSector) {
 		/* We might be able to shrink, but the devices must
 		 * be made bigger first.
@@ -8480,6 +8482,9 @@ static int raid5_start_reshape(struct mddev *mddev)
 	if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))
 		return -EBUSY;
 
+	if (!mddev->new_chunk_sectors)
+		return -EINVAL;
+
 	if (!check_stripe_cache(mddev))
 		return -ENOSPC;
 
Signature · 1 line
2.53.0
author maintainer
#378 lore raw

PATCH 1/1 ALSA: usb-audio: Add mixer mapping for MSI MAG B850M MORTAR WIFI

In reply to Sasha Levin

From: Tomasz Bojanowski <[email protected]>

[ Upstream commit 7b457ae8cf711831f19d20963f5ed2fdf4842d3a ]

The USB audio device 0db0:cc78 (Realtek ALC4080) on the MSI MAG B850M MORTAR WIFI motherboard exposes all playback controls as "PCM", which makes it hard to tell the outputs apart.

Its mixer layout matches the one of the MSI MPG X570S Carbon Max Wifi (units 29, 30 and 32), so reuse msi_mpg_x570s_carbon_max_wifi_alc4080_map for this device too. With the mapping applied, the controls show up as "Speaker", "Front Headphone" and "IEC958".

Tested with a patched snd-usb-audio module on a 7.2.7 kernel.

---

LLM Generated explanations, may be completely bogus:

This is a four-line USB mixer-map ID addition for an existing snd-usb- audio quirk table. The local tree is **6.18.57**; the reused ALC4080 map is already here, and the new ID is not in v6.18.57.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[ALSA/usb-audio] [Add] mixer mapping for MSI MAG B850M MORTAR WIFI (USB ID 0db0:cc78)**

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected for this review class)
- **Reported-by:** none
- **Tested-by:** none as a tag; body says the author tested a patched snd-usb-audio on **7.2.7**
- **Reviewed-by / Acked-by:** none in the commit; mailing-list apply-ack from Takashi Iwai
- **Link:** https://patch.msgid.link/[email protected]
- **Cc: stable:** absent (not a negative signal)
- **Signed-off-by:** Tomasz Bojanowski (author); Takashi Iwai <[email protected]> (SOUND maintainer). Ignore Sasha Levin.

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** USB audio 0db0:cc78 (Realtek ALC4080 on MSI MAG B850M MORTAR WIFI) exposes every playback control as "PCM", so speaker, front headphone, and S/PDIF cannot be told apart.
- **Symptom:** unusable/ambiguous mixer controls; PulseAudio/PipeWire/UCM cannot bind the right output.
- **Root cause:** generic USB mixer names; layout matches existing MSI ALC4080 maps (units 29, 30, 32).
- **Fix:** reuse msi_mpg_x570s_carbon_max_wifi_alc4080_map.
- **Version info:** tested on 7.2.7; hardware is a current AM5 board, so 6.18.y users have this device.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not a hidden fix.** It is an explicit hardware quirk / mixer- map ID addition. Not cleanup or a new API.

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES** Record:
- **File:** sound/usb/mixer_maps.c — **+4 / −0**
- **Function/data:** usbmix_ctl_maps[] only
- **Scope:** single-file surgical table entry

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: **Before:** snd_usb_mixer_controls() walks usbmix_ctl_maps; 0x0db0:0xcc78 misses, so units keep generic "PCM" names. **After:** that ID selects msi_mpg_x570s_carbon_max_wifi_alc4080_map, and find_map() / check_mapped_name() rename units 29/30/32. Probe-time mixer build only; other USB IDs unchanged.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Hardware workaround / USB mixer-map ID]** — same pattern as PCI/USB ID additions. No leak, race, or crash.

Verified map in this tree:

```476:481:sound/usb/mixer_maps.c
static const struct usbmix_name_map
msi_mpg_x570s_carbon_max_wifi_alc4080_map[] = {
        { 29, "Speaker Playback" },
        { 30, "Front Headphone Playback" },
        { 32, "IEC958 Playback" },
        {}
};
```

Lookup in snd_usb_mixer_controls():

```3278:3286:sound/usb/mixer.c
        for (map = usbmix_ctl_maps; map->id; map++) {
                if (map->id == state.chip->usb_id) {
                        state.map = map->map;
                        state.selector_map = map.selector_map;
                        mixer->connector_map = map->connector_map;
                        break;
                }
        }
```

**Step 2.4: ASSESS THE FIX QUALITY**
Record: **Obviously correct.** Four lines, reuses a 2022 map already used for two MSI ALC4080 IDs. **Regression risk: very low** — scoped to one USB ID; wrong names would only affect that board, and the author tested it. No locking, allocation, or API change.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**
Record: Candidate lines blamed to 53b3abbe6e262 (this patch). Reused map from **5762f980ca10d** (Johannes Schickel, 2022-01-15, “add mapping for MSI MPG X570S Carbon Max Wifi”). Sibling ID 0x0db0:0xa073 from **4ddef9c4d70aa** (2022-04-18, Torpedo Max). Neighboring usbmix_ctl_maps MSI/ASUS entries date to 2020.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Bug is missing a device-specific map, not a regression from a named commit. Prerequisite map **is** in this series:
git merge-base --is-ancestor 5762f980ca10d v6.18.57 → yes; same for 4ddef9c4d70aa.

**Step 3.3: CHECK FILE HISTORY**
Record: Recent mixer_maps.c work is more ID/quirk entries (Corsair Virtuoso, Razer Barracuda dB map, KTMicro rename, Corsair HS80). **Standalone.** No “patch X/Y”.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Only this ALSA commit in-tree. Author is a hardware reporter, not the maintainer. Weight comes from **Takashi Iwai** applying it.

**Step 3.5: DEPENDENT/PREREQUISITE COMMITS**
Record: Needs msi_mpg_x570s_carbon_max_wifi_alc4080_map and usbmix_ctl_maps[]. Both exist at v6.18.57. **Applies standalone.**

Precedent: Torpedo Max (4ddef9c4d70aa) is the same reuse and carried **Cc: [email protected]**. This 6.18.y tree already has later mixer-map ID quirks (5144ddfb71c18 Corsair Virtuoso later revision, a7de2b873f3db HS80, 93adf20ff4d6e KTMicro) — git merge-base --is- ancestor of each vs v6.18.57 is true.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 53b3abbe6e262 →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only**, 2026-09-23
- Thread: submission + Takashi Iwai **“Applied now. Thanks.”** (2026-09-28). **No NAK, no revision requests, no stable discussion in- thread.**

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc **Takashi Iwai**, **Jaroslav Kysela**, linux-sound, linux-kernel. Right maintainers. Maintainer applied v1 unchanged.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No bugzilla/syzbot. Author hit it on real hardware. Related
userspace: alsa-ucm-conf PR #581 (“add UCM2 support for MSI MAG B850M Mortar Wifi (ALC4080)”) describes **front-panel and S/PDIF routing problems** on this board. Kernel mixer names matter for UCM. That PR is supporting context, not a second kernel report.

**Step 4.4: RELATED PATCHES AND SERIES**
Record: Standalone 1/1. A later lore subject “USB-Audio: add MSI MAG B850M Mortar **Max** WiFi (0db0:83ed)” is a **different** USB ID — not a dependency.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable/?q=... returned **403**. Openwall/LKML copies had **no stable NAK**. Unverified whether anyone mailed stable@ about this exact patch. Not used as a negative.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: KEY FUNCTIONS**
Record: No function bodies changed. Data consumed by snd_usb_mixer_controls() → find_map() → check_mapped_name().

**Step 5.2: TRACE CALLERS**
Record: snd_usb_mixer_controls() runs when snd-usb-audio builds mixers for a matching USB audio interface (device probe). Userspace- reachable via plugging/enumerating this onboard codec.

**Step 5.3: TRACE CALLEES**
Record: find_map is a linear table walk; check_mapped_name copies a string into kctl->id.name. No alloc/lock beyond existing mixer control creation.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: USB enumerate → snd-usb-audio probe → mixer parse → kcontrol names. **Yes, reachable** for anyone with this motherboard. Unprivileged users see the names via ALSA/PulseAudio; they cannot trigger a kernel crash with this change.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same map already used for 0x0db0:0x419c and 0x0db0:0xa073. This is the established ALC4080 pattern.

---

## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- git describe HEAD → **v6.18.57-155-gcdf239ca885b2**
- make kernelversion → **6.18.57**
- v6.18.57:sound/usb/mixer_maps.c has the ALC4080 map and IDs 0x419c / 0xa073, **not** 0xcc78
- The unmapped-ID bug **exists on this 6.18.y base**
- git merge-base --is-ancestor 53b3abbe6e262 v6.18.57 → **false** (not in the 6.18.57 tag)

(The candidate is present on current HEAD because autosel applied it for evaluation. That is ignored as selection evidence.)

**Step 6.2: BACKPORT COMPLICATIONS**
Record: **Clean apply.** Context around the Torpedo Max entry is identical at v6.18.57. Needle found; 0xcc78 absent; map symbol present.

**Step 6.3: RELATED FIXES ALREADY HERE**
Record: Carbon Max and Torpedo Max maps are here. **No equivalent 0xcc78 mapping** at v6.18.57.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1:** Record: **ALSA USB audio (sound/usb/)** — **IMPORTANT** (common onboard USB audio on AM5 boards). Not core mm/net, not staging.

**Step 7.2:** Record: Active; this 6.18.y tree already backports mixer- map ID quirks. SOUND maintainers: Takashi Iwai, Jaroslav Kysela (MAINTAINERS).

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1:** Record: **Driver-specific / USB-ID-specific** — MSI MAG B850M MORTAR WIFI (0db0:cc78) with CONFIG_SND_USB_AUDIO. Other devices unaffected.

**Step 8.2:** Record: Trigger is **every probe** of that codec. Common for that board. Unprivileged users see wrong mixer names; not a syscall crash.

**Step 8.3:** Record: **Failure mode:** all playback controls named "PCM" → users cannot control speaker vs headphone vs IEC958 independently; userspace routing/UCM can pick the wrong output. **Severity: MEDIUM** as a functional hardware quirk (not oops/corruption). Still the class stable explicitly wants.

**Step 8.4:** Record: **Benefit: high for those boards, zero elsewhere.** **Risk: very low** (4 lines, one ID). **Ratio: strongly favorable.**

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: EVIDENCE**

**For:**
- Official rule: *“fix a real bug that bothers people **or just add a device ID**”* and *hardware quirk* (Documentation/process/stable- kernel-rules.rst)
- Same class as USB/PCI ID and mixer-map quirks routinely taken into 6.18.y
- Identical 2022 sibling (Torpedo Max) was **Cc: stable**
- Real hardware: ALC4080 with colliding "PCM" names
- 4 lines, reuses an in-tree map, maintainer-applied, author-tested
- Map + table exist at v6.18.57; applies cleanly
- Only that USB ID is affected

**Against:**
- Not a crash, UAF, or security fix
- No Fixes:/Cc: stable on this commit (expected; not a veto)
- No second independent reporter in the kernel thread

**Unresolved:**
- lore.kernel.org/stable search 403 — no verified stable-list thread
- Commit text says controls show as "Speaker" / "Front Headphone" / "IEC958"; table strings are "* Playback". Same as the 2022 map. Does not change correctness.

**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — 4-line ID add; author tested; maintainer applied
2. Fixes a real bug that affects users? **PASS** — indistinguishable mixer controls on real hardware
3. Important issue? **PASS** as **hardware quirk / device ID** (documented exception); not a panic
4. Small and contained? **PASS** — +4 lines, one file
5. No new features or APIs? **PASS** — existing map, existing driver
6. Can apply to the local tree? **PASS** — clean against v6.18.57

**Step 9.3: EXCEPTION CATEGORY**
Record: **Device ID addition + hardware quirk/workaround** (USB mixer- map ID on existing snd-usb-audio).

**Step 9.4: DECISION**
Backport. This is the standard stable-eligible USB mixer ID quirk:
small, isolated, already-supported driver, real board, in-tree map.

---

### What the commit solves and why it matters here

On this 6.18.y tree, snd-usb-audio already drives Realtek ALC4080 motherboard codecs, but 0db0:cc78 has no name map. All playback volumes appear as "PCM", so users (and UCM) cannot separate speaker, front headphone, and S/PDIF. The patch binds that ID to the existing MSI ALC4080 map.

### Stable rules / risk vs benefit

Meets the written stable rules via the **device ID / hardware quirk** exception. Benefit is correct mixer labels for this AM5 board; risk is confined to that USB ID. No prerequisites beyond code already in v6.18.57.

### Concerns

None material. Different Mortar **Max** ID 0db0:83ed is a separate patch and not required. Presence of this commit on current autosel HEAD is evaluation-pipeline state, not a reason to skip a technical YES.

---

### Verification
- **[Phase 1]** Parsed subject/tags/body from git show 53b3abbe6e262; Link msgid [email protected]
- **[Phase 2]** Diff: +4 lines in usbmix_ctl_maps[]; map contents and snd_usb_mixer_controls() lookup read in this tree
- **[Phase 3]** git blame on map (5762f980ca10d, 2022) and ID rows; Torpedo Max 4ddef9c4d70aa has Cc: stable; git merge-base --is- ancestor of map/Torpedo vs v6.18.57 = yes
- **[Phase 3]** git log --oneline -20 -- sound/usb/mixer_maps.c; author search only this commit
- **[Phase 4]** b4 dig -c/-a/-w and -m /tmp/thread.mbox: v1 only; To Iwai/Kysela/linux-sound; Iwai “Applied now”
- **[Phase 4]** Openwall + LKML mirrors of the same thread; lore.kernel.org 403 on patch.msgid.link and stable search
- **[Phase 4]** Web search found alsa-ucm-conf PR #581 for this board (userspace routing)
- **[Phase 5]** Call path: snd_usb_mixer_controls → find_map → check_mapped_name verified in mixer.c
- **[Phase 6]** git describe HEAD = v6.18.57-155-gcdf239ca885b2; make kernelversion = 6.18.57; git grep on v6.18.57 -- sound/usb/mixer_maps.c: map yes, 0xcc78 no; ancestor check of candidate vs v6.18.57 = no
- **[Phase 6]** Context around Torpedo Max entry identical at v6.18.57 (clean apply)
- **[Phase 6]** Similar mixer-map ID quirks already in v6.18.57 (Corsair Virtuoso, HS80, KTMicro)
- **[Phase 7]** SOUND maintainers in MAINTAINERS; sound/usb/ still receiving 6.18.y quirks
- **[Phase 8]** Failure mode is misnamed mixer controls for one USB ID, not a kernel oops
- **UNVERIFIED:** whether this patch was already discussed on stable@ (lore stable search 403)

The patch is a contained hardware quirk for an existing driver and should be taken into this 6.18.y tree.

**YES**

 sound/usb/mixer_maps.c | 4 ++++
 1 file changed, 4 insertions(+)
sound/usb/mixer_maps.c +4 -0
index ace4ccad8f51c..a82b9c1d578d9 100644
@@ -718,6 +718,10 @@ static const struct usbmix_ctl_map usbmix_ctl_maps[] = {
 		.id = USB_ID(0x0db0, 0xa073),
 		.map = msi_mpg_x570s_carbon_max_wifi_alc4080_map,
 	},
+	{	/* MSI MAG B850M MORTAR WIFI */
+		.id = USB_ID(0x0db0, 0xcc78),
+		.map = msi_mpg_x570s_carbon_max_wifi_alc4080_map,
+	},
 	{	/* MSI TRX40 */
 		.id = USB_ID(0x0db0, 0x543d),
 		.map = trx40_mobo_map,
Signature · 1 line
2.53.0
author maintainer
#379 lore raw

PATCH 1/1 ipmi: Fix leak in __ipmi_bmc_register

In reply to Sasha Levin

From: Michail Tatas <[email protected]>

[ Upstream commit 18e633dd9674c8bf118ea8583bb5a531edc2728a ]

In case that ida_alloc(&ipmi_bmc_ida,...) succeeds and then platform_device_register() fails, ipmi_bmc_ida is leaked. Fix by freeing the error path

Message-ID: <anUK_HOy_pCgvsBm@michalis-linux>

---

LLM Generated explanations, may be completely bogus:

This is a one-line IDA leak fix in IPMI BMC registration. The buggy error path is in this 6.12.111 tree, the patch applies cleanly, and the maintainer treated it as a bug fix.

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ipmi] [Fix] leak in __ipmi_bmc_register — explicit leak fix in BMC registration.

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- No Fixes: tag (expected for this review pipeline)
- No Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, `Cc:
stable, or Link:`
- Signed-off-by: Michail Tatas <[email protected]> (author)
- Message-ID: <anUK_HOy_pCgvsBm@michalis-linux>
- Signed-off-by: Corey Minyard <[email protected]> (IPMI maintainer; not a pipeline SOB)
- Ignore any pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] if present

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: ida_alloc(&ipmi_bmc_ida, ...) succeeds, then platform_device_register() fails, and the IDA ID is never freed.
- Symptom: leaked IDA ID (IDs cannot be reused). Not a kmalloc leak of the bmc object itself — that is already freed via put_device().
- Failure mode: resource leak on the BMC registration error path; can retry (see Phase 5).
- Root cause: out_list_del calls put_device(&bmc->pdev.dev) (which kfrees the BMC via release_bmc_device) but never ida_free().
- No version range in the message.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. Subject and body both say “Fix leak”. This is a straightforward error-path resource leak.

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/char/ipmi/ipmi_msghandler.c (+1 / −0)
- Function: __ipmi_bmc_register() error label out_list_del
- Scope: single-file, one-line surgical fix
- Upstream SHA: 18e633dd9674c8bf118ea8583bb5a531edc2728a

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: Before — on platform_device_register() failure, the code unlinks the BMC, resets intf->bmc, then put_device(). After — same path, but ida_free(&ipmi_bmc_ida, bmc->pdev.id) runs **before** put_device(), because put_device() → release_bmc_device() → kfree(bmc) would make bmc->pdev.id unusable.

Verified local error path:

```3255:3261:drivers/char/ipmi/ipmi_msghandler.c
out_list_del:
        mutex_lock(&bmc->dyn_mutex);
        list_del(&intf->bmc_link);
        mutex_unlock(&bmc->dyn_mutex);
        intf->bmc = &intf->tmp_bmc;
        put_device(&bmc->pdev.dev);
        goto out;
```

And the only jump to that label:

```3188:3194:drivers/char/ipmi/ipmi_msghandler.c
                rv = platform_device_register(&bmc->pdev);
                if (rv) {
                        dev_err(intf->si_dev,
                                "Unable to register bmc device: %d\n",
                                rv);
                        goto out_list_del;
                }
```

Successful-registration cleanup already frees the ID in cleanup_bmc_work():

```3048:3056:drivers/char/ipmi/ipmi_msghandler.c
static void cleanup_bmc_work(struct work_struct *work)
{
        struct bmc_device *bmc = container_of(work, struct bmc_device,
                                              remove_work);
        int id = bmc->pdev.id; /* Unregister overwrites id */

        platform_device_unregister(&bmc->pdev);
        ida_free(&ipmi_bmc_ida, id);
}
```

That work is queued only from kref_put(&bmc->usecount, cleanup_bmc_device). out_list_del uses put_device(), not kref_put(), so ida_free currently never runs on this failure.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: Category **(a) error-path resource leak**. Mechanism: IDA ID allocated, never returned on platform_device_register() failure. Fix:
add the missing ida_free() before the device is released.

Not a kmalloc UAF: release_bmc_device() still frees the BMC. Not a double-free of the ID: cleanup_bmc_work is not queued on this path.

**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct. ida_free must precede put_device (object containing the id is freed there). Minimal, no unrelated edits, no API/lock/hot-path changes. Regression risk is very low. Double-ida_free is not a concern because this path does not go through cleanup_bmc_work.

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- IDA numbering: 68e7e50f195f (“ipmi: Don't use BMC product/dev ids in the BMC name”, Corey Minyard, 2017)
- out_list_del + put_device: a2cb600fa22a87 (“ipmi: Rework BMC registration”, 2017)
- ida_alloc conversion: 9bd9fbd9032a3 (2023) — API rename only; leak already existed with ida_simple_get
- Partial sibling leak: 4aa7afb0ee20a (2019) freed bmc on ida_simple_get() failure, but did **not** free the ID after platform_device_register() failure

Bug has been in-tree since ~2017. All of the above are ancestors of this HEAD.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Closest introducer is 68e7e50f195f (IDA IDs) plus a2cb600fa22a87 (error path that omits ida_free). Both are in this tree (git merge-base --is-ancestor returned 0).

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Nearby IPMI fixes in this 6.12 tree (d4be659a3e56f SI NULL deref, e2a3b77df6aef refcount leak) are unrelated. Upstream neighbor b6c46ab0bdee9 (“Remove all sysfs files on registration failure”) is a **different** leak in ipmi_add_smi() sysfs attributes, not a prerequisite. This commit is standalone.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Michail Tatas has no other IPMI commits on origin/master besides this one. Corey Minyard (MAINTAINERS: IPMI SUBSYSTEM) authored the registration rewrite and SOB’d this patch. Maintainer-acked.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Needs ida_free / ida_alloc / ipmi_bmc_ida / out_list_del, all present here. git apply --check of 18e633dd9674c succeeded at offset −44 lines. Standalone.

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 18e633dd9674c →
https://patch.msgid.link/anUK_HOy_pCgvsBm@michalis-linux
- b4 dig -a: single **v1**, no later revisions
- Patchew: Corey Minyard replied *“You are correct, added to my next tree. Thank you.”* — no NAK, no requested changes
- Included in [GIT PULL] IPMI bug fixes for 7.3 as “Several cleanup on error fixes”

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To Corey Minyard ([email protected]); Cc [email protected], linux- [email protected]. Subsystem maintainer received and applied it.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla/Reported-by. Found by code inspection. Maintainer confirmed the leak.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone [PATCH], not n/m. Same pull also had unrelated IPMI error-path fixes (sysfs leftover attrs, SI NULL deref already in this tree as d4be659a3e56f). None required for this one-liner.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: Web search of lore.kernel.org/stable for this subject found no prior stable discussion or rejection. UNVERIFIED that nobody ever asked for it on stable@; absence of hits is not a reason to skip it.

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: __ipmi_bmc_register() only. Helpers involved:
ida_alloc/ida_free, platform_device_register, put_device, release_bmc_device, cleanup_bmc_work.

**Step 5.2: TRACE CALLERS**
Record: Sole call site is __bmc_get_device_id() when BMC identity is new/changed (!intf->bmc_registered or GUID/device/product id change). That is called from:
- ipmi_add_smi() (interface probe)
- bmc_get_device_id() used by sysfs attrs (device_id_show and siblings) and ipmi_get_version()
- redo_bmc_reg() work scheduled when !intf->bmc_registered

**Step 5.3: TRACE CALLEES**
Record: Allocates BMC, takes an IDA id, registers a platform device ipmi_bmc.<id>, creates sysfs links. Error path in question is register-fail.

**Step 5.4: FOLLOW THE CALL CHAIN (reachability)**
Record: Reachable on IPMI SMI probe and on BMC id refresh. If __ipmi_bmc_register() fails:

```2674:2675:drivers/char/ipmi/ipmi_msghandler.c
                if (__ipmi_bmc_register(intf, &id, guid_set, &guid,
intf_num))
                        need_waiter(intf); /* Retry later on an error.
*/
```

need_waiter() arms ipmi_timer (1s: IPMI_TIMEOUT_TIME == 1000). ipmi_timeout_handler() sees !intf->bmc_registered and schedules redo_bmc_reg() → bmc_get_device_id() again. Persistent platform_device_register() failure therefore retries about once per second and leaks one IDA ID per retry. Userspace can also hit __bmc_get_device_id via sysfs BMC attributes and ipmi_get_version().

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Only one ida_free(&ipmi_bmc_ida, ...) in this file today (cleanup_bmc_work). The 2019 commit 4aa7afb0ee20a fixed the sibling leak (kfree BMC if ida_simple_get fails). This patch is the missing half of that cleanup.

## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. Tree is **6.12.111** (git describe HEAD → p-6.12-3-gc504cf0baa3d8, VERSION=6 PATCHLEVEL=12 SUBLEVEL=111). 18e633dd9674c is **not** an ancestor (merge-base --is-ancestor exit 1). Local out_list_del still has put_device without ida_free. Bug dates to 2017 (68e7e50f195f / a2cb600fa22a87).

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: git show 18e633dd9674c | git apply --check → **Hunk #1 succeeded at 3257 (offset -44 lines)**. Expected difficulty: **clean apply**. Surrounding out_list_del context matches upstream parent.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: 4aa7afb0ee20a is present (ida_alloc-failure kfree). No other ida_free on out_list_del. No substitute fix.

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/char/ipmi/ — IPMI message handler. **IMPORTANT** for servers/enterprise/BMC out-of-band management (typical LTS users). Not core mm/scheduler, not staging.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature (IPMI since 2.6-era). Recent 6.12.y history is bugfixes, not redesign. Long-lived leak, not a brand-new subsystem.

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Config-specific: CONFIG_IPMI_HANDLER. Driver-specific: systems with an IPMI BMC (most servers). Not universal desktop, but core for enterprise stable.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: platform_device_register(&bmc->pdev) failure after a successful ida_alloc. Typical causes: -ENOMEM, or platform namespace issues. Not every boot. If it fails, the 1s retry loop can fire repeatedly. Not a userspace-triggered security primitive by itself, but BMC sysfs/ipmi_get_version can re-enter registration.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: IDA ID leak (and IDA bitmap growth). BMC object is freed. Not oops/deadlock/corruption. Persistent retry can leak one ID per second. ID space is large (ida_alloc without max ≈ 0..INT_MAX), so exhaustion is slow, but it is a real unbounded leak on a retry path, not a one-shot init leak.

Severity: **MEDIUM** (resource leak on error/retry path). Still matches the class of error-path leak fixes that stable regularly takes.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: stops a verified ID leak in IPMI BMC registration, including the retry loop. High value relative to patch size for IPMI-using servers.
- Risk: **very low** — one line, error path only, ordering is required and correct.
- Ratio: strongly favors backport.

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Real IDA leak on a live error path that can retry every second
- One-line, obviously correct, ida_free before put_device
- Buggy code present in this 6.12.111 tree since 2017
- Applies cleanly (offset only)
- IPMI maintainer confirmed and merged it as a bug fix
- Completes the 2019 leak fix that only covered ida_alloc failure
- No new API, no refactor, no dependencies missing here

AGAINST:
- Trigger is platform_device_register() failure (uncommon)
- Not a crash/UAF/security hole
- No Reported-by from production
- ID space is large, so practical exhaustion is slow

UNRESOLVED:
- Direct lore.kernel.org fetch returned 403; discussion recovered via b4 dig + Patchew
- No stable@ thread found for this subject

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — 1 line; maintainer: “You are correct”
2. Fixes a real bug that affects users? **PASS** — IDA leak; retry can repeat it
3. Important issue? **PASS** (MEDIUM leak, same class as other stable error-path leaks; IPMI is enterprise-relevant). Not CRITICAL crash, but important enough.
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 succeeded

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary small bugfix.

**Step 9.4: DECISION**
Backport. The leak exists here, the fix is trivial and correct, and IPMI BMC registration is used on the servers that run this LTS tree.

### What the commit solves for this tree
If BMC platform-device registration fails after ida_alloc, 6.12 currently drops the BMC (put_device) but keeps the ID. __ipmi_bmc_register failure then schedules a 1s retry, so a sticky failure leaks IDs continuously. Adding ida_free(&ipmi_bmc_ida, bmc->pdev.id) before put_device closes that path.

### Risk vs benefit
Benefit is a real resource-leak fix in a long-lived IPMI path. Risk is essentially nil.

### Concerns
None for 6.12: no missing helpers, no conflicting refactor, apply is clean.

---

Verification:
- [Phase 1] Parsed tags: author SOB Michail Tatas; maintainer SOB Corey Minyard; Message-ID anUK_HOy_pCgvsBm@michalis-linux; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: +1 ida_free(&ipmi_bmc_ida, bmc->pdev.id) in out_list_del of __ipmi_bmc_register
- [Phase 2] Confirmed out_list_del is only reached from platform_device_register() failure; success-path ida_free is in cleanup_bmc_work via kref_put, not this path
- [Phase 3] git blame: IDA intro 68e7e50f195f (2017); error label a2cb600fa22a87 (2017); sibling kfree fix 4aa7afb0ee20a (2019)
- [Phase 3] git merge-base --is-ancestor of those three vs HEAD: all present; 18e633dd9674c **not** in HEAD
- [Phase 3] Neighbor b6c46ab0bdee9 is a different sysfs leak; not a prerequisite
- [Phase 4] b4 dig -c 18e633dd9674c: lore match https://patch.msgid.link/anUK_HOy_pCgvsBm@michalis-linux
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: To Corey Minyard, Cc openipmi-developer + LKML
- [Phase 4] Patchew: maintainer “You are correct, added to my next tree”
- [Phase 4] GIT PULL “IPMI bug fixes for 7.3” lists this commit
- [Phase 4] lore.kernel.org WebFetch 403; discussion taken from b4/Patchew instead
- [Phase 5] Callers: __bmc_get_device_id ← ipmi_add_smi, sysfs BMC attrs, ipmi_get_version, redo_bmc_reg
- [Phase 5] Retry: need_waiter → 1s ipmi_timer → bmc_reg_work while !bmc_registered
- [Phase 6] git describe HEAD: p-6.12-3-gc504cf0baa3d8; make kernelversion: 6.12.111
- [Phase 6] git apply --check: hunk succeeded at line 3257 (offset −44)
- [Phase 7] MAINTAINERS: IPMI SUBSYSTEM → Corey Minyard
- [Phase 8] Failure mode: IDA ID leak on error/retry; severity MEDIUM; risk very low
- UNVERIFIED: Direct lore.kernel.org HTML of the thread (403); no stable@ archive hit for this subject

**YES**

 drivers/char/ipmi/ipmi_msghandler.c | 1 +
 1 file changed, 1 insertion(+)
drivers/char/ipmi/ipmi_msghandler.c +1 -0
index 0247079db185e..dc4704b067b94 100644
@@ -3306,6 +3306,7 @@ static int __ipmi_bmc_register(struct ipmi_smi *intf,
 	list_del(&intf->bmc_link);
 	mutex_unlock(&bmc->dyn_mutex);
 	intf->bmc = &intf->tmp_bmc;
+	ida_free(&ipmi_bmc_ida, bmc->pdev.id);
 	put_device(&bmc->pdev.dev);
 	goto out;
 }
Signature · 1 line
2.53.0
author maintainer
#380 lore raw

PATCH 1/1 soc: qcom: socinfo: Add SoC ID for SDM850

In reply to Sasha Levin

From: David Heidelberg <[email protected]>

[ Upstream commit 743af1d6a8b4bfa62dd01b5c2d81b1c62ea597f7 ]

Recognize the SDM850 SoC.

---

LLM Generated explanations, may be completely bogus:

This tree is **Linux 7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The verdict below is only for this checkout: the socinfo table and QCOM_ID_SDM850 are present here, so the one-line SoC ID addition is a valid hardware-ID backport.

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

Step 1.1: PARSE THE SUBJECT LINE
Record: **[soc: qcom: socinfo]** **[Add]** **SoC ID table entry so SDM850 is recognized by qcom-socinfo**

Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Fixes: none (expected for this review)
- Reported-by: none
- Tested-by: none
- Reviewed-by: none on this commit (patch 1 of the series has Reviewed- by Konrad Dybcio)
- Acked-by: Krzysztof Kozlowski \<[email protected]\>
- Link:
https://lore.kernel.org/r/[email protected]
- Cc: stable: none (expected)
- Signed-off-by: David Heidelberg \<[email protected]\> (author); Bjorn Andersson \<[email protected]\> (qcom SoC maintainer). Ignored: any Sasha Levin SOB (none in the provided message)

Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug description: SDM850 (numeric SMEM id 348) is not in the socinfo soc_id[] table, so the driver cannot map it to a name.
- Symptom/failure mode: /sys/devices/soc0/machine is omitted (NULL machine name). Numeric soc_id still works. Not a crash.
- Version information: none in the message. Cover letter (from the lore mbox): “Useful for sdm850 devices in tree and also will be used by Comma AI comma three.”
- Root cause: missing table entry, not a logic bug.

Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a hidden crash/UAF/leak fix. It is an explicit **missing hardware ID**. That is the documented stable exception for new device IDs on an existing driver.

===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================

Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/soc/qcom/socinfo.c — **+1 / −0**
- Function: static table soc_id[] (not a function body)
- Scope: **single-file surgical ID addition**

Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record: Before, socinfo_machine() walked soc_id[] and returned NULL for id 348. After, id 348 matches QCOM_ID_SDM850 and returns "SDM850". Path: qcom_socinfo_probe() → socinfo_machine() → soc_device_register(). Normal probe path only; no error-path or locking change.

Step 2.3: IDENTIFY THE BUG MECHANISM
Record: **[Hardware ID / device-ID table]** Missing qcom_board_id(SDM850) so SMEM id 348 is unnamed. Macro expands to QCOM_ID_SDM850, "SDM850" via qcom_board_id().

Step 2.4: ASSESS THE FIX QUALITY
Record: Obviously correct one-liner, same pattern as neighboring IDs (SDM636/SDM632). Regression risk is very low: table is append-only lookup; no lock, alloc, or API change. Compile dependency:
QCOM_ID_SDM850 must exist in include/dt-bindings/arm/qcom,ids.h (it does in this tree).

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

Step 3.1: BLAME THE CHANGED LINES
Record: Insertion sits between SDA636 and SDM632, both from 34ec89e68db26 (2022-10-17, “soc: qcom: socinfo: create soc_id table from bindings”). The table format has been stable since then. SDM850 DT has been in tree much longer (44acee2078447 Yoga C630, 2019-09-05; 6be4ba5467bed sdm850.dtsi, 2021-01-15).

Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Not applicable. This fills a gap for hardware whose DT was added years ago, not a regression from a specific commit.

Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: This is **patch 2/2** of “Recognize Snapdragon SDM850”. Patch 1:
dt-bindings: arm: qcom,ids: Add SoC ID for Snapdragon SDM 850 (d529495c991a2b in the qcom tree; also 4e926dc3d6ad3 via arm-soc). Recent socinfo history is mostly other SoC/PMIC ID adds. Standalone on this tree because the #define is already here.

Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: David Heidelberg authored both series patches on these paths. Not the subsystem maintainer. Maintainer path: Ack from Krzysztof Kozlowski, merge by Bjorn Andersson.

Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: **Depends on QCOM_ID_SDM850 (348)** in qcom,ids.h. Verified present at include/dt-bindings/arm/qcom,ids.h:187. git merge-base --is-ancestor confirms both the socinfo commit 743af1d6a8b4b and the header commit are ancestors of HEAD. Can apply standalone **on this tree**. Applying only socinfo without the define would not compile (QCOM_ID_SDM850 undeclared). Parent of 743af1d6a8b4b did **not** have the define (header landed on a different path/timing).

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- Lore/msgid:
https://patch.msgid.link/[email protected]
- Direct lore.kernel.org fetch: **403** (could not read HTML); full thread saved via b4 dig -m to /tmp/sdm850-thread.mbox
- Revisions: **v1** (2026-06-23) was only the dt-bindings patch, titled SDA 850; **v2** (2026-06-27) renamed to SDM850 (Konrad) and added this socinfo consumer (Krzysztof). Applied version is v2/2, the latest.
- Reviewer feedback: Ack from Krzysztof on both patches; Reviewed-by Konrad on patch 1; Bjorn Andersson applied both on 2026-07-05. No NAKs. No reviewer Cc: stable.
- Cover letter: in-tree SDM850 devices + Comma AI comma three.

Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To/Cc included Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, Conor Dooley, linux-arm-msm, devicetree, linux-kernel. Right maintainers were on the thread.

Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla. Motivation is missing ID for already- supported boards, not a crash report.

Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Two-patch series only. No further enablement patches in the thread. Patch 1 is the header define (already in this tree).

Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: **UNVERIFIED** — lore.kernel.org/stable search and WebSearch both failed (403 / tool error). No stable discussion in the captured msm/devicetree thread.

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: Table soc_id[] only. Consumers: socinfo_machine(), called from qcom_socinfo_probe().

Step 5.2: TRACE CALLERS
Record: socinfo_machine() is static, one caller:
qcom_socinfo_probe(). Platform driver qcom-socinfo (CONFIG_QCOM_SOCINFO, default m if ARCH_QCOM). Probe at Qualcomm SoC boot via SMEM SMEM_HW_SW_BUILD_ID. Not IRQ/hot-path. Userspace- visible via soc bus sysfs.

Step 5.3: TRACE CALLEES
Record: Probe uses qcom_smem_get(), soc_device_register(), debugfs init, add_device_randomness(). This patch does not change those calls.

Step 5.4: FOLLOW THE CALL CHAIN
Record: Boot on SDM850 (Yoga C630, Samsung W737, Huawei Matebook E, etc.) → qcom-socinfo probe → SMEM id 348 → name lookup. Reachable on real shipped ARM64 laptops already described in this tree’s DT. Not a syscall fuzzer path.

Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Many sibling “Add SoC ID for …” commits in the same table. No in-tree soc_device_match() on "SDM850" / "SDM845" (grep of drivers). Impact is sysfs/userspace identification, not in-kernel quirk matching.

===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================

Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. drivers/soc/qcom/socinfo.c soc_id[] and socinfo_machine() exist. Header define exists. SDM850 DT:
arch/arm64/boot/dts/qcom/sdm850.dtsi plus board files. Without this line, id 348 stays unnamed. The gap existed from the 2022 table conversion until this 2026 add; hardware DT is from 2019–2021.

Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **Clean apply** on this tree: neighbors SDA636/SDM632 match the hunk. Same qcom_board_id() helper. Prerequisite #define QCOM_ID_SDM850 348 is present.

Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: This exact line is already in HEAD (git merge-base --is- ancestor 743af1d6a8b4b HEAD succeeded; blame line 428 is that commit). Per instructions that is **not** used as a “already selected” veto; it confirms the change is valid in this codebase. No alternate fix for id 348.

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: **drivers/soc/qcom** (Qualcomm socinfo). **IMPORTANT** for ARCH_QCOM users, not core mm/net. Identification only; does not bind a new driver.

Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Actively updated (many recent SoC/PMIC ID commits). Table-add pattern is mature and repetitive.

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

Step 8.1: DETERMINE WHO IS AFFECTED
Record: **Platform-specific** — Qualcomm SDM850 boards (in-tree: Lenovo Yoga C630, Samsung Galaxy Book2 / w737, Huawei Matebook E 2019). Cover letter also cites Comma three. Only if CONFIG_QCOM_SOCINFO is enabled (default on ARCH_QCOM).

Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Every boot on SDM850 once socinfo probes. Not a race. Unprivileged users only observe sysfs; they cannot trigger a crash with this bug.

Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: Missing /sys/devices/soc0/machine (attribute mode 0 when machine is NULL in soc_attribute_mode()). Numeric soc_id still exported. **Severity: LOW** as a crash/corruption issue; **hardware identification** as a device-ID exception.

Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record: Benefit: correct SoC name for real shipping devices already supported by this tree. Risk: **very low** (1 line, data-only). Ratio:
favorable under the device-ID exception.

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

Step 9.1: COMPILE THE EVIDENCE
FOR:
- Documented stable exception: new device/SoC ID on an existing driver
- One line, same idiom as the rest of soc_id[]
- Real hardware: in-tree SDM850 DTs since 2019–2021
- Acked by Krzysztof Kozlowski; applied by Bjorn Andersson
- Prerequisite QCOM_ID_SDM850 is in this 7.3-rc4 tree
- No locking/API/behavior change for other SoCs

AGAINST:
- Not a crash, UAF, deadlock, or data-corruption fix
- No Cc: stable / Fixes (expected; not a negative)
- Userspace-visible name fill-in, not driver probe

UNRESOLVED:
- Could not query lore.kernel.org/stable (HTTP 403 / search failure)

Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — one table entry; maintainer ack; merged to qcom/arm-soc
2. Fixes a real bug that affects users? **PASS** — missing ID for shipping SDM850 machines (Yoga C630 and others)
3. Important issue (crash, security, corruption, deadlock)? **FAIL** as those classes; **PASS** via device-ID exception
4. Small and contained? **PASS** — +1 line, one file
5. No new features or APIs? **PASS** — no new syscall/sysfs ABI; fills existing soc bus machine attribute
6. Can apply to the local tree? **PASS** — table and QCOM_ID_SDM850 exist here

Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: **NEW DEVICE ID** on an existing driver (qcom-socinfo). Analogous to adding a PCI/USB ID.

Step 9.4: MAKE YOUR DECISION
This is a one-line SoC ID for hardware this tree already describes. It does not add a driver or API. Benefit is correct identification on SDM850; risk is negligible. That matches the stable device-ID exception, so it should be backported to this tree.

**What it solves for stable users:** SDM850 reports as an unknown/unnamed SoC in socinfo sysfs. Users of Yoga C630-class machines and similar need the name for inventory/userspace matching.

**Risk vs benefit:** Data-only lookup add; no runtime regression path identified.

**Concerns:** Must keep the header define (QCOM_ID_SDM850 / 348). That define is already in this checkout, so this commit is self-contained here.

Verification:
- [Phase 1] Subject/tags: Add SoC ID; Acked-by Krzysztof Kozlowski; Link msgid 20260627-sda850-v2-2; no Fixes/Reported-by/Cc: stable
- [Phase 1] Cover letter from mbox: in-tree sdm850 devices + Comma AI comma three; v2 renamed SDA850→SDM850
- [Phase 2] Diff: +1 line { qcom_board_id(SDM850) } in soc_id[] of drivers/soc/qcom/socinfo.c
- [Phase 2] qcom_board_id(id) → QCOM_ID_ ## id, __stringify(id) at socinfo.c:25
- [Phase 2] socinfo_machine() returns NULL if no match (lines 562–571); probe sets qs->attr.machine (913–914)
- [Phase 2] soc_attribute_mode() hides machine sysfs when machine is NULL (drivers/base/soc.c:54–55)
- [Phase 3] git describe HEAD / make kernelversion: v7.3-rc4-27 / 7.3.0-rc4
- [Phase 3] git merge-base --is-ancestor 743af1d6a8b4b HEAD: yes; also in v7.3-rc1
- [Phase 3] Prerequisite header commits d529495c991a2b and 4e926dc3d6ad3 are ancestors of HEAD; #define QCOM_ID_SDM850 348 at qcom,ids.h:187
- [Phase 3] Parent of socinfo commit lacked the define (would not compile alone against that parent)
- [Phase 3] Blame: neighbors from 34ec89e68db26 (2022); this line from 743af1d6a8b4b
- [Phase 3] SDM850 DT: git log --diff-filter=A → 44acee2078447 (2019), 6be4ba5467bed (2021)
- [Phase 4] b4 dig -c 743af1d6a8b4b: matched v2 2/2; -a showed v1 then v2; -w listed qcom/dt maintainers; -m saved thread
- [Phase 4] mbox: Krzysztof Ack both; Konrad Reviewed-by on patch 1; Bjorn “Applied, thanks!”; no NAK, no Cc: stable
- [Phase 4] lore.kernel.org WebFetch 403; stable list search UNVERIFIED
- [Phase 5] Only caller of socinfo_machine is qcom_socinfo_probe; no in-tree soc_device_match on SDM850
- [Phase 6] Local files exist; insertion context matches; CONFIG_QCOM_SOCINFO in drivers/soc/qcom/Kconfig
- [Phase 8] Failure mode: missing sysfs machine name, not oops; SDM850 boards listed under arch/arm64/boot/dts/qcom/

**YES**

 drivers/soc/qcom/socinfo.c | 1 +
 1 file changed, 1 insertion(+)
drivers/soc/qcom/socinfo.c +1 -0
index 963772f45489d..79a0defe73227 100644
@@ -359,6 +359,7 @@ static const struct soc_id soc_id[] = {
 	{ qcom_board_id(IPQ8078) },
 	{ qcom_board_id(SDM636) },
 	{ qcom_board_id(SDA636) },
+	{ qcom_board_id(SDM850) },
 	{ qcom_board_id(SDM632) },
 	{ qcom_board_id(SDA632) },
 	{ qcom_board_id(SDA450) },
Signature · 1 line
2.53.0
author maintainer
#381 lore raw

PATCH 1/1 virtio_console: take a kref in find_port_by_vq() to fix port UAF

In reply to Sasha Levin

From: Hari Mishal <[email protected]>

[ Upstream commit 18dd0b4e489e4f0e3b748cf36ccb909c75a3efab ]

find_port_by_vq() returns a raw struct port pointer without taking a reference on it, unlike find_port_by_devt_in_portdev() which does. find_port_by_vq()'s only two callers, in_intr() and out_intr(), run as virtqueue interrupt callbacks, entirely independent of and possibly concurrently with unplug_port(), which itself runs from a workqueue when the host sends a VIRTIO_CONSOLE_PORT_REMOVE control message.

unplug_port() removes the port from portdev->ports under ports_lock, then later drops its last reference with kref_put(), freeing it via remove_port(). find_port_by_vq() also walks portdev->ports under ports_lock, so if it finds the port still on the list, the list removal, and therefore the eventual kref_put(), has not happened yet, and taking a reference at that point is always safe. Without doing so, in_intr()/out_intr() can be left holding a pointer to a port that unplug_port() frees on another core before they are done using it.

Both triggers are host-controlled as the host decides when to send the PORT_REMOVE control message and when to kick the port's data vq. So a malicious backend could race the two on purpose, without any guest side cooperation. The freed object is a generic kmalloc allocation containing a wait_queue_head_t, which in_intr()/out_intr() pass to wake_up_interruptible() after touching the stale pointer. wake_up_interruptible() invokes a function pointer read out of the wait queue's entries. If the freed slab slot is reclaimed with attacker influenced content before that call, then this is an arbitrary function call primitive rather than just undefined behaviour.

Take a reference in find_port_by_vq() while still holding ports_lock, matching find_port_by_devt_in_portdev(), and release it in in_intr() and out_intr() once they are done with the port.

---

LLM Generated explanations, may be completely bogus:

The local tree is **6.6.157** (pending-6.6). The virtio_console UAF is in this tree, and the kref get/put fix is a small, self-contained match for the existing find_port_by_devt_in_portdev() pattern.

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[virtio_console] [take / fix] take a kref in find_port_by_vq() to fix port UAF.** Subsystem is the virtio console character driver. The subject names a use-after-free and the exact missing refcount.

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Signed-off-by:** Hari Mishal \<[email protected]\> (author)
- **Link:**
https://patch.msgid.link/[email protected]
- **Signed-off-by:** Greg Kroah-Hartman \<[email protected]\> (char-misc application)
- **No Fixes:** tag (expected for this review)
- **No Cc: stable** (expected; ignored as a negative)
- **No Reported-by / Tested-by / Reviewed-by / Acked-by**
- Ignore pipeline **Signed-off-by: Sasha Levin** / **[Upstream commit ...]** if present

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** find_port_by_vq() returns a raw struct port * with no kref_get(), unlike find_port_by_devt_in_portdev().
- **Race:** in_intr() / out_intr() (virtqueue callbacks) vs unplug_port() (workqueue, VIRTIO_CONSOLE_PORT_REMOVE).
- **Mechanism:** both walk portdev->ports under ports_lock. Lookup can succeed, drop the lock, then unplug list_del()s and later kref_put() → remove_port() → kfree(port) while the IRQ path still uses the pointer.
- **Symptom:** use-after-free of a kmalloc object that contains a wait_queue_head_t. wake_up_interruptible() follows a function pointer from wait-queue entries. If the slab is recycled with attacker-controlled content, that is an **arbitrary function call**, not just a crash.
- **Trigger:** host-controlled (PORT_REMOVE + data vq kick). A malicious virtio backend can race this without guest help.
- **Fix:** kref_get() under ports_lock in find_port_by_vq(); kref_put(..., remove_port) at the end of in_intr() / out_intr().
- **Version info in message:** none.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not hidden.** This is an explicit UAF/refcount fix, not 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:** ~14 insertions, 1 deletion (comment + kref_get + two kref_puts)
- **Functions:** find_port_by_vq(), out_intr(), in_intr()
- **Classification:** single-file surgical refcount fix

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **find_port_by_vq():** before, returned a list pointer after dropping ports_lock. After, kref_get(&port->kref) while still on the list and holding the lock; callers must put.
- **out_intr():** still looks up, flushes if missing, then wake_up_interruptible(&port->waitqueue); now kref_put() after the wake.
- **in_intr():** same lookup/inbuf/sigio/wake/hvc path; now kref_put() after the last use of port.
- **Early if (!port) returns:** no get was taken, so no put (correct).
- **Path:** virtqueue interrupt/callback vs hot-unplug workqueue.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** **use-after-free / reference counting** (UAF of struct port).
- **What was broken:** lookup did not pin the object; unplug could free it before IRQ handlers finished (waitqueue wake, inbuf, is_rproc_serial(port->portdev->vdev), hvc_poll).
- **How the fix works:** same lock-held get as find_port_by_devt_in_portdev(). If the port is still on portdev->ports, unplug_port() has not yet list_del()d, so it has not yet done the matching kref_put(). kref_get() is therefore on a live ref.

**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Obviously correct:** matches the 2013 open/close unplug fix (057b82be3ca3d0) and the existing finder that already takes a kref.
- **Minimal:** no API, no structural change.
- **Regression risk:** low. remove_port() in this tree is only kfree(port), which is IRQ-safe, so a last kref_put() from in_intr()/out_intr() is safe. Puts are at the end of both handlers; 6.6 has no extra early return after a successful lookup, so get/put is balanced.
- **Residual (not a reason to reject this patch):** in_intr() still does is_rproc_serial(port->portdev->vdev) without a NULL portdev check. That is a separate NPD if unplug already cleared portdev. It already exists when a file holds a kref. Sibling series patch 3/4 addresses it; it is **not** required for kref accounting on this tree.

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- find_port_by_vq() introduced in **203baab8ba3195** (“virtio:
console: Introduce function to hand off data from host to readers”, 2010-02-24), first in **v2.6.34-rc1**. Present in this 6.6 tree (git merge-base --is-ancestor succeeded).
- in_intr() from **17634ba25544d6** (2009). out_intr() from **2770c5ea501be6** (2011).
- **kref_get in find_port_by_devt_in_portdev()** from **057b82be3ca3d0** (2013): “fix race with port unplug and open/close”, **CC: stable**. Same bug class, same fix pattern, already backported historically.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** The missing get was never added for this finder; the bug is as old as find_port_by_vq() / unplug concurrency.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent 6.6 virtio_console commits are unrelated (control-out buffers, cols/rows, probe). **This UAF fix is not in HEAD** (find_port_by_vq() still has no kref_get). Standalone relative to this tree’s in_intr() (no if (!port->portdev) early return).

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Hari Mishal is not the virtio-console maintainer (MAINTAINERS:
Amit Shah). Greg Kroah-Hartman applied the patch. Related series patches 1–2 touch virtio-mem/virtio_input, not this file.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Originally **patch 4/4** in “virtio: validate device-reported values across drivers”. Patch 3/4 adds if (!port->portdev) in in_intr(); lore diffs of 4/4 therefore had an extra kref_put on that return. **This tree does not have that check** (if (!port->portdev) only in discard_port_data() / reclaim_consumed_buffers()). The candidate under review is the form without that hunk, which matches 6.6. **Can apply standalone.** Patch 3 is complementary, not a build/semantic prerequisite for this kref change here.

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **Lore / msgid:** [email protected] (standalone 2026-07-17 resubmit). Earlier: [PATCH 4/4] / [PATCH v2 4/4] 2026-07-15.
- **b4 mbox on that msgid:** **1 message in the thread** (no replies).
- **b4 dig -c <sha>:** not usable; this SHA is not in the 6.6 checkout.
- **WebFetch lore.kernel.org:** **403** (could not read lore HTML directly).
- Openwall/LKML/Patchew confirm v1 → v2 (comment wording only) → standalone resubmit. No NAK found in those archives.
- **UNVERIFIED:** full lore review thread beyond “no replies” from b4.

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: Recipients included Amit Shah, Arnd Bergmann, Greg Kroah- Hartman, virtualization@, linux-kernel@. No public Reviewed-by. **Greg’s SOB** is on the applied commit. Series v1 patches 1 and 3 carried Assisted-by: gkh_clanker:t1000.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: **No syzbot/bugzilla/CVE found.** Analysis is code-level: host- controlled race, waitqueue function-pointer UAF. Severity from the author is crash / possible arbitrary call.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record:
- **3/4** virtio_console: avoid NULL portdev dereference in in_intr() — NPD on port->portdev->vdev after unplug. **Not in this tree.** Related, not required for this patch’s get/put balance on 6.6.
- **1/4, 2/4** — virtio-mem / virtio_input validation; independent.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: Web search of lore stable for this subject did **not** find a prior stable accept/reject. No evidence it was already rejected for stable.

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

(semcode MCP not available; used grep + file reads.)

**Step 5.1: KEY FUNCTIONS**
Record: find_port_by_vq, in_intr, out_intr; callees remove_port, unplug_port, handle_control_message.

**Step 5.2: TRACE CALLERS**
Record:
- find_port_by_vq(): **only** in_intr() and out_intr() (verified by grep).
- Those are vq callbacks registered in init_vqs() (io_callbacks[j] = in_intr / out_intr).
- unplug_port(): handle_control_message() on VIRTIO_CONSOLE_PORT_REMOVE, and virtcons_remove().

**Step 5.3: TRACE CALLEES**
Record: in_intr uses get_inbuf, discard_port_data, send_sigio_to_port, wake_up_interruptible, hvc_poll/hvc_kick. unplug_port does list_del under ports_lock, then inbuf/hvc/sysfs teardown, then kref_put. remove_port is kfree(port) only.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Guest-visible: virtio-console /dev/vport* and hvc console. Unplug is host-driven (control message). **Reachable** on any VM with virtio-console and port hot-unplug, and **forcibly racable** by an untrusted backend. Not a dead config path. CONFIG_VIRTIO_CONSOLE is a normal guest option.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: find_port_by_devt_in_portdev() already kref_get()s under ports_lock. find_port_by_id() does not; it is used from the control work path that also calls unplug_port() (same workqueue for PORT_REMOVE). Different concurrency than vq IRQs.

===============================================================
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: find_port_by_vq() at 309–323 has no kref_get; out_intr 1734–1745 and in_intr 1747–1790 use the raw pointer. Introduced ~v2.6.34. Local tree: **6.6.157**.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply expected.** 6.6 in_intr() matches the candidate (no if (!port->portdev)). Lore 4/4 needed that extra put; the candidate already dropped it. Same kref API (kref_get/kref_put/remove_port).

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: 2013 open/close kref fix is present. **This vq-interrupt UAF fix is not.** Patch 3/4 NPD guard is not present in in_intr().

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **virtio console** (drivers/char/virtio_console.c). **IMPORTANT:** standard VM guest console/serial (/dev/hvc, /dev/vport*), QEMU/KVM, clouds, rproc-serial. Not mm/core, but widely deployed.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature driver (2009–); modest recent churn. Long-lived bug, not a new-subsystem issue.

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / config-specific:** CONFIG_VIRTIO_CONSOLE guests and rproc serial. Large population of VMs.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Concurrent **PORT_REMOVE** (or device remove → unplug_port) and **data vq kick**. Legitimate hot-unplug can hit it; a malicious backend can force it. Guest userspace is not required. Interrupt/callback vs workqueue.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **UAF** of struct port; wake_up_interruptible() on a freed waitqueue. **Severity: HIGH / security-relevant CRITICAL** (crash, or arbitrary call if the slab is recycled). Host-triggered, so in a fully trusted-hypervisor model the host is already privileged; it is still a real guest kernel memory-safety bug and matters for untrusted/vhost-user backends.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit: high** — pins the port for the IRQ path; closes a long- standing UAF on a common VM driver.
- **Risk: very low** — ~3 executable lines, existing kref pattern, remove_port is kfree.
- **Ratio:** strongly favors backport.

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

**Step 9.1: COMPILE THE EVIDENCE**

**FOR:**
- Real UAF: vq IRQ vs unplug_port(), pointer used after possible kfree.
- Security-relevant (waitqueue function pointer; host-controlled race).
- Same pattern as 057b82be3ca3d0, which was **CC: stable**.
- Buggy code present since ~2010; definitely in 6.6.157.
- Small, obviously correct, get/put balanced on this tree.
- virtio-console is a common guest driver.

**AGAINST:**
- No Fixes/Cc-stable/Reported-by/syzbot (not a negative per review rules).
- No public review replies on the 2026-07-17 thread.
- Sibling NPD fix (series 3/4) not included; remaining portdev NULL deref possible. **Does not make this patch wrong.**

**UNRESOLVED:**
- lore.kernel.org HTML 403; b4 showed a 1-message thread only.
- No CVE id found.

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — matches existing kref finder; Greg applied it. No extra Tested-by, but the change is locally verifiable.
2. Fixes a real bug that affects users? **PASS** — UAF on port unplug vs data vq.
3. Important issue? **PASS** — UAF / possible arbitrary call; HIGH/CRITICAL.
4. Small and contained? **PASS** — one file, ~14 lines.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — 6.6 has the buggy functions; candidate already matches this in_intr().

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Not an exception category.** Ordinary memory-safety bug fix (the primary stable class).

**Step 9.4: MAKE YOUR DECISION**
Backport to this 6.6.157 tree. It fixes a real, old, host-racable port UAF with a three-line kref pin that this driver already uses for the open path.

===============================================================
What this solves for stable users
===============================================================

On 6.6, find_port_by_vq() still hands in_intr()/out_intr() an unpinned struct port. unplug_port() can remove it from the list and drop the last kref (remove_port() → kfree) while those callbacks still wake port->waitqueue. That is a use-after-free. In VMs that hot- unplug virtio-console ports, or against a hostile virtio backend, the guest kernel can oops or worse.

The patch takes a kref under ports_lock (safe: still on the list ⇒ unplug has not put yet) and drops it after the last use. That is the same design as the 2013 stable-bound open/close fix. It does not add APIs. Residual portdev == NULL NPD in in_intr() is a separate, older hole (open ports already hit it); series patch 3/4 would close it later and is not required for this get/put to be correct here.

Risk is low: remove_port() is only kfree, so a final put from the vq callback is fine.

===============================================================
Verification
===============================================================
- **[Phase 1]** Parsed subject/tags/body: UAF + kref; SOB Hari Mishal + Greg KH; Link msgid [email protected]; no Fixes/Reported-by.
- **[Phase 2]** Diff: kref_get in find_port_by_vq; kref_put at end of in_intr/out_intr; comment only otherwise.
- **[Phase 2]** Read 6.6 in_intr/out_intr/unplug_port/remove_port /handle_control_message: race and kfree-only release confirmed.
- **[Phase 3]** git describe HEAD / Makefile: **6.6.157**, HEAD af85e5fc2f380.
- **[Phase 3]** git blame find_port_by_vq: 203baab8ba3195 (v2.6.34-rc1); git merge-base --is-ancestor true.
- **[Phase 3]** git show 057b82be3ca3d0: same unplug/kref pattern, **CC: stable**.
- **[Phase 3]** grep: no kref_get in find_port_by_vq on HEAD; only two callers.
- **[Phase 4]** Patchew/Openwall/LKML: series 0–4/4, v2 comment-only, standalone 17 Jul 2026.
- **[Phase 4]** b4 mbox msgid: **1 message**, no replies.
- **[Phase 4]** WebFetch lore: **403**.
- **[Phase 5]** grep callers; init_vqs registers in_intr/out_intr; PORT_REMOVE → unplug_port.
- **[Phase 6]** 6.6 in_intr has no !port->portdev early return; candidate matches; complementary 3/4 not present.
- **[Phase 7]** Kconfig VIRTIO_CONSOLE; MAINTAINERS Amit Shah / virtualization list.
- **[Phase 8]** Failure mode: port UAF via waitqueue; HIGH/CRITICAL.
- **UNVERIFIED:** complete lore review beyond b4’s empty thread; CVE assignment.

**YES**

 drivers/char/virtio_console.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/char/virtio_console.c +12 -1
index 76f934b5d84be..750c15966d00e 100644
@@ -304,6 +304,12 @@ static struct port *find_port_by_id(struct ports_device *portdev, u32 id)
 	return port;
 }
 
+/*
+ * Finds a port by the virtqueue and returns a pointer to struct port
+ * with the reference count incremented.
+ *
+ * Callers MUST decrement it when finished.
+ */
 static struct port *find_port_by_vq(struct ports_device *portdev,
 				    struct virtqueue *vq)
 {
@@ -312,8 +318,10 @@ static struct port *find_port_by_vq(struct ports_device *portdev,
 
 	spin_lock_irqsave(&portdev->ports_lock, flags);
 	list_for_each_entry(port, &portdev->ports, list)
-		if (port->in_vq == vq || port->out_vq == vq)
+		if (port->in_vq == vq || port->out_vq == vq) {
+			kref_get(&port->kref);
 			goto out;
+		}
 	port = NULL;
 out:
 	spin_unlock_irqrestore(&portdev->ports_lock, flags);
@@ -1706,6 +1714,7 @@ static void out_intr(struct virtqueue *vq)
 	}
 
 	wake_up_interruptible(&port->waitqueue);
+	kref_put(&port->kref, remove_port);
 }
 
 static void in_intr(struct virtqueue *vq)
@@ -1751,6 +1760,8 @@ static void in_intr(struct virtqueue *vq)
 
 	if (is_console_port(port) && hvc_poll(port->cons.hvc))
 		hvc_kick();
+
+	kref_put(&port->kref, remove_port);
 }
 
 static void control_intr(struct virtqueue *vq)
Signature · 1 line
2.53.0
#382 lore raw

Re: [PATCH AUTOSEL 6.18-5.10] virtio_console: take a kref in find_port_by_vq() to fix port UAF

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Critical] virtio_console: use-after-free on port->cons.hvc in in_intr() - [High] virtio_console: NULL…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] virtio_console: use-after-free on port->cons.hvc in in_intr()
- [High] virtio_console: NULL portdev dereference and inbuf leak in in_intr() --

commit 30bde48929beace6a7511551cb2600c5af9d8ca1
Author: Hari Mishal <[email protected]>

virtio_console: take a kref in find_port_by_vq() to fix port UAF

This commit takes a kref reference on struct port inside find_port_by_vq() under ports_lock and releases it at the end of in_intr() and out_intr() to prevent a use-after-free when racing with unplug_port().

Quoted 29 lines
drivers/char/virtio_console.c +9 -1
index 088182e54debd..14ca24b6daf2c 100644
@@ -304,6 +304,12 @@ static struct port *find_port_by_id(struct ports_device *portdev, u32 id)
 	return port;
 }
 
+/*
+ * Finds a port by the virtqueue and returns a pointer to struct port
+ * with the reference count incremented.
+ *
+ * Callers MUST decrement it when finished.
+ */
 static struct port *find_port_by_vq(struct ports_device *portdev,
 				    struct virtqueue *vq)
 {
@@ -312,8 +318,10 @@ static struct port *find_port_by_vq(struct ports_device *portdev,
 
 	spin_lock_irqsave(&portdev->ports_lock, flags);
 	list_for_each_entry(port, &portdev->ports, list)
-		if (port->in_vq == vq || port->out_vq == vq)
+		if (port->in_vq == vq || port->out_vq == vq) {
+			kref_get(&port->kref);
 			goto out;
+		}
 	port = NULL;
 out:
 	spin_unlock_irqrestore(&portdev->ports_lock, flags);

[ ... ]

drivers/char/virtio_console.c static void in_intr(struct virtqueue *vq) · line 1767

Quoted 9 lines
drivers/char/virtio_console.c +2 -0
@@ -1751,6 +1760,8 @@ static void in_intr(struct virtqueue *vq)
 
 	if (is_console_port(port) && hvc_poll(port->cons.hvc))
 		hvc_kick();
+
+	kref_put(&port->kref, remove_port);
 }
 
 static void control_intr(struct virtqueue *vq)

[Severity: High]
When in_intr() races with unplug_port() after find_port_by_vq() drops ports_lock, can in_intr() dereference a NULL port->portdev pointer and leak port->inbuf?

With the kref keeping struct port alive while unplug_port() executes on another CPU, unplug_port() clears guest_connected, drains the port data, and sets port->portdev to NULL:

drivers/char/virtio_console.c:unplug_port() {
    ...
	spin_lock_irq(&port->inbuf_lock);
	if (port->guest_connected) {
		...
		port->guest_connected = false;
		port->host_connected = false;
		...
	}
	spin_unlock_irq(&port->inbuf_lock);
    ...
	remove_port_data(port);

	port->portdev = NULL;
    ...
	kref_put(&port->kref, remove_port);
}

If in_intr() acquires port->inbuf_lock after unplug_port() has run, it pops a buffer into port->inbuf and then checks port->portdev->vdev while port->guest_connected is false:

drivers/char/virtio_console.c:in_intr() {
    ...
	spin_lock_irqsave(&port->inbuf_lock, flags);
	port->inbuf = get_inbuf(port);
    ...
	if (!port->guest_connected && !is_rproc_serial(port->portdev->vdev))
		discard_port_data(port);
    ...
}

Because port->portdev is now NULL, evaluating port->portdev->vdev dereferences NULL in interrupt context.

Additionally, if port->portdev becomes NULL just before discard_port_data() runs (or on an rproc_serial port), discard_port_data() returns early without freeing port->inbuf:

drivers/char/virtio_console.c:discard_port_data() {
	if (!port->portdev) {
		/* Device has been unplugged.  vqs are already gone. */
		return;
	}
    ...
}

When in_intr() then drops the final reference via kref_put(&port->kref, remove_port), remove_port() only calls kfree(port), leaking the struct port_buffer stored in port->inbuf.

[Severity: Critical]
In the same race between in_intr() and unplug_port() on a console port, can in_intr() pass a freed port->cons.hvc pointer to hvc_poll()?

While in_intr() holds a kref on struct port after find_port_by_vq() drops ports_lock, unplug_port() tears down the HVC console without clearing port->cons.hvc or synchronizing with in_intr():

drivers/char/virtio_console.c:unplug_port() {
    ...
	if (is_console_port(port)) {
		spin_lock_irq(&pdrvdata_lock);
		list_del(&port->cons.list);
		spin_unlock_irq(&pdrvdata_lock);
		hvc_remove(port->cons.hvc);
		ida_free(&vtermno_ida, port->cons.vtermno);
	}
    ...
}

hvc_remove() drops the tty_port reference, which frees the struct hvc_struct in hvc_port_destruct() if no tty holds an open reference. When in_intr() then reaches:

	if (is_console_port(port) && hvc_poll(port->cons.hvc))
		hvc_kick();

is_console_port(port) still sees a non-NULL port->cons.hvc and passes the dangling pointer to hvc_poll().

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author maintainer
#383 lore raw

PATCH 1/1 spi: bcm63xx: return error from failed controller suspend

In reply to Sasha Levin

From: Jiawen Liu <[email protected]>

[ Upstream commit bbbc1ef5b35341c5122418a14f8924688a4bb954 ]

spi_controller_suspend() can fail if the SPI core cannot stop the controller. bcm63xx_spi_suspend() ignored that error, disabled the controller clock, and returned success.

Return the suspend error before tearing down the clock.

---

LLM Generated explanations, may be completely bogus:

The tree is **6.18.53** (v6.18.53, Makefile VERSION=6 PATCHLEVEL=18 SUBLEVEL=53). The buggy suspend path is in this checkout; the upstream fix is not in v6.18.53. Verdict is for this tree only.

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

**Step 1.1: PARSE THE SUBJECT LINE**
Record: [spi: bcm63xx:] [return] Return error from failed spi_controller_suspend() instead of ignoring it and disabling the clock.

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Jiawen Liu <[email protected]> (author)
- `Link: https://patch.msgid.link/tencent_0BD7D4091B90EC17A8B2BA5EBA8803
[email protected]`
- Signed-off-by: Mark Brown <[email protected]> (SPI maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, or Cc: stable (absence expected for this review)
- Author SOB only besides Mark Brown (Sasha Levin SOB ignored per rules)

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- [Bug] bcm63xx_spi_suspend() ignores spi_controller_suspend() failure, then clk_disable_unprepare() and returns 0.
- [Symptom] Suspend reported success with the controller clock already torn down after a failed queue stop.
- [Version info] None in the message. Code has been this way since the driver was added.
- [Root cause] spi_controller_suspend() can return -EBUSY when spi_stop_queue() cannot drain the queue; the driver treated that as success.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not hidden. It is an explicit error-propagation / PM correctness fix (clock must not be gated if the core could not stop the controller).

===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/spi/spi-bcm63xx.c (+4 / -1)
- Function: bcm63xx_spi_suspend()
- Scope: single-file surgical PM error-path fix

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: Before: call spi_controller_suspend(host) and ignore the result, then always clk_disable_unprepare(bs->clk) and return 0.
After: capture ret; if non-zero, return it immediately and leave the clock enabled.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: [Logic / PM error handling] The SPI core can fail to stop the queued pump (spi_stop_queue() polls ~5s then returns -EBUSY). Continuing to ungated-clock teardown and reporting success leaves the kthread able to touch the controller with the clock off (hang / imprecise abort) and lets system suspend proceed with an active/busy SPI block.

**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct and matches the long-standing pattern in other in-tree SPI drivers (spi-atmel, spi-rockchip, spi-bcm63xx-hsspi, etc.). Minimal. Regression risk is low: on failure, suspend aborts and the clock stays on. Residual SPI-core quirk: spi_controller_suspend() still calls __spi_mark_suspended() even on spi_stop_queue() failure (pre-existing; not introduced here).

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

**Step 3.1: BLAME THE CHANGED LINES**
Record: Ignore-and-disable-clock dates to b42dfed83d95a3 (“spi: add Broadcom BCM63xx SPI controller driver”, 2012-03-09). Present in this tree. spi_controller_suspend() has returned spi_stop_queue() errors and marked SPI_CONTROLLER_SUSPENDED since bef4a48f4ef798 (2023-11-10, already in v6.18.53).

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable. The behavioral gap exists because the driver never checked a return value that can fail.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Related in this tree: 0acbfd61aee18 (“spi: bcm63xx: disable clock on resume failure”) is already in v6.18.53 (explicit `Cc:
stable). Same author’s series: spi-bcm63xx-hsspi and spi-bcm-qspi` get the same suspend check; each patch is per-driver and standalone. This is patch 1/3, self-contained.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Jiawen Liu is not the driver maintainer; Jonas Gorski is listed as Odd Fixes. Mark Brown applied the series. Author also sent the sibling Broadcom SPI suspend checks.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Uses existing spi_controller_suspend() / clk_disable_unprepare(). Dry-run apply of this hunk onto v6.18.53:drivers/spi/spi-bcm63xx.c succeeded (rc 0).

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c bbbc1ef5b35341c5122418a14f8924688a4bb954 → https://patch.m
sgid.link/[email protected]
- -a: v1 only, [PATCH 1/3]
- Thread: submission + Mark Brown “Applied to for-7.3” (no NAK, no requested respin, no reviewer Cc: stable)

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): [email protected], [email protected], Broadcom list, [email protected], Broadcom SPI contacts. Maintainer applied it.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by, syzbot, or bugzilla. Code-inspection fix. No evidence of a field crash report.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Series is three independent driver patches (bcm63xx, bcm63xx- hsspi, bcm-qspi). This one does not need the others. Resume-side counterpart (spi: bcm63xx: disable clock on resume failure) already landed in v6.18.53.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No stable-list discussion found for this subject. lore.kernel.org WebFetch returned 403; thread recovered via b4 dig -m.
UNVERIFIED: exhaustive lore.kernel.org/stable search via HTTP.

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: bcm63xx_spi_suspend(); callees spi_controller_suspend(), clk_disable_unprepare().

**Step 5.2: TRACE CALLERS**
Record: Only wired through DEFINE_SIMPLE_DEV_PM_OPS(bcm63xx_spi_pm_ops, ...) → platform driver .pm. System-sleep path, not a syscall. Triggered on suspend/hibernate of BCM63xx/BMIPS boards with this controller.

**Step 5.3: TRACE CALLEES**
Record: spi_controller_suspend() (drivers/spi/spi.c): if ctlr->queued, spi_stop_queue(); always __spi_mark_suspended(); returns -EBUSY on timeout. spi_stop_queue() waits up to 500 × ~10 ms.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: bcm63xx sets host->transfer_one_message and does not set host->transfer, so spi_register_controller() calls spi_controller_initialize_queue() and ctlr->queued = true. The failure path is reachable. Userspace can keep the queue busy (SPI flash, sensors); a stuck IRQ/transfer makes -EBUSY realistic.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same ignore-then-ungate bug was fixed in sibling Broadcom SPI drivers. Many other SPI hosts already check and return spi_controller_suspend() errors.

===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes, at v6.18.53 in bcm63xx_spi_suspend():

```c
spi_controller_suspend(host);
clk_disable_unprepare(bs->clk);
return 0;
```

git merge-base --is-ancestor bbbc1ef5b35341c5122418a14f8924688a4bb954 v6.18.53 → not an ancestor. Bug present since 2012; fail-able spi_controller_suspend() since 2023 (in this tree).

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply. Surrounding bcm63xx_spi_resume() already matches current mainline (resume error path already backported).

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: Resume-side clock rollback is already in v6.18.53. No earlier version of this suspend check.

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/spi/ Broadcom BCM6348/BCM6358 controller. Criticality:
PERIPHERAL (SoC-specific), but real OpenWrt/BMIPS users. CONFIG_SPI_BCM63XX depends on BCM63XX || BMIPS_GENERIC || COMPILE_TEST. Maintainer status: Odd Fixes.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: File still gets real fixes in 6.18.y (shared reset, CS, deregistration, resume clock). Mature driver, not staging.

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver-specific / config-specific: BCM63xx and BMIPS platforms using this SPI host, on system suspend.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: System suspend while the SPI message pump is still busy after ~5s. Not every boot; can be hit if a transfer is stuck or the queue cannot drain. Unprivileged users can keep SPI busy; they cannot directly call the PM callback (needs suspend permission).

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Clock gated while the queued pump may still run → MMIO with clock off, possible bus hang, incomplete in-flight SPI (flash). PM reports success, so the system continues suspend. Severity: HIGH (hang / possible device corruption on a rare path). Not a universal panic.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record: Benefit: high for affected boards (do not sleep with SPI still active and clock off). Risk: very low (4 insertions, error return only).
Residual: on failure the core still sets SPI_CONTROLLER_SUSPENDED and PM skips resume for this device (is_suspended stays false), so SPI may stay -ESHUTDOWN until a later successful suspend/resume. That core behavior already exists; other hosts already return the error the same way. Ratio: favor backport.

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Real PM bug: ignore failure, ungated clock, return success
- Failure mode is hang / in-flight SPI with clock off, not cosmetic
- Driver is queued, so spi_controller_suspend() can return -EBUSY
- 5-line, obviously correct, same pattern as other SPI hosts and the sibling series
- SPI maintainer applied it; driver maintainer was CCed
- Buggy code is in v6.18.53; patch applies cleanly; no prerequisites
- Resume-side analogue already taken for this stable tree

AGAINST:
- No user/syzbot report; inspection-only
- Trigger is uncommon (queue-stop timeout)
- Peripheral SoC driver, Odd Fixes
- Sent to for-7.3 merge window, not as an urgent -rc fix
- SPI core still marks suspended on failure (pre-existing)

UNRESOLVED:
- HTTP fetch of lore.kernel.org/stable returned 403 (thread obtained via b4)

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — mechanical return-value check; maintainer applied v1 with no NAK
2. Fixes a real bug that affects users? **PASS** — clock off + fake success on failed controller stop
3. Important issue? **PASS** — hang / inconsistent hardware on suspend, not a new feature
4. Small and contained? **PASS** — +4/-1, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — dry-run clean on v6.18.53

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not an ID/quirk/DT/build/docs exception). Qualifies as a normal small bugfix.

**Step 9.4: DECISION**
Backport. The bug exists on this 6.18.53 tree, the fix is surgical, and leaving suspend success + clock off after a failed queue stop is worse than aborting suspend.

------------------------------------------------
What the commit solves for this tree
bcm63xx_spi_suspend() must not disable the controller clock or report success if spi_controller_suspend() failed. On BCM63xx this host is queued, so that call can return -EBUSY. Continuing would let the pump access the block with the clock off and let system suspend proceed anyway.

Stable rules
Meets all six criteria: small, obviously correct, no new API, real PM bug, applies cleanly here.

Risk vs benefit
Benefit is avoiding a hang/inconsistent SPI across suspend on these SoCs. Risk is a 4-line error return that matches the rest of the SPI stack.

Concerns
No field report; rare trigger; Odd Fixes driver. None of that outweighs a clean, standard PM error-path fix whose resume counterpart is already in this tree.

Verification:
- [Phase 1] Subject/tags parsed from the supplied message and git show df107c1912ab6 / upstream bbbc1ef5b353
- [Phase 2] Diff is +4/-1 in bcm63xx_spi_suspend() only
- [Phase 3] git blame / git show b42dfed83d95a3: ignore-clock-off since 2012; bef4a48f4ef798 in v6.18.53
- [Phase 3] git merge-base --is-ancestor bbbc1ef5… v6.18.53 → not present; buggy code confirmed via git show v6.18.53:drivers/spi/spi- bcm63xx.c
- [Phase 3] 0acbfd61aee18 resume fix already in v6.18.53
- [Phase 4] b4 dig -c/-a/-w/-m: v1 1/3, Mark Brown applied, no NAK; lore HTTP 403
- [Phase 5] spi_register_controller() queues this driver; spi_stop_queue() can return -EBUSY
- [Phase 6] patch --dry-run of this commit onto v6.18.53 file: rc 0
- [Phase 6] git describe HEAD / make kernelversion: 6.18.53
- [Phase 7] MAINTAINERS: Odd Fixes, Jonas Gorski; Kconfig SPI_BCM63XX
- [Phase 8] PM core: failed suspend does not set is_suspended, so this device’s resume is skipped — pre-existing core mark-suspended-on-error
- UNVERIFIED: exhaustive lore.kernel.org/stable HTTP search (403)

**YES**

 drivers/spi/spi-bcm63xx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/spi/spi-bcm63xx.c +4 -1
index 8d152e906daac..f73dc14533dcc 100644
@@ -643,8 +643,11 @@ static int bcm63xx_spi_suspend(struct device *dev)
 {
 	struct spi_controller *host = dev_get_drvdata(dev);
 	struct bcm63xx_spi *bs = spi_controller_get_devdata(host);
+	int ret;
 
-	spi_controller_suspend(host);
+	ret = spi_controller_suspend(host);
+	if (ret)
+		return ret;
 
 	clk_disable_unprepare(bs->clk);
 
Signature · 1 line
2.53.0
author maintainer
#384 lore raw

PATCH 1/1 ext4: set EXT4_STATE_NO_EXPAND in ext4_evict_inode

In reply to Sasha Levin

From: Yun Zhou <[email protected]>

[ Upstream commit 2c0e4fb511f97467dafc91b6afb3414100289081 ]

An inode being evicted will never need its extra isize expanded. Set EXT4_STATE_NO_EXPAND before ext4_mark_inode_dirty() in ext4_evict_inode() to make this explicit and prevent any unnecessary work in ext4_try_to_expand_extra_isize().

This also provides defense-in-depth for the s_writepages_rwsem deadlock during mount-time orphan cleanup, ensuring the expand path is blocked for inodes under eviction regardless of how they are reached.

---

LLM Generated explanations, may be completely bogus:

I have the series context, Jan Kara’s review, and the syzbot stack. Compiling the nine-phase analysis and the backport verdict for this tree.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**

Record: **[ext4] [set] set EXT4_STATE_NO_EXPAND in ext4_evict_inode**

- Subsystem: ext4
- Action verb: **set** (the body also uses “prevent” and “ensuring … is blocked”)
- Claimed intent: mark an inode under eviction so extra-isize expansion is skipped

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**

Record:
- **Reviewed-by:** Jan Kara <[email protected]> (ext4 reviewer / long-time maintainer)
- **Link:** https://patch.msgid.link/20260623061903.2148767-2- [email protected] (patch **2/2**)
- **Signed-off-by:** Yun Zhou <[email protected]> (author)
- **Signed-off-by:** Theodore Ts'o <[email protected]> (ext4 maintainer; merged)
- **No Fixes:** tag on the committed version (expected for this review pipeline)
- **No Cc: stable** (expected)
- **No Reported-by / Closes** on this revision (those tags live on patch 1/2)

Notable: this is explicitly patch **2/2** of a two-patch series.

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**

Record:
- **Bug description:** An evicted inode never needs extra isize expanded. Doing that work is unnecessary and can participate in the s_writepages_rwsem deadlock during mount-time orphan cleanup.
- **Symptom/failure mode:** Circular lock dependency / deadlock (s_writepages_rwsem → jbd2 handle → xattr_sem → s_writepages_rwsem).
- **Version information:** none in this commit; sibling patch 1/2 has Fixes: c8585c6fcaf2 (v4.7-rc1).
- **Author’s root-cause framing:** skip expansion by setting EXT4_STATE_NO_EXPAND before ext4_mark_inode_dirty() in ext4_evict_inode(). Described as making the invariant explicit **and** as defense-in-depth for the mount-time orphan deadlock.

**Step 1.4: DETECT HIDDEN BUG FIXES**

Record: **Yes — this is a hidden/downplayed deadlock-path fix, not mere cleanup.**

The committed text says “unnecessary work” and “defense-in-depth”. The **v1** of this exact one-line change was titled *“skip extra isize expansion on inode eviction to avoid deadlock”*, carried the syzbot Reported-by/Closes/Fixes: tags, and the syzbot stack is ext4_orphan_cleanup → evict → **ext4_evict_inode** → __ext4_mark_inode_dirty → ext4_try_to_expand_extra_isize. The tags moved to patch 1/2 (!SB_ACTIVE) after Jan Kara asked for the real lock-order fix; this line remained as the eviction-path closer.

---

## PHASE 2: DIFF ANALYSIS - LINE BY LINE

**Step 2.1: INVENTORY THE CHANGES**

Record:
- **Files:** fs/ext4/inode.c — **+1 / −0**
- **Function:** ext4_evict_inode()
- **Scope:** single-file, one-line surgical change

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**

Record:
- **Before:** deletion path sets i_size = 0, then calls ext4_mark_inode_dirty(). That calls __ext4_mark_inode_dirty() → if i_extra_isize < s_want_extra_isize, ext4_try_to_expand_extra_isize(), which may take xattr_sem, move xattrs, and iput() EA inodes.
- **After:** ext4_set_inode_state(inode, EXT4_STATE_NO_EXPAND) runs first. ext4_try_to_expand_extra_isize() already returns -EOVERFLOW when that flag is set (check present since 2017), so expansion is skipped for this and later ext4_mark_inode_dirty() calls in the same eviction.
- **Path:** deletion path only (after the i_nlink / is_bad_inode early outs; not the cache-drop no_delete path).

**Step 2.3: IDENTIFY THE BUG MECHANISM**

Record:
- **Category:** deadlock / lock-ordering (plus skipping pointless expansion that can iput EA inodes under a jbd2 handle).
- **Mechanism:** mount-time orphan cleanup (!SB_ACTIVE) of a deleted inode (i_nlink == 0) hits ext4_evict_inode → expand extra isize → ext4_xattr_block_set → iput(ea_inode) → write_inode_now() → s_writepages_rwsem, while a jbd2 handle and xattr_sem are held. Setting EXT4_STATE_NO_EXPAND removes that edge for every inode under eviction.

**Step 2.4: ASSESS THE FIX QUALITY**

Record:
- **Quality:** obviously correct. An inode being deleted cannot benefit from extra isize. The flag’s save/restore in ext4_write_lock_xattr / ext4_write_unlock_xattr keeps it set (*save == 1 → do not clear).
- **Regression risk:** very low. One inode-state bit on an inode that is about to be freed. No API, locking, or on-disk format change.
- **Red flags:** none (1 line, one function). It is patch 2/2 but does **not** depend on patch 1’s !SB_ACTIVE check.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**

Record:
- Added line: commit **2c0e4fb511f97** (this change, 2026-06-23).
- Surrounding inode->i_size = 0 / ext4_mark_inode_dirty(): Dave Kleikamp 2006 / Ted Ts’o **bc965ab3f2b4b7** (2008). Extra-isize expansion from dirtying: **6dd4ee7cab7e3** (2007). EXT4_STATE_NO_EXPAND early-out in ext4_try_to_expand_extra_isize:
**cf0a5e818fe216** (2017, from **2e81a4eeedcaa** in 2016).
- This path has been in-tree for many years; not a newly introduced subsystem.

**Step 3.2: FOLLOW THE FIXES: TAG**

Record: **No Fixes: tag on this commit.** Sibling **7461c60b9c6a8** (patch 1/2, parent of this commit) has Fixes: c8585c6fcaf2 (“ext4: fix races between changing inode journal mode and ext4_writepages”, 2016-04-25, **v4.7-rc1**). That commit is an ancestor of this tree. It introduced s_writepages_rwsem (originally s_journal_flag_rwsem), which is the lock in the cycle.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**

Record:
- **7461c60b9c6a8** — skip expansion when !SB_ACTIVE (primary mount- time fix).
- **2c0e4fb511f97** — this commit (eviction-path flag).
- **4f48af3dc7554 / a54778243e88f** — later deferred iput for EA inodes (Jan Kara’s deeper lock-order fix; larger).
- This change is **standalone**: it only uses ext4_set_inode_state() and a flag check that has existed since 2017. It is part of a series but is not patch-X-that-needs-Y to compile or run.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**

Record: Yun Zhou is a regular ext4 contributor (orphan/xattr/deadlock work in this area), not the maintainer. Ted Ts’o merged it; Jan Kara reviewed it. Related author commits: the !SB_ACTIVE skip, then deferred EA iput helpers.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**

Record: **No hard prerequisites beyond code that is already old.** Needs EXT4_STATE_NO_EXPAND and the test at the top of ext4_try_to_expand_extra_isize() (2016–2017). Does **not** need patch
1. Applies as a single insertion before the existing ext4_mark_inode_dirty() call.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**

Record:
- **b4 dig:** [PATCH 2/2] ext4: set EXT4_STATE_NO_EXPAND in ext4_evict_inode — https://patch.msgid.link/20260623061903.2148767- [email protected]
- **Revisions:** evolved from standalone v1 (2026-06-11) through v5–v8 of a larger xattr-iput series, then a simplified 2-patch series that Ted applied. Applied version is that final 2/2.
- **v6/v8 cover letter (author):** “Patch 2 is a belt-and-suspenders semantic improvement: an inode under eviction never needs extra isize expansion.” “v1 … Only fixes the syzbot reproducer, not the underlying lock ordering violation.”
- **Jan Kara (2026-06-11) on the original identical change:** agrees expansion is pointless in ext4_evict_inode; says it **does not fix the real lock-order bug**, only the particular syzbot reproducer. No NAK of this line; he wanted a deeper fix as well.
- **No NAK** of setting the flag. Ted merged it with Jan’s Reviewed-by.

**Step 4.2: CHECK WHO REVIEWED THE PATCH**

Record (b4 dig -w): [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], linux- [email protected]. Subsystem maintainers/reviewers were on To/Cc. Jan Kara reviewed; Ted merged.

**Step 4.3: SEARCH FOR THE BUG REPORT**

Record:
- Syzbot: https://syzkaller.appspot.com/bug?extid=5d19358d7eb30ffb0cc5 — **possible deadlock in wait_transaction_locked**, prio:high, C repro, Denial-of-service via filesystem mount.
- Stack (verified): ext4_orphan_cleanup → evict → **ext4_evict_inode** → __ext4_mark_inode_dirty → ext4_try_to_expand_extra_isize → ext4_expand_extra_isize_ea → ext4_xattr_block_set → iput → write_inode_now → ext4_writepages / s_writepages_rwsem.
- Still reported on linux-5.15 / 6.1 / 6.6 at the time of the dashboard snapshot. Syzbot’s “fix commit” is **7461c60b9c6a** (patch 1), because that commit carries the tags; this commit closes the **same** ext4_evict_inode frame.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**

Record: Series is (1) skip expansion during mount, (2) this flag in evict, then later deferred-iput patches. Patch 1 covers all !SB_ACTIVE callers (including ext4_process_orphan → ext4_truncate). Patch 2 covers **all** eviction, including post-mount. They complement; this one is not incomplete on its own for the syzbot stack.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**

Record: No stable-list thread found for this subject. Absence of Cc:
stable is expected for this pipeline.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**

Record: **ext4_evict_inode()** (modified). Indirectly **__ext4_mark_inode_dirty()**, **ext4_try_to_expand_extra_isize()**.

**Step 5.2: TRACE CALLERS**

Record:
- ext4_evict_inode is ext4_sops.evict_inode (fs/ext4/super.c). Called from VFS evict() on last iput when i_nlink == 0.
- Reachable from unlink/close, and from **ext4_process_orphan() → iput()** during ext4_orphan_cleanup() at mount (fs/ext4/orphan.c). That is the syzbot path.

**Step 5.3: TRACE CALLEES**

Record: After the new flag: ext4_mark_inode_dirty → __ext4_mark_inode_dirty → ext4_try_to_expand_extra_isize (now a no- op via -EOVERFLOW) → later ext4_truncate, ext4_xattr_delete_inode, ext4_free_inode. No new callees.

**Step 5.4: FOLLOW THE CALL CHAIN**

Record: **Yes, userspace-reachable.** Unprivileged unlink hits eviction (no deadlock there once SB_ACTIVE is set). The deadlock needs mount- time orphan cleanup (!SB_ACTIVE), typically mount(2) (admin / crafted image). Syzbot reproduced it. Assessment: DoS, filesystem trigger.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**

Record: Only this site sets EXT4_STATE_NO_EXPAND outside the xattr lock helpers. No sibling-driver clone. Patch 1 is the related early- return in ext4_try_to_expand_extra_isize.

---

## 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** (mainline, not a *.y stable branch).
- ext4_evict_inode + ext4_mark_inode_dirty + expand-on-dirty all exist.
- This commit **is already an ancestor** of HEAD (2c0e4fb511f97). That is expected (source tree), not a reason to treat it as “already selected for stable”.
- Bug class dates to extra-isize expansion (2007) plus s_writepages_rwsem (2016 / v4.7).

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**

Record: **Clean apply.** Insert one call between long-stable inode->i_size = 0 and ext4_mark_inode_dirty(). No refactor of that sequence. EXT4_STATE_NO_EXPAND exists here.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**

Record: Patch 1 (7461c60b9c6a8) and later deferred-iput work are also in this mainline checkout. They do not make this line wrong or redundant for stable: patch 1 is mount-only; this flag also covers post-mount eviction and is the direct closer of the syzbot ext4_evict_inode frame.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**

Record: **ext4 (fs/ext4/)** — **IMPORTANT** (default filesystem on a large fraction of Linux systems; mount/orphan cleanup is a common path after crash).

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**

Record: Actively developed (recent writeback, xattr, orphan, deadlock fixes). The eviction dirtying sequence itself has been stable for many years; this is a small invariant on old code, not a feature on new code.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: DETERMINE WHO IS AFFECTED**

Record: **Filesystem-specific (ext4), but a very large user population.** Triggered on mount of a filesystem with orphans that still need extra-isize expansion and have xattrs that must move.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**

Record:
- **Deadlock:** mount-time orphan cleanup, inode with i_extra_isize < s_want_extra_isize, expansion moves xattrs, !SB_ACTIVE forces write_inode_now on EA iput. Syzbot has a C repro.
- **Post-mount:** every deletion of such an inode would previously attempt a pointless expand (not this deadlock).
- **Unprivileged mount:** generally no; crafted/unclean ext4 images and admin mount yes. Syzbot still reached it from syscall fuzzing.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**

Record: **Deadlock / lockdep circular dependency → hang or lockdep splat. Severity: HIGH (DoS on mount/orphan cleanup).** Not a data- corruption bug.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**

Record:
- **Benefit:** high for a 1-line closer of a documented, syzbot- reproduced deadlock path on ext4 eviction; also stops pointless expand (xattr shuffle / EA iput) on every delete.
- **Risk:** very low (1 line, existing flag, deletion-only).
- **Ratio:** strongly favorable.

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

**FOR backporting:**
- Syzbot C-repro deadlock; stack is exactly ext4_evict_inode → mark dirty → expand extra isize.
- 1-line, obviously correct; Jan Kara Reviewed-by; Ted Ts’o merged.
- Uses a flag and check that have existed since 2016–2017; no new API.
- Independent of patch 1; complements the !SB_ACTIVE skip.
- Defense-in-depth on a HIGH-severity hang in a core filesystem.
- Applies cleanly to this tree’s ext4_evict_inode.

**AGAINST:**
- Final message frames it as “unnecessary work” / “defense-in-depth”; author called v1 incomplete vs the real lock-order bug.
- Patch 2/2; the tagged “real” mount fix is patch 1.
- Jan Kara: this line alone does not fix ext4_xattr_block_set taking s_writepages_rwsem under a handle.
- Deadlock is mount-time / orphan-specific, not every unlink.

**UNRESOLVED:** lore.kernel.org returned 403 to WebFetch; discussion recovered via b4 dig, openwall/lkml mirrors, patchew, and the syzbot dashboard. No stable@ thread found.

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**

1. Obviously correct and tested? **PASS** — 1-line invariant; Reviewed- by Jan Kara; in mainline; syzbot exercised the path.
2. Fixes a real bug that affects users? **PASS** — same path as the syzbot deadlock; also skips harmful extra work on delete.
3. Important issue (crash, security, corruption, deadlock)? **PASS** — deadlock / DoS (HIGH), not theoretical.
4. Small and contained? **PASS** — +1 line, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — call site and EXT4_STATE_NO_EXPAND are present; insertion is mechanical.

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**

Record: Not a device-ID/quirk/DT/docs/build exception. It is a normal small correctness/deadlock-path fix.

**Step 9.4: MAKE YOUR DECISION**

This tree is **7.3-rc4 mainline**. The eviction dirtying path exists; the extra-isize expand-on-dirty path exists; the syzbot stack is this function. The committed wording is modest, but the change is the direct closer of a real, reproduced deadlock edge, not a refactor or a new feature. Risk is negligible. It should be backported.

---

### What the commit solves for stable users

On ext4, ext4_mark_inode_dirty() may try to grow i_extra_isize. During **mount-time orphan cleanup**, that runs from **ext4_evict_inode** while !SB_ACTIVE. Expanding can move xattrs and iput() EA inodes, which then calls write_inode_now() and takes s_writepages_rwsem under a jbd2 handle and xattr_sem. Syzbot reproduced that cycle. Setting EXT4_STATE_NO_EXPAND before the dirty call is correct (the inode is being deleted) and stops that expand/iput edge for every eviction.

### Stable rules / risk

Meets all six criteria: one line, reviewed, real deadlock path, no new API, applies cleanly. Sibling patch 1 (!SB_ACTIVE) is the broader mount fix; this line does not need it, and it still helps post-mount by skipping pointless expansion.

### Concerns

Incomplete as the *only* lock-order fix (Jan Kara). That is a reason to also want patch 1 / deferred iput, not a reason to drop this 1-liner. No backport rework needed on this tree.

---

Verification:
- [Phase 1] Subject/tags: ext4 set NO_EXPAND; Reviewed-by Jan Kara; Link patch 2/2; Ted Ts’o SOB; no Fixes/Reported-by on this revision
- [Phase 1] Body: skip expand on evict; defense-in-depth for s_writepages_rwsem deadlock
- [Phase 2] Diff: +1 line in ext4_evict_inode before ext4_mark_inode_dirty
- [Phase 2] Expand skip: ext4_try_to_expand_extra_isize returns -EOVERFLOW if EXT4_STATE_NO_EXPAND (inode.c:6597)
- [Phase 2] Flag restore: ext4_write_unlock_xattr clears only if *save == 0 (xattr.h:166-170)
- [Phase 3] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion: 7.3.0-rc4
- [Phase 3] git merge-base --is-ancestor 2c0e4fb511f97 HEAD: yes (mainline already has it)
- [Phase 3] Blame: i_size=0 2006; mark_inode_dirty in evict bc965ab3f2b4b7 2008; expand-on-dirty 6dd4ee7cab7e3 2007; NO_EXPAND check cf0a5e818fe216 2017
- [Phase 3] Sibling 7461c60b9c6a8 Fixes: c8585c6fcaf2 (v4.7-rc1); merge-base --is-ancestor c8585c6fcaf2 HEAD: yes
- [Phase 4] b4 dig -c 2c0e4fb511f97: msgid 20260623061903.2148767-2
- [Phase 4] b4 dig -a: v5–v8 larger series then final 2-patch series
- [Phase 4] b4 dig -w: tytso, adilger, [email protected], linux-ext4 on To/Cc
- [Phase 4] Jan Kara 2026-06-11 (openwall/lkml): agrees with the flag; says it only covers the syzbot reproducer, not the full lock-order bug — no NAK
- [Phase 4] Cover letter: “belt-and-suspenders semantic improvement”
- [Phase 4] Syzbot bug extid=5d19358d7eb30ffb0cc5: stack through ext4_evict_inode; prio high; C repro; linux-5.15/6.1/6.6 still listed
- [Phase 4] lore.kernel.org WebFetch: 403; used b4 + mirrors. Stable list search: no hits
- [Phase 5] Caller: ext4_sops.evict_inode; orphan:
ext4_process_orphan → iput (orphan.c:359)
- [Phase 6] Local ext4_evict_inode already contains the line at inode.c:268; apply would be clean on the pre-patch form of the same function
- [Phase 7] ext4, IMPORTANT, actively developed
- [Phase 8] Failure: circular lockdep / deadlock on mount orphan cleanup; severity HIGH; risk very low
- UNVERIFIED: live lore.kernel.org HTML of the thread (403); reconstructed from b4, openwall, patchew, syzbot

**YES**

 fs/ext4/inode.c | 1 +
 1 file changed, 1 insertion(+)
fs/ext4/inode.c +1 -0
index bbc437be5e63b..9a5c08650bd1e 100644
@@ -261,6 +261,7 @@ void ext4_evict_inode(struct inode *inode)
 	if (ext4_inode_is_fast_symlink(inode))
 		memset(EXT4_I(inode)->i_data, 0, sizeof(EXT4_I(inode)->i_data));
 	inode->i_size = 0;
+	ext4_set_inode_state(inode, EXT4_STATE_NO_EXPAND);
 	err = ext4_mark_inode_dirty(handle, inode);
 	if (err) {
 		ext4_warning(inode->i_sb,
Signature · 1 line
2.53.0
#385 lore raw

Re: [PATCH AUTOSEL 6.18-5.10] ext4: set EXT4_STATE_NO_EXPAND in ext4_evict_inode

Sashiko has reviewed this patch and found no issues.
Quoted 13 lines

From: Yun Zhou <[email protected]>

[ Upstream commit 2c0e4fb511f97467dafc91b6afb3414100289081 ]

An inode being evicted will never need its extra isize expanded. Set EXT4_STATE_NO_EXPAND before ext4_mark_inode_dirty() in ext4_evict_inode() to make this explicit and prevent any unnecessary work in ext4_try_to_expand_extra_isize().

This also provides defense-in-depth for the s_writepages_rwsem deadlock during mount-time orphan cleanup, ensuring the expand path is blocked for inodes under eviction regardless of how they are reached.

Quoted 5 lines

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author maintainer
#386 lore raw

PATCH 1/1 wifi: ath11k: validate regulatory capability phy_id

In reply to Sasha Levin

From: Pengpeng Hou <[email protected]>

[ Upstream commit f8729a40ebcc94d164be8f154483a21669f3ab52 ]

ath11k_wmi_tlv_ext_hal_reg_caps() copies firmware regulatory capability records into soc->hal_reg_cap[] using reg_cap.phy_id as the destination index. The loop count is bounded by num_phy, but the phy_id embedded in each record is not checked against the fixed MAX_RADIOS-sized destination array.

Reject firmware records whose phy_id does not fit soc->hal_reg_cap[] before copying the parsed capability.

---

LLM Generated explanations, may be completely bogus:

This tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The candidate is a 6-line firmware phy_id bounds check in ath11k WMI parsing. The buggy memcpy has been in this driver since v5.6; the check is obviously correct and belongs here.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[wifi: ath11k] [validate] [reject firmware phy_id that is out of range for soc->hal_reg_cap[]]**

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected for this review pipeline)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** Rameshkumar Sundaram <[email protected]>; Baochen Qiang <[email protected]> (Qualcomm ath11k reviewers)
- **Acked-by:** none
- **Link:** https://patch.msgid.link/[email protected]
- **Cc: stable:** none (expected; not a negative signal)
- **Signed-off-by:** Pengpeng Hou (author); Jeff Johnson (ath11k maintainer)

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** ath11k_wmi_tlv_ext_hal_reg_caps() copies firmware HAL regulatory-capability records into soc->hal_reg_cap[] using **reg_cap.phy_id as the destination index**. The loop is bounded by num_phy, but **phy_id inside each record is not checked** against MAX_RADIOS.
- **Symptom/failure mode:** out-of-bounds write into struct ath11k_base (memory corruption).
- **Version information:** none in the message.
- **Root cause:** firmware-controlled u32 phy_id used as an array index without a bounds check.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not disguised.** This is an explicit firmware-index validation / OOB-write fix. Verb “validate” is a bounds check, not cleanup.

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** drivers/net/wireless/ath/ath11k/wmi.c — **+6 / -0**
- **Function:** ath11k_wmi_tlv_ext_hal_reg_caps()
- **Scope:** single-file surgical fix

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record (verified in this tree at wmi.c:4862-4880):
- **Before:** ath11k_pull_reg_cap_svc_rdy_ext() fills reg_cap from firmware TLV ext_reg_cap[i].phy_id, then memcpy(&soc->hal_reg_cap[reg_cap.phy_id], &reg_cap, sizeof(reg_cap)) with no check that phy_id < MAX_RADIOS.
- **After:** if reg_cap.phy_id >= ARRAY_SIZE(soc->hal_reg_cap), log a warning and return -EINVAL; otherwise copy as before.
- **Path:** firmware WMI_SERVICE_READY_EXT event during ath11k bring- up (probe/init), not a hot datapath.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** **(d) memory safety — buffer overflow / out-of-bounds write**
- **Mechanism:** phy_id is a firmware u32 (wmi_hal_reg_capabilities_ext.phy_id). Destination is hal_reg_cap[MAX_RADIOS] with **MAX_RADIOS == 3** (core.h:242, core.h:971). Loop bound num_phy is also firmware-supplied and is **not** the same as phy_id. A record with phy_id >= 3 writes sizeof(struct ath11k_hal_reg_capabilities_ext) (10 × u32 = 40 bytes) past the array into following ath11k_base fields (free_vdev_map, tbl_mtx_lock, peer rhashtables).
- The parse helper only checks TLV count vs num_phy (n_ext_hal_reg_caps >= param.num_phy → -ENOBUFS); it does **not** validate phy_id.

**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Obviously correct:** ARRAY_SIZE(soc->hal_reg_cap) is the real destination size; reject-and-return is the right failure mode.
- **Minimal:** 6 lines, one check, no API/struct changes.
- **Regression risk:** **very low**. Well-formed firmware with phy_id 0–2 is unchanged. Invalid phy_id now fails WMI parse instead of corrupting memory. That is the intended probe failure, not a behavior change for working hardware.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Loop + memcpy: **d5c65159f28953** — “ath11k: driver for Qualcomm IEEE 802.11ax devices” (Kalle Valo, 2019-11-25).
- Bounds check: **f8729a40ebcc9** (this commit).
- Introducer is in **v5.6**, not v5.5 (git merge-base --is-ancestor). Bug has been in every tree with ath11k since then.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Not applicable. Introducer identified by
blame: d5c65159f28953 (original driver).

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Recent wmi.c work is other firmware TLV hardening (overread, stride, leak) — related thematically, **not prerequisites**.
- Earlier 84eee3c845d37 (“refine the phy_id check in ath11k_reg_chan_list_event”) is a **different** event path.
- **Standalone**, not patch N/M. Maintainer applied it as [1/1].

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Pengpeng Hou has this one ath11k commit here. Weight comes from **Qualcomm reviewers** and **maintainer Jeff Johnson** (MAINTAINERS:
ATH11K).

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **None.** Uses existing ARRAY_SIZE, ath11k_warn, -EINVAL, soc->hal_reg_cap. Can apply standalone on any tree with this 2019 function.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **Lore URL (b4 dig):** https://patch.msgid.link/[email protected]
- **Revisions:** **v1 only** (b4 dig -a); committed v1.
- **Thread (saved via b4 dig -m):**
- Baochen Qiang: Reviewed-by
- Rameshkumar Sundaram: Reviewed-by
- Jeff Johnson: “Applied, thanks!” [1/1]
- **No NAKs, no stable nomination, no requested revisions.**

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc were Jeff Johnson, linux-wireless, [email protected], linux-kernel. Right lists and maintainer.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: **No user/syzbot/bugzilla report.** Found by code review of firmware TLV parsing. Severity is from the mechanism (OOB write), not from a crash log.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone [PATCH], not a series. ath12k still has an analogous unguarded soc->hal_reg_cap[reg_cap.phy_id] = reg_cap in ath12k/wmi.c — sibling issue, **not a dependency**.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** for lore.kernel.org/stable (HTTP 403). Local history has no stable-specific discussion of this subject.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: KEY FUNCTIONS**
Record: ath11k_wmi_tlv_ext_hal_reg_caps(); helpers ath11k_pull_reg_cap_svc_rdy_ext(), ath11k_wmi_tlv_ext_hal_reg_caps_parse().

**Step 5.2: TRACE CALLERS**
Record (verified with grep/read):
- ath11k_wmi_tlv_ext_hal_reg_caps() ← ath11k_wmi_tlv_svc_rdy_ext_parse() (WMI_TAG_ARRAY_STRUCT after hw- mode and mac-phy TLVs)
- ← ath11k_service_ready_ext_event()
- ← WMI event switch WMI_SERVICE_READY_EXT_EVENTID

**Step 5.3: TRACE CALLEES**
Record: ath11k_wmi_tlv_iter(), ath11k_pull_reg_cap_svc_rdy_ext() (copies firmware phy_id), memcpy().

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable on **ath11k device init** when firmware sends service- ready-ext. Not a syscall hot path. Trigger needs **CONFIG_ATH11K** + Qualcomm 802.11ax hardware + firmware that puts phy_id >= 3 (or otherwise ≥ ARRAY_SIZE). Unprivileged users cannot poke this WMI path directly; **buggy or malicious firmware** can. That is still a real kernel OOB write.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same driver already bounds other firmware indices (e.g. `phy_idx

Quoted 1 line

= reg_caps->num_phy` in the pull helper). This copy site was the hole.

ath12k has the same hole unfixed.

---

## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** ath11k_wmi_tlv_ext_hal_reg_caps() and hal_reg_cap[MAX_RADIOS] are present. The unguarded memcpy was here from v5.6 until f8729a40ebcc9. **Bug introduced in v5.6, long before 7.3.** git merge-base --is-ancestor f8729a40ebcc9 HEAD is true (fix is in 7.3-rc1+); that is mainline merge, not “already selected for stable.”

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** Surrounding function body is still the 2019 structure plus this 6-line check. No refactor of this function in between.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No alternate fix for this memcpy. Other nearby TLV fixes address different bugs.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: **ath11k (Qualcomm 802.11ax)** under drivers/net/wireless/ath/ath11k/. **IMPORTANT** — not core mm/fs, but a widely used Wi-Fi driver (laptops, AP SoCs, Chromebooks, phones).
CONFIG: ATH11K / ATH11K_PCI / ATH11K_AHB.

**Step 7.2: SUBSYSTEM ACTIVITY**
Record: Actively maintained (Jeff Johnson). Recent WMI work is firmware- message validation, consistent with this patch.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: WHO IS AFFECTED**
Record: **Driver-specific / config-specific:** CONFIG_ATH11K users. Impact only if firmware sends a phy_id that does not fit hal_reg_cap[].

**Step 8.2: TRIGGER CONDITIONS**
Record: Device init / firmware service-ready-ext. **Not** every packet. Needs bad phy_id in the WMI record (firmware bug or hostile firmware). Unprivileged userspace cannot fire it without controlling firmware.

**Step 8.3: FAILURE MODE SEVERITY**
Record: **Out-of-bounds write** of 40 bytes into struct ath11k_base after hal_reg_cap[] — can corrupt free_vdev_map, mutexes, peer tables → crash, deadlock, or further memory corruption. **Severity:
HIGH** (OOB write / memory corruption). Not a panic on every boot with good firmware.

**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit:** High for ath11k — stops a real OOB write on a long- standing path (v5.6+).
- **Risk:** Very low — 6 lines, error-path reject, no lock/API change, good firmware unaffected.
- **Ratio:** strongly favors backport.

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

**FOR:**
- Real OOB write: firmware u32 phy_id used as index into a 3-element array.
- Small, obviously correct check (ARRAY_SIZE + -EINVAL).
- Present in this tree’s ath11k code; bug dates to original driver (v5.6).
- Reviewed by Qualcomm ath11k developers; applied by the maintainer.
- Standalone; no new APIs; no series dependencies.
- Matches stable pattern: buffer overflow / firmware TLV validation.

**AGAINST:**
- No Reported-by / syzbot / production crash.
- Trigger is firmware-supplied data at probe, not a generic syscall.
- No explicit Cc: stable (not a negative per pipeline rules).

**UNRESOLVED:**
- Could not query lore.kernel.org/stable (403).
- No public report that shipping firmware actually sent phy_id >= 3.

**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — local review + two Qualcomm Reviewed-by + maintainer apply.
2. Fixes a real bug that affects users? **PASS** — OOB write on firmware parse; ath11k users are real users.
3. Important issue? **PASS** — OOB write / memory corruption (**HIGH**), not style.
4. Small and contained? **PASS** — +6 lines, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — same function/context; no missing prerequisites.

**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 is a surgical firmware-index bounds check that stops a memcpy past hal_reg_cap[MAX_RADIOS]. The destination array and unguarded copy exist in this 7.3 tree’s ath11k code; the bug is older than this branch. Risk is negligible; the failure mode is memory corruption. That meets stable criteria for **this** tree.

---

### What the commit solves for this tree ath11k_wmi_tlv_ext_hal_reg_caps() trusted firmware phy_id as an index into a 3-slot array. A bad phy_id overwrites the rest of struct ath11k_base. The patch rejects those records before the copy.

### Stable rules
Small, obviously correct, no new APIs, applies cleanly, fixes a real OOB write.

### Risk vs benefit
Benefit is preventing kernel memory corruption on ath11k bring-up with bad firmware. Risk is an early -EINVAL only when phy_id is already invalid.

### Concerns
No in-the-wild crash report; trigger is firmware, not unprivileged syscalls. That does not make an OOB write unsuitable for stable. No backport rework needed here.

---

Verification:
- **[Phase 1]** Parsed tags: two Qualcomm Reviewed-by, maintainer SOB/Link; no Fixes/Reported-by/Cc:stable
- **[Phase 2]** Diff: +6 in ath11k_wmi_tlv_ext_hal_reg_caps(); ARRAY_SIZE check before memcpy(&soc->hal_reg_cap[reg_cap.phy_id], ...)
- **[Phase 2]** MAX_RADIOS is 3; hal_reg_cap[MAX_RADIOS] in core.h:971; phy_id is firmware u32
- **[Phase 3]** git blame: memcpy from d5c65159f28953 (2019); check from f8729a40ebcc9
- **[Phase 3]** Introducer in v5.6, not v5.5; fix in v7.3-rc1, not v7.2
- **[Phase 3]** git merge-base --is-ancestor f8729a40ebcc9 HEAD → yes (mainline already has the fix; ignored as “already selected”)
- **[Phase 3]** No series/prereqs; author has only this ath11k commit here
- **[Phase 4]** b4 dig -c f8729a40ebcc9: v1 at patch.msgid.link/[email protected]
- **[Phase 4]** b4 dig -a: v1 only; b4 dig -w: maintainer + linux- wireless + ath11k list
- **[Phase 4]** mbox: Reviewed-by Baochen Qiang + Rameshkumar Sundaram; Jeff Johnson applied [1/1]; no NAK
- **[Phase 4]** lore HTTP fetch 403; used b4 dig -m instead
- **[Phase 5]** Call chain: WMI SERVICE_READY_EXT → ath11k_service_ready_ext_event → TLV parse → this function
- **[Phase 5]** ath12k has the same unguarded pattern (sibling, not a prereq)
- **[Phase 6]** git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4; buggy function present
- **[Phase 6]** Surrounding code still matches 2019 introducer → clean apply
- **[Phase 7]** MAINTAINERS: Jeff Johnson, Supported
- **[Phase 8]** Failure mode: 40-byte OOB write into ath11k_base after hal_reg_cap[] → HIGH
- **UNVERIFIED:** stable@ lore search (HTTP 403); whether any shipping firmware actually sent phy_id >= 3

**YES**

 drivers/net/wireless/ath/ath11k/wmi.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/wireless/ath/ath11k/wmi.c +6 -0
index 3305ec66ddbf2..c6b9e84b169c9 100644
@@ -4816,6 +4816,12 @@ static int ath11k_wmi_tlv_ext_hal_reg_caps(struct ath11k_base *soc,
 			return ret;
 		}
 
+		if (reg_cap.phy_id >= ARRAY_SIZE(soc->hal_reg_cap)) {
+			ath11k_warn(soc, "invalid reg cap phy_id %u\n",
+				    reg_cap.phy_id);
+			return -EINVAL;
+		}
+
 		memcpy(&soc->hal_reg_cap[reg_cap.phy_id],
 		       &reg_cap, sizeof(reg_cap));
 	}
Signature · 1 line
2.53.0
author maintainer
#387 lore raw

PATCH 1/1 spi: loongson: pm: add .freeze .poweroff .thaw .restore

In reply to Sasha Levin

From: Li Jun <[email protected]>

[ Upstream commit a9c2f0d401fd1e11ce59e4243946a59bd818e8c5 ]

after execute s4, the spi error,

[ 1104.754246][ 4] [    T1] tpm_tis_spi spi-SMO0768:00: SPI transfer failed: -110
[ 1104.761503][ 4] [    T1] spi_master spi1: failed to transfer one message from queue
[ 1104.769201][ 4] [    T1] spi_master spi1: noqueue transfer failed
[ 1104.776344][ 4] [    T1] tpm_tis_spi spi-SMO0768:00: SPI transfer failed: -110
[ 1104.783609][ 4] [    T1] spi_master spi1: failed to transfer one message from queue
[ 1104.791308][ 4] [    T1] spi_master spi1: noqueue transfer failed
[ 1104.797446][ 4] [    T1] gttadd tpm_chip_start1 ret = -110

and in s4 the loongson_spi_resume&suspend are not
called at all. use DEFINE_SIMPLE_DEV_PM_OPS() add .freeze .poweroff .thaw .restore, after s4 the spi communication is normal.

---

LLM Generated explanations, may be completely bogus:

The local tree is **6.12.111** (pending-6.12). The buggy PM ops are present here; the candidate is not. The rest of the write-up is the full nine-phase review for this tree only.

===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================

**Step 1.1: PARSE THE SUBJECT LINE**

Record: **[spi: loongson: pm] [add] [hibernation callbacks .freeze/.poweroff/.thaw/.restore]**

The verb is “add”, but the body is a hibernation bug report (S4 SPI timeout), not a feature.

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**

Record:
- **Fixes:** none (expected for this review)
- **Reported-by:** none
- **Tested-by:** none (author states it was tested after S4)
- **Reviewed-by:** none on the committed message
- **Acked-by:** none
- **Link:**
https://patch.msgid.link/[email protected]
- **Cc: stable:** none (expected)
- **Signed-off-by:** Li Jun \<[email protected]\> (author); Mark Brown \<[email protected]\> (SPI maintainer)
- **Ignored pipeline tags:** none present in the provided message beyond the usual evaluation context

Notable: SPI maintainer SOB; mailing-list Link; no syzbot.

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**

Record:
- **Bug:** After S4 (hibernate), Loongson SPI transfers fail with **-110 (ETIMEDOUT)**. tpm_tis_spi device spi-SMO0768:00 cannot talk to the controller; tpm_chip_start returns -110.
- **Symptom:** SPI master spi1 “failed to transfer one message from queue” / “noqueue transfer failed”.
- **Root cause (author):** loongson_spi_suspend/loongson_spi_resume are **not called at all during S4**, because only .suspend/.resume were registered.
- **Fix:** DEFINE_SIMPLE_DEV_PM_OPS() so the same save/restore path is also used for .freeze, .poweroff, .thaw, .restore.
- **Version info:** none in the message; dmesg is a real hibernate- resume failure.
- **Author test:** “after s4 the spi communication is normal.”

**Step 1.4: DETECT HIDDEN BUG FIXES**

Record: **Not hidden.** It is a real hibernation PM bug. “add … callbacks” is the usual wording for filling missing dev_pm_ops slots; it is not a new API or new driver.

===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================

**Step 2.1: INVENTORY THE CHANGES**

Record:
- **File:** drivers/spi/spi-loongson-core.c
- **Scope:** ~2 insertions, ~4 deletions (single struct rewrite)
- **Functions:** loongson_spi_suspend / loongson_spi_resume unchanged; only loongson_spi_dev_pm_ops definition changes
- **Classification:** single-file surgical fix

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**

Record:
- **Before:** dev_pm_ops has only .suspend and .resume. Kernel hibernation uses .freeze/.thaw/.poweroff/.restore (include/linux/pm.h). Those were NULL, so S4 never saved/restored SPI registers or called spi_controller_suspend/spi_controller_resume.
- **After:** DEFINE_SIMPLE_DEV_PM_OPS → SYSTEM_SLEEP_PM_OPS, which sets all six sleep callbacks to the existing suspend/resume pair via pm_sleep_ptr().
- **Path affected:** system hibernation (S4) and poweroff-after-image. S3 still uses the same functions.

**Step 2.3: IDENTIFY THE BUG MECHANISM**

Record:
- **Category:** logic/correctness in PM ops (missing hibernation callbacks); hardware state not restored after S4
- **Mechanism:** After hibernate, SPI controller registers are not rewritten (SPCR/SPER/SPSR/PARA/SFCS/TIMI). Transfers time out. TPM on that bus (SMO0768) fails.
- **Not** UAF/leak/race/overflow.

**Step 2.4: ASSESS THE FIX QUALITY**

Record:
- **Quality:** Obviously correct. Same pattern as SYSTEM_SLEEP_PM_OPS / SET_SYSTEM_SLEEP_PM_OPS used across drivers/spi/ (e.g. spi- sifive.c, spi-bcm63xx.c, many SET_SYSTEM_SLEEP_PM_OPS users).
- **Minimal:** no unrelated edits.
- **Regression risk:** Low. S3 still uses the same two functions. Hibernation now runs the save/restore that S3 already used. RUNTIME_PM_OPS(NULL,NULL,NULL) matches the old struct (no runtime PM).
- **Style note (not a blocker):** include/linux/pm.h prefers EXPORT_NS_GPL_SIMPLE_DEV_PM_OPS when the symbol is exported. Mainline kept DEFINE_SIMPLE_DEV_PM_OPS + existing EXPORT_SYMBOL_NS_GPL. Functionally equivalent on this tree: the macro is non-static const struct dev_pm_ops.

===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================

**Step 3.1: BLAME THE CHANGED LINES**

Record:
- Buggy ops introduced in **6c7a864007b66** (“spi: loongson: add bus driver for the loongson spi controller”, Yinbo Zhu, 2023-06-13; committed 2023-07-31).
- **git merge-base --is-ancestor 6c7a864007b66 HEAD** succeeded.
- Present since **v6.6** (v6.5 does not contain it; v6.6 does). Unchanged since then (git blame on lines 232–276 is entirely that commit).

**Step 3.2: FOLLOW THE FIXES: TAG**

Record: No Fixes: tag. The introducing commit is the original driver, and it **is** in this tree.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**

Record:
- git log --oneline -- drivers/spi/spi-loongson-core.c shows **only** 6c7a864007b66.
- No later refactor of these PM ops in this tree.
- Standalone; subject is [PATCH v3], not X/Y.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**

Record:
- Author Li Jun (Kylinos) has **no** other commits under drivers/spi/ in this checkout.
- Original driver author is Yinbo Zhu (Loongson). Maintainer who applied the fix is Mark Brown.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**

Record:
- Needs DEFINE_SIMPLE_DEV_PM_OPS — present at include/linux/pm.h:418 in this tree.
- Needs existing loongson_spi_suspend/loongson_spi_resume — present.
- **Standalone.** No new helpers.

===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**

Record:
- **v1:** https://lore.kernel.org/linux-
spi/[email protected]/ — manually added four callback pointers.
- **v2:** https://lore.kernel.org/linux-
spi/[email protected]/ — SIMPLE_DEV_PM_OPS() after review.
- **v3 (committed):** https://lore.kernel.org/linux-
spi/[email protected]/ — DEFINE_SIMPLE_DEV_PM_OPS() (non-deprecated helper).
- **b4 mbox -c** on v3: no newer revision.
- **Reviewer:** Mark Brown on v1: “This could be done using SIMPLE_DEV_PM_OPS().” No NAK. He applied v3 to broonie/spi.git for-7.3 (a9c2f0d401fd).
- No Cc: stable in review (not a negative signal).

**Step 4.2: CHECK WHO REVIEWED THE PATCH**

Record:
- **To/Cc:** Li Jun, Yinbo Zhu (original driver author), Mark Brown, linux-spi.
- SPI maintainer reviewed and applied. Original driver author was CCed; no objection in the threads retrieved.

**Step 4.3: SEARCH FOR THE BUG REPORT**

Record:
- No bugzilla/syzbot. Evidence is the author’s dmesg plus “after s4 … normal.”
- ACPI id **SMO0768** is in this tree:
drivers/char/tpm/tpm_tis_spi_main.c (acpi_tis_spi_match). -110 is ETIMEDOUT (include/uapi/asm-generic/errno.h).

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**

Record: Three revisions of **one** patch. v3 is the applied form. No other patches in the series.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**

Record: lore.kernel.org/stable search for “loongson spi freeze” returned only unrelated “freeze” hits in stable review series. **No dedicated stable discussion** of this bug (search via lore ?q= HTML, HTTP 200).

===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================

**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**

Record: Symbol loongson_spi_dev_pm_ops only. Call targets loongson_spi_suspend and loongson_spi_resume are unchanged.

**Step 5.2: TRACE CALLERS**

Record:
- drivers/spi/spi-loongson-plat.c: platform .driver.pm = &loongson_spi_dev_pm_ops
- drivers/spi/spi-loongson-pci.c: PCI .driver.pm = &loongson_spi_dev_pm_ops
- Invoked by the PM core on system sleep/hibernation, not from a syscall directly.

**Step 5.3: TRACE CALLEES**

Record (loongson_spi_suspend/resume in this tree):
- Suspend: spi_controller_suspend(), then read 6 controller registers into struct loongson_spi.
- Resume: write those 6 registers back, then spi_controller_resume().
- spi_controller_suspend (drivers/spi/spi.c) stops a queued controller and sets SPI_CONTROLLER_SUSPENDED.

**Step 5.4: FOLLOW THE CALL CHAIN**

Record:
- Userspace (typically root): echo disk > /sys/power/state or distro hibernate.
- PM core → driver .freeze/.poweroff/.restore → save/restore SPI HW → later tpm_tis_spi transfers.
- **Reachable** on Loongson machines that hibernate with this controller and an SPI TPM (or any SPI child).

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**

Record: In this tree, almost every other SPI driver uses SET_SYSTEM_SLEEP_PM_OPS or DEFINE_SIMPLE_DEV_PM_OPS. Loongson was an outlier with only .suspend/.resume. That matches the S4-only failure.

===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**

Record: **Yes.** drivers/spi/spi-loongson-core.c lines 272–275:

```c
const struct dev_pm_ops loongson_spi_dev_pm_ops = {
        .suspend = loongson_spi_suspend,
        .resume = loongson_spi_resume,
};
```

Bug since driver addition (**v6.6**). This tree is **6.12.111**. Candidate not in HEAD (git log --grep='add .freeze' -- drivers/spi/spi- loongson-core.c empty).

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**

Record: **Minor context, clean functional apply.**
- This tree still has __maybe_unused on suspend/resume; the upstream hunk context dropped it.
- This tree exports SPI_LOONGSON_CORE unquoted; upstream uses "SPI_LOONGSON_CORE".
- **git apply --check of the verbatim upstream hunk failed.**
- An adapted hunk using local context **applied cleanly** (git apply --check exit 0).
- DEFINE_SIMPLE_DEV_PM_OPS exists here.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**

Record: No other loongson SPI PM/hibernation fix in this file’s history.

===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**

Record:
- **Subsystem:** SPI controller driver (drivers/spi/), Loongson/LoongArch.
- **Criticality:** **PERIPHERAL** for the kernel as a whole, **IMPORTANT** for Loongson users (SPI TPM after hibernate).
- Kconfig: SPI_LOONGSON_CORE / _PCI / _PLATFORM, depends on LOONGARCH || COMPILE_TEST.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**

Record: This driver is **mature/quiet** in 6.12 (single commit). The bug is long-standing, not a new-subsystem race.

===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================

**Step 8.1: DETERMINE WHO IS AFFECTED**

Record: **Platform-specific / driver-specific:** LoongArch systems with Loongson SPI (loongson,ls2k1000-spi or PCI 0x7a0b/0x7a1b) that hibernate. Reporter path includes Infineon SPI TPM ACPI SMO0768. Not universal.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**

Record:
- Trigger: **hibernate (S4)**, then resume. Not every boot; every successful S4 on this hardware.
- Unprivileged users cannot normally hibernate (needs CAP_SYS_BOOT / root). Not a local-DoS from unprivileged userspace.
- Not a timing race; deterministic missing callbacks.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**

Record:
- **Failure:** SPI I/O timeouts; TPM start fails (tpm_chip_start -110). Controller left unrestored after image restore.
- **Severity: HIGH** (not a panic, but broken SPI/TPM after hibernate is a serious PM regression). TPM unusable can break measured boot / TPM- backed secrets after S4.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**

Record:
- **Benefit: high** for affected Loongson/S4 users (restores SPI after hibernate).
- **Risk: very low** (~2-line helper swap, standard PM pattern, S3 path unchanged).
- **Ratio:** strongly favors backport.

===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================

**Step 9.1: COMPILE THE EVIDENCE**

**FOR:**
- Real S4 failure with dmesg; author confirmed fix.
- Buggy incomplete dev_pm_ops present in this 6.12 tree since v6.6.
- Tiny, standard DEFINE_SIMPLE_DEV_PM_OPS change; SPI maintainer requested the helper and applied v3.
- TPM (SMO0768) is a real child device in-tree.
- DEFINE_SIMPLE_DEV_PM_OPS exists here; adapted patch applies.

**AGAINST:**
- LoongArch/Loongson-only; hibernate-only (not every boot).
- Subject says “add”; no Fixes:/Cc: stable (not used as a no).
- Verbatim upstream hunk needs a one-line context tweak (namespace quotes / __maybe_unused).
- Could have used EXPORT_NS_GPL_SIMPLE_DEV_PM_OPS (style only).

**UNRESOLVED:** Could not open lore via WebFetch (403); threads were retrieved with b4 mbox and lore HTML search instead. Exact mainline SHA of the evaluation candidate was not in this checkout (a9c2f0d401fd is Mark’s spi.git apply of v3).

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**

1. Obviously correct and tested? **PASS** — standard helper; author tested S4; maintainer applied.
2. Fixes a real bug that affects users? **PASS** — SPI/TPM broken after hibernate.
3. Important issue? **PASS** — HIGH: I/O failure and TPM unusable after S4 (not a panic, still production-breaking PM).
4. Small and contained? **PASS** — one struct, one file.
5. No new features or APIs? **PASS** — missing hibernation ops, not a new API.
6. Can apply to the local tree? **PASS** — with trivial context adjustment; macros and driver exist.

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**

Record: Not a device-ID/quirk/DT/build/docs exception. It is a normal small PM bugfix.

**Step 9.4: MAKE YOUR DECISION**

This should be backported to **this 6.12 tree**. The driver has only .suspend/.resume, so hibernation never restores the controller; that matches the S4 TPM timeouts. The fix is the usual DEFINE_SIMPLE_DEV_PM_OPS mapping, already used by other SPI drivers here, with very low regression risk.

The problem for 6.12 users is that Loongson SPI (and the SPI TPM on that bus) stays dead after hibernate because hibernation callbacks were never wired. That is a real, tested, important PM bug. It meets the stable
rules: small, obviously correct, no new API, and it applies here with a trivial context tweak.

Verification:
- [Phase 1] Parsed subject/tags/body from the provided commit and v1–v3 mboxes; no Fixes/Reported-by/Cc:stable; Link msgid [email protected]
- [Phase 2] Diff: replace 4-line dev_pm_ops with DEFINE_SIMPLE_DEV_PM_OPS; functions unchanged
- [Phase 2] Confirmed SYSTEM_SLEEP_PM_OPS sets suspend/resume/freeze/thaw/poweroff/restore (include/linux/pm.h:312-318); -110 is ETIMEDOUT
- [Phase 3] git blame lines 232–276 → 6c7a864007b66; git merge-base --is-ancestor 6c7a864007b66 HEAD true; v6.5 no, v6.6 yes
- [Phase 3] git log --oneline -- drivers/spi/spi-loongson*.c only the original driver commit
- [Phase 4] b4 mbox v1/v2/v3; Mark Brown asked for SIMPLE_DEV_PM_OPS() on v1; v3 uses DEFINE_SIMPLE_DEV_PM_OPS; b4 mbox -c no newer rev
- [Phase 4] lore.kernel.org/stable ?q=loongson+spi+freeze HTTP 200, no dedicated thread
- [Phase 5] Callers: spi-loongson-plat.c:39, spi-loongson-pci.c:48; ACPI SMO0768 in tpm_tis_spi_main.c:342
- [Phase 6] git describe HEAD → p-6.12-3-gc504cf0baa3d8; make kernelversion → 6.12.111; buggy ops at spi-loongson- core.c:272-275
- [Phase 6] Original hunk git apply --check failed; adapted hunk (unquoted ns + __maybe_unused context) succeeded
- [Phase 7] Kconfig SPI_LOONGSON_* depends on LOONGARCH || COMPILE_TEST
- [Phase 8] Failure: SPI timeout / TPM start -110 after S4; severity HIGH; risk very low
- UNVERIFIED: WebFetch to lore/git.kernel.org returned 403; used b4 and curl HTML instead
- UNVERIFIED: Did not boot-test hibernate on Loongson hardware; relied on author’s dmesg and code

**YES**

 drivers/spi/spi-loongson-core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/spi/spi-loongson-core.c +2 -4
index b46f072a0387b..f07ee432f96b5 100644
@@ -270,10 +270,8 @@ static int __maybe_unused loongson_spi_resume(struct device *dev)
 	return 0;
 }
 
-const struct dev_pm_ops loongson_spi_dev_pm_ops = {
-	.suspend = loongson_spi_suspend,
-	.resume = loongson_spi_resume,
-};
+DEFINE_SIMPLE_DEV_PM_OPS(loongson_spi_dev_pm_ops, loongson_spi_suspend, loongson_spi_resume);
+
 EXPORT_SYMBOL_NS_GPL(loongson_spi_dev_pm_ops, "SPI_LOONGSON_CORE");
 
 MODULE_DESCRIPTION("Loongson SPI core driver");
Signature · 1 line
2.53.0