[PATCH] default descriptor vm_ops to dummy vm_ops
From: Lorenzo Stoakes
Date: Thu May 21 2026 - 13:10:42 EST
We need to default the VMA descriptor's VMA operations to vma_dummy_vm_ops
so we can correctly detect the case where the VMA is made anonymous.
This is what a new file-backed VMA's vm_ops defaults to, so if an
mmap_prepare hook does not specify VMA operations this is what it expects.
Previously we treated NULL as 'not set' but now we want to explicitly treat
it as meaning 'make anon' as per /dev/zero.
We also update compat_set_desc_from_vma() and the VMA tests to reflect
this.
Signed-off-by: Lorenzo Stoakes <ljs@xxxxxxxxxx>
---
mm/util.c | 1 +
mm/vma.c | 1 +
tools/testing/vma/include/dup.h | 1 +
3 files changed, 3 insertions(+)
diff --git a/mm/util.c b/mm/util.c
index 3cc949a0b7ed..2b2a9df689d7 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -1192,6 +1192,7 @@ void compat_set_desc_from_vma(struct vm_area_desc *desc,
desc->vm_file = vma->vm_file;
desc->vma_flags = vma->flags;
desc->page_prot = vma->vm_page_prot;
+ desc->vm_ops = vma->vm_ops;
/* Default. */
desc->action.type = MMAP_NOTHING;
diff --git a/mm/vma.c b/mm/vma.c
index 07486390c692..9eea2850818a 100644
--- a/mm/vma.c
+++ b/mm/vma.c
@@ -2746,6 +2746,7 @@ static unsigned long __mmap_region(struct file *file, unsigned long addr,
.action = {
.type = MMAP_NOTHING, /* Default to no further action. */
},
+ .vm_ops = &vma_dummy_vm_ops,
};
bool allocated_new = false;
int error;
diff --git a/tools/testing/vma/include/dup.h b/tools/testing/vma/include/dup.h
index 9e0dfd3a85b0..306171d061e7 100644
--- a/tools/testing/vma/include/dup.h
+++ b/tools/testing/vma/include/dup.h
@@ -1303,6 +1303,7 @@ static inline void compat_set_desc_from_vma(struct vm_area_desc *desc,
desc->vm_file = vma->vm_file;
desc->vma_flags = vma->flags;
desc->page_prot = vma->vm_page_prot;
+ desc->vm_ops = vma->vm_ops;
/* Default. */
desc->action.type = MMAP_NOTHING;
--
2.54.0