]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/mmap: Fix maple tree calculation for topdown with alignment mask.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 7 May 2020 20:07:49 +0000 (16:07 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:04:44 +0000 (15:04 -0400)
When using alignment mask, calculate the address correctly.

Found by LTP futex_wake04

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
mm/mmap.c

index c37e74bbb95c1a1884505e4a1c5dce1276601e2b..942b9b12a29a4259e2818185ba2b27e0fee1b242 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2278,11 +2278,10 @@ static unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
        if (mas_get_unmapped_area_rev(&mas, info->low_limit, info->high_limit,
                                length))
                return -ENOMEM;
+
        rcu_read_unlock();
-       gap = mas.index;
-       // Not sure why this is needed..
-       if (mas.max > info->high_limit)
-       gap = ((gap) & ~info->align_mask) + info->align_offset;
+       gap = (mas.index + info->align_mask - info->align_offset) &
+               (~info->align_mask);
        /*
         * Adjust search limits by the desired length.
         * See implementation comment at top of unmapped_area().
@@ -2377,8 +2376,8 @@ found_highest:
                                info->low_limit, length);
                pr_err("mas.min %lu max %lu mas.last %lu\n", mas.min, mas.max,
                                mas.last);
-               pr_err("mas.index %lu align %lu offset %lu\n", mas.index,
-                               info->align_offset, info->align_mask);
+               pr_err("mas.index %lu align mask %lu offset %lu\n", mas.index,
+                               info->align_mask, info->align_offset);
                pr_err("rb_find_vma find on %lu => %px (%px)\n", mas.index,
                                rb_find_vma(mm, mas.index), vma);
                mt_dump(&mm->mm_mt);