* [PATCH v2 0/2] mm: kasan: skip KASAN for GFP_HIGHUSER
@ 2026-11-23 3:31 Jeff Xu
2026-11-23 3:31 ` [PATCH v2 1/2] " Jeff Xu
2026-11-23 3:31 ` [PATCH v2 2/2] mm/kasan/kunit: add page_alloc_skip_kasan test Jeff Xu
0 siblings, 2 replies; 5+ messages in thread
From: Jeff Xu @ 2026-11-23 3:31 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Vlastimil Babka,
Johannes Weiner, Andrey Ryabinin
Cc: Jeff Xu, Lorenzo Stoakes, Liam R . Howlett, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Zi Yan,
Alexander Potapenko, Andrey Konovalov, Dmitry Vyukov,
Vincenzo Frascino, Marco Elver, Boris Brezillon, Catalin Marinas,
Chia-I Wu, Dev Jain, Ian Rickards, Jann Horn, Jeff Vander Stoep,
Jeff Xu, Kees Cook, Mark Rutland, Peter Collingbourne,
Pierre-Clément Tosi, Ryan Roberts, Tomasz Figa, Will Deacon,
Alexander Viro, Christian Brauner, Jan Kara, Miklos Szeredi,
Baoquan He, Pasha Tatashin, Pratyush Yadav, Allison Henderson,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, linux-mm, kasan-dev, linux-arm-kernel,
linux-fsdevel, fuse-devel, kexec, netdev, linux-rdma, rds-devel,
linux-kernel
Hi all,
This series moves __GFP_SKIP_KASAN from GFP_HIGHUSER_MOVABLE to
GFP_HIGHUSER (patch 1) and adds a KUnit test for __GFP_SKIP_KASAN
(patch 2).
GFP_HIGHUSER_MOVABLE already skips KASAN tagging under
CONFIG_KASAN_HW_TAGS, whereas GFP_HIGHUSER does not despite sharing the
same userspace-allocation contract. On an Armv9.2-A device (6.12 kernel,
kasan.mode=sync), skipping KASAN on GFP_HIGHUSER cuts 32 MB
/dev/dma_heap/system alloc+free latency by ~80% and improves an
app-loading OpenGL benchmark by 15-23%. As a side effect, GFP_HIGHUSER
shmem mappings (such as drm_gem_shmem_helper / panthor [1, 2]) stop
hitting the swap-in readahead PROT_MTE tag mismatch, though the general
readahead issue for other gfp masks remains separate.
Changes since v1 [3]:
- Dropped GFP_HIGHUSER_KASAN, the pipe/FUSE/kexec/RDS conversions, and
page_alloc_highuser_kasan (v1 patches 1-4 and 7) following David
Hildenbrand's and Tomasz Figa's feedback; kept those callers on
GFP_HIGHUSER (2 patches instead of 7).
- Rewrote patch 1's commit message concisely (Lorenzo Stoakes).
- Dropped Assisted-by: trailers from the patches, keeping tool
disclosure here (Lorenzo Stoakes).
- Rebased onto mm-unstable (d12eccbcb79a).
- Kept the fs/kexec/RDS maintainers from v1 on Cc for visibility since
those patches were dropped.
Testing: built and booted both commits on arm64 with
CONFIG_KASAN_HW_TAGS under QEMU (virt,mte=on) across kasan.mode=sync,
async, and asymm (9/9 runs passed for page_alloc_skip_kasan; 3/3 failed
as expected when patch 1 was reverted, with the next test still
passing). Verified W=1 builds with 0 warnings across arm64 (HW_TAGS,
generic, SW_TAGS, no KASAN) and x86_64 (generic, no KASAN). KUnit tests
were not run on real hardware.
Tooling: an AI coding assistant was used under the author's direction to
audit GFP_HIGHUSER callers, draft the KUnit test helper and changelog
revisions, and run the QEMU/KUnit build and test matrix.
Link: https://lore.kernel.org/r/20260519-panthor-kasan-v2-1-b7384458f076@gmail.com/ [1]
Link: https://lore.kernel.org/r/20260521105148.5497c281@fedora/ [2]
Link: https://lore.kernel.org/all/20261116230627.3537051-1-jeffxu@chromium.org/ [3]
Jeff Xu (2):
mm: kasan: skip KASAN for GFP_HIGHUSER
mm/kasan/kunit: add page_alloc_skip_kasan test
include/linux/gfp_types.h | 4 ++--
mm/kasan/kasan_test_c.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 2 deletions(-)
base-commit: d12eccbcb79a4fa35c3aa588eb79056af62eb859
--
2.56.1.750.gf70dc682cf-goog
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] mm: kasan: skip KASAN for GFP_HIGHUSER
2026-11-23 3:31 [PATCH v2 0/2] mm: kasan: skip KASAN for GFP_HIGHUSER Jeff Xu
@ 2026-11-23 3:31 ` Jeff Xu
2026-11-23 8:54 ` Ryan Roberts
2026-11-23 3:31 ` [PATCH v2 2/2] mm/kasan/kunit: add page_alloc_skip_kasan test Jeff Xu
1 sibling, 1 reply; 5+ messages in thread
From: Jeff Xu @ 2026-11-23 3:31 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Vlastimil Babka,
Johannes Weiner, Andrey Ryabinin
Cc: Jeff Xu, Lorenzo Stoakes, Liam R . Howlett, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Zi Yan,
Alexander Potapenko, Andrey Konovalov, Dmitry Vyukov,
Vincenzo Frascino, Marco Elver, Boris Brezillon, Catalin Marinas,
Chia-I Wu, Dev Jain, Ian Rickards, Jann Horn, Jeff Vander Stoep,
Jeff Xu, Kees Cook, Mark Rutland, Peter Collingbourne,
Pierre-Clément Tosi, Ryan Roberts, Tomasz Figa, Will Deacon,
Alexander Viro, Christian Brauner, Jan Kara, Miklos Szeredi,
Baoquan He, Pasha Tatashin, Pratyush Yadav, Allison Henderson,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, linux-mm, kasan-dev, linux-arm-kernel,
linux-fsdevel, fuse-devel, kexec, netdev, linux-rdma, rds-devel,
linux-kernel
Move __GFP_SKIP_KASAN from GFP_HIGHUSER_MOVABLE to GFP_HIGHUSER so
non-movable userspace page allocations also skip KASAN tagging on
allocation and poisoning on free under CONFIG_KASAN_HW_TAGS.
GFP_HIGHUSER_MOVABLE already skips KASAN because user pages do not hold
kernel data structures and tagging every 16-byte MTE granule on
allocation and free is expensive. GFP_HIGHUSER has the same contract and
differs only in being non-movable, used mainly by DMA-BUF, DRM/GPU
buffers, and non-movable HugeTLB.
On an Armv9.2-A device (6.12 kernel, kasan.mode=sync), this reduces
32 MB /dev/dma_heap/system alloc+free latency by ~80% (~59% alloc, ~98%
close) and improves an app-loading OpenGL benchmark by 15-23%.
Callers that access GFP_HIGHUSER pages through kmap_local_page() or
page_address() (such as ramfs, pipe/FUSE buffers, kexec, and RDS) lose
HW_TAGS checking on those pages. None of them store kernel structs
there; this matches the trade-off already made for GFP_HIGHUSER_MOVABLE.
Generic and SW_TAGS KASAN are unaffected.
Signed-off-by: Jeff Xu <jeffxu@chromium.org>
---
include/linux/gfp_types.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/gfp_types.h b/include/linux/gfp_types.h
index c1331bf0b239..bb54c7abfb02 100644
--- a/include/linux/gfp_types.h
+++ b/include/linux/gfp_types.h
@@ -376,8 +376,8 @@ enum {
#define GFP_USER (__GFP_RECLAIM | __GFP_IO | __GFP_FS | __GFP_HARDWALL)
#define GFP_DMA __GFP_DMA
#define GFP_DMA32 __GFP_DMA32
-#define GFP_HIGHUSER (GFP_USER | __GFP_HIGHMEM)
-#define GFP_HIGHUSER_MOVABLE (GFP_HIGHUSER | __GFP_MOVABLE | __GFP_SKIP_KASAN)
+#define GFP_HIGHUSER (GFP_USER | __GFP_HIGHMEM | __GFP_SKIP_KASAN)
+#define GFP_HIGHUSER_MOVABLE (GFP_HIGHUSER | __GFP_MOVABLE)
#define GFP_TRANSHUGE_LIGHT ((GFP_HIGHUSER_MOVABLE | __GFP_COMP | \
__GFP_NOMEMALLOC | __GFP_NOWARN) & ~__GFP_RECLAIM)
#define GFP_TRANSHUGE (GFP_TRANSHUGE_LIGHT | __GFP_DIRECT_RECLAIM)
base-commit: d12eccbcb79a4fa35c3aa588eb79056af62eb859
--
2.56.1.750.gf70dc682cf-goog
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] mm/kasan/kunit: add page_alloc_skip_kasan test
2026-11-23 3:31 [PATCH v2 0/2] mm: kasan: skip KASAN for GFP_HIGHUSER Jeff Xu
2026-11-23 3:31 ` [PATCH v2 1/2] " Jeff Xu
@ 2026-11-23 3:31 ` Jeff Xu
2026-11-23 8:58 ` Ryan Roberts
1 sibling, 1 reply; 5+ messages in thread
From: Jeff Xu @ 2026-11-23 3:31 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Vlastimil Babka,
Johannes Weiner, Andrey Ryabinin
Cc: Jeff Xu, Lorenzo Stoakes, Liam R . Howlett, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Zi Yan,
Alexander Potapenko, Andrey Konovalov, Dmitry Vyukov,
Vincenzo Frascino, Marco Elver, Boris Brezillon, Catalin Marinas,
Chia-I Wu, Dev Jain, Ian Rickards, Jann Horn, Jeff Vander Stoep,
Jeff Xu, Kees Cook, Mark Rutland, Peter Collingbourne,
Pierre-Clément Tosi, Ryan Roberts, Tomasz Figa, Will Deacon,
Alexander Viro, Christian Brauner, Jan Kara, Miklos Szeredi,
Baoquan He, Pasha Tatashin, Pratyush Yadav, Allison Henderson,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, linux-mm, kasan-dev, linux-arm-kernel,
linux-fsdevel, fuse-devel, kexec, netdev, linux-rdma, rds-devel,
linux-kernel
Add a KUnit test (page_alloc_skip_kasan) to verify that page allocations
using __GFP_SKIP_KASAN (GFP_KERNEL | __GFP_SKIP_KASAN, GFP_HIGHUSER, and
GFP_HIGHUSER_MOVABLE) under CONFIG_KASAN_HW_TAGS:
1. Reset page_kasan_tag() to KASAN_TAG_KERNEL (0xff) across all sub-pages
of a high-order allocation, and
2. Return a match-all (0xff) linear-map pointer from page_address() that
does not trigger a KASAN fault even when the underlying physical
granules carry a mismatched tag (such as KASAN_TAG_INVALID or
restored userspace PROT_MTE tags).
Tested on arm64 with CONFIG_KASAN_HW_TAGS under QEMU (virt,mte=on) with
kasan.mode=sync, async and asymm.
Signed-off-by: Jeff Xu <jeffxu@chromium.org>
---
mm/kasan/kasan_test_c.c | 44 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/mm/kasan/kasan_test_c.c b/mm/kasan/kasan_test_c.c
index f34163e19bd6..72342137bb18 100644
--- a/mm/kasan/kasan_test_c.c
+++ b/mm/kasan/kasan_test_c.c
@@ -380,6 +380,49 @@ static void page_alloc_uaf(struct kunit *test)
KUNIT_EXPECT_KASAN_FAIL_READ(test, ((volatile char *)ptr)[0]);
}
+static void page_alloc_skip_kasan_helper(struct kunit *test, gfp_t gfp)
+{
+ struct page *pages;
+ size_t order = 2;
+ char *ptr;
+ size_t i;
+
+ pages = alloc_pages(gfp, order);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pages);
+
+ for (i = 0; i < (1UL << order); i++) {
+ /*
+ * __GFP_SKIP_KASAN allocations must carry the match-all tag
+ * in page->flags, and so in page_address(), not a random tag.
+ */
+ KUNIT_EXPECT_EQ(test, page_kasan_tag(pages + i),
+ (u8)KASAN_TAG_KERNEL);
+
+ ptr = page_address(pages + i);
+ KUNIT_EXPECT_EQ(test, (u8)get_tag(ptr), (u8)KASAN_TAG_KERNEL);
+
+ /*
+ * The memory tags of such pages are arbitrary: stale poison,
+ * or tags set by userspace through PROT_MTE. Accesses via
+ * page_address() must not fault regardless.
+ */
+ kasan_poison(ptr, PAGE_SIZE, KASAN_TAG_INVALID, false);
+ KUNIT_EXPECT_KASAN_RESULT(test, WRITE_ONCE(*ptr, 0),
+ "WRITE_ONCE(*ptr, 0)", false);
+ }
+
+ __free_pages(pages, order);
+}
+
+static void page_alloc_skip_kasan(struct kunit *test)
+{
+ KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_KASAN_HW_TAGS);
+
+ page_alloc_skip_kasan_helper(test, GFP_KERNEL | __GFP_SKIP_KASAN);
+ page_alloc_skip_kasan_helper(test, GFP_HIGHUSER);
+ page_alloc_skip_kasan_helper(test, GFP_HIGHUSER_MOVABLE);
+}
+
static void krealloc_more_oob_helper(struct kunit *test,
size_t size1, size_t size2)
{
@@ -2369,6 +2412,7 @@ static struct kunit_case kasan_kunit_test_cases[] = {
KUNIT_CASE(kmalloc_large_invalid_free),
KUNIT_CASE(page_alloc_oob_right),
KUNIT_CASE(page_alloc_uaf),
+ KUNIT_CASE(page_alloc_skip_kasan),
KUNIT_CASE(krealloc_more_oob),
KUNIT_CASE(krealloc_less_oob),
KUNIT_CASE(krealloc_large_more_oob),
--
2.56.1.750.gf70dc682cf-goog
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] mm: kasan: skip KASAN for GFP_HIGHUSER
2026-11-23 3:31 ` [PATCH v2 1/2] " Jeff Xu
@ 2026-11-23 8:54 ` Ryan Roberts
0 siblings, 0 replies; 5+ messages in thread
From: Ryan Roberts @ 2026-11-23 8:54 UTC (permalink / raw)
To: Jeff Xu, Andrew Morton, David Hildenbrand, Vlastimil Babka,
Johannes Weiner, Andrey Ryabinin
Cc: Lorenzo Stoakes, Liam R . Howlett, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Zi Yan,
Alexander Potapenko, Andrey Konovalov, Dmitry Vyukov,
Vincenzo Frascino, Marco Elver, Boris Brezillon, Catalin Marinas,
Chia-I Wu, Dev Jain, Ian Rickards, Jann Horn, Jeff Vander Stoep,
Jeff Xu, Kees Cook, Mark Rutland, Peter Collingbourne,
Pierre-Clément Tosi, Tomasz Figa, Will Deacon,
Alexander Viro, Christian Brauner, Jan Kara, Miklos Szeredi,
Baoquan He, Pasha Tatashin, Pratyush Yadav, Allison Henderson,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, linux-mm, kasan-dev, linux-arm-kernel,
linux-fsdevel, fuse-devel, kexec, netdev, linux-rdma, rds-devel,
linux-kernel
On 23/11/2026 03:31, Jeff Xu wrote:
> Move __GFP_SKIP_KASAN from GFP_HIGHUSER_MOVABLE to GFP_HIGHUSER so
> non-movable userspace page allocations also skip KASAN tagging on
> allocation and poisoning on free under CONFIG_KASAN_HW_TAGS.
>
> GFP_HIGHUSER_MOVABLE already skips KASAN because user pages do not hold
> kernel data structures and tagging every 16-byte MTE granule on
> allocation and free is expensive. GFP_HIGHUSER has the same contract and
> differs only in being non-movable, used mainly by DMA-BUF, DRM/GPU
> buffers, and non-movable HugeTLB.
>
> On an Armv9.2-A device (6.12 kernel, kasan.mode=sync), this reduces
> 32 MB /dev/dma_heap/system alloc+free latency by ~80% (~59% alloc, ~98%
> close) and improves an app-loading OpenGL benchmark by 15-23%.
>
> Callers that access GFP_HIGHUSER pages through kmap_local_page() or
> page_address() (such as ramfs, pipe/FUSE buffers, kexec, and RDS) lose
> HW_TAGS checking on those pages. None of them store kernel structs
> there; this matches the trade-off already made for GFP_HIGHUSER_MOVABLE.
> Generic and SW_TAGS KASAN are unaffected.
>
> Signed-off-by: Jeff Xu <jeffxu@chromium.org>
LGTM; I agree with your assessment of the risk.
We have seen poisoning pages at free-time being a performance bottleneck because
the tags are kept inline with data in the cache, and setting the tags therefore
causes hot data to be evicted to bring in the cold data just to set the tags. We
had been experimenting with the concept of "elide poison on free" for "in-kernel
MTE enabled in production" use cases to solve this. But the security analysis is
a bit complex.
I anticipate that your change is probably solving most of the same performance
cost in a much more straightforward manner. I'm guessing these DMA/DRM/GPU
buffers are the largest in-kernel memory allocators for the Android app start
use case.
Reviewed-by: Ryan Roberts <ryan.roberts@arm.com>
> ---
> include/linux/gfp_types.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/gfp_types.h b/include/linux/gfp_types.h
> index c1331bf0b239..bb54c7abfb02 100644
> --- a/include/linux/gfp_types.h
> +++ b/include/linux/gfp_types.h
> @@ -376,8 +376,8 @@ enum {
> #define GFP_USER (__GFP_RECLAIM | __GFP_IO | __GFP_FS | __GFP_HARDWALL)
> #define GFP_DMA __GFP_DMA
> #define GFP_DMA32 __GFP_DMA32
> -#define GFP_HIGHUSER (GFP_USER | __GFP_HIGHMEM)
> -#define GFP_HIGHUSER_MOVABLE (GFP_HIGHUSER | __GFP_MOVABLE | __GFP_SKIP_KASAN)
> +#define GFP_HIGHUSER (GFP_USER | __GFP_HIGHMEM | __GFP_SKIP_KASAN)
> +#define GFP_HIGHUSER_MOVABLE (GFP_HIGHUSER | __GFP_MOVABLE)
> #define GFP_TRANSHUGE_LIGHT ((GFP_HIGHUSER_MOVABLE | __GFP_COMP | \
> __GFP_NOMEMALLOC | __GFP_NOWARN) & ~__GFP_RECLAIM)
> #define GFP_TRANSHUGE (GFP_TRANSHUGE_LIGHT | __GFP_DIRECT_RECLAIM)
>
> base-commit: d12eccbcb79a4fa35c3aa588eb79056af62eb859
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] mm/kasan/kunit: add page_alloc_skip_kasan test
2026-11-23 3:31 ` [PATCH v2 2/2] mm/kasan/kunit: add page_alloc_skip_kasan test Jeff Xu
@ 2026-11-23 8:58 ` Ryan Roberts
0 siblings, 0 replies; 5+ messages in thread
From: Ryan Roberts @ 2026-11-23 8:58 UTC (permalink / raw)
To: Jeff Xu, Andrew Morton, David Hildenbrand, Vlastimil Babka,
Johannes Weiner, Andrey Ryabinin
Cc: Lorenzo Stoakes, Liam R . Howlett, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Zi Yan,
Alexander Potapenko, Andrey Konovalov, Dmitry Vyukov,
Vincenzo Frascino, Marco Elver, Boris Brezillon, Catalin Marinas,
Chia-I Wu, Dev Jain, Ian Rickards, Jann Horn, Jeff Vander Stoep,
Jeff Xu, Kees Cook, Mark Rutland, Peter Collingbourne,
Pierre-Clément Tosi, Tomasz Figa, Will Deacon,
Alexander Viro, Christian Brauner, Jan Kara, Miklos Szeredi,
Baoquan He, Pasha Tatashin, Pratyush Yadav, Allison Henderson,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, linux-mm, kasan-dev, linux-arm-kernel,
linux-fsdevel, fuse-devel, kexec, netdev, linux-rdma, rds-devel,
linux-kernel
On 23/11/2026 03:31, Jeff Xu wrote:
> Add a KUnit test (page_alloc_skip_kasan) to verify that page allocations
> using __GFP_SKIP_KASAN (GFP_KERNEL | __GFP_SKIP_KASAN, GFP_HIGHUSER, and
> GFP_HIGHUSER_MOVABLE) under CONFIG_KASAN_HW_TAGS:
>
> 1. Reset page_kasan_tag() to KASAN_TAG_KERNEL (0xff) across all sub-pages
> of a high-order allocation, and
> 2. Return a match-all (0xff) linear-map pointer from page_address() that
> does not trigger a KASAN fault even when the underlying physical
> granules carry a mismatched tag (such as KASAN_TAG_INVALID or
> restored userspace PROT_MTE tags).
>
> Tested on arm64 with CONFIG_KASAN_HW_TAGS under QEMU (virt,mte=on) with
> kasan.mode=sync, async and asymm.
>
> Signed-off-by: Jeff Xu <jeffxu@chromium.org>
Reviewed-by: Ryan Roberts <ryan.roberts@arm.com>
> ---
> mm/kasan/kasan_test_c.c | 44 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/mm/kasan/kasan_test_c.c b/mm/kasan/kasan_test_c.c
> index f34163e19bd6..72342137bb18 100644
> --- a/mm/kasan/kasan_test_c.c
> +++ b/mm/kasan/kasan_test_c.c
> @@ -380,6 +380,49 @@ static void page_alloc_uaf(struct kunit *test)
> KUNIT_EXPECT_KASAN_FAIL_READ(test, ((volatile char *)ptr)[0]);
> }
>
> +static void page_alloc_skip_kasan_helper(struct kunit *test, gfp_t gfp)
> +{
> + struct page *pages;
> + size_t order = 2;
> + char *ptr;
> + size_t i;
> +
> + pages = alloc_pages(gfp, order);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pages);
> +
> + for (i = 0; i < (1UL << order); i++) {
> + /*
> + * __GFP_SKIP_KASAN allocations must carry the match-all tag
> + * in page->flags, and so in page_address(), not a random tag.
> + */
> + KUNIT_EXPECT_EQ(test, page_kasan_tag(pages + i),
> + (u8)KASAN_TAG_KERNEL);
> +
> + ptr = page_address(pages + i);
> + KUNIT_EXPECT_EQ(test, (u8)get_tag(ptr), (u8)KASAN_TAG_KERNEL);
> +
> + /*
> + * The memory tags of such pages are arbitrary: stale poison,
> + * or tags set by userspace through PROT_MTE. Accesses via
> + * page_address() must not fault regardless.
> + */
> + kasan_poison(ptr, PAGE_SIZE, KASAN_TAG_INVALID, false);
> + KUNIT_EXPECT_KASAN_RESULT(test, WRITE_ONCE(*ptr, 0),
> + "WRITE_ONCE(*ptr, 0)", false);
> + }
> +
> + __free_pages(pages, order);
> +}
> +
> +static void page_alloc_skip_kasan(struct kunit *test)
> +{
> + KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_KASAN_HW_TAGS);
> +
> + page_alloc_skip_kasan_helper(test, GFP_KERNEL | __GFP_SKIP_KASAN);
> + page_alloc_skip_kasan_helper(test, GFP_HIGHUSER);
> + page_alloc_skip_kasan_helper(test, GFP_HIGHUSER_MOVABLE);
> +}
> +
> static void krealloc_more_oob_helper(struct kunit *test,
> size_t size1, size_t size2)
> {
> @@ -2369,6 +2412,7 @@ static struct kunit_case kasan_kunit_test_cases[] = {
> KUNIT_CASE(kmalloc_large_invalid_free),
> KUNIT_CASE(page_alloc_oob_right),
> KUNIT_CASE(page_alloc_uaf),
> + KUNIT_CASE(page_alloc_skip_kasan),
> KUNIT_CASE(krealloc_more_oob),
> KUNIT_CASE(krealloc_less_oob),
> KUNIT_CASE(krealloc_large_more_oob),
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-23 8:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 3:31 [PATCH v2 0/2] mm: kasan: skip KASAN for GFP_HIGHUSER Jeff Xu
2026-11-23 3:31 ` [PATCH v2 1/2] " Jeff Xu
2026-11-23 8:54 ` Ryan Roberts
2026-11-23 3:31 ` [PATCH v2 2/2] mm/kasan/kunit: add page_alloc_skip_kasan test Jeff Xu
2026-11-23 8:58 ` Ryan Roberts
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®