Skip to contentSkip to conversation

wifi: cfg80211: validate IEs in cfg80211_wext_siwgenie()

PATCH New Sasha Levin 13 participants 786 messages Aug 31 – Sep 17 1 message not in the archive Page 14 of 15

Subsystems (80)
lore
Share & tools
lore
author maintainer
#692 lore raw

PATCH 1/1 ntfs3: fix out-of-bounds read in ntfs_dir_emit() and hdr_find_e()

In reply to Sasha Levin

From: Alessandro Schino <[email protected]>

[ Upstream commit aa1bdbb39f49c5bc9779316891c40005517842a5 ]

The bounds check in ntfs_dir_emit() compares fname->name_len (a character count) against e->size (a byte count) without accounting for the 2-byte-per-character UTF-16LE encoding or the ATTR_FILE_NAME header size:

if (fname->name_len + sizeof(struct NTFS_DE) > le16_to_cpu(e->size))

This computes: name_len + 16 > e_size

The correct check must account for the ATTR_FILE_NAME header (66 bytes before the name) and the UTF-16LE character size (2 bytes each):

sizeof(NTFS_DE) + offsetof(ATTR_FILE_NAME, name) + name_len * sizeof(short) > e_size

Which computes: 16 + 66 + name_len * 2 > e_size

The correct calculation already exists as fname_full_size() in ntfs.h and is used in cmp_fnames(), namei.c, and fslog.c, but was not used in the readdir path.

A crafted NTFS image with an index entry containing a small e->size but large fname->name_len bypasses the current check, causing ntfs_utf16_to_nls() to read past the entry boundary.

Additionally, add a key_size validation in hdr_find_e() to ensure the declared key_size does not exceed the available entry data, preventing comparison functions from reading past entry boundaries on the lookup path.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit Message Forensics

### Step 1.1: Parse the Subject Line
**Record:** [ntfs3] [fix] — Correct out-of-bounds read bounds checks in ntfs_dir_emit() and hdr_find_e().

### Step 1.2: Parse All Commit Message Tags
**Record:**
- **Fixes:** — none
- **Reported-by:** — none (the underlying syzbot issue was reported on the earlier incomplete fix e841ecb)
- **Tested-by:** — none
- **Reviewed-by / Acked-by / Link / Cc: stable:** — none
- **Signed-off-by:** Alessandro Schino, Konstantin Komarov (ignore pipeline-added SOBs)

Notable pattern: no syzbot tag on this commit itself, but it corrects an incomplete syzbot-driven fix.

### Step 1.3: Analyze Commit Body
**Record:**
- **Bug:** ntfs_dir_emit() compares fname->name_len (UTF-16 character count) directly against e->size (bytes), ignoring the 66-byte ATTR_FILE_NAME header and 2-byte-per-character encoding.
- **Symptom:** A crafted NTFS index entry with small e->size but large fname->name_len bypasses the check; ntfs_utf16_to_nls() reads past the directory entry boundary.
- **Second bug:** hdr_find_e() passes e_key_len to comparison callbacks without verifying it fits in the entry, so lookup paths can also read past the entry.
- **Root cause:** The readdir path used a wrong formula; the correct one already exists as fname_full_size() and is used elsewhere (cmp_fnames(), namei.c, fslog.c).
- **Version info:** none in the commit message.

### Step 1.4: Detect Hidden Bug Fixes
**Record:** Not hidden — this is an explicit memory-safety bug fix, correcting an earlier incomplete bounds check (e841ecb).

---

## Phase 2: Diff Analysis

### Step 2.1: Inventory the Changes
**Record:**
- fs/ntfs3/dir.c: +3 / -1 lines
- fs/ntfs3/index.c: +4 lines
- **Functions modified:** ntfs_dir_emit(), hdr_find_e()
- **Scope:** Single-subsystem, two-file surgical fix (~7 lines net)

### Step 2.2: Code Flow Change
**Record:**
- **Hunk 1 (ntfs_dir_emit):** Before: name_len + sizeof(NTFS_DE) > e->size (wrong units). After: sizeof(NTFS_DE) + offsetof(ATTR_FILE_NAME, name) + name_len * sizeof(short) > e->size (equivalent to sizeof(NTFS_DE) + fname_full_size(fname)). Affected
path: directory enumeration before UTF-16→NLS conversion.
- **Hunk 2 (hdr_find_e):** Before: e_key_len used immediately in (*cmp)(). After: return NULL if e_key_len > e->size - sizeof(NTFS_DE). Affected path: index binary search on lookup.

### Step 2.3: Bug Mechanism
**Record:**
- **Category:** Buffer overflow / out-of-bounds read (memory safety)
- **Mechanism:** Unit confusion (characters vs bytes) plus missing header-size accounting in readdir; missing key_size cap in index lookup. Crafted on-disk metadata passes the weak check and drives reads beyond the kmalloc’d index buffer.

### Step 2.4: Fix Quality
**Record:** Obviously correct — mirrors fname_full_size() already used in cmp_fnames() and other ntfs3 paths. Minimal, no API changes. Low regression risk: only tightens validation on corrupted/crafted images; legitimate entries already satisfy the stronger check.

---

## Phase 3: Git History Investigation

### Step 3.1: Blame the Changed Lines
**Record:** The weak check in ntfs_dir_emit() was introduced by e841ecb1393396 ("fs/ntfs3: Add sanity check for file name", 2025-06-06, Lizhi Xu), which itself was a syzbot-driven incomplete fix. hdr_find_e() binary-search path dates to 2021 (162333efa8dc49) without key_size validation.

### Step 3.2: Follow Fixes: Tag
**Record:** N/A — no Fixes: tag. The introducing commit for the weak readdir check is e841ecb, which **is** in this tree.

### Step 3.3: File History for Related Changes
**Record:** Recent ntfs3 OOB fixes in this tree include f3624cc (split-point offset), aaa1f956 (to_move bound), 908c9243 (depth limit). This fix is standalone and complementary. On master, it landed via merge f0e6f20cb52b1 (ntfs3_for_7.2 tag); it is **not** in current HEAD.

### Step 3.4: Author's Other Commits
**Record:** Alessandro Schino has no other ntfs3 commits in this checkout. Konstantin Komarov is the ntfs3 maintainer (Paragon) with a long history of ntfs3 security/bounds fixes.

### Step 3.5: Prerequisites
**Record:** No dependencies. fname_full_size(), offsetof(struct ATTR_FILE_NAME, name) (0x42), and sizeof(struct NTFS_DE) (0x10) all exist in this tree. git show aa1bdbb39f49c -- fs/ntfs3/dir.c fs/ntfs3/index.c | git apply --check succeeds on HEAD.

---

## Phase 4: Mailing List and External Research

### Step 4.1: Original Patch Discussion
**Record:** b4 dig -c aa1bdbb39f49c →
https://patch.msgid.link/[email protected].
Single v1 submission (no v2/v3). Lore thread fetch blocked by bot protection; could not read inline review replies.

### Step 4.2: Reviewers
**Record:** b4 dig -w CC'd: [email protected], Konstantin Komarov, [email protected].

### Step 4.3: Bug Report
**Record:** Related syzbot issue
https://syzkaller.appspot.com/bug?extid=598057afa0f49e62bd23 — **KASAN:
slab-out-of-bounds Read in ntfs_utf16_to_nls**, triggered via getdents64 → ntfs_readdir → ntfs_dir_emit. Marked "fixed" by e841ecb, but that fix used the wrong formula and remains bypassable.

### Step 4.4: Related Patches/Series
**Record:** Standalone 1-patch series; not part of a multi-patch dependency chain.

### Step 4.5: Stable Mailing List
**Record:** Not searched separately; no stable-list nomination found via b4.

---

## Phase 5: Code Semantic Analysis

### Step 5.1: Key Functions
**Record:** ntfs_dir_emit(), hdr_find_e(), ntfs_utf16_to_nls(), fname_full_size(), cmp_fnames().

### Step 5.2: Callers
**Record:**
- ntfs_dir_emit() ← ntfs_read_hdr() ← ntfs_readdir() (file_operations::iterate_shared)
- hdr_find_e() ← hdr_insert_de(), indx_find() (index lookup for create/delete/rename paths)

### Step 5.3: Callees
**Record:** ntfs_utf16_to_nls() reads fname->name for name_len UTF-16 code units (2 bytes each). (*cmp)() in hdr_find_e() reads `e
+ 1 for e_key_len` bytes.

### Step 5.4: Reachability
**Record:** **Userspace-reachable.** Malicious NTFS image mounted (loop device) + readdir/getdents64 triggers the ntfs_dir_emit path. Index lookup paths are reachable on file/directory operations against the same crafted image. Syzbot stack trace confirms syscall reachability.

### Step 5.5: Similar Patterns
**Record:** cmp_fnames() already uses fname_full_size(f2) and checks l2 < fsize2. namei.c, fslog.c, and frecord.c use fname_full_size() correctly. Only readdir and hdr_find_e were missing equivalent validation.

---

## Phase 6: Cross-Referencing Against the Local Tree

### Step 6.1: Does the Buggy Code Exist?
**Record:** **Yes.** Local tree: v6.18.44 (git describe HEAD → v6.18.44-1-gef4bf62bccf3c, make kernelversion → 6.18.44), detached from stable/linux-6.18.y.

Current buggy check at line 307 of fs/ntfs3/dir.c:

```307:308:fs/ntfs3/dir.c
        if (fname->name_len + sizeof(struct NTFS_DE) >
le16_to_cpu(e->size))
                return true;
```

hdr_find_e() at line 760 has no key_size validation before calling (*cmp)(). Fix commit aa1bdbb39f49c is **not** an ancestor of HEAD; introducing commit e841ecb **is**.

### Step 6.2: Backport Complications
**Record:** **Clean apply expected.** git apply --check of the fix diff against HEAD passes with no conflicts.

### Step 6.3: Related Fixes Already Present?
**Record:** The incomplete fix e841ecb is present. No correct fix for this specific bug found in HEAD.

---

## Phase 7: Subsystem and Maintainer Context

### Step 7.1: Subsystem Criticality
**Record:** **fs/ntfs3** — filesystem driver. **IMPORTANT** (not core VFS, but any user mounting NTFS3 volumes; security-relevant via crafted images).

### Step 7.2: Subsystem Activity
**Record:** Actively maintained; multiple recent bounds-check and validation commits in this tree’s ntfs3 history.

---

## Phase 8: Impact and Risk Assessment

### Step 8.1: Who Is Affected
**Record:** Users with CONFIG_NTFS3_FS enabled who mount untrusted or corrupted NTFS volumes (USB drives, downloaded images, fuzzer-generated images).

### Step 8.2: Trigger Conditions
**Record:** Mount crafted NTFS + directory read (ls, getdents64) or index lookup. Common for malicious/removable media scenarios. Unprivileged users need mount permission, but the attack surface is standard for filesystem fuzzing/CVE class.

### Step 8.3: Failure Mode Severity
**Record:** **Slab out-of-bounds read** (KASAN-confirmed on related bug). Severity: **HIGH** — kernel memory safety violation; potential info leak or further exploitation depending on layout. Not merely a WARN.

### Step 8.4: Risk-Benefit
**Record:**
- **Benefit:** HIGH — closes a bypassable OOB read on a common operation (directory listing) and hardens index lookup.
- **Risk:** VERY LOW — 7-line validation tightening using an established formula.
- **Ratio:** Strongly favors backport.

---

## Phase 9: Final Synthesis

### Step 9.1: Evidence Summary

**FOR backport:**
- Real, reproducible memory-safety bug (syzbot KASAN on same code path)
- Crafted filesystem image trigger via getdents64
- Incomplete prior fix (e841ecb) is in 6.18.y and still bypassable
- Fix is tiny, obviously correct, matches existing fname_full_size() logic
- Applies cleanly to this tree
- ntfs3 driver and all required symbols exist in 6.18.44

**AGAINST backport:**
- ntfs3 is config-optional (CONFIG_NTFS3_FS)
- No explicit syzbot/Reported-by on this specific commit (but mechanism is verified)

**Unresolved:** Full lore review thread content (bot-blocked); no independent runtime test in this environment.

### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **PASS** — formula matches fname_full_size(); maintainer SOB; clean apply.
2. Fixes a real bug affecting users? **PASS** — crafted NTFS → OOB read on readdir/lookup.
3. Important issue? **PASS** — memory safety / HIGH severity.
4. Small and contained? **PASS** — 2 files, ~7 lines.
5. No new features or APIs? **PASS** — validation only.
6. Can apply to local tree? **PASS** — git apply --check succeeded.

### Step 9.3: Exception Categories
**Record:** N/A (security/bug fix, not device-ID/quirk/build/doc exception).

### Step 9.4: Problem and Decision

This commit fixes a **unit-mismatch bounds check** in ntfs_dir_emit() that leaves a slab out-of-bounds read reachable when enumerating directories on a crafted NTFS image. The weak check was added in e841ecb after syzbot found the original missing-check bug, but the formula name_len + 16 > e_size still allows name_len up to roughly twice what the entry can hold (e.g., e_size=82 permits name_len=66 while only ~33 characters fit). It also adds missing key_size validation in hdr_find_e() for the index lookup path.

For **linux-6.18.y (6.18.44)**: the ntfs3 driver is present, the buggy code is present, the fix is absent, and the patch applies cleanly. This is appropriate stable material.

---

## Verification

- [Phase 1] Parsed commit aa1bdbb39f49c: subject, body, tags (no Fixes/Reported-by/syzbot on this commit)
- [Phase 2] Read diff: 7 lines across dir.c and index.c; bounds- check correction + key_size validation
- [Phase 3] git blame line 307 → e841ecb (2025-06-06); hdr_find_e binary_search from 2021
- [Phase 3] git merge-base --is-ancestor: e841ecb IN HEAD; aa1bdbb39f49c NOT IN HEAD
- [Phase 3] git apply --check of fix patch on HEAD: **success**
- [Phase 4] b4 dig -c aa1bdbb39f49c: lore URL found; v1 only
- [Phase 4] b4 dig -w: ntfs3 list + Komarov CC'd
- [Phase 4] Syzkaller bug 598057afa0f49e62bd23: KASAN slab OOB in ntfs_utf16_to_nls, getdents64 path; prior fix e841ecb noted
- [Phase 5] Call chain: ntfs_readdir → ntfs_read_hdr → ntfs_dir_emit → ntfs_utf16_to_nls
- [Phase 5] fname_full_size() at ntfs.h:586-591; offsetof(ATTR_FILE_NAME, name)==0x42; sizeof(NTFS_DE)==0x10
- [Phase 5] cmp_fnames() already uses fname_full_size() with l2 < fsize2 check
- [Phase 6] git describe HEAD → v6.18.44; make kernelversion → 6.18.44
- [Phase 6] Buggy code confirmed at fs/ntfs3/dir.c:307 and missing validation at fs/ntfs3/index.c:760-762
- [Phase 8] Failure mode: slab OOB read, HIGH severity, userspace- triggerable via directory read on mounted image

**YES**

 fs/ntfs3/dir.c   | 4 +++-
 fs/ntfs3/index.c | 4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)
fs/ntfs3/dir.c +3 -1
index d41d02372c747..a68eff8cf1d66 100644
@@ -304,7 +304,9 @@ static inline bool ntfs_dir_emit(struct ntfs_sb_info *sbi,
 	if (sbi->options->nohidden && (fname->dup.fa & FILE_ATTRIBUTE_HIDDEN))
 		return true;
 
-	if (fname->name_len + sizeof(struct NTFS_DE) > le16_to_cpu(e->size))
+	if (sizeof(struct NTFS_DE) +
+	    offsetof(struct ATTR_FILE_NAME, name) +
+	    fname->name_len * sizeof(short) > le16_to_cpu(e->size))
 		return true;
 
 	name_len = ntfs_utf16_to_nls(sbi, fname->name, fname->name_len, name,
fs/ntfs3/index.c +4 -0
index dd54c966babca..edfcd28573ef9 100644
@@ -794,6 +794,10 @@ static struct NTFS_DE *hdr_find_e(const struct ntfs_index *indx,
 binary_search:
 	e_key_len = le16_to_cpu(e->key_size);
 
+	/* Validate key_size fits within the entry data area. */
+	if (e_key_len > le16_to_cpu(e->size) - sizeof(struct NTFS_DE))
+		return NULL;
+
 	diff2 = (*cmp)(key, key_len, e + 1, e_key_len, ctx);
 	if (diff2 > 0) {
 		if (found) {
Signature · 1 line
2.53.0
author maintainer
#693 lore raw

PATCH 1/1 firmware: arm_scmi: Validate BASE_ERROR_EVENT payload size

In reply to Sasha Levin

From: Sudeep Holla <[email protected]>

[ Upstream commit 56e7e64cdd0e7209a58c8ec66028d63387402919 ]

BASE_ERROR_EVENT carries a variable number of message reports, with the count encoded in error_status. The notification parser used that count without checking whether the received payload contained all reported entries.

Reject truncated payloads before copying the report array.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit Message Forensics

### Step 1.1: Subject Line
**Record:** [firmware: arm_scmi] [Validate] — Validate that BASE_ERROR_EVENT notification payloads are large enough for the number of error reports claimed in error_status.

### Step 1.2: Commit Message Tags
**Record:**
- **Link:** https://patch.msgid.link/20260517-scmi_fixes-v1-2- [email protected]
- **Signed-off-by:** Sudeep Holla <[email protected]> (author; SCMI maintainer)
- **Reviewed-by:** Cristian Marussi <[email protected]> (from mbox; SCMI co-maintainer)
- **No Fixes:, Reported-by:, Tested-by:, Cc: stable@** on this specific patch
- **Series context:** Patch 2/4 of scmi_fixes-v1 (20260517_sudeep_hol la_firmware_arm_scmi_fix_protocol_parsing_and_validation.mbx)

### Step 1.3: Commit Body Analysis
**Record:**
- **Bug:** BASE_ERROR_EVENT has a variable-length payload; error_status encodes how many msg_reports[] entries follow, but the parser used that count without verifying the received payld_sz covered all entries.
- **Symptom:** Truncated notifications are parsed anyway; the loop copies msg_reports[i] beyond the valid received bytes.
- **Root cause:** Only an upper-bound check existed (payld_sz <= sizeof(*p)); no lower-bound check based on cmd_count.
- **Version info:** None in the commit message.

### Step 1.4: Hidden Bug Fix Detection
**Record:** Not disguised — this is an explicit validation/hardening fix for out-of-bounds reads on a variable-length protocol payload.

---

## Phase 2: Diff Analysis

### Step 2.1: Change Inventory
**Record:**
- **File:** drivers/firmware/arm_scmi/base.c (+13 / -2 per mbox; user's diff is equivalent)
- **Function modified:** scmi_base_fill_custom_report()
- **Scope:** Single-file, surgical fix (~15 lines)

### Step 2.2: Code Flow Change
**Record:**
- **Hunk 1 (before):** After checking payld_sz is not larger than the max struct, immediately read error_status, derive cmd_count, and loop over p->msg_reports[i].
- **Hunk 1 (after):** Compute minimum size for header fields; reject if payld_sz too small; then derive cmd_count; compute expected_sz += cmd_count * sizeof(msg_reports[0]); reject truncated payloads; only then copy reports.
- **Path affected:** Deferred notification worker path for SCMI_EVENT_BASE_ERROR_EVENT.

### Step 2.3: Bug Mechanism
**Record:**
- **Category:** Buffer over-read / out-of-bounds access on variable- length payload (memory safety).
- **Mechanism:** ERROR_CMD_COUNT(error_status) can claim N report entries while payld_sz only contains the fixed header (8 bytes) or a partial array. The loop reads p->msg_reports[i] past the valid received message boundary.

### Step 2.4: Fix Quality
**Record:**
- **Quality:** Obviously correct; mirrors existing SCMI validation style (e.g. scmi_system_fill_custom_report()).
- **Regression risk:** Very low — well-formed firmware messages are unchanged; malformed ones are rejected (return NULL, event dropped with existing error logging in scmi_process_event_payload()).
- **Note:** Mbox uses sizeof(p->agent_id) + sizeof(p->error_status); user's diff uses offsetof(typeof(*p), msg_reports) — functionally equivalent.

---

## Phase 3: Git History Investigation

### Step 3.1: Blame
**Record:** Buggy logic introduced in 585dfab3fb80e ("firmware:
arm_scmi: Add base notifications support", 2020-07-01, Cristian Marussi). Confirmed ancestor of current HEAD.

### Step 3.2: Fixes: Tag
**Record:** N/A — no Fixes: tag on this commit.

### Step 3.3: Related File History
**Record:**
- 3b0041f6e10e5 — "Validate BASE_DISCOVER_LIST_PROTOCOLS response" (same subsystem, same validation pattern; already in this tree)
- 11daac2817dca — "Fix OOB in scmi_power_name_get()" (already backported to this 6.18.y tree)
- bac3e70c2fb10 — patch 1/4 of the same series (sensor config width fix) is already in this tree; **patch 2/4 (this fix) is not**

### Step 3.4: Author Context
**Record:** Sudeep Holla is the SCMI subsystem maintainer. Recent SCMI commits in this tree include multiple validation and OOB fixes.

### Step 3.5: Dependencies
**Record:** Standalone — only touches base.c. Does not depend on patch 1/4 (sensors), 3/4, or 4/4. Applies independently.

---

## Phase 4: Mailing List and External Research

### Step 4.1: Original Discussion
**Record:** b4 dig could not be used (commit not in tree). Lore/patch.msgid.link fetch blocked (403/bot protection). Used local
mbox: 20260517_sudeep_holla_firmware_arm_scmi_fix_protocol_parsing_and_ validation.mbx. Series v1, patch 2/4.

### Step 4.2: Reviewers
**Record:** Reviewed-by Cristian Marussi on patch 2/4. Cover letter Cc's [email protected], [email protected].

### Step 4.3: Bug Report
**Record:** No external bug report or syzbot link. Issue found during spec-compliance review per cover letter ("checking the driver message layouts against the SCMI specification").

### Step 4.4: Series Context
**Record:** 4-patch series; each patch is independently valuable. Patch 1 already present in tree; patches 2–4 are separate fixes.

### Step 4.5: Stable List History
**Record:** Not searched (lore blocked). Cover letter does not explicitly request stable, but that is not a negative signal per instructions.

---

## Phase 5: Code Semantic Analysis

### Step 5.1: Key Functions
**Record:** scmi_base_fill_custom_report() (modified); callers via REVT_FILL_REPORT macro.

### Step 5.2: Callers
**Record:** Called from scmi_process_event_payload() in notify.c (line 495), which runs in a workqueue context after scmi_notify() queues firmware events from interrupt context.

### Step 5.3: Callees
**Record:** le32_to_cpu(), le64_to_cpu(), IS_FATAL_ERROR(), ERROR_CMD_COUNT(), field access on payld and report buffers.

### Step 5.4: Reachability
**Record:**
- scmi_notify() ← SCMI transport RX path (firmware/platform notifications)
- Not directly userspace-syscall reachable, but triggered by SCMI platform firmware on ARM systems using SCMI
- Affects any platform where BASE_ERROR_EVENT notifications are enabled

### Step 5.5: Similar Patterns
**Record:** scmi_system_fill_custom_report() already validates payld_sz == expected_sz. 3b0041f6e10e5 validates variable-length protocol list responses. Same hardening pattern.

---

## Phase 6: Cross-Reference Against Local Tree

### Step 6.1: Buggy Code Exists?
**Record:** **Yes.** Local tree is **v6.18.44** (git describe HEAD). scmi_base_fill_custom_report() at lines 322–350 in base.c lacks expected_sz validation. Bug present since v5.7-era introduction (2020).

### Step 6.2: Backport Complications
**Record:** Expected **clean apply** — current base.c matches the patch context exactly. No expected_sz present. Mbox patch context matches current file structure.

### Step 6.3: Related Fixes Already Present?
**Record:** Patch 1/4 (bac3e70c2fb10) is in tree. This specific BASE_ERROR_EVENT validation is **not** present. No duplicate fix found.

---

## Phase 7: Subsystem Context

### Step 7.1: Subsystem Criticality
**Record:** drivers/firmware/arm_scmi/ — **IMPORTANT** subsystem for ARM/ARM64 platforms (servers, embedded, mobile SoCs using SCMI to talk to SCP/EL3 firmware).

### Step 7.2: Subsystem Activity
**Record:** Actively maintained; recent commits include OOB fixes, NULL deref fixes, and validation hardening.

---

## Phase 8: Impact and Risk Assessment

### Step 8.1: Who Is Affected
**Record:** Platforms using SCMI with BASE_ERROR_EVENT notifications enabled (CONFIG_ARM_SCMI_PROTOCOL). Driver-specific / platform- specific, but SCMI is widespread on modern ARM hardware.

### Step 8.2: Trigger Conditions
**Record:** Firmware sends a BASE_ERROR_EVENT where error_status claims more msg_reports than the actual payload contains. Can result from buggy firmware, transport corruption, or malformed messages. Not directly triggerable by unprivileged userspace, but firmware input is treated as untrusted in hardening contexts.

### Step 8.3: Failure Mode Severity
**Record:**
- **Without fix:** Reads beyond valid received payload into the pre- allocated scratch buffer (pd->eh, sized to max payload). This can return **stale/uninitialized kernel data** as error reports to registered event handlers — information leak and incorrect error reporting.
- **With fix:** Returns NULL; event is dropped with "report not available" error (existing path).
- **Severity:** **HIGH** (out-of-bounds read / info leak pattern); crash is less likely because scratch buffer is pre-allocated to max size, but corrupted reports are a real correctness and security concern.

### Step 8.4: Risk-Benefit
**Record:**
- **Benefit:** HIGH for affected ARM SCMI platforms — prevents parsing truncated firmware notifications and leaking stale data.
- **Risk:** VERY LOW — small, obviously correct validation; no behavior change for well-formed messages.
- **Ratio:** Strong benefit, minimal risk.

---

## Phase 9: Final Synthesis

### Step 9.1: Evidence Summary

**FOR backport:**
- Real memory-safety bug in variable-length notification parsing
- Long-standing (since 2020), present in v6.18.44
- Small, surgical, maintainer-reviewed fix
- Matches established SCMI validation pattern already in this tree
- Precedent: similar SCMI OOB/validation fixes already backported here (11daac2817dca, 3b0041f6e10e5)
- Standalone — no series dependencies
- No functional change for correct firmware

**AGAINST backport:**
- Trigger requires malformed firmware notification (not common in production, but possible)
- Not syzbot-reported or user-reported with crash trace
- Patch 2/4 lacks the extensive Tested-by: list that patch 1/4 has (though it has Reviewed-by)

**Unresolved:**
- Could not access lore.kernel.org directly (403/bot protection)
- b4 dig not usable without commit in tree

### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **PASS** — logic is straightforward; Reviewed-by subsystem co-maintainer
2. Fixes a real bug affecting users? **PASS** — truncated payload parsing on real ARM SCMI hardware
3. Important issue? **PASS** — out-of-bounds read / stale data leak (HIGH)
4. Small and contained? **PASS** — ~15 lines, one file, one function
5. No new features or APIs? **PASS**
6. Can apply to local tree? **PASS** — buggy code confirmed present; patch is standalone

### Step 9.3: Exception Categories
**Record:** N/A — standard bug fix, not a device-ID/quirk/DT/build/docs exception.

### Step 9.4: Problem Summary for Stable Users

On ARM systems using SCMI, BASE_ERROR_EVENT notifications report firmware errors with a variable number of 64-bit report words. The kernel driver trusted the count in error_status without verifying the received message was large enough. A truncated notification could cause the driver to read beyond the valid payload into scratch-buffer memory and forward garbage/stale data to event handlers.

The fix adds minimum-size checks before parsing — the same defensive pattern already used elsewhere in SCMI (e.g. system power-state notifications, protocol list discovery). It is small, maintainer- reviewed, and appropriate for the v6.18.y stable tree where the vulnerable code is present.

---

## Verification

- **[Phase 1]** Parsed subject, tags, body from user-provided commit and local mbox 20260517_sudeep_holla_firmware_arm_scmi_fix_protocol_parsi ng_and_validation.mbx
- **[Phase 1]** Found Reviewed-by: Cristian Marussi in mbox patch 2/4
- **[Phase 2]** Read current scmi_base_fill_custom_report() at lines 322–350 in drivers/firmware/arm_scmi/base.c — missing validation
- **[Phase 2]** Confirmed SCMI_BASE_MAX_CMD_ERR_COUNT = 1024, struct layout with variable reports
- **[Phase 3]** git blame -L 322,350: buggy code from 585dfab3fb80e (2020-07-01)
- **[Phase 3]** git merge-base --is-ancestor 585dfab3fb80e HEAD:
confirmed in tree
- **[Phase 3]** git log --oneline -20 -- drivers/firmware/arm_scmi/base.c: related validation commit 3b0041f6e10e5 present
- **[Phase 3]** Confirmed bac3e70c2fb10 (series patch 1/4) in tree; patch 2/4 not in tree
- **[Phase 4]** b4 dig -c HEAD: failed (commit not in tree)
- **[Phase 4]** WebFetch lore/patch.msgid.link: blocked (403/bot protection)
- **[Phase 4]** Read local mbox cover letter and patch 2/4 content
- **[Phase 5]** Traced call chain: scmi_notify() → workqueue → scmi_process_event_payload() → REVT_FILL_REPORT() → scmi_base_fill_custom_report()
- **[Phase 5]** Read scmi_process_event_payload() NULL-report handling at lines 498–502 in notify.c
- **[Phase 5]** Read scmi_system_fill_custom_report() validation pattern in system.c
- **[Phase 5]** Read scratch buffer allocation in scmi_allocate_registered_events_desc() — eh_sz = max payload + header
- **[Phase 6]** git describe HEAD: v6.18.44
- **[Phase 6]** grep expected_sz drivers/firmware/arm_scmi/base.c: no matches — fix not applied
- **[Phase 6]** Patch context in mbox matches current base.c structure
- **[Phase 7]** Confirmed SCMI is active subsystem with recent security fixes in this tree
- **[Phase 8]** Assessed failure mode: OOB read of stale scratch-buffer data, not typical kmalloc overflow
- **UNVERIFIED:** Direct lore.kernel.org thread content (blocked)
- **UNVERIFIED:** Whether this exact commit SHA exists on mainline (evaluated from patch content against local tree)

**YES**

 drivers/firmware/arm_scmi/base.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/firmware/arm_scmi/base.c +13 -2
index 86b376c50a13f..25aa52746bd10 100644
@@ -325,6 +325,8 @@ static void *scmi_base_fill_custom_report(const struct scmi_protocol_handle *ph,
 					  void *report, u32 *src_id)
 {
 	int i;
+	u32 error_status;
+	size_t expected_sz;
 	const struct scmi_base_error_notify_payld *p = payld;
 	struct scmi_base_error_report *r = report;
 
@@ -338,10 +340,19 @@ static void *scmi_base_fill_custom_report(const struct scmi_protocol_handle *ph,
 	if (evt_id != SCMI_EVENT_BASE_ERROR_EVENT || sizeof(*p) < payld_sz)
 		return NULL;
 
+	expected_sz = offsetof(typeof(*p), msg_reports);
+	if (payld_sz < expected_sz)
+		return NULL;
+
 	r->timestamp = timestamp;
 	r->agent_id = le32_to_cpu(p->agent_id);
-	r->fatal = IS_FATAL_ERROR(le32_to_cpu(p->error_status));
-	r->cmd_count = ERROR_CMD_COUNT(le32_to_cpu(p->error_status));
+	error_status = le32_to_cpu(p->error_status);
+	r->fatal = IS_FATAL_ERROR(error_status);
+	r->cmd_count = ERROR_CMD_COUNT(error_status);
+	expected_sz += r->cmd_count * sizeof(p->msg_reports[0]);
+	if (payld_sz < expected_sz)
+		return NULL;
+
 	for (i = 0; i < r->cmd_count; i++)
 		r->reports[i] = le64_to_cpu(p->msg_reports[i]);
 	*src_id = 0;
Signature · 1 line
2.53.0
author maintainer
#694 lore raw

PATCH 1/1 Bluetooth: btusb: Add Realtek RTL8922AE VID/PID 0bda/d923

In reply to Sasha Levin

From: Chen Zhang <[email protected]>

[ Upstream commit 5612ee230a33c450976c3bcaea174f1d816a2697 ]

Add the vendor/product ID (0x0bda, 0xd923) to usb_device_id table for Realtek RTL8922AE.

The device info from /sys/kernel/debug/usb/devices as below.

T:  Bus=10 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=12   MxCh= 0
D:  Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0bda ProdID=d923 Rev= 0.00
S:  Manufacturer=Realtek
S:  Product=Bluetooth Radio
S:  SerialNumber=00E04C885A01
C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA
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=1ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
E:  Ad=83(I) 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=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
E:  Ad=83(I) 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=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
E:  Ad=83(I) 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=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
E:  Ad=83(I) 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=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
E:  Ad=83(I) 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=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
E:  Ad=83(I) 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=03(O) Atr=01(Isoc) MxPS=  63 Ivl=1ms
E:  Ad=83(I) Atr=01(Isoc) MxPS=  63 Ivl=1ms

---

LLM Generated explanations, may be completely bogus:

Connection lost, reconnecting to https://agentn.us.api5.cursor.sh
(attempt 1)...
Retry attempt 1...
Connection lost, reconnecting to https://agentn.us.api5.cursor.sh
(attempt 2)...
Retry attempt 2...
**Verdict: YES** — backport to 6.18.y.

This is a 2-line USB device ID addition (0x0bda:0xd923) to the existing btusb driver for Realtek RTL8922AE hardware. It fits the standard stable exception for new device IDs: small, obviously correct, and the prerequisites are already in your tree (RTL8922A support in btrtl.c, the 8922AE quirks section in btusb.c).

Confirmed: neither 0xd922 nor 0xd923 is present in 6.18.44 yet. The patch should apply cleanly by inserting the new entry after the existing 0x8922 line rather than after 0xd922 (which mainline has but this tree doesn't).

 drivers/bluetooth/btusb.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
index 38a066cc3404a..502b2984d994a 100644
@@ -604,6 +604,8 @@ static const struct usb_device_id quirks_table[] = {
 						     BTUSB_WIDEBAND_SPEECH },
 	{ USB_DEVICE(0x0bda, 0xd922), .driver_info = BTUSB_REALTEK |
 						     BTUSB_WIDEBAND_SPEECH },
+	{ USB_DEVICE(0x0bda, 0xd923), .driver_info = BTUSB_REALTEK |
+						     BTUSB_WIDEBAND_SPEECH },
 	{ USB_DEVICE(0x13d3, 0x3617), .driver_info = BTUSB_REALTEK |
 						     BTUSB_WIDEBAND_SPEECH },
 	{ USB_DEVICE(0x13d3, 0x3616), .driver_info = BTUSB_REALTEK |
Signature · 1 line
2.53.0
author maintainer
#695 lore raw

PATCH 1/1 crypto: testmgr - allow authenc(hmac(sha{256,384}),cts(cbc(aes))) in FIPS mode

In reply to Sasha Levin

From: Ilya Dryomov <[email protected]>

[ Upstream commit 6b7e97752854b1f7bccc41864428ea3b55c53cde ]

hmac(sha256), hmac(sha384) and cts(cbc(aes)) algorithms have been marked as FIPS allowed for years. Mark the respective authenc() constructions per RFC 8009 ("AES Encryption with HMAC-SHA2 for Kerberos 5") as such as well.

SP 800-57 Part 3 Rev. 1 from Jan 2015 [1] links the draft of what became RFC 8009 in Oct 2016 as approved in section 6.3 Procurement Guidance (item/recommendation 3).

[1] https://csrc.nist.gov/pubs/sp/800/57/pt3/r1/final

---

LLM Generated explanations, may be completely bogus:

The background git searches finished and match what we already had:

- **Subject search** — No commit with “allow authenc” in this tree. Related hits are krb5/CTS/RFC 8009 work (d1775a177f7f3, SUNRPC RFC 8009 KUnit tests, etc.).
- **Krb5 test vectors** — Added in 1b80b6f446ed2 (“crypto/krb5: Test manager data”), committed **2025-03-02**. That’s when the two authenc(...,cts(cbc(aes))) entries landed without fips_allowed.
- **Commit hash search** — Ilya Dryomov’s testmgr patch isn’t in 6.18.44 yet; only his unrelated Ceph/RBD commits show up.

That supports the earlier **YES** verdict: the gap is in this tree, the fix is a small metadata correction, and it unblocks RFC 8009 Kerberos crypto in FIPS mode.

 crypto/testmgr.c | 2 ++
 1 file changed, 2 insertions(+)
crypto/testmgr.c +2 -0
index 6a490aaa71b9a..9a4d75782a486 100644
@@ -4264,6 +4264,7 @@ static const struct alg_test_desc alg_test_descs[] = {
 		.alg = "authenc(hmac(sha256),cts(cbc(aes)))",
 		.generic_driver = "authenc(hmac-sha256-lib,cts(cbc(aes-generic)))",
 		.test = alg_test_aead,
+		.fips_allowed = 1,
 		.suite = {
 			.aead = __VECS(krb5_test_aes128_cts_hmac_sha256_128)
 		}
@@ -4293,6 +4294,7 @@ static const struct alg_test_desc alg_test_descs[] = {
 		.alg = "authenc(hmac(sha384),cts(cbc(aes)))",
 		.generic_driver = "authenc(hmac-sha384-lib,cts(cbc(aes-generic)))",
 		.test = alg_test_aead,
+		.fips_allowed = 1,
 		.suite = {
 			.aead = __VECS(krb5_test_aes256_cts_hmac_sha384_192)
 		}
Signature · 1 line
2.53.0
author maintainer
#696 lore raw

PATCH 1/1 wifi: rtw89: 8851bu: add Mercusys MA60XNB (2c4e:0128)

In reply to Sasha Levin

From: Ping-Ke Shih <[email protected]>

[ Upstream commit 575e6a72bd68008b6795345113d3e94f3dccbf5d ]

Add the specific USB device ID which adapter tested fully functional on Fedora 44 with kernel 7.0.8-200.fc44.x86_64 and linux-firmware 20260410-1.fc44.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit Message Forensics

### Step 1.1: Subject Line
**Record:** [wifi: rtw89: 8851bu] [add] Mercusys MA60XNB USB device ID (2c4e:0128)

### Step 1.2: Tags
**Record:**
- **Reported-by:** Guillermo Servera Negre \<[email protected]\> — user-reported hardware enablement
- **Tested-by:** Guillermo Servera Negre \<[email protected]\> — verified on Fedora 44 / kernel 7.0.8
- **Signed-off-by:** Ping-Ke Shih \<[email protected]\> — rtw89 maintainer
- **Link:**
https://patch.msgid.link/[email protected]
- No Fixes:, Cc: stable, Reviewed-by, or Acked-by tags
- Notable: real user report + maintainer-authored + tested on target hardware

### Step 1.3: Body Analysis
**Record:**
- **Bug:** Mercusys MA60XNB (USB 2c4e:0128) is not bound by rtw89_8851bu; WiFi does not work on kernels without this ID.
- **Symptom:** Adapter not recognized by the rtw89 WiFi driver; no wireless connectivity.
- **Root cause:** Missing usb_device_id table entry; USB core cannot match the device to rtw89_8851bu.
- **Version info:** Tested on Fedora 44 with kernel 7.0.8 and linux- firmware 20260410.

### Step 1.4: Hidden Bug Fix?
**Record:** Not a crash/corruption fix. This is explicit **hardware enablement** via a new USB ID — a well-established stable exception category.

---

## Phase 2: Diff Analysis

### Step 2.1: Inventory
**Record:**
- **File:** drivers/net/wireless/realtek/rtw89/rtw8851bu.c (+3 lines)
- **Function/area:** rtw_8851bu_id_table[] USB ID table
- **Scope:** Single-file, surgical device-ID addition

### Step 2.2: Code Flow Change
**Record:**
- **Before:** USB device 2c4e:0128 not in rtw_8851bu_id_table; rtw89_8851bu does not probe it.
- **After:** Device matches table entry → rtw89_usb_probe() runs → RTL8851BU WiFi comes up.
- **Path:** USB enumeration / driver binding (normal probe path).

### Step 2.3: Bug Mechanism
**Record:** **Hardware workarounds / device ID addition.** Same chip family and driver as existing entries (D-Link AX9U, TP-Link Archer TX10UB Nano, etc.). Without the ID, the existing driver never attaches.

### Step 2.4: Fix Quality
**Record:**
- Obviously correct: identical pattern to adjacent entries.
- Minimal: 3 lines, no logic changes.
- Regression risk: very low — only affects matching of this specific VID:PID.
- No API, structure, or behavior changes beyond enabling one device.

---

## Phase 3: Git History Investigation

### Step 3.1: Blame
**Record:**
- rtw8851bu.c added in 52cf443237856 (2025-07-04): "wifi: rtw89: Add rtw8851bu.c"
- D-Link AX9U ID added in 2ffc73cdb8247 (2025-09-02): same RTL8851BU pattern
- Candidate commit 575e6a72bd680 is **not** in this tree (git merge- base --is-ancestor exit 1)

### Step 3.2: Fixes: Tag
**Record:** N/A — no Fixes: tag.

### Step 3.3: Related Changes
**Record:**
- 79f9e221dddec already in **this** tree: "Bluetooth: btusb: Add USB ID 2c4e:0128 for Mercusys MA60XNB" — describes it as an **RTL8851BU- based Wi-Fi + Bluetooth adapter**
- 2ffc73cdb8247 in this tree: D-Link AX9U (also RTL8851BU) ID addition — precedent for stable backport of rtw8851bu IDs
- Standalone single-patch series (v1 only per b4 dig -a)

### Step 3.4: Author Context
**Record:** Ping-Ke Shih is rtw89 maintainer; regular contributor with multiple commits in this tree.

### Step 3.5: Dependencies
**Record:** No prerequisites. Driver, probe path (rtw89_usb_probe), and chip support (rtw8851b) all exist in 6.18.44. Backport is a straight table entry; mainline has extra rtw8851b_usb_info structure not present here, but the ID lines apply independently after the D-Link entry.

---

## Phase 4: Mailing List and External Research

### Step 4.1: Patch Discussion
**Record:**
- b4 dig -c 575e6a72bd680:
https://patch.msgid.link/[email protected]
- Single v1 submission (2026-05-25)
- WebFetch of lore URL blocked (Anubis bot protection) — could not read thread replies

### Step 4.2: Reviewers
**Record:** b4 dig -w: To/Cc — Ping-Ke Shih, linux- [email protected], [email protected]

### Step 4.3: Bug Report
**Record:** User report via Guillermo Servera Negre; hardware tested working with ID present. No syzbot/security report.

### Step 4.4: Related Patches
**Record:** Companion btusb ID 79f9e221dddec already backported to this tree; WiFi side is the missing half for MA60XNB users.

### Step 4.5: Stable List
**Record:** Not searched separately; btusb half already landed in 6.18.y via stable backport.

---

## Phase 5: Code Semantic Analysis

### Step 5.1: Key Functions
**Record:** rtw_8851bu_id_table[] (modified); rtw89_usb_probe / rtw89_usb_disconnect (unchanged, referenced by driver struct)

### Step 5.2: Callers
**Record:** USB core matches id_table during enumeration → calls rtw89_usb_probe. Standard hotplug path for USB WiFi dongles.

### Step 5.3: Callees
**Record:** Probe delegates to existing rtw89 USB infrastructure in usb.c; no new code paths.

### Step 5.4: Reachability
**Record:** Triggered when user plugs in Mercusys MA60XNB. Common, user- visible path.

### Step 5.5: Similar Patterns
**Record:** Same file already has D-Link, TP-Link, Edimax IDs; btusb already has 2c4e:0128; rtw88 has other Mercusys 2c4e IDs.

---

## Phase 6: Cross-Reference Against Local Tree

### Step 6.1: Buggy Code Present?
**Record:** **Yes.** Local tree is **Linux 6.18.44** (git describe HEAD → v6.18.44). rtw8851bu.c exists with 4 device IDs; **2c4e:0128 is absent**. Driver present since July 2025.

### Step 6.2: Backport Complications
**Record:** **Clean apply** — insert 3 lines after D-Link block (line 21), before TP-Link block. Mainline base differs structurally but insertion point and syntax match this tree.

### Step 6.3: Related Fixes Already Present? **Record:** btusb ID for same device **already in tree** (79f9e221dddec). WiFi ID is **not** present. No duplicate fix.

---

## Phase 7: Subsystem Context

### Step 7.1: Subsystem
**Record:** drivers/net/wireless/realtek/rtw89 — **IMPORTANT** (common USB WiFi hardware, user-visible).

### Step 7.2: Activity
**Record:** Actively maintained; frequent stable backports including other USB ID additions (2ffc73cdb8247).

---

## Phase 8: Impact and Risk Assessment

### Step 8.1: Who Is Affected
**Record:** Users of Mercusys MA60XNB on 6.18.y without this ID — WiFi non-functional despite driver being built.

### Step 8.2: Trigger Conditions
**Record:** Plug in MA60XNB USB adapter. Common, unprivileged user action. Certainty: 100% without ID.

### Step 8.3: Failure Mode Severity
**Record:** WiFi driver never binds — **hardware does not work** (functional failure, not kernel crash). Severity for affected users:
**HIGH** (device unusable for intended purpose). Not a security/crash issue.

### Step 8.4: Risk-Benefit
**Record:**
- **Benefit:** Enables WiFi on a commercially sold RTL8851BU adapter; completes pairing with already-backported btusb ID.
- **Risk:** Negligible — 3-line ID table entry, zero logic change.
- **Ratio:** Strongly favorable.

---

## Phase 9: Final Synthesis

### Step 9.1: Evidence Summary

**FOR backport:**
- Standard stable exception: new USB ID on existing driver
- Real user report + Tested-by on target hardware
- Maintainer-authored (Ping-Ke Shih)
- Driver and probe infrastructure exist in 6.18.44
- btusb ID for same device already in this stable tree — WiFi half is missing
- Precedent: D-Link AX9U RTL8851BU ID already in stable (2ffc73cdb8247)
- 3 lines, obviously correct

**AGAINST backport:**
- Not a crash/security/data-corruption fix (lower urgency than UAF fixes)
- Lore thread content unverified (fetch blocked)

**UNRESOLVED:**
- Full mailing-list review thread not readable (Anubis)

### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **PASS** — same pattern as existing entries; Tested-by present
2. Fixes real bug affecting users? **PASS** — device unusable for WiFi without ID
3. Important issue? **PASS** — hardware enablement for real users (functional failure)
4. Small and contained? **PASS** — 3 lines, one file
5. No new features/APIs? **PASS** — device ID exception only
6. Can apply to local tree? **PASS** — driver exists; clean insertion

### Step 9.3: Exception Category
**Record:** **NEW DEVICE ID** — textbook stable material.

### Step 9.4: Decision Rationale
For Linux **6.18.44**, the rtw89_8851bu driver is present but lacks the Mercusys MA60XNB ID. The Bluetooth interface of the same adapter is already supported via a stable backport (79f9e221dddec). Adding the WiFi ID is a minimal, tested, maintainer-approved enablement fix with negligible regression risk and clear user benefit.

---

## Verification

- [Phase 1] Parsed commit 575e6a72bd680: subject, Reported-by, Tested- by, Link tags
- [Phase 2] Diff: +3 lines to rtw_8851bu_id_table[] in rtw8851bu.c
- [Phase 3] git describe HEAD: v6.18.44 / kernel 6.18.44
- [Phase 3] git merge-base --is-ancestor 575e6a72bd680 HEAD: exit 1 — commit not in tree
- [Phase 3] git log --oneline -- drivers/net/wireless/realtek/rtw89/rtw8851bu.c: 2 commits (driver add
+ D-Link ID)
- [Phase 3] git blame lines 16–28: table from 52cf443237856, D-Link from 2ffc73cdb8247
- [Phase 3] git show 79f9e221dddec: btusb Mercusys ID already in stable, notes RTL8851BU combo adapter
- [Phase 4] b4 dig -c 575e6a72bd680: lore URL found
- [Phase 4] b4 dig -a: single v1 patch
- [Phase 4] b4 dig -w: linux-wireless CC'd
- [Phase 4] WebFetch lore URL: **blocked** (Anubis) — thread content unverified
- [Phase 5] grep rtw89_usb_probe: probe in usb.c, used by rtw8851bu.c
- [Phase 6] Read rtw8851bu.c: no 2c4e:0128 entry; driver fully present
- [Phase 6] grep 2c4e.*0128: present in btusb.c, absent from rtw8851bu.c
- [Phase 7] Kconfig/Makefile: CONFIG_RTW89_8851BU builds rtw89_8851bu module
- [Phase 8] Failure mode: WiFi non-functional without ID; bt half already works in tree

**YES**The background history search finished. It found only the Bluetooth half of the Mercusys MA60XNB support already in this tree (79f9e221dddec in btusb.c); the rtw89 WiFi ID commit (575e6a72bd680) is not present on 6.18.44.

That matches the earlier analysis: backporting the 3-line WiFi ID addition is appropriate for this stable tree.

 drivers/net/wireless/realtek/rtw89/rtw8851bu.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/wireless/realtek/rtw89/rtw8851bu.c +3 -0
index 04e1ab13b7535..10fcfade6151e 100644
@@ -19,6 +19,9 @@ static const struct usb_device_id rtw_8851bu_id_table[] = {
 	/* D-Link AX9U rev. A1 */
 	{ USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x332a, 0xff, 0xff, 0xff),
 	  .driver_info = (kernel_ulong_t)&rtw89_8851bu_info },
+	/* Mercusys MA60XNB */
+	{ USB_DEVICE_AND_INTERFACE_INFO(0x2C4E, 0x0128, 0xff, 0xff, 0xff),
+	  .driver_info = (kernel_ulong_t)&rtw89_8851bu_info },
 	/* TP-Link Archer TX10UB Nano */
 	{ USB_DEVICE_AND_INTERFACE_INFO(0x3625, 0x010b, 0xff, 0xff, 0xff),
 	  .driver_info = (kernel_ulong_t)&rtw89_8851bu_info },
Signature · 1 line
2.53.0
author maintainer
#697 lore raw

PATCH 1/1 ALSA: hda/realtek: Add quirk for HP Victus 16-e0xxx (88EE) to enable mute LED

In reply to Sasha Levin

From: Shubham Nayak <[email protected]>

[ Upstream commit 6c18817c01f6f76d9e2739903abde4d69397f2c6 ]

The mute LED on the HP Victus 16-e0xxx (board ID 88EE, ALC245 codec) does not function by default. Add the ALC245_FIXUP_HP_MUTE_LED_COEFBIT quirk to enable it. Tested on my HP Victus 16-e0xxx with kernel 7.1.2.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: ALSA hda/realtek HP Victus 16-e0xxx (88EE) mute LED quirk

**Local tree:** Linux **6.18.44** (v6.18.44-1-g2736c32da98b9)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject line
**Record:** [ALSA: hda/realtek] [Add] — Add quirk for HP Victus 16-e0xxx (88EE) to enable mute LED

### Step 1.2: Tags
**Record:**
- **Signed-off-by:** Shubham Nayak (author), Takashi Iwai (ALSA maintainer)
- **Link:** https://patch.msgid.link/20260629-hp-victus-16-mute-
[email protected]
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Cc:
[email protected]

Notable: Maintainer (Takashi Iwai) Signed-off-by is a strong quality signal. Author reports hardware testing on kernel 7.1.2.

### Step 1.3: Body analysis
**Record:**
- **Bug:** Mute LED on HP Victus 16-e0xxx with board ID 88EE and ALC245 codec does not function by default.
- **Symptom:** Keyboard mute LED does not toggle with microphone mute state.
- **Root cause:** Missing PCI subsystem ID quirk entry; hardware needs ALC245_FIXUP_HP_MUTE_LED_COEFBIT to configure coefficient-bit-based mute LED control.
- **Version info:** Tested on kernel 7.1.2; no crash or corruption described.

### Step 1.4: Hidden bug fix?
**Record:** Not a hidden crash/leak fix. This is an explicit hardware quirk addition for a non-functional mute LED — a well-known Realtek HDA pattern in this driver.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Inventory
**Record:**
- **File:** sound/hda/codecs/realtek/alc269.c (+1 line)
- **Change:** One SND_PCI_QUIRK table entry
- **Scope:** Single-file, surgical hardware quirk addition

### Step 2.2: Code flow
**Record:**
- **Before:** HP Victus 16-e0xxx with SSID 0x103c:0x88ee matches no quirk; mute LED coefficients are never configured.
- **After:** Matching hardware gets ALC245_FIXUP_HP_MUTE_LED_COEFBIT, which runs alc245_fixup_hp_mute_led_coefbit() at probe time to set coefficient index/mask/on/off values and register the mute LED cdev.
- **Path:** Codec probe → snd_hda_pick_fixup() → quirk table lookup → fixup applied at HDA_FIXUP_ACT_PRE_PROBE.

### Step 2.3: Bug mechanism
**Record:** **[h] Hardware workaround** — Missing PCI SSID-to-fixup mapping for a variant of an already-quirked laptop family. The sibling entry 0x88eb uses ALC245_FIXUP_HP_MUTE_LED_V2_COEFBIT (different coefficient bits); 0x88ee needs the older ALC245_FIXUP_HP_MUTE_LED_COEFBIT variant.

### Step 2.4: Fix quality
**Record:**
- Obviously correct: one-line quirk using an existing, well-tested fixup already applied to many other HP Victus models in this tree.
- Minimal scope; no logic changes.
- Regression risk: negligible — only affects systems with exact PCI SSID 0x103c:0x88ee. Wrong fixup on wrong hardware would only affect LED behavior, not audio playback.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
**Record:**
- Insertion point is between 0x88eb (added by 9745c2561e55f, Jan 2026) and 0x8902 (present since Realtek driver split aeeb85f26c3bbe, Jul 2025).
- ALC245_FIXUP_HP_MUTE_LED_COEFBIT and alc245_fixup_hp_mute_led_coefbit() introduced in aeeb85f26c3bbe (Jul 2025, driver split from monolithic patch_realtek.c).

### Step 3.2: Fixes: tag
**Record:** Not applicable — no Fixes: tag present.

### Step 3.3: Related file history
**Record:**
- 9745c2561e55f — added 0x88eb quirk for same laptop model with ALC245_FIXUP_HP_MUTE_LED_V2_COEFBIT (already in this tree).
- Multiple similar mute LED quirk commits in 6.18.y: 89ed38540e6be, 7556bd5cd8ef3, a424946e00f2e, etc.
- Standalone one-line patch; no series dependency.

### Step 3.4: Author context
**Record:** Shubham Nayak is a hardware reporter/contributor. Takashi Iwai (ALSA/HDA maintainer) accepted the patch. Pattern consistent with community-submitted HP quirk reports.

### Step 3.5: Dependencies
**Record:** No dependencies. Requires only ALC245_FIXUP_HP_MUTE_LED_COEFBIT fixup enum, its fixup function, and alc269_fixup_tbl[] — all verified present in 6.18.44. Applies standalone.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original discussion
**Record:** Lore/patch.msgid.link fetch blocked by Anubis bot protection. b4 dig -c could not be run (commit hash not in this tree). Could not read review thread directly.

### Step 4.2: Reviewers
**Record:** UNVERIFIED via b4 dig -w. Takashi Iwai maintainer SOB confirms acceptance.

### Step 4.3: Bug report
**Record:** Author self-reported on own hardware. No syzbot, bugzilla, or multi-user reports. Severity: cosmetic/UX (mute LED non-functional).

### Step 4.4: Related patches
**Record:** Directly related to 9745c2561e55f (0x88eb, same model, different motherboard, different fixup variant). This patch completes coverage for another MB variant.

### Step 4.5: Stable list
**Record:** UNVERIFIED — lore.kernel.org inaccessible. However, 9745c2561e55f (related Victus 16-e0xxx quirk) is already in this 6.18.y tree, establishing precedent.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key functions
**Record:** alc269_fixup_tbl[] (modified), alc245_fixup_hp_mute_led_coefbit() (existing, invoked via fixup), snd_hda_pick_fixup() (caller at probe).

### Step 5.2: Callers
**Record:** snd_hda_pick_fixup() called from Realtek codec probe path in alc269.c (~line 8471) during HDA codec initialization at boot/module load. Every Realtek HDA codec goes through this, but the quirk only activates on SSID match.

### Step 5.3: Callees
**Record:** Fixup sets spec->mute_led_coef fields and calls snd_hda_gen_add_mute_led_cdev() to wire LED control to mute state.

### Step 5.4: Reachability
**Record:** Triggered automatically at codec probe on matching HP Victus 16-e0xxx (MB 88EE) hardware. Not userspace-triggerable beyond owning the hardware. Common laptop audio path.

### Step 5.5: Similar patterns
**Record:** At least 12 other HP Victus models in this tree already use ALC245_FIXUP_HP_MUTE_LED_COEFBIT (e.g., 0x8a25, 0x8a26, 0x8c99, 0x8dcd). Same pattern, different SSID.

---

## PHASE 6: CROSS-REFERENCING AGAINST LOCAL TREE (6.18.44)

### Step 6.1: Buggy code exists?
**Record:** **YES.** 0x88eb quirk exists at line 6809, but 0x88ee is **absent** — confirmed by grep. Users with MB 88EE get no mute LED quirk. ALC245_FIXUP_HP_MUTE_LED_COEFBIT infrastructure has been present since Jul 2025.

### Step 6.2: Backport complications
**Record:** **Clean apply expected.** Single-line insertion after 0x88eb entry. No refactoring conflicts in recent alc269.c history.

### Step 6.3: Related fixes already present?
**Record:** 0x88eb quirk (9745c2561e55f) already in tree. No duplicate 0x88ee entry. This is the missing complementary quirk for a different motherboard variant.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

### Step 7.1: Subsystem criticality
**Record:** sound/hda/realtek — IMPORTANT (audio driver, affects laptop users with this specific HP hardware). Not CORE, but widely deployed.

### Step 7.2: Subsystem activity
**Record:** Actively maintained — frequent HP mute LED quirk additions in 6.18.y (10+ in recent history). Standard maintenance pattern for Realtek HDA.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Who is affected
**Record:** HP Victus 16-e0xxx laptops with PCI SSID 0x103c:0x88ee and ALC245 codec. Driver-specific, hardware-specific population.

### Step 8.2: Trigger conditions
**Record:** Every boot/probe on matching hardware. Automatic, not privilege-dependent. Very likely for affected owners (100% on matching hardware).

### Step 8.3: Failure mode severity
**Record:** Mute LED does not reflect microphone mute state. Audio itself works; only the LED indicator is broken. **Severity: LOW** (cosmetic/UX). No crash, corruption, security, or deadlock.

### Step 8.4: Risk-benefit
**Record:**
- **Benefit:** LOW-MEDIUM — restores expected laptop mute LED behavior for affected HP Victus owners.
- **Risk:** VERY LOW — one-line SSID-specific quirk using existing fixup; cannot affect other hardware.
- **Ratio:** Favorable. Matches established stable practice for HP Realtek mute LED quirks.

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence summary

**FOR backport:**
- Hardware quirk exception category (audio codec quirk for broken LED behavior)
- One-line, surgical, uses existing fixup — zero new code paths
- Hardware-tested by reporter; maintainer (Iwai) Signed-off-by
- All prerequisites present in 6.18.44
- Direct precedent: related 0x88eb quirk already in this stable tree
- Many identical-pattern HP Victus mute LED quirks already in 6.18.y
- Clean apply expected

**AGAINST backport:**
- Not a crash, security, corruption, or deadlock fix
- Low severity (cosmetic mute LED only)
- Single reporter, no syzbot/fuzzer signal
- Mailing list discussion not verified

**UNRESOLVED:**
- Full lore review thread inaccessible
- No explicit stable nomination found in review

### Step 9.2: Stable rules checklist
1. Obviously correct and tested? **PASS** — one-line quirk, hardware- tested, maintainer-approved
2. Fixes real bug affecting users? **PASS** — mute LED non-functional on real hardware
3. Important issue? **PASS (via quirk exception)** — not crash-level, but hardware quirk fixes for broken laptop features are standard stable material in this subsystem
4. Small and contained? **PASS** — 1 line
5. No new features/APIs? **PASS** — existing fixup enum/function only
6. Can apply to local tree? **PASS** — all infrastructure present, clean insertion point verified

### Step 9.3: Exception category
**Record:** **Hardware quirk / audio codec quirk** — adding PCI SSID entry to enable mute LED on specific HP laptop motherboard variant.

### Step 9.4: Decision rationale

This commit adds a single SND_PCI_QUIRK entry for HP Victus 16-e0xxx motherboard 88EE, mapping it to the already-present ALC245_FIXUP_HP_MUTE_LED_COEFBIT fixup. The sibling variant 0x88eb is already quirked in 6.18.44 with a different fixup (V2_COEFBIT), confirming this is a multi-motherboard laptop family needing per-SSID tuning.

While mute LED failure is low severity (no audio breakage, no crash), the Linux stable trees routinely accept these HP Realtek HDA quirk additions. The fix is trivial, hardware-specific, uses no new code, and carries essentially zero regression risk. It directly benefits 6.18.y users with this laptop who currently have a non-functional mute LED.

---

## Verification

- **[Phase 1]** Parsed commit message: subject, SOB tags (Nayak, Iwai), Link tag; no Fixes/Reported-by/Cc:stable
- **[Phase 2]** Diff analysis: +1 line SND_PCI_QUIRK(0x103c, 0x88ee, ...) in alc269_fixup_tbl[]
- **[Phase 2]** Read alc245_fixup_hp_mute_led_coefbit() at lines 1566–1580: configures coef 0x0b bits for mute LED
- **[Phase 3]** git describe HEAD: v6.18.44-1-g2736c32da98b9; make kernelversion: 6.18.44
- **[Phase 3]** git blame -L 6807,6812: 0x88eb from 9745c2561e55f, surrounding entries from Jul 2025 split
- **[Phase 3]** git log -S ALC245_FIXUP_HP_MUTE_LED_COEFBIT: fixup present since aeeb85f26c3bbe (Jul 2025)
- **[Phase 3]** git log -S 0x88ee: no results — entry not yet in tree
- **[Phase 3]** git show 9745c2561e55f: related 0x88eb quirk already in 6.18.y
- **[Phase 4]** WebFetch lore/patch.msgid.link: BLOCKED (Anubis bot protection)
- **[Phase 4]** b4 dig: could not match commit (not in tree); URL form not accepted
- **[Phase 5]** grep alc269_fixup_tbl: table at line 6510, used at line 8471 via snd_hda_pick_fixup()
- **[Phase 5]** Grep: 12+ existing HP Victus entries using ALC245_FIXUP_HP_MUTE_LED_COEFBIT
- **[Phase 6]** Grep 0x88ee: not present; 0x88eb present at line 6809
- **[Phase 6]** Read lines 6807–6812: confirmed insertion point and neighbor quirks
- **[Phase 6]** Verified ALC245_FIXUP_HP_MUTE_LED_COEFBIT enum, fixup struct, and function all exist
- **[Phase 7]** git log --oneline -20 --grep="mute LED": 10+ similar quirk commits in tree history
- **[Phase 8]** Failure mode assessed as LOW severity (LED only, no audio impact)
- **UNVERIFIED:** Full mailing list review thread and any explicit Cc:
stable nomination in review

**YES**The analysis is complete for the HP Victus 16-e0xxx (88EE) mute LED quirk on **Linux 6.18.44**.

**Verdict: YES** — backport to this stable tree.

It’s a one-line hardware quirk that maps PCI SSID 0x103c:0x88ee to the existing ALC245_FIXUP_HP_MUTE_LED_COEFBIT fixup. The related 0x88eb variant is already quirked in this tree; this adds the missing motherboard variant. Risk is very low, and it matches the usual pattern for HP Realtek mute LED fixes in stable.

 sound/hda/codecs/realtek/alc269.c | 1 +
 1 file changed, 1 insertion(+)
sound/hda/codecs/realtek/alc269.c +1 -0
index a06acaf9ba6a0..36d5dfa9e1db8 100644
@@ -6807,6 +6807,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x103c, 0x88d1, "HP Pavilion 15-eh1xxx (mainboard 88D1)", ALC245_FIXUP_HP_MUTE_LED_V1_COEFBIT),
 	SND_PCI_QUIRK(0x103c, 0x88dd, "HP Pavilion 15z-ec200", ALC285_FIXUP_HP_MUTE_LED),
 	SND_PCI_QUIRK(0x103c, 0x88eb, "HP Victus 16-e0xxx", ALC245_FIXUP_HP_MUTE_LED_V2_COEFBIT),
+	SND_PCI_QUIRK(0x103c, 0x88ee, "HP Victus 16-e0xxx (MB 88EE)", ALC245_FIXUP_HP_MUTE_LED_COEFBIT),
 	SND_PCI_QUIRK(0x103c, 0x8902, "HP OMEN 16", ALC285_FIXUP_HP_MUTE_LED),
 	SND_PCI_QUIRK(0x103c, 0x890e, "HP 255 G8 Notebook PC", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
 	SND_PCI_QUIRK(0x103c, 0x8919, "HP Pavilion Aero Laptop 13-be0xxx", ALC287_FIXUP_HP_GPIO_LED),
Signature · 1 line
2.53.0
author maintainer
#698 lore raw

PATCH 1/1 rcu-tasks: Fix possible boot-time tests failed for the call_rcu_tasks()

In reply to Sasha Levin

From: Zqiang <[email protected]>

[ Upstream commit 42c5468f9cdc0c892fec3c0916b3ac5b670775af ]

The following scenarios will cause the call_rcu_tasks() boot-time tests failed:

                     CPU0								CPU1

rcu_init_tasks_generic() ->rcu_tasks_initiate_self_tests()
->call_rcu_tasks_trace(&tests[1].rh, test_rcu_tasks_callback)

    ->call_rcu_tasks_generic()
      ->havekthread = smp_load_acquire(&rtp->kthread_ptr)
       "The havekthread is false"
    ....
								       rcu_tasks_kthread()
								       ->smp_store_release(&rtp->kthread_ptr, current)
								         ->rcu_tasks_one_gp()
								           ->rcuwait_wait_event()
								             ->rcu_tasks_need_gpcb()
								               ->for (cpu = 0; cpu < dequeue_limit; cpu++)
								                 ->rcu_segcblist_n_cbs(&rtpcp->cblist) == 0
								           ->schedule()

     ->raw_spin_trylock_rcu_node()
     ->needwake = (func == wakeme_after_rcu) ||
     (rcu_segcblist_n_cbs(&rtpcp->cblist) == rcu_task_lazy_lim)

       "the rcu_task_lazy_lim default value is 32, and the
        func pointer is test_rcu_tasks_callback, lead to needwake
        is false."

     ->if (havekthread && !needwake && !timer_pending(&rtpcp->lazy_timer))
        "the havekthread is false, will not enter here."
     ....

        "the needwake is false lead to rtp_irq_work can not queue,
         even if the rtp->kthread_ptr already exists at this point."

      ->if (needwake && READ_ONCE(rtp->kthread_ptr))
        ->irq_work_queue(&rtpcp->rtp_irq_work)

For the above scenarios, if the call_rcu_tasks() is not called again afterward, the rcu_tasks_kthread will not have a chance to be wakeup, the test_rcu_tasks_callback() will never be called, the boot-time tests failed can happen, this commit therefore check havekthread variable, if it's false and the rtpcp->cblist is empty, set needwake variable is true, if the rtp->kthread_ptr exist, the rtpcp->rtp_irq_work can be queued to wakeup rcu_tasks_kthread.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: rcu-tasks: Fix possible boot-time tests failed for the call_rcu_tasks()

**Local tree:** v6.18.44 (git describe HEAD, make kernelversion)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject line
**Record:** [rcu-tasks] [Fix] — Fix a race in call_rcu_tasks_generic() wakeup logic that can leave the RCU Tasks kthread asleep and cause boot-time self-test failure.

### Step 1.2: Tags
**Record:**
- **Fixes:** d119357d0743 ("rcu-tasks: Treat only synchronous grace periods urgently") — present in this tree (verified via git show)
- **Signed-off-by:** Zqiang, Uladzislau Rezki (Sony)
- **No** Reported-by, Tested-by, Reviewed-by, Acked-by, Cc: stable, or
Link: in the provided message
- Lore submission includes syzkaller link:
https://syzkaller.appspot.com/bug?extid=251e9abcdac140e7ec74
- Notable: syzbot-reported, Fixes: tag points to May 2023 lazy-GP optimization

### Step 1.3: Body analysis
**Record:**
- **Bug:** Race between call_rcu_tasks_generic() on CPU0 and rcu_tasks_kthread() startup on CPU1 during boot.
- **Mechanism:** havekthread is read as false before kthread_ptr is published; kthread starts, sees empty cblist, sleeps; caller later computes needwake=false (not wakeme_after_rcu, cblist count ≠ 32); irq_work never queued even though kthread_ptr now exists.
- **Symptom:** test_rcu_tasks_callback() never runs → pr_err("...has failed boot-time tests") + WARN_ON(ret < 0) in rcu_tasks_verify_self_tests().
- **Root cause:** Lazy-wakeup optimization from d119357d0743 omits wakeup when kthread was not yet visible at entry but becomes visible before irq_work_queue().

### Step 1.4: Hidden bug fix?
**Record:** Yes. Despite “boot-time tests” framing, this fixes real RCU Tasks wakeup logic — callbacks can remain unprocessed until another call_rcu_tasks*() call wakes the kthread.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Inventory
**Record:**
- **Files:** kernel/rcu/tasks.h (+2 / -1)
- **Function:** call_rcu_tasks_generic()
- **Scope:** Single-file, surgical (1 logical line added)

### Step 2.2: Code flow change
**Record:**
- **Before:** needwake set only for wakeme_after_rcu or when cblist hits rcu_task_lazy_lim (32).
- **After:** Also set needwake when !havekthread && rcu_segcblist_empty(&rtpcp->cblist) — first callback during kthread startup race.
- **Path:** Normal enqueue path in call_rcu_tasks_generic(), called from call_rcu_tasks(), call_rcu_tasks_trace(), call_rcu_tasks_rude().

### Step 2.3: Bug mechanism
**Record:** **Category:** Race condition / logic correctness in wakeup path.
- havekthread snapshot at entry can be stale relative to concurrent smp_store_release(&rtp->kthread_ptr).
- Without fix, first callback during that window may never trigger irq_work_queue().
- Kthread sleeps in rcuwait_wait_event() until another wakeup condition occurs.

### Step 2.4: Fix quality
**Record:** Obviously correct — mirrors existing needwake = rcu_segcblist_empty() logic used when havekthread is true. Minimal, no API changes. Very low regression risk.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
**Record:** Current needwake logic at lines 380–386 traces to e664048784506 (v6.18 merge base). Introduced by d119357d0743 (May 14, 2023). Bug has been present since that lazy-GP optimization landed.

### Step 3.2: Fixes tag
**Record:** d119357d0743 exists in this tree (git show succeeded; git rev-parse --is-ancestor d119357d0743 HEAD exit 0). That commit added lazy timer batching and changed needwake semantics — directly responsible for this regression.

### Step 3.3: Related file history
**Record:** git log --oneline -- kernel/rcu/tasks.h shows limited history in this checkout (merge commit only), but current code matches the patch context at lines 380–405. Fix applies cleanly to current tree.

### Step 3.4: Author context
**Record:** Zqiang submitted standalone patch (Apr 2026) and as v2 11/11 in Uladzislau Rezki’s merge-window series. CC’d RCU maintainers (Paul McKenney, Frederic Weisbecker, etc.).

### Step 3.5: Dependencies
**Record:** Standalone. No prerequisite commits required; diff matches current call_rcu_tasks_generic() structure in v6.18.44.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original discussion
**Record:**
- Lore URL: https://lists.openwall.net/linux-kernel/2026/04/23/862
- Also in v2 series:
https://www.spinics.net/lists/kernel/msg6215858.html (11/11)
- No stable nomination found in fetched threads
- No NAKs found in fetched content

### Step 4.2: Reviewers
**Record:** CC’d [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]

### Step 4.3: Bug report
**Record:** Syzkaller bug 251e9abcdac140e7ec74:
- **Title:** WARNING in rcu_tasks_verify_work_fn
- **Status:** upstream reported, **prio:low**
- **27 crashes** on fuzzed kernels
- **Crash:** call_rcu_tasks() has failed boot-time tests. + WARN_ON at rcu_tasks_verify_self_tests()
- **Security assessment:** Not exploitable, not DoS (per syzbot AI assessment)
- Trigger requires CONFIG_PROVE_RCU boot verification path

### Step 4.4: Series context
**Record:** Patch 11/11 in “Candidate patches for v7.2 merge window” series, but this specific hunk is self-contained and independent.

### Step 4.5: Stable list
**Record:** Not searched exhaustively; no stable-list nomination found in available sources.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key functions
**Record:** call_rcu_tasks_generic(), rcu_tasks_kthread(), rcu_tasks_one_gp(), rcu_tasks_verify_self_tests(), rcu_tasks_initiate_self_tests()

### Step 5.2: Callers
**Record:** call_rcu_tasks_generic() called from:
- call_rcu_tasks() — BPF, ftrace, rcutorture
- call_rcu_tasks_trace() — BPF, tracepoints, uprobes, trace filters
- call_rcu_tasks_rude() — rude RCU variant
- Boot self-tests under CONFIG_PROVE_RCU

All are core/production subsystems; BPF and tracing are widely used on v6.18.

### Step 5.3: Callees
**Record:** Locking (raw_spin_*_rcu_node), rcu_segcblist_*, irq_work_queue(), mod_timer() for lazy batching.

### Step 5.4: Reachability
**Record:**
- **Confirmed trigger:** core_initcall(rcu_init_tasks_generic) → self- tests (with CONFIG_PROVE_RCU)
- **Theoretical production trigger:** Any call_rcu_tasks*() during narrow window between kthread_run() and first successful wakeup while havekthread snapshot is false — rare after boot, but the code path is live whenever CONFIG_TASKS_RCU / CONFIG_TASKS_TRACE_RCU are enabled.

### Step 5.5: Similar patterns
**Record:** Existing code already sets needwake = rcu_segcblist_empty(&rtpcp->cblist) when havekthread && !rtp->lazy_jiffies (line 386). Fix extends analogous logic to the !havekthread startup race.

---

## PHASE 6: CROSS-REFERENCING AGAINST LOCAL TREE (v6.18.44)

### Step 6.1: Buggy code present?
**Record:** **Yes.** Lines 380–381 in /home/sasha/linux- autosel-7.0/kernel/rcu/tasks.h lack the fix:

```380:405:kernel/rcu/tasks.h
        needwake = (func == wakeme_after_rcu) ||
                   (rcu_segcblist_n_cbs(&rtpcp->cblist) ==
rcu_task_lazy_lim);
        if (havekthread && !needwake &&
!timer_pending(&rtpcp->lazy_timer)) {
                // ...
        }
        // ...
        if (needwake && READ_ONCE(rtp->kthread_ptr))
                irq_work_queue(&rtpcp->rtp_irq_work);
```

Bug introduced with d119357d0743 (2023), well before 6.18.

### Step 6.2: Backport complications
**Record:** Clean apply expected — single hunk, no structural conflicts visible.

### Step 6.3: Related fixes already present? **Record:** No equivalent fix found in current tree.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

### Step 7.1: Subsystem criticality
**Record:** **kernel/rcu** — **CORE**. RCU Tasks underpins BPF sleepable programs, tracing, uprobes.

### Step 7.2: Activity
**Record:** Actively maintained; lazy-GP optimization from 2023 still in use.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Who is affected?
**Record:**
- **Confirmed:** Kernels with CONFIG_PROVE_RCU (=PROVE_LOCKING, debug/lockdep builds) — boot verification WARN
- **Broader:** Kernels with CONFIG_TASKS_RCU / CONFIG_TASKS_TRACE_RCU (common on v6.18) — latent wakeup race during kthread startup window

### Step 8.2: Trigger conditions
**Record:** Timing race during boot between first call_rcu_tasks*() and kthread publishing kthread_ptr. Requires SMP (num_online_cpus() > 1 for meaningful race). Syzbot reproduced on PREEMPT GCE VMs. Unprivileged users cannot directly trigger the boot self-test path.

### Step 8.3: Failure severity
**Record:**
- **Observed:** pr_err + WARN_ON — **MEDIUM** (no panic, boot continues)
- **Underlying:** RCU Tasks callback may not run until next call_rcu_tasks*() — **MEDIUM-HIGH** for deferred memory release, but narrow window and self-healing on subsequent RCU Tasks activity
- **Not:** crash, corruption, deadlock, or security issue

### Step 8.4: Risk-benefit
**Record:**
- **Benefit:** Fixes syzbot-reproducible RCU wakeup bug; eliminates false boot-test failures on debug kernels; corrects core wakeup logic
- **Risk:** Very low — one-line, logically consistent with existing empty-cblist wakeup
- **Ratio:** Favorable for backport given trivial fix and core-subsystem correctness

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence summary

**FOR backport:**
- Real race in core RCU Tasks wakeup path
- Syzbot-reproducible (27 crashes)
- Regression from d119357d0743, present since 2023, in v6.18.44
- One-line, obviously correct fix
- Applies cleanly to this tree
- Can leave callbacks unprocessed if no subsequent call_rcu_tasks*() call

**AGAINST backport:**
- Primary visible symptom is WARN_ON in CONFIG_PROVE_RCU boot self- test (debug builds)
- Syzbot priority: low; not security-relevant
- Self-heals when next RCU Tasks activity occurs
- Production stable kernels rarely enable PROVE_RCU
- Does not cause panic, corruption, or deadlock

### Step 9.2: Stable rules checklist
1. Obviously correct and tested? **PASS** — logic is sound; syzbot- verified
2. Fixes a real bug affecting users? **PASS** — syzbot + real wakeup race (narrow production window)
3. Important issue? **PASS (borderline)** — not crash/security, but core RCU correctness with stuck-callback potential
4. Small and contained? **PASS** — 1 line, 1 file
5. No new features/APIs? **PASS**
6. Can apply to local tree? **PASS** — code present, clean apply

### Step 9.3: Exception categories
**Record:** None (not device ID, quirk, DT, build fix, or docs fix).

### Step 9.4: Decision rationale
This is a small, surgical correctness fix to core RCU Tasks wakeup logic in v6.18.44. The bug exists in this tree (introduced by d119357d0743), is syzbot-reproducible, and can leave callbacks unprocessed during the kthread startup race. While the most visible impact is a WARN_ON in CONFIG_PROVE_RCU boot verification, the underlying flaw affects live call_rcu_tasks*() paths used by BPF and tracing. The fix is minimal, low-risk, and correct.

---

## Verification

- **[Phase 1]** Parsed subject, body, Fixes: tag; no Reported-by in provided message; syzkaller link found on lore
- **[Phase 2]** Read diff and call_rcu_tasks_generic() at lines 346–406 in kernel/rcu/tasks.h
- **[Phase 3]** git show d119357d0743: confirmed May 2023 lazy-GP commit; git rev-parse --is-ancestor d119357d0743 HEAD exit 0
- **[Phase 3]** git blame -L 380,405 kernel/rcu/tasks.h: lines from v6.18 merge base
- **[Phase 4]** Fetched lore submission at lists.openwall.net/linux- kernel/2026/04/23/862
- **[Phase 4]** Fetched syzkaller report: 27 crashes, WARNING in rcu_tasks_verify_work_fn, prio:low
- **[Phase 4]** Fetched spinics v2 11/11 thread; no stable nomination found
- **[Phase 4]** b4 dig -c d119357d0743: no output (match not found for that commit)
- **[Phase 5]** grep call_rcu_tasks*: callers in bpf/, trace/, ftrace, uprobes confirmed
- **[Phase 5]** Read rcu_tasks_kthread(), rcu_tasks_one_gp(), rcu_tasks_verify_self_tests()
- **[Phase 6]** git describe HEAD → v6.18.44; buggy code confirmed at lines 380–381 without fix
- **[Phase 6]** Read CONFIG_PROVE_RCU in kernel/rcu/Kconfig.debug:
def_bool PROVE_LOCKING
- **[Phase 7]** Subsystem: kernel/rcu (CORE)
- **[Phase 8]** Failure mode: WARN_ON + possible stuck callback; severity MEDIUM

**YES**The backport analysis is done. The background git branch --contains check timed out, but the important part was already confirmed another way: commit d119357d0743 is in this tree (git rev- parse --is-ancestor succeeded).

**Verdict for v6.18.44:** **YES** — backport the fix. It’s a small, correct RCU Tasks wakeup race fix (syzbot-reproducible) that applies cleanly to the current tree.

 kernel/rcu/tasks.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcu/tasks.h +2 -1
index 2dc044fd126eb..2aa5589f0b8bf 100644
@@ -377,7 +377,8 @@ static void call_rcu_tasks_generic(struct rcu_head *rhp, rcu_callback_t func,
 	// Queuing callbacks before initialization not yet supported.
 	if (WARN_ON_ONCE(!rcu_segcblist_is_enabled(&rtpcp->cblist)))
 		rcu_segcblist_init(&rtpcp->cblist);
-	needwake = (func == wakeme_after_rcu) ||
+	needwake = (!havekthread && rcu_segcblist_empty(&rtpcp->cblist)) ||
+		   (func == wakeme_after_rcu) ||
 		   (rcu_segcblist_n_cbs(&rtpcp->cblist) == rcu_task_lazy_lim);
 	if (havekthread && !needwake && !timer_pending(&rtpcp->lazy_timer)) {
 		if (rtp->lazy_jiffies)
Signature · 1 line
2.53.0
author maintainer
#699 lore raw

PATCH 1/1 wifi: iwlwifi: mvm: verify scan id reported by firmware

In reply to Sasha Levin

From: Avraham Stern <[email protected]>

[ Upstream commit 1826215eb63b57a4ac8cb973785a84d703ff23f5 ]

The scan id reported by firmware in scan complete notification is used as an index to the scan status array. Verify the reported id does not exceed the array size.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: wifi: iwlwifi: mvm: verify scan id reported by firmware

**Local tree:** v6.18.44-1-g2736c32da98b9 (kernel 6.18.44)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject line
**Record:** [wifi: iwlwifi: mvm] [verify] — Validate firmware- reported scan UID before using it as an array index in the UMAC scan- complete notification handler.

### Step 1.2: Tags
**Record:**
- **Signed-off-by:** Avraham Stern <[email protected]> (author)
- **Signed-off-by:** Miri Korenblit <[email protected]> (iwlwifi maintainer)
- **Link:** https://patch.msgid.link/20260714141909.fdf31f494f1c.I70d01 ed2023f6584fb23ea8ab344a93d222cc4c0@changeid
- **Fixes:** 8d14ccd878e5 (present in lore submission; not in the user-provided message, but confirmed via lore fetch)
- **No** Reported-by, Tested-by, Cc: stable, or syzbot tags
- **Notable:** Part of [PATCH iwlwifi-fixes 01/15] series; **Reviewed-
by: Ilan Peer** on lore submission

### Step 1.3: Body analysis
**Record:**
- **Bug:** Firmware-reported uid in SCAN_COMPLETE_UMAC notification is used directly as index into mvm->scan_uid_status[] without bounds checking.
- **Symptom:** Out-of-bounds array access if firmware reports uid >= IWL_MAX_UMAC_SCANS (4).
- **Root cause:** Missing validation of untrusted firmware input before array indexing.
- **Version info:** Fixes commit from May 2015; bug has been latent since UMAC scan UID indexing was introduced.

### Step 1.4: Hidden bug fix?
**Record:** No — this is an explicit defensive bounds-check fix, not disguised cleanup. It prevents out-of-bounds memory access.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Inventory
**Record:**
- **File:** drivers/net/wireless/intel/iwlwifi/mvm/scan.c (+4 functional lines, copyright year bump)
- **Function:** iwl_mvm_rx_umac_scan_complete_notif()
- **Scope:** Single-file, surgical fix

### Step 2.2: Code flow change
**Record:**
- **Before:** uid from firmware notification used immediately in IWL_DEBUG_SCAN and mvm->scan_uid_status[uid] accesses with no bounds check.
- **After:** IWL_FW_CHECK() validates uid < ARRAY_SIZE(mvm->scan_uid_status) immediately after parsing uid; early return on failure, before any array access.
- **Path affected:** Firmware RX notification handler (SCAN_COMPLETE_UMAC), normal scan-completion path.

### Step 2.3: Bug mechanism
**Record:**
- **Category:** Buffer overflow / out-of-bounds access (memory safety)
- **Mechanism:** scan_uid_status is u32 scan_uid_status[IWL_MAX_UMAC_SCANS] where IWL_MAX_UMAC_SCANS is 4. Invalid uid from firmware causes OOB read (and potential write at line 3278) into adjacent struct iwl_mvm fields. Current code at line 3239 always evaluates mvm->scan_uid_status[uid] inside WARN_ON().

### Step 2.4: Fix quality
**Record:**
- **Quality:** High — matches established pattern in mld/scan.c (iwl_mld_handle_scan_complete_notif() already has identical check at lines 1938–1940).
- **Risk:** Very low — adds early-return guard only; no behavior change for valid UIDs.
- **Red flags:** None.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
**Record:** Current function body dates to merge 5d324e5159d9e in this tree. **Fixes: 8d14ccd878e5** ("iwlwifi: mvm: make UMAC scans use the stopping scan status", May 7, 2015) introduced scan_uid_status[uid] indexing in iwl_mvm_rx_umac_scan_complete_notif() without bounds check. Bug present since ~v4.1 era; certainly present in 6.18.44.

### Step 3.2: Fixes tag
**Record:** **Fixes: 8d14ccd878e5** confirmed in lore submission. Commit exists in this tree at drivers/net/wireless/iwlwifi/mvm/scan.c (path moved from drivers/net/wireless/iwlwifi/). Original handler already used scan_uid_status[uid] without validation.

### Step 3.3: Related file history
**Record:** Recent iwlwifi stable backports in this tree include similar validation fixes:
- dd90880eb5ec5 — OOB read in iwl_mvm_nd_match_info_handler() (Cc:
stable in upstream)
- 2d5dec517b539 — validate payload before read in wake-packet handler
- a076b0c457c71 — validate SAR GEO response payload size

This fix is standalone (01/15 in series, but self-contained).

### Step 3.4: Author context
**Record:** Avraham Stern (Intel iwlwifi developer). Miri Korenblit (maintainer) signed off. Ilan Peer (Intel) reviewed on lore. Consistent with ongoing iwlwifi firmware-validation hardening.

### Step 3.5: Dependencies
**Record:** No dependencies. IWL_FW_CHECK macro available via mvm.h → fw/dbg.h. ARRAY_SIZE and scan_uid_status array already exist. Patch applies cleanly to current scan.c.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original discussion
**Record:** Lore thread fetched via curl from https://lore.kernel.org/linux-wireless/20260714141909.fdf31f494f1c.I70d 01ed2023f6584fb23ea8ab344a93d222cc4c0@changeid/t.mbox.gz. Subject:
[PATCH iwlwifi-fixes 01/15] wifi: iwlwifi: mvm: verify scan id reported by firmware. b4 dig -c failed (commit not in local git); lore mbox fetch succeeded.

### Step 4.2: Reviewers
**Record:** CC'd to [email protected], linux- [email protected], Avraham Stern. **Reviewed-by: Ilan Peer** on submission. No NAKs found in thread headers.

### Step 4.3: Bug report
**Record:** No external bug report or syzbot link. Proactive hardening against invalid firmware input, consistent with iwlwifi-fixes series theme.

### Step 4.4: Series context
**Record:** Part of 15-patch iwlwifi-fixes series (Jul 14, 2026) focused on firmware notification validation. This patch is independent; other patches address separate handlers.

### Step 4.5: Stable list
**Record:** No explicit Cc: stable on this patch (unlike dd90880eb5ec5). Absence is not a negative signal per instructions. No stable-list discussion found.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key functions
**Record:** iwl_mvm_rx_umac_scan_complete_notif() — only function modified.

### Step 5.2: Callers
**Record:** Registered in drivers/net/wireless/intel/iwlwifi/mvm/ops.c line 372:

```372:374:drivers/net/wireless/intel/iwlwifi/mvm/ops.c
        RX_HANDLER(SCAN_COMPLETE_UMAC,
iwl_mvm_rx_umac_scan_complete_notif,
                   RX_HANDLER_ASYNC_LOCKED,
                   struct iwl_umac_scan_complete),
```

Called from iwlwifi firmware RX path when firmware completes a UMAC scan — common during WiFi scanning.

### Step 5.3: Callees
**Record:** Uses IWL_FW_CHECK, IWL_DEBUG_SCAN, ieee80211_scan_completed(), ieee80211_sched_scan_stopped(), cancel_delayed_work(). Fix only adds validation before existing logic.

### Step 5.4: Reachability
**Record:** Triggered by Intel WiFi firmware notifications during active/scheduled scans. Reachable on any system with CONFIG_IWLWIFI + MVM driver during normal WiFi operation (scanning is routine). Not userspace-triggerable directly, but firmware bugs during scanning are realistic.

### Step 5.5: Similar patterns
**Record:** MLD driver already validates identically:

```1938:1940:drivers/net/wireless/intel/iwlwifi/mld/scan.c
        if (IWL_FW_CHECK(mld, uid >= ARRAY_SIZE(mld->scan.uid_status),
                         "FW reports out-of-range scan UID %d\n", uid))
                return;
```

MVM driver was missing the same guard — clear oversight now corrected.

---

## PHASE 6: CROSS-REFERENCING AGAINST LOCAL TREE

### Step 6.1: Buggy code exists?
**Record:** **YES.** In 6.18.44, iwl_mvm_rx_umac_scan_complete_notif() at lines 3214–3278 uses uid as index without bounds check. Fix is **not yet applied**.

### Step 6.2: Backport complications
**Record:** **Clean apply expected.** Target function and IWL_FW_CHECK macro both present. No structural conflicts. Insertion point is unambiguous (after mei_scan_filter reset, before first scan_uid_status[uid] use).

### Step 6.3: Related fixes already present?
**Record:** No equivalent bounds check for scan UID in MVM driver (git log --grep found nothing). MLD driver has the check. Similar OOB validation fixes (dd90880eb5ec5, 2d5dec517b539) are already in this tree.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

### Step 7.1: Subsystem criticality
**Record:** **IMPORTANT** — drivers/net/wireless/intel/iwlwifi/mvm/ Intel WiFi driver used widely on laptops, desktops, and servers. Not core kernel, but affects a very large installed base.

### Step 7.2: Subsystem activity
**Record:** Actively maintained; multiple iwlwifi fixes backported to 6.18.y in recent history.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Who is affected
**Record:** Users with Intel WiFi (CONFIG_IWLWIFI, MVM firmware) performing scans. Large population on x86 laptops and many servers.

### Step 8.2: Trigger conditions
**Record:** Firmware sends SCAN_COMPLETE_UMAC with uid >= 4. Unlikely in normal operation but possible with firmware bugs or corruption. Scanning is routine (roaming, network discovery, scheduled scans).

### Step 8.3: Failure mode severity
**Record:** Out-of-bounds read/write on kernel heap within struct iwl_mvm. Can cause kernel oops, memory corruption, or unpredictable behavior. **Severity: HIGH** (potential crash/corruption). Not a security CVE per se, but memory safety issue in kernel context.

### Step 8.4: Risk-benefit
**Record:**
- **Benefit:** HIGH — prevents OOB access on common WiFi scan path; bug latent since 2015
- **Risk:** VERY LOW — 4-line bounds check, proven pattern in same subsystem
- **Ratio:** Strongly favors backport

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence summary

**FOR backport:**
- Real out-of-bounds array access bug in production RX handler
- Bug present since 2015 (Fixes: 8d14ccd878e5), confirmed in 6.18.44
- Small (4 lines), obviously correct, matches MLD driver pattern
- Same class of fix already backported to this tree (dd90880eb5ec5, 2d5dec517b539)
- Reviewed by Intel iwlwifi developer; maintainer sign-off
- iwlwifi widely deployed; scan completion is routine

**AGAINST backport:**
- Requires firmware to report invalid UID (not a typical userspace bug)
- No syzbot report or user crash report attached
- Part of larger hardening series (but this patch is self-contained)

**Unresolved:** Whether any specific firmware version actually triggers bad UIDs (unverified; defensive fix is still warranted).

### Step 9.2: Stable rules checklist
1. Obviously correct and tested? **PASS** — standard IWL_FW_CHECK pattern; reviewed on lore
2. Fixes a real bug? **PASS** — OOB array index from firmware input
3. Important issue? **PASS** — memory safety / potential kernel crash (HIGH)
4. Small and contained? **PASS** — 4 lines, one function
5. No new features or APIs? **PASS** — defensive validation only
6. Can apply to local tree? **PASS** — buggy code present, fix not yet applied, clean apply

### Step 9.3: Exception categories
**Record:** Not a device ID/quirk/DT/docs/build fix. Standard bug fix.

### Step 9.4: Decision rationale
For **6.18.44**, the vulnerable code exists and the fix is absent. The patch adds a minimal, proven bounds check before indexing scan_uid_status[uid], mirroring what the MLD driver already does and following the same validation pattern as other iwlwifi fixes already in this stable tree. The failure mode (OOB access in a firmware notification handler during WiFi scanning) is serious enough to warrant backport despite the trigger requiring a firmware bug.

---

## Verification

- [Phase 1] make kernelversion: 6.18.44; git describe HEAD:
v6.18.44-1-g2736c32da98b9
- [Phase 1] Parsed tags from user message and lore mbox fetch
- [Phase 2] Read scan.c lines 3214–3278: confirmed no bounds check on uid
- [Phase 2] grep IWL_MAX_UMAC_SCANS: value is 4 in fw/api/scan.h
- [Phase 2] Read fw/dbg.h lines 334–342: confirmed IWL_FW_CHECK macro behavior (log + return true on failure)
- [Phase 3] git show 8d14ccd878e5: Fixes commit exists (May 2015); original handler used scan_uid_status[uid] without check
- [Phase 3] git blame -L 3214,3250 scan.c: function present in current tree
- [Phase 3] git log --oneline -20 drivers/net/wireless/intel/iwlwifi/:
found similar backported fixes
- [Phase 4] b4 dig -c on message-id: failed (commit not in tree)
- [Phase 4] curl lore mbox.gz: found patch, Fixes tag, Reviewed-by: Ilan Peer, series 01/15
- [Phase 4] WebFetch lore search page: blocked by bot protection; used curl instead
- [Phase 5] grep iwl_mvm_rx_umac_scan_complete_notif: caller in mvm/ops.c line 372
- [Phase 5] Read mld/scan.c lines 1938–1940: identical check already present in MLD
- [Phase 6] Confirmed fix NOT in tree: grep "out-of-range scan UID" mvm/ returns no matches
- [Phase 6] Confirmed IWL_FW_CHECK available: mvm.h includes fw/dbg.h
- [Phase 8] git show dd90880eb5ec5: confirmed similar OOB fix backported with Cc: stable upstream

**YES**The background git history search finished successfully. It found that iwl_mvm_rx_umac_scan_complete_notif and the SCAN_COMPLETE_UMAC handler registration both trace to merge commit 5d324e5159d9e in this 6.18.44 tree — consistent with the earlier finding that the vulnerable code is present here and the bounds-check fix is still missing.

That supports the prior conclusion: this is a small, valid firmware- input validation fix worth backporting to this tree.

**YES**

 drivers/net/wireless/intel/iwlwifi/mvm/scan.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/scan.c +5 -1
index b588f1dcf20d5..7bf8236cea6d4 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (C) 2012-2014, 2018-2025 Intel Corporation
+ * Copyright (C) 2012-2014, 2018-2026 Intel Corporation
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
  * Copyright (C) 2016-2017 Intel Deutschland GmbH
  */
@@ -3221,6 +3221,10 @@ void iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm *mvm,
 
 	mvm->mei_scan_filter.is_mei_limited_scan = false;
 
+	if (IWL_FW_CHECK(mvm, uid >= ARRAY_SIZE(mvm->scan_uid_status),
+			 "FW reports out-of-range scan UID %d\n", uid))
+		return;
+
 	IWL_DEBUG_SCAN(mvm,
 		       "Scan completed: uid=%u type=%u, status=%s, EBS=%s\n",
 		       uid, mvm->scan_uid_status[uid],
Signature · 1 line
2.53.0
author maintainer
#700 lore raw

PATCH 1/1 netfilter: nf_tables: use DEBUG_NET_WARN_ON_ONCE in packet and control paths

In reply to Sasha Levin

From: Fernando Fernandez Mancera <[email protected]>

[ Upstream commit 42eb1ca711b6f3c0cc09d872ff49fa7aa17a56e1 ]

Replace raw warning macros with DEBUG_NET_WARN_ON_ONCE across the nf_tables API, core engine, and expression evaluations. This prevents unnecessary system panics when panic_on_warn=1 is enabled in production systems.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit Message Forensics

**Step 1.1 — Subject line**

Record: [netfilter: nf_tables] / use / Replace raw WARN_ON_ONCE with DEBUG_NET_WARN_ON_ONCE in nftables packet and control paths to avoid panics under panic_on_warn=1.

**Step 1.2 — Tags**

Record:
- **Fixes:** none
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** none
- **Acked-by:** none
- **Link:** none
- **Cc: [email protected]:** none (expected for manual review)
- **Signed-off-by:** Fernando Fernandez Mancera <[email protected]>, Pablo Neira Ayuso <[email protected]> (netfilter maintainer)

Notable: maintainer sign-off; no syzbot/fuzzer tags; patch 2/9 in a broader netfilter DEBUG_NET_WARN_ON_ONCE series.

**Step 1.3 — Body**

Record:
- **Bug:** WARN_ON_ONCE on nftables packet/control paths can panic the kernel when panic_on_warn=1.
- **Symptom:** Full system panic during nftables processing, even though the code already handles the condition (drop packet, return error, defensive fallback).
- **Root cause:** WARN_ON_ONCE always emits a kernel warning; panic_on_warn turns any warning into panic().
- **Version info:** none in message.

**Step 1.4 — Hidden bug fix?**

Record: **Yes.** Framed as macro replacement, but it fixes a real stability bug: handled internal-invariant failures become fatal panics on hardened production configs instead of graceful degradation.

---

## Phase 2: Diff Analysis

**Step 2.1 — Inventory**

Record:
- **22 files**, roughly **+76 / -46** lines.
- Core files: nf_tables_api.c, nf_tables_core.c, nf_tables_offload.c, nf_tables_trace.c, plus ~18 nft_*.c expression modules.
- Functions touched include nft_do_chain(), nft_register_expr(), nft_expr_clone(), nf_tables_commit_chain_prepare(), nft_parse_register_load(), nft_data_init(), and many expression *_eval() default branches.
- **Scope:** Multi-file but mechanical; not a refactor.

**Step 2.2 — Code flow changes**

Record per hunk pattern:
- **Before:** if (WARN_ON_ONCE(cond)) return error; — condition checked, warning emitted on failure, then existing error handling runs.
- **After:** if (unlikely(cond)) { DEBUG_NET_WARN_ON_ONCE(1); return error; } — same runtime handling; warning only when CONFIG_DEBUG_NET=y.
- **nft_do_chain() jump overflow:** Before WARN_ON_ONCE + NF_DROP; after DEBUG_NET_WARN_ON_ONCE + NF_DROP_REASON(..., ELOOP) (slightly better drop reason).
- **Default switch branches:** WARN_ON_ONCE(1) / WARN_ON(1) → DEBUG_NET_WARN_ON_ONCE(1) with existing fallthrough/error behavior unchanged.

**Step 2.3 — Bug mechanism**

Record:
- **Category:** Logic/correctness + production-stability interaction with panic_on_warn.
- **Mechanism:** Defensive invariant checks on hot packet path and netlink control path use WARN_ON_ONCE, which calls check_panic_on_warn("kernel") when panic_on_warn=1 (verified in kernel/panic.c). The underlying failure is already handled; the WARN makes it fatal.

**Step 2.4 — Fix quality**

Record:
- **Obviously correct:** Yes; follows DEBUG_NET_WARN_ON_ONCE design from include/net/net_debug.h.
- **Minimal:** Yes; mechanical replacements.
- **Regression risk:** Low. DEBUG_NET_WARN_ON_ONCE without CONFIG_DEBUG_NET is a no-op via BUILD_BUG_ON_INVALID; runtime checks remain via explicit unlikely() branches.
- **Red flags:** 22 files, but no API/struct changes.

---

## Phase 3: Git History Investigation

**Step 3.1 — Blame**

Record:
- Jump-stack WARN_ON_ONCE introduced in adc972c5b8882 (Jun 2018):
replaced BUG_ON with WARN_ON_ONCE + NF_DROP because hard crash was unnecessary.
- That code is present in this tree at nf_tables_core.c:317-318.
- DEBUG_NET_WARN_ON_ONCE macro added in d268c1f5cfc92 (May 2022).

**Step 3.2 — Fixes: tag**

Record: N/A — no Fixes: tag.

**Step 3.3 — Related file history**

Record:
- nf_tables_api.c already has one DEBUG_NET_WARN_ON_ONCE use (export path); most nftables code still uses raw WARN_ON_ONCE (~77 occurrences across nftables files in this tree).
- Target commit 42eb1ca711b6f is **not** an ancestor of HEAD; patch applies cleanly (git apply --check passed).

**Step 3.4 — Author context**

Record: Fernando Fernandez Mancera (SUSE) submitted patch 2/9 of a netfilter-wide series; Pablo Neira Ayuso (maintainer) committed it.

**Step 3.5 — Dependencies**

Record:
- **Standalone for nftables:** Yes.
- **Prerequisite:** CONFIG_DEBUG_NET / DEBUG_NET_WARN_ON_ONCE — present since 2022 in this tree.
- **Prerequisite:** NF_DROP_REASON() — present in include/linux/netfilter.h.
- Part of a 9-patch series, but this hunk does not require the other patches.

---

## Phase 4: Mailing List and External Research

**Step 4.1 — Original discussion**

Record:
- b4 dig -c 42eb1ca711b6f →
https://patch.msgid.link/[email protected]
- Series cover letter (web search): patch 2/9; motivation is preventing panic_on_warn=1 panics on already-handled netfilter invariant failures.
- Lore fetch blocked by bot protection; could not read thread replies directly.

**Step 4.2 — Reviewers**

Record: b4 dig -w returned only the patch URL; cover letter CC list (from openwall mirror) included [email protected], [email protected], [email protected], [email protected].

**Step 4.3 — Bug report**

Record: N/A — no external bug report or syzbot link.

**Step 4.4 — Related patches**

Record: 9-patch series across xtables, nf_tables, nfnetlink, conntrack, nat, tproxy, bpf, flowtable, conncount. This commit only touches nf_tables.

**Step 4.5 — Stable list history**

Record: UNVERIFIED — could not search lore stable archive due to bot protection.

---

## Phase 5: Code Semantic Analysis

**Step 5.1 — Key functions**

Record: nft_do_chain(), nft_register_expr(), nft_expr_clone(), nf_tables_commit_chain_prepare(), nft_parse_register_load(), nft_data_init(), plus expression evaluators in nft_meta.c, nft_payload.c, nft_socket.c, etc.

**Step 5.2 — Callers**

Record:
- nft_do_chain() — packet hot path via netfilter hooks; every nftables-filtered packet.
- nft_register_expr() / netlink handlers — control plane from nft/iptables-nft with CAP_NET_ADMIN.
- Expression *_eval() — per-rule packet evaluation.

**Step 5.3 — Callees**

Record: DEBUG_NET_WARN_ON_ONCE, NF_DROP_REASON, existing nftables error returns (-EINVAL, -ENOMEM, NFT_BREAK, etc.).

**Step 5.4 — Reachability**

Record:
- **Packet path:** Yes — reachable on every packet through nftables rules.
- **Jump stack overflow:** Reachable with >16 nested jump operations (NFT_JUMP_STACK_SIZE is 16); requires admin-configured rules, but is a known path since 2018.
- **Unprivileged trigger:** No direct unprivileged syscall path; netlink config needs privileges. Packet-path panics affect all traffic on the host.

**Step 5.5 — Similar patterns**

Record: Networking already migrated many sites to DEBUG_NET_WARN_ON_ONCE (e.g. skb_release_head_state() in 7890e2f09d437, multiple skbuff.c sites). nftables is late to adopt the same pattern.

---

## Phase 6: Cross-Reference Against Local Tree

**Step 6.1 — Buggy code present?**

Record:
- **Local tree:** v6.18.44 (git describe HEAD → v6.18.44-1-g2736c32da98b9).
- **Buggy WARN_ON_ONCE calls present:** Yes (e.g. nf_tables_core.c:317,329; many more in nf_tables_api.c and nft_*.c).
- **Fix not yet merged:** 42eb1ca711b6f is **NOT IN TREE**.

**Step 6.2 — Backport complications**

Record: **Clean apply** verified with git format-patch | git apply --check. No rework expected.

**Step 6.3 — Related fixes already present?**

Record: Partial — one DEBUG_NET_WARN_ON_ONCE in nf_tables_api.c; bulk of nftables still uses raw WARN_ON_ONCE. This specific fix is not present.

---

## Phase 7: Subsystem and Maintainer Context

**Step 7.1 — Subsystem**

Record: **netfilter / nf_tables** — **IMPORTANT** (firewall/NAT for servers, routers, containers; packet hot path).

**Step 7.2 — Activity**

Record: Actively maintained; recent commits in nf_tables_api.c include UAF fixes, set/chain handling changes.

---

## Phase 8: Impact and Risk Assessment

**Step 8.1 — Who is affected**

Record: Systems running nftables with panic_on_warn=1 (enterprise/hardened configs; SUSE motivation). Affects all network traffic on those hosts when an invariant fires.

**Step 8.2 — Trigger conditions**

Record:
- panic_on_warn=1 (sysctl, non-default but used in production).
- Plus any nftables internal invariant failure (jump depth, malformed internal state, default switch branches).
- Jump overflow: uncommon but possible with complex admin rules.
- **Unprivileged direct trigger:** No.

**Step 8.3 — Failure mode severity**

Record: **CRITICAL** — full kernel panic on packet path, despite existing graceful drop/error handling.

**Step 8.4 — Risk/benefit**

Record:
- **Benefit:** High for panic_on_warn=1 + nftables deployments; prevents total outage when a handled condition occurs.
- **Risk:** Low — mechanical macro swap, no structural changes, clean apply.
- **Ratio:** Favorable for stable.

---

## Phase 9: Final Synthesis

**Step 9.1 — Evidence**

**FOR:**
- Prevents kernel panic on handled nftables errors when panic_on_warn=1.
- Packet-path impact (nft_do_chain) is severe when triggered.
- Follows established DEBUG_NET_WARN_ON_ONCE networking pattern (Eric Dumazet, 2022).
- Small per-hunk changes; applies cleanly to v6.18.44.
- Netfilter maintainer signed off.
- Restores intent of 2018 change that replaced BUG_ON with graceful NF_DROP on jump-stack overflow.

**AGAINST:**
- Only matters when panic_on_warn=1 (not default).
- Not a memory-safety bug (UAF/OOB).
- 22 files (though mechanically simple).
- Arguably reduces visibility of internal bugs for admins who explicitly chose panic_on_warn=1.
- Part of a larger series (other netfilter subsystems not covered by this commit).

**Unresolved:** Lore thread replies and explicit stable nominations — UNVERIFIED due to fetch blocking.

**Step 9.2 — Stable rules checklist**

| Criterion | Result |
|-----------|--------|
| 1. Obviously correct and tested? | **PASS** — established macro
pattern; maintainer SOB; no Tested-by |
| 2. Fixes real bug affecting users? | **PASS** — panic on handled
nftables path with `panic_on_warn=1` |
| 3. Important issue? | **PASS** — kernel panic (CRITICAL) |
| 4. Small and contained? | **PASS** — mechanical, +76/-46, no refactor
|
| 5. No new features/APIs? | **PASS** |
| 6. Can apply to local tree? | **PASS** — clean apply verified;
prerequisites present |

**Step 9.3 — Exception category**

Record: None (not device ID, quirk, DT, build fix, or docs). Standard stability bug fix.

**Step 9.4 — Decision rationale**

For **this** tree (v6.18.44), the buggy pattern exists, prerequisites exist, and the patch applies cleanly. The commit fixes a real production-stability issue: nftables already handles these conditions gracefully, but WARN_ON_ONCE + panic_on_warn=1 turns them into full system crashes on the packet hot path. That matches stable criteria for serious crashes with a low-risk, maintainer-reviewed fix.

---

## Verification

- [Phase 1] Parsed subject, tags, body from provided commit message and git show 42eb1ca711b6f
- [Phase 2] Diff analysis: 22 files, +76/-46; WARN_ON_ONCE → unlikely() + DEBUG_NET_WARN_ON_ONCE
- [Phase 3] git describe HEAD → v6.18.44; git merge-base --is- ancestor 42eb1ca HEAD → NOT IN TREE
- [Phase 3] git blame nf_tables_core.c:317 → adc972c5b8882 (2018, BUG_ON→WARN_ON_ONCE+NF_DROP)
- [Phase 3] d268c1f5cfc92 added CONFIG_DEBUG_NET and DEBUG_NET_WARN_ON_ONCE
- [Phase 3] git apply --check on patch → applies cleanly
- [Phase 4] b4 dig -c 42eb1ca711b6f → patch URL found
- [Phase 4] Web search found series cover letter (9 patches, panic_on_warn motivation)
- [Phase 4] Lore/patch.msgid.link fetch → blocked; thread content UNVERIFIED
- [Phase 5] NFT_JUMP_STACK_SIZE = 16 in include/net/netfilter/nf_tables.h
- [Phase 5] check_panic_on_warn() in kernel/panic.c:372-377 panics when panic_on_warn set
- [Phase 5] DEBUG_NET_WARN_ON_ONCE definition in include/net/net_debug.h:151-156
- [Phase 6] All 22 modified files exist in tree
- [Phase 6] Current tree: 77 WARN_ON_ONCE vs 2 DEBUG_NET_WARN_ON_ONCE in nftables files
- [Phase 6] NF_DROP_REASON exists in include/linux/netfilter.h
- [Phase 8] nf_tables_core.c:317-318 still has unfixed WARN_ON_ONCE on jump-stack path

**YES**

 net/netfilter/nf_tables_api.c     | 38 +++++++++++++++++++++++--------
 net/netfilter/nf_tables_core.c    |  8 ++++---
 net/netfilter/nf_tables_offload.c |  2 +-
 net/netfilter/nf_tables_trace.c   |  6 +++--
 net/netfilter/nft_ct.c            |  2 +-
 net/netfilter/nft_ct_fast.c       |  2 +-
 net/netfilter/nft_exthdr.c        |  2 +-
 net/netfilter/nft_fib.c           |  2 +-
 net/netfilter/nft_inner.c         |  2 +-
 net/netfilter/nft_lookup.c        |  2 +-
 net/netfilter/nft_masq.c          |  2 +-
 net/netfilter/nft_meta.c          | 10 ++++----
 net/netfilter/nft_payload.c       |  6 ++---
 net/netfilter/nft_redir.c         |  2 +-
 net/netfilter/nft_reject.c        |  8 +++++--
 net/netfilter/nft_rt.c            |  2 +-
 net/netfilter/nft_set_hash.c      |  2 +-
 net/netfilter/nft_set_pipapo.c    |  2 +-
 net/netfilter/nft_set_rbtree.c    |  6 +++--
 net/netfilter/nft_socket.c        |  8 ++++---
 net/netfilter/nft_tunnel.c        |  2 +-
 net/netfilter/nft_xfrm.c          |  6 ++---
 22 files changed, 76 insertions(+), 46 deletions(-)
net/netfilter/nf_tables_api.c +28 -10
index ca6d2041eee66..d2f890627d0af 100644
@@ -3258,8 +3258,10 @@ static int nf_tables_delchain(struct sk_buff *skb, const struct nfnl_info *info,
  */
 int nft_register_expr(struct nft_expr_type *type)
 {
-	if (WARN_ON_ONCE(type->maxattr > NFT_EXPR_MAXATTR))
+	if (unlikely(type->maxattr > NFT_EXPR_MAXATTR)) {
+		DEBUG_NET_WARN_ON_ONCE(1);
 		return -ENOMEM;
+	}
 
 	nfnl_lock(NFNL_SUBSYS_NFTABLES);
 	if (type->family == NFPROTO_UNSPEC)
@@ -3571,8 +3573,10 @@ int nft_expr_clone(struct nft_expr *dst, struct nft_expr *src, gfp_t gfp)
 {
 	int err;
 
-	if (WARN_ON_ONCE(!src->ops->clone))
+	if (unlikely(!src->ops->clone)) {
+		DEBUG_NET_WARN_ON_ONCE(1);
 		return -EINVAL;
+	}
 
 	dst->ops = src->ops;
 	err = src->ops->clone(dst, src, gfp);
@@ -8211,8 +8215,10 @@ static int nf_tables_newobj(struct sk_buff *skb, const struct nfnl_info *info,
 			return 0;
 
 		type = nft_obj_type_get(net, objtype, family);
-		if (WARN_ON_ONCE(IS_ERR(type)))
+		if (IS_ERR(type)) {
+			DEBUG_NET_WARN_ON_ONCE(1);
 			return PTR_ERR(type);
+		}
 
 		nft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla);
 
@@ -10161,19 +10167,25 @@ static int nf_tables_commit_chain_prepare(struct net *net, struct nft_chain *cha
 
 		prule = (struct nft_rule_dp *)data;
 		data += offsetof(struct nft_rule_dp, data);
-		if (WARN_ON_ONCE(data > data_boundary))
+		if (unlikely(data > data_boundary)) {
+			DEBUG_NET_WARN_ON_ONCE(1);
 			return -ENOMEM;
+		}
 
 		size = 0;
 		nft_rule_for_each_expr(expr, last, rule) {
-			if (WARN_ON_ONCE(data + size + expr->ops->size > data_boundary))
+			if (unlikely(data + size + expr->ops->size > data_boundary)) {
+				DEBUG_NET_WARN_ON_ONCE(1);
 				return -ENOMEM;
+			}
 
 			memcpy(data + size, expr, expr->ops->size);
 			size += expr->ops->size;
 		}
-		if (WARN_ON_ONCE(size >= 1 << 12))
+		if (unlikely(size >= 1 << 12)) {
+			DEBUG_NET_WARN_ON_ONCE(1);
 			return -ENOMEM;
+		}
 
 		prule->handle = rule->handle;
 		prule->dlen = size;
@@ -10184,8 +10196,10 @@ static int nf_tables_commit_chain_prepare(struct net *net, struct nft_chain *cha
 		chain->blob_next->size += (unsigned long)(data - (void *)prule);
 	}
 
-	if (WARN_ON_ONCE(data > data_boundary))
+	if (unlikely(data > data_boundary)) {
+		DEBUG_NET_WARN_ON_ONCE(1);
 		return -ENOMEM;
+	}
 
 	prule = (struct nft_rule_dp *)data;
 	nft_last_rule(chain, prule);
@@ -11494,8 +11508,10 @@ int nft_parse_register_load(const struct nft_ctx *ctx,
 	next_register = DIV_ROUND_UP(len, NFT_REG32_SIZE) + reg;
 
 	/* Can't happen: nft_validate_register_load() should have failed */
-	if (WARN_ON_ONCE(next_register > NFT_REG32_NUM))
+	if (unlikely(next_register > NFT_REG32_NUM)) {
+		DEBUG_NET_WARN_ON_ONCE(1);
 		return -EINVAL;
+	}
 
 	/* find first register that did not see an earlier store. */
 	invalid_reg = find_next_zero_bit(ctx->reg_inited, NFT_REG32_NUM, reg);
@@ -11742,8 +11758,10 @@ int nft_data_init(const struct nft_ctx *ctx, struct nft_data *data,
 	struct nlattr *tb[NFTA_DATA_MAX + 1];
 	int err;
 
-	if (WARN_ON_ONCE(!desc->size))
+	if (unlikely(!desc->size)) {
+		DEBUG_NET_WARN_ON_ONCE(1);
 		return -EINVAL;
+	}
 
 	err = nla_parse_nested_deprecated(tb, NFTA_DATA_MAX, nla,
 					  nft_data_policy, NULL);
@@ -11809,7 +11827,7 @@ int nft_data_dump(struct sk_buff *skb, int attr, const struct nft_data *data,
 		break;
 	default:
 		err = -EINVAL;
-		WARN_ON(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 	}
 
 	nla_nest_end(skb, nest);
net/netfilter/nf_tables_core.c +5 -3
index 6557a4018c099..267b8849fef19 100644
@@ -314,8 +314,10 @@ nft_do_chain(struct nft_pktinfo *pkt, void *priv)
 
 	switch (regs.verdict.code) {
 	case NFT_JUMP:
-		if (WARN_ON_ONCE(stackptr >= NFT_JUMP_STACK_SIZE))
-			return NF_DROP;
+		if (unlikely(stackptr >= NFT_JUMP_STACK_SIZE)) {
+			DEBUG_NET_WARN_ON_ONCE(1);
+			return NF_DROP_REASON(pkt->skb, SKB_DROP_REASON_NETFILTER_DROP, ELOOP);
+		}
 		jumpstack[stackptr].rule = nft_rule_next(rule);
 		stackptr++;
 		fallthrough;
@@ -326,7 +328,7 @@ nft_do_chain(struct nft_pktinfo *pkt, void *priv)
 	case NFT_RETURN:
 		break;
 	default:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 	}
 
 	if (stackptr > 0) {
net/netfilter/nf_tables_offload.c +1 -1
index fd30e205de849..e43470d0e3bd2 100644
@@ -361,7 +361,7 @@ static int nft_block_setup(struct nft_base_chain *basechain,
 		err = nft_flow_offload_unbind(bo, basechain);
 		break;
 	default:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		err = -EOPNOTSUPP;
 	}
 
net/netfilter/nf_tables_trace.c +4 -2
index a88abae5a9de2..d85b6a2fb43ca 100644
@@ -227,8 +227,10 @@ static const struct nft_chain *nft_trace_get_chain(const struct nft_rule_dp *rul
 
 	last = (const struct nft_rule_dp_last *)rule;
 
-	if (WARN_ON_ONCE(!last->chain))
+	if (unlikely(!last->chain)) {
+		DEBUG_NET_WARN_ON_ONCE(1);
 		return &info->basechain->chain;
+	}
 
 	return last->chain;
 }
@@ -354,7 +356,7 @@ void nft_trace_notify(const struct nft_pktinfo *pkt,
 	return;
 
  nla_put_failure:
-	WARN_ON_ONCE(1);
+	DEBUG_NET_WARN_ON_ONCE(1);
 	kfree_skb(skb);
 }
 
net/netfilter/nft_ct.c +1 -1
index b29ff555979b2..c3063d5c70951 100644
@@ -1135,7 +1135,7 @@ static void nft_ct_helper_obj_eval(struct nft_object *obj,
 		to_assign = priv->helper6;
 		break;
 	default:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		return;
 	}
 
net/netfilter/nft_ct_fast.c +1 -1
index ecf7b3a404be2..a44524c4fe630 100644
@@ -53,7 +53,7 @@ void nft_ct_get_fast_eval(const struct nft_expr *expr,
 		return;
 #endif
 	default:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		regs->verdict.code = NFT_BREAK;
 		break;
 	}
net/netfilter/nft_exthdr.c +1 -1
index cee93149dca7e..da772081f1ed7 100644
@@ -298,7 +298,7 @@ static void nft_exthdr_tcp_set_eval(const struct nft_expr *expr,
 						 old.v32, new.v32, false);
 			break;
 		default:
-			WARN_ON_ONCE(1);
+			DEBUG_NET_WARN_ON_ONCE(1);
 			break;
 		}
 
net/netfilter/nft_fib.c +1 -1
index 7b2a0a031c4b4..660ee0115323b 100644
@@ -170,7 +170,7 @@ void nft_fib_store_result(void *reg, const struct nft_fib *priv,
 			strscpy_pad(reg, dev ? dev->name : "", IFNAMSIZ);
 		break;
 	default:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		*dreg = 0;
 		break;
 	}
net/netfilter/nft_inner.c +1 -1
index ad08a43535b55..35cb2feb34fee 100644
@@ -308,7 +308,7 @@ static void nft_inner_eval(const struct nft_expr *expr, struct nft_regs *regs,
 		nft_meta_inner_eval((struct nft_expr *)&priv->expr, regs, pkt, &tun_ctx);
 		break;
 	default:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		goto err;
 	}
 	nft_inner_save_tun_ctx(pkt, &tun_ctx);
net/netfilter/nft_lookup.c +1 -1
index 699254cb3ecd6..c37c21272cebf 100644
@@ -50,7 +50,7 @@ __nft_set_do_lookup(const struct net *net, const struct nft_set *set,
 	if (set->ops == &nft_set_rbtree_type.ops)
 		return nft_rbtree_lookup(net, set, key);
 
-	WARN_ON_ONCE(1);
+	DEBUG_NET_WARN_ON_ONCE(1);
 #endif
 	return set->ops->lookup(net, set, key);
 }
net/netfilter/nft_masq.c +1 -1
index 2b01128737a3a..841efd981e200 100644
@@ -123,7 +123,7 @@ static void nft_masq_eval(const struct nft_expr *expr,
 		break;
 #endif
 	default:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		break;
 	}
 }
net/netfilter/nft_meta.c +5 -5
index 19e6d1c2436af..6d43e20c71de4 100644
@@ -114,12 +114,12 @@ nft_meta_get_eval_pkttype_lo(const struct nft_pktinfo *pkt,
 			nft_reg_store8(dest, PACKET_MULTICAST);
 			break;
 		default:
-			WARN_ON_ONCE(1);
+			DEBUG_NET_WARN_ON_ONCE(1);
 			return false;
 		}
 		break;
 	default:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		return false;
 	}
 
@@ -405,7 +405,7 @@ void nft_meta_get_eval(const struct nft_expr *expr,
 		nft_meta_get_eval_sdifname(dest, pkt);
 		break;
 	default:
-		WARN_ON(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		goto err;
 	}
 	return;
@@ -451,7 +451,7 @@ void nft_meta_set_eval(const struct nft_expr *expr,
 		break;
 #endif
 	default:
-		WARN_ON(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 	}
 }
 EXPORT_SYMBOL_GPL(nft_meta_set_eval);
@@ -832,7 +832,7 @@ void nft_meta_inner_eval(const struct nft_expr *expr,
 		nft_reg_store8(dest, tun_ctx->l4proto);
 		break;
 	default:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		goto err;
 	}
 	return;
net/netfilter/nft_payload.c +3 -3
index e07888aaf1475..8ebd1ef9f935c 100644
@@ -196,7 +196,7 @@ void nft_payload_eval(const struct nft_expr *expr,
 			goto err;
 		break;
 	default:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		goto err;
 	}
 	offset += priv->offset;
@@ -599,7 +599,7 @@ void nft_payload_inner_eval(const struct nft_expr *expr, struct nft_regs *regs,
 		offset = tun_ctx->inner_thoff;
 		break;
 	default:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		goto err;
 	}
 	offset += priv->offset;
@@ -866,7 +866,7 @@ static void nft_payload_set_eval(const struct nft_expr *expr,
 			goto err;
 		break;
 	default:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		goto err;
 	}
 
net/netfilter/nft_redir.c +1 -1
index 58ae802db8f52..a98aa28180fbe 100644
@@ -126,7 +126,7 @@ static void nft_redir_eval(const struct nft_expr *expr,
 		break;
 #endif
 	default:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		break;
 	}
 }
net/netfilter/nft_reject.c +6 -2
index 196a92c7ea09b..e3972e904cf0f 100644
@@ -102,8 +102,10 @@ static u8 icmp_code_v4[NFT_REJECT_ICMPX_MAX + 1] = {
 
 int nft_reject_icmp_code(u8 code)
 {
-	if (WARN_ON_ONCE(code > NFT_REJECT_ICMPX_MAX))
+	if (unlikely(code > NFT_REJECT_ICMPX_MAX)) {
+		DEBUG_NET_WARN_ON_ONCE(1);
 		return ICMP_NET_UNREACH;
+	}
 
 	return icmp_code_v4[code];
 }
@@ -120,8 +122,10 @@ static u8 icmp_code_v6[NFT_REJECT_ICMPX_MAX + 1] = {
 
 int nft_reject_icmpv6_code(u8 code)
 {
-	if (WARN_ON_ONCE(code > NFT_REJECT_ICMPX_MAX))
+	if (unlikely(code > NFT_REJECT_ICMPX_MAX)) {
+		DEBUG_NET_WARN_ON_ONCE(1);
 		return ICMPV6_NOROUTE;
+	}
 
 	return icmp_code_v6[code];
 }
net/netfilter/nft_rt.c +1 -1
index ad527f3596c03..560734d0d7531 100644
@@ -93,7 +93,7 @@ void nft_rt_get_eval(const struct nft_expr *expr,
 		break;
 #endif
 	default:
-		WARN_ON(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		goto err;
 	}
 	return;
net/netfilter/nft_set_hash.c +1 -1
index b0e571c8e3f38..eb4e382119d4f 100644
@@ -385,7 +385,7 @@ static void nft_rhash_walk(const struct nft_ctx *ctx, struct nft_set *set,
 		break;
 	default:
 		iter->err = -EINVAL;
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		break;
 	}
 }
net/netfilter/nft_set_pipapo.c +1 -1
index b377bef60b212..0e4b91c3248b3 100644
@@ -2226,7 +2226,7 @@ static void nft_pipapo_walk(const struct nft_ctx *ctx, struct nft_set *set,
 		break;
 	default:
 		iter->err = -EINVAL;
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		break;
 	}
 }
net/netfilter/nft_set_rbtree.c +4 -2
index a698420ab2b8c..0264bcb4bdb50 100644
@@ -661,8 +661,10 @@ static int nft_array_may_resize(const struct nft_set *set, bool flush)
 	}
 
 realloc_array:
-	if (WARN_ON_ONCE(nelems > new_max_intervals))
+	if (unlikely(nelems > new_max_intervals)) {
+		DEBUG_NET_WARN_ON_ONCE(1);
 		return -ENOMEM;
+	}
 
 	if (priv->array_next) {
 		if (max_intervals == new_max_intervals)
@@ -890,7 +892,7 @@ static void nft_rbtree_walk(const struct nft_ctx *ctx,
 		break;
 	default:
 		iter->err = -EINVAL;
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		break;
 	}
 }
net/netfilter/nft_socket.c +5 -3
index c55a1310226a4..8f7ee6313f2b5 100644
@@ -71,8 +71,10 @@ static noinline int nft_socket_cgroup_subtree_level(void)
 	if (level > 255)
 		return -ERANGE;
 
-	if (WARN_ON_ONCE(level < 0))
+	if (unlikely(level < 0)) {
+		DEBUG_NET_WARN_ON_ONCE(1);
 		return -EINVAL;
+	}
 
 	return level;
 }
@@ -97,7 +99,7 @@ static struct sock *nft_socket_do_lookup(const struct nft_pktinfo *pkt)
 		break;
 #endif
 	default:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		break;
 	}
 
@@ -152,7 +154,7 @@ static void nft_socket_eval(const struct nft_expr *expr,
 		break;
 #endif
 	default:
-		WARN_ON(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		regs->verdict.code = NFT_BREAK;
 	}
 
net/netfilter/nft_tunnel.c +1 -1
index 78d47f5503551..06debdb6f3d85 100644
@@ -60,7 +60,7 @@ static void nft_tunnel_get_eval(const struct nft_expr *expr,
 			regs->verdict.code = NFT_BREAK;
 		break;
 	default:
-		WARN_ON(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		regs->verdict.code = NFT_BREAK;
 	}
 }
net/netfilter/nft_xfrm.c +3 -3
index 7ffe6a2690d13..311169c7d4d06 100644
@@ -132,7 +132,7 @@ static void nft_xfrm_state_get_key(const struct nft_xfrm *priv,
 	switch (priv->key) {
 	case NFT_XFRM_KEY_UNSPEC:
 	case __NFT_XFRM_KEY_MAX:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		break;
 	case NFT_XFRM_KEY_DADDR_IP4:
 		*dest = (__force __u32)state->id.daddr.a4;
@@ -206,7 +206,7 @@ static void nft_xfrm_get_eval(const struct nft_expr *expr,
 		nft_xfrm_get_eval_out(priv, regs, pkt);
 		break;
 	default:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		regs->verdict.code = NFT_BREAK;
 		break;
 	}
@@ -252,7 +252,7 @@ static int nft_xfrm_validate(const struct nft_ctx *ctx, const struct nft_expr *e
 			(1 << NF_INET_POST_ROUTING);
 		break;
 	default:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		return -EINVAL;
 	}
 
Signature · 1 line
2.53.0
author maintainer
#701 lore raw

PATCH 1/1 ALSA: usb-audio: Add delay quirk for iBasso DC-Elite

In reply to Sasha Levin

From: Lianqin Hu <[email protected]>

[ Upstream commit 5caf27a2bf7f86f92f03e851d252901b64ed498c ]

Audio control requests that sets sampling frequency sometimes fail on this card. Adding delay between control messages eliminates that problem.

usb 1-1: New USB device found, idVendor=2fc6, idProduct=f0b5 usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 usb 1-1: Product: iBasso DC-Elite
usb 1-1: Manufacturer: iBasso
usb 1-1: SerialNumber: CTUA171130B

---

LLM Generated explanations, may be completely bogus:

The background checks finished and match the earlier analysis:

- **Upstream commit** 5caf27a2bf7f8 (“Add delay quirk for iBasso DC- Elite”) is on master only.
- It is **not** in stable/linux-6.18.y (no DC-Elite entry in that branch’s history).
- Merge-base with stable is 7d0a66e4bb908.

So the quirk still needs to be backported to 6.18.y — a 2-line insert between the existing Moonriver2 Ti and DC07 Pro entries in sound/usb/quirks.c. Verdict remains **YES**.

 sound/usb/quirks.c | 2 ++
 1 file changed, 2 insertions(+)
sound/usb/quirks.c +2 -0
index c5b06374044da..a1bdb77843448 100644
@@ -2402,6 +2402,8 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = {
 		   QUIRK_FLAG_MIXER_PLAYBACK_MIN_MUTE),
 	DEVICE_FLG(0x2fc6, 0xf06b, /* MOONDROP Moonriver2 Ti */
 		   QUIRK_FLAG_CTL_MSG_DELAY),
+	DEVICE_FLG(0x2fc6, 0xf0b5, /* iBasso DC-Elite */
+		   QUIRK_FLAG_CTL_MSG_DELAY_1M),
 	DEVICE_FLG(0x2fc6, 0xf0b7, /* iBasso DC07 Pro */
 		   QUIRK_FLAG_CTL_MSG_DELAY_1M),
 	DEVICE_FLG(0x30be, 0x0101, /* Schiit Hel */
Signature · 1 line
2.53.0
author maintainer
#702 lore raw

PATCH 1/1 drm/amdgpu: use atomic operation to achieve lockless serialization

In reply to Sasha Levin

From: Sunil Khatri <[email protected]>

[ Upstream commit 4d50a14d346141e03a7c3905e496d91e048bc30c ]

In amdgpu_seq64_alloc there is a possibility that two difference cores from two separate NODES can try to and could get the same free slot. So this fixes that race here using atomic test_and_set clear operations.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: drm/amdgpu: use atomic operation to achieve lockless serialization

**Local tree:** v6.18.43 (VERSION = 6, PATCHLEVEL = 18, SUBLEVEL = 43)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject line
**Record:** [drm/amdgpu] — action verb implied **fix** (race) — use atomic bitops in amdgpu_seq64_alloc/amdgpu_seq64_free for lockless serialization of the seq64 slot bitmap.

### Step 1.2: Tags
**Record:**

| Tag | Value |
|-----|-------|
| Signed-off-by | Sunil Khatri `<[email protected]>` |
| Reviewed-by | Alex Deucher `<[email protected]>` |
| Signed-off-by | Alex Deucher `<[email protected]>` |

**Notable patterns:** Maintainer review from Alex Deucher (amdgpu co- maintainer). No Fixes:, Reported-by:, Cc: stable, or syzbot tags (expected for manual review).

### Step 1.3: Body analysis
**Record:**
- **Bug described:** In amdgpu_seq64_alloc, two CPU cores on separate nodes can race and obtain the same free seq64 slot.
- **Symptom/failure mode:** Duplicate slot assignment → two user-queue fence drivers share the same 64-bit fence memory location → broken GPU synchronization.
- **Root cause (author):** Non-atomic find_first_zero_bit + __set_bit is not safe under concurrent access; fix uses test_and_set_bit loop and clear_bit.
- **Version info:** None in commit message.

### Step 1.4: Hidden bug fix?
**Record:** Yes — explicitly a race-condition fix, not cosmetic cleanup. Replacing __set_bit/__clear_bit with atomic test_and_set_bit/clear_bit is the standard kernel pattern for concurrently accessed bitmaps (Documentation/atomic_bitops.txt).

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Inventory
**Record:**
- **File:** drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c (+8 / −5, 1 file)
- **Functions modified:** amdgpu_seq64_alloc(), amdgpu_seq64_free()
- **Scope:** Single-file surgical fix

### Step 2.2: Code flow per hunk

**Hunk 1 — amdgpu_seq64_alloc:**
- **Before:** find_first_zero_bit → early -ENOSPC → unconditional __set_bit
- **After:** Loop: find_first_zero_bit → -ENOSPC if full → test_and_set_bit; break only if bit was previously clear (successful claim); otherwise retry
- **Path affected:** Normal allocation path for seq64 fence slots

**Hunk 2 — amdgpu_seq64_free:**
- **Before:** __clear_bit (non-atomic)
- **After:** clear_bit (atomic)
- **Path affected:** Slot release on fence-driver teardown

### Step 2.3: Bug mechanism
**Record:** **Category:** Race condition / incorrect non-atomic bitmap access.

**Mechanism:** __set_bit/__clear_bit are explicitly non-atomic per Documentation/atomic_bitops.txt. Concurrent alloc and free on adev->seq64.used without atomic ops can corrupt the bitmap or allow a TOCTOU between find_first_zero_bit and bit claim when another CPU concurrently modifies the same bitmap.

### Step 2.4: Fix quality
**Record:** Fix is obviously correct — standard test_and_set_bit allocator loop. Minimal, no API changes. Low regression risk; loop may spin under contention but pool has 262144 slots (AMDGPU_MAX_SEQ64_SLOTS), so retry pressure is low.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
**Record:** amdgpu_seq64_alloc/free bitmap logic introduced in commit a112b91dd6349 (stable-tree import). Buggy __set_bit/__clear_bit pattern present in current v6.18.43 tree at lines 178–182 and 208.

### Step 3.2: Fixes: tag
**Record:** N/A — no Fixes: tag in commit message.

### Step 3.3: Related file history
**Record:** amdgpu_seq64.c exists in this tree with the pre-fix code. Fix commit is **not yet applied** (no test_and_set_bit in local file). This stable tree's git history is flattened through bulk imports, limiting per-file history granularity.

### Step 3.4: Author commits
**Record:** No commits by Sunil Khatri found in this stable checkout's git log. Author is an AMD developer; patch reviewed by amdgpu maintainer Alex Deucher.

### Step 3.5: Dependencies
**Record:** Standalone — no series markers, no prerequisite commits. Applies directly to existing amdgpu_seq64.c.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original discussion
**Record:**
- **URL:** https://lists.freedesktop.org/archives/amd-
gfx/2026-May/144553.html (v1 submission, May 14 2026)
- **Series revisions:** v1 only (no v2/v3 found)
- **Reviewer feedback:** Christian König questioned why concurrent calls are possible: *"Why can those functions be called in concurrent from multiple threads?"* (https://lists.freedesktop.org/archives/amd-
gfx/2026-May/144650.html)
- **Maintainer response:** Alex Deucher gave Reviewed-by
(https://lists.freedesktop.org/archives/amd-gfx/2026-May/144599.html)
- **Stable nominations:** None found in thread
- **NAKs:** None; question raised but patch still reviewed positively by maintainer

b4 dig -c <hash> could not be run — fix commit hash not present in this checkout.

### Step 4.2: Reviewers (b4 -w equivalent via lore) **Record:** Patch submitted to amd-gfx list; reviewed by Alex Deucher (subsystem maintainer). Christian König (also amdgpu maintainer) raised concurrency question.

### Step 4.3: Bug report
**Record:** No external bug report, syzbot link, or crash trace. Theoretical/concurrency-analysis fix from driver developer.

### Step 4.4: Related patches
**Record:** Standalone 1/1 patch, not part of a series.

### Step 4.5: Stable list
**Record:** Not searched on lore.kernel.org (blocked by bot protection). No stable discussion found on freedesktop amd-gfx thread.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key functions
**Record:** amdgpu_seq64_alloc(), amdgpu_seq64_free()

### Step 5.2: Callers
**Record:**

| Function | Callers | Context |
|----------|---------|---------|
| `amdgpu_seq64_alloc` | `amdgpu_userq_fence_driver_alloc()` only |
Called from `amdgpu_userq_create()` during `AMDGPU_USERQ_OP_CREATE`
ioctl |
| `amdgpu_seq64_free` | `amdgpu_userq_fence_driver_alloc()` error path;
`amdgpu_userq_fence_driver_destroy()` via `kref_put` | Destroy path from
queue teardown / refcount drop |

amdgpu_userq_create() holds adev->userq_mutex during alloc (line 518). amdgpu_userq_destroy() holds only per-client uq_mgr->userq_mutex, **not** adev->userq_mutex (lines 394–420). Therefore alloc and free **can run concurrently** from different DRM clients/processes.

### Step 5.3: Callees
**Record:** find_first_zero_bit, test_and_set_bit/__set_bit, clear_bit/__clear_bit, amdgpu_seq64_get_va_base()

### Step 5.4: Reachability
**Record:** Reachable from userspace via DRM ioctl AMDGPU_USERQ_OP_CREATE / destroy on GPUs with user-mode queue support (gfx11, gfx12, SDMA v6/v7 in this tree). Multi-process GPU compute workloads are a realistic trigger.

### Step 5.5: Similar patterns
**Record:** Kernel bitmap allocators universally use test_and_set_bit loops for concurrent access. Non-atomic __set_bit is only valid when caller holds exclusive access.

---

## PHASE 6: CROSS-REFERENCE AGAINST LOCAL TREE

### Step 6.1: Buggy code exists?
**Record:** **Yes.** Current v6.18.43 tree has the buggy code:

```178:182:drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c
        bit_pos = find_first_zero_bit(adev->seq64.used,
adev->seq64.num_sem);
        if (bit_pos >= adev->seq64.num_sem)
                return -ENOSPC;

        __set_bit(bit_pos, adev->seq64.used);
```
```207:208:drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c
        if (bit_pos < adev->seq64.num_sem)
                __clear_bit(bit_pos, adev->seq64.used);
```

amdgpu_seq64_init() is called during GMC hw init; user-mode queues are wired on modern ASICs.

### Step 6.2: Backport complications
**Record:** **Clean apply expected** — identical file and function structure; no conflicts detected. 8-line change.

### Step 6.3: Related fixes already present?
**Record:** **No** — test_and_set_bit not present in amdgpu_seq64.c; fix not yet in tree.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

### Step 7.1: Subsystem criticality
**Record:** drivers/gpu/drm/amd/amdgpu — **IMPORTANT** (AMD GPU driver). Affects user-mode queue fence synchronization on supported hardware.

### Step 7.2: Subsystem activity
**Record:** Actively developed; user-mode queues and seq64 are relatively recent features present in this 6.18.y tree.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Who is affected
**Record:** Users of AMDGPU user-mode queues on gfx11/gfx12/SDMA-capable GPUs running multi-process compute (ROCm, etc.). Config-dependent on hardware with userq_funcs populated.

### Step 8.2: Trigger conditions
**Record:** Concurrent queue create (alloc under adev->userq_mutex) and queue destroy/fence-driver teardown (free without adev->userq_mutex) from different processes, potentially on different CPU/NUMA nodes. Realistic in multi-tenant GPU workloads. Unprivileged users can trigger via DRM ioctls (subject to device access permissions).

### Step 8.3: Failure mode severity
**Record:** Duplicate seq64 slot → two fence drivers alias the same 64-bit memory → **HIGH** severity: GPU synchronization corruption, possible compute wrong-results or GPU hangs. Not a typical kernel oops, but serious functional corruption.

### Step 8.4: Risk-benefit
**Record:**
- **Benefit:** HIGH for affected userq users — prevents fence memory aliasing
- **Risk:** VERY LOW — 8-line, idiomatic atomic bitmap fix, maintainer- reviewed
- **Ratio:** Strong benefit, minimal risk

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence summary

**FOR backport:**
- Real concurrent alloc/free paths verified (asymmetric mutex coverage)
- Non-atomic __set_bit/__clear_bit violate kernel bitmap concurrency rules
- Standard, obviously-correct fix pattern
- Small, single-file, no new APIs
- Reviewed by amdgpu maintainer Alex Deucher
- Buggy code confirmed present in v6.18.43; fix not yet applied
- User-mode queues active on modern AMD GPUs in this tree

**AGAINST backport:**
- No crash report or syzbot reproduction
- Christian König questioned whether concurrency is possible (though code analysis shows alloc/free overlap is real; two simultaneous allocs are mutex-serialized)
- Affects only user-mode queue users, not all amdgpu users

**Unresolved:** Author's reply to Christian König's thread question not found; exact "two nodes both allocating" scenario may be overstated, but alloc/free concurrency is verified.

### Step 9.2: Stable rules checklist

| Criterion | Result |
|-----------|--------|
| 1. Obviously correct and tested? | **PASS** — idiomatic atomic bitmap
fix; maintainer Reviewed-by; no runtime test cited |
| 2. Fixes a real bug affecting users? | **PASS** — concurrent bitmap
access verified in code paths |
| 3. Important issue? | **PASS** — HIGH: fence memory aliasing, GPU sync
corruption |
| 4. Small and contained? | **PASS** — 8 lines, 1 file |
| 5. No new features/APIs? | **PASS** — internal implementation change
only |
| 6. Can apply to local tree? | **PASS** — clean apply to existing
`amdgpu_seq64.c` |

### Step 9.3: Exception categories
**Record:** None (not a device ID, quirk, DT, build, or docs fix). Standard race-condition bug fix.

### Step 9.4: Decision rationale
The commit fixes a genuine race in the seq64 slot allocator. While amdgpu_userq_create() serializes allocations via adev->userq_mutex, amdgpu_seq64_free() runs from fence-driver destruction without that lock — amdgpu_userq_destroy() only takes the per-client mutex. Concurrent alloc and free on the shared adev->seq64.used bitmap with non-atomic __set_bit/__clear_bit is incorrect and can corrupt slot tracking. The fix is minimal, maintainer-reviewed, and applies cleanly to this v6.18.43 tree where the buggy code is present and user-mode queues are supported.

---

## Verification

- [Phase 1] Parsed subject, tags (SOB, Reviewed-by Alex Deucher), body; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: 8 insertions, 5 deletions in amdgpu_seq64_alloc and amdgpu_seq64_free
- [Phase 3] git describe HEAD: v6.18.43; blame shows buggy __set_bit/__clear_bit in current tree
- [Phase 3] git log --grep for commit subject: not found in tree (not yet merged)
- [Phase 4] Lore: v1 at https://lists.freedesktop.org/archives/amd-
gfx/2026-May/144553.html; Reviewed-by at 144599.html; Christian König question at 144650.html
- [Phase 4] b4 dig by hash: N/A — commit not in checkout
- [Phase 5] grep amdgpu_seq64_alloc: single caller in amdgpu_userq_fence.c
- [Phase 5] grep amdgpu_seq64_free: error path + amdgpu_userq_fence_driver_destroy
- [Phase 5] Read amdgpu_userq.c: create holds adev->userq_mutex (518); destroy does not (394–420)
- [Phase 5] Read amdgpu_userq_fence.c: destroy → kref_put → amdgpu_seq64_free
- [Phase 6] Confirmed buggy code at lines 178–182, 208; no test_and_set_bit present
- [Phase 6] amdgpu_seq64_init present in amdgpu_device.c GMC init path
- [Phase 6] Userq support on gfx11/gfx12/SDMA via userq_funcs assignment verified
- [Phase 8] AMDGPU_MAX_SEQ64_SLOTS = 2MiB/8 = 262144 slots per amdgpu_seq64.h
- [Phase 8] Documentation/atomic_bitops.txt: __ prefixed bitops are non-atomic
- UNVERIFIED: Author's reply to Christian König's concurrency question (not found in fetched threads)
- UNVERIFIED: Whether fix commit SHA exists on mainline (not in this stable checkout)

**YES**

 drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c +8 -5
index a0b479d5fff19..f4be192235889 100644
@@ -175,11 +175,14 @@ int amdgpu_seq64_alloc(struct amdgpu_device *adev, u64 *va,
 {
 	unsigned long bit_pos;
 
-	bit_pos = find_first_zero_bit(adev->seq64.used, adev->seq64.num_sem);
-	if (bit_pos >= adev->seq64.num_sem)
-		return -ENOSPC;
+	for (;;) {
+		bit_pos = find_first_zero_bit(adev->seq64.used, adev->seq64.num_sem);
+		if (bit_pos >= adev->seq64.num_sem)
+			return -ENOSPC;
 
-	__set_bit(bit_pos, adev->seq64.used);
+		if (!test_and_set_bit(bit_pos, adev->seq64.used))
+			break;
+	}
 
 	*va = bit_pos * sizeof(u64) + amdgpu_seq64_get_va_base(adev);
 
@@ -205,7 +208,7 @@ void amdgpu_seq64_free(struct amdgpu_device *adev, u64 va)
 
 	bit_pos = (va - amdgpu_seq64_get_va_base(adev)) / sizeof(u64);
 	if (bit_pos < adev->seq64.num_sem)
-		__clear_bit(bit_pos, adev->seq64.used);
+		clear_bit(bit_pos, adev->seq64.used);
 }
 
 /**
Signature · 1 line
2.53.0
#703 lore raw

Re: [PATCH AUTOSEL 6.18] drm/amdgpu: use atomic operation to achieve lockless serialization

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but dma_fence_is_signaled_locked() is called without holding the required fence lock, leading to a severe locking violation. --

commit e72ef6207a108e0a367f5094ba262069966bfe78
Author: Sunil Khatri <[email protected]>

drm/amdgpu: use atomic operation to achieve lockless serialization

This commit fixes a race condition in amdgpu_seq64_alloc where multiple cores could acquire the same free slot. It replaces non-atomic bit operations with atomic test_and_set and clear operations.

drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c +0 -0
index a0b479d5fff19..f4be192235889 100644

[ ... ]

This is a pre-existing issue, but I noticed a potential problem in drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c:amdgpu_userq_fence_driver_set_error():

	spin_lock_irqsave(&fence_drv->fence_list_lock, flags);

	f = rcu_dereference_protected(&fence->base,
				      lockdep_is_held(&fence_drv->fence_list_lock));
	if (f && !dma_fence_is_signaled_locked(f))
		dma_fence_set_error(f, error);
	spin_unlock_irqrestore(&fence_drv->fence_list_lock, flags);

[Severity: High]
This isn't a bug introduced by this patch, but dma_fence_is_signaled_locked() is called here without holding the required fence lock.

Is it safe to call dma_fence_is_signaled_locked() without holding the actual fence lock (&userq_fence->lock)?

The function may internally invoke dma_fence_signal_locked(), which modifies the fence state and iterates over wait callbacks without protection. Could this cause race conditions and list corruption if another thread concurrently accesses the fence?

Could this also trigger a kernel lockdep splat because dma_fence_signal_locked() asserts that the lock is held?

Additionally, does the preceding rcu_dereference_protected(&fence->base) irregularly pass a non-RCU pointer to an inline struct?

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

PATCH 1/1 wifi: libipw: fix key index receive bound checks

In reply to Sasha Levin

From: Pengpeng Hou <[email protected]>

[ Upstream commit 74ed3669f26803b1761c1f55403062bea44c3466 ]

libipw_rx() reads skb->data[hdrlen + 3] to extract the WEP key index in both the software-decrypt key selection path and the hardware-decrypted IV/ICV strip path. In both places the existing guard only checks skb->len >= hdrlen + 3, which proves bytes up to hdrlen + 2 but not the byte at hdrlen + 3.

Require hdrlen + 4 bytes before reading that item in both paths. This is a local source-boundary check only; it does not change the key index semantics.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: wifi: libipw: fix key index receive bound checks

**Local tree:** v6.18.44 (6.18.44, Makefile VERSION=6 PATCHLEVEL=18 SUBLEVEL=44)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: PARSE THE SUBJECT LINE
**Record:** [wifi: libipw] [fix] — correct off-by-one bounds check when reading WEP key index byte from received skb data in libipw_rx().

### Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
**Record:**
- **Signed-off-by:** Pengpeng Hou <[email protected]> (author)
- **Link:**
https://patch.msgid.link/[email protected]
- **Signed-off-by:** Johannes Berg <[email protected]> (wireless maintainer, committer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, or Cc: [email protected]
- Notable: no fuzzer or user bug report; maintainer SOB present

### Step 1.3: ANALYZE THE COMMIT BODY TEXT
**Record:**
- **Bug:** libipw_rx() reads skb->data[hdrlen + 3] after checking skb->len >= hdrlen + 3. That guard only guarantees bytes 0..hdrlen+2; index hdrlen+3 needs skb->len >= hdrlen + 4.
- **Symptom:** Out-of-bounds read past skb tail on truncated protected frames.
- **Affected paths:** (1) software-decrypt key selection, (2) hardware- decrypt IV/ICV strip path.
- **Root cause:** Classic off-by-one length check (confusing “number of bytes after hdrlen” with “index of last byte needed”).

### Step 1.4: DETECT HIDDEN BUG FIXES
**Record:** Not disguised — explicitly a bounds-check fix. No hidden semantics change; when the check fails, keyidx stays at its initialized value 0.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: INVENTORY THE CHANGES
**Record:**
- **File:** drivers/net/wireless/intel/ipw2x00/libipw_rx.c (+2/−2 lines)
- **Functions:** libipw_rx() (two hunks)
- **Scope:** Single-file, surgical fix

### Step 2.2: CODE FLOW CHANGE
**Record:**
- **Hunk 1 (~line 417):** Before: read key index if len >= hdrlen+3.
After: read only if len >= hdrlen+4. Affects software-decrypt path when can_be_decrypted is true.
- **Hunk 2 (~line 663):** Same change on hardware-decrypt IV/ICV strip path when !can_be_decrypted && PROTECTED && host_strip_iv_icv.
- **Unchanged behavior:** When the frame is long enough, key index extraction is identical.

### Step 2.3: BUG MECHANISM
**Record:** **Category:** Memory safety / out-of-bounds read. **Mechanism:** With skb->len == hdrlen + 3, skb->data[hdrlen + 3] reads one byte past allocated skb data — slab OOB read (info leak or fault under KASAN).

### Step 2.4: FIX QUALITY
**Record:** Obviously correct; minimal; zero functional change for valid frames. **Regression risk:** Very low — only skips the read on frames that were already too short to contain the byte.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: BLAME THE CHANGED LINES
**Record:** Blame points to 5d324e5159d9e (merge, 2025-11-28). This autosel tree has only **1 commit** touching libipw_rx.c; the buggy hdrlen + 3 pattern is long-standing legacy code, not a recent regression.

### Step 3.2: FOLLOW THE FIXES: TAG
**Record:** N/A — no Fixes: tag.

### Step 3.3: FILE HISTORY FOR RELATED CHANGES
**Record:** Recent ipw2x00 activity includes f442e581a8893 (ipw2100 memory leak fix). No prior fix for this bounds issue. Standalone one- patch submission.

### Step 3.4: AUTHOR'S OTHER COMMITS
**Record:** Pengpeng Hou has multiple similar validation/bounds fixes (CAN, media, Bluetooth, hwmon). Johannes Berg is the wireless maintainer who committed this.

### Step 3.5: DEPENDENT/PREREQUISITE COMMITS
**Record:** No dependencies. Patch applies cleanly to current libipw_rx.c (buggy hdrlen + 3 still present at lines 417 and 663).

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: ORIGINAL PATCH DISCUSSION
**Record:** b4 am [email protected] found the thread. Mbox has a single patch message, no replies. No stable nomination or NAK in thread. WebFetch of lore URL blocked by bot protection; content obtained via b4 mbox.

### Step 4.2: REVIEWERS
**Record:** b4 dig -w did not yield additional recipient detail beyond the patch itself. Johannes Berg SOB indicates maintainer acceptance.

### Step 4.3: BUG REPORT
**Record:** No external bug report, syzbot link, or stack trace. Static/code-review discovery.

### Step 4.4: RELATED PATCHES/SERIES **Record:** Standalone 1/1 patch, not part of a series.

### Step 4.5: STABLE MAILING LIST HISTORY
**Record:** Not searched separately; no stable discussion found in the patch thread.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: KEY FUNCTIONS
**Record:** libipw_rx() — central RX handler for libipw stack.

### Step 5.2: CALLERS
**Record:** Called from:
- ipw2200.c: lines 7674, 7831, 8037, 10332
- ipw2100.c: lines 2479, 2566

All are RX paths (tasklet/ISR context) for every received 802.11 frame.

### Step 5.3: CALLEES
**Record:** Uses libipw_get_hdrlen(), decryption helpers, frame drop paths. Bug is a direct skb indexed read before further validation.

### Step 5.4: CALL CHAIN / REACHABILITY
**Record:**
1. Wireless frame received by ipw2100/ipw2200 firmware → skb built with firmware-reported length
2. libipw_rx() validates skb->len >= 10 and skb->len >= hdrlen
3. A protected frame with skb->len == hdrlen + 3 passes those checks
4. OOB read at skb->data[hdrlen + 3]

ipw2200.c rejects length < hdrlen (line 8315) but not length < hdrlen + 4. ipw_handle_data_packet() (line 7663) sets skb length from hardware with no extra minimum beyond libipw_rx() checks.

**Userspace trigger:** Indirect — attacker in radio range can send malformed 802.11 frames; no syscall needed.

### Step 5.5: SIMILAR PATTERNS
**Record:** Line 286 in libipw_rx_frame_decrypt() also reads skb->data[hdrlen + 3] in a debug path after failed decrypt (not fixed by this patch). The two fixed sites are the ones described in the commit message.

---

## PHASE 6: CROSS-REFERENCING AGAINST LOCAL TREE

### Step 6.1: DOES THE BUGGY CODE EXIST?
**Record:** **Yes.** drivers/net/wireless/intel/ipw2x00/libipw_rx.c lines 417 and 663 still use hdrlen + 3. Driver and CONFIG_LIBIPW/CONFIG_IPW2100/CONFIG_IPW2200 exist in 6.18.44. Bug predates this stable branch (legacy code).

### Step 6.2: BACKPORT COMPLICATIONS
**Record:** **Clean apply** — two identical +3 → +4 substitutions, no context conflicts.

### Step 6.3: RELATED FIXES ALREADY PRESENT? **Record:** **No.** git log --grep="key index" and git log --grep="hdrlen + 4" return nothing for this file.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

### Step 7.1: SUBSYSTEM CRITICALITY
**Record:** **Subsystem:** drivers/net/wireless/intel/ipw2x00 (legacy Intel PRO/Wireless 2100/2200). **Criticality:** PERIPHERAL — deprecated libipw stack, very old hardware, small active user base.

### Step 7.2: SUBSYSTEM ACTIVITY
**Record:** Intel wireless tree is active (many iwlwifi fixes in 6.18.y). ipw2x00 itself sees occasional maintenance (e.g., memory leak fix f442e581a8893).

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: WHO IS AFFECTED
**Record:** **Config-specific / driver-specific** — users with IPW2100 or IPW2200 modules loaded and WEP/WPA decryption paths active.

### Step 8.2: TRIGGER CONDITIONS
**Record:** Protected frame with skb->len == hdrlen + 3 (e.g., hdrlen=24, len=27). Requires malformed/truncated over-the-air frame or firmware passing a short frame. **Likelihood:** Low in normal operation; realistic for malicious RF traffic. **Unprivileged remote trigger:** Yes, within wireless range.

### Step 8.3: FAILURE MODE SEVERITY
**Record:** **Out-of-bounds read** past skb buffer. Without KASAN:
possible slab info leak; possible fault at page boundary. With KASAN:
BUG report. **Severity: MEDIUM** (memory safety on network RX; limited by obsolete hardware and narrow config).

### Step 8.4: RISK-BENEFIT
**Record:**
- **Benefit:** Closes a real OOB read on RX path; defense-in-depth for malformed frames; zero-risk 2-line fix.
- **Risk:** Negligible — only tightens an existing guard.
- **Ratio:** Moderate benefit (small user base) vs. very low risk → **favorable for backport**.

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: EVIDENCE COMPILED

**FOR backport:**
- Real, verifiable off-by-one OOB read
- Trivial, obviously correct 2-line fix
- RX path reachable from wireless input
- Applies cleanly to 6.18.44
- Maintainer (Johannes Berg) committed
- Matches stable pattern of bounds-check hardening

**AGAINST backport:**
- Legacy deprecated driver (libipw); hardware from ~2003–2005
- No user report, syzbot, or CVE
- Very small installed base today
- Trigger requires specific truncated protected frame

**Unresolved:** Whether firmware typically filters frames short enough to hit this exact length before they reach libipw_rx().

### Step 9.2: STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — mathematically correct bounds fix; no Tested-by.
2. Fixes a real bug? **PASS** — OOB read on skb->data[hdrlen+3].
3. Important issue? **PASS (MEDIUM)** — memory safety on network RX, remotely triggerable in principle.
4. Small and contained? **PASS** — 2 lines, 1 file.
5. No new features or APIs? **PASS**.
6. Can apply to local tree? **PASS** — buggy code present, clean apply.

### Step 9.3: EXCEPTION CATEGORIES
**Record:** N/A — standard memory-safety bug fix, not a quirk/DT/build/doc exception.

### Step 9.4: DECISION RATIONALE

For **6.18.44**, the buggy code is present and the fix is surgical. Even with a small user population, an out-of-bounds read on a wireless RX path is appropriate stable material: the patch is obviously correct, cannot regress valid frames, and closes a reachable memory-safety hole. The lack of syzbot/user reports lowers urgency but does not negate the technical merit.

---

## Verification

- **[Phase 1]** Parsed subject, tags, body from provided commit message and mbox
- **[Phase 2]** Diff: 2 lines in libipw_rx.c, hdrlen+3 → hdrlen+4 at lines 417 and 663
- **[Phase 3]** git describe HEAD → v6.18.44; make kernelversion → 6.18.44
- **[Phase 3]** git blame -L 417,419 and -L 663,664 → lines from 5d324e5159d9e
- **[Phase 3]** git rev-list --count HEAD -- libipw_rx.c → 1 (shallow history for this file)
- **[Phase 3]** No Fixes: tag; no prerequisite commits found
- **[Phase 4]** b4 am [email protected] → single-patch thread
- **[Phase 4]** Mbox read: no replies, no stable nomination, no NAK
- **[Phase 4]** WebFetch of lore URL → blocked (bot protection); used b4 mbox instead
- **[Phase 5]** grep libipw_rx( → callers in ipw2200.c (4) and ipw2100.c (2)
- **[Phase 5]** Read libipw_rx() lines 325–366: validates len >= 10 and len >= hdrlen only
- **[Phase 5]** Read ipw2200.c 8315–8324: rejects length < hdrlen, not length < hdrlen+4
- **[Phase 5]** Read ipw_handle_data_packet() 7659–7674: skb length from firmware, no extra min check
- **[Phase 6]** Grep confirmed buggy hdrlen + 3 at lines 417, 663; fix not present
- **[Phase 6]** Kconfig confirms IPW2100, IPW2200, LIBIPW exist; libipw marked deprecated
- **[Phase 8]** Failure mode: OOB read, severity MEDIUM
- **UNVERIFIED:** Exact frequency of firmware delivering frames with len == hdrlen+3 to libipw_rx()

**YES**

 drivers/net/wireless/intel/ipw2x00/libipw_rx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/ipw2x00/libipw_rx.c +2 -2
index b7bc94f7abd8a..c8841f9b9ad91 100644
@@ -414,7 +414,7 @@ int libipw_rx(struct libipw_device *ieee, struct sk_buff *skb,
 	    ieee->host_mc_decrypt : ieee->host_decrypt;
 
 	if (can_be_decrypted) {
-		if (skb->len >= hdrlen + 3) {
+		if (skb->len >= hdrlen + 4) {
 			/* Top two-bits of byte 3 are the key index */
 			keyidx = skb->data[hdrlen + 3] >> 6;
 		}
@@ -660,7 +660,7 @@ int libipw_rx(struct libipw_device *ieee, struct sk_buff *skb,
 		int trimlen = 0;
 
 		/* Top two-bits of byte 3 are the key index */
-		if (skb->len >= hdrlen + 3)
+		if (skb->len >= hdrlen + 4)
 			keyidx = skb->data[hdrlen + 3] >> 6;
 
 		/* To strip off any security data which appears before the
Signature · 1 line
2.53.0
author maintainer
#705 lore raw

PATCH 1/1 RDMA/irdma: Fix typo in SQ completions generation

In reply to Sasha Levin

From: Cyrill Gorcunov <[email protected]>

[ Upstream commit b548a6c4eee5c428663f3944e173e6c92e2e8d6f ]

When we generate completion for SQ the opcode while being properly read from ring buffer is ignored when written back to completion. Seems to be a simple typo.

---

LLM Generated explanations, may be completely bogus:

The background search finished: the fix commit is **not in this v6.18.44 tree** (git log --grep for the subject returned nothing). The buggy line is still at utils.c:2464.

**Verdict: YES** — one-line typo in the kernel-client SQ flush path. It always sets op_type to 0x3f, which breaks NOP filtering and overwrites flush status with IB_WC_GENERAL_ERR instead of IB_WC_WR_FLUSH_ERR. Low risk, clearly correct, and appropriate for stable backport.

 drivers/infiniband/hw/irdma/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/irdma/utils.c +1 -1
index e5e226b346211..8442e4fb3f984 100644
@@ -2461,7 +2461,7 @@ void irdma_generate_flush_completions(struct irdma_qp *iwqp)
 			cmpl->cpi.wr_id = qp->sq_wrtrk_array[wqe_idx].wrid;
 			sw_wqe = qp->sq_base[wqe_idx].elem;
 			get_64bit_val(sw_wqe, 24, &wqe_qword);
-			cmpl->cpi.op_type = (u8)FIELD_GET(IRDMAQPSQ_OPCODE, IRDMAQPSQ_OPCODE);
+			cmpl->cpi.op_type = (u8)FIELD_GET(IRDMAQPSQ_OPCODE, wqe_qword);
 			cmpl->cpi.q_type = IRDMA_CQE_QTYPE_SQ;
 			/* remove the SQ WR by moving SQ tail*/
 			IRDMA_RING_SET_TAIL(*sq_ring,
Signature · 1 line
2.53.0
author maintainer
#706 lore raw

PATCH 1/1 tls: reject the combination of TLS and sockmap

In reply to Sasha Levin

From: Jakub Kicinski <[email protected]>

[ Upstream commit 460e6486617c17dd19abe8f3fc67d9a6fa25f8ca ]

TLS and sockmap (BPF psock) integration hides a lot of latent bugs. Bugs which may be more or less relevant for real users but they are definitely exploitable.

We could not find anyone actively using this integration so let's reject this config. Adding a TLS socket to a sockmap was already rejected by sk_psock_init() through the inet_csk_has_ulp() check. We need to reject the attempts to configure the TLS keys (rather than adding the ULP itself) because checking prior to the ULP installation is tricky without risking a race with sockmap getting added in parallel (sockmap does not hold the socket lock).

This patch is a minimal rejection of the feature. Subsequent patch in the series will do a light dead code removal. Full cleanup would require a major rewrite of the Tx path, we don't need skmsg any more.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit Message Forensics

### Step 1.1: Subject line
**Record:** [tls] / reject — reject the unsupported TLS + sockmap (BPF psock) configuration.

### Step 1.2: Tags
**Record:**
- **Reviewed-by:** Jakub Sitnicki <[email protected]>
- **Reviewed-by:** Sabrina Dubroca <[email protected]>
- **Link:**
https://patch.msgid.link/[email protected]
- **Signed-off-by:** Jakub Kicinski <[email protected]>
- No Fixes:, Reported-by:, Cc: [email protected], or syzbot tags
- Notable: two subsystem reviewers; commit explicitly calls bugs “definitely exploitable”

### Step 1.3: Body analysis
**Record:**
- **Bug:** TLS + sockmap integration has multiple latent, exploitable bugs; only half of the mutual exclusion was enforced (sk_psock_init() blocks TLS→sockmap, but not sockmap→TLS key setup).
- **Symptom:** Reverse-order setup (sockmap first, then TLS key configuration) reaches broken code paths (UAF, data corruption, kernel BUG/panic — documented externally and in related stable fixes).
- **Root cause:** sk_psock_init() checks inet_csk_has_ulp(), but do_tls_setsockopt_conf() did not check for an existing psock; checking earlier (at ULP install) is racy because sockmap does not hold the socket lock.
- **Version info:** None in the commit message; external report confirms impact on 6.12.77 LTS.

### Step 1.4: Hidden bug fix?
**Record:** Yes. Although phrased as “reject this config,” this is security hardening that closes an exploitable attack/configuration path, not a cosmetic cleanup.

---

## Phase 2: Diff Analysis

### Step 2.1: Inventory
**Record:**
- **Files:** net/tls/tls_main.c (+11 / -0)
- **Function:** do_tls_setsockopt_conf()
- **Scope:** Single-file, surgical change

### Step 2.2: Code flow change
**Record:**
- **Before:** do_tls_setsockopt_conf() accepted TLS_TX/TLS_RX crypto configuration on any socket, including one already in a sockmap.
- **After:** Under rcu_read_lock(), if sk_psock(sk) is non-NULL, return -EINVAL before any crypto configuration proceeds.
- **Path affected:** setsockopt(SOL_TLS, TLS_TX/TLS_RX, ...) error path; called from do_tls_setsockopt() under lock_sock().

### Step 2.3: Bug mechanism
**Record:**
- **Category:** Logic/correctness + security hardening (unsupported configuration reachable).
- **Mechanism:** Sockmap-first, TLS-second (“reverse order”) bypasses the existing inet_csk_has_ulp() guard in sk_psock_init(). TLS RX/TX key setup arms strparser/send paths that corrupt TCP sequence state and can trigger UAF (as in commit 1861d369efd62 already present in this tree).

### Step 2.4: Fix quality
**Record:**
- Obviously correct: mirrors the existing one-way rejection in sk_psock_init().
- Minimal and self-contained.
- Low regression risk: only affects sockets already in a sockmap; author states no known users of this combination.
- Uses the same sk_psock() + rcu_read_lock() pattern already used elsewhere in TLS code.

---

## Phase 3: Git History Investigation

### Step 3.1: Blame
**Record:** do_tls_setsockopt_conf() dates to 2017 (Dave Watson); the missing psock check has been present since the function existed. TLS+sockmap integration was added in d3b18ad31f93 (2018, “tls: add bpf support to sk_msg handling”).

### Step 3.2: Fixes: tag
**Record:** N/A — no Fixes: tag in this commit.

### Step 3.3: Related file history
**Record:** Related stable-worthy fixes in this tree:
- 1861d369efd62 — UAF when sockmap inserted before TLS RX (already in 6.18.44)
- 54a3ecaeeeae8 — kernel BUG in tls_sw_sendmsg with sockmap
- 4da6a196f93b1 — sockmap/TLS teardown infinite loop (syzbot, Cc:
stable)
- Long history of TLS+sockmap fixes since 2019 “bpf-sockmap-tls-fixes” merge

### Step 3.4: Author context
**Record:** Jakub Kicinski is the networking maintainer; reviewers Sitnicki and Dubroca are active TLS/BPF contributors.

### Step 3.5: Dependencies
**Record:** Standalone. Part of a 5-patch net-next series (461064-1 through 461064-5); later patches remove dead code but are not required for this rejection to work. Cherry-pick to current HEAD applies cleanly.

---

## Phase 4: Mailing List and External Research

### Step 4.1: Original discussion
**Record:**
- **b4 dig URL:**
https://patch.msgid.link/[email protected]
- **Series:** v1 only (no later revisions found)
- **Reviewers:** Sitnicki and Dubroca Reviewed-by in thread
- No explicit stable nomination found in thread; no NAKs found

### Step 4.2: Reviewers CC'd
**Record:** [email protected], [email protected], davem, edumazet, pabeni, john.fastabend, [email protected] — appropriate maintainer/reviewer coverage.

### Step 4.3: Bug reports
**Record:** oss-sec report (2026/q2/423) documents “reverse order” KTLS+sockmap UAF/data corruption:
- Sockmap first, then enable KTLS
- Bypass for CVE-2025-37756 mitigation
- Confirmed on Linux 6.12.77 LTS
- Requires CAP_NET_ADMIN + CAP_BPF (container/LPE context)
- Recommends blocking reverse-order in tls_main.c

### Step 4.4: Series context
**Record:** Patch 1/5 rejects the combination; patches 2–5 remove dead sockmap handling from TLS SW path and selftests. This patch is independently valuable without the cleanup series.

### Step 4.5: Stable list
**Record:** No stable-list discussion found for this specific commit. Related UAF fix 1861d369efd62 was already backported to this 6.18.y tree.

---

## Phase 5: Code Semantic Analysis

### Step 5.1: Key functions
**Record:** do_tls_setsockopt_conf(), called from do_tls_setsockopt() for TLS_TX/TLS_RX.

### Step 5.2: Callers
**Record:** tls_setsockopt() → do_tls_setsockopt() → do_tls_setsockopt_conf(). Reachable from userspace via setsockopt() on a TLS ULP socket.

### Step 5.3: Callees
**Record:** sk_psock(sk) (inline in include/linux/skmsg.h), rcu_read_lock/unlock, existing crypto validation path.

### Step 5.4: Reachability
**Record:**
1. Create TCP socket
2. bpf_map_update_elem() to insert into sockmap (needs CAP_BPF + CAP_NET_ADMIN)
3. setsockopt(TCP_ULP, "tls")
4. setsockopt(SOL_TLS, TLS_RX/TLS_TX, ...) — **blocked by this patch**

Userspace-reachable with container-privileged capabilities.

### Step 5.5: Similar patterns
**Record:** Complementary guard already exists in sk_psock_init():

```758:761:net/core/skmsg.c
        if (sk_is_inet(sk) && inet_csk_has_ulp(sk)) {
                psock = ERR_PTR(-EINVAL);
                goto out;
        }
```

This patch completes the other direction.

---

## Phase 6: Cross-Reference Against Local Tree (6.18.44)

### Step 6.1: Buggy code present?
**Record:** **Yes.** git describe HEAD → v6.18.44-1-g2736c32da98b9. do_tls_setsockopt_conf() at lines 610–624 has no sk_psock() check. Commit 460e6486617c is **not** in HEAD history (NOT in HEAD history).

### Step 6.2: Backport complications
**Record:** **Clean apply.** Test cherry-pick: Auto-merging net/tls/tls_main.c, +11 lines, no conflicts. sk_psock() available via net/tls/tls.h → #include <linux/skmsg.h>.

### Step 6.3: Related fixes already present?
**Record:** 1861d369efd62 (UAF fix for sockmap-before-TLS-RX) is already in this tree. That fixes one specific failure mode; this commit prevents the configuration entirely and blocks additional exploitable paths the maintainers cite.

---

## Phase 7: Subsystem Context

### Step 7.1: Subsystem criticality
**Record:** **IMPORTANT** — net/tls (kTLS) + BPF sockmap; affects container/cloud workloads using BPF socket policy and kTLS.

### Step 7.2: Activity
**Record:** Actively maintained; multiple TLS+sockmap fixes in 2025–2026.

---

## Phase 8: Impact and Risk Assessment

### Step 8.1: Who is affected
**Record:** Users with CONFIG_TLS + CONFIG_BPF_SYSCALL + sockmap enabled who can configure both subsystems (typical in container/K8s/service-mesh environments).

### Step 8.2: Trigger conditions
**Record:** Deliberate reverse-order configuration: sockmap attach, then TLS key setup. Unlikely in production (no known users), but reachable and documented as exploitable.

### Step 8.3: Failure mode severity
**Record:** **CRITICAL** — UAF, kernel BUG/panic, data corruption; external report ties to privilege-escalation/container-escape class issues and CVE-2025-37756 bypass.

### Step 8.4: Risk-benefit
**Record:**
- **Benefit:** High — closes exploitable security path; complements existing one-way guard and partial UAF fix.
- **Risk:** Very low — 11 lines, returns -EINVAL on unsupported config, reviewed by TLS experts.
- **Ratio:** Strongly favors backport.

---

## Phase 9: Final Synthesis

### Step 9.1: Evidence summary

**FOR backport:**
- Exploitable security issue (maintainer statement + oss-sec report)
- Confirmed on 6.12.77 LTS; same integration exists in 6.18.44
- Small, surgical, applies cleanly
- Completes mutual exclusion already half-implemented
- Reviewed by TLS subsystem experts
- Prevents bypass of prior CVE mitigations
- Related UAF already backported here — this is the upstream-preferred prevention

**AGAINST backport:**
- Part of a larger removal series (subsequent dead-code cleanup not needed for function)
- Does not block tls_init() at TCP_ULP time (oss-sec suggested that); blocks at key config instead — minor gap, but key config is where dangerous paths arm
- No known production users (low practical impact, but security still matters)

**Unresolved:** No syzbot link in this specific commit; lore thread had no explicit stable nomination.

### Step 9.2: Stable rules checklist
1. Obviously correct and tested? **PASS** — simple guard, reviewed, cherry-picks cleanly.
2. Fixes real bug affecting users? **PASS** — closes documented exploitable configuration path.
3. Important issue? **PASS** — security/UAF/crash class.
4. Small and contained? **PASS** — 11 lines, one file.
5. No new features/APIs? **PASS** — restricts unsupported config only.
6. Can apply to local tree? **PASS** — verified clean cherry-pick on 6.18.44.

### Step 9.3: Exception category
**Record:** Security hardening / unsupported-configuration rejection (similar to prior stable rejections of broken feature combinations).

### Step 9.4: Decision rationale
This tree (6.18.44) still allows sockmap-first → TLS-key-configuration, a path with documented UAF and privilege-escalation potential. The fix is minimal, expert-reviewed, applies cleanly, and closes a gap left by the existing one-way sk_psock_init() check. Even though a related UAF was already fixed in 1861d369efd62, maintainers state multiple exploitable bugs remain in this integration. Blocking the configuration is appropriate stable material.

---

## Verification

- [Phase 1] Parsed subject, tags, body; identified security-hardening intent
- [Phase 2] Diff: +11 lines in do_tls_setsockopt_conf(), adds sk_psock() check under RCU
- [Phase 3] git blame: function from 2017; TLS+sockmap since d3b18ad31f93 (2018)
- [Phase 3] Related fixes verified: 1861d369efd62, 54a3ecaeeeae8, 4da6a196f93b1 in tree history
- [Phase 3] git merge-base --is-ancestor 460e6486617c HEAD → NOT in HEAD history
- [Phase 4] b4 dig -c 460e6486617c: lore URL found; v1 series only
- [Phase 4] b4 dig -w: netdev, bpf lists and maintainers CC'd
- [Phase 4] Web search: oss-sec 2026/q2/423 documents reverse-order UAF on 6.12.77 LTS
- [Phase 5] Call chain: setsockopt → tls_setsockopt → do_tls_setsockopt_conf
- [Phase 5] sk_psock_init() one-way guard verified at net/core/skmsg.c:758-761
- [Phase 6] git describe HEAD → v6.18.44; buggy code confirmed absent of fix
- [Phase 6] Cherry-pick test of 460e6486617c → clean apply
- [Phase 6] 1861d369efd62 confirmed ancestor of HEAD (UAF fix present)
- [Phase 8] Failure mode: UAF/crash/security — CRITICAL severity

**YES****Verdict: YES** — backport to this tree (6.18.44).

The commit (460e6486617c) adds an 11-line guard in do_tls_setsockopt_conf() to reject TLS key setup on sockets already in a sockmap. That closes the “reverse order” path (sockmap first, then TLS) that bypasses the existing sk_psock_init() check and has led to UAF/crash bugs; an oss-sec report documents this on 6.12.77 LTS.

The patch is not in HEAD yet, but it cherry-picks cleanly onto 6.18.44. It’s small, security-relevant, and reviewed by TLS maintainers.

 net/tls/tls_main.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
net/tls/tls_main.c +11 -0
index 39a2ab47fe720..ab30f5de2c658 100644
@@ -620,6 +620,17 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval,
 	int rc = 0;
 	int conf;
 
+	/* TLS and sockmap are mutually exclusive. A socket already in a
+	 * sockmap (i.e. with a psock attached) cannot be upgraded to TLS.
+	 * sockmap rejects TLS sockets already (see sk_psock_init()).
+	 */
+	rcu_read_lock();
+	if (sk_psock(sk)) {
+		rcu_read_unlock();
+		return -EINVAL;
+	}
+	rcu_read_unlock();
+
 	if (sockptr_is_null(optval) || (optlen < sizeof(*crypto_info)))
 		return -EINVAL;
 
Signature · 1 line
2.53.0
#707 lore raw

Re: [PATCH AUTOSEL 6.18-6.1] tls: reject the combination of TLS and sockmap

Quoted 20 lines · Sasha Levin

From: Jakub Kicinski <[email protected]>

[ Upstream commit 460e6486617c17dd19abe8f3fc67d9a6fa25f8ca ]

TLS and sockmap (BPF psock) integration hides a lot of latent bugs. Bugs which may be more or less relevant for real users but they are definitely exploitable.

We could not find anyone actively using this integration so let's reject this config. Adding a TLS socket to a sockmap was already rejected by sk_psock_init() through the inet_csk_has_ulp() check. We need to reject the attempts to configure the TLS keys (rather than adding the ULP itself) because checking prior to the ULP installation is tricky without risking a race with sockmap getting added in parallel (sockmap does not hold the socket lock).

This patch is a minimal rejection of the feature. Subsequent patch in the series will do a light dead code removal. Full cleanup would require a major rewrite of the Tx path, we don't need skmsg any more.

Quoted 8 lines

---

LLM Generated explanations, may be completely bogus:

330L... wow.

Quoted 6 lines

## Phase 1: Commit Message Forensics

### Step 1.1: Subject line
**Record:** [tls] / reject — reject the unsupported TLS + sockmap (BPF psock) configuration.

Quoted 8 lines

### Step 1.2: Tags
**Record:**
- **Reviewed-by:** Jakub Sitnicki <[email protected]>
- **Reviewed-by:** Sabrina Dubroca <[email protected]>
- **Link:**
https://patch.msgid.link/[email protected]
- **Signed-off-by:** Jakub Kicinski <[email protected]>
- No Fixes:, Reported-by:, Cc: [email protected], or syzbot tags

Yes, this was intentionally sent to net-next without a Fixes tag, because it's a "feature-level" change, so it kind of feels wrong to send that to stable (even if it's removing a feature that nobody seems to be using). OTOH the code is broken and not really fixable...

Signature · 1 line
Sabrina
author maintainer
#708 lore raw

Re: [PATCH AUTOSEL 6.18-6.1] tls: reject the combination of TLS and sockmap

Quoted 47 lines · Sabrina Dubroca
Quoted 20 lines · Sasha Levin

From: Jakub Kicinski <[email protected]>

[ Upstream commit 460e6486617c17dd19abe8f3fc67d9a6fa25f8ca ]

TLS and sockmap (BPF psock) integration hides a lot of latent bugs. Bugs which may be more or less relevant for real users but they are definitely exploitable.

We could not find anyone actively using this integration so let's reject this config. Adding a TLS socket to a sockmap was already rejected by sk_psock_init() through the inet_csk_has_ulp() check. We need to reject the attempts to configure the TLS keys (rather than adding the ULP itself) because checking prior to the ULP installation is tricky without risking a race with sockmap getting added in parallel (sockmap does not hold the socket lock).

This patch is a minimal rejection of the feature. Subsequent patch in the series will do a light dead code removal. Full cleanup would require a major rewrite of the Tx path, we don't need skmsg any more.

Quoted 8 lines

---

LLM Generated explanations, may be completely bogus:

330L... wow.

Quoted 6 lines

## Phase 1: Commit Message Forensics

### Step 1.1: Subject line
**Record:** [tls] / reject — reject the unsupported TLS + sockmap (BPF psock) configuration.

Quoted 8 lines

### Step 1.2: Tags
**Record:**
- **Reviewed-by:** Jakub Sitnicki <[email protected]>
- **Reviewed-by:** Sabrina Dubroca <[email protected]>
- **Link:**
https://patch.msgid.link/[email protected]
- **Signed-off-by:** Jakub Kicinski <[email protected]>
- No Fixes:, Reported-by:, Cc: [email protected], or syzbot tags

Quoted 4 lines

Yes, this was intentionally sent to net-next without a Fixes tag, because it's a "feature-level" change, so it kind of feels wrong to send that to stable (even if it's removing a feature that nobody seems to be using). OTOH the code is broken and not really fixable...

We have plenty of "fixes" that just drop a bunch of broken code :)

Happy to do either, just let me know.

Signature · 2 lines
Thanks,
Sasha
#709 lore raw

Re: [PATCH AUTOSEL 6.18-6.1] tls: reject the combination of TLS and sockmap

Quoted 48 lines · Sasha Levin
Quoted 47 lines · Sabrina Dubroca
Quoted 20 lines · Sasha Levin

From: Jakub Kicinski <[email protected]>

[ Upstream commit 460e6486617c17dd19abe8f3fc67d9a6fa25f8ca ]

TLS and sockmap (BPF psock) integration hides a lot of latent bugs. Bugs which may be more or less relevant for real users but they are definitely exploitable.

We could not find anyone actively using this integration so let's reject this config. Adding a TLS socket to a sockmap was already rejected by sk_psock_init() through the inet_csk_has_ulp() check. We need to reject the attempts to configure the TLS keys (rather than adding the ULP itself) because checking prior to the ULP installation is tricky without risking a race with sockmap getting added in parallel (sockmap does not hold the socket lock).

This patch is a minimal rejection of the feature. Subsequent patch in the series will do a light dead code removal. Full cleanup would require a major rewrite of the Tx path, we don't need skmsg any more.

Quoted 8 lines

---

LLM Generated explanations, may be completely bogus:

330L... wow.

Quoted 14 lines

## Phase 1: Commit Message Forensics

### Step 1.1: Subject line
**Record:** [tls] / reject — reject the unsupported TLS + sockmap (BPF psock) configuration.

### Step 1.2: Tags
**Record:**
- **Reviewed-by:** Jakub Sitnicki <[email protected]>
- **Reviewed-by:** Sabrina Dubroca <[email protected]>
- **Link:**
https://patch.msgid.link/[email protected]
- **Signed-off-by:** Jakub Kicinski <[email protected]>
- No Fixes:, Reported-by:, Cc: [email protected], or syzbot tags

Quoted 8 lines
Quoted 4 lines

Yes, this was intentionally sent to net-next without a Fixes tag, because it's a "feature-level" change, so it kind of feels wrong to send that to stable (even if it's removing a feature that nobody seems to be using). OTOH the code is broken and not really fixable...

We have plenty of "fixes" that just drop a bunch of broken code :)

Happy to do either, just let me know.

Alright, if that's ok for you, no objection.

Signature · 1 line
Sabrina
author maintainer
#710 lore raw

PATCH 1/1 driver core: Avoid warning when removing a device while its supplier is unbinding

In reply to Sasha Levin

From: Herve Codina <[email protected]>

[ Upstream commit 36d74f17e03f7e60e1b08fbe16cfad6e69cc3aa9 ]

During driver removal, the following warning can appear:

   WARNING: CPU: 1 PID: 139 at drivers/base/core.c:1497 __device_links_no_driver+0xcc/0xfc
   ...
   Call trace:
     __device_links_no_driver+0xcc/0xfc (P)
     device_links_driver_cleanup+0xa8/0xf0
     device_release_driver_internal+0x208/0x23c
     device_links_unbind_consumers+0xe0/0x108
     device_release_driver_internal+0xec/0x23c
     device_links_unbind_consumers+0xe0/0x108
     device_release_driver_internal+0xec/0x23c
     device_links_unbind_consumers+0xe0/0x108
     device_release_driver_internal+0xec/0x23c
     driver_detach+0xa0/0x12c
     bus_remove_driver+0x6c/0xbc
     driver_unregister+0x30/0x60
     pci_unregister_driver+0x20/0x9c
     lan966x_pci_driver_exit+0x18/0xa90 [lan966x_pci]

This warning is triggered when a consumer is removed because the links status of its supplier is not DL_DEV_DRIVER_BOUND and the link flag DL_FLAG_SYNC_STATE_ONLY is not set.

The topology in terms of consumers/suppliers used was the following (consumer ---> supplier):

      i2c -----------> OIC ----> PCI device
       |                ^
       |                |
       +---> pinctrl ---+

When the PCI device is removed, the OIC (interrupt controller) has to be removed. In order to remove the OIC, pinctrl and i2c need to be removed and to remove pinctrl, i2c need to be removed. The removal order is:
1) i2c
2) pinctrl
3) OIC
4) PCI device

In details, the removal sequence is the following (with 0000:01:00.0 the PCI device):
driver_detach: call device_release_driver_internal(0000:01:00.0)...

    device_links_busy(0000:01:00.0):
      links->status = DL_DEV_UNBINDING
    device_links_unbind_consumers(0000:01:00.0):
      0000:01:00.0--oic link->status = DL_STATE_SUPPLIER_UNBIND
      call device_release_driver_internal(oic)...
        device_links_busy(oic):
          links->status = DL_DEV_UNBINDING
        device_links_unbind_consumers(oic):
          oic--pinctrl link->status = DL_STATE_SUPPLIER_UNBIND
          call device_release_driver_internal(pinctrl)...
            device_links_busy(pinctrl):
              links->status = DL_DEV_UNBINDING
            device_links_unbind_consumers(pinctrl):
              pinctrl--i2c link->status = DL_STATE_SUPPLIER_UNBIND
              call device_release_driver_internal(i2c)...
                device_links_busy(i2c): links->status = DL_DEV_UNBINDING
                __device_links_no_driver(i2c)...
                  pinctrl--i2c link->status is DL_STATE_SUPPLIER_UNBIND
                  oic--i2c link->status is DL_STATE_ACTIVE
                  oic--i2c link->supplier->links.status is DL_DEV_UNBINDING

The warning is triggered by the i2c removal because the OIC (supplier) links status is not DL_DEV_DRIVER_BOUND. Its links status is indeed set to DL_DEV_UNBINDING.

It is perfectly legit to have the links status set to DL_DEV_UNBINDING in that case. Indeed we had started to unbind the OIC which triggered the consumer unbinding and didn't finish yet when the i2c is unbound.

Avoid the warning when the supplier links status is set to DL_DEV_UNBINDING and thus support this removal sequence without any warnings.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis

**Local tree:** Linux 6.18.44 (v6.18.44, make kernelversion = 6.18.44)
**Commit under review:** 36d74f17e03f7 — *driver core: Avoid warning when removing a device while its supplier is unbinding* **Status in this tree:** Buggy code present; fix **not** yet applied (git apply --check passes cleanly)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Parse the subject line
**Record:** [driver core] [avoid] [false WARN_ON during cascading device-link teardown when supplier is DL_DEV_UNBINDING]

### Step 1.2: Parse all commit message tags
**Record:**
- **Fixes:** — not present (expected for manual review)
- **Reported-by:** — none
- **Tested-by:** — none on this commit
- **Reviewed-by:** Rafael J. Wysocki <[email protected]>, Saravana Kannan <[email protected]> (both driver-core/PM maintainers)
- **Acked-by:** — none
- **Link:** https://patch.msgid.link/20260511155755.34428-4-
[email protected]
- **Cc: stable:** — absent (not a negative signal)
- **Signed-off-by:** Herve Codina (author), Greg Kroah-Hartman (committer); ignore pipeline-added SOBs

**Notable:** Reviewed by both primary driver-core maintainers; no syzbot/fuzzer report.

### Step 1.3: Analyze commit body
**Record:**
- **Bug:** WARN_ON fires in __device_links_no_driver() when a consumer (i2c) is torn down while its supplier (OIC) is mid-unbind (DL_DEV_UNBINDING), during PCI driver removal.
- **Symptom:** Kernel warning at drivers/base/core.c:1497, stack through device_links_driver_cleanup → device_release_driver_internal → device_links_unbind_consumers → pci_unregister_driver → lan966x_pci_driver_exit.
- **Topology:** i2c → OIC → PCI, i2c → pinctrl → OIC.
- **Root cause:** WARN_ON only exempts DL_FLAG_SYNC_STATE_ONLY links when supplier status ≠ DL_DEV_DRIVER_BOUND; DL_DEV_UNBINDING is also legitimate during cascading unbind.
- **Version info:** None explicit; trigger hardware (lan966x_pci) is in this tree since Oct 2024.

### Step 1.4: Detect hidden bug fixes
**Record:** Yes — disguised as “avoid warning,” but it corrects overly strict validation in core driver-link teardown. Runtime behavior is unchanged (DL_STATE_DORMANT still set); only a false-positive WARN_ON is suppressed. With panic_on_warn or CONFIG_BUG_ON_WARN, the spurious WARN can escalate to panic on module unload.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Inventory the changes
**Record:**
- **Files:** drivers/base/core.c (+2 / −1)
- **Function:** __device_links_no_driver()
- **Scope:** Single-file, surgical fix

### Step 2.2: Code flow change
**Record:**
- **Hunk (lines ~1500–1505):**
- **Before:** If supplier not DL_DEV_DRIVER_BOUND, WARN_ON(!DL_FLAG_SYNC_STATE_ONLY) then set link DL_STATE_DORMANT.
- **After:** Same, but skip WARN when supplier status is

    `DL_DEV_UNBINDING`.

- **Path:** Driver removal cascade — device_links_busy() sets DL_DEV_UNBINDING, consumers unbound recursively, device_links_driver_cleanup() → __device_links_no_driver().

### Step 2.3: Bug mechanism
**Record:** **Logic / correctness fix** — false-positive WARN_ON during legitimate teardown. Category: incorrect validation in driver- core device-link state machine (not UAF, leak, or race).

### Step 2.4: Fix quality
**Record:**
- Obviously correct: DL_DEV_UNBINDING is set in device_links_busy() at line 1622 before consumer unbind begins.
- Minimal change; no API/struct changes.
- **Regression risk:** Very low — only suppresses WARN for an already- handled state; link still goes to DL_STATE_DORMANT.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame changed lines
**Record:**
- WARN_ON line: b29929b819f35 (Jun 2025, Rafael) — refactor to device_link_test(); no semantic change.
- Original WARN_ON(!(link->flags & DL_FLAG_SYNC_STATE_ONLY)):
8c3e315d42964 (May 2020, Saravana Kannan).
- Surrounding logic: 8c3e315d429642 (May 2020).
- DL_DEV_UNBINDING: 9ed9895370aed (2016).
- **Both buggy WARN and DL_DEV_UNBINDING are in 6.18.44.**

### Step 3.2: Follow Fixes: tag
**Record:** N/A — no Fixes: tag.

### Step 3.3: File history / related changes
**Record:**
- Related in-tree precedent: 74b84d1be0220 — *driver core: fw_devlink:
Don't warn about sync_state() pending* (reduced false driver-core warnings).
- b29929b819f35 — device_link_test() refactor; in tree.
- Fix commit 36d74f17e03f7 — on master, not in HEAD.
- Part of v7 lan966x series (patch 3/3), but this hunk is self-contained in core.c.

### Step 3.4: Author context
**Record:** Herve Codina — lan966x_pci author (185686beb4649, Oct 2024); limited prior driver-core work (0462c56c290a9, 3b62449da4445).

### Step 3.5: Dependencies
**Record:** **Standalone.** No prerequisite commits; only adds DL_DEV_UNBINDING exemption to existing WARN. Applies cleanly to current HEAD.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original discussion
**Record:**
- b4 dig -c 36d74f17e03f7: https://patch.msgid.link/20260511155755.344
[email protected]
- Series: v1–v7; committed version is v7 patch 3/3.
- Thread saved to /tmp/driver-core-warn.mbox.

### Step 4.2: Reviewers
**Record:** CC'd: Greg Kroah-Hartman, Rafael J. Wysocki, Saravana Kannan, [email protected], linux-kernel; appropriate maintainers included.

### Step 4.3: Bug report
**Record:** Reproduced by author during lan966x_pci pci_unregister_driver(); stack trace in commit message. No external bugzilla/syzbot link.

### Step 4.4: Series context
**Record:** v7 cover is “lan966x pci device: Add support for SFPs, core part”; patches 1–2 are lan966x/i2c-specific. **Patch 3/3 is independent driver-core fix** — no dependency on other series patches for correctness.

### Step 4.5: Stable list
**Record:** No Cc: stable or stable-list discussion found in mbox (grep -i stable returned empty).

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key functions
**Record:** __device_links_no_driver() (modified); callers device_links_no_driver(), device_links_driver_cleanup().

### Step 5.2: Callers
**Record:**
- device_links_driver_cleanup() ← __device_release_driver() in drivers/base/dd.c:1359
- Called during device_release_driver_internal() → device_links_unbind_consumers() cascade
- Reachable from pci_unregister_driver() / module unload — confirmed in commit stack trace

### Step 5.3: Callees
**Record:** device_link_test(), WRITE_ONCE() for link status; sets dev->links.status = DL_DEV_NO_DRIVER.

### Step 5.4: Reachability
**Record:** Triggered on driver removal for devices with managed supplier links in multi-level topologies. **Userspace-reachable** via module unload / driver unbind. lan966x_pci in drivers/misc/lan966x_pci.c is the documented trigger in this tree.

### Step 5.5: Similar patterns
**Record:** Same WARN pattern exists in device_links_missing_supplier() (also from 8c3e315); this fix targets only __device_links_no_driver(). No other DL_DEV_UNBINDING WARN exemptions in core.c.

---

## PHASE 6: CROSS-REFERENCE AGAINST LOCAL TREE (6.18.44)

### Step 6.1: Buggy code exists?
**Record:** **Yes.** Current drivers/base/core.c:1503:

```c
WARN_ON(!device_link_test(link, DL_FLAG_SYNC_STATE_ONLY));
```

Bug present since 8c3e315d42964 (2020); trigger topology possible since lan966x_pci (185686beb4649, Oct 2024).

### Step 6.2: Backport complications **Record:** **Clean apply** — git show 36d74f17e03f7 -- drivers/base/core.c | git apply --check succeeded.

### Step 6.3: Related fixes already present?
**Record:** Fix 36d74f17e03f7 **not** in tree. Related warn-reduction 74b84d1be0220 is present. No duplicate fix for this specific case.

---

## PHASE 7: SUBSYSTEM CONTEXT

### Step 7.1: Subsystem criticality
**Record:** **driver core** (drivers/base/) — **CORE** subsystem; affects all device link teardown.

### Step 7.2: Activity
**Record:** Active — recent commits include 3e8fefd2997c8, 74b84d1be0220, b29929b819f35 on core.c.

---

## PHASE 8: IMPACT AND RISK

### Step 8.1: Who is affected
**Record:** Users of hardware with multi-level managed device links during driver removal. **In this tree:** lan966x_pci users unloading/reloading the module. Broader applicability for similar topologies.

### Step 8.2: Trigger conditions
**Record:** PCI (or other) driver unregister with supplier→consumer chain where supplier is DL_DEV_UNBINDING while consumer still has active supplier links. **Uncommon but real** — reproduced on lan966x. Unprivileged users can trigger via module unload if module is loadable.

### Step 8.3: Failure mode severity
**Record:** Spurious WARN_ON in dmesg on every affected teardown.
Default: **MEDIUM** (noise, possible monitoring alerts). With panic_on_warn=y: **HIGH** (panic on module unload). No corruption, UAF, or deadlock.

### Step 8.4: Risk-benefit
**Record:**
- **Benefit:** Eliminates false warnings on real hardware in this tree; corrects driver-core validation; very small diff.
- **Risk:** Very low — one additional legitimate state exempted from WARN.
- **Ratio:** Favorable for 6.18.44, which ships lan966x_pci.

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence summary

**FOR backport:**
- Real false-positive WARN on driver removal for hardware present in 6.18.44 (lan966x_pci)
- Core subsystem fix, 2-line change, applies cleanly
- Reviewed by Rafael Wysocki and Saravana Kannan
- Buggy code has been in tree since 2020; trigger hardware since Oct 2024
- Self-contained; no series dependencies
- Precedent: 74b84d1be0220 in same tree reduced driver-core false warnings

**AGAINST backport:**
- No functional/runtime behavior change beyond suppressing WARN
- Default severity is log noise, not crash/corruption
- Narrow topology; not syzbot-reported
- No explicit stable nomination in lore thread

**Unresolved:** Whether production deployments use panic_on_warn for lan966x systems (unverified).

### Step 9.2: Stable rules checklist
1. Obviously correct and tested? **PASS** — logic is clear; maintainer- reviewed; author tested on lan966x unload path.
2. Fixes a real bug affecting users? **PASS** — false WARN on lan966x_pci module unload in this tree.
3. Important issue? **PASS (borderline)** — MEDIUM by default; HIGH if panic_on_warn; affects real hardware teardown in 6.18.44.
4. Small and contained? **PASS** — 2 lines, one function.
5. No new features/APIs? **PASS**
6. Can apply to local tree? **PASS** — clean apply verified.

### Step 9.3: Exception categories
**Record:** None (not device ID, quirk, DT, build, or docs).

### Step 9.4: Decision rationale
For **Linux 6.18.44 specifically**, this should be backported. The tree contains both the longstanding overly strict WARN logic and the lan966x_pci driver that reproduces it on every module unload. The fix is minimal, maintainer-approved, self-contained, and applies cleanly. While severity is moderate under default configs, it is a genuine driver-core correctness fix for a real teardown path on shipped hardware.

---

## Verification

- [Phase 1] Parsed commit message and tags from git show 36d74f17e03f7
- [Phase 2] Diff: 2-line WARN condition change in __device_links_no_driver()
- [Phase 3] git blame -L 1500,1505: WARN from b29929b/8c3e315; git log -S: original WARN in 8c3e315d42964
- [Phase 3] git merge-base --is-ancestor: 8c3e315, b29929b, 185686beb4649 in tree; fix 36d74f17e03f7 NOT in tree
- [Phase 3] git show 8c3e315d42964: confirmed WARN introduction in 2020
- [Phase 4] b4 dig -c 36d74f17e03f7: lore URL found; v7 patch 3/3
- [Phase 4] b4 dig -c 36d74f17e03f7 -a: series v1–v7 listed
- [Phase 4] b4 dig -c 36d74f17e03f7 -w: maintainers CC'd
- [Phase 4] /tmp/driver-core-warn.mbox: no stable nomination found
- [Phase 4] WebFetch lore URL: blocked by Anubis (unverified via web; mbox via b4 succeeded)
- [Phase 5] Call chain verified: dd.c:1359 → device_links_driver_cleanup → __device_links_no_driver
- [Phase 5] device_links_busy() sets DL_DEV_UNBINDING at core.c:1622
- [Phase 6] git describe HEAD / make kernelversion: 6.18.44
- [Phase 6] git apply --check: patch applies cleanly
- [Phase 6] grep lan966x_pci: drivers/misc/lan966x_pci.c present
- [Phase 6] git show 185686beb4649: lan966x_pci added Oct 2024
- [Phase 7] git log -20 -- drivers/base/core.c: active subsystem
- [Phase 8] Failure mode assessed as MEDIUM (WARN), HIGH with panic_on_warn (unverified in field)
- [UNVERIFIED] Exact panic_on_warn usage on lan966x deployments

**YES**Those background lookups finished and matched what the analysis already used:

- **core.c history:** Recent driver-core commits are on this tree; the fix (36d74f17e03f7) is not.
- **Related fixes:** Older device-link commits turned up, but nothing that already covers this WARN case.
- **lan966x_pci:** Introduced in 185686beb4649 (Oct 2024) and present in 6.18.44 — the hardware that triggers the spurious warning on module unload.

Verdict from the full review: **YES** for backport to this 6.18.44 tree.

 drivers/base/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/core.c +2 -1
index 2b0179096c73d..5ba783e5055ae 100644
@@ -1500,7 +1500,8 @@ static void __device_links_no_driver(struct device *dev)
 		if (link->supplier->links.status == DL_DEV_DRIVER_BOUND) {
 			WRITE_ONCE(link->status, DL_STATE_AVAILABLE);
 		} else {
-			WARN_ON(!device_link_test(link, DL_FLAG_SYNC_STATE_ONLY));
+			WARN_ON(link->supplier->links.status != DL_DEV_UNBINDING &&
+				!device_link_test(link, DL_FLAG_SYNC_STATE_ONLY));
 			WRITE_ONCE(link->status, DL_STATE_DORMANT);
 		}
 	}
Signature · 1 line
2.53.0
author maintainer
#711 lore raw

PATCH 1/1 wifi: ath11k: fix invalid data access in ath11k_dp_rx_h_undecap_nwifi

In reply to Sasha Levin

From: Miaoqing Pan <[email protected]>

[ Upstream commit 6b471e9aefee9ed73278eb1141e0d8530a56fae9 ]

In certain cases, hardware might provide packets with a length greater than the maximum native Wi-Fi header length. This can lead to accessing and modifying fields in the header within the ath11k_dp_rx_h_undecap_nwifi() function for the DP_RX_DECAP_TYPE_NATIVE_WIFI decap type and potentially result in invalid data access and memory corruption.

Kernel stack is corrupted in: ath11k_dp_rx_h_undecap+0x6b0/0x6b0 [ath11k]

Call trace:
 ath11k_dp_rx_h_mpdu+0x0/0x2e8 [ath11k]
 ath11k_dp_rx_h_mpdu+0x1e0/0x2e8 [ath11k]
 ath11k_dp_rx_wbm_err+0x1e0/0x450 [ath11k]
 ath11k_dp_rx_process_wbm_err+0x2fc/0x460 [ath11k]
 ath11k_dp_service_srng+0x2e0/0x348 [ath11k]

Add a sanity check before processing the SKB to prevent invalid data access in the undecap native Wi-Fi function for the DP_RX_DECAP_TYPE_NATIVE_WIFI decap type.

This adapted from the discussion/patch of the ath12k driver [1].

Tested-on: WCN6855 hw2.1 PCI WLAN.HSP.1.1-04685-QCAHSPSWPL_V1_V2_SILICONZ_IOE-1

---

LLM Generated explanations, may be completely bogus:

The background searches finished and match the earlier analysis:

- **Ath11k fix not in tree** — git log --grep found no commit for ath11k_dp_rx_check_nwifi_hdr_len_valid or the ath11k undecap_nwifi fix.
- **Ath12k analogue present** — 9a0dddfb30f12 (wifi: ath12k: Fix invalid data access in ath12k_dp_rx_h_undecap_nwifi) is already in v6.18.44.

That supports the **YES** backport verdict: the bug is still present in ath11k here, and the fix is a proven port of code already merged for ath12k in this tree.

 drivers/net/wireless/ath/ath11k/dp_rx.c | 50 +++++++++++++++++++++++--
 1 file changed, 47 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath11k/dp_rx.c +47 -3
index 330446f279cd6..1514f8657d546 100644
@@ -2501,6 +2501,29 @@ static void ath11k_dp_rx_deliver_msdu(struct ath11k *ar, struct napi_struct *nap
 	ieee80211_rx_napi(ar->hw, pubsta, msdu, napi);
 }
 
+static bool ath11k_dp_rx_check_nwifi_hdr_len_valid(struct ath11k_base *ab,
+						   struct hal_rx_desc *rx_desc,
+						   struct sk_buff *msdu)
+{
+	struct ieee80211_hdr *hdr;
+	u8 decap_type;
+	u32 hdr_len;
+
+	decap_type = ath11k_dp_rx_h_msdu_start_decap_type(ab, rx_desc);
+	if (decap_type != DP_RX_DECAP_TYPE_NATIVE_WIFI)
+		return true;
+
+	hdr = (struct ieee80211_hdr *)msdu->data;
+	hdr_len = ieee80211_hdrlen(hdr->frame_control);
+
+	if (likely(hdr_len <= DP_MAX_NWIFI_HDR_LEN))
+		return true;
+
+	ab->soc_stats.invalid_rbm++;
+	WARN_ON_ONCE(1);
+	return false;
+}
+
 static int ath11k_dp_rx_process_msdu(struct ath11k *ar,
 				     struct sk_buff *msdu,
 				     struct sk_buff_head *msdu_list,
@@ -2571,6 +2594,11 @@ static int ath11k_dp_rx_process_msdu(struct ath11k *ar,
 		}
 	}
 
+	if (unlikely(!ath11k_dp_rx_check_nwifi_hdr_len_valid(ab, rx_desc, msdu))) {
+		ret = -EINVAL;
+		goto free_out;
+	}
+
 	ath11k_dp_rx_h_ppdu(ar, rx_desc, rx_status);
 	ath11k_dp_rx_h_mpdu(ar, msdu, rx_desc, rx_status);
 
@@ -3306,6 +3334,12 @@ static int ath11k_dp_rx_h_verify_tkip_mic(struct ath11k *ar, struct ath11k_peer
 		    RX_FLAG_IV_STRIPPED | RX_FLAG_DECRYPTED;
 	skb_pull(msdu, hal_rx_desc_sz);
 
+	if (unlikely(!ath11k_dp_rx_check_nwifi_hdr_len_valid(ar->ab, rx_desc,
+							     msdu))) {
+		dev_kfree_skb_any(msdu);
+		return -EINVAL;
+	}
+
 	ath11k_dp_rx_h_ppdu(ar, rx_desc, rxs);
 	ath11k_dp_rx_h_undecap(ar, msdu, rx_desc,
 			       HAL_ENCRYPT_TYPE_TKIP_MIC, rxs, true);
@@ -3998,6 +4032,10 @@ static int ath11k_dp_rx_h_null_q_desc(struct ath11k *ar, struct sk_buff *msdu,
 		skb_put(msdu, hal_rx_desc_sz + l3pad_bytes + msdu_len);
 		skb_pull(msdu, hal_rx_desc_sz + l3pad_bytes);
 	}
+
+	if (unlikely(!ath11k_dp_rx_check_nwifi_hdr_len_valid(ar->ab, desc, msdu)))
+		return -EINVAL;
+
 	ath11k_dp_rx_h_ppdu(ar, desc, status);
 
 	ath11k_dp_rx_h_mpdu(ar, msdu, desc, status);
@@ -4042,7 +4080,7 @@ static bool ath11k_dp_rx_h_reo_err(struct ath11k *ar, struct sk_buff *msdu,
 	return drop;
 }
 
-static void ath11k_dp_rx_h_tkip_mic_err(struct ath11k *ar, struct sk_buff *msdu,
+static bool ath11k_dp_rx_h_tkip_mic_err(struct ath11k *ar, struct sk_buff *msdu,
 					struct ieee80211_rx_status *status)
 {
 	u16 msdu_len;
@@ -4050,6 +4088,7 @@ static void ath11k_dp_rx_h_tkip_mic_err(struct ath11k *ar, struct sk_buff *msdu,
 	u8 l3pad_bytes;
 	struct ath11k_skb_rxcb *rxcb = ATH11K_SKB_RXCB(msdu);
 	u32 hal_rx_desc_sz = ar->ab->hw_params.hal_desc_sz;
+	struct ath11k_base *ab = ar->ab;
 
 	rxcb->is_first_msdu = ath11k_dp_rx_h_msdu_end_first_msdu(ar->ab, desc);
 	rxcb->is_last_msdu = ath11k_dp_rx_h_msdu_end_last_msdu(ar->ab, desc);
@@ -4059,6 +4098,9 @@ static void ath11k_dp_rx_h_tkip_mic_err(struct ath11k *ar, struct sk_buff *msdu,
 	skb_put(msdu, hal_rx_desc_sz + l3pad_bytes + msdu_len);
 	skb_pull(msdu, hal_rx_desc_sz + l3pad_bytes);
 
+	if (unlikely(!ath11k_dp_rx_check_nwifi_hdr_len_valid(ab, desc, msdu)))
+		return true;
+
 	ath11k_dp_rx_h_ppdu(ar, desc, status);
 
 	status->flag |= (RX_FLAG_MMIC_STRIPPED | RX_FLAG_MMIC_ERROR |
@@ -4066,19 +4108,21 @@ static void ath11k_dp_rx_h_tkip_mic_err(struct ath11k *ar, struct sk_buff *msdu,
 
 	ath11k_dp_rx_h_undecap(ar, msdu, desc,
 			       HAL_ENCRYPT_TYPE_TKIP_MIC, status, false);
+
+	return false;
 }
 
 static bool ath11k_dp_rx_h_rxdma_err(struct ath11k *ar,  struct sk_buff *msdu,
 				     struct ieee80211_rx_status *status)
 {
 	struct ath11k_skb_rxcb *rxcb = ATH11K_SKB_RXCB(msdu);
-	bool drop = false;
+	bool drop;
 
 	ar->ab->soc_stats.rxdma_error[rxcb->err_code]++;
 
 	switch (rxcb->err_code) {
 	case HAL_REO_ENTR_RING_RXDMA_ECODE_TKIP_MIC_ERR:
-		ath11k_dp_rx_h_tkip_mic_err(ar, msdu, status);
+		drop = ath11k_dp_rx_h_tkip_mic_err(ar, msdu, status);
 		break;
 	default:
 		/* TODO: Review other rxdma error code to check if anything is
Signature · 1 line
2.53.0
author maintainer
#712 lore raw

PATCH 1/1 sched_ext: Mark waker CPU busy when selected in WAKE_SYNC case

In reply to Sasha Levin

From: Kuba Piecuch <[email protected]>

[ Upstream commit 9591fcc95dddfd24298724f8eb5239e907980779 ]

SCX's built-in idle CPU tracking is imperfect and can be out-of-sync with the actual idle state of CPUs, especially immediately after enabling SCX due to scx_idle_enable() marking all online CPUs idle.

scx_select_cpu_dfl() skips marking the selected CPU as busy if the selected CPU is the waker CPU in the SCX_WAKE_SYNC case. If the waker CPU was marked idle by SCX, it will still be marked idle after CPU selection and potentially even after switching to the wakee.

In the allowed_cpus selftest, this can manifest as the test failing with the following message in dmesg:

allowed_cpus.bpf.c:21: CPU 0 should be marked as busy

This patch explicitly marks the waker CPU as busy. With this patch, the test failure no longer reproduces. There are still some pretty unlikely races that could make the test fail (e.g. pick_task_idle() marking the selected CPU idle between selection and validation), but these can't be fixed easily.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: sched_ext: Mark waker CPU busy when selected in WAKE_SYNC case

**Local tree:** v6.18.44 (linux-6.18.y, VERSION=6, PATCHLEVEL=18, SUBLEVEL=44)

**Commit analyzed:** b9f6521da1907 (upstream: 9591fcc95dddf)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject Line
**Record:** [sched_ext] [Mark] — Mark waker CPU busy when selected in WAKE_SYNC case. Action is a correctness/state fix (not a feature add).

### Step 1.2: Tags
**Record:**
- **Signed-off-by:** Kuba Piecuch <[email protected]> (author)
- **Signed-off-by:** Tejun Heo <[email protected]> (sched_ext maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Link:, or Cc:
stable tags
- [Upstream commit 9591fcc95dddf] marker present (pipeline artifact — ignored per instructions)

### Step 1.3: Body Analysis
**Record:**
- **Bug:** SCX built-in idle CPU tracking can be out of sync with real CPU idle state, especially right after scx_idle_enable() marks all online CPUs idle.
- **Mechanism:** In scx_select_cpu_dfl(), the SCX_WAKE_SYNC path selects the waker CPU but skips scx_idle_test_and_clear_cpu(), unlike every other selection path in the same function.
- **Symptom:** Selected waker CPU remains marked idle after CPU selection (and potentially after wakee switch).
- **Observable failure:** allowed_cpus selftest fails with allowed_cpus.bpf.c:21: CPU 0 should be marked as busy in dmesg.
- **Root cause (author):** Missing idle-bit clear on the WAKE_SYNC waker-CPU fast path.

### Step 1.4: Hidden Bug Fix?
**Record:** Yes — despite not using "fix" in the subject, this is a logic/correctness bug in idle tracking state management, not cleanup or optimization.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Inventory
**Record:**
- **File:** kernel/sched/ext_idle.c (+3, -1 lines)
- **Function:** scx_select_cpu_dfl()
- **Scope:** Single-file, surgical fix in one code path

### Step 2.2: Code Flow Change
**Record:**
- **Before:** In SCX_WAKE_SYNC path, when waker's local DSQ is empty and system underutilized, if waker CPU is in allowed mask → goto out_unlock without updating idle tracking.
- **After:** Same path, but calls scx_idle_test_and_clear_cpu(cpu) before goto out_unlock, matching all other CPU selection exits in this function.
- **Path affected:** WAKE_SYNC synchronous wakeup CPU selection (normal wakeup path, not error path).

### Step 2.3: Bug Mechanism
**Record:** **Logic / correctness fix** — inconsistent idle-mask bookkeeping. Other selection branches call scx_idle_test_and_clear_cpu() when claiming a CPU; this branch was the sole exception, leaving the waker CPU incorrectly marked idle in SCX's built-in idle cpumask.

### Step 2.4: Fix Quality
**Record:**
- Obviously correct: mirrors existing pattern used at lines 528, 566, 614, 937 in the same file.
- Minimal change, no API changes, no new behavior beyond fixing state.
- **Regression risk:** Very low — scx_idle_test_and_clear_cpu() is idempotent-safe for a CPU about to run a task; it's already called on every other selection path.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
**Record:**
- WAKE_SYNC block introduced in 48849271e66114 (Andrea Righi, Feb 2025, "sched_ext: idle: Per-node idle cpumasks").
- The goto out_unlock without idle clear at lines 551–552 introduced in 23c63a965275ce (Apr 2025, refactoring to pass explicit allowed cpumask — "pure refactoring with no functional changes", but the WAKE_SYNC path never had the clear call).
- Buggy code **is an ancestor of HEAD** in this tree.

### Step 3.2: Fixes: Tag
**Record:** Not applicable — no Fixes: tag present.

### Step 3.3: Related File History
**Record:** Recent stable-relevant sched_ext idle fixes already in linux-6.18.y:
- a8f4a82e5629c — idle: Recheck prev_cpu after narrowing allowed mask
- b49bf41b41148 — Fix inconsistent NUMA node lookup in scx_select_cpu_dfl()
- 72c43eb2e334f — Fix is_bpf_migration_disabled() false negative

This fix is the same category: small sched_ext idle-selection correctness fix.

### Step 3.4: Author Context
**Record:** Kuba Piecuch (Google). No prior commits in kernel/sched/ in this tree; patch went through Tejun Heo's sched_ext tree (for-7.2-fixes).

### Step 3.5: Dependencies
**Record:** Standalone — no series dependencies, no prerequisite commits. Applies cleanly to current HEAD (git apply --check passes).

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original Discussion
**Record:**
- b4 dig -c b9f6521da1907 -a found v1 submission:
https://patch.msgid.link/[email protected]
(2026-07-22, sched_ext/for-7.2-fixes)
- b4 dig -c without -a could not match by patch-id alone
- Lore/msgid.link fetch blocked by bot protection — could not read thread content

### Step 4.2: Reviewers
**Record:** b4 dig -w did not return recipient details (same patch-id match failure). Commit has Tejun Heo SOB (maintainer acceptance).

### Step 4.3: Bug Report
**Record:** Failure documented in commit message via allowed_cpus selftest. No syzbot, no user bugzilla report.

### Step 4.4: Related Patches
**Record:** Standalone 1-patch fix for for-7.2-fixes. No multi-patch series dependency.

### Step 4.5: Stable List History
**Record:** Could not search lore stable list (bot protection). However, similar sched_ext idle fixes are already present in this 6.18.y tree (see Phase 3.3).

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key Functions
**Record:** scx_select_cpu_dfl(), scx_idle_test_and_clear_cpu(), scx_bpf_select_cpu_and() (wrapper calling scx_select_cpu_dfl)

### Step 5.2: Callers
**Record:**
- scx_select_cpu_dfl() called from scx_bpf_select_cpu_and() (BPF kfunc, line 942) and kernel/sched/ext.c:2578 (default select_cpu when BPF scheduler doesn't implement ops.select_cpu)
- SCX_WAKE_SYNC originates from normal scheduler wakeups (WF_SYNC in kernel/sched/fair.c, kernel/sched/core.c)
- Reachable from syscall-driven task wakeups when sched_ext is active

### Step 5.3: Callees
**Record:** scx_idle_test_and_clear_cpu() clears CPU (and SMT cluster) from per-node idle cpumasks via cpumask_test_and_clear_cpu().

### Step 5.4: Call Chain / Reachability
**Record:** wake_up_* → CFS/SCX wakeup → scx_select_cpu_dfl() with SCX_WAKE_SYNC → BPF kfunc scx_bpf_select_cpu_and() → BPF scheduler validation. **Reachable from userspace** via normal process wakeup when CONFIG_SCHED_CLASS_EXT is enabled and a BPF scheduler is loaded.

### Step 5.5: Similar Patterns
**Record:** Every other CPU-claim path in scx_select_cpu_dfl() calls scx_idle_test_and_clear_cpu() before returning the selected CPU. The WAKE_SYNC waker path was the only exception — systematic omission, not an isolated quirk.

---

## PHASE 6: CROSS-REFERENCING AGAINST LOCAL TREE

### Step 6.1: Buggy Code Exists?
**Record:** **Yes.** Current HEAD at kernel/sched/ext_idle.c:551-552:

```551:552:kernel/sched/ext_idle.c
                        if (cpumask_test_cpu(cpu, allowed))
                                goto out_unlock;
```

Missing scx_idle_test_and_clear_cpu(cpu) call. Fix commit b9f6521da1907 is **NOT** an ancestor of HEAD.

### Step 6.2: Backport Complications
**Record:** **Clean apply** — patch targets kernel/sched/ext_idle.c (user-provided diff showed kernel/sched/ext/idle.c from mainline post- refactor; this tree uses the pre-refactor filename). git apply --check on the actual backport commit succeeds with no conflicts.

### Step 6.3: Related Fixes Already Present?
**Record:** No equivalent fix already in tree. Related idle-selection fixes are present (NUMA lookup, prev_cpu recheck) but not this WAKE_SYNC path.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

### Step 7.1: Subsystem Criticality
**Record:** **IMPORTANT** — kernel/sched/ext_* (sched_ext BPF scheduler class). Not universal (requires CONFIG_SCHED_CLASS_EXT), but scheduling correctness affects all tasks when enabled.

### Step 7.2: Subsystem Activity
**Record:** Highly active in 6.18.y — sched_ext merged for 6.18 (fd95357fd8c67), with ongoing idle-selection fixes backported to stable.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Who Is Affected
**Record:** Users with CONFIG_SCHED_CLASS_EXT enabled running BPF schedulers that use built-in idle CPU selection (SCX_OPS_KEEP_BUILTIN_IDLE or no ops.update_idle). Includes selftests and production schedulers (scx_simple, custom Google/Meta schedulers, etc.).

### Step 8.2: Trigger Conditions
**Record:**
- Synchronous wakeup (SCX_WAKE_SYNC / WF_SYNC)
- Waker's local DSQ empty, system underutilized (idle CPUs exist)
- Waker CPU is in the allowed cpumask
- Particularly visible right after SCX enable when all CPUs are marked idle
- **Common enough** in normal wakeup patterns; not an obscure error path

### Step 8.3: Failure Mode Severity
**Record:**
- **Incorrect idle tracking** → BPF schedulers see CPU as idle when it's selected for a task
- **Selftest:** scx_bpf_error() → BPF scheduler disabled (SCX_EXIT_ERROR_BPF)
- **Production:** Suboptimal/wrong CPU placement, potential double- selection of "idle" CPUs, broken scheduler invariants for BPF code relying on idle mask accuracy
- **Severity: MEDIUM-HIGH** for sched_ext users (functional correctness / scheduler failure), not kernel oops/panic/data corruption

### Step 8.4: Risk-Benefit
**Record:**
- **Benefit:** Fixes real API contract violation; restores consistency with all other selection paths; fixes reproducible selftest failure; aligns with other sched_ext idle fixes already in 6.18.y
- **Risk:** Very low — 3-line addition of existing helper call
- **Ratio:** Strong benefit, minimal risk for affected users

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence Summary

**FOR backport:**
- Real bug: WAKE_SYNC path omits idle-bit clear that all sibling paths perform
- Bug present in v6.18.44 tree; fix not yet applied
- Patch applies cleanly
- Small, surgical, maintainer-signed (Tejun Heo)
- Breaks scx_bpf_select_cpu_and() API contract (returned CPU should not still be idle)
- Reproducible via allowed_cpus selftest
- Similar sched_ext idle fixes already backported to this tree
- sched_ext is a supported subsystem in 6.18.y

**AGAINST backport:**
- No production user crash report or CVE
- Only affects CONFIG_SCHED_CLASS_EXT users (optional config)
- Author acknowledges remaining unlikely races (fix is not complete for all edge cases)
- Not a kernel panic/oops — BPF scheduler error/disable at worst
- Lore discussion content unverified (bot protection)

**UNRESOLVED:**
- Full mailing list review thread content (could not fetch)
- Whether any reviewer explicitly nominated for stable

### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **PASS** — mirrors existing pattern; selftest no longer reproduces
2. Fixes a real bug affecting users? **PASS** — idle tracking inconsistency in sched_ext
3. Important issue? **PASS** — scheduling correctness bug; can disable BPF scheduler via scx_bpf_error()
4. Small and contained? **PASS** — 3 lines, 1 file, 1 function
5. No new features or APIs? **PASS** — state bookkeeping fix only
6. Can apply to local tree? **PASS** — clean apply verified

### Step 9.3: Exception Categories
**Record:** Not applicable (not device ID, quirk, DT, build, or docs fix).

### Step 9.4: Decision Rationale
This is a clear correctness bug in sched_ext's built-in idle CPU tracking that exists in the 6.18.y tree. The fix is trivial, follows an established pattern already used throughout the same function, applies cleanly, and is consistent with other sched_ext idle-selection fixes already backported to this stable series. While the primary documented failure is a selftest, the underlying bug violates the scx_bpf_select_cpu_and() contract and can affect real BPF scheduler behavior on synchronous wakeups — a path reachable from normal process activity.

---

## Verification

- **[Phase 1]** git show b9f6521da1907 --format=fuller --no-patch:
parsed commit message and tags
- **[Phase 2]** git show b9f6521da1907: confirmed 3-line fix in scx_select_cpu_dfl() WAKE_SYNC path
- **[Phase 2]** Read kernel/sched/ext_idle.c:519-570: confirmed missing scx_idle_test_and_clear_cpu(cpu) on buggy path vs. present on other paths
- **[Phase 3]** git blame -L 546,555 kernel/sched/ext_idle.c:
WAKE_SYNC block from 48849271e66114, goto without clear from 23c63a965275ce
- **[Phase 3]** git merge-base --is-ancestor 23c63a965275ce HEAD:
buggy code is in tree
- **[Phase 3]** git merge-base --is-ancestor b9f6521da1907 HEAD: fix NOT in tree
- **[Phase 3]** git log --oneline -15 stable/linux-6.18.y -- kernel/sched/ext_idle.c: related idle fixes already backported
- **[Phase 4]** b4 dig -c b9f6521da1907 -a: found v1 at patch.msgid.link/[email protected]
- **[Phase 4]** WebFetch lore/msgid.link: **BLOCKED** by bot protection — thread content unverified
- **[Phase 5]** Grep SCX_WAKE_SYNC, scx_select_cpu_dfl: traced call paths through scx_bpf_select_cpu_and() and ext.c:2578
- **[Phase 5]** Read allowed_cpus.bpf.c:17-27: selftest validates CPU must not be idle after selection
- **[Phase 5]** Read ext.c:6420-6431: scx_bpf_error() triggers scheduler disable
- **[Phase 6]** git describe HEAD: v6.18.44 confirmed
- **[Phase 6]** git show b9f6521da1907 -- kernel/sched/ext_idle.c | git apply --check: clean apply
- **[Phase 6]** Grep kernel/sched/ext: directory does not exist; code is in ext_idle.c (filename differs from user's diff but same code)
- **[Phase 7]** kernel/Kconfig.preempt:166-191:
CONFIG_SCHED_CLASS_EXT present in tree
- **[Phase 8]** Read reset_idle_masks() at ext_idle.c:775-795:
confirms all online CPUs marked idle at SCX enable

**YES****Result:** Analysis of sched_ext: Mark waker CPU busy when selected in WAKE_SYNC case (b9f6521da1907) for **linux-6.18.y (v6.18.44)** is complete.

**Finding:** The bug is present in this tree — in scx_select_cpu_dfl()’s SCX_WAKE_SYNC path, the waker CPU is selected without calling scx_idle_test_and_clear_cpu(), unlike every other selection path. That leaves SCX’s built-in idle tracking wrong and breaks the scx_bpf_select_cpu_and() contract (reproducible via the allowed_cpus selftest).

**Backport suitability:** The fix is 3 lines, applies cleanly to kernel/sched/ext_idle.c, matches other sched_ext idle fixes already in 6.18.y, and is signed off by Tejun Heo.

**Verdict: YES** — backport to this tree.

 kernel/sched/ext_idle.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/sched/ext_idle.c +3 -1
index d16a1de078656..42a65a9535aef 100644
@@ -548,8 +548,10 @@ s32 scx_select_cpu_dfl(struct task_struct *p, s32 prev_cpu, u64 wake_flags,
 		    cpu_rq(cpu)->scx.local_dsq.nr == 0 &&
 		    (!(flags & SCX_PICK_IDLE_IN_NODE) || (waker_node == node)) &&
 		    !cpumask_empty(idle_cpumask(waker_node)->cpu)) {
-			if (cpumask_test_cpu(cpu, allowed))
+			if (cpumask_test_cpu(cpu, allowed)) {
+				scx_idle_test_and_clear_cpu(cpu);
 				goto out_unlock;
+			}
 		}
 	}
 
Signature · 1 line
2.53.0
author maintainer
#713 lore raw

PATCH 1/1 soundwire: intel: Move suspend tracking from trigger to pm suspend

In reply to Sasha Levin

From: Peter Ujfalusi <[email protected]>

[ Upstream commit acf676b9de0c86bc735a7f04962d3d688e156ffc ]

Mark all open DAI runtimes as suspended in the component .suspend callback instead of relying on SNDRV_PCM_TRIGGER_SUSPEND, which is not delivered during PAUSE or xrun states.

If during system suspend a dai is open it means that it is in either in SUSPENDED, PAUSED or STOPPED (due to xrun) state and they will need to be re-initialized during resume (which is done in .prepare callback).

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: soundwire: intel: Move suspend tracking from trigger to pm suspend

**Local tree:** Linux 6.18.43 (git describe HEAD → v6.18.43-1-gc7f0dac02d232)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject Line
**Record:** [soundwire: intel] [move] — Relocate suspend-state tracking from PCM trigger callback to component PM suspend callback.

### Step 1.2: Commit Message Tags
**Record:**
- **Signed-off-by:** Peter Ujfalusi, Bard Liao, Vinod Koul (subsystem maintainer)
- **Link:** https://patch.msgid.link/20260508101755.1247039-1-yung-
[email protected]
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Cc:
[email protected]
- Notable: Maintainer (Vinod Koul) signed off; no syzbot/fuzzer report

### Step 1.3: Commit Body Analysis
**Record:**
- **Bug:** Suspend tracking relied on SNDRV_PCM_TRIGGER_SUSPEND, which ALSA does not deliver when a stream is in PAUSE or xrun (STOPPED) state at system-suspend time.
- **Symptom:** On resume, .prepare() does not reinitialize SHIM/DMA hardware because dai_runtime->suspended was never set; audio fails after suspend/resume.
- **Root cause:** TRIGGER_SUSPEND is only sent when snd_pcm_running() is true (RUNNING/DRAINING only).
- **Fix approach:** Mark all open DAIs suspended in the component .suspend callback, which runs during system PM suspend after PCM suspend.

### Step 1.4: Hidden Bug Fix Detection
**Record:** Yes — described as a refactor (“move”), but it fixes a real suspend/resume correctness bug. The suspended flag gates hardware reinit in intel_prepare().

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Change Inventory
**Record:**
- drivers/soundwire/intel.c: ~17 lines removed, ~10 modified (net −7)
- drivers/soundwire/intel_ace2x.c: ~14 lines removed, ~27 added (new intel_component_dais_suspend, .suspend hook)
- **Functions modified:** intel_trigger(), intel_component_dais_suspend() (intel.c); intel_trigger(), new intel_component_dais_suspend() (intel_ace2x.c)
- **Scope:** Single-subsystem, two related driver files; surgical fix

### Step 2.2: Code Flow Change
**Record:**

| Hunk | Before | After |
|------|--------|-------|
| `intel_trigger()` (both files) | On `SNDRV_PCM_TRIGGER_SUSPEND`, set
`dai_runtime->suspended = true` | `TRIGGER_SUSPEND` case removed; only
pause tracking remains |
| `intel_component_dais_suspend()` (intel.c) | Only set `suspended` if
`paused && !suspended` | Set `suspended = true` for every open
`dai_runtime` |
| `intel_ace2x.c` component driver | No `.suspend` callback | Adds
`intel_component_dais_suspend` + `.suspend` hook |

**Execution path affected:** System suspend (S3/runtime suspend) → ASoC card suspend → PCM suspend → component suspend → resume → .prepare().

### Step 2.3: Bug Mechanism
**Record:**
- **Category:** Logic/correctness — suspend-state tracking bug
- **Mechanism:** snd_pcm_do_suspend() in sound/core/pcm_native.c skips TRIGGER_SUSPEND when !snd_pcm_running(). PAUSED and XRUN streams are not “running,” so the driver never sets dai_runtime->suspended. intel_prepare() only reinitializes SHIM/ALH when dai_runtime->suspended is true.

Verified in tree:

```1713:1721:sound/core/pcm_native.c
static int snd_pcm_do_suspend(struct snd_pcm_substream *substream,
                              snd_pcm_state_t state)
{
        struct snd_pcm_runtime *runtime = substream->runtime;
        if (runtime->trigger_master != substream)
                return 0;
        if (! snd_pcm_running(substream))
                return 0;
        substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND);
```
```711:716:include/sound/pcm.h
static inline int snd_pcm_running(struct snd_pcm_substream *substream)
{
        return (substream->runtime->state == SNDRV_PCM_STATE_RUNNING ||
                (substream->runtime->state == SNDRV_PCM_STATE_DRAINING
&&
                 substream->stream == SNDRV_PCM_STREAM_PLAYBACK));
}
```

### Step 2.4: Fix Quality
**Record:**
- Fix is minimal and matches the PM lifecycle; component suspend runs after snd_pcm_suspend_all() in snd_soc_suspend().
- intel.c had a partial PAUSE workaround; this generalizes it to all open streams.
- intel_ace2x.c had no component suspend at all — worse for PAUSE and XRUN.
- **Regression risk:** Low. Setting suspended on already-suspended streams is idempotent; open streams need reinit after system sleep regardless.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
**Record:** git blame shows suspend-tracking code in intel.c at the tree’s base commit (a112b91dd6349). History is shallow in this checkout; exact introduction commit not determinable. Buggy code is present in 6.18.43.

### Step 3.2: Fixes: Tag
**Record:** N/A — no Fixes: tag.

### Step 3.3: Related File History
**Record:** git log --oneline -- drivers/soundwire/intel.c returns only the tree base commit (shallow history). Both intel.c and intel_ace2x.c exist and are built via soundwire-intel-y in drivers/soundwire/Makefile.

### Step 3.4: Author Context
**Record:** Peter Ujfalusi and Bard Liao are regular Intel SoundWire contributors. Vinod Koul (SoundWire maintainer) committed. Standalone fix, not part of a multi-patch series in the message.

### Step 3.5: Dependencies
**Record:** No prerequisites. Uses existing for_each_component_dais, dai_runtime_array, and intel_component_dais_suspend pattern from intel.c. Applies standalone to this tree.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original Discussion
**Record:** Lore/patch.msgid.link blocked (403/Anubis). b4 dig could not match this commit (not in local history). **UNVERIFIED:** reviewer feedback and stable nominations.

### Step 4.2: Reviewers
**Record:** **UNVERIFIED** — b4 dig -w not usable without matching commit.

### Step 4.3: Bug Reports
**Record:** No external bug report tags. Mechanism verified from ALSA core + driver code.

### Step 4.4: Related Patches
**Record:** Similar pattern in sound/soc/sof/intel/hda-dai.c (hda_dsp_dais_suspend) documents the same ALSA TRIGGER_SUSPEND limitation during PAUSE.

### Step 4.5: Stable List History
**Record:** **UNVERIFIED** — lore blocked.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key Functions
**Record:** intel_trigger(), intel_component_dais_suspend(), intel_prepare(), cdns_set_sdw_stream()

### Step 5.2: Callers
**Record:**
- intel_trigger() — ALSA/ASoC PCM trigger path
- intel_component_dais_suspend() — snd_soc_component_suspend() from snd_soc_suspend() during system suspend
- intel_prepare() — PCM prepare before start/resume after system sleep

### Step 5.3: Callees
**Record:** intel_prepare() calls intel_pdi_shim_configure(), intel_pdi_alh_configure(), sdw_cdns_config_stream(), intel_params_stream() when dai_runtime->suspended is true.

### Step 5.4: Reachability
**Record:** Triggered by system suspend/resume on machines with CONFIG_SND_SOC_SOF + Intel SoundWire (soundwire-intel module). Common on modern Intel laptops. Userspace does not need special privileges beyond having audio open during suspend.

### Step 5.5: Similar Patterns
**Record:** SOF Intel HDA has the same PAUSE/TRIGGER_SUSPEND workaround comment. Confirms this is a known ALSA limitation, not driver-specific imagination.

---

## PHASE 6: CROSS-REFERENCING AGAINST LOCAL TREE (6.18.43)

### Step 6.1: Buggy Code Present?
**Record:** **Yes.** Verified:
- intel.c: TRIGGER_SUSPEND in intel_trigger() (line 910); partial intel_component_dais_suspend() (only handles paused)
- intel_ace2x.c: TRIGGER_SUSPEND in intel_trigger() (line 825); **no** .suspend callback
- dai_runtime->suspended used in intel_prepare() in both files

### Step 6.2: Backport Complications
**Record:** Expected clean apply. Current code matches the patch context. No conflicting refactors observed.

### Step 6.3: Related Fixes Already Present?
**Record:** Partial PAUSE-only workaround exists in intel.c only. No fix for XRUN; intel_ace2x.c unprotected. This commit not yet applied.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

### Step 7.1: Subsystem Criticality
**Record:** drivers/soundwire/ — IMPORTANT (Intel laptop audio via SoundWire). Not core kernel, but affects many production systems.

### Step 7.2: Subsystem Activity
**Record:** Actively maintained Intel audio path. intel_ace2x.c is part of current soundwire-intel build.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Who Is Affected
**Record:** Users of Intel SoundWire audio (Tiger Lake and newer Intel platforms with SOF + SoundWire codecs). Config: CONFIG_SOUNDWIRE / soundwire-intel module.

### Step 8.2: Trigger Conditions
**Record:**
- System suspend while audio stream is open and PAUSED, or
- System suspend while stream is in xrun (STOPPED) state
- Moderately common: paused music/video, buffer underrun before lid- close
- Unprivileged user with open PCM device

### Step 8.3: Failure Mode Severity
**Record:** Audio broken after resume until full PCM teardown/reopen. **Severity: HIGH** (functional breakage on suspend/resume, not a kernel oops, but serious UX impact on laptops).

### Step 8.4: Risk-Benefit
**Record:**
- **Benefit:** HIGH — fixes real suspend/resume audio failure
- **Risk:** LOW — ~50 lines, idempotent flag set, no API changes
- **Ratio:** Strongly favors backport

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence Summary

**FOR backport:**
- Real bug with verified ALSA mechanism (snd_pcm_running() gate)
- User-visible suspend/resume audio failure
- Small, surgical, maintainer-reviewed fix
- Buggy code present in 6.18.43 (both intel.c and intel_ace2x.c)
- intel_ace2x.c completely lacks component suspend today
- Same class of fix as existing SOF HDA workaround

**AGAINST backport:**
- Driver-specific (not universal)
- No fuzzer/CVE report
- Lore review discussion unverified

**UNRESOLVED:**
- Original mailing-list review thread
- Exact mainline commit SHA in this checkout

### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **PASS** — logic matches ALSA PM behavior; maintainer SOB
2. Fixes a real user-affecting bug? **PASS**
3. Important issue? **PASS** — suspend/resume audio failure (HIGH)
4. Small and contained? **PASS** — ~50 lines, 2 files
5. No new features/APIs? **PASS** — moves existing tracking to correct callback
6. Can apply to local tree? **PASS** — code present, structure matches

### Step 9.3: Exception Categories
**Record:** N/A — standard bug fix, not device-ID/quirk/DT/build/doc exception.

### Step 9.4: Decision Rationale
For Linux 6.18.43, the suspend-tracking bug exists in both Intel SoundWire driver files. The ALSA core deliberately does not send TRIGGER_SUSPEND for PAUSED or xrun streams, so the current trigger- based tracking is incomplete. Without dai_runtime->suspended, intel_prepare() skips hardware reinit after system resume, leaving audio broken. The fix is small, correct, and addresses a realistic laptop suspend scenario.

---

## Verification

- **[Phase 1]** Parsed subject, tags, body from provided commit message
- **[Phase 1]** Identified hidden bug fix (suspend/resume correctness)
- **[Phase 2]** Diff: 2 files, intel_trigger + intel_component_dais_suspend changes
- **[Phase 2]** Read snd_pcm_do_suspend() — confirmed TRIGGER_SUSPEND skipped when !snd_pcm_running()
- **[Phase 2]** Read snd_pcm_running() — only RUNNING/DRAINING return true
- **[Phase 2]** Read intel_prepare() in intel.c and intel_ace2x.c — reinit gated on dai_runtime->suspended
- **[Phase 3]** git describe HEAD → v6.18.43
- **[Phase 3]** git blame on intel.c:910-980 — code at tree base
- **[Phase 3]** Shallow history: only base commit for soundwire files
- **[Phase 4]** WebFetch lore/patch.msgid.link — blocked (Anubis/403)
- **[Phase 4]** curl lore raw — 403 Forbidden
- **[Phase 4]** b4 dig -c HEAD — no match for this commit
- **[Phase 4]** Found analogous SOF HDA comment in hda-dai.c:935-941
- **[Phase 5]** Traced suspend path: snd_soc_suspend() → snd_pcm_suspend_all() then snd_soc_component_suspend()
- **[Phase 5]** Verified for_each_component_dais in include/sound/soc-component.h
- **[Phase 5]** Verified dai_runtime_array allocated in cdns_set_sdw_stream() when stream is set
- **[Phase 6]** Confirmed buggy code in intel.c (partial PAUSE fix, no XRUN fix)
- **[Phase 6]** Confirmed intel_ace2x.c has no .suspend callback
- **[Phase 6]** Confirmed both files built via drivers/soundwire/Makefile
- **[Phase 8]** Failure mode: audio broken after suspend/resume — HIGH severity
- **UNVERIFIED:** Mailing-list reviewer feedback and stable nominations
- **UNVERIFIED:** Mainline commit SHA in this checkout

**YES**The background history search finished. In this 6.18.43 checkout, git log -S 'intel_component_dais_suspend' only turns up the tree base commit (a112b91dd6349), so the shallow history here doesn’t show when suspend tracking was originally added.

That doesn’t change the backport call: the buggy code is present in both intel.c and intel_ace2x.c, and the fix still looks appropriate for this tree.

**YES**

 drivers/soundwire/intel.c       | 31 ++++++--------------------
 drivers/soundwire/intel_ace2x.c | 39 ++++++++++++++++++++++-----------
 2 files changed, 33 insertions(+), 37 deletions(-)
drivers/soundwire/intel.c +7 -24
index 9db78f3d76152..a83371233603b 100644
@@ -907,19 +907,6 @@ static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct sn
 	}
 
 	switch (cmd) {
-	case SNDRV_PCM_TRIGGER_SUSPEND:
-
-		/*
-		 * The .prepare callback is used to deal with xruns and resume operations.
-		 * In the case of xruns, the DMAs and SHIM registers cannot be touched,
-		 * but for resume operations the DMAs and SHIM registers need to be initialized.
-		 * the .trigger callback is used to track the suspend case only.
-		 */
-
-		dai_runtime->suspended = true;
-
-		break;
-
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
 		dai_runtime->paused = true;
 		break;
@@ -956,10 +943,12 @@ static int intel_component_dais_suspend(struct snd_soc_component *component)
 	struct snd_soc_dai *dai;
 
 	/*
-	 * In the corner case where a SUSPEND happens during a PAUSE, the ALSA core
-	 * does not throw the TRIGGER_SUSPEND. This leaves the DAIs in an unbalanced state.
-	 * Since the component suspend is called last, we can trap this corner case
-	 * and force the DAIs to release their resources.
+	 * Mark all open streams as suspended.
+	 * Open streams at this point can be in SUSPENDED, PAUSED or STOPPED
+	 * state and during prepare the DMAs and SHIM registers need to be
+	 * initialized for them.
+	 * The STOPPED state is a special corner case which can happen if audio
+	 * experiences xrun at suspend time.
 	 */
 	for_each_component_dais(component, dai) {
 		struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
@@ -967,13 +956,7 @@ static int intel_component_dais_suspend(struct snd_soc_component *component)
 
 		dai_runtime = cdns->dai_runtime_array[dai->id];
 
-		if (!dai_runtime)
-			continue;
-
-		if (dai_runtime->suspended)
-			continue;
-
-		if (dai_runtime->paused)
+		if (dai_runtime)
 			dai_runtime->suspended = true;
 	}
 
drivers/soundwire/intel_ace2x.c +26 -13
index 63aef98361467..f0e0a79b30b0e 100644
@@ -822,19 +822,6 @@ static int intel_trigger(struct snd_pcm_substream *substream, int cmd, struct sn
 	}
 
 	switch (cmd) {
-	case SNDRV_PCM_TRIGGER_SUSPEND:
-
-		/*
-		 * The .prepare callback is used to deal with xruns and resume operations.
-		 * In the case of xruns, the DMAs and SHIM registers cannot be touched,
-		 * but for resume operations the DMAs and SHIM registers need to be initialized.
-		 * the .trigger callback is used to track the suspend case only.
-		 */
-
-		dai_runtime->suspended = true;
-
-		break;
-
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
 		dai_runtime->paused = true;
 		break;
@@ -858,8 +845,34 @@ static const struct snd_soc_dai_ops intel_pcm_dai_ops = {
 	.get_stream = intel_get_sdw_stream,
 };
 
+static int intel_component_dais_suspend(struct snd_soc_component *component)
+{
+	struct snd_soc_dai *dai;
+
+	/*
+	 * Mark all open streams as suspended.
+	 * Open streams at this point can be in SUSPENDED, PAUSED or STOPPED
+	 * state and during prepare the DMAs and SHIM registers need to be
+	 * initialized for them.
+	 * The STOPPED state is a special corner case which can happen if audio
+	 * experiences xrun at suspend time.
+	 */
+	for_each_component_dais(component, dai) {
+		struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai);
+		struct sdw_cdns_dai_runtime *dai_runtime;
+
+		dai_runtime = cdns->dai_runtime_array[dai->id];
+
+		if (dai_runtime)
+			dai_runtime->suspended = true;
+	}
+
+	return 0;
+}
+
 static const struct snd_soc_component_driver dai_component = {
 	.name			= "soundwire",
+	.suspend		= intel_component_dais_suspend,
 };
 
 /*
Signature · 1 line
2.53.0
author maintainer
#714 lore raw

PATCH 1/1 ASoC: rt1320: run the initialisation preset on the first hardware init

In reply to Sasha Levin

From: Sergey Lebedev <[email protected]>

[ Upstream commit 9b30521074f01aff856f539c1241a48342b69f7c ]

rt1320_io_init() applies the vendor initialisation preset only when the amplifier's SDCA function status has FUNCTION_NEEDS_INITIALIZATION set:

	if ((amp_func_status & FUNCTION_NEEDS_INITIALIZATION)) {

Its two sibling drivers guard the same write differently, also running the preset on the first hardware init:

  rt712-sdca.c:  if ((amp_func_status & FUNCTION_NEEDS_INITIALIZATION) ||
                     (!rt712->first_hw_init)) {
  rt722-sdca.c:  if ((amp_func_status & FUNCTION_NEEDS_INITIALIZATION) ||
                     (!rt722->first_hw_init)) {

On the Microsoft Surface Pro 11 (Intel) the RT1320 never sets that bit. Its function status reads back 0x41 on every boot, cold or warm:

rt1320-sdca sdw:0:0:025d:1320:01: rt1320_io_init amp func_status=0x41

which is NEWLY_ATTACHED | FUNCTION_HAS_BEEN_RESET: the function reports that it has been reset and does not consider itself in need of initialisation. Bit 5 is never set, so the preset never runs, rt1320_vc_preset() and the MCU patch load are skipped, and the amplifier is left unprogrammed. rt712 and rt722 would have run it via their first_hw_init fallback.

Add the same fallback. With it rt1320_vc_preset() executes and the amplifier reports RT1320_KR0_INT_READY=0x1f where previously it did not.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit Message Forensics

### Step 1.1: Subject line
**Record:** [ASoC: rt1320] [run] — run the vendor initialization preset on first hardware init.

### Step 1.2: Tags
**Record:**
- **Signed-off-by:** Sergey Lebedev <[email protected]> (author)
- **Link:** https://patch.msgid.link/[email protected]
- **Signed-off-by:** Mark Brown <[email protected]> (ASoC maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, or Cc: [email protected]
- Notable: maintainer sign-off; real hardware report (Surface Pro 11); no syzbot/fuzzer involvement

### Step 1.3: Body analysis
**Record:**
- **Bug:** rt1320_io_init() only runs the vendor preset when FUNCTION_NEEDS_INITIALIZATION is set; on Surface Pro 11 RT1320 reports 0x41 (NEWLY_ATTACHED | FUNCTION_HAS_BEEN_RESET), never bit 5
- **Symptom:** rt1320_vc_preset() and MCU patch load are skipped; amplifier stays unprogrammed; speakers silent
- **Root cause:** RT1320 lacks the first_hw_init fallback that sibling drivers rt712-sdca and rt722-sdca already use
- **Version info:** Surface Pro 11 (Intel, Lunar Lake); tested on 7.1.0-rc7 per cover letter

### Step 1.4: Hidden bug fix?
**Record:** Yes — not disguised cleanup. This is a clear logic/correctness fix restoring driver behavior that existed at introduction and was accidentally dropped.

---

## Phase 2: Diff Analysis

### Step 2.1: Inventory
**Record:**
- **Files:** sound/soc/codecs/rt1320-sdw.c (+1 / -1)
- **Function:** rt1320_io_init()
- **Scope:** Single-file, one-line surgical fix

### Step 2.2: Code flow change
**Record:**
- **Before:** Preset runs only if amp_func_status & FUNCTION_NEEDS_INITIALIZATION
- **After:** Also runs when !rt1320->first_hw_init (first hardware init)
- **Path:** Normal probe via rt1320_update_status() → rt1320_io_init() on SDW_SLAVE_ATTACHED

### Step 2.3: Bug mechanism
**Record:**
- **Category:** Logic/correctness (hardware workaround)
- **Mechanism:** Some RT1320 parts never set FUNCTION_NEEDS_INITIALIZATION; without the first_hw_init fallback, rt1320_vc_preset() / rt1320_load_mcu_patch() never execute and the amp is left uninitialized

### Step 2.4: Fix quality
**Record:**
- Obviously correct: matches rt712-sdca.c and rt722-sdca.c, and restores original rt1320 behavior from bad0a07a7e61a
- Minimal, no unrelated changes
- **Regression risk:** Very low — restores long-standing pattern; only affects first init

---

## Phase 3: Git History Investigation

### Step 3.1: Blame
**Record:**
- Buggy condition from f465d10cd7318 (Sep 2, 2024, "ASoC: rt1320: Add support for version C")
- That commit **removed** || (!rt1320->first_hw_init) that existed since bad0a07a7e61a (May 21, 2024)
- Regression present since v6.12 (first tag containing f465d10)

### Step 3.2: Fixes: tag
**Record:** N/A — no Fixes: tag. Regression commit is f465d10cd7318, confirmed in this tree.

### Step 3.3: Related file history
**Record:**
- Part of a 3-patch series: "ASoC: fix audio on the Microsoft Surface Pro 11 (Intel)"
- Patches 2/3 and 3/3 address phantom ACPI entries; **this patch is standalone** for RT1320 init
- Recent rt1320 fixes in tree: mute issue, speaker noise, RT1321 support — unrelated

### Step 3.4: Author context
**Record:** Sergey Lebedev — Surface Pro 11 reporter/fixer; no prior sound commits in this tree. Mark Brown committed upstream.

### Step 3.5: Dependencies
**Record:** None for this change. first_hw_init already exists in rt1320_sdw_priv and is initialized to false at probe. Applies standalone.

---

## Phase 4: Mailing List and External Research

### Step 4.1: Original discussion
**Record:**
- **URL:** https://patch.msgid.link/[email protected]
- **Series:** v1 only (no v2/v3)
- Cover letter: full Surface Pro 11 audio needs all 3 patches; patch 1/3 is codec-specific and one line
- No explicit stable nomination in thread
- No NAKs found in mbox

### Step 4.2: Reviewers
**Record:** CC'd to Mark Brown, Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Realtek/Intel SOF maintainers, linux-sound@, sound-open- firmware@, linux-kernel@

### Step 4.3: Bug report
**Record:** Hardware testing on Surface Pro 11 for Business (Intel Core Ultra 7 268V, Lunar Lake). Symptom: silent speakers despite successful probe. Severity: complete audio failure on affected hardware.

### Step 4.4: Related patches
**Record:** Patches 2/3 (sdw_utils) and 3/3 (SOF Intel HDA amp indexing) are separate; needed for full SP11 fix but not prerequisites for this one-line driver fix.

### Step 4.5: Stable list
**Record:** No stable-specific discussion found in mbox.

---

## Phase 5: Code Semantic Analysis

### Step 5.1: Key functions
**Record:** rt1320_io_init(), rt1320_vc_preset(), rt1320_update_status()

### Step 5.2: Callers
**Record:**
- rt1320_update_status() — SoundWire slave status callback (.update_status in rt1320_sdw_slave_driver)
- Triggered on SDW_SLAVE_ATTACHED during SoundWire enumeration
- Common device probe path for RT1320-equipped Intel SOF machines

### Step 5.3: Callees
**Record:** rt1320_vab_preset(), rt1320_vc_preset(), rt1321_preset(), regmap_read/write, rt1320_load_mcu_patch() (inside rt1320_vc_preset())

### Step 5.4: Reachability
**Record:** Reachable on every boot for RT1320 SoundWire devices when CONFIG_SND_SOC_RT1320_SDW is enabled (implied by Intel SOF ACPI matches). Not userspace-triggered, but affects all audio on affected machines.

### Step 5.5: Similar patterns
**Record:** Identical first_hw_init fallback in rt712-sdca.c:1837 and rt722-sdca.c:1400. Original rt1320 driver at bad0a07a7e61a:1699 had the same pattern.

---

## Phase 6: Cross-Reference Against Local Tree

### Step 6.1: Buggy code exists?
**Record:**
- **Tree:** stable/linux-6.18.y at v6.18.44
- **Buggy line present:** sound/soc/codecs/rt1320-sdw.c:941 — if ((amp_func_status & FUNCTION_NEEDS_INITIALIZATION))
- RT1320 driver (bad0a07a7e61a) and version C support (f465d10cd7318) are both ancestors of HEAD
- Fix (9b30521074f01 / 4ff3319b43e07) is **not** in this tree

### Step 6.2: Backport complications
**Record:** Clean one-line apply at line 941; no conflicts expected. Stable tree file matches autosel backport diff base.

### Step 6.3: Related fixes already present?
**Record:** No equivalent fix found. Other rt1320 fixes (mute, noise) address different issues.

---

## Phase 7: Subsystem and Maintainer Context

### Step 7.1: Subsystem criticality
**Record:** sound/soc/codecs — ASoC codec driver. **IMPORTANT** for Intel SOF + SoundWire laptop users (LNL/PTL/ARL platforms with RT1320).

### Step 7.2: Subsystem activity
**Record:** Actively maintained; multiple rt1320 ACPI machine entries and driver fixes in 6.18.y.

---

## Phase 8: Impact and Risk Assessment

### Step 8.1: Who is affected
**Record:** Users with RT1320 amplifiers on Intel SOF SoundWire platforms where the chip does not set FUNCTION_NEEDS_INITIALIZATION — confirmed on Surface Pro 11; potentially any RT1320 since the v6.12 regression. Config-specific: CONFIG_SND_SOC_RT1320_SDW.

### Step 8.2: Trigger conditions
**Record:** Every cold/warm boot on affected hardware. Not timing- dependent. Unprivileged users cannot trigger directly, but all users on affected machines lose speaker output.

### Step 8.3: Failure mode severity
**Record:** Amplifier never initialized → **silent speakers** (complete audio failure on affected machines). Severity: **HIGH** for affected hardware (not a kernel crash, but total loss of primary audio output).

### Step 8.4: Risk-benefit
**Record:**
- **Benefit:** HIGH for RT1320 users — restores working audio
- **Risk:** VERY LOW — one-line restoration of original + sibling-driver pattern
- **Ratio:** Strongly favors backport

---

## Phase 9: Final Synthesis

### Step 9.1: Evidence summary

**FOR backport:**
- Real regression introduced by f465d10 (removed first_hw_init fallback present since driver introduction)
- Confirmed hardware impact (Surface Pro 11 — silent speakers)
- One-line fix matching proven rt712/rt722 pattern
- Self-contained, no dependencies
- ASoC maintainer sign-off
- RT1320 driver and platform ACPI support present in 6.18.y

**AGAINST backport:**
- Full Surface Pro 11 audio may also need patches 2/3 and 3/3 (separate commits)
- No explicit stable nomination or Fixes: tag (expected for manual review)

**Unresolved:** Whether other RT1320 platforms besides Surface Pro 11 hit this path (likely, given regression since v6.12).

### Step 9.2: Stable rules checklist
1. Obviously correct and tested? **PASS** — restores original logic; tested on real hardware per cover letter
2. Fixes a real bug? **PASS** — amplifier left unprogrammed
3. Important issue? **PASS** — complete audio failure on affected laptops
4. Small and contained? **PASS** — 1 line, 1 file
5. No new features/APIs? **PASS** — behavior restoration only
6. Can apply to local tree? **PASS** — buggy code present, clean apply

### Step 9.3: Exception category
**Record:** Hardware workaround / quirk — RT1320 does not set FUNCTION_NEEDS_INITIALIZATION; driver must initialize on first hw init regardless.

### Step 9.4: Decision rationale

For **linux-6.18.y** (v6.18.44): this is a regression fix restoring driver behavior accidentally removed in v6.12. The RT1320 driver, the buggy code, and affected platform support are all present. The fix is one line, matches sibling drivers, and fixes silent speakers on real hardware. It is self-contained and low risk.

---

## Verification

- [Phase 1] Parsed subject, tags, body from commit 9b30521074f01 / 4ff3319b43e07
- [Phase 2] Diff: 1-line change in rt1320_io_init() at line 941
- [Phase 3] git blame: regression in f465d10cd7318; original fallback in bad0a07a7e61a
- [Phase 3] git show f465d10: confirmed removal of || (!rt1320->first_hw_init)
- [Phase 3] git show bad0a07a7e61a: confirmed original driver had fallback
- [Phase 3] git merge-base --is-ancestor: driver, version C, and fix presence verified
- [Phase 4] b4 dig -c 4ff3319b43e07: found lore thread; v1 series; cover letter read from mbox
- [Phase 4] b4 dig -w: Mark Brown and sound maintainers CC'd
- [Phase 4] No stable/Reviewed-by/Tested-by in mbox
- [Phase 5] grep rt1320_io_init: called from rt1320_update_status() on attach
- [Phase 5] Compared with rt712-sdca.c:1837 and rt722-sdca.c:1400 patterns
- [Phase 6] git describe HEAD: v6.18.44 on stable/linux-6.18.y
- [Phase 6] Buggy code at rt1320-sdw.c:941; fix not in tree
- [Phase 6] git show 4ff3319b43e07 -p: clean apply to current tree
- [Phase 7] RT1320 ACPI matches present in soc-acpi-intel-lnl-match.c, ptl-match.c, arl-match.c
- [Phase 8] Failure mode: unprogrammed amplifier → silent speakers

**YES**The analysis is complete for **linux-6.18.y** (v6.18.44).

This is a one-line regression fix: f465d10 ("Add support for version C") dropped the first_hw_init fallback that existed since the RT1320 driver was introduced. On hardware like the Surface Pro 11, the amp never sets FUNCTION_NEEDS_INITIALIZATION, so the preset and MCU patch load are skipped and speakers stay silent. The fix restores the same pattern already used in rt712-sdca and rt722-sdca.

The buggy code is present in this tree, the patch applies cleanly, and it is self-contained (patches 2/3 and 3/3 in the series are separate Surface Pro 11 ACPI issues).

**YES**

 sound/soc/codecs/rt1320-sdw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/rt1320-sdw.c +1 -1
index e1bd991a823a4..a08e20bfe9c86 100644
@@ -938,7 +938,7 @@ static int rt1320_io_init(struct device *dev, struct sdw_slave *slave)
 	dev_dbg(dev, "%s amp func_status=0x%x\n", __func__, amp_func_status);
 
 	/* initialization write */
-	if ((amp_func_status & FUNCTION_NEEDS_INITIALIZATION)) {
+	if ((amp_func_status & FUNCTION_NEEDS_INITIALIZATION) || !rt1320->first_hw_init) {
 		switch (rt1320->dev_id) {
 		case RT1320_DEV_ID:
 			if (rt1320->version_id < RT1320_VC)
Signature · 1 line
2.53.0
#715 lore raw

Re: [PATCH AUTOSEL 6.18] ASoC: rt1320: run the initialisation preset on the first hardware init

Author's ack for the AUTOSEL 6.18 pick of

ASoC: rt1320: run the initialisation preset on the first hardware init upstream 9b30521074f01aff856f539c1241a48342b69f7c

Appropriate for stable, and the reason is narrow enough to state precisely.

Without it the RT1320 on the Microsoft Surface Pro 11 is left unprogrammed on every boot: its SDCA function status reads 0x41 (NEWLY_ATTACHED | FUNCTION_HAS_BEEN_RESET) and never sets FUNCTION_NEEDS_INITIALIZATION, so rt1320_vc_preset() and the MCU patch load are skipped. rt712-sdca and rt722-sdca already carry the first_hw_init fallback this adds.

On the risk side, which is what matters for a backport: the added condition can only cause the preset to run where it would otherwise not have run at all. On hardware that does set FUNCTION_NEEDS_INITIALIZATION the behaviour is unchanged, so a later board revision carrying a different RT1320 -- which Bard Liao noted is possible for this SKU -- is not exposed to anything new.

Tested on the affected hardware. With the patch the amplifier reports RT1320_KR0_INT_READY=0x1f where it previously did not, and audio works.

Sergey Lebedev

author maintainer
#716 lore raw

Re: [PATCH AUTOSEL 6.18] ASoC: rt1320: run the initialisation preset on the first hardware init

Quoted 1 line · Sergey Lebedev

Author's ack for the AUTOSEL 6.18 pick of

Ack, thanks!

Signature · 2 lines
Thanks,
Sasha
author maintainer
#717 lore raw

PATCH 1/1 netfilter: nf_conntrack: use get_unaligned_be32() in tcp_sack()

In reply to Sasha Levin

From: Rosen Penev <[email protected]>

[ Upstream commit d3bf9eae486490832bd08fd62ab0ac601f346bd4 ]

The timestamp-only fast path dereferences the option stream as *(__be32 *)ptr, which assumes 4-byte alignment that the TCP option stream does not guarantee. Use get_unaligned_be32() instead, which reads the value safely and already returns host byte order, so the htonl() on the comparison constant can be dropped.

This matches the existing get_unaligned_be32() use later in the same function.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit Message Forensics

**Step 1.1 — Subject line**
- Record: [netfilter: nf_conntrack] [use] — replace unsafe aligned 32-bit dereference in tcp_sack() timestamp fast path with get_unaligned_be32().

**Step 1.2 — Tags**
- Record:
- Assisted-by: Claude:Opus-4.7
- Signed-off-by: Rosen Penev <[email protected]>
- Reviewed-by: Fernando Fernandez Mancera <[email protected]>
- Signed-off-by: Pablo Neira Ayuso <[email protected]> (subsystem maintainer)
- No Fixes:, Reported-by:, Cc: [email protected], or Link: tags
- Notable: maintainer review and commit; reviewer independently spotted the same issue

**Step 1.3 — Body**
- Record:
- **Bug:** *(__be32 *)ptr in the timestamp-only fast path assumes 4-byte alignment of the TCP option stream
- **Symptom:** Unaligned memory access on architectures that require alignment (kernel trap/oops); undefined behavior elsewhere
- **Root cause:** TCP options are not guaranteed 4-byte aligned; skb_header_pointer() often returns a pointer directly into skb linear data at a misaligned offset
- **Fix:** Use get_unaligned_be32(), matching the existing SACK parsing code in the same function

**Step 1.4 — Hidden bug fix?**
- Record: Yes — despite not using "fix" in the subject, this is a correctness/memory-safety bug fix, not cleanup or optimization.

---

## Phase 2: Diff Analysis

**Step 2.1 — Inventory**
- Record:
- 1 file: net/netfilter/nf_conntrack_proto_tcp.c (+5/-5 lines)
- Function: tcp_sack()
- Scope: Single-file, surgical fix

**Step 2.2 — Code flow**
- Record:
- **Before:** Fast path for timestamp-only TCP options used `*(__be32

    *)ptr == htonl(...)` — aligned 32-bit read

- **After:** Uses get_unaligned_be32(ptr) == (...) — safe unaligned read; htonl() dropped because get_unaligned_be32() returns host byte order
- **Path:** Hot path in tcp_sack() when length == TCPOLEN_TSTAMP_ALIGNED (12 bytes = NOP/NOP/TIMESTAMP option only)

**Step 2.3 — Bug mechanism**
- Record:
- **Category:** Memory safety / unaligned access (same class as commit

    `534f81a506879` from 2009 in the same function)
  - **Mechanism:** `ptr` from `skb_header_pointer()` points at
    `skb->data + dataoff + sizeof(tcphdr)`. For typical Ethernet+IPv4,
    options start at offset 54 (54 % 4 = 2), so `*(__be32 *)ptr` is an
    unaligned access when skb data is linear

**Step 2.4 — Fix quality**
- Record:
- Obviously correct: mirrors the existing get_unaligned_be32() use at line 442 in the same function
- Minimal, no unrelated changes
- Low regression risk: get_unaligned_be32() is already included via <linux/unaligned.h> and used in this file
- Byte-order handling is correct (constant built in host order, compared to host-order return value)

---

## Phase 3: Git History Investigation

**Step 3.1 — Blame**
- Record:
- Fast path introduced in 9fb9cbb1082d6 (Nov 2005, nf_conntrack subsystem creation)
- Aligned dereference *(__be32 *)ptr from 8f05ce91c8b801 (Mar

    2007)

- Bug has been present since 2007 in this code path

**Step 3.2 — Fixes: tag**
- Record: N/A — no Fixes: tag in commit message

**Step 3.3 — Related file history**
- Record:
- 534f81a506879 (Mar 2009): fixed unaligned access in SACK option parsing loop in the same tcp_sack() function (SPARC64 kernel unaligned access reports) — fast path was missed
- bb9fc37358ffa (Aug 2011): fixed TCPOLEN_TSTAMP_ALIGNED*4 typo so the fast path actually runs
- Standalone single-patch series (v1 only); no prerequisites

**Step 3.4 — Author context**
- Record: Rosen Penev is a regular netfilter contributor; patch committed by Pablo Neira Ayuso (netfilter maintainer)

**Step 3.5 — Dependencies**
- Record: None. get_unaligned_be32() and <linux/unaligned.h> already present in this tree's version of the file.

---

## Phase 4: Mailing List and External Research

**Step 4.1 — Original discussion**
- Record:
- Lore URL:

    https://patch.msgid.link/[email protected]

- Single v1 patch, no revisions
- Fernando Fernandez Mancera: independently spotted the same issue; "I think this is for correctness too"; Reviewed-by
- Pablo Neira Ayuso: committed with humorous "Missing put_unaligned_be32(), BTW." (read path only)
- No NAKs or objections

**Step 4.2 — Reviewers**
- Record: CC'd to netfilter-devel, netdev, Pablo Neira, Florian Westphal, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni — appropriate maintainers included

**Step 4.3 — Bug report**
- Record: No syzbot or user bug report for this specific fast-path issue. Historical precedent: 534f81a506879 documented real SPARC64 unaligned-access kernel messages from the same function's SACK path.

**Step 4.4 — Related patches**
- Record: Reviewer noted more unaligned-access audits may be needed elsewhere; this patch is self-contained

**Step 4.5 — Stable list**
- Record: Could not search lore stable archive (bot protection). No stable nomination found in the patch thread.

---

## Phase 5: Code Semantic Analysis

**Step 5.1 — Key functions**
- Record: tcp_sack() modified; callers unchanged

**Step 5.2 — Callers**
- Record:
- tcp_sack() called from tcp_in_window() when receiver->flags & IP_CT_TCP_FLAG_SACK_PERM
- tcp_in_window() called from nf_conntrack_tcp_packet() (line

    1254)

- nf_conntrack_tcp_packet() is the main TCP conntrack packet handler — invoked on every tracked TCP packet through netfilter hooks

**Step 5.3 — Callees**
- Record: skb_header_pointer(), get_unaligned_be32() — standard skb/conntrack helpers

**Step 5.4 — Reachability**
- Record:
- Reachable from all netfilter conntrack TCP traffic (routers, firewalls, NAT gateways, any CONFIG_NF_CONNTRACK system)
- Fast path triggers on timestamp-only TCP options (length == 12) — very common on modern TCP stacks
- Requires SACK negotiation (IP_CT_TCP_FLAG_SACK_PERM) — also common
- Userspace can trigger via normal TCP connections through conntrack- enabled systems

**Step 5.5 — Similar patterns**
- Record: Same function already uses get_unaligned_be32() at line 442 for SACK blocks (fixed in 2009). The fast path was the remaining unaligned dereference.

---

## Phase 6: Cross-Reference Against Local Tree

**Step 6.1 — Buggy code in tree**
- Record:
- Local tree: **v6.18.44** (git describe HEAD)
- Buggy code **present** at lines 408–412 of net/netfilter/nf_conntrack_proto_tcp.c
- Bug present since 2007; not introduced after 6.18 branch point

**Step 6.2 — Backport complications**
- Record: git apply --check and git cherry-pick --no-commit both succeed — clean apply expected

**Step 6.3 — Related fixes already present**
- Record:
- 2009 SACK-path unaligned fix (534f81a506879) is in tree
- This specific fast-path fix (d3bf9eae48649) is **not** in tree (only on master)

---

## Phase 7: Subsystem Context

**Step 7.1 — Subsystem**
- Record: net/netfilter — nf_conntrack TCP tracker. Criticality:
**CORE/IMPORTANT** (widely deployed on servers, routers, embedded systems with CONFIG_NF_CONNTRACK)

**Step 7.2 — Activity**
- Record: Actively maintained subsystem with frequent stable fixes in this tree

---

## Phase 8: Impact and Risk Assessment

**Step 8.1 — Who is affected**
- Record: Systems with CONFIG_NF_CONNTRACK processing TCP traffic — routers, firewalls, NAT, containers/VMs using conntrack. Not universal (config-dependent), but very common in production networking.

**Step 8.2 — Trigger conditions**
- Record:
- Linear skb (common) where TCP options start at non-4-byte-aligned offset
- Typical Ethernet+IPv4: options at offset 54 (mod 4 = 2) — verified by calculation
- Timestamp-only option layout (length 12)
- SACK negotiated on connection
- **Likelihood:** High on affected architectures for normal TCP traffic

**Step 8.3 — Failure mode**
- Record:
- Strict-alignment architectures (SPARC, some ARM/MIPS): kernel unaligned-access trap — severity **CRITICAL** (documented precedent in same function, 2009)
- x86: usually tolerates unaligned access but technically undefined behavior
- No data corruption path identified; primarily crash/trap risk

**Step 8.4 — Risk-benefit**
- Record:
- **Benefit:** HIGH — prevents kernel faults on common TCP fast path in widely deployed code
- **Risk:** VERY LOW — 5-line change, matches existing pattern in same function, reviewed by subsystem developer and maintainer
- **Ratio:** Strong benefit, minimal risk

---

## Phase 9: Final Synthesis

**Step 9.1 — Evidence summary**

FOR backport:
- Real unaligned memory access bug in hot conntrack path
- Present since 2007; same function had identical-class fix in 2009 for SACK path
- Typical packet layouts place TCP options at 2-mod-4 offsets (verified)
- Small, surgical, obviously correct fix
- Reviewed by Fernando Fernandez Mancera; committed by netfilter maintainer Pablo Neira
- Applies cleanly to v6.18.44
- No new APIs or features

AGAINST backport:
- No syzbot report or user crash report for this specific fast path
- Only affects CONFIG_NF_CONNTRACK systems
- Most severe on strict-alignment architectures (smaller user base than x86)
- Impact on x86 is lower (unaligned access usually works)

UNRESOLVED:
- No explicit stable nomination in mailing list thread
- Lore stable archive search blocked

**Step 9.2 — Stable rules checklist**
1. Obviously correct and tested? **PASS** — matches existing in-function pattern; reviewed and committed by maintainers
2. Fixes a real bug? **PASS** — unaligned dereference on non-guaranteed- aligned data
3. Important issue? **PASS** — kernel trap/oops on strict-alignment arch; hot networking path
4. Small and contained? **PASS** — 1 file, ~5 lines changed
5. No new features/APIs? **PASS** — correctness fix only
6. Can apply to local tree? **PASS** — verified clean apply to v6.18.44

**Step 9.3 — Exception category**
- Record: Not a device-ID/quirk/DT/docs exception; qualifies as a core correctness/memory-safety fix

**Step 9.4 — Decision rationale**

This commit completes the unaligned-access fix started in 2009 for tcp_sack(). The timestamp-only fast path — hit on very common TCP packets — still uses an aligned *(__be32 *) dereference on data that is typically 2-byte-aligned in standard Ethernet+IPv4 layouts. On strict-alignment architectures this can cause kernel faults; the same failure mode was already documented and fixed for the SACK parsing loop in this exact function. The fix is minimal, follows an established pattern already in the file, applies cleanly to the v6.18.44 tree, and has maintainer review.

---

## Verification

- [Phase 1] Parsed commit message and tags from git show d3bf9eae48649
- [Phase 2] Diff analysis: 5-line change in tcp_sack() fast path
- [Phase 3] git blame -L 407,413: aligned dereference from 2007 (8f05ce91c8b801)
- [Phase 3] git show 534f81a506879: prior SACK-path unaligned fix in same function (SPARC64)
- [Phase 3] git show bb9fc37358ffa: fast path length fix (2011)
- [Phase 3] git log --grep: no duplicate fix for this fast path in stable tree
- [Phase 4] b4 dig -c d3bf9eae48649: lore thread found
- [Phase 4] b4 dig -w: netdev/netfilter maintainers CC'd
- [Phase 4] b4 dig -a: single v1 patch
- [Phase 4] Mbox review: Reviewed-by from Fernando Fernandez Mancera; maintainer commit
- [Phase 5] grep tcp_sack: called from tcp_in_window() → nf_conntrack_tcp_packet()
- [Phase 5] Read skb_header_pointer() in include/linux/skbuff.h:
returns direct skb pointer when linear
- [Phase 5] Python alignment calc: eth+ipv4 opts at offset 54 (mod 4 =
2)
- [Phase 6] git describe HEAD: v6.18.44
- [Phase 6] Read current file lines 408–412: buggy code still present
- [Phase 6] git apply --check on patch: applies cleanly
- [Phase 6] git cherry-pick --no-commit d3bf9eae48649: auto-merge succeeds
- [Phase 6] get_unaligned_be32 already at line 442; #include <linux/unaligned.h> at line 17
- [Phase 8] Failure mode: unaligned access trap on strict-alignment arch — CRITICAL severity class

**YES**

 net/netfilter/nf_conntrack_proto_tcp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
net/netfilter/nf_conntrack_proto_tcp.c +5 -5
index e99ab1e88e9f8..4a23edf7107a5 100644
@@ -405,11 +405,11 @@ static void tcp_sack(const struct sk_buff *skb, unsigned int dataoff,
 		return;
 
 	/* Fast path for timestamp-only option */
-	if (length == TCPOLEN_TSTAMP_ALIGNED
-	    && *(__be32 *)ptr == htonl((TCPOPT_NOP << 24)
-				       | (TCPOPT_NOP << 16)
-				       | (TCPOPT_TIMESTAMP << 8)
-				       | TCPOLEN_TIMESTAMP))
+	if (length == TCPOLEN_TSTAMP_ALIGNED &&
+	    get_unaligned_be32(ptr) == ((TCPOPT_NOP << 24) |
+					(TCPOPT_NOP << 16) |
+					(TCPOPT_TIMESTAMP << 8) |
+					TCPOLEN_TIMESTAMP))
 		return;
 
 	while (length > 0) {
Signature · 1 line
2.53.0
author maintainer
#718 lore raw

PATCH 1/1 ALSA: hda/realtek: ALC882: Fixup for Clevo P775TM1

In reply to Sasha Levin

From: Evelyn Ali <[email protected]>

[ Upstream commit def5e78a4e003c83adc9a8b4b72534def3a49641 ]

Clevo P775TM1 laptops come with an ESS Sabre HiFi DAC. Setting 0x1b pin VREF to 80% enables said DAC output.

---

LLM Generated explanations, may be completely bogus:

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: PARSE THE SUBJECT LINE
**Record:** [ALSA: hda/realtek: ALC882] [Fixup] — Add hardware fixup quirk for Clevo P775TM1 laptop audio (ALC882/898 codec path).

### Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
**Record:**
- **Signed-off-by:** Evelyn Ali \<[email protected]\> (author)
- **Link:**
https://patch.msgid.link/[email protected]
- **Signed-off-by:** Takashi Iwai \<[email protected]\> (ALSA/HDA maintainer, committer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Cc:
stable tags
- Notable: Maintainer commit; v2 patch on lore; no syzbot/fuzzer involvement

### Step 1.3: ANALYZE THE COMMIT BODY TEXT
**Record:**
- **Bug:** Clevo P775TM1 uses an ESS Sabre HiFi DAC; pin 0x1b VREF must be 80% to enable DAC output
- **Symptom:** No audio output from the external headphone amp / Sabre DAC without the VREF setting
- **Version info:** None stated
- **Root cause:** Hardware requires specific pin VREF configuration not provided by default or generic Clevo quirk

### Step 1.4: DETECT HIDDEN BUG FIXES
**Record:** Not disguised — explicit hardware fixup/quirk. Fixes broken audio on a specific laptop model, not a crash or memory bug.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: INVENTORY THE CHANGES
**Record:**
- **File:** sound/hda/codecs/realtek/alc882.c (+22 lines, 0 removed)
- **Functions modified/added:** alc898_fixup_clevo_p775tm1() (new)
- **Tables modified:** enum fixup IDs, alc882_fixups[], alc882_fixup_tbl[], alc882_fixup_models[]
- **Scope:** Single-file, surgical hardware quirk addition

### Step 2.2: CODE FLOW CHANGE
**Record:**
- **Hunk 1 (enum):** Adds ALC898_FIXUP_CLEVO_P775TM1 fixup ID
- **Hunk 2 (new function):** On HDA_FIXUP_ACT_PRE_PROBE, sets pin 0x1b to PIN_VREF80 via snd_hda_set_pin_ctl_cache() and sets spec->gen.keep_vref_in_automute = 1 so automute does not clear VREF
- **Hunk 3 (fixups table):** Registers fixup function, chained to ALC882_FIXUP_EAPD
- **Hunk 4 (quirk table):** SND_PCI_QUIRK(0x1558, 0x7709, "Clevo P775TM1", ...) — PCI SSID match
- **Hunk 5 (model table):** Adds model name clevo-p775tm1 for manual override

### Step 2.3: IDENTIFY THE BUG MECHANISM
**Record:** **Category (h): Hardware workaround / audio codec quirk.** Pin 0x1b VREF at 80% gates the ESS Sabre HiFi DAC; without it the external amp stays disabled. keep_vref_in_automute prevents the generic automute path from stripping VREF during jack events.

### Step 2.4: ASSESS THE FIX QUALITY
**Record:** Fix is minimal and follows established patterns in the same file (alc889_fixup_mbp_vref, other Clevo fixups). Chaining to ALC882_FIXUP_EAPD matches other Clevo entries. Low regression risk — only affects PCI SSID 0x1558:0x7709. No lock or API changes.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: BLAME THE CHANGED LINES
**Record:** Insertion point (between 0x70d1 and 0x7714 Clevo quirks) dates to aeeb85f26c3bb (2025-07-09, Realtek driver split). No pre- existing bug — this is missing hardware support, not a regression from prior code.

### Step 3.2: FOLLOW THE FIXES: TAG
**Record:** N/A — no Fixes: tag present.

### Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES **Record:** Local tree at v6.18.44 has only two commits touching alc882.c: e1d695b45fd11 (probe rewrite) and aeeb85f26c3bb (driver split). Commit def5e78a4e003 is on master but not in stable/linux-6.18.y. Standalone single-patch fix, not part of a series.

### Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
**Record:** Evelyn Ali has no other commits in this tree. Takashi Iwai is the ALSA/HDA maintainer and authored the surrounding Clevo quirk infrastructure.

### Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS **Record:** No dependencies. Required symbols (PIN_VREF80, snd_hda_set_pin_ctl_cache, keep_vref_in_automute, ALC882_FIXUP_EAPD) all exist in this tree. git apply --check on the patch succeeds cleanly.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION **Record:** b4 dig -c def5e78a4e003 → [v2] thread at
https://patch.msgid.link/[email protected].
Only v2 found (no v1 in series list). Maintainer merged without objections in thread.

### Step 4.2: CHECK WHO REVIEWED THE PATCH
**Record:** b4 dig -w: To [email protected], Evelyn Ali, Takashi Iwai. Appropriate subsystem list and maintainer CC'd.

### Step 4.3: SEARCH FOR THE BUG REPORT
**Record:** No external bug report or syzbot link. Hardware issue reported by patch author on their own hardware.

### Step 4.4: CHECK FOR RELATED PATCHES AND SERIES **Record:** Standalone 1-patch series. No prerequisites.

### Step 4.5: CHECK STABLE MAILING LIST HISTORY
**Record:** Not searched on lore stable list; no stable nomination found in patch thread. Absence of Cc: stable is expected per review instructions.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF **Record:** alc898_fixup_clevo_p775tm1() (new fixup callback)

### Step 5.2: TRACE CALLERS
**Record:** Invoked by HDA fixup framework during codec probe for matching PCI quirk 0x1558:0x7709. Called from device enumeration when the Realtek codec driver loads — standard driver probe path for affected hardware.

### Step 5.3: TRACE CALLEES
**Record:** snd_hda_set_pin_ctl_cache(codec, 0x1b, PIN_VREF80) — caches pin control for node 0x1b with 80% VREF. Sets spec->gen.keep_vref_in_automute read later in sound/hda/codecs/generic.c automute path.

### Step 5.4: FOLLOW THE CALL CHAIN
**Record:** PCI device probe → HDA codec driver → quirk table lookup by SSID → fixup chain (ALC898_FIXUP_CLEVO_P775TM1 → ALC882_FIXUP_EAPD) → pin configuration at probe. Reachable on boot for matching hardware; not userspace-triggerable but affects all audio on that machine.

### Step 5.5: SEARCH FOR SIMILAR PATTERNS
**Record:** Same keep_vref_in_automute + VREF pattern in alc889_fixup_mbp_vref() and alc889_fixup_mac_pins() in the same file (lines 109–144). Multiple Clevo-specific fixups already present (ALC1220_FIXUP_CLEVO_P950, ALC1220_FIXUP_CLEVO_PB51ED, etc.).

---

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

### Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE? **Record:** Local tree is **v6.18.44** (stable/linux-6.18.y). The fix is **absent** — grep finds no P775TM1, 0x7709, or ALC898_FIXUP_CLEVO_P775TM1. Without the quirk, 0x1558:0x7709 matches only the generic SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD) at line 682, which does not set pin 0x1b VREF. The broken behavior (no Sabre DAC output) is present for P775TM1 owners on this tree.

### Step 6.2: CHECK FOR BACKPORT COMPLICATIONS **Record:** **Clean apply** — git apply --check passes with no conflicts. File structure matches mainline commit base.

### Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE **Record:** No duplicate or alternative fix for P775TM1 found. Clevo VREF/quirk infrastructure is present from the 2025 driver split.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

### Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY **Record:** **sound/ALSA HDA Realtek codec driver** — IMPORTANT (affects audio on specific laptop hardware, not core kernel paths).

### Step 7.2: ASSESS SUBSYSTEM ACTIVITY
**Record:** Actively maintained; frequent laptop quirk additions on stable (e.g., 04dd210180575 Clevo mic fix in this tree).

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: DETERMINE WHO IS AFFECTED
**Record:** **Driver-specific / hardware-specific** — Clevo P775TM1 laptops with PCI SSID 0x1558:0x7709 and Realtek ALC898-class codec.

### Step 8.2: DETERMINE THE TRIGGER CONDITIONS
**Record:** Triggers at every boot/probe on matching hardware. Not timing-dependent. Unprivileged users cannot trigger it arbitrarily, but all users on that laptop are affected.

### Step 8.3: DETERMINE THE FAILURE MODE SEVERITY **Record:** **No audio output** from the ESS Sabre HiFi DAC / external headphone amp. **Severity: MEDIUM** — serious functional impairment for affected users, but no crash, corruption, deadlock, or security impact.

### Step 8.4: CALCULATE RISK-BENEFIT RATIO
**Record:**
- **Benefit:** Enables working audio on Clevo P775TM1 — real hardware fix for real users
- **Risk:** Very low — 22 lines, SSID-gated, established pattern
- **Ratio:** Strong benefit, minimal risk — standard stable quirk material

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: COMPILE THE EVIDENCE

**FOR backporting:**
- Hardware codec quirk — explicit stable exception category
- Fixes real user-visible bug (no audio) on Clevo P775TM1
- Small (22 lines), single file, applies cleanly to v6.18.44
- Follows established patterns in same file (VREF + keep_vref_in_automute, Clevo quirk table)
- Merged by subsystem maintainer (Takashi Iwai)
- All prerequisites present in this tree
- Fix not yet in stable/linux-6.18.y

**AGAINST backporting:**
- Not a crash/security/corruption issue
- Affects narrow hardware population
- No Tested-by: tag beyond author/maintainer
- New laptop model — limited user base on 6.18.y today

**Unresolved:** None material to the decision.

### Step 9.2: STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — standard HDA quirk pattern; maintainer-merged v2
2. Fixes a real bug affecting users? **PASS** — broken audio on P775TM1
3. Important issue? **PASS** (functional/hardware) — no audio is a significant usability failure for affected hardware, though not CRITICAL severity
4. Small and contained? **PASS** — 22 lines, one file
5. No new features or APIs? **PASS** — hardware quirk exception applies
6. Can apply to the local tree? **PASS** — clean apply verified

### Step 9.3: CHECK FOR EXCEPTION CATEGORIES
**Record:** **Hardware quirk / audio codec quirk** — automatic stable YES category per stable rules.

### Step 9.4: DECISION RATIONALE

For **linux-6.18.y (v6.18.44)**, this commit should be backported. It is a textbook HDA Realtek laptop quirk: PCI SSID-specific pin VREF configuration enabling an external DAC. The same file already contains numerous Clevo fixups using identical infrastructure. The patch is absent from this stable tree, applies without modification, and fixes a real hardware issue with negligible regression risk.

---

## Verification

- [Phase 1] git show def5e78a4e003: parsed tags (SOB Evelyn Ali, Link, SOB Takashi Iwai); no Fixes/Reported-by/Tested-by
- [Phase 1] Subject parsed: ALSA hda/realtek ALC882 fixup for Clevo P775TM1
- [Phase 2] Diff: +22 lines in alc882.c; new alc898_fixup_clevo_p775tm1(), quirk 0x1558:0x7709
- [Phase 3] git describe HEAD: v6.18.44; tree is stable/linux-6.18.y
- [Phase 3] git log HEAD..master --grep P775TM1: commit only on master, not in stable branch
- [Phase 3] git apply --check on patch from def5e78a4e003: applies cleanly
- [Phase 3] git blame lines 666–668: surrounding Clevo quirks from aeeb85f26c3bb (2025-07-09)
- [Phase 4] b4 dig -c def5e78a4e003: lore URL
https://patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v2 only, standalone patch
- [Phase 4] b4 dig -w: CC'd [email protected] and Takashi Iwai
- [Phase 4] b4 dig -m /tmp/p775tm1.mbox: thread saved; maintainer merge reply, no stable nomination or NAK
- [Phase 5] grep keep_vref_in_automute: used in alc882.c lines 126/143 and generic.c line 4412
- [Phase 5] grep PIN_VREF80: defined in hda_local.h, used across HDA codecs
- [Phase 6] grep P775TM1|0x7709|ALC898_FIXUP: no matches — fix absent from local tree
- [Phase 6] Read alc882.c line 682: generic Clevo EAPD quirk exists but lacks VREF fix
- [Phase 6] Read alc882.c lines 666–668: gap where 0x7709 quirk should be inserted
- [Phase 8] Failure mode: no audio from Sabre DAC; severity MEDIUM (functional, not crash)

**YES**

 sound/hda/codecs/realtek/alc882.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
sound/hda/codecs/realtek/alc882.c +22 -0
index 529fecd5baa0a..fd466b6985f05 100644
@@ -61,6 +61,7 @@ enum {
 	ALC887_FIXUP_ASUS_HMIC,
 	ALCS1200A_FIXUP_MIC_VREF,
 	ALC888VD_FIXUP_MIC_100VREF,
+	ALC898_FIXUP_CLEVO_P775TM1,
 };
 
 static void alc889_fixup_coef(struct hda_codec *codec,
@@ -236,6 +237,19 @@ static void alc1220_fixup_clevo_pb51ed(struct hda_codec *codec,
 	alc_fixup_headset_mode_no_hp_mic(codec, fix, action);
 }
 
+/* On Clevo P775TM1, VREF of pin 0x1b enables the external headphone amp */
+static void alc898_fixup_clevo_p775tm1(struct hda_codec *codec,
+				       const struct hda_fixup *fix, int action)
+{
+	struct alc_spec *spec = codec->spec;
+
+	if (action != HDA_FIXUP_ACT_PRE_PROBE)
+		return;
+
+	snd_hda_set_pin_ctl_cache(codec, 0x1b, PIN_VREF80);
+	spec->gen.keep_vref_in_automute = 1;
+}
+
 static void alc887_asus_hp_automute_hook(struct hda_codec *codec,
 					 struct hda_jack_callback *jack)
 {
@@ -560,6 +574,12 @@ static const struct hda_fixup alc882_fixups[] = {
 			{}
 		}
 	},
+	[ALC898_FIXUP_CLEVO_P775TM1] = {
+		.type = HDA_FIXUP_FUNC,
+		.v.func = alc898_fixup_clevo_p775tm1,
+		.chained = true,
+		.chain_id = ALC882_FIXUP_EAPD,
+	},
 };
 
 static const struct hda_quirk alc882_fixup_tbl[] = {
@@ -664,6 +684,7 @@ static const struct hda_quirk alc882_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x1558, 0x67f1, "Clevo PC70H[PRS]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
 	SND_PCI_QUIRK(0x1558, 0x67f5, "Clevo PD70PN[NRT]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
 	SND_PCI_QUIRK(0x1558, 0x70d1, "Clevo PC70[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
+	SND_PCI_QUIRK(0x1558, 0x7709, "Clevo P775TM1", ALC898_FIXUP_CLEVO_P775TM1),
 	SND_PCI_QUIRK(0x1558, 0x7714, "Clevo X170SM", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
 	SND_PCI_QUIRK(0x1558, 0x7715, "Clevo X170KM-G", ALC1220_FIXUP_CLEVO_PB51ED),
 	SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
@@ -719,6 +740,7 @@ static const struct hda_model_fixup alc882_fixup_models[] = {
 	{.id = ALC1220_FIXUP_GB_DUAL_CODECS, .name = "dual-codecs"},
 	{.id = ALC1220_FIXUP_GB_X570, .name = "gb-x570"},
 	{.id = ALC1220_FIXUP_CLEVO_P950, .name = "clevo-p950"},
+	{.id = ALC898_FIXUP_CLEVO_P775TM1, .name = "clevo-p775tm1"},
 	{}
 };
 
Signature · 1 line
2.53.0
author maintainer
#719 lore raw

PATCH 1/1 hfsplus: fix issue of direct writes beyond end-of-file

In reply to Sasha Levin

From: Viacheslav Dubeyko <[email protected]>

[ Upstream commit 5f63ac80aef2ee6bb58eab62e98c264774872da6 ]

The xfstests' test-case generic/729 fails with error:

sudo ./check generic/729

FSTYP         -- hfsplus
PLATFORM      -- Linux/x86_64 hfsplus-testing-0001 7.0.0-rc1+ #36 SMP PREEMPT_DYNAMIC Fri Apr 17 12:40:51 PDT 2026
MKFS_OPTIONS  -- /dev/loop51

MOUNT_OPTIONS -- /dev/loop51 /mnt/scratch

generic/729 23s ... [failed, exit status 1]- output mismatch

mmap-rw-fault: /mnt/test/mmap-rw-fault.tmp: Input/output error

The hfsplus_get_block() only allows creating the next sequential block. It returns -EIO for direct writes beyond EOF. This patch waits for any in-flight DIO on the inode to finish. Then, it extends the file by calling generic_cont_expand_simple() with the goal to guarantee that blockdev_direct_IO() finds all needed blocks already reachable sequentially. And, finally, it flushes and invalidates the DIO range again so the page cache is clean before the direct write begins.

sudo ./check generic/729

FSTYP         -- hfsplus
PLATFORM      -- Linux/x86_64 hfsplus-testing-0001 7.0.0-rc1+ #40 SMP PREEMPT_DYNAMIC Thu Apr 16 15:41:03 PDT 2026
MKFS_OPTIONS  -- /dev/loop51

MOUNT_OPTIONS -- /dev/loop51 /mnt/scratch

generic/729 23s ... 32s
Ran: generic/729
Passed all 1 tests

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: hfsplus: fix issue of direct writes beyond end-of-file

**Local tree:** Linux **6.18.43** (git describe HEAD → v6.18.43)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject Line
**Record:** [hfsplus] [fix] [direct writes beyond end-of-file fail with -EIO]

### Step 1.2: Tags
**Record:**
- **Fixes:** — absent (expected for manual review)
- **Reported-by:** — absent
- **Tested-by:** — absent
- **Reviewed-by:** — absent
- **Acked-by:** — absent
- **Link:** https://lore.kernel.org/r/[email protected]
- **Closes:** https://github.com/hfs-linux-kernel/hfs-linux- kernel/issues/210
- **cc:** John Paul Adrian Glaubitz, Yangtao Li, linux- [email protected]
- **Signed-off-by:** Viacheslav Dubeyko (author; ignore pipeline SOBs)

Notable: GitHub issue documents reproducible xfstests failure; no syzbot/KASAN signals.

### Step 1.3: Body Analysis
**Record:**
- **Bug:** hfsplus_get_block() only allocates the *next sequential* block (iblock > hip->fs_blocks → -EIO). Direct I/O writes starting beyond EOF hit this path and fail.
- **Symptom:** xfstests generic/729 fails with mmap-rw-fault: ... Input/output error (userspace EIO).
- **Root cause:** DIO bypasses cont_write_begin() / page-cache expansion that buffered writes use; blockdev_direct_IO() calls hfsplus_get_block() with create=1 on blocks beyond the current allocation frontier.
- **Fix approach:** Before DIO write when ki_pos > i_size: wait for in-flight DIO, expand via generic_cont_expand_simple(), flush and invalidate the affected page-cache range, then proceed with blockdev_direct_IO().
- **Version info:** Issue filed against 6.15.0-rc4+; fix verified on 7.0.0-rc1+ per commit message and GitHub issue.

### Step 1.4: Hidden Bug Fix?
**Record:** No — this is an explicit functional bug fix, not disguised cleanup. It corrects incorrect -EIO on a valid I/O path.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Inventory
**Record:**
- **Files:** fs/hfsplus/inode.c only (+34 / −2 lines)
- **Function modified:** hfsplus_direct_IO()
- **Scope:** Single-file, surgical fix in one function

### Step 2.2: Code Flow Change
**Record:**

| Hunk | Before | After |
|------|--------|-------|
| Pre-DIO path | Immediately calls `blockdev_direct_IO()` | For WRITE
with `ki_pos > i_size`: `inode_dio_wait()` →
`generic_cont_expand_simple()` → `filemap_write_and_wait_range()` →
`invalidate_inode_pages2_range()`, then DIO |
| Error cleanup | Declares local `isize`/`end` in error block | Reuses
`isize`/`end` hoisted to function scope |

Affected path: **O_DIRECT write beyond current EOF** (sparse extension / hole before write).

### Step 2.3: Bug Mechanism
**Record:** **Logic / correctness fix** in filesystem block allocation.

In hfsplus_get_block():

```239:243:fs/hfsplus/extents.c
        if (iblock >= hip->fs_blocks) {
                if (!create)
                        return 0;
                if (iblock > hip->fs_blocks)
                        return -EIO;
```

Only iblock == hip->fs_blocks (next block) can be created. A DIO write at offset 4096 on a zero-length file needs iblock > fs_blocks → -EIO. Buffered writes avoid this via cont_write_begin() in hfsplus_write_begin().

### Step 2.4: Fix Quality
**Record:**
- **Obviously correct:** Mirrors the established pattern in hfsplus_setattr() (same file, lines 278–284): inode_dio_wait() + generic_cont_expand_simple().
- **Minimal:** Only touches the DIO write-beyond-EOF case.
- **Regression risk:** Low — narrow trigger (WRITE && ki_pos > i_size), uses standard VFS helpers already used elsewhere in hfsplus.
- **No new APIs or public interface changes.**

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
**Record:** hfsplus_direct_IO() and the iblock > hip->fs_blocks check both blame to 19eef1d98eeda in this tree (a history-rewrite artifact in the stable queue). The sequential-block constraint in hfsplus_get_block() is longstanding hfsplus design; the DIO path has lacked pre-expansion since hfsplus_direct_IO was wired into hfsplus_aops.

### Step 3.2: Fixes: Tag
**Record:** N/A — no Fixes: tag present.

### Step 3.3: Related File History
**Record:** Recent fs/hfsplus/inode.c history in **this tree** includes multiple backported hfsplus xfstests fixes from the same author:
- 956b1d8051cfa — generic/498 (volume corruption)
- 54694417d4384 — generic/480
- 66e2f3c1aefea — generic/101

This fix is **standalone** (not part of a multi-patch series in the commit message).

### Step 3.4: Author Context
**Record:** Viacheslav Dubeyko is an active hfsplus contributor; multiple hfsplus fixes from this author are already in Linux 6.18.43.

### Step 3.5: Dependencies
**Record:** No prerequisite commits required. All APIs exist in this tree:
- generic_cont_expand_simple() — fs/buffer.c:2473
- inode_dio_wait() — fs/inode.c:2659
- filemap_write_and_wait_range(), invalidate_inode_pages2_range() — standard VFS
- Already used in hfsplus_setattr() at lines 278–284 of the same file

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original Discussion
**Record:** b4 dig -c <sha> could not be run — commit is not in this checkout. Lore URL blocked by Anubis bot protection. GitHub issue #210 confirms the bug and fix (opened 2025-05-27, closed 2026-04-23 after generic/729 passed).

### Step 4.2: Reviewers
**Record:** UNVERIFIED — could not fetch lore thread. Commit cc's fsdevel and hfsplus maintainers.

### Step 4.3: Bug Report
**Record:** [GitHub issue #210](https://github.com/hfs-linux-kernel/hfs- linux-kernel/issues/210):
- Failure: mmap-rw-fault: ... Input/output error
- Reproducible since at least 6.15.0-rc4
- Fixed on 7.0.0-rc1+ with this patch
- **Severity from reporter:** xfstests regression; user-visible EIO, not corruption/crash

### Step 4.4: Related Patches
**Record:** generic/729 (added 2023) tests mmap + DIO write — extends generic/647. It exercises direct writes beyond EOF followed by mmap fault I/O. Same test class has exposed real bugs in btrfs (deadlock) and NFS (EFAULT).

### Step 4.5: Stable List History
**Record:** UNVERIFIED — lore stable list not searchable due to bot protection. Precedent exists in-tree: other Dubeyko hfsplus xfstests fixes already backported to 6.18.y.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key Functions
**Record:** hfsplus_direct_IO() (modified); hfsplus_get_block() (buggy callee, unchanged).

### Step 5.2: Callers
**Record:** hfsplus_direct_IO is registered in hfsplus_aops.direct_IO (line 173). Invoked from VFS when O_DIRECT is set on hfsplus files — reachable from pwrite(), io_uring, and xfstests mmap-rw-fault helper.

### Step 5.3: Callees
**Record:** inode_dio_wait, generic_cont_expand_simple (→ hfsplus_write_begin → cont_write_begin), filemap_write_and_wait_range, invalidate_inode_pages2_range, blockdev_direct_IO.

### Step 5.4: Reachability
**Record:** **Userspace-reachable** on any hfsplus mount with O_DIRECT writes extending past EOF. generic/729 is the concrete, reproducible trigger.

### Step 5.5: Similar Patterns
**Record:** hfsplus_setattr() already uses inode_dio_wait() + generic_cont_expand_simple() for size extension. hfs (fs/hfs/inode.c) has a similar bare hfs_direct_IO() — potentially the same class of bug, but out of scope for this commit.

---

## PHASE 6: CROSS-REFERENCE AGAINST LOCAL TREE (6.18.43)

### Step 6.1: Buggy Code Present?
**Record:** **YES.** Current hfsplus_direct_IO() at lines 123–145 calls blockdev_direct_IO() directly with no pre-expansion. hfsplus_get_block() sequential-only create logic at extents.c:239–243 is present.

### Step 6.2: Backport Complications
**Record:** **Clean apply** — git apply --check with the full upstream diff succeeds on fs/hfsplus/inode.c in this tree.

### Step 6.3: Related Fixes Already Present?
**Record:** **NO** — git log --grep="729" and git log --grep="beyond end-of-file" find no matching fix. This commit is not yet applied.

---

## PHASE 7: SUBSYSTEM CONTEXT

### Step 7.1: Subsystem / Criticality
**Record:** **fs/hfsplus** — IMPORTANT (filesystem I/O correctness), not CORE but affects all hfsplus users doing DIO.

### Step 7.2: Activity
**Record:** Actively maintained in 6.18.y — multiple recent hfsplus xfstests fixes from the same author already landed in this stable series.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Who Is Affected
**Record:** Users of hfsplus with O_DIRECT writes beyond EOF — including Mac interoperability workloads, backup tools, and the standard xfstests generic/729 regression test.

### Step 8.2: Trigger Conditions
**Record:** O_DIRECT write where ki_pos > i_size (sparse extension). Common in generic/729 (truncate to 0, then write at offset 4096). Unprivileged users can trigger on mounted hfsplus volumes they can write to.

### Step 8.3: Failure Mode Severity
**Record:** Returns **-EIO** to userspace on valid I/O. No crash, corruption, or deadlock documented for hfsplus. **Severity: MEDIUM** — functional I/O failure / incorrect error, fits stable rules' "oh, that's not good" category.

### Step 8.4: Risk-Benefit
**Record:**
- **Benefit:** MEDIUM — restores correct DIO semantics; passes standard xfstests; fixes long-standing user-visible failure
- **Risk:** LOW — 34 lines, one function, mirrors existing hfsplus_setattr() pattern, applies cleanly
- **Ratio:** Favorable for backport

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence Summary

**FOR backport:**
- Real, reproducible bug (xfstests generic/729, GitHub #210)
- User-visible EIO on valid direct writes beyond EOF
- Small, surgical, obviously correct fix
- Uses APIs already present and used in same file
- Applies cleanly to Linux 6.18.43
- Same author/subsystem already has xfstests fixes in this stable series
- Tested before/after in commit message

**AGAINST backport:**
- Not crash/corruption/security — severity is functional I/O failure
- hfsplus is a niche filesystem
- Bug likely present since DIO support was added (long-standing)
- Lore review details unverified

**UNRESOLVED:**
- Full mailing-list review thread (lore blocked)
- Whether reviewers explicitly nominated for stable

### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **PASS** — xfstests generic/729; pattern proven in hfsplus_setattr()
2. Fixes a real bug affecting users? **PASS** — EIO on valid O_DIRECT writes
3. Important issue? **PASS (MEDIUM)** — incorrect I/O failure on standard xfstests path; "oh, that's not good" per stable-kernel- rules.rst
4. Small and contained? **PASS** — 1 file, ~34 lines
5. No new features/APIs? **PASS** — uses existing VFS helpers
6. Can apply to local tree? **PASS** — clean git apply --check

### Step 9.3: Exception Category
**Record:** None (not device ID, quirk, DT, build fix, or docs). Standard filesystem correctness fix.

### Step 9.4: Decision Rationale
For **Linux 6.18.43**, the buggy code is present, all dependencies exist, the patch applies cleanly, and the fix addresses a reproducible userspace I/O failure on a supported filesystem using established patterns already in the same driver. While not as severe as the corruption fixes already backported for hfsplus in this series, it meets stable criteria: real bug, tested fix, low risk, user-visible impact. The 6.18.y tree has already accepted similar hfsplus xfstests fixes from this author.

---

## Verification

- **[Phase 1]** Parsed commit message, tags, and GitHub issue #210 (fetched successfully)
- **[Phase 2]** Read current hfsplus_direct_IO() at fs/hfsplus/inode.c:123–145 and hfsplus_get_block() at fs/hfsplus/extents.c:239–243
- **[Phase 2]** Confirmed hfsplus_setattr() uses same expansion pattern at fs/hfsplus/inode.c:278–284
- **[Phase 3]** git describe HEAD → v6.18.43; make kernelversion equivalent via Makefile → 6.18.43
- **[Phase 3]** git log --oneline -20 -- fs/hfsplus/inode.c — found related backported hfsplus fixes
- **[Phase 3]** git blame on changed lines — history rewrite artifact noted
- **[Phase 3]** git log --grep="729" / --grep="beyond end-of-file" — no existing fix in tree
- **[Phase 4]** GitHub issue #210 — confirmed failure mode and fix verification
- **[Phase 4]** Web search — confirmed generic/729 tests mmap + DIO write beyond EOF
- **[Phase 4]** UNVERIFIED: b4 dig (no commit SHA in tree), lore.kernel.org (bot-blocked)
- **[Phase 5]** grep hfsplus_direct_IO — registered in hfsplus_aops at line 173
- **[Phase 5]** grep generic_cont_expand_simple — present in fs/buffer.c:2473 and used in hfsplus
- **[Phase 6]** Confirmed buggy code present in current checkout
- **[Phase 6]** git apply --check with full upstream diff — **succeeds**
- **[Phase 7]** Multiple Dubeyko hfsplus commits in git log --author="Dubeyko" on this tree
- **[Phase 8]** Assessed severity as MEDIUM functional I/O failure, not CRITICAL

**YES**The background git history search failed: it hit the 30s timeout because the command fell through to git log -S 'hfsplus_direct_IO' --all, which is exactly what we must avoid on this repo.

That didn’t block the backport analysis. I used narrower searches instead (git blame, git log -S ... -- fs/hfsplus/inode.c), and the conclusion for Linux **6.18.43** is unchanged: **YES** — the fix applies cleanly and addresses a real O_DIRECT-beyond-EOF EIO bug in hfsplus.

 fs/hfsplus/inode.c | 38 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)
fs/hfsplus/inode.c +36 -2
index 6153e5cc6eb65..7e6cc4dde9f26 100644
@@ -125,9 +125,44 @@ static ssize_t hfsplus_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 	struct file *file = iocb->ki_filp;
 	struct address_space *mapping = file->f_mapping;
 	struct inode *inode = mapping->host;
+	loff_t isize;
 	size_t count = iov_iter_count(iter);
+	loff_t end = iocb->ki_pos + count;
 	ssize_t ret;
 
+	/*
+	 * The hfsplus_get_block() only allows creating the next sequential block.
+	 * For direct writes beyond EOF, expand the file first.
+	 */
+	if (iov_iter_rw(iter) == WRITE && iocb->ki_pos > i_size_read(inode)) {
+		loff_t start_off, end_off;
+		loff_t start_page, end_page;
+
+		isize = i_size_read(inode);
+
+		/*
+		 * Wait for any in-flight DIO on this inode to finish before
+		 * calling generic_cont_expand_simple().
+		 */
+		inode_dio_wait(inode);
+
+		ret = generic_cont_expand_simple(inode, iocb->ki_pos);
+		if (ret)
+			return ret;
+
+		start_off = isize;
+		end_off = (end > 0) ? end - 1 : end;
+
+		ret = filemap_write_and_wait_range(mapping, start_off, end_off);
+		if (ret)
+			return ret;
+
+		start_page = start_off >> PAGE_SHIFT;
+		end_page = end_off >> PAGE_SHIFT;
+
+		invalidate_inode_pages2_range(mapping, start_page, end_page);
+	}
+
 	ret = blockdev_direct_IO(iocb, inode, iter, hfsplus_get_block);
 
 	/*
@@ -135,8 +170,7 @@ static ssize_t hfsplus_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 	 * blocks outside i_size. Trim these off again.
 	 */
 	if (unlikely(iov_iter_rw(iter) == WRITE && ret < 0)) {
-		loff_t isize = i_size_read(inode);
-		loff_t end = iocb->ki_pos + count;
+		isize = i_size_read(inode);
 
 		if (end > isize)
 			hfsplus_write_failed(mapping, end);
Signature · 1 line
2.53.0
author maintainer
#720 lore raw

PATCH 1/1 iommu: arm-smmu-qcom: Ensure smmu is powered up in set_ttbr0_cfg

In reply to Sasha Levin

From: Anna Maniscalco <[email protected]>

[ Upstream commit 8a0aab012b52b5c044ca3bec523e91f95dd40765 ]

arm_smmu_write_context_bank() assumes it is being called with RPM active, but it turns out that is not guaranteed in the path from qcom_adreno_smmu_set_ttbr0_cfg(), so it's possible for the register writes to get lost when configuring the context bank while the GPU is idle, leading to page faults later.
Add the RPM calls here to make sure the SMMU is active before we touch it.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: iommu: arm-smmu-qcom: Ensure smmu is powered up in set_ttbr0_cfg

**Local tree:** Linux **6.18.43** (v6.18.43-1-gc7f0dac02d232) **Mainline commit:** 8a0aab012b52 — **not yet merged** into this checkout (git merge-base --is-ancestor → NOT_IN_TREE)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject line
**Record:** [iommu/arm-smmu-qcom] [ensure] — Ensure the Qualcomm Adreno SMMU is runtime-PM-active before writing context-bank registers in set_ttbr0_cfg.

### Step 1.2: Tags
**Record:**

| Tag | Value |
|-----|-------|
| Signed-off-by | Anna Maniscalco, Will Deacon (ignore pipeline-added
SOBs) |
| Reviewed-by | Rob Clark `<[email protected]>` (Qualcomm/msm
maintainer) |
| Reviewed-by | Robin Murphy `<[email protected]>` (ARM SMMU
maintainer) |
| Fixes: | **Absent** (expected for manual review) |
| Reported-by: | **Absent** |
| Cc: stable | **Absent** (expected) |
| Link: | **Absent** in final commit; v3 cover letter links v1/v2 on
lore |

Notable: dual Reviewed-by from GPU and IOMMU subsystem experts. No syzbot report.

### Step 1.3: Body analysis
**Record:**
- **Bug:** arm_smmu_write_context_bank() assumes runtime PM (RPM) is active, but qcom_adreno_smmu_set_ttbr0_cfg() does not guarantee that.
- **Symptom:** Register writes are silently lost when the SMMU is powered down (GPU idle); later GPU accesses cause **IOMMU page faults**.
- **Root cause:** Missing pm_runtime_resume_and_get() / pm_runtime_put_autosuspend() around the hardware register write.
- **Version info:** None explicit; bug tied to runtime-PM-enabled Adreno SMMU path.

### Step 1.4: Hidden bug fix detection
**Record:** Not disguised — this is an explicit correctness bug fix. The "ensure" verb and page-fault consequence clearly indicate a real functional defect, not cleanup.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Inventory
**Record:**
- **File:** drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c (+9 lines, 0 removed)
- **Function modified:** qcom_adreno_smmu_set_ttbr0_cfg()
- **Scope:** Single-file, surgical fix

### Step 2.2: Code flow change
**Record:**

| Hunk | Before | After |
|------|--------|-------|
| Variable | No `ret` | `int ret;` added |
| Before `arm_smmu_write_context_bank()` | Direct register write, no RPM
| `pm_runtime_resume_and_get()`; error → `-ENODEV` |
| After write | Immediate `return 0` | `pm_runtime_put_autosuspend()`
then `return 0` |

Affected path: both enable-TTBR0 (pgtbl_cfg != NULL) and disable-TTBR0 (pgtbl_cfg == NULL) branches, executed when the msm GPU driver switches per-instance pagetables.

### Step 2.3: Bug mechanism
**Record:**
- **Category:** Logic/correctness — hardware access without power domain active (runtime PM omission).
- **Mechanism:** When the Adreno GPU is idle, the SMMU can be autosuspended. qcom_adreno_smmu_set_ttbr0_cfg() updates in-memory cb->tcr[0] / cb->ttbr[0] then calls arm_smmu_write_context_bank() to push them to hardware. Without RPM resume, MMIO writes are dropped. Software state and hardware state diverge → GPU page faults on next use.

Sibling functions qcom_adreno_smmu_set_prr_bit() and qcom_adreno_smmu_set_prr_addr() already use the identical RPM pattern (added in 7f2ef1bfc758f, Jan 2025). set_ttbr0_cfg was the omission.

### Step 2.4: Fix quality
**Record:**
- **Obviously correct:** Yes — mirrors existing pattern in the same file at lines 158–169 and 178–188.
- **Minimal:** RPM acquired only around the single hardware write, per v2 review feedback.
- **Regression risk:** Very low. Same API used elsewhere; no new locks or data-structure changes.
- **Minor concern:** On RPM failure, in-memory cb state is already modified but hardware write is skipped. Pre-existing pattern (early returns on -EINVAL also leave divergent state); not introduced by this fix.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
**Record:** qcom_adreno_smmu_set_ttbr0_cfg() introduced entirely in 5c7469c66f953 (Jordan Crouse, **2020-11-09**) — "Add implementation for the adreno GPU SMMU". The RPM omission has existed since introduction. Line 263 (arm_smmu_write_context_bank call) unchanged since then.

### Step 3.2: Fixes: tag
**Record:** No Fixes: tag. N/A.

### Step 3.3: Related file history
**Record:**
- 7f2ef1bfc758f (Jan 2025): Added PRR callbacks with RPM — same omission left in set_ttbr0_cfg.
- 70892277ca2db (May 2025): set_stall RPM handling when device is on — related runtime-PM theme.
- 0b4eeee2876f2 (Jul 2024): TBU driver registration; pm_runtime_enable() when dev->pm_domain is set.
- **Standalone:** Yes — single patch, v1→v2→v3 series converged on final minimal form. No other patches required.

### Step 3.4: Author context
**Record:** Anna Maniscalco has no other iommu commits in this tree. Fix reviewed by Rob Clark (msm/Adreno) and Robin Murphy (arm-smmu core).

### Step 3.5: Dependencies
**Record:** No dependencies. Requires only code present in 6.18.y:
- qcom_adreno_smmu_set_ttbr0_cfg — present
- pm_runtime_resume_and_get / pm_runtime_put_autosuspend — used in same file
- linux/pm_runtime.h — already included (line 12)

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original discussion
**Record:**
- b4 dig -c 8a0aab012b52: matched patch-id to v2 thread
- **URL:** https://patch.msgid.link/20260325-qcom_smmu_pmfix-v2-1-
[email protected]
- **Series (b4 dig -a):** v1 (2026-02-10), v2 (2026-03-25); committed version is v3 (2026-05-07)
- v3 changes: self-contained commit message, collected Reviewed-by tags
- v2 changes: narrowed RPM scope to just around arm_smmu_write_context_bank()
- **Stable nomination in thread:** Not found (lkml archive shows cover letter only, no reply thread with Cc: stable)
- **NAKs:** None found

### Step 4.2: Reviewers
**Record (b4 dig -w):** To: Rob Clark, Will Deacon, Robin Murphy, Joerg Roedel. Cc: iommu@, linux-arm-msm@, linux-arm-kernel@, linux-kernel@. Appropriate maintainer coverage.

### Step 4.3: Bug report
**Record:** No external bug report, syzbot link, or Bugzilla reference. Bug identified through code analysis (RPM assumption violated). Failure mode (page faults) is described in commit message.

### Step 4.4: Series context
**Record:** Standalone 1-patch fix. No companion patches needed.

### Step 4.5: Stable list history
**Record:** Not searched exhaustively (no stable-specific discussion found in available sources). Absence of prior stable discussion is not a negative signal.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key functions
**Record:** qcom_adreno_smmu_set_ttbr0_cfg() (modified); arm_smmu_write_context_bank() (callee).

### Step 5.2: Callers
**Record:** Called from drivers/gpu/drm/msm/msm_iommu.c:
1. **msm_iommu_pagetable_create()** (line ~582): first per-instance pagetable → enable TTBR0. Return value checked; failure aborts pagetable creation.
2. **msm_iommu_pagetable_destroy()** (line ~234): last pagetable destroyed → disable TTBR0. Return value **not** checked (pre- existing).

Registered via priv->set_ttbr0_cfg in arm-smmu-qcom.c line 351 for qcom,adreno-smmu devices.

### Step 5.3: Callees
**Record:** pm_runtime_resume_and_get(), arm_smmu_write_context_bank() (MMIO register writes to SMMU context bank), pm_runtime_put_autosuspend(), dev_err().

### Step 5.4: Reachability
**Record:**
- Triggered when userspace opens a GPU context requiring per-instance pagetables (common on Qualcomm Android/Chromebook devices).
- Especially when GPU was previously idle (SMMU autosuspended) — e.g., launching an app after idle, or teardown after app exit.
- **Userspace-reachable:** Yes, via GPU ioctl/mmap paths in drm/msm.
- In msm_iommu_pagetable_create(), set_ttbr0_cfg runs **before** set_prr_addr/set_prr_bit (which do have RPM), confirming TTBR0 writes can be lost even when subsequent PRR setup succeeds.

### Step 5.5: Similar patterns
**Record:** Identical RPM wrap in qcom_adreno_smmu_set_prr_bit() and qcom_adreno_smmu_set_prr_addr(). arm_smmu_destroy_domain_context() in arm-smmu.c uses arm_smmu_rpm_get() before arm_smmu_write_context_bank(). This fix brings set_ttbr0_cfg in line with established conventions.

---

## PHASE 6: CROSS-REFERENCING AGAINST LOCAL TREE (6.18.43)

### Step 6.1: Buggy code present?
**Record:** **Yes.** qcom_adreno_smmu_set_ttbr0_cfg() at lines 227–265 in arm-smmu-qcom.c calls arm_smmu_write_context_bank() without any RPM calls. Bug present since feature introduction (5.12+ era, commit 2020-11-09). Runtime PM enabled when dev->pm_domain is set (line 750–752).

### Step 6.2: Backport complications
**Record:** **Clean apply expected.** The function and surrounding code are unchanged between this tree and mainline at the patch site. No conflicting modifications in recent history of this function.

### Step 6.3: Related fixes already present?
**Record:** **No.** git merge-base --is-ancestor 8a0aab012b52 HEAD → NOT_IN_TREE. No grep hits for "powered up" or "qcom_smmu_pmfix" in this tree.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

### Step 7.1: Subsystem criticality
**Record:** **drivers/iommu** (ARM SMMU, Qualcomm variant) + **drivers/gpu/drm/msm**. Criticality: **IMPORTANT** — affects GPU IOMMU on widely deployed Qualcomm SoCs (sm8250, sm8350, sm8450, sm8550, sm8650, etc., confirmed via DTS qcom,adreno-smmu compatibles).

### Step 7.2: Subsystem activity
**Record:** Actively maintained. Recent commits in arm-smmu-qcom.c include fastrpc compatible fix, probe registration change, SMR group handling (2025–2026).

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Who is affected
**Record:** Users of Qualcomm Adreno GPUs with split pagetables (qcom,adreno-smmu), primarily **arm64** Android phones, tablets, and some Chromebooks running drm/msm with CONFIG_ARM_SMMU and CONFIG_DRM_MSM.

### Step 8.2: Trigger conditions
**Record:**
- GPU idle long enough for SMMU runtime autosuspend.
- Application or kernel initiates per-instance pagetable create/destroy (TTBR0 enable/disable).
- **Likelihood:** Realistic on mobile (frequent idle/suspend cycles). Not every-boot, but common in production workloads.

### Step 8.3: Failure mode severity
**Record:** **IOMMU page faults** on GPU memory accesses → GPU faults, application crashes, potential display freeze. Severity: **HIGH** (functional failure of GPU subsystem; not a kernel panic but user- visible and disruptive).

### Step 8.4: Risk-benefit
**Record:**
- **Benefit:** HIGH for affected Qualcomm platforms — prevents silent hardware misconfiguration.
- **Risk:** VERY LOW — 9-line addition matching proven pattern in same file.
- **Ratio:** Strongly favors backport.

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence summary

**FOR backport:**
- Fixes a real, reproducible-class bug (lost MMIO writes when SMMU suspended)
- Concrete user-visible failure: GPU page faults
- Small, surgical, obviously correct fix
- Reviewed by Rob Clark and Robin Murphy
- Bug present in this tree since 2020; not a mainline-only regression
- Matches established RPM pattern in sibling functions
- Standalone, no dependencies
- Clean apply to 6.18.43

**AGAINST backport:**
- Platform-specific (Qualcomm Adreno only) — mitigated: stable routinely takes targeted driver fixes
- No syzbot/user bug report — mitigated: clear technical analysis and expert review
- Intermittent (requires idle GPU) — mitigated: common on mobile devices

**Unresolved:** No independent user crash report verified; impact inferred from code analysis and commit message.

### Step 9.2: Stable rules checklist

| Criterion | Result |
|-----------|--------|
| 1. Obviously correct and tested? | **PASS** — mirrors existing RPM
pattern; reviewed by subsystem maintainers |
| 2. Fixes real bug affecting users? | **PASS** — lost register writes →
GPU page faults |
| 3. Important issue? | **PASS** — HIGH severity GPU/IOMMU functional
failure |
| 4. Small and contained? | **PASS** — 9 lines, 1 file, 1 function |
| 5. No new features/APIs? | **PASS** — runtime PM only |
| 6. Can apply to local tree? | **PASS** — buggy code present; clean
apply expected |

### Step 9.3: Exception categories
**Record:** Hardware workaround / driver correctness fix for existing Qualcomm Adreno SMMU hardware. Qualifies under stable driver bug-fix norms.

### Step 9.4: Decision rationale
This commit closes a long-standing gap where qcom_adreno_smmu_set_ttbr0_cfg() wrote SMMU context-bank registers without ensuring runtime PM was active. On Qualcomm Adreno platforms in this 6.18.y tree, that can silently drop TTBR0 configuration when the GPU is idle, causing later IOMMU page faults. The fix is minimal, follows an established pattern already used by set_prr_bit and set_prr_addr in the same file, and has maintainer review. It meets all stable kernel criteria for this tree.

---

## Verification

- [Phase 1] Parsed subject, tags (Reviewed-by: Rob Clark, Robin Murphy), body; no Fixes:/Reported-by:
- [Phase 2] Diff: +9 lines in qcom_adreno_smmu_set_ttbr0_cfg(), RPM wrap around arm_smmu_write_context_bank()
- [Phase 3] git blame -L 227,265: function from 5c7469c66f953 (2020-11-09); no RPM since introduction
- [Phase 3] git log -S 'qcom_adreno_smmu_set_ttbr0_cfg': introduced in 5c7469c66f953
- [Phase 3] 7f2ef1bfc758f: PRR functions added with RPM pattern; set_ttbr0_cfg omitted
- [Phase 3] 70892277ca2db: related RPM fix for set_stall
- [Phase 4] b4 dig -c 8a0aab012b52: found v2 thread at patch.msgid.link
- [Phase 4] b4 dig -a: v1 (Feb 2026), v2 (Mar 2026); committed as v3 (May 2026)
- [Phase 4] b4 dig -w: maintainers CC'd (Rob Clark, Will Deacon, Robin Murphy, Joerg Roedel)
- [Phase 4] lkml.iu.edu v3 cover letter: confirms bug description and review tags; no stable nomination found
- [Phase 5] grep set_ttbr0_cfg: callers in msm_iommu.c lines 234, 582; registration at arm-smmu-qcom.c:351
- [Phase 5] Read msm_iommu_pagetable_create(): set_ttbr0_cfg called before RPM-protected set_prr_addr/set_prr_bit
- [Phase 5] Read qcom_adreno_smmu_set_prr_bit/addr: identical RPM pattern confirmed
- [Phase 6] git describe HEAD: v6.18.43; make kernelversion: 6.18.43
- [Phase 6] Read arm-smmu-qcom.c:227-265: buggy code confirmed present (no RPM)
- [Phase 6] git merge-base --is-ancestor 8a0aab012b52 HEAD:
NOT_IN_TREE
- [Phase 6] git show 8a0aab012b52: mainline commit exists and matches provided diff
- [Phase 7] DTS grep: qcom,adreno-smmu on sm8250/sm8350/sm8450/sm8550/sm8650
- [Phase 8] Failure mode: page faults on GPU access; severity HIGH for affected platforms

**YES**The background git searches finished and line up with the earlier analysis:

- **Related history:** qcom_adreno_smmu_set_ttbr0_cfg() has been in the tree since 2020; sibling functions like set_prr_bit/set_prr_addr already use runtime PM, but this path was missed.
- **Author search:** Anna Maniscalco has drm/msm commits in this tree, but no iommu commits — this fix is her iommu contribution.
- **Fix presence:** No match for set_ttbr0 or qcom_smmu_pmfix in this tree; mainline commit 8a0aab012b52 is not merged into 6.18.43.

**Verdict unchanged: YES** — worth backporting to this 6.18.y tree. It’s a small, low-risk fix for a real Qualcomm Adreno GPU bug where TTBR0 register writes can be lost while the SMMU is runtime-suspended, causing later GPU page faults.

 drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +9 -0
index 3b9fb1c71e5f9..f7cb7de80cfb9 100644
@@ -231,6 +231,7 @@ static int qcom_adreno_smmu_set_ttbr0_cfg(const void *cookie,
 	struct io_pgtable *pgtable = io_pgtable_ops_to_pgtable(smmu_domain->pgtbl_ops);
 	struct arm_smmu_cfg *cfg = &smmu_domain->cfg;
 	struct arm_smmu_cb *cb = &smmu_domain->smmu->cbs[cfg->cbndx];
+	int ret;
 
 	/* The domain must have split pagetables already enabled */
 	if (cb->tcr[0] & ARM_SMMU_TCR_EPD1)
@@ -260,8 +261,16 @@ static int qcom_adreno_smmu_set_ttbr0_cfg(const void *cookie,
 		cb->ttbr[0] |= FIELD_PREP(ARM_SMMU_TTBRn_ASID, cb->cfg->asid);
 	}
 
+	ret = pm_runtime_resume_and_get(smmu_domain->smmu->dev);
+	if (ret < 0) {
+		dev_err(smmu_domain->smmu->dev, "failed to get runtime PM: %d\n", ret);
+		return -ENODEV;
+	}
+
 	arm_smmu_write_context_bank(smmu_domain->smmu, cb->cfg->cbndx);
 
+	pm_runtime_put_autosuspend(smmu_domain->smmu->dev);
+
 	return 0;
 }
 
Signature · 1 line
2.53.0
author maintainer
#721 lore raw

PATCH 1/1 x86/topology: Add missing struct declaration and attribute dependency

In reply to Sasha Levin

From: Ricardo Neri <[email protected]>

[ Upstream commit bdf5eb306c4d07a3bfdd4e2ab8f2acc7ff824940 ]

The prototypes for get_topology_cpu_type_name() and get_topology_cpu_type() take a pointer to struct cpuinfo_x86, but asm/topology.h neither includes nor forward-declares the structure. Including asm/topology.h, directly or indirectly, without including asm/processor.h triggers a warning:

./arch/x86/include/asm/topology.h:159:47: error: ‘struct cpuinfo_x86’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
159 | const char *get_topology_cpu_type_name(struct cpuinfo_x86 *c);
| ^~~~~~~~~~~

Since only a pointer is needed, add a forward declaration of struct cpuinfo_x86.

Additionally, sysctl_sched_itmt_enabled is declared in asm/topology.h with the __read_mostly attribute, but the header does not include linux/cache.h. This causes a build failure when including asm/topology.h but not linux/ cache.h:

     ./arch/x86/include/asm/topology.h:264:27: error: expected ‘=’, ‘,’,
     ‘;’, ‘asm’ or ‘__attribute__’ before ‘sysctl_sched_itmt_enabled’
     264 | extern bool __read_mostly sysctl_sched_itmt_enabled;
         |                           ^~~~~~~~~~~~~~~~~~~~~~~~~

Include the required header.

---

LLM Generated explanations, may be completely bogus:

The background search finished: git log --grep='missing struct declaration' only turned up an unrelated drm/i915/perf commit, and nothing matched attribute dependency. That confirms the topology header fix isn’t in this v6.18.44 tree yet, which matches the earlier analysis — the buggy code is still present and the patch should be backported.

**YES**

 arch/x86/include/asm/topology.h | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/include/asm/topology.h +3 -0
index 21041898157a1..63489ec410320 100644
@@ -156,6 +156,8 @@ extern unsigned int __max_threads_per_core;
 extern unsigned int __num_threads_per_package;
 extern unsigned int __num_cores_per_package;
 
+struct cpuinfo_x86;
+
 const char *get_topology_cpu_type_name(struct cpuinfo_x86 *c);
 enum x86_topology_cpu_type get_topology_cpu_type(struct cpuinfo_x86 *c);
 
@@ -259,6 +261,7 @@ extern bool x86_topology_update;
 
 #ifdef CONFIG_SCHED_MC_PRIO
 #include <asm/percpu.h>
+#include <linux/cache.h>
 
 DECLARE_PER_CPU_READ_MOSTLY(int, sched_core_priority);
 extern bool __read_mostly sysctl_sched_itmt_enabled;
Signature · 1 line
2.53.0
author maintainer
#722 lore raw

PATCH 1/1 drm/dp: Add DSC virtual DPCD quirk for Realtek MST branch device

In reply to Sasha Levin

From: Imre Deak <[email protected]>

[ Upstream commit bff2da7aa0020eb72e42d63868dc5adaa0fb85d3 ]

The ASUS DC301 USB-C dock containing a Realtek MST branch device supports the DSC decompression functionality on each of the dock's downstream connectors, even though there is no discoverable peer-to-peer virtual device in the MST topology (which the DP Standard requires/suggests to control the DSC functionality on a per-DFP basis). Add the DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD quirk for this branch device as well to enable the DSC decompression functionality on all DFP connectors of the dock, similarly to how this is done for dock's containing older Synaptics branch devices.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: drm/dp DSC virtual DPCD quirk for Realtek MST

**Local tree:** Linux **6.18.44** (git describe HEAD → v6.18.44)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject line
**Record:** [drm/dp] [Add] — Add DSC virtual DPCD quirk for Realtek MST branch device

### Step 1.2: Tags
**Record:**

| Tag | Value |
|-----|-------|
| Cc: | Lyude Paul \<[email protected]\> |
| Reported-and-tested-by: | Shawn C Lee \<[email protected]\> |
| Reviewed-by: | Mika Kahola \<[email protected]\> |
| Reviewed-by: | Lyude Paul \<[email protected]\> |
| Signed-off-by: | Imre Deak \<[email protected]\> (author SOB; ignore
pipeline SOBs) |
| Link: |
https://patch.msgid.link/[email protected] |

**Notable patterns:** Real hardware reporter+tester; two Reviewed-by including DRM maintainer Lyude Paul. No syzbot, no Fixes: tag (expected for manual review).

### Step 1.3: Body analysis
**Record:**
- **Bug:** ASUS DC301 USB-C dock (Realtek MST branch, OUI 0x00:e0:4c) supports DSC decompression on downstream connectors but does not expose discoverable peer-to-peer virtual DPCD devices as the DP standard expects for per-DFP DSC control.
- **Symptom:** DSC decompression cannot be enabled on the dock's downstream display outputs; high-bandwidth modes that require DSC will fail or fall back incorrectly.
- **Root cause:** Kernel only applies the DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD workaround to Synaptics (0x90:CC:24) MST hubs, not Realtek.
- **Fix approach:** Add Realtek branch-device quirk entry matching OUI 0x00, 0xe0, 0x4c and device ID 'Dp1.4'.

### Step 1.4: Hidden bug fix?
**Record:** Yes — described as "Add quirk" but it fixes broken display functionality on a specific USB-C dock. This is a hardware quirk/workaround, not a cosmetic change.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Inventory
**Record:**
- **Files:** drivers/gpu/drm/display/drm_dp_helper.c (+2 lines)
- **Functions modified:** None directly; dpcd_quirk_list[] static table only
- **Scope:** Single-file, surgical quirk-table addition

### Step 2.2: Code flow change
**Record:**
- **Hunk (quirk table):** Before → only Synaptics MST hubs matched DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD. After → Realtek DP1.4 MST branch devices (OUI 0x00:e0:4c, device ID Dp1.4, is_branch=true) also get the quirk bit set when drm_dp_get_quirks() runs during drm_dp_read_desc().

### Step 2.3: Bug mechanism
**Record:** **Category (h): Hardware workaround**

Without the quirk, drm_dp_mst_dsc_aux_for_port() in drm_dp_mst_topology.c does not find a valid DSC aux for Realtek MST dock ports:

```6159:6176:drivers/gpu/drm/display/drm_dp_mst_topology.c
        if (drm_dp_has_quirk(&desc,
DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD)) {
                // ... reads DSC caps from physical upstream aux ...
                        return immediate_upstream_aux;
        }
```

When this returns NULL, i915 sets connector->dp.dsc_decompression_aux = NULL at MST connector creation, and amdgpu similarly gets no dsc_aux. DSC decompression is never enabled on dock downstream connectors.

### Step 2.4: Fix quality
**Record:** Obviously correct — mirrors the proven Synaptics quirk (added 2019, commit 5b03f9d8688071). Uses a specific device ID ('Dp1.4') rather than DEVICE_ID_ANY, limiting scope. **Regression risk:** Very low; only affects devices matching Realtek OUI + exact device ID on branch devices.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
**Record:** Synaptics DSC_WITHOUT_VIRTUAL_DPCD entry introduced by Mikita Lipski, 2019-09-20 (5b03f9d8688071). Quirk infrastructure and drm_dp_mst_dsc_aux_for_port() logic are ancestors of HEAD and present in 6.18.44. Realtek entry is **not** in this tree.

### Step 3.2: Fixes: tag
**Record:** N/A — no Fixes: tag in commit message.

### Step 3.3: Related file history
**Record:** Recent drm_dp_helper.c changes are unrelated (backlight, AUX probe address). No competing fix for Realtek DSC. Standalone single- patch fix.

### Step 3.4: Author context
**Record:** Imre Deak is an active Intel DRM contributor; prior commits to this file include Synaptics HBLANK-expansion and MediaTek DSC quirks — same subsystem and pattern.

### Step 3.5: Dependencies
**Record:** **No dependencies.** Requires only:
- DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD enum (present in include/drm/display/drm_dp_helper.h)
- drm_dp_mst_dsc_aux_for_port() quirk handling (present in drm_dp_mst_topology.c)
- dpcd_quirk_list[] table (present in drm_dp_helper.c)

All verified present in 6.18.44.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original discussion
**Record:** b4 dig -c <commit> could not run — commit is not in this tree (no commitish available). WebFetch of patch link and lore.kernel.org blocked by Anubis bot protection. **UNVERIFIED:** full mailing-list thread content.

### Step 4.2: Reviewers
**Record:** Commit message confirms Lyude Paul (DRM maintainer) and Mika Kahola reviewed. Cc'd Lyude Paul.

### Step 4.3: Bug report
**Record:** Reported-and-tested-by Shawn C Lee (Intel) on ASUS DC301 USB-C dock hardware. No syzbot/CVE.

### Step 4.4: Series context
**Record:** Standalone 1-patch fix, not part of a series.

### Step 4.5: Stable list history
**Record:** **UNVERIFIED** — could not access lore stable archive due to bot protection.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key functions
**Record:** Modified indirectly via quirk table lookup in drm_dp_get_quirks() → consumed by drm_dp_has_quirk() → used in drm_dp_mst_dsc_aux_for_port().

### Step 5.2: Callers
**Record:** drm_dp_mst_dsc_aux_for_port() called from:
- intel_dp_mst.c — MST connector probe (connector->dp.dsc_decompression_aux)
- amdgpu_dm_mst_types.c — validate_dsc_caps_on_connector()
- drm_dp_mst_topology.c — drm_dp_mst_add_affected_dsc_crtcs()

All are MST hotplug/enumeration and atomic modeset paths — reachable when a user plugs in a USB-C dock.

### Step 5.3: Callees
**Record:** Quirk path reads DPCD via drm_dp_read_desc(), drm_dp_dpcd_read_data(), drm_dp_read_dpcd_caps() — standard AUX reads, no new kernel APIs.

### Step 5.4: Reachability
**Record:** Triggered by plugging ASUS DC301 (or other matching Realtek MST branch) into a DP MST-capable GPU. Userspace display configuration is the entry point. Affects i915 and amdgpu MST users.

### Step 5.5: Similar patterns
**Record:** Identical pattern to Synaptics quirk at line 2538–2539. Same author added related Synaptics/MediaTek DSC quirks in this file.

---

## PHASE 6: CROSS-REFERENCE AGAINST LOCAL TREE (6.18.44)

### Step 6.1: Buggy code exists?
**Record:** **YES.** The quirk table has Synaptics entry but lacks Realtek entry. The DSC_WITHOUT_VIRTUAL_DPCD handling code exists and would work once the table entry is added. Bug affects users of Realtek MST docks on kernels ≥6.18.44 (and any earlier kernel with the Synaptics quirk but not Realtek).

### Step 6.2: Backport complications
**Record:** **Clean apply.** patch -p1 --dry-run succeeded with fuzz 1 (offset 1 line) against current drm_dp_helper.c. No structural conflicts.

### Step 6.3: Related fixes already present?
**Record:** Synaptics DSC_WITHOUT_VIRTUAL_DPCD quirk is present (5b03f9d8688071 is ancestor of HEAD). No Realtek equivalent found (grep for 0x00, 0xe0, 0x4c in quirk table: no match).

---

## PHASE 7: SUBSYSTEM CONTEXT

### Step 7.1: Subsystem criticality
**Record:** **drivers/gpu/drm/display** — IMPORTANT. Affects display output through USB-C/MST docks on Intel and AMD GPUs.

### Step 7.2: Activity
**Record:** Actively maintained; recent commits in drm_dp_helper.c and drm_dp_mst_topology.c within this stable cycle.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Who is affected
**Record:** Users of Realtek MST branch USB-C docks (specifically
tested: ASUS DC301) connected via DP MST to Intel/AMD GPUs with DSC- capable outputs. Config-dependent: CONFIG_DRM, MST, DSC support.

### Step 8.2: Trigger conditions
**Record:** Plug dock into MST-capable port; attempt modes requiring DSC decompression on downstream connectors. Not timing-dependent; deterministic hardware identification failure. Unprivileged users can trigger via normal display hotplug.

### Step 8.3: Failure mode severity
**Record:** **MEDIUM** — DSC decompression disabled → high- resolution/high-refresh modes through dock may not work or may not use optimal compression. Not a kernel crash, oops, or data corruption, but real functional breakage on production hardware.

### Step 8.4: Risk-benefit
**Record:**
- **Benefit:** Enables DSC on Realtek MST docks; restores display functionality matching hardware capability. Tested on real hardware.
- **Risk:** Minimal — 2-line quirk entry, narrowly matched by OUI + device ID + branch flag.
- **Ratio:** Strong benefit for affected hardware, negligible risk.

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence summary

**FOR backport:**
- Hardware quirk — explicit stable exception category
- Fixes real, tested bug on ASUS DC301 USB-C dock
- 2-line, surgical change using existing infrastructure
- Reviewed by DRM maintainer (Lyude Paul)
- Mirrors proven Synaptics quirk (in tree since 2019)
- Applies cleanly to 6.18.44
- No new APIs, no refactoring

**AGAINST backport:**
- Display functionality issue, not crash/security/corruption
- Affects narrow hardware population (Realtek MST docks)
- Mailing-list discussion not independently verified

**UNRESOLVED:**
- Full lore thread content (bot protection)
- Whether other Realtek device IDs beyond 'Dp1.4' need the same quirk

### Step 9.2: Stable rules checklist

| Criterion | Result |
|-----------|--------|
| 1. Obviously correct and tested? | **PASS** — mirrors Synaptics;
Reported-and-tested-by on real hardware; maintainer reviewed |
| 2. Fixes a real bug affecting users? | **PASS** — DSC broken on
Realtek MST dock downstream ports |
| 3. Important issue? | **PASS** (hardware quirk) — display modes broken
on affected dock; not crash-level but real user impact |
| 4. Small and contained? | **PASS** — 2 lines, one file |
| 5. No new features/APIs? | **PASS** — quirk table entry only |
| 6. Can apply to local tree? | **PASS** — clean apply with fuzz 1 |

### Step 9.3: Exception category
**Record:** **Hardware quirk/workaround** — directly matches the stable exception for device-specific quirks that fix real-world hardware issues.

### Step 9.4: Decision rationale

This commit adds a Realtek MST branch device to the existing DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD quirk table. All handling code already exists in 6.18.44 (introduced for Synaptics docks in 2019). Without this entry, DSC decompression is silently unavailable on Realtek MST USB-C docks such as the ASUS DC301, breaking display functionality on downstream connectors.

This is textbook stable material: a small, maintainer-reviewed hardware quirk that enables existing functionality on real hardware, with no API changes and negligible regression risk.

---

## Verification

- **[Phase 1]** Parsed subject, tags, body from user-provided commit message
- **[Phase 2]** Diff analysis: +2 lines to dpcd_quirk_list[] in drm_dp_helper.c
- **[Phase 2]** Read drm_dp_mst_dsc_aux_for_port() quirk handling at lines 6159–6176
- **[Phase 2]** Read drm_dp_get_quirks() matching logic at lines 2558–2583
- **[Phase 3]** git describe HEAD → v6.18.44; Makefile confirms 6.18.44
- **[Phase 3]** git blame on lines 2535–2545: Synaptics quirk from 5b03f9d8688071 (2019)
- **[Phase 3]** git merge-base --is-ancestor 5b03f9d8688071 HEAD → prerequisite commit present
- **[Phase 3]** git log --grep="DSC virtual DPCD quirk for Realtek" → no results (commit not in tree)
- **[Phase 4]** b4 dig requires commitish not available in tree — **UNVERIFIED**
- **[Phase 4]** WebFetch of patch link and lore.kernel.org — blocked by Anubis — **UNVERIFIED**
- **[Phase 5]** grep drm_dp_mst_dsc_aux_for_port → callers in i915, amdgpu, drm_dp_mst_topology.c
- **[Phase 5]** Read intel_dp_mst.c:1745 — dsc_decompression_aux = drm_dp_mst_dsc_aux_for_port(port)
- **[Phase 5]** Read amdgpu_dm_mst_types.c:276 — same pattern
- **[Phase 6]** grep "0x00, 0xe0, 0x4c" in quirk table → no match (bug present, fix absent)
- **[Phase 6]** grep DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD → enum and usage confirmed in tree
- **[Phase 6]** patch -p1 --dry-run on constructed patch → succeeds with fuzz 1
- **[Phase 7]** Subsystem: drivers/gpu/drm/display — DRM display helper
- **[Phase 8]** Failure mode: DSC unavailable on dock ports — MEDIUM severity, real hardware impact

**YES**The background checks finished:

- **Tree:** Linux **6.18.44** (v6.18.44)
- **Commit search:** No match for the Realtek DSC quirk commit in this tree — it isn’t applied here yet
- **Prerequisites:** The Synaptics DSC_WITHOUT_VIRTUAL_DPCD quirk and handling code are present; only the Realtek table entry is missing

That matches the earlier analysis: this is a small hardware quirk that should be backported to this tree.

**YES**

 drivers/gpu/drm/display/drm_dp_helper.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/display/drm_dp_helper.c +2 -0
index 8c858ba40c6c6..77336bc3e62c2 100644
@@ -2537,6 +2537,8 @@ static const struct dpcd_quirk dpcd_quirk_list[] = {
 	{ OUI(0x00, 0x00, 0x00), DEVICE_ID('C', 'H', '7', '5', '1', '1'), false, BIT(DP_DPCD_QUIRK_NO_SINK_COUNT) },
 	/* Synaptics DP1.4 MST hubs can support DSC without virtual DPCD */
 	{ OUI(0x90, 0xCC, 0x24), DEVICE_ID_ANY, true, BIT(DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD) },
+	/* Realtek DP1.4 MST hubs can support DSC without virtual DPCD */
+	{ OUI(0x00, 0xe0, 0x4c), DEVICE_ID('D', 'p', '1', '.', '4', 0), true, BIT(DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD) },
 	/* Synaptics DP1.4 MST hubs require DSC for some modes on which it applies HBLANK expansion. */
 	{ OUI(0x90, 0xCC, 0x24), DEVICE_ID_ANY, true, BIT(DP_DPCD_QUIRK_HBLANK_EXPANSION_REQUIRES_DSC) },
 	/* MediaTek panels (at least in U3224KBA) require DSC for modes with a short HBLANK on UHBR links. */
Signature · 1 line
2.53.0
author maintainer
#723 lore raw

PATCH 1/1 i3c: mipi-i3c-hci: Tolerate i3c_master_add_i3c_dev_locked() failures in DAA

In reply to Sasha Levin

From: Adrian Hunter <[email protected]>

[ Upstream commit c236563c8a84239d31a1e6ec4444887a7b5ed98f ]

i3c_master_add_i3c_dev_locked() no longer leaves the address marked as free on failure, so aborting the DAA sequence on its error is unnecessary.

Failure to register a discovered device does not invalidate the entire Dynamic Address Assignment (DAA) procedure. Align with the behavior of other I3C master drivers by ignoring errors from i3c_master_add_i3c_dev_locked() and continuing enumeration.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit Message Forensics

### Step 1.1: Subject Line
**Record:** [i3c: mipi-i3c-hci] [Tolerate] — Stop aborting DAA when i3c_master_add_i3c_dev_locked() fails; continue enumeration instead.

### Step 1.2: Tags
**Record:**
- **Signed-off-by:** Adrian Hunter <[email protected]> (author)
- **Reviewed-by:** Frank Li <[email protected]> (NXP I3C maintainer)
- **Link:** https://patch.msgid.link/20260612080107.11606-5-
[email protected]
- **Signed-off-by:** Alexandre Belloni <[email protected]> (I3C subsystem maintainer)
- No Fixes:, Reported-by:, Tested-by:, Cc: stable, or syzbot tags
- Notable: Reviewed by subsystem expert; part of V4 4/7 series

### Step 1.3: Body Analysis
**Record:**
- **Bug:** mipi-i3c-hci aborts the entire DAA loop when i3c_master_add_i3c_dev_locked() fails for one device.
- **Symptom:** Remaining I3C devices on the bus are never enumerated/registered after a single device-add failure.
- **Root cause (per author):** After commit 38d3d33 ("Prevent reuse of dynamic address on device add failure"), failed registration no longer frees the address slot, so aborting DAA is unnecessary and harmful.
- **Fix approach:** Ignore the return value and continue DAA, matching svc-i3c-master, cdns, renesas, dw, and adi drivers.
- No explicit kernel version range in message.

### Step 1.4: Hidden Bug Fix Detection
**Record:** Yes — described as alignment/cleanup, but it fixes a real logic bug: premature DAA termination leaves devices undiscovered. Same class of bug fixed in svc-i3c-master (commit 3b2ac810, Cc: stable).

---

## Phase 2: Diff Analysis

### Step 2.1: Inventory
**Record:**
- drivers/i3c/master/mipi-i3c-hci/cmd_v1.c: −3 lines (remove ret check
+ break)
- drivers/i3c/master/mipi-i3c-hci/cmd_v2.c: −3 lines (same)
- Functions: hci_cmd_v1_daa(), hci_cmd_v2_daa()
- Scope: single-file surgical fix in one driver (2 command variants)

### Step 2.2: Code Flow Change
**Record:**
- **Hunk 1 (cmd_v1.c):** Before: assign address via hardware DAA → call i3c_master_add_i3c_dev_locked() → on error, break out of DAA loop. After: call function without checking return; loop continues to next device.
- **Hunk 2 (cmd_v2.c):** Identical behavioral change in v2 DAA path.
- Affected path: normal DAA enumeration loop during bus probe / hot- join.

### Step 2.3: Bug Mechanism
**Record:**
- **Category:** Logic/correctness fix (error-path handling)
- **Mechanism:** Treating a per-device registration failure as fatal to the entire multi-device DAA sequence. With prerequisite 38d3d33, the address is retained on failure, so continuing is safe. Aborting prevents registration of subsequently discovered devices.

### Step 2.4: Fix Quality
**Record:** Obviously correct — matches established pattern in five other I3C master drivers. Minimal change. Low regression risk: only removes an overly aggressive early-exit; real bus/transfer errors still break the loop via RESP_STATUS checks.

---

## Phase 3: Git History Investigation

### Step 3.1: Blame
**Record:** Buggy if (ret) break; pattern introduced in 9ad9a52cce282 (Nov 2020, "i3c/master: introduce the mipi-i3c-hci driver"). Present since driver introduction.

### Step 3.2: Fixes: Tag
**Record:** N/A — no Fixes: tag. Prerequisite identified from commit
message: 38d3d33bf42c2 / upstream b3ba8383da4d0 ("Prevent reuse of dynamic address on device add failure"), which changes i3c_master_add_i3c_dev_locked() to mark addresses as occupied on failure via err_prevent_addr_reuse. **Confirmed present in this tree** (git merge-base --is-ancestor passes).

### Step 3.3: Related File History
**Record:** Recent related commits in tree:
- 38d3d33 — prerequisite (already backported to 6.18.y)
- 3b2ac810 — svc driver: identical "don't check return value" fix (in tree, Cc: stable)
- Fix commit c236563c8a842 is in mainline but **not yet in this 6.18.44 checkout**

### Step 3.4: Author Context
**Record:** Adrian Hunter is an active Intel I3C contributor. Multiple related fixes in drivers/i3c/ around DAA, hot-join, and address management (Jun 2026 series).

### Step 3.5: Dependencies
**Record:**
- **Hard dependency:** 38d3d33 (already in tree) — without it, continuing DAA after failure could reassign addresses.
- **Not required:** Patches 1/7 (race fix), 2/7 (DISEC), 5–7/7 (return- void API change + reconciliation — **not merged to mainline**).
- **Standalone:** Yes, for stable purposes, given prerequisite is present.

---

## Phase 4: Mailing List and External Research

### Step 4.1: Original Discussion
**Record:**
- **URL:** https://patch.msgid.link/20260612080107.11606-5-
[email protected]
- **Series:** V1→V4, patch 4/7; applied version is latest (V4)
- **Cover letter (V4 0/7):** "Patches 3-7 fix address management issues... when DAA does not complete cleanly"
- **Reviewer feedback:** "Applied, thanks!" from maintainer on cover letter
- No explicit stable nomination found in mbox for this specific patch

### Step 4.2: Reviewers
**Record:** CC'd: [email protected], [email protected], [email protected], [email protected]. Reviewed-by Frank Li (NXP).

### Step 4.3: Bug Report
**Record:** No external bug report or syzbot link. Bug identified through code review / series development. Precedent: 3b2ac810 documented identical failure mode for svc driver with explicit I3C spec violation scenario.

### Step 4.4: Related Patches
**Record:** Part of 7-patch V4 series. Patches 5–7 (API change to void return + post-DAA reconciliation) were **not** merged upstream. This patch was merged standalone with patch 3.

### Step 4.5: Stable List History
**Record:** No stable-list discussion found for this specific patch. Prerequisite 38d3d33 was backported to this tree (has upstream-commit marker and Greg K commit).

---

## Phase 5: Code Semantic Analysis

### Step 5.1: Key Functions
**Record:** hci_cmd_v1_daa(), hci_cmd_v2_daa(), called via i3c_hci_daa() in core.c.

### Step 5.2: Callers
**Record:** i3c_hci_daa() → registered as master->ops.do_daa → invoked by i3c_master_do_daa() / i3c_master_do_daa_ext() during bus initialization and hot-join DAA. Called during device probe, not a hot syscall path.

### Step 5.3: Callees
**Record:** i3c_master_add_i3c_dev_locked() — allocates device, retrieves CCC info, attaches to bus. On failure (with 38d3d33): logs error, marks address slot occupied, returns error code.

### Step 5.4: Reachability
**Record:** Triggered during I3C bus enumeration on systems using mipi-i3c-hci (Intel and other MIPI HCI platforms). Multi-device buses are common (sensors, PMICs, etc.). Failure of one device's registration is plausible (transient CCC errors, firmware quirks).

### Step 5.5: Similar Patterns
**Record:** All other I3C master drivers ignore i3c_master_add_i3c_dev_locked() return during DAA:

```1224:1225:drivers/i3c/master/svc-i3c-master.c
        for (i = 0; i < dev_nb; i++)
                i3c_master_add_i3c_dev_locked(m, addrs[i]);
```

Same pattern in renesas-i3c.c, i3c-master-cdns.c, dw-i3c-master.c, adi-i3c-master.c. mipi-i3c-hci is the only outlier.

---

## Phase 6: Cross-Reference Against Local Tree

### Step 6.1: Buggy Code Exists?
**Record:** **Yes.** Local tree is **linux-6.18.y** (v6.18.44). Both cmd_v1.c:365-367 and cmd_v2.c:303-305 still have ret = i3c_master_add_i3c_dev_locked(...); if (ret) break;. Bug present since driver introduction (2020).

### Step 6.2: Backport Complications
**Record:** **Clean apply.** git cherry-pick --no-commit c236563c8a842 auto-merged both files without conflicts.

### Step 6.3: Related Fixes Already Present? **Record:**
- Prerequisite 38d3d33 — **present**
- Svc driver equivalent fix 3b2ac810 — **present**
- This specific mipi-i3c-hci fix — **not present**

---

## Phase 7: Subsystem and Maintainer Context

### Step 7.1: Subsystem Criticality
**Record:** drivers/i3c/master/mipi-i3c-hci/ — **IMPORTANT** (bus driver affecting all I3C peripherals on HCI-based platforms, but hardware-specific).

### Step 7.2: Subsystem Activity
**Record:** Actively maintained — multiple mipi-i3c-hci fixes in 6.18.y (hot-join, DMA, IRQ handling).

---

## Phase 8: Impact and Risk Assessment

### Step 8.1: Who Is Affected
**Record:** Users of CONFIG_I3C with mipi-i3c-hci hardware and multiple I3C devices on the bus.

### Step 8.2: Trigger Conditions
**Record:** DAA discovers ≥2 devices; i3c_master_add_i3c_dev_locked() fails for an early device (allocation failure, CCC retrieval error, duplicate handling, etc.). Not timing-dependent. Requires CONFIG_I3C + mipi-i3c-hci. Unprivileged users cannot directly trigger, but affects system hardware functionality at boot/probe.

### Step 8.3: Failure Mode Severity
**Record:** Subsequent I3C devices fail to register — sensors/peripherals missing, potential bus state inconsistency (hardware has address assigned, kernel unaware). **Severity: MEDIUM-HIGH** for affected hardware (functional failure, not kernel crash). Pre-38d3d33, could also cause address conflicts on hot-join (documented in svc fix); that part is fixed, but partial enumeration remains.

### Step 8.4: Risk-Benefit
**Record:**
- **Benefit:** HIGH for affected platforms — restores multi-device enumeration; completes behavior change started by 38d3d33 backport
- **Risk:** VERY LOW — 6-line total removal, matches five other drivers, prerequisite already in tree
- **Ratio:** Strong benefit, minimal risk

---

## Phase 9: Final Synthesis

### Step 9.1: Evidence Summary

**FOR backport:**
- Real functional bug with documented precedent (3b2ac810, Cc: stable)
- Prerequisite 38d3d33 already in 6.18.y
- Surgical 6-line fix, reviewed by NXP maintainer
- Applies cleanly
- Aligns mipi-i3c-hci with all other I3C master drivers
- Completes address-management fix series partially backported to stable

**AGAINST backport:**
- No crash, security issue, or data corruption
- Hardware-specific (mipi-i3c-hci only)
- Requires i3c_master_add_i3c_dev_locked() failure (not everyday, but plausible)
- Part of larger series (but this patch is self-contained with prerequisite)

**Unresolved:** No user bug report or syzbot reproduction; impact inferred from code analysis and svc-driver precedent.

### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **PASS** — matches established driver pattern; Reviewed-by Frank Li
2. Fixes a real bug? **PASS** — premature DAA abort leaves devices undiscovered
3. Important issue? **PASS** — functional hardware failure on multi- device I3C buses (MEDIUM-HIGH for affected users)
4. Small and contained? **PASS** — 2 files, 6 lines removed
5. No new features/APIs? **PASS** — behavior alignment only
6. Can apply to local tree? **PASS** — clean cherry-pick; prerequisite present

### Step 9.3: Exception Categories
**Record:** N/A — not a device ID, quirk, DT, build, or docs fix. Standard driver bug fix.

### Step 9.4: Decision Rationale
This fix should be backported to **linux-6.18.y** because the prerequisite commit changing i3c_master_add_i3c_dev_locked() failure semantics is already in the tree, but mipi-i3c-hci still aborts DAA on registration failure — leaving subsequent devices undiscovered. The identical issue was fixed and stable-nominated for the svc driver. This is the companion fix for the HCI driver, small and low-risk.

---

## Verification

- [Phase 1] git show c236563c8a842: parsed subject, tags, body
- [Phase 2] Diff: 2 files, hci_cmd_v1_daa/hci_cmd_v2_daa, 6 lines removed
- [Phase 3] git blame cmd_v1.c:365-367: introduced 9ad9a52 (2020)
- [Phase 3] git merge-base --is-ancestor 38d3d33bf42c2 HEAD:
prerequisite present
- [Phase 3] git show 38d3d33: err_prevent_addr_reuse handler confirmed
- [Phase 3] git show 3b2ac810: svc driver identical fix with Cc:
stable
- [Phase 3] git merge-base --is-ancestor 3b2ac810 HEAD: svc fix in tree
- [Phase 4] b4 dig -c c236563c8a842: lore URL found
- [Phase 4] b4 dig -a: V1–V4 series, patch 4/7
- [Phase 4] b4 dig -w: maintainers CC'd
- [Phase 4] /tmp/i3c_daa.mbox: cover letter, patches 1–7 subjects; patch 7 not merged upstream
- [Phase 5] grep i3c_master_add_i3c_dev_locked drivers/i3c/master/: 5 other drivers ignore return
- [Phase 5] core.c:266-270: i3c_hci_daa → perform_daa call chain
- [Phase 6] git describe HEAD: v6.18.44 (linux-6.18.y)
- [Phase 6] Read cmd_v1.c:365-367, cmd_v2.c:303-305: buggy code present
- [Phase 6] git cherry-pick --no-commit c236563c8a842: clean apply
- [Phase 6] git log HEAD..c236563c8a842 -- drivers/i3c/master/mipi-i3c-hci/: fix not in tree
- [Phase 7] git log -20 -- drivers/i3c/master/mipi-i3c-hci/: active subsystem
- [Phase 8] Read svc-i3c-master.c:1205-1225: documented failure mode

**YES**

 drivers/i3c/master/mipi-i3c-hci/cmd_v1.c | 4 +---
 drivers/i3c/master/mipi-i3c-hci/cmd_v2.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)
drivers/i3c/master/mipi-i3c-hci/cmd_v1.c +1 -3
index efb7a1f92641c..b6ba18ccdd2d3 100644
@@ -362,9 +362,7 @@ static int hci_cmd_v1_daa(struct i3c_hci *hci)
 		 * TODO: Extend the subsystem layer to allow for registering
 		 * new device and provide BCR/DCR/PID at the same time.
 		 */
-		ret = i3c_master_add_i3c_dev_locked(&hci->master, next_addr);
-		if (ret)
-			break;
+		i3c_master_add_i3c_dev_locked(&hci->master, next_addr);
 	}
 
 	if (dat_idx >= 0)
drivers/i3c/master/mipi-i3c-hci/cmd_v2.c +1 -3
index 5fc2e4c55ebb0..d7999d341a227 100644
@@ -300,9 +300,7 @@ static int hci_cmd_v2_daa(struct i3c_hci *hci)
 		 * TODO: Extend the subsystem layer to allow for registering
 		 * new device and provide BCR/DCR/PID at the same time.
 		 */
-		ret = i3c_master_add_i3c_dev_locked(&hci->master, next_addr);
-		if (ret)
-			break;
+		i3c_master_add_i3c_dev_locked(&hci->master, next_addr);
 	}
 
 	hci_free_xfer(xfer, 2);
Signature · 1 line
2.53.0
#724 lore raw

Re: [PATCH AUTOSEL 6.18-5.15] i3c: mipi-i3c-hci: Tolerate i3c_master_add_i3c_dev_locked() failures in DAA

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] Missing prerequisite commit causes duplicate I3C dynamic address assignments.

Pre-existing issues:
- [Critical] Missing reinit_completion() in DAA loop leads to Use-After-Free of 'xfer' and stack corruption. --

commit 832ce28e7937a4fe5df00bb4a2c81e5ebbcd17da
Author: Adrian Hunter <[email protected]>

i3c: mipi-i3c-hci: Tolerate i3c_master_add_i3c_dev_locked() failures in DAA

This commit modifies the MIPI I3C HCI driver to ignore errors from i3c_master_add_i3c_dev_locked() during Dynamic Address Assignment (DAA). Instead of aborting the sequence on failure, it continues enumeration to align with the behavior of other I3C master drivers.

drivers/i3c/master/mipi-i3c-hci/cmd_v1.c static int hci_cmd_v1_daa(struct i3c_hci *hci) · line 365

Quoted 12 lines
drivers/i3c/master/mipi-i3c-hci/cmd_v1.c +1 -3
index eb8a3ae2990d7..50290dfbe47dc 100644
@@ -362,9 +362,7 @@ static int hci_cmd_v1_daa(struct i3c_hci *hci)
 		 * TODO: Extend the subsystem layer to allow for registering
 		 * new device and provide BCR/DCR/PID at the same time.
 		 */
-		ret = i3c_master_add_i3c_dev_locked(&hci->master, next_addr);
-		if (ret)
-			break;
+		i3c_master_add_i3c_dev_locked(&hci->master, next_addr);

[Severity: Critical]
This isn't a bug introduced by this patch, but does the lack of a reinit_completion() call in this loop lead to a use-after-free and stack corruption?

Earlier in hci_cmd_v1_daa(), wait_for_completion_timeout() is called on the stack-allocated completion:

	if (!wait_for_completion_timeout(&done, HZ) &&
	    hci->io->dequeue_xfer(hci, xfer, 1)) {
		ret = -ETIME;
		break;
	}

If the timeout expires while the hardware completes concurrently, dequeue_xfer() returns false and the loop continues, but the completion counter remains at 1.

In the next iteration, wait_for_completion_timeout() will return immediately without waiting. The loop will process stale data and eventually exit, freeing the xfer and destroying the completion on the stack, all while the hardware DMA is actively processing the second transfer. Upon completion, the IRQ handler will access the freed xfer and corrupt the stack.

[Severity: High]
Will removing this error check cause duplicate I3C dynamic address assignments because a prerequisite commit is missing from this tree?

This change assumes the presence of upstream commit b3ba8383da4d0 ("i3c:
master: Prevent reuse of dynamic address on device add failure") which ensures the address slot remains occupied on failure.

However, that prerequisite commit is missing from this branch. As a result, if i3c_master_add_i3c_dev_locked() fails, the error path in drivers/i3c/master.c will detach the device and free the dynamic address:

	err_detach_dev:
		if (newdev->dev && newdev->dev->desc)
			newdev->dev->desc = NULL;

		i3c_master_detach_i3c_dev(newdev);

Because the loop now continues instead of breaking, it will allocate this exact same dynamic address again and program it into the hardware of the next physical device, resulting in multiple I3C devices responding to the same address.

Quoted 8 lines
drivers/i3c/master/mipi-i3c-hci/cmd_v1.c +0 -0
 	}
 
 	if (dat_idx >= 0)
drivers/i3c/master/mipi-i3c-hci/cmd_v2.c +0 -0
index efb4326a25b73..d3896ee93b5e3 100644

drivers/i3c/master/mipi-i3c-hci/cmd_v2.c static int hci_cmd_v2_daa(struct i3c_hci *hci) · line 303

Quoted 7 lines
drivers/i3c/master/mipi-i3c-hci/cmd_v2.c +1 -3
@@ -300,9 +300,7 @@ static int hci_cmd_v2_daa(struct i3c_hci *hci)
 		 * TODO: Extend the subsystem layer to allow for registering
 		 * new device and provide BCR/DCR/PID at the same time.
 		 */
-		ret = i3c_master_add_i3c_dev_locked(&hci->master, next_addr);
-		if (ret)
-			break;
+		i3c_master_add_i3c_dev_locked(&hci->master, next_addr);

[Severity: Critical]
This is a pre-existing issue, but does the same missing reinit_completion() logic error apply to the v2 DAA path?

Like hci_cmd_v1_daa(), the loop here in hci_cmd_v2_daa() waits on the same completion object:

	if (!wait_for_completion_timeout(&done, HZ) &&
	    hci->io->dequeue_xfer(hci, xfer, 2)) {
		ret = -ETIME;
		break;
	}

A timeout racing with an IRQ completion will desynchronize the completion counter, causing subsequent iterations to return immediately. This will eventually lead to a use-after-free of the xfer and stack corruption when the hardware DMA finishes.

[Severity: High]
Will ignoring the error here also cause address collisions on the I3C bus?

Since this tree lacks the upstream b3ba8383da4d0 prerequisite, any failure in i3c_master_add_i3c_dev_locked() will free the address. The next loop iteration will then reallocate the exact same address to a different device, leading to severe hardware bus conflicts.

Quoted 3 lines
drivers/i3c/master/mipi-i3c-hci/cmd_v2.c +0 -0
 	}
 
 	hci_free_xfer(xfer, 2);
Signature · 6 lines
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1

-- 
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
author maintainer
#725 lore raw

PATCH 1/1 wifi: iwlwifi: mvm: fix out-of-bounds tid_data access in BA notif

In reply to Sasha Levin

From: Emmanuel Grumbach <[email protected]>

[ Upstream commit 94d3982806c7f194b23484befde12934dda23064 ]

mvmsta->tid_data was indexed by the TFD loop counter 'i' instead of the actual TID value 'tid'. This writes lq_color into a random tid_data slot unrelated to the BA entry.
Since multi-TID blockack is not really in use, 'i' was always 0 and no harm was done.
Add a out-of-bound check before accessing the array.

---

LLM Generated explanations, may be completely bogus:

The background git history searches finished. This checkout has full history (~11,945 commits), but git log -S for both compressed_ba_notif and tid_data[i].lq_color only surfaces the v6.18 import merge (5d324e5159d9e), so the exact commit that introduced the bug couldn't be isolated from history alone.

That doesn't change the conclusion: the buggy line is present at tx.c:2141 in v6.18.44, and the fix remains a good stable backport candidate.

**YES**

 drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/tx.c +7 -1
index ebb201bd23d85..eab3f7184b49b 100644
@@ -2171,8 +2171,14 @@ void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
 			if (tid == IWL_MGMT_TID)
 				tid = IWL_MAX_TID_COUNT;
 
+			if (IWL_FW_CHECK(mvm, tid >=
+					 ARRAY_SIZE(mvmsta->tid_data),
+					 "invalid TID %d in compressed BA\n",
+					 tid))
+				continue;
+
 			if (mvmsta)
-				mvmsta->tid_data[i].lq_color = lq_color;
+				mvmsta->tid_data[tid].lq_color = lq_color;
 
 			iwl_mvm_tx_reclaim(mvm, sta_id, tid,
 					   (int)(le16_to_cpu(ba_tfd->q_num)),
Signature · 1 line
2.53.0
author maintainer
#726 lore raw

PATCH 1/1 ALSA: seq: Remove arbitrary prioq insertion limit

In reply to Sasha Levin

From: Cássio Gabriel <[email protected]>

[ Upstream commit 3fcc84f1f8d28cc1966b859cef33c858ff531766 ]

The sequencer priority queue insertion path uses a hardcoded traversal limit of 10000 entries. The value is intended to catch a corrupted list, but it also becomes a real limit for valid queues.

The event pool limit is per client, while a sequencer queue can be shared by multiple clients. A queue can therefore legitimately contain more than 10000 events. In that case, inserting an event that has to be placed past the arbitrary limit fails with -EINVAL.

Use the queue's own cell count as the traversal bound instead. This keeps the protection against inconsistent list accounting or cyclic lists without rejecting valid large queues.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: ALSA: seq: Remove arbitrary prioq insertion limit

**Local tree:** Linux **6.18.44** (git describe HEAD → v6.18.44)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject Line
**Record:** [ALSA: seq] [remove] — Remove an arbitrary hardcoded traversal limit in the sequencer priority-queue insertion path.

### Step 1.2: Tags
**Record:**
- **Signed-off-by:** Cássio Gabriel <[email protected]> (author)
- **Signed-off-by:** Takashi Iwai <[email protected]> (ALSA maintainer)
- **Link:** https://patch.msgid.link/20260525-alsa-seq-prioq-
[email protected]
- **No** Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or
Cc: stable tags
- Notable: Maintainer (Iwai) sign-off; no fuzzer/user bug reports cited

### Step 1.3: Body Analysis
**Record:**
- **Bug:** snd_seq_prioq_cell_in() uses a hardcoded traversal counter of 10000 intended as corruption/loop protection, but it also caps legitimate queues.
- **Symptom:** Inserting an event that must be placed past the 10000th element returns -EINVAL with pr_err("cannot find a pointer.. infinite loop?").
- **Root cause:** Event pools are per-client (SNDRV_SEQ_MAX_EVENTS = 2000), but sequencer queues are shared across clients. Multiple clients can enqueue to the same queue, so total queue depth can exceed 10000 even when each client stays within its pool limit.
- **Fix approach:** Use f->cells (the queue's own cell count) as the traversal bound instead of 10000.

### Step 1.4: Hidden Bug Fix?
**Record:** No — this is an explicit functional bug fix, not disguised cleanup. The commit clearly describes incorrect rejection of valid events.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Inventory
**Record:**
- **File:** sound/core/seq/seq_prioq.c (+4 net lines, ~6 lines moved/restructured)
- **Function:** snd_seq_prioq_cell_in()
- **Scope:** Single-file, surgical fix

### Step 2.2: Code Flow Change
**Record:**
- **Before:** count = 10000; decrement after each list advance; error when count hits 0 while cur is still non-NULL.
- **After:** remaining = f->cells; at start of each loop iteration, post-decrement check if (remaining-- <= 0) → error with new message "inconsistent prioq cell count"; old end-of-loop count check removed.
- **Affected path:** Slow-path sorted insertion (when the tail fast-path does not apply — priority events or out-of-order timestamps).

### Step 2.3: Bug Mechanism
**Record:**
- **Category:** Logic / correctness bug (artificial operational limit)
- **Mechanism:** The 10000 bound is smaller than the legitimate maximum queue occupancy. With SNDRV_SEQ_DEFAULT_CLIENT_EVENTS = 200 and up to 192 clients sharing one queue, 51 clients each holding 200 queued events yields 10,200 events — exceeding the limit. With max pool size 2000, only 6 fully-loaded clients are needed (6 × 2000 = 12,000).

### Step 2.4: Fix Quality
**Record:**
- **Obviously correct:** Yes. f->cells is the authoritative count maintained by the prioq; a valid list traversal visits at most f->cells nodes. Post-decrement semantics (remaining-- <= 0 uses pre-decrement value) allow exactly N iterations for N existing cells, including full-list traversal for tail insertion.
- **Minimal:** Yes, no unrelated changes.
- **Regression risk:** Very low. Corrupted/cyclic lists still hit the bound and fail safely; valid large queues are no longer rejected.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
**Record:** In this tree, count = 10000 at line 165 is attributed to commit e664048784506 (Nov 2025 merge), but the file header dates to 1998–1999. The 10000 limit with /* FIXME: enough big, isn't it? */ is longstanding ALSA sequencer code, not a recent regression.

### Step 3.2: Fixes: Tag
**Record:** N/A — no Fixes: tag present.

### Step 3.3: Related File History
**Record:** Recent ALSA seq stable commits in this tree include UAF fixes, leaks, and functional fixes. Same author (Cássio Gabriel) already has 33074b1e6c18f ("ALSA: seq_oss: return full count for successful SEQ_FULLSIZE writes") backported here — a similar functional correctness fix with Iwai sign-off. The prioq fix itself is **not** yet in this tree (git log -S "inconsistent prioq cell count" returns nothing).

### Step 3.4: Author Context
**Record:** Cássio Gabriel is an active ALSA seq contributor in this tree. Takashi Iwai (subsystem maintainer) signed off.

### Step 3.5: Dependencies
**Record:** Standalone. Uses existing f->cells field and guard(spinlock_irqsave) — both present in this tree's seq_prioq.c. No series dependencies.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original Discussion
**Record:** b4 dig could not match the commit (not yet in this tree's HEAD). b4 shazam and WebFetch/curl to lore.kernel.org and patch.msgid.link were blocked (Anubis bot protection / 403). **UNVERIFIED:** Full review thread content, stable nominations in replies.

### Step 4.2: Reviewers
**Record:** **UNVERIFIED** via b4 -w. Commit message confirms Takashi Iwai (maintainer) sign-off.

### Step 4.3: Bug Report
**Record:** No external bug report referenced. Bug identified through code analysis by the author.

### Step 4.4: Series Context
**Record:** Standalone 1-patch fix; no "patch X/Y" markers.

### Step 4.5: Stable List History
**Record:** **UNVERIFIED** — lore access blocked.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key Functions
**Record:** snd_seq_prioq_cell_in() — modified.

### Step 5.2: Callers
**Record:** Called from snd_seq_enqueue_event() in sound/core/seq/seq_queue.c (lines 314, 319) for tick and real-time queues. That is reached from snd_seq_client_enqueue_event() → snd_seq_write() ioctl/write path — userspace-accessible ALSA sequencer API.

### Step 5.3: Callees
**Record:** compare_timestamp_rel(), spinlock via guard(spinlock_irqsave), pr_err().

### Step 5.4: Reachability
**Record:** Userspace applications writing sequencer events to a shared queue can trigger the slow insertion path. Reachable from /dev/snd/seq* write/ioctl by unprivileged users with sequencer access.

### Step 5.5: Similar Patterns
**Record:** seq_queue.c has a separate MAX_CELL_PROCESSES_IN_QUEUE (1000) for dispatch processing — a different code path. The prioq 10000 limit is unique to insertion traversal.

---

## PHASE 6: CROSS-REFERENCING AGAINST LOCAL TREE

### Step 6.1: Buggy Code Present?
**Record:** **Yes.** count = 10000; /* FIXME: enough big, isn't it? */ confirmed at line 165 of sound/core/seq/seq_prioq.c in v6.18.44.

### Step 6.2: Backport Complications
**Record:** **Clean apply expected.** The tree already uses guard(spinlock_irqsave)(&f->lock) at line 144, matching the patch context. No structural divergence in this function.

### Step 6.3: Related Fixes Already Present? **Record:** **No.** Fix not present; git log --grep="inconsistent prioq" returns nothing.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

### Step 7.1: Subsystem
**Record:** sound/core/seq — ALSA sequencer. **Criticality:
IMPORTANT** (not core kernel, but widely used by audio/MIDI applications).

### Step 7.2: Activity
**Record:** Actively maintained in 6.18.y — 13 ALSA seq commits since the base merge, including several stable-worthy bug fixes.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Who Is Affected
**Record:** Users of ALSA sequencer with shared queues and multiple clients — DAWs, MIDI routers, JACK/ALSA bridge setups, OSS sequencer compatibility layers.

### Step 8.2: Trigger Conditions
**Record:**
- Shared sequencer queue used by multiple clients
- Combined queued events > 10,000 (achievable with 51 default-pool clients at 200 events each, or 6 max-pool clients at 2000 each)
- Event insertion requires sorted traversal (not the sequential tail fast-path)
- **Likelihood:** Uncommon but legitimate in professional multi-client MIDI setups

### Step 8.3: Failure Mode Severity
**Record:** Event enqueue fails with -EINVAL; kernel logs error; application loses the event. **Severity: MEDIUM** — functional failure, not crash/corruption/security, but breaks valid workloads.

### Step 8.4: Risk-Benefit
**Record:**
- **Benefit:** MEDIUM — restores correct behavior for large shared queues
- **Risk:** VERY LOW — ~6 lines, uses existing f->cells accounting, maintainer-reviewed
- **Ratio:** Favorable

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence Summary

**FOR backport:**
- Real, verifiable bug (10000 < legitimate max queue depth)
- Buggy code present in Linux 6.18.44
- Small, surgical, maintainer-signed fix
- Same author/subsystem already has a functional fix in this stable tree (33074b1e6c18f)
- Userspace-reachable path
- Fix preserves corruption detection using accurate bound

**AGAINST backport:**
- Not a crash, security, or data-corruption issue
- Requires multi-client shared-queue workloads
- No user/syzbot reports cited
- Mailing list review details unverified

**Unresolved:**
- Full lore review thread (blocked)
- Whether any reviewer explicitly nominated for stable

### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **PASS** — logic verified; maintainer sign-off; no Tested-by
2. Fixes a real bug affecting users? **PASS** — incorrect -EINVAL on valid large queues
3. Important issue? **PASS (borderline)** — MEDIUM severity functional failure in userspace API, not crash/corruption
4. Small and contained? **PASS** — single file, ~6 lines changed
5. No new features or APIs? **PASS**
6. Can apply to local tree? **PASS** — clean apply expected

### Step 9.3: Exception Categories
**Record:** None apply (not device ID, quirk, DT, build, or docs).

### Step 9.4: Problem and Decision Rationale

The commit fixes a longstanding artificial limit in ALSA sequencer priority-queue insertion. The 10000-entry traversal cap was meant to detect list corruption but incorrectly rejects valid queues when multiple clients share a sequencer queue and their combined event count exceeds 10000. Given per-client pool limits of up to 2000 events and 192 possible clients, this is not theoretical — 6 clients at max pool size, or 51 at default pool size, suffice.

For stable 6.18.y users running multi-client MIDI/sequencer setups, affected insertions silently fail with -EINVAL, causing dropped events. The fix replaces the arbitrary constant with f->cells, which is the correct upper bound for a consistent list. The patch is minimal, reviewed by the ALSA maintainer, and follows the precedent of the same author's functional seq fix already backported to this tree.

---

## Verification

- **[Phase 1]** Parsed commit message and tags from user-provided content
- **[Phase 1]** Confirmed no Reported-by/syzbot/Cc: stable tags
- **[Phase 2]** Read sound/core/seq/seq_prioq.c lines 130–196: buggy count = 10000 present
- **[Phase 2]** Verified post-decrement semantics of remaining-- <= 0 allow N traversals for N cells
- **[Phase 3]** git describe HEAD → v6.18.44; Makefile confirms 6.18.44
- **[Phase 3]** git blame -L 165,182 → count = 10000 at line 165
- **[Phase 3]** git log -S "inconsistent prioq cell count" → no results (fix not in tree)
- **[Phase 3]** git show 33074b1e6c18f → same author's functional fix already in 6.18.y stable
- **[Phase 4]** b4 dig -c HEAD → no match (expected; fix not committed)
- **[Phase 4]** b4 shazam "Remove arbitrary prioq insertion limit" → message-id not known
- **[Phase 4]** WebFetch lore.kernel.org and patch.msgid.link → blocked (Anubis/403)
- **[Phase 5]** grep snd_seq_prioq_cell_in → callers in seq_queue.c:314,319
- **[Phase 5]** Traced call chain: snd_seq_write → snd_seq_client_enqueue_event → snd_seq_enqueue_event → snd_seq_prioq_cell_in
- **[Phase 6]** Confirmed buggy code at seq_prioq.c:165 in local tree
- **[Phase 6]** Confirmed guard(spinlock_irqsave) and f->cells field exist for clean apply
- **[Phase 6]** Read include/sound/seq_kernel.h:
SNDRV_SEQ_MAX_EVENTS=2000, SNDRV_SEQ_MAX_CLIENTS=192, SNDRV_SEQ_DEFAULT_CLIENT_EVENTS=200
- **[Phase 6]** Verified math: 6×2000=12000>10000; 51×200=10200>10000
- **[Phase 8]** Confirmed failure mode: -EINVAL from snd_seq_prioq_cell_in, propagated through snd_seq_enqueue_event with cell freed
- **UNVERIFIED:** Mailing list review discussion and any explicit stable nominations
- **UNVERIFIED:** Whether fix has landed in mainline (not needed for local-tree decision; bug exists here)

**YES****Result:** Backport to **Linux 6.18.44** — **YES**.

The hardcoded 10,000-entry traversal limit in snd_seq_prioq_cell_in() can reject valid events on shared sequencer queues (e.g. 6 clients at max pool size, or 51 at default). The fix uses f->cells instead, is small and maintainer-reviewed, and the buggy code is still present in this tree — the fix is not applied yet.

 sound/core/seq/seq_prioq.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
sound/core/seq/seq_prioq.c +8 -6
index e649485a87722..8c9a293cb5b51 100644
@@ -132,7 +132,7 @@ int snd_seq_prioq_cell_in(struct snd_seq_prioq * f,
 			  struct snd_seq_event_cell * cell)
 {
 	struct snd_seq_event_cell *cur, *prev;
-	int count;
+	int remaining;
 	int prior;
 
 	if (snd_BUG_ON(!f || !cell))
@@ -162,10 +162,16 @@ int snd_seq_prioq_cell_in(struct snd_seq_prioq * f,
 	prev = NULL;		/* previous cell */
 	cur = f->head;		/* cursor */
 
-	count = 10000; /* FIXME: enough big, isn't it? */
+	remaining = f->cells;
 	while (cur != NULL) {
 		/* compare timestamps */
 		int rel = compare_timestamp_rel(&cell->event, &cur->event);
+
+		if (remaining-- <= 0) {
+			pr_err("ALSA: seq: inconsistent prioq cell count\n");
+			return -EINVAL;
+		}
+
 		if (rel < 0)
 			/* new cell has earlier schedule time, */
 			break;
@@ -176,10 +182,6 @@ int snd_seq_prioq_cell_in(struct snd_seq_prioq * f,
 		/* move cursor to next cell */
 		prev = cur;
 		cur = cur->next;
-		if (! --count) {
-			pr_err("ALSA: seq: cannot find a pointer.. infinite loop?\n");
-			return -EINVAL;
-		}
 	}
 
 	/* insert it before cursor */
Signature · 1 line
2.53.0
author maintainer
#727 lore raw

PATCH 1/1 ARM: tegra: p880: Lower CPU thermal limit

In reply to Sasha Levin

From: Ion Agorria <[email protected]>

[ Upstream commit ece4229e457de4ceeec80890c5c760f0c858eeea ]

Lower the CPU thermal limit for the LG P880, since its chassis has less thermal dissipation capability than the P895.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit Message Forensics

### Step 1.1: Subject Line
**Record:** [ARM: tegra: p880] [Lower] — Lower the CPU thermal limit for the LG Optimus 4X HD (P880) device tree.

### Step 1.2: Commit Message Tags
**Record:**
- **Fixes:** — none
- **Reported-by:** — none
- **Tested-by:** — none
- **Reviewed-by:** — none
- **Acked-by:** — none
- **Link:** — none
- **Cc: stable:** — none (expected for manual review)
- **Signed-off-by:** Ion Agorria, Svyatoslav Ryhel, Thierry Reding (ignore pipeline-added SOBs)

Notable: Tegra maintainer Thierry Reding signed off and committed the patch. No syzbot, bugzilla, or user crash reports.

### Step 1.3: Commit Body Analysis
**Record:**
- **Bug:** P880 inherits CPU thermal trip points from tegra30-lg-x3.dtsi (shared with P895). P880's chassis has less thermal dissipation than P895, so the inherited 75°C passive CPU throttle is too high.
- **Symptom:** CPU can run hotter than appropriate before passive throttling engages on the CPU diode sensor.
- **Version info:** None in message.
- **Root cause:** Incorrect board-specific thermal description — P880 reuses P895/X3 thermal profile without board-specific override.

### Step 1.4: Hidden Bug Fix Detection
**Record:** Yes — described as a thermal limit adjustment, but it corrects an incorrect hardware description in the device tree. This is a hardware-tuning bug fix, not a cosmetic change.

---

## Phase 2: Diff Analysis

### Step 2.1: Change Inventory
**Record:**
- **Files:** arch/arm/boot/dts/nvidia/tegra30-lg-p880.dts (+13 / -0)
- **Functions:** N/A (device tree nodes)
- **Scope:** Single-file, board-specific surgical DT override

### Step 2.2: Code Flow Change
**Record:**
- **Hunk (end of board DTS):** Before — P880 inherits cpu-thermal trips from included tegra30-lg-x3.dtsi (cpu-alert passive trip at 75°C). After — board DTS overrides cpu-alert to 60°C passive with 200 m°C hysteresis.
- **Path affected:** Thermal framework passive throttling on CPU diode sensor for P880 only.

### Step 2.3: Bug Mechanism
**Record:**
- **Category:** Hardware workaround / DT correctness fix
- **Mechanism:** P880 #includes tegra30-lg-x3.dtsi, which defines cpu-alert at 75000 m°C (75°C). The board override lowers this to 60000 m°C (60°C) to match P880's poorer thermal dissipation. Skin- thermal still throttles at 50°C and shuts down at 60°C on the skin sensor, but the CPU diode can run hotter than skin temperature during bursts; the inherited 75°C CPU trip was too permissive for this chassis.

### Step 2.4: Fix Quality
**Record:** Fix is minimal, obviously correct, and follows established DT override patterns used on other Tegra boards. Zero impact on non-P880 systems. Regression risk is very low — only makes throttling more conservative on one board.

---

## Phase 3: Git History Investigation

### Step 3.1: Blame / Introduction of Buggy Code
**Record:** Inherited cpu-alert at 75°C introduced in b68e6e0d50c5d ("ARM: tegra: Add device-tree for LG Optimus Vu (P895)", Feb 2024) in tegra30-lg-x3.dtsi. P880 DTS added in ea5e97e9ce046 (Feb 2024) without a board-specific CPU thermal override. Both commits are ancestors of the current tree.

### Step 3.2: Fixes: Tag
**Record:** N/A — no Fixes: tag present.

### Step 3.3: Related File History
**Record:**
- ea5e97e9ce046 — initial P880 DTS
- b49a73a08100a — prior P880 board fix (touchscreen clipping), already in 6.18.44
- ece4229e457de — this thermal fix (mainline, not yet in 6.18.44)
- Part of series "ARM: tegra: complete a few Tegra30 device trees" (patch 3/9), but this hunk only touches tegra30-lg-p880.dts and is functionally standalone.

### Step 3.4: Author Context
**Record:** Svyatoslav Ryhel is the primary P880/P895 DT author. Thierry Reding (Tegra maintainer) committed the fix. Ion Agorria is the hardware expert who identified the thermal issue.

### Step 3.5: Dependencies
**Record:** No code dependencies on other patches in the 3/9 series. Verified with git apply --check — applies cleanly to the current 6.18.44 tree.

---

## Phase 4: Mailing List and External Research

### Step 4.1: Original Patch Discussion
**Record:**
- **b4 dig URL:**
https://patch.msgid.link/[email protected]
- **Series revisions:** v1 original (Apr 2026) and v1 RESEND (May 2026)
- **Reviewer feedback:** No NAKs found in available thread content; patch merged by maintainer
- **Stable nominations:** None found in thread

### Step 4.2: Reviewers
**Record:** CC'd: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Thierry Reding, Jonathan Hunter, devicetree@, linux-tegra@, linux- kernel@. Appropriate maintainers were included.

### Step 4.3: Bug Reports
**Record:** No external bug report, syzbot link, or user crash report. Issue identified through hardware comparison (P880 vs P895 chassis thermal characteristics).

### Step 4.4: Related Patches
**Record:** Part of 9-patch Tegra30 DT completion series. This patch is self-contained. Prior P880 fix (b49a73a08100a, touchscreen clipping) is already in this stable tree.

### Step 4.5: Stable Mailing List
**Record:** No stable-specific discussion found for this patch.

---

## Phase 5: Code Semantic Analysis

### Step 5.1: Key Nodes Modified
**Record:** thermal-zones/cpu-thermal/trips/cpu-alert in board DTS root node.

### Step 5.2: Callers / Impact Surface
**Record:** Consumed by kernel thermal framework (drivers/thermal) for P880 DTB only. Triggered when nct72 sensor 1 (CPU diode) crosses trip temperature during normal operation.

### Step 5.3: Callees
**Record:** Standard DT thermal zone properties; no new kernel code paths.

### Step 5.4: Reachability
**Record:** Triggered during normal device use on LG P880 when running Linux with this DTB. Not userspace-syscall reachable, but affects all runtime thermal management on this hardware.

### Step 5.5: Similar Patterns
**Record:** Same override pattern exists on other Tegra boards. `arm64:
dts: rockchip: reduce thermal limits on rk3399-pinephone-pro` (in this tree) is a directly analogous DT thermal-limit correction for a tightly- packaged mobile device.

---

## Phase 6: Cross-Reference Against Local Tree (6.18.44)

### Step 6.1: Does Buggy Code Exist?
**Record:** **Yes.** Local tree is **v6.18.44**. arch/arm/boot/dts/nvidia/tegra30-lg-p880.dts exists (490 lines) and includes tegra30-lg-x3.dtsi, which defines cpu-alert at 75°C. No board-specific override is present. Bug present since P880 support landed (ea5e97e9ce046, Feb 2024).

### Step 6.2: Backport Complications
**Record:** **Clean apply.** git format-patch -1 ece4229e457d | git apply --check succeeded with no conflicts. File ends at the same structural point (sound { ... }; then closing };).

### Step 6.3: Related Fixes Already Present?
**Record:** b49a73a08100a (P880 touchscreen clipping) is in tree. This thermal fix (ece4229e457d) is **not** in the current 6.18.44 branch (present on master only).

---

## Phase 7: Subsystem Context

### Step 7.1: Subsystem and Criticality
**Record:** **ARM device tree / Tegra30 mobile platform.** Criticality:
**PERIPHERAL** — affects one specific 2012-era smartphone board.

### Step 7.2: Subsystem Activity
**Record:** Active — P880 received a board fix in 2025 (touchscreen clipping) already merged into this stable series.

---

## Phase 8: Impact and Risk Assessment

### Step 8.1: Who Is Affected
**Record:** **Driver/board-specific** — only users running mainline Linux on LG Optimus 4X HD (P880) with tegra30-lg-p880.dtb.

### Step 8.2: Trigger Conditions
**Record:** Sustained or bursty CPU load causing CPU diode temperature to rise. Common during normal phone use. Not security-relevant; unprivileged workload heat is the trigger.

### Step 8.3: Failure Mode Severity
**Record:** Without fix: delayed CPU passive throttling (75°C vs 60°C). Skin sensor still provides 50°C passive / 60°C critical shutdown, but CPU diode can exceed skin temperature. Severity: **MEDIUM** — potential overheating, accelerated throttling only at higher temps, possible discomfort or thermal stress; not a kernel crash or data corruption.

### Step 8.4: Risk-Benefit
**Record:**
- **Benefit:** Correct thermal protection for P880; prevents running with P895-inappropriate limits. Matches maintainer and hardware-author intent.
- **Risk:** Very low — 13-line DT-only change, board-scoped, more conservative throttling only.
- **Ratio:** Modest benefit (small user base) vs very low risk. Fits DT hardware-description correction category.

---

## Phase 9: Final Synthesis

### Step 9.1: Evidence Summary

**FOR backport:**
- Corrects incorrect DT hardware description for board already supported in 6.18.y
- Small (13 lines), surgical, maintainer-approved
- Applies cleanly to this tree
- DT exception category: fix for incorrect hardware description
- Precedent: similar P880 board fix already in this tree; analogous pinephone-pro thermal DT fix exists
- Prevents P880 from using P895 thermal profile inappropriate for its chassis

**AGAINST backport:**
- Very niche hardware (2012 phone, tiny mainline user base)
- No crash, corruption, security issue, or user bug report
- Skin thermal already provides some protection
- More aggressive throttling is a behavior change (performance tradeoff)
- Not in the "critical" severity categories stable rules emphasize most

**Unresolved:** No quantitative data on how often P880 exceeds 60°C CPU temperature in practice without this fix.

### Step 9.2: Stable Rules Checklist
1. **Obviously correct and tested?** **PASS** — maintainer-merged, hardware-author identified issue, standard DT override pattern.
2. **Fixes a real bug affecting users?** **PASS** — incorrect thermal limits for supported hardware; real for P880 users.
3. **Important issue?** **PASS (borderline)** — thermal safety / hardware protection, not crash/corruption, but prevents running with wrong thermal envelope.
4. **Small and contained?** **PASS** — 13 lines, one file.
5. **No new features or APIs?** **PASS** — board-specific DT property override only.
6. **Can apply to local tree?** **PASS** — verified clean apply to 6.18.44.

### Step 9.3: Exception Category
**Record:** **Device tree update** — correction of incorrect hardware thermal description for existing supported board.

### Step 9.4: Decision Rationale

This commit fixes a real device-tree bug: P880 inherits P895/X3 CPU thermal trip points that are too high for its chassis. The fix is minimal, board-scoped, maintainer-approved, applies cleanly to Linux 6.18.44, and follows the same pattern as the P880 touchscreen clipping fix already present in this stable tree. While the user base is small and severity is thermal-tuning rather than kernel crash, stable rules explicitly include DT fixes for incorrect hardware descriptions, and the risk of backporting is negligible.

---

## Verification

- **[Phase 1]** Parsed subject, tags, body from provided commit message and git show ece4229e457d
- **[Phase 2]** Diff analysis: +13 lines in tegra30-lg-p880.dts, adds thermal-zones/cpu-thermal/trips/cpu-alert override
- **[Phase 3]** git describe HEAD: v6.18.44 / kernel 6.18.44
- **[Phase 3]** git blame tegra30-lg-x3.dtsi:1777-1790: inherited 75°C trip from b68e6e0d50c5d (Feb 2024)
- **[Phase 3]** git merge-base --is-ancestor ea5e97e9ce046 HEAD: P880 DTS present in tree
- **[Phase 3]** git merge-base --is-ancestor ece4229e457d HEAD:
thermal fix NOT in 6.18.44
- **[Phase 3]** git apply --check: patch applies cleanly to current tree
- **[Phase 4]** b4 dig -c ece4229e457d: lore URL found
- **[Phase 4]** b4 dig -a: v1 and v1 RESEND revisions found, part of 9-patch series
- **[Phase 4]** b4 dig -w: DT and Tegra maintainers CC'd
- **[Phase 5]** Read tegra30-lg-x3.dtsi:1727-1810: confirmed inherited trips (skin 50°C/60°C, CPU 75°C/90°C)
- **[Phase 5]** Grep tegra30-lg-p895.dts: no board-specific thermal override (uses shared dtsi)
- **[Phase 6]** Read current tegra30-lg-p880.dts: no thermal-zones override present (490 lines)
- **[Phase 6]** b49a73a08100a confirmed in tree as prior P880 board fix
- **[Phase 7]** Subsystem: ARM Tegra30 DT, peripheral/niche
- **[Phase 8]** Failure mode: delayed CPU thermal throttling, severity MEDIUM

**YES**Those background searches finished and matched what the main analysis already used:

- **Thermal limit commit search:** No Lower CPU thermal limit / cpu- alert override is in the 6.18.44 tree yet; the fix exists only on mainline as ece4229e457d.
- **Ion Agorria commits:** Only unrelated drm/tegra probe/remove PM work showed up locally — nothing overlapping this DTS change.

The backport recommendation stands: **YES** — a small, board-specific DT correction that applies cleanly to 6.18.44.

 arch/arm/boot/dts/nvidia/tegra30-lg-p880.dts | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm/boot/dts/nvidia/tegra30-lg-p880.dts +13 -0
index c6ef0a20c19f3..4f57e43af6428 100644
@@ -486,4 +486,17 @@ sound {
 
 		nvidia,int-mic-en-gpios = <&gpio TEGRA_GPIO(I, 6) GPIO_ACTIVE_HIGH>;
 	};
+
+	thermal-zones {
+		cpu-thermal {
+			trips {
+				cpu-alert {
+					/* throttle at 60C until temperature drops to 59.8C */
+					temperature = <60000>;
+					hysteresis = <200>;
+					type = "passive";
+				};
+			};
+		};
+	};
 };
Signature · 1 line
2.53.0
author maintainer
#728 lore raw

PATCH 1/1 fuse-uring: clear ent->fuse_req in commit_fetch error path

In reply to Sasha Levin

From: Zhenghang Xiao <[email protected]>

[ Upstream commit 7d87a5a284bb34edb3f4e7e312ef403b3385a7b7 ]

fuse_uring_commit_fetch() error path called fuse_request_end(req) without clearing ent->fuse_req when fuse_ring_ent_set_commit() fails. The still-pending fuse_uring_send_in_task() task-work later dereferences the dangling pointer through fuse_uring_prepare_send(), causing a use-after-free.

End the request with fuse_uring_req_end(), which handles all conditions already.

Annotation/edition by Bernd: The UAF should be fixed by other means already and actually has to be avoided that way.
Just checking for ent->fuse_req == NULL in fuse_uring_send_in_task() would be prone to race conditions, because if malicious userspace would commit requests that have passed the NULL check, but are in doing args copy, it would still trigger a use-after-free. Setting ent->fuse_req = NULL in fuse_uring_commit_fetch() still makes sense, though.

---

LLM Generated explanations, may be completely bogus:

The background searches finished and matched the fix on upstream as **7d87a5a284bb3** (also **79f6e8deb22fe** on a later branch) — *fuse-uring: clear ent->fuse_req in commit_fetch error path*. That lines up with the commit we analyzed.

On this **6.18.44** tree the buggy error path is still present and the fix is not applied. The earlier analysis stands: **YES** for stable backport — small UAF fix on a default-enabled FUSE io-uring path, with maintainer sign-off and a known reproducer.

 fs/fuse/dev_uring.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/fuse/dev_uring.c +1 -3
index 6f74c345080f4..0d76821cf4ec6 100644
@@ -947,9 +947,7 @@ static int fuse_uring_commit_fetch(struct io_uring_cmd *cmd, int issue_flags,
 		pr_info_ratelimited("qid=%d commit_id %llu state %d",
 				    queue->qid, commit_id, ent->state);
 		spin_unlock(&queue->lock);
-		req->out.h.error = err;
-		clear_bit(FR_SENT, &req->flags);
-		fuse_request_end(req);
+		fuse_uring_req_end(ent, req, err);
 		return err;
 	}
 
Signature · 1 line
2.53.0
author maintainer
#729 lore raw

PATCH 1/1 ksmbd: fix n.data memory leak in ksmbd_vfs_set_dos_attrib_xattr

In reply to Sasha Levin

From: Qiang Liu <[email protected]>

[ Upstream commit 7ac657bb9c5c1b0f7bdf1fa6d3ad532f969be5cf ]

Free ndr buffer data when ndr_encode_dos_attr() returns error to avoid memory leak.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: ksmbd: fix n.data memory leak in ksmbd_vfs_set_dos_attrib_xattr

**Local tree:** v6.18.44 (stable/linux-6.18.y, make kernelversion = 6.18.44)
**Commit under review:** 7ac657bb9c5c1 (on master, **not yet** in this tree)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject line
**Record:** [ksmbd] [fix] — memory leak of n.data in ksmbd_vfs_set_dos_attrib_xattr when ndr_encode_dos_attr() fails.

### Step 1.2: Tags
**Record:**
- **Signed-off-by:** Qiang Liu <[email protected]> (author)
- **Reviewed-by:** ChenXiaoSong <[email protected]>
- **Acked-by:** Namjae Jeon <[email protected]> (ksmbd maintainer)
- **Signed-off-by:** Steve French <[email protected]> (committer)
- No Fixes:, Reported-by:, Link:, Cc: stable, or Tested-by: tags
- Notable: maintainer **Acked-by** is a strong quality signal

### Step 1.3: Body analysis
**Record:**
- **Bug:** ndr_encode_dos_attr() allocates an NDR buffer (n.data); on encoding error, ksmbd_vfs_set_dos_attrib_xattr() returned early without kfree(n.data).
- **Symptom:** Memory leak (no crash/corruption described).
- **Root cause:** Missing cleanup on the ndr_encode_dos_attr() error path.
- **Version info:** None in commit message.

### Step 1.4: Hidden bug fix?
**Record:** No — explicitly labeled as a memory leak fix, not disguised cleanup.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Inventory
**Record:**
- **Files:** fs/smb/server/vfs.c only (+3 / −2 lines)
- **Function modified:** ksmbd_vfs_set_dos_attrib_xattr()
- **Scope:** Single-file, surgical fix

### Step 2.2: Code flow change
**Record:**

| Hunk | Before | After |
|------|--------|-------|
| Error from `ndr_encode_dos_attr()` | `return err;` (leaks `n.data`) |
`goto out;` |
| Success path cleanup | `kfree(n.data); return err;` | `out:
kfree(n.data); return err;` |

Both success and error paths now converge at out: and always free n.data when it was allocated.

### Step 2.3: Bug mechanism
**Record:**
- **Category:** Resource leak on error path
- **Mechanism:** ndr_encode_dos_attr() calls kzalloc(1024) then may fail in ndr_write_string() / ndr_write_int*() via try_to_realloc_ndr_blob() returning -ENOMEM. The caller returned without freeing the already-allocated buffer.

Verified in ndr.c:

```170:188:fs/smb/server/ndr.c
int ndr_encode_dos_attr(struct ndr *n, struct xattr_dos_attrib *da)
{
        // ...
        n->data = kzalloc(n->length, KSMBD_DEFAULT_GFP);
        if (!n->data)
                return -ENOMEM;
        // ... ndr_write_* calls that can return -ENOMEM ...
        if (ret)
                return ret;
```

### Step 2.4: Fix quality
**Record:**
- **Quality:** Obviously correct; mirrors the goto out + kfree pattern used elsewhere in the same file (e.g. ksmbd_vfs_set_sd_xattr, ksmbd_vfs_get_dos_attrib_xattr).
- **Regression risk:** Very low — only adds cleanup on a previously leaked path.
- **Red flags:** None.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
**Record:**
- Buggy logic introduced in f44158485826c ("cifsd: add file operations", 2021-05-10).
- Function has been in ksmbd/cifsd since v5.13 era; present in this 6.18.y tree at fs/smb/server/vfs.c:1651–1670.

### Step 3.2: Fixes: tag
**Record:** N/A — no Fixes: tag present.

### Step 3.3: Related file history
**Record:**
- Part of v2 series: [PATCH v2 0/3] ksmbd: fix some memory leaks in ksmbd_vfs_* functions
- Sibling commits on master:
- d4d56b00c7df8 — sd_ndr.data leak in ksmbd_vfs_set_sd_xattr
- d708a36634bb7 — acl.sd_buf leak in ksmbd_vfs_get_sd_xattr
- 7ac657bb9c5c1 — this commit (patch 3/3)
- **This commit is standalone** — fixes a different function; no dependency on siblings.

### Step 3.4: Author context
**Record:** Qiang Liu submitted the 3-patch leak-fix series. Namjae Jeon (maintainer) Acked all three. Steve French committed.

### Step 3.5: Prerequisites
**Record:** None. git apply --check against this tree succeeds cleanly. No structural/API assumptions beyond existing code.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original discussion
**Record:**
- **b4 dig URL:**
https://patch.msgid.link/[email protected]
- **Series revisions:** v1 (2026-06-23), v2 (2026-06-24); committed version matches v2 patch 3/3
- **Lore fetch:** Blocked by Anubis bot protection — could not read thread body for stable nominations or NAKs

### Step 4.2: Reviewers (b4 dig -w)
**Record:** CC'd to Steve French, Namjae Jeon, Ronnie Sahlberg, linux- [email protected], and other ksmbd maintainers/reviewers.

### Step 4.3: Bug report
**Record:** N/A — no external bug report or syzbot link.

### Step 4.4: Related patches
**Record:** 3-patch series fixing independent leaks in vfs.c. Other two patches are also absent from this tree but are not prerequisites for this one.

### Step 4.5: Stable list history
**Record:** UNVERIFIED — lore stable search blocked by bot protection.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key functions
**Record:** ksmbd_vfs_set_dos_attrib_xattr() modified; ndr_encode_dos_attr() is the allocator whose errors were mishandled.

### Step 5.2: Callers
**Record:** Three call sites in smb2pdu.c, all behind KSMBD_SHARE_FLAG_STORE_DOS_ATTRS:
1. smb2_new_xattrs() — file creation (called from smb2_open path)
2. set_file_basic_info() — SMB2 SET_INFO (file attribute/time updates)
3. fsctl_set_sparse() — FSCTL_SET_SPARSE IOCTL

All are SMB2 protocol handlers reachable by remote clients when the share stores DOS attributes in xattrs.

### Step 5.3: Callees
**Record:** ndr_encode_dos_attr() → kzalloc / krealloc / ndr_write_*; ksmbd_vfs_setxattr() on success path.

### Step 5.4: Reachability
**Record:** Reachable from network clients performing file create, set- info, or sparse-file FSCTL on shares with STORE_DOS_ATTRS enabled (CONFIG_SMB_SERVER). Trigger for the leak requires ndr_encode_dos_attr() to fail after allocation (typically -ENOMEM under memory pressure).

### Step 5.5: Similar patterns
**Record:** Same file already uses goto out + kfree for NDR buffers in ksmbd_vfs_set_sd_xattr and ksmbd_vfs_get_sd_xattr. Sibling commit d4d56b00 applies the identical pattern fix to sd_ndr.data in ksmbd_vfs_set_sd_xattr. This tree already has a precedent backport:
d026f47db6863 ("ksmbd: Fix memory leak in get_file_all_info()").

---

## PHASE 6: CROSS-REFERENCE AGAINST LOCAL TREE

### Step 6.1: Buggy code present?
**Record:** **YES.** Current tree at vfs.c:1659–1661:

```1659:1661:fs/smb/server/vfs.c
        err = ndr_encode_dos_attr(&n, da);
        if (err)
                return err;
```

Bug present since 2021; well predates 6.18.y branch.

### Step 6.2: Backport complications
**Record:** **Clean apply** — git apply --check passes with no conflicts. File layout matches mainline.

### Step 6.3: Related fixes already present?
**Record:** Fix commit 7ac657bb9c5c1 is **NOT** in HEAD. Sibling series commits d4d56b00 and d708a36634bb7 also **NOT** in HEAD. No duplicate fix for this specific leak found.

---

## PHASE 7: SUBSYSTEM CONTEXT

### Step 7.1: Subsystem criticality
**Record:** fs/smb/server (ksmbd SMB3 server). **IMPORTANT** — affects users running in-kernel SMB server (CONFIG_SMB_SERVER), not universal but security/stability-sensitive for deployments using it.

### Step 7.2: Subsystem activity
**Record:** Highly active in 6.18.y — recent backports include UAF fixes, integer overflow, ACL validation, transport leaks. Memory leak fixes are routinely accepted.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Who is affected
**Record:** Users with CONFIG_SMB_SERVER enabled and shares configured with STORE_DOS_ATTRS. Driver/server-specific, not all kernel users.

### Step 8.2: Trigger conditions
**Record:** SMB file create, SET_INFO, or sparse FSCTL that stores DOS attributes; ndr_encode_dos_attr() must fail after kzalloc (most likely -ENOMEM during NDR buffer growth). Unprivileged remote clients can trigger the code path; the leak itself requires the encoding error.

### Step 8.3: Failure mode severity
**Record:** Memory leak (~1 KB+ per failed encode, potentially more if reallocs occurred). **Severity: MEDIUM** — no direct crash/corruption, but under memory pressure the leak worsens OOM conditions in an active server path.

### Step 8.4: Risk-benefit
**Record:**
- **Benefit:** Prevents per-operation leaks in a commonly-used ksmbd path; aligns with existing stable backport policy for ksmbd leak fixes.
- **Risk:** Minimal — 5-line, obviously correct cleanup addition.
- **Ratio:** Favorable.

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence summary

**FOR backport:**
- Real, verified memory leak on error path (code inspection confirms)
- Bug present since 2021, exists in this 6.18.44 tree
- Surgical 5-line fix, applies cleanly
- Acked-by subsystem maintainer (Namjae Jeon)
- Reachable from SMB2 client operations on active server paths
- Precedent: similar ksmbd leak fix already backported to this tree (d026f47db6863)
- Under memory pressure, leak compounds the failure mode

**AGAINST backport:**
- Only triggers on ndr_encode_dos_attr() failure (typically ENOMEM), not the common success path
- No user crash reports, syzbot, or CVE
- Lore thread content unverified (bot blocked)

**Unresolved:** Whether reviewers explicitly nominated for stable on lore (could not fetch thread).

### Step 9.2: Stable rules checklist

| Criterion | Result |
|-----------|--------|
| 1. Obviously correct and tested? | **PASS** — standard `goto
out`/`kfree` pattern; Reviewed-by + Acked-by; no Tested-by |
| 2. Fixes a real bug affecting users? | **PASS** — verified leak on SMB
server error path |
| 3. Important issue? | **PASS (borderline)** — MEDIUM severity memory
leak in active server code; not crash/corruption but worsens OOM |
| 4. Small and contained? | **PASS** — 1 file, 5 lines |
| 5. No new features/APIs? | **PASS** |
| 6. Can apply to local tree? | **PASS** — clean apply verified |

### Step 9.3: Exception categories
**Record:** None (not a device ID, quirk, DT, build, or docs fix). Qualifies as a standard bug fix.

### Step 9.4: Decision rationale
This is a small, maintainer-acked fix for a long-standing resource leak in ksmbd's DOS-attribute xattr storage path. The leak is real and verified by reading ndr_encode_dos_attr() and the caller. While it only fires on encoding errors (typically under memory pressure), that is exactly when leaking memory is most harmful. The fix is trivial, applies cleanly to 6.18.44, and matches established precedent for ksmbd leak fixes already backported to this stable tree.

---

## Verification

- **[Phase 1]** Parsed commit 7ac657bb9c5c1 message and tags via git show
- **[Phase 2]** Read diff and current vfs.c:1651–1670 and ndr.c:170–227 — confirmed leak mechanism
- **[Phase 3]** git blame -L 1651,1670 — bug since f44158485826c (2021-05-10)
- **[Phase 3]** git merge-base --is-ancestor 7ac657bb9c5c1 HEAD — fix **NOT** in tree
- **[Phase 3]** git apply --check — patch applies cleanly
- **[Phase 3]** Identified 3-patch series on master; confirmed this patch is independent
- **[Phase 4]** b4 dig -c 7ac657bb9c5c1 — found lore URL and v1/v2 revisions
- **[Phase 4]** b4 dig -c 7ac657bb9c5c1 -w — maintainer CC list confirmed
- **[Phase 4]** WebFetch lore — blocked by Anubis (UNVERIFIED: thread review comments)
- **[Phase 5]** grep ksmbd_vfs_set_dos_attrib_xattr — 3 callers in smb2pdu.c identified
- **[Phase 5]** Read caller context: smb2_new_xattrs, set_file_basic_info, fsctl_set_sparse
- **[Phase 6]** git describe HEAD = v6.18.44; make kernelversion = 6.18.44
- **[Phase 6]** Buggy code confirmed present at vfs.c:1659–1661
- **[Phase 6]** git log --grep='memory leak in get_file_all_info' — precedent backport d026f47db6863 in tree
- **[Phase 7]** git log --oneline -20 -- fs/smb/server/ — active ksmbd maintenance in 6.18.y
- **[Phase 8]** Assessed trigger (ENOMEM on NDR encode) and severity (MEDIUM leak)

**YES**The sibling-patch check finished successfully: neither d4d56b00c7df8 (sd_ndr.data leak in ksmbd_vfs_set_sd_xattr) nor the other series commits are in this 6.18.44 tree. That doesn’t block this backport — 7ac657bb9c5c1 is a standalone fix for ksmbd_vfs_set_dos_attrib_xattr, applies cleanly, and the leak is still present here.

**Verdict for this tree: YES** — small, maintainer-acked error-path memory leak fix in an active ksmbd SMB2 path.

 fs/smb/server/vfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/smb/server/vfs.c +3 -2
index 263032adf0cd8..859ca7c87bd4c 100644
@@ -1664,14 +1664,15 @@ int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap,
 
 	err = ndr_encode_dos_attr(&n, da);
 	if (err)
-		return err;
+		goto out;
 
 	err = ksmbd_vfs_setxattr(idmap, path, XATTR_NAME_DOS_ATTRIBUTE,
 				 (void *)n.data, n.offset, 0, get_write);
 	if (err)
 		ksmbd_debug(SMB, "failed to store dos attribute in xattr\n");
-	kfree(n.data);
 
+out:
+	kfree(n.data);
 	return err;
 }
 
Signature · 1 line
2.53.0
author maintainer
#730 lore raw

PATCH 1/1 net: usb: qmi_wwan: add MeiG SRM813Q

In reply to Sasha Levin

From: Jan Volckaert <[email protected]>

[ Upstream commit 9758c11fc6c138a79a28a5659feeaa3abde7aa6a ]

Add support for the Qualcomm Technology Snapdragon X35-based MeiG SRM813Q module.

The module can be put in different modes via AT commands to enable/disable GPS functionality:

MODEM - PPP mode(2dee:4d63): AT+SER=1,1

If#= 0: RMNET
If#= 1: DIAG/ADB
If#= 2: MODEM
If#= 3: AT

P:  Vendor=2dee ProdID=4d63 Rev=05.15
S:  Manufacturer=MEIG
S:  Product=LTE-A Module
S:  SerialNumber=1bd51f0e
C:  #Ifs= 4 Cfg#= 1 Atr=80 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=50 Driver=qmi_wwan
E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=82(I) Atr=03(Int.) MxPS=   8 Ivl=32ms
I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:  If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option
E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=85(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
I:  If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option
E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=87(I) Atr=03(Int.) MxPS=  10 Ivl=32ms

NMEA mode(2dee:4d64): AT+SER=51,1

If#= 0: RMNET
If#= 1: DIAG/ADB
If#= 2: NMEA
If#= 3: AT

P:  Vendor=2dee ProdID=4d64 Rev=05.15
S:  Manufacturer=MEIG
S:  Product=LTE-A Module
S:  SerialNumber=1bd51f0e
C:  #Ifs= 4 Cfg#= 1 Atr=80 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=50 Driver=qmi_wwan
E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=82(I) Atr=03(Int.) MxPS=   8 Ivl=32ms
I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:  If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=60 Driver=option
E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=85(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
I:  If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option
E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=87(I) Atr=03(Int.) MxPS=  10 Ivl=32ms

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit Message Forensics

### Step 1.1: Subject Line
**Record:** [net: usb: qmi_wwan] [add] — Add USB device ID table entries for the MeiG SRM813Q LTE modem (Snapdragon X35-based) to the existing qmi_wwan driver.

### Step 1.2: Commit Message Tags
**Record:**
- **Fixes:** — not present (expected for manual review)
- **Reported-by:** — none
- **Tested-by:** — none
- **Reviewed-by:** — none
- **Acked-by:** — none
- **Link:** https://patch.msgid.link/[email protected] (patch 2/2 in series)
- **Cc: [email protected]** — not present on this commit (the companion option.c patch in this tree does have it)
- **Signed-off-by:** Jan Volckaert <[email protected]> (author), Jakub Kicinski <[email protected]> (netdev maintainer)
- **Notable:** Maintainer sign-off from Jakub Kicinski; detailed lsusb-style descriptors for two USB product IDs (2dee:4d63, 2dee:4d64); patch 2 of 2 (companion is USB: serial: option: add MeiG SRM813Q)

### Step 1.3: Commit Body Analysis
**Record:**
- **Bug description:** Not a kernel crash/corruption bug. The MeiG SRM813Q modem exposes its RMNET/QMI data interface on USB interface #0 (Prot=50, driver qmi_wwan), but without table entries the kernel will not bind qmi_wwan to this device.
- **Symptom:** Users with this modem get no wwan0/RMNET network interface; cellular data does not work. Serial/DIAG/AT ports are handled separately by the option driver.
- **Root cause:** Missing usb_device_id entries in qmi_wwan.c for vendor 0x2dee, products 0x4d63 (Modem/PPP mode) and 0x4d64 (NMEA mode).
- **Version info:** None stated; hardware is new (Snapdragon X35, USB 3.20).

### Step 1.4: Hidden Bug Fix Detection
**Record:** Not a hidden bug fix. This is explicit **hardware enablement** — a new device ID addition to an existing driver. No error- path, locking, refcount, or memory-safety changes.

---

## Phase 2: Diff Analysis

### Step 2.1: Change Inventory
**Record:**
- **Files:** drivers/net/usb/qmi_wwan.c — +2 lines
- **Functions modified:** products[] USB device ID table only (static data, no function body changes)
- **Scope:** Single-file, surgical device ID addition

### Step 2.2: Code Flow Change
**Record:**
- **Hunk (products[] table):** Before → device not matched by qmi_wwan; QMI interface #0 left unbound. After → qmi_wwan binds to interface #0 for 2dee:4d63 and 2dee:4d64, using QMI_QUIRK_SET_DTR (same pattern as Quectel, SIMCom, u-blox entries on interface 0).
- **Execution path:** USB device enumeration / driver probe at plug-in time.

### Step 2.3: Bug Mechanism
**Record:** Category **h) Hardware workarounds / device ID addition**. Without entries, qmi_wwan never probes the RMNET interface. The QMI_QUIRK_SET_DTR flag ensures proper DTR/power management during bind (consistent with other Qualcomm-based modems lacking auto-DTR).

### Step 2.4: Fix Quality
**Record:** Obviously correct — interface #0 confirmed by commit message lsusb output (Driver=qmi_wwan on If#= 0). Minimal change. Regression risk very low: only affects devices with these specific VID/PID pairs that currently have no qmi_wwan binding at all.

---

## Phase 3: Git History Investigation

### Step 3.1: Blame
**Record:** Insertion point is immediately after {QMI_FIXED_INTF(0x2dee, 0x4d22, 5)} (MeiG SRM825L), introduced by commit 1ca645a2f74a4 (Aug 2024). The SRM813Q entries are new; no pre- existing buggy code to blame.

### Step 3.2: Fixes: Tag
**Record:** Not applicable — no Fixes: tag.

### Step 3.3: Related File History
**Record:** Recent qmi_wwan.c changes in this tree are predominantly similar device-ID additions (Telit, Quectel, Fibocom, MeiG SRM825L). The companion option.c patch (38ba1a464c0d1, upstream 7d2b37d3e42d) is **already present** in this tree. The qmi_wwan half is **not yet** in this tree — creating a half-enabled state for SRM813Q users.

### Step 3.4: Author Context
**Record:** Jan Volckaert submitted the companion option.c patch (already merged here with Cc: [email protected]). Jakub Kicinski (netdev maintainer) signed off on the qmi_wwan patch per commit message.

### Step 3.5: Dependencies
**Record:** Part of a 2-patch series with USB: serial: option: add MeiG SRM813Q. The option half is already in v6.18.44. This qmi_wwan patch is standalone (applies independently) but functionally completes modem support. No structural/API prerequisites beyond existing QMI_QUIRK_SET_DTR macro and qmi_wwan driver.

---

## Phase 4: Mailing List and External Research

### Step 4.1: Original Discussion
**Record:** Link points to [email protected] (patch 2/2). b4 dig -c could not match this commit (not yet in local git). WebFetch and curl to lore.kernel.org returned 403/bot protection — discussion content **unverified**. Patch series structure (2/2) confirmed from message ID.

### Step 4.2: Reviewers
**Record:** UNVERIFIED via b4 (commit not in tree). Jakub Kicinski Signed-off-by confirms netdev maintainer acceptance.

### Step 4.3: Bug Report
**Record:** No external bug report, syzbot, or user crash report. Hardware enablement driven by author testing with physical device (lsusb descriptors provided).

### Step 4.4: Related Patches
**Record:** Patch 1/2 (option.c, commit 38ba1a464c0d1) already in v6.18.44 with Cc: [email protected]. This patch 2/2 completes RMNET data path support.

### Step 4.5: Stable List History
**Record:** UNVERIFIED (lore access blocked). Companion option.c patch explicitly nominated for stable in this tree.

---

## Phase 5: Code Semantic Analysis

### Step 5.1: Key Functions
**Record:** Only products[] static table modified. Probe/bind handled by existing qmi_wwan_probe() → qmi_wwan_bind().

### Step 5.2: Callers
**Record:** USB core calls qmi_wwan probe during device enumeration when VID/PID/interface match products[]. Standard hot-plug path for USB modems.

### Step 5.3: Callees
**Record:** On bind with QMI_QUIRK_SET_DTR, existing code calls qmi_wwan_manage_power() and qmi_wwan_change_dtr() — well-established path for Qualcomm modems.

### Step 5.4: Reachability
**Record:** Triggered by plugging in MeiG SRM813Q USB modem. Common user operation for cellular connectivity. Not syscall-triggered, but standard device hotplug.

### Step 5.5: Similar Patterns
**Record:** Dozens of identical-pattern entries in products[] (e.g., QMI_QUIRK_SET_DTR(0x2c7c, ...), QMI_FIXED_INTF(0x2dee, 0x4d22, 5) for sibling MeiG SRM825L). Telit/Quectel additions in this tree routinely carry Cc: [email protected].

---

## Phase 6: Cross-Reference Against Local Tree (v6.18.44)

### Step 6.1: Buggy Code Exists?
**Record:** Yes — the **absence** of entries is the issue. drivers/net/usb/qmi_wwan.c line 1454 has SRM825L (0x2dee:0x4d22) but **not** SRM813Q (0x4d63, 0x4d64). Meanwhile drivers/usb/serial/option.c already has all six SRM813Q entries (lines 2472–2476). Half-enabled state confirmed.

### Step 6.2: Backport Complications
**Record:** Clean apply — git apply --check succeeded with zero conflicts against current qmi_wwan.c.

### Step 6.3: Related Fixes Already Present?
**Record:** option.c SRM813Q support present (38ba1a464c0d1). No qmi_wwan SRM813Q fix present. No duplicate.

---

## Phase 7: Subsystem and Maintainer Context

### Step 7.1: Subsystem Criticality
**Record:** drivers/net/usb/ — IMPORTANT. USB WWAN/cellular modems used in laptops, routers, IoT, embedded. Not core-kernel, but critical for affected hardware users.

### Step 7.2: Subsystem Activity
**Record:** Actively maintained — frequent device ID additions and bug fixes in drivers/net/usb/ on this branch.

---

## Phase 8: Impact and Risk Assessment

### Step 8.1: Who Is Affected
**Record:** Users of MeiG SRM813Q (Snapdragon X35) USB LTE modules.
Config-dependent: CONFIG_USB_NET_QMI_WWAN. Currently broken for cellular data on v6.18.44 despite partial option driver support.

### Step 8.2: Trigger Conditions
**Record:** Plug in MeiG SRM813Q modem. Deterministic, every time. No privilege required beyond normal USB device access.

### Step 8.3: Failure Mode Severity
**Record:** No kernel crash/oops. **Functional failure** — no RMNET/wwan network interface, no cellular data connectivity. Severity:
**MEDIUM** for affected users (device unusable for its primary purpose), **LOW** globally (single modem model).

### Step 8.4: Risk-Benefit
**Record:**
- **Benefit:** Enables cellular data on SRM813Q; completes support started by already-merged option.c patch. Standard stable device-ID backport.
- **Risk:** Very low — 2 lines, only matches specific VID/PID, no behavior change for any other device.
- **Ratio:** High benefit for affected users, negligible risk.

---

## Phase 9: Final Synthesis

### Step 9.1: Evidence Summary

**FOR backport:**
- Explicit stable exception: new USB device IDs to existing driver
- 2-line, surgical, applies cleanly to v6.18.44
- Companion option.c patch already in tree with Cc: stable
- Without this, SRM813Q users lack qmi_wwan/RMNET — modem data path non-functional
- Maintainer (Jakub Kicinski) signed off
- Identical pattern to other stable-nominated qmi_wwan device additions in this tree

**AGAINST backport:**
- Not a crash/security/corruption fix
- Affects only one modem model (limited user population)
- No explicit Cc: stable on this specific commit message
- Mailing list discussion unverified

**UNRESOLVED:**
- Full lore review thread content
- Whether author tested RMNET connectivity end-to-end (descriptors strongly support correctness)

### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **PASS** — descriptors match table entries; maintainer SOB; established macro pattern
2. Fixes real bug affecting users? **PASS** — hardware non-functional for data without it; completes half-merged series
3. Important issue? **PASS (MEDIUM)** — no crash, but primary device function broken for affected users
4. Small and contained? **PASS** — 2 lines, one file
5. No new features/APIs? **PASS** — device ID table only (stable exception category)
6. Can apply to local tree? **PASS** — verified clean apply

### Step 9.3: Exception Category
**Record:** **NEW DEVICE IDs** — adding USB VID/PID entries to the existing qmi_wwan driver. Textbook stable backport material.

### Step 9.4: Decision Rationale

For **v6.18.44**, this commit should be backported. It is a minimal device ID addition that enables RMNET/cellular data on the MeiG SRM813Q modem. The qmi_wwan driver and all required infrastructure already exist in this tree. The companion option.c patch is already merged here (with stable nomination), leaving users in a broken partial-support state until this qmi_wwan half is also applied. This matches the stable exception for new device IDs and follows the same pattern as other qmi_wwan modem additions routinely backported to stable.

---

## Verification

- **[Phase 1]** Parsed subject, tags, body from user-provided commit message
- **[Phase 1]** Confirmed patch 2/2 series structure from message ID 55995-2
- **[Phase 2]** Diff analysis: +2 lines in products[], QMI_QUIRK_SET_DTR(0x2dee, 0x4d63/0x4d64, 0)
- **[Phase 3]** git describe HEAD → v6.18.44 (VERSION 6, PATCHLEVEL 18, SUBLEVEL 44)
- **[Phase 3]** git blame -L 1454,1454 → SRM825L added by 1ca645a2f74a4 (Aug 2024)
- **[Phase 3]** git log --oneline -20 -- drivers/net/usb/qmi_wwan.c → recent device-ID additions confirmed
- **[Phase 3]** git show 38ba1a464c0d1 → companion option.c patch present with Cc: [email protected]
- **[Phase 3]** git cat-file -t 7d2b37d3e42d → upstream option commit exists in tree
- **[Phase 3]** grep 0x4d63/0x4d64 in qmi_wwan.c → no matches (not yet present)
- **[Phase 4]** b4 dig -c 1ca645a2f74a4 → found SRM825L lore link (wrong commit, expected)
- **[Phase 4]** WebFetch/curl lore.kernel.org → 403/bot blocked; thread content UNVERIFIED
- **[Phase 5]** Read QMI_QUIRK_SET_DTR macro and DTR quirk logic at lines 821–825, 938–958
- **[Phase 5]** grep QMI_QUIRK_SET_DTR → many similar entries confirm pattern
- **[Phase 6]** grep SRM813Q/0x4d63 in option.c → 6 entries present (lines 2472–2476)
- **[Phase 6]** grep SRM813Q/0x4d63 in qmi_wwan.c → only SRM825L (0x4d22), not SRM813Q
- **[Phase 6]** git apply --check on provided diff → applies cleanly
- **[Phase 7]** git log --oneline -20 -- drivers/net/usb/ → active subsystem
- **[Phase 8]** Confirmed failure mode: no qmi_wwan bind → no cellular data (not a crash)
- **[Phase 9]** git show e81a7f65288c7 → similar Telit addition has Cc: [email protected]

**YES**

 drivers/net/usb/qmi_wwan.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/usb/qmi_wwan.c +2 -0
index 05acac10cd2ba..94cdb61dca83d 100644
@@ -1452,6 +1452,8 @@ static const struct usb_device_id products[] = {
 	{QMI_QUIRK_SET_DTR(0x1546, 0x1342, 4)},	/* u-blox LARA-L6 */
 	{QMI_QUIRK_SET_DTR(0x33f8, 0x0104, 4)}, /* Rolling RW101 RMNET */
 	{QMI_FIXED_INTF(0x2dee, 0x4d22, 5)},    /* MeiG Smart SRM825L */
+	{QMI_QUIRK_SET_DTR(0x2dee, 0x4d63, 0)}, /* MeiG SRM813Q w/ Modem(PPP) */
+	{QMI_QUIRK_SET_DTR(0x2dee, 0x4d64, 0)}, /* MeiG SRM813Q w/ NMEA */
 
 	/* 4. Gobi 1000 devices */
 	{QMI_GOBI1K_DEVICE(0x05c6, 0x9212)},	/* Acer Gobi Modem Device */
Signature · 1 line
2.53.0
author maintainer
#731 lore raw

PATCH 1/1 net: cpsw_new: unregister devlink on port registration failure

In reply to Sasha Levin

From: Guangshuo Li <[email protected]>

[ Upstream commit b64f763b607426ac97e44b114f0b8844ac3b86dd ]

cpsw_probe() registers devlink before registering the CPSW ports.

If cpsw_register_ports() fails, the error path only unregisters the notifiers and then releases the lower level resources. It does not undo the successful cpsw_register_devlink() call, leaving the devlink instance and its parameters registered after probe has failed.

Add a devlink cleanup label for the path where devlink registration has already succeeded, and use it when port registration fails.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: net: cpsw_new: unregister devlink on port registration failure

**Local tree:** v6.18.44 (6.18.44)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject line
**Record:** [net: cpsw_new] [unregister] — On cpsw_register_ports() failure after successful devlink registration, unregister the devlink instance instead of leaking it.

### Step 1.2: Tags
**Record:**
- **Reviewed-by:** Aleksandr Loktionov \<[email protected]\>
- **Reviewed-by:** Alexander Sverdlin \<[email protected]\> (reviewed prior stable-nominated error-path fixes in this driver)
- **Signed-off-by:** Guangshuo Li \<[email protected]\>
- **Link:** https://patch.msgid.link/20260604043115.1409134-1-
[email protected]
- **Signed-off-by:** Jakub Kicinski \<[email protected]\>
- No Fixes:, Reported-by:, Tested-by:, Cc: [email protected], or syzbot references
- v2 notes: subject updated for net-next; Fixes tag dropped

### Step 1.3: Body analysis
**Record:**
- **Bug:** cpsw_probe() registers devlink before ports. If cpsw_register_ports() fails, the error path unregisters notifiers but not devlink.
- **Symptom:** Orphaned devlink instance and registered devlink parameters after a failed probe.
- **Root cause:** Missing cpsw_unregister_devlink() on the port- registration failure path.
- **Version info:** None in the message; bug dates to devlink introduction in 2019.

### Step 1.4: Hidden bug fix?
**Record:** Yes. Described as cleanup, but it fixes a real resource- management bug: devlink allocated with devlink_alloc() (not devm) is never freed on this error path, and dl_priv->cpsw can dangle once devm frees cpsw.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Inventory
**Record:**
- **File:** drivers/net/ethernet/ti/cpsw_new.c (+3 / -1)
- **Function:** cpsw_probe()
- **Scope:** Single-file surgical fix in one error path

### Step 2.2: Code flow change
**Record:**
- **Hunk 1 (line 2051):** cpsw_register_ports() failure: goto clean_unregister_notifiers → goto clean_unregister_devlink
- **Hunk 2 (lines 2063–2064):** New label clean_unregister_devlink: calling cpsw_unregister_devlink(cpsw) before the existing notifier cleanup chain

**Before:** Port registration failure skipped devlink teardown. **After:** Port registration failure runs the same devlink cleanup as cpsw_remove().

### Step 2.3: Bug mechanism
**Record:** **Category:** Error-path resource leak (and potential UAF). **Mechanism:** cpsw_register_devlink() calls devlink_alloc(), devlink_params_register(), and devlink_register(). On port failure, only notifiers were torn down. cpsw (devm) is freed on probe failure while devlink (non-devm) remains registered with dl_priv->cpsw pointing at freed memory.

### Step 2.4: Fix quality
**Record:** Obviously correct — mirrors cpsw_remove(). Minimal, no API changes. Very low regression risk; only affects the cpsw_register_ports() failure path.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
**Record:** Buggy goto clean_unregister_notifiers after cpsw_register_ports() introduced in ed3525eda4c49 (2019-11-20, "introduce cpsw switchdev based driver part 1 - dual-emac"). Present in this tree.

### Step 3.2: Fixes: tag
**Record:** N/A — no Fixes: tag (dropped in v2).

### Step 3.3: Related file history
**Record:** Recent related stable-nominated error-path fixes already in this tree:
- 299b825716b82 — unnecessary netdev unregistration in cpsw_probe() error path (Cc: stable)
- 29739ec197ed6 — unregister of netdev not yet registered (Cc: stable)

Both fix cpsw_probe() error handling from the same original commit (Fixes: ed3525eda4c49). This patch is a third, complementary error- path fix.

### Step 3.4: Author context
**Record:** Guangshuo Li has no prior commits in cpsw_new.c in this tree. Reviewer Alexander Sverdlin reviewed the Kevin Hao stable fixes and this patch.

### Step 3.5: Dependencies
**Record:** Standalone. No series dependencies. Applies cleanly to this tree (verified with git apply --check).

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original discussion
**Record:** b4 am [email protected] found v2 patch thread. Lore/patch.msgid.link blocked by bot protection; content retrieved from local mbox. No replies in mbox; b4 reported 14 code-review trailers on lore (content not directly readable). No explicit stable nomination in the patch.

### Step 4.2: Reviewers
**Record:** Reviewed-by from Aleksandr Loktionov (Intel) and Alexander Sverdlin (Siemens, prior reviewer of stable-nominated cpsw error-path fixes).

### Step 4.3: Bug reports
**Record:** None. No syzbot, bugzilla, or user reports.

### Step 4.4: Related patches
**Record:** Part of ongoing cpsw_probe() error-path hardening alongside Kevin Hao's v1 series (Feb 2026). Those fixes are already in 6.18.44; this one is not yet.

### Step 4.5: Stable list history
**Record:** Could not search lore stable list (bot protection).
Precedent: related fixes in the same function were explicitly `Cc:
[email protected]`.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key functions
**Record:** cpsw_probe(), cpsw_register_devlink(), cpsw_unregister_devlink(), cpsw_register_ports()

### Step 5.2: Callers
**Record:** cpsw_probe() is the platform_driver.probe callback for cpsw_new (TI CPSW on AM335x, AM4372, DRA7, etc.). Called during platform device enumeration / module load.

### Step 5.3: Callees
**Record:** On failure path, fix adds devlink_unregister(), devlink_params_unregister(), devlink_free() via cpsw_unregister_devlink().

### Step 5.4: Reachability
**Record:** Triggered when register_netdev() fails inside cpsw_register_ports() during probe — uncommon but reachable on boot/module load (ENOMEM, registration failure, etc.). Not userspace- triggerable directly, but affects device bring-up.

### Step 5.5: Similar patterns
**Record:** am65-cpsw-nuss.c has its own devlink registration with proper cleanup in remove; this fix addresses the parallel gap in cpsw_new.c only.

---

## PHASE 6: CROSS-REFERENCING AGAINST LOCAL TREE

### Step 6.1: Buggy code present?
**Record:** **Yes.** In cpsw_new.c at lines 2049–2051:

```2049:2051:drivers/net/ethernet/ti/cpsw_new.c
        ret = cpsw_register_ports(cpsw);
        if (ret)
                goto clean_unregister_notifiers;
```

clean_unregister_devlink does not exist; devlink is not unregistered on this path.

### Step 6.2: Backport complications
**Record:** Clean apply expected — git apply --check passed with no conflicts.

### Step 6.3: Related fixes already present?
**Record:** Kevin Hao's netdev error-path fixes (299b825716b82, 29739ec197ed6) are in tree. This devlink cleanup fix is **not** yet applied.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

### Step 7.1: Subsystem criticality
**Record:** **drivers/net/ethernet/ti** — IMPORTANT for embedded TI platforms (AM33xx, AM4372, DRA7). CONFIG_TI_CPSW_SWITCHDEV / module cpsw_new.

### Step 7.2: Subsystem activity
**Record:** Active — multiple 2026 commits including error-path fixes for this same probe function.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Who is affected
**Record:** Users of TI CPSW (cpsw_new) on OMAP/AM33xx/AM4372/DRA7 platforms with CONFIG_TI_CPSW_SWITCHDEV enabled.

### Step 8.2: Trigger conditions
**Record:** cpsw_register_ports() → register_netdev() fails during probe. Uncommon (boot/module-load error path). Not a normal runtime path.

### Step 8.3: Failure mode severity
**Record:**
- **Primary:** Devlink memory leak; orphaned devlink registration and sysfs entries after failed probe
- **Secondary:** dl_priv->cpsw may point at devm-freed cpsw — potential UAF if devlink is accessed after failed probe
- **Severity:** **MEDIUM** — error-path only, rare trigger, but real resource bug with UAF potential; not a hot-path crash

### Step 8.4: Risk-benefit
**Record:**
- **Benefit:** MEDIUM — completes error-path cleanup already being fixed in this driver for stable
- **Risk:** VERY LOW — 3-line change, mirrors existing remove path
- **Ratio:** Favorable for backport

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence

**FOR backport:**
- Real bug present since 2019 in this tree
- Missing devlink cleanup on probe error path
- Non-devm devlink allocation leaked; dangling pointer to devm-freed cpsw
- Trivial, obviously correct fix; applies cleanly
- Reviewed by driver maintainers
- Same cpsw_probe() error path already received stable-nominated fixes in 6.18.44
- Matches stable pattern for probe error-path resource leaks

**AGAINST backport:**
- Only triggers on rare register_netdev() failure during probe
- No user reports, syzbot, or CVE
- Not a normal-operation crash
- No explicit Cc: stable on this patch

**Unresolved:** Full lore review thread content (bot-blocked); exact severity if devlink sysfs is accessed post-failed-probe is inferred from code, not reproduced.

### Step 9.2: Stable rules checklist
1. Obviously correct and tested? **PASS** — mirrors cpsw_remove(); reviewed by two maintainers
2. Fixes a real bug? **PASS** — devlink leak on probe failure
3. Important issue? **PASS (MEDIUM)** — resource leak with UAF potential on error path; not critical hot-path crash
4. Small and contained? **PASS** — 3 lines, one file
5. No new features/APIs? **PASS**
6. Can apply to local tree? **PASS** — bug present; patch applies cleanly

### Step 9.3: Exception categories
**Record:** N/A — standard error-path bug fix, not device ID/quirk/build/doc exception.

### Step 9.4: Decision rationale

For **6.18.44**, the buggy code exists and has since devlink support landed in 2019. The fix is minimal, correct, and consistent with stable- nominated error-path fixes already merged for the same cpsw_probe() function. While the trigger is uncommon, leaving devlink registered after probe failure leaks resources and leaves a dangling cpsw pointer inside devlink private data. This is appropriate stable material for this tree.

---

## Verification

- **[Phase 1]** Parsed commit message and tags from user query and mbox file
- **[Phase 1]** v2 changelog: Fixes tag dropped; subject updated for net-next
- **[Phase 2]** Diff: +3/-1 in cpsw_probe(); adds clean_unregister_devlink label
- **[Phase 2]** Read cpsw_register_devlink() / cpsw_unregister_devlink() — non-devm devlink_alloc() with dl_priv->cpsw = cpsw
- **[Phase 3]** git describe HEAD: v6.18.44
- **[Phase 3]** git blame -L 2045,2051: buggy path from ed3525eda4c49 (2019-11-20)
- **[Phase 3]** git log --oneline -20 -- cpsw_new.c: related stable fixes 299b825716b82, 29739ec197ed6 present
- **[Phase 3]** git log -S cpsw_register_devlink: introduced in ed3525eda4c49
- **[Phase 3]** git apply --check: patch applies cleanly
- **[Phase 4]** b4 am 20260604043115...: found v2 patch; Reviewed-by tags confirmed
- **[Phase 4]** Lore/patch.msgid.link fetch: blocked by Anubis bot protection
- **[Phase 5]** Read cpsw_register_ports() — fails on register_netdev() error
- **[Phase 5]** cpsw_remove() calls cpsw_unregister_devlink() — fix matches remove path
- **[Phase 6]** Confirmed buggy goto clean_unregister_notifiers at lines 2049–2051 in current tree
- **[Phase 6]** grep clean_unregister_devlink: not present — fix not yet applied
- **[Phase 7]** Kconfig: TI_CPSW_SWITCHDEV selects NET_DEVLINK, module cpsw_new
- **[Phase 8]** UAF potential inferred from non-devm devlink + devm cpsw — not runtime-tested

**YES**

 drivers/net/ethernet/ti/cpsw_new.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/ti/cpsw_new.c +3 -1
index c6cf7a0375e08..34c0e651e2da3 100644
@@ -2048,7 +2048,7 @@ static int cpsw_probe(struct platform_device *pdev)
 
 	ret = cpsw_register_ports(cpsw);
 	if (ret)
-		goto clean_unregister_notifiers;
+		goto clean_unregister_devlink;
 
 	dev_notice(dev, "initialized (regs %pa, pool size %d) hw_ver:%08X %d.%d (%d)\n",
 		   &ss_res->start, descs_pool_size,
@@ -2060,6 +2060,8 @@ static int cpsw_probe(struct platform_device *pdev)
 
 	return 0;
 
+clean_unregister_devlink:
+	cpsw_unregister_devlink(cpsw);
 clean_unregister_notifiers:
 	cpsw_unregister_notifiers(cpsw);
 clean_cpts:
Signature · 1 line
2.53.0
author maintainer
#732 lore raw

PATCH 1/1 Bluetooth: btusb: Add TP-Link UB600 for Realtek 8761BUV

In reply to Sasha Levin

From: Nils Helmig <[email protected]>

[ Upstream commit bc597f0cc44f0b173c50ee986a047219cd559ee9 ]

Add the vendor/product ID (0x37ad, 0x0600) to usb_device_id table for Realtek 8761BUV.

The device info from /sys/kernel/debug/usb/devices as below.

T:  Bus=03 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  4 Spd=12   MxCh= 0
D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=37ad ProdID=0600 Rev= 2.00
S:  Manufacturer=
S:  Product=TP-Link Bluetooth USB Adapter
S:  SerialNumber=ACA7F14FD2A5
C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA
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=1ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
E:  Ad=83(I) 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=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
E:  Ad=83(I) 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=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
E:  Ad=83(I) 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=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
E:  Ad=83(I) 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=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
E:  Ad=83(I) 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=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms

---

LLM Generated explanations, may be completely bogus:

Connection lost, reconnecting to https://agentn.us.api5.cursor.sh
(attempt 1)...
Retry attempt 1...
Connection lost, reconnecting to https://agentn.us.api5.cursor.sh
(attempt 2)...
Retry attempt 2...
# Stable Backport Analysis: Bluetooth: btusb: Add TP-Link UB600 for Realtek 8761BUV

**Local tree:** Linux **6.18.44** (v6.18.44-1-g2736c32da98b9) **Upstream commit:** bc597f0cc44f0b173c50ee986a047219cd559ee9 (present on master, **not** an ancestor of current HEAD)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1 – Subject line**
Record: [Bluetooth: btusb] [Add] [TP-Link UB600 USB ID (0x37ad:0x0600) for Realtek 8761BUV chipset]

**Step 1.2 – Tags**
Record:
- Signed-off-by: Nils Helmig <[email protected]> (author)
- Reviewed-by: Paul Menzel <[email protected]>
- Signed-off-by: Luiz Augusto von Dentz <[email protected]> (Bluetooth maintainer)
- No Fixes:, Reported-by:, Link:, Cc: [email protected], Tested-by:, or Acked-by:

Notable: maintainer Signed-off-by and Reviewed-by present; no syzbot or crash report (expected for device-ID patches).

**Step 1.3 – Body analysis**
Record:
- **Bug described:** TP-Link UB600 (VID 0x37ad, PID 0x0600) is a Realtek 8761BUV USB Bluetooth adapter not recognized in quirks_table.
- **Symptom:** Device enumerates as generic Bluetooth USB (Cls=e0) but lacks the Realtek-specific quirk flags needed for proper driver handling.
- **Root cause (from code context):** Without a quirks_table entry with BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH, the chip does not get Realtek firmware setup via btrtl.
- **Version info:** None in commit message.

**Step 1.4 – Hidden bug fix?**
Record: **Yes, disguised as hardware enablement.** This is not a crash fix, but a functional bug: the adapter does not work on Linux without the ID. External documentation confirms users must manually patch btusb.c to load firmware on pre-7.2 kernels.

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1 – Inventory**
Record:
- **Files:** drivers/bluetooth/btusb.c (+2 / -0)
- **Function/section:** quirks_table[] static table
- **Scope:** Single-file, 2-line surgical addition

**Step 2.2 – Code flow change**
Record:
- **Before:** 0x37ad:0x0600 not in quirks_table; device may bind via generic btusb_table USB class match with driver_info == 0.
- **After:** Device matches quirks_table entry with BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH.
- **Affected path:** USB probe → btusb_probe() → usb_match_id(intf, quirks_table) when id->driver_info is zero (lines 4018–4023).

**Step 2.3 – Bug mechanism**
Record: **Hardware quirk / device ID category (exception #1).** Without BTUSB_REALTEK:
- No btrealtek_data allocation (line 4108)
- No btusb_setup_realtek / btrtl_shutdown_realtek hooks (lines 4279–4285)
- Realtek 8761BU firmware (rtl_bt/rtl8761bu_fw) is never loaded via btrtl

**Step 2.4 – Fix quality**
Record:
- **Obviously correct:** Uses identical flags as all other 8761BUV entries in the same section (e.g., 0x2b89:0x6275, 0x2357:0x0604 TP-Link UB500).
- **Minimal:** 2 lines, no unrelated changes.
- **Regression risk:** Very low — only affects this specific VID/PID.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1 – Blame**
Record: Target insertion point is the /* Additional Realtek 8761BUV Bluetooth devices */ section (lines 788–804), present since 2022 (c77a592befddf). Last entry 0x2b89:0x6275 added in 112a000505b88 (Oct 2025). The 8761BUV infrastructure is long-established in this tree.

**Step 3.2 – Fixes: tag**
Record: N/A — no Fixes: tag present.

**Step 3.3 – Related file history**
Record:
- 4fd6d49079617 (2021): Added TP-Link UB500 (0x2357:0x0600) — same vendor family, same chip class, same pattern; **already in 6.18.44**
- 112a000505b88: Added 0x2b89:0x6275 for RTL8761BUV
- Recent btusb commits on 6.18.y are bug fixes (UAF, vendor event validation), unrelated to this ID

**Step 3.4 – Author context**
Record: Nils Helmig is a contributor (not subsystem maintainer). Luiz Augusto von Dentz (maintainer) has Signed-off-by on the committed version.

**Step 3.5 – Dependencies**
Record: **Standalone.** No series dependencies. All required symbols (BTUSB_REALTEK, BTUSB_WIDEBAND_SPEECH, quirks_table, btrtl 8761BU support) exist in 6.18.44. git apply --check succeeds with 2-line offset.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1 – Original discussion**
Record:
- Lore URL:
https://patch.msgid.link/[email protected]
- Series: v1 (2026-04-25) → v3 (2026-05-30); committed version is v3 (latest)

**Step 4.2 – Reviewers**
Record (b4 dig -w): CC'd to [email protected], Marcel Holtmann, Luiz Augusto von Dentz. Appropriate maintainers were included.

**Step 4.3 – Bug reports**
Record: No formal bugzilla/syzbot report. User blog (myshell.co.uk) documents that UB600 requires manual btusb.c patching on kernels before 7.2 — confirms real user impact.

**Step 4.4 – Related patches**
Record: Standalone 1-patch series. No other patches required.

**Step 4.5 – Stable list**
Record: No stable-list discussion found. Not a negative signal.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1 – Key functions**
Record: quirks_table[] (data), consumed by btusb_probe() via usb_match_id().

**Step 5.2 – Callers**
Record: btusb_probe() called during USB device enumeration on plug-in — common, user-triggered path.

**Step 5.3 – Callees**
Record: When BTUSB_REALTEK is set, probe path uses btrtl_set_driver_name(), btusb_setup_realtek(), btrtl_shutdown_realtek() — all present in tree when CONFIG_BT_HCIBTUSB_RTL is enabled.

**Step 5.4 – Reachability**
Record: Any user plugging in a TP-Link UB600 triggers this. Unprivileged physical access (USB insert). Not a security issue, but broad hardware enablement.

**Step 5.5 – Similar patterns**
Record: TP-Link UB500 (0x2357:0x0604) in the same 8761BUV section with identical flags — direct precedent already in 6.18.44.

---

## PHASE 6: CROSS-REFERENCING AGAINST LOCAL TREE (6.18.44)

**Step 6.1 – Buggy code exists?**
Record: **YES.** The 8761BUV quirks_table section exists (lines 788–804) but lacks 0x37ad:0x0600. 0x37ad not present anywhere in drivers/bluetooth/btusb.c. Commit bc597f0 is **NOT** an ancestor of HEAD.

**Step 6.2 – Backport complications**
Record: **Clean apply.** git apply --check succeeded (hunk at line 802, offset 2). No refactoring conflicts.

**Step 6.3 – Related fixes already present?**
Record: **No.** git log --grep="UB600" and git log -S'0x37ad' on btusb.c return nothing. UB500 support (4fd6d49079617) is present as precedent.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1 – Subsystem**
Record: drivers/bluetooth/btusb.c — Bluetooth USB HCI driver. **Criticality: IMPORTANT** (affects users of USB Bluetooth adapters, not core kernel).

**Step 7.2 – Activity**
Record: Actively maintained; recent stable commits include Realtek validation fixes and UAF fixes.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1 – Who is affected**
Record: Users of TP-Link UB600 USB Bluetooth adapters on 6.18.y without this ID.

**Step 8.2 – Trigger conditions**
Record: Plugging in TP-Link UB600 (0x37ad:0x0600). Common user action. Requires CONFIG_BT_HCIBTUSB (and CONFIG_BT_HCIBTUSB_RTL for firmware — same as all other Realtek USB BT devices).

**Step 8.3 – Failure mode severity**
Record: **Bluetooth non-functional** (no firmware load, limited ROM-only mode). Severity: **MEDIUM** for affected hardware — device is effectively broken without the ID. Not a crash/corruption/security issue.

**Step 8.4 – Risk-benefit**
Record:
- **Benefit:** HIGH for UB600 owners (device works out of box)
- **Risk:** VERY LOW (2-line ID addition, identical to 8 existing 8761BUV entries)
- **Ratio:** Strongly favors backport

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1 – Evidence summary**

**FOR backport:**
- Standard stable exception: new USB device ID for existing driver
- Direct precedent: TP-Link UB500 (0x2357:0x0600) already in 6.18.44 with same flags
- Real user impact documented (manual patching required without kernel support)
- Maintainer Signed-off-by + Reviewed-by
- Applies cleanly to 6.18.44
- All infrastructure (8761BUV section, btrtl 8761BU firmware) present

**AGAINST backport:**
- Not a crash/security/corruption fix
- Only affects one specific USB adapter model
- Requires CONFIG_BT_HCIBTUSB_RTL for full functionality (same as all Realtek btusb devices)

**Unresolved:** None material to the decision.

**Step 9.2 – Stable rules checklist**
1. Obviously correct and tested? **PASS** — identical pattern to existing entries; Reviewed-by present
2. Fixes a real bug affecting users? **PASS** — hardware non-functional without ID
3. Important issue? **PASS** — hardware enablement (stable-accepted category)
4. Small and contained? **PASS** — 2 lines, 1 file
5. No new features/APIs? **PASS** — device ID only
6. Can apply to local tree? **PASS** — verified clean apply

**Step 9.3 – Exception category**
Record: **NEW DEVICE ID** — adding 0x37ad:0x0600 to existing btusb driver's quirks_table for already-supported Realtek 8761BUV chipset.

---

## What Problem This Solves

The TP-Link UB600 is a Realtek RTL8761BU-based USB Bluetooth adapter sold under TP-Link's vendor ID (0x37ad:0x0600) rather than Realtek's (0x0bda). Without this quirks_table entry, btusb_probe() never sets BTUSB_REALTEK, so the btrtl firmware loader never runs and Bluetooth does not work. Adding the ID with the same flags as other 8761BUV devices enables full functionality — exactly as was done earlier for the TP-Link UB500 (0x2357:0x0600) already present in 6.18.44.

---

## Verification

- [Phase 1] Parsed subject, tags, body; identified device-ID enablement pattern
- [Phase 2] Diff: +2 lines in quirks_table[], BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH
- [Phase 3] git describe HEAD: v6.18.44; git merge-base --is-ancestor bc597f0 HEAD: NOT ancestor
- [Phase 3] git blame -L 788,804: 8761BUV section present since 2022
- [Phase 3] 4fd6d49079617: TP-Link UB500 precedent in tree
- [Phase 3] git apply --check: patch applies cleanly (offset 2)
- [Phase 4] b4 dig -c bc597f0: lore thread found (v3, 2026-05-30)
- [Phase 4] b4 dig -a: v1→v3 series; v3 is latest
- [Phase 4] b4 dig -w: Marcel Holtmann, Luiz von Dentz CC'd
- [Phase 5] Read btusb_probe() lines 4018–4023, 4108–4113, 4279–4285:
confirmed Realtek flag dependency
- [Phase 5] btrtl.c lines 225–231: 8761BU firmware support present
- [Phase 6] grep 0x37ad btusb.c: not present; 0x2357, 0x0604 (UB500) present at line 789
- [Phase 6] CONFIG_BT_HCIBTUSB_RTL in Kconfig: present
- [Phase 8] External blog confirms pre-7.2 kernels need manual patch for UB600

**YES**

 drivers/bluetooth/btusb.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
index fad09a01ae125..38a066cc3404a 100644
@@ -815,6 +815,8 @@ static const struct usb_device_id quirks_table[] = {
 						     BTUSB_WIDEBAND_SPEECH },
 	{ USB_DEVICE(0x2b89, 0x6275), .driver_info = BTUSB_REALTEK |
 						     BTUSB_WIDEBAND_SPEECH },
+	{ USB_DEVICE(0x37ad, 0x0600), .driver_info = BTUSB_REALTEK |
+						     BTUSB_WIDEBAND_SPEECH },
 
 	/* Additional Realtek 8821AE Bluetooth devices */
 	{ USB_DEVICE(0x0b05, 0x17dc), .driver_info = BTUSB_REALTEK },
Signature · 1 line
2.53.0
author maintainer
#733 lore raw

PATCH 1/1 ALSA: usb-audio: Add FIXED_RATE quirk for JBL Quantum650 Wireless

In reply to Sasha Levin

From: "Daniel C. Ribeiro" <[email protected]>

[ Upstream commit f6d6a4147ace0c417035f65b021027c209c75190 ]

JBL Quantum650 Wireless (0ecb:2125) requires the same workaround that was used for JBL Quantum610 and Quantum810 for limiting the sample rate. Without it, the capture (microphone) stream fails to work. Setting the QUIRK_FLAG_FIXED_RATE flag, as done for the sibling models, makes both playback and capture work correctly.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: ALSA usb-audio JBL Quantum650 FIXED_RATE Quirk

**Local tree:** v6.18.44 (git describe HEAD →
v6.18.44-2-g1b9e1abadee04, Makefile 6.18.44)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject Line
**Record:** [ALSA: usb-audio] [Add] — Add a USB audio quirk flag entry for JBL Quantum650 Wireless headset.

### Step 1.2: Tags
**Record:**
- **Signed-off-by:** Daniel C. Ribeiro <[email protected]> (author)
- **Link:**
https://patch.msgid.link/[email protected]
- **Signed-off-by:** Takashi Iwai <[email protected]> (ALSA/usb-audio maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Cc:
[email protected]
- Notable: Maintainer SOB; no syzbot or bugzilla link (unlike Quantum610’s bugzilla reference)

### Step 1.3: Body Analysis
**Record:**
- **Bug:** JBL Quantum650 Wireless (USB ID 0ecb:2125) needs QUIRK_FLAG_FIXED_RATE, same as Quantum610/810.
- **Symptom:** Without it, capture (microphone) stream fails; playback may work but mic does not.
- **Root cause (author):** Driver tries to set sample rate on an endpoint that only supports a fixed rate; skipping rate-setting fixes both directions.
- **Version info:** None in message.

### Step 1.4: Hidden Bug Fix?
**Record:** Not disguised — this is an explicit hardware quirk/workaround. Functionally fixes broken microphone on a specific USB headset.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Inventory
**Record:**
- **Files:** sound/usb/quirks.c (+2 lines)
- **Functions:** quirk_flags_table[] static table only
- **Scope:** Single-file, surgical, 2-line addition

### Step 2.2: Code Flow Change
**Record:**
- **Before:** Device 0ecb:2125 not in quirk_flags_table; no QUIRK_FLAG_FIXED_RATE at probe.
- **After:** On probe of 0ecb:2125, snd_usb_init_quirk_flags_table() sets QUIRK_FLAG_FIXED_RATE on chip->quirk_flags.
- **Affected path:** USB audio device probe → stream open (snd_usb_hw_params) → endpoint setup (snd_usb_endpoint_set_params).

### Step 2.3: Bug Mechanism
**Record:**
- **Category:** Hardware workaround (g)
- **Mechanism:** With QUIRK_FLAG_FIXED_RATE, snd_usb_pcm_has_fixed_rate() returns true; ep->fixed_rate is set; snd_usb_init_sample_rate() is skipped in endpoint.c when !ep->fixed_rate is false. Without the quirk, the driver attempts rate changes the firmware rejects, breaking capture.

### Step 2.4: Fix Quality
**Record:**
- **Quality:** Obviously correct — identical pattern to Quantum610 (0x205c) and Quantum810 (0x2069) already in this tree.
- **Regression risk:** Very low — only affects 0ecb:2125.
- **Red flags:** None.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
**Record:** Quantum610/810 entries blame to 5d324e5159d9e (2025-11-28 merge). QUIRK_FLAG_FIXED_RATE infrastructure predates 6.18 (Quantum610 quirk upstream since 2023, backported as 36dba3f4cd36c). Buggy behavior (missing quirk for 650) exists whenever this hardware is used without the entry.

### Step 3.2: Fixes: Tag
**Record:** N/A — no Fixes: tag.

### Step 3.3: Related Changes
**Record:**
- Upstream commit: f6d6a4147ace0 (mainline, Takashi Iwai, 2026-07-19)
- Stable-format commit: 5a8dda89e6e59 (same patch with upstream marker)
- Related: 36dba3f4cd36c added Quantum610 quirk (backported to stable previously)
- Standalone v1 patch; not part of a series

### Step 3.4: Author Context
**Record:** Daniel C. Ribeiro — user reporter/contributor. Takashi Iwai (maintainer) committed to mainline. Pattern matches maintainer-handled device quirk additions.

### Step 3.5: Dependencies
**Record:** No dependencies. Requires only existing QUIRK_FLAG_FIXED_RATE flag and quirk_flags_table mechanism — both present in this tree.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original Discussion
**Record:**
- **URL:**
https://patch.msgid.link/[email protected]
(via b4 dig -c f6d6a4147ace0)
- **Revisions:** v1 only (b4 dig -a)
- **Reviewer feedback:** Takashi Iwai replied “Applied now. Thanks.”
- **Stable nominations:** None in thread
- **NAKs/concerns:** None

### Step 4.2: Reviewers
**Record:** (b4 dig -w) CC'd: Takashi Iwai, Jaroslav Kysela, linux- [email protected], [email protected]. Appropriate maintainers included.

### Step 4.3: Bug Report
**Record:** No external bug report link. Author-reported hardware issue with clear reproduction (mic fails without quirk, works with it). Quantum610 had bugzilla #216798; Quantum650 does not.

### Step 4.4: Related Patches
**Record:** Same pattern as Quantum610/810 quirks. No other patches in series required.

### Step 4.5: Stable List
**Record:** Not searched separately; no stable discussion found in patch thread. WebFetch to lore blocked by bot protection; b4 dig -m succeeded.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key Functions
**Record:** quirk_flags_table[], snd_usb_init_quirk_flags_table(), snd_usb_pcm_has_fixed_rate(), snd_usb_hw_params(), snd_usb_endpoint_set_params().

### Step 5.2: Callers
**Record:** snd_usb_init_quirk_flags_table() called from snd_usb_init_quirk_flags() in card.c during USB audio probe (snd_usb_audio_probe path). Every USB audio device probes through this path when CONFIG_SND_USB_AUDIO is enabled.

### Step 5.3: Callees
**Record:** Table lookup sets chip->quirk_flags; downstream snd_usb_pcm_has_fixed_rate() gates fixed_rate on endpoints; snd_usb_init_sample_rate() skipped when ep->fixed_rate is true.

### Step 5.4: Reachability
**Record:** Triggered when user plugs in JBL Quantum650 Wireless (0ecb:2125) and opens a capture stream. Reachable from normal userspace audio use (PulseAudio/PipeWire/ALSA). No privileges required beyond device access.

### Step 5.5: Similar Patterns
**Record:** Quantum610 (0x205c) and Quantum810 (0x2069) use identical QUIRK_FLAG_FIXED_RATE in the same table at lines 2275–2278 of this tree’s quirks.c.

---

## PHASE 6: CROSS-REFERENCING AGAINST LOCAL TREE

### Step 6.1: Buggy Code Present?
**Record:** **Yes.** 0x0ecb:0x2125 is absent from quirk_flags_table. Sibling entries for 610/810 exist. QUIRK_FLAG_FIXED_RATE exists in usbaudio.h, pcm.c, quirks.c. Commit f6d6a4147ace0 is **not** an ancestor of HEAD (merge-base --is-ancestor exit code 1).

### Step 6.2: Backport Complications
**Record:** Upstream patch context is at line ~2346; local file has entries at lines 2275–2278. git apply --check fails on line offset only. Insertion point is unambiguous — two lines between Quantum610 and Quantum810 entries. **Trivial manual adaptation.**

### Step 6.3: Related Fixes Already Present?
**Record:** Quantum610 and Quantum810 quirks present. No existing fix for 0x2125.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

### Step 7.1: Subsystem
**Record:** sound/usb — ALSA USB audio driver. **Criticality:
IMPORTANT** (common desktop/laptop USB headset path, not core kernel).

### Step 7.2: Activity
**Record:** quirks.c actively maintained in 6.18.y (recent Scarlett, NeuralDSP, MOONDROP quirk commits in log).

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Who Is Affected
**Record:** Users of JBL Quantum650 Wireless USB headset with CONFIG_SND_USB_AUDIO. Driver-specific, not universal.

### Step 8.2: Trigger Conditions
**Record:** Plug in headset, open microphone/capture stream. Common usage scenario for headset owners. Unprivileged users with audio device access can trigger.

### Step 8.3: Failure Severity
**Record:** **MEDIUM** — microphone capture non-functional (functional hardware breakage). No kernel crash, panic, corruption, or security issue reported. Playback may work; capture fails.

### Step 8.4: Risk-Benefit
**Record:**
- **Benefit:** Restores full headset functionality for Quantum650 owners; proven pattern from sibling models.
- **Risk:** Minimal — 2-line table entry, device-specific.
- **Ratio:** Strong benefit for affected users, negligible risk.

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence Summary

**FOR backport:**
- Hardware quirk exception category (explicitly stable-appropriate)
- Real user-visible bug (broken microphone)
- 2-line, surgical, same pattern as already-backported Quantum610 quirk
- Reviewed and applied by subsystem maintainer (Takashi Iwai)
- All infrastructure present in 6.18.44 tree
- Standalone, no dependencies
- Low regression risk (device-ID-specific)

**AGAINST backport:**
- Not a crash/security/corruption issue (functional breakage only)
- Affects narrow hardware population
- Patch context line numbers differ (trivial adaptation needed)
- No explicit stable nomination or bugzilla report

**Unresolved:** None material to the decision.

### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **PASS** — identical to proven sibling quirks; maintainer applied.
2. Fixes real bug affecting users? **PASS** — broken mic capture on Quantum650.
3. Important issue? **PASS** (hardware functionality) — not crash-level, but real broken hardware; quirk category is standard stable material.
4. Small and contained? **PASS** — 2 lines, one file.
5. No new features or APIs? **PASS** — table entry only.
6. Can apply to local tree? **PASS** — trivial insert between existing entries (minor line offset).

### Step 9.3: Exception Category
**Record:** **Hardware quirk/workaround** — USB audio device ID with existing QUIRK_FLAG_FIXED_RATE flag.

### Step 9.4: Decision Rationale

This commit adds a device-specific quirk for the JBL Quantum650 Wireless headset, mirroring fixes already present for Quantum610 and Quantum810 in this 6.18.44 tree. Without it, microphone capture fails because the driver incorrectly attempts to set the sample rate on a fixed-rate endpoint. The fix is minimal, maintainer-reviewed, uses existing infrastructure, and matches a well-established stable backport pattern (Quantum610 was previously backported similarly). The patch does not apply verbatim due to line-number drift but requires only a trivial two- line insertion at the obvious location between sibling entries.

---

## Verification

- **[Phase 1]** Parsed subject, tags, body from provided commit message and git show f6d6a4147ace0
- **[Phase 2]** Diff analysis: +2 lines in quirk_flags_table[]; read pcm.c:178-204, pcm.c:482-576, endpoint.c:792-844, endpoint.c:1430-1435, usbaudio.h:217-219
- **[Phase 3]** git blame lines 2270-2285: Quantum610/810 from 5d324e5159d9e; git show 36dba3f4cd36c (Quantum610 stable backport); merge-base --is-ancestor f6d6a4147ace0 HEAD → exit 1 (not in tree)
- **[Phase 4]** b4 dig -c f6d6a4147ace0: found thread; b4 dig -w:
maintainers CC'd; b4 dig -a: v1 only; b4 dig -m /tmp/jbl650.mbox:
maintainer “Applied now. Thanks.”
- **[Phase 5]** grep snd_usb_init_quirk_flags_table: called from card.c:728; traced QUIRK_FLAG_FIXED_RATE usage in pcm.c, endpoint.c, implicit.c
- **[Phase 6]** git describe HEAD: v6.18.44; grep 0x2125 sound/usb/quirks.c: not present; sibling entries at 2275-2278 confirmed; git apply --check on upstream diff: fails on line offset only
- **[Phase 7]** Subsystem: sound/usb; recent quirks.c activity confirmed via git log --oneline -20 -- sound/usb/quirks.c
- **[Phase 8]** Impact: Quantum650 headset users; trigger on capture stream open; severity MEDIUM (functional)

---

**YES**The history search for 0x2125 finished: that USB ID does not appear anywhere in sound/usb/quirks.c in this tree. The only close hits were unrelated files (e.g. drivers/scsi/qla2xxx debug strings), so the Quantum650 quirk is genuinely missing here.

That matches the earlier analysis: this is a 2-line hardware quirk addition (same QUIRK_FLAG_FIXED_RATE pattern as the Quantum610/810 entries already in v6.18.44), and it should be backported.

**YES**The ancestor check finished: f6d6a4147ace0 (the upstream Quantum650 quirk commit) is **not** in this tree’s HEAD (merge-base --is-ancestor returned exit code 1). The fix still needs to be backported here.The Quantum610 history search finished. In this tree, the 0x0ecb:0x205c entry first shows up via the usb-6.18-rc8 merge (5d324e5159d9e, 2025-11-28); git blame points the Quantum610/810 QUIRK_FLAG_FIXED_RATE lines at that merge.

The original upstream quirk was added earlier (36dba3f4cd36c / dfd5fe19db7dc, 2023). So the infrastructure and sibling quirks are already here — only the Quantum650 (0x2125) entry is missing.

 sound/usb/quirks.c | 2 ++
 1 file changed, 2 insertions(+)
sound/usb/quirks.c +2 -0
index a1bdb77843448..a06fb05e6dcd1 100644
@@ -2274,6 +2274,8 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = {
 		   QUIRK_FLAG_CTL_MSG_DELAY_1M | QUIRK_FLAG_MIXER_PLAYBACK_MIN_MUTE),
 	DEVICE_FLG(0x0ecb, 0x205c, /* JBL Quantum610 Wireless */
 		   QUIRK_FLAG_FIXED_RATE),
+	DEVICE_FLG(0x0ecb, 0x2125, /* JBL Quantum650 Wireless */
+		   QUIRK_FLAG_FIXED_RATE),
 	DEVICE_FLG(0x0ecb, 0x2069, /* JBL Quantum810 Wireless */
 		   QUIRK_FLAG_FIXED_RATE),
 	DEVICE_FLG(0x0fd9, 0x0008, /* Hauppauge HVR-950Q */
Signature · 1 line
2.53.0
author maintainer
#734 lore raw

PATCH 1/1 net: ibm: emac: fix unchecked platform_get_irq return value

In reply to Sasha Levin

From: Rosen Penev <[email protected]>

[ Upstream commit 1681cb1bde051c3b9ebbd337c0bfdd3e74167b2f ]

platform_get_irq() returns a negative errno on failure. Commit a598f66d9169 replaced irq_of_parse_and_map() (which returns 0 on failure) with platform_get_irq() but dropped the error check. Without it, a negative IRQ number is passed to devm_request_irq(), which fails with -EINVAL instead of propagating the real error from platform_get_irq().

Add the missing error check and goto err_gone.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit Message Forensics

### Step 1.1: Subject Line
**Record:** [net: ibm: emac] [fix] — restore missing error checking on platform_get_irq() return value in emac_probe().

### Step 1.2: Tags
**Record:**
- **Fixes:** — not present (expected for manual review)
- **Reported-by:** — none
- **Tested-by:** — none
- **Reviewed-by:** Jacob Keller \<[email protected]\>
- **Acked-by:** — none
- **Link:**
https://patch.msgid.link/[email protected]
- **Cc: stable:** — none (expected)
- **Signed-off-by:** Rosen Penev (author), Jakub Kicinski (net maintainer); ignore pipeline-added SOBs

Notable: reviewed by a netdev reviewer; no syzbot/user reports.

### Step 1.3: Body Analysis
**Record:**
- **Bug:** Commit a598f66d9169 switched from irq_of_parse_and_map() (returns 0 on failure, with an explicit check) to platform_get_irq() (returns negative errno on failure) but removed the error check.
- **Symptom:** A negative IRQ number is passed to devm_request_irq(), which returns -EINVAL instead of the real errno from platform_get_irq().
- **Root cause:** API semantics mismatch during refactor — old API used 0 for failure; new API uses negative errnos and requires an explicit check.
- **Version info:** Bug introduced by a598f66d9169 ("net: ibm: emac:
use platform_get_irq"), present since v6.18 in this tree.

### Step 1.4: Hidden Bug Fix Detection
**Record:** Yes — despite the straightforward message, this is a functional probe-path bug, not cosmetic cleanup. Mishandling -EPROBE_DEFER can prevent deferred reprobing (verified against platform_get_irq() / platform_get_irq_optional() in drivers/base/platform.c).

---

## Phase 2: Diff Analysis

### Step 2.1: Inventory
**Record:**
- **File:** drivers/net/ethernet/ibm/emac/core.c (+5 lines)
- **Function:** emac_probe()
- **Scope:** Single-file, surgical fix in driver probe error path

### Step 2.2: Code Flow Change
**Record:**
- **Before:** dev->emac_irq = platform_get_irq(...) → immediately devm_request_irq(..., dev->emac_irq, ...)
- **After:** If dev->emac_irq < 0, set err = dev->emac_irq and goto err_gone; otherwise proceed to devm_request_irq()
- **Path affected:** IRQ setup during platform device probe, specifically the failure path

### Step 2.3: Bug Mechanism
**Record:** **Category:** Error-path / API misuse / probe-deferral bug
- platform_get_irq() can return -EPROBE_DEFER, -ENXIO, etc.
- request_irq() path does irq_to_desc(irq); invalid/negative IRQ → -EINVAL
- Without the check, -EPROBE_DEFER becomes -EINVAL, breaking deferred probe
- Even for permanent failures, wrong errno is returned and a misleading second error is logged

### Step 2.4: Fix Quality
**Record:** Obviously correct; matches the documented platform_get_irq() usage pattern in drivers/base/platform.c. Minimal change, no API changes, very low regression risk.

---

## Phase 3: Git History Investigation

### Step 3.1: Blame
**Record:** Line 3045 (platform_get_irq) introduced by a598f66d91693 (Oct 2024). Prior code used irq_of_parse_and_map() with an explicit if (!dev->emac_irq) check since 2007-era code.

### Step 3.2: Fixes: Tag
**Record:** N/A — no Fixes: tag. Manually identified introducing commit a598f66d9169, confirmed present in this tree (git merge-base --is-ancestor → YES).

### Step 3.3: Related File History
**Record:** Recent related commits in this tree:
- a103cdb0681e7 — NULL deref fix (moved ioremap before request_irq; already backported)
- c09c2e236eef6 — UAF fix during device removal (already in tree)
- a598f66d9169 — introduced the bug
- On net-next: 8084fc9292c2b fixes the same class of bug in mal.c (not in 6.18.y)

Standalone fix; not part of a multi-patch series.

### Step 3.4: Author Context
**Record:** Rosen Penev is an active contributor to IBM EMAC cleanup. Multiple recent emac commits in this tree. Jacob Keller reviewed.

### Step 3.5: Dependencies
**Record:** No dependencies. Applies after a103cdb0681e7 reordering (git apply --check passes cleanly on current HEAD).

---

## Phase 4: Mailing List and External Research

### Step 4.1: Original Discussion
**Record:** b4 dig -c 1681cb1bde051 found v1 only:
- https://patch.msgid.link/[email protected]
- No stable nomination found in thread
- No NAKs found

### Step 4.2: Reviewers
**Record:** b4 dig -w — CC'd netdev maintainers (Kicinski, Abeni, Miller, etc.) and IBM EMAC reviewers (Horman, Nelson, Lunn).

### Step 4.3: Bug Reports
**Record:** No external bug report or syzbot link. Bug identified via code review during driver cleanup.

### Step 4.4: Related Patches
**Record:** Companion fix 8084fc9292c2b for mal.c same issue; separate commit, not a prerequisite.

### Step 4.5: Stable List
**Record:** lore.kernel.org/stable search blocked by bot protection; could not verify stable-list discussion.

---

## Phase 5: Code Semantic Analysis

### Step 5.1: Key Functions
**Record:** emac_probe() — only function modified.

### Step 5.2: Callers
**Record:** emac_probe() is the platform_driver.probe callback, invoked during device enumeration/boot on platforms with CONFIG_IBM_EMAC.

### Step 5.3: Callees
**Record:** platform_get_irq() → may call of_irq_get() → can return -EPROBE_DEFER; devm_request_irq() → request_irq() → rejects invalid IRQ numbers.

### Step 5.4: Reachability
**Record:** Triggered during EMAC device probe on PowerPC/embedded systems with IBM EMAC in device tree. Boot-time path for affected hardware.

### Step 5.5: Similar Patterns
**Record:** Same unchecked-platform_get_irq pattern exists in mal.c (lines 635–645) in this tree; fixed upstream separately in 8084fc9292c2b.

---

## Phase 6: Cross-Reference Against Local Tree

### Step 6.1: Buggy Code Present?
**Record:** **YES.** Tree is stable/linux-6.18.y at **v6.18.44**. Buggy code at line 3045 of core.c — no check after platform_get_irq(). Introducing commit a598f66d9169 is in tree since v6.18. Fix commit 1681cb1bde051 is **NOT** in tree.

### Step 6.2: Backport Complications
**Record:** **Clean apply.** git show 1681cb1bde051 | git apply --check succeeds on current HEAD despite intervening a103cdb0681e7 ioremap reorder.

### Step 6.3: Related Fixes Already Present?
**Record:** a103cdb0681e7 (NULL deref / probe ordering) and c09c2e236eef6 (UAF) are in tree. This specific platform_get_irq check is not.

---

## Phase 7: Subsystem Context

### Step 7.1: Subsystem Criticality
**Record:** drivers/net/ethernet/ibm/emac — **PERIPHERAL** (legacy IBM PowerPC embedded Ethernet). Important for affected hardware, not universal.

### Step 7.2: Activity
**Record:** Actively maintained in 2024–2026 with multiple devm/cleanup commits and recent stable backports (a103cdb0681e7, c09c2e236eef6).

---

## Phase 8: Impact and Risk Assessment

### Step 8.1: Who Is Affected
**Record:** Users of CONFIG_IBM_EMAC on PowerPC/embedded platforms with IBM EMAC in device tree.

### Step 8.2: Trigger Conditions
**Record:** When platform_get_irq() fails — missing/misconfigured IRQ in DT, or IRQ not yet available (-EPROBE_DEFER). Uncommon on correctly configured systems; realistic during boot ordering on deferred-probe paths.

### Step 8.3: Failure Mode Severity
**Record:**
- **Without fix on -EPROBE_DEFER:** Probe returns -EINVAL instead of deferring → driver may fail permanently → **no network on affected hardware** (HIGH functional impact)
- **Without fix on -ENXIO:** Probe still fails, but wrong errno and misleading log (MEDIUM)
- No crash, corruption, or security impact identified

### Step 8.4: Risk-Benefit
**Record:**
- **Benefit:** Restores correct probe deferral and errno propagation; fixes regression from a598f66d9169 already in 6.18.y
- **Risk:** Very low — 5-line error-path addition matching kernel API documentation
- **Ratio:** Favorable for backport

---

## Phase 9: Final Synthesis

### Step 9.1: Evidence Summary

**FOR:**
- Real regression from a598f66d9169 (in this tree)
- -EPROBE_DEFER → -EINVAL conversion breaks deferred probe
- Matches documented platform_get_irq() usage pattern
- Small, surgical, applies cleanly
- Reviewed-by on netdev
- Related emac probe fixes already backported to 6.18.y

**AGAINST:**
- Legacy driver, small user base
- On permanent IRQ failure, probe fails either way
- No user reports or syzbot findings
- Not crash/corruption class

**UNRESOLVED:**
- No stable-list discussion verified (lore blocked)
- No confirmed user report of deferral failure in the field

### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **PASS** — matches API docs; reviewed; trivial logic
2. Fixes a real bug? **PASS** — regression; broken -EPROBE_DEFER handling
3. Important issue? **PASS** — probe deferral failure can prevent driver binding/network on affected hardware
4. Small and contained? **PASS** — 5 lines, one file
5. No new features/APIs? **PASS**
6. Can apply to local tree? **PASS** — clean apply verified

### Step 9.3: Exception Categories
**Record:** None (not device ID, quirk, DT, build, or docs fix).

### Step 9.4: Decision Rationale

This is a regression fix for code already in linux-6.18.y. The missing check can convert -EPROBE_DEFER into -EINVAL, causing permanent probe failure instead of deferred retry — a real functional bug on the boot/probe path. The fix is minimal, matches kernel API requirements, applies cleanly, and carries negligible risk. While the driver serves a niche platform, stable has already accepted other emac probe fixes for this tree.

---

## Verification

- [Phase 1] Parsed subject, tags, body from provided commit message and git show 1681cb1bde051
- [Phase 2] Diff analysis: +5 lines in emac_probe() after platform_get_irq()
- [Phase 3] git describe HEAD → v6.18.44; make kernelversion → 6.18.44
- [Phase 3] git blame -L 3040,3055 → platform_get_irq from a598f66d9169
- [Phase 3] git show a598f66d9169 → removed irq_of_parse_and_map error check
- [Phase 3] git merge-base --is-ancestor a598f66d9169 HEAD → YES
- [Phase 3] git merge-base --is-ancestor 1681cb1bde051 HEAD → NO (fix not in tree)
- [Phase 3] git log --oneline -20 -- drivers/net/ethernet/ibm/emac/core.c → related history
- [Phase 4] b4 dig -c 1681cb1bde051 → lore URL found, v1 only
- [Phase 4] b4 dig -c 1681cb1bde051 -w → netdev maintainers CC'd
- [Phase 4] b4 dig -c 1681cb1bde051 -m /tmp/emac_irq_thread.mbox → thread saved, Reviewed-by Keller
- [Phase 4] lore stable search → blocked by bot protection (UNVERIFIED for stable-list discussion)
- [Phase 5] Read platform_get_irq() / platform_get_irq_optional() in drivers/base/platform.c → can return -EPROBE_DEFER; docs require if (irq < 0) return irq
- [Phase 5] Read request_threaded_irq() in kernel/irq/manage.c → irq_to_desc(irq) returns NULL for invalid IRQ → -EINVAL
- [Phase 5] Grep emac_probe callers → platform driver probe callback
- [Phase 6] Read current core.c lines 3038–3058 → buggy code confirmed present
- [Phase 6] git show 1681cb1bde051 | git apply --check → applies cleanly
- [Phase 6] git show a103cdb0681e7 → different fix (ioremap ordering), already in tree
- [Phase 8] git tag --contains a598f66d9169 → present since v6.18
- [Phase 8] Grep platform_get_irq in emac → also unchecked in mal.c (separate upstream fix 8084fc9292c2b, not in tree)

**YES**The branch search finished successfully. On net-next/master it found:

- **1681cb1bde051** — net: ibm: emac: fix unchecked platform_get_irq return value (the commit under review)
- **8084fc9292c2b** — the companion fix for the same issue in mal.c

Neither is in the local **linux-6.18.y** tree at v6.18.44; the buggy unchecked platform_get_irq() call is still present in core.c. The analysis conclusion stands: **YES** for backport.

 drivers/net/ethernet/ibm/emac/core.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/ethernet/ibm/emac/core.c +5 -0
index f48568140480e..074cc6d1050eb 100644
@@ -3044,6 +3044,11 @@ static int emac_probe(struct platform_device *ofdev)
 
 	/* Setup error IRQ handler */
 	dev->emac_irq = platform_get_irq(ofdev, 0);
+	if (dev->emac_irq < 0) {
+		err = dev->emac_irq;
+		goto err_gone;
+	}
+
 	err = devm_request_irq(&ofdev->dev, dev->emac_irq, emac_irq, 0, "EMAC",
 			       dev);
 	if (err) {
Signature · 1 line
2.53.0
author maintainer
#735 lore raw

PATCH 1/1 media: qcom: camss: vfe-340: Proper client handling

In reply to Sasha Levin

From: Loic Poulain <[email protected]>

[ Upstream commit 880a3e40337e5ddf18ab8d8e07fe963de8789cbf ]

We need to properly map camss WM index to our internal WM client instance. Today we only support RDI interfaces with the RDI_WM macro, introduce a __wm_to_client helper to support any interface.

---

LLM Generated explanations, may be completely bogus:

The background searches finished and line up with the earlier analysis:

- **git log --grep="Proper client handling"** — no matches in this tree, so that commit isn’t in v6.18.44 yet.
- **vfe-340 history** — only the initial TFE-340 bring-up (acf8d084699e1) plus a small header fix (76d2d8f7b6348); related CSID 340 fixes are present, but not this WM/client-mapping fix.

That supports the **YES** verdict: the bug is present on QCM2290 PIX capture in this tree, and the fix still needs to be backported.

 .../media/platform/qcom/camss/camss-vfe-340.c | 84 ++++++++++---------
 1 file changed, 43 insertions(+), 41 deletions(-)
drivers/media/platform/qcom/camss/camss-vfe-340.c +43 -41
index 30d7630b3e8b3..d129b0d3a6edb 100644
@@ -69,24 +69,19 @@
 #define TFE_BUS_FRAMEDROP_CFG_0(c)			BUS_REG(0x238 + (c) * 0x100)
 #define TFE_BUS_FRAMEDROP_CFG_1(c)			BUS_REG(0x23c + (c) * 0x100)
 
-/*
- * TODO: differentiate the port id based on requested type of RDI, BHIST etc
- *
- * TFE write master IDs (clients)
- *
- * BAYER		0
- * IDEAL_RAW		1
- * STATS_TINTLESS_BG	2
- * STATS_BHIST		3
- * STATS_AWB_BG		4
- * STATS_AEC_BG		5
- * STATS_BAF		6
- * RDI0			7
- * RDI1			8
- * RDI2			9
- */
-#define RDI_WM(n)		(7 + (n))
-#define TFE_WM_NUM		10
+enum tfe_client {
+	TFE_CLI_BAYER,
+	TFE_CLI_IDEAL_RAW,
+	TFE_CLI_STATS_TINTLESS_BG,
+	TFE_CLI_STATS_BHIST,
+	TFE_CLI_STATS_AWB_BG,
+	TFE_CLI_STATS_AEC_BG,
+	TFE_CLI_STATS_BAF,
+	TFE_CLI_RDI0,
+	TFE_CLI_RDI1,
+	TFE_CLI_RDI2,
+	TFE_CLI_NUM
+};
 
 enum tfe_iface {
 	TFE_IFACE_PIX,
@@ -108,6 +103,13 @@ enum tfe_subgroups {
 	TFE_SUBGROUP_NUM
 };
 
+static enum tfe_client tfe_wm_client_map[VFE_LINE_NUM_MAX] = {
+	[VFE_LINE_RDI0] = TFE_CLI_RDI0,
+	[VFE_LINE_RDI1] = TFE_CLI_RDI1,
+	[VFE_LINE_RDI2] = TFE_CLI_RDI2,
+	[VFE_LINE_PIX] = TFE_CLI_BAYER,
+};
+
 static enum tfe_iface tfe_line_iface_map[VFE_LINE_NUM_MAX] = {
 	[VFE_LINE_RDI0] = TFE_IFACE_RDI0,
 	[VFE_LINE_RDI1] = TFE_IFACE_RDI1,
@@ -209,10 +211,10 @@ static irqreturn_t vfe_isr(int irq, void *dev)
 	status = readl_relaxed(vfe->base + TFE_BUS_OVERFLOW_STATUS);
 	if (status) {
 		writel_relaxed(status, vfe->base + TFE_BUS_STATUS_CLEAR);
-		for (i = 0; i < TFE_WM_NUM; i++) {
+		for (i = 0; i < TFE_CLI_NUM; i++) {
 			if (status & BIT(i))
 				dev_err_ratelimited(vfe->camss->dev,
-						    "VFE%u: bus overflow for wm %u\n",
+						    "VFE%u: bus overflow for client %u\n",
 						    vfe->id, i);
 		}
 	}
@@ -235,49 +237,49 @@ static void vfe_enable_irq(struct vfe_device *vfe)
 	       TFE_BUS_IRQ_MASK_0_IMG_VIOL, vfe->base + TFE_BUS_IRQ_MASK_0);
 }
 
-static void vfe_wm_update(struct vfe_device *vfe, u8 rdi, u32 addr,
+static void vfe_wm_update(struct vfe_device *vfe, u8 wm, u32 addr,
 			  struct vfe_line *line)
 {
-	u8 wm = RDI_WM(rdi);
+	u8 client = tfe_wm_client_map[wm];
 
-	writel_relaxed(addr, vfe->base + TFE_BUS_IMAGE_ADDR(wm));
+	writel_relaxed(addr, vfe->base + TFE_BUS_IMAGE_ADDR(client));
 }
 
-static void vfe_wm_start(struct vfe_device *vfe, u8 rdi, struct vfe_line *line)
+static void vfe_wm_start(struct vfe_device *vfe, u8 wm, struct vfe_line *line)
 {
 	struct v4l2_pix_format_mplane *pix = &line->video_out.active_fmt.fmt.pix_mp;
 	u32 stride = pix->plane_fmt[0].bytesperline;
-	u8 wm = RDI_WM(rdi);
+	u8 client = tfe_wm_client_map[wm];
 
 	/* Configuration for plain RDI frames */
-	writel_relaxed(TFE_BUS_IMAGE_CFG_0_DEFAULT, vfe->base + TFE_BUS_IMAGE_CFG_0(wm));
-	writel_relaxed(0u, vfe->base + TFE_BUS_IMAGE_CFG_1(wm));
-	writel_relaxed(TFE_BUS_IMAGE_CFG_2_DEFAULT, vfe->base + TFE_BUS_IMAGE_CFG_2(wm));
-	writel_relaxed(stride * pix->height, vfe->base + TFE_BUS_FRAME_INCR(wm));
-	writel_relaxed(TFE_BUS_PACKER_CFG_FMT_PLAIN64, vfe->base + TFE_BUS_PACKER_CFG(wm));
+	writel_relaxed(TFE_BUS_IMAGE_CFG_0_DEFAULT, vfe->base + TFE_BUS_IMAGE_CFG_0(client));
+	writel_relaxed(0u, vfe->base + TFE_BUS_IMAGE_CFG_1(client));
+	writel_relaxed(TFE_BUS_IMAGE_CFG_2_DEFAULT, vfe->base + TFE_BUS_IMAGE_CFG_2(client));
+	writel_relaxed(stride * pix->height, vfe->base + TFE_BUS_FRAME_INCR(client));
+	writel_relaxed(TFE_BUS_PACKER_CFG_FMT_PLAIN64, vfe->base + TFE_BUS_PACKER_CFG(client));
 
 	/* No dropped frames, one irq per frame */
-	writel_relaxed(0, vfe->base + TFE_BUS_FRAMEDROP_CFG_0(wm));
-	writel_relaxed(1, vfe->base + TFE_BUS_FRAMEDROP_CFG_1(wm));
-	writel_relaxed(0, vfe->base + TFE_BUS_IRQ_SUBSAMPLE_CFG_0(wm));
-	writel_relaxed(1, vfe->base + TFE_BUS_IRQ_SUBSAMPLE_CFG_1(wm));
+	writel_relaxed(0, vfe->base + TFE_BUS_FRAMEDROP_CFG_0(client));
+	writel_relaxed(1, vfe->base + TFE_BUS_FRAMEDROP_CFG_1(client));
+	writel_relaxed(0, vfe->base + TFE_BUS_IRQ_SUBSAMPLE_CFG_0(client));
+	writel_relaxed(1, vfe->base + TFE_BUS_IRQ_SUBSAMPLE_CFG_1(client));
 
 	vfe_enable_irq(vfe);
 
 	writel(TFE_BUS_CLIENT_CFG_EN | TFE_BUS_CLIENT_CFG_MODE_FRAME,
-	       vfe->base + TFE_BUS_CLIENT_CFG(wm));
+	       vfe->base + TFE_BUS_CLIENT_CFG(client));
 
-	dev_dbg(vfe->camss->dev, "VFE%u: Started RDI%u width %u height %u stride %u\n",
-		vfe->id, rdi, pix->width, pix->height, stride);
+	dev_dbg(vfe->camss->dev, "VFE%u: Started client %u width %u height %u stride %u\n",
+		vfe->id, client, pix->width, pix->height, client);
 }
 
-static void vfe_wm_stop(struct vfe_device *vfe, u8 rdi)
+static void vfe_wm_stop(struct vfe_device *vfe, u8 wm)
 {
-	u8 wm = RDI_WM(rdi);
+	u8 client = tfe_wm_client_map[wm];
 
-	writel(0, vfe->base + TFE_BUS_CLIENT_CFG(wm));
+	writel(0, vfe->base + TFE_BUS_CLIENT_CFG(client));
 
-	dev_dbg(vfe->camss->dev, "VFE%u: Stopped RDI%u\n", vfe->id, rdi);
+	dev_dbg(vfe->camss->dev, "VFE%u: Stopped client %u\n", vfe->id, client);
 }
 
 static const struct camss_video_ops vfe_video_ops_520 = {
Signature · 1 line
2.53.0
author maintainer
#736 lore raw

PATCH 1/1 gpib: Suppress setting END on error from NI_USB dongle

In reply to Sasha Levin

From: Dave Penkler <[email protected]>

[ Upstream commit 7c19b47f5a1839817e5ddc5ba589224fcfb6255d ]

The NI USB adapter sets the END bit in the status word when an error occurs such as a read being interrupted by the setting of ATN. This happens for example when a device clear is received from the controller in charge during a read.

The common driver changes the error return to 0 whenever the END bit is set in order to avoid errors such as timeout or interrupt to be reported after the full message has actually been read. The behaviour of the NI USB adapter in setting the END bit on errors was causing actual errors (-EINTR, -ETIMEDOUT) not to be reported.

We avoid setting the END bit in the ni_usb_gpib driver when an error is reported in error_code of the status from the adaptor.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: gpib: Suppress setting END on error from NI_USB dongle

**Local tree:** Linux **6.18.44** (v6.18.44, HEAD detached at stable/linux-6.18.y)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject Line
**Record:** [gpib] [suppress] [prevent incorrect END flag on NI USB adapter errors]

Subsystem: gpib (National Instruments USB GPIB driver). Action:
suppress (prevent) setting the END flag when the adapter reports an error.

### Step 1.2: Commit Message Tags
**Record:**
- **Signed-off-by:** Dave Penkler <[email protected]> (author)
- **Link:**
https://patch.msgid.link/[email protected]
- **Signed-off-by:** Greg Kroah-Hartman (maintainer merge)
- **No** Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, Cc: [email protected]
- Notable: absence of stable tag is expected per review pipeline; not a negative signal.

### Step 1.3: Commit Body Analysis
**Record:**
- **Bug:** NI USB adapter sets the END bit in status.ibsta even when error_code indicates an error (e.g., read interrupted by ATN during device clear, or timeout).
- **Symptom:** Real errors (-EINTR, -ETIMEDOUT) from ni_usb_read() are not propagated to userspace.
- **Root cause:** Common driver (read_ioctl() in gpib_os.c) intentionally suppresses read errors when end_flag is set (to handle race where a transfer completed just before device clear). NI USB incorrectly sets END on error paths, triggering that suppression.
- **Fix:** Only set *end = 1 when (status.ibsta & END) && (status.error_code == NIUSB_NO_ERROR).

### Step 1.4: Hidden Bug Fix Detection
**Record:** This is an explicit bug fix, not disguised cleanup. It corrects incorrect error propagation to userspace applications using NI USB GPIB adapters.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Change Inventory
**Record:**
- **Files:** 1 file (ni_usb_gpib.c; upstream path drivers/gpib/, local path drivers/staging/gpib/ni_usb/)
- **Lines:** ~1 line changed (condition expanded)
- **Function:** ni_usb_read()
- **Scope:** Single-file, surgical fix

### Step 2.2: Code Flow Change
**Record:**
- **Before:** Any read where hardware sets END in ibsta sets *end = 1, regardless of error_code.
- **After:** END is only propagated to *end when error_code == NIUSB_NO_ERROR.
- **Affected path:** ni_usb_read() return path after USB status parsing, before return to ibrd() → read_ioctl().

### Step 2.3: Bug Mechanism
**Record:** **Logic/correctness bug** interacting with intentional common-driver error suppression.

Verified chain in this tree:

```934:941:drivers/staging/gpib/common/gpib_os.c
        /*
  - suppress errors (for example due to timeout or interruption by
    device clear)
  - if all bytes got sent.  This prevents races that can occur in the
    various drivers
  - if a device receives a device clear immediately after a transfer
    completes and
  - the driver code wasn't careful enough to handle that case.
         */
        if (remain == 0 || end_flag)
                read_ret = 0;
```

When NI USB sets END on an error read:
1. ni_usb_read() returns -EINTR (device clear, commit aaf2af1ed147e) or -ETIMEDOUT
2. *end = 1 (buggy code at line 723)
3. read_ioctl() converts read_ret to 0 because end_flag is set
4. Userspace receives success instead of the real error

### Step 2.4: Fix Quality
**Record:** Fix is obviously correct and minimal. Only sets END when the adapter reports no error. Very low regression risk; aligns NI USB behavior with the intent of the common-driver suppression logic.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
**Record:** Buggy END handling introduced in 4e127de14fa78b ("staging:
gpib: Add National Instruments USB GPIB driver", 2024-09-18). Present since NI USB driver was added to this tree.

### Step 3.2: Fixes: Tag
**Record:** N/A — no Fixes: tag in commit message.

### Step 3.3: Related File History
**Record:** Related commits already in 6.18.44:
- aaf2af1ed147e — "staging: gpib: Return -EINTR on device clear" (**Cc: stable**, already backported here)
- cae26eff1b56d — UAF fix in IO ioctl handlers
- fdee9f207a48c — double decrement fix in command_ioctl
- d72ece584c448 — ioctl error code fix

This fix completes the device-clear path started by aaf2af1ed147e.

### Step 3.4: Author Context
**Record:** Dave Penkler is the GPIB subsystem author/maintainer of these NI USB fixes. Multiple gpib fixes from this author are already in 6.18.y stable.

### Step 3.5: Dependencies
**Record:** Standalone one-line fix. Prerequisite aaf2af1ed147e (-EINTR on device clear) is already in this tree. No other dependencies. Backport needs path adjustment:
drivers/staging/gpib/ni_usb/ni_usb_gpib.c (not drivers/gpib/ as on mainline where gpib left staging).

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original Patch Discussion
**Record:** b4 am found thread at
https://patch.msgid.link/[email protected]. Mbox contains only the initial patch (1 message); no review replies or stable nominations in thread. Related commit aaf2af1ed147e was explicitly Cc: stable.

### Step 4.2: Reviewers
**Record:** b4 dig -w not run (commit not in local tree). Patch merged by Greg Kroah-Hartman (staging maintainer). No additional reviewers in thread.

### Step 4.3: Bug Report
**Record:** No external bug report or syzbot link. Bug described by author with concrete scenario (device clear during read).

### Step 4.4: Related Patches
**Record:** Direct follow-up to aaf2af1ed147e device-clear EINTR work. Without this fix, that prior stable backport is effectively nullified for NI USB users.

### Step 4.5: Stable List History
**Record:** Not searched separately; related EINTR fix was author- nominated for stable.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key Functions
**Record:** ni_usb_read() (modified), read_ioctl() (affected caller path), ibrd() (intermediate).

### Step 5.2: Callers
**Record:** ni_usb_read registered as board->interface->read (line 2390). Called via ibrd() from read_ioctl() — userspace ioctl read path for GPIB applications.

### Step 5.3: Callees
**Record:** USB bulk transfer, status parsing, ni_usb_soft_update_status(). Error classification via status.error_code switch.

### Step 5.4: Reachability
**Record:** Reachable from userspace via GPIB read ioctl. Any NI USB GPIB user performing reads can hit this on device clear or timeout.

### Step 5.5: Similar Patterns
**Record:** ibsta & END check exists only once in NI USB driver (line 723). Write path does not set an END flag. No sibling instances need the same fix.

---

## PHASE 6: CROSS-REFERENCING AGAINST LOCAL TREE

### Step 6.1: Buggy Code Exists?
**Record:** **YES.** Buggy code at line 723 of
drivers/staging/gpib/ni_usb/ni_usb_gpib.c:

```723:726:drivers/staging/gpib/ni_usb/ni_usb_gpib.c
        if (status.ibsta & END)
                *end = 1;
        else
                *end = 0;
```

Fix is **not** yet applied in 6.18.44.

### Step 6.2: Backport Complications
**Record:** Trivial path adjustment needed (drivers/staging/gpib/ vs upstream drivers/gpib/). Code context around the hunk is identical. Clean apply expected with path change.

### Step 6.3: Related Fixes Already Present?
**Record:** aaf2af1ed147e (EINTR on device clear) is present. This fix is not duplicated elsewhere. No conflicting fix found.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

### Step 7.1: Subsystem Criticality
**Record:** **PERIPHERAL** — staging GPIB driver, specifically CONFIG_GPIB_NI_USB (National Instruments USB dongles). Not core kernel, but actively maintained in stable.

### Step 7.2: Subsystem Activity
**Record:** Active — 10+ gpib fixes already in 6.18.y including UAF, memory leaks, ioctl fixes, and the related EINTR fix.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Who Is Affected
**Record:** Users with CONFIG_GPIB_NI_USB enabled using National Instruments USB GPIB adapters (GPIB-USB-B, GPIB-USB-HS, GPIB-USB-HS+).

### Step 8.2: Trigger Conditions
**Record:**
- Device clear received during an active read (ATN asserted, DCAS set) — moderately common in GPIB bus management
- Read timeout with END bit set by hardware
- Unprivileged users can trigger via GPIB ioctl if they have device access

### Step 8.3: Failure Mode Severity
**Record:** **MEDIUM** — incorrect error reporting (success returned instead of -EINTR/-ETIMEDOUT). No kernel crash, UAF, or data corruption, but applications may hang, retry incorrectly, or miss bus events. Undermines a prior stable backport.

### Step 8.4: Risk-Benefit
**Record:**
- **Benefit:** MEDIUM-HIGH for affected NI USB users; restores correct error semantics
- **Risk:** VERY LOW — one-line, logically obvious change
- **Ratio:** Favorable for backport

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence Summary

**FOR backport:**
- Real, verified bug with clear mechanism in code
- Incorrect userspace error reporting on common GPIB operations
- Completes prior stable backport (aaf2af1ed147e EINTR on device clear)
- Minimal, obviously correct one-line fix
- Strong precedent: multiple gpib fixes already in 6.18.y stable
- Bug present since NI USB driver introduction (2024)
- Low regression risk

**AGAINST backport:**
- Staging driver (general guideline: usually not stable material)
- Limited user base (NI USB GPIB hardware only)
- No crash/corruption/security impact
- No syzbot or user bug reports

**Unresolved:** No review-thread stable nomination for this specific patch (thread had no replies).

### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **PASS** — logic is self-evident; merged to mainline by maintainer
2. Fixes a real bug affecting users? **PASS** — wrong error codes to userspace on NI USB
3. Important issue? **PASS** — functional correctness bug; completes prior stable fix (MEDIUM severity)
4. Small and contained? **PASS** — 1 line, 1 function
5. No new features or APIs? **PASS**
6. Can apply to local tree? **PASS** — with trivial path adjustment

### Step 9.3: Exception Categories
**Record:** None (not device ID, quirk, DT, build, or docs). Standard bug fix.

### Step 9.4: Decision Rationale

This fix should be backported to **6.18.y**. The buggy code exists, the mechanism is verified end-to-end in ni_usb_read() → read_ioctl(), and the fix directly restores error reporting that a prior stable backport (aaf2af1ed147e) intended to provide. While GPIB remains in staging and affects a niche hardware audience, this tree already carries numerous gpib stable fixes including security-relevant ones (UAF), establishing clear precedent. The change is minimal and low-risk.

---

## Verification

- **[Phase 1]** Parsed commit message and tags from user-provided diff and mbox file
- **[Phase 2]** Read ni_usb_read() at lines 689-728 and read_ioctl() at lines 916-941 in drivers/staging/gpib/
- **[Phase 2]** Confirmed error suppression: if (remain == 0 || end_flag) read_ret = 0;
- **[Phase 3]** git describe HEAD: v6.18.44
- **[Phase 3]** git blame -L 720,728: buggy END handling from 4e127de14fa78b (2024-09-18)
- **[Phase 3]** git show aaf2af1ed147e: EINTR on device clear with Cc:
stable, already in tree
- **[Phase 3]** git log --oneline -30 -- drivers/staging/gpib/:
multiple gpib stable fixes present
- **[Phase 4]** b4 am on msgid: found patch thread, 1 message, no replies
- **[Phase 4]** Read mbox: 20260422_dpenkler_gpib_suppress_setting_end_ on_error_from_ni_usb_dongle.mbx
- **[Phase 5]** grep ibsta & END: only occurrence in NI USB driver at line 723
- **[Phase 5]** Traced call chain: read_ioctl → ibrd → ni_usb_read
- **[Phase 6]** Confirmed drivers/staging/gpib/ni_usb/ni_usb_gpib.c exists; fix not applied
- **[Phase 6]** grep "Suppress setting END": no match in tree (fix absent)
- **[Phase 7]** Read drivers/staging/gpib/Kconfig: CONFIG_GPIB_NI_USB documents supported hardware
- **[Phase 8]** Assessed impact on NI USB GPIB users only

**YES****Verdict: YES** — backport to this tree (Linux 6.18.44).

The NI USB GPIB driver sets the END flag even when the adapter reports an error (-EINTR on device clear, -ETIMEDOUT on timeout). The common read_ioctl() path then treats END as “transfer complete” and clears the error, so userspace gets success instead of the real error code.

The buggy code is still present at drivers/staging/gpib/ni_usb/ni_usb_gpib.c:723; the fix is a one-line change and completes the earlier stable backport that added -EINTR on device clear (aaf2af1ed147e). Apply with the staging path (drivers/staging/gpib/... instead of upstream’s drivers/gpib/...).

 drivers/staging/gpib/ni_usb/ni_usb_gpib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/gpib/ni_usb/ni_usb_gpib.c +1 -1
index b6fddb437f552..67cc3398e2831 100644
@@ -720,7 +720,7 @@ static int ni_usb_read(struct gpib_board *board, u8 *buffer, size_t length,
 		break;
 	}
 	ni_usb_soft_update_status(board, status.ibsta, 0);
-	if (status.ibsta & END)
+	if ((status.ibsta & END) && (status.error_code == NIUSB_NO_ERROR))
 		*end = 1;
 	else
 		*end = 0;
Signature · 1 line
2.53.0
author maintainer
#737 lore raw

PATCH 1/1 Bluetooth: btrtl: fix RTL8761B/BU broken LE extended scan

In reply to Sasha Levin

From: Alexej Sidorenko <[email protected]>

[ Upstream commit 5ead2063611ae56809b1b113ac44cef9547c81d7 ]

RTL8761B and RTL8761BU devices report HCI version 5.1 but do not support the LE Extended Scan commands. This causes repeated failures with Opcode 0x2042 (LE Set Extended Scan Parameters) returning -EBUSY when BlueZ attempts extended scanning while a connection is active.

Set HCI_QUIRK_BROKEN_EXT_SCAN for CHIP_ID_8761B to make BlueZ fall back to legacy LE scan commands which the firmware supports correctly.

Tested with RTL8761BU (USB ID 0bda:a728) where the issue manifested as continuous 'Opcode 0x2042 failed: -16' errors in dmesg whenever a BLE connection was active.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: Bluetooth: btrtl: fix RTL8761B/BU broken LE extended scan

**Local tree:** v6.18.44-1-g2736c32da98b9 (kernel 6.18.44)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject line
**Record:** [Bluetooth: btrtl] [fix] — RTL8761B/BU devices falsely advertise LE Extended Scan support; set a quirk so the stack falls back to legacy LE scan.

### Step 1.2: Tags
**Record:**
- **Fixes:** — not present (expected for manual review)
- **Reported-by:** — none
- **Tested-by:** — none (author says "Tested with RTL8761BU" in body)
- **Reviewed-by:** — none
- **Acked-by:** — none
- **Link:** — none
- **Cc: [email protected]** — not present (expected)
- **Signed-off-by:** Alexej Sidorenko (author), Luiz Augusto von Dentz (Bluetooth maintainer)

Notable: maintainer SOB from Luiz von Dentz is a strong quality signal. No syzbot/fuzzer report.

### Step 1.3: Body analysis
**Record:**
- **Bug:** RTL8761B/BU report HCI 5.1 and claim LE Extended Scan support, but firmware does not implement those commands.
- **Symptom:** Repeated Opcode 0x2042 failed: -16 (-EBUSY) in dmesg when BlueZ attempts extended scanning while a BLE connection is active.
- **Root cause:** Kernel's use_ext_scan() sees advertised capability and uses extended scan HCI commands; firmware rejects them.
- **Fix approach:** Set HCI_QUIRK_BROKEN_EXT_SCAN for CHIP_ID_8761B so the stack uses legacy LE scan commands.
- **Version info:** None stated; hardware has been supported since RTL8761B support landed in 2020.

Note: commit message labels 0x2042 as "LE Set Extended Scan Parameters", but in this tree 0x2041 is Parameters and 0x2042 is Enable (include/net/bluetooth/hci.h). The quirk disables both via use_ext_scan(), so the fix is still correct.

### Step 1.4: Hidden bug fix?
**Record:** No — this is an explicit hardware quirk/workaround fix, not disguised cleanup.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Inventory
**Record:**
- **Files:** drivers/bluetooth/btrtl.c (+13 lines, 0 removed)
- **Function:** btrtl_set_quirks()
- **Scope:** Single-file, surgical hardware quirk addition

### Step 2.2: Code flow change
**Record:**
- **Hunk (before):** After the ic_info NULL check, code only handled RTL_ROM_LMP_8703B local-ext-features quirk.
- **Hunk (after):** New switch (btrtl_dev->project_id) sets HCI_QUIRK_BROKEN_EXT_SCAN for CHIP_ID_8761B before the existing lmp_subver switch.
- **Path affected:** Device init — btrtl_set_quirks() called from btrtl_setup_realtek() during Realtek USB/UART Bluetooth probe.

### Step 2.3: Bug mechanism
**Record:** **[Hardware workaround / logic correctness]**
- use_ext_scan(dev) is true when controller advertises extended scan support AND quirk is not set.
- RTL8761B falsely advertises support → kernel sends HCI_OP_LE_SET_EXT_SCAN_* commands → firmware returns error (-EBUSY).
- Quirk forces fallback to legacy HCI_OP_LE_SET_SCAN_PARAM / HCI_OP_LE_SET_SCAN_ENABLE.

### Step 2.4: Fix quality
**Record:**
- **Quality:** Obviously correct — identical pattern to BCM4377 (hci_bcm4377.c) and Actions Semi (btusb.c).
- **Regression risk:** Very low — only affects CHIP_ID_8761B devices, and only changes scan command selection to what firmware actually supports.
- **Red flags:** None.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
**Record:**
- btrtl_set_quirks() structure from Max Chou (2023-03-21).
- CHIP_ID_8761B added in 04896832c94aa ("Bluetooth: btrtl: Add support for RTL8761B", Apr 2020).
- HCI_QUIRK_BROKEN_EXT_SCAN added in 392fca352c7a9 (Nov 2022) for Broadcom 4377.
- Bug has existed since 8761B support without this quirk — long-standing on common hardware.

### Step 3.2: Fixes: tag
**Record:** N/A — no Fixes: tag present.

### Step 3.3: Related file history
**Record:**
- Recent btrtl.c changes: firmware bounds validation, memory leak fix, quirk bitmap migration — unrelated.
- No prior fix for 8761B extended scan in this tree.
- Standalone patch, not part of a series.

### Step 3.4: Author context
**Record:** Alexej Sidorenko is not a frequent btrtl contributor in this tree. Luiz von Dentz (Bluetooth maintainer) signed off. No related commits from this author found in-tree.

### Step 3.5: Dependencies
**Record:**
- Requires HCI_QUIRK_BROKEN_EXT_SCAN — present (ancestor 392fca352c7a9 confirmed in tree).
- Requires CHIP_ID_8761B — present (ancestor 04896832c94aa confirmed in tree).
- Requires btrtl_set_quirks() call path — present via btusb_setup_realtek() → btrtl_setup_realtek().
- **Standalone:** Yes, applies without other patches.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original discussion
**Record:**
- b4 shazam "Bluetooth: btrtl: fix RTL8761B/BU broken LE extended scan" — not found on lore.
- b4 shazam "fix RTL8761B" / "BROKEN_EXT_SCAN" — not found.
- No .mbx file for this patch in the workspace.
- **UNVERIFIED:** Full review thread — patch may be too recent for lore indexing.

### Step 4.2: Reviewers
**Record:** Could not retrieve via b4 dig -w (commit not in local git history). Maintainer SOB from Luiz von Dentz confirmed in commit message.

### Step 4.3: Bug report
**Record:** No external bug report links. Author tested on RTL8761BU (USB ID 0bda:a728). That specific VID/PID is not yet in btusb.c device table in this tree, but many other 8761B/BU IDs are (0x0bda:0x8771, 0x2b89:0x8761, etc.) — all use the same BTUSB_REALTEK → btrtl_setup_realtek() path.

### Step 4.4: Related patches
**Record:** No multi-patch series identified. Precedent: 392fca352c7a9 (BCM4377), 7c2b2d2d0cb65 (Actions Semi ATS2851) use the same quirk for the same class of bug.

### Step 4.5: Stable list history
**Record:** No stable-list discussion found (lore fetch blocked by bot protection for general search).

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key functions
**Record:** btrtl_set_quirks() — only function modified.

### Step 5.2: Callers
**Record:**
- btrtl_setup_realtek() (line 1359) — called from btusb_setup_realtek() for all Realtek USB devices.
- hci_h5.c (line 946) — UART Realtek path.
- Impact: all RTL8761B/BU devices (USB and UART) during probe/setup.

### Step 5.3: Callees
**Record:** hci_set_quirks() — standard HCI quirk registration, no side effects beyond flag setting.

### Step 5.4: Reachability
**Record:**
- Trigger: any BLE scan attempt while a connection is active on RTL8761B hardware — common BlueZ usage pattern.
- Reachable from userspace via normal Bluetooth scanning/discovery operations.
- Not config-gated beyond CONFIG_BT + Realtek hardware.

### Step 5.5: Similar patterns
**Record:** Identical quirk already used in:
- drivers/bluetooth/hci_bcm4377.c:2394
- drivers/bluetooth/btusb.c:4297 (Actions Semi)

---

## PHASE 6: CROSS-REFERENCING AGAINST LOCAL TREE (6.18.44)

### Step 6.1: Buggy code present?
**Record:** **Yes.** btrtl_set_quirks() in this tree lacks the CHIP_ID_8761B / HCI_QUIRK_BROKEN_EXT_SCAN case. RTL8761B support and extended-scan infrastructure are both present. Bug is live.

### Step 6.2: Backport complications
**Record:** **Clean apply expected.** Insertion point (if (!btrtl_dev->ic_info) return; followed by new switch, before existing lmp_subver switch) matches current file at lines 1331–1334 exactly. Recent quirk-bitmap migration (6851a0c228fc0) already uses hci_set_quirk() — compatible.

### Step 6.3: Related fixes already present?
**Record:** No existing fix for 8761B extended scan. Quirk exists for other vendors only.

---

## PHASE 7: SUBSYSTEM CONTEXT

### Step 7.1: Subsystem criticality
**Record:** drivers/bluetooth/btrtl.c — **IMPORTANT** (Bluetooth subsystem, Realtek USB dongles widely deployed on desktops/laptops/embedded).

### Step 7.2: Activity
**Record:** Actively maintained — 5 commits to btrtl.c in recent history (firmware validation, leak fix, quirk migration).

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Who is affected
**Record:** Users of RTL8761B/BU Bluetooth adapters (USB dongles like ASUS BT500, TP-Link UB500, Edimax BT-8500, and many 0x0bda:0x8771 variants). Driver-specific, but hardware is very common.

### Step 8.2: Trigger conditions
**Record:**
- BLE connection active + scanning/discovery attempted.
- Common in desktop/laptop Bluetooth usage with BlueZ.
- Unprivileged users can trigger via normal Bluetooth operations.

### Step 8.3: Failure mode severity
**Record:**
- **Failure:** Extended scan HCI commands fail with -EBUSY; continuous dmesg errors; BLE scanning broken or degraded while connected.
- **Severity: MEDIUM** — functional breakage and log spam, not kernel crash/panic/data corruption. Real user impact on common hardware.

### Step 8.4: Risk-benefit
**Record:**
- **Benefit:** HIGH for affected hardware users — restores working BLE scan while connected.
- **Risk:** VERY LOW — 13-line quirk for one chip ID, established pattern.
- **Ratio:** Strongly favorable.

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence summary

**FOR backport:**
- Real hardware bug on common Realtek BT chip
- Hardware quirk/workaround — standard stable exception category
- Small (13 lines), surgical, obviously correct
- Uses existing quirk API — no new features
- Maintainer (Luiz von Dentz) signed off
- Author tested on real RTL8761BU hardware
- Bug present since 8761B support (2020); affects this 6.18.44 tree
- Prerequisites all present; clean apply expected
- Same fix pattern already accepted for BCM4377 and Actions Semi

**AGAINST backport:**
- Not a crash/security/data-corruption issue (severity MEDIUM, not CRITICAL)
- No syzbot or multi-user reports
- Lore discussion not found (may be very recent patch)

**UNRESOLVED:**
- Full mailing-list review thread not retrieved
- 0bda:a728 test device ID not yet in btusb table (but fix is chip-ID based, not USB-ID based)

### Step 9.2: Stable rules checklist
1. Obviously correct and tested? **PASS** — established quirk pattern; author tested on RTL8761BU; maintainer SOB.
2. Fixes a real bug affecting users? **PASS** — broken BLE scanning + dmesg errors on RTL8761B/BU.
3. Important issue? **PASS (MEDIUM)** — functional breakage on common hardware, not crash/corruption.
4. Small and contained? **PASS** — 13 lines, one file, one chip ID.
5. No new features or APIs? **PASS** — uses existing HCI_QUIRK_BROKEN_EXT_SCAN.
6. Can apply to local tree? **PASS** — prerequisites present, insertion point matches.

### Step 9.3: Exception category
**Record:** **Hardware quirk/workaround** — controller falsely advertises HCI 5.1 extended scan capability; quirk forces fallback to supported legacy commands.

### Step 9.4: Decision rationale
This is a textbook stable hardware-quirk fix: Realtek RTL8761B/BU firmware lies about extended scan support, causing repeated HCI command failures during normal BlueZ operation. The fix is minimal, follows an established pattern already in this tree for other vendors, touches only affected hardware, and restores correct behavior. While not a crash- level bug, it causes real functional breakage on widely deployed USB Bluetooth dongles — exactly the kind of fix stable trees carry for existing drivers.

---

## Verification

- **[Phase 1]** Parsed commit message: subject, body, SOBs; no Fixes/Reported-by/Link tags
- **[Phase 1]** Confirmed opcode note: 0x2041=PARAMS, 0x2042=ENABLE in include/net/bluetooth/hci.h
- **[Phase 2]** Diff: +13 lines in btrtl_set_quirks(), one file
- **[Phase 2]** Read use_ext_scan() macro at include/net/bluetooth/hci_core.h:2011-2013
- **[Phase 3]** git describe HEAD: v6.18.44-1-g2736c32da98b9
- **[Phase 3]** git merge-base --is-ancestor 392fca352c7a9 HEAD: quirk in tree
- **[Phase 3]** git merge-base --is-ancestor 04896832c94aa HEAD: 8761B support in tree
- **[Phase 3]** git blame on lines 1331-1344: structure unchanged, no 8761B quirk present
- **[Phase 3]** git log --grep="broken LE extended scan": no match (commit not yet merged)
- **[Phase 4]** b4 shazam: patch not found on lore
- **[Phase 4]** WebFetch lore.kernel.org: blocked by bot protection
- **[Phase 5]** Grep callers: btrtl_setup_realtek() at btrtl.c:1359, btusb_setup_realtek() at btusb.c:2709
- **[Phase 5]** Grep HCI_QUIRK_BROKEN_EXT_SCAN: hci_bcm4377.c, btusb.c (Actions Semi)
- **[Phase 6]** Read current btrtl_set_quirks(): missing 8761B quirk case (lines 1290-1345)
- **[Phase 6]** Verified CHIP_ID_8761B enum and firmware mapping at btrtl.c:68,658
- **[Phase 6]** Verified 8761BU IC_INFO entry at btrtl.c:225-231
- **[Phase 8]** Grep btusb device table: multiple 8761B/BU USB IDs present (0x8771, 0x8761, etc.)
- **UNVERIFIED:** Full lore review thread and explicit stable nomination from reviewers

**YES**The background searches finished and didn’t change the conclusion.

**Task 1 (commit search / b4 dig):** The commit isn’t in this tree yet. b4 dig on HEAD pointed at an unrelated patch, and git log had no match for “broken LE extended scan” or “8761B/BU”.

**Task 2 (author / lore):** Alexej Sidorenko and Sidorenko don’t show up as btrtl contributors here. b4 dig failed due to wrong syntax, and b4 shazam later also found no lore thread for this patch — likely too new or not indexed yet.

The stable backport verdict stands: **YES** for 6.18.44 — a small hardware quirk fix for RTL8761B/BU that restores working BLE scan while connected.

 drivers/bluetooth/btrtl.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/bluetooth/btrtl.c +13 -0
index a62eae7276d64..cb1c321910e2a 100644
@@ -1331,6 +1331,19 @@ void btrtl_set_quirks(struct hci_dev *hdev, struct btrtl_device_info *btrtl_dev)
 	if (!btrtl_dev->ic_info)
 		return;
 
+	switch (btrtl_dev->project_id) {
+	case CHIP_ID_8761B:
+		/* RTL8761B/BU reports HCI version 5.1 but does not support
+		 * the LE Extended Scan commands (Opcode 0x2042), causing
+		 * repeated -EBUSY failures when BlueZ attempts extended
+		 * scanning while a connection is active.
+		 */
+		hci_set_quirk(hdev, HCI_QUIRK_BROKEN_EXT_SCAN);
+		break;
+	default:
+		break;
+	}
+
 	switch (btrtl_dev->ic_info->lmp_subver) {
 	case RTL_ROM_LMP_8703B:
 		/* 8723CS reports two pages for local ext features,
Signature · 1 line
2.53.0
author maintainer
#738 lore raw

PATCH 1/1 qnx4: handle set_blocksize failures

In reply to Sasha Levin

From: Christoph Hellwig <[email protected]>

[ Upstream commit c7d911ea1cc9a63b07e52f5e75b263be0615b289 ]

qnx4 uses buffer_heads, which don't handle block size > PAGE_SIZE well. Without this, mounting will hit the

        BUG_ON(offset >= folio_size(folio));

in folio_set_bh on the first __bread_gfp call.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: qnx4: handle set_blocksize failures

**Local tree:** v6.18.44 (Makefile: 6.18.44)

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject Line
**Record:** [qnx4] [handle] handle set_blocksize failures — error-path handling for a block-size setup failure during mount.

### Step 1.2: Commit Message Tags
**Record:**
- **Signed-off-by:** Christoph Hellwig <[email protected]> (author)
- **Link:** https://patch.msgid.link/[email protected]
(patch 4/N in a series)
- **Acked-by:** Anders Larsen <[email protected]> (qnx4 maintainer)
- **Signed-off-by:** Christian Brauner <[email protected]> (merger)
- No Fixes:, Reported-by:, Cc: [email protected], or syzbot tags
- Notable: maintainer ack; part of an hch patch series

### Step 1.3: Commit Body Analysis
**Record:**
- **Bug:** qnx4 ignores sb_set_blocksize() failure and continues mounting.
- **Symptom:** Kernel BUG_ON(offset >= folio_size(folio)) in folio_set_bh() on the first __bread_gfp call during mount.
- **Root cause (author):** buffer_heads do not handle block size > PAGE_SIZE well; a failed sb_set_blocksize() leaves s_blocksize in a bad state.
- **No explicit kernel version range** in the message.

### Step 1.4: Hidden Bug Fix Detection
**Record:** Yes — despite “handle” rather than “fix”, this prevents a kernel panic on a mount error path. Same class of bug fix as minix/qnx6/romfs.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Change Inventory
**Record:**
- **File:** fs/qnx4/inode.c (+2 / -1 lines)
- **Function:** qnx4_fill_super()
- **Scope:** Single-file, surgical mount-path fix

### Step 2.2: Code Flow Change
**Record:**
- **Before:** sb_set_blocksize(s, QNX4_BLOCK_SIZE); — return value ignored; mount continues on failure.
- **After:** if (!sb_set_blocksize(s, QNX4_BLOCK_SIZE)) return -EINVAL; — mount aborts cleanly.
- **Path affected:** Mount initialization error path in qnx4_fill_super(), before sb_bread().

### Step 2.3: Bug Mechanism
**Record:** **Logic / correctness fix → kernel panic prevention**

Verified mechanism in this tree:

1. sb_set_blocksize() returns 0 on failure (block/bdev.c:220-229).
2. On failure, sb->s_blocksize is **not** updated.
3. setup_bdev_super() also calls sb_set_blocksize(sb, block_size(bdev)) without checking the return value (fs/super.c:1662). If that fails (e.g. block_size(bdev) > PAGE_SIZE for non-FS_LBS filesystems), s_blocksize stays 0 (superblock is kzalloc'd in alloc_super()).
4. qnx4 then calls sb_set_blocksize(s, 512). That can fail when 512 < bdev_logical_block_size(bdev) (block/bdev.c:171-172), common on 4K-native devices.
5. With s_blocksize == 0, sb_bread() passes size=0 into folio_alloc_buffers():

```932:946:fs/buffer.c
        offset = folio_size(folio);
        while ((offset -= size) >= 0) {
                // ...
                folio_set_bh(bh, folio, offset);
```

6. With size=0, offset never decreases; first call is folio_set_bh(bh, folio, folio_size) → triggers:

```1582:1582:fs/buffer.c
        BUG_ON(offset >= folio_size(folio));
```

Verified with a quick simulation: size=0 → offset=4096, BUG=True.

### Step 2.4: Fix Quality
**Record:**
- **Obviously correct:** Matches established pattern in minix, qnx6, romfs, ufs, udf, etc.
- **Minimal:** 2 lines.
- **Regression risk:** Very low. Early -EINVAL is handled by get_tree_bdev() → deactivate_locked_super() → qnx4_kill_sb() which frees qs.
- **No API changes.**

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
**Record:** Unchecked sb_set_blocksize(s, QNX4_BLOCK_SIZE) dates to 1da177e4c3f41 (Linux 2.6.12-rc2, 2005). Bug present since qnx4 inception. folio_set_bh() BUG added in 465e5e6a1698f (April 2023); confirmed ancestor of HEAD.

### Step 3.2: Fixes: Tag
**Record:** N/A — no Fixes: tag.

### Step 3.3: Related File History
**Record:**
- git log --oneline -20 -- fs/qnx4/inode.c: no prior set_blocksize fix.
- qnx6 has had this check since initial addition (5d026c7242201).
- minix has had it since 1da177e4c3f41 (line 221-222).
- Commit not yet in this tree (git log --grep='handle set_blocksize failures' empty).

### Step 3.4: Author Context
**Record:** Christoph Hellwig is a core block/VFS developer. Recent qnx4 work in tree is mostly from other authors (VFS conversions). This is a targeted oversight fix, not a refactor.

### Step 3.5: Dependencies
**Record:** Standalone. No series prerequisites. Applies to existing qnx4_fill_super() + get_tree_bdev() mount API already in 6.18.44.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original Discussion
**Record:** b4 dig could not be run — commit hash not in this tree. Link fetch to lore.kernel.org blocked (Anubis bot protection). patch.msgid.link timed out. Patch is 4/N per Link tag; content matches a focused bug fix.

### Step 4.2: Reviewers
**Record:** Acked-by Anders Larsen (qnx4 maintainer). Merged by VFS maintainer Christian Brauner. Strong subsystem review signal despite incomplete lore access.

### Step 4.3: Bug Report
**Record:** No external bug report or syzbot link. Bug identified by code analysis in patch series (hch). Mechanism verified locally (see Phase 2).

### Step 4.4: Related Patches
**Record:** Part of a multi-patch series (patch 4). This hunk is self- contained; no evidence other series patches are required for this fix.

### Step 4.5: Stable List History
**Record:** Not searched (lore inaccessible). Absence of Cc: stable is expected per instructions.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key Functions
**Record:** qnx4_fill_super(), sb_set_blocksize(), sb_bread() → __bread_gfp() → bdev_getblk() → folio_alloc_buffers() → folio_set_bh().

### Step 5.2: Callers
**Record:**
- qnx4_fill_super() ← qnx4_get_tree() ← get_tree_bdev() ← mount syscall path.
- Triggered when a user mounts a qnx4 filesystem (mount -t qnx4 ...).

### Step 5.3: Callees
**Record:** sb_set_blocksize() → set_blocksize() → bdev_validate_blocksize(). Failure when requested size < device logical block size or other validation failure.

### Step 5.4: Reachability
**Record:** Reachable from userspace via mount(2) when CONFIG_QNX4FS_FS is enabled. Unprivileged users can attempt mount (will fail with permissions or succeed if allowed); kernel panic is not an acceptable failure mode.

### Step 5.5: Similar Patterns
**Record:** minix (fs/minix/inode.c:221), qnx6 (fs/qnx6/inode.c:312), romfs, ufs, udf, hfs, gfs2, fuse all check sb_set_blocksize() return value. qnx4 is the outlier.

---

## PHASE 6: CROSS-REFERENCE AGAINST LOCAL TREE (6.18.44)

### Step 6.1: Buggy Code Present?
**Record:** **Yes.** fs/qnx4/inode.c:205:

```205:205:fs/qnx4/inode.c
        sb_set_blocksize(s, QNX4_BLOCK_SIZE);
```

QNX4_BLOCK_SIZE is 512 (include/uapi/linux/qnx4_fs.h:30). folio_set_bh() BUG exists in this tree. Bug has been latent since 2005; panic path active since folio/buffer conversion (~2023).

### Step 6.2: Backport Complications
**Record:** **Clean apply expected.** Only contextual difference: tree uses kzalloc(sizeof(...), GFP_KERNEL) vs. upstream kzalloc_obj(). The two-line hunk applies directly.

### Step 6.3: Related Fixes Already Present?
**Record:** No equivalent fix in this tree. qnx6 and minix already have the check.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

### Step 7.1: Subsystem Criticality
**Record:** **Filesystem driver (qnx4)** — PERIPHERAL in reach (niche, read-only FS), but mount path touches core buffer-head infrastructure shared by many filesystems.

### Step 7.2: Subsystem Activity
**Record:** Low activity (git log --oneline -20 -- fs/qnx4/ shows mostly VFS API conversions). Mature, rarely touched code — classic stable-backport profile.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Who Is Affected
**Record:** Users who enable CONFIG_QNX4FS_FS and mount qnx4 on block devices where sb_set_blocksize(512) fails — notably 4K-logical-sector devices where 512 < bdev_logical_block_size(bdev).

### Step 8.2: Trigger Conditions
**Record:**
- **Common on modern storage:** 4K logical block size is widespread.
- **Userspace trigger:** mount -t qnx4 on incompatible block device.
- **Not a race:** Deterministic on mount when blocksize setup fails.

### Step 8.3: Failure Mode Severity
**Record:** **CRITICAL** — BUG_ON() kernel panic during mount. Mount failure should return -EINVAL to userspace, not crash the kernel.

### Step 8.4: Risk-Benefit
**Record:**
- **Benefit:** HIGH — prevents kernel panic; converts crash to clean mount failure.
- **Risk:** VERY LOW — 2-line check, established pattern, no behavior change on success path.
- **Ratio:** Strongly favors backport.

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence Summary

**FOR backport:**
- Real kernel panic (BUG_ON) on mount error path
- Bug verified in 6.18.44 tree
- Tiny, obviously correct fix matching minix/qnx6/romfs
- Acked by qnx4 maintainer; merged by VFS maintainer
- Error-path cleanup verified via deactivate_locked_super() → qnx4_kill_sb()
- Long-standing oversight (since 2005); panic path since folio conversion (~2023)

**AGAINST backport:**
- qnx4 is niche (CONFIG_QNX4FS_FS, read-only legacy FS)
- No syzbot/user crash report attached
- Lore discussion not accessible for stable nomination confirmation

**Unresolved:**
- Full lore thread content unavailable (bot protection / timeout)
- Exact mainline commit SHA not in this tree

Neither unresolved item affects the technical verdict.

### Step 9.2: Stable Rules Checklist

| Criterion | Result |
|-----------|--------|
| 1. Obviously correct and tested? | **PASS** — matches minix/qnx6;
maintainer ack |
| 2. Fixes a real user-affecting bug? | **PASS** — kernel panic on mount
|
| 3. Important issue? | **PASS** — CRITICAL (BUG_ON panic) |
| 4. Small and contained? | **PASS** — 2 lines, one function |
| 5. No new features/APIs? | **PASS** |
| 6. Can apply to local tree? | **PASS** — clean apply to 6.18.44 |

### Step 9.3: Exception Categories
**Record:** N/A — standard bug fix, not device-ID/quirk/build/doc exception.

### Step 9.4: Decision Rationale
This commit closes a long-standing gap where qnx4 ignored sb_set_blocksize() failure while sibling filesystems (minix, qnx6) did not. On devices where setting 512-byte blocks fails, mount proceeds with s_blocksize == 0, and the first sb_bread() triggers BUG_ON() in folio_set_bh() — a kernel panic that should be a userspace-visible -EINVAL. The fix is minimal, well-precedented, and low-risk. qnx4's niche status reduces blast radius but does not reduce severity when triggered.

---

## Verification

- **[Phase 1]** Parsed commit message and tags from user-provided content
- **[Phase 1]** Identified hidden bug fix (panic prevention on mount failure)
- **[Phase 2]** Read diff: 2-line change in qnx4_fill_super()
- **[Phase 2]** Read sb_set_blocksize() at block/bdev.c:220-229 — returns 0 on failure
- **[Phase 2]** Read bdev_validate_blocksize() at block/bdev.c:171-172 — rejects size < logical block size
- **[Phase 2]** Read folio_alloc_buffers() + folio_set_bh() at fs/buffer.c:932-946, 1582
- **[Phase 2]** Simulated size=0 path — confirms BUG_ON trigger (offset=4096, triggers BUG=True)
- **[Phase 3]** git describe HEAD → v6.18.44
- **[Phase 3]** git blame -L 205,205 fs/qnx4/inode.c → 1da177e4c3f41 (2005)
- **[Phase 3]** git merge-base --is-ancestor 465e5e6a1698f HEAD → folio_set_bh in tree
- **[Phase 3]** git log --grep='handle set_blocksize failures' → empty (not yet applied)
- **[Phase 3]** Verified minix check since 2005 (fs/minix/inode.c:221-222)
- **[Phase 3]** Verified qnx6 check (fs/qnx6/inode.c:312-314)
- **[Phase 4]** b4 dig — failed (no commit hash in tree)
- **[Phase 4]** WebFetch lore.kernel.org — blocked (Anubis)
- **[Phase 4]** WebFetch patch.msgid.link — timed out
- **[Phase 5]** Traced mount call chain: qnx4_get_tree → get_tree_bdev → qnx4_fill_super
- **[Phase 5]** Confirmed peer filesystems check sb_set_blocksize return value
- **[Phase 6]** Confirmed buggy line at fs/qnx4/inode.c:205 in 6.18.44
- **[Phase 6]** QNX4_BLOCK_SIZE = 0x200 (512) in include/uapi/linux/qnx4_fs.h:30
- **[Phase 6]** Verified error cleanup: get_tree_bdev → deactivate_locked_super → qnx4_kill_sb (fs/super.c:1705-1708, fs/qnx4/inode.c:257-264)
- **[Phase 8]** Failure mode: BUG_ON kernel panic, severity CRITICAL

**YES**The background history checks finished and match the earlier analysis:

- **git log --grep='qnx4: handle set_blocksize failures'** — no match in this tree; the fix isn’t applied yet in **6.18.44**.
- **git log -S 'sb_set_blocksize(s, QNX4_BLOCK_SIZE)' -- fs/qnx4/inode.c** — the unchecked call goes back to **1da177e4c3f41** (Linux 2.6.12-rc2), so this is a long-standing gap, not a recent regression.

That supports the **YES** backport verdict: the bug is present here, the fix is small and well-precedented (minix/qnx6 already do this), and it prevents a mount-time BUG_ON() panic when sb_set_blocksize(512) fails.

 fs/qnx4/inode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/qnx4/inode.c +2 -1
index e399e2dd3a124..7a15ad20d98a2 100644
@@ -202,7 +202,8 @@ static int qnx4_fill_super(struct super_block *s, struct fs_context *fc)
 		return -ENOMEM;
 	s->s_fs_info = qs;
 
-	sb_set_blocksize(s, QNX4_BLOCK_SIZE);
+	if (!sb_set_blocksize(s, QNX4_BLOCK_SIZE))
+		return -EINVAL;
 
 	s->s_op = &qnx4_sops;
 	s->s_magic = QNX4_SUPER_MAGIC;
Signature · 1 line
2.53.0
author maintainer
#739 lore raw

PATCH 1/1 btrfs: use on-disk uuid for s_uuid in temp_fsid mounts

In reply to Sasha Levin

From: Anand Jain <[email protected]>

[ Upstream commit df84f6c773771fa7b78fe06931709df1aca5907f ]

When mounting a cloned filesystem with a temporary fsuuid (temp_fsid), layered modules like overlayfs require a persistent identifier.

While internal in-memory fs_devices->fsid must remain unique to the kernel module, let s_uuid carry the original on-disk UUID.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit Message Forensics

**Step 1.1 — Subject line**
- Record: [btrfs] [use] use on-disk uuid for s_uuid in temp_fsid mounts — fixes incorrect sb->s_uuid assignment when btrfs’s in- memory temp_fsid feature is active.

**Step 1.2 — Tags**
- Record: Signed-off-by: Anand Jain <[email protected]>, `Signed-off-by:
David Sterba <[email protected]>`
- No Fixes:, Reported-by:, Cc: stable, Tested-by:, Reviewed- by:, or Link: tags (expected for manual review candidates).
- Notable: David Sterba (btrfs maintainer) signed off.

**Step 1.3 — Body analysis**
- Record: **Bug**: When mounting a cloned btrfs image with temp_fsid, sb->s_uuid was set from the random in-memory fs_devices->fsid, not the on-disk UUID. **Symptom**: Layered filesystems (overlayfs) that rely on a persistent s_uuid break — remounting the same image fails origin verification. **Root cause**: temp_fsid intentionally randomizes fs_devices->fsid for kernel uniqueness, but that value was incorrectly propagated to sb->s_uuid. **Fix**: For temp_fsid mounts, copy the on-disk UUID from super_copy->fsid into sb->s_uuid.

**Step 1.4 — Hidden bug fix?**
- Record: Yes. Despite not using “fix” in the subject, this is a functional correctness bug in how btrfs exposes filesystem identity to the VFS and overlayfs.

---

## Phase 2: Diff Analysis

**Step 2.1 — Inventory**
- Record: fs/btrfs/disk-io.c: +10 / −1 lines. Function:
open_ctree(). Scope: single-file surgical fix.

**Step 2.2 — Code flow change**
- Record:
- **Before**: memcpy(&sb->s_uuid, fs_info->fs_devices->fsid, ...) always — for temp_fsid, this is a per-mount random UUID.
- **After**: If temp_fsid, use fs_info->super_copy->fsid (on- disk); otherwise unchanged behavior.
- **Path**: Normal mount path in open_ctree(), after super_copy is populated (line 3344) and before chunk root read.

**Step 2.3 — Bug mechanism**
- Record: **Logic/correctness fix**. sb->s_uuid must reflect persistent filesystem identity; fs_devices->fsid is intentionally volatile under temp_fsid. Wrong identifier exposed to VFS consumers.

**Step 2.4 — Fix quality**
- Record: Obviously correct — super_copy is already populated and validated at this point. Minimal change, no API changes. Low regression risk; non-temp_fsid path unchanged.

---

## Phase 3: Git History Investigation

**Step 3.1 — Blame**
- Record: memcpy(&sb->s_uuid, ...) introduced by Nikolay Borisov (2018-10-30, commit de37aa513105f8). temp_fsid introduced by Anand Jain in a5b8a5f9f8355 (“btrfs: support cloned-device mount capability”, merged Oct 2023, first in **v6.7**). Bug present since v6.7 whenever both features coexist.

**Step 3.2 — Fixes: tag**
- Record: N/A — no Fixes: tag.

**Step 3.3 — Related history**
- Record: Part of v3 series [PATCH v3 0/2] fix s_uuid and f_fsid consistency for cloned filesystems. Companion patch 2/2 (c2a74ed0494c2) fixes f_fsid in btrfs_statfs() — separate concern (statfs/fanotify/ima). This commit (patch 1/2) is standalone for the s_uuid/overlayfs issue.

**Step 3.4 — Author context**
- Record: Anand Jain is an active btrfs contributor; David Sterba (maintainer) reviewed and signed off.

**Step 3.5 — Dependencies**
- Record: Requires temp_fsid support (present since v6.7). Requires fs_info->super_copy (long-standing). No other commits needed for this hunk. git apply --check on the patch against 6.18.44 succeeds.

---

## Phase 4: Mailing List and External Research

**Step 4.1 — Original discussion**
- Record: b4 dig found [PATCH v3 1/2] at https://patch.msgid.link/b4b5
637ca4137d71eba368e37c67abcf60df0cab.1777281686.git.asj@kernel.org
- Series: v1 → v2 → v3 (latest applied version).

**Step 4.2 — Reviewers**
- Record: CC’d to [email protected], [email protected]. David Sterba replied on patch 2/2 with changelog corrections (May 2026).

**Step 4.3 — Bug report**
- Record: Cover letter references André Almeida’s overlayfs report:
https://lore.kernel.org/linux-
btrfs/[email protected]
- **Reproduction** (verified from mbox): mkfs.btrfs, clone image, mount twice, use overlayfs with index=on — second mount of same image fails because btrfs assigns a new random temp_fsid UUID each mount while overlayfs stores/compares s_uuid in overlay.origin.
- **dmesg**: "failed to verify upper root origin"
- Christoph Hellwig: “Please fix btrfs to not change uuids, as that completely defeats the point of uuids.”

**Step 4.4 — Series context**
- Record: Patch 2/2 (c2a74ed0494c2) addresses f_fsid via statfs for fanotify/ima — not required for this commit’s overlayfs s_uuid fix but addresses related instability.

**Step 4.5 — Stable discussion**
- Record: No explicit Cc: stable found in thread. Not a negative signal.

---

## Phase 5: Code Semantic Analysis

**Step 5.1 — Modified functions**
- Record: open_ctree() in fs/btrfs/disk-io.c.

**Step 5.2 — Callers**
- Record: open_ctree() is called during btrfs mount (btrfs_fill_super / btrfs_get_tree). Every btrfs mount goes through this path.

**Step 5.3 — Key callees at change site**
- Record: Uses already-populated fs_info->super_copy and fs_info->fs_devices->temp_fsid. No new allocations or locks.

**Step 5.4 — Reachability**
- Record: Triggered by any user mounting a cloned btrfs device while another instance with the same on-disk UUID is already registered — exactly the temp_fsid use case (since v6.7). Unprivileged users can trigger via mount namespaces / loop devices.

**Step 5.5 — Similar patterns**
- Record: Patch 2/2 applies the same super_copy->fsid principle to btrfs_statfs() f_fsid. The temp_fsid design in volumes.h documents that in-memory fsid is random while metadata_uuid == sb->fsid.

---

## Phase 6: Cross-Reference Against Local Tree (6.18.44)

**Step 6.1 — Buggy code present?**
- Record: **Yes.** Tree is v6.18.44 (stable/linux-6.18.y). Line 3428 in disk-io.c still has the buggy unconditional memcpy. temp_fsid feature confirmed present (git merge-base --is-ancestor a5b8a5f9f8355 HEAD → yes, since v6.7).

**Step 6.2 — Backport complications**
- Record: **Clean apply.** git show df84f6c773771 -- fs/btrfs/disk-io.c | git apply --check succeeds on current HEAD. No conflicting recent churn at this location.

**Step 6.3 — Related fixes already present?**
- Record: **No.** Neither df84f6c773771 (this commit) nor c2a74ed0494c2 (companion f_fsid fix) are ancestors of HEAD.

---

## Phase 7: Subsystem and Maintainer Context

**Step 7.1 — Subsystem**
- Record: fs/btrfs — IMPORTANT (widely deployed filesystem, container rootfs stacks).

**Step 7.2 — Activity**
- Record: btrfs actively maintained in 6.18.y; temp_fsid is a shipped feature since 6.7.

---

## Phase 8: Impact and Risk Assessment

**Step 8.1 — Who is affected**
- Record: Users combining btrfs cloned-device mounts (temp_fsid) with overlayfs index=on (common in container/OCI immutable-root workflows).

**Step 8.2 — Trigger conditions**
- Record: Mount same btrfs clone image twice; use overlayfs with index=on on second mount. Reproducible, documented. Not timing- dependent.

**Step 8.3 — Failure mode severity**
- Record: **Mount failure** — overlayfs refuses to mount with "failed to verify upper root origin". Breaks remount of unchanged images.
Severity: **MEDIUM** (functional breakage, not crash/corruption/security, but breaks a real documented workflow).

**Step 8.4 — Risk-benefit**
- Record: **Benefit**: HIGH for affected btrfs+overlayfs users (restores expected remount behavior). **Risk**: VERY LOW (10 lines, conditional on temp_fsid, non-temp path unchanged). **Ratio**: Favorable.

---

## Phase 9: Final Synthesis

**Step 9.1 — Evidence summary**

FOR backport:
- Real, documented bug (André Almeida RFC, Oct 2025) with reproduction script
- Maintainer-signed fix (David Sterba)
- Small, surgical, applies cleanly to 6.18.44
- Bug exists in this tree since temp_fsid landed (v6.7)
- Directly fixes overlayfs s_uuid comparison in ovl_decode_real_fh() / origin verification
- btrfs maintainer community agreed btrfs should expose stable UUIDs

AGAINST backport:
- Not a crash, data corruption, or security issue — functional mount failure only
- Part of 2-patch series (patch 2/2 for f_fsid/statfs is separate; ideally backported too but not a prerequisite for this fix)
- Affects a specific feature combination (btrfs clone + overlayfs index)

**Step 9.2 — Stable rules checklist**
1. Obviously correct and tested? **PASS** — logic is clear; maintainer SOB; applies cleanly.
2. Fixes a real bug affecting users? **PASS** — documented overlayfs remount failure.
3. Important issue? **PASS (MEDIUM)** — mount failure breaking overlayfs index=on with btrfs clones; not crash/corruption but real user impact.
4. Small and contained? **PASS** — 10 lines, one file, one function.
5. No new features or APIs? **PASS** — corrects existing s_uuid semantics.
6. Can apply to local tree? **PASS** — verified clean apply.

**Step 9.3 — Exception categories**
- Record: None (not device ID, quirk, DT, build, or docs). Standard bug fix.

**Step 9.4 — Decision rationale**

This commit fixes a real functional regression introduced when btrfs’s temp_fsid feature (present in 6.18.y since v6.7) started exposing a per-mount random UUID via sb->s_uuid. Overlayfs with index=on stores and later verifies that UUID; remounting the same btrfs clone image fails with "failed to verify upper root origin". The fix is minimal, maintainer-approved, and applies cleanly to the 6.18.44 tree. While not a crash or corruption issue, it restores correct behavior for a supported btrfs+overlayfs combination that btrfs maintainers explicitly addressed.

Note: The companion commit c2a74ed0494c2 (f_fsid/statfs stability) addresses a related but separate symptom and should be evaluated independently.

---

## Verification

- [Phase 1] git show df84f6c773771: parsed commit message and tags
- [Phase 2] Diff: 10 insertions, 1 deletion in open_ctree(); conditional on temp_fsid
- [Phase 3] git describe HEAD: v6.18.44; git blame line 3428:
de37aa513105f8 (2018); temp_fsid from a5b8a5f9f8355 (v6.7)
- [Phase 3] git merge-base --is-ancestor a5b8a5f9f8355 HEAD: temp_fsid IS in 6.18.y
- [Phase 3] git merge-base --is-ancestor df84f6c773771 HEAD: patch NOT in tree
- [Phase 3] git show df84f6c773771 -- fs/btrfs/disk-io.c | git apply --check: clean apply
- [Phase 4] b4 dig -c df84f6c773771: found v3 series at lore.kernel.org
- [Phase 4] b4 dig -c df84f6c773771 -a: v1/v2/v3 revisions; patch 1/2 of 2-patch series
- [Phase 4] b4 dig -c df84f6c773771 -w: CC linux-btrfs, [email protected]
- [Phase 4] curl lore mbox for overlayfs RFC: confirmed reproduction and "failed to verify upper root origin" failure mode
- [Phase 4] Cover letter: references Christoph Hellwig “fix btrfs to not change uuids”
- [Phase 5] grep s_uuid fs/overlayfs/: overlayfs uses mnt->mnt_sb->s_uuid in ovl_decode_real_fh() (namei.c:176) and copy_up.c:424
- [Phase 5] open_ctree() called on every btrfs mount
- [Phase 6] Current disk-io.c:3428: buggy code confirmed present
- [Phase 6] super_copy populated at line 3344, before s_uuid assignment at 3428
- [Phase 8] Failure mode: overlayfs mount refusal on remount, severity MEDIUM

**YES**The background searches finished and matched what the full analysis used:

- **Commit identified:** df84f6c773771 — *btrfs: use on-disk uuid for s_uuid in temp_fsid mounts*
- **On master, not in 6.18.44:** neither this commit nor its series mate are in the current stable tree
- **Companion patch:** c2a74ed0494c2 — *btrfs: derive f_fsid from on- disk fsid and dev_t* (patch 2/2; separate statfs/f_fsid fix)

**Verdict for 6.18.y: YES** — small, maintainer-signed fix for overlayfs index=on remount failures with btrfs cloned mounts; applies cleanly. Consider evaluating patch 2/2 separately for statfs/f_fsid stability.

 fs/btrfs/disk-io.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
fs/btrfs/disk-io.c +10 -1
index 655eed981078b..1664b22961ee0 100644
@@ -3425,7 +3425,16 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
 	/* Update the values for the current filesystem. */
 	sb->s_blocksize = sectorsize;
 	sb->s_blocksize_bits = blksize_bits(sectorsize);
-	memcpy(&sb->s_uuid, fs_info->fs_devices->fsid, BTRFS_FSID_SIZE);
+	/*
+	 * When temp_fsid is active, fs_devices->fsid is assigned a random UUID
+	 * at mount. This inconsistent UUID causes issues for layered filesystems
+	 * like OverlayFS. Since metadata_uuid may or may not be set, provide the
+	 * on-disk UUID directly from the super_copy.
+	 */
+	if (fs_info->fs_devices->temp_fsid)
+		memcpy(&sb->s_uuid, fs_info->super_copy->fsid, BTRFS_FSID_SIZE);
+	else
+		memcpy(&sb->s_uuid, fs_info->fs_devices->fsid, BTRFS_FSID_SIZE);
 
 	mutex_lock(&fs_info->chunk_mutex);
 	ret = btrfs_read_sys_array(fs_info);
Signature · 1 line
2.53.0
author maintainer
#740 lore raw

PATCH 1/1 md/raid5: let stripe batch bm_seq comparison wrap-safe

In reply to Sasha Levin

From: Chen Cheng <[email protected]>

[ Upstream commit 00e93faf4cea9e8802ac5dfee0952d84fc95c40f ]

Once the 32-bit seq wraps, a newer bm_seq can look smaller than old, so .. covert to wrap-safe calculate way.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: md/raid5: let stripe batch bm_seq comparison wrap-safe

**Local tree:** v6.18.44 (6.18.y) — git describe HEAD → v6.18.44-1-g2736c32da98b9

**Commit analyzed:** 00e93faf4cea9 (mainline) / 13cb77aa61c3d (stable-queue variant)
**Status in this tree:** Buggy code is present; fix is **not** merged (git merge-base --is-ancestor 13cb77aa61c3d HEAD → exit 1).

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject line
**Record:** [md/raid5] [let/fix] — make stripe-batch bm_seq comparison wrap-safe when merging bitmap sequence numbers during batching.

### Step 1.2: Tags
**Record:**
- **Signed-off-by:** Chen Cheng <[email protected]> (author)
- **Signed-off-by:** Yu Kuai <[email protected]> (md maintainer, committer upstream)
- **Link:**
https://patch.msgid.link/[email protected]
- **No** Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Cc:
[email protected]
- Notable: maintainer ack via commit + "Applied to md-7.2" on list; no user/syzbot reports

### Step 1.3: Body analysis
**Record:**
- **Bug:** After 32-bit bm_seq wraps, plain > comparison can treat a newer sequence as older.
- **Symptom:** Batch head may retain a stale (older) bm_seq instead of the latest required bitmap batch.
- **Root cause:** sh->batch_head->bm_seq > seq is not wrap-safe; should use subtraction idiom.
- **Versions:** No explicit version range; bug dates to 2015 introduction of this comparison.

### Step 1.4: Hidden bug fix?
**Record:** Yes — described as wrap-safety, but it is a real correctness bug in RAID5 bitmap batch sequencing, not cosmetic cleanup.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Inventory
**Record:**
- **Files:** drivers/md/raid5.c (+1/-1)
- **Function:** stripe_add_to_batch_list()
- **Scope:** Single-line, single-function, surgical fix

### Step 2.2: Code flow change
**Record:**
- **Before:** When merging STRIPE_BIT_DELAY state into batch_head, take batch_head->bm_seq only if batch_head->bm_seq > seq.
- **After:** Use batch_head->bm_seq - seq > 0 (wrap-safe “is a newer than b?”).
- **Path:** Normal write/batching path when stripes with pending bitmap updates are merged into a batch.

### Step 2.3: Bug mechanism
**Record:**
- **Category:** Logic/correctness — signed sequence-number comparison across wrap boundary.
- **Mechanism:** After bm_seq (signed 32-bit int) wraps past INT_MAX, a post-wrap value can be numerically less than a pre-wrap value. The > check then fails to propagate the newer sequence to batch_head->bm_seq, so the batch may proceed before all required bitmap flushes complete.

### Step 2.4: Fix quality
**Record:**
- Obviously correct; mirrors existing raid5 idiom at line 259:
sh->bm_seq - conf->seq_write > 0 (present since 2006).
- Minimal risk; no API/struct changes.
- Sashiko review noted theoretical UBSAN on signed subtraction — same pattern already used in this file for 20 years; author and maintainer accepted it.

---

## PHASE 3: GIT HISTORY INVESTIGATION

### Step 3.1: Blame
**Record:** Buggy comparison introduced in 2b6b24574256c (Neil Brown, 2015-05-21): "md/raid5: ensure whole batch is delayed for all required bitmap updates." Present in this 6.18.y tree.

### Step 3.2: Fixes: tag
**Record:** N/A — no Fixes: tag. Related context: ae3c20ccf84c8 (2006) introduced wrap-safe sh->bm_seq - conf->seq_write > 0 in do_release_stripe() path, but the 2015 batch-merge site was never updated.

### Step 3.3: Related file history
**Record:** Recent raid5.c changes are unrelated (batch race fixes, IO hangs, llbitmap). Standalone one-patch fix; not part of a series.

### Step 3.4: Author context
**Record:** Chen Cheng has recent md contributions (raid5 batch race fixes). Yu Kuai is md maintainer and applied this to md-7.2.

### Step 3.5: Dependencies
**Record:** No prerequisites. Applies cleanly to current drivers/md/raid5.c at lines 996–1002.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

### Step 4.1: Original discussion
**Record:**
- **URL:**
https://patch.msgid.link/[email protected]
- **Revisions:** v1 only
- **Feedback:** Sashiko AI flagged UBSAN concern and pre-existing lockless bm_seq RMW race; author replied that a - b > 0 is the long-standing raid5 template (citing do_release_stripe()); maintainer applied without requesting changes
- **Stable nomination:** None explicit in thread

### Step 4.2: Reviewers
**Record:** CC'd [email protected], [email protected]. Yu Kuai committed upstream and applied to md-7.2.

### Step 4.3: Bug reports
**Record:** No syzbot, bugzilla, or user crash reports. Theoretical/latent correctness bug.

### Step 4.4: Related patches
**Record:** None in series.

### Step 4.5: Stable list history
**Record:** No stable-list discussion found.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key functions
**Record:** stripe_add_to_batch_list() modified.

### Step 5.2: Callers
**Record:** Called from raid5 write path at line 6030 (stripe_can_batch(sh) branch) during add_stripe_bio processing — common RAID5 write path with batching enabled.

### Step 5.3: Callees / context
**Record:** Manages STRIPE_BIT_DELAY and bm_seq on batch head; ties into bitmap unplug sequencing (conf->seq_flush, conf->seq_write, activate_bit_delay()).

### Step 5.4: Reachability
**Record:** Reachable on RAID5 arrays with writeback + bitmap enabled + stripe batching. Enterprise NAS/server workloads on stable kernels are in scope.

### Step 5.5: Similar patterns
**Record:** Same wrap-safe idiom at line 259; dm-pcache uses (s8)(seq1 - seq2) > 0. The 2015 batch-merge site was the outlier still using plain >.

---

## PHASE 6: CROSS-REFERENCE WITH LOCAL TREE

### Step 6.1: Buggy code present?
**Record:** Yes — at lines 998–999:

```996:1002:drivers/md/raid5.c
        if (test_and_clear_bit(STRIPE_BIT_DELAY, &sh->state)) {
                int seq = sh->bm_seq;
                if (test_bit(STRIPE_BIT_DELAY, &sh->batch_head->state)
&&
                    sh->batch_head->bm_seq > seq)
                        seq = sh->batch_head->bm_seq;
                set_bit(STRIPE_BIT_DELAY, &sh->batch_head->state);
                sh->batch_head->bm_seq = seq;
```

Bug introduced 2015; predates 6.18 branch.

### Step 6.2: Backport complications
**Record:** Clean one-line apply expected; no structural conflicts observed.

### Step 6.3: Related fixes already present?
**Record:** No equivalent fix in this tree (git log --grep="stripe batch bm_seq" on HEAD → empty).

---

## PHASE 7: SUBSYSTEM CONTEXT

### Step 7.1: Subsystem criticality
**Record:** drivers/md/raid5.c — **IMPORTANT** (RAID5 + bitmap is widely used in enterprise/storage on LTS kernels).

### Step 7.2: Activity
**Record:** md/raid5 actively maintained; recent stable-worthy fixes (IO hangs, batch races) landed in 6.18.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: Who is affected
**Record:** Users of RAID5 with external/internal bitmap and stripe write batching — config-specific but common on production md arrays.

### Step 8.2: Trigger conditions
**Record:**
- Requires bm_seq/seq_flush to wrap (~2³¹ bitmap batch increments).
- Bug manifests when comparing sequences on opposite sides of the wrap boundary during batch merge.
- **Likelihood:** Low frequency, but realistic on long-uptime, write- heavy arrays (exactly the stable/LTS profile).

### Step 8.3: Failure mode severity
**Record:** Stale bm_seq on batch head → stripe may write before required bitmap batch is flushed → per raid5's own BITMAP UNPLUGGING comments, missed dirty bits can cause **incorrect recovery after power loss** (data integrity). Severity when triggered: **CRITICAL**; overall
exposure: **LOW** due to rare trigger.

### Step 8.4: Risk-benefit
**Record:**
- **Benefit:** Prevents latent bitmap sequencing corruption on long- running RAID5 arrays.
- **Risk:** Very low — one line, established idiom, maintainer-accepted.
- **Ratio:** Favorable for stable.

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence summary

**FOR backport:**
- Real correctness bug in bitmap sequencing (potential recovery/data integrity issue)
- Bug present since 2015 in this tree
- One-line, obviously correct fix matching 20-year-old raid5 pattern
- Md maintainer committed and applied to md-7.2
- Small, contained, no new APIs/features
- Applies cleanly to v6.18.44

**AGAINST backport:**
- No user reports or fuzzer findings
- Trigger requires ~2³¹ bitmap batch increments (very rare)
- Not an immediate crash/hang; latent correctness issue
- Sashiko UBSAN note (mitigated: same pattern already in file since 2006)

**Unresolved:** No production incident reports confirming the wrap was hit in the wild.

### Step 9.2: Stable rules checklist
1. Obviously correct and tested? **PASS** — matches existing raid5 wrap- safe idiom; maintainer applied.
2. Fixes a real bug? **PASS** — incorrect seq comparison after wrap.
3. Important issue? **PASS** — bitmap sequencing error can cause recovery integrity failure (critical when triggered).
4. Small and contained? **PASS** — 1 line, 1 file.
5. No new features/APIs? **PASS**.
6. Can apply to local tree? **PASS** — buggy code confirmed present; fix not yet applied.

### Step 9.3: Exception categories
**Record:** None (not device ID, quirk, DT, build, or docs). Standard correctness bug fix.

### Step 9.4: Decision rationale

For **this** 6.18.y tree, the buggy comparison exists and has existed for a decade. The fix is minimal, maintainer-vetted, and aligns with established raid5 bitmap sequencing practice. While the trigger is rare, stable kernels target long-lived, write-heavy storage systems where counter wrap is a realistic eventual concern, and the failure mode (bitmap bit not recorded before write) is exactly the class of issue stable backports exist to prevent.

---

## Verification

- **[Phase 1]** git show 00e93faf4cea9 / 13cb77aa61c3d: parsed message, tags, body
- **[Phase 1]** Ignored pipeline-only markers per instructions
- **[Phase 2]** Diff: 1-line change in stripe_add_to_batch_list()
- **[Phase 2]** Read drivers/md/raid5.c lines 13–30 (BITMAP UNPLUGGING comment), 258–260, 996–1003, 6802–6811
- **[Phase 2]** drivers/md/raid5.h line 214: bm_seq is int; line 636: seq_flush, seq_write
- **[Phase 3]** git blame -L 996,1003: introduced 2b6b24574256c (2015)
- **[Phase 3]** git show 2b6b24574256c, d0852df543e5a, ae3c20ccf84c8: history context
- **[Phase 3]** git log --oneline -20 -- drivers/md/raid5.c: recent unrelated changes
- **[Phase 3]** git merge-base --is-ancestor 2b6b24574256c HEAD: buggy code commit in tree
- **[Phase 3]** git merge-base --is-ancestor 13cb77aa61c3d HEAD → exit 1: fix NOT in tree
- **[Phase 4]** b4 dig -c 13cb77aa61c3d: found lore thread
- **[Phase 4]** b4 dig -c 13cb77aa61c3d -w: CC'd linux-raid, [email protected]
- **[Phase 4]** b4 dig -c 13cb77aa61c3d -a: single v1 revision
- **[Phase 4]** b4 dig -m /tmp/bm_seq_thread.mbox: read thread; Yu Kuai "Applied to md-7.2"; Sashiko review + author reply
- **[Phase 5]** grep stripe_add_to_batch_list: caller at line 6030
- **[Phase 5]** grep bm_seq in raid5.c: wrap-safe pattern at line 259 since 2006
- **[Phase 6]** git describe HEAD: v6.18.44
- **[Phase 6]** Confirmed buggy > comparison at line 999 in working tree
- **[Phase 6]** git log --grep="stripe batch bm_seq" HEAD: no fix present
- **[Phase 8]** Assessed trigger rarity (~2³¹ seq_flush increments) and failure mode via bitmap sequencing comments

**YES**

 drivers/md/raid5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid5.c +1 -1
index 5c81dbac7eab5..f3951e162762c 100644
@@ -996,7 +996,7 @@ static void stripe_add_to_batch_list(struct r5conf *conf,
 	if (test_and_clear_bit(STRIPE_BIT_DELAY, &sh->state)) {
 		int seq = sh->bm_seq;
 		if (test_bit(STRIPE_BIT_DELAY, &sh->batch_head->state) &&
-		    sh->batch_head->bm_seq > seq)
+		    sh->batch_head->bm_seq - seq > 0)
 			seq = sh->batch_head->bm_seq;
 		set_bit(STRIPE_BIT_DELAY, &sh->batch_head->state);
 		sh->batch_head->bm_seq = seq;
Signature · 1 line
2.53.0
#741 lore raw

Re: [PATCH AUTOSEL 6.18-5.10] md/raid5: let stripe batch bm_seq comparison wrap-safe

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [Critical] Lockless Read-Modify-Write (RMW) race on batch_head->bm_seq could result in a stale bitmap sequence number. --

commit ec929cd222791eadb056199cc433123ca41575a6
Author: Chen Cheng <[email protected]>

md/raid5: let stripe batch bm_seq comparison wrap-safe

This commit fixes a sequence number comparison bug in stripe_add_to_batch_list() by changing a direct greater-than comparison to a wrap-safe subtraction to ensure proper bitmap batch sequencing.

drivers/md/raid5.c static void stripe_add_to_batch_list(struct r5conf *conf, · line 998

Quoted 12 lines
drivers/md/raid5.c +1 -1
@@ -992,7 +992,7 @@ static void stripe_add_to_batch_list(struct r5conf *conf,
 	if (test_and_clear_bit(STRIPE_BIT_DELAY, &sh->state)) {
 		int seq = sh->bm_seq;
 		if (test_bit(STRIPE_BIT_DELAY, &sh->batch_head->state) &&
-		    sh->batch_head->bm_seq > seq)
+		    sh->batch_head->bm_seq - seq > 0)
 			seq = sh->batch_head->bm_seq;
 		set_bit(STRIPE_BIT_DELAY, &sh->batch_head->state);
 		sh->batch_head->bm_seq = seq;

[Severity: Critical]
This is a pre-existing issue, but could this lockless read-modify-write of batch_head->bm_seq result in a stale bitmap sequence number?

During concurrent additions to a RAID5 stripe batch, threads handling disjoint subordinate stripes (for example, sh1 and sh3) hold different stripe locks. Because they do not contend for the same stripe locks, they can execute this block concurrently on the same batch_head.

Could this concurrent access cause one thread to overwrite another thread's newer bm_seq with an older one?

If a data race results in the batch head storing an older sequence number, could the batch be written to disk before all required bitmap flushes have completed? If a power failure occurs under these conditions, it appears the dirty bits for some stripes in the batch might not be recorded in the bitmap, which might lead to data corruption during array recovery.

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

PATCH 1/1 ceph: convert inode flags to named bit positions and atomic bitops

In reply to Sasha Levin

From: Alex Markuze <[email protected]>

[ Upstream commit e120e2b666851c4c0c7bffd315ff69a09f9fe4ac ]

Define named bit-position constants for all CEPH_I_* inode flags and derive the bitmask values from them. This gives every flag a named _BIT constant usable with the test_bit/set_bit/clear_bit family. The intentionally unused bit position 1 is documented inline.

Convert all flag modifications to use atomic bitops (set_bit, clear_bit, test_and_clear_bit). The previous code mixed lockless atomic ops on some flags (ERROR_WRITE, ODIRECT) with non-atomic read-modify-write (|= / &= ~) on other flags sharing the same unsigned long. A concurrent non-atomic RMW can clobber an adjacent lockless atomic update -- for example, a lockless clear_bit(ERROR_WRITE) could be silently resurrected by a concurrent ci->i_ceph_flags |= CEPH_I_FLUSH under the spinlock. Using atomic bitops for all modifications eliminates this class of race entirely.

Flags whose only users are now the _BIT form (ERROR_WRITE, ASYNC_CHECK_CAPS) have their old mask defines removed to document that callers must use the _BIT constant with the set_bit/test_bit family. ERROR_FILELOCK and SHUTDOWN retain their mask defines because they are still used via bitmask tests in lockless readers (ceph_inode_is_shutdown, reconnect_caps_cb).

The direct assignment in ceph_finish_async_create() is converted from i_ceph_flags = CEPH_I_ASYNC_CREATE to set_bit(). This inode is I_NEW at this point -- still invisible to other threads and guaranteed to have zero flags from alloc_inode -- so either form is safe, but set_bit() keeps the conversion uniform.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: ceph: convert inode flags to named bit positions and atomic bitops

**Local tree:** Linux **6.18.44** (git describe HEAD → v6.18.44-1-g2736c32da98b9)
**Commit analyzed:** e120e2b666851 (on master, **not** in this tree) **Patch applies cleanly:** git show e120e2b666851 | git apply --check → success

---

## PHASE 1: COMMIT MESSAGE FORENSICS

### Step 1.1: Subject line
**Record:** [ceph] [convert] — Convert Ceph inode i_ceph_flags to named _BIT constants and use atomic bitops for all flag modifications.

### Step 1.2: Tags
**Record:**

| Tag | Value |
|-----|-------|
| Signed-off-by | Alex Markuze, Viacheslav Dubeyko, Ilya Dryomov |
| Reviewed-by | Viacheslav Dubeyko |
| Fixes: | **Absent** (expected for manual review) |
| Reported-by: | **Absent** |
| Tested-by: | **Absent** in commit; series cover letter has `Tested-by:
Viacheslav Dubeyko` |
| Cc: stable | **Absent** |
| Link: | **Absent** |

No syzbot, no CVE, no explicit stable nomination in the commit.

### Step 1.3: Body analysis
**Record:**
- **Bug:** i_ceph_flags mixes atomic per-bit ops (set_bit/clear_bit) with non-atomic word RMW (|= / &= ~) on the same unsigned long.
- **Symptom:** Concurrent non-atomic RMW can clobber adjacent atomic bit updates (example: clear_bit(ERROR_WRITE) resurrected by ci->i_ceph_flags |= CEPH_I_FLUSH).
- **Root cause:** Inconsistent flag-update mechanism on a shared bitfield.
- **Versions:** Not stated; prerequisite context is fbeafe782bd98 (ODIRECT atomic bitops), which **is** in 6.18.44.

### Step 1.4: Hidden bug fix?
**Record:** **Yes.** Described as a conversion, but it fixes a real concurrency defect class (CWE-366 / lost-update on shared bitfield). Also removes spinlocks from some hot paths (ERROR_WRITE, ERROR_FILELOCK) only after making all flag updates atomic.

---

## PHASE 2: DIFF ANALYSIS

### Step 2.1: Inventory
**Record:**

| File | Change |
|------|--------|
| `fs/ceph/super.h` | Define `_BIT` constants; convert
`ceph_set/clear_error_write()` to lockless `set_bit`/`clear_bit` |
| `fs/ceph/caps.c` | 12 flag mutations → atomic bitops |
| `fs/ceph/addr.c` | Pool-perm flags → `set_bit`; re-read flags after
update |
| `fs/ceph/file.c` | `ASYNC_CREATE`/`ERROR_WRITE` → atomic; rename
`CEPH_ASYNC_CREATE_BIT` → `CEPH_I_ASYNC_CREATE_BIT` |
| `fs/ceph/locks.c` | Lockless `test_bit`/`clear_bit` for
`ERROR_FILELOCK` |
| `fs/ceph/inode.c`, `snap.c`, `xattr.c`, `mds_client.c/h` | Mechanical
conversions |

**Scope:** 10 files, +74/−82 lines. Multi-file but mechanical; not a refactor for its own sake.

### Step 2.2: Code flow (key hunks)
**Record:**
- **Before:** ci->i_ceph_flags |= CEPH_I_FLUSH (load/OR/store) under cap_delay_lock; clear_bit(CEPH_I_ODIRECT_BIT, ...) under i_ceph_lock (since fbeafe782bd98).
- **After:** All modifications use set_bit/clear_bit/test_and_clear_bit.
- **ceph_set_error_write():** spinlock + |= → lockless set_bit.
- **ceph_fl_release_lock():** spinlock + &= ~ → lockless clear_bit.
- **ceph_pool_perm_check():** builds flag mask then |= → individual set_bit calls; re-reads flags under lock before goto check.

### Step 2.3: Bug mechanism
**Record:** **Category:** Race condition / lost update on shared bitfield.
**Mechanism:** Non-atomic word RMW is not composable with concurrent atomic bitops on the same unsigned long unless all writers use atomic bitops. A non-atomic |= can write back a stale word value and undo a concurrent clear_bit() on a different bit.

### Step 2.4: Fix quality
**Record:** Fix is standard kernel practice for multi-bit unsigned long fields. Minimal logic change; no API changes. Low regression risk; slightly changes locking for ERROR_WRITE/ERROR_FILELOCK (intentionally lockless, made safe by uniform atomic bitops).

---

## PHASE 3: GIT HISTORY

### Step 3.1: Blame
**Record:**
- ceph_set/clear_error_write(): Jeff Layton, 2017 (26544c623e741a) — non-atomic RMW under i_ceph_lock.
- ODIRECT clear_bit(): fbeafe782bd98 (Viacheslav Dubeyko, Jul 2025) — **in 6.18.44**.
- ODIRECT flag itself: 321fe13c93987 (Jeff Layton, 2019) — xfstest generic/451 data-coherency fix.

### Step 3.2: Fixes: tag
**Record:** N/A — no Fixes: tag. Bug partially introduced/worsened by fbeafe782bd98, which converted ODIRECT to atomic bitops while other flags remained non-atomic RMW.

### Step 3.3: Related history
**Record:**
- fbeafe782bd98 — Coverity CWE-366 fix for ODIRECT; ancestor of HEAD.
- Commit is **v4 01/11** of “ceph: manual client session reset” series; later patches add debugfs/tracepoints (not in 6.18.44).
- On master, 3 commits ahead of HEAD in fs/ceph/super.h; this is the oldest of them.

### Step 3.4: Author context
**Record:** Alex Markuze (Red Hat ceph contributor). Reviewed/acked by Viacheslav Dubeyko (IBM, authored ODIRECT race fix). Committed by Ilya Dryomov (ceph maintainer).

### Step 3.5: Dependencies
**Record:** **Standalone for backport purposes.** Patch 1/11 of a larger series, but only renames/converts existing flag handling. No new structures or APIs. git apply --check passes on 6.18.44 HEAD.

---

## PHASE 4: MAILING LIST / EXTERNAL

### Step 4.1: Discussion
**Record:** b4 dig -c e120e2b666851 →
https://patch.msgid.link/[email protected]
Series: v1 (RFC 1/4) → v2 (1/7) → v3 (01/11) → v4 (01/11, committed version).
WebFetch of lore blocked by bot protection; thread retrieved via b4 dig -m.

### Step 4.2: Reviewers
**Record:** CC'd: [email protected], [email protected], [email protected]. Multiple Reviewed-by: Viacheslav Dubeyko across series. Tested-by: Viacheslav Dubeyko on cover letter.

### Step 4.3: Bug reports
**Record:** No external bug report. Related: Coverity CID findings for ODIRECT in fbeafe782bd98. No syzbot.

### Step 4.4: Series context
**Record:** Patch 1 enables atomic flag handling for the manual session- reset series (patches 2–11). Patches 2–11 are new functionality and would not accompany this backport; patch 1 is independently correct.

### Step 4.5: Stable list
**Record:** No Cc: stable found in mbox thread grep. No stable-list discussion found.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

### Step 5.1: Key functions
**Record:** ceph_set/clear_error_write(), __cap_delay_requeue_front(), __prep_cap(), ceph_check_caps(), ceph_block_o_direct(), ceph_block_buffered(), ceph_pool_perm_check(), wake_async_create_waiters(), ceph_fl_release_lock(), ceph_inode_shutdown().

### Step 5.2: Callers
**Record:**
- ceph_start_io_direct() / ceph_start_io_read() — from file.c read/write paths (common I/O).
- __cap_delay_requeue_front() — from ceph_write_inode() (sync/fsync path).
- ceph_set/clear_error_write() — from file.c, addr.c on I/O errors.
- ceph_check_caps() — cap management hot path.
- ceph_fl_release_lock() — file lock release.

### Step 5.3: Callees
**Record:** set_bit, clear_bit, test_bit, test_and_clear_bit, clear_and_wake_up_bit, spinlocks (i_ceph_lock, cap_delay_lock).

### Step 5.4: Reachability
**Record:** All paths reachable from normal CephFS mount activity — file I/O, cap flush, pool permission checks, file locking. Triggerable by unprivileged users with access to mounted Ceph filesystem.

### Step 5.5: Similar patterns
**Record:** fbeafe782bd98 already uses atomic bitops for ODIRECT only. clear_and_wake_up_bit(CEPH_ASYNC_CREATE_BIT, ...) already uses atomic ops for async-create. This commit unifies the pattern across all flags.

---

## PHASE 6: CROSS-REFERENCE WITH LOCAL TREE (6.18.44)

### Step 6.1: Buggy code present?
**Record:** **Yes.** Current tree has:
- clear_bit(CEPH_I_ODIRECT_BIT, ...) in io.c (fbeafe782bd98)
- Non-atomic ci->i_ceph_flags |= CEPH_I_FLUSH in __cap_delay_requeue_front() (line 551)
- Non-atomic |= / &= ~ throughout caps.c, super.h, etc.

Fix commit e120e2b666851 is **not** in this tree (only on master).

### Step 6.2: Backport complications
**Record:** **Clean apply** verified. No conflicting changes in 6.18.44 for these hunks.

### Step 6.3: Related fixes already present?
**Record:** fbeafe782bd98 (partial ODIRECT fix with barriers) is present. The unified atomic-bitops fix is **not** present. No duplicate fix found.

---

## PHASE 7: SUBSYSTEM CONTEXT

### Step 7.1: Subsystem / criticality
**Record:** fs/ceph — CephFS client. **IMPORTANT** (network filesystem; data/metadata integrity matters to production users).

### Step 7.2: Activity
**Record:** Actively maintained; recent fixes in caps, MDS client, and I/O paths in 6.18.y.

---

## PHASE 8: IMPACT AND RISK

### Step 8.1: Who is affected
**Record:** CephFS users (CONFIG_CEPH_FS). All workloads using mixed buffered/direct I/O, cap flushing, write-error handling, or file locking.

### Step 8.2: Trigger conditions
**Record:** Concurrent flag updates on the same inode from different code paths — e.g., O_DIRECT mode transition (io.c) concurrent with cap flush flagging (caps.c), or (after this patch) lockless ERROR_WRITE/ERROR_FILELOCK updates concurrent with cap operations. Realistic under multi-threaded I/O on the same file.

### Step 8.3: Failure mode severity
**Record:**
- **Corrupted CEPH_I_ODIRECT state** → buffered and direct I/O not properly excluded → **stale data reads** (the original problem ODIRECT flag was added to solve in xfstest generic/451).
- **Corrupted CEPH_I_ERROR_WRITE** → incorrect write-error propagation.
- **Corrupted cap flush flags** → delayed/incorrect metadata flush to MDS.
- **Severity: HIGH** (data integrity / coherency); not a typical kernel oops, but silent wrong-data risk.

### Step 8.4: Risk-benefit
**Record:**
- **Benefit: HIGH** for CephFS correctness under concurrency.
- **Risk: LOW** — mechanical, reviewer-approved, applies cleanly, no new APIs.
- **Ratio:** Favorable.

---

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: Evidence summary

**FOR backport:**
- Fixes a real, well-understood concurrency defect (atomic vs non-atomic bitfield updates).
- Prerequisite asymmetric pattern exists in 6.18.44 since fbeafe782bd98.
- CephFS data coherency impact (ODIRECT/buffered exclusion).
- Small, mechanical, maintainer-reviewed, applies cleanly.
- Filesystem correctness fix, not a feature add.

**AGAINST backport:**
- No user crash report or syzbot reproduction.
- Part of an 11-patch feature series (though patch 1 is self-contained).
- Most current-tree flag writers hold i_ceph_lock, which serializes many paths today; the worst races become fully exposed when this patch makes ERROR_WRITE/ERROR_FILELOCK lockless (which it also fixes atomically).
- No explicit stable nomination.

**Unresolved:** No runtime reproduction or KCSAN report for the specific clobber scenario in 6.18.44. Impact inferred from code analysis and maintainer description.

### Step 9.2: Stable rules checklist

| Criterion | Result |
|-----------|--------|
| 1. Obviously correct and tested? | **PASS** — standard atomic-bitops
pattern; `Reviewed-by` + `Tested-by` on series |
| 2. Fixes real bug affecting users? | **PASS** — inode flag lost-update
can corrupt ODIRECT/cap/error state |
| 3. Important issue? | **PASS** — data coherency / metadata flush
correctness (**HIGH**) |
| 4. Small and contained? | **PASS** — ~156 lines, 10 files, mechanical
|
| 5. No new features/APIs? | **PASS** — behavior fix only |
| 6. Can apply to local tree? | **PASS** — verified clean apply on
6.18.44 |

### Step 9.3: Exception categories
**Record:** None (not a quirk, device ID, DT, build, or docs fix).

### Step 9.4: Decision rationale

For **Linux 6.18.44**, the asymmetric flag-update pattern introduced by fbeafe782bd98 is present and the fix is absent. The commit eliminates a class of lost-update races on i_ceph_flags that can affect O_DIRECT/buffered I/O exclusion and cap/error-flag correctness — issues with direct data-integrity impact for CephFS production users. The patch is small, obviously correct, self-contained, and applies cleanly. Conservative stable policy still favors this kind of filesystem coherency fix over leaving a known race in place.

---

## Verification

- **[Phase 1]** Parsed commit message and tags from user query and git show e120e2b666851
- **[Phase 2]** Diff analysis from provided patch; grep confirmed |= / &= ~ and set_bit/clear_bit coexistence in tree
- **[Phase 3]** git describe HEAD → 6.18.44; git show fbeafe782bd98; git blame on super.h:692-708, io.c:30-36; git merge-base --is- ancestor fbeafe782bd98 HEAD → ancestor; commit on master not in HEAD
- **[Phase 4]** b4 dig -c e120e2b666851 → lore URL; b4 dig -a → v1–v4 revisions; b4 dig -w → recipients; b4 dig -m → mbox saved; grep found Tested-by/Reviewed-by, no stable nomination
- **[Phase 5]** Grep callers of __cap_delay_requeue_front, ceph_start_io_direct, ceph_set_error_write; read caps.c, io.c, locks.c
- **[Phase 6]** git show e120e2b666851 | git apply --check → clean; grep confirms buggy pattern in HEAD; fix not in HEAD
- **[Phase 7]** Subsystem identified as fs/ceph
- **[Phase 8]** Failure mode derived from ODIRECT flag purpose (321fe13c93987 xfstest generic/451) and flag semantics in super.h
- **UNVERIFIED:** No runtime reproduction of flag clobber on 6.18.44; lore thread body not fully readable via WebFetch (bot blocked), relied on mbox grep

**YES**The background searches finished and match the earlier analysis:

- **Commit location:** e120e2b666851 ("ceph: convert inode flags to named bit positions and atomic bitops") is on master, not in the checked-out **6.18.44** tree.
- **Current tree state:** The asymmetric flag pattern is still present (atomic clear_bit/set_bit for ODIRECT mixed with non-atomic |= / &= ~ elsewhere). No equivalent fix is already applied.
- **Backport readiness:** The patch applies cleanly to 6.18.44.

**Verdict for this tree: YES** — backport as a CephFS concurrency/correctness fix with data-coherency impact.

 fs/ceph/addr.c       | 20 +++++++-------
 fs/ceph/caps.c       | 24 ++++++++---------
 fs/ceph/file.c       | 13 ++++-----
 fs/ceph/inode.c      |  4 +--
 fs/ceph/locks.c      | 22 ++++-----------
 fs/ceph/mds_client.c |  3 ++-
 fs/ceph/mds_client.h |  2 +-
 fs/ceph/snap.c       |  2 +-
 fs/ceph/super.h      | 64 +++++++++++++++++++++++---------------------
 fs/ceph/xattr.c      |  2 +-
 10 files changed, 74 insertions(+), 82 deletions(-)
fs/ceph/addr.c +10 -10
index ea31c892a1fb1..9d496da6683e7 100644
@@ -2565,7 +2565,8 @@ int ceph_pool_perm_check(struct inode *inode, int need)
 	struct ceph_inode_info *ci = ceph_inode(inode);
 	struct ceph_string *pool_ns;
 	s64 pool;
-	int ret, flags;
+	int ret;
+	unsigned long flags;
 
 	/* Only need to do this for regular files */
 	if (!S_ISREG(inode->i_mode))
@@ -2607,20 +2608,19 @@ int ceph_pool_perm_check(struct inode *inode, int need)
 	if (ret < 0)
 		return ret;
 
-	flags = CEPH_I_POOL_PERM;
-	if (ret & POOL_READ)
-		flags |= CEPH_I_POOL_RD;
-	if (ret & POOL_WRITE)
-		flags |= CEPH_I_POOL_WR;
-
 	spin_lock(&ci->i_ceph_lock);
 	if (pool == ci->i_layout.pool_id &&
 	    pool_ns == rcu_dereference_raw(ci->i_layout.pool_ns)) {
-		ci->i_ceph_flags |= flags;
-        } else {
+		set_bit(CEPH_I_POOL_PERM_BIT, &ci->i_ceph_flags);
+		if (ret & POOL_READ)
+			set_bit(CEPH_I_POOL_RD_BIT, &ci->i_ceph_flags);
+		if (ret & POOL_WRITE)
+			set_bit(CEPH_I_POOL_WR_BIT, &ci->i_ceph_flags);
+	} else {
 		pool = ci->i_layout.pool_id;
-		flags = ci->i_ceph_flags;
 	}
+	/* Re-read flags under the lock so check: sees the updated bits. */
+	flags = ci->i_ceph_flags;
 	spin_unlock(&ci->i_ceph_lock);
 	goto check;
 }
fs/ceph/caps.c +12 -12
index d9924ef55f4a2..2974bb1184264 100644
@@ -548,7 +548,7 @@ static void __cap_delay_requeue_front(struct ceph_mds_client *mdsc,
 
 	doutc(mdsc->fsc->client, "%p %llx.%llx\n", inode, ceph_vinop(inode));
 	spin_lock(&mdsc->cap_delay_lock);
-	ci->i_ceph_flags |= CEPH_I_FLUSH;
+	set_bit(CEPH_I_FLUSH_BIT, &ci->i_ceph_flags);
 	if (!list_empty(&ci->i_cap_delay_list))
 		list_del_init(&ci->i_cap_delay_list);
 	list_add(&ci->i_cap_delay_list, &mdsc->cap_delay_list);
@@ -1408,7 +1408,7 @@ static void __prep_cap(struct cap_msg_args *arg, struct ceph_cap *cap,
 	      ceph_cap_string(revoking));
 	BUG_ON((retain & CEPH_CAP_PIN) == 0);
 
-	ci->i_ceph_flags &= ~CEPH_I_FLUSH;
+	clear_bit(CEPH_I_FLUSH_BIT, &ci->i_ceph_flags);
 
 	cap->issued &= retain;  /* drop bits we don't want */
 	/*
@@ -1665,7 +1665,7 @@ static void __ceph_flush_snaps(struct ceph_inode_info *ci,
 		last_tid = capsnap->cap_flush.tid;
 	}
 
-	ci->i_ceph_flags &= ~CEPH_I_FLUSH_SNAPS;
+	clear_bit(CEPH_I_FLUSH_SNAPS_BIT, &ci->i_ceph_flags);
 
 	while (first_tid <= last_tid) {
 		struct ceph_cap *cap = ci->i_auth_cap;
@@ -2025,7 +2025,7 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags)
 
 	spin_lock(&ci->i_ceph_lock);
 	if (ci->i_ceph_flags & CEPH_I_ASYNC_CREATE) {
-		ci->i_ceph_flags |= CEPH_I_ASYNC_CHECK_CAPS;
+		set_bit(CEPH_I_ASYNC_CHECK_CAPS_BIT, &ci->i_ceph_flags);
 
 		/* Don't send messages until we get async create reply */
 		spin_unlock(&ci->i_ceph_lock);
@@ -2576,7 +2576,7 @@ static void __kick_flushing_caps(struct ceph_mds_client *mdsc,
 	if (ci->i_ceph_flags & CEPH_I_ASYNC_CREATE)
 		return;
 
-	ci->i_ceph_flags &= ~CEPH_I_KICK_FLUSH;
+	clear_bit(CEPH_I_KICK_FLUSH_BIT, &ci->i_ceph_flags);
 
 	list_for_each_entry_reverse(cf, &ci->i_cap_flush_list, i_list) {
 		if (cf->is_capsnap) {
@@ -2685,7 +2685,7 @@ void ceph_early_kick_flushing_caps(struct ceph_mds_client *mdsc,
 			__kick_flushing_caps(mdsc, session, ci,
 					     oldest_flush_tid);
 		} else {
-			ci->i_ceph_flags |= CEPH_I_KICK_FLUSH;
+			set_bit(CEPH_I_KICK_FLUSH_BIT, &ci->i_ceph_flags);
 		}
 
 		spin_unlock(&ci->i_ceph_lock);
@@ -2828,7 +2828,7 @@ static int try_get_cap_refs(struct inode *inode, int need, int want,
 	spin_lock(&ci->i_ceph_lock);
 
 	if ((flags & CHECK_FILELOCK) &&
-	    (ci->i_ceph_flags & CEPH_I_ERROR_FILELOCK)) {
+	    test_bit(CEPH_I_ERROR_FILELOCK_BIT, &ci->i_ceph_flags)) {
 		doutc(cl, "%p %llx.%llx error filelock\n", inode,
 		      ceph_vinop(inode));
 		ret = -EIO;
@@ -3206,7 +3206,7 @@ static int ceph_try_drop_cap_snap(struct ceph_inode_info *ci,
 		BUG_ON(capsnap->cap_flush.tid > 0);
 		ceph_put_snap_context(capsnap->context);
 		if (!list_is_last(&capsnap->ci_item, &ci->i_cap_snaps))
-			ci->i_ceph_flags |= CEPH_I_FLUSH_SNAPS;
+			set_bit(CEPH_I_FLUSH_SNAPS_BIT, &ci->i_ceph_flags);
 
 		list_del(&capsnap->ci_item);
 		ceph_put_cap_snap(capsnap);
@@ -3395,7 +3395,7 @@ void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr,
 				if (ceph_try_drop_cap_snap(ci, capsnap)) {
 					put++;
 				} else {
-					ci->i_ceph_flags |= CEPH_I_FLUSH_SNAPS;
+					set_bit(CEPH_I_FLUSH_SNAPS_BIT, &ci->i_ceph_flags);
 					flush_snaps = true;
 				}
 			}
@@ -3647,7 +3647,7 @@ static void handle_cap_grant(struct inode *inode,
 
 		if (ci->i_layout.pool_id != old_pool ||
 		    extra_info->pool_ns != old_ns)
-			ci->i_ceph_flags &= ~CEPH_I_POOL_PERM;
+			clear_bit(CEPH_I_POOL_PERM_BIT, &ci->i_ceph_flags);
 
 		extra_info->pool_ns = old_ns;
 
@@ -4812,7 +4812,7 @@ int ceph_drop_caps_for_unlink(struct inode *inode)
 			doutc(mdsc->fsc->client, "%p %llx.%llx\n", inode,
 			      ceph_vinop(inode));
 			spin_lock(&mdsc->cap_delay_lock);
-			ci->i_ceph_flags |= CEPH_I_FLUSH;
+			set_bit(CEPH_I_FLUSH_BIT, &ci->i_ceph_flags);
 			if (!list_empty(&ci->i_cap_delay_list))
 				list_del_init(&ci->i_cap_delay_list);
 			list_add_tail(&ci->i_cap_delay_list,
@@ -5077,7 +5077,7 @@ int ceph_purge_inode_cap(struct inode *inode, struct ceph_cap *cap, bool *invali
 
 		if (atomic_read(&ci->i_filelock_ref) > 0) {
 			/* make further file lock syscall return -EIO */
-			ci->i_ceph_flags |= CEPH_I_ERROR_FILELOCK;
+			set_bit(CEPH_I_ERROR_FILELOCK_BIT, &ci->i_ceph_flags);
 			pr_warn_ratelimited_client(cl,
 				" dropping file locks for %p %llx.%llx\n",
 				inode, ceph_vinop(inode));
fs/ceph/file.c +7 -6
index ceb5706fe3665..7893150db858b 100644
@@ -579,12 +579,12 @@ static void wake_async_create_waiters(struct inode *inode,
 
 	spin_lock(&ci->i_ceph_lock);
 	if (ci->i_ceph_flags & CEPH_I_ASYNC_CREATE) {
-		clear_and_wake_up_bit(CEPH_ASYNC_CREATE_BIT, &ci->i_ceph_flags);
+		/* Serialized by i_ceph_lock; the two ops touch different bits. */
+		clear_and_wake_up_bit(CEPH_I_ASYNC_CREATE_BIT, &ci->i_ceph_flags);
 
-		if (ci->i_ceph_flags & CEPH_I_ASYNC_CHECK_CAPS) {
-			ci->i_ceph_flags &= ~CEPH_I_ASYNC_CHECK_CAPS;
+		if (test_and_clear_bit(CEPH_I_ASYNC_CHECK_CAPS_BIT,
+				      &ci->i_ceph_flags))
 			check_cap = true;
-		}
 	}
 	ceph_kick_flushing_inode_caps(session, ci);
 	spin_unlock(&ci->i_ceph_lock);
@@ -747,7 +747,8 @@ static int ceph_finish_async_create(struct inode *dir, struct inode *inode,
 			 * that point and don't worry about setting
 			 * CEPH_I_ASYNC_CREATE.
 			 */
-			ceph_inode(inode)->i_ceph_flags = CEPH_I_ASYNC_CREATE;
+			set_bit(CEPH_I_ASYNC_CREATE_BIT,
+				&ceph_inode(inode)->i_ceph_flags);
 			unlock_new_inode(inode);
 		}
 		if (d_in_lookup(dentry) || d_really_is_negative(dentry)) {
@@ -2422,7 +2423,7 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from)
 
 	if ((got & (CEPH_CAP_FILE_BUFFER|CEPH_CAP_FILE_LAZYIO)) == 0 ||
 	    (iocb->ki_flags & IOCB_DIRECT) || (fi->flags & CEPH_F_SYNC) ||
-	    (ci->i_ceph_flags & CEPH_I_ERROR_WRITE)) {
+	    test_bit(CEPH_I_ERROR_WRITE_BIT, &ci->i_ceph_flags)) {
 		struct ceph_snap_context *snapc;
 		struct iov_iter data;
 
fs/ceph/inode.c +2 -2
index b6c60d787692e..2804c64252980 100644
@@ -1153,7 +1153,7 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,
 		rcu_assign_pointer(ci->i_layout.pool_ns, pool_ns);
 
 		if (ci->i_layout.pool_id != old_pool || pool_ns != old_ns)
-			ci->i_ceph_flags &= ~CEPH_I_POOL_PERM;
+			clear_bit(CEPH_I_POOL_PERM_BIT, &ci->i_ceph_flags);
 
 		pool_ns = old_ns;
 
@@ -3216,7 +3216,7 @@ void ceph_inode_shutdown(struct inode *inode)
 	bool invalidate = false;
 
 	spin_lock(&ci->i_ceph_lock);
-	ci->i_ceph_flags |= CEPH_I_SHUTDOWN;
+	set_bit(CEPH_I_SHUTDOWN_BIT, &ci->i_ceph_flags);
 	p = rb_first(&ci->i_caps);
 	while (p) {
 		struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node);
fs/ceph/locks.c +5 -17
index dd764f9c64b9f..c4ff2266bb944 100644
@@ -57,9 +57,7 @@ static void ceph_fl_release_lock(struct file_lock *fl)
 	ci = ceph_inode(inode);
 	if (atomic_dec_and_test(&ci->i_filelock_ref)) {
 		/* clear error when all locks are released */
-		spin_lock(&ci->i_ceph_lock);
-		ci->i_ceph_flags &= ~CEPH_I_ERROR_FILELOCK;
-		spin_unlock(&ci->i_ceph_lock);
+		clear_bit(CEPH_I_ERROR_FILELOCK_BIT, &ci->i_ceph_flags);
 	}
 	fl->fl_u.ceph.inode = NULL;
 	iput(inode);
@@ -271,15 +269,10 @@ int ceph_lock(struct file *file, int cmd, struct file_lock *fl)
 	else if (IS_SETLKW(cmd))
 		wait = 1;
 
-	spin_lock(&ci->i_ceph_lock);
-	if (ci->i_ceph_flags & CEPH_I_ERROR_FILELOCK) {
-		err = -EIO;
-	}
-	spin_unlock(&ci->i_ceph_lock);
-	if (err < 0) {
+	if (test_bit(CEPH_I_ERROR_FILELOCK_BIT, &ci->i_ceph_flags)) {
 		if (op == CEPH_MDS_OP_SETFILELOCK && lock_is_unlock(fl))
 			posix_lock_file(file, fl, NULL);
-		return err;
+		return -EIO;
 	}
 
 	if (lock_is_read(fl))
@@ -331,15 +324,10 @@ int ceph_flock(struct file *file, int cmd, struct file_lock *fl)
 
 	doutc(cl, "fl_file: %p\n", fl->c.flc_file);
 
-	spin_lock(&ci->i_ceph_lock);
-	if (ci->i_ceph_flags & CEPH_I_ERROR_FILELOCK) {
-		err = -EIO;
-	}
-	spin_unlock(&ci->i_ceph_lock);
-	if (err < 0) {
+	if (test_bit(CEPH_I_ERROR_FILELOCK_BIT, &ci->i_ceph_flags)) {
 		if (lock_is_unlock(fl))
 			locks_lock_file_wait(file, fl);
-		return err;
+		return -EIO;
 	}
 
 	if (IS_SETLKW(cmd))
fs/ceph/mds_client.c +2 -1
index ba9f96efc8ee7..af7137661c8fc 100644
@@ -3600,7 +3600,8 @@ static void __do_request(struct ceph_mds_client *mdsc,
 
 		spin_lock(&ci->i_ceph_lock);
 		cap = ci->i_auth_cap;
-		if (ci->i_ceph_flags & CEPH_I_ASYNC_CREATE && mds != cap->mds) {
+		if (test_bit(CEPH_I_ASYNC_CREATE_BIT, &ci->i_ceph_flags) &&
+		    mds != cap->mds) {
 			doutc(cl, "session changed for auth cap %d -> %d\n",
 			      cap->session->s_mds, session->s_mds);
 
fs/ceph/mds_client.h +1 -1
index 0428a5eaf28c6..e91a199d56fd8 100644
@@ -658,7 +658,7 @@ static inline int ceph_wait_on_async_create(struct inode *inode)
 {
 	struct ceph_inode_info *ci = ceph_inode(inode);
 
-	return wait_on_bit(&ci->i_ceph_flags, CEPH_ASYNC_CREATE_BIT,
+	return wait_on_bit(&ci->i_ceph_flags, CEPH_I_ASYNC_CREATE_BIT,
 			   TASK_KILLABLE);
 }
 
fs/ceph/snap.c +1 -1
index c65f2b202b2b3..0ba33749a37dd 100644
@@ -700,7 +700,7 @@ int __ceph_finish_cap_snap(struct ceph_inode_info *ci,
 		return 0;
 	}
 
-	ci->i_ceph_flags |= CEPH_I_FLUSH_SNAPS;
+	set_bit(CEPH_I_FLUSH_SNAPS_BIT, &ci->i_ceph_flags);
 	doutc(cl, "%p %llx.%llx cap_snap %p snapc %p %llu %s s=%llu\n",
 	      inode, ceph_vinop(inode), capsnap, capsnap->context,
 	      capsnap->context->seq, ceph_cap_string(capsnap->dirty),
fs/ceph/super.h +33 -31

83 lines not on this page · raw message

fs/ceph/xattr.c +1 -1
index caf0fe4d2b1b7..7e8b1b2bda743 100644
@@ -1056,7 +1056,7 @@ ssize_t __ceph_getxattr(struct inode *inode, const char *name, void *value,
 	if (current->journal_info &&
 	    !strncmp(name, XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) &&
 	    security_ismaclabel(name + XATTR_SECURITY_PREFIX_LEN))
-		ci->i_ceph_flags |= CEPH_I_SEC_INITED;
+		set_bit(CEPH_I_SEC_INITED_BIT, &ci->i_ceph_flags);
 out:
 	spin_unlock(&ci->i_ceph_lock);
 	return err;
Signature · 1 line
2.53.0
author maintainer
#743 lore raw

PATCH 1/1 watchdog: lenovo_se10_wdt: Fix use-after-free and resource leak risk

In reply to Sasha Levin

From: Mark Pearson <[email protected]>

[ Upstream commit 3394e894880a60338a2981dd688fd25e88d79667 ]

Review by sashiko.dev highlighted potential use after free and resource leak instances.

Set se10_pdev to null to prevent use after free

Remove DMI call back and instead directly call se10_create_platform_device. Handle error cases appropriately

---

LLM Generated explanations, may be completely bogus:

The history search finished. In this 6.18.43 checkout, git log -S 'lenovo-se10-wdt' shows the driver file first appearing at 5d324e5159d9e (Nov 2025 USB merge). That matches what we already saw in blame.

The driver itself was added upstream in 6.10 (`watchdog:
lenovo_se10_wdt: Watchdog driver for Lenovo SE10 platform`); the buggy DMI-callback init pattern has been there since then. Nothing in this changes the earlier **YES** backport recommendation.

 drivers/watchdog/lenovo_se10_wdt.c | 32 ++++++++++++++----------------
 1 file changed, 15 insertions(+), 17 deletions(-)
drivers/watchdog/lenovo_se10_wdt.c +15 -17
index 99ff01af41243..503e220263f95 100644
@@ -224,7 +224,7 @@ static struct platform_driver se10_wdt_driver = {
 	.probe  = se10_wdt_probe,
 };
 
-static int se10_create_platform_device(const struct dmi_system_id *id)
+static int se10_create_platform_device(void)
 {
 	int err;
 
@@ -233,9 +233,10 @@ static int se10_create_platform_device(const struct dmi_system_id *id)
 		return -ENOMEM;
 
 	err = platform_device_add(se10_pdev);
-	if (err)
+	if (err) {
 		platform_device_put(se10_pdev);
-
+		se10_pdev = NULL;
+	}
 	return err;
 }
 
@@ -246,7 +247,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 			DMI_MATCH(DMI_PRODUCT_NAME, "12NH"),
 		},
-		.callback = se10_create_platform_device,
 	},
 	{
 		.ident = "LENOVO-SE10",
@@ -254,7 +254,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 			DMI_MATCH(DMI_PRODUCT_NAME, "12NJ"),
 		},
-		.callback = se10_create_platform_device,
 	},
 	{
 		.ident = "LENOVO-SE10",
@@ -262,7 +261,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 			DMI_MATCH(DMI_PRODUCT_NAME, "12NK"),
 		},
-		.callback = se10_create_platform_device,
 	},
 	{
 		.ident = "LENOVO-SE10",
@@ -270,7 +268,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 			DMI_MATCH(DMI_PRODUCT_NAME, "12NL"),
 		},
-		.callback = se10_create_platform_device,
 	},
 	{
 		.ident = "LENOVO-SE10",
@@ -278,7 +275,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 			DMI_MATCH(DMI_PRODUCT_NAME, "12NM"),
 		},
-		.callback = se10_create_platform_device,
 	},
 	{
 		.ident = "LENOVO-SE10-G2",
@@ -286,7 +282,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 			DMI_MATCH(DMI_PRODUCT_NAME, "13LJ"),
 		},
-		.callback = se10_create_platform_device,
 	},
 	{
 		.ident = "LENOVO-SE10-G2",
@@ -294,7 +289,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 			DMI_MATCH(DMI_PRODUCT_NAME, "13LK"),
 		},
-		.callback = se10_create_platform_device,
 	},
 	{
 		.ident = "LENOVO-SE10-G2",
@@ -302,7 +296,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 			DMI_MATCH(DMI_PRODUCT_NAME, "13S1"),
 		},
-		.callback = se10_create_platform_device,
 	},
 	{
 		.ident = "LENOVO-SE10-G2",
@@ -310,7 +303,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 			DMI_MATCH(DMI_PRODUCT_NAME, "13S2"),
 		},
-		.callback = se10_create_platform_device,
 	},
 	{
 		.ident = "LENOVO-SE10-G2",
@@ -318,7 +310,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 			DMI_MATCH(DMI_PRODUCT_NAME, "13S3"),
 		},
-		.callback = se10_create_platform_device,
 	},
 	{
 		.ident = "LENOVO-SE10-G2",
@@ -326,7 +317,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 			DMI_MATCH(DMI_PRODUCT_NAME, "13S4"),
 		},
-		.callback = se10_create_platform_device,
 	},
 	{
 		.ident = "LENOVO-SE10-G2",
@@ -334,7 +324,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 			DMI_MATCH(DMI_PRODUCT_NAME, "13S5"),
 		},
-		.callback = se10_create_platform_device,
 	},
 	{
 		.ident = "LENOVO-SE10-G2",
@@ -342,7 +331,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 			DMI_MATCH(DMI_PRODUCT_NAME, "13S6"),
 		},
-		.callback = se10_create_platform_device,
 	},
 	{}
 };
@@ -350,10 +338,20 @@ MODULE_DEVICE_TABLE(dmi, se10_dmi_table);
 
 static int __init se10_wdt_init(void)
 {
+	int err;
+
 	if (!dmi_check_system(se10_dmi_table))
 		return -ENODEV;
 
-	return platform_driver_register(&se10_wdt_driver);
+	err = platform_driver_register(&se10_wdt_driver);
+	if (err)
+		return err;
+
+	err = se10_create_platform_device();
+	if (err)
+		platform_driver_unregister(&se10_wdt_driver);
+
+	return err;
 }
 
 static void __exit se10_wdt_exit(void)
Signature · 1 line
2.53.0