From: Wei Gao via ltp <ltp@lists.linux.it>
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 1/1] ioctl01: Workaround segfault on ppc64le
Date: Fri, 15 Nov 2024 02:50:52 -0500 [thread overview]
Message-ID: <Zzb9XKvIe9D6Mcn3@wegao> (raw)
In-Reply-To: <20241114172911.362197-1-pvorel@suse.cz>
On Thu, Nov 14, 2024 at 06:29:11PM +0100, Petr Vorel wrote:
> Testing termio/termios invalid/NULL address for EFAULT fails on ppc64le.
> Use typical LTP workaround to test by forked child + checking the
> terminating signal (on all archs).
Very nit:
The title is "[PATCH 1/1] ioctl01: Workaround segfault on ppc64le" but
your code is create workaround for all archs, so maybe update some words?
Reviewed-by: Wei Gao <wegao@suse.com>
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> testcases/kernel/syscalls/ioctl/ioctl01.c | 45 ++++++++++++++++++++---
> 1 file changed, 40 insertions(+), 5 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/ioctl/ioctl01.c b/testcases/kernel/syscalls/ioctl/ioctl01.c
> index c84a72b9a2..e4f32330d0 100644
> --- a/testcases/kernel/syscalls/ioctl/ioctl01.c
> +++ b/testcases/kernel/syscalls/ioctl/ioctl01.c
> @@ -2,7 +2,7 @@
> /*
> * Copyright (c) International Business Machines Corp., 2001
> * Copyright (c) 2020 Petr Vorel <petr.vorel@gmail.com>
> - * Copyright (c) Linux Test Project, 2002-2023
> + * Copyright (c) Linux Test Project, 2002-2024
> * 07/2001 Ported by Wayne Boyer
> * 04/2002 Fixes by wjhuie
> */
> @@ -59,8 +59,42 @@ static struct tcase {
>
> static void verify_ioctl(unsigned int i)
> {
> - TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request, tcases[i].s_tio),
> - tcases[i].error, "%s", tcases[i].desc);
> + struct tcase *tc = &tcases[i];
> +
> + TST_EXP_FAIL(ioctl(*(tc->fd), tc->request, tc->s_tio), tc->error, "%s",
> + tc->desc);
> +}
> +
> +static void test_bad_addr(unsigned int i)
> +{
> + pid_t pid;
> + int status;
> +
> + pid = SAFE_FORK();
> + if (!pid) {
> + verify_ioctl(i);
> + _exit(0);
> + }
> +
> + SAFE_WAITPID(pid, &status, 0);
> +
> + if (WIFEXITED(status) && !WEXITSTATUS(status))
> + return;
> +
> + if (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {
> + tst_res(TPASS, "Child killed by expected signal");
> + return;
> + }
> +
> + tst_res(TFAIL, "Child %s", tst_strstatus(status));
> +}
> +
> +static void do_test(unsigned int i)
> +{
> + if (tcases[i].error == EFAULT)
> + test_bad_addr(i);
> + else
> + verify_ioctl(i);
> }
>
> static void setup(void)
> @@ -86,6 +120,7 @@ static struct tst_test test = {
> .needs_tmpdir = 1,
> .setup = setup,
> .cleanup = cleanup,
> - .test = verify_ioctl,
> - .tcnt = ARRAY_SIZE(tcases)
> + .test = do_test,
> + .tcnt = ARRAY_SIZE(tcases),
> + .forks_child = 1,
> };
> --
> 2.45.2
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-11-15 7:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-14 17:29 [LTP] [PATCH 1/1] ioctl01: Workaround segfault on ppc64le Petr Vorel
2024-11-15 7:50 ` Wei Gao via ltp [this message]
2024-11-15 10:37 ` Petr Vorel
2024-11-26 11:59 ` Cyril Hrubis
2024-11-26 13:07 ` Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zzb9XKvIe9D6Mcn3@wegao \
--to=ltp@lists.linux.it \
--cc=pvorel@suse.cz \
--cc=wegao@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.