google / kmsan

KernelMemorySanitizer, a detector of uses of uninitialized memory in the Linux kernel
Other
406 stars 62 forks source link

KMSAN doesn't support paravirtualization #90

Open ramosian-glider opened 1 year ago

ramosian-glider commented 1 year ago

Right now KMSAN does not play well with CONFIG_XEN_PV=y

In particular, the kernel crashes at boot-time on the following code:

void load_percpu_segment(int cpu)
{
#ifdef CONFIG_X86_32
    loadsegment(fs, __KERNEL_PERCPU);
#else
    __loadsegment_simple(gs, 0);
    wrmsrl(MSR_GS_BASE, cpu_kernelmode_gs_base(cpu));
#endif
}

Here __loadsegment_simple() sets %gs=0, invalidating the following accesses to percpu data, including those happening inside __msan_get_context_state(), which KMSAN adds to every function call.

The behavior of load_percpu_segment() is being fixed upstream: https://lore.kernel.org/lkml/166601847113.401.13616810593513367893.tip-bot2@tip-bot2/, but CONFIG_XEN_PV still generates a bunch of KMSAN reports, so we'd better keep it disabled for now.