github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/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
    55  	//	"kernel_subsystem": [
    56  	//		{ "name": "sound", "path": ["sound", "techpack/audio"]},
    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  
   103  	// Location of the syzkaller checkout, syz-manager will look
   104  	// for binaries in bin subdir (does not have to be syzkaller checkout as
   105  	// long as it preserves `bin` dir structure)
   106  	Syzkaller string `json:"syzkaller"`
   107  
   108  	// Number of parallel test processes inside of each VM.
   109  	// Allowed values are 1-32, recommended range is ~4-8, default value is 6.
   110  	// It should be chosen to saturate CPU inside of the VM and maximize number of test executions,
   111  	// but to not oversubscribe CPU and memory too severe to not cause OOMs and false hangs/stalls.
   112  	Procs int `json:"procs"`
   113  
   114  	// Maximum number of logs to store per crash (default: 100).
   115  	MaxCrashLogs int `json:"max_crash_logs"`
   116  
   117  	// Type of sandbox to use during fuzzing:
   118  	// "none": test under root;
   119  	//      don't do anything special beyond resource sandboxing,
   120  	//      gives the most coverage, default
   121  	// "namespace": create a new user namespace for testing using CLONE_NEWUSER (supported only on Linux),
   122  	//      the test process has CAP_ADMIN inside of the user namespace, but not in the init namespace,
   123  	//      but the test process still has access to all /dev/ nodes owned by root,
   124  	//      this is a compromise between coverage and bug impact,
   125  	//	requires building kernel with CONFIG_USER_NS
   126  	// "setuid": impersonate into user nobody (65534) (supported on Linux, FreeBSD, NetBSD, OpenBSD)
   127  	//      this is the most restrictive sandbox
   128  	// "android": emulate permissions of an untrusted Android app (supported only on Linux)
   129  	Sandbox string `json:"sandbox"`
   130  
   131  	// This value is passed as an argument to executor and allows to adjust sandbox behavior
   132  	// via manager config. For example you can switch between system and user accounts based
   133  	// on this value.
   134  	SandboxArg int `json:"sandbox_arg"`
   135  
   136  	// Use KCOV coverage (default: true).
   137  	Cover bool `json:"cover"`
   138  	// Use coverage filter. Supported types of filter:
   139  	// "files": support specifying kernel source files, support regular expression.
   140  	// eg. "files": ["^net/core/tcp.c$", "^net/sctp/", "tcp"].
   141  	// "functions": support specifying kernel functions, support regular expression.
   142  	// eg. "functions": ["^foo$", "^bar", "baz"].
   143  	// "pcs": specify raw PC table files name.
   144  	// Each line of the file should be: "64-bit-pc:32-bit-weight\n".
   145  	// eg. "0xffffffff81000000:0x10\n"
   146  	CovFilter covFilterCfg `json:"cover_filter,omitempty"`
   147  
   148  	// For each prog in the corpus, remember the raw array of PCs obtained from the kernel.
   149  	// It can be useful for debugging syzkaller descriptions and syzkaller itself.
   150  	// Disabled by default as it slows down fuzzing.
   151  	RawCover bool `json:"raw_cover"`
   152  
   153  	// Reproduce, localize and minimize crashers (default: true).
   154  	Reproduce bool `json:"reproduce"`
   155  
   156  	// The number of VMs that are reserved to only perform fuzzing and nothing else.
   157  	// Can be helpful e.g. to ensure that the pool of fuzzing VMs is never exhausted and
   158  	// the manager continues fuzzing no matter how many new bugs are encountered.
   159  	// By default the value is 0, i.e. all VMs can be used for all purposes.
   160  	FuzzingVMs int `json:"fuzzing_vms,omitempty"`
   161  
   162  	// Keep existing programs in the corpus even if they no longer pass syscall filters.
   163  	// By default it is true, as this is the desired behavior when executing syzkaller
   164  	// locally.
   165  	PreserveCorpus bool `json:"preserve_corpus"`
   166  
   167  	// List of syscalls to test (optional). For example:
   168  	//	"enable_syscalls": [ "mmap", "openat$ashmem", "ioctl$ASHMEM*" ]
   169  	EnabledSyscalls []string `json:"enable_syscalls,omitempty"`
   170  	// List of system calls that should be treated as disabled (optional).
   171  	DisabledSyscalls []string `json:"disable_syscalls,omitempty"`
   172  	// List of syscalls that should not be mutated by the fuzzer (optional).
   173  	NoMutateSyscalls []string `json:"no_mutate_syscalls,omitempty"`
   174  	// List of regexps for known bugs.
   175  	// Don't save reports matching these regexps, but reboot VM after them,
   176  	// matched against whole report output.
   177  	Suppressions []string `json:"suppressions,omitempty"`
   178  	// Completely ignore reports matching these regexps (don't save nor reboot),
   179  	// must match the first line of crash message.
   180  	Ignores []string `json:"ignores,omitempty"`
   181  	// List of regexps to select bugs of interest.
   182  	// If this list is not empty and none of the regexps match a bug, it's suppressed.
   183  	// Regexps are matched against bug title, guilty file and maintainer emails.
   184  	Interests []string `json:"interests,omitempty"`
   185  
   186  	// Path to the strace binary compiled for the target architecture.
   187  	// If set, for each reproducer syzkaller will run it once more under strace and save
   188  	// the output.
   189  	StraceBin string `json:"strace_bin"`
   190  
   191  	// Type of virtual machine to use, e.g. "qemu", "gce", "android", "isolated", etc.
   192  	Type string `json:"type"`
   193  	// VM-type-specific parameters.
   194  	// Parameters for concrete types are in Config type in vm/TYPE/TYPE.go, e.g. vm/qemu/qemu.go.
   195  	VM json.RawMessage `json:"vm"`
   196  
   197  	// Asset storage configuration. There can be specified the upload location and crash assets
   198  	// to upload.
   199  	// A sample config:
   200  	// {
   201  	//    "upload_to": "gs://bucket",
   202  	//    "public_access": true
   203  	// }
   204  	// More details can be found in pkg/asset/config.go.
   205  	AssetStorage *asset.Config `json:"asset_storage"`
   206  
   207  	// Experimental options.
   208  	Experimental Experimental
   209  
   210  	// Implementation details beyond this point. Filled after parsing.
   211  	Derived `json:"-"`
   212  }
   213  
   214  // These options are not guaranteed to be backward/forward compatible and
   215  // can be dropped at any moment.
   216  type Experimental struct {
   217  	// Don't let the VM state accumulate too much by restarting
   218  	// syz-executor before most prog executions.
   219  	ResetAccState bool `json:"reset_acc_state"`
   220  }
   221  
   222  type Subsystem struct {
   223  	Name  string   `json:"name"`
   224  	Paths []string `json:"path"`
   225  }
   226  
   227  type covFilterCfg struct {
   228  	Files     []string `json:"files,omitempty"`
   229  	Functions []string `json:"functions,omitempty"`
   230  	RawPCs    []string `json:"pcs,omitempty"`
   231  }