syz-ci: don't assume kernel config is called .config

.config is linux-ism. We have a convention that kernel config
is copied to kernel.config file. Use it.
This commit is contained in:
Dmitry Vyukov 2019-05-11 12:57:07 +02:00
parent c017728b48
commit 39449875b6
4 changed files with 20 additions and 10 deletions

View File

@ -261,7 +261,7 @@ func (env *env) test() (vcs.BisectResult, *vcs.Commit, *report.Report, error) {
cfg.Manager.Type, cfg.Manager.KernelSrc); err != nil {
return 0, nil, nil, fmt.Errorf("kernel clean failed: %v", err)
}
err = env.inst.BuildKernel(compiler, cfg.Kernel.Userspace,
_, err = env.inst.BuildKernel(compiler, cfg.Kernel.Userspace,
cfg.Kernel.Cmdline, cfg.Kernel.Sysctl, bisectEnv.KernelConfig)
env.buildTime += time.Since(buildStart)
if err != nil {

View File

@ -82,15 +82,22 @@ func (env *Env) BuildSyzkaller(repo, commit string) error {
return nil
}
func (env *Env) BuildKernel(compilerBin, userspaceDir, cmdlineFile, sysctlFile string, kernelConfig []byte) error {
func (env *Env) BuildKernel(compilerBin, userspaceDir, cmdlineFile, sysctlFile string, kernelConfig []byte) (string, error) {
cfg := env.cfg
imageDir := filepath.Join(cfg.Workdir, "image")
if err := build.Image(cfg.TargetOS, cfg.TargetVMArch, cfg.Type,
cfg.KernelSrc, imageDir, compilerBin, userspaceDir,
cmdlineFile, sysctlFile, kernelConfig); err != nil {
return err
return "", err
}
return SetConfigImage(cfg, imageDir, true)
if err := SetConfigImage(cfg, imageDir, true); err != nil {
return "", err
}
kernelConfigFile := filepath.Join(imageDir, "kernel.config")
if !osutil.IsExist(kernelConfigFile) {
kernelConfigFile = ""
}
return kernelConfigFile, nil
}
func SetConfigImage(cfg *mgrconfig.Config, imageDir string, reliable bool) error {

View File

@ -469,13 +469,16 @@ func (jp *JobProcessor) testPatch(job *Job, mgrcfg *mgrconfig.Config) error {
}
log.Logf(0, "job: building kernel...")
if err := env.BuildKernel(mgr.mgrcfg.Compiler, mgr.mgrcfg.Userspace, mgr.mgrcfg.KernelCmdline,
mgr.mgrcfg.KernelSysctl, req.KernelConfig); err != nil {
kernelConfig, err := env.BuildKernel(mgr.mgrcfg.Compiler, mgr.mgrcfg.Userspace, mgr.mgrcfg.KernelCmdline,
mgr.mgrcfg.KernelSysctl, req.KernelConfig)
if err != nil {
return err
}
resp.Build.KernelConfig, err = ioutil.ReadFile(filepath.Join(mgrcfg.KernelSrc, ".config"))
if err != nil {
return fmt.Errorf("failed to read config file: %v", err)
if kernelConfig != "" {
resp.Build.KernelConfig, err = ioutil.ReadFile(kernelConfig)
if err != nil {
return fmt.Errorf("failed to read config file: %v", err)
}
}
log.Logf(0, "job: testing...")
results, err := env.Test(3, req.ReproSyz, req.ReproOpts, req.ReproC)

View File

@ -130,7 +130,7 @@ func test(repo vcs.Repo, bisecter vcs.Bisecter, kernelConfig []byte, env *instan
if err := build.Clean(*flagOS, *flagArch, vmType, *flagKernelSrc); err != nil {
fail(err)
}
err = env.BuildKernel(compiler, *flagUserspace, *flagKernelCmdline, *flagKernelSysctl, bisectEnv.KernelConfig)
_, err = env.BuildKernel(compiler, *flagUserspace, *flagKernelCmdline, *flagKernelSysctl, bisectEnv.KernelConfig)
if err != nil {
if verr, ok := err.(*osutil.VerboseError); ok {
log.Printf("BUILD BROKEN: %v", verr.Title)