1
0
Fork 0
remarkable-linux/drivers/mtd/spi-nor
Thor Thayer 6c677c5968 mtd: spi-nor: cadence-quadspi: Fix page fault kernel panic
commit 47016b341f upstream.

The current Cadence QSPI driver caused a kernel panic when loading
a Root Filesystem from QSPI. The problem was caused by reading more
bytes than needed because the QSPI operated on 4 bytes at a time.
<snip>
[    7.947754] spi_nor_read[1048]:from 0x037cad74, len 1 [bfe07fff]
[    7.956247] cqspi_read[910]:offset 0x58502516, buffer=bfe07fff
[    7.956247]
[    7.966046] Unable to handle kernel paging request at virtual
address bfe08002
[    7.973239] pgd = eebfc000
[    7.975931] [bfe08002] *pgd=2fffb811, *pte=00000000, *ppte=00000000
</snip>
Notice above how only 1 byte needed to be read but by reading 4 bytes
into the end of a mapped page, an unrecoverable page fault occurred.

This patch uses a temporary buffer to hold the 4 bytes read and then
copies only the bytes required into the buffer. A min() function is
used to limit the length to prevent buffer overflows.

Request testing of this patch on other platforms. This was tested
on the Intel Arria10 SoCFPGA DevKit.

Fixes: 0cf1725676 ("mtd: spi-nor: cqspi: Fix build on arches missing readsl/writesl")
Signed-off-by: Thor Thayer <thor.thayer@linux.intel.com>
Cc: <stable@vger.kernel.org>
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-01 12:58:18 -07:00
..
Kconfig mtd: spi-nor: intel-spi: Add support for Intel Denverton SPI serial flash controller 2017-08-01 19:19:28 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
aspeed-smc.c mtd: spi-nor: aspeed: set 4B setting for all chips 2017-08-14 17:23:50 +02:00
atmel-quadspi.c mtd: atmel-quadspi: Remove unneeded pinctrl header 2017-08-01 21:23:21 +02:00
cadence-quadspi.c mtd: spi-nor: cadence-quadspi: Fix page fault kernel panic 2018-05-01 12:58:18 -07:00
fsl-quadspi.c mtd: spi-nor: introduce SPI 1-2-2 and SPI 1-4-4 protocols 2017-05-15 21:56:17 +02:00
hisi-sfc.c mtd: Convert to using %pOF instead of full_name 2017-08-15 14:00:43 +02:00
intel-spi-pci.c mtd: spi-nor: intel-spi: Add support for Intel Denverton SPI serial flash controller 2017-08-01 19:19:28 +02:00
intel-spi-platform.c spi-nor: Add support for Intel SPI serial flash controller 2017-01-03 17:33:36 +00:00
intel-spi.c spi-nor: intel-spi: Fix broken software sequencing codes 2017-11-30 08:40:55 +00:00
intel-spi.h spi-nor: Add support for Intel SPI serial flash controller 2017-01-03 17:33:36 +00:00
mtk-quadspi.c mtd: mtk-quadspi: Remove unneeded pinctrl header 2017-08-01 21:24:47 +02:00
nxp-spifi.c mtd: spi-nor: introduce SPI 1-2-2 and SPI 1-4-4 protocols 2017-05-15 21:56:17 +02:00
spi-nor.c mtd: spi-nor: fix DMA unsafe buffer issue in spi_nor_read_sfdp() 2017-09-18 09:53:27 +02:00
stm32-quadspi.c mtd: spi-nor: stm32-quadspi: Fix uninitialized error return code 2017-12-20 10:10:30 +01:00