Commit Graph

327 Commits

Author SHA1 Message Date
Andrey Konovalov
253a40f30d sys: add proc type to denote per proccess integers 2016-11-25 17:51:41 +01:00
Dmitry Vyukov
4de5c7eb20 prog: fix pointer direction validation
Currently the added test description leads to crashes:

--- FAIL: TestMinimizeRandom (0.12s)
	prog_test.go:20: seed=1480014002950172453
panic: syscall syz_test$regression0: pointer arg 'f0' has output direction [recovered]
	panic: syscall syz_test$regression0: pointer arg 'f0' has output direction

The description is OK. Fix that.
2016-11-24 20:20:05 +01:00
Dmitry Vyukov
50c9bc2948 sys: disable /dev/console
/dev/console known to cause problems on at least two different kernels.
It can turn off all output or produce massive amounts of garbage on console.
Disable it for now.
2016-11-18 19:05:33 +01:00
Dmitry Vyukov
447e172205 sys: improve perf_event_open description 2016-11-16 13:19:33 +01:00
Dmitry Vyukov
112238483a sys: initialize kvm guest memory
Need much more complex support,
but this is a starting point.
2016-11-14 06:55:10 +01:00
Dmitry Vyukov
d0146e983c sys: improve kvm descriptions 2016-11-12 12:40:54 -08:00
Dmitry Vyukov
ac5fed321d sys: better description for eventfd 2016-11-12 11:58:13 -08:00
Dmitry Vyukov
edc6728a2a sys: improve bpf descriptions 2016-11-11 15:03:30 -08:00
Dmitry Vyukov
3a65453870 sys: allow to specify buffer size for strings
This allows to write:
  string[salg_type, 14]
which will give a string buffer of size 14 regardless of actual string size.

Convert salg_type/salg_name to this.
2016-11-11 14:34:41 -08:00
Dmitry Vyukov
588a542b2a sys: add string flags
Allow to define string flags in txt descriptions. E.g.:

  filesystem = "ext2", "ext3", "ext4"

and then use it in string type:

  ptr[in, string[filesystem]]
2016-11-11 14:33:37 -08:00
Dmitry Vyukov
5ed6283b64 sys: don't imply pointer indirection for string arguments
In preparation for extending string functionality
and to make it less magical.
2016-11-11 14:33:15 -08:00
Dmitry Vyukov
f085c198ba sys: replace FileoffType with IntType{Kind: IntFileoff}
FileoffType is effectively an int, no need for a separate type.
Also remove fd option from fileoff as it is unused and use story is unclear.
2016-11-11 14:32:38 -08:00
Dmitry Vyukov
8b731ed4b7 sys: replace FilenameType with BufferType{Kind: BufferFilename}
FilenameType is effectively a buffer, there is no need for a separate type.
2016-11-11 14:32:19 -08:00
Dmitry Vyukov
b40d502736 prog: remote Type argument from Arg.Size/Value
They are not necessary since we now always have types attached to args.
Also remove sys.Type.InnerType as it is not necessary now as well.
2016-11-11 14:31:55 -08:00
Dmitry Vyukov
d3a93e8370 sys: attach Dir to all types
Dir is a static info, so we don't need to compute, propagate and
attach it in prog whenever we generate/change programs.
Attach Dir to all types.
2016-11-11 14:27:54 -08:00
Dmitry Vyukov
959ec07095 sys: always use pointers to types
Currently we store most types by value in sys.Type.
This is somewhat counter-intuitive for C++ programmers,
because one can't easily update the type object.
Store pointers to type objects for all types.
It also makes it easier to update types, e.g. adding paddings.
2016-11-11 14:25:13 -08:00
Dmitry Vyukov
4ae183a783 sys: fix StrConstType size and alignment
The current code is probably a leftover from times when
StrConstType itself implied an indirection (it was a pointer to the string).
Now strconst it is lowered to PtrType[StrConstType],
so its size is len of the string and align is 1.

It is not possible to test it now, as it is always used with indirection,
so static size and align do not affect struct layout.
2016-10-18 21:17:29 +02:00
Andrey Konovalov
e4edb0e20b Add tests for big-endian ints 2016-10-13 15:38:58 +02:00
Andrey Konovalov
7686d19aff Add big-endian ints 2016-10-13 15:38:53 +02:00
Andrey Konovalov
2392578fe9 Update sys/README.md 2016-10-11 20:09:29 +02:00
Andrey Konovalov
d7ba1b8f86 Add assign len fields tests 2016-10-11 20:09:25 +02:00
Andrey Konovalov
78f79fee93 Refactor & improve len type handling 2016-10-11 20:09:19 +02:00
Andrey Konovalov
7311e016f3 Rename duplicate fields in templates 2016-10-10 16:13:26 +02:00
Andrey Konovalov
f2d77726c8 Add exec serialize tests for array[int8] 2016-10-04 18:50:02 +02:00
Andrey Konovalov
c99cbdbe58 Emit BufferBlob for array[int8] 2016-10-04 18:49:57 +02:00
Dmitry Vyukov
3ca39dfc4d sys: add padding to structs again
Struct padding was accidentially lost after:
852e3d2eae
Restore it. Now with tests.

Fixes #78
2016-09-29 13:30:08 +02:00
Dmitry Vyukov
bf21057e7c prog: add a test for union layout
This is a retrospect tests for the union bug fixed in:
91eb1b922f
2016-09-29 12:21:26 +02:00
Dmitry Vyukov
11a690d275 sys, prog: add tests for description parsing and serialization
Add sys/test.txt file with description of syscalls for tests.
These descriptions can be used to ensure that we can parse everything we clain we can parse.
Use these descriptions to write several tests for exec serialization
(one test shows that alignment handling is currently incorrect).
These test descriptions can also be used to write e.g. mutation tests.

Update #78
2016-09-28 20:06:42 +02:00
Dmitry Vyukov
b1a9164b86 sys: refine KCM ioctl type 2016-09-28 17:22:56 +02:00
Dmitry Vyukov
d18f8aa366 Merge pull request #73 from xairy/ranged_arrays
Allow range sized arrays
2016-09-19 19:42:00 +02:00
Andrey Konovalov
551c2aa7e4 sys: delete Size() and Align() methods for struct and union 2016-09-19 16:43:44 +02:00
Andrey Konovalov
f41935d53f Allow range sized arrays 2016-09-19 16:16:24 +02:00
Dmitry Vyukov
255fdfb938 sys: resolve the TODO with recursive structs
syskaller now supports them
@ramosian-glider
2016-09-05 13:00:06 +02:00
Dmitry Vyukov
136250619e sys: resolve some old TODOs in descriptions 2016-09-05 12:49:47 +02:00
Dmitry Vyukov
852e3d2eae sys: support recursive structs
A struct can have a pointer to itself directly or indirectly.
Currently it leads to inifinite recursion when generating descriptions.
Fix this.
2016-09-05 12:49:47 +02:00
Alexander Potapenko
fb6f59caba Add the /dev/tlk_device (Open Trusted Execution device driver) description 2016-09-05 11:00:05 +02:00
Dmitry Vyukov
fcf6db1996 sys: remove autogenerated files
They were necessary when they were the source of constant values
extracted from kernel code (hard to do). Now constants are checked-in
separately, and these large files can be easily regenerated with 'make generate'.
Now they are only a source of large uninteresting diffs in commits.
Remove them.
2016-09-02 18:57:29 +02:00
Dmitry Vyukov
e9d2eec662 sys: fix incorrect argument type introduced in 7690667267 2016-08-28 20:17:50 +02:00
Dmitry Vyukov
58b2762fed sysgen: sort resources by name to avoid unnecessary diffs 2016-08-28 15:04:37 +02:00
Dmitry Vyukov
9b91ede860 executor, csource: share some common code between executor and csource 2016-08-28 14:59:48 +02:00
Dmitry Vyukov
7690667267 sys: specify resources in text descriptions
Currently to add a new resource one needs to modify multiple source files,
which complicates descirption of new system calls.
Move resource descriptions from source code to text desciptions.
2016-08-27 18:27:50 +02:00
Dmitry Vyukov
a71989d077 sys: fix links and formatting in README.md 2016-08-26 15:36:17 +02:00
Dmitry Vyukov
78553d2247 sys: update README to describe the new 2-step generation process 2016-08-26 15:20:36 +02:00
Dmitry Vyukov
d78bc6e66c sys: fix skipping of syscalls with unknown constants
Still need to generate description for such syscalls so that
they at least can be parsed, and so that Go and C entries match.
2016-08-26 12:51:25 +02:00
Dmitry Vyukov
0d0fbbe73f overhaul syscall description generation process
This splits generation process into two phases:
1. Extract values of constants from linux kernel sources.
2. Generate Go code.

Constant values are checked in.
The advantage is that the second phase is now completely independent
from linux source files, kernel version, presence of headers for
particular drivers, etc. This allows to change what Go code we generate
any time without access to all kernel headers (which in future won't be
limited to only upstream headers).

Constant extraction process does require proper kernel sources,
but this can be done only once by the person who added the driver
and has access to the required sources. Then the constant values
are checked in for others to use.
Consant extraction process is per-file/per-arch. That is,
if I am adding a driver that is not present upstream and that
works only on a single arch, I will check in constants only for
that driver and for that arch.
2016-08-26 07:09:25 +02:00
Dmitry Vyukov
1e22c7aefa sys: use ranged int in few syscalls so that it is tested 2016-08-13 09:16:28 -07:00
Dmitry Vyukov
7e6402c003 sys: change int range to use ':' instead of '~'
We can't use '-' because '-' can denote negative numbers.
Colon is used is several range notations (e.g. Go, Mathlab, Excel).
2016-08-13 09:10:12 -07:00
Dmitry Vyukov
3b9fe41fe3 reformat sources 2016-08-13 09:02:44 -07:00
Dmitry Vyukov
ae9d77a96b sys: regenerate syscall descriptions with latest linux sources 2016-08-13 09:01:42 -07:00
Baozeng Ding
7db2edcb33 sys/sysgen/prog: support ranged int
This commit supports inclusive ranged int, like foo int32[-10~10], which will
generate random integer between -10 and 10. In future we will support more than
one range, like int32[0, -5~10, 50, 100~200]
2016-08-10 13:43:15 +08:00
Dmitry Vyukov
32061a606f executor: add support for 386 arch (COMPAT syscalls)
This is not fully working now: e.g. prog and sys packages assume
that pointer size is 8. But at least it compiles and works.
2016-06-30 20:11:04 +02:00
Dmitry Vyukov
1816c21f2b sys: fix kvm_pit_channel_state.count_load_time type 2016-06-21 20:12:26 +02:00
Dmitry Vyukov
da7529ea51 sys: update generated files 2016-06-13 12:50:32 +02:00
Baozeng Ding
1dbfdcf757 sys: support kcm and netrom 2016-06-13 09:28:38 +08:00
Baozeng Ding
09a6b9531f sys: support getsockopt for sctp 2016-06-10 21:47:33 +08:00
Lorenzo Stoakes
a420b770de sys: add removed defines to fix generate in linux-next
This patch redefines constants that were removed in patches between 4.4 and
linux-next, so both linux-next and mainline work with make generate.
2016-03-11 21:54:52 +00:00
Lorenzo Stoakes
61f5f870ac sys: add missing include
IOPRIO_WHO_PGRP, IOPRIO_WHO_USER, and IOPRIO_WHO_PROCESS are defined in
linux/ioprio.h.
2016-03-08 09:56:08 +00:00
Dmitry Vyukov
7fe9da14de sys: fix build with Go1.4
It does not know about arm64 arch.

Fixes #17
2016-02-15 21:33:00 +01:00
Dmitry Vyukov
b21bafb97d sys: fix /dev/snd/pcm description 2016-02-05 22:12:15 +01:00
Dmitry Vyukov
ba993a55b9 sys: terminate string constants with \x00
C expects string constants to be zero terminated.
It worked to some degree probably because most memory is zeros in executor.
2016-02-05 22:12:15 +01:00
Dmitry Vyukov
0f6ca04596 sys: slighly improve diagnostics for incorrect syscall descriptions 2016-01-28 08:20:59 +01:00
Dmitry Vyukov
5dfefdb158 sys: fix write$tun description
Also remove \r in files.
2016-01-26 17:48:13 +01:00
Dmitry Vyukov
66b440bd17 sys: regenerate after tun/random support 2016-01-26 16:53:23 +01:00
Dmitry Vyukov
efe43dc071 sys: open a bunch of new devices 2016-01-26 16:48:37 +01:00
Baozeng Ding
4bbea2300f sys: support /dev/random and /dev/net/tun 2016-01-26 00:45:49 +08:00
Dmitry Vyukov
0d4b201150 sys: allow to open all devices as stopgap 2016-01-24 20:28:38 +01:00
Dmitry Vyukov
f5311fac95 sys: add basic netlink support for real 2016-01-23 21:27:57 +01:00
Dmitry Vyukov
7e28ae6b3b sys: fix arg type 2016-01-23 13:17:06 +01:00
Dmitry Vyukov
790b11ac9b sys: add basic netlink support 2016-01-23 13:10:35 +01:00
Dmitry Vyukov
8bdf62d1b7 sys: implement array byte size arguments 2016-01-23 00:37:08 +01:00
Dmitry Vyukov
b06604d52a sys: remove resolved TODO 2016-01-23 00:06:30 +01:00
Dmitry Vyukov
81438c4ddd sys: use kernel headers instead of host headers
This solves several problems:
 - host usually have outdates headers, so previously we need to define missing consts
 - host may not have some headers at all
 - generation depends on linux distribution and version
 - some of the consts cannot be defined at all (e.g. ioctls that use struct arguments)
2016-01-22 21:18:33 +01:00
Dmitry Vyukov
9c277c7974 sys: describe more dri syscalls 2016-01-16 00:23:47 +01:00
Dmitry Vyukov
81dc7f8dc8 sys: support /dev/input/event ioctls 2016-01-15 20:16:02 +01:00
Dmitry Vyukov
b217dcb509 sys: support /dev/input/{mouse,mice,event} 2016-01-13 20:45:35 +01:00
Dmitry Vyukov
a92b8c76c3 sys: introduce a generic syz_open_dev helper syscall 2016-01-13 18:57:12 +01:00
Dmitry Vyukov
91630fe39d sys: add support for /dev/snd/control 2016-01-13 16:54:29 +01:00
Dmitry Vyukov
bca57831a5 sys: add support for /dev/snd/timer 2016-01-12 20:14:56 +01:00
Dmitry Vyukov
15128d47bd sys: support /dev/snd/seq 2016-01-11 22:26:09 +01:00
Dmitry Vyukov
bb47c6540d sys: add kvm support 2016-01-08 22:41:36 +01:00
Dmitry Vyukov
96e9dbd874 sys: update grammar description 2015-12-31 16:03:01 +01:00
Dmitry Vyukov
aa82db2290 sys: implement sockaddr_storage 2015-12-31 16:03:01 +01:00
Dmitry Vyukov
92bcba4b0b sys: implement fixed-size arrays 2015-12-30 19:43:15 +01:00
Dmitry Vyukov
ddcd0929e3 prog: give more priority to generic socket syscalls 2015-12-30 18:24:26 +01:00
Dmitry Vyukov
777beb5076 sys: add packed/aligned struct attributes 2015-12-30 13:53:09 +01:00
Dmitry Vyukov
28b3d1e1ab sys: add sctp support 2015-12-30 13:04:00 +01:00
Dmitry Vyukov
e6529b30ec sys: add union type 2015-12-29 15:00:57 +01:00
Dmitry Vyukov
b17c5726f6 sys: support for AF_UNIX sockets 2015-12-28 19:11:03 +01:00
Dmitry Vyukov
bd768c8f40 sys: move more subsystems into separate files 2015-12-28 16:11:15 +01:00
Dmitry Vyukov
eef80b3d76 sys: split syscall description into several files 2015-12-28 15:53:32 +01:00
Dmitry Vyukov
4eda9b07e5 prog: don't serialize paddings
Paddings in serialized programs are unnecessary and confusing.
Instead restore them implicitly.
Also use [,,,,] for arrays.
2015-12-28 12:58:10 +01:00
Dmitry Vyukov
4d3db6d4c8 host: detect unsupported syscalls
Also detect transitively unsupported syscalls,
that is, syscalls for which all syscalls that can create
input arguments are disabled.
2015-12-27 12:20:00 +01:00
Dmitry Vyukov
524a2ae38f sysgen: fix syscall number assignment for syzkalls 2015-12-24 21:27:21 +01:00
Dmitry Vyukov
af4e0c0b7a sysgen: pull in syscall numbers from kernel headers
Syscall numbers for different architectures are now pulled in
from kernel headers. This solves 2 problems:
 - we don't need to hardcode numbers for new syscalls (that don't present in typical distro headers)
 - we have correct number for different archs (previously hardcoded numbers were for x86_64)
This also makes syscall numbers available for Go code, which can be useful.
2015-12-24 19:13:08 +01:00
Dmitry Vyukov
5c0a662198 sys: fix padding insertion
Padding was not inserted into indirect structs.
2015-12-23 19:10:41 +01:00
Dmitry Vyukov
47e55508d0 sys: sort new syscalls 2015-12-23 19:09:24 +01:00
Dmitry Vyukov
071ad4e91f sys: fix AT_FDCWD handling
AT_FDCWD is not a flag, it is an fd.
2015-12-23 13:36:13 +01:00
Dmitry Vyukov
06e6726537 sys: fix typos 2015-12-17 14:38:46 +01:00
Dmitry Vyukov
72742865dd sys: add bluetooth support 2015-12-17 14:38:46 +01:00
Dmitry Vyukov
6f71e5dce1 sys: add PF_NFC support 2015-12-17 14:38:46 +01:00
Dmitry Vyukov
6922b20d36 sys: workaround Go compiler bug
see http://golang.org/issue/13579
2015-12-17 14:38:46 +01:00
Dmitry Vyukov
9980a72713 sys: automatically add padding to structs 2015-12-17 14:38:46 +01:00
Dmitry Vyukov
c4b809f85f sys: add support for PF_ALG 2015-12-17 14:38:46 +01:00
Dmitry Vyukov
cf2089138e support kmemleak
If you set "leak":true in manager config, it will do leak checking.
It's quite slow, though. Also there seems to be false positives
and/or non-reproducible leaks.
2015-12-03 20:38:33 +01:00
Dmitry Vyukov
b7800fb0a2 sys: describe some additional syscalls 2015-12-03 20:03:50 +01:00
Dmitry Vyukov
a63ac433ab sys: add userfaultfd syscall 2015-11-30 16:31:45 +01:00
Dmitry Vyukov
d45c28cdcf sys: fix description of perf attribute 2015-11-29 16:36:30 +01:00
Dmitry Vyukov
81de33fab1 add perf ioctl's 2015-11-29 13:19:10 +01:00
Dmitry Vyukov
b94cd3038a add support for perf events 2015-11-29 12:19:58 +01:00
Dmitry Vyukov
9d1895c1bd add support for bpf syscall 2015-11-29 11:05:08 +01:00
Dmitry Vyukov
83ec77a110 sys: start collecting packages with required headers 2015-11-29 08:39:57 +01:00
Dmitry Vyukov
7677b07a71 mark kdbus fd's as so 2015-11-19 17:27:23 +01:00
Dmitry Vyukov
4784f4f6f5 add fuse support 2015-11-19 17:16:36 +01:00
Dmitry Vyukov
495113290e basic support for dri/drm drivers 2015-11-18 21:22:17 +01:00
Dmitry Vyukov
6892001bbc add tty-related ioctl's 2015-11-16 19:14:05 +01:00
Dmitry Vyukov
1334407ba4 reduce number of indirections in syscall description by using consts 2015-11-06 21:51:19 +01:00
Dmitry Vyukov
53d18c7596 describe keyctl syscall 2015-11-06 21:51:19 +01:00
Dmitry Vyukov
f8f416fb8f preliminary description of kdbus syscalls 2015-10-16 18:16:10 +02:00
Dmitry Vyukov
7f031e85ef add common ioctl commands 2015-10-15 20:07:28 +02:00
Dmitry Vyukov
8d0aa4f7c0 improvements for kdbus 2015-10-15 17:59:01 +02:00
Dmitry Vyukov
c9b915608d initial support for call priorities 2015-10-14 16:55:09 +02:00
Dmitry Vyukov
9f8e5038cf teach prog about in6_addr 2015-10-13 21:24:22 +02:00
Dmitry Vyukov
2c6f92b113 describe setsockopt... more or less 2015-10-13 20:13:40 +02:00
Dmitry Vyukov
9706b099e7 describe sysfs and ioprio syscalls 2015-10-13 20:13:40 +02:00
Dmitry Vyukov
8b78c985ab support iocb pointers as resources 2015-10-13 20:13:40 +02:00
Dmitry Vyukov
f6b48b1774 describe arguments of prctl syscall 2015-10-13 20:13:40 +02:00
Dmitry Vyukov
874c5754bb initial commit 2015-10-12 10:16:57 +02:00