[RFC v1 02/19] uprobes: Correctly reject anonymous VMAs for breakpoint installation

From: Andi Kleen

Date: Mon Aug 31 2026 - 16:06:32 EST


Checking for anonymous VMAs is supposed to use this special function,
not just check vm_file.

Assisted-by: omp:gpt-5.6-luna sashiko
Signed-off-by: Andi Kleen <ak@xxxxxxxxxx>
---
kernel/events/uprobes.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 7709ea882477..4287c4ff4c0f 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -139,7 +139,8 @@ static bool valid_vma(struct vm_area_struct *vma, bool is_register)
if (is_register)
flags |= VM_WRITE;

- return vma->vm_file && (vma->vm_flags & flags) == VM_MAYEXEC;
+ return !vma_is_anonymous(vma) && vma->vm_file &&
+ (vma->vm_flags & flags) == VM_MAYEXEC;
}

static unsigned long offset_to_vaddr(struct vm_area_struct *vma, loff_t offset)
--
2.54.0