In order to get an unmapped memory area, the test case msync03 uses sbrk with an offset to make sure it is beyond the program break. This causes issues in purecap, where brk is disabled, and in plain aarch64 due to a buggy sbrk implemention in Musl (ver. 1.5).
Instead, don't rely on sbrk at all and use an mmaped page, unmap it and use this pointer in order to get an unmapped area of memory. This guarantees an ENOMEM in both compat and purecap.
Signed-off-by: Teo Couprie Diaz teo.coupriediaz@arm.com --- testcases/kernel/syscalls/msync/msync03.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/syscalls/msync/msync03.c b/testcases/kernel/syscalls/msync/msync03.c index 8fa62e57a..3231bac1e 100644 --- a/testcases/kernel/syscalls/msync/msync03.c +++ b/testcases/kernel/syscalls/msync/msync03.c @@ -120,7 +120,8 @@ static void setup(void) nwrite += BUF_SIZE; }
- addr1 = SAFE_MMAP(cleanup, 0, page_sz, PROT_READ | PROT_WRITE, + /* addr4 will point to the second page which will be unmapped. */ + addr1 = SAFE_MMAP(cleanup, 0, page_sz*2, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED, fd, 0);
/* addr2 is not a multiple of PAGESIZE */ @@ -130,8 +131,9 @@ 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 = addr1 + page_sz; + SAFE_MUNMAP(cleanup, addr4, page_sz); }
static void msync_verify(struct test_case_t *tc)
On 13/12/2022 17:27, Teo Couprie Diaz wrote:
In order to get an unmapped memory area, the test case msync03 uses sbrk with an offset to make sure it is beyond the program break. This causes issues in purecap, where brk is disabled, and in plain aarch64 due to a buggy sbrk implemention in Musl (ver. 1.5).
Instead, don't rely on sbrk at all and use an mmaped page, unmap it and use this pointer in order to get an unmapped area of memory. This guarantees an ENOMEM in both compat and purecap.
Signed-off-by: Teo Couprie Diaz teo.coupriediaz@arm.com
testcases/kernel/syscalls/msync/msync03.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
LGTM.
Kevin
diff --git a/testcases/kernel/syscalls/msync/msync03.c b/testcases/kernel/syscalls/msync/msync03.c index 8fa62e57a..3231bac1e 100644 --- a/testcases/kernel/syscalls/msync/msync03.c +++ b/testcases/kernel/syscalls/msync/msync03.c @@ -120,7 +120,8 @@ static void setup(void) nwrite += BUF_SIZE; }
- addr1 = SAFE_MMAP(cleanup, 0, page_sz, PROT_READ | PROT_WRITE,
- /* addr4 will point to the second page which will be unmapped. */
- addr1 = SAFE_MMAP(cleanup, 0, page_sz*2, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED, fd, 0);
/* addr2 is not a multiple of PAGESIZE */ @@ -130,8 +131,9 @@ 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 = addr1 + page_sz;
- SAFE_MUNMAP(cleanup, addr4, page_sz);
} static void msync_verify(struct test_case_t *tc)
On Tue, Dec 13, 2022 at 04:27:54PM +0000, Teo Couprie Diaz wrote:
In order to get an unmapped memory area, the test case msync03 uses sbrk with an offset to make sure it is beyond the program break. This causes issues in purecap, where brk is disabled, and in plain aarch64 due to a buggy sbrk implemention in Musl (ver. 1.5).
Instead, don't rely on sbrk at all and use an mmaped page, unmap it and use this pointer in order to get an unmapped area of memory. This guarantees an ENOMEM in both compat and purecap.
Signed-off-by: Teo Couprie Diaz teo.coupriediaz@arm.com
Now merged. Thanks!
--- BR B.
testcases/kernel/syscalls/msync/msync03.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/syscalls/msync/msync03.c b/testcases/kernel/syscalls/msync/msync03.c index 8fa62e57a..3231bac1e 100644 --- a/testcases/kernel/syscalls/msync/msync03.c +++ b/testcases/kernel/syscalls/msync/msync03.c @@ -120,7 +120,8 @@ static void setup(void) nwrite += BUF_SIZE; }
- addr1 = SAFE_MMAP(cleanup, 0, page_sz, PROT_READ | PROT_WRITE,
- /* addr4 will point to the second page which will be unmapped. */
- addr1 = SAFE_MMAP(cleanup, 0, page_sz*2, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED, fd, 0);
/* addr2 is not a multiple of PAGESIZE */ @@ -130,8 +131,9 @@ 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 = addr1 + page_sz;
- SAFE_MUNMAP(cleanup, addr4, page_sz);
} static void msync_verify(struct test_case_t *tc) -- 2.25.1
linux-morello-ltp mailing list -- linux-morello-ltp@op-lists.linaro.org To unsubscribe send an email to linux-morello-ltp-leave@op-lists.linaro.org
linux-morello-ltp@op-lists.linaro.org