Re: linux-next: Tree for Nov 19 (kcsan)

From: Marco Elver
Date: Tue Nov 19 2019 - 13:34:21 EST


On Tue, 19 Nov 2019, Randy Dunlap wrote:

> On 11/19/19 8:12 AM, Marco Elver wrote:
> > On Tue, 19 Nov 2019 at 16:11, Randy Dunlap <rdunlap@xxxxxxxxxxxxx> wrote:
> >>
> >> On 11/19/19 12:46 AM, Stephen Rothwell wrote:
> >>> Hi all,
> >>>
> >>> Changes since 20191118:
> >>>
> >>
> >> on x86_64:
> >>
> >> It seems that this function can already be known by the compiler as a
> >> builtin:
> >>
> >> ../kernel/kcsan/core.c:619:6: warning: conflicting types for built-in function â__tsan_func_exitâ [-Wbuiltin-declaration-mismatch]
> >> void __tsan_func_exit(void)
> >> ^~~~~~~~~~~~~~~~
> >>
> >>
> >> $ gcc --version
> >> gcc (SUSE Linux) 7.4.1 20190905 [gcc-7-branch revision 275407]
> >
> > Interesting. Could you share the .config? So far I haven't been able
> > to reproduce.
>
> Sure, it's attached.

Thanks, the config did the trick, even for gcc 9.0.0.

The problem is CONFIG_UBSAN=y. We haven't explicitly disallowed it like
with KASAN. In principle there should be nothing wrong with KCSAN+UBSAN.

There are 3 options:
1. Just disable UBSAN for KCSAN, and also disable KCSAN for UBSAN.
2. Restrict the config to not allow combining KCSAN and UBSAN.
3. Leave things as-is.

Option 1 probably makes most sense, and I'll send a patch for that
unless there are major objections.

> > I can get the warning if I manually add -fsanitize=thread to flags for
> > kcsan/core.c (but normally disabled via KCSAN_SANITIZE := n). If
> > possible could you also share the output of `make V=1` for
> > kcsan/core.c?
>
> here:

> gcc -Wp,-MD,kernel/kcsan/.core.o.d -nostdinc -isystem /usr/lib64/gcc/x86_64-suse-linux/7/include -I../arch/x86/include -I./arch/x86/include/generated -I../include -I./include -I../arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I../include/uapi -I./include/generated/uapi -include ../include/linux/kconfig.h -include ../include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fno-stack-protector -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fno-conserve-stack -fno-stack-protector -fprofile-arcs -ftest-coverage -fno-tree-loop-im -Wno-maybe-uninitialized -fsanitize=shift -fsanitize=integer-divide-by-zero -fsanitize=unreachable -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=object-size -fsanitize=bool -fsanitize=enum -Wno-maybe-uninitialized -I ../kernel/kcsan -I ./kernel/kcsan -DKBUILD_BASENAME='"core"' -DKBUILD_MODNAME='"core"' -c -o kernel/kcsan/core.o ../kernel/kcsan/core.c
> ../kernel/kcsan/core.c:619:6: warning: conflicting types for built-in function â__tsan_func_exitâ [-Wbuiltin-declaration-mismatch]

Adding '-fsanitize=<anything>' seems to make gcc think that these are
builtins. So this is partially also a gcc problem, but if we disable all
sanitizers with the runtime, then this goes away.

Thanks,
-- Marco