google / kernel-sanitizers

Linux Kernel Sanitizers, fast bug-detectors for the Linux kernel
https://google.github.io/kernel-sanitizers/
442 stars 87 forks source link

__tsan_init not found with gcc 8.0 #192

Closed ab1gale closed 7 years ago

ab1gale commented 7 years ago

Hi, I got following problem when building ktsan-enabled linux with gcc 8.0 (in order to run it with syzkaller)

arch/x86/kernel/head64.o: In function `_GLOBAL__sub_I_00099_0_early_pmd_flags':
head64.c:(.text.startup+0x5): undefined reference to `__tsan_init'
arch/x86/kernel/head.o: In function `_GLOBAL__sub_I_00099_0_reserve_ebda_region':
head.c:(.text.startup+0x5): undefined reference to `__tsan_init'
init/built-in.o: In function `_GLOBAL__sub_I_00099_0___ksymtab_system_state':
main.c:(.text.startup+0x5): undefined reference to `__tsan_init'
init/built-in.o: In function `_GLOBAL__sub_I_00099_0_init_uts_ns':
version.c:(.text.startup+0x15): undefined reference to `__tsan_init'
init/built-in.o: In function `_GLOBAL__sub_I_00099_0_root_mountflags':
do_mounts.c:(.text.startup+0x25): undefined reference to `__tsan_init'
init/built-in.o:do_mounts_initrd.c:(.text.startup+0x35): more undefined references to `__tsan_init' follow

The patch of issue google/kernel-sanitizers#190 does not help for this version of gcc.. Could you help me? Thanks in advance for any advice.

dvyukov commented 7 years ago

You need to either define empty __tsan_init function in ktsan runtime in kernel, or modify gcc to not emit __tsan_init.

dvyukov commented 7 years ago

You need to rebase this patch to gcc 8: https://github.com/google/ktsan/wiki#gcc

ab1gale commented 7 years ago

Forgot to mention that I already rebased patch but still got error. Now error is gone after adding __tsan_init in kernel, as you suggest. Thank you very much! 😄

dvyukov commented 7 years ago

Great