All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/unshare02: Fix failures on Debian
@ 2021-05-14  8:07 Cyril Hrubis
  2021-05-14  9:12 ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2021-05-14  8:07 UTC (permalink / raw)
  To: ltp

The order of checks in kernel is not defined and on Debian we end up
getting eperm even before the flags are checked which fails the invalid
flags testcase.

The fix is simple, we change the test to setuid() only for the EPERM
test.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/syscalls/unshare/unshare02.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/testcases/kernel/syscalls/unshare/unshare02.c b/testcases/kernel/syscalls/unshare/unshare02.c
index e9bd9ed2c..9b222fae2 100644
--- a/testcases/kernel/syscalls/unshare/unshare02.c
+++ b/testcases/kernel/syscalls/unshare/unshare02.c
@@ -30,6 +30,8 @@
 
 #ifdef HAVE_UNSHARE
 
+static uid_t nobody_uid;
+
 static struct test_case_t {
 	int mode;
 	int expected_error;
@@ -42,20 +44,19 @@ static struct test_case_t {
 static void run(unsigned int i)
 {
 	pid_t pid = SAFE_FORK();
-	if (pid == 0)
+	if (pid == 0) {
+		if (tc[i].expected_error == EPERM)
+			SAFE_SETUID(nobody_uid);
+
 		TST_EXP_FAIL(unshare(tc[i].mode), tc[i].expected_error,
 			     "unshare(%s)", tc[i].desc);
+	}
 }
 
 static void setup(void)
 {
 	struct passwd *ltpuser = SAFE_GETPWNAM("nobody");
-	SAFE_SETEUID(ltpuser->pw_uid);
-}
-
-static void cleanup(void)
-{
-	SAFE_SETEUID(0);
+	nobody_uid = ltpuser->pw_uid;
 }
 
 static struct tst_test test = {
@@ -63,7 +64,6 @@ static struct tst_test test = {
 	.forks_child = 1,
 	.needs_tmpdir = 1,
 	.needs_root = 1,
-	.cleanup = cleanup,
 	.setup = setup,
 	.test = run,
 };
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [LTP] [PATCH] syscalls/unshare02: Fix failures on Debian
  2021-05-14  8:07 [LTP] [PATCH] syscalls/unshare02: Fix failures on Debian Cyril Hrubis
@ 2021-05-14  9:12 ` Petr Vorel
  2021-05-17  8:34   ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2021-05-14  9:12 UTC (permalink / raw)
  To: ltp

Hi Cyril,

> The order of checks in kernel is not defined and on Debian we end up
> getting eperm even before the flags are checked which fails the invalid
> flags testcase.

> The fix is simple, we change the test to setuid() only for the EPERM
> test.

Reviewed-by: Petr Vorel <pvorel@suse.cz>
Tested-by: Petr Vorel <pvorel@suse.cz>

Thanks!

Kind regards,
Petr


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [LTP] [PATCH] syscalls/unshare02: Fix failures on Debian
  2021-05-14  9:12 ` Petr Vorel
@ 2021-05-17  8:34   ` Cyril Hrubis
  0 siblings, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2021-05-17  8:34 UTC (permalink / raw)
  To: ltp

Hi!
Pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-17  8:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14  8:07 [LTP] [PATCH] syscalls/unshare02: Fix failures on Debian Cyril Hrubis
2021-05-14  9:12 ` Petr Vorel
2021-05-17  8:34   ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.