[PATCH v3 45/66] kernel/fork: Use maple tree iterators instead of linked list
Liam Howlett
liam.howlett at oracle.com
Mon Oct 4 18:31:03 PDT 2021
From: "Liam R. Howlett" <Liam.Howlett at Oracle.com>
Signed-off-by: Liam R. Howlett <Liam.Howlett at Oracle.com>
---
kernel/fork.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/kernel/fork.c b/kernel/fork.c
index 3c14f8aef01a..d995ab62002b 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)
--
2.30.2
More information about the maple-tree
mailing list