修改源碼
src/VBox/VMM/VMMAll/IOMAllMMIONew.cpp
注釋掉如下代碼
#ifdef VBOX_STRICT
if (pRange->fFlags & IOMMMIO_FLAGS_DBGSTOP_ON_COMPLICATED_WRITE)
{
# ifdef IN_RING3
LogRel(("IOM: Complicated write %#x byte at %RGp to %s, initiating debugger intervention\n", cbValue, GCPhys,
R3STRING(pRange->pszDesc)));
rc = DBGFR3EventSrc(pVM, DBGFEVENT_DEV_STOP, RT_SRC_POS,
"Complicated write %#x byte at %RGp to %s\n", cbValue, GCPhys, R3STRING(pRange->pszDesc));
if (rc == VERR_DBGF_NOT_ATTACHED)
rc = VINF_SUCCESS;
# else
return VINF_IOM_R3_MMIO_WRITE;
# endif
}
#endif
include/iprt/assert.h 注釋掉 RT_BREAKPOINT
刪掉assert可能會(huì)引發(fā)莫名的死機(jī)皆疹,最好還是直接刪源文件里的assert調(diào)用
#define RTAssertDebugBreak() do { RT_BREAKPOINT(); } while (0)
Config.kmk 開(kāi)啟gcov赤套,開(kāi)啟afl插樁
VBOX_GCC_SANITIZER_FLAGS:= \
-fprofile-arcs -ftest-coverage
src/VBox/Devices/Makefile.kmk, 僅對(duì)device部分插樁
VBoxDD_CFLAGS.debug+=-use-afl
VBoxDD_CXXFLAGS.debug+=-use-afl
VBoxDD_LDFLAGS.debug+=-use-afl
include/iprt/mangling.h 刪掉如下代碼
:bad
s/^\(.*\)$/error: Missing # define \1 /
:bad-pad
/^.\{0,70\}$/ { s/$/ /; bbad-pad; }
s/define \([^ ]*\) \([ ]*\)$/define \1 \2RT_MANGLER(\1)/
p
q 1
編譯
./configure --disable-hardening --disable-docs
source ./env.sh
kmk BUILD_TYPE=debug VBOX_WITH_GCC_SANITIZER=1
安裝
cd out/linux.x86/release/bin/src
make
sudo make install
cd ..
sudo depmod
sudo modprobe -r vboxdrv
sudo modprobe vboxdrv
運(yùn)行
sudo ASAN_OPTIONS='detect_leaks=0' ./VirtualBox
提取覆蓋率
IDA loadfile
sudo /home/hades/tools/DynamoRIO-Linux-8.0.0-1/bin64/drrun -t drcov -- ../VirtualBox