All of lore.kernel.org
 help / color / mirror / Atom feed
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] recvmmsg01: Workaround segfault on libc variant on 32 bit
Date: Mon, 11 Nov 2024 03:30:45 -0500	[thread overview]
Message-ID: <ZzHAtb2Zqc7Ffpzi@wegao> (raw)
In-Reply-To: <20241108122139.87974-1-pvorel@suse.cz>

On Fri, Nov 08, 2024 at 01:21:39PM +0100, Petr Vorel wrote:
> EFAULT test segfaults on newer kernels (e.g. 6.4) on libc variant on
> 32bit.  Use typical LTP workaround to test by forked child + checking
> the terminating signal.
> 
> NOTE: testing kernel variants could be done without forking child, but
> use it as well for simplicity.
> 
> Suggested-by: Cyril Hrubis <chrubis@suse.cz>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> NOTE: working on other 3 tests affected by the same problem
> (mq_timedreceive01.c, mq_timedsend01.c,  sigtimedwait01.c).
> 
>  .../kernel/syscalls/recvmmsg/recvmmsg01.c     | 48 +++++++++++++++----
>  1 file changed, 40 insertions(+), 8 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/recvmmsg/recvmmsg01.c b/testcases/kernel/syscalls/recvmmsg/recvmmsg01.c
> index fb21ea1e70..46658b133d 100644
> --- a/testcases/kernel/syscalls/recvmmsg/recvmmsg01.c
> +++ b/testcases/kernel/syscalls/recvmmsg/recvmmsg01.c
> @@ -47,7 +47,7 @@ static struct test_case tcase[] = {
>  		.desc = "bad message vector address",
>  		.fd = &receive_sockfd,
>  		.exp_errno = EFAULT,
> -		.msg_vec = (void*)&bad_addr,
> +		.msg_vec = (void *)&bad_addr,
>  	},
>  	{
>  		.desc = "negative seconds in timeout",
> @@ -74,23 +74,54 @@ static struct test_case tcase[] = {
>  	}
>  };
>  
> -static void do_test(unsigned int i)
> +static void verify_recvmmsg(unsigned int i, void *timeout)
>  {
>  	struct time64_variants *tv = &variants[tst_variant];
>  	struct test_case *tc = &tcase[i];
> -	void *timeout;
>  
>  	ts.type = tv->ts_type;
>  	tst_ts_set_sec(&ts, tc->tv_sec);
>  	tst_ts_set_nsec(&ts, tc->tv_nsec);
>  
> +	TST_EXP_FAIL2(tv->recvmmsg(*tc->fd, *tc->msg_vec, VLEN, 0, timeout),
> +		      tc->exp_errno, "recvmmsg() %s", tc->desc);
> +}
> +
> +static void test_bad_addr(unsigned int i)
> +{
> +	struct time64_variants *tv = &variants[tst_variant];
> +	void *timeout = bad_addr;
> +	pid_t pid;
> +	int status;
> +
> +	pid = SAFE_FORK();
> +	if (!pid) {
> +		verify_recvmmsg(i, timeout);
> +		_exit(!TST_PASS);
> +	}
> +
> +	SAFE_WAITPID(pid, &status, 0);
> +
> +	if (WIFEXITED(status))
> +		return;
> +
> +	if (tv->ts_type == TST_LIBC_TIMESPEC &&
> +		WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {
> +		tst_res(TPASS, "Child killed by signal");
very nit: 
1) s/Child killed by signal/Child killed by SIGSEGV signal/
2) suggest also print out tc->desc

Thanks for create patch fix our current issue.
Reviewed-by: Wei Gao <wegao@suse.com>
> +		return;
> +	}
> +
> +	tst_res(TFAIL, "Child %s", tst_strstatus(status));
> +}
> +
> +static void do_test(unsigned int i)
> +{
> +	struct test_case *tc = &tcase[i];
> +
>  	if (tc->bad_ts_addr)
> -		timeout = bad_addr;
> +		test_bad_addr(i);
>  	else
> -		timeout = tst_ts_get(&ts);
> -
> -	TST_EXP_FAIL2(tv->recvmmsg(*tc->fd, *tc->msg_vec, VLEN, 0, timeout),
> -	             tc->exp_errno, "recvmmsg() %s", tc->desc);
> +		verify_recvmmsg(i, tst_ts_get(&ts));
>  }
>  
>  static void setup(void)
> @@ -139,6 +170,7 @@ static struct tst_test test = {
>  	.setup = setup,
>  	.cleanup = cleanup,
>  	.test_variants = ARRAY_SIZE(variants),
> +	.forks_child = 1,
>  	.bufs = (struct tst_buffers []) {
>  		{&iov, .iov_sizes = (int[]){1, -1}},
>  		{&msg, .size = VLEN * sizeof(*msg)},
> -- 
> 2.45.2
> 

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2024-11-11  8:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-08 12:21 [LTP] [PATCH 1/1] recvmmsg01: Workaround segfault on libc variant on 32 bit Petr Vorel
2024-11-11  8:30 ` Wei Gao via ltp [this message]
2024-11-11  9:58   ` Petr Vorel
2024-11-11 10:37 ` Cyril Hrubis
2024-11-11 14:24   ` Petr Vorel
2024-11-25 21:32   ` 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=ZzHAtb2Zqc7Ffpzi@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.