linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: pcc@google.com, mtk.manpages@gmail.com
Cc: Dave.Martin@arm.com, James.Bottomley@hansenpartnership.com,
	andreyknvl@google.com, catalin.marinas@arm.com,
	david.spickett@linaro.org, deller@gmx.de, ebiederm@xmission.com,
	eugenis@google.com, kcc@google.com, kevin.brodsky@arm.com,
	linux-api@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-man@vger.kernel.org, oleg@redhat.com,
	vincenzo.frascino@arm.com, will@kernel.org,
	Alejandro Colomar <alx.manpages@gmail.com>
Subject: [PATCH] sigaction.2: Document SA_EXPOSE_TAGBITS and the flag support detection protocol
Date: Sat, 14 Nov 2020 22:49:15 +0100	[thread overview]
Message-ID: <20201114214914.177815-1-colomar.6.4.3@gmail.com> (raw)
In-Reply-To: <20201114014132.2439310-1-pcc@google.com>

From: Peter Collingbourne <pcc@google.com>

Signed-off-by: Peter Collingbourne <pcc@google.com>
[alx: srcfix + ffix]
Cowritten-by: Alejandro Colomar <alx.manpages@gmail.com>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---

Hi Michael,

as Peter noted, this patch is not ready
(code hasn't been merged into the kernel yet).

And a spin-off question:
How would you prefer it?:
[
.B SA_*
] (there are 79 similar cases in the pages [1])
or
[
.BR SA_ *
] (there are 3 similar cases in the pages [2])


Hi Peter,

I improved a few minor things in your patch:

- Use semantic newlines (see man-pages(7)).
- Change explicit blank lines to [.PP]
  (see 'Formatting conventions(general)' in man-pages(7)).
- Use Oxford comma.


Thanks,

Alex


[1](grep -r "_\*" man? | wc -l)
[2](grep -r "_ \*" man? | wc -l)

 man2/sigaction.2 | 65 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/man2/sigaction.2 b/man2/sigaction.2
index 22da658d0..91c46f3e3 100644
--- a/man2/sigaction.2
+++ b/man2/sigaction.2
@@ -251,6 +251,19 @@ This flag is meaningful only when establishing a signal handler.
 .\" .I sa_sigaction
 .\" field was added in Linux 2.1.86.)
 .\"
+.TP
+.BR SA_UNSUPPORTED " (since Linux 5.??)"
+This flag bit will never be supported by the kernel.
+It is used as part of the flag support detection protocol described below.
+.TP
+.BR SA_EXPOSE_TAGBITS " (since Linux 5.??)"
+Normally, when delivering a signal,
+an architecture-specific set of tag bits are cleared from the
+.I si_addr
+field of
+.IR siginfo_t .
+If this flag is set, the tag bits will be preserved in
+.IR si_addr .
 .SS The siginfo_t argument to a SA_SIGINFO handler
 When the
 .B SA_SIGINFO
@@ -834,6 +847,58 @@ Triggered by a
 .BR seccomp (2)
 filter rule.
 .RE
+.SS Detecting flag support in sa_flags
+The Linux kernel supports a mechanism for programs to
+detect kernel support for
+.B SA_*
+flags in
+.IR sa_flags .
+This mechanism is quite subtle for backwards compatibility reasons
+related to the historical behavior of the kernel.
+.PP
+Starting with Linux 5.??,
+the kernel will clear any unrecognized bits from the
+.I sa_flags
+value returned via
+.I oldact
+if those bits were set when the signal handler was originally installed.
+Therefore, a program that only needs to be compatible with
+Linux 5.?? and above
+may test for flag bit support by issuing a second call to
+.BR sigaction ()
+and testing whether the bit remains set in
+.IR oldact.sa_flags .
+.PP
+Prior to Linux 5.x, unrecognized flag bits were preserved in
+.I oldact.sa_flags
+so this protocol on its own would not be sufficient to allow a
+userspace program to test for flag bit support
+if it needs to be compatible with kernel versions older than 5.??.
+Therefore, the
+.B SA_UNSUPPORTED
+flag bit was defined,
+which the kernel will always consider to be unknown.
+A userspace program that sets this flag bit in
+.I act.sa_flags
+and finds that it has been cleared in
+.I oldact.sa_flags
+in a subsequent call to
+.BR sigaction ()
+may trust that any other unknown flag bits have been cleared.
+.PP
+A reasonably modern program may trust that the flags
+.BR SA_NOCLDSTOP ,
+.BR SA_NOCLDWAIT ,
+.BR SA_SIGINFO ,
+.BR SA_ONSTACK ,
+.BR SA_RESTART ,
+.BR SA_NODEFER ,
+.BR SA_RESETHAND ,
+and, if defined by the architecture,
+.B SA_RESTORER
+are supported by the kernel,
+without relying on the flag bit support detection protocol,
+since these flags have all been supported since Linux 2.6.
 .SH RETURN VALUE
 .BR sigaction ()
 returns 0 on success; on error, \-1 is returned, and
-- 
2.28.0


  reply	other threads:[~2020-11-14 22:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-14  1:41 [PATCH] sigaction.2: Document SA_EXPOSE_TAGBITS and the flag support detection protocol Peter Collingbourne
2020-11-14 21:49 ` Alejandro Colomar [this message]
2020-11-15  9:51   ` Michael Kerrisk (man-pages)
2020-11-16 12:57 ` Dave Martin
2020-11-17 23:52   ` Peter Collingbourne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201114214914.177815-1-colomar.6.4.3@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=Dave.Martin@arm.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=andreyknvl@google.com \
    --cc=catalin.marinas@arm.com \
    --cc=david.spickett@linaro.org \
    --cc=deller@gmx.de \
    --cc=ebiederm@xmission.com \
    --cc=eugenis@google.com \
    --cc=kcc@google.com \
    --cc=kevin.brodsky@arm.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=oleg@redhat.com \
    --cc=pcc@google.com \
    --cc=vincenzo.frascino@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).