Message ID | 20230321074035.1526157-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..3104c97d70d3 100644 --- a/mm/msync.c +++ b/mm/msync.c @@ -46,13 +46,16 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags) if ((flags & MS_ASYNC) && (flags & MS_SYNC)) goto out; error = -ENOMEM; + if (!len) + return 0; + len = (len + ~PAGE_MASK) & PAGE_MASK; + if (!len) + goto out; + end = start + len; if (end < start) goto out; - error = 0; - if (end == start) - goto out; /* * If the interval [start,end) covers some unmapped address ranges, * just ignore them, but return -ENOMEM at the end. Besides, if the