diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-01-10 14:28:27 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-01-11 14:13:27 +0000 |
| commit | dda5a9889e432dc7e9efe71a39292073fa6f6c00 (patch) | |
| tree | aff1da5e8b86de5f14c9482f7c983ec34b2060f4 /prog/resources.go | |
| parent | 00f3cc59cbd59389deb590c4a852ea30d8c93499 (diff) | |
prog: prefer precise constructors
During resource argument generation, we used to randomly select one of
the matching resources. With so many descendants of fd, this becomes
quite inefficient and most of the time syzkaller fails to build correct
programs.
Give precise resource contructions priority. Experiment with other
resource types only in 1/3 of cases.
Diffstat (limited to 'prog/resources.go')
| -rw-r--r-- | prog/resources.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/prog/resources.go b/prog/resources.go index 61b30581f..d739b528e 100644 --- a/prog/resources.go +++ b/prog/resources.go @@ -27,19 +27,19 @@ var ( } ) -func (target *Target) calcResourceCtors(res *ResourceDesc, precise bool) []*Syscall { - var metas []*Syscall +func (target *Target) calcResourceCtors(res *ResourceDesc, preciseOnly bool) []ResourceCtor { + var ret []ResourceCtor for _, ctor := range res.Ctors { - if !precise || ctor.Precise { - metas = append(metas, target.Syscalls[ctor.Call]) + if !preciseOnly || ctor.Precise { + ret = append(ret, ctor) } } if res.Kind[0] == timespecRes.Name { if c := target.SyscallMap["clock_gettime"]; c != nil { - metas = append(metas, c) + ret = append(ret, ResourceCtor{c, true}) } } - return metas + return ret } func (target *Target) populateResourceCtors() { @@ -91,10 +91,10 @@ func (target *Target) populateResourceCtors() { } } if preciseOk { - res.Ctors = append(res.Ctors, ResourceCtor{call, true}) + res.Ctors = append(res.Ctors, ResourceCtor{target.Syscalls[call], true}) } if impreciseOk { - res.Ctors = append(res.Ctors, ResourceCtor{call, false}) + res.Ctors = append(res.Ctors, ResourceCtor{target.Syscalls[call], false}) } } } @@ -208,8 +208,8 @@ func (target *Target) TransitivelyEnabledCalls(enabled map[*Syscall]bool) (map[* } if ctors[res.Name] == nil { var names []string - for _, call := range target.calcResourceCtors(res, true) { - names = append(names, call.Name) + for _, ctor := range target.calcResourceCtors(res, true) { + names = append(names, ctor.Call.Name) } ctors[res.Name] = names } |
