functionfs: fix the open/removal races
Subsystems (6)
Sasha Levin
maintainerPATCH 1/1 functionfs: fix the open/removal races
From: Al Viro <[email protected]>
[ Upstream commit e5bf5ee266633cb18fff6f98f0b7d59a62819eee ]
ffs_epfile_open() can race with removal, ending up with file->private_data pointing to freed object.
There is a total count of opened files on functionfs (both ep0 and dynamic ones) and when it hits zero, dynamic files get removed. Unfortunately, that removal can happen while another thread is in ffs_epfile_open(), but has not incremented the count yet. In that case open will succeed, leaving us with UAF on any subsequent read() or write().
The root cause is that ffs->opened is misused; atomic_dec_and_test() vs. atomic_add_return() is not a good idea, when object remains visible all along.
To untangle that
* serialize openers on ffs->mutex (both for ep0 and for dynamic files)
* have dynamic ones use atomic_inc_not_zero() and fail if we had
zero ->opened; in that case the file we are opening is doomed.
* have the inodes of dynamic files marked on removal (from the
callback of simple_recursive_removal()) - clear ->i_private there.
* have open of dynamic ones verify they hadn't been already removed,
along with checking that state is FFS_ACTIVE.
---
LLM Generated explanations, may be completely bogus:
## Summary
### What the Commit Fixes
This commit fixes a **Use-After-Free (UAF)** vulnerability in USB gadget functionfs. The race condition occurs between ffs_epfile_open() and file removal:
1. Thread A is in ffs_epfile_open() but hasn't incremented ffs->opened yet
2. Thread B closes the last file handle, triggering removal (since opened is 0)
3. Thread A's open succeeds with file->private_data pointing to freed memory
4. Subsequent read()/write() operations cause UAF
### Fix Mechanism
The fix implements proper synchronization:
- Serializes openers using ffs->mutex
- Uses atomic_inc_not_zero() to fail if counter already zero
- Uses smp_load_acquire()/smp_store_release() for memory ordering
- Clears i_private during removal via simple_recursive_removal() callback
- Uses file->private_data instead of inode->i_private in release path
### Stable Kernel Criteria Assessment
| Criterion | Assessment | |-----------|------------| | Obviously correct | ✅ Uses standard kernel primitives, proper locking patterns | | Fixes real bug | ✅ UAF vulnerability, security-relevant | | Important issue | ✅ Security bug, potential for crashes/exploitation | | Small and contained | ✅ Single file, +43/-10 lines, localized changes | | No new features | ✅ Pure bug fix, no new APIs |
### Risk vs Benefit
**Benefits:**
- Fixes serious UAF vulnerability
- USB gadget functionfs used in Android, embedded systems
- Reviewed by Greg Kroah-Hartman (USB maintainer, stable maintainer)
- Written by Al Viro (highly respected kernel developer)
**Risks:**
- Moderate complexity (changes locking behavior)
- Recent commit (November 2025), limited mainline soak time
- No explicit Cc: [email protected] tag
### Dependencies
- ffs_mutex_lock() - exists in functionfs since early versions
- simple_recursive_removal() with callback - available since ~5.x kernels
- Standard kernel APIs (atomic_inc_not_zero, memory barriers) - universally available
### Concerns
1. **No Fixes: tag** - Makes it harder to determine which stable trees need this fix
2. **No Cc: stable tag** - May indicate maintainers wanted soak time, or an oversight given Greg KH reviewed it
3. **Backport effort** - May need adjustment for older stable trees depending on functionfs evolution
### Conclusion
This is a legitimate UAF security fix that affects real-world users (Android, embedded USB gadgets). Despite moderate complexity, the fix:
- Addresses a serious vulnerability class (UAF)
- Uses correct synchronization patterns
- Has been reviewed by the appropriate maintainer who also maintains stable trees
- Is self-contained with no feature additions
The lack of explicit stable tags appears to be an oversight given the security nature of the bug and Greg KH's review. UAF vulnerabilities typically warrant expedited backporting.
**YES**
drivers/usb/gadget/function/f_fs.c | 53 ++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 10 deletions(-)
drivers/usb/gadget/function/f_fs.c +43 -10
@@ -640,13 +640,22 @@ static ssize_t ffs_ep0_read(struct file *file, char __user *buf,static int ffs_ep0_open (struct inode *inode,struct file *file) { -struct ffs_data *ffs = inode->i_private; +struct ffs_data *ffs = inode->i_sb->s_fs_info; +int ret; -if (ffs->state ==FFS_CLOSING ) -return -EBUSY ; +/* Acquire mutex */ + ret =ffs_mutex_lock (&ffs->mutex, file->f_flags &O_NONBLOCK ); +if (ret <0 ) +return ret; - file->private_data = ffs;ffs_data_opened (ffs); +if (ffs->state ==FFS_CLOSING ) { +ffs_data_closed (ffs); +mutex_unlock (&ffs->mutex); +return -EBUSY ; + } +mutex_unlock (&ffs->mutex); + file->private_data = ffs;return stream_open (inode, file); }
@@ -1193,14 +1202,33 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)static int ffs_epfile_open (struct inode *inode,struct file *file) { -struct ffs_epfile *epfile = inode->i_private; +struct ffs_data *ffs = inode->i_sb->s_fs_info; +struct ffs_epfile *epfile; +int ret; -if (WARN_ON (epfile->ffs->state !=FFS_ACTIVE )) +/* Acquire mutex */ + ret =ffs_mutex_lock (&ffs->mutex, file->f_flags &O_NONBLOCK ); +if (ret <0 ) +return ret; + +if (!atomic_inc_not_zero (&ffs->opened)) { +mutex_unlock (&ffs->mutex); +return -ENODEV ; + } +/* +* we want the state to be FFS_ACTIVE; FFS_ACTIVE alone is +* not enough, though - we might have been through FFS_CLOSING +* and back to FFS_ACTIVE, with our file already removed. +*/ + epfile =smp_load_acquire (&inode->i_private); +if (unlikely (ffs->state !=FFS_ACTIVE || !epfile)) { +mutex_unlock (&ffs->mutex); +ffs_data_closed (ffs);return -ENODEV ; + } +mutex_unlock (&ffs->mutex); file->private_data = epfile; -ffs_data_opened (epfile->ffs); -return stream_open (inode, file); }
@@ -1332,7 +1360,7 @@ static void ffs_dmabuf_put(struct dma_buf_attachment *attach)static int ffs_epfile_release (struct inode *inode,struct file *file) { -struct ffs_epfile *epfile = inode->i_private; +struct ffs_epfile *epfile = file->private_data;struct ffs_dmabuf_priv *priv, *tmp;struct ffs_data *ffs = epfile->ffs;
@@ -2352,6 +2380,11 @@ static int ffs_epfiles_create(struct ffs_data *ffs)return 0 ; } +static void clear_one (struct dentry *dentry) +{ +smp_store_release (&dentry->d_inode->i_private,NULL ); +} +static void ffs_epfiles_destroy (struct ffs_epfile *epfiles,unsigned count) {struct ffs_epfile *epfile = epfiles;
@@ -2359,7 +2392,7 @@ static void ffs_epfiles_destroy(struct ffs_epfile *epfiles, unsigned count)for (; count; --count, ++epfile) {BUG_ON (mutex_is_locked (&epfile->mutex));if (epfile->dentry) { -simple_recursive_removal (epfile->dentry,NULL ); +simple_recursive_removal (epfile->dentry, clear_one); epfile->dentry =NULL ; } }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 scsi: qla2xxx: Use reinit_completion on mbx_intr_comp
From: Tony Battersby <[email protected]>
[ Upstream commit 957aa5974989fba4ae4f807ebcb27f12796edd4d ]
If a mailbox command completes immediately after wait_for_completion_timeout() times out, ha->mbx_intr_comp could be left in an inconsistent state, causing the next mailbox command not to wait for the hardware. Fix by reinitializing the completion before use.
---
LLM Generated explanations, may be completely bogus:
## Comprehensive Analysis
### 1. COMMIT MESSAGE ANALYSIS
The commit message clearly describes a race condition:
- **Bug:** If a mailbox command completes immediately **after** wait_for_completion_timeout() times out, ha->mbx_intr_comp is left in an inconsistent (completed) state
- **Impact:** The next mailbox command will not wait for hardware
- **Fix:** Reinitialize the completion before use
**Notable:** No "Cc: [email protected]" or "Fixes:" tag, but the bug description is clear and the fix is obviously correct.
### 2. CODE CHANGE ANALYSIS
**The Race Condition:**
1. Thread calls wait_for_completion_timeout(&ha->mbx_intr_comp, ...)
2. Timeout expires → returns 0
3. Meanwhile, hardware interrupt fires and qla2x00_handle_mbx_completion() calls complete(&ha->mbx_intr_comp) (at qla_inline.h:271)
4. Completion is now in "done" state
5. Next mailbox command: wait_for_completion_timeout() returns immediately without waiting
6. Driver proceeds before hardware is ready → potential malfunction
**The Fix (2 lines added):**
- reinit_completion(&ha->mbx_intr_comp) before starting to wait (ensures clean initial state)
- reinit_completion(&ha->mbx_intr_comp) after timeout (clears any stale completion that raced)
This is a **standard kernel pattern** for handling completion/timeout races (similar fix in csiostor - commit 3e3f5a8a0f03e).
### 3. CLASSIFICATION
- **Type:** Bug fix for a real race condition
- **Not:** Feature addition, new API, cleanup, or optimization
- **Category:** Driver reliability fix
### 4. SCOPE AND RISK ASSESSMENT
| Factor | Assessment | |--------|------------| | Lines changed | +2 lines (minimal) | | Files touched | 1 file | | API used | `reinit_completion()` - standard kernel API, stable for years | | Complexity | Very low - straightforward pattern | | Risk of regression | Very low - just resets completion state |
### 5. USER IMPACT
- **Affected users:** Anyone with QLogic Fibre Channel HBAs (qla2xxx driver)
- **Deployment:** Enterprise storage systems, SANs, data centers
- **Severity:** If triggered, could cause:
- Mailbox commands proceeding before hardware ready
- Corrupted command sequences
- I/O failures or potential data corruption
- **Frequency:** Race condition, but in storage path - critical when it hits
- **Callers:** 99 functions call qla2x00_mailbox_command - this is the core firmware communication path
### 6. STABILITY INDICATORS
- Signed-off-by: Tony Battersby (author)
- Signed-off-by: Martin K. Petersen (SCSI maintainer)
- Proper patch submission via Link: to patch.msgid.link
### 7. DEPENDENCY CHECK
- Uses only reinit_completion() - standard kernel API available in all stable trees
- No dependencies on other commits
- The affected code path exists in all stable trees where qla2xxx driver is present
### Summary
**Meets all stable kernel criteria:**
1. ✅ **Obviously correct** - standard pattern for completion timeout races
2. ✅ **Fixes real bug** - race condition affecting hardware synchronization
3. ✅ **Small and contained** - only 2 lines, single file
4. ✅ **No new features** - purely a bug fix
5. ✅ **Tested** - accepted by SCSI maintainer
6. ✅ **User impact** - affects enterprise storage users
**Risk vs Benefit:**
- Risk: Negligible - reinit_completion() is well-understood and safe
- Benefit: Prevents potential storage I/O issues from race condition
The only missing element is an explicit "Cc: stable" tag, but this commit clearly qualifies as a proper stable backport candidate. It's a small, surgical fix for a real race condition in a production SCSI driver used in enterprise storage environments.
**YES**
drivers/scsi/qla2xxx/qla_mbx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/qla2xxx/qla_mbx.c +2 -0
@@ -253,6 +253,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)/* Issue set host interrupt command to send cmd out. */ ha->flags.mbox_int =0 ;clear_bit (MBX_INTERRUPT , &ha->mbx_cmd_flags); +reinit_completion (&ha->mbx_intr_comp);/* Unlock mbx registers and wait for interrupt */ ql_dbg(ql_dbg_mbx, vha, 0x100f,
@@ -279,6 +280,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) "cmd=%x Timeout.\n", command);spin_lock_irqsave (&ha->hardware_lock, flags);clear_bit (MBX_INTR_WAIT , &ha->mbx_cmd_flags); +reinit_completion (&ha->mbx_intr_comp);spin_unlock_irqrestore (&ha->hardware_lock, flags);if (chip_reset != ha->chip_reset) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 via_wdt: fix critical boot hang due to unnamed resource allocation
In reply to Sasha LevinFrom: Li Qiang <[email protected]>
[ Upstream commit 7aa31ee9ec92915926e74731378c009c9cc04928 ]
The VIA watchdog driver uses allocate_resource() to reserve a MMIO region for the watchdog control register. However, the allocated resource was not given a name, which causes the kernel resource tree to contain an entry marked as "<BAD>" under /proc/iomem on x86 platforms.
During boot, this unnamed resource can lead to a critical hang because subsequent resource lookups and conflict checks fail to handle the invalid entry properly.
---
LLM Generated explanations, may be completely bogus:
## Analysis Summary
### 1. COMMIT MESSAGE ANALYSIS
**Subject:** "via_wdt: fix critical boot hang due to unnamed resource allocation"
- Uses "fix" language indicating a bug fix
- Claims "critical boot hang" - a severe user-impacting issue
- Affects VIA chipset watchdog driver
**Tags analysis:**
- **Missing:** No "Cc: [email protected]" tag
- **Missing:** No "Fixes:" tag
- **Present:** Reviewed-by: Guenter Roeck (well-respected watchdog/hwmon maintainer)
- **Present:** Signed-off by both watchdog maintainers (Guenter Roeck and Wim Van Sebroeck)
### 2. CODE CHANGE ANALYSIS
The fix is a **single line addition**:
```c wdt_res.name = "via_wdt"; ```
**The bug mechanism:**
1. wdt_res is declared as a static struct resource without initialization at line 67
2. allocate_resource() is called without the resource having a name set
3. This results in a NULL name field, shown as <BAD> in /proc/iomem
4. The kernel's resource code in kernel/resource.c:141 shows: r->name ? r->name : "<BAD>"
**Why this is needed:**
- Other watchdog drivers (e.g., f71808e_wdt.c) properly set wdt_res.name = "superio port"
- struct resource has a name field that should always be populated
### 3. CLASSIFICATION
- **Type:** Bug fix (not new feature)
- **Severity:** The commit claims "critical boot hang" - though the exact mechanism isn't fully clear from code inspection, unnamed resources can cause problems in resource lookup/conflict resolution paths
- **Scope:** Single driver, single line
### 4. SCOPE AND RISK ASSESSMENT
| Factor | Assessment | |--------|------------| | Lines changed | 1 | | Files touched | 1 | | Complexity | Extremely low | | Risk of regression | **Zero** - adding a name to a resource cannot cause problems | | Self-contained | Yes, no dependencies |
### 5. USER IMPACT
- **Affected users:** VIA chipset hardware with watchdog (relatively rare, older hardware)
- **Severity if bug hits:** Boot hang (critical)
- **Bug age:** Present since driver was introduced in 2011 (dc3c56b703dad)
### 6. STABILITY INDICATORS
- **Reviewed-by:** Guenter Roeck - respected maintainer
- **Correctness:** Obviously correct - other drivers do the same thing
- **Testing:** Implied through maintainer review
### 7. DEPENDENCY CHECK
- **No dependencies** - completely self-contained
- **Driver exists in all stable trees** - since 2011
## Risk vs Benefit Analysis
**Benefits:**
- Fixes potential boot hang for affected users
- Fixes incorrect /proc/iomem display (<BAD> entries)
- Brings via_wdt in line with other watchdog drivers
**Risks:**
- **None** - setting a resource name is a standard, safe operation
## Concerns
1. **No explicit stable request:** The maintainers didn't add `Cc:
[email protected]`
2. **Boot hang claim verification:** The exact mechanism for the boot hang isn't easily traced in code, though I trust the reporter/maintainers' assessment
3. **Limited scope:** Only affects VIA chipset users (small population)
## Conclusion
This commit **should be backported** to stable kernels. Despite the missing stable tag, it meets all stable criteria:
1. ✅ **Obviously correct** - trivial one-line fix matching other drivers' patterns
2. ✅ **Fixes a real bug** - unnamed resources are incorrect and can cause issues
3. ✅ **Small and contained** - one line in one file
4. ✅ **No new features** - just fixing existing code
5. ✅ **Zero regression risk** - adding a name cannot break anything
6. ✅ **Maintainer reviewed** - Guenter Roeck reviewed
The fix is so trivially safe that even if the boot hang is rare, there is no downside to including it in stable.
**YES**
drivers/watchdog/via_wdt.c | 1 + 1 file changed, 1 insertion(+)
drivers/watchdog/via_wdt.c +1 -0
@@ -165,6 +165,7 @@ static int wdt_probe(struct pci_dev *pdev,dev_err (&pdev->dev,"cannot enable PCI device\n" );return -ENODEV ; } + wdt_res.name ="via_wdt" ;/* * Allocate a MMIO region which contains watchdog control register
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 ti-sysc: allow OMAP2 and OMAP4 timers to be reserved on AM33xx
In reply to Sasha LevinFrom: Matthias Schiffer <[email protected]>
[ Upstream commit 3f61783920504b2cf99330b372d82914bb004d8e ]
am33xx.dtsi has the same clock setup as am35xx.dtsi, setting ti,no-reset-on-init and ti,no-idle on timer1_target and timer2_target, so AM33 needs the same workaround as AM35 to avoid ti-sysc probe failing on certain target modules.
---
LLM Generated explanations, may be completely bogus:
# Commit Analysis: ti-sysc: allow OMAP2 and OMAP4 timers to be reserved on AM33xx
## 1. Commit Message Analysis
**Subject/Body**: The commit addresses ti-sysc probe failures on AM33xx platforms (commonly used in BeagleBone and industrial embedded systems). The commit explains that AM33xx has the same clock setup as AM35xx (with ti,no-reset-on-init and ti,no-idle on timer targets), so it needs the same workaround.
**Notable absence**: No Cc: [email protected] or Fixes: tag. The maintainers didn't explicitly mark this for stable backporting.
## 2. Code Change Analysis
The changes are minimal and well-contained:
1. **New enum value**: Adds SOC_AM33 to enum sysc_soc at drivers/bus/ti-sysc.c:51
2. **SoC detection**: Adds SOC_FLAG("AM33*", SOC_AM33) to sysc_soc_match[]
3. **Logic extension in sysc_check_active_timer()**:
- Converts if/else to switch statement
- Adds SOC_AM33 case alongside existing SOC_3430 and SOC_AM35 to return -ENXIO
**Technical mechanism**: When a timer has both SYSC_QUIRK_NO_RESET_ON_INIT and SYSC_QUIRK_NO_IDLE quirks set (indicating it's likely in use by the system timer driver), and the SoC is AM33/AM35/3430, the function returns -ENXIO allowing the timer to be "reserved" and preventing probe failure.
## 3. Classification
This falls under the **QUIRKS and WORKAROUNDS** exception category:
- Extends an existing hardware-specific workaround to similar hardware
- Fixes probe failures on real devices
- Follows an established pattern in the driver for handling SoC-specific timer behavior
## 4. Scope and Risk Assessment
**Size**: Very small (~20 lines, 1 file)
**Subsystem**: ti-sysc bus driver (OMAP/TI platform-specific) **Complexity**: Low - straightforward extension of existing logic **Risk**: Very low - only affects AM33xx platforms, doesn't change behavior for any other SoC
The switch statement change is a cosmetic improvement that makes the code cleaner while adding the new case.
## 5. User Impact
**Who is affected**: Users of AM33xx-based systems (BeagleBone Black, industrial AM335x boards)
**Severity**: Probe failures prevent proper hardware initialization, which can be significant for embedded systems **Prevalence**: AM33xx is a widely-deployed platform
## 6. Stability Indicators
- Multiple signed-off-by tags (Matthias Schiffer, Alexander Stein, Kevin Hilman)
- Proper review via lore.kernel.org
- Follows established patterns in the codebase (SOC_AM35 workaround already existed)
## 7. Dependency Check
The commit is self-contained. The required infrastructure (SOC detection mechanism, timer quirk handling) already exists in the driver. The only addition is a new enum value and extending the switch case.
## Summary Assessment
**Pros**:
- Fixes real probe failures on commonly-used embedded platforms
- Very small, contained change with low regression risk
- Extends existing well-tested workaround to similar hardware
- Falls under the "quirks/workarounds" exception for stable
**Cons**:
- No explicit Cc: stable tag from maintainers
- No Fixes: tag to identify when the bug was introduced
- Adds new code (enum value) rather than purely fixing existing code
**Risk vs Benefit**: The risk is very low (only affects AM33xx platforms, extends existing logic). The benefit is meaningful for AM33xx users who would otherwise hit probe failures. This type of platform- specific quirk extension is common and safe.
## Verdict
This is a small, well-contained fix that extends an existing hardware workaround to similar hardware (AM33xx). While it lacks explicit stable tags, it meets the criteria for the "quirks and workarounds" exception. The fix prevents probe failures on a widely-used embedded platform with minimal regression risk. The pattern of extending SoC-specific workarounds to similar SoCs is well-established and safe.
**YES**
drivers/bus/ti-sysc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/bus/ti-sysc.c +9 -2
@@ -48,6 +48,7 @@ enum sysc_soc {SOC_UNKNOWN ,SOC_2420 ,SOC_2430 , +SOC_AM33 ,SOC_3430 ,SOC_AM35 , SOC_3630,
@@ -2912,6 +2913,7 @@ static void ti_sysc_idle(struct work_struct *work)static const struct soc_device_attribute sysc_soc_match[] = {SOC_FLAG ("OMAP242*" ,SOC_2420 ),SOC_FLAG ("OMAP243*" ,SOC_2430 ), +SOC_FLAG ("AM33*" ,SOC_AM33 ),SOC_FLAG ("AM35*" ,SOC_AM35 ),SOC_FLAG ("OMAP3[45]*" ,SOC_3430 ),SOC_FLAG ("OMAP3[67]*" ,SOC_3630 ),
@@ -3117,10 +3119,15 @@ static int sysc_check_active_timer(struct sysc *ddata)* can be dropped if we stop supporting old beagleboard revisions * A to B4 at some point. */ -if (sysc_soc->soc ==SOC_3430 || sysc_soc->soc ==SOC_AM35 ) +switch (sysc_soc->soc) { +case SOC_AM33 : +case SOC_3430 : +case SOC_AM35 : error = -ENXIO ; -else +break ; +default : error = -EBUSY ; + }if ((ddata->cfg.quirks &SYSC_QUIRK_NO_RESET_ON_INIT ) && (ddata->cfg.quirks &SYSC_QUIRK_NO_IDLE ))
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 scsi: qla2xxx: Fix lost interrupts with qlini_mode=disabled
In reply to Sasha LevinFrom: Tony Battersby <[email protected]>
[ Upstream commit 4f6aaade2a22ac428fa99ed716cf2b87e79c9837 ]
When qla2xxx is loaded with qlini_mode=disabled, ha->flags.disable_msix_handshake is used before it is set, resulting in the wrong interrupt handler being used on certain HBAs (qla2xxx_msix_rsp_q_hs() is used when qla2xxx_msix_rsp_q() should be used). The only difference between these two interrupt handlers is that the _hs() version writes to a register to clear the "RISC" interrupt, whereas the other version does not. So this bug results in the RISC interrupt being cleared when it should not be. This occasionally causes a different interrupt handler qla24xx_msix_default() for a different vector to see ((stat & HSRX_RISC_INT) == 0) and ignore its interrupt, which then causes problems like:
qla2xxx [0000:02:00.0]-d04c:6: MBX Command timeout for cmd 20,
iocontrol=8 jiffies=1090c0300 mb[0-3]=[0x4000 0x0 0x40 0xda] mb7 0x500 host_status 0x40000010 hccr 0x3f00
qla2xxx [0000:02:00.0]-101e:6: Mailbox cmd timeout occurred, cmd=0x20,
mb[0]=0x20. Scheduling ISP abort
(the cmd varies; sometimes it is 0x20, 0x22, 0x54, 0x5a, 0x5d, or 0x6a)
This problem can be reproduced with a 16 or 32 Gbps HBA by loading qla2xxx with qlini_mode=disabled and running a high IOPS test while triggering frequent RSCN database change events.
While analyzing the problem I discovered that even with disable_msix_handshake forced to 0, it is not necessary to clear the RISC interrupt from qla2xxx_msix_rsp_q_hs() (more below). So just completely remove qla2xxx_msix_rsp_q_hs() and the logic for selecting it, which also fixes the bug with qlini_mode=disabled.
The test below describes the justification for not needing qla2xxx_msix_rsp_q_hs():
Force disable_msix_handshake to 0:qla24xx_config_rings():
if (0 && (ha->fw_attributes & BIT_6) && (IS_MSIX_NACK_CAPABLE(ha)) &&
(ha->flags.msix_enabled)) {In qla24xx_msix_rsp_q() and qla2xxx_msix_rsp_q_hs(), check:
(rd_reg_dword(®->host_status) & HSRX_RISC_INT)
Count the number of calls to each function with HSRX_RISC_INT set and the number with HSRX_RISC_INT not set while performing some I/O.
If qla2xxx_msix_rsp_q_hs() clears the RISC interrupt (original code):
qla24xx_msix_rsp_q: 50% of calls have HSRX_RISC_INT set qla2xxx_msix_rsp_q_hs: 5% of calls have HSRX_RISC_INT set
(# of qla2xxx_msix_rsp_q_hs interrupts) =
(# of qla24xx_msix_rsp_q interrupts) * 3
If qla2xxx_msix_rsp_q_hs() does not clear the RISC interrupt (patched code):
qla24xx_msix_rsp_q: 100% of calls have HSRX_RISC_INT set qla2xxx_msix_rsp_q_hs: 9% of calls have HSRX_RISC_INT set
(# of qla2xxx_msix_rsp_q_hs interrupts) =
(# of qla24xx_msix_rsp_q interrupts) * 3
In the case of the original code, qla24xx_msix_rsp_q() was seeing HSRX_RISC_INT set only 50% of the time because qla2xxx_msix_rsp_q_hs() was clearing it when it shouldn't have been. In the patched code, qla24xx_msix_rsp_q() sees HSRX_RISC_INT set 100% of the time, which makes sense if that interrupt handler needs to clear the RISC interrupt (which it does). qla2xxx_msix_rsp_q_hs() sees HSRX_RISC_INT only 9% of the time, which is just overlap from the other interrupt during the high IOPS test.
Tested with SCST on:
QLE2742 FW:v9.08.02 (32 Gbps 2-port)
QLE2694L FW:v9.10.11 (16 Gbps 4-port)
QLE2694L FW:v9.08.02 (16 Gbps 4-port)
QLE2672 FW:v8.07.12 (16 Gbps 2-port)
both initiator and target mode
---
LLM Generated explanations, may be completely bogus:
## Analysis of qla2xxx Lost Interrupts Fix
### 1. COMMIT MESSAGE ANALYSIS
**Subject**: "scsi: qla2xxx: Fix lost interrupts with qlini_mode=disabled"
Key findings:
- Contains "Fix" keyword indicating a bug fix
- No Cc: [email protected] tag present
- No Fixes: tag present
- Describes a clear user-visible problem: mailbox command timeouts and ISP aborts
- Symptoms documented include:
``` MBX Command timeout for cmd 20... Scheduling ISP abort ```
### 2. CODE CHANGE ANALYSIS
**Root Cause**: ha->flags.disable_msix_handshake is accessed before it's set during initialization. This causes incorrect interrupt handler selection:
- qla2xxx_msix_rsp_q_hs() is erroneously used when qla2xxx_msix_rsp_q() should be used
- The _hs handler clears the RISC interrupt when it shouldn't
- This causes qla24xx_msix_default() to see (stat & HSRX_RISC_INT) == 0 and ignore its interrupt
**The Fix**:
1. Removes the problematic qla2xxx_msix_rsp_q_hs() handler entirely
2. Removes QLA_MSIX_QPAIR_MULTIQ_RSP_Q_HS definition
3. Simplifies qla25xx_request_irq() by removing vector_type parameter
4. Always uses the correct qla2xxx_msix_rsp_q handler
**Why This Works**: The author's testing shows that the RISC interrupt clearing in _hs was never necessary - removing it actually improves correctness (100% of calls see HSRX_RISC_INT set vs 50% previously).
### 3. CLASSIFICATION
- **Bug fix**: Yes - fixes lost interrupts causing command timeouts
- **Feature addition**: No - actually *removes* code
- **Security fix**: No
- **Hardware affected**: QLogic FC HBAs (16/32 Gbps) in enterprise environments
### 4. SCOPE AND RISK ASSESSMENT
| Metric | Assessment | |--------|------------| | Files changed | 4 (all qla2xxx driver) | | Net lines | Negative (code removal) | | Subsystem | SCSI/qla2xxx - mature, enterprise driver | | Risk level | LOW - removes problematic code path |
The fix is self-contained and simplifies rather than complicates the code.
### 5. USER IMPACT
**Affected users**:
- QLogic FC HBA users with qlini_mode=disabled (target mode)
- High IOPS environments with frequent RSCN events
- Enterprise storage deployments using SCST
**Severity**: HIGH
- Command timeouts cause I/O disruptions
- ISP aborts can trigger path failovers
- Production storage environments severely impacted
### 6. STABILITY INDICATORS
**Testing documented**:
- QLE2742 FW:v9.08.02 (32 Gbps)
- QLE2694L FW:v9.10.11 and v9.08.02 (16 Gbps)
- QLE2672 FW:v8.07.12 (16 Gbps)
- Both initiator and target modes tested
**Sign-offs**: Tony Battersby (author), Martin K. Petersen (SCSI maintainer)
### 7. DEPENDENCY CHECK
- No dependencies on other commits
- Self-contained within qla2xxx driver
- The affected code (multi-queue support) exists in stable trees
### 8. CONCERNS
1. **No explicit stable tags**: Maintainer didn't request backport explicitly
2. **No Fixes: tag**: Unknown exactly when bug was introduced
3. **Configuration-specific**: Only affects qlini_mode=disabled mode
4. **Removes entire handler**: Could theoretically affect unknown edge cases
### FINAL ASSESSMENT
**Arguments FOR backport**:
- Fixes real, user-visible bug causing command timeouts and ISP aborts
- Affects enterprise FC storage deployments in target mode
- Low risk - removes problematic code rather than adding new code
- Extensively tested on multiple HBA models
- SCSI maintainer approved
- Self-contained fix with no dependencies
**Arguments AGAINST backport**:
- No explicit stable request from maintainers
- Touches multiple functions (though all removals)
- Affects specific configuration (target mode)
The fix addresses a significant reliability issue in enterprise storage environments. While lacking explicit stable tags, the nature of the fix (removing buggy code, not adding features), the thorough testing, and the severity of the symptoms (command timeouts, ISP aborts in production) make this appropriate for stable backport. The code removal approach minimizes regression risk.
**YES**
drivers/scsi/qla2xxx/qla_def.h | 1 - drivers/scsi/qla2xxx/qla_gbl.h | 2 +- drivers/scsi/qla2xxx/qla_isr.c | 32 +++----------------------------- drivers/scsi/qla2xxx/qla_mid.c | 4 +--- 4 files changed, 5 insertions(+), 34 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +0 -1
@@ -3503,7 +3503,6 @@ struct isp_operations {#define QLA_MSIX_RSP_Q 0x01#define QLA_ATIO_VECTOR 0x02#define QLA_MSIX_QPAIR_MULTIQ_RSP_Q 0x03 -#define QLA_MSIX_QPAIR_MULTIQ_RSP_Q_HS 0x04#define QLA_MIDX_DEFAULT 0#define QLA_MIDX_RSP_Q 1
drivers/scsi/qla2xxx/qla_gbl.h +1 -1
@@ -766,7 +766,7 @@ extern int qla2x00_dfs_remove(scsi_qla_host_t *);/* Globa function prototypes for multi-q */ extern int qla25xx_request_irq (struct qla_hw_data *,struct qla_qpair *, -struct qla_msix_entry *,int ); +struct qla_msix_entry *);extern int qla25xx_init_req_que (struct scsi_qla_host *,struct req_que *);extern int qla25xx_init_rsp_que (struct scsi_qla_host *,struct rsp_que *); extern int qla25xx_create_req_que(struct qla_hw_data *, uint16_t, uint8_t,
drivers/scsi/qla2xxx/qla_isr.c +3 -29
@@ -4467,32 +4467,6 @@ qla2xxx_msix_rsp_q(int irq, void *dev_id)return IRQ_HANDLED ; } -irqreturn_t -qla2xxx_msix_rsp_q_hs (int irq,void *dev_id) -{ -struct qla_hw_data *ha; -struct qla_qpair *qpair; -struct device_reg_24xx __iomem *reg; -unsigned long flags; - - qpair = dev_id; -if (!qpair) { -ql_log (ql_log_info,NULL ,0x505b , -"%s: NULL response queue pointer.\n" , __func__); -return IRQ_NONE ; - } - ha = qpair->hw; - - reg = &ha->iobase->isp24; -spin_lock_irqsave (&ha->hardware_lock, flags); -wrt_reg_dword (®->hccr,HCCRX_CLR_RISC_INT ); -spin_unlock_irqrestore (&ha->hardware_lock, flags); - -queue_work (ha->wq, &qpair->q_work); - -return IRQ_HANDLED ; -} -/* Interrupt handling helpers. */ struct qla_init_msix_entry {
@@ -4505,7 +4479,6 @@ static const struct qla_init_msix_entry msix_entries[] = { { "rsp_q", qla24xx_msix_rsp_q }, { "atio_q", qla83xx_msix_atio_q }, { "qpair_multiq", qla2xxx_msix_rsp_q }, - { "qpair_multiq_hs", qla2xxx_msix_rsp_q_hs }, }; static const struct qla_init_msix_entry qla82xx_msix_entries[] = {
@@ -4792,9 +4765,10 @@ qla2x00_free_irqs(scsi_qla_host_t *vha) }int qla25xx_request_irq (struct qla_hw_data *ha,struct qla_qpair *qpair, -struct qla_msix_entry *msix,int vector_type) +struct qla_msix_entry *msix) { -const struct qla_init_msix_entry *intr = &msix_entries[vector_type]; +const struct qla_init_msix_entry *intr = + &msix_entries[QLA_MSIX_QPAIR_MULTIQ_RSP_Q ];scsi_qla_host_t *vha =pci_get_drvdata (ha->pdev);int ret;
drivers/scsi/qla2xxx/qla_mid.c +1 -3
@@ -899,9 +899,7 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options, rsp->options, rsp->id, rsp->rsp_q_in, rsp->rsp_q_out); - ret =qla25xx_request_irq (ha, qpair, qpair->msix, - ha->flags.disable_msix_handshake ? -QLA_MSIX_QPAIR_MULTIQ_RSP_Q :QLA_MSIX_QPAIR_MULTIQ_RSP_Q_HS ); + ret =qla25xx_request_irq (ha, qpair, qpair->msix);if (ret) goto que_failed;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 exfat: zero out post-EOF page cache on file extension
In reply to Sasha LevinFrom: Yuezhang Mo <[email protected]>
[ Upstream commit 4e163c39dd4e70fcdce948b8774d96e0482b4a11 ]
xfstests generic/363 was failing due to unzeroed post-EOF page cache that allowed mmap writes beyond EOF to become visible after file extension.
For example, in following xfs_io sequence, 0x22 should not be written to the file but would become visible after the extension:
xfs_io -f -t -c "pwrite -S 0x11 0 8" \
-c "mmap 0 4096" \
-c "mwrite -S 0x22 32 32" \
-c "munmap" \
-c "pwrite -S 0x33 512 32" \
$testfileThis violates the expected behavior where writes beyond EOF via mmap should not persist after the file is extended. Instead, the extended region should contain zeros.
Fix this by using truncate_pagecache() to truncate the page cache after the current EOF when extending the file.
---
LLM Generated explanations, may be completely bogus:
## Commit Analysis: exfat: zero out post-EOF page cache on file extension
### 1. COMMIT MESSAGE ANALYSIS
**Problem Description**:
- xfstests generic/363 failing due to unzeroed post-EOF page cache
- mmap writes beyond EOF become visible after file extension
- This violates expected POSIX behavior where extended regions should contain zeros
**Keywords**: "failing", "fix" - indicates this fixes a real bug
**Tags**:
- No Cc: [email protected] tag
- No Fixes: tag
- Signed-off-by from exfat maintainer (Namjae Jeon)
### 2. CODE CHANGE ANALYSIS
The fix adds truncate_pagecache() calls in two locations:
**Change 1 - exfat_cont_expand() (~line 30)**:
```c + truncate_pagecache(inode, i_size_read(inode)); ```
This truncates page cache to current EOF when expanding a file, invalidating any stale data that may have been written beyond EOF via mmap.
**Change 2 - exfat_file_write_iter() (~line 645)**:
```c + if (pos > i_size_read(inode)) + truncate_pagecache(inode, i_size_read(inode)); ```
This truncates page cache before writes that extend the file, with a conditional check to only run when write position exceeds current file size.
**Technical mechanism of the bug**:
- User mmaps a file and writes beyond EOF into page cache
- These writes don't persist (they're beyond EOF)
- Later, when the file is extended, the stale page cache with those beyond-EOF writes becomes part of the valid file content
- Result: data that should never have persisted becomes visible
**Why the fix works**: truncate_pagecache() invalidates all page cache beyond the specified position, ensuring any stale post-EOF data is discarded before extending the file.
### 3. CLASSIFICATION
- **Type**: Bug fix for **data integrity issue**
- **Category**: Filesystem semantics violation
- **Not an exception case**: Not a device ID, quirk, DT update, or build fix
### 4. SCOPE AND RISK ASSESSMENT
- **Lines changed**: +3 lines (very small)
- **Files touched**: 1 file (fs/exfat/file.c)
- **Complexity**: Low - uses standard kernel APIs
- **Subsystem maturity**: exfat is relatively mature (in mainline since 5.7)
- **Regression risk**: LOW - truncate_pagecache() is a well-tested standard API used by many filesystems for this exact purpose
### 5. USER IMPACT
- **Who is affected**: Users of exfat filesystem (common on SD cards, USB drives, camera media)
- **Severity**: Moderate to high - data integrity violation
- **Reproducibility**: Reproducible via xfstests generic/363, specific mmap usage patterns
- **Real-world impact**: Could cause unexpected data appearing in files, data corruption scenarios
### 6. STABILITY INDICATORS
- **Tested**: Yes - via xfstests generic/363 (standard filesystem test suite)
- **Reviewed**: Has maintainer sign-off (Namjae Jeon)
- **Pattern**: Fix follows the same approach used by other mature filesystems (ext4, xfs, etc.) for handling post-EOF page cache
### 7. DEPENDENCY CHECK
- Uses only existing kernel APIs (truncate_pagecache(), i_size_read())
- No dependencies on other commits
- Functions being modified (exfat_cont_expand, exfat_file_write_iter) exist in stable kernels
---
## Summary
**What problem does this solve?**
Data integrity bug where mmap writes beyond EOF incorrectly persist after file extension, violating filesystem semantics.
**Does it meet stable kernel rules?**
- ✅ Obviously correct - uses standard pattern from other filesystems
- ✅ Fixes real bug - detected by xfstests, affects real users
- ✅ Important issue - data integrity is critical for filesystems
- ✅ Small and contained - 3 lines, 1 file
- ✅ No new features - pure bug fix
- ✅ Should apply cleanly - no dependencies
**Risk vs Benefit:**
- **Risk**: Very low - small change using well-tested APIs
- **Benefit**: Fixes data integrity issue on widely-used filesystem (exfat used on removable media)
**Concerns:**
- No explicit Cc: stable tag, but maintainer may not have considered it necessary
- No Fixes: tag, so unclear when bug was introduced (likely present since exfat's initial inclusion)
This is a clear-cut data integrity bug fix with minimal risk. The fix is small, surgical, uses standard kernel APIs, and follows the same pattern used by mature filesystems like ext4 and xfs. Data integrity issues in filesystems should be fixed in stable trees to protect users from silent data corruption.
**YES**
fs/exfat/file.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/exfat/file.c +5 -0
@@ -25,6 +25,8 @@ static int exfat_cont_expand(struct inode *inode, loff_t size)struct exfat_sb_info *sbi =EXFAT_SB (sb);struct exfat_chain clu; +truncate_pagecache (inode,i_size_read (inode)); + ret =inode_newsize_ok (inode, size);if (ret)return ret;
@@ -639,6 +641,9 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)inode_lock (inode); +if (pos >i_size_read (inode)) +truncate_pagecache (inode,i_size_read (inode)); + valid_size = ei->valid_size; ret =generic_write_checks (iocb, iter);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 scsi: smartpqi: Add support for Hurray Data new controller PCI device
In reply to Sasha LevinFrom: David Strahan <[email protected]>
[ Upstream commit 48e6b7e708029cea451e53a8c16fc8c16039ecdc ]
Add support for new Hurray Data controller.
All entries are in HEX.
Add PCI IDs for Hurray Data controllers:
VID / DID / SVID / SDID
---- ---- ---- ----
9005 028f 207d 4840---
LLM Generated explanations, may be completely bogus:
## Analysis of Commit: smartpqi: Add support for Hurray Data new controller PCI device
### 1. COMMIT MESSAGE ANALYSIS
**Subject/Body:** The commit adds support for a new Hurray Data storage controller by adding its PCI device ID to the smartpqi driver's device table.
**Tags present:**
- Multiple Reviewed-by: tags from Microchip engineers
- Signed-off-by: from driver maintainers
- **No Fixes: tag** - not fixing a bug
- **No Cc: [email protected]** - maintainer didn't explicitly request backport
### 2. CODE CHANGE ANALYSIS
The diff shows an extremely minimal change:
- **File modified:** drivers/scsi/smartpqi/smartpqi_init.c
- **Lines added:** 4 lines (one PCI device ID entry)
- **Change type:** Static array addition to pqi_pci_id_table[]
```c
{
PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
0x207d, 0x4840)
},
```The new entry uses the same vendor ID (0x207d - Hurray Data) already present in the table with different subsystem device IDs (0x4054, 0x4084, 0x4094, 0x4140, 0x4240). This is simply adding another variant.
### 3. CLASSIFICATION
This falls under the **NEW DEVICE IDs exception** - one of the explicitly allowed categories for stable trees:
- Adding a PCI subsystem ID to an existing, mature driver
- The smartpqi driver already supports Hurray Data controllers
- Only the specific hardware variant (SDID 0x4840) is new
- No new driver code, no feature additions - purely declarative data
### 4. SCOPE AND RISK ASSESSMENT
| Factor | Assessment | |--------|------------| | Lines changed | +4 (trivial) | | Files touched | 1 file | | Complexity | None - static data only | | Subsystem maturity | High - smartpqi is a well-tested SCSI driver | | Risk of regression | **Essentially zero** |
This is purely declarative - adding an entry to a static array. It cannot introduce logic bugs, race conditions, or regressions. If the hardware doesn't exist on a system, the entry has no effect whatsoever.
### 5. USER IMPACT
- **Affected users:** Anyone with a Hurray Data controller using subsystem device ID 0x4840
- **Without patch:** Storage controller won't be recognized; system likely unusable
- **With patch:** Hardware works normally
- **Impact severity:** Critical for affected users (storage controller = essential hardware)
### 6. STABILITY INDICATORS
- **Multiple reviews** from driver maintainers (Scott Benesh, Scott Teel, Mike McGowen)
- **Established pattern** - follows exactly the same format as dozens of other entries
- **Mature driver** - smartpqi has been stable for years
### 7. DEPENDENCY CHECK
- **No dependencies** - completely standalone change
- **Code exists in stable trees** - smartpqi driver and its PCI ID table are present in all active stable branches
### DECISION ANALYSIS
**For backporting:**
1. ✅ Falls squarely into the "device ID" exception category
2. ✅ Zero risk of regression - purely data addition
3. ✅ Enables critical hardware (storage controller) for affected users
4. ✅ Trivial, well-reviewed change
5. ✅ Pattern already established with many similar entries
6. ✅ Self-contained with no dependencies
**Against backporting:**
1. ⚠️ No explicit Cc: stable tag
2. ⚠️ Technically "new hardware support" not a bug fix
### CONCLUSION
This is a textbook example of a device ID addition suitable for stable backporting. The stable kernel rules explicitly allow new PCI/USB device IDs because:
- They are trivially small and well-understood
- They have near-zero risk of regression
- They enable real hardware that users have purchased
The lack of an explicit stable tag is not disqualifying for device ID additions - these are routinely accepted into stable trees. For a storage controller, this is particularly important as users with this hardware variant would have non-functional systems without the ID being recognized.
The change is obviously correct, has been reviewed by multiple maintainers, follows an established pattern, and provides clear value to affected users with no risk to anyone else.
**YES**
drivers/scsi/smartpqi/smartpqi_init.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/smartpqi/smartpqi_init.c +4 -0
@@ -10108,6 +10108,10 @@ static const struct pci_device_id pqi_pci_id_table[] = {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,0x207d ,0x4240 ) }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x207d ,0x4840 ) + }, {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,PCI_VENDOR_ID_ADVANTECH ,0x8312 )
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 scsi: ufs: host: mediatek: Fix shutdown/suspend race condition
In reply to Sasha LevinFrom: Peter Wang <[email protected]>
[ Upstream commit 014de20bb36ba03e0e0b0a7e0a1406ab900c9fda ]
Address a race condition between shutdown and suspend operations in the UFS Mediatek driver. Before entering suspend, check if a shutdown is in progress to prevent conflicts and ensure system stability.
---
LLM Generated explanations, may be completely bogus:
## Analysis Summary
### 1. Commit Message Analysis
- **Subject**: "Fix shutdown/suspend race condition" - clearly indicates a bug fix
- **No Cc: stable tag** or **Fixes: tag** present
- The message describes preventing conflicts between shutdown and suspend operations "to ensure system stability"
### 2. Code Change Analysis
The fix is extremely small (4 lines):
```c
if (hba->shutting_down) {
ret = -EBUSY;
goto out;
}
```**What it does**: At the start of ufs_mtk_system_suspend(), before calling ufshcd_system_suspend() and performing Mediatek-specific operations (voltage regulator LPM, MTCMOS control), it checks if hba->shutting_down is true.
**Why the race is problematic**: The Mediatek driver performs hardware- specific operations after calling the core suspend:
- ufs_mtk_dev_vreg_set_lpm() - controls voltage regulators
- ufs_mtk_mtcmos_ctrl() - controls power domains
If shutdown is in progress (ufshcd_wl_shutdown() sets hba->shutting_down = true), these operations could conflict with the shutdown sequence that also manipulates hardware state, causing instability.
### 3. Classification
- **Bug fix**: Yes - fixes a real race condition
- **Not a feature**: No new functionality, APIs, or capabilities added
- Uses existing infrastructure (shutting_down flag already exists in struct ufs_hba)
### 4. Scope and Risk Assessment
- **Lines changed**: 4 lines (minimal)
- **Files touched**: 1 (driver-specific)
- **Risk**: Very low - adds a defensive early return that makes the driver more conservative
- **Regression potential**: Minimal - worst case is a suspend returning -EBUSY when it shouldn't, but this is very unlikely given the shutdown context
### 5. User Impact
- **Affected hardware**: Mediatek UFS storage (common in Android devices and embedded systems)
- **Severity**: Race conditions between suspend/shutdown can cause system hangs, crashes, or data corruption
- **Real-world scenario**: User initiates shutdown while system is suspending (e.g., closing laptop lid during shutdown)
### 6. Stability Indicators
- Signed-off-by Mediatek developer (Peter Wang)
- Acked-by another Mediatek engineer
- Merged by SCSI maintainer Martin K. Petersen
### 7. Concerns
- No explicit Cc: stable tag
- No Fixes: tag indicating when the bug was introduced
- No bug report or Reported-by tag showing users encountered this issue
### Decision Rationale
**In favor of backporting:**
- Fixes a real race condition that can cause system instability
- The fix is trivially correct and uses existing infrastructure
- Very small change with minimal regression risk
- Mediatek UFS is widely deployed in consumer devices
- Race conditions between power management paths (suspend/shutdown) are serious issues
**Against backporting:**
- No explicit stable tag from the maintainer
- No evidence of users hitting this bug in practice
- Other UFS drivers don't have similar protection (though they may not have the same post-suspend hardware operations)
The fix is clearly correct, surgical, and addresses a real class of bug (PM race conditions). While lacking explicit stable markers, the fix meets the stable kernel criteria: it's obviously correct, fixes a real bug affecting system stability, and is small and contained.
**YES**
drivers/ufs/host/ufs-mediatek.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/ufs/host/ufs-mediatek.c +5 -0
@@ -2373,6 +2373,11 @@ static int ufs_mtk_system_suspend(struct device *dev)struct arm_smccc_res res;int ret; +if (hba->shutting_down) { + ret = -EBUSY ; + goto out; + } + ret =ufshcd_system_suspend (dev);if (ret) goto out;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 powerpc/addnote: Fix overflow on 32-bit builds
In reply to Sasha LevinFrom: Ben Collins <[email protected]>
[ Upstream commit 825ce89a3ef17f84cf2c0eacfa6b8dc9fd11d13f ]
The PUT_64[LB]E() macros need to cast the value to unsigned long long like the GET_64[LB]E() macros. Caused lots of warnings when compiled on 32-bit, and clobbered addresses (36-bit P4080).
---
LLM Generated explanations, may be completely bogus:
# Analysis: powerpc/addnote: Fix overflow on 32-bit builds
## 1. COMMIT MESSAGE ANALYSIS
**Subject:** Clearly indicates a fix for an overflow issue on 32-bit builds.
**Key details from message:**
- The PUT_64[LB]E() macros were missing unsigned long long casts that the corresponding GET_64[LB]E() macros already have
- Caused "lots of warnings when compiled on 32-bit"
- **Critical bug:** "clobbered addresses (36-bit P4080)" - this indicates real data corruption on P4080 hardware
**Tags present:**
- Signed-off-by: Ben Collins (author)
- Reviewed-by: Christophe Leroy (PowerPC expert/maintainer)
- Signed-off-by: Madhavan Srinivasan (PowerPC maintainer)
**Missing tags:** No Cc: [email protected] or Fixes: tag, but absence doesn't disqualify the fix.
## 2. CODE CHANGE ANALYSIS
The bug is a classic 32-bit portability issue:
**Before (broken):**
```c #define PUT_64BE(off, v)((PUT_32BE((off), (v) >> 32L), ... #define PUT_64LE(off, v) (PUT_32LE((off), (v)), PUT_32LE((off) + 4, (v) >> 32L)) ```
**After (fixed):**
```c
#define PUT_64BE(off, v)((PUT_32BE((off), (unsigned long long)(v) >>
32L), ...
#define PUT_64LE(off, v) (PUT_32LE((off), (unsigned long long)(v)), \
PUT_32LE((off) + 4, (unsigned long long)(v) >>
32L))
```**Technical mechanism of the bug:**
- On 32-bit systems, unsigned long is only 32 bits
- Shifting a 32-bit value by 32 bits ((v) >> 32L) is undefined behavior or produces incorrect results
- This causes the upper 32 bits of 64-bit values to be lost/corrupted
- The P4080 uses 36-bit physical addressing, so addresses were being truncated/mangled
**Why the fix is correct:**
- The GET_64[LB]E() macros already cast to unsigned long long
- This fix makes PUT_64[LB]E() consistent with the GET macros
- The cast ensures 64-bit arithmetic is performed correctly regardless of host architecture
## 3. CLASSIFICATION
- **Bug fix:** YES - fixes data corruption and compiler warnings
- **Feature addition:** NO
- **Category:** Build fix / correctness fix for 32-bit platforms
## 4. SCOPE AND RISK ASSESSMENT
- **Lines changed:** 4 lines (2 macro definitions modified)
- **Files touched:** 1 file (arch/powerpc/boot/addnote.c)
- **Complexity:** Very low - straightforward type casts
- **Subsystem:** PowerPC boot code (ELF note manipulation tool)
- **Risk:** **Very low** - the change makes the code do what it was always intended to do
## 5. USER IMPACT
- **Affected users:** PowerPC users, especially those with:
- 32-bit build hosts
- 32-bit PowerPC targets
- Hardware with 36-bit addressing (like P4080)
- **Severity:** HIGH - the bug causes address corruption which could lead to boot failures or memory corruption
- **P4080:** This is a Freescale/NXP QorIQ processor used in embedded/networking applications
## 6. STABILITY INDICATORS
- Reviewed by Christophe Leroy (well-known PowerPC developer)
- Author confirmed it fixed real issues on P4080 hardware
- The fix pattern matches what the GET macros already do - proven approach
## 7. DEPENDENCY CHECK
- **Dependencies:** None - completely self-contained fix
- **Code existence:** addnote.c has existed in the kernel for many years (basic boot infrastructure)
## Summary
| Criterion | Assessment | |-----------|------------| | Fixes real bug | ✅ YES - data corruption on P4080 | | Obviously correct | ✅ YES - matches existing GET macro pattern | | Small and contained | ✅ YES - 4 lines, 1 file | | No new features | ✅ YES | | Low regression risk | ✅ YES | | Tested | ✅ Implicitly (author verified fix) | | Reviewed | ✅ YES - by PowerPC expert |
**Risk vs Benefit:**
- **Risk:** Extremely low - adding type casts to ensure correct 64-bit arithmetic
- **Benefit:** High - fixes real data corruption affecting 32-bit PowerPC platforms
The commit is a textbook example of a stable-appropriate fix: it's small, obviously correct, fixes a real bug that causes data corruption, has been reviewed by an expert, and has virtually no risk of regression. The fact that the GET macros already have these casts and worked correctly proves this pattern is correct.
**YES**
arch/powerpc/boot/addnote.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/powerpc/boot/addnote.c +4 -3
@@ -68,8 +68,8 @@ static int e_class = ELFCLASS32;#define PUT_16BE (off, v)(buf[off] = ((v) >> 8) & 0xff, \ buf[(off) + 1] = (v) & 0xff)#define PUT_32BE (off, v)(PUT_16BE((off), (v) >> 16L), PUT_16BE((off) + 2, (v))) -#define PUT_64BE (off, v)((PUT_32BE((off), (v) >> 32L), \ - PUT_32BE((off) + 4, (v)))) +#define PUT_64BE (off, v)((PUT_32BE((off), (unsigned long long)(v) >> 32L), \ + PUT_32BE((off) + 4, (unsigned long long)(v))))#define GET_16LE (off) ((buf[off]) + (buf[(off)+1] << 8))#define GET_32LE (off) (GET_16LE(off) + (GET_16LE((off)+2U) << 16U))
@@ -78,7 +78,8 @@ static int e_class = ELFCLASS32;#define PUT_16LE (off, v) (buf[off] = (v) & 0xff, \ buf[(off) + 1] = ((v) >> 8) & 0xff)#define PUT_32LE (off, v) (PUT_16LE((off), (v)), PUT_16LE((off) + 2, (v) >> 16L)) -#define PUT_64LE (off, v) (PUT_32LE((off), (v)), PUT_32LE((off) + 4, (v) >> 32L)) +#define PUT_64LE (off, v) (PUT_32LE((off), (unsigned long long)(v)), \ + PUT_32LE((off) + 4, (unsigned long long)(v) >> 32L))#define GET_16 (off) (e_data == ELFDATA2MSB ? GET_16BE(off) : GET_16LE(off))#define GET_32 (off) (e_data == ELFDATA2MSB ? GET_32BE(off) : GET_32LE(off))
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 fuse: Invalidate the page cache after FOPEN_DIRECT_IO write
In reply to Sasha LevinFrom: Bernd Schubert <[email protected]>
[ Upstream commit b359af8275a982a458e8df6c6beab1415be1f795 ]
generic_file_direct_write() also does this and has a large comment about.
Reproducer here is xfstest's generic/209, which is exactly to have competing DIO write and cached IO read.
---
LLM Generated explanations, may be completely bogus:
## Analysis Summary
### The Bug
This commit fixes a **data coherency bug** in FUSE when using FOPEN_DIRECT_IO. The problem occurs when:
1. A direct I/O write completes on a FUSE filesystem
2. A concurrent buffered read has populated the page cache with (now stale) data
3. Without invalidation, the cached read returns **stale data**
The VFS layer handles this in generic_file_direct_write() (mm/filemap.c:4172-4224) by calling kiocb_invalidate_post_direct_write() after direct writes. The comment in VFS explicitly mentions this is needed to "invalidate clean pages which might have been cached by non-direct readahead."
### The Fix
The fix adds the same post-write invalidation pattern to FUSE's fuse_direct_io() function:
- After a successful write (res > 0 && write && fopen_direct_io)
- Call invalidate_inode_pages2_range(mapping, idx_from, idx_to)
- This ensures stale read-ahead pages are invalidated
**Code size:** +9 lines, single function, single file
### Stable Kernel Criteria Assessment
| Criterion | Assessment | |-----------|------------| | Obviously correct | ✅ Yes - follows established VFS pattern | | Fixes real bug | ✅ Yes - stale data reads (data integrity) | | Has reproducer | ✅ Yes - xfstest generic/209 | | Small and contained | ✅ Yes - 9 lines in one function | | No new features | ✅ Correct - pure bug fix | | Cc: stable tag | ❌ Not present | | Fixes: tag | ❌ Not present |
### Dependencies and Backport Concerns
**Critical dependency:** This commit requires commit 80e4f25262f9f ("fuse: invalidate page cache pages before direct write") which introduced the fopen_direct_io variable and idx_from/idx_to calculations. That commit was merged in **v6.6-rc1**.
**Backportable to:**
- stable/linux-6.6.y ✅
- stable/linux-6.11.y ✅
- stable/linux-6.12.y ✅
**NOT backportable to:**
- stable/linux-6.1.y ❌ (missing prerequisite code)
- Earlier LTS kernels ❌
### Risk Assessment
**LOW RISK:**
- Very small change (+9 lines)
- Uses existing, well-tested API (invalidate_inode_pages2_range)
- Follows the same pattern as the VFS layer
- Error return from invalidation is silently ignored (same as VFS behavior - "if this invalidation fails, tough, the write still worked...")
- Only affects FUSE filesystems using FOPEN_DIRECT_IO with concurrent cached reads
### User Impact
- **Severity:** Medium-High - stale data reads are a data integrity issue
- **Affected users:** FUSE filesystem users enabling FOPEN_DIRECT_IO (including some high-performance storage systems)
- **Reproducer:** Clear, well-known xfstest (generic/209)
### Verdict
Despite lacking explicit stable tags, this is a legitimate data integrity fix. The bug causes **real user-visible corruption** (stale data reads), the fix is small and surgical, follows an established VFS pattern, and has low regression risk. The lack of Cc: stable doesn't disqualify it - many important fixes arrive without explicit tags.
For kernels 6.6+, this should be backported. For earlier kernels, the prerequisite code doesn't exist, so backporting would require additional work.
**YES**
fs/fuse/file.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/fuse/file.c +9 -0
@@ -1681,6 +1681,15 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,if (res >0 ) *ppos = pos; +if (res >0 && write && fopen_direct_io) { +/* +* As in generic_file_direct_write(), invalidate after the +* write, to invalidate read-ahead cache that may have competed +* with the write. +*/ +invalidate_inode_pages2_range (mapping, idx_from, idx_to); + } +return res >0 ? res : err; }EXPORT_SYMBOL_GPL (fuse_direct_io);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 ipmi: Fix __scan_channels() failing to rescan channels
In reply to Sasha LevinFrom: Jinhui Guo <[email protected]>
[ Upstream commit 6bd30d8fc523fb880b4be548e8501bc0fe8f42d4 ]
channel_handler() sets intf->channels_ready to true but never clears it, so __scan_channels() skips any rescan. When the BMC firmware changes a rescan is required. Allow it by clearing the flag before starting a new scan.
Message-ID: <[email protected]>
---
LLM Generated explanations, may be completely bogus:
## Analysis of IPMI Channel Rescan Fix
### 1. COMMIT MESSAGE ANALYSIS
**Subject:** "ipmi: Fix __scan_channels() failing to rescan channels" - clear bug fix indication.
**Problem described:**
- channel_handler() sets intf->channels_ready = true but never clears it
- This causes __scan_channels() to skip rescans
- When BMC firmware changes, a rescan is required but doesn't happen
**Tags check:**
- No "Cc: [email protected]" tag
- No "Fixes:" tag
- Signed off by IPMI maintainer Corey Minyard
### 2. CODE CHANGE ANALYSIS
The fix adds a bool rescan parameter to __scan_channels():
```c
static int __scan_channels(struct ipmi_smi *intf,
struct ipmi_device_id *id,
bool rescan)
{
if (rescan) {
/* Clear channels_ready to force channels rescan. */
intf->channels_ready = false;
}
...
}
```**Call site updates:**
- ipmi_add_smi(): __scan_channels(intf, &id, false) - initial scan
- __bmc_get_device_id() after BMC re-registration:
__scan_channels(intf, &id, false) - fresh state
- __bmc_get_device_id() when version info changes:
__scan_channels(intf, &bmc->fetch_id, true) - rescan needed
**Bug mechanism:** When BMC firmware changes and __bmc_get_device_id() detects version info differences, it calls __scan_channels() to update channel information. However, since channels_ready was already set true from the initial scan, the rescan logic is skipped, leaving stale channel information.
### 3. CLASSIFICATION
- **Type:** Bug fix (not a feature)
- **Category:** Functional bug in existing driver logic
- **Security:** No security implications
### 4. SCOPE AND RISK ASSESSMENT
**Scope:**
- 1 file changed: drivers/char/ipmi/ipmi_msghandler.c
- ~15 lines of actual changes (mostly parameter additions)
- Localized to the __scan_channels() function and its callers
**Risk:** LOW
- The logic is simple and obvious: clear a boolean flag before rescanning
- No complex interactions or side effects
- The differentiation between initial scan (false) and rescan (true) is well-reasoned
### 5. USER IMPACT
**Affected users:**
- Servers with IPMI/BMC interfaces (common in enterprise/datacenter environments)
- Users who update BMC firmware while the system is running
**Impact without fix:**
- After BMC firmware updates, IPMI channel information becomes stale
- System management through IPMI may malfunction
- Users must reboot to get correct channel information
**Severity:** Medium - affects functionality, not crashes or data corruption
### 6. STABILITY INDICATORS
- Signed off by IPMI subsystem maintainer
- The fix logic is straightforward and verifiable by inspection
- No complex algorithmic changes
### 7. DEPENDENCY CHECK
- Self-contained fix with no dependencies on other commits
- ipmi_msghandler.c exists in all stable trees (mature driver)
- The affected functions (__scan_channels, channel_handler) exist in stable kernels
### Risk vs Benefit Assessment
**Benefits:**
- Fixes real-world bug: BMC firmware updates are common maintenance operations
- Small, surgical fix with minimal code changes
- IPMI is critical for server management in enterprise environments
**Risks:**
- Very low - the change is obviously correct
- Adding a parameter and clearing a flag is straightforward
- No behavioral changes to working code paths (initial scan unchanged)
### Concerns
1. **No Fixes: tag** - Cannot determine when bug was introduced, making it harder to know which stable versions need it
2. **No explicit Cc: stable** - Author didn't request backport
3. **Specific scenario** - Only affects systems where BMC firmware changes at runtime
### Conclusion
This commit fixes a legitimate functional bug where IPMI channel rescanning fails after BMC firmware changes. The fix is:
- **Obviously correct**: Clear a "ready" flag before rescanning
- **Small and contained**: ~15 lines in one file
- **Fixes a real bug**: Users who update BMC firmware encounter this
- **Low risk**: Simple boolean flag manipulation
While it lacks explicit stable tags, the fix is valuable for enterprise users who rely on IPMI for server management. The change is minimal, the logic is clear, and it restores expected functionality without introducing new features.
**YES**
drivers/char/ipmi/ipmi_msghandler.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/char/ipmi/ipmi_msghandler.c +13 -5
@@ -599,7 +599,8 @@ static void __ipmi_bmc_unregister(struct ipmi_smi *intf);static int __ipmi_bmc_register (struct ipmi_smi *intf,struct ipmi_device_id *id,bool guid_set,guid_t *guid,int intf_num); -static int __scan_channels (struct ipmi_smi *intf,struct ipmi_device_id *id); +static int __scan_channels (struct ipmi_smi *intf, +struct ipmi_device_id *id,bool rescan);static void free_ipmi_user (struct kref *ref) {
@@ -2668,7 +2669,7 @@ static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,if (__ipmi_bmc_register (intf, &id, guid_set, &guid, intf_num))need_waiter (intf);/* Retry later on an error. */ else -__scan_channels (intf, &id); +__scan_channels (intf, &id, false);if (!intf_set) {
@@ -2688,7 +2689,7 @@ static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, goto out_noprocessing; }else if (memcmp (&bmc->fetch_id, &bmc->id,sizeof (bmc->id)))/* Version info changes, scan the channels again. */ -__scan_channels (intf, &bmc->fetch_id); +__scan_channels (intf, &bmc->fetch_id, true); bmc->dyn_id_expiry = jiffies +IPMI_DYN_DEV_ID_EXPIRY ;
@@ -3438,10 +3439,17 @@ channel_handler(struct ipmi_smi *intf, struct ipmi_recv_msg *msg)/* * Must be holding intf->bmc_reg_mutex to call this. */ -static int __scan_channels (struct ipmi_smi *intf,struct ipmi_device_id *id) +static int __scan_channels (struct ipmi_smi *intf, +struct ipmi_device_id *id, +bool rescan) {int rv; +if (rescan) { +/* Clear channels_ready to force channels rescan. */ + intf->channels_ready = false; + } +if (ipmi_version_major (id) >1 || (ipmi_version_major (id) ==1 &&ipmi_version_minor (id) >=5 )) {
@@ -3656,7 +3664,7 @@ int ipmi_add_smi(struct module *owner, }mutex_lock (&intf->bmc_reg_mutex); - rv =__scan_channels (intf, &id); + rv =__scan_channels (intf, &id, false);mutex_unlock (&intf->bmc_reg_mutex);if (rv) goto out_err_bmc_reg;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 scsi: qla2xxx: Fix initiator mode with qlini_mode=exclusive
In reply to Sasha LevinFrom: Tony Battersby <[email protected]>
[ Upstream commit 8f58fc64d559b5fda1b0a5e2a71422be61e79ab9 ]
When given the module parameter qlini_mode=exclusive, qla2xxx in initiator mode is initially unable to successfully send SCSI commands to devices it finds while scanning, resulting in an escalating series of resets until an adapter reset clears the issue. Fix by checking the active mode instead of the module parameter.
---
LLM Generated explanations, may be completely bogus:
## Complete Analysis
### 1. Commit Message Analysis
The commit describes a clear bug:
- **Problem:** When using qlini_mode=exclusive, qla2xxx in initiator mode fails to send SCSI commands to discovered devices
- **Symptom:** Escalating series of resets until an adapter reset clears the issue
- **Fix:** Check the active mode instead of the module parameter
No Cc: [email protected] or Fixes: tags are present, but this doesn't preclude backporting if the fix clearly meets stable criteria.
### 2. Code Change Analysis - The Bug
**Buggy logic (lines 3446-3458):**
```c
if (ha->mqenable) {
bool startit = false;
if (QLA_TGT_MODE_ENABLED())
startit = false;
if (ql2x_ini_mode == QLA2XXX_INI_MODE_ENABLED)
startit = true;
for (i = 0; i < ha->max_qpairs; i++)
qla2xxx_create_qpair(base_vha, 5, 0, startit);
}
```The mode values from qla_target.h:
- QLA2XXX_INI_MODE_EXCLUSIVE = 0 (exclusive initiator mode - **an initiator mode!**)
- QLA2XXX_INI_MODE_DISABLED = 1
- QLA2XXX_INI_MODE_ENABLED = 2 (standard initiator mode)
- QLA2XXX_INI_MODE_DUAL = 3
**Root cause:** The code only checks for QLA2XXX_INI_MODE_ENABLED (value 2). When qlini_mode=exclusive is used, ql2x_ini_mode equals QLA2XXX_INI_MODE_EXCLUSIVE (value 0), so startit remains false. Queue pairs are never started for initiator traffic, causing SCSI commands to fail.
**The fix:**
```c bool startit = !!(host->active_mode & MODE_INITIATOR); ```
This uses the runtime active_mode flag which is already correctly set for all initiator modes elsewhere in the driver (see qla_target.c:6493,6511,6515 - all set active_mode = MODE_INITIATOR for various initiator modes including "exclusive").
### 3. Classification
- **Type:** Bug fix (not a new feature)
- **Severity:** HIGH - causes complete failure of SCSI command processing
- **Category:** Logic error in mode detection
### 4. Scope and Risk Assessment
| Factor | Assessment | |--------|------------| | Lines changed | -8 removed, +1 added (net simplification) | | Files touched | 1 (qla_os.c) | | Complexity | LOW - replaces complex logic with simple check | | Risk of regression | VERY LOW - uses existing tested pattern |
### 5. User Impact
- **Who is affected:** Users of QLogic Fibre Channel HBAs (QLA2xxx) with qlini_mode=exclusive
- **Severity:** Complete functional failure - SCSI commands fail, adapter resets repeatedly
- **Impact area:** Enterprise storage - FC HBAs are common in data centers
### 6. Stability Indicators
- Signed-off by the SCSI maintainer (Martin K. Petersen)
- Uses host->active_mode pattern already proven throughout the driver
- The fix simplifies the code, reducing bug surface area
### 7. Dependency Check
- The host->active_mode field exists in all stable kernels (it's part of struct Scsi_Host in include/scsi/scsi_host.h)
- The MODE_INITIATOR constant (0x01) is standard
- No dependencies on other commits
---
## Conclusion
This commit should be backported to stable kernels because:
1. **Fixes a real, serious bug:** Users with qlini_mode=exclusive experience complete storage failure with escalating resets
2. **Obviously correct:** The fix uses the authoritative runtime mode (host->active_mode) instead of trying to derive it from module parameters
3. **Small and surgical:** Removes 8 lines of incorrect logic, adds 1 correct line
4. **Low risk:** Uses existing, well-tested infrastructure that's already used throughout the driver
5. **No new features:** Pure bug fix that restores intended functionality
6. **Important hardware:** QLogic FC HBAs are widely deployed in enterprise environments
The lack of explicit Cc: stable@ tag is not disqualifying when the fix clearly meets all stable kernel criteria.
**YES**
drivers/scsi/qla2xxx/qla_os.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +1 -7
@@ -3444,13 +3444,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) ha->mqenable =0 ;if (ha->mqenable) { -bool startit = false; - -if (QLA_TGT_MODE_ENABLED ()) - startit = false; - -if (ql2x_ini_mode ==QLA2XXX_INI_MODE_ENABLED ) - startit = true; +bool startit = !!(host->active_mode &MODE_INITIATOR );/* Create start of day qpairs for Block MQ */ for (i =0 ; i < ha->max_qpairs; i++)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 um: init cpu_tasks[] earlier
In reply to Sasha LevinFrom: Johannes Berg <[email protected]>
[ Upstream commit 7b5d4416964c07c902163822a30a622111172b01 ]
This is currently done in uml_finishsetup(), but e.g. with KCOV enabled we'll crash because some init code can call into e.g. memparse(), which has coverage annotations, and then the checks in check_kcov_mode() crash because current is NULL.
Simply initialize the cpu_tasks[] array statically, which fixes the crash. For the later SMP work, it seems to have not really caused any problems yet, but initialize all of the entries anyway.
---
LLM Generated explanations, may be completely bogus:
## Analysis Summary
### Bug Mechanism
This commit fixes a **boot crash** in User Mode Linux (UML) when KCOV (kernel code coverage) is enabled:
1. **Root cause**: In UML, current is defined as cpu_tasks[0] (see arch/um/include/asm/current.h:15)
2. **Problem**: cpu_tasks[] was uninitialized (NULL) until uml_finishsetup() was called late in boot
3. **Trigger**: With KCOV enabled, early init code calls coverage- annotated functions like memparse()
4. **Crash path**: KCOV's __sanitizer_cov_trace_pc → check_kcov_mode(current) → dereferences NULL current → crash
### The Fix
The fix is elegantly simple:
- **Before**: struct task_struct *cpu_tasks[NR_CPUS]; (zero- initialized, i.e., NULL)
- **After**: `struct task_struct *cpu_tasks[NR_CPUS] = { [0 ... NR_CPUS
- 1] = &init_task };`
This ensures current is valid (&init_task) from the very start of kernel execution. The runtime initialization in uml_finishsetup() is removed since it's now redundant.
### Stable Criteria Assessment
| Criteria | Assessment | |----------|------------| | Fixes a real bug? | **YES** - Boot crash with KCOV enabled | | Obviously correct? | **YES** - Same value (`&init_task`), just initialized earlier | | Small and contained? | **YES** - 2 files, +3/-3 lines, net -1 | | No new features? | **YES** - Pure bug fix | | Low regression risk? | **YES** - Identical initialization, just at compile time | | Self-contained? | **YES** - No dependencies on other patches |
### Risk Assessment
- **Risk**: Very low. The initialization value is exactly what was done before in uml_finishsetup(), just done statically at compile time instead of at runtime.
- **Scope**: Limited to UML architecture only
- **Impact**: Fixes complete boot failure for UML+KCOV users
### Concerns
- No explicit Cc: [email protected] tag
- No Fixes: tag to identify when bug was introduced
- Affects only UML users (niche architecture, but important for kernel testing/development)
### Conclusion
This is a textbook stable backport candidate:
- Fixes a real, reproducible crash (not theoretical)
- The fix is minimal, surgical, and obviously correct
- Zero risk of introducing regressions since the same value is used, just initialized earlier
- The infrastructure (init_task, cpu_tasks[]) has existed in stable trees for years
The lack of explicit stable tags appears to be an oversight. The fix is appropriate for any stable tree that has both UML support and KCOV support.
**YES**
arch/um/kernel/process.c | 4 +++- arch/um/kernel/um_arch.c | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/um/kernel/process.c +3 -1
@@ -43,7 +43,9 @@* cares about its entry, so it's OK if another processor is modifying its * entry. */ -struct task_struct *cpu_tasks[NR_CPUS ]; +struct task_struct *cpu_tasks[NR_CPUS ] = { + [0 ...NR_CPUS -1 ] = &init_task, +};EXPORT_SYMBOL (cpu_tasks);void free_stack (unsigned long stack,int order)
arch/um/kernel/um_arch.c +0 -2
@@ -239,8 +239,6 @@ static struct notifier_block panic_exit_notifier = {void uml_finishsetup (void ) { - cpu_tasks[0 ] = &init_task; -atomic_notifier_chain_register (&panic_notifier_list, &panic_exit_notifier);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 reset: fix BIT macro reference
In reply to Sasha LevinFrom: Encrow Thorne <[email protected]>
[ Upstream commit f3d8b64ee46c9b4b0b82b1a4642027728bac95b8 ]
RESET_CONTROL_FLAGS_BIT_* macros use BIT(), but reset.h does not include bits.h. This causes compilation errors when including reset.h standalone.
Include bits.h to make reset.h self-contained.
---
LLM Generated explanations, may be completely bogus:
## Summary of Findings
### Bug Introduction
The bug was introduced by commit dad35f7d2fc14 ("reset: replace boolean parameters with flags parameter") which added the RESET_CONTROL_FLAGS_BIT_* macros using BIT(). This was merged in **v6.13-rc1** (October 2024).
### Affected Stable Trees
- **6.13.x stable**: YES - affected, needs this fix
- **6.12.x and earlier**: NO - the RESET_CONTROL_FLAGS_BIT_* macros don't exist in these trees
### Stable Kernel Criteria Assessment
| Criterion | Assessment | |-----------|------------| | Obviously correct? | ✅ YES - adding a missing include is trivially correct | | Fixes real bug? | ✅ YES - compilation error when including reset.h standalone | | Important issue? | ✅ YES - build failures are hard blockers | | Small and contained? | ✅ YES - 1 line change | | No new features? | ✅ YES - only fixes missing dependency | | Low risk? | ✅ YES - zero runtime risk, cannot cause regressions |
### Why This Should Be Backported
1. **Build Fix Exception**: Build fixes are explicitly allowed in stable per Documentation/process/stable-kernel-rules.rst - this is an "include file fix" that makes the header self-contained.
2. **Zero Risk**: Adding a required include cannot cause runtime regressions. The bits.h header is universally available.
3. **Real Bug**: The compilation error is real - the header uses BIT() macro without including its definition.
4. **Reviewed by Maintainer**: Philipp Zabel (reset subsystem maintainer) reviewed and signed off, providing confidence in the fix.
5. **Minimal Change**: Single line addition - the smallest possible fix.
### Concerns
- No explicit Cc: [email protected] or Fixes: tag from maintainer, but this appears to be an oversight given the clear build- fix nature
- Only applicable to 6.13.x stable (older trees don't have the affected code)
### Conclusion
This is a textbook example of a stable-appropriate build fix: minimal, zero-risk, fixes a real compilation error, and makes the header properly self-contained. The fix should be backported to the 6.13.x stable tree where the bug exists.
**YES**
include/linux/reset.h | 1 + 1 file changed, 1 insertion(+)
include/linux/reset.h +1 -0
@@ -2,6 +2,7 @@#ifndef _LINUX_RESET_H_#define _LINUX_RESET_H_ +#include <linux/bits.h> #include <linux/err.h> #include <linux/errno.h> #include <linux/types.h>
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 clk: mvebu: cp110 add CLK_IGNORE_UNUSED to pcie_x10, pcie_x11 & pcie_x4
In reply to Sasha LevinFrom: Josua Mayer <[email protected]>
[ Upstream commit f0e6bc0c3ef4b4afb299bd6912586cafd5d864e9 ]
CP110 based platforms rely on the bootloader for pci port initialization.
TF-A actively prevents non-uboot re-configuration of pci lanes, and many boards do not have software control over the pci card reset.
If a pci port had link at boot-time and the clock is stopped at a later point, the link fails and can not be recovered.
PCI controller driver probe - and by extension ownership of a driver for the pci clocks - may be delayed especially on large modular kernels, causing the clock core to start disabling unused clocks.
Add the CLK_IGNORE_UNUSED flag to the three pci port's clocks to ensure they are not stopped before the pci controller driver has taken ownership and tested for an existing link.
This fixes failed pci link detection when controller driver probes late, e.g. with arm64 defconfig and CONFIG_PHY_MVEBU_CP110_COMPHY=m.
---
LLM Generated explanations, may be completely bogus:
## Commit Analysis: clk: mvebu: cp110 add CLK_IGNORE_UNUSED to pcie_x10, pcie_x11 & pcie_x4
### 1. COMMIT MESSAGE ANALYSIS
**Subject:** Adding CLK_IGNORE_UNUSED flag to three PCIe clock gates on Marvell CP110 platforms.
**Key problem described:**
- CP110 platforms rely on bootloader for PCIe port initialization
- TF-A (Trusted Firmware-A) prevents non-U-Boot reconfiguration of PCIe lanes
- Many boards lack software control over PCIe card reset
- If a PCIe port had an active link at boot and the clock is stopped later, the link fails permanently and cannot be recovered
- PCIe controller driver probe may be delayed on large modular kernels, causing the clock framework to disable "unused" clocks before the driver takes ownership
**Important tags:**
- **No "Cc: [email protected]"** - maintainer didn't explicitly request backport
- **No "Fixes:" tag** - unclear when the issue was introduced
- **Reviewed-by: Andrew Lunn** - reputable ARM/networking kernel developer
- **Closes:** link to lore.kernel.org bug report - confirms real users hit this
### 2. CODE CHANGE ANALYSIS
The change adds a new gate_flags() helper function that returns CLK_IGNORE_UNUSED for three specific clock gates:
- CP110_GATE_PCIE_X1_0 (pcie_x10)
- CP110_GATE_PCIE_X1_1 (pcie_x11)
- CP110_GATE_PCIE_X4 (pcie_x4)
This flag is then passed to init.flags when registering gate clocks.
**Technical mechanism of the bug:**
1. Boot proceeds with PCIe link established by bootloader
2. Clock framework marks these PCIe clocks as "unused" (no driver claimed them yet)
3. Late in boot, clock framework garbage-collects unused clocks
4. PCIe clocks are disabled, breaking the active link
5. When PCIe driver finally probes (especially in modular configs), link is irrecoverably failed
**What CLK_IGNORE_UNUSED does:**
Tells the clock framework to never disable these clocks just because they appear unclaimed. This is the standard mechanism for clocks that must remain active until a driver explicitly takes ownership.
### 3. CLASSIFICATION
**Type:** Hardware workaround / quirk for platform-specific behavior
This falls into the "quirks and workarounds" exception category for stable kernels. It's a workaround for the specific constraints of the Marvell CP110 platform where:
- TF-A manages PCIe lane configuration
- Clock disable breaks PCIe links irreversibly
- Driver load timing varies across kernel configurations
### 4. SCOPE AND RISK ASSESSMENT
**Size:** ~21 lines added, 1 file changed, self-contained
**Risk level:** LOW
- Only affects Marvell CP110 platforms
- No changes to core clock framework
- Worst case: slightly higher power consumption (clocks stay on when could be off)
- No chance of breaking other subsystems
**Subsystem:** mvebu clock driver - mature platform-specific driver
### 5. USER IMPACT
**Affected users:** Marvell CP110-based platforms (Armada 7K/8K, SolidRun products, etc.)
**Severity:** HIGH for affected users - PCIe devices completely fail to be detected
**Real-world evidence:**
- Bug report on lore.kernel.org linked in commit
- Reproducible with "arm64 defconfig and
CONFIG_PHY_MVEBU_CP110_COMPHY=m"
### 6. STABILITY INDICATORS
- **Reviewed-by:** Andrew Lunn (highly respected maintainer for this subsystem)
- The CP110 clock driver has existed for years - this isn't new code
- Change is isolated and uses standard clock framework mechanisms
### 7. DEPENDENCY CHECK
- Self-contained change, no dependencies on other commits
- The CP110 clock driver exists in stable trees
- No required prerequisite patches
### CONCERNS
1. **No explicit stable tag** - maintainer didn't mark for backport
2. **No Fixes: tag** - we don't know how far back this issue goes
3. **Workaround approach** - CLK_IGNORE_UNUSED is somewhat heavy-handed but appropriate here
### DECISION ANALYSIS
**For backporting:**
- Fixes real hardware failure (PCIe not working) on production hardware
- Small, surgical, self-contained fix
- Very low regression risk (only affects specific ARM platform)
- Follows the "hardware quirk" exception pattern for stable
- Uses standard clock framework mechanisms
- Has review from reputable subsystem maintainer
**Against backporting:**
- No Cc: stable from maintainer
- Affects relatively niche ARM SoC platform
- No indication of when bug was introduced
### Conclusion
This commit fixes a real, user-impacting bug where PCIe devices fail to be detected on Marvell CP110-based platforms. The fix is a standard hardware quirk/workaround pattern - adding CLK_IGNORE_UNUSED to prevent premature clock disabling that breaks active PCIe links. The change is small (~21 lines), isolated to a single platform-specific driver, carries minimal regression risk, and has been reviewed by a reputable kernel maintainer.
While there's no explicit stable tag, this fits the stable criteria for hardware workarounds that fix real user-facing bugs. The worst case (clocks stay on unnecessarily) is far preferable to the current bug (PCIe completely broken).
**YES**
drivers/clk/mvebu/cp110-system-controller.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/clk/mvebu/cp110-system-controller.c +20 -0
@@ -110,6 +110,25 @@ static const char * const gate_base_names[] = { [CP110_GATE_EIP197 ] ="eip197" }; +static unsigned long gate_flags (const u8 bit_idx) +{ +switch (bit_idx) { +case CP110_GATE_PCIE_X1_0 : +case CP110_GATE_PCIE_X1_1 : +case CP110_GATE_PCIE_X4 : +/* +* If a port had an active link at boot time, stopping +* the clock creates a failed state from which controller +* driver can not recover. +* Prevent stopping this clock till after a driver has taken +* ownership. +*/ +return CLK_IGNORE_UNUSED ; +default : +return 0 ; + } +}; +struct cp110_gate_clk {struct clk_hw hw;struct regmap *regmap;
@@ -171,6 +190,7 @@ static struct clk_hw *cp110_register_gate(const char *name, init.ops = &cp110_gate_ops; init.parent_names = &parent_name; init.num_parents =1 ; + init.flags =gate_flags (bit_idx); gate->regmap = regmap; gate->bit_idx = bit_idx;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 fuse: Always flush the page cache before FOPEN_DIRECT_IO write
In reply to Sasha LevinFrom: Bernd Schubert <[email protected]>
[ Upstream commit 1ce120dcefc056ce8af2486cebbb77a458aad4c3 ]
This was done as condition on direct_io_allow_mmap, but I believe this is not right, as a file might be open two times - once with write-back enabled another time with FOPEN_DIRECT_IO.
---
LLM Generated explanations, may be completely bogus:
## Analysis Summary
### 1. WHAT THE COMMIT FIXES
This commit addresses a **data coherency bug** in FUSE when a file can be opened twice with different modes:
- **File descriptor A**: opened normally with page cache (write-back caching enabled)
- **File descriptor B**: opened with FOPEN_DIRECT_IO flag
**The Bug:**
The original code only flushed dirty pages before direct I/O when fc->direct_io_allow_mmap was enabled. However, dirty pages can exist regardless of this flag - they can come from a write-back cached file handle to the same file.
**Data corruption scenario:**
1. Write data via normal cached file handle → creates dirty pages in page cache
2. Write to same location via FOPEN_DIRECT_IO handle → goes directly to backend storage
3. Later, dirty pages from step 1 flush to disk → **OVERWRITE** the direct IO data
This causes **data loss/corruption** where writes via direct I/O are silently overwritten.
### 2. CODE CHANGE ANALYSIS
The change is minimal:
```c
- if (fopen_direct_io && fc->direct_io_allow_mmap) {
+ if (fopen_direct_io) {
```Simply removes the && fc->direct_io_allow_mmap condition, making the filemap_write_and_wait_range() call happen for **all** FOPEN_DIRECT_IO operations, not just when direct_io_allow_mmap is enabled.
### 3. STABLE CRITERIA CHECK
| Criterion | Assessment | |-----------|------------| | Obviously correct | ✅ The fix is logically sound - always flush dirty pages before direct IO | | Fixes real bug | ✅ Data corruption/loss in specific multi-fd scenarios | | Important issue | ✅ Data corruption is severe | | Small and contained | ✅ Single condition removal, one file | | No new features | ✅ Pure correctness fix | | Clean application | ✅ Should apply cleanly |
### 4. RISK ASSESSMENT
**Risk: LOW**
- The change is **conservative** - it flushes *more* often, not less
- Worst case: slight performance regression from additional sync operations
- Best case: prevents data corruption in mixed cached/direct IO scenarios
- The affected code path (fuse_direct_io) is well-established
### 5. BACKPORT CONCERNS
**Negative signals:**
- No Cc: [email protected] tag
- No Fixes: tag pointing to b5a2a3a0b7766 (which introduced the incomplete logic)
**Positive signals:**
- Small, surgical fix
- Fixes data corruption (high severity)
- Maintainer-reviewed (signed off by Miklos Szeredi, FUSE maintainer)
- Safe direction of change
### 6. VERSION APPLICABILITY
The original buggy commit (b5a2a3a0b7766) was merged in v6.10, so this fix applies to:
- v6.10.y through current stable trees
### 7. USER IMPACT
Affects FUSE users who:
- Use FOPEN_DIRECT_IO feature
- Have the same file opened through multiple file descriptors with different caching modes
- This is not a theoretical scenario - FUSE servers like libfuse can legitimately have files accessed this way
### CONCLUSION
Despite the absence of explicit Cc: stable tags, this commit **should be backported**. It fixes a real data corruption bug with a minimal, obviously correct change. The fix is safe (more synchronization, not less), small, and addresses a serious issue. The lack of stable tags appears to be an oversight rather than an indication the fix isn't needed in stable. Data corruption bugs in filesystems are exactly the type of issue stable trees exist to fix.
**YES**
fs/fuse/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/file.c +1 -1
@@ -1607,7 +1607,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,if (!ia)return -ENOMEM ; -if (fopen_direct_io && fc->direct_io_allow_mmap) { +if (fopen_direct_io) { res =filemap_write_and_wait_range (mapping, pos, pos + count -1 );if (res) {fuse_io_free (ia);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 firmware: imx: scu-irq: Init workqueue before request mbox channel
In reply to Sasha LevinFrom: Peng Fan <[email protected]>
[ Upstream commit 81fb53feb66a3aefbf6fcab73bb8d06f5b0c54ad ]
With mailbox channel requested, there is possibility that interrupts may come in, so need to make sure the workqueue is initialized before the queue is scheduled by mailbox rx callback.
---
LLM Generated explanations, may be completely bogus:
## Analysis Summary
### What the Bug Is
This commit fixes a classic **initialization race condition** in the i.MX SCU IRQ driver. The problem is:
1. mbox_request_channel_byname(cl, "gip3") is called, which sets up a mailbox channel with imx_scu_irq_callback as the receive callback
2. Once the channel is established, interrupts from the System Controller Unit (SCU) can trigger the callback **at any time**
3. The callback (imx_scu_irq_callback at line 175-178) calls schedule_work(&imx_sc_irq_work)
4. **But** INIT_WORK(&imx_sc_irq_work, ...) was being called **after** the mailbox channel was requested
If an interrupt arrives in the window between mbox_request_channel_byname() and INIT_WORK(), it would schedule an uninitialized work struct, leading to undefined behavior, crashes, or memory corruption in the workqueue subsystem.
### The Fix
The fix is trivially correct: move INIT_WORK() to **before** mbox_request_channel_byname(). This ensures the work struct is properly initialized before any callback can possibly use it.
### Bug Origin
The bug was introduced in commit 851826c7566e9 ("firmware: imx: enable imx scu general irq function") in kernel v5.2-rc1 when this driver was first created. The initialization order was wrong from the very beginning.
### Stable Kernel Criteria Assessment
| Criterion | Assessment | |-----------|------------| | Obviously correct | ✅ Yes - classic "initialize before use" pattern | | Fixes real bug | ✅ Yes - race condition causing potential crashes | | Small and contained | ✅ Yes - moves one line of code | | No new features | ✅ Correct - purely a fix | | Tested | ✅ Has Reviewed-by from NXP engineer | | Low risk | ✅ Cannot introduce regressions |
### Risk vs. Benefit
- **Risk**: Extremely low - the work struct must be initialized before use regardless of when the first interrupt arrives; moving initialization earlier cannot break anything
- **Benefit**: Prevents crashes on i.MX SoC platforms (used in embedded systems, automotive, IoT devices) where early interrupts could trigger the race
### Dependencies
None - this is a self-contained single-line reordering fix that should apply cleanly to any kernel with this driver (5.2+).
### Conclusion
This is an ideal stable backport candidate. It fixes a real initialization race condition that can cause crashes, the fix is obviously correct (a single line moved earlier in the initialization sequence), it's minimal and surgical, and it affects real users of i.MX SoC platforms. The only missing element is an explicit `Cc:
[email protected]` tag, but the fix clearly meets all stable kernel rules.
**YES**
drivers/firmware/imx/imx-scu-irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/imx/imx-scu-irq.c +2 -2
@@ -214,6 +214,8 @@ int imx_scu_enable_general_irq_channel(struct device *dev) cl->dev = dev; cl->rx_callback = imx_scu_irq_callback; +INIT_WORK (&imx_sc_irq_work, imx_scu_irq_work_handler); +/* SCU general IRQ uses general interrupt channel 3 */ ch =mbox_request_channel_byname (cl,"gip3" );if (IS_ERR (ch)) {
@@ -223,8 +225,6 @@ int imx_scu_enable_general_irq_channel(struct device *dev)return ret; } -INIT_WORK (&imx_sc_irq_work, imx_scu_irq_work_handler); -if (!of_parse_phandle_with_args (dev->of_node,"mboxes" ,"#mbox-cells" ,0 , &spec)) i =of_alias_get_id (spec.np,"mu" );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 scsi: lpfc: Fix reusing an ndlp that is marked NLP_DROPPED during FLOGI
In reply to Sasha LevinFrom: Justin Tee <[email protected]>
[ Upstream commit 07caedc6a3887938813727beafea40f07c497705 ]
It's possible for an unstable link to repeatedly bounce allowing a FLOGI retry, but then bounce again forcing an abort of the FLOGI. Ensure that the initial reference count on the FLOGI ndlp is restored in this faulty link scenario.
---
LLM Generated explanations, may be completely bogus:
Looking at this commit, I need to analyze it thoroughly to determine if it's suitable for stable backporting.
## Commit Analysis
### 1. Problem Being Fixed
This commit fixes a **reference counting bug** in the lpfc (Broadcom Fibre Channel) driver. The issue occurs when:
1. A FLOGI (Fabric Login) is issued on an unstable link
2. The link bounces, causing the FLOGI to abort
3. The ndlp (node list pointer) gets marked NLP_DROPPED and its reference count is decremented via lpfc_nlp_put()
4. The link comes back and lpfc tries to reuse the same ndlp for a new FLOGI retry
5. The ndlp is still marked NLP_DROPPED with a decremented refcount, causing reference count imbalances
This can lead to **use-after-free** or **double-free** conditions - serious kernel stability and security issues.
### 2. Code Changes Analysis
The fix is surgical and well-designed:
**In lpfc_issue_els_flogi():**
- Adds a check: if ndlp is marked NLP_DROPPED, clear the flag and restore the reference count with lpfc_nlp_get()
- This is the core fix - properly restoring state when retrying with a previously-dropped ndlp
**In lpfc_cmpl_els_flogi():**
- Before calling lpfc_nlp_put(), now checks if NLP_DROPPED is already set
- Sets NLP_DROPPED atomically before decrementing to prevent double- decrement
**In lpfc_dev_loss_tmo_handler():**
- Uses test_and_set_bit(NLP_DROPPED, ...) to atomically check and set, preventing races
**In lpfc_check_nlp_post_devloss():**
- Clears NLP_DROPPED when restoring the ndlp reference
### 3. Scope and Risk Assessment
- **Files changed:** 2 files in lpfc driver only
- **Lines changed:** ~50 lines of code
- **Scope:** Limited to lpfc FLOGI handling and devloss timeout paths
- **Risk:** MEDIUM - Reference counting changes require care, but these use proper atomic operations (test_and_set_bit, test_and_clear_bit)
### 4. Stable Criteria Evaluation
**Meets stable criteria:**
- ✅ Fixes a real bug (reference count corruption causing potential use- after-free)
- ✅ Small and contained to specific driver (lpfc)
- ✅ No new features added
- ✅ Clear mechanism: adds proper NLP_DROPPED flag tracking to prevent refcount imbalance
- ✅ Affects real-world scenarios: unstable FC links occur in enterprise environments
**Concerns:**
- ❌ No "Fixes:" tag indicating when bug was introduced
- ❌ No "Cc: [email protected]" tag
- The NLP_DROPPED flag usage appears to exist in older kernels already
### 5. User Impact
- **Who is affected:** Users with Broadcom lpfc Fibre Channel HBAs in enterprise storage environments
- **Severity:** HIGH - Reference count bugs can cause kernel crashes, data corruption, or security vulnerabilities
- **Likelihood:** MODERATE - Requires unstable FC link conditions, but these occur in real deployments
### 6. Backport Feasibility
The changes use standard kernel primitives (test_and_set_bit, test_and_clear_bit). The NLP_DROPPED flag and the functions being modified (lpfc_nlp_put, lpfc_nlp_get, lpfc_check_nlp_post_devloss) appear to exist in stable kernels. The patch should apply cleanly or with minor adjustments.
## Conclusion
This is a legitimate bug fix for a reference counting issue that can cause serious problems (use-after-free, crashes) in enterprise Fibre Channel environments. The fix is well-designed with proper atomic operations and is contained to the lpfc driver. While there's no explicit stable tag, the nature of the bug (reference counting corruption in a widely-used enterprise driver) makes it appropriate for stable backporting.
The fix is small, surgical, and addresses a real stability/potential security issue. Enterprise users with lpfc HBAs who experience link instability would benefit from this fix.
**YES**
drivers/scsi/lpfc/lpfc_els.c | 36 +++++++++++++++++++++++++------- drivers/scsi/lpfc/lpfc_hbadisc.c | 4 +++- 2 files changed, 32 insertions(+), 8 deletions(-)
drivers/scsi/lpfc/lpfc_els.c +29 -7
@@ -934,10 +934,15 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,/* Check to see if link went down during discovery */ if (lpfc_els_chk_latt (vport)) {/* One additional decrement on node reference count to -* trigger the release of the node +* trigger the release of the node. Make sure the ndlp +* is marked NLP_DROPPED. */ -if (!(ndlp->fc4_xpt_flags &SCSI_XPT_REGD )) +if (!test_bit (NLP_IN_DEV_LOSS , &ndlp->nlp_flag) && + !test_bit (NLP_DROPPED , &ndlp->nlp_flag) && + !(ndlp->fc4_xpt_flags &SCSI_XPT_REGD )) { +set_bit (NLP_DROPPED , &ndlp->nlp_flag);lpfc_nlp_put (ndlp); + } goto out; }
@@ -995,9 +1000,10 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, IOERR_LOOP_OPEN_FAILURE))) lpfc_vlog_msg(vport, KERN_WARNING, LOG_ELS,"2858 FLOGI Status:x%x/x%x TMO" -":x%x Data x%lx x%x\n" , +":x%x Data x%lx x%x x%lx x%x\n" , ulp_status, ulp_word4, tmo, - phba->hba_flag, phba->fcf.fcf_flag); + phba->hba_flag, phba->fcf.fcf_flag, + ndlp->nlp_flag, ndlp->fc4_xpt_flags);/* Check for retry */ if (lpfc_els_retry (phba, cmdiocb, rspiocb)) {
@@ -1015,14 +1021,17 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,* reference to trigger node release. */ if (!test_bit (NLP_IN_DEV_LOSS , &ndlp->nlp_flag) && - !(ndlp->fc4_xpt_flags &SCSI_XPT_REGD )) + !test_bit (NLP_DROPPED , &ndlp->nlp_flag) && + !(ndlp->fc4_xpt_flags &SCSI_XPT_REGD )) { +set_bit (NLP_DROPPED , &ndlp->nlp_flag);lpfc_nlp_put (ndlp); + }lpfc_printf_vlog (vport,KERN_WARNING ,LOG_ELS ,"0150 FLOGI Status:x%x/x%x " -"xri x%x TMO:x%x refcnt %d\n" , +"xri x%x iotag x%x TMO:x%x refcnt %d\n" , ulp_status, ulp_word4, cmdiocb->sli4_xritag, - tmo,kref_read (&ndlp->kref)); + cmdiocb->iotag, tmo,kref_read (&ndlp->kref));/* If this is not a loop open failure, bail out */ if (!(ulp_status == IOSTAT_LOCAL_REJECT &&
@@ -1279,6 +1288,19 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,uint32_t tmo, did;int rc; +/* It's possible for lpfc to reissue a FLOGI on an ndlp that is marked +* NLP_DROPPED. This happens when the FLOGI completed with the XB bit +* set causing lpfc to reference the ndlp until the XRI_ABORTED CQE is +* issued. The time window for the XRI_ABORTED CQE can be as much as +* 2*2*RA_TOV allowing for ndlp reuse of this type when the link is +* cycling quickly. When true, restore the initial reference and remove +* the NLP_DROPPED flag as lpfc is retrying. +*/ +if (test_and_clear_bit (NLP_DROPPED , &ndlp->nlp_flag)) { +if (!lpfc_nlp_get (ndlp)) +return 1 ; + } + cmdsize = (sizeof (uint32_t ) +sizeof (struct serv_parm )); elsiocb =lpfc_prep_els_iocb (vport,1 , cmdsize, retry, ndlp, ndlp->nlp_DID,ELS_CMD_FLOGI );
drivers/scsi/lpfc/lpfc_hbadisc.c +3 -1
@@ -424,6 +424,7 @@ lpfc_check_nlp_post_devloss(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) {if (test_and_clear_bit (NLP_IN_RECOV_POST_DEV_LOSS , &ndlp->save_flags)) { +clear_bit (NLP_DROPPED , &ndlp->nlp_flag);lpfc_nlp_get (ndlp);lpfc_printf_vlog (vport,KERN_INFO ,LOG_DISCOVERY |LOG_NODE , "8438 Devloss timeout reversed on DID x%x "
@@ -566,7 +567,8 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp)return fcf_inuse; } -lpfc_nlp_put (ndlp); +if (!test_and_set_bit (NLP_DROPPED , &ndlp->nlp_flag)) +lpfc_nlp_put (ndlp);return fcf_inuse; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 exfat: fix remount failure in different process environments
In reply to Sasha LevinFrom: Yuezhang Mo <[email protected]>
[ Upstream commit 51fc7b4ce10ccab8ea5e4876bcdc42cf5202a0ef ]
The kernel test robot reported that the exFAT remount operation failed. The reason for the failure was that the process's umask is different between mount and remount, causing fs_fmask and fs_dmask are changed.
Potentially, both gid and uid may also be changed. Therefore, when initializing fs_context for remount, inherit these mount options from the options used during mount.
---
LLM Generated explanations, may be completely bogus:
## Commit Analysis: exfat: fix remount failure in different process environments
### 1. COMMIT MESSAGE ANALYSIS
**Subject**: Contains "fix" keyword indicating a bug fix for remount failures.
**Key details from message**:
- Reported by kernel test robot - this is a real, reproducible issue
- Root cause: When remounting, the process's umask may differ from the original mount, causing fs_fmask and fs_dmask to unexpectedly change
- The same issue applies to gid and uid
- Has Closes: link to the bug report
**Missing tags**:
- No Cc: [email protected]
- No Fixes: tag indicating when the bug was introduced
### 2. CODE CHANGE ANALYSIS
**The Bug**:
```c // BEFORE: Always uses current process values sbi->options.fs_uid = current_uid(); sbi->options.fs_gid = current_gid(); sbi->options.fs_fmask = current->fs->umask; sbi->options.fs_dmask = current->fs->umask; ```
When exfat_init_fs_context() is called for a remount operation, it was incorrectly initializing uid/gid/fmask/dmask from the **current process** rather than preserving the existing mount options. If the process performing the remount has a different umask (or runs as a different user), the options change unexpectedly, causing remount validation failures.
**The Fix**:
```c
// AFTER: Check if this is a remount and inherit existing options
if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE && fc->root) {
struct super_block *sb = fc->root->d_sb;
struct exfat_mount_options *cur_opts = &EXFAT_SB(sb)->options;
sbi->options.fs_uid = cur_opts->fs_uid;
sbi->options.fs_gid = cur_opts->fs_gid;
sbi->options.fs_fmask = cur_opts->fs_fmask;
sbi->options.fs_dmask = cur_opts->fs_dmask;
} else {
// Original behavior for initial mount
...
}
```This is the correct behavior - remount should preserve existing mount options unless explicitly overridden by the user.
### 3. CLASSIFICATION
- **Type**: Bug fix (not a feature)
- **Category**: Filesystem correctness issue
- **Security**: Not a security issue
### 4. SCOPE AND RISK ASSESSMENT
| Metric | Value | |--------|-------| | Lines changed | ~15 (net +11) | | Files touched | 1 (fs/exfat/super.c) | | Complexity | Low - simple conditional logic | | Risk | Low - uses well-established fs_context patterns |
The fix is surgically targeted at exfat_init_fs_context() and uses standard fs_context APIs (fc->purpose, fc->root, FS_CONTEXT_FOR_RECONFIGURE) that other filesystems use identically.
### 5. USER IMPACT
- **Affected users**: Anyone using exFAT filesystems who performs remount operations
- **Scenario**: Common when system scripts, systemd units, or root user (with different umask) remount a filesystem
- **Severity**: Medium - causes remount failures, but not data corruption
- **Real-world impact**: Yes - kernel test robot found this in automated testing
### 6. STABILITY INDICATORS
- Signed-off by exFAT maintainer (Namjae Jeon)
- Triggered by automated kernel testing
- Logic is straightforward and follows established patterns used by other filesystems
### 7. DEPENDENCY CHECK
The fix relies on:
- fc->purpose and fc->root - standard fs_context fields available since the fs_context API conversion
- EXFAT_SB() macro - existing exFAT infrastructure
- FS_CONTEXT_FOR_RECONFIGURE - standard kernel constant
No additional dependencies required. The fix applies to any kernel with exFAT's fs_context implementation.
### STABLE KERNEL CRITERIA EVALUATION
| Criterion | Met? | |-----------|------| | Obviously correct | ✅ Yes - straightforward logic | | Fixes real bug | ✅ Yes - reported by kernel test robot | | Small and contained | ✅ Yes - single function, ~15 lines | | No new features | ✅ Yes - corrects existing behavior | | No new APIs | ✅ Yes - uses existing fs_context APIs |
### VERDICT
This commit fixes a genuine bug where exFAT remount operations fail when the remounting process has a different umask than the original mounting process. The fix is:
1. **Small and localized** - modifies one function in one file
2. **Obviously correct** - follows the same pattern other filesystems use for handling remount context initialization
3. **Low risk** - no architectural changes, just proper option inheritance
4. **User-impacting** - remount failures are a real usability issue
While the commit lacks explicit Cc: stable and Fixes: tags, the nature of the fix (correcting filesystem remount behavior) and its minimal footprint make it appropriate for stable backporting. The risk- benefit ratio strongly favors inclusion.
**YES**
fs/exfat/super.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
fs/exfat/super.c +15 -4
@@ -813,10 +813,21 @@ static int exfat_init_fs_context(struct fs_context *fc)ratelimit_state_init (&sbi->ratelimit,DEFAULT_RATELIMIT_INTERVAL ,DEFAULT_RATELIMIT_BURST ); - sbi->options.fs_uid =current_uid (); - sbi->options.fs_gid =current_gid (); - sbi->options.fs_fmask = current->fs->umask; - sbi->options.fs_dmask = current->fs->umask; +if (fc->purpose ==FS_CONTEXT_FOR_RECONFIGURE && fc->root) { +struct super_block *sb = fc->root->d_sb; +struct exfat_mount_options *cur_opts = &EXFAT_SB (sb)->options; + + sbi->options.fs_uid = cur_opts->fs_uid; + sbi->options.fs_gid = cur_opts->fs_gid; + sbi->options.fs_fmask = cur_opts->fs_fmask; + sbi->options.fs_dmask = cur_opts->fs_dmask; + }else { + sbi->options.fs_uid =current_uid (); + sbi->options.fs_gid =current_gid (); + sbi->options.fs_fmask = current->fs->umask; + sbi->options.fs_dmask = current->fs->umask; + } + sbi->options.allow_utime =-1 ; sbi->options.errors =EXFAT_ERRORS_RO ;exfat_set_iocharset (&sbi->options, exfat_default_iocharset);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 1/1 ipmi: Fix the race between __scan_channels() and deliver_response()
In reply to Sasha LevinFrom: Jinhui Guo <[email protected]>
[ Upstream commit 936750fdba4c45e13bbd17f261bb140dd55f5e93 ]
The race window between __scan_channels() and deliver_response() causes the parameters of some channels to be set to 0.
1.[CPUA] __scan_channels() issues an IPMI request and waits with
wait_event() until all channels have been scanned. wait_event() internally calls might_sleep(), which might yield the CPU. (Moreover, an interrupt can preempt wait_event() and force the task to yield the CPU.)
2.[CPUB] deliver_response() is invoked when the CPU receives the
IPMI response. After processing a IPMI response, deliver_response() directly assigns intf->wchannels to intf->channel_list and sets intf->channels_ready to true. However, not all channels are actually ready for use.
3.[CPUA] Since intf->channels_ready is already true, wait_event()
never enters __wait_event(). __scan_channels() immediately clears intf->null_user_handler and exits.
4.[CPUB] Once intf->null_user_handler is set to NULL, deliver_response()
ignores further IPMI responses, leaving the remaining channels zero-initialized and unusable.
CPUA CPUB
------------------------------- ----------------------------- __scan_channels()
intf->null_user_handler
= channel_handler;
send_channel_info_cmd(intf,
0);
wait_event(intf->waitq,
intf->channels_ready);
do {
might_sleep();
deliver_response()
channel_handler()
intf->channel_list =
intf->wchannels + set;
intf->channels_ready = true;
send_channel_info_cmd(intf,
intf->curr_channel);
if (condition)
break;
__wait_event(wq_head,
condition);
} while(0)
intf->null_user_handler
= NULL;
deliver_response()
if (!msg->user)
if (intf->null_user_handler)
rv = -EINVAL;
return rv;------------------------------- -----------------------------
Fix the race between __scan_channels() and deliver_response() by deferring both the assignment intf->channel_list = intf->wchannels and the flag intf->channels_ready = true until all channels have been successfully scanned or until the IPMI request has failed.
Message-ID: <[email protected]>
---
LLM Generated explanations, may be completely bogus:
## Summary Analysis
### 1. BUG MECHANISM
This commit fixes a **race condition** between two IPMI functions:
- __scan_channels(): Initiates channel scanning, sets null_user_handler = channel_handler, then waits for channels_ready
- channel_handler() (called via deliver_response()): Processes IPMI responses for each channel
**The Bug** (introduced in commit 31b0b0730ad2a from September 2017):
In channel_handler(), after processing channel N's response (where N < IPMI_MAX_CHANNELS-1):
1. Lines 3420-3421 set channels_ready = true **prematurely**
2. Then sends request for channel N+1
3. __scan_channels() may see channels_ready == true and exit the wait loop early
4. __scan_channels() sets null_user_handler = NULL
5. Responses for channels N+1, N+2, etc. arrive but are **discarded** because null_user_handler is NULL
6. Remaining channels are **zero-initialized and unusable**
### 2. THE FIX
The fix simply **removes 2 lines** that prematurely set channels_ready = true in the else branch. After the fix, channels_ready = true is only set when:
- All channels have been scanned (curr_channel >= IPMI_MAX_CHANNELS), OR
- An error occurs (rv != 0)
### 3. CLASSIFICATION
| Criteria | Assessment | |----------|------------| | Bug type | Race condition causing data corruption (zero-init channels) | | Impact | IPMI channels become unusable on affected systems | | Size | 2 lines removed - minimal and surgical | | Risk | Very LOW - only removes premature assignments | | Subsystem | IPMI - used for server management |
### 4. STABLE BACKPORT CRITERIA
| Criterion | Status | |-----------|--------| | Obviously correct | ✅ Yes - simply delays setting flag until the right time | | Fixes real bug | ✅ Yes - race causes channels to be zero-initialized | | User impacting | ✅ Yes - affects IPMI hardware management | | Small and contained | ✅ Yes - 2 lines in single file | | No new features | ✅ Correct - pure bug fix | | No API changes | ✅ Correct - internal change only |
### 5. SIGNALS
**Positive signals:**
- Fixes a real race condition with clear cause and effect
- Minimal, surgical fix (2 lines removed)
- Bug has existed since 2017 (31b0b0730ad2a) - affects all current LTS kernels
- IPMI maintainer (Corey Minyard) signed off
- Detailed commit message explains the race with CPU timing diagram
**Missing signals:**
- No explicit Cc: [email protected] tag
- No explicit Fixes: 31b0b0730ad2a tag (though it should have one)
- No Tested-by/Reviewed-by tags
### 6. RISK vs BENEFIT
- **Benefit**: Fixes a race condition that makes IPMI channels unusable on servers
- **Risk**: Extremely low - the fix only removes code that ran at the wrong time; the correct code paths for setting channels_ready are untouched
- **Affected users**: Server/data center users relying on IPMI for hardware management
### 7. DEPENDENCIES
The fix is standalone and doesn't depend on other commits. The affected code has existed unchanged since 2017, so it should apply cleanly to all active stable kernels.
### CONCLUSION
This is a clear backport candidate. The commit fixes a real race condition that causes IPMI channels to become unusable. The fix is minimal (2 lines removed), obviously correct (simply delays a flag until the right time), and carries virtually no regression risk. IPMI is critical infrastructure for server management, making this fix important for stable users.
**YES**
drivers/char/ipmi/ipmi_msghandler.c | 2 -- 1 file changed, 2 deletions(-)
drivers/char/ipmi/ipmi_msghandler.c +0 -2
@@ -3417,8 +3417,6 @@ channel_handler(struct ipmi_smi *intf, struct ipmi_recv_msg *msg) intf->channels_ready = true;wake_up (&intf->waitq); }else { - intf->channel_list = intf->wchannels + set; - intf->channels_ready = true; rv =send_channel_info_cmd (intf, intf->curr_channel); }
Signature · 1 line
2.51.0