aboutsummaryrefslogtreecommitdiffstats
path: root/prog
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2015-10-16 18:16:10 +0200
committerDmitry Vyukov <dvyukov@google.com>2015-10-16 18:16:10 +0200
commitf8f416fb8f2ce79d0cbf980ee53ddb68fac850ca (patch)
tree16fc267a129cafde8432c62b575a9c4497054e55 /prog
parent587db99baa54c04e23c207aaf6a5d05d0e1bb791 (diff)
preliminary description of kdbus syscalls
Diffstat (limited to 'prog')
-rw-r--r--prog/analysis.go9
-rw-r--r--prog/consts.go101
-rw-r--r--prog/mutation.go5
-rw-r--r--prog/prio.go3
-rw-r--r--prog/prog.go2
-rw-r--r--prog/rand.go18
6 files changed, 134 insertions, 4 deletions
diff --git a/prog/analysis.go b/prog/analysis.go
index 43d0aa076..30c9542da 100644
--- a/prog/analysis.go
+++ b/prog/analysis.go
@@ -205,7 +205,7 @@ func assignTypeAndDir(c *Call) {
}
func sanitizeCall(c *Call) {
- switch c.Meta.Name {
+ switch c.Meta.CallName {
case "mmap":
// Add MAP_FIXED flag, otherwise it produces non-deterministic results.
addr := c.Args[0]
@@ -245,6 +245,13 @@ func sanitizeCall(c *Call) {
if cmd.Val == SYSLOG_ACTION_CONSOLE_OFF || cmd.Val == SYSLOG_ACTION_CONSOLE_ON {
cmd.Val = SYSLOG_ACTION_SIZE_UNREAD
}
+ case "ioctl":
+ cmd := c.Args[1]
+ // Freeze kills machine. Though, it is an interesting functions,
+ // so we need to test it somehow (TODO).
+ if uint32(cmd.Val) == uint32(FIFREEZE) {
+ cmd.Val = FITHAW
+ }
case "exit", "exit_group":
code := c.Args[0]
// These codes are reserved by executor.
diff --git a/prog/consts.go b/prog/consts.go
index 93eb2be63..9df6be072 100644
--- a/prog/consts.go
+++ b/prog/consts.go
@@ -288,6 +288,107 @@ const (
KCMP_SIGHAND = 4
KCMP_SYSVSEM = 6
KCMP_VM = 1
+ KDBUS_ATTACH_ANY = 18446744073709551615
+ KDBUS_ATTACH_AUDIT = 4096
+ KDBUS_ATTACH_AUXGROUPS = 8
+ KDBUS_ATTACH_CAPS = 1024
+ KDBUS_ATTACH_CGROUP = 512
+ KDBUS_ATTACH_CMDLINE = 256
+ KDBUS_ATTACH_CONN_DESCRIPTION = 8192
+ KDBUS_ATTACH_CREDS = 2
+ KDBUS_ATTACH_EXE = 128
+ KDBUS_ATTACH_NAMES = 16
+ KDBUS_ATTACH_PIDS = 4
+ KDBUS_ATTACH_PID_COMM = 64
+ KDBUS_ATTACH_SECLABEL = 2048
+ KDBUS_ATTACH_TID_COMM = 32
+ KDBUS_ATTACH_TIMESTAMP = 1
+ KDBUS_CMD_BUS_CREATOR_INFO = 2147784069
+ KDBUS_CMD_BUS_MAKE = 1074042112
+ KDBUS_CMD_BYEBYE = 1074042242
+ KDBUS_CMD_CONN_INFO = 2147784068
+ KDBUS_CMD_ENDPOINT_MAKE = 1074042128
+ KDBUS_CMD_ENDPOINT_UPDATE = 1074042129
+ KDBUS_CMD_FREE = 1074042243
+ KDBUS_CMD_HELLO = 3221525888
+ KDBUS_CMD_LIST = 2147784070
+ KDBUS_CMD_MATCH_ADD = 1074042288
+ KDBUS_CMD_MATCH_REMOVE = 1074042289
+ KDBUS_CMD_NAME_ACQUIRE = 1074042272
+ KDBUS_CMD_NAME_RELEASE = 1074042273
+ KDBUS_CMD_RECV = 2147784081
+ KDBUS_CMD_SEND = 1074042256
+ KDBUS_CMD_UPDATE = 1074042241
+ KDBUS_HELLO_ACCEPT_FD = 1
+ KDBUS_HELLO_ACTIVATOR = 2
+ KDBUS_HELLO_MONITOR = 8
+ KDBUS_HELLO_POLICY_HOLDER = 4
+ KDBUS_IOCTL_MAGIC = 149
+ KDBUS_ITEM_ATTACH_FLAGS_RECV = 13
+ KDBUS_ITEM_ATTACH_FLAGS_SEND = 12
+ KDBUS_ITEM_AUDIT = 4108
+ KDBUS_ITEM_AUXGROUPS = 4099
+ KDBUS_ITEM_BLOOM_FILTER = 8
+ KDBUS_ITEM_BLOOM_MASK = 9
+ KDBUS_ITEM_BLOOM_PARAMETER = 7
+ KDBUS_ITEM_CANCEL_FD = 6
+ KDBUS_ITEM_CAPS = 4106
+ KDBUS_ITEM_CGROUP = 4105
+ KDBUS_ITEM_CMDLINE = 4104
+ KDBUS_ITEM_CONN_DESCRIPTION = 4109
+ KDBUS_ITEM_CREDS = 4097
+ KDBUS_ITEM_DST_ID = 16
+ KDBUS_ITEM_DST_NAME = 10
+ KDBUS_ITEM_EXE = 4103
+ KDBUS_ITEM_FDS = 5
+ KDBUS_ITEM_ID = 14
+ KDBUS_ITEM_ID_ADD = 32771
+ KDBUS_ITEM_ID_REMOVE = 32772
+ KDBUS_ITEM_MAKE_NAME = 11
+ KDBUS_ITEM_NAME = 15
+ KDBUS_ITEM_NAME_ADD = 32768
+ KDBUS_ITEM_NAME_CHANGE = 32770
+ KDBUS_ITEM_NAME_REMOVE = 32769
+ KDBUS_ITEM_NEGOTIATE = 1
+ KDBUS_ITEM_OWNED_NAME = 4100
+ KDBUS_ITEM_PAYLOAD_MEMFD = 4
+ KDBUS_ITEM_PAYLOAD_OFF = 3
+ KDBUS_ITEM_PAYLOAD_VEC = 2
+ KDBUS_ITEM_PIDS = 4098
+ KDBUS_ITEM_PID_COM = 4102
+ KDBUS_ITEM_POLICY_ACCESS = 8192
+ KDBUS_ITEM_REPLY_DEAD = 32774
+ KDBUS_ITEM_REPLY_TIMEOUT = 32773
+ KDBUS_ITEM_SECLABEL = 4107
+ KDBUS_ITEM_TID_COMM = 4101
+ KDBUS_ITEM_TIMESTAMP = 4096
+ KDBUS_LIST_ACTIVATORS = 4
+ KDBUS_LIST_NAMES = 2
+ KDBUS_LIST_QUEUED = 8
+ KDBUS_LIST_UNIQUE = 1
+ KDBUS_MAKE_ACCESS_GROUP = 1
+ KDBUS_MAKE_ACCESS_WORLD = 2
+ KDBUS_MATCH_REPLACE = 1
+ KDBUS_MSG_EXPECT_REPLY = 1
+ KDBUS_MSG_NO_AUTO_START = 2
+ KDBUS_MSG_SIGNAL = 4
+ KDBUS_NAME_ACQUIRED = 64
+ KDBUS_NAME_ACTIVATOR = 16
+ KDBUS_NAME_ALLOW_REPLACEMENT = 2
+ KDBUS_NAME_IN_QUEUE = 8
+ KDBUS_NAME_PRIMARY = 32
+ KDBUS_NAME_QUEUE = 4
+ KDBUS_NAME_REPLACE_EXISTING = 1
+ KDBUS_POLICY_ACCESS_GROUP = 2
+ KDBUS_POLICY_ACCESS_NULL = 0
+ KDBUS_POLICY_ACCESS_USER = 1
+ KDBUS_POLICY_ACCESS_WORLD = 3
+ KDBUS_POLICY_OWN = 2
+ KDBUS_POLICY_SEE = 0
+ KDBUS_POLICY_TALK = 1
+ KDBUS_RECV_RETURN_DROPPED_MSGS = 2
+ KDBUS_RECV_RETURN_INCOMPLETE_FDS = 1
+ KDBUS_SEND_SYNC_REPLY = 1
KEXEC_ARCH_386 = 196608
KEXEC_ARCH_ARM = 2621440
KEXEC_ARCH_IA_64 = 3276800
diff --git a/prog/mutation.go b/prog/mutation.go
index 022bd513e..fd4cef209 100644
--- a/prog/mutation.go
+++ b/prog/mutation.go
@@ -149,6 +149,8 @@ func (p *Prog) Mutate(rs rand.Source, ncalls int, ct *ChoiceTable) {
}
case sys.LenType:
panic("bad arg returned by mutationArgs: LenType")
+ case sys.ConstType:
+ panic("bad arg returned by mutationArgs: ConstType")
default:
panic(fmt.Sprintf("bad arg returned by mutationArgs: %#v, type=%#v", *arg, arg.Type))
}
@@ -301,6 +303,9 @@ func mutationArgs(c *Call) (args, bases []*Arg, parents []*[]*Arg) {
case sys.LenType:
// Size is updated when the size-of arg change.
return
+ case sys.ConstType:
+ // Well, this is const.
+ return
}
if arg.Dir == DirOut {
return
diff --git a/prog/prio.go b/prog/prio.go
index 91e69d777..ffc4cc3d6 100644
--- a/prog/prio.go
+++ b/prog/prio.go
@@ -208,7 +208,8 @@ func foreachArgType(meta *sys.Call, f func(sys.Type, ArgDir)) {
rec(f, d)
}
case sys.ResourceType, sys.FileoffType, sys.BufferType,
- sys.VmaType, sys.LenType, sys.FlagsType, sys.IntType, sys.FilenameType:
+ sys.VmaType, sys.LenType, sys.FlagsType, sys.ConstType,
+ sys.IntType, sys.FilenameType:
default:
panic("unknown type")
}
diff --git a/prog/prog.go b/prog/prog.go
index 019873d99..615951918 100644
--- a/prog/prog.go
+++ b/prog/prog.go
@@ -61,6 +61,8 @@ func (a *Arg) Size(typ sys.Type) uintptr {
return typ1.TypeSize
case sys.FlagsType:
return typ1.TypeSize
+ case sys.ConstType:
+ return typ1.TypeSize
case sys.FileoffType:
return typ1.TypeSize
case sys.ResourceType:
diff --git a/prog/rand.go b/prog/rand.go
index 0f353ceb3..568df3a30 100644
--- a/prog/rand.go
+++ b/prog/rand.go
@@ -561,7 +561,19 @@ func (r *randGen) generateArgs(s *state, types []sys.Type, dir ArgDir) ([]*Arg,
sizes[typ.Name()] = size
}
}
- // Pass 2: fill in size arguments.
+
+ // Pass 2: calculate size of the whole struct.
+ // Now we know sizes of all non-size arguments and size arguments are const-size.
+ var parentSize uintptr
+ for i, typ := range types {
+ parentSize += args[i].Size(typ)
+ }
+ if sizes["parent"] != nil {
+ panic("parent is reserved len name")
+ }
+ sizes["parent"] = constArg(parentSize)
+
+ // Pass 3: fill in size arguments.
for i, typ := range types {
if a, ok := typ.(sys.LenType); ok {
size := sizes[a.Buf]
@@ -581,7 +593,7 @@ func (r *randGen) generateArg(s *state, typ sys.Type, dir ArgDir, sizes map[stri
// in subsequent calls. For the same reason we do generate pointer/array/struct
// output arguments (their elements can be referenced in subsequent calls).
switch typ.(type) {
- case sys.IntType, sys.FlagsType, sys.FileoffType, sys.ResourceType:
+ case sys.IntType, sys.FlagsType, sys.ConstType, sys.FileoffType, sys.ResourceType:
return constArg(0), nil, nil
}
}
@@ -668,6 +680,8 @@ func (r *randGen) generateArg(s *state, typ sys.Type, dir ArgDir, sizes map[stri
return arg, pageSizeArg(npages, 0), nil
case sys.FlagsType:
return constArg(r.flags(a.Vals)), nil, nil
+ case sys.ConstType:
+ return constArg(a.Val), nil, nil
case sys.IntType:
v := r.randInt()
switch a.Kind {