Module Name: src Committed By: maxv Date: Fri May 15 12:34:52 UTC 2020
Modified Files: src/sys/dev/usb: uhub.c usbdivar.h vhci.c src/sys/kern: subr_kcov.c src/sys/sys: kcov.h Log Message: Introduce KCOV remote support. This allows to collect KCOV coverage on threads other than curlwp, which is useful when fuzzing components that defer processing, such as the network stack (partially runs in softints) and the USB stack (partially runs in uhub kthreads). A subsystem that whishes to provide coverage for its threads creates a "mailbox" via kcov_remote_register() and gives it a (subsystem, id) identifier. There is one mailbox per "target lwp". The target lwp(s) must then call kcov_remote_enter() and kcov_remote_leave() with the identifier, to respectively enable and disable coverage within the thread. On the userland side, the fuzzer has access to the mailboxes on the system with the KCOV_IOC_REMOTE_ATTACH and KCOV_IOC_REMOTE_DETACH ioctls. When attached to a mailbox with a given identifier, the KCOV_IOC_ENABLE, KCOV_IOC_DISABLE and mmap() operations will affect the mailbox. As a demonstrator, the vHCI subsystem is changed to use KCOV mailboxes. When the vHCI bus attaches it creates as many mailboxes as it has USB ports, each mailbox being associated with a distinct port. Uhub is changed to enable KCOV coverage in usbd_new_device(). With that in place, all of the USB enumeration procedure can be traced with KCOV. To generate a diff of this commit: cvs rdiff -u -r1.144 -r1.145 src/sys/dev/usb/uhub.c cvs rdiff -u -r1.122 -r1.123 src/sys/dev/usb/usbdivar.h cvs rdiff -u -r1.16 -r1.17 src/sys/dev/usb/vhci.c cvs rdiff -u -r1.12 -r1.13 src/sys/kern/subr_kcov.c cvs rdiff -u -r1.7 -r1.8 src/sys/sys/kcov.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.