Commit Graph

276 Commits

Author SHA1 Message Date
Andrey Konovalov
ea8dc17ee9 executor: fix macros in common.h 2017-12-14 08:54:55 +01:00
Dmitry Vyukov
da131727fb sys/linux: describe PF_KEY 2017-12-11 20:12:35 +01:00
Dmitry Vyukov
4016fc5ad7 prog: fix hints of data args
Hints for data args don't work.
We do all the work, but at the final stage we patch
arg in the _old_ program, not in the _new_ one.
So programs passed to the callback are all the same
and don't contain any mutations.
Tests did not catch this because they work right before that point
(don't test the actual interface function MutateWithHints).

Fix that and add a test that catches this.
2017-12-08 10:45:11 +01:00
Dmitry Vyukov
fadd10ac05 sys/linux: add a simple description for selinux 2017-12-08 10:15:04 +01:00
Dmitry Vyukov
71ac44a0c2 executor: fix build
exitf function was not defined with some combinations of options in csource.
Fix defines and switch exitf back to fail, fail already checks ENOMEM/EAGAIN,
so there is no reason to use exitf in this particular case.
2017-12-06 10:34:58 +01:00
Dmitry Vyukov
64d31856d9 executor: unshare PID namespace even for sandbox=none
Unshare as much as we can for all sandboxing modes.
This fixes "kernel panic: Attempted to kill init!" crashes
under sandbox=none. And should just generally improve
reproducibility, e.g. if we unshare SYSVSEM fuzzer won't
collide with any existing semaphores.
2017-12-05 20:08:06 +01:00
Dmitry Vyukov
c2c4cd4e57 executor: treat fail-nth errors as non-fatal
We see occasional ENOENT/EACCES errors returned.
It seems that fuzzer somehow gets its hands to it.
2017-12-05 20:08:06 +01:00
Dmitry Vyukov
3a80fe350d prog: support bytesizeN for vma
I guess this is currently unused,
but ignoring bytesizeN for vma looks wrong.
If user asks for bytesizeN for vma, divide vma size by N.
2017-11-29 11:12:47 +01:00
Dmitry Vyukov
1808de66ce prog: repair arrays/buffers with incorrect size in Deserialize
For string[N] we successfully deserialize a string of any length.
Similarly for a fixed-size array[T, N] we successfully deserialize
an array of any size.
Such programs later crash in foreachSubargOffset because static size
Type.Size() does not match what we've calculated iterating over fields.
The crash happens only in SerializeForExec in syz-fuzzer,
which is especially bad.
Fix this from both sides:
1. Validate sizes of arrays/buffers in Validate.
2. Repair incorrect sizes in Deserialize.
2017-11-28 19:15:28 +01:00
Dmitry Vyukov
ac93d7e1d8 pkg/compiler: add check that len does not refer to array with varlen elements
This [almost] always means a bug in descriptions.
Fix all bugs identified by the check.
2017-11-28 14:55:21 +01:00
Dmitry Vyukov
afba0b55e6 sys/linux: add binder descriptions 2017-11-27 15:09:30 +01:00
Dmitry Vyukov
deb5f6aea2 sys/linux: assorted improvements to descriptions 2017-11-27 09:09:06 +01:00
Dmitry Vyukov
103a5b3fa4 sys/linux: add files from net dir to list of /proc files 2017-11-27 09:09:05 +01:00
Dmitry Vyukov
502d78153c sys/linux: fix control len in msghdr's
Contol len is in bytes, not array elements.
2017-11-27 09:09:03 +01:00
Dmitry Vyukov
473d90487b sys/linux: improve hash generation for KEYCTL_DH_COMPUTE
KEYCTL_DH_COMPUTE used the old fixed list of algorithm names.
Use the new code for algorithm generation.
+ it needs only SHASH algs, but we passed in all alg names.
Pass only SHASH algs.
2017-11-27 09:09:01 +01:00
Dmitry Vyukov
8257de047b sys/linux: open files from /proc 2017-11-27 09:08:59 +01:00
Dmitry Vyukov
bbe60f6cb6 sys/linux: improve fuse descriptions 2017-11-27 09:08:57 +01:00
Dmitry Vyukov
01b82d46ee executor: use /proc/thread-self/fail-nth instead of /proc/self/task/%d/fail-nth
Makes code slightly simpler.
2017-11-27 09:08:56 +01:00
Dmitry Vyukov
ddf7b3e065 sys/linux: improve AF_ALG alg name generation
There is effectively infinite number of possible crypto
algorithm names due to templates. Plus there is tricky
relation between algorithms and algorithm type names.

This change adds custom mutator for sockaddr_alg struct
to improve variance in generated algorithms.
2017-11-24 13:56:20 +01:00
Dmitry Vyukov
7061d1973b sys/syz-extract: fix mmap on arm
__NR_mmap is missing on arm entirely,
so we disable mmap during generate.
Patch mmap to mmap2 right in syz-extract,
so that mmap is never missing.
2017-11-23 08:51:04 +01:00
Dmitry Vyukov
b3a8d05cdd executor: fixup previous commit 2017-11-22 10:38:32 +01:00
Dmitry Vyukov
ae8da4a43e executor: move arm syscall fixup to syz-extract 2017-11-22 10:34:47 +01:00
Atul Prakash
93f228d8d8 executor: Modified executor_linux.cc to support ARM32 architecture
executor: changed kOutputDataAddr so that it works on 32-bit kernels
executor: simplified ifdefs for arm in executor_linux.cc
executor: removed empty lines that were accidentally added.
2017-11-22 10:16:55 +01:00
Dmitry Vyukov
f07ea3fc22 sys/linux: remove get_kernel_syms, add quotactl syscall
get_kernel_syms does not seem to be present upstream.
Describe an old quotactl syscall.
Also fix umount/umount2 names in kallsyms.
2017-11-20 17:23:24 +01:00
Andrey Konovalov
dd1609f876 executor: proceed even if /dev/net/tun is not available
For some racy bugs syzkaller can generate a C reproducer with tun
enabled, when it's not actuallly required to trigger the bug.
Some kernel developers (that don't have CONFIG_TUN=y on their setups)
complain about such C repros.
When tun is not available, instead of exiting, print a message that tun
initialization failed and proceed.
2017-11-08 17:43:40 +01:00
Tobias Klauser
784eb9c23c sys/freebsd: add POLLINIGNEOF 2017-11-08 19:30:10 +03:00
Eric Biggers
38977f0e6b sys/linux: add definition for LOOP_SET_BLOCK_SIZE
The v4.14 kernel will support a new loop ioctl, LOOP_SET_BLOCK_SIZE.
2017-11-07 12:26:11 +03:00
Eric Biggers
a6b071286e sys/linux: fix wrong ioctl numbers in loop device definitions
Fix a couple apparent copy-and-paste errors:

    - ioctl$LOOP_CHANGE_FD should use LOOP_CHANGE_FD
    - ioctl$LOOP_CTL_REMOVE should use LOOP_CTL_REMOVE
2017-11-07 12:26:11 +03:00
Eric Biggers
7cff33f196 sys/linux: add definition for keyctl_restrict_keyring()
Add a definition for keyctl_restrict_keyring(), which was added in the
v4.12 kernel.
2017-11-03 12:33:25 +03:00
Eric Biggers
d53e548027 sys/linux: add definition for keyctl_dh_compute()
Add a definition for keyctl_dh_compute(), which was added in the v4.7
kernel, then in the v4.12 kernel extended to take in an optional
'keyctl_kdf_params' argument.  (Requires CONFIG_KEY_DH_OPERATIONS=y.)
2017-11-03 12:33:25 +03:00
Eric Biggers
494a18d9f8 sys/linux: use resource subtypes for "user" and "keyring" keys
Many functions in the keys API take in an ID parameter that is expected
to refer to a keyring, not to any key.  Therefore, define a resource
subtype 'keyring' which can be created by add_key("keyring", ...) or by
using one of the special keyring IDs.

Also define a resource subtype 'user_key', since we'll be adding a
definition for KEYCTL_DH_COMPUTE which takes in a struct containing
"user" key IDs.
2017-11-03 12:33:25 +03:00
Eric Biggers
2fb815f286 sys/linux: define all the key types
Add to key.txt all key types that currently might be present in the
kernel.  It was missing a few important ones such as "asymmetric", which
has a significant attack surface since the payloads are run through an
ASN.1 decoder.
2017-11-03 12:33:25 +03:00
Utkarsh Anand
edfd374bd6 Changing the types of members of struct stat
As defined in the header files.
2017-10-30 18:57:38 +01:00
Utkarsh Anand
4b567b4940 Added a few more syscall descriptions, consts
and other related files.
2017-10-30 18:57:38 +01:00
Utkarsh Anand
9b42a968df Add two new syscalls shmctl and msgctl 2017-10-30 18:57:38 +01:00
Utkarsh Anand
d84e0ffaec Fix the SYS_SEMCTL value issue for NetBSD 2017-10-30 18:57:38 +01:00
Dmitry Vyukov
83d9c30252 sys/netbsd: fix mmap signature
mmap syscall has 7 arguments (one unused padding)
2017-10-25 18:36:49 +02:00
Dmitry Vyukov
bc5423304f executor: small fixes for netbsd
RLIMIT_AS auses frequent random aborts on netbsd.
Reason unknown. Disable it for now.

Documentation says that __syscall should be used
for syscalls with 64-bit arguments. On amd64 most
syscalls have 64-bit arguments (incl mmap),
so switch to it.
2017-10-25 18:36:49 +02:00
Dmitry Vyukov
031174c310 executor: fix netbsd syscalls
executor_netbsd.cc was including syscalls_freebsd.h,
which completely messed up syscall numbers and names.
Include the right syscalls header.
2017-10-25 09:45:05 +02:00
Utkarsh Anand
3f955eba7f Lots of changes to sys/netbsd (#397)
* Lots of changes to sys/netbsd:
- Removed a few syscalls that did not have proper constants defined.
- Autogenerated *.const files.
- Removed a few types like uid and gid, that were not available.
- Ran make generate

* Few changes for NetBSD support:
- Added sys/netbsd/init.go
- Added netbsd to sys/sys.go

* Fix order in sys/sys.go

* Update documentation for NetBSD
2017-10-25 09:27:47 +02:00
Dmitry Vyukov
88999972bf executor: fix mkdtemp return value check
mkdtemp return NULL on failure.
2017-10-25 07:44:06 +02:00
Dmitry Vyukov
e729550825 all: basic building on netbsd
This just makes make TARGETOS=netbsd succeed.
We don't yet have prog target for netbsd.
2017-10-23 10:10:05 +02:00
Dmitry Vyukov
b71450d9fb executor: prevent executor from messing with output region
When comparisons are enabled fuzzer somehow manages to discover
the output region and corrupt it. It seems to fetch the address
from some memory operations (mmap/munmap).

Don't leak the output region address.
2017-10-23 09:59:39 +02:00
Dmitry Vyukov
3704c60135 executor: fix build breakages due to doexit
Some standard libraries contain "using ::exit;",
which breaks with the current redefinition of exit.
2017-10-19 11:06:05 +02:00
Dmitry Vyukov
296be8cc8d pkg/ipc: move fallback coverage into executor
It seems to explode linux corpus.
So make it freebsd-specific.
2017-10-18 16:49:25 +02:00
Dmitry Vyukov
f89294761c executor: use forkserver for freebsd
Use forkserver and shmem for freebsd.
This greatly improves speed.
Also introduce fallback coverage signal based
on unique (syscall+errno) pairs.
2017-10-18 12:01:24 +02:00
Willem de Bruijn
6a3e678181 sys/linux: add MSG_ZEROCOPY 2017-10-17 15:26:15 +02:00
Dmitry Vyukov
3d5e81e280 sys/freebsd: more syscall descriptions
This is mostly copied form linux.
We probably need better support for sharing descriptions
between multiple OSes. But there are lots of differences,
so this is not trivial.
2017-10-17 13:50:05 +02:00
Dmitry Vyukov
bb146866c0 executor: improvements for akaros
1. remove workaround for pthread attrs (was fixed in akaros)
2. remove workaround for dup2 (was fixed in akaros)
3. check that we receive a program
4. implement timeout for test processes
2017-10-17 10:57:38 +02:00
Dmitry Vyukov
8793f74c6c sys/fuchsia: more descriptions 2017-10-16 19:23:13 +02:00