aboutsummaryrefslogtreecommitdiffstats
path: root/prog/encoding.go
Commit message (Collapse)AuthorAgeFilesLines
* prog: detect argument type mismatch during deserializationDmitry Vyukov2017-12-311-0/+5
|
* prog: minor refactoring around argumentsDmitry Vyukov2017-12-171-2/+2
| | | | | | Introduce isUsed(arg) helper, use it in several places. Move method definitions closer to their types. Simplify presence check for ArgUsed.Used() in several places.
* prog: don't serialize output data argsDmitry Vyukov2017-12-171-10/+30
| | | | | | | | 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: introduce more readable format for data argsDmitry Vyukov2017-12-171-14/+141
| | | | | | | | | | | | | | | | | | | | | Fixes #460 File names, crypto algorithm names, etc in programs are completely unreadable: bind$alg(r0, &(0x7f0000408000)={0x26, "6861736800000000000000000000", 0x0, 0x0, "6d6435000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000 00000000000"}, 0x58) Introduce another format for printable strings. New args are denoted by '' ("" for old args). New format is enabled for printable chars, \x00 and \t, \r, \n. Example: `serialize(&(0x7f0000408000)={"6861736800000000000000000000", "4849000000"})`, vs: `serialize(&(0x7f0000408000)={'hash\x00', 'HI\x00'})`,
* prog: repair arrays/buffers with incorrect size in DeserializeDmitry Vyukov2017-11-281-0/+12
| | | | | | | | | | | | | 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.
* prog: export MakeData/UnionArg as we do for other arg typesDmitry Vyukov2017-11-221-2/+2
| | | | Target code can use these to generate special structs.
* prog: remove default target and all global stateDmitry Vyukov2017-09-151-10/+12
| | | | | | 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, sys: move types to progDmitry Vyukov2017-09-051-13/+11
| | | | | | | | | | | 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-20/+20
| | | | In preparation for moving sys types to prog to reduce later diffs.
* sys: rename Call to SyscallDmitry Vyukov2017-09-051-1/+1
| | | | | In preparation for moving sys types to prog to avoid confusion between sys.Call and prog.Call.
* sys, pkg/compiler: move padding computation to compilerDmitry Vyukov2017-09-041-1/+1
| | | | This makes types constant during execution, everything is precomputed.
* prog: restore missing struct fieldsDmitry Vyukov2017-08-251-2/+2
| | | | | We already do this for syscall arguments. Helps to save some old programs after description changes.
* sys, prog: switch values to to uint64Dmitry Vyukov2017-08-191-8/+7
| | | | | | | | | | 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: generate missing syscall args when decodingAndrey Konovalov2017-08-011-0/+5
| | | | | | | | After a change in syscall description the number of syscall arguments might change and some of the programs in corpus get invalidated. This change makes syzkaller to generate missing arguments when decoding a program as an attempt to fix and keep more programs from corpus.
* prog: return error instead of panic when parsingAndrey Konovalov2017-07-241-1/+1
|
* prog: split Arg into smaller structsAndrey Konovalov2017-07-171-52/+80
| | | | | | | | | | | | | | | | | | | | | | 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: validate deserialized programsDmitry Vyukov2017-01-241-2/+7
| | | | | | | 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-2/+2
| | | | | 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-5/+3
| | | | | | | | | | | | | 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: increase line length limit when deserializing programsDmitry Vyukov2017-01-091-1/+7
| | | | | | | | bufio.Scanner has a default limit of 4K per line, if a program contains longer line, it fails. Extend the limit to 64K. Also check scanning errors. Turns out even scanning of bytes.Buffer can fail due to the line limit.
* syz-hub: add programDmitry Vyukov2016-11-171-0/+33
| | | | syz-hub is used to exchange programs between syz-managers.
* prog: assign types to args during constructionDmitry Vyukov2016-11-111-15/+15
| | | | | | Eliminate assignTypeAndDir function and instead assign types to all args during construction. This will allow considerable simplifation of assignSizes.
* sys: always use pointers to typesDmitry Vyukov2016-11-111-4/+4
| | | | | | | | 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.
* Refactor & improve len type handlingAndrey Konovalov2016-10-111-10/+25
|
* sys: support recursive structsDmitry Vyukov2016-09-051-3/+3
| | | | | | A struct can have a pointer to itself directly or indirectly. Currently it leads to inifinite recursion when generating descriptions. Fix this.
* sys: add union typeDmitry Vyukov2015-12-291-0/+26
|
* prog: don't serialize paddingsDmitry Vyukov2015-12-281-13/+77
| | | | | | Paddings in serialized programs are unnecessary and confusing. Instead restore them implicitly. Also use [,,,,] for arrays.
* sys: automatically add padding to structsDmitry Vyukov2015-12-171-1/+3
|
* prog: allow comments in programsDmitry Vyukov2015-11-201-1/+1
| | | | Useful for manual program minimization.
* initial commitDmitry Vyukov2015-10-121-0/+411