Skip to contentSkip to conversation

nommu: pass NULL argument to vma_iter_prealloc()

PATCH Applied Hajime Tazaki 3 participants 3 messages Nov 8, 2024 – Nov 12, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nommu: pass NULL argument to vma_iter_prealloc()

When deleting a vma entry from a maple tree, it has to pass NULL to vma_iter_prealloc() in order to calculate internal state of the tree, but it passed a wrong argument. As a result, nommu kernels crashed upon accessing a vma iterator, such as acct_collect() reading the size of vma entries after do_munmap().

This commit fixes this issue by passing a right argument to the preallocation call.

Fixes b5df09226450 ("mm: set up vma iterator for vma_iter_prealloc() calls")
---
 mm/nommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/nommu.c +1 -1
index 385b0c15add8..0c708f85408d 100644
@@ -573,7 +573,7 @@ static int delete_vma_from_mm(struct vm_area_struct *vma)
 	VMA_ITERATOR(vmi, vma->vm_mm, vma->vm_start);
 
 	vma_iter_config(&vmi, vma->vm_start, vma->vm_end);
-	if (vma_iter_prealloc(&vmi, vma)) {
+	if (vma_iter_prealloc(&vmi, NULL)) {
 		pr_warn("Allocation of vma tree for process %d failed\n",
 		       current->pid);
 		return -ENOMEM;
Signature · 1 line
2.43.0
#1 lore raw

Andrew,

Just in case you didn't notice, this patch was reviewed on another list.

Thanks,
Liam

Quoted 33 lines · Hajime Tazaki

When deleting a vma entry from a maple tree, it has to pass NULL to vma_iter_prealloc() in order to calculate internal state of the tree, but it passed a wrong argument. As a result, nommu kernels crashed upon accessing a vma iterator, such as acct_collect() reading the size of vma entries after do_munmap().

This commit fixes this issue by passing a right argument to the preallocation call.

Fixes b5df09226450 ("mm: set up vma iterator for vma_iter_prealloc() calls")
---
 mm/nommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/nommu.c +1 -1
index 385b0c15add8..0c708f85408d 100644
@@ -573,7 +573,7 @@ static int delete_vma_from_mm(struct vm_area_struct *vma)
 	VMA_ITERATOR(vmi, vma->vm_mm, vma->vm_start);
 
 	vma_iter_config(&vmi, vma->vm_start, vma->vm_end);
-	if (vma_iter_prealloc(&vmi, vma)) {
+	if (vma_iter_prealloc(&vmi, NULL)) {
 		pr_warn("Allocation of vma tree for process %d failed\n",
 		       current->pid);
 		return -ENOMEM;
Signature · 1 line
2.43.0
maintainer
#2 lore raw
Quoted 21 lines · On Tue, 12 Nov 2024 07:46:18 -0500 "Liam R. Howlett" <[email protected]>…

Andrew,

Just in case you didn't notice, this patch was reviewed on another list.

Thanks,
Liam

Quoted 13 lines · Hajime Tazaki

When deleting a vma entry from a maple tree, it has to pass NULL to vma_iter_prealloc() in order to calculate internal state of the tree, but it passed a wrong argument. As a result, nommu kernels crashed upon accessing a vma iterator, such as acct_collect() reading the size of vma entries after do_munmap().

This commit fixes this issue by passing a right argument to the preallocation call.

Fixes b5df09226450 ("mm: set up vma iterator for vma_iter_prealloc() calls")

Yep, thanks, 247d720b2c5d in mm-hotfixes-stable.