Skip to contentSkip to conversation

setfsuid02: Fix a fake failure for setfsuid02

PATCH In review You Zhou 2 participants 5 messages Oct 28, 2022 – Nov 1, 2022

lore
Share & tools
lore

You Zhou

author
#0 lore raw

PATCH 1/1 setfsuid02: Fix a fake failure for setfsuid02

When run setfsuid02 case on x86_64 platform, I got a failure even if the filesystem user ID is set successfully.
"
./setfsuid02
tst_test.c:1526: TINFO: Timeout per run is 0h 00m 30s setfsuid02.c:31: TFAIL: setfsuid(invalid_fsuid) test for expected

			failure: retval 11 != 0: SUCCESS (0)

Summary:

passed   0
failed   1
broken   0
skipped  0

warnings 0
"

On both success and failure, setfsuid syscall returns the previous filesystem user ID of the caller. In this case, if case sets filesystem user ID successfully for the first time, this syscall can return the ID previously set for the second time.

---
 testcases/kernel/syscalls/setfsuid/setfsuid02.c | 5 +++++
 1 file changed, 5 insertions(+)
testcases/kernel/syscalls/setfsuid/setfsuid02.c +5 -0
index 850f17834..441d1e27a 100644
@@ -28,8 +28,13 @@ static void run(void)
 	UID16_CHECK(invalid_uid, setfsuid);
 
 	TST_EXP_VAL_SILENT(SETFSUID(invalid_uid), current_uid);
+#if __x86_64__
+	TST_EXP_VAL(SETFSUID(invalid_uid), invalid_uid,
+		    "setfsuid(invalid_fsuid) test for expected failure:");
+#else
 	TST_EXP_VAL(SETFSUID(invalid_uid), current_uid,
 		    "setfsuid(invalid_fsuid) test for expected failure:");
+#endif
 }
 
 static struct tst_test test = {
Signature · 5 lines
2.25.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw
Quoted 32 lines

When run setfsuid02 case on x86_64 platform, I got a failure even if the filesystem user ID is set successfully.
"
./setfsuid02
tst_test.c:1526: TINFO: Timeout per run is 0h 00m 30s setfsuid02.c:31: TFAIL: setfsuid(invalid_fsuid) test for expected

			failure: retval 11 != 0: SUCCESS (0)

Summary:

passed   0
failed   1
broken   0
skipped  0

warnings 0
"

On both success and failure, setfsuid syscall returns the previous filesystem user ID of the caller. In this case, if case sets filesystem user ID successfully for the first time, this syscall can return the ID previously set for the second time.

---
 testcases/kernel/syscalls/setfsuid/setfsuid02.c | 5 +++++
 1 file changed, 5 insertions(+)
testcases/kernel/syscalls/setfsuid/setfsuid02.c +0 -0
index 850f17834..441d1e27a 100644

testcases/kernel/syscalls/setfsuid/setfsuid02.c static void run(void) · line 33

Quoted 6 lines
testcases/kernel/syscalls/setfsuid/setfsuid02.c +3 -0
@@ -28,8 +28,13 @@ static void run(void)
 	UID16_CHECK(invalid_uid, setfsuid);
 
 	TST_EXP_VAL_SILENT(SETFSUID(invalid_uid), current_uid);
+#if __x86_64__
+	TST_EXP_VAL(SETFSUID(invalid_uid), invalid_uid,
+		    "setfsuid(invalid_fsuid) test for expected failure:");

Hi You,

this is most certainly invalid way of fixing things.

Would you mind to test if the patch from Avinesh works for you?
https://lore.kernel.org/ltp/[email protected]/

Kind regards,
Petr

Quoted 7 lines
testcases/kernel/syscalls/setfsuid/setfsuid02.c +2 -0
+#else
 	TST_EXP_VAL(SETFSUID(invalid_uid), current_uid,
 		    "setfsuid(invalid_fsuid) test for expected failure:");
+#endif
 }
 
 static struct tst_test test = {
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hi You,

FYI fixed in 5398d6c41 ("setfsuid02: using -1 as invalid fsuid for setfsuid()").

BTW this test failed on other archs (at least on aarch64, ppc64le, I suspect it's not arch specific), therefore your solution would not work.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#3 lore raw
In reply to Petr Vorel

Hi, Petr,

I try the patch from Avinesh, the test result is normal, so the purpose of this test case is to try to set an invalid uid?

Best wishes
You Zhou

-----Original Message-----
From: Petr Vorel <[email protected]>
Sent: Monday, October 31, 2022 6:59 PM
To: Zhou, You <[email protected]>
Cc: [email protected]
Subject: Re: [LTP] [PATCH] setfsuid02: Fix a fake failure for setfsuid02

Quoted 33 lines

When run setfsuid02 case on x86_64 platform, I got a failure even if the filesystem user ID is set successfully.
"
./setfsuid02
tst_test.c:1526: TINFO: Timeout per run is 0h 00m 30s setfsuid02.c:31: TFAIL: setfsuid(invalid_fsuid) test for expected

			failure: retval 11 != 0: SUCCESS (0)

Summary:

passed   0
failed   1
broken   0
skipped  0

warnings 0
"

On both success and failure, setfsuid syscall returns the previous filesystem user ID of the caller. In this case, if case sets filesystem user ID successfully for the first time, this syscall can return the ID previously set for the second time.

---
 testcases/kernel/syscalls/setfsuid/setfsuid02.c | 5 +++++
 1 file changed, 5 insertions(+)
testcases/kernel/syscalls/setfsuid/setfsuid02.c +0 -0
index 850f17834..441d1e27a 100644

testcases/kernel/syscalls/setfsuid/setfsuid02.c static void run(void) · line 33

Quoted 6 lines
testcases/kernel/syscalls/setfsuid/setfsuid02.c +3 -0
@@ -28,8 +28,13 @@ static void run(void)
 	UID16_CHECK(invalid_uid, setfsuid);
 
 	TST_EXP_VAL_SILENT(SETFSUID(invalid_uid), current_uid);
+#if __x86_64__
+	TST_EXP_VAL(SETFSUID(invalid_uid), invalid_uid,
+		    "setfsuid(invalid_fsuid) test for expected failure:");

Hi You,

this is most certainly invalid way of fixing things.

Would you mind to test if the patch from Avinesh works for you?
https://lore.kernel.org/ltp/[email protected]/

Kind regards,
Petr

Quoted 7 lines
testcases/kernel/syscalls/setfsuid/setfsuid02.c +2 -0
+#else
 	TST_EXP_VAL(SETFSUID(invalid_uid), current_uid,
 		    "setfsuid(invalid_fsuid) test for expected failure:");
+#endif
 }
 
 static struct tst_test test = {
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Hi You,

Quoted 3 lines

Hi, Petr,

I try the patch from Avinesh, the test result is normal, so the purpose of this test case is to try to set an invalid uid?

yes, the purpose is to test that setfsuid() syscall fails if an passed invalid fsuid.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp