lkml.org 
[lkml]   [2024]   [Apr]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] mtd: diskonchip: work around ubsan link failure
Date
On Fri, 2024-04-05 at 14:30:04 UTC, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks.

Miquel

\
 
 \ /
  Last update: 2024-05-27 16:30    [W:0.029 / U:0.544 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site