/* See kernel/kcov.c for more details. */ /* Coverage collection mode enabled for this task (0 if disabled): */ unsigned int kcov_mode; /* Size of the kcov_area: */ unsigned int kcov_size; /* Buffer for coverage collection: */ void *kcov_area; /* KCOV descriptor wired with this task or NULL: */ struct kcov *kcov; /* KCOV common handle for remote coverage collection: */ u64 kcov_handle; /* KCOV sequence number: */ int kcov_sequence; #endif #ifdef CONFIG_MEMCG struct
asm/current.h> #include <linux/pid.h> #include <linux/sem.h> #include <linux/shm.h> #include <linux/kcov.h trace recursion: */ unsigned long trace_recursion; #endif /* CONFIG_TRACING */ #ifdef CONFIG_KCOV /* Coverage collection mode enabled for this task (0 if disabled): */ enum kcov_mode kcov_mode ; /* Size of the kcov_area: */ unsigned int kcov_size; /* Buffer for coverage collection: */ void *kcov_area; /* KCOV descriptor wired with this task or NULL: */ struct kcov
. ❞ kcov_task_exit(tsk); kmsan_task_exit(tsk); coredump_task_exit(tsk); ptrace_event(PTRACE_EVENT_EXIT , code); validate_creds_for_do_exit(tsk); io_uring_files_cancel(); 接着内核分别调用了kcov_task_exit、kmsan_task_exit 和coredump_task_exit来通知kcov和kmsan进程的退出。
Memory leaks (experimental) Fuzzing userspace: libFuzzer Fuzzing Kernelspace: KASAN Fuzzing Kernelspace: KCOV Allows for simple code coverage instrumentation Basic-block level instrumentation Enabled with CONFIG_KCOV guided Linux syscall fuzzer Supported in android on pixel devices Requires a kernel with KASAN and KCOV
在运行过程中,会输出如下信息 GenomeScope analyzing kmer_hist k=31 readlen=150 outdir=test Model converged het:0.0236 kcov
除了KASAN,kcov是另一个对测试非常有用的内核修改。kcov旨在允许在内核中进行覆盖率引导模糊测试。它会测量在系统调用输入方面的覆盖率,对于模糊系统(如syzkaller)非常有用。 如需在启用KASAN和kcov的情况下编译内核,请将以下构建标志添加到内核构建配置: CONFIG_KASAN CONFIG_KASAN_INLINE CONFIG_TEST_KASAN CONFIG_KCOV
CONFIG_KCOV=y # Debug info for symbolization.
[]const u8{ "kcov", "kcov-output", null, }); } 现在当你运行 zig build test -Dtest-coverage 时,报告将存放在 kcov-output。 uses: goto-bus-stop/setup-zig@v2 with: version: 0.10.1 - name: Install kcov install -y \ --no-install-recommends \ --allow-unauthenticated \ kcov : codecov/codecov-action@v3 with: name: code-coverage-report directory: kcov-output
kernel 版本为 4.4)于是在此版本上可以开启 编译方式,添加 kconfig CONFIG_KASAN CONFIG_KASAN_INLINE CONFIG_TEST_KASAN CONFIG_KCOV
github.com/openai/gym 测试覆盖率报告作为代码阅读工具 #CoverageReport #CI #review 本文教你一种使用覆盖率报告阅读项目源码的方法,以alacritty的代码为示例,使用kcov
这次作者用syzkaller fuzz USB驱动共发现了80+个bug,它先开启kcov去收集代码覆盖率信息,写了两个usb操作的描述模板(vusb.txt用来生成usb消息,vusb_ids.txt
Travis CI和AppVeyor集成 对于开源项目免费 Coveralls[68] 与Travis CI和AppVeyor集成 对于开源项目免费 LCOV[69] 有很多配置项 Gcovr[70] kcov coveralls.io/ [69] LCOV: http://ltp.sourceforge.net/coverage/lcov.php [70] Gcovr: http://gcovr.com/ [71] kcov : http://simonkagstrom.github.io/kcov/index.html [72] OpenCppCoverage: https://github.com/OpenCppCoverage
Languages and Toolchains io_uring Tracing Scheduler VFIO/IOMMU/PCI Kernel Dependability (static analysis, kcov
Languages and Toolchains io_uring Tracing Scheduler VFIO/IOMMU/PCI Kernel Dependability (static analysis, kcov
profile_task_exit(tsk); kcov_task_exit(tsk); ptrace_event(PTRACE_EVENT_EXIT, code); validate_creds_for_do_exit
); tick_nohz_task_switch(); finish_lock_switch(rq); finish_arch_post_lock_switch(); kcov_finish_switch
://github.com/torvalds/linux.git cd linux # 配置内核 make defconfig make kvm_guest.config echo "CONFIG_KCOV
x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev xsltproc unzip 拓展阅读: Building a Pixel kernel with KASAN+KCOV