aboutsummaryrefslogtreecommitdiffstats
path: root/prog/analysis.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2022-09-15 13:36:15 +0000
committerAleksandr Nogikh <wp32pw@gmail.com>2022-09-27 13:07:37 +0200
commit2b420c9686b7c95216d491a97fcd5158acb810f2 (patch)
tree091b25ff54bf7f41a7fcf3a027a714fb2e7255b8 /prog/analysis.go
parent1856cdc9b3652a082c5bfa0e08a9f883baece8ec (diff)
sys/linux: extract raw images from syz_mount_image
To simplify the extraction code, let's make segments non-overlapping even before execution.
Diffstat (limited to 'prog/analysis.go')
-rw-r--r--prog/analysis.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/prog/analysis.go b/prog/analysis.go
index 1b572f0c0..04f0b270a 100644
--- a/prog/analysis.go
+++ b/prog/analysis.go
@@ -10,6 +10,7 @@ package prog
import (
"fmt"
+ "io"
)
type state struct {
@@ -337,3 +338,40 @@ func checkMaxCallID(id int) {
panic(fmt.Sprintf("too many syscalls, have %v, max supported %v", id, fallbackCallMask+1))
}
}
+
+type ExtractedAssetType int
+
+const (
+ MountInRepro ExtractedAssetType = iota
+)
+
+type ExtractedAsset struct {
+ Call int
+ Type ExtractedAssetType
+ Reader io.Reader
+ Error error
+}
+
+func (p *Prog) ExtractAssets() []*ExtractedAsset {
+ handler := p.Target.ExtractMountedImage
+ if handler == nil {
+ // Such an operation is not supported by the target.
+ return nil
+ }
+ ret := []*ExtractedAsset{}
+ for id, c := range p.Calls {
+ // So far we only support the MountInRepro asset.
+ reader, err := handler(c)
+ if reader == nil && err == nil {
+ // This is not the call that contains the mount image.
+ continue
+ }
+ ret = append(ret, &ExtractedAsset{
+ Type: MountInRepro,
+ Call: id,
+ Reader: reader,
+ Error: err,
+ })
+ }
+ return ret
+}