On Tue, Nov 21, 2023 at 11:06 PM Ilya Leoshkevich <iii@xxxxxxxxxxxxx> wrote: > > Like for KASAN, it's useful to temporarily disable KMSAN checks around, > e.g., redzone accesses. Introduce kmsan_disable_current() and > kmsan_enable_current(), which are similar to their KASAN counterparts. Initially we used to have this disablement counter in KMSAN, but adding it uncontrollably can result in KMSAN not functioning properly. E.g. forgetting to call kmsan_disable_current() or underflowing the counter will break reporting. We'd better put this API in include/linux/kmsan.h to indicate it should be discouraged. > Even though it's not strictly necessary, make them reentrant, in order > to match the KASAN behavior. Until this becomes strictly necessary, I think we'd better KMSAN_WARN_ON if the counter is re-entered.