Re: [PATCH v1 0/7] mm: kasan: skip KASAN for GFP_HIGHUSER
From: Jeff Xu
Date: Tue Nov 17 2026 - 20:29:14 EST
On Tue, Nov 17, 2026 at 11:11 PM Tomasz Figa <tfiga@xxxxxxxxxxxx> wrote:
>
> On Tue, Nov 17, 2026 at 7:10 PM David Hildenbrand (Arm)
> <david@xxxxxxxxxx> wrote:
> >
> > I really don't want us to spread KASAN-related GFP flags in the kernel.
> >
> > There must be a proper way to abstract this.
> >
> > Why is GFP_HIGHUSER not sufficient? We were already told that this is memory to
> > be mapped into user space. Placing data structure on it and handing out pointers
> > to that would already be a bit questionable.
> >
> > So what are the ways to avoid GFP_HIGHUSER_KASAN?
>
> I think the idea behind GFP_HIGHUSER_KASAN is to make it possible to
> skip KASAN for GFP_HIGHUSER by default (for most of its users), but
> keep it for some of the users which today use GFP_HIGHUSER for their
> memory allocations, but could benefit from the added security. As per
> the other patches in the series:
>
> pipe, fuse: use GFP_HIGHUSER_KASAN for pipe buffer pages
> kexec: use GFP_HIGHUSER_KASAN for segment pages
> net/rds: use GFP_HIGHUSER_KASAN for message pages
>
> That said, I'm not familiar with any of the code mentioned by those
> patches, so I can't really tell how much they would benefit from KASAN
> or if their choice of GFP_HIGHUSER to begin with is correct.
Thanks David and Tomasz for the feedback.
Tomasz is right about why I added GFP_HIGHUSER_KASAN in v1: out of
caution, I audited existing GFP_HIGHUSER callers to find any that never
map the pages to userspace and instead fill/drain them in the kernel via
kmap_local_page() (pipe, FUSE, kexec, rds). Since this series intends to
improve KASAN performance while preserving its security aspects, and the
performance impact on pipe/FUSE/kexec/rds was negligible in my testing,
v1 was optimized for minimum behavioral change.
Looking closer at both of your questions, I agree that the security
benefit of keeping those 4 under KASAN is minimal -- e.g., only linear
overflows out of the pipe/FUSE/kexec/rds page, since none of them store
kernel structures or pointers. That is the exact same trade-off we
already make for GFP_HIGHUSER_MOVABLE.
To avoid introducing GFP_HIGHUSER_KASAN, I see two options:
1) Simply keep those 4 cases under GFP_HIGHUSER (drop patches 1-4 and
7), reducing the series to just the GFP_HIGHUSER change and its KUnit
test.
2) Switch those 4 callers to GFP_USER. Since CONFIG_KASAN_HW_TAGS is
64-bit arm64 only (!CONFIG_HIGHMEM), GFP_USER is identical to today's
GFP_HIGHUSER on arm64 and all other 64-bit builds (and if 32-bit
CONFIG_HIGHMEM=y builds still need ZONE_HIGHMEM, that could be gated
on CONFIG_HIGHMEM, though that feels ugly at call sites).
(1) seems much cleaner to me. David, would (1) work for you?
Thanks,
Jeff