]> www.infradead.org Git - users/jedix/linux-maple.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)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 20 Jan 2021 15:29:09 +0000 (10:29 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
mm/mprotect.c

index ab709023e9aafa5cb93ffd09a8fc7ec7ffddb630..d9479609f1b5dbff43a304727a8f35697880562a 100644 (file)
@@ -518,6 +518,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);
 
@@ -549,11 +550,12 @@ 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);
+       mas_set(&mas, start);
+       vma = mas_walk(&mas);
        error = -ENOMEM;
        if (!vma)
                goto out;
-       prev = vma->vm_prev;
+       prev = mas_prev(&mas, 0);
        if (unlikely(grows & PROT_GROWSDOWN)) {
                if (vma->vm_start >= end)
                        goto out;
@@ -633,7 +635,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
                if (nstart >= end)
                        goto out;
 
-               vma = prev->vm_next;
+               vma = mas_next(&mas, ULONG_MAX);
                if (!vma || vma->vm_start != nstart) {
                        error = -ENOMEM;
                        goto out;