lkml.org 
[lkml]   [2022]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/4] mm/mempolicy: return EINVAL for illegal user memory range for set_mempolicy_home_node
Date
From: Ma Wupeng <mawupeng1@huawei.com>

Add access_ok to check user memory range and return EINVAL if overflows.

Signed-off-by: Ma Wupeng <mawupeng1@huawei.com>
---
mm/mempolicy.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 61aa9aedb728..e3a2c465fe8a 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1499,6 +1499,10 @@ SYSCALL_DEFINE4(set_mempolicy_home_node, unsigned long, start, unsigned long, le
start = untagged_addr(start);
if (start & ~PAGE_MASK)
return -EINVAL;
+
+ if (unlikely(!access_ok((void __user *)start, len)))
+ return -EINVAL;
+
/*
* flags is used for future extension if any.
*/
--
2.25.1
\
 
 \ /
  Last update: 2022-12-05 04:42    [W:0.098 / U:0.700 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site