All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/2] syscalls/sigsuspend01.c: Convert to the new API
Date: Mon, 17 Aug 2020 16:33:09 +0200	[thread overview]
Message-ID: <20200817143309.GD8445@yuki.lan> (raw)
In-Reply-To: <20200815051312.25002-2-yangx.jy@cn.fujitsu.com>

Hi!
Pushed with a few fixes, thanks.

> +static void setup(void)
>  {
> +	struct sigaction sa_new;
>  
> +	SAFE_SIGEMPTYSET(&signalset);
> +	SAFE_SIGEMPTYSET(&sigset1);
> +	SAFE_SIGADDSET(&sigset1, SIGALRM);
> +
> +	sa_new.sa_handler = sig_handler;
> +	SAFE_SIGACTION(SIGALRM, &sa_new, 0);

Here you were passing random data to the sigaction() function, as the
sa_new was created on a stack and only sa_handler was set.

Which, for instance, breaks the test in a case of the -i 2 option, since
if you were unlucky the SA_RESETHAND was set in the sa_new and the
signal handler was uninstalled after the first signal was handled and
the test process was killed by SIGALRM when the signal arrived for a
second time.

In short there was all kind of mess passed down the call, on strace it
looked as:

[pid 3245] rt_sigaction(SIGALRM, {sa_handler=0x557469b59c20, sa_mask=[HUP INT QUIT ILL ABRT USR1 ALRM TERM CHLD TSTP TTOU URG VTALRM PROF WINCH PWR SYS RT_1 RT_2 RT_3 RT_4 RT_6 RT_10 RT_12 RT_13 RT_14 RT_18 RT_20 RT_21 RT_22], sa_flags=SA_RESTORER|SA_ONSTACK|SA_RESTART|SA_NODEFER|SA_RESETHAND|0xe9e4e8, sa_restorer=0x7f26dc368b40}, NULL, 8) = 0

So I changed it to:

	struct sigaction sa_new = {
		.sa_handler = sig_handler
	};

Which will clears the rest of the structure.

> +	/* Block SIGALRM */
> +	SAFE_SIGPROCMASK(SIG_SETMASK, &sigset1, NULL);
>  }
> +
> +static struct tst_test test = {
> +	.setup = setup,
> +	.test_all = verify_sigsuspend,
> +};

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2020-08-17 14:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-15  5:13 [LTP] [PATCH 1/2] safe_macros: Add SAFE_SIGFILLSET() Xiao Yang
2020-08-15  5:13 ` [LTP] [PATCH 2/2] syscalls/sigsuspend01.c: Convert to the new API Xiao Yang
2020-08-17 14:33   ` Cyril Hrubis [this message]
2020-08-17 15:00     ` Xiao Yang

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=20200817143309.GD8445@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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.