Messages in this thread Patch in this message |  | | From | Wupeng Ma <> | Subject | [PATCH v3 2/4] mm/mempolicy: return EINVAL for if len overflows for set_mempolicy_home_node | Date | Sat, 28 Jan 2023 14:32:27 +0800 |
| |
From: Ma Wupeng <mawupeng1@huawei.com>
Check and return 0 if len == 0 at the beginning of the function. Return -EINVAL if len overflows for set_mempolicy_home_node.
Signed-off-by: Ma Wupeng <mawupeng1@huawei.com> --- mm/mempolicy.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 02c8a712282f..85c5d3c2503b 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1512,13 +1512,16 @@ SYSCALL_DEFINE4(set_mempolicy_home_node, unsigned long, start, unsigned long, le if (home_node >= MAX_NUMNODES || !node_online(home_node)) return -EINVAL; + if (!len) + return 0; + len = PAGE_ALIGN(len); - end = start + len; + if (!len) + return -EINVAL; + end = start + len; if (end < start) return -EINVAL; - if (end == start) - return 0; mmap_write_lock(mm); for_each_vma_range(vmi, vma, end) { vmstart = max(start, vma->vm_start); -- 2.25.1
|  |