aboutsummaryrefslogtreecommitdiffstats
path: root/prog
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-10-05 17:40:16 +0200
committerAleksandr Nogikh <nogikh@google.com>2023-10-06 11:42:31 +0000
commit160f76ea821e29048389ecb03e8961c4e9cdf519 (patch)
treefd38f69adefd6210f56ea30340954d8a4093d248 /prog
parent7e4eb997711a9389137dc3bcaeb000ef1fd669bf (diff)
pkg/compiler: support (in) for union fields
We had a problem -- using inout ANYUNION leads to syzkaller generating copyout instructions for fmt[X, resource] types. Add a validation rule to detect this during tests. Fix this by supporting (in) for union fields. Previously, all union field direction attributes were banned as they were making things more complicated. The (in) attribute is definitely safe and allows for more flexibility.
Diffstat (limited to 'prog')
-rw-r--r--prog/validation.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/prog/validation.go b/prog/validation.go
index 09c3cd64c..a1915f3d0 100644
--- a/prog/validation.go
+++ b/prog/validation.go
@@ -169,6 +169,9 @@ func (arg *ResultArg) validate(ctx *validCtx, dir Dir) error {
if arg.Dir() == DirIn && len(arg.uses) > 0 {
return fmt.Errorf("result arg '%v' is DirIn, but is used %d times", typ.Name(), len(arg.uses))
}
+ if len(arg.uses) > 0 && arg.Size() > 8 {
+ return fmt.Errorf("result arg '%v' is to be copied out, yet it's bigger than int64 (%d > 8)", typ.Name(), arg.Size())
+ }
return nil
}