* [LTP] [PATCH] sigwaitinfo01: recent glibc calls syscall directly
@ 2018-09-12 8:09 Jan Stancek
2018-10-15 7:17 ` Xiao Yang
0 siblings, 1 reply; 3+ messages in thread
From: Jan Stancek @ 2018-09-12 8:09 UTC (permalink / raw)
To: ltp
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.
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
.../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c | 29 +++++++++++++++++++---
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
index 95a9436a44c9..02730364db4d 100644
--- a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
+++ b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
@@ -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)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* [LTP] [PATCH] sigwaitinfo01: recent glibc calls syscall directly
2018-09-12 8:09 [LTP] [PATCH] sigwaitinfo01: recent glibc calls syscall directly Jan Stancek
@ 2018-10-15 7:17 ` Xiao Yang
2018-10-15 7:34 ` Jan Stancek
0 siblings, 1 reply; 3+ messages in thread
From: Xiao Yang @ 2018-10-15 7:17 UTC (permalink / raw)
To: ltp
On 2018/09/12 16:09, Jan Stancek wrote:
> 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.
>
> Signed-off-by: Jan Stancek<jstancek@redhat.com>
> ---
> .../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c | 29 +++++++++++++++++++---
> 1 file changed, 25 insertions(+), 4 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
> index 95a9436a44c9..02730364db4d 100644
> --- a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
> +++ b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
> @@ -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);
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
> + _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)
^ permalink raw reply [flat|nested] 3+ messages in thread* [LTP] [PATCH] sigwaitinfo01: recent glibc calls syscall directly
2018-10-15 7:17 ` Xiao Yang
@ 2018-10-15 7:34 ` Jan Stancek
0 siblings, 0 replies; 3+ messages in thread
From: Jan Stancek @ 2018-10-15 7:34 UTC (permalink / raw)
To: ltp
----- Original Message -----
> On 2018/09/12 16:09, Jan Stancek wrote:
> > 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.
> >
> > Signed-off-by: Jan Stancek<jstancek@redhat.com>
> > ---
> > .../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c | 29
> > +++++++++++++++++++---
> > 1 file changed, 25 insertions(+), 4 deletions(-)
> >
> > diff --git a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
> > b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
> > index 95a9436a44c9..02730364db4d 100644
> > --- a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
> > +++ b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
> > @@ -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);
> Hi Jan,
>
> Perhaps, just use tst_resm(TINFO | TTERRNO, "swi_func returned: %ld",
> TEST_RETURN);
Right, pushed with change above.
Regards,
Jan
>
> Other than that this patch looks good to me, and it works well on glibc
> v2.28.
>
> Thanks,
> Xiao Yang
>
> > + _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)
>
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-10-15 7:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-12 8:09 [LTP] [PATCH] sigwaitinfo01: recent glibc calls syscall directly Jan Stancek
2018-10-15 7:17 ` Xiao Yang
2018-10-15 7:34 ` Jan Stancek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.