Re: [PATCH v2] ubsan: Tighten UBSAN_BOUNDS on GCC

From: Kees Cook
Date: Wed Jun 21 2023 - 14:05:10 EST


On Wed, Jun 21, 2023 at 09:42:01AM -0700, Guenter Roeck wrote:
> Hi,
>
> On Tue, Apr 04, 2023 at 07:23:59PM -0700, Kees Cook wrote:
> > The use of -fsanitize=bounds on GCC will ignore some trailing arrays,
> > leaving a gap in coverage. Switch to using -fsanitize=bounds-strict to
> > match Clang's stricter behavior.
> >
> > Cc: Marco Elver <elver@xxxxxxxxxx>
> > Cc: Masahiro Yamada <masahiroy@xxxxxxxxxx>
> > Cc: Nathan Chancellor <nathan@xxxxxxxxxx>
> > Cc: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
> > Cc: Nicolas Schier <nicolas@xxxxxxxxx>
> > Cc: Tom Rix <trix@xxxxxxxxxx>
> > Cc: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> > Cc: Miroslav Benes <mbenes@xxxxxxx>
> > Cc: linux-kbuild@xxxxxxxxxxxxxxx
> > Cc: llvm@xxxxxxxxxxxxxxx
> > Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
> > ---
>
> This patch, presumably as side effect, enables CONFIG_ARCH_STM32
> for arm64:allmodconfig. As consequence, CONFIG_STM32_RPROC is enabled
> as well. This in turn results in the following build error.
>
> Building arm64:allmodconfig ... failed
> --------------
> Error log:
> In file included from include/linux/printk.h:564,
> from include/asm-generic/bug.h:22,
> from arch/arm64/include/asm/bug.h:26,
> from include/linux/bug.h:5,
> from include/linux/fortify-string.h:5,
> from include/linux/string.h:254,
> from include/linux/dma-mapping.h:7,
> from drivers/remoteproc/stm32_rproc.c:9:
> drivers/remoteproc/stm32_rproc.c: In function 'stm32_rproc_mem_alloc':
> drivers/remoteproc/stm32_rproc.c:122:22: error: format '%x' expects argument of type 'unsigned int', but argument 5 has type 'size_t'
>
> I did not try to understand what is going on, but reverting this
> patch fixes the problem.

Well that is really weird! I will investigate... this patch should be
pretty self-contained...

--
Kees Cook