Re: [PATCH v2 19/20] kasan, mm: allow cache merging with no metadata
From: Marco Elver
Date: Wed Nov 11 2020 - 20:35:59 EST
On Tue, Nov 10, 2020 at 11:20PM +0100, Andrey Konovalov wrote:
> The reason cache merging is disabled with KASAN is because KASAN puts its
> metadata right after the allocated object. When the merged caches have
> slightly different sizes, the metadata ends up in different places, which
> KASAN doesn't support.
>
> It might be possible to adjust the metadata allocation algorithm and make
> it friendly to the cache merging code. Instead this change takes a simpler
> approach and allows merging caches when no metadata is present. Which is
> the case for hardware tag-based KASAN with kasan.mode=prod.
>
> Signed-off-by: Andrey Konovalov <andreyknvl@xxxxxxxxxx>
> Link: https://linux-review.googlesource.com/id/Ia114847dfb2244f297d2cb82d592bf6a07455dba
> ---
> include/linux/kasan.h | 26 ++++++++++++++++++++++++--
> mm/kasan/common.c | 11 +++++++++++
> mm/slab_common.c | 11 ++++++++---
> 3 files changed, 43 insertions(+), 5 deletions(-)
>
[...]
>
> +/*
> + * Only allow cache merging when stack collection is disabled and no metadata
> + * is present.
> + */
> +slab_flags_t __kasan_never_merge(slab_flags_t flags)
I'm getting
mm/kasan/common.c:88:14: warning: no previous prototype for ‘__kasan_never_merge’ [-Wmissing-prototypes]
for a KASAN x86 build with W=1. Presumably because if !KASAN_HW_TAGS
then this is never needed and defined static inline in the header.
> +{
> + if (kasan_stack_collection_enabled())
> + return flags;
> + return flags & ~SLAB_KASAN;
> +}
Thanks,
-- Marco