mirror of
https://github.com/reactos/syzkaller.git
synced 2024-11-23 11:29:46 +00:00
sys: rename Call to Syscall
In preparation for moving sys types to prog to avoid confusion between sys.Call and prog.Call.
This commit is contained in:
parent
c34180fca0
commit
5db39ab953
@ -34,7 +34,7 @@ import (
|
||||
// Prog is description compilation result.
|
||||
type Prog struct {
|
||||
Resources []*sys.ResourceDesc
|
||||
Syscalls []*sys.Call
|
||||
Syscalls []*sys.Syscall
|
||||
StructDescs []*sys.KeyedStruct
|
||||
// Set of unsupported syscalls/flags.
|
||||
Unsupported map[string]bool
|
||||
|
@ -44,8 +44,8 @@ func (comp *compiler) genResource(n *ast.Resource) *sys.ResourceDesc {
|
||||
return res
|
||||
}
|
||||
|
||||
func (comp *compiler) genSyscalls() []*sys.Call {
|
||||
var calls []*sys.Call
|
||||
func (comp *compiler) genSyscalls() []*sys.Syscall {
|
||||
var calls []*sys.Syscall
|
||||
for _, decl := range comp.desc.Nodes {
|
||||
if n, ok := decl.(*ast.Call); ok {
|
||||
calls = append(calls, comp.genSyscall(n))
|
||||
@ -60,12 +60,12 @@ func (comp *compiler) genSyscalls() []*sys.Call {
|
||||
return calls
|
||||
}
|
||||
|
||||
func (comp *compiler) genSyscall(n *ast.Call) *sys.Call {
|
||||
func (comp *compiler) genSyscall(n *ast.Call) *sys.Syscall {
|
||||
var ret sys.Type
|
||||
if n.Ret != nil {
|
||||
ret = comp.genType(n.Ret, "ret", sys.DirOut, true)
|
||||
}
|
||||
return &sys.Call{
|
||||
return &sys.Syscall{
|
||||
Name: n.Name.Name,
|
||||
CallName: n.CallName,
|
||||
NR: n.NR,
|
||||
@ -74,7 +74,7 @@ func (comp *compiler) genSyscall(n *ast.Call) *sys.Call {
|
||||
}
|
||||
}
|
||||
|
||||
func (comp *compiler) genStructDescs(syscalls []*sys.Call) []*sys.KeyedStruct {
|
||||
func (comp *compiler) genStructDescs(syscalls []*sys.Syscall) []*sys.KeyedStruct {
|
||||
// Calculate struct/union/array sizes, add padding to structs and detach
|
||||
// StructDesc's from StructType's. StructType's can be recursive so it's
|
||||
// not possible to write them out inline as other types. To break the
|
||||
|
@ -367,7 +367,7 @@ loop:
|
||||
fmt.Fprintf(w, "\twrite_file(\"/sys/kernel/debug/fail_futex/ignore-private\", \"N\");\n")
|
||||
fmt.Fprintf(w, "\tinject_fault(%v);\n", opts.FaultNth)
|
||||
}
|
||||
meta := sys.Calls[instr]
|
||||
meta := sys.Syscalls[instr]
|
||||
emitCall := true
|
||||
if meta.CallName == "syz_test" {
|
||||
emitCall = false
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
// DetectSupportedSyscalls returns list on supported syscalls on host.
|
||||
func DetectSupportedSyscalls() (map[*sys.Call]bool, error) {
|
||||
func DetectSupportedSyscalls() (map[*sys.Syscall]bool, error) {
|
||||
// There are 3 possible strategies:
|
||||
// 1. Executes all syscalls with presumably invalid arguments and check for ENOSYS.
|
||||
// But not all syscalls are safe to execute. For example, pause will hang,
|
||||
@ -28,8 +28,8 @@ func DetectSupportedSyscalls() (map[*sys.Call]bool, error) {
|
||||
// Requires CONFIG_KALLSYMS. Seems to be the most reliable. That's what we use here.
|
||||
|
||||
kallsyms, _ := ioutil.ReadFile("/proc/kallsyms")
|
||||
supported := make(map[*sys.Call]bool)
|
||||
for _, c := range sys.Calls {
|
||||
supported := make(map[*sys.Syscall]bool)
|
||||
for _, c := range sys.Syscalls {
|
||||
if isSupported(kallsyms, c) {
|
||||
supported[c] = true
|
||||
}
|
||||
@ -37,7 +37,7 @@ func DetectSupportedSyscalls() (map[*sys.Call]bool, error) {
|
||||
return supported, nil
|
||||
}
|
||||
|
||||
func isSupported(kallsyms []byte, c *sys.Call) bool {
|
||||
func isSupported(kallsyms []byte, c *sys.Syscall) bool {
|
||||
if c.NR == ^uint64(0) {
|
||||
return false // don't even have a syscall number
|
||||
}
|
||||
@ -59,7 +59,7 @@ func isSupported(kallsyms []byte, c *sys.Call) bool {
|
||||
return bytes.Index(kallsyms, []byte(" T sys_"+c.CallName+"\n")) != -1
|
||||
}
|
||||
|
||||
func isSupportedSyzkall(c *sys.Call) bool {
|
||||
func isSupportedSyzkall(c *sys.Syscall) bool {
|
||||
switch c.CallName {
|
||||
case "syz_test":
|
||||
return false
|
||||
@ -112,7 +112,7 @@ func isSupportedSyzkall(c *sys.Call) bool {
|
||||
panic("unknown syzkall: " + c.Name)
|
||||
}
|
||||
|
||||
func isSupportedSocket(c *sys.Call) bool {
|
||||
func isSupportedSocket(c *sys.Syscall) bool {
|
||||
af, ok := c.Args[0].(*sys.ConstType)
|
||||
if !ok {
|
||||
println(c.Name)
|
||||
@ -125,7 +125,7 @@ func isSupportedSocket(c *sys.Call) bool {
|
||||
return err != syscall.ENOSYS && err != syscall.EAFNOSUPPORT
|
||||
}
|
||||
|
||||
func isSupportedOpen(c *sys.Call) bool {
|
||||
func isSupportedOpen(c *sys.Syscall) bool {
|
||||
fname, ok := extractStringConst(c.Args[0])
|
||||
if !ok {
|
||||
return true
|
||||
@ -137,7 +137,7 @@ func isSupportedOpen(c *sys.Call) bool {
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func isSupportedOpenAt(c *sys.Call) bool {
|
||||
func isSupportedOpenAt(c *sys.Syscall) bool {
|
||||
fname, ok := extractStringConst(c.Args[1])
|
||||
if !ok {
|
||||
return true
|
||||
|
@ -18,7 +18,7 @@ func TestLog(t *testing.T) {
|
||||
t.Skipf("skipping: %v", err)
|
||||
}
|
||||
t.Logf("unsupported:")
|
||||
for _, c := range sys.Calls {
|
||||
for _, c := range sys.Syscalls {
|
||||
s, ok := supp[c]
|
||||
if ok && !s {
|
||||
t.Fatalf("map contains false value")
|
||||
@ -29,7 +29,7 @@ func TestLog(t *testing.T) {
|
||||
}
|
||||
trans := sys.TransitivelyEnabledCalls(supp)
|
||||
t.Logf("transitively unsupported:")
|
||||
for _, c := range sys.Calls {
|
||||
for _, c := range sys.Syscalls {
|
||||
s, ok := trans[c]
|
||||
if ok && !s {
|
||||
t.Fatalf("map contains false value")
|
||||
@ -58,7 +58,7 @@ func TestSupportedSyscalls(t *testing.T) {
|
||||
"stat",
|
||||
}
|
||||
for _, name := range safe {
|
||||
c := sys.CallMap[name]
|
||||
c := sys.SyscallMap[name]
|
||||
if c == nil {
|
||||
t.Fatalf("can't find syscall '%v'", name)
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ func Deserialize(data []byte) (prog *Prog, err error) {
|
||||
name = p.Ident()
|
||||
|
||||
}
|
||||
meta := sys.CallMap[name]
|
||||
meta := sys.SyscallMap[name]
|
||||
if meta == nil {
|
||||
return nil, fmt.Errorf("unknown syscall %v", name)
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ func TestSerializeForExec(t *testing.T) {
|
||||
argData = uint64(ExecArgData)
|
||||
)
|
||||
callID := func(name string) uint64 {
|
||||
c := sys.CallMap[name]
|
||||
c := sys.SyscallMap[name]
|
||||
if c == nil {
|
||||
t.Fatalf("unknown syscall %v", name)
|
||||
}
|
||||
|
34
prog/prio.go
34
prog/prio.go
@ -39,7 +39,7 @@ func CalculatePriorities(corpus []*Prog) [][]float32 {
|
||||
|
||||
func calcStaticPriorities() [][]float32 {
|
||||
uses := make(map[string]map[int]float32)
|
||||
for _, c := range sys.Calls {
|
||||
for _, c := range sys.Syscalls {
|
||||
noteUsage := func(weight float32, str string, args ...interface{}) {
|
||||
id := fmt.Sprintf(str, args...)
|
||||
if uses[id] == nil {
|
||||
@ -101,9 +101,9 @@ func calcStaticPriorities() [][]float32 {
|
||||
}
|
||||
})
|
||||
}
|
||||
prios := make([][]float32, len(sys.Calls))
|
||||
prios := make([][]float32, len(sys.Syscalls))
|
||||
for i := range prios {
|
||||
prios[i] = make([]float32, len(sys.Calls))
|
||||
prios[i] = make([]float32, len(sys.Syscalls))
|
||||
}
|
||||
for _, calls := range uses {
|
||||
for c0, w0 := range calls {
|
||||
@ -133,9 +133,9 @@ func calcStaticPriorities() [][]float32 {
|
||||
}
|
||||
|
||||
func calcDynamicPrio(corpus []*Prog) [][]float32 {
|
||||
prios := make([][]float32, len(sys.Calls))
|
||||
prios := make([][]float32, len(sys.Syscalls))
|
||||
for i := range prios {
|
||||
prios[i] = make([]float32, len(sys.Calls))
|
||||
prios[i] = make([]float32, len(sys.Syscalls))
|
||||
}
|
||||
for _, p := range corpus {
|
||||
for _, c0 := range p.Calls {
|
||||
@ -196,30 +196,30 @@ func normalizePrio(prios [][]float32) {
|
||||
// based on call-to-call priorities and a set of enabled syscalls.
|
||||
type ChoiceTable struct {
|
||||
run [][]int
|
||||
enabledCalls []*sys.Call
|
||||
enabled map[*sys.Call]bool
|
||||
enabledCalls []*sys.Syscall
|
||||
enabled map[*sys.Syscall]bool
|
||||
}
|
||||
|
||||
func BuildChoiceTable(prios [][]float32, enabled map[*sys.Call]bool) *ChoiceTable {
|
||||
func BuildChoiceTable(prios [][]float32, enabled map[*sys.Syscall]bool) *ChoiceTable {
|
||||
if enabled == nil {
|
||||
enabled = make(map[*sys.Call]bool)
|
||||
for _, c := range sys.Calls {
|
||||
enabled = make(map[*sys.Syscall]bool)
|
||||
for _, c := range sys.Syscalls {
|
||||
enabled[c] = true
|
||||
}
|
||||
}
|
||||
var enabledCalls []*sys.Call
|
||||
var enabledCalls []*sys.Syscall
|
||||
for c := range enabled {
|
||||
enabledCalls = append(enabledCalls, c)
|
||||
}
|
||||
run := make([][]int, len(sys.Calls))
|
||||
run := make([][]int, len(sys.Syscalls))
|
||||
for i := range run {
|
||||
if !enabled[sys.Calls[i]] {
|
||||
if !enabled[sys.Syscalls[i]] {
|
||||
continue
|
||||
}
|
||||
run[i] = make([]int, len(sys.Calls))
|
||||
run[i] = make([]int, len(sys.Syscalls))
|
||||
sum := 0
|
||||
for j := range run[i] {
|
||||
if enabled[sys.Calls[j]] {
|
||||
if enabled[sys.Syscalls[j]] {
|
||||
sum += int(prios[i][j] * 1000)
|
||||
}
|
||||
run[i][j] = sum
|
||||
@ -230,7 +230,7 @@ func BuildChoiceTable(prios [][]float32, enabled map[*sys.Call]bool) *ChoiceTabl
|
||||
|
||||
func (ct *ChoiceTable) Choose(r *rand.Rand, call int) int {
|
||||
if ct == nil {
|
||||
return r.Intn(len(sys.Calls))
|
||||
return r.Intn(len(sys.Syscalls))
|
||||
}
|
||||
if call < 0 {
|
||||
return ct.enabledCalls[r.Intn(len(ct.enabledCalls))].ID
|
||||
@ -242,7 +242,7 @@ func (ct *ChoiceTable) Choose(r *rand.Rand, call int) int {
|
||||
for {
|
||||
x := r.Intn(run[len(run)-1])
|
||||
i := sort.SearchInts(run, x)
|
||||
if !ct.enabled[sys.Calls[i]] {
|
||||
if !ct.enabled[sys.Syscalls[i]] {
|
||||
continue
|
||||
}
|
||||
return i
|
||||
|
@ -14,7 +14,7 @@ type Prog struct {
|
||||
}
|
||||
|
||||
type Call struct {
|
||||
Meta *sys.Call
|
||||
Meta *sys.Syscall
|
||||
Args []Arg
|
||||
Ret Arg
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ func TestGeneration(t *testing.T) {
|
||||
|
||||
func TestDefault(t *testing.T) {
|
||||
initTest(t)
|
||||
for _, meta := range sys.CallMap {
|
||||
for _, meta := range sys.SyscallMap {
|
||||
for _, t := range meta.Args {
|
||||
defaultArg(t)
|
||||
}
|
||||
@ -47,7 +47,7 @@ func TestDefault(t *testing.T) {
|
||||
|
||||
func TestDefaultCallArgs(t *testing.T) {
|
||||
initTest(t)
|
||||
for _, meta := range sys.CallMap {
|
||||
for _, meta := range sys.SyscallMap {
|
||||
// Ensure that we can restore all arguments of all calls.
|
||||
prog := fmt.Sprintf("%v()", meta.Name)
|
||||
p, err := Deserialize([]byte(prog))
|
||||
@ -84,7 +84,7 @@ func TestSerialize(t *testing.T) {
|
||||
|
||||
func TestVmaType(t *testing.T) {
|
||||
rs, iters := initTest(t)
|
||||
meta := sys.CallMap["syz_test$vma0"]
|
||||
meta := sys.SyscallMap["syz_test$vma0"]
|
||||
r := newRand(rs)
|
||||
for i := 0; i < iters; i++ {
|
||||
s := newState(nil)
|
||||
|
12
prog/rand.go
12
prog/rand.go
@ -271,7 +271,7 @@ func (r *randGen) timespec(s *state, typ *sys.StructType, usec bool) (arg Arg, c
|
||||
})
|
||||
default:
|
||||
// few ms ahead for absolute
|
||||
meta := sys.CallMap["clock_gettime"]
|
||||
meta := sys.SyscallMap["clock_gettime"]
|
||||
ptrArgType := meta.Args[1].(*sys.PtrType)
|
||||
argType := ptrArgType.Type.(*sys.StructType)
|
||||
tp := groupArg(argType, []Arg{
|
||||
@ -304,7 +304,7 @@ func (r *randGen) timespec(s *state, typ *sys.StructType, usec bool) (arg Arg, c
|
||||
|
||||
// createMmapCall creates a "normal" mmap call that maps [start, start+npages) page range.
|
||||
func createMmapCall(start, npages uint64) *Call {
|
||||
meta := sys.CallMap["mmap"]
|
||||
meta := sys.SyscallMap["mmap"]
|
||||
mmap := &Call{
|
||||
Meta: meta,
|
||||
Args: []Arg{
|
||||
@ -420,7 +420,7 @@ func (r *randGen) createResource(s *state, res *sys.ResourceType) (arg Arg, call
|
||||
// Find calls that produce the necessary resources.
|
||||
metas0 := sys.ResourceConstructors(kind)
|
||||
// TODO: reduce priority of less specialized ctors.
|
||||
var metas []*sys.Call
|
||||
var metas []*sys.Syscall
|
||||
for _, meta := range metas0 {
|
||||
if s.ct == nil || s.ct.run[meta.ID] == nil {
|
||||
continue
|
||||
@ -543,11 +543,11 @@ func (r *randGen) generateCall(s *state, p *Prog) []*Call {
|
||||
}
|
||||
}
|
||||
}
|
||||
meta := sys.Calls[s.ct.Choose(r.Rand, call)]
|
||||
meta := sys.Syscalls[s.ct.Choose(r.Rand, call)]
|
||||
return r.generateParticularCall(s, meta)
|
||||
}
|
||||
|
||||
func (r *randGen) generateParticularCall(s *state, meta *sys.Call) (calls []*Call) {
|
||||
func (r *randGen) generateParticularCall(s *state, meta *sys.Syscall) (calls []*Call) {
|
||||
c := &Call{
|
||||
Meta: meta,
|
||||
Ret: returnArg(meta.Ret),
|
||||
@ -567,7 +567,7 @@ func GenerateAllSyzProg(rs rand.Source) *Prog {
|
||||
r := newRand(rs)
|
||||
s := newState(nil)
|
||||
handled := make(map[string]bool)
|
||||
for _, meta := range sys.Calls {
|
||||
for _, meta := range sys.Syscalls {
|
||||
if !strings.HasPrefix(meta.CallName, "syz_") || handled[meta.CallName] {
|
||||
continue
|
||||
}
|
||||
|
40
sys/decl.go
40
sys/decl.go
@ -7,7 +7,7 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Call struct {
|
||||
type Syscall struct {
|
||||
ID int
|
||||
NR uint64 // kernel syscall number
|
||||
Name string
|
||||
@ -268,9 +268,9 @@ func (t *UnionType) FieldName() string {
|
||||
}
|
||||
|
||||
var (
|
||||
CallMap = make(map[string]*Call)
|
||||
Resources map[string]*ResourceDesc
|
||||
ctors = make(map[string][]*Call)
|
||||
SyscallMap = make(map[string]*Syscall)
|
||||
Resources map[string]*ResourceDesc
|
||||
ctors = make(map[string][]*Syscall)
|
||||
)
|
||||
|
||||
type StructDesc struct {
|
||||
@ -299,7 +299,7 @@ func initStructFields() {
|
||||
keyedStructs[desc.Key] = desc.Desc
|
||||
}
|
||||
|
||||
for _, c := range Calls {
|
||||
for _, c := range Syscalls {
|
||||
ForeachType(c, func(t Type) {
|
||||
switch s := t.(type) {
|
||||
case *StructType:
|
||||
@ -318,7 +318,7 @@ func initStructFields() {
|
||||
}
|
||||
|
||||
// ResourceConstructors returns a list of calls that can create a resource of the given kind.
|
||||
func ResourceConstructors(name string) []*Call {
|
||||
func ResourceConstructors(name string) []*Syscall {
|
||||
return ctors[name]
|
||||
}
|
||||
|
||||
@ -327,7 +327,7 @@ func initResources() {
|
||||
for _, res := range resourceArray {
|
||||
Resources[res.Name] = res
|
||||
}
|
||||
for _, c := range Calls {
|
||||
for _, c := range Syscalls {
|
||||
ForeachType(c, func(t Type) {
|
||||
if r, ok := t.(*ResourceType); ok {
|
||||
r.Desc = Resources[r.TypeName]
|
||||
@ -339,10 +339,10 @@ func initResources() {
|
||||
}
|
||||
}
|
||||
|
||||
func resourceCtors(kind []string, precise bool) []*Call {
|
||||
func resourceCtors(kind []string, precise bool) []*Syscall {
|
||||
// Find calls that produce the necessary resources.
|
||||
var metas []*Call
|
||||
for _, meta := range Calls {
|
||||
var metas []*Syscall
|
||||
for _, meta := range Syscalls {
|
||||
// Recurse into arguments to see if there is an out/inout arg of necessary type.
|
||||
ok := false
|
||||
ForeachType(meta, func(typ Type) {
|
||||
@ -399,7 +399,7 @@ func isCompatibleResource(dst, src []string, precise bool) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *Call) InputResources() []*ResourceType {
|
||||
func (c *Syscall) InputResources() []*ResourceType {
|
||||
var resources []*ResourceType
|
||||
ForeachType(c, func(typ Type) {
|
||||
switch typ1 := typ.(type) {
|
||||
@ -412,13 +412,13 @@ func (c *Call) InputResources() []*ResourceType {
|
||||
return resources
|
||||
}
|
||||
|
||||
func TransitivelyEnabledCalls(enabled map[*Call]bool) map[*Call]bool {
|
||||
supported := make(map[*Call]bool)
|
||||
func TransitivelyEnabledCalls(enabled map[*Syscall]bool) map[*Syscall]bool {
|
||||
supported := make(map[*Syscall]bool)
|
||||
for c := range enabled {
|
||||
supported[c] = true
|
||||
}
|
||||
inputResources := make(map[*Call][]*ResourceType)
|
||||
ctors := make(map[string][]*Call)
|
||||
inputResources := make(map[*Syscall][]*ResourceType)
|
||||
ctors := make(map[string][]*Syscall)
|
||||
for c := range supported {
|
||||
inputs := c.InputResources()
|
||||
inputResources[c] = inputs
|
||||
@ -431,7 +431,7 @@ func TransitivelyEnabledCalls(enabled map[*Call]bool) map[*Call]bool {
|
||||
}
|
||||
for {
|
||||
n := len(supported)
|
||||
haveGettime := supported[CallMap["clock_gettime"]]
|
||||
haveGettime := supported[SyscallMap["clock_gettime"]]
|
||||
for c := range supported {
|
||||
canCreate := true
|
||||
for _, res := range inputResources[c] {
|
||||
@ -467,7 +467,7 @@ func TransitivelyEnabledCalls(enabled map[*Call]bool) map[*Call]bool {
|
||||
return supported
|
||||
}
|
||||
|
||||
func ForeachType(meta *Call, f func(Type)) {
|
||||
func ForeachType(meta *Syscall, f func(Type)) {
|
||||
seen := make(map[*StructDesc]bool)
|
||||
var rec func(t Type)
|
||||
rec = func(t Type) {
|
||||
@ -512,11 +512,11 @@ func init() {
|
||||
initResources()
|
||||
structDescs = nil
|
||||
|
||||
for _, c := range Calls {
|
||||
if CallMap[c.Name] != nil {
|
||||
for _, c := range Syscalls {
|
||||
if SyscallMap[c.Name] != nil {
|
||||
println(c.Name)
|
||||
panic("duplicate syscall")
|
||||
}
|
||||
CallMap[c.Name] = c
|
||||
SyscallMap[c.Name] = c
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func TestResourceCtors(t *testing.T) {
|
||||
for _, c := range Calls {
|
||||
for _, c := range Syscalls {
|
||||
for _, res := range c.InputResources() {
|
||||
if len(resourceCtors(res.Desc.Kind, true)) == 0 {
|
||||
t.Errorf("call %v requires input resource %v, but there are no calls that can create this resource", c.Name, res.Desc.Name)
|
||||
@ -19,8 +19,8 @@ func TestResourceCtors(t *testing.T) {
|
||||
|
||||
func TestTransitivelyEnabledCalls(t *testing.T) {
|
||||
t.Parallel()
|
||||
calls := make(map[*Call]bool)
|
||||
for _, c := range Calls {
|
||||
calls := make(map[*Syscall]bool)
|
||||
for _, c := range Syscalls {
|
||||
calls[c] = true
|
||||
}
|
||||
if trans := TransitivelyEnabledCalls(calls); len(calls) != len(trans) {
|
||||
@ -31,30 +31,30 @@ func TestTransitivelyEnabledCalls(t *testing.T) {
|
||||
}
|
||||
t.Fatalf("can't create some resource")
|
||||
}
|
||||
delete(calls, CallMap["epoll_create"])
|
||||
delete(calls, SyscallMap["epoll_create"])
|
||||
if trans := TransitivelyEnabledCalls(calls); len(calls) != len(trans) {
|
||||
t.Fatalf("still must be able to create epoll fd with epoll_create1")
|
||||
}
|
||||
delete(calls, CallMap["epoll_create1"])
|
||||
delete(calls, SyscallMap["epoll_create1"])
|
||||
trans := TransitivelyEnabledCalls(calls)
|
||||
if len(calls)-5 != len(trans) ||
|
||||
trans[CallMap["epoll_ctl$EPOLL_CTL_ADD"]] ||
|
||||
trans[CallMap["epoll_ctl$EPOLL_CTL_MOD"]] ||
|
||||
trans[CallMap["epoll_ctl$EPOLL_CTL_DEL"]] ||
|
||||
trans[CallMap["epoll_wait"]] ||
|
||||
trans[CallMap["epoll_pwait"]] {
|
||||
trans[SyscallMap["epoll_ctl$EPOLL_CTL_ADD"]] ||
|
||||
trans[SyscallMap["epoll_ctl$EPOLL_CTL_MOD"]] ||
|
||||
trans[SyscallMap["epoll_ctl$EPOLL_CTL_DEL"]] ||
|
||||
trans[SyscallMap["epoll_wait"]] ||
|
||||
trans[SyscallMap["epoll_pwait"]] {
|
||||
t.Fatalf("epoll fd is not disabled")
|
||||
}
|
||||
}
|
||||
|
||||
func TestClockGettime(t *testing.T) {
|
||||
t.Parallel()
|
||||
calls := make(map[*Call]bool)
|
||||
for _, c := range Calls {
|
||||
calls := make(map[*Syscall]bool)
|
||||
for _, c := range Syscalls {
|
||||
calls[c] = true
|
||||
}
|
||||
// Removal of clock_gettime should disable all calls that accept timespec/timeval.
|
||||
delete(calls, CallMap["clock_gettime"])
|
||||
delete(calls, SyscallMap["clock_gettime"])
|
||||
trans := TransitivelyEnabledCalls(calls)
|
||||
if len(trans)+10 > len(calls) {
|
||||
t.Fatalf("clock_gettime did not disable enough calls: before %v, after %v", len(calls), len(trans))
|
||||
|
@ -5892,7 +5892,7 @@ var structDescs = []*KeyedStruct{
|
||||
}}},
|
||||
}
|
||||
|
||||
var Calls = []*Call{
|
||||
var Syscalls = []*Syscall{
|
||||
{NR: 18446744073709551615, Name: "accept", CallName: "accept", Args: []Type{
|
||||
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock", FldName: "fd", TypeSize: 4}},
|
||||
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "peer", TypeSize: 4, IsOptional: true}, Type: &UnionType{Key: StructKey{Name: "sockaddr_storage", Dir: 1}}},
|
||||
|
@ -5941,7 +5941,7 @@ var structDescs = []*KeyedStruct{
|
||||
}}},
|
||||
}
|
||||
|
||||
var Calls = []*Call{
|
||||
var Syscalls = []*Syscall{
|
||||
{NR: 43, Name: "accept", CallName: "accept", Args: []Type{
|
||||
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock", FldName: "fd", TypeSize: 4}},
|
||||
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "peer", TypeSize: 8, IsOptional: true}, Type: &UnionType{Key: StructKey{Name: "sockaddr_storage", Dir: 1}}},
|
||||
|
@ -5892,7 +5892,7 @@ var structDescs = []*KeyedStruct{
|
||||
}}},
|
||||
}
|
||||
|
||||
var Calls = []*Call{
|
||||
var Syscalls = []*Syscall{
|
||||
{NR: 9437469, Name: "accept", CallName: "accept", Args: []Type{
|
||||
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock", FldName: "fd", TypeSize: 4}},
|
||||
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "peer", TypeSize: 4, IsOptional: true}, Type: &UnionType{Key: StructKey{Name: "sockaddr_storage", Dir: 1}}},
|
||||
|
@ -5941,7 +5941,7 @@ var structDescs = []*KeyedStruct{
|
||||
}}},
|
||||
}
|
||||
|
||||
var Calls = []*Call{
|
||||
var Syscalls = []*Syscall{
|
||||
{NR: 202, Name: "accept", CallName: "accept", Args: []Type{
|
||||
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock", FldName: "fd", TypeSize: 4}},
|
||||
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "peer", TypeSize: 8, IsOptional: true}, Type: &UnionType{Key: StructKey{Name: "sockaddr_storage", Dir: 1}}},
|
||||
|
@ -5941,7 +5941,7 @@ var structDescs = []*KeyedStruct{
|
||||
}}},
|
||||
}
|
||||
|
||||
var Calls = []*Call{
|
||||
var Syscalls = []*Syscall{
|
||||
{NR: 330, Name: "accept", CallName: "accept", Args: []Type{
|
||||
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock", FldName: "fd", TypeSize: 4}},
|
||||
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "peer", TypeSize: 8, IsOptional: true}, Type: &UnionType{Key: StructKey{Name: "sockaddr_storage", Dir: 1}}},
|
||||
|
@ -26,7 +26,7 @@ var archs = []*Arch{
|
||||
{"ppc64le", 8, []string{"__ppc64__", "__PPC64__", "__powerpc64__"}},
|
||||
}
|
||||
|
||||
func generateExecutorSyscalls(arch *Arch, syscalls []*sys.Call) []byte {
|
||||
func generateExecutorSyscalls(arch *Arch, syscalls []*sys.Syscall) []byte {
|
||||
data := ArchData{
|
||||
CARCH: arch.CARCH,
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ func generate(arch string, prog *compiler.Prog, consts map[string]uint64, out io
|
||||
serializer.Write(out, prog.StructDescs)
|
||||
fmt.Fprintf(out, "\n\n")
|
||||
|
||||
fmt.Fprintf(out, "var Calls = ")
|
||||
fmt.Fprintf(out, "var Syscalls = ")
|
||||
serializer.Write(out, prog.Syscalls)
|
||||
fmt.Fprintf(out, "\n\n")
|
||||
|
||||
|
@ -202,10 +202,10 @@ func main() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if _, ok := calls[sys.CallMap["syz_emit_ethernet"]]; ok {
|
||||
if _, ok := calls[sys.SyscallMap["syz_emit_ethernet"]]; ok {
|
||||
config.Flags |= ipc.FlagEnableTun
|
||||
}
|
||||
if _, ok := calls[sys.CallMap["syz_extract_tcp_res"]]; ok {
|
||||
if _, ok := calls[sys.SyscallMap["syz_extract_tcp_res"]]; ok {
|
||||
config.Flags |= ipc.FlagEnableTun
|
||||
}
|
||||
if faultInjectionEnabled {
|
||||
@ -407,18 +407,18 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
func buildCallList(enabledCalls string) map[*sys.Call]bool {
|
||||
calls := make(map[*sys.Call]bool)
|
||||
func buildCallList(enabledCalls string) map[*sys.Syscall]bool {
|
||||
calls := make(map[*sys.Syscall]bool)
|
||||
if enabledCalls != "" {
|
||||
for _, id := range strings.Split(enabledCalls, ",") {
|
||||
n, err := strconv.ParseUint(id, 10, 64)
|
||||
if err != nil || n >= uint64(len(sys.Calls)) {
|
||||
if err != nil || n >= uint64(len(sys.Syscalls)) {
|
||||
panic(fmt.Sprintf("invalid syscall in -calls flag: '%v", id))
|
||||
}
|
||||
calls[sys.Calls[n]] = true
|
||||
calls[sys.Syscalls[n]] = true
|
||||
}
|
||||
} else {
|
||||
for _, c := range sys.Calls {
|
||||
for _, c := range sys.Syscalls {
|
||||
calls[c] = true
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ func (mgr *Manager) httpPrio(w http.ResponseWriter, r *http.Request) {
|
||||
mgr.minimizeCorpus()
|
||||
call := r.FormValue("call")
|
||||
idx := -1
|
||||
for i, c := range sys.Calls {
|
||||
for i, c := range sys.Syscalls {
|
||||
if c.CallName == call {
|
||||
idx = i
|
||||
break
|
||||
@ -209,7 +209,7 @@ func (mgr *Manager) httpPrio(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
data := &UIPrioData{Call: call}
|
||||
for i, p := range mgr.prios[idx] {
|
||||
data.Prios = append(data.Prios, UIPrio{sys.Calls[i].Name, p})
|
||||
data.Prios = append(data.Prios, UIPrio{sys.Syscalls[i].Name, p})
|
||||
}
|
||||
sort.Sort(UIPrioArray(data.Prios))
|
||||
|
||||
|
@ -149,7 +149,7 @@ func load(data []byte, filename string) (*Config, map[int]bool, error) {
|
||||
}
|
||||
|
||||
func parseSyscalls(cfg *Config) (map[int]bool, error) {
|
||||
match := func(call *sys.Call, str string) bool {
|
||||
match := func(call *sys.Syscall, str string) bool {
|
||||
if str == call.CallName || str == call.Name {
|
||||
return true
|
||||
}
|
||||
@ -163,7 +163,7 @@ func parseSyscalls(cfg *Config) (map[int]bool, error) {
|
||||
if len(cfg.Enable_Syscalls) != 0 {
|
||||
for _, c := range cfg.Enable_Syscalls {
|
||||
n := 0
|
||||
for _, call := range sys.Calls {
|
||||
for _, call := range sys.Syscalls {
|
||||
if match(call, c) {
|
||||
syscalls[call.ID] = true
|
||||
n++
|
||||
@ -174,13 +174,13 @@ func parseSyscalls(cfg *Config) (map[int]bool, error) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, call := range sys.Calls {
|
||||
for _, call := range sys.Syscalls {
|
||||
syscalls[call.ID] = true
|
||||
}
|
||||
}
|
||||
for _, c := range cfg.Disable_Syscalls {
|
||||
n := 0
|
||||
for _, call := range sys.Calls {
|
||||
for _, call := range sys.Syscalls {
|
||||
if match(call, c) {
|
||||
delete(syscalls, call.ID)
|
||||
n++
|
||||
@ -191,7 +191,7 @@ func parseSyscalls(cfg *Config) (map[int]bool, error) {
|
||||
}
|
||||
}
|
||||
// mmap is used to allocate memory.
|
||||
syscalls[sys.CallMap["mmap"].ID] = true
|
||||
syscalls[sys.SyscallMap["mmap"].ID] = true
|
||||
|
||||
return syscalls, nil
|
||||
}
|
||||
|
@ -129,16 +129,16 @@ func readCorpus() []*prog.Prog {
|
||||
return progs
|
||||
}
|
||||
|
||||
func buildCallList() map[*sys.Call]bool {
|
||||
func buildCallList() map[*sys.Syscall]bool {
|
||||
calls, err := host.DetectSupportedSyscalls()
|
||||
if err != nil {
|
||||
Logf(0, "failed to detect host supported syscalls: %v", err)
|
||||
calls = make(map[*sys.Call]bool)
|
||||
for _, c := range sys.Calls {
|
||||
calls = make(map[*sys.Syscall]bool)
|
||||
for _, c := range sys.Syscalls {
|
||||
calls[c] = true
|
||||
}
|
||||
}
|
||||
for _, c := range sys.Calls {
|
||||
for _, c := range sys.Syscalls {
|
||||
if !calls[c] {
|
||||
Logf(0, "disabling unsupported syscall: %v", c.Name)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user