github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/pkg/mgrconfig/config.go (about) 1 // Copyright 2015 syzkaller project authors. All rights reserved. 2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 package mgrconfig 5 6 import ( 7 "encoding/json" 8 9 "github.com/google/syzkaller/pkg/asset" 10 ) 11 12 type Config struct { 13 // Instance name (used for identification and as GCE instance prefix). 14 Name string `json:"name"` 15 // Target OS/arch, e.g. "linux/arm64" or "linux/amd64/386" (amd64 OS with 386 test process). 16 RawTarget string `json:"target"` 17 // URL that will display information about the running syz-manager process (e.g. "localhost:50000"). 18 HTTP string `json:"http"` 19 // TCP address to serve RPC for fuzzer processes (optional). 20 RPC string `json:"rpc,omitempty"` 21 // Location of a working directory for the syz-manager process. Outputs here include: 22 // - <workdir>/crashes/*: crash output files 23 // - <workdir>/corpus.db: corpus with interesting programs 24 // - <workdir>/instance-x: per VM instance temporary files 25 Workdir string `json:"workdir"` 26 // Refers to a directory. Optional. 27 // Each VM will get a recursive copy of the files that are present in workdir_template. 28 // VM config can then use these private copies as needed. The copy directory 29 // can be referenced with "{{TEMPLATE}}" string. This is different from using 30 // the files directly in that each instance will get own clean, private, 31 // scratch copy of the files. Currently supported only for qemu_args argument 32 // of qemu VM type. Use example: 33 // Create a template dir with necessary files: 34 // $ mkdir /mytemplatedir 35 // $ truncate -s 64K /mytemplatedir/fd 36 // Then specify the dir in the manager config: 37 // "workdir_template": "/mytemplatedir" 38 // Then use these files in VM config: 39 // "qemu_args": "-fda {{TEMPLATE}}/fd" 40 WorkdirTemplate string `json:"workdir_template,omitempty"` 41 // Directory with kernel object files (e.g. `vmlinux` for linux) 42 // (used for report symbolization, coverage reports and in tree modules finding, optional). 43 KernelObj string `json:"kernel_obj"` 44 // Directories with out-of-tree kernel module object files for coverage report generation (optional). 45 // KernelObj is also scanned for in-tree kernel modules and does not need to be duplicated here. 46 // Note: the modules need to be unstripped and contain debug info. 47 ModuleObj []string `json:"module_obj,omitempty"` 48 // Kernel source directory (if not set defaults to KernelObj). 49 KernelSrc string `json:"kernel_src,omitempty"` 50 // Location of the driectory where the kernel was built (if not set defaults to KernelSrc) 51 KernelBuildSrc string `json:"kernel_build_src,omitempty"` 52 // Is the kernel built separately from the modules? (Specific to Android builds) 53 AndroidSplitBuild bool `json:"android_split_build"` 54 // Kernel subsystem with paths to each subsystem, paths starting with "-" will be excluded 55 // "kernel_subsystem": [ 56 // { "name": "sound", "path": ["sound", "techpack/audio", "-techpack/audio/dsp"]}, 57 // { "name": "mydriver": "path": ["mydriver_path"]} 58 // ] 59 KernelSubsystem []Subsystem `json:"kernel_subsystem,omitempty"` 60 // Arbitrary optional tag that is saved along with crash reports (e.g. branch/commit). 61 Tag string `json:"tag,omitempty"` 62 // Location of the disk image file. 63 Image string `json:"image,omitempty"` 64 // Location (on the host machine) of a root SSH identity to use for communicating with 65 // the virtual machine (may be empty for some VM types). 66 SSHKey string `json:"sshkey,omitempty"` 67 // SSH user ("root" by default). 68 SSHUser string `json:"ssh_user,omitempty"` 69 70 HubClient string `json:"hub_client,omitempty"` 71 HubAddr string `json:"hub_addr,omitempty"` 72 HubKey string `json:"hub_key,omitempty"` 73 // Hub input domain identifier (optional). 74 // The domain is used to avoid duplicate work (input minimization, smashing) 75 // across multiple managers testing similar kernels and connected to the same hub. 76 // If two managers are in the same domain, they will not do input minimization after each other. 77 // If additionally they are in the same smashing sub-domain, they will also not do smashing 78 // after each other. 79 // By default (empty domain) all managers testing the same OS are placed into the same domain, 80 // this is a reasonable setting if managers test roughly the same kernel. In this case they 81 // will not do minimization nor smashing after each other. 82 // The setting can be either a single identifier (e.g. "foo") which will affect both minimization 83 // and smashing; or two identifiers separated with '/' (e.g. "foo/bar"), in this case the first 84 // identifier affects minimization and both affect smashing. 85 // For example, if managers test different Linux kernel versions with different tools, 86 // a reasonable use of domains on these managers can be: 87 // - "upstream/kasan" 88 // - "upstream/kmsan" 89 // - "upstream/kcsan" 90 // - "5.4/kasan" 91 // - "5.4/kcsan" 92 // - "4.19/kasan" 93 HubDomain string `json:"hub_domain,omitempty"` 94 95 // List of email addresses to receive notifications when bugs are encountered for the first time (optional). 96 // Mailx is the only supported mailer. Please set it up prior to using this function. 97 EmailAddrs []string `json:"email_addrs,omitempty"` 98 99 DashboardClient string `json:"dashboard_client,omitempty"` 100 DashboardAddr string `json:"dashboard_addr,omitempty"` 101 DashboardKey string `json:"dashboard_key,omitempty"` 102 DashboardUserAgent string `json:"dashboard_user_agent,omitempty"` 103 // If set, only consult dashboard if it needs reproducers for crashes, 104 // but otherwise don't send any info to dashboard (default: false). 105 DashboardOnlyRepro bool `json:"dashboard_only_repro,omitempty"` 106 107 // Location of the syzkaller checkout, syz-manager will look 108 // for binaries in bin subdir (does not have to be syzkaller checkout as 109 // long as it preserves `bin` dir structure) 110 Syzkaller string `json:"syzkaller"` 111 112 // Number of parallel test processes inside of each VM. 113 // Allowed values are 1-32, recommended range is ~4-8, default value is 6. 114 // It should be chosen to saturate CPU inside of the VM and maximize number of test executions, 115 // but to not oversubscribe CPU and memory too severe to not cause OOMs and false hangs/stalls. 116 Procs int `json:"procs"` 117 118 // Maximum number of logs to store per crash (default: 100). 119 MaxCrashLogs int `json:"max_crash_logs"` 120 121 // Type of sandbox to use during fuzzing: 122 // "none": test under root; 123 // don't do anything special beyond resource sandboxing, 124 // gives the most coverage, default 125 // "namespace": create a new user namespace for testing using CLONE_NEWUSER (supported only on Linux), 126 // the test process has CAP_ADMIN inside of the user namespace, but not in the init namespace, 127 // but the test process still has access to all /dev/ nodes owned by root, 128 // this is a compromise between coverage and bug impact, 129 // requires building kernel with CONFIG_USER_NS 130 // "setuid": impersonate into user nobody (65534) (supported on Linux, FreeBSD, NetBSD, OpenBSD) 131 // this is the most restrictive sandbox 132 // "android": emulate permissions of an untrusted Android app (supported only on Linux) 133 Sandbox string `json:"sandbox"` 134 135 // This value is passed as an argument to executor and allows to adjust sandbox behavior 136 // via manager config. For example you can switch between system and user accounts based 137 // on this value. 138 SandboxArg int64 `json:"sandbox_arg"` 139 140 // Enables snapshotting mode. In this mode VM is snapshotted and restarted from the snapshot 141 // before executing each test program. This provides better reproducibility and avoids global 142 // accumulated state. Currently only qemu VMs and Linux support this mode. 143 Snapshot bool `json:"snapshot"` 144 145 // Use KCOV coverage (default: true). 146 Cover bool `json:"cover"` 147 148 // CovFilter used to restrict the area of the kernel visible to syzkaller. 149 // DEPRECATED! Use the FocusAreas parameter instead. 150 CovFilter CovFilterCfg `json:"cover_filter,omitempty"` 151 152 // For each prog in the corpus, remember the raw array of PCs obtained from the kernel. 153 // It can be useful for debugging syzkaller descriptions and syzkaller itself. 154 // Disabled by default as it slows down fuzzing. 155 RawCover bool `json:"raw_cover"` 156 157 // Reproduce, localize and minimize crashers (default: true). 158 Reproduce bool `json:"reproduce"` 159 160 // The number of VMs that are reserved to only perform fuzzing and nothing else. 161 // Can be helpful e.g. to ensure that the pool of fuzzing VMs is never exhausted and 162 // the manager continues fuzzing no matter how many new bugs are encountered. 163 // By default the value is 0, i.e. all VMs can be used for all purposes. 164 FuzzingVMs int `json:"fuzzing_vms,omitempty"` 165 166 // Keep existing programs in the corpus even if they no longer pass syscall filters. 167 // By default it is true, as this is the desired behavior when executing syzkaller 168 // locally. 169 PreserveCorpus bool `json:"preserve_corpus"` 170 171 // List of syscalls to test (optional). For example: 172 // "enable_syscalls": [ "mmap", "openat$ashmem", "ioctl$ASHMEM*" ] 173 EnabledSyscalls []string `json:"enable_syscalls,omitempty"` 174 // List of system calls that should be treated as disabled (optional). 175 DisabledSyscalls []string `json:"disable_syscalls,omitempty"` 176 // List of syscalls that should not be mutated by the fuzzer (optional). 177 NoMutateSyscalls []string `json:"no_mutate_syscalls,omitempty"` 178 // List of regexps for known bugs. 179 // Don't save reports matching these regexps, but reboot VM after them, 180 // matched against whole report output. 181 Suppressions []string `json:"suppressions,omitempty"` 182 // Completely ignore reports matching these regexps (don't save nor reboot), 183 // must match the first line of crash message. 184 Ignores []string `json:"ignores,omitempty"` 185 // List of regexps to select bugs of interest. 186 // If this list is not empty and none of the regexps match a bug, it's suppressed. 187 // Regexps are matched against bug title, guilty file and maintainer emails. 188 Interests []string `json:"interests,omitempty"` 189 190 // Path to the strace binary compiled for the target architecture. 191 // If set, for each reproducer syzkaller will run it once more under strace and save 192 // the output. 193 StraceBin string `json:"strace_bin"` 194 // If true, syzkaller will expect strace_bin to be part of the target 195 // image instead of copying it from the host (default: false). 196 StraceBinOnTarget bool `json:"strace_bin_on_target"` 197 198 // File in PATH to syz-execprog/executor on the target. If set, 199 // syzkaller will expect the execprog/executor binaries to be part of 200 // the target image instead of copying them from the host. 201 ExecprogBinOnTarget string `json:"execprog_bin_on_target"` 202 ExecutorBinOnTarget string `json:"executor_bin_on_target"` 203 204 // Whether to run fsck commands on file system images found in new crash 205 // reproducers. The fsck logs get reported as assets in the dashboard. 206 // Note: you may need to install 3rd-party dependencies for this to work. 207 // fsck commands that can be run by syz-manager are specified in mount 208 // syscall descriptions - typically in sys/linux/filesystem.txt. 209 // Enabled by default. 210 RunFsck bool `json:"run_fsck"` 211 212 // Type of virtual machine to use, e.g. "qemu", "gce", "android", "isolated", etc. 213 Type string `json:"type"` 214 // VM-type-specific parameters. 215 // Parameters for concrete types are in Config type in vm/TYPE/TYPE.go, e.g. vm/qemu/qemu.go. 216 VM json.RawMessage `json:"vm"` 217 218 // Asset storage configuration. There can be specified the upload location and crash assets 219 // to upload. 220 // A sample config: 221 // { 222 // "upload_to": "gs://bucket", 223 // "public_access": true 224 // } 225 // More details can be found in pkg/asset/config.go. 226 AssetStorage *asset.Config `json:"asset_storage"` 227 228 // Experimental options. 229 Experimental Experimental 230 231 // Implementation details beyond this point. Filled after parsing. 232 Derived `json:"-"` 233 } 234 235 // These options are not guaranteed to be backward/forward compatible and 236 // can be dropped at any moment. 237 type Experimental struct { 238 // Don't let the VM state accumulate too much by restarting 239 // syz-executor before most prog executions. 240 ResetAccState bool `json:"reset_acc_state"` 241 242 // Use KCOV remote coverage feature (default: true). 243 RemoteCover bool `json:"remote_cover"` 244 245 // Hash adjacent PCs to form fuzzing feedback signal, otherwise use PCs as signal (default: true). 246 CoverEdges bool `json:"cover_edges"` 247 248 // Use automatically (auto) generated or manually (manual) written descriptions or any (any) (default: manual) 249 DescriptionsMode string `json:"descriptions_mode"` 250 251 // FocusAreas configures what attention syzkaller should pay to the specific areas of the kernel. 252 // The probability of selecting a program from an area is at least `Weight / sum of weights`. 253 // If FocusAreas is non-empty, by default all kernel code not covered by any filter will be ignored. 254 // To focus fuzzing on some areas, but to consider the rest of the code as well, add a record 255 // with an empty Filter, but non-empty weight. 256 // E.g. "focus_areas": [ {"filter": {"files": ["^net"]}, "weight": 10.0}, {"weight": 1.0} ]. 257 FocusAreas []FocusArea `json:"focus_areas,omitempty"` 258 259 // Enable dynamic discovery and fuzzing of KFuzzTest targets. 260 EnableKFuzzTest bool `json:"enable_kfuzztest"` 261 } 262 263 type FocusArea struct { 264 // Name allows to display detailed statistics for every focus area. 265 Name string `json:"name"` 266 267 // A coverage filter. 268 // Supported filter types: 269 // "files": support specifying kernel source files, support regular expression. 270 // eg. "files": ["^net/core/tcp.c$", "^net/sctp/", "tcp"]. 271 // "functions": support specifying kernel functions, support regular expression. 272 // eg. "functions": ["^foo$", "^bar", "baz"]. 273 // "pcs": specify raw PC table files name. 274 // Each line of the file should be: "64-bit-pc:32-bit-weight\n". 275 // eg. "0xffffffff81000000:0x10\n" 276 // If empty, it's assumed to match the whole kernel. 277 Filter CovFilterCfg `json:"filter,omitempty"` 278 279 // Weight is a positive number that determines how much focus should be put on this area. 280 Weight float64 `json:"weight"` 281 } 282 283 type Subsystem struct { 284 Name string `json:"name"` 285 Paths []string `json:"path"` 286 } 287 288 type CovFilterCfg struct { 289 Files []string `json:"files,omitempty"` 290 Functions []string `json:"functions,omitempty"` 291 RawPCs []string `json:"pcs,omitempty"` 292 }