]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
kernel/fork: Use maple tree iterators instead of linked list
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 4 Jan 2021 19:54:49 +0000 (14:54 -0500)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 20 Oct 2021 19:22:35 +0000 (15:22 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
kernel/fork.c

index 3c14f8aef01ac3097566140bb95b524a75c997f5..d995ab62002b3fcb1a1bf8b490df2e13073be99a 100644 (file)
@@ -1229,14 +1229,19 @@ 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) {
+               MA_STATE(mas, &mm->mm_mt, 0, 0);
                mmap_read_lock(mm);
-               for (vma = mm->mmap; vma && !ret; vma = vma->vm_next) {
+               rcu_read_lock();
+               mas_for_each(&mas, vma, ULONG_MAX) {
                        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;
+                       }
                }
+               rcu_read_unlock();
                mmap_read_unlock(mm);
                fput(old_exe_file);
                if (ret)