* [PATCH v2 0/2] mm/vmalloc: harden remap_vmalloc_range_partial against NULL pages
@ 2026-10-29 9:19 Ye Liu
2026-10-29 9:19 ` [PATCH v2 1/2] mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial Ye Liu
2026-10-29 9:19 ` [PATCH v2 2/2] mm/vmalloc: reject NULL pages in remap_vmalloc_range_partial Ye Liu
0 siblings, 2 replies; 10+ messages in thread
From: Ye Liu @ 2026-10-29 9:19 UTC (permalink / raw)
To: Andrew Morton, Uladzislau Rezki
Cc: linux-mm, linux-kernel, Ye Liu, Jose A. Perez de Azpillaga
remap_vmalloc_range_partial() passes vmalloc_to_page()'s result to
vm_insert_page() unchecked, oopsing via page_folio() if the page is
NULL. The NULL case never happens today because VM_USERMAP areas keep
every page mapped, but that assumption is nowhere checked.
Patch 1 drops VM_DMA_COHERENT from the allow-list -- a dead entry (no
caller maps a DMA-coherent area through this path).
Patch 2 fails the mapping with -EINVAL instead of oopsing if
vmalloc_to_page() ever returns NULL, with a WARN to mark the broken
invariant.
Patch 1 is a behavior change (no in-tree caller affected)
Patch 2 only changes a failure path that cannot be reached today.
The two are independent.
Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
Changes in v2:
- patch 1: drop the vrealloc-shrink justification.
- patch 2: fail with -EINVAL rather than oopsing.
- Link to v1: https://patch.msgid.link/20261026-vmalloc_remap-v1-0-b7a907814e90@linux.dev
---
Ye Liu (2):
mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial
mm/vmalloc: reject NULL pages in remap_vmalloc_range_partial
mm/vmalloc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
---
base-commit: 2efb7a11f1aa4d2dc285fe2680cca22cb9f72f64
change-id: 20261026-vmalloc_remap-012cf418c2a8
Best regards,
--
Ye Liu <ye.liu@linux.dev>
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v2 1/2] mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial 2026-10-29 9:19 [PATCH v2 0/2] mm/vmalloc: harden remap_vmalloc_range_partial against NULL pages Ye Liu @ 2026-10-29 9:19 ` Ye Liu 2026-10-29 11:57 ` Jose A. Perez de Azpillaga ` (2 more replies) 2026-10-29 9:19 ` [PATCH v2 2/2] mm/vmalloc: reject NULL pages in remap_vmalloc_range_partial Ye Liu 1 sibling, 3 replies; 10+ messages in thread From: Ye Liu @ 2026-10-29 9:19 UTC (permalink / raw) To: Andrew Morton, Uladzislau Rezki; +Cc: linux-mm, linux-kernel, Ye Liu From: Ye Liu <liuye@kylinos.cn> No caller maps a VM_DMA_COHERENT area through this path: such areas come from dma_alloc_coherent() internals and are freed via vunmap(), never through remap_vmalloc_range[_partial](); all 13 callers pass vmalloc_user()/vmalloc()-backed addresses. The flag was added in commit fe9041c245196 ("vmalloc: lift the arm flag for coherent mappings to common code") as a mechanical translation of ARM's VM_ARM_DMA_CONSISTENT. Drop it so DMA-coherent areas can never enter the path. Signed-off-by: Ye Liu <liuye@kylinos.cn> --- mm/vmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index db669103dc66..a888eca016a8 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -4894,7 +4894,7 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr, if (!area) return -EINVAL; - if (!(area->flags & (VM_USERMAP | VM_DMA_COHERENT))) + if (!(area->flags & VM_USERMAP)) return -EINVAL; if (check_add_overflow(size, off, &end_index) || -- 2.43.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial 2026-10-29 9:19 ` [PATCH v2 1/2] mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial Ye Liu @ 2026-10-29 11:57 ` Jose A. Perez de Azpillaga 2026-11-21 21:20 ` + mm-vmalloc-drop-vm_dma_coherent-from-remap_vmalloc_range_partial.patch added to mm-unstable branch Andrew Morton 2026-11-22 15:39 ` [PATCH v2 1/2] mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial Uladzislau Rezki 2 siblings, 0 replies; 10+ messages in thread From: Jose A. Perez de Azpillaga @ 2026-10-29 11:57 UTC (permalink / raw) To: Ye Liu, Andrew Morton, Uladzislau Rezki; +Cc: linux-mm, linux-kernel, Ye Liu On 10/29/26 10:19 AM, Ye Liu wrote: > From: Ye Liu <liuye@kylinos.cn> > > No caller maps a VM_DMA_COHERENT area through this path: such areas > come from dma_alloc_coherent() internals and are freed via vunmap(), > never through remap_vmalloc_range[_partial](); all 13 callers pass > vmalloc_user()/vmalloc()-backed addresses. > > The flag was added in commit fe9041c245196 ("vmalloc: lift the arm > flag for coherent mappings to common code") as a mechanical > translation of ARM's VM_ARM_DMA_CONSISTENT. > > Drop it so DMA-coherent areas can never enter the path. > > Signed-off-by: Ye Liu <liuye@kylinos.cn> > --- > mm/vmalloc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index db669103dc66..a888eca016a8 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -4894,7 +4894,7 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr, > if (!area) > return -EINVAL; > > - if (!(area->flags & (VM_USERMAP | VM_DMA_COHERENT))) > + if (!(area->flags & VM_USERMAP)) > return -EINVAL; > > if (check_add_overflow(size, off, &end_index) || > Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com> -- cheers, jose a. p-a ^ permalink raw reply [flat|nested] 10+ messages in thread
* + mm-vmalloc-drop-vm_dma_coherent-from-remap_vmalloc_range_partial.patch added to mm-unstable branch 2026-10-29 9:19 ` [PATCH v2 1/2] mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial Ye Liu 2026-10-29 11:57 ` Jose A. Perez de Azpillaga @ 2026-11-21 21:20 ` Andrew Morton 2026-11-22 15:39 ` [PATCH v2 1/2] mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial Uladzislau Rezki 2 siblings, 0 replies; 10+ messages in thread From: Andrew Morton @ 2026-11-21 21:20 UTC (permalink / raw) To: mm-commits, urezki, azpijr, liuye, akpm The patch titled Subject: mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial has been added to the -mm mm-unstable branch. Its filename is mm-vmalloc-drop-vm_dma_coherent-from-remap_vmalloc_range_partial.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-vmalloc-drop-vm_dma_coherent-from-remap_vmalloc_range_partial.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Ye Liu <liuye@kylinos.cn> Subject: mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial Date: Thu, 29 Oct 2026 17:19:07 +0800 Patch series "mm/vmalloc: harden remap_vmalloc_range_partial against NULL pages", v2. remap_vmalloc_range_partial() passes vmalloc_to_page()'s result to vm_insert_page() unchecked, oopsing via page_folio() if the page is NULL. The NULL case never happens today because VM_USERMAP areas keep every page mapped, but that assumption is nowhere checked. Patch 1 drops VM_DMA_COHERENT from the allow-list -- a dead entry (no caller maps a DMA-coherent area through this path). Patch 2 fails the mapping with -EINVAL instead of oopsing if vmalloc_to_page() ever returns NULL, with a WARN to mark the broken invariant. Patch 1 is a behavior change (no in-tree caller affected) Patch 2 only changes a failure path that cannot be reached today. The two are independent. This patch (of 2): No caller maps a VM_DMA_COHERENT area through this path: such areas come from dma_alloc_coherent() internals and are freed via vunmap(), never through remap_vmalloc_range[_partial](); all 13 callers pass vmalloc_user()/vmalloc()-backed addresses. The flag was added in commit fe9041c245196 ("vmalloc: lift the arm flag for coherent mappings to common code") as a mechanical translation of ARM's VM_ARM_DMA_CONSISTENT. Drop it so DMA-coherent areas can never enter the path. Link: https://lore.kernel.org/20261029-vmalloc_remap-v2-0-c4705cbf26c2@linux.dev Link: https://patch.msgid.link/20261029-vmalloc_remap-v2-1-c4705cbf26c2@linux.dev Signed-off-by: Ye Liu <liuye@kylinos.cn> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com> Cc: Uladzislau Rezki (Sony) <urezki@gmail.com> mm/vmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/vmalloc.c~mm-vmalloc-drop-vm_dma_coherent-from-remap_vmalloc_range_partial +++ a/mm/vmalloc.c @@ -5052,7 +5052,7 @@ int remap_vmalloc_range_partial(struct v if (!area) return -EINVAL; - if (!(area->flags & (VM_USERMAP | VM_DMA_COHERENT))) + if (!(area->flags & VM_USERMAP)) return -EINVAL; if (check_add_overflow(size, off, &end_index) || _ Patches currently in -mm which might be from liuye@kylinos.cn are mm-vmalloc-drop-vm_dma_coherent-from-remap_vmalloc_range_partial.patch mm-vmalloc-reject-null-pages-in-remap_vmalloc_range_partial.patch ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial 2026-10-29 9:19 ` [PATCH v2 1/2] mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial Ye Liu 2026-10-29 11:57 ` Jose A. Perez de Azpillaga 2026-11-21 21:20 ` + mm-vmalloc-drop-vm_dma_coherent-from-remap_vmalloc_range_partial.patch added to mm-unstable branch Andrew Morton @ 2026-11-22 15:39 ` Uladzislau Rezki 2026-12-01 2:07 ` Ye Liu 2 siblings, 1 reply; 10+ messages in thread From: Uladzislau Rezki @ 2026-11-22 15:39 UTC (permalink / raw) To: Ye Liu; +Cc: Andrew Morton, Uladzislau Rezki, linux-mm, linux-kernel, Ye Liu On Thu, Oct 29, 2026 at 05:19:07PM +0800, Ye Liu wrote: > From: Ye Liu <liuye@kylinos.cn> > > No caller maps a VM_DMA_COHERENT area through this path: such areas > come from dma_alloc_coherent() internals and are freed via vunmap(), > never through remap_vmalloc_range[_partial](); all 13 callers pass > vmalloc_user()/vmalloc()-backed addresses. > > The flag was added in commit fe9041c245196 ("vmalloc: lift the arm > flag for coherent mappings to common code") as a mechanical > translation of ARM's VM_ARM_DMA_CONSISTENT. > > Drop it so DMA-coherent areas can never enter the path. > > Signed-off-by: Ye Liu <liuye@kylinos.cn> > --- > mm/vmalloc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index db669103dc66..a888eca016a8 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -4894,7 +4894,7 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr, > if (!area) > return -EINVAL; > > - if (!(area->flags & (VM_USERMAP | VM_DMA_COHERENT))) > + if (!(area->flags & VM_USERMAP)) > return -EINVAL; > > if (check_add_overflow(size, off, &end_index) || > > -- > 2.43.0 > I think we should really clarify why а remap_vmalloc_range_partial() should no longer accept VM_DMA_COHERENT mappings, because this change explicitly disallows a previously supported behavior. Could you please clarify why we should disallow this now? Thank you! -- Uladzislau Rezki ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial 2026-11-22 15:39 ` [PATCH v2 1/2] mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial Uladzislau Rezki @ 2026-12-01 2:07 ` Ye Liu 0 siblings, 0 replies; 10+ messages in thread From: Ye Liu @ 2026-12-01 2:07 UTC (permalink / raw) To: Uladzislau Rezki; +Cc: Andrew Morton, linux-mm, linux-kernel, Ye Liu 在 2026/11/22 23:39, Uladzislau Rezki 写道: > On Thu, Oct 29, 2026 at 05:19:07PM +0800, Ye Liu wrote: >> From: Ye Liu <liuye@kylinos.cn> >> >> No caller maps a VM_DMA_COHERENT area through this path: such areas >> come from dma_alloc_coherent() internals and are freed via vunmap(), >> never through remap_vmalloc_range[_partial](); all 13 callers pass >> vmalloc_user()/vmalloc()-backed addresses. >> >> The flag was added in commit fe9041c245196 ("vmalloc: lift the arm >> flag for coherent mappings to common code") as a mechanical >> translation of ARM's VM_ARM_DMA_CONSISTENT. >> >> Drop it so DMA-coherent areas can never enter the path. >> >> Signed-off-by: Ye Liu <liuye@kylinos.cn> >> --- >> mm/vmalloc.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/mm/vmalloc.c b/mm/vmalloc.c >> index db669103dc66..a888eca016a8 100644 >> --- a/mm/vmalloc.c >> +++ b/mm/vmalloc.c >> @@ -4894,7 +4894,7 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr, >> if (!area) >> return -EINVAL; >> >> - if (!(area->flags & (VM_USERMAP | VM_DMA_COHERENT))) >> + if (!(area->flags & VM_USERMAP)) >> return -EINVAL; >> >> if (check_add_overflow(size, off, &end_index) || >> >> -- >> 2.43.0 >> > I think we should really clarify why а remap_vmalloc_range_partial() should > no longer accept VM_DMA_COHERENT mappings, because this change explicitly > disallows a previously supported behavior. > > Could you please clarify why we should disallow this now? > Hi Uladzislau, Thanks for the review. Sorry for not making this explicit enough. The key point is that "previously accepted by the check" is not the same as "previously supported behavior". No in-tree caller passes a VM_DMA_COHERENT area to remap_vmalloc_range[_partial](); all 13 callers use vmalloc_user()/vmalloc() areas with VM_USERMAP. VM_DMA_COHERENT areas come from dma_alloc_coherent() internals and are freed via vunmap()/dma_free_coherent(), so they should not enter this remapping path at all. The flag was introduced by fe9041c245196 as a mechanical translation of ARM's VM_ARM_DMA_CONSISTENT, not as an API requirement. So this change removes an unused/accidental allowance rather than a supported behavior. I can reword the changelog to make that clearer if you think it would help. > Thank you! > > -- > Uladzislau Rezki -- Thanks, Ye Liu ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 2/2] mm/vmalloc: reject NULL pages in remap_vmalloc_range_partial 2026-10-29 9:19 [PATCH v2 0/2] mm/vmalloc: harden remap_vmalloc_range_partial against NULL pages Ye Liu 2026-10-29 9:19 ` [PATCH v2 1/2] mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial Ye Liu @ 2026-10-29 9:19 ` Ye Liu 2026-10-29 12:04 ` Jose A. Perez de Azpillaga ` (2 more replies) 1 sibling, 3 replies; 10+ messages in thread From: Ye Liu @ 2026-10-29 9:19 UTC (permalink / raw) To: Andrew Morton, Uladzislau Rezki Cc: linux-mm, linux-kernel, Ye Liu, Jose A. Perez de Azpillaga From: Ye Liu <liuye@kylinos.cn> 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@gmail.com> Signed-off-by: Ye Liu <liuye@kylinos.cn> --- 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 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/2] mm/vmalloc: reject NULL pages in remap_vmalloc_range_partial 2026-10-29 9:19 ` [PATCH v2 2/2] mm/vmalloc: reject NULL pages in remap_vmalloc_range_partial Ye Liu @ 2026-10-29 12:04 ` Jose A. Perez de Azpillaga 2026-11-21 21:20 ` + mm-vmalloc-reject-null-pages-in-remap_vmalloc_range_partial.patch added to mm-unstable branch Andrew Morton 2026-11-22 14:54 ` [PATCH v2 2/2] mm/vmalloc: reject NULL pages in remap_vmalloc_range_partial Uladzislau Rezki 2 siblings, 0 replies; 10+ messages in thread From: Jose A. Perez de Azpillaga @ 2026-10-29 12:04 UTC (permalink / raw) To: Ye Liu, Andrew Morton, Uladzislau Rezki; +Cc: linux-mm, linux-kernel, Ye Liu On 10/29/26 10:19 AM, Ye Liu wrote: > From: Ye Liu <liuye@kylinos.cn> > > 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@gmail.com> > Signed-off-by: Ye Liu <liuye@kylinos.cn> > --- > 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; > + thanks for picking this up :) Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com> -- cheers, jose a. p-a ^ permalink raw reply [flat|nested] 10+ messages in thread
* + mm-vmalloc-reject-null-pages-in-remap_vmalloc_range_partial.patch added to mm-unstable branch 2026-10-29 9:19 ` [PATCH v2 2/2] mm/vmalloc: reject NULL pages in remap_vmalloc_range_partial Ye Liu 2026-10-29 12:04 ` Jose A. Perez de Azpillaga @ 2026-11-21 21:20 ` Andrew Morton 2026-11-22 14:54 ` [PATCH v2 2/2] mm/vmalloc: reject NULL pages in remap_vmalloc_range_partial Uladzislau Rezki 2 siblings, 0 replies; 10+ messages in thread From: Andrew Morton @ 2026-11-21 21:20 UTC (permalink / raw) To: mm-commits, urezki, azpijr, liuye, akpm The patch titled Subject: mm/vmalloc: reject NULL pages in remap_vmalloc_range_partial has been added to the -mm mm-unstable branch. Its filename is mm-vmalloc-reject-null-pages-in-remap_vmalloc_range_partial.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-vmalloc-reject-null-pages-in-remap_vmalloc_range_partial.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Ye Liu <liuye@kylinos.cn> Subject: mm/vmalloc: reject NULL pages in remap_vmalloc_range_partial Date: Thu, 29 Oct 2026 17:19:08 +0800 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. Link: https://patch.msgid.link/20261029-vmalloc_remap-v2-2-c4705cbf26c2@linux.dev Signed-off-by: Ye Liu <liuye@kylinos.cn> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Suggested-by: Jose A. Perez de Azpillaga <azpijr@gmail.com> Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com> Cc: Uladzislau Rezki (Sony) <urezki@gmail.com> mm/vmalloc.c | 3 +++ 1 file changed, 3 insertions(+) --- a/mm/vmalloc.c~mm-vmalloc-reject-null-pages-in-remap_vmalloc_range_partial +++ a/mm/vmalloc.c @@ -5064,6 +5064,9 @@ int remap_vmalloc_range_partial(struct v 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; _ Patches currently in -mm which might be from liuye@kylinos.cn are mm-vmalloc-drop-vm_dma_coherent-from-remap_vmalloc_range_partial.patch mm-vmalloc-reject-null-pages-in-remap_vmalloc_range_partial.patch ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/2] mm/vmalloc: reject NULL pages in remap_vmalloc_range_partial 2026-10-29 9:19 ` [PATCH v2 2/2] mm/vmalloc: reject NULL pages in remap_vmalloc_range_partial Ye Liu 2026-10-29 12:04 ` Jose A. Perez de Azpillaga 2026-11-21 21:20 ` + mm-vmalloc-reject-null-pages-in-remap_vmalloc_range_partial.patch added to mm-unstable branch Andrew Morton @ 2026-11-22 14:54 ` Uladzislau Rezki 2 siblings, 0 replies; 10+ messages in thread From: Uladzislau Rezki @ 2026-11-22 14:54 UTC (permalink / raw) To: Ye Liu Cc: Andrew Morton, Uladzislau Rezki, linux-mm, linux-kernel, Ye Liu, Jose A. Perez de Azpillaga On Thu, Oct 29, 2026 at 05:19:08PM +0800, Ye Liu wrote: > From: Ye Liu <liuye@kylinos.cn> > > 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@gmail.com> > Signed-off-by: Ye Liu <liuye@kylinos.cn> > --- > 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@gmail.com> -- Uladzislau Rezki ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-12-01 2:07 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-10-29 9:19 [PATCH v2 0/2] mm/vmalloc: harden remap_vmalloc_range_partial against NULL pages Ye Liu 2026-10-29 9:19 ` [PATCH v2 1/2] mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial Ye Liu 2026-10-29 11:57 ` Jose A. Perez de Azpillaga 2026-11-21 21:20 ` + mm-vmalloc-drop-vm_dma_coherent-from-remap_vmalloc_range_partial.patch added to mm-unstable branch Andrew Morton 2026-11-22 15:39 ` [PATCH v2 1/2] mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial Uladzislau Rezki 2026-12-01 2:07 ` Ye Liu 2026-10-29 9:19 ` [PATCH v2 2/2] mm/vmalloc: reject NULL pages in remap_vmalloc_range_partial Ye Liu 2026-10-29 12:04 ` Jose A. Perez de Azpillaga 2026-11-21 21:20 ` + mm-vmalloc-reject-null-pages-in-remap_vmalloc_range_partial.patch added to mm-unstable branch Andrew Morton 2026-11-22 14:54 ` [PATCH v2 2/2] mm/vmalloc: reject NULL pages in remap_vmalloc_range_partial Uladzislau Rezki
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.