CVE-2025-38398: spi: spi-qpic-snand: reallocate BAM transactions

Published Jul 25, 2025
·
Updated

In the Linux kernel, the following vulnerability has been resolved:

spi: spi-qpic-snand: reallocate BAM transactions

Using the mtdnandbiterrs module for testing the driver occasionally results in weird things like below.

1. swiotlb mapping fails with the following message:

[ 85.926216] qcomsnand 79b0000.spi: swiotlb buffer is full (sz: 4294967294 bytes), total 512 (slots), used 0 (slots) [ 85.932937] qcomsnand 79b0000.spi: failure in mapping desc [ 87.999314] qcomsnand 79b0000.spi: failure to write raw page [ 87.999352] mtdnandbiterrs: error: writeoob failed (-110)

Rebooting the board after this causes a panic due to a NULL pointer dereference.

2. If the swiotlb mapping does not fail, rebooting the board may result in a different panic due to a bad spinlock magic:

[ 256.104459] BUG: spinlock bad magic on CPU#3, procd/2241 [ 256.104488] Unable to handle kernel paging request at virtual address ffffffff0000049b ...

Investigating the issue revealed that these symptoms are results of memory corruption which is caused by out of bounds access within the driver.

The driver uses a dynamically allocated structure for BAM transactions, which structure must have enough space for all possible variations of different flash operations initiated by the driver. The required space heavily depends on the actual number of 'codewords' which is calculated from the pagesize of the actual NAND chip.

Although the qcomnandcalloc() function allocates memory for the BAM transactions during probe, but since the actual number of 'codewords' is not yet know the allocation is done for one 'codeword' only.

Because of this, whenever the driver does a flash operation, and the number of the required transactions exceeds the size of the allocated arrays the driver accesses memory out of the allocated range.

To avoid this, change the code to free the initially allocated BAM transactions memory, and allocate a new one once the actual number of 'codewords' required for a given NAND chip is known.

Affected Software

6 affected components
The Linux Foundation Linux Kernel
Linux Linux kernel>=6.15<6.15.6
Linux Linux kernel=6.16-rc1
Linux Linux kernel=6.16-rc2
Linux Linux kernel=6.16-rc3
Linux Linux kernel=6.16-rc4

Event History

Jul 25, 2025
CVE Published
via MITRE·12:53 PM
Data Sourced
via MITRE·12:53 PM
DescriptionSeverity
Data Sourced
via NVD·01:15 PM
RemedyDescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2025-38398?

CVE-2025-38398 is classified as a moderate severity vulnerability in the Linux kernel.

2

How do I fix CVE-2025-38398?

To fix CVE-2025-38398, you should update the Linux kernel to the latest stable version that addresses this vulnerability.

3

What systems are affected by CVE-2025-38398?

CVE-2025-38398 affects systems running the Linux kernel, particularly where the spi-qpic-snand driver is utilized.

4

Does CVE-2025-38398 require immediate action?

While CVE-2025-38398 is of moderate severity, it is recommended to apply updates promptly to mitigate possible exploitation.

5

What are the potential impacts of CVE-2025-38398?

The potential impacts of CVE-2025-38398 include system instability and failures related to swiotlb mapping when using the mtd_nandbiterrs module.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203