Skip to contentSkip to conversation

syscall: remove PROT_WRITE|PROT_EXEC from brk02

PATCH New Li Wang 2 participants 3 messages May 8, 2021 – May 10, 2021

lore
Share & tools
lore

Li Wang

author
#0 lore raw

PATCH 1/1 syscall: remove PROT_WRITE|PROT_EXEC from brk02

We got permission denied while performing the brk02 on x86_64/s390x (kernel-4.18). After looking at the manual page of mprotect(), seems the access issue caused by PROT_EXEC.

" POSIX says that the behavior of mprotect() is unspecified if it is applied to a region of memory that was not obtained via mmap(2). "

 # ./brk02
 tst_test.c:1291: TINFO: Timeout per run is 0h 05m 00s
 brk02.c:41: TFAIL: Cannot mprotect new VMA

From Liam Howlett:
Just removing the PROT_EXEC invalidates the test. However, if both PROT_EXEC and PROT_WRITE are removed, then the test still does what is intended.

So let's remove 'PROT_WRITE|PROT_EXEC' to make brk02 PASS with all platforms.

---
 testcases/kernel/syscalls/brk/brk02.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
testcases/kernel/syscalls/brk/brk02.c +1 -2
index 4a272bac3..11e803cb4 100644
@@ -36,8 +36,7 @@ void brk_down_vmas(void)
 		return;
 	}
 
-	if (mprotect(addr - page_size, page_size,
-		     PROT_READ|PROT_WRITE|PROT_EXEC)) {
+	if (mprotect(addr - page_size, page_size, PROT_READ)) {
 		tst_res(TFAIL | TERRNO, "Cannot mprotect new VMA");
 		return;
 	}
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/1 syscall: remove PROT_WRITE|PROT_EXEC from brk02

Quoted 43 lines · Li Wang

We got permission denied while performing the brk02 on x86_64/s390x (kernel-4.18). After looking at the manual page of mprotect(), seems the access issue caused by PROT_EXEC.

" POSIX says that the behavior of mprotect() is unspecified if it is applied to a region of memory that was not obtained via mmap(2). "

 # ./brk02
 tst_test.c:1291: TINFO: Timeout per run is 0h 05m 00s
 brk02.c:41: TFAIL: Cannot mprotect new VMA

From Liam Howlett:
Just removing the PROT_EXEC invalidates the test. However, if both PROT_EXEC and PROT_WRITE are removed, then the test still does what is intended.

So let's remove 'PROT_WRITE|PROT_EXEC' to make brk02 PASS with all platforms.

---
 testcases/kernel/syscalls/brk/brk02.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
testcases/kernel/syscalls/brk/brk02.c +1 -2
index 4a272bac3..11e803cb4 100644
@@ -36,8 +36,7 @@ void brk_down_vmas(void)
 		return;
 	}
 
-	if (mprotect(addr - page_size, page_size,
-		     PROT_READ|PROT_WRITE|PROT_EXEC)) {
+	if (mprotect(addr - page_size, page_size, PROT_READ)) {
 		tst_res(TFAIL | TERRNO, "Cannot mprotect new VMA");
 		return;
 	}
Signature · 1 line
2.30.2