diff options
| author | Florent Revest <revest@chromium.org> | 2025-01-21 16:18:19 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-01-21 15:46:45 +0000 |
| commit | da72ac06e38cf1dd2ecbddd5502225ff7589542d (patch) | |
| tree | 980e5309e6c7a92bbc84ebc63b17559568f569c9 /syz-manager | |
| parent | cce8ebd1002f4970df17ee9a7d9694a0a07fa965 (diff) | |
syz-manager: fix empty fs images being run through fsck
We currently read an fs image twice from an io.Reader, once to upload it
to the dashboard and once to write it to disk for fsck. The first
io.Reader read exhausts the stream and therefore leaves an empty image
to write to disk. All fsck commands fail with
fsck.ext4 -n exited with status code 8
e2fsck 1.47.0 (5-Feb-2023)
fsck.ext4: Attempt to read block from filesystem resulted in short
read while trying to open /tmp/1234.img
Could this be a zero-length partition?
This basically duplicates the io.Reader using a Tee. I considered
refactoring the asset upload and fsck APIs to use a buffer instead of a
reader but this leads to a rather far fetching refactoring. Duplicating
streams here seemed to be a more self-contained change.
Diffstat (limited to 'syz-manager')
| -rw-r--r-- | syz-manager/manager.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/syz-manager/manager.go b/syz-manager/manager.go index e093f7732..fd6be0072 100644 --- a/syz-manager/manager.go +++ b/syz-manager/manager.go @@ -922,14 +922,16 @@ func (mgr *Manager) uploadReproAssets(repro *repro.Result) []dashapi.NewAsset { if !ok { panic("unknown extracted prog asset") } - asset, err := mgr.assetStorage.UploadCrashAsset(r, name, dashTyp, nil) + r2 := &bytes.Buffer{} + r1 := io.TeeReader(r, r2) + asset, err := mgr.assetStorage.UploadCrashAsset(r1, name, dashTyp, nil) if err != nil { log.Logf(1, "processing of the asset %v (%v) failed: %v", name, typ, err) return } // Report file systems that fail fsck with a separate tag. if mgr.cfg.RunFsck && dashTyp == dashapi.MountInRepro && c.Meta.Attrs.Fsck != "" { - logs, isClean, err := image.Fsck(r, c.Meta.Attrs.Fsck) + logs, isClean, err := image.Fsck(r2, c.Meta.Attrs.Fsck) if err != nil { log.Logf(1, "fsck of the asset %v failed: %v", name, err) } else { |
