-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run a smoke test on the base kernel build and report back the results.
- Loading branch information
Showing
8 changed files
with
254 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# syntax=docker.io/docker/dockerfile:1.7-labs | ||
# Copyright 2025 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. | ||
|
||
# Build syzkaller. | ||
FROM gcr.io/syzkaller/env as syzkaller-builder | ||
WORKDIR /build | ||
# First query the modules to facilitate caching. | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
COPY --exclude=vendor --exclude=syz-cluster . . | ||
RUN make TARGETARCH=amd64 | ||
|
||
FROM golang:1.23-alpine AS boot-step-builder | ||
WORKDIR /build | ||
|
||
# Copy the code and the dependencies. | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
COPY pkg/ pkg/ | ||
# TODO: get rid of the prog/ dependency? | ||
COPY prog/ prog/ | ||
COPY vm/ vm/ | ||
COPY executor/ executor/ | ||
COPY dashboard/dashapi/ dashboard/dashapi/ | ||
# Copying from the builder to take the `make descriptions` result. | ||
COPY --from=syzkaller-builder /build/sys/ sys/ | ||
COPY syz-cluster/workflow/boot-step/*.go syz-cluster/workflow/boot-step/ | ||
COPY syz-cluster/pkg/ syz-cluster/pkg/ | ||
|
||
RUN go build -o /build/boot-step-bin /build/syz-cluster/workflow/boot-step | ||
|
||
FROM debian:bookworm | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y qemu-system openssh-client | ||
|
||
# pkg/osutil uses syzkaller user for sandboxing. | ||
RUN useradd --create-home syzkaller | ||
|
||
COPY --from=syzkaller-builder /build/bin/ /syzkaller/bin/ | ||
COPY --from=boot-step-builder /build/boot-step-bin /bin/boot-step | ||
COPY syz-cluster/workflow/configs/ /configs/ | ||
|
||
ENTRYPOINT ["/bin/boot-tracker"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// Copyright 2025 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 main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"fmt" | ||
"log" | ||
"path/filepath" | ||
|
||
"github.com/google/syzkaller/pkg/instance" | ||
"github.com/google/syzkaller/pkg/mgrconfig" | ||
"github.com/google/syzkaller/pkg/osutil" | ||
"github.com/google/syzkaller/syz-cluster/pkg/api" | ||
"github.com/google/syzkaller/syz-cluster/pkg/app" | ||
) | ||
|
||
var ( | ||
flagConfig = flag.String("config", "", "syzkaller config") | ||
flagSession = flag.String("session", "", "session ID") | ||
flagTestName = flag.String("test_name", "", "test name") | ||
flagBaseBuild = flag.String("base_build", "", "base build ID") | ||
flagPatchedBuild = flag.String("patched_build", "", "patched build ID") | ||
flagOutput = flag.String("output", "", "where to store the result") | ||
) | ||
|
||
func main() { | ||
flag.Parse() | ||
if *flagConfig == "" || *flagSession == "" || *flagTestName == "" { | ||
app.Fatalf("--config, --session and --test_name must be set") | ||
} | ||
|
||
ctx := context.Background() | ||
client := app.DefaultClient() | ||
|
||
testResult := &api.TestResult{ | ||
SessionID: *flagSession, | ||
TestName: *flagTestName, | ||
BaseBuildID: *flagBaseBuild, | ||
PatchedBuildID: *flagPatchedBuild, | ||
Result: api.TestRunning, | ||
} | ||
// Report that we've begun the test -- it will let us report the findings. | ||
err := client.UploadTestResult(ctx, testResult) | ||
if err != nil { | ||
app.Fatalf("failed to upload test result: %v", err) | ||
} | ||
|
||
bootedFine, err := runTest(ctx, client) | ||
if err != nil { | ||
app.Fatalf("failed to run the boot test: %v", err) | ||
} | ||
if bootedFine { | ||
testResult.Result = api.TestPassed | ||
} else { | ||
testResult.Result = api.TestFailed | ||
} | ||
|
||
// Report the test results. | ||
err = client.UploadTestResult(ctx, testResult) | ||
if err != nil { | ||
app.Fatalf("failed to upload test result: %v", err) | ||
} | ||
if *flagOutput != "" { | ||
osutil.WriteJSON(*flagOutput, &api.BootResult{ | ||
Success: bootedFine, | ||
}) | ||
} | ||
} | ||
|
||
func runTest(ctx context.Context, client *api.Client) (bool, error) { | ||
cfg, err := mgrconfig.LoadFile(filepath.Join("/configs", *flagConfig, "base.cfg")) | ||
if err != nil { | ||
return false, err | ||
} | ||
cfg.Workdir = "/tmp/test-workdir" | ||
rep, err := instance.RunSmokeTest(cfg) | ||
if err != nil { | ||
return false, err | ||
} | ||
if rep != nil { | ||
log.Printf("uploading the finding %q", rep.Title) | ||
findingErr := client.UploadFinding(ctx, &api.Finding{ | ||
SessionID: *flagSession, | ||
TestName: *flagTestName, | ||
Title: rep.Title, | ||
Report: rep.Report, | ||
Log: rep.Output, | ||
}) | ||
if findingErr != nil { | ||
return false, fmt.Errorf("failed to report the finding: %w", findingErr) | ||
} | ||
return false, nil | ||
} | ||
return true, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2025 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. | ||
|
||
apiVersion: argoproj.io/v1alpha1 | ||
kind: WorkflowTemplate | ||
metadata: | ||
name: boot-step-template | ||
spec: | ||
templates: | ||
- name: boot-step | ||
inputs: | ||
parameters: | ||
- name: config | ||
value: "" | ||
- name: base-build-id | ||
value: "" | ||
- name: patched-build-id | ||
value: "" | ||
- name: test-name | ||
value: "" | ||
artifacts: | ||
- name: kernel | ||
path: /kernel | ||
container: | ||
image: boot-step-local | ||
imagePullPolicy: IfNotPresent | ||
command: ["/bin/boot-step"] | ||
args: [ | ||
"--config", "{{inputs.parameters.config}}", | ||
"--output", "/output/result.json", | ||
"--session", "{{workflow.parameters.session-id}}", | ||
"--test_name", "{{inputs.parameters.test-name}}", | ||
"--base_build", "{{inputs.parameters.base-build-id}}", | ||
"--patched_build", "{{inputs.parameters.patched-build-id}}" | ||
] | ||
volumeMounts: | ||
- name: workdir | ||
mountPath: /workdir | ||
- name: output | ||
mountPath: /output | ||
- name: dev-kvm | ||
mountPath: /dev/kvm | ||
# Needed for /dev/kvm. | ||
# TODO: there's a "device plugin" mechanism in k8s that can share it more safely. | ||
securityContext: | ||
privileged: true | ||
volumes: | ||
- name: workdir | ||
emptyDir: {} | ||
- name: output | ||
emptyDir: {} | ||
- name: dev-kvm | ||
hostPath: | ||
path: /dev/kvm | ||
type: CharDevice | ||
outputs: | ||
parameters: | ||
- name: result | ||
valueFrom: | ||
path: /output/result.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,3 +96,6 @@ spec: | |
- name: result | ||
valueFrom: | ||
path: /output/result.json | ||
artifacts: | ||
- name: kernel | ||
path: /output |