Skip to contentSkip to conversation

Additional checks for sched_xxx, socketcall01, inotify06

PATCH New Dejan Jovicevic 2 participants 7 messages Nov 2, 2016

lore
Share & tools
lore
#0 lore raw

cover Additional checks for sched_xxx, socketcall01, inotify06

This series adds checks in setup() to determine if the tests are run as super user in case of sched_xxx and socketcall01 or to determine if the test is run with the appropriate kernel version, in case of the inotify06 test.

Dejan Jovicevic (3):
sched_xxx: TCONF instead of TFAIL if user is not root
socketcall: TCONF instead of TFAIL when user is not root
inotify06: kernel version check

 testcases/kernel/syscalls/inotify/inotify06.c                          | 3 +++
 .../kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c    | 1 +
 .../kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c    | 1 +
 .../kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c    | 1 +
 testcases/kernel/syscalls/sched_setparam/sched_setparam02.c            | 1 +
 testcases/kernel/syscalls/sched_setparam/sched_setparam03.c            | 2 ++
 testcases/kernel/syscalls/socketcall/socketcall01.c                    | 1 +
 7 files changed, 10 insertions(+)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/3 sched_xxx: TCONF instead of TFAIL if user is not root

Tests sched_rr_get_interval01, sched_rr_get_interval02, sched_rr_get_interval03, sched_setparam02 and sched_setparam03 break with TFAIL if they are not ran as root. This is because they all require setting scheduling policy to SCHED_RR or other requiring super user privileges.
This was changed so that tests break with TCONF reporting the appropriate message to the user if he is not root.

---
 .../kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c     | 1 +
 .../kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c     | 1 +
 .../kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c     | 1 +
 testcases/kernel/syscalls/sched_setparam/sched_setparam02.c             | 1 +
 testcases/kernel/syscalls/sched_setparam/sched_setparam03.c             | 2 ++
 5 files changed, 6 insertions(+)
testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c +1 -0
index 7527c43..b6084f6 100644
@@ -115,6 +115,7 @@ int main(int ac, char **av)
 /* setup() - performs all ONE TIME setup for this test */
 void setup(void)
 {
+	tst_require_root();
 	/*
 	 * Initialize scheduling parameter structure to use with
 	 * sched_setscheduler()
testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c +1 -0
index 5410176..6bf743f 100644
@@ -119,6 +119,7 @@ int main(int ac, char **av)
 /* setup() - performs all ONE TIME setup for this test */
 void setup(void)
 {
+	tst_require_root();
 	/*
 	 * Initialize scheduling parameter structure to use with
 	 * sched_setscheduler()
testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c +1 -0
index c9686ad..56f2fcf 100644
@@ -142,6 +142,7 @@ int main(int ac, char **av)
 /* setup() - performs all ONE TIME setup for this test */
 void setup(void)
 {
+	tst_require_root();
 	/*
 	 * Initialize scheduling parameter structure to use with
 	 * sched_setscheduler()
testcases/kernel/syscalls/sched_setparam/sched_setparam02.c +1 -0
index 9321a4e..132cc9d 100644
@@ -145,6 +145,7 @@ int main(int ac, char **av)
 /* setup() - performs all ONE TIME setup for this test */
 void setup(void)
 {
+	tst_require_root();
 
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
testcases/kernel/syscalls/sched_setparam/sched_setparam03.c +2 -0
index 127a74f..50caecb 100644
@@ -150,6 +150,8 @@ int main(int ac, char **av)
 /* setup() - performs all ONE TIME setup for this test */
 void setup(void)
 {
+	tst_require_root();
+
 	struct sched_param p = { 1 };
 
 	tst_sig(FORK, DEF_HANDLER, cleanup);
Signature · 1 line
1.9.1
#2 lore raw

PATCH 1/3 sched_xxx: TCONF instead of TFAIL if user is not root

Hi!

testcases/kernel/syscalls/sched_setparam/sched_setparam03.c int main(int ac, char **av) · line 155

Quoted 5 lines

void setup(void)
{

testcases/kernel/syscalls/sched_setparam/sched_setparam03.c +2 -0
+	tst_require_root();
+
 	struct sched_param p = { 1 };

I've changed this part so that the call to tst_require_root() goes after the struct sched_param declaration and pushed, thanks.

Signature · 2 lines
Cyril Hrubis
[email protected]
#3 lore raw

PATCH 2/3 socketcall: TCONF instead of TFAIL when user is not root

In reply to Dejan Jovicevic

sockatcall01 uses certain protocols that require super user privileges.

---
 testcases/kernel/syscalls/socketcall/socketcall01.c | 1 +
 1 file changed, 1 insertion(+)
testcases/kernel/syscalls/socketcall/socketcall01.c +1 -0
index d439729..b576bd8 100644
@@ -142,6 +142,7 @@ int main(int ac, char **av)
 /* setup() - performs all ONE TIME setup for this test. */
 void setup(void)
 {
+	tst_require_root();
 
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
Signature · 1 line
1.9.1
#4 lore raw

PATCH 2/3 socketcall: TCONF instead of TFAIL when user is not root

Hi!

Quoted 2 lines

sockatcall01 uses certain protocols that require super user privileges.

Right, the RAW socket needs root. You should have included that in the commit message from the start. Pushed with better commit message, thanks.

Also it took me while to realize that the syscall is not implemented on x86_64 and that the test returns PASS wrongly instead of CONF. I have fixed that in another patch as well.

Signature · 2 lines
Cyril Hrubis
[email protected]
#5 lore raw

PATCH 3/3 inotify06: kernel version check

In reply to Dejan Jovicevic

For test inotify06, kernels prior to 4.2 have a race when inode is being deleted while inotify group watching that inode is being torn down. When the race is hit, the kernel crashes or loops. So, added a check to see if the kernel is >= 4.2.0, and if not, the test breaks with TCONF and an appropriate message.

---
 testcases/kernel/syscalls/inotify/inotify06.c | 3 +++
 1 file changed, 3 insertions(+)
testcases/kernel/syscalls/inotify/inotify06.c +3 -0
index 71f7596..1caa70d 100644
@@ -67,6 +67,9 @@ static void cleanup(void)
 
 static void setup(void)
 {
+    if (tst_kvercmp(4, 2, 0) < 0)
+		tst_brkm(TCONF, NULL, "Test must be run with kernel 4.2 or newer");
+
 	int i;
 
 	tst_sig(FORK, DEF_HANDLER, cleanup);
Signature · 1 line
1.9.1
#6 lore raw

PATCH 3/3 inotify06: kernel version check

Hi!

Quoted 5 lines

For test inotify06, kernels prior to 4.2 have a race when inode is being deleted while inotify group watching that inode is being torn down. When the race is hit, the kernel crashes or loops. So, added a check to see if the kernel is >= 4.2.0, and if not, the test breaks with TCONF and an appropriate message.

NO.

Bringing down broken kernel is exactly the whole point of the test. Otherwise you cannot tell if the fix was backported to your kernel or not.

Signature · 2 lines
Cyril Hrubis
[email protected]