Skip to contentSkip to conversation

mm/mremap:: Use vma_lookup() instead of find_vma()

PATCH Applied Miaohe Lin 2 participants 2 messages Mar 12, 2022 – Mar 14, 2022

Subsystems (2)
lore
Share & tools
lore

Miaohe Lin

author
#0 lore raw

PATCH 1/1 mm/mremap:: Use vma_lookup() instead of find_vma()

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

---
 mm/mremap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/mremap.c +2 -2
index 002eec83e91e..9d76da79594d 100644
@@ -942,8 +942,8 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
 
 	if (mmap_write_lock_killable(current->mm))
 		return -EINTR;
-	vma = find_vma(mm, addr);
-	if (!vma || vma->vm_start > addr) {
+	vma = vma_lookup(mm, addr);
+	if (!vma) {
 		ret = EFAULT;
 		goto out;
 	}
Signature · 1 line
2.23.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Miaohe Lin

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

---
 mm/mremap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/mremap.c +0 -0
index 002eec83e91e..9d76da79594d 100644

mm/mremap.c SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len, · line 949

Quoted 10 lines
mm/mremap.c +2 -2
@@ -942,8 +942,8 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
 
 	if (mmap_write_lock_killable(current->mm))
 		return -EINTR;
-	vma = find_vma(mm, addr);
-	if (!vma || vma->vm_start > addr) {
+	vma = vma_lookup(mm, addr);
+	if (!vma) {
 		ret = EFAULT;
 		goto out;
 	}
Signature · 3 lines
Thanks,

David / dhildenb