linux/drivers/mtd
Linus Walleij 87a73eb5b5 mtd: jedec_probe: Fix crash in jedec_read_mfr()
It turns out that the loop where we read manufacturer
jedec_read_mfd() can under some circumstances get a
CFI_MFR_CONTINUATION repeatedly, making the loop go
over all banks and eventually hit the end of the
map and crash because of an access violation:

Unable to handle kernel paging request at virtual address c4980000
pgd = (ptrval)
[c4980000] *pgd=03808811, *pte=00000000, *ppte=00000000
Internal error: Oops: 7 [#1] PREEMPT ARM
CPU: 0 PID: 1 Comm: swapper Not tainted 4.16.0-rc1+ #150
Hardware name: Gemini (Device Tree)
PC is at jedec_probe_chip+0x6ec/0xcd0
LR is at 0x4
pc : [<c03a2bf4>]    lr : [<00000004>]    psr: 60000013
sp : c382dd18  ip : 0000ffff  fp : 00000000
r10: c0626388  r9 : 00020000  r8 : c0626340
r7 : 00000000  r6 : 00000001  r5 : c3a71afc  r4 : c382dd70
r3 : 00000001  r2 : c4900000  r1 : 00000002  r0 : 00080000
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
Control: 0000397f  Table: 00004000  DAC: 00000053
Process swapper (pid: 1, stack limit = 0x(ptrval))

Fix this by breaking the loop with a return 0 if
the offset exceeds the map size.

Fixes: 5c9c11e1c4 ("[MTD] [NOR] Add support for flash chips with ID in bank other than 0")
Cc: <stable@vger.kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
2018-03-29 19:29:06 +02:00
..
chips mtd: jedec_probe: Fix crash in jedec_read_mfr() 2018-03-29 19:29:06 +02:00
devices This pull-request contains the following notable changes: 2018-01-29 09:55:14 +01:00
lpddr
maps This pull request contains the following core changes: 2017-11-22 20:46:06 -10:00
nand mtd: nand: atmel: Fix get_sectorsize() function 2018-03-29 19:29:06 +02:00
onenand Core changes: 2018-01-29 09:58:36 +01:00
parsers mtd: sharpslpart: make local function sharpsl_nand_cleanup_ftl() static 2018-01-06 15:06:23 +01:00
spi-nor mtd: mtk-nor: modify functions' name more generally 2018-01-14 16:14:06 +01:00
tests mtd: mtd_oobtest: Handle bitflips during reads 2018-01-12 10:24:08 +01:00
ubi ubi: block: Fix locking for idr_alloc/idr_remove 2018-01-18 16:48:31 +01:00
afs.c
ar7part.c
bcm47xxpart.c mtd: extract TRX parser out of bcm47xxpart into a separated module 2017-06-22 13:13:10 -07:00
bcm63xxpart.c
cmdlinepart.c
ftl.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
inftlcore.c mtd: nand: Rename nand.h into rawnand.h 2017-08-13 10:11:49 +02:00
inftlmount.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
Kconfig kconfig: kill off GENERIC_IO option 2017-11-13 21:39:15 +01:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mtd_blkdevs.c mtd: blkdevs: Fix mtd block write failure 2017-08-12 14:53:24 -07:00
mtdblock_ro.c
mtdblock.c
mtdchar.c mtdchar: fix usage of mtd_ooblayout_ecc() 2018-03-19 10:28:11 +01:00
mtdconcat.c mtd: remove the get_unmapped_area method 2017-11-13 21:39:18 +01:00
mtdcore.c MTD changes: 2018-01-29 11:11:56 -08:00
mtdcore.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mtdoops.c
mtdpart.c mtd: Remove duplicate checks on mtd_oob_ops parameter 2018-01-16 15:23:22 +01:00
mtdsuper.c Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
mtdswap.c mtd: mtdswap: make array 'name' static const, shrinks object size 2017-12-16 21:30:08 +01:00
nftlcore.c mtd: nand: Rename nand.h into rawnand.h 2017-08-13 10:11:49 +02:00
nftlmount.c mtd: nand: Rename nand.h into rawnand.h 2017-08-13 10:11:49 +02:00
ofpart.c mtd: Convert to using %pOF instead of full_name 2017-08-15 14:00:43 +02:00
redboot.c
rfd_ftl.c
sm_ftl.c treewide: setup_timer() -> timer_setup() 2017-11-21 15:57:07 -08:00
sm_ftl.h
ssfdc.c mtd: nand: Rename nand.h into rawnand.h 2017-08-13 10:11:49 +02:00