net: dsa: mt7530: check CORE_PLL_GROUP4 access in mt7531_setup()
Subsystems (71)
Sasha Levin
maintainerPATCH 1/1 ext4: reduce max cluster size to match documented 256MB limit
In reply to Sasha LevinFrom: Baokun Li <[email protected]>
[ Upstream commit afa3caf2fbc417f755f36e271c4b3c2d45ccda9d ]
The mke2fs man page documents:
Valid cluster-size values are from 2048 to 256M bytes per cluster.
but EXT4_MAX_CLUSTER_LOG_SIZE was set to 30 (1GB), allowing crafted filesystem images to specify cluster sizes up to 1GB.
On 32-bit systems with bigalloc enabled, the consistency check in ext4_handle_clustersize():
s_blocks_per_group == s_clusters_per_group * (clustersize / blocksize)
can overflow when the cluster ratio is large enough. Since s_blocks_per_group is not range-checked in the bigalloc path, the wrapped product can pass the consistency check, leading to inconsistent group geometry and potential out-of-bounds block allocation.
Reduce EXT4_MAX_CLUSTER_LOG_SIZE to 28 to match the documented 256MB limit. With this cap, the maximum product is:
(blocksize * 8) * (256M / blocksize) = 2^31
which fits safely in a 32-bit unsigned long for all block sizes.
---
LLM Generated explanations, may be completely bogus:
Local tree is **v7.3-rc4** (kernel 7.3.0-rc4, detached HEAD). The change is a one-line cap on ext4 bigalloc cluster size to stop a 32-bit overflow on crafted images.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[ext4]** **[reduce]** reduce EXT4_MAX_CLUSTER_LOG_SIZE from 30 (1GB) to 28 (256MB) to match the documented mke2fs limit and stop a 32-bit overflow.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Reported-by:** Sashiko <[email protected]> (automated kernel review, not syzbot)
- **Closes:** https://sashiko.dev/#/patchset/20260608061112.392391-1-
libaokun%40linux.alibaba.com (v1 series)
- **Reviewed-by:** Andreas Dilger <[email protected]> (ext4 co- maintainer)
- **Link:** https://patch.msgid.link/20260608111150.827117-3-
[email protected]
- **Signed-off-by:** Baokun Li <[email protected]> (author)
- **Signed-off-by:** Theodore Ts'o <[email protected]> (ext4 maintainer; applied the series)
- **Fixes:** none (expected for this review pipeline)
- **Cc: stable:** none (expected)
- Ignore pipeline markers: none present in the supplied message beyond the usual evaluation context
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** EXT4_MAX_CLUSTER_LOG_SIZE was 30, so crafted bigalloc images can claim cluster sizes up to 1GB. mke2fs only documents 2048–256MB.
- **Symptom/failure mode:** On 32-bit, s_clusters_per_group * (clustersize / blocksize) in ext4_handle_clustersize() wraps. s_blocks_per_group is not range-checked on the bigalloc path, so the wrapped product can pass the consistency check. That yields inconsistent group geometry and possible out-of-bounds block allocation.
- **Version info:** none beyond “32-bit systems with bigalloc”.
- **Root cause (author):** cluster-size cap is too high; product can exceed 32-bit unsigned long.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. The message names overflow, crafted images, and OOB allocation. It is an explicit mount-time sanity fix.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File:** fs/ext4/ext4.h — 1 line changed (30 → 28)
- **Functions:** none; only #define EXT4_MAX_CLUSTER_LOG_SIZE
- **Scope:** single-file, one-constant surgical fix
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** __ext4_fill_super() rejects s_log_cluster_size only if it is greater than 30 - 10 = 20, so clustersize = BLOCK_SIZE << log = 1024 << 20 = 1GB is accepted.
- **After:** max log is 28 - 10 = 18, so max cluster size is 1024 << 18 = 256MB.
- **Path:** mount-time superblock validation in __ext4_fill_super(), before ext4_handle_clustersize().
Verified use site:
```5196:5202:fs/ext4/super.c
if (le32_to_cpu(es->s_log_cluster_size) >
(EXT4_MAX_CLUSTER_LOG_SIZE - EXT4_MIN_BLOCK_LOG_SIZE)) {
ext4_msg(sb, KERN_ERR,
"Invalid log cluster size: %u",
le32_to_cpu(es->s_log_cluster_size));
goto out;
}
```**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** integer overflow in mount-time geometry check, leading to inconsistent geometry / possible OOB block allocation (memory- safety / filesystem-image robustness).
- **Mechanism:** s_blocks_per_group and s_clusters_per_group are unsigned long (fs/ext4/ext4.h). The check is:
```4500:4506:fs/ext4/super.c
if (sbi->s_blocks_per_group !=
(sbi->s_clusters_per_group * (clustersize /
sb->s_blocksize))) {
ext4_msg(sb, KERN_ERR,
"blocks per group (%lu) and clusters per group
(%lu) inconsistent",
sbi->s_blocks_per_group,
sbi->s_clusters_per_group);
return -EINVAL;
}
```s_clusters_per_group is capped at blocksize * 8. Max product is (blocksize * 8) * (clustersize / blocksize) = 8 * clustersize.
- With 1GB clusters: 8 * 2^30 = 2^33 → wraps on 32-bit unsigned long.
- With 256MB clusters: 8 * 2^28 = 2^31 → fits in 32-bit unsigned long.
The s_blocks_per_group > sb->s_blocksize * 8 range check is only on the **non-bigalloc** branch (verified in ext4_handle_clustersize()).
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- **Quality:** obviously correct. Tightens an existing mount-time bound to the documented mkfs limit; the overflow math is checkable by inspection.
- **Regression risk:** very low. mke2fs documents max 256MB; Andreas Dilger noted real-world >1GB clusters are implausible. A 512MB (log
29) filesystem would also be rejected; Jan Kara said 28 or 29 were both acceptable. **29 is not overflow-safe:** 8 * 512MB = 2^32 wraps to 0 on 32-bit unsigned long. 28 is the right cap. Ted applied 28.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Current line (already 28 in this checkout): afa3caf2fbc41 Baokun Li, 2026-06-08 — the candidate itself.
- Previous value 30 introduced by **9e47a4c9fc580** (“ext4: sanity check the block and cluster size at mount time”, Ted Ts'o, 2016-11-18), first in **v4.10-rc1**. Duplicate in-tree copy:
8cdf3372fe836.
- That original commit was **Cc: stable** and cited security refs (SecurityFocus 539661, RH BZ 1332506). The 1GB cap has been in place since then.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. The overflow is in the interaction of the 2016 cap (9e47a4c9fc580, in this tree) and the bigalloc consistency multiply (bigalloc from 281b59959707d, **v3.2-rc1**). Both ancestors of HEAD.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record:
- This is **v2 2/3** of “ext4: tighten mount-time superblock geometry validation”.
- Sibling **1/3:** d42dc7726a003 — 8-alignment of clusters/inodes per group (bitmap csum).
- Sibling **3/3:** a34de48f329b2 — inodes-per-group multiple of inodes-per-block.
- Cover letter (Ted applied 2026-07-23): patches 2 and 3 were added in v2 for additional Sashiko issues and are **independent of patch 1**.
- This commit is standalone: only the #define in ext4.h. No prerequisite from 1/3 or 3/3.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Baokun Li is a regular, high-volume ext4 contributor (many recent ext4 commits in this tree). Series was reviewed by Dilger/Kara/Zhang Yi and applied by Ted Ts'o.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: None required. EXT4_MAX_CLUSTER_LOG_SIZE and the s_log_cluster_size check exist here. The define is the only consumer besides ext4.h itself (git grep shows only fs/ext4/ext4.h and fs/ext4/super.c). Applies standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **b4 dig -c afa3caf2fbc41:** matched [PATCH v2 2/3] at https://patch
.msgid.link/[email protected]
- **b4 dig -a:** series is **v2** “ext4: tighten mount-time superblock geometry validation” (2026-06-08). v1 was only patch 1; patches 2–3 are new in v2.
- **Jan Kara** (2026-06-09): no NAK; defer 28 vs 29 to Ted; both fine if consistent.
- **Andreas Dilger** (2026-06-08): Reviewed-by; “pretty safe”; doubts anyone uses >1GiB clusters.
- **Ted Ts'o** (2026-07-23): “Applied, thanks!” with this SHA.
- No NAKs. No reviewer Cc: stable in the thread (absence expected).
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (**b4 dig -w**): linux-ext4, tytso, adilger, [email protected], [email protected], [email protected], [email protected], Sashiko. Maintainers and regular reviewers were on the To/Cc list. Dilger R-b; Ted applied.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: Sashiko is an LF/Google automated review bot, not a user crash or syzbot repro. The Closes URL is the v1 patchset page (SPA; fetch returned the Sashiko landing page, not the finding text). Cover letter:
patches 2 and 3 fix additional Sashiko-reported issues. Severity from the patch itself: crafted-image overflow → inconsistent geometry / OOB allocation.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Three independent mount-time checks. This one does not need 1/3 or 3/3 to be correct. Siblings are also real bugfixes but out of scope for this verdict.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable returned 403. Openwall/web search found no stable-list rejection of this patch. UNVERIFIED whether anyone already requested it on stable@.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: No function body changed. Consumer: __ext4_fill_super() cluster-log check; downstream user of the accepted size:ext4_handle_clustersize().
**Step 5.2: TRACE CALLERS**
Record:
- ext4_handle_clustersize() is static; only caller is __ext4_fill_super() at mount (fs/ext4/super.c:5451).
- ext4_fill_super() is the VFS mount entry (:5835).
- Context: filesystem mount, not IRQ/hot path.
**Step 5.3: TRACE CALLEES**
Record: The define is only compared in the mount validator. No new calls.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace mount of an ext4 image (mount, loop, USB, VM disk) → ext4_fill_super → __ext4_fill_super → log-cluster check → ext4_handle_clustersize(). Reachable from any ext4 mount of a bigalloc image. Triggering the overflow needs a crafted superblock (untrusted image), typically CAP_SYS_ADMIN to mount, still the usual malicious- filesystem class.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same series adds two other geometry checks. Same class of crafted-image bugs. No other EXT4_MAX_CLUSTER_LOG_SIZE sites.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record:
- Tree: **v7.3-rc4-27-gf0100363d8c37**, VERSION=7 PATCHLEVEL=3 SUBLEVEL=0 EXTRAVERSION=-rc4.
- git merge-base --is-ancestor afa3caf2fbc41 HEAD → commit **is** in HEAD (landed via ext4-for-linus 7.3-rc1). Current #define is already 28.
- That does **not** mean “already selected for stable”; it is the mainline landing. The **bug mechanism** (32-bit multiply of s_clusters_per_group by cluster ratio, uncapped s_blocks_per_group on bigalloc) is still in ext4_handle_clustersize() here; only the cap is 28.
- Bug class has existed since the 2016 cap (9e47a4c9fc580 is an ancestor). Code is not missing.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: Expected apply: **clean**. One-line #define change in fs/ext4/ext4.h. Macro and check have been stable since 2016 / the 2022 ext4_handle_clustersize() factor-out (4a8557b094671).
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This is the fix. No earlier alternate cap. No follow-up revert or tightening of this define after afa3caf2fbc41 in fs/ext4/ext4.h.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **ext4** (fs/ext4/). **IMPORTANT** — default Linux filesystem; crafted-image bugs affect anyone who mounts untrusted ext4 (install media, USB, VMs, backups).
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively developed (ext4_for_linus pulls this cycle). The overflow is in long-standing mount validation, not new BS>PS work.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Filesystem-specific (ext4)**, extra conditions: **bigalloc + 32-bit unsigned long + cluster size > 256MB**. 64-bit does not wrap at 1GB, but the looser cap still allows undocumented cluster sizes. 32-bit still matters (embedded, some Android/i686).
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Mount of a crafted bigalloc image with large s_log_cluster_size. Not every boot. Not an unprivileged syscall by itself (mount is privileged), but standard untrusted-image attack. Not a timing race.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: Integer overflow bypass of geometry check → inconsistent groups → **potential out-of-bounds block allocation**. Severity **HIGH** (memory corruption / OOB on crafted mount). Not a guaranteed panic on every mount, but it is a real robustness/security class that stable routinely takes.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** high for 32-bit ext4 mounts of untrusted images; aligns kernel with documented mkfs limit.
- **Risk:** very low (one constant; Dilger R-b; Ted applied). Only theoretical regression is rejecting 512MB/1GB cluster filesystems that mke2fs would not create.
- **Ratio:** strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real 32-bit overflow in mount-time geometry check; wrapped product can pass; OOB allocation is the stated consequence.
- One-line, obviously correct cap matching mke2fs (256MB).
- 28 is the max value that keeps 8 * clustersize ≤ 2^31 on 32-bit.
- Reviewed by Andreas Dilger; applied by Ted Ts'o; Jan Kara did not object.
- Independent of the rest of the series.
- Affected code present since v4.10; applies cleanly.
- Same class as the original 2016 cluster-size sanity check (that one was Cc: stable).
AGAINST:
- Trigger needs crafted bigalloc + typically 32-bit.
- No Fixes: / Cc: stable (not a negative per rules).
- Sashiko is a bot, not a production crash with a reproducer.
- Jan Kara floated 29; that value still overflows (verified); committed value is 28.
UNRESOLVED:
- Stable@ discussion (lore/stable 403).
- Full Sashiko finding text (SPA page).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — one-constant change; maintainer-applied; Dilger R-b.
2. Fixes a real bug that affects users? **PASS** — overflow on crafted bigalloc mount.
3. Important issue (crash, security, corruption, deadlock)? **PASS** —
HIGH: overflow → bad geometry / possible OOB allocation.
4. Small and contained? **PASS** — 1 line, 1 file.
5. No new features or APIs? **PASS** — tightens an existing limit.
6. Can apply to the local tree? **PASS** — define and check exist; patch is a single substitution.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not an ID/quirk/DT/build/docs exception. It is a normal small correctness/security-style mount check.
**Step 9.4: MAKE YOUR DECISION**
This tree has the ext4 mount path, the overflow-prone multiply, and the too-large historical cap. The fix is a one-line tightening to the documented 256MB limit so the 32-bit product cannot wrap. Independent, reviewed, and low regression risk. It should be backported here.
------------------------------------------------
What the commit solves and why it matters
------------------------------------------------
Crafted ext4 bigalloc images can set cluster size up to 1GB. On 32-bit, the groups-per-cluster consistency multiply wraps, so a bogus s_blocks_per_group can look consistent. That can produce wrong group geometry and out-of-bounds block allocation when the image is mounted. Capping at 256MB matches mke2fs and keeps the product at 2^31.
------------------------------------------------
Stable rules / risk vs benefit
------------------------------------------------
Meets all six criteria: real overflow, small, no API, applies cleanly. Benefit is blocking a crafted-image OOB path; risk is rejecting undocumented huge clusters that tools do not create.
------------------------------------------------
Concerns
------------------------------------------------
No extra series deps. No backport rework expected. 32-bit-centric, but still a valid stable-class filesystem-image bug.
Verification:
- [Phase 1] Parsed tags: Reported-by Sashiko; Reviewed-by Andreas Dilger; SOB Baokun Li + Ted Ts'o; Link msgid 20260608111150.827117-3; no Fixes/Cc:stable
- [Phase 1] Cover letter (openwall/spinics): v2 2/3 independent of 1/3; overflow on 32-bit bigalloc
- [Phase 2] Diff: 1 line in fs/ext4/ext4.h, 30→28
- [Phase 2] Read ext4_handle_clustersize(): s_blocks_per_group range check only on non-bigalloc; multiply at lines 4500–4501
- [Phase 2] Types: s_blocks_per_group / s_clusters_per_group are unsigned long (ext4.h:1595–1596)
- [Phase 2] Math: max product 8*clustersize; 1GB → 2^33 wrap; 256MB → 2^31; 512MB → 2^32 wrap (29 unsafe)
- [Phase 2] Consumer: __ext4_fill_super log-cluster check at super.c:5196–5202
- [Phase 3] git blame: current 28 from afa3caf2fbc41; 30 from 9e47a4c9fc580 (2016-11-18, v4.10-rc1, Cc:stable)
- [Phase 3] git merge-base --is-ancestor 9e47a4c9fc580 HEAD: yes
- [Phase 3] git merge-base --is-ancestor afa3caf2fbc41 HEAD: yes (mainline landing, not used as circular “already selected”)
- [Phase 3] Series siblings d42dc7726a003 and a34de48f329b2 are independent; this patch only touches the define
- [Phase 3] git grep EXT4_MAX_CLUSTER_LOG_SIZE: only ext4.h and super.c
- [Phase 4] b4 dig -c: lore msgid 20260608111150.827117-3
- [Phase 4] b4 dig -a: v2 series 2026-06-08; v1 was patch 1 only
- [Phase 4] b4 dig -w: tytso, dilger, jack, linux-ext4 on original To/Cc
- [Phase 4] Jan Kara: 28 vs 29 up to Ted, no NAK
- [Phase 4] Andreas Dilger: Reviewed-by; safe, nobody using >1GiB clusters
- [Phase 4] Ted: Applied 2026-07-23 as afa3caf2fbc41
- [Phase 4] lore.kernel.org/stable: 403, UNVERIFIED
- [Phase 4] sashiko.dev hash URL: landing page only, UNVERIFIED full finding text
- [Phase 5] Only caller of ext4_handle_clustersize: __ext4_fill_super (mount)
- [Phase 6] git describe HEAD: v7.3-rc4-27-gf0100363d8c37; make kernelversion 7.3.0-rc4
- [Phase 6] Buggy cap/check present in this lineage since v4.10; apply is a one-line define swap
- [Phase 8] Failure mode: 32-bit overflow → inconsistent geometry / possible OOB alloc, severity HIGH
- UNVERIFIED: stable@ thread; full Sashiko report body
**YES**
fs/ext4/ext4.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/ext4.h +1 -1
@@ -334,7 +334,7 @@ struct ext4_io_submit {#define EXT4_MAX_BLOCK_SIZE 65536#define EXT4_MIN_BLOCK_LOG_SIZE 10#define EXT4_MAX_BLOCK_LOG_SIZE 16 -#define EXT4_MAX_CLUSTER_LOG_SIZE 30 +#define EXT4_MAX_CLUSTER_LOG_SIZE 28#ifdef __KERNEL__# define EXT4_BLOCK_SIZE (s) ((s)->s_blocksize)#else
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-5.10] ext4: reduce max cluster size to match documented 256MB limit
Sashiko has reviewed this patch and found no issues.
Quoted 14 lines
From: Baokun Li <[email protected]>
[ Upstream commit
afa3caf2fbc417f755f36e271c4b3c2d45ccda9d]The mke2fs man page documents:
Valid cluster-size values are from 2048 to 256M bytes per cluster.
but
EXT4_MAX_CLUSTER_LOG_SIZEwas set to 30 (1GB), allowing crafted filesystem images to specify cluster sizes up to 1GB.On 32-bit systems with bigalloc enabled, the consistency check in
ext4_handle_clustersize():
Quoted 7 lines
s_blocks_per_group==s_clusters_per_group* (clustersize / blocksize)[ ... ]Signed-off-by Baokun Li <[email protected]>Reviewed-by Andreas Dilger <[email protected]>Signed-off-by Theodore Ts'o <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 s390/mm: Add missing mm check to do_secure_storage_access()
In reply to Sasha LevinFrom: Heiko Carstens <[email protected]>
[ Upstream commit 7cf227b2707ed0129018c283ffc8f893945586db ]
Similar like the normal exception handler the secure storage access exception handler needs to verify if mm is not NULL, which may happen with kernel threads.
---
LLM Generated explanations, may be completely bogus:
The local tree is **7.3.0-rc4** (v7.3-rc4-27-gf0100363d8c37). The candidate is 7cf227b2707ed (“s390/mm: Add missing mm check to do_secure_storage_access()”). The function and the unguarded current->mm path exist here; the decision is whether this fix belongs in this tree on technical merit.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1 — Subject line**
- Record: **[s390/mm]** **[Add]** missing mm check in do_secure_storage_access(). “Add missing … check” is a correctness fix, not a feature.
**Step 1.2 — Tags**
- Record:
- Reported-by: sashiko-bot <[email protected]> — static/AI review, not syzbot
- `Closes: https://lore.kernel.org/all/20260717132345.539A11F00A3A@smt
p.kernel.org/` - `Signed-off-by: Heiko Carstens <[email protected]>` (author; s390 architecture maintainer) - `Reviewed-by: Christian Borntraeger <[email protected]>` (KVM/s390)
- Signed-off-by: Vasily Gorbik <[email protected]> (s390 maintainer, applied)
- No Fixes:, no Cc: stable (expected for this pipeline)
- Ignore any Sasha Levin SOB (none on the real commit)
**Step 1.3 — Body**
- Record:
- **Bug:** secure-storage exception handler did not check `current->mm
!= NULL`, unlike `do_exception()`.
- **Symptom:** kernel thread with `mm == NULL` can hit PGM 0x3d and
then `mmap_read_lock(NULL)`.
- **Failure mode:** NULL dereference in the exception handler.
- **Root cause:** user-fault path assumed `current->mm` was always
valid.
- **Version info:** none in the message. Function dates to 2020
(`084ea4d611a3d0`).**Step 1.4 — Hidden bug fix?**
- Record: Not hidden. Explicit missing-check / NULL-deref fix. Not cleanup disguised as a fix.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1 — Inventory**
- Record:
- File: arch/s390/mm/fault.c (+2 / −3)
- Function: do_secure_storage_access()
- Scope: single-file surgical fix
**Step 2.2 — Code flow**
- Record:
- **Before:** user-fault path did if (faulthandler_disabled()) then
`mm = current->mm; mmap_read_lock(mm)`.
- **After:** `mm = current->mm` is taken first; path is `if
(faulthandler_disabled() || !mm) return
handle_fault_error_nolock(regs, 0);` - Affected path: non-kernel-fault PGM 0x3d (user mode, or kernel uaccess via secondary space).
- handle_fault_error_nolock() is already the no-lock fallback: user SIGSEGV, or kernel fixup_exception() / oops.
**Step 2.3 — Bug mechanism**
- Record:
- **Category:** memory safety — NULL pointer dereference
- **Mechanism:** mmap_read_lock(mm) with mm == NULL (kernel thread).
- **Fix:** same !mm guard as do_exception() at line 285.
**Step 2.4 — Fix quality**
- Record:
- Obviously correct: one extra condition, same pattern as the normal fault handler.
- Minimal; no unrelated edits.
- Regression risk is very low: the new path only avoids locking a NULL mm. For kernel uaccess, handle_fault_error_nolock() runs exception fixups and returns -EFAULT, which is the intended behavior (same as do_exception() and as 11709abccf93b for atomic context).
---
## PHASE 3: GIT HISTORY
**Step 3.1 — Blame**
- Record:
- do_secure_storage_access() introduced in 084ea4d611a3d0
(2020-01-21): already did `mm = current->mm;
down_read(&mm->mmap_sem)` with no NULL check.
- `11709abccf93b` (2025-06-03) added `faulthandler_disabled()` after a
real qemu crash (`copy_page_from_iter_atomic` → PGM 0x3d while
`in_atomic`), but still assigned `mm = current->mm` afterward with
no `!mm` check.
- The `!mm` check on this path is `7cf227b2707ed` itself.
- `do_exception()` has had `faulthandler_disabled() || !mm` for years
(`a12d622ad541b5` / `70ffdb9393a72`).**Step 3.2 — Fixes: tag**
- Record: No Fixes: tag. The incomplete guard is from 11709abccf93b (in this tree). The NULL-mm hole has existed since the handler was added in 2020.
**Step 3.3 — File history**
- Record: This is v4 2/8 of “Reintroduce support for DCACHE_WORD_ACCESS”. Neighbors:
- 1/8 VM_SPARSE (unrelated feature)
- 3/8 lock_mm_and_find_vma() (refactor; still needs mm != NULL)
- 4–7 more handler cleanups
- 8/8 DCACHE_WORD_ACCESS feature
- This patch is standalone. It does not depend on 1/8 or 8/8.
**Step 3.4 — Author**
- Record: Heiko Carstens is s390 architecture maintainer (MAINTAINERS:
S390 ARCHITECTURE). He wrote the 2025 atomic-context fix and this follow-up. Borntraeger reviewed.
**Step 3.5 — Prerequisites**
- Record: None. It only adds || !mm next to an existing faulthandler_disabled() check. Applies standalone on this tree’s fault.c.
---
## PHASE 4: MAILING LIST / EXTERNAL
**Step 4.1 — Original discussion**
- Record:
- b4 dig -c 7cf227b2707ed →
https://patch.msgid.link/[email protected]
- b4 dig -a: v1/v2 were VM_SPARSE-only; v3 “Reintroduce DCACHE_WORD_ACCESS”; v4 is the applied series. This mm-check first appears as v4 2/8.
- Sashiko report (Closes:): **[High] Missing !mm check … kernel threads faulting on user-space accesses … NULL pointer dereference.** Example given: copy_from_user() onto a secure page from a kernel thread, then mmap_read_lock(NULL).
- Alexander Gordeev (S390 MM) called that sashiko note a **false positive** on a related patch.
- Heiko still took the check: he wanted the handler to match do_exception() and to address the sashiko reports. Borntraeger gave Reviewed-by on this exact patch. No NAK.
**Step 4.2 — Recipients (b4 dig -w)**
- Record: Heiko, Gordeev, Schnelle, Gorbik, Borntraeger, Frank, Imbrenda, Hildenbrand; linux-s390@, kvm@, linux-kernel@. Right maintainers were on CC.
**Step 4.3 — Bug report**
- Record: Sashiko static finding, severity High. Not a user crash log for the !mm case. The related 2025 bug *was* a real qemu oops on this same handler. WebFetch/curl to lore returned 403; thread was recovered with b4 mbox.
**Step 4.4 — Series**
- Record: Bundled with a feature series, but this hunk is an independent NULL check. Other 2/8–7/8 patches are not required for this guard.
**Step 4.5 — Stable list**
- Record: **UNVERIFIED** — lore.kernel.org /stable/ returned 403. No stable discussion found in the saved v4 mbox (no Cc: stable in review).
---
## PHASE 5: CODE SEMANTICS
**Step 5.1 — Functions**
- Record: do_secure_storage_access() only.
**Step 5.2 — Callers**
- Record: Trap table in arch/s390/kernel/traps.c: [0x3d] = do_secure_storage_access. Hardware PGM 0x3d (secure storage access). COND_TRAP weak-aliases to default_trap_handler if the symbol is absent. Reached from __do_pgm_check → exception handler, not a normal syscall helper.
**Step 5.3 — Callees**
- Record: After the check: lock_mm_and_find_vma / mmap_read_lock, folio_walk_*, arch_make_folio_accessible. On the new path:
handle_fault_error_nolock() only (no lock, no folio walk).
**Step 5.4 — Reachability**
- Record: is_kernel_fault() is false for user mode, or kernel mode with teid.as == PSW_BITS_AS_SECONDARY (uaccess). User processes have an mm. Kernel threads have current->mm == NULL unless use_mm().
- Reachable in principle: kernel-thread uaccess to a secure page without use_mm().
- Confirmed real traffic on this handler: 11709abccf93b stack (qemu vfs_write → copy_page_from_iter_atomic → PGM 0x3d). Those tasks have an mm; they hit the atomic case, not !mm.
- Userspace-reachable for normal tasks: yes, but they have mm, so this check does not change that path.
**Step 5.5 — Similar patterns**
- Record: do_exception() already uses is_kernel_fault() || faulthandler_disabled() || !mm. This commit brings the secure handler in line. No other copy of this hole in fault.c.
---
## PHASE 6: LOCAL TREE
**Step 6.1 — Does the buggy code exist here?**
- Record: Yes. Tree is **7.3.0-rc4**. do_secure_storage_access() is in arch/s390/mm/fault.c under CONFIG_KVM. Current source already has if (faulthandler_disabled() || !mm) at line 451 (git merge-base --is-ancestor 7cf227b2707ed HEAD succeeded). The unguarded mmap_read_lock(current->mm) pattern was present from 2020 until this commit (v7.3-rc1).
**Step 6.2 — Backport difficulty**
- Record: Clean apply on this tree. Later refactors (lock_mm_and_find_vma, goto, __context_unsafe) still keep the !mm check.
**Step 6.3 — Related fixes already here?**
- Record: 11709abccf93b is here (atomic/faulthandler_disabled only). No earlier !mm fix on this path. This commit is the !mm fix.
---
## PHASE 7: SUBSYSTEM
**Step 7.1**
- Record: **s390 MM / Secure Execution (Ultravisor) exception handling**. Criticality: **IMPORTANT** on s390 with KVM/protected virtualization; not core-universal. Not staging.
**Step 7.2**
- Record: Active. Multiple 2025–2026 fixes on this same function (atomic handling, donated-memory fixups, folio_walk, vmalloc). Mature handler, still getting real-bug fixes.
---
## PHASE 8: IMPACT AND RISK
**Step 8.1 — Who is affected**
- Record: s390 systems with CONFIG_KVM that take PGM 0x3d (Secure Execution / protected virt). Not universal.
**Step 8.2 — Trigger**
- Record: Kernel thread (current->mm == NULL) takes a user/secondary- space secure-storage exception (e.g. uaccess to a secure page). Unprivileged users do not directly set mm to NULL. Likelihood is lower than the 2025 atomic qemu case; Gordeev called the sashiko report a false positive. Heiko still treated the check as required for parity with do_exception().
**Step 8.3 — Failure mode**
- Record: mmap_read_lock(NULL) → kernel oops. **Severity: HIGH** if the path runs; **MEDIUM** if it is only defensive. Exception-handler NULL deref is still a crash class of bug.
**Step 8.4 — Risk vs benefit**
- Record:
- **Benefit:** Medium–high. Prevents an oops on a path that already crashed qemu in atomic context; completes the standard three-way fault-handler guard.
- **Risk:** Very low. One condition, error-path only, same semantics
as `do_exception()`.
- **Ratio:** Favor including it.
---
## PHASE 9: SYNTHESIS
**Step 9.1 — Evidence**
**For:**
- Real NULL-deref if mm is NULL before mmap_read_lock().
- Same guard do_exception() has used for years.
- Same function already needed a production fix (11709abccf93b) for kernel uaccess to secure pages.
- 5-line, obviously correct change; handle_fault_error_nolock() is the right fallback (exception fixup / -EFAULT).
- Written by the s390 arch maintainer; Reviewed-by Borntraeger.
- Sashiko rated the hole High and described the copy_from_user + kernel-thread scenario.
- Code exists in this 7.3-rc4 tree; no missing prerequisites.
**Against:**
- Gordeev called the sashiko !mm note a false positive (may not be hit by real kernel threads that use use_mm()).
- No live crash log for the !mm case (sashiko static analysis).
- s390 + KVM + Secure Execution only.
- Landed as 2/8 of a feature series (the hunk itself is independent).
**Unresolved:**
- Stable-list history (lore /stable/ 403).
- No public reproducer of a kernel-thread !mm crash.
**Step 9.2 — Stable rules**
1. Obviously correct and tested? **PASS** — one condition, reviewed by KVM/s390, applied by s390 maintainer.
2. Fixes a real bug that affects users? **PASS** — NULL mm then mmap_read_lock() is a real oops; sibling path already crashed qemu. Trigger may be uncommon, but the hole is real.
3. Important (crash/security/corruption/deadlock)? **PASS** — exception- handler NULL deref / oops.
4. Small and contained? **PASS** — +2/−3 in one function.
5. No new features/APIs? **PASS**.
6. Applies to this tree? **PASS** — fault.c and the user-fault path are present; patch is trivial here.
**Step 9.3 — Exceptions**
- Record: None (not a device ID, quirk, DT, build, or docs fix). Qualifies as a normal crash-prevention fix.
**Step 9.4 — Decision**
This tree has the handler and had the unguarded mm use. The fix is a one-line NULL check that matches do_exception() and closes a crash path in the PGM 0x3d handler. Benefit outweighs risk.
---
### What the commit solves (for this tree)
do_secure_storage_access() handles s390 PGM 0x3d. On the user/secondary-space path it took mmap_read_lock(current->mm) without checking mm. Kernel threads have mm == NULL, so that is a NULL deref. do_exception() already checks faulthandler_disabled() || !mm. The 2025 commit added only the atomic half after a qemu oops; this commit adds the missing !mm half. On this 7.3-rc4 tree the function exists and the check is the right fix.
### Risk vs benefit
Very low risk, meaningful crash-prevention benefit on s390 KVM/Secure Execution. No API or structural change.
---
Verification:
- [Phase 1] Parsed tags: Reported-by sashiko-bot; Closes lore msgid 20260717132345.539A11F00A3A; Reviewed-by Borntraeger; SOB Heiko + Gorbik; no Fixes/Cc-stable
- [Phase 1] Body: kernel-thread mm == NULL vs normal exception handler
- [Phase 2] Diff: arch/s390/mm/fault.c +2/−3; if (faulthandler_disabled() || !mm) then handle_fault_error_nolock
- [Phase 2] Confirmed handle_fault_error_nolock() does fixup/SIGSEGV/oops and does not unlock mm
- [Phase 3] git show 7cf227b2707ed; ancestor of HEAD
- [Phase 3] Blame: function from 084ea4d611a3d0 (2020); !mm on do_exception long-standing; faulthandler_disabled only from 11709abccf93b (2025)
- [Phase 3] git show 11709abccf93b: real qemu stack, sleeping on mmap_lock in atomic PGM 0x3d
- [Phase 3] Series neighbors 79ef8d384fdfb…46a8c8d142ba8 do not replace this check
- [Phase 4] b4 dig -c 7cf227b2707ed:
https://patch.msgid.link/[email protected]
- [Phase 4] b4 dig -a: v4 is the applied series; this is 2/8
- [Phase 4] b4 dig -w: s390 + KVM maintainers on CC
- [Phase 4] b4 mbox of Closes: sashiko [High] NULL deref; Gordeev “false positive”; Heiko still aligned with do_exception()
- [Phase 4] WebFetch/curl lore: 403; UNVERIFIED: stable@ discussion
- [Phase 5] git grep do_secure_storage_access: traps.c PGM 0x3d + entry.h
- [Phase 5] Read is_kernel_fault(): user mode or secondary AS → user path
- [Phase 6] git describe HEAD = v7.3-rc4-27-gf0100363d8c37; make kernelversion = 7.3.0-rc4
- [Phase 6] Current fault.c:451 has faulthandler_disabled() || !mm
- [Phase 7] MAINTAINERS: Heiko = S390 ARCHITECTURE; Gordeev = S390 MM
- [Phase 8] Failure mode: NULL deref in exception handler; trigger narrower than the 2025 atomic bug
- UNVERIFIED: whether a kernel thread without use_mm() has hit this on a production machine; Gordeev doubted it
The fix is small, matches the existing fault-handler contract, and prevents an oops on this tree’s s390 secure-storage path.
**YES**
arch/s390/mm/fault.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/s390/mm/fault.c +2 -3
@@ -404,9 +404,9 @@ void do_secure_storage_access(struct pt_regs *regs) {union teid teid = { .val = regs->int_parm_long };unsigned long addr =get_fault_address (regs); +struct mm_struct *mm = current->mm;struct vm_area_struct *vma;struct folio_walk fw; -struct mm_struct *mm;struct folio *folio;int rc;
@@ -448,9 +448,8 @@ void do_secure_storage_access(struct pt_regs *regs)if (rc)return handle_fault_error_nolock (regs,0 ); }else { -if (faulthandler_disabled ()) +if (faulthandler_disabled () || !mm)return handle_fault_error_nolock (regs,0 ); - mm = current->mm;mmap_read_lock (mm); vma =find_vma (mm, addr);if (!vma)
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18] s390/mm: Add missing mm check to do_secure_storage_access()
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines
From: Heiko Carstens <[email protected]>
[ Upstream commit
7cf227b2707ed0129018c283ffc8f893945586db]Similar like the normal exception handler the secure storage access exception handler needs to verify if mm is not NULL, which may happen with kernel threads.
Quoted 6 lines
Reported-by sashiko-bot <[email protected]>Signed-off-by Heiko Carstens <[email protected]>Reviewed-by Christian Borntraeger <[email protected]>> ---Signed-off-by Vasily Gorbik <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 ksmbd: enable TCP keepalive for accepted connections
In reply to Sasha LevinFrom: Namjae Jeon <[email protected]>
[ Upstream commit 56549c18a4f75309161ca780feaa4d17904e3ee9 ]
A client that disappears without sending a FIN or RST can leave its ksmbd connection in ESTABLISHED indefinitely. ksmbd sets a socket receive timeout, but the connection receive loop retries timeout errors without a limit, so the connection remains in conn_list and consumes the per-IP connection quota.
Enable SO_KEEPALIVE on accepted TCP sockets so the TCP stack can detect a silent peer failure. The keepalive idle time, interval, and probe count remain controlled by the existing TCP sysctl settings.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). The buggy accept/receive path is present, and this is a small, real connection- leak fix that belongs here.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[ksmbd]** **[enable]** Enable TCP keepalive on accepted ksmbd sockets so a silent peer does not leave the connection ESTABLISHED forever.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Signed-off-by:** Namjae Jeon <[email protected]> (ksmbd maintainer)
- No **Fixes:**, **Reported-by:**, **Tested-by:**, **Reviewed-by:**, **Acked-by:**, **Link:**, or **Cc: stable** on this commit (absence expected for this review)
- Companion later commit 80b6367ec37f has `Link:
https://github.com/openwrt/openwrt/issues/24744` (different bug: FIN- WAIT-1 orphans)
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** Client vanishes without FIN/RST; ksmbd connection stays ESTABLISHED.
- **Mechanism:** sk_rcvtimeo is set, but the receive loop retries timeout/-EAGAIN with no limit, so the conn stays in conn_list and consumes the per-IP quota.
- **Fix:** sock_set_keepalive() on the accepted socket; idle/interval/probes stay on existing TCP sysctls.
- **Symptom:** leaked kthreads/sockets and eventual refusal of new clients from that IP.
- **Version info:** none in the message. Code path has been in-tree since the 2023 unlimited-retry change.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not disguised. It is explicitly a leak/stuck-connection fix that uses an existing socket option. Not a new userspace API.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: fs/smb/server/transport_tcp.c (**+6 / -0**)
- Function: ksmbd_kthread_fn() (accept path)
- Scope: single-file surgical fix (one call + comment)
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** After accept, set sk_rcvtimeo / sk_sndtimeo, then ksmbd_tcp_new_connection().
- **After:** Same, plus sock_set_keepalive(client_sk->sk) so TCP probes a silent peer.
- Path: normal accept of a new SMB TCP connection.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record:
- **Category:** resource leak / stuck connection (logic/correctness), mitigated by a standard TCP keepalive workaround.
- **Broken behavior:** ksmbd_conn_handler_loop() reads the RFC1002 header with max_retries = -1. ksmbd_tcp_readv() treats negative max_retries as unlimited -EAGAIN retries. KSMBD_TCP_RECV_TIMEOUT is 7 * HZ, so a dead peer yields -EAGAIN forever.
- ksmbd_conn_alive() only drops idle conns when deadtime > 0 **and** open_files_count == 0. A crashed client with open files stays alive forever.
- **Fix:** sock_set_keepalive() → tcp_set_keepalive() → keepalive timer. Failed probes produce RST/tcp_write_err(), kernel_recvmsg() returns 0/error, handler exits, conn leaves conn_list.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Obviously correct: same helper NFS/RPC and RDS already use (sock_set_keepalive since 2020).
- Minimal; comment-only extra.
- Regression risk **low**: default keepalive is 2 hours + 9 probes × 75s. Healthy SMB clients send traffic/echoes. No new sysctl/API. Does not change the unlimited-retry policy for truly idle-but-alive sessions.
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- Timeout assignment: present since original cifsd/ksmbd (0626e6641f6b, 2021).
- Unlimited retry: **be6f42fad5f5fd** “ksmbd: don't terminate inactive sessions after a few seconds” (**v6.3-rc4**, 2023-03-22). That commit is in this tree and was itself Cc: stable. Keepalive was never added then.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Conceptual introducer is be6f42fad5f5fd, present here.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES** Record:
- Recent transport_tcp.c work: per-IP limits, sock_create_kern, active_num_conn leaks.
- Same-day companion: **80b6367ec37f** “keep TCP timers alive for kernel sockets” (sk_net_refcnt_upgrade on the **listen** socket). That is a **different** bug (FIN-WAIT-1 orphans after tcp_close() clears timers on kernel sockets). Not required for keepalive on a still-held ESTABLISHED socket.
- Standalone for the ESTABLISHED leak.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Namjae Jeon is the ksmbd maintainer; many recent ksmbd fixes in this tree.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS** Record:
- Needs sock_set_keepalive() — in this tree (ce3d9544cecac, 2020), EXPORT_SYMBOL.
- connection.h already includes <net/sock.h>.
- Companion sk_net_refcnt_upgrade is **not** a prerequisite for this ESTABLISHED-path fix.
- Can apply standalone.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- Upstream SHA: **56549c18a4f75309161ca780feaa4d17904e3ee9**
- Lore:
https://patch.msgid.link/[email protected]
- Submitted 2026-08-20 as [PATCH] (with the timer patch as -2); merged in ksmbd 7.3-rc1 pull (“Improve TCP connection reliability…”)
- b4 dig -a: v1 keepalive + v2 timer companion, same day. No later unapplied revision.
- Mbox: author-only; no NAK, no extra review comments (maintainer tree).
- WebFetch of lore URLs returned 403; thread recovered via b4.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): [email protected], Sergey Senozhatsky, Tom Talpey, Atte Heikkilä, ChenXiaoSong. No NAK found.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record:
- Direct Reported-by: none on this commit.
- Real-world match: [cifsd-team/ksmbd#627](https://github.com/cifsd- team/ksmbd/issues/627) — Windows 11, stale ESTABLISHED sockets, connection limit exhausted (default ~32), only restart helps. Kernel 6.19.9 in that report; **same receive-loop logic is in 6.12**.
- Related: namjaejeon/ksmbd#517 (ESTABLISHED after client power-off; deadtime = 10 did not help — consistent with open files skipping deadtime).
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Two-patch reliability pair. Patch 1 = this (keepalive). Patch 2 = listen-socket netns upgrade for post-close timers. This patch is useful alone.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search 403. No evidence this was already rejected for 6.12. Not in this tree (git merge-base --is-ancestor 56549c18… HEAD failed).
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: modified ksmbd_kthread_fn; callees sock_set_keepalive / tcp_set_keepalive; related ksmbd_tcp_readv, ksmbd_conn_handler_loop, ksmbd_conn_alive.
**Step 5.2: TRACE CALLERS**
Record:
- ksmbd_kthread_fn ← kthread_run in ksmbd_tcp_run_kthread (listen on 445).
- Header read: ksmbd_conn_handler_loop → t->ops->read(..., -1) → ksmbd_tcp_read → ksmbd_tcp_readv.
- Process context, one kthread per connection. Userspace-reachable: any SMB client connect.
**Step 5.3: TRACE CALLEES**
Record: sock_set_keepalive locks the sock, calls sk->sk_prot->keepalive(sk, true) (tcp_set_keepalive for TCP), sets SOCK_KEEPOPEN. tcp_set_keepalive arms inet_csk_reset_keepalive_timer. Failed probes: tcp_send_active_reset
+ tcp_write_err.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: SMB connect to 445 → accept → keepalive enabled → handler recv loop. Unprivileged network clients can leave zombie conns (especially after crash/VPN drop). **Reachable.**
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: net/sunrpc/xprtsock.c and net/rds/tcp_listen.c already call sock_set_keepalive. ksmbd was the outlier.
---
## PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.**
- Tree: **pending-6.12 / 6.12.111** (p-6.12-3-gc504cf0baa3d8)
- Accept path at ksmbd_kthread_fn (~L325–329): timeouts set, **no** keepalive.
- Unlimited retry in ksmbd_tcp_readv (L409–423) and max_retries = -1 (connection.c L444).
- Introduced v6.3 (be6f42fad5f5fd); present for the whole 6.12 lifetime.
- Keepalive commit is **not** an ancestor of HEAD.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean apply.** Insertion point matches this file exactly (sk_sndtimeo then ksmbd_tcp_new_connection). sock_set_keepalive already exported.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: No keepalive on ksmbd sockets. deadtime is optional userspace config and skipped when files are open. Not a substitute.
---
## 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:
NAS, OpenWrt, appliances). Not core mm/VFS, but production file service.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Active (connection-limit, sock_create_kern, leak fixes). Mature enough that this long-standing hole matters.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver/config-specific:** CONFIG_SMB_SERVER. Typical stable
users: NAS, routers, embedded SMB.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record:
- Trigger: client crash, sleep, VPN drop, power-off without FIN/RST.
- Common on laptops/Wi‑Fi/VPN.
- Unprivileged remote clients can fill the per-IP quota (max_ip_connections is in this tree).
- Timing: default first probe after **2 hours**, then ~11 minutes of probes. Slow but **finite**, vs never.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record:
- Failure: kthread + socket + conn_list entry leak; per-IP/global connection quota exhaustion; new mounts fail until ksmbd restart.
- **Severity: HIGH** (service outage / resource leak). Not a panic, but a real production hang of the SMB service.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit: HIGH** for ksmbd users (closes zombies, restores quota).
- **Risk: VERY LOW** (6 lines, existing helper, sysctl-controlled, conservative defaults).
- Ratio strongly favors backport.
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real stuck-connection / quota DoS, not style.
- Unlimited -EAGAIN retry (be6f42fad5f5fd, in this tree, previously sent to stable) without keepalive is the hole.
- deadtime does not cover open-file + silent peer.
- User reports of ESTABLISHED pile-up (#627).
- 6-line, obviously correct, existing API.
- Applies cleanly to 6.12.111.
- Maintainer-authored; same pattern as sunrpc/RDS.
**AGAINST:**
- Looks like “enable a feature,” but it only turns on SO_KEEPALIVE.
- Default 2-hour idle before probes (slow, still a fix).
- No Fixes:/Cc: stable on this commit (not a negative per review rules).
- Companion timer patch is separate (do not block this on it).
**UNRESOLVED:**
- lore.kernel.org HTTP 403 (thread recovered via b4).
- No on-list Reviewed-by (maintainer submission).
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — one well-known helper; in mainline 7.3.
2. Fixes a real bug that affects users? **PASS** — leaked ESTABLISHED conns / quota; #627.
3. Important issue? **PASS** — service DoS / resource leak on a file server (HIGH).
4. Small and contained? **PASS** — +6 lines, one function.
5. No new features or APIs? **PASS** — existing SO_KEEPALIVE / sysctls only.
6. Can apply to the local tree? **PASS** — code and helper exist; clean insert.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/DT/build/docs exception. Fits “hardware/protocol workaround”: enable kernel TCP keepalive so dead peers are detected.
**Step 9.4: MAKE YOUR DECISION**
This tree has the unlimited recv-timeout retry and no keepalive. The patch is the missing counterpart to the 2023 stable change that stopped tearing down idle sessions. Benefit is real for ksmbd; risk is negligible.
---
### What it solves for stable users
A client that disappears without FIN/RST leaves ksmbd in ESTABLISHED:
the handler retries receive timeouts forever, holding a kthread and a conn_list slot (and the per-IP quota). That matches field reports of Windows clients filling the connection limit until ksmbd is restarted. Keepalive lets TCP fail the socket so the handler can tear the conn down.
### Risk vs benefit
Benefit: prevents unbounded connection growth and SMB accept failures.
Risk: one sock_set_keepalive() with default 2-hour keepalive — will not drop healthy sessions on a short idle.
### Concerns
None that block 6.12. The later sk_net_refcnt_upgrade patch is a separate FIN-WAIT-1 orphan fix, not required for this ESTABLISHED-path change.
---
### Verification
- **[Phase 1]** Parsed message: enable keepalive; SOB Namjae Jeon; no Fixes/Reported-by.
- **[Phase 2]** Diff: +6 in ksmbd_kthread_fn; sock_set_keepalive(client_sk->sk) after timeouts.
- **[Phase 2]** Confirmed ksmbd_tcp_readv unlimited retry when max_retries < 0; handler uses -1 for header read.
- **[Phase 2]** Confirmed ksmbd_conn_alive() returns true if open_files_count > 0, ignoring deadtime.
- **[Phase 2]** Confirmed sock_set_keepalive → tcp_set_keepalive (net/core/sock.c, net/ipv4/tcp_timer.c).
- **[Phase 3]** git describe HEAD / make kernelversion: **p-6.12-3 / 6.12.111**.
- **[Phase 3]** Blame: unlimited retry from be6f42fad5f5fd (v6.3); git merge-base --is-ancestor be6f42fad5f5f HEAD succeeded.
- **[Phase 3]** git merge-base --is-ancestor 56549c18a4f75309161ca780feaa4d17904e3ee9 HEAD failed (not in this tree).
- **[Phase 3]** sock_set_keepalive introduced ce3d9544cecac (2020); present here.
- **[Phase 4]** b4 dig -c 56549c18…: lore 20260820135420.5634-1; series with timer patch -2.
- **[Phase 4]** b4 dig -w: linux-cifs, Senozhatsky, Talpey, et al.
- **[Phase 4]** b4 dig -a: v1 keepalive + companion timer patch; no later unapplied rev.
- **[Phase 4]** GitHub ksmbd#627: stale ESTABLISHED / quota exhaustion.
- **[Phase 4]** Companion 80b6367ec37f: listen-socket sk_net_refcnt_upgrade for post-close timers — different bug.
- **[Phase 5]** Call chain: accept kthread → ksmbd_tcp_new_connection → ksmbd_conn_handler_loop → unlimited read(..., -1).
- **[Phase 5]** Same helper in sunrpc/RDS.
- **[Phase 6]** Local accept path L325–329 has no keepalive; context matches the patch.
- **[Phase 6]** connection.h includes <net/sock.h>.
- **[Phase 8]** Defaults: TCP_KEEPALIVE_TIME 2h, PROBES 9, INTVL 75s (include/net/tcp.h).
- **UNVERIFIED:** HTTP fetch of lore.kernel.org (403); recovered via b4. Whether every distro sets deadtime (irrelevant: deadtime skipped with open files).
**YES**
fs/smb/server/transport_tcp.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/smb/server/transport_tcp.c +6 -0
@@ -312,6 +312,12 @@ static int ksmbd_kthread_fn(void *p)ksmbd_debug (CONN ,"connect success: accepted new connection\n" ); client_sk->sk->sk_rcvtimeo =KSMBD_TCP_RECV_TIMEOUT ; client_sk->sk->sk_sndtimeo =KSMBD_TCP_SEND_TIMEOUT ; +/* +* Detect peers that disappear without sending a FIN or RST. +* Otherwise the connection handler can retry receive timeouts +* indefinitely and keep the connection in conn_list. +*/ +sock_set_keepalive (client_sk->sk);ksmbd_tcp_new_connection (client_sk); }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 i2c: amd-asf: Validate firmware-reported length
In reply to Sasha LevinFrom: Paritosh Potukuchi <[email protected]>
[ Upstream commit b2f4816a378dc840b605a1235b80e57c5f85b46c ]
The firmware may sometimes return a length greater than the allocated buffer size, which can lead to out-of-bounds access and a kernel panic.
Currently, the driver does not validate the length read from firmware.
Add a check to ensure the firmware-reported length stays within the bounds of the data buffer.
---
LLM Generated explanations, may be completely bogus:
## Phase 1: Commit message forensics
**Step 1.1 — Subject line**
Record: **[i2c/amd-asf] [Validate] firmware-reported length used as a copy bound**
**Step 1.2 — Tags** (pipeline markers ignored: [Upstream commit ...], Signed-off-by: Sasha Levin)
Record:
- Signed-off-by: Paritosh Potukuchi <[email protected]> (author)
- Acked-by: Shyam Sundar S K <[email protected]> (original driver author)
- Signed-off-by: Andi Shyti <[email protected]> (I2C maintainer)
- Link: https://lore.kernel.org/r/20260612101815.4124804-1-
[email protected]
- No Fixes:, Reported-by, Tested-by, Reviewed-by, or Cc: stable (absence expected)
**Step 1.3 — Body**
Record: Firmware can return a length larger than the allocated buffer; that produces **out-of-bounds access and a kernel panic**. The driver never checked the length read from firmware. The fix is a bounds check against the data buffer. No stack trace, reproducer, or version range is given.
**Step 1.4 — Hidden bug fix?**
Record: **No.** This is an explicit OOB/panic fix, not cleanup disguised as a fix.
---
## Phase 2: Diff analysis
**Step 2.1 — Inventory**
Record: One file, drivers/i2c/busses/i2c-amd-asf-plat.c, **+4 / −0**.
Function: amd_asf_process_target(). Surgical single-function change.
**Step 2.2 — Code flow**
Before (verified in v6.18.53):
```92:94:drivers/i2c/busses/i2c-amd-asf-plat.c
len = inb_p(ASFDATARWPTR);
for (idx = 0; idx < len; idx++)
data[idx] = inb_p(ASFINDEX);
```data is u8 data[ASF_BLOCK_MAX_BYTES] (72). len is u8, so firmware can return 0–255. The loop writes past the stack buffer when len > 72. A later loop in the same function also indexes data[idx] with the same len.
After: if len > ASF_BLOCK_MAX_BYTES, return before the copy.
**Step 2.3 — Bug mechanism**
Record: **(d) Memory safety — buffer overflow / OOB.** Firmware-supplied I/O length used as loop bound with no clamp. Same pattern already exists on the host write path (amd_asf_access(): if (len == 0 || len > ASF_BLOCK_MAX_BYTES)).
**Step 2.4 — Fix quality**
Record: Minimal and obviously correct for stopping the overflow. Comparison is > against a 72-byte array (index 0..71), so len == 72 is valid. Regression risk is low on the success path. On the error path the early return skips bank-status clear and ASFSETDATARDPTR reset; that can leave hardware stuck after a firmware bug, but that path already panicked. No API, locking, or data-structure change.
---
## Phase 3: Git history
**Step 3.1 — Blame**
Record: Buggy loop introduced in 9b25419ad3971 (“i2c: amd-asf: Add routine to handle the ASF slave process”, 2024-09-23). First in **v6.13-rc1**. Present in this 6.18.y tree.
**Step 3.2 — Fixes: tag**
Record: None. Introducer is 9b25419ad3971, confirmed ancestor of v6.18.53.
**Step 3.3 — File history**
Record: Related commits already in v6.18.53:
- a5089cd23b10c — initialize len (Fixes: 9b25419ad397)
- b719afaa1e5d8 — set cmd on error
No extra prerequisite is required for this bounds check. Standalone.
**Step 3.4 — Author**
Record: First I2C commit from Paritosh Potukuchi. Acked by original AMD ASF author Shyam Sundar S K. Applied by I2C maintainer Andi Shyti.
**Step 3.5 — Dependencies**
Record: Uses existing ASF_BLOCK_MAX_BYTES and the existing loop. git diff v6.18.53 d88d3b2633b03^ -- drivers/i2c/busses/i2c-amd-asf-plat.c is empty; git apply --check against the 6.18.53 file succeeded. **Applies standalone and cleanly.**
---
## Phase 4: Mailing list / external research
**Step 4.1 — Original discussion**
Record: b4 dig -c b2f4816a378dc840b605a1235b80e57c5f85b46c matched
https://patch.msgid.link/20260612093502.3805287-1-
[email protected]
Thread saved to mbox (lore HTTP 403 via WebFetch/curl).
Revisions:
- v1 (2026-06-12 09:35): same check, broken indentation
- v2 (2026-06-12 10:18): indentation fixed (subject still [PATCH], not [PATCH v2])
- Applied version adds a blank line before the if (Andi added it on apply)
Andi asked how often this happens and whether it should be considered a fix. Shyam acked without quantifying frequency and without NAK. Andi merged to i2c/i2c-for-7.2. No reviewer asked for Cc: stable. No NAK.
**Step 4.2 — Recipients (b4 dig -w)**
Record: Author, [email protected], [email protected], linux-i2c, linux-kernel. Right maintainers were on the patch.
**Step 4.3 — Bug report**
Record: No syzbot/bugzilla link. Report is the patch itself from AMD, describing firmware returning too-large length and a panic.
**Step 4.4 — Series**
Record: Standalone single patch, not part of a multi-patch series.
**Step 4.5 — Stable list**
Record: lore.kernel.org/stable returned 403. Mbox has no “stable” mention. **UNVERIFIED** whether stable@ discussed it separately.
---
## Phase 5: Code semantic analysis
**Step 5.1 — Functions**
Record: amd_asf_process_target() only.
**Step 5.2 — Callers**
Record: Not called directly. Registered as delayed-work callback in amd_asf_probe() via devm_delayed_work_autocancel(..., amd_asf_process_target). Scheduled from amd_asf_irq_handler() when ASF target IRQ bit 6 is set (schedule_delayed_work(&dev->work_buf, HZ)). Workqueue context, not IRQ context.
**Step 5.3 — Callees**
Record: inb_p/outb_p (port I/O), then (after this hunk) i2c_slave_event(). No alloc/lock in the changed path.
**Step 5.4 — Reachability**
Record: Reached when AMD ASF slave/target interrupt fires (CONFIG_I2C_AMD_ASF, ACPI AMDI001A). Trigger is firmware/BMC ASF traffic, not a generic unprivileged syscall. Still a host kernel stack overflow if firmware reports len > 72.
**Step 5.5 — Similar patterns**
Record: Host path already bounds-checks in amd_asf_access() (len == 0 || len > ASF_BLOCK_MAX_BYTES) and amd_asf_xfer() (msgs->len > ASF_BLOCK_MAX_BYTES - 3). Slave/target path was the missing check.
---
## Phase 6: Local tree (v6.18.53 / 6.18.y)
**Step 6.1 — Does the buggy code exist?**
Record: **Yes.** git merge-base --is-ancestor d88d3b2633b03 v6.18.53 failed (fix not in 6.18.53). git show v6.18.53:drivers/i2c/busses/i2c-amd-asf-plat.c has the unbounded loop. Driver added in v6.13; bug since then.
**Step 6.2 — Backport difficulty**
Record: **Clean apply.** Parent of the candidate matches 6.18.53 file content; git apply --check succeeded.
**Step 6.3 — Related fixes already here?**
Record: Uninit-len and error-cmd fixes are in 6.18.53. **No existing bounds check** on this firmware length.
---
## Phase 7: Subsystem context
**Step 7.1**
Record: **drivers/i2c** (AMD ASF bus driver). Criticality:
**PERIPHERAL** (AMD ASF/DASH, depends on I2C_PIIX4), but a host panic still matters for those systems.
**Step 7.2**
Record: Small, mature-enough driver (landed v6.13, a few follow-up fixes through 6.15). Not staging.
---
## Phase 8: Impact and risk
**Step 8.1 — Who is affected**
Record: **Driver-specific / config-specific:** CONFIG_I2C_AMD_ASF on AMD systems with ASF (AMDI001A).
**Step 8.2 — Trigger**
Record: ASF target interrupt + firmware length > 72. Frequency not quantified on-list (Andi asked; Shyam only acked). Not a normal syscall path; firmware/BMC-driven. Unprivileged userspace generally cannot set that I/O length directly.
**Step 8.3 — Failure mode**
Record: Stack buffer overflow (up to 183 bytes past a 72-byte stack array), then OOB read in the second loop. Commit states **kernel panic**. Severity: **CRITICAL** (crash; stack smash).
**Step 8.4 — Risk vs benefit**
Record: Benefit **high** for ASF users (panic/OOB). Risk **very low** (4 lines, success path unchanged, same check already used on the write path). Early-return skips HW cleanup only on the already-broken firmware path.
---
## Phase 9: Synthesis
**For backporting**
- Real stack OOB from unvalidated firmware length → panic
- Tiny, obviously correct, matches existing driver checks
- Driver and buggy loop are in this 6.18.53 tree (since v6.13)
- Applies cleanly; no missing helpers
- Acked by original driver author; applied by I2C maintainer
**Against**
- AMD-only driver, not a core path
- Frequency of bad firmware length never quantified
- Early return does not reset ASF bank/pointer (error-path incompleteness, not a happy-path regression)
- No Fixes:/Cc: stable (not a negative per rules)
**Unresolved**
- Stable mailing list search (lore 403)
- Exact field reproduction rate (unverified beyond AMD’s “may sometimes”)
**Stable rules**
1. Obviously correct and tested? **PASS** — 4-line bound check; maintainer applied after ack
2. Real bug affecting users? **PASS** — OOB/panic on ASF target RX
3. Important (crash/security/corruption/deadlock)? **PASS** — stack overflow → panic
4. Small and contained? **PASS** — +4 lines, one function
5. No new features/APIs? **PASS**
6. Can apply to this tree? **PASS** — clean against 6.18.53
Exception category: none needed; this is a normal crash/OOB fix.
This 6.18.y tree has the unbounded copy and not the fix. Backporting prevents a kernel panic on AMD ASF hardware when firmware reports a length above 72.
---
## What the commit solves, and why it matters here
amd_asf_process_target() copies firmware bytes into a 72-byte stack buffer using a length read from ASFDATARWPTR with no cap. len is u8, so a value 73–255 overruns the stack and can panic. This 6.18.53 tree still has that loop. The patch adds the same bound already used on the write path. Cost is four lines; the normal path is unchanged.
---
## Verification
- **[Phase 1]** Parsed message/tags from git show d88d3b2633b03; no Fixes/Reported-by/Cc: stable; Acked-by Shyam; SOB Andi Shyti
- **[Phase 2]** Diff is +4 in amd_asf_process_target; data[ASF_BLOCK_MAX_BYTES] (72); len is u8; write path already checks len > ASF_BLOCK_MAX_BYTES at line 176
- **[Phase 3]** git blame on v6.18.53: loop from 9b25419ad3971; git describe --contains → v6.13-rc1; git merge-base --is-ancestor 9b25419ad3971 v6.18.53 true
- **[Phase 3]** git merge-base --is-ancestor d88d3b2633b03 v6.18.53 false (fix not in 6.18.53)
- **[Phase 3]** a5089cd23b10c and b719afaa1e5d8 are ancestors of v6.18.53
- **[Phase 3]** git diff v6.18.53 d88d3b2633b03^ -- drivers/i2c/busses/i2c-amd-asf-plat.c empty
- **[Phase 4]** b4 dig -c b2f4816a378dc840b605a1235b80e57c5f85b46c / -a / -w / -m; thread: v1 indent bug, v2 indent fix, Andi process nits + “how often?”, Shyam Ack, merged i2c-for-7.2; no NAK
- **[Phase 4]** lore WebFetch/curl 403; discussion taken from saved mbox
- **[Phase 4]** git.kernel.org commit b2f4816a378dc840b605a1235b80e57c5f85b46c exists; no Fixes/Cc: stable in that commit
- **[Phase 5]** git grep amd_asf_process_target: only definition + devm_delayed_work_autocancel; scheduled from amd_asf_irq_handler
- **[Phase 6]** git describe HEAD → v6.18.53-5049-g0f0bdc2b0dffb; make kernelversion → 6.18.53; buggy loop present in v6.18.53: file
- **[Phase 6]** git apply --check of this patch onto the v6.18.53
file: rc 0
- **[Phase 7]** CONFIG_I2C_AMD_ASF in v6.18.53 Kconfig, depends on I2C_PIIX4, ACPI id AMDI001A
- **[Phase 8]** Failure mode: stack OOB → panic (from commit + code); trigger is firmware length, not a generic syscall
- **UNVERIFIED:** stable@ list discussion (lore 403); how often firmware returns len > 72 (not answered on-list)
**YES**
drivers/i2c/busses/i2c-amd-asf-plat.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/i2c/busses/i2c-amd-asf-plat.c +4 -0
@@ -90,6 +90,10 @@ static void amd_asf_process_target(struct work_struct *work)outb_p (reg,ASFDATABNKSEL ); cmd =inb_p (ASFINDEX ); len =inb_p (ASFDATARWPTR ); + +if (len >ASF_BLOCK_MAX_BYTES ) +return ; +for (idx =0 ; idx < len; idx++) data[idx] =inb_p (ASFINDEX );
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 serial: qcom_geni: Disable closing_wait for console to prevent shutdown timeout
In reply to Sasha LevinFrom: Aniket Randive <[email protected]>
[ Upstream commit acba38e675dd66f52925cb9edf9ed8db16335875 ]
During system power-off, systemd closes the console UART and blocks in tty_wait_until_sent() waiting for pending TX completion before uart_shutdown() can cancel pending TX operations. With the default closing_wait of 30s, this causes a watchdog reset when systemd is responsible for watchdog feeding.
Set closing_wait to ASYNC_CLOSING_WAIT_NONE in startup() for console ports to bypass tty_wait_until_sent() on close, allowing uart_shutdown() to cancel TX commands cleanly. This change doesn't impact regular ports functionality.
---
LLM Generated explanations, may be completely bogus:
This checkout is **v7.3-rc4** (7.3.0-rc4). The candidate is a small Qualcomm GENI UART console workaround for a 30s close-time TX drain that can watchdog-reset the box on power-off. The driver, startup(), and closing_wait path are all present here.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[serial/qcom_geni] [Disable] [skip console closing_wait so UART close does not stall shutdown]**
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Fixes:** none (expected for this review pipeline)
- **Reported-by / Tested-by / Reviewed-by / Acked-by:** none
- **Cc: stable:** none (expected)
- **Link:** https://patch.msgid.link/20260706093749.836121-1-
[email protected]
- **Signed-off-by:** Aniket Randive (author); Greg Kroah-Hartman (TTY maintainer). Ignore any Sasha Levin SOB — not on this commit.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** On power-off, systemd closes the console UART. Close blocks in tty_wait_until_sent() for pending TX before the UART can cancel that TX.
- **Symptom:** Default closing_wait is 30s (tty_port_init: (3000 * HZ) / 100). If systemd is the watchdog feeder, that stall causes a **watchdog reset** instead of a clean power-off.
- **Root cause (author):** GENI TX is command-based; drain waits for completion, but cancel happens only later in uart_shutdown() / driver shutdown. Chicken-and-egg.
- **Fix:** In qcom_geni_serial_startup(), if uart_console(uport), set tport->closing_wait = ASYNC_CLOSING_WAIT_NONE. Regular UARTs unchanged.
- **Versions:** none named.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: Not a disguised cleanup. It is an explicit hang/watchdog fix using an existing tty_port flag.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- File: drivers/tty/serial/qcom_geni_serial.c — **+8 / −0**
- Function: qcom_geni_serial_startup()
- Scope: single-file, surgical, console-only
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** Console ports keep default 30s closing_wait. Last close → tty_port_close_start() → tty_wait_until_sent(tty, 30s) if the software TX buffer or UART FIFO is not empty.
- **After:** Console ports skip that drain. Close proceeds immediately so shutdown can continue.
- **Path:** close/power-off of the console tty, not the hot TX path, not non-console ports.
Verified close chain:
1. tty_release() → uart_close() → tty_port_close()
2. tty_port_close_start() (tty_port.c:638-643) waits if closing_wait != ASYNC_CLOSING_WAIT_NONE
3. tty_wait_until_sent() waits on !tty_chars_in_buffer(tty), then uart_wait_until_sent() polls ops->tx_empty
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Logic / hardware workaround]** GENI TX uses a sequencer command (UART_START_TX). If that command is still active, tx_empty (SE_GENI_TX_FIFO_STATUS) and the xmit fifo stay non-empty, so close waits the full 30s. Setting ASYNC_CLOSING_WAIT_NONE is the documented way to skip that wait (tty_port.c:642-643).
Nuance (verified, not assumed): tty_port_shutdown() returns immediately when port->console is set, so **console close does not call driver shutdown()**. Hangup (uart_hangup() → uart_shutdown()) *does* shut the port down and does *not* use closing_wait. The 30s stall is the close-time wait itself. Skipping it still fixes the watchdog; the “so shutdown can cancel TX” wording is only partly accurate for the close path.
**Step 2.4: ASSESS THE FIX QUALITY**
Record:
- Quality: **obviously correct** for the stated goal. ASYNC_CLOSING_WAIT_NONE is the uapi sentinel (65535). uport->state is valid in startup() because uart_port_startup() calls ops->startup() only after the port is bound.
- Risk: last few console bytes on last close may not drain. That is acceptable at power-off versus a watchdog reboot. Non-console ports unchanged. No API/ABI change. Userspace can still override via TIOCSSERIAL.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record:
- qcom_geni_serial_startup() introduced in **c4f528795d1ad** (2018-03-20, “Add serial driver support for GENI based QUP”).
- Default 30s closing_wait is in tty_port_init() and is old.
- Bug is long-standing in this driver, not a last-month regression.
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: No Fixes: tag. Not applicable.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: Standalone, not “patch X/Y”. Nearby later work (dbe2afb952bdb reboot quiesce, panic notifier) is a different problem (DMA/SMMU on reboot/panic), not a prerequisite. a699213d4e6ef “Fix blocked task” is an unrelated PM-runtime hang revert.
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Aniket Randive has a few qcom-geni commits (this one; debug- console probe). Qualcomm platform engineer, not the TTY maintainer. Greg KH applied it.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **None.** Uses uart_console(), tty_port.closing_wait, and ASYNC_CLOSING_WAIT_NONE, all older than this driver. Applies standalone. In this tree, later PM-runtime lines sit around the same function; the closing_wait hunk does not depend on them.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- b4 dig -c acba38e675dd: **[PATCH V1]** https://patch.msgid.link/2026
[email protected]
- b4 dig -a: **v1 only**; that is what was applied (2026-07-06 submit, 2026-07-10 by Greg).
- Saved mbox: **patch only, no replies, no NAK, no Cc: stable from reviewers.**
- lore.kernel.org fetches returned 403; thread confirmed via b4 mbox + Openwall/LKML mirrors.
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record (b4 dig -w): To Greg Kroah-Hartman, Jiri Slaby (TTY maintainers). Cc: linux-serial, linux-arm-msm, Krzysztof Kozlowski, Qualcomm/Linaro GENI people. No extra Reviewed-by; maintainer SOB is the review signal.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: No syzbot, bugzilla, or public user report. Description matches an internal Qualcomm power-off/watchdog failure. No independent repro in the thread.
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Single patch, not a series. Later “quiesce on reboot/panic” series is independent.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search returned 403. No stable discussion found via web search. **UNVERIFIED** whether anyone already requested or rejected this for -stable.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
semcode MCP is not available (only the cursor namespace). Callers/callees traced with grep/read.
**Step 5.1: IDENTIFY KEY FUNCTIONS**
Record: qcom_geni_serial_startup (modified). Related:tty_port_close_start, tty_wait_until_sent, uart_wait_until_sent, qcom_geni_serial_tx_empty, qcom_geni_serial_shutdown.
**Step 5.2: TRACE CALLERS**
Record: .startup = qcom_geni_serial_startup is in both FIFO and DMA uart_ops. Called from uart_port_startup() on open (and uart_set_info / console re-init). Reachable from userspace open of the console tty and from console registration.
**Step 5.3: TRACE CALLEES**
Record: uart_console(), assignment to tport->closing_wait. No alloc/lock in the new code.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Userspace (systemd) close of /dev/ttyMSM* / console → tty_release → uart_close → tty_port_close_start → 30s wait. **Yes, reachable from userspace.** Trigger is power-off/getty stop with GENI as console, not an obscure debug path.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: No other serial driver sets closing_wait = ASYNC_CLOSING_WAIT_NONE at startup. USB-serial/cdc-acm/mxser only expose it via ioctl. This is GENI-specific policy, not a tree-wide tty change.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.**
- Tree: v7.3-rc4-27-gf0100363d8c37, Makefile VERSION=7 PATCHLEVEL=3 SUBLEVEL=0 EXTRAVERSION=-rc4
- Driver: drivers/tty/serial/qcom_geni_serial.c since 2018
- qcom_geni_serial_startup() present
- tty_port_close_start() still waits on closing_wait
- Commit **acba38e675dd** is an ancestor of HEAD (already applied here). That is not used as “already selected”; it confirms the surrounding code matches.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Clean in this tree** (already applied). Context in this tree has later PM-runtime/tx_kick_enabled lines around startup; the hunk itself is still the same 8 lines.
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: This *is* the fix. No alternate fix for console closing_wait. Reboot/panic quiesce commits do not replace it.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **serial / qcom_geni** (CONFIG_SERIAL_QCOM_GENI, optional CONFIG_SERIAL_QCOM_GENI_CONSOLE). **IMPORTANT** (not core mm/VFS):
Snapdragon phones, laptops, and embedded boards. Console + watchdog is a production path on those platforms.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: Actively developed in 7.x (DMA, nbcon, runtime PM, SA8255p). The wait-on-close bug is still in the old 2018 startup/close design, not a new-feature-only issue.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver-specific + config-specific:** ARCH_QCOM (or COMPILE_TEST) with GENI UART used as **console**. Non-console GENI ports unchanged.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: Power-off/reboot (or last close of the console tty) while TX is still pending. Common on Android/embedded with systemd feeding the watchdog. Unprivileged users do not typically close the system console; **root/systemd** does. Not a local-priv-esc, still a production shutdown failure.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **Watchdog reset / failed power-off.** **HIGH** (hang then reset). Can interrupt an otherwise orderly shutdown (unmount/sync still in progress). Not a KASAN/UAF class bug.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** High for GENI-console devices: avoids 30s stall / watchdog reboot on power-off.
- **Risk:** Very low: 8 lines, console-only, existing flag, no locking change.
- **Ratio:** Benefit clearly outweighs risk.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
FOR:
- Real user-visible failure: shutdown blocked 30s → watchdog reset on Qualcomm GENI console.
- Small, obviously correct use of ASYNC_CLOSING_WAIT_NONE.
- Console-only; non-console ports unchanged.
- No new APIs/features.
- Driver and bug path exist in this tree since the 2018 GENI UART driver.
- Applied by TTY maintainer (Greg KH) as v1 with no NAK.
- Matches stable “hardware workaround / hang fix” practice.
AGAINST:
- No public Reported-by / Tested-by / syzbot.
- Workaround, not a hardware TX-stuck root-cause fix; last console bytes on close may be dropped.
- Author’s “shutdown can cancel TX” claim is imprecise for console *close* (tty_port_shutdown skips consoles).
- Affects one SoC UART family, not all machines.
UNRESOLVED:
- Stable list discussion (lore.kernel.org/stable 403).
- Independent reproducer beyond the commit text.
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — mechanism matches tty_port; merged by maintainer. Internal Qualcomm testing implied, not independently reproduced here.
2. Fixes a real bug that affects users? **PASS** — power-off hang/watchdog on GENI console.
3. Important (crash/security/corruption/deadlock)? **PASS** — watchdog reset / failed shutdown is a serious hang/reset, not cosmetic.
4. Small and contained? **PASS** — +8 lines, one function, one file.
5. No new features or APIs? **PASS**.
6. Can apply to the local tree? **PASS** — startup(), uart_console(), tty_port, ASYNC_CLOSING_WAIT_NONE all exist here.
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: Not a device-ID/DT/build/docs exception. It is a **hardware/driver workaround** for a shutdown hang, which stable routinely takes.
**Step 9.4: MAKE YOUR DECISION**
This tree has the GENI serial driver and the 30s close-wait path. The patch is a small, console-only workaround that prevents a production watchdog reset on power-off. That is within stable rules for this checkout.
===============================================================
What the commit solves for this tree
===============================================================
Without the change, closing the GENI console tty waits up to 30s for TX to drain. GENI TX can sit in an unfinished sequencer command, so the wait often runs to the timeout. If systemd feeds the watchdog, the machine resets instead of powering off. Setting closing_wait to ASYNC_CLOSING_WAIT_NONE only for console ports skips that drain. Cost is possible loss of the last console bytes on close; that is preferable to a watchdog reboot.
===============================================================
Verification
===============================================================
- **[Phase 1]** Parsed tags: Link to msgid 20260706093749.836121-1; SOB Aniket Randive + Greg KH; no Fixes/Reported-by/Cc:stable.
- **[Phase 2]** Diff: +8 in qcom_geni_serial_startup(); sets tport->closing_wait for uart_console().
- **[Phase 2]** tty_port_init: default closing_wait = (3000 * HZ) / 100 (30s). tty_port_close_start waits unless ASYNC_CLOSING_WAIT_NONE.
- **[Phase 2]** tty_port_shutdown: returns early if port->console — console close does not call driver shutdown. Hangup *does* call uart_shutdown().
- **[Phase 2]** qcom_geni_serial_tx_empty reads SE_GENI_TX_FIFO_STATUS; stuck TX keeps wait alive.
- **[Phase 3]** git describe HEAD → v7.3-rc4-27-gf0100363d8c37; make kernelversion → 7.3.0-rc4.
- **[Phase 3]** git merge-base --is-ancestor acba38e675dd HEAD → yes (present; not used as “already selected”).
- **[Phase 3]** Blame: startup from c4f528795d1ad (2018); closing_wait lines from acba38e675dd.
- **[Phase 3]** git merge-base --is-ancestor acba38e675dd v7.3-rc1 → yes; not in v7.2.
- **[Phase 4]** b4 dig -c → v1 lore URL; -a → only v1; -w → gregkh, jirislaby, linux-serial, linux-arm-msm; -m → no review replies.
- **[Phase 4]** WebFetch lore → 403; Openwall/LKML mirrors match the committed patch.
- **[Phase 5]** Callers: uart_port_startup → ops->startup; userspace close path confirmed.
- **[Phase 6]** File and startup() exist; Kconfig SERIAL_QCOM_GENI / SERIAL_QCOM_GENI_CONSOLE.
- **[Phase 8]** Failure: watchdog reset on power-off, severity HIGH, risk of fix very low.
- **UNVERIFIED:** stable@ discussion (lore/stable 403). Independent public reproducer.
**YES**
drivers/tty/serial/qcom_geni_serial.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/tty/serial/qcom_geni_serial.c +8 -0
@@ -1244,6 +1244,7 @@ static int qcom_geni_serial_startup(struct uart_port *uport) {int ret;struct qcom_geni_serial_port *port =to_dev_port (uport); +struct tty_port *tport = &uport->state->port;if (!port->setup) { ret =qcom_geni_serial_port_setup (uport);
@@ -1251,6 +1252,13 @@ static int qcom_geni_serial_startup(struct uart_port *uport)return ret; } +/* +* Skip the close-time transmit drain for console ports so that +* shutdown can proceed without waiting for pending TX completion. +*/ +if (uart_console (uport)) + tport->closing_wait =ASYNC_CLOSING_WAIT_NONE ; +uart_port_lock_irq (uport);qcom_geni_serial_start_rx (uport);uart_port_unlock_irq (uport);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH AUTOSEL 6.18-6.6] serial: qcom_geni: Disable closing_wait for console to prevent shutdown timeout
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] serial: qcom_geni: uncancelled console TX in qcom_geni_serial_startup() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] serial: qcom_geni: uncancelled console TX in qcom_geni_serial_startup() --
commit 410ad55ea7c02110e68e77ae15503cb551a22bf5
Author: Aniket Randive <[email protected]>
serial: qcom_geni: Disable closing_wait for console to prevent shutdown timeout
This commit sets closing_wait to ASYNC_CLOSING_WAIT_NONE in qcom_geni_serial_startup() for console ports so that closing the console TTY bypasses tty_wait_until_sent() during system shutdown.
Quoted 13 lines
drivers/tty/serial/qcom_geni_serial.c +1
-0@@ -1227,6 +1227,7 @@ static int qcom_geni_serial_startup(struct uart_port *uport) {int ret;struct qcom_geni_serial_port *port =to_dev_port (uport); +struct tty_port *tport = &uport->state->port;if (!port->setup) { ret =qcom_geni_serial_port_setup (uport);
drivers/tty/serial/qcom_geni_serial.c static int qcom_geni_serial_startup(struct uart_port *uport) · line 1243
Quoted 9 lines
drivers/tty/serial/qcom_geni_serial.c +6
-0@@ -1234,6 +1235,13 @@ static int qcom_geni_serial_startup(struct uart_port *uport)return ret; } +/* +* Skip the close-time transmit drain for console ports so that +* shutdown can proceed without waiting for pending TX completion. +*/ +if (uart_console (uport)) + tport->closing_wait =ASYNC_CLOSING_WAIT_NONE ;
[Severity: Medium]
Does uart_shutdown() actually get called to cancel pending TX commands when a console port is closed?
The commit message states that setting closing_wait to ASYNC_CLOSING_WAIT_NONE bypasses tty_wait_until_sent() on close, allowing uart_shutdown() to cancel TX commands cleanly.
However, when uart_console(uport) is true, serial_core_add_one_port() sets port->console:
drivers/tty/serial/serial_core.c:serial_core_add_one_port() {
...
port->console = uart_console(uport);
...
}When userspace closes the final file descriptor on the console TTY via tty_release() -> uart_close() -> tty_port_close(), tty_port_close_start() skips tty_wait_until_sent() without calling tty_driver_flush_buffer() (unless tty->flow.tco_stopped is set):
drivers/tty/tty_port.c:tty_port_close_start() {
...
if (tty->flow.tco_stopped)
tty_driver_flush_buffer(tty);
if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
tty_wait_until_sent(tty, port->closing_wait);
...
}Then tty_port_close() calls tty_port_shutdown(), which returns early for console ports without invoking port->ops->shutdown() (uart_tty_port_shutdown() -> uart_port_shutdown() -> qcom_geni_serial_shutdown()):
drivers/tty/tty_port.c:tty_port_shutdown() {
struct tty_struct *tty = port->tty;
mutex_lock(&port->mutex);
if (port->console)
goto out;
...
}After that, tty_port_close_end() clears TTY_PORT_ACTIVE via tty_port_set_active(port, false), so even a subsequent uart_hangup() (which checks tty_port_active(port)) will not call uart_flush_buffer() or uart_shutdown().
Doesn't this leave pending GENI sequencer TX commands (UART_START_TX), TX interrupts, and unsent bytes in tport->xmit_fifo active after the console TTY is closed, causing subsequent qcom_geni_serial_console_write() calls to poll until timeout before cancelling the stalled command and re-triggering qcom_geni_serial_isr() -> qcom_geni_serial_handle_tx_fifo() on the leftover xmit_fifo data?
Quoted 4 lines
drivers/tty/serial/qcom_geni_serial.c +1
-0+uart_port_lock_irq (uport);qcom_geni_serial_start_rx (uport);uart_port_unlock_irq (uport);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/realtek: Fix headset mic on ASUS Vivobook S14 S5406SA
In reply to Sasha LevinFrom: Zhang Heng <[email protected]>
[ Upstream commit f2d08f3651fb12634347fef2c41687a807a7dcba ]
On the ASUS Vivobook S14 S5406SA (subsystem 0x104310c4, Lunar Lake platform) with an ALC294 codec, the headset microphone (3.5mm jack) fails to capture any audio. Adding the ALC2XX_FIXUP_HEADSET_MIC quirk resolves the issue and restores proper headset mic recording.
---
LLM Generated explanations, may be completely bogus:
I have enough to decide for this 6.12 tree: the quirk and insertion point exist, the 0x10c4 entry does not.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
**Step 1.1: PARSE THE SUBJECT LINE**
Record: **[ALSA/hda/realtek] [Fix] [headset microphone capture on ASUS Vivobook S14 S5406SA]**
Subsystem prefix is ALSA: hda/realtek. Action verb is **Fix**. Claimed intent is restoring 3.5mm headset-mic capture on one ASUS laptop by adding a PCI subsystem quirk.
**Step 1.2: PARSE ALL COMMIT MESSAGE TAGS**
Record:
- **Link:** https://github.com/thesofproject/linux/issues/5729 (user bug report; later confirmed fixed by the model/quirk)
- **Link:**
https://patch.msgid.link/[email protected]
(alsa-devel submission; patch 3/4)
- **Signed-off-by:** Zhang Heng \<[email protected]\> (author)
- **Signed-off-by:** Takashi Iwai \<[email protected]\> (ALSA maintainer; applied the series)
- **Fixes:** none (expected)
- **Cc: stable:** none (expected)
- **Reported-by / Tested-by / Reviewed-by / Acked-by:** none in the commit message
Notable: msgid -3 shows this was patch 3 of a 4-patch batch of independent hardware quirks, not a dependent refactor series.
**Step 1.3: ANALYZE THE COMMIT BODY TEXT**
Record:
- **Bug:** On ASUS Vivobook S14 S5406SA, PCI subsystem 0x1043:0x10c4, Lunar Lake + ALC294, the 3.5mm headset microphone captures silence. Headset speakers work; internal DMIC works.
- **Symptom:** Userspace sees a “Headphones Stereo Microphone” source that records silence; analog capture mixer controls are missing.
- **Root cause (from message + issue):** BIOS leaves headset-mic pin 0x19 as 0x411111f0 (N/A). ALC2XX_FIXUP_HEADSET_MIC overrides that pin and sets HDA_PINCFG_HEADSET_MIC.
- **Version info in message:** Lunar Lake platform; GitHub reporter was on 6.17, but that does not limit this tree.
**Step 1.4: DETECT HIDDEN BUG FIXES**
Record: **Not a hidden fix.** It is an explicit hardware-quirk bug fix:
one SND_PCI_QUIRK line. No cleanup/refactor disguise.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
**Step 2.1: INVENTORY THE CHANGES**
Record:
- **File in upstream commit:** sound/hda/codecs/realtek/alc269.c (+1 / −0)
- **File in this tree:** sound/pci/hda/patch_realtek.c (Realtek codec not yet split)
- **Function / table:** alc269_fixup_tbl[]
- **Scope:** single-file, one-line surgical hardware quirk
**Step 2.2: UNDERSTAND THE CODE FLOW CHANGE**
Record:
- **Before:** SSID 0x1043:0x10c4 has no PCI quirk. patch_alc269() still calls snd_hda_pick_fixup() on alc269_fixup_tbl. Existing ASUS ALC294 *pin* quirks do not match this machine’s pin 0x12 (0x40000000 vs required 0x90a60130), so no headset-mic fixup is applied. Pin 0x19 stays N/A; analog headset mic is never parsed.
- **After:** That SSID selects ALC2XX_FIXUP_HEADSET_MIC at PRE_PROBE.
- **Path:** codec probe / jack autoconfig only; not a hot path, error path, or API change.
**Step 2.3: IDENTIFY THE BUG MECHANISM**
Record: **[Hardware workaround / pin-config quirk]**
In this tree ALC2XX_FIXUP_HEADSET_MIC is:
```10552:10555:sound/pci/hda/patch_realtek.c
[ALC2XX_FIXUP_HEADSET_MIC] = {
.type = HDA_FIXUP_FUNC,
.v.func = alc_fixup_headset_mic,
},
```alc_fixup_headset_mic() (same body as later alc2xx_fixup_headset_mic) does:
1. Override pin 0x19 to 0x03a1103c (headset mic)
2. Update coef 0x45
3. Set spec->parse_flags |= HDA_PINCFG_HEADSET_MIC
That matches the GitHub dump: pin 0x19 was 0x411111f0 with VREF_HIZ.
**Step 2.4: ASSESS THE FIX QUALITY**
Record: **Obviously correct and minimal.** One PCI ID, existing fixup already used for Acer Nitro 5, ASUS Vivobook 15 X1504VAP, Gigabyte, Huawei, Clevo, TongFang, HONOR. Regression surface is only SSID 0x1043:0x10c4. No locking, no API, no new code. **Regression risk:
very low.**
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
**Step 3.1: BLAME THE CHANGED LINES**
Record: The new line is an addition. Neighboring entries exist in this tree at:
```11192:11193:sound/pci/hda/patch_realtek.c
SND_PCI_QUIRK(0x1043, 0x10c0, "ASUS X540SA",
ALC256_FIXUP_ASUS_MIC),
SND_PCI_QUIRK(0x1043, 0x10d0, "ASUS X540LA/X540LJ",
ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
```The *bug* is missing pin config from BIOS, not a regression in a specific old commit. The reusable fixup was added by 1c643c600407d (“Add new alc2xx-fixup-headset-mic model”, 2024-12-07), which is **in this tree** (git merge-base --is-ancestor 1c643c600407d HEAD succeeded). That is the stable backport of upstream 50db91fccea0d (first contained in v6.13-rc3; original SHA is **not** an ancestor of this 6.12 branch, but the equivalent change is present).
**Step 3.2: FOLLOW THE FIXES: TAG**
Record: **No Fixes: tag.** Not applicable. The hardware never had a working pin default for this SSID in this tree.
**Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES**
Record: sound/pci/hda/patch_realtek.c is actively receiving similar one-line quirks (mute LEDs, speakers, headset mics). Recent history is the same class of change. **No prerequisite series for this one line.** Similar in-tree uses of ALC2XX_FIXUP_HEADSET_MIC include Acer Nitro 5 (0x1025:0x1539/159c/1597) and ASUS Vivobook 15 X1504VAP (0x1043:0x1e1f).
**Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS**
Record: Zhang Heng has multiple Realtek quirk commits in this tree (Samsung, ASUS UM6702RC, Inspur, Conexant). Regular ALSA hda contributor; this patch was applied by maintainer Takashi Iwai. Related same-day patches are other independent quirks (Acer Nitro ANV16-42, Acer Gadget E10, Huawei Matebook Conexant), not dependencies.
**Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS**
Record: **Standalone.** Needs only ALC2XX_FIXUP_HEADSET_MIC / alc_fixup_headset_mic(), both present. Series 1/4, 2/4, and 4/4 touch different SSIDs/files. File path in the upstream diff (alc269.c) must be rewritten to patch_realtek.c here; the hunk context around 0x10c0/0x10d0 matches.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
**Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION**
Record:
- **Lore msgid:** [email protected]
- **b4 mbox:** 5 messages; series is four independent quirks (2026-08-07)
- **Revisions:** single submission ([PATCH 3/4]); no v2/v3 in the thread
- **Maintainer:** Takashi Iwai: “Applied all four patches now. Thanks.” — no NAK, no requested changes, no stable-risk comments
- Direct lore.kernel.org HTTP fetches returned 403; thread was recovered via b4 mbox
**Step 4.2: CHECK WHO REVIEWED THE PATCH**
Record: **To:** [email protected]. **Cc:** [email protected], [email protected]. Subsystem maintainer received and applied it. b4 dig -w was not used (no upstream SHA in this checkout); recipients came from the mbox.
**Step 4.3: SEARCH FOR THE BUG REPORT**
Record: GitHub thesofproject/linux#5729 (closed):
- Hardware: ASUS Vivobook S14 S5406SA, ALC294, SSID 0x104310c4, Intel Lunar Lake, driver sof-audio-pci-intel-lnl
- Symptom: headset speakers OK, headset mic silent; pin 0x19 = 0x411111f0
- Pierre-Louis Bossart: ALC294 config issue, not SOF
- Zhang Heng / Kailang Yang: try model alc2xx-fixup-headset-mic
- Reporter **confirmed** hda_model=alc2xx-fixup-headset-mic on the same machine: dmesg Headset Mic=0x19, jack detect works, pw-record captures real audio
- Also referenced Arch forum thread for the same SSID
**Step 4.4: CHECK FOR RELATED PATCHES AND SERIES**
Record: Batch of four independent hardware quirks. This patch does not need the others. Other patches are not required for this SSID to work.
**Step 4.5: CHECK STABLE MAILING LIST HISTORY**
Record: lore.kernel.org/stable search returned HTTP 403. **UNVERIFIED** whether someone already asked stable@ for this specific commit. No in- tree evidence it was rejected.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
**Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF**
Record: No function body changed. Touches alc269_fixup_tbl[]. Runtime effect is via alc_fixup_headset_mic() selected as ALC2XX_FIXUP_HEADSET_MIC.
**Step 5.2: TRACE CALLERS**
Record:
- HDA_CODEC_ENTRY(0x10ec0294, "ALC294", patch_alc269) at line 13992
- patch_alc269() → snd_hda_pick_fixup(..., alc269_fixup_tbl, alc269_fixups) at 12583–12584
- Called at codec probe (HDA/SOF HDA generic), not IRQ/syscall hot path
- Impact surface: **only** PCI subsystem 0x1043:0x10c4
**Step 5.3: TRACE CALLEES**
Record: alc_fixup_headset_mic → snd_hda_apply_pincfgs, alc_update_coef_idx, sets HDA_PINCFG_HEADSET_MIC. Same pattern already used on other laptops in this file.
**Step 5.4: FOLLOW THE CALL CHAIN**
Record: Plug headset → HDA jack parse/probe → if quirk matches, pin 0x19 becomes a headset mic. **Reachable from userspace** on that laptop (PipeWire/ALSA capture). Reporter confirmed it.
**Step 5.5: SEARCH FOR SIMILAR PATTERNS**
Record: Same ALC2XX_FIXUP_HEADSET_MIC already applied to multiple vendors in alc269_fixup_tbl. This is the standard pattern for “BIOS left headset mic pin as 0x411111f0”.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
**Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?**
Record: **Yes.** This tree is **6.12.111** (pending-6.12, git describe HEAD = p-6.12-3-g710455e2077bb). Makefile: VERSION=6 PATCHLEVEL=12 SUBLEVEL=111.
- Quirk 0x1043:0x10c4 / “S5406SA” is **absent** (git grep found no matches).
- Realtek driver, ALC294 patch_alc269, ALC2XX_FIXUP_HEADSET_MIC, and Lunar Lake SOF (sound/soc/sof/intel/pci-lnl.c) **are present**.
- The machine is a 2024/2025 Lunar Lake laptop; 6.12 is an LTS that runs that hardware.
**Step 6.2: CHECK FOR BACKPORT COMPLICATIONS**
Record: **Minor path remap, otherwise clean.** Upstream hunk is against sound/hda/codecs/realtek/alc269.c; here the table is sound/pci/hda/patch_realtek.c. Context lines 0x10c0 then 0x10d0 match exactly. Enum name is the same. **Expected difficulty: trivial backport** (standard for HD-audio quirks on 6.12).
**Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE**
Record: Subject grep for S5406SA / this title found nothing. Pin quirks for ASUS ALC294 do not match this pin dump (0x12 is 0x40000000, not 0x90a60130). **No existing fix for this SSID.**
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
**Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY**
Record: **[sound/pci/hda Realtek codec] [IMPORTANT]** — common laptop audio, not mm/core, but HD-audio quirks are a large fraction of stable backports. Affects users of this ASUS model.
**Step 7.2: ASSESS SUBSYSTEM ACTIVITY**
Record: **Active but mature quirk table.** Recent commits are almost all device-specific SND_PCI_QUIRK additions — the same class as this patch.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
**Step 8.1: DETERMINE WHO IS AFFECTED**
Record: **Driver/hardware-specific** — only ASUS SSID 0x1043:0x10c4 (Vivobook S14 S5406SA, ALC294). Other machines unchanged.
**Step 8.2: DETERMINE THE TRIGGER CONDITIONS**
Record: **Every use of the 3.5mm headset mic** on that laptop. Not a race. Unprivileged user hits it by recording from the headset. Internal DMIC still works, so some users workaround; headset-mic users do not.
**Step 8.3: DETERMINE THE FAILURE MODE SEVERITY**
Record: **[Headset analog capture silently fails] [MEDIUM functional / HIGH for affected hardware]** — not a panic/UAF, but the combo-jack mic is unusable, which is exactly what hardware-quirk stable exceptions cover. Confirmed by a real user; second report on Arch for the same SSID.
**Step 8.4: CALCULATE RISK-BENEFIT RATIO**
Record:
- **Benefit:** High for owners of this laptop on 6.12 LTS (headset mic works without a modprobe model override).
- **Risk:** Very low — one table entry, existing fixup, SSID-matched, maintainer-applied, user-tested.
- **Ratio:** Strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
**Step 9.1: COMPILE THE EVIDENCE**
**FOR:**
- Real, user-confirmed hardware bug (GitHub #5729; model param proven on the same machine)
- Classic HD-audio PCI quirk — stable exception category
- One line, existing ALC2XX_FIXUP_HEADSET_MIC already in 6.12
- ALC294 and Lunar Lake SOF support exist here
- Isolated to one SSID; no API/feature
- Applied by Takashi Iwai; no NAKs
- Insertion context 0x10c0/0x10d0 matches this file
**AGAINST:**
- Upstream path is alc269.c; this tree still uses patch_realtek.c (trivial remap)
- Not a crash/security issue (quirks are still accepted)
- Original patch had no Cc: stable (not a negative per the rules)
**UNRESOLVED:**
- lore.kernel.org HTTP 403; stable@ discussion not fetched (thread recovered via b4)
- No upstream SHA in this checkout for b4 dig -c
**Step 9.2: APPLY THE STABLE RULES CHECKLIST**
1. Obviously correct and tested? **PASS** — same fixup already in tree; reporter confirmed alc2xx-fixup-headset-mic; maintainer applied it
2. Fixes a real bug that affects users? **PASS** — silent headset-mic capture on a shipping Lunar Lake ASUS
3. Important issue? **PASS** under the hardware-quirk exception (device feature broken; not cosmetic)
4. Small and contained? **PASS** — +1 line
5. No new features or APIs? **PASS** — existing quirk ID only
6. Can apply to the local tree? **PASS** — needs path change to sound/pci/hda/patch_realtek.c; context matches
**Step 9.3: CHECK FOR EXCEPTION CATEGORIES**
Record: **Hardware quirk/workaround** (and PCI-ID-style table addition to an existing driver). Automatic YES class per the stable quirk rules.
**Step 9.4: MAKE YOUR DECISION**
This belongs on 6.12. The bug is present, the fixup infrastructure is present, Lunar Lake audio is present, and the change is a one-line SSID quirk that only enables headset-mic pin parsing on that laptop.
Verification:
- [Phase 1] Parsed subject/tags: Fix + GitHub issue + msgid 3/4; no Fixes/Cc:stable (expected)
- [Phase 1] Body: ALC294 SSID 0x104310c4 headset mic silent; quirk ALC2XX_FIXUP_HEADSET_MIC
- [Phase 2] Diff: +1 SND_PCI_QUIRK(0x1043, 0x10c4, ...) in alc269_fixup_tbl
- [Phase 2] This tree implements that ID via alc_fixup_headset_mic():
pin 0x19 → 0x03a1103c + HDA_PINCFG_HEADSET_MIC
- [Phase 3] 1c643c600407d (alc2xx-fixup-headset-mic model) is in HEAD; upstream 50db91fccea0d is not an ancestor (expected 6.12 vs 6.13)
- [Phase 3] git log --grep=S5406SA -- sound/pci/hda/: no matches; quirk not already applied
- [Phase 3] Series 1/4–4/4 are independent quirks; 3/4 is standalone
- [Phase 4] b4 mbox 20260807125857.678297-3: Takashi Iwai applied all four; no NAK
- [Phase 4] GitHub #5729: reporter confirmed hda_model=alc2xx-fixup- headset-mic restores capture
- [Phase 4] lore.kernel.org WebFetch: 403 — UNVERIFIED via HTTP; recovered via b4
- [Phase 5] ALC294 → patch_alc269 → snd_hda_pick_fixup(alc269_fixup_tbl); caller is codec probe
- [Phase 5] ASUS ALC294 pin quirks do not match this machine (0x12 is 0x40000000)
- [Phase 6] git describe HEAD: p-6.12-3-g710455e2077bb; make kernelversion 6.12.111
- [Phase 6] File is sound/pci/hda/patch_realtek.c; 0x10c0/0x10d0 neighbors match; 0x10c4 absent
- [Phase 6] sound/soc/sof/intel/pci-lnl.c present (Lunar Lake SOF)
- [Phase 8] Failure mode: silent analog headset mic, SSID-scoped; severity medium functionally, high for that hardware
- UNVERIFIED: whether stable@ already discussed this commit (lore 403)
The one-line quirk is the standard stable HD-audio backport: it restores headset-mic capture on one confirmed laptop with negligible risk.
**YES**
sound/hda/codecs/realtek/alc269.c | 1 + 1 file changed, 1 insertion(+)
sound/hda/codecs/realtek/alc269.c +1 -0
@@ -7101,6 +7101,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x1043 ,0x10a1 ,"ASUS UX391UA" ,ALC294_FIXUP_ASUS_SPK ),SND_PCI_QUIRK (0x1043 ,0x10a4 ,"ASUS TP3407SA" ,ALC287_FIXUP_TAS2781_I2C ),SND_PCI_QUIRK (0x1043 ,0x10c0 ,"ASUS X540SA" ,ALC256_FIXUP_ASUS_MIC ), +SND_PCI_QUIRK (0x1043 ,0x10c4 ,"ASUS Vivobook S14 S5406SA" ,ALC2XX_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1043 ,0x10d0 ,"ASUS X540LA/X540LJ" ,ALC255_FIXUP_ASUS_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1043 ,0x10d3 ,"ASUS K6500ZC" ,ALC294_FIXUP_ASUS_SPK ), SND_PCI_QUIRK(0x1043, 0x1154, "ASUS TP3607SH", ALC287_FIXUP_TAS2781_I2C),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: brcmfmac: validate msgbuf flowring IDs before use
In reply to Sasha LevinFrom: Can Peng <[email protected]>
[ Upstream commit 32856f39fefdc75bd253cab999f996750628648e ]
Firmware messages carry flow_ring_id values which brcmfmac converts to an internal flowid by subtracting BRCMF_H2D_MSGRING_FLOWRING_IDSTART. The resulting value is used as a bit index in txstatus_done_map and as an array index into msgbuf->flowrings and the flowring state.
Validate the firmware supplied flow_ring_id before using it. This prevents flow_ring_id values below BRCMF_H2D_MSGRING_FLOWRING_IDSTART from underflowing and rejects values outside msgbuf->max_flowrings.
In the tx status path, complete the packet with an error after removing a valid packet id so the skb is not leaked when the flow ring id is invalid.
---
LLM Generated explanations, may be completely bogus:
This is a 5.15.221 tree (pending-5.15). The buggy firmware-ID indexing is present here, and the patch is a small bounds check that prevents out-of-bounds writes/crashes and an skb leak.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [subsystem: wifi: brcmfmac] [action verb: validate] [intent:
reject firmware-supplied msgbuf flowring IDs before they are used as bitmap/array indexes]
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record: Tags in the candidate message:
- Acked-by: Arend van Spriel <[email protected]> (brcmfmac maintainer)
- Link:
https://patch.msgid.link/[email protected]
- Signed-off-by: Can Peng <[email protected]> (author)
- Signed-off-by: Johannes Berg <[email protected]> (wireless maintainer who applied it)
No Reported-by, Tested-by, Fixes, or Cc: stable in the candidate text (absence expected). The original mailing-list submission (v1, same msgid) did include Fixes: 9a1bb60250d2 ("brcmfmac: Adding msgbuf protocol.") and Cc: [email protected]; those are author- submitted tags, not pipeline markers.
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: firmware flow_ring_id is converted with id - BRCMF_H2D_MSGRING_FLOWRING_IDSTART and then used as a bit index in txstatus_done_map and an array index into msgbuf->flowrings / flowring state, with no range check.
- Failure mode: IDs below BRCMF_H2D_MSGRING_FLOWRING_IDSTART (2) underflow a u16; IDs above max_flowrings index past allocated arrays. On the TX-status path, a valid pktid can already have been taken, so an early return would leak the skb.
- Version info in the body: none. Original Fixes target is from 2014.
- Root cause (author): missing validation of firmware-supplied ring IDs.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not a hidden fix. The subject/body describe a bounds check and an skb-leak close on the invalid-ID TX-status path.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c (single file)
- Scope: ~40 insertions / 6 deletions (mailing-list v1: 46 lines net in that file)
- Functions: adds brcmf_msgbuf_get_flowid(); changes brcmf_msgbuf_process_txstatus(), brcmf_msgbuf_process_flow_ring_create_response(), brcmf_msgbuf_process_flow_ring_delete_response()
- Classification: single-file surgical fix
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
- Helper (new): convert firmware flow_ring_id to internal flowid only if id >= BRCMF_H2D_MSGRING_FLOWRING_IDSTART and (id - START) < msgbuf->max_flowrings. Uses u32 so the subtract cannot wrap.
- TX status (normal/error path): previously always subtracted then set_bit(flowid, txstatus_done_map), msgbuf->flowrings[flowid], atomic_dec, brcmf_txfinalize(..., true). After: if ID invalid, brcmf_txfinalize(..., false) and return (skb already taken from pktid table).
- Create/delete response: previously subtracted and used the index unconditionally (brcmf_msgbuf_remove_flowring, brcmf_flowring_open, brcmf_flowring_delete). After: invalid ID returns without touching rings.
Step 2.3: IDENTIFY THE BUG MECHANISM
Record:
- Category: memory safety (out-of-bounds index / underflow) plus resource leak on the TX-status error path.
- Mechanism: firmware DMA completion messages supply compl_hdr.flow_ring_id. BRCMF_H2D_MSGRING_FLOWRING_IDSTART is 2. For ID 0 or 1, u16 flowid -= 2 wraps to 65534/65535. set_bit() then writes far past txstatus_done_map (sized to max_flowrings bits). msgbuf->flowrings[flowid] is an OOB load and typically a crash. Oversized IDs do the same without wrapping. The helper rejects both. TX-status also finalizes the skb so brcmf_msgbuf_get_pktid()’s take is not leaked.
Step 2.4: ASSESS THE FIX QUALITY
Record:
- Obviously correct: range check matches how the host builds IDs (flowid + BRCMF_H2D_MSGRING_FLOWRING_IDSTART in create/delete requests). Happy path is unchanged.
- Minimal: one helper, three call sites, no API change.
- Regression risk: low. Invalid create/delete IDs now skip ring teardown; that is safer than OOB. A stuck ring on bogus firmware is preferable to memory corruption. brcmf_txfinalize() already handles a NULL ifp from a bad ifidx by freeing the skb.
- Red flags: none. Double blank line after the helper is style-only (v2 tried to clean it; Johannes applied v1).
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Unvalidated flowid = le16_to_cpu(...flow_ring_id) dates to 9a1bb60250d2 (Hante Meuleman, 2014-07-30), “brcmfmac: Adding msgbuf protocol.”
- The subtract of BRCMF_H2D_MSGRING_FLOWRING_IDSTART was added in be4b092cab84b (Franky Lin, 2016-11-23), “brcmfmac: add pcie host dongle interface rev6 support” (replaced BRCMF_NROF_H2D_COMMON_MSGRINGS, also 2).
- Code has been in-tree for many years, including this 5.15 branch.
Step 3.2: FOLLOW THE FIXES: TAG
Record:
- Original mailing-list Fixes: 9a1bb60250d2. git merge-base --is- ancestor 9a1bb60250d2 HEAD succeeds.
- Slightly imprecise: large-ID OOB is from 2014; underflow of IDs 0/1 is from the 2016 subtract. Both commits are in this tree.
- No later in-tree fix of the same hole (brcmf_msgbuf_get_flowid is absent; git log --grep="invalid flowring" / --grep="flow_ring_id" on this path found nothing equivalent).
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record: Recent msgbuf.c commits here are unrelated (pktid DMA unmap, allocation-mode plumbing, memleak in attach). Not part of a functional series that must land first. v2 was whitespace-only prep + the same validation; Johannes applied v1 and declined the cleanup.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: git log --author="Can Peng" on drivers/net/wireless/broadcom/brcm80211/ in this tree is empty (outside contributor). Weight comes from Arend van Spriel’s Acked-by and Johannes applying the patch.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: No new helpers, structs, or APIs. Uses existing bphy_err, brcmf_txfinalize, brcmf_get_ifp, msgbuf->max_flowrings. Standalone. v2 patch 1/2 (blank-line cleanup) is not required.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 mbox on msgid [email protected] retrieved the thread (lore WebFetch returned 403).
- v1: standalone [PATCH wireless] with Fixes + Cc: stable.
- Arend: one nit (double blank line), “To be applied to wireless tree,” Acked-by. No NAK.
- v2: 0/2 cover + whitespace cleanup + same validation rebase. Johannes:
too late, he already applied v1; not rebasing for whitespace.
- Applied version matches the candidate (v1, double blank line kept). No later functional revision.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: To: Arend van Spriel. Cc: linux-wireless, brcm80211 lists, linux-kernel, [email protected]. Ack from the brcm80211 maintainer; applied by Johannes Berg.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No syzbot, bugzilla, or user crash in the message. Justification is code analysis of firmware-supplied indexes. Trigger is a bad flow_ring_id on D2H completion rings (firmware bug, DMA corruption, or hostile firmware), not a documented userspace repro.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: v2 series is cleanup + this fix. Functional patch is self- contained. No other msgbuf ID-validation patches in the thread.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: Author Cc’d [email protected] on v1/v2. No separate stable- list rejection found. lore.kernel.org HTTP from WebFetch was 403; evidence is the b4-retrieved mbox.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: brcmf_msgbuf_get_flowid (new);brcmf_msgbuf_process_txstatus;brcmf_msgbuf_process_flow_ring_create_response;brcmf_msgbuf_process_flow_ring_delete_response.
Step 5.2: TRACE CALLERS
Record:
- All three process_* functions are called only from brcmf_msgbuf_process_msgtype() (MSGBUF_TYPE_TX_STATUS, MSGBUF_TYPE_FLOW_RING_CREATE_CMPLT, MSGBUF_TYPE_FLOW_RING_DELETE_CMPLT).
- That is called from brcmf_msgbuf_process_rx() while draining D2H rings.
- brcmf_proto_msgbuf_rx_trigger() calls process_rx for RX/TX/control complete rings.
- Call site: brcmf_pcie_isr_thread() in pcie.c on BRCMF_PCIE_MB_INT_D2H_DB (IRQ thread). Hot path for PCIe FullMAC traffic.
Step 5.3: TRACE CALLEES
Record: brcmf_msgbuf_get_pktid (takes skb out of the TX pktid table; already bounds-checks pktid); set_bit; msgbuf->flowrings[flowid]; atomic_dec(&commonring->outstanding_tx); brcmf_txfinalize; brcmf_get_ifp; brcmf_msgbuf_remove_flowring / brcmf_flowring_delete / brcmf_flowring_open (those use flowid as flow->rings[flowid] with no extra range check).
Step 5.4: FOLLOW THE CALL CHAIN
Record: Userspace TX → flowring → firmware; firmware posts TX-status / create / delete completions into DMA rings; host IRQ processes them. Any PCIe brcmfmac user hits this path. Not a syscall fuzz target by itself; firmware-supplied fields in DMA completions are still a real input.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Other flow_ring_id uses: host-generated create/delete requests, and ring-status which only logs the ID. No sibling driver copy of this helper. brcmf_flowring_delete/open do not bounds-check flowid; they assume the caller already has a valid index.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. This checkout is 5.15.221 (p-5.15-2-g6703e5d2f3a29). Unvalidated subtract is in msgbuf.c at process_txstatus (~883–891), create_response (~1239–1245), delete_response (~1268–1274). Introduced 2014/2016; present here. brcmf_msgbuf_get_flowid is not present.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Minor context conflict. 5.15 brcmf_msgbuf_rxreorder still has a bool inirq argument (687006e20c445); the candidate hunk context uses the later two-argument form. Insertion point after brcmf_msgbuf_remove_flowring and the three process_* hunks match.
Expected: trivial context adjust, not a rework. bphy_err, max_flowrings, brcmf_txfinalize all exist.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: No equivalent validation. Unrelated msgbuf fixes (pktid unmap, attach memleak) do not close this hole.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [brcmfmac msgbuf / PCIe FullMAC Wi-Fi] [IMPORTANT]. Not core mm/vfs, but used on Raspberry Pi-class boards and many Broadcom PCIe WLAN cards. CONFIG_BRCMFMAC_PCIE selects BRCMFMAC_PROTO_MSGBUF. SDIO/USB FullMAC uses BCDC, not this path.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Mature. msgbuf protocol from 2014; this file is not under heavy 5.15 churn. Long-standing hole, not a brand-new subsystem.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: Driver-specific / config-specific: CONFIG_BRCMFMAC_PCIE (msgbuf). Does not affect SDIO/USB brcmfmac. Population is still large for an LTS kernel.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Trigger is a firmware completion with flow_ring_id < 2 or >= max_flowrings + 2. Normal firmware should echo host IDs, so the common path is fine. Realistic triggers: buggy/mismatched firmware, DMA corruption, compromised firmware. Unprivileged userspace cannot poke the ID directly; it can generate TX completions by sending traffic.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- set_bit(underflowed_id, txstatus_done_map): out-of-bounds write (memory corruption).
- msgbuf->flowrings[flowid] / flow->rings[flowid]: OOB / NULL deref → oops.
- TX-status without finalize: skb leak (the patch closes this).
- Severity: HIGH (crash / memory corruption on a common Wi-Fi driver). Not a documented privilege-escalation writeup, but OOB write from device DMA is security-relevant.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: high for PCIe brcmfmac — prevents OOB write/crash and a leak.
- Risk: low — ~40-line helper, no locking/API/data-structure change, no happy-path behavior change.
- Ratio: strongly favors backport.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real OOB index from firmware-supplied IDs (underflow and upper bound), present in this 5.15 tree since 2014/2016.
- TX-status path can leak an skb after brcmf_msgbuf_get_pktid() if the ring ID is bad.
- Small, obviously correct helper; happy path unchanged.
- Maintainer Acked-by; wireless maintainer applied v1.
- Applies with only a trivial rxreorder-context tweak.
AGAINST:
- No public crash/syzbot report; trigger depends on bad firmware IDs.
- Affects only PCIe msgbuf, not all brcmfmac buses.
UNRESOLVED:
- Could not HTTP-fetch lore.kernel.org (403); thread was recovered via b4 mbox.
- No mainline SHA in this checkout to merge-base --is-ancestor the fix itself (expected: it is not in 5.15 yet).
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — range check matches host ID encoding; Acked by subsystem maintainer.
2. Fixes a real bug that affects users? PASS — unvalidated device- supplied index used as bit/array index; skb leak on that path.
3. Important issue? PASS — OOB write / crash / leak; HIGH.
4. Small and contained? PASS — one file, ~40 lines, three call sites.
5. No new features or APIs? PASS — internal helper only.
6. Can apply to the local tree? PASS — buggy code is here; minor context conflict only.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Not a device-ID/quirk/DT/build/docs exception. It is a straightforward memory-safety fix.
Step 9.4: MAKE YOUR DECISION
This should be backported to this 5.15 tree. The hole exists here, the fix is surgical, and the downside of skipping it is memory corruption or an oops if firmware supplies a bad flowring ID.
Verification:
- [Phase 1] Parsed candidate tags: Acked-by Arend van Spriel, Link msgid, SOBs Can Peng / Johannes Berg; no Fixes/Cc in candidate text.
- [Phase 1] b4 mbox v1 body: Fixes: 9a1bb60250d2 and `Cc:
[email protected]`.
- [Phase 2] Diff: helper brcmf_msgbuf_get_flowid; TX-status finalizes skb on invalid ID; create/delete return early.
- [Phase 2] Confirmed BRCMF_H2D_MSGRING_FLOWRING_IDSTART is 2 in bus.h; flowid is u16 so subtract underflows.
- [Phase 2] txstatus_done_map allocated as BITS_TO_LONGS(max_flowrings) * sizeof(unsigned long) — overflowed bit index is OOB.
- [Phase 2] brcmf_txfinalize() NULL-ifp path frees the skb (core.c).
- [Phase 3] git blame: unvalidated use 9a1bb60250d2 (2014); subtract be4b092cab84b (2016).
- [Phase 3] git merge-base --is-ancestor 9a1bb60250d2 HEAD: yes.
- [Phase 3] No brcmf_msgbuf_get_flowid in this tree; no prior “invalid flowring” fix on this path.
- [Phase 4] b4 mbox -c: 7 messages; v1 applied; v2 whitespace declined by Johannes; Arend Acked-by, no NAK.
- [Phase 4] WebFetch lore/msgid.link: 403; used b4 instead.
- [Phase 5] Call chain: brcmf_pcie_isr_thread → brcmf_proto_msgbuf_rx_trigger → brcmf_msgbuf_process_rx → process_msgtype → the three functions.
- [Phase 5] Host encodes IDs as flowid + BRCMF_H2D_MSGRING_FLOWRING_IDSTART at msgbuf.c create/delete request sites.
- [Phase 6] git describe HEAD: p-5.15-2-g6703e5d2f3a29; make kernelversion: 5.15.221.
- [Phase 6] Local process_txstatus still does unvalidated flowid -= BRCMF_H2D_MSGRING_FLOWRING_IDSTART.
- [Phase 6] Nearby brcmf_msgbuf_rxreorder(..., bool inirq) differs from candidate context → minor apply tweak.
- [Phase 7] Kconfig: BRCMFMAC_PCIE selects BRCMFMAC_PROTO_MSGBUF.
- [Phase 8] Failure mode: OOB set_bit / OOB flowrings[] dereference; severity HIGH.
- UNVERIFIED: live firmware that currently emits IDs < 2 (no user report in the thread).
**YES**
.../broadcom/brcm80211/brcmfmac/msgbuf.c | 46 ++++++++++++++++--- 1 file changed, 40 insertions(+), 6 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c +40 -6
@@ -561,6 +561,28 @@ brcmf_msgbuf_remove_flowring(struct brcmf_msgbuf *msgbuf, u16 flowid)brcmf_flowring_delete (msgbuf->flow, flowid); } +static bool brcmf_msgbuf_get_flowid (struct brcmf_msgbuf *msgbuf, +u16 flow_ring_id,u16 *flowid) +{ +u32 id = flow_ring_id; + +if (id <BRCMF_H2D_MSGRING_FLOWRING_IDSTART ) { +bphy_err (msgbuf->drvr,"invalid flowring id %u\n" , + flow_ring_id); +return false; + } + + id -=BRCMF_H2D_MSGRING_FLOWRING_IDSTART ; +if (id >= msgbuf->max_flowrings) { +bphy_err (msgbuf->drvr,"invalid flowring id %u\n" , + flow_ring_id); +return false; + } + + *flowid = id; +return true; +} +static struct brcmf_msgbuf_work_item *brcmf_msgbuf_dequeue_work (struct brcmf_msgbuf *msgbuf)
@@ -881,17 +903,23 @@ brcmf_msgbuf_process_txstatus(struct brcmf_msgbuf *msgbuf, void *buf)struct msgbuf_tx_status *tx_status;u32 idx;struct sk_buff *skb; +u16 flow_ring_id;u16 flowid; tx_status = (struct msgbuf_tx_status *)buf; idx =le32_to_cpu (tx_status->msg.request_id) -1 ; - flowid =le16_to_cpu (tx_status->compl_hdr.flow_ring_id); - flowid -=BRCMF_H2D_MSGRING_FLOWRING_IDSTART ; + flow_ring_id =le16_to_cpu (tx_status->compl_hdr.flow_ring_id); skb =brcmf_msgbuf_get_pktid (msgbuf->drvr->bus_if->dev, msgbuf->tx_pktids, idx);if (!skb)return ; +if (!brcmf_msgbuf_get_flowid (msgbuf, flow_ring_id, &flowid)) { +brcmf_txfinalize (brcmf_get_ifp (msgbuf->drvr, tx_status->msg.ifidx), + skb, false); +return ; + } +set_bit (flowid, msgbuf->txstatus_done_map); commonring = msgbuf->flowrings[flowid];atomic_dec (&commonring->outstanding_tx);
@@ -1238,13 +1266,16 @@ brcmf_msgbuf_process_flow_ring_create_response(struct brcmf_msgbuf *msgbuf,struct msgbuf_flowring_create_resp *flowring_create_resp;u16 status;u16 flowid; +u16 flow_ring_id; flowring_create_resp = (struct msgbuf_flowring_create_resp *)buf; - flowid =le16_to_cpu (flowring_create_resp->compl_hdr.flow_ring_id); - flowid -=BRCMF_H2D_MSGRING_FLOWRING_IDSTART ; + flow_ring_id =le16_to_cpu (flowring_create_resp->compl_hdr.flow_ring_id); status =le16_to_cpu (flowring_create_resp->compl_hdr.status); +if (!brcmf_msgbuf_get_flowid (msgbuf, flow_ring_id, &flowid)) +return ; +if (status) {bphy_err (drvr,"Flowring creation failed, code %d\n" , status);brcmf_msgbuf_remove_flowring (msgbuf, flowid);
@@ -1267,13 +1298,16 @@ brcmf_msgbuf_process_flow_ring_delete_response(struct brcmf_msgbuf *msgbuf,struct msgbuf_flowring_delete_resp *flowring_delete_resp;u16 status;u16 flowid; +u16 flow_ring_id; flowring_delete_resp = (struct msgbuf_flowring_delete_resp *)buf; - flowid =le16_to_cpu (flowring_delete_resp->compl_hdr.flow_ring_id); - flowid -=BRCMF_H2D_MSGRING_FLOWRING_IDSTART ; + flow_ring_id =le16_to_cpu (flowring_delete_resp->compl_hdr.flow_ring_id); status =le16_to_cpu (flowring_delete_resp->compl_hdr.status); +if (!brcmf_msgbuf_get_flowid (msgbuf, flow_ring_id, &flowid)) +return ; +if (status) {bphy_err (drvr,"Flowring deletion failed, code %d\n" , status);brcmf_flowring_delete (msgbuf->flow, flowid);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ksmbd: fix SMB2 byte-range lock end offset
In reply to Sasha LevinFrom: Namjae Jeon <[email protected]>
[ Upstream commit 54d90311f9b4eb23f3b0b62650b0cfddb11a12ef ]
SMB2 describes a byte-range lock using an offset and a length, while Linux file_lock uses an inclusive end offset. smb2_lock() currently sets fl_end to start + length and consequently locks one extra byte for every nonzero-length request.
Translate nonzero lengths to start + length - 1 and reject ranges that cannot be represented by loff_t instead of silently truncating them at OFFSET_MAX. Track zero-length locks from the request length so one-byte ranges are not mistaken for zero-length locks after endpoint conversion.
---
LLM Generated explanations, may be completely bogus:
The local tree is **6.12.111** (pending-6.12). The candidate is mainline 54d90311f9b4e (ksmbd: fix SMB2 byte-range lock end offset). It is not in this checkout, and the buggy smb2_lock() conversion is.
===============================================================
PHASE 1: COMMIT MESSAGE FORENSICS
===============================================================
Step 1.1: PARSE THE SUBJECT LINE
Record: [ksmbd] [fix] [SMB2 byte-range lock end offset is off by one vs Linux file_lock inclusive ends]
Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
Record:
- Signed-off-by: Namjae Jeon \<[email protected]\> (ksmbd maintainer)
- No Fixes:
- No Reported-by / Tested-by / Reviewed-by / Acked-by
- No Link:
- No Cc: stable
Absence of Fixes/Cc:stable is expected for this review pipeline and is not a negative signal.
Step 1.3: ANALYZE THE COMMIT BODY TEXT
Record:
- Bug: SMB2 describes a lock as (offset, length). Linux file_lock uses an inclusive fl_end. smb2_lock() sets fl_end = start + length, so every nonzero-length lock covers one extra byte.
- Symptom: adjacent-byte I/O or locks can hit a false conflict; unlock/lock ranges disagree with Windows/Samba; huge ranges are silently truncated at OFFSET_MAX instead of being rejected.
- Root cause: missing length - 1 conversion, plus start == end used as a zero-length detector (that becomes wrong once 1-byte locks correctly get start == end).
- No kernel version called out in the message. Pull text for 7.3-rc1 lists this among protocol-compatibility lock fixes.
Step 1.4: DETECT HIDDEN BUG FIXES
Record: Not disguised. It is an explicit off-by-one / range-translation bug fix, plus a necessary zero-length tracking correction so the conversion does not reclassify 1-byte locks as empty.
===============================================================
PHASE 2: DIFF ANALYSIS - LINE BY LINE
===============================================================
Step 2.1: INVENTORY THE CHANGES
Record:
- File: fs/smb/server/smb2pdu.c only (+14 / -30)
- Functions: smb2_lock_init(), smb2_lock()
- Scope: single-file surgical fix
Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
Record:
1. smb2_lock_init(): stop inferring zero_len from start == end; take it from the SMB2 request length (!lock_length).
2. Range setup in smb2_lock():
- Before: clamp start/length to OFFSET_MAX, set fl_end = start + length, then reject wrap with fl_end < fl_start.
- After: reject if start or inclusive end cannot be represented in loff_t; set fl_end = start + length - 1 (or start if length is 0).
3. Zero-byte conflict tests: < end → <= end so the last locked byte is included.
4. Non-zero overlap test: ad-hoc half-open checks → standard inclusive overlap (start1 <= end2 && start2 <= end1), matching VFS locks_overlap().
Step 2.3: IDENTIFY THE BUG MECHANISM
Record: [Logic / correctness, plus bounds]
- Off-by-one: POSIX fl_end is inclusive (fs/locks.c uses fl_end = fl_start + (l_len - 1)).
- Classification: after that conversion, a 1-byte lock has start == end. Using that as zero_len would skip vfs_lock_file() (if (smb_lock->zero_len) goto skip).
- Overflow: old code silently truncated at OFFSET_MAX; new code returns STATUS_INVALID_LOCK_RANGE.
- Conflict checks: old comparisons assumed exclusive-ish ends and missed some inclusive overlaps.
Step 2.4: ASSESS THE FIX QUALITY
Record: Obviously correct. Same conversion as VFS flock_to_posix_lock() and the CIFS client (fl_end = start + (length ? length - 1 : 0)). Overlap test matches locks_overlap(). Minimal, no API change. Regression risk is low: adjacent-byte I/O that was wrongly denied will now succeed; unrepresentable ranges that were clamped will now fail, which matches the spec.
===============================================================
PHASE 3: GIT HISTORY INVESTIGATION
===============================================================
Step 3.1: BLAME THE CHANGED LINES
Record:
- Core fl_end = fl_start + lock_length comes from e2f34481b24db2 (“cifsd: add server-side procedures for SMB3”, 2021-05-10), first in v5.15-rc1.
- OFFSET_MAX clamping: 50bf80a553ccb5 (“cifsd: fix xfstests generic/504 test failure”).
- zero_len / conflict checks: d63528eb0d43c4 (Hyunchul Lee, 2021-07-10).
The bug has been in ksmbd since the server was merged.
Step 3.2: FOLLOW THE FIXES: TAG
Record: No Fixes: tag. The introducing commit is in this tree (git merge-base --is-ancestor e2f34481b24db2 HEAD succeeded).
Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Record:
- Already in this tree: f751d6e39d4c9 “ksmbd: Do not skip lock checks for single-byte ranges” — check_lock_range() uses inclusive start + length - 1. That makes the remaining smb2_lock() off-by-one more inconsistent, not less.
- Later on fs-next, not required here: 5ce5227cd60b7 “recognize replayed SMB2 lock sequences” (replay feature, not a prerequisite).
Standalone.
Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Record: Namjae Jeon is the ksmbd maintainer (MAINTAINERS + Git). This is not a drive-by change.
Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
Record: No new helpers. smb2_lock_init() has a single caller. git apply --check of 54d90311f9b4e succeeds on this tree (hunk offsets only). Standalone.
===============================================================
PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
===============================================================
Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Record:
- b4 dig -c 54d90311f9b4e (with and without -C/-a):
lore.kernel.org returned errors; no thread URL.
- WebFetch of lore.kernel.org: HTTP 403.
- LKML [GIT PULL] ksmbd server update for 7.3-rc1 lists this commit in Namjae’s 7.3-rc1 pull, among lock/protocol-compatibility fixes.
UNVERIFIED: individual review comments, v2/v3 revisions, reviewer Cc:stable.
Step 4.2: CHECK WHO REVIEWED THE PATCH
Record: Only the maintainer SOB is on the commit. b4 dig -w failed. Subsystem maintainer authored it.
Step 4.3: SEARCH FOR THE BUG REPORT
Record: No Reported-by on this commit. Older ksmbd-tools issue #68 shows real users hitting smb2_lock “end offset(ffffffffffffffff) is smaller than the start offset” — the overflow path this patch now rejects instead of wrapping. That report is historical (cifsd era), not a direct report of this patch.
Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
Record: Adjacent 7.3 lock patches are replay/UAF/compound features. This conversion fix does not depend on them. Related inclusive-range I/O fix is already in this tree.
Step 4.5: CHECK STABLE MAILING LIST HISTORY
Record: lore.kernel.org/stable search could not be fetched (403). No verified stable NAK. This tree does not already contain “lock end offset”.
===============================================================
PHASE 5: CODE SEMANTIC ANALYSIS
===============================================================
Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
Record: smb2_lock_init(), smb2_lock()
Step 5.2: TRACE CALLERS
Record:
- smb2_lock() is the SMB2_LOCK handler (smb2_0_server_cmds[SMB2_LOCK_HE] in fs/smb/server/smb2ops.c).
- smb2_lock_init() is only called from smb2_lock(). Reachable from any SMB2/SMB3 client that issues LOCK.
Step 5.3: TRACE CALLEES
Record: vfs_lock_file(), locks_free_lock(), smb_flock_init(), ksmbd connection lock-list walk. Zero-length locks still skip vfs_lock_file() by design (POSIX l_len == 0 means lock-to-EOF, which is not SMB zero-byte lock semantics).
Step 5.4: FOLLOW THE CALL CHAIN
Record: Network SMB2 LOCK → smb2_lock() → VFS POSIX locks / ksmbd lock list → later check_lock_range() on read/write/truncate. Userspace- reachable over the network. Not a rare config path if CONFIG_SMB_SERVER is enabled.
Step 5.5: SEARCH FOR SIMILAR PATTERNS
Record: Same inclusive conversion already exists in fs/locks.c and fs/smb/client/cifssmb.c. I/O-side check_lock_range() in this tree already uses pos + count - 1. Only the LOCK request path was still off by one.
===============================================================
PHASE 6: CROSS-REFERENCING AGAINST THE LOCAL TREE
===============================================================
Step 6.1: DOES THE BUGGY CODE EXIST IN THIS TREE?
Record: Yes. fs/smb/server/smb2pdu.c around 7584–7602 still does fl_end = fl_start + lock_length and if (lock->start == lock->end) lock->zero_len = 1. Introduced with cifsd in v5.15, present in 6.12.111.git merge-base --is-ancestor 54d90311f9b4e HEAD failed — the fix is not here.
Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
Record: Clean apply (git apply --check succeeded; hunks at 7488+). Nearby mainline-only context (lock_count > 64, kzalloc_obj) is not part of this commit’s hunks. Expected difficulty: clean apply.
Step 6.3: CHECK IF RELATED FIXES ARE ALREADY HERE
Record: Inclusive I/O lock checks (f751d6e39d4c9) are here. No prior “lock end offset” fix. Applying this makes LOCK and I/O use the same inclusive model.
===============================================================
PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
===============================================================
Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
Record: [fs/smb/server (ksmbd)] [IMPORTANT for ksmbd users / PERIPHERAL vs core VFS]. Byte-range locks are a core SMB feature for Windows apps, databases, and exclusive file access. CONFIG_SMB_SERVER defaults to n.
Step 7.2: ASSESS SUBSYSTEM ACTIVITY
Record: Actively maintained; this 6.12 tree already carries many ksmbd stable backports. The author is the maintainer.
===============================================================
PHASE 8: IMPACT AND RISK ASSESSMENT
===============================================================
Step 8.1: DETERMINE WHO IS AFFECTED
Record: ksmbd/SMB3 server users (CONFIG_SMB_SERVER). Every SMB2 LOCK with nonzero length.
Step 8.2: DETERMINE THE TRIGGER CONDITIONS
Record: Common for any client using byte-range locks (Office, databases, installers, some build tools). Network-facing; an unprivileged SMB user who can open a file can issue LOCK. Not a rare race.
Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
Record:
- Over-lock of one extra byte → false STATUS_FILE_LOCK_CONFLICT / denied I/O on the adjacent byte; apps can fail or block. HIGH for ksmbd shares that use locking.
- Silent clamp of huge ranges → requested bytes past OFFSET_MAX stay unlocked. Integrity hole, rare offsets. MEDIUM.
- If this conversion were done without passing original zero_len, 1-byte locks would skip VFS — that would be under-lock / data-race. The patch prevents that. HIGH if mishandled; the patch handles it.
Severity overall: HIGH for locking correctness, not a kernel oops.
Step 8.4: CALCULATE RISK-BENEFIT RATIO
Record:
- Benefit: correct exclusive ranges vs Windows/Samba/VFS; fewer false conflicts; no silent truncation.
- Risk: very low (14/30 lines, one file, applies cleanly, matches established conversion).
- Ratio: strongly favors backporting.
===============================================================
PHASE 9: FINAL SYNTHESIS
===============================================================
Step 9.1: COMPILE THE EVIDENCE
FOR:
- Real, long-standing off-by-one in mandatory SMB byte-range locks (since v5.15).
- User-visible false conflicts on the extra byte; protocol mismatch with Windows/Samba.
- Silent OFFSET_MAX truncation replaced by a spec-style invalid-range error.
- Zero-length vs 1-byte classification fixed so inclusive ends do not skip vfs_lock_file().
- Overlap tests aligned with VFS locks_overlap().
- Small, maintainer-authored, applies cleanly here.
- This tree already uses inclusive ends on the I/O path, so leaving LOCK wrong is inconsistent.
AGAINST:
- No crash/UAF/CVE; no Reported-by on this commit.
- ksmbd is opt-in, not core VFS.
- Could not retrieve the original review thread (lore errors).
UNRESOLVED:
- Original mailing-list review comments / explicit stable nomination.
Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. Obviously correct and tested? PASS — matches VFS and CIFS client math; maintainer SOB; in the 7.3-rc1 ksmbd pull.
2. Fixes a real bug that affects users? PASS — wrong lock coverage on every nonzero SMB2 LOCK.
3. Important issue? PASS — mandatory lock correctness (false conflicts; possible under-lock on truncated huge ranges). Not a panic, but it is data-access / sharing integrity.
4. Small and contained? PASS — one file, +14/-30.
5. No new features or APIs? PASS.
6. Can apply to the local tree? PASS — git apply --check clean; buggy code present.
Step 9.3: CHECK FOR EXCEPTION CATEGORIES
Record: Not a device-ID/quirk/DT/build/docs exception. Ordinary correctness fix.
Step 9.4: MAKE YOUR DECISION
This should be backported to this 6.12 tree. The extra locked byte is a real protocol bug on a path every locking SMB client hits. The patch is small, correct, has no prerequisites that this tree lacks, and applies cleanly.
Verification:
- [Phase 1] Parsed subject/body/tags on 54d90311f9b4e; maintainer SOB only; no Fixes/Reported-by/Cc:stable.
- [Phase 2] Diff: smb2_lock_init + smb2_lock in fs/smb/server/smb2pdu.c, +14/-30; inclusive fl_end, request-based zero_len, overlap <=.
- [Phase 2] Confirmed VFS conversion at fs/locks.c:515-518 (fl_end = fl_start + (l_len - 1)) and locks_overlap() at 621-624.
- [Phase 2] Confirmed CIFS client uses the same formula at fs/smb/client/cifssmb.c:2122-2124.
- [Phase 2] Confirmed zero-len locks skip vfs_lock_file() at smb2pdu.c:7742-7748 in this tree.
- [Phase 3] git blame: buggy fl_end = start + length from e2f34481b24db2 (v5.15-rc1); clamp from 50bf80a553ccb5.
- [Phase 3] git merge-base --is-ancestor e2f34481b24db2 HEAD succeeded; 54d90311f9b4e is not an ancestor of HEAD.
- [Phase 3] Follow-up 5ce5227cd60b7 is lock-replay, not a prerequisite.
- [Phase 4] b4 dig -c 54d90311f9b4e failed (lore errors). LKML 7.3-rc1 ksmbd pull lists this commit.
- [Phase 4] UNVERIFIED: original lore review thread (403/server error).
- [Phase 5] smb2_lock is SMB2_LOCK_HE proc; smb2_lock_init has one caller.
- [Phase 6] make kernelversion / Makefile: 6.12.111, branch pending-6.12, git describe HEAD = p-6.12-3-gc504cf0baa3d8.
- [Phase 6] Live code at smb2pdu.c:7602 still uses fl_start + lock_length.
- [Phase 6] git show 54d90311f9b4e | git apply --check succeeded.
- [Phase 6] Related f751d6e39d4c9 (inclusive I/O checks) is already in HEAD.
- [Phase 7] MAINTAINERS: ksmbd maintained by Namjae Jeon; CONFIG_SMB_SERVER default n.
- [Phase 8] Failure mode: false lock conflicts / incorrect coverage on SMB2 LOCK; severity HIGH for ksmbd locking users, not a kernel oops.
- UNVERIFIED: Could not read lore.kernel.org patch review or stable@ discussion.
The extra-byte lock is a real, old ksmbd protocol bug. The fix is small, matches VFS, and applies cleanly to 6.12.111.
**YES**
fs/smb/server/smb2pdu.c | 44 +++++++++++++---------------------------- 1 file changed, 14 insertions(+), 30 deletions(-)
fs/smb/server/smb2pdu.c +14 -30
@@ -7604,7 +7604,7 @@ static int smb2_set_flock_flags(struct file_lock *flock, int flags) }static struct ksmbd_lock *smb2_lock_init (struct file_lock *flock, -unsigned int cmd,int flags, +unsigned int cmd,int flags,bool zero_len,struct list_head *lock_list) {struct ksmbd_lock *lock;
@@ -7618,8 +7618,7 @@ static struct ksmbd_lock *smb2_lock_init(struct file_lock *flock, lock->start = flock->fl_start; lock->end = flock->fl_end; lock->flags = flags; -if (lock->start == lock->end) - lock->zero_len =1 ; + lock->zero_len = zero_len;INIT_LIST_HEAD (&lock->clist);INIT_LIST_HEAD (&lock->flist);INIT_LIST_HEAD (&lock->llist);
@@ -7712,32 +7711,18 @@ int smb2_lock(struct ksmbd_work *work) lock_start =le64_to_cpu (lock_ele[i].Offset); lock_length =le64_to_cpu (lock_ele[i].Length); -if (lock_start >U64_MAX - lock_length) { +if (lock_start >OFFSET_MAX || + (lock_length && + lock_length -1 >OFFSET_MAX - lock_start)) {pr_err ("Invalid lock range requested\n" ); rsp->hdr.Status =STATUS_INVALID_LOCK_RANGE ;locks_free_lock (flock); goto out; } -if (lock_start >OFFSET_MAX ) - flock->fl_start =OFFSET_MAX ; -else - flock->fl_start = lock_start; - - lock_length =le64_to_cpu (lock_ele[i].Length); -if (lock_length >OFFSET_MAX - flock->fl_start) - lock_length =OFFSET_MAX - flock->fl_start; - - flock->fl_end = flock->fl_start + lock_length; - -if (flock->fl_end < flock->fl_start) { -ksmbd_debug (SMB , -"the end offset(%llx) is smaller than the start offset(%llx)\n" , - flock->fl_end, flock->fl_start); - rsp->hdr.Status =STATUS_INVALID_LOCK_RANGE ; -locks_free_lock (flock); - goto out; - } + flock->fl_start = lock_start; + flock->fl_end = lock_length ? + flock->fl_start + lock_length -1 : flock->fl_start;/* Check conflict locks in one request */ list_for_each_entry (cmp_lock, &lock_list, llist) {
@@ -7753,7 +7738,8 @@ int smb2_lock(struct ksmbd_work *work) } } - smb_lock =smb2_lock_init (flock, cmd, flags, &lock_list); + smb_lock =smb2_lock_init (flock, cmd, flags, !lock_length, + &lock_list);if (!smb_lock) { err = -EINVAL ;locks_free_lock (flock);
@@ -7827,7 +7813,7 @@ int smb2_lock(struct ksmbd_work *work)/* check zero byte lock range */ if (cmp_lock->zero_len && !smb_lock->zero_len && cmp_lock->start > smb_lock->start && - cmp_lock->start < smb_lock->end) { + cmp_lock->start <= smb_lock->end) {spin_unlock (&conn->llist_lock);up_read (&conn_list_lock);pr_err ("previous lock conflict with zero byte lock range\n" );
@@ -7836,17 +7822,15 @@ int smb2_lock(struct ksmbd_work *work)if (smb_lock->zero_len && !cmp_lock->zero_len && smb_lock->start > cmp_lock->start && - smb_lock->start < cmp_lock->end) { + smb_lock->start <= cmp_lock->end) {spin_unlock (&conn->llist_lock);up_read (&conn_list_lock);pr_err ("current lock conflict with zero byte lock range\n" ); goto out; } -if (((cmp_lock->start <= smb_lock->start && - cmp_lock->end > smb_lock->start) || - (cmp_lock->start < smb_lock->end && - cmp_lock->end >= smb_lock->end)) && +if (cmp_lock->start <= smb_lock->end && + smb_lock->start <= cmp_lock->end && !cmp_lock->zero_len && !smb_lock->zero_len) {spin_unlock (&conn->llist_lock);up_read (&conn_list_lock);
Signature · 1 line
2.53.0