sigwaitinfo01: recent glibc calls syscall directly
PATCH 1/1 sigwaitinfo01: recent glibc calls syscall directly
glibc commit
8b0e795aaa44 ("Simplify Linux sig{timed}wait{info} implementations")
changed sigwaitinfo to call sigtimedwait, which calls rt_sigtimedwait syscall directly.
So, an invalid pointer no longer crashes child process and test reports failure. Fix it by accepting either crash or EFAULT.
--- .../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c | 29 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c +25 -4
@@ -371,19 +371,40 @@ void test_bad_address2(swi_func sigwaitinfo, int signo)tst_brkm (TBROK |TERRNO ,NULL ,"fork() failed" );case 0 :signal (SIGSEGV ,SIG_DFL ); + +/* +* depending on glibc implementation we should +* either crash or get EFAULT +*/ TEST (sigwaitinfo ((void *)1 ,NULL ,NULL )); -_exit (0 ); +if (TEST_RETURN ==-1 &&TEST_ERRNO ==EFAULT ) +_exit (0 ); + +tst_resm (TINFO ,"swi_func returned: %ld, errno: %d" , +TEST_RETURN ,TEST_ERRNO ); +_exit (1 );break ;default :break ; }SUCCEED_OR_DIE (waitpid,"waitpid failed" , pid, &status,0 ); -if (WIFSIGNALED (status) &&WTERMSIG (status) ==SIGSEGV ) + +if ((WIFSIGNALED (status) &&WTERMSIG (status) ==SIGSEGV ) + || (WIFEXITED (status) &&WEXITSTATUS (status) ==0 )) {tst_resm (TPASS ,"Test passed" ); -else -tst_resm (TFAIL ,"Unrecognised child exit code" ); +return ; + } + +if (WIFEXITED (status)) { +tst_resm (TFAIL ,"Unrecognised child exit code: %d" , +WEXITSTATUS (status)); + } +if (WIFSIGNALED (status)) { +tst_resm (TFAIL ,"Unrecognised child termsig: %d" , +WTERMSIG (status)); + } }void test_bad_address3 (swi_func sigwaitinfo,int signo)
Signature · 1 line
1.8.3.1
PATCH 1/1 sigwaitinfo01: recent glibc calls syscall directly
Quoted 24 lines · Jan Stancek
glibc commit
8b0e795aaa44("Simplify Linux sig{timed}wait{info} implementations")
changed sigwaitinfo to call sigtimedwait, which callsrt_sigtimedwaitsyscall directly.So, an invalid pointer no longer crashes child process and test reports failure. Fix it by accepting either crash or EFAULT.
Signed-off-by Jan Stancek<[email protected]>--- .../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c | 29 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-)testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c +3
-0@@ -371,19 +371,40 @@ void test_bad_address2(swi_func sigwaitinfo, int signo)tst_brkm (TBROK |TERRNO ,NULL ,"fork() failed" );case 0 :signal (SIGSEGV ,SIG_DFL ); + +/* +* depending on glibc implementation we should
testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c void test_bad_address2(swi_func sigwaitinfo, int signo) · line 385
Quoted 10 lines
testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c +7
-1+* either crash or get EFAULT +*/ TEST (sigwaitinfo ((void *)1 ,NULL ,NULL )); -_exit (0 ); +if (TEST_RETURN ==-1 &&TEST_ERRNO ==EFAULT ) +_exit (0 ); + +tst_resm (TINFO ,"swi_func returned: %ld, errno: %d" , +TEST_RETURN ,TEST_ERRNO );
Hi Jan,
Perhaps, just use tst_resm(TINFO | TTERRNO, "swi_func returned: %ld", TEST_RETURN);
Other than that this patch looks good to me, and it works well on glibc v2.28.
Thanks,
Xiao Yang
Quoted 28 lines
testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c +15
-3+_exit (1 );break ;default :break ; }SUCCEED_OR_DIE (waitpid,"waitpid failed" , pid,&status,0 ); -if (WIFSIGNALED (status)&&WTERMSIG (status) ==SIGSEGV ) + +if ((WIFSIGNALED (status)&&WTERMSIG (status) ==SIGSEGV ) + || (WIFEXITED (status)&&WEXITSTATUS (status) ==0 )) {tst_resm (TPASS ,"Test passed" ); -else -tst_resm (TFAIL ,"Unrecognised child exit code" ); +return ; + } + +if (WIFEXITED (status)) { +tst_resm (TFAIL ,"Unrecognised child exit code: %d" , +WEXITSTATUS (status)); + } +if (WIFSIGNALED (status)) { +tst_resm (TFAIL ,"Unrecognised child termsig: %d" , +WTERMSIG (status)); + } }void test_bad_address3 (swi_func sigwaitinfo,int signo)
PATCH 1/1 sigwaitinfo01: recent glibc calls syscall directly
----- Original Message -----
Quoted 40 lines · Jan Stancek
Quoted 27 lines
glibc commit
8b0e795aaa44("Simplify Linux sig{timed}wait{info} implementations")
changed sigwaitinfo to call sigtimedwait, which callsrt_sigtimedwaitsyscall directly.So, an invalid pointer no longer crashes child process and test reports failure. Fix it by accepting either crash or EFAULT.
Signed-off-by Jan Stancek<[email protected]>--- .../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c | 29 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-)testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c +3
-0@@ -371,19 +371,40 @@ void test_bad_address2(swi_func sigwaitinfo, int signo) tst_brkm(TBROK | TERRNO, NULL, "fork() failed");case 0 :signal (SIGSEGV ,SIG_DFL ); + +/* +* depending on glibc implementation we should testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c void test_bad_address2(swi_func sigwaitinfo, int · line 386
Quoted 10 lines
testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c +7
-1+* either crash or get EFAULT +*/ TEST (sigwaitinfo ((void *)1 ,NULL ,NULL )); -_exit (0 ); +if (TEST_RETURN ==-1 &&TEST_ERRNO ==EFAULT ) +_exit (0 ); + +tst_resm (TINFO ,"swi_func returned: %ld, errno: %d" , +TEST_RETURN ,TEST_ERRNO );Hi Jan,
Quoted 2 lines
Perhaps, just use
tst_resm(TINFO | TTERRNO, "swi_func returned: %ld", TEST_RETURN);
Right, pushed with change above.
Regards,
Jan
Quoted 39 lines
Other than that this patch looks good to me, and it works well on glibc v2.28.
Thanks,
Xiao YangQuoted 28 lines
testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c +15
-3+_exit (1 );break ;default :break ; }SUCCEED_OR_DIE (waitpid,"waitpid failed" , pid,&status,0 ); -if (WIFSIGNALED (status)&&WTERMSIG (status) ==SIGSEGV ) + +if ((WIFSIGNALED (status)&&WTERMSIG (status) ==SIGSEGV ) + || (WIFEXITED (status)&&WEXITSTATUS (status) ==0 )) {tst_resm (TPASS ,"Test passed" ); -else -tst_resm (TFAIL ,"Unrecognised child exit code" ); +return ; + } + +if (WIFEXITED (status)) { +tst_resm (TFAIL ,"Unrecognised child exit code: %d" , +WEXITSTATUS (status)); + } +if (WIFSIGNALED (status)) { +tst_resm (TFAIL ,"Unrecognised child termsig: %d" , +WTERMSIG (status)); + } }void
test_bad_address3(swi_func sigwaitinfo, int signo)