syscalls/mount03: Copy setuid_test to execute instead of 'TEST FILE'
PATCH v4 1/2 syscalls/mount03: Copy setuid_test to execute instead of 'TEST FILE'
When testing the MS_NOSUID mount flag, mount03 forgets to copy setuid_test into the new filesystem. Instead it writes 'TEST FILE' into a new file and attempts to execute it with S_ISUID. This fails, but not for the reasons ltp expects.
Fix this by copying the test helper binary instead.
While we're touching the test, also rename the helper to mount03_setuid_test so as to follow current ltp convention.
---
Changes since v3:
* Dropped the duplicate TST_RESOURCE_COPY()
* Moved setting SUID_MODE to setup()
testcases/kernel/syscalls/mount/mount03.c | 26 +++++++++++++---------
.../mount/{setuid_test.c => mount03_setuid_test.c} | 0
2 files changed, 15 insertions(+), 11 deletions(-)
rename testcases/kernel/syscalls/mount/{setuid_test.c => mount03_setuid_test.c} (100%)testcases/kernel/syscalls/mount/mount03.c +15 -11
@@ -261,15 +261,7 @@ int test_rwflag(int i, int cnt)case 5 :/* Validate MS_NOSUID flag of mount call */ -snprintf (file,PATH_MAX ,"%ssetuid_test" , path_name); -SAFE_FILE_PRINTF (cleanup, file,"TEST FILE" ); - -SAFE_STAT (cleanup, file, &file_stat); - -if (file_stat.st_mode !=SUID_MODE && -chmod (file,SUID_MODE ) <0 ) -tst_brkm (TBROK , cleanup, -"setuid for setuid_test failed" ); +snprintf (file,PATH_MAX ,"%smount03_setuid_test" , path_name); pid =fork ();switch (pid) {
@@ -291,9 +283,8 @@ int test_rwflag(int i, int cnt)/* reset the setup_uid */ if (status)return 0 ; -else -return 1 ; } +return 1 ; }case 6 :/* Validate MS_NOATIME flag of mount call */
@@ -346,6 +337,7 @@ int test_rwflag(int i, int cnt)static void setup (void ) {char path[PATH_MAX ]; +struct stat file_stat;tst_sig (FORK ,DEF_HANDLER , cleanup);
@@ -373,6 +365,18 @@ static void setup(void)strncpy (path, path_name,PATH_MAX );snprintf (path_name,PATH_MAX ,"%s/%s/" , path, mntpoint); +SAFE_MOUNT (cleanup, device, mntpoint, fs_type,0 ,NULL ); +TST_RESOURCE_COPY (cleanup,"mount03_setuid_test" , path_name); + +snprintf (file,PATH_MAX ,"%smount03_setuid_test" , path_name); +SAFE_STAT (cleanup, file, &file_stat); + +if (file_stat.st_mode !=SUID_MODE && +chmod (file,SUID_MODE ) <0 ) +tst_brkm (TBROK , cleanup, +"setuid for setuid_test failed" ); +SAFE_UMOUNT (cleanup, mntpoint); +TEST_PAUSE ; }
testcases/kernel/syscalls/mount/mount03_setuid_test.c renamed from testcases/kernel/syscalls/mount/setuid_test.c +0 -0
Signature · 1 line
2.15.0
PATCH v4 2/2 getdtablesize01: Handle ENFILE errno
From: "Suzuki K. Poulose" <[email protected]>
getdtablesize01 testcase attempts to open RLIMIT_NOFILE-1 (Maximum open files for a process) file descriptors. However if we hit an ENFILE (system wide limit of maximum number of open files) we should break the test, rather than failing. This is more relevant for runs on VMs where the rootfs could be a 9p fs or any other emulated fs.
---
Changes since v3:
* Dropped loop variable
testcases/kernel/syscalls/getdtablesize/getdtablesize01.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
testcases/kernel/syscalls/getdtablesize/getdtablesize01.c +9 -6
@@ -54,7 +54,7 @@ int TST_TOTAL = 1;int main (void ) { -int table_size, loop, fd, count =0 ; +int table_size, fd =0 , count =0 ;int max_val_opfiles;struct rlimit rlp;
@@ -80,15 +80,16 @@ int main(void)tst_resm (TINFO ,"Checking Max num of files that can be opened by a process.Should be: RLIMIT_NOFILE - 1" ); -for (loop =1 ; loop <= max_val_opfiles; loop++) { +for (; ;) { fd =open ("/etc/hosts" ,O_RDONLY ); + +if (fd ==-1 ) +break ; + count = fd; +#ifdef DEBUG printf ("Opened file num %d\n" , fd);#endif -if (fd ==-1 ) -break ; -else - count = fd; }//Now the max files opened should be RLIMIT_NOFILE - 1 , why ? read getdtablesize man page
@@ -97,6 +98,8 @@ int main(void)close (count);if (count == (max_val_opfiles -1 ))tst_resm (TPASS ,"%d = %d" , count, (max_val_opfiles -1 )); +else if (fd <0 && errno ==ENFILE ) +tst_brkm (TBROK , cleanup,"Reached maximum number of open files for the system" );else tst_resm (TFAIL ,"%d != %d" , count, (max_val_opfiles -1 ));
Signature · 1 line
2.15.0
PATCH v4 2/2 getdtablesize01: Handle ENFILE errno
Hi!
testcases/kernel/syscalls/getdtablesize/getdtablesize01.c int main(void) · line 102
Quoted 6 lines
testcases/kernel/syscalls/getdtablesize/getdtablesize01.c +2
-0@@ -97,6 +98,8 @@ int main(void)close (count);if (count == (max_val_opfiles -1 ))tst_resm (TPASS ,"%d = %d" , count, (max_val_opfiles -1 )); +else if (fd <0 && errno ==ENFILE ) +tst_brkm (TBROK , cleanup,"Reached maximum number of open files for the system" );
^
Haven't we agreed that this should be TCONF?
No need to resend, I can update it before push.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v4 2/2 getdtablesize01: Handle ENFILE errno
[ Apologies for the delayed response. I am travelling with spotty connectivity ]
Quoted 9 lines · Cyril Hrubis
Hi!
testcases/kernel/syscalls/getdtablesize/getdtablesize01.c int main(void) · line 102
Quoted 6 lines
testcases/kernel/syscalls/getdtablesize/getdtablesize01.c +2
-0@@ -97,6 +98,8 @@ int main(void)close (count);if (count == (max_val_opfiles -1 ))tst_resm (TPASS ,"%d = %d" , count, (max_val_opfiles -1 )); +else if (fd <0 && errno ==ENFILE ) +tst_brkm (TBROK , cleanup,"Reached maximum number of open files for the system" );^
Haven't we agreed that this should be TCONF?
Yup, I was sure I'd updated it as well. I might have lost the change moving the patches across branches.
Quoted 2 lines
No need to resend, I can update it before push.
Yes, please. :)
Thanks,
Punit
PATCH v4 2/2 getdtablesize01: Handle ENFILE errno
Hi!
Quoted 3 lines
Quoted 1 line
No need to resend, I can update it before push.
Yes, please. :)
Pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v4 1/2 syscalls/mount03: Copy setuid_test to execute instead of 'TEST FILE'
In reply to Punit AgrawalHi!
Pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]