Re: [PATCH v3 4/4] selftest/x86/signal: Include test cases for validating sigaltstack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux