Re: [PATCH] ubsan: Add awareness of signed integer overflow traps

From: Kees Cook
Date: Mon Apr 15 2024 - 20:46:39 EST


On Mon, Apr 15, 2024 at 11:34:54AM -0700, Nathan Chancellor wrote:
> On Mon, Apr 15, 2024 at 11:28:35AM -0700, Kees Cook wrote:
> > On arm64, UBSAN traps can be decoded from the trap instruction. Add the
> > add, sub, and mul overflow trap codes now that CONFIG_UBSAN_SIGNED_WRAP
> > exists. Seen under clang 19:
> >
> > Internal error: UBSAN: unrecognized failure code: 00000000f2005515 [#1] PREEMPT SMP
> >
> > Reported-by: Nathan Chancellor <nathan@xxxxxxxxxx>
> > Closes: https://lore.kernel.org/lkml/20240411-fix-ubsan-in-hardening-config-v1-0-e0177c80ffaa@xxxxxxxxxx
> > Fixes: 557f8c582a9b ("ubsan: Reintroduce signed overflow sanitizer")
> > Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
>
> As I mentioned, CONFIG_UBSAN_SIGNED_INTEGER_WRAP needs to be
> CONFIG_UBSAN_SIGNED_WRAP. I applied this change with that fix up and the

Whoops; thanks!

> warning now becomes:
>
> Internal error: UBSAN: integer subtraction overflow: 00000000f2005515 [#1] PREEMPT SMP

Perfecto. :)

> So:
>
> Tested-by: Nathan Chancellor <nathan@xxxxxxxxxx>

Thanks!

--
Kees Cook