aboutsummaryrefslogtreecommitdiffstats
path: root/prog/analysis.go
Commit message (Collapse)AuthorAgeFilesLines
* prog: annotate image assets with fsck logsFlorent Revest2024-12-091-2/+2
| | | | | | | | | | | | | | | | | | Syscall attributes are extended with a fsck command field which lets file system mount definitions specify a fsck-like command to run. This is required because all file systems have a custom fsck command invokation style. When uploading a compressed image asset to the dashboard, syz-manager also runs the fsck command and logs its output over the dashapi. The dashboard logs these fsck logs into the database. This has been requested by fs maintainer Ted Tso who would like to quickly understand whether a filesystem is corrupted or not before looking at a reproducer in more details. Ultimately, this could be used as an early triage sign to determine whether a bug is obviously critical.
* prog: reduce amount of hint replacementsDmitry Vyukov2024-07-021-9/+11
| | | | | | | | | | | | | | | | | | | | Several optimizations to reduce amount of hint replacements: 1. Don't mutate int's that are <= 8 bits. 2. Don't mutate data that is <= 3 bytes. 3. Restrict mutation of len only value >10 and < 1<<20. Values <= 10 we can produce during normal mutation. Values > 1<<20 are presumably not length of something and we have logic to produce various large bogus lengths. 4. Include all small ints <= 16 into specialInts and remove 31, 32, 63 (don't remember where they come from). 5. Don't produce other known flags (and combinations) for flags. And a larger part computes groups of related arguments so that we don't try to produce known ioctl's from other known ioctl's, and similarly for socket/socketpair/setsockopt/etc. See comments in Target.initRelatedFields for details. Update #477
* all: adapt all cover and sig to 64bitJoey Jiao2024-05-271-5/+5
| | | | | | | | | | | | | | | | | | Taken some arm64 devices for example: kaslr_offset is diff at bits 12-40, and kernel modules are loaded at 2GB space, so we have `ffffffd342e10000 T _stext` where uppper 32bit is ffffffd3. However, if we check modules range, the 1st module is loaded at 0xffffffd2eeb2a000, while the last module is loaded at 0xffffffd2f42c4000. We can see the upper 32bits are diff for core kernel and modules. If we use current 32bits for covered PC, we will get wrong module address recovered. So we need to move to 64bit cover and signal: - change cover/sig to 64bit to fit for syz-executor change - remove kernel upper base logic as kernel upper base is not a constant when kaslr enabled for core kernel and modules. - remove unused pcBase
* prog: collect parents during arg traversalAleksandr Nogikh2024-03-211-5/+35
| | | | | This spares the need to construct a parents map for len[A, T] and conditional fields calculations.
* syz-manager: prefer non-ANY progs in corpus minimizationAleksandr Nogikh2024-02-081-0/+9
| | | | | In case of non-squashed programs we can leverage our descriptions in a much better way than just blind mutations of binary blobs.
* prog: optimize foreachArgImpl()Aleksandr Nogikh2024-01-031-5/+7
| | | | | | | | | | | | | | Per profiling, (*GroupArg).Size() calls from this function were one of the hottest paths during the BenchmarkMutate() benchmark. Some of those calls are made only to issue a runtime panic, which we arguably don't need unless we're testing the code. After the changes: │ /tmp/original │ /tmp/new │ │ sec/op │ sec/op vs base │ Mutate-36 221.8µ ± 4% 179.0µ ± 3% -19.31% (p=0.000 n=15)
* pkg/image: make Decompress easier to useDmitry Vyukov2022-12-221-4/+2
| | | | | | | | | | Change DecompressWriter to DecompressCheck: checking validity of the image is the only useful use of DecompressWriter. Change Decompress to MustDecompress which does not return an error. We check validity during program deserialization, so all other uses already panic on errors. Also add dtor return value in preparation for subsequent changes.
* prog: move image extraction from sys/linuxDmitry Vyukov2022-12-221-28/+19
| | | | | | Now that images are not linux-specific, we can move all image-related logic directly into prog package and significantly simplify the logic.
* prog, pkg/compiler: add `BufferCompressed` buffer type & `compressed_image` ↵Hrutvik Kanabar2022-11-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | builtin Create the `BufferCompressed` kind of `BufferType`, which will be used to represent compressed data. Create the corresponding `compressed_image` syzlang builtin, which is backed by `BufferCompressed`. For now, no syscalls use this feature - this will be introduced in future commits. We have to be careful to decompress the data before mutating, and re-compress before storing. We make sure that any deserialised `BufferCompressed` data is valid too. `BufferCompressed` arguments are mutated using a generic heatmap. In future, we could add variants of `BufferCompressed` or populate the `BufferType` sub-kind, using it to choose different kinds of heatmap for different uncompressed data formats. Various operations on compressed data must be forbidden, so we check for `BufferCompressed` in key places. We also have to ensure `compressed_image` can only be used in syscalls that are marked `no_{generate,minimize}`. Therefore, we add a generic compiler check which allows type descriptions to require attributes on the syscalls which use them.
* sys/linux: extract raw images from syz_mount_imageAleksandr Nogikh2022-09-271-0/+38
| | | | | To simplify the extraction code, let's make segments non-overlapping even before execution.
* pkg/compiler: add out_overlay field attributeDmitry Vyukov2022-01-111-3/+10
|
* all: replace collide mode by `async` call propertyAleksandr Nogikh2021-12-101-12/+17
| | | | | | | | | | | | | Replace the currently existing straightforward approach to race triggering (that was almost entirely implemented inside syz-executor) with a more flexible one. The `async` call property instructs syz-executor not to block until the call has completed execution and proceed immediately to the next call. The decision on what calls to mark with `async` is made by syz-fuzzer. Ultimately this should let us implement more intelligent race provoking strategies as well as make more fine-grained reproducers.
* all: refactor fault injection into call propsAleksandr Nogikh2021-09-221-0/+9
| | | | | | | | | | | | Now that call properties mechanism is implemented, we can refactor fault injection. Unfortunately, it is impossible to remove all traces of the previous apprach. In reprolist and while performing syz-ci jobs, syzkaller still needs to parse the old format. Remove the old prog options-based approach whenever possible and replace it with the use of call properties.
* prog: increase max number of syscallsDmitry Vyukov2021-07-221-6/+13
| | | | | | | | | | Currently fallback coverage imposes an implicit 8K limit on the max number of syscalls. 8K is quite close to the current number of syscalls we have on Linux. 1. Bump this limit to 2M. 2. Detect limit violation during startup rather than later, with an obscure error message and only if fallback coverage is used.
* all: fix comments formatDmitry Vyukov2020-07-121-5/+5
| | | | | | | Fix capitalization, dots at the end and two spaces after a period. Update #1876
* prog: speed up foreachArgImplDmitry Vyukov2020-05-181-4/+6
| | | | | Don't generate garbage for ctx. This speeds up mutation tests by 20%.
* prog: introduce Field typeDmitry Vyukov2020-05-021-1/+4
| | | | | | | | | | | | | Remvoe FieldName from Type and add a separate Field type that holds field name. Use Field for struct fields, union options and syscalls arguments, only these really have names. Reduces size of sys/linux/gen/amd64.go from 5665583 to 5201321 (-8.2%). Allows to not create new type for squashed any pointer. But main advantages will follow, e.g. removing StructDesc, using TypeRef in Arg, etc. Update #1580
* prog: remove Dir from TypeDmitry Vyukov2020-05-011-2/+2
| | | | | | | | | | | | | | | | | | Having Dir is Type is handy, but forces us to duplicate lots of types. E.g. if a struct is referenced as both in and out, then we need to have 2 copies and 2 copies of structs/types it includes. If also prevents us from having the struct type as struct identity (because we can have up to 3 of them). Revert to the old way we used to do it: propagate Dir as we walk syscall arguments. This moves lots of dir passing from pkg/compiler to prog package. Now Arg contains the dir, so once we build the tree, we can use dirs as before. Reduces size of sys/linux/gen/amd64.go from 6058336 to 5661150 (-6.6%). Update #1580
* prog: add ignore_return and breaks_returns call attribtuesDmitry Vyukov2020-04-191-6/+1
| | | | | We had these hard-coded for fuchsia and linux accordingly. Replace with call attributes.
* prog: don't add fallback coverage after clone+ptraceDmitry Vyukov2020-01-151-5/+8
| | | | | clone+ptrace combo cause fallback coverage explosion under gvisor. Mechanics of that are unclear, but effect is very clear.
* prog: don't add fallback coverage after prctlDmitry Vyukov2020-01-151-2/+3
| | | | The same reason as with seccomp.
* prog: refactor bitfields representationDmitry Vyukov2019-12-191-5/+3
| | | | | | | | All callers of BitfieldMiddle just want static size (0 for middle). Make it so: Size for middle bitfields just returns 0. Removes lots of if's. Introduce Type.UnitSize, which now holds the underlying type for bitfields. This will be needed to fix #1542 b/c even if UnitSize=4 for last bitfield Size can be anywhere from 0 to 4 (not necessary equal to UnitSize due to overlapping).
* prog: add implementation for resource centricVeronica Radu2019-09-031-3/+5
|
* prog: fix a bunch of bugs in parsingDmitry Vyukov2019-03-291-1/+1
| | | | | | Add fuzzer for Deserialize and fix 5 or so bugs it found. Fixes #1086
* prog: prevent sandbox escaping files from entering s.filesGreg Steuck2018-11-271-1/+1
|
* prog: add concept of "special pointers"Dmitry Vyukov2018-08-301-2/+2
| | | | | | | | | | | | | | | | | Currently we only generate either valid user-space pointers or NULL. Extend NULL to a set of special pointers that we will use in programs. All targets now contain 3 special values: - NULL - 0xfffffffffffffff (invalid kernel pointer) - 0x999999999999999 (non-canonical address) Each target can add additional special pointers on top of this. Also generate NULL/special pointers for non-opt ptr's. This restriction was always too restrictive. We may want to generate them with very low probability, but we do want to generate them. Also change pointers to NULL/special during mutation (but still not in the opposite direction).
* prog: don't add fallback signal after seccompDmitry Vyukov2018-08-191-43/+52
| | | | | seccomp filter can produce arbitrary errno values for subsequent syscalls. Don't trust anything afterwards.
* executor: collect coverage from unfinished syscallsDmitry Vyukov2018-07-291-10/+23
| | | | | | | | Write coverage from unfinished syscalls. Also detect when a syscall was blocked during execution, even if it finished. Helpful for fallback coverage. Fixes #580
* prog: fix and improve fallback coverageDmitry Vyukov2018-06-301-19/+27
| | | | | | | | First we emitted fallbackSignalFlags inside of the loop, while we need to this outside of the loop. Second, make flags signal weaker otherwise we get all 256 signals for open, chmod, etc. Third, simplify and speedup code.
* prog: add stronger fallback signalDmitry Vyukov2018-06-291-0/+105
| | | | | Also mixin resource constructors and some signature of flags values for successful calls into fallback coverage.
* prog: simplify codeDmitry Vyukov2018-05-051-3/+4
| | | | | | Now that we don't have ReturnArg and only ResultArg's refer to other ResultArg's we can remove ArgUser/ArgUsed and devirtualize lots of code.
* pkg/compiler: support non-zero terminated filenamesDmitry Vyukov2018-04-021-0/+7
| | | | | | | | | | | | | | | Now file names become: string[filename] with a possibility of using other string features: stringnoz[filename] string[filename, CONST_SIZE] and filename is left as type alias as it is commonly used: type filename string[filename]
* pkg/compiler: allow specifying static size for filename'sDmitry Vyukov2018-03-051-2/+7
| | | | Sometimes filenames are embed into structs and need to take fixed space.
* prog: fix address analysisDmitry Vyukov2018-02-261-3/+8
| | | | | | 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-2/+2
| | | | | | 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.
* pkg/compiler: fix alignment corner caseDmitry Vyukov2018-02-251-2/+4
| | | | | Fix alignemnt calculation for packed structs with alignment and bitfields. Amusingly this affected only a single real struct -- ipv6_fragment_ext_header.
* prog: rework address allocationDmitry Vyukov2018-02-191-15/+14
| | | | | | | | | | | | 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: combine RequiresBitmasks and RequiresChecksums into RequiredFeaturesDmitry Vyukov2018-02-191-16/+4
|
* prog: merge foreachSubargOffset into foreachArgImplDmitry Vyukov2018-02-191-32/+11
|
* prog: rework foreachArgDmitry Vyukov2018-02-191-34/+40
| | | | | | | | 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-1/+1
|
* prog: don't serialize output data argsDmitry Vyukov2017-12-171-3/+3
| | | | | | | | 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: remove default target and all global stateDmitry Vyukov2017-09-151-3/+5
| | | | | | 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-117/+7
| | | | | | | | | | | 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-26/+26
| | | | In preparation for moving sys types to prog to reduce later diffs.
* sys: change BitfieldLast to BitfieldMiddleDmitry Vyukov2017-09-041-1/+1
| | | | | | | | That's the condition we always want. Currently we always check: t.BitfieldOffset() == 0 || t.BitfieldLast() now can check just: !t.BitfieldMiddle()
* sys, pkg/compiler: move padding computation to compilerDmitry Vyukov2017-09-041-2/+2
| | | | This makes types constant during execution, everything is precomputed.
* sys, prog: switch values to to uint64Dmitry Vyukov2017-08-191-7/+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: split Arg into smaller structsAndrey Konovalov2017-07-171-83/+83
| | | | | | | | | | | | | | | | | | | | | | 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.
* repro: always minimize over EnableTunAndrey Konovalov2017-06-121-12/+12
|