History

signal: define the SA_UNSUPPORTED bit in sa_flags

Define a sa_flags bit, SA_UNSUPPORTED, which will never be supported in the uapi. The purpose of this flag bit is to allow userspace to distinguish an old kernel that does not clear unknown sa_flags bits from a kernel that supports every flag bit. In other words, if userspace does something like: act.sa_flags |= SA_UNSUPPORTED; sigaction(SIGSEGV, &act, 0); sigaction(SIGSEGV, 0, &oldact); and finds that SA_UNSUPPORTED remains set in oldact.sa_flags, it means that the kernel cannot be trusted to have cleared unknown flag bits from sa_flags, so no assumptions about flag bit support can be made.

Peter Collingbourne committed 5 years ago

Commit a54f0df1 parent 7da50822 files · +13 −0Browse files

Showing the changes to include/uapi (1 of 2 files). Show all

Unified · Split

include/uapi/asm-generic/signal-defs.h+7−0
@@ -14,6 +14,12 @@ · 13 unmodified lines
14 * SA_RESTART flag to get restarting signals (which were the default long ago)14 * SA_RESTART flag to get restarting signals (which were the default long ago)
15 * SA_NODEFER prevents the current signal from being masked in the handler.15 * SA_NODEFER prevents the current signal from being masked in the handler.
16 * SA_RESETHAND clears the handler when the signal is delivered.16 * SA_RESETHAND clears the handler when the signal is delivered.
17 * SA_UNSUPPORTED is a flag bit that will never be supported. Kernels from
18 * before the introduction of SA_UNSUPPORTED did not clear unknown bits from
19 * sa_flags when read using the oldact argument to sigaction and rt_sigaction,
20 * so this bit allows flag bit support to be detected from userspace while
21 * allowing an old kernel to be distinguished from a kernel that supports every
22 * flag bit.
17 *23 *
18 * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single24 * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
19 * Unix names RESETHAND and NODEFER respectively.25 * Unix names RESETHAND and NODEFER respectively.
@@ -34,6 +40,7 @@ · 14 unmodified lines
34/* 0x00000080 used on parisc */40/* 0x00000080 used on parisc */
35/* 0x00000100 used on sparc */41/* 0x00000100 used on sparc */
36/* 0x00000200 used on sparc */42/* 0x00000200 used on sparc */
43#define SA_UNSUPPORTED 0x00000400
37/* 0x00010000 used on mips */44/* 0x00010000 used on mips */
38/* 0x01000000 used on x86 */45/* 0x01000000 used on x86 */
39/* 0x02000000 used on x86 */46/* 0x02000000 used on x86 */