Commit Graph

87 Commits

Author SHA1 Message Date
Andrey Konovalov
b323c5aaa9 prog: add FieldName to Type
FieldName() is the name of the struct field or union option with this type.
TypeName() is now always the name of the type.
2017-01-23 18:13:06 +01:00
Andrey Konovalov
243c4bf89c prog: fix bytesizeN for nonarray fields 2017-01-19 20:46:26 +01:00
Andrey Konovalov
872e436375 prog, sys: fix padding varlen structs 2017-01-19 15:22:04 +01:00
Dmitry Vyukov
19a21e6795 sys: don't imply pointer indirection for filename type
Change all 'filename' to 'ptr[in, filename]' and don't imply pointer indirection for filename type.
This is necessary because in some bases we want to embed filename directly into a struct (e.g. unix sock addr).
Similar change was already done for string type for similar reasons. Generally, we want to imply as less as possible.

NOTE: IF YOU HAVE PRIVATE DESCRIPTIONS, YOU NEED TO DO THE SAME REPLACEMENT.
2017-01-18 19:58:12 +01:00
Andrey Konovalov
109c58ef68 prog: mutate sized strings with respect to size 2017-01-18 19:16:07 +01:00
Andrey Konovalov
9d963ea599 prog: fix Size() for unions args 2017-01-18 13:07:53 +01:00
Andrey Konovalov
54e0cede43 prog: add bitfields to templates
Now it's possible to use `int32:18` to denote a bitfield of size 18 as a struct field.

This fixes #72.
2017-01-17 13:25:33 +01:00
Dmitry Vyukov
ff8c0180ab sys, executor: more kvm improvements
1. Basic support for arm64 kvm testing.
2. Fix compiler warnings in x86 kvm code.
3. Test all pseudo syz calls in csource.
4. Fix handling of real code in x86.
2017-01-12 11:57:17 +01:00
Dmitry Vyukov
bbd4840872 sys: extend kvm support
Add new pseudo syscall syz_kvm_setup_cpu that setups VCPU into
interesting states for execution. KVM is too difficult to setup otherwise.
Lots of improvements possible, but this is a starting point.
2017-01-09 20:28:10 +01:00
Dmitry Vyukov
94b38efc1d sys: allow to specify number of pages for vma type
Allows to write vma[4] or vma[5-10] to specify desired number of pages.
2017-01-09 20:20:48 +01:00
Andrey Konovalov
df98b6bde5 prog: add bytesizeN types 2016-12-20 18:12:07 +01:00
Dmitry Vyukov
99b473cb4b executor: use different address for our network card
IP addresses like 192.168.0.1/192.168.1.1 are often used for routing between VM and the host.
Offset our IP addresses to start from 192.168.218.0 to reduce potential conflicts.
2016-12-06 20:09:17 +01:00
Andrey Konovalov
c5707f5e57 executor: emit ethernet traffic 2016-11-29 17:39:38 +01:00
Andrey Konovalov
2429a7b034 sys: move sockaddr description to templates 2016-11-29 16:39:02 +01:00
Andrey Konovalov
86917cc3a7 sys: move in_addr description to templates 2016-11-29 16:39:02 +01:00
Dmitry Vyukov
5d94283455 ipc, prog, sysgen: format code 2016-11-25 20:17:32 +01:00
Andrey Konovalov
253a40f30d sys: add proc type to denote per proccess integers 2016-11-25 17:51:41 +01:00
Dmitry Vyukov
13f99c534b sysgen: reduce compilation time and memory consumption
Go compiler does not seem to like long generated functions.
This change reduces compilation time of sys_arch.go,
reduces compiler memory consumption and fixes compiler crash on arm64.
2016-11-15 12:10:10 +01: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
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
Andrey Konovalov
7686d19aff Add big-endian ints 2016-10-13 15:38:53 +02:00
Andrey Konovalov
6dd64c7a70 Assign to structs correct type name 2016-10-11 14:24:49 +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
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
Andrey Konovalov
f41935d53f Allow range sized arrays 2016-09-19 16:16:24 +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
Dmitry Vyukov
97bd0d9fdb sysgen: check that structs are not passed as syscall arguments 2016-09-02 18:37:27 +02:00
Dmitry Vyukov
58b2762fed sysgen: sort resources by name to avoid unnecessary diffs 2016-08-28 15:04:37 +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
c152f0e981 sysgen: fix generation of flags
On arm64 all constants are removed for some ptrace flags.
Use plain int in such cases.
2016-08-26 14: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
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
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
Baozeng Ding
1dbfdcf757 sys: support kcm and netrom 2016-06-13 09:28:38 +08:00
David Drysdale
423e5ccacb Add debug logging to sysgen/ code 2016-03-10 15:26:45 +00:00
David Drysdale
064e1a65a5 sysgen: Cope with non-inline kernel build
When regenerating system call tables, cope with a local kernel tree where
the kernel has been built into a separate directory (with `make O=...`) rather
than inline.

So:
 - LINUX makefile var / -linux command line option give location of source tree
 - LINUXBLD makefile var / -linuxbld command line option gives location of
   built kernel
2016-03-10 14:33:32 +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
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
e5afa2fd73 sysgen: fix build for CONFIG_DEBUG_VIRTUAL=y 2016-01-26 16:52:57 +01:00
Dmitry Vyukov
22fda1e655 Merge pull request #14 from sploving/master
sys: support /dev/random and /dev/net/tun
2016-01-26 16:42:23 +01:00
Baozeng Ding
4bbea2300f sys: support /dev/random and /dev/net/tun 2016-01-26 00:45:49 +08:00
Dmitry Vyukov
b5f1cae8dd sysgen: use __ppc64__ || __PPC64__ || __powerpc64__ to detect ppc
Different macros are defined by different compilers...
2016-01-25 11:06:30 +01:00