Skip to contentSkip to conversation

prctl.2 man page updates for Linux 5.6

PATCH Applied Dave Martin 9 participants 37 messages May 27, 2020 – Jun 24, 2020 15 messages not in the archive

Subsystems (2)

v2 of 3 Applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover prctl.2 man page updates for Linux 5.6

A bunch of updates to the prctl(2) man page to fill in missing prctls (mostly) up to Linux 5.6 (along with a few other tweaks and fixes).

Patches from the v1 series [1] that have been applied or rejected already have been dropped.

People not Cc'd on the whole series can find the whole series at
https://lore.kernel.org/linux-man/ .

Patches:

* Patch 1 is a new (but trivial) formatting fix, unrelated to the new prctls.

* Patches 2-3 relate to the speculation control prctls. These are unmodified from v1, but need review.

* Patches 4-5 relate to the arm64 prctls from v1, with reviewer feedback incorporated. (See notes in the patches.)

* Patch 6 is *draft* wording for the arm64 address tagging prctls. The semantics of address tagging is particularly slippery, so this needs discussion before merging.

[1] https://lore.kernel.org/linux-man/29a02b16-dd61-6186-1340-fcc7d5225ad0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org/T/#t

Dave Martin (6):
prctl.2: ffix use literal hyphens when referencing kernel docs prctl.2: Add PR_SPEC_INDIRECT_BRANCH for SPECULATION_CTRL prctls prctl.2: Add PR_SPEC_DISABLE_NOEXEC for SPECULATION_CTRL prctls prctl.2: Add SVE prctls (arm64)
prctl.2: Add PR_PAC_RESET_KEYS (arm64)
prctl.2: Add tagged address ABI control prctls (arm64)

 man2/prctl.2 | 444 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 435 insertions(+), 9 deletions(-)
Signature · 1 line
2.1.4

A message that is not in the archive (sent off-list or not yet received): 1590614258-24728-1-git-send-email-Dave.Martin-5wv7dgnIgG8@public.gmane.org

#2 lore raw

PATCH v2 3/6 prctl.2: Add PR_SPEC_DISABLE_NOEXEC for SPECULATION_CTRL prctls

Add the PR_SPEC_DISABLE_NOEXEC mode added in Linux 5.1 for the PR_SPEC_STORE_BYPASS "misfeature" of PR_SET_SPECULATION_CTRL and PR_GET_SPECULATION_CTRL.

Cc Waiman Long <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 man2/prctl.2 | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
man2/prctl.2 +20 -2
index b6fb51c..cab9915 100644
@@ -1187,6 +1187,12 @@ The speculation feature is disabled, mitigation is enabled.
 Same as
 .B PR_SPEC_DISABLE
 but cannot be undone.
+.TP
+.BR PR_SPEC_DISABLE_NOEXEC " (since Linux 5.1)"
+Same as
+.BR PR_SPEC_DISABLE ,
+but but the state will be cleared on
+.BR execve (2).
 .RE
 .IP
 If all bits are 0,
@@ -1251,6 +1257,17 @@ with the same value for
 .I arg2
 will fail with the error
 .BR EPERM .
+.\" commit 71368af9027f18fe5d1c6f372cfdff7e4bde8b48
+.TP
+.BR PR_SPEC_DISABLE_NOEXEC " (since Linux 5.1)"
+Same as
+.BR PR_SPEC_DISABLE ,
+but but the state will be cleared on
+.BR execve (2).
+Currently only supported for
+.I arg2
+equal to
+.B PR_SPEC_STORE_BYPASS.
 .RE
 .IP
 Any unsupported value in
@@ -1899,11 +1916,12 @@ was
 .BR PR_SET_SPECULATION_CTRL
 and
 .IR arg3
-is neither
+is not
 .BR PR_SPEC_ENABLE ,
 .BR PR_SPEC_DISABLE ,
+.BR PR_SPEC_FORCE_DISABLE ,
 nor
-.BR PR_SPEC_FORCE_DISABLE .
+.BR PR_SPEC_DISABLE_NOEXEC .
 .SH VERSIONS
 The
 .BR prctl ()
Signature · 1 line
2.1.4

A message that is not in the archive (sent off-list or not yet received): 1590614258-24728-4-git-send-email-Dave.Martin-5wv7dgnIgG8@public.gmane.org

#4 lore raw

Re: [PATCH v2 3/6] prctl.2: Add PR_SPEC_DISABLE_NOEXEC for SPECULATION_CTRL prctls

Hi Dave,

Quoted 8 lines · Dave Martin

Add the PR_SPEC_DISABLE_NOEXEC mode added in Linux 5.1 for the PR_SPEC_STORE_BYPASS "misfeature" of PR_SET_SPECULATION_CTRL and PR_GET_SPECULATION_CTRL.

Cc Waiman Long <[email protected]>
Cc Thomas Gleixner <[email protected]>

I had already applied your earlier send of this patch (in a private branch). I'll push those changes shortly.

Cheers,

Michael

Quoted 57 lines
---
 man2/prctl.2 | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
man2/prctl.2 +20 -3
index b6fb51c..cab9915 100644
@@ -1187,6 +1187,12 @@ The speculation feature is disabled, mitigation is enabled.
 Same as
 .B PR_SPEC_DISABLE
 but cannot be undone.
+.TP
+.BR PR_SPEC_DISABLE_NOEXEC " (since Linux 5.1)"
+Same as
+.BR PR_SPEC_DISABLE ,
+but but the state will be cleared on
+.BR execve (2).
 .RE
 .IP
 If all bits are 0,
@@ -1251,6 +1257,17 @@ with the same value for
 .I arg2
 will fail with the error
 .BR EPERM .
+.\" commit 71368af9027f18fe5d1c6f372cfdff7e4bde8b48
+.TP
+.BR PR_SPEC_DISABLE_NOEXEC " (since Linux 5.1)"
+Same as
+.BR PR_SPEC_DISABLE ,
+but but the state will be cleared on
+.BR execve (2).
+Currently only supported for
+.I arg2
+equal to
+.B PR_SPEC_STORE_BYPASS.
 .RE
 .IP
 Any unsupported value in
@@ -1899,11 +1916,12 @@ was
 .BR PR_SET_SPECULATION_CTRL
 and
 .IR arg3
-is neither
+is not
 .BR PR_SPEC_ENABLE ,
 .BR PR_SPEC_DISABLE ,
+.BR PR_SPEC_FORCE_DISABLE ,
 nor
-.BR PR_SPEC_FORCE_DISABLE .
+.BR PR_SPEC_DISABLE_NOEXEC .
 .SH VERSIONS
 The
 .BR prctl ()
--

2.1.4

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
Acked-by
#5 lore raw

Re: [PATCH v2 3/6] prctl.2: Add PR_SPEC_DISABLE_NOEXEC for SPECULATION_CTRL prctls

In reply to a message not in the archive
Quoted 51 lines · Dave Martin

Add the PR_SPEC_DISABLE_NOEXEC mode added in Linux 5.1 for the PR_SPEC_STORE_BYPASS "misfeature" of PR_SET_SPECULATION_CTRL and PR_GET_SPECULATION_CTRL.

Cc Waiman Long <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
  man2/prctl.2 | 22 ++++++++++++++++++++--
  1 file changed, 20 insertions(+), 2 deletions(-)
man2/prctl.2 +17 -1
index b6fb51c..cab9915 100644
@@ -1187,6 +1187,12 @@ The speculation feature is disabled, mitigation is enabled.
  Same as
  .B PR_SPEC_DISABLE
  but cannot be undone.
+.TP
+.BR PR_SPEC_DISABLE_NOEXEC " (since Linux 5.1)"
+Same as
+.BR PR_SPEC_DISABLE ,
+but but the state will be cleared on
+.BR execve (2).
  .RE
  .IP
  If all bits are 0,
@@ -1251,6 +1257,17 @@ with the same value for
  .I arg2
  will fail with the error
  .BR EPERM .
+.\" commit 71368af9027f18fe5d1c6f372cfdff7e4bde8b48
+.TP
+.BR PR_SPEC_DISABLE_NOEXEC " (since Linux 5.1)"
+Same as
+.BR PR_SPEC_DISABLE ,
+but but the state will be cleared on
+.BR execve (2).
+Currently only supported for
+.I arg2
+equal to
+.B PR_SPEC_STORE_BYPASS.
  .RE
  .IP
  Any unsupported value in
@@ -1899,11 +1916,12 @@ was
  .BR PR_SET_SPECULATION_CTRL
  and
  .IR arg3
-is neither

man2/prctl.2 was · line 1927

Quoted 10 lines
man2/prctl.2 +3 -1
+is not
  .BR PR_SPEC_ENABLE ,
  .BR PR_SPEC_DISABLE ,
+.BR PR_SPEC_FORCE_DISABLE ,
  nor
-.BR PR_SPEC_FORCE_DISABLE .
+.BR PR_SPEC_DISABLE_NOEXEC .
  .SH VERSIONS
  The
  .BR prctl ()
#6 lore raw

PATCH v2 4/6 prctl.2: Add SVE prctls (arm64)

In reply to a message not in the archive

Add documentation for the the PR_SVE_SET_VL and PR_SVE_GET_VL prctls added in Linux 4.15 for arm64.

Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>

---

Since v1:

* Minor rewordings and typo fixes.

* Fix typo'd #define names.

* Add type annotation for PR_SVE_SET_VL arg2.

* Clarify return value semantics of PR_SVE_SET_VL

* Add note to say that the args for PR_SVE_GET_VL are ignored.

* Note for PR_SVE_SET_VL that the PR_SVE_VL_LEN_MASK field specifies an upper bound on what vector length to set, not an exact value.

* Rework PR_SVE_SET_VL arg2 description to enumerate all possible flag combinations rather than describing the flags independently.

Coming up with a clear description of each flag that is independent of the description of the other flag turns out to be hard.

* In lieu of having a separate man page to cross reference for detailed guidance, cross-reference the kernel documentation.

* Avoid confusing cross-reference to PR_SVE_SET_VL when describing the return value of PR_SVE_GET_VL.

* Clarify error conditions for PR_SVE_SET_VL and PR_SVE_GET_VL, and move detail to the individual prctl descriptions to keep related content close together while minimising duplication.

* Add safety warning. This is deliberately vague, pending ongoing discussions with libc folks.

---
 man2/prctl.2 | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 160 insertions(+)
man2/prctl.2 +160 -0
index cab9915..91df7c8 100644
@@ -1291,6 +1291,148 @@ call failing with the error
 .BR ENXIO .
 For further details, see the kernel source file
 .IR Documentation/admin\-guide/kernel\-parameters.txt .
+.\" prctl PR_SVE_SET_VL
+.\" commit 2d2123bc7c7f843aa9db87720de159a049839862
+.\" linux-5.6/Documentation/arm64/sve.rst
+.TP
+.BR PR_SVE_SET_VL " (since Linux 4.15, only on arm64)"
+Configure the thread's SVE vector length,
+as specified by
+.IR "(int) arg2" .
+Arguments
+.IR arg3 ", " arg4 " and " arg5
+are ignored.
+.IP
+The bits of
+.I arg2
+corresponding to
+.B PR_SVE_VL_LEN_MASK
+must be set to the desired vector length in bytes.
+This is interpreted as an upper bound:
+the kernel will select the greatest available vector length
+that does not exceed the value specified.
+In particular, specifying
+.B SVE_VL_MAX
+(defined in
+.I <asm/sigcontext.h>)
+for the
+.B PR_SVE_VL_LEN_MASK
+bits requests the maximum supported vector length.
+.IP
+In addition,
+.I arg2
+must be set to one of the following combinations of flags:
+.RS
+.TP
+.B 0
+Perform the change immediately.
+At the next
+.BR execve (2)
+in the thread,
+the vector length will be reset to the value configured in
+.IR /proc/sys/abi/sve_default_vector_length .
+.TP
+.B PR_SVE_VL_INHERIT
+Perform the change immediately.
+Subsequent
+.BR execve (2)
+calls will preserve the new vector length.
+.TP
+.B PR_SVE_SET_VL_ONEXEC
+Defer the change, so that it is performed at the next
+.BR execve (2)
+in the thread.
+Further
+.BR execve (2)
+calls will reset the vector length to the value configured in
+.IR /proc/sys/abi/sve_default_vector_length .
+.TP
+.B "PR_SVE_SET_VL_ONEXEC | PR_SVE_VL_INHERIT"
+Defer the change, so that it is performed at the next
+.BR execve (2)
+in the thread.
+Further
+.BR execve (2)
+calls will preserve the new vector length.
+.RE
+.IP
+In all cases,
+any previously pending deferred change is canceled.
+.IP
+The call fails with error
+.B EINVAL
+if SVE is not supported on the platform, if
+.I arg2
+is unrecognized or invalid, or the value in the bits of
+.I arg2
+corresponding to
+.B PR_SVE_VL_LEN_MASK
+is outside the range
+.BR SVE_VL_MIN .. SVE_VL_MAX
+or is not a multiple of 16.
+.IP
+On success,
+a nonnegative value is returned that describes the
+.I selected
+configuration,
+which may differ from the current configuration if
+.B PR_SVE_SET_VL_ONEXEC
+was specified.
+The value is encoded in the same way as the return value of
+.BR PR_SVE_GET_VL .
+.IP
+The configuration (including any pending deferred change)
+is inherited across
+.BR fork (2)
+and
+.BR clone (2).
+.IP
+.B Warning:
+Because the compiler or run-time environment
+may be using SVE, using this call without the
+.B PR_SVE_SET_VL_ONEXEC
+flag may crash the calling process.
+The conditions for using it safely are complex and system-dependent.
+Don't use it unless you really know what you are doing.
+.IP
+For more information, see the kernel source file
+.I Documentation/arm64/sve.rst
+.\"commit b693d0b372afb39432e1c49ad7b3454855bc6bed
+(or
+.I Documentation/arm64/sve.txt
+before Linux 5.3).
+.\" prctl PR_SVE_GET_VL
+.TP
+.BR PR_SVE_GET_VL " (since Linux 4.15, only on arm64)"
+Get the thread's current SVE vector length configuration.
+.IP
+Arguments
+.IR arg2 ", " arg3 ", " arg4 " and " arg5
+are ignored.
+.IP
+Providing that the kernel and platform support SVE
+this operation always succeeds,
+returning a nonnegative value that describes the
+.I current
+configuration.
+The bits corresponding to
+.B PR_SVE_VL_LEN_MASK
+contain the currently configured vector length in bytes.
+The bit corresponding to
+.B PR_SVE_VL_INHERIT
+indicates whether the vector length will be inherited
+across
+.BR execve (2).
+.IP
+Note that there is no way to determine whether there is
+a pending vector length change that has not yet taken effect.
+.IP
+For more information, see the kernel source file
+.I Documentation/arm64/sve.rst
+.\"commit b693d0b372afb39432e1c49ad7b3454855bc6bed
+(or
+.I Documentation/arm64/sve.txt
+before Linux 5.3).
 .\"
 .\" prctl PR_TASK_PERF_EVENTS_DISABLE
 .TP
@@ -1534,6 +1676,8 @@ On success,
 .BR PR_GET_NO_NEW_PRIVS ,
 .BR PR_GET_SECUREBITS ,
 .BR PR_GET_SPECULATION_CTRL ,
+.BR PR_SVE_GET_VL ,
+.BR PR_SVE_SET_VL ,
 .BR PR_GET_THP_DISABLE ,
 .BR PR_GET_TIMING ,
 .BR PR_GET_TIMERSLACK ,
@@ -1817,6 +1961,22 @@ and unused arguments to
 .BR prctl ()
 are not 0.
 .TP
+.B EINVAL
+.I option
+is
+.B PR_SVE_SET_VL
+and the arguments are invalid or unsupported,
+or SVE is not available on this platform.
+See the description of
+.B PR_SVE_SET_VL
+above for details.
+.TP
+.B EINVAL
+.I option
+is
+.B PR_SVE_GET_VL
+and SVE is not available on this platform.
+.TP
 .B ENODEV
 .I option
 was
Signature · 1 line
2.1.4

A message that is not in the archive (sent off-list or not yet received): 1590614258-24728-5-git-send-email-Dave.Martin-5wv7dgnIgG8@public.gmane.org

#8 lore raw

Re: [PATCH v2 4/6] prctl.2: Add SVE prctls (arm64)

Hi Dave,

Quoted 2 lines · Dave Martin

Add documentation for the the PR_SVE_SET_VL and PR_SVE_GET_VL prctls added in Linux 4.15 for arm64.

Looks really good to me, thanks. Just a few comments inline.

Quoted 29 lines
man2/prctl.2 +21 -0
index cab9915..91df7c8 100644
@@ -1291,6 +1291,148 @@ call failing with the error
 .BR ENXIO .
 For further details, see the kernel source file
 .IR Documentation/admin\-guide/kernel\-parameters.txt .
+.\" prctl PR_SVE_SET_VL
+.\" commit 2d2123bc7c7f843aa9db87720de159a049839862
+.\" linux-5.6/Documentation/arm64/sve.rst
+.TP
+.BR PR_SVE_SET_VL " (since Linux 4.15, only on arm64)"
+Configure the thread's SVE vector length,
+as specified by
+.IR "(int) arg2" .
+Arguments
+.IR arg3 ", " arg4 " and " arg5
+are ignored.
+.IP
+The bits of
+.I arg2
+corresponding to
+.B PR_SVE_VL_LEN_MASK
+must be set to the desired vector length in bytes.
+This is interpreted as an upper bound:
+the kernel will select the greatest available vector length
+that does not exceed the value specified.
+In particular, specifying

man2/prctl.2 call failing with the error · line 1324

Quoted 10 lines
man2/prctl.2 +10 -0
+.B SVE_VL_MAX
+(defined in
+.I <asm/sigcontext.h>)
+for the
+.B PR_SVE_VL_LEN_MASK
+bits requests the maximum supported vector length.
+.IP
+In addition,
+.I arg2
+must be set to one of the following combinations of flags:

How about saying:

In addition, the other bits of arg2 must be set according to the following combinations of flags:

Otherwise I find it a bit fiddly to read, because it's valid to have flags of 0 and a non-zero length.

man2/prctl.2 call failing with the error · line 1333

Quoted 9 lines
man2/prctl.2 +9 -0
+.RS
+.TP
+.B 0
+Perform the change immediately.
+At the next
+.BR execve (2)
+in the thread,
+the vector length will be reset to the value configured in
+.IR /proc/sys/abi/sve_default_vector_length .

(implementation note: does this mean that 'sve_default_vl' should be
an atomic_t, as it can be accessed concurrently? We probably need {READ,WRITE}_ONCE() at the very least, as I'm not seeing any locks that help us here...)

Quoted 34 lines
man2/prctl.2 +34 -0
+.TP
+.B PR_SVE_VL_INHERIT
+Perform the change immediately.
+Subsequent
+.BR execve (2)
+calls will preserve the new vector length.
+.TP
+.B PR_SVE_SET_VL_ONEXEC
+Defer the change, so that it is performed at the next
+.BR execve (2)
+in the thread.
+Further
+.BR execve (2)
+calls will reset the vector length to the value configured in
+.IR /proc/sys/abi/sve_default_vector_length .
+.TP
+.B "PR_SVE_SET_VL_ONEXEC | PR_SVE_VL_INHERIT"
+Defer the change, so that it is performed at the next
+.BR execve (2)
+in the thread.
+Further
+.BR execve (2)
+calls will preserve the new vector length.
+.RE
+.IP
+In all cases,
+any previously pending deferred change is canceled.
+.IP
+The call fails with error
+.B EINVAL
+if SVE is not supported on the platform, if
+.I arg2
+is unrecognized or invalid, or the value in the bits of
+.I arg2

man2/prctl.2 call failing with the error · line 1377

Quoted 10 lines
man2/prctl.2 +10 -0
+corresponding to
+.B PR_SVE_VL_LEN_MASK
+is outside the range
+.BR SVE_VL_MIN .. SVE_VL_MAX
+or is not a multiple of 16.
+.IP
+On success,
+a nonnegative value is returned that describes the
+.I selected
+configuration,

If I'm reading the kernel code correctly, this is slightly weird, as the returned value may contain the PR_SVE_VL_INHERIT flag but it will never contain the PR_SVE_SET_VL_ONEXEC flag. Is that right?

If so, maybe just say something like:

On success, a nonnegative value is returned that describes the selected configuration in the same way as PR_SVE_GET_VL.

Quoted 16 lines
man2/prctl.2 +16 -0
+which may differ from the current configuration if
+.B PR_SVE_SET_VL_ONEXEC
+was specified.
+The value is encoded in the same way as the return value of
+.BR PR_SVE_GET_VL .
+.IP
+The configuration (including any pending deferred change)
+is inherited across
+.BR fork (2)
+and
+.BR clone (2).
+.IP
+.B Warning:
+Because the compiler or run-time environment
+may be using SVE, using this call without the
+.B PR_SVE_SET_VL_ONEXEC

man2/prctl.2 call failing with the error · line 1403

Quoted 10 lines
man2/prctl.2 +10 -0
+flag may crash the calling process.
+The conditions for using it safely are complex and system-dependent.
+Don't use it unless you really know what you are doing.
+.IP
+For more information, see the kernel source file
+.I Documentation/arm64/sve.rst
+.\"commit b693d0b372afb39432e1c49ad7b3454855bc6bed
+(or
+.I Documentation/arm64/sve.txt
+before Linux 5.3).

I think I'd drop the kernel reference here, as it feels like we're saying "only do this if you know what you're doing" on one hand, but then "if you don't know what you're doing, see this other documentation" on the other.

Will

#9 lore raw

Re: [PATCH v2 4/6] prctl.2: Add SVE prctls (arm64)

Quoted 50 lines · Will Deacon

Hi Dave,

Quoted 2 lines · Dave Martin

Add documentation for the the PR_SVE_SET_VL and PR_SVE_GET_VL prctls added in Linux 4.15 for arm64.

Looks really good to me, thanks. Just a few comments inline.

Quoted 29 lines
man2/prctl.2 +21 -0
index cab9915..91df7c8 100644
@@ -1291,6 +1291,148 @@ call failing with the error
 .BR ENXIO .
 For further details, see the kernel source file
 .IR Documentation/admin\-guide/kernel\-parameters.txt .
+.\" prctl PR_SVE_SET_VL
+.\" commit 2d2123bc7c7f843aa9db87720de159a049839862
+.\" linux-5.6/Documentation/arm64/sve.rst
+.TP
+.BR PR_SVE_SET_VL " (since Linux 4.15, only on arm64)"
+Configure the thread's SVE vector length,
+as specified by
+.IR "(int) arg2" .
+Arguments
+.IR arg3 ", " arg4 " and " arg5
+are ignored.
+.IP
+The bits of
+.I arg2
+corresponding to
+.B PR_SVE_VL_LEN_MASK
+must be set to the desired vector length in bytes.
+This is interpreted as an upper bound:
+the kernel will select the greatest available vector length
+that does not exceed the value specified.
+In particular, specifying

man2/prctl.2 call failing with the error · line 1324

Quoted 10 lines
man2/prctl.2 +10 -0
+.B SVE_VL_MAX
+(defined in
+.I <asm/sigcontext.h>)
+for the
+.B PR_SVE_VL_LEN_MASK
+bits requests the maximum supported vector length.
+.IP
+In addition,
+.I arg2
+must be set to one of the following combinations of flags:

How about saying:

Quoted 5 lines

In addition, the other bits of arg2 must be set according to the following combinations of flags:

Otherwise I find it a bit fiddly to read, because it's valid to have flags of 0 and a non-zero length.

0 is listed, so I hoped that was clear enough.

Maybe just write "must be one of the following values:"?

0 is a value, but I can see why you might be uneasy about 0 being described as a "combination of flags".

Quoted 6 lines
Quoted 6 lines
man2/prctl.2 +6 -0
+.RS
+.TP
+.B 0
+Perform the change immediately.
+At the next
+.BR execve (2)
Quoted 8 lines

man2/prctl.2 call failing with the error · line 1333

Quoted 3 lines
man2/prctl.2 +3 -0
+in the thread,
+the vector length will be reset to the value configured in
+.IR /proc/sys/abi/sve_default_vector_length .

(implementation note: does this mean that 'sve_default_vl' should be
an atomic_t, as it can be accessed concurrently? We probably need {READ,WRITE}_ONCE() at the very least, as I'm not seeing any locks that help us here...)

Is this purely theoretical? Can you point to what could go wrong?

While I doubt I thought about this very hard and I agree that you're right in principle, I think there are probably non-atomic sysctls and debugs files etc. all over the place.

I didn't want to clutter the code unnecessarily.

Quoted 39 lines
Quoted 39 lines
man2/prctl.2 +39 -0
+.B PR_SVE_VL_INHERIT
+Perform the change immediately.
+Subsequent
+.BR execve (2)
+calls will preserve the new vector length.
+.TP
+.B PR_SVE_SET_VL_ONEXEC
+Defer the change, so that it is performed at the next
+.BR execve (2)
+in the thread.
+Further
+.BR execve (2)
+calls will reset the vector length to the value configured in
+.IR /proc/sys/abi/sve_default_vector_length .
+.TP
+.B "PR_SVE_SET_VL_ONEXEC | PR_SVE_VL_INHERIT"
+Defer the change, so that it is performed at the next
+.BR execve (2)
+in the thread.
+Further
+.BR execve (2)
+calls will preserve the new vector length.
+.RE
+.IP
+In all cases,
+any previously pending deferred change is canceled.
+.IP
+The call fails with error
+.B EINVAL
+if SVE is not supported on the platform, if
+.I arg2
+is unrecognized or invalid, or the value in the bits of
+.I arg2
+corresponding to
+.B PR_SVE_VL_LEN_MASK
+is outside the range
+.BR SVE_VL_MIN .. SVE_VL_MAX
+or is not a multiple of 16.
+.IP
Quoted 8 lines

man2/prctl.2 call failing with the error · line 1377

Quoted 4 lines
man2/prctl.2 +4 -0
+On success,
+a nonnegative value is returned that describes the
+.I selected
+configuration,

If I'm reading the kernel code correctly, this is slightly weird, as the returned value may contain the PR_SVE_VL_INHERIT flag but it will never contain the PR_SVE_SET_VL_ONEXEC flag. Is that right?

Yes, which is an oddity.

I suppose we could fake that up actually by returning that flag if sve_vl and sve_vl_onexec are different, but we don't currently do this.

Quoted 4 lines

If so, maybe just say something like:

On success, a nonnegative value is returned that describes the selected configuration in the same way as PR_SVE_GET_VL.

How does that help? PR_SVE_GET_VL doesn't fully clarify the oddity you call out anyway.

Really, I preferred not to have people relying on this one way or the other. The only sensible reason for an _ONEXEC is because you've committed to calling execve(). On such a path, queryng the vector length isn't likely to be useful.

Maybe I was optimistic.

Quoted 22 lines
Quoted 22 lines
man2/prctl.2 +22 -0
+which may differ from the current configuration if
+.B PR_SVE_SET_VL_ONEXEC
+was specified.
+The value is encoded in the same way as the return value of
+.BR PR_SVE_GET_VL .
+.IP
+The configuration (including any pending deferred change)
+is inherited across
+.BR fork (2)
+and
+.BR clone (2).
+.IP
+.B Warning:
+Because the compiler or run-time environment
+may be using SVE, using this call without the
+.B PR_SVE_SET_VL_ONEXEC
+flag may crash the calling process.
+The conditions for using it safely are complex and system-dependent.
+Don't use it unless you really know what you are doing.
+.IP
+For more information, see the kernel source file
+.I Documentation/arm64/sve.rst
Quoted 8 lines

man2/prctl.2 call failing with the error · line 1403

Quoted 4 lines
man2/prctl.2 +4 -0
+.\"commit b693d0b372afb39432e1c49ad7b3454855bc6bed
+(or
+.I Documentation/arm64/sve.txt
+before Linux 5.3).

I think I'd drop the kernel reference here, as it feels like we're saying "only do this if you know what you're doing" on one hand, but then "if you don't know what you're doing, see this other documentation" on the other.

Well, the docmuentation doesn't answer those questions either.

I could just swap the warning and the cross-reference, so that the cross-reference doesn't seem to follow on from "knowing what you're doing"?

Cheers
---Dave

#10 lore raw

Re: [PATCH v2 4/6] prctl.2: Add SVE prctls (arm64)

Quoted 50 lines · Dave Martin
Quoted 43 lines · Will Deacon
Quoted 29 lines · Dave Martin
man2/prctl.2 +21 -0
index cab9915..91df7c8 100644
@@ -1291,6 +1291,148 @@ call failing with the error
 .BR ENXIO .
 For further details, see the kernel source file
 .IR Documentation/admin\-guide/kernel\-parameters.txt .
+.\" prctl PR_SVE_SET_VL
+.\" commit 2d2123bc7c7f843aa9db87720de159a049839862
+.\" linux-5.6/Documentation/arm64/sve.rst
+.TP
+.BR PR_SVE_SET_VL " (since Linux 4.15, only on arm64)"
+Configure the thread's SVE vector length,
+as specified by
+.IR "(int) arg2" .
+Arguments
+.IR arg3 ", " arg4 " and " arg5
+are ignored.
+.IP
+The bits of
+.I arg2
+corresponding to
+.B PR_SVE_VL_LEN_MASK
+must be set to the desired vector length in bytes.
+This is interpreted as an upper bound:
+the kernel will select the greatest available vector length
+that does not exceed the value specified.
+In particular, specifying

man2/prctl.2 call failing with the error · line 1324

Quoted 10 lines
man2/prctl.2 +10 -0
+.B SVE_VL_MAX
+(defined in
+.I <asm/sigcontext.h>)
+for the
+.B PR_SVE_VL_LEN_MASK
+bits requests the maximum supported vector length.
+.IP
+In addition,
+.I arg2
+must be set to one of the following combinations of flags:

How about saying:

Quoted 5 lines

In addition, the other bits of arg2 must be set according to the following combinations of flags:

Otherwise I find it a bit fiddly to read, because it's valid to have flags of 0 and a non-zero length.

Quoted 6 lines

0 is listed, so I hoped that was clear enough.

Maybe just write "must be one of the following values:"?

0 is a value, but I can see why you might be uneasy about 0 being described as a "combination of flags".

It's more that arg2 *also* holds the length, so saying that arg2 must be set to a combination of flags isn't quite right, because it's actually to set to a combination of flags and the length.

Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
man2/prctl.2 +6 -0
+.RS
+.TP
+.B 0
+Perform the change immediately.
+At the next
+.BR execve (2)
Quoted 8 lines

man2/prctl.2 call failing with the error · line 1333

Quoted 3 lines
man2/prctl.2 +3 -0
+in the thread,
+the vector length will be reset to the value configured in
+.IR /proc/sys/abi/sve_default_vector_length .

(implementation note: does this mean that 'sve_default_vl' should be
an atomic_t, as it can be accessed concurrently? We probably need {READ,WRITE}_ONCE() at the very least, as I'm not seeing any locks that help us here...)

Quoted 1 line

Is this purely theoretical? Can you point to what could go wrong?

If the write is torn by the compiler, then a concurrent reader could end up seeing a bogus value. There could also be ToCToU issues if it's re-read.

Quoted 5 lines

While I doubt I thought about this very hard and I agree that you're right in principle, I think there are probably non-atomic sysctls and debugs files etc. all over the place.

I didn't want to clutter the code unnecessarily.

Right, but KCSAN is coming along and so somebody less familiar with the code will hit this eventually.

Quoted 48 lines
Quoted 39 lines
Quoted 39 lines
man2/prctl.2 +39 -0
+.B PR_SVE_VL_INHERIT
+Perform the change immediately.
+Subsequent
+.BR execve (2)
+calls will preserve the new vector length.
+.TP
+.B PR_SVE_SET_VL_ONEXEC
+Defer the change, so that it is performed at the next
+.BR execve (2)
+in the thread.
+Further
+.BR execve (2)
+calls will reset the vector length to the value configured in
+.IR /proc/sys/abi/sve_default_vector_length .
+.TP
+.B "PR_SVE_SET_VL_ONEXEC | PR_SVE_VL_INHERIT"
+Defer the change, so that it is performed at the next
+.BR execve (2)
+in the thread.
+Further
+.BR execve (2)
+calls will preserve the new vector length.
+.RE
+.IP
+In all cases,
+any previously pending deferred change is canceled.
+.IP
+The call fails with error
+.B EINVAL
+if SVE is not supported on the platform, if
+.I arg2
+is unrecognized or invalid, or the value in the bits of
+.I arg2
+corresponding to
+.B PR_SVE_VL_LEN_MASK
+is outside the range
+.BR SVE_VL_MIN .. SVE_VL_MAX
+or is not a multiple of 16.
+.IP
Quoted 8 lines

man2/prctl.2 call failing with the error · line 1377

Quoted 4 lines
man2/prctl.2 +4 -0
+On success,
+a nonnegative value is returned that describes the
+.I selected
+configuration,

If I'm reading the kernel code correctly, this is slightly weird, as the returned value may contain the PR_SVE_VL_INHERIT flag but it will never contain the PR_SVE_SET_VL_ONEXEC flag. Is that right?

Quoted 4 lines

Yes, which is an oddity.

I suppose we could fake that up actually by returning that flag if sve_vl and sve_vl_onexec are different, but we don't currently do this.

I don't think there's any need to change the code, but I think this stuff is worth documenting.

Quoted 7 lines
Quoted 4 lines

If so, maybe just say something like:

On success, a nonnegative value is returned that describes the selected configuration in the same way as PR_SVE_GET_VL.

How does that help? PR_SVE_GET_VL doesn't fully clarify the oddity you call out anyway.

It clarifies it enough for my liking (by explicitly talking about "the bit corresponding to PR_SVE_VL_INHERIT" and not about PR_SVE_SET_VL_ONEXEC), but either way, I think saying that the return value is the same is a useful clarification. If you want to make PR_SVE_GET_VL more explicit, we could do that too.

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
man2/prctl.2 +7 -0
+.B PR_SVE_SET_VL_ONEXEC
+flag may crash the calling process.
+The conditions for using it safely are complex and system-dependent.
+Don't use it unless you really know what you are doing.
+.IP
+For more information, see the kernel source file
+.I Documentation/arm64/sve.rst
Quoted 8 lines

man2/prctl.2 call failing with the error · line 1403

Quoted 4 lines
man2/prctl.2 +4 -0
+.\"commit b693d0b372afb39432e1c49ad7b3454855bc6bed
+(or
+.I Documentation/arm64/sve.txt
+before Linux 5.3).

I think I'd drop the kernel reference here, as it feels like we're saying "only do this if you know what you're doing" on one hand, but then "if you don't know what you're doing, see this other documentation" on the other.

Quoted 5 lines

Well, the docmuentation doesn't answer those questions either.

I could just swap the warning and the cross-reference, so that the cross-reference doesn't seem to follow on from "knowing what you're doing"?

Ok.

Will

#11 lore raw

Re: [PATCH v2 4/6] prctl.2: Add SVE prctls (arm64)

Quoted 77 lines · Will Deacon
Quoted 50 lines · Dave Martin
Quoted 43 lines · Will Deacon
Quoted 29 lines · Dave Martin
man2/prctl.2 +21 -0
index cab9915..91df7c8 100644
@@ -1291,6 +1291,148 @@ call failing with the error
 .BR ENXIO .
 For further details, see the kernel source file
 .IR Documentation/admin\-guide/kernel\-parameters.txt .
+.\" prctl PR_SVE_SET_VL
+.\" commit 2d2123bc7c7f843aa9db87720de159a049839862
+.\" linux-5.6/Documentation/arm64/sve.rst
+.TP
+.BR PR_SVE_SET_VL " (since Linux 4.15, only on arm64)"
+Configure the thread's SVE vector length,
+as specified by
+.IR "(int) arg2" .
+Arguments
+.IR arg3 ", " arg4 " and " arg5
+are ignored.
+.IP
+The bits of
+.I arg2
+corresponding to
+.B PR_SVE_VL_LEN_MASK
+must be set to the desired vector length in bytes.
+This is interpreted as an upper bound:
+the kernel will select the greatest available vector length
+that does not exceed the value specified.
+In particular, specifying

man2/prctl.2 call failing with the error · line 1324

Quoted 10 lines
man2/prctl.2 +10 -0
+.B SVE_VL_MAX
+(defined in
+.I <asm/sigcontext.h>)
+for the
+.B PR_SVE_VL_LEN_MASK
+bits requests the maximum supported vector length.
+.IP
+In addition,
+.I arg2
+must be set to one of the following combinations of flags:

How about saying:

Quoted 5 lines

In addition, the other bits of arg2 must be set according to the following combinations of flags:

Otherwise I find it a bit fiddly to read, because it's valid to have flags of 0 and a non-zero length.

Quoted 6 lines

0 is listed, so I hoped that was clear enough.

Maybe just write "must be one of the following values:"?

0 is a value, but I can see why you might be uneasy about 0 being described as a "combination of flags".

It's more that arg2 *also* holds the length, so saying that arg2 must be set to a combination of flags isn't quite right, because it's actually to set to a combination of flags and the length.

Quoted 15 lines
Quoted 14 lines

man2/prctl.2 call failing with the error · line 1333

Quoted 9 lines
man2/prctl.2 +9 -0
+.RS
+.TP
+.B 0
+Perform the change immediately.
+At the next
+.BR execve (2)
+in the thread,
+the vector length will be reset to the value configured in
+.IR /proc/sys/abi/sve_default_vector_length .

(implementation note: does this mean that 'sve_default_vl' should be
an atomic_t, as it can be accessed concurrently? We probably need {READ,WRITE}_ONCE() at the very least, as I'm not seeing any locks that help us here...)

Quoted 4 lines
Quoted 1 line

Is this purely theoretical? Can you point to what could go wrong?

If the write is torn by the compiler, then a concurrent reader could end up seeing a bogus value. There could also be ToCToU issues if it's re-read.

It won't be torn in practice, no decision logic depends on the value read, and you can't even get from the write to the read or vice-versa without crossing a TU boundary (even under LTO), so there's basically zero scope for sabotXXXXXoptimisation by the compiler.

Only root is allowed to write this thing anyway.

Quoted 8 lines
Quoted 5 lines

While I doubt I thought about this very hard and I agree that you're right in principle, I think there are probably non-atomic sysctls and debugs files etc. all over the place.

I didn't want to clutter the code unnecessarily.

Right, but KCSAN is coming along and so somebody less familiar with the code will hit this eventually.

So the issue is theoretical, probably one of very many similar issues, and anyway we have a tool for tracking them down if we need to?

I'm playing devil's advocate here, but I'd debate whether it's worth it -- or even wise -- to fix these piecemeal unless we're confident this is an egregious case. Doing so may encourage a false sense of safety. When we're in a position to do a treewide cleanup, that would be better, no?

Quoted 61 lines
Quoted 48 lines
Quoted 39 lines
Quoted 39 lines
man2/prctl.2 +39 -0
+.B PR_SVE_VL_INHERIT
+Perform the change immediately.
+Subsequent
+.BR execve (2)
+calls will preserve the new vector length.
+.TP
+.B PR_SVE_SET_VL_ONEXEC
+Defer the change, so that it is performed at the next
+.BR execve (2)
+in the thread.
+Further
+.BR execve (2)
+calls will reset the vector length to the value configured in
+.IR /proc/sys/abi/sve_default_vector_length .
+.TP
+.B "PR_SVE_SET_VL_ONEXEC | PR_SVE_VL_INHERIT"
+Defer the change, so that it is performed at the next
+.BR execve (2)
+in the thread.
+Further
+.BR execve (2)
+calls will preserve the new vector length.
+.RE
+.IP
+In all cases,
+any previously pending deferred change is canceled.
+.IP
+The call fails with error
+.B EINVAL
+if SVE is not supported on the platform, if
+.I arg2
+is unrecognized or invalid, or the value in the bits of
+.I arg2
+corresponding to
+.B PR_SVE_VL_LEN_MASK
+is outside the range
+.BR SVE_VL_MIN .. SVE_VL_MAX
+or is not a multiple of 16.
+.IP
Quoted 8 lines

man2/prctl.2 call failing with the error · line 1377

Quoted 4 lines
man2/prctl.2 +4 -0
+On success,
+a nonnegative value is returned that describes the
+.I selected
+configuration,

If I'm reading the kernel code correctly, this is slightly weird, as the returned value may contain the PR_SVE_VL_INHERIT flag but it will never contain the PR_SVE_SET_VL_ONEXEC flag. Is that right?

Quoted 4 lines

Yes, which is an oddity.

I suppose we could fake that up actually by returning that flag if sve_vl and sve_vl_onexec are different, but we don't currently do this.

I don't think there's any need to change the code, but I think this stuff is worth documenting.

Quoted 5 lines
Quoted 4 lines

If so, maybe just say something like:

On success, a nonnegative value is returned that describes the selected configuration in the same way as PR_SVE_GET_VL.

Quoted 8 lines
Quoted 2 lines

How does that help? PR_SVE_GET_VL doesn't fully clarify the oddity you call out anyway.

It clarifies it enough for my liking (by explicitly talking about "the bit corresponding to PR_SVE_VL_INHERIT" and not about PR_SVE_SET_VL_ONEXEC), but either way, I think saying that the return value is the same is a useful clarification. If you want to make PR_SVE_GET_VL more explicit, we could do that too.

Fair enough. I'll just refer to PR_SVE_GET_VL, as you suggest.

I'm not keen to add any new wording at this stage.

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines

man2/prctl.2 call failing with the error · line 1403

Quoted 11 lines
man2/prctl.2 +11 -0
+.B PR_SVE_SET_VL_ONEXEC
+flag may crash the calling process.
+The conditions for using it safely are complex and system-dependent.
+Don't use it unless you really know what you are doing.
+.IP
+For more information, see the kernel source file
+.I Documentation/arm64/sve.rst
+.\"commit b693d0b372afb39432e1c49ad7b3454855bc6bed
+(or
+.I Documentation/arm64/sve.txt
+before Linux 5.3).

I think I'd drop the kernel reference here, as it feels like we're saying "only do this if you know what you're doing" on one hand, but then "if you don't know what you're doing, see this other documentation" on the other.

Quoted 7 lines
Quoted 5 lines

Well, the docmuentation doesn't answer those questions either.

I could just swap the warning and the cross-reference, so that the cross-reference doesn't seem to follow on from "knowing what you're doing"?

Ok.

OK, I'll aim to do that then.

Cheers
---Dave

#12 lore raw

Re: [PATCH v2 4/6] prctl.2: Add SVE prctls (arm64)

[Dropped linux-man and Michael]

Quoted 21 lines · Dave Martin
Quoted 20 lines · Will Deacon
Quoted 18 lines · Dave Martin
Quoted 15 lines · Will Deacon

man2/prctl.2 call failing with the error · line 1333

Quoted 9 lines · Dave Martin

+.RS
+.TP
+.B 0

man2/prctl.2 +6 -0
+Perform the change immediately.
+At the next
+.BR execve (2)
+in the thread,
+the vector length will be reset to the value configured in
+.IR /proc/sys/abi/sve_default_vector_length .

(implementation note: does this mean that 'sve_default_vl' should be
an atomic_t, as it can be accessed concurrently? We probably need {READ,WRITE}_ONCE() at the very least, as I'm not seeing any locks that help us here...)

Is this purely theoretical? Can you point to what could go wrong?

Quoted 7 lines
Quoted 2 lines

If the write is torn by the compiler, then a concurrent reader could end up seeing a bogus value. There could also be ToCToU issues if it's re-read.

It won't be torn in practice, no decision logic depends on the value read, and you can't even get from the write to the read or vice-versa without crossing a TU boundary (even under LTO), so there's basically zero scope for sabotXXXXXoptimisation by the compiler.

Perhaps, but I'm not brave enough to state that :) Look at this crazy thing, for example:

https://lore.kernel.org/lkml/CAG48ez2nFks+yN1Kp4TZisso+rjvv_4UW0FTo8iFUd4Qyq1qDw@mail.gmail.com/

Could the same sort of technique be applied to:

	vl = current->thread.sve_vl_onexec ?
	     current->thread.sve_vl_onexec : sve_default_vl;

	if (WARN_ON(!sve_vl_valid(vl)))
		vl = SVE_VL_MIN;

	supported_vl = find_supported_vector_length(vl);

so that the compiled code does something like:

	if (within_valid_bounds(sve_default_vl)) {
		supported_vl = jump_table(sve_default_vl); // Reload the variable
	} else {
		WARN_ON(1);
		supported_vl = SVE_VL_MIN;
	}

?

I'd certainly prefer not to have to think about that!

Quoted 11 lines

Only root is allowed to write this thing anyway.

Quoted 8 lines
Quoted 5 lines

While I doubt I thought about this very hard and I agree that you're right in principle, I think there are probably non-atomic sysctls and debugs files etc. all over the place.

I didn't want to clutter the code unnecessarily.

Right, but KCSAN is coming along and so somebody less familiar with the code will hit this eventually.

Quoted 8 lines

So the issue is theoretical, probably one of very many similar issues, and anyway we have a tool for tracking them down if we need to?

I'm playing devil's advocate here, but I'd debate whether it's worth it -- or even wise -- to fix these piecemeal unless we're confident this is an egregious case. Doing so may encourage a false sense of safety. When we're in a position to do a treewide cleanup, that would be better, no?

That's a good point, but it is inevitable that people will try to attempt treewide introduction of {READ,WRITE}_ONCE() based solely on KCSAN reports rather than an understanding of the code, and so I'd much rather somebody who understands the code (that's you ;) deals with it first.

If the race is benign, then you can annotate the accesses with data_race() and add a comment along the lines of your "It won't be torn in practice..." paragraph above.

Anyway, this is entirely independent to the manpage effort, just that the concurrency wasn't clear to me before I read what you'd written and thought I'd mention this before I forget. It's also looking less likely that KCSAN is going to land for 5.8, so there's no urgency to this at all.

Will

#13 lore raw

Re: [PATCH v2 4/6] prctl.2: Add SVE prctls (arm64)

Quoted 60 lines · Will Deacon

[Dropped linux-man and Michael]

Quoted 21 lines · Dave Martin
Quoted 20 lines · Will Deacon
Quoted 18 lines · Dave Martin
Quoted 15 lines · Will Deacon

Review

Quoted 9 lines · Dave Martin

+.RS
+.TP
+.B 0

(quoted diff) +6 -0
+Perform the change immediately.
+At the next
+.BR execve (2)
+in the thread,
+the vector length will be reset to the value configured in
+.IR /proc/sys/abi/sve_default_vector_length .

(implementation note: does this mean that 'sve_default_vl' should be
an atomic_t, as it can be accessed concurrently? We probably need {READ,WRITE}_ONCE() at the very least, as I'm not seeing any locks that help us here...)

Is this purely theoretical? Can you point to what could go wrong?

Quoted 7 lines
Quoted 2 lines

If the write is torn by the compiler, then a concurrent reader could end up seeing a bogus value. There could also be ToCToU issues if it's re-read.

It won't be torn in practice, no decision logic depends on the value read, and you can't even get from the write to the read or vice-versa without crossing a TU boundary (even under LTO), so there's basically zero scope for sabotXXXXXoptimisation by the compiler.

Perhaps, but I'm not brave enough to state that :) Look at this crazy thing, for example:

https://lore.kernel.org/lkml/CAG48ez2nFks+yN1Kp4TZisso+rjvv_4UW0FTo8iFUd4Qyq1qDw@mail.gmail.com/

Could the same sort of technique be applied to:

	vl = current->thread.sve_vl_onexec ?
	     current->thread.sve_vl_onexec : sve_default_vl;

	if (WARN_ON(!sve_vl_valid(vl)))
		vl = SVE_VL_MIN;

	supported_vl = find_supported_vector_length(vl);

so that the compiled code does something like:

	if (within_valid_bounds(sve_default_vl)) {
		supported_vl = jump_table(sve_default_vl); // Reload the variable
	} else {
		WARN_ON(1);
		supported_vl = SVE_VL_MIN;
	}
Quoted 3 lines

?

I'd certainly prefer not to have to think about that!

Well sure, but the compiler has much to lose and nothing to gain from such a transformation here. This is a bit different from a load of conditional code that can be heavily const-folded during specialisation.

Anyway, I'm not saying that you're not correct about the risk, just that this feels like a common pattern.

Quoted 20 lines
Quoted 11 lines

Only root is allowed to write this thing anyway.

Quoted 8 lines
Quoted 5 lines

While I doubt I thought about this very hard and I agree that you're right in principle, I think there are probably non-atomic sysctls and debugs files etc. all over the place.

I didn't want to clutter the code unnecessarily.

Right, but KCSAN is coming along and so somebody less familiar with the code will hit this eventually.

Quoted 8 lines

So the issue is theoretical, probably one of very many similar issues, and anyway we have a tool for tracking them down if we need to?

I'm playing devil's advocate here, but I'd debate whether it's worth it -- or even wise -- to fix these piecemeal unless we're confident this is an egregious case. Doing so may encourage a false sense of safety. When we're in a position to do a treewide cleanup, that would be better, no?

Quoted 8 lines

That's a good point, but it is inevitable that people will try to attempt treewide introduction of {READ,WRITE}_ONCE() based solely on KCSAN reports rather than an understanding of the code, and so I'd much rather somebody who understands the code (that's you ;) deals with it first.

If the race is benign, then you can annotate the accesses with data_race() and add a comment along the lines of your "It won't be torn in practice..." paragraph above.

Oh, it's complex enough to reason about that we should definitely use proper atomics here so that we don't have to think about it. Also, I'd concede that the fact that this code has a custom sysctl accessor may make justify a special case fix.

For most users, it would be better to clip sysctl's wings so that only atomic accesses are allowed if the default implementation is used. sysctl is not a fast path: for single values of fundamental types, there's no reason I can think of not to use atomics across the board.

Quoted 4 lines

Anyway, this is entirely independent to the manpage effort, just that the concurrency wasn't clear to me before I read what you'd written and thought I'd mention this before I forget. It's also looking less likely that KCSAN is going to land for 5.8, so there's no urgency to this at all.

Sure, and I don't think I thought much beyond "I wonder what happens if ... nah, probably fine, if it mattered then everyone would be doing it."

I'm pretty sure I didn't get that wording out of the C spec.

It's a good spot though, and I may look at a fix if I get around to it. Can't promise when, though.

Cheers
---Dave

#14 lore raw

Re: [PATCH v2 4/6] prctl.2: Add SVE prctls (arm64)

In reply to a message not in the archive

Hi Dave,

I've not applied this patch yet, in case you want to make some changes in response to Will's comments.

I think all of the rest of the patches in the series are now applied (and pushed to master).

Thanks,

Michael

Quoted 232 lines · Dave Martin

Add documentation for the the PR_SVE_SET_VL and PR_SVE_GET_VL prctls added in Linux 4.15 for arm64.

Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>

---

Since v1:

* Minor rewordings and typo fixes.

* Fix typo'd #define names.

* Add type annotation for PR_SVE_SET_VL arg2.

* Clarify return value semantics of PR_SVE_SET_VL

* Add note to say that the args for PR_SVE_GET_VL are ignored.

* Note for PR_SVE_SET_VL that the PR_SVE_VL_LEN_MASK field specifies an upper bound on what vector length to set, not an exact value.

* Rework PR_SVE_SET_VL arg2 description to enumerate all possible flag combinations rather than describing the flags independently.

Coming up with a clear description of each flag that is independent of the description of the other flag turns out to be hard.

* In lieu of having a separate man page to cross reference for detailed guidance, cross-reference the kernel documentation.

* Avoid confusing cross-reference to PR_SVE_SET_VL when describing the return value of PR_SVE_GET_VL.

* Clarify error conditions for PR_SVE_SET_VL and PR_SVE_GET_VL, and move detail to the individual prctl descriptions to keep related content close together while minimising duplication.

* Add safety warning. This is deliberately vague, pending ongoing discussions with libc folks.

---
 man2/prctl.2 | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 160 insertions(+)
man2/prctl.2 +160 -0
index cab9915..91df7c8 100644
@@ -1291,6 +1291,148 @@ call failing with the error
 .BR ENXIO .
 For further details, see the kernel source file
 .IR Documentation/admin\-guide/kernel\-parameters.txt .
+.\" prctl PR_SVE_SET_VL
+.\" commit 2d2123bc7c7f843aa9db87720de159a049839862
+.\" linux-5.6/Documentation/arm64/sve.rst
+.TP
+.BR PR_SVE_SET_VL " (since Linux 4.15, only on arm64)"
+Configure the thread's SVE vector length,
+as specified by
+.IR "(int) arg2" .
+Arguments
+.IR arg3 ", " arg4 " and " arg5
+are ignored.
+.IP
+The bits of
+.I arg2
+corresponding to
+.B PR_SVE_VL_LEN_MASK
+must be set to the desired vector length in bytes.
+This is interpreted as an upper bound:
+the kernel will select the greatest available vector length
+that does not exceed the value specified.
+In particular, specifying
+.B SVE_VL_MAX
+(defined in
+.I <asm/sigcontext.h>)
+for the
+.B PR_SVE_VL_LEN_MASK
+bits requests the maximum supported vector length.
+.IP
+In addition,
+.I arg2
+must be set to one of the following combinations of flags:
+.RS
+.TP
+.B 0
+Perform the change immediately.
+At the next
+.BR execve (2)
+in the thread,
+the vector length will be reset to the value configured in
+.IR /proc/sys/abi/sve_default_vector_length .
+.TP
+.B PR_SVE_VL_INHERIT
+Perform the change immediately.
+Subsequent
+.BR execve (2)
+calls will preserve the new vector length.
+.TP
+.B PR_SVE_SET_VL_ONEXEC
+Defer the change, so that it is performed at the next
+.BR execve (2)
+in the thread.
+Further
+.BR execve (2)
+calls will reset the vector length to the value configured in
+.IR /proc/sys/abi/sve_default_vector_length .
+.TP
+.B "PR_SVE_SET_VL_ONEXEC | PR_SVE_VL_INHERIT"
+Defer the change, so that it is performed at the next
+.BR execve (2)
+in the thread.
+Further
+.BR execve (2)
+calls will preserve the new vector length.
+.RE
+.IP
+In all cases,
+any previously pending deferred change is canceled.
+.IP
+The call fails with error
+.B EINVAL
+if SVE is not supported on the platform, if
+.I arg2
+is unrecognized or invalid, or the value in the bits of
+.I arg2
+corresponding to
+.B PR_SVE_VL_LEN_MASK
+is outside the range
+.BR SVE_VL_MIN .. SVE_VL_MAX
+or is not a multiple of 16.
+.IP
+On success,
+a nonnegative value is returned that describes the
+.I selected
+configuration,
+which may differ from the current configuration if
+.B PR_SVE_SET_VL_ONEXEC
+was specified.
+The value is encoded in the same way as the return value of
+.BR PR_SVE_GET_VL .
+.IP
+The configuration (including any pending deferred change)
+is inherited across
+.BR fork (2)
+and
+.BR clone (2).
+.IP
+.B Warning:
+Because the compiler or run-time environment
+may be using SVE, using this call without the
+.B PR_SVE_SET_VL_ONEXEC
+flag may crash the calling process.
+The conditions for using it safely are complex and system-dependent.
+Don't use it unless you really know what you are doing.
+.IP
+For more information, see the kernel source file
+.I Documentation/arm64/sve.rst
+.\"commit b693d0b372afb39432e1c49ad7b3454855bc6bed
+(or
+.I Documentation/arm64/sve.txt
+before Linux 5.3).
+.\" prctl PR_SVE_GET_VL
+.TP
+.BR PR_SVE_GET_VL " (since Linux 4.15, only on arm64)"
+Get the thread's current SVE vector length configuration.
+.IP
+Arguments
+.IR arg2 ", " arg3 ", " arg4 " and " arg5
+are ignored.
+.IP
+Providing that the kernel and platform support SVE
+this operation always succeeds,
+returning a nonnegative value that describes the
+.I current
+configuration.
+The bits corresponding to
+.B PR_SVE_VL_LEN_MASK
+contain the currently configured vector length in bytes.
+The bit corresponding to
+.B PR_SVE_VL_INHERIT
+indicates whether the vector length will be inherited
+across
+.BR execve (2).
+.IP
+Note that there is no way to determine whether there is
+a pending vector length change that has not yet taken effect.
+.IP
+For more information, see the kernel source file
+.I Documentation/arm64/sve.rst
+.\"commit b693d0b372afb39432e1c49ad7b3454855bc6bed
+(or
+.I Documentation/arm64/sve.txt
+before Linux 5.3).
 .\"
 .\" prctl PR_TASK_PERF_EVENTS_DISABLE
 .TP
@@ -1534,6 +1676,8 @@ On success,
 .BR PR_GET_NO_NEW_PRIVS ,
 .BR PR_GET_SECUREBITS ,
 .BR PR_GET_SPECULATION_CTRL ,
+.BR PR_SVE_GET_VL ,
+.BR PR_SVE_SET_VL ,
 .BR PR_GET_THP_DISABLE ,
 .BR PR_GET_TIMING ,
 .BR PR_GET_TIMERSLACK ,
@@ -1817,6 +1961,22 @@ and unused arguments to
 .BR prctl ()
 are not 0.
 .TP
+.B EINVAL
+.I option
+is
+.B PR_SVE_SET_VL
+and the arguments are invalid or unsupported,
+or SVE is not available on this platform.
+See the description of
+.B PR_SVE_SET_VL
+above for details.
+.TP
+.B EINVAL
+.I option
+is
+.B PR_SVE_GET_VL
+and SVE is not available on this platform.
+.TP
 .B ENODEV
 .I option
 was
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

A message that is not in the archive (sent off-list or not yet received): 77b02e4a-bfcf-90ef-90ca-73e878b7b649-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#16 lore raw

Re: [PATCH v2 4/6] prctl.2: Add SVE prctls (arm64)

Quoted 9 lines · Michael Kerrisk (man-pages)

Hi Dave,

I've not applied this patch yet, in case you want to make some changes in response to Will's comments.

I think all of the rest of the patches in the series are now applied (and pushed to master).

Thanks,

Ack, thanks
---Dave

#17 lore raw

RFC PATCH v2 6/6 prctl.2: Add tagged address ABI control prctls (arm64)

In reply to a message not in the archive

** This patch is a draft for review and should not be applied before it
has been discussed. **

Add documentation for the the PR_SET_TAGGED_ADDR_CTRL and PR_GET_TAGGED_ADDR_CTRL prctls added in Linux 5.4 for arm64.

Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc Vincenzo Frascino <[email protected]>

---

 man2/prctl.2 | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 156 insertions(+)
man2/prctl.2 +156 -0
index 3ee2702..062fd51 100644
@@ -1504,6 +1504,143 @@ For more information, see the kernel source file
 (or
 .I Documentation/arm64/sve.txt
 before Linux 5.3).
+.\" prctl PR_SET_TAGGED_ADDR_CTRL
+.\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d
+.TP
+.BR PR_SET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)"
+Controls support for passing tagged userspace addresses to the kernel
+(i.e., addresses where bits 56\(em63 are not all zero).
+.IP
+The level of support is selected by
+.IR "(unsigned int) arg2" ,
+which can be one of the following:
+.RS
+.TP
+.B 0
+Addresses that are passed
+for the purpose of being dereferenced by the kernel
+must be untagged.
+.TP
+.B PR_TAGGED_ADDR_ENABLE
+Addresses that are passed
+for the purpose of being dereferenced by the kernel
+may be tagged, with the exceptions summarized below.
+.RE
+.IP
+The remaining arguments
+.IR arg3 ", " arg4 " and " arg5
+must all be zero.
+.IP
+On success, the mode specified in
+.I arg2
+is set for the calling thread and the the return value is 0.
+If the arguments are invalid,
+the mode specified in
+.I arg2
+is unrecognized,
+or if this feature is disabled or unsupported by the kernel,
+the call fails with
+.BR EINVAL .
+.IP
+In particular, if
+.BR prctl ( PR_SET_TAGGED_ADDR_CTRL ,
+0, 0, 0, 0)
+fails with
+.B EINVAL
+then all addresses passed to the kernel must be untagged.
+.IP
+Irrespective of which mode is set,
+addresses passed to certain interfaces
+must always be untagged:
+.RS
+.IP \(em
+.BR brk (2),
+.BR mmap (2),
+.BR shmat (2),
+and the
+.I new_address
+argument of
+.BR mremap (2).
+.IP
+(Prior to Linux 5.6 these accepted tagged addresses,
+but the behaviour may not be what you expect.
+Don't rely on it.)
+.IP \(em
+\(oqpolymorphic\(cq interfaces
+that accept pointers to arbitrary types cast to a
+.I void *
+or other generic type, specifically
+.BR prctl (2),
+.BR ioctl (2),
+and in general
+.BR setsockopt (2)
+(only certain specific
+.BR setsockopt (2)
+options allow tagged addresses).
+.IP \(em
+.BR shmdt (2).
+.RE
+.IP
+This list of exclusions may shrink
+when moving from one kernel version to a later kernel version.
+While the kernel may make some guarantees
+for backwards compatibility reasons,
+for the purposes of new software
+the effect of passing tagged addresses to these interfaces
+is unspecified.
+.IP
+The mode set by this call is inherited across
+.BR fork (2)
+and
+.BR clone (2).
+The mode is reset by
+.BR execve (2)
+to 0
+(i.e., tagged addresses not permitted in the user/kernel ABI).
+.IP
+.B Warning:
+Because the compiler or run-time environment
+may make use of address tagging,
+a successful
+.B PR_SET_TAGGED_ADDR_CTRL
+may crash the calling process.
+The conditions for using it safely are complex and system-dependent.
+Don't use it unless you know what you are doing.
+.IP
+For more information, see the kernel source file
+.IR Documentation/arm64/tagged\-address\-abi.rst .
+.\" prctl PR_GET_TAGGED_ADDR_CTRL
+.\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d
+.TP
+.BR PR_GET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)"
+Returns the current tagged address mode
+for the calling thread.
+.IP
+Arguments
+.IR arg2 ", " arg3 ", " arg4 " and " arg5
+must all be zero.
+.IP
+If the arguments are invalid
+or this feature is disabled or unsupported by the kernel,
+the call fails with
+.BR EINVAL .
+In particular, if
+.BR prctl ( PR_GET_TAGGED_ADDR_CTRL ,
+0, 0, 0, 0)
+fails with
+.BR EINVAL ,
+then this feature is definitely unsupported or disabled,
+and all addresses passed to the kernel must be untagged.
+.IP
+Otherwise, the call returns a nonnegative value
+describing the current tagged address mode,
+encoded in the same way as the
+.I arg2
+argument of
+.BR PR_SET_TAGGED_ADDR_CTRL .
+.IP
+For more information, see the kernel source file
+.IR Documentation/arm64/tagged\-address\-abi.rst .
 .\"
 .\" prctl PR_TASK_PERF_EVENTS_DISABLE
 .TP
@@ -1749,6 +1886,7 @@ On success,
 .BR PR_GET_SPECULATION_CTRL ,
 .BR PR_SVE_GET_VL ,
 .BR PR_SVE_SET_VL ,
+.BR PR_GET_TAGGED_ADDR_CTRL ,
 .BR PR_GET_THP_DISABLE ,
 .BR PR_GET_TIMING ,
 .BR PR_GET_TIMERSLACK ,
@@ -2057,6 +2195,24 @@ is
 .B PR_SVE_GET_VL
 and SVE is not available on this platform.
 .TP
+.B EINVAL
+.I option
+is
+.BR PR_SET_TAGGED_ADDR_CTRL
+and the arguments are invalid or unsupported.
+See the description of
+.B PR_SET_TAGGED_ADDR_CTRL
+above for details.
+.TP
+.B EINVAL
+.I option
+is
+.BR PR_GET_TAGGED_ADDR_CTRL
+and the arguments are invalid or unsupported.
+See the description of
+.B PR_GET_TAGGED_ADDR_CTRL
+above for details.
+.TP
 .B ENODEV
 .I option
 was
Signature · 1 line
2.1.4

A message that is not in the archive (sent off-list or not yet received): 1590614258-24728-7-git-send-email-Dave.Martin-5wv7dgnIgG8@public.gmane.org

#19 lore raw

Re: [RFC PATCH v2 6/6] prctl.2: Add tagged address ABI control prctls (arm64)

Hey folks,

Do we have any review comments for this (extensive!) patch from Dave?

Cheers,

Michael

Quoted 197 lines · Dave Martin

** This patch is a draft for review and should not be applied before it
has been discussed. **

Add documentation for the the PR_SET_TAGGED_ADDR_CTRL and PR_GET_TAGGED_ADDR_CTRL prctls added in Linux 5.4 for arm64.

Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc Vincenzo Frascino <[email protected]>

---

 man2/prctl.2 | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 156 insertions(+)
man2/prctl.2 +156 -0
index 3ee2702..062fd51 100644
@@ -1504,6 +1504,143 @@ For more information, see the kernel source file
 (or
 .I Documentation/arm64/sve.txt
 before Linux 5.3).
+.\" prctl PR_SET_TAGGED_ADDR_CTRL
+.\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d
+.TP
+.BR PR_SET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)"
+Controls support for passing tagged userspace addresses to the kernel
+(i.e., addresses where bits 56\(em63 are not all zero).
+.IP
+The level of support is selected by
+.IR "(unsigned int) arg2" ,
+which can be one of the following:
+.RS
+.TP
+.B 0
+Addresses that are passed
+for the purpose of being dereferenced by the kernel
+must be untagged.
+.TP
+.B PR_TAGGED_ADDR_ENABLE
+Addresses that are passed
+for the purpose of being dereferenced by the kernel
+may be tagged, with the exceptions summarized below.
+.RE
+.IP
+The remaining arguments
+.IR arg3 ", " arg4 " and " arg5
+must all be zero.
+.IP
+On success, the mode specified in
+.I arg2
+is set for the calling thread and the the return value is 0.
+If the arguments are invalid,
+the mode specified in
+.I arg2
+is unrecognized,
+or if this feature is disabled or unsupported by the kernel,
+the call fails with
+.BR EINVAL .
+.IP
+In particular, if
+.BR prctl ( PR_SET_TAGGED_ADDR_CTRL ,
+0, 0, 0, 0)
+fails with
+.B EINVAL
+then all addresses passed to the kernel must be untagged.
+.IP
+Irrespective of which mode is set,
+addresses passed to certain interfaces
+must always be untagged:
+.RS
+.IP \(em
+.BR brk (2),
+.BR mmap (2),
+.BR shmat (2),
+and the
+.I new_address
+argument of
+.BR mremap (2).
+.IP
+(Prior to Linux 5.6 these accepted tagged addresses,
+but the behaviour may not be what you expect.
+Don't rely on it.)
+.IP \(em
+\(oqpolymorphic\(cq interfaces
+that accept pointers to arbitrary types cast to a
+.I void *
+or other generic type, specifically
+.BR prctl (2),
+.BR ioctl (2),
+and in general
+.BR setsockopt (2)
+(only certain specific
+.BR setsockopt (2)
+options allow tagged addresses).
+.IP \(em
+.BR shmdt (2).
+.RE
+.IP
+This list of exclusions may shrink
+when moving from one kernel version to a later kernel version.
+While the kernel may make some guarantees
+for backwards compatibility reasons,
+for the purposes of new software
+the effect of passing tagged addresses to these interfaces
+is unspecified.
+.IP
+The mode set by this call is inherited across
+.BR fork (2)
+and
+.BR clone (2).
+The mode is reset by
+.BR execve (2)
+to 0
+(i.e., tagged addresses not permitted in the user/kernel ABI).
+.IP
+.B Warning:
+Because the compiler or run-time environment
+may make use of address tagging,
+a successful
+.B PR_SET_TAGGED_ADDR_CTRL
+may crash the calling process.
+The conditions for using it safely are complex and system-dependent.
+Don't use it unless you know what you are doing.
+.IP
+For more information, see the kernel source file
+.IR Documentation/arm64/tagged\-address\-abi.rst .
+.\" prctl PR_GET_TAGGED_ADDR_CTRL
+.\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d
+.TP
+.BR PR_GET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)"
+Returns the current tagged address mode
+for the calling thread.
+.IP
+Arguments
+.IR arg2 ", " arg3 ", " arg4 " and " arg5
+must all be zero.
+.IP
+If the arguments are invalid
+or this feature is disabled or unsupported by the kernel,
+the call fails with
+.BR EINVAL .
+In particular, if
+.BR prctl ( PR_GET_TAGGED_ADDR_CTRL ,
+0, 0, 0, 0)
+fails with
+.BR EINVAL ,
+then this feature is definitely unsupported or disabled,
+and all addresses passed to the kernel must be untagged.
+.IP
+Otherwise, the call returns a nonnegative value
+describing the current tagged address mode,
+encoded in the same way as the
+.I arg2
+argument of
+.BR PR_SET_TAGGED_ADDR_CTRL .
+.IP
+For more information, see the kernel source file
+.IR Documentation/arm64/tagged\-address\-abi.rst .
 .\"
 .\" prctl PR_TASK_PERF_EVENTS_DISABLE
 .TP
@@ -1749,6 +1886,7 @@ On success,
 .BR PR_GET_SPECULATION_CTRL ,
 .BR PR_SVE_GET_VL ,
 .BR PR_SVE_SET_VL ,
+.BR PR_GET_TAGGED_ADDR_CTRL ,
 .BR PR_GET_THP_DISABLE ,
 .BR PR_GET_TIMING ,
 .BR PR_GET_TIMERSLACK ,
@@ -2057,6 +2195,24 @@ is
 .B PR_SVE_GET_VL
 and SVE is not available on this platform.
 .TP
+.B EINVAL
+.I option
+is
+.BR PR_SET_TAGGED_ADDR_CTRL
+and the arguments are invalid or unsupported.
+See the description of
+.B PR_SET_TAGGED_ADDR_CTRL
+above for details.
+.TP
+.B EINVAL
+.I option
+is
+.BR PR_GET_TAGGED_ADDR_CTRL
+and the arguments are invalid or unsupported.
+See the description of
+.B PR_GET_TAGGED_ADDR_CTRL
+above for details.
+.TP
 .B ENODEV
 .I option
 was
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

A message that is not in the archive (sent off-list or not yet received): 88ac761e-64b3-e1e3-3cdc-1f413a6d69d6-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#21 lore raw

Re: [RFC PATCH v2 6/6] prctl.2: Add tagged address ABI control prctls (arm64)

Quoted 1 line · Michael Kerrisk (man-pages)

Do we have any review comments for this (extensive!) patch from Dave?

(Adding Andrey, since he was involved with this ABI)

Regardless, it would be good to have Catalin's ack and I think he was planning to take a look at this.

Will

Quoted 204 lines · Dave Martin
Quoted 197 lines

** This patch is a draft for review and should not be applied before it
has been discussed. **

Add documentation for the the PR_SET_TAGGED_ADDR_CTRL and PR_GET_TAGGED_ADDR_CTRL prctls added in Linux 5.4 for arm64.

Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc Vincenzo Frascino <[email protected]>

---

 man2/prctl.2 | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 156 insertions(+)
man2/prctl.2 +156 -0
index 3ee2702..062fd51 100644
@@ -1504,6 +1504,143 @@ For more information, see the kernel source file
 (or
 .I Documentation/arm64/sve.txt
 before Linux 5.3).
+.\" prctl PR_SET_TAGGED_ADDR_CTRL
+.\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d
+.TP
+.BR PR_SET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)"
+Controls support for passing tagged userspace addresses to the kernel
+(i.e., addresses where bits 56\(em63 are not all zero).
+.IP
+The level of support is selected by
+.IR "(unsigned int) arg2" ,
+which can be one of the following:
+.RS
+.TP
+.B 0
+Addresses that are passed
+for the purpose of being dereferenced by the kernel
+must be untagged.
+.TP
+.B PR_TAGGED_ADDR_ENABLE
+Addresses that are passed
+for the purpose of being dereferenced by the kernel
+may be tagged, with the exceptions summarized below.
+.RE
+.IP
+The remaining arguments
+.IR arg3 ", " arg4 " and " arg5
+must all be zero.
+.IP
+On success, the mode specified in
+.I arg2
+is set for the calling thread and the the return value is 0.
+If the arguments are invalid,
+the mode specified in
+.I arg2
+is unrecognized,
+or if this feature is disabled or unsupported by the kernel,
+the call fails with
+.BR EINVAL .
+.IP
+In particular, if
+.BR prctl ( PR_SET_TAGGED_ADDR_CTRL ,
+0, 0, 0, 0)
+fails with
+.B EINVAL
+then all addresses passed to the kernel must be untagged.
+.IP
+Irrespective of which mode is set,
+addresses passed to certain interfaces
+must always be untagged:
+.RS
+.IP \(em
+.BR brk (2),
+.BR mmap (2),
+.BR shmat (2),
+and the
+.I new_address
+argument of
+.BR mremap (2).
+.IP
+(Prior to Linux 5.6 these accepted tagged addresses,
+but the behaviour may not be what you expect.
+Don't rely on it.)
+.IP \(em
+\(oqpolymorphic\(cq interfaces
+that accept pointers to arbitrary types cast to a
+.I void *
+or other generic type, specifically
+.BR prctl (2),
+.BR ioctl (2),
+and in general
+.BR setsockopt (2)
+(only certain specific
+.BR setsockopt (2)
+options allow tagged addresses).
+.IP \(em
+.BR shmdt (2).
+.RE
+.IP
+This list of exclusions may shrink
+when moving from one kernel version to a later kernel version.
+While the kernel may make some guarantees
+for backwards compatibility reasons,
+for the purposes of new software
+the effect of passing tagged addresses to these interfaces
+is unspecified.
+.IP
+The mode set by this call is inherited across
+.BR fork (2)
+and
+.BR clone (2).
+The mode is reset by
+.BR execve (2)
+to 0
+(i.e., tagged addresses not permitted in the user/kernel ABI).
+.IP
+.B Warning:
+Because the compiler or run-time environment
+may make use of address tagging,
+a successful
+.B PR_SET_TAGGED_ADDR_CTRL
+may crash the calling process.
+The conditions for using it safely are complex and system-dependent.
+Don't use it unless you know what you are doing.
+.IP
+For more information, see the kernel source file
+.IR Documentation/arm64/tagged\-address\-abi.rst .
+.\" prctl PR_GET_TAGGED_ADDR_CTRL
+.\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d
+.TP
+.BR PR_GET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)"
+Returns the current tagged address mode
+for the calling thread.
+.IP
+Arguments
+.IR arg2 ", " arg3 ", " arg4 " and " arg5
+must all be zero.
+.IP
+If the arguments are invalid
+or this feature is disabled or unsupported by the kernel,
+the call fails with
+.BR EINVAL .
+In particular, if
+.BR prctl ( PR_GET_TAGGED_ADDR_CTRL ,
+0, 0, 0, 0)
+fails with
+.BR EINVAL ,
+then this feature is definitely unsupported or disabled,
+and all addresses passed to the kernel must be untagged.
+.IP
+Otherwise, the call returns a nonnegative value
+describing the current tagged address mode,
+encoded in the same way as the
+.I arg2
+argument of
+.BR PR_SET_TAGGED_ADDR_CTRL .
+.IP
+For more information, see the kernel source file
+.IR Documentation/arm64/tagged\-address\-abi.rst .
 .\"
 .\" prctl PR_TASK_PERF_EVENTS_DISABLE
 .TP
@@ -1749,6 +1886,7 @@ On success,
 .BR PR_GET_SPECULATION_CTRL ,
 .BR PR_SVE_GET_VL ,
 .BR PR_SVE_SET_VL ,
+.BR PR_GET_TAGGED_ADDR_CTRL ,
 .BR PR_GET_THP_DISABLE ,
 .BR PR_GET_TIMING ,
 .BR PR_GET_TIMERSLACK ,
@@ -2057,6 +2195,24 @@ is
 .B PR_SVE_GET_VL
 and SVE is not available on this platform.
 .TP
+.B EINVAL
+.I option
+is
+.BR PR_SET_TAGGED_ADDR_CTRL
+and the arguments are invalid or unsupported.
+See the description of
+.B PR_SET_TAGGED_ADDR_CTRL
+above for details.
+.TP
+.B EINVAL
+.I option
+is
+.BR PR_GET_TAGGED_ADDR_CTRL
+and the arguments are invalid or unsupported.
+See the description of
+.B PR_GET_TAGGED_ADDR_CTRL
+above for details.
+.TP
 .B ENODEV
 .I option
 was
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#22 lore raw

Re: [RFC PATCH v2 6/6] prctl.2: Add tagged address ABI control prctls (arm64)

In reply to Dave Martin

Hi Dave,

man2/prctl.2 For more information, see the kernel source file · line 1512

Quoted 12 lines · Dave P Martin
man2/prctl.2 +6 -0
@@ -1504,6 +1504,143 @@ For more information, see the kernel source file
 (or
 .I Documentation/arm64/sve.txt
 before Linux 5.3).
+.\" prctl PR_SET_TAGGED_ADDR_CTRL
+.\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d
+.TP
+.BR PR_SET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)"
+Controls support for passing tagged userspace addresses to the kernel
+(i.e., addresses where bits 56\(em63 are not all zero).

Nitpick: maybe say "userspace addresses" again inside the brackets since kernel addresses have all top bits 1.

man2/prctl.2 For more information, see the kernel source file · line 1515

Quoted 3 lines
man2/prctl.2 +3 -0
+.IP
+The level of support is selected by
+.IR "(unsigned int) arg2" ,

We use (unsigned long) for arg2.

Quoted 7 lines
man2/prctl.2 +7 -0
+which can be one of the following:
+.RS
+.TP
+.B 0
+Addresses that are passed
+for the purpose of being dereferenced by the kernel
+must be untagged.

man2/prctl.2 For more information, see the kernel source file · line 1532

Quoted 10 lines
man2/prctl.2 +10 -0
+.TP
+.B PR_TAGGED_ADDR_ENABLE
+Addresses that are passed
+for the purpose of being dereferenced by the kernel
+may be tagged, with the exceptions summarized below.
+.RE
+.IP
+The remaining arguments
+.IR arg3 ", " arg4 " and " arg5
+must all be zero.

Indeed. The above commit didn't have this, we added it later in commit 3e91ec89f527b9870fe42dcbdb74fd389d123a95.

Quoted 12 lines
man2/prctl.2 +12 -0
+.IP
+On success, the mode specified in
+.I arg2
+is set for the calling thread and the the return value is 0.
+If the arguments are invalid,
+the mode specified in
+.I arg2
+is unrecognized,
+or if this feature is disabled or unsupported by the kernel,
+the call fails with
+.BR EINVAL .
+.IP

man2/prctl.2 For more information, see the kernel source file · line 1554

Quoted 10 lines
man2/prctl.2 +10 -0
+In particular, if
+.BR prctl ( PR_SET_TAGGED_ADDR_CTRL ,
+0, 0, 0, 0)
+fails with
+.B EINVAL
+then all addresses passed to the kernel must be untagged.
+.IP
+Irrespective of which mode is set,
+addresses passed to certain interfaces
+must always be untagged:

Maybe you could add some extra info from the kernel comment (commit b2a84de2a2deb76a6a51609845341f508c518c03) along the lines of "... to avoid the creation of aliasing mappings in userspace).

man2/prctl.2 For more information, see the kernel source file · line 1567

Quoted 13 lines
man2/prctl.2 +13 -0
+.RS
+.IP \(em
+.BR brk (2),
+.BR mmap (2),
+.BR shmat (2),
+and the
+.I new_address
+argument of
+.BR mremap (2).
+.IP
+(Prior to Linux 5.6 these accepted tagged addresses,
+but the behaviour may not be what you expect.
+Don't rely on it.)

shmat() was not part of the subsequent fix (dcde237319e626d1ec3c9d8b7613032f0fd4663a), it always rejected tagged address. But I guess it doesn't matter much, the user should not pass tagged addresses to these syscalls anyway.

You could move shmat() down together with shmdt().

Quoted 29 lines
man2/prctl.2 +29 -0
+.IP \(em
+\(oqpolymorphic\(cq interfaces
+that accept pointers to arbitrary types cast to a
+.I void *
+or other generic type, specifically
+.BR prctl (2),
+.BR ioctl (2),
+and in general
+.BR setsockopt (2)
+(only certain specific
+.BR setsockopt (2)
+options allow tagged addresses).
+.IP \(em
+.BR shmdt (2).
+.RE
+.IP
+This list of exclusions may shrink
+when moving from one kernel version to a later kernel version.
+While the kernel may make some guarantees
+for backwards compatibility reasons,
+for the purposes of new software
+the effect of passing tagged addresses to these interfaces
+is unspecified.
+.IP
+The mode set by this call is inherited across
+.BR fork (2)
+and
+.BR clone (2).
+The mode is reset by

man2/prctl.2 For more information, see the kernel source file · line 1606

Quoted 10 lines
man2/prctl.2 +10 -0
+.BR execve (2)
+to 0
+(i.e., tagged addresses not permitted in the user/kernel ABI).
+.IP
+.B Warning:
+Because the compiler or run-time environment
+may make use of address tagging,
+a successful
+.B PR_SET_TAGGED_ADDR_CTRL
+may crash the calling process.

I don't think PR_SET_TAGGED_ADDR_CTRL could crash the calling process. Rather disabling tagged addresses would break it. If a process is using tagged addresses but does not pass them to the kernel, it will continue to do so even when the syscalls accept such addresses.

man2/prctl.2 For more information, see the kernel source file · line 1608

Quoted 2 lines
man2/prctl.2 +2 -0
+The conditions for using it safely are complex and system-dependent.
+Don't use it unless you know what you are doing.

This syscall is intended for the C library if the heap allocator generates tagged addresses. So it's not a general purpose prctl() random application code could call. Anyway I'm fine with your warning of not doing it but you may want to clarify the intent.

Quoted 14 lines
man2/prctl.2 +14 -0
+.IP
+For more information, see the kernel source file
+.IR Documentation/arm64/tagged\-address\-abi.rst .
+.\" prctl PR_GET_TAGGED_ADDR_CTRL
+.\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d
+.TP
+.BR PR_GET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)"
+Returns the current tagged address mode
+for the calling thread.
+.IP
+Arguments
+.IR arg2 ", " arg3 ", " arg4 " and " arg5
+must all be zero.
+.IP

man2/prctl.2 For more information, see the kernel source file · line 1632

Quoted 10 lines
man2/prctl.2 +10 -0
+If the arguments are invalid
+or this feature is disabled or unsupported by the kernel,
+the call fails with
+.BR EINVAL .
+In particular, if
+.BR prctl ( PR_GET_TAGGED_ADDR_CTRL ,
+0, 0, 0, 0)
+fails with
+.BR EINVAL ,
+then this feature is definitely unsupported or disabled,

I guess it's outside the scope of the prctl.2 to describe how the feature was disabled (e.g. sysctl).

Quoted 37 lines
man2/prctl.2 +23 -0
+and all addresses passed to the kernel must be untagged.
+.IP
+Otherwise, the call returns a nonnegative value
+describing the current tagged address mode,
+encoded in the same way as the
+.I arg2
+argument of
+.BR PR_SET_TAGGED_ADDR_CTRL .
+.IP
+For more information, see the kernel source file
+.IR Documentation/arm64/tagged\-address\-abi.rst .
 .\"
 .\" prctl PR_TASK_PERF_EVENTS_DISABLE
 .TP
@@ -1749,6 +1886,7 @@ On success,
 .BR PR_GET_SPECULATION_CTRL ,
 .BR PR_SVE_GET_VL ,
 .BR PR_SVE_SET_VL ,
+.BR PR_GET_TAGGED_ADDR_CTRL ,
 .BR PR_GET_THP_DISABLE ,
 .BR PR_GET_TIMING ,
 .BR PR_GET_TIMERSLACK ,
@@ -2057,6 +2195,24 @@ is
 .B PR_SVE_GET_VL
 and SVE is not available on this platform.
 .TP
+.B EINVAL
+.I option
+is
+.BR PR_SET_TAGGED_ADDR_CTRL
+and the arguments are invalid or unsupported.
+See the description of
+.B PR_SET_TAGGED_ADDR_CTRL
+above for details.
+.TP
+.B EINVAL
+.I option

man2/prctl.2 is · line 2218

Quoted 10 lines
man2/prctl.2 +7 -0
+is
+.BR PR_GET_TAGGED_ADDR_CTRL
+and the arguments are invalid or unsupported.
+See the description of
+.B PR_GET_TAGGED_ADDR_CTRL
+above for details.
+.TP
 .B ENODEV
 .I option
 was

Apart from some minor nits above, the documentation looks fine.

Thanks for writing this up.

Signature · 1 line
Catalin

A message that is not in the archive (sent off-list or not yet received): 20200609172232.GA63286-ryiLQoaaaizILnBEAk/[email protected]

#24 lore raw

Re: [RFC PATCH v2 6/6] prctl.2: Add tagged address ABI control prctls (arm64)

Quoted 18 lines · Catalin Marinas

Hi Dave,

man2/prctl.2 For more information, see the kernel source file · line 1512

Quoted 12 lines · Dave P Martin
man2/prctl.2 +6 -0
@@ -1504,6 +1504,143 @@ For more information, see the kernel source file
 (or
 .I Documentation/arm64/sve.txt
 before Linux 5.3).
+.\" prctl PR_SET_TAGGED_ADDR_CTRL
+.\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d
+.TP
+.BR PR_SET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)"
+Controls support for passing tagged userspace addresses to the kernel
+(i.e., addresses where bits 56\(em63 are not all zero).

Nitpick: maybe say "userspace addresses" again inside the brackets since kernel addresses have all top bits 1.

Happy to do that. This is a user-facing interface though: userspace addresses are the only kind of address there is.

Quoted 6 lines

man2/prctl.2 For more information, see the kernel source file · line 1515

Quoted 4 lines
man2/prctl.2 +3 -0
+.IP
+The level of support is selected by
+.IR "(unsigned int) arg2" ,

We use (unsigned long) for arg2.

Hmmm, not quite sure how I came up with unsigned int here. I'll just drop this: the type in the prctl() prototype is unsigned long anyway.

The type is actually moot in this case, since the valid values all fit in an unsigned int.

Quoted 12 lines
Quoted 12 lines
man2/prctl.2 +12 -0
+which can be one of the following:
+.RS
+.TP
+.B 0
+Addresses that are passed
+for the purpose of being dereferenced by the kernel
+must be untagged.
+.TP
+.B PR_TAGGED_ADDR_ENABLE
+Addresses that are passed
+for the purpose of being dereferenced by the kernel
+may be tagged, with the exceptions summarized below.
Quoted 8 lines

man2/prctl.2 For more information, see the kernel source file · line 1532

Quoted 5 lines
man2/prctl.2 +5 -0
+.RE
+.IP
+The remaining arguments
+.IR arg3 ", " arg4 " and " arg5
+must all be zero.

Indeed. The above commit didn't have this, we added it later in commit 3e91ec89f527b9870fe42dcbdb74fd389d123a95.

Ah, missed that. Did any full kernel release expose the unchecked behaviour?

Mind you, there's probably no need to document in any case.

Quoted 19 lines
Quoted 19 lines
man2/prctl.2 +18 -0
+.IP
+On success, the mode specified in
+.I arg2
+is set for the calling thread and the the return value is 0.
+If the arguments are invalid,
+the mode specified in
+.I arg2
+is unrecognized,
+or if this feature is disabled or unsupported by the kernel,
+the call fails with
+.BR EINVAL .
+.IP
+In particular, if
+.BR prctl ( PR_SET_TAGGED_ADDR_CTRL ,
+0, 0, 0, 0)
+fails with
+.B EINVAL
+then all addresses passed to the kernel must be untagged.
Quoted 8 lines

man2/prctl.2 For more information, see the kernel source file · line 1554

Quoted 4 lines
man2/prctl.2 +4 -0
+.IP
+Irrespective of which mode is set,
+addresses passed to certain interfaces
+must always be untagged:

Maybe you could add some extra info from the kernel comment (commit b2a84de2a2deb76a6a51609845341f508c518c03) along the lines of "... to avoid the creation of aliasing mappings in userspace).

It depends. It's useful if it helps people to guess highly accurately the rule for in interface that is too new or that we don't explicitly document (such as a random setsockopt or perf widget).

If not, it might be best to say nothing and make guarantees only about the explicitly listed interfaces though.

What do you think?

Quoted 19 lines

man2/prctl.2 For more information, see the kernel source file · line 1567

Quoted 13 lines
man2/prctl.2 +13 -0
+.RS
+.IP \(em
+.BR brk (2),
+.BR mmap (2),
+.BR shmat (2),
+and the
+.I new_address
+argument of
+.BR mremap (2).
+.IP
+(Prior to Linux 5.6 these accepted tagged addresses,
+but the behaviour may not be what you expect.
+Don't rely on it.)

shmat() was not part of the subsequent fix (dcde237319e626d1ec3c9d8b7613032f0fd4663a), it always rejected tagged address. But I guess it doesn't matter much, the user should not pass tagged addresses to these syscalls anyway.

Quoted 1 line

You could move shmat() down together with shmdt().

I guess I was highlighting that shmdt() is a special case, because the user would guess from the pattern of the other listed calls that shmdt() should accept tagged addresses. If you think separating it just adds to the confusion, I'm happy not too call it out specially here.

OTOH, we could fix shmdt() and document the legacy behaviour as a bug in specific kernel versions rather than the canonical behaviour. But I guess that's one for later.

Quoted 34 lines
Quoted 34 lines
man2/prctl.2 +34 -0
+.IP \(em
+\(oqpolymorphic\(cq interfaces
+that accept pointers to arbitrary types cast to a
+.I void *
+or other generic type, specifically
+.BR prctl (2),
+.BR ioctl (2),
+and in general
+.BR setsockopt (2)
+(only certain specific
+.BR setsockopt (2)
+options allow tagged addresses).
+.IP \(em
+.BR shmdt (2).
+.RE
+.IP
+This list of exclusions may shrink
+when moving from one kernel version to a later kernel version.
+While the kernel may make some guarantees
+for backwards compatibility reasons,
+for the purposes of new software
+the effect of passing tagged addresses to these interfaces
+is unspecified.
+.IP
+The mode set by this call is inherited across
+.BR fork (2)
+and
+.BR clone (2).
+The mode is reset by
+.BR execve (2)
+to 0
+(i.e., tagged addresses not permitted in the user/kernel ABI).
+.IP
+.B Warning:
Quoted 8 lines

man2/prctl.2 For more information, see the kernel source file · line 1606

Quoted 5 lines
man2/prctl.2 +5 -0
+Because the compiler or run-time environment
+may make use of address tagging,
+a successful
+.B PR_SET_TAGGED_ADDR_CTRL
+may crash the calling process.

I don't think PR_SET_TAGGED_ADDR_CTRL could crash the calling process. Rather disabling tagged addresses would break it. If a process is using

This is precisely how PR_SET_TAGGED_ADDR_CTRL could crash the calling process, no?

Rather than try to explain the different cases in detail here and have the reader take it as gospel, I thought it would be better to scare them a bit and encourage them to so some homework. Perhaps I'm being too cautious.

Quoted 10 lines

tagged addresses but does not pass them to the kernel, it will continue to do so even when the syscalls accept such addresses.

man2/prctl.2 For more information, see the kernel source file · line 1608

Quoted 2 lines
man2/prctl.2 +2 -0
+The conditions for using it safely are complex and system-dependent.
+Don't use it unless you know what you are doing.

This syscall is intended for the C library if the heap allocator generates tagged addresses. So it's not a general purpose prctl() random application code could call. Anyway I'm fine with your warning of not doing it but you may want to clarify the intent.

Maybe add something like

"This call is primarily intended for use by the run-time environment."

?

Quoted 20 lines
Quoted 20 lines
man2/prctl.2 +19 -0
+.IP
+For more information, see the kernel source file
+.IR Documentation/arm64/tagged\-address\-abi.rst .
+.\" prctl PR_GET_TAGGED_ADDR_CTRL
+.\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d
+.TP
+.BR PR_GET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)"
+Returns the current tagged address mode
+for the calling thread.
+.IP
+Arguments
+.IR arg2 ", " arg3 ", " arg4 " and " arg5
+must all be zero.
+.IP
+If the arguments are invalid
+or this feature is disabled or unsupported by the kernel,
+the call fails with
+.BR EINVAL .
+In particular, if
Quoted 8 lines

man2/prctl.2 For more information, see the kernel source file · line 1632

Quoted 5 lines
man2/prctl.2 +5 -0
+.BR prctl ( PR_GET_TAGGED_ADDR_CTRL ,
+0, 0, 0, 0)
+fails with
+.BR EINVAL ,
+then this feature is definitely unsupported or disabled,

I guess it's outside the scope of the prctl.2 to describe how the feature was disabled (e.g. sysctl).

We could include it here, but I'm thinking we might want a more comprehensive separate page to describe how to use MTE in general.

For now, is referencing the kernel documentation enough?

Quoted 50 lines
Quoted 37 lines
man2/prctl.2 +23 -0
+and all addresses passed to the kernel must be untagged.
+.IP
+Otherwise, the call returns a nonnegative value
+describing the current tagged address mode,
+encoded in the same way as the
+.I arg2
+argument of
+.BR PR_SET_TAGGED_ADDR_CTRL .
+.IP
+For more information, see the kernel source file
+.IR Documentation/arm64/tagged\-address\-abi.rst .
 .\"
 .\" prctl PR_TASK_PERF_EVENTS_DISABLE
 .TP
@@ -1749,6 +1886,7 @@ On success,
 .BR PR_GET_SPECULATION_CTRL ,
 .BR PR_SVE_GET_VL ,
 .BR PR_SVE_SET_VL ,
+.BR PR_GET_TAGGED_ADDR_CTRL ,
 .BR PR_GET_THP_DISABLE ,
 .BR PR_GET_TIMING ,
 .BR PR_GET_TIMERSLACK ,
@@ -2057,6 +2195,24 @@ is
 .B PR_SVE_GET_VL
 and SVE is not available on this platform.
 .TP
+.B EINVAL
+.I option
+is
+.BR PR_SET_TAGGED_ADDR_CTRL
+and the arguments are invalid or unsupported.
+See the description of
+.B PR_SET_TAGGED_ADDR_CTRL
+above for details.
+.TP
+.B EINVAL
+.I option

man2/prctl.2 is · line 2218

Quoted 10 lines
man2/prctl.2 +7 -0
+is
+.BR PR_GET_TAGGED_ADDR_CTRL
+and the arguments are invalid or unsupported.
+See the description of
+.B PR_GET_TAGGED_ADDR_CTRL
+above for details.
+.TP
 .B ENODEV
 .I option
 was

Apart from some minor nits above, the documentation looks fine.

Quoted 1 line

Thanks for writing this up.

Thanks for the review. I was taking a punt on some of it, so I'm reassured that you didn't find too many controversial points.

Cheers
---Dave

A message that is not in the archive (sent off-list or not yet received): [email protected]

Reviewed-by
#26 lore raw

Re: [RFC PATCH v2 6/6] prctl.2: Add tagged address ABI control prctls (arm64)

Quoted 18 lines · Dave P Martin
Quoted 16 lines · Catalin Marinas

man2/prctl.2 For more information, see the kernel source file · line 1512

Quoted 12 lines · Dave P Martin
man2/prctl.2 +6 -0
@@ -1504,6 +1504,143 @@ For more information, see the kernel source file
 (or
 .I Documentation/arm64/sve.txt
 before Linux 5.3).
+.\" prctl PR_SET_TAGGED_ADDR_CTRL
+.\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d
+.TP
+.BR PR_SET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)"
+Controls support for passing tagged userspace addresses to the kernel
+(i.e., addresses where bits 56\(em63 are not all zero).

Nitpick: maybe say "userspace addresses" again inside the brackets since kernel addresses have all top bits 1.

Quoted 2 lines

Happy to do that. This is a user-facing interface though: userspace addresses are the only kind of address there is.

Living in the kernel land for too long, it's hard to switch perspective ;). I think the original sentence makes sense anyway, it should be obvious that it refers to user addresses.

Quoted 11 lines
Quoted 5 lines

man2/prctl.2 For more information, see the kernel source file · line 1515

Quoted 3 lines
man2/prctl.2 +3 -0
+.IP
+The level of support is selected by
+.IR "(unsigned int) arg2" ,

We use (unsigned long) for arg2.

Hmmm, not quite sure how I came up with unsigned int here. I'll just drop this: the type in the prctl() prototype is unsigned long anyway.

The type is actually moot in this case, since the valid values all fit in an unsigned int.

Passing an int doesn't require that the top 32-bit of the long are zeroed (in case anyone writes the low-level SVC by hand).

Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
man2/prctl.2 +12 -0
+which can be one of the following:
+.RS
+.TP
+.B 0
+Addresses that are passed
+for the purpose of being dereferenced by the kernel
+must be untagged.
+.TP
+.B PR_TAGGED_ADDR_ENABLE
+Addresses that are passed
+for the purpose of being dereferenced by the kernel
+may be tagged, with the exceptions summarized below.
Quoted 8 lines

man2/prctl.2 For more information, see the kernel source file · line 1532

Quoted 5 lines
man2/prctl.2 +5 -0
+.RE
+.IP
+The remaining arguments
+.IR arg3 ", " arg4 " and " arg5
+must all be zero.

Indeed. The above commit didn't have this, we added it later in commit 3e91ec89f527b9870fe42dcbdb74fd389d123a95.

Quoted 2 lines

Ah, missed that. Did any full kernel release expose the unchecked behaviour?

No, they both went into 5.4-rc1. I probably didn't want to rebase the series and just added a patch on top.

Quoted 1 line

Mind you, there's probably no need to document in any case.

I agree. Just mentioned it because I looked at the commit you mentioned and there was no check for the arg3..arg5, so went to check the history.

Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
man2/prctl.2 +18 -0
+.IP
+On success, the mode specified in
+.I arg2
+is set for the calling thread and the the return value is 0.
+If the arguments are invalid,
+the mode specified in
+.I arg2
+is unrecognized,
+or if this feature is disabled or unsupported by the kernel,
+the call fails with
+.BR EINVAL .
+.IP
+In particular, if
+.BR prctl ( PR_SET_TAGGED_ADDR_CTRL ,
+0, 0, 0, 0)
+fails with
+.B EINVAL
+then all addresses passed to the kernel must be untagged.
Quoted 8 lines

man2/prctl.2 For more information, see the kernel source file · line 1554

Quoted 4 lines
man2/prctl.2 +4 -0
+.IP
+Irrespective of which mode is set,
+addresses passed to certain interfaces
+must always be untagged:

Maybe you could add some extra info from the kernel comment (commit b2a84de2a2deb76a6a51609845341f508c518c03) along the lines of "... to avoid the creation of aliasing mappings in userspace).

Quoted 6 lines

It depends. It's useful if it helps people to guess highly accurately the rule for in interface that is too new or that we don't explicitly document (such as a random setsockopt or perf widget).

If not, it might be best to say nothing and make guarantees only about the explicitly listed interfaces though.

Fine by me to keep it as it is. We can always update the man page if new syscalls come into this category.

Quoted 21 lines
Quoted 19 lines

man2/prctl.2 For more information, see the kernel source file · line 1567

Quoted 13 lines
man2/prctl.2 +13 -0
+.RS
+.IP \(em
+.BR brk (2),
+.BR mmap (2),
+.BR shmat (2),
+and the
+.I new_address
+argument of
+.BR mremap (2).
+.IP
+(Prior to Linux 5.6 these accepted tagged addresses,
+but the behaviour may not be what you expect.
+Don't rely on it.)

shmat() was not part of the subsequent fix (dcde237319e626d1ec3c9d8b7613032f0fd4663a), it always rejected tagged address. But I guess it doesn't matter much, the user should not pass tagged addresses to these syscalls anyway.

Quoted 1 line

You could move shmat() down together with shmdt().

Quoted 8 lines

I guess I was highlighting that shmdt() is a special case, because the user would guess from the pattern of the other listed calls that shmdt() should accept tagged addresses. If you think separating it just adds to the confusion, I'm happy not too call it out specially here.

OTOH, we could fix shmdt() and document the legacy behaviour as a bug in specific kernel versions rather than the canonical behaviour. But I guess that's one for later.

If we patch shmdt() to allow tagged addresses, then it makes sense to keep shmat() with the rest of the above. Just pointing out that shmat() never allowed tagged pointers

Quoted 43 lines
Quoted 34 lines
Quoted 34 lines
man2/prctl.2 +34 -0
+.IP \(em
+\(oqpolymorphic\(cq interfaces
+that accept pointers to arbitrary types cast to a
+.I void *
+or other generic type, specifically
+.BR prctl (2),
+.BR ioctl (2),
+and in general
+.BR setsockopt (2)
+(only certain specific
+.BR setsockopt (2)
+options allow tagged addresses).
+.IP \(em
+.BR shmdt (2).
+.RE
+.IP
+This list of exclusions may shrink
+when moving from one kernel version to a later kernel version.
+While the kernel may make some guarantees
+for backwards compatibility reasons,
+for the purposes of new software
+the effect of passing tagged addresses to these interfaces
+is unspecified.
+.IP
+The mode set by this call is inherited across
+.BR fork (2)
+and
+.BR clone (2).
+The mode is reset by
+.BR execve (2)
+to 0
+(i.e., tagged addresses not permitted in the user/kernel ABI).
+.IP
+.B Warning:
Quoted 8 lines

man2/prctl.2 For more information, see the kernel source file · line 1606

Quoted 5 lines
man2/prctl.2 +5 -0
+Because the compiler or run-time environment
+may make use of address tagging,
+a successful
+.B PR_SET_TAGGED_ADDR_CTRL
+may crash the calling process.

I don't think PR_SET_TAGGED_ADDR_CTRL could crash the calling process. Rather disabling tagged addresses would break it. If a process is using

Quoted 2 lines

This is precisely how PR_SET_TAGGED_ADDR_CTRL could crash the calling process, no?

I see your point. E.g. it was enabled by glibc but disabled by a user application.

Quoted 4 lines

Rather than try to explain the different cases in detail here and have the reader take it as gospel, I thought it would be better to scare them a bit and encourage them to so some homework. Perhaps I'm being too cautious.

That's fine, leave the warning in place.

Quoted 11 lines
Quoted 10 lines

tagged addresses but does not pass them to the kernel, it will continue to do so even when the syscalls accept such addresses.

man2/prctl.2 For more information, see the kernel source file · line 1608

Quoted 2 lines
man2/prctl.2 +2 -0
+The conditions for using it safely are complex and system-dependent.
+Don't use it unless you know what you are doing.

This syscall is intended for the C library if the heap allocator generates tagged addresses. So it's not a general purpose prctl() random application code could call. Anyway I'm fine with your warning of not doing it but you may want to clarify the intent.

Quoted 3 lines

Maybe add something like

"This call is primarily intended for use by the run-time environment."

That works as well, maybe in addition to the warning. Up to you.

Quoted 28 lines
Quoted 19 lines
Quoted 19 lines
man2/prctl.2 +19 -0
+.IP
+For more information, see the kernel source file
+.IR Documentation/arm64/tagged\-address\-abi.rst .
+.\" prctl PR_GET_TAGGED_ADDR_CTRL
+.\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d
+.TP
+.BR PR_GET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)"
+Returns the current tagged address mode
+for the calling thread.
+.IP
+Arguments
+.IR arg2 ", " arg3 ", " arg4 " and " arg5
+must all be zero.
+.IP
+If the arguments are invalid
+or this feature is disabled or unsupported by the kernel,
+the call fails with
+.BR EINVAL .
+In particular, if
Quoted 8 lines

man2/prctl.2 For more information, see the kernel source file · line 1632

Quoted 5 lines
man2/prctl.2 +5 -0
+.BR prctl ( PR_GET_TAGGED_ADDR_CTRL ,
+0, 0, 0, 0)
+fails with
+.BR EINVAL ,
+then this feature is definitely unsupported or disabled,

I guess it's outside the scope of the prctl.2 to describe how the feature was disabled (e.g. sysctl).

Quoted 4 lines

We could include it here, but I'm thinking we might want a more comprehensive separate page to describe how to use MTE in general.

For now, is referencing the kernel documentation enough?

I think simply saying "unsupported or disabled" is sufficient in the man page. The sysctl is not aimed at the user sw/run-time developers but rather those controlling the system. For the latter, the kernel documentation is sufficient.

So with the (unsigned int) fixed, feel free to add:

I don't have a strong opinion on the other nitpicks, so I'll leave the decision to you.

Signature · 1 line
Catalin
#27 lore raw

Re: [RFC PATCH v2 6/6] prctl.2: Add tagged address ABI control prctls (arm64)

Quoted 19 lines · Catalin Marinas
Quoted 18 lines · Dave P Martin
Quoted 16 lines · Catalin Marinas

man2/prctl.2 For more information, see the kernel source file · line 1512

Quoted 12 lines · Dave P Martin
man2/prctl.2 +6 -0
@@ -1504,6 +1504,143 @@ For more information, see the kernel source file
 (or
 .I Documentation/arm64/sve.txt
 before Linux 5.3).
+.\" prctl PR_SET_TAGGED_ADDR_CTRL
+.\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d
+.TP
+.BR PR_SET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)"
+Controls support for passing tagged userspace addresses to the kernel
+(i.e., addresses where bits 56\(em63 are not all zero).

Nitpick: maybe say "userspace addresses" again inside the brackets since kernel addresses have all top bits 1.

Quoted 6 lines
Quoted 2 lines

Happy to do that. This is a user-facing interface though: userspace addresses are the only kind of address there is.

Living in the kernel land for too long, it's hard to switch perspective ;). I think the original sentence makes sense anyway, it should be obvious that it refers to user addresses.

OK

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

man2/prctl.2 For more information, see the kernel source file · line 1515

Quoted 3 lines
man2/prctl.2 +3 -0
+.IP
+The level of support is selected by
+.IR "(unsigned int) arg2" ,

We use (unsigned long) for arg2.

Quoted 8 lines
Quoted 5 lines

Hmmm, not quite sure how I came up with unsigned int here. I'll just drop this: the type in the prctl() prototype is unsigned long anyway.

The type is actually moot in this case, since the valid values all fit in an unsigned int.

Passing an int doesn't require that the top 32-bit of the long are zeroed (in case anyone writes the low-level SVC by hand).

Fair point, I was forgetting that wrinkle. Anyway, the convention in this page seems to be that if the type is unsigned long, we don't mention it, because the prctl() prototype says that already.

Question: the glibc prototype for prctl is variadic, so surely any calls that don't explicitly cast the args to unsigned long are already theoretically broken? The #defines (and 0) are all implicitly int. This probably affects lots of prctls.

We may get away with it because the compiler is almost certainly going to favour a mov over a ldr for getting small integers into regs, and mov <Wd> fortunately zeroes the top bits for us anyway.

Seems icky though.

Quoted 24 lines
Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
man2/prctl.2 +12 -0
+which can be one of the following:
+.RS
+.TP
+.B 0
+Addresses that are passed
+for the purpose of being dereferenced by the kernel
+must be untagged.
+.TP
+.B PR_TAGGED_ADDR_ENABLE
+Addresses that are passed
+for the purpose of being dereferenced by the kernel
+may be tagged, with the exceptions summarized below.
Quoted 8 lines

man2/prctl.2 For more information, see the kernel source file · line 1532

Quoted 5 lines
man2/prctl.2 +5 -0
+.RE
+.IP
+The remaining arguments
+.IR arg3 ", " arg4 " and " arg5
+must all be zero.

Indeed. The above commit didn't have this, we added it later in commit 3e91ec89f527b9870fe42dcbdb74fd389d123a95.

Quoted 2 lines

Ah, missed that. Did any full kernel release expose the unchecked behaviour?

Quoted 7 lines

No, they both went into 5.4-rc1. I probably didn't want to rebase the series and just added a patch on top.

Quoted 1 line

Mind you, there's probably no need to document in any case.

I agree. Just mentioned it because I looked at the commit you mentioned and there was no check for the arg3..arg5, so went to check the history.

Ah, OK. We should keep quiet then, but I can add the commit reference as an internal comment in case anyone wants to check where the arg zeroing enforcement came from.

Quoted 32 lines
Quoted 32 lines
Quoted 19 lines
Quoted 19 lines
man2/prctl.2 +18 -0
+.IP
+On success, the mode specified in
+.I arg2
+is set for the calling thread and the the return value is 0.
+If the arguments are invalid,
+the mode specified in
+.I arg2
+is unrecognized,
+or if this feature is disabled or unsupported by the kernel,
+the call fails with
+.BR EINVAL .
+.IP
+In particular, if
+.BR prctl ( PR_SET_TAGGED_ADDR_CTRL ,
+0, 0, 0, 0)
+fails with
+.B EINVAL
+then all addresses passed to the kernel must be untagged.
Quoted 8 lines

man2/prctl.2 For more information, see the kernel source file · line 1554

Quoted 4 lines
man2/prctl.2 +4 -0
+.IP
+Irrespective of which mode is set,
+addresses passed to certain interfaces
+must always be untagged:

Maybe you could add some extra info from the kernel comment (commit b2a84de2a2deb76a6a51609845341f508c518c03) along the lines of "... to avoid the creation of aliasing mappings in userspace).

It depends. It's useful if it helps people to guess highly accurately the rule for in interface that is too new or that we don't explicitly document (such as a random setsockopt or perf widget).

Quoted 5 lines
Quoted 2 lines

If not, it might be best to say nothing and make guarantees only about the explicitly listed interfaces though.

Fine by me to keep it as it is. We can always update the man page if new syscalls come into this category.

OK, I'll probably keep it as-is for now, but shout if you change your mind!

Quoted 26 lines
Quoted 26 lines
Quoted 19 lines

man2/prctl.2 For more information, see the kernel source file · line 1567

Quoted 13 lines
man2/prctl.2 +13 -0
+.RS
+.IP \(em
+.BR brk (2),
+.BR mmap (2),
+.BR shmat (2),
+and the
+.I new_address
+argument of
+.BR mremap (2).
+.IP
+(Prior to Linux 5.6 these accepted tagged addresses,
+but the behaviour may not be what you expect.
+Don't rely on it.)

shmat() was not part of the subsequent fix (dcde237319e626d1ec3c9d8b7613032f0fd4663a), it always rejected tagged address. But I guess it doesn't matter much, the user should not pass tagged addresses to these syscalls anyway.

Quoted 1 line

You could move shmat() down together with shmdt().

I guess I was highlighting that shmdt() is a special case, because the user would guess from the pattern of the other listed calls that shmdt() should accept tagged addresses. If you think separating it just adds to the confusion, I'm happy not too call it out specially here.

Quoted 7 lines
Quoted 3 lines

OTOH, we could fix shmdt() and document the legacy behaviour as a bug in specific kernel versions rather than the canonical behaviour. But I guess that's one for later.

If we patch shmdt() to allow tagged addresses, then it makes sense to keep shmat() with the rest of the above. Just pointing out that shmat() never allowed tagged pointers

Oh, I see what you mean. I'll have a think when I revisit this.

[...]

Quoted 34 lines
Quoted 10 lines
Quoted 9 lines

man2/prctl.2 For more information, see the kernel source file · line 1606

Quoted 6 lines
man2/prctl.2 +6 -0
+.B Warning:
+Because the compiler or run-time environment
+may make use of address tagging,
+a successful
+.B PR_SET_TAGGED_ADDR_CTRL
+may crash the calling process.

I don't think PR_SET_TAGGED_ADDR_CTRL could crash the calling process. Rather disabling tagged addresses would break it. If a process is using

Quoted 2 lines

This is precisely how PR_SET_TAGGED_ADDR_CTRL could crash the calling process, no?

I see your point. E.g. it was enabled by glibc but disabled by a user application.

Quoted 4 lines

Rather than try to explain the different cases in detail here and have the reader take it as gospel, I thought it would be better to scare them a bit and encourage them to so some homework. Perhaps I'm being too cautious.

That's fine, leave the warning in place.

Quoted 11 lines
Quoted 10 lines

tagged addresses but does not pass them to the kernel, it will continue to do so even when the syscalls accept such addresses.

man2/prctl.2 For more information, see the kernel source file · line 1608

Quoted 2 lines
man2/prctl.2 +2 -0
+The conditions for using it safely are complex and system-dependent.
+Don't use it unless you know what you are doing.

This syscall is intended for the C library if the heap allocator generates tagged addresses. So it's not a general purpose prctl() random application code could call. Anyway I'm fine with your warning of not doing it but you may want to clarify the intent.

Quoted 5 lines
Quoted 3 lines

Maybe add something like

"This call is primarily intended for use by the run-time environment."

That works as well, maybe in addition to the warning. Up to you.

OK, I may try to add that, but I'll try not to go overboard!

Quoted 38 lines
Quoted 28 lines
Quoted 19 lines
Quoted 19 lines
man2/prctl.2 +19 -0
+.IP
+For more information, see the kernel source file
+.IR Documentation/arm64/tagged\-address\-abi.rst .
+.\" prctl PR_GET_TAGGED_ADDR_CTRL
+.\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d
+.TP
+.BR PR_GET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)"
+Returns the current tagged address mode
+for the calling thread.
+.IP
+Arguments
+.IR arg2 ", " arg3 ", " arg4 " and " arg5
+must all be zero.
+.IP
+If the arguments are invalid
+or this feature is disabled or unsupported by the kernel,
+the call fails with
+.BR EINVAL .
+In particular, if
Quoted 8 lines

man2/prctl.2 For more information, see the kernel source file · line 1632

Quoted 5 lines
man2/prctl.2 +5 -0
+.BR prctl ( PR_GET_TAGGED_ADDR_CTRL ,
+0, 0, 0, 0)
+fails with
+.BR EINVAL ,
+then this feature is definitely unsupported or disabled,

I guess it's outside the scope of the prctl.2 to describe how the feature was disabled (e.g. sysctl).

Quoted 4 lines

We could include it here, but I'm thinking we might want a more comprehensive separate page to describe how to use MTE in general.

For now, is referencing the kernel documentation enough?

I think simply saying "unsupported or disabled" is sufficient in the man page. The sysctl is not aimed at the user sw/run-time developers but rather those controlling the system. For the latter, the kernel documentation is sufficient.

Quoted 6 lines

So with the (unsigned int) fixed, feel free to add:

I don't have a strong opinion on the other nitpicks, so I'll leave the decision to you.

OK, thanks

---Dave

A message that is not in the archive (sent off-list or not yet received): [email protected]

#29 lore raw

Re: [RFC PATCH v2 6/6] prctl.2: Add tagged address ABI control prctls (arm64)

Quoted 23 lines · Dave P Martin
Quoted 9 lines · Catalin Marinas
Quoted 8 lines · Dave P Martin
Quoted 6 lines · Catalin Marinas
Quoted 3 lines · Dave P Martin

+.IP
+The level of support is selected by
+.IR "(unsigned int) arg2" ,

We use (unsigned long) for arg2.

Quoted 8 lines
Quoted 5 lines

Hmmm, not quite sure how I came up with unsigned int here. I'll just drop this: the type in the prctl() prototype is unsigned long anyway.

The type is actually moot in this case, since the valid values all fit in an unsigned int.

Passing an int doesn't require that the top 32-bit of the long are zeroed (in case anyone writes the low-level SVC by hand).

Fair point, I was forgetting that wrinkle. Anyway, the convention in this page seems to be that if the type is unsigned long, we don't mention it, because the prctl() prototype says that already.

Quoted 8 lines

Question: the glibc prototype for prctl is variadic, so surely any calls that don't explicitly cast the args to unsigned long are already theoretically broken? The #defines (and 0) are all implicitly int. This probably affects lots of prctls.

We may get away with it because the compiler is almost certainly going to favour a mov over a ldr for getting small integers into regs, and mov <Wd> fortunately zeroes the top bits for us anyway.

So does LDR Wd.

Anyway, I think glibc (or my reading of it) has something like like:

  register long _x1 asm ("x1") = _x1tmp;

before invoking the SVC. I assume this would do the right conversion to long. I can't tell about other libraries but I'd say it's their responsibility to convert the args to long before calling the kernel's prctl().

Signature · 1 line
Catalin
#30 lore raw

Re: [RFC PATCH v2 6/6] prctl.2: Add tagged address ABI control prctls (arm64)

Quoted 35 lines · Catalin Marinas
Quoted 23 lines · Dave P Martin
Quoted 9 lines · Catalin Marinas
Quoted 8 lines · Dave P Martin
Quoted 6 lines · Catalin Marinas
Quoted 3 lines · Dave P Martin

+.IP
+The level of support is selected by
+.IR "(unsigned int) arg2" ,

We use (unsigned long) for arg2.

Quoted 8 lines
Quoted 5 lines

Hmmm, not quite sure how I came up with unsigned int here. I'll just drop this: the type in the prctl() prototype is unsigned long anyway.

The type is actually moot in this case, since the valid values all fit in an unsigned int.

Passing an int doesn't require that the top 32-bit of the long are zeroed (in case anyone writes the low-level SVC by hand).

Fair point, I was forgetting that wrinkle. Anyway, the convention in this page seems to be that if the type is unsigned long, we don't mention it, because the prctl() prototype says that already.

Quoted 8 lines

Question: the glibc prototype for prctl is variadic, so surely any calls that don't explicitly cast the args to unsigned long are already theoretically broken? The #defines (and 0) are all implicitly int. This probably affects lots of prctls.

We may get away with it because the compiler is almost certainly going to favour a mov over a ldr for getting small integers into regs, and mov <Wd> fortunately zeroes the top bits for us anyway.

So does LDR Wd.

Quoted 8 lines

Anyway, I think glibc (or my reading of it) has something like like:

  register long _x1 asm ("x1") = _x1tmp;

before invoking the SVC. I assume this would do the right conversion to long. I can't tell about other libraries but I'd say it's their responsibility to convert the args to long before calling the kernel's prctl().

Ignore me. I was worrying that glibc would propagate junk in the high bits of int arguments, due to treating them as longs. Actually, it will, but it doesn't matter where we explicitly cast the argument to int inside the kernel (thanks as usual to -fno-strict-overflow).

Cheers
---Dave

A message that is not in the archive (sent off-list or not yet received): [email protected]

#32 lore raw

Re: [RFC PATCH v2 6/6] prctl.2: Add tagged address ABI control prctls (arm64)

Hi Dave

Is there a plan for future work on this patch?

Thanks,

Michael

Quoted 53 lines · Dave Martin
Quoted 35 lines · Catalin Marinas
Quoted 23 lines · Dave P Martin
Quoted 9 lines · Catalin Marinas
Quoted 8 lines · Dave P Martin
Quoted 6 lines · Catalin Marinas
Quoted 3 lines · Dave P Martin

+.IP
+The level of support is selected by
+.IR "(unsigned int) arg2" ,

We use (unsigned long) for arg2.

Quoted 8 lines
Quoted 5 lines

Hmmm, not quite sure how I came up with unsigned int here. I'll just drop this: the type in the prctl() prototype is unsigned long anyway.

The type is actually moot in this case, since the valid values all fit in an unsigned int.

Passing an int doesn't require that the top 32-bit of the long are zeroed (in case anyone writes the low-level SVC by hand).

Fair point, I was forgetting that wrinkle. Anyway, the convention in this page seems to be that if the type is unsigned long, we don't mention it, because the prctl() prototype says that already.

Quoted 8 lines

Question: the glibc prototype for prctl is variadic, so surely any calls that don't explicitly cast the args to unsigned long are already theoretically broken? The #defines (and 0) are all implicitly int. This probably affects lots of prctls.

We may get away with it because the compiler is almost certainly going to favour a mov over a ldr for getting small integers into regs, and mov <Wd> fortunately zeroes the top bits for us anyway.

So does LDR Wd.

Quoted 8 lines

Anyway, I think glibc (or my reading of it) has something like like:

  register long _x1 asm ("x1") = _x1tmp;

before invoking the SVC. I assume this would do the right conversion to long. I can't tell about other libraries but I'd say it's their responsibility to convert the args to long before calling the kernel's prctl().

Ignore me. I was worrying that glibc would propagate junk in the high bits of int arguments, due to treating them as longs. Actually, it will, but it doesn't matter where we explicitly cast the argument to int inside the kernel (thanks as usual to -fno-strict-overflow).

Cheers
---Dave

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

A message that is not in the archive (sent off-list or not yet received): CAKgNAkgnH7f4bNiF8q-GOY_xz1x9gYnDjMTw=vpR7ONxoL=cdw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#34 lore raw

Re: [RFC PATCH v2 6/6] prctl.2: Add tagged address ABI control prctls (arm64)

Quoted 3 lines · Michael Kerrisk (man-pages)

Hi Dave

Is there a plan for future work on this patch?

I think we have agreement on the content. Mainly this is waiting for me to repost.

Cheers
---Dave

[...]

#35 lore raw

PATCH v2 1/6 prctl.2: ffix use literal hyphens when referencing kernel docs

In reply to Dave Martin

There is one case of a cross-reference to a kernel documentation filename that uses unescaped hyphens.

To avoid misrendering, escape these as \- similarly to other instances.

---
 man2/prctl.2 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man2/prctl.2 +1 -1
index 968a75a..dc99218 100644
@@ -1261,7 +1261,7 @@ This parameter may enforce a read-only policy which will result in the
 call failing with the error
 .BR ENXIO .
 For further details, see the kernel source file
-.IR Documentation/admin-guide/kernel-parameters.txt .
+.IR Documentation/admin\-guide/kernel\-parameters.txt .
 .\"
 .\" prctl PR_TASK_PERF_EVENTS_DISABLE
 .TP
Signature · 1 line
2.1.4

A message that is not in the archive (sent off-list or not yet received): 1590614258-24728-2-git-send-email-Dave.Martin-5wv7dgnIgG8@public.gmane.org

#37 lore raw

Re: [PATCH v2 1/6] prctl.2: ffix use literal hyphens when referencing kernel docs

Quoted 16 lines · Dave Martin

There is one case of a cross-reference to a kernel documentation filename that uses unescaped hyphens.

To avoid misrendering, escape these as \- similarly to other instances.

---
 man2/prctl.2 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man2/prctl.2 +0 -0
index 968a75a..dc99218 100644

man2/prctl.2 This parameter may enforce a read-only policy which will result in the · line 1267

Quoted 8 lines
man2/prctl.2 +1 -1
@@ -1261,7 +1261,7 @@ This parameter may enforce a read-only policy which will result in the
 call failing with the error
 .BR ENXIO .
 For further details, see the kernel source file
-.IR Documentation/admin-guide/kernel-parameters.txt .
+.IR Documentation/admin\-guide/kernel\-parameters.txt .
 .\"
 .\" prctl PR_TASK_PERF_EVENTS_DISABLE
 .TP

Thanks, Dave. Applied.

Cheers,

Michael

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#38 lore raw

PATCH v2 2/6 prctl.2: Add PR_SPEC_INDIRECT_BRANCH for SPECULATION_CTRL prctls

In reply to Dave Martin

Add the PR_SPEC_INDIRECT_BRANCH "misfeature" added in Linux 4.20 for PR_SET_SPECULATION_CTRL and PR_GET_SPECULATION_CTRL.

Cc Tim Chen <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 man2/prctl.2 | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
man2/prctl.2 +18 -6
index dc99218..b6fb51c 100644
@@ -1213,11 +1213,20 @@ arguments must be specified as 0; otherwise the call fails with the error
 .\" commit 356e4bfff2c5489e016fdb925adbf12a1e3950ee
 Sets the state of the speculation misfeature specified in
 .IR arg2 .
-Currently, the only permitted value for this argument is
+Currently, this argument must be one of:
+.RS
+.TP
 .B PR_SPEC_STORE_BYPASS
-(otherwise the call fails with the error
+speculative store bypass control, or
+.\" commit 9137bb27e60e554dab694eafa4cca241fa3a694f
+.TP
+.BR PR_SPEC_INDIRECT_BRANCH " (since Linux 4.20)"
+indirect branch speculation control.
+.RE
+.IP
+(Otherwise the call fails with the error
 .BR ENODEV ).
-This setting is a per-thread attribute.
+These settings are per-thread attributes.
 The
 .IR arg3
 argument is used to hand in the control value,
@@ -1235,13 +1244,16 @@ Same as
 .BR PR_SPEC_DISABLE ,
 but cannot be undone.
 A subsequent
-.B
-prctl(..., PR_SPEC_ENABLE)
+.BR prctl (\c
+.IR arg2 ,
+.BR PR_SPEC_ENABLE )
+with the same value for
+.I arg2
 will fail with the error
 .BR EPERM .
 .RE
 .IP
-Any other value in
+Any unsupported value in
 .IR arg3
 will result in the call failing with the error
 .BR ERANGE .
Signature · 1 line
2.1.4

A message that is not in the archive (sent off-list or not yet received): 1590614258-24728-3-git-send-email-Dave.Martin-5wv7dgnIgG8@public.gmane.org

#40 lore raw

Re: [PATCH v2 2/6] prctl.2: Add PR_SPEC_INDIRECT_BRANCH for SPECULATION_CTRL prctls

Hi Dave,

Quoted 7 lines · Dave Martin

Add the PR_SPEC_INDIRECT_BRANCH "misfeature" added in Linux 4.20 for PR_SET_SPECULATION_CTRL and PR_GET_SPECULATION_CTRL.

Cc Tim Chen <tim.c.chen-VuQAYsv1563Yd54FQh9/[email protected]>
Cc Thomas Gleixner <[email protected]>

I had also applied this patch from the email you sent earlier. I've pushed those changes to master now.

Thanks,

Michael

Quoted 55 lines
---
 man2/prctl.2 | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
man2/prctl.2 +18 -7
index dc99218..b6fb51c 100644
@@ -1213,11 +1213,20 @@ arguments must be specified as 0; otherwise the call fails with the error
 .\" commit 356e4bfff2c5489e016fdb925adbf12a1e3950ee
 Sets the state of the speculation misfeature specified in
 .IR arg2 .
-Currently, the only permitted value for this argument is
+Currently, this argument must be one of:
+.RS
+.TP
 .B PR_SPEC_STORE_BYPASS
-(otherwise the call fails with the error
+speculative store bypass control, or
+.\" commit 9137bb27e60e554dab694eafa4cca241fa3a694f
+.TP
+.BR PR_SPEC_INDIRECT_BRANCH " (since Linux 4.20)"
+indirect branch speculation control.
+.RE
+.IP
+(Otherwise the call fails with the error
 .BR ENODEV ).
-This setting is a per-thread attribute.
+These settings are per-thread attributes.
 The
 .IR arg3
 argument is used to hand in the control value,
@@ -1235,13 +1244,16 @@ Same as
 .BR PR_SPEC_DISABLE ,
 but cannot be undone.
 A subsequent
-.B
-prctl(..., PR_SPEC_ENABLE)
+.BR prctl (\c
+.IR arg2 ,
+.BR PR_SPEC_ENABLE )
+with the same value for
+.I arg2
 will fail with the error
 .BR EPERM .
 .RE
 .IP
-Any other value in
+Any unsupported value in
 .IR arg3
 will result in the call failing with the error
 .BR ERANGE .
--

2.1.4

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#41 lore raw

Re: [PATCH v2 2/6] prctl.2: Add PR_SPEC_INDIRECT_BRANCH for SPECULATION_CTRL prctls

Quoted 7 lines · Michael Kerrisk (man-pages)

Hi Dave,

Quoted 4 lines · Dave Martin

Add the PR_SPEC_INDIRECT_BRANCH "misfeature" added in Linux 4.20 for PR_SET_SPECULATION_CTRL and PR_GET_SPECULATION_CTRL.

Quoted 6 lines
Quoted 3 lines
Cc Tim Chen <[email protected]>
Cc Thomas Gleixner <[email protected]>

I had also applied this patch from the email you sent earlier. I've pushed those changes to master now.

Thanks for this.

Do you publish a "development" branch somewhere, or similar?

If possible, it's nice to have git rebase work out which patches to drop for me rather than me doing it by hand.

Don't bother if publishing an extra branch doesn't fit with your workflow, though.

Cheers
---Dave

A message that is not in the archive (sent off-list or not yet received): [email protected]

#43 lore raw

Re: [PATCH v2 2/6] prctl.2: Add PR_SPEC_INDIRECT_BRANCH for SPECULATION_CTRL prctls

Quoted 12 lines · Dave Martin
Quoted 11 lines · Michael Kerrisk (man-pages)

Hi Dave,

Quoted 7 lines · Dave Martin

Add the PR_SPEC_INDIRECT_BRANCH "misfeature" added in Linux 4.20 for PR_SET_SPECULATION_CTRL and PR_GET_SPECULATION_CTRL.

Cc Tim Chen <tim.c.chen-VuQAYsv1563Yd54FQh9/[email protected]>
Cc Thomas Gleixner <[email protected]>
Quoted 6 lines
Quoted 2 lines

I had also applied this patch from the email you sent earlier. I've pushed those changes to master now.

Thanks for this.

Do you publish a "development" branch somewhere, or similar?

Ocassionally, I do this on a per-series basis.

Quoted 3 lines

If possible, it's nice to have git rebase work out which patches to drop for me rather than me doing it by hand.

Yuh, sorry about that. I'l try to do it bette rnext time.

Thanks,

Michael

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#44 lore raw

PATCH v2 5/6 prctl.2: Add PR_PAC_RESET_KEYS (arm64)

In reply to Dave Martin

Add documentation for the PR_PAC_RESET_KEYS ioctl added in Linux 5.0 for arm64.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Amit Daniel Kachhap <[email protected]>
Cc Mark Rutland <[email protected]>

---

Since v1:

* Clarify explicitly that PR_PAC_RESET_KEYS is redundant when combined with execve().

* Move error condition details into the prctl description, to avoid excessive duplication while keeping keeping related pieces of text closer together.

* In lieu of having a separate man page to cross reference for detailed guidance, cross-reference the kernel documentation.

* Add safety warning. This is deliberately vague, pending ongoing discussions with libc folks.

---
 man2/prctl.2 | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)
man2/prctl.2 +80 -0
index 91df7c8..3ee2702 100644
@@ -950,6 +950,77 @@ behavior.
 A value of 1 indicates
 .BR execve (2)
 will operate in the privilege-restricting mode described above.
+.\" prctl PR_PAC_RESET_KEYS
+.\" commit ba830885656414101b2f8ca88786524d4bb5e8c1
+.TP
+.BR PR_PAC_RESET_KEYS " (since Linux 5.0, only on arm64)"
+Securely reset the thread's pointer authentication keys
+to fresh random values generated by the kernel.
+.IP
+The set of keys to be reset is specified by
+.IR arg2 ,
+which must be a logical OR of zero or more of the following:
+.RS
+.TP
+.B PR_PAC_APIAKEY
+instruction authentication key A
+.TP
+.B PR_PAC_APIBKEY
+instruction authentication key B
+.TP
+.B PR_PAC_APDAKEY
+data authentication key A
+.TP
+.B PR_PAC_APDBKEY
+data authentication key B
+.TP
+.B PR_PAC_APGAKEY
+generic authentication \(lqA\(rq key.
+.IP
+(Yes folks, there really is no generic B key.)
+.RE
+.IP
+As a special case, if
+.I arg2
+is zero then all the keys are reset.
+Since new keys could be added in future,
+this is the recommended way to completely wipe the existing keys
+when establishing a clean execution context.
+Note that there is no need to use
+.BR PR_PAC_RESET_KEYS
+in preparation for calling
+.BR execve (2),
+since
+.BR execve (2)
+resets all the pointer authentication keys.
+.IP
+The remaining arguments
+.IR arg3 ", " arg4 " and " arg5
+must all be zero.
+.IP
+If the arguments are invalid,
+and in particular if
+.I arg2
+contains set bits that are unrecognized
+or that correspond to a key not available on this platform,
+the call fails with error
+.BR EINVAL .
+.IP
+.B Warning:
+Because the compiler or run-time environment
+may be using some or all of the keys,
+a successful
+.IP
+For more information, see the kernel source file
+.I Documentation/arm64/pointer\-authentication.rst
+.\"commit b693d0b372afb39432e1c49ad7b3454855bc6bed
+(or
+.I Documentation/arm64/pointer\-authentication.txt
+before Linux 5.3).
+.B PR_PAC_RESET_KEYS
+may crash the calling process.
+The conditions for using it safely are complex and system-dependent.
+Don't use it unless you know what you are doing.
 .\" prctl PR_SET_PDEATHSIG
 .TP
 .BR PR_SET_PDEATHSIG " (since Linux 2.1.57)"
@@ -1964,6 +2035,15 @@ are not 0.
 .B EINVAL
 .I option
 is
+.B PR_PAC_RESET_KEYS
+and the arguments are invalid or unsupported.
+See the description of
+.B PR_PAC_RESET_KEYS
+above for details.
+.TP
+.B EINVAL
+.I option
+is
 .B PR_SVE_SET_VL
 and the arguments are invalid or unsupported,
 or SVE is not available on this platform.
Signature · 1 line
2.1.4

A message that is not in the archive (sent off-list or not yet received): 1590614258-24728-6-git-send-email-Dave.Martin-5wv7dgnIgG8@public.gmane.org

Acked-by
#46 lore raw

Re: [PATCH v2 5/6] prctl.2: Add PR_PAC_RESET_KEYS (arm64)

Quoted 2 lines · Dave Martin

Add documentation for the PR_PAC_RESET_KEYS ioctl added in Linux 5.0 for arm64.

[...]

Quoted 11 lines
man2/prctl.2 +11 -0
+If the arguments are invalid,
+and in particular if
+.I arg2
+contains set bits that are unrecognized
+or that correspond to a key not available on this platform,
+the call fails with error
+.BR EINVAL .
+.IP
+.B Warning:
+Because the compiler or run-time environment
+may be using some or all of the keys,

man2/prctl.2 behavior. · line 1021

Quoted 10 lines
man2/prctl.2 +10 -0
+a successful
+.IP
+For more information, see the kernel source file
+.I Documentation/arm64/pointer\-authentication.rst
+.\"commit b693d0b372afb39432e1c49ad7b3454855bc6bed
+(or
+.I Documentation/arm64/pointer\-authentication.txt
+before Linux 5.3).
+.B PR_PAC_RESET_KEYS
+may crash the calling process.

I might be misreading this, but this looks like the kernel reference appears mid-sentence. Regardless, I think we should drop the kernel doc reference, as I mentioned on the SVE patches.

With that:

Will

#47 lore raw

Re: [PATCH v2 5/6] prctl.2: Add PR_PAC_RESET_KEYS (arm64)

Hi Will,

Thanks for reviewing.

Quoted 22 lines · Will Deacon
Quoted 2 lines · Dave Martin

Add documentation for the PR_PAC_RESET_KEYS ioctl added in Linux 5.0 for arm64.

[...]

Quoted 16 lines
man2/prctl.2 +16 -0
+If the arguments are invalid,
+and in particular if
+.I arg2
+contains set bits that are unrecognized
+or that correspond to a key not available on this platform,
+the call fails with error
+.BR EINVAL .
+.IP
+.B Warning:
+Because the compiler or run-time environment
+may be using some or all of the keys,
+a successful
+.IP
+For more information, see the kernel source file
+.I Documentation/arm64/pointer\-authentication.rst
+.\"commit b693d0b372afb39432e1c49ad7b3454855bc6bed
Quoted 8 lines

man2/prctl.2 behavior. · line 1021

Quoted 5 lines
man2/prctl.2 +5 -0
+(or
+.I Documentation/arm64/pointer\-authentication.txt
+before Linux 5.3).
+.B PR_PAC_RESET_KEYS
+may crash the calling process.

I might be misreading this, but this looks like the kernel reference appears mid-sentence.

It's hidden as a comment (.\").

Quoted 2 lines

Regardless, I think we should drop the kernel doc reference, as I mentioned on the SVE patches.

I actually request that people add these kinds of comments in the source. It helps me verify details in patches, and is also handy when checking details in the future.

Quoted 3 lines

With that:

Thanks.

Cheers,

Michael

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#48 lore raw

Re: [PATCH v2 5/6] prctl.2: Add PR_PAC_RESET_KEYS (arm64)

In reply to a message not in the archive

Hello Dave,

I've applied this patch (manually, because 4/6 is not yet applied). I have a question below.

Quoted 29 lines · Dave Martin

Add documentation for the PR_PAC_RESET_KEYS ioctl added in Linux 5.0 for arm64.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Amit Daniel Kachhap <[email protected]>
Cc Mark Rutland <[email protected]>

---

Since v1:

* Clarify explicitly that PR_PAC_RESET_KEYS is redundant when combined with execve().

* Move error condition details into the prctl description, to avoid excessive duplication while keeping keeping related pieces of text closer together.

* In lieu of having a separate man page to cross reference for detailed guidance, cross-reference the kernel documentation.

* Add safety warning. This is deliberately vague, pending ongoing discussions with libc folks.

---
 man2/prctl.2 | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)

[...]

man2/prctl.2 behavior. · line 1012

Quoted 5 lines

+.IP
+.B Warning:

man2/prctl.2 +3 -0
+Because the compiler or run-time environment
+may be using some or all of the keys,
+a successful

Things got a bit garbled here. I think the next few lines should have been at the end.

man2/prctl.2 behavior. · line 1023

Quoted 11 lines

+.IP

man2/prctl.2 +10 -0
+For more information, see the kernel source file
+.I Documentation/arm64/pointer\-authentication.rst
+.\"commit b693d0b372afb39432e1c49ad7b3454855bc6bed
+(or
+.I Documentation/arm64/pointer\-authentication.txt
+before Linux 5.3).
+.B PR_PAC_RESET_KEYS
+may crash the calling process.
+The conditions for using it safely are complex and system-dependent.
+Don't use it unless you know what you are doing.

I applied the following change after your patch; is it okay?

.IP
.B Warning:
Because the compiler or run-time environment
may be using some or all of the keys,
a successful
+may crash the calling process.
+The conditions for using it safely are complex and system-dependent. +Don't use it unless you know what you are doing.
.IP
For more information, see the kernel source file
.I Documentation/arm64/pointer\-authentication.rst
@@ -1020,9 +1023,6 @@ For more information, see the kernel source file
.I Documentation/arm64/pointer\-authentication.txt
before Linux 5.3).
.B PR_PAC_RESET_KEYS
-may crash the calling process.
-The conditions for using it safely are complex and system-dependent. -Don't use it unless you know what you are doing.
.\" prctl PR_SET_PDEATHSIG
.TP
.BR PR_SET_PDEATHSIG " (since Linux 2.1.57)"

[...]

Thanks,

Michael

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#49 lore raw

Re: [PATCH v2 5/6] prctl.2: Add PR_PAC_RESET_KEYS (arm64)

Quoted 60 lines · Michael Kerrisk (man-pages)

Hello Dave,

I've applied this patch (manually, because 4/6 is not yet applied). I have a question below.

Quoted 29 lines · Dave Martin

Add documentation for the PR_PAC_RESET_KEYS ioctl added in Linux 5.0 for arm64.

Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Amit Daniel Kachhap <[email protected]>
Cc Mark Rutland <[email protected]>

---

Since v1:

* Clarify explicitly that PR_PAC_RESET_KEYS is redundant when combined with execve().

* Move error condition details into the prctl description, to avoid excessive duplication while keeping keeping related pieces of text closer together.

* In lieu of having a separate man page to cross reference for detailed guidance, cross-reference the kernel documentation.

* Add safety warning. This is deliberately vague, pending ongoing discussions with libc folks.

---
 man2/prctl.2 | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)

[...]

man2/prctl.2 behavior. · line 1012

Quoted 5 lines

+.IP
+.B Warning:

man2/prctl.2 +3 -0
+Because the compiler or run-time environment
+may be using some or all of the keys,
+a successful

Things got a bit garbled here. I think the next few lines should have been at the end.

man2/prctl.2 behavior. · line 1023

Quoted 11 lines

+.IP

man2/prctl.2 +10 -0
+For more information, see the kernel source file
+.I Documentation/arm64/pointer\-authentication.rst
+.\"commit b693d0b372afb39432e1c49ad7b3454855bc6bed
+(or
+.I Documentation/arm64/pointer\-authentication.txt
+before Linux 5.3).
+.B PR_PAC_RESET_KEYS
+may crash the calling process.
+The conditions for using it safely are complex and system-dependent.
+Don't use it unless you know what you are doing.

I applied the following change after your patch; is it okay?

Quoted 5 lines

.IP
.B Warning:
Because the compiler or run-time environment
may be using some or all of the keys,
a successful

Looks fine, execpt that I think you need to move the

.B PR_PAC_RESET_KEYS

line here also.

Thanks
---Dave

Quoted 17 lines
man2/prctl.2 +3 -3
+may crash the calling process.
+The conditions for using it safely are complex and system-dependent.
+Don't use it unless you know what you are doing.
 .IP
 For more information, see the kernel source file
 .I Documentation/arm64/pointer\-authentication.rst
@@ -1020,9 +1023,6 @@ For more information, see the kernel source file
 .I Documentation/arm64/pointer\-authentication.txt
 before Linux 5.3).
 .B PR_PAC_RESET_KEYS
-may crash the calling process.
-The conditions for using it safely are complex and system-dependent.
-Don't use it unless you know what you are doing.
 .\" prctl PR_SET_PDEATHSIG
 .TP
 .BR PR_SET_PDEATHSIG " (since Linux 2.1.57)"

[...]

#50 lore raw

Re: [PATCH v2 5/6] prctl.2: Add PR_PAC_RESET_KEYS (arm64)

Quoted 8 lines
Quoted 7 lines

I applied the following change after your patch; is it okay?

.IP
.B Warning:
Because the compiler or run-time environment
may be using some or all of the keys,
a successful

Quoted 5 lines

Looks fine, execpt that I think you need to move the

.B PR_PAC_RESET_KEYS

line here also.

Thanks. Fixed. But, the fix will be in the 5.08 man-pages release, I'm sorry. I cut 5.07 a few hours ago.

Cheers,

Michael

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#51 lore raw
In reply to Dave Martin

Hi Dave

Quoted 8 lines · Dave Martin

A bunch of updates to the prctl(2) man page to fill in missing prctls (mostly) up to Linux 5.6 (along with a few other tweaks and fixes).

Patches from the v1 series [1] that have been applied or rejected already have been dropped.

Quoted 7 lines

People not Cc'd on the whole series can find the whole series at
https://lore.kernel.org/linux-man/ .

Patches:

* Patch 1 is a new (but trivial) formatting fix, unrelated to the new prctls.

Applied.

Quoted 2 lines

* Patches 2-3 relate to the speculation control prctls. These are unmodified from v1, but need review.

Applied, and pushed (since there were no review comments from last version).

Quoted 2 lines

* Patches 4-5 relate to the arm64 prctls from v1, with reviewer feedback incorporated. (See notes in the patches.)

I'll hold off on these patches, to see if review comments come in.

Quoted 3 lines

* Patch 6 is *draft* wording for the arm64 address tagging prctls. The semantics of address tagging is particularly slippery, so this needs discussion before merging.

Okay -- I'll hold off with that patch too.

Cheers,

Michael

Quoted 17 lines

[1] https://lore.kernel.org/linux-man/[email protected]/T/#t

Dave Martin (6):
prctl.2: ffix use literal hyphens when referencing kernel docs prctl.2: Add PR_SPEC_INDIRECT_BRANCH for SPECULATION_CTRL prctls prctl.2: Add PR_SPEC_DISABLE_NOEXEC for SPECULATION_CTRL prctls prctl.2: Add SVE prctls (arm64)
prctl.2: Add PR_PAC_RESET_KEYS (arm64)
prctl.2: Add tagged address ABI control prctls (arm64)

 man2/prctl.2 | 444 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 435 insertions(+), 9 deletions(-)

--
2.1.4