[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230320024739.224850-4-mawupeng1@huawei.com>
Date: Mon, 20 Mar 2023 10:47:38 +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>, <david@...hat.com>
Subject: [PATCH v4 3/4] mm/mempolicy: return EINVAL if len overflows for mbind
From: Ma Wupeng <mawupeng1@...wei.com>
Return -EINVAL if len overflows for mbind.
Signed-off-by: Ma Wupeng <mawupeng1@...wei.com>
---
mm/mempolicy.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 3a68998adc3a..6b1c45021e48 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1259,6 +1259,7 @@ static long do_mbind(unsigned long start, unsigned long len,
nodemask_t *nmask, unsigned long flags)
{
struct mm_struct *mm = current->mm;
+ unsigned long old_len = len;
struct mempolicy *new;
unsigned long end;
int err;
@@ -1279,7 +1280,7 @@ static long do_mbind(unsigned long start, unsigned long len,
len = PAGE_ALIGN(len);
end = start + len;
- if (end < start)
+ if (end < start || (old_len != 0 && len == 0))
return -EINVAL;
if (end == start)
return 0;
--
2.25.1
Powered by blists - more mailing lists