diff options
| author | Simone Weiß <simone.weiss@elektrobit.com> | 2024-03-04 20:00:40 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-03-18 10:58:57 +0000 |
| commit | ee397bf91e9742f2d410282306456afde4efea02 (patch) | |
| tree | aa665d2c0572d4d2a30ca69697c561fd56ab0cd4 /pkg | |
| parent | fc090d205d8c3d58f190659a98795d89421b7e6b (diff) | |
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.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/bisect/bisect.go | 6 | ||||
| -rw-r--r-- | pkg/vcs/linux.go | 9 |
2 files changed, 12 insertions, 3 deletions
diff --git a/pkg/bisect/bisect.go b/pkg/bisect/bisect.go index 270668e05..b75b2d2e0 100644 --- a/pkg/bisect/bisect.go +++ b/pkg/bisect/bisect.go @@ -416,7 +416,11 @@ func (env *env) minimizeConfig() (*testResult, error) { minConfig, err := env.minimizer.Minimize(env.cfg.Manager.SysTarget, env.cfg.Kernel.Config, env.cfg.Kernel.BaselineConfig, env.reportTypes, env.cfg.Trace, predMinimize) if err != nil { - return nil, err + if errors.Is(err, vcs.ErrBadKconfig) { + env.log("config minimization failed due to bad Kconfig %v\nproceeding with the original config", err) + } else { + return nil, err + } } env.kernelConfig = minConfig return testResults[hash.Hash(minConfig)], nil 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 { |
