On 12/12/2022 14:59, Teo Couprie Diaz wrote:
In msync03, sbrk(0) was used and offset to get a pointer to an unmapped area. This caused issues in purecap because sbrk is now disabled, and in compat with the 1.5 verrsion of musl because of a bug in the sbrk implementation.
Instead, don't rely on sbrk at all and mmap a page, unmap it and use this pointer in order to get an unmapped area of memory, generating an ENOMEM in compat and purecap.
Signed-off-by: Teo Couprie Diaz teo.coupriediaz@arm.com
testcases/kernel/syscalls/msync/msync03.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/msync/msync03.c b/testcases/kernel/syscalls/msync/msync03.c index 8fa62e57a..6d59c9d26 100644 --- a/testcases/kernel/syscalls/msync/msync03.c +++ b/testcases/kernel/syscalls/msync/msync03.c @@ -130,8 +130,17 @@ static void setup(void) SAFE_GETRLIMIT(NULL, RLIMIT_DATA, &rl); addr3 = (char *)(uintptr_t)rl.rlim_max;
- /* memory pointed to by addr4 was not mapped */
- addr4 = sbrk(0) + (4 * page_sz);
- /* memory pointed to by addr4 is not mapped */
- addr4 = mmap(NULL, page_sz, PROT_NONE, MAP_PRIVATE, 0, 0);
- if (addr4 == MAP_FAILED) {
addr4 = NULL;
- } else {
if (!munmap(addr4, page_sz))
tst_resm(TFAIL, "Could not setup test, munmap failed :\n%s",
strerror(errno));
- }
- tst_resm(TINFO, "addr4 : %p", addr4);
I obviously forgot this debug message, it will be removed if a v2 is required (which will probably be the case) ! Apologies for the mistake.
} static void msync_verify(struct test_case_t *tc)