Re: [PATCH v2 1/2] mm: kasan: skip KASAN for GFP_HIGHUSER

From: Jeff Xu

Date: Tue Nov 24 2026 - 14:55:10 EST


On Tue, Nov 24, 2026 at 09:10:53AM +0100, David Hildenbrand (Arm) wrote:
> On 11/23/26 04:31, Jeff Xu wrote:
> > -#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)
>
> Can we please add a big fat comment above GFP_HIGHUSER, explaining why we use
> __GFP_SKIP_KASAN and which security impact this has?

Sure, I'll add a comment above GFP_HIGHUSER in v3:

/*
* GFP_HIGHUSER (and GFP_HIGHUSER_MOVABLE derived from it) sets
* __GFP_SKIP_KASAN to skip HW_TAGS tagging on allocation and poisoning on
* free. These pages are meant for userspace data (e.g. anonymous and page
* cache pages, DMA-BUF, GPU/DRM buffers) rather than kernel data structures,
* and tagging every granule on allocation and free is expensive.
*
* Security impact: under CONFIG_KASAN_HW_TAGS, these pages carry the
* match-all tag (0xff), so kernel accesses via page_address() or
* kmap_local_page() lose HW_TAGS out-of-bounds and use-after-free
* detection. Callers that store kernel data structures in these pages
* should not use GFP_HIGHUSER. Generic and SW_TAGS KASAN are unaffected.
*/

Thanks,
Jeff