[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CA+fCnZeJ1AdvEmNmwo8r+ue0qtQVUoQyeMSsq0DMXyK2EQxj5g@mail.gmail.com>
Date: Sun, 3 Oct 2021 18:27:31 +0200
From: Andrey Konovalov <andreyknvl@...il.com>
To: "Matthew Wilcox (Oracle)" <willy@...radead.org>
Cc: Andrey Ryabinin <ryabinin.a.a@...il.com>,
Alexander Potapenko <glider@...gle.com>,
Dmitry Vyukov <dvyukov@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
kasan-dev <kasan-dev@...glegroups.com>,
Linux Memory Management List <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] kasan: Fix tag for large allocations when using CONFIG_SLAB
On Fri, Oct 1, 2021 at 4:42 AM Matthew Wilcox (Oracle)
<willy@...radead.org> wrote:
>
> If an object is allocated on a tail page of a multi-page slab, kasan
> will get the wrong tag because page->s_mem is NULL for tail pages.
> I'm not quite sure what the user-visible effect of this might be.
>
> Fixes: 7f94ffbc4c6a ("kasan: add hooks implementation for tag-based mode")
> Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
> ---
> mm/kasan/common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/kasan/common.c b/mm/kasan/common.c
> index 2baf121fb8c5..41779ad109cd 100644
> --- a/mm/kasan/common.c
> +++ b/mm/kasan/common.c
> @@ -298,7 +298,7 @@ static inline u8 assign_tag(struct kmem_cache *cache,
> /* For caches that either have a constructor or SLAB_TYPESAFE_BY_RCU: */
> #ifdef CONFIG_SLAB
> /* For SLAB assign tags based on the object index in the freelist. */
> - return (u8)obj_to_index(cache, virt_to_page(object), (void *)object);
> + return (u8)obj_to_index(cache, virt_to_head_page(object), (void *)object);
> #else
> /*
> * For SLUB assign a random tag during slab creation, otherwise reuse
> --
> 2.32.0
>
Reviewed-by: Andrey Konovalov <andreyknvl@...il.com>
Powered by blists - more mailing lists