Re: [PATCH v2 08/34] kasan: only apply __GFP_ZEROTAGS when memory is zeroed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 06, 2021 at 10:43:45PM +0100, andrey.konovalov@xxxxxxxxx wrote:
> From: Andrey Konovalov <andreyknvl@xxxxxxxxxx>
> 
> __GFP_ZEROTAGS should only be effective if memory is being zeroed.
> Currently, hardware tag-based KASAN violates this requirement.
> 
> Fix by including an initialization check along with checking for
> __GFP_ZEROTAGS.
> 
> Signed-off-by: Andrey Konovalov <andreyknvl@xxxxxxxxxx>
> Reviewed-by: Alexander Potapenko <glider@xxxxxxxxxx>
> ---
>  mm/kasan/hw_tags.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c
> index 0b8225add2e4..c643740b8599 100644
> --- a/mm/kasan/hw_tags.c
> +++ b/mm/kasan/hw_tags.c
> @@ -199,11 +199,12 @@ void kasan_alloc_pages(struct page *page, unsigned int order, gfp_t flags)
>  	 * page_alloc.c.
>  	 */
>  	bool init = !want_init_on_free() && want_init_on_alloc(flags);
> +	bool init_tags = init && (flags & __GFP_ZEROTAGS);
>  
>  	if (flags & __GFP_SKIP_KASAN_POISON)
>  		SetPageSkipKASanPoison(page);
>  
> -	if (flags & __GFP_ZEROTAGS) {
> +	if (init_tags) {

You can probably leave this unchanged but add a WARN_ON_ONCE() if !init.
AFAICT there's only a single place where __GFP_ZEROTAGS is passed.

-- 
Catalin




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux