linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Arnd Bergmann <arnd@kernel.org>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	stable@vger.kernel.org, Dinghao Liu <dinghao.liu@zju.edu.cn>,
	linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mtd: diskonchip: work around ubsan link failure
Date: Tue,  9 Apr 2024 08:41:27 +0200	[thread overview]
Message-ID: <20240409064128.91899-1-miquel.raynal@bootlin.com> (raw)
In-Reply-To: <20240405143015.717429-1-arnd@kernel.org>

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

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

      reply	other threads:[~2024-04-09  6:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-05 14:30 [PATCH] mtd: diskonchip: work around ubsan link failure Arnd Bergmann
2024-04-09  6:41 ` Miquel Raynal [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240409064128.91899-1-miquel.raynal@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=dinghao.liu@zju.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=stable@vger.kernel.org \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).