From ee397bf91e9742f2d410282306456afde4efea02 Mon Sep 17 00:00:00 2001 From: Simone Weiß Date: Mon, 4 Mar 2024 20:00:40 +0100 Subject: pkg/bisect: make bisection more robust Bisection should not fail if the Kconfig or the baseline config have issues. Broken kernel sources might lead to issues when parsing Kconfig, ignore this and proceed with the original config. If the baseline config is not parseable, proceed anyway as this is an optional parameter to begin with. --- pkg/vcs/linux.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'pkg/vcs/linux.go') diff --git a/pkg/vcs/linux.go b/pkg/vcs/linux.go index 98ae07cda..d5a4d138c 100644 --- a/pkg/vcs/linux.go +++ b/pkg/vcs/linux.go @@ -5,6 +5,7 @@ package vcs import ( "bytes" + "errors" "fmt" "net/mail" "path/filepath" @@ -274,6 +275,8 @@ func ParseMaintainersLinux(text []byte) Recipients { return mtrs } +var ErrBadKconfig = errors.New("failed to parse Kconfig") + const configBisectTag = "# Minimized by syzkaller" // Minimize() attempts to drop Linux kernel configs that are unnecessary(*) for bug reproduction. @@ -289,7 +292,7 @@ func (ctx *linux) Minimize(target *targets.Target, original, baseline []byte, ty } kconf, err := kconfig.Parse(target, filepath.Join(ctx.git.dir, "Kconfig")) if err != nil { - return nil, fmt.Errorf("failed to parse Kconfig: %w", err) + return nil, fmt.Errorf("%w: %w", ErrBadKconfig, err) } config, err := kconfig.ParseConfigData(original, "original") if err != nil { @@ -324,8 +327,10 @@ func (ctx *linux) Minimize(target *targets.Target, original, baseline []byte, ty } if len(baseline) > 0 { baselineConfig, err := kconfig.ParseConfigData(baseline, "baseline") + // If we fail to parse the baseline config proceed with original one as baseline config + // is an optional parameter. if err != nil { - return nil, err + return nil, fmt.Errorf("%w: %w", ErrBadKconfig, err) } err = minimizeCtx.minimizeAgainst(baselineConfig) if err != nil { -- cgit mrf-deployment