]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
fork: Use VMA iterator
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 4 Jan 2021 19:54:49 +0000 (14:54 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 1 Nov 2021 14:43:49 +0000 (10:43 -0400)
The VMA iterator is faster than the linked list and removing the linked
list will shrink the vm_area_struct.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
kernel/fork.c

index a47e59c3ee4de15dfe4c86f48456b870a86f20d5..6861d289a733c853549f2aea062a998ea164cbde 100644 (file)
@@ -1230,13 +1230,16 @@ int replace_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file)
        /* Forbid mm->exe_file change if old file still mapped. */
        old_exe_file = get_mm_exe_file(mm);
        if (old_exe_file) {
+               VMA_ITERATOR(vmi, mm, 0);
                mmap_read_lock(mm);
-               for (vma = mm->mmap; vma && !ret; vma = vma->vm_next) {
+               for_each_vma(vmi, vma) {
                        if (!vma->vm_file)
                                continue;
                        if (path_equal(&vma->vm_file->f_path,
-                                      &old_exe_file->f_path))
+                                      &old_exe_file->f_path)) {
                                ret = -EBUSY;
+                               break;
+                       }
                }
                mmap_read_unlock(mm);
                fput(old_exe_file);