aboutsummaryrefslogtreecommitdiffstats
path: root/syz-cluster/workflow/fuzz-step
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-07-18 12:21:39 +0200
committerAleksandr Nogikh <nogikh@google.com>2025-07-22 14:49:22 +0000
commit0b3a8483a73330b481a0d9fef2e276eb06465bc0 (patch)
treeaebd4c3a914f6c69d6d6f89c8b2e68a6c5d868af /syz-cluster/workflow/fuzz-step
parent6ce0983056e7e9efff04681de67e6310b88fdc16 (diff)
all: determine patched symbols for focused fuzzing
Hash the code section of the individual symbols from vmlinux.o and use it to determine the functions that changed their bodies between the base and the patched build. If the number of affected symbols is reasonable (<5%), fuzz it with the highest priority.
Diffstat (limited to 'syz-cluster/workflow/fuzz-step')
-rw-r--r--syz-cluster/workflow/fuzz-step/main.go47
1 files changed, 41 insertions, 6 deletions
diff --git a/syz-cluster/workflow/fuzz-step/main.go b/syz-cluster/workflow/fuzz-step/main.go
index 6996ae8a0..f7ed5ef39 100644
--- a/syz-cluster/workflow/fuzz-step/main.go
+++ b/syz-cluster/workflow/fuzz-step/main.go
@@ -10,6 +10,12 @@ import (
"errors"
"flag"
"fmt"
+ "io"
+ "net/http"
+ "os"
+ "path/filepath"
+ "time"
+
"github.com/google/syzkaller/pkg/config"
"github.com/google/syzkaller/pkg/log"
"github.com/google/syzkaller/pkg/manager"
@@ -19,11 +25,6 @@ import (
"github.com/google/syzkaller/syz-cluster/pkg/api"
"github.com/google/syzkaller/syz-cluster/pkg/app"
"golang.org/x/sync/errgroup"
- "io"
- "net/http"
- "os"
- "path/filepath"
- "time"
)
var (
@@ -93,7 +94,12 @@ func run(baseCtx context.Context, client *api.Client, timeout time.Duration,
if err != nil {
return fmt.Errorf("failed to load configs: %w", err)
}
- manager.PatchFocusAreas(patched, series.PatchBodies())
+
+ baseSymbols, patchedSymbols, err := readSymbolHashes()
+ if err != nil {
+ app.Errorf("failed to read symbol hashes: %v", err)
+ }
+ manager.PatchFocusAreas(patched, series.PatchBodies(), baseSymbols, patchedSymbols)
if *flagCorpusURL != "" {
err := downloadCorpus(baseCtx, patched.Workdir, *flagCorpusURL)
@@ -282,6 +288,35 @@ func reportFinding(ctx context.Context, client *api.Client, bug *manager.UniqueB
return client.UploadFinding(ctx, finding)
}
+func readSymbolHashes() (base, patched map[string]string, err error) {
+ // These are saved by the build step.
+ base, err = readJSONMap("/base/symbol_hashes.json")
+ if err != nil {
+ return nil, nil, fmt.Errorf("failed to read base hashes: %w", err)
+ }
+ patched, err = readJSONMap("/patched/symbol_hashes.json")
+ if err != nil {
+ return nil, nil, fmt.Errorf("failed to read patched hashes: %w", err)
+ }
+ log.Logf(0, "extracted %d symbol hashes for base and %d for patched", len(base), len(patched))
+ return
+}
+
+func readJSONMap(file string) (map[string]string, error) {
+ f, err := os.Open(file)
+ if err != nil {
+ return nil, err
+ }
+ defer f.Close()
+
+ var data map[string]string
+ err = json.NewDecoder(f).Decode(&data)
+ if err != nil {
+ return nil, err
+ }
+ return data, nil
+}
+
func compressArtifacts(dir string) (io.Reader, error) {
var buf bytes.Buffer
lw := &LimitedWriter{