On Wed, 16 Sep 2020 at 00:34, Nick Desaulniers <[email protected]> wrote: > On Tue, Sep 15, 2020 at 2:02 PM Josh Poimboeuf <[email protected]> wrote: > > > > panic() is noreturn, so the compiler is enforcing the fact that it > > doesn't return, by trapping if it does return. > > > > I seem to remember that's caused by CONFIG_UBSAN_TRAP. > > Indeed, if I remove CONFIG_UBSAN_TRAP from the 0day report's > randconfig, these unreachable instruction warnings all go away. > > So what's the right way to fix this? > > CONFIG_UBSAN_TRAP enables -fsanitize-undefined-trap-on-error (not > sure why that's wrapped in cc-option; it shouldn't be selectable via > Kconfig if unsupported by the toolchain). > > Should clang not be emitting `ud2` trapping instructions for this flag > for no-return functions?
I think this would defeat the purpose of this UBSAN feature. Certain UBSAN checks are done fully statically, like is done by fsanitize=unreachable, and could actually be enabled in production kernels; trapping the kernel in these cases would be a reasonable way to avoid further damage to the system. (You could in theory force it to not emit a trap by using fno-sanitize-trap=unreachable, but I think it's a bad idea.) > or > > Should objtool be made aware of the config option and then not check > traps after no-returns? I'd vote for this. And it seems Ilie implemented this already. > I suspect the latter, but I'm not sure how feasible it is to > implement. Josh, Marco, do you have thoughts on the above? Thanks, -- Marco

