ANDROID: 16K: Fix mincore emulation

Since the temporary page to process the mincore range is reused
and __collapse_mincore_results() bitwise ORs X contiguous entries
with the initial buffer value; clear the previous results when
emulating the page size to avoid corruption from the previous
processed entries.

Bug: 383389337
Bug: 390505059
Bug: 385169772
Bug: 390404912
Test: atest
     vts_ltp_test_x86_64:syscalls.mlock201_64bit#syscalls.mlock201_64bit
          --iterations 10
Change-Id: I816b8952f8d544ab37298582e626ab3f8bbcab7f
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
This commit is contained in:
Kalesh Singh
2025-01-21 23:33:43 +00:00
committed by Carlos Llamas
parent 8aab407984
commit 3c9a39c770

View File

@@ -302,6 +302,14 @@ SYSCALL_DEFINE3(mincore, unsigned long, start, size_t, len,
retval = -EFAULT;
break;
}
/*
* If emulating the page size, clear the old results, to avoid
* corrupting the next __collapse_mincore_result()
*/
if (nr_subpages > 1)
memset(res, 0, retval / nr_subpages);
pages -= retval;
vec += retval / nr_subpages;
start += retval << PAGE_SHIFT;