Fix FILECAPS test hanging for more than 12 hours
PATCH 1/1 Fix FILECAPS test hanging for more than 12 hours
Hi,
Recently running FILECAPS test on my Fedora system:
# uname -a Linux 2.6.33.1-19.fc13.ppc64 #1 SMP Tue Mar 23 06:32:38 EDT 2010 ppc64 ppc64 ppc64 GNU/Linux,
I found that the test hangs for more than 12 hours. The following patch by Serge fixes the issue. Kindly include it inside LTP.
Serge, please add a Sign-off.
Issue before the patch:
=============================
# ./runltp -f filecaps <<<test_start>>> tag=Filecaps stime=1271951563 cmdline="filecapstest.sh" contacts="" analysis=exit <<<test_output>>> Running in: cap_sys_admin tests testing for correct caps ... The test hangs here for more than 12 hours.
Following are various info about the processes running this test:
# ps ajxf 1608 1724 1608 1458 ? -1 S 0 0:00 \_ /opt/ltp/bin/ltp-pan -e -S -a 1608 -n 1608 -p -f /tmp/ltp-71wskF3epE/alltests -l /opt/ltp/results/LTP_RUN_ON-20 1724 30311 30311 1458 ? -1 S 0 0:00 \_ /bin/sh /opt/ltp/testcases/bin/filecapstest.sh 30311 30315 30311 1458 ? -1 S 0 0:00 \_ verify_caps_exec 1 30315 30316 30311 1458 ? -1 Z 1000 0:00 \_ [verify_caps_exe] <defunct>
STRACE on the PIDs does not show anything:
[root@alien5 ltp]# strace -p 30425
Process 30425 attached - interrupt to quit waitpid(-1, ^C <unfinished ...>
Process 30425 detached
[root@alien5 ltp]# strace -p 30429
Process 30429 attached - interrupt to quit open("caps_fifo", O_RDONLY^C <unfinished ...> Process 30429 detached
[root@alien5 ltp]# strace -p 30430
attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted
# getenforce Permissive [root@alien5 ltp]# tail -f /var/log/messages 2010-04-21T18:00:15.752320+05:18 alien5 setroubleshoot: SELinux is preventing /sbin/rsyslogd access to a leaked /opt/ltp/output/LTP_RUN_ON-2010_Apr_21-17h_51m_22s.output file descriptor. For complete SELinux messages. run sealert -l 894e0d2d-23c3-45d1-9108-71ad97f5a45e 2010-04-21T18:00:15.794214+05:18 alien5 setroubleshoot: SELinux is preventing /sbin/rsyslogd access to a leaked /opt/ltp/output/LTP_RUN_ON-2010_Apr_21-17h_51m_22s.output file descriptor. For complete SELinux messages. run sealert -l 894e0d2d-23c3-45d1-9108-71ad97f5a45e 2010-04-21T18:00:15.823557+05:18 alien5 setroubleshoot: SELinux is preventing /sbin/rsyslogd access to a leaked /opt/ltp/output/LTP_RUN_ON-2010_Apr_21-17h_51m_22s.output file descriptor. For complete SELinux messages. run sealert -l 894e0d2d-23c3-45d1-9108-71ad97f5a45e 2010-04-21T18:00:17.721361+05:18 alien5 syslogtst: syslogtst:10 error level is logged Apr 21 18:00:19 alien5 kernel: imklog 4.4.2, log source = /proc/kmsg started. Apr 21 18:00:19 alien5 rsyslogd: [origin software="rsyslogd" swVersion="4.4.2" x-pid="2165" x-info="http://www.rsyslog.com"] (re)start Apr 21 18:00:20 alien5 setroubleshoot: SELinux is preventing /sbin/rsyslogd access to a leaked /opt/ltp/output/LTP_RUN_ON-2010_Apr_21-17h_51m_22s.output file descriptor. For complete SELinux messages. run sealert -l 894e0d2d-23c3-45d1-9108-71ad97f5a45e Apr 21 18:00:20 alien5 setroubleshoot: SELinux is preventing /sbin/rsyslogd access to a leaked /opt/ltp/output/LTP_RUN_ON-2010_Apr_21-17h_51m_22s.output file descriptor. For complete SELinux messages. run sealert -l 894e0d2d-23c3-45d1-9108-71ad97f5a45e Apr 21 18:00:20 alien5 setroubleshoot: SELinux is preventing /sbin/rsyslogd access to a leaked /opt/ltp/output/LTP_RUN_ON-2010_Apr_21-17h_51m_22s.output file descriptor. For complete SELinux messages. run sealert -l 894e0d2d-23c3-45d1-9108-71ad97f5a45e
So, i executed the following command:
# sealert -l 894e0d2d-23c3-45d1-9108-71ad97f5a45e exception when creating syslog handler: [Errno 2] No such file or directory Summary: SELinux is preventing /sbin/rsyslogd access to a leaked /opt/ltp/output/LTP_RUN_ON-2010_Apr_21-17h_51m_22s.output file descriptor.
Detailed Description:
[rsyslogd has a permissive type (syslogd_t). This access was not denied.]
SELinux denied access requested by the rsyslogd command. It looks like this is either a leaked descriptor or rsyslogd output was redirected to a file it is not
allowed to access. Leaks usually can be ignored since SELinux is just closing the leak and reporting the error. The application does not use the descriptor, so it will run properly. If this is a redirection, you will not get output in the /opt/ltp/output/LTP_RUN_ON-2010_Apr_21-17h_51m_22s.output. You should generate a bugzilla on selinux-policy, and it will get routed to the appropriate
package. You can safely ignore this avc.
Allowing Access:
You can generate a local policy module to allow this access - see FAQ
(http://docs.fedoraproject.org/selinux-faq-fc5/#id2961385)
Additional Information:
Source Context unconfined_u:system_r:syslogd_t:s0
Target Context unconfined_u:object_r:usr_t:s0
Target Objects /opt/ltp/output/LTP_RUN_ON-
2010_Apr_21-17h_51m_22s.output [ file ]
Source rsyslogd
Source Path /sbin/rsyslogd
Port <Unknown>
Host alien5.ltc.austin.ibm.com
Source RPM Packages rsyslog-4.4.2-6.fc13
Target RPM Packages
Policy RPM selinux-policy-3.7.15-4.fc13
Selinux Enabled True
Policy Type targeted
Enforcing Mode Enforcing
Plugin Name leaks
Host Name alien5.ltc.austin.ibm.com
Platform Linux alien5.ltc.austin.ibm.com
2.6.33.1-19.fc13.ppc64 #1 SMP Tue Mar 23 06:32:38
EDT 2010 ppc64 ppc64
Alert Count 186
First Seen Tue Apr 20 23:55:40 2010
Last Seen Wed Apr 21 18:00:19 2010
Local ID 894e0d2d-23c3-45d1-9108-71ad97f5a45eLine Numbers
Raw Audit Messages
node= type=AVC msg=audit(1271853019.957:317): avc:
denied { append } for pid=2164 comm="rsyslogd" path="/opt/ltp/output/LTP_RUN_ON-2010_Apr_21-17h_51m_22s.output" dev=sda3 ino=1188363 scontext=unconfined_u:system_r:syslogd_t:s0 tcontext=unconfined_u:object_r:usr_t:s0 tclass=file
node= type=AVC msg=audit(1271853019.957:317): avc:
denied { append } for pid=2164 comm="rsyslogd" path="/opt/ltp/results/LTP_RUN_ON-2010_Apr_21-17h_51m_22s.log" dev=sda3 ino=1188362 scontext=unconfined_u:system_r:syslogd_t:s0 tcontext=unconfined_u:object_r:usr_t:s0 tclass=file
node= type=AVC msg=audit(1271853019.957:317): avc:
denied { append } for pid=2164 comm="rsyslogd" path="/opt/ltp/output/LTP_RUN_ON-2010_Apr_21-17h_51m_22s.failed" dev=sda3 ino=1188364 scontext=unconfined_u:system_r:syslogd_t:s0 tcontext=unconfined_u:object_r:usr_t:s0 tclass=file
node= type=SYSCALL msg=audit(1271853019.957:317):
arch=14 syscall=11 success=yes exit=0 a0=1026c900 a1=1026b5b0 a2=1026b640 a3=1026b5a8 items=0 ppid=2163 pid=2164 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=22 comm="rsyslogd" exe="/sbin/rsyslogd" subj=unconfined_u:system_r:syslogd_t:s0 key=(null)
=============================
=============================
Test result after applying the patch
=============================
<<<test_start>>>
tag=Filecaps stime=1272996532
cmdline="filecapstest.sh"
contacts=""
analysis=exit
<<<test_output>>>
incrementing stop
Running in:cap_sys_admin tests
filecaps 1 TPASS : could not set capabilities as non-root
testing for correct caps
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO :
caps are =
filecaps 0 TINFO : 0
filecaps 0 TINFO : 1
filecaps 0 TINFO : 2
filecaps 0 TINFO : 3
filecaps 0 TINFO : 4
filecaps 0 TINFO : 5
filecaps 0 TINFO : 6
filecaps 0 TINFO : 7
filecaps 0 TINFO : 8
filecaps 0 TINFO : 9
filecaps 0 TINFO : 10
filecaps 0 TINFO : 11
filecaps 0 TINFO : 12
filecaps 0 TINFO : 13
filecaps 0 TINFO : 14
filecaps 0 TINFO : 15
filecaps 0 TINFO : 16
filecaps 0 TINFO : 17
filecaps 0 TINFO : 18
filecaps 0 TINFO : 19
filecaps 0 TINFO : 20
filecaps 0 TINFO : 21
filecaps 0 TINFO : 22
filecaps 0 TINFO : 23
filecaps 0 TINFO : 24
filecaps 0 TINFO : 25
filecaps 0 TINFO : 26
filecaps 0 TINFO : 27
filecaps 0 TINFO : 28
filecaps 0 TINFO : 29
filecaps 0 TINFO : 30
filecaps 0 TINFO : 31
filecaps 0 TINFO : 32
filecaps 0 TINFO : 33
filecaps 1 TPASS : All tests passed
testing for correct pI checks
filecaps 0 TINFO : start filecaps 0 TINFO : =ep filecaps 0 TINFO : after raising all caps filecaps 0 TINFO : =eip filecaps 0 TINFO : after first drop cap_sys_admin filecaps 0 TINFO : =eip cap_sys_admin-eip filecaps 0 TINFO : after first raise cap_sys_admin filecaps 0 TINFO : =eip cap_sys_admin-ep filecaps 0 TINFO : after drop cappset filecaps 0 TINFO : =ip cap_sys_admin-p filecaps 0 TINFO : after second drop cap_sys_admin filecaps 0 TINFO : =eip cap_setpcap-e cap_sys_admin-eip filecaps 0 TINFO : final filecaps 0 TINFO : =eip cap_setpcap-e cap_sys_admin-eip filecaps 1 TPASS : pI is properly capped
<<<execution_status>>>
initiation_status="ok"
duration=0 termination_type=exited termination_id=0 corefile=no cutime=0 cstime=4
<<<test_end>>>
=============================
Regards--
Subrata
From 4b368ba90ba282bee61d8bc43fd8c1e178539a5a Mon Sep 17 00:00:00 2001
From: Serge E. Hallyn <[email protected]>
Date: Wed, 28 Apr 2010 11:26:58 -0500
Subject: [PATCH 1/1] make filecaps tests succeed
Most of these are belated cleanup after the move to using /opt/ltp. Also undoing an ill-advised replacement of return with tst_exit. All filecaps tests now succeed on fedora 10.
--- testcases/kernel/security/filecaps/filecapstest.sh | 9 ++++++--- testcases/kernel/security/filecaps/print_caps.c | 3 ++- .../kernel/security/filecaps/verify_caps_exec.c | 19 ++++++++++++++----- 3 files changed, 22 insertions(+), 9 deletions(-)
testcases/kernel/security/filecaps/filecapstest.sh +6 -3
@@ -22,8 +22,11 @@ echo "Running in:" #rm -f print_caps #cp $LTPROOT/testcases/bin/print_caps . -mkfifo caps_fifo -chmod 777 caps_fifo +#FIFOFILE="$LTPROOT/testcases/bin/caps_fifo" +FIFOFILE="/tmp/caps_fifo" +rm -f $FIFOFILE +mkfifo $FIFOFILE +chmod 777 $FIFOFILE exit_code=0 echo "cap_sys_admin tests" verify_caps_exec 0
@@ -46,5 +49,5 @@ if [ $tmp -ne 0 ]; then exit_code=$tmp fi -unlink caps_fifo +unlink $FIFOFILE exit $exit_code
testcases/kernel/security/filecaps/print_caps.c +2 -1
@@ -36,7 +36,7 @@#include <sys/capability.h> #endif -#define FIFOFILE "caps_fifo" +#define FIFOFILE "/tmp/caps_fifo"int main (int argc,char *argv[]) {
@@ -68,4 +68,5 @@ int main(int argc, char *argv[])#else return 0 ;#endif +return 0 ; }
testcases/kernel/security/filecaps/verify_caps_exec.c +14 -5
@@ -43,7 +43,7 @@#include <sys/prctl.h> #include <test.h> -#define TSTPATH "./print_caps" +#define TSTPATH "print_caps"char *TCID ="filecaps" ;int TST_TOTAL =1 ;
@@ -70,7 +70,7 @@ void print_my_caps()cap_free (txt); } -int drop_root (int keep_perms) +void drop_root (int keep_perms) {int ret;
@@ -84,10 +84,19 @@ int drop_root(int keep_perms) }if (keep_perms) {cap_t cap =cap_from_text ("=eip" ); -cap_set_proc (cap); +int ret; +if (!cap) { +tst_resm (TBROK ,"cap_from_text failed\n" ); +tst_exit (); + } + ret =cap_set_proc (cap); +if (ret <0 ) { +perror (cap_set_proc); +tst_resm (TBROK |TERRNO ,"cap_set_proc failed\n" ); +tst_exit (); + }cap_free (cap); } -tst_exit (); }int perms_test (void )
@@ -114,7 +123,7 @@ int perms_test(void)return ret; } -#define FIFOFILE "caps_fifo" +#define FIFOFILE "/tmp/caps_fifo"void create_fifo (void ) {int ret;
Signature · 1 line
1.6.0.6
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 1 line · Subrata Modak
Serge, please add a Sign-off.
It's there in the patch in your attachment...
-serge
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 4 lines · Serge E. Hallyn
Quoted 1 line · Subrata Modak
Serge, please add a Sign-off.
It's there in the patch in your attachment...
Serge,
Please address the items in the previous review and we'll get it committed.
Thanks,
-Garrett
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 10 lines · Garrett Cooper
Quoted 4 lines · Serge E. Hallyn
Quoted 1 line · Subrata Modak
Serge, please add a Sign-off.
It's there in the patch in your attachment...
Serge,
Please address the items in the previous review and we'll get it committed.
Thanks,
-Garrett
Ah, I see. You only broke the testcase to get my attention so you could get me to use more appropriate ltp helpers. Sneaky! And since I learned some things in the process, great. Hopefully I'll get them right when I submit the next set.
From 2077a47e9cd2f85a8e54695c71396a1a8397d3d6 Mon Sep 17 00:00:00 2001
From: Serge E. Hallyn <[email protected]>
Date: Wed, 28 Apr 2010 11:26:58 -0500
Subject: [PATCH 1/1] make filecaps tests succeed
Most of these are belated cleanup after the move to using /opt/ltp. But come on, replacing 'return' with tst_exit(), are you just trying to mess with my head?
Changelog: may 4: address Garrett's feedback
1. single return 0 in print_caps.c
2. use $TMP if defined for location of caps_fifo
3. use tst_brkm in place of tst_resm.
--- testcases/kernel/security/filecaps/filecapstest.sh | 10 +++- testcases/kernel/security/filecaps/print_caps.c | 5 +- .../kernel/security/filecaps/verify_caps_exec.c | 48 ++++++++------------ 3 files changed, 28 insertions(+), 35 deletions(-)
testcases/kernel/security/filecaps/filecapstest.sh +7 -3
@@ -22,8 +22,12 @@ echo "Running in:" #rm -f print_caps #cp $LTPROOT/testcases/bin/print_caps . -mkfifo caps_fifo -chmod 777 caps_fifo +#FIFOFILE="$LTPROOT/testcases/bin/caps_fifo" +TMP=${TMP:=/tmp} +FIFOFILE="$TMP/caps_fifo" +rm -f $FIFOFILE +mkfifo $FIFOFILE +chmod 777 $FIFOFILE exit_code=0 echo "cap_sys_admin tests" verify_caps_exec 0
@@ -46,5 +50,5 @@ if [ $tmp -ne 0 ]; then exit_code=$tmp fi -unlink caps_fifo +unlink $FIFOFILE exit $exit_code
testcases/kernel/security/filecaps/print_caps.c +2 -3
@@ -36,7 +36,7 @@#include <sys/capability.h> #endif -#define FIFOFILE "caps_fifo" +#define FIFOFILE "/tmp/caps_fifo"int main (int argc,char *argv[]) {
@@ -65,7 +65,6 @@ int main(int argc, char *argv[])close (fd);cap_free (cap); -#else -return 0 ;#endif +return 0 ; }
testcases/kernel/security/filecaps/verify_caps_exec.c +19 -29
110 lines not on this page · raw message
Signature · 8 lines
1.6.0.6 ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 12 lines · Serge E. Hallyn
Quoted 10 lines · Garrett Cooper
Quoted 4 lines · Serge E. Hallyn
Quoted 1 line · Subrata Modak
Serge, please add a Sign-off.
It's there in the patch in your attachment...
Serge,
Please address the items in the previous review and we'll get it committed. Thanks,
-Garrett
Quoted 4 lines
Ah, I see. You only broke the testcase to get my attention so you could get me to use more appropriate ltp helpers. Sneaky! And since I learned some things in the process, great. Hopefully I'll get them right when I submit the next set.
??? You're getting the glory, not me (and FWIW I haven't committed to LTP in about a month)...
Quoted 8 lines
From
2077a47e9cd2f85a8e54695c71396a1a8397d3d6Mon Sep 17 00:00:00 2001
From: Serge E. Hallyn <[email protected]>
Date: Wed, 28 Apr 2010 11:26:58 -0500
Subject: [PATCH 1/1] make filecaps tests succeedMost of these are belated cleanup after the move to using
/opt/ltp. But come on, replacing 'return' withtst_exit(), are you just trying to mess with my head?
Yeah, I admit that was stupid :(... I want trying to preserve the exit code in the event that the call would fail *sigh*. It doesn't matter that much now I suppose.
[...]
Quoted 7 lines
p =
index(buf, '.')+1;
- if (p==(char *)1) {
-tst_resm(TFAIL, "got a bad message from print_caps\n");
-tst_exit();
- }
+ if (p==(char *)1)
+tst_brkm(TFAIL, tst_exit, "got a bad message from print_caps\n");
This is a really incorrect way to do things. I think that the
assumption made was that index(3) would return 0 ('\0') if it fails to find '.'. That's incorrect and would cause a segfault on some systems (does on FreeBSD at least... don't see why it would pass on Linux):
$ ~/test_null_inc
Segmentation fault: 11 (core dumped)
[garrcoop@bioshock ~]$ cat ~/test_null_inc.c
#include <stdio.h>
int
main(void)
{
printf("%s\n", (NULL + 1));
return 0;
} Could you please change this to check and see whether or not index
returns NULL instead of accessing memory like that?
Other than that, patch looks good.
Thanks!
-Garrett
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 1 line · Garrett Cooper
Quoted 1 line
p =
index(buf, '.')+1;
Jinkeys! The intertubes archives insist I wrote that, but I'm finding it hard to believe.
Quoted 12 lines
Quoted 6 lines
- if (p==(char *)1) {
-tst_resm(TFAIL, "got a bad message from print_caps\n");
-tst_exit();
- }
+ if (p==(char *)1)
+tst_brkm(TFAIL, tst_exit, "got a bad message from print_caps\n");This is a really incorrect way to do things. I think that the
assumption made was that index(3) would return 0 ('\0') if it fails to find '.'. That's incorrect and would cause a segfault on some systems (does on FreeBSD at least... don't see why it would pass on Linux):
Quoted 10 lines
$ ~/test_null_inc
Segmentation fault: 11 (core dumped)
[garrcoop@bioshock ~]$ cat ~/test_null_inc.c
#include <stdio.h>
int
main(void)
{
printf("%s\n", (NULL + 1));
return 0;
}Well, that's different - you're dereferencing NULL+1, whereas I'm just checking the the value of the pointer.
Still what I did is darned ugly, cleanup below.
thanks,
-serge
Quoted 3 lines
Could you please change this to check and see whether or not index
returns NULL instead of accessing memory like that?
Other than that, patch looks good.
From: Serge E. Hallyn <[email protected]>
Date: Wed, 5 May 2010 02:59:05 -0500
Subject: [PATCH 1/1] check for index(3) returning NULL
--- .../kernel/security/filecaps/verify_caps_exec.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
testcases/kernel/security/filecaps/verify_caps_exec.c +3 -2
@@ -182,9 +182,10 @@ int fork_drop_and_exec(int keepperms, cap_t expected_caps)tst_resm (TINFO ,"got a bad seqno (c=%d, s=%d, seqno=%d)" , c, s, seqno); } - p =index (buf,'.' )+1 ; -if (p==(char *)1 ) + p =index (buf,'.' ); +if (!p)tst_brkm (TFAIL , tst_exit,"got a bad message from print_caps\n" ); + p +=1 ; actual_caps =cap_from_text (p);if (cap_compare (actual_caps, expected_caps) !=0 ) { capstxt =cap_to_text (expected_caps,NULL );
Signature · 8 lines
1.6.0.6 ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 57 lines · Serge E. Hallyn
Quoted 1 line · Garrett Cooper
Quoted 1 line
p = index(buf, '.')+1;Jinkeys! The intertubes archives insist I wrote that, but I'm finding it hard to believe.
Quoted 12 lines
Review
Quoted 6 lines
(quoted diff) +2
-4- if (p==(char *)1) { - tst_resm(TFAIL, "got a bad message from print_caps\n"); - tst_exit(); - } + if (p==(char *)1) + tst_brkm(TFAIL, tst_exit, "got a bad message from print_caps\n");This is a really incorrect way to do things. I think that the
assumption made was that index(3) would return 0 ('\0') if it fails to find '.'. That's incorrect and would cause a segfault on some systems (does on FreeBSD at least... don't see why it would pass on Linux):Quoted 10 lines
$ ~/test_null_inc Segmentation fault: 11 (core dumped) [garrcoop@bioshock ~]$ cat ~/test_null_inc.c #include <stdio.h> int main(void) { printf("%s\n", (NULL + 1)); return 0; }Well, that's different - you're dereferencing NULL+1, whereas I'm just checking the the value of the pointer.
Still what I did is darned ugly, cleanup below.
thanks,
-sergeQuoted 3 lines
Could you please change this to check and see whether or not index
returns NULL instead of accessing memory like that?
Other than that, patch looks good.From: Serge E. Hallyn <[email protected]>
Date: Wed, 5 May 2010 02:59:05 -0500
Subject: [PATCH 1/1] check for index(3) returning NULLSigned-off-by Serge E. Hallyn <[email protected]>---
.../kernel/security/filecaps/verify_caps_exec.c| 5 +++--1 files changed, 3 insertions(+), 2 deletions(-)testcases/kernel/security/filecaps/verify_caps_exec.c +0
-0@@ -182,9 +182,10 @@ int fork_drop_and_exec(int keepperms, cap_t expected_caps)tst_resm (TINFO ,"got a bad seqno (c=%d, s=%d, seqno=%d)" , c, s, seqno);
testcases/kernel/security/filecaps/verify_caps_exec.c int fork_drop_and_exec(int keepperms, cap_t expected_caps) · line 191
Quoted 10 lines
testcases/kernel/security/filecaps/verify_caps_exec.c +3
-2} - p =index (buf,'.' )+1 ; -if (p==(char *)1 ) + p =index (buf,'.' ); +if (!p)tst_brkm (TFAIL , tst_exit,"got a bad message from print_caps\n" ); + p +=1 ; actual_caps =cap_from_text (p);if (cap_compare (actual_caps, expected_caps) !=0 ) { capstxt =cap_to_text (expected_caps,NULL );
Looks good! If that's the complete diff, then Acked-by: Garrett Cooper <[email protected]>
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 63 lines · Garrett Cooper
Quoted 61 lines · Serge E. Hallyn
Quoted 1 line · Garrett Cooper
Quoted 1 line
p = index(buf, '.')+1;Jinkeys! The intertubes archives insist I wrote that, but I'm finding it hard to believe.
Quoted 12 lines
Review
Quoted 6 lines
(quoted diff) +2
-4- if (p==(char *)1) { - tst_resm(TFAIL, "got a bad message from print_caps\n"); - tst_exit(); - } + if (p==(char *)1) + tst_brkm(TFAIL, tst_exit, "got a bad message from print_caps\n");This is a really incorrect way to do things. I think that the
assumption made was that index(3) would return 0 ('\0') if it fails to find '.'. That's incorrect and would cause a segfault on some systems (does on FreeBSD at least... don't see why it would pass on Linux):Quoted 10 lines
$ ~/test_null_inc Segmentation fault: 11 (core dumped) [garrcoop@bioshock ~]$ cat ~/test_null_inc.c #include <stdio.h> int main(void) { printf("%s\n", (NULL + 1)); return 0; }Well, that's different - you're dereferencing NULL+1, whereas I'm just checking the the value of the pointer.
Still what I did is darned ugly, cleanup below.
thanks,
-sergeQuoted 3 lines
Could you please change this to check and see whether or not index
returns NULL instead of accessing memory like that?
Other than that, patch looks good.From: Serge E. Hallyn <[email protected]>
Date: Wed, 5 May 2010 02:59:05 -0500
Subject: [PATCH 1/1] check for index(3) returning NULLSigned-off-by Serge E. Hallyn <[email protected]>---
.../kernel/security/filecaps/verify_caps_exec.c| 5 +++--1 files changed, 3 insertions(+), 2 deletions(-)testcases/kernel/security/filecaps/verify_caps_exec.c +1
-2@@ -182,9 +182,10 @@ int fork_drop_and_exec(int keepperms, cap_t expected_caps)tst_resm (TINFO ,"got a bad seqno (c=%d, s=%d, seqno=%d)" , c, s, seqno); } - p =index (buf,'.' )+1 ; -if (p==(char *)1 ) + p =index (buf,'.' );
Quoted 8 lines
testcases/kernel/security/filecaps/verify_caps_exec.c int fork_drop_and_exec(int keepperms, cap_t expected_caps) · line 191
Quoted 6 lines
testcases/kernel/security/filecaps/verify_caps_exec.c +2
-0+if (!p)tst_brkm (TFAIL , tst_exit,"got a bad message from print_caps\n" ); + p +=1 ; actual_caps =cap_from_text (p);if (cap_compare (actual_caps, expected_caps) !=0 ) { capstxt =cap_to_text (expected_caps,NULL );Looks good! If that's the complete diff, then Acked-by: Garrett Cooper <[email protected]>
Right - that one on top of the previous longer one, please. (or I can rebase-squash them and resend if Subrata prefers)
-serge
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 73 lines · Serge E. Hallyn
Quoted 63 lines · Garrett Cooper
Quoted 61 lines · Serge E. Hallyn
Quoted 1 line · Garrett Cooper
Quoted 1 line
p = index(buf, '.')+1;Jinkeys! The intertubes archives insist I wrote that, but I'm finding it hard to believe.
Quoted 12 lines
Review
Quoted 6 lines
(quoted diff) +2
-4- if (p==(char *)1) { - tst_resm(TFAIL, "got a bad message from print_caps\n"); - tst_exit(); - } + if (p==(char *)1) + tst_brkm(TFAIL, tst_exit, "got a bad message from print_caps\n");This is a really incorrect way to do things. I think that the
assumption made was that index(3) would return 0 ('\0') if it fails to find '.'. That's incorrect and would cause a segfault on some systems (does on FreeBSD at least... don't see why it would pass on Linux):Quoted 10 lines
$ ~/test_null_inc Segmentation fault: 11 (core dumped) [garrcoop@bioshock ~]$ cat ~/test_null_inc.c #include <stdio.h> int main(void) { printf("%s\n", (NULL + 1)); return 0; }Well, that's different - you're dereferencing NULL+1, whereas I'm just checking the the value of the pointer.
Still what I did is darned ugly, cleanup below.
thanks,
-sergeQuoted 3 lines
Could you please change this to check and see whether or not index
returns NULL instead of accessing memory like that?
Other than that, patch looks good.From: Serge E. Hallyn <[email protected]>
Date: Wed, 5 May 2010 02:59:05 -0500
Subject: [PATCH 1/1] check for index(3) returning NULLSigned-off-by Serge E. Hallyn <[email protected]>---
.../kernel/security/filecaps/verify_caps_exec.c| 5 +++--1 files changed, 3 insertions(+), 2 deletions(-)testcases/kernel/security/filecaps/verify_caps_exec.c +1
-2@@ -182,9 +182,10 @@ int fork_drop_and_exec(int keepperms, cap_t expected_caps)tst_resm (TINFO ,"got a bad seqno (c=%d, s=%d, seqno=%d)" , c, s, seqno); } - p =index (buf,'.' )+1 ; -if (p==(char *)1 ) + p =index (buf,'.' );Quoted 8 lines
testcases/kernel/security/filecaps/verify_caps_exec.c int fork_drop_and_exec(int keepperms, cap_t expected_caps) · line 191
Quoted 6 lines
testcases/kernel/security/filecaps/verify_caps_exec.c +2
-0+if (!p)tst_brkm (TFAIL , tst_exit,"got a bad message from print_caps\n" ); + p +=1 ; actual_caps =cap_from_text (p);if (cap_compare (actual_caps, expected_caps) !=0 ) { capstxt =cap_to_text (expected_caps,NULL );Looks good! If that's the complete diff, then Acked-by: Garrett Cooper <[email protected]>
Quoted 2 lines
Right - that one on top of the previous longer one, please. (or I can rebase-squash them and resend if Subrata prefers)
A resend will be great.
Regards--
Subrata
Quoted 2 lines
-serge
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list