]> www.infradead.org Git - users/willy/linux.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)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 20 Oct 2021 20:00:34 +0000 (16:00 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
kernel/fork.c

index 1ad71e3e2be1ca8d4dc3cbef3c09d8c3f5b6a23b..1fabd948b1bb164b4d74d0bbaa43856aa5df0cd6 100644 (file)
@@ -1228,14 +1228,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)