linux-stable/drivers/mtd
Arnd Bergmann 672c5715b6 mtd: diskonchip: work around ubsan link failure
commit 21c9fb611c upstream.

I ran into a randconfig build failure with UBSAN using gcc-13.2:

arm-linux-gnueabi-ld: error: unplaced orphan section `.bss..Lubsan_data31' from `drivers/mtd/nand/raw/diskonchip.o'

I'm not entirely sure what is going on here, but I suspect this has something
to do with the check for the end of the doc_locations[] array that contains
an (unsigned long)0xffffffff element, which is compared against the signed
(int)0xffffffff. If this is the case, we should get a runtime check for
undefined behavior, but we instead get an unexpected build-time error.

I would have expected this to work fine on 32-bit architectures despite the
signed integer overflow, though on 64-bit architectures this likely won't
ever work.

Changing the contition to instead check for the size of the array makes the
code safe everywhere and avoids the ubsan check that leads to the link
error. The loop code goes back to before 2.6.12.

Cc: stable@vger.kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20240405143015.717429-1-arnd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-05-02 16:18:36 +02:00
..
chips mtd: cfi_cmdset_0001: Byte swap OTP info 2023-12-08 08:44:27 +01:00
devices mtd: devices: docg3: check the return value of devm_ioremap() in the probe 2022-10-26 13:22:37 +02:00
hyperbus
lpddr mtd: lpddr2_nvm: Fix possible null-ptr-deref 2023-01-18 11:41:03 +01:00
maps mtd: maps: physmap-core: fix flash size larger than 32-bit 2024-03-26 18:22:21 -04:00
nand mtd: diskonchip: work around ubsan link failure 2024-05-02 16:18:36 +02:00
parsers treewide: Remove uninitialized_var() usage 2023-06-09 10:29:01 +02:00
spi-nor spi: cadence-quadspi: fix suspend-resume implementations 2023-05-17 11:35:48 +02:00
tests
ubi ubi: correct the calculation of fastmap size 2024-04-13 12:51:23 +02:00
ftl.c
inftlcore.c
inftlmount.c
Kconfig
Makefile
mtd_blkdevs.c mtd: Fix gluebi NULL pointer dereference caused by ftl notifier 2024-01-25 14:34:23 -08:00
mtdblock.c mtdblock: tolerate corrected bit-flips 2023-04-20 12:07:35 +02:00
mtdblock_ro.c
mtdchar.c
mtdconcat.c
mtdcore.c mtd: Fix device name leak when register device failed in add_mtd_device() 2023-01-18 11:41:02 +01:00
mtdcore.h
mtdoops.c
mtdpart.c
mtdsuper.c
mtdswap.c
nftlcore.c
nftlmount.c
rfd_ftl.c
sm_ftl.c mtd: sm_ftl: Fix deadlock caused by cancel_work_sync in sm_release 2022-08-25 11:17:51 +02:00
sm_ftl.h
ssfdc.c