aboutsummaryrefslogtreecommitdiffstats
path: root/prog/minimization.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-12-28 21:31:00 +0100
committerAleksandr Nogikh <nogikh@google.com>2024-02-19 11:54:01 +0000
commit31179bc75602cbe8f0421b44f19ff1b960039644 (patch)
tree9804abe8e2ca0218da0e2c71b61a8b411f26e800 /prog/minimization.go
parented571339c6ff5ed764283737a0aa68451085e84d (diff)
prog: support conditional fields
pkg/compiler restructures conditional fields in structures into unions, so we only have to implement the support for unions. Semantics is as follows: If a union has conditions, syzkaller picks the first field whose condition matches. Since we require the last union field to have no conditions, we can always construct an object. Changes from this commit aim at ensuring that the selected union fields always follow the rule above.
Diffstat (limited to 'prog/minimization.go')
-rw-r--r--prog/minimization.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/prog/minimization.go b/prog/minimization.go
index 0beaef17b..a9864aca2 100644
--- a/prog/minimization.go
+++ b/prog/minimization.go
@@ -278,13 +278,21 @@ func minimizeInt(ctx *minimizeArgsCtx, arg Arg, path string) bool {
}
v0 := a.Val
a.Val = def.Val
+
+ // By mutating an integer, we risk violating conditional fields.
+ // If the fields are patched, the minimization process must be restarted.
+ patched := ctx.call.setDefaultConditions(ctx.p.Target)
if ctx.pred(ctx.p, ctx.callIndex0) {
*ctx.p0 = ctx.p
ctx.triedPaths[path] = true
return true
}
a.Val = v0
- return false
+ if patched {
+ // No sense to return here.
+ ctx.triedPaths[path] = true
+ }
+ return patched
}
func (typ *ResourceType) minimize(ctx *minimizeArgsCtx, arg Arg, path string) bool {