2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00
linux/drivers/mtd/nand
Gabor Juhos ddaad4ad77
mtd: nand: qpic_common: prevent out of bounds access of BAM arrays
The common QPIC code does not do any boundary checking when it handles
the command elements and scatter gater list arrays of a BAM transaction,
thus it allows to access out of bounds elements in those.

Although it is the responsibility of the given driver to allocate enough
space for all possible BAM transaction variations, however there can be
mistakes in the driver code which can lead to hidden memory corruption
issues which are hard to debug.

This kind of problem has been observed during testing the 'spi-qpic-snand'
driver. Although the driver has been fixed with a preceding patch, but it
still makes sense to reduce the chance of having such errors again later.

In order to prevent such errors, change the qcom_alloc_bam_transaction()
function to store the number of elements of the arrays in the
'bam_transaction' strucutre during allocation. Also, add sanity checks to
the qcom_prep_bam_dma_desc_{cmd,data}() functions to avoid using out of
bounds indices for the arrays.

Tested-by: Lakshmi Sowjanya D <quic_laksd@quicinc.com>     # on SDX75
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
Link: https://patch.msgid.link/20250618-qpic-snand-avoid-mem-corruption-v3-2-319c71296cda@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2025-06-29 22:10:47 +01:00
..
onenand mtd: onenand: Fix uninitialized retlen in do_otp_read() 2024-12-05 11:11:00 +01:00
raw A big core MTD change is the introduction of a new class to always 2025-06-02 11:08:17 -07:00
spi mtd: spinand: fix memory leak of ECC engine conf 2025-06-19 19:13:21 +02:00
bbt.c mtd: nand: bbt: Use the bitmap API to allocate bitmaps 2022-09-20 10:06:58 +02:00
core.c mtd: nand: drop EXPORT_SYMBOL_GPL for nanddev_erase() 2022-11-07 17:17:20 +01:00
ecc-mtk.c mtd: nand: ecc-mtk: Add ECC support fot MT7986 IC 2023-02-03 19:09:44 +01:00
ecc-mxic.c mtd: nand: ecc-mxic: Fix use of uninitialized variable ret 2025-04-29 11:05:35 +02:00
ecc-sw-bch.c mtd: spinand: Constify struct nand_ecc_engine_ops 2024-10-21 11:55:50 +02:00
ecc-sw-hamming.c mtd: spinand: Constify struct nand_ecc_engine_ops 2024-10-21 11:55:50 +02:00
ecc.c mtd: Explicitly include correct DT includes 2023-07-27 17:03:41 +02:00
Kconfig mtd: nand: MTD_NAND_ECC_MEDIATEK should depend on ARCH_MEDIATEK 2022-05-12 16:43:04 +02:00
Makefile mtd: nand: Drop explicit test for built-in CONFIG_SPI_QPIC_SNAND 2025-04-07 09:01:58 +02:00
qpic_common.c mtd: nand: qpic_common: prevent out of bounds access of BAM arrays 2025-06-29 22:10:47 +01:00