[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20211206150231.2283069-4-Liam.Howlett@oracle.com>
Date: Mon, 6 Dec 2021 15:02:53 +0000
From: Liam Howlett <liam.howlett@...cle.com>
To: Liam Howlett <liam.howlett@...cle.com>,
Nick Hu <nickhu@...estech.com>,
Greentime Hu <green.hu@...il.com>,
Vincent Chen <deanbo422@...il.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [RFC PATCH 3/6] nds32/mm/mmap.c: Check length of unmapped area before
allowing MAP_FIXED
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: 664eec400bf8 (nds32: MMU fault handling and page table
management)
Signed-off-by: Liam R. Howlett <Liam.Howlett@...cle.com>
---
arch/nds32/mm/mmap.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/nds32/mm/mmap.c b/arch/nds32/mm/mmap.c
index 1bdf5e7d1b43..1bc5a82ac3d3 100644
--- a/arch/nds32/mm/mmap.c
+++ b/arch/nds32/mm/mmap.c
@@ -31,6 +31,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
if(IS_ENABLED(CONFIG_CPU_CACHE_ALIASING))
aliasing = 1;
+ if (len > TASK_SIZE)
+ return -ENOMEM;
+
/*
* We only need to do colour alignment if either the I or D
* caches alias.
@@ -48,9 +51,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
Powered by blists - more mailing lists