Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dev Jain <dev.jain@arm.com>
To: Hui Zhu <hui.zhu@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	Uladzislau Rezki <urezki@gmail.com>,
	Nicholas Piggin <npiggin@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Hui Zhu <zhuhui@kylinos.cn>
Subject: Re: [PATCH] vmalloc: Fix NULL pointer dereference in is_vm_area_hugepages()
Date: Fri, 29 May 2026 10:24:12 +0530	[thread overview]
Message-ID: <cb2b4151-e096-4de5-a064-ee3bfa8cdc2c@arm.com> (raw)
In-Reply-To: <20260529014130.671291-1-hui.zhu@linux.dev>



On 29/05/26 7:11 am, Hui Zhu wrote:
> From: Hui Zhu <zhuhui@kylinos.cn>
> 
> find_vm_area() can return NULL if the given address is not a valid
> vmalloc area. Check the return value before dereferencing it to avoid
> a kernel crash.
> 
> Fixes: 121e6f3258fe ("mm/vmalloc: hugepage vmalloc mappings")
> Signed-off-by: Hui Zhu <zhuhui@kylinos.cn>
> ---

I think this makes sense from API PoV.

Reviewed-by: Dev Jain <dev.jain@arm.com>

>  include/linux/vmalloc.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
> index 3b02c0c6b371..d87dc7f77f4e 100644
> --- a/include/linux/vmalloc.h
> +++ b/include/linux/vmalloc.h
> @@ -265,7 +265,9 @@ static inline bool is_vm_area_hugepages(const void *addr)
>  	 * allocated in the vmalloc layer.
>  	 */
>  #ifdef CONFIG_HAVE_ARCH_HUGE_VMALLOC
> -	return find_vm_area(addr)->page_order > 0;
> +	struct vm_struct *area = find_vm_area(addr);
> +
> +	return area && area->page_order > 0;
>  #else
>  	return false;
>  #endif



  reply	other threads:[~2026-05-29  4:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29  1:41 [PATCH] vmalloc: Fix NULL pointer dereference in is_vm_area_hugepages() Hui Zhu
2026-05-29  4:54 ` Dev Jain [this message]
2026-06-01  9:29   ` Uladzislau Rezki

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=cb2b4151-e096-4de5-a064-ee3bfa8cdc2c@arm.com \
    --to=dev.jain@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=hui.zhu@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=npiggin@gmail.com \
    --cc=urezki@gmail.com \
    --cc=zhuhui@kylinos.cn \
    /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