Commit Graph

26 Commits

Author SHA1 Message Date
Dmitry Vyukov
75a7c5e2d1 prog: rework address allocation
1. mmap all memory always, without explicit mmap calls in the program.
This makes lots of things much easier and removes lots of code.
Makes mmap not a special syscall and allows to fuzz without mmap enabled.

2. Change address assignment algorithm.
Current algorithm allocates unmapped addresses too frequently
and allows collisions between arguments of a single syscall.
The new algorithm analyzes actual allocations in the program
and places new arguments at unused locations.
2018-02-19 21:48:20 +01:00
Dmitry Vyukov
76ab9250a7 prog: move Minimize tests to an own file 2018-02-19 21:48:20 +01:00
Dmitry Vyukov
dd768bf1c6 prog: reorder Minimize arguments
Make the predicate the last argument.
It's more common and convenient (arguments are not separated by multiple lines).
2018-02-19 21:48:20 +01:00
Dmitry Vyukov
d973f28294 prog: don't serialize default arguments
This reduces size of a corpus in half.
We store corpus on manager and on hub,
so this will reduce their memory consumption.
But also makes large programs more readable.
2018-02-01 15:20:12 +01:00
Dmitry Vyukov
e8b4970547 pkg/compiler: allow unions with only 1 field
Unions with only 1 field are not actually unions,
and can always be replaced with the option type.
However, they are still useful when there will be
more options in future but currently only 1 is described.
Alternatives are:
 - not using union (but then all existing programs will be
   broken when union is finally introduced)
 - adding a fake field (ugly and reduces fuzzer efficiency)

Allow unions with only 1 field.
2018-01-27 17:08:43 +01:00
Dmitry Vyukov
a8927abe6c prog: support opt for proc types 2018-01-06 17:40:49 +01:00
Dmitry Vyukov
8a67aa70b0 prog: add test for len mutation
Test we actually can get an unnatural len value.
2018-01-06 17:40:43 +01:00
Dmitry Vyukov
286edfb78e prog: fix TestMutateTable
Now works fast enough even for short mode.

Fixes #208
2017-12-17 11:39:14 +01:00
Dmitry Vyukov
2b4927e6ce prog: add benchmark for Mutate 2017-12-17 11:39:14 +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
354c324465 syz-fuzzer: don't send/check CallIndex for inputs
The call index check episodically fails:

2017/10/02 22:07:32 bad call index 1, calls 1, program:

under unknown circumstances. I've looked at the code again
and don't see where/how we can mess CallIndex.
Added a new test for minimization that especially checks resulting
CallIndex.
It would be good to understand what happens, but we don't have
any reproducers. CallIndex is actually unused at this point.
Manager only needs call name. So remove CallIndex entirely.
2017-10-10 10:41:27 +02:00
Dmitry Vyukov
52a33fd516 prog: remove default target and all global state
Now each prog function accepts the desired target explicitly.
No global, implicit state involved.
This is much cleaner and allows cross-OS/arch testing, etc.
2017-09-15 16:02:37 +02:00
Dmitry Vyukov
ffe7e17368 prog, sys: move types to prog
Large overhaul moves syscalls and arg types from sys to prog.
Sys package now depends on prog and contains only generated
descriptions of syscalls.
Introduce prog.Target type that encapsulates all targer properties,
like syscall list, ptr/page size, etc. Also moves OS-dependent pieces
like mmap call generation from prog to sys.

Update #191
2017-09-05 15:52:42 +02:00
Alexander Potapenko
d8b0de2df3 prog: reduce the "uber-mmap" size
During minimization we create a single memory mapping that contains all
the smaller mmap() ranges, so that other mmap() calls can be dropped.
This "uber-mmap" used to start at 0x7f0000000000 regardless of where the
smaller mappings were located. Change its starting address to the
beginning of the first small mmap() range.
2017-08-08 17:57:01 +02:00
Andrey Konovalov
493773c70d prog: properly remove calls when splicing progs
Use removeCall() to update use references.

Also add a test and speed up other ones.
2017-08-01 15:57:03 +02:00
Andrey Konovalov
cfc46d9d0b prog: split Arg into smaller structs
Right now Arg is a huge struct (160 bytes), which has many different fields
used for different arg kinds. Since most of the args we see in a typical
corpus are ArgConst, this results in a significant memory overuse.

This change:
- makes Arg an interface instead of a struct
- adds a SomethingArg struct for each arg kind we have
- converts all *Arg pointers into just Arg, since interface variable by
  itself contains a pointer to the actual data
- removes ArgPageSize, now ConstArg is used instead
- consolidates correspondence between arg kinds and types, see comments
  before each SomethingArg struct definition
- now LenType args that denote the length of VmaType args are serialized as
  "0x1000" instead of "(0x1000)"; to preserve backwards compatibility
  syzkaller is able to parse the old format for now
- multiple small changes all over to make the above work

After this change syzkaller uses twice less memory after deserializing a
typical corpus.
2017-07-17 14:34:09 +02:00
Andrey Konovalov
96ee88d82d prog: fix buffer type with value 0x0 in tests 2017-05-26 16:35:11 +02:00
Andrey Konovalov
fa9c44b568 prog: minimize based on individual args 2016-11-25 17:22:42 +01:00
Andrey Konovalov
a5df734b8d fuzzer: combine progs from corpus 2016-11-25 09:58:17 +01:00
Andrey Konovalov
55cd443931 Fix validate, detect nil non-optional pointer 2016-10-11 20:54:28 +02:00
Andrey Konovalov
78f79fee93 Refactor & improve len type handling 2016-10-11 20:09:19 +02:00
Dmitry Vyukov
afb08bdd3c prog: fix serialized program in a test
Also test at least deserialization of these programs in short mode.
2016-10-07 13:43:43 +02:00
Dmitry Vyukov
4eb9d403e8 prog: implement mutation of union args 2015-12-31 16:03:01 +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
28571fdc32 prog: glue mmap's together during minimization 2015-12-23 13:47:45 +01:00
Dmitry Vyukov
874c5754bb initial commit 2015-10-12 10:16:57 +02:00