mount08.c: SKIP test if selinux is running
PATCH 1/1 mount08.c: SKIP test if selinux is running
--- testcases/kernel/syscalls/mount/mount08.c | 3 +++ 1 file changed, 3 insertions(+)
testcases/kernel/syscalls/mount/mount08.c +3 -0
@@ -41,6 +41,9 @@ static void run(void)static void setup (void ) { +if (tst_selinux_enforcing ()) +tst_brk (TCONF ,"SKIP test since selinux is running" ); +SAFE_TOUCH (FOO ,0777 ,NULL );SAFE_TOUCH (BAR ,0777 ,NULL ); }
Signature · 5 lines
2.49.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
The commit is missing why this has to be done. Please be more verbose and explain the reasons in the commit message.
Quoted 25 lines
Signed-off-by Wei Gao <[email protected]>--- testcases/kernel/syscalls/mount/mount08.c | 3 +++ 1 file changed, 3 insertions(+)testcases/kernel/syscalls/mount/mount08.c +3
-0@@ -41,6 +41,9 @@ static void run(void)static void setup (void ) { +if (tst_selinux_enforcing ()) +tst_brk (TCONF ,"SKIP test since selinux is running" ); +SAFE_TOUCH (FOO ,0777 ,NULL );SAFE_TOUCH (BAR ,0777 ,NULL ); }Signature · 5 lines
2.49.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi,
Quoted 2 lines
The commit is missing why this has to be done. Please be more verbose and explain the reasons in the commit message.
+1, I was going to write the same (remember: often more useful commit message is not *what* you change, but *why* your did the change).
Also, test under SELinux returns EACCES instead of ENOENT:
mount08.c:32: TFAIL: mount(/proc/130541/fd/4) expected ENOENT: EACCES (13)
Why not keep the test just update errno for SELinux?
In setup:
static int exp_errno = ENOENT;
if (tst_selinux_enforcing()) exp_errno = EACCES;
Quoted 11 lines
Quoted 10 lines
Signed-off-by Wei Gao <[email protected]>--- testcases/kernel/syscalls/mount/mount08.c | 3 +++ 1 file changed, 3 insertions(+)testcases/kernel/syscalls/mount/mount08.c +0
-0@@ -41,6 +41,9 @@ static void run(void)
Quoted 4 lines
testcases/kernel/syscalls/mount/mount08.c static void run(void) · line 45
Quoted 4 lines
testcases/kernel/syscalls/mount/mount08.c +2
-0static void setup (void ) { +if (tst_selinux_enforcing ()) +tst_brk (TCONF ,"SKIP test since selinux is running" );
Please don't use upper case. Also SELinux is not "running" but enabled in enforce mode. If test should be really skip I would use:
tst_brk(TCONF, "skip test due SELinux enforce");
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/1 mount08.c: Check EACCES error when test under selinux enabled in enforce mode
In reply to Wei Gao via ltpTest case expected ENOENT but get EACCES when selinux enabled in enforce mode. This patch add check errno under selinux.
--- testcases/kernel/syscalls/mount/mount08.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/mount/mount08.c +6 -1
@@ -16,6 +16,8 @@#define FOO MNTPOINT "/foo"#define BAR MNTPOINT "/bar" +static int exp_errno =ENOENT ; +static void run (void ) {char path[PATH_MAX ];
@@ -31,7 +33,7 @@ static void run(void)TST_EXP_FAIL (mount (BAR , path,"" ,MS_BIND ,0 ), -ENOENT , + exp_errno,"mount(%s)" , path );
@@ -41,6 +43,9 @@ static void run(void)static void setup (void ) { +if (tst_selinux_enforcing ()) + exp_errno =EACCES ; +SAFE_TOUCH (FOO ,0777 ,NULL );SAFE_TOUCH (BAR ,0777 ,NULL ); }
Signature · 5 lines
2.49.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2] mount08.c: Check EACCES error when test under selinux enabled in enforce mode
Hi Wei,
Quoted 2 lines
Test case expected ENOENT but get EACCES when selinux enabled in enforce mode. This patch add check errno under selinux.
Thanks!
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2] mount08.c: Check EACCES error when test under selinux enabled in enforce mode
In reply to Wei Gao via ltpHi!
Quoted 31 lines · Wei Gao via ltp
Test case expected ENOENT but get EACCES when selinux enabled in enforce mode. This patch add check errno under selinux.
Signed-off-by Wei Gao <[email protected]>--- testcases/kernel/syscalls/mount/mount08.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)testcases/kernel/syscalls/mount/mount08.c +3
-1@@ -16,6 +16,8 @@#define FOO MNTPOINT "/foo"#define BAR MNTPOINT "/bar" +static int exp_errno =ENOENT ; +static void run (void ) {char path[PATH_MAX ];@@ -31,7 +33,7 @@ static void run(void)TST_EXP_FAIL (mount (BAR , path,"" ,MS_BIND ,0 ), -ENOENT , + exp_errno,"mount(%s)" , path );
testcases/kernel/syscalls/mount/mount08.c static void run(void) · line 51
Quoted 9 lines
testcases/kernel/syscalls/mount/mount08.c +3
-0@@ -41,6 +43,9 @@ static void run(void)static void setup (void ) { +if (tst_selinux_enforcing ()) + exp_errno =EACCES ; +SAFE_TOUCH (FOO ,0777 ,NULL );SAFE_TOUCH (BAR ,0777 ,NULL ); }
We are not 100% sure that SELinux will be configured to block the access to mount. We should probably consider both of them only when SELinux is enabled, otherwise ENOENT only.
- Andrea
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2] mount08.c: Check EACCES error when test under selinux enabled in enforce mode
Hi Andrea, Wei,
Quoted 3 lines
We are not 100% sure that SELinux will be configured to block the access to mount. We should probably consider both of them only when SELinux is enabled, otherwise ENOENT only.
Good point. Lets' use TST_EXP_FAIL_ARR with ENOENT or ENOENT and EACCES. Wei, please make a comment in source code, why EACCES is not enough for SELinux. Thanks!
Kind regards,
Petr
Quoted 1 line
- Andrea
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 1/1 mount08.c: Check EACCES error when test under selinux enabled in enforce mode
In reply to Wei Gao via ltpTest case expected ENOENT but get EACCES when selinux enabled in enforce mode. This patch add check errno under selinux.
--- testcases/kernel/syscalls/mount/mount08.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/mount/mount08.c +15 -2
@@ -6,6 +6,8 @@/*\ * Verify that mount will raise ENOENT if we try to mount on magic links * under /proc/<pid>/fd/<nr>. +* If SELinux is enabled, the expected error also can be EACCES since +* SElinux plicy could be configured to block the operation. */ #include "tst_test.h"
@@ -16,6 +18,12 @@#define FOO MNTPOINT "/foo"#define BAR MNTPOINT "/bar" +static int exp_errnos_num; +static int exp_errnos[] = { +ENOENT , +EACCES , +}; +static void run (void ) {char path[PATH_MAX ];
@@ -29,9 +37,9 @@ static void run(void)sprintf (path,"/proc/%d/fd/%d" ,getpid (), proc_fd); -TST_EXP_FAIL ( +TST_EXP_FAIL_ARR (mount (BAR , path,"" ,MS_BIND ,0 ), -ENOENT , + exp_errnos, exp_errnos_num,"mount(%s)" , path );
@@ -41,6 +49,11 @@ static void run(void)static void setup (void ) { + exp_errnos_num =ARRAY_SIZE (exp_errnos) -1 ; + +if (tst_selinux_enforcing ()) + exp_errnos_num++; +SAFE_TOUCH (FOO ,0777 ,NULL );SAFE_TOUCH (BAR ,0777 ,NULL ); }
Signature · 5 lines
2.49.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3] mount08.c: Check EACCES error when test under selinux enabled in enforce mode
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Andrea Cervesato via ltp
AppliedRe: [LTP] [PATCH v3] mount08.c: Check EACCES error when test under selinux enabled in enforce mode
In reply to Wei Gao via ltpMerged, thanks!
- Andrea
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp