diff options
| author | Florent Revest <revest@chromium.org> | 2024-11-28 01:50:23 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-12-09 18:35:48 +0000 |
| commit | deb728774249ce479316c219f77530e2af52e3bd (patch) | |
| tree | 0c40542088d8ffebf4ee5ddb56a61a94ed57afaf /prog | |
| parent | 07e46fbc2bd7ff8782c975596672e4e3d3891865 (diff) | |
prog: annotate image assets with fsck logs
Syscall attributes are extended with a fsck command field which lets
file system mount definitions specify a fsck-like command to run. This
is required because all file systems have a custom fsck command
invokation style.
When uploading a compressed image asset to the dashboard, syz-manager
also runs the fsck command and logs its output over the dashapi.
The dashboard logs these fsck logs into the database.
This has been requested by fs maintainer Ted Tso who would like to
quickly understand whether a filesystem is corrupted or not before
looking at a reproducer in more details. Ultimately, this could be used
as an early triage sign to determine whether a bug is obviously
critical.
Diffstat (limited to 'prog')
| -rw-r--r-- | prog/analysis.go | 4 | ||||
| -rw-r--r-- | prog/images_test.go | 5 | ||||
| -rw-r--r-- | prog/prog_test.go | 16 | ||||
| -rw-r--r-- | prog/types.go | 3 |
4 files changed, 24 insertions, 4 deletions
diff --git a/prog/analysis.go b/prog/analysis.go index 087a2b3dc..a6ad97c08 100644 --- a/prog/analysis.go +++ b/prog/analysis.go @@ -383,7 +383,7 @@ const ( MountInRepro AssetType = iota ) -func (p *Prog) ForEachAsset(cb func(name string, typ AssetType, r io.Reader)) { +func (p *Prog) ForEachAsset(cb func(name string, typ AssetType, r io.Reader, c *Call)) { for id, c := range p.Calls { ForeachArg(c, func(arg Arg, _ *ArgCtx) { a, ok := arg.(*DataArg) @@ -395,7 +395,7 @@ func (p *Prog) ForEachAsset(cb func(name string, typ AssetType, r io.Reader)) { if len(data) == 0 { return } - cb(fmt.Sprintf("mount_%v", id), MountInRepro, bytes.NewReader(data)) + cb(fmt.Sprintf("mount_%v", id), MountInRepro, bytes.NewReader(data), c) }) } } diff --git a/prog/images_test.go b/prog/images_test.go index 86914105f..1ae7008f9 100644 --- a/prog/images_test.go +++ b/prog/images_test.go @@ -46,10 +46,13 @@ func TestForEachAsset(t *testing.T) { t.Fatalf("failed to deserialize %s: %s", file, err) } base := strings.TrimSuffix(file, ".in") - p.ForEachAsset(func(name string, typ AssetType, r io.Reader) { + p.ForEachAsset(func(name string, typ AssetType, r io.Reader, c *Call) { if typ != MountInRepro { t.Fatalf("unknown asset type %v", typ) } + if !strings.HasPrefix(c.Meta.Name, "syz_mount_image$") { + t.Fatalf("unexpected syscall name %v", c.Meta.Name) + } testResult, err := io.ReadAll(r) if err != nil { t.Fatal(err) diff --git a/prog/prog_test.go b/prog/prog_test.go index 29f2aee5b..96280b3e8 100644 --- a/prog/prog_test.go +++ b/prog/prog_test.go @@ -140,6 +140,22 @@ func TestVmaType(t *testing.T) { } } +func TestFsckAttr(t *testing.T) { + target, err := GetTarget("test", "64") + if err != nil { + t.Fatal(err) + } + + syscall := target.SyscallMap["test$fsck_attr"] + if syscall == nil { + t.Fatal("could not find test$fsck_attr in sys/test") + } + + if syscall.Attrs.Fsck != "fsck.test -n" { + t.Fatalf("unexpected fsck command %s", syscall.Attrs.Fsck) + } +} + // TestCrossTarget ensures that a program serialized for one arch can be // deserialized for another arch. This happens when managers exchange // programs via hub. diff --git a/prog/types.go b/prog/types.go index 5f2360946..02bbdffdf 100644 --- a/prog/types.go +++ b/prog/types.go @@ -33,7 +33,7 @@ type Syscall struct { // pkg/compiler uses this structure to parse descriptions. // syz-sysgen uses this structure to generate code for executor. // -// Only `bool`s and `uint64`s are currently supported. +// Only `bool`s, `string`s and `uint64`s are currently supported. // // See docs/syscall_descriptions_syntax.md for description of individual attributes. type SyscallAttrs struct { @@ -47,6 +47,7 @@ type SyscallAttrs struct { RemoteCover bool Automatic bool AutomaticHelper bool + Fsck string } // MaxArgs is maximum number of syscall arguments. |
