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

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

 



On Tue, Jun 11, 2024 at 01:26:50PM +0530, Dev Jain wrote:

> + * A signal is said to be delivered, when the program takes action on the
> + * signal: such action may involve termination of the process, ignoring the
> + * signal, terminating with core dump, stopping the process, or continuing the
> + * process if it was currently stopped. A signal is said to be blocked when the
> + * program refuses to take any of the above actions; note that, this is not the
> + * same as ignoring the signal. At a later time, the program may unblock the
> + * signal and then it will have to take one of the five actions
> + * described above.

I'm not sure that's what my understanding of a blocked signal is, I
would interpret "blocked" as a signal being masked (this usage can be
seen in for example sigaction(2)).  I'd also interpret delivery of the
signal as happening when the signal handler is invoked rather than
something that the handler has control over (the comment later on says
that so I think it's just an issue here).  Perhaps I'm confused about
terminology though, this is just usage I've picked up and ICBW.

> + * For standard signals (also see real-time signals in the man page), multiple
> + * blocked instances of the same signal are not queued; such a signal will
> + * be delivered just once.

See also SA_NODEFER.

> +	/* SEGV has been blocked in sa_mask, but ucontext is invariant */
> +	ret = sigismember(&(((ucontext_t *)uc)->uc_sigmask), SIGSEGV);
> +	ksft_test_result(ret == 0, "SEGV not blocked in ucontext\n");
> +
> +	/* USR1 has been blocked, but ucontext is invariant */
> +	ret = sigismember(&(((ucontext_t *)uc)->uc_sigmask), SIGUSR1);
> +	ksft_test_result(ret == 0, "USR1 not blocked in ucontext\n");

We're not manipulating the masks outside of main() so it's a bit unclear
what the mention of ucontext being invariant is all about here?

> +	/* Mangled ucontext implies USR2 is blocked for current thread */
> +	if (raise(SIGUSR2))
> +		ksft_exit_fail_perror("raise");
> +
> +	ksft_print_msg("USR2 bypassed successfully\n");
> +
> +	act.sa_sigaction = &handler_verify_ucontext;
> +	if (sigaction(SIGUSR1, &act, NULL))
> +		ksft_exit_fail_perror("Cannot install handler");
> +
> +	if (raise(SIGUSR1))
> +		ksft_exit_fail_perror("raise");
> +
> +	ksft_print_msg("USR2 still blocked on return from handler\n");

But we just raised SIGUSR1 rather than SIGUSR2?  If nothing else this
bit is a little unclear.

Attachment: signature.asc
Description: PGP signature


[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