linux-stable/drivers/mtd
Arnd Bergmann ad371d69a6 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:29:30 +02:00
..
chips mtd: cfi_cmdset_0001: Byte swap OTP info 2023-11-28 17:07:14 +00:00
devices
hyperbus
lpddr
maps mtd: maps: physmap-core: fix flash size larger than 32-bit 2024-03-26 18:20:50 -04:00
nand mtd: diskonchip: work around ubsan link failure 2024-05-02 16:29:30 +02:00
parsers mtd: parsers: ofpart: add workaround for #size-cells 0 2024-02-16 19:06:29 +01:00
spi-nor mtd: spi-nor: Correct flags for Winbond w25q128 2023-09-19 12:28:06 +02:00
tests
ubi ubi: correct the calculation of fastmap size 2024-04-03 15:19:27 +02:00
Kconfig
Makefile
ftl.c
inftlcore.c
inftlmount.c
mtd_blkdevs.c mtd: Fix gluebi NULL pointer dereference caused by ftl notifier 2024-01-25 15:27:21 -08:00
mtdblock.c
mtdblock_ro.c
mtdchar.c mtdchar: mark bits of ioctl handler noinline 2023-06-09 10:34:24 +02:00
mtdconcat.c
mtdcore.c mtd: core: fix error path for nvmem provider 2023-05-11 23:03:40 +09:00
mtdcore.h
mtdoops.c
mtdpart.c
mtdpstore.c
mtdsuper.c
mtdswap.c
nftlcore.c
nftlmount.c
rfd_ftl.c
sm_ftl.c
sm_ftl.h
ssfdc.c