Re: [PATCH v2 2/2] mm/vmalloc: reject NULL pages in remap_vmalloc_range_partial
From: Uladzislau Rezki
Date: Sun Nov 22 2026 - 09:54:26 EST
On Thu, Oct 29, 2026 at 05:19:08PM +0800, Ye Liu wrote:
> From: Ye Liu <liuye@xxxxxxxxxx>
>
> remap_vmalloc_range_partial() passes vmalloc_to_page()'s result to
> vm_insert_page() unchecked, oopsing via page_folio() on a NULL page.
> The NULL case cannot happen today because VM_USERMAP areas keep every
> page mapped, but nothing enforces that invariant. Warn once and fail
> the mapping with -EINVAL instead of oopsing if it is ever broken.
>
> Suggested-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>
> Signed-off-by: Ye Liu <liuye@xxxxxxxxxx>
> ---
> mm/vmalloc.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index a888eca016a8..dabef40ea88b 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -4906,6 +4906,9 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
> struct page *page = vmalloc_to_page(kaddr);
> int ret;
>
> + if (WARN_ON_ONCE(!page))
> + return -EINVAL;
> +
> ret = vm_insert_page(vma, uaddr, page);
> if (ret)
> return ret;
>
> --
> 2.43.0
>
LGTM
Reviewed-by: Uladzislau Rezki (Sony) <urezki@xxxxxxxxx>
--
Uladzislau Rezki