diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-04-16 17:38:36 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-04-19 10:26:57 +0200 |
| commit | 90d17ab8980674c6a59f47a062adccb37f99b88a (patch) | |
| tree | 63c96e2abc46f63d9092f07b16c8e70458b11444 /prog | |
| parent | 0781895e0f8359843b9215ac6ad16925a46b2703 (diff) | |
prog: introduce call attributes
Add common infrastructure for syscall attributes.
Add few attributes we want, but they are not implemented for now
(don't affect behavior, this will follow).
Diffstat (limited to 'prog')
| -rw-r--r-- | prog/rand.go | 3 | ||||
| -rw-r--r-- | prog/types.go | 32 |
2 files changed, 35 insertions, 0 deletions
diff --git a/prog/rand.go b/prog/rand.go index c761d0b40..b350e31c0 100644 --- a/prog/rand.go +++ b/prog/rand.go @@ -555,6 +555,9 @@ func (r *randGen) generateCall(s *state, p *Prog, insertionPoint int) []*Call { } func (r *randGen) generateParticularCall(s *state, meta *Syscall) (calls []*Call) { + if meta.Attrs.Disabled { + panic(fmt.Sprintf("generating disabled call %v", meta.Name)) + } c := &Call{ Meta: meta, Ret: MakeReturnArg(meta.Ret), diff --git a/prog/types.go b/prog/types.go index 7b4ec53e8..9257fae37 100644 --- a/prog/types.go +++ b/prog/types.go @@ -6,6 +6,7 @@ package prog import ( "fmt" "strings" + "unicode" ) type Syscall struct { @@ -16,11 +17,29 @@ type Syscall struct { MissingArgs int // number of trailing args that should be zero-filled Args []Type Ret Type + Attrs SyscallAttrs inputResources []*ResourceDesc outputResources []*ResourceDesc } +// SyscallAttrs represents call attributes in syzlang. +// +// This structure is the source of truth for the all other parts of the system. +// pkg/compiler uses this structure to parse descriptions. +// syz-sysgen uses this structure to generate code for executor. +// +// Only bool's and uint64's are currently supported. +type SyscallAttrs struct { + // Never enable this system call in fuzzing. + Disabled bool + // Additional execution timeout (in ms) for the call on top of some default value. + Timeout uint64 + // Additional execution timeout (in ms) for the whole program if it contains this call. + // If a program contains several such calls, the max value is used. + ProgTimeout uint64 +} + // MaxArgs is maximum number of syscall arguments. // Executor also knows about this value. const MaxArgs = 9 @@ -653,3 +672,16 @@ func ForeachType(meta *Syscall, f func(Type)) { rec(meta.Ret) } } + +// CppName transforms PascalStyleNames to cpp_style_names. +func CppName(name string) string { + var res []byte + for i := range name { + c := rune(name[i]) + if unicode.IsUpper(c) && i != 0 && !unicode.IsUpper(rune(name[i-1])) { + res = append(res, '_') + } + res = append(res, byte(unicode.ToLower(c))) + } + return string(res) +} |
