From: Liam R. Howlett Date: Mon, 4 Jan 2021 19:54:49 +0000 (-0500) Subject: kernel/fork: Use maple tree iterators instead of linked list X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d8fc086191b1d2bd2c8d7c4365a21b7c371083a3;p=users%2Fjedix%2Flinux-maple.git kernel/fork: Use maple tree iterators instead of linked list Signed-off-by: Liam R. Howlett --- diff --git a/kernel/fork.c b/kernel/fork.c index 3c14f8aef01ac..d995ab62002b3 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -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)