diff mbox series

[2/4] mm/mempolicy: return EINVAL for illegal user memory range for set_mempolicy_home_node

Message ID 20221205034108.3365182-3-mawupeng1@huawei.com (mailing list archive)
State New
Headers show
Series return EINVAL for illegal user memory range | expand

Commit Message

mawupeng Dec. 5, 2022, 3:41 a.m. UTC
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 mbox series

Patch

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.
 	 */