aboutsummaryrefslogtreecommitdiffstats
path: root/prog/mutation.go
Commit message (Collapse)AuthorAgeFilesLines
...
* prog: mutate fixed-size strings moreDmitry Vyukov2018-06-121-4/+4
| | | | | Allow removing/inserting ranges of bytes from fixed-size strings, provided we truncate/extend resulting string to keep original size.
* prog: refactor mutateArg from a big huge functionDmitry Vyukov2018-05-071-131/+180
| | | | Update #538
* prog: dedup mutation codeDmitry Vyukov2018-05-071-127/+71
| | | | Update #538
* gometalinter: enable cyclomatic complexity checkingDmitry Vyukov2018-05-041-207/+204
| | | | | | Refactor some functions to be simpler. Update #538
* prog: support big-endian during hints matchingDmitry Vyukov2018-04-011-0/+15
| | | | | | | | | | | | Use big-endian match/replace for both blobs and ints. Sometimes we have unmarked blobs (no little/big-endian info); for ANYBLOBs we intentionally lose all marking; but even for marked ints we may need this too. Consider that kernel code does not convert the data (i.e. not ntohs(pkt->proto) == ETH_P_BATMAN), but instead converts the constant (i.e. pkt->proto == htons(ETH_P_BATMAN)). In such case we will see dynamic operand that does not match what we have in the program.
* prog: fix 32-bit buildDmitry Vyukov2018-03-051-1/+1
| | | | | Currently fails with: prog/mutation.go:442:24: constant 4294967296 overflows int
* pkg/compiler: allow specifying static size for filename'sDmitry Vyukov2018-03-051-1/+1
| | | | Sometimes filenames are embed into structs and need to take fixed space.
* prog: fix address analysisDmitry Vyukov2018-02-261-7/+16
| | | | | | Even during mutation of a call we want to analyze whole program to find all used addresses (rather then stop on the selected call). Also update address during ANY mutation if size has increased.
* prog: add arbitrary mutation of complex structsDmitry Vyukov2018-02-251-125/+198
| | | | | | Squash complex structs into flat byte array and mutate this array with generic blob mutations. This allows to mutate what we currently consider as paddings and add/remove paddings from structs, etc.
* prog: rework address allocationDmitry Vyukov2018-02-191-22/+9
| | | | | | | | | | | | 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.
* prog: fix mutationArgs for special typesDmitry Vyukov2018-02-191-52/+26
| | | | | | | | | | | | There are 2 bugs currently: 1. mutationArgs recurses into special types, even though they must be mutated as the whole only. 2. When mutationArgs is called from Gen.MutateArg, it included the top special type as well, it must not because at this point only the subargs must be mutated. Fix both problems.
* prog: rework foreachArgDmitry Vyukov2018-02-191-34/+28
| | | | | | | | Make Foreach* callback accept the arg and a context struct that can contain lots of aux info. This (1) removes lots of unuser base/parent args, (2) provides foundation for stopping recursion, (3) allows to merge foreachSubargOffset.
* sys/linux: extend netfilter descriptionsDmitry Vyukov2018-01-271-475/+263
|
* prog: remove unused UnionArg.OptionTypeDmitry Vyukov2018-01-271-1/+1
|
* pkg/compiler: allow unions with only 1 fieldDmitry Vyukov2018-01-271-6/+17
| | | | | | | | | | | | | 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.
* pkg/compiler: support non-zero-terminated stringsDmitry Vyukov2018-01-181-1/+1
| | | | Add stringnoz type.
* pkg/compiler: support void typeDmitry Vyukov2018-01-131-1/+2
| | | | | | "void": type with static size 0 mostly useful inside of templates and varlen unions can't be syscall argument
* prog: mutate len argumentsDmitry Vyukov2017-12-311-10/+15
| | | | Fixes #183
* prog: don't serialize output data argsDmitry Vyukov2017-12-171-12/+14
| | | | | | | | Fixes #188 We now will write just ""/1000 to denote a 1000-byte output buffer. Also we now don't store 1000-byte buffer in memory just to denote size. Old format is still parsed.
* prog: append a bunch of bytes during mutationDmitry Vyukov2017-12-081-6/+20
| | | | | | | | | In some cases we need to extend a buffer by a large margin to pass the next if in kernel (a size check). Currently we only append a single byte, so we can never pass the if incrementally (size is always smaller than threshold, so 1-byte larger inputs are not added to corpus).
* prog: export MakeData/UnionArg as we do for other arg typesDmitry Vyukov2017-11-221-1/+1
| | | | Target code can use these to generate special structs.
* syz-fuzzer: don't send/check CallIndex for inputsDmitry Vyukov2017-10-101-1/+1
| | | | | | | | | | | | | | 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.
* prog: remove default target and all global stateDmitry Vyukov2017-09-151-17/+18
| | | | | | 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.
* prog: remove special knowledge about "mmap" syscallDmitry Vyukov2017-09-151-2/+2
| | | | Abstract "mmap" away as it can be called differently on another OS.
* prog, sys: move types to progDmitry Vyukov2017-09-051-9/+16
| | | | | | | | | | | 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
* prog: dot-import sysDmitry Vyukov2017-09-051-39/+39
| | | | In preparation for moving sys types to prog to reduce later diffs.
* sys, pkg/compiler: move padding computation to compilerDmitry Vyukov2017-09-041-7/+5
| | | | This makes types constant during execution, everything is precomputed.
* sys, prog: switch values to to uint64Dmitry Vyukov2017-08-191-27/+26
| | | | | | | | | | We currently use uintptr for all values. This won't work for 32-bit archs. Moreover in some cases we use uintptr but assume that it is always 64-bits (e.g. in encodingexec). Switch everything to uint64. Update #324
* prog: reduce the "uber-mmap" sizeAlexander Potapenko2017-08-081-1/+5
| | | | | | | | 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.
* prog: don't mutate mmap() calls too oftenAlexander Potapenko2017-08-021-0/+5
| | | | | | | Due to https://github.com/google/syzkaller/issues/316 there're too many mmap() calls in the programs, and syzkaller is spending quite a bit of time mutating them. Most of the time changing mmap() calls won't give us new coverage, so let's not do it too often.
* prog: properly remove calls when splicing progsAndrey Konovalov2017-08-011-2/+2
| | | | | | Use removeCall() to update use references. Also add a test and speed up other ones.
* prog: split Arg into smaller structsAndrey Konovalov2017-07-171-93/+130
| | | | | | | | | | | | | | | | | | | | | | 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.
* prog: limit prog size when splicingAndrey Konovalov2017-02-011-190/+194
|
* prog, sys: add csum type, embed checksums for ipv4 packetsAndrey Konovalov2017-01-251-1/+6
| | | | | | | This change adds a `csum[kind, type]` type. The only available kind right now is `ipv4`. Using `csum[ipv4, int16be]` in `ipv4_header` makes syzkaller calculate and embed correct checksums into ipv4 packets.
* prog: validate deserialized programsDmitry Vyukov2017-01-241-2/+4
| | | | | | | The optimization change removed validation too aggressively. We do need program validation during deserialization, because we can get bad programs from corpus or hub. Restore program validation after deserialization.
* prog: add FieldName to TypeAndrey Konovalov2017-01-231-3/+7
| | | | | FieldName() is the name of the struct field or union option with this type. TypeName() is now always the name of the type.
* all: spot optimizationsDmitry Vyukov2017-01-201-330/+332
| | | | | | | | | | | | | A bunch of spot optmizations after cpu/memory profiling: 1. Optimize hot-path coverage comparison in fuzzer. 2. Don't allocate and copy serialized program, serialize directly into shmem. 3. Reduce allocations during parsing of output shmem (encoding/binary sucks). 4. Don't allocate and copy coverage arrays, refer directly to the shmem region (we are not going to mutate them). 5. Don't validate programs outside of tests, validation allocates tons of memory. 6. Replace the choose primitive with simpler switches. Choose allocates fullload of memory (for int, func, and everything the func refers). 7. Other minor optimizations.
* prog: generate larger arraysDmitry Vyukov2017-01-201-1/+1
| | | | | | | | | Currently we generate arrays of size [0,5] with equal probability. Generate [0,10] with bias towards smaller arrays. But 0 has the lowest probability. I've benchmark a slightly different change with max array size of 20, results are somewhat inconclusive: it was better than baseline almost all way, but baseline suddenly caught up at the end. It also considerably reduced executions per second (by ~20%). So increasing array size to 10 should be a win...
* prog: mutate programs more aggressivelyDmitry Vyukov2017-01-201-2/+2
| | | | | | | | | | | Currently we stop mutating with 50% probability. Stop mutating with 33% probability instead. Benchmark shows both coverage increase and corpus reduction: baseline oneof3 diff coverage 65467 65604 137 corpus 35423 35354 -69 exec total 5474879 5023268 -451611
* prog: mutate int argumentsDmitry Vyukov2017-01-201-1/+12
| | | | | | | | | | Mutate int arguments instead of regenerating. Benchmark shows strong increase of coverage: baseline mutateconst diff coverage 65467 65744 +277 corpus 35423 35638 +215 exec total 5474879 5197932 -276947
* prog: mutate sized strings with respect to sizeAndrey Konovalov2017-01-181-2/+9
|
* sys: extend kvm supportDmitry Vyukov2017-01-091-0/+2
| | | | | | 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.
* sys: move sockaddr description to templatesAndrey Konovalov2016-11-291-2/+0
|
* sys: add proc type to denote per proccess integersAndrey Konovalov2016-11-251-2/+2
|
* prog: minimize based on individual argsAndrey Konovalov2016-11-251-7/+116
|
* fuzzer: combine progs from corpusAndrey Konovalov2016-11-251-166/+177
|
* prog: fix checks for max and min len when mutating a bin blobAndrey Konovalov2016-11-221-2/+2
|
* sys: allow to specify buffer size for stringsDmitry Vyukov2016-11-111-5/+1
| | | | | | | | 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.
* sys: add string flagsDmitry Vyukov2016-11-111-5/+7
| | | | | | | | | | 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]]
* sys: replace FileoffType with IntType{Kind: IntFileoff}Dmitry Vyukov2016-11-111-1/+1
| | | | | 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.