diff mbox series

[v2,2/2] mm/userfaultfd: add VM_WARN_ONCE()

Message ID 20230213163124.2850816-2-usama.anjum@collabora.com (mailing list archive)
State New
Headers show
Series [v2,1/2] mm/userfaultfd: Support WP on multiple VMAs | expand

Commit Message

Muhammad Usama Anjum Feb. 13, 2023, 4:31 p.m. UTC
Add VM_WARN_ONCE() to uffd_wp_range() to detect range (start, len) abuse.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 mm/userfaultfd.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
index bccea08005a8..14ec88301511 100644
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -716,6 +716,8 @@  void uffd_wp_range(struct mm_struct *dst_mm, struct vm_area_struct *dst_vma,
 	unsigned int mm_cp_flags;
 	struct mmu_gather tlb;
 
+	VM_WARN_ONCE(start < dst_vma->vm_start || start + len > dst_vma->vm_end,
+		     "The address range exceeds VMA boundary.\n");
 	if (enable_wp)
 		mm_cp_flags = MM_CP_UFFD_WP;
 	else