[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230116115813.2956935-5-mawupeng1@huawei.com>
Date: Mon, 16 Jan 2023 19:58:13 +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>
Subject: [PATCH v2 4/4] mm/msync: return ENOMEM if len overflows for msync
From: Ma Wupeng <mawupeng1@...wei.com>
Return -ENOMEM if len overflows for msync.
Signed-off-by: Ma Wupeng <mawupeng1@...wei.com>
---
mm/msync.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/msync.c b/mm/msync.c
index ac4c9bfea2e7..8ac227ec38af 100644
--- a/mm/msync.c
+++ b/mm/msync.c
@@ -36,6 +36,7 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
struct vm_area_struct *vma;
int unmapped_error = 0;
int error = -EINVAL;
+ size_t old_len = len;
start = untagged_addr(start);
@@ -48,7 +49,7 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
error = -ENOMEM;
len = (len + ~PAGE_MASK) & PAGE_MASK;
end = start + len;
- if (end < start)
+ if (end < start || (old_len != 0 && len == 0))
goto out;
error = 0;
if (end == start)
--
2.25.1
Powered by blists - more mailing lists