CVE-2026-139004: spi: spi-qpic-snand: publish the ECC context to snandc->qspi

Published Nov 30, 2026
·
Updated

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

spi: spi-qpic-snand: publish the ECC context to snandc->qspi

qcomspiooblayoutecc() and qcomspiooblayoutfree() read the ECC configuration through snandc->qspi->ecc. qcomspiprobe() points it at a zeroed scratch struct and only qcomspieccprepareioreqpipelined(), which runs on page I/O, ever updates it. qcomspieccinitctxpipelined() installs the ooblayout but does not publish the context it just allocated, and qcomspiecccleanupctxpipelined() frees that context without clearing the pointer.

spinandinit() calls mtdooblayoutcountfreebytes() right after the ECC context is created and before any page I/O, so the ooblayout always runs against a pointer that does not describe the current context:

- On a first probe it reads the zeroed struct from qcomspiprobe(), so steps, bytes and bbmsize are 0. The count then returns 0 rather than an error, so the probe continues with mtd->oobavail set to 0.

- On a probe retry it reads the ecccfg the previous attempt freed.

A retry is easy to hit. On IPQ5018 with the qcom,smem-part parser the partition parse returns -EPROBEDEFER until SMEM has probed, so the first spi-nand probe defers. It defers inside mtddeviceparseregister(), after mtdotpnvmemadd() has already read the factory OTP - that read goes through prepareioreq and leaves snandc->qspi->ecc pointing at the context that spinandcleanup() then frees. The second probe allocates a new context, never publishes it, and computes the OOB layout from the freed one. Once the slab has been reused, qecc->steps holds garbage and

oobregion->length = qecc->steps 4;

goes negative. qcomspiooblayoutfree() only reports -ERANGE for section 1 and later, so mtdooblayoutcountbytes() sums the regions and returns that negative length as the byte count. The -512 below is steps 4 with steps == -128. It is a byte count that happens to collide with -ERESTARTSYS, not an error the driver returned. spinandinit() takes it as an error, and because it is not -EPROBEDEFER the driver core never retries and the NAND never appears:

spi-nand spi0.0: ESMT SPI NAND was found. spi-nand spi0.0: probe with driver spi-nand failed with error -512 UBI error: cannot open mtd rootfs, error -2 Waiting for root device /dev/ubiblock01...

On a Mercusys MR80X (IPQ5018, ESMT F50D1G41LB) about half of the boots failed to mount the rootfs, the outcome depending on whether the freed memory had been overwritten yet.

Publish the context when it is created and clear the pointer when it is destroyed. Clearing leaves snandc->qspi->ecc NULL after cleanup, which is safe: the mtd is unregistered before cleanupctx runs, so no ooblayout callback can follow.

Affected Software

1 affected component
Linux Linux kernel

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Compensating control

    In the qcom SPI NAND driver, publish the ECC context to snandc->qspi when it is created and clear the pointer when the context is destroyed.

Event History

Nov 30, 2026
CVE Published
via MITRE·01:26 PM
Data Sourced
via MITRE·01:26 PM
Description

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