Message ID | 20230320024739.224850-5-mawupeng1@huawei.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Add overflow checks for several syscalls | expand |
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)