Re: [PATCH v3 1/1] kasan: Add memzero init for unaligned size under SLUB debug
From: Andrey Konovalov <andreyknvl@gmail.com>
Date: 2021-07-01 13:31:57
Also in:
linux-mediatek, linux-mm, lkml
From: Andrey Konovalov <andreyknvl@gmail.com>
Date: 2021-07-01 13:31:57
Also in:
linux-mediatek, linux-mm, lkml
On Wed, Jun 30, 2021 at 10:13 PM Marco Elver [off-list ref] wrote:
quoted
+ if (IS_ENABLED(CONFIG_SLUB_DEBUG) && init && ((unsigned long)size & KASAN_GRANULE_MASK)) { + init = false; + memzero_explicit((void *)addr, size); + } size = round_up(size, KASAN_GRANULE_SIZE); hw_set_mem_tag_range((void *)addr, size, tag, init);I think this solution might be fine for now, as I don't see an easy way to do this without some major refactor to use kmem_cache_debug_flags(). However, I think there's an intermediate solution where we only check the static-key 'slub_debug_enabled' though. Because I've checked, and various major distros _do_ enabled CONFIG_SLUB_DEBUG. But the static branch just makes sure there's no performance overhead. Checking the static branch requires including mm/slab.h into mm/kasan/kasan.h, which we currently don't do and perhaps wanted to avoid. Although I don't see a reason there, because there's no circular dependency even if we did.
Most likely this won't be a problem. We already include ../slab.h into many mm/kasan/*.c files.
Andrey, any opinion?
I like this approach. Easy to implement and is better than checking only CONFIG_SLUB_DEBUG. Thanks, Marco! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel