Skip to contentSkip to conversation

remap_file_pages: Use vma_lookup() instead of find_vma()

PATCH Applied Liam Howlett 2 participants 2 messages Aug 17, 2021

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

PATCH 1/1 remap_file_pages: Use vma_lookup() instead of find_vma()

From: "Liam R. Howlett" <[email protected]>

Using vma_lookup() verifies the start address is contained in the found vma. This results in easier to read code.

---
 mm/mmap.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
mm/mmap.c +1 -4
index d9aa54be6244..1a23d4575cc4 100644
@@ -2994,14 +2994,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
 	if (mmap_write_lock_killable(mm))
 		return -EINTR;
 
-	vma = find_vma(mm, start);
+	vma = vma_lookup(mm, start);
 
 	if (!vma || !(vma->vm_flags & VM_SHARED))
 		goto out;
 
-	if (start < vma->vm_start)
-		goto out;
-
 	if (start + size > vma->vm_end) {
 		struct vm_area_struct *next;
 
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · Liam Howlett

From: "Liam R. Howlett" <[email protected]>

Using vma_lookup() verifies the start address is contained in the found vma. This results in easier to read code.

---
  mm/mmap.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
mm/mmap.c +1 -1
index d9aa54be6244..1a23d4575cc4 100644
@@ -2994,14 +2994,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
  	if (mmap_write_lock_killable(mm))
  		return -EINTR;
 
-	vma = find_vma(mm, start);
+	vma = vma_lookup(mm, start);

mm/mmap.c SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, · line 3004

Quoted 10 lines
mm/mmap.c +0 -3
 
  	if (!vma || !(vma->vm_flags & VM_SHARED))
  		goto out;
 
-	if (start < vma->vm_start)
-		goto out;
-
  	if (start + size > vma->vm_end) {
  		struct vm_area_struct *next;
 
Signature · 3 lines
Thanks,

David / dhildenb