arch_get_unmapped_area() could potentially allow a larger than possible
length when using the MAP_FIXED flag.  The bound check should come
before the check for MAP_FIXED.

Fixes: 5bba49f5397c (ARC: [mm] Aliasing VIPT dcache support 4/4)
Signed-off-by: Liam R. Howlett <liam.howl...@oracle.com>
---
 arch/arc/mm/mmap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arc/mm/mmap.c b/arch/arc/mm/mmap.c
index 722d26b94307..1d7076406c4e 100644
--- a/arch/arc/mm/mmap.c
+++ b/arch/arc/mm/mmap.c
@@ -35,6 +35,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
        int aliasing = cache_is_vipt_aliasing();
        struct vm_unmapped_area_info info;
 
+       if (len > TASK_SIZE)
+               return -ENOMEM;
+
        /*
         * We only need to do colour alignment if D cache aliases.
         */
@@ -51,9 +54,6 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
                return addr;
        }
 
-       if (len > TASK_SIZE)
-               return -ENOMEM;
-
        if (addr) {
                if (do_align)
                        addr = COLOUR_ALIGN(addr, pgoff);
-- 
2.30.2

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

Reply via email to