-
Notifications
You must be signed in to change notification settings - Fork 6
API Reference
-
nameis the string of plugin name -
analyzoris the instance of current plugin -
init()passesmanagerto the plugin. Themanagercontains all necessary info of the current case, including case hash, config, logger, case path and etc.init()is called automatically by the deployer whenever a plugin is loaded. -
setup()sets the plugin path and creates the plugin work folder in the case directory. It also prepares the plugin logger. -
install_analyzor()installs the next plugin. It's automatically called by the deployer. -
run()eventually executes the plugin'srun()function. Once the plugin has finished running, it dumps the results to the plugin folder, and procceed the cleanup process. -
prepare()checks whether the dependencies has met. If it does, procceed theprepare()of the plugin. -
generate_report()generates the plugin report in the plugin folder. -
success()calls the plugin'ssuccess(). -
create_stamp()generates the finish stamp for the plugin. -
check_stamp()checks whether the plugin has a finish stamp -
null_results()resets the finish and results of the plugin -
plugin_finished()returns whether a plugin has finished successfully. -
plugin_capable()returns whether a plugin is enabled. -
pass
-
dump_results()generates aresults.jsonin the plugin folder. -
build_mainline_kernel(self, commit=None, config=None, image=None, gcc_version=None, kernel=None, patch="", keep_ori_config=False, extra_cmd="", kernel_repo="", branch="")build_mainline_kernel()controls the building process of a upstream kernel.commitspecifies the git commit of the kernel source. IfcommitisNone, it uses the case kernel commit.configlinks to a url of a kernel config that is used for compilation. IfconfigisNone, it uses the case kernel config.imagespecfies the image name, e.g., stretch.gcc_versionis decided by case report date unless if it'sNone.kernelcan be upstream, net, linux-next and etc. It will be set by the case if it's not specified.patchpoints to a path of a kernel patch, it will be apply to the source code if it's a valid patch. Ifkeep_ori_configisTrue, the kernel config will not be changed.extra_cmdwill be executed before compiling the kernel.kernel_repois a url to a Linux kernel repo if it's need to be specified.branchindicates a particular branch of Linux kernel source code. -
err_msg()logs an error message. -
info_msg()logs a info message -
debug_msglogs a debug message
-
reprois aReproducer()class for each vendor kernel. -
root_userspecifies the root user. -
normal_userspecifies the normal user. -
typeindicates three types:distro,upstream, andandroid. -
distro_imageis an absolute path of the distro image. -
vmlinuxis an absolute path of the vmlinux. -
ssh_keyis an absolute path of ssh private key -
ssh_portindicates the ssh port -
gdb_portindicates the gdb port -
mon_portindicates the QEMU monitor port -
distro_srcis an absolute path of the distro source code folder -
distro_code_nameindicates the distro code name (e.g., Ubuntu hasfocal,bionic -
distro_versionindicates the kernel version of the distro kernel -
effective_cycle_startis the date that the vendor kernel releases -
effective_cycle_endis the date that the vendor kernel ends the support -
includeis a list of keywords, and SyzBridge only captures the crash that contains one of those keywords -
excludeis a list of keywords, and SyzBridge discards the crash that contains one of those keywords
-
ssh_portspecifies the ssh port of the reproducer VM -
mon_portspecifies the qemu monitor port of the reproducer VM -
gdb_portspecifies the gdb port of the reproducer VM -
prepare()creates an image snapshot of the testing distro. -
create_snapshot()creates an image snapshot of the testing distro.srcspecifies the testing distro image.img_diris the path of the directory that keep the snapshot image.image_nameindicates the snapshot image name.target_formatindicates the format of the snapshot image. It needs to be set torawwhen creating snapshot of bullseye and android image. -
save_crash_log()save the content oflog_msgto{self.path_case}/crash_log-{name} -
need_repro()checks whether a case need to reproduce on the testing distro. A case will not reproduce when SyzBridge decides this bug doesn't affect the testing distro or the patch already exist in the testing distro kernel. -
reproduce(self, func, func_args, work_dir, timeout, vm_tag="reproducer", root=True, attempt=3, **kwargs)reproduce()is the main function for bug reproducing. It invokeslaunch_qemu()to boot up the kernel and wait for the callback functionfuncto execute.func_argspass the arguments tofunc.work_dirspecifies the folder that store the QEMU log and launch script.timeoutindicates the maximum time for running the QEMU.vm_tagis used as a identifier for QEMU log. PoC will run as root user ifrootisTrue.attemptindicates how many times that SyzBridge tries to reproduce the bug if it fails.**kwargscontains arguments forVMclass, they can be specified as well. -
launch_qemu(self, c_hash=0, log_suffix="", log_name=None, timeout=None, enable_gdb=False, enable_qemu_mon=False, gdb_port=None, mon_port=None, ssh_port=None, **kwargs)launch_qemu()returns a VM class.c_hashrepresents that hash value of the bug, it usually comes with the bug from syzbot.log_suffixappend to the log file for better identification.log_namespecifies the name of the log file.timeoutindicates the maximum time for running the QEMU.enable_gdbcontrols whether open the gdb port.enable_qemu_moncontrols whether open the QEMU monitor port.gdb_portormon_portwill be ignored they are not enabled.ssh_portspecifies the ssh port, it will be automatically set an unused port if it's not specified.**kwargscontains arguments forVMclass, they can be specified as well. -
run_qemu()boots up the QEMU and invoke the callback functionfunc.*argsis the arguments offunc
-
__init__(self, linux :str, kernel :Vendor(), port, image, hash_tag, key, vmlinux=None, tag='', arch='amd64', work_path='/tmp/', mem="4G", cpu="2", gdb_port=-1, mon_port=-1, timeout=None, debug=False, logger=None, log_name='vm.log', log_suffix="", snapshot=True)linuxis the path to the upstream Linux directory. (Only for upstream)kernelis theVendor()class initiated from SyzBridge config.portindicates the ssh port.imageis the path of the kernel image.hash_tagindicates the case hahs from syzbot.keyis the path of the ssh key.vmlinuxis the path of vmlinux (Only for upstream).tagis used for better identification.archindicates the architecture of the kernel.work_pathstores logs and launch scripts of QEMU.memindicates the how many memory is used by the VM.cpuindicates how many cpu cores are used by the VM.gdb_portindicates the gdb port.mon_portindicates the QEMU monitor port.timeoutis maximum running time of the QEMU.debugenables the debug mode.loggerspecifies the logger instance.log_nameindicates the name of the log file.log_suffixadd additional suffix to the log file name.snapshotindicates whether using snapshot for booting the image. -
reset()resets QEMU instance by empty multipleVM()flag, includingqemu_ready,kill_qemu,trigger_crash, and etc. -
run()boots up the kernel in QEMU and prepares monitor, logger, and timer for theVM()instance.alternative_funcspecifies the callback function that will be called after booting up.alternative_func_outputis aQueuethat all the output writes to.argscontains the arguments of thealternative_func. -
wait()function waits until thealternative_funcexits. It blocks the process. -
shutdownruns the commandshutdown -h nowto shutdown theVM()instance. -
kill_vmforce the theVM()instance exits by killing all the related processes. -
uploadrelies on scp to tansfer file to QEMU.userindicates the scp user.srcis a list of files on the local machine that are ready to upload.dstis the path in the virtual machine.waitdetermines whether block the process. -
downloaduses scp to transfer file from the QEMU to local machine.userindicates the scp user.srcis a list of files on the virtual machine that are ready to upload.dstis the path in the local machine.waitdetermines whether block the process. -
commanduses ssh to execute command in the virtual machine.cmdsis the command.userindicates the ssh user.waitdetermines whether block the process.timeoutindicates the timeout for the ssh. -
is_qemu_ready()determines the status of the QEMU by checking the ssh connect.