From 29396b656bc85f2ce721ae032f607afcf67d84d4 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Thu, 15 Jun 2023 13:55:53 +0200 Subject: pkg/vcs: move linuxAlterConfigs() to separate file The new linux_configs.go file will contain routines that manage Linux-related configs. --- pkg/vcs/linux.go | 85 ++-------------------------------------------- pkg/vcs/linux_configs.go | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 82 deletions(-) create mode 100644 pkg/vcs/linux_configs.go (limited to 'pkg/vcs') diff --git a/pkg/vcs/linux.go b/pkg/vcs/linux.go index b29e11664..07278e83f 100644 --- a/pkg/vcs/linux.go +++ b/pkg/vcs/linux.go @@ -151,7 +151,7 @@ func (ctx *linux) EnvForCommit( if err != nil { return nil, err } - linuxAlterConfigs(cf, tags) + setLinuxTagConfigs(cf, tags) compiler := "" if compilerType == "gcc" { @@ -219,85 +219,6 @@ func linuxGCCPath(tags map[string]bool, binDir, defaultCompiler string) string { return filepath.Join(binDir, "gcc-"+version, "bin", "gcc") } -func linuxAlterConfigs(cf *kconfig.ConfigFile, tags map[string]bool) { - const disableAlways = "disable-always" - // If tags is nil, disable only configs marked as disableAlways. - checkTag := func(tag string) bool { - return tags != nil && !tags[tag] || - tags == nil && tag == disableAlways - } - 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. - "SECURITY_TOMOYO_OMIT_USERSPACE_LOADER": "v5.2", - // Kernel is boot broken before 4.15 due to double-free in vudc_probe: - // https://lkml.org/lkml/2018/9/7/648 - // Fixed by e28fd56ad5273be67d0fae5bedc7e1680e729952. - "USBIP_VUDC": "v4.15", - // CONFIG_CAN causes: - // all runs: crashed: INFO: trying to register non-static key in can_notifier - // for v4.11..v4.12 and v4.12..v4.13 ranges. - // Fixed by 74b7b490886852582d986a33443c2ffa50970169. - "CAN": "v4.13", - // Setup of network devices is broken before v4.12 with a "WARNING in hsr_get_node". - // Fixed by 675c8da049fd6556eb2d6cdd745fe812752f07a8. - "HSR": "v4.12", - // Setup of network devices is broken before v4.12 with a "WARNING: ODEBUG bug in __sk_destruct" - // coming from smc_release. - "SMC": "v4.12", - // Kernel is boot broken before 4.10 with a lockdep warning in vhci_hcd_probe. - "USBIP_VHCI_HCD": "v4.10", - "BT_HCIVHCI": "v4.10", - // Setup of network devices is broken before v4.7 with a deadlock involving team. - "NET_TEAM": "v4.7", - // Setup of network devices is broken before v4.5 with a warning in batadv_tvlv_container_remove. - "BATMAN_ADV": "v4.5", - // UBSAN is broken in multiple ways before v5.3, see: - // https://github.com/google/syzkaller/issues/1523#issuecomment-696514105 - "UBSAN": "v5.3", - // First, we disable coverage in pkg/bisect because it fails machine testing starting from 4.7. - // Second, at 6689da155bdcd17abfe4d3a8b1e245d9ed4b5f2c CONFIG_KCOV selects CONFIG_GCC_PLUGIN_SANCOV - // (why?), which is build broken for hundreds of revisions. - "KCOV": disableAlways, - // This helps to produce stable binaries in presence of kernel tag changes. - "LOCALVERSION_AUTO": disableAlways, - // BTF fails lots of builds with: - // pahole version v1.9 is too old, need at least v1.13 - // Failed to generate BTF for vmlinux. Try to disable CONFIG_DEBUG_INFO_BTF. - "DEBUG_INFO_BTF": disableAlways, - // This config only adds debug output. It should not be enabled at all, - // but it was accidentially enabled on some instances for some periods of time, - // and kernel is boot-broken for prolonged ranges of commits with deadlock - // which makes bisections take weeks. - "DEBUG_KOBJECT": disableAlways, - // This config is causing problems to kernel signature calculation as new initramfs is generated - // as a part of every build. Due to this init.data section containing this generated initramfs - // is differing between builds causing signture being random number. - "BLK_DEV_INITRD": disableAlways, - } - for cfg, tag := range disable { - if checkTag(tag) { - cf.Unset(cfg) - } - } - 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. - {"UNWINDER_ORC", "UNWINDER_FRAME_POINTER", "v5.4"}, - } - for _, a := range alter { - if checkTag(a.Tag) { - cf.Unset(a.From) - cf.Set(a.To, kconfig.Yes) - } - } -} - func (ctx *linux) PrepareBisect() error { if ctx.vmType != "gvisor" { // Some linux repos we fuzz don't import the upstream release git tags. We need tags @@ -401,8 +322,8 @@ func (ctx *linux) Minimize(target *targets.Target, original, baseline []byte, if err != nil { return nil, err } - linuxAlterConfigs(originalConfig, nil) - linuxAlterConfigs(baselineConfig, nil) + setLinuxTagConfigs(originalConfig, nil) + setLinuxTagConfigs(baselineConfig, nil) kconfPred := func(candidate *kconfig.ConfigFile) (bool, error) { res, err := pred(serialize(candidate)) return res == BisectBad, err diff --git a/pkg/vcs/linux_configs.go b/pkg/vcs/linux_configs.go new file mode 100644 index 000000000..b54fed8fa --- /dev/null +++ b/pkg/vcs/linux_configs.go @@ -0,0 +1,88 @@ +// Copyright 2023 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package vcs + +import "github.com/google/syzkaller/pkg/kconfig" + +// setLinuxTagConfigs() disables Linux kernel configurations depending on the Linux kernel version, +// which is determined by the git tags reachable from HEAD. +// The problem is that Linux kernel is regularly broken w.r.t syzbot configs, especially on older versions. +func setLinuxTagConfigs(cf *kconfig.ConfigFile, tags map[string]bool) { + const disableAlways = "disable-always" + // If tags is nil, disable only configs marked as disableAlways. + checkTag := func(tag string) bool { + return tags != nil && !tags[tag] || + tags == nil && tag == disableAlways + } + 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. + "SECURITY_TOMOYO_OMIT_USERSPACE_LOADER": "v5.2", + // Kernel is boot broken before 4.15 due to double-free in vudc_probe: + // https://lkml.org/lkml/2018/9/7/648 + // Fixed by e28fd56ad5273be67d0fae5bedc7e1680e729952. + "USBIP_VUDC": "v4.15", + // CONFIG_CAN causes: + // all runs: crashed: INFO: trying to register non-static key in can_notifier + // for v4.11..v4.12 and v4.12..v4.13 ranges. + // Fixed by 74b7b490886852582d986a33443c2ffa50970169. + "CAN": "v4.13", + // Setup of network devices is broken before v4.12 with a "WARNING in hsr_get_node". + // Fixed by 675c8da049fd6556eb2d6cdd745fe812752f07a8. + "HSR": "v4.12", + // Setup of network devices is broken before v4.12 with a "WARNING: ODEBUG bug in __sk_destruct" + // coming from smc_release. + "SMC": "v4.12", + // Kernel is boot broken before 4.10 with a lockdep warning in vhci_hcd_probe. + "USBIP_VHCI_HCD": "v4.10", + "BT_HCIVHCI": "v4.10", + // Setup of network devices is broken before v4.7 with a deadlock involving team. + "NET_TEAM": "v4.7", + // Setup of network devices is broken before v4.5 with a warning in batadv_tvlv_container_remove. + "BATMAN_ADV": "v4.5", + // UBSAN is broken in multiple ways before v5.3, see: + // https://github.com/google/syzkaller/issues/1523#issuecomment-696514105 + "UBSAN": "v5.3", + // First, we disable coverage in pkg/bisect because it fails machine testing starting from 4.7. + // Second, at 6689da155bdcd17abfe4d3a8b1e245d9ed4b5f2c CONFIG_KCOV selects CONFIG_GCC_PLUGIN_SANCOV + // (why?), which is build broken for hundreds of revisions. + "KCOV": disableAlways, + // This helps to produce stable binaries in presence of kernel tag changes. + "LOCALVERSION_AUTO": disableAlways, + // BTF fails lots of builds with: + // pahole version v1.9 is too old, need at least v1.13 + // Failed to generate BTF for vmlinux. Try to disable CONFIG_DEBUG_INFO_BTF. + "DEBUG_INFO_BTF": disableAlways, + // This config only adds debug output. It should not be enabled at all, + // but it was accidentially enabled on some instances for some periods of time, + // and kernel is boot-broken for prolonged ranges of commits with deadlock + // which makes bisections take weeks. + "DEBUG_KOBJECT": disableAlways, + // This config is causing problems to kernel signature calculation as new initramfs is generated + // as a part of every build. Due to this init.data section containing this generated initramfs + // is differing between builds causing signture being random number. + "BLK_DEV_INITRD": disableAlways, + } + for cfg, tag := range disable { + if checkTag(tag) { + cf.Unset(cfg) + } + } + 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. + {"UNWINDER_ORC", "UNWINDER_FRAME_POINTER", "v5.4"}, + } + for _, a := range alter { + if checkTag(a.Tag) { + cf.Unset(a.From) + cf.Set(a.To, kconfig.Yes) + } + } +} -- cgit mrf-deployment