kern: add a TDA_PSELECT for early restoration of sigmask

It may be the case that we want to avoid delivering signals that are
normally blocked by the thread's signal mask, in which case the syscall
should schedule this one instead to restore the mask prior to delivery.

This will be used by pselect/ppoll to avoid delivering signals that were
supposed to be blocked after the timeout has elapsed.  The name was
chosen as this is the expected behavior of pselect/ppoll, while late
restoration of the mask is exceptional behavior for these specific
calls.

__FreeBSD_version bump as later TDA_* values have changed, third-party
modules that may be using MOD3/MOD4 need to be rebuilt.

Reviewed by:	kib
Sponsored by:	Klara, Inc.
Sponsored by:	NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D47741
This commit is contained in:
Kyle Evans 2024-11-25 22:04:48 -06:00
parent 5035db222e
commit cab31f5633
3 changed files with 12 additions and 1 deletions

View File

@ -365,6 +365,16 @@ sigqueue_start(void)
SIGFILLSET(fastblock_mask);
SIG_CANTMASK(fastblock_mask);
ast_register(TDA_SIG, ASTR_UNCOND, 0, ast_sig);
/*
* TDA_PSELECT is for the case where the signal mask should be restored
* before delivering any signals so that we do not deliver any that are
* blocked by the normal thread mask. It is mutually exclusive with
* TDA_SIGSUSPEND, which should be used if we *do* want to deliver
* signals that are normally blocked, e.g., if it interrupted our sleep.
*/
ast_register(TDA_PSELECT, ASTR_ASTF_REQUIRED | ASTR_TDP,
TDP_OLDMASK, ast_sigsuspend);
ast_register(TDA_SIGSUSPEND, ASTR_ASTF_REQUIRED | ASTR_TDP,
TDP_OLDMASK, ast_sigsuspend);
}

View File

@ -73,7 +73,7 @@
* cannot include sys/param.h and should only be updated here.
*/
#undef __FreeBSD_version
#define __FreeBSD_version 1500027
#define __FreeBSD_version 1500028
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,

View File

@ -494,6 +494,7 @@ enum {
TDA_RACCT,
TDA_MOD1, /* For third party use, before signals are */
TAD_MOD2, /* processed .. */
TDA_PSELECT, /* For discarding temporary signal mask */
TDA_SIG,
TDA_KTRACE,
TDA_SUSPEND,