public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@suse.de>
To: "Chang S. Bae" <chang.seok.bae@intel.com>
Cc: tglx@linutronix.de, mingo@kernel.org, luto@kernel.org,
	x86@kernel.org, len.brown@intel.com, dave.hansen@intel.com,
	hjl.tools@gmail.com, Dave.Martin@arm.com, jannh@google.com,
	mpe@ellerman.id.au, tony.luck@intel.com,
	ravi.v.shankar@intel.com, libc-alpha@sourceware.org,
	linux-arch@vger.kernel.org, linux-api@vger.kernel.org,
	linux-kernel@vger.kernel.org, Borislav Petkov <bp@alien8.de>,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v3 4/4] selftest/x86/signal: Include test cases for validating sigaltstack
Date: Fri, 8 Jan 2021 19:07:23 +0100	[thread overview]
Message-ID: <20210108180716.GA12995@zn.tnic> (raw)
In-Reply-To: <20201223015312.4882-5-chang.seok.bae@intel.com>

On Tue, Dec 22, 2020 at 05:53:12PM -0800, Chang S. Bae wrote:
> +static int setup_altstack(void *start, unsigned long size)
> +{
> +	stack_t ss;
> +
> +	memset(&ss, 0, sizeof(ss));
> +	ss.ss_size = size;
> +	ss.ss_sp = start;
> +
> +	return sigaltstack(&ss, NULL);
> +}
> +
> +static jmp_buf jmpbuf;
> +
> +static void sigsegv(int sig, siginfo_t *info, void *ctx_void)
> +{
> +	if (sigalrm_expected) {
> +		printf("[FAIL]\tSIGSEGV signal delivery is wrong.\n");

			 	"Wrong signal delivered: SIGSEGV (expected SIGALRM)."

> +		nerrs++;
> +	} else {
> +		printf("[OK]\tSIGSEGV signal is delivered.\n");

					s/is //

> +	}
> +
> +	siglongjmp(jmpbuf, 1);
> +}
> +
> +static void sigalrm(int sig, siginfo_t *info, void *ctx_void)
> +{
> +	if (!sigalrm_expected) {
> +		printf("[FAIL]\tSIGALRM sigal delivery is wrong.\n");

See above.

> +		nerrs++;
> +	} else {
> +		printf("[OK]\tSIGALRM signal is delivered.\n");

Ditto.

> +	}
> +}
> +
> +static void test_sigaltstack(void *altstack, unsigned long size)
> +{
> +	if (setup_altstack(altstack, size))
> +		err(1, "sigaltstack()");
> +
> +	sigalrm_expected = (size > at_minstack_size) ? true : false;
> +
> +	sethandler(SIGSEGV, sigsegv, 0);
> +	sethandler(SIGALRM, sigalrm, SA_ONSTACK);
> +
> +	if (sigsetjmp(jmpbuf, 1) == 0) {

	if (!sigsetjmp...)

> +		printf("[RUN]\tTest an (%s) alternate signal stack\n",

			"Test an alternate signal stack of %ssufficient size.\n"

> +		       sigalrm_expected ? "enough" : "too-small");

					 "" : "in");

> +		printf("\tRaise SIGALRM. %s is expected to be delivered.\n",
> +		       sigalrm_expected ? "It" : "But SIGSEGV");

					"It" : "SIGSEGV"

Drop "But".

Ask if something's not clear.

-- 
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg

      reply	other threads:[~2021-01-08 18:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-23  1:53 [PATCH v3 0/4] x86: Improve Minimum Alternate Stack Size Chang S. Bae
2020-12-23  1:53 ` [PATCH v3 1/4] x86/signal: Introduce helpers to get the maximum signal frame size Chang S. Bae
2020-12-23  1:53 ` [PATCH v3 2/4] x86/elf: Support a new ELF aux vector AT_MINSIGSTKSZ Chang S. Bae
2020-12-23  1:53 ` [PATCH v3 3/4] x86/signal: Prevent an alternate stack overflow before a signal delivery Chang S. Bae
2020-12-23  6:55   ` Jann Horn
2021-01-08 18:09   ` Borislav Petkov
2020-12-23  1:53 ` [PATCH v3 4/4] selftest/x86/signal: Include test cases for validating sigaltstack Chang S. Bae
2021-01-08 18:07   ` Borislav Petkov [this message]

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=20210108180716.GA12995@zn.tnic \
    --to=bp@suse.de \
    --cc=Dave.Martin@arm.com \
    --cc=bp@alien8.de \
    --cc=chang.seok.bae@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=hjl.tools@gmail.com \
    --cc=jannh@google.com \
    --cc=len.brown@intel.com \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=ravi.v.shankar@intel.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    /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