From: Dev Jain <dev.jain@arm.com>
To: akpm@linux-foundation.org, vbabka@kernel.org, harry@kernel.org,
ryabinin.a.a@gmail.com
Cc: surenb@google.com, mhocko@suse.com, jackmanb@google.com,
hannes@cmpxchg.org, ziy@nvidia.com, hao.li@linux.dev,
cl@gentwo.org, rientjes@google.com, roman.gushchin@linux.dev,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
glider@google.com, andreyknvl@gmail.com, dvyukov@google.com,
vincenzo.frascino@arm.com, kasan-dev@googlegroups.com,
ryan.roberts@arm.com, anshuman.khandual@arm.com,
catalin.marinas@arm.com
Subject: Re: [PATCH 3/3] vmalloc: hw_tags: optimize vmalloc redzoning
Date: Tue, 19 May 2026 13:05:44 +0530 [thread overview]
Message-ID: <fe2b977d-3a24-4322-a0e8-b91d67b15d26@arm.com> (raw)
In-Reply-To: <20260513105734.3380544-4-dev.jain@arm.com>
On 13/05/26 4:27 pm, Dev Jain wrote:
> If the allocation size is less than a page, vmalloc first unpoisons the
> entire page, then poisons the tail with KASAN_TAG_INVALID (for hw tags),
> to catch OOB.
>
> Instead, unpoison the allocation length, and then poison the tail,
> saving some work.
My bad, I see that the actual allocation size (and not page-aligned size)
is passed down to kasan_unpoison_vmalloc, so this patch is a no-op.
I'll drop it.
>
> Signed-off-by: Dev Jain <dev.jain@arm.com>
> ---
> mm/kasan/hw_tags.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c
> index cbef5e450954..7c94f71b5f12 100644
> --- a/mm/kasan/hw_tags.c
> +++ b/mm/kasan/hw_tags.c
> @@ -364,9 +364,6 @@ void *__kasan_unpoison_vmalloc(const void *start, unsigned long size,
> tag = (flags & KASAN_VMALLOC_KEEP_TAG) ? get_tag(start) : kasan_random_tag();
> start = set_tag(start, tag);
>
> - /* Unpoison and initialize memory up to size. */
> - kasan_unpoison(start, size, flags & KASAN_VMALLOC_INIT);
> -
> /*
> * Explicitly poison and initialize the in-page vmalloc() redzone.
> * Unlike software KASAN modes, hardware tag-based KASAN doesn't
> @@ -375,8 +372,14 @@ void *__kasan_unpoison_vmalloc(const void *start, unsigned long size,
> redzone_start = round_up((unsigned long)start + size,
> KASAN_GRANULE_SIZE);
> redzone_size = round_up(redzone_start, PAGE_SIZE) - redzone_start;
> - kasan_poison((void *)redzone_start, redzone_size, KASAN_TAG_INVALID,
> - flags & KASAN_VMALLOC_INIT);
> +
> + /* Unpoison and initialize memory before the redzone. */
> + kasan_unpoison(start, redzone_start - (unsigned long)start,
> + flags & KASAN_VMALLOC_INIT);
> +
> + if (redzone_size)
> + kasan_poison((void *)redzone_start, redzone_size,
> + KASAN_TAG_INVALID, flags & KASAN_VMALLOC_INIT);
>
> /*
> * Set per-page tag flags to allow accessing physical memory for the
next prev parent reply other threads:[~2026-05-19 7:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 10:57 [PATCH 0/3] kasan: hw_tags: some micro-optimizations Dev Jain
2026-05-13 10:57 ` [PATCH 1/3] mm/slub: hw_tags: skip page-allocator unpoisoning on slab allocation Dev Jain
2026-05-14 12:11 ` Ryan Roberts
2026-05-15 7:04 ` Dev Jain
2026-05-13 10:57 ` [PATCH 2/3] kasan: avoid re-poisoning tag-based kmalloc redzones Dev Jain
2026-05-19 8:15 ` Dev Jain
2026-05-19 8:53 ` Ryan Roberts
2026-05-20 7:02 ` Dev Jain
2026-05-20 8:33 ` Dev Jain
2026-05-20 4:32 ` Dev Jain
2026-05-13 10:57 ` [PATCH 3/3] vmalloc: hw_tags: optimize vmalloc redzoning Dev Jain
2026-05-19 7:35 ` Dev Jain [this message]
2026-05-14 9:56 ` [PATCH 0/3] kasan: hw_tags: some micro-optimizations Harry Yoo (Oracle)
2026-05-14 10:22 ` Dev Jain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fe2b977d-3a24-4322-a0e8-b91d67b15d26@arm.com \
--to=dev.jain@arm.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=anshuman.khandual@arm.com \
--cc=catalin.marinas@arm.com \
--cc=cl@gentwo.org \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=hannes@cmpxchg.org \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=jackmanb@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=ryabinin.a.a@gmail.com \
--cc=ryan.roberts@arm.com \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=vincenzo.frascino@arm.com \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®