From a7ce77be27d8e3728b97122a005bc5b23298cfc3 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Tue, 24 Aug 2021 15:50:19 +0000 Subject: all: introduce call properties Call properties let us specify how each individual call within a program must be executed. So far the only way to enforce extra rules was to pass extra program-level properties (e.g. that is how fault injection was done). However, it entangles the logic and not flexible enough. Implement an ability to pass properties along with each individual call. --- sys/syz-sysgen/sysgen.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'sys') diff --git a/sys/syz-sysgen/sysgen.go b/sys/syz-sysgen/sysgen.go index 35bea4f3b..fbff765cc 100644 --- a/sys/syz-sysgen/sysgen.go +++ b/sys/syz-sysgen/sysgen.go @@ -51,9 +51,15 @@ type OSData struct { Archs []ArchData } +type CallPropDescription struct { + Type string + Name string +} + type ExecutorData struct { OSes []OSData CallAttrs []string + CallProps []CallPropDescription } var srcDir = flag.String("src", "", "path to root of syzkaller source dir") @@ -181,6 +187,14 @@ func main() { data.CallAttrs = append(data.CallAttrs, prog.CppName(attrs.Field(i).Name)) } + defaultProps := prog.DefaultCallProps() + defaultProps.ForeachProp(func(name, _ string, value reflect.Value) { + data.CallProps = append(data.CallProps, CallPropDescription{ + Type: value.Kind().String(), + Name: prog.CppName(name), + }) + }) + writeExecutorSyscalls(data) } @@ -326,6 +340,15 @@ var defsTempl = template.Must(template.New("").Parse(`// AUTOGENERATED FILE struct call_attrs_t { {{range $attr := $.CallAttrs}} uint64_t {{$attr}};{{end}} }; + +struct call_props_t { {{range $attr := $.CallProps}} + {{$attr.Type}} {{$attr.Name}};{{end}} +}; + +#define read_call_props_t(var, reader) { \{{range $attr := $.CallProps}} + (var).{{$attr.Name}} = ({{$attr.Type}})(reader); \{{end}} +} + {{range $os := $.OSes}} #if GOOS_{{$os.GOOS}} #define GOOS "{{$os.GOOS}}" -- cgit mrf-deployment