From 251aabb77ec4d86b9374b6f999fbb8e1ea70963f Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Tue, 4 Feb 2020 15:05:16 +0100 Subject: dashboard/config: switch to ORC unwinder Jann pointed out that the frame pointer unwinder fails to unwind double fault stacks. Switch to using the ORC unwinder instead. https://www.kernel.org/doc/html/latest/x86/orc-unwinder.html Suggested-by: Jann Horn --- dashboard/config/bits-kmsan.config | 4 ++++ dashboard/config/bits-syzbot.config | 4 ++++ dashboard/config/upstream-kasan.config | 4 ++-- dashboard/config/upstream-kcsan.config | 4 ++-- dashboard/config/upstream-leak.config | 4 ++-- pkg/vcs/linux.go | 23 +++++++++++++++++++---- 6 files changed, 33 insertions(+), 10 deletions(-) diff --git a/dashboard/config/bits-kmsan.config b/dashboard/config/bits-kmsan.config index cfe907917..c24d8876e 100644 --- a/dashboard/config/bits-kmsan.config +++ b/dashboard/config/bits-kmsan.config @@ -20,6 +20,10 @@ CONFIG_PREEMPT_NONE=y # CONFIG_SND_HDA_INTEL is not set # CONFIG_HARDENED_USERCOPY is not set +# KMSAN doesn't support ORC unwinder (https://github.com/google/kmsan/issues/48). +# CONFIG_UNWINDER_ORC is not set +CONFIG_UNWINDER_FRAME_POINTER=y + # Disable debug configs enabled in KASAN configs: # CONFIG_BLK_DEBUG_FS is not set # CONFIG_DEBUG_DEVRES is not set diff --git a/dashboard/config/bits-syzbot.config b/dashboard/config/bits-syzbot.config index 34ef787ea..865edff4c 100644 --- a/dashboard/config/bits-syzbot.config +++ b/dashboard/config/bits-syzbot.config @@ -163,3 +163,7 @@ CONFIG_BLK_DEV_LOOP_MIN_COUNT=16 ### These help to test wifi. CONFIG_MAC80211_HWSIM=y CONFIG_VIRT_WIFI=y + +### ORC unwinder allows to unwind exception and interrupt stacks. +CONFIG_UNWINDER_ORC=y +# CONFIG_UNWINDER_FRAME_POINTER is not set diff --git a/dashboard/config/upstream-kasan.config b/dashboard/config/upstream-kasan.config index f7102eff0..172b96bf5 100644 --- a/dashboard/config/upstream-kasan.config +++ b/dashboard/config/upstream-kasan.config @@ -6815,8 +6815,8 @@ CONFIG_DEBUG_BOOT_PARAMS=y # CONFIG_DEBUG_NMI_SELFTEST is not set CONFIG_X86_DEBUG_FPU=y # CONFIG_PUNIT_ATOM_DEBUG is not set -# CONFIG_UNWINDER_ORC is not set -CONFIG_UNWINDER_FRAME_POINTER=y +CONFIG_UNWINDER_ORC=y +# CONFIG_UNWINDER_FRAME_POINTER is not set # end of x86 Debugging # diff --git a/dashboard/config/upstream-kcsan.config b/dashboard/config/upstream-kcsan.config index c3021cef3..955ab430a 100644 --- a/dashboard/config/upstream-kcsan.config +++ b/dashboard/config/upstream-kcsan.config @@ -6684,7 +6684,7 @@ CONFIG_DEBUG_BOOT_PARAMS=y # CONFIG_DEBUG_NMI_SELFTEST is not set CONFIG_X86_DEBUG_FPU=y # CONFIG_PUNIT_ATOM_DEBUG is not set -# CONFIG_UNWINDER_ORC is not set -CONFIG_UNWINDER_FRAME_POINTER=y +CONFIG_UNWINDER_ORC=y +# CONFIG_UNWINDER_FRAME_POINTER is not set # CONFIG_UNWINDER_GUESS is not set # end of Kernel hacking diff --git a/dashboard/config/upstream-leak.config b/dashboard/config/upstream-leak.config index cf63a6db6..334e13cb6 100644 --- a/dashboard/config/upstream-leak.config +++ b/dashboard/config/upstream-leak.config @@ -6717,7 +6717,7 @@ CONFIG_DEBUG_BOOT_PARAMS=y # CONFIG_DEBUG_NMI_SELFTEST is not set CONFIG_X86_DEBUG_FPU=y # CONFIG_PUNIT_ATOM_DEBUG is not set -# CONFIG_UNWINDER_ORC is not set -CONFIG_UNWINDER_FRAME_POINTER=y +CONFIG_UNWINDER_ORC=y +# CONFIG_UNWINDER_FRAME_POINTER is not set # CONFIG_UNWINDER_GUESS is not set # end of Kernel hacking diff --git a/pkg/vcs/linux.go b/pkg/vcs/linux.go index 59a7b9e3b..9fc96fef4 100644 --- a/pkg/vcs/linux.go +++ b/pkg/vcs/linux.go @@ -109,7 +109,7 @@ func (ctx *linux) EnvForCommit(binDir, commit string, kernelConfig []byte) (*Bis } env := &BisectEnv{ Compiler: filepath.Join(binDir, "gcc-"+linuxCompilerVersion(tags), "bin", "gcc"), - KernelConfig: linuxDisableConfigs(kernelConfig, tags), + KernelConfig: linuxAlterConfigs(kernelConfig, tags), } // v4.0 doesn't boot with our config nor with defconfig, it halts on an interrupt in x86_64_start_kernel. if !tags["v4.1"] { @@ -132,8 +132,8 @@ func linuxCompilerVersion(tags map[string]bool) string { } } -func linuxDisableConfigs(config []byte, tags map[string]bool) []byte { - prereq := map[string]string{ +func linuxAlterConfigs(config []byte, tags map[string]bool) []byte { + disable := map[string]string{ // 5.2 has CONFIG_SECURITY_TOMOYO_INSECURE_BUILTIN_SETTING which allows to test tomoyo better. // This config also enables CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER // but we need it disabled to boot older kernels. @@ -176,11 +176,26 @@ func linuxDisableConfigs(config []byte, tags map[string]bool) []byte { // which makes bisections take weeks. "CONFIG_DEBUG_KOBJECT": "disable-always", } - for cfg, tag := range prereq { + for cfg, tag := range disable { if !tags[tag] { config = bytes.Replace(config, []byte(cfg+"=y"), []byte("# "+cfg+" is not set"), -1) } } + alter := []struct { + From string + To string + Tag string + }{ + // Even though ORC unwinder was introduced a long time ago, it might have been broken for + // some time. 5.4 is chosen as a version tag, where ORC unwinder seems to work properly. + {"CONFIG_UNWINDER_ORC", "CONFIG_UNWINDER_FRAME_POINTER", "v5.4"}, + } + for _, a := range alter { + if !tags[a.Tag] { + config = bytes.Replace(config, []byte(a.From+"=y"), []byte("# "+a.From+" is not set"), -1) + config = bytes.Replace(config, []byte("# "+a.To+" is not set"), []byte(a.To+"=y"), -1) + } + } return config } -- cgit mrf-deployment