Skip to contentSkip to conversation

syscall/prctl06: Fix proc NoNewPrivs detection

PATCH New Cyril Hrubis 1 participant 1 message May 7, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 syscall/prctl06: Fix proc NoNewPrivs detection

The prctl() syscall check does return in case of success hence the check for NoNewPrivs was never executed. Move the proc check before the sycall check to fix that.

---
 testcases/kernel/syscalls/prctl/prctl06.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
testcases/kernel/syscalls/prctl/prctl06.c +6 -7
index 3ebf1ab60..d6517e6b1 100644
@@ -87,6 +87,12 @@ static void setup(void)
 	SAFE_CHOWN(BIN_PATH, 0, 0);
 	SAFE_CHMOD(BIN_PATH, SUID_MODE);
 
+	if (FILE_LINES_SCANF(PROC_STATUS, "NoNewPrivs:%d", &field)) {
+		tst_res(TCONF, "%s doesn't support NoNewPrivs field", PROC_STATUS);
+		proc_flag = 0;
+		proc_sup = "No";
+	}
+
 	TEST(prctl(PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0));
 	if (TST_RET == 0) {
 		tst_res(TINFO, "kernel supports PR_GET/SET_NO_NEW_PRIVS");
@@ -99,13 +105,6 @@ static void setup(void)
 
 	tst_brk(TBROK | TTERRNO,
 		"current environment doesn't permit PR_GET/SET_NO_NEW_PRIVS");
-
-	TEST(FILE_LINES_SCANF(PROC_STATUS, "NoNewPrivs:%d", &field));
-	if (TST_RET == 1) {
-		tst_res(TCONF, "%s doesn't support NoNewPrivs field", PROC_STATUS);
-		proc_flag = 0;
-		proc_sup = "No";
-	}
 }
 
 static const char *const resfile[] = {
Signature · 1 line
2.26.2