Bug 198443

Summary: KCOV: trace arch/x86/kernel code
Product: Memory Management Reporter: Dmitry Vyukov (dvyukov)
Component: SanitizersAssignee: Dmitry Vyukov (dvyukov)
Status: NEW ---    
Severity: enhancement CC: kasan-dev
Priority: P2    
Hardware: All   
OS: Linux   
Kernel Version: ALL Tree: Mainline
Regression: No

Description Dmitry Vyukov 2018-01-10 14:36:08 UTC
Currently code in arch/x86/kernel/Makefile is not instrumented:

# If instrumentation of this dir is enabled, boot hangs during first second.
# Probably could be more selective here, but note that files related to irqs,
# boot, dumpstack/stacktrace, etc are either non-interesting or can lead to
# non-deterministic coverage.
KCOV_INSTRUMENT			:= n

But the files contain a bunch of syscalls and code invoked from syscalls. E.g. modity_ldt, set_thread_area. Here is what I've tested and it works (enabled code with syscall definitions and mentioning copy_to/from_user):

KCOV_INSTRUMENT_i8237.o			:= n
KCOV_INSTRUMENT_resource.o			:= n
KCOV_INSTRUMENT_machine_kexec_32.o			:= n
KCOV_INSTRUMENT_devicetree.o			:= n
KCOV_INSTRUMENT_apb_timer.o			:= n
KCOV_INSTRUMENT_smpboot.o			:= n
KCOV_INSTRUMENT_pvclock.o			:= n
#KCOV_INSTRUMENT_cpuid.o			:= n
KCOV_INSTRUMENT_e820.o			:= n
KCOV_INSTRUMENT_sysfb_efi.o			:= n
KCOV_INSTRUMENT_setup_percpu.o			:= n
KCOV_INSTRUMENT_io_delay.o			:= n
KCOV_INSTRUMENT_paravirt_patch_32.o			:= n
KCOV_INSTRUMENT_stacktrace.o			:= n
KCOV_INSTRUMENT_pci-swiotlb.o			:= n
KCOV_INSTRUMENT_itmt.o			:= n
KCOV_INSTRUMENT_check.o			:= n
#KCOV_INSTRUMENT_signal.o			:= n
KCOV_INSTRUMENT_idt.o			:= n
KCOV_INSTRUMENT_quirks.o			:= n
KCOV_INSTRUMENT_tsc_sync.o			:= n
KCOV_INSTRUMENT_jump_label.o			:= n
KCOV_INSTRUMENT_time.o			:= n
#KCOV_INSTRUMENT_ioport.o			:= n
KCOV_INSTRUMENT_mmconf-fam10h_64.o			:= n
KCOV_INSTRUMENT_step.o			:= n
KCOV_INSTRUMENT_crash_dump_32.o			:= n
KCOV_INSTRUMENT_ftrace.o			:= n
KCOV_INSTRUMENT_pmem.o			:= n
KCOV_INSTRUMENT_espfix_64.o			:= n
KCOV_INSTRUMENT_unwind_guess.o			:= n
KCOV_INSTRUMENT_kexec-bzimage64.o			:= n
#KCOV_INSTRUMENT_process_64.o			:= n
#KCOV_INSTRUMENT_tls.o			:= n
KCOV_INSTRUMENT_setup.o			:= n
KCOV_INSTRUMENT_tce_64.o			:= n
KCOV_INSTRUMENT_reboot.o			:= n
KCOV_INSTRUMENT_i8253.o			:= n
KCOV_INSTRUMENT_paravirt-spinlocks.o			:= n
KCOV_INSTRUMENT_hw_breakpoint.o			:= n
KCOV_INSTRUMENT_irq_work.o			:= n
KCOV_INSTRUMENT_pci-calgary_64.o			:= n
KCOV_INSTRUMENT_audit_64.o			:= n
KCOV_INSTRUMENT_rtc.o			:= n
KCOV_INSTRUMENT_irq.o			:= n
KCOV_INSTRUMENT_unwind_orc.o			:= n
KCOV_INSTRUMENT_ptrace.o			:= n
KCOV_INSTRUMENT_early-quirks.o			:= n
KCOV_INSTRUMENT_probe_roms.o			:= n
KCOV_INSTRUMENT_traps.o			:= n
KCOV_INSTRUMENT_ksysfs.o			:= n
#KCOV_INSTRUMENT_signal_compat.o			:= n
KCOV_INSTRUMENT_early_printk.o			:= n
#KCOV_INSTRUMENT_uprobes.o			:= n
KCOV_INSTRUMENT_paravirt.o			:= n
KCOV_INSTRUMENT_vsmp_64.o			:= n
KCOV_INSTRUMENT_irq_64.o			:= n
KCOV_INSTRUMENT_mpparse.o			:= n
KCOV_INSTRUMENT_sysfb.o			:= n
KCOV_INSTRUMENT_asm-offsets_64.o			:= n
KCOV_INSTRUMENT_dumpstack.o			:= n
KCOV_INSTRUMENT_aperture_64.o			:= n
KCOV_INSTRUMENT_asm-offsets.o			:= n
KCOV_INSTRUMENT_dumpstack_32.o			:= n
KCOV_INSTRUMENT_head32.o			:= n
KCOV_INSTRUMENT_livepatch.o			:= n
KCOV_INSTRUMENT_irqinit.o			:= n
KCOV_INSTRUMENT_amd_nb.o			:= n
KCOV_INSTRUMENT_tboot.o			:= n
KCOV_INSTRUMENT_tracepoint.o			:= n
KCOV_INSTRUMENT_amd_gart_64.o			:= n
KCOV_INSTRUMENT_unwind_frame.o			:= n
KCOV_INSTRUMENT_head64.o			:= n
KCOV_INSTRUMENT_sysfb_simplefb.o			:= n
KCOV_INSTRUMENT_paravirt_patch_64.o			:= n
KCOV_INSTRUMENT_reboot_fixups_32.o			:= n
KCOV_INSTRUMENT_kvmclock.o			:= n
KCOV_INSTRUMENT_doublefault.o			:= n
KCOV_INSTRUMENT_hpet.o			:= n
KCOV_INSTRUMENT_crash.o			:= n
KCOV_INSTRUMENT_pci-nommu.o			:= n
KCOV_INSTRUMENT_apm_32.o			:= n
KCOV_INSTRUMENT_pci-dma.o			:= n
KCOV_INSTRUMENT_dumpstack_64.o			:= n
KCOV_INSTRUMENT_pci-iommu_table.o			:= n
KCOV_INSTRUMENT_tsc.o			:= n
KCOV_INSTRUMENT_alternative.o			:= n
#KCOV_INSTRUMENT_msr.o			:= n
KCOV_INSTRUMENT_machine_kexec_64.o			:= n
KCOV_INSTRUMENT_nmi.o			:= n
#KCOV_INSTRUMENT_ldt.o			:= n
#KCOV_INSTRUMENT_vm86_32.o			:= n
KCOV_INSTRUMENT_trace_clock.o			:= n
KCOV_INSTRUMENT_perf_regs.o			:= n
KCOV_INSTRUMENT_bootflag.o			:= n
KCOV_INSTRUMENT_i8259.o			:= n
KCOV_INSTRUMENT_nmi_selftest.o			:= n
KCOV_INSTRUMENT_crash_dump_64.o			:= n
KCOV_INSTRUMENT_pcspeaker.o			:= n
KCOV_INSTRUMENT_kvm.o			:= n
KCOV_INSTRUMENT_kdebugfs.o			:= n
KCOV_INSTRUMENT_module.o			:= n
KCOV_INSTRUMENT_x86_init.o			:= n
KCOV_INSTRUMENT_asm-offsets_32.o			:= n
KCOV_INSTRUMENT_kgdb.o			:= n
KCOV_INSTRUMENT_topology.o			:= n
KCOV_INSTRUMENT_irq_32.o			:= n
KCOV_INSTRUMENT_platform-quirks.o			:= n
#KCOV_INSTRUMENT_process_32.o			:= n
#KCOV_INSTRUMENT_sys_x86_64.o			:= n
KCOV_INSTRUMENT_tsc_msr.o			:= n
KCOV_INSTRUMENT_smp.o			:= n
KCOV_INSTRUMENT_ebda.o			:= n
KCOV_INSTRUMENT_eisa.o			:= n
KCOV_INSTRUMENT_process.o			:= n
Need to understand what exactly files need to be disabled and upstream this.
I've also tried the following and it does not yet boot:

KCOV_INSTRUMENT_head$(BITS).o				:= n
KCOV_INSTRUMENT_setup.o					:= n
KCOV_INSTRUMENT_dumpstack.o				:= n
KCOV_INSTRUMENT_dumpstack_$(BITS).o			:= n
KCOV_INSTRUMENT_stacktrace.o				:= n
KCOV_INSTRUMENT_relocate_kernel_$(BITS).o		:= n
KCOV_INSTRUMENT_ftrace_$(BITS).o			:= n
KCOV_INSTRUMENT_test_nx.o				:= n
KCOV_INSTRUMENT_paravirt_patch_$(BITS).o		:= n
KCOV_INSTRUMENT_tsc.o					:= n
KCOV_INSTRUMENT_paravirt-spinlocks.o			:= n
KCOV_INSTRUMENT_pvclock.o				:= n
KCOV_INSTRUMENT_kvmclock.o				:= n
KCOV_INSTRUMENT_ftrace.o				:= n
KCOV_INSTRUMENT_early_printk.o				:= n