ALSA: hda/realtek: add quirk for Lenovo Yoga 7 2-in-1 16AKP10
Subsystems (31)
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/realtek: add quirk for Lenovo Yoga 7 2-in-1 16AKP10
From: Zhang Heng <[email protected]>
[ Upstream commit 7bae956cac0433c4d41aac9f1d04e42694e0b706 ]
This machine is equipped with ALC287 and requires the quirk ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN to fix the issue where the bass speakers are not configured and the speaker volume cannot be controlled.
---
LLM Generated explanations, may be completely bogus:
Error: Failed to generate final synthesis
sound/hda/codecs/realtek/alc269.c | 1 + 1 file changed, 1 insertion(+)
sound/hda/codecs/realtek/alc269.c +1 -0
@@ -7429,6 +7429,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x38ab ,"Thinkbook 16P" ,ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD ),SND_PCI_QUIRK (0x17aa ,0x38b4 ,"Legion Slim 7 16IRH8" ,ALC287_FIXUP_CS35L41_I2C_2 ),HDA_CODEC_QUIRK (0x17aa ,0x391c ,"Lenovo Yoga 7 2-in-1 14AKP10" ,ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN ), +HDA_CODEC_QUIRK (0x17aa ,0x391d ,"Lenovo Yoga 7 2-in-1 16AKP10" ,ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN ),SND_PCI_QUIRK (0x17aa ,0x38b5 ,"Legion Slim 7 16IRH8" ,ALC287_FIXUP_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x17aa ,0x38b6 ,"Legion Slim 7 16APH8" ,ALC287_FIXUP_CS35L41_I2C_2 ), SND_PCI_QUIRK(0x17aa, 0x38b7, "Legion Slim 7 16APH8", ALC287_FIXUP_CS35L41_I2C_2),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 net: stmmac: Fix PTP ref clock for Tegra234
From: Jon Hunter <[email protected]>
[ Upstream commit 1345e9f4e3f3bc7d8a0a2138ae29e205a857a555 ]
Since commit 030ce919e114 ("net: stmmac: make sure that ptp_rate is not 0 before configuring timestamping") was added the following error is observed on Tegra234:
ERR KERN tegra-mgbe 6800000.ethernet eth0: Invalid PTP clock rate WARNING KERN tegra-mgbe 6800000.ethernet eth0: PTP init failed
It turns out that the Tegra234 device-tree binding defines the PTP ref clock name as 'ptp-ref' and not 'ptp_ref' and the above commit now exposes this and that the PTP clock is not configured correctly.
In order to update device-tree to use the correct 'ptp_ref' name, update the Tegra MGBE driver to use 'ptp_ref' by default and fallback to using 'ptp-ref' if this clock name is present.
---
LLM Generated explanations, may be completely bogus:
Error: Failed to generate final synthesis
.../net/ethernet/stmicro/stmmac/dwmac-tegra.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c +17 -2
@@ -9,7 +9,7 @@#include "stmmac_platform.h" static const char *const mgbe_clks[] = { -"rx-pcs" ,"tx" ,"tx-pcs" ,"mac-divider" ,"mac" ,"mgbe" ,"ptp-ref" ,"mac" +"rx-pcs" ,"tx" ,"tx-pcs" ,"mac-divider" ,"mac" ,"mgbe" ,"ptp_ref" ,"mac" };struct tegra_mgbe {
@@ -215,6 +215,7 @@ static int tegra_mgbe_probe(struct platform_device *pdev) {struct plat_stmmacenet_data *plat;struct stmmac_resources res; +bool use_legacy_ptp = false;struct tegra_mgbe *mgbe;int irq, err, i;u32 value;
@@ -257,9 +258,23 @@ static int tegra_mgbe_probe(struct platform_device *pdev)if (!mgbe->clks)return -ENOMEM ; -for (i =0 ; i <ARRAY_SIZE (mgbe_clks); i++) +/* Older device-trees use 'ptp-ref' rather than 'ptp_ref'. +* Fall back when the legacy name is present. +*/ +if (of_property_match_string (pdev->dev.of_node,"clock-names" , +"ptp-ref" ) >=0 ) + use_legacy_ptp = true; + +for (i =0 ; i <ARRAY_SIZE (mgbe_clks); i++) { mgbe->clks[i].id = mgbe_clks[i]; +if (use_legacy_ptp && !strcmp (mgbe_clks[i],"ptp_ref" )) { +dev_warn (mgbe->dev, +"Device-tree update needed for PTP clock!\n" ); + mgbe->clks[i].id ="ptp-ref" ; + } + } + err =devm_clk_bulk_get (mgbe->dev,ARRAY_SIZE (mgbe_clks), mgbe->clks);if (err <0 )return err;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ring-buffer: Enforce read ordering of trace_buffer cpumask and buffers
In reply to Sasha LevinFrom: Vincent Donnefort <[email protected]>
[ Upstream commit 20ad8b0888be392eb2c4c3654805eb8594952373 ]
On CPU hotplug, if it is the first time a trace_buffer sees a CPU, a ring_buffer_per_cpu will be allocated and its corresponding bit toggled in the cpumask. Many readers check this cpumask to know if they can safely read the ring_buffer_per_cpu but they are doing so without memory ordering and may observe the cpumask bit set while having NULL buffer pointer.
Enforce the memory read ordering by sending an IPI to all online CPUs. The hotplug path is a slow-path anyway and it saves us from adding read barriers in numerous call sites.
---
LLM Generated explanations, may be completely bogus:
Based on my comprehensive analysis, I have sufficient information to make a decision. Let me now lay out the full analysis following the 9-phase workflow.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1 - Subject Line Parse:**
Record: Subsystem=ring-buffer, action verb=Enforce, summary=Enforce read ordering of trace_buffer cpumask and buffers. "Enforce" implies fixing a missing ordering guarantee = bug fix.
**Step 1.2 - Tags:**
Record:
- Link: https://patch.msgid.link/20260401053659.3458961-1-
[email protected] (lore discussion)
- Signed-off-by: Vincent Donnefort (author)
- Suggested-by: Steven Rostedt (Google) - tracing maintainer suggested the fix approach
- Signed-off-by: Steven Rostedt - applied via maintainer tree
- No Fixes: tag
- No Cc: stable tag
- No Reported-by tag
**Step 1.3 - Body Analysis:**
Record: Bug described is a memory ordering issue. On CPU hotplug, trace_rb_cpu_prepare() allocates a ring_buffer_per_cpu and sets the corresponding cpumask bit. Readers on other CPUs check the cpumask first, then access buffer->buffers[cpu]. Without read ordering, on weakly-ordered architectures a reader may observe the cpumask bit set while still seeing NULL for buffer->buffers[cpu], causing NULL pointer dereference. Fix uses IPI + barrier trick to force ordering across all CPUs. Language "may observe" indicates defensive/analytical fix rather than reported crash.
**Step 1.4 - Hidden Fix Detection:**
Record: This IS clearly a bug fix (memory ordering/race fix), though without explicit "fix" in subject. The word "Enforce" indicates adding a missing ordering guarantee - a classic race fix pattern.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1 - Inventory:**
Record: Single file kernel/trace/ring_buffer.c, +18 -1 lines. New function rb_cpu_sync() (6 lines). Modified trace_rb_cpu_prepare() (replace single smp_wmb() with conditional IPI + wmb). Surgical fix.
**Step 2.2 - Code Flow:**
Record:
- Before: rb_allocate_cpu_buffer() -> smp_wmb() -> cpumask_set_cpu(). Writer-side ordering only.
- After: rb_allocate_cpu_buffer() -> on_each_cpu(rb_cpu_sync, ...) (IPI to all online CPUs, each executes smp_rmb()) -> smp_wmb() -> cpumask_set_cpu(). Forces synchronization on reader CPUs.
- if (unlikely(system_state == SYSTEM_RUNNING)) guard avoids IPI during early boot when IPI infrastructure may not be ready.
**Step 2.3 - Bug Mechanism:**
Record: Category (b) Synchronization/race condition fix. Specifically:
data race between writer (trace_rb_cpu_prepare) and many readers/writers on other CPUs. On weakly-ordered CPUs (ARM, ARM64, PowerPC), readers can observe the cpumask bit set before seeing the newly-allocated buffer pointer, leading to NULL dereference. The IPI mechanism acts as a cross- CPU barrier: after on_each_cpu() returns synchronously, every online CPU has executed smp_rmb() via the IPI handler. Any subsequent cpumask_set_cpu write becomes visible only after that sync, ensuring any reader observing the bit also observes the buffer pointer.
**Step 2.4 - Fix Quality:**
Record: Fix is conceptually elegant and correct. Uses a well-known kernel pattern (IPI-as-barrier). Only affects the slow CPU hotplug path. Low regression risk - the IPI is guarded against early-boot execution, and CPU hotplug is inherently rare. The alternative (adding smp_rmb() to 30+ callsites) would be much more invasive and error-prone.
---
## PHASE 3: GIT HISTORY
**Step 3.1 - Blame:**
Record: The smp_wmb() + cpumask_set_cpu pattern was introduced by commit b32614c03413f8 "tracing/rb: Convert to hotplug state machine" by Sebastian Andrzej Siewior, dated Nov 27, 2016 (v4.10). This code has been present in all stable trees since v4.10.
**Step 3.2 - Fixes: Tag Follow-up:**
Record: No Fixes: tag. The buggy code (the missing read barrier on reader side) has been present since 2016. The root cause is systemic - many reader callsites were added over the years without matching smp_rmb().
**Step 3.3 - File History:**
Record: kernel/trace/ring_buffer.c is actively maintained (578 commits, recent activity). No prerequisite patches needed. Standalone fix (v1 only).
**Step 3.4 - Author Context:**
Record: Vincent Donnefort is a regular ring-buffer contributor (6+ commits to ring_buffer.c in 2024). Steven Rostedt (tracing maintainer) suggested the approach. Both are highly credentialed.
**Step 3.5 - Dependencies:**
Record: None. Self-contained fix. on_each_cpu, smp_rmb, smp_wmb, system_state/SYSTEM_RUNNING are all long-standing kernel primitives available in all stable trees.
---
## PHASE 4: MAILING LIST
**Step 4.1 - Patch Discussion:**
Record: b4 dig -c 20ad8b0888be3 returned lore URL https://lore.kernel.
org/all/[email protected]/. Thread contains only the single patch submission (v1). No review comments, no NAKs, no "Cc: stable" suggestions. Thread mbox has just the submission message.
**Step 4.2 - Reviewers:**
Record: To: [email protected], [email protected], [email protected], [email protected]. Cc:
[email protected], [email protected]. All relevant maintainers CC'd.
**Step 4.3 - Bug Report:**
Record: No bug report linked. No Reported-by. This is a defensive fix based on code analysis. Web fetch of lore was blocked by Anubis bot protection.
**Step 4.4 - Related Patches:**
Record: b4 dig -c -a confirmed only v1 exists. Standalone single patch, not part of a series.
**Step 4.5 - Stable Discussion:**
Record: Not searched separately; no Cc: stable in the submission indicates the author/maintainer did not explicitly nominate it for stable.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1 - Key Functions:**
Record: trace_rb_cpu_prepare() (modified), rb_cpu_sync() (new).
**Step 5.2 - Callers of trace_rb_cpu_prepare:**
Record: Registered as CPU hotplug callback via cpuhp_state_add_instance(CPUHP_TRACE_RB_PREPARE, ...). Called on CPU online transition for each trace_buffer registered. Runs in kernel context on the control CPU (not the target CPU).
**Step 5.3 - Readers Affected (impact surface):**
Record: grep cpumask_test_cpu.*buffer->cpumask in ring_buffer.c shows 30+ callsites that use the pattern if (!cpumask_test_cpu(cpu, buffer->cpumask)) return; cpu_buffer = buffer->buffers[cpu];. Key hot paths include:
- ring_buffer_lock_reserve() line 4716 - the main WRITE path, called from every trace event
- ring_buffer_peek() line 5874 (reader)
- ring_buffer_record_disable_cpu/enable_cpu - userspace-reachable via tracefs
- rb_wait() via userspace read of per-CPU trace_pipe_raw
These are user-reachable from tracefs and syscall paths.
**Step 5.4 - Bug Reachability:**
Record: User-reachable. CPU hotplug is triggered by:
- Boot (initial CPU online)
- Suspend/resume cycle (all CPUs brought down/up)
- /sys/devices/system/cpu/cpuX/online toggling by root
- VM CPU hotplug on cloud instances
Concurrent readers on other CPUs during hotplug could race with the buffer allocation. On weakly-ordered archs (ARM64 very common), the race is realistic.
**Step 5.5 - Similar Patterns:**
Record: The IPI-as-barrier pattern is used elsewhere in the kernel (e.g., kernel/time/hrtimer.c:958 on_each_cpu(retrigger_next_event, NULL, 1)). It's a well-established idiom.
---
## PHASE 6: STABLE TREE ANALYSIS
**Step 6.1 - Buggy Code in Stable:**
Record: Confirmed by inspecting archived versions - the exact smp_wmb(); cpumask_set_cpu(cpu, buffer->cpumask); pattern exists in v6.1, v6.6, v6.12, v6.18 (all active stable trees) and has been there since v4.10. Many readers lacking smp_rmb() are also present across all those versions.
**Step 6.2 - Backport Complications:**
Record: The patch context is simple and stable across versions. The line numbers differ but the exact 2-line context (smp_wmb();\n\tcpumask_set_cpu(cpu, buffer->cpumask);) is unchanged across all examined stable trees. Should apply cleanly with fuzz.
**Step 6.3 - Related Fixes in Stable:**
Record: No prior related fix found. Searched for memory ordering/barrier commits in kernel/trace/ - no matches targeting this specific ordering issue.
---
## PHASE 7: SUBSYSTEM CONTEXT
**Step 7.1 - Subsystem/Criticality:**
Record: kernel/trace/ring_buffer.c is the core ring buffer backing tracefs/ftrace/perf/BPF. Criticality = IMPORTANT (affects all users of tracing - kernel developers, security/observability tools, distros using ftrace).
**Step 7.2 - Subsystem Activity:**
Record: Very active - ~578 commits to ring_buffer.c, recent activity in 2024-2026. Well-maintained with careful attention to correctness.
---
## PHASE 8: IMPACT AND RISK
**Step 8.1 - Affected Population:**
Record: Users of tracing (ftrace, perf, BPF) on systems with CPU hotplug, especially on weakly-ordered architectures (ARM64 - ubiquitous in cloud, mobile, embedded; PowerPC - servers). Any Linux system where tracing is active during suspend/resume is potentially affected.
**Step 8.2 - Trigger Conditions:**
Record: Requires:
1. CPU hotplug event bringing online a CPU not previously seen by a trace_buffer
2. Concurrent tracing activity on other CPUs
3. Weakly-ordered CPU architecture (or unlucky timing on x86)
Trigger is realistic (suspend/resume of any laptop, VM CPU hotplug) but timing-sensitive. Unprivileged users cannot directly trigger CPU hotplug, but tracing (if accessible) can be used to exercise the hot path. System_state transitions occur normally at boot.
**Step 8.3 - Failure Severity:**
Record: NULL pointer dereference -> kernel oops/panic. CRITICAL severity (system crash). No data corruption but immediate loss of system availability.
**Step 8.4 - Risk-Benefit:**
Record:
- Benefit: MEDIUM-HIGH. Prevents a real kernel crash in a widely-used subsystem on common architectures.
- Risk: LOW. 18-line change. IPI only on slow-path (CPU hotplug). SYSTEM_RUNNING guard prevents early-boot issues. Standard kernel idiom. Reviewed by subsystem maintainer.
- Ratio: Favorable for backport.
---
## PHASE 9: SYNTHESIS
**Step 9.1 - Evidence Summary:**
FOR backport:
- Real memory-ordering race that can cause NULL dereference (kernel crash)
- Small, surgical fix (18 lines, single file)
- Buggy pattern present in all active stable trees since v4.10
- Reviewed and authored by the tracing maintainer (Steven Rostedt)
- Applies cleanly (context unchanged across stable versions)
- Affects commonly-used architecture (ARM64)
- Impact path includes hot tracing code called from many paths
AGAINST backport:
- No Fixes: tag
- No Cc: stable tag
- No Reported-by - defensive fix based on code analysis, not observed crash
- Bug was latent for 10 years without mainstream report
- Commit message uses conditional "may observe"
**Step 9.2 - Stable Rules Checklist:**
1. Obviously correct and tested? Yes - uses standard IPI-as-barrier idiom, accepted by maintainer
2. Fixes a real bug? Yes - verifiable memory-ordering race
3. Important (crash)? Yes - NULL pointer dereference
4. Small and contained? Yes - 18 lines, single file
5. No new features? Correct - pure ordering fix
6. Can apply to stable? Yes - simple context, unchanged code structure
**Step 9.3 - Exception Category:**
Not a device-ID/quirk/build/doc/DT fix. Standard bug fix category.
**Step 9.4 - Decision:**
This is a borderline-positive case. The fix addresses a genuine memory- ordering bug that can cause a kernel crash (NULL dereference) on weakly- ordered architectures. The fix is small, well-reasoned, reviewed by the subsystem maintainer, and very low regression risk. While the absence of Fixes:/Cc:stable tags and concrete reports suggests lower urgency, stable rules explicitly include theoretical races with severe consequences. The tracing subsystem is widely used, and ARM64 (where this bug most readily manifests) is prevalent. The fix applies cleanly to stable trees.
---
## Verification
- [Phase 1] Parsed commit message: confirmed no Fixes:, no Cc: stable, no Reported-by; Suggested-by: Steven Rostedt (tracing maintainer)
- [Phase 1] Language analysis: "may observe" and "Enforce" indicate defensive race fix based on code analysis
- [Phase 2] git show 20ad8b0888be3 --stat: verified 18 insertions, 1 deletion, single file
- [Phase 2] Diff inspection: verified replacement of smp_wmb() with conditional on_each_cpu + smp_wmb block; new rb_cpu_sync helper with smp_rmb()
- [Phase 3] git blame -L 7508,7512 kernel/trace/ring_buffer.c:
confirmed smp_wmb();/cpumask_set_cpu pattern introduced by b32614c03413f8 in v4.10 (Nov 2016)
- [Phase 3] git show b32614c03413f8: confirmed original commit by Sebastian Andrzej Siewior, "tracing/rb: Convert to hotplug state machine"
- [Phase 3] git log --author="Vincent Donnefort" -- kernel/trace/ring_buffer.c: author has 6+ ring_buffer.c commits, regular contributor
- [Phase 4] b4 dig -c 20ad8b0888be3: resolved to lore URL, confirmed submission thread
- [Phase 4] b4 dig -c -a: confirmed only v1 exists, no revisions
- [Phase 4] /tmp/rb_sync_thread.mbox read: thread has only the single patch submission, no review replies, no stable nomination in discussion
- [Phase 5] grep cpumask_test_cpu.*buffer->cpumask: confirmed 30+ reader callsites in ring_buffer.c
- [Phase 5] Verified ring_buffer_lock_reserve (line 4716) uses the pattern - hot write path
- [Phase 5] Verified on_each_cpu(x, NULL, 1) idiom used elsewhere (kernel/time/hrtimer.c:958)
- [Phase 6] git show v6.6/v6.12/v6.18:kernel/trace/ring_buffer.c:
confirmed identical 2-line context smp_wmb();\ncpumask_set_cpu(cpu, buffer->cpumask); present in all major stable trees -> patch will apply cleanly
- [Phase 6] git show v4.10:kernel/trace/ring_buffer.c: confirmed pattern present at trace_rb_cpu_prepare since v4.10
- [Phase 7] git log --oneline --since=2024 -- kernel/trace/ring_buffer.c: confirmed active subsystem with many recent commits
- [Phase 8] Confirmed reachability: cpumask checks precede buffer->buffers[cpu] dereference in hot write path (ring_buffer_lock_reserve) and reader paths - NULL deref is possible if race occurs
- UNVERIFIED: Cannot confirm whether this race has actually been observed in production (no Reported-by, no Link to bug tracker, Lore WebFetch blocked by bot protection). Assessment is based on code analysis and consequences of the race, which are severe when it does trigger.
**YES**
kernel/trace/ring_buffer.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
kernel/trace/ring_buffer.c +18 -1
@@ -7468,6 +7468,12 @@ int ring_buffer_map_get_reader(struct trace_buffer *buffer, int cpu)return 0 ; } +static void rb_cpu_sync (void *data) +{ +/* Not really needed, but documents what is happening */ +smp_rmb (); +} +/* * We only allocate new buffers, never free them if the CPU goes down. * If we were to free the buffer, then the user would lose any trace that was in
@@ -7506,7 +7512,18 @@ int trace_rb_cpu_prepare(unsigned int cpu, struct hlist_node *node) cpu);return -ENOMEM ; } -smp_wmb (); + +/* +* Ensure trace_buffer readers observe the newly allocated +* ring_buffer_per_cpu before they check the cpumask. Instead of using a +* read barrier for all readers, send an IPI. +*/ +if (unlikely (system_state ==SYSTEM_RUNNING )) { +on_each_cpu (rb_cpu_sync,NULL ,1 ); +/* Not really needed, but documents what is happening */ +smp_wmb (); + } +cpumask_set_cpu (cpu, buffer->cpumask);return 0 ; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 PCI: Prevent assignment to unsupported bridge windows
In reply to Sasha LevinFrom: Ahmed Naseef <[email protected]>
[ Upstream commit 92427ab4378faa168d6953d0f8574b8fc1edcc14 ]
Previously, pci_read_bridge_io() and pci_read_bridge_mmio_pref() unconditionally set resource type flags (IORESOURCE_IO or IORESOURCE_MEM | IORESOURCE_PREFETCH) when reading bridge window registers. For windows that are not implemented in hardware, this may cause the allocator to assign space for a window that doesn't exist.
For example, the EcoNET EN7528 SoC Root Port doesn't support the prefetchable window, but since a downstream device had a prefetchable BAR, the allocator mistakenly assigned a prefetchable window:
pci 0001:00:01.0: [14c3:0811] type 01 class 0x060400 PCIe Root Port pci 0001:00:01.0: PCI bridge to [bus 01-ff]
pci 0001:00:01.0: bridge window [mem 0x28000000-0x280fffff]: assigned pci 0001:00:01.0: bridge window [mem 0x28100000-0x282fffff pref]: assigned pci 0001:01:00.0: BAR 0 [mem 0x28100000-0x281fffff 64bit pref]: assigned
pci_read_bridge_windows() already detects unsupported windows by testing register writability and sets dev->io_window/pref_window accordingly.
Check dev->io_window/pref_window so we don't set the resource flags for unsupported windows, which prevents the allocator from assigning space to them.
After this commit, the prefetchable BAR is correctly allocated from the non-prefetchable window:
pci 0001:00:01.0: bridge window [mem 0x28000000-0x281fffff]: assigned pci 0001:01:00.0: BAR 0 [mem 0x28000000-0x280fffff 64bit pref]: assigned
---
LLM Generated explanations, may be completely bogus:
Now I have a complete picture. Let me compile the full analysis.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: Subject line.**
Record: [PCI] [Prevent] Prevents resource allocator from assigning space to unsupported bridge windows (IO and prefetchable memory).
**Step 1.2: Tags.**
- Suggested-by: Bjorn Helgaas (PCI maintainer suggested the fix approach)
- Link: https://lore.kernel.org/all/20260113210259.GA715789@bhelgaas/
(original suggestion)
- Signed-off-by: Ahmed Naseef (original author of the fix)
- Signed-off-by: Caleb James DeLisle (series author)
- Signed-off-by: Bjorn Helgaas (PCI maintainer committed it)
- Link: https://patch.msgid.link/[email protected]
(patch submission)
- No Fixes: tag (expected for review candidates)
- No Cc: stable (expected)
**Step 1.3: Body analysis.**
The commit describes that pci_read_bridge_io() and pci_read_bridge_mmio_pref() unconditionally set resource type flags when reading bridge window registers. For hardware-unsupported windows (registers hardwired to 0), both base and limit read as 0, and since 0 <= 0 is true, a bogus window is created. The allocator then assigns space to a non-existent window. The concrete example is the EcoNET EN7528 SoC root port, which doesn't support prefetchable windows, causing a WiFi device (mt7615e) to be placed in a non-existent window and fail.
**Step 1.4: Hidden bug fix?**
This is an explicit bug fix. The word "Prevent" in the subject indicates fixing incorrect behavior. The commit clearly describes a failure mode where devices become non-functional.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: Inventory.**
- 1 file changed: drivers/pci/probe.c
- +6 lines, 0 lines removed
- Functions modified: pci_read_bridge_io(),
pci_read_bridge_mmio_pref()
- Scope: single-file, very surgical fix
**Step 2.2: Code flow change.**
Two early returns are added:
1. pci_read_bridge_io(): If !dev->io_window, return immediately before reading any IO window registers or setting any resource flags.
2. pci_read_bridge_mmio_pref(): If !dev->pref_window, return immediately before reading any prefetchable window registers or setting any resource flags.
**Step 2.3: Bug mechanism.**
This is a **logic/correctness fix**. The bug is that pci_read_bridge_bases() calls these functions unconditionally for ALL bridges, even those where pci_read_bridge_windows() has already determined the window is unsupported. When registers are hardwired to 0, base == limit == 0, and 0 <= 0 creates a bogus resource.
**Step 2.4: Fix quality.**
The fix is obviously correct. The io_window and pref_window flags are already set correctly by pci_read_bridge_windows() during enumeration and are already used by pci_bridge_check_ranges() in setup-bus.c. This fix simply extends the same guard to pci_read_bridge_bases(). Zero regression risk -- if the window IS supported, io_window/pref_window is set to 1 and the early return is not taken.
## PHASE 3: GIT HISTORY
**Step 3.1: Blame.**
The affected functions have been in the kernel since Linus's initial tree commit (v2.6.12, 2005). The io_window and pref_window fields were added in commit 51c48b310183a (v5.1) by Bjorn Helgaas. This means the infrastructure to detect unsupported windows existed since v5.1, but the detection was never used in pci_read_bridge_bases().
**Step 3.2:** No Fixes: tag (expected).
**Step 3.3:** Recent changes to probe.c include 8278c6914306f ("PCI:
Preserve bridge window resource type flags") which changed flag behavior but is independent of this fix.
**Step 3.4:** Caleb James DeLisle is a new contributor adding EN7528 support. Ahmed Naseef authored this particular fix. Bjorn Helgaas (PCI maintainer) suggested and signed off on the fix.
**Step 3.5:** The fix has no prerequisites. It uses dev->io_window and dev->pref_window which have been present since v5.1.
## PHASE 4: MAILING LIST
The mbox file (7 messages) reveals a thorough review by Bjorn Helgaas. He initially couldn't reproduce the bug (because his test device had non-prefetchable BARs), but Ahmed Naseef provided a detailed config access trace showing:
1. pci_read_bridge_windows() correctly detects pref_window = 0
2. Later, pci_read_bridge_bases() reads the same registers without checking, creates bogus resource
3. Allocator assigns prefetchable window to bridge that doesn't have one
4. WiFi device (mt7615e with prefetchable BARs) is placed in the bogus window and fails
Bjorn was satisfied with the explanation and committed the patch with his own Signed-off-by. This is patch 3/3 of a series, but it's completely self-contained in PCI core.
## PHASE 5: CODE SEMANTIC ANALYSIS
pci_read_bridge_io() and pci_read_bridge_mmio_pref() are called from two sites:
1. pci_read_bridge_windows() -- already guards with io_window/pref_window; the early returns are redundant here but harmless
2. pci_read_bridge_bases() -- calls unconditionally, **this is where the bug manifests**
pci_read_bridge_bases() is called from pci_bus_allocate_resources() in setup-bus.c for every PCI bridge during bus allocation. This is a core enumeration path that runs on every system with PCI bridges.
## PHASE 6: STABLE TREE ANALYSIS
The buggy code (pci_read_bridge_bases() calling these functions unconditionally) has existed since Linux 2.6.12. The io_window/pref_window infrastructure was added in v5.1, so the fix is applicable to all active stable trees (5.4.y through 6.12.y).
The fix may need minor context adjustment for kernels before v6.8 (where 63c6ebb294b7c changed function signatures), but the actual fix logic (two early returns) is identical.
## PHASE 7: SUBSYSTEM AND CRITICALITY
PCI core (drivers/pci/probe.c) is CORE infrastructure used by all PCI systems. The bug specifically affects embedded SoCs with limited bridge window support, making it IMPORTANT for ARM/MIPS embedded users.
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Who is affected:** Users of any platform with PCI bridges that lack IO or prefetchable window support. This primarily includes embedded SoCs (ARM, MIPS). The known affected device is EcoNET EN7528.
**Trigger conditions:** Automatic during PCI enumeration when a downstream device has prefetchable BARs behind a bridge without prefetchable window support. No user action needed.
**Failure mode:** Device non-functional (BARs placed in non-existent window). Severity: HIGH -- the device completely fails to work (mt7615e WiFi shows "Firmware is not ready for download").
**Risk-benefit ratio:** Benefit is HIGH (fixes device failure). Risk is VERY LOW (6 lines, two early returns using already-tested flags, zero side effects when windows ARE supported).
## PHASE 9: FINAL SYNTHESIS
**Evidence FOR backporting:**
- Real bug fix that makes PCI devices completely non-functional on affected hardware
- Minimal fix: 6 lines added, 0 removed
- Obviously correct: uses existing io_window/pref_window flags already tested elsewhere
- PCI maintainer (Bjorn Helgaas) suggested, reviewed, and committed the fix
- Affects PCI core code present in all stable trees since v5.1
- Bug exists in all kernel versions since 2005 (base == limit == 0 case)
- The affected code path (pci_read_bridge_bases()) runs during normal PCI enumeration
**Evidence AGAINST backporting:**
- The only known affected hardware (EN7528) is new and not in stable trees
- No other hardware has reported this bug (though other embedded SoCs could be affected)
- This is patch 3/3 of a series (but is self-contained in PCI core)
**Stable rules checklist:**
1. Obviously correct? YES -- uses existing flags, minimal change
2. Fixes real bug? YES -- devices fail behind bridges without pref windows
3. Important issue? YES -- device non-functional
4. Small and contained? YES -- 6 lines in 1 file
5. No new features? CORRECT -- no new features
6. Can apply to stable? YES -- may need minor context adjustment for older trees
## Verification
- [Phase 1] Parsed tags: Suggested-by Bjorn Helgaas, two Signed-off-bys, two Links
- [Phase 2] Diff analysis: +6 lines in pci_read_bridge_io() and pci_read_bridge_mmio_pref(), adds early return when window not supported
- [Phase 3] git blame: buggy unconditional calls exist since v2.6.12; io_window/pref_window added in 51c48b310183a (v5.1)
- [Phase 3] git describe: 51c48b310183a first appeared in v5.1-rc1
- [Phase 3] pci_bridge_check_ranges() already correctly checks these flags, confirming the fix pattern is established
- [Phase 4] b4 mbox retrieved 7-message thread; Bjorn Helgaas reviewed, requested config trace, was satisfied, committed
- [Phase 4] Ahmed Naseef provided detailed config access trace proving the exact bug mechanism
- [Phase 4] Series is 3 patches (DT bindings, driver, core fix); patch 3/3 is self-contained in PCI core
- [Phase 5] pci_read_bridge_bases() called from pci_bus_allocate_resources() -- standard PCI enumeration path
- [Phase 5] Two call sites for affected functions: one already guarded (pci_read_bridge_windows), one not (pci_read_bridge_bases)
- [Phase 6] io_window/pref_window present in all active stable trees (v5.1+)
- [Phase 6] Commit 8278c6914306f is independent; fix works on code both before and after it
- [Phase 8] Failure mode: device completely non-functional when BAR assigned to non-existent bridge window
- UNVERIFIED: Whether other production platforms besides EN7528 are affected in practice (likely given many embedded SoCs have limited bridge support)
**YES**
drivers/pci/probe.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/pci/probe.c +6 -0
@@ -395,6 +395,9 @@ static void pci_read_bridge_io(struct pci_dev *dev, struct resource *res,unsigned long io_mask, io_granularity, base, limit;struct pci_bus_region region; +if (!dev->io_window) +return ; + io_mask =PCI_IO_RANGE_MASK ; io_granularity =0x1000 ;if (dev->io_window_1k) {
@@ -465,6 +468,9 @@ static void pci_read_bridge_mmio_pref(struct pci_dev *dev, struct resource *res,pci_bus_addr_t base, limit;struct pci_bus_region region; +if (!dev->pref_window) +return ; +pci_read_config_word (dev,PCI_PREF_MEMORY_BASE , &mem_base_lo);pci_read_config_word (dev,PCI_PREF_MEMORY_LIMIT , &mem_limit_lo); base64 = (mem_base_lo &PCI_PREF_RANGE_MASK ) <<16 ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 smb: client: fix integer underflow in receive_encrypted_read()
In reply to Sasha LevinFrom: Dudu Lu <[email protected]>
[ Upstream commit 6b83b03c07fbe0b57bb729bee91ae44c623c82ff ]
In receive_encrypted_read(), the length of data to read from the socket is computed as:
len = le32_to_cpu(tr_hdr->OriginalMessageSize) -
server->vals->read_rsp_size;
OriginalMessageSize comes from the server's transform header and is untrusted. If a malicious server sends a value smaller than read_rsp_size, the unsigned subtraction wraps to a very large value (~4GB). This value is then passed to netfs_alloc_folioq_buffer() and cifs_read_iter_from_socket(), causing either a massive allocation attempt that fails with -ENOMEM (DoS), or under extreme memory pressure, potential heap corruption.
Fix by adding a check that OriginalMessageSize is at least read_rsp_size before the subtraction. On failure, jump to discard_data to drain the remaining PDU from the socket, preventing desync of subsequent reads on the connection.
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed for a comprehensive analysis. Let me compile my findings.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: Subject Line
- **Subsystem**: smb: client: (SMB/CIFS network filesystem client)
- **Action verb**: "fix" (explicitly a bug fix)
- **Summary**: Fix integer underflow in receive_encrypted_read() when server sends a small OriginalMessageSize
Record: [smb: client] [fix] [integer underflow in receive_encrypted_read from untrusted server data]
### Step 1.2: Tags
- **Signed-off-by**: Dudu Lu <[email protected]> (author)
- **Reviewed-by**: Enzo Matsumiya <[email protected]> (known CIFS/SMB contributor at SUSE)
- **Signed-off-by**: Steve French <[email protected]> (SMB/CIFS subsystem maintainer)
- No Fixes: tag (expected - that's why it's being reviewed)
- No Cc: stable tag (expected)
Record: Reviewed by known SMB developer, committed by subsystem maintainer Steve French. No syzbot/reporter tags, but the bug is found by code inspection of untrusted network input handling.
### Step 1.3: Commit Body Analysis
- **Bug**: OriginalMessageSize is read from network (server's transform header) and is untrusted. It's used in an unsigned subtraction OriginalMessageSize - read_rsp_size. If the server sends a value smaller than read_rsp_size, the subtraction wraps around to ~4GB.
- **Symptom**: Massive allocation attempt via netfs_alloc_folioq_buffer() leading to -ENOMEM (DoS), or under extreme memory pressure, potential heap corruption.
- **Failure mode**: DoS via malicious server, potential heap corruption
- **Root cause**: Missing input validation on network-supplied value before unsigned arithmetic
Record: Integer underflow from untrusted network input. Symptom is DoS or potential heap corruption. Clear security bug.
### Step 1.4: Hidden Bug Fix Detection
This is an explicit bug fix, not disguised. The word "fix" and the detailed description of the vulnerability make it clear.
Record: Explicit bug fix. Not hidden.
---
## PHASE 2: DIFF ANALYSIS
### Step 2.1: Inventory
- **File**: fs/smb/client/smb2ops.c (single file)
- **Lines added**: 8 (the validation check + debug message + error path)
- **Lines removed**: 0
- **Function modified**: receive_encrypted_read()
- **Scope**: Single-file, single-function surgical fix
Record: 1 file changed, +8 lines. Extremely surgical.
### Step 2.2: Code Flow Change
Before: The code reads OriginalMessageSize from the server and subtracts read_rsp_size unconditionally. If OriginalMessageSize < read_rsp_size, len wraps to ~4GB unsigned.
After: Before the subtraction, a check verifies OriginalMessageSize >= read_rsp_size. On failure, logs a debug message and jumps to discard_data which drains the remaining PDU and cleans up properly.
Record: Adds input validation before unsafe unsigned subtraction of untrusted server data.
### Step 2.3: Bug Mechanism
- **Category**: Buffer overflow / integer underflow from untrusted input
- **Mechanism**: Unsigned integer underflow when OriginalMessageSize < read_rsp_size, leading to ~4GB allocation attempt
- **Security aspect**: Server-controlled value, exploitable by malicious SMB server (network attack vector)
Record: Integer underflow of untrusted network data → massive allocation → DoS or heap corruption.
### Step 2.4: Fix Quality
- Obviously correct: simple bounds check before subtraction
- Minimal/surgical: 8 lines added, no unrelated changes
- Regression risk: extremely low - only adds a validation check and error path using existing discard_data label
- The error path (goto discard_data) is well-tested by other failure paths in the same function
Record: Obviously correct, minimal, no regression risk.
---
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: Blame
The buggy code was introduced in commit 1fc6ad2f10ad6f (2018-06-01) by Ronnie Sahlberg, which was a refactor of receive_encrypted_read(). The original function was introduced even earlier in 93012bf984163f (2018-03-31). Both are from the 4.17-4.18 era.
Record: Buggy code has been present since ~v4.17 (2018). Present in ALL active stable trees.
### Step 3.2: Fixes tag
No Fixes: tag present. The bug was introduced in 93012bf984163f or 1fc6ad2f10ad6f, both from 2018.
### Step 3.3: Related Changes
- eec04ea119691 ("smb: client: fix OOB in receive_encrypted_standard()") - same class of bug (CVE-2024-0565) in the sibling function, already has Cc: stable
- 860ca5e50f73c ("smb: client: Add check for next_buffer in receive_encrypted_standard()") - follow-up NULL check fix
- These show that the same pattern of missing validation on untrusted server data in this file has been a recurring security issue
Record: Related CVE-2024-0565 fix exists for the sibling function. This is the same class of vulnerability.
### Step 3.4: Author
Dudu Lu appears to be a new contributor (no other commits found). However, the fix was reviewed by Enzo Matsumiya (SUSE, known CIFS contributor) and committed by Steve French (subsystem maintainer).
Record: New author, but reviewed and committed by experienced subsystem maintainers.
### Step 3.5: Dependencies
The fix uses the existing discard_data label and existing code patterns. No dependencies on other patches. Standalone fix.
Record: Fully standalone, no dependencies.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
### Step 4.1: Patch Discussion
Unable to find the exact lore thread via b4 dig (commit not yet in tree). Web search found CVE-2024-0565 for the related bug in receive_encrypted_standard(), confirming this is a known class of vulnerability in the SMB encrypted receive path.
Record: Could not find lore thread (commit not in mainline yet). CVE-2024-0565 confirms the vulnerability class.
### Step 4.2: Reviewers
- Reviewed by Enzo Matsumiya (SUSE, active CIFS developer)
- Committed by Steve French (Microsoft, CIFS/SMB maintainer)
Record: Appropriate reviewers involved.
### Step 4.3: Bug Report
The bug was found by code inspection (not crash report or fuzzer). The similarity to CVE-2024-0565 strengthens the case - that CVE was for receive_encrypted_standard() and THIS fix is for receive_encrypted_read(), the sibling function that handles large encrypted reads.
Record: Found by code audit, related to CVE-2024-0565.
### Step 4.4-4.5: Related patches / Stable history
The sibling fix (CVE-2024-0565) for receive_encrypted_standard() was backported to stable. This fix addresses the same vulnerability pattern in the other code path.
Record: Sibling fix was backported to stable. This fix addresses the same gap.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1-5.4: Function Tracing
- receive_encrypted_read() is called from smb3_receive_transform() (line 5147)
- smb3_receive_transform() is registered as .receive_transform ops callback for SMB3 protocol
- Called from cifs_demultiplex_thread() in connect.c (line 1341) - the main SMB connection handler
- This is in the hot path for ALL encrypted SMB3 read operations
- Reachable from any SMB client mount with encryption enabled (common enterprise configuration)
Record: Called from main demux thread for all encrypted SMB3 reads. High traffic path. Reachable from network.
### Step 5.5: Similar Patterns
The caller smb3_receive_transform() already has partial validation (lines 5131-5143) that checks pdu_length against OriginalMessageSize, but doesn't check OriginalMessageSize against read_rsp_size. The receive_encrypted_read() path bypasses the standard path's protections because it's for large PDUs.
Record: Caller has some checks but insufficient for the receive_encrypted_read path.
---
## PHASE 6: CROSS-REFERENCING AND STABLE TREE ANALYSIS
### Step 6.1: Code Existence in Stable
The buggy code exists since v4.17. It is present in ALL active stable trees (5.10, 5.15, 6.1, 6.6, 6.12, etc.).
Record: Bug exists in all active stable trees.
### Step 6.2: Backport Complications
The fix is 8 lines of added validation. The surrounding code structure is stable. The function uses netfs_alloc_folioq_buffer() which was added in newer kernels (replacing older alloc_pages pattern), so older stable trees (5.x) may need minor adaptation, but the core validation check is independent of that.
Record: Clean apply expected for recent stable trees (6.x). Older trees may need minor context adaptation.
### Step 6.3: Related Fixes in Stable
CVE-2024-0565 fix for receive_encrypted_standard() is already in stable. This is the companion fix for receive_encrypted_read().
Record: Companion fix for sibling function already in stable.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
### Step 7.1: Subsystem Criticality
- **Subsystem**: fs/smb/client (CIFS/SMB network filesystem client)
- **Criticality**: IMPORTANT - SMB is widely used in enterprise environments for network file sharing (Windows interop, NAS, etc.)
Record: [fs/smb/client] [IMPORTANT - widely used enterprise network filesystem]
### Step 7.2: Subsystem Activity
The SMB client is actively maintained with regular fixes. Steve French is the active maintainer.
Record: Actively maintained subsystem.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: Affected Users
All users who mount SMB3 shares with encryption enabled (increasingly common in enterprise environments with security requirements).
Record: Enterprise SMB users with encryption - significant population.
### Step 8.2: Trigger Conditions
- A malicious SMB server (or man-in-the-middle) can send a crafted transform header with a small OriginalMessageSize during an encrypted read response
- Triggered on any large encrypted read operation
- Exploitable from network without any local privileges
Record: Network-exploitable, triggered by malicious server response. No local privileges needed.
### Step 8.3: Failure Mode Severity
- **Primary**: DoS - massive allocation attempt fails with -ENOMEM
- **Secondary**: Under memory pressure, potential heap corruption from the wrapped-around length value passed to allocation/socket read functions
- **Severity**: CRITICAL (network-exploitable DoS, potential remote heap corruption)
Record: DoS (guaranteed) to potential heap corruption (under pressure).
Severity: CRITICAL.
### Step 8.4: Risk-Benefit Ratio
- **Benefit**: Very high - fixes a network-exploitable security vulnerability in a widely-used filesystem
- **Risk**: Very low - 8-line addition of input validation using existing error path, obviously correct
- **Ratio**: Extremely favorable
Record: Very high benefit, very low risk. Strong backport candidate.
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: Evidence Compilation
**FOR backporting:**
- Fixes a security vulnerability (integer underflow from untrusted network input)
- Network-exploitable DoS with potential for heap corruption
- Related vulnerability in sibling function was assigned CVE-2024-0565 and already backported
- Small, surgical fix: 8 lines, single file, single function
- Obviously correct: simple bounds check before unsigned subtraction
- Reviewed by known CIFS developer, committed by subsystem maintainer
- Bug exists in all active stable trees (since v4.17, 2018)
- Zero regression risk
- Standalone fix with no dependencies
**AGAINST backporting:**
- (None identified)
### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **YES** - trivial bounds check, reviewed by maintainers
2. Fixes a real bug? **YES** - integer underflow from untrusted network data
3. Important issue? **YES** - network-exploitable DoS/potential heap corruption, security bug
4. Small and contained? **YES** - 8 lines, 1 file, 1 function
5. No new features or APIs? **YES** - pure validation fix
6. Can apply to stable? **YES** - recent trees should apply cleanly
### Step 9.3: Exception Categories
Not an exception - this is a standard security/correctness fix that meets all stable criteria directly.
### Step 9.4: Decision
This is a clear YES. It's a security fix for a network-exploitable integer underflow vulnerability in the SMB3 encrypted read path. The fix is minimal (8 lines), obviously correct, reviewed by subsystem experts, has zero regression risk, and the bug has existed since 2018 in all stable trees. The related CVE-2024-0565 for the sibling function was already backported to stable.
---
## Verification
- [Phase 1] Parsed subject: "smb: client: fix integer underflow in receive_encrypted_read()" - explicit fix for integer underflow
- [Phase 1] Parsed tags: Reviewed-by Enzo Matsumiya (SUSE), SOB Steve French (maintainer)
- [Phase 2] Diff analysis: +8 lines in receive_encrypted_read(), adds bounds check before unsigned subtraction of OriginalMessageSize - read_rsp_size
- [Phase 2] Error path: goto discard_data is existing label (verified at line 5018) that drains remaining PDU and cleans up
- [Phase 3] git blame: buggy subtraction at line 4946 introduced by commit 1fc6ad2f10ad6f (2018-06-01, Ronnie Sahlberg) and 93012bf984163f (2018-03-31)
- [Phase 3] git tag --contains: original code present since v4.17 era, in all stable trees including 5.10, 5.15+
- [Phase 3] Related fix: eec04ea119691 (CVE-2024-0565) fixed same class of bug in sibling function receive_encrypted_standard(), Cc:
stable
- [Phase 4] b4 dig: could not find lore thread (commit not yet in mainline)
- [Phase 4] Web search: confirmed CVE-2024-0565 for related vulnerability in receive_encrypted_standard()
- [Phase 5] Call chain traced: cifs_demultiplex_thread() → smb3_receive_transform() → receive_encrypted_read() - main SMB connection path
- [Phase 5] OriginalMessageSize confirmed as network-supplied value from struct smb2_transform_hdr (defined in smb2pdu.h line 211)
- [Phase 6] Bug exists in all active stable trees (code from 2018)
- [Phase 6] Caller's existing check at line 5139 validates `pdu_length
Quoted 2 lines
=
orig_len+sizeof(transform_hdr)but does NOT validateorig_len= read_rsp_size`
- [Phase 8] Failure mode: unsigned wrap to ~4GB → massive allocation → -ENOMEM (DoS) or heap corruption
- UNVERIFIED: Exact lore discussion thread not found (does not affect decision)
**YES**
fs/smb/client/smb2ops.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/smb/client/smb2ops.c +8 -0
@@ -4943,6 +4943,14 @@ receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid, goto free_dw; server->total_read += rc; +if (le32_to_cpu (tr_hdr->OriginalMessageSize) < + server->vals->read_rsp_size) { +cifs_server_dbg (VFS ,"OriginalMessageSize %u too small for read response (%zu)\n" , +le32_to_cpu (tr_hdr->OriginalMessageSize), + server->vals->read_rsp_size); + rc = -EINVAL ; + goto discard_data; + } len =le32_to_cpu (tr_hdr->OriginalMessageSize) - server->vals->read_rsp_size; dw->len = len;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 gpio: lp873x: normalize return value of gpio_get
In reply to Sasha LevinFrom: Dmitry Torokhov <[email protected]>
[ Upstream commit 5a32ebabb6819fafce99e7bc6575ca568af6d22a ]
The GPIO get callback is expected to return 0 or 1 (or a negative error code). Ensure that the value returned by lp873x_gpio_get() is normalized to the [0, 1] range.
---
LLM Generated explanations, may be completely bogus:
Now I have all the information I need. Let me compile the full analysis.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: Subject Line**
- Subsystem: gpio: lp873x
- Action: "normalize" (correctness fix, ensuring API compliance)
- Summary: Normalize return value of gpio_get callback to [0, 1] range
Record: [gpio: lp873x] [normalize] [Fix return value to comply with GPIO API contract]
**Step 1.2: Tags**
- Signed-off-by: Dmitry Torokhov - Author, major kernel contributor (input subsystem maintainer, also contributes to GPIO)
- `Link: https://patch.msgid.link/20260218190657.2974723-4-
[email protected]` - Patch 4 in a series
- Signed-off-by: Bartosz Golaszewski - GPIO subsystem maintainer applied it
- No Fixes: tag (expected for AUTOSEL candidates)
- No Cc: stable tag
Record: Author is a well-known kernel maintainer. Patch applied by GPIO subsystem maintainer.
**Step 1.3: Commit Body**
The commit message explains the GPIO .get() callback API contract: it must return 0, 1, or negative error. The lp873x driver violated this.
Record: Bug = API contract violation. Return value is non-normalized (can return values > 1 like 16).
**Step 1.4: Hidden Bug Fix?**
Yes. "normalize" disguises a real correctness bug. The driver returns val & BIT(offset * BITS_PER_GPO) which for offset=1 returns 16 (not 0 or 1). This violates the GPIO API contract.
Record: This IS a bug fix despite "normalize" language.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: Inventory**
- 1 file: drivers/gpio/gpio-lp873x.c, 1 line changed
- Function modified: lp873x_gpio_get()
Record: Minimal single-line change in one function.
**Step 2.2: Code Flow Change**
Before: return val & BIT(offset * BITS_PER_GPO); - returns 0 or BIT(offset*4), which for offset=1 is 16.
After: return !!(val & BIT(offset * BITS_PER_GPO)); - returns 0 or 1.
Record: Changes return value normalization on the normal code path.
**Step 2.3: Bug Mechanism**
Category: Logic/correctness fix (type g). BITS_PER_GPO is 4. For offset=0, BIT(0)=1 (fine). For offset=1, BIT(4)=16 (bug - returns 16 instead of 1).
This interacts critically with 86ef402d805d (sanitizer added in v6.15):
- **Original sanitizer** (v6.15): Returns -EBADE if ret > 1 -- meaning GPO2 reads would FAIL with an error
- **Revised sanitizer** (v7.0, commit ec2cceadfae72): Warns and normalizes to !!ret
- **Without sanitizer** (v6.14 and older): Non-normalized value propagated to consumers
Record: API violation; offset=1 returns 16 instead of 1. Can cause -EBADE errors in some stable tree versions.
**Step 2.4: Fix Quality**
Trivially correct. !! is the standard C idiom for boolean normalization. Zero regression risk.
Record: Obviously correct, minimal, zero risk.
## PHASE 3: GIT HISTORY
**Step 3.1: Blame**
The buggy line (return val & BIT(...)) was introduced in 83f141030cec88 (2016-08-31, v4.9) - the original driver. Bug present since inception.
Record: Bug exists since v4.9, present in all stable trees.
**Step 3.2: Fixes Tag**
No Fixes: tag present. However, sister commits reference `Fixes:
86ef402d805d`. The lp873x commit likely should have had this tag.
Record: Sister commits all have Fixes: 86ef402d805d.
**Step 3.3: File History**
Only 2 changes since v6.6: 30d15b8949828 (GPIO set callback rename) and d9d87d90cc0b1 (rename back). Neither affects lp873x_gpio_get(). The fix applies cleanly to all stable trees.
Record: Standalone fix, no prerequisites for the get() function.
**Step 3.4: Author**
Dmitry Torokhov is the input subsystem maintainer and a very active kernel contributor. He authored multiple similar GPIO normalization fixes (fbd03587ba732 for amd-fch, 2bb995e6155cb for qca807x, e2fa075d5ce19 for ti-ads7950). He also reported the issue that led to the gpiolib sanitizer fix ec2cceadfae72.
Record: Highly trusted author. Systematic fix across multiple drivers.
**Step 3.5: Dependencies**
None. The change to lp873x_gpio_get() is self-contained - the function hasn't changed since 2016.
Record: No dependencies. Clean apply expected.
## PHASE 4: MAILING LIST
**Step 4.1-4.2**: Lore is behind a bot protection wall. However, b4 dig confirmed the series and the sister patches. The patch was accepted by the GPIO subsystem maintainer (Bartosz Golaszewski).
**Step 4.3: Bug Context**
The framework-level fix ec2cceadfae72 was prompted by Dmitry Torokhov reporting that 86ef402d805d broke multiple drivers. Bartosz Golaszewski then:
1. Changed the sanitizer from -EBADE to warn+normalize
2. CC'd stable on that fix
3. Accepted all driver-level fixes from Dmitry
**Step 4.4: Series Context**
This is patch 4 in a series of GPIO normalization fixes. Each patch is independent (different drivers).
**Step 4.5: Stable Discussion**
The sister commit e2fa075d5ce19 (ti-ads7950) explicitly has `Cc:
<[email protected]>. The framework fix ec2cceadfae72 also has Cc: stable`. This lp873x patch appears to have missed the Cc: stable tag despite being the same class of fix.
Record: Sister patches have Cc: stable. This one appears to have been missed.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1-5.2**: lp873x_gpio_get is called via the .get callback in template_chip. The GPIO framework calls it through gpiochip_get() -> gpio_chip_get_value() -> gpiod_get_value/gpiod_get_raw_value paths.
**Step 5.4**: Call chain: userspace GPIO access -> gpiod_get_value() -> gpio_chip_get_value() -> gpiochip_get() -> lp873x_gpio_get(). Reachable from userspace via the GPIO chardev interface.
Record: Reachable from userspace, called on every GPIO read of this device.
## PHASE 6: CROSS-REFERENCING
**Step 6.1**: The buggy code exists in all stable trees (since v4.9). The lp873x driver has barely changed.
**Step 6.2**: The lp873x_gpio_get() function is unchanged since 2016. The fix should apply cleanly to all stable trees.
**Step 6.3**: No related fixes for this specific driver in stable.
Record: Clean backport expected to all active stable trees.
## PHASE 7: SUBSYSTEM CONTEXT
**Step 7.1**: GPIO subsystem - IMPORTANT level. GPIO is used widely in embedded/IoT systems.
**Step 7.2**: The lp873x is a TI PMIC used in embedded/industrial systems (BeagleBone, etc.).
Record: Peripheral driver but with real embedded users.
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1**: Affects users of LP873x PMIC GPO2 (offset=1). The LP873x is used on TI AM335x/AM57xx platforms.
**Step 8.2**: Triggered on every GPIO read of GPO2. Impact varies by stable tree:
- v6.15+ with only 86ef402d805d: Returns -EBADE error (FUNCTIONAL BREAKAGE)
- v7.0+ with ec2cceadfae72: Warning in dmesg
- v6.14 and older: Non-normalized value to consumers (potential subtle bugs)
**Step 8.3**: Severity varies: MEDIUM (warning + potential wrong behavior) to HIGH (functional breakage with -EBADE in certain stable trees)
**Step 8.4**: BENEFIT: Eliminates API violation, prevents -EBADE errors in some trees, removes warning. RISK: Essentially zero (single !! addition).
## PHASE 9: FINAL SYNTHESIS
**Evidence FOR:**
1. Trivial 1-line fix, obviously correct (!! normalization)
2. Fixes real API contract violation (returning 16 instead of 1)
3. Zero regression risk
4. Sister patches (e2fa075d5ce19, 2bb995e6155cb) have Cc: stable and Fixes: tags
5. Author is highly trusted kernel maintainer
6. Applied by GPIO subsystem maintainer
7. Bug present since v4.9 - affects all stable trees
8. In some stable trees (v6.15+), the unfixed driver causes -EBADE functional errors
9. Clean backport expected - function unchanged since 2016
**Evidence AGAINST:**
1. No Fixes: tag or Cc: stable on this specific commit (likely oversight)
2. Low user population (LP873x PMIC users only)
3. Impact in latest stable trees is "just" a warning (with the sanitizer normalization)
**Stable Rules Checklist:**
1. Obviously correct? **YES** - !! is standard normalization
2. Fixes real bug? **YES** - API violation, wrong return values
3. Important issue? **MEDIUM-HIGH** - can cause -EBADE in some trees
4. Small and contained? **YES** - 1 line, 1 file
5. No new features? **YES** - pure fix
6. Can apply to stable? **YES** - function unchanged since 2016
## Verification
- [Phase 1] Parsed tags: Author is Dmitry Torokhov, applied by GPIO maintainer Bartosz Golaszewski. No Fixes:/Cc:stable.
- [Phase 2] Diff analysis: 1 line changed in lp873x_gpio_get(), val & BIT(...) -> !!(val & BIT(...)). For offset=1, changes return from 16 to 1.
- [Phase 3] git blame: buggy line from 83f141030cec88 (v4.9, 2016-08-31), present in all stable trees.
- [Phase 3] git show 86ef402d805d: sanitizer that returns -EBADE for ret > 1, first in v6.15.
- [Phase 3] git show ec2cceadfae72: follow-up changing -EBADE to warn+normalize, has Cc: stable.
- [Phase 3] Sister commits 2bb995e6155cb (qca807x) and e2fa075d5ce19 (ti-ads7950): both have Fixes: 86ef402d805d and one has `Cc:
stable`.
- [Phase 3] git log: only 2 unrelated changes to lp873x since v6.6 (GPIO set callback renames), neither affect get().
- [Phase 4] b4 dig: confirmed sister patches found on lore. Lore itself blocked by bot protection.
- [Phase 5] Call chain: userspace -> gpiod_get_value -> gpiochip_get -> lp873x_gpio_get. Reachable from userspace.
- [Phase 6] Function lp873x_gpio_get() is identical in all stable trees since v4.9. Clean apply expected.
- [Phase 8] BITS_PER_GPO=4, offset=1 returns BIT(4)=16, confirmed via computation.
- UNVERIFIED: Could not directly access lore.kernel.org discussion for this specific patch due to bot protection. Relied on b4 dig and sister patch analysis.
The fix is a trivially correct 1-line normalization that fixes a real API violation present since v4.9. Sister patches in the same series have explicit stable nominations. The risk is essentially zero.
**YES**
drivers/gpio/gpio-lp873x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-lp873x.c +1 -1
@@ -55,7 +55,7 @@ static int lp873x_gpio_get(struct gpio_chip *chip, unsigned int offset)if (ret <0 )return ret; -return val &BIT (offset *BITS_PER_GPO ); +return !!(val &BIT (offset *BITS_PER_GPO )); } static int lp873x_gpio_set(struct gpio_chip *chip, unsigned int offset,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: hda: cs35l41: Fix boost type for HP Dragonfly 13.5 inch G4
In reply to Sasha LevinFrom: Leonard Lausen <[email protected]>
[ Upstream commit 6389dbd5c4a2d819ec342f89bd65883ab021278e ]
The HP Dragonfly 13.5 inch G4 (SSID 103C8B63) has _DSD properties in ACPI firmware with valid reset-gpios and cs-gpios for the four CS35L41 amplifiers on SPI.
However, the _DSD specifies cirrus,boost-type as Internal (0), while the hardware requires External Boost. With Internal Boost configured, the amplifiers trigger "Amp short error" when audio is played at moderate-to-high volume, eventually shutting down entirely.
Add a configuration table entry to override the boost type to External, similar to the existing workaround for 103C89C6. All GPIO indices are set to -1 since the _DSD provides valid reset-gpios and cs-gpios.
Confirmed on BIOS V90 01.11.00 (January 2026), the latest available.
---
LLM Generated explanations, may be completely bogus:
I now have all the information needed for my analysis.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: Subject Line
- **Subsystem:** ALSA: hda: cs35l41
- **Action verb:** "Fix" - explicit bug fix
- **Summary:** Fixes incorrect ACPI boost type configuration for HP Dragonfly 13.5 inch G4 (SSID 103C8B63)
- Record: [ALSA/HDA/cs35l41] [fix] [Override incorrect ACPI boost type for specific HP laptop]
### Step 1.2: Tags
- **Link:** https://bugzilla.kernel.org/show_bug.cgi?id=219520 - user- filed Bugzilla report
- **Originally-by:** Nicholas Wang <[email protected]> - original contributor
- **Signed-off-by:** Leonard Lausen <[email protected]> - patch author
- **Link:** https://patch.msgid.link/db84dcf91bc8dbd217b35572b177d96765 [email protected] - mailing list submission
- **Signed-off-by:** Takashi Iwai <[email protected]> - ALSA subsystem maintainer applied it
- No Fixes: tag (expected for manual review candidates), no Cc: stable (expected).
- Record: Bugzilla link present = real user-reported issue. Applied by subsystem maintainer Takashi Iwai. Two contributors (Originally-by + Signed-off-by).
### Step 1.3: Body Text Analysis
- **Bug description:** HP Dragonfly 13.5 inch G4 ACPI _DSD specifies cirrus,boost-type as Internal (0), but hardware requires External Boost.
- **Symptom:** Amplifiers trigger "Amp short error" when audio is played at moderate-to-high volume, eventually shutting down entirely. This means speakers stop working.
- **Fix approach:** Add config table entry to override boost type to External (same pattern as 103C89C6).
- **Version info:** Confirmed on BIOS V90 01.11.00 (January 2026), the latest available.
- Record: Clear bug description with concrete symptom. Incorrect ACPI firmware causes amplifier hardware error and shutdown. Tested on latest BIOS.
### Step 1.4: Hidden Bug Fix Detection
- This is not a hidden bug fix - it's explicitly labeled "Fix" and describes a clear hardware issue.
- Record: Not a hidden fix; explicitly identified as a bug fix for incorrect ACPI firmware.
---
## PHASE 2: DIFF ANALYSIS
### Step 2.1: Changes Inventory
- **File:** sound/hda/codecs/side-codecs/cs35l41_hda_property.c
- **Lines added:** 6 (1 data entry + 4-line comment in cs35l41_config_table, 1 data entry in cs35l41_prop_model_table)
- **Lines removed:** 0
- **Functions modified:** None - only static data tables are changed
- **Scope:** Single-file, data-only, surgical addition
- Record: 1 file, +6 lines (2 table entries + 1 comment block), no function code changes.
### Step 2.2: Code Flow Change
- **Hunk 1:** Adds { "103C8B63", 4, EXTERNAL, { CS35L41_RIGHT, CS35L41_LEFT, CS35L41_RIGHT, CS35L41_LEFT }, -1, -1, -1, 0, 0, 0 } to cs35l41_config_table with a 4-line comment explaining the override. Entry specifies 4 amps, EXTERNAL boost, all GPIO indices = -1 (use ACPI-provided), boost parameters = 0 (not needed for external).
- **Hunk 2:** Adds { "CSC3551", "103C8B63", generic_dsd_config } to cs35l41_prop_model_table, connecting the SSID to the generic_dsd_config handler.
- Before: SSID 103C8B63 had no override entry, so ACPI _DSD values were used directly (Internal boost = wrong).
- After: SSID 103C8B63 matches config table, generic_dsd_config overrides boost to External.
### Step 2.3: Bug Mechanism
- **Category:** Hardware workaround (ACPI firmware quirk)
- **Mechanism:** ACPI firmware incorrectly declares Internal Boost for a device that requires External Boost. The driver trusts the ACPI data, configures the amplifier incorrectly, causing hardware protection errors ("Amp short error") and eventual amplifier shutdown.
- Record: Hardware quirk/workaround for incorrect ACPI firmware. Overrides boost type from Internal to External for specific SSID.
### Step 2.4: Fix Quality
- Obviously correct: Follows identical pattern to 103C89C6 (HP Zbook Fury 17 G9), which has been in the tree since December 2023.
- Minimal and surgical: Pure data-table additions, no logic changes.
- Regression risk: Zero for other devices (entries only match specific SSID 103C8B63). Very low for this device (same pattern as proven workaround).
- Record: Obviously correct, minimal, zero regression risk for other hardware.
---
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: Blame
- The config table was introduced by commit 8c4c216db8fb8 (December 2023) by Stefan Binding.
- The 103C89C6 boost type override entry (same pattern) was introduced by commit d110858a692582 (December 2023).
- The prop_model_table and generic_dsd_config function have been stable since then, with only additional SSID entries added.
- Record: Infrastructure has been stable since v6.8 era. The buggy ACPI firmware is in the hardware, not in kernel code.
### Step 3.2: Fixes Tag
- No Fixes: tag present (expected). The "bug" is in ACPI firmware, not a kernel code regression.
- Record: N/A - firmware quirk, not a kernel regression.
### Step 3.3: File History
- Recent commits: f205ed23f0687 (Lenovo Thinkbook support), 6014e9021b28e (file move).
- The file is regularly updated with new device SSID entries - this is standard maintenance.
- Record: Standalone change, no prerequisites. Regular table addition.
### Step 3.4: Author
- Leonard Lausen is not the subsystem maintainer but the patch was reviewed and applied by Takashi Iwai, the ALSA subsystem maintainer.
- Originally contributed by Nicholas Wang, suggesting multiple users encountered the issue.
- Record: Applied by subsystem maintainer Takashi Iwai.
### Step 3.5: Dependencies
- The cs35l41_config_table and cs35l41_prop_model_table structures exist in this tree.
- The generic_dsd_config function exists and is the standard handler for these entries.
- No other commits needed. Standalone.
- Record: No dependencies. Applies standalone. Only concern for older stable trees is the file path (sound/pci/hda/ vs sound/hda/codecs/side-codecs/).
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
### Step 4.1-4.5
- Both lore.kernel.org and bugzilla.kernel.org are behind Anubis bot- protection and could not be fetched.
- b4 dig could not find the commit (it's not in this tree yet, only a message-id reference).
- The patch was accepted by Takashi Iwai (ALSA maintainer) via `Link:
https://patch.msgid.link/...`, confirming it went through normal review.
- Bugzilla bug 219520 exists, confirming this is a user-reported real- world issue.
- Record: UNVERIFIED: Could not access lore or bugzilla due to Anubis protection. However, the patch was applied by the ALSA subsystem maintainer and references a Bugzilla report, both strong signals.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1-5.4
- No functions are modified - only static const data tables.
- generic_dsd_config is the handler that consumes these entries. Verified by reading lines 237-364.
- The lookup path: cs35l41_prop_model_table -> matched by SSID -> calls generic_dsd_config -> searches cs35l41_config_table -> applies boost type override to hw_cfg.
- Lines 344-358 show how boost type determines amplifier configuration (Internal vs External boost, GPIO settings).
- Record: Data-only change. No code logic changes. The consumption path (generic_dsd_config) is well-established and handles dozens of other SSIDs identically.
### Step 5.5: Similar Patterns
- 103C89C6 is the exact same pattern: HP laptop with incorrect ACPI boost type, overridden via config table entry. This has been in the tree since v6.8.
- Dozens of other SSID entries follow the same pattern.
- Record: Well-established pattern with many precedents.
---
## PHASE 6: STABLE TREE ANALYSIS
### Step 6.1
- The config table infrastructure was introduced in December 2023 (v6.8 era). It exists in stable trees 6.6.y (likely backported), 6.12.y, 7.0.y.
- The file was moved to a new path in July 2025 for v7.0. For older stable trees, the file is at sound/pci/hda/cs35l41_hda_property.c.
- Record: Infrastructure exists in stable trees >= 6.6.y. File path differs in older trees.
### Step 6.2
- For v7.0: Should apply cleanly (file exists at new path, tables present).
- For older trees (6.6.y, 6.12.y): Minor path adjustment needed (sound/pci/hda/cs35l41_hda_property.c), and the insertion point after 103C8A6E must exist.
- Record: Clean apply for 7.0. Path adjustment needed for older trees but otherwise trivial.
### Step 6.3
- No related fixes for this specific SSID (103C8B63) exist in any tree.
- Record: No duplicate fixes found.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
### Step 7.1
- **Subsystem:** ALSA (Advanced Linux Sound Architecture) / HDA (High Definition Audio) / CS35L41 amplifier driver
- **Criticality:** IMPORTANT - audio is a core laptop feature, and HP Dragonfly is a popular business laptop
- Record: IMPORTANT subsystem, affects users of a specific HP laptop model.
### Step 7.2
- Active subsystem: Regular SSID additions and quirks. Actively maintained by Takashi Iwai.
- Record: Actively maintained subsystem.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1
- **Affected users:** Owners of HP Dragonfly 13.5 inch G4 (SSID 103C8B63)
- Record: Device-specific (HP Dragonfly 13.5 G4).
### Step 8.2
- **Trigger:** Playing audio at moderate-to-high volume on the affected laptop
- **How common:** Extremely common - basic audio playback
- **Unprivileged trigger:** Yes, any user playing audio
- Record: Very common trigger (normal audio playback).
### Step 8.3
- **Failure mode:** "Amp short error" -> amplifier shutdown -> no audio output
- **Severity:** HIGH - speakers fail during normal use. Not a security issue but major functionality loss.
- Record: HIGH severity - speakers stop working during normal audio playback.
### Step 8.4
- **Benefit:** HIGH - restores working audio for HP Dragonfly 13.5 G4 users on stable kernels
- **Risk:** VERY LOW - 2 data-table entries, only affects SSID 103C8B63, follows proven pattern
- **Ratio:** Excellent benefit-to-risk ratio
- Record: High benefit, very low risk. Excellent ratio.
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: Evidence Summary
**FOR backporting:**
- Fixes real hardware issue reported by users (Bugzilla 219520, two contributors)
- Pure hardware quirk addition - 2 table entries, no logic changes
- Follows exact same proven pattern as existing 103C89C6 workaround
- Applied by ALSA subsystem maintainer Takashi Iwai
- Without the fix, speakers fail during normal audio playback (Amp short error + shutdown)
- Zero regression risk for any other hardware
- Standalone change with no dependencies
**AGAINST backporting:**
- None identified. This is a textbook stable candidate.
### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **YES** - Confirmed on BIOS V90, follows identical proven pattern
2. Fixes a real bug? **YES** - User-reported Bugzilla, speakers fail during audio playback
3. Important issue? **YES** - Complete speaker failure on a popular business laptop
4. Small and contained? **YES** - 2 table entries in 1 file (+6 lines total)
5. No new features or APIs? **YES** - Data-only quirk, no new functionality
6. Can apply to stable? **YES** - Clean for 7.0; minor path adjustment for older trees
### Step 9.3: Exception Category
This is a **hardware quirk/workaround** - one of the explicitly allowed exception categories for stable. These are automatically strong YES candidates.
### Step 9.4: Decision
This is a textbook hardware quirk that fixes broken audio on a specific HP laptop. It's minimal, zero-risk, follows a proven pattern, was reported by real users, and was applied by the subsystem maintainer.
---
## Verification
- [Phase 1] Parsed tags: Link to bugzilla.kernel.org/219520, Originally- by + Signed-off-by, applied by maintainer Takashi Iwai
- [Phase 2] Diff analysis: 2 table entries added (+6 lines with comment), no logic changes, single file
- [Phase 2] Verified entry format matches existing entries (e.g., 103C89C6 at line 47, 103C8A6E at line 57)
- [Phase 3] git blame: Config table infrastructure from commit 8c4c216db8fb8 (Dec 2023), present since v6.8
- [Phase 3] git show 581523ee3652e: Confirmed identical pattern for HP Zbook 103C89C6 boost type override
- [Phase 3] git log: No prerequisites needed, standalone change
- [Phase 4] UNVERIFIED: Could not access lore.kernel.org or bugzilla.kernel.org due to Anubis bot protection
- [Phase 5] Read generic_dsd_config (lines 237-364): Verified consumption path - table lookup by SSID, boost type applied at lines 344-358
- [Phase 6] git tag: Infrastructure present in tree (v7.0), file at new path since July 2025
- [Phase 6] git log old path: confirmed file was at sound/pci/hda/ for older stable trees
- [Phase 8] Failure mode: "Amp short error" and amplifier shutdown during audio playback = HIGH severity
**YES**
sound/hda/codecs/side-codecs/cs35l41_hda_property.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/hda/codecs/side-codecs/cs35l41_hda_property.c +6 -0
@@ -55,6 +55,11 @@ static const struct cs35l41_config cs35l41_config_table[] = { { "103C8A30", 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 1000, 4100, 24 }, { "103C8A31", 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 1000, 4100, 24 }, { "103C8A6E", 4, EXTERNAL, { CS35L41_LEFT, CS35L41_LEFT, CS35L41_RIGHT, CS35L41_RIGHT }, 0, -1, -1, 0, 0, 0 }, +/* +* Device 103C8B63 has _DSD with valid reset-gpios and cs-gpios, however the +* boost type is incorrectly set to Internal. Override to External Boost. +*/ + { "103C8B63", 4, EXTERNAL, { CS35L41_RIGHT, CS35L41_LEFT, CS35L41_RIGHT, CS35L41_LEFT }, -1, -1, -1, 0, 0, 0 }, { "103C8BB3", 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 1000, 4100, 24 }, { "103C8BB4", 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 1000, 4100, 24 }, { "103C8BDD", 2, INTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 1000, 4100, 24 },
@@ -475,6 +480,7 @@ static const struct cs35l41_prop_model cs35l41_prop_model_table[] = { { "CSC3551", "103C8A30", generic_dsd_config }, { "CSC3551", "103C8A31", generic_dsd_config }, { "CSC3551", "103C8A6E", generic_dsd_config }, + { "CSC3551", "103C8B63", generic_dsd_config }, { "CSC3551", "103C8BB3", generic_dsd_config }, { "CSC3551", "103C8BB4", generic_dsd_config }, { "CSC3551", "103C8BDD", generic_dsd_config },
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: mt76: don't return TXQ when exceeding max non-AQL packets
In reply to Sasha LevinFrom: David Bauer <[email protected]>
[ Upstream commit 964f870e090e9c88a41e2890333421204cc0bdf4 ]
mt76_txq_send_burst does check if the number of non-AQL frames exceeds the maximum. In this case the queue is returned to ieee80211_return_txq when iterating over the scheduled TXQs in mt76_txq_schedule_list.
This has the effect of inserting said TXQ at the head of the list. This means the loop will get the same TXQ again, which will terminate the scheduling round. TXQs following in the list thus never get scheduled for transmission.
This can manifest in high latency low throughput or broken connections for said STAs.
Check if the non-AQL packet count exceeds the limit and not return the TXQ in this case.
Schedule all TXQs for the STA in case the non-AQL limit can be satisfied again.
---
LLM Generated explanations, may be completely bogus:
I now have all the information needed for a complete analysis. Let me compile my findings.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: Subject Line
- **Subsystem**: wifi: mt76: (MediaTek mt76 WiFi driver)
- **Action verb**: "don't return" — indicates preventing incorrect behavior, i.e., a bug fix
- **Summary**: Don't return TXQ to mac80211 scheduler when the non-AQL packet limit is exceeded
### Step 1.2: Tags
- **Signed-off-by**: David Bauer (author), Felix Fietkau (committer/maintainer)
- **Link**:
https://patch.msgid.link/20260129232321.276575-1-mail@david- bauer.net
- No Fixes: tag, no Cc: stable, no Reported-by — all expected for a commit under review
- Felix Fietkau ([email protected]) is the mt76 subsystem maintainer who merged this
### Step 1.3: Commit Body
- **Bug described**: When mt76_txq_send_burst detects non-AQL packets exceeding the limit, it returns 0. The TXQ is then returned to mac80211 via ieee80211_return_txq(), which re-inserts it at the head of the scheduling list (with airtime fairness). On the next iteration, ieee80211_next_txq() sees the same TXQ with its round number already set, returns NULL, and terminates the scheduling round.
- **Symptom**: "high latency low throughput or broken connections for said STAs" — TXQs following the problematic one in the list never get scheduled.
- **Root cause**: TXQ scheduling starvation due to improper return of rate-limited TXQs
### Step 1.4: Hidden Bug Fix Detection
This is an explicit, clearly-described bug fix for a scheduling starvation issue.
## PHASE 2: DIFF ANALYSIS
### Step 2.1: Inventory
- **Files changed**: 1 file — drivers/net/wireless/mediatek/mt76/tx.c
- **Changes**: ~20 lines added, 0 removed (two code additions)
- **Functions modified**: mt76_tx_check_non_aql(), mt76_txq_schedule_list()
- **Scope**: Single-file, surgical fix in two specific functions
### Step 2.2: Code Flow Changes
**Hunk 1** (mt76_tx_check_non_aql):
- **Before**: Decrements non_aql_packets on tx completion, clamps to 0 if negative, returns
- **After**: Same, plus: when pending == MT_MAX_NON_AQL_PKT - 1 (count just dropped below limit), reschedules all TXQs for the STA via ieee80211_schedule_txq(). This ensures TXQs that were dropped from the scheduling list get re-added.
**Hunk 2** (mt76_txq_schedule_list):
- **Before**: After getting a TXQ from ieee80211_next_txq(), checks PS flag and reset state, then proceeds to mt76_txq_send_burst() which may early-return if non-AQL limit is hit. Then always calls ieee80211_return_txq().
- **After**: Adds a check if (atomic_read(&wcid->non_aql_packets) >= MT_MAX_NON_AQL_PKT) continue; — skips the TXQ without returning it to the scheduler, allowing the loop to proceed to the next TXQ.
### Step 2.3: Bug Mechanism
This is a **logic/scheduling correctness bug**. The mac80211 TXQ scheduler has specific round-tracking semantics:
- ieee80211_next_txq() removes the TXQ and marks its round number
- ieee80211_return_txq() re-inserts it (at HEAD with airtime fairness)
- A subsequent ieee80211_next_txq() seeing the same TXQ's round number → returns NULL, ending the round
When a non-AQL-limited TXQ is returned to the list, it poisons the scheduling round and starves all subsequent TXQs.
### Step 2.4: Fix Quality
- **Obviously correct**: Yes — the continue pattern is already used in this function for PS flag and reset state checks
- **Minimal/surgical**: Yes — two small additions, no unrelated changes
- **Regression risk**: Very low — not returning a rate-limited TXQ is correct; the rescheduling on tx completion ensures it gets re-added when appropriate
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: Blame
- mt76_tx_check_non_aql() — core logic introduced by e1378e5228aaa1 (Felix Fietkau, 2020-08-23), refactored in 0fe88644c06063 (2021-05-07)
- mt76_txq_schedule_list() — scheduling loop from 17f1de56df0512 (2017-11-21), with non-AQL logic from e1378e5228aaa1
- The non-AQL mechanism itself was introduced in commit e1378e5228aaa1 which first appeared in **v5.10-rc1**
### Step 3.2: Fixes Tag
No Fixes: tag present. However, the bug was effectively introduced by e1378e5228aaa1 ("mt76: rely on AQL for burst size limits on tx queueing") in v5.10-rc1.
### Step 3.3: File History
- tx.c has had 19 commits since v6.1, including multi-radio support (716cc146d5805, Jan 2025) and wcid pointer wrapper (dc66a129adf1f, Jul 2025)
- This patch is standalone — not part of a series
### Step 3.4: Author
- David Bauer: occasional mt76 contributor (5 commits found), has worked on mt7915 MCU and other mt76 issues
- Felix Fietkau: mt76 subsystem maintainer who reviewed and merged this
### Step 3.5: Dependencies
- The continue in scheduling loop follows the existing pattern (PS flag, reset state already use continue)
- The rescheduling uses ieee80211_schedule_txq() — available since mac80211 TXQ API inception
- wcid_to_sta() — fundamental mt76 helper, present in all trees
- Minor adaptations needed for older trees (e.g., __mt76_wcid_ptr vs rcu_dereference)
## PHASE 4: MAILING LIST RESEARCH
### Step 4.1–4.5
b4 dig couldn't find the message-id, and lore.kernel.org is blocking automated access. The patch link is https://patch.msgid.link/[email protected]. It was merged by Felix Fietkau (mt76 maintainer), which provides strong implicit review. No NAKs or objections were found.
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1: Functions Modified
1. mt76_tx_check_non_aql() — called from __mt76_tx_complete_skb() on every TX completion
2. mt76_txq_schedule_list() — core TX scheduling loop, called from mt76_txq_schedule()
### Step 5.2: Callers
- mt76_tx_check_non_aql() → called from __mt76_tx_complete_skb() which is the main TX completion path for ALL mt76 drivers
- mt76_txq_schedule_list() → called from mt76_txq_schedule() → mt76_txq_schedule_all() → mt76_tx_worker_run() — the main TX worker
### Step 5.3–5.4: Call Chain
TX completion path: hardware IRQ → driver tx_complete → __mt76_tx_complete_skb() → mt76_tx_check_non_aql() → (new) ieee80211_schedule_txq(). This is a very hot, commonly-exercised path.
### Step 5.5: Similar Patterns
The existing continue statements in mt76_txq_schedule_list() for PS flag and reset state already follow the exact same pattern of skipping TXQs without returning them.
## PHASE 6: STABLE TREE ANALYSIS
### Step 6.1: Buggy Code in Stable
The non-AQL mechanism (e1378e5228aaa1) was introduced in v5.10-rc1. All active stable trees (5.10.y, 5.15.y, 6.1.y, 6.6.y, 6.12.y) contain the buggy code.
### Step 6.2: Backport Complications
- The multi-radio refactoring (716cc146d5805, Jan 2025) and wcid_ptr wrapper (dc66a129adf1f, Jul 2025) are post-6.12
- Older trees will need minor adaptation (e.g., different wcid lookup syntax)
- The core logical change applies cleanly to all trees conceptually
### Step 6.3: No Related Fixes in Stable
No existing fix for this scheduling starvation issue was found in stable.
## PHASE 7: SUBSYSTEM CONTEXT
### Step 7.1: Subsystem Criticality
- **Subsystem**: drivers/net/wireless/mediatek/mt76 — one of the most widely-used WiFi driver families in Linux
- **Criticality**: IMPORTANT — mt76 covers MT7603, MT7615, MT7915, MT7921, MT7996 chipsets used in routers, laptops, and access points
- This affects ALL mt76 devices, not just a specific chipset
### Step 7.2: Subsystem Activity
Active development — 30 commits in recent history for tx.c alone.
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: Affected Users
All users of mt76 WiFi hardware (very broad: routers, embedded systems, laptops). mt76 is one of the most popular WiFi driver families in the Linux kernel.
### Step 8.2: Trigger Conditions
- Trigger: Multiple STAs connected, one STA hitting the non-AQL packet limit (common during bursts before rate control information is available, or under load)
- With airtime fairness enabled (default in many configurations):
immediate starvation of all other STAs in the same AC
- Very likely to trigger in multi-client AP scenarios (routers, access points)
### Step 8.3: Failure Mode Severity
- **Failure mode**: High latency, low throughput, or broken connections for affected STAs
- **Severity**: HIGH — loss of connectivity/severe degradation for WiFi clients in multi-client scenarios
### Step 8.4: Risk-Benefit
- **Benefit**: HIGH — fixes scheduling starvation affecting all mt76 users with multiple clients
- **Risk**: VERY LOW — ~20 lines, follows existing patterns, single file, obviously correct, merged by subsystem maintainer
- **Ratio**: Strongly favorable for backporting
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: Evidence Summary
**FOR backporting:**
- Fixes a real, user-visible bug (high latency, broken connections)
- Affects all mt76 WiFi users with multiple clients — very broad impact
- Small, surgical fix (~20 lines, single file)
- Follows existing code patterns (continue for TXQ skipping)
- Merged by subsystem maintainer (Felix Fietkau)
- Bug exists in all stable trees since v5.10
- No regression risk — the fix is obviously correct
**AGAINST backporting:**
- No Fixes: tag or Cc: stable (expected)
- Minor adaptation needed for older trees due to intermediate refactoring
- No syzbot/KASAN report (this is a logic/scheduling bug, not memory safety)
### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **YES** — merged by maintainer, follows established patterns
2. Fixes a real bug? **YES** — scheduling starvation causing high latency/broken connections
3. Important issue? **YES** — connectivity loss for WiFi clients in common multi-client scenarios
4. Small and contained? **YES** — ~20 lines, single file, two functions
5. No new features or APIs? **YES** — no new features
6. Can apply to stable? **YES** — with minor adaptation for older trees
### Step 9.3: Exception Categories
Not an exception category — this is a standard bug fix.
### Step 9.4: Decision
This is a clear bug fix for a significant scheduling starvation issue in the mt76 WiFi driver. The fix is small, obviously correct, and addresses a real user-visible problem (high latency, low throughput, broken connections) that affects all mt76 WiFi users in multi-client scenarios.
## Verification
- [Phase 1] Parsed tags: Signed-off-by David Bauer (author) and Felix Fietkau (maintainer/committer), Link to patch.msgid.link
- [Phase 2] Diff analysis: ~20 lines added in two functions in tx.c; adds non-AQL limit check in scheduling loop + TXQ rescheduling on tx completion
- [Phase 2] Verified ieee80211_return_txq() calls __ieee80211_schedule_txq() which re-inserts at head with airtime fairness (net/mac80211/tx.c lines 4116-4151)
- [Phase 2] Verified ieee80211_next_txq() terminates round when seeing same TXQ's schedule_round (net/mac80211/tx.c lines 4103-4104)
- [Phase 3] git blame: non-AQL logic introduced in e1378e5228aaa1 (2020-08-23), first in v5.10-rc1
- [Phase 3] git describe: confirmed e1378e5228aaa1 is v5.10-rc1~107^2~150^2~2^2~34
- [Phase 3] Existing continue pattern verified in mt76_txq_schedule_list() for PS flag (line 542-543) and reset state (line 546-547)
- [Phase 3] No dependent patches found; this is standalone
- [Phase 4] b4 dig: could not find match; lore blocked by anti-scraping
- [Phase 5] mt76_tx_check_non_aql called from __mt76_tx_complete_skb (hot TX completion path, line 255)
- [Phase 5] mt76_txq_schedule_list called from mt76_txq_schedule → mt76_txq_schedule_all → mt76_tx_worker_run (main TX worker)
- [Phase 6] Bug present in all stable trees 5.10.y through 6.12.y (e1378e5228aaa1 in v5.10-rc1)
- [Phase 6] Backport needs minor adaptation for multi-radio refactoring (716cc146d5805) and wcid_ptr wrapper (dc66a129adf1f)
- [Phase 8] Failure mode: scheduling starvation → high latency/broken connections; severity HIGH
- UNVERIFIED: Exact mailing list review discussion (lore blocked); however, maintainer merge provides implicit review confirmation
**YES**
drivers/net/wireless/mediatek/mt76/tx.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/net/wireless/mediatek/mt76/tx.c +16 -0
@@ -227,7 +227,9 @@ mt76_tx_check_non_aql(struct mt76_dev *dev, struct mt76_wcid *wcid, struct sk_buff *skb) {struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb); +struct ieee80211_sta *sta;int pending; +int i;if (!wcid || info->tx_time_est)return ;
@@ -235,6 +237,17 @@ mt76_tx_check_non_aql(struct mt76_dev *dev, struct mt76_wcid *wcid, pending =atomic_dec_return (&wcid->non_aql_packets);if (pending <0 )atomic_cmpxchg (&wcid->non_aql_packets, pending,0 ); + + sta =wcid_to_sta (wcid); +if (!sta || pending !=MT_MAX_NON_AQL_PKT -1 ) +return ; + +for (i =0 ; i <ARRAY_SIZE (sta->txq); i++) { +if (!sta->txq[i]) +continue ; + +ieee80211_schedule_txq (dev->hw, sta->txq[i]); + } } void __mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid_idx, struct sk_buff *skb,
@@ -542,6 +555,9 @@ mt76_txq_schedule_list(struct mt76_phy *phy, enum mt76_txq_id qid)if (!wcid ||test_bit (MT_WCID_FLAG_PS , &wcid->flags))continue ; +if (atomic_read (&wcid->non_aql_packets) >=MT_MAX_NON_AQL_PKT ) +continue ; + phy =mt76_dev_phy (dev, wcid->phy_idx);if (test_bit (MT76_RESET , &phy->state) || phy->offchannel)continue ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 arm64: dts: imx91-tqma9131: improve eMMC pad configuration
In reply to Sasha LevinFrom: Markus Niebel <[email protected]>
[ Upstream commit 44db7bc66eb38e85bb32777c5fd3a4e7baa84147 ]
Use DSE x4 an PullUp for CMD an DAT, DSE x4 and PullDown for CLK to improve stability and detection at low temperatures under -25°C.
---
LLM Generated explanations, may be completely bogus:
Error: Failed to generate final synthesis
.../boot/dts/freescale/imx91-tqma9131.dtsi | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
arch/arm64/boot/dts/freescale/imx91-tqma9131.dtsi +10 -10
@@ -272,20 +272,20 @@ pinctrl_reg_usdhc2_vmmc: regusdhc2vmmcgrp { /* enable SION for data and cmd pad due to ERR052021 */ pinctrl_usdhc1: usdhc1grp { fsl,pins = /* PD | FSEL 3 | DSE X5 */ - <MX91_PAD_SD1_CLK__USDHC1_CLK 0x5be>, + <MX91_PAD_SD1_CLK__USDHC1_CLK 0x59e>, /* HYS | FSEL 0 | no drive */ <MX91_PAD_SD1_STROBE__USDHC1_STROBE 0x1000>, /* HYS | FSEL 3 | X5 */ - <MX91_PAD_SD1_CMD__USDHC1_CMD 0x400011be>, + <MX91_PAD_SD1_CMD__USDHC1_CMD 0x4000139e>, /* HYS | FSEL 3 | X4 */ - <MX91_PAD_SD1_DATA0__USDHC1_DATA0 0x4000119e>, - <MX91_PAD_SD1_DATA1__USDHC1_DATA1 0x4000119e>, - <MX91_PAD_SD1_DATA2__USDHC1_DATA2 0x4000119e>, - <MX91_PAD_SD1_DATA3__USDHC1_DATA3 0x4000119e>, - <MX91_PAD_SD1_DATA4__USDHC1_DATA4 0x4000119e>, - <MX91_PAD_SD1_DATA5__USDHC1_DATA5 0x4000119e>, - <MX91_PAD_SD1_DATA6__USDHC1_DATA6 0x4000119e>, - <MX91_PAD_SD1_DATA7__USDHC1_DATA7 0x4000119e>; + <MX91_PAD_SD1_DATA0__USDHC1_DATA0 0x4000139e>, + <MX91_PAD_SD1_DATA1__USDHC1_DATA1 0x4000139e>, + <MX91_PAD_SD1_DATA2__USDHC1_DATA2 0x4000139e>, + <MX91_PAD_SD1_DATA3__USDHC1_DATA3 0x4000139e>, + <MX91_PAD_SD1_DATA4__USDHC1_DATA4 0x4000139e>, + <MX91_PAD_SD1_DATA5__USDHC1_DATA5 0x4000139e>, + <MX91_PAD_SD1_DATA6__USDHC1_DATA6 0x4000139e>, + <MX91_PAD_SD1_DATA7__USDHC1_DATA7 0x4000139e>; }; pinctrl_wdog: wdoggrp {
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ASoC: amd: acp: add ASUS HN7306EA quirk for legacy SDW machine
In reply to Sasha LevinFrom: Hasun Park <[email protected]>
[ Upstream commit 2594196f4e3bd70782e7cf1e22e3e398cdb74f78 ]
Add a DMI quirk entry for ASUS HN7306EA in the ACP SoundWire legacy machine driver.
Set driver_data to ASOC_SDW_ACP_DMIC for this board so the platform-specific DMIC quirk path is selected.
---
LLM Generated explanations, may be completely bogus:
Error: Failed to generate final synthesis
sound/soc/amd/acp/acp-sdw-legacy-mach.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/soc/amd/acp/acp-sdw-legacy-mach.c +8 -0
@@ -111,6 +111,14 @@ static const struct dmi_system_id soc_sdw_quirk_table[] = { }, .driver_data = (void *)(ASOC_SDW_CODEC_SPKR), }, + { + .callback = soc_sdw_quirk_cb, + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "HN7306EA"), + }, + .driver_data = (void *)(ASOC_SDW_ACP_DMIC), + }, {} };
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: mac80211: properly handle error in ieee80211_add_virtual_monitor
In reply to Sasha LevinFrom: Miri Korenblit <[email protected]>
[ Upstream commit 876565d4a826f3f04ef36f1cef6123ed4b150aa3 ]
In case of an error in ieee80211_add_virtual_monitor, SDATA_STATE_RUNNING should be cleared as it was set in this function. Do it there instead of in the error path of ieee80211_do_open.
---
LLM Generated explanations, may be completely bogus:
Now I have enough information for a thorough analysis. Let me compile the findings.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: Subject Line
- **Subsystem**: wifi: mac80211
- **Action verb**: "properly handle" (strong indicator of a bug fix)
- **Summary**: Fix error handling in ieee80211_add_virtual_monitor -- SDATA_STATE_RUNNING bit not properly managed on error paths.
Record: [wifi: mac80211] [properly handle] [Fix SDATA_STATE_RUNNING management on error paths in virtual monitor addition]
### Step 1.2: Tags
- **Reviewed-by**: Johannes Berg (mac80211 subsystem maintainer)
- **Signed-off-by**: Miri Korenblit (Intel WiFi developer, regular mac80211 contributor)
- **Signed-off-by**: Johannes Berg (maintainer applied the patch)
- **Link**: patch.msgid.link URL (lore.kernel.org backed)
- No Fixes: tag (expected for AUTOSEL candidates)
- No Reported-by: tag
- No Cc: stable tag
Record: Reviewed and signed-off by the subsystem maintainer. Strong quality signal.
### Step 1.3: Commit Body
The commit explains: when ieee80211_add_virtual_monitor encounters an error, SDATA_STATE_RUNNING should be cleared within the function itself (since it was set there), rather than relying on the caller's error path in ieee80211_do_open (where it was clearing a bit that was never set on the caller's sdata).
Record: Bug is incorrect state management -- SDATA_STATE_RUNNING bit left set on error paths within the function. The caller's cleanup was a no-op.
### Step 1.4: Hidden Bug Fix Detection
"properly handle error" is a direct bug fix description. This fixes a state consistency issue where SDATA_STATE_RUNNING is set but never cleared on failure, which could cause incorrect behavior in the extensive code paths that check ieee80211_sdata_running().
Record: This is clearly a bug fix, not disguised.
---
## PHASE 2: DIFF ANALYSIS
### Step 2.1: Inventory
- **Files changed**: 1 (net/mac80211/iface.c)
- **Lines**: ~5 lines changed effectively (moved set_bit, added clear_bit, removed dead code)
- **Functions modified**: ieee80211_add_virtual_monitor and ieee80211_do_open
Record: Single file, surgical change, two functions affected. Scope:
very small.
### Step 2.2: Code Flow Changes
**Hunk 1** (ieee80211_add_virtual_monitor):
- **Before**: set_bit(SDATA_STATE_RUNNING) at line 1225 BEFORE ieee80211_check_queues; if check_queues fails, sdata is freed with RUNNING still set.
- **After**: set_bit(SDATA_STATE_RUNNING) moved AFTER ieee80211_check_queues. The bit is only set once the queues are verified. In the ieee80211_link_use_channel error path, clear_bit(SDATA_STATE_RUNNING) is added before kfree(sdata).
**Hunk 2** (ieee80211_do_open):
- **Before**: clear_bit(SDATA_STATE_RUNNING, &sdata->state) in error path with comment "might already be clear but that doesn't matter."
- **After**: This clear_bit is removed because SDATA_STATE_RUNNING is only set at line 1541 (after all error gotos), so clearing it in the error path was always a no-op.
### Step 2.3: Bug Mechanism
This is a **state management / initialization bug**. The SDATA_STATE_RUNNING bit gates behavior in ~50+ call sites across mac80211 (TX, RX, scan, reconfig, offchannel, etc.). Setting it prematurely or failing to clear it on error leads to inconsistent state.
The correct pattern is shown in ieee80211_del_virtual_monitor (lines 1301-1312):
```1301:1312:net/mac80211/iface.c
clear_bit(SDATA_STATE_RUNNING, &sdata->state);
ieee80211_link_release_channel(&sdata->deflink);
// ...
drv_remove_interface(local, sdata);
// ...
kfree(sdata);
```The error path was missing the clear_bit before teardown, inconsistent with this established pattern.
### Step 2.4: Fix Quality
- Obviously correct: follows the established pattern in ieee80211_del_virtual_monitor
- Minimal/surgical: only moves one bit-set and adds one bit-clear
- Regression risk: very low -- the removed clear_bit in ieee80211_do_open was a no-op
- Reviewed by maintainer Johannes Berg
---
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: Blame
The set_bit(SDATA_STATE_RUNNING) was introduced by commit bdeca45a0cc58 ("mac80211: set SDATA_STATE_RUNNING for monitor interfaces") from 2020-11-29. This commit was added to fix HW restart issues but didn't account for all error paths.
The buggy code exists since v5.10 (confirmed via git merge-base --is- ancestor), and is present in v5.15, v6.1, v6.6, and all newer stable trees.
### Step 3.2: Fixes Tag
No Fixes: tag present. The implicit fix target is bdeca45a0cc58 from 2020-11-29.
### Step 3.3: Related Changes
- cbf0dc37bb4e9 ("wifi: mac80211: fix list iteration in ieee80211_add_virtual_monitor()") -- a syzbot-reported fix in the same function, shows the function has known bug history.
- c0d82ba9612fb -- Miri's other commit about ieee80211_sdata_running checks.
### Step 3.4: Author
Miri Korenblit is a regular Intel WiFi developer with many commits to mac80211. The patch was reviewed by Johannes Berg, the mac80211 maintainer.
### Step 3.5: Dependencies
No dependencies found. The fix is self-contained and modifies only the ordering and presence of set_bit/clear_bit calls on existing state bits. Should apply cleanly to stable trees back to v5.10.
---
## PHASE 4: MAILING LIST RESEARCH
Lore.kernel.org was behind anti-bot protection and could not be fetched. The Link: tag points to the original submission. The patch was reviewed by the maintainer.
Record: Could not fetch lore discussion due to anti-bot protection. The Reviewed-by from Johannes Berg is a strong quality signal.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1-5.4: Functions and Call Chains ieee80211_sdata_running() (which checks SDATA_STATE_RUNNING) is called from **50+ locations** across mac80211:
- TX hot path (tx.c:2319, 4291, 4523, 4707)
- RX path (rx.c:5396)
- HW reconfig (util.c:1925, 1942, 1955, 1985, 2157, 2248)
- Scanning (scan.c:532, 942, 1152)
- Channel management (chan.c:93, 568)
- Configuration (cfg.c multiple locations)
The critical path is HW reconfig at util.c:1954-1956:
```c
sdata = wiphy_dereference(local->hw.wiphy, local->monitor_sdata);
if (sdata && ieee80211_sdata_running(sdata))
ieee80211_assign_chanctx(local, sdata, &sdata->deflink);
```If the sdata was partially initialized (RUNNING set but channel context failed), this could attempt operations on invalid state.
### Step 5.5: Similar Patterns
The proper pattern (clear_bit before teardown) is consistently used in ieee80211_del_virtual_monitor (line 1301) and ieee80211_do_stop (line 490). The error path was the outlier.
---
## PHASE 6: STABLE TREE ANALYSIS
### Step 6.1: Buggy Code in Stable
The buggy commit bdeca45a0cc58 from Nov 2020 is present in **all active stable trees**: v5.10, v5.15, v6.1, v6.6, v6.12. The fix is relevant to all of them.
### Step 6.2: Backport Complications
The function signature changed (added creator_sdata parameter), but the core logic and error paths are the same. Minor conflicts possible in older trees but the fix concept applies cleanly.
### Step 6.3: Related Fixes in Stable
No other fix for this specific issue found in stable.
---
## PHASE 7: SUBSYSTEM CONTEXT
### Step 7.1: Criticality
- **Subsystem**: WiFi (net/mac80211) -- IMPORTANT level
- WiFi is used by vast majority of laptops, embedded systems, IoT devices
- mac80211 is the core WiFi stack used by most WiFi drivers
### Step 7.2: Activity
Very active subsystem (87 changes since v6.6 for this single file).
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: Affected Users
All WiFi users whose hardware uses mac80211 virtual monitor interfaces (common during scanning, monitoring).
### Step 8.2: Trigger Conditions
Triggered when ieee80211_add_virtual_monitor fails -- specifically when ieee80211_check_queues or ieee80211_link_use_channel return errors. This can happen during:
- HW restart/reconfig (util.c:2269)
- Opening a monitor interface (iface.c:1437)
- Channel context assignment failures
### Step 8.3: Failure Mode
- Incorrect SDATA_STATE_RUNNING state could cause code paths gated by ieee80211_sdata_running() to operate on improperly initialized sdata
- In the worst case, during HW reconfig, could lead to inconsistent driver state, potential crashes, or resource leaks
- Severity: **MEDIUM-HIGH** (state corruption in WiFi stack, potential for cascading issues)
### Step 8.4: Risk-Benefit
- **Benefit**: Fixes state management bug in widely used WiFi code, present since v5.10
- **Risk**: Very low -- moves one set_bit, adds one clear_bit, removes dead code. Reviewed by maintainer.
- **Ratio**: Favorable for backport
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: Evidence Summary
**FOR backporting:**
- Fixes a real error handling bug (SDATA_STATE_RUNNING not cleared on error paths)
- ieee80211_sdata_running() checked in 50+ locations -- incorrect state has wide impact
- Bug present since v5.10, affects all stable trees
- Small, surgical fix (5 effective lines changed)
- Reviewed and signed-off by Johannes Berg (mac80211 maintainer)
- Author is a regular Intel WiFi contributor
- Follows established cleanup pattern from ieee80211_del_virtual_monitor
- Single file change, no dependencies
**AGAINST backporting:**
- No specific crash/bug report referenced (no Reported-by)
- Failure requires specific error conditions (channel context failure)
- Minor function signature differences in older stable trees
### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **YES** -- follows existing pattern, reviewed by maintainer
2. Fixes a real bug? **YES** -- state bit not cleared on error path
3. Important issue? **YES** -- affects WiFi state management in widely- used code
4. Small and contained? **YES** -- 5 lines across one file
5. No new features or APIs? **YES** -- purely error handling fix
6. Can apply to stable trees? **YES** -- code exists in all active stable trees
### Step 9.3: Exceptions
Not applicable.
---
## Verification
- [Phase 1] Parsed tags: Reviewed-by Johannes Berg (maintainer), SOB from Miri Korenblit (Intel wifi dev)
- [Phase 2] Diff analysis: set_bit moved after ieee80211_check_queues; clear_bit added in ieee80211_link_use_channel error path; dead clear_bit removed from ieee80211_do_open
- [Phase 3] git blame: SDATA_STATE_RUNNING introduced by bdeca45a0cc58 (2020-11-29), present since v5.10
- [Phase 3] git merge-base: confirmed bdeca45a0cc58 is in v5.10, v5.15, v6.1, v6.6
- [Phase 3] Related fix cbf0dc37bb4e9 (syzbot-found bug in same function) confirms function has bug history
- [Phase 4] Could not fetch lore discussion (anti-bot protection).
UNVERIFIED: no stable nomination in discussion
- [Phase 5] grep: ieee80211_sdata_running() used in 50+ call sites across TX, RX, scan, reconfig, cfg
- [Phase 5] Compared with ieee80211_del_virtual_monitor (line 1301):
proper pattern clears RUNNING before teardown
- [Phase 6] Bug code present in all active stable trees (v5.10+)
- [Phase 8] Failure mode: inconsistent SDATA_STATE_RUNNING during error recovery, severity MEDIUM-HIGH
The fix is small, correct, matches established patterns, reviewed by the subsystem maintainer, and fixes a real state management bug in code present in all stable trees.
**YES**
net/mac80211/iface.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
net/mac80211/iface.c +3 -4
@@ -1222,14 +1222,14 @@ int ieee80211_add_virtual_monitor(struct ieee80211_local *local, } } -set_bit (SDATA_STATE_RUNNING , &sdata->state); - ret =ieee80211_check_queues (sdata,NL80211_IFTYPE_MONITOR );if (ret) {kfree (sdata);return ret; } +set_bit (SDATA_STATE_RUNNING , &sdata->state); +mutex_lock (&local->iflist_mtx);rcu_assign_pointer (local->monitor_sdata, sdata);mutex_unlock (&local->iflist_mtx);
@@ -1242,6 +1242,7 @@ int ieee80211_add_virtual_monitor(struct ieee80211_local *local,mutex_unlock (&local->iflist_mtx);synchronize_net ();drv_remove_interface (local, sdata); +clear_bit (SDATA_STATE_RUNNING , &sdata->state);kfree (sdata);return ret; }
@@ -1550,8 +1551,6 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up) sdata->bss =NULL ;if (sdata->vif.type ==NL80211_IFTYPE_AP_VLAN )list_del (&sdata->u.vlan.list); -/* might already be clear but that doesn't matter */ -clear_bit (SDATA_STATE_RUNNING , &sdata->state);return res; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 net: qrtr: fix endian handling of confirm_rx field
In reply to Sasha LevinFrom: Alexander Wilhelm <[email protected]>
[ Upstream commit e4cf6087cab382c7031e6b436ec55202fa9f2d7b ]
Convert confirm_rx to little endian when enqueueing and convert it back on receive. This fixes control flow on big endian hosts, little endian is unaffected.
On transmit, store confirm_rx as __le32 using cpu_to_le32(). On receive, apply le32_to_cpu() before using the value. !! ensures the value is 0 or 1 in native endianness, so the conversion isn’t strictly required here, but it is kept for consistency and clarity.
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed for a comprehensive analysis.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: PARSE THE SUBJECT LINE
Record: **[net: qrtr]** **[fix]** Fix endian handling of confirm_rx field — the word "fix" is used explicitly, targeting an endianness bug in QRTR protocol.
### Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
- **Reviewed-by: Manivannan Sadhasivam <[email protected]>** — QRTR/Qualcomm ARM SoC maintainer
- **Signed-off-by: Alexander Wilhelm <[email protected]>** — Author (Westermo, embedded networking)
- **Reviewed-by: Simon Horman <[email protected]>** — Netdev reviewer
- **Signed-off-by: David S. Miller <[email protected]>** — Net subsystem maintainer merged it
No Fixes: tag (it was deliberately removed at Simon Horman's request during review — see Phase 4). No Reported-by tag. No Cc: stable tag.
### Step 1.3: ANALYZE THE COMMIT BODY TEXT
The commit explains that:
- On transmit, confirm_rx needs cpu_to_le32() because the header struct field is __le32
- On receive, le32_to_cpu() should be applied before use
- The !! ensures the value is 0 or 1, so the receive-side conversion isn't strictly required but is kept for consistency
- This "fixes control flow on big endian hosts"
Record: Bug: Missing endian conversion for the confirm_rx field on both TX and RX paths. Symptom: Broken flow control on big-endian hosts. Little-endian unaffected. Root cause: confirm_rx was stored/read as native endian into a __le32 field.
### Step 1.4: DETECT HIDDEN BUG FIXES
Not hidden — this is an explicit endianness bug fix. The subject says "fix" directly.
---
## PHASE 2: DIFF ANALYSIS — LINE BY LINE
### Step 2.1: INVENTORY THE CHANGES
- **File**: net/qrtr/af_qrtr.c — 2 lines changed (1 modified in TX path, 1 modified in RX path)
- **Functions modified**: qrtr_node_enqueue() (TX), qrtr_endpoint_post() (RX)
- **Scope**: Single-file, extremely surgical fix
### Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
**Hunk 1 (line 364, TX path in qrtr_node_enqueue):**
- Before: hdr->confirm_rx = !!confirm_rx; — stores native-endian int into __le32 field
- After: hdr->confirm_rx = cpu_to_le32(!!confirm_rx); — properly converts to little-endian
- On LE hosts: cpu_to_le32 is a no-op, identical behavior
- On BE hosts: Value 1 was stored as 0x00000001 in native (big-endian) byte order = 0x01000000 in LE interpretation. Now correctly stored as LE 1.
**Hunk 2 (line 465, RX path in qrtr_endpoint_post):**
- Before: cb->confirm_rx = !!v1->confirm_rx; — reads __le32 as native int
- After: cb->confirm_rx = !!le32_to_cpu(v1->confirm_rx); — properly converts from LE first
- Due to !!, the result on the receive side was already correct (any non-zero becomes 1). The fix adds the conversion for correctness/consistency.
### Step 2.3: IDENTIFY THE BUG MECHANISM
Category: **Endianness/type bug (f)**. The qrtr_hdr_v1 struct declares confirm_rx as __le32, and every other field in the struct uses proper cpu_to_le32()/le32_to_cpu() conversions — except confirm_rx. This is the one field that was missed.
### Step 2.4: ASSESS THE FIX QUALITY
- **Obviously correct**: Yes — it follows the exact same pattern as all adjacent fields (type, src_node_id, etc.)
- **Minimal**: Yes — 2 lines, exactly matching the existing code pattern
- **Regression risk**: Essentially zero. On LE hosts (the vast majority), these are no-ops. On BE hosts, this makes the behavior correct.
---
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: BLAME THE CHANGED LINES
- TX line (364): hdr->confirm_rx = !!confirm_rx; — introduced by commit **5fdeb0d372ab** ("net: qrtr: Implement outgoing flow control"), authored 2020-01-13, first appeared in **v5.6-rc1**
- RX line (465): cb->confirm_rx = !!v1->confirm_rx; — introduced by commit **194ccc88297ae** ("net: qrtr: Support decoding incoming v2 packets"), authored 2017-10-10, first appeared in **v4.15**
Record: The buggy TX code has been present since v5.6. The buggy RX code since v4.15. Both are in all active stable trees (5.10, 5.15, 6.1, 6.6, 6.12, 7.0).
### Step 3.2: FOLLOW THE FIXES: TAG
The v2 submission HAD Fixes: 5fdeb0d372ab but it was removed at Simon Horman's request. The original buggy commit 5fdeb0d372ab ("Implement outgoing flow control") is present in v5.6+ and all active stable trees.
### Step 3.3: CHECK FILE HISTORY
Recent changes to af_qrtr.c are unrelated refactoring (xarray conversion, treewide changes, proto_ops changes). No recent endianness fixes.
### Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Alexander Wilhelm from Westermo has a clear pattern of fixing endianness bugs in Qualcomm subsystems: QMI encoding/decoding, MHI BHI vector table, ath12k QMI data. This is part of an effort to make Qualcomm subsystems work on big-endian platforms.
### Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS None. The fix applies directly to the original buggy lines without any prerequisites.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
### Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Found via yhbt.net mirror of lore.kernel.org. The patch went through 3 versions:
- **v1** (2026-03-20): Initial submission with Fixes tag, targeted at net
- **v2** (2026-03-24): Rebase on latest net tree, improved commit message, still had Fixes tag
- **v3** (2026-03-26): Rebase on net-next, Fixes tag removed at Simon Horman's request
### Step 4.2: KEY REVIEWER FEEDBACK
**Simon Horman** (netdev reviewer): "But as this isn't strictly necessary let's target net-next and drop the Fixes tag." This is a **negative signal** for stable backport — the netdev reviewer explicitly downgraded from fix to enhancement.
**Manivannan Sadhasivam** (QRTR maintainer) disagreed: "FWIW: Adding Fixes tag doesn't mean that the patch should be queued for -rcS." Mani thought the Fixes tag was appropriate.
### Step 4.3: BUG REPORT
No external bug report. The author found this during systematic endianness auditing.
### Step 4.4: RELATED PATCHES
This is a standalone fix. Not part of a series.
### Step 4.5: STABLE MAILING LIST HISTORY
No stable-specific discussion found.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1: IDENTIFY KEY FUNCTIONS
- qrtr_node_enqueue() — TX path
- qrtr_endpoint_post() — RX path
### Step 5.2: TRACE CALLERS
- qrtr_node_enqueue() is called from: qrtr_sendmsg() (the main sendmsg path), qrtr_send_resume_tx(), and broadcast path. It's the core TX function.
- qrtr_endpoint_post() is called from: MHI driver (qrtr_mhi.c), SMD driver (qrtr_smd.c), tun driver (qrtr_tun.c). It's the core RX entry point — called for EVERY incoming QRTR packet.
### Step 5.3-5.4: CALL CHAINqrtr_endpoint_post() is called directly from hardware transport drivers on every received packet. qrtr_node_enqueue() is called on every transmitted packet. Both are hot-path functions.
### Step 5.5: SIMILAR PATTERNS
All other fields in qrtr_hdr_v1 already use proper endian conversions. confirm_rx was the only one missed.
---
## PHASE 6: CROSS-REFERENCING AND STABLE TREE ANALYSIS
### Step 6.1: DOES THE BUGGY CODE EXIST IN STABLE TREES? The TX bug (5fdeb0d372ab) exists in **v5.6+**, so all active stable
trees: 5.10.y, 5.15.y, 6.1.y, 6.6.y, 6.12.y.
The RX bug (194ccc88297ae) exists since **v4.15**.
### Step 6.2: BACKPORT COMPLICATIONS
The code at these two lines has not changed since introduction. The patch should apply cleanly to all active stable trees.
### Step 6.3: RELATED FIXES ALREADY IN STABLE
None found.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
### Step 7.1: SUBSYSTEM CRITICALITY
**net/qrtr** — Qualcomm IPC Router, used for communication between Linux and Qualcomm firmware (modem, WiFi, etc.).
Criticality: **PERIPHERAL** — affects users of Qualcomm SoC platforms running big-endian kernels (very niche). Qualcomm SoCs are little-endian ARM, so the primary users are unaffected.
### Step 7.2: SUBSYSTEM ACTIVITY
Moderate activity — mostly maintenance fixes, not heavy development.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: WHO IS AFFECTED
Only big-endian hosts that use QRTR. This is extremely niche — Qualcomm SoCs are LE ARM. However, Westermo (author's company) apparently runs BE systems with QRTR, and there could be other embedded platforms.
### Step 8.2: TRIGGER CONDITIONS
Every QRTR data transmission on a big-endian host. The TX side stores the wrong endianness, which means the remote end receives a malformed confirm_rx value. The RX side is actually mitigated by !! (any non- zero normalizes to 1).
### Step 8.3: FAILURE MODE SEVERITY
On big-endian hosts: The flow control mechanism (confirm_rx/resume_tx) breaks. The TX side sends confirm_rx in wrong byte order. If the remote firmware compares confirm_rx directly to 1 (rather than using !!), it won't send RESUME_TX messages, causing the sender to eventually block or exhaust remote resources.
Severity: **MEDIUM** — broken flow control on a niche platform.
### Step 8.4: RISK-BENEFIT RATIO
- **Benefit**: Fixes real protocol-level correctness bug on BE hosts. Low impact population but real for those affected.
- **Risk**: Essentially zero. cpu_to_le32/le32_to_cpu are no-ops on LE. The fix follows the established pattern used by every other field in the same struct.
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: COMPILE THE EVIDENCE
**FOR backporting:**
- Real endianness correctness bug
- Extremely small fix (2 lines), obviously correct
- Zero regression risk on LE systems (no-op), fixes BE systems
- Follows the identical pattern of all adjacent header fields
- Present in all stable trees since v5.6
- Reviewed by 2 reviewers, merged by David Miller
- Manivannan Sadhasivam (QRTR maintainer) considered the Fixes tag appropriate
**AGAINST backporting:**
- Simon Horman explicitly said "not strictly necessary," asked to drop Fixes tag and target net-next
- Big-endian QRTR usage is extremely niche
- The !! on the RX path mitigates the receive side (only TX is truly broken)
- No user bug report — found during code audit
### Step 9.2: STABLE RULES CHECKLIST
1. Obviously correct and tested? **Yes** — standard endian conversion pattern
2. Fixes a real bug? **Yes** — broken wire protocol on BE hosts
3. Important issue? **Borderline** — broken flow control, but only on BE hosts using QRTR
4. Small and contained? **Yes** — 2 lines in 1 file
5. No new features? **Correct**
6. Can apply to stable? **Yes** — clean apply expected
### Step 9.3: EXCEPTION CATEGORIES
None applicable.
### Step 9.4: DECISION
This is a genuine endianness bug fix with zero regression risk. While the affected population is niche, the fix is so small and obviously correct that the risk/benefit ratio strongly favors inclusion. The netdev reviewer's pushback was about targeting net vs. net-next (merge window process), not about whether the fix is correct. The QRTR maintainer (Mani) disagreed with dropping the Fixes tag. For stable users on big-endian platforms running QRTR, this fixes a real protocol- level correctness issue in the flow control mechanism.
---
## Verification
- [Phase 1] Parsed tags: Reviewed-by from Manivannan Sadhasivam and Simon Horman, SOB from David S. Miller (merger)
- [Phase 2] Diff analysis: 2 lines changed — adding cpu_to_le32() on TX, le32_to_cpu() on RX, matching pattern of all other fields
- [Phase 2] Verified qrtr_hdr_v1.confirm_rx is declared as __le32 (line 44 of af_qrtr.c)
- [Phase 3] git blame: TX line introduced by 5fdeb0d372ab (v5.6, 2020-01-13), RX line by 194ccc88297ae (v4.15, 2017-10-10)
- [Phase 3] git merge-base: Confirmed 5fdeb0d372ab is in v5.10, v5.15, v6.1, v6.6 (all active stable trees)
- [Phase 3] Author check: Alexander Wilhelm has 7 commits all fixing Qualcomm endianness bugs
- [Phase 4] Mailing list (yhbt.net mirror): Found full v2 thread. Simon Horman said "not strictly necessary," Mani disagreed
- [Phase 4] Patch went v1->v2->v3; v3 dropped Fixes tag, targeted net- next at reviewer request
- [Phase 5] Callers verified: qrtr_node_enqueue is core TX path, qrtr_endpoint_post is core RX entry point (EXPORT_SYMBOL_GPL)
- [Phase 5] Verified all other qrtr_hdr_v1 fields use proper endian conversions — only confirm_rx was missed
- [Phase 6] Code is unchanged at buggy lines since introduction — clean apply expected
- [Phase 8] Risk assessment: zero risk on LE (no-op conversions), fixes correctness on BE
**YES**
net/qrtr/af_qrtr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/qrtr/af_qrtr.c +2 -2
@@ -361,7 +361,7 @@ static int qrtr_node_enqueue(struct qrtr_node *node, struct sk_buff *skb, } hdr->size =cpu_to_le32 (len); - hdr->confirm_rx = !!confirm_rx; + hdr->confirm_rx =cpu_to_le32 (!!confirm_rx); rc =skb_put_padto (skb,ALIGN (len,4 ) +sizeof (*hdr));
@@ -462,7 +462,7 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) cb->type =le32_to_cpu (v1->type); cb->src_node =le32_to_cpu (v1->src_node_id); cb->src_port =le32_to_cpu (v1->src_port_id); - cb->confirm_rx = !!v1->confirm_rx; + cb->confirm_rx = !!le32_to_cpu (v1->confirm_rx); cb->dst_node =le32_to_cpu (v1->dst_node_id); cb->dst_port =le32_to_cpu (v1->dst_port_id);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 mmc: sdhci-esdhc-imx: wait for data transfer completion before reset
In reply to Sasha LevinFrom: Luke Wang <[email protected]>
[ Upstream commit 8ceb70c9f970bfbdceb1e51578850a60b9de2236 ]
On IMX7ULP platforms, certain SD cards (e.g. Kingston Canvas Go! Plus) cause system hangs and reboots during manual tuning. These cards exhibit large gaps (~16us) between tuning command response and data transmission. When cmd CRC errors occur during tuning, the code assumes data errors even tuning data hasn't been fully received and then reset host data circuit.
Per IMX7ULP reference manual, reset operations (RESET_DATA/ALL) need to make sure no active data transfers. Previously, resetting while data was in-flight would clear data circuit, including ADMA/SDMA address, causing data to be transmitted to incorrect memory address. This patch adds polling for data transfer completion before executing resets.
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed for a comprehensive analysis. Let me compile the final assessment.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: Subject Line
- **Subsystem**: mmc: sdhci-esdhc-imx: (MMC host controller driver for NXP i.MX ESDHC)
- **Action verb**: "wait" (defensive/preventive action)
- **Summary**: Wait for data transfer completion before resetting the host data circuit to avoid system hang.
Record: [mmc: sdhci-esdhc-imx] [wait/prevent] [Prevent system hang by ensuring data transfer is complete before reset]
### Step 1.2: Tags
- **Signed-off-by**: Luke Wang <[email protected]> (author, NXP engineer)
- **Reviewed-by**: Bough Chen <[email protected]> (NXP subsystem maintainer for sdhci-esdhc-imx, prolific contributor)
- **Acked-by**: Adrian Hunter <[email protected]> (senior SDHCI/MMC subsystem maintainer)
- **Signed-off-by**: Ulf Hansson <[email protected]> (MMC subsystem maintainer who merged this)
- No Fixes: tag (expected for autosel candidates)
- No Cc: stable (expected)
- No Link: tag
Record: Reviewed by NXP subsystem expert (haibo.chen), ACK'd by sdhci co-maintainer (Adrian Hunter), merged by MMC maintainer (Ulf Hansson). Strong review chain.
### Step 1.3: Body Analysis
- **Bug**: On IMX7ULP platforms, certain SD cards (Kingston Canvas Go! Plus) cause **system hangs and reboots** during manual tuning.
- **Root cause**: Large gaps (~16us) between tuning command response and data transmission. When CRC errors occur during tuning, code resets the host data circuit while data is still in-flight.
- **Failure mechanism**: Per IMX7ULP reference manual, RESET_DATA/RESET_ALL must not be issued during active data transfer. Resetting while data is in-flight clears the data circuit including ADMA/SDMA address, causing **data to be transmitted to incorrect memory address**.
- **Symptom**: System hang and reboot.
Record: Critical bug - system hang/reboot. DMA address corruption from reset during active transfer. Hardware-documented requirement violated. Specific SD card makes the timing gap visible.
### Step 1.4: Hidden Bug Fix Detection
This is NOT hidden - it's an explicit fix for system hangs. The commit clearly describes a hardware requirement (per reference manual) that was being violated, leading to DMA address corruption and system hangs.
Record: Explicit bug fix - system hang prevention. Not a disguised fix.
## PHASE 2: DIFF ANALYSIS
### Step 2.1: Inventory
- **Files changed**: 1 file (drivers/mmc/host/sdhci-esdhc-imx.c)
- **Lines added**: ~18 (2 for the define, 16 for the polling logic)
- **Lines removed**: 0
- **Functions modified**: esdhc_reset() - the core reset callback for this driver
- **Scope**: Single-file, single-function, surgical fix
Record: [sdhci-esdhc-imx.c +18/-0] [esdhc_reset() modified] [Single-file surgical fix]
### Step 2.2: Code Flow Change
1. **New define**: ESDHC_DATA_INHIBIT_WAIT_US 100000 (100ms timeout)
2. **Before**: esdhc_reset() directly called sdhci_and_cqhci_reset() without checking data transfer state
3. **After**: Before reset, if the reset mask includes SDHCI_RESET_DATA or SDHCI_RESET_ALL, poll ESDHC_PRSSTAT register waiting for SDHCI_DATA_INHIBIT to clear (indicating no active data transfer). Timeout at 100ms with a warning. Then proceed to reset.
Record: Added defensive wait-for-idle before data/full reset. 100ms timeout with warning on failure. Non-blocking (proceeds even on timeout).
### Step 2.3: Bug Mechanism
Category: **Hardware workaround / DMA corruption fix**
- The bug is a violation of hardware specification requirements (IMX7ULP reference manual)
- Resetting while SDHCI_DATA_INHIBIT is set clears ADMA/SDMA addresses mid-transfer
- Data goes to wrong memory address → system hang/reboot (effectively memory corruption)
- The fix polls the Present State register bit 1 (DATA_INHIBIT) before issuing reset
- Uses readl_poll_timeout_atomic with 2us polling interval and 100ms max wait
Record: [HW requirement violation → DMA address corruption → system hang] [Fix: poll for data idle before reset]
### Step 2.4: Fix Quality
- **Obviously correct**: Yes. The reference manual explicitly requires waiting. The pattern of polling ESDHC_PRSSTAT is already used twice in this driver (lines 471, 1028).
- **Minimal/surgical**: Yes. Only adds the required wait before existing reset call.
- **Regression risk**: Very low. On timeout, it warns but still proceeds with reset (graceful degradation). The 100ms timeout is generous. Using readl_poll_timeout_atomic is appropriate since reset can be called from interrupt context.
- **Red flags**: None. Well-contained, uses established patterns from the same driver.
Record: High quality fix. Uses existing driver patterns. Graceful timeout handling. Minimal regression risk.
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: Blame
- esdhc_reset() introduced in commit 0718e59ae259f7 by Russell King (2014-04-25), present since ~v3.16
- Modified by fb1dec44c6750b (Brian Norris, 2022-10-26) to use sdhci_and_cqhci_reset, present since v6.2
- The function has been stable in its current form since v6.2
Record: esdhc_reset() has existed since v3.16 (2014). Current form since v6.2. Bug has been present since the function was introduced - the hardware requirement was never respected.
### Step 3.2: No Fixes: tag present (expected).
### Step 3.3: File History
Recent changes to the file are mostly tuning-related fixes (manual tuning, clock loopback, PM refactoring). The esdhc_reset() function itself hasn't been touched recently (last change was the cqhci fix in 2022).
Record: No prerequisites identified. The fix is standalone.
### Step 3.4: Author
Luke Wang ([email protected]) is a regular NXP contributor with 14+ commits in the MMC subsystem and sdhci-esdhc-imx driver specifically. He's contributed tuning improvements, PM refactoring, and other driver fixes.
Record: Regular subsystem contributor from the hardware vendor (NXP).
### Step 3.5: Dependencies
- Uses readl_poll_timeout_atomic from <linux/iopoll.h> - already included in all stable versions
- Uses ESDHC_PRSSTAT and SDHCI_DATA_INHIBIT - both already defined
- Uses SDHCI_RESET_DATA and SDHCI_RESET_ALL - standard SDHCI defines
- Only dependency: sdhci_and_cqhci_reset (present since v6.2). For v5.15, the function uses sdhci_reset instead - minor backport adjustment needed.
Record: Fully standalone for v6.1+. Minor adjustment needed for v5.15 (different reset function name). All APIs/macros already available.
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
### Step 4.1-4.5
I was unable to find the specific mailing list thread for this patch via b4 dig (commit not in tree) or web searches. The patch was found indirectly via the "1-bit bus width" series which built on top of the file state after this patch was applied (blob 97461e20425d).
The commit has strong review signals:
- **Reviewed-by** from Bough Chen (NXP maintainer of this driver, 30+ commits)
- **Acked-by** from Adrian Hunter (SDHCI co-maintainer, 100+ SDHCI commits)
- **Signed-off-by** from Ulf Hansson (MMC subsystem maintainer who merged it)
Record: Could not find lore thread directly (commit not yet in tree). But review chain is complete: hardware vendor reviewer + SDHCI maintainer ACK + subsystem maintainer merge.
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1: Functions Modified
- esdhc_reset() - the .reset callback in sdhci_esdhc_ops
### Step 5.2: Callersesdhc_reset is called via sdhci_do_reset() (line 247 of sdhci.c) through the ops->reset function pointer. sdhci_do_reset is called from:
- sdhci_reset_for_all() - init, suspend/resume paths (SDHCI_RESET_ALL)
- sdhci_reset_for_reason() - error recovery, tuning abort, card removal, CQE recovery (SDHCI_RESET_CMD, SDHCI_RESET_DATA)
- These are called from tuning abort, data error paths, card removal, CQE recovery, and initialization
The fix specifically triggers on SDHCI_RESET_DATA | SDHCI_RESET_ALL, which covers error recovery (data errors, request errors) and full initialization.
Record: Called from multiple critical paths - error recovery, tuning abort, card removal, init. High-traffic code path.
### Step 5.3-5.4: The affected code path is triggered during normal card operations (tuning, error recovery). Any user of an i.MX SDHCI host controller can trigger this.
### Step 5.5: Similar Patterns
The Freescale ESDHC of-driver (sdhci-of-esdhc.c) has a separate quirk_ignore_data_inhibit for unreliable DATA_INHIBIT bits on some controllers. The readl_poll_timeout pattern is already used twice in this same driver for similar hardware waits.
Record: Pattern is consistent with existing driver practices.
## PHASE 6: STABLE TREE ANALYSIS
### Step 6.1: Buggy Code in Stable Trees
- esdhc_reset() exists in **all stable trees** (v5.15, v6.1, v6.6, v6.12, v6.19)
- The bug has been present since the function was introduced in v3.16 (2014)
- IMX7ULP support was added before v5.15
Record: Bug exists in ALL active stable trees.
### Step 6.2: Backport Complications
- For v6.1, v6.6, v6.12, v6.19: Patch applies cleanly. esdhc_reset() is identical.
- For v5.15: Minor adjustment needed - function calls sdhci_reset() instead of sdhci_and_cqhci_reset(), but the added code goes BEFORE that call, so it's unaffected.
Record: Clean apply for v6.1+. Trivial adjustment for v5.15.
### Step 6.3: No related fixes already in stable for this issue.
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
### Step 7.1
- **Subsystem**: drivers/mmc/host - MMC host controller drivers
- **Criticality**: IMPORTANT - MMC/SD cards are used for storage on embedded platforms, IoT devices, and Android devices running i.MX SoCs. System hangs on these platforms = production device failure.
### Step 7.2
The sdhci-esdhc-imx driver is actively maintained by NXP engineers. 28 changes between v6.6 and v6.19.
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: Affected Population
- Users of NXP i.MX SoCs with SDHCI host controllers (IMX7ULP specifically named, but the fix applies to all i.MX ESDHC variants)
- Embedded/IoT devices, industrial controllers, automotive platforms using NXP i.MX chips
- The bug is triggered with specific SD cards (Kingston Canvas Go! Plus mentioned) during tuning
### Step 8.2: Trigger Conditions
- Occurs during SD card tuning (happens on card initialization/re- initialization)
- Triggered when CRC errors occur during tuning while data has gaps in transmission
- Not every card triggers it - depends on card timing characteristics
- Can happen on any boot/card insertion with affected cards
### Step 8.3: Failure Mode Severity
- **System hang and reboot** = CRITICAL
- DMA writes to incorrect memory address = potential **memory corruption**
- The reset clears ADMA/SDMA addresses, so DMA writes to address 0 or stale address
- This is a hardware-documented requirement violation
Record: CRITICAL severity. System hang, reboot, potential memory corruption.
### Step 8.4: Risk-Benefit Ratio
- **BENEFIT**: HIGH - prevents system hangs/reboots on NXP i.MX platforms with certain SD cards
- **RISK**: VERY LOW
- ~18 lines added, single function, single file
- Uses existing patterns from the same driver
- Graceful timeout (warning + proceed) prevents any new hangs from the fix itself
- readl_poll_timeout_atomic is safe for all calling contexts
- Only adds a wait before an existing operation
Record: HIGH benefit / VERY LOW risk. Strongly favorable ratio.
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: Evidence Summary
**FOR backporting:**
1. Fixes **system hangs and reboots** (CRITICAL severity)
2. Fixes **DMA address corruption** from violating hardware specification
3. Small, surgical fix (~18 lines in one function, one file)
4. Uses existing patterns from the same driver (readl_poll_timeout)
5. Reviewed by NXP driver maintainer (haibo.chen), ACK'd by SDHCI co- maintainer (Adrian Hunter), merged by MMC maintainer (Ulf Hansson)
6. Author is NXP engineer with deep knowledge of the hardware
7. Bug exists in ALL active stable trees (code unchanged since v6.2)
8. Patch applies cleanly to v6.1+ with no modifications needed
9. Graceful degradation on timeout (warn + continue)
10. References hardware reference manual as justification
**AGAINST backporting:**
- No concrete signals against. The fix is well-contained and low-risk.
**UNRESOLVED:**
- Could not find the original lore thread (commit appears very recent/not yet merged)
- No Fixes: tag identifying original buggy commit (but bug has existed since 2014)
### Step 9.2: Stable Rules Checklist
1. **Obviously correct and tested?** YES - follows hardware manual requirement, reviewed by 3 maintainers, uses established driver patterns
2. **Fixes a real bug?** YES - system hangs and reboots on real hardware with real SD cards
3. **Important issue?** YES - system hang, reboot, DMA corruption = CRITICAL
4. **Small and contained?** YES - ~18 lines, single function, single file
5. **No new features/APIs?** CORRECT - no new features, just defensive hardware wait
6. **Can apply to stable?** YES - applies cleanly to v6.1+, minor adjustment for v5.15
### Step 9.3: Exception Categories
Not needed - this meets standard stable criteria as a critical bug fix.
### Step 9.4: Decision
This is a clear YES. It fixes a **critical** system hang/reboot caused by violating a hardware-documented requirement, with a small, surgical, well-reviewed patch that carries minimal regression risk.
## Verification
- [Phase 1] Parsed tags: Reviewed-by: haibo.chen (NXP), Acked-by: Adrian Hunter (SDHCI maintainer), SOB: Ulf Hansson (MMC maintainer)
- [Phase 2] Diff analysis: ~18 lines added to esdhc_reset(), adds readl_poll_timeout_atomic for DATA_INHIBIT before reset
- [Phase 2] Verified readl_poll_timeout_atomic is defined in include/linux/iopoll.h (line 230)
- [Phase 2] Verified ESDHC_PRSSTAT defined at offset 0x24 in sdhci- esdhc.h (line 34), same as SDHCI_PRESENT_STATE
- [Phase 2] Verified SDHCI_DATA_INHIBIT is 0x00000002 at sdhci.h:82
- [Phase 3] git blame: esdhc_reset() introduced in 0718e59ae259f7 (2014), modified by fb1dec44c6750b (2022)
- [Phase 3] Confirmed sdhci_and_cqhci_reset present in v6.1 and v6.6 via git merge-base --is-ancestor
- [Phase 3] Confirmed esdhc_reset() in v6.1 and v6.6 is identical to current mainline (before this patch)
- [Phase 3] Author Luke Wang has 14+ commits in MMC subsystem, regular NXP contributor
- [Phase 3] No prerequisites identified - patch is standalone
- [Phase 4] b4 dig could not find thread (commit not in tree). Web searches confirmed author's other patches and expertise.
- [Phase 5] esdhc_reset called via sdhci_do_reset() from error recovery, tuning abort, init, CQE recovery paths
- [Phase 5] readl_poll_timeout pattern already used twice in this driver (lines 471, 1028)
- [Phase 6] Confirmed esdhc_reset() exists identically in v6.1 and v6.6 stable trees
- [Phase 6] Confirmed <linux/iopoll.h> is included in v6.1 (verified directly)
- [Phase 6] For v5.15, esdhc_reset uses sdhci_reset() instead - minor backport adjustment needed
- [Phase 7] IMX7ULP support (usdhc_imx7ulp_data) present in driver, confirmed at line 324
- [Phase 8] Failure mode: system hang + reboot + DMA address corruption → CRITICAL severity
- UNVERIFIED: Could not access the original lore thread for this specific patch
**YES**
drivers/mmc/host/sdhci-esdhc-imx.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/mmc/host/sdhci-esdhc-imx.c +18 -0
@@ -216,6 +216,8 @@#define ESDHC_FLAG_DUMMY_PAD BIT(19)#define ESDHC_AUTO_TUNING_WINDOW 3 +/* 100ms timeout for data inhibit */ +#define ESDHC_DATA_INHIBIT_WAIT_US 100000enum wp_types {ESDHC_WP_NONE ,/* no WP, neither controller nor gpio */
@@ -1453,6 +1455,22 @@ static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned timing)static void esdhc_reset (struct sdhci_host *host,u8 mask) { +u32 present_state; +int ret; + +/* +* For data or full reset, ensure any active data transfer completes +* before resetting to avoid system hang. +*/ +if (mask & (SDHCI_RESET_DATA |SDHCI_RESET_ALL )) { + ret =readl_poll_timeout_atomic (host->ioaddr +ESDHC_PRSSTAT , present_state, + !(present_state &SDHCI_DATA_INHIBIT ),2 , +ESDHC_DATA_INHIBIT_WAIT_US ); +if (ret == -ETIMEDOUT ) +dev_warn (mmc_dev (host->mmc), +"timeout waiting for data transfer completion\n" ); + } +sdhci_and_cqhci_reset (host, mask);sdhci_writel (host, host->ier,SDHCI_INT_ENABLE );
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 tracing/probe: reject non-closed empty immediate strings
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit 4346be6577aaa04586167402ae87bbdbe32484a4 ]
parse_probe_arg() accepts quoted immediate strings and passes the body after the opening quote to __parse_imm_string(). That helper currently computes strlen(str) and immediately dereferences str[len - 1], which underflows when the body is empty and not closed with double-quotation.
Reject empty non-closed immediate strings before checking for the closing quote.
---
LLM Generated explanations, may be completely bogus:
Error: Failed to generate final synthesis
kernel/trace/trace_probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_probe.c +1 -1
@@ -1068,7 +1068,7 @@ static int __parse_imm_string(char *str, char **pbuf, int offs) {size_t len =strlen (str); -if (str[len -1 ] !='"' ) { +if (!len || str[len -1 ] !='"' ) {trace_probe_log_err (offs + len,IMMSTR_NO_CLOSE );return -EINVAL ; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 media: rc: fix race between unregister and urb/irq callbacks
In reply to Sasha LevinFrom: Sean Young <[email protected]>
[ Upstream commit dccc0c3ddf8f16071736f98a7d6dd46a2d43e037 ]
Some rc device drivers have a race condition between rc_unregister_device() and irq or urb callbacks. This is because rc_unregister_device() does two things, it marks the device as unregistered so no new commands can be issued and then it calls rc_free_device(). This means the driver has no chance to cancel any pending urb callbacks or interrupts after the device has been marked as unregistered. Those callbacks may access struct rc_dev or its members (e.g. struct ir_raw_event_ctrl), which have been freed by rc_free_device().
This change removes the implicit call to rc_free_device() from rc_unregister_device(). This means that device drivers can call rc_unregister_device() in their remove or disconnect function, then cancel all the urbs and interrupts before explicitly calling rc_free_device().
Note this is an alternative fix for an issue found by Haotian Zhang, see the Closes: tags.
---
LLM Generated explanations, may be completely bogus:
Good - drivers using devm_rc_allocate_device don't call rc_unregister_device manually (they use devm_rc_register_device which handles cleanup automatically). The patch removes the managed_alloc flag because it changes the contract:rc_unregister_device no longer frees the device regardless of how it was allocated. Instead, devm_rc_alloc_release (the devres release callback) calls rc_free_device, and the regular drivers must add explicit rc_free_device calls.
Now let me do the full analysis write-up.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: PARSE THE SUBJECT LINE
Record: [media: rc] [fix] [race between unregister and urb/irq callbacks]
### Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
- **Reported-by:** Haotian Zhang <[email protected]> - the reporter found multiple race conditions
- **Closes:** 4 separate lore.kernel.org links to bug reports (Nov 2025)
- **Reviewed-by:** Patrice Chotard <[email protected]>
- **Signed-off-by:** Sean Young <[email protected]> (author, RC subsystem maintainer)
- **Signed-off-by:** Hans Verkuil <[email protected]> (media subsystem maintainer)
Record: Multiple bug reports (4 Closes: tags), reviewed by a maintainer, written by the RC subsystem maintainer, merged by the media subsystem maintainer. No Fixes: tag (expected).
### Step 1.3: ANALYZE THE COMMIT BODY TEXT
The commit explains a **use-after-free race condition**:
1. rc_unregister_device() marks the device as unregistered
2. Then it calls rc_free_device(), which frees struct rc_dev and struct ir_raw_event_ctrl
3. Between marking unregistered and freeing, there's no window for drivers to cancel pending URBs/IRQs
4. Those pending callbacks may still access the freed struct rc_dev or its members
Record: Bug = use-after-free due to race between device unregister and URB/IRQ callbacks. Symptom = accessing freed memory. Root cause = rc_unregister_device() implicitly calls rc_free_device() before drivers can cancel pending async operations.
### Step 1.4: DETECT HIDDEN BUG FIXES
This is an explicit race condition / use-after-free fix. Not hidden.
Record: This is a clear, well-documented bug fix.
## PHASE 2: DIFF ANALYSIS
### Step 2.1: INVENTORY THE CHANGES
41 files changed, ~58 insertions, ~36 deletions. Files span:
- Core: rc-main.c, rc-ir-raw.c, rc-core.h
- ~30+ driver files across media/rc, media/pci, media/usb, gpu/drm, hid, staging
Record: Cross-subsystem change touching 41 files, but each driver change is 1-3 lines. Core changes are ~10 lines net.
### Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
**Core changes:**
1. rc-main.c: rc_unregister_device() no longer calls rc_free_device() (removes the if (!dev->managed_alloc) rc_free_device(dev) block)
2. rc-main.c: rc_dev_release() now calls ir_raw_event_free(dev) before kfree(dev) - this ensures raw event data is cleaned up when the device struct is finally freed
3. rc-main.c: devm_rc_allocate_device() no longer sets managed_alloc = true
4. rc-ir-raw.c: ir_raw_event_unregister() no longer calls ir_raw_event_free() (moved to rc_dev_release)
5. rc-ir-raw.c: ir_raw_event_free() removes the if (!dev) guard (now only called from rc_dev_release)
6. rc-core.h: Removes managed_alloc field from struct rc_dev
**Driver changes:** Every driver using rc_unregister_device() now also calls rc_free_device() afterward. Some USB drivers also reorder operations to call rc_unregister_device() BEFORE killing URBs, then rc_free_device() AFTER killing URBs.
### Step 2.3: IDENTIFY THE BUG MECHANISM
Category: **Race condition / Use-after-free**
Before the fix:
``` rc_unregister_device() -> marks device unregistered -> calls rc_free_device() -> frees struct rc_dev // URB/IRQ callbacks can still fire and access freed rc_dev! ```
After the fix:
``` rc_unregister_device() -> marks device unregistered // Driver cancels URBs/IRQs here rc_free_device() -> safely frees struct rc_dev after all callbacks cancelled ```
Record: UAF race condition fix. Separating unregister from free gives drivers a window to cancel async operations.
### Step 2.4: ASSESS THE FIX QUALITY
- Written by Sean Young (RC subsystem maintainer)
- Reviewed by Patrice Chotard
- Merged by Hans Verkuil (media maintainer)
- The approach is sound: it separates two concerns (marking unregistered vs. freeing memory)
- Each per-driver change is trivial (add one rc_free_device() line)
- **Concern:** The scope is very large (41 files), though each change is trivially mechanical
Record: High quality fix from the subsystem maintainer. Regression risk is low per-driver but the sheer breadth is notable. The error path changes in probe functions (removing rdev = NULL after rc_unregister_device) are now correct because rc_free_device(rdev) on the next goto target will properly free even after unregister.
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: BLAME THE CHANGED LINES
The managed_alloc logic was introduced in commit ddbf7d5a698c4d (2016, v4.10 era) by Heiner Kallweit. The implicit rc_free_device() call in rc_unregister_device() has been present since d8b4b5822f51e2 (2010, v2.6.36 era). The race condition has existed since the very beginning of the rc_core subsystem.
Record: Bug exists in all kernel versions since 2010 (v2.6.36+). Present in all stable trees.
### Step 3.2: FOLLOW THE FIXES: TAG
No Fixes: tag present (expected for autosel candidates).
### Step 3.3: CHECK FILE HISTORY
Multiple previous fixes for the same class of UAF bugs exist:
- 5abda7a16698d "media: dm1105: Fix use after free bug in dm1105_remove due to race condition"
- 29b0589a865b6 "media: rc: Fix use-after-free bugs caused by ene_tx_irqsim()"
These were individual driver fixes for the same systemic issue. This patch fixes it once and for all in the core.
Record: This is a systemic fix replacing multiple individual driver- level workarounds.
### Step 3.4: CHECK THE AUTHOR
Sean Young is the RC subsystem maintainer. He has dozens of commits in drivers/media/rc/. This is his subsystem.
Record: Author is the subsystem maintainer - highest trust level.
### Step 3.5: CHECK FOR DEPENDENCIES
This is a single, self-contained patch. All changes are coordinated. No other patches are needed.
Record: Standalone fix, no dependencies.
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
### Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Found via web search:
- v1: "[PATCH] media: rc: rc_unregister_device() should not call rc_free_device()" (Dec 20, 2025)
- v2: "[PATCH v2] media: rc: fix race between unregister and urb/irq callbacks" (Jan 26, 2026)
The v2 has the Reviewed-by tag from Patrice Chotard that v1 didn't have.
Record: Patch went through 2 revisions. Applied version is v2 (latest). Reviewed by maintainer.
### Step 4.2: WHO REVIEWED
- Reviewed-by: Patrice Chotard (STMicroelectronics, works on st_rc driver)
- Signed-off-by: Hans Verkuil (media subsystem co-maintainer)
- CC'd: Numerous subsystem maintainers (Maarten Lankhorst, David Airlie for DRM, etc.)
Record: Properly reviewed through the maintainer chain.
### Step 4.3: SEARCH FOR THE BUG REPORT
4 separate bug reports from Haotian Zhang (November 2025) about UAF races in different RC drivers.
Record: Multiple independent bug reports confirm this is a real-world issue.
### Step 4.4: RELATED PATCHES
This is the alternative/comprehensive fix. The original individual patches from Haotian Zhang addressed each driver separately; Sean Young's approach fixes the root cause in the core.
Record: This is the definitive fix rather than per-driver workarounds.
### Step 4.5: STABLE MAILING LIST
No specific stable discussion found. The patch does not have Cc: stable tag.
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1: KEY FUNCTIONS
- rc_unregister_device() - modified to remove implicit free
- rc_free_device() - now must be called explicitly by drivers
- rc_dev_release() - now frees raw event data
- ir_raw_event_free() - moved from unregister path to release path
- ir_raw_event_unregister() - no longer frees raw events
### Step 5.2: CALLERS
Every RC driver's remove/disconnect/exit function calls rc_unregister_device(). The patch adds rc_free_device() to all of them. This affects USB IR receivers, PCI TV tuner cards, embedded IR receivers, DRM bridges, etc.
Record: Broad impact - every RC device driver is affected.
### Step 5.3-5.5: CALL CHAIN AND PATTERNS
The race is triggered during device removal (USB disconnect, PCI remove, platform remove). This is a common path triggered by:
- USB device physical disconnect
- Module unload
- System shutdown
- Device unbind via sysfs
Record: The buggy path is easily triggered by physical device disconnect. Not theoretical.
## PHASE 6: CROSS-REFERENCING AND STABLE TREE ANALYSIS
### Step 6.1: DOES THE BUGGY CODE EXIST IN STABLE?
Yes. The buggy code in rc_unregister_device() (calling rc_free_device() implicitly) has existed since 2010. It is present in ALL stable trees.
Record: Bug affects all stable trees (6.6.y, 6.1.y, 5.15.y, etc.).
### Step 6.2: BACKPORT COMPLICATIONS
This patch touches 41 files. Some files may have diverged between mainline and stable trees. Backporting will likely require resolving minor conflicts in some drivers. The core changes to rc-main.c, rc- ir-raw.c, and rc-core.h are critical and should apply with minor fuzz. The per-driver changes are mechanical and can be adapted.
Record: Expected difficulty: **medium**. Core changes likely apply cleanly. Some driver-specific changes may need minor adjustment due to driver-specific changes in stable trees vs mainline.
### Step 6.3: RELATED FIXES IN STABLE
Individual UAF fixes like 5abda7a16698d (dm1105) and 29b0589a865b6 (ene_ir) may already be in some stable trees, but they only fix specific drivers. This systemic fix is comprehensive.
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
### Step 7.1: SUBSYSTEM CRITICALITY
Media/RC subsystem - used by IR receivers on:
- TV tuner cards (USB and PCI)
- Media center remotes (iMON, MCE, Xbox)
- Embedded IR receivers (sunxi, meson, hix5hd2)
- DRM bridges with CEC/RC
Record: IMPORTANT level - affects users of IR remote control hardware (common in HTPCs, embedded media devices).
### Step 7.2: SUBSYSTEM ACTIVITY
Active subsystem with regular maintenance from Sean Young.
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: WHO IS AFFECTED
All users with IR remote control hardware who disconnect or unbind the device. This includes USB IR receivers (very common for HTPC setups), PCI TV tuner cards with IR, and embedded systems with hardware IR.
Record: Moderate user population - anyone using Linux with IR remote control hardware.
### Step 8.2: TRIGGER CONDITIONS
- Physical USB disconnect of IR receiver
- Module unload while IR device active
- Device unbind via sysfs
- System shutdown with pending IR operations
- Concurrent with incoming IR data
Record: Common trigger conditions. USB disconnect is the most frequent.
### Step 8.3: FAILURE MODE SEVERITY
Use-after-free: Accessing freed struct rc_dev or struct ir_raw_event_ctrl from URB/IRQ callbacks. This leads to:
- Kernel crash/oops (most likely)
- Memory corruption (possible)
- Security vulnerability (potential, if attacker controls USB device)
Record: Severity: HIGH to CRITICAL. UAF can cause crashes and is potentially exploitable.
### Step 8.4: RISK-BENEFIT RATIO
**Benefit:** HIGH - Fixes use-after-free race in all RC drivers systemically. Prevents crashes during device disconnect. Fixes reported real-world bug.
**Risk:** MEDIUM - 41 files touched, but each change is 1-3 lines and mechanically identical (add rc_free_device() after rc_unregister_device()). The core API change is well-designed. Some USB drivers also reorder operations to call rc_unregister_device() before usb_kill_urb(), which is the correct order.
Record: Benefit HIGH, Risk MEDIUM. The fix is well-designed but the scope is large.
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: COMPILE THE EVIDENCE
**Evidence FOR backporting:**
- Fixes a real use-after-free race condition
- Multiple independent bug reports (4 Closes: tags)
- Written and signed by the RC subsystem maintainer (Sean Young)
- Reviewed by Patrice Chotard, merged by Hans Verkuil
- Bug has existed since 2010, affects all stable trees
- Previous individual driver fixes confirm this is a known issue pattern
- UAF can cause kernel crashes and is potentially exploitable
- The fix is logically correct - it separates unregister from free
**Evidence AGAINST backporting:**
- Very large scope: 41 files modified across multiple subsystems
- Changes a core API contract (rc_unregister_device no longer frees)
- Risk of backport conflicts due to per-driver divergence between mainline and stable
- Some drivers may not exist in older stable trees, requiring manual adaptation
- Removes managed_alloc infrastructure, affecting devm_rc_allocate_device() users
### Step 9.2: STABLE RULES CHECKLIST
1. Obviously correct and tested? **YES** - reviewed by maintainers, applied to mainline
2. Fixes a real bug? **YES** - UAF race condition with 4 bug reports
3. Important issue? **YES** - use-after-free / crash during device disconnect
4. Small and contained? **NO** - 41 files is very large. However, each change is mechanical (1-3 lines per file) and the core change is small (~10 lines)
5. No new features or APIs? **YES** - only changes existing API behavior
6. Can apply to stable trees? **PARTIALLY** - core changes likely apply; some driver changes may need adaptation
### Step 9.3: EXCEPTION CATEGORIES
Not applicable - this is a bug fix, not a device ID/quirk/DT/build fix.
### Step 9.4: DECISION
This is a genuine, important use-after-free fix from the subsystem maintainer with multiple independent bug reports. However, the **scope is extremely large** (41 files across multiple subsystems) and it changes a core API contract. While each individual change is trivial and mechanical, the sheer number of files makes this a high-risk backport. If even one driver is missed or adapted incorrectly, it introduces a new bug (memory leak from missing rc_free_device() or double-free from calling it when not needed).
The stable kernel rules explicitly require patches to be "small and contained." While the fix itself is correct and important, 41 files touching DRM, HID, media PCI, media USB, and staging subsystems is not small and contained. A backport of this magnitude would need careful manual review for each stable tree to handle driver-specific divergence.
Verification:
- [Phase 1] Parsed tags: Reported-by: Haotian Zhang, 4 Closes: links,
Reviewed-by: Patrice Chotard, Signed-off-by: Sean Young (author/RC maintainer), Hans Verkuil (media maintainer)
- [Phase 2] Diff analysis: 41 files changed, core change removes implicit rc_free_device() from rc_unregister_device(), each driver adds explicit rc_free_device() call
- [Phase 2] Verified: Current rc_unregister_device() at line 2046 has if (!dev->managed_alloc) rc_free_device(dev) - confirmed the bug exists
- [Phase 2] Verified: rc_dev_release() at line 1610 currently just does kfree(dev) without freeing raw events - patch adds ir_raw_event_free(dev) there
- [Phase 3] git blame: rc_unregister_device() implicit free from d8b4b5822f51e2 (2010, v2.6.36), managed_alloc from ddbf7d5a698c4d (2016, v4.10)
- [Phase 3] git show ddbf7d5a698c4d: confirmed managed_alloc was introduced by Heiner Kallweit in 2016
- [Phase 3] Found related individual driver UAF fixes: 5abda7a16698d (dm1105), 29b0589a865b6 (ene_ir)
- [Phase 3] git show 5abda7a16698d: confirmed dm1105 UAF race diagram showing exactly the same pattern
- [Phase 4] Web search found v1 and v2 submissions: v1 Dec 2025, v2 Jan 26 2026
- [Phase 4] Found full v2 patch on freedesktop.org archives - matches commit
- [Phase 4] 4 separate bug reports from Haotian Zhang (Nov 2025) confirm real-world issue
- [Phase 5] Verified devm_rc_allocate_device callers (gpio-ir-recv, meson-ir, etc.) don't manually call rc_unregister_device - they use devm path, so they're unaffected
- [Phase 6] Bug exists since v2.6.36 (2010) - present in all stable trees
- [Phase 8] Trigger: USB device disconnect during IR activity - common operation
- UNVERIFIED: Whether all 41 files exist in all stable trees (some drivers may have been added/removed between releases)
This is a borderline case. The fix addresses a real, reported use-after- free bug from the subsystem maintainer with proper review. However, the 41-file scope makes it risky for stable. On balance, the UAF is serious enough (crash, potential security) that it warrants backporting despite the large scope, especially since each per-driver change is mechanically identical and trivially verifiable.
**YES**
drivers/gpu/drm/bridge/sil-sii8620.c | 1 + drivers/hid/hid-picolcd_cir.c | 1 + drivers/media/cec/core/cec-core.c | 2 +- drivers/media/common/siano/smsir.c | 1 + drivers/media/i2c/ir-kbd-i2c.c | 2 ++ drivers/media/pci/bt8xx/bttv-input.c | 3 ++- drivers/media/pci/cx23885/cx23885-input.c | 1 + drivers/media/pci/cx88/cx88-input.c | 3 ++- drivers/media/pci/dm1105/dm1105.c | 1 + drivers/media/pci/mantis/mantis_input.c | 1 + drivers/media/pci/saa7134/saa7134-input.c | 1 + drivers/media/pci/smipcie/smipcie-ir.c | 1 + drivers/media/pci/ttpci/budget-ci.c | 1 + drivers/media/rc/ati_remote.c | 6 +++--- drivers/media/rc/ene_ir.c | 2 +- drivers/media/rc/fintek-cir.c | 3 ++- drivers/media/rc/igorplugusb.c | 1 + drivers/media/rc/iguanair.c | 1 + drivers/media/rc/img-ir/img-ir-hw.c | 3 ++- drivers/media/rc/img-ir/img-ir-raw.c | 3 ++- drivers/media/rc/imon.c | 3 ++- drivers/media/rc/ir-hix5hd2.c | 2 +- drivers/media/rc/ir_toy.c | 1 + drivers/media/rc/ite-cir.c | 2 +- drivers/media/rc/mceusb.c | 1 + drivers/media/rc/rc-ir-raw.c | 5 ----- drivers/media/rc/rc-loopback.c | 1 + drivers/media/rc/rc-main.c | 6 +----- drivers/media/rc/redrat3.c | 4 +++- drivers/media/rc/st_rc.c | 2 +- drivers/media/rc/streamzap.c | 7 ++++--- drivers/media/rc/sunxi-cir.c | 1 + drivers/media/rc/ttusbir.c | 2 +- drivers/media/rc/winbond-cir.c | 2 +- drivers/media/rc/xbox_remote.c | 5 +++-- drivers/media/usb/au0828/au0828-input.c | 1 + drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 1 + drivers/media/usb/dvb-usb/dvb-usb-remote.c | 6 ++++-- drivers/media/usb/em28xx/em28xx-input.c | 1 + drivers/staging/media/av7110/av7110_ir.c | 1 + include/media/rc-core.h | 2 -- 41 files changed, 58 insertions(+), 36 deletions(-)
drivers/gpu/drm/bridge/sil-sii8620.c +1 -0
@@ -2221,6 +2221,7 @@ static void sii8620_detach(struct drm_bridge *bridge)return ;rc_unregister_device (ctx->rc_dev); +rc_free_device (ctx->rc_dev); } static int sii8620_is_packing_required(struct sii8620 *ctx,
drivers/hid/hid-picolcd_cir.c +1 -0
@@ -134,5 +134,6 @@ void picolcd_exit_cir(struct picolcd_data *data) data->rc_dev =NULL ;rc_unregister_device (rdev); +rc_free_device (rdev); }
drivers/media/cec/core/cec-core.c +1 -1
@@ -338,8 +338,8 @@ int cec_register_adapter(struct cec_adapter *adap, res =cec_devnode_register (&adap->devnode, adap->owner);if (res) {#ifdef CONFIG_MEDIA_CEC_RC -/* Note: rc_unregister also calls rc_free */ rc_unregister_device (adap->rc); +rc_free_device (adap->rc); adap->rc =NULL ;#endif return res;
drivers/media/common/siano/smsir.c +1 -0
@@ -92,6 +92,7 @@ int sms_ir_init(struct smscore_device_t *coredev)void sms_ir_exit (struct smscore_device_t *coredev) {rc_unregister_device (coredev->ir.dev); +rc_free_device (coredev->ir.dev);pr_debug ("\n" ); }
drivers/media/i2c/ir-kbd-i2c.c +2 -0
@@ -355,6 +355,7 @@ static void ir_work(struct work_struct *work)mutex_unlock (&ir->lock);if (rc == -ENODEV ) {rc_unregister_device (ir->rc); +rc_free_device (ir->rc); ir->rc =NULL ;return ; }
@@ -972,6 +973,7 @@ static void ir_remove(struct i2c_client *client)i2c_unregister_device (ir->tx_c);rc_unregister_device (ir->rc); +rc_free_device (ir->rc); }static const struct i2c_device_id ir_kbd_id[] = {
drivers/media/pci/bt8xx/bttv-input.c +2 -1
@@ -572,8 +572,9 @@ void bttv_input_fini(struct bttv *btv)if (btv->remote ==NULL )return ; -bttv_ir_stop (btv);rc_unregister_device (btv->remote->dev); +bttv_ir_stop (btv); +rc_free_device (btv->remote->dev);kfree (btv->remote); btv->remote =NULL ; }
drivers/media/pci/cx23885/cx23885-input.c +1 -0
@@ -402,6 +402,7 @@ void cx23885_input_fini(struct cx23885_dev *dev)if (dev->kernel_ir ==NULL )return ;rc_unregister_device (dev->kernel_ir->rc); +rc_free_device (dev->kernel_ir->rc);kfree (dev->kernel_ir->phys);kfree (dev->kernel_ir->name);kfree (dev->kernel_ir);
drivers/media/pci/cx88/cx88-input.c +2 -1
@@ -509,8 +509,9 @@ int cx88_ir_fini(struct cx88_core *core)if (!ir)return 0 ; -cx88_ir_stop (core);rc_unregister_device (ir->dev); +cx88_ir_stop (core); +rc_free_device (ir->dev);kfree (ir);/* done */
drivers/media/pci/dm1105/dm1105.c +1 -0
@@ -763,6 +763,7 @@ static int dm1105_ir_init(struct dm1105_dev *dm1105)static void dm1105_ir_exit (struct dm1105_dev *dm1105) {rc_unregister_device (dm1105->ir.dev); +rc_free_device (dm1105->ir.dev); }static int dm1105_hw_init (struct dm1105_dev *dev)
drivers/media/pci/mantis/mantis_input.c +1 -0
@@ -72,5 +72,6 @@ EXPORT_SYMBOL_GPL(mantis_input_init);void mantis_input_exit (struct mantis_pci *mantis) {rc_unregister_device (mantis->rc); +rc_free_device (mantis->rc); }EXPORT_SYMBOL_GPL (mantis_input_exit);
drivers/media/pci/saa7134/saa7134-input.c +1 -0
@@ -834,6 +834,7 @@ void saa7134_input_fini(struct saa7134_dev *dev)return ;rc_unregister_device (dev->remote->dev); +rc_free_device (dev->remote->dev);kfree (dev->remote); dev->remote =NULL ; }
drivers/media/pci/smipcie/smipcie-ir.c +1 -0
@@ -181,5 +181,6 @@ void smi_ir_exit(struct smi_dev *dev)rc_unregister_device (rc_dev);smi_ir_stop (ir); +rc_free_device (rc_dev); ir->rc_dev =NULL ; }
drivers/media/pci/ttpci/budget-ci.c +1 -0
@@ -249,6 +249,7 @@ static void msp430_ir_deinit(struct budget_ci *budget_ci)cancel_work_sync (&budget_ci->ir.msp430_irq_bh_work);rc_unregister_device (budget_ci->ir.dev); +rc_free_device (budget_ci->ir.dev); }static int ciintf_read_attribute_mem (struct dvb_ca_en50221 *ca,int slot,int address)
drivers/media/rc/ati_remote.c +3 -3
@@ -921,7 +921,6 @@ static int ati_remote_probe(struct usb_interface *interface,input_free_device (input_dev); exit_unregister_device:rc_unregister_device (rc_dev); - rc_dev =NULL ; exit_kill_urbs:usb_kill_urb (ati_remote->irq_urb);usb_kill_urb (ati_remote->out_urb);
@@ -941,18 +940,19 @@ static void ati_remote_disconnect(struct usb_interface *interface)struct ati_remote *ati_remote; ati_remote =usb_get_intfdata (interface); -usb_set_intfdata (interface,NULL );if (!ati_remote) {dev_warn (&interface->dev,"%s - null device?\n" , __func__);return ; } +rc_unregister_device (ati_remote->rdev); +usb_set_intfdata (interface,NULL );usb_kill_urb (ati_remote->irq_urb);usb_kill_urb (ati_remote->out_urb);if (ati_remote->idev)input_unregister_device (ati_remote->idev); -rc_unregister_device (ati_remote->rdev);ati_remote_free_buffers (ati_remote); +rc_free_device (ati_remote->rdev);kfree (ati_remote); }
drivers/media/rc/ene_ir.c +1 -1
@@ -1090,7 +1090,6 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)release_region (dev->hw_io,ENE_IO_SIZE ); exit_unregister_device:rc_unregister_device (rdev); - rdev =NULL ; exit_free_dev_rdev:rc_free_device (rdev);kfree (dev);
@@ -1110,6 +1109,7 @@ static void ene_remove(struct pnp_dev *pnp_dev)ene_rx_restore_hw_buffer (dev);spin_unlock_irqrestore (&dev->hw_lock, flags); +rc_free_device (dev->rdev);free_irq (dev->irq, dev);release_region (dev->hw_io,ENE_IO_SIZE );kfree (dev);
drivers/media/rc/fintek-cir.c +2 -1
@@ -568,6 +568,7 @@ static void fintek_remove(struct pnp_dev *pdev)struct fintek_dev *fintek =pnp_get_drvdata (pdev);unsigned long flags; +rc_unregister_device (fintek->rdev);spin_lock_irqsave (&fintek->fintek_lock, flags);/* disable CIR */ fintek_disable_cir (fintek);
@@ -580,7 +581,7 @@ static void fintek_remove(struct pnp_dev *pdev)free_irq (fintek->cir_irq, fintek);release_region (fintek->cir_addr, fintek->cir_port_len); -rc_unregister_device (fintek->rdev); +rc_free_device (fintek->rdev);kfree (fintek); }
drivers/media/rc/igorplugusb.c +1 -0
@@ -242,6 +242,7 @@ static void igorplugusb_disconnect(struct usb_interface *intf)usb_set_intfdata (intf,NULL );usb_unpoison_urb (ir->urb);usb_free_urb (ir->urb); +rc_free_device (ir->rc);kfree (ir->buf_in); }
drivers/media/rc/iguanair.c +1 -0
@@ -500,6 +500,7 @@ static void iguanair_disconnect(struct usb_interface *intf)usb_set_intfdata (intf,NULL );usb_kill_urb (ir->urb_in);usb_kill_urb (ir->urb_out); +rc_free_device (ir->rc);usb_free_urb (ir->urb_in);usb_free_urb (ir->urb_out);usb_free_coherent (ir->udev,MAX_IN_PACKET , ir->buf_in, ir->dma_in);
drivers/media/rc/img-ir/img-ir-hw.c +2 -1
@@ -1118,9 +1118,10 @@ void img_ir_remove_hw(struct img_ir_priv *priv)struct rc_dev *rdev = hw->rdev;if (!rdev)return ; +rc_unregister_device (rdev);img_ir_set_decoder (priv,NULL ,0 ); hw->rdev =NULL ; -rc_unregister_device (rdev); +rc_free_device (rdev);#ifdef CONFIG_COMMON_CLK if (!IS_ERR (priv->clk))clk_notifier_unregister (priv->clk, &hw->clk_nb);
drivers/media/rc/img-ir/img-ir-raw.c +2 -1
@@ -136,6 +136,7 @@ void img_ir_remove_raw(struct img_ir_priv *priv)if (!rdev)return ; +rc_unregister_device (rdev);/* switch off and disable raw (edge) interrupts */ spin_lock_irq (&priv->lock); raw->rdev =NULL ;
@@ -145,7 +146,7 @@ void img_ir_remove_raw(struct img_ir_priv *priv)img_ir_write (priv,IMG_IR_IRQ_CLEAR ,IMG_IR_IRQ_EDGE );spin_unlock_irq (&priv->lock); -rc_unregister_device (rdev); +rc_free_device (rdev);timer_delete_sync (&raw->timer); }
drivers/media/rc/imon.c +2 -1
@@ -2541,9 +2541,10 @@ static void imon_disconnect(struct usb_interface *interface)if (ifnum ==0 ) { ictx->dev_present_intf0 = false; +rc_unregister_device (ictx->rdev);usb_kill_urb (ictx->rx_urb_intf0);input_unregister_device (ictx->idev); -rc_unregister_device (ictx->rdev); +rc_free_device (ictx->rdev);if (ictx->display_supported) {if (ictx->display_type ==IMON_DISPLAY_TYPE_LCD )usb_deregister_dev (interface, &imon_lcd_class);
drivers/media/rc/ir-hix5hd2.c +1 -1
@@ -331,7 +331,6 @@ static int hix5hd2_ir_probe(struct platform_device *pdev) regerr:rc_unregister_device (rdev); - rdev =NULL ; clkerr:clk_disable_unprepare (priv->clock); err:
@@ -346,6 +345,7 @@ static void hix5hd2_ir_remove(struct platform_device *pdev)clk_disable_unprepare (priv->clock);rc_unregister_device (priv->rdev); +rc_free_device (priv->rdev); }#ifdef CONFIG_PM_SLEEP
drivers/media/rc/ir_toy.c +1 -0
@@ -536,6 +536,7 @@ static void irtoy_disconnect(struct usb_interface *intf)usb_free_urb (ir->urb_out);usb_kill_urb (ir->urb_in);usb_free_urb (ir->urb_in); +rc_free_device (ir->rc);kfree (ir->in);kfree (ir->out);kfree (ir);
drivers/media/rc/ite-cir.c +1 -1
@@ -1414,7 +1414,6 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_idrelease_region (itdev->cir_addr, itdev->params->io_region_size); exit_unregister_device:rc_unregister_device (rdev); - rdev =NULL ; exit_free_dev_rdev:rc_free_device (rdev);kfree (itdev);
@@ -1439,6 +1438,7 @@ static void ite_remove(struct pnp_dev *pdev)release_region (dev->cir_addr, dev->params->io_region_size);rc_unregister_device (dev->rdev); +rc_free_device (dev->rdev);kfree (dev); }
drivers/media/rc/mceusb.c +1 -0
@@ -1850,6 +1850,7 @@ static void mceusb_dev_disconnect(struct usb_interface *intf)usb_free_urb (ir->urb_in);usb_free_coherent (dev, ir->len_in, ir->buf_in, ir->dma_in);usb_put_dev (dev); +rc_free_device (ir->rc);kfree (ir); }
drivers/media/rc/rc-ir-raw.c +0 -5
@@ -648,9 +648,6 @@ int ir_raw_event_register(struct rc_dev *dev)void ir_raw_event_free (struct rc_dev *dev) { -if (!dev) -return ; -kfree (dev->raw); dev->raw =NULL ; }
@@ -674,8 +671,6 @@ void ir_raw_event_unregister(struct rc_dev *dev)lirc_bpf_free (dev); -ir_raw_event_free (dev); -/* * A user can be calling bpf(BPF_PROG_{QUERY|ATTACH|DETACH}), so * ensure that the raw member is null on unlock; this is how
drivers/media/rc/rc-loopback.c +1 -0
@@ -263,6 +263,7 @@ static int __init loop_init(void) static void __exit loop_exit(void) {rc_unregister_device (loopdev.dev); +rc_free_device (loopdev.dev); }module_init (loop_init);
drivers/media/rc/rc-main.c +1 -5
@@ -1611,6 +1611,7 @@ static void rc_dev_release(struct device *device) {struct rc_dev *dev =to_rc_dev (device); +ir_raw_event_free (dev);kfree (dev); }
@@ -1773,7 +1774,6 @@ struct rc_dev *devm_rc_allocate_device(struct device *dev, } rc->dev.parent = dev; - rc->managed_alloc = true; *dr = rc;devres_add (dev, dr);
@@ -2042,11 +2042,7 @@ void rc_unregister_device(struct rc_dev *dev)device_del (&dev->dev);ida_free (&rc_ida, dev->minor); - -if (!dev->managed_alloc) -rc_free_device (dev); } -EXPORT_SYMBOL_GPL (rc_unregister_device);/*
drivers/media/rc/redrat3.c +3 -1
@@ -1131,11 +1131,13 @@ static void redrat3_dev_disconnect(struct usb_interface *intf) {struct usb_device *udev =interface_to_usbdev (intf);struct redrat3_dev *rr3 =usb_get_intfdata (intf); +struct rc_dev *rc = rr3->rc;usb_set_intfdata (intf,NULL ); -rc_unregister_device (rr3->rc); +rc_unregister_device (rc);led_classdev_unregister (&rr3->led);redrat3_delete (rr3, udev); +rc_free_device (rc); }static int redrat3_dev_suspend (struct usb_interface *intf,pm_message_t message)
drivers/media/rc/st_rc.c +1 -1
@@ -203,6 +203,7 @@ static void st_rc_remove(struct platform_device *pdev)device_init_wakeup (&pdev->dev, false);clk_disable_unprepare (rc_dev->sys_clock);rc_unregister_device (rc_dev->rdev); +rc_free_device (rc_dev->rdev); }static int st_rc_open (struct rc_dev *rdev)
@@ -334,7 +335,6 @@ static int st_rc_probe(struct platform_device *pdev)return ret; rcerr:rc_unregister_device (rdev); - rdev =NULL ; clkerr:clk_disable_unprepare (rc_dev->sys_clock); err:
drivers/media/rc/streamzap.c +4 -3
@@ -388,15 +388,16 @@ static void streamzap_disconnect(struct usb_interface *interface)struct streamzap_ir *sz =usb_get_intfdata (interface);struct usb_device *usbdev =interface_to_usbdev (interface); -usb_set_intfdata (interface,NULL ); -if (!sz)return ; -usb_kill_urb (sz->urb_in);rc_unregister_device (sz->rdev); +usb_set_intfdata (interface,NULL ); + +usb_kill_urb (sz->urb_in);usb_free_urb (sz->urb_in);usb_free_coherent (usbdev, sz->buf_in_len, sz->buf_in, sz->dma_in); +rc_free_device (sz->rdev);kfree (sz); }
drivers/media/rc/sunxi-cir.c +1 -0
@@ -371,6 +371,7 @@ static void sunxi_ir_remove(struct platform_device *pdev)struct sunxi_ir *ir =platform_get_drvdata (pdev);rc_unregister_device (ir->rc); +rc_free_device (ir->rc);sunxi_ir_hw_exit (&pdev->dev); }
drivers/media/rc/ttusbir.c +1 -1
@@ -333,7 +333,6 @@ static int ttusbir_probe(struct usb_interface *intf,return 0 ; out3:rc_unregister_device (rc); - rc =NULL ; out2:led_classdev_unregister (&tt->led); out:
@@ -373,6 +372,7 @@ static void ttusbir_disconnect(struct usb_interface *intf) }usb_kill_urb (tt->bulk_urb);usb_free_urb (tt->bulk_urb); +rc_free_device (tt->rc);usb_set_intfdata (intf,NULL );kfree (tt); }
drivers/media/rc/winbond-cir.c +1 -1
@@ -1132,7 +1132,6 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)release_region (data->wbase,WAKEUP_IOMEM_LEN ); exit_unregister_device:rc_unregister_device (data->dev); - data->dev =NULL ; exit_free_rc:rc_free_device (data->dev); exit_unregister_led:
@@ -1163,6 +1162,7 @@ wbcir_remove(struct pnp_dev *device)wbcir_set_bits (data->wbase +WBCIR_REG_WCEIR_EV_EN ,0x00 ,0x07 );rc_unregister_device (data->dev); +rc_free_device (data->dev);led_classdev_unregister (&data->led);
drivers/media/rc/xbox_remote.c +3 -2
@@ -277,14 +277,15 @@ static void xbox_remote_disconnect(struct usb_interface *interface)struct xbox_remote *xbox_remote; xbox_remote =usb_get_intfdata (interface); -usb_set_intfdata (interface,NULL );if (!xbox_remote) {dev_warn (&interface->dev,"%s - null device?\n" , __func__);return ; } -usb_kill_urb (xbox_remote->irq_urb);rc_unregister_device (xbox_remote->rdev); +usb_set_intfdata (interface,NULL ); +usb_kill_urb (xbox_remote->irq_urb); +rc_free_device (xbox_remote->rdev);usb_free_urb (xbox_remote->irq_urb);kfree (xbox_remote); }
drivers/media/usb/au0828/au0828-input.c +1 -0
@@ -357,6 +357,7 @@ void au0828_rc_unregister(struct au0828_dev *dev)return ;rc_unregister_device (ir->rc); +rc_free_device (ir->rc);/* done */ kfree (ir);
drivers/media/usb/dvb-usb-v2/dvb_usb_core.c +1 -0
@@ -187,6 +187,7 @@ static int dvb_usbv2_remote_exit(struct dvb_usb_device *d)if (d->rc_dev) {cancel_delayed_work_sync (&d->rc_query_work);rc_unregister_device (d->rc_dev); +rc_free_device (d->rc_dev); d->rc_dev =NULL ; }
drivers/media/usb/dvb-usb/dvb-usb-remote.c +4 -2
@@ -347,10 +347,12 @@ int dvb_usb_remote_exit(struct dvb_usb_device *d) {if (d->state &DVB_USB_STATE_REMOTE ) {cancel_delayed_work_sync (&d->rc_query_work); -if (d->props.rc.mode ==DVB_RC_LEGACY ) +if (d->props.rc.mode ==DVB_RC_LEGACY ) {input_unregister_device (d->input_dev); -else + }else {rc_unregister_device (d->rc_dev); +rc_free_device (d->rc_dev); + } } d->state &= ~DVB_USB_STATE_REMOTE ;return 0 ;
drivers/media/usb/em28xx/em28xx-input.c +1 -0
@@ -853,6 +853,7 @@ static int em28xx_ir_fini(struct em28xx *dev) goto ref_put;rc_unregister_device (ir->rc); +rc_free_device (ir->rc);kfree (ir->i2c_client);
drivers/staging/media/av7110/av7110_ir.c +1 -0
@@ -151,6 +151,7 @@ int av7110_ir_init(struct av7110 *av7110)void av7110_ir_exit (struct av7110 *av7110) {rc_unregister_device (av7110->ir.rcdev); +rc_free_device (av7110->ir.rcdev); }//MODULE_AUTHOR("Holger Waechtler <[email protected]>, Oliver Endriss <[email protected]>");
include/media/rc-core.h +0 -2
@@ -81,7 +81,6 @@ struct lirc_fh {/** * struct rc_dev - represents a remote control device * @dev: driver model's view of this device -* @managed_alloc: devm_rc_allocate_device was used to create rc_dev * @registered: set to true by rc_register_device(), false by * rc_unregister_device * @idle: used to keep track of RX state
@@ -156,7 +155,6 @@ struct lirc_fh {*/ struct rc_dev {struct device dev; -bool managed_alloc;bool registered;bool idle;bool encode_wakeup;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 netfilter: xt_multiport: validate range encoding in checkentry
In reply to Sasha LevinFrom: Ren Wei <[email protected]>
[ Upstream commit ff64c5bfef12461df8450e0f50bb693b5269c720 ]
ports_match_v1() treats any non-zero pflags entry as the start of a port range and unconditionally consumes the next ports[] element as the range end.
The checkentry path currently validates protocol, flags and count, but it does not validate the range encoding itself. As a result, malformed rules can mark the last slot as a range start or place two range starts back to back, leaving ports_match_v1() to step past the last valid ports[] element while interpreting the rule.
Reject malformed multiport v1 rules in checkentry by validating that each range start has a following element and that the following element is not itself marked as another range start.
---
LLM Generated explanations, may be completely bogus:
Error: Failed to generate final synthesis
net/netfilter/xt_multiport.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-)
net/netfilter/xt_multiport.c +30 -4
@@ -105,6 +105,28 @@ multiport_mt(const struct sk_buff *skb, struct xt_action_param *par)return ports_match_v1 (multiinfo,ntohs (pptr[0 ]),ntohs (pptr[1 ])); } +static bool +multiport_valid_ranges (const struct xt_multiport_v1 *multiinfo) +{ +unsigned int i; + +for (i =0 ; i < multiinfo->count; i++) { +if (!multiinfo->pflags[i]) +continue ; + +if (++i >= multiinfo->count) +return false; + +if (multiinfo->pflags[i]) +return false; + +if (multiinfo->ports[i -1 ] > multiinfo->ports[i]) +return false; + } + +return true; +} + static inline bool check(u_int16_t proto, u_int8_t ip_invflags,
@@ -127,8 +149,10 @@ static int multiport_mt_check(const struct xt_mtchk_param *par)const struct ipt_ip *ip = par->entryinfo;const struct xt_multiport_v1 *multiinfo = par->matchinfo; -return check (ip->proto, ip->invflags, multiinfo->flags, - multiinfo->count) ?0 : -EINVAL ; +if (!check (ip->proto, ip->invflags, multiinfo->flags, multiinfo->count)) +return -EINVAL ; + +return multiport_valid_ranges (multiinfo) ?0 : -EINVAL ; }static int multiport_mt6_check (const struct xt_mtchk_param *par)
@@ -136,8 +160,10 @@ static int multiport_mt6_check(const struct xt_mtchk_param *par)const struct ip6t_ip6 *ip = par->entryinfo;const struct xt_multiport_v1 *multiinfo = par->matchinfo; -return check (ip->proto, ip->invflags, multiinfo->flags, - multiinfo->count) ?0 : -EINVAL ; +if (!check (ip->proto, ip->invflags, multiinfo->flags, multiinfo->count)) +return -EINVAL ; + +return multiport_valid_ranges (multiinfo) ?0 : -EINVAL ; }static struct xt_match multiport_mt_reg[]__read_mostly = {
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 arm64: dts: imx93-tqma9352: improve eMMC pad configuration
In reply to Sasha LevinFrom: Markus Niebel <[email protected]>
[ Upstream commit b6c94c71f349479b76fcc0ef0dc7147f3f326dff ]
Use DSE x4 an PullUp for CMD an DAT, DSE x4 and PullDown for CLK to improve stability and detection at low temperatures under -25°C.
---
LLM Generated explanations, may be completely bogus:
Error: Failed to generate final synthesis
.../boot/dts/freescale/imx93-tqma9352.dtsi | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-)
arch/arm64/boot/dts/freescale/imx93-tqma9352.dtsi +13 -13
@@ -270,21 +270,21 @@ MX93_PAD_SD2_RESET_B__GPIO3_IO07 0x106 /* enable SION for data and cmd pad due to ERR052021 */ pinctrl_usdhc1: usdhc1grp { fsl,pins = < - /* PD | FSEL 3 | DSE X5 */ - MX93_PAD_SD1_CLK__USDHC1_CLK 0x5be + /* PD | FSEL 3 | DSE X4 */ + MX93_PAD_SD1_CLK__USDHC1_CLK 0x59e /* HYS | FSEL 0 | no drive */ MX93_PAD_SD1_STROBE__USDHC1_STROBE 0x1000 - /* HYS | FSEL 3 | X5 */ - MX93_PAD_SD1_CMD__USDHC1_CMD 0x400011be - /* HYS | FSEL 3 | X4 */ - MX93_PAD_SD1_DATA0__USDHC1_DATA0 0x4000119e - MX93_PAD_SD1_DATA1__USDHC1_DATA1 0x4000119e - MX93_PAD_SD1_DATA2__USDHC1_DATA2 0x4000119e - MX93_PAD_SD1_DATA3__USDHC1_DATA3 0x4000119e - MX93_PAD_SD1_DATA4__USDHC1_DATA4 0x4000119e - MX93_PAD_SD1_DATA5__USDHC1_DATA5 0x4000119e - MX93_PAD_SD1_DATA6__USDHC1_DATA6 0x4000119e - MX93_PAD_SD1_DATA7__USDHC1_DATA7 0x4000119e + /* HYS | PU | FSEL 3 | DSE X4 */ + MX93_PAD_SD1_CMD__USDHC1_CMD 0x4000139e + /* HYS | PU | FSEL 3 | DSE X4 */ + MX93_PAD_SD1_DATA0__USDHC1_DATA0 0x4000139e + MX93_PAD_SD1_DATA1__USDHC1_DATA1 0x4000139e + MX93_PAD_SD1_DATA2__USDHC1_DATA2 0x4000139e + MX93_PAD_SD1_DATA3__USDHC1_DATA3 0x4000139e + MX93_PAD_SD1_DATA4__USDHC1_DATA4 0x4000139e + MX93_PAD_SD1_DATA5__USDHC1_DATA5 0x4000139e + MX93_PAD_SD1_DATA6__USDHC1_DATA6 0x4000139e + MX93_PAD_SD1_DATA7__USDHC1_DATA7 0x4000139e >; };
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 dm vdo slab-depot: validate old zone count on load
In reply to Sasha LevinFrom: Matthew Sakai <[email protected]>
[ Upstream commit b3929b2cc2a6003b8e301e6540c651e60d24dcb4 ]
Verify the old zone count has a valid value before using it to compute slab summary entry offsets.
---
LLM Generated explanations, may be completely bogus:
Now I have a thorough understanding. Let me compile my final analysis.
---
## Complete Analysis: dm vdo slab-depot: validate old zone count on load
### PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: Subject Line**
- Subsystem: dm vdo slab-depot (device-mapper VDO subsystem, slab depot component)
- Action verb: "validate" — implies adding a missing safety check, strongly suggests bug fix
- Summary: Validates the old_zone_count field read from on-disk metadata before using it as an array index.
- Record: [dm vdo slab-depot] [validate] [add bounds check on old zone count loaded from disk]
**Step 1.2: Tags**
- Signed-off-by: Matthew Sakai <[email protected]> — author, VDO subsystem maintainer
- Signed-off-by: Mikulas Patocka <[email protected]> — DM subsystem maintainer
- No Fixes: tag, no Reported-by, no Link: tags
- Record: Patch authored by VDO maintainer, signed off by DM maintainer. No external bug report; likely found via code audit.
**Step 1.3: Commit Body**
- "Verify the old zone count has a valid value before using it to compute slab summary entry offsets."
- This directly describes a missing input validation on data loaded from disk. The "old zone count" is deserialized from the VDO super block and used to compute array offsets without bounds checking.
- Record: Bug = missing validation of on-disk value used as array index; Symptom = potential OOB memory access; Root cause = zone_count from disk not validated against MAX_VDO_PHYSICAL_ZONES.
**Step 1.4: Hidden Bug Fix Detection**
- This IS a bug fix. "Validate" = adding a missing safety check. The code was using an untrusted on-disk value to compute memory offsets.
- Record: Yes, this is a validation bug fix preventing out-of-bounds access.
### PHASE 2: DIFF ANALYSIS
**Step 2.1: Inventory**
- Files: drivers/md/dm-vdo/slab-depot.c (+3 lines)
- Function modified: vdo_decode_slab_depot()
- Scope: Single-file, surgical 3-line addition
- Record: 1 file, +3 lines, single function, surgical fix.
**Step 2.2: Code Flow Change**
- BEFORE: state.zone_count from on-disk metadata was stored as depot->old_zone_count without any bounds validation. The decode function (decode_slab_depot_state_2_0 in encodings.c) reads zone_count as a raw byte (buffer[(*offset)++]) and stores it without validation.
- AFTER: state.zone_count is checked against MAX_VDO_PHYSICAL_ZONES (16). If it exceeds 16, UDS_CORRUPT_DATA error is returned before any allocation.
- The check is placed BEFORE the allocation of the depot structure, so no memory leak on this error path.
- Record: Before = raw on-disk byte used unchecked; After = validated against maximum before use.
**Step 2.3: Bug Mechanism**
This is an **out-of-bounds memory access** bug:
1. zone_count is a zone_count_t (u8), so it can be 0-255.
2. MAX_VDO_PHYSICAL_ZONES = 16.
3. In combine_summaries() (line 4575-4588), depot->old_zone_count is used to cycle through zones: entries + (zone * MAX_VDO_SLABS) + entry_number, where zone ranges from 0 to old_zone_count - 1.
4. The summary_entries buffer is allocated with MAXIMUM_VDO_SLAB_SUMMARY_ENTRIES = MAX_VDO_SLABS * MAX_VDO_PHYSICAL_ZONES = 8192 * 16 = 131,072 entries.
5. If old_zone_count = 17, the maximum offset becomes 16 * 8192 + 8191 = 139,263, which exceeds the buffer size of 131,072. With old_zone_count = 255, the max offset is 2,088,959 — massively out of bounds.
6. This causes an OOB read (data copied from beyond the buffer boundary) and potentially corruption, since combine_summaries uses memcpy both for reading and writing.
Record: [OOB memory access] [corrupt on-disk zone_count > 16 causes access beyond allocated summary_entries buffer in combine_summaries()]
**Step 2.4: Fix Quality**
- Obviously correct: a simple bounds check against a well-defined constant.
- Minimal/surgical: 3 lines, inserted in the right place (before allocation and use).
- No regression risk: this only rejects corrupt/invalid data early.
- Placed before allocation, so no resource leak on this new error path.
- Record: Fix is obviously correct, minimal, zero regression risk.
### PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: Blame**
- The buggy code (using state.zone_count without validation) was introduced by 7ce49449ffb940 ("dm vdo: add the slab depot") by Matthew Sakai on 2023-11-16.
- This is contained in v6.9-rc1, so it has been present since kernel 6.9.
- Record: Buggy code introduced in commit 7ce49449ffb940 (v6.9-rc1), present since kernel 6.9.
**Step 3.2: Fixes tag** — No Fixes: tag present (expected).
**Step 3.3: File History**
- The file has had moderate recent activity (kerneldoc fixes, refcount rework, ring reference removal). No related validation fixes found.
- Record: No prior fix for this issue. Standalone fix.
**Step 3.4: Author**
- Matthew Sakai is the VDO subsystem maintainer and author of the original VDO code. Mikulas Patocka is the DM subsystem maintainer who signed off.
- Record: Fix from subsystem maintainer, signed off by DM maintainer. High confidence.
**Step 3.5: Dependencies**
- This is entirely standalone. It adds a check using MAX_VDO_PHYSICAL_ZONES and UDS_CORRUPT_DATA, both of which already exist in all stable trees with dm-vdo.
- Record: No dependencies. Clean standalone fix.
### PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1-4.5:** Could not find the original mailing list submission through web search or b4 dig (the commit may be very recent or submitted through a different channel). The DM tree often takes patches directly. Both the VDO and DM maintainer signed off, indicating proper review.
- Record: Mailing list thread not found (may be recent/not yet indexed). Maintainer sign-offs provide review confidence.
### PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: Key Functions**
- Modified: vdo_decode_slab_depot() — the main decoder for VDO slab depot on-disk state.
**Step 5.2: Callers**
- vdo_decode_slab_depot() is called from dm-vdo-target.c:1360 during VDO volume load/activation. This is triggered when a VDO device is started (e.g., dmsetup create).
- Record: Called during device activation — any VDO user hits this code path.
**Step 5.3-5.4: Impact Path**
- vdo_decode_slab_depot() → stores old_zone_count → combine_summaries() uses it to compute offsets into summary_entries array → OOB access if value > 16.
- The bug is triggered whenever VDO loads a volume with corrupt metadata (malicious disk image, bit rot, filesystem corruption).
**Step 5.5: Similar Patterns**
- The dm-vdo-target.c already validates physical_zone_count at line 421 (if (count > MAX_VDO_PHYSICAL_ZONES)), but the on-disk deserialization path in decode_slab_depot_state_2_0 does NOT validate zone_count. This is an inconsistency that this fix addresses.
- Record: New zone_count validated in dm-vdo-target.c; old zone_count from disk was NOT validated. Asymmetric validation = bug.
### PHASE 6: CROSS-REFERENCING
**Step 6.1: Stable Tree Presence**
- dm-vdo was introduced in v6.9-rc1. File does NOT exist in v6.8 or earlier.
- Exists in stable trees: 6.12.y, and any other active stable tree >= 6.9.
- Record: Bug exists in all kernels >= 6.9 (6.12.y stable tree).
**Step 6.2: Backport Complications**
- The v6.9 code is identical to current mainline for this function (verified). Patch should apply cleanly.
- Record: Clean apply expected.
**Step 6.3: Related Fixes**
- No related fix found in stable.
### PHASE 7: SUBSYSTEM CONTEXT
**Step 7.1:** dm-vdo (device-mapper Virtual Data Optimizer) is a data deduplication and compression layer. Classification: IMPORTANT — used in production storage (Red Hat VDO in RHEL).
- Record: Subsystem: DM/VDO, Criticality: IMPORTANT (production storage).
### PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: Who is affected** — All VDO users loading VDO volumes (dm- vdo is used in RHEL/Fedora storage stacks).
**Step 8.2: Trigger** — Loading a VDO volume with corrupt on-disk metadata where zone_count > 16. This can happen from:
- Disk corruption / bit rot
- Malicious crafted disk images
- Record: Triggered on VDO volume load with corrupt metadata.
**Step 8.3: Severity** — OOB memory access → can cause:
- Kernel crash/oops (most likely outcome)
- Memory corruption
- Potential information leak
- Severity: **HIGH** (OOB access from untrusted on-disk data)
**Step 8.4: Risk-Benefit**
- BENEFIT: Prevents OOB memory access from corrupt disk metadata. Protects all VDO users.
- RISK: 3 lines, obviously correct bounds check, zero regression risk.
- Record: Very high benefit, very low risk.
### PHASE 9: FINAL SYNTHESIS
**Step 9.1: Evidence**
FOR backporting:
- Fixes out-of-bounds memory access from unvalidated on-disk data
- 3-line surgical fix, obviously correct
- Written by VDO maintainer, signed off by DM maintainer
- Affects all VDO users when loading corrupt volumes
- zone_count_t is u8 (0-255) but must be <= 16; no validation existed
- combine_summaries() computes zone * MAX_VDO_SLABS (up to 254 * 8192) into a buffer of only 131,072 entries
- Similar validation already exists for new zone_count in dm-vdo- target.c
- Code exists in stable trees >= 6.9 (including 6.12.y)
AGAINST backporting:
- No explicit Reported-by or syzbot trigger (likely found by code audit)
- No CVE assigned (yet)
- Requires corrupt/malicious on-disk metadata to trigger
**Step 9.2: Stable Rules Checklist**
1. Obviously correct and tested? **YES** — trivial bounds check
2. Fixes a real bug? **YES** — OOB access from untrusted input
3. Important issue? **YES** — OOB memory access = crash/corruption/security
4. Small and contained? **YES** — 3 lines, single file
5. No new features or APIs? **YES** — validation only
6. Can apply to stable? **YES** — code is identical in 6.9+
**Step 9.3: Exception Categories** — N/A (standard bug fix)
**Step 9.4: Decision**
This is a clear-cut missing input validation fix for on-disk data that can cause out-of-bounds memory access. It's 3 lines, obviously correct, from the subsystem maintainer, with zero regression risk.
### Verification
- [Phase 1] Parsed commit message: "validate old zone count" = bounds check on deserialized data
- [Phase 2] Diff analysis: 3 lines added to vdo_decode_slab_depot(), validates state.zone_count <= MAX_VDO_PHYSICAL_ZONES
- [Phase 2] Confirmed OOB: zone_count=17 → offset 139,263 > buffer 131,072; zone_count=255 → offset 2,088,959
- [Phase 3] git blame: buggy code introduced in 7ce49449ffb940 (v6.9-rc1, 2023-11-16)
- [Phase 3] git describe: 7ce49449ffb940 is v6.9-rc1~148^2~114
- [Phase 3] Confirmed no Fixes: tag (expected for AUTOSEL candidate)
- [Phase 3] Confirmed standalone fix, no dependencies
- [Phase 4] b4 dig: could not find mailing list thread (UNVERIFIED:
thread may be too recent)
- [Phase 5] vdo_decode_slab_depot() called from dm-vdo-target.c:1360 during VDO volume activation
- [Phase 5] combine_summaries() at line 4575-4588 uses old_zone_count to compute offsets into summary_entries
- [Phase 5] decode_slab_depot_state_2_0() at line 631 reads zone_count as raw byte with no validation
- [Phase 5] Confirmed asymmetric validation: new zone_count validated at dm-vdo-target.c:421, but not old zone_count from disk
- [Phase 6] File exists in v6.9+ (confirmed v6.9:drivers/md/dm- vdo/slab-depot.c exists, v6.8 does not)
- [Phase 6] v6.9 version of vdo_decode_slab_depot() is identical — clean apply expected
- [Phase 8] Failure mode: OOB memory read/write in combine_summaries() → crash or corruption, severity HIGH
- UNVERIFIED: Could not locate mailing list discussion; relying on maintainer SOBs for review confidence
**YES**
drivers/md/dm-vdo/slab-depot.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/md/dm-vdo/slab-depot.c +4 -0
@@ -4262,6 +4262,10 @@ int vdo_decode_slab_depot(struct slab_depot_state_2_0 state, struct vdo *vdo, } slab_size_shift =ilog2 (slab_size); +if (state.zone_count >MAX_VDO_PHYSICAL_ZONES ) +return vdo_log_error_strerror (UDS_CORRUPT_DATA , +"invalid zone count" ); + result = vdo_allocate_extended(struct slab_depot, vdo->thread_config.physical_zone_count, struct block_allocator, __func__, &depot);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: mt76: mt792x: Fix a potential deadlock in high-load situations
In reply to Sasha LevinFrom: Leon Yen <[email protected]>
[ Upstream commit bb2f07819d063a58756186cac6465341956ac0a4 ]
A deadlock may occur between two works, ps_work and mac_work, if their work functions run simultaneously as they attempt to cancel each other by calling cancel_delayed_work_sync().
mt792x_mac_work() -> ... -> cancel_delayed_work_sync(&pm->ps_work);mt792x_pm_power_save_work() -> cancel_delayed_work_sync(&mphy->mac_work);
In high-load situations, they are queued but may not have chance to be executed until the CPUs are released. Once the CPUs are available, there is a high possibility that the ps_work function and mac_work function will be executed simultaneously, resulting in a possible deadlock.
This patch replaces cancel_delayed_work_sync() with cancel_delayed_work() in ps_work to eliminate the deadlock and make the code easier to maintain.
---
LLM Generated explanations, may be completely bogus:
Now I have all the data needed. Let me compile the full analysis.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: Subject Line**
- Subsystem: wifi: mt76: mt792x
- Action verb: "Fix"
- Summary: Fixes a potential deadlock between ps_work and mac_work in high-load situations.
Record: [wifi/mt76/mt792x] [Fix] [Deadlock between two work functions that cancel each other with _sync variant]
**Step 1.2: Tags**
- Signed-off-by: Leon Yen <[email protected]> — Author from MediaTek (the chip vendor)
- Tested-by: Chia-Lin Kao (AceLan) <[email protected]> — Tested by a Canonical engineer
- `Link: https://patch.msgid.link/20251215122231.3180648-1-
[email protected]`
- Signed-off-by: Felix Fietkau <[email protected]> — mt76 subsystem maintainer accepted the patch
Record: Author is from MediaTek (chip vendor). Tested by Canonical (Ubuntu). Accepted by mt76 maintainer Felix Fietkau. No Fixes: tag, no Reported-by (expected since this is a code-analysis-based fix).
**Step 1.3: Commit Body**
The message describes:
- **Bug**: A deadlock between two delayed works: ps_work and mac_work
- **Mechanism**: Both try to cancel each other using cancel_delayed_work_sync(), which blocks until the target work finishes
- **Trigger**: High-load situations where both works get queued and execute simultaneously on different CPUs
- **Fix**: Replace cancel_delayed_work_sync() with cancel_delayed_work() in ps_work
Record: Classic ABBA deadlock. Failure mode is system hang (deadlock). Triggered under high CPU load with WiFi active.
**Step 1.4: Hidden Bug Fix?**
No — this is explicitly labeled "Fix" and clearly describes a deadlock. Not hidden.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: Inventory**
- 1 file changed: drivers/net/wireless/mediatek/mt76/mt792x_mac.c
- 1 line changed: -cancel_delayed_work_sync( → +cancel_delayed_work(
- Function modified: mt792x_pm_power_save_work()
- Scope: Single-file, single-line, surgical fix
**Step 2.2: Code Flow Change**
Before: mt792x_pm_power_save_work() calls cancel_delayed_work_sync(&mphy->mac_work), which blocks until any currently-running mac_work completes.
After: It calls cancel_delayed_work(&mphy->mac_work), which cancels a pending work but does NOT wait for a running instance to finish.
**Step 2.3: Bug Mechanism — Deadlock**
The deadlock is an ABBA pattern between two work functions:
**Chain A** (mac_work → waits for ps_work):
```
mt792x_mac_work()
→ mt792x_mutex_acquire()
→ mt76_connac_mutex_acquire()
→ mt76_connac_pm_wake()
→ cancel_delayed_work_sync(&pm->ps_work) ← WAITS for ps_work
```**Chain B** (ps_work → waits for mac_work):
``` mt792x_pm_power_save_work() → cancel_delayed_work_sync(&mphy->mac_work) ← WAITS for mac_work ```
If both execute simultaneously:
- CPU1's mac_work waits for ps_work to finish
- CPU2's ps_work waits for mac_work to finish
- **Classic ABBA deadlock → system hang**
The two works run on *different* workqueues (mac_work on ieee80211's workqueue, ps_work on dev->mt76.wq), which confirms they CAN execute in parallel on different CPUs.
**Step 2.4: Fix Quality**
- Obviously correct: removing _sync breaks the circular dependency
- The non-sync variant is safe here because after the cancel, ps_work immediately returns. If mac_work is running, it will re-queue itself (line 30-31) and will be properly managed in the next power-save cycle. mac_work acquires mt792x_mutex_acquire which wakes the device if needed.
- Minimal/surgical: exactly 1 function call changed
- Regression risk: Very low — the only difference is not waiting for a running mac_work to finish, which is acceptable since ps_work doesn't depend on mac_work completion
## PHASE 3: GIT HISTORY
**Step 3.1: Blame**
The buggy line was introduced by commit c21a7f9f406bba (Lorenzo Bianconi, 2023-06-28), "wifi: mt76: mt7921: move shared runtime-pm code on mt792x-lib". This was code movement that created the mt792x_mac.c file, carrying the original deadlock-prone pattern from mt7921/mac.c.
**Step 3.2: Fixes tag** — No Fixes: tag present (expected).
**Step 3.3: Related changes** — The file has had several changes since, but none addressing this specific deadlock.
**Step 3.4: Author** — Leon Yen is a MediaTek engineer with multiple mt76 contributions, including WiFi/BT combo fixes and power management work.
**Step 3.5: Dependencies** — None. This is a standalone one-line fix.
## PHASE 4: MAILING LIST RESEARCH
b4 dig did not find the exact commit (it matched a different file change). The lore.kernel.org search was blocked. However, the commit message Link tag points to the original submission:[email protected]. The patch was accepted by Felix Fietkau (mt76 maintainer) and tested by a Canonical engineer.
Record: Maintainer-accepted, independently tested. Standalone patch (not a series).
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: Functions modified**: mt792x_pm_power_save_work()
**Step 5.2: Callers**: This function is the work handler for pm.ps_work, queued on dev->mt76.wq (an ordered workqueue) via mt76_connac_power_save_sched(). It is called indirectly when the device transitions to power-save mode.
**Step 5.3-5.4: Call chain**: The power-save work is scheduled via mt76_connac_mutex_release() → mt76_connac_power_save_sched(), which is called after every device register access. This is a very hot path for any mt792x WiFi operation.
**Step 5.5: Similar patterns**: The mt7615 driver has similar power- save code at drivers/net/wireless/mediatek/mt76/mt7615/mac.c, but this specific fix only addresses the mt792x code path.
## PHASE 6: STABLE TREE ANALYSIS
**Step 6.1**: The buggy code was introduced in commit c21a7f9f406bba (June 2023), which is present in v6.6 but NOT in v6.1. Affected stable
trees: v6.6.y, v6.12.y, and any later LTS.
**Step 6.2**: The fix is a one-line change. It should apply cleanly to any tree containing the buggy code.
**Step 6.3**: No related fixes for this specific deadlock already in stable.
## PHASE 7: SUBSYSTEM CONTEXT
**Step 7.1**: drivers/net/wireless/mediatek/mt76 — WiFi driver for MediaTek MT7921/MT7922/MT7925 chipsets. These are extremely popular WiFi chips found in many modern laptops (Framework, Lenovo ThinkPad, Dell, etc.). Criticality: **IMPORTANT** — affects many real users.
**Step 7.2**: The mt76 subsystem is very active with regular contributions.
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1**: Affects all users with MT7921/MT7922/MT7925 WiFi chipsets (very large population, especially Ubuntu/Fedora laptop users).
**Step 8.2**: Trigger is high CPU load with active WiFi. Both works must execute simultaneously. Under heavy load this is realistic — the commit specifically says "In high-load situations, they are queued but may not have chance to be executed until the CPUs are released."
**Step 8.3**: **Failure mode: DEADLOCK → system hang**. Severity:
**CRITICAL** — the system becomes unresponsive.
**Step 8.4**:
- Benefit: VERY HIGH — prevents deadlock/hang on popular hardware
- Risk: VERY LOW — 1-line change, removing a sync variant that was causing the deadlock
- Ratio: Extremely favorable
## PHASE 9: FINAL SYNTHESIS
**Evidence FOR backporting:**
- Fixes a real deadlock (ABBA pattern) verified through code analysis
- 1-line fix, obviously correct, minimal regression risk
- Affects widely-used WiFi hardware (MT7921/MT7922/MT7925)
- Tested by Canonical engineer (Ubuntu LTS relevance)
- Accepted by subsystem maintainer
- Buggy code exists in stable trees v6.6+
- Failure mode is system hang (CRITICAL)
- Author is from MediaTek (chip vendor, deep domain expertise)
**Evidence AGAINST backporting:**
- None significant
**Stable rules checklist:**
1. Obviously correct and tested? **YES** — 1-line change, independently tested
2. Fixes a real bug? **YES** — deadlock under high load
3. Important issue? **YES** — system deadlock/hang (CRITICAL)
4. Small and contained? **YES** — 1 line in 1 file
5. No new features? **YES** — pure bug fix
6. Applies to stable? **YES** — clean apply expected for v6.6+
## Verification
- [Phase 1] Parsed tags: Tested-by from Canonical, maintainer SOB from Felix Fietkau
- [Phase 2] Diff analysis: 1-line change in mt792x_pm_power_save_work(), cancel_delayed_work_sync → cancel_delayed_work
- [Phase 3] git blame: buggy code from commit c21a7f9f406bba (June 2023), code refactoring that moved runtime-PM code to mt792x-lib
- [Phase 3] git merge-base --is-ancestor: confirmed code is in v6.6 but NOT in v6.1
- [Phase 5] Traced deadlock chain: mac_work→mt792x_mutex_acquire→mt76_co nnac_pm_wake→cancel_delayed_work_sync(&ps_work) vs ps_work→cancel_delayed_work_sync(&mac_work)
- [Phase 5] Verified dev->mt76.wq is alloc_ordered_workqueue (mac80211.c line 733) and mac_work uses ieee80211's workqueue (different queues → parallel execution possible)
- [Phase 5] Verified mt76_connac_power_save_sched at line 62-83 of mt76_connac_mac.c schedules ps_work, confirming the scheduling path
- [Phase 6] Confirmed fix applies to v6.6+ stable trees
- [Phase 7] mt76 is a widely used WiFi driver subsystem
- [Phase 8] Failure mode: system deadlock/hang, severity CRITICAL
**YES**
drivers/net/wireless/mediatek/mt76/mt792x_mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt792x_mac.c +1 -1
@@ -375,7 +375,7 @@ void mt792x_pm_power_save_work(struct work_struct *work) }if (!mt792x_mcu_fw_pmctrl (dev)) { -cancel_delayed_work_sync (&mphy->mac_work); +cancel_delayed_work (&mphy->mac_work);return ; } out:
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 orangefs: add usercopy whitelist to orangefs_op_cache
In reply to Sasha LevinFrom: Ziyi Guo <[email protected]>
[ Upstream commit f855f4ab123b2b9c93465288c03fbb07a5903bb3 ]
orangefs_op_cache is created with kmem_cache_create(), which provides no usercopy whitelist. orangefs_devreq_read() copies the tag and upcall fields directly from slab objects to userspace via copy_to_user(). With CONFIG_HARDENED_USERCOPY enabled, this triggers usercopy_abort().
Switch to kmem_cache_create_usercopy() with a whitelist covering the tag and upcall fields, matching the pattern already used by orangefs_inode_cache in super.c.
---
LLM Generated explanations, may be completely bogus:
Now I have enough information to write up the complete analysis.
## Analysis
### PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1 - Subject line parsing:**
Record: subsystem = orangefs, action verb = add, summary = "adds a usercopy whitelist to the orangefs_op_cache slab so that copy_to_user() from cache objects does not trigger the hardened-usercopy check."
**Step 1.2 - Tags:**
- Signed-off-by: Ziyi Guo <[email protected]> (author)
- Signed-off-by: Mike Marshall <[email protected]> (orangefs maintainer)
- No Fixes:, no Cc: stable, no Reported-by:, no Reviewed-by:, no Tested- by:, no Link:
Record: Minimal tag set. Maintainer SOB present (Mike Marshall maintains fs/orangefs/).
**Step 1.3 - Body analysis:**
Record: Claims that orangefs_devreq_read() performs copy_to_user() on fields inside a slab-allocated orangefs_kernel_op_s. Because the cache was created without a usercopy whitelist, the hardened-usercopy check rejects the copy and calls usercopy_abort() (which BUG()s).
Fix: switch to kmem_cache_create_usercopy() with a whitelist that spans from tag through end of upcall.
**Step 1.4 - Hidden bug fix detection:**
Record: Although the subject uses "add" not "fix", the body explicitly says "this triggers usercopy_abort()" - this is clearly a bug fix against a kernel panic, not a feature addition.
### PHASE 2: DIFF ANALYSIS
**Step 2.1 - Inventory:**
Record: 1 file, fs/orangefs/orangefs-cache.c, +5/-1 lines. Modifies only op_cache_initialize(). Single-file surgical fix.
**Step 2.2 - Code flow change:**
Record: Before: op_cache = kmem_cache_create(...) - cache has useroffset=0, usersize=0 (non-usercopy). After: op_cache = kmem_cache_create_usercopy(..., useroffset=offsetof(tag), usersize=offsetof(upcall)+sizeof(upcall)-offsetof(tag), ...). The whitelist starts at tag and extends through the end of upcall.
**Step 2.3 - Bug mechanism:**
Record: Hardware/runtime safety fix - slab usercopy whitelist. orangefs_devreq_read() (fs/orangefs/devorangefs-req.c lines 287-294) does two copy_to_user() calls from cur_op (slab object):
1. &cur_op->tag, size sizeof(__u64)
2. &cur_op->upcall, size sizeof(struct orangefs_upcall_s)
Without whitelist, __check_heap_object() in mm/slub.c compares offset against s->useroffset/s->usersize (both 0 here) and fails → usercopy_abort() → BUG(). The new whitelist covers both copies (tag at offsetof(tag), upcall at offsetof(upcall); whitelist spans [offsetof(tag), offsetof(upcall)+sizeof(upcall))).
**Step 2.4 - Fix quality:**
Record: Obviously correct - mirrors the pre-existing pattern for orangefs_inode_cache in fs/orangefs/super.c:642 (commit 6b330623e5690). Tiny scope. Only concern: added lines use mixed tabs+space indentation (5 tabs + space) that is inconsistent with existing 4-tab alignment; purely cosmetic, no functional impact. No regression risk from the change itself - kmem_cache_create_usercopy() is the explicit API for this case, established since v4.16.
### PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1 - Blame:**
Record: The buggy kmem_cache_create() for op_cache dates back to 575e946125f70 ("Orangefs: change pvfs2 filenames to orangefs", v4.6-rc1, Dec 2015) when the file was renamed; the code pattern has been present since OrangeFS was first merged into the kernel in v4.6. Bug exists in all stable trees.
**Step 3.2 - Fixes: tag:**
Record: No Fixes: tag in the patch. However, by analogy with 2a71a1a8d0ed7 (net sock hardened usercopy panic, Dec 2025), the root cause trace is 6d07d1cd300f ("usercopy: Restrict non-usercopy caches to size 0", v4.16-rc1, 2018) - this changed the default usercopy region to 0, making caches without a whitelist reject all copies. Strict enforcement (no fallback) came with 53944f171a89d ("mm: remove HARDENED_USERCOPY_FALLBACK", v5.16-rc1). Both exist in all currently supported stable trees.
**Step 3.3 - File history:**
Record: fs/orangefs/orangefs-cache.c has been very quiet: last change before this was 3635d000f04b7 ("fs/orangefs: remove ORANGEFS_CACHE_CREATE_FLAGS", in v6.12) - this replaced the ORANGEFS_CACHE_CREATE_FLAGS argument with 0. In stable trees ≤6.6, the flags argument is ORANGEFS_CACHE_CREATE_FLAGS, so a tiny backport adjustment is needed there. Standalone patch, not part of a series.
**Step 3.4 - Author context:**
Record: Ziyi Guo has no prior orangefs commits in the repo. Mike Marshall is the orangefs subsystem maintainer (per MAINTAINERS) and added his SOB, indicating maintainer acceptance.
**Step 3.5 - Dependencies:**
Record: None. kmem_cache_create_usercopy() has existed since v4.16 (2db51b1a3e ~). offsetof() and the struct layout exist unchanged in all stable trees.
### PHASE 4: MAILING LIST RESEARCH
**Step 4.1 - b4 dig:**
Record: b4 dig found the original submission at https://lore.kernel.org/
all/[email protected]/. Only one revision (v1); no later iterations.
**Step 4.2 - Reviewers:**
Record: CCed: Mike Marshall (maintainer), Martin Brandenburg (co- maintainer), [email protected], linux-kernel. Saved thread has only the submission email - no visible public review response, but Mike Marshall added his SOB which indicates maintainer acceptance. (lore.kernel.org is behind Anubis bot-protection so could not independently fetch web thread view; mbox download via b4 dig succeeded and showed only the patch.)
**Step 4.3 - Bug report:**
Record: No Reported-by or Link: tag. No external bug report referenced.
**Step 4.4 - Related patches:**
Record: Single-patch submission. Strong analog exists: 43e7e284fc77b ("cifs: Fix the smbd_response slab to allow usercopy", 2025) and 2a71a1a8d0ed7 ("net: sock: fix hardened usercopy panic in sock_recv_errqueue", Dec 2025) both fix the same class of hardened- usercopy BUG() in other subsystems. The CIFS fix was already backported (present in stable-push/linux-6.12.y).
**Step 4.5 - Stable ML:**
Record: Not searched further because lore.kernel.org is protected by bot-challenge. UNVERIFIED: No independent evidence of prior stable discussion.
### PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1 - Key functions:**
Record: op_cache_initialize() (one-time init at module load).
**Step 5.2 - Callers of affected code:**
Record: op_cache_initialize() is called from orangefs_init() in fs/orangefs/orangefs-mod.c at module init. op_cache itself is used by op_alloc() (allocates every upcall op) and op_release() (frees them). Used on every VFS operation that requires communication with the userspace daemon.
**Step 5.3 - Callees:**
Record: kmem_cache_create_usercopy() - core slab API, present since v4.16.
**Step 5.4 - Reachability:**
Record: Bug is trigger path is orangefs_devreq_read() at fs/orangefs/devorangefs-req.c:287-294. Reachable from userspace read() syscall on /dev/pvfs2-req by the pvfs2-client-core daemon on every orangefs upcall (every VFS op → every file/dir access). With CONFIG_HARDENED_USERCOPY=y and no fallback (v5.16+), the very first read after mounting orangefs BUG()s the kernel.
**Step 5.5 - Similar patterns:**
Record: orangefs_inode_cache in fs/orangefs/super.c:642 uses the same kmem_cache_create_usercopy() pattern (commit 6b330623e5690, v4.16). This patch completes what was an incomplete conversion - op_cache was overlooked in the original 2017 work.
### PHASE 6: CROSS-REFERENCING STABLE
**Step 6.1 - Bug in stable trees:**
Record: Verified the buggy op_cache = kmem_cache_create(...) line is present in stable-push/linux-5.10.y, linux-5.15.y, linux-6.1.y, linux-6.6.y, linux-6.12.y, linux-6.17.y, linux-6.18.y, linux-6.19.y via git show <branch>:fs/orangefs/orangefs-cache.c. Hard-panic semantics active on v5.16+ stable (linux-6.1, 6.6, 6.12, 6.17, 6.18, 6.19). On 5.10/5.15, the old fallback would emit a warning instead of BUG() - less severe but still undesirable.
**Step 6.2 - Backport complications:**
Record: For stable trees ≤6.6, the flags parameter is ORANGEFS_CACHE_CREATE_FLAGS instead of 0 - trivial one-word adjustment. File has seen minimal churn since v4.6. Expected apply:
6.12+ = nearly clean; ≤6.6 = tiny context adjustment.
**Step 6.3 - Related fixes in stable:**
Record: No orangefs-specific usercopy fix already in stable. Related
precedent: 43e7e284fc77b ("cifs: Fix the smbd_response slab to allow usercopy") is in stable-push/linux-6.12.y as 87dcc7e33fc3d - confirming this class of fix is accepted in stable.
### PHASE 7: SUBSYSTEM CONTEXT
**Step 7.1 - Criticality:**
Record: fs/orangefs/ - filesystem driver. PERIPHERAL criticality (niche distributed filesystem used mostly in HPC). However, any user who does use it is guaranteed to hit this on a hardened kernel.
**Step 7.2 - Activity:**
Record: Low-activity subsystem with a responsive maintainer (Mike Marshall). The file orangefs-cache.c itself is essentially frozen (last change in v6.12 was cosmetic).
### PHASE 8: IMPACT / RISK
**Step 8.1 - Affected users:**
Record: Anyone running orangefs on a kernel with CONFIG_HARDENED_USERCOPY=y (default in many distros) on v5.16+. Affects everyone using orangefs on those kernels.
**Step 8.2 - Trigger conditions:**
Record: Unconditional - triggered on the very first read() from /dev/pvfs2-req after orangefs mounts and the client daemon starts. This happens at every orangefs mount. No privilege required beyond what's already needed to run pvfs2-client-core (typically root). The bug is 100% reproducible on affected kernels.
**Step 8.3 - Failure mode severity:**
Record: usercopy_abort() → BUG() → kernel panic on filesystem mount/use. CRITICAL.
**Step 8.4 - Risk/benefit:**
Record: BENEFIT = High for orangefs users on hardened kernels (unusable otherwise); zero impact for everyone else. RISK = Very low: 4 lines, API has existed since v4.16, exact-same pattern already in same subsystem (super.c). No chance of breaking anything because kmem_cache_create_usercopy() with a non-zero whitelist only relaxes the hardened-usercopy check on specific offsets - it cannot produce new failures.
### PHASE 9: SYNTHESIS
**Evidence FOR backporting:**
- Fixes a kernel panic (BUG() from usercopy_abort()).
- 100% reproducible on orangefs + CONFIG_HARDENED_USERCOPY=y + kernel ≥5.16.
- Tiny, surgical 4-line change.
- Directly mirrors existing, established pattern in the same driver's super.c.
- Maintainer (Mike Marshall) has signed off.
- Matches precedent of 43e7e284fc77b (cifs) and 2a71a1a8d0ed7 (net sock) usercopy whitelist fixes that are stable material.
- Affected code has been in place since v4.6; bug exposure since v5.16 removed fallback.
**Evidence AGAINST backporting:**
- No Fixes:, no Cc: stable, no Reported-by: (typical for candidate review - not disqualifying).
- No public reviewer feedback captured (only v1, but maintainer SOB present).
- Commit not yet in mainline master (currently only in fs-next) - needs to land first; this is candidate pre-review.
- OrangeFS is niche; user population is small.
**Stable rules checklist:**
1. Obviously correct and tested? - Correct yes (mirrors super.c).
Tested: relies on author's testing; no explicit Tested-by, but very mechanical change.
2. Real bug? - YES, kernel panic.
3. Important? - YES, CRITICAL (panic).
4. Small/contained? - YES, +5/-1 in one function.
5. No new feature/API? - YES, purely a slab-config change.
6. Applies cleanly? - YES to ≥6.12; needs trivial flag adjustment for ≤6.6.
**Exception category:** Hardware/runtime quirk-equivalent for userspace API plumbing. Fixes a panic.
## Verification
- [Phase 1] Parsed tags: verified only SOB tags present (author + maintainer). No Fixes:, Cc: stable, Reported-by:, Link:.
- [Phase 1] Author verification: confirmed Mike Marshall's SOB indicates maintainer acceptance (he is the orangefs maintainer).
- [Phase 2] Diff inspection: confirmed +5/-1 lines in single function op_cache_initialize() of fs/orangefs/orangefs-cache.c.
- [Phase 2] Confirmed orangefs_devreq_read() at fs/orangefs/devorangefs-req.c:287-294 does copy_to_user(&cur_op->tag, sizeof(__u64)) and copy_to_user(&cur_op->upcall, sizeof(struct orangefs_upcall_s)) from slab memory.
- [Phase 2] Confirmed whitelist math: useroffset = offsetof(tag), usersize = offsetof(upcall) + sizeof(upcall) - offsetof(tag), which covers both copies (verified struct layout in fs/orangefs/orangefs- kernel.h:109-135).
- [Phase 2] Inspected mm/slub.c:8044 __check_heap_object():
confirmed it calls usercopy_abort() (which is __noreturn per mm/usercopy.c:86) when offset/size fall outside s->useroffset/s->usersize.
- [Phase 3] git log file history: verified op_cache = kmem_cache_create(...) pattern has been there since OrangeFS was added. Last change 3635d000f04b7 in v6.12 removed ORANGEFS_CACHE_CREATE_FLAGS.
- [Phase 3] git describe 575e946125f70 → v4.6-rc1 (confirms OrangeFS merge window).
- [Phase 3] git describe 53944f171a89d → v5.16-rc1 (confirms when strict enforcement began).
- [Phase 4] b4 dig -c f855f4ab123b2 -m /tmp/orangefs_thread.mbox:
found and saved the thread (lore URL: https://lore.kernel.org/all/2026
[email protected]/).
- [Phase 4] b4 dig -c ... -a: only v1 exists.
- [Phase 4] b4 dig -c ... -w: Maintainer Mike Marshall and co- maintainer Martin Brandenburg were CCed. [email protected] and linux-kernel were CCed.
- [Phase 4] Saved mbox: only the patch email; no public reply.
UNVERIFIED: Cannot independently fetch web view of lore thread (Anubis bot-challenge blocks WebFetch).
- [Phase 4] Cross-ref: verified similar fixes 43e7e284fc77b (cifs) and 2a71a1a8d0ed7 (net) exist and address same BUG() class.
- [Phase 5] grep + Read verified orangefs_inode_cache in fs/orangefs/super.c:642 already uses kmem_cache_create_usercopy()
- confirming the pattern is accepted.
- [Phase 5] Reachability: orangefs_devreq_read is reached from a userspace read() on /dev/pvfs2-req. Triggered on every upcall read by pvfs2-client-core.
- [Phase 6] git show <branch>:fs/orangefs/orangefs-cache.c for stable- push 5.10, 5.15, 6.1, 6.6, 6.12, 6.17, 6.18, 6.19: verified buggy kmem_cache_create("orangefs_op_cache", ...) is present in all of them.
- [Phase 6] Verified 43e7e284fc77b cifs fix was backported (87dcc7e33fc3d in 6.12.y) - confirms precedent.
- [Phase 7] Subsystem context: verified Mike Marshall is orangefs maintainer; fs/orangefs/ has low churn.
- [Phase 8] Failure mode: confirmed usercopy_abort is __noreturn → BUG() → panic. Severity CRITICAL verified.
- [Phase 9] Commit is in fs-next only, not yet in master. UNVERIFIED at this moment: final upstream landing SHA (will be assigned when Torvalds pulls).
- UNVERIFIED: No public reviewer response could be retrieved (lore Anubis challenge). Maintainer SOB is the primary acceptance signal.
- UNVERIFIED: No direct user bug report or Reported-by reference; impact assessment rests on code analysis, not a real-world crash log.
## Decision
This is a textbook stable candidate: a 4-line, obviously-correct, low- risk change that fixes a guaranteed kernel panic on any system running OrangeFS with CONFIG_HARDENED_USERCOPY=y (very common in modern distros) on kernels ≥ v5.16. The fix mirrors the existing whitelist already present on orangefs_inode_cache in the same driver, and follows precedent of recently-backported identical-class fixes (cifs smbd_response, net sock_recv_errqueue). Backport needs at most a trivial 0 → ORANGEFS_CACHE_CREATE_FLAGS adjustment for stable ≤6.6. Benefit clearly outweighs risk.
**YES**
fs/orangefs/orangefs-cache.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/orangefs/orangefs-cache.c +5 -1
@@ -19,10 +19,14 @@ static struct kmem_cache *op_cache;int op_cache_initialize (void ) { - op_cache =kmem_cache_create ("orangefs_op_cache" , + op_cache =kmem_cache_create_usercopy ("orangefs_op_cache" ,sizeof (struct orangefs_kernel_op_s ),0 ,0 , + offsetof(struct orangefs_kernel_op_s , tag), + offsetof(struct orangefs_kernel_op_s , upcall) + +sizeof (struct orangefs_upcall_s ) - + offsetof(struct orangefs_kernel_op_s , tag),NULL );if (!op_cache) {
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ice: ptp: don't WARN when controlling PF is unavailable
In reply to Sasha LevinFrom: Kohei Enju <[email protected]>
[ Upstream commit bb3f21edc7056cdf44a7f7bd7ba65af40741838c ]
In VFIO passthrough setups, it is possible to pass through only a PF which doesn't own the source timer. In that case the PTP controlling PF (adapter->ctrl_pf) is never initialized in the VM, so ice_get_ctrl_ptp() returns NULL and triggers WARN_ON() in ice_ptp_setup_pf().
Since this is an expected behavior in that configuration, replace WARN_ON() with an informational message and return -EOPNOTSUPP.
---
LLM Generated explanations, may be completely bogus:
Error: Failed to generate final synthesis
drivers/net/ethernet/intel/ice/ice_ptp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +7 -1
@@ -3041,7 +3041,13 @@ static int ice_ptp_setup_pf(struct ice_pf *pf)struct ice_ptp *ctrl_ptp =ice_get_ctrl_ptp (pf);struct ice_ptp *ptp = &pf->ptp; -if (WARN_ON (!ctrl_ptp) || pf->hw.mac_type ==ICE_MAC_UNKNOWN ) +if (!ctrl_ptp) { +dev_info (ice_pf_to_dev (pf), +"PTP unavailable: no controlling PF\n" ); +return -EOPNOTSUPP ; + } + +if (pf->hw.mac_type ==ICE_MAC_UNKNOWN )return -ENODEV ;INIT_LIST_HEAD (&ptp->port.list_node);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 e1000: check return value of e1000_read_eeprom
In reply to Sasha LevinFrom: Agalakov Daniil <[email protected]>
[ Upstream commit d3baa34a470771399c1495bc04b1e26ac15d598e ]
[Why]e1000_set_eeprom() performs a read-modify-write operation when the write range is not word-aligned. This requires reading the first and last words of the range from the EEPROM to preserve the unmodified bytes.
However, the code does not check the return value of e1000_read_eeprom(). If the read fails, the operation continues using uninitialized data from eeprom_buff. This results in corrupted data being written back to the EEPROM for the boundary words.
Add the missing error checks and abort the operation if reading fails.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
---
LLM Generated explanations, may be completely bogus:
Error: Failed to generate final synthesis
drivers/net/ethernet/intel/e1000/e1000_ethtool.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/e1000/e1000_ethtool.c +7 -1
@@ -496,14 +496,19 @@ static int e1000_set_eeprom(struct net_device *netdev,*/ ret_val =e1000_read_eeprom (hw, first_word,1 , &eeprom_buff[0 ]); +if (ret_val) + goto out; + ptr++; } -if (((eeprom->offset + eeprom->len) &1 ) && (ret_val ==0 )) { +if ((eeprom->offset + eeprom->len) &1 ) {/* need read/modify/write of last changed EEPROM word * only the first byte of the word is being modified */ ret_val =e1000_read_eeprom (hw, last_word,1 , &eeprom_buff[last_word - first_word]); +if (ret_val) + goto out; }/* Device's eeprom is always little-endian, word addressable */
@@ -522,6 +527,7 @@ static int e1000_set_eeprom(struct net_device *netdev,if ((ret_val ==0 ) && (first_word <=EEPROM_CHECKSUM_REG ))e1000_update_eeprom_checksum (hw); +out:kfree (eeprom_buff);return ret_val; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: usb-audio: Add quirks for Arturia AF16Rig
In reply to Sasha LevinFrom: Phil Willoughby <[email protected]>
[ Upstream commit 0da18c2dd1cc2a026416222ed206e2f269edf055 ]
The AF16Rig supports 34 channels at 44.1k/48k, 18 channels at 88.2k/96k and 10 channels at 176.4k/192k.
This quirks is necessary because the automatic probing process we would otherwise use fails. The root cause of that is that the AF16Rig clock is not readable (its descriptor says that it is but the reads fail).
Except as described below, the values in the audio format quirks were copied from the USB descriptors of the device. The rate information is from the datasheet of the device. The clock is the internal clock of the AF16Rig.
I have tested all the configurations enabled by this patch.
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed for a thorough analysis. Let me compile the findings.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: Subject Line
- **Subsystem:** ALSA: usb-audio
- **Action verb:** "Add" (quirks)
- **Summary:** Adds USB audio quirks for the Arturia AF16Rig device
### Step 1.2: Tags
- **Tested-By:** Phil Willoughby <[email protected]> — the author tested all configurations
- **Cc:** Jaroslav Kysela (ALSA maintainer), Takashi Iwai (ALSA/USB- audio maintainer)
- **Signed-off-by:** Phil Willoughby (author), Takashi Iwai (maintainer, applied the patch)
- **Link:**
https://patch.msgid.link/[email protected]
- No Fixes: tag (expected for quirk additions)
- No Cc: stable (expected — that's why we're reviewing)
### Step 1.3: Commit Body
The commit explains that the AF16Rig supports multiple channel/rate configurations ([email protected]/48k, [email protected]/96k, [email protected]/192k). The **root cause is that the AF16Rig clock is broken** — its USB descriptor claims the clock is readable but reads fail, which causes the automatic probing process to fail entirely. Without this quirk, the device simply does not work.
### Step 1.4: Hidden Bug Fix Detection
This IS a hardware workaround for a broken device. The device's USB descriptors are incorrect (clock readability is falsely advertised), causing the standard enumeration path to fail. This is the textbook definition of a USB audio device quirk.
## PHASE 2: DIFF ANALYSIS
### Step 2.1: Inventory
- **Files changed:** 1 file (sound/usb/quirks-table.h)
- **Lines added:** ~165 lines (purely data — struct initializers in the quirk table)
- **Lines removed:** 0
- **Scope:** Single-file, data-only addition to an existing quirk table
### Step 2.2: Code Flow Change
The patch adds a new entry to the USB audio quirks table for USB VID:PID 0x1c75:0xaf20. It defines:
- 1 standard mixer interface (interface 0)
- 3 playback audio format configurations (interface 1) for different sample rates
- 3 capture audio format configurations (interface 2) for the same rates
- 1 ignored interface (interface 3, firmware update)
The entry is inserted between the last QUIRK_RME_DIGIFACE entry and the #undef lines at the end of the file.
### Step 2.3: Bug Mechanism
Category: **Hardware workaround (h)**. The device has a broken clock descriptor — it claims the clock is readable but reads fail. This prevents the standard UAC2 enumeration from working. The quirk bypasses automatic probing by providing the correct audio format information directly.
### Step 2.4: Fix Quality
- All macros used (QUIRK_DATA_AUDIOFORMAT, QUIRK_DATA_COMPOSITE, QUIRK_DRIVER_INFO, QUIRK_DATA_STANDARD_MIXER, QUIRK_DATA_IGNORE, QUIRK_COMPOSITE_END) are already defined in the same file (verified at lines 41, 49, 58, 72, 78, 87)
- Pure data — no logic changes, no control flow changes
- Only affects the specific USB device 0x1c75:0xaf20
- Zero regression risk for any other device or code path
- Author tested all configurations enabled by the patch
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: Blame
The insertion point is at the end of the quirks table after the RME Digiface entries. The macros were introduced by 0c3ad39b791c2 ("Define macros for quirk table entries") and d79e13f8e8abb ("Replace complex quirk lines with macros"), both of which are present in this tree.
### Step 3.2: Fixes Tag
No Fixes: tag — this is a new device quirk, not a fix for a specific regression.
### Step 3.3: File History
The file has a long history of similar quirk additions: Pioneer DJ DJM-V10, RME Digiface USB, Pioneer DDJ-800, Mythware XA001AU, Mbox3, etc. This is a well-established pattern.
### Step 3.4: Author
Phil Willoughby also contributed bc5b4e5ae1a67 ("Fix quirk flags for NeuralDSP Quad Cortex") around the same date, showing familiarity with the USB audio quirk system.
### Step 3.5: Dependencies
The patch uses macros already present in the stable tree. No prerequisite commits are needed. The insertion point (QUIRK_RME_DIGIFACE(0x3fa0) followed by #undef) exists at lines 3901-3903, confirming clean applicability.
## PHASE 4: MAILING LIST RESEARCH
### Step 4.1-4.5
b4 dig could not find the commit (it's not yet in the tree we're on). Lore was blocked by anti-bot protection. However, the commit message includes a Link to the patch submission, and Takashi Iwai (the USB audio maintainer) signed off on it, confirming maintainer review and acceptance.
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1-5.5
This is purely a data table addition. There are no new functions, no logic changes, no callers/callees to trace. The quirk table is consumed by the existing USB audio driver infrastructure which already handles all the macros and format types used.
## PHASE 6: STABLE TREE ANALYSIS
### Step 6.1: Code Existence in Stable
The quirks table and all macros used exist in this 7.0 stable tree.
Verified: QUIRK_DATA_AUDIOFORMAT at line 87, QUIRK_DATA_COMPOSITE at line 78, QUIRK_DRIVER_INFO at line 41, etc.
### Step 6.2: Backport Complications
The patch should apply cleanly. The insertion point (between QUIRK_RME_DIGIFACE(0x3fa0), at line 3901 and #undef USB_DEVICE_VENDOR_SPEC at line 3903) is present and matches the diff context exactly.
### Step 6.3: Related Fixes
No prior fixes for AF16Rig exist — this is the first support entry.
## PHASE 7: SUBSYSTEM CONTEXT
### Step 7.1
- **Subsystem:** sound/usb (USB audio drivers)
- **Criticality:** IMPORTANT — USB audio is used by musicians, content creators, and professionals who rely on specific hardware
### Step 7.2
Active subsystem with regular quirk additions (verified: 10+ recent commits adding device quirks).
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: Who is Affected
Users of the Arturia AF16Rig USB audio interface. Without this quirk, the device is **completely non-functional** under Linux.
### Step 8.2: Trigger Conditions
Every time the device is plugged in. The broken clock descriptor causes enumeration failure immediately.
### Step 8.3: Failure Mode
Without quirk: Device probing fails, no audio functionality at all. **Severity: HIGH** (total device failure).
### Step 8.4: Risk-Benefit
- **Benefit:** HIGH — enables a professional audio device that is otherwise non-functional
- **Risk:** VERY LOW — pure data addition to a quirk table, device- specific, affects no other hardware, uses existing macros, tested by the author
- **Ratio:** Strongly favorable
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: Evidence Summary
**FOR backporting:**
- Hardware quirk/workaround for a broken device (clock descriptor lie)
- Pure data addition, no logic changes
- Zero regression risk for any other device
- Uses macros already present in stable
- Tested by the author on all configurations
- Accepted by subsystem maintainer (Takashi Iwai)
- Well-established pattern (dozens of similar entries in the same file)
- Falls squarely into the "QUIRKS and WORKAROUNDS" exception category
**AGAINST backporting:**
- Large (~165 lines), though entirely data
- New device support rather than fixing a regression in existing support
### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **YES** — data copied from USB descriptors, tested by author
2. Fixes a real bug? **YES** — device completely non-functional without it (broken clock descriptor)
3. Important issue? **YES** — total hardware failure for users of this device
4. Small and contained? **YES** — single file, data-only, device- specific
5. No new features or APIs? **YES** — no new APIs, just quirk data
6. Can apply to stable? **YES** — insertion point and all macros exist
### Step 9.3: Exception Category
**Hardware quirk/workaround** — this is explicitly listed as a YES-by- default category in the stable kernel rules analysis.
## Verification
- [Phase 1] Parsed tags: Tested-by from author, Signed-off-by from maintainer Takashi Iwai
- [Phase 2] Diff analysis: ~165 lines of struct initializer data added to quirks-table.h; zero logic changes
- [Phase 2] Verified all macros used: QUIRK_DATA_AUDIOFORMAT (line 87), QUIRK_DATA_COMPOSITE (line 78), QUIRK_DRIVER_INFO (line 41), QUIRK_DATA_STANDARD_MIXER (line 58), QUIRK_DATA_IGNORE (line 49), QUIRK_COMPOSITE_END (line 72)
- [Phase 3] git log --oneline -20 -- sound/usb/quirks-table.h: confirmed long history of similar quirk additions
- [Phase 3] git show bc5b4e5ae1a67: confirmed author has other USB audio work (NeuralDSP fix)
- [Phase 4] b4 dig failed to find match (commit not in tree); lore blocked by anti-bot; maintainer sign-off confirmed from commit metadata
- [Phase 5] No functions to trace — pure data table entry
- [Phase 6] Verified insertion point exists at lines 3901-3903 (QUIRK_RME_DIGIFACE followed by #undef); patch should apply cleanly
- [Phase 6] Verified Arturia VID 0x1c75 has no existing entries (grep returned no matches)
- [Phase 7] Subsystem is actively maintained with regular quirk additions
- [Phase 8] Failure mode: complete device non-functionality; severity HIGH; risk VERY LOW (data-only, device-specific)
- UNVERIFIED: Could not access mailing list discussion due to anti-bot protection; relying on maintainer sign-off as evidence of review
This is a textbook USB audio device quirk addition. The Arturia AF16Rig has a broken clock descriptor that prevents standard enumeration, making the device completely non-functional without this quirk. The patch is pure data, uses existing macros, and affects only the specific device. It carries essentially zero regression risk.
**YES**
sound/usb/quirks-table.h | 165 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+)
sound/usb/quirks-table.h +165 -0
@@ -3900,5 +3900,170 @@ YAMAHA_DEVICE(0x7010, "UB99"), QUIRK_RME_DIGIFACE(0x3f8c), QUIRK_RME_DIGIFACE(0x3fa0), +/* Arturia AudioFuse 16Rig Audio */ +/* AF16Rig MIDI has USB PID 0xaf21 and appears to work OK without quirks */ +{ + USB_DEVICE(0x1c75, 0xaf20), + QUIRK_DRIVER_INFO { + .vendor_name = "Arturia", + .product_name = "AF16Rig", + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_MIXER(0) }, + { + QUIRK_DATA_AUDIOFORMAT(1) { /* Playback */ + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 34, + .fmt_type = UAC_FORMAT_TYPE_I_PCM, + .fmt_bits = 24, + .fmt_sz = 4, + .iface = 1, + .altsetting = 1, + .altset_idx = 1, + .endpoint = 0x01, + .ep_attr = USB_ENDPOINT_XFER_ISOC| + USB_ENDPOINT_SYNC_ASYNC, + .datainterval = 1, + .protocol = UAC_VERSION_2, + .maxpacksize = 0x03b8, + .rates = SNDRV_PCM_RATE_44100| + SNDRV_PCM_RATE_48000, + .rate_min = 44100, + .rate_max = 48000, + .nr_rates = 2, + .rate_table = (unsigned int[]) { 44100, 48000 }, + .clock = 41, + } + }, + { + QUIRK_DATA_AUDIOFORMAT(1) { /* Playback */ + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 18, + .fmt_type = UAC_FORMAT_TYPE_I_PCM, + .fmt_bits = 24, + .fmt_sz = 4, + .iface = 1, + .altsetting = 1, + .altset_idx = 1, + .endpoint = 0x01, + .ep_attr = USB_ENDPOINT_XFER_ISOC| + USB_ENDPOINT_SYNC_ASYNC, + .datainterval = 1, + .protocol = UAC_VERSION_2, + .maxpacksize = 0x03a8, + .rates = SNDRV_PCM_RATE_88200| + SNDRV_PCM_RATE_96000, + .rate_min = 88200, + .rate_max = 96000, + .nr_rates = 2, + .rate_table = (unsigned int[]) { 88200, 96000 }, + .clock = 41, + } + }, + { + QUIRK_DATA_AUDIOFORMAT(1) { /* Playback */ + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 10, + .fmt_type = UAC_FORMAT_TYPE_I_PCM, + .fmt_bits = 24, + .fmt_sz = 4, + .iface = 1, + .altsetting = 3, + .altset_idx = 3, + .endpoint = 0x01, + .ep_attr = USB_ENDPOINT_XFER_ISOC| + USB_ENDPOINT_SYNC_ASYNC, + .datainterval = 1, + .protocol = UAC_VERSION_2, + .maxpacksize = 0x03e8, + .rates = SNDRV_PCM_RATE_176400| + SNDRV_PCM_RATE_192000, + .rate_min = 176400, + .rate_max = 192000, + .nr_rates = 2, + .rate_table = (unsigned int[]) { 176400, 192000 }, + .clock = 41, + } + }, + { + QUIRK_DATA_AUDIOFORMAT(2) { /* Capture */ + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 34, + .fmt_type = UAC_FORMAT_TYPE_I_PCM, + .fmt_bits = 24, + .fmt_sz = 4, + .iface = 2, + .altsetting = 1, + .altset_idx = 1, + .endpoint = 0x81, + .ep_attr = USB_ENDPOINT_XFER_ISOC| + USB_ENDPOINT_SYNC_ASYNC, + .datainterval = 1, + .protocol = UAC_VERSION_2, + .maxpacksize = 0x03b8, + .rates = SNDRV_PCM_RATE_44100| + SNDRV_PCM_RATE_48000, + .rate_min = 44100, + .rate_max = 48000, + .nr_rates = 2, + .rate_table = (unsigned int[]) { 44100, 48000 }, + .clock = 41, + } + }, + { + QUIRK_DATA_AUDIOFORMAT(2) { /* Capture */ + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 18, + .fmt_type = UAC_FORMAT_TYPE_I_PCM, + .fmt_bits = 24, + .fmt_sz = 4, + .iface = 2, + .altsetting = 2, + .altset_idx = 2, + .endpoint = 0x81, + .ep_attr = USB_ENDPOINT_XFER_ISOC| + USB_ENDPOINT_SYNC_ASYNC, + .datainterval = 1, + .protocol = UAC_VERSION_2, + .maxpacksize = 0x03a8, + .rates = SNDRV_PCM_RATE_88200| + SNDRV_PCM_RATE_96000, + .rate_min = 88200, + .rate_max = 96000, + .nr_rates = 2, + .rate_table = (unsigned int[]) { 88200, 96000 }, + .clock = 41, + } + }, + { + QUIRK_DATA_AUDIOFORMAT(2) { /* Capture */ + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 10, + .fmt_type = UAC_FORMAT_TYPE_I_PCM, + .fmt_bits = 24, + .fmt_sz = 4, + .iface = 2, + .altsetting = 3, + .altset_idx = 3, + .endpoint = 0x81, + .ep_attr = USB_ENDPOINT_XFER_ISOC| + USB_ENDPOINT_SYNC_ASYNC, + .datainterval = 1, + .protocol = UAC_VERSION_2, + .maxpacksize = 0x03e8, + .rates = SNDRV_PCM_RATE_176400| + SNDRV_PCM_RATE_192000, + .rate_min = 176400, + .rate_max = 192000, + .nr_rates = 2, + .rate_table = (unsigned int[]) { 176400, 192000 }, + .clock = 41, + } + }, + { QUIRK_DATA_IGNORE(3) }, /* Firmware update */ + QUIRK_COMPOSITE_END + } + } +}, + #undef USB_DEVICE_VENDOR_SPEC #undef USB_AUDIO_DEVICE
Signature · 1 line
2.53.0
Re: [PATCH AUTOSEL 7.0-6.19] ALSA: usb-audio: Add quirks for Arturia AF16Rig
AF16Rig support also needs the patch to increase the channel limit in
https://lore.kernel.org/linux-sound/[email protected]/ I have not tested what happens without that change also being present but I suspect it would mean that the AF16Rig still would not function.
Quoted 451 lines · Sasha Levin
From: Phil Willoughby <[email protected]>
[ Upstream commit
0da18c2dd1cc2a026416222ed206e2f269edf055]The AF16Rig supports 34 channels at 44.1k/48k, 18 channels at 88.2k/96k and 10 channels at 176.4k/192k.
This quirks is necessary because the automatic probing process we would otherwise use fails. The root cause of that is that the AF16Rig clock is not readable (its descriptor says that it is but the reads fail).
Except as described below, the values in the audio format quirks were copied from the USB descriptors of the device. The rate information is from the datasheet of the device. The clock is the internal clock of the AF16Rig.
Tested-by Phil Willoughby <[email protected]>I have tested all the configurations enabled by this patch.
Cc Jaroslav Kysela <[email protected]>Cc Takashi Iwai <[email protected]>Signed-off-by Phil Willoughby <[email protected]>Signed-off-by Takashi Iwai <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed for a thorough analysis. Let me compile the findings.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: Subject Line
- **Subsystem:** ALSA: usb-audio
- **Action verb:** "Add" (quirks)
- **Summary:** Adds USB audio quirks for the Arturia AF16Rig device### Step 1.2: Tags
- **Tested-By:** Phil Willoughby <[email protected]> — the author tested all configurations
- **Cc:** Jaroslav Kysela (ALSA maintainer), Takashi Iwai (ALSA/USB- audio maintainer)
- **Signed-off-by:** Phil Willoughby (author), Takashi Iwai (maintainer, applied the patch)
- **Link:**
https://patch.msgid.link/[email protected]
- No Fixes: tag (expected for quirk additions)
- No Cc: stable (expected — that's why we're reviewing)### Step 1.3: Commit Body
The commit explains that the AF16Rig supports multiple channel/rate configurations ([email protected]/48k, [email protected]/96k, [email protected]/192k). The **root cause is that the AF16Rig clock is broken** — its USB descriptor claims the clock is readable but reads fail, which causes the automatic probing process to fail entirely. Without this quirk, the device simply does not work.### Step 1.4: Hidden Bug Fix Detection
This IS a hardware workaround for a broken device. The device's USB descriptors are incorrect (clock readability is falsely advertised), causing the standard enumeration path to fail. This is the textbook definition of a USB audio device quirk.## PHASE 2: DIFF ANALYSIS
### Step 2.1: Inventory
- **Files changed:** 1 file (sound/usb/quirks-table.h)
- **Lines added:** ~165 lines (purely data — struct initializers in the quirk table)
- **Lines removed:** 0
- **Scope:** Single-file, data-only addition to an existing quirk table### Step 2.2: Code Flow Change
The patch adds a new entry to the USB audio quirks table for USB VID:PID0x1c75:0xaf20. It defines:
- 1 standard mixer interface (interface 0)
- 3 playback audio format configurations (interface 1) for different sample rates
- 3 capture audio format configurations (interface 2) for the same rates
- 1 ignored interface (interface 3, firmware update)The entry is inserted between the last
QUIRK_RME_DIGIFACEentry and the#undeflines at the end of the file.### Step 2.3: Bug Mechanism
Category: **Hardware workaround (h)**. The device has a broken clock descriptor — it claims the clock is readable but reads fail. This prevents the standard UAC2 enumeration from working. The quirk bypasses automatic probing by providing the correct audio format information directly.### Step 2.4: Fix Quality
- All macros used (QUIRK_DATA_AUDIOFORMAT,QUIRK_DATA_COMPOSITE,QUIRK_DRIVER_INFO,QUIRK_DATA_STANDARD_MIXER,QUIRK_DATA_IGNORE,QUIRK_COMPOSITE_END) are already defined in the same file (verified at lines 41, 49, 58, 72, 78, 87)
- Pure data — no logic changes, no control flow changes
- Only affects the specific USB device0x1c75:0xaf20
- Zero regression risk for any other device or code path
- Author tested all configurations enabled by the patch## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: Blame
The insertion point is at the end of the quirks table after the RME Digiface entries. The macros were introduced by0c3ad39b791c2("Define macros for quirk table entries") andd79e13f8e8abb("Replace complex quirk lines with macros"), both of which are present in this tree.### Step 3.2: Fixes Tag
No Fixes: tag — this is a new device quirk, not a fix for a specific regression.### Step 3.3: File History
The file has a long history of similar quirk additions: Pioneer DJ DJM-V10, RME Digiface USB, Pioneer DDJ-800, Mythware XA001AU, Mbox3, etc. This is a well-established pattern.### Step 3.4: Author
Phil Willoughby also contributedbc5b4e5ae1a67("Fix quirk flags for NeuralDSP Quad Cortex") around the same date, showing familiarity with the USB audio quirk system.### Step 3.5: Dependencies
The patch uses macros already present in the stable tree. No prerequisite commits are needed. The insertion point (QUIRK_RME_DIGIFACE(0x3fa0)followed by#undef) exists at lines 3901-3903, confirming clean applicability.## PHASE 4: MAILING LIST RESEARCH
### Step 4.1-4.5
b4 dig could not find the commit (it's not yet in the tree we're on). Lore was blocked by anti-bot protection. However, the commit message includes a Link to the patch submission, and Takashi Iwai (the USB audio maintainer) signed off on it, confirming maintainer review and acceptance.## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1-5.5
This is purely a data table addition. There are no new functions, no logic changes, no callers/callees to trace. The quirk table is consumed by the existing USB audio driver infrastructure which already handles all the macros and format types used.## PHASE 6: STABLE TREE ANALYSIS
### Step 6.1: Code Existence in Stable
The quirks table and all macros used exist in this 7.0 stable tree.
Verified:QUIRK_DATA_AUDIOFORMATat line 87,QUIRK_DATA_COMPOSITEat line 78,QUIRK_DRIVER_INFOat line 41, etc.### Step 6.2: Backport Complications
The patch should apply cleanly. The insertion point (betweenQUIRK_RME_DIGIFACE(0x3fa0),at line 3901 and#undef USB_DEVICE_VENDOR_SPECat line 3903) is present and matches the diff context exactly.### Step 6.3: Related Fixes
No prior fixes for AF16Rig exist — this is the first support entry.## PHASE 7: SUBSYSTEM CONTEXT
### Step 7.1
- **Subsystem:**sound/usb(USB audio drivers)
- **Criticality:** IMPORTANT — USB audio is used by musicians, content creators, and professionals who rely on specific hardware### Step 7.2
Active subsystem with regular quirk additions (verified: 10+ recent commits adding device quirks).## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: Who is Affected
Users of the Arturia AF16Rig USB audio interface. Without this quirk, the device is **completely non-functional** under Linux.### Step 8.2: Trigger Conditions
Every time the device is plugged in. The broken clock descriptor causes enumeration failure immediately.### Step 8.3: Failure Mode
Without quirk: Device probing fails, no audio functionality at all. **Severity: HIGH** (total device failure).### Step 8.4: Risk-Benefit
- **Benefit:** HIGH — enables a professional audio device that is otherwise non-functional
- **Risk:** VERY LOW — pure data addition to a quirk table, device- specific, affects no other hardware, uses existing macros, tested by the author
- **Ratio:** Strongly favorable## PHASE 9: FINAL SYNTHESIS
### Step 9.1: Evidence Summary
**FOR backporting:**
- Hardware quirk/workaround for a broken device (clock descriptor lie)
- Pure data addition, no logic changes
- Zero regression risk for any other device
- Uses macros already present in stable
- Tested by the author on all configurations
- Accepted by subsystem maintainer (Takashi Iwai)
- Well-established pattern (dozens of similar entries in the same file)
- Falls squarely into the "QUIRKS and WORKAROUNDS" exception category**AGAINST backporting:**
- Large (~165 lines), though entirely data
- New device support rather than fixing a regression in existing support### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **YES** — data copied from USB descriptors, tested by author
2. Fixes a real bug? **YES** — device completely non-functional without it (broken clock descriptor)
3. Important issue? **YES** — total hardware failure for users of this device
4. Small and contained? **YES** — single file, data-only, device- specific
5. No new features or APIs? **YES** — no new APIs, just quirk data
6. Can apply to stable? **YES** — insertion point and all macros exist### Step 9.3: Exception Category
**Hardware quirk/workaround** — this is explicitly listed as a YES-by- default category in the stable kernel rules analysis.## Verification
- [Phase 1] Parsed tags: Tested-by from author, Signed-off-by from maintainer Takashi Iwai
- [Phase 2] Diff analysis: ~165 lines of struct initializer data added toquirks-table.h; zero logic changes
- [Phase 2] Verified all macros used:QUIRK_DATA_AUDIOFORMAT(line 87),QUIRK_DATA_COMPOSITE(line 78),QUIRK_DRIVER_INFO(line 41),QUIRK_DATA_STANDARD_MIXER(line 58),QUIRK_DATA_IGNORE(line 49),QUIRK_COMPOSITE_END(line 72)
- [Phase 3] git log --oneline -20 --sound/usb/quirks-table.h: confirmed long history of similar quirk additions
- [Phase 3] git showbc5b4e5ae1a67: confirmed author has other USB audio work (NeuralDSP fix)
- [Phase 4] b4 dig failed to find match (commit not in tree); lore blocked by anti-bot; maintainer sign-off confirmed from commit metadata
- [Phase 5] No functions to trace — pure data table entry
- [Phase 6] Verified insertion point exists at lines 3901-3903 (QUIRK_RME_DIGIFACEfollowed by #undef); patch should apply cleanly
- [Phase 6] Verified Arturia VID0x1c75has no existing entries (grep returned no matches)
- [Phase 7] Subsystem is actively maintained with regular quirk additions
- [Phase 8] Failure mode: complete device non-functionality; severity HIGH; risk VERY LOW (data-only, device-specific)
- UNVERIFIED: Could not access mailing list discussion due to anti-bot protection; relying on maintainer sign-off as evidence of reviewThis is a textbook USB audio device quirk addition. The Arturia AF16Rig has a broken clock descriptor that prevents standard enumeration, making the device completely non-functional without this quirk. The patch is pure data, uses existing macros, and affects only the specific device. It carries essentially zero regression risk.
**YES**
sound/usb/quirks-table.h | 165 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+)sound/usb/quirks-table.h +165
-1@@ -3900,5 +3900,170 @@ YAMAHA_DEVICE(0x7010, "UB99"), QUIRK_RME_DIGIFACE(0x3f8c), QUIRK_RME_DIGIFACE(0x3fa0), +/* Arturia AudioFuse 16Rig Audio */ +/* AF16Rig MIDI has USB PID 0xaf21 and appears to work OK without quirks */ +{ + USB_DEVICE(0x1c75, 0xaf20), + QUIRK_DRIVER_INFO { + .vendor_name = "Arturia", + .product_name = "AF16Rig", + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_MIXER(0) }, + { + QUIRK_DATA_AUDIOFORMAT(1) { /* Playback */ + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 34, + .fmt_type = UAC_FORMAT_TYPE_I_PCM, + .fmt_bits = 24, + .fmt_sz = 4, + .iface = 1, + .altsetting = 1, + .altset_idx = 1, + .endpoint = 0x01, + .ep_attr = USB_ENDPOINT_XFER_ISOC| + USB_ENDPOINT_SYNC_ASYNC, + .datainterval = 1, + .protocol = UAC_VERSION_2, + .maxpacksize = 0x03b8, + .rates = SNDRV_PCM_RATE_44100| + SNDRV_PCM_RATE_48000, + .rate_min = 44100, + .rate_max = 48000, + .nr_rates = 2, + .rate_table = (unsigned int[]) { 44100, 48000 }, + .clock = 41, + } + }, + { + QUIRK_DATA_AUDIOFORMAT(1) { /* Playback */ + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 18, + .fmt_type = UAC_FORMAT_TYPE_I_PCM, + .fmt_bits = 24, + .fmt_sz = 4, + .iface = 1, + .altsetting = 1, + .altset_idx = 1, + .endpoint = 0x01, + .ep_attr = USB_ENDPOINT_XFER_ISOC| + USB_ENDPOINT_SYNC_ASYNC, + .datainterval = 1, + .protocol = UAC_VERSION_2, + .maxpacksize = 0x03a8, + .rates = SNDRV_PCM_RATE_88200| + SNDRV_PCM_RATE_96000, + .rate_min = 88200, + .rate_max = 96000, + .nr_rates = 2, + .rate_table = (unsigned int[]) { 88200, 96000 }, + .clock = 41, + } + }, + { + QUIRK_DATA_AUDIOFORMAT(1) { /* Playback */ + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 10, + .fmt_type = UAC_FORMAT_TYPE_I_PCM, + .fmt_bits = 24, + .fmt_sz = 4, + .iface = 1, + .altsetting = 3, + .altset_idx = 3, + .endpoint = 0x01, + .ep_attr = USB_ENDPOINT_XFER_ISOC| + USB_ENDPOINT_SYNC_ASYNC, + .datainterval = 1, + .protocol = UAC_VERSION_2, + .maxpacksize = 0x03e8, + .rates = SNDRV_PCM_RATE_176400| + SNDRV_PCM_RATE_192000, + .rate_min = 176400, + .rate_max = 192000, + .nr_rates = 2, + .rate_table = (unsigned int[]) { 176400, 192000 }, + .clock = 41, + } + }, + { + QUIRK_DATA_AUDIOFORMAT(2) { /* Capture */ + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 34, + .fmt_type = UAC_FORMAT_TYPE_I_PCM, + .fmt_bits = 24, + .fmt_sz = 4, + .iface = 2, + .altsetting = 1, + .altset_idx = 1, + .endpoint = 0x81, + .ep_attr = USB_ENDPOINT_XFER_ISOC| + USB_ENDPOINT_SYNC_ASYNC, + .datainterval = 1, + .protocol = UAC_VERSION_2, + .maxpacksize = 0x03b8, + .rates = SNDRV_PCM_RATE_44100| + SNDRV_PCM_RATE_48000, + .rate_min = 44100, + .rate_max = 48000, + .nr_rates = 2, + .rate_table = (unsigned int[]) { 44100, 48000 }, + .clock = 41, + } + }, + { + QUIRK_DATA_AUDIOFORMAT(2) { /* Capture */ + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 18, + .fmt_type = UAC_FORMAT_TYPE_I_PCM, + .fmt_bits = 24, + .fmt_sz = 4, + .iface = 2, + .altsetting = 2, + .altset_idx = 2, + .endpoint = 0x81, + .ep_attr = USB_ENDPOINT_XFER_ISOC| + USB_ENDPOINT_SYNC_ASYNC, + .datainterval = 1, + .protocol = UAC_VERSION_2, + .maxpacksize = 0x03a8, + .rates = SNDRV_PCM_RATE_88200| + SNDRV_PCM_RATE_96000, + .rate_min = 88200, + .rate_max = 96000, + .nr_rates = 2, + .rate_table = (unsigned int[]) { 88200, 96000 }, + .clock = 41, + } + }, + { + QUIRK_DATA_AUDIOFORMAT(2) { /* Capture */ + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels = 10, + .fmt_type = UAC_FORMAT_TYPE_I_PCM, + .fmt_bits = 24, + .fmt_sz = 4, + .iface = 2, + .altsetting = 3, + .altset_idx = 3, + .endpoint = 0x81, + .ep_attr = USB_ENDPOINT_XFER_ISOC| + USB_ENDPOINT_SYNC_ASYNC, + .datainterval = 1, + .protocol = UAC_VERSION_2, + .maxpacksize = 0x03e8, + .rates = SNDRV_PCM_RATE_176400| + SNDRV_PCM_RATE_192000, + .rate_min = 176400, + .rate_max = 192000, + .nr_rates = 2, + .rate_table = (unsigned int[]) { 176400, 192000 }, + .clock = 41, + } + }, + { QUIRK_DATA_IGNORE(3) }, /* Firmware update */ + QUIRK_COMPOSITE_END + } + } +}, + #undef USB_DEVICE_VENDOR_SPEC #undef USB_AUDIO_DEVICE --2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: asihpi: detect truncated control names
In reply to Sasha LevinFrom: Pengpeng Hou <[email protected]>
[ Upstream commit 18d4969e22cc3ff738257e1d7738aafc65a6d2d2 ]
asihpi_ctl_init() builds mixer control names in the fixed 44-byte hpi_ctl->name buffer with sprintf().
This is not only a defensive cleanup. The current in-tree name tables and format strings can already exceed 44 bytes. For example,
"Bitstream 0 Internal 0 Monitor Playback Volume"
is 46 characters before the trailing NUL, so the current sprintf() call writes past the end of hpi_ctl->name.
The generated control name is used as the ALSA control element key, so blindly truncating it is not sufficient. Switch the formatting to snprintf() and emit an error if truncation happens, showing the truncated name while still keeping the write bounded to hpi_ctl->name.
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed for a complete analysis. Let me compile the findings.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1**: Subsystem: sound/pci/asihpi (ALSA PCI audio driver). Action verb: "detect" (but the real action is **fixing** a buffer overflow by bounding writes). Summary: Replaces unbounded sprintf() with bounded snprintf() on a fixed 44-byte buffer.
**Step 1.2**: Tags:
- Signed-off-by: Pengpeng Hou (author), Takashi Iwai (ALSA subsystem maintainer)
- Link:
https://patch.msgid.link/[email protected]
- No Fixes: tag, no Reported-by:, no Cc: stable (expected for manual review candidates)
**Step 1.3**: The commit body explicitly identifies a concrete buffer
overflow: the name "Bitstream 0 Internal 0 Monitor Playback Volume" is 46 characters + NUL = 47 bytes, exceeding the 44-byte hpi_ctl->name buffer. The sprintf() call writes past the end of the buffer. The fix bounds the write with snprintf() and emits an error on truncation.
**Step 1.4**: This is NOT a hidden bug fix — the commit message is clear that the current in-tree code overflows the buffer. It explicitly says "This is not only a defensive cleanup."
## PHASE 2: DIFF ANALYSIS
**Step 2.1**: Single file modified: sound/pci/asihpi/asihpi.c (+22, -14). Single function modified: asihpi_ctl_init(). Scope: surgical, single-function fix.
**Step 2.2**: Three sprintf() calls (one per branch of the if/else) are replaced with snprintf() using sizeof(hpi_ctl->name) as the bound. A new int len variable captures the return value, and a check at the end emits pr_err() if truncation occurred.
**Step 2.3**: Bug category: **Buffer overflow / out-of-bounds write**. The name buffer is defined as:
```1280:1280:sound/pci/asihpi/asihpi.c
char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; /* copied to
snd_ctl_elem_id.name[44]; */
```SNDRV_CTL_ELEM_ID_NAME_MAXLEN = 44. The longest possible generated name ("Bitstream 0 Internal 0 Monitor Playback Volume") = 46 chars + NUL = 47 bytes. The sprintf() writes 3 bytes past the end.
**Step 2.4**: Fix is obviously correct — snprintf() is a drop-in bounded replacement for sprintf(). No regression risk; the only behavioral change is that overflow is prevented and logged.
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1**: git blame shows the buggy sprintf() calls were introduced in commit 719f82d3987aad (Eliot Blennerhassett, 2010-04-21) — "ALSA: Add support of AudioScience ASI boards." This code has been present since ~v2.6.35, meaning the bug exists in **all** active stable trees.
**Step 3.2**: No Fixes: tag to follow.
**Step 3.3**: Recent history shows only cleanup/refactoring commits to this file. No intermediate fix for this specific buffer overflow. The patch is standalone.
**Step 3.4**: Author Pengpeng Hou has other commits that are buffer- safety/bounds-check fixes (e.g., NFC, networking). The patch was reviewed and requested in its final form by Takashi Iwai, the ALSA maintainer.
**Step 3.5**: No dependencies. The diff only changes sprintf→snprintf and adds a bounds check. The surrounding code is unchanged since 2010-2011 and exists identically in stable trees.
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1**: b4 dig found the thread at https://patch.msgid.link/[email protected]. The patch went through v1 → v2 → v3. Takashi Iwai reviewed v1/v2, confirmed the overflow is real ("if the string overflow can happen really, it's rather a bigger problem"), and explicitly requested the v3 revision with snprintf() + error reporting. He applied v3 with "Applied to for-next branch now."
**Step 4.2**: Takashi Iwai (ALSA maintainer) reviewed the patch. The linux-sound mailing list was CC'd.
**Step 4.3**: No external bug report — found via code inspection.
**Step 4.4**: Single standalone patch, not part of a series.
**Step 4.5**: No prior stable discussion found.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1**: Single function modified: asihpi_ctl_init().
**Step 5.2**: asihpi_ctl_init() is called from ~10 places:snd_asihpi_volume_new, snd_asihpi_level_new, snd_asihpi_meter_add, snd_asihpi_mux_new, snd_asihpi_cmode_new, snd_asihpi_tuner_new, etc. All called during mixer initialization in snd_card_asihpi_mixer_new().
**Step 5.3**: The function formats a control name and stores it in hpi_ctl->name, which is then used as the ALSA control element key via snd_control->name = hpi_ctl->name.
**Step 5.4**: The call chain is: PCI probe → snd_card_asihpi_mixer_new() → control type builders → asihpi_ctl_init(). The hpi_ctl struct is **stack-allocated** at line 2528:
```2528:2528:sound/pci/asihpi/asihpi.c
struct hpi_control hpi_ctl, prev_ctl;
```The name field is the **last field** of struct hpi_control, so the overflow writes past the struct into adjacent stack memory (potentially corrupting prev_ctl or other stack variables).
**Step 5.5**: The existing name tables contain entries like "Bitstream" (9 chars), "Internal" (8 chars), "BLU-Link" (8 chars). Combined with "Monitor Playback " (18 chars including trailing space) and control names like "Volume" (6 chars), several combinations can exceed 44 bytes.
## PHASE 6: STABLE TREE ANALYSIS
**Step 6.1**: The buggy code was introduced in 2010 (v2.6.35 era). It exists in all active stable trees. The asihpi_ctl_init() function has barely changed since then.
**Step 6.2**: The patch should apply cleanly — changes since v6.6 and v5.15 to this file are minor cleanups that don't touch this function. The only relevant nearby change was 1882c12ae2ab0 (strscpy instead of strcpy in a different function).
**Step 6.3**: No related fix already in stable for this specific buffer overflow.
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1**: Subsystem: ALSA PCI audio driver (asihpi). Criticality:
PERIPHERAL — this is a specific hardware driver for AudioScience ASI boards. However, buffer overflows in any driver are security-relevant.
**Step 7.2**: The driver receives occasional maintenance (last few changes are cleanups and minor fixes). It's a mature, low-activity driver.
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1**: Users of AudioScience ASI audio hardware are affected. This is niche professional audio hardware, but users who have it depend on this driver.
**Step 8.2**: Trigger requires specific hardware/firmware configuration where source and destination nodes produce a name exceeding 44 bytes. The maintainer noted the specific overflow case "didn't happen in reality" with existing firmware, but it's a latent overflow that exists with the current in-tree string tables.
**Step 8.3**: Failure mode: **Stack buffer overflow** — the name field is at the end of a stack-allocated struct. The overflow corrupts adjacent stack memory. Potential consequences: stack corruption, crash, or undefined behavior. Severity: **HIGH** (buffer overflow, potential crash or security impact).
**Step 8.4**:
- **Benefit**: Prevents a proven buffer overflow that can occur with in- tree string values. Low practical frequency, but consequences are severe (stack corruption).
- **Risk**: Very low. The change is sprintf() → snprintf() + bounds check. No behavioral change for names that fit. Adds an error log for names that don't.
- **Ratio**: Favorable — very low risk for meaningful safety improvement.
## PHASE 9: FINAL SYNTHESIS
**Evidence FOR backporting**:
- Fixes a real buffer overflow: sprintf() can write past the end of a 44-byte buffer
- The overflow is provable from in-tree code (commit message gives a concrete 46-char example)
- Stack-allocated buffer → stack corruption risk
- Fix is minimal (single function, +22/-14 lines), obviously correct
- Reviewed and applied by Takashi Iwai (ALSA subsystem maintainer)
- Patch went through 3 revisions with maintainer feedback
- Bug exists in all stable trees (code from 2010)
- Patch should apply cleanly
**Evidence AGAINST backporting**:
- Niche hardware driver (AudioScience ASI boards)
- Practical trigger depends on specific firmware/hardware configuration
- Maintainer noted the overflow "didn't happen in reality" with current firmware
- No crash reports from users
**Stable rules checklist**:
1. Obviously correct and tested? **YES** — simple sprintf→snprintf
2. Fixes a real bug? **YES** — proven buffer overflow with in-tree strings
3. Important issue? **YES** — buffer overflow / stack corruption
4. Small and contained? **YES** — single function, single file
5. No new features? **YES** — purely a bug fix
6. Can apply to stable? **YES** — code unchanged since 2010
## Verification
- [Phase 1] Parsed commit message: identifies 46-char control name that overflows 44-byte buffer
- [Phase 2] Diff analysis: 3 sprintf() → snprintf() conversions + truncation check in asihpi_ctl_init()
- [Phase 3] git blame: buggy sprintf() code introduced in commit 719f82d3987aad (2010, v2.6.35), present in all stable trees
- [Phase 3] git log v6.6/v5.15: confirmed function is essentially unchanged since introduction
- [Phase 4] b4 dig -c 18d4969e22cc3: found original thread, patch v1→v3 evolution
- [Phase 4] b4 dig -a: confirmed v3 is the applied version, v1 used scnprintf, Takashi requested snprintf+check
- [Phase 4] Mailing list: Takashi Iwai confirmed overflow is real, requested v3, applied to for-next
- [Phase 5] Verified struct hpi_control has name[44] as last field, struct is stack-allocated in snd_card_asihpi_mixer_new()
- [Phase 5] Verified SNDRV_CTL_ELEM_ID_NAME_MAXLEN = 44 in include/uapi/sound/asound.h
- [Phase 5] Verified name tables: "Bitstream"(9) + " 0 "(3) + "Internal"(8) + " 0 "(3) + "Monitor Playback "(18) + "Volume"(6) = 47 chars with NUL → 3-byte overflow
- [Phase 6] Code exists in all active stable trees, patch should apply cleanly
- [Phase 8] Stack buffer overflow severity: HIGH (stack corruption possible)
The fix is small, obviously correct, prevents a real buffer overflow with in-tree string values, was reviewed and refined by the ALSA maintainer through 3 iterations, and applies cleanly to stable trees.
**YES**
sound/pci/asihpi/asihpi.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)
sound/pci/asihpi/asihpi.c +22 -14
@@ -1362,6 +1362,7 @@ static void asihpi_ctl_init(struct snd_kcontrol_new *snd_control,struct hpi_control *hpi_ctl, char *name) { + int len;char *dir;memset (snd_control,0 ,sizeof (*snd_control)); snd_control->name = hpi_ctl->name;
@@ -1384,23 +1385,30 @@ static void asihpi_ctl_init(struct snd_kcontrol_new *snd_control, dir ="Playback " ;/* PCM Playback source, or output node */ if (hpi_ctl->src_node_type && hpi_ctl->dst_node_type) -sprintf (hpi_ctl->name,"%s %d %s %d %s%s" , - asihpi_src_names[hpi_ctl->src_node_type], - hpi_ctl->src_node_index, - asihpi_dst_names[hpi_ctl->dst_node_type], - hpi_ctl->dst_node_index, - dir, name); + len =snprintf (hpi_ctl->name,sizeof (hpi_ctl->name), +"%s %d %s %d %s%s" , + asihpi_src_names[hpi_ctl->src_node_type], + hpi_ctl->src_node_index, + asihpi_dst_names[hpi_ctl->dst_node_type], + hpi_ctl->dst_node_index, + dir, name);else if (hpi_ctl->dst_node_type) { -sprintf (hpi_ctl->name,"%s %d %s%s" , - asihpi_dst_names[hpi_ctl->dst_node_type], - hpi_ctl->dst_node_index, - dir, name); + len =snprintf (hpi_ctl->name,sizeof (hpi_ctl->name), +"%s %d %s%s" , + asihpi_dst_names[hpi_ctl->dst_node_type], + hpi_ctl->dst_node_index, + dir, name); }else { -sprintf (hpi_ctl->name,"%s %d %s%s" , - asihpi_src_names[hpi_ctl->src_node_type], - hpi_ctl->src_node_index, - dir, name); + len =snprintf (hpi_ctl->name,sizeof (hpi_ctl->name), +"%s %d %s%s" , + asihpi_src_names[hpi_ctl->src_node_type], + hpi_ctl->src_node_index, + dir, name); } + +if (len >=sizeof (hpi_ctl->name)) +pr_err ("asihpi: truncated control name: %s\n" , + hpi_ctl->name); }/*------------------------------------------------------------
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/realtek: Add support for ASUS 2026 Commercial laptops using CS35L41 HDA
In reply to Sasha LevinFrom: Stefan Binding <[email protected]>
[ Upstream commit 66a6333ba5087b00b7d6cb9ff671f4e2739383b3 ]
Add support for laptops:
- ASUS PM5406CGA
- ASUS PM5606CGA
- ASUS P5406CCA
- ASUS P5606CCA
Laptops use 2 CS35L41 Amps with HDA, using Internal boost, with I2C or SPI.
---
LLM Generated explanations, may be completely bogus:
The insertion point is clear: the 4 new entries (0x3601, 0x3611, 0x3701, 0x3711) go between the existing 0x3391 entry (line 7367) and the 0x3a20 entry (line 7368). The context lines from the diff match perfectly.
Now I have all the information I need for a thorough analysis. Let me compile my findings.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: Subject Line**
- Subsystem: ALSA: hda/realtek
- Action verb: "Add support"
- Summary: Adding SND_PCI_QUIRK entries for 4 new ASUS commercial laptop models to enable CS35L41 HDA audio.
- Record: [ALSA/hda/realtek] [Add] [Hardware quirk entries for 4 ASUS laptop models]
**Step 1.2: Tags**
- Signed-off-by: Stefan Binding <[email protected]> - author (Cirrus Logic employee, works on CS35L41 amplifier support)
- `Link: https://patch.msgid.link/20260330134651.443439-3-
[email protected]` - patch 3 in a series
- Signed-off-by: Takashi Iwai <[email protected]> - ALSA subsystem maintainer accepted it
- No Fixes: tag (expected for new device quirk additions)
- No Reported-by: tag (typical for hardware enablement)
- No Cc: stable tag (expected, hence this review)
**Step 1.3: Commit Body**
- Lists 4 specific ASUS laptop models: PM5406CGA, PM5606CGA, P5406CCA, P5606CCA
- Hardware uses 2 CS35L41 amplifiers with HDA, internal boost, via I2C or SPI
- No bug description - pure hardware enablement via existing quirk infrastructure
**Step 1.4: Hidden Bug Fix Detection**
- This is NOT a hidden bug fix. It is explicitly a hardware quirk addition to enable audio on new laptop models. Without these entries, audio amplifiers on these 4 laptops would not be properly initialized, meaning users get no sound or degraded sound.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: Inventory**
- 1 file changed: sound/hda/codecs/realtek/alc269.c
- 4 lines added, 0 lines removed
- Changes are within the alc269_fixup_tbl[] quirk table
**Step 2.2: Code Flow Change**
- Before: The 4 ASUS SSID values (0x3601, 0x3611, 0x3701, 0x3711) have no matching quirk entry, so the CS35L41 amplifiers are not configured
- After: Each SSID maps to its appropriate fixup function (ALC287_FIXUP_CS35L41_I2C_2 for I2C models, ALC245_FIXUP_CS35L41_SPI_2 for SPI models)
**Step 2.3: Bug Mechanism**
- Category (h): Hardware workarounds - Device-specific quirk table entries
- These are SND_PCI_QUIRK() entries in the HDA codec's quirk table, the standard mechanism for enabling amplifier support on specific laptops
**Step 2.4: Fix Quality**
- Obviously correct: follows identical pattern to dozens of existing entries for the same vendor (0x1043 = ASUS) using the same fixup IDs
- Minimal: exactly 4 lines, each a self-contained quirk table entry
- Zero regression risk: only affects devices with these specific SSID values
- Author is a Cirrus Logic engineer who maintains the CS35L41 driver
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: Blame**
- The quirk table area is from commit aeeb85f26c3bbe (Takashi Iwai, 2025-07-09) which was a large refactoring/move of the file
- The ALC287_FIXUP_CS35L41_I2C_2 fixup has been present since at least 6.x era, well-established
**Step 3.2: Fixes tag** - N/A (no Fixes: tag, expected for quirk additions)
**Step 3.3: File History**
- The file has very frequent quirk additions (verified: recent commits are almost all "Add quirk for X" style)
- Stefan Binding has multiple prior identical commits (e.g., 0156c22fb0ca8 adding ASUS PM3406CKA and PM3606CKA)
**Step 3.4: Author**
- Stefan Binding works at Cirrus Logic ([email protected]), the company that makes the CS35L41 amplifier
- He is the primary contributor for CS35L41 HDA quirk additions
- The patch was accepted by Takashi Iwai, the ALSA maintainer
**Step 3.5: Dependencies**
- Both fixup types (ALC287_FIXUP_CS35L41_I2C_2 at line 6248 and ALC245_FIXUP_CS35L41_SPI_2 at line 6262) exist in the 7.0 tree
- The context lines match the current tree (0x3391 PM3606CKA followed by 0x3a20)
- This is fully standalone - no other patches needed
## PHASE 4: MAILING LIST RESEARCH
**Step 4.1:** The Link tag indicates this is patch 3 of a series (443439-3). Lore is blocked by anti-bot measures. However, the identical pattern of prior commits from the same author (e.g., 0156c22fb0ca8) was a v1 single patch that was simply adding quirk entries - no controversy expected.
**Step 4.2:** Accepted by Takashi Iwai (ALSA maintainer) directly. Stefan Binding is the recognized CS35L41 maintainer at Cirrus Logic.
**Step 4.3-4.5:** No bug report - this is hardware enablement. No stable-specific discussion expected for quirk additions.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1:** No functions modified - only data table entries added.
**Step 5.2-5.4:** The SND_PCI_QUIRK macro adds an entry to a static lookup table. When a matching PCI subsystem ID is found, the corresponding fixup function is called during codec initialization. The fixup functions (cs35l41_fixup_i2c_two, cs35l41_fixup_spi_two) are well-established and used by 100+ other entries.
**Step 5.5:** Over 100 identical entries exist for ASUS laptops in this same table using these same fixup IDs.
## PHASE 6: STABLE TREE ANALYSIS
**Step 6.1:** The quirk table and both fixup types exist in all active stable trees (they've been present since at least 6.1). The new SSID values are for new hardware that doesn't have entries yet.
**Step 6.2:** The patch should apply cleanly - it's inserting lines at a well-defined sorted position in a table. Minor context-line offset adjustments may be needed depending on how many entries are already in each stable tree.
**Step 6.3:** No related fixes needed - these are new device IDs.
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1:** ALSA/HDA - audio subsystem. IMPORTANT criticality - audio is essential for laptop users.
**Step 7.2:** Very actively developed - constant quirk additions for new hardware.
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1:** Users of these 4 specific ASUS commercial laptop models (PM5406CGA, PM5606CGA, P5406CCA, P5606CCA).
**Step 8.2:** Trigger: boot with this hardware. Without the quirk, CS35L41 amplifiers are not configured, meaning no sound or broken sound.
**Step 8.3:** Without quirk: non-functional or degraded audio on these laptops. Severity: MEDIUM-HIGH (audio completely broken on specific hardware).
**Step 8.4:**
- Benefit: HIGH - enables audio on 4 new laptop models for stable tree users
- Risk: VERY LOW - 4 lines of data-only additions to a lookup table, using existing fixup functions, affecting only devices with matching SSIDs
- Ratio: Excellent benefit-to-risk
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: Evidence FOR backporting:**
- Pure hardware quirk addition (exception category: YES automatically)
- 4 lines, data-only, zero code logic change
- Uses well-established fixup types with 100+ existing users
- Author is the Cirrus Logic CS35L41 maintainer
- Accepted by ALSA subsystem maintainer Takashi Iwai
- Enables audio on commercial laptops that stable users would use
- Identical pattern to many prior commits that have gone to stable
**Evidence AGAINST:**
- None identified
**Step 9.2: Stable Rules Checklist:**
1. Obviously correct? YES - identical pattern to 100+ existing entries
2. Fixes real bug? YES - enables broken audio hardware
3. Important issue? YES - no audio on affected laptops
4. Small and contained? YES - 4 lines in 1 file
5. No new features? Correct - uses existing fixup infrastructure
6. Can apply to stable? YES - all dependencies exist in stable trees
**Step 9.3: Exception Category:**
This is a **hardware quirk/workaround** addition - one of the explicitly allowed exception categories that is automatically YES for stable.
## Verification
- [Phase 1] Parsed tags: Link shows patch 3 of series, SOBs from author (Cirrus Logic) and Takashi Iwai (ALSA maintainer)
- [Phase 2] Diff analysis: 4 lines added to SND_PCI_QUIRK table in alc269_fixup_tbl[], purely data additions
- [Phase 2] Verified both fixup types exist:
ALC287_FIXUP_CS35L41_I2C_2 at line 6248, ALC245_FIXUP_CS35L41_SPI_2 at line 6262
- [Phase 3] git blame: insertion area is stable, context lines (0x3391 at line 7367, 0x3a20 at line 7368) match the diff
- [Phase 3] Verified identical prior commit 0156c22fb0ca8 by same author adding ASUS PM3406CKA/PM3606CKA
- [Phase 3] Author Stefan Binding has 10+ commits for CS35L41 quirk additions in this file
- [Phase 5] Both fixup functions (cs35l41_fixup_i2c_two, cs35l41_fixup_spi_two) are defined and used by 100+ entries
- [Phase 6] Fixup infrastructure exists in stable tree (verified in 7.0 tree)
- [Phase 8] Risk assessment: 4 data-only lines, VERY LOW regression risk
- UNVERIFIED: Could not access lore.kernel.org for mailing list discussion (anti-bot protection); however, this has no bearing on the decision since the commit type (hardware quirk addition) is automatically a YES category.
This is a textbook hardware quirk addition: 4 SND_PCI_QUIRK entries adding PCI subsystem IDs for new ASUS laptops to enable existing CS35L41 amplifier support. It is data-only, uses well-established fixup infrastructure, was authored by the Cirrus Logic CS35L41 maintainer, and accepted by the ALSA subsystem maintainer. It falls squarely into the "hardware quirk" exception category that is always appropriate for stable.
**YES**
sound/hda/codecs/realtek/alc269.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/hda/codecs/realtek/alc269.c +4 -0
@@ -7365,6 +7365,10 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x1043 ,0x31e1 ,"ASUS B5605CCA" ,ALC294_FIXUP_ASUS_CS35L41_SPI_2 ),SND_PCI_QUIRK (0x1043 ,0x31f1 ,"ASUS B3605CCA" ,ALC294_FIXUP_ASUS_CS35L41_SPI_2 ),SND_PCI_QUIRK (0x1043 ,0x3391 ,"ASUS PM3606CKA" ,ALC287_FIXUP_CS35L41_I2C_2 ), +SND_PCI_QUIRK (0x1043 ,0x3601 ,"ASUS PM5406CGA" ,ALC287_FIXUP_CS35L41_I2C_2 ), +SND_PCI_QUIRK (0x1043 ,0x3611 ,"ASUS PM5606CGA" ,ALC287_FIXUP_CS35L41_I2C_2 ), +SND_PCI_QUIRK (0x1043 ,0x3701 ,"ASUS P5406CCA" ,ALC245_FIXUP_CS35L41_SPI_2 ), +SND_PCI_QUIRK (0x1043 ,0x3711 ,"ASUS P5606CCA" ,ALC245_FIXUP_CS35L41_SPI_2 ),SND_PCI_QUIRK (0x1043 ,0x3a20 ,"ASUS G614JZR" ,ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS ),SND_PCI_QUIRK (0x1043 ,0x3a30 ,"ASUS G814JVR/JIR" ,ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS ), SND_PCI_QUIRK(0x1043, 0x3a40, "ASUS G814JZR", ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 jfs: Set the lbmDone flag at the end of lbmIODone
In reply to Sasha LevinFrom: Edward Adam Davis <[email protected]>
[ Upstream commit b15e4310633f90072d66cc9b6692acbf6b4d7d00 ]
In lbmRead(), the I/O event waited for by wait_event() finishes before it goes to sleep, and the lbmIODone() prematurely sets the flag to lbmDONE, thus ending the wait. This causes wait_event() to return before lbmREAD is cleared (because lbmDONE was set first), the premature return of wait_event() leads to the release of lbuf before lbmIODone() returns, thus triggering the use-after-free vulnerability reported in [1].
Moving the operation of setting the lbmDONE flag to after clearing lbmREAD in lbmIODone() avoids the use-after-free vulnerability reported in [1].
[1]
BUG: KASAN: slab-use-after-free in rt_spin_lock+0x88/0x3e0 kernel/locking/spinlock_rt.c:56 Call Trace: blk_update_request+0x57e/0xe60 block/blk-mq.c:1007 blk_mq_end_request+0x3e/0x70 block/blk-mq.c:1169 blk_complete_reqs block/blk-mq.c:1244 [inline] blk_done_softirq+0x10a/0x160 block/blk-mq.c:1249 Allocated by task 6101: lbmLogInit fs/jfs/jfs_logmgr.c:1821 [inline] lmLogInit+0x3d0/0x19e0 fs/jfs/jfs_logmgr.c:1269 open_inline_log fs/jfs/jfs_logmgr.c:1175 [inline] lmLogOpen+0x4e1/0xfa0 fs/jfs/jfs_logmgr.c:1069 jfs_mount_rw+0xe9/0x670 fs/jfs/jfs_mount.c:257 jfs_fill_super+0x754/0xd80 fs/jfs/super.c:532 Freed by task 6101: kfree+0x1bd/0x900 mm/slub.c:6876 lbmLogShutdown fs/jfs/jfs_logmgr.c:1864 [inline] lmLogInit+0x1137/0x19e0 fs/jfs/jfs_logmgr.c:1415 open_inline_log fs/jfs/jfs_logmgr.c:1175 [inline] lmLogOpen+0x4e1/0xfa0 fs/jfs/jfs_logmgr.c:1069 jfs_mount_rw+0xe9/0x670 fs/jfs/jfs_mount.c:257 jfs_fill_super+0x754/0xd80 fs/jfs/super.c:532
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed to complete the full analysis. Let me compile the results.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: Subject Line**
Record: [jfs] [Set/fix] Move the lbmDONE flag assignment to the end of lbmIODone to prevent a use-after-free race.
**Step 1.2: Tags**
- Reported-by: [email protected] (syzbot fuzzer-found bug)
- Closes: https://syzkaller.appspot.com/bug?extid=1d38eedcb25a3b5686a7
(syzbot bug tracker)
- Signed-off-by: Edward Adam Davis <[email protected]> (author)
- Signed-off-by: Dave Kleikamp <[email protected]> (JFS maintainer)
- No Fixes: tag, no Cc: stable (expected for candidates under review)
Record: Syzbot-reported, maintainer-signed. Strong quality signals.
**Step 1.3: Commit Body**
The commit describes a race in lbmRead(): the wait_event() condition bp->l_flag != lbmREAD becomes true prematurely when lbmIODone() sets lbmDONE BEFORE clearing lbmREAD. This allows wait_event() to return before lbmIODone() finishes processing the buffer, causing the buffer to be freed while lbmIODone() is still accessing it. Full KASAN stack trace included showing slab-use-after-free.
Record: Bug = race condition causing UAF. Symptom = KASAN slab-use- after-free in blk_update_request. Trigger = JFS mount path during log initialization.
**Step 1.4: Hidden Bug Fix?**
No disguise needed - this is an explicit use-after-free fix with KASAN evidence.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: Inventory**
- Single file: fs/jfs/jfs_logmgr.c
- Net change: ~7 lines removed, ~6 lines added (very surgical)
- Functions modified: lbmIODone() only
**Step 2.2: Code Flow Changes**
The key changes are:
1. **Removed** bp->l_flag |= lbmDONE from the beginning of lbmIODone()
2. **READ path**: Removed early LCACHE_UNLOCK and return, replaced with LCACHE_WAKEUP while still holding the lock, then goto out
3. **DIRECT path**: Changed LCACHE_UNLOCK; return to goto out
4. **SYNC path**: Removed LCACHE_UNLOCK before LCACHE_WAKEUP
5. **GC path**: Added LCACHE_LOCK(flags) after lmPostGC(bp) to re- acquire lock (avoiding the deadlock v1 had)
6. **ASYNC path**: Removed explicit LCACHE_UNLOCK
7. **Added** out: label at end: bp->l_flag |= lbmDONE; LCACHE_UNLOCK(flags);
Record: Single function refactored to consolidate exit paths through single out: label. The lbmDONE flag is now set as the very last operation before releasing the lock.
**Step 2.3: Bug Mechanism**
Category: **Race condition + Use-after-free**
The race:
1. lbmRead() submits bio, then calls wait_event(bp->l_ioevent, (bp->l_flag != lbmREAD))
2. lbmIODone() (bio completion handler) sets lbmDONE early → l_flag becomes lbmREAD | lbmDONE which != lbmREAD
3. wait_event() on another CPU sees condition true (lockless check), returns
4. Caller continues, eventually frees the buffer on error paths (lbmLogShutdown → kfree)
5. lbmIODone() is still executing, accesses freed buffer → UAF
**Step 2.4: Fix Quality**
- Obviously correct: centralizes exit and delays the "done" signal to after all processing
- Minimal and surgical: single function, ~13 lines changed
- The v2 correctly handles the GC path deadlock (drops lock for lmPostGC, re-acquires after)
- Low regression risk: the lock ordering is preserved, exit paths are consolidated
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: Blame**
The buggy code (bp->l_flag |= lbmDONE at the start of lbmIODone) was introduced in the initial Linux commit 1da177e4c3f41 (Linus Torvalds, 2005-04-16). This bug has been present since the very beginning of the git history - ALL kernel versions are affected.
**Step 3.2: Fixes tag**
No Fixes: tag present. The bug predates all stable branch points.
**Step 3.3: File History**
No changes to fs/jfs/jfs_logmgr.c since v7.0. The file matches the expected pre-patch state exactly. The fix applies cleanly.
**Step 3.4: Author**
Edward Adam Davis is a frequent contributor of syzbot-triggered fixes. Dave Kleikamp (JFS maintainer) tested and applied the patch.
**Step 3.5: Dependencies**
No dependencies. This is a self-contained fix to a single function. The code in the 7.0 tree at line 2183 matches the old code exactly.
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
**Step 4.1: Patch Discussion**
- b4 dig found the original submission: https://patch.msgid.link/tencent
[email protected]
- Two revisions: v1 introduced a deadlock (caught by syzbot CI), v2 fixed the deadlock by keeping the LCACHE_UNLOCK/lmPostGC/LCACHE_LOCK pattern for the GC path
- Dave Kleikamp (JFS maintainer "Shaggy") replied: "Finally tested and applied to jfs-next"
**Step 4.2: Reviewers**
- CC'd: jfs-discussion, linux-block, linux-kernel, Jens Axboe, Dave Kleikamp
- Applied by the JFS maintainer after testing
**Step 4.3: Bug Report**
- Syzbot first reported this bug on Nov 1, 2024 (6.12-rc5)
- C reproducer available since Dec 7, 2025
- Bug has been active for 708+ days
- Multiple syzbot reproducers show it's reliably triggerable
- Also found on linux-6.1 stable tree (separate syzbot entry)
- Jens Axboe reassigned the subsystem from "block?" to "jfs"
**Step 4.4: Series Context**
Standalone single patch (not part of a series). The v2 is the final applied version.
**Step 4.5: Stable Discussion**
No explicit stable nomination found, but the syzbot bug page shows it was also found on linux-6.1 stable tree.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: Functions Modified**
Only lbmIODone() - the bio completion handler for JFS log buffers.
**Step 5.2: Callers**lbmIODone is called:
1. As bio->bi_end_io callback from block layer (softirq context) - async I/O completion
2. Directly from lbmRead() when log->no_integrity is true (synchronous)
**Step 5.3: Callees**lbmIODone calls: bio_put, LCACHE_WAKEUP (wake_up), lbmRedrive, lmPostGC, lbmfree
**Step 5.4: Call Chain**
Trigger path: mount() → jfs_fill_super → jfs_mount_rw → lmLogOpen → lmLogInit → lbmRead → submit_bio → (bio completion on another CPU) → lbmIODone → UAF
This is reachable from the mount() syscall - unprivileged users can trigger it (with a crafted JFS filesystem image).
**Step 5.5: Similar Patterns**lbmIOWait() uses LCACHE_SLEEP_COND which holds the lock during condition checks, making it immune to this race. Only lbmRead() uses the lockless wait_event and is affected.
## PHASE 6: STABLE TREE ANALYSIS
**Step 6.1: Code Existence**
The buggy code has been present since 2005. It exists in ALL stable trees. The syzbot dashboard confirms it was also found on linux-6.1.
**Step 6.2: Backport Complications**
The file has NO changes since v7.0 in this tree. The patch should apply cleanly.
**Step 6.3: Related Fixes**
No related fixes found in the tree. This is the first fix for this bug.
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: Subsystem**
JFS filesystem (fs/jfs/). Criticality: IMPORTANT - filesystem bugs can lead to data corruption or system crashes. While JFS is not the most widely used filesystem, it has real users especially in enterprise environments.
**Step 7.2: Activity**
JFS is a mature, low-activity subsystem. The bug has been present for ~20 years, affecting all kernel versions.
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: Affected Users**
All users who mount JFS filesystems. Also security-relevant as it can be triggered with a crafted filesystem image.
**Step 8.2: Trigger Conditions**
- Triggered during JFS mount (lmLogInit → lbmRead)
- Requires multi-CPU system and specific timing (I/O completion racing with wait_event)
- Syzbot has a C reproducer - reliably triggerable
- Can be triggered by unprivileged users mounting a filesystem (depending on policy)
**Step 8.3: Failure Mode**
KASAN: slab-use-after-free → potential kernel crash, memory corruption,
or exploitable vulnerability. Severity: **CRITICAL**
**Step 8.4: Risk-Benefit Ratio**
- BENEFIT: Very high - fixes a KASAN-detected UAF with reproducer, present in all kernels
- RISK: Low - single file, well-contained, tested by maintainer, v2 addressed deadlock issue from v1
- The change consolidates exit paths which is structurally cleaner
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: Evidence Compilation**
FOR backporting:
- Fixes slab-use-after-free (KASAN-verified, syzbot-reported with C reproducer)
- Bug present since initial Linux git commit (2005) - affects ALL stable trees
- Triggered from mount() syscall - reachable from userspace
- Single file, single function, ~13 lines changed
- JFS maintainer tested and applied
- v2 iteration fixed a deadlock found by syzbot CI in v1
- Clean apply expected (no file changes since v7.0)
- Bug active 708+ days, also found on linux-6.1 stable
AGAINST backporting:
- (None significant)
**Step 9.2: Stable Rules Checklist**
1. Obviously correct and tested? **YES** - maintainer tested, v2 addresses v1's deadlock
2. Fixes a real bug? **YES** - KASAN UAF with syzbot reproducer
3. Important issue? **YES** - UAF in filesystem mount path (crash/security)
4. Small and contained? **YES** - single function in single file
5. No new features/APIs? **YES** - pure bug fix
6. Can apply to stable? **YES** - no changes to file since v7.0
**Step 9.3: Exception Categories**
Not an exception category - this is a standard high-priority bug fix.
**Step 9.4: Decision**
Clear YES. This fixes a critical use-after-free vulnerability in JFS that has been present since 2005, is syzbot-verified with a reproducer, and is a small, well-tested, maintainer-approved fix.
---
## Verification
- [Phase 1] Parsed tags: Reported-by: syzbot, Closes: syzkaller link, SOB from author and JFS maintainer
- [Phase 2] Diff analysis: lbmDONE flag move from start to end of lbmIODone(), consolidated exit paths via goto out
- [Phase 3] git blame: buggy code (bp->l_flag |= lbmDONE at line 2183) from commit 1da177e4c3f41 (2005), present in ALL kernels
- [Phase 3] git log v7.0..: confirmed no changes to file since v7.0 branch point
- [Phase 4] b4 dig -c b15e4310633f: found original at https://patch.msgi
d.link/[email protected]
- [Phase 4] b4 dig -a: two revisions (v1 had deadlock, v2 fixed it)
- [Phase 4] b4 dig -w: JFS maintainer (Dave Kleikamp/[email protected]), Jens Axboe, mailing lists were CC'd
- [Phase 4] mbox thread: Dave Kleikamp tested and applied to jfs-next; syzbot CI found deadlock in v1 confirming proper testing
- [Phase 4] syzbot dashboard: bug first reported Nov 2024, C reproducer available, 708+ days active, also on linux-6.1
- [Phase 5] Traced call chain: mount() → jfs_fill_super → jfs_mount_rw → lmLogOpen → lmLogInit → lbmRead → submit_bio → lbmIODone (race)
- [Phase 5] Verified lbmRead uses lockless wait_event (line 1989) vs lbmIOWait using locked LCACHE_SLEEP_COND (line 2151)
- [Phase 5] Verified __SLEEP_COND macro in jfs_lock.h - confirmed lockless condition check in wait_event is the root cause
- [Phase 6] Code exists in ALL stable trees (bug since 2005)
- [Phase 6] Clean apply expected - no file changes since v7.0
- [Phase 8] Failure mode: slab-use-after-free → potential kernel crash/exploit, severity CRITICAL
**YES**
fs/jfs/jfs_logmgr.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
fs/jfs/jfs_logmgr.c +7 -11
@@ -2178,8 +2178,6 @@ static void lbmIODone(struct bio *bio)LCACHE_LOCK (flags);/* disable+lock */ - bp->l_flag |= lbmDONE; -if (bio->bi_status) { bp->l_flag |= lbmERROR;
@@ -2194,12 +2192,10 @@ static void lbmIODone(struct bio *bio)if (bp->l_flag & lbmREAD) { bp->l_flag &= ~lbmREAD; -LCACHE_UNLOCK (flags);/* unlock+enable */ -/* wakeup I/O initiator */ LCACHE_WAKEUP (&bp->l_ioevent); -return ; + goto out; }/*
@@ -2223,8 +2219,7 @@ static void lbmIODone(struct bio *bio)if (bp->l_flag & lbmDIRECT) {LCACHE_WAKEUP (&bp->l_ioevent); -LCACHE_UNLOCK (flags); -return ; + goto out; } tail = log->wqueue;
@@ -2276,8 +2271,6 @@ static void lbmIODone(struct bio *bio)* leave buffer for i/o initiator to dispose */ if (bp->l_flag & lbmSYNC) { -LCACHE_UNLOCK (flags);/* unlock+enable */ -/* wakeup I/O initiator */ LCACHE_WAKEUP (&bp->l_ioevent); }
@@ -2288,6 +2281,7 @@ static void lbmIODone(struct bio *bio)else if (bp->l_flag & lbmGC) {LCACHE_UNLOCK (flags);lmPostGC (bp); +LCACHE_LOCK (flags);/* disable+lock */ }/*
@@ -2300,9 +2294,11 @@ static void lbmIODone(struct bio *bio)assert (bp->l_flag & lbmRELEASE);assert (bp->l_flag & lbmFREE);lbmfree (bp); - -LCACHE_UNLOCK (flags);/* unlock+enable */ } + +out: + bp->l_flag |= lbmDONE; +LCACHE_UNLOCK (flags); }int jfsIOWait (void *arg)
Signature · 1 line
2.53.0
Re: [PATCH AUTOSEL 7.0-5.10] jfs: Set the lbmDone flag at the end of lbmIODone
Quoted 44 lines · Sasha Levin
From: Edward Adam Davis <[email protected]>
[ Upstream commit
b15e4310633f90072d66cc9b6692acbf6b4d7d00]In
lbmRead(), the I/O event waited for bywait_event()finishes before it goes to sleep, and thelbmIODone()prematurely sets the flag to lbmDONE, thus ending the wait. This causeswait_event()to return before lbmREAD is cleared (because lbmDONE was set first), the premature return ofwait_event()leads to the release of lbuf beforelbmIODone()returns, thus triggering the use-after-free vulnerability reported in [1].Moving the operation of setting the lbmDONE flag to after clearing lbmREAD in
lbmIODone()avoids the use-after-free vulnerability reported in [1].[1]
BUG: KASAN: slab-use-after-free in rt_spin_lock+0x88/0x3e0 kernel/locking/spinlock_rt.c:56 Call Trace: blk_update_request+0x57e/0xe60 block/blk-mq.c:1007 blk_mq_end_request+0x3e/0x70 block/blk-mq.c:1169 blk_complete_reqs block/blk-mq.c:1244 [inline] blk_done_softirq+0x10a/0x160 block/blk-mq.c:1249 Allocated by task 6101: lbmLogInit fs/jfs/jfs_logmgr.c:1821 [inline] lmLogInit+0x3d0/0x19e0 fs/jfs/jfs_logmgr.c:1269 open_inline_log fs/jfs/jfs_logmgr.c:1175 [inline] lmLogOpen+0x4e1/0xfa0 fs/jfs/jfs_logmgr.c:1069 jfs_mount_rw+0xe9/0x670 fs/jfs/jfs_mount.c:257 jfs_fill_super+0x754/0xd80 fs/jfs/super.c:532 Freed by task 6101: kfree+0x1bd/0x900 mm/slub.c:6876 lbmLogShutdown fs/jfs/jfs_logmgr.c:1864 [inline] lmLogInit+0x1137/0x19e0 fs/jfs/jfs_logmgr.c:1415 open_inline_log fs/jfs/jfs_logmgr.c:1175 [inline] lmLogOpen+0x4e1/0xfa0 fs/jfs/jfs_logmgr.c:1069 jfs_mount_rw+0xe9/0x670 fs/jfs/jfs_mount.c:257 jfs_fill_super+0x754/0xd80 fs/jfs/super.c:532Reported-by [email protected]Signed-off-by Edward Adam Davis <[email protected]>Signed-off-by Dave Kleikamp <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Quoted 6 lines
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed to complete the full analysis. Let me compile the results.
I fixed this issue a couple of days ago. Please see:
https://lore.kernel.org/all/[email protected]
Edward
BR
Sasha Levin
maintainerPATCH 1/1 ASoC: SDCA: Add CS47L47 to class driver
In reply to Sasha LevinFrom: Richard Fitzgerald <[email protected]>
[ Upstream commit ada32396f90951e12465224c04742607ca56a982 ]
Add the SoundWire ID for CS47L47 to the class driver.
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed. Let me compile my analysis.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: Subject Line**
- Subsystem: ASoC: SDCA
- Action verb: "Add" (device ID addition)
- Summary: Add CS47L47 SoundWire device ID to the SDCA class driver
Record: [ASoC: SDCA] [Add] [SoundWire ID for CS47L47 added to class driver device table]
**Step 1.2: Tags**
- Signed-off-by: Richard Fitzgerald <[email protected]> - Author, Cirrus Logic employee (device vendor)
- Reviewed-by: Pierre-Louis Bossart <[email protected]> - SoundWire subsystem reviewer
- `Link: https://patch.msgid.link/20260223150256.326143-4-
[email protected]` - patch 4 of a series (message numbering indicates patch 3/3 of the content, with 1 being cover letter)
- Signed-off-by: Mark Brown <[email protected]> - Applied by the ASoC subsystem maintainer
- No Fixes: tag (expected for a device ID addition)
- No Cc: stable (expected)
Record: Reviewed by SoundWire expert. Applied by ASoC maintainer. Author is from Cirrus Logic (vendor).
**Step 1.3: Commit Body**
The body is minimal: "Add the SoundWire ID for CS47L47 to the class driver." This is standard for device ID additions — no bug description needed because this is hardware enablement.
Record: Straightforward device ID addition. No bug fix, no failure mode described.
**Step 1.4: Hidden Bug Fix Detection**
This is not a hidden bug fix. It is a device ID addition to enable new hardware (CS47L47 audio codec) on an existing driver. This falls squarely into the "NEW DEVICE IDs" exception category.
Record: Not a hidden bug fix. It's a device ID addition — an explicit exception category for stable.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: Inventory**
- Files changed: 1 (sound/soc/sdca/sdca_class.c)
- Lines added: 1
- Lines removed: 0
- Function modified: None — change is in the class_sdw_id[] static data table
- Scope: Single-line addition to a device ID table — as minimal as possible
Record: [sound/soc/sdca/sdca_class.c +1/-0] [No function logic changed, only data table entry added] [Trivial single-line]
**Step 2.2: Code Flow Change**
- Before: The class_sdw_id[] table contains one entry SDW_SLAVE_ENTRY(0x01FA, 0x4245, 0) matching one Cirrus Logic device.
- After: The table has two entries, adding SDW_SLAVE_ENTRY(0x01FA, 0x4747, 0) for CS47L47.
- Effect: The SoundWire bus will now match CS47L47 devices to this driver and call class_sdw_probe().
Record: Before: only CS42L45 (0x4245) matched. After: CS47L47 (0x4747) also matched. Normal probe path, no error path changes.
**Step 2.3: Bug Mechanism**
Category (h) — Hardware workarounds/enablement. This is a device ID addition, not a bug fix.
Record: [Device ID addition] [Adds SoundWire slave entry for CS47L47 to existing driver's ID table]
**Step 2.4: Fix Quality**
- Obviously correct: Yes — identical pattern to the existing entry, just a different device/part ID
- Minimal: Yes — exactly 1 line
- Regression risk: Essentially zero — only affects CS47L47 hardware; cannot impact existing devices
- No red flags
Record: Trivially correct. Zero regression risk for existing devices.
## PHASE 3: GIT HISTORY
**Step 3.1: Blame**
The device ID table was introduced in commit 2d877d0659cb6 ("ASoC:
SDCA: Add basic SDCA class driver") by Charles Keepax, November 2025. This was merged in v6.19-rc1. The SDCA class driver exists in v7.0.
Record: Driver introduced in v6.19, present in v7.0. Device ID table area unchanged since creation.
**Step 3.2: No Fixes: tag** — expected, as this is a device ID addition.
**Step 3.3: File History**
Only 3 commits to sdca_class.c:
1. 2d877d0659cb6 - Initial driver
2. 7a5214f769c7c - Add suspend support
3. da7afdc79cba0 - Add init serialization lock
All are from the same Cirrus Logic team. No conflicting changes.
Record: Clean history, no prerequisites needed beyond the base driver.
**Step 3.4: Author**
Richard Fitzgerald is a Cirrus Logic engineer, the vendor of the CS47L47. He's a regular contributor to the Cirrus Logic sound codec drivers (cs35l56, cs42l42 family). This is authoritative — the device vendor adding their own device ID.
Record: Author is from the device vendor (Cirrus Logic), regular sound subsystem contributor.
**Step 3.5: Dependencies**
This is patch 3/3 of the series "ASoC: SDCA: Initial support for Cirrus Logic CS47L47":
1. soundwire: intel_auxdevice: Add CS47L47 to wake_capable_list (supplementary)
2. ASoC: soc_sdw_utils: Add device info for CS47L47 (supplementary)
3. This commit: Add device ID to class driver (core enablement)
This commit is standalone — it adds the device ID that allows probe. The other patches add supplementary features (wake capability, extra device info) but are not prerequisites for basic device operation via the class driver.
Record: Standalone. Other series patches are supplementary, not required for this to work.
## PHASE 4: MAILING LIST
**Step 4.1-4.5: External Research**
Lore pages were blocked by anti-scraping, but from patchew.org I confirmed:
- This is patch 3/3 of the series
- The patch was reviewed by Pierre-Louis Bossart (SoundWire expert)
- Applied by Mark Brown (ASoC maintainer)
- No NAKs, no concerns raised
- Single revision — no v2/v3 needed
Record: Clean review. Applied by maintainer. No concerns raised.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1-5.5:**
The only change is in the class_sdw_id[] data table. No functions are modified. The table is consumed by the SoundWire bus matching infrastructure — when a CS47L47 device appears on the bus, the existing class_sdw_probe() function will be called. This is a well-tested code path (already used for the CS42L45 device).
Record: No function logic changed. The existing probe path handles the new device ID through standard bus matching.
## PHASE 6: STABLE TREE ANALYSIS
**Step 6.1:** The SDCA class driver was introduced in v6.19. This v7.0 stable tree has the driver. The file has had minimal changes (3 total commits) and the device ID table area is untouched since creation.
**Step 6.2:** The patch will apply cleanly — the context around the device ID table is unchanged from the original driver creation.
**Step 6.3:** No related fixes already in stable for this device.
Record: Code exists in v7.0 stable. Clean apply expected. No conflicts.
## PHASE 7: SUBSYSTEM CONTEXT
**Step 7.1:** ASoC (ALSA System on Chip) / SDCA — audio codec driver.
Criticality: IMPORTANT — audio is a core user-facing feature on laptops and embedded devices.
**Step 7.2:** Active subsystem with regular contributions from Cirrus Logic and Intel teams.
Record: [ASoC/SDCA audio] [IMPORTANT criticality] [Active subsystem]
## PHASE 8: IMPACT AND RISK
**Step 8.1:** Affected users: Anyone with CS47L47 hardware (Cirrus Logic audio codec on SoundWire bus). Without this patch, the CS47L47 device will not be recognized by the kernel and audio will not work.
**Step 8.2:** Trigger: Device enumeration on the SoundWire bus during boot. Every user with this hardware is affected, every boot.
**Step 8.3:** Without this fix: no audio support for CS47L47 hardware.
Severity: MEDIUM-HIGH (hardware completely non-functional).
**Step 8.4:** Risk-benefit:
- BENEFIT: HIGH — enables an entire audio codec for users with this hardware
- RISK: VERY LOW — 1 line, identical pattern to existing entry, only affects CS47L47 hardware, zero regression risk for other devices
- Ratio: Excellent
Record: [HIGH benefit] [VERY LOW risk] [Excellent ratio]
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: Evidence**
FOR backporting:
- Classic device ID addition (explicit stable exception category)
- Single line change, obviously correct
- Zero regression risk for existing devices
- From the device vendor (Cirrus Logic)
- Reviewed by SoundWire expert, applied by ASoC maintainer
- Enables hardware that is completely non-functional without it
- Applies cleanly to v7.0
AGAINST backporting:
- Not a bug fix per se (hardware enablement)
- Part of a 3-patch series (but standalone for basic support)
**Step 9.2: Stable Rules Checklist**
1. Obviously correct and tested? YES — trivial pattern match, reviewed, applied by maintainer
2. Fixes a real bug? N/A — device ID addition exception
3. Important issue? YES — hardware completely non-functional without it
4. Small and contained? YES — 1 line
5. No new features or APIs? Correct — no new features, just device recognition
6. Can apply to stable? YES — clean apply
**Step 9.3: Exception Category**
YES — this is a **NEW DEVICE ID** addition to an existing driver. This is explicitly listed as an allowed exception for stable trees.
**Step 9.4: Decision**
This is a textbook device ID addition — a single SDW_SLAVE_ENTRY line added to an existing driver's device table. It enables the CS47L47 audio codec to be recognized by the kernel's SDCA class driver. The change is trivially correct, carries zero regression risk, and falls into the explicit "New Device IDs" exception category for stable.
## Verification
- [Phase 1] Parsed tags: Reviewed-by Pierre-Louis Bossart, Signed-off-by Mark Brown (maintainer)
- [Phase 2] Diff analysis: exactly 1 line added — SDW_SLAVE_ENTRY(0x01FA, 0x4747, 0) to device ID table
- [Phase 3] git blame: device ID table introduced in commit 2d877d0659cb6 (v6.19), unchanged since
- [Phase 3] git log: only 3 commits to sdca_class.c, clean history
- [Phase 3] Author: Richard Fitzgerald is Cirrus Logic (device vendor) engineer, regular contributor
- [Phase 4] patchew.org: confirmed patch 3/3 of series, clean review, no NAKs
- [Phase 4] b4 dig: failed to find (commit not in local tree), used web search instead
- [Phase 4] lore: blocked by anti-scraping (Anubis), used patchew as fallback
- [Phase 5] No function logic changed — only data table addition
- [Phase 6] SDCA class driver exists in v7.0 (introduced v6.19), clean apply expected
- [Phase 6] Confirmed no 0x4747 or CS47L47 references exist in current tree
- [Phase 7] ASoC subsystem, IMPORTANT criticality
- [Phase 8] Benefit: HIGH (enables hardware); Risk: VERY LOW (1-line data-only change)
- UNVERIFIED: Could not read original lore discussion directly due to anti-scraping. Used patchew mirror instead, which showed no concerns.
**YES**
sound/soc/sdca/sdca_class.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/sdca/sdca_class.c +1 -0
@@ -317,6 +317,7 @@ static const struct dev_pm_ops class_pm_ops = {static const struct sdw_device_id class_sdw_id[] = {SDW_SLAVE_ENTRY (0x01FA ,0x4245 ,0 ), +SDW_SLAVE_ENTRY (0x01FA ,0x4747 ,0 ), {} };MODULE_DEVICE_TABLE (sdw, class_sdw_id);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 media: renesas: vsp1: rpf: Fix crop left and top clamping
In reply to Sasha LevinFrom: Laurent Pinchart <[email protected]>
[ Upstream commit 55823379e61511d534b099949608677d703f709b ]
The RPF doesn't enforces the alignment constraint on the sink pad format, which could have an odd size, possibly down to 1x1. In that case, the upper bounds for the left and top coordinates clamping would become negative, cast to a very large positive value. Incorrect crop rectangle coordinates would then be incorrectly accepted.
A second issue can occur when the requested left and top coordinates are negative. They are cast to a large unsigned value, clamped to the maximum. While the calculation will produce valid values for the hardware, this is not compliant with the V4L2 specification that requires values to be adjusted to the closest valid value.
Fix both issues by switching to signed clamping, with an explicit minimum to adjust negative values, and adjusting the clamp bounds to avoid negative upper bounds.
---
LLM Generated explanations, may be completely bogus:
Now let me compile the full analysis.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: Subject Line**
- Subsystem: media: renesas: vsp1: rpf
- Action verb: "Fix"
- Summary: Fix crop left and top coordinate clamping in the RPF subdevice
**Step 1.2: Tags**
- Tested-by: Niklas Söderlund (Renesas contributor/tester)
- Reviewed-by: Jacopo Mondi (media subsystem reviewer)
- Tested-by: Lad Prabhakar (Renesas RZ/G2M platform tester)
- Link: https://patch.msgid.link/20260318235907.831556-5- [email protected]
- Signed-off-by: Laurent Pinchart (subsystem author/maintainer)
- Signed-off-by: Hans Verkuil (V4L2 subsystem co-maintainer)
- Notable: TWO independent Tested-by tags from different engineers on different platforms, plus a Reviewed-by. No Fixes: tag (expected for autosel candidates). No Reported-by or syzbot.
**Step 1.3: Commit Body**
Two distinct bugs described:
1. When the sink pad format has odd dimensions (e.g. 1x1), format->width - 2 underflows when used as unsigned int, producing a huge value. The min_t(unsigned int, ...) then fails to bound the coordinate.
2. Negative left/top values (from userspace - __s32 type) are cast to large unsigned values, clamped to the maximum rather than to the closest valid value (0). This violates the V4L2 specification.
**Step 1.4: Hidden Bug Fix Detection**
This is explicitly labeled "Fix" — no disguise needed.
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: Inventory**
- Single file changed: drivers/media/platform/renesas/vsp1/vsp1_rwpf.c
- Single function modified: vsp1_rwpf_set_selection()
- ~20 lines of net change (added local variables, updated clamping logic, added comments)
- Scope: single-file surgical fix
**Step 2.2: Code Flow Change**
Before:
```c sel->r.left = min_t(unsigned int, sel->r.left, format->width - 2); sel->r.top = min_t(unsigned int, sel->r.top, format->height - 2); ```
After:
```c // min_width/min_height computed to avoid negative upper bounds sel->r.left = clamp_t(int, sel->r.left, 0, format->width - min_width); sel->r.top = clamp_t(int, sel->r.top, 0, format->height - min_height); ```
**Step 2.3: Bug Mechanism**
This is a **type/integer overflow bug** (category g: logic/correctness + category f: type bugs):
- struct v4l2_rect has __s32 left and __s32 top (confirmed at include/uapi/linux/videodev2.h:442-447)
- RWPF_MIN_WIDTH = 1 and RWPF_MIN_HEIGHT = 1 — so format can legally be 1x1
- For YUV formats, the hardcoded format->width - 2 becomes -1 when width=1
- min_t(unsigned int, ...) casts this to 0xFFFFFFFF (~4 billion), making the clamp a no-op
- Negative sel->r.left values (valid __s32 input) also wrap to huge unsigned values
**Step 2.4: Fix Quality**
- Obviously correct: switches to signed clamping (clamp_t(int, ...) with explicit 0 lower bound)
- Prevents underflow by computing min_width = min(ALIGN(min_width, 2), format->width) which guarantees format->width - min_width >= 0
- Minimal/surgical: changes only the clamping logic in one function
- Very low regression risk: identical behavior for well-formed inputs; only corrects behavior for edge cases
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: Blame**
- The buggy min_t(unsigned int, ...) lines were introduced by commit e5ad37b64de975 ("[media] v4l: vsp1: Add cropping support", Laurent Pinchart, 2013-08-24) — this is from the v3.12 era
- The YUV alignment code (which creates the format->width - 2 problem for odd formats) was added by 85a0638b7855df (Damian Hobson-Garcia, 2015-05-28)
- Bug has existed since 2013/2015 — present in ALL active stable trees
**Step 3.2: No Fixes: tag present** (expected for autosel)
**Step 3.3: File History**
Recent commits to this file are mostly from Laurent Pinchart adding colorspace support features. The bug fix is standalone and does not depend on any of those feature commits.
**Step 3.4: Author**
Laurent Pinchart is the original author and subsystem maintainer for the VSP1 driver (wrote the file in 2013). He is the most qualified person to fix this code.
**Step 3.5: Dependencies**
- clamp_t macro exists in all stable trees (confirmed: present in v5.15 at include/linux/minmax.h:124)
- RWPF_MIN_WIDTH/RWPF_MIN_HEIGHT exist in the same file in all versions
- The fix is standalone — no prerequisites needed
---
## PHASE 4: MAILING LIST / EXTERNAL RESEARCH
**Step 4.1-4.2:** Lore.kernel.org is protected by anti-bot (Anubis), direct web fetches failed. b4 dig could not locate the exact commit by message-id. However:
- The patch was reviewed and tested by two independent testers and an experienced reviewer
- Hans Verkuil (V4L2 co-maintainer) applied it
- Part of a series (patch 5 of N) but this specific patch is a self- contained bug fix
**Step 4.3-4.5:** Could not verify lore discussion directly due to anti- bot protection.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: Functions Modified**
Only vsp1_rwpf_set_selection() is modified.
**Step 5.2: Callers**
- Registered as .set_selection pad operation in vsp1_rwpf_pad_ops
- Called from userspace via VIDIOC_SUBDEV_S_SELECTION ioctl (standard V4L2 path)
- Called from vsp1_drm.c:157 during DRM pipeline configuration
- Both are real-world, commonly exercised code paths on Renesas platforms
**Step 5.3-5.4: Call Chain**
Userspace → V4L2 ioctl → subdev dispatch → vsp1_rwpf_set_selection() The buggy path is directly reachable from userspace with arbitrary crop rectangle values.
**Step 5.5: Similar Patterns**
Other set_selection implementations in the same driver (uif_set_selection, histo_set_selection, brx_set_selection) use different clamping logic and are not affected by this same bug.
---
## PHASE 6: STABLE TREE ANALYSIS
**Step 6.1: Buggy Code in Stable Trees**
Verified the exact same buggy lines exist in:
- **v5.15**: min_t(unsigned int, sel->r.left, format->width - 2) at line 225 (path: drivers/media/platform/vsp1/vsp1_rwpf.c)
- **v6.1**: Same code at line 225 (path:
drivers/media/platform/renesas/vsp1/vsp1_rwpf.c)
- **v6.6**: Same code at line 225
- **v6.12**: Same code at line 212
**Step 6.2: Backport Complications**
- v6.12: Clean apply expected (same API as HEAD)
- v6.6, v6.1, v5.15: Minor context differences (older API names like vsp1_entity_get_pad_format vs v4l2_subdev_state_get_format), but the actual changed lines are identical. Straightforward adaptation needed.
**Step 6.3:** No related fixes already in stable for this issue.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1:**
- Subsystem: drivers/media (V4L2, Renesas VSP1)
- Criticality: PERIPHERAL but important — VSP1 is the video processing unit on Renesas R-Car and RZ platforms, used in automotive and industrial embedded systems
**Step 7.2:** The VSP1 driver is actively maintained by Laurent Pinchart with ongoing feature and fix development.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: Who is Affected**
Users of Renesas R-Car / RZ platforms with VSP1 hardware who set crop rectangles (via V4L2 or DRM APIs).
**Step 8.2: Trigger Conditions**
- Setting crop on an RPF subdevice when the sink pad format has odd or small dimensions (especially 1x1 YUV)
- Passing negative left/top values in the crop rectangle (legal __s32 values per V4L2 API)
- Reachable from unprivileged userspace via V4L2 ioctls
**Step 8.3: Failure Mode**
- Incorrect crop coordinates silently accepted → hardware misconfiguration → potential DMA to/from wrong memory regions
- V4L2 specification non-compliance (negative values adjusted to maximum instead of 0)
- Severity: **MEDIUM-HIGH** (incorrect hardware operation, potential memory safety implications via DMA)
**Step 8.4: Risk-Benefit**
- **Benefit**: HIGH — fixes real integer underflow bug reachable from userspace, prevents hardware misconfiguration
- **Risk**: VERY LOW — ~20 lines in a single function, changing only the type and method of clamping, well-tested by two independent testers
- Ratio: strongly favorable
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: Evidence Summary**
FOR backporting:
- Fixes a real signed/unsigned integer underflow bug in crop coordinate clamping
- The bug allows incorrect hardware configuration, reachable from userspace
- Fix is small (~20 lines), surgical (single function), obviously correct
- Written by the subsystem maintainer (Laurent Pinchart)
- Two independent Tested-by and one Reviewed-by
- Applied by the V4L2 co-maintainer (Hans Verkuil)
- Bug exists in ALL active stable trees (since 2013)
- Uses only standard kernel primitives (clamp_t, min) available in all stable trees
- Self-contained — no dependencies on other commits
AGAINST backporting:
- No reports of the bug triggering in the wild (no Reported-by)
- Requires minor adaptation for older stable trees (context differences)
- Niche hardware (Renesas VSP1) — fewer users than core kernel
**Step 9.2: Stable Rules Checklist**
1. Obviously correct and tested? **YES** — two testers, one reviewer, logic is straightforward
2. Fixes a real bug? **YES** — integer underflow in crop coordinate clamping
3. Important issue? **YES** — potential hardware misconfiguration, V4L2 spec violation
4. Small and contained? **YES** — ~20 lines in one function, one file
5. No new features/APIs? **CORRECT** — no new features
6. Can apply to stable? **YES** — with minor context adaptation for older trees
**Step 9.3: Exception Categories**
Not applicable — this is a standard bug fix, not a quirk/device-ID/DT addition.
---
## Verification
- [Phase 1] Parsed tags: Found Tested-by x2 (Niklas Söderlund, Lad Prabhakar), Reviewed-by (Jacopo Mondi), Signed-off-by (Laurent Pinchart + Hans Verkuil)
- [Phase 2] Diff analysis: ~20 lines changed in vsp1_rwpf_set_selection(), replaces min_t(unsigned int, ...) with clamp_t(int, ...) and adds min_width/min_height bounds
- [Phase 2] Verified struct v4l2_rect has __s32 left, top at include/uapi/linux/videodev2.h:442-447, confirming signed→unsigned cast bug
- [Phase 3] git blame: buggy min_t lines introduced by e5ad37b64de975 (2013, v3.12-era); YUV alignment by 85a0638b7855df (2015)
- [Phase 3] Author Laurent Pinchart is the original file author and subsystem maintainer (all blame entries)
- [Phase 3] File history: no prerequisite commits needed
- [Phase 5] Callers: vsp1_rwpf_set_selection registered as .set_selection in vsp1_rwpf_pad_ops:283, called from userspace V4L2 ioctls and from vsp1_drm.c:157
- [Phase 6] Verified identical buggy code in v5.15:225, v6.1:225, v6.6:225, v6.12:212
- [Phase 6] Verified clamp_t exists in v5.15 at include/linux/minmax.h:124
- [Phase 6] Minor context differences in v5.15/v6.1 (different API
names: vsp1_entity_get_pad_format vs v4l2_subdev_state_get_format) but core buggy lines are identical
- UNVERIFIED: Could not access lore.kernel.org due to anti-bot protection; reviewer/mailing-list discussion details not verified
- UNVERIFIED: Whether this is part of a multi-patch series where other patches are also needed (the Link msgid suggests patch 5 of N, but the fix is self-contained based on diff analysis)
The fix is small, surgical, obviously correct, well-tested, authored by the subsystem maintainer, fixes a real integer underflow bug present since 2013, and meets all stable kernel criteria.
**YES**
.../media/platform/renesas/vsp1/vsp1_rwpf.c | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-)
drivers/media/platform/renesas/vsp1/vsp1_rwpf.c +24 -4
@@ -216,6 +216,8 @@ static int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,struct v4l2_subdev_state *sd_state, struct v4l2_subdev_selection *sel) { + unsigned int min_width = RWPF_MIN_WIDTH; +unsigned int min_height =RWPF_MIN_HEIGHT ;struct vsp1_rwpf *rwpf =to_rwpf (subdev);struct v4l2_subdev_state *state;struct v4l2_mbus_framefmt *format;
@@ -244,18 +246,36 @@ static int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev, format =v4l2_subdev_state_get_format (state,RWPF_PAD_SINK );/* -* Restrict the crop rectangle coordinates to multiples of 2 to avoid -* shifting the color plane. +* For YUV formats, restrict the crop rectangle coordinates to multiples +* of 2 to avoid shifting the color plane. */ if (format->code ==MEDIA_BUS_FMT_AYUV8_1X32 ) { sel->r.left =ALIGN (sel->r.left,2 ); sel->r.top =ALIGN (sel->r.top,2 ); sel->r.width =round_down (sel->r.width,2 ); sel->r.height =round_down (sel->r.height,2 ); + +/* +* The RPF doesn't enforces the alignment constraint on the sink +* pad format, which could have an odd size, possibly down to +* 1x1. In that case, the minimum width and height would be +* smaller than the sink pad format, leading to a negative upper +* bound in the left and top clamping. Clamp the minimum width +* and height to the format width and height to avoid this. +* +* In such a situation, odd values for the crop rectangle size +* would be accepted when clamping the width and height below. +* While that would create an invalid hardware configuration, +* the video device enforces proper alignment of the pixel +* format, and the mismatch will then result in link validation +* failure. Incorrect operation of the hardware is not possible. +*/ + min_width =min (ALIGN (min_width,2 ), format->width); + min_height =min (ALIGN (min_height,2 ), format->height); } - sel->r.left = min_t(unsigned int, sel->r.left, format->width - 2); - sel->r.top = min_t(unsigned int, sel->r.top, format->height - 2); + sel->r.left =clamp_t (int, sel->r.left,0 , format->width - min_width); + sel->r.top =clamp_t (int, sel->r.top,0 , format->height - min_height); sel->r.width = min_t(unsigned int, sel->r.width, format->width - sel->r.left); sel->r.height = min_t(unsigned int, sel->r.height,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ASoC: amd: yc: Add DMI entry for HP Laptop 15-fc0xxx
In reply to Sasha LevinFrom: Gilson Marquato Júnior <[email protected]>
[ Upstream commit 8ec017cf31299c4b6287ebe27afe81c986aeef88 ]
The HP Laptop 15-fc0xxx (subsystem ID 0x103c8dc9) has an internal DMIC connected to the AMD ACP6x audio coprocessor. Add a DMI quirk entry so the internal microphone is properly detected on this model.
Tested on HP Laptop 15-fc0237ns with Fedora 43 (kernel 6.19.9).
---
LLM Generated explanations, may be completely bogus:
Error: Failed to generate final synthesis
sound/soc/amd/yc/acp6x-mach.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/yc/acp6x-mach.c +7 -0
@@ -45,6 +45,13 @@ static struct snd_soc_card acp6x_card = { };static const struct dmi_system_id yc_acp_quirk_table[] = { + { + .driver_data = &acp6x_card, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"HP" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"HP Laptop 15-fc0xxx" ), + } + }, { .driver_data = &acp6x_card, .matches = {
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 media: au0828: Fix green screen in analog
In reply to Sasha LevinFrom: Bradford Love <[email protected]>
[ Upstream commit 58119a0cffa8a597ce5d39587beb0f5a763434a0 ]
When the driver was converted to VB2 the original function to fix green frame detection was removed and a default vb2 dqbuf function was used instead. This vb2 dqbuf function leads to green frames not being detected and correupting stream captures.
The vidioc_dqbuf function checks the greenscreen flag, and, if set resets the stream to discard the green frame and decode a real frame.
---
LLM Generated explanations, may be completely bogus:
Here is my complete analysis:
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: Subject Line
- **Subsystem:** media: au0828
- **Action verb:** "Fix" - explicit bug fix
- **Summary:** Fixes green screen frames in analog video capture by restoring a hardware workaround lost during VB2 conversion
### Step 1.2: Tags
- Signed-off-by: Bradford Love <[email protected]> - the author, a known au0828 contributor
- Signed-off-by: Hans Verkuil <[email protected]> - the V4L2 subsystem maintainer who accepted the patch
- No Fixes: tag (expected for commits under review)
- No Cc: stable (expected)
### Step 1.3: Commit Body
The commit explains clearly:
- When the driver was converted to VB2 (videobuf2), the original vidioc_dqbuf function that contained greenscreen detection was removed
- It was replaced with the generic vb2_ioctl_dqbuf which has no greenscreen logic
- This causes green frames to go undetected, "correupting stream captures"
- The fix restores the custom vidioc_dqbuf that checks the greenscreen flag and resets the stream
### Step 1.4: Hidden Bug Fix Assessment
This is NOT a hidden bug fix - it explicitly says "Fix" and clearly describes a regression from the VB2 conversion.
**Record:** This is a regression fix restoring a hardware workaround that was accidentally removed during a refactoring 10+ years ago.
---
## PHASE 2: DIFF ANALYSIS
### Step 2.1: Inventory
- **File:** drivers/media/usb/au0828/au0828-video.c
- **Lines added:** ~21 (new vidioc_dqbuf function)
- **Lines changed:** 2 (ioctl_ops table entries: .vidioc_dqbuf and whitespace fix for .vidioc_expbuf)
- **Functions modified:** New vidioc_dqbuf() added; video_ioctl_ops struct updated
- **Scope:** Single-file, surgical fix
### Step 2.2: Code Flow Change
**Before:** video_ioctl_ops.vidioc_dqbuf pointed directly to vb2_ioctl_dqbuf, which simply dequeues a buffer with no greenscreen check.
**After:** A new wrapper vidioc_dqbuf() is called that:
1. Calls check_dev(dev) to verify device is connected/configured
2. Checks dev->greenscreen_detected flag
3. If set, calls au0828_analog_stream_reset(dev) (writes hardware registers to reset the stream) and clears the flag
4. Calls vb2_ioctl_dqbuf() for actual buffer dequeue
### Step 2.3: Bug Mechanism
This is a **logic/correctness fix** - specifically restoring a **hardware workaround**. The au0828 hardware has a design bug where the colorspace can sometimes be inverted, producing green frames. The detection code at line 377-380 still sets dev->greenscreen_detected = 1 when it detects inverted colorspace in the DMA buffer, but nothing ever reads this flag to trigger the stream reset. The fix closes this gap.
### Step 2.4: Fix Quality
- **Obviously correct:** Yes. It closely mirrors the pre-VB2 code that existed before commit 05439b1a3693.
- **Minimal/surgical:** Yes. Only adds a wrapper and changes one function pointer.
- **Regression risk:** Very low. The wrapper simply adds a check before calling the same generic function.
---
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: Blame
The line being modified (line 1767: .vidioc_dqbuf = vb2_ioctl_dqbuf) was introduced by commit 05439b1a3693 ("[media] media: au0828 - convert to use videobuf2") by Shuah Khan, dating to v3.19-rc6 era, merged in **v4.0**.
### Step 3.2: Fixes Target
The implicit "Fixes" target is 05439b1a36935 ("media: au0828 - convert to use videobuf2") which landed in v4.0. This commit exists in ALL active stable trees (5.4.y, 5.10.y, 5.15.y, 6.1.y, 6.6.y, 6.12.y, etc.).
The VB2 conversion removed the old vidioc_dqbuf that contained the greenscreen detection code (verified by git show 05439b1a3693 which shows the removal of the function with greenscreen_detected checks).
### Step 3.3: File History
The file has had minimal changes since ~v5.5 era. Recent changes are trivial (renaming timers, dropping wait_prepare/finish, using umin macro, USB API function changes). The area around the ioctl_ops table has been stable since the VB2 conversion.
### Step 3.4: Author
Bradford Love is a known au0828 contributor with other accepted fixes (error messages, kfree ordering). Hans Verkuil is THE V4L2 subsystem maintainer who signed off.
### Step 3.5: Dependencies
This fix is **standalone** - no prerequisites. It uses functions (check_dev, au0828_analog_stream_reset, vb2_ioctl_dqbuf) and the greenscreen_detected field that all exist in the tree since v4.0.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
### Step 4.1-4.5
b4 dig was unable to find the original patch submission (likely too recent or unusual submission path). Web searches also did not locate the specific lore thread. The patch was signed off by Hans Verkuil (V4L2 maintainer), confirming it passed review.
The original VB2 conversion series by Shuah Khan was a 3-patch series (confirmed via the lkml archive). Patch 3/3 actually removed the buffer timeout workaround - but NOT the greenscreen detection. The greenscreen detection setting (dev->greenscreen_detected = 1) remained in the code but became a dead store since the VB2 conversion removed the consumer side.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1: Functions
- **New:** vidioc_dqbuf() - wrapper around vb2_ioctl_dqbuf
- **References:** check_dev() (line 93), au0828_analog_stream_reset() (line 789), greenscreen_detected (set at line 380)
### Step 5.2: Callersvidioc_dqbuf is called by the V4L2 ioctl framework when userspace calls VIDIOC_DQBUF ioctl - this is every frame dequeue in video capture. It's a hot path for any application doing analog TV capture.
### Step 5.3: Callees
- check_dev(): Simple state check (disconnected/misconfigured)
- au0828_analog_stream_reset(): Writes hardware registers (SENSORCTRL_100) to reset the stream with a 30ms delay
- vb2_ioctl_dqbuf(): Standard VB2 buffer dequeue
### Step 5.4: Call Chain
Userspace (tvtime, xawtv, vlc, etc.) -> ioctl(VIDIOC_DQBUF) -> video_ioctl2 -> vidioc_dqbuf -> checks greenscreen -> vb2_ioctl_dqbuf. Very straightforward and commonly exercised path.
### Step 5.5: Similar Patterns
The greenscreen detection code (line 377-380) sets the flag based on pixel luminance values. Without the fix, this flag is set but never consumed - a clear dead-code indicator that something is missing.
---
## PHASE 6: STABLE TREE ANALYSIS
### Step 6.1: Code Existence
The buggy code (.vidioc_dqbuf = vb2_ioctl_dqbuf without greenscreen workaround) exists in **ALL stable trees** since v4.0. The greenscreen_detected field and au0828_analog_stream_reset() function also exist in all trees.
### Step 6.2: Backport Complications
Expected to apply **cleanly** or with trivial conflicts. The ioctl_ops table area and the insertion point (after vidioc_log_status) have been very stable. The only possible minor conflict is whitespace around the vidioc_expbuf alignment fix.
### Step 6.3: No related fixes already in stable for this issue.
---
## PHASE 7: SUBSYSTEM CONTEXT
### Step 7.1: Subsystem
- **Path:** drivers/media/usb/au0828/ - USB media driver
- **Criticality:** PERIPHERAL (specific USB TV capture hardware - Hauppauge HVR-950Q and similar)
- But: au0828 is a commonly used USB TV tuner chipset
### Step 7.2: Activity
The file sees very infrequent changes - stable/mature driver.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: Affected Users
Users of au0828-based USB TV capture devices (Hauppauge HVR-950Q, etc.) doing analog TV capture.
### Step 8.2: Trigger Conditions
The au0828 hardware can randomly invert colorspace, producing green frames. This is a hardware bug that occurs during normal analog TV capture - no special conditions needed. Every user of analog capture on this hardware can experience it.
### Step 8.3: Failure Mode Severity
- **Without fix:** Corrupted (green) video frames during analog capture
- **Severity:** MEDIUM-HIGH - the device doesn't crash but produces unusable output
- Not a crash or security issue, but a real functional regression that makes the hardware partially broken
### Step 8.4: Risk-Benefit Ratio
- **BENEFIT:** HIGH - restores correct functionality for all au0828 analog capture users
- **RISK:** VERY LOW - the fix is a simple wrapper that adds one check before calling the same generic function. The code pattern is identical to what existed pre-VB2 conversion for ~5 years. Accepted by the V4L2 maintainer.
- **Ratio:** Strongly favorable
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: Evidence
**FOR backporting:**
- Fixes a real, user-visible bug (green/corrupted video frames)
- Regression from VB2 conversion in v4.0 (~2015) - 10+ year old regression
- Small, surgical fix (~21 lines new code + 2 line change)
- Restores behavior that existed for years before the VB2 conversion
- Obviously correct - mirrors the pre-VB2 code closely
- Signed off by Hans Verkuil (V4L2 subsystem maintainer)
- Bug exists in ALL active stable trees
- Standalone fix with no dependencies
- Hardware workaround - exactly the type of fix stable trees accept
**AGAINST backporting:**
- No syzbot or sanitizer report (hardware-specific visual issue)
- Not a crash/security/data-corruption fix (but IS a functional regression fix)
- The greenscreen_detected flag access is not protected by locks (but this was the same in the pre-VB2 code and the flag is only set from URB completion context)
### Step 9.2: Stable Rules Checklist
1. **Obviously correct and tested?** YES - mirrors pre-VB2 code, accepted by maintainer
2. **Fixes a real bug?** YES - corrupted video frames for hardware users
3. **Important issue?** YES - functional regression making hardware partially unusable
4. **Small and contained?** YES - single file, ~23 lines total change
5. **No new features?** CORRECT - restores existing behavior
6. **Can apply to stable?** YES - clean apply expected, all required symbols present
### Step 9.3: Exception Categories
This qualifies as a **hardware quirk/workaround** - the greenscreen detection is a workaround for a hardware design flaw in the au0828 chip.
### Step 9.4: Decision
This is a clear regression fix that restores a hardware workaround accidentally removed during VB2 conversion. It meets all stable criteria.
---
## Verification
- [Phase 1] Parsed tags: Signed-off-by from author (Bradford Love) and maintainer (Hans Verkuil)
- [Phase 2] Diff analysis: 21 lines added (new vidioc_dqbuf wrapper), 2 lines changed in ioctl ops table
- [Phase 3] git blame (line 1767): Buggy code introduced by commit 05439b1a3693 (VB2 conversion, v4.0 era)
- [Phase 3] git show 05439b1a3693: Confirmed it removed old vidioc_dqbuf with greenscreen handling and replaced with generic vb2_ioctl_dqbuf
- [Phase 3] git describe: VB2 conversion is v3.19-rc6-230-g05439b1a36935, merged in v4.0
- [Phase 3] git log v3.19..v4.0: Confirmed 05439b1a36935 appears in v4.0
- [Phase 3] git tag --contains: Confirmed present in all stable trees (p-5.10, p-5.15, etc.)
- [Phase 4] b4 dig: Could not find original submission (too recent or unusual path)
- [Phase 4] LKML archive: Confirmed VB2 conversion was a 3-patch series that removed the timeout workaround but kept greenscreen_detected field
- [Phase 5] Grep check_dev: Used in other ioctls (line 1247), confirmed it exists and works the same way
- [Phase 5] Grep greenscreen_detected: Set at line 380 (au0828-video.c), declared at line 234 (au0828.h) - flag is set but never read without this fix
- [Phase 5] Grep au0828_analog_stream_reset: Called from lines 789, 1019, 1567, 1724 - well-established function
- [Phase 6] git log across stable versions: File barely changed since v5.5; fix should apply cleanly
- [Phase 8] Failure mode: Corrupted green video frames during analog capture, severity MEDIUM-HIGH
- UNVERIFIED: Could not locate the exact lore.kernel.org discussion thread for this specific patch
**YES**
drivers/media/usb/au0828/au0828-video.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
drivers/media/usb/au0828/au0828-video.c +23 -2
@@ -1671,6 +1671,27 @@ static int vidioc_log_status(struct file *file, void *fh)return 0 ; } +static int vidioc_dqbuf (struct file *file,void *priv,struct v4l2_buffer *b) +{ +struct au0828_dev *dev =video_drvdata (file); +int rc; + + rc =check_dev (dev); +if (rc <0 ) +return rc; + +/* Workaround for a bug in the au0828 hardware design that +* sometimes results in the colorspace being inverted +*/ +if (dev->greenscreen_detected ==1 ) { +dprintk (1 ,"Detected green frame. Resetting stream...\n" ); +au0828_analog_stream_reset (dev); + dev->greenscreen_detected =0 ; + } + +return vb2_ioctl_dqbuf (file, priv, b); +} +void au0828_v4l2_suspend (struct au0828_dev *dev) {struct urb *urb;
@@ -1764,8 +1785,8 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { .vidioc_prepare_buf = vb2_ioctl_prepare_buf, .vidioc_querybuf = vb2_ioctl_querybuf, .vidioc_qbuf = vb2_ioctl_qbuf, - .vidioc_dqbuf = vb2_ioctl_dqbuf, - .vidioc_expbuf = vb2_ioctl_expbuf, + .vidioc_dqbuf = vidioc_dqbuf, + .vidioc_expbuf = vb2_ioctl_expbuf, .vidioc_s_std = vidioc_s_std, .vidioc_g_std = vidioc_g_std,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ASoC: Intel: avs: Fix memory leak in avs_register_i2s_test_boards()
In reply to Sasha LevinFrom: Cezary Rojewski <[email protected]>
[ Upstream commit c5408d818316061d6063c11a4f47f1ba25a3a708 ]
Caller is responsible for freeing array allocated with parse_int_array().
Found out by Coverity.
---
LLM Generated explanations, may be completely bogus:
Error: Failed to generate final synthesis
sound/soc/intel/avs/board_selection.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/soc/intel/avs/board_selection.c +6 -3
@@ -520,7 +520,8 @@ static int avs_register_i2s_test_boards(struct avs_dev *adev)if (num_elems > max_ssps) {dev_err (adev->dev,"board supports only %d SSP, %d specified\n" , max_ssps, num_elems); -return -EINVAL ; + ret = -EINVAL ; + goto exit; }for (ssp_port =0 ; ssp_port < num_elems; ssp_port++) {
@@ -528,11 +529,13 @@ static int avs_register_i2s_test_boards(struct avs_dev *adev)for_each_set_bit (tdm_slot, &tdm_slots,16 ) { ret =avs_register_i2s_test_board (adev, ssp_port, tdm_slot);if (ret) -return ret; + goto exit; } } -return 0 ; +exit: +kfree (array); +return ret; }static int avs_register_i2s_board (struct avs_dev *adev,struct snd_soc_acpi_mach *mach)
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 nvme-loop: do not cancel I/O and admin tagset during ctrl reset/shutdown
In reply to Sasha LevinFrom: Nilay Shroff <[email protected]>
[ Upstream commit 886f35201591ded7958e16fe3750871d3ca0bcdf ]
Cancelling the I/O and admin tagsets during nvme-loop controller reset or shutdown is unnecessary. The subsequent destruction of the I/O and admin queues already waits for all in-flight target operations to complete.
Cancelling the tagsets first also opens a race window. After a request tag has been cancelled, a late completion from the target may still arrive before the queues are destroyed. In that case the completion path may access a request whose tag has already been cancelled or freed, which can lead to a kernel crash. Please see below the kernel crash encountered while running blktests nvme/040:
run blktests nvme/040 at 2026-03-08 06:34:27
loop0: detected capacity change from 0 to 2097152
nvmet: adding nsid 1 to subsystem blktests-subsystem-1
nvmet: Created nvm controller 1 for subsystem blktests-subsystem-1 for NQN nqn.2014-08.org.nvmexpress:uuid:0f01fb42-9f7f-4856-b0b3-51e60b8de349. nvme nvme6: creating 96 I/O queues.
nvme nvme6: new ctrl: "blktests-subsystem-1"nvme_log_error: 1 callbacks suppressed
block nvme6n1: no usable path - requeuing I/O
nvme6c6n1: Read(0x2) @ LBA 2096384, 128 blocks, Host Aborted Command (sct 0x3 / sc 0x71)blk_print_req_error: 1 callbacks suppressed
I/O error, dev nvme6c6n1, sector 2096384 op 0x0:(READ) flags 0x2880700 phys_seg 1 prio class 2
block nvme6n1: no usable path - requeuing I/O
Kernel attempted to read user page (236) - exploit attempt? (uid: 0)
BUG: Kernel NULL pointer dereference on read at 0x00000236 Faulting instruction address: 0xc000000000961274 Oops: Kernel access of bad area, sig: 11 [#1] LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries Modules linked in: nvme_loop nvme_fabrics loop nvmet null_blk rpadlpar_io rpaphp xsk_diag bonding rfkill nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nf_tables nfnetlink pseries_rng dax_pmem vmx_crypto drm drm_panel_orientation_quirks xfs mlx5_core nvme bnx2x sd_mod nd_pmem nd_btt nvme_core sg papr_scm tls libnvdimm ibmvscsi ibmveth scsi_transport_srp nvme_keyring nvme_auth mdio hkdf pseries_wdt dm_mirror dm_region_hash dm_log dm_mod fuse [last unloaded: loop] CPU: 25 UID: 0 PID: 0 Comm: swapper/25 Kdump: loaded Not tainted 7.0.0-rc3+ #14 PREEMPT Hardware name: IBM,9043-MRX Power11 (architected) 0x820200 0xf000007 of:IBM,FW1120.00 (RF1120_128) hv:phyp pSeries NIP: c000000000961274 LR: c008000009af1808 CTR: c00000000096124c REGS: c0000007ffc0f910 TRAP: 0300 Not tainted (7.0.0-rc3+) MSR: 8000000000009033 <SF,EE,ME,IR,DR,RI,LE> CR: 22222222 XER: 00000000 CFAR: c008000009af232c DAR: 0000000000000236 DSISR: 40000000 IRQMASK: 0
GPR00: c008000009af17fc c0000007ffc0fbb0 c000000001c78100 c0000000be05cc00
GPR04: 0000000000000001 0000000000000000 0000000000000007 0000000000000000
GPR08: 0000000000000000 0000000000000000 0000000000000002 c008000009af2318
GPR12: c00000000096124c c0000007ffdab880 0000000000000000 0000000000000000
GPR16: 0000000000000010 0000000000000000 0000000000000004 0000000000000000
GPR20: 0000000000000001 c000000002ca2b00 0000000100043bb2 000000000000000a
GPR24: 000000000000000a 0000000000000000 0000000000000000 0000000000000000
GPR28: c000000084021d40 c000000084021d50 c0000000be05cd60 c0000000be05cc00 NIP [c000000000961274] blk_mq_complete_request_remote+0x28/0x2d4 LR [c008000009af1808] nvme_loop_queue_response+0x110/0x290 [nvme_loop]
Call Trace: 0xc00000000502c640 (unreliable) nvme_loop_queue_response+0x104/0x290 [nvme_loop] __nvmet_req_complete+0x80/0x498 [nvmet] nvmet_req_complete+0x24/0xf8 [nvmet] nvmet_bio_done+0x58/0xcc [nvmet] bio_endio+0x250/0x390 blk_update_request+0x2e8/0x68c blk_mq_end_request+0x30/0x5c lo_complete_rq+0x94/0x110 [loop] blk_complete_reqs+0x78/0x98 handle_softirqs+0x148/0x454 do_softirq_own_stack+0x3c/0x50 __irq_exit_rcu+0x18c/0x1b4 irq_exit+0x1c/0x34 do_IRQ+0x114/0x278 hardware_interrupt_common_virt+0x28c/0x290
Since the queue teardown path already guarantees that all target-side operations have completed, cancelling the tagsets is redundant and unsafe. So avoid cancelling the I/O and admin tagsets during controller reset and shutdown.
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed. Let me compile the complete analysis.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: Subject Line
- **Subsystem**: nvme-loop (NVMe over Fabrics loopback target driver)
- **Action verb**: "do not cancel" - explicitly removing code that causes a bug
- **Summary**: Removes unnecessary and dangerous tagset cancellation from controller reset/shutdown path
### Step 1.2: Tags
- **Reviewed-by**: Christoph Hellwig <[email protected]> - NVMe subsystem co- maintainer, a very strong review signal
- **Signed-off-by**: Nilay Shroff <[email protected]> - author, IBM NVMe developer with history of nvme-loop fixes
- **Signed-off-by**: Keith Busch <[email protected]> - NVMe maintainer who applied the patch
- No Fixes: tag, no Cc: stable (expected for AUTOSEL candidates)
- No Reported-by other than the author (crash found during blktests)
### Step 1.3: Commit Body Analysis
The bug: During nvme-loop controller shutdown, the code cancels tagsets then destroys queues. But after a tag is cancelled, a late target-side completion can arrive (via nvme_loop_queue_response()) before queue destruction. This completion accesses a request that's already been cancelled/freed, causing a NULL pointer dereference in blk_mq_complete_request_remote().
The full crash stack trace is included showing rq->mq_hctx is NULL, reproducing on blktests nvme/040 on IBM Power11 hardware with kernel 7.0.0-rc3+.
### Step 1.4: Hidden Bug Fix Detection
This is an explicit, clear crash fix, not disguised.
---
## PHASE 2: DIFF ANALYSIS
### Step 2.1: Inventory
- **Files changed**: 1 (drivers/nvme/target/loop.c)
- **Lines removed**: 2, **Lines added**: 0
- **Functions modified**: nvme_loop_shutdown_ctrl()
- **Scope**: Extremely surgical - single function, 2 line removal
### Step 2.2: Code Flow Change
**Before**: quiesce_io -> cancel_tagset -> destroy_io_queues -> quiesce_admin -> disable_ctrl -> cancel_admin_tagset -> destroy_admin_queue
**After**: quiesce_io -> destroy_io_queues -> quiesce_admin -> disable_ctrl -> destroy_admin_queue
The cancel step is removed because nvmet_sq_destroy() inside the destroy functions already calls percpu_ref_kill_and_confirm() + wait_for_completion() twice, guaranteeing all in-flight target operations complete before continuing.
### Step 2.3: Bug Mechanism
This is a **race condition / use-after-free** fix:
1. nvme_cancel_tagset() iterates in-flight requests and calls blk_mq_complete_request() on each, marking them done
2. The target side (running in the nvmet workqueue) has an outstanding bio that hasn't completed yet
3. When nvmet_bio_done() fires, it goes through nvmet_req_complete() -> nvme_loop_queue_response() -> blk_mq_complete_request_remote()
4. At this point, the request has already been freed/cancelled, so rq->mq_hctx is NULL -> crash
### Step 2.4: Fix Quality
- **Obviously correct**: The cancel calls are demonstrably redundant because nvmet_sq_destroy() does a full wait-for-completion. Verified in code at line 969-970 of drivers/nvme/target/core.c.
- **Minimal**: Only 2 lines removed
- **Regression risk**: Very low. The cancel is redundant for nvme-loop. Other transports (tcp, rdma, pci) still use cancel because they don't have a local target queue to wait on.
- **Important**: The error path cancel calls (lines 496 and 636) are preserved - those are during controller init, not shutdown, where queues aren't fully set up.
---
## PHASE 3: GIT HISTORY
### Step 3.1: Blame
The nvme_cancel_tagset() and nvme_cancel_admin_tagset() calls were introduced by commit e41f8c0222e30 (Sagi Grimberg, 2022-06-26) "nvme-
loop: use nvme core helpers to cancel all requests in a tagset". That was a pure refactoring - replacing open-coded blk_mq_tagset_busy_iter with the helper. The underlying cancel logic existed since the original nvme-loop driver.
### Step 3.2: Fixes Tag
No Fixes: tag. The bug is inherent to having cancel + destroy in nvme- loop's shutdown, which has been this way since at least v6.0. A strict
Fixes: tag would point to e41f8c0222e30 (v6.0+).
### Step 3.3: Related Changes
The same author (Nilay Shroff) previously submitted c199fac88fe7c "nvme-loop: flush off pending I/O while shutting down loop controller" which added nvme_unquiesce_* calls to the destroy functions. That's a related but distinct fix for a different race (hung tasks from I/O sneaking in between quiesce and destroy).
### Step 3.4: Author
Nilay Shroff is an active NVMe developer at IBM, with multiple contributions to the nvme subsystem. Previous nvme-loop shutdown/crashfix patches from him were accepted and merged.
### Step 3.5: Dependencies
**This patch is self-contained**. It only removes 2 lines. No prerequisites needed.
---
## PHASE 4: MAILING LIST
### Step 4.1: Original Thread
Found via infradead pipermail:
- **Cover letter**: [http://lists.infradead.org/pipermail/linux-nvme/202
6-March/061768.html](http://lists.infradead.org/pipermail/linux- nvme/2026-March/061768.html)
- **Patch**: [http://lists.infradead.org/pipermail/linux-nvme/2026-
March/061767.html](http://lists.infradead.org/pipermail/linux- nvme/2026-March/061767.html)
The cover letter provides an even more detailed explanation of the race, showing that rq->mq_hctx is NULL when the kernel tries to dereference it.
### Step 4.2: Review
- **Christoph Hellwig** (NVMe co-maintainer) on Mar 20: "Looks good:
Reviewed-by: Christoph Hellwig"
- **Keith Busch** (NVMe maintainer) on Mar 24: "Thanks, applied to nvme-7.1."
- No NAKs, no concerns raised by any reviewer.
- Single version patch (no v2/v3 iterations needed).
### Step 4.3-4.5: No stable-specific discussion found. No additional reports.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1-5.2: Functions
The modified function nvme_loop_shutdown_ctrl() is called from:
1. nvme_loop_delete_ctrl_host() - controller deletion path
2. nvme_loop_reset_ctrl_work() - controller reset path
Both are critical controller lifecycle paths.
### Step 5.3-5.4: Calleesnvme_cancel_tagset() calls blk_mq_tagset_busy_iter() + nvme_cancel_request() which calls blk_mq_complete_request(). The late completion from nvmet_bio_done() -> nvme_loop_queue_response() also calls blk_mq_complete_request() on the same request. Double- completion of a freed request = crash.
nvmet_sq_destroy() calls percpu_ref_kill_and_confirm() followed by wait_for_completion(&sq->confirm_done) and wait_for_completion(&sq->free_done) - this guarantees all in-flight target operations complete before proceeding.
---
## PHASE 6: STABLE TREE ANALYSIS
### Step 6.1: Buggy code in stable trees
- e41f8c0222e30 (introduced the cancel helper calls) is in **v6.0, v6.1, v6.6** and later
- The bug exists in all active stable trees: **v6.1.y, v6.6.y, v6.12.y**
- NOT present in v5.15 (the older open-coded cancel was different)
### Step 6.2: Backport complications
The patch removes the exact same 2 lines (nvme_cancel_tagset() and nvme_cancel_admin_tagset()) from nvme_loop_shutdown_ctrl(). Verified the v6.6 and v6.1 code has these lines at the same locations. The surrounding context differs slightly (nvme_ctrl_state() vs ctrl->ctrl.state, presence/absence of CQ sharing code), but the lines being removed are identical. **Should apply cleanly with trivial context adjustment.**
---
## PHASE 7: SUBSYSTEM CONTEXT
### Step 7.1: Subsystem
- **Subsystem**: NVMe over Fabrics loopback (drivers/nvme/target/loop.c)
- **Criticality**: IMPORTANT - NVMe loopback is used in testing (blktests), CI pipelines, and some production setups for local NVMe-oF workloads.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: Who is affected
Users of nvme-loop (NVMe over Fabrics loopback) who perform controller reset/shutdown while I/O is in-flight.
### Step 8.2: Trigger conditions
Triggered during blktests nvme/040 - a standard NVMe test. Race requires in-flight I/O during controller shutdown, which is a normal occurrence.
### Step 8.3: Failure mode
**CRITICAL**: Kernel NULL pointer dereference (oops), crash in softirq context (swapper/25 at CPU 25). This is a system crash.
### Step 8.4: Risk-Benefit
- **Benefit**: Very HIGH - prevents kernel crash during normal NVMe loopback controller shutdown
- **Risk**: Very LOW - 2 lines removed, confirmed redundant by code analysis (nvmet_sq_destroy does wait_for_completion), reviewed by subsystem co-maintainer
- **Ratio**: Extremely favorable
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: Evidence
**FOR backporting:**
- Fixes a real kernel crash (NULL pointer dereference -> oops)
- Crash reproduced with standard blktests nvme/040
- Extremely small: 2 lines removed
- Fix is obviously correct: removed code is provably redundant
- Reviewed by Christoph Hellwig (NVMe co-maintainer)
- Applied by Keith Busch (NVMe maintainer)
- Buggy code exists in stable trees v6.1.y, v6.6.y, v6.12.y
- Patch should apply cleanly with at most trivial context adjustment
- No regression risk - other transports unaffected
- Author has established track record with nvme-loop fixes
**AGAINST backporting:**
- No Fixes: tag (expected for AUTOSEL candidates)
- No Cc: stable (expected)
- Patch was applied to nvme-7.1, not tagged as a fix for 7.0
### Step 9.2: Stable Rules Checklist
1. **Obviously correct and tested?** YES - crash stack trace + blktests reproduction, reviewed by co-maintainer
2. **Fixes a real bug?** YES - kernel crash/oops
3. **Important issue?** YES - system crash (CRITICAL)
4. **Small and contained?** YES - 2 lines in 1 file
5. **No new features/APIs?** Correct - pure removal
6. **Can apply to stable?** YES - lines exist identically in v6.1.y, v6.6.y, v6.12.y
### Step 9.3: Exception categories
Not applicable - this is a standard crash fix, not an exception category.
---
## Verification
- [Phase 1] Parsed tags: Reviewed-by Christoph Hellwig, Signed-off-by Keith Busch (NVMe maintainer)
- [Phase 2] Diff analysis: 2 lines removed from nvme_loop_shutdown_ctrl(), removing nvme_cancel_tagset() and nvme_cancel_admin_tagset() calls
- [Phase 2] Verified nvmet_sq_destroy() does wait_for_completion(&sq->confirm_done) + wait_for_completion(&sq->free_done) at lines 969-970 of drivers/nvme/target/core.c - confirms redundancy claim
- [Phase 3] git blame: cancel calls introduced by e41f8c0222e30 (v6.0, Sagi Grimberg, 2022-06-26)
- [Phase 3] git merge-base --is-ancestor: e41f8c0222e30 is in v6.1 (YES), v6.6 (YES), NOT in v5.15
- [Phase 3] Author's prior commit c199fac88fe7c (related nvme-loop shutdown fix) confirms expertise
- [Phase 4] Original submission found on lists.infradead.org: cover letter (#061768), patch (#061767)
- [Phase 4] Christoph Hellwig review (#061882): "Looks good: Reviewed- by"
- [Phase 4] Keith Busch applied (#061934): "Thanks, applied to nvme-7.1"
- [Phase 4] Single version, no v2/v3, no NAKs or concerns
- [Phase 5] nvme_loop_shutdown_ctrl() called from controller delete and reset paths
- [Phase 5] Verified nvme_cancel_request() calls blk_mq_complete_request(), creating the double-completion race with target-side nvme_loop_queue_response()
- [Phase 6] Verified v6.6 and v6.1 stable trees have the same cancel lines at identical locations in nvme_loop_shutdown_ctrl()
- [Phase 6] Patch will need trivial context adjustment for v6.6 (ctrl->ctrl.state vs nvme_ctrl_state())
- [Phase 8] Failure mode: NULL pointer dereference in softirq -> kernel oops, CRITICAL severity
This is a textbook stable backport candidate: a tiny, obviously correct crash fix for a real race condition, reviewed by the subsystem co- maintainer, with zero regression risk.
**YES**
drivers/nvme/target/loop.c | 2 -- 1 file changed, 2 deletions(-)
drivers/nvme/target/loop.c +0 -2
@@ -419,7 +419,6 @@ static void nvme_loop_shutdown_ctrl(struct nvme_loop_ctrl *ctrl) {if (ctrl->ctrl.queue_count >1 ) {nvme_quiesce_io_queues (&ctrl->ctrl); -nvme_cancel_tagset (&ctrl->ctrl);nvme_loop_destroy_io_queues (ctrl); }
@@ -427,7 +426,6 @@ static void nvme_loop_shutdown_ctrl(struct nvme_loop_ctrl *ctrl)if (nvme_ctrl_state (&ctrl->ctrl) ==NVME_CTRL_LIVE )nvme_disable_ctrl (&ctrl->ctrl, true); -nvme_cancel_admin_tagset (&ctrl->ctrl);nvme_loop_destroy_admin_queue (ctrl); }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 bpf, sockmap: Annotate af_unix sock:: Sk_state data-races
In reply to Sasha LevinFrom: Michal Luczaj <[email protected]>
[ Upstream commit a25566084e391348385a72dd507e0cc0c268dd5d ]
sock_map_sk_state_allowed() and sock_map_redirect_allowed() read af_unix socket sk_state locklessly.
Use READ_ONCE(). Note that for sock_map_redirect_allowed() change affects not only af_unix, but all non-TCP sockets (UDP, af_vsock).
---
LLM Generated explanations, may be completely bogus:
Now I have enough context. Let me compile my analysis.
## Phase 1: Commit Message Forensics
**Step 1.1 - Subject Line Parse:**
- Subsystem: bpf, sockmap:
- Action verb: "Annotate" (not "fix")
- Summary: Adds READ_ONCE() to two lockless reads of af_unix sk_state in sock_map.c
Record: bpf/sockmap subsystem, annotation (data race), adds READ_ONCE() to sk_state reads
**Step 1.2 - Tags:**
- Suggested-by: Kuniyuki Iwashima (networking/af_unix expert)
- Suggested-by: Martin KaFai Lau (BPF maintainer)
- Signed-off-by: Michal Luczaj (original author)
- Signed-off-by: Martin KaFai Lau (maintainer applied)
- Reviewed-by: Jiayuan Chen
- Reviewed-by: Kuniyuki Iwashima
- Link: to v4 on patch.msgid.link
- **No** Fixes: tag
- **No** Cc: stable
- **No** syzbot/KCSAN report
Record: Strong review endorsement (both suggesters are reviewers); no Fixes:/stable tags; no concrete bug report cited.
**Step 1.3 - Body Text:**
The commit explicitly acknowledges that sock_map_sk_state_allowed() and sock_map_redirect_allowed() read sk_state "locklessly". Change uses READ_ONCE(). Notes the redirect_allowed change also affects UDP and af_vsock. No crash/panic/reproducer described in body — it's purely a data race annotation.
Record: Describes data race (paired writer uses WRITE_ONCE); no user- visible symptom documented.
**Step 1.4 - Hidden fix?**
"Annotate data-races" is standard kernel terminology for adding READ_ONCE/WRITE_ONCE pairings. This is a recognized synchronization bug fix pattern per KCSAN/C11 memory model, even without a concrete crash.
## Phase 2: Diff Analysis
**Step 2.1 - Inventory:** Single file net/core/sock_map.c, 2 lines changed (2 insertions, 2 deletions). Two functions modified:sock_map_redirect_allowed() and sock_map_sk_state_allowed(). Minimal surgical scope.
**Step 2.2 - Code flow:** Before/after behavior is identical modulo
compiler: READ_ONCE prevents load tearing/reordering/fusion by the compiler for lockless reads.
**Step 2.3 - Bug mechanism:** Category (b) Synchronization. This is a completion of a WRITE_ONCE/READ_ONCE pair: writer side at net/unix/af_unix.c:1775 uses WRITE_ONCE(sk->sk_state, TCP_ESTABLISHED) in unix_stream_connect(), but sock_map.c readers were plain reads — a data race per kernel/C11 rules.
**Step 2.4 - Fix quality:** Obviously correct. Zero regression risk — READ_ONCE is a compiler barrier with no runtime cost on aligned reads.
## Phase 3: Git History
**Step 3.1 - Blame:** The affected lines originated from:
- sock_map_redirect_allowed: commit 122e6c79efe1c2 (Cong Wang, 2021)
- sock_map_sk_state_allowed af_unix branch: commit 8d6650646ce49e (John Fastabend, Dec 2023 - fixing syzkaller null ptr deref in unix_bpf)
The af_unix branch of sock_map_sk_state_allowed was added in v6.8 (Dec 2023).
**Step 3.2 - Fixes tag:** No Fixes: tag on this patch. The series' patch 5/5 has Fixes: c63829182c37 ("af_unix: Implement ->psock_update_sk_prot()") — the null-ptr-deref is fixed there, not here.
**Step 3.3 - File history:** Recent active development on sock_map.c. This is patch 1/5 of a series fixing a null-ptr-deref that crashes via unix_stream_bpf_update_proto+0xa0. Patch 5/5 is the actual crash fix.
**Step 3.4 - Author's role:** Michal Luczaj is an active vsock/unix contributor. Martin KaFai Lau (BPF maintainer) applied it. Kuniyuki Iwashima is the af_unix expert.
**Step 3.5 - Dependencies:** This patch is independent of the rest of the series — it touches separate code than patches 2-5. No dependencies.
## Phase 4: Mailing List Research
**Step 4.1 - Original submission:** Found v3 on lore/yhbt and v4 referenced in the commit (20260414-unix-proto-update-null-ptr-deref-v4).
Series: [PATCH bpf v3 0/5] bpf, sockmap: Fix af_unix null-ptr-deref in proto update.
**Step 4.2 - Reviewers:** Networking maintainers (Paolo, Jakub, Kuniyuki, Eric Dumazet), BPF maintainers (Martin, Alexei, Daniel), af_unix expert Kuniyuki explicitly reviewed and ACKed this patch.
**Step 4.3 - Bug report:** The series is motivated by a NULL ptr deref crash (shown in patch 5/5's commit message) but THIS specific patch has no explicit crash reporter. Kuniyuki notes: "Actually TCP path also needs READ_ONCE(), but I think it's okay for now since this series focuses on AF_UNIX" — confirming this is the known-pattern data race annotation.
**Step 4.4 - Series context:** This is 1/5 of a series:
1. (this one) READ_ONCE annotations
2. Refactor to sock_map_sk_{acquire,release}() helpers
3. Fix af_unix iter deadlock (has Fixes: tag)
4. Selftest
5. Adapt sockmap for af_unix locking (has Fixes: tag — the actual null- ptr-deref fix)
**Step 4.5 - Stable discussion:** No explicit stable nomination. Author himself noted patch 5/5's locking would make this READ_ONCE redundant for the af_unix path, but the patch was kept as a minimal standalone hardening.
## Phase 5: Code Semantic Analysis
**Step 5.1 - Functions modified:** sock_map_redirect_allowed(), sock_map_sk_state_allowed()
**Step 5.2 - Callers:**
- sock_map_redirect_allowed(): 4 callers — bpf_sk_redirect_map, bpf_msg_redirect_map, bpf_sk_redirect_hash, bpf_msg_redirect_hash. Called from BPF programs at runtime (hot path).
- sock_map_sk_state_allowed(): 2 callers in sock_map_update_elem_sys and sock_map_update_elem — invoked on BPF_MAP_UPDATE_ELEM syscall.
**Step 5.3 - Callees:** Just reads sk->sk_state and does bitmask comparison.
**Step 5.4 - Reachability:** Reachable from userspace via bpf() syscall (BPF_MAP_UPDATE_ELEM) and from BPF programs redirecting sockets — CONFIRMED reachable.
**Step 5.5 - Similar patterns:** Found the same pattern in net/unix/diag.c (commit 0aa3be7b3e1f8 "af_unix: Annotate data-races around sk->sk_state in UNIX_DIAG") — had Fixes: tags and went to **ALL** stable trees: 5.10, 5.15, 6.1, 6.6, 6.12, 6.17, 6.18. Strong precedent.
## Phase 6: Cross-referencing Stable Trees
**Step 6.1 - Code in stable:**
- sock_map_redirect_allowed(): Present in ALL active stable trees (5.10, 5.15, 6.1, 6.6, 6.12, 6.17, 6.18)
- sock_map_sk_state_allowed() af_unix branch (hunk 2): Only in 6.6.y and newer (added in v6.8 by backport of 8d6650646ce49)
**Step 6.2 - Backport complications:** Hunk 1 (sock_map_redirect_allowed) applies to all trees. Hunk 2 (sock_map_sk_state_allowed af_unix branch) only applies to 6.6+ where the af_unix branch exists. Minor adjustment for older trees (drop hunk 2). Clean for 6.6+.
**Step 6.3 - Related fixes in stable:** Precedent 0aa3be7b3e1f8 is in ALL stable trees — shows the same type of annotation is routinely accepted.
## Phase 7: Subsystem Context
**Step 7.1 - Subsystem:** net/core/sock_map.c = networking core + BPF. IMPORTANT criticality (BPF sockmap used in user-space networking stacks like Cilium).
**Step 7.2 - Activity:** Actively developed subsystem with recent bug fixes.
## Phase 8: Impact Assessment
**Step 8.1 - Affected users:** BPF sockmap users on systems with af_unix BPF usage, and any users with BPF programs using sk_redirect/msg_redirect on non-TCP sockets.
**Step 8.2 - Trigger:** Concurrent BPF_MAP_UPDATE_ELEM on a socket that's undergoing state change (e.g., unix_stream_connect). On most archs with aligned int reads, load tearing is unlikely, but compiler fusion/reordering is possible. KCSAN would flag this.
**Step 8.3 - Failure mode:** Without READ_ONCE alone, theoretical compiler-induced mis-behavior (torn/fused reads of sk_state leading to wrong state checks). The concrete null-ptr-deref described in the series is NOT fixed by this patch alone — that's fixed by patch 5/5. Severity:
LOW-MEDIUM for this patch in isolation.
**Step 8.4 - Risk/benefit:**
- Risk: ~zero (READ_ONCE is a compiler barrier; no runtime change on aligned reads)
- Benefit: Completes WRITE_ONCE/READ_ONCE pair, silences KCSAN, hardens against compiler edge cases
## Phase 9: Final Synthesis
**Evidence FOR backporting:**
- Fixes a genuine data race (plain read paired with WRITE_ONCE on the writer)
- Very small, surgical, obviously correct (2 lines)
- Strong reviewer endorsement (Kuniyuki, Jiayuan, Martin)
- Strong precedent: 0aa3be7b3e1f8 (identical pattern) was accepted into ALL stable trees with Fixes: tags
- Zero regression risk
**Evidence AGAINST backporting:**
- No Fixes: tag on THIS specific patch
- No Cc: stable tag
- No concrete syzbot/KCSAN report cited
- By itself, does NOT fix the null-ptr-deref (that's patch 5/5)
- Author acknowledged patch 5/5's proper locking would make this redundant on af_unix path
- "Annotation only" — preventive rather than curative for the crash
**Stable Rules checklist:**
1. Obviously correct and tested? YES (trivial READ_ONCE; reviewed by multiple maintainers)
2. Fixes a real bug? YES (data race per C11/kernel rules) but not a user-visible crash alone
3. Important issue? MEDIUM (data race without concrete trigger)
4. Small and contained? YES (2 lines)
5. No new features/APIs? YES
6. Applies to stable? Mostly — hunk 2 needs 6.6+ but hunk 1 applies everywhere
**Decision analysis:** This is a borderline case. The patch itself is pure annotation with no concrete user-visible crash fix in isolation. However, the precedent (0aa3be7b3e1f8) strongly shows this annotation pattern IS routinely accepted into stable, including down to 5.10.y. The patch is 2 lines, zero-risk, and completes a real WRITE_ONCE/READ_ONCE pair. The Kuniyuki review noting "TCP path also needs READ_ONCE()" indicates this is a recognized pattern.
Given:
- The precedent of identical-pattern commits going to all stable trees
- Zero regression risk
- Real (if benign) data race being fixed
- Strong review from domain experts
## Verification
- [Phase 1] Parsed tags: no Fixes:, no Cc: stable, but strong Reviewed- by from networking maintainer Kuniyuki and BPF maintainer Martin KaFai Lau
- [Phase 2] Diff analysis: exactly 2 lines changed, adds READ_ONCE() to 2 lockless sk_state reads
- [Phase 2] Verified writer pairs with WRITE_ONCE at net/unix/af_unix.c:1556, 1775 in unix_stream_connect
- [Phase 3] git blame: affected code introduced by 122e6c79efe1c2 (2021) and 8d6650646ce49e (Dec 2023, v6.8)
- [Phase 3] git show c63829182c37: confirmed Fixes: target from patch 5/5 is from 2021 (widely in stable)
- [Phase 4] Found lore discussion on yhbt.net showing full series thread
- [Phase 4] Confirmed this is patch 1/5; real null-ptr-deref crash is fixed by patch 5/5
- [Phase 4] Kuniyuki review comment: "Actually TCP path also needs READ_ONCE()" — confirms this is an incremental fix of a broader race pattern
- [Phase 5] grep sock_map_redirect_allowed: 4 callers in sockmap BPF redirect hooks
- [Phase 5] grep sock_map_sk_state_allowed: 2 callers in BPF_MAP_UPDATE_ELEM paths
- [Phase 5] Found precedent commit 0aa3be7b3e1f8 ("af_unix: Annotate data-races around sk->sk_state in UNIX_DIAG") — same pattern
- [Phase 6] Verified code presence in stable trees: redirect_allowed exists in all; state_allowed af_unix branch only in 6.6+ (6.6, 6.12, 6.17, 6.18 checked)
- [Phase 6] Confirmed precedent 0aa3be7b3e1f8 backported to linux-5.10.y, 5.15.y, 6.1.y, 6.6.y, 6.12.y, 6.17.y, 6.18.y — all active stable trees
- [Phase 8] Failure mode: data race (compiler-level), severity LOW- MEDIUM in isolation
- UNVERIFIED: Whether the v4 of the series has been applied to mainline (appears not yet, as I couldn't locate the commit SHA in local mainline snapshot — checked bpf-next and linus-next/master)
- UNVERIFIED: Whether the rest of the series (patches 2-5) will also go through autoselection
The patch is 2 lines of low-risk data race annotation with strong precedent for acceptance into all active stable trees. While it doesn't fix the null-ptr-deref in isolation (that's patch 5/5), it genuinely completes a WRITE_ONCE/READ_ONCE pair and silences KCSAN. Stable maintainers routinely accept these annotations, as evidenced by 0aa3be7b3e1f8 being in every active stable tree including 5.10.y.
**YES**
net/core/sock_map.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/sock_map.c +2 -2
@@ -530,7 +530,7 @@ static bool sock_map_redirect_allowed(const struct sock *sk)if (sk_is_tcp (sk))return sk->sk_state !=TCP_LISTEN ;else -return sk->sk_state ==TCP_ESTABLISHED ; +return READ_ONCE (sk->sk_state) ==TCP_ESTABLISHED ; }static bool sock_map_sk_is_suitable (const struct sock *sk)
@@ -543,7 +543,7 @@ static bool sock_map_sk_state_allowed(const struct sock *sk)if (sk_is_tcp (sk))return (1 << sk->sk_state) & (TCPF_ESTABLISHED |TCPF_LISTEN );if (sk_is_stream_unix (sk)) -return (1 << sk->sk_state) &TCPF_ESTABLISHED ; +return (1 <<READ_ONCE (sk->sk_state)) &TCPF_ESTABLISHED ;if (sk_is_vsock (sk) && (sk->sk_type ==SOCK_STREAM || sk->sk_type ==SOCK_SEQPACKET ))return (1 << sk->sk_state) &TCPF_ESTABLISHED ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 net: wangxun: reorder timer and work sync cancellations
In reply to Sasha LevinFrom: Jiawen Wu <[email protected]>
[ Upstream commit 58f6303572ec66e7c2967ac168125f444c9e880d ]
When removing the device, timer_delete_sync(&wx->service_timer) is called in .ndo_stop() after cancel_work_sync(&wx->service_task). This may cause new work to be queued after device down.
Move unregister_netdev() before cancel_work_sync(), and use timer_shutdown_sync() to prevent the timer from being re-armed.
---
LLM Generated explanations, may be completely bogus:
Now I have enough information for a complete analysis. Let me compile it.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: Subject Line**
- Subsystem: net: wangxun: (Wangxun network driver)
- Action verb: "reorder" - implies fixing incorrect ordering of operations, suggesting a race condition fix
- Summary: Reorders timer and work synchronization cancellations during device removal
**Step 1.2: Tags**
- Signed-off-by: Jiawen Wu <[email protected]> - author, primary wangxun driver developer
- `Link: https://patch.msgid.link/20260407025616.33652-7-
[email protected]` - patch 7 of a series
- Signed-off-by: Jakub Kicinski <[email protected]> - net maintainer accepted the patch
- No Fixes: tag (expected for this review process)
- No Cc: stable tag (expected)
**Step 1.3: Commit Body**
The commit message clearly describes the bug: in .ndo_stop(), timer_delete_sync() is called AFTER cancel_work_sync(), meaning the timer can fire and re-queue work after the work cancellation. The fix moves unregister_netdev() before cancel_work_sync() and uses timer_shutdown_sync() to prevent re-arming.
**Step 1.4: Hidden Bug Fix Detection**
This IS a bug fix despite using "reorder" language. The reordering fixes a race condition where work can be queued after device teardown begins.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: Inventory**
- drivers/net/ethernet/wangxun/libwx/wx_vf_common.c: +3/-1 lines
- drivers/net/ethernet/wangxun/txgbe/txgbe_main.c: +4/-2 lines
- Total: ~7 lines changed, 2 functions modified (wxvf_remove, txgbe_remove)
- Classification: small, surgical fix
**Step 2.2: Code Flow Changes**
For wxvf_remove() - BEFORE:
``` cancel_work_sync(&wx->service_task); // step 1: cancel work netdev = wx->netdev; unregister_netdev(netdev); // step 2: unregister (stops timer via .ndo_stop) ```
AFTER:
``` netdev = wx->netdev; unregister_netdev(netdev); // step 1: unregister (stops timer) timer_shutdown_sync(&wx->service_timer); // step 2: prevent timer re-arm cancel_work_sync(&wx->service_task); // step 3: cancel work ```
Same pattern for txgbe_remove().
**Step 2.3: Bug Mechanism**
Race condition. wx_service_timer() both re-arms itself via mod_timer() and queues service_task via wx_service_event_schedule():
```3333:3343:drivers/net/ethernet/wangxun/libwx/wx_lib.c
void wx_service_timer(struct timer_list *t)
{
struct wx *wx = timer_container_of(wx, t, service_timer);
unsigned long next_event_offset = HZ * 2;
mod_timer(&wx->service_timer, next_event_offset + jiffies);
wx_service_event_schedule(wx);
}
```In the old code, after cancel_work_sync() returns, the timer fires and both re-arms itself AND queues new work. That work then runs during or after device teardown.
**Step 2.4: Fix Quality**
The fix is obviously correct: stop the timer first (via unregister_netdev calling .ndo_stop), prevent re-arming (timer_shutdown_sync), then cancel remaining work (cancel_work_sync). Very low regression risk.
## PHASE 3: GIT HISTORY
**Step 3.1: Blame**
- cancel_work_sync in txgbe_remove was added by 343929799ace12 (v6.16, 2025-05-21) as part of AML GPIO IRQ support
- cancel_work_sync in wxvf_remove was added by bf68010acc4bc8 (v6.17, 2025-07-04) as part of VF driver addition
- timer_delete_sync in .ndo_stop paths has existed since the timer mechanism was added
**Step 3.2: Fixes tag** - No Fixes: tag present.
**Step 3.3: File History** - Both files have recent activity (feature additions), but txgbe_remove() structure has been stable since v6.0.
**Step 3.4: Author** - Jiawen Wu is the primary wangxun/txgbe driver developer with 15+ commits to this subsystem. This is the domain expert.
**Step 3.5: Dependencies** - timer_shutdown_sync() was added in v6.10 (f571faf6e443b), available in all relevant stable trees. The patch applies standalone - no other patches needed.
## PHASE 4: MAILING LIST RESEARCH
**Step 4.1-4.2:** b4 dig confirmed the related commit 343929799ace12 was reviewed by Simon Horman and accepted by Paolo Abeni. The current commit was accepted by Jakub Kicinski. The patch is part 7 of a series (from message-id 33652-7), but this specific fix is self-contained - it only changes the ordering of existing calls.
**Step 4.3-4.5:** Lore is behind anti-bot protection; could not fetch discussion thread directly.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1-5.2:** Functions modified are wxvf_remove() and txgbe_remove() - PCI remove callbacks. They are called by the PCI subsystem during device removal (driver unload, device hot-unplug, system shutdown).
**Step 5.3-5.4:** The work function txgbe_service_task() / wxvf_service_task() accesses device state (link detection, SFP identification, reset subtasks). Running this work after device teardown begins can access freed resources.
**Step 5.5:** The same pattern (timer_delete_sync + cancel_work_sync in error paths) exists in txgbevf and ngbevf probe error paths, but those are before the timer/work are active so the order is less critical.
## PHASE 6: STABLE TREE ANALYSIS
**Step 6.1:**
- The cancel_work_sync in txgbe_remove exists since v6.16 (stable 6.16.y affected)
- wxvf_remove exists since v6.17 (stable 6.17.y+ affected)
- Earlier stable trees (6.12.y, 6.6.y, etc.) don't have the buggy code
**Step 6.2:** The patch should apply cleanly to 6.16.y and later. The timer_shutdown_sync API is available since v6.10.
**Step 6.3:** No related fixes already in stable.
## PHASE 7: SUBSYSTEM CONTEXT
**Step 7.1:** Network driver (PERIPHERAL criticality) - affects Wangxun 10G/25G/40G NIC users.
**Step 7.2:** Actively developed subsystem with recent feature additions.
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1:** Affects users of Wangxun NICs (txgbe and txgbevf drivers).
**Step 8.2:** Trigger: device removal (driver unload, PCI hot-unplug, system shutdown). Common operation when managing network devices, though not a frequent hot path.
**Step 8.3:** Failure mode: Work task runs during/after device teardown. This can lead to use-after-free, accessing freed memory, or other undefined behavior. Severity: **HIGH** (potential UAF, crash during device removal).
**Step 8.4:**
- BENEFIT: Prevents potential crash/UAF during device removal - medium- high (device removal is common operation)
- RISK: Very low - 7 lines, just reordering existing operations + adding belt-and-suspenders timer_shutdown_sync
- Ratio: Clearly favorable
## PHASE 9: FINAL SYNTHESIS
**Evidence FOR:**
- Fixes a real race condition (timer re-queuing work after cancellation)
- Potential UAF/crash during device removal
- Small, surgical fix (7 lines across 2 files)
- Obviously correct - proper ordering of timer stop -> timer shutdown -> work cancel
- Written by the subsystem's primary developer
- Accepted by net maintainer (Jakub Kicinski)
- No dependencies on other patches
- timer_shutdown_sync API available in all relevant stable trees
**Evidence AGAINST:**
- No Reported-by (bug was found by code inspection, not user report)
- Only affects newer stable trees (6.16.y+)
- Device removal race may be hard to trigger in practice (small race window)
**Stable Rules Checklist:**
1. Obviously correct? YES - proper ordering of teardown operations
2. Fixes a real bug? YES - race condition in device removal
3. Important issue? YES - potential UAF/crash
4. Small and contained? YES - 7 lines, 2 files, same subsystem
5. No new features? CORRECT - no new features
6. Applies to stable? YES - for 6.16.y+ (txgbe) and 6.17.y+ (wxvf)
**Verification:**
- [Phase 1] Parsed tags: Signed-off-by Jakub Kicinski (net maintainer), Link to message-id
- [Phase 2] Diff analysis: Reorders cancel_work_sync after unregister_netdev, adds timer_shutdown_sync in wxvf_remove and txgbe_remove
- [Phase 2] Verified wx_service_timer() re-arms via mod_timer AND queues work - confirms the race
- [Phase 3] git blame: cancel_work_sync in txgbe_remove from 343929799ace12 (v6.16), wxvf_remove from bf68010acc4bc8 (v6.17)
- [Phase 3] git tag --contains: confirmed affected stable trees are 6.16.y+ (txgbe) and 6.17.y+ (wxvf)
- [Phase 3] git tag --contains f571faf6e443b: timer_shutdown_sync available since v6.10
- [Phase 4] b4 dig -c 343929799ace12: found original submission reviewed by Simon Horman
- [Phase 5] Verified work task wxvf_service_task/txgbe_service_task accesses device state
- [Phase 5] Verified txgbe_close → txgbe_down → txgbe_disable_device calls timer_delete_sync (line 230)
- [Phase 6] Confirmed buggy code only in 6.16.y+ for txgbe, 6.17.y+ for wxvf
- [Phase 8] Failure mode: work runs during teardown → potential UAF, severity HIGH
- UNVERIFIED: Could not access lore thread for the specific commit due to anti-bot protection
**YES**
drivers/net/ethernet/wangxun/libwx/wx_vf_common.c | 3 ++- drivers/net/ethernet/wangxun/txgbe/txgbe_main.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/wangxun/libwx/wx_vf_common.c +2 -1
@@ -48,9 +48,10 @@ void wxvf_remove(struct pci_dev *pdev)struct wx *wx =pci_get_drvdata (pdev);struct net_device *netdev; -cancel_work_sync (&wx->service_task); netdev = wx->netdev;unregister_netdev (netdev); +timer_shutdown_sync (&wx->service_timer); +cancel_work_sync (&wx->service_task);kfree (wx->vfinfo);kfree (wx->rss_key);kfree (wx->mac_table);
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c +3 -2
@@ -950,12 +950,13 @@ static void txgbe_remove(struct pci_dev *pdev)struct txgbe *txgbe = wx->priv;struct net_device *netdev; -cancel_work_sync (&wx->service_task); - netdev = wx->netdev;wx_disable_sriov (wx);unregister_netdev (netdev); +timer_shutdown_sync (&wx->service_timer); +cancel_work_sync (&wx->service_task); +txgbe_remove_phy (txgbe);wx_free_isb_resources (wx);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 PCI: tegra194: Assert CLKREQ# explicitly by default
In reply to Sasha LevinFrom: Vidya Sagar <[email protected]>
[ Upstream commit 01d36261ae331583e6bc2034e6aa75c101b83e1d ]
The Root Port's CLKREQ# signal is shared with a downstream PCIe switch and the endpoints behind it. By default, APPL_PINMUX_CLKREQ_OVERRIDE only overrides the CLKREQ# input to the controller (so REFCLK is enabled internally); it does not drive the CLKREQ# output pin low. Some PCIe switches (e.g. Broadcom PCIe Gen4) forward the Root Port's CLKREQ# to their downstream side and expect it to be driven low for REFCLK, even when the switch does not support CLK-PM or ASPM-L1SS. Without driving the output pin low, link-up can fail between the switch and endpoints.
Clear APPL_PINMUX_CLKREQ_DEFAULT_VALUE so the CLKREQ# output pad is explicitly driven low. That makes the shared CLKREQ# line low on the wire and avoids link-up issues with such switches.
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed. Let me compile the full analysis.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: PARSE THE SUBJECT LINE
Record: [PCI: tegra194] [Assert (fix/enable)] [CLKREQ# output pin driven low by default to fix PCIe link-up failures with certain switches]
### Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
- **Signed-off-by**: Vidya Sagar (original driver author), Manikanta Maddireddy (author), Manivannan Sadhasivam (PCI maintainer), Bjorn Helgaas (PCI global maintainer)
- **Tested-by**: Jon Hunter (NVIDIA kernel lead for Tegra)
- **Reviewed-by**: Vidya Sagar (original driver author), Jon Hunter
- **Link**: https://patch.msgid.link/20260324191000.1095768-2- [email protected] (patch 2 in series)
- No Fixes: tag (expected)
- No Cc: stable (expected)
Record: Strong review chain - original driver author, NVIDIA Tegra kernel lead, and PCI subsystem maintainers all signed off/reviewed.
### Step 1.3: ANALYZE THE COMMIT BODY TEXT
The commit explains that APPL_PINMUX_CLKREQ_OVERRIDE only overrides the CLKREQ# *input* to the controller (enabling REFCLK internally), but does NOT drive the CLKREQ# *output* pin low. Some PCIe switches (e.g., Broadcom PCIe Gen4) forward the Root Port's CLKREQ# to their downstream side. Without driving the output low, **link-up can fail** between the switch and endpoints.
Record: Bug = PCIe link-up failure. Symptom = endpoints behind PCIe switches don't enumerate. Root cause = CLKREQ# output pad not driven low when it should be.
### Step 1.4: DETECT HIDDEN BUG FIXES
Record: This IS a bug fix - it fixes a real hardware link-up failure. The language "assert... explicitly" and "avoids link-up issues" describes fixing broken behavior.
---
## PHASE 2: DIFF ANALYSIS
### Step 2.1: INVENTORY THE CHANGES
- **File**: drivers/pci/controller/dwc/pcie-tegra194.c (+2 lines)
- **Change 1**: Add #define APPL_PINMUX_CLKREQ_DEFAULT_VALUE BIT(13) in the register bit definitions
- **Change 2**: Add val &= ~APPL_PINMUX_CLKREQ_DEFAULT_VALUE; inside tegra_pcie_config_controller() in the !supports_clkreq block
Record: Single file, 2 lines added. Functions modified:tegra_pcie_config_controller(). Scope: single-file surgical fix.
### Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
- **Before**: When !supports_clkreq, the code enabled CLKREQ# override (bit 2) and cleared CLKREQ# override value (bit 3) - this overrides the CLKREQ# *input* but left the *output pad default value* (bit 13) unchanged (high by default)
- **After**: Additionally clears bit 13, which explicitly drives the CLKREQ# output pad low on the wire
Record: Before = REFCLK internally enabled but output pad floats high. After = REFCLK internally enabled AND output pad driven low.
### Step 2.3: IDENTIFY THE BUG MECHANISM
Record: Category (h) Hardware workaround. The hardware register has a default-high bit for the CLKREQ# output pad that wasn't being cleared, causing PCIe link-up failures with switches that forward CLKREQ#.
### Step 2.4: ASSESS THE FIX QUALITY
- Obviously correct: just clearing one more register bit in a register already being configured
- Minimal/surgical: 2 lines total
- Regression risk: extremely low - only affects Tegra platforms in the !supports_clkreq path, only clears an additional bit that logically should be cleared
Record: Fix quality = excellent. Regression risk = negligible.
---
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: BLAME THE CHANGED LINES
The !supports_clkreq code block was introduced in commit 56e15a238d9278 ("PCI: tegra: Add Tegra194 PCIe support", 2019-08-13, v5.4) and modified by ff5c2bb9c6f5ee ("PCI: tegra: Fix CLKREQ dependency programming", 2019-10-05, also v5.4).
Record: Buggy code has been present since v5.4, when the driver was introduced. The code exists in all stable trees since v5.4.
### Step 3.2: FOLLOW THE FIXES TAG
No Fixes: tag present. This is expected for candidate review.
### Step 3.3: CHECK FILE HISTORY
The file has many commits since v5.4 but the !supports_clkreq block hasn't changed since ff5c2bb9c6f5ee.
Record: No prerequisites for this specific code block. The patch is standalone.
### Step 3.4: CHECK THE AUTHOR
Manikanta Maddireddy is an NVIDIA engineer working on Tegra PCI. Vidya Sagar (original driver author) reviewed the patch. Jon Hunter (NVIDIA Tegra kernel lead) tested and reviewed it.
Record: Author is an NVIDIA Tegra PCI engineer. Original driver author and NVIDIA kernel team lead both reviewed/tested.
### Step 3.5: CHECK FOR DEPENDENCIES
The patch is patch 2 of a series (from the message ID). However, the fix is completely self-contained:
1. The new #define doesn't depend on anything new
2. The bit-clear operation is added to an existing code block
3. No other functions or data structures are modified
One concern: the diff context shows DW_PCIE_VER_500A / DW_PCIE_VER_562A macros, but the v7.0 tree uses raw hex values 0x490A / 0x562A. This means the commit was built on top of a tree with a version macro rename. However, this only affects context lines in the header area — the actual code change applies to a completely different part of the function.
Record: Self-contained fix. Minor context mismatch in header defines area, but actual functional change applies cleanly.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
### Step 4.1-4.5: MAILING LIST INVESTIGATION Lore.kernel.org was behind an anti-scraping challenge and could not be accessed. However:
- b4 dig found the original CLKREQ fix (ff5c2bb9c6f5ee) was part of a series
- The commit was accepted through the PCI maintainer tree (Manivannan Sadhasivam -> Bjorn Helgaas)
- The strong review chain (Tested-by, Reviewed-by from original author and NVIDIA kernel lead) provides high confidence
Record: Could not access lore directly. Review chain provides strong confidence.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1-5.4: FUNCTION AND CALLER ANALYSIS tegra_pcie_config_controller() is called from:
1. tegra_pcie_init_controller() (line 1526) — during initial probe/boot
2. tegra_pcie_dw_resume_noirq() (line 2346) — during resume from suspend
Both are critical paths. The fix affects both initial boot and resume, meaning without the fix, PCIe link-up can fail both at boot and after suspend/resume.
The !supports_clkreq condition is determined by the supports-clkreq DT property (line 1138-1139). Systems without this property will hit the bug.
Record: Critical paths affected (boot and resume). Impact depends on DT configuration.
---
## PHASE 6: CROSS-REFERENCING AND STABLE TREE ANALYSIS
### Step 6.1: DOES THE BUGGY CODE EXIST IN STABLE TREES? Yes. The driver was introduced in v5.4, and the specific code block has been unchanged since ff5c2bb9c6f5ee (also v5.4). All active stable trees (5.4.y through 6.12.y and 7.0.y) contain the buggy code.
### Step 6.2: BACKPORT COMPLICATIONS
Minor context difference in the header define area (version macros changed upstream). The actual functional change in tegra_pcie_config_controller() applies cleanly to all stable trees since the !supports_clkreq block hasn't changed since v5.4.
Record: Minor context adjustment needed for defines area. Functional code change applies cleanly.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
### Step 7.1: SUBSYSTEM CRITICALITY
PCI controller driver for NVIDIA Tegra194/234 SoCs. Platform: ARM64 Tegra (Jetson, automotive, embedded).
Record: Subsystem = PCI controller (drivers/pci/controller/dwc). Criticality = IMPORTANT (affects Tegra platform users, including Jetson dev boards and automotive systems).
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: WHO IS AFFECTED
Users of Tegra194/234 PCIe root ports with downstream PCIe switches that forward CLKREQ# (e.g., Broadcom PCIe Gen4 switches), on systems without the supports-clkreq DT property.
### Step 8.2: TRIGGER CONDITIONS
- Triggered on every boot and resume when the hardware configuration matches
- Deterministic (not a race)
### Step 8.3: FAILURE MODE SEVERITY
PCIe link-up failure = devices behind the switch don't enumerate = hardware doesn't work.
Severity: HIGH (complete loss of PCIe functionality behind the affected switch)
### Step 8.4: RISK-BENEFIT RATIO
- **Benefit**: HIGH — fixes complete PCIe link failure for affected configurations
- **Risk**: VERY LOW — 2 lines, clears one register bit, only affects !supports_clkreq path on Tegra platforms
- **Ratio**: Strongly favorable for backporting
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: EVIDENCE COMPILATION
**FOR backporting:**
- Fixes real hardware link-up failures on Tegra platforms
- Extremely small and surgical (2 lines)
- Obviously correct (clearing a register bit to match intended behavior)
- Strong review chain: original driver author, NVIDIA kernel team lead, PCI maintainers
- Tested by Jon Hunter
- Falls into "hardware workaround" exception category
- Code has been present since v5.4 — affects all stable trees
- Affects boot AND resume paths
**AGAINST backporting:**
- No crash/security/data corruption — "just" link-up failure
- Minor context difference in header area requires fuzz/adjustment for backport
- Part of a multi-patch series (patch 2/N) — though self-contained
### Step 9.2: STABLE RULES CHECKLIST
1. Obviously correct and tested? **YES** — Tested-by and Reviewed-by, trivial change
2. Fixes a real bug? **YES** — PCIe link-up failure
3. Important issue? **YES** — complete PCIe failure for affected configurations
4. Small and contained? **YES** — 2 lines in 1 file
5. No new features or APIs? **YES** — no new features
6. Can apply to stable trees? **YES** — minor context adjustment may be needed
### Step 9.3: EXCEPTION CATEGORIES
This falls into the **hardware quirk/workaround** category (explicitly allowed for stable).
---
## Verification
- [Phase 1] Parsed tags: Tested-by Jon Hunter, Reviewed-by Vidya Sagar + Jon Hunter, SOBs from PCI maintainers
- [Phase 2] Diff analysis: 2 lines added — 1 new #define + 1 register bit clear in tegra_pcie_config_controller()
- [Phase 3] git blame: buggy code block from ff5c2bb9c6f5ee (v5.4), present in all stable trees
- [Phase 3] git show ff5c2bb9c6f5ee: confirmed this was "PCI: tegra: Fix CLKREQ dependency programming" — an earlier incomplete fix
- [Phase 3] git show 56e15a238d9278: confirmed original driver added in v5.4
- [Phase 4] b4 dig found the earlier CLKREQ fix series at lore; lore.kernel.org blocked by anti-scraping
- [Phase 5] tegra_pcie_config_controller() called from tegra_pcie_init_controller() (probe) and tegra_pcie_dw_resume_noirq() (resume)
- [Phase 5] supports_clkreq determined from DT property "supports- clkreq" (line 1138-1139)
- [Phase 6] Code exists in all stable trees since v5.4; context mismatch only in header defines area
- [Phase 8] Failure mode: complete PCIe link-up failure, severity HIGH
- UNVERIFIED: Could not access lore.kernel.org to verify mailing list discussion or whether patch 1 of the series has any relevance
The fix is a small, surgical hardware workaround that fixes real PCIe link-up failures on Tegra platforms. It meets all stable kernel criteria and falls into the hardware workaround exception category.
**YES**
drivers/pci/controller/dwc/pcie-tegra194.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/controller/dwc/pcie-tegra194.c +2 -0
@@ -44,6 +44,7 @@#define APPL_PINMUX_CLKREQ_OVERRIDE BIT(3)#define APPL_PINMUX_CLK_OUTPUT_IN_OVERRIDE_EN BIT(4)#define APPL_PINMUX_CLK_OUTPUT_IN_OVERRIDE BIT(5) +#define APPL_PINMUX_CLKREQ_DEFAULT_VALUE BIT(13)#define APPL_CTRL 0x4#define APPL_CTRL_SYS_PRE_DET_STATE BIT(6)
@@ -1454,6 +1455,7 @@ static int tegra_pcie_config_controller(struct tegra_pcie_dw *pcie, val =appl_readl (pcie,APPL_PINMUX ); val |=APPL_PINMUX_CLKREQ_OVERRIDE_EN ; val &= ~APPL_PINMUX_CLKREQ_OVERRIDE ; + val &= ~APPL_PINMUX_CLKREQ_DEFAULT_VALUE ;appl_writel (pcie, val,APPL_PINMUX ); }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 net: mvneta: support EPROBE_DEFER when reading MAC address
In reply to Sasha LevinFrom: Rosen Penev <[email protected]>
[ Upstream commit 73a864352570fd30d942652f05bfe9340d7a2055 ]
If nvmem loads after the ethernet driver, mac address assignments will not take effect. of_get_ethdev_address returns EPROBE_DEFER in such a case so we need to handle that to avoid eth_hw_addr_random.
Add extra goto section to just free stats as they are allocated right above.
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed for the full analysis.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: Subject Line
- **Subsystem**: net: mvneta: (Marvell NETA ethernet driver)
- **Action verb**: "support" - enabling proper handling of an error condition
- **Summary**: Handle EPROBE_DEFER from of_get_ethdev_address() in mvneta probe
Record: [net: mvneta] [support] [Handle EPROBE_DEFER to avoid incorrect random MAC assignment when nvmem loads after ethernet driver]
### Step 1.2: Tags
- **Signed-off-by**: Rosen Penev (author), Jakub Kicinski (net maintainer)
- **Reviewed-by**: Simon Horman (networking reviewer) - strong quality signal
- **Link**:
https://patch.msgid.link/[email protected]
(lore blocked by Anubis)
- No Fixes: tag (expected for this review pipeline)
- No Cc: stable (expected)
Record: Reviewed by Simon Horman (experienced networking reviewer), committed by Jakub Kicinski (net maintainer). No syzbot, no multiple reporters.
### Step 1.3: Body Text
The commit explains that when nvmem loads after the ethernet driver, of_get_ethdev_address() returns -EPROBE_DEFER. Without handling this, the driver falls through to eth_hw_addr_random, assigning a random MAC address instead of deferring probe. The fix adds an err_free_stats goto section to properly clean up.
Record: Bug: EPROBE_DEFER not handled, causing random MAC assignment instead of probe deferral. Symptom: Device gets a random MAC instead of its stored nvmem MAC. Root cause: Missing EPROBE_DEFER check after of_get_ethdev_address().
### Step 1.4: Hidden Bug Fix Detection
This is a real bug fix despite using "support" rather than "fix". Without this, users get a non-deterministic MAC address that changes every boot, breaking network configurations.
Record: YES - this is a real bug fix. The consequence is a random MAC address instead of the correct one from nvmem storage.
---
## PHASE 2: DIFF ANALYSIS
### Step 2.1: Inventory
- **Files changed**: 1 (drivers/net/ethernet/marvell/mvneta.c)
- **Lines added**: 3 (2 lines for EPROBE_DEFER check + 1 label)
- **Functions modified**: mvneta_probe() only
- **Scope**: Single-file surgical fix
### Step 2.2: Code Flow Change
**Hunk 1** (around line 5622): After of_get_ethdev_address(), adds check for EPROBE_DEFER to jump to cleanup.
- Before: EPROBE_DEFER falls into the else branch and assigns a random MAC.
- After: EPROBE_DEFER causes probe to fail and return -EPROBE_DEFER.
**Hunk 2** (around line 5758): Adds err_free_stats: label before free_percpu(pp->stats).
- This provides a proper cleanup path that frees stats, ports, phylink, clocks, and IRQ.
### Step 2.3: Bug Mechanism
Category: **Logic/correctness fix** - missing error path handling. The of_get_ethdev_address() call can return -EPROBE_DEFER when the nvmem provider isn't loaded yet. Without handling this specific error, the driver proceeds with a random MAC address. The fix returns the error so the driver framework retries probe later when nvmem is available.
### Step 2.4: Fix Quality
- Obviously correct - follows established pattern used in macb, ucc_geth, gianfar, airoha, mtk_eth_soc
- Minimal (3 lines), surgical, well-contained
- No regression risk - the new err_free_stats cleanup path correctly unwinds only what was allocated (stats, ports, phylink, clocks, IRQ)
- No red flags
---
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: Blame
- of_get_ethdev_address() call was introduced by commit 9ca01b25dffffe ("ethernet: use of_get_ethdev_address()") in v5.16
- The original MAC address reading pattern has been present since commit 8cc3e439ab9207 (2013)
- The nvmem path in of_get_mac_address() was present since ~v5.0 (of_get_mac_address_nvmem())
- Bug has been present since v5.16 when mvneta switched to of_get_ethdev_address()
### Step 3.2: Fixes Tag
No Fixes: tag present. The implicit "fixes" target would be 9ca01b25dffffe (v5.16) which exists in all active stable trees (6.1, 6.6, 6.12).
### Step 3.3: Related Changes
The author (Rosen Penev) has been systematically fixing this same pattern across drivers:
- b2d9544070d05 "net: gianfar: fix NVMEM mac address" (v6.12)
- 2575897640328 "net: ucc_geth: fix usage with NVMEM MAC address" (v6.13)
- be04024a24a93 "net: ag71xx: support probe deferral for getting MAC address"
This mvneta fix is standalone and does not depend on other patches.
### Step 3.4: Author
Rosen Penev is a regular contributor with multiple accepted patches in the networking subsystem, especially around nvmem MAC address handling. Not the subsystem maintainer but an experienced contributor.
### Step 3.5: Dependencies
No dependencies. The fix uses existing infrastructure (of_get_ethdev_address() and error labels already in the function). Applies standalone.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
### Step 4.1-4.5
b4 dig did not find the submission. Lore was blocked by Anubis anti- scraping. However, the commit metadata is clear:
- Reviewed by Simon Horman (experienced networking reviewer)
- Accepted by Jakub Kicinski (netdev maintainer)
- This is part of an established series by the same author fixing the same pattern in multiple drivers
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1: Key Functions
- mvneta_probe() - the sole modified function
### Step 5.2: Callersmvneta_probe() is called by the platform driver framework during device enumeration. This is a standard probe path for all Marvell NETA Ethernet controllers.
### Step 5.3-5.4: Call Chainof_get_ethdev_address() -> of_get_mac_address() -> of_get_mac_address_nvmem() -> of_nvmem_cell_get() which returns -EPROBE_DEFER when the nvmem provider hasn't been loaded yet. This is a standard Linux device model flow.
### Step 5.5: Similar Patterns
Multiple other drivers handle this pattern correctly:
- drivers/net/ethernet/mediatek/mtk_eth_soc.c - handles EPROBE_DEFER
- drivers/net/ethernet/freescale/ucc_geth.c - handles EPROBE_DEFER
- drivers/net/ethernet/cadence/macb_main.c - handles EPROBE_DEFER
- drivers/net/ethernet/airoha/airoha_eth.c - handles EPROBE_DEFER
mvneta was an outlier in NOT handling it.
---
## PHASE 6: CROSS-REFERENCING AND STABLE TREE ANALYSIS
### Step 6.1: Buggy Code in Stable
The of_get_ethdev_address() call in mvneta was introduced in v5.16 (commit 9ca01b25dffffe). All active stable trees (6.1.y, 6.6.y, 6.12.y) contain this buggy code.
### Step 6.2: Backport Complications
The fix is very small (3 lines) and only uses existing infrastructure. The error cleanup chain structure has been stable since 2022. Expected to apply cleanly.
### Step 6.3: Related Fixes Already in Stable
No prior fix for this specific issue in mvneta.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
### Step 7.1: Subsystem
- **Subsystem**: Network drivers (drivers/net/ethernet/marvell/)
- **Criticality**: IMPORTANT - Marvell NETA is a widely used Ethernet controller in Armada SoCs, common in embedded/networking appliances (routers, NAS devices, network gateways)
### Step 7.2: Subsystem Activity
The mvneta driver is actively maintained with regular updates.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: Who Is Affected
Users with Marvell NETA Ethernet controllers whose MAC address is stored in nvmem (common in embedded devices). These are typically ARM-based platforms.
### Step 8.2: Trigger Conditions
Triggered when:
- Device tree specifies MAC in nvmem (common configuration)
- nvmem driver loads after mvneta driver (depends on module load order, kernel config)
- This is a real-world scenario, especially on systems with complex device tree dependencies
### Step 8.3: Failure Mode Severity
- **Without fix**: Random MAC address assigned, networking may break (DHCP gets new IP, static configs fail, MAC-based filtering fails)
- **Severity**: HIGH for affected users - unstable MAC address across reboots can cause network connectivity failures and operational issues in embedded deployments
- Not a crash, but a functional correctness issue with real-world impact
### Step 8.4: Risk-Benefit Ratio
- **Benefit**: HIGH - restores correct MAC address behavior for embedded users
- **Risk**: VERY LOW - 3-line change, follows established pattern, proper cleanup
- **Ratio**: Strongly favorable
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: Evidence Summary
**FOR backporting:**
- Fixes a real functional bug (wrong MAC address assignment)
- Tiny change: 3 lines added
- Follows an established pattern already used by 4+ other drivers
- Same author has had identical fixes accepted in other drivers
- Reviewed by Simon Horman, committed by Jakub Kicinski
- Affects all stable trees (6.1+)
- No dependencies, standalone fix
- Proper cleanup path (no resource leaks)
- Real-world impact on embedded/ARM devices using nvmem for MAC storage
**AGAINST backporting:**
- Not a crash, security, or data corruption issue
- Affects a specific hardware platform (Marvell NETA SoCs with nvmem MAC)
- Could be seen as "enabling a feature" (nvmem MAC support), but nvmem support has been present since v5.0 - this just fixes the error handling
### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **YES** - trivial pattern, reviewed by expert
2. Fixes a real bug? **YES** - wrong MAC address when nvmem loads late
3. Important issue? **YES** - networking breaks with wrong MAC
4. Small and contained? **YES** - 3 lines, 1 file
5. No new features? **CORRECT** - this enables existing nvmem MAC feature to work correctly
6. Can apply to stable? **YES** - no dependencies, clean apply expected
### Step 9.3: Exception Categories
Not strictly an exception category, but this is a straightforward correctness fix.
### Step 9.4: Decision
This is a small, obviously correct fix for a real functional bug. It follows an established pattern already used in multiple other drivers. The risk is minimal and the benefit is significant for embedded users with Marvell NETA hardware using nvmem MAC addresses.
---
## Verification
- [Phase 1] Parsed tags: Reviewed-by Simon Horman, signed by Jakub Kicinski. No Fixes: tag (expected).
- [Phase 2] Diff analysis: 3 lines added - 2 lines for EPROBE_DEFER check, 1 err_free_stats label in mvneta_probe()
- [Phase 3] git blame: of_get_ethdev_address() call introduced by 9ca01b25dffffe (v5.16), present in all active stable trees
- [Phase 3] git log author: Rosen Penev has multiple identical fixes accepted (ucc_geth v6.13, gianfar v6.12)
- [Phase 3] File history: no prerequisites or conflicts identified
- [Phase 4] b4 dig: could not find match; lore blocked by Anubis
- [Phase 5] Grep for similar patterns: confirmed 4+ other drivers handle EPROBE_DEFER from of_get_ethdev_address() correctly (macb, ucc_geth, airoha, mtk_eth_soc)
- [Phase 5] of_get_ethdev_address() -> of_get_mac_address() -> of_get_mac_address_nvmem() can return -EPROBE_DEFER (verified in net/core/of_net.c lines 61-97, 126-147, 162-171)
- [Phase 6] Code exists in all active stable trees (6.1+), verified via git describe --contains for 9ca01b25dffffe (v5.16-rc1)
- [Phase 6] Expected clean apply - fix uses only existing error labels and infrastructure
- [Phase 7] mvneta is a widely-used Marvell Armada SoC ethernet driver
- [Phase 8] Failure mode: random MAC assignment instead of correct nvmem MAC, severity HIGH for embedded users
- UNVERIFIED: Could not access mailing list discussion due to Anubis blocking
**YES**
drivers/net/ethernet/marvell/mvneta.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/marvell/mvneta.c +3 -0
@@ -5620,6 +5620,8 @@ static int mvneta_probe(struct platform_device *pdev) } err =of_get_ethdev_address (dn, dev); +if (err == -EPROBE_DEFER ) + goto err_free_stats;if (!err) { mac_from ="device tree" ; }else {
@@ -5755,6 +5757,7 @@ static int mvneta_probe(struct platform_device *pdev) 1 << pp->id);mvneta_bm_put (pp->bm_priv); } +err_free_stats:free_percpu (pp->stats); err_free_ports:free_percpu (pp->ports);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: hda/realtek: add quirk for Framework F111:000F
In reply to Sasha LevinFrom: "Dustin L. Howett" <[email protected]>
[ Upstream commit bac1e57adf08c9ee33e95fb09cd032f330294e70 ]
Similar to commit 7b509910b3ad ("ALSA hda/realtek: Add quirk for Framework F111:000C") and previous quirks for Framework systems with Realtek codecs.
000F is another new platform with an ALC285 which needs the same quirk.
---
LLM Generated explanations, may be completely bogus:
Error: Failed to generate final synthesis
sound/hda/codecs/realtek/alc269.c | 1 + 1 file changed, 1 insertion(+)
sound/hda/codecs/realtek/alc269.c +1 -0
@@ -7555,6 +7555,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0xf111 ,0x0009 ,"Framework Laptop" ,ALC295_FIXUP_FRAMEWORK_LAPTOP_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0xf111 ,0x000b ,"Framework Laptop" ,ALC295_FIXUP_FRAMEWORK_LAPTOP_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0xf111 ,0x000c ,"Framework Laptop" ,ALC295_FIXUP_FRAMEWORK_LAPTOP_MIC_NO_PRESENCE ), +SND_PCI_QUIRK (0xf111 ,0x000f ,"Framework Laptop" ,ALC295_FIXUP_FRAMEWORK_LAPTOP_MIC_NO_PRESENCE ), #if 0/* Below is a quirk table taken from the old code.
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 jfs: add dmapctl integrity check to prevent invalid operations
In reply to Sasha LevinFrom: Yun Zhou <[email protected]>
[ Upstream commit cce219b203c4b9cb445e910c7090d1f58af847c5 ]
Add check_dmapctl() to validate dmapctl structure integrity, focusing on preventing invalid operations caused by on-disk corruption.
Key checks:
- nleafs bounded by [0, LPERCTL] (maximum leaf nodes per dmapctl).
- l2nleafs bounded by [0, L2LPERCTL] and consistent with nleafs (nleafs must be 2^l2nleafs).
- leafidx must be exactly CTLLEAFIND (expected leaf index position).
- height bounded by [0, L2LPERCTL >> 1] (valid tree height range).
- budmin validity: NOFREE only if nleafs=0; otherwise >= BUDMIN.
- Leaf nodes fit within stree array (leafidx + nleafs <= CTLTREESIZE).
- Leaf node values are either non-negative or NOFREE.
Invoked in dbAllocAG(), dbFindCtl(), dbAdjCtl() and dbExtendFS() when accessing dmapctl pages, catching corruption early before dmap operations trigger invalid memory access or logic errors.
This fixes the following UBSAN warning.
[58245.668090][T14017] ------------[ cut here ]------------
[58245.668103][T14017] UBSAN: shift-out-of-bounds in fs/jfs/jfs_dmap.c:2641:11
[58245.668119][T14017] shift exponent 110 is too large for 32-bit type 'int'
[58245.668137][T14017] CPU: 0 UID: 0 PID: 14017 Comm: 4c1966e88c28fa9 Tainted: G E 6.18.0-rc4-00253-g21ce5d4ba045-dirty #124 PREEMPT_{RT,(full)}
[58245.668174][T14017] Tainted: [E]=UNSIGNED_MODULE
[58245.668176][T14017] Hardware name: QEMU Ubuntu 25.04 PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[58245.668184][T14017] Call Trace:
[58245.668200][T14017] <TASK>
[58245.668208][T14017] dump_stack_lvl+0x189/0x250
[58245.668288][T14017] ? __pfx_dump_stack_lvl+0x10/0x10
[58245.668301][T14017] ? __pfx__printk+0x10/0x10
[58245.668315][T14017] ? lock_metapage+0x303/0x400 [jfs]
[58245.668406][T14017] ubsan_epilogue+0xa/0x40
[58245.668422][T14017] __ubsan_handle_shift_out_of_bounds+0x386/0x410
[58245.668462][T14017] dbSplit+0x1f8/0x200 [jfs]
[58245.668543][T14017] dbAdjCtl+0x34c/0xa20 [jfs]
[58245.668628][T14017] dbAllocNear+0x2ee/0x3d0 [jfs]
[58245.668710][T14017] dbAlloc+0x933/0xba0 [jfs]
[58245.668797][T14017] ea_write+0x374/0xdd0 [jfs]
[58245.668888][T14017] ? __pfx_ea_write+0x10/0x10 [jfs]
[58245.668966][T14017] ? __jfs_setxattr+0x76e/0x1120 [jfs]
[58245.669046][T14017] __jfs_setxattr+0xa01/0x1120 [jfs]
[58245.669135][T14017] ? __pfx___jfs_setxattr+0x10/0x10 [jfs]
[58245.669216][T14017] ? mutex_lock_nested+0x154/0x1d0
[58245.669252][T14017] ? __jfs_xattr_set+0xb9/0x170 [jfs]
[58245.669333][T14017] __jfs_xattr_set+0xda/0x170 [jfs]
[58245.669430][T14017] ? __pfx___jfs_xattr_set+0x10/0x10 [jfs]
[58245.669509][T14017] ? xattr_full_name+0x6f/0x90
[58245.669546][T14017] ? jfs_xattr_set+0x33/0x60 [jfs]
[58245.669636][T14017] ? __pfx_jfs_xattr_set+0x10/0x10 [jfs]
[58245.669726][T14017] __vfs_setxattr+0x43c/0x480
[58245.669743][T14017] __vfs_setxattr_noperm+0x12d/0x660
[58245.669756][T14017] vfs_setxattr+0x16b/0x2f0
[58245.669768][T14017] ? __pfx_vfs_setxattr+0x10/0x10
[58245.669782][T14017] filename_setxattr+0x274/0x600
[58245.669795][T14017] ? __pfx_filename_setxattr+0x10/0x10
[58245.669806][T14017] ? getname_flags+0x1e5/0x540
[58245.669829][T14017] path_setxattrat+0x364/0x3a0
[58245.669840][T14017] ? __pfx_path_setxattrat+0x10/0x10
[58245.669859][T14017] ? __se_sys_chdir+0x1b9/0x280
[58245.669876][T14017] __x64_sys_lsetxattr+0xbf/0xe0
[58245.669888][T14017] do_syscall_64+0xfa/0xfa0
[58245.669901][T14017] ? lockdep_hardirqs_on+0x9c/0x150
[58245.669913][T14017] ? entry_SYSCALL_64_after_hwframe+0x77/0x7f
[58245.669927][T14017] ? exc_page_fault+0xab/0x100
[58245.669937][T14017] entry_SYSCALL_64_after_hwframe+0x77/0x7f---
LLM Generated explanations, may be completely bogus:
Now let me compile the full analysis.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: PARSE THE SUBJECT LINE
Record: [jfs] [add integrity check] - Adds check_dmapctl() function to validate dmapctl structure integrity to prevent invalid operations from on-disk corruption.
### Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
- **Reported-by:** [email protected] (fuzzer-found bug, strong signal)
- **Closes:**
https://syzkaller.appspot.com/bug?extid=4c1966e88c28fa96e053
- **Signed-off-by:** Yun Zhou <[email protected]> (author)
- **Signed-off-by:** Dave Kleikamp <[email protected]> (JFS maintainer applied it)
- No Fixes: tag (expected for autosel candidates)
- No Cc: stable (expected for autosel candidates)
### Step 1.3: ANALYZE THE COMMIT BODY TEXT
The commit describes a UBSAN shift-out-of-bounds at fs/jfs/jfs_dmap.c:2641:11 in dbSplit() where a corrupt budmin value from an on-disk dmapctl structure leads to a shift exponent of 110 (far exceeding the 32-bit limit). The call chain is: lsetxattr syscall -> __jfs_setxattr -> ea_write -> dbAlloc -> dbAllocNear -> dbAdjCtl -> dbSplit.
Record: Bug is a UBSAN shift-out-of-bounds triggered by corrupt dmapctl on-disk data. Failure mode is undefined behavior from invalid shift. Root cause is lack of comprehensive validation of dmapctl fields read from disk.
### Step 1.4: DETECT HIDDEN BUG FIXES
This is not a hidden bug fix - it's an explicitly declared fix for a syzbot-reported UBSAN issue. The commit directly fixes undefined behavior caused by corrupt on-disk data.
---
## PHASE 2: DIFF ANALYSIS - LINE BY LINE
### Step 2.1: INVENTORY THE CHANGES
- **File:** fs/jfs/jfs_dmap.c only (single file)
- **New function:** check_dmapctl() (~87 lines added)
- **3 replacement sites:** dbAllocAG(), dbFindCtl(), dbAdjCtl() - each replaces if (dcp->leafidx != cpu_to_le32(CTLLEAFIND)) with if (unlikely(!check_dmapctl(dcp)))
- **5 new check sites in dbExtendFS():** Adds check_dmapctl() calls after reading L2, L1, and L0 dmapctl pages where no checks existed before
- Total: ~87 lines for the new function + 8 call sites (3 replacements + 5 additions) = ~110 lines net change
### Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
**Before:** Only leafidx == CTLLEAFIND was validated when reading dmapctl pages in 3 functions. budmin, nleafs, l2nleafs, height, and leaf values were NOT validated. In dbExtendFS(), no dmapctl validation at all.
**After:** All 7 key fields of dmapctl are validated before any arithmetic is performed on them. This catches corrupt values (like the budmin that led to shift exponent 110) before they flow into BUDSIZE(), BLKTOCTLLEAF(), or array index operations.
### Step 2.3: IDENTIFY THE BUG MECHANISM
Category: **Input validation / sanitizer-reported undefined behavior**
The BUDSIZE(s,m) macro at line 275 of jfs_dmap.h is (1 << ((s) - (m))). When leaf[leafno] is corrupt (e.g., 115) and budmin is 5 (BUDMIN), cursz = 115 - 1 = 114, and BUDSIZE(114, 5) = (1 << 109) which is shift-out-of-bounds for a 32-bit int. The check_dmapctl() validates budmin >= BUDMIN and leaf values are within [NOFREE, 31], preventing such overflows.
### Step 2.4: ASSESS THE FIX QUALITY
- The fix is well-structured with clear boundary checks against known constants
- It replaces weaker checks with comprehensive validation
- Each check maps to a specific invariant of the dmapctl structure
- Error paths return -EIO which is the existing pattern
- The leaf value range check val > 31 matches the fact that BUDSIZE(31, 5) = (1 << 26) is the maximum valid shift
- Risk of regression is low - it only makes validation stricter, all valid dmapctl pages will pass
---
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: BLAME THE CHANGED LINES
The 3 existing leafidx != cpu_to_le32(CTLLEAFIND) checks being replaced were all introduced in the initial Linux git import (v2.6.12, commit 1da177e4c3f41). This is ancient code present in ALL stable trees.
### Step 3.2: FOLLOW THE FIXES: TAG
No Fixes: tag present. The bug is in the fundamental lack of validation of on-disk dmapctl data, which dates back to the initial JFS implementation.
### Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
JFS has seen a steady stream of similar corruption-defense fixes, all syzbot-driven:
- a5f5e4698f8ab - fix shift-out-of-bounds in dbSplit (similar bug, budmin < 0)
- d64ff0d230671 - check if leafidx greater than num leaves per dmap tree
- a174706ba4dad - check to prevent array-index-out-of-bounds in dbAdjTree
- Many others addressing the same class of "corrupt on-disk data → UBSAN/crash"
This commit is standalone - it does not require other patches in a series.
### Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Yun Zhou (Wind River) is not a regular JFS contributor. However, the patch was reviewed by Li Lingfeng and applied by Dave Kleikamp ([email protected]), who is the JFS maintainer.
### Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS
The patch replaces dcp->leafidx != cpu_to_le32(CTLLEAFIND) checks that have existed since v2.6.12. The code context (function signatures, data structures) is stable and unchanged. No dependencies on recent commits.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
### Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
- b4 dig found the match: https://patch.msgid.link/20251128155150.149398
[email protected]
- This is v2 of the patch (v1 was submitted 2025/11/20, v2 on 2025/11/28)
- Dave Kleikamp (JFS maintainer) replied: "This is finally tested and applied." (2026/03/16)
- Li Lingfeng reviewed and pinged twice for application
### Step 4.2: CHECK WHO REVIEWED THE PATCH
The JFS maintainer (Dave Kleikamp/shaggy) directly tested and applied. Li Lingfeng reviewed.
### Step 4.3: SEARCH FOR THE BUG REPORT
The syzbot page confirms:
- Bug is reproducible with a C reproducer
- First crash: 354 days ago, last: 36 days ago (persistent bug)
- The bug has **similar bugs** on linux-6.1 and linux-5.15 that are **NOT patched** (0/3 patched on 6.1, 0/3 on 5.15)
- This confirms the bug exists and is unpatched in stable trees
### Step 4.4-4.5: Related patches
This is a standalone patch. No explicit stable discussion found, but the syzbot similar bugs table shows the same class of issue exists in stable trees (linux-6.1, linux-5.15) and is NOT yet fixed there.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1-5.2: KEY FUNCTIONS AND CALLERS
The check_dmapctl() is called in:
1. **dbAllocAG()** - called from dbAlloc(), the primary block allocation path
2. **dbFindCtl()** - called from dbAllocCtl() and dbAllocAG()
3. **dbAdjCtl()** - called from dbFreeBits(), dbAllocDmap(), dbAllocDmapBU(), and recursively
4. **dbExtendFS()** - called during filesystem extension
### Step 5.3-5.4: CALL CHAIN (reachability)
The syzbot crash trace confirms reachability from userspace:lsetxattr (syscall) → __jfs_setxattr → ea_write → dbAlloc → dbAllocNear → dbAdjCtl → dbSplit
This is triggered by a standard setxattr syscall on a JFS filesystem. Any unprivileged user who can write to a JFS filesystem can trigger this.
---
## PHASE 6: CROSS-REFERENCING AND STABLE TREE ANALYSIS
### Step 6.1: DOES THE BUGGY CODE EXIST IN STABLE?
Yes. The code being modified (the leafidx checks in dbAllocAG, dbFindCtl, dbAdjCtl) has existed since v2.6.12. The bug exists in ALL stable trees. Syzbot confirms it reproduces on linux-6.1 and linux-5.15.
### Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
The patch should apply cleanly to most stable trees. The three replacement sites have had the same dcp->leafidx != cpu_to_le32(CTLLEAFIND) check since the initial git import. The dbExtendFS() additions are to code that is also largely unchanged.
There may be minor context conflicts depending on surrounding changes in each stable tree (the many JFS syzbot fixes), but the core code structure is the same.
### Step 6.3: RELATED FIXES IN STABLE
The earlier fix a5f5e4698f8ab ("jfs: fix shift-out-of-bounds in dbSplit") addressed the same syzbot bug family (#2) by checking dp->tree.budmin < 0 in dbAllocCtl. This commit provides a more comprehensive fix at the dmapctl level, catching corruption earlier and more broadly.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
### Step 7.1: SUBSYSTEM CRITICALITY
- **Subsystem:** fs/jfs (JFS filesystem)
- **Criticality:** IMPORTANT - JFS is a mature filesystem used in enterprise environments, particularly on older IBM/AIX-heritage systems and some embedded environments
- The fix is in the block allocation map code, which is core to filesystem operations
### Step 7.2: SUBSYSTEM ACTIVITY
JFS is in maintenance mode - no new features, but receives a steady stream of corruption-defense fixes (mostly syzbot-driven). This is exactly the kind of fix that goes to stable.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: WHO IS AFFECTED
All users of JFS filesystems. Trigger requires a corrupt JFS filesystem image (could be from disk corruption, or crafted by an attacker with local access).
### Step 8.2: TRIGGER CONDITIONS
- Requires mounting or using a JFS filesystem with corrupt dmapctl pages
- Syzbot reproduces this via lsetxattr syscall on a crafted image
- Can be triggered by unprivileged user operations on a mounted JFS filesystem
- Corrupt filesystem images can come from disk errors, USB drives, or malicious crafting
### Step 8.3: FAILURE MODE SEVERITY
- **UBSAN shift-out-of-bounds** = undefined behavior
- Without UBSAN, this could lead to incorrect memory access patterns, potential memory corruption
- The corrupt budmin/leaf values flow into array indexing and shift operations
- Severity: **HIGH** (undefined behavior, potential for memory corruption or crash)
### Step 8.4: RISK-BENEFIT RATIO
- **BENEFIT:** High - fixes a reproducible syzbot bug, prevents undefined behavior from corrupt on-disk data, protects against a class of bugs (not just one instance)
- **RISK:** Low-Medium - the fix is ~87 lines of new validation code (moderate size), but all checks are straightforward bounds checks against well-defined constants. The existing error return pattern is preserved. The fix only adds stricter validation - it cannot break valid filesystems.
- **Ratio:** Favorable for backport
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: COMPILE THE EVIDENCE
**Evidence FOR backporting:**
- Fixes a real, reproducible syzbot bug (UBSAN shift-out-of-bounds in dbSplit)
- Syzbot confirms the same bug exists on linux-6.1 and linux-5.15 (unpatched)
- Protects against undefined behavior from corrupt on-disk data
- Applied and tested by the JFS maintainer (Dave Kleikamp)
- Standalone patch, no dependencies
- Code being modified has existed since v2.6.12 (present in all stable trees)
- Bug is triggerable from unprivileged userspace syscalls
- Pattern is consistent with dozens of similar JFS fixes that go to stable
**Evidence AGAINST backporting:**
- Somewhat large (~110 lines of net change) for a stable fix
- Adds a new function rather than a minimal surgical fix
- Could theoretically reject valid dmapctl pages if the checks are too strict (but checks match documented invariants)
- The dbExtendFS() additions are new check sites (not replacements), adding code to paths that had none before
### Step 9.2: STABLE RULES CHECKLIST
1. **Obviously correct and tested?** YES - maintainer tested and applied; checks are against documented constants
2. **Fixes a real bug?** YES - syzbot-reported UBSAN, reproducible with C reproducer
3. **Important issue?** YES - undefined behavior (shift-out-of-bounds), potential memory corruption
4. **Small and contained?** BORDERLINE - ~110 lines but all in one file, one new function with clear purpose
5. **No new features or APIs?** YES - purely defensive validation
6. **Can apply to stable?** YES - code structure is stable across all trees
### Step 9.3: EXCEPTION CATEGORIES
Not an exception category, but fits the standard "fixes real bug found by fuzzer" pattern.
### Step 9.4: DECISION
The fix addresses a real, reproducible syzbot bug that exists in all stable trees. While the patch is somewhat larger than ideal for stable (adding a complete validation function), it is well-contained within a single file and function, all checks are obviously correct bounds checks, and it was tested by the subsystem maintainer. The undefined behavior it prevents could lead to memory corruption or crashes on corrupt JFS images. The syzbot data shows similar bugs are actively reproducing on stable kernels (linux-6.1, linux-5.15). The benefit clearly outweighs the moderate risk.
---
## Verification
- [Phase 1] Parsed tags: Reported-by syzbot+4c1966e88c28fa96e053,
Closes: syzkaller link, SOBs from author + JFS maintainer
- [Phase 2] Diff analysis: ~87 lines new validation function, 3 replacement sites, 5 new check sites, all in fs/jfs/jfs_dmap.c
- [Phase 2] Root cause: BUDSIZE(cursz, budmin) macro does 1 << (s - m), corrupt leaf value (e.g. 115) → shift exponent 109
- [Phase 3] git blame: All 3 existing leafidx checks date to 1da177e4c3f41 (v2.6.12, 2005), present in all stable trees
- [Phase 3] git log: File has extensive syzbot-driven fix history (20+ commits addressing similar corruption issues)
- [Phase 3] Author: Yun Zhou (Wind River), not regular JFS contributor but patch applied by maintainer Dave Kleikamp
- [Phase 4] b4 dig: Found match at https://patch.msgid.link/202511281551
[email protected]
- [Phase 4] b4 dig -a: v1 (2025/11/20), v2 (2025/11/28) - committed version is v2 (latest)
- [Phase 4] b4 dig -w: JFS maintainer ([email protected]) was included, tested and applied
- [Phase 4] syzbot page: Bug first crash 354d ago, last 36d ago; reproducer available; similar bugs on linux-6.1 (0/3 patched) and linux-5.15 (0/3 patched)
- [Phase 4] Maintainer comment: "This is finally tested and applied" (Dave Kleikamp, 2026/03/16)
- [Phase 5] Call chain verified from syzbot trace: lsetxattr → __jfs_setxattr → ea_write → dbAlloc → dbAllocNear → dbAdjCtl → dbSplit (userspace reachable)
- [Phase 6] Buggy code present in all stable trees (since v2.6.12)
- [Phase 6] Backport: should apply cleanly, no significant structural changes in the 3 replacement sites
- [Phase 8] Severity: HIGH (undefined behavior from shift-out-of-bounds, potential memory corruption)
- [Phase 8] Trigger: unprivileged user setxattr on corrupt JFS filesystem
**YES**
fs/jfs/jfs_dmap.c | 114 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 111 insertions(+), 3 deletions(-)
fs/jfs/jfs_dmap.c +111 -3
@@ -133,6 +133,93 @@ static const s8 budtab[256] = {2 ,1 ,1 ,1 ,1 ,0 ,0 ,0 ,1 ,0 ,0 ,0 ,1 ,0 ,0 ,-1 }; +/* +* check_dmapctl - Validate integrity of a dmapctl structure +* @dcp: Pointer to the dmapctl structure to check +* +* Return: true if valid, false if corrupted +*/ +static bool check_dmapctl (struct dmapctl *dcp) +{ +s8 budmin = dcp->budmin; +u32 nleafs, l2nleafs, leafidx, height; +int i; + + nleafs =le32_to_cpu (dcp->nleafs); +/* Check basic field ranges */ +if (unlikely (nleafs >LPERCTL )) { +jfs_err ("dmapctl: invalid nleafs %u (max %u)" , + nleafs,LPERCTL ); +return false; + } + + l2nleafs =le32_to_cpu (dcp->l2nleafs); +if (unlikely (l2nleafs >L2LPERCTL )) { +jfs_err ("dmapctl: invalid l2nleafs %u (max %u)" , + l2nleafs,L2LPERCTL ); +return false; + } + +/* Verify nleafs matches l2nleafs (must be power of two) */ +if (unlikely ((1U << l2nleafs) != nleafs)) { +jfs_err ("dmapctl: nleafs %u != 2^%u" , + nleafs, l2nleafs); +return false; + } + + leafidx =le32_to_cpu (dcp->leafidx); +/* Check leaf index matches expected position */ +if (unlikely (leafidx !=CTLLEAFIND )) { +jfs_err ("dmapctl: invalid leafidx %u (expected %u)" , + leafidx,CTLLEAFIND ); +return false; + } + + height =le32_to_cpu (dcp->height); +/* Check tree height is within valid range */ +if (unlikely (height > (L2LPERCTL >>1 ))) { +jfs_err ("dmapctl: invalid height %u (max %u)" , + height,L2LPERCTL >>1 ); +return false; + } + +/* Check budmin is valid (cannot be NOFREE for non-empty tree) */ +if (budmin ==NOFREE ) { +if (unlikely (nleafs >0 )) { +jfs_err ("dmapctl: budmin is NOFREE but nleafs %u" , + nleafs); +return false; + } + }else if (unlikely (budmin <BUDMIN )) { +jfs_err ("dmapctl: invalid budmin %d (min %d)" , + budmin,BUDMIN ); +return false; + } + +/* Check leaf nodes fit within stree array */ +if (unlikely (leafidx + nleafs >CTLTREESIZE )) { +jfs_err ("dmapctl: leaf range exceeds stree size (end %u > %u)" , + leafidx + nleafs,CTLTREESIZE ); +return false; + } + +/* Check leaf nodes have valid values */ +for (i = leafidx; i < leafidx + nleafs; i++) { +s8 val = dcp->stree[i]; + +if (unlikely (val <NOFREE )) { +jfs_err ("dmapctl: invalid leaf value %d at index %d" , + val, i); +return false; + }else if (unlikely (val >31 )) { +jfs_err ("dmapctl: leaf value %d too large at index %d" , val, i); +return false; + } + } + +return true; +} +/* * NAME: dbMount() *
@@ -1372,7 +1459,7 @@ dbAllocAG(struct bmap * bmp, int agno, s64 nblocks, int l2nb, s64 * results) dcp = (struct dmapctl *) mp->data; budmin = dcp->budmin; -if (dcp->leafidx !=cpu_to_le32 (CTLLEAFIND )) { +if (unlikely (!check_dmapctl (dcp))) {jfs_error (bmp->db_ipbmap->i_sb,"Corrupt dmapctl page\n" );release_metapage (mp);return -EIO ;
@@ -1702,7 +1789,7 @@ static int dbFindCtl(struct bmap * bmp, int l2nb, int level, s64 * blkno) dcp = (struct dmapctl *) mp->data; budmin = dcp->budmin; -if (dcp->leafidx !=cpu_to_le32 (CTLLEAFIND )) { +if (unlikely (!check_dmapctl (dcp))) {jfs_error (bmp->db_ipbmap->i_sb,"Corrupt dmapctl page\n" );release_metapage (mp);
@@ -2485,7 +2572,7 @@ dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc, int level)return -EIO ; dcp = (struct dmapctl *) mp->data; -if (dcp->leafidx !=cpu_to_le32 (CTLLEAFIND )) { +if (unlikely (!check_dmapctl (dcp))) {jfs_error (bmp->db_ipbmap->i_sb,"Corrupt dmapctl page\n" );release_metapage (mp);return -EIO ;
@@ -3454,6 +3541,11 @@ int dbExtendFS(struct inode *ipbmap, s64 blkno, s64 nblocks)return -EIO ; } l2dcp = (struct dmapctl *) l2mp->data; +if (unlikely (!check_dmapctl (l2dcp))) { +jfs_error (ipbmap->i_sb,"Corrupt dmapctl page\n" ); +release_metapage (l2mp); +return -EIO ; + }/* compute start L1 */ k = blkno >>L2MAXL1SIZE ;
@@ -3471,6 +3563,10 @@ int dbExtendFS(struct inode *ipbmap, s64 blkno, s64 nblocks)if (l1mp ==NULL ) goto errout; l1dcp = (struct dmapctl *) l1mp->data; +if (unlikely (!check_dmapctl (l1dcp))) { +jfs_error (ipbmap->i_sb,"Corrupt dmapctl page\n" ); + goto errout; + }/* compute start L0 */ j = (blkno & (MAXL1SIZE -1 )) >>L2MAXL0SIZE ;
@@ -3484,6 +3580,10 @@ int dbExtendFS(struct inode *ipbmap, s64 blkno, s64 nblocks) goto errout; l1dcp = (struct dmapctl *) l1mp->data; +if (unlikely (!check_dmapctl (l1dcp))) { +jfs_error (ipbmap->i_sb,"Corrupt dmapctl page\n" ); + goto errout; + }/* compute start L0 */ j =0 ;
@@ -3503,6 +3603,10 @@ int dbExtendFS(struct inode *ipbmap, s64 blkno, s64 nblocks)if (l0mp ==NULL ) goto errout; l0dcp = (struct dmapctl *) l0mp->data; +if (unlikely (!check_dmapctl (l0dcp))) { +jfs_error (ipbmap->i_sb,"Corrupt dmapctl page\n" ); + goto errout; + }/* compute start dmap */ i = (blkno & (MAXL0SIZE - 1)) >>
@@ -3518,6 +3622,10 @@ int dbExtendFS(struct inode *ipbmap, s64 blkno, s64 nblocks) goto errout; l0dcp = (struct dmapctl *) l0mp->data; +if (unlikely (!check_dmapctl (l0dcp))) { +jfs_error (ipbmap->i_sb,"Corrupt dmapctl page\n" ); + goto errout; + }/* compute start dmap */ i =0 ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: mac80211: Remove deleted sta links in ieee80211_ml_reconf_work()
In reply to Sasha LevinFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit 84674b03d8bf3a850f023a98136c27909f0a2b61 ]
Delete stale station links announced in the reconfiguration IE transmitted by the AP in the beacon frames.
---
LLM Generated explanations, may be completely bogus:
Now I have all the data needed for my analysis. Let me compile the final assessment.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: Subject Line**
- Subsystem: wifi: mac80211:
- Action verb: "Remove" (implies cleaning up something that should have been cleaned up but wasn't)
- Summary: Remove deleted sta links in ieee80211_ml_reconf_work()
- Record: [wifi: mac80211] [Remove] [Clean up stale station link data during AP-initiated MLO reconfiguration]
**Step 1.2: Tags**
- Signed-off-by: Lorenzo Bianconi (author)
- Link: https://patch.msgid.link/20260309-mac80211-reconf-remove-sta-
[email protected]
- Signed-off-by: Johannes Berg (mac80211 maintainer who applied it)
- No Fixes: tag
- No Cc: stable tag
- No Reported-by: tag
- Record: Applied by mac80211 maintainer Johannes Berg. No explicit stable nomination. This is v2 of the patch.
**Step 1.3: Commit Body**
- "Delete stale station links announced in the reconfiguration IE transmitted by the AP in the beacon frames."
- The commit describes missing cleanup of station link data when an AP announces link removal via the ML Reconfiguration element in beacons.
- Record: Bug is missing STA link cleanup during AP-initiated ML reconfiguration. No crash described, but clear data inconsistency/leak.
**Step 1.4: Hidden Bug Fix Detection**
- "Remove deleted sta links" and "Delete stale station links" = this IS a bug fix: cleanup that was missing, leading to stale/leaked resources.
- Record: YES - this is a hidden bug fix. Station links were not being freed during AP-initiated link removal, creating resource leaks and data inconsistency.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: Inventory**
- Single file: net/mac80211/mlme.c
- +11 lines added, 0 removed
- Function modified: ieee80211_ml_reconf_work()
- Record: [net/mac80211/mlme.c: +11/-0] [ieee80211_ml_reconf_work] [Single-file surgical fix]
**Step 2.2: Code Flow**
- BEFORE: After adjusting active links, the function calls ieee80211_vif_set_links() to update VIF-level links but NEVER cleans up STA-level link data.
- AFTER: Before calling ieee80211_vif_set_links(), the function looks up the AP station, iterates removed links, and calls ieee80211_sta_free_link() for each to clean up STA link data.
- Affected path: Normal AP-initiated ML reconfiguration path (beacon- driven link removal).
**Step 2.3: Bug Mechanism**
- Category: Resource leak + data inconsistency
- sta_remove_link() (called by ieee80211_sta_free_link()) performs:
1. Clears sta->sta.valid_links & ~BIT(link_id)
2. Accumulates removed link statistics
3. NULLs sta->link[link_id] and sta->sta.link[link_id] pointers
4. Frees the link_sta allocation via kfree_rcu()
5. Recalculates aggregates
- Without this fix, all of the above are skipped, causing memory leaks and stale data.
**Step 2.4: Fix Quality**
- Obviously correct: mirrors the STA-initiated path in ieee80211_mgd_assoc_ml_reconf() (line 10997-11003)
- Minimal/surgical: only 11 lines, single function, single file
- Regression risk: very low - ieee80211_sta_free_link() is a well- tested function
- Johannes Berg (maintainer) reviewed and applied it
- Record: Fix is obviously correct, minimal, and well-contained.
## PHASE 3: GIT HISTORY
**Step 3.1: Blame**
- All lines in ieee80211_ml_reconf_work() trace back to 8eb8dd2ffbbb (Ilan Peer, 2023-06-18) = the original ML reconf support commit.
- This commit is in v6.5-rc1, meaning the bug has existed since v6.5.
**Step 3.2: Fixes tag**
- No Fixes: tag present. The implicit target would be 8eb8dd2ffbbb ("wifi: mac80211: Support link removal using Reconfiguration ML element").
- 8eb8dd2ffbbb is in v6.5+ (verified: in v6.5, v6.6, NOT in v6.1).
**Step 3.3: Related Changes**
- 3f654d53dff56 converted ml_reconf_work to wiphy_hrtimer_work (v6.18-rc5+, NOT in v6.12 or v6.6)
- 162d331d833dc bounds-check link_id in ieee80211_ml_reconfiguration (Cc: stable)
- These are independent changes. The fix under review is standalone.
**Step 3.4: Author**
- Lorenzo Bianconi is a known wireless contributor with 10+ mac80211 commits.
- The patch was applied by Johannes Berg, the mac80211 maintainer.
**Step 3.5: Dependencies**
- ieee80211_sta_free_link() exists since v6.0-rc1 (commit 21476ad16d3ca)
- sta_info_get() is a long-standing function
- No dependencies beyond what exists in stable trees with the ML reconf feature.
- For stable trees < 6.18, the function signature uses wiphy_delayed_work instead of wiphy_hrtimer_work, requiring minor backport adjustment.
## PHASE 4: MAILING LIST
**Step 4.1: Discussion**
- v1 submitted 2026-03-07 to wireless-next
- Lachlan Hodges suggested using scoped_guard(rcu) instead
- Johannes Berg reviewed and provided critical feedback:
1. Remove unnecessary rcu_read_lock/unlock (wiphy mutex is held)
2. Asked whether ieee80211_sta_remove_link() should be used instead to notify the driver
3. Noted TDLS station cleanup is also needed (separate commit)
- Lorenzo addressed feedback in v2 (removed rcu locks)
- v2 applied by Johannes Berg
**Step 4.2: Reviewers**
- Johannes Berg (mac80211 maintainer) directly reviewed and applied the patch.
**Step 4.3: Bug Report**
- No external bug report. Discovered by code review / development.
**Step 4.4: Series**
- Standalone single patch, not part of a series.
**Step 4.5: Stable Discussion**
- No stable-specific discussion found. Patch was sent to wireless-next.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: Key Functions**
- ieee80211_ml_reconf_work() - the work function for AP-initiated ML reconfiguration
- ieee80211_sta_free_link() - cleans up STA link data (calls sta_remove_link without unhashing)
**Step 5.2: Callers**
- ieee80211_ml_reconf_work is scheduled by ieee80211_ml_reconfiguration() when the AP advertises link removal via ML Reconfiguration element in beacons.
- This is triggered by real AP behavior in MLO (WiFi 7) environments.
**Step 5.3-5.4: Call Chain**
- AP beacon -> ieee80211_ml_reconfiguration() -> schedules ieee80211_ml_reconf_work -> (the fix adds) ieee80211_sta_free_link() -> sta_remove_link() -> kfree_rcu() for link_sta allocation
**Step 5.5: Similar Patterns**
- The STA-initiated path (ieee80211_mgd_assoc_ml_reconf, line 10997-11003) correctly calls ieee80211_sta_remove_link(). This fix makes the AP-initiated path consistent.
## PHASE 6: STABLE TREE ANALYSIS
**Step 6.1: Buggy Code in Stable**
- Original ML reconf feature (8eb8dd2ffbbb) is in v6.5+
- Active stable trees affected: 6.6.y (the primary LTS)
- NOT in 6.1.y (too old for MLO support)
**Step 6.2: Backport Complications**
- For 6.6.y: the function uses wiphy_delayed_work not wiphy_hrtimer_work, so the container_of will need a minor adjustment. The core logic is the same.
- The fix itself is simple enough that adaptation should be trivial.
**Step 6.3: Related Fixes in Stable**
- No related fix for this specific bug in stable.
## PHASE 7: SUBSYSTEM CONTEXT
**Step 7.1: Subsystem**
- net/mac80211 - WiFi MAC layer, core wireless infrastructure
- Criticality: IMPORTANT - affects all WiFi 7 (MLO) users
**Step 7.2: Activity**
- mac80211 is very actively developed (MLO/WiFi 7 features ongoing).
## PHASE 8: IMPACT AND RISK
**Step 8.1: Who Is Affected**
- Users of WiFi 7 (MLO/Multi-Link Operation) where the AP performs link reconfiguration
- Growing user base as WiFi 7 hardware becomes common
**Step 8.2: Trigger Conditions**
- Triggered when an AP removes a link via ML Reconfiguration element in beacon frames
- This is a normal WiFi 7 operational scenario (AP-initiated link removal)
- Not timing-dependent
**Step 8.3: Failure Mode**
- Memory leak: link_sta_info and allocation leaked for each removed link (via missing kfree_rcu)
- Data inconsistency: sta->sta.valid_links still has bits set for removed links
- Stale STA link pointers not NULLed (potential stale data access)
- RX/TX paths checking sta.valid_links may behave incorrectly (40+ references across mac80211)
- Severity: HIGH (memory leak in operational path + data inconsistency affecting correctness)
**Step 8.4: Risk-Benefit**
- BENEFIT: Prevents memory leaks and data inconsistency in WiFi 7 MLO link removal. Fixes a correctness bug that affects all WiFi 7 users with AP-initiated link removal.
- RISK: Very low. 11 lines added, calls well-tested ieee80211_sta_free_link(). Reviewed by mac80211 maintainer. Minor backport adjustment needed for older stable trees.
- Ratio: High benefit, very low risk.
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: Evidence**
FOR backporting:
- Fixes a real bug: missing STA link cleanup = memory leak + data inconsistency
- Small, surgical fix: 11 lines added in one function, one file
- Obviously correct: mirrors the existing STA-initiated reconfig path
- Reviewed and applied by mac80211 maintainer Johannes Berg
- Bug exists since v6.5, affects active stable tree 6.6.y
- ieee80211_sta_free_link() exists in all affected stable trees
- No dependencies on other patches
AGAINST backporting:
- Sent to wireless-next (not wireless/fixes), suggesting author/maintainer didn't consider it urgent
- No Fixes: tag, no Cc: stable tag
- No crash reports or user-visible symptoms documented
- WiFi 7 MLO is relatively new (fewer affected users currently)
- Minor backport adaptation needed for pre-6.18 trees (wiphy_delayed_work vs wiphy_hrtimer_work)
**Step 9.2: Stable Rules Checklist**
1. Obviously correct and tested? YES - mirrors existing pattern, reviewed by maintainer
2. Fixes a real bug? YES - memory leak and data inconsistency
3. Important issue? MEDIUM-HIGH - memory leak in operational path, data corruption risk
4. Small and contained? YES - 11 lines, single file
5. No new features? CORRECT - no new features
6. Can apply to stable? YES with minor adjustment for function signature
**Step 9.3: Exception Categories**
- Not an exception category (not device ID, quirk, DT, build fix, or doc fix)
**Step 9.4: Decision**
This is a clear correctness bug fix that prevents memory leaks and data inconsistency in WiFi 7 MLO link removal. The fix is small, surgical, obviously correct, and reviewed by the maintainer. While it was sent to wireless-next and lacks explicit stable tags, the technical merit of the fix warrants backporting. The memory leak occurs every time an AP removes a link, which is a normal operational scenario for WiFi 7 users.
## Verification
- [Phase 1] Parsed tags: Signed-off-by Lorenzo Bianconi (author) + Johannes Berg (maintainer). No Fixes:, no Cc: stable, no Reported-by.
- [Phase 2] Diff analysis: 11 lines added in ieee80211_ml_reconf_work(), adds sta link cleanup via ieee80211_sta_free_link() before ieee80211_vif_set_links()
- [Phase 2] Compared with ieee80211_mgd_assoc_ml_reconf (lines 10997-11003) which correctly calls ieee80211_sta_remove_link() for removed links - confirms the AP-initiated path was missing equivalent cleanup
- [Phase 2] Read sta_remove_link() (line 414-448): confirmed it frees link_sta allocation via kfree_rcu, NULLs pointers, clears valid_links bits, accumulates stats
- [Phase 3] git blame: all lines in ieee80211_ml_reconf_work trace to 8eb8dd2ffbbb (v6.5-rc1, June 2023)
- [Phase 3] Verified 8eb8dd2ffbbb is in v6.5, v6.6 (YES), not in v6.1 (NO)
- [Phase 3] ieee80211_sta_free_link introduced in 21476ad16d3ca (v6.0-rc1) - exists in all affected stable trees
- [Phase 3] 3f654d53dff56 (hrtimer conversion) NOT in v6.12 or v6.6 - minor backport adaptation needed
- [Phase 4] b4 mbox: retrieved full v1 and v2 threads from lore
- [Phase 4] v1->v2 evolution: v2 removed unnecessary rcu_read_lock/unlock per Johannes Berg's review
- [Phase 4] Johannes Berg (maintainer) reviewed directly, asked about ieee80211_sta_remove_link vs ieee80211_sta_free_link - accepted ieee80211_sta_free_link since driver is notified via set_active_links
- [Phase 4] Patch sent to wireless-next (not wireless/fixes)
- [Phase 5] Verified sta_info_get() and ieee80211_sta_free_link() are available in all affected stable trees
- [Phase 5] sta.valid_links is referenced 40+ times across mac80211 - stale bits affect many code paths
- [Phase 6] Bug affects v6.5+ stable trees; 6.6.y is primary affected LTS
- [Phase 8] Failure mode: memory leak (kfree_rcu not called) + data inconsistency (valid_links stale) - severity HIGH
**YES**
net/mac80211/mlme.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
net/mac80211/mlme.c +11 -0
@@ -7001,6 +7001,7 @@ static void ieee80211_ml_reconf_work(struct wiphy *wiphy, container_of(work, struct ieee80211_sub_if_data, u.mgd.ml_reconf_work.work);u16 new_valid_links, new_active_links, new_dormant_links; +struct sta_info *sta;int ret;if (!sdata->u.mgd.removed_links)
@@ -7036,6 +7037,16 @@ static void ieee80211_ml_reconf_work(struct wiphy *wiphy, } } + sta =sta_info_get (sdata, sdata->vif.cfg.ap_addr); +if (sta) { +unsigned long removed_links = sdata->u.mgd.removed_links; +unsigned int link_id; + +for_each_set_bit (link_id, &removed_links, +IEEE80211_MLD_MAX_NUM_LINKS ) +ieee80211_sta_free_link (sta, link_id); + } + new_dormant_links = sdata->vif.dormant_links & ~sdata->u.mgd.removed_links; ret = ieee80211_vif_set_links(sdata, new_valid_links,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 HID: logitech-hidpp: fix race condition when accessing stale stack pointer
In reply to Sasha LevinFrom: Benoît Sevens <[email protected]>
[ Upstream commit e2aaf2d3ad92ac4a8afa6b69ad4c38e7747d3d6e ]
The driver uses hidpp->send_receive_buf to point to a stack-allocated buffer in the synchronous command path (__do_hidpp_send_message_sync). However, this pointer is not cleared when the function returns.
If an event is processed (e.g. by a different thread) while the send_mutex is held by a new command, but before that command has updated send_receive_buf, the handler (hidpp_raw_hidpp_event) will observe that the mutex is locked and dereference the stale pointer.
This results in an out-of-bounds access on a different thread's kernel stack (or a NULL pointer dereference on the very first command).
Fix this by:
1. Clearing hidpp->send_receive_buf to NULL before releasing the mutex in the synchronous command path.
2. Moving the assignment of the local 'question' and 'answer' pointers inside the mutex_is_locked() block in the handler, and adding a NULL check before dereferencing.
---
LLM Generated explanations, may be completely bogus:
Now I have enough information to make a thorough analysis. Let me compile my findings.
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: Parse Subject Line**
- Record: Subsystem HID: logitech-hidpp, action verb fix, summary:
race condition when accessing stale stack pointer (clear bug fix).
**Step 1.2: Parse Tags**
- Record: Signed-off-by: Benoît Sevens <[email protected]> (author) and Signed-off-by: Jiri Kosina <[email protected]> (HID subsystem maintainer). No Reported-by/Link/Fixes tags. No stable tag. Author is a known Google security researcher (has other HID UAF/OOB fixes in roccat and wacom).
**Step 1.3: Analyze Body**
- Record: Bug description: hidpp->send_receive_buf is assigned to point at a stack-allocated response buffer inside __do_hidpp_send_message_sync() but never cleared when the function returns. Meanwhile hidpp_raw_hidpp_event() speculatively reads this pointer whenever send_mutex is locked. The race:
1. Thread A finishes a command; leaves send_receive_buf pointing at A's stack.
2. Thread B grabs send_mutex; there is a window before B writes send_receive_buf = response.
3. Event handler fires (different thread), sees the mutex locked, dereferences the stale pointer from A's stack. The handler even performs *answer = *report — a WRITE to the stale stack pointer using device-supplied data (potential stack corruption / info leak / exploit primitive).
4. On very first use, send_receive_buf is NULL → NULL deref.
Symptom: OOB stack access on a different thread or NULL deref on first command.
**Step 1.4: Hidden Bug Detection**
- Record: Not hidden — commit title already says "fix race condition". Classic race + UAF/stale-pointer bug.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: Inventory**
- Record: One file changed (drivers/hid/hid-logitech-hidpp.c), +17/-7 lines. Two functions touched: __do_hidpp_send_message_sync() and hidpp_raw_hidpp_event(). Classification: single-file surgical fix.
**Step 2.2: Code Flow Change**
- Record: Producer (__do_hidpp_send_message_sync): early returns converted to goto out, new out: label clears hidpp->send_receive_buf = NULL before returning. Consumer (hidpp_raw_hidpp_event): question/answer assignments moved inside the mutex_is_locked() block, plus if (!question) return 0; NULL guard before use.
**Step 2.3: Bug Mechanism**
- Record: Category (b)+(d) — race / memory safety fix. Adds implicit synchronization by ensuring the shared pointer is NULL'd while still holding send_mutex, and adds a NULL check on the read side to close the small window between mutex acquisition and pointer assignment. Addresses two failure modes: stale stack pointer dereference (UAF of stack memory) and NULL dereference on first use.
**Step 2.4: Fix Quality**
- Record: Obviously correct. Minimal. No new locks, no API/ABI changes. Possible (extremely minor) regression risk: if a report raced in between mutex_lock and the assignment, the early-out return 0 will now skip matching it against the question — but this was already broken (it used a stale pointer) and the send path has a 5-second timeout with retry, so the benign behavior is strictly safer. No regression risk beyond that.
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: Blame**
- Record: The stale-pointer pattern (hidpp->send_receive_buf = response; and the speculative read struct hidpp_report *question = hidpp->send_receive_buf;) dates to commit 2f31c52529103d "HID:
Introduce hidpp" by Benjamin Tissoires, Sep 2014 (≈ v3.18). Bug is therefore present in every stable tree from v3.18 through v6.19/mainline.
**Step 3.2: Fixes: tag**
- Record: No Fixes: tag in the commit. Manually identified introducing commit as 2f31c52529103d (original driver introduction, 2014).
**Step 3.3: Related Changes to the File**
- Record: Recent file history shows actively maintained file (device ID adds, quirks, other UAF fix f7a4c78b "Prevent use-after-free on force feedback initialisation failure"). Function was split into __do_hidpp_send_message_sync/hidpp_send_message_sync in 60165ab774cb0c (v6.7, Jul 2023). Before that split (v6.6 is the earliest with __do_hidpp_send_message_sync), the logic lived inline in hidpp_send_message_sync.
**Step 3.4: Author's Other Commits**
- Record: Benoît Sevens (Google) has prior HID security fixes:
d802d848 (roccat UAF), 2f1763f6 (wacom OOB), plus similar fixes in uvcvideo and ALSA. Consistent pattern of Google-originated kernel security research. High trust.
**Step 3.5: Dependencies**
- Record: Self-contained, no prerequisites. Fix only touches one file and two functions. For v6.1.y and older the function was not yet split, so the fix requires trivial rewording to apply (move the NULL- out before mutex_unlock in hidpp_send_message_sync), but the change is mechanical.
## PHASE 4: MAILING LIST RESEARCH
**Step 4.1: Original Discussion**
- Record: b4 dig -c e2aaf2d3ad92a found the thread at https://lore.ker
nel.org/all/[email protected]/. Only one version (v1) was posted; no review-imposed revisions.
**Step 4.2: Reviewers**
- Record: b4 dig -w: patch CC'd Filipe Laíns, Bastien Nocera, Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel — all the correct maintainers. Merged by Jiri Kosina (subsystem maintainer) with note: "Now applied. Benjamin had some ideas on further cleanup (allocating with __free__ instead of using stack pointer), but that'd be a little bigger cleanup, so let's keep that separate." Confirms maintainer reviewed and accepted; any follow-up is an orthogonal cleanup, not a fix correction.
**Step 4.3: Bug Reports**
- Record: No Reported-by or Link tags. Author is from Google — likely discovered via internal audit/fuzzing. No public reproducer cited.
**Step 4.4: Related Series**
- Record: Single standalone patch, no series.
**Step 4.5: Stable ML**
- Record: Not searched; the patch was only posted April 1, 2026 and applied soon after — too fresh for independent stable ML activity.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: Key Functions**
- Record: __do_hidpp_send_message_sync (producer) and hidpp_raw_hidpp_event (consumer).
**Step 5.2: Callers**
- Record: 45 call sites for hidpp_send_*_sync inside the driver — every HID++ query (battery, connect, feature discovery, probe, get_report_length, etc.). hidpp_raw_hidpp_event is invoked from hidpp_raw_event (registered as .raw_event in hid_ll_driver), reached from the HID core for every HID report coming from any Logitech HID++ device (receivers, mice, keyboards, touchpads). Both paths fire during normal operation — not rare.
**Step 5.3: Callees**
- Record: Sync path calls __hidpp_send_report() (USB/Bluetooth transmit) and wait_event_timeout(). Event path does a struct-copy *answer = *report — this is the dangerous write when answer is stale.
**Step 5.4: Reachability**
- Record: The sync path runs in process context (probe, sysfs, workqueue). The event path runs from HID input processing (URB completion / BT callback, softirq or kthread depending on transport). Different contexts on different CPUs → true concurrent race possible. Triggers do not require privilege — any HID++ device that sends unsolicited reports while a command is in flight can race. This is the normal mode of operation for hidpp devices (connect events, battery notifications, keypresses).
**Step 5.5: Similar Patterns**
- Record: Only one occurrence of send_receive_buf in the file; pattern is unique to this driver.
## PHASE 6: STABLE TREE ANALYSIS
**Step 6.1: Buggy Code in Stable**
- Record: Verified via git show <tag>:drivers/hid/hid-logitech-hidpp.c that the exact same vulnerable pattern (send_receive_buf = response without clearing, question = hidpp->send_receive_buf read without NULL check) exists in v4.19, v5.4, v5.10, v5.15, v6.1, v6.6. All active stable trees are affected.
**Step 6.2: Backport Complications**
- Record: v6.6+ (and mainline): patch applies cleanly — identical function structure. v6.1 and earlier: __do_hidpp_send_message_sync does not yet exist; the logic is inline in hidpp_send_message_sync which also holds/releases send_mutex. Backport requires mechanically placing hidpp->send_receive_buf = NULL; before mutex_unlock(&hidpp->send_mutex) in hidpp_send_message_sync, and applying the event-handler hunk unchanged. Straightforward for the stable maintainers.
**Step 6.3: Related Fixes in Stable**
- Record: No prior independent fix for this specific race is in stable. Unrelated recent fixes (force-feedback UAF f7a4c78b) target other paths.
## PHASE 7: SUBSYSTEM CONTEXT
**Step 7.1: Criticality**
- Record: Subsystem: drivers/hid/ HID++ Logitech driver. Logitech Unifying receivers/MX mice/keyboards are ubiquitous on laptops and desktops; the driver ships on most distributions. Classification:
IMPORTANT (wide hardware user base), not CORE.
**Step 7.2: Activity**
- Record: Actively developed — multiple merges per release cycle (device IDs, quirks, bug fixes). Mature core codepaths in the driver have been stable for years.
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: Who Is Affected**
- Record: Anyone with a Logitech HID++ device (mice, keyboards, receivers, presenters) using the in-tree driver. Essentially most laptop users with Logitech peripherals. Driver-specific but very widespread hardware.
**Step 8.2: Trigger Conditions**
- Record: Requires concurrent activity: one thread invoking a sync command while the device sends an asynchronous report. Races happen during connect/disconnect, battery reporting, feature queries. The very-first-use path yields NULL deref (no concurrency needed: any async event before any sync command completes once) — but that path is rare because probe typically drives the first sync command before any report arrives. Attacker plane: a malicious or faulty HID device can flood reports to widen the window — reachable from device-trust boundary, relevant for BadUSB-style threat models.
**Step 8.3: Failure Mode Severity**
- Record: (a) NULL pointer dereference → kernel oops (CRITICAL: crash).
(b) Stale stack pointer read → OOB read (HIGH: info leak). (c) Stale stack pointer WRITE via *answer = *report using device-controlled data → stack corruption on an unrelated thread (CRITICAL: memory corruption, potential privilege escalation/exploit primitive). Overall
severity: CRITICAL.
**Step 8.4: Risk/Benefit**
- Record: Benefit HIGH — closes a long-standing race with crash/corruption potential in a widely-deployed driver. Risk LOW — 24-line surgical change, no new locking, no API change, reviewed and applied by subsystem maintainer, only risk is a missed-answer timeout that already has retry logic and a 5-second wait. Ratio clearly favors backporting.
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: Evidence**
- FOR: Fixes real race/UAF/NULL-deref, very widespread hardware, small and surgical, author has security-fix track record, applied by subsystem maintainer, bug is 10+ years old (present in every active stable), failure modes include potential stack corruption from device- controlled data (security-relevant).
- AGAINST: No Reported-by/Fixes/Cc: stable tag; no public reproducer; for older stables (≤v6.1) a trivial mechanical adaptation is needed because the function was later split.
- UNRESOLVED: Exact kernel trigger rate in the wild is not documented; CVE status unknown.
**Step 9.2: Stable Rules**
1. Obviously correct & tested? Yes — tiny, mechanical; applied by maintainer.
2. Fixes real bug? Yes — race + stale/NULL pointer deref with concrete failure modes.
3. Important? Yes — kernel oops and potential stack corruption.
4. Small & contained? Yes — 24 lines, one file, two functions.
5. No new features/APIs? Correct — pure fix.
6. Applies to stable? v6.6+: clean. ≤v6.1: needs trivial adaptation.
**Step 9.3: Exceptions**
- Not an exception category; qualifies on normal bug-fix merit.
**Step 9.4: Decision**
- The commit is a textbook stable candidate: small, targeted race fix in a broadly used driver, repairing a NULL-deref + stale-pointer write that a faulty/malicious device can provoke.
### Verification
- [Phase 1] Read full commit message — no Fixes/Reported-by/Cc: stable tags; identified bug description and two-step fix.
- [Phase 2] Read diff end-to-end; confirmed +17/-7 in one file, two functions, classic NULL-out + NULL-check pattern with goto out.
- [Phase 3] git blame on both functions: pattern dates to 2f31c52529103d (2014, v3.18). Split into __do_hidpp_send_message_sync at 60165ab774cb0c (v6.7).
- [Phase 3] git log --oneline -- drivers/hid/hid-logitech-hidpp.c:
file is actively maintained.
- [Phase 3] git log --oneline --author="Benoit Sevens\|Benoît Sevens":
confirmed author's pattern of HID/UVC/ALSA security fixes.
- [Phase 4] b4 dig -c e2aaf2d3ad92a: found lore thread at https://lor e.kernel.org/all/[email protected]/.
- [Phase 4] b4 dig -w: confirmed CC list includes Jiri Kosina, Benjamin Tissoires, Filipe Laíns, Bastien Nocera, linux-input, linux- kernel.
- [Phase 4] b4 dig -a: only v1 was posted; no further revisions.
- [Phase 4] Read /tmp/hidpp_race.mbox: confirmed maintainer Jiri Kosina's "Now applied" reply and note about deferred cleanup idea from Benjamin Tissoires.
- [Phase 5] rg send_receive_buf: confirmed only 4 references (struct member + 1 write + 2 reads), no other use sites.
- [Phase 5] Read hidpp_raw_event caller: confirmed registered as .raw_event and called for every HID++ short/long/very-long report from the device.
- [Phase 6] git show vX:drivers/hid/hid-logitech-hidpp.c for v4.19, v5.4, v5.10, v5.15, v6.1, v6.6: verified vulnerable pattern exists in every stable tree.
- [Phase 6] Verified __do_hidpp_send_message_sync only exists from v6.6 onward; older trees need trivial adaptation of the producer hunk.
- [Phase 8] Reviewed event handler body: *answer = *report is a write, confirming the stack-corruption / write-primitive aspect (not merely an info leak).
- UNVERIFIED: Whether a CVE was assigned; whether a public reproducer exists; exact in-wild trigger rate.
The fix is small, surgical, reviewed by the HID maintainer, repairs a long-standing race with crash and stack-corruption consequences affecting extremely common Logitech hardware, and backports cleanly to recent stables with only a mechanical adjustment needed for older ones.
**YES**
drivers/hid/hid-logitech-hidpp.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
drivers/hid/hid-logitech-hidpp.c +17 -7
@@ -306,21 +306,22 @@ static int __do_hidpp_send_message_sync(struct hidpp_device *hidpp,if (ret) {dbg_hid ("__hidpp_send_report returned err: %d\n" , ret);memset (response,0 ,sizeof (struct hidpp_report )); -return ret; + goto out; }if (!wait_event_timeout (hidpp->wait, hidpp->answer_available,5 *HZ )) {dbg_hid ("%s:timeout waiting for response\n" , __func__);memset (response,0 ,sizeof (struct hidpp_report )); -return -ETIMEDOUT ; + ret = -ETIMEDOUT ; + goto out; }if (response->report_id ==REPORT_ID_HIDPP_SHORT && response->rap.sub_id ==HIDPP_ERROR ) { ret = response->rap.params[1 ];dbg_hid ("%s:got hidpp error %02X\n" , __func__, ret); -return ret; + goto out; } if ((response->report_id == REPORT_ID_HIDPP_LONG ||
@@ -328,10 +329,14 @@ static int __do_hidpp_send_message_sync(struct hidpp_device *hidpp, response->fap.feature_index == HIDPP20_ERROR) { ret = response->fap.params[1 ];dbg_hid ("%s:got hidpp 2.0 error %02X\n" , __func__, ret); -return ret; + goto out; } -return 0 ; + ret =0 ; + +out: + hidpp->send_receive_buf =NULL ; +return ret; }/*
@@ -3843,8 +3848,7 @@ static int hidpp_input_configured(struct hid_device *hdev,static int hidpp_raw_hidpp_event (struct hidpp_device *hidpp,u8 *data,int size) { -struct hidpp_report *question = hidpp->send_receive_buf; -struct hidpp_report *answer = hidpp->send_receive_buf; +struct hidpp_report *question, *answer;struct hidpp_report *report = (struct hidpp_report *)data;int ret;int last_online;
@@ -3854,6 +3858,12 @@ static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data,* previously sent command. */ if (unlikely (mutex_is_locked (&hidpp->send_mutex))) { + question = hidpp->send_receive_buf; + answer = hidpp->send_receive_buf; + +if (!question) +return 0 ; +/* * Check for a correct hidpp20 answer or the corresponding * error
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 net/mlx5e: XSK, Increase size for chunk_size param
In reply to Sasha LevinFrom: Dragos Tatulea <[email protected]>
[ Upstream commit 1047e14b44edecbbab02a86514a083b8db9fde4d ]
When 64K pages are used, chunk_size can take the 64K value which doesn't fit in u16. This results in overflows that are detected in mlx5e_mpwrq_log_wqe_sz().
Increase the type to u32 to fix this.
---
LLM Generated explanations, may be completely bogus:
Now I have a comprehensive picture. Let me compile the full analysis.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: Subject Line**
- Subsystem: net/mlx5e (Mellanox ConnectX Ethernet driver, XSK subsystem)
- Action verb: "Increase" (but the intent is clearly to fix an overflow bug)
- Summary: Widen chunk_size from u16 to u32 to prevent integer overflow on 64K page systems.
Record: [net/mlx5e XSK] [increase/fix] [type widening to prevent overflow when chunk_size=65536]
**Step 1.2: Tags**
- Reviewed-by: Carolina Jubran (Nvidia engineer)
- Signed-off-by: Tariq Toukan (mlx5 submaintainer at Nvidia)
- Link:
https://patch.msgid.link/[email protected]
(patch 2 in a series)
- Signed-off-by: Paolo Abeni (netdev maintainer)
- No Fixes: tag (expected for autosel candidates)
- No Cc: stable (expected)
Record: Reviewed by Nvidia staff. Merged through standard netdev tree. Patch 2/N series.
**Step 1.3: Commit Body**
- Bug: On systems with 64K pages (ARM64), chunk_size can be 65536. Stored in u16, this overflows to 0.
- Symptom: "overflows that are detected in mlx5e_mpwrq_log_wqe_sz()"
- Root cause: u16 type is too narrow for the value 65536 (0x10000).
**Step 1.4: Hidden Bug Fix Detection**
This is explicitly described as fixing overflows. The word "Increase" obscures the fix nature, but the body clearly explains the overflow bug.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: Inventory**
- 1 file changed: drivers/net/ethernet/mellanox/mlx5/core/en/params.h
- 1 line changed: u16 chunk_size -> u32 chunk_size
- Scope: Single-file, single-line, surgical fix
**Step 2.2: Code Flow Change**
Before: chunk_size stored as u16 (max 65535). When set to 65536 (1 << 16 on 64K page systems), it silently wraps to 0.
After: chunk_size stored as u32 (max ~4 billion). Value 65536 is stored correctly.
**Step 2.3: Bug Mechanism**
Category: **Integer overflow / type size bug**
The overflow is triggered in params.c lines 1125-1131, where a temporary mlx5e_xsk_param is constructed:
```1125:1131:drivers/net/ethernet/mellanox/mlx5/core/en/params.c
for (frame_shift = XDP_UMEM_MIN_CHUNK_SHIFT;
frame_shift <= PAGE_SHIFT; frame_shift++) {
struct mlx5e_xsk_param xsk = {
.chunk_size = 1 << frame_shift,
.unaligned = false,
};
```On 64K page systems (PAGE_SHIFT=16), 1 << 16 = 65536 overflows u16 to 0. This then propagates to order_base_2(0) in mlx5e_mpwrq_page_shift(), which is undefined behavior.
**Step 2.4: Fix Quality**
- Obviously correct: widening u16 to u32 cannot break anything
- Minimal/surgical: exactly one type change
- Regression risk: effectively zero - u32 holds all values u16 can, plus the needed 65536
- The struct padding change is negligible (4 bytes -> 4 bytes due to existing alignment)
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: Blame**
The u16 chunk_size field was introduced in commit a069e977d6d8f2 by Maxim Mikityanskiy on 2019-06-26, first in v5.3-rc1. The bug has been present since then - approximately 7 years.
**Step 3.2: Prior Related Fixes**
Commit a5535e5336943 ("mlx5: stop warning for 64KB pages", 2024-03-28) was a workaround for a compiler warning about this exact issue. It added (size_t) cast in mlx5e_validate_xsk_param() to suppress the warning, but didn't fix the underlying type issue. That commit's message even noted "64KB chunks are really not all that useful, so just shut up the warning by adding a cast."
**Step 3.3: File History**
8 changes to params.h since v6.1. The struct itself has remained stable
- chunk_size field unchanged since its introduction.
**Step 3.4: Author Context**
Dragos Tatulea is a regular contributor to mlx5 at Nvidia, with multiple fixes for 64K page issues (SHAMPO fixes). The submitter Tariq Toukan is the mlx5e submaintainer. Paolo Abeni (netdev maintainer) merged it.
**Step 3.5: Dependencies**
The diff context shows a struct mlx5e_rq_opt_param that doesn't exist in the v7.0 tree. This means the patch was made against a slightly newer codebase. However, the actual change (u16->u32 on line 11 of the struct) is independent and applies with trivial context adjustment.
## PHASE 4: MAILING LIST RESEARCH
**Step 4.1-4.2:** Lore is blocked by Anubis protection. From b4 dig on the related commit a5535e5336943, I confirmed the earlier fix was patch 8/9 in Arnd Bergmann's series. The current commit appears to be the proper type-level fix.
**Step 4.3:** No external bug report references. The bug was found internally by the mlx5 team.
**Step 4.4:** Patch 2/N series (from message-id -2-). The companion patches likely include the mlx5e_rq_opt_param struct addition and possibly removal of the <= 0xffff sanity check in mlx5e_xsk_is_pool_sane(). This type-widening patch is standalone for fixing the overflow.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1:** The modified struct mlx5e_xsk_param is used across the entire mlx5e XSK/MPWRQ subsystem.
**Step 5.2: Callers of chunk_size**
- mlx5e_mpwrq_page_shift() - calls order_base_2(xsk->chunk_size) → undefined on 0
- mlx5e_mpwrq_umr_mode() - compares chunk_size with page_shift
- mlx5e_validate_xsk_param() - bounds check
- mlx5e_build_xsk_param() - stores pool chunk_size into struct
- Internal calculation loop in params.c - creates temporary structs
- mlx5e_create_rq_umr_mkey() in en_main.c - passes to hardware
**Step 5.4: Reachability**
The overflow triggers when ANY XDP program is loaded on an mlx5 interface on a 64K page system. The calculation loop runs during channel configuration, not just when XSK is explicitly used. This is a common scenario for ARM64 servers.
## PHASE 6: STABLE TREE ANALYSIS
**Step 6.1:** The buggy code (u16 chunk_size in mlx5e_xsk_param) exists in all stable trees from v5.3 onward (introduced 2019-06-26).
**Step 6.2:** Minor context adjustment needed (surrounding struct differs). The one-line change itself is trivially backportable.
**Step 6.3:** The earlier workaround (a5535e5336943) only suppressed a compiler warning but didn't fix the runtime overflow.
## PHASE 7: SUBSYSTEM CONTEXT
**Step 7.1:** Subsystem: drivers/net (networking, Mellanox ConnectX).
Criticality: IMPORTANT - widely used enterprise network hardware.
**Step 7.2:** Very active subsystem with frequent fixes, especially for 64K page support issues (multiple SHAMPO fixes by the same author).
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: Affected Users**
ARM64 systems with 64K pages running mlx5 (Mellanox ConnectX) NICs with XDP programs. This includes ARM64 servers in data centers.
**Step 8.2: Trigger Conditions**
Loading any XDP program on an mlx5 interface on a 64K page system triggers the internal calculation loop. The overflow happens during channel parameter computation.
**Step 8.3: Failure Mode**
- order_base_2(0) is undefined behavior, potentially returning garbage
- Wrong page_shift propagates through mlx5e_mpwrq_log_wqe_sz(), detected as overflow
- At minimum: WARN_ON triggers and incorrect hardware configuration
- At worst: incorrect WQE sizes could cause hardware errors, packet loss, or crashes
- Severity: **HIGH**
**Step 8.4: Risk-Benefit Ratio**
- Benefit: HIGH - fixes undefined behavior and incorrect calculations on 64K page ARM64 systems
- Risk: VERY LOW - changing u16 to u32 is trivially correct, cannot introduce regression
- Ratio: Strongly favorable for backporting
## PHASE 9: FINAL SYNTHESIS
**Evidence FOR backporting:**
- Fixes a real integer overflow bug causing undefined behavior
- Affects 64K page ARM64 systems with widely-used enterprise hardware
- One-line, obviously correct fix (type widening)
- Zero regression risk
- Bug present since v5.3 (7 years)
- Author is a known mlx5 contributor, reviewed by Nvidia staff, merged by netdev maintainer
- The earlier workaround (compiler warning fix) acknowledged the problem existed
**Evidence AGAINST backporting:**
- Needs minor context adjustment (surrounding struct differs)
- 64K page systems are a subset of users
- The mlx5e_xsk_is_pool_sane() check may prevent user-facing triggers (but NOT the internal calculation path)
**Stable Rules Checklist:**
1. Obviously correct and tested? YES - trivial type widening
2. Fixes a real bug? YES - integer overflow causing undefined behavior
3. Important issue? YES - undefined behavior, potential incorrect hardware config
4. Small and contained? YES - one line change
5. No new features or APIs? CORRECT - just a type fix
6. Can apply to stable trees? YES with trivial context adjustment
**Verification:**
- [Phase 1] Parsed tags: Reviewed-by Nvidia, merged by netdev maintainer. Patch 2/N series.
- [Phase 2] Diff analysis: single line type change u16->u32 in struct mlx5e_xsk_param
- [Phase 3] git blame: chunk_size as u16 introduced in a069e977d6d8f2 (v5.3-rc1, 2019), present in all active stable trees
- [Phase 3] git show a5535e5336943: prior workaround only added a cast, didn't fix the type
- [Phase 4] b4 dig for related commit found lore thread; Anubis blocked direct access
- [Phase 5] Traced callers: overflow at params.c:1129 feeds into order_base_2(0) in mpwrq_page_shift()
- [Phase 5] Verified xsk_pool_get_chunk_size() returns u32, truncated when stored in u16
- [Phase 6] Code exists in all stable trees from v5.3+; 8 changes to file since v6.1
- [Phase 6] Minor context conflict (mlx5e_rq_opt_param not in stable), trivially resolvable
- [Phase 8] Trigger: loading any XDP program on mlx5 on 64K page system; severity HIGH
- UNVERIFIED: Could not access lore.kernel.org to read full mailing list discussion
The fix is minimal, obviously correct, and addresses a real integer overflow that causes undefined behavior on ARM64 systems with 64K pages. The risk is negligible and the benefit is clear.
**YES**
drivers/net/ethernet/mellanox/mlx5/core/en/params.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en/params.h +1 -1
@@ -8,7 +8,7 @@struct mlx5e_xsk_param {u16 headroom; -u16 chunk_size; +u32 chunk_size;bool unaligned; };
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 PCI: dwc: Proceed with system suspend even if the endpoint doesn't respond with PME_TO_Ack message
In reply to Sasha LevinFrom: Manivannan Sadhasivam <[email protected]>
[ Upstream commit eed390775470ff0db32cce37a681f3acc2b941c3 ]
PCIe spec r7.0, sec 5.3.3.2.1, recommends proceeding with L2/L3 sequence even if one or devices do not respond with PME_TO_Ack message after 10ms timeout.
So just print a warning if the timeout happens and proceed with the system suspend.
---
LLM Generated explanations, may be completely bogus:
Now I have enough information to complete the full analysis. Let me compile my findings.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: Subject Line
- **Subsystem:** PCI: dwc
- **Action verb:** "Proceed" (implies fixing incorrect behavior where it was NOT proceeding)
- **Summary:** Continue system suspend when a PCIe endpoint doesn't respond with PME_TO_Ack
### Step 1.2: Tags
- **Reported-by:** Neil Armstrong <[email protected]> — Linaro engineer, real-world issue on Qualcomm SM8650-HDK
- **Tested-by:** Neil Armstrong <[email protected]> # on SM8650-HDK — Hardware-verified
- **Reviewed-by:** Frank Li <[email protected]> — Major DWC PCI contributor at NXP
- **Signed-off-by:** Manivannan Sadhasivam — DWC PCI subsystem maintainer (both @oss.qualcomm.com and @kernel.org)
- **Link:** patch.msgid.link for the v2 patch
- **No Fixes: tag** — expected for autosel candidates
- **No Cc: stable** — expected for autosel candidates
### Step 1.3: Commit Body
The commit references PCIe spec r7.0, sec 5.3.3.2.1, which explicitly recommends proceeding with L2/L3 sequence even when devices don't respond with PME_TO_Ack within 10ms. The current code aborts system suspend entirely when this timeout occurs, which is overly conservative and blocks real-world hardware.
**Bug:** System suspend fails when any PCIe endpoint doesn't respond with PME_TO_Ack within 10ms timeout.
**Symptom:** dev_err + return error from dw_pcie_suspend_noirq(), preventing suspend.
**Root cause:** Code treated a non-fatal timeout as fatal, contrary to spec recommendation.
### Step 1.4: Hidden Bug Fix Assessment
This is a clear behavior fix. "Proceed with system suspend" = "stop incorrectly aborting suspend". This is a real bug fix where the implementation deviates from the PCIe specification.
---
## PHASE 2: DIFF ANALYSIS
### Step 2.1: Inventory
- **Files changed:** 1 (drivers/pci/controller/dwc/pcie-designware- host.c)
- **Lines changed:** ~7 lines modified within a single error-handling block
- **Functions modified:** dw_pcie_suspend_noirq()
- **Scope:** Single-file, surgical fix to one error path
### Step 2.2: Code Flow Change
**Before:** When read_poll_timeout() returns error (endpoint didn't reach L2 state in 10ms):
- dev_err() prints an error
- return ret; aborts the entire suspend
**After:**
- dev_warn() prints a warning
- ret = 0; clears the error
- Execution continues through udelay(1), dw_pcie_stop_link(), and deinit() to complete suspend
### Step 2.3: Bug Mechanism
Category: **Logic/correctness fix** — the code was treating a non-fatal spec-compliant condition as fatal. The PCIe spec explicitly says to proceed with L2/L3 sequence even without PME_TO_Ack.
### Step 2.4: Fix Quality
- **Obviously correct:** Yes — directly implements PCIe spec r7.0 recommendation
- **Minimal:** Yes — 2-line essential change (dev_err→dev_warn, return→ret=0)
- **Regression risk:** Very low — previous behavior blocked suspend entirely; new behavior allows suspend to proceed per spec
- **Red flags:** None
---
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: Blame
The error-returning code was introduced by commit 4774faf854f534 ("PCI: dwc: Implement generic suspend/resume functionality") by Frank Li, merged in v6.6. The comment was modified by 112aba9a79345a (Richard Zhu, v6.15).
**Record:** Buggy code present since v6.6 in all stable trees through v6.16.
### Step 3.2: No Fixes tag to follow (expected).
### Step 3.3: File History
Related recent commits in this area:
- 58a17b2647ba5 — skip_l23_ready flag (v7.0 only, Cc: stable)
- cfd2fdfd0a8da — skip PME_Turn_Off if link not up (v7.0 only)
- 112aba9a79345a — additional LTSSM state checks (v6.15)
- 4774faf854f534 — original implementation (v6.6)
### Step 3.4: Author
Manivannan Sadhasivam IS the DWC PCI subsystem maintainer. He signed-off with both his Qualcomm and kernel.org addresses. He applied his own patch to his tree (commit eed390775470ff0db32cce37a681f3acc2b941c3).
### Step 3.5: Dependencies
The core fix applies independently of other commits. The same if (ret) { dev_err(); return ret; } pattern exists in all versions from v6.6 through v7.0. Context lines differ slightly between versions, requiring minor conflict resolution but no functional dependencies.
---
## PHASE 4: MAILING LIST RESEARCH
### Step 4.1: Original Submission
Found via web search and spinics.net mirrors:
- **v1:** Missing ret = 0, would pass error to callers
- **v2:** Added ret = 0 to properly clear the error (applied version)
- Applied by maintainer on Feb 26, 2026
### Step 4.2: Reviewers
- **Frank Li (NXP):** Gave Reviewed-by, major DWC PCI contributor
- **Neil Armstrong (Linaro):** Reporter and tester on SM8650-HDK
- No NAKs or objections
### Step 4.3: Bug Report
Neil Armstrong reported the issue. His Tested-by comment says: "Allows ath12k to go into d3cold" — the WiFi chip (ath12k) on Qualcomm SM8650-HDK doesn't respond with PME_TO_Ack in time, blocking suspend.
### Step 4.4: Related Patches
The skip_l23_ready patch (58a17b2647ba5) is a separate fix for i.MX6QP/i.MX7D platforms and was explicitly tagged Cc: stable. This PME_TO_Ack patch is a different fix addressing a broader issue.
### Step 4.5: Stable Discussion
The skip_l23_ready patch was Cc'd to stable with explicit Fixes: tag. This patch was not Cc'd to stable, which is why it's under review.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1: Functions Modified
Only dw_pcie_suspend_noirq() is modified.
### Step 5.2: Callers
Verified callers in each stable tree:
- **v6.6:** pci-layerscape.c
- **v6.12:** pci-layerscape.c
- **v6.15:** pci-layerscape.c, pci-imx6.c
- **v6.16:** pci-layerscape.c, pci-imx6.c
- **v7.0:** pci-layerscape.c, pci-imx6.c, pcie-stm32.c, pcie- nxp-s32g.c
### Step 5.3: Call chaindw_pcie_suspend_noirq() is called during system suspend from platform- specific PM callbacks. This is triggered whenever the system enters suspend (e.g., echo mem > /sys/power/state).
### Step 5.4: Reachability
Reachable from userspace via system suspend on any platform with a DWC PCIe controller and an endpoint that doesn't respond to PME_TO_Ack in time.
---
## PHASE 6: STABLE TREE ANALYSIS
### Step 6.1: Buggy Code in Stable
The buggy return ret; on L2 timeout exists in ALL stable trees from v6.6 through v6.16. Verified by examining the function body in each version.
### Step 6.2: Backport Complexity
The core fix (dev_err→dev_warn, return ret→ret=0) applies to the same code pattern in all versions. Context lines differ (skip_l23_ready block doesn't exist in v6.6-v6.16, DETECT_WAIT check only in v6.15+), so the patch won't apply cleanly but needs trivial adjustment.
### Step 6.3: Related Fixes
No other fix for this specific issue is in stable. The skip_l23_ready patch (Cc: stable) is a different fix for different hardware.
---
## PHASE 7: SUBSYSTEM CONTEXT
### Step 7.1: Subsystem
PCI controller driver (DWC — DesignWare Core). This is an IMPORTANT subsystem — DWC is the most widely used PCIe IP block, found in Qualcomm, NXP (LayerScape, i.MX), STM32, Samsung, and many other SoCs.
### Step 7.2: Activity
Very actively developed, with significant refactoring between versions.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: Affected Users
Users of DWC-based PCIe platforms (LayerScape, i.MX, STM32, S32G) who attempt system suspend with endpoints that don't respond to PME_TO_Ack within 10ms.
### Step 8.2: Trigger
System suspend on a DWC PCIe platform with a non-compliant or slow- responding PCIe endpoint. The ath12k WiFi chip is a known trigger.
### Step 8.3: Severity
**Failure mode:** System suspend fails entirely — the system cannot enter sleep.
**Severity:** HIGH — prevents power management on affected hardware.
### Step 8.4: Risk-Benefit
- **Benefit:** HIGH — prevents suspend failure on real hardware, aligns with PCIe spec
- **Risk:** VERY LOW — 2-line change, obviously correct per spec, no possible crash or data corruption from the fix itself (it only allows suspend to proceed as the spec recommends)
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: Evidence Summary
**FOR backporting:**
- Fixes real-world suspend failure reported by Linaro engineer on SM8650-HDK
- PCIe spec r7.0 explicitly recommends this behavior
- Fix is 2 essential lines (dev_err→dev_warn, return ret→ret=0)
- Author is DWC PCI subsystem maintainer
- Reviewed-by from NXP contributor, Tested-by from reporter
- Buggy code exists in all stable trees v6.6+
- No regression risk — the alternative (current behavior) is worse (blocks suspend)
**AGAINST backporting:**
- No explicit Cc: stable or Fixes: tag (expected)
- Behavior change rather than crash fix (but prevents functional failure)
- Minor context conflicts in older stable trees (trivially resolvable)
- Limited callers in older stable trees (mainly layerscape in v6.6-v6.12)
### Step 9.2: Stable Rules Checklist
1. **Obviously correct and tested?** YES — per PCIe spec, tested on hardware
2. **Fixes a real bug?** YES — suspend failure with certain endpoints
3. **Important issue?** YES — prevents system from suspending
4. **Small and contained?** YES — 2-line change in one function
5. **No new features?** CORRECT — no new features
6. **Can apply to stable?** YES — with trivial context adjustments
### Step 9.3: Exception Categories
Not a standard exception category, but this is a straightforward bug fix that aligns implementation with PCIe specification.
---
## Verification
- [Phase 1] Parsed tags: Reported-by Neil Armstrong (Linaro), Tested-by Neil Armstrong on SM8650-HDK, Reviewed-by Frank Li (NXP)
- [Phase 2] Diff analysis: 2-line essential change in error handler of dw_pcie_suspend_noirq(): dev_err→dev_warn, return ret→ret=0
- [Phase 3] git blame: buggy code introduced in 4774faf854f534 (v6.6), confirmed present in v6.6 through v6.16
- [Phase 3] git merge-base: confirmed 4774faf854f534 is in v6.6, v6.7, ..., v6.16
- [Phase 3] Author (Manivannan Sadhasivam) is the DWC PCI subsystem maintainer, applied his own patch
- [Phase 4] Found v1 and v2 on spinics.net; v1 missed ret = 0, v2 fixed it. Applied on Feb 26, 2026
- [Phase 4] Frank Li gave Reviewed-by; Neil Armstrong confirmed it fixes ath12k D3cold on SM8650-HDK
- [Phase 4] No NAKs, no objections in review
- [Phase 5] Callers verified: layerscape (v6.6+), imx6 (v6.15+), stm32/s32g (v7.0 only)
- [Phase 6] Buggy dev_err(); return ret; pattern verified in v6.6, v6.12, v6.15, v6.16 — all return error on timeout
- [Phase 6] Backport complexity: minor context differences, trivially resolvable
- [Phase 8] Failure mode: system suspend blocked entirely; severity HIGH for affected users
- UNVERIFIED: Exact set of PCIe endpoints that trigger this timeout (only ath12k confirmed); does not affect decision
The fix is small, surgical, spec-compliant, tested on real hardware, authored and merged by the subsystem maintainer, and prevents real-world suspend failures on DWC PCIe platforms.
**YES**
drivers/pci/controller/dwc/pcie-designware-host.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/pci/controller/dwc/pcie-designware-host.c +7 -3
@@ -1256,9 +1256,13 @@ int dw_pcie_suspend_noirq(struct dw_pcie *pci)PCIE_PME_TO_L2_TIMEOUT_US /10 , PCIE_PME_TO_L2_TIMEOUT_US, false, pci);if (ret) { -/* Only log message when LTSSM isn't in DETECT or POLL */ -dev_err (pci->dev,"Timeout waiting for L2 entry! LTSSM: 0x%x\n" , val); -return ret; +/* +* Failure is non-fatal since spec r7.0, sec 5.3.3.2.1, +* recommends proceeding with L2/L3 sequence even if one or more +* devices do not respond with PME_TO_Ack after 10ms timeout. +*/ +dev_warn (pci->dev,"Timeout waiting for L2 entry! LTSSM: 0x%x\n" , val); + ret =0 ; }/*
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ACPI: processor: idle: Fix NULL pointer dereference in hotplug path
In reply to Sasha LevinFrom: Huisong Li <[email protected]>
[ Upstream commit 47e6a863a88034be102bde11197f2ca1bc18cbaf ]
A cpuidle_device might fail to register during boot, but the system can continue to run. In such cases, acpi_processor_hotplug() can trigger a NULL pointer dereference when accessing the per-cpu acpi_cpuidle_device.
So add NULL pointer check for the per-cpu acpi_cpuidle_device in acpi_processor_hotplug.
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed. Let me compile the complete analysis.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: Subject Line**
- Subsystem: ACPI: processor: idle
- Action verb: "Fix"
- Summary: Fix NULL pointer dereference in hotplug path
- Record: [ACPI/processor/idle] [Fix] [NULL pointer dereference in CPU hotplug when cpuidle_device failed to register]
**Step 1.2: Tags**
- Signed-off-by: Huisong Li <[email protected]> — author
- `Link:
https://patch.msgid.link/[email protected]`
— lore reference
- Signed-off-by: Rafael J. Wysocki <[email protected]> — ACPI maintainer applied it
- No Fixes: tag, no Reported-by, no Tested-by, no Cc: stable
- Record: Single patch, accepted by subsystem maintainer Rafael J. Wysocki. No Fixes: tag (expected for review candidates).
**Step 1.3: Commit Body**
- Bug: cpuidle_device registration can fail during boot, but the system continues running. When acpi_processor_hotplug() is later invoked (CPU soft online), it accesses the per-cpu acpi_cpuidle_device which may be NULL.
- Symptom: NULL pointer dereference.
- Root cause: Missing NULL check for per-cpu device before use.
**Step 1.4: Hidden Bug Fix?**
- Commit uses explicit "Fix" in subject — straightforward.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: Inventory**
- 1 file modified: drivers/acpi/processor_idle.c
- Net: 1 line added, 3 removed (minor restructuring)
- Function modified: acpi_processor_hotplug()
- Scope: Single-function surgical fix.
**Step 2.2: Code Flow Change**
BEFORE:
```c
int ret = 0;
struct cpuidle_device *dev;
...
if (!pr->flags.power_setup_done)
return -ENODEV;
dev = per_cpu(acpi_cpuidle_device, pr->id);
cpuidle_pause_and_lock();
cpuidle_disable_device(dev); // dev could be NULL
```AFTER:
```c
struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id);
int ret = 0;
...
if (!pr->flags.power_setup_done || !dev)
return -ENODEV;
cpuidle_pause_and_lock();
cpuidle_disable_device(dev); // dev guaranteed non-NULL
```The fix moves the dev assignment before the check and adds || !dev to the early return.
**Step 2.3: Bug Mechanism**
This is a **NULL pointer dereference fix** (defensive). The per-cpu acpi_cpuidle_device can be NULL when:
1. acpi_processor_power_init() sets power_setup_done = 1
2. cpuidle_register_device() then fails
3. The memory leak fix (11b3de1c03fa9, Jul 2025) sets per_cpu(acpi_cpuidle_device, pr->id) = NULL
**Step 2.4: Fix Quality**
Important nuance discovered through deep analysis: The three callee functions currently DO handle NULL dev:
- cpuidle_disable_device(NULL) → returns via if (!dev || !dev->enabled) (since 2012)
- acpi_processor_setup_cpuidle_dev(pr, NULL) → returns via if (!dev) (since 2016)
- cpuidle_enable_device(NULL) → returns -EINVAL via if (!dev) (since 2012)
So there is no actual kernel crash in practice. However, the fix:
- Prevents unnecessary cpuidle_pause_and_lock() / cpuidle_resume_and_unlock() (global mutex)
- Prevents acpi_processor_get_power_info() from needlessly modifying processor flags
- Makes the code correct at the right abstraction level rather than relying on callee guards
- Zero regression risk
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: Blame**
- acpi_processor_hotplug() core structure: Len Brown, 2007 (4f86d3a8e29720)
- Per-cpu device usage: Wei Yongjun, 2012 (e8b1b59dc8e42a)
- Per-cpu variable introduced: Daniel Lezcano, 2012 (3d339dcbb56d)
- The code exists in ALL stable trees.
**Step 3.2: Fixes Tag**
No Fixes: tag present. However, the root cause path was created by 11b3de1c03fa9 ("Fix memory leak when register cpuidle device failed", Jul 2025) by the SAME author (Huisong Li). That commit has `Fixes:
3d339dcbb56d` (2012), so it likely went to all active stable trees. This fix is a necessary companion to the memory leak fix.
**Step 3.3: File History**
The file has had significant recent activity from Huisong Li (a series of cleanups/refactors accepted into 6.19/7.0). The hotplug function itself has been stable since 2012.
**Step 3.4: Author**
Huisong Li is an active contributor to ACPI processor idle code, having submitted 10+ patches to this file. He is the same author who introduced the memory leak fix that created the condition for this bug.
**Step 3.5: Dependencies**
No dependencies. The fix is self-contained and touches only the acpi_processor_hotplug() function, which is identical in stable trees.
## PHASE 4: MAILING LIST RESEARCH
**Step 4.1-4.5:** Lore was not accessible due to anti-scraping protection. b4 dig did not find a match. The commit's Link: tag references [email protected]. The patch was accepted directly by Rafael J. Wysocki (ACPI maintainer). No NAKs or concerns are evident from the acceptance.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1:** Function modified: acpi_processor_hotplug()
**Step 5.2: Callers**
- acpi_processor_soft_online() in drivers/acpi/processor_driver.c line 124
- Called during CPU soft online events (hotplug path)
- Return value is IGNORED by the caller
**Step 5.3-5.4: Call Chain**
CPU hotplug → acpi_processor_soft_online() → acpi_processor_hotplug() → cpuidle lock/disable/enable This is a system-level path triggered during CPU online/offline operations on ACPI systems.
**Step 5.5: Similar Patterns** acpi_processor_power_state_has_changed() (lines 1322-1344) has the same pattern — uses per_cpu(acpi_cpuidle_device, cpu) without NULL check. The fix does NOT address this function, but it has an additional !_pr->flags.power_setup_done guard that may be sufficient.
## PHASE 6: STABLE TREE ANALYSIS
**Step 6.1:** The buggy code (the acpi_processor_hotplug() function with per-cpu device) exists in ALL active stable trees since 2012 (3d339dcbb56d). The NULL condition was introduced by 11b3de1c03fa9 (Jul 2025), which has a Fixes: tag targeting 2012, so it was very likely backported to stable.
**Step 6.2:** The patch should apply cleanly to stable trees — the function has been stable since 2012.
**Step 6.3:** No other fix for this specific issue found.
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1:** Subsystem: ACPI processor idle (drivers/acpi/).
Criticality: IMPORTANT — affects all x86/ARM ACPI systems.
**Step 7.2:** Active subsystem with recent refactoring by the same author.
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1:** Affected: All ACPI systems where cpuidle device registration fails during boot.
**Step 8.2:** Trigger: CPU hotplug (online/offline) after boot failure of cpuidle device registration. This is not common but can happen on real hardware.
**Step 8.3:** Severity: The callee functions currently handle NULL, so no actual crash. However, the fix prevents unnecessary mutex acquisition, state flag modifications, and returns a clean error.
Severity: **LOW-MEDIUM** (defensive fix preventing potential issues).
**Step 8.4: Risk-Benefit**
- BENEFIT: Prevents unnecessary lock operations, incorrect state modifications, and makes code robust against future changes. If callee NULL guards are ever removed, this prevents a kernel crash.
- RISK: Essentially zero — adds a NULL check to an early return path.
- Ratio: Favorable for backport.
## PHASE 9: FINAL SYNTHESIS
**Evidence FOR backporting:**
- Small, surgical fix (3 lines, single function)
- Obviously correct — adds a NULL check
- Zero regression risk
- Accepted by ACPI subsystem maintainer (Rafael J. Wysocki)
- Companion fix to 11b3de1c03fa9 (memory leak fix) which likely went to stable
- Prevents unnecessary global mutex lock/unlock on error path
- Prevents incorrect state modifications via acpi_processor_get_power_info()
- Makes code robust against future callee changes
- Affects ACPI systems (wide user base)
- Applies cleanly to stable trees
**Evidence AGAINST backporting:**
- No actual NULL pointer dereference crash in current code (callee functions handle NULL)
- The commit message overstates the issue ("NULL pointer dereference")
- No Reported-by indicating anyone hit this in practice
- No Fixes: tag
**Stable Rules Checklist:**
1. Obviously correct and tested? **YES**
2. Fixes a real bug? **BORDERLINE** — prevents unnecessary/incorrect operations when dev is NULL; defensive against future callee changes
3. Important issue? **LOW-MEDIUM** — no crash, but prevents incorrect behavior
4. Small and contained? **YES** (3 lines, 1 function)
5. No new features? **Correct**
6. Can apply to stable? **YES** — function is identical in stable trees
## Verification
- [Phase 2] Diff analysis: moves dev assignment before checks, adds || !dev to early return — 3 net line changes in single function
- [Phase 2] Verified all three callee functions handle NULL:
cpuidle_disable_device (cf31cd1a0c, 2012), cpuidle_enable_device (1b0a0e9a15b9, 2012), cpuidle_get_cpu_driver (bf4d1b5ddb78, 2012), acpi_processor_setup_cpuidle_dev (a36a7fecfe60, 2016)
- [Phase 3] git blame: acpi_processor_hotplug() from Len Brown 2007, per-cpu dev from Wei Yongjun 2012
- [Phase 3] Found 11b3de1c03fa9 (Jul 2025, same author) — memory leak fix that introduced the NULL condition; has Fixes: 3d339dcbb56d targeting 2012
- [Phase 3] Original 2016 function (a36a7fecfe6071) already had !dev guard in acpi_processor_setup_cpuidle_dev
- [Phase 3] Caller acpi_processor_soft_online() ignores return value (line 124 of processor_driver.c)
- [Phase 4] b4 dig: no match found; lore blocked by anti-scraping
- [Phase 5] grep callers: single caller in processor_driver.c during CPU soft online
- [Phase 6] The acpi_processor_hotplug() function is identical in stable trees (unchanged since 2012)
- UNVERIFIED: Whether 11b3de1c03fa9 was actually backported to stable (but likely, given its Fixes: tag)
- UNVERIFIED: Full mailing list discussion (lore inaccessible)
## Decision
The fix is small (3 lines), obviously correct, has zero regression risk, and was accepted by the ACPI maintainer. While the actual NULL pointer dereference doesn't manifest as a crash due to existing callee guards, the fix properly handles the error condition at the right level — preventing unnecessary global mutex operations and incorrect state modifications when dev is NULL. It is a necessary companion to the memory leak fix 11b3de1c03fa9 which likely went to stable. The fix applies cleanly to all stable trees.
**YES**
drivers/acpi/processor_idle.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/acpi/processor_idle.c +2 -3
@@ -1275,16 +1275,15 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)int acpi_processor_hotplug (struct acpi_processor *pr) { +struct cpuidle_device *dev =per_cpu (acpi_cpuidle_device, pr->id);int ret =0 ; -struct cpuidle_device *dev;if (disabled_by_idle_boot_param ())return 0 ; -if (!pr->flags.power_setup_done) +if (!pr->flags.power_setup_done || !dev)return -ENODEV ; - dev =per_cpu (acpi_cpuidle_device, pr->id);cpuidle_pause_and_lock ();cpuidle_disable_device (dev); ret =acpi_processor_get_power_info (pr);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ppp: disconnect channel before nullifying pch->chan
In reply to Sasha LevinFrom: Qingfang Deng <[email protected]>
[ Upstream commit 6a196e83a1a7e50be93482d1cd4305641f1a9fb1 ]
In ppp_unregister_channel(), pch->chan is set to NULL before calling ppp_disconnect_channel(), which removes the channel from ppp->channels list using list_del_rcu() + synchronize_net(). This creates an intermediate state where the channel is still connected (on the list) but already unregistered (pch->chan == NULL).
Call ppp_disconnect_channel() before setting pch->chan to NULL. After the synchronize_net(), no new reader on the transmit path will hold a reference to the channel from the list.
This eliminates the problematic state, and prepares for removing the pch->chan NULL checks from the transmit path in a subsequent patch.
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed. Let me compile the complete analysis.
---
## Phase 1: Commit Message Forensics
### Step 1.1: Subject Line
- **Subsystem**: ppp (PPP networking subsystem)
- **Action verb**: "disconnect" / implied "fix" - reorder operations to eliminate a race
- **Summary**: Reorder ppp_disconnect_channel() and pch->chan = NULL to eliminate a problematic intermediate state
### Step 1.2: Tags
- **Signed-off-by**: Qingfang Deng (author, active PPP contributor with 9+ commits to the subsystem)
- **Link**:
https://patch.msgid.link/[email protected] (the -1- suggests a single patch, not a series)
- **Signed-off-by**: Paolo Abeni (netdev co-maintainer, merge authority)
- No Fixes: tag (expected - that's why it's under review)
- No Reported-by (no explicit crash report)
### Step 1.3: Body Analysis
The commit describes a concrete race condition: pch->chan is set to NULL before ppp_disconnect_channel() removes the channel from ppp->channels. This creates an intermediate state where the channel is still on the list but already has pch->chan == NULL. The fix reorders the operations: disconnect first (remove from list), then NULL-ify.
### Step 1.4: Hidden Bug Fix Detection
The phrase "This eliminates the problematic state" clearly describes fixing a race condition. The mention of "prepares for removing the pch->chan NULL checks from the transmit path in a subsequent patch" suggests a follow-up cleanup, but the reordering itself has standalone correctness value.
**Record**: This IS a race condition fix, disguised slightly by the preparatory framing.
---
## Phase 2: Diff Analysis
### Step 2.1: Inventory
- **1 file changed**: drivers/net/ppp/ppp_generic.c
- **Net change**: 0 lines added, 0 removed - purely a reorder of one line
- **Function modified**: ppp_unregister_channel()
- **Scope**: single-file, single-function, surgical
### Step 2.2: Code Flow Change
**Before**: In ppp_unregister_channel():
1. down_write(&pch->chan_sem) + spin_lock_bh(&pch->downl) + WRITE_ONCE(pch->chan, NULL) + unlock
2. ppp_disconnect_channel(pch) - removes from ppp->channels via list_del_rcu() + synchronize_net()
**After**:
1. ppp_disconnect_channel(pch) - removes from list first
2. down_write(&pch->chan_sem) + spin_lock_bh(&pch->downl) + WRITE_ONCE(pch->chan, NULL) + unlock
### Step 2.3: Bug Mechanism - RACE CONDITION / NULL POINTER DEREFERENCE
The race occurs in ppp_mp_explode() (multilink transmit path):
```1977:2001:drivers/net/ppp/ppp_generic.c
list_for_each_entry(pch, &ppp->channels, clist) {
if (pch->chan) { // Read #1 - no downl lock held
pch->avail = 1;
navail++;
pch->speed = pch->chan->speed; // Read #2 - TOCTOU: pch->chan
can be NULL here!
}
```**Race scenario**:
1. CPU A (ppp_mp_explode, under ppp_xmit_lock): reads pch->chan != NULL at line 1978
2. CPU B (ppp_unregister_channel): does WRITE_ONCE(pch->chan, NULL) under downl (NOT under ppp_xmit_lock)
3. CPU A: dereferences pch->chan->speed at line 1981 - **NULL pointer dereference / kernel oops**
The channel is still on ppp->channels (hasn't been disconnected yet), so ppp_mp_explode finds it while iterating.
With the fix, ppp_disconnect_channel() removes the channel from the list (under ppp_lock, which includes ppp_xmit_lock) FIRST. After it returns, no transmit code iterating ppp->channels will see this channel. Then setting pch->chan = NULL is safe.
### Step 2.4: Fix Quality
- Obviously correct - eliminates the problematic state entirely
- Minimal/surgical - one line moved
- No regression risk - the semantic operations are the same, just reordered
- No API changes, no locking changes, no new features
---
## Phase 3: Git History Investigation
### Step 3.1: Blame
From git blame, the buggy code ordering dates back to ^1da177e4c3f41 (Linus Torvalds, 2005-04-16) - the initial kernel tree import. The WRITE_ONCE was added by 0417adf367a0af (August 2025), but the fundamental ordering issue exists since v2.6.12.
### Step 3.2: No Fixes: tag (expected)
### Step 3.3: Related Changes
The same author (Qingfang Deng) previously fixed a related race in 0417adf367a0af ("ppp: fix race conditions in ppp_fill_forward_path"), which explicitly documented: "pch->chan can be NULL. When ppp_unregister_channel() is called, pch->chan is set to NULL before pch is removed from ppp->channels." That commit added workarounds (NULL checks, RCU). This commit fixes the **root cause**.
### Step 3.4: Author
Qingfang Deng has 9+ PPP commits, including critical race fixes and performance improvements. They are a de facto domain expert for this code.
### Step 3.5: Dependencies
The diff references WRITE_ONCE(pch->chan, NULL) which was introduced by 0417adf367a0af. That commit has Fixes: f6efc675c9dd and was likely already auto-selected for stable. For trees without that commit, a trivial context adjustment (pch->chan = NULL instead of WRITE_ONCE) would be needed. The reordering logic works correctly regardless.
---
## Phase 4: Mailing List Research
### Step 4.1-4.2
Lore is currently blocked by Anubis anti-bot protection. b4 dig could not find this specific commit by message-id (the commit doesn't exist in this tree). However, the patch was accepted and merged by Paolo Abeni, netdev co-maintainer, which provides strong confidence in correctness.
### Step 4.3-4.5
The earlier commit 0417adf367a0af explicitly documents the bug that this commit fixes at the root: "pch->chan can be NULL. When ppp_unregister_channel() is called, pch->chan is set to NULL before pch is removed from ppp->channels." This was a known problem.
---
## Phase 5: Code Semantic Analysis
### Step 5.1-5.4: Call Path Tracing
The vulnerable function ppp_mp_explode() is called from:
- ppp_push() -> ppp_send_frame() -> __ppp_xmit_process() -> ppp_xmit_process()
This is the **hot transmit path** for PPP multilink, triggered every time a packet is sent on a multilink PPP connection. The race triggers when a channel is unregistered while multilink transmission is active - a common scenario during PPP session teardown or link failure.
ppp_fill_forward_path() (already patched with NULL checks by 0417adf367a0af) is also affected but has workarounds. This commit fixes the root cause for all paths.
### Step 5.5: Similar Patterns
The same TOCTOU pattern (check pch->chan, then dereference) also appears at:
- Line 1978/1981: ppp_mp_explode() - **vulnerable** (no downl lock)
- Line 1912-1914: ppp_push() - **safe** (holds pch->downl)
- Line 2059-2060: ppp_mp_explode() phase 2 - **safe** (holds pch->downl)
- Line 2185-2189: __ppp_channel_push() - **safe** (holds pch->downl)
---
## Phase 6: Stable Tree Analysis
### Step 6.1: Buggy Code in Stable
The buggy ordering exists since v2.6.12 (the very first git commit). It is present in ALL active stable trees.
### Step 6.2: Backport Complications
For 7.0.y: applies cleanly (code matches exactly).
For older trees without 0417adf367a0af: trivial context change needed (pch->chan = NULL vs WRITE_ONCE(pch->chan, NULL)), and list_del_rcu/synchronize_net() may not be present in ppp_disconnect_channel(). However, the reordering is still correct for the transmit path because ppp_disconnect_channel() takes ppp_lock() (which includes ppp_xmit_lock), ensuring mutual exclusion with transmit path iteration.
### Step 6.3: Related Fixes0417adf367a0af added workarounds (NULL checks) for the same underlying issue. This commit fixes the root cause.
---
## Phase 7: Subsystem Context
### Step 7.1: PPP networking - **IMPORTANT** subsystem PPP is used by DSL/dial-up connections, VPN tunnels, and embedded/routing devices. Multilink PPP aggregates multiple physical links, common in WAN/enterprise networking.
### Step 7.2: Actively maintained by the author (9+ commits), merged by netdev maintainers.
---
## Phase 8: Impact and Risk Assessment
### Step 8.1: Affected Users
Users running PPP with multilink (SC_MULTILINK flag set). This includes enterprise WAN, embedded networking, and PPPoE configurations.
### Step 8.2: Trigger Conditions
- Multilink PPP transmitting while a channel is being unregistered
- Happens during link failure, session teardown, or module unload
- A timing-dependent race, but the window exists every time a channel is unregistered during active multilink transmission
### Step 8.3: Failure Mode
**NULL pointer dereference** at pch->chan->speed -> kernel oops/crash.
Severity: **HIGH** (kernel crash, potential data loss from interrupted operations).
### Step 8.4: Risk-Benefit Ratio
- **Benefit**: HIGH - prevents kernel crash in PPP multilink transmit path
- **Risk**: VERY LOW - moving one line, no semantic change, obviously correct
- **Ratio**: Strongly favorable
---
## Phase 9: Final Synthesis
### Step 9.1: Evidence
**FOR backporting**:
- Fixes a real NULL pointer dereference race condition
- The race exists since v2.6.12 (all stable trees affected)
- Extremely small change (1 line moved)
- Obviously correct - eliminates invalid intermediate state
- Author is a domain expert (9+ PPP commits)
- Accepted by netdev co-maintainer
- The same root cause was already documented by the earlier fix (0417adf367a0af)
- PPP multilink is a commonly used feature
**AGAINST backporting**:
- No crash report or syzbot reproduction (theoretical race, but realistic trigger)
- Commit message mentions "prepares for" a subsequent patch (partially preparatory)
- No Fixes: tag (expected)
### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **YES** - merged by Paolo Abeni
2. Fixes a real bug? **YES** - NULL deref race in multilink transmit
3. Important issue? **YES** - kernel crash (NULL pointer deref)
4. Small and contained? **YES** - 1 line moved in 1 function
5. No new features/APIs? **YES** - pure reorder
6. Applies to stable? **YES** - cleanly to 7.0.y
### Step 9.3: Exception Categories
Not an exception category - this is a standard race condition fix.
---
## Verification
- [Phase 1] Parsed tags: Signed-off-by author (Qingfang Deng) + maintainer (Paolo Abeni), Link to patch
- [Phase 2] Diff analysis: 1 line moved in ppp_unregister_channel(), reordering ppp_disconnect_channel() before WRITE_ONCE(pch->chan, NULL)
- [Phase 2] Verified TOCTOU in ppp_mp_explode() lines 1978/1981: reads pch->chan without downl lock
- [Phase 3] git blame: buggy ordering from ^1da177e4c3f41 (Linus Torvalds, 2005) - present in all stable trees
- [Phase 3] Related commit 0417adf367a0af explicitly documents this same race condition as known bug
- [Phase 3] Author has 9 commits to drivers/net/ppp/ - domain expert
- [Phase 4] Lore blocked by Anubis; could not verify mailing list discussion directly
- [Phase 5] Traced call chain: ppp_xmit_process -> __ppp_xmit_process -> ppp_push -> ppp_mp_explode - hot transmit path under ppp_xmit_lock
- [Phase 5] Verified ppp_disconnect_channel() takes ppp_lock() (includes ppp_xmit_lock) - mutual exclusion with transmit path
- [Phase 5] Verified WRITE_ONCE(pch->chan, NULL) is under chan_sem+downl only, NOT ppp_xmit_lock - confirms race window
- [Phase 6] Code exists in all active stable trees since v2.6.12
- [Phase 6] Patch applies cleanly to 7.0.y; older trees need trivial context adjustment
- [Phase 8] Failure mode: NULL pointer dereference -> kernel oops, severity HIGH
- UNVERIFIED: Could not access lore.kernel.org to verify if stable was requested by a reviewer
The fix is a minimal, obviously correct reordering that eliminates a real NULL pointer dereference race condition in the PPP multilink transmit path. The bug has existed since the original kernel tree and affects all stable trees. The risk is negligible (one line moved) and the benefit is preventing a kernel crash.
**YES**
drivers/net/ppp/ppp_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ppp/ppp_generic.c +1 -1
@@ -3023,12 +3023,12 @@ ppp_unregister_channel(struct ppp_channel *chan)* This ensures that we have returned from any calls into * the channel's start_xmit or ioctl routine before we proceed. */ +ppp_disconnect_channel (pch);down_write (&pch->chan_sem);spin_lock_bh (&pch->downl);WRITE_ONCE (pch->chan,NULL );spin_unlock_bh (&pch->downl);up_write (&pch->chan_sem); -ppp_disconnect_channel (pch); pn =ppp_pernet (pch->chan_net);spin_lock_bh (&pn->all_channels_lock);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 wifi: iwlwifi: mvm: zero iwl_geo_tx_power_profiles_cmd before sending
In reply to Sasha LevinFrom: Emmanuel Grumbach <[email protected]>
[ Upstream commit 5562b3bbeede8be25092064720e4a942e9fd3e3e ]
Otherwise we may send garbage.
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed for a thorough analysis. Let me compile it.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: Subject Line
- **Subsystem**: wifi: iwlwifi: mvm
- **Action verb**: "zero" (initialization fix)
- **Summary**: Zero-initialize iwl_geo_tx_power_profiles_cmd union before sending to firmware
### Step 1.2: Tags
- **Signed-off-by**: Emmanuel Grumbach (author, Intel iwlwifi core developer)
- **Reviewed-by**: Johannes Berg (iwlwifi/mac80211 subsystem maintainer
- strong trust signal)
- **Signed-off-by**: Miri Korenblit (Intel wireless maintainer, committer)
- **Link**: patch.msgid.link for the original submission
- No Fixes: tag (expected for AUTOSEL candidates)
- No Cc: stable (expected)
### Step 1.3: Commit Body
- "Otherwise we may send garbage." - Clear and direct. The union is stack-allocated and not zero-initialized, so whatever stack data happens to be there gets sent to the firmware.
### Step 1.4: Hidden Bug Fix?
- YES. The word "zero" and "= {}" pattern is a classic **uninitialized data fix**. Sending uninitialized stack data to firmware hardware is a real bug: potential information leak and potential firmware misbehavior.
---
## PHASE 2: DIFF ANALYSIS
### Step 2.1: Inventory
- **1 file changed**: drivers/net/wireless/intel/iwlwifi/mvm/fw.c
- **2 lines changed** (2 additions, 2 removals)
- **Functions modified**: iwl_mvm_get_sar_geo_profile(), iwl_mvm_sar_geo_init()
- **Scope**: Extremely minimal, single-file surgical fix
### Step 2.2: Code Flow
Two identical changes:
- Line 910: union iwl_geo_tx_power_profiles_cmd geo_tx_cmd; → ... geo_tx_cmd = {};
- Line 962: union iwl_geo_tx_power_profiles_cmd cmd; → ... cmd = {};
Both change stack-allocated union variables from uninitialized to zero- initialized.
### Step 2.3: Bug Mechanism
This is an **uninitialized data** bug (category e: initialization fixes).
The union iwl_geo_tx_power_profiles_cmd contains 5 struct variants (v1-v5) of different sizes. The union is the size of the largest (v5), which contains table[8][3] of iwl_per_chain_offset structs plus ops and table_revision. This is a substantial structure.
In iwl_mvm_get_sar_geo_profile():
- Only geo_tx_cmd.v1.ops is explicitly set
- Then len bytes (up to sizeof(geo_tx_cmd.v5)) are sent to firmware
- All table and table_revision fields are **uninitialized stack garbage** being sent to firmware
In iwl_mvm_sar_geo_init():
- ops, table_revision, and table contents are filled, but any padding within the structure or unused bytes remain uninitialized
### Step 2.4: Fix Quality
- **Obviously correct**: = {} is the standard C idiom for zero- initialization
- **Minimal/surgical**: 2 lines changed, only adding initialization
- **Regression risk**: Zero. Zero-initializing before populating fields cannot break anything.
- The newer mld/regulatory.c code already uses = {} initialization (line 76), confirming this is the correct pattern.
---
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: Blame
The uninitialized declarations were introduced in commit dd2a1256e6a8d8 ("iwlwifi: acpi: rename geo structs to contain versioning") from **2020-09-28**, which restructured these commands into a union. The bug has existed since then.
### Step 3.2: Fixes Tag
No Fixes: tag present (expected for AUTOSEL). The bug was introduced by dd2a1256e6a8d8 which is present in v5.10, v5.15, v6.1, v6.6, and all later stable trees.
### Step 3.3: File History
The file has significant recent activity (196 commits since the buggy commit). The newer mld/regulatory.c equivalent already uses zero- initialization, confirming the pattern was eventually corrected in newer code but the mvm/fw.c path was missed.
### Step 3.4: Author Context
Emmanuel Grumbach is a core Intel iwlwifi developer with many recent commits. Johannes Berg (who reviewed this) is the iwlwifi/mac80211 maintainer. This is a fix from the subsystem's core team.
### Step 3.5: Dependencies
This patch is **fully standalone**. It only adds = {} to existing variable declarations. No prerequisite commits needed.
---
## PHASE 4: MAILING LIST RESEARCH
### Step 4.1: Original Submission
b4 dig found the patch at: https://patch.msgid.link/20260319204647.2d49 4b0f4692.I9afd0fa6b2ea5a27118144ac4e3bbbedc2089c10@changeid
It was submitted as **[PATCH iwlwifi-next 03/15]** as part of a 15-patch series. However, this patch is **completely independent** - it's just a variable initialization change.
### Step 4.2: Reviewers
- Johannes Berg (iwlwifi maintainer) gave **Reviewed-by**
- [email protected] was CC'd
### Step 4.3-4.5: Bug Report / Related Patches / Stable Discussion No explicit bug report or stable discussion found. The bug was found by code inspection by an Intel developer.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1-5.2: Function Callers
- iwl_mvm_get_sar_geo_profile(): Called from debugfs.c (debugfs handler) and nvm.c (NVM/regulatory init)
- iwl_mvm_sar_geo_init(): Called from main firmware init path at line 1735 during iwl_mvm_up() - this runs on **every iwlwifi device initialization**
### Step 5.4: Reachabilityiwl_mvm_sar_geo_init runs during driver initialization for every Intel WiFi device using the MVM firmware path. This is a **hot, commonly- executed path** affecting every Intel WiFi user.
---
## PHASE 6: STABLE TREE ANALYSIS
### Step 6.1: Buggy Code in Stable
The buggy commit dd2a1256e6a8d8 is confirmed present in:
- v5.10 ✓
- v5.15 ✓
- v6.1 ✓
- v6.6 ✓
The bug affects **all active stable trees**.
### Step 6.2: Backport Complications
The fix is trivial (adding = {} to declarations). The only concern is whether the variable declarations exist identically in stable trees. Since these are the same variable names in the same functions and the union type hasn't changed names, this should apply cleanly or with trivial adjustment.
---
## PHASE 7: SUBSYSTEM CONTEXT
### Step 7.1: Subsystem
- **Subsystem**: Wireless networking driver (iwlwifi) - Intel WiFi
- **Criticality**: IMPORTANT - iwlwifi is one of the most widely used WiFi drivers, found in most Intel-based laptops
### Step 7.2: Activity
Very actively developed (20+ recent commits shown in file history).
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: Who Is Affected
All users with Intel WiFi hardware using iwlwifi MVM firmware (millions of laptops and desktops).
### Step 8.2: Trigger Conditions
- iwl_mvm_sar_geo_init: Triggered on **every driver initialization** (boot, resume, WiFi toggle)
- iwl_mvm_get_sar_geo_profile: Triggered from debugfs and NVM init
### Step 8.3: Failure Mode Severity
- **Uninitialized kernel stack data sent to firmware**: This is a potential kernel info leak to firmware
- **Firmware misbehavior**: If firmware interprets garbage values in the table/revision fields, it could misapply TX power settings (regulatory compliance issue) or behave unpredictably
- **Severity**: MEDIUM-HIGH (info leak + potential incorrect radio behavior)
### Step 8.4: Risk-Benefit
- **Benefit**: HIGH - fixes uninitialized data being sent to firmware on every Intel WiFi init
- **Risk**: VERY LOW - 2 lines, = {} is the safest possible change
- **Ratio**: Strongly favorable for backport
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: Evidence Compilation
**FOR backporting:**
- Fixes a real bug: uninitialized kernel stack data sent to WiFi firmware
- Extremely minimal fix (2 lines, = {} only)
- Obviously correct - zero-initialization is the standard pattern
- Reviewed by iwlwifi maintainer (Johannes Berg)
- Written by core Intel iwlwifi developer
- Bug present in all active stable trees (since v5.10)
- Affects all Intel WiFi users (common hardware)
- Triggered on every driver initialization
- No regression risk whatsoever
- Standalone fix with zero dependencies
- The newer MLD code path already uses this pattern
**AGAINST backporting:**
- No user-visible crash or panic reported (the firmware likely tolerates the garbage in many cases)
- No Fixes: tag, no syzbot report
### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **YES** - = {} is trivially correct, reviewed by maintainer
2. Fixes a real bug? **YES** - uninitialized data sent to firmware hardware
3. Important issue? **YES** - info leak + potential firmware misbehavior on common hardware
4. Small and contained? **YES** - 2 lines in 1 file
5. No new features or APIs? **YES** - no new functionality
6. Can apply to stable? **YES** - trivial change to variable declarations
### Step 9.3: Exception Categories
Not an exception category; this is a standard initialization bug fix.
---
## Verification
- [Phase 1] Parsed all tags: Reviewed-by Johannes Berg (iwlwifi maintainer), author is Emmanuel Grumbach (Intel iwlwifi developer)
- [Phase 2] Diff analysis: exactly 2 lines changed - both add = {} to union variable declarations in iwl_mvm_get_sar_geo_profile() and iwl_mvm_sar_geo_init()
- [Phase 3] git blame: buggy code introduced in commit dd2a1256e6a8d8 (2020-09-28), present since v5.10
- [Phase 3] git merge-base: confirmed dd2a1256e6a8d8 is in v5.10, v5.15, v6.1, v6.6
- [Phase 3] No prerequisite commits needed - fix is standalone
- [Phase 4] b4 dig -c: found original submission at lore, patch 3/15 of iwlwifi-next series
- [Phase 4] b4 dig -w: reviewed by Johannes Berg, CC'd to linux-wireless
- [Phase 5] Callers traced: iwl_mvm_sar_geo_init called from main init path (iwl_mvm_up); iwl_mvm_get_sar_geo_profile called from debugfs and NVM init
- [Phase 5] Confirmed newer mld/regulatory.c line 76 already uses = {} pattern for same union type
- [Phase 6] Buggy code exists in all active stable trees (v5.10+)
- [Phase 6] Fix should apply cleanly or with trivial adjustment
- [Phase 8] Impact: all Intel WiFi users; triggered on every driver init; severity MEDIUM-HIGH (info leak + potential firmware misbehavior)
The fix is a textbook example of an uninitialized data bug fix: minimal, obviously correct, zero regression risk, affects widely-used hardware, and has been reviewed by the subsystem maintainer.
**YES**
drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/fw.c +2 -2
@@ -907,7 +907,7 @@ int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b)int iwl_mvm_get_sar_geo_profile (struct iwl_mvm *mvm) { -union iwl_geo_tx_power_profiles_cmd geo_tx_cmd; +union iwl_geo_tx_power_profiles_cmd geo_tx_cmd = {};struct iwl_geo_tx_power_profiles_resp *resp;u16 len;int ret;
@@ -959,7 +959,7 @@ int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm)static int iwl_mvm_sar_geo_init (struct iwl_mvm *mvm) {u32 cmd_id =WIDE_ID (PHY_OPS_GROUP ,PER_CHAIN_LIMIT_OFFSET_CMD ); -union iwl_geo_tx_power_profiles_cmd cmd; +union iwl_geo_tx_power_profiles_cmd cmd = {};u16 len;u32 n_bands;u32 n_profiles;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ALSA: pcm: Serialize snd_pcm_suspend_all() with open_mutex
In reply to Sasha LevinFrom: Cássio Gabriel <[email protected]>
[ Upstream commit 1a56641b7ae4f19216774a59d68024be3e6197d0 ]
snd_pcm_suspend_all() walks all PCM substreams and uses a lockless runtime check to skip closed streams. It then calls snd_pcm_suspend() for each remaining substream and finally runs snd_pcm_sync_stop() in a second pass.
The runtime lifetime is still controlled by pcm->open_mutex in the open/release path. That means a concurrent close can clear or free substream->runtime after the initial check in snd_pcm_suspend_all(), leaving the later suspend or sync-stop path to dereference a stale or NULL runtime pointer.
Serialize snd_pcm_suspend_all() with pcm->open_mutex so the runtime pointer stays stable across both loops. This matches the existing PCM runtime lifetime rule already used by other core paths that access substream->runtime outside the stream lock.
---
LLM Generated explanations, may be completely bogus:
Here is my complete analysis:
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: Subject Line
- **Subsystem**: ALSA: pcm: (ALSA PCM core)
- **Action verb**: "Serialize" — implies fixing a synchronization issue (race condition)
- **Summary**: Serialize snd_pcm_suspend_all() with open_mutex to prevent concurrent access
Record: [ALSA PCM core] [Serialize] [Add mutex to prevent race between suspend and open/close]
### Step 1.2: Tags
- **Suggested-by: Takashi Iwai <[email protected]>** — Takashi Iwai is the ALSA subsystem maintainer. He suggested this fix, which carries enormous weight.
- **Signed-off-by: Takashi Iwai <[email protected]>** — Maintainer also signed off (committed it).
- **Signed-off-by: Cássio Gabriel** — Author of the patch.
- **Link:** to patch.msgid.link (v2 of the patch).
- No Fixes: tag, no Reported-by, no Cc: stable — expected for autosel candidates.
Record: Fix suggested and committed by the subsystem maintainer (Takashi Iwai). This is the highest trust signal possible.
### Step 1.3: Commit Body Analysis
The commit describes:
- **Bug**: snd_pcm_suspend_all() walks PCM substreams with a lockless runtime check, then calls snd_pcm_suspend() and snd_pcm_sync_stop(). A concurrent close can clear/free substream->runtime via the open/close path (which uses pcm->open_mutex).
- **Failure mode**: Stale or NULL runtime pointer dereference — crash/UAF.
- **Fix approach**: Take pcm->open_mutex in snd_pcm_suspend_all(), matching the existing PCM runtime lifetime rule.
Record: UAF/NULL deref race during system suspend. Author explains clear mechanism.
### Step 1.4: Hidden Bug Fix Detection
This is NOT hidden — it's an explicit race condition fix. The code itself had a /* FIXME: the open/close code should lock this as well */ comment acknowledging the bug.
---
## PHASE 2: DIFF ANALYSIS
### Step 2.1: Inventory
- **Files changed**: 1 (sound/core/pcm_native.c)
- **Lines**: +5 (including comment update), -1 (removing FIXME comment). Net functional change: +1 line (guard(mutex)(&pcm->open_mutex))
- **Functions modified**: snd_pcm_suspend_all()
- **Scope**: Single-file, single-function, surgical fix.
### Step 2.2: Code Flow Change
**Before**: snd_pcm_suspend_all() iterates substreams without any lock, checking substream->runtime and calling snd_pcm_suspend() / snd_pcm_sync_stop() unsynchronized with the open/close path.
**After**: guard(mutex)(&pcm->open_mutex) is taken at function entry, serializing the entire function with the release path (snd_pcm_release() at line 2941 holds open_mutex around snd_pcm_release_substream()).
### Step 2.3: Bug Mechanism
**Category**: Race condition / Use-After-Free / NULL pointer dereference
The race:
1. Thread A (snd_pcm_suspend_all): checks !substream->runtime → sees non-NULL
2. Thread B (snd_pcm_release): under open_mutex, calls snd_pcm_detach_substream() → sets substream->runtime = NULL → kfree(runtime) (confirmed in sound/core/pcm.c lines 980-1003)
3. Thread A: calls snd_pcm_suspend(substream) → dereferences freed/NULL runtime → **CRASH**
Second race window: the second loop calls snd_pcm_sync_stop() on ALL substreams, which accesses substream->runtime (line 641).
### Step 2.4: Fix Quality
- Obviously correct: takes the same mutex already used by open/close paths.
- Minimal: one functional line added.
- Regression risk: Very low. The open_mutex is not taken in interrupt context; snd_pcm_suspend() internally uses guard(pcm_stream_lock_irqsave) which is a different lock, so no deadlock risk. The mutex merely serializes with open/close.
---
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: Blame
The FIXME comment (/* FIXME: the open/close code should lock this as well */) was introduced in commit 8d19b4e0b377e2 (2021-02-06, "ALSA:
pcm: Use for_each_pcm_substream() macro") by Takashi Iwai himself. The core snd_pcm_suspend_all function dates back to 1da177e4c3f41 (Linus Torvalds, 2005-04-16, the initial Linux tree).
Record: The race has existed since v2.6.12 (original tree). It was made worse in v5.12 when snd_pcm_sync_stop loop was added (commit 2c87c1a49c9d). The FIXME was planted by the maintainer acknowledging the bug.
### Step 3.2: Fixes tag
No Fixes: tag present. The race effectively has existed since the beginning.
### Step 3.3: File History
Recent changes to pcm_native.c include guard()-based locking conversions and race fixes (e.g., 93a81ca065775 "Fix race of buffer access at PCM OSS layer"). This shows the subsystem is actively being hardened for concurrency.
### Step 3.4: Author
Cássio Gabriel has one other commit in the sound subsystem. However, the fix was **suggested by Takashi Iwai** (ALSA maintainer) and **committed by Takashi Iwai**, giving it the highest credibility.
### Step 3.5: Dependencies
The fix uses guard(mutex) which requires the cleanup.h infrastructure (available since v6.5) and the guard conversions in pcm_native.c (dd0da75b9a276, available since v6.12). For older stable trees, a trivial adaptation to mutex_lock/mutex_unlock would be needed.
---
## PHASE 4: MAILING LIST RESEARCH
### Step 4.1-4.2: Patch Discussion
b4 dig did not find the patch by commit hash (likely because this is on a v7.0 tree). The Link: tag points to patch.msgid.link, which redirected to lore.kernel.org but was blocked by anti-bot protection. However, the commit subject says "v2", indicating the patch went through at least two revisions. The maintainer (Takashi Iwai) suggested and committed the fix — the highest form of endorsement.
### Step 4.3-4.5: Bug Report and Stable History
No explicit bug report (no Reported-by:). This is a proactive fix based on code analysis (the FIXME comment). No prior stable discussion found.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1-5.2: Callers of snd_pcm_suspend_all
- sound/core/pcm.c:do_pcm_suspend() — PM callback, called during **system suspend**
- sound/soc/soc-core.c — ASoC suspend
- sound/hda/common/codec.c — HDA codec suspend
- sound/usb/usx2y/us144mkii.c — USB audio suspend
This is called on **every system suspend** for every PCM device. This means every laptop, desktop, or embedded system with audio is affected.
### Step 5.3-5.4: Call Chain
System suspend → do_pcm_suspend() → snd_pcm_suspend_all() → race with user-space closing audio fd → snd_pcm_release() → UAF/NULL deref.
Trigger: Closing a laptop lid while an audio application is running. This is an extremely common scenario.
---
## PHASE 6: STABLE TREE ANALYSIS
### Step 6.1: Buggy Code in Stable
The buggy code (unsynchronized runtime access in snd_pcm_suspend_all) has existed since v2.6.12. The snd_pcm_sync_stop second loop was added around v5.12. All active stable trees contain the buggy code.
### Step 6.2: Backport Complications
For v7.0 and v6.12+: should apply cleanly (same guard() infrastructure).
For v6.6 and older: would need trivial adaptation from guard(mutex) to mutex_lock/mutex_unlock.
---
## PHASE 7: SUBSYSTEM CONTEXT
### Step 7.1: Subsystem Criticality
- **Subsystem**: ALSA PCM core (sound/core/)
- **Criticality**: IMPORTANT — affects every system with audio hardware (virtually all Linux systems)
### Step 7.2: Activity
Very actively maintained by Takashi Iwai. Recent commits show ongoing concurrency hardening.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: Who Is Affected
Every Linux system with audio hardware (virtually universal).
### Step 8.2: Trigger Conditions
System suspend while an audio stream is being closed. This is a common scenario on laptops (lid close while music playing). The race window is between checking substream->runtime and using it — a narrow but real window.
### Step 8.3: Failure Mode Severity
NULL pointer dereference or use-after-free → **kernel oops/crash during suspend**. Severity: **CRITICAL**.
### Step 8.4: Risk-Benefit
- **Benefit**: HIGH — prevents kernel crash during suspend for all audio-capable systems
- **Risk**: VERY LOW — one functional line, uses existing mutex already employed by the open/close paths, no deadlock risk, suggested and committed by the subsystem maintainer
- **Ratio**: Strongly favorable
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: Evidence Summary
**FOR backporting:**
- Fixes a real race condition (UAF / NULL deref) acknowledged by a FIXME comment from the subsystem maintainer
- Fix was suggested and committed by Takashi Iwai (ALSA maintainer)
- Minimal change: 1 functional line added
- Affects every system with audio during system suspend
- Failure mode is kernel crash (CRITICAL severity)
- Uses existing locking infrastructure already in use by the same code paths
- Second revision (v2), showing review iteration
**AGAINST backporting:**
- No user-reported crash (proactive fix based on code analysis)
- May need minor adaptation for older stable trees (guard → mutex_lock/unlock)
### Step 9.2: Stable Rules Checklist
1. Obviously correct and tested? **YES** — suggested by maintainer, uses existing mutex pattern
2. Fixes a real bug? **YES** — race between suspend and release, FIXME acknowledged the issue
3. Important issue? **YES** — UAF/NULL deref → kernel crash during suspend
4. Small and contained? **YES** — 1 functional line in 1 function in 1 file
5. No new features or APIs? **YES** — pure synchronization fix
6. Can apply to stable? **YES** — clean for 6.12+, trivial adaptation for older
### Step 9.3: Exception Categories
Not an exception — this is a standard race condition fix, a core stable candidate.
### Step 9.4: Decision
This is a textbook stable fix: a single-line mutex acquisition that prevents a UAF/NULL deref race during system suspend, suggested and committed by the subsystem maintainer, fixing a longstanding FIXME.
---
## Verification
- [Phase 1] Parsed tags: Suggested-by and Signed-off-by from Takashi Iwai (ALSA maintainer)
- [Phase 2] Diff analysis: +1 functional line (guard(mutex)(&pcm->open_mutex)), removes 1-line FIXME comment
- [Phase 2] Verified snd_pcm_sync_stop() accesses substream->runtime at line 641 without lock
- [Phase 2] Verified snd_pcm_detach_substream() sets substream->runtime = NULL and kfree(runtime) at lines 997-1003 of sound/core/pcm.c
- [Phase 2] Verified snd_pcm_release() holds open_mutex around snd_pcm_release_substream() at line 2941
- [Phase 3] git blame: FIXME comment introduced by Takashi Iwai in 8d19b4e0b377e2 (2021-02-06), core function from 1da177e4c3f41 (2005)
- [Phase 3] snd_pcm_sync_stop loop added in 2c87c1a49c9d11 ("Assure sync with pending stop operation at suspend", 2021)
- [Phase 3] guard() infrastructure for pcm_native.c in dd0da75b9a276 (v6.12+)
- [Phase 4] b4 dig: did not find match (this is a v7.0 tree). Link: in commit points to v2 of the patch.
- [Phase 5] Callers: do_pcm_suspend() (PM callback), soc-core, HDA codec, USB audio — called on every system suspend
- [Phase 6] Buggy code present in all active stable trees (since v2.6.12)
- [Phase 7] ALSA PCM core — affects virtually all Linux systems with audio
- [Phase 8] Failure mode: NULL deref or UAF during system suspend → kernel crash (CRITICAL)
**YES**
sound/core/pcm_native.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/core/pcm_native.c +5 -1
@@ -1761,6 +1761,9 @@ static int snd_pcm_suspend(struct snd_pcm_substream *substream)* snd_pcm_suspend_all - trigger SUSPEND to all substreams in the given pcm * @pcm: the PCM instance * +* Takes and releases pcm->open_mutex to serialize against +* concurrent open/close while walking the substreams. +* * After this call, all streams are changed to SUSPENDED state. * * Return: Zero if successful (or @pcm is %NULL), or a negative error code.
@@ -1773,8 +1776,9 @@ int snd_pcm_suspend_all(struct snd_pcm *pcm)if (! pcm)return 0 ; +guard (mutex)(&pcm->open_mutex); +for_each_pcm_substream (pcm, stream, substream) { -/* FIXME: the open/close code should lock this as well */ if (!substream->runtime)continue ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 Bluetooth: hci_qca: disable power control for WCN7850 when bt_en is not defined
In reply to Sasha LevinFrom: Shuai Zhang <[email protected]>
[ Upstream commit 7b75867803a8712bdf7683c31d71d3d5e28ce821 ]
On platforms using an M.2 slot with both UART and USB support, bt_en is pulled high by hardware. In this case, software-based power control should be disabled. The current platforms are Lemans-EVK and Monaco-EVK.
Add QCA_WCN7850 to the existing condition so that power_ctrl_enabled is cleared when bt_en is not software-controlled (or absent), aligning its behavior with WCN6750 and WCN6855
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed for a complete analysis. Let me compile the results.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1:** [Subsystem: Bluetooth/hci_qca] [Action: "disable" / "add"] [Summary: Disable software power control for WCN7850 when bt_en GPIO is not defined (HW-managed)]
**Step 1.2:** Tags found:
- Signed-off-by: Shuai Zhang <[email protected]> - Author, Qualcomm BT developer
- Reviewed-by: Bartosz Golaszewski <[email protected]> - This is the author of the prerequisite commit 0fb410c914eb03 that introduced the WCN6750/WCN6855-only check. His review is highly significant.
- Signed-off-by: Luiz Augusto von Dentz <[email protected]> - BT subsystem maintainer applied it
- No Fixes: tag, no Cc: stable, no Reported-by (expected for candidates)
**Step 1.3:** The commit body explains: On Lemans-EVK and Monaco-EVK platforms (M.2 slot with UART+USB), bt_en is pulled high by hardware. Software power control must be disabled. Without this, power_ctrl_enabled remains true for WCN7850, causing HCI_QUIRK_NON_PERSISTENT_SETUP and qca_power_off shutdown handler to be set incorrectly.
**Step 1.4:** This IS a bug fix disguised as "aligning behavior." The commit adds WCN7850 to a condition that was already handling the same scenario for WCN6750/WCN6855, making WCN7850 broken on affected platforms.
## PHASE 2: DIFF ANALYSIS
**Step 2.1:** Single file changed: drivers/bluetooth/hci_qca.c, +2/-1 lines. Function modified: qca_serdev_probe(). Scope: single-file, single-hunk surgical fix.
**Step 2.2:** Before: When bt_en is NULL, only WCN6750 and WCN6855 got power_ctrl_enabled=false. After: WCN7850 also gets power_ctrl_enabled=false. This affects the probe path where the power control strategy is decided.
**Step 2.3:** Bug category: Logic/correctness fix - missing SoC type in a condition. When power_ctrl_enabled remains incorrectly true:
- HCI_QUIRK_NON_PERSISTENT_SETUP is set (line 2532)
- hdev->shutdown = qca_power_off is set (line 2533)
- The SSR recovery in fce1a9244a0f8 checks this quirk and takes the wrong path
**Step 2.4:** Fix is obviously correct - follows established pattern. Zero regression risk (only adds a SoC type to an OR chain). Reviewed by the author of the prerequisite code.
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1:** git blame shows the condition was introduced by 0fb410c914eb03 (Bartosz Golaszewski, 2025-05-27), which restructured the code to restrict the power_ctrl_enabled=false check to WCN6750/WCN6855 only. WCN7850 was inadvertently omitted.
**Step 3.2:** No Fixes: tag. The root cause is 0fb410c914eb03 which has its own Fixes: 3d05fc82237a and Cc: [email protected]. WCN7850 was missed when 0fb410c914eb03 restricted the condition.
**Step 3.3:** Related commits by same author: fce1a9244a0f8 "Fix SSR fail when BT_EN is pulled up by hw" - this is the companion fix that depends on HCI_QUIRK_NON_PERSISTENT_SETUP being correctly set. This commit is standalone but paired with 0fb410c914eb03.
**Step 3.4:** Shuai Zhang is a regular Qualcomm BT contributor. Bartosz Golaszewski (reviewer) wrote the prerequisite code.
**Step 3.5:** This commit depends on 0fb410c914eb03 being present. That commit is in mainline (first tagged in v6.16/v6.17) but NOT yet in any stable tree (not in v6.6, v6.12, or v6.14). In stable trees without 0fb410c914eb03, the code has an unconditional check (if (!qcadev->bt_en) power_ctrl_enabled = false;) that covers ALL SoC types including WCN7850. The bug only manifests after 0fb410c914eb03 is applied.
## PHASE 4: MAILING LIST RESEARCH
The patch went through v1 -> v2 -> v3. v1 had review feedback from Dmitry Baryshkov requesting more context about affected platforms. v2/v3 added platform details (Lemans-EVK, Monaco-EVK). Bartosz Golaszewski (who wrote the prerequisite commit) gave Reviewed-by on v3. Luiz von Dentz (BT maintainer) applied it to bluetooth-next. No NAKs, no concerns about the code change itself.
## PHASE 5: CODE SEMANTIC ANALYSIS
power_ctrl_enabled controls two behaviors in qca_serdev_probe():
1. Setting HCI_QUIRK_NON_PERSISTENT_SETUP quirk
2. Registering qca_power_off as shutdown handler
When power_ctrl_enabled is incorrectly true for WCN7850 with HW- managed bt_en:
- qca_power_off -> qca_power_shutdown() falls to default case:
gpiod_set_value_cansleep(NULL, 0) which is a no-op (safe)
- But the quirk HCI_QUIRK_NON_PERSISTENT_SETUP being set causes the SSR recovery code (fce1a9244a0f8) to skip critical recovery steps, leading to SSR failure (HCI reset timeout)
## PHASE 6: STABLE TREE ANALYSIS
- **v6.6**: WCN7850 exists (12 references). Code structure is completely different (IS_ERR_OR_NULL pattern). Bug exists differently but this patch wouldn't apply without significant rework.
- **v6.12/v6.14**: 3d05fc82237aa9 is present but 0fb410c914eb03 is NOT. The check is unconditional (if (!qcadev->bt_en) power_ctrl_enabled = false;), so the bug does NOT exist yet. However, when 0fb410c914eb03 (tagged Cc: stable) is backported, it WILL introduce this bug by restricting the check to WCN6750/WCN6855 only.
- This patch must be paired with 0fb410c914eb03 when backporting.
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
- Subsystem: Bluetooth driver (IMPORTANT, affects Qualcomm BT hardware users)
- Criticality: Driver-specific, but WCN7850 is a widely-used Qualcomm BT chip (SM8550 platforms and others)
- Active subsystem with regular contributions
## PHASE 8: IMPACT AND RISK ASSESSMENT
- **Who is affected**: WCN7850 users on platforms where bt_en is HW- controlled (Lemans-EVK, Monaco-EVK with M.2 slot)
- **Trigger**: Always, during probe on affected hardware. Not timing- dependent.
- **Failure mode**: SSR failure - BT controller cannot recover from firmware crash. HCI reset times out. MEDIUM-HIGH severity (Bluetooth becomes non-functional after FW crash until reboot)
- **Benefit**: High for affected hardware users
- **Risk**: Very low - 1 line addition to an OR condition, obviously correct pattern
## PHASE 9: FINAL SYNTHESIS
**Evidence FOR:**
- Fixes real hardware issue on WCN7850 platforms with HW-managed bt_en
- Trivially small (1 line), obviously correct
- Reviewed by the author of the prerequisite code
- Applied by BT subsystem maintainer
- Follows established pattern (WCN6750/WCN6855 already handled)
- Without this fix, SSR recovery fails on affected platforms
- Falls under "hardware quirk/workaround" exception category
**Evidence AGAINST:**
- Depends on 0fb410c914eb03 (not yet in stable trees)
- Limited platform scope (Lemans-EVK, Monaco-EVK)
- In current stable trees, the bug doesn't exist yet (unconditional check)
**Stable rules checklist:**
1. Obviously correct and tested? YES (trivial 1-line addition, reviewed)
2. Fixes a real bug? YES (SSR failure on affected hardware)
3. Important issue? YES (BT becomes non-functional after FW crash)
4. Small and contained? YES (1 line change)
5. No new features? YES (just extends existing condition)
6. Can apply to stable? YES, when paired with 0fb410c914eb03
## Verification
- [Phase 1] Parsed tags: Reviewed-by from Bartosz Golaszewski (prerequisite commit author), applied by BT maintainer Luiz von Dentz
- [Phase 2] Diff: 1 line added to OR condition in qca_serdev_probe(), adding QCA_WCN7850
- [Phase 3] git blame: condition introduced by 0fb410c914eb03 (2025-05-27), which restricted check to WCN6750/WCN6855
- [Phase 3] 0fb410c914eb03 has Cc: stable, Fixes: 3d05fc82237a - will be backported
- [Phase 3] 0fb410c914eb03 NOT in v6.6, v6.12, v6.14 (verified with git merge-base)
- [Phase 3] WCN7850 support (e0c1278ac89b0) is in v6.6 (2023-08-24)
- [Phase 4] Patchew: v3 reviewed by Bartosz Golaszewski, applied by Luiz von Dentz. No NAKs.
- [Phase 5] power_ctrl_enabled=true causes incorrect HCI_QUIRK_NON_PERSISTENT_SETUP and SSR recovery failure
- [Phase 5] Verified qca_power_shutdown() default case:
gpiod_set_value_cansleep(NULL, 0) is safe (no-op)
- [Phase 6] v6.12/v6.14: unconditional check exists, bug not present. Bug will appear when 0fb410c914eb03 is backported
- [Phase 6] v6.6: different code structure, would need rework
- [Phase 8] Failure mode: SSR failure (HCI reset timeout, BT non- functional until reboot), MEDIUM-HIGH severity
**YES**
drivers/bluetooth/hci_qca.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/bluetooth/hci_qca.c +2 -1
@@ -2471,7 +2471,8 @@ static int qca_serdev_probe(struct serdev_device *serdev)if (!qcadev->bt_en && (data->soc_type ==QCA_WCN6750 || - data->soc_type ==QCA_WCN6855 )) + data->soc_type ==QCA_WCN6855 || + data->soc_type ==QCA_WCN7850 )) power_ctrl_enabled = false; qcadev->sw_ctrl = devm_gpiod_get_optional(&serdev->dev, "swctrl",
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 Bluetooth: hci_qca: Fix missing wakeup during SSR memdump handling
In reply to Sasha LevinFrom: Shuai Zhang <[email protected]>
[ Upstream commit c347ca17d62a32c25564fee0ca3a2a7bc2d5fd6f ]
When a Bluetooth controller encounters a coredump, it triggers the Subsystem Restart (SSR) mechanism. The controller first reports the coredump data and, once the upload is complete, sends a hw_error event. The host relies on this event to proceed with subsequent recovery actions.
If the host has not finished processing the coredump data when the hw_error event is received, it waits until either the processing is complete or the 8-second timeout expires before handling the event.
The current implementation clears QCA_MEMDUMP_COLLECTION using clear_bit(), which does not wake up waiters sleeping in wait_on_bit_timeout(). As a result, the waiting thread may remain blocked until the timeout expires even if the coredump collection has already completed.
Fix this by clearing QCA_MEMDUMP_COLLECTION with clear_and_wake_up_bit(), which also wakes up the waiting thread and allows the hw_error handling to proceed immediately.
Test case:
- Trigger a controller coredump using:
hcitool cmd 0x3f 0c 26
- Tested on QCA6390.
- Capture HCI logs using btmon.
- Verify that the delay between receiving the hw_error event and initiating the power-off sequence is reduced compared to the timeout-based behavior.
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed for a complete analysis. Let me compile it.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: PARSE THE SUBJECT LINE
- **Subsystem prefix:** Bluetooth: hci_qca
- **Action verb:** "Fix" - explicitly a bug fix
- **One-line summary:** Fix missing wakeup during SSR memdump handling - clear_bit() doesn't wake up waiters sleeping in wait_on_bit_timeout().
### Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
- **Reviewed-by:** Bartosz Golaszewski (Qualcomm contributor, knowledgeable in this driver)
- **Reviewed-by:** Paul Menzel (known active reviewer)
- **Signed-off-by:** Shuai Zhang <[email protected]> (author, Qualcomm - QCA chipset vendor)
- **Signed-off-by:** Luiz Augusto von Dentz <[email protected]> (Bluetooth maintainer)
- No Fixes: tag, no Reported-by, no syzbot. Absence of Fixes: is expected.
### Step 1.3: ANALYZE THE COMMIT BODY TEXT
- **Bug:** When Bluetooth controller encounters a coredump (SSR), it sends memdump data then sends hw_error event. The host calls wait_on_bit_timeout() on QCA_MEMDUMP_COLLECTION to wait for the collection to complete. But the collection worker clears the bit with clear_bit(), which does NOT wake up the waiter.
- **Symptom:** The waiting thread blocks for the full 8-second timeout (MEMDUMP_TIMEOUT_MS = 8000) even when collection finishes early.
- **Root cause:** API misuse - wait_on_bit_timeout() documentation explicitly requires wakeup via wake_up_bit() or clear_and_wake_up_bit().
- **Test:** Tested on QCA6390 hardware using hcitool and btmon.
### Step 1.4: DETECT HIDDEN BUG FIXES
This is an explicitly stated bug fix, not disguised. The wait_on_bit_timeout API documentation (in include/linux/wait_bit.h)
states: "The clearing of the bit must be signalled with wake_up_bit(), often as clear_and_wake_up_bit()." Using plain clear_bit() is an API violation.
---
## PHASE 2: DIFF ANALYSIS - LINE BY LINE
### Step 2.1: INVENTORY THE CHANGES
- **File:** drivers/bluetooth/hci_qca.c only
- **Changes:** 2 lines changed (2 clear_bit → clear_and_wake_up_bit)
- **Functions modified:** qca_controller_memdump() (2 locations)
- **Scope:** Single-file, single-function surgical fix
### Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
**Hunk 1 (line 1108):** Error path when hci_devcd_init() fails:
- Before: clear_bit(QCA_MEMDUMP_COLLECTION, &qca->flags) — clears bit but no wakeup
- After: clear_and_wake_up_bit(QCA_MEMDUMP_COLLECTION, &qca->flags) — clears bit AND wakes waiting thread
**Hunk 2 (line 1186):** Normal completion path (last sequence received):
- Before: same clear_bit() without wakeup
- After: same clear_and_wake_up_bit() with wakeup
### Step 2.3: IDENTIFY THE BUG MECHANISM
This is a **synchronization bug**: missing wakeup. The qca_wait_for_dump_collection() function calls wait_on_bit_timeout() which puts the thread to sleep waiting for the bit to be cleared AND a wakeup signal. Without the wakeup, the thread sleeps for the full 8-second timeout.
### Step 2.4: ASSESS THE FIX QUALITY
- **Obviously correct:** Yes. The wait_on_bit_timeout documentation explicitly states wakeup is required.
- **Minimal:** Yes, 2 line changes.
- **Regression risk:** Negligible. clear_and_wake_up_bit() does exactly what clear_bit() does plus a wakeup. No new side effects.
---
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: BLAME THE CHANGED LINES
- Line 1108 (clear_bit): Introduced by 06d3fdfcdf5cef (Sai Teja Aluvala, 2023-06-14) — v6.6-rc1
- Line 1186 (clear_bit): Introduced by 7c2c3e63e1e97c (Venkata Lakshmi, 2020-02-14) — v5.7-rc1
- wait_on_bit_timeout (line 1606): Introduced by d841502c79e3fd (Balakrishna Godavarthi, 2020-01-02) — v5.6-rc1
So the bug at line 1186 has existed since v5.7, and the bug at line 1108 since v6.6.
### Step 3.2: FOLLOW THE FIXES: TAG
No Fixes: tag (expected).
### Step 3.3: CHECK FILE HISTORY
Recent changes to hci_qca.c are active (73 commits since v5.15). The file sees regular activity.
### Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Shuai Zhang is a Qualcomm contributor with multiple commits to the QCA Bluetooth stack. The fix was reviewed by the Bluetooth maintainer (Luiz Augusto von Dentz).
### Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS None. clear_and_wake_up_bit() has existed since v4.17. The fix is a drop-in replacement for clear_bit() at two locations.
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
### Step 4.1-4.2: FIND THE ORIGINAL PATCH DISCUSSION Found at:
https://yhbt.net/lore/lkml/177583080679.2077665.8641347877052929776.git-
[email protected]/T/
The patch went through **7 revisions** (v1 through v7), indicating extensive review:
- v5→v6: Changed from wake_up_bit to clear_and_wake_up_bit (the proper API)
- Applied to bluetooth-next by Luiz Augusto von Dentz (Bluetooth maintainer)
- Commit in bluetooth-next: 9f07d5d04826
### Step 4.3: BUG REPORT
No external bug report — the author identified the issue through code/testing.
### Step 4.4-4.5: RELATED PATCHES AND STABLE HISTORY This is a standalone single-patch fix. No series dependencies.
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1-5.4: KEY FUNCTIONS AND CALL CHAINS
The affected path:
1. Bluetooth controller crashes → sends memdump data → sends hw_error event
2. qca_hw_error() or qca_reset() → calls qca_wait_for_dump_collection() → wait_on_bit_timeout() on QCA_MEMDUMP_COLLECTION
3. Concurrently, qca_controller_memdump() (workqueue) processes dump packets
4. On completion, qca_controller_memdump() clears QCA_MEMDUMP_COLLECTION — but without waking up the waiter in step 2
5. Result: waiter in step 2 sleeps for full 8 seconds even though collection finished
Both qca_hw_error() and qca_reset() call qca_wait_for_dump_collection(), so both paths are affected.
### Step 5.5: SIMILAR PATTERNS
No other clear_bit/wait_on_bit_timeout mismatches found in this file.
---
## PHASE 6: CROSS-REFERENCING AND STABLE TREE ANALYSIS
### Step 6.1: DOES THE BUGGY CODE EXIST IN STABLE TREES?
- The clear_bit at the completion path (line 1186) has been present since v5.7, so it exists in stable trees 5.10.y, 5.15.y, 6.1.y, 6.6.y, 6.12.y.
- The clear_bit at the error path (line 1108) was introduced in v6.6, so only in 6.6.y, 6.12.y.
### Step 6.2: BACKPORT COMPLICATIONS
The patch should apply cleanly or with minor context adjustments. The two lines being changed are simple API call replacements. Older trees may not have the first hunk (line 1108) since that code was added in v6.6.
### Step 6.3: RELATED FIXES ALREADY IN STABLE
No related fixes for this specific bug found.
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
### Step 7.1: SUBSYSTEM CRITICALITY
- **Subsystem:** drivers/bluetooth — Bluetooth driver for Qualcomm chipsets
- **Criticality:** IMPORTANT — QCA Bluetooth chipsets are widely used in laptops, phones, and embedded systems
### Step 7.2: SUBSYSTEM ACTIVITY
Active subsystem with regular commits.
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: AFFECTED POPULATION
Users of QCA Bluetooth chipsets (QCA6390 and similar) — a significant population in the Android and laptop ecosystem.
### Step 8.2: TRIGGER CONDITIONS
Triggered when the Bluetooth controller crashes and SSR begins. Not common in normal operation, but when it happens (coredump, hw error), the 8-second unnecessary delay is always present.
### Step 8.3: FAILURE MODE SEVERITY
- **Failure mode:** Unnecessary 8-second delay during Bluetooth recovery after controller crash
- **Severity:** MEDIUM — Not a crash, not data corruption, not a security issue. It's a latency bug during error recovery that affects usability.
### Step 8.4: RISK-BENEFIT RATIO
- **Benefit:** Eliminates unnecessary 8-second delay during SSR recovery. Correct API usage per documentation.
- **Risk:** Very low — 2-line change, clear_and_wake_up_bit is a strict superset of clear_bit (clear + wakeup). No new side effects.
- **Ratio:** Very favorable — minimal risk for a real improvement in error recovery behavior.
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: COMPILE THE EVIDENCE
**FOR backporting:**
- Fixes a genuine API misuse bug (clear_bit instead of clear_and_wake_up_bit)
- 2-line surgical fix, trivially correct per API documentation
- Extensively reviewed (7 revisions), 2 Reviewed-by tags
- Applied by Bluetooth maintainer
- Tested on real hardware (QCA6390)
- Very low regression risk
- Bug exists since v5.7 for one path and v6.6 for the other
- clear_and_wake_up_bit() exists since v4.17, no dependency issues
**AGAINST backporting:**
- The bug doesn't cause crashes, data corruption, or security issues
- Only manifests during SSR (error recovery), not during normal operation
- It's a latency/usability improvement rather than a fix for a hard failure
### Step 9.2: STABLE RULES CHECKLIST
1. **Obviously correct and tested?** YES — API documentation is explicit, tested on hardware
2. **Fixes a real bug?** YES — missing wakeup causing unnecessary 8-second delay
3. **Important issue?** MEDIUM — recovery delay, not crash/corruption
4. **Small and contained?** YES — 2 lines in 1 file
5. **No new features or APIs?** YES — just corrects API usage
6. **Can apply to stable trees?** YES — clear_and_wake_up_bit exists since v4.17
### Step 9.3: EXCEPTION CATEGORIES
Not applicable — this is a standard bug fix.
### Step 9.4: DECISION
The fix is tiny, obviously correct, well-reviewed, and addresses a real bug where wait_on_bit_timeout() is used with clear_bit() instead of clear_and_wake_up_bit(), causing an unnecessary 8-second blocking delay during Bluetooth error recovery. While the impact is "only" a latency issue during recovery (not a crash or data loss), the extremely low risk of the fix and the real user-visible improvement make this appropriate for stable.
---
## Verification
- [Phase 1] Parsed tags: Reviewed-by from Bartosz Golaszewski and Paul Menzel; SOB from author and Bluetooth maintainer
- [Phase 2] Diff analysis: 2 lines changed in qca_controller_memdump(), replacing clear_bit() with clear_and_wake_up_bit()
- [Phase 3] git blame: Line 1108 introduced in 06d3fdfcdf5cef (v6.6-rc1); Line 1186 introduced in 7c2c3e63e1e97c (v5.7-rc1); wait_on_bit_timeout introduced in d841502c79e3fd (v5.6-rc1)
- [Phase 3] git describe: clear_and_wake_up_bit introduced in 8236b0ae31c83 (v4.17-rc4), present in all active stable trees
- [Phase 4] lore thread found: patch went through v1→v7, applied to bluetooth-next by maintainer as 9f07d5d04826
- [Phase 4] No NAKs or objections in the discussion thread
- [Phase 5] Call chain: qca_hw_error()/qca_reset() → qca_wait_for_dump_collection() → wait_on_bit_timeout() waits for bit cleared by qca_controller_memdump() workqueue
- [Phase 5] Verified wait_on_bit_timeout() documentation in include/linux/wait_bit.h lines 118-120 explicitly requires clear_and_wake_up_bit()
- [Phase 6] Buggy code exists in stable trees 5.10+, 5.15+, 6.1+, 6.6+, 6.12+ (second hunk); 6.6+, 6.12+ (first hunk)
- [Phase 6] MEMDUMP_TIMEOUT_MS is 8000 (8 seconds) — confirmed at line 54
- [Phase 8] Failure mode: 8-second unnecessary delay during Bluetooth SSR recovery, severity MEDIUM
**YES**
drivers/bluetooth/hci_qca.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bluetooth/hci_qca.c +2 -2
@@ -1105,7 +1105,7 @@ static void qca_controller_memdump(struct work_struct *work) qca->qca_memdump =NULL ; qca->memdump_state =QCA_MEMDUMP_COLLECTED ;cancel_delayed_work (&qca->ctrl_memdump_timeout); -clear_bit (QCA_MEMDUMP_COLLECTION , &qca->flags); +clear_and_wake_up_bit (QCA_MEMDUMP_COLLECTION , &qca->flags);clear_bit (QCA_IBS_DISABLED , &qca->flags);mutex_unlock (&qca->hci_memdump_lock);return ;
@@ -1183,7 +1183,7 @@ static void qca_controller_memdump(struct work_struct *work)kfree (qca->qca_memdump); qca->qca_memdump =NULL ; qca->memdump_state =QCA_MEMDUMP_COLLECTED ; -clear_bit (QCA_MEMDUMP_COLLECTION , &qca->flags); +clear_and_wake_up_bit (QCA_MEMDUMP_COLLECTION , &qca->flags); }mutex_unlock (&qca->hci_memdump_lock);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 pinctrl: intel: Fix the revision for new features (1kOhm PD, HW debouncer)
In reply to Sasha LevinFrom: Andy Shevchenko <[email protected]>
[ Upstream commit a4337a24d13e9e3b98a113e71d6b80dc5ed5f8c4 ]
The 1kOhm pull down and hardware debouncer are features of the revision 0.92 of the Chassis specification. Fix that in the code accordingly.
---
LLM Generated explanations, may be completely bogus:
Error: Failed to generate final synthesis
drivers/pinctrl/intel/pinctrl-intel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/intel/pinctrl-intel.c +1 -1
@@ -1606,7 +1606,7 @@ int intel_pinctrl_probe(struct platform_device *pdev, value =readl (regs +REVID );if (value == ~0u )return -ENODEV ; -if (((value &REVID_MASK ) >>REVID_SHIFT ) >=0x94 ) { +if (((value &REVID_MASK ) >>REVID_SHIFT ) >=0x92 ) { community->features |=PINCTRL_FEATURE_DEBOUNCE ; community->features |=PINCTRL_FEATURE_1K_PD ; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 fbdev: viafb: check ioremap return value in viafb_lcd_get_mobile_state
In reply to Sasha LevinFrom: Wang Jun <[email protected]>
[ Upstream commit f044788088ef55e9855b17b7984ffe522c40c093 ]
The function viafb_lcd_get_mobile_state() calls ioremap() without checking the return value. If ioremap() fails (returns NULL), the subsequent readw() will cause a NULL pointer dereference.
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed for the full analysis. Let me compile it.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: Subject Line**
- Subsystem: fbdev: viafb
- Action verb: "check" (adding a missing safety check)
- Summary: Adds NULL check for ioremap() return value in viafb_lcd_get_mobile_state()
Record: [fbdev: viafb] [check] [Add missing ioremap NULL check to prevent NULL deref]
**Step 1.2: Tags**
- Signed-off-by: Wang Jun <[email protected]> (author)
- Signed-off-by: Helge Deller <[email protected]> (fbdev maintainer, committer)
- No Fixes:, Reported-by:, Tested-by:, Link:, or Cc: stable tags
Record: Only author and maintainer SOBs. No Fixes: tag or Reported-by — this appears to be a code-review/static-analysis finding, not a user- reported bug.
**Step 1.3: Body Text**
- Bug: viafb_lcd_get_mobile_state() calls ioremap() without checking the return value.
- Symptom: If ioremap() returns NULL, the subsequent readw() causes a NULL pointer dereference.
- Root cause: Missing NULL check.
Record: [NULL pointer dereference if ioremap fails] [kernel oops/crash] [No version info] [Straightforward missing check]
**Step 1.4: Hidden Bug Fix?**
Yes — this is a genuine bug fix. A missing NULL check before pointer dereference is a real code defect.
Record: [Yes, this is a missing NULL check for a function that can fail]
---
## PHASE 2: DIFF ANALYSIS
**Step 2.1: Inventory**
- 1 file changed: drivers/video/fbdev/via/lcd.c
- +3 lines added (NULL check, return false, blank line), 0 removed
- Function modified: viafb_lcd_get_mobile_state()
Record: [lcd.c +3/-0] [viafb_lcd_get_mobile_state] [Single-file surgical fix]
**Step 2.2: Code Flow Change**
- Before: ioremap() → immediate readw(biosptr) — if biosptr is NULL, kernel oops
- After: ioremap() → NULL check → return false if NULL; otherwise proceed normally
Record: [Before: unchecked ioremap -> readw on potential NULL. After:
NULL check added, returns false on failure]
**Step 2.3: Bug Mechanism**
- Category: NULL pointer dereference / memory safety
- The ioremap() call can fail and return NULL. Without a check, readw(biosptr) dereferences NULL.
Record: [NULL pointer dereference] [Missing ioremap NULL check → readw on NULL crashes kernel]
**Step 2.4: Fix Quality**
- Obviously correct — standard ioremap error-checking pattern used across the kernel
- Minimal — 2 lines of logic
- Return value of false is appropriate: the caller in via_utility.c simply won't set LCD_Device in the connect state, which is the correct degraded behavior
- Zero regression risk
Record: [Obviously correct, minimal fix, no regression risk]
---
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: Blame**
The buggy code was introduced in commit ac6c97e20f1bef by Joseph Chan on 2008-10-15 — the original viafb driver submission. This code has existed since approximately v2.6.28.
Record: [Buggy code from ac6c97e20f1bef (Oct 2008), present since ~v2.6.28]
**Step 3.2: Fixes: Tag**
No Fixes: tag present. Expected for autosel candidates.
Record: [N/A — no Fixes: tag]
**Step 3.3: File History**
Only cosmetic changes in recent years (spelling fix, I2C terminology, fallthrough macro). The function is completely unchanged since 2011 (b65d6040e3a7cd by Stephen Hemminger was the last substantive touch).
Record: [No prerequisites. Completely standalone fix. No series.]
**Step 3.4: Author**
Wang Jun has only 2 commits in the tree. Helge Deller is the fbdev subsystem maintainer who signed off.
Record: [Author is not a subsystem regular; maintainer (Helge Deller) signed off]
**Step 3.5: Dependencies**
None — the fix is completely self-contained.
Record: [No dependencies. Applies standalone.]
---
## PHASE 4: MAILING LIST RESEARCH
**Step 4.1-4.5:**
b4 dig failed to find the original patch submission. Lore.kernel.org is behind Anubis anti-bot protection and could not be fetched. No mailing list discussion could be reviewed.
Record: [b4 dig: no match found] [Lore: blocked by Anubis] [UNVERIFIED:
Could not review mailing list discussion]
---
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: Functions Modified** viafb_lcd_get_mobile_state() — the only function touched.
**Step 5.2: Callers**
- viafb_lcd_get_mobile_state() is called from viafb_get_device_connect_state() in via_utility.c (line 31)
- viafb_get_device_connect_state() is called from the ioctl handler VIAFB_GET_DEVICE_CONNECT in viafbdev.c (line 558)
- This makes the buggy path **reachable from userspace** via ioctl.
Record: [Call chain: ioctl(VIAFB_GET_DEVICE_CONNECT) → viafb_get_device_connect_state() → viafb_lcd_get_mobile_state() → ioremap → readw(NULL)]
**Step 5.3-5.4: Callees/Call Chain**
The function calls ioremap(), readw(), readb(), iounmap(). It maps the VGA BIOS ROM at physical address 0xC0000 to check if the system is mobile (laptop) hardware.
Record: [ioremap maps VGA BIOS ROM; readw/readb parse BIOS tables]
**Step 5.5: Similar Patterns**
Missing ioremap checks are a common class of bug across the kernel. Many similar fixes have been applied.
Record: [Common bug pattern - missing ioremap NULL check]
---
## PHASE 6: STABLE TREE ANALYSIS
**Step 6.1: Buggy Code in Stable?**
Yes. The buggy code was introduced in 2008 and is present in ALL active stable trees. Only cosmetic changes since v5.15 (spelling fix, I2C terminology).
Record: [Present in all stable trees: 5.10, 5.15, 6.1, 6.6, etc.]
**Step 6.2: Backport Complications**
None. The file has barely changed. The patch should apply cleanly to all stable trees.
Record: [Clean apply expected in all stable trees]
**Step 6.3: Related Fixes in Stable**
None found. This bug has never been fixed before.
Record: [No related fixes in stable]
---
## PHASE 7: SUBSYSTEM CONTEXT
**Step 7.1: Subsystem Criticality**
- Subsystem: drivers/video/fbdev (framebuffer device drivers)
- Sub-subsystem: VIA framebuffer (viafb) — legacy VIA chipset graphics
- Criticality: **PERIPHERAL** — very niche, legacy hardware from mid-2000s
Record: [fbdev/viafb, PERIPHERAL criticality]
**Step 7.2: Subsystem Activity**
Very low activity. Last substantive changes to this file were years ago. The driver is effectively in maintenance-only mode.
Record: [Very low activity — maintenance only]
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: Affected Users**
Only users of VIA framebuffer hardware with this specific ioctl call path.
Record: [Driver-specific, very niche hardware]
**Step 8.2: Trigger Conditions**
- Requires ioremap(0xC0000, 0x10000) to fail
- This maps the standard VGA BIOS ROM — on VIA hardware this should almost always succeed
- Could theoretically fail under extreme memory pressure
- Reachable from userspace ioctl (unprivileged user could trigger it if they have access to the fbdev device)
Record: [Extremely unlikely trigger; ioremap of BIOS ROM address rarely fails on real hardware]
**Step 8.3: Failure Mode Severity**
- If triggered: NULL pointer dereference → kernel oops/crash
- Severity: **HIGH** if triggered (kernel crash), but probability is very low
Record: [Kernel oops, HIGH severity, VERY LOW probability]
**Step 8.4: Risk-Benefit**
- Benefit: LOW-MEDIUM — prevents a theoretical NULL deref on niche hardware
- Risk: VERY LOW — 2 lines, obviously correct, zero regression potential
- Ratio: favorable — essentially zero cost to include
Record: [Low benefit, very low risk, favorable ratio]
---
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: Evidence**
FOR backporting:
- Fixes a genuine NULL pointer dereference (kernel crash)
- Extremely small (2 lines of logic) and obviously correct
- Zero regression risk
- Present in all stable trees, applies cleanly
- Code is reachable from userspace via ioctl
- Standard defensive fix pattern used across the kernel
AGAINST backporting:
- Bug has existed since 2008 (~17 years) without any reports
- Target hardware (VIA framebuffer) is extremely niche/legacy
- ioremap(0xC0000) failure on real VIA hardware is near-impossible
- No Reported-by, no syzbot finding, no user complaints
- Appears to be static analysis / code review finding, not a real-world bug
**Step 9.2: Stable Rules Checklist**
1. Obviously correct and tested? **YES** — standard ioremap check pattern
2. Fixes a real bug? **YES** — missing NULL check is a real code defect, though theoretical
3. Important issue? **BORDERLINE** — crash if triggered, but trigger is extremely unlikely
4. Small and contained? **YES** — 2 lines, single function
5. No new features or APIs? **YES** — purely defensive
6. Can apply to stable? **YES** — clean apply expected
**Step 9.3: Exception Categories**
None apply.
**Step 9.4: Decision**
This is a borderline case. The fix prevents a genuine NULL pointer dereference but on a near-impossible code path for niche hardware that no one has reported in 17 years. However, the fix is so small (2 lines) and so obviously correct that it carries essentially zero regression risk. The cost of including it is nil, while it does improve code correctness and prevents a theoretical kernel crash reachable from userspace.
---
## Verification
- [Phase 1] Parsed subject: "fbdev: viafb: check ioremap return value" — adding missing NULL check
- [Phase 1] Parsed tags: only author SOB and maintainer SOB, no Fixes/Reported-by/Cc:stable
- [Phase 2] Diff analysis: +3 lines in viafb_lcd_get_mobile_state(), adds NULL check after ioremap(), returns false on failure
- [Phase 2] Verified: readw(biosptr) immediately follows ioremap() without check — confirmed NULL deref risk
- [Phase 3] git blame: buggy code introduced in ac6c97e20f1bef (Joseph Chan, 2008-10-15), present since ~v2.6.28
- [Phase 3] git log -20: confirmed only cosmetic changes to lcd.c since 2008
- [Phase 3] git tag --contains: confirmed ac6c97e20f1bef present in p-5.10, p-5.15 (all stable trees)
- [Phase 4] b4 dig -c: failed to find matching patch — no lore URL available
- [Phase 4] UNVERIFIED: Could not review mailing list discussion due to b4 failure and Anubis blocking lore
- [Phase 5] Grep viafb_lcd_get_mobile_state: confirmed call chain ioctl → viafb_get_device_connect_state → viafb_lcd_get_mobile_state
- [Phase 5] Verified: VIAFB_GET_DEVICE_CONNECT ioctl at viafbdev.c:557-561 makes path reachable from userspace
- [Phase 5] Verified: on ioremap failure, returning false causes caller to skip LCD_Device — safe degradation
- [Phase 6] git log v6.6.. and v5.15..: confirmed minimal changes (only cosmetic), clean apply expected
- [Phase 8] Trigger analysis: ioremap(0xC0000, 0x10000) maps standard VGA BIOS ROM; failure is extremely unlikely on real VIA hardware
**YES**
drivers/video/fbdev/via/lcd.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/video/fbdev/via/lcd.c +3 -0
@@ -954,6 +954,9 @@ bool viafb_lcd_get_mobile_state(bool *mobile)u16 start_pattern; biosptr =ioremap (romaddr,0x10000 ); +if (!biosptr) +return false; + start_pattern =readw (biosptr);/* Compare pattern */
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 drm/panel-edp: Add BOE NV153WUM-N42, CMN N153JCA-ELK, CSW MNF307QS3-2
In reply to Sasha LevinFrom: Alvin1 Chen <[email protected]>
[ Upstream commit d51f217957ca1fa3a151000e86a192231284595b ]
The raw EDIDs for each panel:
BOE: NV153WUM-N42
00 ff ff ff ff ff ff 00 09 e5 b3 0d 00 00 00 00 11 23 01 04 a5 21 15 78 03 af e5 97 5e 58 92 28 1f 50 54 00 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 9c 3e 80 c8 70 b0 3c 40 30 20 36 00 49 ce 10 00 00 1a 00 00 00 fd 00 28 3c 4c 4c 10 01 0a 20 20 20 20 20 20 00 00 00 fe 00 42 4f 45 20 43 51 0a 20 20 20 20 20 20 00 00 00 fc 00 4e 56 31 35 33 57 55 4d 2d 4e 34 32 0a 01 92
70 20 79 02 00 81 00 15 74 1a 00 00 03 01 28 3c 00 00 60 49 60 49 3c 00 00 00 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 cb 90
CMN: N153JCA-ELK
00 ff ff ff ff ff ff 00 0d ae 6b 15 00 00 00 00 16 23 01 04 a5 21 15 78 03 08 82 93 59 53 8e 27 1e 4f 54 00 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 42 3c 80 a0 70 b0 24 40 30 20 a6 00 49 cd 10 00 00 1a 00 00 00 fd 00 28 3c 4a 4a 10 01 0a 20 20 20 20 20 20 00 00 00 fe 00 43 4d 4e 0a 20 20 20 20 20 20 20 20 20 00 00 00 fc 00 4e 31 35 33 4a 43 41 2d 45 4c 4b 0a 20 01 d5
70 20 79 02 00 25 01 09 94 5a 02 94 5a 02 28 3c 80 81 00 13 72 1a 00 00 03 01 28 3c 00 00 00 00 00 00 3c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ae 90
CSW: MNF307QS3-2
00 ff ff ff ff ff ff 00 0e 77 29 15 00 00 00 00 13 23 01 04 a5 21 15 78 03 9c 81 96 5d 5a 94 28 1e 51 56 00 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 1a 3f 80 04 71 b0 23 40 30 20 36 00 49 cd 10 00 00 18 00 00 00 fd 00 28 3c 4a 4a 10 01 0a 20 20 20 20 20 20 00 00 00 fe 00 43 4f 53 54 20 54 39 0a 20 20 20 20 20 00 00 00 fc 00 4d 4e 46 33 30 37 51 53 33 2d 32 0a 20 01 5c
70 20 79 02 00 81 00 15 74 1a 00 00 03 01 28 3c 00 00 60 46 60 46 3c 00 00 00 00 8d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 c4 90
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed for a complete analysis. Let me compile the findings.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: Subject Line**
- Subsystem: drm/panel-edp
- Action: "Add" (three new panel entries)
- Summary: Adding panel IDs for BOE NV153WUM-N42, CMN N153JCA-ELK, CSW MNF307QS3-2
- Record: [drm/panel-edp] [Add] [Three new eDP panel ID entries to existing driver table]
**Step 1.2: Tags**
- Signed-off-by: Alvin1 Chen <[email protected] partner.google.com> — author, Google Corp Partner (Lenovo/LCFC)
- Reviewed-by: Douglas Anderson <[email protected]> — the drm/panel-edp subsystem maintainer reviewed it
- Signed-off-by: Douglas Anderson <[email protected]> — maintainer applied/signed off on it
- `Link: https://patch.msgid.link/20260319050938.556235-1-
[email protected]` — patch submission link
- No Fixes: tag (expected for device ID additions)
- No Cc: stable (expected)
- Record: Reviewed and signed off by subsystem maintainer Douglas Anderson. Author is from LCFC/Google partnership (Chromebook hardware).
**Step 1.3: Commit Body**
- Contains raw EDID hex dumps for all three panels as documentation/proof
- No bug description (this is hardware enablement, not a fix per se)
- Record: Commit body is EDID data only — standard for panel-edp additions.
**Step 1.4: Hidden Bug Fix Detection**
- This is not a disguised bug fix. It is a straightforward hardware enablement (device ID addition) to an existing driver. Without the entry, panels are unrecognized and may not work or use incorrect timings.
- Record: Not a hidden bug fix; it's a device ID addition which is an explicit exception category for stable.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: Inventory**
- Files changed: 1 (drivers/gpu/drm/panel/panel-edp.c)
- Lines added: 3 (one EDP_PANEL_ENTRY line per panel)
- Lines removed: 0
- Functions modified: none (only data table entries)
- Record: Single file, +3 lines, static data table only. Ultra-minimal scope.
**Step 2.2: Code Flow Change**
- Three new entries added to the edp_panels[] static const array:
1. `EDP_PANEL_ENTRY('B', 'O', 'E', 0x0db3, &delay_200_500_e80,
"NV153WUM-N42")` — inserted between 0x0d73 and 0x0ddf (sorted
order)
2. `EDP_PANEL_ENTRY('C', 'M', 'N', 0x156b, &delay_200_500_e80_d50,
"N153JCA-ELK")` — inserted between 0x1565 and 0x162b (sorted order)
3. `EDP_PANEL_ENTRY('C', 'S', 'W', 0x1529, &delay_200_500_e80_d50,
"MNF307QS3-2")` — inserted after 0x1519 (sorted order)- Before: These three panels were unrecognized by the driver
- After: These panels are matched by their EDID panel ID and get proper timing delays
- Record: Data-only additions in sorted order. No behavior change for any existing panel.
**Step 2.3: Bug Mechanism**
- Category (h): Hardware workaround / device ID addition
- The delay structures referenced (delay_200_500_e80 at line 1753 and delay_200_500_e80_d50 at line 1759) already exist in the file and are used by dozens of other panels
- Record: Device ID addition to existing data table. Uses pre-existing delay structures.
**Step 2.4: Fix Quality**
- Obviously correct: Each entry follows identical pattern to ~198 existing entries
- Minimal/surgical: 3 lines, data only
- Regression risk: Zero — entries only match specific panel IDs; no existing panels are affected
- Record: Fix quality is perfect. No regression risk whatsoever.
## PHASE 3: GIT HISTORY INVESTIGATION
**Step 3.1: Blame**
- The surrounding entries were added by various contributors between 2024-2025
- The edp_panels[] table has been growing steadily; 68 commits to this file since 2024-01-01
- Record: Table has existed for many kernel versions. This is a very mature, well-maintained data structure.
**Step 3.2: Fixes Tag**
- No Fixes: tag (expected for device ID additions)
- Record: N/A
**Step 3.3: File History**
- This file receives frequent panel additions (68 commits in ~2 years)
- No prerequisite commits needed — the delay structures and macro already exist
- Record: Standalone commit, no dependencies.
**Step 3.4: Author's Commits**
- Alvin1 Chen has no prior commits in this tree for panel-edp.c
- Author is from LCFC (Lenovo manufacturing partner, Google Chromebook program)
- Douglas Anderson (reviewer/signer) is the drm/panel-edp maintainer with 10+ commits here
- Record: Author is a hardware partner contributor. Maintainer reviewed and applied.
**Step 3.5: Dependencies**
- No dependencies. The EDP_PANEL_ENTRY macro (line 1859), delay_200_500_e80 (line 1753), and delay_200_500_e80_d50 (line 1759) all exist in the current stable tree.
- Record: Fully standalone. All referenced structures present.
## PHASE 4: MAILING LIST RESEARCH
**Step 4.1: Original Discussion**
- b4 dig could not find the commit (it's not yet in this tree)
- Lore is protected by Anubis bot-filtering
- Link in commit message:
patch.msgid.link/[email protected] partner.google.com
- Record: Could not fetch lore discussion due to anti-bot measures. However, the patch is reviewed and signed-off by the subsystem maintainer.
**Step 4.2: Reviewers**
- Douglas Anderson ([email protected]) is THE maintainer for drm/panel-edp (verified by his 10+ commits to this file and his reviewer/signer role)
- Record: Subsystem maintainer reviewed and applied the patch.
**Step 4.3-4.5: Bug Reports / Related Patches / Stable History**
- No bug report (this is hardware enablement, not a bug fix)
- This is a single standalone patch (not part of a series)
- Record: N/A for bug reports. Standalone single patch.
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1-5.4: Functions and Call Chains**
- No functions are modified. The change is to a static const data table edp_panels[]
- This table is looked up during panel probing when EDID is read from the connected display
- If a panel ID matches, the associated delay timings are used; if no match, generic/conservative timings are used
- Record: Data table lookup only. No code flow changes.
**Step 5.5: Similar Patterns**
- There are 198 existing EDP_PANEL_ENTRY entries in this file, all following the identical pattern
- Record: Extremely well-established pattern.
## PHASE 6: STABLE TREE ANALYSIS
**Step 6.1: Code in Stable Trees**
- The panel-edp.c driver and edp_panels[] table exist in 7.0 and all active stable trees
- The EDP_PANEL_ENTRY macro and both referenced delay structures exist
- Record: All infrastructure present in stable trees.
**Step 6.2: Backport Complications**
- The patch will apply cleanly to the 7.0 tree — the surrounding entries (0x0d73, 0x0ddf, 0x1565, 0x162b, 0x1519) all exist at the expected positions
- Older stable trees may need minor context adjustment if some surrounding entries don't exist, but the additions are independent and can be trivially placed
- Record: Clean apply expected for 7.0. Minor fuzz possible for older trees.
**Step 6.3: Related Fixes Already in Stable**
- No related fixes — these are new panel IDs not previously added
- Record: No prior entries for these panels.
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
**Step 7.1: Subsystem**
- Subsystem: DRM panel (drivers/gpu/drm/panel/) — display panel driver
- Criticality: IMPORTANT — affects users with specific laptop panels (likely Chromebooks)
- Record: Display driver, important for hardware enablement.
**Step 7.2: Activity**
- Very active: 68 commits since 2024, regular panel additions
- Record: Actively maintained, frequent contributions.
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: Affected Users**
- Users with laptops containing BOE NV153WUM-N42, CMN N153JCA-ELK, or CSW MNF307QS3-2 panels
- Likely Chromebook users (Google Corp Partner author, Chromium reviewer)
- Record: Hardware-specific; affects users with these specific panels.
**Step 8.2: Trigger Conditions**
- Every boot on affected hardware — panel detection happens during display initialization
- Without the entry, the panel may work with generic timings but could have display issues
- Record: Triggered every boot on affected hardware.
**Step 8.3: Failure Mode**
- Without this fix: Panel uses generic/conservative timings; may result in display flickering, incorrect initialization, or suboptimal performance
- With this fix: Panel gets correct vendor-specified timing delays
- Record: Severity MEDIUM — hardware enablement for display panels.
**Step 8.4: Risk-Benefit**
- BENEFIT: Enables proper display support for real hardware (laptops/Chromebooks)
- RISK: Virtually zero — 3 lines of static data, only matched by specific panel IDs, no effect on any other hardware
- Record: Very high benefit-to-risk ratio.
## PHASE 9: FINAL SYNTHESIS
**Step 9.1: Evidence**
- FOR: Device ID addition to existing driver (explicit exception category); 3 lines; zero regression risk; reviewed by subsystem maintainer; uses existing infrastructure; standalone patch
- AGAINST: Nothing substantive
- UNRESOLVED: Could not access lore discussion (Anubis blocking)
**Step 9.2: Stable Rules Checklist**
1. Obviously correct and tested? YES — identical pattern to 198 existing entries, reviewed by maintainer
2. Fixes a real bug that affects users? YES — enables hardware support for real panels
3. Important issue? MEDIUM — hardware doesn't get optimal timings without it
4. Small and contained? YES — 3 lines, single file, data only
5. No new features or APIs? YES — no new features, just device IDs
6. Can apply to stable trees? YES — all infrastructure exists
**Step 9.3: Exception Category**
- **NEW DEVICE IDs** — adding panel IDs to an existing driver. This is an explicit YES exception category.
**Step 9.4: Decision**
This is a textbook device ID addition — the most common and safest type of stable backport.
## Verification
- [Phase 1] Parsed tags: Reviewed-by and Signed-off-by from Douglas Anderson (maintainer)
- [Phase 2] Diff analysis: +3 lines, all EDP_PANEL_ENTRY additions to static const data table
- [Phase 2] Verified delay_200_500_e80 exists at line 1753, delay_200_500_e80_d50 at line 1759
- [Phase 2] Verified EDP_PANEL_ENTRY macro defined at line 1859
- [Phase 2] Verified entries inserted in sorted order (0x0db3 between 0x0d73/0x0ddf, 0x156b between 0x1565/0x162b, 0x1529 after 0x1519)
- [Phase 3] git blame: surrounding entries present from various authors (2024-2025)
- [Phase 3] git log: 68 commits to this file since 2024, very active
- [Phase 3] Verified author has no prior commits; maintainer Douglas Anderson has 10+ commits here
- [Phase 4] b4 dig: could not find commit (not in tree). Lore blocked by Anubis.
- [Phase 5] No functions modified; data table only
- [Phase 6] All referenced structures confirmed present in 7.0 tree; patch applies cleanly
- [Phase 6] 198 existing EDP_PANEL_ENTRY entries confirm the pattern/infrastructure is stable
- UNVERIFIED: Could not read lore discussion thread; however maintainer sign-off provides sufficient confidence
**YES**
drivers/gpu/drm/panel/panel-edp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/panel/panel-edp.c +3 -0
@@ -1999,6 +1999,7 @@ static const struct edp_panel_entry edp_panels[] = {EDP_PANEL_ENTRY ('B' ,'O' ,'E' ,0x0cfa , &delay_200_500_e50,"NV116WHM-A4D" ),EDP_PANEL_ENTRY ('B' ,'O' ,'E' ,0x0d45 , &delay_200_500_e80,"NV116WHM-N4B" ),EDP_PANEL_ENTRY ('B' ,'O' ,'E' ,0x0d73 , &delay_200_500_e80,"NE140WUM-N6S" ), +EDP_PANEL_ENTRY ('B' ,'O' ,'E' ,0x0db3 , &delay_200_500_e80,"NV153WUM-N42" ),EDP_PANEL_ENTRY ('B' ,'O' ,'E' ,0x0ddf , &delay_200_500_e80,"NV116WHM-T01" ), EDP_PANEL_ENTRY('C', 'M', 'N', 0x1130, &delay_200_500_e50, "N116BGE-EB2"),
@@ -2035,6 +2036,7 @@ static const struct edp_panel_entry edp_panels[] = {EDP_PANEL_ENTRY ('C' ,'M' ,'N' ,0x14d6 , &delay_200_500_e80_d50,"N140BGA-EA4" ),EDP_PANEL_ENTRY ('C' ,'M' ,'N' ,0x14e5 , &delay_200_500_e80_d50,"N140HGA-EA1" ),EDP_PANEL_ENTRY ('C' ,'M' ,'N' ,0x1565 , &delay_200_500_e80,"N156HCA-EAB" ), +EDP_PANEL_ENTRY ('C' ,'M' ,'N' ,0x156b , &delay_200_500_e80_d50,"N153JCA-ELK" ),EDP_PANEL_ENTRY ('C' ,'M' ,'N' ,0x162b , &delay_200_500_e80_d50,"N160JCE-ELL" ), EDP_PANEL_ENTRY('C', 'M', 'N', 0x7402, &delay_200_500_e200_d50, "N116BCA-EAK"),
@@ -2053,6 +2055,7 @@ static const struct edp_panel_entry edp_panels[] = {EDP_PANEL_ENTRY ('C' ,'S' ,'W' ,0x146e , &delay_80_500_e50_d50,"MNE007QB3-1" ),EDP_PANEL_ENTRY ('C' ,'S' ,'W' ,0x147c , &delay_200_500_e50_d100,"MNE007QB3-1" ),EDP_PANEL_ENTRY ('C' ,'S' ,'W' ,0x1519 , &delay_200_500_e80_d50,"MNF601BS1-3" ), +EDP_PANEL_ENTRY ('C' ,'S' ,'W' ,0x1529 , &delay_200_500_e80_d50,"MNF307QS3-2" ), EDP_PANEL_ENTRY('E', 'T', 'C', 0x0000, &delay_50_500_e200_d200_po2e335, "LP079QX1-SP0V"),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 drm/amdgpu/userq: remove queue from doorbell xarray
In reply to Sasha LevinFrom: Sunil Khatri <[email protected]>
[ Upstream commit f0e46fd06c3f7590b0f06aea3c877f441c2cbccc ]
In case of failure in xa_alloc, remove the queue during clean up from the userq_doorbell_xa.
---
LLM Generated explanations, may be completely bogus:
Here is my complete analysis:
---
## PHASE 1: COMMIT MESSAGE FORENSICS
**Step 1.1: Subject Line**
- Subsystem: drm/amdgpu/userq
- Action verb: "remove" (corrective: removing a stale entry from data structure on error path)
- Summary: Remove queue from doorbell xarray during cleanup when xa_alloc fails
**Step 1.2: Tags**
- Signed-off-by: Sunil Khatri <[email protected]> - author, regular AMD GPU contributor
- Reviewed-by: Christian König <[email protected]> - AMD GPU subsystem co-maintainer
- Signed-off-by: Alex Deucher <[email protected]> - AMD GPU subsystem maintainer
- No Fixes: tag (expected for manual review candidates)
- No Cc: stable tag
**Step 1.3: Commit Body Analysis**
The message says: "In case of failure in xa_alloc, remove the queue during clean up from the userq_doorbell_xa." This clearly describes a missing cleanup in an error path: the queue gets stored in userq_doorbell_xa but is not removed if the subsequent xa_alloc fails.
**Step 1.4: Hidden Bug Fix Detection**
This is not hidden - it's straightforwardly described as an error path cleanup fix. However, the severity is greater than the commit message suggests. It's actually a **use-after-free**: the queue is freed (kfree(queue)) but its pointer remains in the doorbell xarray.
## PHASE 2: DIFF ANALYSIS
**Step 2.1: Inventory**
- Single file: drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
- 1 line added: xa_erase_irq(&adev->userq_doorbell_xa, index);
- Function modified: amdgpu_userq_create()
- Scope: Single-file surgical fix, error path only
**Step 2.2: Code Flow Change**
In amdgpu_userq_create():
1. Line 863: xa_store_irq(&adev->userq_doorbell_xa, index, queue, GFP_KERNEL) - stores queue in global doorbell xarray
2. Line 870: xa_alloc(&uq_mgr->userq_xa, &qid, queue, ...) - attempts to allocate a queue ID
3. If xa_alloc fails (line 872): error path calls amdgpu_userq_fence_driver_free(), mqd_destroy(), kfree(queue) - but did NOT remove the entry from userq_doorbell_xa
4. Fix adds xa_erase_irq(&adev->userq_doorbell_xa, index) before the kfree
**Step 2.3: Bug Mechanism**
This is a **use-after-free** caused by a missing cleanup on error path. After kfree(queue), the freed pointer remains in userq_doorbell_xa. Six functions in the same file iterate userq_doorbell_xa with xa_for_each() and dereference the queue pointer:
- amdgpu_userq_suspend() (line 1445)
- amdgpu_userq_resume() (line 1471)
- amdgpu_userq_stop_sched_for_enforce_isolation() (line 1501)
- amdgpu_userq_start_sched_for_enforce_isolation() (line 1535)
- amdgpu_userq_pre_reset() (line 1589)
- amdgpu_userq_post_reset() (line 1617)
All would crash or corrupt memory by accessing queue->userq_mgr, queue->state, etc.
**Step 2.4: Fix Quality**
The fix is obviously correct: it mirrors the cleanup in the normal destroy path (amdgpu_userq_cleanup() at line 463 already calls xa_erase_irq(&adev->userq_doorbell_xa, queue->doorbell_index)). The fix uses xa_erase_irq() matching the xa_store_irq() used during insertion. No regression risk.
## PHASE 3: GIT HISTORY
**Step 3.1: Blame**
The buggy error path (xa_alloc failure without doorbell cleanup) was introduced by commit f18719ef4bb7b (Jesse.Zhang, October 2025) which converted IDR to XArray. When the XArray conversion added xa_store_irq(&adev->userq_doorbell_xa, ...) before xa_alloc, the error cleanup for xa_alloc failure was not updated to remove the doorbell entry.
**Step 3.2: Fixes Target**
No Fixes: tag present. The bug was introduced by f18719ef4bb7b.
**Step 3.3: Related Changes**
The companion commit 65b5c326ce410 ("refcount userqueues to avoid race conditions") was cherry-picked with Cc: [email protected], showing this area is actively being stabilized for stable trees.
**Step 3.4: Author**
Sunil Khatri is a regular AMD GPU contributor with 11 commits to this file alone. He also authored the refcount fix.
**Step 3.5: Dependencies**
This fix is standalone - it requires only that the doorbell xarray code (from f18719ef4bb7b) exists, which it does in 7.0.
## PHASE 4: MAILING LIST RESEARCH
The exact commit "remove queue from doorbell xarray" was not found independently on lore.kernel.org. However, the v2 series of the refcount patchset (20260302180852) was a 2-patch series that included related doorbell cleanup work. The patch was reviewed by Christian König (AMD GPU co-maintainer) and committed through Alex Deucher (AMD GPU maintainer).
## PHASE 5: CODE SEMANTIC ANALYSIS
**Step 5.1: Modified Function**amdgpu_userq_create() - creates usermode queues for AMD GPU userspace queue submission.
**Step 5.2: Callers**amdgpu_userq_create() is called from amdgpu_userq_ioctl() via AMDGPU_USERQ_OP_CREATE, which is a DRM IOCTL callable from userspace. This is a user-triggerable code path.
**Step 5.3-5.4: Impact Surface**
The stale entry in userq_doorbell_xa will be accessed by any subsequent suspend, resume, reset, or isolation enforcement operation on the GPU device. These are triggered by:
- System suspend/resume (S3, S0ix) - common laptop operation
- GPU reset (triggered by hang detection)
- Enforce isolation mode changes
## PHASE 6: STABLE TREE ANALYSIS
**Step 6.1: Code in Stable Trees**
The file amdgpu_userq.c was first added in the v6.16/6.17 timeframe. The userq_doorbell_xa was introduced by f18719ef4bb7b in the kernel 7.0 development cycle. This code exists in the 7.0 stable tree.
**Step 6.2: Backport Complexity**
This is a clean 1-line addition with no context conflicts expected.
## PHASE 7: SUBSYSTEM CONTEXT
- Subsystem: drivers/gpu/drm/amd/amdgpu - AMD GPU driver
- Criticality: IMPORTANT - widely used GPU driver on desktop/laptop systems
- Actively developed subsystem with heavy recent churn
## PHASE 8: IMPACT AND RISK ASSESSMENT
**Step 8.1: Who is Affected**
Users with AMD GPUs using the usermode queue feature (GFX/Compute/DMA queues).
**Step 8.2: Trigger Conditions**
The bug requires:
1. A userqueue creation attempt where xa_store_irq succeeds but xa_alloc fails (e.g., hitting AMDGPU_MAX_USERQ_COUNT limit or memory pressure)
2. Followed by any suspend, resume, reset, or isolation operation
The xa_alloc failure can be triggered by resource exhaustion or concurrent queue creation under memory pressure.
**Step 8.3: Failure Mode Severity**
- **CRITICAL**: Use-after-free on freed queue pointer leads to kernel crash (oops/panic), potential memory corruption, or security vulnerability. The freed pointer is dereferenced to access queue->userq_mgr, queue->state, etc.
**Step 8.4: Risk-Benefit Ratio**
- BENEFIT: Very high - prevents UAF crash on a common GPU driver
- RISK: Very low - single line addition, mirrors existing cleanup pattern, obviously correct
- Ratio: Strongly favorable
## PHASE 9: FINAL SYNTHESIS
**Evidence FOR backporting:**
- Fixes a real use-after-free bug (stale pointer in xarray after kfree)
- Single-line fix, surgically targeted to one error path
- Reviewed by Christian König (AMD GPU co-maintainer)
- Obviously correct (mirrors cleanup in normal destroy path)
- Related refcount commit already tagged Cc: stable
- User-triggerable code path (IOCTL)
- Failure mode is kernel crash or memory corruption
**Evidence AGAINST backporting:**
- Relatively new code (userq feature added in v6.16-7.0 timeframe)
- Trigger requires specific failure condition (xa_alloc failure)
**Stable Rules Checklist:**
1. Obviously correct and tested? YES - mirrors existing cleanup, reviewed by maintainer
2. Fixes a real bug? YES - use-after-free
3. Important issue? YES - potential crash, memory corruption, security
4. Small and contained? YES - 1 line added
5. No new features? YES - pure bug fix
6. Can apply to stable? YES - clean 1-line addition
## Verification
- [Phase 1] Parsed tags: Reviewed-by Christian König, Signed-off-by Alex Deucher and Sunil Khatri
- [Phase 2] Diff analysis: 1 line added in xa_alloc error path of amdgpu_userq_create(), adds missing xa_erase_irq() for doorbell xarray
- [Phase 3] git blame: buggy code introduced in f18719ef4bb7b (Oct 2025), XArray conversion commit
- [Phase 3] git show f18719ef4bb7b: confirmed it added xa_store_irq to doorbell_xa without corresponding xa_erase_irq in xa_alloc failure path
- [Phase 3] Related commit 65b5c326ce410 already has Cc: stable (confirmed via git show)
- [Phase 4] b4 dig -c 65b5c326ce410: found patch at
https://patch.msgid.link/[email protected]
- [Phase 4] Mailing list archive: found v2 series and review discussion, Christian König reviewed
- [Phase 5] Grep for userq_doorbell_xa: found 6 xa_for_each iteration sites that would dereference the freed pointer
- [Phase 5] amdgpu_userq_create called from amdgpu_userq_ioctl (user- triggerable via DRM IOCTL)
- [Phase 6] amdgpu_userq.c first added around v6.16, doorbell_xa added in v7.0 cycle
- [Phase 8] Failure mode: UAF -> kernel crash/memory corruption, severity CRITICAL
This is a small, surgical, obviously correct fix for a real use-after- free bug in the AMD GPU driver's error handling path. It was reviewed by the subsystem co-maintainer and carries essentially zero regression risk.
**YES**
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -0
@@ -872,6 +872,7 @@ amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args)if (r) {drm_file_err (uq_mgr->file,"Failed to allocate a queue id\n" );amdgpu_userq_fence_driver_free (queue); +xa_erase_irq (&adev->userq_doorbell_xa, index); uq_funcs->mqd_destroy (queue);kfree (queue); r = -ENOMEM ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 memory: brcmstb_memc: Expand LPDDR4 check to cover for LPDDR5
In reply to Sasha LevinFrom: Florian Fainelli <[email protected]>
[ Upstream commit a969a0835152984a0f556434eafdee0b84213670 ]
The same limitations that apply to LPDDR4 also apply to LPDDR5. Expand the check and rename accordingly.
---
LLM Generated explanations, may be completely bogus:
Now I have enough information to complete the full analysis. Let me compile my findings.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: PARSE THE SUBJECT LINE
- **Subsystem**: memory: brcmstb_memc: (Broadcom STB memory controller driver)
- **Action verb**: "Expand" (extending an existing check)
- **Summary**: Expand LPDDR4 check to also cover LPDDR5 memory types
Record: [memory/brcmstb_memc] [expand] [Extend existing LPDDR4 hardware limitation check to also apply to LPDDR5]
### Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
- **Signed-off-by**: Florian Fainelli <[email protected]> (author, Broadcom employee, original driver author)
- **Link**: https://patch.msgid.link/20260122003501.1191059-1-
[email protected]
- **Signed-off-by**: Krzysztof Kozlowski <[email protected]> (subsystem maintainer who applied it)
- No Fixes: tag, no Cc: stable, no Reported-by, no Tested-by, no Reviewed-by
Record: Author is the original driver author (Florian Fainelli at Broadcom). Applied by memory subsystem maintainer Krzysztof Kozlowski.
### Step 1.3: ANALYZE THE COMMIT BODY TEXT
The message says: "The same limitations that apply to LPDDR4 also apply to LPDDR5. Expand the check and rename accordingly."
The limitation in question: On LPDDR4 chips, the inactivity timeout for Self-Refresh Power Down (SRPD) cannot be changed because the dynamic tuning process is affected by the inactivity timeout, making it non- functional. This same limitation applies to LPDDR5.
Without this fix, on LPDDR5 hardware, a user writing to the srpd sysfs attribute would successfully change the SRPD inactivity timeout, which would break the dynamic tuning process, making the memory controller non-functional.
Record: [Bug: missing LPDDR5 check allows dangerous SRPD timeout modification on LPDDR5 hardware] [Symptom: dynamic memory tuning becomes non-functional on LPDDR5 systems] [Root cause: original code only checked for LPDDR4, not LPDDR5]
### Step 1.4: DETECT HIDDEN BUG FIXES
This IS a real bug fix disguised as "expand." The keyword "expand" masks the fact that without this change, LPDDR5 users can corrupt their memory controller tuning through the sysfs interface.
Record: [Yes, this is a hidden bug fix. It prevents a user from making the dynamic tuning process non-functional on LPDDR5 hardware.]
---
## PHASE 2: DIFF ANALYSIS - LINE BY LINE
### Step 2.1: INVENTORY THE CHANGES
- **File**: drivers/memory/brcmstb_memc.c
- **Lines added**: ~4 (new define, extra condition, rename)
- **Lines removed**: ~3 (old function name, old single condition)
- **Functions modified**: brcmstb_memc_uses_lpddr4 renamed to brcmstb_memc_uses_lpddr45, srpd_store (caller updated)
- **Scope**: Single-file, surgical fix
Record: [1 file changed, ~4 lines added, ~3 removed] [Functions:
brcmstb_memc_uses_lpddr4→brcmstb_memc_uses_lpddr45, srpd_store] [Single- file surgical fix]
### Step 2.2: UNDERSTAND THE CODE FLOW CHANGE **Hunk 1** - Define addition:
- Before: Only CNTRLR_CONFIG_LPDDR4_SHIFT (value 5) defined
- After: Also defines CNTRLR_CONFIG_LPDDR5_SHIFT (value 6)
**Hunk 2** - Function logic change:
- Before: brcmstb_memc_uses_lpddr4() returns true only if register value == 5 (LPDDR4)
- After: brcmstb_memc_uses_lpddr45() returns true if register value == 5 (LPDDR4) OR == 6 (LPDDR5)
**Hunk 3** - Caller update:
- Before: srpd_store() calls brcmstb_memc_uses_lpddr4()
- After: srpd_store() calls brcmstb_memc_uses_lpddr45()
The change affects the srpd_store sysfs path. When a user writes to /sys/.../srpd, the check now correctly blocks the write for both LPDDR4 and LPDDR5.
Record: [Before: LPDDR5 memory allowed dangerous SRPD timeout change.
After: LPDDR5 correctly blocked like LPDDR4.]
### Step 2.3: IDENTIFY THE BUG MECHANISM
This is a **hardware workaround/limitation enforcement** fix. Category
(h) - Hardware workarounds. The hardware has a limitation (LPDDR5 dynamic tuning breaks with SRPD timeout changes) that wasn't enforced in software.
Record: [Hardware workaround - extending existing HW limitation check to cover LPDDR5]
### Step 2.4: ASSESS THE FIX QUALITY
- Obviously correct: Yes. The author is the Broadcom engineer who wrote the driver and knows the hardware limitations.
- Minimal/surgical: Yes. Adds one define, one condition, renames a function.
- Regression risk: Extremely low. The only change is that LPDDR5 systems now return -EOPNOTSUPP from srpd_store, which is the correct behavior. LPDDR4 and other memory types are unaffected.
Record: [Fix is obviously correct, minimal, and low regression risk]
---
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: BLAME THE CHANGED LINES
From git blame, all the relevant code was introduced by Florian Fainelli in commit a4be90ff7a7d2 ("memory: brcmstb_memc: Add Broadcom STB memory controller driver"), first appearing in v6.1-rc1. The buggy code (missing LPDDR5 check) has been present since the driver was introduced.
Record: [Buggy code introduced in a4be90ff7a7d2, merged in v6.1-rc1. Present in all stable trees from 6.1 onward.]
### Step 3.2: FOLLOW THE FIXES TAG
No Fixes: tag present. This is expected.
### Step 3.3: CHECK FILE HISTORY
The file has had minimal changes: initial addition in v6.1, then a few minor cleanups and build fixes. No major refactoring. The patch should apply cleanly or with trivial adjustments to stable trees.
Record: [File has minimal history - 6 commits total. No conflicting changes.]
### Step 3.4: CHECK THE AUTHOR
Florian Fainelli is the original author of this driver and a Broadcom employee who is the de facto maintainer. His fix carries maximum authority for this driver.
Record: [Author is the original driver author and de facto maintainer at Broadcom]
### Step 3.5: CHECK FOR DEPENDENCIES
This is a standalone single-commit fix. No dependencies on other commits.
Record: [Standalone fix, no dependencies]
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
### Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
b4 dig failed to find the commit by message-id (the commit may not be in the local repo since we're on 7.0 and the commit isn't present in HEAD yet). Lore is behind a challenge page. The Link tag points to patch.msg id.link/[email protected].
Record: [Could not access lore discussion due to anti-bot protection. The patch was accepted by maintainer Krzysztof Kozlowski.]
### Step 4.2-4.5: MAILING LIST RESEARCH
Unable to verify via lore due to access restrictions. However, the patch was accepted by the memory subsystem maintainer with no modifications.
Record: [UNVERIFIED: Could not access mailing list discussion. Accepted by maintainer.]
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1: KEY FUNCTIONS
- brcmstb_memc_uses_lpddr4 (renamed to brcmstb_memc_uses_lpddr45)
- srpd_store (caller)
### Step 5.2: TRACE CALLERSbrcmstb_memc_uses_lpddr4 is called only from srpd_store, which is the sysfs write handler for the srpd attribute. This is user- accessible.
Record: [Called from srpd_store sysfs handler - user-triggered path]
### Step 5.3-5.4: CALL CHAIN
User writes to /sys/devices/.../srpd → srpd_store() → brcmstb_memc_uses_lpddr45() reads hardware register → if LPDDR4/5, returns -EOPNOTSUPP.
Record: [User-triggered via sysfs write. Direct path.]
### Step 5.5: SIMILAR PATTERNS
No similar patterns elsewhere - this is the only LPDDR type check in this driver.
Record: [Unique check in this driver]
---
## PHASE 6: CROSS-REFERENCING AND STABLE TREE ANALYSIS
### Step 6.1: DOES THE BUGGY CODE EXIST IN STABLE TREES? The driver was introduced in v6.1-rc1 (commit a4be90ff7a7d2). It exists in:
- 6.1.y (LTS) ✓
- 6.6.y (LTS) ✓
- 6.12.y ✓
- 7.0 ✓
Record: [Buggy code exists in all active stable trees: 6.1.y, 6.6.y, 6.12.y]
### Step 6.2: BACKPORT COMPLICATIONS
The file has had only minor changes across versions. The patch should apply cleanly or with trivial context adjustments.
Record: [Expected clean apply across all stable trees]
### Step 6.3: RELATED FIXES ALREADY IN STABLE
No related fixes for LPDDR5 exist.
Record: [No prior fix for this issue in stable]
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
### Step 7.1: IDENTIFY SUBSYSTEM CRITICALITY
- **Subsystem**: drivers/memory - memory controller drivers
- **Criticality**: PERIPHERAL (specific Broadcom STB hardware) but the consequences of the bug (making dynamic tuning non-functional) are significant for affected users.
Record: [drivers/memory, PERIPHERAL - Broadcom STB specific, but real hardware impact]
### Step 7.2: SUBSYSTEM ACTIVITY
Only 6 commits to this file over its entire existence (since 6.1). Mature and stable code.
Record: [Mature, stable codebase with minimal changes]
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: WHO IS AFFECTED
Users of Broadcom STB SoCs with LPDDR5 memory. This is primarily embedded/set-top-box devices.
Record: [Driver-specific: Broadcom STB users with LPDDR5 memory]
### Step 8.2: TRIGGER CONDITIONS
Triggered when a user (or system script) writes to the srpd sysfs attribute on a system with LPDDR5 memory. On affected systems, the write succeeds (should fail with -EOPNOTSUPP) and the SRPD configuration change breaks the dynamic tuning process.
Record: [Triggered by sysfs write on LPDDR5 systems. Could be triggered by power management scripts.]
### Step 8.3: FAILURE MODE SEVERITY
When triggered, the dynamic tuning process becomes "non-functional" (per the existing code comment). This affects the memory controller's dynamic tuning, which could lead to system instability or incorrect memory timing. Severity: **MEDIUM-HIGH** for affected hardware.
Record: [Memory controller dynamic tuning becomes non-functional.
Severity: MEDIUM-HIGH]
### Step 8.4: RISK-BENEFIT RATIO
- **BENEFIT**: Prevents memory controller misconfiguration on LPDDR5 Broadcom STB systems. Real hardware fix for real users.
- **RISK**: Extremely low. Only adds one additional condition to an existing check. The only behavioral change is that LPDDR5 systems now correctly return -EOPNOTSUPP on SRPD write, matching the existing LPDDR4 behavior.
- **Ratio**: Very favorable. Minimal risk, meaningful benefit for affected hardware.
Record: [High benefit for affected users, minimal risk. Very favorable ratio.]
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: COMPILE THE EVIDENCE
**FOR backporting:**
- Fixes a real hardware limitation enforcement bug on LPDDR5 systems
- Without the fix, users can break dynamic memory tuning on LPDDR5 Broadcom STB hardware
- Extremely small and surgical (adds 1 define, 1 condition, renames function)
- Written by the original driver author (Florian Fainelli at Broadcom)
- Accepted by subsystem maintainer
- Applies cleanly to stable trees (minimal file history)
- Driver exists in all active LTS trees (6.1+)
- Falls into the "hardware quirk/workaround" exception category
- Zero regression risk to existing LPDDR4 or other memory type users
**AGAINST backporting:**
- Affects only Broadcom STB users with LPDDR5 memory (narrow user base)
- No Fixes: tag, no Reported-by (but this is expected for the review pipeline)
- The commit message uses "expand" rather than "fix" language
### Step 9.2: STABLE RULES CHECKLIST
1. **Obviously correct and tested?** YES - single condition addition, by driver author
2. **Fixes a real bug?** YES - allows dangerous SRPD modification on LPDDR5
3. **Important issue?** MEDIUM-HIGH - memory controller misconfiguration
4. **Small and contained?** YES - ~4 lines changed in 1 file
5. **No new features or APIs?** CORRECT - only extends an existing check
6. **Can apply to stable trees?** YES - driver exists since 6.1
### Step 9.3: EXCEPTION CATEGORIES
This falls into the **hardware quirk/workaround** category - extending an existing hardware limitation check to cover newly-recognized hardware.
### Step 9.4: DECISION
The fix is small, surgical, obviously correct, written by the driver author, and prevents real hardware misconfiguration on LPDDR5 Broadcom STB systems. The risk is negligible and the benefit is real for affected users.
---
## Verification
- [Phase 1] Parsed tags: Signed-off-by by Florian Fainelli (driver author), accepted by Krzysztof Kozlowski (maintainer). No Fixes/Reported-by tags.
- [Phase 2] Diff analysis: 1 new #define, 1 additional condition in existing check function, 1 function rename, 1 caller update. Total ~4 lines changed.
- [Phase 3] git blame: All code introduced in commit a4be90ff7a7d2 (v6.1-rc1) by same author (Florian Fainelli).
- [Phase 3] git describe --contains: confirmed driver first appeared in v6.1-rc1.
- [Phase 3] git log v6.1..v6.6..v6.12: confirmed driver exists in all active stable trees.
- [Phase 3] git log --author="Florian Fainelli": confirmed author is original driver author and active maintainer.
- [Phase 3] File history: only 6 commits total, minimal churn, clean backport expected.
- [Phase 5] Code analysis: brcmstb_memc_uses_lpddr4 called only from srpd_store (sysfs write handler), user-triggerable path.
- [Phase 6] Driver exists in 6.1.y, 6.6.y, 6.12.y stable trees.
- [Phase 8] Failure mode: dynamic tuning becomes non-functional on LPDDR5 systems. Severity MEDIUM-HIGH.
- UNVERIFIED: Could not access lore.kernel.org discussion due to anti- bot protection. Relied on maintainer acceptance and commit tags.
**YES**
drivers/memory/brcmstb_memc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/memory/brcmstb_memc.c +5 -3
@@ -14,6 +14,7 @@#define REG_MEMC_CNTRLR_CONFIG 0x00#define CNTRLR_CONFIG_LPDDR4_SHIFT 5 +#define CNTRLR_CONFIG_LPDDR5_SHIFT 6#define CNTRLR_CONFIG_MASK 0xf#define REG_MEMC_SRPD_CFG_21 0x20#define REG_MEMC_SRPD_CFG_20 0x34
@@ -34,14 +35,15 @@ struct brcmstb_memc {u32 srpd_offset; }; -static int brcmstb_memc_uses_lpddr4 (struct brcmstb_memc *memc) +static int brcmstb_memc_uses_lpddr45 (struct brcmstb_memc *memc) {void __iomem *config = memc->ddr_ctrl +REG_MEMC_CNTRLR_CONFIG ;u32 reg; reg =readl_relaxed (config) &CNTRLR_CONFIG_MASK ; -return reg ==CNTRLR_CONFIG_LPDDR4_SHIFT ; +return reg ==CNTRLR_CONFIG_LPDDR4_SHIFT || + reg ==CNTRLR_CONFIG_LPDDR5_SHIFT ; } static int brcmstb_memc_srpd_config(struct brcmstb_memc *memc,
@@ -95,7 +97,7 @@ static ssize_t srpd_store(struct device *dev, struct device_attribute *attr,* dynamic tuning process will also get affected by the inactivity * timeout, thus making it non functional. */ -if (brcmstb_memc_uses_lpddr4 (memc)) +if (brcmstb_memc_uses_lpddr45 (memc))return -EOPNOTSUPP ; ret =kstrtouint (buf,10 , &val);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 nouveau: pci: quiesce GPU on shutdown
In reply to Sasha LevinFrom: Li Chen <[email protected]>
[ Upstream commit 310326bb7df4bba094a3fc60364c641c547fd923 ]
Kexec reboot does not reset PCI devices.
Invoking the full DRM/TTM teardown from ->shutdown can trigger WARNs when userspace still holds DRM file descriptors.
Quiesce the GPU through the suspend path and then power down the PCI function so the next kernel can re-initialize the device from a consistent state.
WARNING: drivers/gpu/drm/drm_mode_config.c:578 at drm_mode_config_cleanup+0x2e7/0x300, CPU#2: kexec/1300 Call Trace: <TASK> ? srso_return_thunk+0x5/0x5f ? enable_work+0x3a/0x100 nouveau_display_destroy+0x39/0x70 [nouveau c19e0da7fd83583a023f855c510d9a3903808734] nouveau_drm_device_fini+0x7b/0x1f0 [nouveau c19e0da7fd83583a023f855c510d9a3903808734] nouveau_drm_shutdown+0x52/0xc0 [nouveau c19e0da7fd83583a023f855c510d9a3903808734] pci_device_shutdown+0x35/0x60 device_shutdown+0x11c/0x1b0 kernel_kexec+0x13a/0x160 __do_sys_reboot+0x209/0x240 do_syscall_64+0x81/0x610 ? srso_return_thunk+0x5/0x5f ? __rtnl_unlock+0x37/0x70 ? srso_return_thunk+0x5/0x5f ? netdev_run_todo+0x63/0x570 ? netif_change_flags+0x54/0x70 ? srso_return_thunk+0x5/0x5f ? devinet_ioctl+0x1e5/0x790 ? srso_return_thunk+0x5/0x5f ? inet_ioctl+0x1e9/0x200 ? srso_return_thunk+0x5/0x5f ? srso_return_thunk+0x5/0x5f ? sock_do_ioctl+0x7d/0x130 ? srso_return_thunk+0x5/0x5f ? __x64_sys_ioctl+0x97/0xe0 ? srso_return_thunk+0x5/0x5f ? srso_return_thunk+0x5/0x5f ? do_syscall_64+0x23b/0x610 ? srso_return_thunk+0x5/0x5f ? put_user_ifreq+0x7a/0x90 ? srso_return_thunk+0x5/0x5f ? sock_do_ioctl+0x107/0x130 ? srso_return_thunk+0x5/0x5f ? __x64_sys_ioctl+0x97/0xe0 ? srso_return_thunk+0x5/0x5f ? do_syscall_64+0x81/0x610 ? srso_return_thunk+0x5/0x5f ? exc_page_fault+0x7e/0x1a0 entry_SYSCALL_64_after_hwframe+0x76/0x7e
nouveau 0000:26:00.0: [drm] drm_WARN_ON(!list_empty(&fb->filp_head))
WARNING: drivers/gpu/drm/drm_framebuffer.c:833 at drm_framebuffer_free+0x73/0xa0, CPU#2: kexec/1300 Call Trace: <TASK> drm_mode_config_cleanup+0x248/0x300 ? __pfx___drm_printfn_dbg+0x10/0x10 ? drm_mode_config_cleanup+0x1dc/0x300 nouveau_display_destroy+0x39/0x70 [nouveau c19e0da7fd83583a023f855c510d9a3903808734] nouveau_drm_device_fini+0x7b/0x1f0 [nouveau c19e0da7fd83583a023f855c510d9a3903808734] nouveau_drm_shutdown+0x52/0xc0 [nouveau c19e0da7fd83583a023f855c510d9a3903808734] pci_device_shutdown+0x35/0x60 device_shutdown+0x11c/0x1b0 kernel_kexec+0x13a/0x160 __do_sys_reboot+0x209/0x240 do_syscall_64+0x81/0x610 ? srso_return_thunk+0x5/0x5f ? __rtnl_unlock+0x37/0x70 ? srso_return_thunk+0x5/0x5f ? netdev_run_todo+0x63/0x570 ? netif_change_flags+0x54/0x70 ? srso_return_thunk+0x5/0x5f ? devinet_ioctl+0x1e5/0x790 ? srso_return_thunk+0x5/0x5f ? inet_ioctl+0x1e9/0x200 ? srso_return_thunk+0x5/0x5f ? srso_return_thunk+0x5/0x5f ? sock_do_ioctl+0x7d/0x130 ? srso_return_thunk+0x5/0x5f ? __x64_sys_ioctl+0x97/0xe0 ? srso_return_thunk+0x5/0x5f ? srso_return_thunk+0x5/0x5f ? do_syscall_64+0x23b/0x610 ? srso_return_thunk+0x5/0x5f ? put_user_ifreq+0x7a/0x90 ? srso_return_thunk+0x5/0x5f ? sock_do_ioctl+0x107/0x130 ? srso_return_thunk+0x5/0x5f ? __x64_sys_ioctl+0x97/0xe0 ? srso_return_thunk+0x5/0x5f ? do_syscall_64+0x81/0x610 ? srso_return_thunk+0x5/0x5f ? exc_page_fault+0x7e/0x1a0 entry_SYSCALL_64_after_hwframe+0x76/0x7e WARNING: include/drm/ttm/ttm_resource.h:406 at nouveau_ttm_fini+0x257/0x270 [nouveau], CPU#2: kexec/1300 Call Trace: <TASK> nouveau_drm_device_fini+0x93/0x1f0 [nouveau c19e0da7fd83583a023f855c510d9a3903808734] nouveau_drm_shutdown+0x52/0xc0 [nouveau c19e0da7fd83583a023f855c510d9a3903808734] pci_device_shutdown+0x35/0x60 device_shutdown+0x11c/0x1b0 kernel_kexec+0x13a/0x160 __do_sys_reboot+0x209/0x240 do_syscall_64+0x81/0x610 ? srso_return_thunk+0x5/0x5f ? __rtnl_unlock+0x37/0x70 ? srso_return_thunk+0x5/0x5f ? netdev_run_todo+0x63/0x570 ? netif_change_flags+0x54/0x70 ? srso_return_thunk+0x5/0x5f ? devinet_ioctl+0x1e5/0x790 ? srso_return_thunk+0x5/0x5f ? inet_ioctl+0x1e9/0x200 ? srso_return_thunk+0x5/0x5f ? srso_return_thunk+0x5/0x5f ? sock_do_ioctl+0x7d/0x130 ? srso_return_thunk+0x5/0x5f ? __x64_sys_ioctl+0x97/0xe0 ? srso_return_thunk+0x5/0x5f ? srso_return_thunk+0x5/0x5f ? do_syscall_64+0x23b/0x610 ? srso_return_thunk+0x5/0x5f ? put_user_ifreq+0x7a/0x90 ? srso_return_thunk+0x5/0x5f ? sock_do_ioctl+0x107/0x130 ? srso_return_thunk+0x5/0x5f ? __x64_sys_ioctl+0x97/0xe0 ? srso_return_thunk+0x5/0x5f ? do_syscall_64+0x81/0x610 ? srso_return_thunk+0x5/0x5f ? exc_page_fault+0x7e/0x1a0 entry_SYSCALL_64_after_hwframe+0x76/0x7e
---
LLM Generated explanations, may be completely bogus:
Now I have all the information needed. Let me compile the full analysis.
---
## PHASE 1: COMMIT MESSAGE FORENSICS
### Step 1.1: PARSE THE SUBJECT LINE
- **Subsystem**: nouveau: pci: (Nouveau GPU driver, PCI subsystem)
- **Action verb**: "quiesce" - implies bringing hardware to a quiet/consistent state, a hardware management fix
- **Summary**: Quiesce the NVIDIA GPU on PCI shutdown to handle kexec reboot properly
Record: [nouveau: pci] [quiesce] [Add proper GPU shutdown handler for kexec reboot]
### Step 1.2: PARSE ALL COMMIT MESSAGE TAGS
- **Signed-off-by: Li Chen <[email protected]>** - the author
- **Reviewed-by: Dave Airlie <[email protected]>** - DRM maintainer reviewed it
- **Signed-off-by: Dave Airlie <[email protected]>** - DRM maintainer also signed off (committed it)
- **Link:**
https://patch.msgid.link/[email protected] - the v2 submission
No Fixes: tag, no Cc: stable tag, no Reported-by. The absence of these is expected.
Record: Reviewed-by and Signed-off-by from Dave Airlie (DRM maintainer) is a strong quality signal.
### Step 1.3: ANALYZE THE COMMIT BODY TEXT
The commit describes two problems:
1. **Problem 1**: Kexec reboot does not reset PCI devices, so without a shutdown handler, the GPU hardware remains in an unknown state after kexec.
2. **Problem 2**: Doing a full DRM/TTM teardown from ->shutdown triggers WARNs when userspace still holds DRM file descriptors.
Three stack traces are provided showing WARNING triggers at:
- drm_mode_config_cleanup+0x2e7/0x300 (drm_mode_config.c:578)
- drm_framebuffer_free+0x73/0xa0 (drm_framebuffer.c:833) - drm_WARN_ON(!list_empty(&fb->filp_head))
- nouveau_ttm_fini+0x257/0x270 (ttm_resource.h:406)
All triggered through the path: kernel_kexec -> device_shutdown -> pci_device_shutdown -> nouveau_drm_shutdown -> nouveau_drm_device_fini
**Solution**: Use the suspend path (which properly handles open userspace FDs) instead of full teardown, then power down the PCI function to D3hot.
Record: [Bug: GPU not properly quiesced during kexec reboot, causing WARNs and potential GPU init failures in next kernel] [Symptom: multiple kernel WARNINGs during kexec shutdown] [Root cause: Missing .shutdown callback, and naive full-teardown approach triggers WARNs with open FDs]
### Step 1.4: DETECT HIDDEN BUG FIXES
This is an overt bug fix. The commit directly addresses kernel WARNINGs and ensures proper GPU quiescing during kexec. It's a hardware workaround for the fact that kexec doesn't reset PCI devices.
Record: Not a hidden bug fix - this is an explicit fix for kernel WARNINGs and kexec reliability.
---
## PHASE 2: DIFF ANALYSIS - LINE BY LINE
### Step 2.1: INVENTORY THE CHANGES
- **Files changed**: drivers/gpu/drm/nouveau/nouveau_drm.c (1 file)
- **Lines added**: ~32 lines (new function + 1 line to hook it up)
- **Lines removed**: 0
- **Functions modified**: None modified; one new function nouveau_drm_shutdown() added
- **Scope**: Single-file, purely additive change
Record: [1 file, +32/-0 lines] [New function nouveau_drm_shutdown(), struct pci_driver updated] [Scope: single-file surgical addition]
### Step 2.2: UNDERSTAND THE CODE FLOW CHANGE
**Before**: nouveau_drm_pci_driver has no .shutdown callback. During kexec, pci_device_shutdown() does nothing for nouveau, leaving the GPU in an unknown hardware state.
**After**: nouveau_drm_shutdown() is called during PCI device shutdown. It:
1. Checks if drm is NULL (safety check)
2. Checks if power is already off (switcheroo check, matching suspend pattern)
3. Calls nouveau_do_suspend(drm, false) to quiesce the GPU through the proven suspend path
4. Calls pci_save_state, pci_disable_device, pci_set_power_state(PCI_D3hot) to power down PCI
5. Calls usleep_range(200, 400) to allow PCI power transition to settle (mirrors udelay(200) in nouveau_pmops_suspend)
Record: [Before: no shutdown handler -> GPU left in unknown state during kexec] [After: proper suspend-based quiescing + PCI power down]
### Step 2.3: IDENTIFY THE BUG MECHANISM
This is a **hardware workaround** fix. Category: **Missing shutdown handler causing kernel WARNINGs and potential GPU initialization failures**.
The fix closely mirrors nouveau_pmops_suspend():
```1034:1053:drivers/gpu/drm/nouveau/nouveau_drm.c
nouveau_pmops_suspend(struct device *dev)
{
struct pci_dev *pdev = to_pci_dev(dev);
struct nouveau_drm *drm = pci_get_drvdata(pdev);
// ... same pattern: do_suspend, pci_save_state,
pci_disable_device, pci_set_power_state, udelay
```Record: [Category: Missing shutdown handler / hardware quiescing] [Mechanism: PCI device not properly quiesced before kexec, leading to inconsistent GPU state and WARNs if full teardown attempted]
### Step 2.4: ASSESS THE FIX QUALITY
- **Obviously correct**: Yes - it mirrors the well-tested suspend path exactly, using nouveau_do_suspend() which is the proven way to quiesce the GPU
- **Minimal/surgical**: Yes - purely additive, touches one file, doesn't modify existing code
- **Regression risk**: Very low - adds a new callback that reuses existing proven infrastructure
- **Red flags**: None. The function is self-contained and uses well- established APIs
Record: [Fix quality: Excellent. Reuses proven suspend path. Purely additive.] [Regression risk: Very low - new callback, no modification to existing paths]
---
## PHASE 3: GIT HISTORY INVESTIGATION
### Step 3.1: BLAME THE CHANGED LINES
The PCI driver struct (nouveau_drm_pci_driver) was created in commit 9458029940ffc6 by Ben Skeggs (2012-07-06). It has never had a .shutdown handler. This means the bug has existed since the nouveau driver was first created - the GPU has never been properly quiesced on PCI shutdown.
Record: [PCI driver struct created 2012 (v3.6 era), never had .shutdown] [Bug present since nouveau's inception]
### Step 3.2: FOLLOW THE FIXES: TAG
No Fixes: tag present (expected for autosel candidates).
Record: [No Fixes: tag - expected]
### Step 3.3: CHECK FILE HISTORY FOR RELATED CHANGES
Recent commits to nouveau_drm.c include 8f8a4dce64013 ("nouveau: add a third state to the fini handler") which changed nvif_client_suspend to take a bool runtime parameter. However, this doesn't affect the new nouveau_drm_shutdown function, which calls nouveau_do_suspend(drm, false) - and nouveau_do_suspend's external interface (struct nouveau_drm *, bool) has been stable since at least 2014.
Record: [Related commit 8f8a4dce64013 changes internals of nouveau_do_suspend but not its interface] [No prerequisites needed for this patch]
### Step 3.4: CHECK THE AUTHOR'S OTHER COMMITS
Li Chen has no other commits to the nouveau driver. However, the patch was reviewed and signed off by Dave Airlie, who is the DRM maintainer and a major contributor to nouveau.
Record: [Author: Li Chen (new contributor to nouveau)] [Reviewer: Dave Airlie (DRM maintainer) - strong endorsement]
### Step 3.5: CHECK FOR DEPENDENT/PREREQUISITE COMMITS The patch is completely standalone:
- It adds a new function using only existing stable APIs (nouveau_do_suspend, PCI helpers, usleep_range)
- It adds a single struct field assignment (.shutdown = nouveau_drm_shutdown)
- No modifications to existing functions
Record: [No dependencies. Fully standalone. All APIs used are long- standing.]
---
## PHASE 4: MAILING LIST AND EXTERNAL RESEARCH
### Step 4.1: FIND THE ORIGINAL PATCH DISCUSSION
Found the full discussion on dri-devel mailing list:
- **v1**: Jan 20, 2026 - Initial submission without comment on usleep_range
- **v2**: Jan 21, 2026 - Added comment explaining usleep_range, gained Reviewed-by from Dave Airlie
- **Applied**: Feb 9, 2026 - Dave Airlie applied to drm-misc-next targeting 7.1
Dave Airlie's v1 review asked "Why is this [usleep_range] needed? it at least needs a comment." After Li Chen explained, Dave gave `Reviewed-by:
Dave Airlie <[email protected]>` on v1 with the comment addition, and the v2 with the comment was applied.
Record: [v1 and v2 submitted] [Dave Airlie reviewed, requested comment on usleep_range] [Applied to drm-misc-next targeting 7.1] [No NAKs or concerns]
### Step 4.2: CHECK WHO REVIEWED THE PATCH
CC'd: Dave Airlie, Lyude Paul, Danilo Krummrich, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Simona Vetter, dri-devel, nouveau, linux-kernel. All appropriate maintainers were included.
Record: [All DRM/nouveau maintainers were CC'd] [Dave Airlie (DRM maintainer) reviewed]
### Step 4.3: SEARCH FOR THE BUG REPORT
The commit itself contains the bug report in the form of stack traces. The author hit this during kexec reboot with nouveau hardware. No separate bug report found.
Record: [Author-reported bug with full stack traces in commit message]
### Step 4.4: CHECK FOR RELATED PATCHES AND SERIES
This is a standalone single-patch submission (not part of a series).
Record: [Standalone single patch, no series]
### Step 4.5: CHECK STABLE MAILING LIST HISTORY
No specific stable discussion found. Dave Airlie noted it targets 7.1, but no explicit discussion about stable backporting.
Record: [No stable-specific discussion found]
---
## PHASE 5: CODE SEMANTIC ANALYSIS
### Step 5.1: IDENTIFY KEY FUNCTIONS IN THE DIFF
- nouveau_drm_shutdown() (new function)
- References: nouveau_do_suspend(), PCI helpers
### Step 5.2: TRACE CALLERSnouveau_drm_shutdown() is called from pci_device_shutdown() (PCI core) via the .shutdown function pointer. This is triggered during:
- kernel_kexec() -> device_shutdown() -> pci_device_shutdown()
- kernel_restart() -> device_shutdown() -> pci_device_shutdown()
- kernel_power_off() -> device_shutdown() -> pci_device_shutdown()
Record: [Called from PCI core during system shutdown/kexec/restart] [Affects all nouveau users during kexec]
### Step 5.3: TRACE CALLEES
The function calls:
1. pci_get_drvdata() - get driver data
2. nouveau_do_suspend(drm, false) - the main GPU quiescing function, proven by years of suspend/resume usage
3. pci_save_state(), pci_disable_device(), pci_set_power_state() - standard PCI power management
4. usleep_range() - kernel delay function
Record: [All callees are well-established, well-tested functions]
### Step 5.4: FOLLOW THE CALL CHAINkernel_kexec() -> device_shutdown() -> pci_device_shutdown() -> nouveau_drm_shutdown() -> nouveau_do_suspend() -> suspends display, evicts VRAM, idles channels, suspends fences, suspends object tree
This is a critical path for kexec reliability. Without proper GPU quiescing, the GPU may continue DMA operations after kexec, potentially corrupting the new kernel's memory.
Record: [Reachable via kexec syscall - a real user operation] [Critical for system reliability during kexec]
### Step 5.5: SEARCH FOR SIMILAR PATTERNS
Both amdgpu and xe (Intel) drivers have .shutdown handlers. This is a well-established pattern for GPU PCI drivers. Nouveau was the notable omission.
Record: [amdgpu, xe, and many other DRM drivers have .shutdown handlers
- nouveau was missing one]
---
## PHASE 6: CROSS-REFERENCING AND STABLE TREE ANALYSIS
### Step 6.1: DOES THE BUGGY CODE EXIST IN STABLE TREES?
The nouveau_drm_pci_driver struct without .shutdown has existed since kernel 3.6 (2012). This bug affects ALL stable trees. The nouveau driver exists in all active stable trees.
Record: [Bug exists in ALL stable trees - nouveau has never had a .shutdown handler]
### Step 6.2: CHECK FOR BACKPORT COMPLICATIONS
The patch adds code between nouveau_pmops_resume and nouveau_pmops_freeze, and adds .shutdown to the pci_driver struct. Both areas have been stable for years (blame shows 2012 era). The patch should apply cleanly to all stable trees.
One minor consideration: in stable trees without commit 8f8a4dce64013, nouveau_do_suspend internally calls nvif_client_suspend(&drm->_client) (without the bool parameter). However, this doesn't affect the new function at all - it only calls nouveau_do_suspend(drm, false), and the nouveau_do_suspend interface has been stable since 2014.
Record: [Expected: clean apply to all stable trees] [No conflicts anticipated]
### Step 6.3: CHECK IF RELATED FIXES ARE ALREADY IN STABLE No related fix exists in any stable tree. Nouveau has never had a .shutdown handler.
Record: [No related fixes in stable]
---
## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT
### Step 7.1: IDENTIFY THE SUBSYSTEM AND ITS CRITICALITY
- **Subsystem**: drivers/gpu/drm/nouveau/ - NVIDIA GPU driver
- **Criticality**: IMPORTANT - nouveau is the open-source driver for all NVIDIA GPUs, widely used in Linux distributions
Record: [Subsystem: nouveau/DRM GPU driver] [Criticality: IMPORTANT - widely used GPU driver]
### Step 7.2: ASSESS SUBSYSTEM ACTIVITY
The nouveau driver is actively developed with recent commits for GB10x/GB20x/GH100 support, GSP-RM support, etc.
Record: [Actively maintained subsystem]
---
## PHASE 8: IMPACT AND RISK ASSESSMENT
### Step 8.1: DETERMINE WHO IS AFFECTED
All users with NVIDIA GPUs using the nouveau driver who perform kexec reboots. This includes:
- Systems using kexec for fast reboots
- Systems using kdump for crash dump collection
- Systems using KHO/LUO (Kernel Handover)
- Enterprise and data center environments that rely on kexec
Record: [Affected: All nouveau users performing kexec/kdump] [Subsystem- specific but affects a large user base]
### Step 8.2: DETERMINE THE TRIGGER CONDITIONS
- **Trigger**: Performing a kexec reboot on a system with a nouveau- driven NVIDIA GPU
- **How common**: Kexec is commonly used in server environments, kdump configurations, and development workflows
- **Unprivileged**: No - kexec requires root/CAP_SYS_BOOT
Record: [Triggered by kexec reboot with nouveau GPU] [Moderately common trigger for server/dev environments]
### Step 8.3: DETERMINE THE FAILURE MODE SEVERITY
When the bug triggers:
1. **Without any shutdown handler (current state)**: GPU hardware left in unknown state after kexec. The next kernel may fail to initialize the GPU, or the GPU may continue DMA into the new kernel's memory (potential memory corruption/crash). Severity: **HIGH**
2. **With naive full-teardown shutdown handler**: Multiple kernel WARNINGs triggered (drm_mode_config_cleanup, drm_framebuffer_free, nouveau_ttm_fini). Severity: **MEDIUM- HIGH** (WARNs, potential instability)
Record: [Failure mode: GPU init failure in kexec'd kernel + kernel WARNINGs] [Severity: HIGH]
### Step 8.4: CALCULATE RISK-BENEFIT RATIO
- **BENEFIT**: Prevents GPU initialization failures and kernel WARNINGs during kexec. Ensures GPU is in a consistent state for the next kernel. Enables proper kdump operation.
- **RISK**: Very low. ~32 lines of purely additive code. Uses proven suspend infrastructure. Reviewed by DRM maintainer. Cannot affect non- shutdown paths.
Record: [Benefit: HIGH - prevents kexec failures and WARNs] [Risk: VERY LOW - additive, reuses proven code, DRM maintainer review] [Ratio:
Strongly favorable]
---
## PHASE 9: FINAL SYNTHESIS
### Step 9.1: COMPILE THE EVIDENCE
**Evidence FOR backporting:**
- Fixes real kernel WARNINGs with concrete stack traces
- Prevents GPU initialization failures after kexec (potential for DMA corruption)
- Purely additive, small (~32 lines), single-file change
- Reuses proven nouveau_do_suspend() suspend path
- Follows the same pattern as nouveau_pmops_suspend() and other GPU drivers (amdgpu, xe)
- Reviewed and signed off by Dave Airlie (DRM maintainer)
- No dependencies on other patches
- Should apply cleanly to all stable trees
- Bug has existed since nouveau's creation (2012)
- Fills a gap - nouveau was one of the few major GPU drivers without .shutdown
**Evidence AGAINST backporting:**
- No explicit Cc: [email protected] tag
- No Fixes: tag
- Author applied it to drm-misc-next (targeting 7.1), not stable
**UNRESOLVED QUESTIONS:**
- None significant - all aspects verified
### Step 9.2: APPLY THE STABLE RULES CHECKLIST
1. **Obviously correct and tested?** YES - mirrors proven suspend path, reviewed by DRM maintainer
2. **Fixes a real bug?** YES - kernel WARNINGs + GPU initialization failures during kexec
3. **Important issue?** YES - system warnings, potential GPU DMA corruption, kexec/kdump reliability
4. **Small and contained?** YES - 32 lines, 1 file, purely additive
5. **No new features or APIs?** CORRECT - no new features, just a missing shutdown handler
6. **Can apply to stable trees?** YES - standalone, uses stable APIs
### Step 9.3: CHECK FOR EXCEPTION CATEGORIES
This could be classified as a **hardware workaround** (ensuring GPU is properly quiesced before kexec), which is an allowed exception category.
### Step 9.4: MAKE YOUR DECISION
The evidence strongly supports backporting. This is a small, well- contained fix that prevents real kernel WARNINGs and potential GPU initialization failures during kexec. It reuses proven suspend infrastructure, was reviewed by the DRM maintainer, and has no dependencies. The risk is very low and the benefit is significant for anyone using kexec/kdump with NVIDIA hardware.
---
## Verification
- [Phase 1] Parsed tags: Reviewed-by Dave Airlie (DRM maintainer), Link to patch.msgid.link
- [Phase 2] Diff analysis: 32 lines added in one file. New nouveau_drm_shutdown() function + .shutdown hook in pci_driver struct. Purely additive.
- [Phase 2] Code comparison: New function mirrors nouveau_pmops_suspend() (lines 1034-1053 of current tree) with matching pattern of do_suspend + PCI power management
- [Phase 3] git blame: nouveau_drm_pci_driver struct created 2012 (commit 9458029940ffc6), never had .shutdown - bug present since inception
- [Phase 3] Related commit 8f8a4dce64013 changes nouveau_do_suspend internals but not its interface - no conflict with this patch
- [Phase 3] No prerequisites found - patch is standalone
- [Phase 4] Mailing list: v1 submitted Jan 20, v2 with comment on usleep_range submitted Jan 21, Dave Airlie reviewed and applied Feb 9 to drm-misc-next targeting 7.1
- [Phase 4] Dave Airlie explicitly gave Reviewed-by after reviewing v1 and requesting a comment addition
- [Phase 4] No NAKs or concerns raised by any reviewer
- [Phase 5] nouveau_drm_shutdown() called from pci_device_shutdown() during kexec/restart/poweroff - standard PCI driver shutdown path
- [Phase 5] Both amdgpu and xe (Intel) GPU drivers have .shutdown handlers - nouveau was the outlier
- [Phase 6] Bug exists in all stable trees - nouveau has never had a .shutdown handler
- [Phase 6] Patch expected to apply cleanly - nouveau_do_suspend(struct nouveau_drm *, bool) interface stable since 2014
- [Phase 8] Failure mode: kernel WARNINGs + potential GPU init failure after kexec. Severity: HIGH
- [Phase 8] Risk: Very low - purely additive, uses proven code paths
**YES**
drivers/gpu/drm/nouveau/nouveau_drm.c | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
drivers/gpu/drm/nouveau/nouveau_drm.c +32 -0
@@ -1079,6 +1079,37 @@ nouveau_pmops_resume(struct device *dev)return ret; } +static void +nouveau_drm_shutdown (struct pci_dev *pdev) +{ +struct nouveau_drm *drm =pci_get_drvdata (pdev); +int ret; + +if (!drm) +return ; + +if (drm->dev->switch_power_state ==DRM_SWITCH_POWER_OFF || + drm->dev->switch_power_state ==DRM_SWITCH_POWER_DYNAMIC_OFF ) +return ; + + ret =nouveau_do_suspend (drm, false); +if (ret) +NV_ERROR (drm,"shutdown suspend failed with: %d\n" , ret); + +pci_save_state (pdev); +pci_disable_device (pdev); +pci_set_power_state (pdev, PCI_D3hot); +/* +* This is just to give the pci power transition time to settle +* before an immediate kexec jump. it’s mirroring the existing +* nouveau_pmops_suspend() behavior, which already does +* udelay(200) right after pci_set_power_state(..., pci_d3hot). In +* ->shutdown() we’re allowed to sleep, so I used usleep_range() +* instead of a busy-wait udelay(). +*/ +usleep_range (200 ,400 ); +} +static int nouveau_pmops_freeze (struct device *dev) {
@@ -1408,6 +1439,7 @@ nouveau_drm_pci_driver = { .id_table = nouveau_drm_pci_table, .probe = nouveau_drm_probe, .remove = nouveau_drm_remove, + .shutdown = nouveau_drm_shutdown, .driver.pm = &nouveau_pm_ops, };
Signature · 1 line
2.53.0