aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2021-09-15 15:14:27 +0000
committerAleksandr Nogikh <wp32pw@gmail.com>2021-09-16 15:21:06 +0200
commit20497e8e232a2f190f5fc182a0ab45c814c0968f (patch)
tree15a01afb18bd0a228adba9a731e6b013882a91dc
parent7612dc7768b6f0f12e9b370437eaa9c041cdb8c9 (diff)
all: try to query compiler id even when a build fails
Currently syzkaller leaves an empty CompilerID, when it has failed to build a kernel. However, in almost all cases this is possible to do. Query compiler information irregardless of whether the build process is successful.
-rw-r--r--pkg/build/build.go14
-rw-r--r--pkg/build/linux.go31
-rw-r--r--syz-ci/jobs.go2
3 files changed, 24 insertions, 23 deletions
diff --git a/pkg/build/build.go b/pkg/build/build.go
index c1b0302e9..0add9451b 100644
--- a/pkg/build/build.go
+++ b/pkg/build/build.go
@@ -76,6 +76,14 @@ func Image(params Params) (details ImageDetails, err error) {
}
}
details, err = builder.build(params)
+ if details.CompilerID == "" {
+ // Fill in the compiler info even if the build failed.
+ var idErr error
+ details.CompilerID, idErr = compilerIdentity(params.Compiler)
+ if err == nil {
+ err = idErr
+ } // Try to preserve the build error otherwise.
+ }
if err != nil {
err = extractRootCause(err, params.TargetOS, params.KernelDir)
return
@@ -85,12 +93,6 @@ func Image(params Params) (details ImageDetails, err error) {
return details, fmt.Errorf("failed to chmod 0600 %v: %v", key, err)
}
}
- if details.CompilerID == "" {
- details.CompilerID, err = compilerIdentity(params.Compiler)
- if err != nil {
- return
- }
- }
return
}
diff --git a/pkg/build/linux.go b/pkg/build/linux.go
index 85575e621..3947463de 100644
--- a/pkg/build/linux.go
+++ b/pkg/build/linux.go
@@ -26,12 +26,17 @@ import (
type linux struct{}
func (linux linux) build(params Params) (ImageDetails, error) {
- if err := linux.buildKernel(params); err != nil {
- return ImageDetails{}, err
+ details := ImageDetails{}
+ err := linux.buildKernel(params)
+ // Even if the build fails, autogenerated files would still be present (unless the build is really broken).
+ if err != nil {
+ details.CompilerID, _ = queryLinuxCompiler(params.KernelDir)
+ return details, err
}
- compilerID, err := queryLinuxCompiler(params.KernelDir)
+
+ details.CompilerID, err = queryLinuxCompiler(params.KernelDir)
if err != nil {
- return ImageDetails{}, err
+ return details, err
}
kernelPath := filepath.Join(params.KernelDir, filepath.FromSlash(kernelBin(params.TargetArch)))
@@ -39,28 +44,22 @@ func (linux linux) build(params Params) (ImageDetails, error) {
// The old way of assembling the image from userspace dir.
// It should be removed once all syzbot instances are switched.
if err := linux.createImage(params, kernelPath); err != nil {
- return ImageDetails{}, err
+ return details, err
}
} else if params.VMType == "qemu" {
// If UserspaceDir is a file (image) and we use qemu, we just copy image and kernel to the output dir
// assuming that qemu will use injected kernel boot. In this mode we also assume password/key-less ssh.
if err := osutil.CopyFile(kernelPath, filepath.Join(params.OutputDir, "kernel")); err != nil {
- return ImageDetails{}, err
+ return details, err
}
if err := osutil.CopyFile(params.UserspaceDir, filepath.Join(params.OutputDir, "image")); err != nil {
- return ImageDetails{}, err
+ return details, err
}
} else if err := embedLinuxKernel(params, kernelPath); err != nil {
- return ImageDetails{}, err
- }
- signature, err := elfBinarySignature(filepath.Join(params.OutputDir, "obj", "vmlinux"))
- if err != nil {
- return ImageDetails{}, err
+ return details, err
}
- return ImageDetails{
- Signature: signature,
- CompilerID: compilerID,
- }, nil
+ details.Signature, err = elfBinarySignature(filepath.Join(params.OutputDir, "obj", "vmlinux"))
+ return details, err
}
func (linux linux) buildKernel(params Params) error {
diff --git a/syz-ci/jobs.go b/syz-ci/jobs.go
index 7ea6aaff7..605ddaf7b 100644
--- a/syz-ci/jobs.go
+++ b/syz-ci/jobs.go
@@ -549,10 +549,10 @@ func (jp *JobProcessor) testPatch(job *Job, mgrcfg *mgrconfig.Config) error {
log.Logf(0, "job: building kernel...")
kernelConfig, details, err := env.BuildKernel(mgr.mgrcfg.Compiler, mgr.mgrcfg.Ccache, mgr.mgrcfg.Userspace,
mgr.mgrcfg.KernelCmdline, mgr.mgrcfg.KernelSysctl, req.KernelConfig)
+ resp.Build.CompilerID = details.CompilerID
if err != nil {
return err
}
- resp.Build.CompilerID = details.CompilerID
if kernelConfig != "" {
resp.Build.KernelConfig, err = ioutil.ReadFile(kernelConfig)
if err != nil {