linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Dev Jain <dev.jain@arm.com>
Cc: shuah@kernel.org, mingo@kernel.org, tglx@linutronix.de,
	mark.rutland@arm.com, ryan.roberts@arm.com, broonie@kernel.org,
	suzuki.poulose@arm.com, Anshuman.Khandual@arm.com,
	DeepakKumar.Mishra@arm.com, aneesh.kumar@kernel.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/2] selftests: Add a test mangling with uc_sigmask
Date: Sun, 30 Jun 2024 17:18:08 +0200	[thread overview]
Message-ID: <20240630151808.GA13321@redhat.com> (raw)
In-Reply-To: <20240627035215.1527279-3-dev.jain@arm.com>

I see nothing wrong, but perhaps this test can be simplified?
Feel free to ignore.

Say,

On 06/27, Dev Jain wrote:
>
> +void handler_usr(int signo, siginfo_t *info, void *uc)
> +{
> +	int ret;
> +
> +	/*
> +	 * Break out of infinite recursion caused by raise(SIGUSR1) invoked
> +	 * from inside the handler
> +	 */
> +	++cnt;
> +	if (cnt > 1)
> +		return;
> +
> +	ksft_print_msg("In handler_usr\n");
> +
> +	/* SEGV blocked during handler execution, delivered on return */
> +	if (raise(SIGSEGV))
> +		ksft_exit_fail_perror("raise");
> +
> +	ksft_print_msg("SEGV bypassed successfully\n");

You could simply do sigprocmask(SIG_SETMASK, NULL, &oldset) and check if
SIGSEGV is blocked in oldset. SIG_SETMASK has no effect if newset == NULL.

Likewise,

> +	/*
> +	 * Mangle ucontext; this will be copied back into &current->blocked
> +	 * on return from the handler.
> +	 */
> +	if (sigaddset(&((ucontext_t *)uc)->uc_sigmask, SIGUSR2))
> +		ksft_exit_fail_perror("sigaddset");
> +}

The caller (main) can do the same rather than raise(SIGUSR2).

But again, I won't insist.

Oleg.


  parent reply	other threads:[~2024-06-30 15:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-27  3:52 [PATCH v4 0/2] Add test to distinguish between thread's signal mask and ucontext_t Dev Jain
2024-06-27  3:52 ` [PATCH v4 1/2] selftests: Rename sigaltstack to generic signal Dev Jain
2024-06-27  3:52 ` [PATCH v4 2/2] selftests: Add a test mangling with uc_sigmask Dev Jain
2024-06-27 16:20   ` Mark Brown
2024-06-30 15:18   ` Oleg Nesterov [this message]
2024-07-15 11:49     ` Dev Jain
2024-07-22 14:58       ` Shuah Khan
2024-07-23  4:30         ` Dev Jain
2024-07-23 15:55           ` Shuah Khan
2024-07-16  9:44 ` [PATCH v4 0/2] Add test to distinguish between thread's signal mask and ucontext_t Dev Jain

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=20240630151808.GA13321@redhat.com \
    --to=oleg@redhat.com \
    --cc=Anshuman.Khandual@arm.com \
    --cc=DeepakKumar.Mishra@arm.com \
    --cc=aneesh.kumar@kernel.org \
    --cc=broonie@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=shuah@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).