1# How syzkaller works 2 3Below is the generic descriptions of how syzkaller works. 4Check [this](linux/internals.md) for Linux kernel specific things. 5 6## Overview 7 8The process structure for the syzkaller system is shown in the following diagram; 9red labels indicate corresponding configuration options. 10 11![Process structure for syzkaller](process_structure.png?raw=true) 12 13The `syz-manager` process starts, monitors and restarts several VM instances, and starts a `syz-fuzzer` process inside of the VMs. 14It is responsible for persistent corpus and crash storage. 15As opposed to `syz-fuzzer` processes, it runs on a host with stable kernel which does not experience white-noise fuzzer load. 16 17The `syz-fuzzer` process runs inside of presumably unstable VMs. 18The `syz-fuzzer` guides fuzzing process itself (input generation, mutation, minimization, etc) and sends inputs that trigger new coverage back to the `syz-manager` process via RPC. 19It also starts transient `syz-executor` processes. 20 21Each `syz-executor` process executes a single input (a sequence of syscalls). 22It accepts the program to execute from the `syz-fuzzer` process and sends results back. 23It is designed to be as simple as possible (to not interfere with fuzzing process), written in C++, compiled as static binary and uses shared memory for communication. 24 25## Syscall descriptions 26 27The `syz-fuzzer` process generates programs to be executed by `syz-executor` based on syscall descriptions described [here](syscall_descriptions.md). 28 29## Crash reports 30 31When `syzkaller` finds a crasher, it saves information about it into `workdir/crashes` directory. 32The directory contains one subdirectory per unique crash type. 33Each subdirectory contains a `description` file with a unique string identifying the crash (intended for bug identification and deduplication); 34and up to 100 `logN` and `reportN` files, one pair per test machine crash: 35``` 36 - crashes/ 37 - 6e512290efa36515a7a27e53623304d20d1c3e 38 - description 39 - log0 40 - report0 41 - log1 42 - report1 43 ... 44 - 77c578906abe311d06227b9dc3bffa4c52676f 45 - description 46 - log0 47 - report0 48 ... 49``` 50 51Descriptions are extracted using a set of [regular expressions](/pkg/report/report.go#L33). 52This set may need to be extended if you are using a different kernel architecture, or are just seeing a previously unseen kernel error messages. 53 54`logN` files contain raw `syzkaller` logs and include kernel console output as well as programs executed before the crash. 55These logs can be fed to `syz-repro` tool for [crash location and minimization](reproducing_crashes.md), 56or to `syz-execprog` tool for [manual localization](executing_syzkaller_programs.md). 57`reportN` files contain post-processed and symbolized kernel crash reports (e.g. a KASAN report). 58Normally you need just 1 pair of these files (i.e. `log0` and `report0`), because they all presumably describe the same kernel bug. 59However, `syzkaller` saves up to 100 of them for the case when the crash is poorly reproducible, or if you just want to look at a set of crash reports to infer some similarities or differences. 60 61There are 3 special types of crashes: 62 - `no output from test machine`: the test machine produces no output whatsoever 63 - `lost connection to test machine`: the ssh connection to the machine was unexpectedly closed 64 - `test machine is not executing programs`: the machine looks alive, but no test programs were executed for long period of time 65 66Most likely you won't see `reportN` files for these crashes (e.g. if there is no output from the test machine, there is nothing to put into report). 67Sometimes these crashes indicate a bug in `syzkaller` itself (especially if you see a Go panic message in the logs). 68However, frequently they mean a kernel lockup or something similarly bad (here are just a few examples of bugs found this way: 69[1](https://groups.google.com/d/msg/syzkaller/zfuHHRXL7Zg/Tc5rK8bdCAAJ), 70[2](https://groups.google.com/d/msg/syzkaller/kY_ml6TCm9A/wDd5fYFXBQAJ), 71[3](https://groups.google.com/d/msg/syzkaller/OM7CXieBCoY/etzvFPX3AQAJ)). 72