kernel_samsung_a53x/drivers/mtd
Arnd Bergmann 354575a8be mtd: diskonchip: work around ubsan link failure
commit 21c9fb611c25d5cd038f6fe485232e7884bb0b3d 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-11-19 11:32:40 +01:00
..
chips mtd: cfi_cmdset_0001: Byte swap OTP info 2024-11-18 11:43:26 +01:00
devices Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hyperbus Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lpddr Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
maps mtd: maps: physmap-core: fix flash size larger than 32-bit 2024-11-19 08:44:54 +01:00
nand mtd: diskonchip: work around ubsan link failure 2024-11-19 11:32:40 +01:00
parsers Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
spi-nor Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tests Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ubi ubi: correct the calculation of fastmap size 2024-11-19 09:22:16 +01:00
ftl.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inftlcore.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inftlmount.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtd_blkdevs.c mtd: Fix gluebi NULL pointer dereference caused by ftl notifier 2024-11-18 12:12:25 +01:00
mtdblock.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdblock_ro.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdchar.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdconcat.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdcore.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdcore.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdoops.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdpart.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdpstore.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdsuper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtdswap.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nftlcore.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nftlmount.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rfd_ftl.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sm_ftl.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sm_ftl.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ssfdc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00