ANDROID: 16K: msync: __PAGE_ALIGN addr and len

In page-compat mode, msync() syscalls must be at __PAGE_ALIGN-ed
addresses and of __PAGE_SIZE-multiple length.

Bug: 383389337
Bug: 315325080
Bug: 302403436
Change-Id: I5630c1fca6c0e9d44d9c3f60d5bc42c4083d970d
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
This commit is contained in:
Kalesh Singh
2023-11-20 10:13:56 -08:00
committed by Carlos Llamas
parent 5d8eb7f9e0
commit 4956d7c6c4

View File

@@ -14,6 +14,7 @@
#include <linux/file.h>
#include <linux/syscalls.h>
#include <linux/sched.h>
#include <linux/page_size_compat.h>
/*
* MS_SYNC syncs the entire file - including mappings.
@@ -41,12 +42,12 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
if (flags & ~(MS_ASYNC | MS_INVALIDATE | MS_SYNC))
goto out;
if (offset_in_page(start))
if (__offset_in_page_log(start))
goto out;
if ((flags & MS_ASYNC) && (flags & MS_SYNC))
goto out;
error = -ENOMEM;
len = (len + ~PAGE_MASK) & PAGE_MASK;
len = (len + ~__PAGE_MASK) & __PAGE_MASK;
end = start + len;
if (end < start)
goto out;