Skip to contentSkip to conversation

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

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

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

PATCH 1/1 ksmbd: protect private extended attributes

In reply to Sasha Levin

From: Namjae Jeon <[email protected]>

[ Upstream commit 4ea46ea602fc7055eee4b5b0e84f90f22da7f7e7 ]

SMB clients can currently create an EA named NTACL because SMB EAs are mapped into the user namespace while the ksmbd security descriptor is stored as security.NTACL. Allowing the reserved logical name makes the server-private ACL metadata appear writable through the SMB EA API.

Reject NTACL, DOSATTRIB, and DosStream-prefixed EA names without regard to case. Filter the same private names from EA query results so stale or externally-created user namespace attributes cannot be exposed.

This fixes smb2.ea.acl_xattr when acl_xattr_name is configured as NTACL.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit message forensics

**Step 1.1 — Subject**
- Record: [ksmbd] [protect] keep server-private xattr names off the SMB EA API

**Step 1.2 — Tags**
- Record: Signed-off-by: Namjae Jeon <[email protected]> (ksmbd maintainer; author and committer).
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, Link:, or Cc: stable. Absence of Fixes:/Cc: stable is expected for this review and is not a negative signal.

**Step 1.3 — Body**
- Record: SMB EAs are stored as user.* xattrs. ksmbd keeps NT ACL metadata in security.NTACL. Clients can still create an EA named NTACL, so the reserved logical name looks writable over SMB SET_INFO/QUERY_INFO EA. The patch rejects NTACL, DOSATTRIB, and DosStream.-prefixed names case-insensitively on set, and filters the same names from query results so leftover user.* copies are not exposed. Failure mode: reserved metadata can be written or listed through the EA API. Symptom: Samba smbtorture smb2.ea.acl_xattr fails when acl_xattr_name=NTACL. Introduced with original ksmbd EA mapping; not a new 7.x-only bug.

**Step 1.4 — Hidden bug fix?**
- Record: Yes. “Protect” is a security/integrity fix, not cleanup. SET currently does not reject reserved names. GET already skipped DosStream. / DOSATTRIB with case-sensitive strncmp, but not NTACL and not case variants.

## Phase 2: Diff analysis

**Step 2.1 — Inventory**
- Record: fs/smb/server/smb2pdu.c only (+22/-6). Functions: new smb2_is_private_ea(); smb2_set_ea(); smb2_get_ea().
Classification: single-file surgical fix.

**Step 2.2 — Flow**
- Record:
- SET: after the EA name-length check, reserved names return -EACCES instead of ksmbd_vfs_setxattr/remove_xattr on user.<name>.
- GET: STREAM and DOSATTRIB strncmp skips become one smb2_is_private_ea() skip (adds NTACL, case-insensitive). Specific-name QUERY still cannot return those names.

**Step 2.3 — Bug mechanism**
- Record: Logic/correctness plus a hardware/protocol reserved-name filter (category g/h). Same-namespace collisions: user.DOSATTRIB (DOS flags/create time) and user.DosStream.* (named streams). security.NTACL is a different namespace, so SET of EA NTACL creates user.NTACL rather than overwriting the SD; the patch still blocks that reserved name and hides any leftover user.NTACL.

**Step 2.4 — Fix quality**
- Record: Obviously correct. strncasecmp + exact length for NTACL/DOSATTRIB, prefix match for streams. -EACCES maps to STATUS_ACCESS_DENIED in both smb2_set_info() and CREATE error mapping, matching smbtorture. Regression risk is low: only reserved Samba/ksmbd names are rejected. Query of a private name still yields STATUS_NO_EAS_ON_FILE rather than ACCESS_DENIED; that is pre- existing GET skip behavior, not a new crash path.

## Phase 3: Git history

**Step 3.1 — Blame**
- Record: Unfiltered SET and GET STREAM/DOSATTRIB skips come from e2f34481b24db (“cifsd: add server-side procedures for SMB3”, 2021-03-16). Present since ksmbd entered the kernel (5.15 era). git merge-base --is-ancestor e2f34481b24db HEAD succeeds.

**Step 3.2 — Fixes tag**
- Record: None. Buggy behavior is the original EA mapping, not a later regression.

**Step 3.3 — File history**
- Record: Recent 6.12 ksmbd work is unrelated (buffer sizes, leases, durable reconnect). No competing private-EA helper in this tree.

**Step 3.4 — Author**
- Record: Namjae Jeon is the ksmbd maintainer. Surrounding 7.3 ksmbd commits are other protocol/security fixes; this commit is standalone (4ea46ea602fc).

**Step 3.5 — Dependencies**
- Record: Needs SD_PREFIX, DOS_ATTRIBUTE_PREFIX, STREAM_PREFIX from fs/smb/server/xattr.h (included via vfs.h in smb2pdu.c). All exist here. strncasecmp is in include/linux/string.h. Applies standalone.

## Phase 4: Mailing list / external

**Step 4.1**
- Record: SHA 4ea46ea602fc7055eee4b5b0e84f90f22da7f7e7 (v7.3-rc1). b4 dig -c 4ea46ea602fc failed: lore.kernel.org returned errors (Anubis bot challenge). WebFetch to lore also 403. UNVERIFIED: original thread text, NAKs, reviewer Cc:stable.

**Step 4.2**
- Record: UNVERIFIED recipients. Commit is authored and committed by the subsystem maintainer; Linus merged it in ksmbd-for-7.3-rc1 (61a09cfc12147), described as smbtorture-validated protocol fixes and security hardening.

**Step 4.3**
- Record: Samba source4/torture/smb2/ea.c torture_smb2_acl_xattr (smb2.ea.acl_xattr) requires acl_xattr_name, checks the name is not listed, and expects SET to fail with NT_STATUS_ACCESS_DENIED. Confirmed from samba-team/samba master.

**Step 4.4**
- Record: Standalone. No later revert or follow-up on smb2_is_private_ea through v7.3-rc1 (git grep still shows the helper at three sites).

**Step 4.5**
- Record: UNVERIFIED on lore.kernel.org/stable (lore blocked). No in- tree revert.

## Phase 5: Code semantics

**Step 5.1**
- Record: smb2_is_private_ea, smb2_set_ea, smb2_get_ea.

**Step 5.2**
- Record: smb2_set_ea callers: CREATE EA context (smb2_open path ~3322) and FILE_FULL_EA_INFORMATION in smb2_set_info_file (~6644). smb2_get_ea caller: smb2_get_info_file (~5493). Reachable from SMB2 CREATE / SET_INFO / QUERY_INFO.

**Step 5.3**
- Record: SET uses ksmbd_vfs_setxattr / ksmbd_vfs_remove_xattr after prefixing XATTR_USER_PREFIX. GET uses ksmbd_vfs_listxattr / ksmbd_vfs_getxattr. Internal DOS/stream/SD writers (ksmbd_vfs_set_dos_attrib_xattr, stream helpers, ksmbd_vfs_set_sd_xattr) do not go through smb2_set_ea, so server- internal writes remain allowed.

**Step 5.4**
- Record: Yes, from userspace: authenticated SMB client with FILE_WRITE_EA / FILE_READ_EA. Those rights are normally part of generic write/read.

**Step 5.5**
- Record: GET already special-cased STREAM and DOSATTRIB; SET did not. Same reserved names as Samba (user.DOSATTRIB, user.DosStream.*, security.NTACL).

## Phase 6: This tree (6.12.111)

**Step 6.1**
- Record: Local tree is pending-6.12, git describe p-6.12-3-gc504cf0baa3d8, make kernelversion **6.12.111**. Candidate is **not** an ancestor of HEAD. Buggy SET/GET code is present (smb2_set_ea at 2392, smb2_get_ea at 4758). smb2_is_private_ea is absent.

**Step 6.2**
- Record: git apply --check of 4ea46ea602fc succeeded (hunks at 2379, 2436, 4852; offsets only). Clean apply.

**Step 6.3**
- Record: No alternate fix. GET still uses case-sensitive STREAM/DOSATTRIB skips and does not filter NTACL.

## Phase 7: Subsystem

**Step 7.1**
- Record: fs/smb/server (ksmbd). Criticality: IMPORTANT — network file server, optional (CONFIG_SMB_SERVER default n), but a common stable attack/integrity surface.

**Step 7.2**
- Record: Actively maintained. This bug is old (original EA code), not a 7.3-only feature.

## Phase 8: Impact and risk

**Step 8.1**
- Record: ksmbd users only (NAS, appliances, distro ksmbd). Not universal.

**Step 8.2**
- Record: Trigger: SMB2 SET_INFO FULL_EA or CREATE with EA context using reserved names. Common for any client that can write EAs. Unprivileged local processes cannot hit it unless they are SMB clients; an authenticated SMB user can.

**Step 8.3**
- Record: Failure mode: overwrite user.DOSATTRIB (hidden/system/create time) and user.DosStream.* (stream data); expose or plant user.NTACL. Severity: **HIGH** (metadata/stream integrity and reserved-name ACL confusion). Not a kernel oops. Default ksmbd ACL store is security.NTACL, so SET EA NTACL does not overwrite the SD; DOSATTRIB/streams are the real same-namespace collisions.

**Step 8.4**
- Record: Benefit high for ksmbd hosts. Risk very low (~20-line filter, no locking/API change). Ratio favors backport.

## Phase 9: Synthesis

**Step 9.1 — Evidence**

FOR:
- Real reserved-name hole on a network server: SET can write user.DOSATTRIB and user.DosStream.*.
- GET can leak user.NTACL if that xattr exists.
- Matches Samba’s long-standing hide/reject of those names; smbtorture smb2.ea.acl_xattr expects ACCESS_DENIED.
- Small, maintainer-authored, in v7.3-rc1 with no revert.
- Applies cleanly to this 6.12 tree; macros and callers exist.
- -EACCES already maps to STATUS_ACCESS_DENIED.

AGAINST:
- Not a crash/UAF.
- NTACL SD lives in security.*, so this is not a direct ACL overwrite on default ksmbd.
- Commit message is partly a test fix.
- Lore review UNVERIFIED.

UNRESOLVED:
- Original lore thread / reviewer stable nomination (lore blocked).

**Step 9.2 — Stable rules**
1. Obviously correct and tested? **PASS** (applies cleanly; smbtorture named; maintainer).
2. Real user-visible bug? **PASS** (EA write/list of private metadata).
3. Important (crash/security/corruption/deadlock)? **PASS** (HIGH:
metadata/stream integrity on an SMB server; security-boundary).
4. Small and contained? **PASS** (+22/-6, one file).
5. No new features/APIs? **PASS** (reject/filter only).
6. Applies to this tree? **PASS** (git apply --check succeeded).

**Step 9.3 — Exceptions**
- Record: Not a device-ID/quirk/DT/build/docs exception. Qualifies as a normal security/integrity bug fix.

**Step 9.4 — Decision**
Backport to this 6.12 tree. The important part is not the Samba test name; it is that authenticated clients can currently smash DOS attribute and named-stream xattrs that ksmbd treats as private.

---

### What this solves for 6.12 users

ksmbd maps SMB EAs to user.*. It stores DOS attributes in user.DOSATTRIB and streams in user.DosStream.*. smb2_set_ea() does not reject those names, so a client with FILE_WRITE_EA can overwrite that metadata. Query already hid some of those names, but not NTACL and not case variants. The patch closes SET and GET.

### Stable-rules / risk

Meets all six criteria. Benefit is integrity of ksmbd private xattrs; risk is a tight ACCESS_DENIED on reserved names that Samba has treated as private for years.

### Verification
- [Phase 1] Parsed message/tags on 4ea46ea602fc; only author SOB; no Fixes/Link.
- [Phase 2] Full git show 4ea46ea602fc diff: helper + SET -EACCES + GET filter.
- [Phase 2] Confirmed -EACCES → STATUS_ACCESS_DENIED at smb2_set_info err_out (~6761) and CREATE err_out (~3812).
- [Phase 2] Confirmed XATTR_NAME_DOS_ATTRIBUTE = user.+DOSATTRIB, XATTR_NAME_STREAM = user.+DosStream., XATTR_NAME_SD = security.+NTACL in xattr.h.
- [Phase 3] git blame SET/GET: e2f34481b24db (2021); ancestor of HEAD.
- [Phase 3] git merge-base --is-ancestor 4ea46ea602fc HEAD → no (not in 6.12).
- [Phase 4] b4 dig -c 4ea46ea602fc → lore error. UNVERIFIED mailing- list discussion.
- [Phase 4] Samba torture_smb2_acl_xattr expects SET ACCESS_DENIED and no list leak.
- [Phase 4] Merge 61a09cfc12147 mentions smbtorture protocol fixes / security hardening.
- [Phase 4] smb2_is_private_ea still in v7.3-rc1; no revert.
- [Phase 5] Callers: CREATE EA context, SET_INFO FULL_EA, QUERY_INFO EA.
- [Phase 6] git describe HEAD = p-6.12-3-gc504cf0baa3d8; kernelversion 6.12.111.
- [Phase 6] git apply --check of the commit succeeded with line offsets only.
- [Phase 8] Same-namespace overwrite of DOSATTRIB/streams verified in vfs.c / smb2_update_xattrs.
- UNVERIFIED: lore reviewers, CVE assignment, whether any distro already carries a different backport.

**YES**

 fs/smb/server/smb2pdu.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)
fs/smb/server/smb2pdu.c +22 -6
index e73edf006df72..4f8e2a6307602 100644
@@ -2378,6 +2378,22 @@ static noinline int create_smb2_pipe(struct ksmbd_work *work)
 	return err;
 }
 
+static bool smb2_is_private_ea(const char *name, size_t name_len)
+{
+	if (name_len == SD_PREFIX_LEN &&
+	    !strncasecmp(name, SD_PREFIX, SD_PREFIX_LEN))
+		return true;
+	if (name_len == DOS_ATTRIBUTE_PREFIX_LEN &&
+	    !strncasecmp(name, DOS_ATTRIBUTE_PREFIX,
+			   DOS_ATTRIBUTE_PREFIX_LEN))
+		return true;
+	if (name_len >= STREAM_PREFIX_LEN &&
+	    !strncasecmp(name, STREAM_PREFIX, STREAM_PREFIX_LEN))
+		return true;
+
+	return false;
+}
+
 /**
  * smb2_set_ea() - handler for setting extended attributes using set
  *		info command
@@ -2419,6 +2435,10 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
 			rc = -EINVAL;
 			break;
 		}
+		if (smb2_is_private_ea(eabuf->name, eabuf->EaNameLength)) {
+			rc = -EACCES;
+			break;
+		}
 
 		memcpy(attr_name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN);
 		memcpy(&attr_name[XATTR_USER_PREFIX_LEN], eabuf->name,
@@ -4828,17 +4848,13 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,
 		if (strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN))
 			continue;
 
-		if (!strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX,
-			     STREAM_PREFIX_LEN))
-			continue;
-
 		if (req->InputBufferLength &&
 		    strncmp(&name[XATTR_USER_PREFIX_LEN], ea_req->name,
 			    ea_req->EaNameLength))
 			continue;
 
-		if (!strncmp(&name[XATTR_USER_PREFIX_LEN],
-			     DOS_ATTRIBUTE_PREFIX, DOS_ATTRIBUTE_PREFIX_LEN))
+		if (smb2_is_private_ea(&name[XATTR_USER_PREFIX_LEN],
+				       name_len - XATTR_USER_PREFIX_LEN))
 			continue;
 
 		if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN))
Signature · 1 line
2.53.0
author maintainer
#255 lore raw

PATCH 1/1 pmdomain: qcom: rpmhpd: Skip retention by default

In reply to Sasha Levin

From: Mike Tipton <[email protected]>

[ Upstream commit 7178817f190496f2bfdec181fb4aa72832448468 ]

Retention is very rarely an operational corner. In the majority of cases, HW cannot operate properly at Retention levels and so the minimum operational level when enabling a rail is the first corner above Retention. A small subset of always-on use cases can operate at Retention, but those aren't controlled from HLOS.

Currently, we allow Retention by default and only disallow it special cases. But this leaves us open to various failures when the PD is enabled without first being voted to an OPP above Retention. Such as when a child GDSC PD requests to enable its parent RPMh PD. In this case, the GDSC would get stuck powering on.

Newer chips have started supporting Retention on rails that didn't previously (such as for MMCX). Instead of adding more special cases to skip Retention on MMCX, start skipping Retention by default since it's almost never desired from an HLOS perspective.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit message forensics

**Step 1.1: Subject line**
- Record: [pmdomain/qcom/rpmhpd] [Skip] Skip Retention voltage as the default enable corner

**Step 1.2: Tags**
- Record:
- Signed-off-by: Mike Tipton <[email protected]> (author, Qualcomm)
- Reviewed-by: Konrad Dybcio <[email protected]> (Qualcomm SoC reviewer)
- Signed-off-by: Ulf Hansson <[email protected]> (GENERIC PM DOMAINS maintainer)
- No Fixes: tag (expected)
- No Cc: stable (expected)
- No Reported-by, Tested-by, Link, or syzbot tags
- Notable: Qualcomm author + Qualcomm reviewer + subsystem maintainer SOB. No user/syzbot report.

**Step 1.3: Body**
- Record:
- **Bug:** HLOS enable of an RPMh PD without an OPP above Retention can vote Retention. Most hardware cannot run at Retention.
- **Symptom:** Child GDSC enable of a parent RPMh PD leaves the GDSC stuck powering on (hardware hang, not a kernel oops).
- **Root cause:** Retention is allowed by default; only MXC opted out via skip_retention_level. Newer chips now expose Retention on rails that previously did not (e.g. MMCX).
- **Fix approach:** Skip Retention for every rail when building the cmd-db mapping, instead of adding more per-rail flags.
- **Version info:** None in the message. “Newer chips” / MMCX is the motivation.

**Step 1.4: Hidden bug fix?**
- Record: Not hidden. It is a real hardware-failure fix described as a default-policy change. Skipping Retention is the workaround, not a cleanup.

## Phase 2: Diff analysis

**Step 2.1: Inventory**
- Record:
- File: drivers/pmdomain/qcom/rpmhpd.c (+9 / −5)
- Functions/data: struct rpmhpd (drop skip_retention_level), mxc / mxc_ao initializers, rpmhpd_update_level_mapping()
- Scope: single-file surgical change

**Step 2.2: Code flow**
- Record:
- **Before:** rpmhpd_update_level_mapping() copied cmd-db aux levels into rpmhpd->level[]. Retention (vlvl 16) was skipped only if skip_retention_level was set. That flag was true only on mxc / mxc_ao. enable_corner became the first non-zero mapped corner, which could be Retention.
- **rpmhpd_power_on():** `corner = max(pd->corner,

    pd->enable_corner)` then aggregate. Enable without an OPP uses
    `enable_corner`.

- **After:** Retention is always skipped. enable_corner is the first corner above Retention. MXC’s flag is redundant and removed.
- Path affected: probe-time mapping, then every power-on that does not already have a higher OPP (including parent enable from a child GDSC).

**Step 2.3: Bug mechanism**
- Record: **Hardware workaround / logic fix.** Retention as min enable corner is not a valid operational vote for HLOS. Child GDSC parent-on uses that corner and the GDSC never completes power-on.
- Verified path: gdsc_register() attaches GDSCs as genpd subdomains of the clock-controller’s dev->pm_domain (drivers/clk/qcom/gdsc.c). genpd_power_on() walks parents and calls rpmhpd_power_on() with no performance state. DT has many power-domains = <&rpmhpd RPMHPD_MMCX> nodes (sm8450/sm8550/sm8650/sm8750 and others).

**Step 2.4: Fix quality**
- Record: Obviously correct given the existing skip logic. Minimal. If cmd-db has no Retention entry, the new if never matches (no-op on older rails). Regression risk is a slightly higher min vote (Retention 16 → typically MIN_SVS 48) on rails that advertised Retention; the author states HLOS must not use Retention. No API/ABI change.

## Phase 3: Git history

**Step 3.1: Blame**
- Record:
- Mapping loop: 279b7e8a62cc (“soc: qcom: rpmhpd: Add RPMh power

    domain driver”, 2019)
  - `enable_corner`: `e3e56c050ab6` (“soc: qcom: rpmhpd: Make power_on
    actually enable the domain”, 2021) — this is what makes Retention
    reachable as the enable vote
  - Opt-in skip: `ddab91f4b2de5` (“Skip retention level for Power
    Domains”, 2024), MXC only, `Cc: [email protected] # v5.17`

- This change: 7178817f19049 (2026-07-13)

**Step 3.2: Fixes tag**
- Record: None. Closest predecessor is ddab91f4b2de5 (MXC-only skip). Both ddab91f4b2de5 and e3e56c050ab6 are ancestors of this HEAD.

**Step 3.3: File history**
- Record: Recent work is mostly new SoC tables. No later revert of default-skip. Eliza MXC/MMCX add was reverted for unrelated reasons (9fca7779ad185). Standalone v1 patch, not part of a numbered series.

**Step 3.4: Author**
- Record: Mike Tipton (Qualcomm); this is his only recent commit on drivers/pmdomain/qcom/. Konrad reviews rpmhpd regularly. Ulf is the pmdomain maintainer.

**Step 3.5: Dependencies**
- Record: Needs enable_corner + Retention skip continue in rpmhpd_update_level_mapping(). Both exist here. Applies standalone on a tree that still has skip_retention_level. No other patches required.

## Phase 4: Mailing list / external

**Step 4.1: Original discussion**
- Record: b4 dig -c 7178817f19049 →
https://patch.msgid.link/20260629-rpmhpd-skip-
[email protected]
- Series: **v1 only** (no v2/v3).
- Thread (mbox): Ulf Hansson: “Applied for next, thanks!” No NAKs, no stable nomination, no reviewer risk flags.

**Step 4.2: Recipients (b4 dig -w)**
- Record: Ulf Hansson, linux-arm-msm, linux-pm, linux-kernel, Bjorn Andersson, Konrad Dybcio, Taniya Das (author of the MXC skip), Fenglin Wu. Right lists and people.

**Step 4.3: Bug report**
- Record: No public user/syzbot/bugzilla report. Failure mode is described by the Qualcomm author from platform bring-up.

**Step 4.4: Related series**
- Record: Standalone. Extends ddab91f4b2de5 rather than depending on a multi-patch series.

**Step 4.5: Stable list**
- Record: lore.kernel.org/stable fetch returned 403. UNVERIFIED whether stable@ discussed this subject. The 2024 MXC skip *was* Cc:stable.

## Phase 5: Semantic / call graph

**Step 5.1: Functions**
- Record: rpmhpd_update_level_mapping() (changed), rpmhpd_power_on() / rpmhpd_set_performance_state() (consumers of enable_corner, unchanged).

**Step 5.2: Callers**
- Record: rpmhpd_update_level_mapping() ← rpmhpd_probe() only. rpmhpd_power_on() is generic_pm_domain.power_on, called from genpd (including parent-on for child GDSCs). Probe + device/runtime PM, not a syscall-only path.

**Step 5.3: Callees**
- Record: cmd_db_read_aux_data(), then later rpmhpd_aggregate_corner() → rpmhpd_send_corner() (RPMh votes).

**Step 5.4: Reachability**
- Record: Yes, from normal Qualcomm device probe. Clock-controller GDSCs are subdomains of rpmhpd (often MMCX). Userspace does not need a special trigger; enabling display/video/camera clocks is enough.

**Step 5.5: Similar patterns**
- Record: Only MXC used skip_retention_level. MMCX/mmcx_w_cx_parent did not. That matches “instead of adding more special cases for MMCX.”

## Phase 6: This tree only

**Step 6.1: Does the buggy code exist here?**
- Record:
- Local tree: **Linux 7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37, Makefile VERSION=7 PATCHLEVEL=3).
- drivers/pmdomain/qcom/rpmhpd.c is present. Pre-commit code had skip_retention_level only on MXC.
- 7178817f19049 is already an ancestor of HEAD (in v7.3-rc1; **not** in v7.2). Current file already skips Retention unconditionally.
- Bug class (Retention as enable_corner) dates to e3e56c050ab6 (2021) whenever cmd-db lists Retention; MMCX Retention on newer chips is why this default change was made. That hardware **is** represented in this 7.3 tree.

**Step 6.2: Backport difficulty**
- Record: Against current HEAD the patch is already applied (forward apply would fail). Against 7.3 immediately before this commit it is a clean apply (same file layout, skip_retention_level present). No extra backport rework for this tree’s rpmhpd.c.

**Step 6.3: Related fixes already here**
- Record: MXC-only skip (ddab91f4b2de5) is here; it does **not** cover MMCX/CX/etc. 2a93c6cbd5a70 (enabled_corner aggregation) is a different bug (peer off during sync_state). No substitute for this commit.

## Phase 7: Subsystem context

**Step 7.1**
- Record: drivers/pmdomain/qcom/ — Qualcomm RPMh power domains. **IMPORTANT** (not core mm/fs, but used on a large set of Snapdragon phones, laptops, and embedded boards). Maintainer: Ulf Hansson (GENERIC PM DOMAINS).

**Step 7.2**
- Record: Active (new SoC tables: Nord, Hawi, Eliza, Kaanapali, Glymur, etc.). The Retention default is independent of those tables.

## Phase 8: Impact and risk

**Step 8.1: Who is affected**
- Record: Qualcomm rpmhpd platforms (CONFIG_QCOM_RPMHPD), especially SoCs whose cmd-db advertises Retention on MMCX or other non-MXC rails. Not universal; not staging.

**Step 8.2: Trigger**
- Record: Common: child GDSC on, parent rpmhpd has no OPP. Happens at probe/runtime PM. Unprivileged userspace can cause it indirectly by using multimedia devices; it also happens at boot when those controllers probe.

**Step 8.3: Failure mode**
- Record: GDSC stuck powering on → device/controller hang, probe failure, missing display/video/camera (or boot issues if that path is on the critical path). Severity: **HIGH** (hardware hang), not a KASAN/UAF class crash.

**Step 8.4: Risk-benefit**
- Record:
- **Benefit:** Prevents GDSC/parent-rail hangs on Qualcomm platforms in this tree, including MMCX without extending a per-rail flag list.
- **Risk:** Low. 14-line change; no-op if Retention is absent from cmd-db; MXC behavior unchanged; Qualcomm + maintainer reviewed.
- **Ratio:** Benefit > risk.

## Phase 9: Synthesis

**Step 9.1: Evidence**

For:
- Concrete hang: parent RPMh PD at Retention → child GDSC stuck on.
- Call path and DT consumers verified in this tree.
- Small, obviously correct extension of an existing skip that was already Cc:stable for MXC.
- Safe no-op when Retention is not in cmd-db.
- Reviewed by Konrad, applied by Ulf; Taniya Das (original skip author) was on Cc.
- This 7.3 tree has rpmhpd, enable_corner, skip_retention_level, and MMCX users.

Against:
- No Fixes: / public reproducer / syzbot (not a negative per rules).
- Default change for all rails, not only MMCX (mitigated: Retention skip is a no-op where unused).
- lore.kernel.org/stable search could not be fetched (403).

**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** — v1 accepted, maintainer applied, Qualcomm review.
2. Real user-visible bug? **PASS** — GDSC stuck on parent enable.
3. Important (hang/corruption/security)? **PASS** — hardware hang on a widely used SoC family; HIGH, not a panic.
4. Small and contained? **PASS** — +9/−5, one file.
5. No new features/APIs? **PASS** — same skip, defaulted; no userspace API.
6. Can apply to this tree? **PASS** — 7.3 has the pre-image; the commit is in 7.3-rc1.

**Step 9.3: Exception category**
- Record: Hardware workaround (skip a non-operational corner), same class as the 2024 MXC Retention skip.

**Step 9.4: Decision**
This tree is 7.3.0-rc4. The rpmhpd driver, the Retention- as-enable_corner bug, and MMCX parent-GDSC consumers are all here. The change is a small, correct hang fix, not a feature. It should be in this tree.

---

### What it solves for users of this tree

Without it, enabling a Qualcomm GDSC whose parent RPMh rail (often MMCX) has no OPP votes Retention. That rail cannot actually run there, so the GDSC never finishes power-on. Display, video, camera, and similar controllers that list power-domains = <&rpmhpd RPMHPD_MMCX> hit this on probe or runtime PM. Skipping Retention when building the cmd-db map makes the min enable corner the first real operational level.

### Risk vs benefit

Benefit is avoiding a platform hang on common Qualcomm PM paths. Risk is
low: SoCs without Retention in cmd-db are unchanged; MXC already skipped Retention; HLOS is not supposed to use Retention.

### Concerns

No public reproducer. Stable-list discussion unverified (HTTP 403). Slightly higher min vote on rails that listed Retention is intended, not a silent functional change for rails that never had it.

### Verification
- [Phase 1] Parsed tags: author/reviewer/maintainer SOBs only; no Fixes/stable/syzbot
- [Phase 2] Diff: +9/−5 in rpmhpd.c; drop skip_retention_level; always skip RPMH_REGULATOR_LEVEL_RETENTION (16)
- [Phase 2] rpmhpd_power_on() uses max(pd->corner, pd->enable_corner) — verified in file
- [Phase 2] GDSC subdomain attach in gdsc_register() — verified
- [Phase 2] DT MMCX consumers in sm8450/sm8550/sm8650/sm8750 dtsi — verified
- [Phase 3] git describe HEAD / make kernelversion: v7.3-rc4 / 7.3.0-rc4
- [Phase 3] git merge-base --is-ancestor 7178817f19049 HEAD: yes; not in v7.2; in v7.3-rc1
- [Phase 3] Blame: mapping 279b7e8a62cc (2019); enable_corner e3e56c050ab6 (2021); MXC skip ddab91f4b2de5 (2024)
- [Phase 3] Pre-image: skip_retention_level only on mxc/mxc_ao; mmcx had no flag
- [Phase 4] b4 dig -c 7178817f19049: lore/msgid 20260629-rpmhpd-skip- [email protected]
- [Phase 4] b4 dig -a: v1 only; Ulf “Applied for next”; no NAK
- [Phase 4] b4 dig -w: Ulf, Bjorn, Konrad, Taniya Das, linux-arm-msm, linux-pm
- [Phase 4] UNVERIFIED: lore.kernel.org/stable (403)
- [Phase 5] rpmhpd_update_level_mapping() called only from rpmhpd_probe
- [Phase 6] Post-fix code already in this checkout; related MXC skip present and insufficient
- [Phase 8] Failure mode: GDSC stuck on — HIGH hang, Qualcomm-specific

**YES**

 drivers/pmdomain/qcom/rpmhpd.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/pmdomain/qcom/rpmhpd.c +9 -5
index 4c3cbf3abc750..fc61ec45755c3 100644
@@ -41,7 +41,6 @@
  * @addr:		Resource address as looped up using resource name from
  *			cmd-db
  * @state_synced:	Indicator that sync_state has been invoked for the rpmhpd resource
- * @skip_retention_level: Indicate that retention level should not be used for the power domain
  */
 struct rpmhpd {
 	struct device	*dev;
@@ -58,7 +57,6 @@ struct rpmhpd {
 	const char	*res_name;
 	u32		addr;
 	bool		state_synced;
-	bool            skip_retention_level;
 };
 
 struct rpmhpd_desc {
@@ -176,7 +174,6 @@ static struct rpmhpd mxc = {
 	.pd = { .name = "mxc", },
 	.peer = &mxc_ao,
 	.res_name = "mxc.lvl",
-	.skip_retention_level = true,
 };
 
 static struct rpmhpd mxc_ao = {
@@ -184,7 +181,6 @@ static struct rpmhpd mxc_ao = {
 	.active_only = true,
 	.peer = &mxc,
 	.res_name = "mxc.lvl",
-	.skip_retention_level = true,
 };
 
 static struct rpmhpd nsp = {
@@ -974,7 +970,15 @@ static int rpmhpd_update_level_mapping(struct rpmhpd *rpmhpd)
 		return -EINVAL;
 
 	for (i = 0; i < rpmhpd->level_count; i++) {
-		if (rpmhpd->skip_retention_level && buf[i] == RPMH_REGULATOR_LEVEL_RETENTION)
+		/*
+		 * Most HW won't function properly at Retention. The minimum
+		 * operational level is the first level above Retention. The
+		 * small subset of HW that can operate at Retention isn't
+		 * controlled by HLOS. Skip the Retention level to avoid HW
+		 * failures when the PD is enabled without first having an
+		 * explicit OPP level set.
+		 */
+		if (buf[i] == RPMH_REGULATOR_LEVEL_RETENTION)
 			continue;
 
 		rpmhpd->level[i] = buf[i];
Signature · 1 line
2.53.0
author maintainer
#256 lore raw

PATCH 1/1 ALSA: usx2y: Stop clearing urb->hcpriv before submission

In reply to Sasha Levin

From: Michal Pecio <[email protected]>

[ Upstream commit fabae5548149ef5c8a056875d9ebdc38366db539 ]

This is managed by USB core and drivers aren't expected to touch it.

It should only be not NULL on a submitted URB, in which case clearing defeats the "submitted while active" sanity check in usb_submit_urb() and may crash the HCD handling the URB and panic the kernel.

---

LLM Generated explanations, may be completely bogus:

I have the local tree, the live hcpriv path, and the mailing-list record. The rest of this is the nine-phase write-up and the backport verdict for 6.12 only.

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

**Step 1.1: PARSE THE SUBJECT LINE**

Record: **[ALSA/usx2y] [Stop]** Stop clearing urb->hcpriv before usb_submit_urb(). “Stop” here means “stop doing something unsafe,” i.e. a correctness fix, not a feature.

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

Verified from git show fabae5548149ef5c8a056875d9ebdc38366db539:

- Signed-off-by: Michal Pecio <[email protected]> (author)
- `Link: https://patch.msgid.link/20260810075728.483c827e.michal.pecio@g
mail.com`
- Signed-off-by: Takashi Iwai <[email protected]> (ALSA maintainer)

Absent (expected for this pipeline, not a negative signal): Fixes:, Cc: stable, Reported-by, Tested-by, Reviewed-by, Acked-by.

No syzbot, no CVE, no multi-user report.

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

Record:
- **Bug:** Client driver writes urb->hcpriv = NULL immediately before usb_submit_urb(). hcpriv is USB-core/HCD private.
- **Symptom/failure mode:** If the URB is still active (hcpriv != NULL), that store hides it from usb_submit_urb()’s “submitted while active” check. The HCD then treats a live URB as a new submit and **can crash / panic**.
- **Version info in the message:** none. Git places the commit at v7.2-rc5-196-gfabae5548149e (2026-08-10). The assignment itself dates to 1da177e4c3f41 (Linux-2.6.12-rc2).
- **Root cause (author):** drivers must not touch hcpriv; a non-NULL value means “already submitted.”

**Step 1.4: DETECT HIDDEN BUG FIXES**

Record: Not a disguised cleanup. The message names the panic path. The diff is a one-line deletion of an illegal store.

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

**Step 2.1: INVENTORY THE CHANGES**

Record:
- File: sound/usb/usx2y/usbusx2yaudio.c — 1 deletion, 0 additions
- Function: usx2y_urb_submit()
- Scope: single-file, surgical

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

Record: Before, usx2y_urb_submit() set start_frame, **zeroed hcpriv**, set urb->dev, then usb_submit_urb(GFP_ATOMIC). After, the hcpriv store is gone. This is the **normal ISO resubmit path** (completion → usx2y_usbframe_complete() → usx2y_urb_submit()), not an error-only path.

**Step 2.3: IDENTIFY THE BUG MECHANISM**

Record: **[Memory safety / HCD invariant]** urb->hcpriv is documented in include/linux/usb.h as HCD-private. usb_submit_urb() in this tree:

```378:381:drivers/usb/core/urb.c
        if (urb->hcpriv) {
                WARN_ONCE(1, "URB %pK submitted while active\n", urb);
                return -EBUSY;
        }
```

__usb_hcd_giveback_urb() already sets urb->hcpriv = NULL **before** the complete callback, so on a legal resubmit the driver’s store is a no-op. If the URB is still queued, the store defeats -EBUSY/WARN_ONCE. xHCI then does urb->hcpriv = urb_priv in xhci_urb_enqueue() over a live URB (new urb_priv, old still on the ring) → DMA/ring corruption and panic.

**Step 2.4: ASSESS THE FIX QUALITY**

Record: Obviously correct: delete an illegal write. Minimal. Regression risk is very low: giveback already NULL’s hcpriv before complete; first-time submits from usx2y_urbs_start() go through usb_submit_urb() directly with a freshly allocated URB. On a true double-submit, users get -EBUSY and this driver’s existing dev_err + usx2y_clients_stop() instead of an HCD panic.

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

**Step 3.1: BLAME THE CHANGED LINES**

Record: git blame on line 170: urb->hcpriv = NULL introduced in **1da177e4c3f41 (Linux-2.6.12-rc2, 2005)**. Present for the entire life of this driver. Surrounding function was only renamed/style-fixed (Takashi Iwai, 2021).

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

Record: No Fixes: tag. The broken line is original driver code, not a later regression. The USB-core check was added in **2f02bc8af3abb (Alan Stern, 2012)** “USB: report submission of active URBs” (WARN_ONCE + -EBUSY). That commit exists in this tree. This driver has been defeating that check since the check existed.

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

Record: Recent local history on this file includes 86f82bf2b5f99 (validate nrpacks), print API, __counted_by, etc. None of those remove hcpriv. git merge-base --is-ancestor fabae5548149e HEAD → **not an ancestor** (exit 1). Standalone one-line patch, not N/M.

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

Record: Michal Pecio has no prior ALSA usx2y commits in this checkout. On origin/master the only nearby hcpriv work is 25e531b422dc2 (usb: xhci: Make usb_host_endpoint.hcpriv survive endpoint_disable()) — different field (ep->hcpriv), not a prerequisite. Author is a USB/xHCI contributor; ALSA maintainer applied this the same day.

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

Record: None. The function, field, and usb_submit_urb() check all exist here. git show fabae5548149e | git apply --check succeeded. Standalone.

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

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

Record:
- b4 dig -c fabae5548149e → https://patch.msgid.link/20260810075728.48
[email protected]
- b4 dig -a: **v1 only**, 2026-08-10
- Thread (LKML/openwall): standalone [PATCH], no v2. Takashi Iwai:
“Applied to for-next branch. Thanks.” No NAK, no stable discussion, no reviewer risk flags.

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

Record (b4 dig -w): To/Cc Jaroslav Kysela, Takashi Iwai, linux-sound, linux-kernel. **Not** linux-usb. Applied by the ALSA maintainer the same day; no separate Reviewed-by.

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

Record: No Reported-by, no bugzilla/syzbot. Inspection-driven. Severity from the author is kernel panic; no public crash log was found.

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

Record: Not a series. git log origin/master fabae5548149e..origin/master -- sound/usb/usx2y/usbusx2yaudio.c is empty (no follow-up/revert).

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

Record: lore.kernel.org returned 403 via WebFetch. Web search of site:lore.kernel.org/stable usx2y hcpriv found **no** stable-list thread. UNVERIFIED beyond that search: no evidence it was rejected for stable.

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

semcode MCP is not available; callers/callees from grep + reads.

**Step 5.1: IDENTIFY KEY FUNCTIONS**

Record: usx2y_urb_submit() only.

**Step 5.2: TRACE CALLERS**

Record:
- usx2y_usbframe_complete() in the same file: playback URB after usx2y_urb_play_prepare(), capture completed_urb after retire. Called from i_usx2y_urb_complete() (URB complete / giveback).
- usx2yhwdeppcm.c includes usbusx2yaudio.c and calls usx2y_urb_submit() for capture (and second capture) in the hwdep/rawusb path.

Hot path: **every ISO frame** while PCM is running. Userspace trigger:
open/play/record on a Tascam US-122/224/428 (CONFIG_SND_USB_USX2Y).

**Step 5.3: TRACE CALLEES**

Record: usb_submit_urb(urb, GFP_ATOMIC), dev_err on failure. No alloc, no new locks.

**Step 5.4: FOLLOW THE CALL CHAIN**

Record: usb_hcd_giveback_urb → __usb_hcd_giveback_urb (hcpriv = NULL) → i_usx2y_urb_complete → usx2y_usbframe_complete → usx2y_urb_submit → usb_submit_urb. Reachable from normal PCM. On a clean complete, hcpriv is already NULL. Double-submit is the dangerous case (startup state machine STATE_STARTING1/2 can pick urb[0]/urb[1] by index; two URBs per substream, NRURBS == 2).

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**

Record: urb->hcpriv = NULL in sound/ exists **only** in this file. Other hcpriv writes are in HCDs (xhci, ehci, ohci, …), which is correct. This driver is the outlier among ALSA USB.

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

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

Record: **Yes.** Local tree: pending-6.12, git describe p-6.12-3-gc504cf0baa3d8, **make kernelversion = 6.12.111**. Line 170 of sound/usb/usx2y/usbusx2yaudio.c is urb->hcpriv = NULL;. Introduced in 2.6.12-rc2; present for this entire 6.12 line.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**

Record: **Clean apply** (git apply --check exit 0). Hunk context matches. No refactor of this submit helper in 6.12 vs the mainline parent.

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

Record: No prior usx2y hcpriv fix (git log --grep=hcpriv -- sound/usb/usx2y/ empty). Nearby usx2y hardening in this tree (nrpacks validation, URB actual_length checks, etc.) does not replace this change.

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

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

Record: **ALSA USB** (sound/usb/usx2y/), driver-specific. **PERIPHERAL/IMPORTANT-for-those-devices**: Tascam US-122/224/428 (CONFIG_SND_USB_USX2Y, x86/PPC/Alpha). Not core mm/net, but USB audio submit on a live HCD is a **system-wide panic** if it fires.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**

Record: Mature (2002–2005 origin), still receiving real fixes in 6.12 (parameter validation, bounds). Low churn, not staging.

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

**Step 8.1: DETERMINE WHO IS AFFECTED**

Record: **Driver-specific / config-specific**: users with Tascam US-122/224/428 and CONFIG_SND_USB_USX2Y. Unprivileged PCM I/O can exercise the path.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**

Record: Legal resubmit after giveback: hcpriv already NULL → **no behavior change**. Panic requires submitting a still-active URB (startup state machine, lost completed_urb, or overlapping complete/submit). Not shown with a public reproducer; ISO ping-pong with two URBs makes it **plausible**. Unprivileged users running audio can hit the submit path.

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

Record: **HCD crash / kernel panic** if an active URB is submitted after hcpriv is cleared. **Severity: CRITICAL** when it fires; **likelihood:
unproven / low** (no Reported-by). After the fix: -EBUSY + WARN + stream stop — **HIGH** improvement vs panic.

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

Record:
- **Benefit:** Restores USB core’s active-URB guard on a path that otherwise can panic the machine; correct path unchanged.
- **Risk:** 1-line deletion, no API, no locking, no data-structure change.
- **Ratio:** Strongly favors backport.

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

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Objectively illegal write to HCD-private urb->hcpriv (docs + USB core).
- Defeats usb_submit_urb()’s WARN_ONCE/-EBUSY (in this tree since 2012).
- Failure mode is HCD crash/panic (xhci re-owns a live URB).
- Buggy line present here since 2.6.12; commit is **not** in HEAD.
- 1 deletion; git apply --check clean; no prerequisites.
- USB-knowledgeable author; ALSA maintainer applied v1 same day; no NAK; no later revert.

AGAINST:
- No Reported-by / syzbot / crash log.
- Tascam-only driver.
- On the spec-compliant complete path the store is already a no-op (giveback NULL’s hcpriv first), so this is **latent** unless double- submit happens.

UNRESOLVED:
- Could not fetch lore.kernel.org (403); discussion recovered via b4 + LKML/openwall.
- No stable-list hit found; not proven it was ever NAK’d for stable.

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

1. Obviously correct and tested? **PASS** — one illegal store removed; maintainer applied; correct path unchanged.
2. Fixes a real bug that affects users? **PASS** — drivers must not clear hcpriv; this driver does; users of this hardware exist.
3. Important issue (crash, security, corruption, deadlock)? **PASS** — bypass can panic the HCD; severity is crash, even if unreported.
4. Small and contained? **PASS** — 1 line, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — clean apply; code present.

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**

Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary small bugfix.

**Step 9.4: MAKE YOUR DECISION**

This belongs in **this** 6.12 tree. The hardware set is narrow, but the patch is the lowest-risk way to stop a driver from disabling USB core’s double-submit guard. A panic on ISO resubmit is exactly the class of bug stable is meant to take; waiting for a public oops is unnecessary when the mechanism is visible in this checkout.

------------------------------------------------
What the commit solves for 6.12 users
------------------------------------------------
usx2y_urb_submit() currently zeros urb->hcpriv before usb_submit_urb(). USB core uses that pointer as “this URB is in the HCD.” Clearing it lets a still-active URB through as if it were idle. That can crash the host controller. After the deletion, a double-submit returns -EBUSY and this driver already stops the streams.

Meets stable rules: obviously correct, real invariant bug, crash severity, 1 line, no new API, applies here.

Risk vs benefit: benefit is avoiding a panic; risk is effectively zero on the giveback path this driver uses every frame.

Concerns: niche device, no reproducer. Neither blocks a one-line restore of an existing USB-core check.

Verification:
- [Phase 1] Tags: author SOB, Link msgid, Takashi Iwai SOB; no Fixes/Reported-by/stable Cc
- [Phase 1] Subject/body: stop illegal hcpriv clear; panic if URB still active
- [Phase 2] Diff: delete urb->hcpriv = NULL in usx2y_urb_submit(); confirmed at line 170 in this tree
- [Phase 2] usb_submit_urb() checks urb->hcpriv and returns -EBUSY (drivers/usb/core/urb.c:378-381)
- [Phase 2] __usb_hcd_giveback_urb() sets urb->hcpriv = NULL before urb->complete() (hcd.c:1627)
- [Phase 2] xHCI xhci_urb_enqueue() assigns urb->hcpriv = urb_priv (xhci.c:1552)
- [Phase 2] include/linux/usb.h: hcpriv is HCD-private; Documentation -EBUSY = URB already active
- [Phase 3] blame: 1da177e4c3f41 Linux-2.6.12-rc2 introduced the store
- [Phase 3] sanity check added 2f02bc8af3abb (2012), present here
- [Phase 3] git merge-base --is-ancestor fabae5548149e HEAD → not in this tree
- [Phase 3] no follow-up/revert on origin/master for this file after the commit
- [Phase 4] b4 dig -c fabae5548149e: lore msgid; v1 only; To/Cc ALSA maintainers
- [Phase 4] Takashi Iwai applied to for-next; no NAK
- [Phase 4] lore.kernel.org WebFetch 403; LKML/openwall used instead
- [Phase 5] callers: usx2y_usbframe_complete, hwdep path via #include "usbusx2yaudio.c"
- [Phase 5] only sound/ instance of urb->hcpriv = NULL
- [Phase 6] git describe HEAD = p-6.12-3-gc504cf0baa3d8; make kernelversion = 6.12.111
- [Phase 6] git apply --check of fabae5548149e succeeded
- [Phase 7] CONFIG_SND_USB_USX2Y Tascam US-122/224/428
- [Phase 8] Failure mode: HCD panic on active-URB submit; severity CRITICAL if triggered
- UNVERIFIED: no public reproducer; stable@ archive not readable (403)

**YES**

 sound/usb/usx2y/usbusx2yaudio.c | 1 -
 1 file changed, 1 deletion(-)
sound/usb/usx2y/usbusx2yaudio.c +0 -1
index c7c7ec9c228b4..1ea181e9bb283 100644
@@ -167,7 +167,6 @@ static int usx2y_urb_submit(struct snd_usx2y_substream *subs, struct urb *urb, i
 	if (!urb)
 		return -ENODEV;
 	urb->start_frame = frame + NRURBS * nr_of_packs();  // let hcd do rollover sanity checks
-	urb->hcpriv = NULL;
 	urb->dev = subs->usx2y->dev; /* we need to set this at each time */
 	err = usb_submit_urb(urb, GFP_ATOMIC);
 	if (err < 0) {
Signature · 1 line
2.53.0
author maintainer
#257 lore raw

PATCH 1/1 tools/lib/api: Fix potential double-free from fdarray__grow()

In reply to Sasha Levin

From: Namhyung Kim <[email protected]>

[ Upstream commit eadce0f46a1d066b812c7e5aa46a33711c78a755 ]

If the realloc for fda->entries succeeds but the realloc for fda->priv fails, the error path frees the newly allocated entries.

However, fda->entries is neither updated to point to the new entries block nor cleared to NULL. If realloc moved the allocation to a new block, the old fda->entries pointer is now freed memory.

When fdarray__exit() is later called to clean up, it executes free(fda->entries), which would trigger a double-free on that old pointer.

---

LLM Generated explanations, may be completely bogus:

The local tree is mainline **v7.3-rc4**. The change is a real realloc double-free in perf/libperf userspace, present since v3.18, and it is small enough to meet the stable rules.

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

**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[tools/lib/api] [fix] [prevent double-free in fdarray__grow() on partial realloc failure]**

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Reported-by: Sashiko Review <[email protected]> — AI static review, not a user crash
- `Closes: https://lore.kernel.org/linux-perf-
users/[email protected]`
- Reviewed-by: Ian Rogers <[email protected]> — perf tools reviewer
- Signed-off-by: Namhyung Kim <[email protected]> — perf tools maintainer (author and committer)
- No Fixes: tag (expected)
- No Cc: stable (expected)
- Ignore any pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] markers — none on the real commit

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** In fdarray__grow(), realloc(fda->entries) can succeed and realloc(fda->priv) can fail. The old error path free(entries) without updating fda->entries.
- **Symptom:** If realloc moved the block, fda->entries still points at the old (already freed) pointer. Later fdarray__exit() does free(fda->entries) → **double-free**.
- **Version info:** none in the message. Git shows the two-realloc pattern since **v3.18-rc1**.
- **Root cause:** classic partial-realloc handling: new pointer discarded, struct left holding a dangling pointer.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. Explicit double-free fix. The fdarray__new() free(fda) → fdarray__delete(fda) change is the matching leak fix once fda->entries is kept on failure.

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

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: tools/lib/api/fd/array.c — **+3 / −2** (net +1), 5 lines touched
- Functions: fdarray__grow(), fdarray__new()
- Scope: **single-file surgical fix**

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Hunk 1 (fdarray__grow error path): **before** free(entries) and return -ENOMEM, leaving fda->entries stale. **after** assign fda->entries = entries and return -ENOMEM, so fdarray__exit() frees the live block once.
- Hunk 2 (fdarray__new): **before** free(fda) on grow failure, leaking the entries block after hunk 1. **after** fdarray__delete(fda) which runs fdarray__exit() then free(fda).

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** double-free (and a companion leak on fdarray__new)
- **Mechanism:** two-step realloc. sizeof(struct priv) is larger than sizeof(struct pollfd) (pointer + flags vs 8-byte pollfd), so psize is larger than size. Entries can grow while priv allocation fails under memory pressure. Callers then fdarray__exit().

**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct realloc handling: if the first realloc moved the block, the old pointer is already invalid and **must** be replaced.
- Clearing fda->entries to NULL (what the bot suggested) would leak the new block and leave fda->nr > 0 with a NULL array.
- Minimal, no API/struct fdarray change. fdarray__delete() has existed since 2014.
- Regression risk: **very low**. Error path only. On failure, extra unused entries capacity may remain (nr_alloc unchanged); that is harmless.

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

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- free(entries) on priv failure introduced in **2171a9256862ec** (“tools lib fd array: Allow associating an integer cookie with each entry”), Arnaldo, 2014-09-25.
- First appeared in **v3.18-rc1**.
- fdarray itself: **1b85337d0685d** (same merge window).

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The introducing commit is 2171a9256862ec, ancestor of this tree (git merge-base --is-ancestor exit 0).

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Later fdarray work (flags, duplicate, poll-storm, hang) does not replace this error path. No follow-up after eadce0f46a1d0. Standalone, not N/M.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Namhyung Kim is a **PERFORMANCE EVENTS SUBSYSTEM** maintainer. Ian Rogers is a listed reviewer. Author applied it to perf-tools-next.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Uses existing fdarray__delete() / fdarray__exit(). Can apply standalone to any tree that still has the two-realloc grow path.

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

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION** Record:
- b4 dig -c eadce0f46a1d0 →
https://patch.msgid.link/[email protected]
- v1: [PATCH v1] lib/api/fd: Fix potential double-free from fdarray__grow() (2026-07-10)
- v2: subject-only (tools/lib/api:); **no code change**
- Ian Rogers: Reviewed-by (2026-07-15)
- Namhyung: “Applied to perf-tools-next, thanks!” (2026-07-16)
- No NAKs, no Cc: stable in review, no reviewer risk flags

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): Namhyung, Arnaldo, Ian Rogers, Jiri Olsa, Adrian Hunter, James Clark, Peter Zijlstra, Ingo Molnar, LKML, linux-perf- users, Sashiko. Right maintainer set.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: Sashiko flagged a **High** pre-existing issue on another fdarray patch. Namhyung replied “I'll handle this in a separate patch.” No user repro, syzbot, or bugzilla. Bug is from code inspection, not a field crash.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone. Separate from the fdarray__filter() nonfilterable fix that triggered the review.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** (lore.kernel.org HTTP 403). The v2 mbox has no stable discussion.

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

**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: fdarray__grow(), fdarray__new(). Cleanup via fdarray__exit() / fdarray__delete().

**Step 5.2: TRACE CALLERS**
Record (grep on this tree):
- fdarray__grow: fdarray__new, fdarray__add, perf_evlist__alloc_pollfd
- fdarray__add: perf_evlist__add_pollfd, builtin-record.c (per- thread pollfd), builtin-daemon.c, fdarray__dup_entry_from, tests
- fdarray__exit on those objects: perf_evlist__exit, record thread teardown (fdarray__exit(&thread_data[t].pollfd)), daemon goto out → fdarray__exit(&fda)

**Step 5.3: TRACE CALLEES**
Record: realloc, memset, calloc, free. No locks, no kernel allocators.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace perf / libperf. Typical path: perf record mmap → perf_evlist__alloc_pollfd → fdarray__grow. On -ENOMEM, evlist/thread/daemon cleanup calls fdarray__exit. **Reachable from a normal perf invocation under memory pressure**, not a kernel syscall path.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Only this grow function does the paired entries/priv realloc. No sibling copy of the bug.

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- git describe HEAD: **v7.3-rc4-27-gf0100363d8c37**
- make kernelversion: **7.3.0-rc4** (Linus mainline, origin = torvalds/linux.git)
- Fix commit **eadce0f46a1d0 is already an ancestor of HEAD**
- Buggy two-realloc body exists in history from v3.18; current file already has the fix
- Introduced long before this tree

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** to any tree with this fdarray__grow shape. Function has been stable aside from later memset of new slots. No conflicting refactor in this file.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This is the fix. No earlier equivalent.

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

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **tools/lib/api** used by **tools/perf** and **tools/lib/perf**.
Criticality: **IMPORTANT** for perf users, **not CORE kernel**. Userspace heap corruption, not a kernel oops.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Active (recent poll-storm/hang fixes in the same file’s callers). The grow error path itself dates to 2014 and was untouched until this commit.

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

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **config/tool-specific** — anyone running kernel-tree perf / libperf (record, daemon, evlist polling). Distros ship this perf. Not a kernel-wide crash.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Grow of an fdarray that already has (or just got) an entries allocation
- realloc(entries) succeeds, realloc(priv) fails
- Then fdarray__exit() (all production callers do this)
- Unprivileged perf can hit grow; failure needs allocation failure, so uncommon but not fictional (priv is the larger realloc)
- Not a timing race

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Userspace double-free / heap corruption** of perf → abort or allocator abort. Severity: **HIGH** for the tool, **not** a kernel panic. Possible security angle only if perf is privileged; unverified here.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** stops a real double-free on a cleanup path every grow- failure caller uses
- **Risk:** very low (5 lines, error path, maintainer-authored and reviewed)
- **Ratio:** favorable. Official “bothers people” bar is weaker (bot- found, no field report), but the defect is concrete, not a speculative race.

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

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Real double-free, not style
- Tiny, obviously correct
- Bug since v3.18; this tree has the code
- All major callers fdarray__exit() after -ENOMEM
- Partial failure is plausible because priv is larger than entries
- Reviewed by Ian Rogers; applied by Namhyung Kim
- No dependencies; clean apply
- Matches stable double-free / error-path pattern

AGAINST:
- Userspace tools, not kernel runtime
- Found by Sashiko, not a user
- Subject says “potential”; no Fixes:/Cc: stable
- Official rule: “real bug that bothers people” / not “this could be a problem”
- Trigger needs allocation failure

UNRESOLVED:
- Whether stable@ ever discussed it (lore HTTP 403)
- Whether any distro perf user hit it

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — realloc semantics; maintainer + reviewer
2. Fixes a real bug that affects users? **PASS** — double-free on grow- fail + exit; users are perf users
3. Important issue? **PASS** (HIGH userspace heap corruption; not a kernel oops)
4. Small and contained? **PASS** — 5 lines, one file
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — already present here; same hunk applies to older trees that still have this grow function

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not an ID/quirk/DT/build/doc exception). It is a normal bug fix.

**Step 9.4: MAKE YOUR DECISION**
This tree is **7.3-rc4 mainline**, and the fix is already in it. The evaluation is whether that fix is stable material for this codebase: it is. Distros ship tools/perf from the kernel tree; a double-free on a path every evlist/daemon/record teardown takes is a real crash of that tool. The patch is too small and too localized to justify holding it back because the finder was a bot or the trigger is OOM.

===============================================================
What the commit solves, and why it matters
===============================================================
fdarray__grow() grows two parallel allocations. On the second realloc failing it used to free() the first result without storing it, so fda->entries could dangle. perf record, libperf evlist, and perf daemon all fdarray__exit() afterward, which is a double-free of the process heap. Stable users who cannot bump the whole kernel still use this perf.

Risk vs benefit: benefit is preventing heap corruption in a widely shipped tool; risk is a 5-line error-path change already reviewed by the subsystem.

No missing prerequisites. No backport rework needed for this array.c.

===============================================================
Verification
===============================================================
- [Phase 1] Tags: Sashiko Reported-by, Closes lore, Reviewed-by Ian Rogers, SOB Namhyung; no Fixes/Cc-stable
- [Phase 2] Diff: 5 lines in tools/lib/api/fd/array.c; free(entries) → keep pointer; free(fda) → fdarray__delete(fda)
- [Phase 3] git blame on parent: free(entries) from 2171a9256862ec (v3.18-rc1)
- [Phase 3] git merge-base --is-ancestor 2171a9256862ec HEAD → yes; eadce0f46a1d0 also ancestor
- [Phase 3] git log --oneline eadce0f46a1d0..HEAD -- tools/lib/api/fd/array.c → empty (no follow-up)
- [Phase 4] b4 dig -c eadce0f46a1d0: v2 at patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1→v2 subject-only; applied to perf-tools-next
- [Phase 4] b4 dig -w: perf maintainers on To/Cc
- [Phase 4] b4 mbox of Closes: Sashiko High pre-existing double-free; Namhyung “I'll handle this in a separate patch”
- [Phase 4] lore WebFetch/curl: 403 — stable@ search UNVERIFIED
- [Phase 5] grep callers: evlist, builtin-record, builtin-daemon, tests; all production paths fdarray__exit
- [Phase 6] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion: 7.3.0-rc4
- [Phase 6] Current array.c already contains the fixed grow/new bodies
- [Phase 7] MAINTAINERS: Namhyung maintainer, Ian Rogers reviewer of PERFORMANCE EVENTS SUBSYSTEM
- [Phase 8] Failure mode: userspace double-free in perf, HIGH for the tool
- UNVERIFIED: field reports; privileged-perf exploitability; stable@ thread

**YES**

 tools/lib/api/fd/array.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/lib/api/fd/array.c +3 -2
index f0f195207fca9..dcb396ab51eb1 100644
@@ -31,7 +31,8 @@ int fdarray__grow(struct fdarray *fda, int nr)
 
 	priv = realloc(fda->priv, psize);
 	if (priv == NULL) {
-		free(entries);
+		/* this will be freed by fdarray__exit() */
+		fda->entries = entries;
 		return -ENOMEM;
 	}
 
@@ -50,7 +51,7 @@ struct fdarray *fdarray__new(int nr_alloc, int nr_autogrow)
 
 	if (fda != NULL) {
 		if (fdarray__grow(fda, nr_alloc)) {
-			free(fda);
+			fdarray__delete(fda);
 			fda = NULL;
 		} else {
 			fda->nr_autogrow = nr_autogrow;
Signature · 1 line
2.53.0
author maintainer
#258 lore raw

PATCH 1/1 NFS: Verify symlink inode before caching target

In reply to Sasha Levin

From: ZhangGuoDong <[email protected]>

[ Upstream commit 3265f1998ae9a9282a8a6ca95467d9572d6ebb82 ]

nfs_symlink() copies the symlink target into a folio before issuing the SYMLINK RPC. After a successful reply, it caches that folio in the instantiated inode mapping and assumes that the dentry now names a symlink.

If the dentry is instantiated with a non-symlink inode, the raw symlink target folio can be inserted into the wrong mapping. When that inode is a directory, reclaim or unmount later calls nfs_readdir_clear_array() through nfs_dir_aops and interprets the symlink target as a readdir cache array, which can lead to invalid kfree() calls.

A vmcore from a 4.19-based kernel showed the crash when reclaiming a directory mapping on unmount:

Stack trace:

   nfs_readdir_clear_array+0x4d/0x70 [nfs]
   page_cache_free_page.isra.35+0x1a/0x90
   delete_from_page_cache_batch+0x1cf/0x2c0
   truncate_inode_pages_range+0x24d/0x910
   [...]
   nfs_evict_inode+0x15/0x30 [nfs]
   evict+0x115/0x2b0
   dispose_list+0x48/0x60
   evict_inodes+0x16c/0x1b0
   generic_shutdown_super+0x3f/0x120
   nfs_kill_super+0x1b/0x40 [nfs]
   deactivate_locked_super+0x3f/0x70
   cleanup_mnt+0x3b/0x80

The current code still has the same unchecked cache insertion pattern, so it may be susceptible to the same failure mode.

Verify that the instantiated inode is a symlink before caching the target folio. If the type is wrong, drop the suspect dentry and skip the cache insertion while preserving the successful SYMLINK result.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit message forensics

**Step 1.1: Subject line**
Record: **[NFS]** **[Verify]** Verify the instantiated inode is a symlink before inserting the SYMLINK target folio into the page cache.

**Step 1.2: Tags**
Record:
- Co-developed-by: Jackie Liu \<[email protected]\>
- Signed-off-by: Jackie Liu \<[email protected]\>
- Signed-off-by: ZhangGuoDong \<[email protected]\>
- Signed-off-by: Trond Myklebust \<[email protected]\> (NFS client maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, Link:, or Cc: stable (absence is expected for this review)
- Mainline SHA: 3265f1998ae9a9282a8a6ca95467d9572d6ebb82 (authored 2026-07-03, committed by Trond 2026-08-17, merged to Linus in nfs- for-7.3-1)

**Step 1.3: Body**
Record: After a successful SYMLINK RPC, nfs_symlink() inserts the pre- copied target folio into d_inode(dentry)->i_mapping without checking that the dentry is actually a symlink. If that inode is a directory, later reclaim/unmount runs nfs_readdir_clear_array() via nfs_dir_aops.free_folio and treats the symlink text as a readdir cache array, leading to invalid kfree(). A 4.19 vmcore showed exactly that stack on unmount. The author states the same unchecked insertion still exists. Failure mode: invalid free / memory corruption / crash during unmount or mapping reclaim.

**Step 1.4: Hidden bug fix?**
Record: Not hidden. This is an explicit crash/corruption fix. The “verify before caching” wording is a missing type check, not cleanup.

## Phase 2: Diff analysis

**Step 2.1: Inventory**
Record: One file, fs/nfs/dir.c. **+6 / −0**. Function:
nfs_symlink(). Single-file surgical fix.

**Step 2.2: Control-flow change**
Record: After NFS_PROTO(dir)->symlink() returns 0, the old code always set the dentry verifier and tried filemap_add_folio(d_inode(dentry)->i_mapping, folio, 0, …). After the change, unlikely(!d_is_symlink(dentry)) causes d_drop(dentry), folio_put(folio), and return 0 (RPC still succeeded). The success path is unchanged for real symlinks.

**Step 2.3: Bug mechanism**
Record: **Memory safety / type confusion.** A folio of symlink text is inserted into a directory mapping whose a_ops->free_folio is nfs_readdir_clear_array(). That function maps the folio as struct nfs_cache_array and kfree()s array[i].name for i < array->size. Path-string bytes as size/pointers yield invalid kfree(). Also avoids a possible NULL deref if d_inode(dentry) is NULL (negative dentry after splice).

**Step 2.4: Fix quality**
Record: Obviously correct and minimal. d_is_symlink() is the right VFS helper. Skipping cache insert is already treated as non-fatal (“READLINK will get the missing page from the server”). d_drop() avoids leaving a wrong-type dentry hashed with a verifier. Regression risk is low: the common success path is unchanged; the new path only runs on a type mismatch.

## Phase 3: Git history

**Step 3.1: Blame**
Record: Unchecked cache insertion comes from 873101b337767 (“NFS: copy symlinks into page cache before sending NFS SYMLINK request”, 2006-09-22). That commit is an ancestor of this tree (git merge-base --is-ancestor exit 0). Folio conversion is f003a717ae908 (2023); same pattern, add_to_page_cache → filemap_add_folio. Directory free_folio = nfs_readdir_clear_array is present at fs/nfs/dir.c:71-73.

**Step 3.2: Fixes: tag**
Record: None. Introducer is 873101b337767, present here since 2.6-era NFS.

**Step 3.3: File history**
Record: Recent fs/nfs/dir.c work is readdir/verifier/atomic_open (including df214a74b5f2a ENXIO on O_CREAT of an existing symlink). Those are related NFS type-confusion issues but not prerequisites. This patch is standalone.

**Step 3.4: Author**
Record: ZhangGuoDong / Jackie Liu (Kylin). Not subsystem maintainers. Trond (maintainer) signed off and put it in nfs-for-7.3-1. Same author also has pnfs/blocklayout leak fixes in this tree.

**Step 3.5: Dependencies**
Record: Needs d_is_symlink() (in include/linux/dcache.h here) and folio-based nfs_symlink() (present via f003a717ae908). No other commits required. Insertion context around nfs_set_verifier() is unique in this file.

## Phase 4: Mailing list / external

**Step 4.1: Original submission**
Record: b4 dig -c 3265f1998ae9a9282a8a6ca95467d9572d6ebb82 →
https://patch.msgid.link/[email protected]
v1 only (2026-07-03). Saved mbox has the patch and **no replies**. Trond applied it as-is (same +6 hunk). Lore HTML was 403 (Anubis); discussion content was recovered via b4.

**Step 4.2: Recipients (b4 dig -w)**
Record: Trond Myklebust, Anna Schumaker, [email protected], ZhangGuoDong, Jackie Liu. Right maintainers/list.

**Step 4.3: Bug report**
Record: No public bugzilla/syzbot link. Evidence is a 4.19 vmcore stack in the commit message (unmount → nfs_readdir_clear_array).

**Step 4.4: Series**
Record: Standalone [PATCH], not n/m. Same 7.3 NFS pull also has NFSv3 symlink/atomic_open fixes; those are separate.

**Step 4.5: Stable list**
Record: Lore stable search 403. Trond’s 7.3 pull listed this under **“Other bugfixes”**, not “Stable fixes”. That is categorization, not a NAK. No stable-thread rejection found.

## Phase 5: Semantic / call graph

**Step 5.1: Functions**
Record: nfs_symlink() only.

**Step 5.2: Callers**
Record: nfs_dir_inode_operations.symlink, nfs3_dir_inode_operations.symlink, nfs4_dir_inode_operations.symlink all point at nfs_symlink. vfs_symlink() → dir->i_op->symlink() from do_symlinkat / symlink(2).

**Step 5.3: Callees**
Record: NFS_PROTO(dir)->symlink (nfs_proc_symlink / nfs3_proc_symlink / nfs4_proc_symlink) instantiate via nfs_instantiate / nfs_add_or_obtain → nfs_fhget + d_splice_alias. Then filemap_add_folio. Directory inodes get i_data.a_ops = &nfs_dir_aops in fs/nfs/inode.c (S_ISDIR branch).

**Step 5.4: Reachability**
Record: Yes — unprivileged symlink(2) on an NFS mount. Crash is later (reclaim/unmount), not at syscall return.

**Step 5.5: Similar patterns**
Record: Same class as nfs_atomic_open_v23() not checking d_is_reg() after CREATE (fixed in this tree by df214a74b5f2a). NFS create paths can attach a different type than the client assumed.

## Phase 6: This tree (pending-6.12 / 6.12.111)

**Step 6.1: Buggy code present?**
Record: **Yes.** nfs_symlink() at fs/nfs/dir.c:2612-2665 has the unchecked filemap_add_folio(d_inode(dentry)->i_mapping, …) after RPC success. nfs_dir_aops.free_folio = nfs_readdir_clear_array still kfrees names from folio contents. 3265f1998ae9 is **not** an ancestor of HEAD.

**Step 6.2: Backport difficulty**
Record: **Clean apply.** Hunk context is the return error; / nfs_set_verifier() sequence, identical here. Later mainline %llu for i_ino is outside this hunk.

**Step 6.3: Related fixes already here?**
Record: No d_is_symlink() guard in nfs_symlink(). df214a74b5f2a is a different type-check (open/CREATE), not this cache-insert bug.

## Phase 7: Subsystem

**Step 7.1:** NFS client (fs/nfs/). **IMPORTANT** — common networked filesystem; not core mm/VFS, but widely deployed (enterprise/Android/embedded).

**Step 7.2:** Actively maintained; this is a long-standing pattern, not a brand-new subsystem.

## Phase 8: Impact and risk

**Step 8.1:** NFS client users who create symlinks (symlink(2)). All of NFSv2/v3/v4 client.

**Step 8.2:** Trigger is **not** every symlink(). It needs the post- RPC dentry to not be a symlink: NFSv2 LOOKUP-after-SYMLINK race, missing fh/attrs then LOOKUP, server wrong type, or fh alias onto a directory inode. Unprivileged users can call symlink(2); the crash is delayed to reclaim/unmount.

**Step 8.3:** Failure mode: invalid kfree / memory corruption / oops on unmount. **CRITICAL**.

**Step 8.4:** Benefit **high** (prevents unmount crash/corruption). Risk **very low** (6 lines, success path unchanged, cache skip already defined as optional). Ratio strongly favors backport.

## Phase 9: Synthesis

**For:**
- Real crash with vmcore stack (nfs_readdir_clear_array on unmount).
- Same insertion vs directory free_folio pattern is in this 6.12 tree.
- Bug dates to 2006 (873101b337767).
- 6-line type check; NFS maintainer signed off.
- Userspace-reachable via symlink(2).
- Also avoids NULL d_inode if instantiation left a non- symlink/negative dentry.
- Applies cleanly; no new APIs.

**Against:**
- Trigger is uncommon (race/server/fh mismatch), not every symlink.
- No Fixes:/Cc: stable (expected; not a NO reason).
- Trond grouped it as “other bugfixes” in the 7.3 pull, not “stable fixes”.
- Mailing list had no public review comments (silent apply).
- Crash evidence is 4.19; current kernels are folio-based but the type- confusion is unchanged.

**Unresolved:** Exact 4.19 race vs this tree is not re-reproduced here. The local code still matches the described mechanism.

**Stable rules:**
1. Obviously correct and tested? **PASS** — type check + drop/skip cache; maintainer applied v1 unchanged.
2. Real user-visible bug? **PASS** — production vmcore.
3. Important (crash/corruption)? **PASS** — invalid kfree on unmount.
4. Small/contained? **PASS** — +6 lines, one function.
5. No new features/APIs? **PASS**.
6. Applies to this tree? **PASS**.

**Exception category:** None needed; it is a normal bugfix.

This tree is **6.12.111** (pending-6.12). The buggy path is here, the fix is surgical, and the failure is a crash with memory corruption. It should be backported.

Verification:
- [Phase 1] Tags parsed from provided message and GitHub 3265f1998ae9; no Fixes/Cc:stable; Trond SOB confirmed.
- [Phase 2] Diff is +6 in nfs_symlink() only; compared to local fs/nfs/dir.c:2612-2665.
- [Phase 3] git blame on nfs_symlink; introducer 873101b337767 is ancestor; git merge-base --is-ancestor 3265f1998ae9 HEAD → not in this tree.
- [Phase 3] nfs_dir_aops.free_folio = nfs_readdir_clear_array at lines 71-73; nfs_readdir_clear_array kfree loop at 221-231; directory a_ops set in inode.c ~501-505.
- [Phase 4] b4 dig -c 3265f1998ae9 → lore msgid [email protected]; -a v1 only; -w Trond+Anna+linux-nfs; mbox has no replies.
- [Phase 4] Openwall 7.3 pull lists this under other bugfixes:
https://lists.openwall.net/linux-kernel/2026/08/26/1997
- [Phase 4] Lore HTML 403; used b4 mbox instead.
- [Phase 5] Grep: v2/v3/v4 dir i_op->symlink = nfs_symlink; vfs_symlink in fs/namei.c.
- [Phase 6] make kernelversion → 6.12.111; git describe HEAD → p-6.12-3-gc504cf0baa3d8; insertion context unique; d_is_symlink exists.
- [Phase 8] Failure mode from vmcore + local nfs_readdir_clear_array
code: invalid kfree, CRITICAL.
- UNVERIFIED: Could not re-run the 4.19 workload; mechanism match is from code, not a new repro.

**YES**

 fs/nfs/dir.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/nfs/dir.c +6 -0
index 38b0834e3ebf1..0d8ac9a7448af 100644
@@ -2632,6 +2632,12 @@ int nfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
 		return error;
 	}
 
+	if (unlikely(!d_is_symlink(dentry))) {
+		d_drop(dentry);
+		folio_put(folio);
+		return 0;
+	}
+
 	nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
 
 	/*
Signature · 1 line
2.53.0
author maintainer
#259 lore raw

PATCH 1/1 crypto: keembay - add missing MODULE_DEVICE_TABLE()

In reply to Sasha Levin

From: Pengpeng Hou <[email protected]>

[ Upstream commit b73b71df4cb4ca241165ad31218c82dfe489147c ]

The driver has an OF match table wired to .of_match_table, but does not export the table with MODULE_DEVICE_TABLE().

Add the missing MODULE_DEVICE_TABLE(of, ...) entry so module alias information is generated for OF based module autoloading.

This is a source-level fix. It does not claim dynamic hardware reproduction; the evidence is the driver-owned match table, its use by the platform driver, and the missing module alias publication.

---

LLM Generated explanations, may be completely bogus:

## Local tree

This checkout is **v7.3-rc4** (7.3.0-rc4, git describe:
v7.3-rc4-27-gf0100363d8c37). The candidate is b73b71df4cb4c (crypto: keembay - add missing MODULE_DEVICE_TABLE()). The Keem Bay OCS ECC driver is present here. The verdict is for this tree’s lineage:
does this one-line autoload fix meet stable rules given that the driver and the missing alias exist in this code.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[crypto: keembay] [add] [missing MODULE_DEVICE_TABLE() for OF module autoload]**

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- No Fixes: tag (expected for this review)
- No Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, Link:, or Cc: [email protected]
- Signed-off-by: Pengpeng Hou <[email protected]> (author)
- Signed-off-by: Herbert Xu <[email protected]> (crypto maintainer; applied the patch)
- Ignore pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] if present; they are not in this git object

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** kmb_ocs_ecc_of_match[] is wired to .of_match_table but not exported with MODULE_DEVICE_TABLE(of, ...).
- **Symptom:** OF modules.alias entries are not generated, so udev/kmod will not autoload keembay-ocs-ecc from the DT compatible intel,keembay-ocs-ecc.
- **Version info:** none in the message.
- **Root cause:** missing module-alias publication for an existing match table. Author states this is a source-level finding, not a live hardware repro.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised cleanup. It is an explicit autoload/enablement fix. Same class as adding a device ID for modular builds.

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/crypto/intel/keembay/keembay-ocs-ecc.c — **+1 / −0**
- Function/scope: file-scope kmb_ocs_ecc_of_match[] (no function body change)
- Classification: **single-file surgical fix**

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** match table exists and is used for bind-time matching if the driver is already loaded (built-in, or loaded some other way).
- **After:** modpost/file2alias also emit of: aliases from that table, so DT device appearance can load the module.
- Path affected: **module autoload / init**, not the probe runtime path.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- Category: **hardware enablement / missing device-ID publication** (OF module aliases)
- Mechanism: without MODULE_DEVICE_TABLE, scripts/mod/file2alias.c does not emit aliases for intel,keembay-ocs-ecc. Built-in still binds; **CONFIG_CRYPTO_DEV_KEEMBAY_OCS_ECC=m does not autoload from DT**.
- Confirmed in include/linux/module.h: MODULE_DEVICE_TABLE creates the alias symbol file2alias scans.

**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: one standard macro next to the existing table, matching sibling Keem Bay drivers (AES, HCU).
- Minimal; no locking, no API, no data-structure change.
- Regression risk: **very low**. Macro is a no-op for built-in; for modules it only adds aliases.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Match table introduced in **c9f608c380090** (“crypto: keembay-ocs- ecc - Add Keem Bay OCS ECC Driver”, Prabhjot Khurana, 2021-10-20).
- git merge-base --is-ancestor c9f608c380090 v5.16 succeeded → first appeared in **v5.16**.
- Bug: table never had MODULE_DEVICE_TABLE until b73b71df4cb4c (2026-07-13). Long-lived.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Introducer is c9f608c380090, ancestor of HEAD.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES** Record:
- 86c85d6657e47 (2024-08-24): **“crypto: keembay - fix module autoloading”** — same fix for HCU (MODULE_DEVICE_TABLE(of, kmb_ocs_hcu_of_match)).
- 0a94091e29f91: same publication for OCS AES/SM4.
- fbf31dd599875 (v6.4-rc1): moved driver to drivers/crypto/intel/keembay/.
- Standalone one-liner; not patch N/M.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Pengpeng Hou is a regular contributor of missing-MODULE_DEVICE_TABLE and validation fixes (ixp4xx crypto, several RTC/vdpa/watchdog/hwmon drivers). Not the Keem Bay maintainer. Crypto maintainer Herbert Xu applied it.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Uses existing of_device_id table and MODULE_DEVICE_TABLE. Applies standalone on this tree.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c b73b71df4cb4c →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only**; committed version is that v1.
- Thread (mbox): Herbert Xu: **“Patch applied. Thanks.”** No NAK, no requested changes, no Cc: stable from reviewers.
- Direct lore HTTP fetch returned 403/Anubis; discussion recovered via b4 dig -m.

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc included Prabhjot Khurana, Mark Gross, **Herbert Xu**, David S. Miller, linux-crypto@, linux-kernel@. Maintainer applied it. No extra Reviewed-by on the commit.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by / bugzilla / syzbot. Author calls it a source- level finding. No user crash report found.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Same-day sibling 1e5004d5a3a80 (“crypto: ixp4xx - add missing MODULE_DEVICE_TABLE()”), same commit-message template. Systematic scan, still a real missing-alias bug.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** for lore.kernel.org/stable (Anubis bot-wall). No in-tree evidence this was rejected for stable.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: No function body changed. Touches kmb_ocs_ecc_of_match[] used by kmb_ocs_ecc_driver (module_platform_driver).

**Step 5.2: TRACE CALLERS**
Record: kmb_ocs_ecc_probe() is the platform .probe. Called by the platform bus when a device matches intel,keembay-ocs-ecc. Autoload is the missing step before probe for =m.

**Step 5.3: TRACE CALLEES**
Record: Probe ioremaps, requests IRQ, starts crypto_engine, registers ECDH P-256/P-384. Unchanged.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable when ARCH_KEEMBAY (or COMPILE_TEST) and CRYPTO_DEV_KEEMBAY_OCS_ECC=m, and DT has intel,keembay-ocs-ecc.
Kconfig: “Say Y or M if you are compiling for the Intel Keem Bay SoC.” In-tree DTS (arch/arm64/boot/dts/intel/) has **no** ocs-ecc node (only the binding example). Hardware is still a real SoC (ARCH_KEEMBAY in arch/arm64/Kconfig.platforms). Userspace does not trigger this via a generic syscall; DT device + modular driver does.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same omission later fixed in HCU (86c85d6657e47) and AES (0a94091e29f91). This is the remaining ECC sibling.

---

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** File and kmb_ocs_ecc_of_match[] are here. Pre-fix parent of b73b71df4cb4c had the table and .of_match_table assignment with no MODULE_DEVICE_TABLE. Introduced v5.16; this tree is 7.3-rc4. git merge-base --is-ancestor b73b71df4cb4c HEAD is true (landed by 7.3-rc1). That does not make the fix unworthy of stable; it confirms the driver/bug lived in this lineage.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** on this tree (already applied as +1 line). Older stables before fbf31dd599875 use drivers/crypto/keembay/; that is a path tweak only, not a semantic dependency for this checkout.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: HCU and AES already publish OF aliases. No alternate ECC autoload fix besides this commit. Driver also has MODULE_ALIAS_CRYPTO("ecdh-nist-p256") etc., which can load the module on crypto-API request, **not** on DT device appearance.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/crypto/intel/keembay/ — SoC crypto accelerator. **PERIPHERAL** (Keem Bay / Movidius only), but an existing in-tree driver, not staging.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Moderate churn (crypto_engine API, remove-callback, directory move). Match table itself unchanged since 2021 except this alias line.
Maintainer: Prabhjot Khurana; applied by Herbert Xu.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **platform-specific / config-specific** — CRYPTO_DEV_KEEMBAY_OCS_ECC=m on Keem Bay with a DT node for OCS ECC.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Boot/enumeration when the OF device is created and the driver is a module. Not a race. Unprivileged users do not trigger it directly. Common on that SoC if the node exists; rare globally.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Hardware crypto module does not autoload from DT; ECDH offload missing until manual modprobe or a crypto-alias load. Not panic/UAF/corruption. **MEDIUM** functional/enablement (stable’s “device ID” class).

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** modular Keem Bay ECC actually binds at device discovery. Same class as device-ID additions.
- **Risk:** very low (one macro).
- **Ratio:** favorable.

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Real modular autoload bug: OF match table present, aliases not published.
- Official stable rules: *“fix a real bug that bothers people **or just add a device ID**.”* This is publishing an existing OF ID for modules.
- User-prompt exception: new/missing device IDs and hardware enablement on an existing driver.
- +1 line, obviously correct, maintainer-applied, v1 unchanged.
- Same fix already used on sibling HCU/AES drivers.
- Driver has been in this lineage since v5.16; no missing prerequisites in this tree.

AGAINST:
- No user/syzbot report; author says source-level only.
- Niche SoC; no in-tree DTS node for this compatible.
- MODULE_ALIAS_CRYPTO can still load the module on algorithm request.
- Not a crash, leak, or security bug.

UNRESOLVED:
- Stable-list discussion (lore blocked).
- Whether out-of-tree Keem Bay DTs include intel,keembay-ocs-ecc.

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — standard macro; applied by Herbert Xu.
2. Fixes a real bug that affects users? **PASS** — modular OF autoload does not work; device-ID equivalent.
3. Important issue? **PASS** under the device-ID / hardware-enablement exception (not a panic).
4. Small and contained? **PASS** — 1 line, 1 file.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — file and table exist; applies as a single insertion.

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Device ID / module-alias publication for an existing driver.**

**Step 9.4: MAKE YOUR DECISION**
This is a one-line, obviously correct enablement fix: the driver already matches intel,keembay-ocs-ecc, but modular builds never advertised that ID to userspace. That is the same class of change stable already takes for PCI/USB/OF IDs. Risk is negligible. This 7.3-rc4 tree contains the driver and the historical bug; the patch is appropriate to carry on this lineage’s stable trees.

### What the commit solves
Without MODULE_DEVICE_TABLE(of, kmb_ocs_ecc_of_match), modpost does not emit OF aliases, so a modular keembay-ocs-ecc will not autoload when the DT device appears. Built-in still works. The fix only publishes the existing match table.

### Risk vs benefit
Benefit is hardware actually probing on modular Keem Bay systems. Risk is a compile-time alias with no runtime logic change.

### Concerns
Niche platform; no crash report. That does not disqualify a device-ID- class one-liner. No functional dependencies.

Verification:
- [Phase 1] git log -1 --format='%B' b73b71df4cb4c: tags as listed; no Fixes/Reported-by/Cc: stable
- [Phase 2] git show b73b71df4cb4c: +1 line MODULE_DEVICE_TABLE(of, kmb_ocs_ecc_of_match)
- [Phase 2] include/linux/module.h and scripts/mod/file2alias.c:
alias generation confirmed
- [Phase 3] git blame on match table: introducer c9f608c380090; git merge-base --is-ancestor c9f608c380090 v5.16 succeeded
- [Phase 3] Sibling fixes 86c85d6657e47 (HCU) and 0a94091e29f91 (AES) confirmed
- [Phase 4] b4 dig -c/-a/-w/-m: v1 lore URL; Herbert “Patch applied. Thanks.”; crypto list + original Intel authors
- [Phase 4] lore HTTP: 403/Anubis — UNVERIFIED via WebFetch/curl
- [Phase 5] Probe at kmb_ocs_ecc_probe; grep found no in-tree DTS using intel,keembay-ocs-ecc
- [Phase 6] git describe HEAD → v7.3-rc4-27-gf0100363d8c37; make kernelversion → 7.3.0-rc4; pre-fix parent lacks the macro; driver present
- [Phase 6] git merge-base --is-ancestor b73b71df4cb4c HEAD succeeded
- [Phase 7] Kconfig CRYPTO_DEV_KEEMBAY_OCS_ECC depends on ARCH_KEEMBAY || COMPILE_TEST
- [Phase 8] Failure mode: missing module autoload, not oops
- UNVERIFIED: stable@ mailing-list discussion; live hardware reproduction (author did not claim one)

**YES**

 drivers/crypto/intel/keembay/keembay-ocs-ecc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/crypto/intel/keembay/keembay-ocs-ecc.c +1 -0
index 59308926399d0..f31b5ae73f664 100644
@@ -987,6 +987,7 @@ static const struct of_device_id kmb_ocs_ecc_of_match[] = {
 	},
 	{}
 };
+MODULE_DEVICE_TABLE(of, kmb_ocs_ecc_of_match);
 
 /* The OCS driver is a platform device. */
 static struct platform_driver kmb_ocs_ecc_driver = {
Signature · 1 line
2.53.0
author maintainer
#260 lore raw

PATCH 1/1 Bluetooth: btusb: Add support for 1357:c123 Realtek 8852BE device

In reply to Sasha Levin

From: Pavel Zverev <[email protected]>

[ Upstream commit 335d7bd554a20f33acf762655cafe1089f7f5822 ]

Wiko Hi MateBook 14 Ryzen 200 laptops (DMI system-product-name "MNCA-XX", board "M1060") are equipped with an RTL8852BE Wi-Fi/BT combo chip (rtw89_8852be), whose Bluetooth radio enumerates as 1357:c123 instead of one of the already-supported 1358:c123 / 0bda:c123 identifiers, presumably due to OEM rebranding. Without a matching entry it only matches the generic USB Bluetooth class fallback, so the Realtek firmware/config (rtl8852btu_fw.bin / rtl8852btu_config.bin) is never loaded and the adapter cannot discover or connect to any device, even though hciconfig reports it as powered and scanning.

Device descriptor:
idVendor 0x1357
idProduct 0xc123
bcdDevice 0.00
iManufacturer 1 Realtek
iProduct 2 Bluetooth Radio
bDeviceClass 224 Wireless
bDeviceSubClass 1 Radio Frequency
bDeviceProtocol 1 Bluetooth

Adding the same BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH quirk already used for 1358:c123 and 0bda:c123 fixes firmware loading and normal operation.

---

LLM Generated explanations, may be completely bogus:

This is a two-line USB ID addition for an existing Realtek path in btusb. The 6.18.53 tree already has that path and the sibling IDs; this OEM VID is missing, so Bluetooth never loads firmware on the affected laptop.

## Phase 1: Commit message forensics

**Step 1.1 — Subject**
Record: [Bluetooth/btusb] [Add] USB ID 1357:c123 for Realtek 8852BE (OEM rebrand of known c123 devices)

**Step 1.2 — Tags**
Record:
- Signed-off-by: Pavel Zverev \<[email protected]\> (author)
- Signed-off-by: Luiz Augusto von Dentz \<[email protected]\> (Bluetooth maintainer; applied the patch)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, Link:, or Cc: stable (absence of Fixes/Cc:stable is expected for this review queue)

**Step 1.3 — Body**
Record:
- Bug: Wiko Hi MateBook 14 Ryzen 200 (DMI "MNCA-XX" / board "M1060") has RTL8852BE (Wi-Fi rtw89_8852be). BT enumerates as **1357:c123** instead of already-supported **1358:c123** / **0bda:c123**.
- Symptom: generic USB Bluetooth class match only; rtl8852btu_fw.bin / rtl8852btu_config.bin never load; adapter appears powered/scanning but cannot discover or connect.
- Root cause: missing quirks_table entry so BTUSB_REALTEK is never applied.
- Descriptor: vendor 0x1357, product 0xc123, class 224/1/1, manufacturer “Realtek”.
- Fix: same BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH flags as the sibling IDs.

**Step 1.4 — Hidden bug fix?**
Record: Not hidden. It is an explicit hardware-enablement / device-ID quirk. Bluetooth is non-functional without it.

## Phase 2: Diff analysis

**Step 2.1 — Inventory**
Record: drivers/bluetooth/btusb.c only; **+2 / -0** lines; table quirks_table[]; single-file surgical change.

**Step 2.2 — Flow**
Record: After { USB_DEVICE(0x0bda, 0xc123), ... } insert { USB_DEVICE(0x1357, 0xc123), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }. Probe path only; no error-path or locking change.

**Step 2.3 — Bug mechanism**
Record: **Hardware workaround / device ID** (stable exception). Without the ID:
1. Device matches generic { USB_DEVICE_INFO(0xe0, 0x01, 0x01) } in btusb_table with driver_info == 0.
2. btusb_probe() then calls usb_match_id(intf, quirks_table).
3. No match → no BTUSB_REALTEK → hdev->setup is not btusb_setup_realtek → no btrtl_download_firmware().

Firmware is chosen later by chip identity (btrtl_match_ic() on LMP/HCI rev), not by USB PID, so this ID only gates the Realtek setup path.

**Step 2.4 — Fix quality**
Record: Obviously correct copy of sibling entries. Scope is this VID:PID only. Regression risk is negligible (wrong non-Realtek device with 1357:c123 is not plausible given the descriptor). No API/structure change.

## Phase 3: Git history

**Step 3.1 — Blame**
Record: Neighbor IDs:
- 1358:c123 — f496297e76a69 (Julian Pidancet, 2020) “Add support for 1358:c123 Realtek 8822CE” (Huawei Matebook); contained in v5.11-rc1.
- 0bda:c123 — 24d6a6d24f01f (Cadel Watson, 2020) “Support 0bda:c123 Realtek 8822CE”; also v5.11-rc1.
The missing ID is new OEM VID 0x1357 with the same PID. Buggy “no Realtek quirk” behavior has existed for this VID:PID for as long as the device has existed; the table itself has been there since ~5.11.

**Step 3.2 — Fixes: tag**
Record: None. Not a regression from a specific commit; it is a missing ID.

**Step 3.3 — File history**
Record: Recent btusb.c history in this tree includes many of the same pattern (Add Realtek RTL8922AE VID/PID 0bda/d923, Mercusys/ASUS/TP- Link IDs, several RTL8852BE IDs). Standalone; not “patch X/Y”.

**Step 3.4 — Author**
Record: Pavel Zverev has no other drivers/bluetooth/ commits in this tree. Applied by Luiz Augusto von Dentz (Bluetooth USB maintainer). Same class of ID adds is routinely accepted.

**Step 3.5 — Dependencies**
Record: Needs existing BTUSB_REALTEK / quirks_table / btrtl_setup_realtek() / RTL8852 firmware table. All are in this tree (1fb9943146968 RTL8852BT/8852BE-VT firmware matching is an ancestor of HEAD). Standalone +2 lines.

## Phase 4: Mailing list

**Step 4.1 — Original discussion**
Record:
- SHA: 335d7bd554a20f33acf762655cafe1089f7f5822
- b4 dig -c:
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only**, 2026-07-08, no later revision
- Thread: submission, BlueZ CI pass, patchwork-bot “applied to bluetooth-next”
- No NAK, no reviewer risk flags, no request for changes
- Applied to bluetooth-next as 1386e748cfc0; later on master as 335d7bd554a20

**Step 4.2 — Recipients (b4 dig -w)**
Record: To Marcel Holtmann, Luiz Dentz; Cc linux-bluetooth@. Correct lists/maintainers. Luiz applied it.

**Step 4.3 — Bug report**
Record: No bugzilla/syzbot link. Author reports a specific laptop (DMI + USB descriptor) and that adding the ID restored discovery/connect. Direct user impact, one platform.

**Step 4.4 — Series**
Record: Single standalone patch. CI: CheckPatch, build, sparse all PASS (Patchwork series 1123385).

**Step 4.5 — Stable list**
Record: lore.kernel.org HTTP 403 from WebFetch; WebSearch for stable discussion failed. No local git log --grep=1357:c123 hits. UNVERIFIED:
no evidence this was already discussed on stable@; that is not a negative.

## Phase 5: Code semantics

**Step 5.1 — Functions**
Record: No function body change. Data: quirks_table[]. Consumers:
btusb_probe() via usb_match_id().

**Step 5.2 — Callers**
Record: USB probe when a matching interface is enumerated. btusb_table generic class entry binds first; then quirks_table supplies driver_info. Not irq/syscall hot path; once per device bind.

**Step 5.3 — Callees**
Record: With the new flags, probe sets hdev->setup = btusb_setup_realtek → btrtl_setup_realtek() → btrtl_initialize() / btrtl_download_firmware(). Also HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED. CONFIG_BT_HCIBTUSB_RTL defaults to y.

**Step 5.4 — Reachability**
Record: Yes, from plugging in / internal USB BT of that laptop. Unprivileged users then use BlueZ; the bug is “adapter never works,” not a crash.

**Step 5.5 — Similar patterns**
Record: Dozens of BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH IDs, including other 8852BE VIDs (0bda:4853, 13d3:3618, 0489:e123, …). Sibling c123 IDs already present. Same fix applied many times.

## Phase 6: This tree (6.18.53)

**Step 6.1 — Does the buggy code exist?**
Record: Yes.
- Tree: pending-6.18, git describe HEAD = p-6.18-1-g03b85e06ca9bf, make kernelversion = **6.18.53**, merge-base with master = Linux 6.18 (2025-11-30).
- git merge-base --is-ancestor 335d7bd554a20 HEAD → **not in HEAD**.
- 1358:c123 and 0bda:c123 are at lines 877–880 of drivers/bluetooth/btusb.c; **1357:c123 is absent**.
- Realtek setup and rtl8852btu_* firmware names exist in btrtl.c.

The ID was added in mainline in Aug 2026, after 6.18; the **gap** (missing ID) is in this tree. That is the usual device-ID backport case, not “code not present.”

**Step 6.2 — Backport difficulty**
Record: git show 335d7bd554a20 | git apply --check succeeded (hunk at line 878, offset -16). Clean apply, trivial offset.

**Step 6.3 — Related fixes already here?**
Record: No 1357:c123 entry. Other 8852BE IDs and firmware support are already here; this does not duplicate them.

## Phase 7: Subsystem context

**Step 7.1**
Record: drivers/bluetooth/btusb.c — USB Bluetooth. **IMPORTANT** (very common laptop combo chips), not core mm/vfs, not staging.

**Step 7.2**
Record: Actively maintained; this tree already backported many Bluetooth: btusb: Add ... ID patches (e.g. b85ef6483d5b3 RTL8922AE 0bda/d923). Mature table, ongoing OEM IDs.

## Phase 8: Impact and risk

**Step 8.1 — Who is affected**
Record: Driver + VID/PID specific. Users of 1357:c123, documented as Wiko Hi MateBook 14 Ryzen 200. No effect on other devices.

**Step 8.2 — Trigger**
Record: Every boot / BT bring-up on that hardware. Not a race. Unprivileged use of BT is broken until firmware loads.

**Step 8.3 — Failure mode**
Record: Adapter enumerates and looks “up” but cannot discover or connect. Severity **HIGH** for that hardware (Bluetooth unusable), not a panic. Device-ID exception still applies.

**Step 8.4 — Risk vs benefit**
Record:
- Benefit: high for affected laptops; zero for everyone else.
- Risk: very low (+2 lines, VID/PID gated, same flags as existing c123 entries).
- Ratio: strongly in favor of backport.

## Phase 9: Synthesis

**Evidence FOR**
- Explicit stable exception: **new USB ID on an existing driver**.
- Real user-visible bug: BT cannot pair/connect without Realtek firmware.
- +2 lines, identical to 1358:c123 / 0bda:c123 already in 6.18.53.
- Applies cleanly; Realtek/8852 firmware path already present.
- Maintainer-applied; CI passed; no NAKs.
- This 6.18.y tree already takes the same class of ID adds.

**Evidence AGAINST**
- Not a crash/UAF/security issue (not required for device IDs).
- One OEM laptop family (still a real product).
- Author is not a regular Bluetooth contributor (offset by Luiz applying it).
- Sibling IDs were labeled 8822CE in 2020; this commit says 8852BE. Firmware is matched by chip ID after BTUSB_REALTEK, so a mis-named chip in the subject would still load the correct image. Author cites rtl8852btu_* from the working setup.

**Unresolved**
- Could not fetch lore/stable@ via HTTP (403). Thread recovered via b4 dig -m.
- Did not independently attach the laptop; relied on author’s descriptor and “works after this ID.”

**Stable rules**
1. Obviously correct and tested? **PASS** (same flags as siblings; author + CI + maintainer).
2. Real bug affecting users? **PASS** (BT unusable on that hardware).
3. Important? **PASS** under the device-ID exception (hardware does not work).
4. Small and contained? **PASS** (+2 lines, one table).
5. No new features/APIs? **PASS** (existing quirk flags only).
6. Applies to this tree? **PASS** (git apply --check clean).

**Exception category:** NEW DEVICE ID on existing btusb / Realtek path.

This should be backported to this 6.18.53 tree. The driver, Realtek firmware loader, and sibling c123 quirks are already here; only 1357:c123 is missing, and that is enough to leave this laptop’s Bluetooth non-functional.

Verification:
- [Phase 1] Parsed subject/tags from git show 335d7bd554a20; no Fixes/Cc:stable; Luiz SOB present
- [Phase 2] Diff is +2 lines in quirks_table; confirmed btusb_probe() uses generic class match then usb_match_id(..., quirks_table) when driver_info == 0 (btusb.c ~4064–4069, 82–83, 4309–4312)
- [Phase 2] Firmware selected by btrtl_match_ic() / btrtl_setup_realtek(), not USB PID (btrtl.c 342–345, 1359–1368)
- [Phase 3] Blame: 1358:c123 = f496297e76a69, 0bda:c123 = 24d6a6d24f01f, both v5.11-rc1 and in this tree
- [Phase 3] git merge-base --is-ancestor 335d7bd554a20 HEAD → not in this tree
- [Phase 3] git merge-base --is-ancestor 1fb9943146968 HEAD → 8852BT/BE-VT firmware support is in this tree
- [Phase 4] b4 dig -c/-a/-w/-m: v1, linux-bluetooth, Luiz applied, CI PASS, no NAK
- [Phase 4] lore WebFetch 403; stable@ search failed — UNVERIFIED beyond b4 mbox
- [Phase 5] CONFIG_BT_HCIBTUSB_RTL default y (Kconfig); BTUSB_WIDEBAND_SPEECH → HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED (btusb.c:4344)
- [Phase 6] git describe HEAD p-6.18-1-g03b85e06ca9bf; kernel 6.18.53; grep shows 1358/0bda:c123, not 1357:c123
- [Phase 6] git apply --check succeeded with offset -16
- [Phase 7/8] Same ID-add pattern already in this tree (e.g. b85ef6483d5b3)
- UNVERIFIED: physical confirmation of 8852BE vs 8822CE; does not change the ID-add decision because firmware is chip-matched

**YES**

 drivers/bluetooth/btusb.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
index 9257341b01399..3c9d5d0976936 100644
@@ -882,6 +882,8 @@ static const struct usb_device_id quirks_table[] = {
 						     BTUSB_WIDEBAND_SPEECH },
 	{ USB_DEVICE(0x0bda, 0xc123), .driver_info = BTUSB_REALTEK |
 						     BTUSB_WIDEBAND_SPEECH },
+	{ USB_DEVICE(0x1357, 0xc123), .driver_info = BTUSB_REALTEK |
+						     BTUSB_WIDEBAND_SPEECH },
 	{ USB_DEVICE(0x0cb5, 0xc547), .driver_info = BTUSB_REALTEK |
 						     BTUSB_WIDEBAND_SPEECH },
 
Signature · 1 line
2.53.0
author maintainer
#261 lore raw

PATCH 1/1 HID: i2c-hid: add reset quirk for Lenovo Yoga Slim 7x Gen 11 keyboard

In reply to Sasha Levin

From: Oleg Keri <[email protected]>

[ Upstream commit 39e8e085710a2d36d9ceade11739fb7b87f5aeb0 ]

The ITE controller behind the keyboard of the Lenovo Yoga Slim 7x Gen 11 (048d:83db) carries out a reset but never raises the interrupt that acknowledges it. i2c_hid_finish_hwreset() therefore waits out its full one second timeout and logs "device did not ack reset within 1000 ms" on every probe and every resume, before the keyboard comes up regardless.

Set I2C_HID_QUIRK_NO_IRQ_AFTER_RESET for it, as is already done for several other ITE parts, so the reset is followed by a fixed 100 ms sleep instead.

---

LLM Generated explanations, may be completely bogus:

I have enough to judge this as a hardware quirk for the existing i2c-hid
driver: the 1-second reset-ack wait is in this 6.18 tree, and the new ID only matches 048d:83db.

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

**Step 1.1: PARSE THE SUBJECT LINE**

Record: [HID: i2c-hid] [add] [reset quirk for Lenovo Yoga Slim 7x Gen 11 keyboard]

Subsystem prefix is HID: i2c-hid. Action verb is **add** (hardware quirk table entry). Claimed intent: stop waiting a full second for a reset IRQ this ITE keyboard never raises.

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

Record:
- Fixes: — absent (expected for autosel review; not a negative signal)
- Reported-by: — absent
- Tested-by: — absent
- Reviewed-by: — absent
- Acked-by: — absent
- Link: — absent
- Cc: [email protected] — absent (expected)
- Signed-off-by: Oleg Keri <[email protected]> (author)
- Signed-off-by: Jiri Kosina <[email protected]> (HID maintainer; this is the real maintainer SOB)
- Signed-off-by: Sasha Levin — ignored per instructions (pipeline)

Notable: HID maintainer applied it. No syzbot/KASAN tags. Author is a hardware user, not a regular HID contributor (git log --author='Oleg Keri' on drivers/hid/ shows only this commit).

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

Record:
- **Bug:** ITE controller 048d:83db on Lenovo Yoga Slim 7x Gen 11 performs reset but never raises the ack IRQ.
- **Symptom:** i2c_hid_finish_hwreset() waits the full 1000 ms and logs device did not ack reset within 1000 ms on probe (author also says resume). Keyboard still comes up afterward.
- **Root cause:** Device does not implement the i2c-hid reset-complete interrupt.
- **Fix:** I2C_HID_QUIRK_NO_IRQ_AFTER_RESET → 100 ms msleep instead of 1 s wait_event_timeout.
- **Version info:** None in the message. Cover letter (mailing list) identifies the machine as a Snapdragon X2 Elite (glymur) laptop.

**Step 1.4: DETECT HIDDEN BUG FIXES**

Record: Not a hidden fix. It is an explicit hardware quirk. Same class as USB/PCI/HID quirk table additions, which stable explicitly accepts.

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

**Step 2.1: INVENTORY THE CHANGES**

Record:
- drivers/hid/hid-ids.h: +1 (I2C_DEVICE_ID_ITE_LENOVO_YOGA_SLIM_7X_G11_KEYBOARD 0x83db)
- drivers/hid/i2c-hid/i2c-hid-core.c: +2 (quirk table entry using USB_VENDOR_ID_ITE + that ID + I2C_HID_QUIRK_NO_IRQ_AFTER_RESET)
- Total: **+3 / -0**. Functions: none modified; static i2c_hid_quirks[] table only.
- Scope: **single-purpose, two-file surgical quirk**.

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

Record:
- **Before:** i2c_hid_lookup_quirk(0x048d, 0x83db) returns 0. i2c_hid_finish_hwreset() takes the wait_event_timeout(..., 1000 ms) branch, warns, then continues.
- **After:** lookup returns I2C_HID_QUIRK_NO_IRQ_AFTER_RESET. Same function msleep(100) and clears I2C_HID_RESET_PENDING without waiting for IRQ.
- Path: HID probe (hid_add_device → ll_driver->parse → i2c_hid_parse → start/finish hwreset). Initialization path, not a new API.

Verified i2c_hid_finish_hwreset():

```508:516:drivers/hid/i2c-hid/i2c-hid-core.c
        if (ihid->quirks & I2C_HID_QUIRK_NO_IRQ_AFTER_RESET) {
                msleep(100);
                clear_bit(I2C_HID_RESET_PENDING, &ihid->flags);
        } else if (!wait_event_timeout(ihid->wait,
                                       !test_bit(I2C_HID_RESET_PENDING,
&ihid->flags),
                                       msecs_to_jiffies(1000))) {
                dev_warn(&ihid->client->dev, "device did not ack reset
within 1000 ms\n");
                clear_bit(I2C_HID_RESET_PENDING, &ihid->flags);
        }
```

**Step 2.3: IDENTIFY THE BUG MECHANISM**

Record: **(h) Hardware workaround.** Device never signals reset- complete. Generic 1 s wait is correct for spec-compliant parts and wrong for this ITE keyboard. Quirk matches the existing Voyo/Hantick/Raydium pattern.

**Step 2.4: ASSESS THE FIX QUALITY**

Record:
- Obviously correct: identical to existing table rows; USB_VENDOR_ID_ITE is 0x048d, matching the commit text.
- Minimal: three lines, no behavioral change for any other VID/PID.
- Regression risk: very low. Only 048d:83db is affected. If a future device reused that ID and *did* ack reset, it would sleep 100 ms instead of waiting for IRQ — that ID is this laptop’s keyboard.
- No public API / data-structure change.

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

**Step 3.1: BLAME THE CHANGED LINES**

Record:
- Quirk flag and table date to 2017 (402946a8ef71e, Hantick).
- ITE Voyo entry: fc6a31b007393 (2021-02-05), Hans de Goede.
- Timeout-as-warning (so probe still succeeds): 7bcf9ebb50f2a (2023-12-06). That commit even said more NO_IRQ_AFTER_RESET quirks should become unnecessary; they still help because the 1 s wait remains.
- G11 ID did not exist before this change (git show <parent>:drivers/hid/hid-ids.h has Slim 7x 0x8987 only).
- Buggy *behavior* is the generic wait in i2c_hid_finish_hwreset, present for years, including this 6.18 tree.

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

Record: No Fixes: tag. Not applicable. The “introduction” is hardware, not a kernel regression.

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

Record:
- Related: a45f15808fb75 “HID: lenovo: fixup Lenovo Yoga Slim 7x Keyboard rdesc” (product 0x8987, original Slim 7x, not Gen 11).
- Later in this checkout: 245d6017beff2 adds BAD_INPUT_SIZE for another device; independent.
- This commit is **patch 1/2** of “HID: Lenovo Yoga Slim 7x Gen 11 keyboard fixes”. Patch 2 (HID: lenovo: suppress phantom radio control input) uses the #define this patch adds. Cover letter: each patch builds standalone if applied in order; this one does not need patch 2.
- Patch 2 is **not** in this tree (git log --grep='suppress phantom radio' empty; hid-lenovo.c has no G11 ID).

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

Record: Oleg Keri has no other HID commits here. Jiri Kosina (HID maintainer) signed off and applied it. Recipients included Benjamin Tissoires and Lenovo’s Mark Pearson.

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

Record: No prerequisites. I2C_HID_QUIRK_NO_IRQ_AFTER_RESET, i2c_hid_lookup_quirk(), USB_VENDOR_ID_ITE, and the quirks table all exist in the parent (7e1d29620273b, v6.18.57-15-g7e1d29620273b). Standalone apply.

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

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

Record:
- b4 dig -c 2cb79eaedc9ed matched lore:
https://patch.msgid.link/[email protected]
- b4 dig -a:
- v1 (2026-09-08): standalone i2c-hid patch

    `[email protected]`

- v2 series (2026-09-08 / resend 2026-09-10): 0/2 + 1/2 + 2/2
- v2 change was **ordering only** (kbuild robot: patch 2 used an undeclared ID). No functional change to this quirk.
- Jiri applied 1/2 from the standalone posting (“Applied, thank you.”). Oleg later noted 1/2 was already applied, only 2/2 still needed.
- No NAK. No reviewer concern about the quirk itself. No Cc: stable in the thread (absence expected).

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

Record (b4 dig -w): Oleg Keri; Jiri Kosina; Benjamin Tissoires; Derek J. Clark; Mark Pearson (Lenovo); linux-input; linux-kernel. Right maintainers and Lenovo contact were on the original To/Cc. Maintainer applied it.

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

Record: No bugzilla/syzbot link. Evidence is the author’s machine (048d:83db) and the exact dev_warn string, which matches i2c_hid_finish_hwreset(). Cover letter: Snapdragon X2 Elite (glymur) Yoga Slim 7x Gen 11.

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

Record: Series of two. Patch 1 (this) is self-contained. Patch 2 is hid- lenovo input mapping for a phantom KEY_RFKILL collection; it needs this #define but this patch does not need patch 2. Evaluating only this commit: standalone YES.

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

Record: Web search of lore stable for this subject returned no relevant hits. No record of a prior rejection from stable. UNVERIFIED beyond
that: lore.kernel.org search URLs returned 403 via WebFetch.

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

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

Record: No function bodies changed. Data consumed by i2c_hid_lookup_quirk(); effect in i2c_hid_finish_hwreset().

**Step 5.2: TRACE CALLERS**

Record (git grep, no semcode MCP in this session):
- i2c_hid_lookup_quirk: __i2c_hid_core_probe() — sets ihid->quirks from HID descriptor VID/PID **before** hid_add_device().
- i2c_hid_finish_hwreset:
1. i2c_hid_parse() — .parse of i2c_hid_ll_driver, called from

     `hid_add_device()` (`drivers/hid/hid-core.c:2998`). **Every
     probe.**

2. i2c_hid_core_resume() — **only if** I2C_HID_QUIRK_RESET_ON_RESUME. This device is **not** given that quirk.

So the 1 s wait is verified on **probe**. “Every resume” is **not** explained by i2c_hid_core_resume() for this ID unless the I2C HID device is re-probed (possible on some Qualcomm/ACPI power paths). Author may have observed re-probe; that part is not proven from this tree’s resume function. Probe delay is enough.

**Step 5.3: TRACE CALLEES**

Record: Quirk path: msleep(100) + clear_bit(I2C_HID_RESET_PENDING). Default path: wait_event_timeout on ihid->wait, woken from i2c_hid_get_input() when a zero-length reset-complete report arrives.

**Step 5.4: FOLLOW THE CALL CHAIN**

Record: Boot/device enumeration: ACPI or OF I2C HID → i2c_hid probe → fetch HID descriptor (048d:83db) → quirk lookup → hid_add_device → i2c_hid_parse → hwreset. Not a syscall bug; it is the laptop keyboard coming up. Userspace-visible: ~1 s before the keyboard is ready, plus a warning.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**

Record: Same quirk already used for Hantick 5288, ITE Voyo Winpad A15, Raydium 3118. ITE not sending reset IRQ is a known family issue. This is not a one-off invention.

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

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

Record:
- Local tree: v6.18.57-155-gcdf239ca885b2, Makefile 6.18.57.
- i2c_hid_finish_hwreset() 1 s timeout + warning: **yes**.
- Quirk infrastructure: **yes**.
- G11 ID before this change: **no** (parent hid-ids.h).
- i2c-hid driver: **yes** (CONFIG_I2C_HID, ACPI and OF).
- Glymur platform bits exist in this tree (pinctrl, rpmhpd, sound). No yoga-slim7x Gen 11 DT (only original x1e80100-lenovo-yoga- slim7x.dts). These Windows-on-ARM laptops typically enumerate I2C HID from **ACPI**, so the quirk does not depend on a Gen 11 DT.

Bug exists whenever this keyboard is present on 6.18.y.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**

Record: **Clean apply.** Parent quirks table has the Voyo row immediately above the insertion point, same as the diff. USB_VENDOR_ID_ITE and neighboring ITE IDs already exist.

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

Record: No other G11 reset fix. Slim 7x rdesc fix (0x8987) is a different product. Hans’s 2023 warning change is here; it makes missing ACK non-fatal but still waits 1 s. This quirk still does useful work.

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

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

Record: drivers/hid/i2c-hid — laptop built-in keyboard over I2C-HID. **IMPORTANT** (not core mm/VFS; not staging). Affects owners of this Lenovo model, which is a real shipping machine.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**

Record: i2c-hid is mature (quirk table since 2016/2017) and still gets device-specific quirks. Typical stable material.

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

**Step 8.1: DETERMINE WHO IS AFFECTED**

Record: **Driver/hardware-specific** — only 048d:83db (Yoga Slim 7x Gen 11 ITE keyboard). Harmless to everyone else.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**

Record: Every i2c-hid probe of that keyboard (boot; also any unbind/rebind or platform re-probe). Not an unprivileged syscall exploit. Timing-independent; 100% on this hardware.

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

Record: Keyboard still works after the timeout (7bcf9ebb50f2a turned missing ACK into a warning). User impact is **~1 second delay** plus a warning on init. Severity **MEDIUM** as a hang/crash, but this is the **hardware-quirk exception**, not a panic fix.

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

Record:
- **Benefit:** Removes a 1 s keyboard delay and a false warning on a current Lenovo ARM laptop that 6.18.y users can run.
- **Risk:** Very low (3 lines, VID/PID match, existing flag).
- **Ratio:** Strongly favors backport.

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

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Real hardware bug: ITE keyboard never acks reset IRQ.
- User-visible 1 s delay + warning on probe.
- Classic HID/i2c-hid quirk; same flag already used for other ITE parts.
- +3 lines, obviously correct, HID maintainer applied.
- Driver and quirk machinery exist in this 6.18.57 tree.
- Applies cleanly; no new API; no prerequisites.
- Explicit stable exception: hardware quirk / device ID for an existing driver.

AGAINST:
- Not a crash, UAF, deadlock, or data-corruption bug.
- 7bcf9ebb50f2a made missing ACK non-fatal and hoped to reduce new quirks.
- “Every resume” is not the RESET_ON_RESUME path for this ID (unverified as a code path; author observation only).
- Patch 2 of the series is separate (not required for this fix).
- No Reported-by besides the author (still a real device).

UNRESOLVED:
- Could not fetch lore.kernel.org HTML (403); used b4 dig + patchew/openwall instead.
- Resume-on-this-ID not shown in i2c_hid_core_resume() without RESET_ON_RESUME.
- No in-tree DT for Gen 11; ACPI I2C HID still makes the quirk relevant.

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

1. Obviously correct and tested? **PASS** — copy of existing quirk row; author has the laptop; maintainer applied.
2. Fixes a real bug that affects users? **PASS** — 1 s keyboard init delay and warning on this model.
3. Important issue? **PASS** as hardware-quirk exception (not CRITICAL panic; still the class stable takes).
4. Small and contained? **PASS** — 3 lines, two files.
5. No new features or APIs? **PASS** — table entry only.
6. Can apply to the local tree? **PASS** — parent already has the table, flag, and ITE vendor ID.

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**

Record: **Hardware quirk / workaround** (and a device ID on an existing driver). Automatic stable-qualifier under the stated exceptions.

**Step 9.4: MAKE YOUR DECISION**

This should be backported to this 6.18.y tree. The i2c-hid reset-wait bug is here; the fix is a three-line quirk for one VID/PID; risk is negligible.

What it solves for stable users: Yoga Slim 7x Gen 11 keyboard init no longer burns a full second waiting for an IRQ the ITE controller never sends.

Risk vs benefit: very low risk, real delay/warning removed. No dependencies beyond code already in 6.18.57.

===============================================================
Verification:
===============================================================
- [Phase 1] Parsed tags: author Oleg Keri; maintainer Jiri Kosina SOB; no Fixes/Cc stable/Reported-by (expected).
- [Phase 2] Diff: +1 hid-ids.h, +2 i2c-hid-core.c quirks table; USB_VENDOR_ID_ITE is 0x048d; finish_hwreset quirk vs 1000 ms wait verified in tree.
- [Phase 3] git describe HEAD / make kernelversion:
v6.18.57-155-gcdf239ca885b2 / 6.18.57.
- [Phase 3] Parent 7e1d29620273b lacks G11 ID; has Voyo/Hantick/Raydium NO_IRQ_AFTER_RESET rows.
- [Phase 3] Blame: flag from 402946a8ef71e (2017); ITE Voyo fc6a31b007393 (2021); warning 7bcf9ebb50f2a (2023).
- [Phase 3] No Fixes tag. Author has no other hid commits here.
- [Phase 3] Series 1/2; patch 2 not in this tree; this patch builds alone.
- [Phase 4] b4 dig -c 2cb79eaedc9ed: lore match [email protected].
- [Phase 4] b4 dig -a: v1 standalone then v2 series (ordering only).
- [Phase 4] b4 dig -w: Jiri Kosina, Benjamin Tissoires, Mark Pearson, linux-input.
- [Phase 4] Patchew: Jiri “Applied, thank you”; kbuild robot only on patch 2 without this #define.
- [Phase 4] lore.kernel.org WebFetch 403; stable-list search found no prior discussion of this quirk.
- [Phase 5] Callers: lookup from __i2c_hid_core_probe; finish_hwreset from i2c_hid_parse (probe) and resume only with RESET_ON_RESUME (this ID does not set that).
- [Phase 5] hid_add_device → ll_driver->parse at hid-core.c:2998 verified.
- [Phase 6] Buggy 1 s wait present; G11 ID not in parent; glymur support present; no Gen 11 DT; ACPI I2C HID still applies.
- [Phase 6] Parent table context matches diff; clean apply.
- [Phase 8] Failure mode: 1 s delay + warning, keyboard still works; severity MEDIUM; quirk exception applies.
- UNVERIFIED: author’s “every resume” vs code (resume does not call finish_hwreset without RESET_ON_RESUME). Did not drive the verdict; probe path is verified.

**YES**

 drivers/hid/hid-ids.h              | 1 +
 drivers/hid/i2c-hid/i2c-hid-core.c | 2 ++
 2 files changed, 3 insertions(+)
drivers/hid/hid-ids.h +1 -0
index 11f120a5d1b90..a10b4ae0e3d8e 100644
@@ -737,6 +737,7 @@
 #define I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720	0x837a
 #define USB_DEVICE_ID_ITE_LENOVO_YOGA900	0x8396
 #define I2C_DEVICE_ID_ITE_LENOVO_YOGA_SLIM_7X_KEYBOARD	0x8987
+#define I2C_DEVICE_ID_ITE_LENOVO_YOGA_SLIM_7X_G11_KEYBOARD	0x83db
 #define USB_DEVICE_ID_ITE8595		0x8595
 #define USB_DEVICE_ID_ITE_MEDION_E1239T	0xce50
 
drivers/hid/i2c-hid/i2c-hid-core.c +2 -0
index e5a4c7deba502..62b3dd0390a7c 100644
@@ -126,6 +126,8 @@ static const struct i2c_hid_quirks {
 		I2C_HID_QUIRK_NO_IRQ_AFTER_RESET | I2C_HID_QUIRK_BAD_INPUT_SIZE },
 	{ I2C_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_VOYO_WINPAD_A15,
 		I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
+	{ USB_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_LENOVO_YOGA_SLIM_7X_G11_KEYBOARD,
+		I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
 	{ I2C_VENDOR_ID_RAYDIUM, I2C_PRODUCT_ID_RAYDIUM_3118,
 		I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
 	{ USB_VENDOR_ID_ALPS_JP, HID_ANY_ID,
Signature · 1 line
2.53.0
author maintainer
#262 lore raw

PATCH 1/1 ALSA: hda/realtek: Enable mute LED on HP Laptop 15-dy0xxx

In reply to Sasha Levin

From: Carl Quist <[email protected]>

[ Upstream commit eb2b516900f2cff6c931a0d664a625ee93855779 ]

The mute LED on the HP Laptop 15-dy0xxx (PCI SSID 103c:864f, Realtek ALC236) does not work, because the machine has no entry in the quirk table. No fixup is applied, so no mute LED classdev is registered and nothing ever drives the LED.

The LED is controlled by COEF index 0x07, bit 0. This was verified on the hardware with hda-verb: setting the bit lights the mute LED and clearing it turns the LED off.

hda-verb /dev/snd/hwC0D0 0x20 SET_COEF_INDEX 0x07
hda-verb /dev/snd/hwC0D0 0x20 SET_PROC_COEF 0x1 # LED on
hda-verb /dev/snd/hwC0D0 0x20 SET_PROC_COEF 0x200 # LED off

That is exactly what ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 configures, and the closely related HP Laptop 15-dw0xxx (103c:85f0) already uses it. Bit 9 (0x200) is set by default on this board and is preserved by the fixup's read-modify-write.

Tested on an HP Laptop 15-dy0xxx (SKU 7FU54UA#ABA, board 864F, BIOS F.40).

---

LLM Generated explanations, may be completely bogus:

This is a one-line Realtek HDA mute-LED quirk for PCI SSID 103c:864f. The local tree is **6.12.111** (pending-6.12). The helper it uses already exists here; only the table entry is missing.

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

**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ALSA: hda/realtek] [Enable] Enable mute LED on HP Laptop 15-dy0xxx

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Carl Quist <[email protected]> (author)
- `Link: https://lore.kernel.org/CAOtcGaxXndKxTK5MVSEcmF-
[email protected]`
- Signed-off-by: Takashi Iwai <[email protected]> (ALSA maintainer)
- No Fixes: tag (expected)
- No Cc: stable (expected)
- No Reported-by: / Tested-by: / Reviewed-by: / Acked-by:
- Hardware test is in the body (“Tested on an HP Laptop 15-dy0xxx…”)

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** HP Laptop 15-dy0xxx (PCI SSID 103c:864f, ALC236) has no quirk-table entry, so no mute-LED classdev is registered and the LED never lights.
- **Symptom:** mute LED does not track mute state.
- **Root cause:** missing SND_PCI_QUIRK for this SSID. LED is COEF index 0x07 bit 0, verified with hda-verb on real hardware.
- **Fix:** reuse existing ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 (same as HP Laptop 15-dw0xxx 103c:85f0).
- **Version info:** none beyond the model; hardware SKU 7FU54UA#ABA, BIOS F.40.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is an explicit hardware-quirk addition for a non-working mute LED.

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

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File in mainline: sound/hda/codecs/realtek/alc269.c (+1 / -0)
- Function/table: alc269_fixup_tbl[]
- Scope: single-file, one-line surgical quirk
- Local equivalent file: sound/pci/hda/patch_realtek.c (HDA codecs were not yet split in 6.12)

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: Before, SSID 103c:864f matches no entry, so snd_hda_pick_fixup() applies no ALC236 mute-LED fixup. After, that SSID maps to ALC236_FIXUP_HP_MUTE_LED_COEFBIT2, which at HDA_FIXUP_ACT_PRE_PROBE registers a mute-LED classdev. Probe-time only; no other SSIDs change.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **(h) Hardware workaround.** Missing SND_PCI_QUIRK for a laptop whose ALC236 mute LED is driven by COEF 0x07 bit 0.

Verified against this tree’s helper:

```4763:4776:sound/pci/hda/patch_realtek.c
static void alc236_fixup_hp_mute_led_coefbit2(struct hda_codec *codec,
                                          const struct hda_fixup *fix,
int action)
{
        struct alc_spec *spec = codec->spec;

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

alc_update_coef_idx() is RMW ((val & ~mask) | bits_set), so bit 9 (0x200) is preserved as the commit claims.

**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct: one existing fixup, one SSID, gated by PCI subsystem ID. Regression risk is limited to this exact machine. No API, locking, or hot-path change.

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

**Step 3.1: BLAME THE CHANGED LINES**
Record: There is no “buggy line” — the bug is a **missing** table entry. The helper alc236_fixup_hp_mute_led_coefbit2 was added in 0659400f18c0e (2023-07-19, “Enable Mute LED on HP Laptop 15s-eq2xxx”) with Cc: stable. That helper is an ancestor of this HEAD.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable. The missing-SSID pattern is the same as many later quirk adds.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: This tree already contains the same class of patches, e.g.:
- dda834cc2048d — HP 14s-dr1xxx mute LED (0x86c8, COEFBIT2), landed 2026-09-21
- dc60a7d2dc78b — HP 15s-eq1xxx mute LED (0x8706, COEFBIT2)
- b685eba97a5ae — HP 14s-dr5xxx mute LED
Standalone; not patch X/Y.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: git log --author="Carl Quist" -- sound/pci/hda/ in this tree is empty. Author is an end-user reporter, not the subsystem maintainer. Takashi Iwai applied the patch the same day.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Only prerequisite is ALC236_FIXUP_HP_MUTE_LED_COEFBIT2, present here. The commit mentions 15-dw0xxx (103c:85f0, b28d3d0841a60, 2026-07-03) as a related user of the same fixup; that SSID is **not** in this tree and is **not** required. Can apply standalone.

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

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c eb2b516900f2c →
https://patch.msgid.link/CAOtcGaxXndKxTK5MVSEcmF-
[email protected]
- b4 dig -a: single v1, 2026-08-05, Carl Quist. No later revision.
- Thread: Takashi Iwai: “Applied now. But at the next time, please submit to [email protected], instead.”
- No NAK, no stable objection, no requested changes.

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: b4 dig -w recipients: Carl Quist, alsa-devel@alsa- project.org, [email protected]. Subsystem maintainer received and applied it.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: The submission is the bug report. Hardware-verified with hda- verb and a named SKU. Lore fetch of the search URL returned 403; the thread was obtained via b4 dig -m instead.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone. Sibling 15-dw0xxx (b28d3d0841a60) was AUTOSEL’d for 6.18 — same pattern, different SSID. Not a dependency.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: Web search of lore.kernel.org/stable for this subject did not return a 15-dy0xxx discussion. No evidence it was rejected for stable. Closely analogous COEFBIT2 mute-LED quirks are already in this 6.12 tree.

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

**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: Table alc269_fixup_tbl[] only. Runtime path uses existing alc236_fixup_hp_mute_led_coefbit2() → snd_hda_gen_add_mute_led_cdev() → coef_mute_led_set() → alc_update_coef_led().

**Step 5.2: TRACE CALLERS**
Record: alc269_fixup_tbl is passed from the ALC269-family probe path:

```12583:12584:sound/pci/hda/patch_realtek.c
        snd_hda_pick_fixup(codec, alc269_fixup_models,
                       alc269_fixup_tbl, alc269_fixups);
```

That is codec probe (device enumeration), not IRQ or a syscall hot path.

**Step 5.3: TRACE CALLEES**
Record: alc_update_coef_idx() → __alc_update_coefex_idx() does RMW on NID 0x20. Matches the hda-verb sequence in the commit (SET_COEF_INDEX 0x07 on 0x20).

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace mute → LED classdev brightness → coef_mute_led_set(). Reachable on this laptop whenever the user mutes. Not a crash path.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Many HP ALC236 laptops in this tree already use ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 (0x84ae, 0x86c1, 0x86c8, 0x8706, 0x87b7, 0x87d3, …). This is the same established pattern.

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- Tree: p-6.12-2-gd38d58a4e0359, make kernelversion = **6.12.111**, branch pending-6.12
- git merge-base --is-ancestor eb2b516900f2c HEAD → not an ancestor (commit not in this tree)
- 0x864f is absent from sound/pci/hda/patch_realtek.c
- Helper and enum ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 are present (since v6.5-era 0659400f18c0e)
- Insertion neighbors exist: 0x861f then 0x869d at lines 10898–10899

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Path remap only (alc269.c → patch_realtek.c). Context around 0x861f/0x869d matches. Expected: **clean apply with path adjustment**, same as dda834cc2048d already on this branch.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No 15-dy0xxx / 0x864f entry. Other COEFBIT2 HP mute-LED quirks are present; none covers this SSID.

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

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: sound/pci/hda Realtek codec quirks. **IMPORTANT** for laptop audio (very common driver), but this one line is **platform/device- specific**.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Active: recent mute-LED quirk backports on this same file (faee5b4612c26, dda834cc2048d, …). Mature quirk table; this is a routine SSID add, not new infrastructure.

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

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / platform-specific:** HP Laptop 15-dy0xxx with PCI SSID 103c:864f and CONFIG_SND_HDA_CODEC_REALTEK. No other machines match this SSID.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Every mute toggle on that laptop. Unprivileged users can trigger the LED path, but the current bug is “LED never works,” not a crash.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Mute LED stuck/off. **MEDIUM** for that hardware (broken indicator, not oops/corruption). Still the documented stable **hardware- quirk exception**.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** restores mute LED on a shipping HP 15-dy0xxx; same fix already used on many ALC236 HP models in this tree.
- **Risk:** very low — 1 line, SSID-gated, existing helper.
- **Ratio:** strongly favorable.

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

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Hardware codec quirk (SND_PCI_QUIRK) — explicit stable exception
- Real, hardware-tested bug (named SKU, hda-verb proof)
- One line; existing ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 already in 6.12
- ALSA maintainer applied v1 with no objections
- Same class of quirks already backported to this tree (14s-dr1xxx two days ago)
- Sibling 15-dw0xxx quirk was AUTOSEL’d for 6.18

AGAINST:
- Not a crash, security issue, or data-corruption fix (LED-only)
- Mainline path differs (alc269.c vs patch_realtek.c) — trivial remap
- Author is not a regular ALSA contributor

UNRESOLVED:
- Direct lore.kernel.org HTTP fetch returned 403; thread recovered via b4 dig -m
- No dedicated stable-list thread found for this exact subject

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — 1-line SSID map; tested on named hardware; maintainer applied
2. Fixes a real bug that affects users? **PASS** — mute LED never driven on this laptop
3. Important issue? **PASS** under the hardware-quirk exception (severity MEDIUM: LED, not crash)
4. Small and contained? **PASS** — +1 line, one table
5. No new features or APIs? **PASS** — wires an existing fixup
6. Can apply to the local tree? **PASS** — helper present; insert between 0x861f and 0x869d in patch_realtek.c

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Hardware quirk / audio codec quirk** (SND_PCI_QUIRK in Realtek HDA). Qualifies automatically.

**Step 9.4: MAKE YOUR DECISION**
The 6.12 tree already has the COEFBIT2 helper and many HP ALC236 mute- LED SSIDs. This commit only adds 103c:864f. That is the standard, low- risk stable backport for Realtek laptop LED quirks.

Detailed explanation:
- **Problem:** Without a quirk, ALC236 on HP 15-dy0xxx never registers a mute-LED classdev, so the LED stays dead.
- **Why it matters here:** 6.12 users on that SKU still see a broken LED; the driver and helper are already in this tree.
- **Rules:** Matches the quirk exception; small, tested, no new API.
- **Risk vs benefit:** Benefit is a working LED on one HP model; risk is confined to that SSID.
- **Backport note:** Change the path to sound/pci/hda/patch_realtek.c; no other code changes needed.

Verification:
- [Phase 1] Parsed tags: author SOB Carl Quist; Link to lore Message-ID; maintainer SOB Takashi Iwai; no Fixes/Cc:stable/Reported-by
- [Phase 2] Diff: +1 SND_PCI_QUIRK(0x103c, 0x864f, …, ALC236_FIXUP_HP_MUTE_LED_COEFBIT2) in alc269_fixup_tbl
- [Phase 2] Helper in this tree at alc236_fixup_hp_mute_led_coefbit2() uses COEF 0x07 mask/on=1; __alc_update_coefex_idx is RMW
- [Phase 3] git log -S alc236_fixup_hp_mute_led_coefbit2 -- sound/pci/hda/patch_realtek.c → 0659400f18c0e (2023-07-19, Cc:stable); git merge-base --is-ancestor 0659400f18c0e HEAD → present
- [Phase 3] git merge-base --is-ancestor eb2b516900f2c HEAD → not in this tree
- [Phase 3] Related in-tree backports: dda834cc2048d (14s-dr1xxx), dc60a7d2dc78b (15s-eq1xxx)
- [Phase 4] b4 dig -c eb2b516900f2c: v1 only; Takashi “Applied now”; CC’d alsa-devel + tiwai
- [Phase 4] Sibling b28d3d0841a60 (15-dw0xxx) AUTOSEL 6.18; not an ancestor of this HEAD and not required
- [Phase 5] Probe uses snd_hda_pick_fixup(..., alc269_fixup_tbl, ...)
- [Phase 6] git describe HEAD = p-6.12-2-gd38d58a4e0359; make kernelversion = 6.12.111; 0x864f absent; insert point 0x861f/0x869d at lines 10898–10899
- [Phase 8] Failure mode: mute LED not driven; severity MEDIUM; SSID- gated
- UNVERIFIED: lore.kernel.org HTTP 403 on search/direct Message-ID URLs (thread obtained via b4 instead)
- UNVERIFIED: no dedicated stable@ thread found for this exact commit

**YES**

 sound/hda/codecs/realtek/alc269.c | 1 +
 1 file changed, 1 insertion(+)
sound/hda/codecs/realtek/alc269.c +1 -0
index 68d5e5aa7f62d..f2b0eb8501a78 100644
@@ -6772,6 +6772,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x103c, 0x860c, "HP ZBook 17 G6", ALC285_FIXUP_HP_GPIO_AMP_INIT),
 	SND_PCI_QUIRK(0x103c, 0x860f, "HP ZBook 15 G6", ALC285_FIXUP_HP_GPIO_AMP_INIT),
 	SND_PCI_QUIRK(0x103c, 0x861f, "HP Elite Dragonfly G1", ALC285_FIXUP_HP_GPIO_AMP_INIT),
+	SND_PCI_QUIRK(0x103c, 0x864f, "HP Laptop 15-dy0xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
 	SND_PCI_QUIRK(0x103c, 0x869d, "HP", ALC236_FIXUP_HP_MUTE_LED),
 	SND_PCI_QUIRK(0x103c, 0x86c1, "HP Laptop 15-da3001TU", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
 	SND_PCI_QUIRK(0x103c, 0x86c7, "HP Envy AiO 32", ALC274_FIXUP_HP_ENVY_GPIO),
Signature · 1 line
2.53.0
author maintainer
#263 lore raw

PATCH 1/1 Bluetooth: hci_bcsp: validate received packet lengths

In reply to Sasha Levin

From: Li Qiang <[email protected]>

[ Upstream commit ceea75ad8925425ee6520ead964b55888fe871ec ]

The BCSP transmit path reads an HCI command header when an extension packet has only been tested for a nonzero length. Its LE configuration packet handler also indexes bytes through offset seven without a length check.

Validate the complete command and LE configuration packet headers before accessing their fields.

---

LLM Generated explanations, may be completely bogus:

The local tree is **6.12.111** (p-6.12-3-g710455e2077bb). The buggy BCSP length handling is in this checkout; the candidate is not. The verdict is for this tree only.

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

**Step 1.1: PARSE THE SUBJECT LINE**
Record: [Bluetooth / hci_bcsp] [validate] [check command and LE-config packet lengths before field access]

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Li Qiang <[email protected]> (author)
- Signed-off-by: Luiz Augusto von Dentz <[email protected]> (Bluetooth maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, Link:, or Cc: [email protected]
- Ignore pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] markers
- Absence of Fixes:/Cc: stable is expected for this review and is **not** a negative signal

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** BCSP TX reads an HCI command header without a full-header length check; LE config RX indexes through offset 7 without a length check.
- **Symptom:** Out-of-bounds read of skb/payload bytes on truncated packets (cover letter: “out-of-bounds accesses … when data is truncated”).
- **Version info:** none in the commit; code dates to git origin (2005).
- **Root cause (author):** fields are used before the complete header is known to be present.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is a bounds-check / OOB fix, even though the series is titled “harden packet and transport parsing.”

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

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/bluetooth/hci_bcsp.c only (+4 / -1)
- Functions: bcsp_prepare_pkt(), bcsp_handle_le_pkt()
- Scope: single-file surgical fix

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Hunk 1 (bcsp_prepare_pkt):** before: if hciextn && chan == 5, always read hci_command_hdr.opcode and data[HCI_COMMAND_HDR_SIZE].
after: only if len > HCI_COMMAND_HDR_SIZE (3). Short commands skip vendor-extension rewrite and are slipped as-is.
- **Hunk 2 (bcsp_handle_le_pkt):** before: data[1], data[2], memcmp(&data[4], …, 4) with no skb->len check. after: return if rx_skb->len < 8.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Memory safety / out-of-bounds read (category d).**
- TX: HCI_COMMAND_HDR_SIZE is 3. Userspace HCI sockets accept len >= 4 (1 type byte + 3-byte command). After skb_pull(1), skb->len can be **exactly 3**. For vendor OGF 0x3f, the driver then does `*(data
+ 3) — one byte past skb->len`.
- If that byte has high nibble 0xc0, len -= 4 makes len == -1, and the BCSP header is built with a bogus length (hdr[1]/hdr[2] from a signed -1).
- RX: memcmp of bytes 4–7 with no len check. The receive state machine normally makes that path in-bounds when the header length field is 4; the extra check is defensive.

**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct and minimal. Skipping extension parsing on short packets is the safe default. Early-return on short LE frames does not drop valid conf/sync packets (those are 4-byte hdr + 4-byte payload = 8). Regression risk is very low. No API/data-structure change.

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

**Step 3.1: BLAME THE CHANGED LINES**
Record: Buggy TX/RX logic is from 1da177e4c3f41 (Linux-2.6.12-rc2, 2005), with later style/API churn only (c5ec514016d1a6, 8083ad1cf910dc, 59ae1d127ac0ae). Present for the entire life of this driver, including 6.12.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent 6.12 BCSP work includes b420a4c7f915f (syzbot NULL deref in bcsp_recv), timer/kfree fixes. No prior length check. This commit is **standalone** (series 3/5; other patches touch bfusb.c, btmrvl_main.c, hci_ldisc.c, hci_qca.c).

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Li Qiang has no other drivers/bluetooth/ commits in this 6.12 tree. Luiz von Dentz is a listed Bluetooth driver maintainer and applied the series to bluetooth-next (a4c72c8c7cef).

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Uses existing HCI_COMMAND_HDR_SIZE and rx_skb->len. A surgical patch against this file applied cleanly (git apply --check exit 0).

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

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c a4c72c8c7cef → https://patch.msgid.link/6fb9de3e499424f798
[email protected]
- Cover: [PATCH 0/5] Bluetooth: harden packet and transport parsing (2026-07-16)
- b4 dig -a: **v1 only** (no v2/v3)
- Applied 2026-07-20 by Luiz to bluetooth-next as a4c72c8c7cef
- No NAK on patch 3/5. BlueZ CI failed **patch 5/5** (hci_qca.c context), not this file.
- Patch 2/5 (btmrvl) later caused a Chromebook regression (Marek Szyprowski). That is a **different** patch; not this one.

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc [email protected], Marcel Holtmann, Luiz von Dentz, LKML. Maintainer applied it. No extra Reviewed-by on 3/5.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla report for this specific OOB. Cover letter describes truncated-header OOB as the failure mode. Trigger reconstructed from this tree’s hci_sock_sendmsg + bcsp_prepare_pkt.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Series of five independent driver/transport bounds checks. 3/5 does not depend on 1/2/4/5. Do not pull the others as prerequisites.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org WebFetch returned 403. No stable-thread hit via b4/openwall for this subject. UNVERIFIED whether anyone already asked stable@ for this SHA.

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

**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: bcsp_prepare_pkt, bcsp_handle_le_pkt

**Step 5.2: TRACE CALLERS**
Record:
- bcsp_prepare_pkt: bcsp_dequeue() (unrel, rel, and ACK). Dequeue is hci_uart_proto.dequeue → hci_uart_tx_wakeup / TTY write worker.
- bcsp_handle_le_pkt: bcsp_complete_rx_pkt() when BCSP channel 1, unreliable → bcsp_recv() → hci_uart_tty_receive. Syzbot has already reached bcsp_recv via TTY (TIOCSTI) in this tree.

**Step 5.3: TRACE CALLEES**
Record: TX reads hci_opcode_ogf / raw data[], then alloc_skb + SLIP. RX uses memcmp, alloc_skb, skb_queue_head, hci_uart_tx_wakeup.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: TX is reachable from userspace sendmsg on an HCI RAW/USER socket bound to a BCSP UART device. RAW vendor OGF 0x3f needs CAP_NET_RAW (ogf > HCI_SFLT_MAX_OGF); USER channel bind needs CAP_NET_ADMIN. Not unprivileged, but a real kernel OOB on a live HCI UART. RX is reachable from the UART/TTY receive path (including fuzzing).

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same series adds analogous header-length checks in bfusb/btmrvl/qca. H5 (hci_h5.c) does not implement this vendor- extension rewrite. No duplicate BCSP fix in this tree.

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes.
- drivers/bluetooth/hci_bcsp.c:197 if (hciextn && chan == 5) with no length check
- drivers/bluetooth/hci_bcsp.c:405-406 LE handler indexes data[4] without len < 8
- Bug introduced in 2.6.12-era origin; not post-6.12

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** for the actual edits (git apply --check succeeded). Nearby mainline context uses timer_delete; 6.12 still has del_timer in bcsp_pkt_cull. That is unused context for a tight hunk. No semantic rework needed.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: git log --grep='validate received' on this file: empty. No earlier equivalent check.

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

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: Bluetooth HCI UART BCSP (CONFIG_BT_HCIUART_BCSP) — CSR BlueCore UART. **IMPORTANT** for those devices, not core mm/VFS. Still a production protocol path, and this file is actively fuzzed.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Bluetooth in this tree is active (many btusb/btintel/hci_bcsp stable fixes). BCSP itself is mature; this is an old bug, not a new- feature fallout.

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

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Config-specific (BT_HCIUART_BCSP) + HCI UART BCSP hardware. TX trigger also needs an HCI socket send of a short vendor command.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- TX: HCI command packet, hciextn (default true), len == 3 after type byte, OGF 0x3f. Constructible from userspace with CAP_NET_RAW/CAP_NET_ADMIN.
- RX: truncated LE frame; memcmp path is likely already in-bounds if the state machine honors the header length field.
- Not a hot every-packet path for well-formed kernel-generated commands (hci_cmd_sync_alloc always includes the 3-byte header).

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: One-byte (or more, if data is short) read past skb->len on TX; possible wrong BCSP channel/length if the spilled byte looks like an HCI extension. May stay inside skb tailroom (not always a KASAN crash). **Severity: HIGH** (memory safety / OOB), not a guaranteed panic.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record: Benefit medium-high (closes a long-standing OOB in a fuzzed UART protocol). Risk very low (4 lines, skip-on-short-packet). Ratio favors backport.

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

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Real OOB read in bcsp_prepare_pkt when a 3-byte vendor HCI command is sent on BCSP
- RX handler indexes through byte 7 with no length guard
- 4 insertions / 1 deletion, obviously correct
- Code present in this 6.12 tree since origin
- No prerequisites; applies here
- Bluetooth maintainer applied it to bluetooth-next
- Same class as other packet-length checks already landing in this tree

AGAINST:
- No syzbot/user crash report for this exact bug
- TX trigger is privileged
- RX len < 8 check is likely redundant given the BCSP RX state machine
- Sister patch 2/5 in the same series had a regression (different driver)
- Framed as “hardening”

UNRESOLVED:
- lore.kernel.org WebFetch 403; no confirmed stable@ discussion
- Whether skb tailroom would make the 1-byte TX OOB a KASAN hit on this kernel’s allocator

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — maintainer-applied; logic is local and readable
2. Fixes a real bug that affects users? **PASS** — OOB on truncated vendor commands over BCSP UART
3. Important issue (crash, security, corruption, deadlock)? **PASS** — OOB / memory-safety (HIGH, not proven panic)
4. Small and contained? **PASS** — one file, five lines
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — buggy code present; surgical apply succeeded

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/docs exception. Ordinary small memory- safety fix.

**Step 9.4: MAKE YOUR DECISION**
This belongs on 6.12. The TX length check closes a real out-of-bounds field access on a path that HCI sockets can hit; the RX check is cheap and harmless. Scope, risk, and local applicability all fit stable rules.

===============================================================
Verification
===============================================================
- [Phase 1] Parsed subject/body/tags: author Li Qiang, SOB Luiz von Dentz; no Fixes/syzbot/Cc-stable
- [Phase 2] Diff: hci_bcsp.c +4/-1 in bcsp_prepare_pkt and bcsp_handle_le_pkt
- [Phase 2] HCI_COMMAND_HDR_SIZE is 3 in include/net/bluetooth/hci.h
- [Phase 2] hciextn defaults to true (module_param)
- [Phase 3] git blame: lines from 1da177e4c3f41 (2.6.12-rc2)
- [Phase 3] git merge-base --is-ancestor a4c72c8c7cef HEAD → not in this tree (exit 1); object exists as a commit
- [Phase 3] git log --grep='validate received' -- drivers/bluetooth/hci_bcsp.c → empty
- [Phase 4] b4 dig -c a4c72c8c7cef: lore msgid 6fb9de3e…; v1-only series; applied to bluetooth-next
- [Phase 4] b4 dig -w: linux-bluetooth, Holtmann, von Dentz
- [Phase 4] mbox: no NAK on 3/5; CI fail was qca 5/5; btmrvl 2/5 later regressed Chromebooks
- [Phase 4] UNVERIFIED: stable@ mailing list (lore WebFetch 403)
- [Phase 5] Callers: bcsp_dequeue → UART TX; bcsp_complete_rx_pkt → bcsp_recv
- [Phase 5] hci_sock_sendmsg: len < 4 rejected; after type pull, skb->len can be 3; OGF 0x3f on RAW needs CAP_NET_RAW
- [Phase 6] git describe HEAD / Makefile: 6.12.111; buggy if (hciextn && chan == 5) still present
- [Phase 6] git apply --check of the two hunks: success
- [Phase 8] Failure mode: OOB read past skb->len on TX vendor- extension parse; severity HIGH
- UNVERIFIED: whether this 1-byte read is always inside skb tailroom vs KASAN-poisoned

The TX path can read past a 3-byte HCI command; the fix is four lines and applies to this 6.12 tree without extra commits.

**YES**

 drivers/bluetooth/hci_bcsp.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/bluetooth/hci_bcsp.c +4 -1
index 591abe6d63ddb..6461492cf653b 100644
@@ -194,7 +194,7 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data,
 		return NULL;
 	}
 
-	if (hciextn && chan == 5) {
+	if (hciextn && chan == 5 && len > HCI_COMMAND_HDR_SIZE) {
 		__le16 opcode = ((struct hci_command_hdr *)data)->opcode;
 
 		/* Vendor specific commands */
@@ -402,6 +402,9 @@ static void bcsp_handle_le_pkt(struct hci_uart *hu)
 	u8 sync_pkt[4]     = { 0xda, 0xdc, 0xed, 0xed };
 
 	/* spot "conf" pkts and reply with a "conf rsp" pkt */
+	if (bcsp->rx_skb->len < 8)
+		return;
+
 	if (bcsp->rx_skb->data[1] >> 4 == 4 && bcsp->rx_skb->data[2] == 0 &&
 	    !memcmp(&bcsp->rx_skb->data[4], conf_pkt, 4)) {
 		struct sk_buff *nskb = alloc_skb(4, GFP_ATOMIC);
Signature · 1 line
2.53.0
author maintainer
#264 lore raw

PATCH 1/1 ksmbd: allow I/O on directory named streams

In reply to Sasha Levin

From: Namjae Jeon <[email protected]>

[ Upstream commit 8184c425a19d44f138d42b44cc363917c08e5f1c ]

Named streams are stored as extended attributes on the base inode. The VFS read and write helpers reject directory inodes before or together with checking whether the handle represents a stream.

Permit read and write operations when a directory-backed handle is a named stream. Continue rejecting direct I/O on ordinary directory handles.

This fixes creation of the directory stream in smb2.getinfo.complex.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit message forensics

**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ksmbd] [allow] permit read/write on named streams whose base inode is a directory

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Namjae Jeon <[email protected]> (ksmbd maintainer; author)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, Link:, or Cc: stable@
- Absence of Fixes:/Cc: stable is expected for this review pipeline and is not a negative signal
- Ignore any later [Upstream commit ...] / Signed-off-by: Sasha Levin markers; they are candidate-prep, not selection

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** Named streams are stored as xattrs on the base inode. ksmbd_vfs_read() and ksmbd_vfs_write() reject directory inodes before (read) or together with (write) the stream-handle check, so a directory-backed stream never reaches ksmbd_vfs_stream_read() / ksmbd_vfs_stream_write().
- **Symptom:** SMB read/write of a named stream on a directory fails (-EISDIR / -EACCES). Samba smbtorture smb2.getinfo.complex cannot create DNAME:streamtwo.
- **Version info in the message:** none.
- **Root cause:** directory inode check is applied to the base inode, not to whether the handle is a stream.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. This is an explicit protocol-correctness fix for existing ADS I/O. “Allow” here means “stop rejecting a path that already exists,” not a new API.

## Phase 2: Diff analysis

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: fs/smb/server/vfs.c — 3 insertions, 2 deletions
- Functions: ksmbd_vfs_read(), ksmbd_vfs_write()
- Scope: single-file surgical fix

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Read, before:** S_ISDIR(inode) → immediate -EISDIR, so ksmbd_stream_fd() is never reached.
- **Read, after:** reject only S_ISDIR && !ksmbd_stream_fd(fp). Stream handles fall through to ksmbd_vfs_stream_read() (xattr).
- **Write, before:** inside the SMB access check, S_ISDIR forces -EACCES even for stream fds.
- **Write, after:** same access check, but directory rejection is skipped for ksmbd_stream_fd(fp), then the existing stream-write branch runs.
- Ordinary directory I/O is still rejected. Stream I/O still never calls kernel_read() / kernel_write().

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Logic / protocol correctness.** Directory ADS is valid SMB. The VFS helpers treated the base directory inode as “no I/O allowed” and never used the xattr stream path.

**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct and minimal. ksmbd_stream_fd() is an existing inline (fp->stream.name != NULL). After the exemption, both functions still take the stream branch and goto out / return before VFS file I/O, so the __kernel_write_iter WARNING that motivated the earlier directory-write ban is not reintroduced. Regression risk is very low.

## Phase 3: Git history investigation

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Read S_ISDIR check: f44158485826c0 (“cifsd: add file operations”, 2021). Directory stream **reads** have been broken since ksmbd’s original file ops.
- Write S_ISDIR check: 2a879da5c34a1 (“ksmbd: fix the warning from __kernel_write_iter”), upstream b37f2f332b40, present here as v6.12.25~99. That stable backport banned all directory writes to avoid WARNING: CPU: ... at fs/read_write.c:599 __kernel_write_iter. It sits **before** the stream-fd check, so it also blocked directory **stream** writes that previously went through xattrs.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The write-side bug is a follow-on to 2a879da5c34a1 / b37f2f332b40, which **is** in this tree.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Stream I/O already exists here (ksmbd_vfs_stream_read/write, d62ba16563a86 OOB check, 5c54a557bde18 empty-stream write fix, a8f5d39971bba opener creds for ADS). Neighboring 7.3 stream patches (copychunk, AAPL FinderInfo, stream delete, ::$DATA validation) are **not** prerequisites for this 3-line change. Standalone.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Namjae Jeon is the ksmbd maintainer. This landed in the ksmbd 7.3-rc1 pull among other ADS/protocol fixes. Same author previously landed 2fb9b5dc80cab (“allow write with FILE_APPEND_DATA”) on stable for a similar client-visible I/O rejection.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Uses only ksmbd_stream_fd(), already in fs/smb/server/vfs_cache.h and included from vfs.c. Parent 4ea46ea602fc7 (“protect private extended attributes”) is **not** in this tree and is not required. git show 8184c425a19d4 | git apply --check succeeds on this tree.

## Phase 4: Mailing list and external research

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record: b4 dig -c 8184c425a19d4 failed (lore.kernel.org returned an error / Anubis bot wall). Same for lore search URLs. Fallback: the commit is listed in Namjae’s **[GIT PULL] ksmbd server update for 7.3-rc1** (2026-08-23) as ksmbd: allow I/O on directory named streams, under “Correct alternate-data-stream and named-stream handling,” not under “New features.”

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: UNVERIFIED at patch-thread level (lore unreachable). The pull is from the subsystem maintainer to Linus.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: Samba smb2.getinfo.complex (source4/torture/smb2/getinfo.c) does:
- torture_setup_complex_dir(..., DNAME)
- torture_setup_complex_file(..., DNAME ":streamtwo") Historically noted as “streams on directories does not work.” That is a real client/test failure, not a theoretical one.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Part of the large 7.3 ksmbd dump, but this hunk is self- contained. Later stream patches improve enumeration, delete, copychunk, AAPL; they are not needed for this I/O gate.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: UNVERIFIED (lore blocked). No in-tree discussion of rejecting this fix.

## Phase 5: Code semantic analysis

**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: ksmbd_vfs_read(), ksmbd_vfs_write(), helper ksmbd_stream_fd().

**Step 5.2: TRACE CALLERS**
Record:
- ksmbd_vfs_read() ← smb2_read() (smb2pdu.c)
- ksmbd_vfs_write() ← smb2_write() and smb2_write_rdma_channel() Reachable from normal SMB2 READ/WRITE on a connected share. connection_type is set from the negotiated dialect, so the write-side directory check applies to SMB2/SMB3.

**Step 5.3: TRACE CALLEES**
Record: Stream path uses ksmbd_vfs_getcasexattr / ksmbd_vfs_setxattr on the dentry. Directories support xattrs; no kernel_write() on the directory inode.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace SMB client → SMB2 CREATE of dir:streamtwo (open already allowed when s_type is not explicit $DATA) → SMB2 WRITE → ksmbd_vfs_write() currently returns -EACCES. Triggerable by any client with streams enabled (KSMBD_SHARE_FLAG_STREAMS).

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Other S_ISDIR checks in ksmbd (oplock, setattr, query info) are separate. No duplicate I/O gate that would still block this path after the patch.

## Phase 6: Cross-referencing against the local tree

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. Local tree is **6.12.111** (pending-6.12, p-6.12-3-gc504cf0baa3d8). Current code:

```377:378:fs/smb/server/vfs.c
        if (S_ISDIR(inode->i_mode))
                return -EISDIR;
```
```503:505:fs/smb/server/vfs.c
        if (work->conn->connection_type) {
                if (!(fp->daccess & (FILE_WRITE_DATA_LE |
FILE_APPEND_DATA_LE)) ||
                    S_ISDIR(file_inode(fp->filp)->i_mode)) {
```

8184c425a19d4 is **not** an ancestor of HEAD. Write-side regression introduced in **v6.12.25**.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply (git apply --check exit 0). Surrounding functions match the upstream hunk context. ksmbd_stream_fd() already present.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No equivalent directory-stream I/O exemption. Stream write OOB/empty-xattr fixes are present but do not address S_ISDIR.

## Phase 7: Subsystem and maintainer context

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: fs/smb/server (ksmbd). **IMPORTANT** — in-kernel SMB3 server used by NAS/embedded/distro images. Not core mm/VFS, not staging.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained; this tree already carries many ksmbd protocol and memory-safety backports. Mature ADS support has existed since the cifsd era (2021).

## Phase 8: Impact and risk assessment

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: ksmbd users with KSMBD_SHARE_FLAG_STREAMS who have Windows/Samba/macOS clients using named streams on directories (Explorer ADS, smbtorture, some backup/metadata workflows).

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: SMB2 WRITE/READ on a handle opened as dir:stream. Common in protocol tests; less common than file ADS, but a supported SMB feature. Unprivileged share users can trigger it if they can create streams.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Client I/O fails (STATUS derived from -EISDIR/-EACCES); not a panic, UAF, or silent corruption. **MEDIUM** functional/interoperability, **HIGH** as a **stable-to-stable write regression** since v6.12.25.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** Restores directory ADS I/O; undoes over-broad fallout from the __kernel_write_iter stable fix; unblocks smb2.getinfo.complex.
- **Risk:** Very low (3 lines, existing helper, stream path still bypasses kernel_write).
- **Ratio:** favorable.

## Phase 9: Final synthesis

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Real SMB protocol bug: named streams live in xattrs; directory base inodes must still allow stream I/O.
- Write path is a **regression** from 2a879da5c34a1 (v6.12.25) already on this 6.12.y tree.
- Existing ADS stack is in this tree; this only opens the gate to it.
- 3-line, obviously correct, applies cleanly.
- Maintainer-authored; validated via smbtorture smb2.getinfo.complex.
- Does not restore the directory kernel_write WARNING.

AGAINST:
- Not a crash/security/corruption issue.
- Directory ADS is a narrower client feature than file ADS.
- Read-side rejection has existed since 2021 (enabling reads is correctness, not a 6.12.y regression).

UNRESOLVED:
- Original lore review thread (b4/lore blocked).
- Whether reviewers asked for Cc: stable.

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — logic is local and was exercised by smbtorture.
2. Fixes a real bug that affects users? **PASS** — SMB clients cannot I/O directory named streams.
3. Important issue? **PASS** — interoperability failure plus a write- side regression from a prior stable commit. Not a panic, but user- visible and already shipped in 6.12.y.
4. Small and contained? **PASS** — 3 lines, one file.
5. No new features or APIs? **PASS** — no new syscall/sysfs; streams already advertised.
6. Can apply to the local tree? **PASS** — clean apply; helpers exist.

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None of device-ID / quirk / DT / build / docs. Qualifies on ordinary bug-fix rules.

**Step 9.4: MAKE YOUR DECISION**
This tree already contains ksmbd named-stream I/O and the v6.12.25 directory-write ban. The ban is correct for ordinary directory handles but incorrectly covers stream handles, which never use kernel_write(). Backporting this exemption restores intended ADS behavior with negligible risk.

---

What this solves for 6.12.y: Windows/Samba clients that write a named stream on a directory (as smb2.getinfo.complex does with DNAME:streamtwo) currently get -EACCES on write and -EISDIR on read. After v6.12.25 that write failure is a regression from a WARNING fix. The patch is a 3-line predicate change; stream I/O still goes through xattrs, so the WARNING does not come back.

Verification:
- [Phase 1] Parsed tags: only maintainer SOB; no Fixes/Reported-by/Cc:
stable
- [Phase 2] Diff: 3 lines in ksmbd_vfs_read/ksmbd_vfs_write; exempts ksmbd_stream_fd() from S_ISDIR
- [Phase 3] git blame: read check from f44158485826c0 (2021); write check from 2a879da5c34a1 (v6.12.25~99)
- [Phase 3] git merge-base --is-ancestor 2a879da5c34a1 HEAD → yes; 8184c425a19d4 → no
- [Phase 3] git apply --check of 8184c425a19d4 → clean
- [Phase 4] b4 dig -c 8184c425a19d4 failed (lore error)
- [Phase 4] 7.3-rc1 GIT PULL lists this under ADS handling, not new features
- [Phase 4] Samba getinfo.c creates DNAME ":streamtwo" in smb2.getinfo.complex
- [Phase 5] Callers: smb2_read / smb2_write / RDMA write; stream callees are xattr helpers
- [Phase 6] git describe HEAD → p-6.12-3-gc504cf0baa3d8; make kernelversion → 6.12.111; buggy S_ISDIR present
- [Phase 8] Failure mode: failed SMB stream I/O, plus write regression since v6.12.25; not a panic
- UNVERIFIED: lore review comments / stable ML discussion (lore blocked)

**YES**

 fs/smb/server/vfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/smb/server/vfs.c +3 -2
index 3ac5f3f48121d..47c289ad9c3dc 100644
@@ -372,7 +372,7 @@ int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, size_t count,
 	ssize_t nbytes = 0;
 	struct inode *inode = file_inode(filp);
 
-	if (S_ISDIR(inode->i_mode))
+	if (S_ISDIR(inode->i_mode) && !ksmbd_stream_fd(fp))
 		return -EISDIR;
 
 	if (unlikely(count == 0))
@@ -500,7 +500,8 @@ int ksmbd_vfs_write(struct ksmbd_work *work, struct ksmbd_file *fp,
 
 	if (work->conn->connection_type) {
 		if (!(fp->daccess & (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE)) ||
-		    S_ISDIR(file_inode(fp->filp)->i_mode)) {
+		    (S_ISDIR(file_inode(fp->filp)->i_mode) &&
+		     !ksmbd_stream_fd(fp))) {
 			pr_err("no right to write(%pD)\n", fp->filp);
 			err = -EACCES;
 			goto out;
Signature · 1 line
2.53.0
author maintainer
#265 lore raw

PATCH 1/1 spi: bcm-qspi: return error from failed controller suspend

In reply to Sasha Levin

From: Jiawen Liu <[email protected]>

[ Upstream commit 44d09ef0ba690ac46d17eb05c12a47a5dd75e231 ]

spi_controller_suspend() can fail if the SPI core cannot stop the controller. bcm_qspi_suspend() ignored that error, disabled the controller clock, uninitialized the hardware, and returned success.

Return the suspend error before tearing down the clock and hardware state.

---

LLM Generated explanations, may be completely bogus:

The local tree is **6.18.53** (autosel). The buggy ignore-and-teardown path is in that base, and this is a small PM error-path fix that belongs there.

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[spi / bcm-qspi] [return] [propagate spi_controller_suspend() failure instead of tearing down clocks/hardware and reporting success]**

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Fixes: — **absent** (expected for autosel review; not a negative)
- Reported-by: — **absent**
- Tested-by: — **absent**
- Reviewed-by: Kamal Dasu <[email protected]> — **driver maintainer** (MAINTAINERS: “BROADCOM SPI DRIVER”)
- Acked-by: — none on this commit; sibling patch 2/3 was Acked-by William Zhang (Broadcom)
- `Link: https://patch.msgid.link/tencent_21BF5F9512F56D45FD9018BAF14ED2
[email protected]`
- Cc: stable@ — **absent** (expected)
- Signed-off-by: Jiawen Liu <[email protected]> (author)
- Signed-off-by: Mark Brown <[email protected]> (SPI maintainer)
- Pipeline tags ([Upstream commit 44d09ef0ba69…], Sasha Levin SOB) **ignored** per instructions

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** spi_controller_suspend() can fail when the SPI core cannot stop the controller. bcm_qspi_suspend() discarded that return value.
- **Symptom:** On that failure the driver still clk_disable_unprepare()s, calls bcm_qspi_hw_uninit(), and **returns 0**, so PM continues as if suspend succeeded.
- **Root cause (author):** ignored error, then hardware teardown.
- **Version info in message:** none.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not hidden.** It is an explicit error-propagation fix: keep clocks/HW up and fail device suspend if the controller cannot be stopped.

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES** Record:
- File: drivers/spi/spi-bcm-qspi.c — **+5 / −1**
- Function: bcm_qspi_suspend()
- Scope: **single-file surgical fix**

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: **Before:** always call spi_controller_suspend(), then disable the clock, uninit HW, return 0. **After:** if spi_controller_suspend() returns non-zero, return that error **before** clock disable / bcm_qspi_hw_uninit(). Normal success path unchanged.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Logic / PM error-path]** spi_controller_suspend() → for queued controllers, spi_stop_queue(). That polls up to 500 × ~10 ms and returns **-EBUSY** if the queue is still non-empty or ctlr->busy. This driver sets host->transfer_one = bcm_qspi_transfer_one, so spi_register_controller() calls spi_controller_initialize_queue() and sets ctlr->queued = true. Failure is therefore reachable.

Old code then:
1. Disables the controller clock
2. bcm_qspi_hw_uninit() writes MSPI registers (clears MSPI_SPCR2, write lock, status)
3. Reports success so system suspend proceeds

That can interrupt an in-flight QSPI transfer (this hardware is used as SPI NOR on Broadcom STB / iProc).

**Step 2.4: ASSESS THE FIX QUALITY**
Record: **Obviously correct** and matches the standard pattern already used by many SPI drivers (spi-rockchip, spi-qup, spi-dw-core, spi-bcm63xx, etc.). **Regression risk is low:** 5 lines, error path only. Residual SPI-core quirk: spi_controller_suspend() still calls __spi_mark_suspended() even on spi_stop_queue() failure; that is pre-existing core behavior, not introduced here, and is the same contract other drivers already rely on.

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Ignore-and-teardown dates to **fa236a7ef24048** (“spi: bcm-qspi: Add Broadcom MSPI driver”, Kamal Dasu, 2016) which called spi_master_suspend() and always returned 0.
- Rename to spi_controller_suspend(qspi->host): **ec271c04ae93b8** (2023), no functional change.
- Clock path: **1b7ad8c405c3dc** (2020) switched to clk_disable_unprepare().
- Bug has been in the driver since introduction (**v4.9-era**), not new 6.18 code.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Buggy behavior is original suspend implementation, not a later regression.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Standalone among bcm-qspi changes. Same author submitted a 3-patch series of the same pattern:
- spi: bcm63xx: return error from failed controller suspend
- spi: bcm63xx-hsspi: …
- **this patch (3/3)**
- later sibling: spi: bcmbca-hsspi: …
Each driver is independent; this patch does not need the others.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Jiawen Liu is a regular SPI error-handling contributor, not this driver’s maintainer. Weight comes from **Reviewed-by Kamal Dasu** (listed maintainer) and **SOB Mark Brown**.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **None.** Uses qspi->host and spi_controller_suspend(), both in v6.18.53. Standalone.

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 44d09ef0ba69 → **https://patch.msgid.link/tencent_21BF5F95 [email protected]**
- Subject: [PATCH 3/3] spi: bcm-qspi: return error from failed controller suspend
- b4 dig -a: **v1 only** (no v2/v3)
- Thread: Kamal Dasu **Reviewed-by**; no NAK; no request for further changes

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To Mark Brown (broonie@); Cc linux-spi, Kamal Dasu, bcm-kernel-feedback-list, Jonas Gorski, Kursad Oney, William Zhang. Right maintainers were on the patch.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: **No bugzilla/syzbot/user crash report.** Bug is derived from code review of ignored return value.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: 3/3 series; each patch is a per-driver copy of the same check. This commit is self-contained.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: **UNVERIFIED** — lore.kernel.org/stable/ HTTP 403 from this environment. SPI list thread (via b4 dig -m) had no stable nomination and no objection.

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: bcm_qspi_suspend (modified). Callees of interest:
spi_controller_suspend, clk_disable_unprepare, bcm_qspi_hw_uninit.

**Step 5.2: TRACE CALLERS**
Record: Wired via bcm_qspi_pm_ops (SIMPLE_DEV_PM_OPS / DEFINE_SIMPLE_DEV_PM_OPS), exported and used by:
- drivers/spi/spi-brcmstb-qspi.c (brcm,spi-brcmstb-qspi / brcm,spi- brcmstb-mspi)
- drivers/spi/spi-iproc-qspi.c
Called from the PM core on system suspend, not from a syscall directly.

**Step 5.3: TRACE CALLEES**
Record: spi_controller_suspend → spi_stop_queue (queued) → -EBUSY after ~5s; then __spi_mark_suspended. bcm_qspi_hw_uninit performs MMIO to stop MSPI.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: **Userspace-reachable indirectly:** suspend-to-idle/S3 with in- flight SPI (SPI-NOR, userspace spidev, etc.). Not a syscall crash path; a **system-suspend** path. If QSPI backs system flash, interrupting a write/erase is a **data-corruption** risk.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same ignore-return bug was fixed in sibling Broadcom SPI drivers in the same series. Vast majority of in-tree SPI drivers already check spi_controller_suspend()’s return.

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** git describe HEAD → v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion → **6.18.53**. v6.18.53:drivers/spi/spi-bcm-qspi.c still has:

```c
spi_controller_suspend(qspi->host);
clk_disable_unprepare(qspi->clk);
bcm_qspi_hw_uninit(qspi);
return 0;
```

Original driver commit fa236a7ef24048 **is** an ancestor of v6.18.53.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** to this 6.18.y file: the pre-image hunk is byte- identical in v6.18.53. No master vs host rename needed (already qspi->host).

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This exact fix is **not** in v6.18.53 (git log v6.18.53 --grep="return error from failed controller suspend" -- drivers/spi/ is empty). No alternate fix in the file.

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **[drivers/spi, Broadcom QSPI]** **[IMPORTANT for that hardware, PERIPHERAL globally]**. Not core mm/net, but this controller commonly backs SPI-NOR on Broadcom STB and iProc boards.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature driver (2016), still maintained (Kamal Dasu). SPI core still actively developed. This is a long-standing hole, not churn from a new subsystem.

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / platform-specific:** Broadcom STB and iProc QSPI users who suspend. Config: CONFIG_SPI_BCM_QSPI and SoC glue drivers.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: System suspend while the SPI message queue cannot drain within ~5s (-EBUSY). Unprivileged users cannot trigger it except insofar as they can generate SPI traffic and then suspend (typically privileged). **Not common** on a healthy idle bus; **realistic** if a transfer is stuck or messages keep arriving during freeze.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Failure mode:** clock off + MMIO uninit while the controller is still busy, then suspend proceeds. Outcomes: hung MMIO, incomplete SPI NOR program/erase, **possible flash corruption**, later resume with HW already torn down. **Severity: HIGH** (data corruption / crash on a real suspend error path). Not a panic on every boot.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit: medium–high** for affected platforms (correct abort of suspend; no teardown while busy).
- **Risk: very low** (5 lines, error path, maintainer-reviewed, same pattern as many drivers).
- **Ratio: favorable.**

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

**FOR:**
- Real ignored-error bug: teardown + success after spi_controller_suspend() fails
- Driver is queued (transfer_one), so -EBUSY is a real return
- Teardown while busy can corrupt SPI-NOR or touch unclocked MMIO
- 5-line, obviously correct, matches subsystem convention
- Reviewed by the listed Broadcom SPI maintainer; applied by Mark Brown
- Buggy code present since 2016; present in **this** 6.18.53 tree
- Applies cleanly; no prerequisites

**AGAINST:**
- No user Reported-by, syzbot, or Fixes:
- Trigger is the uncommon queue-stop timeout, not every suspend
- Affects only Broadcom QSPI platforms
- No explicit Cc: stable (not a negative under these rules)

**UNRESOLVED:**
- Could not query lore.kernel.org/stable/ (HTTP 403)
- No public reproducer beyond the code path

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — trivial check; maintainer Reviewed-by; in mainline via Mark Brown
2. Fixes a real bug that affects users? **PASS** — ignored PM error then unsafe HW teardown
3. Important issue (crash, security, corruption, deadlock)? **PASS** —
HIGH: possible SPI-NOR corruption / MMIO after clock gate if queue stop fails
4. Small and contained? **PASS** — +5/−1, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — hunk matches v6.18.53

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Not an exception category** (not a new ID/quirk/DT/build/docs). It is a normal small bugfix.

**Step 9.4: MAKE YOUR DECISION**
This should be backported to **this 6.18.y tree**. The bug exists here, the fix is surgical, and failing to stop the SPI queue must not be reported as a successful suspend.

---

### What the commit solves for stable users

On Broadcom QSPI, suspend used to disable the clock and uninit MSPI even when the SPI core could not stop the queue, then return success. That lets suspend continue with the controller still busy. The patch fails the device suspend instead, which is what every modern SPI driver already does.

### Stable rules and risk

Meets all six criteria: real PM bug, small, no new API, clean apply on 6.18.53. Risk is far below benefit.

### Concerns

No user reports; trigger is an error path. Sibling series patches are independent and not required. Residual __spi_mark_suspended() on failure is a pre-existing SPI-core issue, not a reason to skip this driver fix.

### Verification
- **[Phase 1]** Parsed tags: Reviewed-by Kamal Dasu; Link to msgid; no Fixes/Reported-by/Cc: stable
- **[Phase 2]** Diff: +5/−1 in bcm_qspi_suspend(); check spi_controller_suspend() before clk_disable_unprepare / bcm_qspi_hw_uninit
- **[Phase 2]** spi_stop_queue() in drivers/spi/spi.c returns -EBUSY after 500 polls
- **[Phase 2]** host->transfer_one set in bcm_qspi_probe; spi_controller_initialize_queue() sets queued = true
- **[Phase 3]** Blame: ignore-return since fa236a7ef24048 (2016); rename ec271c04ae93b8 (2023)
- **[Phase 3]** git merge-base --is-ancestor fa236a7ef24048 v6.18.53 — yes
- **[Phase 3]** Series is 3 independent per-driver patches; this one is standalone
- **[Phase 4]** b4 dig -c 44d09ef0ba69 → lore msgid above; v1 only; Kamal Reviewed-by; no NAK
- **[Phase 4]** b4 dig -w: Mark Brown + linux-spi + Broadcom list
- **[Phase 4]** UNVERIFIED: stable@ lore search (403)
- **[Phase 5]** Callers: spi-brcmstb-qspi.c, spi-iproc-qspi.c via bcm_qspi_pm_ops
- **[Phase 6]** git describe HEAD: v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion: 6.18.53
- **[Phase 6]** git show v6.18.53:drivers/spi/spi-bcm-qspi.c still has the buggy sequence; pre-image matches
- **[Phase 6]** git log v6.18.53 --grep="return error from failed controller suspend" -- drivers/spi/ empty
- **[Phase 8]** Failure mode: suspend proceeds after clock-off/HW uninit while queue busy → HIGH (corruption/crash risk)

**YES**

 drivers/spi/spi-bcm-qspi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/spi/spi-bcm-qspi.c +5 -1
index cfdaa5eaec76d..ae5545be0a45c 100644
@@ -1694,13 +1694,17 @@ EXPORT_SYMBOL_GPL(bcm_qspi_remove);
 static int __maybe_unused bcm_qspi_suspend(struct device *dev)
 {
 	struct bcm_qspi *qspi = dev_get_drvdata(dev);
+	int ret;
 
 	/* store the override strap value */
 	if (!bcm_qspi_bspi_ver_three(qspi))
 		qspi->s3_strap_override_ctrl =
 			bcm_qspi_read(qspi, BSPI, BSPI_STRAP_OVERRIDE_CTRL);
 
-	spi_controller_suspend(qspi->host);
+	ret = spi_controller_suspend(qspi->host);
+	if (ret)
+		return ret;
+
 	clk_disable_unprepare(qspi->clk);
 	bcm_qspi_hw_uninit(qspi);
 
Signature · 1 line
2.53.0
author maintainer
#266 lore raw

PATCH 1/1 i2c: acpi: Force ELAN1300 touchpads to 100 kHz

In reply to Sasha Levin

From: Abhijeeth Babu <[email protected]>

[ Upstream commit 9e9762e578db7556bea644bb5a8a2435f63544d1 ]

The ELAN1300 touchpad with HID ID 04F3:3104 on the ASUS VivoBook X513UA_KM513UA exhibits severe pointer jumps and erratic movement when the I2C bus operates at 400 kHz.

The system DSDT describes the touchpad using an I2cSerialBusV2 resource with a speed of 0x00061A80, corresponding to 400 kHz, on the AMDI0010:03 controller.

At this speed, libinput repeatedly reports:

kernel bug: Touch jump detected and discarded

Add ELAN1300 to i2c_acpi_force_100khz_device_ids so that it operates at 100 kHz.

Before the change, nine touch-jump events were recorded, with additional messages suppressed by libinput's rate limiter. With the bus forced to 100 kHz, no touch-jump events have been observed and the touchpad operates normally.

The affected system uses BIOS X513UA.319 dated 2023-05-09.

---

LLM Generated explanations, may be completely bogus:

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**

Record: [i2c: acpi] [Force] Force ELAN1300 touchpads to 100 kHz instead of the DSDT-advertised 400 kHz.

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

Record:
- Fixes: none (expected)
- Reported-by: none
- Tested-by: none (author reports before/after on the affected machine)
- Reviewed-by: none
- Acked-by: Mika Westerberg <[email protected]> (ACPI/I2C ACPI expert)
- Signed-off-by: Abhijeeth Babu (author)
- Signed-off-by: Andi Shyti (I2C host-driver maintainer; merged to i2c/i2c-for-7.3)
- `Link: https://lore.kernel.org/r/20260617192611.125513-1-
[email protected]`
- Cc: [email protected] none (expected)
- Ignored: [Upstream commit 9e9762e578db7556bea644bb5a8a2435f63544d1] and Signed-off-by: Sasha Levin (pipeline markers)

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

Record:
- Bug: ELAN1300 (HID 04F3:3104) on ASUS VivoBook X513UA_KM513UA jumps/erratically tracks when the I2C bus runs at 400 kHz.
- DSDT I2cSerialBusV2 speed 0x00061A80 = 400000 Hz on AMDI0010:03.
- Symptom: libinput kernel bug: Touch jump detected and discarded (nine events before rate limiting).
- Root cause: bus too fast for this touchpad under Linux (same class of issue as existing ELAN06FA/DLL0945 100 kHz quirks; comment notes Windows works at 400 kHz, so this is a Linux HCNT/LCNT/timing interaction, not a DSDT typo).
- Author tested: jumps gone at 100 kHz. BIOS X513UA.319 (2023-05-09).

**Step 1.4: DETECT HIDDEN BUG FIXES**

Record: Not hidden. Explicit hardware quirk. Same pattern as the existing i2c_acpi_force_100khz_device_ids entries.

---

## PHASE 2: DIFF ANALYSIS - LINE BY LINE

**Step 2.1: INVENTORY THE CHANGES**

Record:
- File: drivers/i2c/i2c-core-acpi.c (+1 / −0)
- Function: none; one ACPI ID added to
i2c_acpi_force_100khz_device_ids[]
- Scope: single-file, one-line surgical quirk

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

Record: Before, i2c_acpi_lookup_speed() left ELAN1300 at DSDT 400 kHz. After, acpi_match_device_ids() matches "ELAN1300" and sets lookup->force_speed = I2C_MAX_STANDARD_MODE_FREQ (100000). i2c_acpi_find_bus_speed() then returns that forced speed and logs FW_BUG if it differs from the ACPI-advertised speed.

**Step 2.3: IDENTIFY THE BUG MECHANISM**

Record: Category **(h) hardware workaround**. Same mechanism as DLL0945/ELAN06FA: ACPI HID match forces the adapter to 100 kHz because 400 kHz produces unusable HID reports.

**Step 2.4: ASSESS THE FIX QUALITY**

Record: Obviously correct; one table entry; no API/locking/refcount change. Regression risk is limited to other machines whose ACPI HID is also ELAN1300: they would be forced to 100 kHz. Standard-mode I2C is universally supported; previous quirks used the same HID-wide match. Bus-wide force could slow sibling devices on AMDI0010:03; that is the established tradeoff of this table.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**

Record: Table introduced by bfd74cd1fbc02 (“i2c: Force ELAN06FA touchpad I2C bus freq to 100KHz”, 2025-01-13). DLL0945 added by 0b7c9528facdb (2025-08-03). Both are in v6.18 / v6.18.53. The 400 kHz force infrastructure is 7574c0db2e68c (2019), also in this tree.

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

Record: No Fixes: tag. Not applicable. The “bug” is hardware+DSDT+Linux timing, present whenever this laptop runs a kernel that honors the 400 kHz DSDT resource.

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

Record: Recent related commits on this file: ELAN06FA (bfd74cd1fbc02), DLL0945 (0b7c9528facdb). Standalone; not patch X/Y. ELAN0678 appears in the mainline hunk context but is **not** in this 6.18 tree (git log --grep=ELAN0678 -- drivers/i2c/ empty; no matches in the tree). That ID is not a prerequisite.

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

Record: Only this I2C commit from Abhijeeth Babu. Acked by Mika Westerberg; merged by Andi Shyti (MAINTAINERS: I2C host-driver maintainer).

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

Record: Depends on i2c_acpi_force_100khz_device_ids + i2c_acpi_lookup_speed() force path. Both exist at v6.18.53. Standalone one-line add. Applies to v6.18.53 (git apply --check on that file: rc 0).

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

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

Record:
- b4 dig -c 9e9762e578db7556bea644bb5a8a2435f63544d1 →
https://patch.msgid.link/[email protected]
- Thread: https://lore-kernel.gnuweeb.org/linux-
acpi/[email protected]/T/ (3 messages)
- b4 dig -a: v1 only; no later revisions
- No NAK. Mika Acked-by. Andi: “merged to i2c/i2c-for-7.3.” No reviewer Cc: stable request (absence is not a negative).

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

Record (b4 dig -w): To Mika Westerberg, Andi Shyti; Cc linux-i2c, linux-acpi, linux-kernel. Right maintainers on the original submission.

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

Record: No syzbot/bugzilla. Author is the reporter: before (nine libinput touch-jumps) / after (none). Real hardware, BIOS dated 2023.

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

Record: Standalone v1. Same table already holds ELAN06FA and DLL0945.

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

Record: gnuweeb stable/?q=ELAN1300 hits are unrelated old stable reviews (no this patch). No recorded reason to exclude it.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: IDENTIFY KEY FUNCTIONS**

Record: Table i2c_acpi_force_100khz_device_ids; consumers i2c_acpi_lookup_speed(), i2c_acpi_find_bus_speed(). semcode MCP not available; used grep.

**Step 5.2: TRACE CALLERS**

Record: i2c_acpi_find_bus_speed() callers include:
- drivers/i2c/busses/i2c-designware-common.c (i2c_dw_acpi_round_bus_speed) — **this is the path for AMDI0010**
- i2c-amd-mp2-plat.c, i2c-synquacer.c, i2c-ls2x.c, i2c-viai2c-zhaoxin.c, i2c-usbio.c, drivers/crypto/atmel-i2c.c

AMDI0010 is in dw_i2c_acpi_match[] in i2c-designware-platdrv.c (line 359). Probe-time bus frequency, not a hot path.

**Step 5.3: TRACE CALLEES**

Record: acpi_walk_namespace → i2c_acpi_lookup_speed → acpi_match_device_ids. Then DesignWare i2c_dw_adjust_bus_speed() takes min/max with ACPI speed. Forced 100 kHz is applied at adapter setup.

**Step 5.4: FOLLOW THE CALL CHAIN**

Record: Laptop boot → DesignWare AMDI0010 probe → ACPI speed lookup → ELAN1300 match → 100 kHz. Userspace HID/libinput then sees stable reports. Reachable on any ACPI x86 laptop with this HID; not a rare config.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**

Record: Same table already has { "DLL0945", 0 } and { "ELAN06FA", 0 }. This is the third instance of the same quirk.

---

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

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

Record: Local tree is **6.18.53** (make kernelversion; git describe HEAD → v6.18.53-5049-g0f0bdc2b0dffb). At **v6.18.53** the table is:

```
{ "DLL0945", 0 },
{ "ELAN06FA", 0 },
{}
```

No ELAN1300. Matching/force path is present. Hardware (BIOS 2023) predates 6.18. Bug exists here.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**

Record: Clean apply to v6.18.53 (git apply --check rc 0). Mainline context mentions ELAN0678, which is not in 6.18; the one-line add still matches DLL0945/ELAN06FA. Difficulty: clean / trivial.

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

Record: ELAN06FA and DLL0945 are in v6.18. No other ELAN1300 workaround in hid/i2c (rg ELAN1300 only this table). No alternate fix.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

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

Record: I2C ACPI core (drivers/i2c/i2c-core-acpi.c). **IMPORTANT** for ACPI laptops: input device usability. Not mm/fs/net core, but a shared I2C path used by many x86 systems.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**

Record: Mature. Speed-force tables have existed since 2019 (400 kHz) and 2025 (100 kHz). Low churn; ID additions are the normal maintenance pattern.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: DETERMINE WHO IS AFFECTED**

Record: Driver/hardware-specific: ACPI HID ELAN1300 (reported: ASUS VivoBook X513UA_KM513UA, I2C-HID 04F3:3104, DesignWare AMDI0010). Only those machines change behavior.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**

Record: Every boot / every pointer motion at 400 kHz. Not a race. Unprivileged user just uses the touchpad. Common on the affected laptop.

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

Record: Unusable touchpad (severe jumps; libinput discards motion). Not a panic/UAF. **MEDIUM–HIGH** for affected users (primary pointing device broken). Fits the documented **hardware quirk** exception.

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

Record:
- Benefit: high for ELAN1300 laptops on 6.18.y (touchpad works).
- Risk: very low (1 line, existing table, 100 kHz is safer than 400 kHz for I2C slaves).
- Ratio: strongly favors backport.

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Real user-visible hardware bug (tested before/after).
- Classic I2C ACPI speed quirk; table and matcher already in 6.18.53.
- One line; no new API.
- Acked by Mika Westerberg; merged by Andi Shyti; no NAK.
- Same class as ELAN06FA/DLL0945 already in this tree.

AGAINST:
- Not a crash/security/corruption issue.
- Affects a specific HID, not all machines.
- No Fixes:/Cc: stable (expected; not a negative).
- HID-wide match could slow other ELAN1300 boards to 100 kHz (accepted pattern; low risk).

UNRESOLVED:
- lore.kernel.org WebFetch returned 403; discussion recovered via b4/gnuweeb/lkml.
- How many other products share ACPI HID ELAN1300 is unverified.

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

1. Obviously correct and tested? **PASS** — one ID; author measured jumps gone.
2. Fixes a real bug that affects users? **PASS** — unusable touchpad on a shipping ASUS laptop.
3. Important issue? **PASS** as hardware quirk (broken input), not a kernel oops.
4. Small and contained? **PASS** — +1 line, one file.
5. No new features or APIs? **PASS** — existing quirk table.
6. Can apply to the local tree? **PASS** — table exists; applies cleanly to 6.18.53.

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**

Record: **Hardware quirk/workaround** (and ACPI device-ID addition to an existing table). Explicitly allowed for stable.

**Step 9.4: DECISION**

This 6.18.53 tree already has the 100 kHz force table and honors DSDT 400 kHz for unmatched HIDs, so ELAN1300 laptops still misbehave here. The fix is a one-line ID add, the same mechanism already used for ELAN06FA and DLL0945, and it applies cleanly.

What it solves for stable users: ASUS VivoBook X513UA (and any other ELAN1300) touchpads stop jumping when the DesignWare AMDI0010 bus is left at 400 kHz.

Risk vs benefit: negligible code risk, restores a primary input device.

---

## Verification

- [Phase 1] Parsed tags: Acked-by Mika Westerberg; SOB Andi Shyti; Link lore msgid [email protected]; no Fixes/Reported-by/Cc-stable. Ignored Upstream/Sasha markers.
- [Phase 1] Body: DSDT 0x00061A80 = 400 kHz; libinput touch jumps; BIOS X513UA.319 2023-05-09.
- [Phase 2] Diff: +1 { "ELAN1300", 0 } in i2c_acpi_force_100khz_device_ids; i2c_acpi_lookup_speed sets I2C_MAX_STANDARD_MODE_FREQ (100000 in include/linux/i2c.h).
- [Phase 3] git blame: table from bfd74cd1fbc02 (ELAN06FA, 2025-01); DLL0945 0b7c9528facdb. Both ancestors of v6.18.53.
- [Phase 3] git merge-base --is-ancestor: ELAN06FA and DLL0945 in v6.18.53; ELAN1300 **not** in v6.18.53 tag.
- [Phase 3] No ELAN0678 in this tree; not a dependency.
- [Phase 4] b4 dig -c 9e9762e578db7556bea644bb5a8a2435f63544d1: v1 only; Mika ack; Andi merged to i2c-for-7.3; no NAK.
- [Phase 4] b4 dig -w: To Mika/Andi; Cc linux-i2c/linux-acpi.
- [Phase 4] Thread read via gnuweeb/lkml (lore.kernel.org fetch 403).
- [Phase 4] Stable list search for ELAN1300: no discussion of this patch.
- [Phase 5] Callers of i2c_acpi_find_bus_speed: DesignWare (AMDI0010), plus several other ACPI I2C hosts. AMDI0010 in i2c-designware- platdrv.c.
- [Phase 5] semcode: namespace not present; used rg.
- [Phase 6] make kernelversion / git describe HEAD: 6.18.53 / v6.18.53-5049-g0f0bdc2b0dffb.
- [Phase 6] git show v6.18.53:drivers/i2c/i2c-core-acpi.c: table has DLL0945+ELAN06FA only.
- [Phase 6] git apply --check of the hunk onto v6.18.53 file: success (rc 0).
- [Phase 7] MAINTAINERS: Andi Shyti = I2C SUBSYSTEM HOST DRIVERS.
- [Phase 8] Failure mode: broken touchpad tracking, not oops. Severity MEDIUM–HIGH for affected laptops; quirk exception applies.
- UNVERIFIED: exact number of other SKUs using ACPI HID ELAN1300.

**YES**

 drivers/i2c/i2c-core-acpi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/i2c/i2c-core-acpi.c +1 -0
index ed90858a27b7b..98ebbc973f212 100644
@@ -372,6 +372,7 @@ static const struct acpi_device_id i2c_acpi_force_100khz_device_ids[] = {
 	 */
 	{ "DLL0945", 0 },
 	{ "ELAN06FA", 0 },
+	{ "ELAN1300", 0 },
 	{}
 };
 
Signature · 1 line
2.53.0
author maintainer
#267 lore raw

PATCH 1/1 drm/amdgpu: Support some Barco AMD based graphics adapters

In reply to Sasha Levin

From: Matthew Jacob <[email protected]>

[ Upstream commit 3dc4d68ee26a7ac12069ff0562ad8935106c79b6 ]

These adapters typically are only supported by Barco on the Windows platform. However, with these changes in the linux driver, multiple monitor support should work correctly.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit message forensics

**Step 1.1:** Record: [drm/amdgpu] [Support] [add PCI IDs so Barco AMD adapters bind to amdgpu]

**Step 1.2:** Tags in the commit as given:
- Signed-off-by: Matthew Jacob <[email protected]> (author)
- Signed-off-by: Alex Deucher <[email protected]> (amdgpu maintainer)
- No Fixes:, Reported-by:, Cc: stable, Link:, Tested-by, or Reviewed-by on the committed message (absence of Fixes/`Cc:
stable` is expected for this review)

**Step 1.3:** Record:
- Bug/problem: Barco MXRT cards (AMD GPUs with Barco PCI IDs) are not in pciidlist, so amdgpu never binds; Windows-only vendor support.
- Symptom: cards do not work as DRM devices; multi-monitor setups fail.
- Version info: none in the message.
- Root cause: missing device IDs, not a logic bug in existing chip code.

**Step 1.4:** Record: Not a hidden crash/UAF fix. It is hardware enablement via PCI IDs. That is an explicit stable exception, not disguised cleanup.

## Phase 2: Diff analysis

**Step 2.1:** Record:
- File: drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c only
- +4 / -0 (four PCI ID rows)
- Function/object: pciidlist[]
- Scope: single-file surgical device-ID addition

**Step 2.2:** Record (each hunk is the same pattern):
- Before: ID missing → PCI core does not match amdgpu
- After: ID present with existing CHIP_* flags → probe uses already- supported ASIC paths
- 0x664D → CHIP_BONAIRE
- 0x693B → CHIP_TONGA
- 0x67D4 → CHIP_POLARIS10
- 0x698F → CHIP_POLARIS12
- Path: device enumeration / probe, not an error path

**Step 2.3:** Record: [Hardware workarounds / device ID addition]
Mechanism: missing IDs so existing Bonaire/Tonga/Polaris code never runs for those DIDs.

**Step 2.4:** Record: Obviously correct if the IDs belong to those families. Regression risk is low: only those four DIDs start probing; neighboring IDs are unchanged. Wrong-family assignment could mis-init a GPU; public PCI databases and nearby IDs in the same table match the chosen CHIP_* values. Original submission used // comments; the committed form dropped them (kernel style). No API or data-structure change.

## Phase 3: Git history

**Step 3.1:** Record: pciidlist has existed for the life of amdgpu. Nearby IDs (0x6649, 0x6939, 0x67D0, 0x6987) are long-standing. The gap is missing Barco DIDs, not a newly introduced logic bug. CHIP_BONAIRE / CHIP_TONGA / CHIP_POLARIS10 / CHIP_POLARIS12 are in include/drm/amd_asic_type.h (enum values 5, 11, 15, 17).

**Step 3.2:** No Fixes: tag. Buggy “code” is the absence of IDs. Not applicable as a Fixes follow-up.

**Step 3.3:** Recent related history on this file includes other PCI ID work (e.g. cyan skillfish IDs already in v6.18). Standalone; not patch X/Y. A later named-initializer rewrite of the table exists only as a later candidate on this branch, not in v6.18.53.

**Step 3.4:** Author Matthew Jacob (Feral Software) has this one amdgpu commit here. Alex Deucher, amdgpu maintainer, applied it (`CommitDate:
Wed Jul 1 2026`, SOB).

**Step 3.5:** No functional prerequisites. Applies against the existing pciidlist format in v6.18.53. Does not need new CHIP types, new helpers, or other series patches.

Upstream object 3dc4d68ee26a7ac12069ff0562ad8935106c79b6 is **not** an ancestor of v6.18 or v6.18.53.

## Phase 4: Mailing list / external research

**Step 4.1:** b4 dig -c 3dc4d68ee26a7ac12069ff0562ad8935106c79b6 failed (lore.kernel.org server error). Fallback: freedesktop amd-gfx.
- Submission: https://lists.freedesktop.org/archives/amd-
gfx/2026-June/147081.html
- First attempt (attachment, not git-format):
https://lists.freedesktop.org/archives/amd-gfx/2026-June/147075.html
- Alex asked for a proper git patch + SOB:
https://lists.freedesktop.org/archives/amd-gfx/2026-June/147077.html
- Alex applied the git-format patch the same day:
https://lists.freedesktop.org/archives/amd-gfx/2026-June/147083.html
(“Applied. Thanks!”)
- Archive index also lists later Christian König and Matthew Jacob follow-ups; **exact text of those later mails is UNVERIFIED** (message numbers not resolved). No NAK found on the applied version.

**Step 4.2:** Recipients: amd-gfx. Maintainer Alex Deucher reviewed and applied. Not a drive-by unreviewed ID dump.

**Step 4.3:** Real-world reports:
- 2023: Matthias Reichl, Barco MXRT-5600 1002:664d on HP Z240; neither radeon nor amdgpu bound; adding the ID made it work (Debian, kernel 6.2-rc3, CIK enabled). Alex noted the DID was missing from AMD’s Windows list too. https://lists.freedesktop.org/archives/amd-
gfx/2023-January/088522.html
- 2026 cover letter: Kaiser radiology PACS fleets; Barco/Kaiser had no objection.
- PCI ID databases: 664D Bonaire/W5100/MXRT-5600; 693B Tonga/W7100/MXRT-7600; 67D4 Polaris10/WX 7100/MXRT-8700; 698F Polaris12/WX 3100/MXRT 4700.

**Step 4.4:** Standalone 4-line ID add. A later separate patch proposed 0x67D7 (MXRT-6700); not required for this commit.

**Step 4.5:** lore.kernel.org/stable search returned 403; **UNVERIFIED** whether stable@ already discussed this ID set. No evidence of a NAK for stable.

## Phase 5: Code semantic analysis

**Step 5.1:** Record: pciidlist[] (static pci_device_id table). No function body edits.

**Step 5.2:** Record: PCI core match → amdgpu .id_table / MODULE_DEVICE_TABLE(pci, pciidlist) around the probe path in amdgpu_drv.c. Trigger is plugging in / booting with that GPU. Not a syscall hot path.

**Step 5.3:** Record: probe then uses existing ASIC init for CHIP_BONAIRE / CHIP_TONGA / CHIP_POLARIS10 / CHIP_POLARIS12. Those ASICs already have full driver support in this tree.

**Step 5.4:** Record: Userspace-reachable only in the sense of having the card. Unprivileged users cannot invent a PCI ID. Impact is “card works vs. no DRM driver”.

**Step 5.5:** Same table already lists sibling IDs in each family. amdgpu_unsupported_pciidlist[] does not contain these four IDs. radeon include/drm/drm_pciids.h still lacks 0x664D (Bonaire default driver is radeon unless CIK is switched to amdgpu). That does not block amdgpu IDs for Tonga/Polaris.

## Phase 6: Local tree (this checkout)

**Step 6.1:** Record:
- git describe HEAD → v6.18.53-5049-g0f0bdc2b0dffb; Makefile → **6.18.53**
- v6.18.53:drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c does **not** contain 0x664D, 0x693B, 0x67D4, 0x698F
- Surrounding rows in v6.18.53 match the candidate hunks (positional {0x1002, 0x...., PCI_ANY_ID, ...} form)
- CHIP_* enums exist in this series
- Bug/gap: missing IDs, present for as long as those families have been in amdgpu

**Step 6.2:** Record: **clean apply** onto v6.18.53. No format mismatch. (HEAD currently uses PCI_DEVICE() named initializers because a later candidate rewrote the table; that rewrite is not in v6.18.53.)

**Step 6.3:** Record: No alternate fix for these four IDs in v6.18..v6.18.53. Cyan skillfish ID adds are a different family and already in v6.18.

## Phase 7: Subsystem context

**Step 7.1:** Record: [drm/amdgpu] [IMPORTANT] — common GPU driver, not staging. Device-ID-only, not a new driver.

**Step 7.2:** Record: amdgpu is actively developed; these GCN families (CIK/VI/Polaris) are mature. Adding IDs to old ASICs is the usual pattern.

## Phase 8: Impact and risk

**Step 8.1:** Record: driver-specific / hardware-specific. Users of Barco MXRT (medical/pro multi-display) AMD cards. Not universal.

**Step 8.2:** Record: Trigger = boot with that PCI device. Common for those machines, zero for everyone else. Not a userspace exploit path.

**Step 8.3:** Record: Failure mode today = adapter unbound / no KMS, not an oops. Severity for affected users: **HIGH** (hardware dead on Linux). Severity for others: none. Not panic/UAF.

**Step 8.4:** Record:
- Benefit: high for those GPUs (kernel finally binds; Tonga/Polaris work with default amdgpu; Bonaire needs existing DRM_AMDGPU_CIK / amdgpu.cik_support=1 like other Bonaire parts)
- Risk: very low (4 rows, existing CHIP flags, maintainer-applied)
- Ratio: favorable; this is the documented device-ID exception

Caveats (not blockers):
- Two IDs were labeled “Tentative” in the mail (0x67D4 MXRT-8750 vs databases saying MXRT-8700; 0x698F MXRT-4700, which does exist). Family assignment still matches public PCI IDs.
- Bonaire 0x664D is not added to radeon; default CIK remains radeon. Same as needing CIK-in-amdgpu for other Bonaire cards.

## Phase 9: Synthesis

**Evidence FOR:**
- Canonical PCI ID addition to an existing driver
- 4 lines, existing CHIP_* only
- Families already in 6.18.y; IDs missing from v6.18.53
- Applies cleanly
- Maintainer (Alex Deucher) applied it
- Documented users (Kaiser PACS, 2023 MXRT-5600 report)
- PCI ID databases agree with the chip mapping

**Evidence AGAINST:**
- Not a crash/security/corruption fix
- Two IDs originally marked tentative
- Bonaire ID incomplete vs radeon default
- Exact later König comments UNVERIFIED

**Unresolved:** exact text of later amd-gfx follow-ups; whether stable@ already discussed it (lore 403 / b4 lore error).

**Stable rules checklist:**
1. Obviously correct and tested? **PASS** — table rows + maintainer apply; 2023 user tested 664d
2. Real bug affecting users? **PASS** — devices never bind
3. Important? **PASS** under the device-ID exception (hardware enablement, not a new driver)
4. Small and contained? **PASS** — 4 lines, one file
5. No new features/APIs? **PASS** — IDs only; no new ioctls/params
6. Can apply to this tree? **PASS** — v6.18.53 table format matches

**Exception category:** New PCI IDs on an existing driver.

This should be backported to this 6.18.y tree: the driver and ASIC support are already here; only the four IDs are missing.

Verification:
- [Phase 1] Parsed subject/tags/body: Support + two SOBs; no Fixes/Reported-by
- [Phase 2] Diff: +4 PCI IDs in pciidlist (664D Bonaire, 693B Tonga, 67D4 Polaris10, 698F Polaris12)
- [Phase 3] git describe HEAD / Makefile: 6.18.53; upstream 3dc4d68ee26a not ancestor of v6.18/v6.18.53
- [Phase 3] git show v6.18.53:drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c:
those four IDs absent; neighbor rows match the patch
- [Phase 3] CHIP_BONAIRE etc. in include/drm/amd_asic_type.h
- [Phase 4] b4 dig: lore server error; used lists.freedesktop.org instead
- [Phase 4] 147075/147077/147081/147083: resend as git patch, Alex applied
- [Phase 4] 2023 664d thread: card worked after adding the ID
- [Phase 5] MODULE_DEVICE_TABLE / .id_table = pciidlist; IDs not on amdgpu_unsupported_pciidlist
- [Phase 6] Clean apply to v6.18.53 old-style table; radeon drm_pciids.h still has 0x6649 but not 0x664D
- [Phase 7] amdgpu important, families mature
- [Phase 8] Probe-only; risk limited to those DIDs
- UNVERIFIED: full text of later Christian König replies; stable@ archive (403)

**YES**

 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -0
index 376a7cd2667f6..845ebe041563f 100644
@@ -1953,6 +1953,7 @@ static const struct pci_device_id pciidlist[] = {
 	{0x1002, 0x6646, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|AMD_IS_MOBILITY},
 	{0x1002, 0x6647, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|AMD_IS_MOBILITY},
 	{0x1002, 0x6649, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
+	{0x1002, 0x664D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
 	{0x1002, 0x6650, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
 	{0x1002, 0x6651, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
 	{0x1002, 0x6658, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
@@ -2022,6 +2023,7 @@ static const struct pci_device_id pciidlist[] = {
 	{0x1002, 0x6930, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
 	{0x1002, 0x6938, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
 	{0x1002, 0x6939, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
+	{0x1002, 0x693B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
 	/* fiji */
 	{0x1002, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI},
 	{0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI},
@@ -2050,6 +2052,7 @@ static const struct pci_device_id pciidlist[] = {
 	{0x1002, 0x67C4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
 	{0x1002, 0x67C7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
 	{0x1002, 0x67D0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
+	{0x1002, 0x67D4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
 	{0x1002, 0x67DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
 	{0x1002, 0x67C8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
 	{0x1002, 0x67C9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
@@ -2063,6 +2066,7 @@ static const struct pci_device_id pciidlist[] = {
 	{0x1002, 0x6985, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
 	{0x1002, 0x6986, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
 	{0x1002, 0x6987, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
+	{0x1002, 0x698F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
 	{0x1002, 0x6995, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
 	{0x1002, 0x6997, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
 	{0x1002, 0x699F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
Signature · 1 line
2.53.0
author maintainer
#268 lore raw

PATCH 1/1 ALSA: hda/realtek: add missing NULL check for codec->bus->pci

In reply to Sasha Levin

From: Bob Song <[email protected]>

[ Upstream commit 3b36ac93739e7b119a30affaee9c2dd41f24efbb ]

In alc269_probe(), codec->bus->pci is dereferenced without a NULL check for the ALC236 vendor ID case. Add the missing check, consistent with the existing pattern used elsewhere in the same function.

---

LLM Generated explanations, may be completely bogus:

The local checkout is **v7.3-rc4** (mainline, 7.3.0-rc4). The candidate is a one-line NULL check in alc269_probe(). The unguarded codec->bus->pci->vendor dereference is real: non-PCI HDA controllers leave bus->pci NULL, and the same function already guards other PCI accesses.

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

**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ALSA hda/realtek] [add] missing NULL check for codec->bus->pci

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Bob Song <[email protected]> (author)
- `Link: https://patch.msgid.link/20260730015302.253008-2-
[email protected]`
- Signed-off-by: Takashi Iwai <[email protected]> (ALSA maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, or Cc: stable (absence expected)
- Message-Id suffix -2 indicates patch 2 of a 2-patch series

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: alc269_probe() dereferences codec->bus->pci with no NULL check in the ALC236 (0x10ec0236) case
- Symptom: kernel oops / NULL pointer dereference at codec probe
- Root cause: missing the same codec->bus->pci && guard already used earlier in the same function
- No stack trace, reproducer, or version range in the message

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. It is an explicit NULL-deref fix (“add missing NULL check”, “consistent with the existing pattern”).

===============================================================
PHASE 2: DIFF ANALYSIS
===============================================================

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: sound/hda/codecs/realtek/alc269.c (+1 / −0)
- Function: alc269_probe()
- Scope: single-file, single-line surgical fix

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: In the 0x10ec0236 / ALC256 variant case, probe used to evaluate codec->bus->pci->vendor != PCI_VENDOR_ID_AMD unconditionally. After the change it short-circuits if codec->bus->pci is NULL and leaves spec->en_3kpull_low at its default (true). PCI-present behavior is unchanged.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- Category: NULL pointer dereference (memory safety)
- Mechanism: hda_bus.pci is optional. azx_bus_init() does bus->pci = chip->pci. Platform controllers (Tegra, ACPI HDA, CIX IPBLOQ) never set chip->pci, so it stays NULL. ALC236 probe then does pci->vendor and oopses. The 2014 commit 5100cd07d43a1 (“ALSA:
hda/realtek - Allow NULL bus->pci”) already established that Realtek must tolerate a NULL PCI pointer.

**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct; matches existing guards at lines 9119 and 9126 in the same function. No API, locking, or data-structure change. If pci is NULL, skipping the AMD-specific en_3kpull_low = false keeps the default — the same “optional PCI” policy as 2014. Regression risk is very low.

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

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Unguarded deref introduced in 69ea4c9d02b79 (“ALSA: hda/realtek - remove 3k pull low procedure”, 2023-07-13, in v6.5-rc3)
- Condition rewritten (still unguarded) in 46cdff2369cbd (“ALSA:
hda/realtek - Remodified 3k pull low procedure”, 2023-08-15, in v6.5-rc7)
- File later moved/split (6014e9021b28e, aeeb85f26c3bbe); logic unchanged until this fix

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The buggy pattern dates to 69ea4c9d02b79 / 46cdff2369cbd, both ancestors of this HEAD.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent alc269.c history is mostly laptop quirks. Sibling in the same series is 5b106b40ed220 (COEF error checks). That patch touches alc282_init / alc282_shutup / alc285_hp_init / alc294_hp_init, not alc269_probe or bus->pci. This NULL check is standalone.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Bob Song is a regular HDA contributor, not the subsystem maintainer. Takashi Iwai applied the patch. Related author work around the same time is the independent COEF-check patch.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None required. One added && in an existing if. The v2 split from the COEF patch was requested by Iwai because they are different fixes.

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

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 3b36ac93739e7 → https://patch.msgid.link/20260730015302.25
[email protected]
- v1: combined COEF checks + this NULL check (20260729063803.1453980-1)
- v2: split into two patches after maintainer request
- Applied version is v2 (latest)
- Direct lore HTTP fetch returned 403; thread recovered via b4 dig -m

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc [email protected], [email protected], linux- [email protected], [email protected]. Takashi Iwai (ALSA maintainer) applied it: “Applied to for-next branch now. Thanks.” No NAK.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by, syzbot, or bugzilla. Found by code inspection (missing check vs. siblings). No user crash report found.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Two-patch v2 series. Patch 1 = COEF error checks (independent). Iwai on v1: “Could you split the NULL check to another patch? Basically it's a completely different sort of fix from others.” Confirms this is self-contained.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search returned HTTP 403. No stable discussion in the saved mbox. UNVERIFIED whether anyone already nominated this for stable.

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

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

**Step 5.2: TRACE CALLERS**
Record: Assigned as alc269_codec_ops.probe. Invoked from the HDA codec driver probe path when a matching ID in snd_hda_id_alc269[] is enumerated (includes 0x10ec0236 “ALC236”). Probe-time, not IRQ/hot path.

**Step 5.3: TRACE CALLEES**
Record: The hunk only reads codec->core.vendor_id and codec->bus->pci->vendor, then may set spec->en_3kpull_low. That flag is later consumed by alc256_shutup().

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Device enumeration → HDA controller probe → codec bind → alc269_probe(). Reachable on any machine with an ALC236 (very common Dell/HP laptop codec). The NULL path is reached only when the controller did not assign bus->pci (platform/ACPI/Tegra/CIX). Userspace can trigger it by loading the codec module / booting with that hardware.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same function already uses if (codec->bus->pci && …) for Acer/Lenovo rename quirks. realtek.c has if (!codec->bus->pci) return. This site was the hole left by the 2023 3k-pull rewrite.

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: Yes. Local tree is v7.3-rc4-27-gf0100363d8c37 / 7.3.0-rc4. File sound/hda/codecs/realtek/alc269.c exists. The ALC236 bus->pci->vendor test is at lines 9188–9191; this commit (3b36ac93739e7) is already an ancestor of HEAD. The bug was introduced in v6.5-era code that this tree still contains.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Expected apply: clean. One context line in an if. No refactor needed on this tree. (Older stables still using sound/pci/hda/patch_realtek.c / patch_alc269() would need a path/function-name adjustment; that does not apply to this checkout.)

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This exact fix is already in HEAD. 5100cd07d43a1 (2014) added the general “allow NULL bus->pci” policy; it did not cover this later ALC236 site. No other substitute for this one-line guard.

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

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: sound/hda/codecs/realtek — HD-audio Realtek codec.
Criticality: **IMPORTANT** (extremely common laptop audio), not core mm/VFS.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively developed (quirks land frequently). The buggy PCI deref itself has been stable since 2023; this is a late correctness fix, not churn in new code.

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

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver/codec-specific: ALC236 (0x10ec0236) on a bus where hda_bus.pci is NULL. Intel/AMD PCI HDA (the usual ALC236 laptops) always set pci in azx_create() / SOF / AVS, so they do not crash. Non-PCI controllers in this tree (Tegra, ACPI HDA, CIX IPBLOQ) never assign chip->pci.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Codec probe of ALC236 with bus->pci == NULL. Not a race. Not unprivileged-syscall-exploitable beyond “device exists.” Commonness of the crash path is low; commonness of ALC236 is high. The NULL case is a supported configuration (explicit 2014 policy).

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: NULL deref → oops at probe. Audio init fails; with panic_on_oops the machine dies. Severity: **HIGH** (crash), trigger
rarity: low-to-medium.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: prevents a probe-time oops on a supported non-PCI HDA + ALC236 configuration; restores the documented NULL-PCI policy
- Risk: one && in a probe-time if; PCI systems behave identically
- Ratio: high benefit / very low risk

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

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Real NULL deref, not style
- Same function already NULL-checks bus->pci in two other places
- 2014 maintainer commit documented that Realtek must allow NULL bus->pci
- Platform HDA controllers in this tree leave pci NULL (verified: no ->pci = in tegra.c, acpi.c, cix-ipbloq.c)
- One-line, obviously correct, applied by Takashi Iwai
- Independent of the sibling COEF patch
- Code and bug exist in this tree

AGAINST:
- No user crash report or syzbot hit
- Typical ALC236 laptops use PCI HDA, so they never take the NULL path
- No Fixes: / Cc: stable from the author (not a negative per the rules)

UNRESOLVED:
- Direct lore.kernel.org HTTP was 403 (thread recovered via b4)
- No confirmed stable-list discussion
- How often ALC236 actually sits behind Tegra/ACPI/CIX HDA is unverified; the NULL-PCI design is still supported

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — one && matching existing pattern; maintainer applied to for-next
2. Fixes a real bug that affects users? **PASS** — NULL deref on a supported non-PCI HDA configuration
3. Important issue (crash, security, corruption, deadlock)? **PASS** — probe-time oops
4. Small and contained? **PASS** — +1 line, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — file and surrounding code match; commit is already in this HEAD

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/doc exception. It is a straight crash fix.

**Step 9.4: MAKE YOUR DECISION**

This is a one-line NULL check closing a hole left when the 2023 3k-pull rewrite dereferenced codec->bus->pci without the guard the rest of Realtek has used since 2014. On this v7.3-rc4 tree the buggy site exists, non-PCI controllers still leave pci NULL, and the change cannot alter PCI HDA behavior. It meets the stable rules: real crash, tiny, obviously correct.

Verification:
- [Phase 1] Parsed tags: SOB Bob Song + Takashi Iwai; Link msgid -2; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: +1 line in alc269_probe() adding codec->bus->pci && before pci->vendor
- [Phase 2] Confirmed sibling NULL checks at alc269.c:9119 and :9126
- [Phase 3] git blame: guard is 3b36ac93739e7; surrounding code from aeeb85f26c3bbe (file split)
- [Phase 3] Unguarded deref from 69ea4c9d02b79 (v6.5-rc3) and 46cdff2369cbd (v6.5-rc7); both are ancestors of HEAD
- [Phase 3] Sibling 5b106b40ed220 does not touch alc269_probe / bus->pci — not a prerequisite
- [Phase 3] git merge-base --is-ancestor 3b36ac93739e7 HEAD → already in this tree
- [Phase 4] b4 dig -c 3b36ac93739e7: lore URL found; v1 combined, v2 split at Iwai’s request; Iwai applied v2
- [Phase 4] b4 dig -w: linux-sound, perex, tiwai on original To/Cc
- [Phase 4] lore HTTP 403; mbox saved with b4 dig -m
- [Phase 5] alc269_probe is .probe of alc269_codec_ops; ID 0x10ec0236 is in snd_hda_id_alc269[]
- [Phase 5] azx_bus_init() assigns bus->pci = chip->pci; tegra/acpi/cix-ipbloq never set chip->pci
- [Phase 6] git describe HEAD → v7.3-rc4-27-gf0100363d8c37; make kernelversion → 7.3.0-rc4
- [Phase 6] Buggy ALC236 block present at alc269.c:9188–9191
- [Phase 6] Historical policy: 5100cd07d43a1 “Allow NULL bus->pci” (v3.15-rc1) is in HEAD
- [Phase 8] Failure mode: NULL deref at codec probe → oops; severity HIGH; PCI path unchanged
- UNVERIFIED: whether ALC236 is commonly wired to Tegra/ACPI/CIX in the field; lore.kernel.org/stable discussion (HTTP 403)

**YES**

 sound/hda/codecs/realtek/alc269.c | 1 +
 1 file changed, 1 insertion(+)
sound/hda/codecs/realtek/alc269.c +1 -0
index 6bf500c0b5f9b..d88627558150f 100644
@@ -8451,6 +8451,7 @@ static int alc269_probe(struct hda_codec *codec, const struct hda_device_id *id)
 		spec->init_hook = alc256_init;
 		spec->gen.mixer_nid = 0; /* ALC256 does not have any loopback mixer path */
 		if (codec->core.vendor_id == 0x10ec0236 &&
+		    codec->bus->pci &&
 		    codec->bus->pci->vendor != PCI_VENDOR_ID_AMD)
 			spec->en_3kpull_low = false;
 		break;
Signature · 1 line
2.53.0
author maintainer
#269 lore raw

PATCH 1/1 fs/ntfs3: Fix memory leak in indx_find_sort()

In reply to Sasha Levin

From: Konstantin Komarov <[email protected]>

[ Upstream commit 194491be54e1c9e4d29d3ee777b05ff031c4b670 ]

When popping a level from the index lookup stack, indx_find_sort() frees the struct indx_node but not the index buffer it owns. Every call that descends and then pops a level leaks that allocation.

Free n->index before freeing the node itself.

---

LLM Generated explanations, may be completely bogus:

I have enough to decide: this is a one-line leak fix in indx_find_sort(), the buggy code is in this 7.3-rc4 tree, and it meets the stable rules.

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

**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[fs/ntfs3] [fix] memory leak in indx_find_sort()** — subsystem fs/ntfs3, action verb **fix**, claimed intent is to stop leaking the index buffer when a lookup level is popped.

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Commit 194491be54e1c9e4d29d3ee777b05ff031c4b670 (Author: Konstantin Komarov, 2026-07-30):

- **Fixes:** none (expected for this review)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** none
- **Acked-by:** none
- **Link:** none in the commit message
- **Cc: stable:** none (expected)
- **Signed-off-by:** Konstantin Komarov \<almaz.alexandrovich@paragon- software.com\> (author/maintainer)

No syzbot, no multi-user reports, no explicit stable nomination. Author is the NTFS3 maintainer.

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** When popping a level from the index lookup stack, indx_find_sort() frees struct indx_node but not the index buffer it owns (n->index).
- **Symptom:** Every call that descends into a child index block and later pops that level leaks that allocation (typically a 4 KiB kmalloc of INDEX_BUFFER).
- **Failure mode:** kernel memory leak on NTFS3 $SDH index walks.
- **Version info:** none in the message.
- **Root cause (author):** kfree(n) without kfree(n->index).
- **Fix:** free n->index before freeing the node.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. Subject and body state a leak fix. It is a classic missing-kfree resource-leak fix, not cleanup-only.

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

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: fs/ntfs3/index.c — **+1 / −0**
- Function: indx_find_sort()
- Scope: **single-file surgical fix** (one line in the pop_level path)

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record (before → after):
- Before: fnd_pop(fnd); kfree(n); — node struct freed; n->index (and buffer heads in n->nb) left allocated.
- After: fnd_pop(fnd); kfree(n->index); kfree(n); — index buffer and node struct freed.
- Path: **normal** pop-level path when the current directory entry is the last in that index block and the walk moves to the parent. Not init-only.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Memory leak / resource leak]**
- indx_read() / indx_read_ra() allocates struct indx_node and in->index (kmalloc(bytes, GFP_NOFS) where bytes = 1u << indx->index_bits, typically 4096).
- Correct teardown is put_indx_node(): kfree(in->index); nb_put(&in->nb); kfree(in);.
- Sibling indx_find_raw() already does fnd_pop() + put_indx_node(n).
- indx_find_sort() used kfree(n) only. This patch adds kfree(n->index) on the pop path.
- Mechanism: missing free of owned kmalloc buffer.

Note (verified, not a reason to reject): the patch does **not** call nb_put(&n->nb), so buffer_head refs can still leak on this path. Two other kfree(n) sites in the same function (invalid-entry error paths at the de_has_vcn_ex loop) are also unchanged.

**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct for the stated leak: kfree(n->index) matches the first action of put_indx_node(); kfree(NULL) is safe; fnd_pop() NULLs the stack slot so later fnd_clear()/put_indx_node() will not double-free.
- Minimal: one line, no unrelated edits, no API change.
- Regression risk: **very low**. Does not change lookup results, locking, or on-disk layout.
- Residual risk: incomplete vs put_indx_node() (BH leak remains). That is an unfixed sibling leak, not a regression introduced by this line.

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

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Pop-level kfree(n) / ntfs_free(n) present since **82cae269cfa95** (“fs/ntfs3: Add initialization of super block”, 2021-08-13) — NTFS3 introduction.
- ntfs_free(n) → kfree(n) in **195c52bdd5d5e** (“Do not use driver own alloc wrappers”, 2021-08-24); ntfs_free was just kfree, so the leak is original, not introduced by that conversion.
- This leak has existed for the entire life of NTFS3 in mainline (~5.15 onward).

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Buggy code is the original indx_find_sort() implementation in 82cae269cfa95, which **is an ancestor of HEAD**.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Recent fs/ntfs3/index.c work is mostly bounds checks and cosmetics.
- Related leak: 87ac077d6ea86 “ntfs3: fix memory leak in indx_create_allocate()” — different function.
- No later commit after 194491be54e1c changes this site (git log 194491be54e1c..HEAD -- fs/ntfs3/index.c is empty).
- Standalone 1-line patch, not “X/Y” of a series.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Konstantin Komarov is the NTFS3 maintainer (Paragon). Many recent NTFS3 commits are his. Weight: high.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. The patch only uses existing kfree, fnd_pop, and n->index. Those exist in this tree. **Can apply standalone.**

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

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 194491be54e1c → https://patch.msgid.link/20260724111443.14
[email protected]
- b4 dig -a: single revision **v1** only (2026-07-24). Committed version matches v1.
- lore.kernel.org fetch returned 403; patch text confirmed via Openwall/IU mirrors. No replies found on those archives (no NAK, no
Cc: stable in-thread).
- Earlier independent patch (Jan 2026) from Jiasheng Jiang: “[PATCH v2] fs/ntfs3: Fix memory and resource leak in indx_find_sort” replacing **all three** kfree(n) with put_indx_node(n) and adding `Fixes:
82cae269cfa9`. That fuller patch was **not** merged; the maintainer later landed this narrower 1-line version.

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc: Konstantin Komarov, [email protected], [email protected], linux- [email protected]. No extra reviewer SOB on the commit. Maintainer self-applied.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by / bugzilla / syzbot. Bug established from code (missing free vs put_indx_node / indx_find_raw). User-report count:
**unverified / none found**.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Jiang’s Jan 2026 patch is the more complete form of the same fix. This commit is a subset (pop path n->index only). No series dependency for applying this one line.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search was 403; web search did not turn up a stable-list thread for this subject. **No verified stable-list NAK or prior selection discussion.**

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

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

**Step 5.2: TRACE CALLERS**
Record: Only caller in this tree is ntfs_insert_security() in fs/ntfs3/fsntfs.c (SDH index walk when inserting a security descriptor). That is called from:
- inode.c file/inode create when a new default/dir security id must be stored
- xattr.c when setting a security descriptor xattr

Not interrupt context. Process context, under ni->ni_lock. Finder is released with fnd_put() → fnd_clear() → put_indx_node() for **remaining** stack nodes; popped nodes are supposed to be freed in indx_find_sort itself.

**Step 5.3: TRACE CALLEES**
Record: fnd_pop, kfree, indx_read/hdr_first_de/de_is_last on the surrounding path. indx_read_ra allocates node + index buffer + buffer_heads.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace NTFS3 create/setxattr → ntfs_insert_security → indx_find then loop indx_find_sort. **Reachable from userspace** on a mounted ntfs3 volume. Not every I/O; triggered when inserting (or searching duplicate) security descriptors in $Secure::$SDH. If the SDH B-tree is deeper than root, pop_level runs and leaked before this fix.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same function still has kfree(n) without kfree(n->index) on two **error** paths. indx_find_raw already uses put_indx_node. Pattern is systematic in indx_find_sort, only partly fixed here.

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- Local tree: **v7.3-rc4-27-gf0100363d8c37**, make kernelversion = **7.3.0-rc4**.
- fs/ntfs3/index.c indx_find_sort() exists. Pre-image is fnd_pop + kfree(n) without freeing n->index.
- Bug introduced with NTFS3 in **82cae269cfa95 (2021)**, present in this tree (git merge-base --is-ancestor 82cae269cfa95 HEAD succeeded).
- This is not “new code after this branch point.”

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** Surrounding function text is the original structure; the hunk is one added line. No conflicting refactor of indx_find_sort in this tree. put_indx_node() already exists if a slightly richer backport were used, but this exact diff applies as-is.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No earlier alternative (Jiang put_indx_node) in this history. This commit **is** the fix that landed (ntfs3_for_7.3 merge dc83d18cdd904). No competing fix for the same kfree(n) pop site.

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

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **[fs/ntfs3] [IMPORTANT]** — real RW filesystem (CONFIG_NTFS3_FS), not staging. Not core VFS/mm, but used on Windows volumes, dual-boot, and some appliances. Leak is in metadata index walk for $Secure.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Active (many 7.3 NTFS3 fixes). The leak itself is old (2021), not a bug in brand-new code.

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

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **filesystem-specific / config-specific** — CONFIG_NTFS3_FS users who insert security descriptors (file create with new/default SD, security xattr). Not universal.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Trigger: indx_find_sort() after a descent into an index allocation block, then last-entry pop.
- How common: not every syscall; **per unique-SD insert / SDH hash-chain walk**, not a once-per-boot init-only leak. Repeated unique ACLs leak repeatedly.
- Unprivileged users: if they can create files or set security xattrs on ntfs3, yes. Typical create after def_security_id is cached may not re-enter insert; still reachable.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **[kernel memory leak of index buffers (and remaining BH refs)] [HIGH for the kmalloc leak on a live FS path; not panic/corruption].** Unbounded across many unique SD inserts; can contribute to memory pressure. Not a crash or data-corruption bug.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** medium-high for ntfs3 users — stops a real leak on a used lookup path; 4 KiB+ per popped level.
- **Risk:** very low — 1 line, same pattern as put_indx_node’s first free, no lock/API change.
- **Ratio:** strongly in favor of taking the fix.

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

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Real leak: kfree(n) drops the node without freeing n->index allocated in indx_read_ra().
- Normal pop path, not style-only.
- 1 line, obviously correct, maintainer-authored.
- Code and bug exist in this 7.3-rc4 tree since NTFS3 was added.
- Applies cleanly; no prerequisites.
- Same class as many stable leak fixes; sibling indx_find_raw already frees via put_indx_node().
- Reachable from userspace ntfs3 create/xattr.

AGAINST:
- Not a crash, deadlock, or corruption issue.
- Incomplete: no nb_put(), two error-path kfree(n) sites remain.
- Single caller (ntfs_insert_security), not a hot readdir path.
- No syzbot/user Reported-by, no in-commit tests.

UNRESOLVED:
- Could not fetch lore.kernel.org (403) or confirm stable-list discussion.
- No public reply thread found on mirrors for the July v1 mail.

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — correctness is visible from put_indx_node() / indx_find_raw(). Testing is only implied by maintainer merge, not a Tested-by tag.
2. Fixes a real bug that affects users? **PASS** — leaked kernel allocations on ntfs3 SD insert/lookup.
3. Important issue (crash, security, corruption, deadlock)? **PASS** — memory leak on a live FS path (stable routinely takes these). Not CRITICAL severity, but it is a real resource leak, not cosmetic.
4. Small and contained? **PASS** — +1 line, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — context matches; ntfs3 and indx_find_sort() are present.

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. It is a normal leak fix.

**Step 9.4: MAKE YOUR DECISION**
This tree is **7.3.0-rc4**. The leak exists in indx_find_sort() here and has since NTFS3 landed. The patch is a one-line kfree(n->index) on pop, matching the node’s ownership. Residual BH/error-path leaks do not make this line wrong or risky. Benefit outweighs risk.

===============================================================
What problem this solves for this tree
===============================================================
indx_find_sort() walks the NTFS $SDH B-tree. After indx_read() fills a child indx_node, popping that level used to kfree only the node object. The owned index buffer stayed allocated for every descent- then-pop. NTFS3 users inserting security descriptors (file create / security xattr) leak that memory. This commit frees n->index first, which is the correct teardown for that allocation.

It meets stable rules: obviously correct, real leak, small, no new API, applies here. Risk is a single kfree on a pointer the node exclusively owns after fnd_pop().

Concerns: the fuller put_indx_node() replacement was proposed earlier and would also drop buffer heads and fix two error paths; this commit is a partial fix. That is acceptable for stable — it still plugs the main pop-path kmalloc leak without depending on other commits.

===============================================================
Verification
===============================================================
- [Phase 1] Parsed commit 194491be54e1c: subject/body leak fix; tags = author SOB only; no Fixes/Reported-by/Cc: stable.
- [Phase 2] Diff: +1 line kfree(n->index) before kfree(n) in indx_find_sort() pop_level; confirmed put_indx_node() does kfree(in->index); nb_put(); kfree(in).
- [Phase 2] Confirmed indx_read_ra() kmallocs ib and assigns in->index = ib.
- [Phase 2] Confirmed indx_find_raw() uses put_indx_node(n) after fnd_pop.
- [Phase 3] git blame: pop path from 82cae269cfa95 (2021); kfree(n) from 195c52bdd5d5e; this line from 194491be54e1c.
- [Phase 3] git merge-base --is-ancestor 82cae269cfa95 HEAD and 194491be54e1c HEAD: both true.
- [Phase 3] git log 194491be54e1c..HEAD -- fs/ntfs3/index.c: no later change to this file.
- [Phase 3] No Fixes: tag to follow.
- [Phase 4] b4 dig -c 194491be54e1c: lore msgid [email protected]; -a v1 only; -w ntfs3/fsdevel/lkml.
- [Phase 4] Openwall/IU mirrors: patch text matches commit; no replies found.
- [Phase 4] Found unmerged Jan 2026 Jiasheng Jiang put_indx_node patch (lkml.iu.edu / gnuweeb).
- [Phase 4] lore.kernel.org WebFetch: 403. Stable-list hit:
**UNVERIFIED**.
- [Phase 5] git grep indx_find_sort: only ntfs_insert_security + declaration.
- [Phase 5] ntfs_insert_security out: calls fnd_put(fnd_sdh).
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4.
- [Phase 6] Pre-fix source at 194491be54e1c^ still has kfree(n) without kfree(n->index).
- [Phase 8] Failure mode: kmalloc leak of index buffers on SDH pop; severity HIGH for leak class, not oops/corruption.
- UNVERIFIED: whether any user actually hit OOM from this; mailing-list review comments beyond the isolated patch mail.

The fix is small, surgical, and meets the stable criteria for this tree.

**YES**

 fs/ntfs3/index.c | 1 +
 1 file changed, 1 insertion(+)
fs/ntfs3/index.c +1 -0
index edfcd28573ef9..03ae5a817c1b4 100644
@@ -1325,6 +1325,7 @@ int indx_find_sort(struct ntfs_index *indx, struct ntfs_inode *ni,
 		/* Pop one level. */
 		if (n) {
 			fnd_pop(fnd);
+			kfree(n->index);
 			kfree(n);
 		}
 
Signature · 1 line
2.53.0
author maintainer
#270 lore raw

PATCH 1/1 Bluetooth: hci_nokia: validate firmware packet bounds

In reply to Sasha Levin

From: Pengpeng Hou <[email protected]>

[ Upstream commit 45640627e3ddc5f4d3a0d08618a596a8c65d48a5 ]

nokia_setup_fw() walks a length-prefixed firmware stream and decodes HCI command packets from each record.

Check that each record fits in the remaining firmware image, that command records contain the HCI command header, and that the payload length is covered before submitting the command.

---

LLM Generated explanations, may be completely bogus:

The local tree is **6.18.53** (pending-6.18). The buggy firmware parser is in this checkout and the bounds checks are not. This is a real out-of-bounds firmware walk, not a feature or cleanup.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[Bluetooth / hci_nokia] [validate] [bounds-check length- prefixed firmware records before decoding HCI commands]**

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Signed-off-by:** Pengpeng Hou \<[email protected]\> (author)
- **Signed-off-by:** Luiz Augusto von Dentz \<[email protected]\> (Bluetooth maintainer; applied the patch)
- **No Fixes:** tag (expected for this review)
- **No Cc: stable** (expected)
- **No Reported-by / Tested-by / Reviewed-by / Acked-by / Link**
- Ignore pipeline markers if present (none on the upstream commit)

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** nokia_setup_fw() walks a length-prefixed firmware blob and treats each record as an HCI command without checking that pkt_size, the command header, or cmd->plen fit in the remaining image.
- **Symptom / failure mode:** out-of-bounds read of firmware (memcpy of cmd->plen bytes; pointer walk past fw->data), and size_t underflow of fw_size if pkt_size + 2 > fw_size, which can turn the loop into an unbounded walk.
- **Version info in message:** none. Introducer is the original driver (v4.12-rc1).
- **Root cause (author):** missing bounds checks on a length-prefixed stream before __hci_cmd_sync().

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not disguised.** Subject and body are an explicit bounds- validation fix. Same class as firmware OOB checks already in this tree for btrtl and hci_aml.

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** drivers/bluetooth/hci_nokia.c — **+20 / −0**
- **Function:** nokia_setup_fw()
- **Scope:** single-file surgical fix

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Current loop in this tree:

```350:381:drivers/bluetooth/hci_nokia.c
        while (fw_size >= 4) {
                u16 pkt_size = get_unaligned_le16(fw_ptr);
                u8 pkt_type = fw_ptr[2];
                const struct hci_command_hdr *cmd;
                u16 opcode;
                struct sk_buff *skb;

                switch (pkt_type) {
                case HCI_COMMAND_PKT:
                        cmd = (struct hci_command_hdr *)(fw_ptr + 3);
                        opcode = le16_to_cpu(cmd->opcode);

                        skb = __hci_cmd_sync(hu->hdev, opcode,
cmd->plen,
                                             fw_ptr + 3 +
HCI_COMMAND_HDR_SIZE,
                                             HCI_INIT_TIMEOUT);
                        // ...
                }
                fw_ptr += pkt_size + 2;
                fw_size -= pkt_size + 2;
        }
```

Record, per hunk:
1. **Record size vs remaining image:** before, a huge pkt_size was trusted; after, pkt_size > fw_size - 2 → -EINVAL / goto done.
2. **Command header present:** before, fw_ptr + 3 was cast to hci_command_hdr with only fw_size >= 4; after, pkt_size < 1 + HCI_COMMAND_HDR_SIZE is rejected (HCI_COMMAND_HDR_SIZE is 3).
3. **Payload vs cmd->plen:** before, __hci_cmd_sync() copied cmd->plen bytes from fw_ptr + 6 with no check; after, `cmd->plen

Quoted 1 line

pkt_size - 1 - HCI_COMMAND_HDR_SIZE` is rejected.

Error path only for malformed images. Valid firmware is unchanged.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Memory safety / OOB + size_t underflow]**
- hci_cmd_sync_alloc() does skb_put_data(skb, param, plen) → memcpy of cmd->plen (up to 255) from the firmware pointer with no source-size check.
- fw_size is size_t. fw_size -= pkt_size + 2 underflows if the record is larger than the remaining blob, so the while (fw_size >= 4) loop can continue with fw_ptr past the buffer.

**Step 2.4: ASSESS THE FIX QUALITY**
Record: **Obviously correct and minimal.** Arithmetic is sound: the loop already requires fw_size >= 4, so fw_size - 2 does not underflow; the header check makes pkt_size - 1 - HCI_COMMAND_HDR_SIZE non- negative. Regression risk is low: only malformed images that already caused OOB are rejected. No API, locking, or data-structure changes.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**
Record: Entire parser is **7bb318680e868c** (“Bluetooth: add nokia driver”, Sebastian Reichel, 2017-04-13). **git describe --contains → v4.12-rc1~129^2~175^2~4.** Unchanged since then in this area.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Introducer is the original driver commit above. That commit is in this tree (the driver file exists and matches the pre-image).

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent hci_nokia.c history in this tree is unrelated (h4_recv_buf, quirk_flags, SPDX, unused struct). **Standalone, not patch X/Y.** No later hci_nokia.c commits on origin/master after the fix.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Pengpeng Hou has other Bluetooth bounds-check commits in this tree (btusb Realtek vendor event length, SCO altsetting clamp). Maintainer SOB is Luiz von Dentz.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **None.** Uses existing HCI_COMMAND_HDR_SIZE, goto done, request_firmware. **git apply --check of 45640627e3ddc succeeded on this tree.**

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **b4 dig:**
https://patch.msgid.link/[email protected]
- **v1 only** (no v2/v3)
- Applied to bluetooth-next as **a392bd47c5e0** by Luiz on 2026-07-07; mainline **45640627e3ddc** (same patch-id 6d5cdd79755cd7e3d221355fefd1165392e0381a)
- **No NAKs.** BlueZ CI: CheckPatch/BuildKernel/Sparse/32-bit all PASS (Patchwork series 1122167)
- No reviewer “Cc: stable” in the thread (CI + patchwork-bot only)

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (**b4 dig -w**): Marcel Holtmann, Luiz von Dentz, linux- bluetooth, linux-kernel. Applied by the Bluetooth maintainer.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: **No syzbot/bugzilla/user report.** Bug is from code inspection of the parser.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone. Same class of firmware-bounds fixes landed in mainline around the same time:
- Bluetooth: btrtl: validate firmware patch bounds
- Bluetooth: hci_aml: validate firmware segment lengths Both are **already in this 6.18 tree** (6744ab60dfac5, e1534d49a7b8b) via stable (they had Cc: stable).

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable WebFetch returned **403**. Keyword search found **no** stable-list discussion of this subject. **UNVERIFIED** beyond that.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: KEY FUNCTIONS**
Record: **nokia_setup_fw()** only.

**Step 5.2: TRACE CALLERS**
Record:
- nokia_setup() → nokia_setup_fw() (step “3. send firmware”)
- nokia_proto.setup = nokia_setup
- hci_uart_setup() in hci_serdev.c / hci_ldisc.c calls hu->proto->setup(hu)

**Step 5.3: TRACE CALLEES**
Record: request_firmware(), get_unaligned_le16(), __hci_cmd_sync() → hci_cmd_sync_alloc() → skb_put_data()/memcpy(), release_firmware().

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Triggered when the HCI UART Nokia device is set up (HCI bring-up after serdev probe of nokia,h4p-bluetooth). **Reachable from userspace HCI up**, not from arbitrary syscalls without the device. Firmware comes from nokia/bcmfw.bin or nokia/ti1273.bin via the firmware loader (including the userspace helper).

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: btintel_legacy_rom_patching() already validates remain < cmd->plen. This tree already backported the same class for **btrtl** and **hci_aml**. hci_nokia was the missing parser.

---

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes**, drivers/bluetooth/hci_nokia.c nokia_setup_fw(), lines 350–381. Introduced **v4.12**.
Local tree: **p-6.18-1-g03b85e06ca9bf, kernelversion 6.18.53, branch pending-6.18.**
git merge-base --is-ancestor 45640627e3ddc HEAD → **not an ancestor** (fix not in this tree).
git merge-base --is-ancestor 45640627e3ddc v6.18 → **not in v6.18**. Mainline describe: **v7.2-rc6-1358-g45640627e3ddc**.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply** (git apply --check exit 0). Surrounding code matches the pre-image.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: **No** Malformed firmware / this subject in this tree. Sibling firmware OOB fixes for other BT drivers **are** already here; they do not cover hci_nokia.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: SUBSYSTEM AND CRITICALITY**
Record: **Bluetooth HCI UART Nokia H4+ driver** (CONFIG_BT_HCIUART_NOKIA). **PERIPHERAL** (Nokia N9/N900/N950-class UART Bluetooth), but the bug class is kernel memory safety during device setup.

**Step 7.2: SUBSYSTEM ACTIVITY**
Record: Bluetooth core is active; hci_nokia.c itself is mature (parser unchanged since 2017).

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: WHO IS AFFECTED**
Record: **Driver-specific / config-specific:** CONFIG_BT_HCIUART_NOKIA and DT nokia,h4p-bluetooth, firmware nokia/bcmfw.bin or nokia/ti1273.bin.

**Step 8.2: TRIGGER CONDITIONS**
Record: HCI setup with a firmware image whose length prefix, header, or plen does not fit the blob. **Not every boot with good linux- firmware.** Can be hit by truncated/corrupt firmware or a userspace firmware loader. Unprivileged network clients cannot trigger it without the device and a bad firmware file.

**Step 8.3: FAILURE MODE SEVERITY**
Record: **Kernel OOB read** (memcpy past fw->data) and possible **unbounded buffer walk** after fw_size underflow. **Severity: HIGH** (oops / KASAN / infoleak potential). Not a remote unauth exploit by itself.

**Step 8.4: RISK-BENEFIT RATIO**
Record:
- **Benefit: HIGH for affected hardware** (prevents OOB/crash on bad firmware); **MEDIUM overall** (niche driver, but same bug class already taken for other BT firmware parsers in this tree).
- **Risk: VERY LOW** (20 lines, error-path only, clean apply).
- **Ratio: backport.**

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

**FOR:**
- Real OOB: trusted pkt_size/cmd->plen without remaining-size checks; __hci_cmd_sync copies plen bytes; fw_size can underflow.
- Present in this 6.18.53 tree since v4.12; fix is not in HEAD.
- Small (+20), obviously correct, applies cleanly.
- No new APIs; valid firmware behavior unchanged.
- Applied by the Bluetooth maintainer; BlueZ CI passed.
- Same class already backported here for btrtl and hci_aml.

**AGAINST:**
- Niche Nokia UART hardware.
- No syzbot/user report; trigger needs malformed firmware.
- No Fixes: / Cc: stable (not a negative under these rules).

**UNRESOLVED:**
- Stable list 403; no evidence it was NAK’d for stable.
- No public crash report with a stack trace.

**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** (logic + maintainer apply + CI)
2. Fixes a real bug that affects users? **PASS** (OOB on malformed Nokia firmware at HCI setup)
3. Important (crash/security/corruption/deadlock)? **PASS** — HIGH memory-safety OOB
4. Small and contained? **PASS** — +20 lines, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — git apply --check clean

**Step 9.3: EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary **memory-safety bug fix**.

**Step 9.4: DECISION**
This tree still has the unbounded firmware walk. The patch is a 20-line guard that this 6.18 branch already accepted for sibling Bluetooth firmware parsers. Backport it.

---

### What the commit solves for this tree

nokia_setup_fw() still trusts a LE16 length and cmd->plen from nokia/bcmfw.bin / nokia/ti1273.bin. A truncated or hostile image can make __hci_cmd_sync() memcpy past the firmware buffer and can wrap fw_size so the loop walks off the end. The patch rejects those records with -EINVAL before the copy/advance.

### Risk vs benefit

Benefit is preventing a kernel OOB during HCI setup on Nokia H4+ UART Bluetooth. Risk is negligible: checks only fire on records that already overflowed, and the hunk applies without context changes.

---

### Verification
- **[Phase 1]** Parsed tags on 45640627e3ddc / a392bd47c5e0: author
+ Luiz SOB only; no Fixes/Cc/Reported-by
- **[Phase 2]** Diff: +20 in nokia_setup_fw(); three -EINVAL checks; __hci_cmd_sync / skb_put_data confirmed as memcpy(param, plen)
- **[Phase 2]** HCI_COMMAND_HDR_SIZE is 3; struct hci_command_hdr { __le16 opcode; __u8 plen; }
- **[Phase 3]** git blame 350–381: all 7bb318680e868c (v4.12-rc1)
- **[Phase 3]** No Fixes tag; introducer is original driver
- **[Phase 3]** git apply --check of 45640627e3ddc: **exit 0**
- **[Phase 4]** b4 dig -c a392bd47c5e0 / -a / -w: v1 only; lore msgid 20260706091701.77562-1; CC Holtmann + von Dentz + linux- bluetooth
- **[Phase 4]** mbox: BlueZ CI PASS; patchwork-bot applied to bluetooth- next a392bd47c5e0; no NAK
- **[Phase 4]** lore.kernel.org WebFetch 403; stable-list discussion **UNVERIFIED** (search did not show a hit)
- **[Phase 5]** Callers: nokia_setup ← hci_uart_setup in hci_serdev.c/hci_ldisc.c
- **[Phase 6]** git describe HEAD → p-6.18-1-g03b85e06ca9bf; make kernelversion → **6.18.53**
- **[Phase 6]** Buggy loop present; merge-base --is-ancestor 45640627e3ddc HEAD failed; not in v6.18; mainline is v7.2-rc6-1358
- **[Phase 6]** Sibling firmware OOB fixes **are** in this tree:
6744ab60dfac5 (btrtl), e1534d49a7b8b (hci_aml)
- **[Phase 8]** Failure mode: OOB read / possible unbounded walk → HIGH
- **UNVERIFIED:** whether a specific production nokia/*.bin is malformed (not required; the parser is still unchecked)

**YES**

 drivers/bluetooth/hci_nokia.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/bluetooth/hci_nokia.c +20 -0
index 1e65b541f8ade..be2923231e712 100644
@@ -354,9 +354,29 @@ static int nokia_setup_fw(struct hci_uart *hu)
 		u16 opcode;
 		struct sk_buff *skb;
 
+		if (pkt_size > fw_size - 2) {
+			err = -EINVAL;
+			dev_err(dev, "%s: Malformed firmware packet\n",
+				hu->hdev->name);
+			goto done;
+		}
+
 		switch (pkt_type) {
 		case HCI_COMMAND_PKT:
+			if (pkt_size < 1 + HCI_COMMAND_HDR_SIZE) {
+				err = -EINVAL;
+				dev_err(dev, "%s: Malformed firmware command\n",
+					hu->hdev->name);
+				goto done;
+			}
+
 			cmd = (struct hci_command_hdr *)(fw_ptr + 3);
+			if (cmd->plen > pkt_size - 1 - HCI_COMMAND_HDR_SIZE) {
+				err = -EINVAL;
+				dev_err(dev, "%s: Truncated firmware command\n",
+					hu->hdev->name);
+				goto done;
+			}
 			opcode = le16_to_cpu(cmd->opcode);
 
 			skb = __hci_cmd_sync(hu->hdev, opcode, cmd->plen,
Signature · 1 line
2.53.0
author maintainer
#271 lore raw

PATCH 1/1 drm/amd/pm: validate vega10 profile mode inputs

In reply to Sasha Levin

From: Lijo Lazar <[email protected]>

[ Upstream commit bf939f2a1687ef4ab815640096357f8ef5bd5fb6 ]

Check for out of range profile modes and custom params that exceed 8 bits.

---

LLM Generated explanations, may be completely bogus:

The local tree is **6.18.53**. Vega10 still accepts out-of-range pp_power_profile_mode sysfs values and silently truncates custom DPM bytes before they are sent to SMU.

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

Step 1.1: PARSE THE SUBJECT LINE
Record: [drm/amd/pm] [validate] [reject out-of-range Vega10 power profile modes and custom params wider than 8 bits]

Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Lijo Lazar <[email protected]> (author)
- Reviewed-by: Asad Kamal <[email protected]>
- Signed-off-by: Alex Deucher <[email protected]> (AMDGPU maintainer)
- No Fixes:, Reported-by, Tested-by, Link:, or Cc: stable (absence is expected)
- Ignore pipeline tags: [Upstream commit bf939f2a1687ef4ab815640096357f8ef5bd5fb6], Signed-off-by: Sasha Levin

Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record: [Bug: Vega10 profile-mode setter does not reject invalid modes or custom params that do not fit in 8 bits] [Symptom: invalid SMU SetWorkloadMask / SetCustomGfxDpmParameters programming; silent uint8_t truncation] [No version info in the message] [Root cause implied:
missing bounds checks before SMC messages]

Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not disguised. The subject is explicitly “validate”. This is input validation before firmware commands, not style cleanup.

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

Step 2.1: INVENTORY THE CHANGES
Record: [drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c: +9 / -0] [vega10_set_power_profile_mode()] [single-file surgical fix]

Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Hunk 1: After power_profile_mode = input[size], if mode > PP_SMC_POWER_PROFILE_CUSTOM (6), log and return -EINVAL. Before: any mode fell through to 1 << power_profile_mode (or 1 << (mode-1)) as PPSMC_MSG_SetWorkloadMask, then stored in hwmgr->power_profile_mode.
- Hunk 2: For CUSTOM with size==4, reject any of input[0..3] with bits above 7 set. Before: those long values were assigned through uint8_t (busy_set_point etc. and custom_profile_mode[] which is uint8_t[4]), then packed into a 32-bit SMC parameter. Values >255 or negative were truncated.

Step 2.3: IDENTIFY THE BUG MECHANISM
Record: [Logic / bounds / firmware-input validation]
- Missing range check: userspace sysfs can supply modes 7–9 (WINDOW3D/CAPPED/UNCAPPED exist in the shared enum but Vega10’s table only lists 0–CUSTOM). Those become invalid SMU workload bits.
- Missing 8-bit check: custom DPM fields are 8-bit hardware parameters; overflow was silently truncated into the packed SMC word.

Step 2.4: ASSESS THE FIX QUALITY
Record: [Obviously correct and minimal. Same > PP_SMC_POWER_PROFILE_CUSTOM guard already exists in vega20_set_power_profile_mode.] [Regression risk very low: only invalid writes return -EINVAL; legal modes 0–6 and 8-bit custom params are unchanged.] No public API or data-structure change.

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

Step 3.1: BLAME THE CHANGED LINES
Record: Function introduced in 6390258a2f1390 (“drm/amd/pp: Add custom power profile mode support on Vega10”, 2018-02-19, contained in v4.17-rc1). Profile mode taken from input[size] in e815a9e62b3225 (Evan Quan, 2019). Unconditional 1 << power_profile_mode SMU send from 3919a485187a85 / fe122ee5428293 (Kenneth Feng, 2021). The buggy pattern has been in this family of kernels for years, including 6.18.

Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. N/A. The missing checks are original to this setter, not a recent regression.

Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: Recent vega10_hwmgr.c work is other bounds checks (OD DPM triples, voltage index). This patch is standalone, not “patch X/Y”. No prerequisite refactor required for these two ifs.

Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Lijo Lazar is a regular AMD PM contributor (161 commits under drivers/gpu/drm/amd/pm/ in this tree). Applied by Alex Deucher. Related author work is other PM validation, not a coupled series for this function.

Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: None. Uses existing PP_SMC_POWER_PROFILE_CUSTOM, pr_err, and the existing uint8_t packing. Can apply standalone.

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

Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
[https://patch.msgid.link/[email protected]]
[v1 only; committed version matches v1] [Asad Kamal: Reviewed-by; no other technical discussion] [No Cc: stable in review] [No NAKs]

Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: Recipients: amd-gfx, Hawking Zhang, Alexander Deucher, Asad Kamal, Candice Li. Reviewer Asad Kamal (AMD). Maintainer Alex Deucher signed off on merge.

Step 4.3: SEARCH FOR THE BUG REPORT
Record: No Reported-by / Link / syzbot. No separate bugzilla. The submission itself is the only write-up.

Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone one-patch series. Vega20 already had the equivalent mode check (present after e098bc9612c2b, 2020 layout move). smu7 uses a switch on known modes so invalid values are not turned into SMU bitmasks.

Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable returned HTTP 403; UNVERIFIED whether it was discussed on stable@. No evidence in the amd-gfx thread of a stable NAK.

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

Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: vega10_set_power_profile_mode()

Step 5.2: TRACE CALLERS
Record:
- Registered as hwmgr_func.set_power_profile_mode.
- pp_set_power_profile_mode() → amdgpu_dpm_set_power_profile_mode() → amdgpu_set_pp_power_profile_mode() (sysfs pp_power_profile_mode, S_IRUGO|S_IWUSR). This is the untrusted path: first character parsed with kstrtol, so modes 0–9 are reachable; CUSTOM then parses extra longs into parameter[].
- pp_dpm_switch_power_profile() already rejects !(type < PP_SMC_POWER_PROFILE_CUSTOM) before calling.
- pp_psm.c uses internal workload_setting[] values, not raw sysfs.

Step 5.3: TRACE CALLEES
Record: smum_send_msg_to_smc_with_parameter() with PPSMC_MSG_SetCustomGfxDpmParameters and PPSMC_MSG_SetWorkloadMask. Those talk to Vega10 SMU firmware.

Step 5.4: FOLLOW THE CALL CHAIN
Record: Userspace write to /sys/class/drm/cardX/device/pp_power_profile_mode (typically root) → amdgpu_pm.c store → powerplay → vega10_set_power_profile_mode. Reachable from userspace. Not a syscall for unprivileged users (owner-write sysfs).

Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: vega20_hwmgr.c already has if (power_profile_mode > PP_SMC_POWER_PROFILE_CUSTOM). Newer swsmu paths also bound profile types. Vega10 was the gap among powerplay Vega setters that shift the mode into an SMU mask.

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

Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. Local tree is 6.18.53 (VERSION=6 PATCHLEVEL=18 SUBLEVEL=53, git describe v6.18.53-5049-g0f0bdc2b0dffb). v6.18.53’s vega10_set_power_profile_mode has no range check and no 8-bit check (function at line 5400). Bug dates to 2018/2019/2021 code, long before 6.18.

Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: [clean apply with line offset]. Context at v6.18.53 matches the patch hunks; only the @@ line number differs (5407 vs original 5216). No conflicting refactor in this file for these lines.

Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No equivalent Vega10 profile-mode validation in v6.18.53. Vega20 already has the mode check. No earlier version of this exact fix.

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

Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [drm/amd/pm powerplay Vega10] [IMPORTANT: discrete GPU driver, not core mm/fs, but Vega 56/64 / Frontier / MI25 still in production use]

Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mature Vega10 powerplay; most recent file changes are bounds- checking, not feature work. Bug is old, not a last-month introduction.

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

Step 8.1: DETERMINE WHO IS AFFECTED
Record: [driver-specific] Vega10 amdgpu + CONFIG powerplay users who write pp_power_profile_mode.

Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Write an out-of-range mode (7/8/9) or CUSTOM params >255 / negative while DPM is manual. Common for tuning tools (and easy to mistype). Root-only sysfs store; not unprivileged. Not a race.

Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: Invalid SMU workload mask / silently truncated custom DPM bytes → wrong clocks/heuristics; possible SMU/GPU misbehavior. Not a demonstrated KASAN crash. [Severity: MEDIUM, HIGH if SMU rejects poorly and the GPU hangs — hang not confirmed in mailing list]

Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record: [Benefit: medium — stops firmware-facing bad input on a real sysfs ABI] [Risk: very low — +9 lines, reject-only] [Ratio: favorable]

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

Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real missing validation on a documented userspace sysfs ABI
- Invalid modes become 1 << mode SMU SetWorkloadMask; Vega10 has no switch/default to ignore them (smu7 does; vega20 already range-checks)
- Custom params are 8-bit hardware fields packed into one SMC dword; overflow was silent truncation
- Tiny, obviously correct, no new API
- Code and bug exist in this 6.18.53 tree; applies with offset only
- Reviewed and merged by AMD GPU maintainers

AGAINST:
- No crash report, syzbot, or Fixes: tag
- Sysfs is owner-writable (typically root), not an unprivileged UAF
- Commit message does not document a hang/CVE
- From the current first-character sysfs parser, mode cannot exceed 9, so the shift is not C UB; the issue is invalid firmware bits, not a kernel OOB

UNRESOLVED:
- Whether invalid SetWorkloadMask actually hangs Vega10 SMU (not documented on list)
- Whether stable@ discussed this (lore.kernel.org/stable HTTP 403)

Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — two straightforward -EINVAL guards; Reviewed-by + maintainer SOB
2. Fixes a real bug that affects users? PASS — sysfs can program SMU with out-of-range profile/custom values
3. Important issue? PASS (MEDIUM, firmware/GPU misprogramming; not a confirmed panic, but hardware-command validation on a user ABI)
4. Small and contained? PASS — +9 lines, one function
5. No new features or APIs? PASS
6. Can apply to the local tree? PASS — buggy function present on 6.18.53; context matches

Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Not a device-ID/quirk/DT/build/doc exception. Ordinary driver bounds-check fix.

Step 9.4: MAKE YOUR DECISION
This should be backported to this 6.18.y tree. The bug is present here, the fix is surgical, valid userspace is unaffected, and leaving it out keeps a userspace-to-SMU hole that sibling Vega20 code already closed.

What problem this solves for stable users:
On Vega10, writing pp_power_profile_mode with a mode above CUSTOM, or CUSTOM heuristics that do not fit in 8 bits, is accepted and forwarded to SMU. That can select a nonsense workload bit or pack truncated DPM parameters. 6.18 still ships that path; the patch only fails those writes with -EINVAL.

Risk vs benefit:
Benefit is correct firmware programming on a real sysfs control. Risk is negligible.

Concerns:
None that block backport. Cherry-pick needs only hunk offset (line 5407 vs 5216). No extra commits required.

Verification:
- [Phase 1] Parsed tags: author Lijo Lazar, Reviewed-by Asad Kamal, SOB Alex Deucher; no Fixes/Reported-by/Link/Cc:stable
- [Phase 2] Diff: +9 lines in vega10_set_power_profile_mode; mode > CUSTOM → -EINVAL; custom input[0..3] & ~0xFF → -EINVAL
- [Phase 2] custom_profile_mode is uint8_t[4] in vega10_hwmgr.h:386; packing uses uint8_t then <<8/16/24
- [Phase 3] git blame on parent: function 6390258a2f1390 (v4.17); SMU shift 3919a485187a85 (2021)
- [Phase 3] No Fixes: tag
- [Phase 3] git log --author="Lijo Lazar" -- drivers/gpu/drm/amd/pm/:
161 commits
- [Phase 4] b4 dig -c bf939f2a1687:
https://patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: amd-gfx + AMD PM maintainers
- [Phase 4] mbox: Asad Kamal Reviewed-by; no NAK; no stable mention
- [Phase 4] lore.kernel.org/stable: HTTP 403 — UNVERIFIED
- [Phase 5] Callers: sysfs amdgpu_set_pp_power_profile_mode (S_IWUSR); pp_dpm_switch_power_profile already bounds type; pp_psm uses internal tables
- [Phase 5] amdgpu_pm.c:1384 only special-cases CUSTOM; other modes skip extra parsing; tmp[0] is first character so sysfs modes are 0–9
- [Phase 5] vega20 already has the same mode > CUSTOM check at vega20_hwmgr.c:4097
- [Phase 6] git describe HEAD: v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion 6.18.53
- [Phase 6] git grep on v6.18.53: no range check in vega10_hwmgr.c
- [Phase 6] Function text on v6.18.53 matches the patch pre-image (offset only)
- [Phase 6] git merge-base --is-ancestor bf939f2a1687 HEAD: not an ancestor (mainline commit not in 6.18.y history)
- [Phase 8] Failure mode: invalid SMU commands / truncated DPM bytes; sysfs root-writable; severity MEDIUM
- UNVERIFIED: actual Vega10 SMU hang on bad SetWorkloadMask; stable@ discussion (HTTP 403)

**YES**

 drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c +9 -0
index d6aaba0b3613d..84c777fde62f5 100644
@@ -5406,6 +5406,11 @@ static int vega10_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, ui
 	uint8_t min_active_level;
 	uint32_t power_profile_mode = input[size];
 
+	if (power_profile_mode > PP_SMC_POWER_PROFILE_CUSTOM) {
+		pr_err("Invalid power profile mode %u\n", power_profile_mode);
+		return -EINVAL;
+	}
+
 	if (power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) {
 		if (size != 0 && size != 4)
 			return -EINVAL;
@@ -5421,6 +5426,10 @@ static int vega10_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, ui
 				return -EINVAL;
 		}
 
+		if ((input[0] & ~0xFF) || (input[1] & ~0xFF) ||
+		    (input[2] & ~0xFF) || (input[3] & ~0xFF))
+			return -EINVAL;
+
 		data->custom_profile_mode[0] = busy_set_point = input[0];
 		data->custom_profile_mode[1] = FPS = input[1];
 		data->custom_profile_mode[2] = use_rlc_busy = input[2];
Signature · 1 line
2.53.0
author maintainer
#272 lore raw

PATCH 1/1 wifi: mt76: mt7603: file buffered frames under the TID reported to mac80211

In reply to Sasha Levin

From: Felix Fietkau <[email protected]>

[ Upstream commit 0bbd6c52dfff62b319963f54cd9370f9486e59d2 ]

The PS queue filed redirected frames under the TID taken from the TXD, while mac80211 was told about the TID taken from the QoS header, or TID 0 for anything that is not a QoS data frame. When the two disagree, mt7603_release_buffered_frames() skips the frame because it does not match the requested TIDs, so it stays in the PS queue until the station wakes up. Buffered MMPDUs hit this whenever they were sent on a non-zero TID.

Use one TID for both.

---

LLM Generated explanations, may be completely bogus:

This tree is **6.12.111** (p-6.12-2). The mt7603 PS-queue TID mismatch is present here, the two-line fix applies cleanly, and it is a real AP- mode buffering bug.

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

**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[wifi: mt76: mt7603]** **[file]** buffered frames under the TID reported to mac80211. “File” here means enqueue/classify; the body is a correctness fix so mac80211 and the driver PS queue use the same TID.

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Link:** https://patch.msgid.link/[email protected] (patch 08/10)
- **Signed-off-by:** Felix Fietkau (mt76 maintainer; ignore any Sasha Levin SOB)
- **No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked-by:, or Cc:
stable** (absence expected for this review)

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** Redirected PS frames are queued under the TXD TID, while ieee80211_sta_set_buffered() is told the QoS-header TID, or TID 0 for non-QoS data / MMPDUs.
- **Symptom:** mt7603_release_buffered_frames() skips the skb (tids & BIT(skb->priority) fails). The frame sits in msta->psq until the station fully wakes (mt7603_sta_ps() splices the whole queue). Buffered MMPDUs hit this whenever the TXD TID is non-zero.
- **Root cause:** Two different TID sources for the same frame.
- **Fix:** Use the same tid for both skb->priority and ieee80211_sta_set_buffered().

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is an explicit protocol/correctness fix.

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

**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** drivers/net/wireless/mediatek/mt76/mt7603/dma.c (+1 / −1)
- **Function:** mt7603_rx_loopback_skb()
- **Scope:** single-file surgical fix

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** skb->priority = FIELD_GET(MT_TXD1_TID, val) (3-bit TXD field), then later ieee80211_sta_set_buffered(sta, tid, true) with tid from the QoS header or 0.
- **After:** skb->priority = tid after that classification.
- **Path:** hardware PS redirect → MCU RX loopback → driver PS queue. Not an init-only path.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Logic / correctness.** Enqueue key (skb->priority) and mac80211 TIM/TID bitmap disagree, so release_buffered_frames never dequeues those skbs during PS-Poll/U-APSD.

**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct and minimal. tid is already 0–7 (IEEE80211_QOS_CTL_TAG1D_MASK or 0). No new locks, APIs, or data structures. Regression risk is very low: release matching becomes consistent with what mac80211 was already told.

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

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- skb->priority = FIELD_GET(MT_TXD1_TID, val) comes from the original driver (c8846e1015022, 2018).
- Split vs mac80211 TID: e004b700660025 (2019, ieee80211_sta_set_buffered) and d55aa5e17461b8 (2019, QoS-only TID, default 0).
- Current if/else (QoS / data / bufferable MMPDU) is b473c0e47f04d (2024, “fix tx queue of loopback packets”), **already in this 6.12 tree**.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Buggy split has been in the driver since 2019; MMPDU TID-0 reporting since d55aa5e17461b8 / b473c0e47f04d.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent dma.c history includes b473c0e47f04d and 9b8d932053b8b. This commit is **not** in HEAD (git merge-base --is- ancestor 0bbd6c52dfff62b319963f54cd9370f9486e59d2 HEAD → not ancestor). Standalone vs later 2026 PS series (see 3.5).

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Felix Fietkau is the mt76 maintainer. Nearby author work on this driver is unrelated (chainmask, EEPROM, WPDMA EOF). Same 10-patch series contains other mt7603 PS fixes he wrote.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Upstream SHA 0bbd6c52dfff62b319963f54cd9370f9486e59d2. Series 08/10. Needed context b473c0e47f04d **is** in this tree. Later series patches are **not** in this tree and are **not** required for this two- line change:
- 697badc27a9b3 U-APSD EOSP
- d5001f493fefd clear buffered-TID when psq empty
- 636a883e2feef re-arm HW PS after service period
Those fix other PS bugs; this patch only aligns enqueue TID with ieee80211_sta_set_buffered(). It can apply standalone.

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

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 0bbd6c52dfff6 →
https://patch.msgid.link/[email protected]
- Single series revision (v1 only; -a showed only this series)
- Thread: 11 messages = 10 patches + kernel test robot on **patch 10 only** (mt7996 OOB, unrelated)
- No NAK, no reviewer risk comments, no Cc: stable on this patch

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: b4 dig -w: To [email protected], From Felix Fietkau. No extra Reviewed-by. Author is the subsystem maintainer and applied it himself.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by / bugzilla / syzbot. Failure mode is code- derived. Related series patch 07 mentions U-APSD retry storms/packet loss; that is a **different** bug.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: [PATCH 01/10] adds MT_DRV_HW_PS_BUFFERING for firmware-TIM chips (mt7915/mt7996), not mt7603 loopback. mt7603 patches 05–07 are sibling PS fixes, not semantic prerequisites of 08.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No useful stable-list hit for this subject (lore.kernel.org fetch 403; web search returned unrelated archives). UNVERIFIED that anyone already requested/rejected it for stable.

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

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

**Step 5.2: TRACE CALLERS**
Record:
- Called only from mt7603_queue_rx_skb() when q == MT_RXQ_MCU and the packet is not PKT_TYPE_RX_EVENT (HW-redirected TX).
- mt7603_queue_rx_skb is .rx_skb in drivers/net/wireless/mediatek/mt76/mt7603/init.c.
- Release path: mac80211 drv_release_buffered_frames → mt7603_release_buffered_frames() which filters on BIT(skb->priority) (verified at main.c:458).

**Step 5.3: TRACE CALLEES**
Record: ieee80211_is_data_qos / ieee80211_is_data / ieee80211_is_bufferable_mmpdu(skb) (present in this tree’s ieee80211.h), ieee80211_sta_set_buffered, skb_queue under ps_lock.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable in AP mode when a station is in PS and the PSE redirects TX. Userspace/network traffic plus sleeping clients trigger it. Not a syscall crash path; it is a common AP operation on this hardware.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Other mt76 chips use mt76_release_buffered_frames(); mt7603 has its own psq. No duplicate of this exact TXD-vs-QoS TID split elsewhere in this driver.

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** dma.c still has:

```42:75:drivers/net/wireless/mediatek/mt76/mt7603/dma.c
        skb->priority = FIELD_GET(MT_TXD1_TID, val);
        ...
        ieee80211_sta_set_buffered(sta, tid, true);
```

MT_TXD1_TID is GENMASK(22, 20). mt7603_release_buffered_frames() still skips on !(tids & BIT(skb->priority)). Bug introduced 2019; still here in 6.12.111. Upstream commit is **not** an ancestor of HEAD.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** git apply --check of 0bbd6c52dfff6 succeeded. This tree still uses rcu_dereference(dev->mt76.wcid[idx]) rather than mt76_wcid_ptr(); that is unused context, not a conflict.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No equivalent TID alignment. git log --grep='buffered frames under the TID' on this path is empty. Sibling 2026 PS series patches are not in this tree.

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

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **wifi / mt76 / mt7603** (CONFIG_MT7603E: MT7603E PCIe and MT7628/MT7688 SoC WLAN). **IMPORTANT** (widely used AP/router silicon), not core mm/net.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature driver, still receiving maintainer fixes. Not staging.

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

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific:** AP (and any PS-buffering) users of MT7603/MT7628/MT7688. Not universal.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Station in power-save; HW redirects frames into the driver PS queue; mac80211 later releases by TID (PS-Poll / U-APSD). Common on APs with phones/IoT clients. Unprivileged Wi-Fi clients can trigger it by sleeping. MMPDUs with non-zero TXD TID are the documented always-hit case.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Frames are not released during the service period. They wait until the station leaves PS, or they can be dropped if psq hits 64. That delays bufferable management (deauth/disassoc/action) and mismatched-TID data. **Severity: HIGH** for AP connectivity; not a kernel oops.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record: **Benefit: high** for this hardware (PS buffering actually works for the TIDs mac80211 asked for). **Risk: very low** (2 lines, no locking/API change, applies cleanly). Ratio strongly favors backport.

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

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Real, explained bug; mechanism confirmed in this tree’s dma.c and main.c
- User-visible AP PS failure (stuck/delayed frames, possible psq overflow drops)
- 2-line, obviously correct, maintainer-authored
- Applies cleanly to 6.12.111
- Prerequisite loopback-queue rewrite (b473c0e47f04d) already present
- Does not need the rest of the 10-patch series

AGAINST:
- Not a crash, UAF, or CVE
- No reporter / Tested-by / Fixes tag
- Other mt7603 PS bugs in the same series remain unfixed here (does not make this patch wrong)

UNRESOLVED:
- No stable-list discussion found (lore 403 / search noise)
- No independent user report for this exact TID mismatch

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — two-line alignment; in mainline from the maintainer
2. Real bug affecting users? **PASS** — PS-buffered frames not released until wake
3. Important issue? **PASS** — AP power-save correctness / delayed MMPDUs; HIGH not panic
4. Small and contained? **PASS** — 2 lines, one function
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — clean apply on 6.12.111

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: None (not a device ID / quirk / DT / build / docs exception). Qualifies as a normal contained bugfix.

**Step 9.4: MAKE YOUR DECISION**
Backport. This 6.12 tree has the exact buggy split, the fix is surgical, and it restores mac80211-driven release of buffered frames (especially MMPDUs) for a still-deployed wireless SoC.

------------------------------------------------
What the commit solves for stable users
------------------------------------------------
On MT7603/MT7628 APs, hardware-redirected PS frames are advertised to mac80211 under one TID and stored under another. Service-period release then skips them, so management and some data stay in the driver queue until the client fully wakes (or the 64-entry queue drops them). Using one TID for both makes release_buffered_frames find those skbs.

Risk vs benefit: two lines, no API/locking change, clean apply; benefit is correct PS delivery on real AP hardware.

Concerns: sibling U-APSD/PS-rearm fixes are separate commits and not required. No backport rewrite needed on this tree.

===============================================================
Verification
===============================================================
- [Phase 1] Tags: Link msgid [email protected]; SOB Felix Fietkau; no Fixes/Reported-by/Cc stable
- [Phase 2] Diff: move skb->priority from MT_TXD1_TID to classified tid in mt7603_rx_loopback_skb (+1/−1)
- [Phase 3] git describe / Makefile: **6.12.111** (p-6.12-2-gd38d58a4e0359)
- [Phase 3] Blame/history: TXD priority from c8846e1015022; mac80211 TID from e004b700660025 / d55aa5e17461b8; MMPDU/queue split b473c0e47f04d **is** ancestor of HEAD
- [Phase 3] git merge-base --is-ancestor 0bbd6c52dfff62b319963f54cd9370f9486e59d2 HEAD → not present
- [Phase 3] Related series SHAs 697badc27a9b3, d5001f493fefd, 636a883e2feef → not in HEAD; not required
- [Phase 4] b4 dig -c 0bbd6c52dfff6: lore match, v1 only; -w: linux- wireless + author; robot reply only on patch 10
- [Phase 4] UNVERIFIED: stable@ discussion (lore 403)
- [Phase 5] Caller: mt7603_queue_rx_skb MCU loopback; release uses BIT(skb->priority) at main.c:458
- [Phase 6] Local dma.c:42 still assigns priority from TXD; git apply --check of upstream diff **exit 0**
- [Phase 8] Failure mode: PS frames skipped until wake / possible psq drop; HIGH connectivity, not oops

**YES**

 drivers/net/wireless/mediatek/mt76/mt7603/dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7603/dma.c +1 -1
index e26cc78fff949..25009e49e7771 100644
@@ -39,7 +39,6 @@ mt7603_rx_loopback_skb(struct mt7603_dev *dev, struct sk_buff *skb)
 
 	val = le32_to_cpu(txd[1]);
 	idx = FIELD_GET(MT_TXD1_WLAN_IDX, val);
-	skb->priority = FIELD_GET(MT_TXD1_TID, val);
 
 	if (idx >= MT7603_WTBL_STA - 1)
 		goto free;
@@ -72,6 +71,7 @@ mt7603_rx_loopback_skb(struct mt7603_dev *dev, struct sk_buff *skb)
 		hwq = MT_TX_HW_QUEUE_MGMT;
 	}
 
+	skb->priority = tid;
 	ieee80211_sta_set_buffered(sta, tid, true);
 
 	val = le32_to_cpu(txd[0]);
Signature · 1 line
2.53.0
author maintainer
#273 lore raw

PATCH 1/1 ALSA: hda/realtek: Add quirk for ASRock NUC BOX-358H

In reply to Sasha Levin

From: Eckhart Mohr <[email protected]>

[ Upstream commit 9a44b828dd7c0be1d0d6d6cf178d9727ceb6da6e ]

Fix headphone jack detection for some devices

---

LLM Generated explanations, may be completely bogus:

This is a one-line Realtek HDA hardware quirk for the ASRock NUC BOX-358H. The local tree is **6.18.57**. The same jack-detect fixup already exists here; only the new PCI SSID is missing.

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**
Record: [ALSA/hda/realtek] [Add] quirk for ASRock NUC BOX-358H

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Signed-off-by: Eckhart Mohr <[email protected]> (author)
- Signed-off-by: Werner Sembach <[email protected]> (Tuxedo; submitted the patch)
- `Link: https://patch.msgid.link/20261001183403.103990-1-
[email protected]`
- Signed-off-by: Takashi Iwai <[email protected]> (ALSA maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, or `Cc:
stable` on the committed message
- Ignore pipeline tags ([Upstream commit 9a44b828...], `Signed-off-by:
Sasha Levin`)

Notable: no Cc: stable on the commit itself. That is expected for this review queue. On-list, Werner later asked for stable (Phase 4).

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: headphone jack detection fails on some devices (the ASRock NUC BOX-358H)
- Symptom: jack not detected / audio jack unusable until the codec is quirked
- Version info: none in the message
- Root cause (from this message): not spelled out beyond “fix headphone jack detection”
- The sibling 2021 quirk for ASRock NUC Box 1100 (174a7fb3859ae) documents the mechanism: cold boot leaves COEF values that hide the jack; warm reboot from another OS preserves working COEF dumps. This commit reuses that same ALC233_FIXUP_NO_AUDIO_JACK for a new SSID.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is an explicit hardware quirk. The “Add quirk” wording is the standard ALSA form for a real device bug.

## PHASE 2: DIFF ANALYSIS - LINE BY LINE

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

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- Before: PCI SSID 0x1849:0x6256 has no match in alc269_fixup_tbl, so snd_hda_pick_fixup() does not apply ALC233_FIXUP_NO_AUDIO_JACK
- After: that SSID maps to alc233_fixup_no_audio_jack(), which writes the existing COEF table via alc_process_coef_fw()
- Path: codec probe / init, not an error path

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- Category: **(h) Hardware workaround** — SND_PCI_QUIRK for ASRock (0x1849) product 0x6256
- Mechanism: same COEF default programming already used for ASRock NUC Box 1100 (0x1849:0x1233)
- No leak, race, UAF, or locking change

**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Quality: obviously correct as a SSID-scoped reuse of an existing fixup
- Minimal: one table line, no unrelated edits
- Regression risk: very low. SND_PCI_QUIRK matches PCI subsystem vendor/device only. 0x6256 does not appear on any other HDA quirk in this tree
- Residual (not a reason to reject): the 358H ships a Realtek ALC256; the fixup name is ALC233. That is pre-existing reuse of the 1100 COEF dump. Tuxedo submitted it and Takashi applied it with no objection

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Insertion sits next to the 1100 entry from 174a7fb3859ae (Werner Sembach, 2021-11-12, Cc: stable)
- Surrounding table came into alc269.c via aeeb85f26c3bb (2025-07-11, “Split Realtek HD-audio codec driver”), which is an ancestor of v6.18.57
- The buggy *behavior* is missing SSID coverage, not a recently introduced logic bug. The 1100 workaround has been in-tree since v5.16-era (Nov 2021)

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable. The analogous original commit is 174a7fb3859ae (“Add quirk for ASRock NUC Box 1100”), present in this tree.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Recent alc269.c history is full of similar one-line/small quirk additions (HP mute LEDs, ASUS speakers, Lenovo SSIDs, etc.), including several already in 6.18.y
- No later follow-up in this tree mentioning 358H or 0x6256
- Standalone, not patch X/Y

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record:
- Eckhart Mohr / Werner Sembach (Tuxedo Computers) regularly submit Realtek quirks
- Takashi Iwai applied this; he is the ALSA HD-audio maintainer
- Same authors shipped the 1100 quirk that this extends

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Record:
- Needs ALC233_FIXUP_NO_AUDIO_JACK, alc233_fixup_no_audio_jack(), and alc269_fixup_tbl — all present on v6.18.57 and on the candidate’s parent
- Parent of 8fa1cfe41877d does **not** contain 0x1849, 0x6256
- Applies standalone

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 8fa1cfe41877d: match at https://patch.msgid.link/202610011
[email protected]
- b4 dig -a: **v1 only**, no later revisions
- LKML: Takashi: “Applied now. Thanks.” (2026-10-03)
- Werner: “again i forgot to add cc stable can you add that in your branch?” (2026-10-03)
- Takashi: “Just send a post again to stable once when the commit is merged to Linus tree.” (2026-10-04)
- No NAKs, no risk flags
- lore.kernel.org direct fetches returned HTTP 403; thread recovered via b4 dig + lkml.iu.edu

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w):
- To/Cc: Werner Sembach, Eckhart Mohr, Jaroslav Kysela, Takashi Iwai, linux-sound, linux-kernel
- Right maintainers and list were on the original recipients
- Applied by Takashi Iwai

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record:
- No syzbot/bugzilla link
- Vendor hardware is real: ASRock Industrial NUC BOX-358H (Intel Core Ultra Series 3 / Panther Lake-H), front combo jack, Realtek ALC256 (asrockind.com)
- ServeTheHome even has a photo titled around the 358H audio jack
- User impact is that specific mini-PC’s headphone/mic jack

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone v1. Only related in-tree work is the 2021 1100 quirk, already present.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search did not turn up a dedicated stable thread for this SSID. Absence of an auto Cc: stable is why this is in manual review. The author still requested stable on the original thread.

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: No function body changes. Data: alc269_fixup_tbl[]. Runtime effect goes through existing alc233_fixup_no_audio_jack() → alc_process_coef_fw().

**Step 5.2: TRACE CALLERS**
Record:
- alc269_fixup_tbl is passed to snd_hda_pick_fixup() in the ALC269-family probe path (alc269.c ~8557)
- snd_hda_pick_fixup() matches PCI subsystem vendor/device first (sound/hda/common/auto_parser.c)
- Called at codec init for Realtek ALC269-family devices (includes ALC256, vendor id 0x10ec0256)

**Step 5.3: TRACE CALLEES**
Record:
- alc_process_coef_fw() writes the COEF firmware table (WRITE_COEF for indices 0x1a, 0x1b, 0x37, 0x38, 0x45, 0x46, 0x49)
- No allocations, no locks added

**Step 5.4: FOLLOW THE CALL CHAIN**
Record:
- Reachable when this NUC’s HDA codec probes (boot / module load)
- Userspace does not need a special syscall; plugging headphones is the user-visible path
- Not a security/syzbot path; it is a device init quirk

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Identical pattern already used for 0x1849:0x1233 (NUC Box 1100). Many other SND_PCI_QUIRK rows in the same table. 0x6256 is unique in ALSA HDA.

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- Local tree: git describe HEAD = v6.18.57-155-gcdf239ca885b2; make kernelversion = 6.18.57
- v6.18.57:sound/hda/codecs/realtek/alc269.c has ALC233_FIXUP_NO_AUDIO_JACK and the 1100 SSID
- v6.18.57 does **not** contain 0x1849, 0x6256
- Context around the 1100 row on v6.18.57 matches the patch (verified by string match)
- Candidate commit 8fa1cfe41877d is an ancestor of current HEAD because this autosel checkout already contains evaluation commits; that is **not** treated as “already selected”

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Expected **clean apply** onto 6.18.57. File path and surrounding table rows match. No refactor needed.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: The 1100 quirk is here. There is no alternate 358H fix. No follow-up revert/correction in this tree.

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY** Record:
- Subsystem: ALSA HD-audio / Realtek codec (sound/hda/codecs/realtek/)
- Criticality: **IMPORTANT** for users of this hardware; **PERIPHERAL** for everyone else (SSID-gated)

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature, actively maintained quirk table. Frequent small hardware-quirk backports in 6.18.y.

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver-specific / platform-specific: ASRock NUC BOX-358H (PCI SSID 1849:6256). Other machines unchanged.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Trigger: boot on that NUC, then use the front combo jack
- Common for owners of that box; zero for others
- Unprivileged users hit it (jack detect), but this is not an exploit

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- Failure: headphone/headset jack not detected (broken analog audio I/O on a machine that has a jack)
- Severity: **MEDIUM** for functional impact (not a panic/UAF), **HIGH** for that device’s usability
- Matches the documented 1100 failure: jack dead on cold boot

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: high for 358H users on 6.18.y (this series is still current as of Oct 2026; this is a 2026 Panther Lake NUC)
- Risk: very low (1 line, existing fixup, SSID-matched)
- Ratio: strongly favors backport

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Textbook stable exception: hardware quirk / PCI ID on an existing driver
- Real user-visible bug: jack detection
- 1-line, existing fixup, no new API
- Prerequisites present in 6.18.57; applies cleanly
- ALSA maintainer applied it
- Submitter explicitly asked for stable
- Same pattern as the 2021 1100 quirk, which was Cc: stable
- Tuxedo-tested on the named device

AGAINST:
- Short commit body
- No Fixes: / no sanitizer report (expected for a quirk)
- COEF table originally dumped for the 1100 (ALC233-named); 358H is ALC256 per vendor specs — accepted by maintainer, SSID-limited

UNRESOLVED:
- Could not fetch lore.kernel.org HTML (403); discussion recovered via b4 dig and LKML archives
- Did not independently dump COEFs on a 358H (not available)

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — one SSID row; Tuxedo authors; maintainer applied
2. Fixes a real bug that affects users? **PASS** — jack detection on a shipping NUC
3. Important issue? **PASS** as a hardware quirk (broken jack; not a panic, but the documented exception class)
4. Small and contained? **PASS** — +1 line
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — clean on 6.18.57

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Hardware quirk / PCI ID addition to an existing driver.** Automatic YES class.

**Step 9.4: MAKE YOUR DECISION**
Backport. The 6.18.57 tree already has the fixup and the 1100 SSID; it only lacks 0x1849:0x6256. That is exactly the class of change stable exists to take.

What it solves for stable users: on ASRock NUC BOX-358H, the Realtek jack is not detected unless this COEF quirk runs. Without it, the combo headphone/mic jack stays broken on cold boot.

Risk vs benefit: one SSID-matched table line, no structural change, benefit is working analog audio on that NUC.

### Verification
- [Phase 1] Parsed tags: author Eckhart Mohr; SOB Werner Sembach, Takashi Iwai; Link msgid; no Fixes/Cc:stable on the commit
- [Phase 1] Ignored [Upstream commit 9a44b828…] and Sasha Levin SOB as pipeline markers
- [Phase 2] Diff: +1 line in alc269_fixup_tbl[] — SND_PCI_QUIRK(0x1849, 0x6256, …, ALC233_FIXUP_NO_AUDIO_JACK)
- [Phase 2] Confirmed fixup body at alc233_fixup_no_audio_jack() writes alc233_fixup_no_audio_jack_coefs
- [Phase 3] git show 174a7fb3859ae: 2021 1100 quirk, Cc: stable, same fixup; git merge-base --is-ancestor vs parent of candidate = present
- [Phase 3] git log --author='Eckhart Mohr' / Werner: regular Realtek quirk contributors
- [Phase 3] No follow-up 358H/0x6256 commits in this tree
- [Phase 4] b4 dig -c 8fa1cfe41877d: lore msgid [email protected]
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: Takashi Iwai, Jaroslav Kysela, linux-sound
- [Phase 4] LKML: Takashi applied; Werner requested Cc:stable; Takashi said to send to stable after Linus merge
- [Phase 4] lore.kernel.org WebFetch: 403 (UNVERIFIED via direct lore HTML)
- [Phase 5] snd_hda_pick_fixup() matches PCI SSID; probe calls it with alc269_fixup_tbl
- [Phase 5] git grep 0x6256 in HDA: only this new quirk
- [Phase 6] git describe HEAD / make kernelversion: 6.18.57
- [Phase 6] git grep on v6.18.57: 1100 quirk present, 358H SSID absent; insertion context matches
- [Phase 8] Vendor spec: NUC BOX-358H has a front combo jack and ALC256
- UNVERIFIED: independent COEF dump on 358H hardware; lore.kernel.org HTML body

This is a small, SSID-scoped hardware quirk that restores jack detection on a real machine, with the required fixup already in 6.18.57.

**YES**

 sound/hda/codecs/realtek/alc269.c | 1 +
 1 file changed, 1 insertion(+)
sound/hda/codecs/realtek/alc269.c +1 -0
index 2a466ef894697..0bfa64bee9d3b 100644
@@ -7640,6 +7640,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x17aa, 0x9e56, "Lenovo ZhaoYang CF4620Z", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
 	SND_PCI_QUIRK(0x1849, 0x0269, "Positivo Master C6400", ALC269VB_FIXUP_ASUS_ZENBOOK),
 	SND_PCI_QUIRK(0x1849, 0x1233, "ASRock NUC Box 1100", ALC233_FIXUP_NO_AUDIO_JACK),
+	SND_PCI_QUIRK(0x1849, 0x6256, "ASRock NUC Box 358H", ALC233_FIXUP_NO_AUDIO_JACK),
 	SND_PCI_QUIRK(0x1849, 0xa233, "Positivo Master C6300", ALC269_FIXUP_HEADSET_MIC),
 	SND_PCI_QUIRK(0x1854, 0x0440, "LG CQ6", ALC256_FIXUP_HEADPHONE_AMP_VOL),
 	SND_PCI_QUIRK(0x1854, 0x0441, "LG CQ6 AIO", ALC256_FIXUP_HEADPHONE_AMP_VOL),
Signature · 1 line
2.53.0
author maintainer
#274 lore raw

PATCH 1/1 wifi: mt76: mt7603: fix U-APSD service period termination

In reply to Sasha Levin

From: Felix Fietkau <[email protected]>

[ Upstream commit 697badc27a9b3b2a8d86092abeed767714f735a2 ]

Frames released from the driver PS queue were all tagged with MORE_DATA and none of them ever carried the EOSP bit, so from the client's point of view a U-APSD service period was started but never finished. Clients that keep their receiver on until EOSP arrives stop sending trigger frames, and all downlink traffic for that station stalls until they give up. ieee80211_sta_eosp() only cleared the service period state inside mac80211, which is why the mismatch went unnoticed.

Assign MORE_DATA per frame and set the wire EOSP bit on the last one. If the last released frame is a bufferable MMPDU it has no QoS control field to carry EOSP, so let mac80211 append a QoS-Null frame instead.

Also stop handing the remaining frame budget to mt76_release_buffered_frames() once frames have been released from the PS
queue: both would signal the end of the same service period. Releasing fewer frames than requested is allowed, and MORE_DATA tells the client to trigger again.

---

LLM Generated explanations, may be completely bogus:

The local tree is **5.15.221** (pending-5.15). The buggy mt7603 U-APSD path is present here and matches mainline before 697badc27a9b3. This is a real protocol fix for a stall, and it should be backported.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[wifi/mt76/mt7603] [fix] [U-APSD service period never ends on the wire]**

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Link: https://patch.msgid.link/[email protected]
— patch **05/10** of Felix Fietkau’s series
- Signed-off-by: Felix Fietkau <[email protected]> (mt76 maintainer)
- No Fixes:, no Reported-by:, no Tested-by:, no Reviewed-by:, no Cc: stable (absence of the last two is expected in this pipeline)
- Ignore any Signed-off-by: Sasha Levin / [Upstream commit ...] if present; they are candidate-prep markers

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** Frames pulled from the driver PS queue all get MORE_DATA and never EOSP. A U-APSD SP starts and never ends on the air.
- **Symptom:** Clients that stay awake until EOSP stop sending trigger frames; **all downlink traffic for that STA stalls** until they give up.
- **Root cause:** ieee80211_sta_eosp() only clears mac80211’s WLAN_STA_SP. mac80211 documents that a driver implementing .release_buffered_frames must set the **wire** EOSP bit itself.
- **Second bug in the same function:** leftover nframes is handed to mt76_release_buffered_frames(), which ends the **same** SP a second time.
- **Fix:** assign MORE_DATA/EOSP per frame; QoS-Null via ieee80211_send_eosp_nullfunc() if the last frame is a bufferable MMPDU; do not forward leftover budget once PS-queue frames were released.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not hidden.** Subject and body describe a concrete protocol failure with a user-visible stall.

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/net/wireless/mediatek/mt76/mt7603/main.c (**+63 / −11**)
- Functions: mt7603_ps_skb_hdr() (new), mt7603_ps_set_more_data → mt7603_ps_set_flags, mt7603_release_buffered_frames
- Scope: **single-file surgical fix**

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** every released PS-queue frame unconditionally ORs IEEE80211_FCTL_MOREDATA; never sets/clears EOSP; ieee80211_sta_eosp() is called if the list is non-empty, then leftover nframes still go to mt76_release_buffered_frames().
- **After:**
1. Walk remaining PS queue under ps_lock and build a pending-TID bitmap.
2. If nothing was dequeued, fall through to

     `mt76_release_buffered_frames()` (unchanged).
  3. If anything was dequeued, **do not** also release from mac80211
     TXQs.
  4. `MORE_DATA` = not-last **or** more frames remain (mac80211
     `more_data` or pending matching TIDs).
  5. Wire `EOSP` only on the last frame and only for
     `IEEE80211_FRAME_RELEASE_UAPSD`.
  6. Last frame not QoS data → `ieee80211_send_eosp_nullfunc()`; else
     `ieee80211_sta_eosp()`.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** protocol / correctness (U-APSD SP termination), not UAF/leak/race.
- **Mechanism:** driver never put EOSP on the air; clients that wait for EOSP stop triggering; downlink stalls.
- Also: MORE_DATA was only set, never cleared. Recycled frames from mt7603_filter_tx() can keep a stale bit; the new helper assigns both bits.

**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Matches mac80211’s .release_buffered_frames contract (include/net/mac80211.h: driver must set EOSP in the QoS header; sending fewer frames than requested is allowed).
- IEEE80211_QOS_CTL_EOSP (0x0010) on the first QoS-control byte is the correct on-wire bit.
- ieee80211_send_eosp_nullfunc() uses IEEE80211_TX_STATUS_EOSP on the NDP; TX status then clears WLAN_STA_SP. iwlwifi already calls this from BH/TX context; .release_buffered_frames must be atomic, and ieee80211_send_null_response() uses dev_alloc_skb (GFP_ATOMIC)
+ ieee80211_xmit.
- Regression risk: **low–medium**. Logic is contained; PS-Poll does not set wire EOSP (uapsd is false). Companion series patches 06–08 make TIM / HW buffering / TID filing more complete but are not required for this EOSP fix to compile or to be correct on its own.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- mt7603_release_buffered_frames: c8846e101502 (2018-11, **mt76: add driver for MT7603E and MT7628/7688**)
- Unconditional MORE_DATA: b126c8897435 (2019-03)
- ieee80211_sta_eosp() without wire EOSP: b7001f46085e (2019-03)
- All three are ancestors of this 5.15 tree.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Buggy behavior dates to driver introduction / 2019 PS-queue helpers, all in this tree.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Mainline follow-ups on the same function (not in this tree):
- d5001f493fef — tell mac80211 when the PS queue is empty (ieee80211_sta_set_buffered(..., false))
- 636a883e2feef — restore hardware PS buffering after an SP These are related U-APSD bugs, not prerequisites for this diff.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Felix Fietkau is the mt76 maintainer and original author of this driver. This is a maintainer fix.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: Patch **05/10**. Patches 01–03/09–10 target mt7915/mt7996 / MLO / new HW TIM — **not needed**. Patch 04 sets wire EOSP in generic mt76_release_buffered_frames() (tx.c); mt7603 has its **own** .release_buffered_frames and only calls the generic helper when the driver PS queue is empty. This patch does not use new APIs or struct fields. **Can apply standalone.**

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 697badc27a9b3 →
https://patch.msgid.link/[email protected]
- **v1 only** (no v2/v3)
- Thread is the 10-patch series plus a kernel-test-robot mail
- Robot error is on **patch 10 / patch 1** (ieee80211_txq_aql_pending missing) — **unrelated** to this patch
- No NAKs, no reviewer risk flags, no Cc: stable suggestion in the thread

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: b4 dig -w: To/Cc were **Felix Fietkau** and **linux- wireless@**. No extra reviewer SOB. Maintainer self-applied into wireless-next (listed in the 2026-08-06 wireless-next pull).

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: OpenWrt mt76 users reported U-APSD stalls / **iPhone freezes** on MT7603 APs (openwrt/mt76#1080 / PR #1084). Testers said an EOSP- related change made iPhone freezes go away; remaining TX-retry/loss is the separate HW-buffering bug (series patch 07).

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Series 01–10 as above. This commit is self-contained. Patch 06 should be considered as a follow-up candidate (TIM never cleared); it is not required for this hunk.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: No evidence this fix was discussed on stable@ or previously rejected. UNVERIFIED that every stable archive was searchable (lore.kernel.org returned 403 for some URLs); b4/openwall/syzbot CI were used instead.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: mt7603_release_buffered_frames, mt7603_ps_set_flags, mt7603_ps_skb_hdr

**Step 5.2: TRACE CALLERS**
Record: Assigned as ieee80211_ops.release_buffered_frames in this file. mac80211 calls it for **PS-Poll and U-APSD** from the RX/PS path (atomic). Reachable whenever an AP-mode STA uses power save.

**Step 5.3: TRACE CALLEES**
Record: mt7603_wtbl_set_ps, mt7603_ps_tx_list / mt76_tx_queue_skb_raw, mt76_release_buffered_frames (empty-PS-queue only), ieee80211_sta_eosp, ieee80211_send_eosp_nullfunc — all exist in this tree.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Client trigger (QoS-Null/PS-Poll) → mac80211 → mt7603_release_buffered_frames. **Yes, userspace/STA traffic triggers it.** Typical clients: phones with U-APSD.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Generic mt76_queue_ps_skb() in this tree still only sets IEEE80211_TX_STATUS_EOSP + MORE_DATA, not wire EOSP (mainline patch 04). mt7603_rx_loopback_skb() sets ieee80211_sta_set_buffered(..., true) and never clears it (mainline patch 06). Same U-APSD family, different bugs.

---

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** mt7603_ps_set_more_data and mt7603_release_buffered_frames in drivers/net/wireless/mediatek/mt76/mt7603/main.c are **byte-for-byte identical** to the parent of 697badc27a9b3. Bug since ~2018/2019.

Local tree: p-5.15-2-g6703e5d2f3a29, **5.15.221**. git merge-base --is-ancestor 697badc27a9b3 HEAD → **not in this tree**.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** Same function bodies; needed APIs (ieee80211_send_eosp_nullfunc, ieee80211_get_qos_ctl, IEEE80211_QOS_CTL_EOSP, IEEE80211_FRAME_RELEASE_UAPSD) are in 5.15.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No related U-APSD EOSP/TIM/HW-rearm fixes on this file in this tree.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **wifi / mt76 / mt7603** (CONFIG_MT7603E). Criticality:
**IMPORTANT** for users of that hardware (MT7603E / MT7628/MT7688 APs — very common home routers), not core mm/net.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature driver (since 5.0-era). This is a long-standing bug, not a regression in new code.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific:** AP (or GO) mode on MT7603/MT7628 with U-APSD (or PS-Poll) clients.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: STA enters power save; hardware redirects frames into msta->psq; STA sends a U-APSD trigger. Common for phones. Unprivileged wireless clients can trigger it.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Downlink stall / client freeze** until the STA gives up (disconnect/retry). Not a kernel oops. Severity: **HIGH** for affected APs (connectivity loss), not CRITICAL kernel crash.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** high for MT7603 AP users — restores U-APSD SP completion so phones keep triggering.
- **Risk:** low–medium (contained ~50-line logic in one ops callback; no API/lock/core changes).
- **Ratio:** benefit outweighs risk.

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

**FOR:**
- Real, user-visible stall (U-APSD SP never ends on the air)
- Matches mac80211 driver contract
- Present in this 5.15 tree since driver introduction
- Functions identical to mainline parent → clean apply
- Small, one file, no new APIs
- Maintainer-authored, merged to mainline as 697badc27a9b3
- Corroborated by OpenWrt MT7603/iPhone freeze reports

**AGAINST:**
- Not crash/UAF/security
- Series 05/10 (other patches are separate bugs/chips)
- Follow-ups 06–08 still missing here (incomplete *overall* U-APSD, but this patch is a complete EOSP fix)
- No extra reviewer tags

**UNRESOLVED:**
- Direct lore.kernel.org HTTP often 403; thread recovered via b4
- No explicit stable@ discussion found

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — protocol-correct; maintainer merged; consistent with mac80211 docs and iwlwifi’s ieee80211_send_eosp_nullfunc usage
2. Fixes a real bug that affects users? **PASS** — stall / client freeze on common AP chipsets
3. Important issue? **PASS** — serious connectivity failure for U-APSD STAs (not a panic, but production-breaking for those devices)
4. Small and contained? **PASS** — one file, +63/−11
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — clean; APIs present

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/quirk/DT/build/docs exception. It is a **driver protocol bugfix**.

**Step 9.4: DECISION**
Backport to this 5.15 tree. The bug exists here; the fix is self- contained and applies cleanly. Companion commits d5001f493fef and 636a883e2feef are worth later evaluation but are not required for this one.

---

### What the commit solves, and why it matters here

mt7603 implements its own .release_buffered_frames because hardware redirects frames into a driver PS queue. That path tagged every frame with MORE_DATA and never set EOSP on the air. mac80211 only saw ieee80211_sta_eosp(), so the stack thought the SP ended while phones waiting for EOSP stopped triggering. On 5.15 APs using CONFIG_MT7603E, that is a real stall, not a cleanup.

### Stable rules / risk vs benefit

Surgical, obviously correct vs the documented U-APSD contract, no new APIs, clean apply. Risk is limited to this driver’s PS release path. Benefit is restoring downlink for power-save clients on a widely deployed chipset.

### Concerns

Patches 06–08 (TIM clear, HW PS re-arm, TID filing) address **other** remaining PS bugs. They are not compile or semantic prerequisites for this hunk. Patch 04 is the analogous EOSP fix for chips that use generic mt76_release_buffered_frames; mt7603 only hits that when its PS queue is empty.

---

Verification:
- [Phase 1] Parsed subject/body/tags: Link is 05/10; author Felix Fietkau; no Fixes/Reported-by/Cc stable
- [Phase 2] Diff: +63/−11 in mt7603_release_buffered_frames; MORE_DATA+EOSP assignment; stop double SP end; QoS-Null for MMPDU
- [Phase 2] Confirmed IEEE80211_QOS_CTL_EOSP is 0x0010 and ieee80211_get_qos_ctl() returns u8 * to the first QoS byte
- [Phase 2] Confirmed ieee80211_send_eosp_nullfunc() in 5.15 sets IEEE80211_TX_STATUS_EOSP on the NDP; TX status clears WLAN_STA_SP
- [Phase 3] blame: c8846e101502 / b126c8897435 / b7001f46085e; all ancestors of HEAD
- [Phase 3] git merge-base --is-ancestor 697badc27a9b3 HEAD → not present
- [Phase 3] Follow-ups on origin/master: d5001f493fef, 636a883e2feef only; no revert
- [Phase 4] b4 dig -c 697badc27a9b3: v1 series, msgid [email protected]
- [Phase 4] b4 dig -w: linux-wireless@ + author only
- [Phase 4] b4 mbox: 11 messages; robot fail is patch 10/ieee80211_txq_aql_pending, unrelated
- [Phase 4] OpenWrt mt76#1084: EOSP-related change reported to stop iPhone freezes
- [Phase 5] ops hook .release_buffered_frames = mt7603_release_buffered_frames; callers are mac80211 PS-Poll/U-APSD
- [Phase 5] ieee80211_send_eosp_nullfunc exists and is exported in this tree; iwlwifi calls it from TX/BH
- [Phase 6] make kernelversion → 5.15.221; git describe HEAD → p-5.15-2-g6703e5d2f3a29
- [Phase 6] Byte-for-byte match of both functions vs 697badc27a9b3^
- [Phase 7] CONFIG_MT7603E present for MT7603E/MT7628
- [Phase 8] Failure mode: downlink stall / client freeze, severity HIGH for that hardware
- UNVERIFIED: exhaustive stable@ archive search (lore HTTP 403); no evidence of a prior stable rejection

**YES**

 .../net/wireless/mediatek/mt76/mt7603/main.c  | 74 ++++++++++++++++---
 1 file changed, 63 insertions(+), 11 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7603/main.c +63 -11
index 0d7c84941cd0a..f8a43d9f72f95 100644
@@ -423,13 +423,33 @@ mt7603_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps)
 	mt7603_ps_tx_list(dev, &list);
 }
 
+static struct ieee80211_hdr *
+mt7603_ps_skb_hdr(struct sk_buff *skb)
+{
+	return (struct ieee80211_hdr *)&skb->data[MT_TXD_SIZE];
+}
+
+/*
+ * Buffered frames can be recycled into the PS queue by mt7603_filter_tx(), so
+ * both bits have to be assigned, not just set.
+ */
 static void
-mt7603_ps_set_more_data(struct sk_buff *skb)
+mt7603_ps_set_flags(struct sk_buff *skb, bool more_data, bool eosp)
 {
-	struct ieee80211_hdr *hdr;
+	struct ieee80211_hdr *hdr = mt7603_ps_skb_hdr(skb);
+
+	if (more_data)
+		hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA);
+	else
+		hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_MOREDATA);
+
+	if (!ieee80211_is_data_qos(hdr->frame_control))
+		return;
 
-	hdr = (struct ieee80211_hdr *)&skb->data[MT_TXD_SIZE];
-	hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA);
+	if (eosp)
+		*ieee80211_get_qos_ctl(hdr) |= IEEE80211_QOS_CTL_EOSP;
+	else
+		*ieee80211_get_qos_ctl(hdr) &= ~IEEE80211_QOS_CTL_EOSP;
 }
 
 static void
@@ -442,7 +462,10 @@ mt7603_release_buffered_frames(struct ieee80211_hw *hw,
 	struct mt7603_dev *dev = hw->priv;
 	struct mt7603_sta *msta = (struct mt7603_sta *)sta->drv_priv;
 	struct sk_buff_head list;
-	struct sk_buff *skb, *tmp;
+	struct sk_buff *skb, *tmp, *last;
+	bool eosp_null, uapsd;
+	u16 pending = 0;
+	u8 last_tid;
 
 	__skb_queue_head_init(&list);
 
@@ -458,20 +481,49 @@ mt7603_release_buffered_frames(struct ieee80211_hw *hw,
 
 		skb_set_queue_mapping(skb, MT_TXQ_PSD);
 		__skb_unlink(skb, &msta->psq);
-		mt7603_ps_set_more_data(skb);
 		__skb_queue_tail(&list, skb);
 		nframes--;
 	}
+
+	skb_queue_walk(&msta->psq, skb)
+		pending |= BIT(skb->priority);
 	spin_unlock_bh(&dev->ps_lock);
 
-	if (!skb_queue_empty(&list))
-		ieee80211_sta_eosp(sta);
+	last = skb_peek_tail(&list);
+	if (!last) {
+		mt76_release_buffered_frames(hw, sta, tids, nframes, reason,
+					     more_data);
+		return;
+	}
+
+	/*
+	 * End the service period here instead of passing the remaining frame
+	 * budget on to mt76_release_buffered_frames(), which would signal the
+	 * end of the same service period a second time.
+	 */
+	uapsd = reason == IEEE80211_FRAME_RELEASE_UAPSD;
+	more_data |= !!(pending & tids);
+
+	skb_queue_walk(&list, skb)
+		mt7603_ps_set_flags(skb, skb != last || more_data,
+				    skb == last && uapsd);
+
+	/*
+	 * EOSP lives in the QoS control field, so a bufferable MMPDU cannot
+	 * terminate a U-APSD service period on its own. In that case mac80211
+	 * has to append a QoS-Null frame, which ends the SP through its tx
+	 * status.
+	 */
+	eosp_null = uapsd &&
+		    !ieee80211_is_data_qos(mt7603_ps_skb_hdr(last)->frame_control);
+	last_tid = __fls(tids);
 
 	mt7603_ps_tx_list(dev, &list);
 
-	if (nframes)
-		mt76_release_buffered_frames(hw, sta, tids, nframes, reason,
-					     more_data);
+	if (eosp_null)
+		ieee80211_send_eosp_nullfunc(sta, last_tid);
+	else
+		ieee80211_sta_eosp(sta);
 }
 
 static int
Signature · 1 line
2.53.0
author maintainer
#275 lore raw

PATCH 1/1 platform/x86: int1092: Fix info leak in parse_package()

In reply to Sasha Levin

From: Abdun Nihaal <[email protected]>

[ Upstream commit f5eb833730c071b68a68de5d1df442aae4ae7e6e ]

Sashiko reports a possible information leak that can occur as follows:

1. In parse_package(), memory allocated for data->device_mode_info is not zerozed initially as it is allocated with devm_kmalloc_array().

2. In the for loop after the allocation, a malformed ACPI package provided by firmware can cause some fields in data->device_mode_info to remain uninitialized.

3. Later in update_sar_data(), the uninitialized fields gets copied to the fields of context->sar_data, which can be exposed to userspace through sysfs attribute read (intc_data_show()).

Fix the leak by switching to use devm_kcalloc() for allocation.

---

LLM Generated explanations, may be completely bogus:

I have enough to judge the leak path, the devm_kcalloc fix, and whether this 7.3-rc4 tree should take it. Writing up the nine-phase analysis next.

## Phase 1: Commit message forensics

**Step 1.1: Subject line**
Record: [platform/x86: int1092] [Fix] [info leak in parse_package() — uninitialized kmalloc data can reach sysfs]

**Step 1.2: Tags**
Record:
- Reported-by: Sashiko <[email protected]> — automated kernel review bot, not syzbot
- `Closes: https://sashiko.dev/#/patchset/20260710052806.100107-1-
nihaal%40cse.iitm.ac.in`
- Signed-off-by: Abdun Nihaal <[email protected]> (author)
- `Link: https://patch.msgid.link/20260723-platx86-v4-2-
[email protected]`
- Reviewed-by: Ilpo Järvinen <[email protected]> (platform/x86 maintainer)
- Signed-off-by: Ilpo Järvinen <[email protected]> (applied by maintainer)
- No Fixes: tag in the committed message (expected for this review pipeline)
- No Cc: stable in the committed message; original mail **was** CCed to [email protected] (verified via b4 dig -w and the v4 cover letter on the stable list)
- No Tested-by: (cover letter: compile-tested only)

**Step 1.3: Body**
Record:
- **Bug:** device_mode_info is allocated with devm_kmalloc_array() (non-zeroed). The parse loop continues on malformed ACPI package elements, leaving those array slots uninitialized.
- **Symptom:** Uninitialized fields can be copied in update_sar_data() into context->sar_data and read from userspace via intc_data sysfs (intc_data_show()).
- **Root cause:** Allocation is not zeroed, despite parse_package() documenting that skipped entries “will have the default value of zero.”
- **Fix:** devm_kmalloc_array() → devm_kcalloc().
- **Version info in message:** none. Driver has existed since v5.15.

**Step 1.4: Hidden bug fix?**
Record: Not hidden. Explicit information-leak fix. The surrounding comment already promised zeroed skipped slots; the allocator did not provide that.

## Phase 2: Diff analysis

**Step 2.1: Inventory**
Record:
- File: drivers/platform/x86/intel/int1092/intel_sar.c (+4/−4)
- Function: parse_package()
- Scope: single-file, one-call-site surgical change

**Step 2.2: Code flow**
Record:
- **Before:** devm_kmalloc_array() returns uninitialized heap. Loop writes only successfully parsed modes; failed/malformed entries leave device_mode_info[itr] untouched.
- **After:** devm_kcalloc() zeros the whole array first, so skipped slots stay {0} as the function comment describes.
- **Path:** probe/init (sar_get_data() → parse_package()), then later sysfs read / ACPI notify (update_sar_data()).

**Step 2.3: Bug mechanism**
Record: **Uninitialized data / kernel info leak.**
Mechanism verified in this tree:
1. parse_package() allocates device_mode_info.
2. Loop uses continue on type/count/get_int_value() failures (lines 105–114).
3. update_sar_data() compares context->sar_data.device_mode to device_mode_info[itr].device_mode and copies bandtable_index, antennatable_index, sartable_index.
4. intc_data_show() emits those four ints to userspace.

If a skipped slot’s uninitialized device_mode happens to match the current mode, heap leftovers are copied into sar_data and printed.

**Step 2.4: Fix quality**
Record: Obviously correct. devm_kcalloc() is the zeroing counterpart of devm_kmalloc_array(). No API change, no lock change, no extra error path. Regression risk is negligible (slightly more work at probe to zero a small array, max 50 modes).

## Phase 3: Git history

**Step 3.1: Blame**
Record:
- Buggy skip-and-leave-uninitialized loop: dcfbd31ef4bcf (“platform/x86: BIOS SAR driver for Intel M.2 Modem”), 2021-08-20, first in **v5.15-rc1**.
- Original allocator was kmalloc_array() (also non-zeroing). Same leak class from day one.
- Matching-by-device_mode copy: 7df227847ab56 (2021-10-11).

**Step 3.2: Fixes: tag**
Record: No Fixes: on this commit. The matching parent (30c906cff490c) has Fixes: dcfbd31ef4bc. That introducer **is** an ancestor of this tree (git merge-base --is-ancestor dcfbd31ef4bcf HEAD succeeded).

**Step 3.3: File history**
Record: Recent related commits on this file:
- 30c906cff490c — convert to devm_* allocations (patch 1/2, parent of this commit)
- f5eb833730c07 — this info-leak fix (patch 2/2)
This is **patch 2/2** of a two-patch series. It is standalone *on top of patch 1*.

**Step 3.4: Author**
Record: Abdun Nihaal submitted both int1092 fixes in this series. Ilpo Järvinen (platform/x86 maintainer) reviewed and applied both. Not the original driver author (Shravan Sudhakar / Intel).

**Step 3.5: Prerequisites**
Record: **Depends on 30c906cff490c**, which changed kmalloc_objs/kmalloc_array into devm_kmalloc_array(). This hunk only applies as written if that conversion is present. In **this** tree, that parent **is** present (git merge-base --is-ancestor 30c906cff490c HEAD succeeded). No other missing helpers: devm_kcalloc() is core device-managed alloc.

## Phase 4: Mailing list / external research

**Step 4.1: Original discussion**
Record:
- b4 dig -c f5eb833730c07 → https://patch.msgid.link/20260723-platx86-
[email protected]
- Series: v1 (combined) → v2 → v3 (split 2/2) → **v4** (applied). v4 only updated the commit message per Ilpo to document the leak path.
- Cover letter: “[PATCH v4 0/2] platform/x86: int1092: Fix two bugs in SAR driver”
- Explicitly CCed [email protected]; also appeared on the stable list (spinics lists/stable/msg986235.html / msg971516.html).
- No NAK found in available archives.
- Cover letter: “Both patches are compile tested only.”

**Step 4.2: Recipients (b4 dig -w)**
Record: Abdun Nihaal; Shravan Sudhakar; Hans de Goede; Ilpo Järvinen; [email protected]; [email protected]; **[email protected]**; Sashiko. Maintainer Ilpo reviewed and applied.

**Step 4.3: Bug report**
Record: Sashiko static/agent review, not a user crash report. Closes URL did not return the specific finding body (only the Sashiko project page). Leak path is independently verifiable from the source. **UNVERIFIED:** exact Sashiko finding text.

**Step 4.4: Series**
Record: 2/2. Patch 1 (30c906cff490c) is the devm_ conversion (has Cc: stable and Fixes:). Patch 2 is this kcalloc leak fix. Both are in this tree, in order.

**Step 4.5: Stable list**
Record: Series was mailed to stable@ (cover + both patches). No evidence of a NAK or “not for stable” reason. Patch 1 later received CVE-2026-89437 (memory leak). That CVE is **patch 1**, not this info- leak commit; not used as the reason for this decision.

## Phase 5: Code semantic analysis

**Step 5.1: Functions**
Record: parse_package() modified. Related: update_sar_data(), intc_data_show(), sar_get_data(), sar_probe(), sar_get_device_mode(), intc_reg_store().

**Step 5.2: Callers**
Record:
- parse_package() ← sar_get_data() ← sar_probe() (boot/probe, MAX_REGULATORY = 3 times)
- update_sar_data() ← sar_get_device_mode() (probe + ACPI notify 0x80) and intc_reg_store() (sysfs write)
- intc_data_show() ← sysfs read of intc_data

**Step 5.3: Callees**
Record: get_int_value(), devm_kcalloc(). No locks, no I/O besides ACPI objects already passed in.

**Step 5.4: Reachability**
Record: Yes, from userspace on systems with ACPI ID INTC1092:
- DEVICE_ATTR_RO(intc_data) is mode **0444** (__DEVICE_ATTR_RO → 0444 in include/linux/device.h).
- Documented in Documentation/ABI/testing/sysfs-driver-intc_sar as /sys/bus/platform/devices/INTC1092:00/intc_data.
Unprivileged processes can read it. Triggering the *uninitialized* slots still needs malformed ACPI firmware; once those slots exist, a matching device_mode exposes leftover heap words.

**Step 5.5: Similar patterns**
Record: Same file’s loop comment already required zeros. No sibling copy of this bug in the int1092 directory. The immediately preceding series patch did not zero the array (devm_kmalloc_array), so this follow-up is required to actually close the leak.

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

**Step 6.1: Does the buggy code exist here?**
Record:
- Tree: **v7.3-rc4-27-gf0100363d8c37**, make kernelversion = **7.3.0-rc4**, VERSION=7 PATCHLEVEL=3 SUBLEVEL=0 EXTRAVERSION=-rc4.
- Driver **is** present. parse_package() / update_sar_data() / intc_data_show() all exist.
- Introducer dcfbd31ef4bcf is an ancestor (v5.15-era).
- Current file already uses devm_kcalloc() because f5eb833730c07 is an ancestor of HEAD. That is **not** treated as “already selected”; it only confirms the code and the fix belong to this lineage.
- Parent 30c906cff490c is also an ancestor, so the hunk’s devm_kmalloc_array context exists in this history.

**Step 6.2: Backport difficulty**
Record: **Clean apply** onto the parent already in this tree (4-line allocator swap in one function). No conflicting refactor of this function after the parent besides this commit itself.

**Step 6.3: Related fixes already here**
Record: Patch 1 (devm conversion) is here. That conversion **does not** zero the array, so it does not substitute for this fix. No other info- leak fix on this path.

## Phase 7: Subsystem context

**Step 7.1**
Record: drivers/platform/x86/intel/int1092/ — Intel BIOS Dynamic SAR for M.2 modem. Criticality: **PERIPHERAL / platform-specific**, but the sysfs node is world-readable, so the leak is a real userspace-visible security issue on those machines.

**Step 7.2**
Record: Low-churn mature driver (added 2021, occasional fixes).
Maintainer: Shravan Sudhakar; applied by Ilpo Järvinen (pdx86). Config:
CONFIG_INTEL_SAR_INT1092, depends on ACPI.

## Phase 8: Impact and risk

**Step 8.1: Who is affected**
Record: Users of Intel platforms with ACPI device INTC1092 and this driver loaded (WWAN SAR). Not universal; **driver/platform-specific**.

**Step 8.2: Trigger**
Record: Probe parses BIOS ACPI DSM packages. Malformed/partial packages skip slots. Later, ACPI notify or intc_reg store calls update_sar_data(); any user can read intc_data. Firmware-dependent, but the skip path is intentional (not a theoretical dead branch). Unprivileged read of the attribute: **yes**.

**Step 8.3: Failure mode**
Record: Kernel heap contents (a few integers) can be copied into a world-readable sysfs attribute. Severity: **HIGH** (info leak / security), not a panic. Matches the classic uninitialized-kmalloc-to- userspace pattern.

**Step 8.4: Risk–benefit**
Record:
- **Benefit:** High for affected hardware — closes a kernel-memory disclosure through a documented 0444 sysfs ABI; implements the behavior the function comment already promised.
- **Risk:** Very low — one allocator flag, no locking, no ABI change, no new features.
- **Ratio:** Strongly favors taking the fix.

## Phase 9: Synthesis

**Step 9.1: Evidence**

FOR:
- Real uninitialized-heap info leak to userspace via sysfs
- World-readable intc_data (0444)
- Function comment already required zeros; kmalloc/devm_kmalloc_array never provided them
- Bug present since the driver was added (v5.15); code exists in this 7.3 tree
- 4-line, obviously correct devm_kcalloc() switch
- Reviewed and applied by the platform/x86 maintainer
- Author CCed stable@; v4 series posted to the stable list
- Prerequisite patch 1 is already in this tree

AGAINST:
- Niche Intel WWAN SAR driver, not a core path
- Needs malformed ACPI to leave holes (though that path is explicit)
- Compile-tested only, no Tested-by
- Committed message omitted Fixes: / Cc: stable (not a negative per pipeline rules)

UNRESOLVED:
- Full Sashiko finding text (page did not return the patchset body)
- Full verbatim Ilpo review mail (known: he asked to document the leak path; then Reviewed-by + applied)
- lore.kernel.org WebFetch returned 403; discussion reconstructed via b4 dig, openwall, LKML archive, and spinics

**Step 9.2: Stable rules**
1. Obviously correct and tested? **PASS** (obvious kcalloc swap; maintainer review; compile-tested)
2. Real bug affecting users? **PASS** (heap data can reach sysfs)
3. Important (crash/security/corruption/deadlock)? **PASS** — security/info leak
4. Small and contained? **PASS** — 8 lines in one function
5. No new features/APIs? **PASS**
6. Can apply to this tree? **PASS** — file, function, and devm_kmalloc_array parent all exist here

**Step 9.3: Exception category**
Record: Not a device-ID/quirk/DT/build/docs exception. It is a normal **security/uninitialized-data** bugfix.

**Step 9.4: Decision**
This tree is 7.3-rc4. The INT1092 SAR driver and the non-zeroed allocation-plus-continue parse loop are part of this lineage. Switching to devm_kcalloc() is the minimal, correct way to stop leftover slab contents from being matched in update_sar_data() and printed by intc_data_show(). Prerequisite 30c906cff490c is already here, so the patch is self-contained for this tree. That is a stable- quality security fix.

### What the commit solves, and why it matters here parse_package() can skip malformed ACPI package entries and leave device_mode_info[] uninitialized. Those words can later be copied into context->sar_data and read through /sys/bus/platform/devices/INTC1092:00/intc_data (mode 0444). On 7.3 this driver is present; without zeroing, that is a kernel info leak. devm_kcalloc() closes it with no behavioral change for well-formed firmware.

### Stable rules / risk
The change is four lines, maintainer-reviewed, and does not add APIs. Benefit is closing a userspace-visible leak; regression risk is essentially zero.

### Concerns
Needs patch 1’s devm_kmalloc_array conversion — **already in this tree**. No other blockers.

Verification:
- [Phase 1] Parsed tags: Reported-by Sashiko; Reviewed-by/SOB Ilpo Järvinen; no Fixes in the commit; original mail CCed stable@
- [Phase 2] Diff: devm_kmalloc_array → devm_kcalloc in parse_package() only
- [Phase 2] Confirmed skip/continue loop and update_sar_data() copy in intel_sar.c
- [Phase 3] Introducer dcfbd31ef4bcf (v5.15-rc1) is ancestor of HEAD
- [Phase 3] Parent 30c906cff490c is ancestor of HEAD (merge-base --is-ancestor exit 0)
- [Phase 3] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- [Phase 4] b4 dig -c f5eb833730c07: v4 2/2 at patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1…v4; applied version is v4 (commit-message- only change)
- [Phase 4] b4 dig -w: pdx86 maintainers + [email protected]
- [Phase 4] Cover letter: two bugfixes, compile-tested only; Ilpo requested leak-path wording
- [Phase 4] lore.kernel.org WebFetch: 403; used openwall/LKML/spinics instead
- [Phase 5] Call chain: sar_probe → sar_get_data → parse_package; sysfs intc_data_show is 0444
- [Phase 6] Buggy parse/sysfs path exists in this tree; kcalloc is the correct fix for it
- [Phase 8] Failure mode: kernel heap integers to userspace sysfs, severity HIGH (info leak)
- UNVERIFIED: verbatim Sashiko finding body; full Ilpo review email text

**YES**

 drivers/platform/x86/intel/int1092/intel_sar.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/platform/x86/intel/int1092/intel_sar.c +4 -4
index 7263114f0b3d0..f506155f35d4d 100644
@@ -91,10 +91,10 @@ static acpi_status parse_package(struct wwan_sar_context *context, union acpi_ob
 	    item->package.count <= data->total_dev_mode)
 		return AE_ERROR;
 
-	data->device_mode_info = devm_kmalloc_array(&context->sar_device->dev,
-						    data->total_dev_mode,
-						    sizeof(*data->device_mode_info),
-						    GFP_KERNEL);
+	data->device_mode_info = devm_kcalloc(&context->sar_device->dev,
+					      data->total_dev_mode,
+					      sizeof(*data->device_mode_info),
+					      GFP_KERNEL);
 	if (!data->device_mode_info)
 		return AE_ERROR;
 
Signature · 1 line
2.53.0
author maintainer
#276 lore raw

PATCH 1/1 nvme-tcp: look up host_iface in the current netns

In reply to Sasha Levin

From: Geliang Tang <[email protected]>

[ Upstream commit 58202950e39c127d593ec4f0624d8b8985a285b1 ]

nvme_tcp_alloc_ctrl() looks opts->host_iface up in &init_net, the boot-time netns. When called from any other netns - e.g. the selftest's ns2, where ns2eth1 actually lives - the lookup misses and the controller setup fails with "invalid interface passed":

nvmet: adding nsid 1 to subsystem nqn.2014-08.org.nvmexpress.mptcpdev
nvmet_tcp: enabling port 24660 (0.0.0.0:24099)

 # nvme discover -a 10.1.1.1 --tos=0x10 --host-iface=ns2eth1
 nvme_tcp: invalid interface passed: ns2eth1
 # failed to add controller, error invalid interface

Look the device up in current->nsproxy->net_ns instead so the check sees the calling task's netns.

---

LLM Generated explanations, may be completely bogus:

This is a one-line netns-correctness fix in existing NVMe-TCP host- iface validation. The buggy lookup is in this 6.12 tree; the patch applies cleanly.

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

Step 1.1: PARSE THE SUBJECT LINE
Record: [nvme-tcp] [look up] [validate host_iface in the calling task’s netns instead of init_net]

Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Reviewed-by: Hannes Reinecke \<[email protected]\> (NVMe/storage maintainer)
- Signed-off-by: Geliang Tang \<[email protected]\> (author; MPTCP contributor)
- Signed-off-by: Keith Busch \<[email protected]\> (NVMe maintainer; applied the patch)
- No Fixes:, Reported-by, Tested-by, Link:, or Cc: stable (absence expected for this review)
- Ignore pipeline markers (Upstream commit / Sasha Levin SOB) — none in the origin commit 58202950e39c1

Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: nvme_tcp_alloc_ctrl() looks up opts->host_iface with __dev_get_by_name(&init_net, ...). In any other netns the name is missing, so controller setup fails.
- Symptom: nvme_tcp: invalid interface passed: ns2eth1 then failed to add controller, error invalid interface. Concrete repro: nvme discover -a 10.1.1.1 --tos=0x10 --host-iface=ns2eth1 from netns ns2.
- Failure mode: connect/discover abort with -ENODEV. Not a crash, leak, or corruption.
- Root cause: hardcoded boot netns instead of the calling task’s netns.
- Version info: none in the message. The log line nqn.2014-08.org.nvmexpress.mptcpdev is from an MPTCP NVMe selftest that is not in this tree; the mechanism is not MPTCP-specific.

Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a disguised cleanup. It is an explicit correctness fix:
wrong netns for a name lookup. No hidden leak/race/UAF.

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

Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/nvme/host/tcp.c (+2/−1)
- Function: nvme_tcp_alloc_ctrl()
- Scope: single-file, one-line surgical change

Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record: In the NVMF_OPT_HOST_IFACE validation path, existence check was __dev_get_by_name(&init_net, opts->host_iface). After:
__dev_get_by_name(current->nsproxy->net_ns, opts->host_iface). Normal connect path only; if the name is missing, still -ENODEV / out_free_ctrl.

Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Category: logic/correctness (wrong network namespace)
- Mechanism: interface names are per-netns. Lookup in init_net rejects names that only exist in the caller’s netns (veths, container NICs). The later SO_BINDTODEVICE already uses sock_net(sk) (net/core/sock.c sock_setbindtodevice()), and sock_create() already uses current->nsproxy->net_ns. Only this existence check was wrong.
- Not UAF/leak/race/crash. Pre-existing __dev_get_by_name without RTNL/RCU is unchanged (comment in net/core/dev.c says RTNL is required). Later MPTCP RFCs added RCU; mainline did not.

Step 2.4: ASSESS THE FIX QUALITY
Record: Obviously correct and consistent with sock_create(). Minimal. current->nsproxy is valid here: nvme_tcp_alloc_ctrl() is only called from nvme_tcp_create_ctrl() → nvmf_create_ctrl() → nvmf_dev_write() (userspace write to /dev/nvme-fabrics), not from reconnect workqueues. Regression risk very low: a caller that relied on init_net names while running in another netns would still fail later at SO_BINDTODEVICE.

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

Step 3.1: BLAME THE CHANGED LINES
Record:
- Feature: 3ede8f72a9a28 (“nvme-tcp: allow selecting the network interface for connections”), 2021-06-03, first in v5.14-rc1. Used dev_get_by_name(&init_net, ...).
- Switch to __dev_get_by_name: 8b43ced64d2bac (2021-07-13), Fixes:
3ede8f72, to avoid holding a netdev ref that blocked unregister. Still &init_net.
- Both are ancestors of this 6.12 tree. Bug present since the feature landed.

Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. Buggy pattern comes from 3ede8f72a9a28 / 8b43ced64d2bac, both in HEAD.

Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: Recent tcp.c history in this tree is TLS/PDU hardening, not host_iface. Origin after this commit has no further host_iface change on this file. Standalone v1, not “patch X/Y”.

Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Geliang Tang is an MPTCP contributor, not an NVMe maintainer. In this tree his nvme work is unrelated (nvmet-tcp leak, unused variable). On origin this is his only tcp.c host_iface change. Weight comes from Hannes’s Reviewed-by and Keith applying it.

Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: No new helpers. __dev_get_by_name and current->nsproxy->net_ns exist here. Applies standalone (hunk succeeded at offset 32). inet_pton_with_scope(&init_net, ...) for addresses is left as-is; that is a separate scope issue, not a dependency.

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

Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- SHA: 58202950e39c127d593ec4f0624d8b8985a285b1 (not in this tree; on origin)
- b4 dig: https://patch.msgid.link/c14cd4633c27abe2dec863480168691023694
[email protected]
- Thread (gnuweeb mirror; lore.kernel.org returned 403/bot wall):
standalone [PATCH], 2026-07-26
- b4 dig -a: v1 only; applied version is that v1
- Hannes Reinecke 2026-07-27: Reviewed-by. Note that discovery-log addresses in a netns may not be reachable from the initiator; not a NAK of this lookup fix.
- Keith Busch 2026-08-10: “Thanks, applied to nvme-7.3.”
- No NAK, no Cc: stable in the thread
- Earlier MPTCP RFC series combined netns + RCU (dev_get_by_name_rcu / netdev_name_in_use); the committed patch is the netns one-liner only

Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: b4 dig -w recipients: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg, Hannes Reinecke, linux-nvme. Appropriate maintainers. Hannes reviewed; Keith applied.

Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla. Evidence is the author’s selftest log (ns2eth1 in ns2). That MPTCP NVMe selftest is not in this 6.12 tree. Bug is still real for any netns + host-iface.

Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Applied as a standalone linux-nvme patch, not as part of the MPTCP NVMe series. No sibling patch required for this lookup.

Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: gnuweeb /stable/ search 404; lore.kernel.org 403. No verified stable-list discussion. UNVERIFIED: whether anyone already nominated or rejected this for stable.

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

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

Step 5.2: TRACE CALLERS
Record:
- nvme_tcp_alloc_ctrl ← nvme_tcp_create_ctrl (.create_ctrl of nvme_tcp_transport)
- ← nvmf_create_ctrl() in drivers/nvme/host/fabrics.c
- ← nvmf_dev_write() (misc device write)
- Userspace: nvme-cli connect/discover writing to /dev/nvme- fabrics
- Reconnect (nvme_tcp_setup_ctrl / nvme_tcp_alloc_queue) does not call alloc_ctrl; it reuses opts->host_iface on SO_BINDTODEVICE

Step 5.3: TRACE CALLEES
Record: __dev_get_by_name(net, name) → netdev_name_node_lookup(). Existence check only; no ref taken (that was the point of 8b43ced64d2bac).

Step 5.4: FOLLOW THE CALL CHAIN
Record: Reachable from userspace via /dev/nvme-fabrics when host_iface= is set. Privileged fabrics connect, not an unprivileged syscall smash. In this tree nvme_tcp_alloc_queue() uses sock_create() → current->nsproxy->net_ns, then sock_setsockopt(..., SO_BINDTODEVICE, ...) which looks up the name in sock_net(sk). Validation was the only init_net step on that path.

Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Only this __dev_get_by_name in drivers/nvme/. RDMA transport has no NVMF_OPT_HOST_IFACE. inet_pton_with_scope(&init_net, ...) remains for traddr/host_traddr (numeric parse; different issue).

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

Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. drivers/nvme/host/tcp.c:3000:
if (!__dev_get_by_name(&init_net, opts->host_iface))
Tree: pending-6.12, make kernelversion 6.12.111, git describe HEAD p-6.12-3-gc504cf0baa3d8. Bug since v5.14. git merge-base --is-ancestor 58202950e39c1 HEAD is false (fix not present).

Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: git apply --check of origin diff: hunk succeeded at offset 32. Local context still kcalloc (mainline later kzalloc_objs); that is after the hunk, not in it. Expected: clean apply / trivial offset.

Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No later host_iface netns fix. 1be52169 (sock_create_kern) and b013b817 (netns UAF on kernel TCP socket) are not in this tree; this patch does not depend on them.

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

Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: NVMe over Fabrics TCP host (drivers/nvme/host/tcp.c, CONFIG_NVME_TCP). Criticality: IMPORTANT — datacenter remote block storage, not core mm/vfs, not staging.

Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Actively maintained (TLS, PDU validation, etc.). host_iface itself has been stable since 5.14 with only the 2021 refcount change until this 2026 netns fix.

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

Step 8.1: DETERMINE WHO IS AFFECTED
Record: Users of NVMe-TCP who pass host_iface= from a non-init netns, when that name is not also in init_net. Driver-specific + config (CONFIG_NVME_TCP) + optional option. Typical host-net eth0 cases often pass the init_net check by accident; unique names (ns2eth1, container veths) fail.

Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Write connect/discover options including host_iface=<name> from a process whose netns is not init_net. Not every boot; only this option. Needs fabrics connect privilege, not unprivileged exploitability.

Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record: Controller creation fails (-ENODEV); no NVMe device. No oops, hang, or corruption. Severity: MEDIUM (availability of an existing option), HIGH for those who need interface pinning in a netns.

Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: medium for netns/container NVMe-TCP with host-iface; low for default host-net users
- Risk: very low (1-line, same helper, same error path)
- Ratio: favorable — almost no regression surface, real connectivity bug

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

Step 9.1: COMPILE THE EVIDENCE

FOR:
- Real, reproduced failure: host-iface rejected in non-init netns
- Feature and buggy code exist in 6.12 since v5.14
- Matches how sockets are created and bound in this tree
- One-line, obviously correct; applies with offset only
- Reviewed by Hannes Reinecke; applied by Keith Busch
- No new API/feature; restores intended host-iface behavior
- Storage connect failure is user-visible for affected deployments (containers, netns isolation, multi-homed pinning)

AGAINST:
- Not a crash, UAF, corruption, deadlock, or security bug
- Optional host-iface plus non-init netns is a relatively narrow path
- Motivating selftest (MPTCP NVMe) is not in 6.12
- Went into nvme-7.3 updates, not a -fixes pull; no stable nomination in the thread
- Hannes noted broader discovery/netns limitations (not a NAK)

UNRESOLVED:
- Stable mailing list discussion (lore blocked / gnuweeb stable 404)
- Whether distro/k8s NVMe-TCP actually uses host-iface from a container netns (plausible, not counted)

Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — one-line netns fix; maintainer Reviewed-by; author reproduced
2. Fixes a real bug that affects users? PASS — connect fails with -ENODEV for a valid interface in the caller’s netns
3. Important issue? PASS — availability of NVMe-TCP when host-iface is used from a netns; not a panic, but a functional showstopper on that path. Small correctness fixes of this kind are routine in stable
4. Small and contained? PASS — +2/−1 in one function
5. No new features or APIs? PASS
6. Can apply to the local tree? PASS — buggy line present; apply-check succeeded at offset 32

Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: None (not a device ID, quirk, DT, build, or docs fix). Qualifies as a normal small bugfix.

Step 9.4: MAKE YOUR DECISION
The local 6.12 tree still looks host_iface up in init_net while creating the TCP socket in the caller’s netns. That is a long-standing, self-contained correctness bug. Backporting this line restores connect/discover with --host-iface from containers and other netns without new infrastructure. Risk is negligible compared with leaving NVMe-TCP interface pinning broken off host netns.

===============================================================
What the commit solves for this tree
===============================================================

host_iface is supposed to force NVMe-TCP onto a named NIC via SO_BINDTODEVICE. Validation used &init_net, so a name that only exists in the calling netns is treated as invalid and controller setup aborts. In 6.12 the socket is already created with sock_create() (current netns) and bind-to-device already searches that netns. The check is the broken piece. Stable users who pin NVMe-TCP to a NIC from a netns/container hit a hard connect failure; this is the whole fix.

Risk vs benefit: benefit is restoring an existing option in netns; risk is a one-line lookup change with the same -ENODEV path. No prerequisites. inet_pton_with_scope(&init_net) is untouched and not required for this fix.

===============================================================
Verification
===============================================================
- [Phase 1] Parsed origin commit 58202950e39c1: Reviewed-by Hannes Reinecke; SOB Geliang Tang + Keith Busch; no Fixes/Cc-stable
- [Phase 2] Diff: +2/−1 in nvme_tcp_alloc_ctrl(); &init_net → current->nsproxy->net_ns
- [Phase 2] Confirmed sock_setbindtodevice() uses sock_net(sk); sock_create() uses current->nsproxy->net_ns (net/socket.c:1614)
- [Phase 3] blame: 3ede8f72a9a28 (v5.14-rc1) introduced init_net lookup; 8b43ced64d2bac switched to __dev_get_by_name, still init_net; both ancestors of HEAD
- [Phase 3] git merge-base --is-ancestor 58202950e39c1 HEAD → not an ancestor (fix absent)
- [Phase 4] b4 dig -c 58202950e39c1: lore msgid c14cd4633c27abe2...; v1 only
- [Phase 4] b4 dig -w: linux-nvme maintainers on To/Cc
- [Phase 4] Hannes: Reviewed-by plus discovery/netns remark, no NAK;
Keith: applied to nvme-7.3
- [Phase 4] lore.kernel.org 403; used lore-kernel.gnuweeb.org.
UNVERIFIED: stable@ thread
- [Phase 5] Callers via grep: only nvme_tcp_create_ctrl → nvmf_dev_write; reconnect does not call alloc_ctrl
- [Phase 6] git describe HEAD p-6.12-3-gc504cf0baa3d8; make kernelversion 6.12.111; buggy line at tcp.c:3000
- [Phase 6] git apply --check of origin diff: succeeded at offset 32
- [Phase 6] 1be52169 / b013b817 not in this tree; not required
- [Phase 8] Failure: -ENODEV / invalid interface; severity MEDIUM–HIGH availability, not crash
- UNVERIFIED: production hit rate of host-iface from container netns; MPTCP selftest not in this tree

**YES**

 drivers/nvme/host/tcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/tcp.c +2 -1
index beef2b576102a..1f26e35d7a99e 100644
@@ -2999,7 +2999,8 @@ static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(struct device *dev,
 	}
 
 	if (opts->mask & NVMF_OPT_HOST_IFACE) {
-		if (!__dev_get_by_name(&init_net, opts->host_iface)) {
+		if (!__dev_get_by_name(current->nsproxy->net_ns,
+				       opts->host_iface)) {
 			pr_err("invalid interface passed: %s\n",
 			       opts->host_iface);
 			ret = -ENODEV;
Signature · 1 line
2.53.0
#277 lore raw

Re: [PATCH AUTOSEL 6.18-5.15] nvme-tcp: look up host_iface in the current netns

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Critical] nvme-tcp: use-after-free in nvme_tcp_alloc_ctrl() via __dev_get_by_name() --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] nvme-tcp: use-after-free in nvme_tcp_alloc_ctrl() via __dev_get_by_name() --

commit 04aa71fe23c7dec86f240fa7773c4020c75d2bb7
Author: Geliang Tang <[email protected]>

nvme-tcp: look up host_iface in the current netns

This commit changes nvme_tcp_alloc_ctrl() to look up opts->host_iface in current->nsproxy->net_ns rather than init_net so that interfaces in the calling task's network namespace can be found.

drivers/nvme/host/tcp.c static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(struct device *dev, · line 2939

Quoted 11 lines
drivers/nvme/host/tcp.c +2 -1
index 9a96df1a511c0..fb6858023f19d 100644
@@ -2935,7 +2935,8 @@ static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(struct device *dev,
 	}
 
 	if (opts->mask & NVMF_OPT_HOST_IFACE) {
-		if (!__dev_get_by_name(&init_net, opts->host_iface)) {
+		if (!__dev_get_by_name(current->nsproxy->net_ns,
+				       opts->host_iface)) {

[Severity: Critical]
Is it safe to call __dev_get_by_name() here without holding rtnl_lock()?

When userspace writes connection parameters with host_iface=<name> to /dev/nvme-fabrics, the call chain:

nvmf_dev_write()

    -> nvmf_create_ctrl()
      -> nvme_tcp_create_ctrl()
        -> nvme_tcp_alloc_ctrl()

runs in sleepable process context holding only nvmf_dev_mutex, with neither rtnl_lock() nor rcu_read_lock() held.

In net/core/dev.c, __dev_get_by_name() requires the RTNL semaphore and calls netdev_name_node_lookup(), which traverses the per-netns hash bucket with non-RCU list primitives:

net/core/dev.c:netdev_name_node_lookup() {
	struct hlist_head *head = dev_name_hash(net, name);
	struct netdev_name_node *name_node;

	hlist_for_each_entry(name_node, head, hlist)
		if (!strcmp(name_node->name, name))
			return name_node;
	return NULL;
}
net/core/dev.c:__dev_get_by_name() {
	struct netdev_name_node *node_name;

	node_name = netdev_name_node_lookup(net, name);
	return node_name ? node_name->dev : NULL;
}

If a network device in current->nsproxy->net_ns is concurrently unregistered via unregister_netdevice_many_notify() -> rollback_registered_many() (which unlinks the node in unlist_netdevice(), waits for an RCU grace period via synchronize_net(), and then frees the nodes via netdev_name_node_alt_flush() and netdev_name_node_free()), has an altname deleted via netdev_name_node_alt_destroy() -> __netdev_name_node_alt_destroy(), or is renamed via dev_change_name(), neither synchronize_net() nor call_rcu() will wait for a preempted reader in nvme_tcp_alloc_ctrl().

Could this trigger a use-after-free on name_node or name_node->name during the hash list traversal, and should this lookup use dev_get_by_name_rcu() under rcu_read_lock() (or netdev_name_in_use()) instead?

Quoted 3 lines
drivers/nvme/host/tcp.c +0 -0
 			pr_err("invalid interface passed: %s\n",
 			       opts->host_iface);
 			ret = -ENODEV;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author maintainer
#278 lore raw

PATCH 1/1 net: libwx: disable TX VLAN offload for packets with >2 VLAN tags

In reply to Sasha Levin

From: Jiawen Wu <[email protected]>

[ Upstream commit f5cfb576ce39ba5647024c6d6eeb5b7a822fab6e ]

The current hardware does not support TX VLAN offload for packets with three or more VLAN tags. When such packets are transmitted with hardware VLAN offload enabled, the hardware may malfunction or produce corrupted frames.

Add a check in wx_features_check() to parse the VLAN depth of the skb. If more than two VLAN tags are detected (including both the hardware tag and in-band tags), strip NETIF_F_HW_VLAN_CTAG_TX and NETIF_F_HW_VLAN_STAG_TX from the feature set. This forces the kernel networking stack to handle VLAN insertion in software for these specific packets, ensuring correct transmission.

---

LLM Generated explanations, may be completely bogus:

The candidate is a hardware-limitation workaround in Wangxun libwx: TX VLAN offload is unsafe for more than two tags and can corrupt frames. This 7.3-rc4 tree already has wx_features_check and the VLAN TX path, so the rest of the write-up is whether that fix belongs here as a stable backport.

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**
- Record: [net/libwx] [disable] disable TX VLAN offload for packets with >2 VLAN tags
- Subsystem: net: libwx (Wangxun shared NIC library used by txgbe/ngbe)
- Verb disable is a hardware-workaround action, not a feature or cleanup

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Record:
- Signed-off-by: Jiawen Wu <[email protected]> (author; Wangxun maintainer)
- `Link: https://patch.msgid.link/069DF89AA8029189+20260713060441.2766

    [email protected]`

- Signed-off-by: Jakub Kicinski <[email protected]> (netdev maintainer, applied)
- No Fixes: tag (expected for this review pipeline)
- No Cc: [email protected]
- No Reported-by:, Tested-by:, Reviewed-by:, Acked-by:
- Ignore any pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] (none in the real commit)

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Record:
- **Bug:** Wangxun TX VLAN offload does not support three or more VLAN tags
- **Symptom / failure mode:** hardware may malfunction or produce **corrupted frames**
- **Root cause (author):** HW offload still used on >2-tag packets
- **Fix:** in wx_features_check(), count hwaccel + in-band VLAN tags; if vlan_num > 2, drop NETIF_F_HW_VLAN_CTAG_TX and NETIF_F_HW_VLAN_STAG_TX so the stack inserts in software
- **Version info in message:** none

**Step 1.4: DETECT HIDDEN BUG FIXES**
- Record: Not a disguised cleanup. This is an explicit hardware workaround for incorrect TX offload. Intel reviewer Jacob Keller treated it as a bug fix that should have gone to net with a Fixes: tag (see Phase 4).

## PHASE 2: DIFF ANALYSIS - LINE BY LINE

**Step 2.1: INVENTORY THE CHANGES**
- Record:
- File: drivers/net/ethernet/wangxun/libwx/wx_lib.c — **+24 / -0**
- Function: wx_features_check()
- Scope: single-file surgical addition inside an existing ndo_features_check hook

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
- Record:
- **Before:** wx_features_check() only restricted checksum/GSO for encapsulated packets; VLAN TX offload was left on for every packet
- **After:** count skb_vlan_tag_present() plus in-band eth_type_vlan() headers via skb_header_pointer(). If more than two tags, clear HW VLAN TX features and break
- Path: per-packet TX feature check (netif_skb_features() → ndo_features_check). Normal TX path, not probe/error-only

**Step 2.3: IDENTIFY THE BUG MECHANISM**
- Record:
- Category: **hardware workaround / logic correctness** (not UAF/leak/race)
- Mechanism: HW can insert/offload at most two VLAN tags. With a third tag and HW VLAN TX still enabled, the NIC may emit corrupted frames or malfunction
- How the fix works: validate_xmit_vlan() in net/core/dev.c sees VLAN TX offload cleared and calls __vlan_hwaccel_push_inside(), so the extra tag is inserted in software

**Step 2.4: ASSESS THE FIX QUALITY**
- Record:
- Obviously correct: this is the standard ndo_features_check pattern; skb_header_pointer() is NULL-safe; loop stops at >2 tags
- v1 skipped the in-band walk when no hwaccel tag; v2 (applied) always walks in-band tags — better
- Minimal, no API/data-structure change
- Regression risk: **low**. Extra work only while eth_type_vlan(skb->protocol) is true. Worst case is extra software VLAN insertion, not a new crash path
- Residual gap (not a reason to reject): VF drivers (txgbevf/ngbevf) use wx_xmit_frame but do **not** set ndo_features_check, so VFs are not covered

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**
- Record:
- New lines are entirely from f5cfb576ce39b (this commit)
- Surrounding wx_features_check() introduced by 3b05aa997c491 (“net: wangxun: restrict feature flags for tunnel packets”, 2025-04-22)
- TX VLAN offload itself: 3403960cdf86c (“net: wangxun: libwx add tx

    offload functions”, 2023-05-31, in v6.5-rc1)

**Step 3.2: FOLLOW THE FIXES: TAG**
- Record: No Fixes: tag. Author told Jacob Keller they could not identify one. The limitation dates to original TX VLAN offload (3403960cdf86c), not a later regression. That commit **is** an ancestor of this tree.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
- Record:
- Immediate follow-up: 732ed8f75ce58 “net: libwx: fix FDIR ATR queue mismatch for software VLAN packets” — sets WX_TX_FLAGS_SW_VLAN when VLAN is in-band; has its own Fixes: b501d261a5b3. Related when more packets take the SW VLAN path, but standalone
- Not labeled patch X/Y. Standalone 24-line addition
- Prerequisite in this tree: wx_features_check() exists

    (`3b05aa997c491` is an ancestor)

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
- Record: Jiawen Wu is the Wangxun maintainer (MAINTAINERS: M: Jiawen Wu <[email protected]>). Regular libwx/txgbe/ngbe fixes around the same time.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
- Record: Depends on wx_features_check() / ndo_features_check (3b05aa997c491). Both exist here. Helpers used (eth_type_vlan, skb_header_pointer, skb_vlan_tag_present) are long-standing core APIs. Can apply standalone on this tree.

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
- Record:
- b4 dig -c f5cfb576ce39b: [PATCH net-next v2] https://patch.msgid.l

    ink/[email protected]
  - `b4 dig -a`: v1 (2026-07-10) → v2 (2026-07-13, applied)
  - v1 review (Przemek Kitszel): style/logic nits — don’t skip the loop
    when no hwaccel tag; don’t use a dummy parse depth of 8; move the
    `vlan_num > 2` test inside the loop. All addressed in v2
  - v2 review (Jacob Keller): **asked why this went to net-next instead
    of net with a Fixes: tag to the commit that introduced VLAN
    tagging**
  - Author reply: “Probably because I couldn't find a Fixes tag for
    it...”
  - Applied to **netdev/net-next.git** by Jakub Kicinski (patchwork bot,
    2026-07-22)

- No NAKs; no reviewer objection to the fix itself
- No explicit Cc: stable in the thread (Jacob’s question is the stable-relevant signal)

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
- Record (b4 dig -w): netdev maintainers (Kicinski, Abeni, Dumazet, Miller, Horman, Lunn), Wangxun (Jiawen Wu, Duanqiang Wen, Mengyuan Lou), Intel NIC reviewers (Jacob Keller, Przemek Kitszel). Right audience.

**Step 4.3: SEARCH FOR THE BUG REPORT**
- Record: No Reported-by, syzbot, or bugzilla. Vendor/maintainer hardware-limitation report. Severity from message: corrupted frames / hardware malfunction.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
- Record: Standalone v1/v2 of one patch, not a multi-patch series. Follow-up ATR SW-VLAN fix is separate and already in this tree.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
- Record: **UNVERIFIED** — lore.kernel.org HTTP 403; no local stable@ discussion found. No evidence it was rejected for stable.

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
- Record: wx_features_check() only (exported)

**Step 5.2: TRACE CALLERS**
- Record:
- txgbe_netdev_ops.ndo_features_check = wx_features_check

    (`txgbe_main.c`)
  - `ngbe_netdev_ops.ndo_features_check = wx_features_check`
    (`ngbe_main.c`)
  - Core: `netif_skb_features()` → `dev->netdev_ops->ndo_features_check`
    (`net/core/dev.c`)

- Called from the generic TX validation path (validate_xmit_skb / xmit_one) — userspace-reachable on every transmit for those NICs
- VF ops use wx_xmit_frame but **no** ndo_features_check (coverage gap)

**Step 5.3: TRACE CALLEES**
- Record: skb_vlan_tag_present, eth_type_vlan, skb_header_pointer — read-only skb inspection; no alloc/lock/I/O

**Step 5.4: FOLLOW THE CALL CHAIN**
- Record: syscall/send path → qdisc → validate_xmit_skb() → netif_skb_features() → wx_features_check() → if VLAN TX bits dropped, validate_xmit_vlan() software-inserts the tag → wx_xmit_frame(). Reachable from userspace on Wangxun PF devices. Triple-tag is uncommon (QinQ + extra tag) but real.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
- Record: Many NICs call vlan_features_check(), which **keeps** HW VLAN TX on multi-tag skbs and only tightens csum features. Wangxun’s extra restriction is device-specific (max two tags). Same idea as other ndo_features_check HW-limit hooks, not a copy of vlan_features_check().

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
- Record:
- Local tree: **v7.3-rc4-27-gf0100363d8c37**, make kernelversion =

    **7.3.0-rc4**
  - `wx_features_check()` exists; pre-patch body had no VLAN-depth check
    (`git show f5cfb576ce39b^:...`)
  - TX VLAN flags (`WX_TXD_VLE`, `skb_vlan_tag_present` in
    `wx_xmit_frame`) exist since `3403960cdf86c`

- Candidate **is** already an ancestor of HEAD (already merged here). Evaluation is still whether the fix has stable merit for this codebase; the pre-fix function is the buggy code

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
- Record: **Clean apply** on this tree. Context is the existing wx_features_check(); no conflicting refactor of that function besides this commit and later unrelated wangxun work

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
- Record: This fix is in the tree. Related ATR SW-VLAN fix 732ed8f75ce58 is also here. No alternate fix of the >2-tag HW limit.

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
- Record: drivers/net/ethernet/wangxun/libwx — **IMPORTANT** for Wangxun NIC users (txgbe/ngbe PFs), **PERIPHERAL** vs core mm/net. Not staging.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
- Record: Actively developed (2026 wangxun commits: Tx timeout, PCIe AER, FDIR, PTP). Author is the maintainer.

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: DETERMINE WHO IS AFFECTED**
- Record: **driver-specific** — CONFIG_TXGBE / CONFIG_NGBE Wangxun PF users. Not universal. VFs not covered by this hook.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
- Record: TX of a frame with **three or more** VLAN tags (hwaccel + in- band) while HW VLAN TX is on. Uncommon vs plain Ethernet; used in QinQ/provider/NFV setups. Unprivileged users can send tagged frames if the interface/bridge allows it. Not a pure timing race.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
- Record: Corrupted TX frames and possible hardware malfunction. **HIGH** (data corruption on the wire; possible device misbehavior). Not a kernel oops, but not cosmetic.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
- Record:
- **Benefit:** high for affected Wangxun users (correct frames; avoid HW malfunction)
- **Risk:** very low (24 lines, feature-bit clear, standard stack fallback)
- **Ratio:** favors backporting

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

**FOR:**
- Real HW limit: >2 VLAN tags + HW VLAN TX → corrupted frames / malfunction
- Jacob Keller explicitly framed it as a net bugfix that needed Fixes:
- Author is the Wangxun maintainer; netdev maintainers applied it
- Small (+24), contained, no new APIs
- Uses the intended ndo_features_check mechanism
- Hardware quirk/workaround class (stable exception)
- wx_features_check and VLAN TX offload exist in this tree
- v2 addressed review nits; no NAKs

**AGAINST:**
- Sent to net-next, not net (author could not pick a Fixes: SHA)
- No public reproducer, crash log, or extra Reported-by
- Triple-tag TX is a relatively rare path
- VF devices sharing wx_xmit_frame still lack this hook

**UNRESOLVED:**
- No stable@ lore search (HTTP 403)
- “Malfunction” not independently characterized beyond the vendor commit message

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — v2 after review; applied by Kicinski; logic matches core validate_xmit_vlan()
2. Fixes a real bug that affects users? **PASS** — HW TX of >2 VLAN tags is wrong and user-triggerable
3. Important issue? **PASS** — on-wire corruption / HW malfunction (HIGH, not a core oops)
4. Small and contained? **PASS** — +24 lines, one function
5. No new features or APIs? **PASS** — disables an unsafe offload for specific packets
6. Can apply to the local tree? **PASS** — wx_features_check() present; patch is a clean addition

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
- Record: **Hardware quirk/workaround** — disable an offload the NIC cannot perform. Same class as USB/PCI/codec quirks.

**Step 9.4: DECISION**

This tree is 7.3.0-rc4 and already contains the Wangxun TX offload path and wx_features_check(). The patch is a small, reviewed workaround for a vendor-confirmed HW limit that otherwise yields corrupted frames. Missing Fixes:/Cc: stable is why it needs manual review, not a reason to drop it. Jacob Keller’s net-vs-net-next question is the right
classification: this is a bugfix, not a feature.

### What the commit solves for stable users
Wangxun PFs will no longer ask the NIC to hardware-insert/offload a third VLAN tag. Those packets fall back to software VLAN insertion, which avoids bad frames and possible device malfunction.

### Risk vs benefit
Benefit is correctness on a real (if uncommon) TX path. Risk is a few extra header walks and software VLAN push only when tags are already present.

### Concerns
- Needs wx_features_check() (present here)
- Optional companion 732ed8f75ce58 for FDIR ATR on SW-VLAN packets is already in this tree
- VFs still omit ndo_features_check; that is a remaining gap, not a regression from this patch

Verification:
- [Phase 1] Parsed subject/tags/body from git log -1 / git show f5cfb576ce39b; no Fixes/Reported-by/Cc: stable
- [Phase 2] Diff: +24 in wx_features_check() only; confirmed current file at wx_lib.c:3265-3313
- [Phase 2] Confirmed stack fallback: validate_xmit_vlan() in net/core/dev.c:3971-3977
- [Phase 3] git blame on wx_features_check: body from 3b05aa997c491; new VLAN loop from f5cfb576ce39b
- [Phase 3] TX offload intro 3403960cdf86c (v6.5-rc1); git merge-base --is-ancestor both 3b05aa997c491 and 3403960cdf86c vs HEAD: yes
- [Phase 3] Follow-up 732ed8f75ce58 exists; not a required prereq for this hunk
- [Phase 3] Author Jiawen Wu listed as Wangxun maintainer in MAINTAINERS
- [Phase 4] b4 dig -c/-a/-w/-m: v1→v2, lore msgid 069DF89AA8029189+...; Przemek nits on v1; Jacob Keller asked why not net+Fixes; author said no Fixes SHA; applied to net-next
- [Phase 4] lore WebFetch 403; v1 retrieved via b4 mbox
- [Phase 5] Callers: txgbe_main.c:705, ngbe_main.c:681; netif_skb_features in net/core/dev.c:3895-3924
- [Phase 5] VF netdev_ops: ndo_start_xmit=wx_xmit_frame, no ndo_features_check
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4; pre-patch function confirmed via git show f5cfb576ce39b^
- [Phase 8] Failure mode from commit text + HW offload path: corrupted frames / malfunction, severity HIGH
- UNVERIFIED: stable@ mailing-list history (lore 403); independent crash/reproducer beyond vendor description

**YES**

 drivers/net/ethernet/wangxun/libwx/wx_lib.c | 24 +++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/net/ethernet/wangxun/libwx/wx_lib.c +24 -0
index 4a6851612368d..9be339965a683 100644
@@ -3193,6 +3193,30 @@ netdev_features_t wx_features_check(struct sk_buff *skb,
 				    netdev_features_t features)
 {
 	struct wx *wx = netdev_priv(netdev);
+	__be16 type = skb->protocol;
+	u16 vlan_depth = ETH_HLEN;
+	u32 vlan_num = 0;
+
+	if (skb_vlan_tag_present(skb))
+		vlan_num++;
+
+	while (eth_type_vlan(type)) {
+		struct vlan_hdr vhdr, *vh;
+
+		vh = skb_header_pointer(skb, vlan_depth, sizeof(vhdr), &vhdr);
+		if (unlikely(!vh))
+			break;
+
+		type = vh->h_vlan_encapsulated_proto;
+		vlan_depth += VLAN_HLEN;
+		vlan_num++;
+
+		if (vlan_num > 2) {
+			features &= ~(NETIF_F_HW_VLAN_CTAG_TX |
+				      NETIF_F_HW_VLAN_STAG_TX);
+			break;
+		}
+	}
 
 	if (!skb->encapsulation)
 		return features;
Signature · 1 line
2.53.0
author maintainer
#279 lore raw

PATCH 1/1 iio: adc: max1241: add missing MODULE_DEVICE_TABLE()

In reply to Sasha Levin

From: Pengpeng Hou <[email protected]>

[ Upstream commit 790a2080e0c9eabefea3561dec301172043de236 ]

The driver has a match table for the spi bus wired into its driver structure, but the table is not exported with MODULE_DEVICE_TABLE().

Add the missing MODULE_DEVICE_TABLE() entry so module alias information is generated for automatic module loading.

This is a source-level fix. It does not claim dynamic hardware reproduction; the evidence is the driver-owned match table, its use by the driver registration structure, and the missing module alias publication.

---

LLM Generated explanations, may be completely bogus:

The local checkout is mainline **7.3.0-rc4** (v7.3-rc4-27, origin/master). The change is a one-line MODULE_DEVICE_TABLE(spi, …) for an existing IIO ADC driver. Below is the full checklist against that tree.

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

**Step 1.1: PARSE THE SUBJECT LINE**
Record: [iio: adc: max1241:] [add] [export the existing SPI id_table via MODULE_DEVICE_TABLE so udev can autoload the module]

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Fixes: none (expected)
- Reported-by: none
- Tested-by: none
- Reviewed-by: Andy Shevchenko <[email protected]>
- Acked-by: none
- Link: none in the git commit
- Cc: [email protected]: none (expected)
- Signed-off-by: Pengpeng Hou <[email protected]> (author)
- Signed-off-by: Jonathan Cameron <[email protected]> (IIO maintainer)
- No syzbot, no CVE, no bugzilla

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** max1241_id[] is wired to spi_driver.id_table, but not published with MODULE_DEVICE_TABLE(spi, …).
- **Symptom:** file2alias never emits spi:max1241, so udev/modprobe will not autoload max1241.ko for SPI-id instantiation.
- **Failure mode:** driver stays unloaded until a manual modprobe / builtin; not a crash.
- **Version info in message:** none.
- **Root cause:** missing module-alias publication for an already- registered match table.
- The “source-level fix / no dynamic hardware reproduction” paragraph is in the original lore submission, not a stable-pipeline marker.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is an explicit autoload/modalias fix. Same pattern as other “publish the module alias” patches.

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

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/iio/adc/max1241.c (+1 / -0)
- Function/data: none rewritten; one macro after max1241_id[]
- Scope: single-file, one-line surgical fix

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** SPI id table exists and is used at bind time if the module is already loaded; modules.alias has no spi:max1241.
- **After:** build-time alias spi:max1241 is generated (same mechanism as the existing MODULE_DEVICE_TABLE(of, max1241_dt_ids)).
- **Path affected:** module autoload for SPI-id devices. Probe/runtime I/O unchanged.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **Hardware matching / module autoload (logic/correctness, device-ID class).** Not UAF, leak, race, or crash. MODULE_DEVICE_TABLE is consumed by scripts/mod/file2alias.c (do_spi_entry).

**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct; matches every other SPI IIO ADC in this tree. No API, locking, or control-flow change. Regression risk is negligible. The committed hunk matches the driver after d04a09b41d2e2 ({ .name = "max1241" }); the lore v1 still had { "max1241", max1241 }, but the macro placement is identical.

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

**Step 3.1: BLAME THE CHANGED LINES**
Record: max1241_id[] and id_table come from 8a80a71d9020b (“iio:
adc: Add MAX1241 driver”, 2020-04-03), contained in **v5.8-rc1**. OF table had MODULE_DEVICE_TABLE(of, …) from day one; SPI publication was omitted then and stayed omitted until this commit.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Introduction commit is 8a80a71d9020b (v5.8). No later competing fix for the same SPI alias.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES** Record (file log, no --all):
- 790a2080e0c9e — this commit (v7.3-rc1)
- d04a09b41d2e2 — simplify id table (named initializer; not a prerequisite for the macro)
- 09e3bdfe499d5 — id-table formatting
- Driver added in 8a80a71d9020b
Standalone; not patch X/Y.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Pengpeng Hou is a regular contributor of the same MODULE_DEVICE_TABLE pattern (IIO bmi270, rtc, vdpa, watchdog, hwmon, fbdev). Not the IIO maintainer. Same-day sibling: 87359c88846fa (`iio:
imu: bmi270: add missing MODULE_DEVICE_TABLE()`), also applied by Jonathan Cameron.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. Macro sits next to an array that has existed since v5.8. Applies on both old { "max1241", max1241 } and new .name forms.

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

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 790a2080e0c9e →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only** (no v2/v3)
- Thread: Andy Shevchenko Reviewed-by; Jonathan Cameron applied it.
- **Maintainer comment (verbatim from mbox):** “I'm not rushing this in given we don't have reports of it actually causing problems for any users. Applied to the testing branch of iio.git which means it'll go upstream in the next merge window.”
- No NAK. No Cc: stable in review. Landed in iio-for-7.3a (merge window), not iio-fixes.

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc were Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel. Andy reviewed; Jonathan applied.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by, no bugzilla, no syzbot. Author presents it as source-level evidence (table present, not exported). No hardware repro claimed.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Same-day IIO sibling bmi270 (OF table, more important for DT autoload). This max1241 patch is a single standalone [PATCH], not a numbered series.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search for this subject/max1241 found **no** discussion of *this* commit. Broader MODULE_DEVICE_TABLE search **did** show current stable practice taking the same class, e.g. [PATCH 6.18 190/398] Input: eeti_ts - publish the OF module alias, ASoC “Publish the OF/PCI module aliases” into 6.12/6.18. Those are the same autoload-publication category Greg is shipping now.

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

**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: No function body changed. Added MODULE_DEVICE_TABLE(spi, max1241_id) beside max1241_id[]. Related symbols:
max1241_spi_driver.id_table, module_spi_driver().

**Step 5.2: TRACE CALLERS**
Record: Runtime callers of max1241_probe are SPI core bind (module_spi_driver). The new macro is **not** called at runtime; scripts/mod/file2alias.c do_spi_entry reads it at modpost. Userspace trigger is udev/modprobe on MODALIAS=spi:max1241.

**Step 5.3: TRACE CALLEES**
Record: N/A for the added line. Existing probe still uses regulators/GPIO/IIO register.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Reachable when CONFIG_MAX1241=m and a SPI device is instantiated by **SPI id** (spi_board_info / spi_new_device / ACPI SPI name), not by DT. DT already autoloads via existing MODULE_DEVICE_TABLE(of, max1241_dt_ids) (of:N*T*Cmaxim,max1241). No in-tree DTS or board file instantiates max1241 (only Documentation/devicetree/bindings/iio/adc/maxim,max1241.yaml).

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Dozens of drivers/iio/adc/* files already have MODULE_DEVICE_TABLE(spi, …) (max1118.c, max11205.c, ad7476.c, …). Historical IIO fixes of the same bug: 8f0d7daf53972 (imx25-gcq autoload), 447ccb4e0834a (qcom-spmi-adc5, had Cc: stable), cc3304052a89a (stm32-dfsdm aliases).

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- git describe HEAD → v7.3-rc4-27-gf0100363d8c37
- make kernelversion → 7.3.0-rc4
- Driver is present (drivers/iio/adc/max1241.c, CONFIG_MAX1241).
- Bug introduced **v5.8**, long before this branch.
- git merge-base --is-ancestor 790a2080e0c9e HEAD → yes; this commit landed in **v7.3-rc1**. Current file already has the SPI MODULE_DEVICE_TABLE. That is expected on mainline; it does **not** mean the autoload bug is absent from older stables that still have the v5.8-style driver. The SPI id table and OF table this patch depends on are both here.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply. One line after the existing max1241_id[] terminator. No refactor required. Table-format commits (09e3bdfe499d5, d04a09b41d2e2) do not block the macro.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This is the SPI-table publication. OF publication was always present. No alternate SPI-alias fix in the file log.

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

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/iio/adc/ — **PERIPHERAL/IMPORTANT**: IIO ADC, one Maxim SPI chip (CONFIG_MAX1241). Not mm/net/core. Users are boards with this ADC, typically DT.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: IIO ADC is actively developed (continuous iio-for-7.3a / fixes merges). This particular file is mature (added 2020, infrequent changes).

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

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / config-specific** (CONFIG_MAX1241=m). Built-in (=y) is unaffected. DT users already autoload via OF aliases. Remaining gap: SPI-id (non-DT) instantiation.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Module build + SPI device named max1241 without OF compatible. Not every boot; not a syscall crash path. Unprivileged users do not trigger it directly. No in-tree board/DTS consumer of the SPI id was found.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Failure mode:** module not autoloaded; ADC node missing until manual load. **Severity: LOW–MEDIUM** (functionality, not oops/corruption/deadlock). Workaround: modprobe max1241.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** restores SPI-id autoload for a driver that already claims id_table; same class Greg is taking (“publish the … module alias”).
- **Risk:** very low (one macro, no runtime logic).
- **Ratio:** favorable *because* cost is ~zero, even though user population for the SPI-id path is small.

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

**Step 9.1: COMPILE THE EVIDENCE**

**FOR backporting:**
- Real autoload bug: SPI match table registered but not exported.
- One line, obviously correct, reviewed (Andy Shevchenko) and merged by the IIO maintainer.
- Same class as device-ID / module-alias publication, which stable currently accepts (eeti_ts OF alias on 6.18/7.2; ASoC OF/PCI aliases on 6.12/6.18).
- Earlier IIO autoload fixes used Cc: stable (447ccb4e0834a).
- Driver present since v5.8; no missing prerequisites in this tree.
- Zero runtime regression surface.

**AGAINST backporting:**
- Not a crash, UAF, deadlock, or data-corruption bug.
- OF MODULE_DEVICE_TABLE already exists, so the normal DT path already works.
- Maintainer delayed it to the merge window specifically because there were **no user reports**.
- No in-tree DTS/board instantiation of the SPI id.
- Author series is a static sweep of missing tables, not an incident report.

**UNRESOLVED:**
- How many production boards instantiate max1241 by SPI board_info/ACPI rather than DT (no evidence found).
- WebFetch to lore returned 403/timeout; thread was recovered via b4 dig -m instead.

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — one macro, reviewed, in mainline v7.3-rc1.
2. Fixes a real bug that affects users? **PASS** — missing spi: alias when CONFIG_MAX1241=m; impact is real but narrow.
3. Important issue? **PASS** under the device-ID / module-alias exception (not a crash). Official stable-kernel-rules.rst allows “just add a device ID”; publishing the existing SPI id is that mechanism.
4. Small and contained? **PASS** — +1 line, one file.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — surrounding max1241_id[] / id_table exist; hunk is a single insertion.

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Device ID / module-alias publication** (not a new driver, not a new API). Closest listed exception: adding IDs to an existing driver. Build/docs/quirk categories do not apply.

**Step 9.4: MAKE YOUR DECISION**
This tree has the driver and the SPI id table the patch exports. The change is a one-line, zero-risk autoload fix of a type already going into stable. Maintainer caution (no reports, not iio-fixes) lowers severity but does not make it a cleanup or a new feature. Criterion 3 is met via the device-ID exception, not via crash/security.

What it solves for stable users: if max1241 is built as a module and the chip is created by SPI id rather than DT, udev can load the driver instead of leaving the ADC unbound. DT users are already covered; the extra alias does not change their path.

Risk vs benefit: benefit is modest and device-specific; risk is effectively none. That trade-off matches other “publish the module alias” stable commits.

### Verification
- [Phase 1] Parsed tags: Reviewed-by Andy Shevchenko; SOB Jonathan Cameron; no Fixes/Reported-by/Cc: stable/syzbot
- [Phase 1] Body: missing SPI MODULE_DEVICE_TABLE; autoload aliases; source-level, no hardware repro
- [Phase 2] Diff: +1 line in drivers/iio/adc/max1241.c after max1241_id[]
- [Phase 3] git blame: table from 8a80a71d9020b (v5.8-rc1); OF table always exported; SPI table not
- [Phase 3] No Fixes: tag; introduction commit confirmed via git show / git describe --contains --match 'v*'
- [Phase 3] Author also landed 87359c88846fa (bmi270 MODULE_DEVICE_TABLE) the same day
- [Phase 3] git merge-base --is-ancestor 790a2080e0c9e HEAD exit 0; contained in v7.3-rc1
- [Phase 4] b4 dig -c 790a2080e0c9e:
https://patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: IIO maintainers + linux-iio
- [Phase 4] b4 dig -m /tmp/max1241-thread.mbox: Andy Reviewed-by;
Jonathan: not rushing, no user reports, testing branch / next merge window
- [Phase 4] lore.kernel.org/stable: no thread for this commit; other “publish the module alias” patches are in 6.12/6.18/7.2
- [Phase 5] file2alias.c do_spi_entry generates SPI aliases; probe path unchanged
- [Phase 5] No in-tree DTS/board max1241 users (grep arch/ and dts); only DT binding YAML
- [Phase 6] git describe HEAD = v7.3-rc4-27; kernelversion 7.3.0-rc4; driver + both match tables present
- [Phase 6] Pre-fix parent 790a2080e0c9e^ has SPI table and OF MODULE_DEVICE_TABLE, no SPI MODULE_DEVICE_TABLE
- [Phase 7] Subsystem IIO ADC, CONFIG_MAX1241 tristate “module will be called max1241”
- [Phase 8] Failure mode: missing autoload, severity LOW–MEDIUM; risk very low
- UNVERIFIED: real-world count of non-DT max1241 boards (no evidence found; not used as a YES driver)
- UNVERIFIED: WebFetch lore (403/timeout); replaced by b4 dig mbox + curl

The patch is a one-line, obviously correct module-alias export for an existing SPI id table. This tree has the driver (since v5.8). It matches the device-ID/module-alias exception and current stable practice for “publish the module alias” fixes, with negligible regression risk.

**YES**

 drivers/iio/adc/max1241.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/adc/max1241.c +1 -0
index d62c1a0116593..cab04beae7293 100644
@@ -179,6 +179,7 @@ static const struct spi_device_id max1241_id[] = {
 	{ "max1241", max1241 },
 	{ }
 };
+MODULE_DEVICE_TABLE(spi, max1241_id);
 
 static const struct of_device_id max1241_dt_ids[] = {
 	{ .compatible = "maxim,max1241" },
Signature · 1 line
2.53.0
author maintainer
#280 lore raw

PATCH 1/1 wifi: ath12k: fix scan command endianness on big endian

In reply to Sasha Levin

From: Alexander Wilhelm <[email protected]>

[ Upstream commit 6c90f68f97de591e0413f7d2de59449a0388bbab ]

ath12k_wmi_scan_req_arg stores scan parameters in CPU-native byte order, while ath12k_wmi_send_scan_start_cmd() writes them into a WMI command buffer whose contents must be in little-endian format. The existing code copies the channel list and writes s_ssid and hint_bssid related values to the command buffer without endian conversion. As a result, scan requests contain invalid parameters on big-endian systems and fail.

Convert the channel list as well as the s_ssid and hint_bssid related values to little-endian before writing them to the WMI command buffer. This preserves the existing behaviour on little-endian systems while fixing scan requests on big-endian architectures.

---

LLM Generated explanations, may be completely bogus:

The local tree is **v7.3-rc4** (mainline). The buggy ath12k scan path is present here, and this is a small, real endianness fix for scan commands on big-endian hosts.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**
- Record: **[ath12k / wifi] [fix] [scan WMI command missing little- endian conversion on big-endian]**

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Record:
- No Fixes: tag (expected for this review)
- No Reported-by: / Tested-by: / Cc: stable
- Reviewed-by: Rameshkumar Sundaram <[email protected]> (Qualcomm ath12k)
- Reviewed-by: Baochen Qiang <[email protected]> (Qualcomm ath12k)
- `Link: https://patch.msgid.link/20260703-fix-channel-list-

    [email protected]`

- Signed-off-by: Alexander Wilhelm <[email protected]> (author; Westermo)
- Signed-off-by: Jeff Johnson <[email protected]> (ath12k maintainer; applied)
- Ignore pipeline-added Sasha Levin SOB if present (not on this commit)

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Record:
- **Bug:** ath12k_wmi_scan_req_arg is CPU-endian; the WMI start-scan buffer must be little-endian. Channel list is memcpy'd; s_ssid / hint_bssid integers are assigned without cpu_to_le32.
- **Symptom:** scan start commands carry invalid channel/hint values on big-endian; scans fail.
- **Root cause:** missing endian conversion on those TLV payloads (other scalar fields in the same function already use cpu_to_le32).
- **Version info:** none in the message. Buggy code dates to the original ath12k driver.

**Step 1.4: DETECT HIDDEN BUG FIXES**
- Record: **Not a hidden fix.** Subject and body state an endianness correctness bug. Not cleanup/refactor.

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES**
- Record:
- drivers/net/wireless/ath/ath12k/wmi.c: 20 insertions / 8 deletions
- drivers/net/wireless/ath/ath12k/wmi.h: 10 insertions
- **Net:** +22 / −8, two files
- **Function:** ath12k_wmi_send_scan_start_cmd()
- **Scope:** single-function surgical fix plus two local wire-format structs

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
- Record:
- **Channel list:** memcpy of host u32 channel frequencies → per-

    element `cpu_to_le32` into `__le32 *`.
  - **Hint short SSID:** raw `u32` assigns → `cpu_to_le32` into
    `ath12k_wmi_hint_short_ssid_params` (`__le32` fields).
  - **Hint BSSID:** `freq_flags` raw assign → `cpu_to_le32` into
    `ath12k_wmi_hint_bssid_params`.

- **Normal path** (every scan start), not an error-only path. LE behavior unchanged (cpu_to_le32 is identity on LE).

**Step 2.3: IDENTIFY THE BUG MECHANISM**
- Record: **[Type / endianness]** Host-endian u32s were placed in a LE WMI buffer. Firmware then sees swapped channel numbers (e.g. 2412 / 0x0000096c becomes 0x6c090000) and rejects or mis-handles the scan.

**Step 2.4: ASSESS THE FIX QUALITY**
- Record: **Obviously correct.** Same function already converts num_chan, dwell times, SSID length, etc. with cpu_to_le32. New *_params structs match existing ath12k_wmi_ssid_params (__le32 ssid_len). **Regression risk: very low** on LE; no API/locking/refcount change. Review found a pre-existing swapped ether_addr_copy on hint BSSID; that was **not** mixed into this patch (separate commit 7b0bd40e97a00).

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**
- Record: Buggy memcpy(tmp_ptr, arg->chan_list, ...) and hint field copies come from **d889913205cf7 (“wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices”)**, Kalle Valo, 2022-11-28. First appeared in **v6.3-rc1**. Long-lived, not recent churn.

**Step 3.2: FOLLOW THE FIXES: TAG**
- Record: **No Fixes: tag.** Introduction commit is d889913205cf7, ancestor of this HEAD (git merge-base --is-ancestor of the fix itself is true). This tree contains both the original driver and the fix.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
- Record:
- Immediate predecessor on this function: 7b0bd40e97a00 “Correctly copy the hint BSSID in WMI scan request” (same day in the ath tree). Independent bug (copy direction).
- Later wmi.c commits (c42b27336eeff, TLV/overread fixes) do **not** revert or rework this endian conversion.
- Same author earlier: 9eb6f553026e1 “enforce CPU endian format for all QMI data” — same BE enablement effort.
- **Standalone** for the endian bug; not patch N/M of a series (v2 of a single patch).

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
- Record: Alexander Wilhelm (Westermo) has ath12k BE work; not the subsystem maintainer. Applied by **Jeff Johnson** (Qualcomm ath12k maintainer) after Qualcomm reviews.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
- Record: No new helpers. Uses existing cpu_to_le32. Hint *_params structs are added in this patch. 7b0bd40e97a00 is **not** a semantic prerequisite for channel-list conversion; it only changes ether_addr_copy argument order. **Can apply standalone** (possible one-hunk context mismatch on trees that still have the swapped copy).

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
- Record:
- Lore/msgid: `https://patch.msgid.link/20260703-fix-channel-list-

    [email protected]`

- **v1:** 2026-03-17? (msgid dated 2026-06-29) “fix channel list copy on big endian”
- **v2:** 2026-07-03 “fix scan command endianness on big endian” — rebase; also convert s_ssid / hint_bssid; reworded message
- Applied version is **v2** (latest).
- **No NAK.** Baochen asked whether to also fix swapped ether_addr_copy; Jeff: **separate patch**. Rameshkumar and Baochen Reviewed-by. Jeff: “Applied, thanks!”
- **No reviewer Cc: stable.**

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
- Record: Recipients: Jeff Johnson, Baochen Qiang, linux-wireless, [email protected], linux-kernel. Right maintainers/lists. Two Qualcomm Reviewed-bys; maintainer applied it.

**Step 4.3: SEARCH FOR THE BUG REPORT**
- Record: No syzbot/bugzilla. Author is a vendor using BE + ath12k (consistent with their prior QMI endian patch). Failure mode described as scan failure, not a crash dump.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
- Record: Single-patch series. Related: 7b0bd40e97a00 (hint BSSID copy direction), prompted by Baochen on this thread. Not required for the channel-list endian fix.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
- Record: No stable-list discussion found for this subject. WebSearch on lore.kernel.org/stable did not return this patch. **UNVERIFIED** beyond that search (lore.kernel.org HTTP 403 from this environment).

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: IDENTIFY KEY FUNCTIONS**
- Record: ath12k_wmi_send_scan_start_cmd() only. New structs:
ath12k_wmi_hint_short_ssid_params, ath12k_wmi_hint_bssid_params.

**Step 5.2: TRACE CALLERS**
- Record:
- ath12k_wmi_send_scan_start_cmd ← ath12k_start_scan

    (`mac.c:5407`)
  - `ath12k_start_scan` ← hw scan (`mac.c:5727`, fills `chan_list[i] =
    chan_list[i]->center_freq`)
  - `ath12k_start_scan` ← remain-on-channel (`mac.c:14062`,
    `chan_list[0] = chan->center_freq`)

- **Userspace-reachable** via nl80211 scan / ROC. Not IRQ.

**Step 5.3: TRACE CALLEES**
- Record: Builds a WMI skb (ath12k_wmi_alloc_skb), fills TLVs, ath12k_wmi_cmd_send(..., WMI_START_SCAN_CMDID). Firmware then runs the scan.

**Step 5.4: FOLLOW THE CALL CHAIN**
- Record: cfg80211/mac80211 scan or ROC → ath12k_mac → WMI start-scan. **Yes, userspace-triggerable.** Channel list is always filled on those paths. num_hint_s_ssid / num_hint_bssid are **never assigned** in this tree (stay 0 from kzalloc); hint conversions are still correct but not the live bug. **The live bug is the channel list on every scan/ROC.**

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
- Record: Other fields in the same command already use cpu_to_le32. ath12k_wmi_ssid_params already has __le32 ssid_len. Sibling ath11k ath11k_wmi_send_scan_start_cmd still copies chan_list as host u32 without cpu_to_le32 (ath11k WMI structs are less consistently __le32). Other ath12k endian fixes exist (2adcddd8a316e vdev create, 8f1a078842d4a WMI service bits, 1cfa6d4e5bd9b HAL TLV).

---

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
- Record: **Yes.** Tree is **v7.3-rc4** (7.3.0-rc4, HEAD f0100363d8c37). ath12k and ath12k_wmi_send_scan_start_cmd exist. Bug introduced **v6.3**; not after this branch. The fix commit 6c90f68f97de5 is already an ancestor of HEAD; current wmi.c already has the cpu_to_le32 channel loop. Evaluating technical merit for this codebase, not “already queued.”

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
- Record: **Clean apply here** (already present). New structs are additive. On older stables without 7b0bd40e97a00, one ether_addr_copy context hunk may need a trivial refresh; channel- list hunk is independent.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
- Record: This exact fix is in the tree. No alternate/earlier endian fix for this memcpy. No revert.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
- Record: **wifi / ath12k (Qualcomm Wi-Fi 7)** — **IMPORTANT** (not mm/core; real devices and scan/ROC depend on it).

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
- Record: **Active** (frequent wmi.c fixes). This particular memcpy has been wrong since the driver landed in v6.3.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: DETERMINE WHO IS AFFECTED**
- Record: **Driver-specific + endian-specific:** CONFIG_ATH12K on big- endian CPUs. LE ath12k (typical x86/ARM) unchanged. Author affiliation indicates real BE industrial use.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
- Record: **Any scan or remain-on-channel.** Common for Wi-Fi (network manager, iw scan, P2P/ROC). Unprivileged users can trigger scans depending on policy; not a UAF/crash primitive. Not a race.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
- Record: **Scan/ROC commands invalid on BE → scan fails / association cannot find APs.** Not oops/deadlock/corruption. **Severity: HIGH** for BE ath12k (driver largely unusable for STA), **LOW** for LE majority.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
- Record:
- **Benefit:** Restores scanning on BE ath12k; no-op on LE.
- **Risk:** Very low (~22 lines, cpu_to_le32 only, internal structs).
- **Ratio:** Favorable. Classic endianness driver fix.

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

**FOR backporting:**
- Real, user-visible bug: WMI scan channel list (and hint integers) not converted to LE.
- Hits every hw scan and ROC on BE; firmware gets garbage channel numbers.
- Small, matches existing conversions in the same function.
- Present since v6.3; this tree has the driver.
- Reviewed and applied by Qualcomm ath12k maintainers; v2 addressed review (hints + rebase).
- cpu_to_le32 is identity on LE → negligible regression risk.
- Endianness/type bugs are a documented stable category.

**AGAINST:**
- Not crash/UAF/security/deadlock.
- BE + ath12k is a smaller population than x86/ARM LE.
- No Fixes: / Cc: stable / syzbot (absence expected; not a negative).
- Hint paths appear unused in this tree (still correct to convert).

**UNRESOLVED:**
- Full lore.kernel.org HTML was 403; thread recovered via b4 dig -m.
- No stable-list thread found.
- No in-tree test proving a specific BE board besides the author’s description.

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — same conversion pattern as the rest of the command; Qualcomm review + maintainer apply. Author exercised BE.
2. Fixes a real bug that affects users? **PASS** — scans fail on BE.
3. Important issue? **PASS** — Wi-Fi scan/ROC broken on affected systems (endianness correctness), not a style tweak.
4. Small and contained? **PASS** — two files, +22/−8, one function.
5. No new features or APIs? **PASS** — internal __le32 wire structs only.
6. Can apply to the local tree? **PASS** — ath12k WMI scan path exists here; hunks match.

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
- Record: Not a device-ID/quirk/DT/build/docs exception. Standard correctness fix.

**Step 9.4: MAKE YOUR DECISION**
This tree has the ath12k scan WMI path introduced in v6.3. Missing cpu_to_le32 on the channel list makes scanning fail on big-endian; the patch is small, matches existing WMI encoding, and is a no-op on little- endian. It meets stable rules for this checkout.

---

## What the commit solves and why it matters

ath12k_wmi_send_scan_start_cmd() already converted scalar WMI fields with cpu_to_le32, but copied chan_list with memcpy and assigned hint integers in CPU order. On big-endian, firmware sees swapped frequencies, so scan/ROC fail. Stable users of ath12k on BE cannot scan or remain-on-channel without this. LE users see no behavior change.

## Risk vs benefit

Benefit is restoring a core Wi-Fi operation on BE. Risk is very low:
surgical conversions, no locking/API change, identity transform on LE.

## Concerns

No functional dependency on other patches for the channel-list fix. Hint BSSID ether_addr_copy direction is a separate commit already in this tree. Backport to older stables may need a one-line context tweak if that copy-direction fix is absent.

---

## Verification
- [Phase 1] Parsed tags: two Qualcomm Reviewed-by; maintainer SOB; msgid.link; no Fixes/stable/syzbot
- [Phase 2] Diff: wmi.c + wmi.h, +22/−8; memcpy → cpu_to_le32 loop; hint fields converted; two __le32 structs added
- [Phase 3] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion: 7.3.0-rc4
- [Phase 3] git merge-base --is-ancestor 6c90f68f97de5 HEAD: yes (exit
0)
- [Phase 3] git blame on parent: buggy memcpy/assigns from d889913205cf7 (v6.3-rc1)
- [Phase 3] Related: 7b0bd40e97a00 hint BSSID copy; 9eb6f553026e1 QMI endian; no revert after this fix
- [Phase 4] b4 dig -c 6c90f68f97de5: v2 msgid 20260703-fix-channel- [email protected]
- [Phase 4] b4 dig -a: v1 channel-list-only → v2 also converts hints
- [Phase 4] b4 dig -w: Jeff Johnson, Baochen Qiang, linux-wireless, ath12k list
- [Phase 4] mbox: Baochen/Rameshkumar R-b; Jeff applied; swapped ether_addr_copy deferred to separate patch (no NAK of endian fix)
- [Phase 4] lore.kernel.org fetch: 403; used b4 mbox + mirrors
- [Phase 4] stable list search: no discussion found
- [Phase 5] Callers: ath12k_start_scan ← hw scan (mac.c:5727) and ROC (mac.c:14062); both write chan_list as center_freq
- [Phase 5] num_hint_* never assigned in ath12k (remain 0)
- [Phase 6] Current tree already contains the converted loop at wmi.c:2739-2740
- [Phase 8] Failure: invalid WMI scan params on BE → scan failure; not oops
- UNVERIFIED: specific BE board log beyond commit text; full lore HTML

**YES**

 drivers/net/wireless/ath/ath12k/wmi.c | 20 ++++++++++++--------
 drivers/net/wireless/ath/ath12k/wmi.h | 10 ++++++++++
 2 files changed, 22 insertions(+), 8 deletions(-)
drivers/net/wireless/ath/ath12k/wmi.c +12 -8
index 39d5110eca901..91f293ab70137 100644
@@ -2666,9 +2666,10 @@ int ath12k_wmi_send_scan_start_cmd(struct ath12k *ar,
 	struct wmi_tlv *tlv;
 	void *ptr;
 	int i, ret, len;
-	u32 *tmp_ptr, extraie_len_with_pad = 0;
-	struct ath12k_wmi_hint_short_ssid_arg *s_ssid = NULL;
-	struct ath12k_wmi_hint_bssid_arg *hint_bssid = NULL;
+	__le32 *tmp_ptr;
+	u32 extraie_len_with_pad = 0;
+	struct ath12k_wmi_hint_short_ssid_params *s_ssid = NULL;
+	struct ath12k_wmi_hint_bssid_params *hint_bssid = NULL;
 
 	len = sizeof(*cmd);
 
@@ -2751,9 +2752,10 @@ int ath12k_wmi_send_scan_start_cmd(struct ath12k *ar,
 	tlv = ptr;
 	tlv->header = ath12k_wmi_tlv_hdr(WMI_TAG_ARRAY_UINT32, len);
 	ptr += TLV_HDR_SIZE;
-	tmp_ptr = (u32 *)ptr;
+	tmp_ptr = (__le32 *)ptr;
 
-	memcpy(tmp_ptr, arg->chan_list, arg->num_chan * 4);
+	for (i = 0; i < arg->num_chan; i++)
+		tmp_ptr[i] = cpu_to_le32(arg->chan_list[i]);
 
 	ptr += len;
 
@@ -2809,8 +2811,10 @@ int ath12k_wmi_send_scan_start_cmd(struct ath12k *ar,
 		ptr += TLV_HDR_SIZE;
 		s_ssid = ptr;
 		for (i = 0; i < arg->num_hint_s_ssid; ++i) {
-			s_ssid->freq_flags = arg->hint_s_ssid[i].freq_flags;
-			s_ssid->short_ssid = arg->hint_s_ssid[i].short_ssid;
+			s_ssid->freq_flags =
+				cpu_to_le32(arg->hint_s_ssid[i].freq_flags);
+			s_ssid->short_ssid =
+				cpu_to_le32(arg->hint_s_ssid[i].short_ssid);
 			s_ssid++;
 		}
 		ptr += len;
@@ -2824,7 +2828,7 @@ int ath12k_wmi_send_scan_start_cmd(struct ath12k *ar,
 		hint_bssid = ptr;
 		for (i = 0; i < arg->num_hint_bssid; ++i) {
 			hint_bssid->freq_flags =
-				arg->hint_bssid[i].freq_flags;
+				cpu_to_le32(arg->hint_bssid[i].freq_flags);
 			ether_addr_copy(&hint_bssid->bssid.addr[0],
 					&arg->hint_bssid[i].bssid.addr[0]);
 			hint_bssid++;
drivers/net/wireless/ath/ath12k/wmi.h +10 -0
index 6d9c645e3d5d0..6468d9738639e 100644
@@ -3504,6 +3504,16 @@ struct ath12k_wmi_hint_bssid_arg {
 	struct ath12k_wmi_mac_addr_params bssid;
 };
 
+struct ath12k_wmi_hint_short_ssid_params {
+	__le32 freq_flags;
+	__le32 short_ssid;
+};
+
+struct ath12k_wmi_hint_bssid_params {
+	__le32 freq_flags;
+	struct ath12k_wmi_mac_addr_params bssid;
+};
+
 struct ath12k_wmi_scan_req_arg {
 	u32 scan_id;
 	u32 scan_req_id;
Signature · 1 line
2.53.0
author maintainer
#281 lore raw

PATCH 1/1 HID: intel-ish-hid: ignore post-init ENUM_DEVICES from firmware

In reply to Sasha Levin

From: Wahid Khan <[email protected]>

[ Upstream commit f3f3f6df05226dfa220c4e603310dae94595060a ]

Some ISH firmware versions (observed on Tiger Lake LP, 8086:a0fc, GUID {33AECD58-B679-4E54-9BD9-A04D34F0C226}) periodically re-send an unsolicited HOSTIF_DM_ENUM_DEVICES response roughly every 79 seconds.

The current guard collapses two distinct cases into one condition:

  if (!(response_flag) || init_done)  ->  bad packet + ish_hw_reset

This incorrectly treats a valid post-init firmware announcement as a corrupted packet, triggering an ISH soft-reset and a full ISHTP re-initialisation cycle on each occurrence (~1100 times per day on affected hardware).

Split the check: reject messages with no response flag as before, but simply discard valid ENUM_DEVICES messages that arrive after init is complete.

---

LLM Generated explanations, may be completely bogus:

The local tree is **5.15.221** (pending-5.15, p-5.15-2-g9a29d9b0f9507). The buggy HOSTIF_DM_ENUM_DEVICES / init_done reset guard is present here and matches the patch, so this is a decision for this tree only.

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

**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[HID/intel-ish-hid] [ignore] discard post-init ENUM_DEVICES from firmware instead of treating them as bad packets**

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Fixes: **none** (expected for this review pipeline)
- Reported-by: **none**
- Tested-by: Zhang Lixu \<[email protected]\> (Intel; independent of the author)
- Acked-by: Srinivas Pandruvada \<[email protected]\> (ISH maintainer)
- Reviewed-by: **none**
- Link: **none**
- Cc: stable: **none** (expected)
- Signed-off-by: Wahid Khan (author); Jiri Kosina (HID maintainer, applied the patch)
- Ignore: any Sasha Levin SOB / [Upstream commit ...] (pipeline)

Notable: maintainer Ack + Intel Tested-by + HID maintainer SOB.

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** Some ISH firmware (Tiger Lake LP, PCI 8086:a0fc, HID GUID {33AECD58-B679-4E54-9BD9-A04D34F0C226}) periodically resends a valid HOSTIF_DM_ENUM_DEVICES **response** about every 79 seconds after init.
- **Symptom:** The driver treats that as a bad packet, calls ish_hw_reset(), and fully re-inits ISHTP. About **1100 times per day**.
- **Root cause:** One condition folds “no response flag” and init_done together:
if (!(response_flag) || init_done) -> bad packet + ish_hw_reset
- **Fix:** Keep rejecting messages with no response flag; drop valid post-init ENUM_DEVICES.
- **Versions:** Observed on TGL LP; no kernel-version bound in the message.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not a hidden fix.** Explicit firmware-quirk / incorrect-error- handling fix. “Ignore” here is the workaround, not cleanup.

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

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/hid/intel-ish-hid/ishtp-hid-client.c only
- Scope: **+3 / -2** in process_recv(), HOSTIF_DM_ENUM_DEVICES case
- Classification: **single-file surgical fix**

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** Any ENUM_DEVICES with no response bit **or** client_data->init_done increments bad_recv_cnt, logs via report_bad_packet(), and calls ish_hw_reset().
- **After:** No response bit still resets. If the response bit is set and init_done is true, the handler breaks (discard). Pre-init responses still enumerate devices.
- Path: receive path after probe succeeds (init_done = 1 at the end of hid_ishtp_cl_init()).

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** hardware/firmware workaround + logic/correctness
- **Mechanism:** Firmware sends a valid post-init ENUM_DEVICES **response**. The driver wrongly classifies it as corruption and resets the ISH PCI function.
- Header check: CMD_MASK is 0x7F, IS_RESPONSE is 0x80. !(recv_msg->hdr.command & ~CMD_MASK) means “bit 7 not set” (request, not response). That part is unchanged.

**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct relative to the described firmware behavior: stop resetting on a valid response after init.
- Minimal; no API/data-structure change.
- Regression risk: **low**. Post-init ENUM_DEVICES were never processed as enumeration; they only caused reset+reinit. Discarding them avoids the reset storm. Genuine hotplug would use HOSTIF_DM_ADD_DEVICE (command 34), which this patch does not touch.
- GET_HID_DESCRIPTOR / GET_REPORT_DESCRIPTOR still use the old init_done reset. That is out of scope; the commit only claims ENUM_DEVICES is resent.

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

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Combined guard introduced in 0b28cb4bcb17dc (2016-08-17) **HID:
intel-ish-hid: ISH HID client driver** — original driver.
- ish_hw_reset() in that path: 29b06d12ba796a (2019) **Use the new interface functions in HID ish client**.
- Present in this tree from the beginning of intel-ish-hid. Not a recent mainline-only bug.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Bug is in original 2016 client driver, which **is** an ancestor of HEAD (git merge-base --is-ancestor 0b28cb4bcb17dc HEAD).

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- d21497331b967 already in this tree: **Reset enum_devices_done before enumeration**. Same failure mode (init_done + ENUM_DEVICES → ish_hw_reset) on S3/S4 when there are 0 sensors. Different trigger (stale enum_devices_done), complementary, **not** a substitute for this patch.
- Not a numbered series (X/Y). Standalone.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Wahid Khan has **no** prior commits in this tree under drivers/hid/. Weight comes from Srinivas Ack, Zhang Tested-by, Jiri Kosina SOB. Srinivas is listed in MAINTAINERS for INTEL INTEGRATED SENSOR HUB DRIVER.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **None.** Touches existing process_recv / init_done / CMD_MASK. No new helpers. A later “clamp HID device count” patch (openwall, 2026-07-30) is independent and not required.

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

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- v1: 2026-06-27, https://ratatoskr.run/linux-input/2026/06/17183853 — same diff; SOB was Wahid (incomplete).
- v2: 2026-07-20, https://ratatoskr.run/linux-input/2026/07/17285763 —
changelog: “added proper sign off”. **No code change.**
- Thread listing also shows Srinivas replies on 2026-06-29.
- b4 dig -c 13054abbaa4f... was the wrong SHA (hid.git SID from a search snippet); lore is behind Anubis (403/PoW). **UNVERIFIED:** full text of Srinivas’s replies.
- Committed version is v2 plus Acked-by / Tested-by / Jiri Kosina SOB.

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: Recipients/maintainers for this subsystem are Srinivas Pandruvada, Jiri Kosina, Benjamin Tissoires, linux-input. Ack is from the ISH maintainer; apply from HID maintainer. **UNVERIFIED:** b4 dig -w recipient list (lore blocked).

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot/bugzilla Link. Hardware observation is in the commit:
TGL LP 8086:a0fc, ~79s period. Tested-by from Intel’s Zhang Lixu (same tester as the related enum_devices_done stable fix).

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone. Not part of Shen Yongchao’s later process_recv bounds-check series. Related enum_devices_done fix is already here.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: Searches hit AUTOSEL for **Reset enum_devices_done**, not this subject. **UNVERIFIED:** whether this exact patch was already discussed on stable@. That is ignored as circular anyway.

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

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

**Step 5.2: TRACE CALLERS**
Record:
- ish_cl_event_cb() → process_recv()
- Registered in hid_ishtp_cl_init() via ishtp_register_event_cb()
- ishtp_cl_bus_rx_event() schedule_work(&device->event_work) → ishtp_bus_event_work() → event_cb
- Workqueue RX path, not a syscall; triggered by ISH firmware messages on systems with CONFIG_INTEL_ISH_HID.

**Step 5.3: TRACE CALLEES**
Record: On the bad path: report_bad_packet(), ish_hw_reset() → _ish_hw_reset() → pci_reset_function(). After reset, hid_ishtp_cl_reset() schedules hid_ishtp_cl_reset_handler(), which deinits and calls hid_ishtp_cl_init(..., 1) up to 3 times.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace does not send ENUM_DEVICES; firmware does. Reachable on every TGL-LP (and similar) ISH laptop after HID client init. High impact for those machines: periodic PCI reset of the sensor hub.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same !(command & ~CMD_MASK) || init_done reset in HOSTIF_GET_HID_DESCRIPTOR and HOSTIF_GET_REPORT_DESCRIPTOR. Commit only changes ENUM_DEVICES, matching the firmware that resends that command.

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** ishtp-hid-client.c lines 112–121 are identical to the pre-patch code. TGL LP ID 0xA0FC is in ipc/hw-ish.h / pci-ish.c (1479a82d82df6, 2019). HID GUID in this file matches the commit. Bug introduced with the original driver (0b28cb4bcb17, 2016).

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** Exact hunk context matches this file (verified). No refactor of process_recv between the patch parent and this 5.15 tree.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: d21497331b967 is here and does **not** ignore post-init ENUM_DEVICES; it only clears enum_devices_done before sending the command. The periodic-resend bug remains.

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

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **HID / Intel ISH** (drivers/hid/intel-ish-hid/). **IMPORTANT** for Intel laptops/tablets (accelerometer, gyro, ALS, etc.), not core mm/VFS. Not staging.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Mature since 2016. This tree still receives ISH fixes (e.g. enum_devices_done). Platform IDs through Tiger Lake are present.

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

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific / platform-specific:** CONFIG_INTEL_ISH_HID on x86 with ISH firmware that resends ENUM_DEVICES. Confirmed example:
TGL LP 8086:a0fc, a common 11th-gen laptop platform. Same HID client GUID is used across ISH generations, so other firmware versions could hit it too.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: After successful ISH HID init, firmware timer ~79s. No userspace trigger; unprivileged users do not need to do anything. Very likely on affected hardware (every ~79s forever).

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- Failure: pci_reset_function() on ISH + full ISHTP reinit, plus BAD packet dev_err flood.
- Sensors drop and come back ~1100 times/day; possible gaps in input/IIO; extra PCI reset load.
- Severity: **HIGH** (stability / availability of ISH; not a KASAN UAF, not silent FS corruption).

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** high for TGL-class ISH machines still on 5.15 LTS (Android/ChromeOS/enterprise).
- **Risk:** very low (5 lines, post-init discard only; malformed packets still reset).
- **Ratio:** strongly favors backport.

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

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Real firmware misbehavior on shipping Intel ISH (TGL LP 8086:a0fc in this tree).
- User-visible: PCI reset + ISHTP reinit ~1100/day, error log flood, sensor disruption.
- Buggy guard present here since original 2016 driver.
- 5-line, obviously correct split of two cases.
- Applies cleanly.
- ISH maintainer Ack, Intel Tested-by, HID maintainer applied it.
- Same init_done + ENUM_DEVICES + ish_hw_reset class of bug already accepted into this tree (d21497331b967).
- Fits the **hardware quirk/workaround** stable exception.

AGAINST:
- Not a panic/UAF/CVE; driver-specific.
- Silently ignoring post-init ENUM_DEVICES will not pick up a device list change via that command (old code did that only via a brutal reset).
- Full Srinivas review text not retrieved (lore Anubis).

UNRESOLVED:
- Exact lore body of 2026-06-29 replies.
- How many ISH firmware versions besides TGL LP resend ENUM_DEVICES.

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — Tested-by Intel; Acked by ISH maintainer; logic is a 2-way split of an existing if.
2. Fixes a real bug that affects users? **PASS** — observed on TGL LP; periodic ISH reset.
3. Important issue (crash, security, corruption, deadlock)? **PASS** — repeated PCI function reset and full client reinit is a serious stability issue, not cosmetic.
4. Small and contained? **PASS** — one file, 5 lines.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — exact context in 5.15.221.

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Hardware quirk/workaround** for non-compliant/buggy ISH firmware. Also a logic fix for misclassifying a valid response.

**Step 9.4: MAKE YOUR DECISION**

This should be backported to **this** 5.15 tree. The bug exists here, the hardware ID exists here, the fix is tiny and applies cleanly, and the current behavior is a reset storm on common Intel ISH laptops.

===============================================================
Verification
===============================================================
- [Phase 1] Tags: Tested-by Zhang Lixu; Acked-by Srinivas Pandruvada; SOB Jiri Kosina; no Fixes/Cc:stable/Reported-by.
- [Phase 2] Diff: process_recv ENUM_DEVICES only; split !response || init_done into reject-without-flag vs discard-if-init_done.
- [Phase 2] CMD_MASK/IS_RESPONSE in ishtp-hid.h confirmed (0x7F/0x80).
- [Phase 3] blame: guard from 0b28cb4bcb17dc (2016); ancestor of HEAD.
- [Phase 3] related: d21497331b967 already in tree; does not fix periodic resend.
- [Phase 3] author: no prior Wahid Khan commits in this hid tree.
- [Phase 4] ratatoskr v1 2026-06-27, v2 2026-07-20 (“proper sign off” only); Srinivas replies listed 2026-06-29.
- [Phase 4] lore.kernel.org 403/Anubis; b4 dig on a mistaken hid.git SHA failed. UNVERIFIED: full review email text.
- [Phase 5] callers: workqueue ishtp_bus_event_work → ish_cl_event_cb → process_recv.
- [Phase 5] reset: _ish_hw_reset uses pci_reset_function; hid_ishtp_cl_reset_handler re-runs hid_ishtp_cl_init.
- [Phase 6] git describe HEAD = p-5.15-2-g9a29d9b0f9507; make kernelversion = 5.15.221.
- [Phase 6] buggy if at lines 113–114 present; exact patch context matches.
- [Phase 6] TGL 0xA0FC in tree (1479a82d82df6); GUID matches commit.
- [Phase 7] MAINTAINERS: INTEL INTEGRATED SENSOR HUB DRIVER → Srinivas + Jiri.
- [Phase 8] failure mode: periodic ISH PCI reset, HIGH; not a kernel oops.
- UNVERIFIED: exact Srinivas reply text; whether other FW besides TGL LP hits this.

The problem is a firmware quirk that this 5.15 driver turns into an ISH reset loop. The fix is small, reviewed, tested, and already matches the local source.

**YES**

 drivers/hid/intel-ish-hid/ishtp-hid-client.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/hid/intel-ish-hid/ishtp-hid-client.c +3 -2
index 12a43c64e8156..085313ae354ab 100644
@@ -113,8 +113,7 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf,
 
 		switch (recv_msg->hdr.command & CMD_MASK) {
 		case HOSTIF_DM_ENUM_DEVICES:
-			if ((!(recv_msg->hdr.command & ~CMD_MASK) ||
-					client_data->init_done)) {
+			if (!(recv_msg->hdr.command & ~CMD_MASK)) {
 				++client_data->bad_recv_cnt;
 				report_bad_packet(hid_ishtp_cl, recv_msg,
 						  cur_pos,
@@ -122,6 +121,8 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf,
 				ish_hw_reset(ishtp_get_ishtp_device(hid_ishtp_cl));
 				break;
 			}
+			if (client_data->init_done)
+				break;
 			client_data->hid_dev_count = (unsigned int)*payload;
 			if (!client_data->hid_devices)
 				client_data->hid_devices = devm_kcalloc(
Signature · 1 line
2.53.0
author maintainer
#282 lore raw

PATCH 1/1 thermal: intel: int340x: clean up RFIM groups on DVFS failure

In reply to Sasha Levin

From: Pengpeng Hou <[email protected]>

[ Upstream commit 28f34d7dafa6dfa657efd6760b7c78e98c9b2f6a ]

proc_thermal_rfim_add() can create the FIVR and DLVR sysfs groups before creating the DVFS group.

If DVFS group creation fails while both earlier groups are enabled, the current error handling removes only one group: the FIVR branch returns before the DLVR cleanup branch can run. This leaves the DLVR group behind even though RFIM setup fails.

Use one DVFS failure path that removes all previously created RFIM groups before returning the error.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit message forensics

**Step 1.1: PARSE THE SUBJECT LINE**
Record: [thermal/intel/int340x] [clean up] incomplete RFIM sysfs-group unwind when DVFS group creation fails

**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: Rafael J. Wysocki <[email protected]> (thermal maintainer)
- No Fixes:, Reported-by:, Tested-by:, Reviewed-by:, Acked- by:, or Cc: stable (absence of the last two is expected for this review)

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- Bug: proc_thermal_rfim_add() may create FIVR and DLVR sysfs groups, then fail creating DVFS.
- Symptom: on DVFS failure with both earlier groups enabled, the FIVR cleanup branch returns immediately, so the DLVR group is never removed.
- Failure mode: leftover sysfs group after RFIM setup reports failure (resource leak; probe of the Intel processor thermal PCI device fails).
- Root cause: two sequential if (ret && FEATURE_*) { remove; return; } blocks instead of one failure path that removes every group that was created.
- Version info in the message: none.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Yes. The subject says “clean up”, but the body and the diff are an error-path leak fix (missing sysfs_remove_group for DLVR).

## Phase 2: Diff analysis

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c (+5 / −6)
- Function: proc_thermal_rfim_add()
- Scope: single-file surgical error-path change

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record: Before, DVFS sysfs_create_group() failure did:

```c
if (ret && FIVR) { sysfs_remove_group(fivr); return ret; }
if (ret && DLVR) { sysfs_remove_group(dlvr); return ret; }
```

If both FIVR and DLVR bits are set, the first branch returns and DLVR is never removed. After, a single if (ret) removes DLVR and/or FIVR according to the feature mask, then returns.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: [error path / resource leak] Incomplete unwind. sysfs_create_group(&pdev->dev.kobj, &dvfs_attribute_group) failure leaked dlvr_attribute_group when FIVR+DLVR+DVFS were all enabled.

**Step 2.4: ASSESS THE FIX QUALITY**
Record: Obviously correct. Groups are only removed if the corresponding feature bit is set, and those bits are the same ones that caused the groups to be created earlier in this function. No API, locking, or data- structure changes. Regression risk is very low: sysfs_remove_group on a group that this function just created.

## Phase 3: Git history

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Original FIVR-only DVFS unwind: 473be51142adba (“Add RFIM driver”, 2020; first in v5.11-rc1).
- Incomplete DLVR branch: 5bc6b1df65c87f (“Add DLVR support for RFIM control”, 2023-04-13; first in v6.4-rc1). That commit added the second if (ret && DLVR) return after the existing FIVR early-return, which is the bug.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable beyond that. The introducing commit is 5bc6b1df65c87f, and git merge-base --is-ancestor 5bc6b1df65c87f HEAD succeeded.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- 15176b818e048c (“Fix sysfs group leak on DLVR registration failure”) — same class of bug for the *DLVR create* path leaking FIVR; already in this tree (v7.0-rc1).
- This patch is standalone, not patch X/Y. Same author later did a similar ODVP probe-unwind fix (d83dc9ce57a74) in a different file; not a prerequisite.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Pengpeng Hou is not the subsystem maintainer. Thermal maintainer Rafael J. Wysocki applied the patch. Driver author Srinivas Pandruvada was on the original To/Cc list.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None. The fix only reorders existing sysfs_remove_group() calls on fivr_attribute_group / dlvr_attribute_group, both present in this tree. Can apply standalone.

## Phase 4: Mailing list and external research

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 28f34d7dafa6d →
https://patch.msgid.link/[email protected]
- b4 dig -a: v1 only
- Thread (mbox): no NAKs. Rafael: “Applied as 7.3 material, thanks!”
- No reviewer Cc: stable suggestion

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc included Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Srinivas Pandruvada, linux-pm. Applied by the thermal maintainer. No separate Reviewed-by.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No Reported-by / bugzilla / syzbot. This is a code-inspection leak, not a user crash report.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Standalone v1. Sibling leak fix is 15176b818e048c (already here). Author’s ODVP cleanup is a different driver file.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org HTTP 403. b4 dig thread has no stable-list discussion. UNVERIFIED: whether linux-stable@ ever discussed this subject independently.

## Phase 5: Code semantic analysis

**Step 5.1: KEY FUNCTIONS**
Record: proc_thermal_rfim_add() (modified). Uses sysfs_create_group / sysfs_remove_group.

**Step 5.2: TRACE CALLERS**
Record:
- proc_thermal_mmio_add() in processor_thermal_device.c (only caller)
- That is called from proc_thermal_pci_probe() and proc_thermal_pci_legacy probe
- Probe / device-enumeration path, not IRQ or a hot syscall path

**Step 5.3: TRACE CALLEES**
Record: sysfs_create_group, sysfs_remove_group on the PCI device kobject.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: PCI probe → proc_thermal_mmio_add() → proc_thermal_rfim_add(). On RFIM failure, proc_thermal_mmio_add() does goto err_rem_ptc and **does not** call proc_thermal_rfim_remove(). proc_thermal_pci_probe() then return ret without proc_thermal_mmio_remove(). The leaked DLVR group therefore stays on pdev->dev.kobj. Reachable whenever this Intel thermal PCI device is probed (common on Intel laptops/SoCs with INT340x). Trigger still requires sysfs_create_group(dvfs) to fail.

Verified hardware with all three bits (the only way both groups exist at DVFS failure): Meteor Lake MTLP_THERMAL is FIVR | DVFS | DLVR (processor_thermal_device_pci.c). 5bc6b1df65c87f is what OR’d PROC_THERMAL_FEATURE_DLVR onto that ID.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same incomplete-unwind pattern was already fixed for DLVR- create-fails-after-FIVR (15176b818e048c). fs/sysfs/group.c returns -EEXIST (and warns) if the named group already exists, so a leaked DLVR group can make a later re-bind fail even after the original transient error is gone.

## Phase 6: Cross-referencing against the local tree

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- Local tree: v7.3-rc4-27-gf0100363d8c37, make kernelversion → 7.3.0-rc4
- RFIM, DLVR, FIVR, DVFS, and MTLP FIVR+DLVR+DVFS are all present
- Bug introduced in v6.4 (5bc6b1df65c87f), well before this 7.3 branch
- Parent of the candidate still has the two early-return blocks

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Clean apply. Surrounding proc_thermal_rfim_add() in this tree matches the hunk (Nova Lake DLVR switch and the earlier FIVR leak fix are already here).

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: 15176b818e048c is in this tree and fixes a *different* leak (DLVR create vs FIVR). It does not fix DVFS-create leaking DLVR. No other substitute for this patch.

## Phase 7: Subsystem and maintainer context

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: [drivers/thermal/intel/int340x] [IMPORTANT] — Intel laptop/SoC processor thermal / RFIM sysfs, not core mm/fs, but used on shipping Meteor Lake platforms. CONFIG_INT340X_THERMAL.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained (Nova Lake, Wildcat Lake, Panther Lake IDs and DLVR tables in recent history). Maintainer applied this patch.

## Phase 8: Impact and risk

**Step 8.1: WHO IS AFFECTED**
Record: Driver-specific / config-specific: Intel INT340x processor thermal PCI, specifically IDs with FIVR+DLVR+DVFS (Meteor Lake in this tree).

**Step 8.2: TRIGGER CONDITIONS**
Record: Device probe, after FIVR and DLVR groups succeed, when DVFS sysfs_create_group() fails (ENOMEM, duplicate name, etc.). Not unprivileged-syscall reachable except via driver bind. Uncommon, but deterministic when it happens. Re-probe can then hit -EEXIST on the leaked DLVR group (internal_create_group() in fs/sysfs/group.c).

**Step 8.3: FAILURE MODE SEVERITY**
Record: [sysfs group leak on PCI device after failed probe; possible sticky re-bind failure] [MEDIUM] — not a panic or filesystem corruption. Stale dlvr attributes can remain on the PCI device kobject after the driver has reported probe failure.

**Step 8.4: RISK-BENEFIT RATIO**
Record: Benefit medium (correct unwind on a real shipping platform’s probe error path; avoids leftover sysfs and sticky -EEXIST). Risk very low (5-line error-path-only change, no locking/API). Ratio favors taking the fix.

## Phase 9: Final synthesis

**Step 9.1: EVIDENCE**

FOR:
- Real, deterministic incomplete unwind; DLVR group leaked when FIVR+DLVR+DVFS are set
- Meteor Lake actually sets all three feature bits
- Caller does not call proc_thermal_rfim_remove() on proc_thermal_rfim_add() failure
- Same bug class as 15176b818e048c, which this tree already contains
- Tiny, obviously correct, no new API
- Thermal maintainer applied it; right people were CCed; no NAKs
- Bug present since v6.4; code exists in this 7.3 tree

AGAINST:
- Trigger is a failed sysfs_create_group() (rare)
- No user/syzbot report
- Not a crash, UAF, or data-corruption bug
- Rafael queued it as 7.3 material, not as a stable-cc’d hotfix

UNRESOLVED:
- Direct lore.kernel.org / stable-list HTTP search returned 403; thread content recovered via b4 dig -m instead

**Step 9.2: STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — control flow is local and clear; maintainer applied v1 with no further revisions.
2. Fixes a real bug that affects users? **PASS** — leftover sysfs on the PCI device after failed RFIM setup on Meteor Lake.
3. Important issue? **PASS** (medium) — resource leak with a possible sticky re-bind failure, not a panic; still the error-path leak class stable regularly takes.
4. Small and contained? **PASS** — one function, +5/−6 lines.
5. No new features or APIs? **PASS**
6. Can apply to the local tree? **PASS** — file and both sysfs groups exist; hunk matches.

**Step 9.3: EXCEPTION CATEGORIES**
Record: None (not a device ID, quirk, DT, build, or docs exception). It is a normal small leak fix.

**Step 9.4: DECISION**
This tree is 7.3.0-rc4. The buggy unwind, DLVR/FIVR/DVFS groups, and Meteor Lake FIVR+DLVR+DVFS mask are all here. The patch is a minimal, correct error-path leak fix with negligible regression risk. It should be in this tree.

Verification:
- [Phase 1] Tags: author SOB, Rafael SOB, lore Link; no Fixes/Reported- by/Cc: stable
- [Phase 2] Diff: proc_thermal_rfim_add() DVFS failure path; two early-returns collapsed into one unwind of DLVR then FIVR
- [Phase 3] git blame on parent: FIVR unwind from 473be51142adba (v5.11); DLVR early-return from 5bc6b1df65c87f (v6.4-rc1)
- [Phase 3] git merge-base --is-ancestor 5bc6b1df65c87f HEAD → yes; related leak fix 15176b818e048c also in HEAD
- [Phase 3] git log --author='Pengpeng Hou' on thermal: this RFIM fix plus a later independent ODVP unwind
- [Phase 4] b4 dig -c 28f34d7dafa6d:
https://patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1 only; b4 dig -w: linux-pm + Pandruvada/Wysocki/Lezcano
- [Phase 4] mbox: Rafael “Applied as 7.3 material”; no NAK, no stable nomination
- [Phase 4] lore.kernel.org WebFetch: 403; stable-list search UNVERIFIED via HTTP
- [Phase 5] Callers: proc_thermal_mmio_add → PCI probe; RFIM failure jumps to err_rem_ptc, skipping proc_thermal_rfim_remove
- [Phase 5] MTLP ID: FIVR | DVFS | DLVR in processor_thermal_device_pci.c; DLVR bit added in 5bc6b1df65c87f
- [Phase 5] sysfs_create_group / internal_create_group: -EEXIST if named group already exists
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- [Phase 6] Parent function still has the buggy two-branch return; this tree has the needed groups and IDs
- [Phase 8] Failure mode: leaked dlvr sysfs group after probe failure; severity MEDIUM

The fix is small, surgical, and meets the stable criteria for an error- path resource leak on hardware this tree already supports.

**YES**

 .../intel/int340x_thermal/processor_thermal_rfim.c    | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c +5 -6
index 635bc8fded1e9..2f32b230a4b15 100644
@@ -460,12 +460,11 @@ int proc_thermal_rfim_add(struct pci_dev *pdev, struct proc_thermal_device *proc
 
 	if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_DVFS) {
 		ret = sysfs_create_group(&pdev->dev.kobj, &dvfs_attribute_group);
-		if (ret && proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_FIVR) {
-			sysfs_remove_group(&pdev->dev.kobj, &fivr_attribute_group);
-			return ret;
-		}
-		if (ret && proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_DLVR) {
-			sysfs_remove_group(&pdev->dev.kobj, &dlvr_attribute_group);
+		if (ret) {
+			if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_DLVR)
+				sysfs_remove_group(&pdev->dev.kobj, &dlvr_attribute_group);
+			if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_FIVR)
+				sysfs_remove_group(&pdev->dev.kobj, &fivr_attribute_group);
 			return ret;
 		}
 	}
Signature · 1 line
2.53.0
author maintainer
#283 lore raw

PATCH 1/1 bpf: Reject callback subprogs invoke tailcall

In reply to Sasha Levin

From: Pu Lehui <[email protected]>

[ Upstream commit a41d0c30d764e086c62b049e806fd12df4f4acfc ]

Some JIT compilers, such as x86_64, rely on a register to pass the TCC. When subprograms of synchronous callback invoke tailcall, C helpers invoking bpf callback clobber this register, and the corrupted TCC may bypass the TCC limit, leading to infinite tailcall.

Fix this by rejecting tailcall inside all subprogs of sync callback. This also cleanly consolidates the existing async and exception callback checks into a single unified is_cb check.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit message forensics

**Step 1.1 — Subject line**
Record: [bpf] [Reject] Reject callback subprogs that invoke tailcall (verifier hardening against TCC clobber / infinite tailcall).

**Step 1.2 — Tags**
Record:
- Reported-by: Sashiko <[email protected]> — BPF fuzzer found this
- Reported-by: Björn Töpel <[email protected]> — independently reported by a BPF JIT developer
- Acked-by: Eduard Zingerman <[email protected]> — BPF verifier maintainer
- `Link: https://patch.msgid.link/20260716120157.835937-3-
[email protected]` — v3 2/3 of a 3-patch series
- Signed-off-by: Pu Lehui <[email protected]>
- Signed-off-by: Eduard Zingerman <[email protected]>
- No Fixes: tag (expected)
- No Cc: stable (expected)
- Ignore pipeline Signed-off-by: Sasha Levin / [Upstream commit ...] if present — none on the original commit

**Step 1.3 — Body**
Record:
- **Bug:** Some JITs (x86-64) pass the tail-call counter (TCC) in a register. A sync callback is invoked from a C helper, which clobbers that register. If a callback subprog then tail-calls, TCC is garbage and the limit can be bypassed.
- **Symptom:** Infinite tailcall (CPU hang / soft lockup).
- **Root cause:** Verifier only rejected tailcalls inside exception callbacks (is_exception_cb), not sync callbacks (bpf_loop, bpf_for_each_map_elem, etc.).
- **Fix:** Reject tailcall on any callback frame via unified is_cb. Also drop the special async-cb verifier_bug in favor of that same check.
- **Version:** Landed in v7.3-rc1 (2026-07-16); this checkout is v7.3-rc4.

**Step 1.4 — Hidden bug fix?**
Record: Not hidden. Explicit security/correctness fix (infinite tailcall), plus a small consolidation of existing callback checks. Not cleanup-only.

---

## Phase 2: Diff analysis

**Step 2.1 — Inventory**
Record:
- File: kernel/bpf/verifier.c (+2 / -6, 8 lines)
- Function: check_max_stack_depth_subprog()
- Scope: single-file surgical verifier change

**Step 2.2 — Code flow**
Record:
1. **Removed** if (subprog[sidx].is_async_cb && has_tail_call) verifier_bug; return -EFAULT. Async callbacks with a tailcall are no longer a verifier BUG; they fall through to the unified reject.
2. **Changed** the stack-walk guard from is_exception_cb (“cannot tail call within exception cb”) to is_cb (“cannot tail call within callback”). Any callback on the bpf2bpf stack of a tailcall-reachable subprog is rejected with -EINVAL.

**Step 2.3 — Bug mechanism**
Record: **Logic / correctness** in the BPF verifier, with a **hang** failure mode.
- is_cb is set in push_callback_call() for every helper/kfunc callback, including sync ones.
- has_tail_call is set in check_subprogs() when a subprog contains BPF_FUNC_tail_call.
- x86-64 JIT (emit_prologue_tail_call) uses %rax as TCC / TCC pointer. Callback entry is a C ABI call, so %rax is clobbered.
- Corrupted TCC can skip MAX_TAIL_CALL_CNT and loop forever.

**Step 2.4 — Fix quality**
Record: Minimal and obviously correct. Same pattern already used for exception callbacks (b9ae0c9dd0aca, 2023). Regression risk is **verifier tightening**: programs that do callback → subprog → tailcall now fail to load. Those programs were dangerous. Series patch 1 is required to avoid false rejects of unrelated tailcall branches (see Phase 3). No API/feature additions.

---

## Phase 3: Git history

**Step 3.1 — Blame**
Record:
- is_cb field: 406a6fa44bfbc (2023-12, bitfield conversion); assignment in push_callback_call(): ab5cfac139ab85 (2023-11)
- Exception-only tailcall reject: b9ae0c9dd0aca (2023-09, “bpf: Add support for custom exception callbacks”)
- Async has_tail_call verifier_bug: 7ddc80a476c2d (2021-07, “Teach stack depth check about async callbacks”)
- has_tail_call tracking: 7f6e4312e15a5 (2020)
- bpf_loop: e6f2dd0f80674 (2021-11); CAP_BPF: 5679ff2f138f7 (2022-08)
- x86 TCC-in-register: ebf7d1f508a7 (cited by series patch 1)

The hole (sync callbacks + tailcall) has been present for years; this tree is far newer.

**Step 3.2 — Fixes: tag**
Record: None on this commit. Related: series patch 1 has `Fixes:
ebf7d1f508a7. GitHub CI suggested Fixes: b9ae0c9dd0ac` for this patch (that commit only covered exception callbacks).

**Step 3.3 — Related file history**
Record: v3 series “Fixes for tailcall with subprog and callback”:
1. 3513ea9dab6c1 bpf: Sync tail_call_reachable with callee state on entry
2. a41d0c30d764e **this commit**
3. 42bfd21a8b701 selftests/bpf: Add testcases for callback with tailcall

Follow-up already in this tree: 266aa4ad0b2e8 (“Reject tail calls directly from callback frames”) — extra reject in check_helper_call() to avoid a verifier WARN; it comments that stack-depth validation already rejects this.

**Step 3.4 — Author**
Record: Pu Lehui is a regular BPF contributor (JIT/verifier). Acked and applied by Eduard Zingerman (verifier maintainer).

**Step 3.5 — Prerequisites**
Record: **Not fully standalone.** Patch 1 must come first. Without it, tail_call_reachable leaks across branches, so patch 2 can reject valid programs that mix a tailcall subprog with a no-tailcall callback (tailcall_callback_2 selftest). Both 3513ea9dab6c1 and 42bfd21a8b701 **are ancestors of this HEAD**. is_cb is present. Can apply on this tree (already applied).

---

## Phase 4: Mailing list / external research

**Step 4.1 — Original discussion**
Record:
- Lore: https://patch.msgid.link/20260716120157.835937-3-
[email protected]
- Cover: https://patch.msgid.link/20260716120157.835937-1-
[email protected]
- Revisions: v1 (2 patches, 2026-07-11) → v2 (2026-07-14) → **v3 (3 patches, 2026-07-16)** applied
- v3 added patch 1 after Sashiko found the tail_call_reachable leak
- Applied to **bpf-next** (not bpf fixes) by Eduard Zingerman on 2026-07-17
- Sashiko AI review flagged removing the async verifier_bug. Author
replied: async/exception tailcalls are meaningless (ctx not passed); sync callbacks are subprogs so is_cb fires; direct tailcall in a callback is already rejected earlier in check_helper_call via unknown R0 vs callback return range
- No NAKs. Eduard acked. Patchwork applied v3 as latest.

**Step 4.2 — Recipients (b4 dig -w)**
Record: bpf@vger, Alexei, Andrii, Daniel Borkmann, Martin KaFai Lau, Kartikeya, Yonghong, Song Liu, Jiri Olsa, Björn Töpel, Eduard. Right maintainers.

**Step 4.3 — Bug report**
Record: Two independent reports:
- Sashiko fuzzer
- Björn Töpel, in review of RISC-V JIT bpf2bpf+tailcall: callback entered from C ABI with clobbered TCC, then subprog tailcall. He confirmed the verifier accepted callback → subprog → tailcall.

**Step 4.4 — Series**
Record: 3 patches; 1+2 are kernel, 3 is selftests. Patch 1 is a correctness prerequisite for patch 2. Both are in this tree.

**Step 4.5 — Stable list**
Record: lore.kernel.org/stable search returned 403. UNVERIFIED whether it was discussed on stable@. No Cc: stable on the patch. Submitted to bpf-next during the 7.2 cycle, so it was aimed at 7.3, not 7.2-rc.

---

## Phase 5: Code semantic analysis

**Step 5.1 — Functions**
Record: check_max_stack_depth_subprog() only.

**Step 5.2 — Callers**
Record: check_max_stack_depth() → do_check finalization (kernel/bpf/verifier.c ~21334). Runs on every successful BPF_PROG_LOAD before JIT. Called for main (i==0) and every is_async_cb subprog.

**Step 5.3 — Callees**
Record: Walks insns, bpf_find_subprog(), bpf_pseudo_call / bpf_pseudo_func. Sets tail_call_reachable from callee has_tail_call, then marks tail_call_reachable on the frame stack for the JIT.

**Step 5.4 — Reachability**
Record: Userspace BPF_PROG_LOAD. Typical trigger: TC/XDP/cgroup program with bpf_loop (or similar) whose callback calls a subprog that tail-calls. bpf_loop is CAP_BPF-gated (kernel/bpf/helpers.c). Not fully unprivileged; reachable by any CAP_BPF loader (Cilium, systemd, containers with CAP_BPF). **Yes, reachable from userspace.**

**Step 5.5 — Similar patterns**
Record: Same is_cb walk used for:
- BPF_LD_ABS/IND in callbacks (e7d28823c6621)
- bpf_throw from callbacks
Later 266aa4ad0b2e8 added a matching reject in check_helper_call().

---

## Phase 6: This tree

**Step 6.1 — Does the buggy code exist?**
Record: **Yes, in this lineage, and the fix is already merged.**
- Tree: **v7.3-rc4** (7.3.0-rc4, HEAD f0100363d8c37)
- git merge-base --is-ancestor a41d0c30d764e HEAD → true
- git describe --contains a41d0c30d764e → v7.3-rc1~134^2~141^2~1
- Not in v7.2 (merge-base --is-ancestor failed)
- Before this commit, check_max_stack_depth_subprog() only tested is_exception_cb. Sync callbacks were unprotected. That is the 7.3 code this commit fixed.
- Reverse git apply --check of the commit succeeds: working tree already has the after-state.

**Step 6.2 — Backport difficulty**
Record: **Already applied** on this tree. is_cb, check_max_stack_depth_subprog(), and series patch 1 are present. Would apply cleanly to the pre-commit parent; no extra rework for 7.3.

**Step 6.3 — Related fixes already here**
Record: Series 1/3 and 3/3, plus follow-up 266aa4ad0b2e8. No alternate fix that would make this redundant; the follow-up depends on this diagnostic.

---

## Phase 7: Subsystem context

**Step 7.1**
Record: **BPF verifier** (kernel/bpf/verifier.c). **IMPORTANT** (core BPF safety; all BPF loaders). Not mm/scheduler, but verifier bugs are security-relevant.

**Step 7.2**
Record: Highly active in 7.3. This is a mature path (check_max_stack_depth has existed for years), not new infrastructure.

---

## Phase 8: Impact and risk

**Step 8.1 — Who is affected**
Record: Config-specific / BPF users. Needs JIT that passes TCC in a register (x86-64 is the cited case; Björn noted RISC-V too). Sync callbacks (bpf_loop, for-each helpers) plus tailcall.

**Step 8.2 — Trigger**
Record: Load and run a BPF program: callback subprog tail-calls. Timing- independent. Needs CAP_BPF (and usually CAP_NET_ADMIN/PERFMON for the program type). Confirmed accepted by the old verifier.

**Step 8.3 — Failure mode**
Record: **Infinite tailcall → CPU hang / soft lockup.** Severity **HIGH** (DoS / hang). Not a verified memory-corruption UAF, but a real stability/security issue.

**Step 8.4 — Risk-benefit**
Record:
- **Benefit:** Stops a hang/DoS in a common BPF pattern (loop callback + tailcall) on x86-64.
- **Risk:** Low. 8-line verifier reject. Can break previously accepted (unsafe) programs. False-positive risk is handled by patch 1, already in this tree.
- **Ratio:** High benefit / low risk.

---

## Phase 9: Synthesis

**Step 9.1 — Evidence**

For backporting / keeping this in this tree:
- Real hang: TCC clobber → infinite tailcall (x86-64 JIT, independently described by Töpel)
- Two reporters (Sashiko + Björn Töpel)
- Verifier maintainer Acked-by and applied
- 8-line, obviously correct extension of an existing guard
- Selftests in 42bfd21a8b701
- Call path is BPF_PROG_LOAD (userspace)
- This tree has the code, patch 1, and is_cb

Against:
- Sent to bpf-next, not bpf fixes; no Fixes: / Cc: stable
- Tightens verifier (rejects previously valid programs)
- Series member 2/3; needs patch 1 (present here)
- Original commit already in v7.3-rc1, so this checkout already contains the fix

Unresolved: whether anyone asked for it on stable@ (lore/stable 403).

**Step 9.2 — Stable rules**
1. Obviously correct and tested? **PASS** — Acked, applied, selftests, follow-up confirms the check
2. Real bug affecting users? **PASS** — accepted programs can hang a CPU
3. Important (crash/security/corruption/deadlock)? **PASS** — hang/DoS; HIGH
4. Small and contained? **PASS** — 8 lines, one function
5. No new features/APIs? **PASS** — verifier reject only
6. Can apply to this tree? **PASS** — already in v7.3-rc1; prerequisites present

**Step 9.3 — Exceptions**
Record: None (not a device ID / quirk / DT / build / docs patch). Qualifies as a normal important bugfix.

**Step 9.4 — Decision**
This tree is **v7.3-rc4**. The bug is in this series’ BPF verifier/JIT, the fix is small and correct, and the only dependency (patch 1) is already here. Already merged in 7.3-rc1 is not a reason to treat it as unsuitable; it is evidence it belongs in this tree. Technical merit supports including it.

---

### What the commit solves, and why it matters here

x86-64 (and similar JITs) pass the tail-call counter in a register. Sync BPF callbacks run from C helpers, which clobber that register. If a callback’s subprogram tail-calls, the counter can be garbage, the 33-call limit is skipped, and the CPU can tail-call forever.

The verifier only blocked that for exception callbacks. This patch uses the existing is_cb bit so **all** callbacks are rejected. That is a real hang/DoS for CAP_BPF program loaders on this kernel.

It meets stable rules: obviously correct, important, 8 lines, no new API. Patch 1 of the same series is already in this tree, so the false- reject leak is not an issue here.

### Risk vs benefit

Benefit is high (prevents hang). Risk is low (reject unsafe programs). The only behavioral change is failing BPF_PROG_LOAD for callback+tailcall, which is the intended safety net.

### Concerns

- Needs series patch 1 (3513ea9dab6c1) — **already in this tree**
- Selftests (42bfd21a8b701) are nice-to-have, not required for the kernel fix — **already in this tree**
- Follow-up 266aa4ad0b2e8 is a separate WARN-avoidance fix, not a prerequisite for this one

---

### Verification

- **[Phase 1]** Parsed tags: Sashiko + Björn Töpel Reported-by; Eduard Acked-by/SOB; Link msgid 835937-3 (v3 2/3); no Fixes/Cc-stable
- **[Phase 1]** git show a41d0c30d764e --format=full: infinite tailcall from TCC clobber; reject via is_cb
- **[Phase 2]** Diff: kernel/bpf/verifier.c +2/-6 in check_max_stack_depth_subprog(); is_exception_cb → is_cb; remove async verifier_bug
- **[Phase 2]** Current code at 5480–5482 already has if (subprog[tmp].is_cb) / "cannot tail call within callback"
- **[Phase 3]** git describe HEAD / make kernelversion:
**v7.3-rc4**, 7.3.0-rc4
- **[Phase 3]** git merge-base --is-ancestor a41d0c30d764e HEAD: yes (already in this tree, v7.3-rc1)
- **[Phase 3]** git merge-base --is-ancestor a41d0c30d764e v7.2: no (7.2 does not have it; not used as a split verdict)
- **[Phase 3]** Parent 3513ea9dab6c1 is series 1/3; git merge-base --is-ancestor 3513ea9dab6c1 HEAD: yes
- **[Phase 3]** Blame: exception check b9ae0c9dd0aca (2023); async bug 7ddc80a476c2d (2021); is_cb 406a6fa44bfbc / ab5cfac139ab85 (2023)
- **[Phase 3]** Follow-up 266aa4ad0b2e8 already in tree; extra reject in check_helper_call() at 11320
- **[Phase 4]** b4 dig -c a41d0c30d764e: lore msgid 20260716120157.835937-3
- **[Phase 4]** b4 dig -a: v1→v2→v3; v3 applied; v3 added patch 1 after Sashiko
- **[Phase 4]** b4 dig -w: bpf maintainers CC’d (Alexei, Eduard, Daniel, Andrii, Björn, Kartikeya)
- **[Phase 4]** mbox: Eduard applied to bpf-next; Sashiko AI concern answered by author; no NAK
- **[Phase 4]** WebSearch: Töpel RISC-V thread confirms verifier accepted callback→subprog→tailcall
- **[Phase 4]** lore.kernel.org/stable: **UNVERIFIED** (403)
- **[Phase 5]** check_max_stack_depth() at 5552 calls this; verifier finalize at 21334 on every successful load
- **[Phase 5]** push_callback_call() sets is_cb at 9847; check_subprogs() sets has_tail_call at 3031
- **[Phase 5]** x86 JIT emit_prologue_tail_call uses %rax for TCC (arch/x86/net/bpf_jit_comp.c:500–526)
- **[Phase 5]** bpf_loop behind CAP_BPF (kernel/bpf/helpers.c:2124)
- **[Phase 5]** Selftest tools/testing/selftests/bpf/progs/tailcall_callback.c expects "cannot tail call within callback"
- **[Phase 6]** Reverse git apply --check of this commit: success (fix already present)
- **[Phase 8]** Failure mode: infinite tailcall hang, severity HIGH; trigger CAP_BPF BPF_PROG_LOAD
- **UNVERIFIED:** Stable mailing-list discussion (HTTP 403)

The local tree is v7.3-rc4. The buggy verifier path exists in this series, the 8-line reject is a real hang fix, prerequisites are present, and the change belongs in this tree.

**YES**

 kernel/bpf/verifier.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
kernel/bpf/verifier.c +2 -6
index b89a5d717e422..5cc3e9a990ef7 100644
@@ -6808,10 +6808,6 @@ static int check_max_stack_depth_subprog(struct bpf_verifier_env *env, int idx,
 		if (verifier_bug_if(sidx < 0, env, "callee not found at insn %d", next_insn))
 			return -EFAULT;
 		if (subprog[sidx].is_async_cb) {
-			if (subprog[sidx].has_tail_call) {
-				verifier_bug(env, "subprog has tail_call and async cb");
-				return -EFAULT;
-			}
 			/* async callbacks don't increase bpf prog stack size unless called directly */
 			if (!bpf_pseudo_call(insn + i))
 				continue;
@@ -6852,8 +6848,8 @@ static int check_max_stack_depth_subprog(struct bpf_verifier_env *env, int idx,
 	 */
 	if (tail_call_reachable)
 		for (tmp = idx; tmp >= 0; tmp = dinfo[tmp].caller) {
-			if (subprog[tmp].is_exception_cb) {
-				verbose(env, "cannot tail call within exception cb\n");
+			if (subprog[tmp].is_cb) {
+				verbose(env, "cannot tail call within callback\n");
 				return -EINVAL;
 			}
 			subprog[tmp].tail_call_reachable = true;
Signature · 1 line
2.53.0
#284 lore raw

Re: [PATCH AUTOSEL 6.18] bpf: Reject callback subprogs invoke tailcall

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] bpf: unreset tail_call_reachable in check_max_stack_depth_subprog() --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] bpf: unreset tail_call_reachable in check_max_stack_depth_subprog() --

commit c2ffc0a7246f4fd9042fb29769bcdfa70c066eca
Author: Pu Lehui <[email protected]>

bpf: Reject callback subprogs invoke tailcall

This commit rejects tailcalls inside synchronous callback subprograms by widening the exception callback check in check_max_stack_depth_subprog() to cover all callbacks via is_cb.

Quoted 4 lines
kernel/bpf/verifier.c +0 -0
index b89a5d717e422..5cc3e9a990ef7 100644

[ ... ]

kernel/bpf/verifier.c static int check_max_stack_depth_subprog(struct bpf_verifier_env *env, int idx, · line 6855

Quoted 11 lines
kernel/bpf/verifier.c +2 -2
@@ -6852,8 +6848,8 @@ static int check_max_stack_depth_subprog(struct bpf_verifier_env *env, int idx,
 	 */
 	if (tail_call_reachable)
 		for (tmp = idx; tmp >= 0; tmp = dinfo[tmp].caller) {
-			if (subprog[tmp].is_exception_cb) {
-				verbose(env, "cannot tail call within exception cb\n");
+			if (subprog[tmp].is_cb) {
+				verbose(env, "cannot tail call within callback\n");
 				return -EINVAL;
 			}
 			subprog[tmp].tail_call_reachable = true;

[Severity: High]
Can this falsely reject valid BPF programs when a program calls a tail-calling subprogram and later uses an unrelated synchronous callback that does not invoke any tailcalls?

In check_max_stack_depth() -> check_max_stack_depth_subprog(), the local variable tail_call_reachable is initialized once at function entry and is only ever set to true when descending into a callee:

kernel/bpf/verifier.c:check_max_stack_depth_subprog() {
	bool tail_call_reachable = false;
	...
		idx = sidx;
		if (!priv_stack_supported)
			subprog[idx].priv_stack_mode = NO_PRIV_STACK;

		if (subprog[idx].has_tail_call)
			tail_call_reachable = true;
}

Because tail_call_reachable is never reset to false when entering a subsequent callee whose has_tail_call is false (or when popping back to a caller), once any normal subprogram with has_tail_call == true is visited, tail_call_reachable remains true for the rest of the walk.

Synchronous callbacks (such as callbacks passed to bpf_loop or bpf_for_each_map_elem) have is_cb == true and is_async_cb == false, so the traversal enters them via bpf_pseudo_func(insn + i). If a synchronous callback without tailcalls is visited after an unrelated tail-calling subprogram, tail_call_reachable is still true and hits this new subprog[tmp].is_cb check, failing BPF_PROG_LOAD with -EINVAL.

Does this backport also need prerequisite upstream commit 3513ea9dab6c1 ("bpf: Sync tail_call_reachable with callee state on entry"), which updates the callee entry logic to:

	tail_call_reachable = subprog[idx].has_tail_call;

so that tail_call_reachable does not leak across unrelated subprograms?

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

PATCH 1/1 fs/ntfs3: load ATTR_BITMAP run extents from $MFT extension records

In reply to Sasha Levin

From: Konstantin Komarov <[email protected]>

[ Upstream commit e31886cb6e0e14cf65e27da0bf1a422ff419d893 ]

When $MFT's ATTR_BITMAP attribute is heavily fragmented, its run list can span multiple MFT extension records (attribute list entries with vcn > 0). The non-primary segment handler in ntfs_read_mft() only processed ATTR_DATA extension segments for MFT_REC_MFT, silently skipping any ATTR_BITMAP segments. This left sbi->mft.bitmap.run incomplete, causing wnd_init() to fail with -ENOENT when wnd_rescan() tried to look up a VCN not covered by the truncated run list.

Observed on a 16 TB NTFS volume (0xFFFFFEFF total clusters) whose MFT bitmap run list was split across 97 extents in extension records. wnd_rescan() successfully looked up VCNs 0-122 from the runs loaded from the base record, then failed at VCN 123 (the last cluster of the bitmap) whose run was only present in an extension record.

Fix by extending the MFT_REC_MFT special case to also handle ATTR_BITMAP extension segments, storing their runs into sbi->mft.bitmap.run the same way the primary segment does.

---

LLM Generated explanations, may be completely bogus:

I have enough to judge this: a real NTFS3 mount failure, a small first- pass run-list fix, and a related later super.c workaround already in this 7.3 tree. Writing the full 9-phase analysis next.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**

Record: **[fs/ntfs3] [load] load ATTR_BITMAP run extents from $MFT extension records**

The verb is “load”, not “fix”, but the body describes a mount failure and a missing code path. Intent is a bug fix.

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

Commit: e31886cb6e0e14cf65e27da0bf1a422ff419d893

Tags present:
- Signed-off-by: Senjin <[email protected]> (author of the fix)
- Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon- software.com> (ntfs3 maintainer)

Tags absent (expected for this pipeline): Fixes:, Cc: stable, Reported-by, Tested-by, Reviewed-by, Acked-by, Link:.

AuthorDate: 2026-07-02; CommitDate: 2026-07-24 (maintainer applied it).

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

Record:
- **Bug:** When $MFT’s ATTR_BITMAP is heavily fragmented, its run list spans MFT extension records (le->vcn > 0). ntfs_read_mft() only unpacked ATTR_DATA extension segments for MFT_REC_MFT and skipped ATTR_BITMAP segments.
- **Symptom:** sbi->mft.bitmap.run is truncated. wnd_init() → wnd_rescan() → run_lookup_entry() returns -ENOENT. Mount fails.
- **Evidence:** 16 TB volume (0xFFFFFEFF clusters). Bitmap run list split across 97 extents. VCNs 0–122 found from the base record; VCN 123 (last bitmap cluster) only in an extension record.
- **Root cause:** Non-primary segment handler too narrow (ino != MFT_REC_MFT || attr->type != ATTR_DATA).
- **Fix:** Same special case also unpacks ATTR_BITMAP into sbi->mft.bitmap.run.
- **Versions:** None named in the message. Observation used CONFIG_NTFS3_64BIT_CLUSTER=y (from the v2 cover letter).

**Step 1.4: DETECT HIDDEN BUG FIXES**

Record: Not a disguised cleanup. Explicit mount-failure fix; “load” is the mechanism.

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES**

Record:
- File: fs/ntfs3/inode.c — **+8 / −2** (net +6)
- Function: ntfs_read_mft()
- Scope: **single-file surgical fix**

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

Before (parent e31886cb6e0e1^):

```c
if (le && le->vcn) {
    /* non-primary segment */
    if (ino != MFT_REC_MFT || attr->type != ATTR_DATA)
        goto next_attr;
    run = &ni->file.run;
    ...
    goto attr_unpack_run;
}
```

After:

```c
if (le && le->vcn) {
    if (ino != MFT_REC_MFT)
        goto next_attr;
    if (attr->type == ATTR_DATA)
        run = &ni->file.run;
    else if (attr->type == ATTR_BITMAP)
        run = &sbi->mft.bitmap.run;
    else
        goto next_attr;
    ...
    goto attr_unpack_run;
}
```

Record: Non-primary $MFT ATTR_BITMAP segments now take the same attr_unpack_run path the primary ATTR_BITMAP case already uses (run = &sbi->mft.bitmap.run around inode.c:323–333). Other inodes and other attribute types still skip non-primary segments.

**Step 2.3: IDENTIFY THE BUG MECHANISM**

Record: **[Logic / correctness]** Incomplete run-list construction. Missing handling of $MFT ATTR_BITMAP extension segments left sbi->mft.bitmap.run short, so wnd_rescan() failed with -ENOENT at an uncovered VCN.

**Step 2.4: ASSESS THE FIX QUALITY**

Record:
- Obviously correct: it mirrors the existing ATTR_DATA special case and the primary ATTR_BITMAP assignment.
- Minimal: one condition split, one extra branch.
- Regression risk: low. run_add_entry() allows overlapping runs, so a later second unpack is safe.
- No API / locking / data-structure change.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**

Record: Buggy test if (ino != MFT_REC_MFT || attr->type != ATTR_DATA) comes from **82cae269cfa953** (“fs/ntfs3: Add initialization of super block”, 2021-08-13) — original ntfs3 merge. Present since **v5.15**.

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

Record: No Fixes: tag. Introducer is 82cae269cfa953, ancestor of HEAD (git merge-base --is-ancestor exit 0).

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

Record: Related commit already in this tree:

**6d979b64287fb** — ntfs3: fix mount failure on volumes with fragmented MFT bitmap (2026-04-07, contained in **v7.1-rc1**).

That patch:
1. Moves ni_load_all_mi() before wnd_init().
2. Walks attributes and run_unpack_ex()s $BITMAP extents with svcn != 0.

Same symptom (wnd_init / -ENOENT), different site (super.c second pass vs inode.c first pass). 6d979b64287fb is an ancestor of e31886cb6e0e1.

Series context: mailing-list **v2 1/2**. Patch 2/2 is 789af83e41aef (lseek EINVAL on 64-bit clusters) — independent, not a prerequisite.

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

Record: Applied by **Konstantin Komarov**, listed M: for NTFS3 (MAINTAINERS: Supported). Senjin also authored the sibling lseek fix. Maintainer SOB is a strong quality signal.

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

Record: Standalone. Uses existing attr_unpack_run, sbi->mft.bitmap.run, and the MFT_REC_MFT special case from 2021. No new helpers. Patch 2/2 is unrelated.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

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

Record:
- b4 dig -c e31886cb6e0e1 **failed**: lore.kernel.org returned errors.
- Found via web search:
- v1: 2026-06-10, [PATCH] fs/ntfs3: load ATTR_BITMAP run extents...
- v2: 2026-06-13, [PATCH v2 1/2] — **hunk-header fix only, no code change**
- Cover: [PATCH v2 0/2] fs/ntfs3: two fixes for large NTFS volumes
- Openwall: https://lists.openwall.net/linux-kernel/2026/06/13/668 and

    `/669`

- No NAKs found. Maintainer merged it into ntfs3_for_7.3.
- Cover letter: both bugs seen on a 16 TB volume with CONFIG_NTFS3_64BIT_CLUSTER=y.

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

Record: b4 dig -w failed. Recipients from the archived mail:
[email protected], [email protected], [email protected]. Maintainer was CC’d and later signed off. No other Reviewed-by on the commit.

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

Record: Reporter is Senjin (author), with a concrete 16 TB / 97-extent case. No syzbot/bugzilla. Cover does not mention 6d979b64287fb, so Senjin likely reproduced on a kernel without that later-pass workaround (UNVERIFIED which exact release they ran).

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

Record: v2 0/2 is two independent large-volume fixes. 2/2 is not required for 1/2.

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

Record: lore.kernel.org/stable search did not return discussion of this commit (403/irrelevant hits). No documented reason to keep it out of stable.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: IDENTIFY KEY FUNCTIONS**

Record: ntfs_read_mft(); uses ni_enum_attr_ex(), attr_unpack_run → run_unpack_ex(). Failure path: wnd_init() → wnd_rescan() → run_lookup_entry().

**Step 5.2: TRACE CALLERS**

Record:
- ntfs_read_mft() is static; only caller is ntfs_iget5() when I_NEW.
- Mount: ntfs_fill_super() → ntfs_iget5($MFT) → ntfs_read_mft().
- Not IRQ; mount/iget path.

**Step 5.3: TRACE CALLEES**

Record: ni_enum_attr_ex() loads ATTR_LIST records via ni_load_mi(). Matching segments go to run_unpack_ex() into sbi->mft.bitmap.run. Later wnd_init(&sbi->mft.bitmap) scans that run list.

**Step 5.4: FOLLOW THE CALL CHAIN**

Record: mount -t ntfs3 → ntfs_fill_super → load $MFT → incomplete bitmap runs → wnd_init fails → mount fails. **Userspace-reachable.** Unprivileged users cannot trigger it without mount rights; operators with NTFS volumes can. Volume is unusable until remounted with another driver.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**

Record: Primary ATTR_BITMAP already sets run = &sbi->mft.bitmap.run. 6d979b64287fb unpacks the same extents later in ntfs_fill_super(). run_add_entry() documents that new runs may overlap existing ones, so both paths together are safe.

---

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

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

Record:
- Local tree: **v7.3-rc4-27-gf0100363d8c37**, make kernelversion = **7.3.0-rc4** (mainline-style checkout, detached HEAD).
- Candidate **is already an ancestor of HEAD**.
- Buggy skip has existed since 82cae269cfa953 (v5.15). Parent of this commit still has it.
- 6d979b64287fb (v7.1-rc1) is also in this tree and tries to paper over the same gap in super.c.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**

Record: Expected apply: **clean** on any tree with the original MFT_REC_MFT/ATTR_DATA special case (all ntfs3 trees since 5.15). Hunk is isolated.

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

Record: 6d979b64287fb is here. It is a second-pass unpack after ni_load_all_mi(), not a replacement for loading during ntfs_read_mft(). No later commit reverts or replaces e31886cb6e0e1. ADS/iomap commits after it do not touch this branch.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

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

Record: **fs/ntfs3** — **IMPORTANT** (supported RW Windows filesystem, not staging). Not core VFS/mm, but mount failure is serious for dual- boot, NAS, and large Windows volumes.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**

Record: Actively maintained (Paragon tree, multiple 7.x ntfs3 pulls). This is a targeted correctness fix, not drive-by churn.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: DETERMINE WHO IS AFFECTED**

Record: **Filesystem-specific / config-specific.** Users of CONFIG_NTFS3_FS with a fragmented $MFT $BITMAP (large or long- lived NTFS). The 16 TB report also used CONFIG_NTFS3_64BIT_CLUSTER. Fragmentation itself is not limited to 64-bit clusters; 6d979b64287fb reproduced on a 664 GB volume.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**

Record: Every mount of an affected volume. Not a race. Needs mount capability, not an unprivileged syscall gadget. Common on large/aged NTFS.

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

Record: **Mount failure (-ENOENT)** — volume cannot be mounted with ntfs3. **HIGH** (not a panic, but the filesystem is unusable).

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

Record:
- **Benefit:** High for affected volumes (mount works). Completes the $MFT parse the same way ATTR_DATA was always handled. Helps trees that lack 6d979b64287fb; on trees that have it, it is still the right first-pass fix and is overlap-safe.
- **Risk:** Very low (6 lines in one function, existing unpack helper).
- **Ratio:** Strongly favors backport.

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

**FOR:**
- Real mount failure, observed on a 16 TB volume (97 extents; fail at last VCN).
- Independent 664 GB report of the same class (6d979b64287fb).
- Bug in ntfs3 since v5.15.
- 8-line, obviously correct extension of an existing special case.
- Maintainer SOB; merged to ntfs3_for_7.3.
- Standalone (series 2/2 is unrelated).
- run_add_entry() allows overlap with the v7.1 second-pass unpack.

**AGAINST:**
- 6d979b64287fb already in **this** 7.3 tree may already make mount succeed via a later unpack.
- No Fixes:/Cc: stable (not a negative in this pipeline).
- Affects ntfs3 only, not all kernel users.

**UNRESOLVED:**
- Whether Senjin’s 16 TB kernel included 6d979b64287fb (cover letter never mentions it).
- lore.kernel.org was unreachable for b4 dig / WebFetch; discussion recovered from Openwall/LKML mirrors.

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

1. Obviously correct and tested? **PASS** — mirrors ATTR_DATA; tested on a real 16 TB volume; maintainer applied it.
2. Fixes a real bug that affects users? **PASS** — mount -ENOENT on fragmented $MFT bitmap.
3. Important issue? **PASS** — filesystem unmountable (HIGH).
4. Small and contained? **PASS** — +8/−2, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — code and helpers are present; hunk matches ntfs_read_mft().

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**

Record: None of the ID/quirk/DT/build/doc exceptions. It qualifies as a normal important bug fix.

**Step 9.4: DECISION**

This checkout is 7.3-rc4 and already contains the commit; the question is still whether that fix is stable material for this lineage. It is.

6d979b64287fb is a later-pass workaround, not a reason to drop the first-pass unpack. Silently skipping $MFT ATTR_BITMAP extents in ntfs_read_mft() is a real bug. The patch is small, correct, maintainer-acked, and prevents a user-visible mount failure on large/fragmented NTFS volumes.

---

### What the commit solves

$MFT’s bitmap run list can spill into extension records. ntfs_read_mft() unpacked only ATTR_DATA there, so sbi->mft.bitmap.run was truncated and wnd_init() failed with -ENOENT. Mount failed. The patch stores those bitmap extents the same way the primary segment already does.

### Stable rules

Meets all six criteria: small, obviously correct, real important bug, no new API, applies here.

### Risk vs benefit

Benefit: restores mount on affected NTFS volumes. Risk: very low; overlap with 6d979b64287fb is handled by run_add_entry().

### Concerns

- Series 1/2: 2/2 is an unrelated lseek fix; not required.
- 6d979b64287fb already in this 7.3 tree: complementary, not a blocker.
- No extra prerequisites beyond original ntfs3 MFT_REC_MFT handling (v5.15).

---

## Verification

- **[Phase 1]** Parsed e31886cb6e0e1: Senjin + Konstantin SOBs only; no Fixes/stable/Reported-by.
- **[Phase 2]** git show e31886cb6e0e1: +8/−2 in ntfs_read_mft(); ATTR_BITMAP → sbi->mft.bitmap.run.
- **[Phase 2]** Read inode.c ATTR_BITMAP primary case (lines 323–333) and attr_unpack_run (399–414).
- **[Phase 2]** Read wnd_rescan(): missing run → err = -ENOENT.
- **[Phase 3]** git blame on parent: buggy line from 82cae269cfa953 (2021-08-13).
- **[Phase 3]** git merge-base --is-ancestor 82cae269cfa953 HEAD → yes.
- **[Phase 3]** Related fix 6d979b64287fb in tree (v7.1-rc1~76^2~6); ancestor of this commit.
- **[Phase 3]** git log --author=Konstantin Komarov -- fs/ntfs3/:
maintainer.
- **[Phase 4]** b4 dig -c e31886cb6e0e1: lore error; UNVERIFIED via b4.
- **[Phase 4]** Openwall v2 0/2 and 1/2: 16 TB repro; v2 is hunk-header only; 2/2 independent.
- **[Phase 4]** WebFetch spinics/lore: 500/403; used Openwall/LKML mirrors.
- **[Phase 4]** No stable@ discussion found.
- **[Phase 5]** Only caller of ntfs_read_mft: ntfs_iget5 (mount/I_NEW).
- **[Phase 5]** run_add_entry() documents overlap is allowed.
- **[Phase 6]** git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4.
- **[Phase 6]** Candidate is ancestor of HEAD; parent still has the skip.
- **[Phase 7]** MAINTAINERS: NTFS3 Supported, M: Konstantin Komarov.
- **[Phase 8]** Failure mode: mount -ENOENT, severity HIGH.
- **UNVERIFIED:** Exact kernel Senjin reproduced on; whether 6d979b64287fb alone would have mounted that 16 TB volume.

The local tree has the ntfs3 code path, the bug dates to the original driver, the patch is a small contained mount fix, and it should be backported.

**YES**

 fs/ntfs3/inode.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
fs/ntfs3/inode.c +8 -2
index 120691bc71ee9..99fdba7b403cb 100644
@@ -126,10 +126,16 @@ static struct inode *ntfs_read_mft(struct inode *inode,
 
 	if (le && le->vcn) {
 		/* This is non primary attribute segment. Ignore if not MFT. */
-		if (ino != MFT_REC_MFT || attr->type != ATTR_DATA)
+		if (ino != MFT_REC_MFT)
+			goto next_attr;
+
+		if (attr->type == ATTR_DATA)
+			run = &ni->file.run;
+		else if (attr->type == ATTR_BITMAP)
+			run = &sbi->mft.bitmap.run;
+		else
 			goto next_attr;
 
-		run = &ni->file.run;
 		asize = le32_to_cpu(attr->size);
 		goto attr_unpack_run;
 	}
Signature · 1 line
2.53.0
author maintainer
#286 lore raw

PATCH 1/1 ASoC: amd: acp-config: Add HVY-WXX9/M1060 DMI quirk

In reply to Sasha Levin

From: Mehmet Aysel <[email protected]>

[ Upstream commit 032bb633e0c34a88b70a4bfc65ebd4e2b510f706 ]

Add DMI match table entry for HUAWEI HVY-WXX9 board, product version M1060, a MateBook D16 2021 (Ryzen 5 4600H) revision not covered by the existing M1010/M1020/M1040 entries. This board uses the same FLAG_AMD_LEGACY / ACP_PCI_DEV_ID configuration as the other HVY-WXX9 variants.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit message forensics

**Step 1.1: Subject line**
Record: [ASoC/amd/acp-config] [Add] DMI quirk for HUAWEI HVY-WXX9 product version M1060

**Step 1.2: Tags**
Record:
- Signed-off-by: Mehmet Aysel <[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: stable (absence of the last two is expected for this review)

**Step 1.3: Body**
Record:
- **Bug:** MateBook D16 2021 (Ryzen 5 4600H), board HVY-WXX9 / product version M1060, is not in the DMI table. Sibling revisions M1010/M1020/M1040 already are.
- **Symptom:** ACP legacy audio does not bind on this BIOS revision.
- **Root cause:** snd_amd_acp_find_config() only returns FLAG_AMD_LEGACY on exact DMI matches; M1060 is missing.
- **Version info:** same hardware family already supported; this is another product-version string.

**Step 1.4: Hidden bug fix?**
Record: Not hidden. This is an explicit hardware DMI quirk. It is not cleanup or refactoring.

## Phase 2: Diff analysis

**Step 2.1: Inventory**
Record: sound/soc/amd/acp-config.c only; **+14 / -0**. One new config_table[] entry. Single-file surgical change. Functions: none changed; static table data only.

**Step 2.2: Code flow**
Record: **Before:** HVY-WXX9 + M1060 does not match; snd_amd_acp_find_config() returns 0. acp_pci_probe() then does if (flag != FLAG_AMD_LEGACY && flag != FLAG_AMD_LEGACY_ONLY_DMIC) return -ENODEV.
**After:** Same board matches and gets FLAG_AMD_LEGACY / ACP_PCI_DEV_ID, like M1010/M1020/M1040. Probe path only; no error-path or locking change.

**Step 2.3: Bug mechanism**
Record: **Hardware workaround / DMI quirk.** Missing exact DMI match left a real MateBook D16 2021 revision without ACP legacy enablement.

**Step 2.4: Fix quality**
Record: Copy of the existing M1040 entry with version "M1060". Minimal, obviously correct, no API or lock changes. Regression risk is limited to that DMI triple (HUAWEI / HVY-WXX9 / M1060).

## Phase 3: Git history

**Step 3.1: Blame**
Record: M1010 HVY-WXX9: b5338b1b901e4 (“Add support for a new Huawei Matebook laptop”, Marian Postevca, Dec 2023). M1020/M1040:
54fcd9dd44b2c (Aug 2023). Table itself: f1bdd8d385a80 (Nov 2021). All are ancestors of this 6.12 tree. The gap is only the M1060 string.

**Step 3.2: Fixes: tag**
Record: No Fixes: tag. Not applicable.

**Step 3.3: File history**
Record: Last acp-config.c change on this branch is e17de785850e3 (ACP 7.0 ACPI machine id). Huawei DMI rows have been unchanged since v6.7-era additions. Standalone table append; no prerequisite refactor.

**Step 3.4: Author**
Record: Mehmet Aysel has no other commits in sound/soc/amd/ on this tree. ASoC maintainer Mark Brown applied the series. Related historical work is Marian Postevca’s HVY-WXX9 entries, including 5513c5d0fb3d5 (“Fix support… must also update acp3x-es83xx DMI table”).

**Step 3.5: Dependencies**
Record: Compiles and applies alone. This is **patch 1/2**. Companion c1a39c228ace (“ASoC: amd: acp3x-es83xx: Add HVY-WXX9/M1060 DMI quirk”) is also not in this tree. Without 2/2, acp3x_es83xx_probe() still returns -ENODEV if ACPI exposes ES83xx but DMI does not match. 1/2 is still required: ACP PCI will not bind without FLAG_AMD_LEGACY. Same two-table pattern as M1010 (b5338b1b901e4 + 5513c5d0fb3d5).

## Phase 4: Mailing list / external

**Step 4.1: Original discussion**
Record: b4 dig -c 032bb633e0c3 →
https://patch.msgid.link/[email protected]
b4 dig -a: **v1 only** (no v2/v3). Mark Brown applied both patches to broonie/sound for-7.3
(https://git.kernel.org/broonie/sound/c/032bb633e0c3). Included in the sound fixes pull for 7.3-rc1 (git describe --contains → v7.3-rc1~17^2^2~4). No NAK found.

**Step 4.2: Recipients**
Record: b4 dig -w: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai, linux-sound, linux-kernel. Right ASoC/sound maintainers.

**Step 4.3: Bug report**
Record: No Bugzilla/syzbot link. Author describes a specific board/SKU not covered by existing exact matches. No user-count beyond that machine class.

**Step 4.4: Series**
Record: Two-patch series. [2/2] adds the same DMI triple to acp3x-es83xx.c with ES83XX_ENABLE_DMIC. Both should be backported for working speakers/mic; this commit is still a valid standalone quirk and a prerequisite for 2/2.

**Step 4.5: Stable list**
Record: No stable-list discussion found for HVY-WXX9/M1060. Lore search from this environment is 403-limited; lkml/openwall mirrors were used instead.

## Phase 5: Semantic / call-graph

**Step 5.1: Functions**
Record: No function bodies edited. Data consumed by snd_amd_acp_find_config().

**Step 5.2: Callers**
Record: snd_amd_acp_find_config() is called from PCI probe:
- sound/soc/amd/acp/acp-pci.c (acp_pci_probe) — **this is the path that matters** (FLAG_AMD_LEGACY)
- sound/soc/amd/renoir/rn-pci-acp3x.c, vangogh/pci-acp5x.c, yc/pci- acp6x.c, ps/pci-ps.c
- SOF: pci-rn.c, pci-rmb.c, pci-vangogh.c, pci-acp63.c, pci- acp70.c

**Step 5.3: Callees**
Record: dmi_check_system() on each config_entry. Match sets acp_quirk_data and returns flags.

**Step 5.4: Reachability**
Record: Yes — PCI enumeration on AMD ACP 0x15E2 (CONFIG_SND_SOC_AMD_ACP_PCI / CONFIG_SND_AMD_ACP_CONFIG, X86+PCI+ACPI). Userspace does not trigger it; missing audio on that laptop is the user-visible effect.

**Step 5.5: Similar patterns**
Record: Same table already has HVY-WXX9 M1010/M1020/M1040 and other Huawei KLVL/BOM entries. This tree has many post-v6.12 AMD DMI quirk backports (e.g. 6599a33c97f45, 33680092d71b4).

## Phase 6: This tree (6.12.y)

**Step 6.1: Buggy/missing code**
Record: Local tree is **6.12.111** (git describe HEAD → p-6.12-3-gc504cf0baa3d8, make kernelversion → 6.12.111). M1060 is **absent**. Sibling HVY-WXX9 entries are at acp-config.c:120-161. 032bb633e0c3 is **not** an ancestor of HEAD.

**Step 6.2: Backport difficulty**
Record: git show 032bb633e0c3 | git apply --check → **Hunk succeeded at 159 (offset -50 lines)**. Clean apply.

**Step 6.3: Related fixes already here?**
Record: No M1060 entry in sound/soc/amd/. No substitute fix.

## Phase 7: Subsystem context

**Step 7.1:**
Record: ASoC AMD ACP machine config. **IMPORTANT** for owners of these Huawei AMD laptops; not core mm/fs. Driver already exists here.

**Step 7.2:**
Record: ACP config table is mature (since ~5.17/6.7 Huawei work). This 6.12 tree continues to take AMD DMI quirks.

## Phase 8: Impact and risk

**Step 8.1:**
Record: Driver-specific, DMI-specific: HUAWEI HVY-WXX9 / M1060 (MateBook D16 2021, Ryzen 5 4600H).

**Step 8.2:**
Record: Trigger is boot/ACP PCI probe on that SKU. Not unprivileged- attack surface. Common for that machine; zero effect on others.

**Step 8.3:**
Record: Failure mode is **no audio** (-ENODEV), not oops/UAF. Severity **MEDIUM** for those users; this is the hardware-quirk exception, not a crash fix.

**Step 8.4:**
Record: **Benefit high** for that SKU (audio enablement, same as IDs/quirks already taken here). **Risk very low** (14-line DMI row, exact match, existing flag). Ratio strongly favors backport.

## Phase 9: Synthesis

**Evidence FOR:**
- Documented hardware-quirk / device-ID exception
- Real laptop revision omitted from exact DMI matches
- Sibling M1010/M1020/M1040 already in this 6.12 tree
- +14 lines, one file, no new API
- Applies cleanly with line offset
- Applied by ASoC maintainer; in v7.3-rc1 sound pull
- This tree already backports AMD DMI quirks after v6.12

**Evidence AGAINST:**
- Not a crash/security/corruption fix
- Full speakers/mic also need companion 2/2 (c1a39c228ace), not in this tree
- Author is not the subsystem regular (mitigated by Mark Brown applying it)

**Unresolved:** None that change the verdict. Stable-list 403 on lore; mirrors showed no NAK and no prior rejection.

**Stable rules:**
1. Obviously correct and tested? **PASS** — copy of existing entry; maintainer applied
2. Real bug affecting users? **PASS** — missing audio on M1060
3. Important (crash/security/corruption/deadlock)? **PASS via quirk exception** — device enablement
4. Small and contained? **PASS** — 14 lines, one file
5. No new features/APIs? **PASS** — DMI row for existing driver/flags
6. Applies to this tree? **PASS** — verified git apply --check

**Exception category:** Hardware DMI quirk / device-ID-style addition to an existing driver.

The patch makes ACP legacy bind on a MateBook D16 2021 BIOS revision this tree already treats as supported for M1010/M1020/M1040. That is exactly the class of quirk 6.12.y already takes. Companion acp3x-es83xx M1060 should be backported too for a complete card, but this commit is self-contained, applies cleanly, and is the PCI-bind half of that enablement.

Verification:
- [Phase 1] Tags: author SOB, Mark Brown SOB, msgid link; no Fixes/Reported-by/Cc: stable
- [Phase 2] Diff: +14 lines in config_table[] only; FLAG_AMD_LEGACY
+ ACP_PCI_DEV_ID + DMI triple
- [Phase 3] Blame: M1010=b5338b1b901e4, M1020/M1040=54fcd9dd44b2c; both ancestors of HEAD
- [Phase 3] 5513c5d0fb3d5 documents that acp-config alone is incomplete without es83xx DMI
- [Phase 3] Author has no other sound/soc/amd commits on this tree
- [Phase 4] b4 dig -c 032bb633e0c3: msgid 20260825092432.56292-1; v1 only; Broonie applied both
- [Phase 4] Recipients: lgirdwood, broonie, perex, tiwai, linux-sound
- [Phase 4] Included in sound fixes pull for 7.3-rc1; git describe --contains = v7.3-rc1~17^2^2~4
- [Phase 5] acp_pci_probe() returns -ENODEV unless flag is FLAG_AMD_LEGACY
- [Phase 5] acp3x_es83xx_probe() also requires its own DMI table (companion 2/2)
- [Phase 6] git describe HEAD = p-6.12-3-gc504cf0baa3d8; make kernelversion = 6.12.111
- [Phase 6] git merge-base --is-ancestor 032bb633e0c3 HEAD → not ancestor; M1060 absent
- [Phase 6] git apply --check of 032bb633 → success at line 159, offset -50
- [Phase 6] Companion c1a39c228ace also not an ancestor of HEAD
- [Phase 7/8] Post-v6.12 AMD DMI quirks already present (e.g. 6599a33c97f45, 2026-09-21)
- UNVERIFIED: full lore.kernel.org thread body (HTTP 403); used lkml.iu.edu / openwall / b4 instead

**YES**

 sound/soc/amd/acp-config.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
sound/soc/amd/acp-config.c +14 -0
index 365209ea53f36..653e8ce946082 100644
@@ -159,6 +159,20 @@ static const struct config_entry config_table[] = {
 			{}
 		},
 	},
+	{
+		.flags = FLAG_AMD_LEGACY,
+		.device = ACP_PCI_DEV_ID,
+		.dmi_table = (const struct dmi_system_id []) {
+			{
+				.matches = {
+					DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"),
+					DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HVY-WXX9"),
+					DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1060"),
+				},
+			},
+			{}
+		},
+	},
 };
 
 static int snd_amd_acp_acpi_find_config(struct pci_dev *pci)
Signature · 1 line
2.53.0
author maintainer
#287 lore raw

PATCH 1/1 platform/x86/amd/pmc: Add T14 Gen2 AMD (20XL) to s2idle quirk list

In reply to Sasha Levin

From: Yap Weei Choong <[email protected]>

[ Upstream commit e25fb2258bddbcf70df69d1358be3e1274bdc5f2 ]

The ThinkPad T14 Gen 2 AMD was sold under two machine types, 20XK and 20XL, but only 20XK has been in the s2idle quirk list since the quirk was introduced in commit 455cd867b85b ("platform/x86: thinkpad_acpi:
Add a s2idle resume quirk for a number of laptops").

On 20XL machines the firmware SMI handler therefore still runs on the NVMe D3->D0 transition when exiting suspend-to-idle. With IOMMU translation enabled (the default), this intermittently stalls resume for ~10.25 seconds: seven devices across three root ports (nvme, both xhci_hcd functions, xhci-pci-renesas, snd_hda_intel x2, snd_rn_pci_acp3x) block in pci_pm_resume_noirq and are released simultaneously, consistent with all cores being held in SMM.

Add the missing 20XL machine type, mirroring the existing 20XK entry. This is the same class of omission fixed by commit 9a469c6dfab3 ("platform/x86: thinkpad_acpi: Add missing T14s Gen1 type to s2idle quirk list").

Verified on a ThinkPad T14 Gen 2a (type 20XLS41C00, BIOS R1MET62W 1.32, kernel 6.12.95): with this entry the quirk message appears at probe and a 14-hour suspend resumes in ~1s with no noirq stalls, where previously even short suspends could hit the ~10s delay. A further two-day soak (short naps and two ~14-hour suspends) showed every resume clean.

---

LLM Generated explanations, may be completely bogus:

The local checkout is **Linux 7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The candidate is e25fb2258bddb (platform/x86/amd/pmc: Add T14 Gen2 AMD (20XL) to s2idle quirk list). It is an 8-line DMI hardware-quirk addition: the sibling machine type 20XK has been quirked since 2022; 20XL was omitted, and that omission causes ~10s s2idle resume stalls on T14 Gen 2 AMD.

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

**Step 1.1: PARSE THE SUBJECT LINE**
Record: [platform/x86/amd/pmc] [Add] [T14 Gen2 AMD machine type 20XL to the existing s2idle DMI quirk list]

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- Link: https://bugzilla.kernel.org/show_bug.cgi?id=221755 — user- filed kernel bug
- `Link:
https://patch.msgid.link/[email protected]` — lore submission
- Signed-off-by: Yap Weei Choong <[email protected]> (author)
- Tested-by: Yap Weei Choong <[email protected]> (author verified on hardware)
- Reviewed-by: Mario Limonciello (AMD) <[email protected]> (AMD PMC author of the original quirk)
- Reviewed-by: Ilpo Järvinen <[email protected]> (platform-drivers-x86 maintainer)
- Signed-off-by: Ilpo Järvinen <[email protected]> (applied)
- No Fixes: tag (expected)
- No Cc: stable (expected)
- No Reported-by: (bugzilla Link instead)
- Ignore any Sasha Levin SOB (none on the real commit)

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** ThinkPad T14 Gen 2 AMD shipped as machine types 20XK and 20XL. Only 20XK was listed when the quirk was added in 455cd867b85b.
- **Symptom:** On 20XL, the firmware SMI still runs on NVMe D3→D0 at s2idle exit. With IOMMU on (default), resume stalls ~10.25s; seven devices on three root ports (nvme, both xhci_hcd, xhci-pci- renesas, snd_hda_intel x2, snd_rn_pci_acp3x) block in pci_pm_resume_noirq and wake together — consistent with all cores stuck in SMM.
- **Fix:** Add DMI entry 20XL mirroring 20XK. Same class of omission as 9a469c6dfab3 (missing T14s Gen1 type).
- **Versions:** Reproduced on kernel 6.12.95, BIOS R1MET62W 1.32, type 20XLS41C00. After the quirk: 14-hour suspend resumes in ~1s; two-day soak was clean.
- **Root cause:** Incomplete DMI coverage of a known Lenovo firmware SMI bug, not a new kernel logic bug.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. Explicit hardware quirk for a documented firmware bug. The verb is "Add" because that is how DMI quirk tables are extended.

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

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/platform/x86/amd/pmc/pmc-quirks.c — **+8 / −0**
- Function: none; static fwbug_list[] table only
- Scope: single-file surgical DMI addition

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** DMI match for LENOVO/20XK applies quirk_s2idle_spurious_8042. LENOVO/20XL does not match, so amd_pmc_quirks_init() leaves dev->quirks unset for 20XL.
- **After:** 20XL matches the same quirk. Probe logs the s2idle quirk; amd_pmc_process_restore_quirks() runs amd_pmc_skip_nvme_smi_handler() on s2idle restore; disable_8042_wakeup is also set (same as 20XK).
- Path: probe (amd_pmc_quirks_init) and s2idle restore (amd_pmc_s2idle_restore → amd_pmc_process_restore_quirks). DMI- gated; other machines unchanged.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** Hardware workaround (DMI quirk table entry)
- **Mechanism:** Skip the Lenovo BIOS SMI on NVMe D3→D0 by clearing bit 0 at FCH_PM_BASE + FCH_PM_SCRATCH (0xFED80380 / SI3R) before the D0 transition. 20XL never got that skip.

**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: identical copy of the adjacent 20XK entry with product name 20XL.
- Minimal: 8 lines, no API/locking/refactor.
- Regression risk: very low. Only DMI-matched 20XL machines. False- positive would require another Lenovo product whose DMI product name contains 20XL; Lenovo machine types are 4-character prefixes and existing entries (20XK, 20XF, 20XH, …) use the same pattern.
- Red flags: none.

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

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- 20XK block: e8ef8dd28c4c4 (Mario Limonciello, 2023-07-10) — moved the quirk from thinkpad_acpi into amd-pmc.
- 20XK driver_data: later 5b9e07551faa7 (2025-07-24) switched it to &quirk_s2idle_spurious_8042.
- 20XL block: e25fb2258bddb (Yap Weei Choong, 2026-07-17) — this candidate.
- Original 20XK-only list: 455cd867b85b (2022-04-28, thinkpad_acpi). git show 455cd867b85b contains 20XK and **not** 20XL.
- Bug present since v5.18-era quirk introduction; still present after the 2023 move into amd-pmc.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Referenced history:
- 455cd867b85b — **is an ancestor of HEAD** (git merge-base --is- ancestor exit 0). Introduced the quirk; listed T14 Gen2 as 20XK only.
- 9a469c6dfab3 — **is an ancestor of HEAD**. Precedent: add the missing second Lenovo machine type (T14s Gen1 20UJ beside 20UH). Same 8-line DMI pattern.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Recent pmc-quirks.c work is more DMI quirk rows (Legion Go 2, Yoga 6, MECHREVO, TUXEDO, L14 Gen3, suspend delay). No refactor that this depends on. git log e25fb2258bddb..HEAD -- pmc-quirks.c shows no later edits of the 20XL entry. Standalone, not patch X/Y.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Yap Weei Choong has this single commit under drivers/platform/x86/amd/. Mario Limonciello (reviewer) originated the quirk and maintains this table. Ilpo Järvinen applied it as platform- drivers-x86 maintainer.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: On this tree the patch assumes fwbug_list[] and quirk_s2idle_spurious_8042 in pmc-quirks.c. Both exist. amd_pmc_quirks_init() / amd_pmc_process_restore_quirks() exist in pmc.c. Applies standalone here.

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

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c e25fb2258bddb →
https://patch.msgid.link/[email protected]
- b4 dig -a: **v1 only**; committed version is that v1.
- Thread (mbox): (1) author submission, (2) Mario Reviewed-by with no requests, (3) Ilpo applied as [1/1] to review-ilpo-next.
- No NAK. No reviewer Cc: stable. Ilpo’s boilerplate: fixes usually go via for-next unless they are this-cycle or a clear regression — that explains missing Cc: stable, not unsuitability for later stable backport.
- Lore HTTP 403 from this environment; thread recovered via b4 dig -m and Openwall/Patchew mirrors.

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To [email protected]; Cc Hans, Ilpo, [email protected] (MAINTAINERS for AMD PMC), Mario, linux- kernel. Right lists and both AMD PMC and PDx86 maintainers.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: Bugzilla 221755 linked; HTTP 403, so **bugzilla comments are UNVERIFIED**. Commit body itself is a first-hand report: machine type 20XLS41C00, BIOS, 6.12.95, 10.25s stall, soak test. Patchew lists a single-patch series.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: msgid …-2 is git-send-email numbering. Ilpo applied [1/1];
Patchew: “posted 1 patch”. Standalone.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: WebSearch of lore stable for this subject found **no** discussion of 20XL / this commit. No recorded reason to keep it out of stable.

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

**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: No function body edited. Table consumers:
amd_pmc_quirks_init(), amd_pmc_process_restore_quirks(), amd_pmc_skip_nvme_smi_handler(). semcode MCP: not available; used git grep.

**Step 5.2: TRACE CALLERS**
Record:
- amd_pmc_quirks_init(dev) from amd_pmc_probe() in pmc.c when CONFIG_SUSPEND and !disable_workarounds.
- amd_pmc_process_restore_quirks(pdev) from amd_pmc_s2idle_restore(), the LPS0 .restore callback (acpi_register_lps0_dev).
- Impact: AMD notebook s2idle resume, DMI-limited to 20XL.

**Step 5.3: TRACE CALLEES**
Record: dmi_first_match(fwbug_list); on match, skip SMI via request_mem_region_muxed / ioremap / iowrite8(val & ~BIT(0)) at FCH PM scratch. Same path 20XK already uses.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace suspend (s2idle, default on modern AMD laptops) → ACPI LPS0 restore → skip SMI. Reachable on every suspend/resume of a 20XL T14 Gen 2 AMD. Unprivileged users typically can suspend.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same file already pairs Gen1 T14 as 20UD+20UE and T14s as 20UH+20UJ. T14 Gen2 was 20XK only until this commit — same hole 9a469c6dfab3 fixed for T14s Gen1.

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- Tree: **7.3.0-rc4** (mainline).
- File and fwbug_list exist. 20XK exists. 20XL **is present** because e25fb2258bddb is already an ancestor of HEAD (git merge-base --is- ancestor exit 0). That is the mainline landing, not a reason to reject the fix on technical merit.
- Pre-commit state (20XK without 20XL) is what this patch corrects. The omission dates to 455cd867b85b (2022).

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: On this tree the hunk applies cleanly against the 20XK block. Expected difficulty: **clean apply**. (Older stables that still keep the table in thinkpad_acpi.c would need the same 8 lines next to 20XK there; that is not this checkout.)

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No alternate 20XL fix. git grep 20XL hits only this new pmc- quirks.c entry. 9a469c6dfab3 is the analogous T14s fix, already here.

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

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: drivers/platform/x86/amd/pmc/ — AMD PMC s2idle. **IMPORTANT** for AMD Ryzen notebooks (CONFIG_AMD_PMC, depends on ACPI/PCI/SUSPEND). Not core mm/VFS, but suspend/resume on a current ThinkPad SKU.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively maintained; frequent DMI quirk additions. Table is the supported way to fix firmware s2idle bugs. MAINTAINERS: Shyam Sundar S K; Mario is the quirk author and reviewed this patch.

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

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: Driver-specific / DMI-specific: Lenovo ThinkPad T14 Gen 2 AMD machine type **20XL** (e.g. 20XLS41C00). 20XK already quirked. CONFIG_AMD_PMC + s2idle.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: s2idle suspend/resume with IOMMU (default). Intermittent but seen on short suspends; 10s stall. Users who close the lid trigger it. Not a theoretical race.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- Failure: ~10s resume hang; PCI noirq waiters; all cores in SMM. Original quirk commit also documented IOMMU page faults and post- resume instability on this firmware SMI.
- Severity: **HIGH** (multi-second system hang on resume; possible IOMMU faults). Not a panic on every resume, but a serious production laptop bug.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- Benefit: **high** for 20XL owners (resume ~1s vs ~10s; matches 20XK).
- Risk: **very low** (8 lines, DMI-gated, copies a years-old entry).
- Ratio: strongly favors backport. Hardware-quirk exception category.

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

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Real firmware bug; missing second machine type of a known model
- ~10s s2idle resume stall, PCI noirq pileup, SMM hold; original class also caused IOMMU page faults
- Hardware quirk / DMI ID — explicit stable exception
- 8 lines, copy of 20XK, no new API
- Tested on hardware (6.12.95, 14h suspend, two-day soak)
- Reviewed by Mario Limonciello and Ilpo Järvinen
- Precedent: 9a469c6dfab3 did the same for T14s Gen1
- Bugzilla 221755; infrastructure present in this tree since 2023 (e8ef8dd28c4c4)
- Applies cleanly beside 20XK

AGAINST:
- No Cc: stable (expected; Ilpo routed via for-next)
- Affects one ThinkPad SKU, not all users
- Bugzilla page itself could not be fetched (403)

UNRESOLVED:
- Full bugzilla 221755 comment thread (403)
- Direct lore.kernel.org HTML (403); mbox + mirrors were enough

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — identical 20XK entry; author soak-tested; AMD + PDx86 review
2. Fixes a real bug that affects users? **PASS** — 20XL s2idle stall, bugzilla, hardware verification
3. Important issue? **PASS** — HIGH: resume hang / SMM stall; original bug class includes IOMMU faults
4. Small and contained? **PASS** — +8 lines, one table
5. No new features or APIs? **PASS** — DMI row for existing quirk
6. Can apply to the local tree? **PASS** — pmc-quirks.c + 20XK + quirk_s2idle_spurious_8042 present

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Hardware quirk/workaround** (DMI s2idle quirk), same class as USB/PCI/codec quirk table additions. Automatically stable-appropriate.

**Step 9.4: MAKE YOUR DECISION**
This is a textbook stable backport: a missing DMI match for a known firmware SMI bug on a shipping ThinkPad, eight lines, already reviewed and tested. It belongs in this tree’s stable lineage.

===============================================================
DETAILED EXPLANATION
===============================================================

**Problem:** T14 Gen 2 AMD has two Lenovo machine types. The kernel has skipped a resume-time NVMe SMI on 20XK since 2022. 20XL never matched, so firmware still traps into SMM on s2idle resume, stalling the machine ~10 seconds (and historically this SMI also caused IOMMU page faults).

**Stable rules:** Obviously correct, user-visible, small, no new API. Hardware-quirk exception applies.

**Risk vs benefit:** Benefit is restoring normal ~1s resume on 20XL. Risk is a DMI match that can only fire on 20XL-like product names. No locking or core-path change.

**Concerns:** None material on this 7.3-rc4 tree. The patch does not need other series members. Older stables that still keep the list in thinkpad_acpi.c would place the same row next to 20XK; that does not apply here.

===============================================================
VERIFICATION
===============================================================

Verification:
- [Phase 1] Subject/tags parsed from git log -1 e25fb2258bddb: Add DMI quirk; Links bugzilla 221755 and msgid; Tested-by author; Reviewed-by Mario Limonciello and Ilpo Järvinen; no Fixes/Cc-stable
- [Phase 1] Body: 10.25s s2idle stall on 20XL; verified 20XLS41C00 / BIOS R1MET62W / 6.12.95
- [Phase 2] git show e25fb2258bddb: +8 lines in fwbug_list[] only; LENOVO/20XL → quirk_s2idle_spurious_8042
- [Phase 2] Read pmc-quirks.c: skip SMI in amd_pmc_skip_nvme_smi_handler(); 20XK block immediately above
- [Phase 3] git blame -L 66,82 pmc-quirks.c: 20XK from e8ef8dd28c4c4 (2023); 20XL from e25fb2258bddb
- [Phase 3] git merge-base --is-ancestor 455cd867b85b HEAD → 0; git show confirms original list has 20XK, not 20XL
- [Phase 3] git merge-base --is-ancestor 9a469c6dfab3 HEAD → 0; same 8-line missing-type pattern for T14s 20UJ
- [Phase 3] Author log: only this amd/pmc commit; no later 20XL edits
- [Phase 4] b4 dig -c e25fb2258bddb: lore msgid 20260717060744.1252065-2
- [Phase 4] b4 dig -a: v1 only
- [Phase 4] b4 dig -w: PDx86 list, Hans, Ilpo, Shyam, Mario
- [Phase 4] b4 dig -m /tmp/thread.mbox: Mario Reviewed-by; Ilpo applied [1/1]; no NAK; for-next routing note
- [Phase 4] Openwall/Patchew mirrors confirm the same thread; Patchew “1 patch”
- [Phase 4] lore.kernel.org HTTP 403; bugzilla 221755 HTTP 403
- [Phase 4] Stable-list search: no hits for this subject
- [Phase 5] git grep amd_pmc_quirks_init: probe in pmc.c:938; restore via amd_pmc_s2idle_restore → amd_pmc_process_restore_quirks
- [Phase 5] semcode unavailable; callers from grep/read
- [Phase 6] make kernelversion / git describe HEAD: 7.3.0-rc4 / v7.3-rc4-27-gf0100363d8c37
- [Phase 6] git merge-base --is-ancestor e25fb2258bddb HEAD → 0 (commit already in this mainline checkout)
- [Phase 6] File and 20XK entry present; hunk would apply cleanly to the pre-commit 20XK block
- [Phase 7] Kconfig AMD_PMC: AMD Ryzen notebook s2idle; MAINTAINERS Shyam / PDx86
- [Phase 8] Failure mode from commit + 455cd867b85b: SMM resume stall / possible IOMMU faults; HIGH; DMI-limited
- UNVERIFIED: bugzilla 221755 comment text (403)
- UNVERIFIED: live lore HTML (403); mbox used instead

The patch is a contained hardware quirk for a real s2idle hang on T14 Gen 2 AMD 20XL and meets stable criteria on this tree.

**YES**

 drivers/platform/x86/amd/pmc/pmc-quirks.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/platform/x86/amd/pmc/pmc-quirks.c +8 -0
index 74ddf1d8289a9..09a30f3337596 100644
@@ -71,6 +71,14 @@ static const struct dmi_system_id fwbug_list[] = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "20XK"),
 		}
 	},
+	{
+		.ident = "T14 Gen2 AMD",
+		.driver_data = &quirk_s2idle_spurious_8042,
+		.matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "20XL"),
+		}
+	},
 	{
 		.ident = "T14 Gen1 AMD",
 		.driver_data = &quirk_s2idle_spurious_8042,
Signature · 1 line
2.53.0
author maintainer
#288 lore raw

PATCH 1/1 soc: amlogic: meson-clk-measure: remove debugfs tree

In reply to Sasha Levin

From: Pengpeng Hou <[email protected]>

[ Upstream commit 67481152be2ec5de3529664c82054b43d6d4b9f5 ]

meson_msr_probe() creates a debugfs tree with entries that reference devm-managed measurement table entries and the driver's private regmap state. The driver has no remove callback, so unbinding the device can leave those debugfs entries behind after the private data is released.

Store the debugfs root and remove the subtree from a new remove callback.

---

LLM Generated explanations, may be completely bogus:

## Phase 1: Commit message forensics

**Step 1.1 — Subject**
- Record: [soc: amlogic: meson-clk-measure] [remove] [tear down leftover debugfs on driver unbind]

**Step 1.2 — Tags**
- Reviewed-by: Neil Armstrong <[email protected]> (Amlogic SoC maintainer; also committed the patch)
- `Link:
https://patch.msgid.link/[email protected]`
- Signed-off-by: Pengpeng Hou <[email protected]> (author)
- Signed-off-by: Neil Armstrong <[email protected]> (maintainer)
- No Fixes:, no Reported-by:, no Tested-by:, no Cc: stable (absence is expected)
- No syzbot / bugzilla / CVE tags

**Step 1.3 — Body**
- Record: [Bug: probe creates debugfs entries that point at devm- managed msr_table and private regmap state, but the driver had no remove callback.]
- [Symptom: after unbind, leftover debugfs files can be used after that memory is released.]
- [Version info: none in the message. Driver has existed since v5.0.]
- [Root cause: missing lifetime teardown for debugfs vs. devm-managed private data.]

**Step 1.4 — Hidden bug fix?**
- Record: [Not hidden. This is an explicit lifetime/UAF fix, even though the verb is "remove".]

## Phase 2: Diff analysis

**Step 2.1 — Inventory**
- Record: [drivers/soc/amlogic/meson-clk-measure.c: +14 / −0]
- Functions: struct meson_msr (new debugfs_root), meson_msr_probe(), new meson_msr_remove(), meson_msr_driver table
- Scope: single-file surgical fix

**Step 2.2 — Code flow**
- Before: meson_msr_probe() builds /sys/kernel/debug/meson-clk-msr/ (measure_summary plus per-clock files). File private data is priv->data.msr_table and &priv->data.msr_table[i], with .priv = priv. priv, msr_table, reg, and regmap are all devm_* allocations. There was no platform_set_drvdata() and no .remove.
- After: root dentry is stored, platform_set_drvdata() is set, and meson_msr_remove() calls debugfs_remove_recursive() so the tree is gone before devres frees private data.
- Path: driver remove / module unload / sysfs unbind, not the normal measure path.

**Step 2.3 — Bug mechanism**
- Record: [Use-after-free / leftover debugfs after unbind]
- Mechanism: unbind runs devres teardown and frees priv / msr_table / regmap. Debugfs files remain. clk_msr_summary_show() does msr_table->priv->data.msr_count; meson_measure_id() then uses priv->regmap and priv->data.reg. That is a UAF if those files are read after unbind.
- Category (c)/(d): lifetime/refcount-style teardown; memory safety.

**Step 2.4 — Fix quality**
- Record: [Obviously correct, minimal, standard pattern.]
- debugfs_remove() itself already ignores IS_ERR_OR_NULL, so the extra check is redundant but harmless.
- platform_set_drvdata() is required for platform_get_drvdata() in remove.
- .remove is void (*)(struct platform_device *) in this tree, matching the new callback.
- Regression risk: low. debugfs_remove() uses simple_recursive_removal(), so in-flight file users are drained before return. No public API change.

## Phase 3: Git history

**Step 3.1 — Blame**
- Record: `[Buggy debugfs creation is from 2b45ebef39a2c ("soc: amlogic:
Add Meson Clock Measure driver"), 2018-11-28, first in v5.0-rc1.]`
- The missing-remove bug is as old as the driver. Confirmed on the parent of the fix: no platform_set_drvdata, no debugfs_root, no remove callback.

**Step 3.2 — Fixes: tag**
- Record: [No Fixes: tag. Introducer is 2b45ebef39a2c, present in this tree.]

**Step 3.3 — File history**
- Record: [Recent commits add SoC tables (A1/T7, S4, C3) and register- offset refactoring. None change debugfs lifetime.]
- Standalone, not patch X/Y.

**Step 3.4 — Author**
- Record: [Pengpeng Hou: only this commit on this driver. Reviewer/committer Neil Armstrong is the original driver author and Amlogic maintainer.]

**Step 3.5 — Dependencies**
- Record: [None. Uses existing debugfs_create_dir / debugfs_remove_recursive / platform_set_drvdata. Can apply standalone to this tree.]

## Phase 4: Mailing list and external research

**Step 4.1 — Original discussion**
- Record: [https://patch.msgid.link/20260615091531.21964-1- [email protected]]
- b4 dig -a: only v1; that version was applied.
- Maintainer review: Reviewed-by: Neil Armstrong.
- Sashiko bot flagged a pre-existing probe-time race (measure_summary created before .priv is filled). Armstrong replied: “Impossible the driver is initialized way before userspace starts.” That race is not introduced by this patch and was not treated as a blocker.
- No NAK. No reviewer request for Cc: stable.

**Step 4.2 — Recipients (b4 dig -w)**
- Record: [Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl, linux-amlogic, linux-arm-kernel, linux-kernel. Right maintainers were on the patch.]

**Step 4.3 — Bug report**
- Record: [No Reported-by / syzbot / bugzilla. Bug is from code inspection of lifetime mismatch.]

**Step 4.4 — Series**
- Record: [Standalone single patch. No follow-up on this file after 67481152be2ec.]

**Step 4.5 — Stable list**
- Record: [UNVERIFIED: lore.kernel.org/stable returned HTTP 403.]

## Phase 5: Code semantic analysis

**Step 5.1 — Functions**
- Record: [meson_msr_probe, meson_msr_remove (new), meson_msr_driver; readers clk_msr_show / clk_msr_summary_show / meson_measure_id]

**Step 5.2 — Callers**
- Record: [probe/remove from the platform core on bind/unbind. Debugfs show via DEFINE_SHOW_ATTRIBUTE. meson_msr_remove is only the new driver .remove.]

**Step 5.3 — Callees**
- Record: [debugfs_create_dir/file, debugfs_remove_recursive, platform_set/get_drvdata, and on read: mutex + regmap MMIO.]

**Step 5.4 — Reachability**
- Record: [Yes. CONFIG_MESON_CLK_MEASURE is tristate, default y on ARCH_MESON. DT nodes exist for GX, Meson8/8b, AXG, G12A, SM1, C3, S4, A1, T7. Unbind is rmmod meson-clk-measure or sysfs unbind, then reading leftover debugfs. Typically root-only, but still a real kernel UAF.]

**Step 5.5 — Similar patterns**
- Record: [Same teardown exists in other SoC drivers (qcom smem/socinfo/aoss, ti smartreflex). This driver was the one missing it.]

## Phase 6: This tree (v7.3-rc4)

**Step 6.1 — Does the buggy code exist here?**
- Record: [Yes in this lineage. Driver is drivers/soc/amlogic/meson- clk-measure.c. Bug introduced in v5.0 (2b45ebef39a2c). This checkout is v7.3-rc4-27-gf0100363d8c37 / 7.3.0-rc4. The fix landed in v7.3-rc1 (git merge-base --is-ancestor 67481152be2ec v7.3-rc1 succeeded; it is not in v7.2).]
- Current file already has debugfs_root and meson_msr_remove(). That is because the commit merged during 7.3; it is not a reason to treat the bug as never existing here.

**Step 6.2 — Backport difficulty**
- Record: [Clean apply on this tree. Context matches. .remove is already void.]

**Step 6.3 — Related fixes already here?**
- Record: [This is the fix. No alternate teardown was present before it.]

## Phase 7: Subsystem context

**Step 7.1**
- Record: `[Subsystem: drivers/soc/amlogic clock-measure debugfs helper.
Criticality: PERIPHERAL (Amlogic-only, debugfs), but UAF is still a crash/memory-safety bug.]`

**Step 7.2**
- Record: [Mature driver (2018). Recent work is new SoC tables, not lifetime redesign.]

## Phase 8: Impact and risk

**Step 8.1 — Who is affected**
- Record: [Amlogic Meson users with CONFIG_MESON_CLK_MEASURE and CONFIG_DEBUG_FS, after driver unbind/unload.]

**Step 8.2 — Trigger**
- Record: [Unbind or rmmod, then open leftover debugfs. Not a boot-hot path. Privileged in typical debugfs setups. Deterministic UAF, not a heisenrace.]

**Step 8.3 — Failure mode**
- Record: `[UAF → oops / KASAN / possible memory corruption. Severity:
HIGH.]`

**Step 8.4 — Risk-benefit**
- Record: `[Benefit: high for the affected unbind path (prevents UAF).
Risk: very low (14 lines, standard debugfs teardown). Ratio favors taking the fix.]`

## Phase 9: Synthesis

**Step 9.1 — Evidence**

For:
- Real UAF: leftover debugfs vs. devm private data after unbind
- Small (+14), obviously correct
- Reviewed and applied by the subsystem maintainer
- Driver and bug exist in this 7.3 tree’s history since v5.0
- MESON_CLK_MEASURE is tristate, so module unload is a supported path
- Same teardown pattern used elsewhere in drivers/soc/

Against:
- No user/syzbot report
- Debugfs, typically root-only
- Amlogic-only helper, not core kernel
- Maintainer did not nominate stable

Unresolved:
- Could not search lore.kernel.org/stable (HTTP 403)

**Step 9.2 — Stable rules**
1. Obviously correct and tested? **PASS** — standard remove + debugfs_remove_recursive; maintainer Reviewed-by
2. Real bug affecting users? **PASS** — leftover debugfs after unbind is a UAF
3. Important (crash/security/corruption/deadlock)? **PASS** — UAF oops / memory-safety; HIGH, not a theoretical warning
4. Small and contained? **PASS** — 14 lines, one file
5. No new features/APIs? **PASS**
6. Applies to this tree? **PASS** — driver present, void .remove, no missing prereqs

**Step 9.3 — Exception category**
- Record: [None. This is a normal bugfix, not a device- ID/quirk/DT/build/docs exception.]

**Step 9.4 — Decision**
This tree is 7.3-rc4. The clock-measure driver is here, the missing- remove UAF has been here since v5.0, and the patch is a small, correct teardown. It meets stable criteria for this checkout.

### What it fixes and why it matters
meson_msr_probe() publishes debugfs files whose private pointers refer to devm-allocated priv / msr_table / regmap. Without a remove callback those dentries survive unbind, so a later read of measure_summary or a per-clock file uses freed memory. On 7.3 that is a real module-unload/unbind UAF on Amlogic boards that ship this IP.

### Stable rules / risk
The change is 14 lines, does not add APIs, and matches debugfs_remove() semantics already used by sibling SoC drivers. Benefit is preventing a UAF; regression risk is very low.

### Concerns
No public reproducer. Trigger is privileged debugfs/unbind. That lowers breadth, not severity. No extra commits are required on this tree.

Verification:
- [Phase 1] Parsed tags: Reviewed-by Neil Armstrong; Link to msgid 20260615091531.21964-1; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: +14 in meson-clk-measure.c; store debugfs root, set drvdata, add void remove
- [Phase 2] Pre-fix parent 67481152be2ec^: no platform_set_drvdata, no debugfs_root, no remove
- [Phase 2] clk_msr_summary_show uses msr_table->priv; meson_measure_id uses priv->regmap — UAF after unbind confirmed
- [Phase 3] git blame: debugfs create from 2b45ebef39a2c (v5.0-rc1)
- [Phase 3] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; Makefile 7.3.0-rc4
- [Phase 3] git merge-base --is-ancestor 67481152be2ec v7.3-rc1: yes; not in v7.2
- [Phase 4] b4 dig -c 67481152be2ec:
https://patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1 only, applied as-is
- [Phase 4] b4 dig -w: Armstrong, Hilman, Brunet, Blumenstingl, linux- amlogic
- [Phase 4] mbox: Armstrong Reviewed-by; dismissed sashiko probe-race as pre-existing/impossible
- [Phase 5] Kconfig MESON_CLK_MEASURE tristate default ARCH_MESON; DT compatibles in meson-gx/g12/axg/sm1/s4/a1/t7/c3 dtsi
- [Phase 5] platform_driver.remove is void (*)(struct platform_device *) in include/linux/platform_device.h:280
- [Phase 5] debugfs_remove() already IS_ERR_OR_NULL-safe (fs/debugfs/inode.c:778)
- [Phase 6] File present; no later changes on this file after the fix
- [Phase 8] Failure mode: UAF on leftover debugfs after unbind, severity HIGH
- UNVERIFIED: lore.kernel.org/stable search (HTTP 403)

**YES**

 drivers/soc/amlogic/meson-clk-measure.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/soc/amlogic/meson-clk-measure.c +14 -0
index d862e30a244ed..7ca43bcb622a2 100644
@@ -7,6 +7,7 @@
 #include <linux/of_address.h>
 #include <linux/platform_device.h>
 #include <linux/bitfield.h>
+#include <linux/err.h>
 #include <linux/seq_file.h>
 #include <linux/debugfs.h>
 #include <linux/regmap.h>
@@ -50,6 +51,7 @@ struct meson_msr_data {
 struct meson_msr {
 	struct regmap *regmap;
 	struct meson_msr_data data;
+	struct dentry *debugfs_root;
 };
 
 #define CLK_MSR_ID(__id, __name) \
@@ -952,6 +954,7 @@ static int meson_msr_probe(struct platform_device *pdev)
 	       sizeof(struct msr_reg_offset));
 
 	root = debugfs_create_dir("meson-clk-msr", NULL);
+	priv->debugfs_root = root;
 	clks = debugfs_create_dir("clks", root);
 
 	debugfs_create_file("measure_summary", 0444, root,
@@ -967,9 +970,19 @@ static int meson_msr_probe(struct platform_device *pdev)
 				    &priv->data.msr_table[i], &clk_msr_fops);
 	}
 
+	platform_set_drvdata(pdev, priv);
+
 	return 0;
 }
 
+static void meson_msr_remove(struct platform_device *pdev)
+{
+	struct meson_msr *priv = platform_get_drvdata(pdev);
+
+	if (!IS_ERR_OR_NULL(priv->debugfs_root))
+		debugfs_remove_recursive(priv->debugfs_root);
+}
+
 static const struct msr_reg_offset msr_reg_offset = {
 	.duty_val = 0x0,
 	.freq_ctrl = 0x4,
@@ -1065,6 +1078,7 @@ MODULE_DEVICE_TABLE(of, meson_msr_match_table);
 
 static struct platform_driver meson_msr_driver = {
 	.probe	= meson_msr_probe,
+	.remove = meson_msr_remove,
 	.driver = {
 		.name		= "meson_msr",
 		.of_match_table	= meson_msr_match_table,
Signature · 1 line
2.53.0
author maintainer
#289 lore raw

PATCH 1/1 RISC-V: errata: Add SiFive MAL-9092 workaround

In reply to Sasha Levin

From: Yong-Xuan Wang <[email protected]>

[ Upstream commit 148ab873d8194cb44f29474da3b4428fa2e100d1 ]

SiFive cores with MAL-9092 require fence.rw instructions around HLV/HLVX/HSV hypervisor instructions to ensure proper memory ordering when accessing guest memory.

Note that HSTATUS.HU is cleared during KVM initialization, restricting hypervisor instructions to HS-mode only. If future changes enable HSTATUS.HU for U-mode access, additional errata considerations will be needed.

---

LLM Generated explanations, may be completely bogus:

The local tree is **6.18.y** (v6.18.57). This SiFive MAL-9092 change is a hardware-errata workaround for KVM guest-memory accesses, and the code it patches is already in this series.

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

**Step 1.1: PARSE THE SUBJECT LINE**

Record: [subsystem: RISC-V errata/SiFive] [action verb: Add] [workaround for SiFive MAL-9092: fence.rw around HLV/HLVX/HSV]

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

Record:
- No Fixes: tag (expected for this review queue)
- No Reported-by: / Tested-by: / Acked-by:
- Reviewed-by: Samuel Holland <[email protected]> (SiFive, same vendor)
- `Link: https://patch.msgid.link/20260817-sifive-
[email protected]`
- Signed-off-by: Yong-Xuan Wang <[email protected]> (author, SiFive)
- Signed-off-by: Paul Walmsley <[email protected]> (RISC-V arch maintainer)
- No Cc: [email protected] (expected; not a negative signal)
- Sasha Levin SOB ignored per instructions

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

Record:
- [Bug] SiFive cores with MAL-9092 do not provide the required memory ordering around hypervisor load/store (HLV/HLVX/HSV) when touching guest memory.
- [Symptom] Wrong/stale guest instruction or data observed by the host hypervisor (KVM unprivileged guest-memory access). Not a documented oops; it is an architecture-level ordering hole.
- [Version] None stated. Paul queued it for v7.3-rc. Affected mimpid values look like 2025-10-31, 2025-12-17, and 2026-03-20 silicon.
- [Root cause] Missing fence.rw around those hypervisor instructions on specific marchid/mimpid combinations. HSTATUS.HU is left clear in KVM setup, so the workaround is HS-mode only.

**Step 1.4: DETECT HIDDEN BUG FIXES**

Record: Not a disguised cleanup. It is an explicit hardware-errata workaround, which is a stable exception category (quirks/workarounds).

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

**Step 2.1: INVENTORY THE CHANGES**

Record:
- arch/riscv/Kconfig.errata: +14 (CONFIG_ERRATA_SIFIVE_MAL_9092, depends on ERRATA_SIFIVE && 64BIT, default y)
- arch/riscv/errata/sifive/errata.c: +20 (errata_mal_9092_check_func
+ list entry)
- arch/riscv/include/asm/errata_list_vendors.h: +2/-1 (ERRATA_SIFIVE_MAL_9092 2, ERRATA_SIFIVE_NUMBER 3)
- arch/riscv/include/asm/insn-def.h: +13/-3 (ALTERNATIVE nop→fence rw,rw around HLVX_HU/HLV_W/HLV_D)
- Total: **4 files, +49/-4**. Functions: errata_mal_9092_check_func (new), errata_list[] (extended), HLV macros. Scope: single-arch surgical errata, not a refactor.

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

Record:
- Probe: previously only CIP-453/CIP-1200. After, marchid==0x8000000000000109 and mimpid in {0x19251031,0x19251217,0x19260320} also set bit ERRATA_SIFIVE_MAL_9092.
- HLV macros: previously a single hypervisor load. After, nop (or patched fence rw,rw) both before and after the instruction via the existing ALTERNATIVE framework.
- Normal KVM path (kvm_riscv_vcpu_unpriv_read), not an error path. Unaffected CPUs keep nop.

**Step 2.3: IDENTIFY THE BUG MECHANISM**

Record: [category: hardware workaround / memory-ordering errata] [mechanism: SiFive MAL-9092 omits ordering around HS-mode guest-memory hypervisor ops; alternatives patch in fence.rw only on matching CPUs]

No HSV macros exist in this tree; wrapping HLV/HLVX is the complete in- tree coverage.

**Step 2.4: ASSESS THE FIX QUALITY**

Record: Matches CIP-453/CIP-1200 style. CPU-ID gated, default y, reviewed by SiFive and queued by the arch maintainer. Regression risk is
low: extra nops on other CPUs; fences only on listed IDs. Residual
risks: insn-def.h relies on include order for ALTERNATIVE/SIFIVE_VENDOR_ID/ERRATA_SIFIVE_MAL_9092; warn_miss_errata() can warn at boot if KVM is not built-in because the only alternative sites are in KVM.

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

**Step 3.1: BLAME THE CHANGED LINES**

Record: HLV macros come from 26b73f14933e9c (2022-10-02, “riscv: KVM:
Apply insn-def to hlv encodings”). SiFive errata probe/list from 800149a77c2cb8 / bff3ff525460b4 (2021, CIP-453/CIP-1200). The hypervisor accessors have been in tree for years; the errata is new silicon, not new kernel code.

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

Record: No Fixes: tag. The defect is in the CPU, not in a prior kernel commit. Not applicable.

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

Record: Recent arch/riscv errata work is MIPS P8700, T-Head GHOSTWRITE, vendor-header split (16d18e3eaf29b). None of those is a prerequisite for this patch. Standalone v1, not patch X/Y.

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

Record: Yong-Xuan Wang is a SiFive contributor with RISC-V KVM work in this history (APLIC, Svade/Svadu). Samuel Holland (SiFive) reviewed. Not the arch maintainer; Paul Walmsley queued it.

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

Record: Needs RISC-V alternatives, ERRATA_SIFIVE, errata_list_vendors.h, and the HLV macros. All are ancestors of v6.18.57 (git merge-base --is-ancestor succeeded for 16d18e3eaf29b and 26b73f14933e9c). Applies standalone.

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

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

Record:
- b4 dig -c f36eeaaaecc2c → https://patch.msgid.link/20260817-sifive-
[email protected]
- b4 dig -a: **v1 only** (2026-08-17). No v2/v3.
- Thread: patch + Paul Walmsley “Thanks, queued for v7.3-rc.” No NAKs, no stable nomination, no reviewer risk flags.
- lore.kernel.org WebFetch returned 403; thread recovered via b4 dig -m mbox.

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

Record: b4 dig -w To/Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Samuel Holland, other SiFive engineers, linux-riscv, linux-kernel. Appropriate RISC-V maintainers were on the patch.

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

Record: No syzbot/bugzilla/user crash thread. This is a vendor errata from SiFive, not a fuzzer report. Public MAL-9092 documentation beyond the patch was not found.

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

Record: Single standalone patch ([PATCH], not [PATCH 1/N]). No follow-ups on these files after this commit on HEAD.

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

Record: Web search of stable/MAL-9092 found no stable-list discussion and no stated reason to keep it out of stable.

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

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

Record: errata_mal_9092_check_func (new); errata_list[]; macros ALT_SIFIVE_MAL_9092_FENCE, HLVX_HU, HLV_W, HLV_D. Existing sifive_errata_probe / sifive_errata_patch_func pick it up via ERRATA_SIFIVE_NUMBER.

**Step 5.2: TRACE CALLERS**

Record:
- HLV* used only in arch/riscv/kvm/vcpu_exit.c → kvm_riscv_vcpu_unpriv_read()
- Callers of that: kvm_riscv_vcpu_virtual_insn() in vcpu_insn.c (guest insn fetch when stval is 0 / 16-bit); vcpu_sbi_v01.c (SBI 0.1 SEND_IPI / remote fence hart-mask reads)
- Context: KVM VM-exit handling, not IRQ-entry core. Reachable whenever a guest traps.

**Step 5.3: TRACE CALLEES**

Record: Probe only compares archid/impid. Patching uses patch_text_nosync under text_mutex, same as CIP errata. Macros expand to ALTERNATIVE("nop", "fence rw, rw", ...).

**Step 5.4: FOLLOW THE CALL CHAIN**

Record: Userspace QEMU/KVM on RISC-V → guest trap → kvm_riscv_vcpu_unpriv_read → HLV/HLVX. Unprivileged guest code can induce those exits. Only relevant with CONFIG_KVM on matching SiFive cores.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**

Record: Same pattern as CIP-453 and CIP-1200 in this tree. No HSV macros in arch/riscv at v6.18.57 or HEAD, so nothing else to wrap here.

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

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

Record: Yes. Local tree: git describe HEAD = v6.18.57-155-gcdf239ca885b2, make kernelversion = **6.18.57**. git merge-base --is-ancestor f36eeaaaecc2c v6.18.57 failed (workaround not in 6.18.57). v6.18.57 already has HLV macros in insn-def.h, KVM vcpu_exit.c, and SiFive errata with ERRATA_SIFIVE_NUMBER 2. The hardware bug is therefore live for matching CPUs running this series.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**

Record: git diff --stat v6.18.57 f36eeaaaecc2c -- <the four files> is exactly +49/-4. Clean apply. No conflicting refactor in 6.18.57 vs this patch.

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

Record: git log --grep=MAL-9092 only finds this candidate. No earlier equivalent workaround.

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

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

Record: [arch/riscv errata + KVM guest-memory access] [IMPORTANT, not
CORE: RISC-V-specific, and only listed SiFive cores with KVM]. Wrong guest-memory ordering is still a real virt correctness issue for those systems.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**

Record: RISC-V errata and KVM are actively maintained. This is new- silicon errata on a mature HLV/KVM path, not a rewrite of a brand-new subsystem.

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

**Step 8.1: DETERMINE WHO IS AFFECTED**

Record: RISC-V + CONFIG_ERRATA_SIFIVE (selected by ARCH_SIFIVE) + CONFIG_64BIT + KVM + marchid 0x8000000000000109 with one of three mimpids. Driver/platform-specific, not universal.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**

Record: Trigger is KVM using HLV/HLVX to read guest memory (instruction emulate, SBI 0.1 hart masks). Common for any VM on those cores. Guest (typically unprivileged) can cause the VM-exit. Not a rare error-path- only bug.

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

Record: [Failure mode: missing memory fence → stale/wrong guest insn or data in the hypervisor] [Severity: HIGH — guest corruption or incorrect emulation; not a documented host panic]. Silent wrongness is worse than a WARN.

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

Record:
- Benefit: HIGH for KVM on the listed SiFive cores (correct guest-memory access).
- Risk: LOW — ~50 lines, ID-gated alternatives, same mechanism as CIP-1200 already in 6.18.57. Unaffected CPUs only gain nops.
- Ratio: benefit outweighs risk for this 6.18.y tree.

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

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Hardware errata/quirk, which stable explicitly accepts
- Real KVM guest-memory ordering bug on shipping/soon-shipping SiFive cores
- Small (+49/-4), uses existing alternatives/errata machinery
- HLV/KVM/SiFive errata all present in 6.18.57; applies cleanly
- Reviewed by SiFive, queued by RISC-V arch maintainer, no NAKs
- CPU-ID match so other RISC-V systems are not functionally changed

AGAINST:
- New Kconfig symbol (standard for RISC-V errata, default y)
- No field crash/syzbot report (vendor errata, typical)
- Possible warn_miss_errata noise if KVM is disabled on an affected CPU
- HSV mentioned in text but no HSV macros here (not a functional gap in 6.18.y)

UNRESOLVED:
- Public MAL-9092 datasheet text was not found (only the kernel patch)
- lore.kernel.org HTTP 403; discussion recovered from b4 mbox instead

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

1. Obviously correct and tested? **PASS** — ID-gated alternative fences; SiFive review; maintainer queued for 7.3-rc
2. Fixes a real bug that affects users? **PASS** — KVM guest-memory ordering on listed cores
3. Important issue? **PASS** — HIGH: incorrect hypervisor guest instruction/data reads (corruption / bad emulation)
4. Small and contained? **PASS** — 4 files, +49/-4
5. No new features or APIs? **PASS** — no userspace ABI; Kconfig is the usual errata toggle
6. Can apply to the local tree? **PASS** — clean vs v6.18.57

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**

Record: Hardware quirk/workaround (SiFive CPU errata), same class as USB/PCI quirks and existing CIP-453/CIP-1200.

**Step 9.4: DECISION**

This belongs on **this** 6.18.y tree. The HLV path has been here since 2022; 6.18.57 just lacks the fence workaround. LTS users who run KVM on these SiFive cores get a contained, ID-gated fix with the same shape as errata already in the series.

Verification:
- [Phase 1] Parsed tags: Reviewed-by Samuel Holland; Link to msgid 20260817-sifive-errata-v1-1; SOB Yong-Xuan Wang and Paul Walmsley; no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff: +49/-4 across Kconfig.errata, errata.c, errata_list_vendors.h, insn-def.h; ALTERNATIVE nop→fence around HLVX_HU/HLV_W/HLV_D
- [Phase 3] git blame v6.18.57 insn-def.h: HLV macros from 26b73f14933e9c (2022); errata framework from 2021 CIP commits
- [Phase 3] No Fixes: tag; standalone, not a series
- [Phase 3] git merge-base --is-ancestor 26b73f14933e9c v6.18.57 → yes; 16d18e3eaf29b v6.18.57 → yes
- [Phase 4] b4 dig -c f36eeaaaecc2c: lore URL found; -a: v1 only; -w:
RISC-V maintainers on To/Cc; mbox: Paul “queued for v7.3-rc”; no NAK
- [Phase 4] lore WebFetch 403; mbox used instead
- [Phase 5] HLV* only used in kvm/vcpu_exit.c; callers vcpu_insn.c and vcpu_sbi_v01.c; git grep HSV_ in arch/riscv: none
- [Phase 6] git describe HEAD: v6.18.57-155-gcdf239ca885b2; kernelversion 6.18.57
- [Phase 6] git merge-base --is-ancestor f36eeaaaecc2c v6.18.57 → not in 6.18.57; git grep MAL-9092 v6.18.57 → none
- [Phase 6] git diff --stat v6.18.57 f36eeaaaecc2c -- the four files → exact patch, clean apply
- [Phase 7] ARCH_SIFIVE selects ERRATA_SIFIVE; KVM is arch/riscv/kvm/Kconfig
- [Phase 8] Failure mode: missing fence → wrong guest memory in KVM, severity HIGH
- UNVERIFIED: full public MAL-9092 silicon manual; compile of vcpu_exit.c was inferred from include order, not by building

The workaround is small, ID-gated, and fixes a real KVM memory-ordering erratum on hardware that 6.18.y can boot. It meets the stable rules and the hardware-quirk exception.

**YES**

 arch/riscv/Kconfig.errata                    | 14 ++++++++++++++
 arch/riscv/errata/sifive/errata.c            | 20 ++++++++++++++++++++
 arch/riscv/include/asm/errata_list_vendors.h |  3 ++-
 arch/riscv/include/asm/insn-def.h            | 16 +++++++++++++---
 4 files changed, 49 insertions(+), 4 deletions(-)
arch/riscv/Kconfig.errata +14 -0
index 6f230aebd4968..65d00fb9db9d7 100644
@@ -95,6 +95,20 @@ config ERRATA_STARFIVE_JH7100
 	  Say "Y" if you want to support the BeagleV Starlight and/or
 	  StarFive VisionFive V1 boards.
 
+config ERRATA_SIFIVE_MAL_9092
+	bool "Apply SiFive HLV/HLVX/HSV fence errata"
+	depends on ERRATA_SIFIVE && 64BIT
+	default y
+	help
+	  This will apply the SiFive MAL-9092 errata to add fence.rw
+	  instructions around all HLV/HLVX/HSV instructions.
+
+	  Note: HSTATUS.HU is cleared during KVM initialization. If future
+	  changes enable HSTATUS.HU to allow hypervisor instructions in
+	  U-mode, additional errata handling may be required.
+
+	  If you don't know what to do here, say "Y".
+
 config ERRATA_THEAD
 	bool "T-HEAD errata"
 	depends on RISCV_ALTERNATIVE
arch/riscv/errata/sifive/errata.c +20 -0
index 38aac2c47845a..3025b9d6966f8 100644
@@ -51,6 +51,22 @@ static bool errata_cip_1200_check_func(unsigned long  arch_id, unsigned long imp
 	return true;
 }
 
+static bool errata_mal_9092_check_func(unsigned long  arch_id, unsigned long impid)
+{
+	/*
+	 * Affected cores:
+	 * Architecture ID: 0x8000000000000109
+	 * Implementation ID: 0x19251031, 0x19251217, 0x19260320
+	 */
+
+	if (arch_id != 0x8000000000000109)
+		return false;
+	if (impid != 0x19251031 && impid != 0x19251217 && impid != 0x19260320)
+		return false;
+
+	return true;
+}
+
 static struct errata_info_t errata_list[ERRATA_SIFIVE_NUMBER] = {
 	{
 		.name = "cip-453",
@@ -60,6 +76,10 @@ static struct errata_info_t errata_list[ERRATA_SIFIVE_NUMBER] = {
 		.name = "cip-1200",
 		.check_func = errata_cip_1200_check_func
 	},
+	{
+		.name = "mal-9092",
+		.check_func = errata_mal_9092_check_func
+	},
 };
 
 static u32 __init_or_module sifive_errata_probe(unsigned long archid,
arch/riscv/include/asm/errata_list_vendors.h +2 -1
index ec7eba3734371..c62a82f60468a 100644
@@ -11,7 +11,8 @@
 #ifdef CONFIG_ERRATA_SIFIVE
 #define	ERRATA_SIFIVE_CIP_453 0
 #define	ERRATA_SIFIVE_CIP_1200 1
-#define	ERRATA_SIFIVE_NUMBER 2
+#define	ERRATA_SIFIVE_MAL_9092 2
+#define	ERRATA_SIFIVE_NUMBER 3
 #endif
 
 #ifdef CONFIG_ERRATA_THEAD
arch/riscv/include/asm/insn-def.h +13 -3
index d29da6ccd3dd8..b1b97eab91007 100644
@@ -191,18 +191,28 @@
 	INSN_R(OPCODE_SYSTEM, FUNC3(0), FUNC7(49),		\
 	       __RD(0), RS1(gaddr), RS2(vmid))
 
+#define ALT_SIFIVE_MAL_9092_FENCE					\
+ALTERNATIVE("nop", "fence rw, rw", SIFIVE_VENDOR_ID,			\
+	    ERRATA_SIFIVE_MAL_9092, CONFIG_ERRATA_SIFIVE_MAL_9092)
+
 #define HLVX_HU(dest, addr)					\
+	ALT_SIFIVE_MAL_9092_FENCE "\n"				\
 	INSN_R(OPCODE_SYSTEM, FUNC3(4), FUNC7(50),		\
-	       RD(dest), RS1(addr), __RS2(3))
+	       RD(dest), RS1(addr), __RS2(3)) "\n"		\
+	ALT_SIFIVE_MAL_9092_FENCE
 
 #define HLV_W(dest, addr)					\
+	ALT_SIFIVE_MAL_9092_FENCE "\n"				\
 	INSN_R(OPCODE_SYSTEM, FUNC3(4), FUNC7(52),		\
-	       RD(dest), RS1(addr), __RS2(0))
+	       RD(dest), RS1(addr), __RS2(0)) "\n"		\
+	ALT_SIFIVE_MAL_9092_FENCE
 
 #ifdef CONFIG_64BIT
 #define HLV_D(dest, addr)					\
+	ALT_SIFIVE_MAL_9092_FENCE "\n"				\
 	INSN_R(OPCODE_SYSTEM, FUNC3(4), FUNC7(54),		\
-	       RD(dest), RS1(addr), __RS2(0))
+	       RD(dest), RS1(addr), __RS2(0)) "\n"		\
+	ALT_SIFIVE_MAL_9092_FENCE
 #else
 #define HLV_D(dest, addr)					\
 	__ASM_STR(.error "hlv.d requires 64-bit support")
Signature · 1 line
2.53.0
author maintainer
#290 lore raw

PATCH 1/1 mmc: rtsx_usb_sdmmc: suppress false CD after init timeout

In reply to Sasha Levin

From: Sean Rhodes <[email protected]>

[ Upstream commit 7185b6d33b170cae54fb562ead44452810b6c231 ]

Some Realtek USB SD readers with a tray keep raw SD_CD asserted when an empty tray is inserted. The MMC core then repeatedly tries to initialize non-existent media, sees command timeouts, calls ->get_cd() again, and starts the same detect cycle over.

Do not qualify media by open-coding MMC commands in ->get_cd(). Instead, let the normal MMC rescan path probe the card. If an initialization command times out before a card has been attached, suppress the raw SD_CD signal so the host can settle and the USB parent can autosuspend.

Clear the suppression only when raw SD_CD drops. On the affected tray reader, changing media requires removing and reinserting the tray, so a low CD transition is the signal that a new insertion attempt can be trusted again.

---

LLM Generated explanations, may be completely bogus:

Local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The change is a hardware quirk in drivers/mmc/host/rtsx_usb_sdmmc.c: tray-style Realtek USB readers can keep SD_CD asserted with no media, so MMC init times out, ->get_cd() still says present, and the detect cycle never stops.

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

Step 1.1: PARSE THE SUBJECT LINE
Record: **[mmc/rtsx_usb_sdmmc] [suppress] [stop false card-detect after init timeout]**
- Subsystem: mmc: rtsx_usb_sdmmc
- Verb: “suppress” (workaround / prevent a false-positive CD loop)
- Intent: do not keep reporting media present after an init timeout

Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- **Fixes:** none (expected for this review)
- **Reported-by / Tested-by / Reviewed-by / Cc: stable:** none in the commit
- **Acked-by:** Greg Kroah-Hartman <[email protected]>
- **Signed-off-by:** Sean Rhodes <[email protected]> (author); Ulf Hansson <[email protected]> (MMC maintainer)
- **Link:** none on the commit; mailing-list thread recovered via b4 dig (Phase 4)
- Notable: Greg’s Ack is on the series, not a Cc: stable tag. Absence of Fixes: / Cc: stable is not treated as a negative.

Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- **Bug:** Some Realtek USB SD readers with a tray leave raw SD_CD asserted when the tray is empty.
- **Symptom:** MMC core keeps initializing non-existent media, hits command timeouts, calls ->get_cd() again, and repeats. Cover letter (Phase 4) also reports USB reset churn and the USB parent never autosuspending.
- **Root cause:** ->get_cd() trusts raw SD_CD and does not distinguish “tray in, no card” from real media.
- **Fix approach:** Do not probe from ->get_cd(). After an init timeout with no attached mmc->card, suppress raw SD_CD until it actually drops (tray remove/reinsert).
- **Version info in the message:** none. Cover letter tested on Linux 7.0.0-27-generic, RTS5129 0bda:0129, StarLite Mk V.

Step 1.4: DETECT HIDDEN BUG FIXES
Record: **Not hidden.** It is an explicit hardware-quirk / detect-loop fix. “Do not qualify media by open-coding MMC commands in ->get_cd()” refers to dropping an RFC approach, not cleanup-for-its-own-sake.

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

Step 2.1: INVENTORY THE CHANGES
Record:
- **File:** drivers/mmc/host/rtsx_usb_sdmmc.c only
- **Scope:** +12 / −1, single-file surgical change
- **Functions / sites:**
- struct rtsx_usb_sdmmc: add bool suppress_cd
- sdmmc_get_cd(): honor/clear suppression
- sdmmc_request(): set suppression on pre-attach -ETIMEDOUT
- rtsx_usb_init_host(): initialize the flag

Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
1. **sdmmc_get_cd():** Before: val & SD_CD → card_exist = true, return 1. After: if CD is low, clear suppress_cd and report no card; if CD is high but suppress_cd is set, fall through to no_card (return 0).
2. **sdmmc_request() error path:** Before: any cmd->error re-ran sdmmc_get_cd(). After: if !mmc->card && cmd->error == -ETIMEDOUT, set suppress_cd first, then re-run get_cd() so the next detect sees no media.
3. **Init:** suppress_cd = false in rtsx_usb_init_host().

Step 2.3: IDENTIFY THE BUG MECHANISM
Record: **[Hardware workaround + logic/correctness]**
- Broken: raw SD_CD is a false present signal on empty-tray RTS5129-class readers.
- MMC core (mmc_rescan) treats get_cd()==1 as “probe now”; init times out; sdmmc_request calls get_cd() again; still 1; with MMC_CAP_NEEDS_POLL set from runtime_resume, detect is rescheduled every HZ (drivers/mmc/core/core.c out: path).
- Fix: after a timeout before mmc->card exists, lie about CD until the line drops, so rescan takes the get_cd()==0 power-off path instead of retrying init.

Step 2.4: ASSESS THE FIX QUALITY
Record:
- **Quality:** Minimal and readable. WRITE_ONCE/READ_ONCE are
justified: sdmmc_get_cd() is also called from mmc_rescan and rtsx_usb_sdmmc_runtime_resume, not only from sdmmc_request.
- **Regression risk (low–medium, contained):** a real card that times out on first init with SD_CD still high is hidden until CD drops. That matches tray hardware (remove/reinsert tray). For slot readers, CD normally drops on removal, so a retry is still “pull and reinsert.”
- **Not** a new API, not a new driver, no userspace ABI.

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

Step 3.1: BLAME THE CHANGED LINES
Record:
- Buggy if (val & SD_CD) / sdmmc_request timeout→sdmmc_get_cd()
path: **c7f6558d84afe** (“mmc: Add realtek USB sdmmc host driver”, 2014), first in **v3.16-rc1**.
- Nearby OCP updates (d2e6fb2c31a07, 6fb942b85a1ab, 2025) are unrelated to CD polarity; this tree has them.

Step 3.2: FOLLOW THE FIXES: TAG
Record: **No Fixes: tag on this commit.** Companion series patch 1/2 (483c948324a38) has Fixes: bb400d2120bd (“mfd: rtsx_usb: Defer autosuspend while card exists”); bb400d2120bd **is** an ancestor of this tree. This commit does not depend on that Fixes: target in its own diff.

Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- **4dad599b8b5d1** — drop always-on poll; set MMC_CAP_NEEDS_POLL only while runtime-resumed. That is why a stuck-high CD becomes a permanent rescan loop.
- **235b630eda072** — same author, earlier rtsx_usb interrupt-detect restore, **Cc: stable**, S3 delay from mmc_rescan. Same hardware family.
- **No follow-ups** on rtsx_usb_sdmmc.c / rtsx_usb.c after 7185b6d33b170 in this tree.
- This is **patch 2/2** of “rtsx_usb: fix tray-reader false card detect and autosuspend”. Companion **1/2** is 483c948324a38 and is already in this tree.

Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Sean Rhodes (Star Labs) is a regular contributor for this laptop hardware, not the MMC maintainer. Related work: 483c948324a38 (series 1/2), 235b630eda072 (stable-bound detect/PM). Maintainer weight is Ulf’s application + Greg’s Ack.

Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record:
- Diff is self-contained in rtsx_usb_sdmmc.c (suppress_cd only).
- Full “USB parent autosuspends with empty tray” behavior is the **matched pair** with 1/2; this commit alone still stops the init- timeout storm.
- In **this** checkout both patches are present. No missing helper/API.

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

Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 7185b6d33b170: **[PATCH v2 2/2]**
https://patch.msgid.link/1d6f22a3777e78d6232cbe7dc3aa17ded8fc32e2.1783
[email protected]
- b4 dig -a: v2 series “rtsx_usb: fix tray-reader false card detect and autosuspend” (2026-07-06). RFC (not in this mbox) open-coded MMC commands from ->get_cd(); v2 dropped that.
- Thread saved to mbox (5 messages). lore.kernel.org WebFetch returned **403**; discussion taken from b4 dig -m.
- **Ulf Hansson (2026-07-10):** queued for -next for more testing; *“Potentially we should also tag these for stable kernels, but let's get it tested a bit more in next first.”* No NAK.
- **Greg KH:** “No objection from me” + Acked-by. No stable NAK.
- Applied version is v2 (latest matching patch-id). No later unapplied revision found.

Step 4.2: CHECK WHO REVIEWED THE PATCH
Record (b4 dig -w): To Ulf Hansson; Cc Greg KH, Arnd, Ricky Wu (Realtek), Lee Jones, Roger Tseng, Dan Carpenter, Jisheng Zhang, linux- mmc, linux-kernel. MMC maintainer picked it; Greg acked the series.

Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot/bugzilla. Author is a hardware vendor. Cover letter gives a concrete repro (empty tray vs card vs S3) and three minutes of empty-tray soak with no timeout/reset churn. Severity from reporter:
detect livelock, USB reset churn, autosuspend never happens.

Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Standalone as a CD-suppression fix; series 1/2 is the parent autosuspend/cache change. This tree has both. No later fixup series found.

Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable/ fetch **403 (UNVERIFIED via lore)**. In-tree/mbox: Ulf deferred Cc: stable until -next soak. Commit landed in **mmc-v7.3** (pulled to Linus for 7.3). From July -next through **7.3-rc4** (this HEAD) there are **no follow-up fixes**. That is the soak Ulf asked for.

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

Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: sdmmc_get_cd(), sdmmc_request(), rtsx_usb_init_host(); field suppress_cd.

Step 5.2: TRACE CALLERS
Record:
- sdmmc_get_cd ← rtsx_usb_sdmmc_ops.get_cd ← mmc_rescan() / _mmc_detect_card_removed(); also sdmmc_request() on command error; also rtsx_usb_sdmmc_runtime_resume().
- sdmmc_request ← mmc_host_ops.request (MMC I/O / init commands).
- Reachable from USB card-reader use (plug, tray insert, rescan work), not a dead path.

Step 5.3: TRACE CALLEES
Record: rtsx_usb_get_card_status(), rtsx_usb_write_register() on OCP clear, mmc_request_done(). No new allocations or locks.

Step 5.4: FOLLOW THE CALL CHAIN
Record: USB parent resumes child on apparent insert → runtime_resume sets MMC_CAP_NEEDS_POLL and may mmc_detect_change → mmc_rescan → get_cd()==1 → init cmds → sdmmc_request timeout → without this patch get_cd still 1 → rescan forever. Userspace does not need a syscall; inserting an empty tray is enough.

Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: No other suppress_cd in-tree. PCI Realtek host (rtsx_pci_sdmmc.c) has its own sdmmc_get_cd; this quirk is USB-tray- specific. Same author’s prior rtsx_usb interrupt-detect restore is the closest sibling.

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

Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: **Yes.** File and functions exist. Pre-fix logic (trust raw SD_CD) has been in the driver since v3.16. This checkout is **7.3.0-rc4**; commit 7185b6d33b170 is already an ancestor of HEAD (merged via mmc-v7.3). The bug class is old; the fix is present here. That does **not** substitute for a technical-merit decision.

Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: **Clean apply on this tree.** Hunks match current sdmmc_get_cd / sdmmc_request / rtsx_usb_init_host. OCP fields already exist. WRITE_ONCE/READ_ONCE available. Companion 1/2 already here.

Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No alternate fix for empty-tray false CD. 4dad599b8b5d1 made poll runtime-gated (necessary context, not a substitute). No later revert.

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

Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: **MMC host driver** (CONFIG_MMC_REALTEK_USB, RTS5129/39 USB readers) on top of MISC_RTSX_USB. **IMPORTANT** for affected laptops (very common Realtek USB readers), not core mm/VFS. Peripheral relative to the whole kernel, but not staging.

Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mature driver (2014) with occasional PM/detect/OCP work. Not a newly added subsystem.

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

Step 8.1: DETERMINE WHO IS AFFECTED
Record: **Driver-specific / config-specific** (CONFIG_MMC_REALTEK_USB). Strongest hit: tray-style RTS5129 (0bda:0129) as on Star Labs StarLite Mk V; other rtsx USB readers share get_cd. Slot-only devices keep working as long as CD drops on removal.

Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Insert empty tray (or leave tray in with no card) so SD_CD stays high. Common on that hardware. Not a userspace exploit path. Timing is deterministic, not a thin race.

Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- Repeated MMC init + command timeouts
- MMC_CAP_NEEDS_POLL rescan every second
- USB reset churn (author, cover letter)
- USB parent stuck out of autosuspend (power)
- Related earlier bug: long S3 entry while mmc_rescan is frozen
- **Severity: HIGH** for affected machines (livelock of detect + USB churn + PM), not a panic/UAF. Not LOW: the host never settles.

Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- **Benefit:** High for tray-reader laptops; stops detect storm and enables autosuspend (with 1/2, already here).
- **Risk:** Low. +12/−1, local flag, no locking change beyond WRITE_ONCE. Residual risk is “timeout on first init hides a present card until CD drops,” which is the intended tray semantics.
- **Ratio:** Benefit > risk.

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

Step 9.1: COMPILE THE EVIDENCE

**FOR backporting to this tree:**
- Real hardware bug on shipping RTS5129 tray readers; vendor-tested (insert, empty tray soak, S3).
- Failure is a detect livelock plus USB reset churn / failed autosuspend — user-visible stability and power, not cosmetics.
- Hardware-quirk class (false CD), which stable explicitly takes.
- Tiny, obviously structured, no new API.
- Driver and buggy get_cd path have existed since v3.16; this tree has that code.
- Greg Ack; MMC maintainer applied; Ulf only delayed stable tagging for -next soak — now past -next and through 7.3-rc4 with **zero** follow- up fixes.
- Same author already got a related rtsx_usb detect/PM fix into stable (235b630eda072).

**AGAINST:**
- Not a KASAN/crash/CVE.
- Ulf did not Cc: stable at merge (wanted -next first).
- Series 2/2: full autosuspend story wants 1/2 (already in this tree).
- Possible hide-until-reinsert if a real card times out during first init.

**UNRESOLVED:**
- Could not query lore.kernel.org/stable (HTTP 403). Relied on b4 mbox
+ git history instead.

Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? **PASS** — v2 after RFC, runtime log on StarLite Mk V, Acked by Greg, merged by Ulf, no regressing follow-ups through 7.3-rc4.
2. Fixes a real bug that affects users? **PASS** — empty-tray false CD, observed detect loop and USB churn.
3. Important issue? **PASS** — detect livelock / USB reset churn / PM stuck (HIGH), hardware quirk.
4. Small and contained? **PASS** — one file, +12/−1.
5. No new features or APIs? **PASS** — internal flag only.
6. Can apply to the local tree? **PASS** — file/functions present; companion 1/2 present; applies cleanly.

Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: **Hardware quirk / workaround** for broken CD on tray readers (same bucket as USB/PCI quirks).

Step 9.4: MAKE YOUR DECISION
This tree is 7.3.0-rc4. The driver and false-CD loop exist here; the patch is small, tested, and a real hardware workaround. Ulf’s “test in -next first” condition has been met (no revert, no fixup). It belongs in this tree on technical merit.

**What it solves for users of this tree:** empty-tray Realtek USB SD readers no longer hammer MMC init and USB, so the host can settle and autosuspend.

**Risk vs benefit:** low code risk vs high impact on that hardware.

**Concerns:** none that block this tree; 1/2 is already here; no missing prerequisites.

Verification:
- [Phase 1] Subject/tags: suppress false CD; Acked-by Greg KH; SOB Sean Rhodes + Ulf Hansson; no Fixes/Reported-by/Cc:stable
- [Phase 1] Body: empty-tray SD_CD stuck high → init timeout → get_cd loop
- [Phase 2] Diff: +12/−1 in rtsx_usb_sdmmc.c; suppress_cd; timeout in sdmmc_request when !mmc->card
- [Phase 2] Confirmed mmc_rescan uses ops->get_cd and reschedules on MMC_CAP_NEEDS_POLL (core.c ~2284 and 2334–2336)
- [Phase 2] Confirmed runtime_resume sets MMC_CAP_NEEDS_POLL and calls sdmmc_get_cd
- [Phase 3] git blame on parent: CD logic from c7f6558d84afe (v3.16-rc1)
- [Phase 3] git merge-base --is-ancestor 7185b6d33b170 HEAD → yes; companion 483c948324a38 is parent
- [Phase 3] No follow-ups on these files after the commit
- [Phase 3] Related stable-bound detect fix: 235b630eda072
- [Phase 3] bb400d2120bd is in this tree (companion Fixes target)
- [Phase 4] b4 dig -c/-a/-w/-m: v2 series, Ulf “potentially stable after -next”, Greg Ack, no NAK
- [Phase 4] lore WebFetch 403; used mbox + openwall/lkml snippets instead
- [Phase 4] Cover letter: RTS5129 0bda:0129, empty tray → runtime_status=suspended, no timeout/reset churn
- [Phase 5] Callers of sdmmc_get_cd: ops.get_cd, sdmmc_request, runtime_resume
- [Phase 6] make kernelversion / git describe HEAD: 7.3.0-rc4 / v7.3-rc4-27-gf0100363d8c37
- [Phase 6] Buggy get_cd present; patch applies; no alternate fix
- [Phase 7] CONFIG_MMC_REALTEK_USB — RTS5129/39 USB SD/MMC
- [Phase 8] Failure: detect livelock + USB churn + failed autosuspend, severity HIGH for that hardware
- UNVERIFIED: lore.kernel.org/stable search (HTTP 403)

**YES**

 drivers/mmc/host/rtsx_usb_sdmmc.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/mmc/host/rtsx_usb_sdmmc.c +12 -1
index 84674659a84d4..bf37fab233cf0 100644
@@ -44,6 +44,7 @@ struct rtsx_usb_sdmmc {
 	bool			double_clk;
 	bool			host_removal;
 	bool			card_exist;
+	bool			suppress_cd;
 	bool			initial_mode;
 	bool			ddr_mode;
 
@@ -774,6 +775,7 @@ static int sdmmc_get_cd(struct mmc_host *mmc)
 	struct rtsx_ucr *ucr = host->ucr;
 	int err;
 	u16 val;
+	bool cd;
 
 	if (host->host_removal)
 		return -ENOMEDIUM;
@@ -791,8 +793,14 @@ static int sdmmc_get_cd(struct mmc_host *mmc)
 
 	/* get OCP status */
 	host->ocp_stat = (val >> 4) & 0x03;
+	cd = val & SD_CD;
 
-	if (val & SD_CD) {
+	if (!cd) {
+		WRITE_ONCE(host->suppress_cd, false);
+		goto no_card;
+	}
+
+	if (!READ_ONCE(host->suppress_cd)) {
 		host->card_exist = true;
 		return 1;
 	}
@@ -874,6 +882,8 @@ static void sdmmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
 		 * detect card when fail to update card existence state and
 		 * speed up card removal when retry
 		 */
+		if (!mmc->card && cmd->error == -ETIMEDOUT)
+			WRITE_ONCE(host->suppress_cd, true);
 		sdmmc_get_cd(mmc);
 		dev_dbg(sdmmc_dev(host), "cmd->error = %d\n", cmd->error);
 	}
@@ -1359,6 +1369,7 @@ static void rtsx_usb_init_host(struct rtsx_usb_sdmmc *host)
 
 	host->power_mode = MMC_POWER_OFF;
 	host->ocp_stat = 0;
+	host->suppress_cd = false;
 }
 
 static int rtsx_usb_sdmmc_drv_probe(struct platform_device *pdev)
Signature · 1 line
2.53.0
author maintainer
#291 lore raw

PATCH 1/1 wifi: rtw89: wow: only WiFi 6 chips initialize RF registers in WoWLAN mode

In reply to Sasha Levin

From: Chih-Kang Chang <[email protected]>

[ Upstream commit dbff9040587e9bd6d3ee337315971957f9f76612 ]

Only the WiFi 6 chips need to initialize RF register when WoWLAN download FW for some power save issue. Applying the same initialization flow to WiFi 7 chips might trigger the error
'RF parameters exceed size. path=1, idx=1500.'.

This happens because normal mode uses rtw89_phy_config_rf_reg_v1(), which skips registers with addresses below 0x100. However, WoWLAN mode uses rtw89_phy_config_rf_reg_noio(), and WiFi 7 chips do not satisfy the rtw89_chip_rf_v1() condition. As a result, more RF registers are configured, causing the size overflow error.

---

LLM Generated explanations, may be completely bogus:

The local checkout is **Linux 7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37, origin/master). This tree already contains rtw89 WiFi 7 (RTL8922A/RTL8922D) with WoWLAN, which is the path the overflow hits.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**
- Record: [wifi: rtw89: wow] [only … initialize] [gate WoWLAN RF register init to WiFi 6 / CHIP_AX]
- Subsystem: Realtek rtw89 WoWLAN. The verb is a restriction (“only … initialize”), i.e. stop a wrong flow on WiFi 7.

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Record:
- Signed-off-by: Chih-Kang Chang <[email protected]> (author)
- Signed-off-by: Ping-Ke Shih <[email protected]> (rtw89 maintainer; applied to rtw-next)
- `Link:

    https://patch.msgid.link/[email protected]`

- No Fixes:, no Reported-by:, no Tested-by:, no Reviewed-by:, no Cc: stable (absence is expected)
- Ignore pipeline Signed-off-by: Sasha Levin / [Upstream commit …] if present — not in the git object

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Record:
- **Bug:** WoWLAN firmware swap always calls rtw89_phy_init_rf_reg(rtwdev, true). That is needed only on WiFi 6 (AX) for a power-save issue.
- **Symptom:** On WiFi 7, `'RF parameters exceed size. path=1,

    idx=1500.'`
  - **Root cause:** Normal mode uses `rtw89_phy_config_rf_reg_v1()`,
    which skips RF addresses `< 0x100`. WoWLAN uses
    `rtw89_phy_config_rf_reg_noio()`, which skips `< 0x100` only when
    `rtw89_chip_rf_v1()` is true. WiFi 7 chips use `write_rf_v2`/`v3`,
    so they do not skip those registers, fill more than 1500 H2C slots,
    and hit the size cap.

- **Version info:** none in the message.

**Step 1.4: DETECT HIDDEN BUG FIXES**
- Record: Not hidden. It is an explicit chip-generation bug fix (wrong RF init on BE causing H2C RF table overflow).

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES**
- Record: drivers/net/wireless/realtek/rtw89/wow.c — 2 insertions, 1 deletion. Function: rtw89_wow_swap_fw(). Scope: single-file, one- call gate.

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
- Record: After WoWLAN/normal FW download, the code **always** collected RF regs with noio=true and sent them via H2C. After the fix, that runs **only** if chip->chip_gen == RTW89_CHIP_AX. WiFi 7 (RTW89_CHIP_BE) skips it. BE already has a separate restore:
rtw89_phy_rfk_pre_ntfy_and_wait() later in the same function.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
- Record: **Logic / hardware-generation mismatch**, not a kernel buffer overwrite.
- Store path in rtw89_phy_cofig_rf_reg_store():
- RTW89_H2C_RF_PAGE_SIZE == 500, RTW89_H2C_RF_PAGE_NUM == 3 → cap **1500**
- idx=1500 ⇒ page = 3 >= 3 → rtw89_warn(...) and **drop** the register (no OOB write)
- Extra entries are dropped; 1500 params are still sent. Result:
warning spam + incomplete RF programming of WoWLAN FW.
- Category: hardware/chip-gen workaround + functional correctness of suspend/WoWLAN.

**Step 2.4: ASSESS THE FIX QUALITY**
- Record: Obviously correct. chip is already rtwdev->chip in this function; RTW89_CHIP_AX is the existing gen enum. AX still gets the power-save RF init; BE does not. Regression risk is low: BE never needed this path (vendor statement + separate RFK notify). No API/data-structure change.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**
- Record: Unconditional rtw89_phy_init_rf_reg(rtwdev, true) came from 19e28c7fcc740 (“wifi: rtw89: add WoWLAN function support”, 2022-10-27, in v6.2-rc1). The noio collector is d9112042d994 (same era). The bug becomes real when WiFi 7 chips (empty rf_table, firmware rf_radio[] elements, write_rf not v1) run that WoWLAN path. RTL8922A chip info: c0a04552e36e1 (~v6.8). RTL8922D is newer (2026).

**Step 3.2: FOLLOW THE FIXES: TAG**
- Record: No Fixes: tag. Not applicable.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
- Record: Nearby wow.c work is MLO ARP, 8922D interrupt disable, cipher messages — independent. This is **10/10** of a mixed rtw-next series, not a dependent chain. Cover letter: independent MAC/FW/PCI/WoWLAN items; this patch does not need 01–09.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
- Record: Chih-Kang Chang is a regular Realtek rtw89 contributor. Ping- Ke Shih is the **rtw89 maintainer** (MAINTAINERS) and applied the series to rtw-next.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
- Record: Standalone. Needs only chip->chip_gen / RTW89_CHIP_AX (present since f698afa7ce374, 2023) and rtw89_phy_init_rf_reg(). Both exist in this tree. No new helpers.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
- Record: b4 dig -c dbff9040587e9 →
https://patch.msgid.link/[email protected]
- Series: [PATCH rtw-next 00/10] wifi: rtw89: update some MAC, FW and WoWLAN settings
- This commit is **10/10**. b4 dig -a: only **v1**.
- Cover letter does not call out this patch as the headline fix (it highlights 4/10 scan and 7/10 typo). No reviewer NAK. Maintainer applied all 10 to rtw-next (mbox reply 2026-07-03).
- No Cc: stable in the thread.

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
- Record: b4 dig -w To/Cc: Ping-Ke Shih, linux-wireless, gary.chang, timlee, dian_syuan0116, kevin_yang (all Realtek rtw89). No external Reviewed-by. Maintainer SOB + apply is the review signal.

**Step 4.3: SEARCH FOR THE BUG REPORT**
- Record: No public bugzilla/syzbot. The message quotes a concrete driver warning (path=1, idx=1500), which matches the H2C cap. Vendor-observed, not a user mailing-list report.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
- Record: Series mates (MAC TX complete, chip version to FW, UDM1 log level, packet offload drop, sniffer RX filter, PCI phy error, LPS MLO link ID, MLO ARP) are **not** prerequisites of this 2-line gate.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
- Record: **UNVERIFIED.** lore.kernel.org returned HTTP 403 for /stable/ and thread HTML. mbox from b4 dig -m had no stable discussion.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: IDENTIFY KEY FUNCTIONS**
- Record: rtw89_wow_swap_fw(); callees of interest:
rtw89_phy_init_rf_reg(), rtw89_phy_config_rf_reg_noio(), rtw89_phy_cofig_rf_reg_store().

**Step 5.2: TRACE CALLERS**
- Record: rtw89_wow_swap_fw() is called from rtw89_wow_enable() (wow=true) and rtw89_wow_disable() (wow=false). Those are called from rtw89_wow_suspend() / resume. rtw89_ops_suspend() in mac80211.c is the mac80211 suspend op (CONFIG_PM). Reachable from userspace suspend with WoWLAN (NetworkManager magic- packet/disconnect/net-detect). Not a syscall crash path; it is a common laptop suspend path.

**Step 5.3: TRACE CALLEES**
- Record: rtw89_phy_init_rf_reg(noio=true) walks firmware or chip RF tables and stores H2C pages (no MMIO). Overflow is handled as warn+drop, then rtw89_phy_config_rf_reg_fw() still sends up to 1500 entries.

**Step 5.4: FOLLOW THE CALL CHAIN**
- Record: userspace suspend → ieee80211 suspend → rtw89_ops_suspend → rtw89_wow_suspend → rtw89_wow_enable → rtw89_wow_swap_fw → RF init. **Yes, reachable** on RTL8922A/D with WoWLAN enabled. Both chips have wowlan_stub in this tree.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
- Record: Same function already special-cases BE (rtw89_phy_rfk_pre_ntfy_and_wait) and AX (disable_intr_for_dlfw). This gate matches that pattern. rtw89_chip_rf_v1() is true only for 8852B/BT/C and 8851B (write_rf_v1). 8852A is AX but not rf_v1 — still correctly keeps RF init because the new check is CHIP_AX, not chip_rf_v1().

---

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
- Record: **Yes, the affected stack exists.** This tree has RTW89_CHIP_BE chips (rtw8922a.c, rtw8922d.c) with WoWLAN stubs, firmware rf_radio[] tables, write_rf v2/v3 (so rtw89_chip_rf_v1() is false), and rtw89_wow_swap_fw().
- The **unconditional** call is already replaced here by commit dbff9040587e9 (ancestor of HEAD). That is this tree’s current code, not a reason to treat the bug as fictional: without this change, BE WoWLAN still hits the 1500-entry cap.
- Bug introduced relative to this codebase: WoWLAN RF collect since v6.2; overflow on BE once WiFi 7 + firmware radio tables are used (8922A from ~6.8, 8922D in this 7.3 cycle).

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
- Record: On **this** 7.3-rc4 tree the hunk is already applied; a re- apply would be empty. Context (chip, RTW89_CHIP_AX, rtw89_phy_init_rf_reg) matches. Expected difficulty if it were
missing: **clean apply**.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
- Record: This is the fix. Follow-ups on wow.c (73aecc221e7df cipher debug, d946a4e031167 scan V3) do not replace it. No revert.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
- Record: [drivers/net/wireless/realtek/rtw89] — **IMPORTANT** (shipping WiFi 6/7, not core mm/VFS). Not staging.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
- Record: Actively developed (WiFi 7 8922D, MLO WoWLAN). Maintainer:
Ping-Ke Shih. Mature AX WoWLAN plus newer BE support.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: DETERMINE WHO IS AFFECTED**
- Record: **Driver-specific / config-specific:** CONFIG_PM + rtw89 + RTL8922A or RTL8922D (and any other BE chip using this wow path). AX users unchanged.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
- Record: Suspend/resume with WoWLAN (or wow FW swap on resume). Common on laptops. Unprivileged users cannot directly invoke it; suspend typically needs policy/login, but it is a normal user flow. Not a race.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
- Record: **MEDIUM (functional HIGH for affected NICs).** Not a KASAN/UAF/panic. Verified: no kernel OOB write. User-visible:
rtw89_warn (can repeat per extra register) and truncated RF H2C, so WoWLAN/power-save RF state on WiFi 7 can be wrong (failed wake or bad RF after resume). That is a real suspend bug, not cosmetic-only.

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
- Record: **Benefit: high for BE WoWLAN users in this tree. Risk: very low** (2 lines, existing enum, AX path unchanged). Ratio favors applying it.

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Real, vendor-documented overflow of the 1500-slot RF H2C table on WiFi 7 WoWLAN (idx=1500 = 3*500).
- This tree **has** BE chips with WoWLAN; the wrong noio path is used because they are not rf_v1.
- 2-line, obviously correct gen check; AX still initialized; BE already uses RFK pre-notify.
- Maintainer SOB and applied to rtw-next; self-contained despite 10/10 series.
- Typical stable-class hardware/suspend workaround.

AGAINST:
- Not a crash, UAF, deadlock, or security bug.
- No Fixes: / public user reports / syzbot.
- Warning-and-drop, not memory corruption.
- Only rtw89 WiFi 7 + WoWLAN.

UNRESOLVED:
- lore /stable/ search 403; no confirmation of prior stable discussion.
- Exact user-visible radio failure beyond the warning is vendor- described, not independently reproduced here.

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — mechanism matches code; maintainer applied.
2. Fixes a real bug that affects users? **PASS** — BE WoWLAN RF H2C overflow/truncation on suspend.
3. Important issue? **PASS** (medium-high functional / suspend) — not panic, but broken WoWLAN RF on shipping WiFi 7 is important for this tree.
4. Small and contained? **PASS** — 2 lines, one function.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — context exists; already present as dbff9040587e9.

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
- Record: Hardware workaround / chip-generation quirk (do not run AX- only RF init on BE). Qualifies under quirks/workarounds.

**Step 9.4: MAKE YOUR DECISION**
This tree is 7.3-rc4 with RTL8922A/8922D WoWLAN. The bug is real here:
firmware RF tables plus rtw89_phy_config_rf_reg_noio() without the v1 < 0x100 skip overflow the 1500-entry H2C buffer and mis-init RF during wow FW swap. The fix is a one-condition guard, no series dependency, no new API. Benefit outweighs risk.

---

## What the commit solves for this tree

On WiFi 7 rtw89, WoWLAN firmware download used the WiFi 6 “collect RF regs, no MMIO” path. BE chips are not rf_v1, so addresses < 0x100 were included, curr_idx hit 1500, and the driver warned and dropped the rest. Suspend/WoWLAN RF programming was incomplete. Gating on RTW89_CHIP_AX restores the intended split: AX keeps the power-save RF init; BE keeps RFK notify only.

It meets stable rules: small, correct, no features, real user-facing suspend bug on hardware this tree supports. Risk is negligible.

## Verification
- [Phase 1] Parsed git object dbff9040587e9: SOB Chang + Shih, Link msgid …44808-11…; no Fixes/Reported-by/Cc: stable
- [Phase 2] Diff: wow.c rtw89_wow_swap_fw: wrap rtw89_phy_init_rf_reg(rtwdev, true) in chip->chip_gen == RTW89_CHIP_AX
- [Phase 2] fw.h: RTW89_H2C_RF_PAGE_SIZE 500, PAGE_NUM 3 → 1500; phy.c warns at page >= PAGE_NUM without OOB store
- [Phase 2] rtw89_chip_rf_v1() is write_rf == rtw89_phy_write_rf_v1; 8922A=v2, 8922D=v3; 8852B/C/BT/8851B=v1
- [Phase 3] blame: RF init from 19e28c7fcc740 (v6.2-rc1); chip_gen from f698afa7ce374; 8922A c0a04552e36e1
- [Phase 3] git merge-base --is-ancestor dbff9040587e9 HEAD → yes (already in this 7.3-rc4 tree)
- [Phase 3] Series 0819de0fd2906..dbff9040587e9 is 10 independent rtw- next patches; this one only touches wow.c
- [Phase 4] b4 dig -c dbff9040587e9: lore thread found; -a v1 only; -w linux-wireless + Realtek; -m 12 msgs, maintainer “10 patch(es) applied”
- [Phase 4] WebFetch lore HTML: 403; stable-list search UNVERIFIED
- [Phase 5] Call chain: rtw89_ops_suspend → rtw89_wow_suspend → rtw89_wow_enable → rtw89_wow_swap_fw; 8922A/D have wowlan_stub
- [Phase 5] BE path already calls rtw89_phy_rfk_pre_ntfy_and_wait in the same function
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; VERSION=7 PATCHLEVEL=3 EXTRAVERSION=-rc4
- [Phase 6] Current wow.c already has the AX gate (this commit)
- [Phase 7] MAINTAINERS: Ping-Ke Shih maintains rtw89
- [Phase 8] Failure mode verified as warn+truncate, not kernel memory overflow; severity MEDIUM/HIGH functional for BE WoWLAN
- UNVERIFIED: independent reproduction of failed wake; stable@ discussion (lore 403)

**YES**

 drivers/net/wireless/realtek/rtw89/wow.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw89/wow.c +2 -1
index f6cdbc15dcc4a..90046d6f620ef 100644
@@ -1299,7 +1299,8 @@ static int rtw89_wow_swap_fw(struct rtw89_dev *rtwdev, bool wow)
 	if (disable_intr_for_dlfw)
 		rtw89_hci_enable_intr(rtwdev);
 
-	rtw89_phy_init_rf_reg(rtwdev, true);
+	if (chip->chip_gen == RTW89_CHIP_AX)
+		rtw89_phy_init_rf_reg(rtwdev, true);
 
 	ret = rtw89_fw_h2c_role_maintain(rtwdev, rtwvif_link, rtwsta_link,
 					 RTW89_ROLE_FW_RESTORE);
Signature · 1 line
2.53.0
author maintainer
#292 lore raw

PATCH 1/1 remoteproc: Force shutdown during device removal

In reply to Sasha Levin

From: Bjorn Andersson <[email protected]>

[ Upstream commit 4059c64d78b5d543dabae332922e763b4c95c79e ]

rproc_del() is subjected to the reference counted shutdown path, as such a remoteproc with more than one reference will be left running as its resources are released underneath it.

Refactor the shutdown path such that the reference count value is ignored when called from rproc_del().

---

LLM Generated explanations, may be completely bogus:

The local checkout is mainline **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The change is a real rmmod/unbind crash
fix: rproc_del() used the refcounted shutdown path, so a remoteproc with power > 1 kept running while its driver tore resources down underneath it.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**
- Record: **[remoteproc] [Force] Force shutdown during device removal**
- Subsystem: remoteproc. Verb “Force” is a correctness/safety change:
shutdown must happen on device removal even if extra power refs remain.

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
- Record:
- **No Fixes: tag** (expected for this review pipeline; not a negative)
- **No Cc: [email protected]** (same)
- **No Reported-by: / Tested-by:**
- **Reviewed-by:** Pradnya Dahiwale, Konrad Dybcio (Qualcomm remoteproc reviewers)
- **Assisted-by:** OpenCode:GPT-5.5 (LLM-assisted; still maintainer- authored and reviewed)
- **Link:** `https://lore.kernel.org/r/20260723-rproc-rmmod-not-

    [email protected]`

- **Signed-off-by:** Bjorn Andersson (author and remoteproc maintainer). Ignore any Sasha Levin SOB.
- Series identity is in the lore Message-Id: **v1-3** of rproc-rmmod- not-crashing.

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
- Record:
- **Bug:** rproc_del() calls the refcounted rproc_shutdown() path. If rproc->power > 1, shutdown only decrements the counter and leaves the processor running.
- **Symptom:** Driver removal continues: debugfs teardown, list removal, device_del(), char-dev removal, then the platform remove() unmaps firmware memory / IOMMU / power domains under a still-running coprocessor. Cover letter: “unmap memory and shut down critical resources under its feet.”
- **Root cause:** Removal is bound to the user-facing power-refcount API, which is intentionally a no-op until the last user.
- **Version info:** None in the message. The TODO this replaces dates

    to 2016 (`ddf711872c9d2`, v4.9-rc1).

- **Fix:** Internal __rproc_shutdown(rproc, force); rproc_del() uses force=true and ignores the remaining refcount.

**Step 1.4: DETECT HIDDEN BUG FIXES**
- Record: **Not hidden.** The subject/body describe a crash/UAF-class removal bug. “Refactor the shutdown path” is only the mechanism (extract a force helper). Cover letter of `[PATCH 0/3] remoteproc:
Improve removal of remoteproc drivers` states the same failure for three rmmod cases (crash state, crash-handler race, extra power ref). This commit is the third of those.

---

## PHASE 2: DIFF ANALYSIS

**Step 2.1: INVENTORY THE CHANGES**
- Record:
- **File:** drivers/remoteproc/remoteproc_core.c only (+31 / -26)
- **Functions:** rproc_shutdown body moved to __rproc_shutdown(struct rproc *rproc, bool force); rproc_shutdown() becomes a force=false wrapper; rproc_del() calls __rproc_shutdown(rproc, true) instead of rproc_shutdown()
- **Scope:** Single-file, surgical. No API/struct/header changes.

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
- Record:
- **Before (rproc_shutdown):** lock → require RUNNING/ATTACHED/CRASHED → atomic_dec_and_test(&rproc->power) → if not last user, unlock and return without stopping → else rproc_stop + resource cleanup + unprepare + IOMMU disable + free cached resource table.
- **After:** same path unless force. With force, stop/cleanup still runs even if the decrement did not hit zero.
- **rproc_shutdown() users** (sysfs, cdev, client drivers) still use force=false; behavior unchanged.
- **rproc_del():** was rproc_shutdown() (and a TODO “make sure this works with rproc->power > 1”); now forced stop. Affected path is **device removal / module unload**, not the normal stop API.

**Step 2.3: IDENTIFY THE BUG MECHANISM**
- Record:
- **Category:** logic/correctness on the removal path, with UAF / use- after-unmap / crash consequences.
- **Mechanism:** Power refs are taken by rproc_boot() (atomic_inc_return(&rproc->power) > 1 skips a second boot). Auto- boot plus a client (ath11k/ath12k, TI PRU ethernet, MediaTek MDP/vcodec, etc.) or sysfs/cdev start yields power > 1. rproc_del() then left the DSP/modem running while qcom_pas_remove() (verified) does rproc_del() then qcom_pas_unassign_memory_region() and subdev teardown.

**Step 2.4: ASSESS THE FIX QUALITY**
- Record:
- **Quality:** Obviously correct. Forced stop on deletion is what the 2016 TODO asked for. Existing state check still avoids stopping an already-offline rproc. rproc_stop failure still re-increments power (same as before).
- **Regression risk:** Low. Force-stop while clients still hold refs is intentional: the rproc device is going away; leaving firmware running during unmap is worse. Residual power after force-stop is
harmless: a later rproc_shutdown() hits the state check (OFFLINE) and returns -EINVAL **before** another decrement.
- **Review note (verified in mbox):** Konrad asked whether non-forced rproc_shutdown() should also check rproc->deleting. Bjorn explained the mutex + state machine already serializes that race; v1 was applied unchanged. No NAK.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**
- Record:
- Shutdown-on-delete + TODO introduced in **ddf711872c9d2**

    (“remoteproc: Introduce auto-boot flag”, 2016-08-17, **v4.9-rc1**).
    Originally `if (rproc->auto_boot) rproc_shutdown()`.
  - Recovery-path copy of the same TODO was later removed in
    **`7e83cab824a86`** (v4.13-rc1) by switching recovery to
    `rproc_stop()`/`rproc_start()`. The **`rproc_del()` TODO remained
    until this commit**.

- Bug is long-standing, not new-in-7.3 code.

**Step 3.2: FOLLOW THE FIXES: TAG**
- Record: **No Fixes: tag on this commit.** Related series:
- **1/3 2482ca875ef59** “Allow shutdown of crashed processors” —

    `Fixes: 5e6a0e05270e` (2022). Present in this tree.
  - **2/3 `74ee3b2f57674`** “Prevent crash handling to race with
    rproc_del()” — `Fixes: 8afd519c3470`. Present in this tree.

- This 3/3 commit is **4059c64d78b5d** (2026-07-27).

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
- Record: Immediate parents are 1/3 and 2/3 (same author, same lore series). Follow-ups on remoteproc_core.c after 3/3: **none**. Standalone for the power > 1 bug; 1/3 and 2/3 fix other rmmod crash variants.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
- Record: Bjorn Andersson is the remoteproc maintainer (`Signed-off-by:
Bjorn Andersson <[email protected]>` on apply). Same-week series is exactly these three rmmod-crash fixes.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
- Record:
- 3/3 does **not** require 2/3’s deleting flag or cancel_work_sync (those are adjacent context in rproc_del()).
- 3/3 does **not** add the RPROC_CRASHED state check; that is 1/3. Forced shutdown of a **running** rproc with extra refs works without 1/3.
- **In this tree:** 1/3 and 2/3 are already ancestors, so no missing prereqs here. Can apply standalone.

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
- Record:
- b4 dig -c 4059c64d78b5d → https://patch.msgid.link/20260723-rproc-

    [email protected]

- b4 dig -a: **v1 only** (no v2/v3). Applied as submitted.
- Cover letter (mbox msg 0): three rmmod failure modes; this patch is “bump the refcount … rproc_shutdown() becomes a nop, again leaving the remoteproc running”.
- Konrad R-b, then a follow-up question about deleting; Bjorn replied with the mutex/state analysis; Pradnya R-b; applied 2026-07-27.
- **No NAK. No reviewer request for Cc: stable.** Maintainer:
“there's more dragons hidden in these code paths” but still applied this as a real fix.

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
- Record (b4 dig -w): To/Cc included Bjorn Andersson, Mathieu Poirier, Shengjiu Wang, Fernando Guzman Lugo, Ohad Ben-Cohen, linux- remoteproc@, linux-arm-msm@, linux-kernel@. Kernel.org lore 403’d for WebFetch; thread recovered via b4 dig -m.

**Step 4.3: SEARCH FOR THE BUG REPORT**
- Record: No syzbot/bugzilla Reported-by. Evidence is maintainer analysis plus the decade-old TODO. Cover letter describes a concrete rmmod trigger. No separate user bug report found.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
- Record: Series of 3, all applied. 1/3 crashed-state stop; 2/3 crash- work vs rproc_del(); 3/3 force stop on extra refs. 3/3 is self- contained for its bug. In this tree the other two are already present.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
- Record: lore.kernel.org/stable search for this subject did not turn up a stable-specific discussion. WebFetch of lore returned 403; WebSearch snippets were unrelated. **No evidence this was rejected for stable.**

---

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1: IDENTIFY KEY FUNCTIONS**
- Record: __rproc_shutdown() (new static), rproc_shutdown(), rproc_del(). Indirectly rproc_stop(), rproc_resource_cleanup(), rproc_unprepare_device(), rproc_disable_iommu().

**Step 5.2: TRACE CALLERS**
- Record:
- rproc_del(): every remoteproc platform remove()

    (`qcom_q6v5_pas`, `qcom_q6v5_mss`, `qcom_wcnss`, `stm32_rproc`,
    `mtk_scp`, `xlnx_r5_remoteproc`, …).

- rproc_shutdown(): sysfs state, cdev stop/release, and clients (ath11k/ath12k AHB, TI ICSSG/ICSSM, wkup_m3_ipc, st_fdma, MediaTek vcodec, etc.). Those keep force=false.
- Context: process context, driver unbind / rmmod, not IRQ.

**Step 5.3: TRACE CALLEES**
- Record: Forced path still rproc_stop() (subdevices, resource table reset, ops->stop, unprepare, RPROC_OFFLINE) then resource cleanup, unprepare, IOMMU disable, kfree(cached_table). Same teardown as a last-user shutdown, just not gated on refcount.

**Step 5.4: FOLLOW THE CALL CHAIN**
- Record: Userspace-reachable via rmmod / sysfs unbind of a remoteproc driver while another rproc_boot() holder exists (Wi-Fi firmware on Qualcomm PAS is a documented client). Unprivileged trigger depends on whether module unload is allowed; the bug is real on developer and production unbind paths.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
- Record: stm32_rproc_remove() already does an extra rproc_shutdown() if power > 0 before rproc_del(), which can happen to drain one extra ref. Qualcomm PAS remove() only calls rproc_del() then unassigns memory — that is the crashing pattern this fixes in core so every driver gets it.

---

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
- Record: **Yes.** __rproc_shutdown() / forced rproc_del() are in drivers/remoteproc/remoteproc_core.c (this commit is an ancestor of HEAD). Pre-fix form is rproc_shutdown() in rproc_del() plus the power-refcount bailout. Bug introduced **v4.9-rc1** (ddf711872c9d2).

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
- Record: **On this tree: clean / already integrated.** 2/3 already added crash_handler_lock / deleting / cancel_work_sync immediately above the changed call, matching this hunk. No later conflicting edits.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
- Record: 1/3 and 2/3 are in HEAD. No alternate force-shutdown implementation. This commit is the fix for the power > 1 case.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
- Record: **drivers/remoteproc/ — IMPORTANT** (not mm/VFS, but core for Qualcomm/TI/STM32/Mediatek/Xilinx coprocessors: modem, Wi-Fi, audio DSP, PRU). A core-framework removal bug hits every remoteproc driver.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
- Record: Actively maintained (Qualcomm PAS, sysmon, attach/detach, crash handling). This is a maintainer fix for a very old hole, not churn in brand-new code.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: DETERMINE WHO IS AFFECTED**
- Record: **Driver-specific / config-specific:** CONFIG_REMOTEPROC platforms, especially Qualcomm PAS + client rproc_boot() users. Not universal desktop x86, but common on phones, laptops with Qualcomm SoCs, and embedded boards.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
- Record:
- Trigger: rproc_del() while atomic_read(&rproc->power) > 1 and state is RUNNING/ATTACHED/CRASHED.
- How: auto-boot + client rproc_boot(), or extra sysfs/cdev start, then unbind/rmmod.
- Not every boot; **common on Qualcomm** where Wi-Fi/other clients hold a boot ref.
- Unprivileged: only if module unload is permitted.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
- Record: Firmware left running while driver unmaps carveouts, disables IOMMU, and frees resource tables → **oops/UAF, possible DMA corruption**. Cover letter matches that. **Severity: HIGH (crash / memory safety on device removal).**

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
- Record:
- **Benefit:** High for remoteproc users — prevents rmmod/unbind crash and teardown-under-running-firmware.
- **Risk:** Low — ~net +5 lines of logic, wrapper extract, no API change, rproc_shutdown() behavior unchanged, reviewed by subsystem people.
- **Ratio:** Benefit clearly exceeds risk.

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

**FOR backporting:**
- Real bug: extra power refs make rproc_del() skip stop; resources released under live firmware (crash/UAF/DMA).
- Known since 2016 TODO in rproc_del().
- Concrete trigger: client rproc_boot() + driver remove (Qualcomm PAS verified).
- Small, contained, obviously correct force flag.
- Maintainer patch, two Reviewed-by, applied after discussion; no NAK.
- No new APIs/features; public rproc_shutdown() unchanged.
- Prerequisites 1/3 and 2/3 are in this tree; 3/3 still stands alone for this bug.

**AGAINST:**
- Patch 3/3 of a series (other rmmod cases need 1/3 and 2/3; those are already here).
- No Fixes:/Cc: stable/Reported-by (expected here; not a veto).
- Trigger is unbind/rmmod, not every boot.
- Cover letter admits more issues remain in these paths (not a reason to skip this hole).

**UNRESOLVED:**
- lore.kernel.org HTTP 403 via WebFetch; thread recovered with b4 dig -m.
- No stable-list discussion found.

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — logic is local and reviewed; maintainer applied v1.
2. Fixes a real bug that affects users? **PASS** — rmmod/unbind with extra boot refs.
3. Important issue (crash, security, corruption, deadlock)? **PASS** — crash / UAF / DMA under teardown; HIGH.
4. Small and contained? **PASS** — one file, wrapper + one call-site change.
5. No new features or APIs? **PASS** — internal force flag only.
6. Can apply to the local tree? **PASS** — code and prereqs are in this 7.3-rc4 tree.

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
- Record: None (not a device ID, quirk, DT, build, or doc exception). It qualifies as a normal important bugfix.

**Step 9.4: MAKE YOUR DECISION**
This is a small, correct fix for a long-standing removal crash in remoteproc core. On this tree the surrounding series is already present, so there is no missing dependency. It meets stable-kernel rules on technical merit.

---

### What the commit solves (for stable users)
rproc_del() used to call rproc_shutdown(), which only actually stops the remote processor when the power refcount hits zero. Auto-boot plus any extra rproc_boot() (Wi-Fi, PRU ethernet, sysfs/cdev start, …) left the coprocessor running while the platform driver unmapped firmware memory and dropped IOMMU/power resources. That is an oops / use-after- unmap on rmmod or device unbind.

### Risk vs benefit
Benefit is preventing a real crash on a common Qualcomm/embedded unbind path. Risk is low: the public shutdown API is unchanged; only deletion forces stop.

### Concerns
None that block this tree. It is series patch 3/3, but the power > 1 fix does not need 1/3 or 2/3, and both are already here.

---

### Verification
- **[Phase 1]** git log -1 --format=%B 4059c64d78b5d:
subject/body/tags as above; no Fixes/Cc-stable/Reported-by; Link lore id v1-3; Reviewed-by Pradnya + Konrad.
- **[Phase 1]** Local tree: git describe HEAD → v7.3-rc4-27-gf0100363d8c37; make kernelversion → 7.3.0-rc4.
- **[Phase 2]** git show 4059c64d78b5d: 1 file, +31/-26; __rproc_shutdown(..., force); rproc_del uses force=true.
- **[Phase 2]** Read current rproc_shutdown/rproc_del/rproc_boot/rproc_stop in this
checkout: power increment-on-boot, bailout-on-shutdown, forced stop on delete confirmed.
- **[Phase 3]** git log -S 'TODO: make sure this works with rproc->power' → ddf711872c9d2 (v4.9-rc1) and this commit; git describe --contains ddf711872c9d2 → v4.9-rc1~104^2~13.
- **[Phase 3]** git merge-base --is-ancestor 4059c64d78b5d HEAD → yes; same for 2482ca875ef59 and 74ee3b2f57674.
- **[Phase 3]** git log 4059c64d78b5d..HEAD -- drivers/remoteproc/remoteproc_core.c → empty (no follow-up reversal).
- **[Phase 4]** b4 dig -c 4059c64d78b5d / -w / -a / -m /tmp/rproc-thread.mbox: v1-only series; cover letter describes extra- refcount rmmod crash; Konrad R-b + deleting-flag question; Bjorn reply; Pradnya R-b; applied. No NAK, no Cc-stable in thread.
- **[Phase 4]** WebFetch lore.kernel.org → 403; used mbox instead. Stable-list search: no relevant hits.
- **[Phase 5]** rg rproc_boot / rproc_shutdown / rproc_del:
clients and remove paths listed above. Read qcom_q6v5_pas.c qcom_pas_remove(): rproc_del() then qcom_pas_unassign_memory_region(). Read stm32_rproc_remove():
extra rproc_shutdown before rproc_del().
- **[Phase 6]** Buggy rproc_del+refcount path present since v4.9; this tree has the fix and both series siblings.
- **[Phase 8]** Failure mode: firmware running during resource unmap → crash/UAF; severity HIGH. Trigger: extra rproc_boot + device removal.
- **UNVERIFIED:** Direct HTTP read of lore HTML (403). No public syzbot/user bugzilla report.

**YES**

 drivers/remoteproc/remoteproc_core.c | 57 +++++++++++++++-------------
 1 file changed, 31 insertions(+), 26 deletions(-)
drivers/remoteproc/remoteproc_core.c +31 -26
index 70c990c3a5d76..1e277333de871 100644
@@ -1993,28 +1993,7 @@ int rproc_boot(struct rproc *rproc)
 }
 EXPORT_SYMBOL(rproc_boot);
 
-/**
- * rproc_shutdown() - power off the remote processor
- * @rproc: the remote processor
- *
- * Power off a remote processor (previously booted with rproc_boot()).
- *
- * In case @rproc is still being used by an additional user(s), then
- * this function will just decrement the power refcount and exit,
- * without really powering off the device.
- *
- * Every call to rproc_boot() must (eventually) be accompanied by a call
- * to rproc_shutdown(). Calling rproc_shutdown() redundantly is a bug.
- *
- * Notes:
- * - we're not decrementing the rproc's refcount, only the power refcount.
- *   which means that the @rproc handle stays valid even after rproc_shutdown()
- *   returns, and users can still use it with a subsequent rproc_boot(), if
- *   needed.
- *
- * Return: 0 on success, and an appropriate error value otherwise
- */
-int rproc_shutdown(struct rproc *rproc)
+static int __rproc_shutdown(struct rproc *rproc, bool force)
 {
 	struct device *dev = &rproc->dev;
 	bool crashed;
@@ -2034,9 +2013,10 @@ int rproc_shutdown(struct rproc *rproc)
 	}
 	crashed = rproc->state == RPROC_CRASHED;
 
-	/* if the remote proc is still needed, bail out */
-	if (!atomic_dec_and_test(&rproc->power))
+	if (!atomic_dec_and_test(&rproc->power) && !force) {
+		/* The remote processor is still needed by another user. */
 		goto out;
+	}
 
 	ret = rproc_stop(rproc, crashed);
 	if (ret) {
@@ -2060,6 +2040,32 @@ int rproc_shutdown(struct rproc *rproc)
 	mutex_unlock(&rproc->lock);
 	return ret;
 }
+
+/**
+ * rproc_shutdown() - power off the remote processor
+ * @rproc: the remote processor
+ *
+ * Power off a remote processor (previously booted with rproc_boot()).
+ *
+ * In case @rproc is still being used by an additional user(s), then
+ * this function will just decrement the power refcount and exit,
+ * without really powering off the device.
+ *
+ * Every call to rproc_boot() must (eventually) be accompanied by a call
+ * to rproc_shutdown(). Calling rproc_shutdown() redundantly is a bug.
+ *
+ * Notes:
+ * - we're not decrementing the rproc's refcount, only the power refcount.
+ *   which means that the @rproc handle stays valid even after rproc_shutdown()
+ *   returns, and users can still use it with a subsequent rproc_boot(), if
+ *   needed.
+ *
+ * Return: 0 on success, and an appropriate error value otherwise
+ */
+int rproc_shutdown(struct rproc *rproc)
+{
+	return __rproc_shutdown(rproc, false);
+}
 EXPORT_SYMBOL(rproc_shutdown);
 
 /**
@@ -2626,8 +2632,7 @@ int rproc_del(struct rproc *rproc)
 	if (cancel_work_sync(&rproc->crash_handler))
 		pm_relax(rproc->dev.parent);
 
-	/* TODO: make sure this works with rproc->power > 1 */
-	rproc_shutdown(rproc);
+	__rproc_shutdown(rproc, true);
 
 	rproc_delete_debug_dir(rproc);
 
Signature · 1 line
2.53.0
author maintainer
#293 lore raw

PATCH 1/1 ACPI: battery: Sanitise model_number by dropping unprintable characters

In reply to Sasha Levin

From: Kate Hsuan <[email protected]>

[ Upstream commit 6587dd87595cfae6bf1304cd0cd1df2274424e42 ]

The battery Embedded Controller (EC) may return the model name with trailing unprintable or non-ASCII characters. For example, on some systems:

$ cat /sys/class/power_supply/BAT0/model_name
LNV-5B10W51864��

If a non-ASCII or an unprintable character is found, it will be replaced with '\0' to ensure the model_number is a valid string.

If left intact, the malformed string prevents udev rules and hwdb working correctly.

---

LLM Generated explanations, may be completely bogus:

# Stable Backport Analysis: ACPI battery model_number sanitization

Local tree: **v7.3-rc4** (7.3.0-rc4, HEAD f0100363d8c37). Commit under review: 6587dd87595cfae6bf1304cd0cd1df2274424e42.

This is a mainline 7.3-rc checkout. The verdict is whether this fix has the technical merit to be backported from this tree into stable, given that the ACPI battery driver and the unsanitized model_number path exist here.

---

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1: PARSE THE SUBJECT LINE**

Record: **[ACPI battery] [Sanitise] [drop unprintable/non-ASCII bytes from model_number so sysfs model_name is a usable C string]**

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

Record:
- **Fixes:** none (expected for this review)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** Mark Pearson <[email protected]> (Lenovo)
- **Acked-by:** none
- **Link:**
https://gitlab.freedesktop.org/upower/upower/-/work_items/345 (UPower work item)
- **Link:**
https://patch.msgid.link/[email protected] (v2 submission)
- **Cc: stable:** none (expected; not a negative)
- **Signed-off-by:** Kate Hsuan <[email protected]> (author, Red Hat); Rafael J. Wysocki <[email protected]> (ACPI maintainer)
- **Other:** [ rjw: Subject tweak ]

Notable: Lenovo Reviewed-by plus a Red Hat author. No syzbot/KASAN.

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

Record:
- **Bug:** Battery EC/_BIF/_BIX returns a model string with trailing unprintable or non-ASCII bytes. Example: LNV-5B10W51864 plus replacement characters in sysfs.
- **Symptom:** /sys/class/power_supply/BAT0/model_name is not a clean ASCII string; **udev rules and hwdb cannot match** it.
- **Failure mode:** Userspace battery identification fails (UPower, hwdb quirks, udev ATTR{model_name} rules). Not a kernel oops.
- **Version info:** none in the message. Driver and field are old (see Phase 3).
- **Root cause (author):** firmware/EC returns garbage; kernel copies it into model_number unchanged.

**Step 1.4: DETECT HIDDEN BUG FIXES**

Record: **Not a disguised cleanup.** The subject/body describe a firmware-string sanitization so userspace matching works. It is a **hardware quirk / firmware workaround**, not a crash fix.

---

## PHASE 2: DIFF ANALYSIS - LINE BY LINE

**Step 2.1: INVENTORY THE CHANGES**

Record:
- **File:** drivers/acpi/battery.c only — **+14 / −0**
- **Functions:** new acpi_battery_clean_unprintable_chars(); call added at the end of extract_battery_info()
- **Also:** #include <linux/ctype.h>
- **Scope:** single-file surgical change

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

Record:
- **Before:** extract_package() strscpy()s ACPI string/buffer into battery->model_number. That value is exported as POWER_SUPPLY_PROP_MODEL_NAME (val->strval = battery->model_number). Trailing non-ASCII/unprintable bytes stay in the sysfs string.
- **After:** On successful extract (!result), walk model_number and replace the first non-ASCII or non-printable byte with '\0' (truncate). isprint('\0') is false, so an existing terminator also stops the loop.
- **Path:** initialization/update when _BIF/_BIX is parsed (acpi_battery_get_info() → extract_battery_info()), not a hot I/O path.

**Step 2.3: IDENTIFY THE BUG MECHANISM**

Record:
- **Category:** **hardware workaround / firmware string sanitization** (logic/correctness of exported sysfs string)
- **Mechanism:** EC returns trailing garbage; kernel treated it as a C string and exported it. Truncating at the first bad byte makes model_name matchable by udev/hwdb.
- **Not:** UAF, leak, race, NULL deref, overflow, deadlock.

**Step 2.4: ASSESS THE FIX QUALITY**

Record:
- **Quality:** Small and easy to verify. Loop is bounded by ARRAY_SIZE(battery->model_number) (64). Stops at NUL or first bad byte. Matches the “trailing garbage” report.
- **Regression risk:** Low. Sysfs model_name changes from a garbage- suffixed string to the printable prefix — that is the intended ABI cleanup. Unlikely udev rules match the unprintable suffix. Theoretical
risk: a legitimate non-ASCII model name would be truncated; ACPI _BIF/_BIX model strings in practice are ASCII (Lenovo example LNV-5B10W51864). Only model_number is cleaned, not serial_number/oem_info — incomplete vs a full sanitizer, but matches the reported bug.
- **v1 vs v2:** v1 stripped unprintables in the middle and kept the rest; v2 truncates. v2 is what landed; Lenovo reviewed it as good.

---

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1: BLAME THE CHANGED LINES**

Record:
- New helper is entirely this commit (6587dd87595cfa).
- extract_battery_info() exists since **Dave Lambley, 2016** (2d09af4a88d99a).
- model_number[] and copy-from-ACPI go back to the old ACPI battery driver (**~2007–2009**; c67fcd670b55e added _BIX in 2009). Unsanitized export has been present for many LTS generations.
- String copy uses strscpy from Armin Wolf, 2023 (a1a32ded2887fd) — that only changed copy safety, not sanitization.

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

Record: **No Fixes: tag.** Nothing to follow. Bug is long-standing firmware/EC behavior, not a recent regression from a specific commit.

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

Record: Recent drivers/acpi/battery.c commits after this one (mutex split, notification merge, charging-status check) are **independent**. No prerequisite series. Standalone.

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

Record: Kate Hsuan (Red Hat) has this one ACPI battery commit plus other hardware-enablement work (Lenovo cameras, power-supply LEDs). Not the ACPI maintainer. ACPI maintainer (Rafael) applied it. Lenovo’s Mark Pearson reviewed it.

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

Record: Uses isascii/isprint from linux/ctype.h (long-standing). extract_battery_info() and model_number[MAX_STRING_LENGTH] exist in this tree and in old kernels. **Standalone; no extra commits required.**

---

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

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

Record:
- **b4 dig:**
https://patch.msgid.link/[email protected]
- **Revisions:** v1 [email protected] (2026-07-08); **v2** (committed) 2026-07-10. v1 compacted by dropping unprintables; v2 truncates at first bad byte.
- **Review:** Mark Pearson: “this impacts a few of our platforms”; “Implementation looks good to me.” **Reviewed-by** given.
- **Maintainer:** Rafael: **“Applied as 7.3 material, thanks!”** No NAK. No Cc: stable request in the v2 thread (mbox).
- lore.kernel.org HTTP **403**; thread recovered via **b4 mbox** and openwall.

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

Record (b4 -w): Kate Hsuan, Mark Pearson (Lenovo), Rafael J. Wysocki, Len Brown, linux-acpi@, linux-kernel@. Right maintainers were on Cc. Rafael applied it.

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

Record: UPower work item
https://gitlab.freedesktop.org/upower/upower/-/work_items/345 — **GitLab returned 403; body UNVERIFIED**. Commit + Lenovo review still establish real udev/hwdb/UPower impact on some Lenovo platforms.

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

Record: Standalone (not N/M). No follow-up in this tree extending sanitization to serial/oem.

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

Record: lore.kernel.org/stable search **403**. **UNVERIFIED** whether stable@ discussed this. No evidence in the ACPI thread of a stable nomination or a rejection.

---

## PHASE 5: CODE SEMANTIC ANALYSIS

semcode MCP was **not available**. Used rg and file reads.

**Step 5.1: IDENTIFY KEY FUNCTIONS**

Record: acpi_battery_clean_unprintable_chars() (new); extract_battery_info() (caller added).

**Step 5.2: TRACE CALLERS**

Record:
- extract_battery_info() ← acpi_battery_get_info()
- acpi_battery_get_info() ← acpi_battery_update() (probe/update when !update_time), acpi_battery_refresh(), battery_notify() post- suspend path
- model_number read in acpi_battery_get_property() for POWER_SUPPLY_PROP_MODEL_NAME → sysfs model_name

Calling context: ACPI battery probe/update/resume, process context with property_lock. Not IRQ. Userspace reads sysfs (udev, UPower, desktop power applets).

**Step 5.3: TRACE CALLEES**

Record: isascii(), isprint() only. No alloc, no locks, no I/O.

**Step 5.4: FOLLOW THE CALL CHAIN**

Record: Firmware _BIF/_BIX → extract → sysfs model_name → udev/hwdb/UPower. **Reachable on any ACPI-battery laptop at boot.** Trigger is broken EC data on affected Lenovo (and similar) machines.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**

Record: Same !isascii || !isprint pattern in ath10k/11k/12k SMBIOS BDF, ipw2100/2200, sound/ump. Kernel already sanitizes firmware strings this way. This patch does **not** sanitize serial_number/type/oem_info in the same driver.

---

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

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

Record: **Yes.** drivers/acpi/battery.c has model_number[MAX_STRING_LENGTH] (64), extract_package() strscpy into it, and sysfs export via POWER_SUPPLY_PROP_MODEL_NAME. The bug is unsanitized firmware text; that behavior is ancient. Approximate
introduction: ACPI battery driver **2.6 era (~2007)**. This 7.3 tree already contains the fix (git merge-base --is-ancestor 6587dd87595cfa HEAD → yes). Evaluation is still whether the **fix itself** belongs on stable, not whether it is already applied here.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**

Record: **Clean/minor.** The hunk is a new helper + 4-line call + include. extract_battery_info() surrounding quirk code (ACPI_BATTERY_QUIRK_*) has been stable for years. Later 7.3-only changes (property_lock, kfifo notify) sit **elsewhere** and are not required. for (unsigned int i = 0; ...) is valid in current kernel C; very old compilers on ancient LTS could need unsigned int i; moved out — not an issue for this 7.3-based evaluation.

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

Record: This is the only model_number sanitization in battery.c. No earlier equivalent fix.

---

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

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

Record: **ACPI battery driver** (drivers/acpi/battery.c). **IMPORTANT** for ACPI laptops (power sysfs, udev, UPower), not core mm/VFS. Not staging.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**

Record: Moderately active (locking, notify coalescing, charge-status). Mature driver; this is a firmware quirk, not a new subsystem.

---

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1: DETERMINE WHO IS AFFECTED**

Record: **Driver/hardware-specific.** ACPI battery users whose EC returns garbage in the model string. Confirmed: **some Lenovo platforms** (Mark Pearson). Red Hat authored it, so it showed up on a distro kernel. Not universal.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**

Record: Every boot on affected hardware (sysfs populated from _BIF/_BIX). Unprivileged users can **read** model_name; they cannot trigger a kernel crash. udev runs as root and fails to match. Common on those machines, rare globally.

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

Record: **Failure mode:** udev/hwdb/UPower cannot match model_name → battery quirks, identification, and distro rules do not apply. **Severity: MEDIUM** (functional userspace integration, not oops/corruption/deadlock). Official stable rules explicitly include **hardware quirks**.

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

Record:
- **Benefit:** High for affected Lenovo/ACPI laptops on stable/LTS: hwdb and udev start working. Matches the hardware-quirk exception.
- **Risk:** Very low — 14 lines, no locking/alloc, truncates a firmware string already copied with strscpy.
- **Ratio:** Benefit outweighs risk for stable.

---

## PHASE 9: FINAL SYNTHESIS

**Step 9.1: COMPILE THE EVIDENCE**

**FOR backporting:**
- Real firmware bug on shipping Lenovo platforms (Lenovo Reviewed-by; “a few of our platforms”).
- Documented UPower/udev/hwdb breakage.
- Official stable rules: *“hardware quirk”* is an accepted class (Documentation/process/stable-kernel-rules.rst).
- 14 lines, single file, obviously correct, no new API.
- ACPI maintainer applied it; Lenovo reviewed it; Red Hat authored it.
- Driver and unsanitized model_number exist far back; no missing prerequisites.
- Same sanitization pattern as other firmware-string handling in-tree.

**AGAINST:**
- Not a crash, UAF, deadlock, or CVE.
- Changes userspace-visible model_name (intentional).
- Rafael labeled it “7.3 material,” not an explicit stable nomination.
- Userspace *could* strip the bytes (kernel is still the right place, as with other firmware sanitizers).
- Only model_number is cleaned.

**UNRESOLVED:**
- UPower work item body (GitLab 403).
- v1 review text beyond the v1/v2 diff (lore 403).
- Whether stable@ already discussed it (lore 403).

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

1. Obviously correct and tested? **PASS** — bounded truncate; Lenovo review; maintainer applied.
2. Fixes a real bug that affects users? **PASS** — udev/hwdb/UPower fail on real Lenovo batteries.
3. Important issue? **PASS** as **hardware quirk** (explicitly listed in stable-kernel-rules.rst). Severity MEDIUM, not oops-level.
4. Small and contained? **PASS** — +14 lines, one file.
5. No new features or APIs? **PASS** — sanitizes an existing sysfs string.
6. Can apply to the local tree? **PASS** — driver and extract_battery_info() are present; hunk is self-contained.

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**

Record: **Hardware quirk / firmware workaround** (sanitize broken EC model string). Analogous to USB/PCI/codec quirks: small, device- specific, makes existing userspace matching work.

**Step 9.4: MAKE YOUR DECISION**

This is a small, reviewed firmware sanitization that fixes a real udev/hwdb failure on Lenovo ACPI batteries. It is not a kernel crash, but stable rules treat hardware quirks as in-scope, and the risk is very low. It should be backported.

---

## What the commit solves and why it matters to stable users

On some systems the battery EC returns a model name with trailing non- ASCII/unprintable bytes. That string is exported as /sys/class/power_supply/BAT0/model_name. udev rules and hwdb match on that attribute; garbage bytes prevent matches, so UPower and distro battery quirks do not apply. Stable/LTS laptop users (enterprise, Fedora, Ubuntu) stay on these kernels for years; they need the same identification to work.

## Stable rules, risk vs benefit, concerns

Meets the written rules: obviously correct, real user-visible bug, hardware quirk, 14 lines, no new API. Benefit is restored udev/hwdb matching on affected machines; risk is a one-time sysfs string cleanup with no locking or allocation. No extra commits are required. Later 7.3 battery locking/notify work is unrelated.

---

Verification:
- [Phase 1] Parsed tags: Reviewed-by Mark Pearson (Lenovo); SOB Kate Hsuan (Red Hat) and Rafael J. Wysocki; Link to UPower work item 345 and patch.msgid v2; no Fixes:/Reported-by/Cc:stable
- [Phase 1] Body: example LNV-5B10W51864 plus unprintable suffix; udev/hwdb matching failure
- [Phase 2] Diff: +14 drivers/acpi/battery.c; new acpi_battery_clean_unprintable_chars(); call in extract_battery_info() when !result; #include <linux/ctype.h>
- [Phase 2] Confirmed isprint/isascii in include/linux/ctype.h; isprint('\0') is false so loop stops at NUL
- [Phase 2] MAX_STRING_LENGTH is 64; ARRAY_SIZE(battery->model_number) matches
- [Phase 3] Blame: helper is 6587dd87595cfa; extract_battery_info from 2d09af4a88d99a (2016); strscpy from a1a32ded2887fd (2023); model_number field long-standing
- [Phase 3] No Fixes: tag; git log on drivers/acpi/battery.c shows no prerequisite series
- [Phase 3] git merge-base --is-ancestor 6587dd87595cfa HEAD succeeded (commit is in this tree)
- [Phase 4] b4 dig -c 6587dd87595cfa: v2 at patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v1 2026-07-08 (strip-in-place), v2 2026-07-10 (truncate) — committed version is v2
- [Phase 4] b4 dig -w: Rafael, Len Brown, linux-acpi, Mark Pearson on the original To/Cc
- [Phase 4] b4 mbox: Pearson “impacts a few of our platforms”; Rafael “Applied as 7.3 material”; no NAK, no Cc:stable in thread
- [Phase 4] lore.kernel.org and GitLab 403 — UPower issue body and stable@ history UNVERIFIED
- [Phase 5] Callers: acpi_battery_get_info from acpi_battery_update, acpi_battery_refresh, battery_notify; property POWER_SUPPLY_PROP_MODEL_NAME → sysfs
- [Phase 5] Similar isascii/isprint sanitization in ath1x k SMBIOS and ipw2x00
- [Phase 6] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion: 7.3.0-rc4
- [Phase 6] Parent of fix still copies model_number via strscpy with no sanitization
- [Phase 7] Subsystem ACPI battery; official rules quote: hardware quirk is in-scope
- [Phase 8] Failure mode: udev/hwdb mismatch, severity MEDIUM; not oops/UAF
- UNVERIFIED: UPower work item 345 details; v1 mailing-list review comments; any prior stable@ discussion

The patch is a 14-line firmware quirk that restores battery model_name matching for real Lenovo hardware, with negligible regression risk.

**YES**

 drivers/acpi/battery.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/acpi/battery.c +14 -0
index 296c2981b1a73..0b922aceb28d1 100644
@@ -10,6 +10,7 @@
 
 #define pr_fmt(fmt) "ACPI: battery: " fmt
 
+#include <linux/ctype.h>
 #include <linux/delay.h>
 #include <linux/dmi.h>
 #include <linux/jiffies.h>
@@ -486,6 +487,15 @@ static int acpi_battery_get_status(struct acpi_battery *battery)
 	return 0;
 }
 
+static void acpi_battery_clean_unprintable_chars(char *str, size_t length)
+{
+	for (unsigned int i = 0; i < length; i++) {
+		if (!isascii(str[i]) || !isprint(str[i])) {
+			str[i] = '\0';
+			break;
+		}
+	}
+}
 
 static int extract_battery_info(const int use_bix,
 			 struct acpi_battery *battery,
@@ -527,6 +537,10 @@ static int extract_battery_info(const int use_bix,
 	    battery->capacity_now > battery->full_charge_capacity)
 		battery->capacity_now = battery->full_charge_capacity;
 
+	if (!result)
+		acpi_battery_clean_unprintable_chars(battery->model_number,
+					ARRAY_SIZE(battery->model_number));
+
 	return result;
 }
 
Signature · 1 line
2.53.0
author maintainer
#294 lore raw

PATCH 1/1 net: sfp: add quirk for HORACO copper SFP+ module

In reply to Sasha Levin

From: Aleksander Jan Bajkowski <[email protected]>

[ Upstream commit 1bb028baab541900d3603d4f93c1c0fb5aba5401 ]

Add quirk for a copper SFP+ module that identifies itself as "OEM" "HC-10GE-113C". It uses RollBall protocol to talk to the PHY.

---

LLM Generated explanations, may be completely bogus:

Local tree is **v7.3-rc4** (mainline 7.3.0-rc4). The candidate is 1bb028baab541 (net: sfp: add quirk for HORACO copper SFP+ module). The SFP quirk table and sfp_fixup_rollball() are present here, so this is evaluated as a hardware-quirk backport on technical merit.

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

**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[net: sfp:] [add] [quirk for HORACO copper SFP+ module]**
- Subsystem: net: sfp (SFP cage / phylink)
- Verb: **add** — here it is a hardware quirk table entry, not a new driver or API

**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected; this is not a regression from a prior kernel commit)
- **Reported-by:** none
- **Tested-by:** none
- **Reviewed-by:** Andrew Lunn <[email protected]> (PHY/SFP reviewer)
- **Acked-by:** none
- **Link:** https://patch.msgid.link/[email protected]
- **Cc: stable:** none (expected)
- **Signed-off-by:** Aleksander Jan Bajkowski <[email protected]> (author); Jakub Kicinski <[email protected]> (netdev maintainer)
- Ignored: any pipeline “Upstream commit” / Sasha Levin SOB (none on this commit)

Notable: reviewed by Lunn, applied by Kicinski. No syzbot, no multi-user reports.

**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** copper SFP+ identifying as vendor "OEM" / part "HC-10GE-113C" talks to its PHY with the RollBall I2C-to-MDIO protocol, which the EEPROM does not describe in a way the generic path understands.
- **Symptom:** PHY probe uses the wrong MDIO protocol (typically MDIO_I2C_NONE or C45), so the copper PHY is not found and the link does not come up.
- **Version info:** none in the message. Patch was sent as [PATCH net- next] on 2026-07-19; applied 2026-07-21; git describe --contains → **v7.3-rc1**.
- **Root cause (author):** module uses RollBall; needs an sfp_quirks[] match so sfp_fixup_rollball() runs.

**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not a hidden cleanup.** It is an explicit hardware quirk. That is an allowed stable class (SFP_QUIRK_* / stable-kernel-rules.rst “hardware quirk”), not a disguised leak/race.

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

**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/net/phy/sfp.c — **+3 / −0**
- Data only: sfp_quirks[] (static const table)
- Scope: **single-file surgical quirk addition** (one SFP_QUIRK_F + comment)

**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** EEPROM vendor "OEM" + PN "HC-10GE-113C" does not match any quirk. sfp_sm_mod_probe() sets mdio_protocol from EEPROM (MDIO_I2C_C45 if 10GBASE-T ECC, else MDIO_I2C_NONE for a module that does not identify as copper). sfp_sm_probe_for_phy() then either skips PHY probe or probes at the wrong address/protocol.
- **After:** sfp_lookup_quirk() matches exact vendor+part, sfp_fixup_rollball() sets sfp->mdio_protocol = MDIO_I2C_ROLLBALL and phy_t_retry to 1s. Probe uses SFP_PHY_ADDR_ROLLBALL and C45-over-RollBall.
- Path: **module insert / probe** (normal path for this SKU only).

**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** **(h) Hardware workaround** — SFP quirk
- **Mechanism:** broken/non-standard EEPROM vs actual RollBall PHY access. Fix is vendor/PN table entry calling existing sfp_fixup_rollball().

**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Quality:** obviously correct. Same pattern as FLYPRO SFP-10GT- CS-30M, Turris RTSFP-*, OEM SFP-10G-T. Match is exact (sfp_match requires equal length; this entry is not SFP_QUIRK_F_PREFIX).
- **Minimal:** 3 lines, no unrelated edits.
- **Regression risk:** very low. Only this vendor+PN pair. sfp_fixup_rollball() only sets protocol + retry interval.
- **Caveat (verified, not blocking):** some other OEM 10G copper entries use sfp_fixup_rollball_cc (also patches extended_cc). Author chose plain sfp_fixup_rollball; Lunn reviewed. If this SKU already has a valid ECC, CC extra is unnecessary.

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

**Step 3.1: BLAME THE CHANGED LINES**
Record:
- New lines authored in **1bb028baab541** (2026-07-19).
- Neighbors: YV XGSPON quirk (dfec1c14aecee, 2025) and OEM SFP-GE-T (0805d67bc0ef95, 2024).
- **Infrastructure:** sfp_fixup_rollball() introduced in **324e88cbe3b7b** (“net: sfp: add support for multigig RollBall transceivers”, 2022-10-03) — **v6.1-rc1**. Present in this tree.

**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Not a regression from a specific prior commit. The module never worked without the quirk.

**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- Same author, same pattern: ddbf0e78a8b20 “net: sfp: add quirk for FLYPRO copper SFP+ module” (v6.17-rc5).
- Later on same file: hwmon leak fix; prefix-match for *other* OEM PNs (f53167e29b8e9); more ONT quirks. **None change the HORACO entry.**
- **Standalone**, not patch X/Y.

**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Aleksander Jan Bajkowski is a regular PHY/SFP contributor (FLYPRO quirk, intel-xway, realtek, mediatek). Not the SFP maintainer; Lunn’s Reviewed-by covers that.

**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Record:
- Needs: SFP_QUIRK_F, sfp_fixup_rollball(), MDIO_I2C_ROLLBALL — all in this tree (sfp.c, include/linux/mdio/mdio-i2c.h).
- **Applies standalone.** No new helpers.

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

**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c 1bb028baab541:
**https://patch.msgid.link/[email protected]**
- b4 dig -a: **v1 only** ([PATCH net-next]), 2026-07-19
- Thread (mbox): (1) patch, (2) Lunn **Reviewed-by**, (3) patchwork-bot applied to **netdev/net-next.git** as 1bb028baab54
- **No NAK**, no requested respin, **no Cc: stable** in review

**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To/Cc included Russell King ([email protected]), Andrew Lunn, Heiner Kallweit, netdev maintainers (David, Edumazet, Kicinski, Pabeni), [email protected]. Right people; Lunn reviewed.

**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: no Reported-by, bugzilla, or syzbot. Author describes a real module SKU. Severity from reporter: **module does not work** (PHY protocol). User count: **unverified beyond the author**.

**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: **standalone**, not a series. Related only as the same quirk pattern as FLYPRO.

**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org search returned **403**. Web search for “HORACO … stable” found the net-next thread (LKML, Patchew, spinics), **not** a stable-list NAK. **UNVERIFIED:** no stable@ thread found; no evidence it was rejected.

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

**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: **No function bodies changed.** New table entry consumed by sfp_lookup_quirk() → sfp_fixup_rollball().

**Step 5.2: TRACE CALLERS**
Record (from sfp.c):
- sfp_lookup_quirk() called from module-ID setup (~line 2677)
- If quirk->fixup, called under st_mutex (~2686–2687)
- sfp_sm_probe_for_phy() switches on mdio_protocol; MDIO_I2C_ROLLBALL probes SFP_PHY_ADDR_ROLLBALL
- Context: **SFP insert**, process/workqueue, not IRQ. Userspace-visible as “plug copper SFP+, no link”

**Step 5.3: TRACE CALLEES**
Record: sfp_fixup_rollball() assigns MDIO_I2C_ROLLBALL and phy_t_retry = 1s. No alloc/lock.

**Step 5.4: FOLLOW THE CALL CHAIN**
Record: SFP cage driver (CONFIG_SFP, depends on I2C+PHYLINK) → EEPROM read → quirk → PHY probe. **Reachable** when this module is inserted. Not a syscall fuzzer path; **hardware + SFP cage**.

**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: many RollBall quirks already: FLYPRO, FS, Walsun, OEM SFP-10G-T / RTSFP-*, Turris. Same bug class; this SKU was missing.

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

**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?** Record:
- git describe HEAD: **v7.3-rc4-27-gf0100363d8c37**
- make kernelversion: **7.3.0-rc4**
- drivers/net/phy/sfp.c exists; sfp_quirks[] exists; sfp_fixup_rollball() exists (since v6.1).
- Without this entry, this SKU would not match. git merge-base --is- ancestor 1bb028baab541 HEAD → **yes** (already in 7.3-rc1+). Evaluation is still: would this tree *need* the quirk for the hardware — **yes, the driver is here**.

**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **clean apply** on this tree (already applied as a 3-line insert next to other OEM entries). No conflicting refactor of the table around that site beyond later prefix-match macros unused by this entry.

**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: this exact quirk is the fix. No alternate HORACO workaround. Follow-ups do not replace it.

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

**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY** Record:
- Subsystem: **drivers/net/phy** — SFP cage (CONFIG_SFP)
- Criticality: **IMPORTANT** for machines with SFP cages (routers, NICs, embedded); **PERIPHERAL** as a single OEM copper module SKU. Not mm/VFS/core.

**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: active (many 2025–2026 quirk and RollBall commits). Quirk table is the long-standing way to handle broken modules.

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

**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **driver-specific + hardware-specific** — users of HORACO HC-10GE-113C (EEPROM OEM / HC-10GE-113C) in an SFP cage. No effect on other modules.

**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: insert/probe that module. Common for owners of that SKU, **never** otherwise. Unprivileged users cannot trigger it without the hardware. Not a race.

**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- Failure: PHY not probed / no copper link
- Not oops/UAF/corruption
- **Severity: MEDIUM** for that hardware (link dead), **LOW** globally
- Still matches the documented **hardware quirk** stable exception

**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** module works on stable kernels that already have SFP+RollBall (this tree does)
- **Risk:** very low (3 lines, exact match, existing fixup)
- **Ratio:** favorable — classic stable quirk

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

**Step 9.1: COMPILE THE EVIDENCE**

FOR:
- Documentation/process/stable-kernel-rules.rst explicitly allows **hardware quirks**
- Prompt class: **SFP_QUIRK_*** — “YES for stable”
- Real hardware: RollBall PHY, wrong/missing EEPROM description
- 3-line table add, existing sfp_fixup_rollball()
- Reviewed by Andrew Lunn; applied by Kicinski
- RollBall stack in this tree since v6.1
- Exact vendor+PN match; no new API/feature surface
- Same pattern as FLYPRO and other OEM 10G copper quirks

AGAINST:
- net-next, not net; no Cc: stable / Fixes (expected for new IDs)
- No public crash/CVE; only this SKU
- Submitted as “add quirk”, not a core bugfix
- Whether every OEM HC-10GE-113C also needs rollball_cc was not independently tested here (Lunn review is the available evidence)

UNRESOLVED:
- lore.kernel.org HTTP 403; stable@ history only via web search (no hit)
- No independent Tested-by besides implied author testing
- How many users have this module: unverified

**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — table entry + Lunn Reviewed- by; applied to net-next
2. Fixes a real bug that affects users? **PASS** — module cannot talk to PHY / no link
3. Important issue? **PASS** under the **hardware quirk** exception (not a kernel oops)
4. Small and contained? **PASS** — +3 lines, one file
5. No new features or APIs? **PASS** — existing quirk hook only
6. Can apply to the local tree? **PASS** — SFP + sfp_fixup_rollball present; applies cleanly

**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Hardware quirk / SFP quirk** (and analogous to device-ID addition on an existing driver). Qualifies automatically.

**Step 9.4: MAKE YOUR DECISION**
This tree has the SFP driver and RollBall fixup. The patch is a 3-line SKU quirk so that copper module gets MDIO_I2C_ROLLBALL. That is the stable exception, low risk, self-contained. Backport **yes**.

------------------------------------------------
What it solves for stable users
------------------------------------------------
Without the quirk, a HORACO HC-10GE-113C (OEM / HC-10GE-113C) never uses RollBall, so the PHY is not probed and the 10G copper link stays down. With it, insert matches the table and uses the existing RollBall path (protocol + 1s PHY retry).

Risk vs benefit
------------------------------------------------
Benefit is that specific module working. Risk is negligible: exact string match, no locking/API change. Later prefix-match work does not apply to this exact PN.

Concerns
------------------------------------------------
None that block backport: no series, no missing helpers on this tree, no review objections. Optional rollball_cc is unused; reviewers accepted sfp_fixup_rollball.

Verification:
- [Phase 1] Tags: Reviewed-by Andrew Lunn; Link msgid [email protected]; SOB Bajkowski + Kicinski; no Fixes/Reported-by/Cc:stable
- [Phase 1] Subject [PATCH net-next]; body states OEM HC-10GE-113C uses RollBall
- [Phase 2] Diff: +3 lines in sfp_quirks[]; SFP_QUIRK_F("OEM", "HC-10GE-113C", sfp_fixup_rollball)
- [Phase 2] sfp_fixup_rollball() sets MDIO_I2C_ROLLBALL and 1s phy_t_retry (sfp.c:412–421)
- [Phase 2] sfp_sm_probe_for_phy() uses SFP_PHY_ADDR_ROLLBALL for that protocol (sfp.c:2244–2246)
- [Phase 2] sfp_lookup_quirk() exact vendor+part match (sfp.c:668–684); fixup at 2686–2687
- [Phase 3] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; kernelversion 7.3.0-rc4
- [Phase 3] Commit 1bb028baab541; git describe --contains = v7.3-rc1~133^2~221
- [Phase 3] git merge-base --is-ancestor 1bb028baab541 HEAD succeeded
- [Phase 3] sfp_fixup_rollball from 324e88cbe3b7b (v6.1-rc1)
- [Phase 3] Similar FLYPRO quirk ddbf0e78a8b20 (v6.17-rc5); author has two sfp.c quirk commits
- [Phase 3] No later commit edits the HORACO lines (git blame 613–615 = 1bb028baab541)
- [Phase 4] b4 dig -c/-a/-w/-m: v1 only; Lunn Reviewed-by; applied to net-next; CC list includes RMK, Lunn, Kallweit, netdev
- [Phase 4] lore.kernel.org WebFetch 403; mbox from b4 used instead
- [Phase 4] Web search: LKML/Patchew/spinics confirm review; no stable- list discussion found
- [Phase 5] Call path: module probe → lookup_quirk → fixup → sm_probe_for_phy; CONFIG_SFP (I2C+PHYLINK)
- [Phase 6] Quirk present in this checkout at sfp.c:613–614; RollBall enum in mdio-i2c.h
- [Phase 7] stable-kernel-rules.rst line 19: hardware quirk is in- scope
- [Phase 8] Failure mode: no PHY/no link for that SKU; not an oops
- UNVERIFIED: stable@ mailing list archives (HTTP 403); number of field users; whether this SKU also needs sfp_fixup_rollball_cc

**YES**

 drivers/net/phy/sfp.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/phy/sfp.c +3 -0
index af43530ffb2c3..195468bde2f29 100644
@@ -576,6 +576,9 @@ static const struct sfp_quirk sfp_quirks[] = {
 
 	SFP_QUIRK_F("YV", "SFP+ONU-XGSPON", sfp_fixup_potron),
 
+	// HORACO HC-10GE-113C uses Rollball protocol to talk to the PHY.
+	SFP_QUIRK_F("OEM", "HC-10GE-113C", sfp_fixup_rollball),
+
 	// OEM SFP-GE-T is a 1000Base-T module with broken TX_FAULT indicator
 	SFP_QUIRK_F("OEM", "SFP-GE-T", sfp_fixup_ignore_tx_fault),
 
Signature · 1 line
2.53.0
author maintainer
#295 lore raw

PATCH 1/1 net: usb: cdc_ether: add quirk for AMI BMC stale link events

In reply to Sasha Levin

From: Jinhui Guo <[email protected]>

[ Upstream commit 089ca284afb0f3b2870a5ce41524cbc91ed350d4 ]

On AMD Genoa/Turin platforms the BMC-provided USB-Ethernet gadget (American Megatrends, VID 0x046b PID 0xffb0) intermittently fails to respond to ARP after AC cold boot. usbmon captures a stale NETWORK_CONNECTION(off) immediately followed by NETWORK_CONNECTION(on) on the interrupt endpoint (~130us apart) after enumeration. Because alloc_netdev() leaves __LINK_STATE_NOCARRIER cleared, netif_carrier_ok() returns true when the spurious OFF arrives, so usbnet_cdc_status() cannot recognise it as redundant and schedules EVENT_LINK_CHANGE. __handle_link_change() then calls unlink_urbs(), killing ~60 rx URBs whose payload has already been DMA'd into memory — xHCI trace confirms them completing as -ECONNRESET with non-zero residual length. rx_complete() drops these unconditionally. The following ON restores the carrier and re-submits URBs, but the ARP reply is already lost; the interface looks "up but silent" until ifdown/ifup.

Fix this by adding a device-specific quirk with FLAG_LINK_INTR set, which makes usbnet_probe() call netif_carrier_off() after bind. With initial carrier == OFF, usbnet_cdc_status() recognises the spurious OFF as matching the current state and drops it; the subsequent ON is the first real event and brings the link up cleanly without ever tearing down the rx queue. The scheduled link-change kevent is harmless because EVENT_DEV_OPEN is not yet set at probe time.

This is applied as a device-specific quirk rather than a change to the shared cdc_info driver_info because some CDC devices never send NETWORK_CONNECTION notifications; forcing carrier off for them would leave the link permanently DOWN. Restricting the change to this VID/PID keeps that class of device untouched.

Tested on Genoa and Turin across 100+ AC cold boot cycles; ping first-packet success rate went from intermittent to 100%.

---

LLM Generated explanations, may be completely bogus:

Local tree is **6.12.111**. The buggy cdc_ether path is present here, and this is a device-specific hardware quirk for an existing driver.

## PHASE 1: COMMIT MESSAGE FORENSICS

**Step 1.1 PARSE THE SUBJECT LINE**
- Record: [net: usb: cdc_ether] [add quirk] [AMI BMC VID 0x046b PID 0xffb0 stale NETWORK_CONNECTION events]

**Step 1.2 PARSE ALL COMMIT MESSAGE TAGS**
- Record:
- Signed-off-by: Jinhui Guo <[email protected]> (author)
- `Link: https://patch.msgid.link/20260730051341.24930-1-
[email protected]`
- Signed-off-by: Jakub Kicinski <[email protected]> (netdev maintainer applied it)
- No Fixes:, no Cc: stable, no Reported-by, no Reviewed-by, no Acked-by, no Tested-by (absence of Fixes/Cc-stable is expected for this review)
- Ignore pipeline Signed-off-by: Sasha Levin / `[Upstream commit

    ...]` if present

**Step 1.3 ANALYZE THE COMMIT BODY TEXT**
- Record:
- **Bug:** AMI BMC USB-Ethernet gadget on AMD Genoa/Turin (VID

    `0x046b` PID `0xffb0`) intermittently fails ARP after AC cold boot.

- **Symptom:** Interface looks “up but silent” until ifdown/ifup.
- **Root cause:** After enumeration, firmware emits stale NETWORK_CONNECTION(off) then (on) ~130µs apart. alloc_netdev() leaves __LINK_STATE_NOCARRIER clear, so netif_carrier_ok() is true; usbnet_cdc_status() treats OFF as a real transition, schedules EVENT_LINK_CHANGE, and __handle_link_change() unlink_urbs()s ~60 RX URBs. Completions come back as -ECONNRESET with payload already DMA’d; rx_complete() drops them, including the ARP reply.
- **Fix:** Device-specific driver_info with FLAG_LINK_INTR so probe starts carrier OFF; redundant OFF is dropped; ON is the first real event.
- **Why not global:** Some CDC devices never send NETWORK_CONNECTION; forcing carrier off would leave them permanently DOWN.
- **Testing:** 100+ AC cold boots on Genoa and Turin; first-packet ping went from intermittent to 100%.

**Step 1.4 DETECT HIDDEN BUG FIXES**
- Record: Not hidden. This is an explicit hardware quirk for a real connectivity failure.

## PHASE 2: DIFF ANALYSIS

**Step 2.1 INVENTORY THE CHANGES**
- Record:
- File: drivers/net/usb/cdc_ether.c only (~+16 lines, 0 removed)
- Adds ami_bmc_info (clone of cdc_info plus FLAG_LINK_INTR)
- Adds USB_DEVICE_AND_INTERFACE_INFO(0x046b, 0xffb0, ...) **before** the generic CDC Ethernet catch-all
- Scope: single-file surgical quirk / device ID

**Step 2.2 UNDERSTAND THE CODE FLOW CHANGE**
- Record:
- **Before:** 046b:ffb0 matches USB_INTERFACE_INFO(..., USB_CDC_SUBCLASS_ETHERNET, ...) → cdc_info (FLAG_ETHER | FLAG_POINTTOPOINT, no FLAG_LINK_INTR). Carrier starts ON. Stale OFF is a state change.
- **After:** Same bind/status/unbind/filter/power callbacks, plus FLAG_LINK_INTR. usbnet_probe() calls usbnet_link_change(dev, 0, 0) → netif_carrier_off(). Stale OFF matches current state and is ignored.

**Step 2.3 IDENTIFY THE BUG MECHANISM**
- Record: **Hardware workaround / logic correctness.** Stale firmware notifications plus default carrier-ON cause a false link-down that tears down RX URBs and drops in-flight frames (ARP).

**Step 2.4 ASSESS THE FIX QUALITY**
- Record: Minimal and obviously correct. FLAG_LINK_INTR is the established usbnet pattern (asix, smsc, dm9601, cdc_ncm, …). Restricted to one VID/PID. Regression risk is confined to 046b:ffb0:
initial carrier is OFF until the first ON notification. Author captured that ON always follows. No public API / data-structure change.

## PHASE 3: GIT HISTORY INVESTIGATION

**Step 3.1 BLAME THE CHANGED LINES**
- Record:
- Generic cdc_info has existed since early usbnet.
- FLAG_LINK_INTR added in 37e8273cd3059 (“usbnet: Set link down initially for drivers that update link state”, 2009).
- Global FLAG on cdc_ether was removed in 71cc1fa9f2d71 (2010) because CDC Ethernet notifications are optional; devices that never send them stayed DOWN (bugzilla.kernel.org/14791). That is why this must be device-specific.
- Carrier comparison in usbnet_cdc_status() added by 2d5c9dd2cde33 (“net: usb: cdc_ether: don't spew notifications”, 2024-08-08). That check is what lets a redundant OFF be dropped. Confirmed ancestor of HEAD.

**Step 3.2 FOLLOW THE FIXES: TAG**
- Record: No Fixes: tag. Not applicable. The interaction is long- standing default carrier-ON plus this BMC’s cold-boot notifications.

**Step 3.3 CHECK FILE HISTORY**
- Record: Recent cdc_ether.c history is other device IDs/quirks (zte_cdc_info, Cinterion WWAN IDs, ThinkPad dock). Same pattern. Standalone, not patch X/Y.

**Step 3.4 CHECK THE AUTHOR'S OTHER COMMITS**
- Record: git log --author="Jinhui Guo" -- drivers/net/usb/ is empty in this tree. Author is not the subsystem maintainer. Applied by Jakub Kicinski. USB net maintainers were on To/Cc (Oliver Neukum, netdev).

**Step 3.5 CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
- Record: Can apply standalone. This tree already has:
- FLAG_LINK_INTR and usbnet_probe() handling
- usbnet_cdc_status() carrier filter (2d5c9dd2cde33)
- usbnet_cdc_bind / unbind / usbnet_cdc_update_filter / usbnet_manage_power
- Products table with the same Cinterion-then-catch-all context

## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH

**Step 4.1 FIND THE ORIGINAL PATCH DISCUSSION**
- Record:
- b4 dig -c 46651395... failed (SHA not in this repo).
- Lore WebFetch returned 403 (Anubis bot-check).
- Openwall/Patchew/LKML recovered the thread:
- https://lists.openwall.net/linux-kernel/2026/07/30/380 (v1, standalone [PATCH])
- https://lists.openwall.net/linux-kernel/2026/07/30/387 (author follow-up with usbmon + xHCI evidence)
- Single revision. No v2/v3 found. No NAK found.

**Step 4.2 CHECK WHO REVIEWED THE PATCH**
- Record: To: Oliver Neukum, Andrew Lunn, David Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni. Cc: linux-usb, netdev. No Reviewed- by/Acked-by in the recovered thread. Kicinski’s SOB is the apply signal. Recipients were the right maintainers.

**Step 4.3 SEARCH FOR THE BUG REPORT**
- Record: No syzbot/bugzilla. Author is the reporter, with usbmon, CDC status traces, and xHCI Stop Ring / -ECONNRESET givebacks. Failure is AC-cold-boot only; DC reboot preserves gadget state. 100+ cycle test.

**Step 4.4 CHECK FOR RELATED PATCHES AND SERIES**
- Record: Standalone 16-line patch. Author’s follow-up mentions not changing shared cdc_info because a global FLAG_LINK_INTR attempt was reverted (the 2010 revert 71cc1fa9f2d71 is in this tree; the cited subject string does not match that commit — likely a misremembered title — but the technical reason matches the 2010 revert).

**Step 4.5 CHECK STABLE MAILING LIST HISTORY**
- Record: lore.kernel.org/stable search was blocked (403). Openwall/web search found no stable-specific NAK or “do not backport” discussion.
UNVERIFIED: whether anyone already requested this on stable@.

## PHASE 5: CODE SEMANTIC ANALYSIS

**Step 5.1 KEY FUNCTIONS**
- Record: No function bodies changed. New ami_bmc_info; new products[] entry. Runtime path: usbnet_probe() → FLAG_LINK_INTR → usbnet_link_change(); status path remains usbnet_cdc_status().

**Step 5.2 TRACE CALLERS**
- Record:
- usbnet_probe is cdc_driver.probe (USB enumeration).
- usbnet_cdc_status is the interrupt completion status callback.
- usbnet_open submits the interrupt URB and RX URBs

    (`EVENT_DEV_OPEN`).

- __handle_link_change unlinks RX URBs if carrier is down **and** EVENT_DEV_OPEN is set.

**Step 5.3 TRACE CALLEES**
- Record: usbnet_link_change(dev, 0, 0) synchronously netif_carrier_off() then defers EVENT_LINK_CHANGE. Probe-time kevent is a no-op because EVENT_DEV_OPEN is clear (__handle_link_change returns immediately).

**Step 5.4 FOLLOW THE CALL CHAIN**
- Record: Reachable on any host with this BMC gadget and CONFIG_USB_NET_CDCETHER. After boot, NetworkManager/ip link set up opens the netdev; stale notifications then hit the status path.
Userspace-visible: lost ARP, silent interface.

**Step 5.5 SEARCH FOR SIMILAR PATTERNS**
- Record: Same file already has zte_cdc_info (device-specific status/bind). Many usbnet drivers use FLAG_LINK_INTR. drivers/hid/hid-ids.h defines USB_VENDOR_ID_AMI 0x046b; unusual_devs.h has another AMI BMC ID 0x046b:0xff40. Vendor ID is consistent.

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

**Step 6.1 DOES THE BUGGY CODE EXIST IN THIS TREE?**
- Record: Yes. Tree is p-6.12-2-gd38d58a4e0359, make kernelversion = **6.12.111**.
- cdc_info.flags = FLAG_ETHER | FLAG_POINTTOPOINT (no

    `FLAG_LINK_INTR`) at `cdc_ether.c:525`.
  - Catch-all `USB_INTERFACE_INFO(USB_CLASS_COMM,
    USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE)` at line 944.
  - No `0x046b` / `0xffb0` / `ami_bmc` in this driver.
  - `usbnet_cdc_status()` has the `netif_carrier_ok() !=
    !!event->wValue` filter (`2d5c9dd2cde33`).

- rx_complete() drops -ECONNRESET/-ESHUTDOWN via goto block.
- usbnet_probe() applies FLAG_LINK_INTR after register_netdev() (author said “before register_netdev”; in this tree it is after, but netif_carrier_off() is still synchronous and status URBs start at usbnet_open, so the quirk still works).

**Step 6.2 CHECK FOR BACKPORT COMPLICATIONS**
- Record: Clean apply expected. Surrounding cdc_info / Cinterion 0x1e2d:0x0069 / generic catch-all match the patch context. Line numbers differ slightly (6.12 vs later mainline); context is identical.

**Step 6.3 CHECK IF RELATED FIXES ARE ALREADY HERE**
- Record: No AMI BMC quirk. 2d5c9dd2cde33 is the prerequisite filter, already present. No alternate fix for this VID/PID.

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

**Step 7.1 IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
- Record: drivers/net/usb/cdc_ether.c — USB CDC Ethernet. **IMPORTANT** for hosts using this gadget (AMD Genoa/Turin BMC USB NIC), not core mm/VFS. Common on enterprise servers.

**Step 7.2 ASSESS SUBSYSTEM ACTIVITY**
- Record: Mature driver (2005). Ongoing ID/quirk additions. USB NETWORKING DRIVERS in MAINTAINERS is “Odd Fixes”, drivers/net/usb/.

## PHASE 8: IMPACT AND RISK ASSESSMENT

**Step 8.1 WHO IS AFFECTED**
- Record: Driver-specific / config-specific: CONFIG_USB_NET_CDCETHER and AMI BMC gadget 046b:ffb0 (AMD Genoa/Turin and similar AMI BMC platforms). Other CDC devices unchanged.

**Step 8.2 TRIGGER CONDITIONS**
- Record: AC cold boot; firmware queues stale OFF/ON; interface already open so RX URBs exist. Intermittent race with ARP DMA vs Stop Ring. Unprivileged users do not trigger it; it is a boot/enumeration path. Common on affected servers that use the BMC USB NIC.

**Step 8.3 FAILURE MODE SEVERITY**
- Record: Lost RX frames (ARP) → interface up but no L2 connectivity until ifdown/ifup or peer re-ARP. Not a panic. **HIGH** operational impact on affected hardware (host-BMC or provisioning network dead after cold boot).

**Step 8.4 RISK-BENEFIT RATIO**
- Record:
- **Benefit:** High for AMI BMC USB-Ethernet users on 6.12; fixes a real post-boot connectivity failure.
- **Risk:** Very low — 16 lines, one VID/PID, existing flag, no locking/API change.
- **Ratio:** Strongly favors backport.

## PHASE 9: FINAL SYNTHESIS

**Step 9.1 COMPILE THE EVIDENCE**

FOR:
- Real, reproduced connectivity bug with usbmon/xHCI evidence
- Hardware quirk + device ID on an existing driver (stable exception)
- 16-line contained change
- FLAG_LINK_INTR is a long-standing, well-understood usbnet mechanism
- Does not change generic cdc_info (avoids the 2010 permanent-DOWN regression)
- Prerequisite carrier filter already in 6.12
- Tested 100+ AC cold boots; netdev maintainer applied it
- Affects enterprise AMD server BMC networking

AGAINST:
- Not a crash/security issue
- No Reviewed-by in recovered mail (Kicinski still applied it)
- Affects one VID/PID, not all users
- Author slightly misstated probe vs register_netdev order (does not break the fix here)

UNRESOLVED:
- Could not use b4 dig (SHA absent) or lore.kernel.org (403)
- Could not confirm stable@ discussion
- Author’s other 71cc1fa9f2d7 subject string does not match this tree’s commit of that SHA (2010 revert) — rationale still holds

**Step 9.2 STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — standard flag, 100+ boot test, maintainer SOB
2. Fixes a real bug that affects users? **PASS** — silent NIC after AC cold boot
3. Important issue? **PASS** — connectivity loss / dropped RX (HIGH, not panic)
4. Small and contained? **PASS** — +16 lines, one file, one VID/PID
5. No new features or APIs? **PASS** — quirk/ID only
6. Can apply to the local tree? **PASS** — code and prerequisites present; clean context

**Step 9.3 EXCEPTION CATEGORIES**
- Record: **Hardware quirk/workaround** and **device ID addition to an existing driver**.

**Step 9.4 DECISION**
This should be backported to this 6.12 tree. It is a small, device- scoped quirk that fixes a real post-boot network failure on AMI BMC USB- Ethernet, using infrastructure that already exists here.

### What the commit solves
On AMD Genoa/Turin, the AMI BMC USB CDC gadget emits a stale link-OFF then link-ON right after cold-boot enumeration. Because CDC Ethernet starts with carrier on, that OFF is treated as a real link-down, RX URBs are unlinked, and in-flight ARP is dropped. The interface stays up but silent. Starting carrier off for this VID/PID only makes the stale OFF a no-op.

### Risk vs benefit
Benefit is restoring first-packet connectivity after AC cold boot on affected servers. Risk is limited to 046b:ffb0 and is the intended FLAG_LINK_INTR behavior.

### Concerns
None material for 6.12. Apply should be clean. Do not change generic cdc_info.

### Verification
- [Phase 1] Parsed tags: author SOB, msgid Link, Kicinski SOB; no Fixes/Cc-stable/Reported-by
- [Phase 2] Diff: +16 lines in cdc_ether.c; ami_bmc_info with FLAG_LINK_INTR; ID 0x046b:0xffb0 before catch-all
- [Phase 3] git describe HEAD / make kernelversion:
p-6.12-2-gd38d58a4e0359, **6.12.111**
- [Phase 3] git merge-base --is-ancestor 46651395… HEAD: commit not in this repo
- [Phase 3] git merge-base --is-ancestor 2d5c9dd2cde33 HEAD: yes (carrier filter present)
- [Phase 3] git show 71cc1fa9f2d71: 2010 partial revert removing FLAG_LINK_INTR from cdc_info
- [Phase 3] git blame usbnet_cdc_status: carrier check from 2d5c9dd2cde33
- [Phase 3] git log --oneline -20 -- drivers/net/usb/cdc_ether.c:
ID/quirk history; no AMI entry
- [Phase 3] git log --author="Jinhui Guo" -- drivers/net/usb/: empty in this tree
- [Phase 4] b4 dig -c <sha>: no match (SHA not local)
- [Phase 4] lore WebFetch: 403; used Openwall + Patchew instead
- [Phase 4] Author follow-up: usbmon OFF/ON ~130µs, xHCI -ECONNRESET length 1514, AC vs DC explanation
- [Phase 4] No NAK found; no v2 found
- [Phase 5] usbnet_probe FLAG_LINK_INTR → usbnet_link_change(dev,0,0) after register_netdev (lines 1861–1877)
- [Phase 5] __handle_link_change returns if !EVENT_DEV_OPEN; else unlink_urbs when carrier down
- [Phase 5] rx_complete -ECONNRESET/-ESHUTDOWN → goto block
- [Phase 5] usbnet_open starts interrupt URB then sets EVENT_DEV_OPEN
- [Phase 6] No ami_bmc/0x046b/0xffb0 in cdc_ether.c; catch-all still binds this device to cdc_info
- [Phase 6] FLAG_LINK_INTR defined in include/linux/usb/usbnet.h:122
- [Phase 6] USB_DEVICE_AND_INTERFACE_INFO exists in include/linux/usb.h
- [Phase 6] CONFIG_USB_NET_CDCETHER builds cdc_ether.o
- [Phase 7] HID confirms USB_VENDOR_ID_AMI 0x046b
- [Phase 8] Failure mode: dropped RX/ARP, silent interface — HIGH for this hardware
- UNVERIFIED: stable@ discussion (lore 403); exact mainline SHA not in this checkout

The patch is a textbook stable quirk: small, obviously correct, already tested, and the buggy code is in this tree.

**YES**

 drivers/net/usb/cdc_ether.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/net/usb/cdc_ether.c +16 -0
index a032c1ded4063..05e625a461b49 100644
@@ -532,6 +532,16 @@ static const struct driver_info	cdc_info = {
 	.manage_power =	usbnet_manage_power,
 };
 
+static const struct driver_info ami_bmc_info = {
+	.description =	"AMI BMC USB Ethernet",
+	.flags =	FLAG_ETHER | FLAG_POINTTOPOINT | FLAG_LINK_INTR,
+	.bind =		usbnet_cdc_bind,
+	.unbind =	usbnet_cdc_unbind,
+	.status =	usbnet_cdc_status,
+	.set_rx_mode =	usbnet_cdc_update_filter,
+	.manage_power =	usbnet_manage_power,
+};
+
 static const struct driver_info	zte_cdc_info = {
 	.description =	"ZTE CDC Ethernet Device",
 	.flags =	FLAG_ETHER | FLAG_POINTTOPOINT,
@@ -940,6 +950,12 @@ static const struct usb_device_id	products[] = {
 				      USB_CDC_SUBCLASS_ETHERNET,
 				      USB_CDC_PROTO_NONE),
 	.driver_info = (unsigned long)&wwan_info,
+}, {
+	/* AMI BMC gadget */
+	USB_DEVICE_AND_INTERFACE_INFO(0x046b, 0xffb0, USB_CLASS_COMM,
+				      USB_CDC_SUBCLASS_ETHERNET,
+				      USB_CDC_PROTO_NONE),
+	.driver_info = (unsigned long)&ami_bmc_info,
 }, {
 	USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET,
 			USB_CDC_PROTO_NONE),
Signature · 1 line
2.53.0
#296 lore raw

Re: [PATCH AUTOSEL 6.18-5.15] net: usb: cdc_ether: add quirk for AMI BMC stale link events

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

From: Jinhui Guo <[email protected]>

[ Upstream commit 089ca284afb0f3b2870a5ce41524cbc91ed350d4 ]

On AMD Genoa/Turin platforms the BMC-provided USB-Ethernet gadget (American Megatrends, VID 0x046b PID 0xffb0) intermittently fails to respond to ARP after AC cold boot. usbmon captures a stale NETWORK_CONNECTION(off) immediately followed by NETWORK_CONNECTION(on) on the interrupt endpoint (~130us apart) after enumeration. Because alloc_netdev() leaves __LINK_STATE_NOCARRIER cleared, netif_carrier_ok() returns true when the spurious OFF arrives, so usbnet_cdc_status() cannot recognise it as redundant and schedules EVENT_LINK_CHANGE. __handle_link_change() then calls unlink_urbs(), killing ~60 rx URBs whose payload has already been DMA'd into memory — xHCI trace [ ... ]

Quoted 4 lines

Sashiko has reviewed this patch and found no issues.

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