From: Will Deacon <will@kernel.org>
To: Maciej Wieczor-Retman <m.wieczorretman@pm.me>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>,
Alexander Potapenko <glider@google.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
Dmitry Vyukov <dvyukov@google.com>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@redhat.com>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
Vlastimil Babka <vbabka@suse.cz>, Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Samuel Holland <samuel.holland@sifive.com>,
Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>,
linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com,
linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org
Subject: Re: [PATCH v7 02/15] kasan: arm64: x86: Make special tags arch specific
Date: Thu, 8 Jan 2026 17:56:39 +0000 [thread overview]
Message-ID: <aV_v18YWCHXMETVK@willie-the-truck> (raw)
In-Reply-To: <0db7ec3b1a813b4d9e3aa8648b3c212166a248b7.1765386422.git.m.wieczorretman@pm.me>
On Wed, Dec 10, 2025 at 05:28:43PM +0000, Maciej Wieczor-Retman wrote:
> From: Samuel Holland <samuel.holland@sifive.com>
>
> KASAN's tag-based mode defines multiple special tag values. They're
> reserved for:
> - Native kernel value. On arm64 it's 0xFF and it causes an early return
> in the tag checking function.
> - Invalid value. 0xFE marks an area as freed / unallocated. It's also
> the value that is used to initialize regions of shadow memory.
> - Min and max values. 0xFD is the highest value that can be randomly
> generated for a new tag. 0 is the minimal value with the exception of
> arm64's hardware mode where it is equal to 0xF0.
>
> Metadata macro is also defined:
> - Tag width equal to 8.
>
> Tag-based mode on x86 is going to use 4 bit wide tags so all the above
> values need to be changed accordingly.
>
> Make tag width and native kernel tag arch specific for x86 and arm64.
>
> Base the invalid tag value and the max value on the native kernel tag
> since they follow the same pattern on both mentioned architectures.
>
> Also generalize KASAN_SHADOW_INIT and 0xff used in various
> page_kasan_tag* helpers.
>
> Give KASAN_TAG_MIN the default value of zero, and move the special value
> for hw_tags arm64 to its arch specific kasan-tags.h.
>
> Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
> Co-developed-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
> Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
> ---
> Changelog v7:
> - Reorder defines of arm64 tag width to prevent redefinition warnings.
> - Remove KASAN_TAG_MASK so it's only defined in mmzone.h (Andrey
> Konovalov)
> - Merge the 'support tag widths less than 8 bits' with this patch since
> they do similar things and overwrite each other. (Alexander)
>
> Changelog v6:
> - Add hardware tags KASAN_TAG_WIDTH value to the arm64 arch file.
> - Keep KASAN_TAG_MASK in the mmzone.h.
> - Remove ifndef from KASAN_SHADOW_INIT.
>
> Changelog v5:
> - Move KASAN_TAG_MIN to the arm64 kasan-tags.h for the hardware KASAN
> mode case.
>
> Changelog v4:
> - Move KASAN_TAG_MASK to kasan-tags.h.
>
> Changelog v2:
> - Remove risc-v from the patch.
>
> MAINTAINERS | 2 +-
> arch/arm64/include/asm/kasan-tags.h | 14 ++++++++++++++
> arch/arm64/include/asm/kasan.h | 2 --
> arch/arm64/include/asm/uaccess.h | 1 +
> arch/x86/include/asm/kasan-tags.h | 9 +++++++++
> include/linux/kasan-tags.h | 19 ++++++++++++++-----
> include/linux/kasan.h | 3 +--
> include/linux/mm.h | 6 +++---
> include/linux/page-flags-layout.h | 9 +--------
> 9 files changed, 44 insertions(+), 21 deletions(-)
> create mode 100644 arch/arm64/include/asm/kasan-tags.h
> create mode 100644 arch/x86/include/asm/kasan-tags.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 7bf6385efe04..a591598cc4b5 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -13420,7 +13420,7 @@ L: kasan-dev@googlegroups.com
> S: Maintained
> B: https://bugzilla.kernel.org/buglist.cgi?component=Sanitizers&product=Memory%20Management
> F: Documentation/dev-tools/kasan.rst
> -F: arch/*/include/asm/*kasan.h
> +F: arch/*/include/asm/*kasan*.h
> F: arch/*/mm/kasan_init*
> F: include/linux/kasan*.h
> F: lib/Kconfig.kasan
> diff --git a/arch/arm64/include/asm/kasan-tags.h b/arch/arm64/include/asm/kasan-tags.h
> new file mode 100644
> index 000000000000..259952677443
> --- /dev/null
> +++ b/arch/arm64/include/asm/kasan-tags.h
> @@ -0,0 +1,14 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef __ASM_KASAN_TAGS_H
> +#define __ASM_KASAN_TAGS_H
> +
> +#define KASAN_TAG_KERNEL 0xFF /* native kernel pointers tag */
> +
> +#ifdef CONFIG_KASAN_HW_TAGS
> +#define KASAN_TAG_MIN 0xF0 /* minimum value for random tags */
> +#define KASAN_TAG_WIDTH 4
> +#else
> +#define KASAN_TAG_WIDTH 8
> +#endif
Shouldn't this be 0 when KASAN is not in use at all?
Will
next prev parent reply other threads:[~2026-01-08 17:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-10 17:14 [PATCH v7 00/15] kasan: x86: arm64: KASAN tag-based mode for x86 Maciej Wieczor-Retman
2025-12-10 17:28 ` [PATCH v7 01/15] kasan: sw_tags: Use arithmetic shift for shadow computation Maciej Wieczor-Retman
2025-12-10 17:28 ` [PATCH v7 02/15] kasan: arm64: x86: Make special tags arch specific Maciej Wieczor-Retman
2026-01-08 17:56 ` Will Deacon [this message]
2026-01-09 13:37 ` Maciej Wieczor-Retman
2026-01-09 13:43 ` Will Deacon
2025-12-10 17:29 ` [PATCH v7 04/15] x86/kasan: Add arch specific kasan functions Maciej Wieczor-Retman
2025-12-10 17:29 ` [PATCH v7 06/15] mm/execmem: Untag addresses in EXECMEM_ROX related pointer arithmetic Maciej Wieczor-Retman
2025-12-10 17:30 ` [PATCH v7 14/15] x86/kasan: Logical bit shift for kasan_mem_to_shadow Maciej Wieczor-Retman
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=aV_v18YWCHXMETVK@willie-the-truck \
--to=will@kernel.org \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=dave.hansen@linux.intel.com \
--cc=david@redhat.com \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=hpa@zytor.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=m.wieczorretman@pm.me \
--cc=maciej.wieczor-retman@intel.com \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=rppt@kernel.org \
--cc=ryabinin.a.a@gmail.com \
--cc=samuel.holland@sifive.com \
--cc=surenb@google.com \
--cc=tglx@linutronix.de \
--cc=vbabka@suse.cz \
--cc=vincenzo.frascino@arm.com \
--cc=x86@kernel.org \
/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