Commit Graph

1550 Commits

Author SHA1 Message Date
Dmitry Vyukov
a29e1be6ff pkg/compiler: fix alignment calculation bug 2017-09-04 20:54:29 +02:00
Dmitry Vyukov
1c0d4caf7c sys: change BitfieldLast to BitfieldMiddle
That's the condition we always want.
Currently we always check:
t.BitfieldOffset() == 0 || t.BitfieldLast()
now can check just:
!t.BitfieldMiddle()
2017-09-04 20:51:56 +02:00
Dmitry Vyukov
b6e402dd48 sys: remove IntSignalno 2017-09-04 20:25:23 +02:00
Dmitry Vyukov
399addc875 sys, pkg/compiler: move padding computation to compiler
This makes types constant during execution, everything is precomputed.
2017-09-04 20:25:23 +02:00
Dmitry Vyukov
94e151ceb5 pkg/ast: prohibit empty strings
This is currently unsupported and unused.
2017-09-04 20:25:22 +02:00
Dmitry Vyukov
d878c4ff43 sys: minor fixes for statx and sigevent 2017-09-04 20:25:22 +02:00
Dmitry Vyukov
b5c5217623 pkg/ifuzz: use serializer
Simplifies code and reduces size of generated code from 820K to 310K.
2017-09-04 20:25:22 +02:00
Dmitry Vyukov
dbb49d0211 pkg/compiler: prohibit arrays of size 0
This is pointless and the only case that can yield 0 static type size.
2017-09-04 20:25:22 +02:00
Dmitry Vyukov
622a1ffd72 pkg/compiler: prohibit bitfields of size 0
They don't work the way C bitfields work.
So this will lead to confusion at least.
2017-09-04 20:25:22 +02:00
Dmitry Vyukov
291192c61b pkg/compiler: don't allow bitfields in unions, args and anon types 2017-09-04 20:25:22 +02:00
Dmitry Vyukov
e707c97f9a pkg/compiler: move bitfield marking from sys 2017-09-04 20:25:22 +02:00
Dmitry Vyukov
54a92e90e0 pkg/compiler: prohibit bitfields in syscall args 2017-09-04 20:25:22 +02:00
Dmitry Vyukov
740662e03a pkg/compiler: reserve in/out/inout/opt names 2017-09-04 20:25:22 +02:00
Dmitry Vyukov
a5c115a64b prog: move ptrSize const to test
It is used only by a single test. Remove it from non-test code.
2017-09-04 20:25:22 +02:00
Dmitry Vyukov
2cf0659df1 sys: don't assume vma size is 8
Use explicit size for vma.
This is the last use of hardcoded ptrSize in sys package.
2017-09-04 20:25:22 +02:00
Dmitry Vyukov
4ee497d22e pkg/compiler: use correct arch ptr size 2017-09-04 20:25:22 +02:00
Dmitry Vyukov
8c64b078d1 pkg/compiler: detect resources without ctors
Fixes #217
2017-09-04 20:25:22 +02:00
Dmitry Vyukov
b06c1bd324 pkg/compiler: verify validity of len targets
Update #217
2017-09-04 20:25:22 +02:00
Dmitry Vyukov
8094a4202f pkg/compiler: move checking code to a separate file 2017-09-04 20:25:22 +02:00
Dmitry Vyukov
f29b943c0b pkg/compiler: detect recursive struct declarations
Update #217
2017-09-04 20:25:22 +02:00
Dmitry Vyukov
f400a0da0f pkg/ast: fix struct comment parsing 2017-09-04 20:25:03 +02:00
Dmitry Vyukov
a54dce007d sys: allow custom size for PtrType
This is required to support ptr64 type.
2017-09-02 14:08:30 +02:00
Dmitry Vyukov
08c91ab698 sys: support ptr64 type
ptr64 is like ptr, but always takes 8 bytes of space.
Needed for some APIs. Unfortunately, most of these APIs
use buffer type, so we can't use ptr64 immidiately.
2017-09-02 13:44:28 +02:00
Dmitry Vyukov
9c995bedad sys: improve bpf descriptions 2017-09-02 13:38:16 +02:00
Dmitry Vyukov
2c0b7b7ff3 pkg/compiler: restore generation of unsupported syscalls
Unfortunately this is sitll needed, see the added comment.

Update #191
2017-09-02 13:21:47 +02:00
Dmitry Vyukov
a7206b24ca pkg/compiler: check and generate types
Move most of the logic from sysgen to pkg/compiler.

Update #217
2017-09-02 13:06:53 +02:00
Victor Chibotaru
aa51461a34 hints: add some more tests for DataArg 2017-09-01 18:14:53 +02:00
Andrey Konovalov
76bc1b9d35 sys: add AF_PACKET sockets description 2017-09-01 17:17:33 +02:00
Victor Chibotaru
d9a07bf6e9 hints: add new mutations and tests 2017-09-01 17:17:08 +02:00
Andrey Konovalov
70ab363e79 Update linux_kernel_reporting_bugs.md 2017-09-01 13:58:35 +02:00
Andrey Konovalov
83f1ca5484 Update linux_kernel_reporting_bugs.md 2017-09-01 13:55:37 +02:00
Dmitry Vyukov
4ccdd78294 sys: export struct/union attributes
Export struct/union attributes so that they can be filled in
by a different package.
2017-08-31 19:21:52 +02:00
Dmitry Vyukov
5a093b74f6 sys: change proc arguments to the format used by const/flags/len
All other types have optional underlying type as the last argument.
Proc have it as first. This creates very irregular syntax and
complicates parsing. Make type the last argument.

Note: this is a breaking change if you have descriptions on the side.
2017-08-31 14:31:21 +02:00
Thomas Garnier
ed7f95981b Fix reboot support for VM isolated
Do not fail a reboot if the reboot command returns an error. Reduces the
wait time per ssh commands to 30 seconds.

Signed-off-by: Thomas Garnier <thgarnie@google.com>
2017-08-30 19:30:38 +02:00
Victor Chibotaru
49c11eb514 ipc, prog, fuzzer, execprog: add hints generation code
A hint is basically a tuple consisting of a pointer to an argument
in one of the syscalls of a program and a value, which should be
assigned to that argument.

A simplified version of hints workflow looks like this:
    1. Fuzzer launches a program and collects all the comparisons' data
for every syscall in the program.
    2. Next it tries to match the obtained comparison operands' values
vs. the input arguments' values.
    3. For every such match the fuzzer mutates the program by
replacing the pointed argument with the saved value.
    4. If a valid program is obtained, then fuzzer launches it and
checks if new coverage is obtained.

This commit includes:
    1. All the code related to hints generation, parsing and mutations.
    2. Fuzzer functions to launch the process.
    3. Some new stats gathered by fuzzer and manager, related to hints.
    4. An updated version of execprog to test the hints process.
2017-08-30 18:40:14 +02:00
Victor Chibotaru
07c84b670b executor, ipc: modify the IO between KCOV<->executor<->fuzzer
Now executor is able to read comparisons data from KCOV and write them
to fuzzer.
2017-08-30 18:40:14 +02:00
Victor Chibotaru
1336586b42 executor, fuzzer: change the way Syzkaller opens the KCOV device
We have implemented a new version of KCOV, which is able to dump
comparison operands' data, obtained from Clang's instrumentation hooks
__sanitizer_cov_trace_cmp[1248], __sanitizer_cov_trace_const_cmp[1248]
and __sanitizer_cov_trace_switch.

Current KCOV implementation can work in two modes: "Dump only the PCs"
or "Dump only comparisons' data". Mode selection is done by the
following series of calls:

fd = open(KCOV_PATH, ...); // works as previous
ioctl(fd, KCOV_INIT_TRACE, ...); // works as previous
mmap(fd, ...); // works as previous
ioctl(fd, KCOV_ENABLE, mode);
// mode = KCOV_MODE_TRACE_CMP or mode = KCOV_MODE_TRACE_PC

Note that this new interface is backwards compatible, as old KCOV
devices will just return -EINVAL for the last ioctl. This way we can
distinguish if the KCOV device is able to dump the comparisons.

Main changes in this commit:
    1. Fuzzer now checks at startup which type (new/old) of KCOV device
is running.
    2. Executor now receives an additional flag, which indicates if
executor should read the comparisons data from KCOV. The flag works on
per-call basis, so executor can collect PCs or Comps for each
individual syscall.
2017-08-30 18:40:14 +02:00
Dmitry Vyukov
1d0002255d pkg/report: don't confuse "DEBUG:" with "BUG:"
Android sometimes prints "Boot_DEBUG:" during boot,
which we confuse with "BUG:".
2017-08-30 14:16:27 +02:00
Dmitry Vyukov
be2917712f pkg/compiler: actually tolerate unsupported consts
The previous commit removes errors on unsupported structs/resources,
but their usages still error. Fix that.
2017-08-28 19:00:31 +02:00
Dmitry Vyukov
0b652d7278 pkg/compiler: tolerate unsupported consts everywhere
Currently unsupported consts in structs and resources break build.
However, that can well happen for arch-specific devices (e.g. Android).
Make this non-fatal as it used to be.
2017-08-28 16:04:54 +02:00
Dmitry Vyukov
4074aed7c0 pkg/compiler: more static error checking
Update #217
2017-08-27 20:19:41 +02:00
Zubin Mithra
5857966468 docs: fix syz-headerparser documentation
Remove the --device option from the documentation file
docs/hedaerparser_usage.md
2017-08-27 18:17:00 +02:00
Dmitry Vyukov
e2ffb4fc91 pkg/compiler: move more const-processing code to compiler 2017-08-27 15:28:49 +02:00
Dmitry Vyukov
e71c87fbf5 sys/syz-sysgen: remove dead code 2017-08-27 12:04:16 +02:00
Dmitry Vyukov
a3857c4e90 pkg/compiler, sys/syz-sysgen: move const handling to pkg/compiler
Now pkg/compiler deals with consts.
2017-08-27 11:51:40 +02:00
Dmitry Vyukov
9ec49e082f prog: restore missing struct fields
We already do this for syscall arguments.
Helps to save some old programs after description changes.
2017-08-25 21:56:07 +02:00
Dmitry Vyukov
8f38cf7952 sys: improve tun descriptions 2017-08-25 20:44:37 +02:00
Zubin Mithra
c3631fc789 tools: add headerparser as a tool to assist in writing system call descriptions
The tool can be found inside tools/syz-headerparser. Details on how to use
headerparser can be found inside docs/headerparser_usage.md.
2017-08-25 17:23:52 +02:00
Dmitry Vyukov
3f1aca4826 executor: split a too long line 2017-08-24 10:59:27 +02:00
Dmitry Vyukov
f238fbd42d all: support i386 arch
Update #191
2017-08-19 19:17:27 +02:00