From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A097B38C2A9 for ; Fri, 29 May 2026 04:54:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780030463; cv=none; b=Jaf7Fx/wvUQWdakyJJqUmKtH7alHzHaZERC+5Ne0MuSxJ4XZXP4VHy3FLxRo5HCl0qcRFfdcezN7XvsQQMNbLAur92jJlrbgbehSU0EIENYOJwJO3HMYWiN7/7E/fXBZfdiokYZEVIjPDQUeGYVIq3U6Qy6LzypNzfUtTYEKhJk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780030463; c=relaxed/simple; bh=9ZeCdBi+o6rNm0JaiPfWqhFJAJ+0UGMwKBp+YQQgMao=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FPgWp6qEwrO2toEuGSoHNwL7lzeWErnDHU3npaOfC7GdHfrBvuf8xfQD5IDC7WIefObpNgUe0Cdz9EOR+/RkOj1Ai18TAGfBNnEOU27rBR5eVJ32N+XgYvYfINg3V2L0q6AXmlvq10UtScM69YdpGwK/bNF+2y75KfcwdsYCQiQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=HyJ4vwp5; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="HyJ4vwp5" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C728D22EE; Thu, 28 May 2026 21:54:12 -0700 (PDT) Received: from [10.164.19.8] (unknown [10.164.19.8]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7FD753F632; Thu, 28 May 2026 21:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1780030457; bh=9ZeCdBi+o6rNm0JaiPfWqhFJAJ+0UGMwKBp+YQQgMao=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=HyJ4vwp51VA+tyI509PRHllcQY2Yp6pbcF7a9QbRTNIwW8DrrHeR7zZBFwPOr2yiS JqIgVnEOUZsMNvv5VRH5nD5q+5mmY6zX6vzG3uzwe7y9YrOwTqgkT3bFDPQTZiXN+P 3zC8Dfzyf0L4mBABE36fGYRXsAUP0N1GqG9j0nT0= Message-ID: Date: Fri, 29 May 2026 10:24:12 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] vmalloc: Fix NULL pointer dereference in is_vm_area_hugepages() To: Hui Zhu , Andrew Morton , Uladzislau Rezki , Nicholas Piggin , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Hui Zhu References: <20260529014130.671291-1-hui.zhu@linux.dev> Content-Language: en-US From: Dev Jain In-Reply-To: <20260529014130.671291-1-hui.zhu@linux.dev> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 29/05/26 7:11 am, Hui Zhu wrote: > From: Hui Zhu > > 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 > --- I think this makes sense from API PoV. Reviewed-by: Dev Jain > 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