Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | From bb977ca0716ae98f10102c7122fe15bc0ddb5356 Mon Sep 17 00:00:00 2001 |
| 2 | From: "Hongzhi.Song" <hongzhi.song@windriver.com> |
| 3 | Date: Thu, 20 Sep 2018 21:49:02 -0400 |
| 4 | Subject: [PATCH] sigwaitinfo01: recent glibc calls syscall directly |
| 5 | |
| 6 | glibc commit |
| 7 | 8b0e795aaa44 ("Simplify Linux sig{timed}wait{info} implementations") |
| 8 | changed sigwaitinfo to call sigtimedwait, which calls rt_sigtimedwait |
| 9 | syscall directly. |
| 10 | |
| 11 | So, an invalid pointer no longer crashes child process and test |
| 12 | reports failure. Fix it by accepting either crash or EFAULT. |
| 13 | |
| 14 | Signed-off-by: Jan Stancek <jstancek@redhat.com> |
| 15 | |
| 16 | Upstream-Status: Submitted [https://lists.linux.it/pipermail/ltp/2018-September/009338.html] |
| 17 | |
| 18 | Signed-off-by: Hongzhi.Song <hongzhi.song@windriver.com> |
| 19 | --- |
| 20 | .../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c | 30 +++++++++++++++++++--- |
| 21 | 1 file changed, 26 insertions(+), 4 deletions(-) |
| 22 | |
| 23 | diff --git a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c |
| 24 | index 95a9436a4..8fa8ac34b 100644 |
| 25 | --- a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c |
| 26 | +++ b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c |
| 27 | @@ -371,19 +371,41 @@ void test_bad_address2(swi_func sigwaitinfo, int signo) |
| 28 | tst_brkm(TBROK | TERRNO, NULL, "fork() failed"); |
| 29 | case 0: |
| 30 | signal(SIGSEGV, SIG_DFL); |
| 31 | + |
| 32 | + /* |
| 33 | + * depending on glibc implementation we should |
| 34 | + * either crash or get EFAULT |
| 35 | + */ |
| 36 | TEST(sigwaitinfo((void *)1, NULL, NULL)); |
| 37 | |
| 38 | - _exit(0); |
| 39 | + if (TEST_RETURN == -1 && TEST_ERRNO == EFAULT) |
| 40 | + _exit(0); |
| 41 | + |
| 42 | + tst_resm(TINFO, "swi_func returned: %ld, errno: %d", |
| 43 | + TEST_RETURN, TEST_ERRNO); |
| 44 | + _exit(1); |
| 45 | + |
| 46 | break; |
| 47 | default: |
| 48 | break; |
| 49 | } |
| 50 | |
| 51 | SUCCEED_OR_DIE(waitpid, "waitpid failed", pid, &status, 0); |
| 52 | - if (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) |
| 53 | + |
| 54 | + if ((WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) |
| 55 | + || (WIFEXITED(status) && WEXITSTATUS(status) == 0)) { |
| 56 | tst_resm(TPASS, "Test passed"); |
| 57 | - else |
| 58 | - tst_resm(TFAIL, "Unrecognised child exit code"); |
| 59 | + return; |
| 60 | + } |
| 61 | + |
| 62 | + if (WIFEXITED(status)) { |
| 63 | + tst_resm(TFAIL, "Unrecognised child exit code: %d", |
| 64 | + WEXITSTATUS(status)); |
| 65 | + } |
| 66 | + if (WIFSIGNALED(status)) { |
| 67 | + tst_resm(TFAIL, "Unrecognised child termsig: %d", |
| 68 | + WTERMSIG(status)); |
| 69 | + } |
| 70 | } |
| 71 | |
| 72 | void test_bad_address3(swi_func sigwaitinfo, int signo) |
| 73 | -- |
| 74 | 2.11.0 |
| 75 | |