Re: [PATCH v4 2/2] selftests: Add a test mangling with uc_sigmask

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

 



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.





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux