linux-stable/drivers/mtd
Arnd Bergmann 68f43870e9 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:35:31 +02:00
..
chips mtd: cfi_cmdset_0001: Byte swap OTP info 2023-10-27 19:45:11 +02:00
devices The main load of changes is related to Uwe's work converting platform 2023-11-04 11:04:30 -10:00
hyperbus mtd: hyperbus: rpc-if: Convert to platform remove callback returning void 2023-10-16 10:56:48 +02:00
lpddr mtd: lpddr2_nvm: Convert to platform remove callback returning void 2023-10-16 10:56:48 +02:00
maps mtd: maps: sun_uflash: Declare uflash_devinit static 2024-03-26 18:17:19 -04:00
nand mtd: diskonchip: work around ubsan link failure 2024-05-02 16:35:31 +02:00
parsers mtd: parsers: ar7: remove support 2023-10-19 10:31:44 +02:00
spi-nor * MTD 2024-01-09 15:40:59 -08:00
tests treewide: use get_random_u32_below() instead of deprecated function 2022-11-18 02:15:15 +01:00
ubi ubi: correct the calculation of fastmap size 2024-04-03 15:32:07 +02:00
Kconfig
Makefile
ftl.c mtd: ftl: use container_of() rather than cast 2022-09-19 18:14:53 +02:00
inftlcore.c mtd: inftlcore: fix repeated words in comments 2022-11-07 17:14:21 +01:00
inftlmount.c
mtd_blkdevs.c for-6.8/block-2024-01-08 2024-01-11 13:58:04 -08:00
mtdblock.c mtdblock: make warning messages ratelimited 2023-07-27 17:16:14 +02:00
mtdblock_ro.c mtdblock: make warning messages ratelimited 2023-07-27 17:16:14 +02:00
mtdchar.c mtdchar: mark bits of ioctl handler noinline 2023-06-01 18:12:31 +02:00
mtdconcat.c mtd: fix repeated word in comment 2022-09-20 10:40:30 +02:00
mtdcore.c mtd: limit OTP NVMEM cell parse to non-NAND devices 2024-05-02 16:35:31 +02:00
mtdcore.h mtd: use refcount to prevent corruption 2023-07-12 13:30:08 +02:00
mtdoops.c mtd: mtdoops: panic caused mtdoops to call mtdoops_erase function immediately 2022-11-07 17:08:00 +01:00
mtdpart.c mtd: mtdpart: check for subpartitions parsing result 2023-10-16 10:50:32 +02:00
mtdpstore.c mtd: Fix a typo in a comment 2022-09-19 18:14:53 +02:00
mtdsuper.c mtd: key superblock by device number 2023-08-31 12:47:15 +02:00
mtdswap.c mtd: always initialize 'stats' in struct mtd_oob_ops 2022-09-21 10:38:07 +02:00
nftlcore.c mtd: always initialize 'stats' in struct mtd_oob_ops 2022-09-21 10:38:07 +02:00
nftlmount.c
rfd_ftl.c
sm_ftl.c mtd: sm_ftl: Fix typos in comments 2023-06-22 23:00:43 +02:00
sm_ftl.h
ssfdc.c mtd: ssfdc: Remove an unused variable 2023-12-14 16:43:15 +01:00