google / kmsan

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

false-positive bug report likely due to kmsan_percpu_ctx shared between softirq and hardirq context #92

Open thejh opened 11 months ago

thejh commented 11 months ago

syzkaller with KMSAN created the following bug report: https://syzkaller.appspot.com/bug?extid=cfc08744435c4cf94a40

This looks like it might be a false-positive due to KMSAN missing part of the initialization because it occurs in a kmsan_in_runtime() section. KMSAN stores the kmsan_in_runtime flag in a kmsan_ctx. There are two types of such contexts (see kmsan_get_context()):

Therefore, I think the following sequence of events can happen:

One way to fix this might be to add another set of percpu kmsan_ctx - one set for softirq, one set for single-depth hardirq - and select from them based on whether in_hardirq() || in_nmi() is set.

(It might also be a good idea to add more contexts like this, for stuff like NMI context.)