]> www.infradead.org Git - users/willy/linux.git/commitdiff
mm/mprotect: Use maple tree navigation instead of vma linked list
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 4 Jan 2021 20:02:28 +0000 (15:02 -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>
mm/mprotect.c

index 883e2cc85cad84ad0e67822b8ac22a0ecbae9aee..a4041d2c0dfb3473622b7adf1ac09e27a2f8eee1 100644 (file)
@@ -528,6 +528,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
        const int grows = prot & (PROT_GROWSDOWN|PROT_GROWSUP);
        const bool rier = (current->personality & READ_IMPLIES_EXEC) &&
                                (prot & PROT_READ);
+       MA_STATE(mas, &current->mm->mm_mt, start, start);
 
        start = untagged_addr(start);
 
@@ -559,11 +560,15 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
        if ((pkey != -1) && !mm_pkey_is_allocated(current->mm, pkey))
                goto out;
 
-       vma = find_vma(current->mm, start);
+       rcu_read_lock();
+       vma = mas_find(&mas, ULONG_MAX);
        error = -ENOMEM;
-       if (!vma)
+       if (!vma) {
+               rcu_read_unlock();
                goto out;
-       prev = vma->vm_prev;
+       }
+       prev = mas_prev(&mas, 0);
+       rcu_read_unlock();
        if (unlikely(grows & PROT_GROWSDOWN)) {
                if (vma->vm_start >= end)
                        goto out;
@@ -644,7 +649,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
                if (nstart >= end)
                        goto out;
 
-               vma = prev->vm_next;
+               vma = vma_next(current->mm, prev);
                if (!vma || vma->vm_start != nstart) {
                        error = -ENOMEM;
                        goto out;