Update selinux ioctl test
PATCH 1/1 Update selinux ioctl test
Update the selinux ioctl test in ltp to reflect the revised selinux_file_ioctl() logic in the kernel. Also requires the corresponding ltp selinux test policy update.
---
testcases/kernel/security/selinux-testsuite/tests/ioctl/selinux_ioctl.c | 13 +++ testcases/kernel/security/selinux-testsuite/tests/ioctl/selinux_noioctl.c | 33 ++++++---- 2 files changed, 33 insertions(+), 13 deletions(-)
Index: testcases/kernel/security/selinux-testsuite/tests/ioctl/selinux_ioctl.c
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/security/selinux-testsuite/tests/ioctl/selinux_ioctl.c,v retrieving revision 1.2
kernel/security/selinux-testsuite/tests/ioctl/selinux_ioctl.c +10 -3
@@ -35,7 +35,7 @@exit (1 ); } -/* This one should hit the FILE__GETATTR test */ +/* This one should hit the FILE__IOCTL test */ rc =ioctl (fd,FIGETBSZ , &val);if ( rc !=0 ) {perror ("test_ioctl:FIGETBSZ" );
@@ -49,15 +49,22 @@exit (1 ); } -/* This one should hit the normal file descriptor use test */ +/* This one should hit the FILE__IOCTL test */ rc =ioctl (fd,FIONBIO , &val);if ( rc !=0 ) {perror ("test_ioctl:FIONBIO" );exit (1 ); } +/* This one should hit the FILE__READ test */ + rc =ioctl (fd,EXT2_IOC_GETVERSION , &val); +if ( rc !=0 ) { +perror ("test_ioctl:EXT2_IOC_GETVERSION" ); +exit (1 ); + } + +/* This one should hit the FILE__WRITE test */ val =0 ; -/* This one should hit the FILE__SETATTR test */ rc =ioctl (fd,EXT2_IOC_SETVERSION , &val);if ( rc !=0 ) {perror ("test_ioctl:EXT2_IOC_SETVERSION" );
Index: testcases/kernel/security/selinux-testsuite/tests/ioctl/selinux_noioctl.c
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/security/selinux-testsuite/tests/ioctl/selinux_noioctl.c,v retrieving revision 1.2
kernel/security/selinux-testsuite/tests/ioctl/selinux_noioctl.c +23 -10
@@ -37,29 +37,42 @@exit (1 ); } -/* This one should hit the normal file descriptor use test; expect success */ - rc =ioctl (fd,FIONBIO , &val); -if ( rc !=0 ) { -perror ("test_noioctl:FIONBIO" ); -exit (1 ); +/* This one should hit the FILE__IOCTL test and fail. */ + rc =ioctl (fd,FIGETBSZ , &val); +if ( rc ==0 ) { +printf ("test_noioctl:FIGETBSZ" ); +exit (1 ); } -/* This one should hit the FILE__GETATTR test; expect failure */ - rc =ioctl (fd,FIGETBSZ , &val); +/* This one should hit the FILE__IOCTL test and fail. */ + rc =ioctl (fd,FIOCLEX );if ( rc ==0 ) { +printf ("test_noioctl:FIOCLEX" );exit (1 ); } -/* This one should hit the FILE__IOCTL test */ - rc =ioctl (fd,FIOCLEX ); +/* This one should hit the FILE__IOCTL test and fail. */ + rc =ioctl (fd,FIONBIO , &val);if ( rc ==0 ) { +printf ("test_noioctl:FIONBIO" ); +exit (1 ); + } + +/* +* This one should hit the FILE__READ test and succeed since +* read permission had to be granted in order to open the file. +*/ + rc =ioctl (fd,EXT2_IOC_GETVERSION , &val); +if ( rc !=0 ) { +perror ("test_noioctl:EXT2_IOC_GETVERSION" );exit (1 ); } +/* This one should hit the FILE__WRITE test and fail. */ val =0 ; -/* This one should hit the FILE__SETATTR test; expect failure */ rc =ioctl (fd,EXT2_IOC_SETVERSION , &val);if ( rc ==0 ) { +perror ("test_noioctl:EXT2_IOC_SETVERSION" );exit (1 ); }
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 5 lines · Stephen Smalley
Update the selinux ioctl test in ltp to reflect the revised
selinux_file_ioctl()logic in the kernel. Also requires the corresponding ltp selinux test policy update.Signed-off-by Stephen Smalley <[email protected]>
Thanks.
Regards--
Subrata
Quoted 100 lines
---
testcases/kernel/security/selinux-testsuite/tests/ioctl/selinux_ioctl.c | 13 +++ testcases/kernel/security/selinux-testsuite/tests/ioctl/selinux_noioctl.c | 33 ++++++---- 2 files changed, 33 insertions(+), 13 deletions(-)Index:
testcases/kernel/security/selinux-testsuite/tests/ioctl/selinux_ioctl.c
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/security/selinux-testsuite/tests/ioctl/selinux_ioctl.c,v retrieving revision 1.2
diff -u -r1.2selinux_ioctl.ckernel/security/selinux-testsuite/tests/ioctl/selinux_ioctl.c +10
-3@@ -35,7 +35,7 @@exit (1 ); } -/* This one should hit the FILE__GETATTR test */ +/* This one should hit the FILE__IOCTL test */ rc =ioctl (fd,FIGETBSZ , &val);if ( rc !=0 ) {perror ("test_ioctl:FIGETBSZ" );@@ -49,15 +49,22 @@exit (1 ); } -/* This one should hit the normal file descriptor use test */ +/* This one should hit the FILE__IOCTL test */ rc =ioctl (fd,FIONBIO , &val);if ( rc !=0 ) {perror ("test_ioctl:FIONBIO" );exit (1 ); } +/* This one should hit the FILE__READ test */ + rc =ioctl (fd,EXT2_IOC_GETVERSION , &val); +if ( rc !=0 ) { +perror ("test_ioctl:EXT2_IOC_GETVERSION" ); +exit (1 ); + } + +/* This one should hit the FILE__WRITE test */ val =0 ; -/* This one should hit the FILE__SETATTR test */ rc =ioctl (fd,EXT2_IOC_SETVERSION , &val);if ( rc !=0 ) {perror ("test_ioctl:EXT2_IOC_SETVERSION" );Index:
testcases/kernel/security/selinux-testsuite/tests/ioctl/selinux_noioctl.c
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/security/selinux-testsuite/tests/ioctl/selinux_noioctl.c,v retrieving revision 1.2
diff -u -r1.2selinux_noioctl.ckernel/security/selinux-testsuite/tests/ioctl/selinux_noioctl.c +21
-9@@ -37,29 +37,42 @@exit (1 ); } -/* This one should hit the normal file descriptor use test; expect success */ - rc =ioctl (fd,FIONBIO , &val); -if ( rc !=0 ) { -perror ("test_noioctl:FIONBIO" ); -exit (1 ); +/* This one should hit the FILE__IOCTL test and fail. */ + rc =ioctl (fd,FIGETBSZ , &val); +if ( rc ==0 ) { +printf ("test_noioctl:FIGETBSZ" ); +exit (1 ); } -/* This one should hit the FILE__GETATTR test; expect failure */ - rc =ioctl (fd,FIGETBSZ , &val); +/* This one should hit the FILE__IOCTL test and fail. */ + rc =ioctl (fd,FIOCLEX );if ( rc ==0 ) { +printf ("test_noioctl:FIOCLEX" );exit (1 ); } -/* This one should hit the FILE__IOCTL test */ - rc =ioctl (fd,FIOCLEX ); +/* This one should hit the FILE__IOCTL test and fail. */ + rc =ioctl (fd,FIONBIO , &val);if ( rc ==0 ) { +printf ("test_noioctl:FIONBIO" ); +exit (1 ); + } + +/* +* This one should hit the FILE__READ test and succeed since +* read permission had to be granted in order to open the file. +*/ + rc =ioctl (fd,EXT2_IOC_GETVERSION , &val); +if ( rc !=0 ) { +perror ("test_noioctl:EXT2_IOC_GETVERSION" );exit (1 ); }
kernel/security/selinux-testsuite/tests/ioctl/selinux_noioctl.c line 78
Quoted 10 lines
kernel/security/selinux-testsuite/tests/ioctl/selinux_noioctl.c +2
-1+/* This one should hit the FILE__WRITE test and fail. */ val =0 ; -/* This one should hit the FILE__SETATTR test; expect failure */ rc =ioctl (fd,EXT2_IOC_SETVERSION , &val);if ( rc ==0 ) { +perror ("test_noioctl:EXT2_IOC_SETVERSION" );exit (1 ); }
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.