[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221205034108.3365182-4-mawupeng1@huawei.com>
Date: Mon, 5 Dec 2022 11:41:07 +0800
From: Wupeng Ma <mawupeng1@...wei.com>
To: <akpm@...ux-foundation.org>
CC: <linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
<mawupeng1@...wei.com>, <kuleshovmail@...il.com>,
<aneesh.kumar@...ux.ibm.com>, <clameter@....com>
Subject: [PATCH 3/4] mm/mempolicy: return EINVAL for illegal user memory range for mbind
From: Ma Wupeng <mawupeng1@...wei.com>
Add access_ok to check user memory range and return EINVAL if overflows for
mbind.
Signed-off-by: Ma Wupeng <mawupeng1@...wei.com>
---
mm/mempolicy.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index e3a2c465fe8a..a6bddf454953 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1272,6 +1272,9 @@ static long do_mbind(unsigned long start, unsigned long len,
if (start & ~PAGE_MASK)
return -EINVAL;
+ if (unlikely(!access_ok((void __user *)start, len)))
+ return -EINVAL;
+
if (mode == MPOL_DEFAULT)
flags &= ~MPOL_MF_STRICT;
--
2.25.1
Powered by blists - more mailing lists