Skip to contentSkip to conversation

chown and 16 bit syscall testing

LTP In review Han Pingtian 2 participants 9 messages Oct 31, 2014 – Dec 5, 2014

lore
Share & tools
lore
#0 lore raw

Hey there,

I found that looks like all chown test cases will be compiled to 16 bit compat test case, but they just call chown() something like

    TEST(chown(fname, uid, gid));

which won't test if there is a 16 bit chown() syscall. I think maybe we should change it to something like below:

    TEST(CHOWN(fname, uid, guid));

then define CHOWN like this

    UID_T CHOWN(void (cleanup)(void))
    {
            LTP_CREATE_SYSCALL(chown, cleanup);
    }

?

Thanks in advance!

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#1 lore raw

Hi!

Quoted 12 lines · Han Pingtian

Hey there,

I found that looks like all chown test cases will be compiled to 16 bit compat test case, but they just call chown() something like

     TEST(chown(fname, uid, gid));

which won't test if there is a 16 bit chown() syscall. I think maybe we should change it to something like below:

     TEST(CHOWN(fname, uid, guid));
Quoted 8 lines

then define CHOWN like this

     UID_T CHOWN(void (cleanup)(void))
     {
             LTP_CREATE_SYSCALL(chown, cleanup);
     }

?

I think, this is a good idea.

And there are more such test cases, which are not fixed for the 16-bit compat case. For example, setresuid.

So if it's possible, fixing them will be good as well;)

Quoted 10 lines

Thanks in advance!

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw
Quoted 22 lines · Stanislav Kholmanskikh

Hi!

Quoted 19 lines · Han Pingtian

Hey there,

I found that looks like all chown test cases will be compiled to 16 bit compat test case, but they just call chown() something like

    TEST(chown(fname, uid, gid));

which won't test if there is a 16 bit chown() syscall. I think maybe we should change it to something like below:

    TEST(CHOWN(fname, uid, guid));

then define CHOWN like this

    UID_T CHOWN(void (cleanup)(void))
    {
            LTP_CREATE_SYSCALL(chown, cleanup);
    }
Quoted 9 lines
Quoted 1 line

?

I think, this is a good idea.

And there are more such test cases, which are not fixed for the 16-bit compat case. For example, setresuid.

So if it's possible, fixing them will be good as well;)

Looks like those cases need to be fixed for the 16-bit compat, right?

chown0[1-5] fchown0[1-5] lchown03 setresgid0[1-4] setresuid0[1-3,5]

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#3 lore raw
Quoted 27 lines · Han Pingtian
Quoted 26 lines · Stanislav Kholmanskikh

Hi!

Quoted 12 lines · Han Pingtian

Hey there,

I found that looks like all chown test cases will be compiled to 16 bit compat test case, but they just call chown() something like

     TEST(chown(fname, uid, gid));

which won't test if there is a 16 bit chown() syscall. I think maybe we should change it to something like below:

     TEST(CHOWN(fname, uid, guid));
Quoted 8 lines

then define CHOWN like this

     UID_T CHOWN(void (cleanup)(void))
     {
             LTP_CREATE_SYSCALL(chown, cleanup);
     }

?

I think, this is a good idea.

Quoted 8 lines
Quoted 5 lines

And there are more such test cases, which are not fixed for the 16-bit compat case. For example, setresuid.

So if it's possible, fixing them will be good as well;)

Looks like those cases need to be fixed for the 16-bit compat, right?

chown0[1-5] fchown0[1-5] lchown03 setresgid0[1-4] setresuid0[1-3,5]

Looks so.

Sorry for the late response.

Quoted 13 lines

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#4 lore raw

PATCH 1/1 fix some syscall tests for 16-bit compat testing

Quoted 8 lines · Stanislav Kholmanskikh
Quoted 3 lines

Looks like those cases need to be fixed for the 16-bit compat, right?

chown0[1-5] fchown0[1-5] lchown03 setresgid0[1-4] setresuid0[1-3,5]

Looks so.

Sorry for the late response.

I have composed a patch, please take a look. Thanks

From 71f5463f414e55d609603905e3f20b1f0eac2226 Mon Sep 17 00:00:00 2001
From: Han Pingtian <[email protected]>
Date: Fri, 21 Nov 2014 15:50:23 +0800
Subject: [PATCH] fix some syscall tests for 16-bit compat testing

Some syscall test cases have been compiled for 16-bit compat testing, but doesn't change the code yet. This fix try to add proper code to let them support this testing.

---
 testcases/kernel/syscalls/chown/chown01.c         |  3 ++-
 testcases/kernel/syscalls/chown/chown02.c         |  3 ++-
 testcases/kernel/syscalls/chown/chown03.c         |  3 ++-
 testcases/kernel/syscalls/chown/chown04.c         |  3 ++-
 testcases/kernel/syscalls/chown/chown05.c         |  3 ++-
 testcases/kernel/syscalls/fchown/fchown01.c       |  3 ++-
 testcases/kernel/syscalls/fchown/fchown02.c       |  3 ++-
 testcases/kernel/syscalls/fchown/fchown03.c       |  3 ++-
 testcases/kernel/syscalls/fchown/fchown04.c       |  3 ++-
 testcases/kernel/syscalls/fchown/fchown05.c       |  3 ++-
 testcases/kernel/syscalls/lchown/lchown03.c       |  3 ++-
 testcases/kernel/syscalls/setresgid/setresgid01.c |  3 ++-
 testcases/kernel/syscalls/setresgid/setresgid02.c |  3 ++-
 testcases/kernel/syscalls/setresgid/setresgid03.c |  3 ++-
 testcases/kernel/syscalls/setresgid/setresgid04.c |  3 ++-
 testcases/kernel/syscalls/setresuid/setresuid01.c |  3 ++-
 testcases/kernel/syscalls/setresuid/setresuid02.c |  3 ++-
 testcases/kernel/syscalls/setresuid/setresuid03.c |  2 +-
 testcases/kernel/syscalls/setresuid/setresuid04.c |  9 +++++----
 testcases/kernel/syscalls/setresuid/setresuid05.c |  3 ++-
 testcases/kernel/syscalls/utils/compat_16.h       | 20 ++++++++++++++++++++
 21 files changed, 62 insertions(+), 23 deletions(-)
testcases/kernel/syscalls/chown/chown01.c +2 -1
index ef728e1..5cf33dc 100644
@@ -117,6 +117,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 char *TCID = "chown01";
 int TST_TOTAL = 1;
@@ -145,7 +146,7 @@ int main(int ac, char **av)
 
 		tst_count = 0;
 
-		TEST(chown(fname, uid, gid));
+		TEST(CHOWN(cleanup, fname, uid, gid));
 
 		if (TEST_RETURN == -1) {
 			tst_resm(TFAIL | TTERRNO, "chown(%s, %d,%d) failed",
testcases/kernel/syscalls/chown/chown02.c +2 -1
index 339b2e8..30394ec 100644
@@ -79,6 +79,7 @@
 
 #include "test.h"
 #include "usctest.h"
+#include "compat_16.h"
 
 #define FILE_MODE	(S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
 #define NEW_PERMS1	(S_IFREG|S_IRWXU|S_IRWXG|S_ISUID|S_ISGID)
@@ -142,7 +143,7 @@ int main(int ac, char **av)
 			 * Call chown(2) with different user id and
 			 * group id (numeric values) to set it on testfile.
 			 */
-			TEST(chown(file_name, user_id, group_id));
+			TEST(CHOWN(cleanup, file_name, user_id, group_id));
 
 			if (TEST_RETURN == -1) {
 				tst_resm(TFAIL | TTERRNO,
testcases/kernel/syscalls/chown/chown03.c +2 -1
index 9780c2f..0ed4c91 100644
@@ -82,6 +82,7 @@
 
 #include "test.h"
 #include "usctest.h"
+#include "compat_16.h"
 
 #define FILE_MODE	(S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
 #define NEW_PERMS	(S_IFREG|S_IRWXU|S_IRWXG|S_ISUID|S_ISGID)
@@ -115,7 +116,7 @@ int main(int ac, char **av)
 		user_id = geteuid();
 		group_id = getegid();
 
-		TEST(chown(TESTFILE, -1, group_id));
+		TEST(CHOWN(cleanup, TESTFILE, -1, group_id));
 
 		if (TEST_RETURN == -1) {
 			tst_resm(TFAIL | TTERRNO, "chown(%s, ..) failed",
testcases/kernel/syscalls/chown/chown04.c +2 -1
index 1459227..b07dfa8 100644
@@ -55,6 +55,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 #define MODE_RWX		 (S_IRWXU|S_IRWXG|S_IRWXO)
 #define FILE_MODE		 (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
@@ -118,7 +119,7 @@ int main(int ac, char **av)
 		tst_count = 0;
 
 		for (i = 0; i < TST_TOTAL; i++) {
-			TEST(chown(tc[i].pathname, user_id, group_id));
+			TEST(CHOWN(cleanup, tc[i].pathname, user_id, group_id));
 
 			if (TEST_RETURN == 0) {
 				tst_resm(TFAIL, "chown succeeded unexpectedly");
testcases/kernel/syscalls/chown/chown05.c +2 -1
index 92e1811..3ec4f13 100644
@@ -77,6 +77,7 @@
 
 #include "test.h"
 #include "usctest.h"
+#include "compat_16.h"
 
 #define FILE_MODE	(S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
 #define TESTFILE	"testfile"
@@ -121,7 +122,7 @@ int main(int ac, char **av)
 			user_id = test_cases[i].user_id;
 			group_id = test_cases[i].group_id;
 
-			TEST(chown(TESTFILE, user_id, group_id));
+			TEST(CHOWN(cleanup, TESTFILE, user_id, group_id));
 
 			if (TEST_RETURN == -1) {
 				tst_resm(TFAIL | TTERRNO, "chown failed");
testcases/kernel/syscalls/fchown/fchown01.c +2 -1
index be620d7..841e02b 100644
@@ -42,6 +42,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 static void setup(void);
 static void cleanup(void);
@@ -65,7 +66,7 @@ int main(int ac, char **av)
 
 		tst_count = 0;
 
-		TEST(fchown(fd, geteuid(), getegid()));
+		TEST(FCHOWN(cleanup, fd, geteuid(), getegid()));
 
 		if (TEST_RETURN == -1) {
 			tst_resm(TFAIL | TTERRNO, "fchown failed");
testcases/kernel/syscalls/fchown/fchown02.c +2 -1
index fd14ba1..0c1782d 100644
@@ -38,6 +38,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 #define FILE_MODE	S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
 #define NEW_PERMS1	S_IFREG | S_IRWXU | S_IRWXG | S_ISUID | S_ISGID
@@ -71,7 +72,7 @@ static void verify_fchown(struct test_case *t)
 {
 	struct stat stat_buf;
 
-	TEST(fchown(*t->fd, t->user_id, t->group_id));
+	TEST(FCHOWN(cleanup, *t->fd, t->user_id, t->group_id));
 
 	if (TEST_RETURN == -1) {
 		tst_resm(TFAIL | TTERRNO, "fchown() Fails on %s", t->pathname);
testcases/kernel/syscalls/fchown/fchown03.c +2 -1
index 3a75093..d0218b2 100644
@@ -41,6 +41,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 #define FILE_MODE (mode_t)(S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
 #define NEW_PERMS (mode_t)(S_IFREG | S_IRWXU | S_IRWXG | S_ISUID | S_ISGID)
@@ -77,7 +78,7 @@ int main(int ac, char **av)
 		user_id = geteuid();
 		group_id = getegid();
 
-		TEST(fchown(fildes, -1, group_id));
+		TEST(FCHOWN(cleanup, fildes, -1, group_id));
 
 		if (TEST_RETURN == -1) {
 			tst_resm(TFAIL, "fchown() on %s Fails, errno=%d",
testcases/kernel/syscalls/fchown/fchown04.c +2 -1
index 0829944..6dec6cb 100644
@@ -45,6 +45,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 #define DIR_MODE	(S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
 			 S_IXGRP|S_IROTH|S_IXOTH)
@@ -140,7 +141,7 @@ static void setup(void)
 
 static void fchown_verify(int i)
 {
-	TEST(fchown(*test_cases[i].fd, geteuid(), getegid()));
+	TEST(FCHOWN(cleanup, *test_cases[i].fd, geteuid(), getegid()));
 
 	if (TEST_RETURN == -1) {
 		if (TEST_ERRNO == test_cases[i].exp_errno) {
testcases/kernel/syscalls/fchown/fchown05.c +2 -1
index 67a745a..47d5b00 100644
@@ -34,6 +34,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 #define FILE_MODE	S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
 #define TESTFILE	"testfile"
@@ -80,7 +81,7 @@ int main(int ac, char **av)
 			user_id = tc[i].user_id;
 			group_id = tc[i].group_id;
 
-			TEST(fchown(fildes, user_id, group_id));
+			TEST(FCHOWN(cleanup, fildes, user_id, group_id));
 
 			if (TEST_RETURN == -1) {
 				tst_resm(TFAIL | TTERRNO,
testcases/kernel/syscalls/lchown/lchown03.c +2 -1
index 9e4d6f9..8624728 100644
@@ -40,6 +40,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 #define DIR_MODE	(S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
 			 S_IXGRP|S_IROTH|S_IXOTH)
@@ -124,7 +125,7 @@ static void setup(void)
 
 static void lchown_verify(const struct test_case_t *test)
 {
-	TEST(lchown(test->pathname, geteuid(), getegid()));
+	TEST(LCHOWN(cleanup, test->pathname, geteuid(), getegid()));
 
 	if (TEST_RETURN != -1) {
 		tst_resm(TFAIL, "lchown() returned %ld, expected -1, errno=%d",
testcases/kernel/syscalls/setresgid/setresgid01.c +2 -1
index f9c62a0..db3b9dc 100644
@@ -76,6 +76,7 @@
 #include <unistd.h>
 #include "test.h"
 #include "usctest.h"
+#include "compat_16.h"
 
 #define EXP_RET_VAL	0
 
@@ -131,7 +132,7 @@ int main(int argc, char **argv)
 
 		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			TEST(setresgid(*tdat[testno].rgid, *tdat[testno].egid,
+			TEST(SETRESGID(cleanup, *tdat[testno].rgid, *tdat[testno].egid,
 				       *tdat[testno].sgid));
 
 			if (TEST_RETURN == EXP_RET_VAL) {
testcases/kernel/syscalls/setresgid/setresgid02.c +2 -1
index 754fca1..e0c935d 100644
@@ -81,6 +81,7 @@
 #include <unistd.h>
 #include "test.h"
 #include "usctest.h"
+#include "compat_16.h"
 
 #define EXP_RET_VAL	0
 
@@ -138,7 +139,7 @@ int main(int argc, char **argv)
 
 		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			TEST(setresgid(*tdat[testno].rgid, *tdat[testno].egid,
+			TEST(SETRESGID(cleanup, *tdat[testno].rgid, *tdat[testno].egid,
 				       *tdat[testno].sgid));
 
 			if (TEST_RETURN == EXP_RET_VAL) {
testcases/kernel/syscalls/setresgid/setresgid03.c +2 -1
index 32d7995..0e9801e 100644
@@ -81,6 +81,7 @@
 #include <unistd.h>
 #include "test.h"
 #include "usctest.h"
+#include "compat_16.h"
 
 #define EXP_RET_VAL	-1
 #define EXP_ERRNO	EPERM
@@ -131,7 +132,7 @@ int main(int argc, char **argv)
 
 		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			TEST(setresgid(*tdat[testno].rgid, *tdat[testno].egid,
+			TEST(SETRESGID(cleanup, *tdat[testno].rgid, *tdat[testno].egid,
 				       *tdat[testno].sgid));
 
 			TEST_ERROR_LOG(TEST_ERRNO);
testcases/kernel/syscalls/setresgid/setresgid04.c +2 -1
index 4e71910..cc481ce 100644
@@ -30,6 +30,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 char *TCID = "setresgid04";
 int TST_TOTAL = 1;
@@ -76,7 +77,7 @@ static void setresgid_verify(void)
 {
 	struct stat buf;
 
-	TEST(setresgid(-1, ltpuser->pw_gid, -1));
+	TEST(SETRESGID(cleanup, -1, ltpuser->pw_gid, -1));
 
 	if (TEST_RETURN != 0) {
 		tst_resm(TFAIL | TTERRNO, "setresgid failed unexpectedly");
testcases/kernel/syscalls/setresuid/setresuid01.c +2 -1
index 39e1ac3..49211c1 100644
@@ -69,6 +69,7 @@
 #include "test.h"
 #include "usctest.h"
 #include <errno.h>
+#include "compat_16.h"
 
 char *TCID = "setresuid01";
 
@@ -140,7 +141,7 @@ int main(int ac, char **av)
 
 		for (i = 0; i < TST_TOTAL; i++) {
 			/* Set the real, effective or user id */
-			TEST(setresuid(*test_data[i].real_uid,
+			TEST(SETRESUID(cleanup, *test_data[i].real_uid,
 				       *test_data[i].eff_uid,
 				       *test_data[i].sav_uid));
 
testcases/kernel/syscalls/setresuid/setresuid02.c +2 -1
index 0837c9e..5e1b7fd 100644
@@ -65,6 +65,7 @@
 #include "usctest.h"
 #include <errno.h>
 #include <sys/wait.h>
+#include "compat_16.h"
 
 char *TCID = "setresuid02";
 
@@ -140,7 +141,7 @@ int main(int ac, char **av)
 			for (i = 0; i < TST_TOTAL; i++) {
 
 				/* Set the real, effective or saved user id */
-				TEST(setresuid(*test_data[i].real_uid,
+				TEST(SETRESUID(cleanup, *test_data[i].real_uid,
 					       *test_data[i].eff_uid,
 					       *test_data[i].sav_uid));
 
testcases/kernel/syscalls/setresuid/setresuid03.c +1 -1
index f624253..592c764 100644
@@ -150,7 +150,7 @@ int main(int ac, char **av)
 			for (i = 0; i < TST_TOTAL; i++) {
 
 				/* Set the real, effective or saved user id */
-				TEST(setresuid(*test_data[i].real_uid,
+				TEST(SETRESUID(cleanup, *test_data[i].real_uid,
 					       *test_data[i].eff_uid,
 					       *test_data[i].sav_uid));
 
testcases/kernel/syscalls/setresuid/setresuid04.c +5 -4
index 140d5f3..dfc9058 100644
@@ -53,6 +53,7 @@
 #include "test.h"
 #include "usctest.h"
 #include <pwd.h>
+#include "compat_16.h"
 
 char *TCID = "setresuid04";
 int TST_TOTAL = 1;
@@ -111,8 +112,8 @@ void do_master_child(void)
 		/* Reset tst_count in case we are looping */
 		tst_count = 0;
 
-		if (setresuid(0, ltpuser->pw_uid, 0) == -1) {
-			perror("setfsuid failed");
+		if (SETRESUID(cleanup, 0, ltpuser->pw_uid, 0) == -1) {
+			perror("setresuid failed");
 			exit(1);
 		}
 
@@ -176,8 +177,8 @@ void do_master_child(void)
 		 *         the file with RDWR permissions.
 		 */
 		tst_count++;
-		if (setresuid(0, 0, 0) == -1) {
-			perror("setfsuid failed");
+		if (SETRESUID(cleanup, 0, 0, 0) == -1) {
+			perror("setresuid failed");
 			exit(1);
 		}
 
testcases/kernel/syscalls/setresuid/setresuid05.c +2 -1
index 8880aeb..44d1565 100644
@@ -30,6 +30,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 char *TCID = "setresuid05";
 int TST_TOTAL = 1;
@@ -76,7 +77,7 @@ static void setresuid_verify(void)
 {
 	struct stat buf;
 
-	TEST(setresuid(-1, ltpuser->pw_uid, -1));
+	TEST(SETRESUID(cleanup, -1, ltpuser->pw_uid, -1));
 
 	if (TEST_RETURN != 0) {
 		tst_resm(TFAIL | TTERRNO, "setresuid failed unexpectedly");
testcases/kernel/syscalls/utils/compat_16.h +20 -0
index 40bef59..b6a702d 100644
@@ -127,8 +127,28 @@ int SETREGID(void (cleanup)(void), GID_T rgid, GID_T egid)
 	LTP_CREATE_SYSCALL(setregid, cleanup, rgid, egid);
 }
 
+int SETRESUID(void (cleanup)(void), UID_T ruid, UID_T euid, UID_T suid)
+{
+	LTP_CREATE_SYSCALL(setresuid, cleanup, ruid, euid, suid);
+}
+
+int SETRESGID(void (cleanup)(void), GID_T rgid, GID_T egid, GID_T sgid)
+{
+	LTP_CREATE_SYSCALL(setresgid, cleanup, rgid, egid, sgid);
+}
+
+int FCHOWN(void (cleanup)(void), unsigned int fd, UID_T owner, GID_T group)
+{
+	LTP_CREATE_SYSCALL(fchown, cleanup, fd, owner, group);
+}
+
 int LCHOWN(void (cleanup)(void), const char *path, UID_T owner, GID_T group)
 {
 	LTP_CREATE_SYSCALL(lchown, cleanup, path, owner, group);
 }
+
+int CHOWN(void (cleanup)(void), const char *path, UID_T owner, GID_T group)
+{
+	LTP_CREATE_SYSCALL(chown, cleanup, path, owner, group);
+}
 #endif /* __LTP_COMPAT_16_H__ */
Signature · 13 lines
1.9.3


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#5 lore raw

Re: [LTP] [PATCH] fix some syscall tests for 16-bit compat testing

Hi.

In general, it looks good.

I have only one comment, that it's possible that the uid/gid values we pass to the syscall may not fit into UID_T/GID_T. For example, when we get uid of nobody user in runtime and pass it to chown() or etc.

Yes, it's more like an artificial case, but it's.

We have UID16_CHECK and GID16_CHECK macros to check if the uid/gid fits the compat mode.

What do you think about using it in test cases chown01, chown03, chown04, fchown01, fchown03, fchown04, setresgid*, setresuid* ?

Thank you.

Quoted 495 lines · Han Pingtian
Quoted 8 lines · Stanislav Kholmanskikh
Quoted 3 lines

Looks like those cases need to be fixed for the 16-bit compat, right?

chown0[1-5] fchown0[1-5] lchown03 setresgid0[1-4] setresuid0[1-3,5]

Looks so.

Sorry for the late response.

I have composed a patch, please take a look. Thanks

From 71f5463f414e55d609603905e3f20b1f0eac2226 Mon Sep 17 00:00:00 2001
From: Han Pingtian <[email protected]>
Date: Fri, 21 Nov 2014 15:50:23 +0800
Subject: [PATCH] fix some syscall tests for 16-bit compat testing

Some syscall test cases have been compiled for 16-bit compat testing, but doesn't change the code yet. This fix try to add proper code to let them support this testing.

---
  testcases/kernel/syscalls/chown/chown01.c         |  3 ++-
  testcases/kernel/syscalls/chown/chown02.c         |  3 ++-
  testcases/kernel/syscalls/chown/chown03.c         |  3 ++-
  testcases/kernel/syscalls/chown/chown04.c         |  3 ++-
  testcases/kernel/syscalls/chown/chown05.c         |  3 ++-
  testcases/kernel/syscalls/fchown/fchown01.c       |  3 ++-
  testcases/kernel/syscalls/fchown/fchown02.c       |  3 ++-
  testcases/kernel/syscalls/fchown/fchown03.c       |  3 ++-
  testcases/kernel/syscalls/fchown/fchown04.c       |  3 ++-
  testcases/kernel/syscalls/fchown/fchown05.c       |  3 ++-
  testcases/kernel/syscalls/lchown/lchown03.c       |  3 ++-
  testcases/kernel/syscalls/setresgid/setresgid01.c |  3 ++-
  testcases/kernel/syscalls/setresgid/setresgid02.c |  3 ++-
  testcases/kernel/syscalls/setresgid/setresgid03.c |  3 ++-
  testcases/kernel/syscalls/setresgid/setresgid04.c |  3 ++-
  testcases/kernel/syscalls/setresuid/setresuid01.c |  3 ++-
  testcases/kernel/syscalls/setresuid/setresuid02.c |  3 ++-
  testcases/kernel/syscalls/setresuid/setresuid03.c |  2 +-
  testcases/kernel/syscalls/setresuid/setresuid04.c |  9 +++++----
  testcases/kernel/syscalls/setresuid/setresuid05.c |  3 ++-
  testcases/kernel/syscalls/utils/compat_16.h       | 20 ++++++++++++++++++++
  21 files changed, 62 insertions(+), 23 deletions(-)
testcases/kernel/syscalls/chown/chown01.c +2 -1
index ef728e1..5cf33dc 100644
@@ -117,6 +117,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  char *TCID = "chown01";
  int TST_TOTAL = 1;
@@ -145,7 +146,7 @@ int main(int ac, char **av)
 
  		tst_count = 0;
 
-		TEST(chown(fname, uid, gid));
+		TEST(CHOWN(cleanup, fname, uid, gid));
 
  		if (TEST_RETURN == -1) {
  			tst_resm(TFAIL | TTERRNO, "chown(%s, %d,%d) failed",
testcases/kernel/syscalls/chown/chown02.c +2 -1
index 339b2e8..30394ec 100644
@@ -79,6 +79,7 @@
 
  #include "test.h"
  #include "usctest.h"
+#include "compat_16.h"
 
  #define FILE_MODE	(S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
  #define NEW_PERMS1	(S_IFREG|S_IRWXU|S_IRWXG|S_ISUID|S_ISGID)
@@ -142,7 +143,7 @@ int main(int ac, char **av)
  			 * Call chown(2) with different user id and
  			 * group id (numeric values) to set it on testfile.
  			 */
-			TEST(chown(file_name, user_id, group_id));
+			TEST(CHOWN(cleanup, file_name, user_id, group_id));
 
  			if (TEST_RETURN == -1) {
  				tst_resm(TFAIL | TTERRNO,
testcases/kernel/syscalls/chown/chown03.c +2 -1
index 9780c2f..0ed4c91 100644
@@ -82,6 +82,7 @@
 
  #include "test.h"
  #include "usctest.h"
+#include "compat_16.h"
 
  #define FILE_MODE	(S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
  #define NEW_PERMS	(S_IFREG|S_IRWXU|S_IRWXG|S_ISUID|S_ISGID)
@@ -115,7 +116,7 @@ int main(int ac, char **av)
  		user_id = geteuid();
  		group_id = getegid();
 
-		TEST(chown(TESTFILE, -1, group_id));
+		TEST(CHOWN(cleanup, TESTFILE, -1, group_id));
 
  		if (TEST_RETURN == -1) {
  			tst_resm(TFAIL | TTERRNO, "chown(%s, ..) failed",
testcases/kernel/syscalls/chown/chown04.c +2 -1
index 1459227..b07dfa8 100644
@@ -55,6 +55,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  #define MODE_RWX		 (S_IRWXU|S_IRWXG|S_IRWXO)
  #define FILE_MODE		 (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
@@ -118,7 +119,7 @@ int main(int ac, char **av)
  		tst_count = 0;
 
  		for (i = 0; i < TST_TOTAL; i++) {
-			TEST(chown(tc[i].pathname, user_id, group_id));
+			TEST(CHOWN(cleanup, tc[i].pathname, user_id, group_id));
 
  			if (TEST_RETURN == 0) {
  				tst_resm(TFAIL, "chown succeeded unexpectedly");
testcases/kernel/syscalls/chown/chown05.c +2 -1
index 92e1811..3ec4f13 100644
@@ -77,6 +77,7 @@
 
  #include "test.h"
  #include "usctest.h"
+#include "compat_16.h"
 
  #define FILE_MODE	(S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
  #define TESTFILE	"testfile"
@@ -121,7 +122,7 @@ int main(int ac, char **av)
  			user_id = test_cases[i].user_id;
  			group_id = test_cases[i].group_id;
 
-			TEST(chown(TESTFILE, user_id, group_id));
+			TEST(CHOWN(cleanup, TESTFILE, user_id, group_id));
 
  			if (TEST_RETURN == -1) {
  				tst_resm(TFAIL | TTERRNO, "chown failed");
testcases/kernel/syscalls/fchown/fchown01.c +2 -1
index be620d7..841e02b 100644
@@ -42,6 +42,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  static void setup(void);
  static void cleanup(void);
@@ -65,7 +66,7 @@ int main(int ac, char **av)
 
  		tst_count = 0;
 
-		TEST(fchown(fd, geteuid(), getegid()));
+		TEST(FCHOWN(cleanup, fd, geteuid(), getegid()));
 
  		if (TEST_RETURN == -1) {
  			tst_resm(TFAIL | TTERRNO, "fchown failed");
testcases/kernel/syscalls/fchown/fchown02.c +2 -1
index fd14ba1..0c1782d 100644
@@ -38,6 +38,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  #define FILE_MODE	S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
  #define NEW_PERMS1	S_IFREG | S_IRWXU | S_IRWXG | S_ISUID | S_ISGID
@@ -71,7 +72,7 @@ static void verify_fchown(struct test_case *t)
  {
  	struct stat stat_buf;
 
-	TEST(fchown(*t->fd, t->user_id, t->group_id));
+	TEST(FCHOWN(cleanup, *t->fd, t->user_id, t->group_id));
 
  	if (TEST_RETURN == -1) {
  		tst_resm(TFAIL | TTERRNO, "fchown() Fails on %s", t->pathname);
testcases/kernel/syscalls/fchown/fchown03.c +2 -1
index 3a75093..d0218b2 100644
@@ -41,6 +41,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  #define FILE_MODE (mode_t)(S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
  #define NEW_PERMS (mode_t)(S_IFREG | S_IRWXU | S_IRWXG | S_ISUID | S_ISGID)
@@ -77,7 +78,7 @@ int main(int ac, char **av)
  		user_id = geteuid();
  		group_id = getegid();
 
-		TEST(fchown(fildes, -1, group_id));
+		TEST(FCHOWN(cleanup, fildes, -1, group_id));
 
  		if (TEST_RETURN == -1) {
  			tst_resm(TFAIL, "fchown() on %s Fails, errno=%d",
testcases/kernel/syscalls/fchown/fchown04.c +2 -1
index 0829944..6dec6cb 100644
@@ -45,6 +45,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  #define DIR_MODE	(S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
  			 S_IXGRP|S_IROTH|S_IXOTH)
@@ -140,7 +141,7 @@ static void setup(void)
 
  static void fchown_verify(int i)
  {
-	TEST(fchown(*test_cases[i].fd, geteuid(), getegid()));
+	TEST(FCHOWN(cleanup, *test_cases[i].fd, geteuid(), getegid()));
 
  	if (TEST_RETURN == -1) {
  		if (TEST_ERRNO == test_cases[i].exp_errno) {
testcases/kernel/syscalls/fchown/fchown05.c +2 -1
index 67a745a..47d5b00 100644
@@ -34,6 +34,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  #define FILE_MODE	S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
  #define TESTFILE	"testfile"
@@ -80,7 +81,7 @@ int main(int ac, char **av)
  			user_id = tc[i].user_id;
  			group_id = tc[i].group_id;
 
-			TEST(fchown(fildes, user_id, group_id));
+			TEST(FCHOWN(cleanup, fildes, user_id, group_id));
 
  			if (TEST_RETURN == -1) {
  				tst_resm(TFAIL | TTERRNO,
testcases/kernel/syscalls/lchown/lchown03.c +2 -1
index 9e4d6f9..8624728 100644
@@ -40,6 +40,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  #define DIR_MODE	(S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
  			 S_IXGRP|S_IROTH|S_IXOTH)
@@ -124,7 +125,7 @@ static void setup(void)
 
  static void lchown_verify(const struct test_case_t *test)
  {
-	TEST(lchown(test->pathname, geteuid(), getegid()));
+	TEST(LCHOWN(cleanup, test->pathname, geteuid(), getegid()));
 
  	if (TEST_RETURN != -1) {
  		tst_resm(TFAIL, "lchown() returned %ld, expected -1, errno=%d",
testcases/kernel/syscalls/setresgid/setresgid01.c +2 -1
index f9c62a0..db3b9dc 100644
@@ -76,6 +76,7 @@
  #include <unistd.h>
  #include "test.h"
  #include "usctest.h"
+#include "compat_16.h"
 
  #define EXP_RET_VAL	0
 
@@ -131,7 +132,7 @@ int main(int argc, char **argv)
 
  		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			TEST(setresgid(*tdat[testno].rgid, *tdat[testno].egid,
+			TEST(SETRESGID(cleanup, *tdat[testno].rgid, *tdat[testno].egid,
  				       *tdat[testno].sgid));
 
  			if (TEST_RETURN == EXP_RET_VAL) {
testcases/kernel/syscalls/setresgid/setresgid02.c +2 -1
index 754fca1..e0c935d 100644
@@ -81,6 +81,7 @@
  #include <unistd.h>
  #include "test.h"
  #include "usctest.h"
+#include "compat_16.h"
 
  #define EXP_RET_VAL	0
 
@@ -138,7 +139,7 @@ int main(int argc, char **argv)
 
  		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			TEST(setresgid(*tdat[testno].rgid, *tdat[testno].egid,
+			TEST(SETRESGID(cleanup, *tdat[testno].rgid, *tdat[testno].egid,
  				       *tdat[testno].sgid));
 
  			if (TEST_RETURN == EXP_RET_VAL) {
testcases/kernel/syscalls/setresgid/setresgid03.c +2 -1
index 32d7995..0e9801e 100644
@@ -81,6 +81,7 @@
  #include <unistd.h>
  #include "test.h"
  #include "usctest.h"
+#include "compat_16.h"
 
  #define EXP_RET_VAL	-1
  #define EXP_ERRNO	EPERM
@@ -131,7 +132,7 @@ int main(int argc, char **argv)
 
  		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			TEST(setresgid(*tdat[testno].rgid, *tdat[testno].egid,
+			TEST(SETRESGID(cleanup, *tdat[testno].rgid, *tdat[testno].egid,
  				       *tdat[testno].sgid));
 
  			TEST_ERROR_LOG(TEST_ERRNO);
testcases/kernel/syscalls/setresgid/setresgid04.c +2 -1
index 4e71910..cc481ce 100644
@@ -30,6 +30,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  char *TCID = "setresgid04";
  int TST_TOTAL = 1;
@@ -76,7 +77,7 @@ static void setresgid_verify(void)
  {
  	struct stat buf;
 
-	TEST(setresgid(-1, ltpuser->pw_gid, -1));
+	TEST(SETRESGID(cleanup, -1, ltpuser->pw_gid, -1));
 
  	if (TEST_RETURN != 0) {
  		tst_resm(TFAIL | TTERRNO, "setresgid failed unexpectedly");
testcases/kernel/syscalls/setresuid/setresuid01.c +2 -1
index 39e1ac3..49211c1 100644
@@ -69,6 +69,7 @@
  #include "test.h"
  #include "usctest.h"
  #include <errno.h>
+#include "compat_16.h"
 
  char *TCID = "setresuid01";
 
@@ -140,7 +141,7 @@ int main(int ac, char **av)
 
  		for (i = 0; i < TST_TOTAL; i++) {
  			/* Set the real, effective or user id */
-			TEST(setresuid(*test_data[i].real_uid,
+			TEST(SETRESUID(cleanup, *test_data[i].real_uid,
  				       *test_data[i].eff_uid,
  				       *test_data[i].sav_uid));
 
testcases/kernel/syscalls/setresuid/setresuid02.c +2 -1
index 0837c9e..5e1b7fd 100644
@@ -65,6 +65,7 @@
  #include "usctest.h"
  #include <errno.h>
  #include <sys/wait.h>
+#include "compat_16.h"
 
  char *TCID = "setresuid02";
 
@@ -140,7 +141,7 @@ int main(int ac, char **av)
  			for (i = 0; i < TST_TOTAL; i++) {
 
  				/* Set the real, effective or saved user id */
-				TEST(setresuid(*test_data[i].real_uid,
+				TEST(SETRESUID(cleanup, *test_data[i].real_uid,
  					       *test_data[i].eff_uid,
  					       *test_data[i].sav_uid));
 
testcases/kernel/syscalls/setresuid/setresuid03.c +1 -1
index f624253..592c764 100644
@@ -150,7 +150,7 @@ int main(int ac, char **av)
  			for (i = 0; i < TST_TOTAL; i++) {
 
  				/* Set the real, effective or saved user id */
-				TEST(setresuid(*test_data[i].real_uid,
+				TEST(SETRESUID(cleanup, *test_data[i].real_uid,
  					       *test_data[i].eff_uid,
  					       *test_data[i].sav_uid));
 
testcases/kernel/syscalls/setresuid/setresuid04.c +5 -4
index 140d5f3..dfc9058 100644
@@ -53,6 +53,7 @@
  #include "test.h"
  #include "usctest.h"
  #include <pwd.h>
+#include "compat_16.h"
 
  char *TCID = "setresuid04";
  int TST_TOTAL = 1;
@@ -111,8 +112,8 @@ void do_master_child(void)
  		/* Reset tst_count in case we are looping */
  		tst_count = 0;
 
-		if (setresuid(0, ltpuser->pw_uid, 0) == -1) {
-			perror("setfsuid failed");
+		if (SETRESUID(cleanup, 0, ltpuser->pw_uid, 0) == -1) {
+			perror("setresuid failed");
  			exit(1);
  		}
 
@@ -176,8 +177,8 @@ void do_master_child(void)
  		 *         the file with RDWR permissions.
  		 */
  		tst_count++;
-		if (setresuid(0, 0, 0) == -1) {
-			perror("setfsuid failed");
+		if (SETRESUID(cleanup, 0, 0, 0) == -1) {
+			perror("setresuid failed");
  			exit(1);
  		}
 
testcases/kernel/syscalls/setresuid/setresuid05.c +2 -1
index 8880aeb..44d1565 100644
@@ -30,6 +30,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  char *TCID = "setresuid05";
  int TST_TOTAL = 1;
@@ -76,7 +77,7 @@ static void setresuid_verify(void)
  {
  	struct stat buf;
 
-	TEST(setresuid(-1, ltpuser->pw_uid, -1));
+	TEST(SETRESUID(cleanup, -1, ltpuser->pw_uid, -1));
 
  	if (TEST_RETURN != 0) {
  		tst_resm(TFAIL | TTERRNO, "setresuid failed unexpectedly");
testcases/kernel/syscalls/utils/compat_16.h +15 -0
index 40bef59..b6a702d 100644
@@ -127,8 +127,28 @@ int SETREGID(void (cleanup)(void), GID_T rgid, GID_T egid)
  	LTP_CREATE_SYSCALL(setregid, cleanup, rgid, egid);
  }
 
+int SETRESUID(void (cleanup)(void), UID_T ruid, UID_T euid, UID_T suid)
+{
+	LTP_CREATE_SYSCALL(setresuid, cleanup, ruid, euid, suid);
+}
+
+int SETRESGID(void (cleanup)(void), GID_T rgid, GID_T egid, GID_T sgid)
+{
+	LTP_CREATE_SYSCALL(setresgid, cleanup, rgid, egid, sgid);
+}
+
+int FCHOWN(void (cleanup)(void), unsigned int fd, UID_T owner, GID_T group)
+{
+	LTP_CREATE_SYSCALL(fchown, cleanup, fd, owner, group);
+}
+

testcases/kernel/syscalls/utils/compat_16.h int SETREGID(void (cleanup)(void), GID_T rgid, GID_T egid) · line 154

Quoted 10 lines
testcases/kernel/syscalls/utils/compat_16.h +5 -0
  int LCHOWN(void (cleanup)(void), const char *path, UID_T owner, GID_T group)
  {
  	LTP_CREATE_SYSCALL(lchown, cleanup, path, owner, group);
  }
+
+int CHOWN(void (cleanup)(void), const char *path, UID_T owner, GID_T group)
+{
+	LTP_CREATE_SYSCALL(chown, cleanup, path, owner, group);
+}
  #endif /* __LTP_COMPAT_16_H__ */

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#6 lore raw

Re: [LTP] [PATCH v2] fix some syscall tests for 16-bit compat testing

Quoted 10 lines · Stanislav Kholmanskikh

Hi.

In general, it looks good.

I have only one comment, that it's possible that the uid/gid values we pass to the syscall may not fit into UID_T/GID_T. For example, when we get uid of nobody user in runtime and pass it to chown() or etc.

Yes, it's more like an artificial case, but it's.

Quoted 7 lines

We have UID16_CHECK and GID16_CHECK macros to check if the uid/gid fits the compat mode.

What do you think about using it in test cases chown01, chown03, chown04, fchown01, fchown03, fchown04, setresgid*, setresuid* ?

Thank you.

Please review new patch which included UID16_CHECK and GID16_CHECK.

Thanks.

From f65d580f11791c4b2728018a2f8e52398c25d97a Mon Sep 17 00:00:00 2001
From: Han Pingtian <[email protected]>
Date: Fri, 21 Nov 2014 15:50:23 +0800
Subject: [PATCH] fix some syscall tests for 16-bit compat testing

Some syscall testcases have been compiled for 16-bit compat testing, but doesn't change the code yet. This fix try to add proper code to let them support this testing.

---
 testcases/kernel/syscalls/chown/chown01.c         |  7 ++++---
 testcases/kernel/syscalls/chown/chown02.c         |  3 ++-
 testcases/kernel/syscalls/chown/chown03.c         |  7 ++++---
 testcases/kernel/syscalls/chown/chown04.c         |  7 ++++---
 testcases/kernel/syscalls/chown/chown05.c         |  3 ++-
 testcases/kernel/syscalls/fchown/fchown01.c       |  6 +++++-
 testcases/kernel/syscalls/fchown/fchown02.c       |  3 ++-
 testcases/kernel/syscalls/fchown/fchown03.c       |  5 +++--
 testcases/kernel/syscalls/fchown/fchown04.c       |  6 +++++-
 testcases/kernel/syscalls/fchown/fchown05.c       |  3 ++-
 testcases/kernel/syscalls/lchown/lchown03.c       |  6 +++++-
 testcases/kernel/syscalls/setresgid/setresgid01.c |  7 ++++---
 testcases/kernel/syscalls/setresgid/setresgid02.c |  9 +++++----
 testcases/kernel/syscalls/setresgid/setresgid03.c |  7 ++++---
 testcases/kernel/syscalls/setresgid/setresgid04.c |  5 ++++-
 testcases/kernel/syscalls/setresuid/setresuid01.c |  9 +++++----
 testcases/kernel/syscalls/setresuid/setresuid02.c |  7 ++++---
 testcases/kernel/syscalls/setresuid/setresuid03.c |  8 ++++----
 testcases/kernel/syscalls/setresuid/setresuid04.c | 11 +++++++----
 testcases/kernel/syscalls/setresuid/setresuid05.c |  5 ++++-
 testcases/kernel/syscalls/utils/compat_16.h       | 20 ++++++++++++++++++++
 21 files changed, 99 insertions(+), 45 deletions(-)
testcases/kernel/syscalls/chown/chown01.c +4 -3
index ef728e1..5a77a98 100644
@@ -117,6 +117,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 char *TCID = "chown01";
 int TST_TOTAL = 1;
@@ -145,7 +146,7 @@ int main(int ac, char **av)
 
 		tst_count = 0;
 
-		TEST(chown(fname, uid, gid));
+		TEST(CHOWN(cleanup, fname, uid, gid));
 
 		if (TEST_RETURN == -1) {
 			tst_resm(TFAIL | TTERRNO, "chown(%s, %d,%d) failed",
@@ -170,8 +171,8 @@ static void setup(void)
 
 	tst_tmpdir();
 
-	uid = geteuid();
-	gid = getegid();
+	UID16_CHECK((uid = geteuid()), "chown", cleanup)
+	GID16_CHECK((gid = getegid()), "chown", cleanup)
 
 	sprintf(fname, "t_%d", getpid());
 
testcases/kernel/syscalls/chown/chown02.c +2 -1
index 339b2e8..30394ec 100644
@@ -79,6 +79,7 @@
 
 #include "test.h"
 #include "usctest.h"
+#include "compat_16.h"
 
 #define FILE_MODE	(S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
 #define NEW_PERMS1	(S_IFREG|S_IRWXU|S_IRWXG|S_ISUID|S_ISGID)
@@ -142,7 +143,7 @@ int main(int ac, char **av)
 			 * Call chown(2) with different user id and
 			 * group id (numeric values) to set it on testfile.
 			 */
-			TEST(chown(file_name, user_id, group_id));
+			TEST(CHOWN(cleanup, file_name, user_id, group_id));
 
 			if (TEST_RETURN == -1) {
 				tst_resm(TFAIL | TTERRNO,
testcases/kernel/syscalls/chown/chown03.c +4 -3
index 9780c2f..59b1d62 100644
@@ -82,6 +82,7 @@
 
 #include "test.h"
 #include "usctest.h"
+#include "compat_16.h"
 
 #define FILE_MODE	(S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
 #define NEW_PERMS	(S_IFREG|S_IRWXU|S_IRWXG|S_ISUID|S_ISGID)
@@ -112,10 +113,10 @@ int main(int ac, char **av)
 
 		tst_count = 0;
 
-		user_id = geteuid();
-		group_id = getegid();
+		UID16_CHECK((user_id = geteuid()), "chown", cleanup)
+		GID16_CHECK((group_id = getegid()), "chown", cleanup)
 
-		TEST(chown(TESTFILE, -1, group_id));
+		TEST(CHOWN(cleanup, TESTFILE, -1, group_id));
 
 		if (TEST_RETURN == -1) {
 			tst_resm(TFAIL | TTERRNO, "chown(%s, ..) failed",
testcases/kernel/syscalls/chown/chown04.c +4 -3
index 1459227..b6d7f3d 100644
@@ -55,6 +55,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 #define MODE_RWX		 (S_IRWXU|S_IRWXG|S_IRWXO)
 #define FILE_MODE		 (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
@@ -111,14 +112,14 @@ int main(int ac, char **av)
 
 	TEST_EXP_ENOS(exp_enos);
 
-	user_id = geteuid();
-	group_id = getegid();
+	UID16_CHECK((user_id = geteuid()), "chown", cleanup)
+	GID16_CHECK((group_id = getegid()), "chown", cleanup)
 
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		tst_count = 0;
 
 		for (i = 0; i < TST_TOTAL; i++) {
-			TEST(chown(tc[i].pathname, user_id, group_id));
+			TEST(CHOWN(cleanup, tc[i].pathname, user_id, group_id));
 
 			if (TEST_RETURN == 0) {
 				tst_resm(TFAIL, "chown succeeded unexpectedly");
testcases/kernel/syscalls/chown/chown05.c +2 -1
index 92e1811..3ec4f13 100644
@@ -77,6 +77,7 @@
 
 #include "test.h"
 #include "usctest.h"
+#include "compat_16.h"
 
 #define FILE_MODE	(S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
 #define TESTFILE	"testfile"
@@ -121,7 +122,7 @@ int main(int ac, char **av)
 			user_id = test_cases[i].user_id;
 			group_id = test_cases[i].group_id;
 
-			TEST(chown(TESTFILE, user_id, group_id));
+			TEST(CHOWN(cleanup, TESTFILE, user_id, group_id));
 
 			if (TEST_RETURN == -1) {
 				tst_resm(TFAIL | TTERRNO, "chown failed");
testcases/kernel/syscalls/fchown/fchown01.c +5 -1
index be620d7..df74635 100644
@@ -42,6 +42,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 static void setup(void);
 static void cleanup(void);
@@ -65,7 +66,10 @@ int main(int ac, char **av)
 
 		tst_count = 0;
 
-		TEST(fchown(fd, geteuid(), getegid()));
+		UID16_CHECK(geteuid(), "fchown", cleanup)
+		GID16_CHECK(getegid(), "fchown", cleanup)
+
+		TEST(FCHOWN(cleanup, fd, geteuid(), getegid()));
 
 		if (TEST_RETURN == -1) {
 			tst_resm(TFAIL | TTERRNO, "fchown failed");
testcases/kernel/syscalls/fchown/fchown02.c +2 -1
index fd14ba1..0c1782d 100644
@@ -38,6 +38,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 #define FILE_MODE	S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
 #define NEW_PERMS1	S_IFREG | S_IRWXU | S_IRWXG | S_ISUID | S_ISGID
@@ -71,7 +72,7 @@ static void verify_fchown(struct test_case *t)
 {
 	struct stat stat_buf;
 
-	TEST(fchown(*t->fd, t->user_id, t->group_id));
+	TEST(FCHOWN(cleanup, *t->fd, t->user_id, t->group_id));
 
 	if (TEST_RETURN == -1) {
 		tst_resm(TFAIL | TTERRNO, "fchown() Fails on %s", t->pathname);
testcases/kernel/syscalls/fchown/fchown03.c +3 -2
index 3a75093..8c68f12 100644
@@ -41,6 +41,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 #define FILE_MODE (mode_t)(S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
 #define NEW_PERMS (mode_t)(S_IFREG | S_IRWXU | S_IRWXG | S_ISUID | S_ISGID)
@@ -75,9 +76,9 @@ int main(int ac, char **av)
 		tst_count = 0;
 
 		user_id = geteuid();
-		group_id = getegid();
+		GID16_CHECK((group_id = getegid()), "fchown", cleanup)
 
-		TEST(fchown(fildes, -1, group_id));
+		TEST(FCHOWN(cleanup, fildes, -1, group_id));
 
 		if (TEST_RETURN == -1) {
 			tst_resm(TFAIL, "fchown() on %s Fails, errno=%d",
testcases/kernel/syscalls/fchown/fchown04.c +5 -1
index 0829944..4fe7fdd 100644
@@ -45,6 +45,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 #define DIR_MODE	(S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
 			 S_IXGRP|S_IROTH|S_IXOTH)
@@ -140,7 +141,10 @@ static void setup(void)
 
 static void fchown_verify(int i)
 {
-	TEST(fchown(*test_cases[i].fd, geteuid(), getegid()));
+	UID16_CHECK(geteuid(), "fchown", cleanup)
+	GID16_CHECK(getegid(), "fchown", cleanup)
+
+	TEST(FCHOWN(cleanup, *test_cases[i].fd, geteuid(), getegid()));
 
 	if (TEST_RETURN == -1) {
 		if (TEST_ERRNO == test_cases[i].exp_errno) {
testcases/kernel/syscalls/fchown/fchown05.c +2 -1
index 67a745a..47d5b00 100644
@@ -34,6 +34,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 #define FILE_MODE	S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
 #define TESTFILE	"testfile"
@@ -80,7 +81,7 @@ int main(int ac, char **av)
 			user_id = tc[i].user_id;
 			group_id = tc[i].group_id;
 
-			TEST(fchown(fildes, user_id, group_id));
+			TEST(FCHOWN(cleanup, fildes, user_id, group_id));
 
 			if (TEST_RETURN == -1) {
 				tst_resm(TFAIL | TTERRNO,
testcases/kernel/syscalls/lchown/lchown03.c +5 -1
index 9e4d6f9..d70847b 100644
@@ -40,6 +40,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 #define DIR_MODE	(S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
 			 S_IXGRP|S_IROTH|S_IXOTH)
@@ -124,7 +125,10 @@ static void setup(void)
 
 static void lchown_verify(const struct test_case_t *test)
 {
-	TEST(lchown(test->pathname, geteuid(), getegid()));
+	UID16_CHECK(geteuid(), "lchown", cleanup)
+	GID16_CHECK(getegid(), "lchown", cleanup)
+
+	TEST(LCHOWN(cleanup, test->pathname, geteuid(), getegid()));
 
 	if (TEST_RETURN != -1) {
 		tst_resm(TFAIL, "lchown() returned %ld, expected -1, errno=%d",
testcases/kernel/syscalls/setresgid/setresgid01.c +4 -3
index f9c62a0..440dd43 100644
@@ -76,6 +76,7 @@
 #include <unistd.h>
 #include "test.h"
 #include "usctest.h"
+#include "compat_16.h"
 
 #define EXP_RET_VAL	0
 
@@ -131,7 +132,7 @@ int main(int argc, char **argv)
 
 		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			TEST(setresgid(*tdat[testno].rgid, *tdat[testno].egid,
+			TEST(SETRESGID(cleanup, *tdat[testno].rgid, *tdat[testno].egid,
 				       *tdat[testno].sgid));
 
 			if (TEST_RETURN == EXP_RET_VAL) {
@@ -195,14 +196,14 @@ void setup(void)
 
 	}
 	root = *passwd_p;
-	root_gid = root.pw_gid;
+	GID16_CHECK((root_gid = root.pw_gid), "setresgid", cleanup)
 
 	if ((passwd_p = getpwnam("nobody")) == NULL) {
 		tst_brkm(TBROK, NULL, "nobody user id doesn't exist");
 
 	}
 	nobody = *passwd_p;
-	nobody_gid = nobody.pw_gid;
+	GID16_CHECK((nobody_gid = nobody.pw_gid), "setresgid", cleanup)
 
 	/* Pause if that option was specified
 	 * TEST_PAUSE contains the code to fork the test with the -c option.
testcases/kernel/syscalls/setresgid/setresgid02.c +5 -4
index 754fca1..113544e 100644
@@ -81,6 +81,7 @@
 #include <unistd.h>
 #include "test.h"
 #include "usctest.h"
+#include "compat_16.h"
 
 #define EXP_RET_VAL	0
 
@@ -138,7 +139,7 @@ int main(int argc, char **argv)
 
 		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			TEST(setresgid(*tdat[testno].rgid, *tdat[testno].egid,
+			TEST(SETRESGID(cleanup, *tdat[testno].rgid, *tdat[testno].egid,
 				       *tdat[testno].sgid));
 
 			if (TEST_RETURN == EXP_RET_VAL) {
@@ -202,21 +203,21 @@ void setup(void)
 
 	}
 	root = *passwd_p;
-	root_gid = root.pw_gid;
+	GID16_CHECK((root_gid = root.pw_gid), "setresgid", cleanup)
 
 	if ((passwd_p = getpwnam("bin")) == NULL) {
 		tst_brkm(TBROK, NULL, "bin user id doesn't exist");
 
 	}
 	bin = *passwd_p;
-	bin_gid = bin.pw_gid;
+	GID16_CHECK((bin_gid = bin.pw_gid), "setresgid", cleanup)
 
 	if ((passwd_p = getpwnam("nobody")) == NULL) {
 		tst_brkm(TBROK, NULL, "nobody user id doesn't exist");
 
 	}
 	nobody = *passwd_p;
-	nobody_gid = nobody.pw_gid;
+	GID16_CHECK((nobody_gid = nobody.pw_gid), "setresgid", cleanup)
 
 	/* Set effective/saved gid to nobody */
 	if (setresgid(-1, nobody_gid, nobody_gid) == -1) {
testcases/kernel/syscalls/setresgid/setresgid03.c +4 -3
index 32d7995..aa67081 100644
@@ -81,6 +81,7 @@
 #include <unistd.h>
 #include "test.h"
 #include "usctest.h"
+#include "compat_16.h"
 
 #define EXP_RET_VAL	-1
 #define EXP_ERRNO	EPERM
@@ -131,7 +132,7 @@ int main(int argc, char **argv)
 
 		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			TEST(setresgid(*tdat[testno].rgid, *tdat[testno].egid,
+			TEST(SETRESGID(cleanup, *tdat[testno].rgid, *tdat[testno].egid,
 				       *tdat[testno].sgid));
 
 			TEST_ERROR_LOG(TEST_ERRNO);
@@ -207,14 +208,14 @@ void setup(void)
 
 	}
 	bin = *passwd_p;
-	bin_gid = bin.pw_gid;
+	GID16_CHECK((bin_gid = bin.pw_gid), "setresgid", cleanup)
 
 	if ((passwd_p = getpwnam("nobody")) == NULL) {
 		tst_brkm(TBROK, NULL, "nobody user id doesn't exist");
 
 	}
 	nobody = *passwd_p;
-	nobody_gid = nobody.pw_gid;
+	GID16_CHECK((nobody_gid = nobody.pw_gid), "setresgid", cleanup)
 
 	/* set the expected errnos... */
 	TEST_EXP_ENOS(exp_enos);
testcases/kernel/syscalls/setresgid/setresgid04.c +4 -1
index 4e71910..019aaeb 100644
@@ -30,6 +30,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 char *TCID = "setresgid04";
 int TST_TOTAL = 1;
@@ -70,13 +71,15 @@ static void setup(void)
 	tst_tmpdir();
 
 	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
+
+	GID16_CHECK(ltpuser->pw_gid, "setresgid", cleanup)
 }
 
 static void setresgid_verify(void)
 {
 	struct stat buf;
 
-	TEST(setresgid(-1, ltpuser->pw_gid, -1));
+	TEST(SETRESGID(cleanup, -1, ltpuser->pw_gid, -1));
 
 	if (TEST_RETURN != 0) {
 		tst_resm(TFAIL | TTERRNO, "setresgid failed unexpectedly");
testcases/kernel/syscalls/setresuid/setresuid01.c +5 -4
index 39e1ac3..027aee3 100644
@@ -69,6 +69,7 @@
 #include "test.h"
 #include "usctest.h"
 #include <errno.h>
+#include "compat_16.h"
 
 char *TCID = "setresuid01";
 
@@ -140,7 +141,7 @@ int main(int ac, char **av)
 
 		for (i = 0; i < TST_TOTAL; i++) {
 			/* Set the real, effective or user id */
-			TEST(setresuid(*test_data[i].real_uid,
+			TEST(SETRESUID(cleanup, *test_data[i].real_uid,
 				       *test_data[i].eff_uid,
 				       *test_data[i].sav_uid));
 
@@ -185,13 +186,13 @@ void setup(void)
 	TEST_EXP_ENOS(exp_enos);
 
 	root = *(getpwnam("root"));
-	root_pw_uid = root.pw_uid;
+	UID16_CHECK((root_pw_uid = root.pw_uid), "setresuid", cleanup)
 
 	nobody = *(getpwnam("nobody"));
-	nobody_pw_uid = nobody.pw_uid;
+	UID16_CHECK((nobody_pw_uid = nobody.pw_uid), "setresuid", cleanup)
 
 	bin = *(getpwnam("bin"));
-	bin_pw_uid = bin.pw_uid;
+	UID16_CHECK((bin_pw_uid = bin.pw_uid), "setresuid", cleanup)
 
 	/* Pause if that option was specified
 	 * TEST_PAUSE contains the code to fork the test with the -c option.
testcases/kernel/syscalls/setresuid/setresuid02.c +4 -3
index 0837c9e..bb50633 100644
@@ -65,6 +65,7 @@
 #include "usctest.h"
 #include <errno.h>
 #include <sys/wait.h>
+#include "compat_16.h"
 
 char *TCID = "setresuid02";
 
@@ -140,7 +141,7 @@ int main(int ac, char **av)
 			for (i = 0; i < TST_TOTAL; i++) {
 
 				/* Set the real, effective or saved user id */
-				TEST(setresuid(*test_data[i].real_uid,
+				TEST(SETRESUID(cleanup, *test_data[i].real_uid,
 					       *test_data[i].eff_uid,
 					       *test_data[i].sav_uid));
 
@@ -196,10 +197,10 @@ void setup(void)
 	}
 
 	nobody = *(getpwnam("nobody"));
-	nobody_pw_uid = nobody.pw_uid;
+	UID16_CHECK((nobody_pw_uid = nobody.pw_uid), "setresuid", cleanup)
 
 	bin = *(getpwnam("bin"));
-	bin_pw_uid = bin.pw_uid;
+	UID16_CHECK((bin_pw_uid = bin.pw_uid), "setresuid", cleanup)
 
 	/* Pause if that option was specified
 	 * TEST_PAUSE contains the code to fork the test with the -i option.
testcases/kernel/syscalls/setresuid/setresuid03.c +4 -4
index f624253..c679b82 100644
@@ -150,7 +150,7 @@ int main(int ac, char **av)
 			for (i = 0; i < TST_TOTAL; i++) {
 
 				/* Set the real, effective or saved user id */
-				TEST(setresuid(*test_data[i].real_uid,
+				TEST(SETRESUID(cleanup, *test_data[i].real_uid,
 					       *test_data[i].eff_uid,
 					       *test_data[i].sav_uid));
 
@@ -207,13 +207,13 @@ void setup(void)
 	}
 
 	root = *(getpwnam("root"));
-	root_pw_uid = root.pw_uid;
+	UID16_CHECK((root_pw_uid = root.pw_uid), "setresuid", cleanup)
 
 	nobody = *(getpwnam("nobody"));
-	nobody_pw_uid = nobody.pw_uid;
+	UID16_CHECK((nobody_pw_uid = nobody.pw_uid), "setresuid", cleanup)
 
 	bin = *(getpwnam("bin"));
-	bin_pw_uid = bin.pw_uid;
+	UID16_CHECK((bin_pw_uid = bin.pw_uid), "setresuid", cleanup)
 
 	/* Pause if that option was specified
 	 * TEST_PAUSE contains the code to fork the test with the -i option.
testcases/kernel/syscalls/setresuid/setresuid04.c +7 -4
index 140d5f3..49b2616 100644
@@ -53,6 +53,7 @@
 #include "test.h"
 #include "usctest.h"
 #include <pwd.h>
+#include "compat_16.h"
 
 char *TCID = "setresuid04";
 int TST_TOTAL = 1;
@@ -111,8 +112,8 @@ void do_master_child(void)
 		/* Reset tst_count in case we are looping */
 		tst_count = 0;
 
-		if (setresuid(0, ltpuser->pw_uid, 0) == -1) {
-			perror("setfsuid failed");
+		if (SETRESUID(cleanup, 0, ltpuser->pw_uid, 0) == -1) {
+			perror("setresuid failed");
 			exit(1);
 		}
 
@@ -176,8 +177,8 @@ void do_master_child(void)
 		 *         the file with RDWR permissions.
 		 */
 		tst_count++;
-		if (setresuid(0, 0, 0) == -1) {
-			perror("setfsuid failed");
+		if (SETRESUID(cleanup, 0, 0, 0) == -1) {
+			perror("setresuid failed");
 			exit(1);
 		}
 
@@ -203,6 +204,8 @@ void setup(void)
 
 	ltpuser = getpwnam(nobody_uid);
 
+	UID16_CHECK(ltpuser->pw_uid, "setresuid", cleanup)
+
 	tst_tmpdir();
 
 	sprintf(testfile, "setresuid04file%d.tst", getpid());
testcases/kernel/syscalls/setresuid/setresuid05.c +4 -1
index 8880aeb..81175eb 100644
@@ -30,6 +30,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
+#include "compat_16.h"
 
 char *TCID = "setresuid05";
 int TST_TOTAL = 1;
@@ -70,13 +71,15 @@ static void setup(void)
 	tst_tmpdir();
 
 	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
+
+	UID16_CHECK(ltpuser->pw_uid, "setresuid", cleanup)
 }
 
 static void setresuid_verify(void)
 {
 	struct stat buf;
 
-	TEST(setresuid(-1, ltpuser->pw_uid, -1));
+	TEST(SETRESUID(cleanup, -1, ltpuser->pw_uid, -1));
 
 	if (TEST_RETURN != 0) {
 		tst_resm(TFAIL | TTERRNO, "setresuid failed unexpectedly");
testcases/kernel/syscalls/utils/compat_16.h +20 -0
index 40bef59..b6a702d 100644
@@ -127,8 +127,28 @@ int SETREGID(void (cleanup)(void), GID_T rgid, GID_T egid)
 	LTP_CREATE_SYSCALL(setregid, cleanup, rgid, egid);
 }
 
+int SETRESUID(void (cleanup)(void), UID_T ruid, UID_T euid, UID_T suid)
+{
+	LTP_CREATE_SYSCALL(setresuid, cleanup, ruid, euid, suid);
+}
+
+int SETRESGID(void (cleanup)(void), GID_T rgid, GID_T egid, GID_T sgid)
+{
+	LTP_CREATE_SYSCALL(setresgid, cleanup, rgid, egid, sgid);
+}
+
+int FCHOWN(void (cleanup)(void), unsigned int fd, UID_T owner, GID_T group)
+{
+	LTP_CREATE_SYSCALL(fchown, cleanup, fd, owner, group);
+}
+
 int LCHOWN(void (cleanup)(void), const char *path, UID_T owner, GID_T group)
 {
 	LTP_CREATE_SYSCALL(lchown, cleanup, path, owner, group);
 }
+
+int CHOWN(void (cleanup)(void), const char *path, UID_T owner, GID_T group)
+{
+	LTP_CREATE_SYSCALL(chown, cleanup, path, owner, group);
+}
 #endif /* __LTP_COMPAT_16_H__ */
Signature · 13 lines
1.9.3


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#7 lore raw

Re: [LTP] [PATCH v2] fix some syscall tests for 16-bit compat testing

Quoted 14 lines · Han Pingtian
Quoted 13 lines · Stanislav Kholmanskikh

Hi.

In general, it looks good.

I have only one comment, that it's possible that the uid/gid values we pass to the syscall may not fit into UID_T/GID_T. For example, when we get uid of nobody user in runtime and pass it to chown() or etc.

Yes, it's more like an artificial case, but it's.

We have UID16_CHECK and GID16_CHECK macros to check if the uid/gid fits the compat mode.

Quoted 8 lines
Quoted 4 lines

What do you think about using it in test cases chown01, chown03, chown04, fchown01, fchown03, fchown04, setresgid*, setresuid* ?

Thank you.

Please review new patch which included UID16_CHECK and GID16_CHECK.

Thanks.

Hi!

I pushed your patch with TCID_DEFINE added (overlooked it at that time), and also pushed a follow-up patch which:
* fixes setresuid02_16, setresuid03_16, setresuid04_16 - they do
testing inside their children.
* explicitly declares setresuid(), setresgid() in compat_16.h. This is
to manage compilation warnings.

Tested in OL6 with 2.6.39-400.215.11.el6uek.x86_64 and 2.6.39-400.214.5.el6uek.i686 kernels.

Thank you.

Quoted 652 lines
Quoted 2 lines

From f65d580f11791c4b2728018a2f8e52398c25d97a Mon Sep 17 00:00:00 2001

From: Han Pingtian <[email protected]>
Date: Fri, 21 Nov 2014 15:50:23 +0800
Subject: [PATCH] fix some syscall tests for 16-bit compat testing

Some syscall testcases have been compiled for 16-bit compat testing, but doesn't change the code yet. This fix try to add proper code to let them support this testing.

---
  testcases/kernel/syscalls/chown/chown01.c         |  7 ++++---
  testcases/kernel/syscalls/chown/chown02.c         |  3 ++-
  testcases/kernel/syscalls/chown/chown03.c         |  7 ++++---
  testcases/kernel/syscalls/chown/chown04.c         |  7 ++++---
  testcases/kernel/syscalls/chown/chown05.c         |  3 ++-
  testcases/kernel/syscalls/fchown/fchown01.c       |  6 +++++-
  testcases/kernel/syscalls/fchown/fchown02.c       |  3 ++-
  testcases/kernel/syscalls/fchown/fchown03.c       |  5 +++--
  testcases/kernel/syscalls/fchown/fchown04.c       |  6 +++++-
  testcases/kernel/syscalls/fchown/fchown05.c       |  3 ++-
  testcases/kernel/syscalls/lchown/lchown03.c       |  6 +++++-
  testcases/kernel/syscalls/setresgid/setresgid01.c |  7 ++++---
  testcases/kernel/syscalls/setresgid/setresgid02.c |  9 +++++----
  testcases/kernel/syscalls/setresgid/setresgid03.c |  7 ++++---
  testcases/kernel/syscalls/setresgid/setresgid04.c |  5 ++++-
  testcases/kernel/syscalls/setresuid/setresuid01.c |  9 +++++----
  testcases/kernel/syscalls/setresuid/setresuid02.c |  7 ++++---
  testcases/kernel/syscalls/setresuid/setresuid03.c |  8 ++++----
  testcases/kernel/syscalls/setresuid/setresuid04.c | 11 +++++++----
  testcases/kernel/syscalls/setresuid/setresuid05.c |  5 ++++-
  testcases/kernel/syscalls/utils/compat_16.h       | 20 ++++++++++++++++++++
  21 files changed, 99 insertions(+), 45 deletions(-)
testcases/kernel/syscalls/chown/chown01.c +4 -3
index ef728e1..5a77a98 100644
@@ -117,6 +117,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  char *TCID = "chown01";
  int TST_TOTAL = 1;
@@ -145,7 +146,7 @@ int main(int ac, char **av)
 
  		tst_count = 0;
 
-		TEST(chown(fname, uid, gid));
+		TEST(CHOWN(cleanup, fname, uid, gid));
 
  		if (TEST_RETURN == -1) {
  			tst_resm(TFAIL | TTERRNO, "chown(%s, %d,%d) failed",
@@ -170,8 +171,8 @@ static void setup(void)
 
  	tst_tmpdir();
 
-	uid = geteuid();
-	gid = getegid();
+	UID16_CHECK((uid = geteuid()), "chown", cleanup)
+	GID16_CHECK((gid = getegid()), "chown", cleanup)
 
  	sprintf(fname, "t_%d", getpid());
 
testcases/kernel/syscalls/chown/chown02.c +2 -1
index 339b2e8..30394ec 100644
@@ -79,6 +79,7 @@
 
  #include "test.h"
  #include "usctest.h"
+#include "compat_16.h"
 
  #define FILE_MODE	(S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
  #define NEW_PERMS1	(S_IFREG|S_IRWXU|S_IRWXG|S_ISUID|S_ISGID)
@@ -142,7 +143,7 @@ int main(int ac, char **av)
  			 * Call chown(2) with different user id and
  			 * group id (numeric values) to set it on testfile.
  			 */
-			TEST(chown(file_name, user_id, group_id));
+			TEST(CHOWN(cleanup, file_name, user_id, group_id));
 
  			if (TEST_RETURN == -1) {
  				tst_resm(TFAIL | TTERRNO,
testcases/kernel/syscalls/chown/chown03.c +4 -3
index 9780c2f..59b1d62 100644
@@ -82,6 +82,7 @@
 
  #include "test.h"
  #include "usctest.h"
+#include "compat_16.h"
 
  #define FILE_MODE	(S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
  #define NEW_PERMS	(S_IFREG|S_IRWXU|S_IRWXG|S_ISUID|S_ISGID)
@@ -112,10 +113,10 @@ int main(int ac, char **av)
 
  		tst_count = 0;
 
-		user_id = geteuid();
-		group_id = getegid();
+		UID16_CHECK((user_id = geteuid()), "chown", cleanup)
+		GID16_CHECK((group_id = getegid()), "chown", cleanup)
 
-		TEST(chown(TESTFILE, -1, group_id));
+		TEST(CHOWN(cleanup, TESTFILE, -1, group_id));
 
  		if (TEST_RETURN == -1) {
  			tst_resm(TFAIL | TTERRNO, "chown(%s, ..) failed",
testcases/kernel/syscalls/chown/chown04.c +4 -3
index 1459227..b6d7f3d 100644
@@ -55,6 +55,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  #define MODE_RWX		 (S_IRWXU|S_IRWXG|S_IRWXO)
  #define FILE_MODE		 (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
@@ -111,14 +112,14 @@ int main(int ac, char **av)
 
  	TEST_EXP_ENOS(exp_enos);
 
-	user_id = geteuid();
-	group_id = getegid();
+	UID16_CHECK((user_id = geteuid()), "chown", cleanup)
+	GID16_CHECK((group_id = getegid()), "chown", cleanup)
 
  	for (lc = 0; TEST_LOOPING(lc); lc++) {
  		tst_count = 0;
 
  		for (i = 0; i < TST_TOTAL; i++) {
-			TEST(chown(tc[i].pathname, user_id, group_id));
+			TEST(CHOWN(cleanup, tc[i].pathname, user_id, group_id));
 
  			if (TEST_RETURN == 0) {
  				tst_resm(TFAIL, "chown succeeded unexpectedly");
testcases/kernel/syscalls/chown/chown05.c +2 -1
index 92e1811..3ec4f13 100644
@@ -77,6 +77,7 @@
 
  #include "test.h"
  #include "usctest.h"
+#include "compat_16.h"
 
  #define FILE_MODE	(S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
  #define TESTFILE	"testfile"
@@ -121,7 +122,7 @@ int main(int ac, char **av)
  			user_id = test_cases[i].user_id;
  			group_id = test_cases[i].group_id;
 
-			TEST(chown(TESTFILE, user_id, group_id));
+			TEST(CHOWN(cleanup, TESTFILE, user_id, group_id));
 
  			if (TEST_RETURN == -1) {
  				tst_resm(TFAIL | TTERRNO, "chown failed");
testcases/kernel/syscalls/fchown/fchown01.c +5 -1
index be620d7..df74635 100644
@@ -42,6 +42,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  static void setup(void);
  static void cleanup(void);
@@ -65,7 +66,10 @@ int main(int ac, char **av)
 
  		tst_count = 0;
 
-		TEST(fchown(fd, geteuid(), getegid()));
+		UID16_CHECK(geteuid(), "fchown", cleanup)
+		GID16_CHECK(getegid(), "fchown", cleanup)
+
+		TEST(FCHOWN(cleanup, fd, geteuid(), getegid()));
 
  		if (TEST_RETURN == -1) {
  			tst_resm(TFAIL | TTERRNO, "fchown failed");
testcases/kernel/syscalls/fchown/fchown02.c +2 -1
index fd14ba1..0c1782d 100644
@@ -38,6 +38,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  #define FILE_MODE	S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
  #define NEW_PERMS1	S_IFREG | S_IRWXU | S_IRWXG | S_ISUID | S_ISGID
@@ -71,7 +72,7 @@ static void verify_fchown(struct test_case *t)
  {
  	struct stat stat_buf;
 
-	TEST(fchown(*t->fd, t->user_id, t->group_id));
+	TEST(FCHOWN(cleanup, *t->fd, t->user_id, t->group_id));
 
  	if (TEST_RETURN == -1) {
  		tst_resm(TFAIL | TTERRNO, "fchown() Fails on %s", t->pathname);
testcases/kernel/syscalls/fchown/fchown03.c +3 -2
index 3a75093..8c68f12 100644
@@ -41,6 +41,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  #define FILE_MODE (mode_t)(S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
  #define NEW_PERMS (mode_t)(S_IFREG | S_IRWXU | S_IRWXG | S_ISUID | S_ISGID)
@@ -75,9 +76,9 @@ int main(int ac, char **av)
  		tst_count = 0;
 
  		user_id = geteuid();
-		group_id = getegid();
+		GID16_CHECK((group_id = getegid()), "fchown", cleanup)
 
-		TEST(fchown(fildes, -1, group_id));
+		TEST(FCHOWN(cleanup, fildes, -1, group_id));
 
  		if (TEST_RETURN == -1) {
  			tst_resm(TFAIL, "fchown() on %s Fails, errno=%d",
testcases/kernel/syscalls/fchown/fchown04.c +5 -1
index 0829944..4fe7fdd 100644
@@ -45,6 +45,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  #define DIR_MODE	(S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
  			 S_IXGRP|S_IROTH|S_IXOTH)
@@ -140,7 +141,10 @@ static void setup(void)
 
  static void fchown_verify(int i)
  {
-	TEST(fchown(*test_cases[i].fd, geteuid(), getegid()));
+	UID16_CHECK(geteuid(), "fchown", cleanup)
+	GID16_CHECK(getegid(), "fchown", cleanup)
+
+	TEST(FCHOWN(cleanup, *test_cases[i].fd, geteuid(), getegid()));
 
  	if (TEST_RETURN == -1) {
  		if (TEST_ERRNO == test_cases[i].exp_errno) {
testcases/kernel/syscalls/fchown/fchown05.c +2 -1
index 67a745a..47d5b00 100644
@@ -34,6 +34,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  #define FILE_MODE	S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
  #define TESTFILE	"testfile"
@@ -80,7 +81,7 @@ int main(int ac, char **av)
  			user_id = tc[i].user_id;
  			group_id = tc[i].group_id;
 
-			TEST(fchown(fildes, user_id, group_id));
+			TEST(FCHOWN(cleanup, fildes, user_id, group_id));
 
  			if (TEST_RETURN == -1) {
  				tst_resm(TFAIL | TTERRNO,
testcases/kernel/syscalls/lchown/lchown03.c +5 -1
index 9e4d6f9..d70847b 100644
@@ -40,6 +40,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  #define DIR_MODE	(S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
  			 S_IXGRP|S_IROTH|S_IXOTH)
@@ -124,7 +125,10 @@ static void setup(void)
 
  static void lchown_verify(const struct test_case_t *test)
  {
-	TEST(lchown(test->pathname, geteuid(), getegid()));
+	UID16_CHECK(geteuid(), "lchown", cleanup)
+	GID16_CHECK(getegid(), "lchown", cleanup)
+
+	TEST(LCHOWN(cleanup, test->pathname, geteuid(), getegid()));
 
  	if (TEST_RETURN != -1) {
  		tst_resm(TFAIL, "lchown() returned %ld, expected -1, errno=%d",
testcases/kernel/syscalls/setresgid/setresgid01.c +4 -3
index f9c62a0..440dd43 100644
@@ -76,6 +76,7 @@
  #include <unistd.h>
  #include "test.h"
  #include "usctest.h"
+#include "compat_16.h"
 
  #define EXP_RET_VAL	0
 
@@ -131,7 +132,7 @@ int main(int argc, char **argv)
 
  		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			TEST(setresgid(*tdat[testno].rgid, *tdat[testno].egid,
+			TEST(SETRESGID(cleanup, *tdat[testno].rgid, *tdat[testno].egid,
  				       *tdat[testno].sgid));
 
  			if (TEST_RETURN == EXP_RET_VAL) {
@@ -195,14 +196,14 @@ void setup(void)
 
  	}
  	root = *passwd_p;
-	root_gid = root.pw_gid;
+	GID16_CHECK((root_gid = root.pw_gid), "setresgid", cleanup)
 
  	if ((passwd_p = getpwnam("nobody")) == NULL) {
  		tst_brkm(TBROK, NULL, "nobody user id doesn't exist");
 
  	}
  	nobody = *passwd_p;
-	nobody_gid = nobody.pw_gid;
+	GID16_CHECK((nobody_gid = nobody.pw_gid), "setresgid", cleanup)
 
  	/* Pause if that option was specified
  	 * TEST_PAUSE contains the code to fork the test with the -c option.
testcases/kernel/syscalls/setresgid/setresgid02.c +5 -4
index 754fca1..113544e 100644
@@ -81,6 +81,7 @@
  #include <unistd.h>
  #include "test.h"
  #include "usctest.h"
+#include "compat_16.h"
 
  #define EXP_RET_VAL	0
 
@@ -138,7 +139,7 @@ int main(int argc, char **argv)
 
  		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			TEST(setresgid(*tdat[testno].rgid, *tdat[testno].egid,
+			TEST(SETRESGID(cleanup, *tdat[testno].rgid, *tdat[testno].egid,
  				       *tdat[testno].sgid));
 
  			if (TEST_RETURN == EXP_RET_VAL) {
@@ -202,21 +203,21 @@ void setup(void)
 
  	}
  	root = *passwd_p;
-	root_gid = root.pw_gid;
+	GID16_CHECK((root_gid = root.pw_gid), "setresgid", cleanup)
 
  	if ((passwd_p = getpwnam("bin")) == NULL) {
  		tst_brkm(TBROK, NULL, "bin user id doesn't exist");
 
  	}
  	bin = *passwd_p;
-	bin_gid = bin.pw_gid;
+	GID16_CHECK((bin_gid = bin.pw_gid), "setresgid", cleanup)
 
  	if ((passwd_p = getpwnam("nobody")) == NULL) {
  		tst_brkm(TBROK, NULL, "nobody user id doesn't exist");
 
  	}
  	nobody = *passwd_p;
-	nobody_gid = nobody.pw_gid;
+	GID16_CHECK((nobody_gid = nobody.pw_gid), "setresgid", cleanup)
 
  	/* Set effective/saved gid to nobody */
  	if (setresgid(-1, nobody_gid, nobody_gid) == -1) {
testcases/kernel/syscalls/setresgid/setresgid03.c +4 -3
index 32d7995..aa67081 100644
@@ -81,6 +81,7 @@
  #include <unistd.h>
  #include "test.h"
  #include "usctest.h"
+#include "compat_16.h"
 
  #define EXP_RET_VAL	-1
  #define EXP_ERRNO	EPERM
@@ -131,7 +132,7 @@ int main(int argc, char **argv)
 
  		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			TEST(setresgid(*tdat[testno].rgid, *tdat[testno].egid,
+			TEST(SETRESGID(cleanup, *tdat[testno].rgid, *tdat[testno].egid,
  				       *tdat[testno].sgid));
 
  			TEST_ERROR_LOG(TEST_ERRNO);
@@ -207,14 +208,14 @@ void setup(void)
 
  	}
  	bin = *passwd_p;
-	bin_gid = bin.pw_gid;
+	GID16_CHECK((bin_gid = bin.pw_gid), "setresgid", cleanup)
 
  	if ((passwd_p = getpwnam("nobody")) == NULL) {
  		tst_brkm(TBROK, NULL, "nobody user id doesn't exist");
 
  	}
  	nobody = *passwd_p;
-	nobody_gid = nobody.pw_gid;
+	GID16_CHECK((nobody_gid = nobody.pw_gid), "setresgid", cleanup)
 
  	/* set the expected errnos... */
  	TEST_EXP_ENOS(exp_enos);
testcases/kernel/syscalls/setresgid/setresgid04.c +4 -1
index 4e71910..019aaeb 100644
@@ -30,6 +30,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  char *TCID = "setresgid04";
  int TST_TOTAL = 1;
@@ -70,13 +71,15 @@ static void setup(void)
  	tst_tmpdir();
 
  	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
+
+	GID16_CHECK(ltpuser->pw_gid, "setresgid", cleanup)
  }
 
  static void setresgid_verify(void)
  {
  	struct stat buf;
 
-	TEST(setresgid(-1, ltpuser->pw_gid, -1));
+	TEST(SETRESGID(cleanup, -1, ltpuser->pw_gid, -1));
 
  	if (TEST_RETURN != 0) {
  		tst_resm(TFAIL | TTERRNO, "setresgid failed unexpectedly");
testcases/kernel/syscalls/setresuid/setresuid01.c +5 -4
index 39e1ac3..027aee3 100644
@@ -69,6 +69,7 @@
  #include "test.h"
  #include "usctest.h"
  #include <errno.h>
+#include "compat_16.h"
 
  char *TCID = "setresuid01";
 
@@ -140,7 +141,7 @@ int main(int ac, char **av)
 
  		for (i = 0; i < TST_TOTAL; i++) {
  			/* Set the real, effective or user id */
-			TEST(setresuid(*test_data[i].real_uid,
+			TEST(SETRESUID(cleanup, *test_data[i].real_uid,
  				       *test_data[i].eff_uid,
  				       *test_data[i].sav_uid));
 
@@ -185,13 +186,13 @@ void setup(void)
  	TEST_EXP_ENOS(exp_enos);
 
  	root = *(getpwnam("root"));
-	root_pw_uid = root.pw_uid;
+	UID16_CHECK((root_pw_uid = root.pw_uid), "setresuid", cleanup)
 
  	nobody = *(getpwnam("nobody"));
-	nobody_pw_uid = nobody.pw_uid;
+	UID16_CHECK((nobody_pw_uid = nobody.pw_uid), "setresuid", cleanup)
 
  	bin = *(getpwnam("bin"));
-	bin_pw_uid = bin.pw_uid;
+	UID16_CHECK((bin_pw_uid = bin.pw_uid), "setresuid", cleanup)
 
  	/* Pause if that option was specified
  	 * TEST_PAUSE contains the code to fork the test with the -c option.
testcases/kernel/syscalls/setresuid/setresuid02.c +4 -3
index 0837c9e..bb50633 100644
@@ -65,6 +65,7 @@
  #include "usctest.h"
  #include <errno.h>
  #include <sys/wait.h>
+#include "compat_16.h"
 
  char *TCID = "setresuid02";
 
@@ -140,7 +141,7 @@ int main(int ac, char **av)
  			for (i = 0; i < TST_TOTAL; i++) {
 
  				/* Set the real, effective or saved user id */
-				TEST(setresuid(*test_data[i].real_uid,
+				TEST(SETRESUID(cleanup, *test_data[i].real_uid,
  					       *test_data[i].eff_uid,
  					       *test_data[i].sav_uid));
 
@@ -196,10 +197,10 @@ void setup(void)
  	}
 
  	nobody = *(getpwnam("nobody"));
-	nobody_pw_uid = nobody.pw_uid;
+	UID16_CHECK((nobody_pw_uid = nobody.pw_uid), "setresuid", cleanup)
 
  	bin = *(getpwnam("bin"));
-	bin_pw_uid = bin.pw_uid;
+	UID16_CHECK((bin_pw_uid = bin.pw_uid), "setresuid", cleanup)
 
  	/* Pause if that option was specified
  	 * TEST_PAUSE contains the code to fork the test with the -i option.
testcases/kernel/syscalls/setresuid/setresuid03.c +4 -4
index f624253..c679b82 100644
@@ -150,7 +150,7 @@ int main(int ac, char **av)
  			for (i = 0; i < TST_TOTAL; i++) {
 
  				/* Set the real, effective or saved user id */
-				TEST(setresuid(*test_data[i].real_uid,
+				TEST(SETRESUID(cleanup, *test_data[i].real_uid,
  					       *test_data[i].eff_uid,
  					       *test_data[i].sav_uid));
 
@@ -207,13 +207,13 @@ void setup(void)
  	}
 
  	root = *(getpwnam("root"));
-	root_pw_uid = root.pw_uid;
+	UID16_CHECK((root_pw_uid = root.pw_uid), "setresuid", cleanup)
 
  	nobody = *(getpwnam("nobody"));
-	nobody_pw_uid = nobody.pw_uid;
+	UID16_CHECK((nobody_pw_uid = nobody.pw_uid), "setresuid", cleanup)
 
  	bin = *(getpwnam("bin"));
-	bin_pw_uid = bin.pw_uid;
+	UID16_CHECK((bin_pw_uid = bin.pw_uid), "setresuid", cleanup)
 
  	/* Pause if that option was specified
  	 * TEST_PAUSE contains the code to fork the test with the -i option.
testcases/kernel/syscalls/setresuid/setresuid04.c +7 -4
index 140d5f3..49b2616 100644
@@ -53,6 +53,7 @@
  #include "test.h"
  #include "usctest.h"
  #include <pwd.h>
+#include "compat_16.h"
 
  char *TCID = "setresuid04";
  int TST_TOTAL = 1;
@@ -111,8 +112,8 @@ void do_master_child(void)
  		/* Reset tst_count in case we are looping */
  		tst_count = 0;
 
-		if (setresuid(0, ltpuser->pw_uid, 0) == -1) {
-			perror("setfsuid failed");
+		if (SETRESUID(cleanup, 0, ltpuser->pw_uid, 0) == -1) {
+			perror("setresuid failed");
  			exit(1);
  		}
 
@@ -176,8 +177,8 @@ void do_master_child(void)
  		 *         the file with RDWR permissions.
  		 */
  		tst_count++;
-		if (setresuid(0, 0, 0) == -1) {
-			perror("setfsuid failed");
+		if (SETRESUID(cleanup, 0, 0, 0) == -1) {
+			perror("setresuid failed");
  			exit(1);
  		}
 
@@ -203,6 +204,8 @@ void setup(void)
 
  	ltpuser = getpwnam(nobody_uid);
 
+	UID16_CHECK(ltpuser->pw_uid, "setresuid", cleanup)
+
  	tst_tmpdir();
 
  	sprintf(testfile, "setresuid04file%d.tst", getpid());
testcases/kernel/syscalls/setresuid/setresuid05.c +4 -1
index 8880aeb..81175eb 100644
@@ -30,6 +30,7 @@
  #include "test.h"
  #include "usctest.h"
  #include "safe_macros.h"
+#include "compat_16.h"
 
  char *TCID = "setresuid05";
  int TST_TOTAL = 1;
@@ -70,13 +71,15 @@ static void setup(void)
  	tst_tmpdir();
 
  	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
+
+	UID16_CHECK(ltpuser->pw_uid, "setresuid", cleanup)
  }
 
  static void setresuid_verify(void)
  {
  	struct stat buf;
 
-	TEST(setresuid(-1, ltpuser->pw_uid, -1));
+	TEST(SETRESUID(cleanup, -1, ltpuser->pw_uid, -1));
 
  	if (TEST_RETURN != 0) {
  		tst_resm(TFAIL | TTERRNO, "setresuid failed unexpectedly");
testcases/kernel/syscalls/utils/compat_16.h +15 -0
index 40bef59..b6a702d 100644
@@ -127,8 +127,28 @@ int SETREGID(void (cleanup)(void), GID_T rgid, GID_T egid)
  	LTP_CREATE_SYSCALL(setregid, cleanup, rgid, egid);
  }
 
+int SETRESUID(void (cleanup)(void), UID_T ruid, UID_T euid, UID_T suid)
+{
+	LTP_CREATE_SYSCALL(setresuid, cleanup, ruid, euid, suid);
+}
+
+int SETRESGID(void (cleanup)(void), GID_T rgid, GID_T egid, GID_T sgid)
+{
+	LTP_CREATE_SYSCALL(setresgid, cleanup, rgid, egid, sgid);
+}
+
+int FCHOWN(void (cleanup)(void), unsigned int fd, UID_T owner, GID_T group)
+{
+	LTP_CREATE_SYSCALL(fchown, cleanup, fd, owner, group);
+}
+

testcases/kernel/syscalls/utils/compat_16.h int SETREGID(void (cleanup)(void), GID_T rgid, GID_T egid) · line 154

Quoted 10 lines
testcases/kernel/syscalls/utils/compat_16.h +5 -0
  int LCHOWN(void (cleanup)(void), const char *path, UID_T owner, GID_T group)
  {
  	LTP_CREATE_SYSCALL(lchown, cleanup, path, owner, group);
  }
+
+int CHOWN(void (cleanup)(void), const char *path, UID_T owner, GID_T group)
+{
+	LTP_CREATE_SYSCALL(chown, cleanup, path, owner, group);
+}
  #endif /* __LTP_COMPAT_16_H__ */

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#8 lore raw

Re: [LTP] [PATCH v2] fix some syscall tests for 16-bit compat testing

Quoted 35 lines · Stanislav Kholmanskikh
Quoted 14 lines · Han Pingtian
Quoted 13 lines · Stanislav Kholmanskikh

Hi.

In general, it looks good.

I have only one comment, that it's possible that the uid/gid values we pass to the syscall may not fit into UID_T/GID_T. For example, when we get uid of nobody user in runtime and pass it to chown() or etc.

Yes, it's more like an artificial case, but it's.

We have UID16_CHECK and GID16_CHECK macros to check if the uid/gid fits the compat mode.

Quoted 8 lines
Quoted 4 lines

What do you think about using it in test cases chown01, chown03, chown04, fchown01, fchown03, fchown04, setresgid*, setresuid* ?

Thank you.

Please review new patch which included UID16_CHECK and GID16_CHECK.

Thanks.

Hi!

I pushed your patch with TCID_DEFINE added (overlooked it at that time), and also pushed a follow-up patch which:
* fixes setresuid02_16, setresuid03_16, setresuid04_16 - they do
testing inside their children.
* explicitly declares setresuid(), setresgid() in compat_16.h. This is
to manage compilation warnings.

Quoted 5 lines

Tested in OL6 with 2.6.39-400.215.11.el6uek.x86_64 and 2.6.39-400.214.5.el6uek.i686 kernels.

Thank you.

Thanks!

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list