* [PATCH v4 0/2] arm64 relaxed ABI
[not found] <cover.1560339705.git.andreyknvl@google.com>
@ 2019-06-12 14:21 ` Vincenzo Frascino
2019-06-12 14:21 ` Vincenzo Frascino
` (2 more replies)
2019-06-13 15:51 ` [PATCH v5 0/2] arm64 relaxed ABI Vincenzo Frascino
1 sibling, 3 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-12 14:21 UTC (permalink / raw)
To: linux-arm-kernel, linux-doc, linux-mm, linux-arch,
linux-kselftest, linux-kernel
Cc: Catalin Marinas, Will Deacon, Andrey Konovalov, Alexander Viro
On arm64 the TCR_EL1.TBI0 bit has been always enabled on the arm64 kernel,
hence the userspace (EL0) is allowed to set a non-zero value in the top
byte but the resulting pointers are not allowed at the user-kernel syscall
ABI boundary.
This patchset proposes a relaxation of the ABI with which it is possible
to pass tagged tagged pointers to the syscalls, when these pointers are in
memory ranges obtained as described in tagged-address-abi.txt contained in
this patch series.
Since it is not desirable to relax the ABI to allow tagged user addresses
into the kernel indiscriminately, this patchset documents a new sysctl
interface (/proc/sys/abi/tagged_addr) that is used to prevent the applications
from enabling the relaxed ABI and a new prctl() interface that can be used to
enable or disable the relaxed ABI.
This patchset should be merged together with [1].
[1] https://patchwork.kernel.org/cover/10674351/
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
CC: Andrey Konovalov <andreyknvl@google.com>
CC: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Vincenzo Frascino (2):
arm64: Define Documentation/arm64/tagged-address-abi.txt
arm64: Relax Documentation/arm64/tagged-pointers.txt
Documentation/arm64/tagged-address-abi.txt | 111 +++++++++++++++++++++
Documentation/arm64/tagged-pointers.txt | 23 +++--
2 files changed, 127 insertions(+), 7 deletions(-)
create mode 100644 Documentation/arm64/tagged-address-abi.txt
--
2.21.0
^ permalink raw reply [flat|nested] 50+ messages in thread
* [PATCH v4 0/2] arm64 relaxed ABI
2019-06-12 14:21 ` [PATCH v4 0/2] arm64 relaxed ABI Vincenzo Frascino
@ 2019-06-12 14:21 ` Vincenzo Frascino
2019-06-12 14:21 ` [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt Vincenzo Frascino
2019-06-12 14:21 ` [PATCH v4 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt Vincenzo Frascino
2 siblings, 0 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-12 14:21 UTC (permalink / raw)
To: linux-arm-kernel, linux-doc, linux-mm, linux-arch,
linux-kselftest, linux-kernel
Cc: Catalin Marinas, Will Deacon, Andrey Konovalov, Alexander Viro
On arm64 the TCR_EL1.TBI0 bit has been always enabled on the arm64 kernel,
hence the userspace (EL0) is allowed to set a non-zero value in the top
byte but the resulting pointers are not allowed at the user-kernel syscall
ABI boundary.
This patchset proposes a relaxation of the ABI with which it is possible
to pass tagged tagged pointers to the syscalls, when these pointers are in
memory ranges obtained as described in tagged-address-abi.txt contained in
this patch series.
Since it is not desirable to relax the ABI to allow tagged user addresses
into the kernel indiscriminately, this patchset documents a new sysctl
interface (/proc/sys/abi/tagged_addr) that is used to prevent the applications
from enabling the relaxed ABI and a new prctl() interface that can be used to
enable or disable the relaxed ABI.
This patchset should be merged together with [1].
[1] https://patchwork.kernel.org/cover/10674351/
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
CC: Andrey Konovalov <andreyknvl@google.com>
CC: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Vincenzo Frascino (2):
arm64: Define Documentation/arm64/tagged-address-abi.txt
arm64: Relax Documentation/arm64/tagged-pointers.txt
Documentation/arm64/tagged-address-abi.txt | 111 +++++++++++++++++++++
Documentation/arm64/tagged-pointers.txt | 23 +++--
2 files changed, 127 insertions(+), 7 deletions(-)
create mode 100644 Documentation/arm64/tagged-address-abi.txt
--
2.21.0
^ permalink raw reply [flat|nested] 50+ messages in thread
* [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-12 14:21 ` [PATCH v4 0/2] arm64 relaxed ABI Vincenzo Frascino
2019-06-12 14:21 ` Vincenzo Frascino
@ 2019-06-12 14:21 ` Vincenzo Frascino
2019-06-12 14:21 ` Vincenzo Frascino
` (2 more replies)
2019-06-12 14:21 ` [PATCH v4 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt Vincenzo Frascino
2 siblings, 3 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-12 14:21 UTC (permalink / raw)
To: linux-arm-kernel, linux-doc, linux-mm, linux-arch,
linux-kselftest, linux-kernel
Cc: Catalin Marinas, Will Deacon, Andrey Konovalov, Alexander Viro
On arm64 the TCR_EL1.TBI0 bit has been always enabled hence
the userspace (EL0) is allowed to set a non-zero value in the
top byte but the resulting pointers are not allowed at the
user-kernel syscall ABI boundary.
With the relaxed ABI proposed through this document, it is now possible
to pass tagged pointers to the syscalls, when these pointers are in
memory ranges obtained by an anonymous (MAP_ANONYMOUS) mmap().
This change in the ABI requires a mechanism to requires the userspace
to opt-in to such an option.
Specify and document the way in which sysctl and prctl() can be used
in combination to allow the userspace to opt-in this feature.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
CC: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
Documentation/arm64/tagged-address-abi.txt | 111 +++++++++++++++++++++
1 file changed, 111 insertions(+)
create mode 100644 Documentation/arm64/tagged-address-abi.txt
diff --git a/Documentation/arm64/tagged-address-abi.txt b/Documentation/arm64/tagged-address-abi.txt
new file mode 100644
index 000000000000..96e149e2c55c
--- /dev/null
+++ b/Documentation/arm64/tagged-address-abi.txt
@@ -0,0 +1,111 @@
+ARM64 TAGGED ADDRESS ABI
+========================
+
+This document describes the usage and semantics of the Tagged Address
+ABI on arm64.
+
+1. Introduction
+---------------
+
+On arm64 the TCR_EL1.TBI0 bit has been always enabled on the arm64 kernel,
+hence the userspace (EL0) is allowed to set a non-zero value in the top
+byte but the resulting pointers are not allowed at the user-kernel syscall
+ABI boundary.
+
+This document describes a relaxation of the ABI with which it is possible
+to pass tagged tagged pointers to the syscalls, when these pointers are in
+memory ranges obtained as described in paragraph 2.
+
+Since it is not desirable to relax the ABI to allow tagged user addresses
+into the kernel indiscriminately, arm64 provides a new sysctl interface
+(/proc/sys/abi/tagged_addr) that is used to prevent the applications from
+enabling the relaxed ABI and a new prctl() interface that can be used to
+enable or disable the relaxed ABI.
+
+The sysctl is meant also for testing purposes in order to provide a simple
+way for the userspace to verify the return error checking of the prctl()
+command without having to reconfigure the kernel.
+
+The ABI properties are inherited by threads of the same application and
+fork()'ed children but cleared when a new process is spawn (execve()).
+
+2. ARM64 Tagged Address ABI
+---------------------------
+
+From the kernel syscall interface prospective, we define, for the purposes
+of this document, a "valid tagged pointer" as a pointer that either it has
+a zero value set in the top byte or it has a non-zero value, it is in memory
+ranges privately owned by a userspace process and it is obtained in one of
+the following ways:
+ - mmap() done by the process itself, where either:
+ * flags = MAP_PRIVATE | MAP_ANONYMOUS
+ * flags = MAP_PRIVATE and the file descriptor refers to a regular
+ file or "/dev/zero"
+ - a mapping below sbrk(0) done by the process itself
+ - any memory mapped by the kernel in the process's address space during
+ creation and following the restrictions presented above (i.e. data, bss,
+ stack).
+
+The ARM64 Tagged Address ABI is an opt-in feature, and an application can
+control it using the following prctl()s:
+ - PR_SET_TAGGED_ADDR_CTRL: can be used to enable the Tagged Address ABI.
+ - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
+ Address ABI.
+
+As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
+the ABI guarantees the following behaviours:
+
+ - Every current or newly introduced syscall can accept any valid tagged
+ pointers.
+
+ - If a non valid tagged pointer is passed to a syscall then the behaviour
+ is undefined.
+
+ - Every valid tagged pointer is expected to work as an untagged one.
+
+ - The kernel preserves any valid tagged pointers and returns them to the
+ userspace unchanged in all the cases except the ones documented in the
+ "Preserving tags" paragraph of tagged-pointers.txt.
+
+A definition of the meaning of tagged pointers on arm64 can be found in:
+Documentation/arm64/tagged-pointers.txt.
+
+3. ARM64 Tagged Address ABI Exceptions
+--------------------------------------
+
+The behaviours described in paragraph 2, with particular reference to the
+acceptance by the syscalls of any valid tagged pointer are not applicable
+to the following cases:
+ - mmap() addr parameter.
+ - mremap() new_address parameter.
+ - prctl_set_mm() struct prctl_map fields.
+ - prctl_set_mm_map() struct prctl_map fields.
+
+4. Example of correct usage
+---------------------------
+
+void main(void)
+{
+ static int tbi_enabled = 0;
+ unsigned long tag = 0;
+
+ char *ptr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
+ MAP_ANONYMOUS, -1, 0);
+
+ if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE,
+ 0, 0, 0) == 0)
+ tbi_enabled = 1;
+
+ if (!ptr)
+ return -1;
+
+ if (tbi_enabled)
+ tag = rand() & 0xff;
+
+ ptr = (char *)((unsigned long)ptr | (tag << TAG_SHIFT));
+
+ *ptr = 'a';
+
+ ...
+}
+
--
2.21.0
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-12 14:21 ` [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt Vincenzo Frascino
@ 2019-06-12 14:21 ` Vincenzo Frascino
2019-06-12 15:35 ` Catalin Marinas
2019-06-12 16:30 ` Szabolcs Nagy
2 siblings, 0 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-12 14:21 UTC (permalink / raw)
To: linux-arm-kernel, linux-doc, linux-mm, linux-arch,
linux-kselftest, linux-kernel
Cc: Catalin Marinas, Will Deacon, Andrey Konovalov, Alexander Viro
On arm64 the TCR_EL1.TBI0 bit has been always enabled hence
the userspace (EL0) is allowed to set a non-zero value in the
top byte but the resulting pointers are not allowed at the
user-kernel syscall ABI boundary.
With the relaxed ABI proposed through this document, it is now possible
to pass tagged pointers to the syscalls, when these pointers are in
memory ranges obtained by an anonymous (MAP_ANONYMOUS) mmap().
This change in the ABI requires a mechanism to requires the userspace
to opt-in to such an option.
Specify and document the way in which sysctl and prctl() can be used
in combination to allow the userspace to opt-in this feature.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
CC: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
Documentation/arm64/tagged-address-abi.txt | 111 +++++++++++++++++++++
1 file changed, 111 insertions(+)
create mode 100644 Documentation/arm64/tagged-address-abi.txt
diff --git a/Documentation/arm64/tagged-address-abi.txt b/Documentation/arm64/tagged-address-abi.txt
new file mode 100644
index 000000000000..96e149e2c55c
--- /dev/null
+++ b/Documentation/arm64/tagged-address-abi.txt
@@ -0,0 +1,111 @@
+ARM64 TAGGED ADDRESS ABI
+========================
+
+This document describes the usage and semantics of the Tagged Address
+ABI on arm64.
+
+1. Introduction
+---------------
+
+On arm64 the TCR_EL1.TBI0 bit has been always enabled on the arm64 kernel,
+hence the userspace (EL0) is allowed to set a non-zero value in the top
+byte but the resulting pointers are not allowed at the user-kernel syscall
+ABI boundary.
+
+This document describes a relaxation of the ABI with which it is possible
+to pass tagged tagged pointers to the syscalls, when these pointers are in
+memory ranges obtained as described in paragraph 2.
+
+Since it is not desirable to relax the ABI to allow tagged user addresses
+into the kernel indiscriminately, arm64 provides a new sysctl interface
+(/proc/sys/abi/tagged_addr) that is used to prevent the applications from
+enabling the relaxed ABI and a new prctl() interface that can be used to
+enable or disable the relaxed ABI.
+
+The sysctl is meant also for testing purposes in order to provide a simple
+way for the userspace to verify the return error checking of the prctl()
+command without having to reconfigure the kernel.
+
+The ABI properties are inherited by threads of the same application and
+fork()'ed children but cleared when a new process is spawn (execve()).
+
+2. ARM64 Tagged Address ABI
+---------------------------
+
+From the kernel syscall interface prospective, we define, for the purposes
+of this document, a "valid tagged pointer" as a pointer that either it has
+a zero value set in the top byte or it has a non-zero value, it is in memory
+ranges privately owned by a userspace process and it is obtained in one of
+the following ways:
+ - mmap() done by the process itself, where either:
+ * flags = MAP_PRIVATE | MAP_ANONYMOUS
+ * flags = MAP_PRIVATE and the file descriptor refers to a regular
+ file or "/dev/zero"
+ - a mapping below sbrk(0) done by the process itself
+ - any memory mapped by the kernel in the process's address space during
+ creation and following the restrictions presented above (i.e. data, bss,
+ stack).
+
+The ARM64 Tagged Address ABI is an opt-in feature, and an application can
+control it using the following prctl()s:
+ - PR_SET_TAGGED_ADDR_CTRL: can be used to enable the Tagged Address ABI.
+ - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
+ Address ABI.
+
+As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
+the ABI guarantees the following behaviours:
+
+ - Every current or newly introduced syscall can accept any valid tagged
+ pointers.
+
+ - If a non valid tagged pointer is passed to a syscall then the behaviour
+ is undefined.
+
+ - Every valid tagged pointer is expected to work as an untagged one.
+
+ - The kernel preserves any valid tagged pointers and returns them to the
+ userspace unchanged in all the cases except the ones documented in the
+ "Preserving tags" paragraph of tagged-pointers.txt.
+
+A definition of the meaning of tagged pointers on arm64 can be found in:
+Documentation/arm64/tagged-pointers.txt.
+
+3. ARM64 Tagged Address ABI Exceptions
+--------------------------------------
+
+The behaviours described in paragraph 2, with particular reference to the
+acceptance by the syscalls of any valid tagged pointer are not applicable
+to the following cases:
+ - mmap() addr parameter.
+ - mremap() new_address parameter.
+ - prctl_set_mm() struct prctl_map fields.
+ - prctl_set_mm_map() struct prctl_map fields.
+
+4. Example of correct usage
+---------------------------
+
+void main(void)
+{
+ static int tbi_enabled = 0;
+ unsigned long tag = 0;
+
+ char *ptr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
+ MAP_ANONYMOUS, -1, 0);
+
+ if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE,
+ 0, 0, 0) == 0)
+ tbi_enabled = 1;
+
+ if (!ptr)
+ return -1;
+
+ if (tbi_enabled)
+ tag = rand() & 0xff;
+
+ ptr = (char *)((unsigned long)ptr | (tag << TAG_SHIFT));
+
+ *ptr = 'a';
+
+ ...
+}
+
--
2.21.0
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v4 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt
2019-06-12 14:21 ` [PATCH v4 0/2] arm64 relaxed ABI Vincenzo Frascino
2019-06-12 14:21 ` Vincenzo Frascino
2019-06-12 14:21 ` [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt Vincenzo Frascino
@ 2019-06-12 14:21 ` Vincenzo Frascino
2019-06-12 14:21 ` Vincenzo Frascino
` (2 more replies)
2 siblings, 3 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-12 14:21 UTC (permalink / raw)
To: linux-arm-kernel, linux-doc, linux-mm, linux-arch,
linux-kselftest, linux-kernel
Cc: Catalin Marinas, Will Deacon, Andrey Konovalov, Alexander Viro
On arm64 the TCR_EL1.TBI0 bit has been always enabled hence
the userspace (EL0) is allowed to set a non-zero value in the
top byte but the resulting pointers are not allowed at the
user-kernel syscall ABI boundary.
With the relaxed ABI proposed in this set, it is now possible to pass
tagged pointers to the syscalls, when these pointers are in memory
ranges obtained by an anonymous (MAP_ANONYMOUS) mmap().
Relax the requirements described in tagged-pointers.txt to be compliant
with the behaviours guaranteed by the ARM64 Tagged Address ABI.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
CC: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
Documentation/arm64/tagged-pointers.txt | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/Documentation/arm64/tagged-pointers.txt b/Documentation/arm64/tagged-pointers.txt
index a25a99e82bb1..db58a7e95805 100644
--- a/Documentation/arm64/tagged-pointers.txt
+++ b/Documentation/arm64/tagged-pointers.txt
@@ -18,7 +18,8 @@ Passing tagged addresses to the kernel
--------------------------------------
All interpretation of userspace memory addresses by the kernel assumes
-an address tag of 0x00.
+an address tag of 0x00, unless the userspace opts-in the ARM64 Tagged
+Address ABI via the PR_SET_TAGGED_ADDR_CTRL prctl().
This includes, but is not limited to, addresses found in:
@@ -31,18 +32,23 @@ This includes, but is not limited to, addresses found in:
- the frame pointer (x29) and frame records, e.g. when interpreting
them to generate a backtrace or call graph.
-Using non-zero address tags in any of these locations may result in an
-error code being returned, a (fatal) signal being raised, or other modes
-of failure.
+Using non-zero address tags in any of these locations when the
+userspace application did not opt-in to the ARM64 Tagged Address ABI,
+may result in an error code being returned, a (fatal) signal being raised,
+or other modes of failure.
-For these reasons, passing non-zero address tags to the kernel via
-system calls is forbidden, and using a non-zero address tag for sp is
-strongly discouraged.
+For these reasons, when the userspace application did not opt-in, passing
+non-zero address tags to the kernel via system calls is forbidden, and using
+a non-zero address tag for sp is strongly discouraged.
Programs maintaining a frame pointer and frame records that use non-zero
address tags may suffer impaired or inaccurate debug and profiling
visibility.
+A definition of the meaning of ARM64 Tagged Address ABI and of the
+guarantees that the ABI provides when the userspace opts-in via prctl()
+can be found in: Documentation/arm64/tagged-address-abi.txt.
+
Preserving tags
---------------
@@ -57,6 +63,9 @@ be preserved.
The architecture prevents the use of a tagged PC, so the upper byte will
be set to a sign-extension of bit 55 on exception return.
+This behaviours are preserved even when the the userspace opts-in the ARM64
+Tagged Address ABI via the PR_SET_TAGGED_ADDR_CTRL prctl().
+
Other considerations
--------------------
--
2.21.0
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v4 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt
2019-06-12 14:21 ` [PATCH v4 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt Vincenzo Frascino
@ 2019-06-12 14:21 ` Vincenzo Frascino
2019-06-12 15:56 ` Catalin Marinas
2019-06-12 16:37 ` Szabolcs Nagy
2 siblings, 0 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-12 14:21 UTC (permalink / raw)
To: linux-arm-kernel, linux-doc, linux-mm, linux-arch,
linux-kselftest, linux-kernel
Cc: Catalin Marinas, Will Deacon, Andrey Konovalov, Alexander Viro
On arm64 the TCR_EL1.TBI0 bit has been always enabled hence
the userspace (EL0) is allowed to set a non-zero value in the
top byte but the resulting pointers are not allowed at the
user-kernel syscall ABI boundary.
With the relaxed ABI proposed in this set, it is now possible to pass
tagged pointers to the syscalls, when these pointers are in memory
ranges obtained by an anonymous (MAP_ANONYMOUS) mmap().
Relax the requirements described in tagged-pointers.txt to be compliant
with the behaviours guaranteed by the ARM64 Tagged Address ABI.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
CC: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
Documentation/arm64/tagged-pointers.txt | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/Documentation/arm64/tagged-pointers.txt b/Documentation/arm64/tagged-pointers.txt
index a25a99e82bb1..db58a7e95805 100644
--- a/Documentation/arm64/tagged-pointers.txt
+++ b/Documentation/arm64/tagged-pointers.txt
@@ -18,7 +18,8 @@ Passing tagged addresses to the kernel
--------------------------------------
All interpretation of userspace memory addresses by the kernel assumes
-an address tag of 0x00.
+an address tag of 0x00, unless the userspace opts-in the ARM64 Tagged
+Address ABI via the PR_SET_TAGGED_ADDR_CTRL prctl().
This includes, but is not limited to, addresses found in:
@@ -31,18 +32,23 @@ This includes, but is not limited to, addresses found in:
- the frame pointer (x29) and frame records, e.g. when interpreting
them to generate a backtrace or call graph.
-Using non-zero address tags in any of these locations may result in an
-error code being returned, a (fatal) signal being raised, or other modes
-of failure.
+Using non-zero address tags in any of these locations when the
+userspace application did not opt-in to the ARM64 Tagged Address ABI,
+may result in an error code being returned, a (fatal) signal being raised,
+or other modes of failure.
-For these reasons, passing non-zero address tags to the kernel via
-system calls is forbidden, and using a non-zero address tag for sp is
-strongly discouraged.
+For these reasons, when the userspace application did not opt-in, passing
+non-zero address tags to the kernel via system calls is forbidden, and using
+a non-zero address tag for sp is strongly discouraged.
Programs maintaining a frame pointer and frame records that use non-zero
address tags may suffer impaired or inaccurate debug and profiling
visibility.
+A definition of the meaning of ARM64 Tagged Address ABI and of the
+guarantees that the ABI provides when the userspace opts-in via prctl()
+can be found in: Documentation/arm64/tagged-address-abi.txt.
+
Preserving tags
---------------
@@ -57,6 +63,9 @@ be preserved.
The architecture prevents the use of a tagged PC, so the upper byte will
be set to a sign-extension of bit 55 on exception return.
+This behaviours are preserved even when the the userspace opts-in the ARM64
+Tagged Address ABI via the PR_SET_TAGGED_ADDR_CTRL prctl().
+
Other considerations
--------------------
--
2.21.0
^ permalink raw reply related [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-12 14:21 ` [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt Vincenzo Frascino
2019-06-12 14:21 ` Vincenzo Frascino
@ 2019-06-12 15:35 ` Catalin Marinas
2019-06-12 15:35 ` Catalin Marinas
2019-06-13 10:15 ` Vincenzo Frascino
2019-06-12 16:30 ` Szabolcs Nagy
2 siblings, 2 replies; 50+ messages in thread
From: Catalin Marinas @ 2019-06-12 15:35 UTC (permalink / raw)
To: Vincenzo Frascino
Cc: linux-arm-kernel, linux-doc, linux-mm, linux-arch,
linux-kselftest, linux-kernel, Will Deacon, Andrey Konovalov,
Alexander Viro, Szabolcs Nagy
Hi Vincenzo,
Some minor comments below but it looks fine to me overall. Cc'ing
Szabolcs as well since I'd like a view from the libc people.
On Wed, Jun 12, 2019 at 03:21:10PM +0100, Vincenzo Frascino wrote:
> diff --git a/Documentation/arm64/tagged-address-abi.txt b/Documentation/arm64/tagged-address-abi.txt
> new file mode 100644
> index 000000000000..96e149e2c55c
> --- /dev/null
> +++ b/Documentation/arm64/tagged-address-abi.txt
> @@ -0,0 +1,111 @@
> +ARM64 TAGGED ADDRESS ABI
> +========================
> +
> +This document describes the usage and semantics of the Tagged Address
> +ABI on arm64.
> +
> +1. Introduction
> +---------------
> +
> +On arm64 the TCR_EL1.TBI0 bit has been always enabled on the arm64 kernel,
> +hence the userspace (EL0) is allowed to set a non-zero value in the top
I'd be clearer here: "userspace (EL0) is allowed to perform a user
memory access through a 64-bit pointer with a non-zero top byte" (or
something along the lines). Otherwise setting a non-zero top byte is
allowed on any architecture, dereferencing it is a problem.
> +byte but the resulting pointers are not allowed at the user-kernel syscall
> +ABI boundary.
> +
> +This document describes a relaxation of the ABI with which it is possible
"relaxation of the ABI that makes it possible to..."
> +to pass tagged tagged pointers to the syscalls, when these pointers are in
> +memory ranges obtained as described in paragraph 2.
"section 2" is better. There are a lot more paragraphs.
> +
> +Since it is not desirable to relax the ABI to allow tagged user addresses
> +into the kernel indiscriminately, arm64 provides a new sysctl interface
> +(/proc/sys/abi/tagged_addr) that is used to prevent the applications from
> +enabling the relaxed ABI and a new prctl() interface that can be used to
> +enable or disable the relaxed ABI.
> +
> +The sysctl is meant also for testing purposes in order to provide a simple
> +way for the userspace to verify the return error checking of the prctl()
> +command without having to reconfigure the kernel.
> +
> +The ABI properties are inherited by threads of the same application and
> +fork()'ed children but cleared when a new process is spawn (execve()).
"spawned".
I guess you could drop these three paragraphs here and mention the
inheritance properties when introducing the prctl() below. You can also
mention the global sysctl switch after the prctl() was introduced.
> +
> +2. ARM64 Tagged Address ABI
> +---------------------------
> +
> +From the kernel syscall interface prospective, we define, for the purposes
> +of this document, a "valid tagged pointer" as a pointer that either it has
"either has" (no 'it') sounds slightly better but I'm not a native
English speaker either.
> +a zero value set in the top byte or it has a non-zero value, it is in memory
> +ranges privately owned by a userspace process and it is obtained in one of
> +the following ways:
> + - mmap() done by the process itself, where either:
> + * flags = MAP_PRIVATE | MAP_ANONYMOUS
> + * flags = MAP_PRIVATE and the file descriptor refers to a regular
> + file or "/dev/zero"
> + - a mapping below sbrk(0) done by the process itself
> + - any memory mapped by the kernel in the process's address space during
> + creation and following the restrictions presented above (i.e. data, bss,
> + stack).
> +
> +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
> +control it using the following prctl()s:
> + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable the Tagged Address ABI.
enable or disable (not sure we need the latter but it doesn't heart).
I'd add the arg2 description here as well.
> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> + Address ABI.
> +
> +As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
> +the ABI guarantees the following behaviours:
> +
> + - Every current or newly introduced syscall can accept any valid tagged
> + pointers.
> +
> + - If a non valid tagged pointer is passed to a syscall then the behaviour
> + is undefined.
> +
> + - Every valid tagged pointer is expected to work as an untagged one.
> +
> + - The kernel preserves any valid tagged pointers and returns them to the
> + userspace unchanged in all the cases except the ones documented in the
> + "Preserving tags" paragraph of tagged-pointers.txt.
I'd think we need to qualify the context here in which the kernel
preserves the tagged pointers. Did you mean on the syscall return?
> +
> +A definition of the meaning of tagged pointers on arm64 can be found in:
> +Documentation/arm64/tagged-pointers.txt.
> +
> +3. ARM64 Tagged Address ABI Exceptions
> +--------------------------------------
> +
> +The behaviours described in paragraph 2, with particular reference to the
"section 2"
> +acceptance by the syscalls of any valid tagged pointer are not applicable
> +to the following cases:
> + - mmap() addr parameter.
> + - mremap() new_address parameter.
> + - prctl_set_mm() struct prctl_map fields.
> + - prctl_set_mm_map() struct prctl_map fields.
> +
> +4. Example of correct usage
> +---------------------------
> +
> +void main(void)
> +{
> + static int tbi_enabled = 0;
> + unsigned long tag = 0;
> +
> + char *ptr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
> + MAP_ANONYMOUS, -1, 0);
> +
> + if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE,
> + 0, 0, 0) == 0)
> + tbi_enabled = 1;
> +
> + if (!ptr)
> + return -1;
> +
> + if (tbi_enabled)
> + tag = rand() & 0xff;
> +
> + ptr = (char *)((unsigned long)ptr | (tag << TAG_SHIFT));
> +
> + *ptr = 'a';
> +
> + ...
> +}
> +
> --
> 2.21.0
--
Catalin
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-12 15:35 ` Catalin Marinas
@ 2019-06-12 15:35 ` Catalin Marinas
2019-06-13 10:15 ` Vincenzo Frascino
1 sibling, 0 replies; 50+ messages in thread
From: Catalin Marinas @ 2019-06-12 15:35 UTC (permalink / raw)
To: Vincenzo Frascino
Cc: linux-arm-kernel, linux-doc, linux-mm, linux-arch,
linux-kselftest, linux-kernel, Will Deacon, Andrey Konovalov,
Alexander Viro, Szabolcs Nagy
Hi Vincenzo,
Some minor comments below but it looks fine to me overall. Cc'ing
Szabolcs as well since I'd like a view from the libc people.
On Wed, Jun 12, 2019 at 03:21:10PM +0100, Vincenzo Frascino wrote:
> diff --git a/Documentation/arm64/tagged-address-abi.txt b/Documentation/arm64/tagged-address-abi.txt
> new file mode 100644
> index 000000000000..96e149e2c55c
> --- /dev/null
> +++ b/Documentation/arm64/tagged-address-abi.txt
> @@ -0,0 +1,111 @@
> +ARM64 TAGGED ADDRESS ABI
> +========================
> +
> +This document describes the usage and semantics of the Tagged Address
> +ABI on arm64.
> +
> +1. Introduction
> +---------------
> +
> +On arm64 the TCR_EL1.TBI0 bit has been always enabled on the arm64 kernel,
> +hence the userspace (EL0) is allowed to set a non-zero value in the top
I'd be clearer here: "userspace (EL0) is allowed to perform a user
memory access through a 64-bit pointer with a non-zero top byte" (or
something along the lines). Otherwise setting a non-zero top byte is
allowed on any architecture, dereferencing it is a problem.
> +byte but the resulting pointers are not allowed at the user-kernel syscall
> +ABI boundary.
> +
> +This document describes a relaxation of the ABI with which it is possible
"relaxation of the ABI that makes it possible to..."
> +to pass tagged tagged pointers to the syscalls, when these pointers are in
> +memory ranges obtained as described in paragraph 2.
"section 2" is better. There are a lot more paragraphs.
> +
> +Since it is not desirable to relax the ABI to allow tagged user addresses
> +into the kernel indiscriminately, arm64 provides a new sysctl interface
> +(/proc/sys/abi/tagged_addr) that is used to prevent the applications from
> +enabling the relaxed ABI and a new prctl() interface that can be used to
> +enable or disable the relaxed ABI.
> +
> +The sysctl is meant also for testing purposes in order to provide a simple
> +way for the userspace to verify the return error checking of the prctl()
> +command without having to reconfigure the kernel.
> +
> +The ABI properties are inherited by threads of the same application and
> +fork()'ed children but cleared when a new process is spawn (execve()).
"spawned".
I guess you could drop these three paragraphs here and mention the
inheritance properties when introducing the prctl() below. You can also
mention the global sysctl switch after the prctl() was introduced.
> +
> +2. ARM64 Tagged Address ABI
> +---------------------------
> +
> +From the kernel syscall interface prospective, we define, for the purposes
> +of this document, a "valid tagged pointer" as a pointer that either it has
"either has" (no 'it') sounds slightly better but I'm not a native
English speaker either.
> +a zero value set in the top byte or it has a non-zero value, it is in memory
> +ranges privately owned by a userspace process and it is obtained in one of
> +the following ways:
> + - mmap() done by the process itself, where either:
> + * flags = MAP_PRIVATE | MAP_ANONYMOUS
> + * flags = MAP_PRIVATE and the file descriptor refers to a regular
> + file or "/dev/zero"
> + - a mapping below sbrk(0) done by the process itself
> + - any memory mapped by the kernel in the process's address space during
> + creation and following the restrictions presented above (i.e. data, bss,
> + stack).
> +
> +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
> +control it using the following prctl()s:
> + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable the Tagged Address ABI.
enable or disable (not sure we need the latter but it doesn't heart).
I'd add the arg2 description here as well.
> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> + Address ABI.
> +
> +As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
> +the ABI guarantees the following behaviours:
> +
> + - Every current or newly introduced syscall can accept any valid tagged
> + pointers.
> +
> + - If a non valid tagged pointer is passed to a syscall then the behaviour
> + is undefined.
> +
> + - Every valid tagged pointer is expected to work as an untagged one.
> +
> + - The kernel preserves any valid tagged pointers and returns them to the
> + userspace unchanged in all the cases except the ones documented in the
> + "Preserving tags" paragraph of tagged-pointers.txt.
I'd think we need to qualify the context here in which the kernel
preserves the tagged pointers. Did you mean on the syscall return?
> +
> +A definition of the meaning of tagged pointers on arm64 can be found in:
> +Documentation/arm64/tagged-pointers.txt.
> +
> +3. ARM64 Tagged Address ABI Exceptions
> +--------------------------------------
> +
> +The behaviours described in paragraph 2, with particular reference to the
"section 2"
> +acceptance by the syscalls of any valid tagged pointer are not applicable
> +to the following cases:
> + - mmap() addr parameter.
> + - mremap() new_address parameter.
> + - prctl_set_mm() struct prctl_map fields.
> + - prctl_set_mm_map() struct prctl_map fields.
> +
> +4. Example of correct usage
> +---------------------------
> +
> +void main(void)
> +{
> + static int tbi_enabled = 0;
> + unsigned long tag = 0;
> +
> + char *ptr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
> + MAP_ANONYMOUS, -1, 0);
> +
> + if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE,
> + 0, 0, 0) == 0)
> + tbi_enabled = 1;
> +
> + if (!ptr)
> + return -1;
> +
> + if (tbi_enabled)
> + tag = rand() & 0xff;
> +
> + ptr = (char *)((unsigned long)ptr | (tag << TAG_SHIFT));
> +
> + *ptr = 'a';
> +
> + ...
> +}
> +
> --
> 2.21.0
--
Catalin
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt
2019-06-12 14:21 ` [PATCH v4 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt Vincenzo Frascino
2019-06-12 14:21 ` Vincenzo Frascino
@ 2019-06-12 15:56 ` Catalin Marinas
2019-06-12 15:56 ` Catalin Marinas
2019-06-12 16:37 ` Szabolcs Nagy
2 siblings, 1 reply; 50+ messages in thread
From: Catalin Marinas @ 2019-06-12 15:56 UTC (permalink / raw)
To: Vincenzo Frascino
Cc: linux-arm-kernel, linux-doc, linux-mm, linux-arch,
linux-kselftest, linux-kernel, Will Deacon, Andrey Konovalov,
Alexander Viro
A couple of minor nits below.
On Wed, Jun 12, 2019 at 03:21:11PM +0100, Vincenzo Frascino wrote:
> --- a/Documentation/arm64/tagged-pointers.txt
> +++ b/Documentation/arm64/tagged-pointers.txt
> @@ -18,7 +18,8 @@ Passing tagged addresses to the kernel
> --------------------------------------
>
> All interpretation of userspace memory addresses by the kernel assumes
> -an address tag of 0x00.
> +an address tag of 0x00, unless the userspace opts-in the ARM64 Tagged
> +Address ABI via the PR_SET_TAGGED_ADDR_CTRL prctl().
>
> This includes, but is not limited to, addresses found in:
>
> @@ -31,18 +32,23 @@ This includes, but is not limited to, addresses found in:
> - the frame pointer (x29) and frame records, e.g. when interpreting
> them to generate a backtrace or call graph.
>
> -Using non-zero address tags in any of these locations may result in an
> -error code being returned, a (fatal) signal being raised, or other modes
> -of failure.
> +Using non-zero address tags in any of these locations when the
> +userspace application did not opt-in to the ARM64 Tagged Address ABI,
Nitpick: drop the comma after "ABI," since a predicate follows.
> +may result in an error code being returned, a (fatal) signal being raised,
> +or other modes of failure.
>
> -For these reasons, passing non-zero address tags to the kernel via
> -system calls is forbidden, and using a non-zero address tag for sp is
> -strongly discouraged.
> +For these reasons, when the userspace application did not opt-in, passing
> +non-zero address tags to the kernel via system calls is forbidden, and using
> +a non-zero address tag for sp is strongly discouraged.
>
> Programs maintaining a frame pointer and frame records that use non-zero
> address tags may suffer impaired or inaccurate debug and profiling
> visibility.
>
> +A definition of the meaning of ARM64 Tagged Address ABI and of the
> +guarantees that the ABI provides when the userspace opts-in via prctl()
> +can be found in: Documentation/arm64/tagged-address-abi.txt.
> +
>
> Preserving tags
> ---------------
> @@ -57,6 +63,9 @@ be preserved.
> The architecture prevents the use of a tagged PC, so the upper byte will
> be set to a sign-extension of bit 55 on exception return.
>
> +This behaviours are preserved even when the the userspace opts-in the ARM64
"These" ... "opts in to"
> +Tagged Address ABI via the PR_SET_TAGGED_ADDR_CTRL prctl().
> +
>
> Other considerations
> --------------------
> --
> 2.21.0
--
Catalin
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt
2019-06-12 15:56 ` Catalin Marinas
@ 2019-06-12 15:56 ` Catalin Marinas
0 siblings, 0 replies; 50+ messages in thread
From: Catalin Marinas @ 2019-06-12 15:56 UTC (permalink / raw)
To: Vincenzo Frascino
Cc: linux-arm-kernel, linux-doc, linux-mm, linux-arch,
linux-kselftest, linux-kernel, Will Deacon, Andrey Konovalov,
Alexander Viro
A couple of minor nits below.
On Wed, Jun 12, 2019 at 03:21:11PM +0100, Vincenzo Frascino wrote:
> --- a/Documentation/arm64/tagged-pointers.txt
> +++ b/Documentation/arm64/tagged-pointers.txt
> @@ -18,7 +18,8 @@ Passing tagged addresses to the kernel
> --------------------------------------
>
> All interpretation of userspace memory addresses by the kernel assumes
> -an address tag of 0x00.
> +an address tag of 0x00, unless the userspace opts-in the ARM64 Tagged
> +Address ABI via the PR_SET_TAGGED_ADDR_CTRL prctl().
>
> This includes, but is not limited to, addresses found in:
>
> @@ -31,18 +32,23 @@ This includes, but is not limited to, addresses found in:
> - the frame pointer (x29) and frame records, e.g. when interpreting
> them to generate a backtrace or call graph.
>
> -Using non-zero address tags in any of these locations may result in an
> -error code being returned, a (fatal) signal being raised, or other modes
> -of failure.
> +Using non-zero address tags in any of these locations when the
> +userspace application did not opt-in to the ARM64 Tagged Address ABI,
Nitpick: drop the comma after "ABI," since a predicate follows.
> +may result in an error code being returned, a (fatal) signal being raised,
> +or other modes of failure.
>
> -For these reasons, passing non-zero address tags to the kernel via
> -system calls is forbidden, and using a non-zero address tag for sp is
> -strongly discouraged.
> +For these reasons, when the userspace application did not opt-in, passing
> +non-zero address tags to the kernel via system calls is forbidden, and using
> +a non-zero address tag for sp is strongly discouraged.
>
> Programs maintaining a frame pointer and frame records that use non-zero
> address tags may suffer impaired or inaccurate debug and profiling
> visibility.
>
> +A definition of the meaning of ARM64 Tagged Address ABI and of the
> +guarantees that the ABI provides when the userspace opts-in via prctl()
> +can be found in: Documentation/arm64/tagged-address-abi.txt.
> +
>
> Preserving tags
> ---------------
> @@ -57,6 +63,9 @@ be preserved.
> The architecture prevents the use of a tagged PC, so the upper byte will
> be set to a sign-extension of bit 55 on exception return.
>
> +This behaviours are preserved even when the the userspace opts-in the ARM64
"These" ... "opts in to"
> +Tagged Address ABI via the PR_SET_TAGGED_ADDR_CTRL prctl().
> +
>
> Other considerations
> --------------------
> --
> 2.21.0
--
Catalin
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-12 14:21 ` [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt Vincenzo Frascino
2019-06-12 14:21 ` Vincenzo Frascino
2019-06-12 15:35 ` Catalin Marinas
@ 2019-06-12 16:30 ` Szabolcs Nagy
2019-06-12 16:30 ` Szabolcs Nagy
2019-06-13 9:20 ` Catalin Marinas
2 siblings, 2 replies; 50+ messages in thread
From: Szabolcs Nagy @ 2019-06-12 16:30 UTC (permalink / raw)
To: Vincenzo Frascino, linux-arm-kernel@lists.infradead.org,
linux-doc@vger.kernel.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: nd, Catalin Marinas, Will Deacon, Andrey Konovalov,
Alexander Viro
On 12/06/2019 15:21, Vincenzo Frascino wrote:
> On arm64 the TCR_EL1.TBI0 bit has been always enabled hence
> the userspace (EL0) is allowed to set a non-zero value in the
> top byte but the resulting pointers are not allowed at the
> user-kernel syscall ABI boundary.
>
> With the relaxed ABI proposed through this document, it is now possible
> to pass tagged pointers to the syscalls, when these pointers are in
> memory ranges obtained by an anonymous (MAP_ANONYMOUS) mmap().
>
> This change in the ABI requires a mechanism to requires the userspace
> to opt-in to such an option.
>
> Specify and document the way in which sysctl and prctl() can be used
> in combination to allow the userspace to opt-in this feature.
>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> CC: Andrey Konovalov <andreyknvl@google.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
> Documentation/arm64/tagged-address-abi.txt | 111 +++++++++++++++++++++
> 1 file changed, 111 insertions(+)
> create mode 100644 Documentation/arm64/tagged-address-abi.txt
>
> diff --git a/Documentation/arm64/tagged-address-abi.txt b/Documentation/arm64/tagged-address-abi.txt
> new file mode 100644
> index 000000000000..96e149e2c55c
> --- /dev/null
> +++ b/Documentation/arm64/tagged-address-abi.txt
> @@ -0,0 +1,111 @@
> +ARM64 TAGGED ADDRESS ABI
> +========================
> +
> +This document describes the usage and semantics of the Tagged Address
> +ABI on arm64.
> +
> +1. Introduction
> +---------------
> +
> +On arm64 the TCR_EL1.TBI0 bit has been always enabled on the arm64 kernel,
> +hence the userspace (EL0) is allowed to set a non-zero value in the top
> +byte but the resulting pointers are not allowed at the user-kernel syscall
> +ABI boundary.
> +
> +This document describes a relaxation of the ABI with which it is possible
> +to pass tagged tagged pointers to the syscalls, when these pointers are in
^^^^^^^^^^^^^
typo.
> +memory ranges obtained as described in paragraph 2.
> +
> +Since it is not desirable to relax the ABI to allow tagged user addresses
> +into the kernel indiscriminately, arm64 provides a new sysctl interface
> +(/proc/sys/abi/tagged_addr) that is used to prevent the applications from
> +enabling the relaxed ABI and a new prctl() interface that can be used to
> +enable or disable the relaxed ABI.
> +
> +The sysctl is meant also for testing purposes in order to provide a simple
> +way for the userspace to verify the return error checking of the prctl()
> +command without having to reconfigure the kernel.
> +
> +The ABI properties are inherited by threads of the same application and
> +fork()'ed children but cleared when a new process is spawn (execve()).
OK.
> +
> +2. ARM64 Tagged Address ABI
> +---------------------------
> +
> +From the kernel syscall interface prospective, we define, for the purposes
^^^^^^^^^^^
perspective
> +of this document, a "valid tagged pointer" as a pointer that either it has
> +a zero value set in the top byte or it has a non-zero value, it is in memory
> +ranges privately owned by a userspace process and it is obtained in one of
> +the following ways:
> + - mmap() done by the process itself, where either:
> + * flags = MAP_PRIVATE | MAP_ANONYMOUS
> + * flags = MAP_PRIVATE and the file descriptor refers to a regular
> + file or "/dev/zero"
this does not make it clear if MAP_FIXED or other
flags are valid (there are many map flags i don't
know, but at least fixed should work and stack/growsdown.
i'd expect anything that's not incompatible with
private|anon to work).
> + - a mapping below sbrk(0) done by the process itself
doesn't the mmap rule cover this?
> + - any memory mapped by the kernel in the process's address space during
> + creation and following the restrictions presented above (i.e. data, bss,
> + stack).
OK.
Can a null pointer have a tag?
(in case NULL is valid to pass to a syscall)
> +
> +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
> +control it using the following prctl()s:
> + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable the Tagged Address ABI.
> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> + Address ABI.
> +
> +As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
> +the ABI guarantees the following behaviours:
> +
> + - Every current or newly introduced syscall can accept any valid tagged
> + pointers.
> +
> + - If a non valid tagged pointer is passed to a syscall then the behaviour
> + is undefined.
> +
> + - Every valid tagged pointer is expected to work as an untagged one.
> +
> + - The kernel preserves any valid tagged pointers and returns them to the
> + userspace unchanged in all the cases except the ones documented in the
> + "Preserving tags" paragraph of tagged-pointers.txt.
OK.
i guess pointers of another process are not "valid tagged
pointers" for the current one, so e.g. in ptrace the
ptracer has to clear the tags before PEEK etc.
> +
> +A definition of the meaning of tagged pointers on arm64 can be found in:
> +Documentation/arm64/tagged-pointers.txt.
> +
> +3. ARM64 Tagged Address ABI Exceptions
> +--------------------------------------
> +
> +The behaviours described in paragraph 2, with particular reference to the
> +acceptance by the syscalls of any valid tagged pointer are not applicable
> +to the following cases:
> + - mmap() addr parameter.
> + - mremap() new_address parameter.
> + - prctl_set_mm() struct prctl_map fields.
> + - prctl_set_mm_map() struct prctl_map fields.
i don't understand the exception: does it mean
that passing a tagged address to these syscalls
is undefined?
> +
> +4. Example of correct usage
> +---------------------------
> +
> +void main(void)
> +{
> + static int tbi_enabled = 0;
> + unsigned long tag = 0;
> +
> + char *ptr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
> + MAP_ANONYMOUS, -1, 0);
> +
> + if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE,
> + 0, 0, 0) == 0)
> + tbi_enabled = 1;
> +
> + if (!ptr)
> + return -1;
mmap returns MAP_FAILED on failure.
> +
> + if (tbi_enabled)
> + tag = rand() & 0xff;
> +
> + ptr = (char *)((unsigned long)ptr | (tag << TAG_SHIFT));
> +
> + *ptr = 'a';
> +
> + ...
> +}
> +
>
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-12 16:30 ` Szabolcs Nagy
@ 2019-06-12 16:30 ` Szabolcs Nagy
2019-06-13 9:20 ` Catalin Marinas
1 sibling, 0 replies; 50+ messages in thread
From: Szabolcs Nagy @ 2019-06-12 16:30 UTC (permalink / raw)
To: Vincenzo Frascino, linux-arm-kernel@lists.infradead.org,
linux-doc@vger.kernel.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: nd, Catalin Marinas, Will Deacon, Andrey Konovalov,
Alexander Viro
On 12/06/2019 15:21, Vincenzo Frascino wrote:
> On arm64 the TCR_EL1.TBI0 bit has been always enabled hence
> the userspace (EL0) is allowed to set a non-zero value in the
> top byte but the resulting pointers are not allowed at the
> user-kernel syscall ABI boundary.
>
> With the relaxed ABI proposed through this document, it is now possible
> to pass tagged pointers to the syscalls, when these pointers are in
> memory ranges obtained by an anonymous (MAP_ANONYMOUS) mmap().
>
> This change in the ABI requires a mechanism to requires the userspace
> to opt-in to such an option.
>
> Specify and document the way in which sysctl and prctl() can be used
> in combination to allow the userspace to opt-in this feature.
>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> CC: Andrey Konovalov <andreyknvl@google.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
> Documentation/arm64/tagged-address-abi.txt | 111 +++++++++++++++++++++
> 1 file changed, 111 insertions(+)
> create mode 100644 Documentation/arm64/tagged-address-abi.txt
>
> diff --git a/Documentation/arm64/tagged-address-abi.txt b/Documentation/arm64/tagged-address-abi.txt
> new file mode 100644
> index 000000000000..96e149e2c55c
> --- /dev/null
> +++ b/Documentation/arm64/tagged-address-abi.txt
> @@ -0,0 +1,111 @@
> +ARM64 TAGGED ADDRESS ABI
> +========================
> +
> +This document describes the usage and semantics of the Tagged Address
> +ABI on arm64.
> +
> +1. Introduction
> +---------------
> +
> +On arm64 the TCR_EL1.TBI0 bit has been always enabled on the arm64 kernel,
> +hence the userspace (EL0) is allowed to set a non-zero value in the top
> +byte but the resulting pointers are not allowed at the user-kernel syscall
> +ABI boundary.
> +
> +This document describes a relaxation of the ABI with which it is possible
> +to pass tagged tagged pointers to the syscalls, when these pointers are in
^^^^^^^^^^^^^
typo.
> +memory ranges obtained as described in paragraph 2.
> +
> +Since it is not desirable to relax the ABI to allow tagged user addresses
> +into the kernel indiscriminately, arm64 provides a new sysctl interface
> +(/proc/sys/abi/tagged_addr) that is used to prevent the applications from
> +enabling the relaxed ABI and a new prctl() interface that can be used to
> +enable or disable the relaxed ABI.
> +
> +The sysctl is meant also for testing purposes in order to provide a simple
> +way for the userspace to verify the return error checking of the prctl()
> +command without having to reconfigure the kernel.
> +
> +The ABI properties are inherited by threads of the same application and
> +fork()'ed children but cleared when a new process is spawn (execve()).
OK.
> +
> +2. ARM64 Tagged Address ABI
> +---------------------------
> +
> +From the kernel syscall interface prospective, we define, for the purposes
^^^^^^^^^^^
perspective
> +of this document, a "valid tagged pointer" as a pointer that either it has
> +a zero value set in the top byte or it has a non-zero value, it is in memory
> +ranges privately owned by a userspace process and it is obtained in one of
> +the following ways:
> + - mmap() done by the process itself, where either:
> + * flags = MAP_PRIVATE | MAP_ANONYMOUS
> + * flags = MAP_PRIVATE and the file descriptor refers to a regular
> + file or "/dev/zero"
this does not make it clear if MAP_FIXED or other
flags are valid (there are many map flags i don't
know, but at least fixed should work and stack/growsdown.
i'd expect anything that's not incompatible with
private|anon to work).
> + - a mapping below sbrk(0) done by the process itself
doesn't the mmap rule cover this?
> + - any memory mapped by the kernel in the process's address space during
> + creation and following the restrictions presented above (i.e. data, bss,
> + stack).
OK.
Can a null pointer have a tag?
(in case NULL is valid to pass to a syscall)
> +
> +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
> +control it using the following prctl()s:
> + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable the Tagged Address ABI.
> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> + Address ABI.
> +
> +As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
> +the ABI guarantees the following behaviours:
> +
> + - Every current or newly introduced syscall can accept any valid tagged
> + pointers.
> +
> + - If a non valid tagged pointer is passed to a syscall then the behaviour
> + is undefined.
> +
> + - Every valid tagged pointer is expected to work as an untagged one.
> +
> + - The kernel preserves any valid tagged pointers and returns them to the
> + userspace unchanged in all the cases except the ones documented in the
> + "Preserving tags" paragraph of tagged-pointers.txt.
OK.
i guess pointers of another process are not "valid tagged
pointers" for the current one, so e.g. in ptrace the
ptracer has to clear the tags before PEEK etc.
> +
> +A definition of the meaning of tagged pointers on arm64 can be found in:
> +Documentation/arm64/tagged-pointers.txt.
> +
> +3. ARM64 Tagged Address ABI Exceptions
> +--------------------------------------
> +
> +The behaviours described in paragraph 2, with particular reference to the
> +acceptance by the syscalls of any valid tagged pointer are not applicable
> +to the following cases:
> + - mmap() addr parameter.
> + - mremap() new_address parameter.
> + - prctl_set_mm() struct prctl_map fields.
> + - prctl_set_mm_map() struct prctl_map fields.
i don't understand the exception: does it mean
that passing a tagged address to these syscalls
is undefined?
> +
> +4. Example of correct usage
> +---------------------------
> +
> +void main(void)
> +{
> + static int tbi_enabled = 0;
> + unsigned long tag = 0;
> +
> + char *ptr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
> + MAP_ANONYMOUS, -1, 0);
> +
> + if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE,
> + 0, 0, 0) == 0)
> + tbi_enabled = 1;
> +
> + if (!ptr)
> + return -1;
mmap returns MAP_FAILED on failure.
> +
> + if (tbi_enabled)
> + tag = rand() & 0xff;
> +
> + ptr = (char *)((unsigned long)ptr | (tag << TAG_SHIFT));
> +
> + *ptr = 'a';
> +
> + ...
> +}
> +
>
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt
2019-06-12 14:21 ` [PATCH v4 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt Vincenzo Frascino
2019-06-12 14:21 ` Vincenzo Frascino
2019-06-12 15:56 ` Catalin Marinas
@ 2019-06-12 16:37 ` Szabolcs Nagy
2019-06-12 16:37 ` Szabolcs Nagy
2 siblings, 1 reply; 50+ messages in thread
From: Szabolcs Nagy @ 2019-06-12 16:37 UTC (permalink / raw)
To: Vincenzo Frascino, linux-arm-kernel@lists.infradead.org,
linux-doc@vger.kernel.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: nd, Catalin Marinas, Will Deacon, Andrey Konovalov,
Alexander Viro
On 12/06/2019 15:21, Vincenzo Frascino wrote:
> On arm64 the TCR_EL1.TBI0 bit has been always enabled hence
> the userspace (EL0) is allowed to set a non-zero value in the
> top byte but the resulting pointers are not allowed at the
> user-kernel syscall ABI boundary.
>
> With the relaxed ABI proposed in this set, it is now possible to pass
> tagged pointers to the syscalls, when these pointers are in memory
> ranges obtained by an anonymous (MAP_ANONYMOUS) mmap().
>
> Relax the requirements described in tagged-pointers.txt to be compliant
> with the behaviours guaranteed by the ARM64 Tagged Address ABI.
>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> CC: Andrey Konovalov <andreyknvl@google.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
> Documentation/arm64/tagged-pointers.txt | 23 ++++++++++++++++-------
> 1 file changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/Documentation/arm64/tagged-pointers.txt b/Documentation/arm64/tagged-pointers.txt
> index a25a99e82bb1..db58a7e95805 100644
> --- a/Documentation/arm64/tagged-pointers.txt
> +++ b/Documentation/arm64/tagged-pointers.txt
> @@ -18,7 +18,8 @@ Passing tagged addresses to the kernel
> --------------------------------------
>
> All interpretation of userspace memory addresses by the kernel assumes
> -an address tag of 0x00.
> +an address tag of 0x00, unless the userspace opts-in the ARM64 Tagged
> +Address ABI via the PR_SET_TAGGED_ADDR_CTRL prctl().
>
> This includes, but is not limited to, addresses found in:
>
> @@ -31,18 +32,23 @@ This includes, but is not limited to, addresses found in:
> - the frame pointer (x29) and frame records, e.g. when interpreting
> them to generate a backtrace or call graph.
>
> -Using non-zero address tags in any of these locations may result in an
> -error code being returned, a (fatal) signal being raised, or other modes
> -of failure.
> +Using non-zero address tags in any of these locations when the
> +userspace application did not opt-in to the ARM64 Tagged Address ABI,
> +may result in an error code being returned, a (fatal) signal being raised,
> +or other modes of failure.
>
> -For these reasons, passing non-zero address tags to the kernel via
> -system calls is forbidden, and using a non-zero address tag for sp is
> -strongly discouraged.
> +For these reasons, when the userspace application did not opt-in, passing
> +non-zero address tags to the kernel via system calls is forbidden, and using
> +a non-zero address tag for sp is strongly discouraged.
>
> Programs maintaining a frame pointer and frame records that use non-zero
> address tags may suffer impaired or inaccurate debug and profiling
> visibility.
>
> +A definition of the meaning of ARM64 Tagged Address ABI and of the
> +guarantees that the ABI provides when the userspace opts-in via prctl()
> +can be found in: Documentation/arm64/tagged-address-abi.txt.
> +
OK.
>
> Preserving tags
> ---------------
> @@ -57,6 +63,9 @@ be preserved.
> The architecture prevents the use of a tagged PC, so the upper byte will
> be set to a sign-extension of bit 55 on exception return.
>
> +This behaviours are preserved even when the the userspace opts-in the ARM64
these behaviours.
> +Tagged Address ABI via the PR_SET_TAGGED_ADDR_CTRL prctl().
> +
>
> Other considerations
> --------------------
>
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt
2019-06-12 16:37 ` Szabolcs Nagy
@ 2019-06-12 16:37 ` Szabolcs Nagy
0 siblings, 0 replies; 50+ messages in thread
From: Szabolcs Nagy @ 2019-06-12 16:37 UTC (permalink / raw)
To: Vincenzo Frascino, linux-arm-kernel@lists.infradead.org,
linux-doc@vger.kernel.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: nd, Catalin Marinas, Will Deacon, Andrey Konovalov,
Alexander Viro
On 12/06/2019 15:21, Vincenzo Frascino wrote:
> On arm64 the TCR_EL1.TBI0 bit has been always enabled hence
> the userspace (EL0) is allowed to set a non-zero value in the
> top byte but the resulting pointers are not allowed at the
> user-kernel syscall ABI boundary.
>
> With the relaxed ABI proposed in this set, it is now possible to pass
> tagged pointers to the syscalls, when these pointers are in memory
> ranges obtained by an anonymous (MAP_ANONYMOUS) mmap().
>
> Relax the requirements described in tagged-pointers.txt to be compliant
> with the behaviours guaranteed by the ARM64 Tagged Address ABI.
>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> CC: Andrey Konovalov <andreyknvl@google.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
> Documentation/arm64/tagged-pointers.txt | 23 ++++++++++++++++-------
> 1 file changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/Documentation/arm64/tagged-pointers.txt b/Documentation/arm64/tagged-pointers.txt
> index a25a99e82bb1..db58a7e95805 100644
> --- a/Documentation/arm64/tagged-pointers.txt
> +++ b/Documentation/arm64/tagged-pointers.txt
> @@ -18,7 +18,8 @@ Passing tagged addresses to the kernel
> --------------------------------------
>
> All interpretation of userspace memory addresses by the kernel assumes
> -an address tag of 0x00.
> +an address tag of 0x00, unless the userspace opts-in the ARM64 Tagged
> +Address ABI via the PR_SET_TAGGED_ADDR_CTRL prctl().
>
> This includes, but is not limited to, addresses found in:
>
> @@ -31,18 +32,23 @@ This includes, but is not limited to, addresses found in:
> - the frame pointer (x29) and frame records, e.g. when interpreting
> them to generate a backtrace or call graph.
>
> -Using non-zero address tags in any of these locations may result in an
> -error code being returned, a (fatal) signal being raised, or other modes
> -of failure.
> +Using non-zero address tags in any of these locations when the
> +userspace application did not opt-in to the ARM64 Tagged Address ABI,
> +may result in an error code being returned, a (fatal) signal being raised,
> +or other modes of failure.
>
> -For these reasons, passing non-zero address tags to the kernel via
> -system calls is forbidden, and using a non-zero address tag for sp is
> -strongly discouraged.
> +For these reasons, when the userspace application did not opt-in, passing
> +non-zero address tags to the kernel via system calls is forbidden, and using
> +a non-zero address tag for sp is strongly discouraged.
>
> Programs maintaining a frame pointer and frame records that use non-zero
> address tags may suffer impaired or inaccurate debug and profiling
> visibility.
>
> +A definition of the meaning of ARM64 Tagged Address ABI and of the
> +guarantees that the ABI provides when the userspace opts-in via prctl()
> +can be found in: Documentation/arm64/tagged-address-abi.txt.
> +
OK.
>
> Preserving tags
> ---------------
> @@ -57,6 +63,9 @@ be preserved.
> The architecture prevents the use of a tagged PC, so the upper byte will
> be set to a sign-extension of bit 55 on exception return.
>
> +This behaviours are preserved even when the the userspace opts-in the ARM64
these behaviours.
> +Tagged Address ABI via the PR_SET_TAGGED_ADDR_CTRL prctl().
> +
>
> Other considerations
> --------------------
>
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-12 16:30 ` Szabolcs Nagy
2019-06-12 16:30 ` Szabolcs Nagy
@ 2019-06-13 9:20 ` Catalin Marinas
2019-06-13 9:20 ` Catalin Marinas
2019-06-13 10:14 ` Szabolcs Nagy
1 sibling, 2 replies; 50+ messages in thread
From: Catalin Marinas @ 2019-06-13 9:20 UTC (permalink / raw)
To: Szabolcs Nagy
Cc: linux-arch@vger.kernel.org, nd, linux-doc@vger.kernel.org,
Andrey Konovalov, Will Deacon, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, Alexander Viro,
linux-kselftest@vger.kernel.org, Vincenzo Frascino,
linux-arm-kernel@lists.infradead.org
Hi Szabolcs,
On Wed, Jun 12, 2019 at 05:30:34PM +0100, Szabolcs Nagy wrote:
> On 12/06/2019 15:21, Vincenzo Frascino wrote:
> > +2. ARM64 Tagged Address ABI
> > +---------------------------
> > +
> > +From the kernel syscall interface prospective, we define, for the purposes
> ^^^^^^^^^^^
> perspective
>
> > +of this document, a "valid tagged pointer" as a pointer that either it has
> > +a zero value set in the top byte or it has a non-zero value, it is in memory
> > +ranges privately owned by a userspace process and it is obtained in one of
> > +the following ways:
> > + - mmap() done by the process itself, where either:
> > + * flags = MAP_PRIVATE | MAP_ANONYMOUS
> > + * flags = MAP_PRIVATE and the file descriptor refers to a regular
> > + file or "/dev/zero"
>
> this does not make it clear if MAP_FIXED or other flags are valid
> (there are many map flags i don't know, but at least fixed should work
> and stack/growsdown. i'd expect anything that's not incompatible with
> private|anon to work).
Just to clarify, this document tries to define the memory ranges from
where tagged addresses can be passed into the kernel in the context
of TBI only (not MTE); that is for hwasan support. FIXED or GROWSDOWN
should not affect this.
> > + - a mapping below sbrk(0) done by the process itself
>
> doesn't the mmap rule cover this?
IIUC it doesn't cover it as that's memory mapped by the kernel
automatically on access vs a pointer returned by mmap(). The statement
above talks about how the address is obtained by the user.
> > + - any memory mapped by the kernel in the process's address space during
> > + creation and following the restrictions presented above (i.e. data, bss,
> > + stack).
>
> OK.
>
> Can a null pointer have a tag?
> (in case NULL is valid to pass to a syscall)
Good point. I don't think it can. We may change this for MTE where we
give a hint tag but no hint address, however, this document only covers
TBI for now.
> > +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
> > +control it using the following prctl()s:
> > + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable the Tagged Address ABI.
> > + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> > + Address ABI.
> > +
> > +As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
> > +the ABI guarantees the following behaviours:
> > +
> > + - Every current or newly introduced syscall can accept any valid tagged
> > + pointers.
> > +
> > + - If a non valid tagged pointer is passed to a syscall then the behaviour
> > + is undefined.
> > +
> > + - Every valid tagged pointer is expected to work as an untagged one.
> > +
> > + - The kernel preserves any valid tagged pointers and returns them to the
> > + userspace unchanged in all the cases except the ones documented in the
> > + "Preserving tags" paragraph of tagged-pointers.txt.
>
> OK.
>
> i guess pointers of another process are not "valid tagged pointers"
> for the current one, so e.g. in ptrace the ptracer has to clear the
> tags before PEEK etc.
Another good point. Are there any pros/cons here or use-cases? When we
add MTE support, should we handle this differently?
> > +A definition of the meaning of tagged pointers on arm64 can be found in:
> > +Documentation/arm64/tagged-pointers.txt.
> > +
> > +3. ARM64 Tagged Address ABI Exceptions
> > +--------------------------------------
> > +
> > +The behaviours described in paragraph 2, with particular reference to the
> > +acceptance by the syscalls of any valid tagged pointer are not applicable
> > +to the following cases:
> > + - mmap() addr parameter.
> > + - mremap() new_address parameter.
> > + - prctl_set_mm() struct prctl_map fields.
> > + - prctl_set_mm_map() struct prctl_map fields.
>
> i don't understand the exception: does it mean that passing a tagged
> address to these syscalls is undefined?
I'd say it's as undefined as it is right now without these patches. We
may be able to explain this better in the document.
--
Catalin
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 9:20 ` Catalin Marinas
@ 2019-06-13 9:20 ` Catalin Marinas
2019-06-13 10:14 ` Szabolcs Nagy
1 sibling, 0 replies; 50+ messages in thread
From: Catalin Marinas @ 2019-06-13 9:20 UTC (permalink / raw)
To: Szabolcs Nagy
Cc: Vincenzo Frascino, linux-arm-kernel@lists.infradead.org,
linux-doc@vger.kernel.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, nd, Will Deacon, Andrey Konovalov,
Alexander Viro
Hi Szabolcs,
On Wed, Jun 12, 2019 at 05:30:34PM +0100, Szabolcs Nagy wrote:
> On 12/06/2019 15:21, Vincenzo Frascino wrote:
> > +2. ARM64 Tagged Address ABI
> > +---------------------------
> > +
> > +From the kernel syscall interface prospective, we define, for the purposes
> ^^^^^^^^^^^
> perspective
>
> > +of this document, a "valid tagged pointer" as a pointer that either it has
> > +a zero value set in the top byte or it has a non-zero value, it is in memory
> > +ranges privately owned by a userspace process and it is obtained in one of
> > +the following ways:
> > + - mmap() done by the process itself, where either:
> > + * flags = MAP_PRIVATE | MAP_ANONYMOUS
> > + * flags = MAP_PRIVATE and the file descriptor refers to a regular
> > + file or "/dev/zero"
>
> this does not make it clear if MAP_FIXED or other flags are valid
> (there are many map flags i don't know, but at least fixed should work
> and stack/growsdown. i'd expect anything that's not incompatible with
> private|anon to work).
Just to clarify, this document tries to define the memory ranges from
where tagged addresses can be passed into the kernel in the context
of TBI only (not MTE); that is for hwasan support. FIXED or GROWSDOWN
should not affect this.
> > + - a mapping below sbrk(0) done by the process itself
>
> doesn't the mmap rule cover this?
IIUC it doesn't cover it as that's memory mapped by the kernel
automatically on access vs a pointer returned by mmap(). The statement
above talks about how the address is obtained by the user.
> > + - any memory mapped by the kernel in the process's address space during
> > + creation and following the restrictions presented above (i.e. data, bss,
> > + stack).
>
> OK.
>
> Can a null pointer have a tag?
> (in case NULL is valid to pass to a syscall)
Good point. I don't think it can. We may change this for MTE where we
give a hint tag but no hint address, however, this document only covers
TBI for now.
> > +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
> > +control it using the following prctl()s:
> > + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable the Tagged Address ABI.
> > + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> > + Address ABI.
> > +
> > +As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
> > +the ABI guarantees the following behaviours:
> > +
> > + - Every current or newly introduced syscall can accept any valid tagged
> > + pointers.
> > +
> > + - If a non valid tagged pointer is passed to a syscall then the behaviour
> > + is undefined.
> > +
> > + - Every valid tagged pointer is expected to work as an untagged one.
> > +
> > + - The kernel preserves any valid tagged pointers and returns them to the
> > + userspace unchanged in all the cases except the ones documented in the
> > + "Preserving tags" paragraph of tagged-pointers.txt.
>
> OK.
>
> i guess pointers of another process are not "valid tagged pointers"
> for the current one, so e.g. in ptrace the ptracer has to clear the
> tags before PEEK etc.
Another good point. Are there any pros/cons here or use-cases? When we
add MTE support, should we handle this differently?
> > +A definition of the meaning of tagged pointers on arm64 can be found in:
> > +Documentation/arm64/tagged-pointers.txt.
> > +
> > +3. ARM64 Tagged Address ABI Exceptions
> > +--------------------------------------
> > +
> > +The behaviours described in paragraph 2, with particular reference to the
> > +acceptance by the syscalls of any valid tagged pointer are not applicable
> > +to the following cases:
> > + - mmap() addr parameter.
> > + - mremap() new_address parameter.
> > + - prctl_set_mm() struct prctl_map fields.
> > + - prctl_set_mm_map() struct prctl_map fields.
>
> i don't understand the exception: does it mean that passing a tagged
> address to these syscalls is undefined?
I'd say it's as undefined as it is right now without these patches. We
may be able to explain this better in the document.
--
Catalin
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 9:20 ` Catalin Marinas
2019-06-13 9:20 ` Catalin Marinas
@ 2019-06-13 10:14 ` Szabolcs Nagy
2019-06-13 10:14 ` Szabolcs Nagy
2019-06-13 11:16 ` Vincenzo Frascino
1 sibling, 2 replies; 50+ messages in thread
From: Szabolcs Nagy @ 2019-06-13 10:14 UTC (permalink / raw)
To: Catalin Marinas
Cc: linux-arch@vger.kernel.org, Vincenzo Frascino,
linux-doc@vger.kernel.org, Andrey Konovalov, Will Deacon,
linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Viro,
linux-kselftest@vger.kernel.org, nd,
linux-arm-kernel@lists.infradead.org
On 13/06/2019 10:20, Catalin Marinas wrote:
> Hi Szabolcs,
>
> On Wed, Jun 12, 2019 at 05:30:34PM +0100, Szabolcs Nagy wrote:
>> On 12/06/2019 15:21, Vincenzo Frascino wrote:
>>> +2. ARM64 Tagged Address ABI
>>> +---------------------------
>>> +
>>> +From the kernel syscall interface prospective, we define, for the purposes
>> ^^^^^^^^^^^
>> perspective
>>
>>> +of this document, a "valid tagged pointer" as a pointer that either it has
>>> +a zero value set in the top byte or it has a non-zero value, it is in memory
>>> +ranges privately owned by a userspace process and it is obtained in one of
>>> +the following ways:
>>> + - mmap() done by the process itself, where either:
>>> + * flags = MAP_PRIVATE | MAP_ANONYMOUS
>>> + * flags = MAP_PRIVATE and the file descriptor refers to a regular
>>> + file or "/dev/zero"
>>
>> this does not make it clear if MAP_FIXED or other flags are valid
>> (there are many map flags i don't know, but at least fixed should work
>> and stack/growsdown. i'd expect anything that's not incompatible with
>> private|anon to work).
>
> Just to clarify, this document tries to define the memory ranges from
> where tagged addresses can be passed into the kernel in the context
> of TBI only (not MTE); that is for hwasan support. FIXED or GROWSDOWN
> should not affect this.
yes, so either the text should list MAP_* flags that don't affect
the pointer tagging semantics or specify private|anon mapping
with different wording.
>>> + - a mapping below sbrk(0) done by the process itself
>>
>> doesn't the mmap rule cover this?
>
> IIUC it doesn't cover it as that's memory mapped by the kernel
> automatically on access vs a pointer returned by mmap(). The statement
> above talks about how the address is obtained by the user.
ok i read 'mapping below sbrk' as an mmap (possibly MAP_FIXED)
that happens to be below the heap area.
i think "below sbrk(0)" is not the best term to use: there
may be address range below the heap area that can be mmapped
and thus below sbrk(0) and sbrk is a posix api not a linux
syscall, the libc can implement it with mmap or whatever.
i'm not sure what the right term for 'heap area' is
(the address range between syscall(__NR_brk,0) at
program startup and its current value?)
>>> + - any memory mapped by the kernel in the process's address space during
>>> + creation and following the restrictions presented above (i.e. data, bss,
>>> + stack).
>>
>> OK.
>>
>> Can a null pointer have a tag?
>> (in case NULL is valid to pass to a syscall)
>
> Good point. I don't think it can. We may change this for MTE where we
> give a hint tag but no hint address, however, this document only covers
> TBI for now.
OK.
>>> +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
>>> +control it using the following prctl()s:
>>> + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable the Tagged Address ABI.
>>> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
>>> + Address ABI.
>>> +
>>> +As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
>>> +the ABI guarantees the following behaviours:
>>> +
>>> + - Every current or newly introduced syscall can accept any valid tagged
>>> + pointers.
>>> +
>>> + - If a non valid tagged pointer is passed to a syscall then the behaviour
>>> + is undefined.
>>> +
>>> + - Every valid tagged pointer is expected to work as an untagged one.
>>> +
>>> + - The kernel preserves any valid tagged pointers and returns them to the
>>> + userspace unchanged in all the cases except the ones documented in the
>>> + "Preserving tags" paragraph of tagged-pointers.txt.
>>
>> OK.
>>
>> i guess pointers of another process are not "valid tagged pointers"
>> for the current one, so e.g. in ptrace the ptracer has to clear the
>> tags before PEEK etc.
>
> Another good point. Are there any pros/cons here or use-cases? When we
> add MTE support, should we handle this differently?
i'm not sure what gdb does currently, but it has
an 'address_significant' hook used at a few places
that drops the tag on aarch64, so it probably
avoids passing tagged pointer to ptrace.
i was worried about strace which tries to print
structs passed to syscalls and follow pointers in
them which currently would work, but if we allow
tags in syscalls then it needs some update.
(i haven't checked the strace code though)
>>> +A definition of the meaning of tagged pointers on arm64 can be found in:
>>> +Documentation/arm64/tagged-pointers.txt.
>>> +
>>> +3. ARM64 Tagged Address ABI Exceptions
>>> +--------------------------------------
>>> +
>>> +The behaviours described in paragraph 2, with particular reference to the
>>> +acceptance by the syscalls of any valid tagged pointer are not applicable
>>> +to the following cases:
>>> + - mmap() addr parameter.
>>> + - mremap() new_address parameter.
>>> + - prctl_set_mm() struct prctl_map fields.
>>> + - prctl_set_mm_map() struct prctl_map fields.
>>
>> i don't understand the exception: does it mean that passing a tagged
>> address to these syscalls is undefined?
>
> I'd say it's as undefined as it is right now without these patches. We
> may be able to explain this better in the document.
>
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 10:14 ` Szabolcs Nagy
@ 2019-06-13 10:14 ` Szabolcs Nagy
2019-06-13 11:16 ` Vincenzo Frascino
1 sibling, 0 replies; 50+ messages in thread
From: Szabolcs Nagy @ 2019-06-13 10:14 UTC (permalink / raw)
To: Catalin Marinas
Cc: nd, Vincenzo Frascino, linux-arm-kernel@lists.infradead.org,
linux-doc@vger.kernel.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, Will Deacon, Andrey Konovalov,
Alexander Viro
On 13/06/2019 10:20, Catalin Marinas wrote:
> Hi Szabolcs,
>
> On Wed, Jun 12, 2019 at 05:30:34PM +0100, Szabolcs Nagy wrote:
>> On 12/06/2019 15:21, Vincenzo Frascino wrote:
>>> +2. ARM64 Tagged Address ABI
>>> +---------------------------
>>> +
>>> +From the kernel syscall interface prospective, we define, for the purposes
>> ^^^^^^^^^^^
>> perspective
>>
>>> +of this document, a "valid tagged pointer" as a pointer that either it has
>>> +a zero value set in the top byte or it has a non-zero value, it is in memory
>>> +ranges privately owned by a userspace process and it is obtained in one of
>>> +the following ways:
>>> + - mmap() done by the process itself, where either:
>>> + * flags = MAP_PRIVATE | MAP_ANONYMOUS
>>> + * flags = MAP_PRIVATE and the file descriptor refers to a regular
>>> + file or "/dev/zero"
>>
>> this does not make it clear if MAP_FIXED or other flags are valid
>> (there are many map flags i don't know, but at least fixed should work
>> and stack/growsdown. i'd expect anything that's not incompatible with
>> private|anon to work).
>
> Just to clarify, this document tries to define the memory ranges from
> where tagged addresses can be passed into the kernel in the context
> of TBI only (not MTE); that is for hwasan support. FIXED or GROWSDOWN
> should not affect this.
yes, so either the text should list MAP_* flags that don't affect
the pointer tagging semantics or specify private|anon mapping
with different wording.
>>> + - a mapping below sbrk(0) done by the process itself
>>
>> doesn't the mmap rule cover this?
>
> IIUC it doesn't cover it as that's memory mapped by the kernel
> automatically on access vs a pointer returned by mmap(). The statement
> above talks about how the address is obtained by the user.
ok i read 'mapping below sbrk' as an mmap (possibly MAP_FIXED)
that happens to be below the heap area.
i think "below sbrk(0)" is not the best term to use: there
may be address range below the heap area that can be mmapped
and thus below sbrk(0) and sbrk is a posix api not a linux
syscall, the libc can implement it with mmap or whatever.
i'm not sure what the right term for 'heap area' is
(the address range between syscall(__NR_brk,0) at
program startup and its current value?)
>>> + - any memory mapped by the kernel in the process's address space during
>>> + creation and following the restrictions presented above (i.e. data, bss,
>>> + stack).
>>
>> OK.
>>
>> Can a null pointer have a tag?
>> (in case NULL is valid to pass to a syscall)
>
> Good point. I don't think it can. We may change this for MTE where we
> give a hint tag but no hint address, however, this document only covers
> TBI for now.
OK.
>>> +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
>>> +control it using the following prctl()s:
>>> + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable the Tagged Address ABI.
>>> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
>>> + Address ABI.
>>> +
>>> +As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
>>> +the ABI guarantees the following behaviours:
>>> +
>>> + - Every current or newly introduced syscall can accept any valid tagged
>>> + pointers.
>>> +
>>> + - If a non valid tagged pointer is passed to a syscall then the behaviour
>>> + is undefined.
>>> +
>>> + - Every valid tagged pointer is expected to work as an untagged one.
>>> +
>>> + - The kernel preserves any valid tagged pointers and returns them to the
>>> + userspace unchanged in all the cases except the ones documented in the
>>> + "Preserving tags" paragraph of tagged-pointers.txt.
>>
>> OK.
>>
>> i guess pointers of another process are not "valid tagged pointers"
>> for the current one, so e.g. in ptrace the ptracer has to clear the
>> tags before PEEK etc.
>
> Another good point. Are there any pros/cons here or use-cases? When we
> add MTE support, should we handle this differently?
i'm not sure what gdb does currently, but it has
an 'address_significant' hook used at a few places
that drops the tag on aarch64, so it probably
avoids passing tagged pointer to ptrace.
i was worried about strace which tries to print
structs passed to syscalls and follow pointers in
them which currently would work, but if we allow
tags in syscalls then it needs some update.
(i haven't checked the strace code though)
>>> +A definition of the meaning of tagged pointers on arm64 can be found in:
>>> +Documentation/arm64/tagged-pointers.txt.
>>> +
>>> +3. ARM64 Tagged Address ABI Exceptions
>>> +--------------------------------------
>>> +
>>> +The behaviours described in paragraph 2, with particular reference to the
>>> +acceptance by the syscalls of any valid tagged pointer are not applicable
>>> +to the following cases:
>>> + - mmap() addr parameter.
>>> + - mremap() new_address parameter.
>>> + - prctl_set_mm() struct prctl_map fields.
>>> + - prctl_set_mm_map() struct prctl_map fields.
>>
>> i don't understand the exception: does it mean that passing a tagged
>> address to these syscalls is undefined?
>
> I'd say it's as undefined as it is right now without these patches. We
> may be able to explain this better in the document.
>
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-12 15:35 ` Catalin Marinas
2019-06-12 15:35 ` Catalin Marinas
@ 2019-06-13 10:15 ` Vincenzo Frascino
2019-06-13 10:15 ` Vincenzo Frascino
2019-06-13 11:37 ` Dave Martin
1 sibling, 2 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-13 10:15 UTC (permalink / raw)
To: Catalin Marinas
Cc: linux-arch, linux-doc, Szabolcs Nagy, Andrey Konovalov,
Will Deacon, linux-kernel, linux-mm, Alexander Viro,
linux-kselftest, linux-arm-kernel
Hi Catalin,
On 12/06/2019 16:35, Catalin Marinas wrote:
> Hi Vincenzo,
>
> Some minor comments below but it looks fine to me overall. Cc'ing
> Szabolcs as well since I'd like a view from the libc people.
>
Thanks for this, I saw Szabolcs comments.
> On Wed, Jun 12, 2019 at 03:21:10PM +0100, Vincenzo Frascino wrote:
>> diff --git a/Documentation/arm64/tagged-address-abi.txt b/Documentation/arm64/tagged-address-abi.txt
>> new file mode 100644
>> index 000000000000..96e149e2c55c
>> --- /dev/null
>> +++ b/Documentation/arm64/tagged-address-abi.txt
>> @@ -0,0 +1,111 @@
>> +ARM64 TAGGED ADDRESS ABI
>> +========================
>> +
>> +This document describes the usage and semantics of the Tagged Address
>> +ABI on arm64.
>> +
>> +1. Introduction
>> +---------------
>> +
>> +On arm64 the TCR_EL1.TBI0 bit has been always enabled on the arm64 kernel,
>> +hence the userspace (EL0) is allowed to set a non-zero value in the top
>
> I'd be clearer here: "userspace (EL0) is allowed to perform a user
> memory access through a 64-bit pointer with a non-zero top byte" (or
> something along the lines). Otherwise setting a non-zero top byte is
> allowed on any architecture, dereferencing it is a problem.
>
Ok.
>> +byte but the resulting pointers are not allowed at the user-kernel syscall
>> +ABI boundary.
>> +
>> +This document describes a relaxation of the ABI with which it is possible
>
> "relaxation of the ABI that makes it possible to..."
>
>> +to pass tagged tagged pointers to the syscalls, when these pointers are in
>> +memory ranges obtained as described in paragraph 2.
>
> "section 2" is better. There are a lot more paragraphs.
>
Agree.
>> +
>> +Since it is not desirable to relax the ABI to allow tagged user addresses
>> +into the kernel indiscriminately, arm64 provides a new sysctl interface
>> +(/proc/sys/abi/tagged_addr) that is used to prevent the applications from
>> +enabling the relaxed ABI and a new prctl() interface that can be used to
>> +enable or disable the relaxed ABI.
>> +
>> +The sysctl is meant also for testing purposes in order to provide a simple
>> +way for the userspace to verify the return error checking of the prctl()
>> +command without having to reconfigure the kernel.
>> +
>> +The ABI properties are inherited by threads of the same application and
>> +fork()'ed children but cleared when a new process is spawn (execve()).
>
> "spawned".
>
> I guess you could drop these three paragraphs here and mention the
> inheritance properties when introducing the prctl() below. You can also
> mention the global sysctl switch after the prctl() was introduced.
>
I will move the last two (rewording them) to the _section_ 2, but I would still
prefer the Introduction to give an overview of the solution as well.
>> +
>> +2. ARM64 Tagged Address ABI
>> +---------------------------
>> +
>> +From the kernel syscall interface prospective, we define, for the purposes
>> +of this document, a "valid tagged pointer" as a pointer that either it has
>
> "either has" (no 'it') sounds slightly better but I'm not a native
> English speaker either.
>
>> +a zero value set in the top byte or it has a non-zero value, it is in memory
>> +ranges privately owned by a userspace process and it is obtained in one of
>> +the following ways:
>> + - mmap() done by the process itself, where either:
>> + * flags = MAP_PRIVATE | MAP_ANONYMOUS
>> + * flags = MAP_PRIVATE and the file descriptor refers to a regular
>> + file or "/dev/zero"
>> + - a mapping below sbrk(0) done by the process itself
>> + - any memory mapped by the kernel in the process's address space during
>> + creation and following the restrictions presented above (i.e. data, bss,
>> + stack).
>> +
>> +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
>> +control it using the following prctl()s:
>> + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable the Tagged Address ABI.
>
> enable or disable (not sure we need the latter but it doesn't heart).
>
> I'd add the arg2 description here as well.
>
Good point I missed this.
>> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
>> + Address ABI.
>> +
>> +As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
>> +the ABI guarantees the following behaviours:
>> +
>> + - Every current or newly introduced syscall can accept any valid tagged
>> + pointers.
>> +
>> + - If a non valid tagged pointer is passed to a syscall then the behaviour
>> + is undefined.
>> +
>> + - Every valid tagged pointer is expected to work as an untagged one.
>> +
>> + - The kernel preserves any valid tagged pointers and returns them to the
>> + userspace unchanged in all the cases except the ones documented in the
>> + "Preserving tags" paragraph of tagged-pointers.txt.
>
> I'd think we need to qualify the context here in which the kernel
> preserves the tagged pointers. Did you mean on the syscall return?
>
What this means is that on syscall return the tags are preserved, but if for
example you have tagged pointers inside siginfo_t, they will not because
according to tagged-pointers.txt non-zero tags are not preserved when delivering
signals.
>> +
>> +A definition of the meaning of tagged pointers on arm64 can be found in:
>> +Documentation/arm64/tagged-pointers.txt.
>> +
>> +3. ARM64 Tagged Address ABI Exceptions
>> +--------------------------------------
>> +
>> +The behaviours described in paragraph 2, with particular reference to the
>
> "section 2"
>
>> +acceptance by the syscalls of any valid tagged pointer are not applicable
>> +to the following cases:
>> + - mmap() addr parameter.
>> + - mremap() new_address parameter.
>> + - prctl_set_mm() struct prctl_map fields.
>> + - prctl_set_mm_map() struct prctl_map fields.
>> +
>> +4. Example of correct usage
>> +---------------------------
>> +
>> +void main(void)
>> +{
>> + static int tbi_enabled = 0;
>> + unsigned long tag = 0;
>> +
>> + char *ptr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
>> + MAP_ANONYMOUS, -1, 0);
>> +
>> + if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE,
>> + 0, 0, 0) == 0)
>> + tbi_enabled = 1;
>> +
>> + if (!ptr)
>> + return -1;
>> +
>> + if (tbi_enabled)
>> + tag = rand() & 0xff;
>> +
>> + ptr = (char *)((unsigned long)ptr | (tag << TAG_SHIFT));
>> +
>> + *ptr = 'a';
>> +
>> + ...
>> +}
>> +
>> --
>> 2.21.0
>
--
Regards,
Vincenzo
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 10:15 ` Vincenzo Frascino
@ 2019-06-13 10:15 ` Vincenzo Frascino
2019-06-13 11:37 ` Dave Martin
1 sibling, 0 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-13 10:15 UTC (permalink / raw)
To: Catalin Marinas
Cc: linux-arm-kernel, linux-doc, linux-mm, linux-arch,
linux-kselftest, linux-kernel, Will Deacon, Andrey Konovalov,
Alexander Viro, Szabolcs Nagy
Hi Catalin,
On 12/06/2019 16:35, Catalin Marinas wrote:
> Hi Vincenzo,
>
> Some minor comments below but it looks fine to me overall. Cc'ing
> Szabolcs as well since I'd like a view from the libc people.
>
Thanks for this, I saw Szabolcs comments.
> On Wed, Jun 12, 2019 at 03:21:10PM +0100, Vincenzo Frascino wrote:
>> diff --git a/Documentation/arm64/tagged-address-abi.txt b/Documentation/arm64/tagged-address-abi.txt
>> new file mode 100644
>> index 000000000000..96e149e2c55c
>> --- /dev/null
>> +++ b/Documentation/arm64/tagged-address-abi.txt
>> @@ -0,0 +1,111 @@
>> +ARM64 TAGGED ADDRESS ABI
>> +========================
>> +
>> +This document describes the usage and semantics of the Tagged Address
>> +ABI on arm64.
>> +
>> +1. Introduction
>> +---------------
>> +
>> +On arm64 the TCR_EL1.TBI0 bit has been always enabled on the arm64 kernel,
>> +hence the userspace (EL0) is allowed to set a non-zero value in the top
>
> I'd be clearer here: "userspace (EL0) is allowed to perform a user
> memory access through a 64-bit pointer with a non-zero top byte" (or
> something along the lines). Otherwise setting a non-zero top byte is
> allowed on any architecture, dereferencing it is a problem.
>
Ok.
>> +byte but the resulting pointers are not allowed at the user-kernel syscall
>> +ABI boundary.
>> +
>> +This document describes a relaxation of the ABI with which it is possible
>
> "relaxation of the ABI that makes it possible to..."
>
>> +to pass tagged tagged pointers to the syscalls, when these pointers are in
>> +memory ranges obtained as described in paragraph 2.
>
> "section 2" is better. There are a lot more paragraphs.
>
Agree.
>> +
>> +Since it is not desirable to relax the ABI to allow tagged user addresses
>> +into the kernel indiscriminately, arm64 provides a new sysctl interface
>> +(/proc/sys/abi/tagged_addr) that is used to prevent the applications from
>> +enabling the relaxed ABI and a new prctl() interface that can be used to
>> +enable or disable the relaxed ABI.
>> +
>> +The sysctl is meant also for testing purposes in order to provide a simple
>> +way for the userspace to verify the return error checking of the prctl()
>> +command without having to reconfigure the kernel.
>> +
>> +The ABI properties are inherited by threads of the same application and
>> +fork()'ed children but cleared when a new process is spawn (execve()).
>
> "spawned".
>
> I guess you could drop these three paragraphs here and mention the
> inheritance properties when introducing the prctl() below. You can also
> mention the global sysctl switch after the prctl() was introduced.
>
I will move the last two (rewording them) to the _section_ 2, but I would still
prefer the Introduction to give an overview of the solution as well.
>> +
>> +2. ARM64 Tagged Address ABI
>> +---------------------------
>> +
>> +From the kernel syscall interface prospective, we define, for the purposes
>> +of this document, a "valid tagged pointer" as a pointer that either it has
>
> "either has" (no 'it') sounds slightly better but I'm not a native
> English speaker either.
>
>> +a zero value set in the top byte or it has a non-zero value, it is in memory
>> +ranges privately owned by a userspace process and it is obtained in one of
>> +the following ways:
>> + - mmap() done by the process itself, where either:
>> + * flags = MAP_PRIVATE | MAP_ANONYMOUS
>> + * flags = MAP_PRIVATE and the file descriptor refers to a regular
>> + file or "/dev/zero"
>> + - a mapping below sbrk(0) done by the process itself
>> + - any memory mapped by the kernel in the process's address space during
>> + creation and following the restrictions presented above (i.e. data, bss,
>> + stack).
>> +
>> +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
>> +control it using the following prctl()s:
>> + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable the Tagged Address ABI.
>
> enable or disable (not sure we need the latter but it doesn't heart).
>
> I'd add the arg2 description here as well.
>
Good point I missed this.
>> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
>> + Address ABI.
>> +
>> +As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
>> +the ABI guarantees the following behaviours:
>> +
>> + - Every current or newly introduced syscall can accept any valid tagged
>> + pointers.
>> +
>> + - If a non valid tagged pointer is passed to a syscall then the behaviour
>> + is undefined.
>> +
>> + - Every valid tagged pointer is expected to work as an untagged one.
>> +
>> + - The kernel preserves any valid tagged pointers and returns them to the
>> + userspace unchanged in all the cases except the ones documented in the
>> + "Preserving tags" paragraph of tagged-pointers.txt.
>
> I'd think we need to qualify the context here in which the kernel
> preserves the tagged pointers. Did you mean on the syscall return?
>
What this means is that on syscall return the tags are preserved, but if for
example you have tagged pointers inside siginfo_t, they will not because
according to tagged-pointers.txt non-zero tags are not preserved when delivering
signals.
>> +
>> +A definition of the meaning of tagged pointers on arm64 can be found in:
>> +Documentation/arm64/tagged-pointers.txt.
>> +
>> +3. ARM64 Tagged Address ABI Exceptions
>> +--------------------------------------
>> +
>> +The behaviours described in paragraph 2, with particular reference to the
>
> "section 2"
>
>> +acceptance by the syscalls of any valid tagged pointer are not applicable
>> +to the following cases:
>> + - mmap() addr parameter.
>> + - mremap() new_address parameter.
>> + - prctl_set_mm() struct prctl_map fields.
>> + - prctl_set_mm_map() struct prctl_map fields.
>> +
>> +4. Example of correct usage
>> +---------------------------
>> +
>> +void main(void)
>> +{
>> + static int tbi_enabled = 0;
>> + unsigned long tag = 0;
>> +
>> + char *ptr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
>> + MAP_ANONYMOUS, -1, 0);
>> +
>> + if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE,
>> + 0, 0, 0) == 0)
>> + tbi_enabled = 1;
>> +
>> + if (!ptr)
>> + return -1;
>> +
>> + if (tbi_enabled)
>> + tag = rand() & 0xff;
>> +
>> + ptr = (char *)((unsigned long)ptr | (tag << TAG_SHIFT));
>> +
>> + *ptr = 'a';
>> +
>> + ...
>> +}
>> +
>> --
>> 2.21.0
>
--
Regards,
Vincenzo
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 10:14 ` Szabolcs Nagy
2019-06-13 10:14 ` Szabolcs Nagy
@ 2019-06-13 11:16 ` Vincenzo Frascino
2019-06-13 11:16 ` Vincenzo Frascino
2019-06-13 12:28 ` Szabolcs Nagy
1 sibling, 2 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-13 11:16 UTC (permalink / raw)
To: Szabolcs Nagy, Catalin Marinas
Cc: linux-arch@vger.kernel.org, linux-doc@vger.kernel.org,
Andrey Konovalov, Will Deacon, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, Alexander Viro,
linux-kselftest@vger.kernel.org, nd,
linux-arm-kernel@lists.infradead.org
Hi Szabolcs,
thank you for your review.
On 13/06/2019 11:14, Szabolcs Nagy wrote:
> On 13/06/2019 10:20, Catalin Marinas wrote:
>> Hi Szabolcs,
>>
>> On Wed, Jun 12, 2019 at 05:30:34PM +0100, Szabolcs Nagy wrote:
>>> On 12/06/2019 15:21, Vincenzo Frascino wrote:
>>>> +2. ARM64 Tagged Address ABI
>>>> +---------------------------
>>>> +
>>>> +From the kernel syscall interface prospective, we define, for the purposes
>>> ^^^^^^^^^^^
>>> perspective
>>>
>>>> +of this document, a "valid tagged pointer" as a pointer that either it has
>>>> +a zero value set in the top byte or it has a non-zero value, it is in memory
>>>> +ranges privately owned by a userspace process and it is obtained in one of
>>>> +the following ways:
>>>> + - mmap() done by the process itself, where either:
>>>> + * flags = MAP_PRIVATE | MAP_ANONYMOUS
>>>> + * flags = MAP_PRIVATE and the file descriptor refers to a regular
>>>> + file or "/dev/zero"
>>>
>>> this does not make it clear if MAP_FIXED or other flags are valid
>>> (there are many map flags i don't know, but at least fixed should work
>>> and stack/growsdown. i'd expect anything that's not incompatible with
>>> private|anon to work).
>>
>> Just to clarify, this document tries to define the memory ranges from
>> where tagged addresses can be passed into the kernel in the context
>> of TBI only (not MTE); that is for hwasan support. FIXED or GROWSDOWN
>> should not affect this.
>
> yes, so either the text should list MAP_* flags that don't affect
> the pointer tagging semantics or specify private|anon mapping
> with different wording.
>
Good point. Could you please propose a wording that would be suitable for this case?
>>>> + - a mapping below sbrk(0) done by the process itself
>>>
>>> doesn't the mmap rule cover this?
>>
>> IIUC it doesn't cover it as that's memory mapped by the kernel
>> automatically on access vs a pointer returned by mmap(). The statement
>> above talks about how the address is obtained by the user.
>
> ok i read 'mapping below sbrk' as an mmap (possibly MAP_FIXED)
> that happens to be below the heap area.
>
> i think "below sbrk(0)" is not the best term to use: there
> may be address range below the heap area that can be mmapped
> and thus below sbrk(0) and sbrk is a posix api not a linux
> syscall, the libc can implement it with mmap or whatever.
>
> i'm not sure what the right term for 'heap area' is
> (the address range between syscall(__NR_brk,0) at
> program startup and its current value?)
>
I used sbrk(0) with the meaning of "end of the process's data segment" not
implying that this is a syscall, but just as a useful way to identify the mapping.
I agree that it is a posix function implemented by libc but when it is used with
0 finds the current location of the program break, which can be changed by brk()
and depending on the new address passed to this syscall can have the effect of
allocating or deallocating memory.
Will changing sbrk(0) with "end of the process's data segment" make it more clear?
I will add what you are suggesting about the heap area.
>>>> + - any memory mapped by the kernel in the process's address space during
>>>> + creation and following the restrictions presented above (i.e. data, bss,
>>>> + stack).
>>>
>>> OK.
>>>
>>> Can a null pointer have a tag?
>>> (in case NULL is valid to pass to a syscall)
>>
>> Good point. I don't think it can. We may change this for MTE where we
>> give a hint tag but no hint address, however, this document only covers
>> TBI for now.
>
> OK.
>
>>>> +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
>>>> +control it using the following prctl()s:
>>>> + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable the Tagged Address ABI.
>>>> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
>>>> + Address ABI.
>>>> +
>>>> +As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
>>>> +the ABI guarantees the following behaviours:
>>>> +
>>>> + - Every current or newly introduced syscall can accept any valid tagged
>>>> + pointers.
>>>> +
>>>> + - If a non valid tagged pointer is passed to a syscall then the behaviour
>>>> + is undefined.
>>>> +
>>>> + - Every valid tagged pointer is expected to work as an untagged one.
>>>> +
>>>> + - The kernel preserves any valid tagged pointers and returns them to the
>>>> + userspace unchanged in all the cases except the ones documented in the
>>>> + "Preserving tags" paragraph of tagged-pointers.txt.
>>>
>>> OK.
>>>
>>> i guess pointers of another process are not "valid tagged pointers"
>>> for the current one, so e.g. in ptrace the ptracer has to clear the
>>> tags before PEEK etc.
>>
>> Another good point. Are there any pros/cons here or use-cases? When we
>> add MTE support, should we handle this differently?
>
> i'm not sure what gdb does currently, but it has
> an 'address_significant' hook used at a few places
> that drops the tag on aarch64, so it probably
> avoids passing tagged pointer to ptrace.
>
> i was worried about strace which tries to print
> structs passed to syscalls and follow pointers in
> them which currently would work, but if we allow
> tags in syscalls then it needs some update.
> (i haven't checked the strace code though)
>>>>> +A definition of the meaning of tagged pointers on arm64 can be found in:
>>>> +Documentation/arm64/tagged-pointers.txt.
>>>> +
>>>> +3. ARM64 Tagged Address ABI Exceptions
>>>> +--------------------------------------
>>>> +
>>>> +The behaviours described in paragraph 2, with particular reference to the
>>>> +acceptance by the syscalls of any valid tagged pointer are not applicable
>>>> +to the following cases:
>>>> + - mmap() addr parameter.
>>>> + - mremap() new_address parameter.
>>>> + - prctl_set_mm() struct prctl_map fields.
>>>> + - prctl_set_mm_map() struct prctl_map fields.
>>>
>>> i don't understand the exception: does it mean that passing a tagged
>>> address to these syscalls is undefined?
>>
>> I'd say it's as undefined as it is right now without these patches. We
>> may be able to explain this better in the document.
>>
>
--
Regards,
Vincenzo
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 11:16 ` Vincenzo Frascino
@ 2019-06-13 11:16 ` Vincenzo Frascino
2019-06-13 12:28 ` Szabolcs Nagy
1 sibling, 0 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-13 11:16 UTC (permalink / raw)
To: Szabolcs Nagy, Catalin Marinas
Cc: nd, linux-arm-kernel@lists.infradead.org,
linux-doc@vger.kernel.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, Will Deacon, Andrey Konovalov,
Alexander Viro
Hi Szabolcs,
thank you for your review.
On 13/06/2019 11:14, Szabolcs Nagy wrote:
> On 13/06/2019 10:20, Catalin Marinas wrote:
>> Hi Szabolcs,
>>
>> On Wed, Jun 12, 2019 at 05:30:34PM +0100, Szabolcs Nagy wrote:
>>> On 12/06/2019 15:21, Vincenzo Frascino wrote:
>>>> +2. ARM64 Tagged Address ABI
>>>> +---------------------------
>>>> +
>>>> +From the kernel syscall interface prospective, we define, for the purposes
>>> ^^^^^^^^^^^
>>> perspective
>>>
>>>> +of this document, a "valid tagged pointer" as a pointer that either it has
>>>> +a zero value set in the top byte or it has a non-zero value, it is in memory
>>>> +ranges privately owned by a userspace process and it is obtained in one of
>>>> +the following ways:
>>>> + - mmap() done by the process itself, where either:
>>>> + * flags = MAP_PRIVATE | MAP_ANONYMOUS
>>>> + * flags = MAP_PRIVATE and the file descriptor refers to a regular
>>>> + file or "/dev/zero"
>>>
>>> this does not make it clear if MAP_FIXED or other flags are valid
>>> (there are many map flags i don't know, but at least fixed should work
>>> and stack/growsdown. i'd expect anything that's not incompatible with
>>> private|anon to work).
>>
>> Just to clarify, this document tries to define the memory ranges from
>> where tagged addresses can be passed into the kernel in the context
>> of TBI only (not MTE); that is for hwasan support. FIXED or GROWSDOWN
>> should not affect this.
>
> yes, so either the text should list MAP_* flags that don't affect
> the pointer tagging semantics or specify private|anon mapping
> with different wording.
>
Good point. Could you please propose a wording that would be suitable for this case?
>>>> + - a mapping below sbrk(0) done by the process itself
>>>
>>> doesn't the mmap rule cover this?
>>
>> IIUC it doesn't cover it as that's memory mapped by the kernel
>> automatically on access vs a pointer returned by mmap(). The statement
>> above talks about how the address is obtained by the user.
>
> ok i read 'mapping below sbrk' as an mmap (possibly MAP_FIXED)
> that happens to be below the heap area.
>
> i think "below sbrk(0)" is not the best term to use: there
> may be address range below the heap area that can be mmapped
> and thus below sbrk(0) and sbrk is a posix api not a linux
> syscall, the libc can implement it with mmap or whatever.
>
> i'm not sure what the right term for 'heap area' is
> (the address range between syscall(__NR_brk,0) at
> program startup and its current value?)
>
I used sbrk(0) with the meaning of "end of the process's data segment" not
implying that this is a syscall, but just as a useful way to identify the mapping.
I agree that it is a posix function implemented by libc but when it is used with
0 finds the current location of the program break, which can be changed by brk()
and depending on the new address passed to this syscall can have the effect of
allocating or deallocating memory.
Will changing sbrk(0) with "end of the process's data segment" make it more clear?
I will add what you are suggesting about the heap area.
>>>> + - any memory mapped by the kernel in the process's address space during
>>>> + creation and following the restrictions presented above (i.e. data, bss,
>>>> + stack).
>>>
>>> OK.
>>>
>>> Can a null pointer have a tag?
>>> (in case NULL is valid to pass to a syscall)
>>
>> Good point. I don't think it can. We may change this for MTE where we
>> give a hint tag but no hint address, however, this document only covers
>> TBI for now.
>
> OK.
>
>>>> +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
>>>> +control it using the following prctl()s:
>>>> + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable the Tagged Address ABI.
>>>> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
>>>> + Address ABI.
>>>> +
>>>> +As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
>>>> +the ABI guarantees the following behaviours:
>>>> +
>>>> + - Every current or newly introduced syscall can accept any valid tagged
>>>> + pointers.
>>>> +
>>>> + - If a non valid tagged pointer is passed to a syscall then the behaviour
>>>> + is undefined.
>>>> +
>>>> + - Every valid tagged pointer is expected to work as an untagged one.
>>>> +
>>>> + - The kernel preserves any valid tagged pointers and returns them to the
>>>> + userspace unchanged in all the cases except the ones documented in the
>>>> + "Preserving tags" paragraph of tagged-pointers.txt.
>>>
>>> OK.
>>>
>>> i guess pointers of another process are not "valid tagged pointers"
>>> for the current one, so e.g. in ptrace the ptracer has to clear the
>>> tags before PEEK etc.
>>
>> Another good point. Are there any pros/cons here or use-cases? When we
>> add MTE support, should we handle this differently?
>
> i'm not sure what gdb does currently, but it has
> an 'address_significant' hook used at a few places
> that drops the tag on aarch64, so it probably
> avoids passing tagged pointer to ptrace.
>
> i was worried about strace which tries to print
> structs passed to syscalls and follow pointers in
> them which currently would work, but if we allow
> tags in syscalls then it needs some update.
> (i haven't checked the strace code though)
>>>>> +A definition of the meaning of tagged pointers on arm64 can be found in:
>>>> +Documentation/arm64/tagged-pointers.txt.
>>>> +
>>>> +3. ARM64 Tagged Address ABI Exceptions
>>>> +--------------------------------------
>>>> +
>>>> +The behaviours described in paragraph 2, with particular reference to the
>>>> +acceptance by the syscalls of any valid tagged pointer are not applicable
>>>> +to the following cases:
>>>> + - mmap() addr parameter.
>>>> + - mremap() new_address parameter.
>>>> + - prctl_set_mm() struct prctl_map fields.
>>>> + - prctl_set_mm_map() struct prctl_map fields.
>>>
>>> i don't understand the exception: does it mean that passing a tagged
>>> address to these syscalls is undefined?
>>
>> I'd say it's as undefined as it is right now without these patches. We
>> may be able to explain this better in the document.
>>
>
--
Regards,
Vincenzo
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 10:15 ` Vincenzo Frascino
2019-06-13 10:15 ` Vincenzo Frascino
@ 2019-06-13 11:37 ` Dave Martin
2019-06-13 11:37 ` Dave Martin
2019-06-13 12:28 ` Catalin Marinas
1 sibling, 2 replies; 50+ messages in thread
From: Dave Martin @ 2019-06-13 11:37 UTC (permalink / raw)
To: Vincenzo Frascino
Cc: linux-arch, linux-doc, Szabolcs Nagy, Catalin Marinas,
Will Deacon, linux-kernel, linux-mm, Alexander Viro,
linux-kselftest, Andrey Konovalov, linux-arm-kernel
On Thu, Jun 13, 2019 at 11:15:34AM +0100, Vincenzo Frascino wrote:
> Hi Catalin,
>
> On 12/06/2019 16:35, Catalin Marinas wrote:
> > Hi Vincenzo,
> >
> > Some minor comments below but it looks fine to me overall. Cc'ing
> > Szabolcs as well since I'd like a view from the libc people.
> >
>
> Thanks for this, I saw Szabolcs comments.
>
> > On Wed, Jun 12, 2019 at 03:21:10PM +0100, Vincenzo Frascino wrote:
> >> diff --git a/Documentation/arm64/tagged-address-abi.txt b/Documentation/arm64/tagged-address-abi.txt
> >> new file mode 100644
> >> index 000000000000..96e149e2c55c
> >> --- /dev/null
> >> +++ b/Documentation/arm64/tagged-address-abi.txt
[...]
> >> +Since it is not desirable to relax the ABI to allow tagged user addresses
> >> +into the kernel indiscriminately, arm64 provides a new sysctl interface
> >> +(/proc/sys/abi/tagged_addr) that is used to prevent the applications from
> >> +enabling the relaxed ABI and a new prctl() interface that can be used to
> >> +enable or disable the relaxed ABI.
> >> +
> >> +The sysctl is meant also for testing purposes in order to provide a simple
> >> +way for the userspace to verify the return error checking of the prctl()
> >> +command without having to reconfigure the kernel.
> >> +
> >> +The ABI properties are inherited by threads of the same application and
> >> +fork()'ed children but cleared when a new process is spawn (execve()).
> >
> > "spawned".
I'd just say "cleared by execve()."
"Spawn" suggests (v)fork+exec to me (at least, what's what "spawn" means on
certain other OSes).
> >
> > I guess you could drop these three paragraphs here and mention the
> > inheritance properties when introducing the prctl() below. You can also
> > mention the global sysctl switch after the prctl() was introduced.
> >
>
> I will move the last two (rewording them) to the _section_ 2, but I would still
> prefer the Introduction to give an overview of the solution as well.
>
> >> +
> >> +2. ARM64 Tagged Address ABI
> >> +---------------------------
> >> +
> >> +From the kernel syscall interface prospective, we define, for the purposes
> >> +of this document, a "valid tagged pointer" as a pointer that either it has
> >
> > "either has" (no 'it') sounds slightly better but I'm not a native
> > English speaker either.
> >
> >> +a zero value set in the top byte or it has a non-zero value, it is in memory
> >> +ranges privately owned by a userspace process and it is obtained in one of
> >> +the following ways:
> >> + - mmap() done by the process itself, where either:
> >> + * flags = MAP_PRIVATE | MAP_ANONYMOUS
> >> + * flags = MAP_PRIVATE and the file descriptor refers to a regular
> >> + file or "/dev/zero"
> >> + - a mapping below sbrk(0) done by the process itself
> >> + - any memory mapped by the kernel in the process's address space during
> >> + creation and following the restrictions presented above (i.e. data, bss,
> >> + stack).
> >> +
> >> +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
> >> +control it using the following prctl()s:
> >> + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable the Tagged Address ABI.
> >
> > enable or disable (not sure we need the latter but it doesn't heart).
> >
> > I'd add the arg2 description here as well.
> >
>
> Good point I missed this.
>
> >> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> >> + Address ABI.
For both prctls, you should also document the zeroed arguments up to
arg5 (unless we get rid of the enforcement and just ignore them).
Is there a canonical way to detect whether this whole API/ABI is
available? (i.e., try to call this prctl / check for an HWCAP bit,
etc.)
[...]
Cheers
---Dave
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 11:37 ` Dave Martin
@ 2019-06-13 11:37 ` Dave Martin
2019-06-13 12:28 ` Catalin Marinas
1 sibling, 0 replies; 50+ messages in thread
From: Dave Martin @ 2019-06-13 11:37 UTC (permalink / raw)
To: Vincenzo Frascino
Cc: Catalin Marinas, linux-arch, linux-doc, Szabolcs Nagy,
Andrey Konovalov, Will Deacon, linux-kernel, linux-mm,
Alexander Viro, linux-kselftest, linux-arm-kernel
On Thu, Jun 13, 2019 at 11:15:34AM +0100, Vincenzo Frascino wrote:
> Hi Catalin,
>
> On 12/06/2019 16:35, Catalin Marinas wrote:
> > Hi Vincenzo,
> >
> > Some minor comments below but it looks fine to me overall. Cc'ing
> > Szabolcs as well since I'd like a view from the libc people.
> >
>
> Thanks for this, I saw Szabolcs comments.
>
> > On Wed, Jun 12, 2019 at 03:21:10PM +0100, Vincenzo Frascino wrote:
> >> diff --git a/Documentation/arm64/tagged-address-abi.txt b/Documentation/arm64/tagged-address-abi.txt
> >> new file mode 100644
> >> index 000000000000..96e149e2c55c
> >> --- /dev/null
> >> +++ b/Documentation/arm64/tagged-address-abi.txt
[...]
> >> +Since it is not desirable to relax the ABI to allow tagged user addresses
> >> +into the kernel indiscriminately, arm64 provides a new sysctl interface
> >> +(/proc/sys/abi/tagged_addr) that is used to prevent the applications from
> >> +enabling the relaxed ABI and a new prctl() interface that can be used to
> >> +enable or disable the relaxed ABI.
> >> +
> >> +The sysctl is meant also for testing purposes in order to provide a simple
> >> +way for the userspace to verify the return error checking of the prctl()
> >> +command without having to reconfigure the kernel.
> >> +
> >> +The ABI properties are inherited by threads of the same application and
> >> +fork()'ed children but cleared when a new process is spawn (execve()).
> >
> > "spawned".
I'd just say "cleared by execve()."
"Spawn" suggests (v)fork+exec to me (at least, what's what "spawn" means on
certain other OSes).
> >
> > I guess you could drop these three paragraphs here and mention the
> > inheritance properties when introducing the prctl() below. You can also
> > mention the global sysctl switch after the prctl() was introduced.
> >
>
> I will move the last two (rewording them) to the _section_ 2, but I would still
> prefer the Introduction to give an overview of the solution as well.
>
> >> +
> >> +2. ARM64 Tagged Address ABI
> >> +---------------------------
> >> +
> >> +From the kernel syscall interface prospective, we define, for the purposes
> >> +of this document, a "valid tagged pointer" as a pointer that either it has
> >
> > "either has" (no 'it') sounds slightly better but I'm not a native
> > English speaker either.
> >
> >> +a zero value set in the top byte or it has a non-zero value, it is in memory
> >> +ranges privately owned by a userspace process and it is obtained in one of
> >> +the following ways:
> >> + - mmap() done by the process itself, where either:
> >> + * flags = MAP_PRIVATE | MAP_ANONYMOUS
> >> + * flags = MAP_PRIVATE and the file descriptor refers to a regular
> >> + file or "/dev/zero"
> >> + - a mapping below sbrk(0) done by the process itself
> >> + - any memory mapped by the kernel in the process's address space during
> >> + creation and following the restrictions presented above (i.e. data, bss,
> >> + stack).
> >> +
> >> +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
> >> +control it using the following prctl()s:
> >> + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable the Tagged Address ABI.
> >
> > enable or disable (not sure we need the latter but it doesn't heart).
> >
> > I'd add the arg2 description here as well.
> >
>
> Good point I missed this.
>
> >> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> >> + Address ABI.
For both prctls, you should also document the zeroed arguments up to
arg5 (unless we get rid of the enforcement and just ignore them).
Is there a canonical way to detect whether this whole API/ABI is
available? (i.e., try to call this prctl / check for an HWCAP bit,
etc.)
[...]
Cheers
---Dave
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 11:16 ` Vincenzo Frascino
2019-06-13 11:16 ` Vincenzo Frascino
@ 2019-06-13 12:28 ` Szabolcs Nagy
2019-06-13 12:28 ` Szabolcs Nagy
2019-06-13 14:03 ` Vincenzo Frascino
1 sibling, 2 replies; 50+ messages in thread
From: Szabolcs Nagy @ 2019-06-13 12:28 UTC (permalink / raw)
To: Vincenzo Frascino, Catalin Marinas
Cc: linux-arch@vger.kernel.org, linux-doc@vger.kernel.org,
Andrey Konovalov, Will Deacon, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, Alexander Viro,
linux-kselftest@vger.kernel.org, nd,
linux-arm-kernel@lists.infradead.org
On 13/06/2019 12:16, Vincenzo Frascino wrote:
> Hi Szabolcs,
>
> thank you for your review.
>
> On 13/06/2019 11:14, Szabolcs Nagy wrote:
>> On 13/06/2019 10:20, Catalin Marinas wrote:
>>> Hi Szabolcs,
>>>
>>> On Wed, Jun 12, 2019 at 05:30:34PM +0100, Szabolcs Nagy wrote:
>>>> On 12/06/2019 15:21, Vincenzo Frascino wrote:
>>>>> +2. ARM64 Tagged Address ABI
>>>>> +---------------------------
>>>>> +
>>>>> +From the kernel syscall interface prospective, we define, for the purposes
>>>> ^^^^^^^^^^^
>>>> perspective
>>>>
>>>>> +of this document, a "valid tagged pointer" as a pointer that either it has
>>>>> +a zero value set in the top byte or it has a non-zero value, it is in memory
>>>>> +ranges privately owned by a userspace process and it is obtained in one of
>>>>> +the following ways:
>>>>> + - mmap() done by the process itself, where either:
>>>>> + * flags = MAP_PRIVATE | MAP_ANONYMOUS
>>>>> + * flags = MAP_PRIVATE and the file descriptor refers to a regular
>>>>> + file or "/dev/zero"
>>>>
>>>> this does not make it clear if MAP_FIXED or other flags are valid
>>>> (there are many map flags i don't know, but at least fixed should work
>>>> and stack/growsdown. i'd expect anything that's not incompatible with
>>>> private|anon to work).
>>>
>>> Just to clarify, this document tries to define the memory ranges from
>>> where tagged addresses can be passed into the kernel in the context
>>> of TBI only (not MTE); that is for hwasan support. FIXED or GROWSDOWN
>>> should not affect this.
>>
>> yes, so either the text should list MAP_* flags that don't affect
>> the pointer tagging semantics or specify private|anon mapping
>> with different wording.
>>
>
> Good point. Could you please propose a wording that would be suitable for this case?
i don't know all the MAP_ magic, but i think it's enough to change
the "flags =" to
* flags have MAP_PRIVATE and MAP_ANONYMOUS set or
* flags have MAP_PRIVATE set and the file descriptor refers to...
>>>>> + - a mapping below sbrk(0) done by the process itself
>>>>
>>>> doesn't the mmap rule cover this?
>>>
>>> IIUC it doesn't cover it as that's memory mapped by the kernel
>>> automatically on access vs a pointer returned by mmap(). The statement
>>> above talks about how the address is obtained by the user.
>>
>> ok i read 'mapping below sbrk' as an mmap (possibly MAP_FIXED)
>> that happens to be below the heap area.
>>
>> i think "below sbrk(0)" is not the best term to use: there
>> may be address range below the heap area that can be mmapped
>> and thus below sbrk(0) and sbrk is a posix api not a linux
>> syscall, the libc can implement it with mmap or whatever.
>>
>> i'm not sure what the right term for 'heap area' is
>> (the address range between syscall(__NR_brk,0) at
>> program startup and its current value?)
>>
>
> I used sbrk(0) with the meaning of "end of the process's data segment" not
> implying that this is a syscall, but just as a useful way to identify the mapping.
> I agree that it is a posix function implemented by libc but when it is used with
> 0 finds the current location of the program break, which can be changed by brk()
> and depending on the new address passed to this syscall can have the effect of
> allocating or deallocating memory.
>
> Will changing sbrk(0) with "end of the process's data segment" make it more clear?
i don't understand what's the relevance of the *end*
of the data segment.
i'd expect the text to say something about the address
range of the data segment.
i can do
mmap((void*)65536, 65536, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_SHARED|MAP_ANON, -1, 0);
and it will be below the end of the data segment.
>
> I will add what you are suggesting about the heap area.
>
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 12:28 ` Szabolcs Nagy
@ 2019-06-13 12:28 ` Szabolcs Nagy
2019-06-13 14:03 ` Vincenzo Frascino
1 sibling, 0 replies; 50+ messages in thread
From: Szabolcs Nagy @ 2019-06-13 12:28 UTC (permalink / raw)
To: Vincenzo Frascino, Catalin Marinas
Cc: nd, linux-arm-kernel@lists.infradead.org,
linux-doc@vger.kernel.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, Will Deacon, Andrey Konovalov,
Alexander Viro
On 13/06/2019 12:16, Vincenzo Frascino wrote:
> Hi Szabolcs,
>
> thank you for your review.
>
> On 13/06/2019 11:14, Szabolcs Nagy wrote:
>> On 13/06/2019 10:20, Catalin Marinas wrote:
>>> Hi Szabolcs,
>>>
>>> On Wed, Jun 12, 2019 at 05:30:34PM +0100, Szabolcs Nagy wrote:
>>>> On 12/06/2019 15:21, Vincenzo Frascino wrote:
>>>>> +2. ARM64 Tagged Address ABI
>>>>> +---------------------------
>>>>> +
>>>>> +From the kernel syscall interface prospective, we define, for the purposes
>>>> ^^^^^^^^^^^
>>>> perspective
>>>>
>>>>> +of this document, a "valid tagged pointer" as a pointer that either it has
>>>>> +a zero value set in the top byte or it has a non-zero value, it is in memory
>>>>> +ranges privately owned by a userspace process and it is obtained in one of
>>>>> +the following ways:
>>>>> + - mmap() done by the process itself, where either:
>>>>> + * flags = MAP_PRIVATE | MAP_ANONYMOUS
>>>>> + * flags = MAP_PRIVATE and the file descriptor refers to a regular
>>>>> + file or "/dev/zero"
>>>>
>>>> this does not make it clear if MAP_FIXED or other flags are valid
>>>> (there are many map flags i don't know, but at least fixed should work
>>>> and stack/growsdown. i'd expect anything that's not incompatible with
>>>> private|anon to work).
>>>
>>> Just to clarify, this document tries to define the memory ranges from
>>> where tagged addresses can be passed into the kernel in the context
>>> of TBI only (not MTE); that is for hwasan support. FIXED or GROWSDOWN
>>> should not affect this.
>>
>> yes, so either the text should list MAP_* flags that don't affect
>> the pointer tagging semantics or specify private|anon mapping
>> with different wording.
>>
>
> Good point. Could you please propose a wording that would be suitable for this case?
i don't know all the MAP_ magic, but i think it's enough to change
the "flags =" to
* flags have MAP_PRIVATE and MAP_ANONYMOUS set or
* flags have MAP_PRIVATE set and the file descriptor refers to...
>>>>> + - a mapping below sbrk(0) done by the process itself
>>>>
>>>> doesn't the mmap rule cover this?
>>>
>>> IIUC it doesn't cover it as that's memory mapped by the kernel
>>> automatically on access vs a pointer returned by mmap(). The statement
>>> above talks about how the address is obtained by the user.
>>
>> ok i read 'mapping below sbrk' as an mmap (possibly MAP_FIXED)
>> that happens to be below the heap area.
>>
>> i think "below sbrk(0)" is not the best term to use: there
>> may be address range below the heap area that can be mmapped
>> and thus below sbrk(0) and sbrk is a posix api not a linux
>> syscall, the libc can implement it with mmap or whatever.
>>
>> i'm not sure what the right term for 'heap area' is
>> (the address range between syscall(__NR_brk,0) at
>> program startup and its current value?)
>>
>
> I used sbrk(0) with the meaning of "end of the process's data segment" not
> implying that this is a syscall, but just as a useful way to identify the mapping.
> I agree that it is a posix function implemented by libc but when it is used with
> 0 finds the current location of the program break, which can be changed by brk()
> and depending on the new address passed to this syscall can have the effect of
> allocating or deallocating memory.
>
> Will changing sbrk(0) with "end of the process's data segment" make it more clear?
i don't understand what's the relevance of the *end*
of the data segment.
i'd expect the text to say something about the address
range of the data segment.
i can do
mmap((void*)65536, 65536, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_SHARED|MAP_ANON, -1, 0);
and it will be below the end of the data segment.
>
> I will add what you are suggesting about the heap area.
>
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 11:37 ` Dave Martin
2019-06-13 11:37 ` Dave Martin
@ 2019-06-13 12:28 ` Catalin Marinas
2019-06-13 12:28 ` Catalin Marinas
2019-06-13 13:23 ` Dave Martin
1 sibling, 2 replies; 50+ messages in thread
From: Catalin Marinas @ 2019-06-13 12:28 UTC (permalink / raw)
To: Dave Martin
Cc: linux-arch, linux-doc, Szabolcs Nagy, Andrey Konovalov,
Will Deacon, linux-kernel, linux-mm, Alexander Viro,
linux-kselftest, Vincenzo Frascino, linux-arm-kernel
On Thu, Jun 13, 2019 at 12:37:32PM +0100, Dave P Martin wrote:
> On Thu, Jun 13, 2019 at 11:15:34AM +0100, Vincenzo Frascino wrote:
> > On 12/06/2019 16:35, Catalin Marinas wrote:
> > > On Wed, Jun 12, 2019 at 03:21:10PM +0100, Vincenzo Frascino wrote:
> > >> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> > >> + Address ABI.
[...]
> Is there a canonical way to detect whether this whole API/ABI is
> available? (i.e., try to call this prctl / check for an HWCAP bit,
> etc.)
The canonical way is a prctl() call. HWCAP doesn't make sense since it's
not a hardware feature. If you really want a different way of detecting
this (which I don't think it's worth), we can reinstate the AT_FLAGS
bit.
--
Catalin
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 12:28 ` Catalin Marinas
@ 2019-06-13 12:28 ` Catalin Marinas
2019-06-13 13:23 ` Dave Martin
1 sibling, 0 replies; 50+ messages in thread
From: Catalin Marinas @ 2019-06-13 12:28 UTC (permalink / raw)
To: Dave Martin
Cc: Vincenzo Frascino, linux-arch, linux-doc, Szabolcs Nagy,
Andrey Konovalov, Will Deacon, linux-kernel, linux-mm,
Alexander Viro, linux-kselftest, linux-arm-kernel
On Thu, Jun 13, 2019 at 12:37:32PM +0100, Dave P Martin wrote:
> On Thu, Jun 13, 2019 at 11:15:34AM +0100, Vincenzo Frascino wrote:
> > On 12/06/2019 16:35, Catalin Marinas wrote:
> > > On Wed, Jun 12, 2019 at 03:21:10PM +0100, Vincenzo Frascino wrote:
> > >> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> > >> + Address ABI.
[...]
> Is there a canonical way to detect whether this whole API/ABI is
> available? (i.e., try to call this prctl / check for an HWCAP bit,
> etc.)
The canonical way is a prctl() call. HWCAP doesn't make sense since it's
not a hardware feature. If you really want a different way of detecting
this (which I don't think it's worth), we can reinstate the AT_FLAGS
bit.
--
Catalin
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 12:28 ` Catalin Marinas
2019-06-13 12:28 ` Catalin Marinas
@ 2019-06-13 13:23 ` Dave Martin
2019-06-13 13:23 ` Dave Martin
2019-06-13 15:39 ` Catalin Marinas
1 sibling, 2 replies; 50+ messages in thread
From: Dave Martin @ 2019-06-13 13:23 UTC (permalink / raw)
To: Catalin Marinas
Cc: linux-arch, linux-doc, Szabolcs Nagy, Andrey Konovalov,
Will Deacon, linux-kernel, linux-mm, Alexander Viro,
linux-kselftest, Vincenzo Frascino, linux-arm-kernel
On Thu, Jun 13, 2019 at 01:28:21PM +0100, Catalin Marinas wrote:
> On Thu, Jun 13, 2019 at 12:37:32PM +0100, Dave P Martin wrote:
> > On Thu, Jun 13, 2019 at 11:15:34AM +0100, Vincenzo Frascino wrote:
> > > On 12/06/2019 16:35, Catalin Marinas wrote:
> > > > On Wed, Jun 12, 2019 at 03:21:10PM +0100, Vincenzo Frascino wrote:
> > > >> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> > > >> + Address ABI.
> [...]
> > Is there a canonical way to detect whether this whole API/ABI is
> > available? (i.e., try to call this prctl / check for an HWCAP bit,
> > etc.)
>
> The canonical way is a prctl() call. HWCAP doesn't make sense since it's
> not a hardware feature. If you really want a different way of detecting
> this (which I don't think it's worth), we can reinstate the AT_FLAGS
> bit.
Sure, I think this probably makes sense -- I'm still getting my around
which parts of the design are directly related to MTE and which aren't.
I was a bit concerned about the interaction between
PR_SET_TAGGED_ADDR_CTRL and the sysctl: the caller might conclude that
this API is unavailable when actually tagged addresses are stuck on.
I'm not sure whether this matters, but it's a bit weird.
One option would be to change the semantics, so that the sysctl just
forbids turning tagging from off to on. Alternatively, we could return
a different error code to distinguish this case.
Or we just leave it as proposed.
Cheers
---Dave
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 13:23 ` Dave Martin
@ 2019-06-13 13:23 ` Dave Martin
2019-06-13 15:39 ` Catalin Marinas
1 sibling, 0 replies; 50+ messages in thread
From: Dave Martin @ 2019-06-13 13:23 UTC (permalink / raw)
To: Catalin Marinas
Cc: linux-arch, linux-doc, Szabolcs Nagy, Andrey Konovalov,
Will Deacon, linux-kernel, linux-mm, Alexander Viro,
linux-kselftest, Vincenzo Frascino, linux-arm-kernel
On Thu, Jun 13, 2019 at 01:28:21PM +0100, Catalin Marinas wrote:
> On Thu, Jun 13, 2019 at 12:37:32PM +0100, Dave P Martin wrote:
> > On Thu, Jun 13, 2019 at 11:15:34AM +0100, Vincenzo Frascino wrote:
> > > On 12/06/2019 16:35, Catalin Marinas wrote:
> > > > On Wed, Jun 12, 2019 at 03:21:10PM +0100, Vincenzo Frascino wrote:
> > > >> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> > > >> + Address ABI.
> [...]
> > Is there a canonical way to detect whether this whole API/ABI is
> > available? (i.e., try to call this prctl / check for an HWCAP bit,
> > etc.)
>
> The canonical way is a prctl() call. HWCAP doesn't make sense since it's
> not a hardware feature. If you really want a different way of detecting
> this (which I don't think it's worth), we can reinstate the AT_FLAGS
> bit.
Sure, I think this probably makes sense -- I'm still getting my around
which parts of the design are directly related to MTE and which aren't.
I was a bit concerned about the interaction between
PR_SET_TAGGED_ADDR_CTRL and the sysctl: the caller might conclude that
this API is unavailable when actually tagged addresses are stuck on.
I'm not sure whether this matters, but it's a bit weird.
One option would be to change the semantics, so that the sysctl just
forbids turning tagging from off to on. Alternatively, we could return
a different error code to distinguish this case.
Or we just leave it as proposed.
Cheers
---Dave
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 12:28 ` Szabolcs Nagy
2019-06-13 12:28 ` Szabolcs Nagy
@ 2019-06-13 14:03 ` Vincenzo Frascino
2019-06-13 14:03 ` Vincenzo Frascino
2019-06-13 15:32 ` Szabolcs Nagy
1 sibling, 2 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-13 14:03 UTC (permalink / raw)
To: Szabolcs Nagy, Catalin Marinas
Cc: linux-arch@vger.kernel.org, linux-doc@vger.kernel.org,
Andrey Konovalov, Will Deacon, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, Alexander Viro,
linux-kselftest@vger.kernel.org, nd,
linux-arm-kernel@lists.infradead.org
On 13/06/2019 13:28, Szabolcs Nagy wrote:
> On 13/06/2019 12:16, Vincenzo Frascino wrote:
>> Hi Szabolcs,
>>
>> thank you for your review.
>>
>> On 13/06/2019 11:14, Szabolcs Nagy wrote:
>>> On 13/06/2019 10:20, Catalin Marinas wrote:
>>>> Hi Szabolcs,
>>>>
>>>> On Wed, Jun 12, 2019 at 05:30:34PM +0100, Szabolcs Nagy wrote:
>>>>> On 12/06/2019 15:21, Vincenzo Frascino wrote:
>>>>>> +2. ARM64 Tagged Address ABI
>>>>>> +---------------------------
>>>>>> +
>>>>>> +From the kernel syscall interface prospective, we define, for the purposes
>>>>> ^^^^^^^^^^^
>>>>> perspective
>>>>>
>>>>>> +of this document, a "valid tagged pointer" as a pointer that either it has
>>>>>> +a zero value set in the top byte or it has a non-zero value, it is in memory
>>>>>> +ranges privately owned by a userspace process and it is obtained in one of
>>>>>> +the following ways:
>>>>>> + - mmap() done by the process itself, where either:
>>>>>> + * flags = MAP_PRIVATE | MAP_ANONYMOUS
>>>>>> + * flags = MAP_PRIVATE and the file descriptor refers to a regular
>>>>>> + file or "/dev/zero"
>>>>>
>>>>> this does not make it clear if MAP_FIXED or other flags are valid
>>>>> (there are many map flags i don't know, but at least fixed should work
>>>>> and stack/growsdown. i'd expect anything that's not incompatible with
>>>>> private|anon to work).
>>>>
>>>> Just to clarify, this document tries to define the memory ranges from
>>>> where tagged addresses can be passed into the kernel in the context
>>>> of TBI only (not MTE); that is for hwasan support. FIXED or GROWSDOWN
>>>> should not affect this.
>>>
>>> yes, so either the text should list MAP_* flags that don't affect
>>> the pointer tagging semantics or specify private|anon mapping
>>> with different wording.
>>>
>>
>> Good point. Could you please propose a wording that would be suitable for this case?
>
> i don't know all the MAP_ magic, but i think it's enough to change
> the "flags =" to
>
> * flags have MAP_PRIVATE and MAP_ANONYMOUS set or
> * flags have MAP_PRIVATE set and the file descriptor refers to...
>
>
Fine by me. I will add it the next iterations.
>>>>>> + - a mapping below sbrk(0) done by the process itself
>>>>>
>>>>> doesn't the mmap rule cover this?
>>>>
>>>> IIUC it doesn't cover it as that's memory mapped by the kernel
>>>> automatically on access vs a pointer returned by mmap(). The statement
>>>> above talks about how the address is obtained by the user.
>>>
>>> ok i read 'mapping below sbrk' as an mmap (possibly MAP_FIXED)
>>> that happens to be below the heap area.
>>>
>>> i think "below sbrk(0)" is not the best term to use: there
>>> may be address range below the heap area that can be mmapped
>>> and thus below sbrk(0) and sbrk is a posix api not a linux
>>> syscall, the libc can implement it with mmap or whatever.
>>>
>>> i'm not sure what the right term for 'heap area' is
>>> (the address range between syscall(__NR_brk,0) at
>>> program startup and its current value?)
>>>
>>
>> I used sbrk(0) with the meaning of "end of the process's data segment" not
>> implying that this is a syscall, but just as a useful way to identify the mapping.
>> I agree that it is a posix function implemented by libc but when it is used with
>> 0 finds the current location of the program break, which can be changed by brk()
>> and depending on the new address passed to this syscall can have the effect of
>> allocating or deallocating memory.
>>
>> Will changing sbrk(0) with "end of the process's data segment" make it more clear?
>
> i don't understand what's the relevance of the *end*
> of the data segment.
>
> i'd expect the text to say something about the address
> range of the data segment.
>
> i can do
>
> mmap((void*)65536, 65536, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_SHARED|MAP_ANON, -1, 0);
>
> and it will be below the end of the data segment.
>
As far as I understand the data segment "lives" below the program break, hence
it is a way of describing the range from which the user can obtain a valid
tagged pointer.
Said that, I am not really sure on how do you want me to document this (my aim
is for this to be clear to the userspace developers). Could you please propose
something?
>>
>> I will add what you are suggesting about the heap area.
>>
--
Regards,
Vincenzo
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 14:03 ` Vincenzo Frascino
@ 2019-06-13 14:03 ` Vincenzo Frascino
2019-06-13 15:32 ` Szabolcs Nagy
1 sibling, 0 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-13 14:03 UTC (permalink / raw)
To: Szabolcs Nagy, Catalin Marinas
Cc: nd, linux-arm-kernel@lists.infradead.org,
linux-doc@vger.kernel.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, Will Deacon, Andrey Konovalov,
Alexander Viro
On 13/06/2019 13:28, Szabolcs Nagy wrote:
> On 13/06/2019 12:16, Vincenzo Frascino wrote:
>> Hi Szabolcs,
>>
>> thank you for your review.
>>
>> On 13/06/2019 11:14, Szabolcs Nagy wrote:
>>> On 13/06/2019 10:20, Catalin Marinas wrote:
>>>> Hi Szabolcs,
>>>>
>>>> On Wed, Jun 12, 2019 at 05:30:34PM +0100, Szabolcs Nagy wrote:
>>>>> On 12/06/2019 15:21, Vincenzo Frascino wrote:
>>>>>> +2. ARM64 Tagged Address ABI
>>>>>> +---------------------------
>>>>>> +
>>>>>> +From the kernel syscall interface prospective, we define, for the purposes
>>>>> ^^^^^^^^^^^
>>>>> perspective
>>>>>
>>>>>> +of this document, a "valid tagged pointer" as a pointer that either it has
>>>>>> +a zero value set in the top byte or it has a non-zero value, it is in memory
>>>>>> +ranges privately owned by a userspace process and it is obtained in one of
>>>>>> +the following ways:
>>>>>> + - mmap() done by the process itself, where either:
>>>>>> + * flags = MAP_PRIVATE | MAP_ANONYMOUS
>>>>>> + * flags = MAP_PRIVATE and the file descriptor refers to a regular
>>>>>> + file or "/dev/zero"
>>>>>
>>>>> this does not make it clear if MAP_FIXED or other flags are valid
>>>>> (there are many map flags i don't know, but at least fixed should work
>>>>> and stack/growsdown. i'd expect anything that's not incompatible with
>>>>> private|anon to work).
>>>>
>>>> Just to clarify, this document tries to define the memory ranges from
>>>> where tagged addresses can be passed into the kernel in the context
>>>> of TBI only (not MTE); that is for hwasan support. FIXED or GROWSDOWN
>>>> should not affect this.
>>>
>>> yes, so either the text should list MAP_* flags that don't affect
>>> the pointer tagging semantics or specify private|anon mapping
>>> with different wording.
>>>
>>
>> Good point. Could you please propose a wording that would be suitable for this case?
>
> i don't know all the MAP_ magic, but i think it's enough to change
> the "flags =" to
>
> * flags have MAP_PRIVATE and MAP_ANONYMOUS set or
> * flags have MAP_PRIVATE set and the file descriptor refers to...
>
>
Fine by me. I will add it the next iterations.
>>>>>> + - a mapping below sbrk(0) done by the process itself
>>>>>
>>>>> doesn't the mmap rule cover this?
>>>>
>>>> IIUC it doesn't cover it as that's memory mapped by the kernel
>>>> automatically on access vs a pointer returned by mmap(). The statement
>>>> above talks about how the address is obtained by the user.
>>>
>>> ok i read 'mapping below sbrk' as an mmap (possibly MAP_FIXED)
>>> that happens to be below the heap area.
>>>
>>> i think "below sbrk(0)" is not the best term to use: there
>>> may be address range below the heap area that can be mmapped
>>> and thus below sbrk(0) and sbrk is a posix api not a linux
>>> syscall, the libc can implement it with mmap or whatever.
>>>
>>> i'm not sure what the right term for 'heap area' is
>>> (the address range between syscall(__NR_brk,0) at
>>> program startup and its current value?)
>>>
>>
>> I used sbrk(0) with the meaning of "end of the process's data segment" not
>> implying that this is a syscall, but just as a useful way to identify the mapping.
>> I agree that it is a posix function implemented by libc but when it is used with
>> 0 finds the current location of the program break, which can be changed by brk()
>> and depending on the new address passed to this syscall can have the effect of
>> allocating or deallocating memory.
>>
>> Will changing sbrk(0) with "end of the process's data segment" make it more clear?
>
> i don't understand what's the relevance of the *end*
> of the data segment.
>
> i'd expect the text to say something about the address
> range of the data segment.
>
> i can do
>
> mmap((void*)65536, 65536, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_SHARED|MAP_ANON, -1, 0);
>
> and it will be below the end of the data segment.
>
As far as I understand the data segment "lives" below the program break, hence
it is a way of describing the range from which the user can obtain a valid
tagged pointer.
Said that, I am not really sure on how do you want me to document this (my aim
is for this to be clear to the userspace developers). Could you please propose
something?
>>
>> I will add what you are suggesting about the heap area.
>>
--
Regards,
Vincenzo
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 14:03 ` Vincenzo Frascino
2019-06-13 14:03 ` Vincenzo Frascino
@ 2019-06-13 15:32 ` Szabolcs Nagy
2019-06-13 15:32 ` Szabolcs Nagy
2019-06-13 15:35 ` Vincenzo Frascino
1 sibling, 2 replies; 50+ messages in thread
From: Szabolcs Nagy @ 2019-06-13 15:32 UTC (permalink / raw)
To: Vincenzo Frascino, Catalin Marinas
Cc: nd, linux-arm-kernel@lists.infradead.org,
linux-doc@vger.kernel.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, Will Deacon, Andrey Konovalov,
Alexander Viro
On 13/06/2019 15:03, Vincenzo Frascino wrote:
> On 13/06/2019 13:28, Szabolcs Nagy wrote:
>> On 13/06/2019 12:16, Vincenzo Frascino wrote:
>>> On 13/06/2019 11:14, Szabolcs Nagy wrote:
>>>> On 13/06/2019 10:20, Catalin Marinas wrote:
>>>>> On Wed, Jun 12, 2019 at 05:30:34PM +0100, Szabolcs Nagy wrote:
>>>>>> On 12/06/2019 15:21, Vincenzo Frascino wrote:
>>>>>>> + - a mapping below sbrk(0) done by the process itself
>>>>>>
>>>>>> doesn't the mmap rule cover this?
>>>>>
>>>>> IIUC it doesn't cover it as that's memory mapped by the kernel
>>>>> automatically on access vs a pointer returned by mmap(). The statement
>>>>> above talks about how the address is obtained by the user.
>>>>
>>>> ok i read 'mapping below sbrk' as an mmap (possibly MAP_FIXED)
>>>> that happens to be below the heap area.
>>>>
>>>> i think "below sbrk(0)" is not the best term to use: there
>>>> may be address range below the heap area that can be mmapped
>>>> and thus below sbrk(0) and sbrk is a posix api not a linux
>>>> syscall, the libc can implement it with mmap or whatever.
>>>>
>>>> i'm not sure what the right term for 'heap area' is
>>>> (the address range between syscall(__NR_brk,0) at
>>>> program startup and its current value?)
>>>>
>>>
>>> I used sbrk(0) with the meaning of "end of the process's data segment" not
>>> implying that this is a syscall, but just as a useful way to identify the mapping.
>>> I agree that it is a posix function implemented by libc but when it is used with
>>> 0 finds the current location of the program break, which can be changed by brk()
>>> and depending on the new address passed to this syscall can have the effect of
>>> allocating or deallocating memory.
>>>
>>> Will changing sbrk(0) with "end of the process's data segment" make it more clear?
>>
>> i don't understand what's the relevance of the *end*
>> of the data segment.
>>
>> i'd expect the text to say something about the address
>> range of the data segment.
>>
>> i can do
>>
>> mmap((void*)65536, 65536, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_SHARED|MAP_ANON, -1, 0);
>>
>> and it will be below the end of the data segment.
>>
>
> As far as I understand the data segment "lives" below the program break, hence
> it is a way of describing the range from which the user can obtain a valid
> tagged pointer.>
> Said that, I am not really sure on how do you want me to document this (my aim
> is for this to be clear to the userspace developers). Could you please propose
> something?
[...], it is in the memory ranges privately owned by a
userspace process and it is obtained in one of the
following ways:
- mmap done by the process itself, [...]
- brk syscall done by the process itself.
(i.e. the heap area between the initial location
of the program break at process creation and its
current location.)
- any memory mapped by the kernel [...]
the data segment that's part of the process image is
already covered by the last point.
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 15:32 ` Szabolcs Nagy
@ 2019-06-13 15:32 ` Szabolcs Nagy
2019-06-13 15:35 ` Vincenzo Frascino
1 sibling, 0 replies; 50+ messages in thread
From: Szabolcs Nagy @ 2019-06-13 15:32 UTC (permalink / raw)
To: Vincenzo Frascino, Catalin Marinas
Cc: nd, linux-arm-kernel@lists.infradead.org,
linux-doc@vger.kernel.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, Will Deacon, Andrey Konovalov,
Alexander Viro
On 13/06/2019 15:03, Vincenzo Frascino wrote:
> On 13/06/2019 13:28, Szabolcs Nagy wrote:
>> On 13/06/2019 12:16, Vincenzo Frascino wrote:
>>> On 13/06/2019 11:14, Szabolcs Nagy wrote:
>>>> On 13/06/2019 10:20, Catalin Marinas wrote:
>>>>> On Wed, Jun 12, 2019 at 05:30:34PM +0100, Szabolcs Nagy wrote:
>>>>>> On 12/06/2019 15:21, Vincenzo Frascino wrote:
>>>>>>> + - a mapping below sbrk(0) done by the process itself
>>>>>>
>>>>>> doesn't the mmap rule cover this?
>>>>>
>>>>> IIUC it doesn't cover it as that's memory mapped by the kernel
>>>>> automatically on access vs a pointer returned by mmap(). The statement
>>>>> above talks about how the address is obtained by the user.
>>>>
>>>> ok i read 'mapping below sbrk' as an mmap (possibly MAP_FIXED)
>>>> that happens to be below the heap area.
>>>>
>>>> i think "below sbrk(0)" is not the best term to use: there
>>>> may be address range below the heap area that can be mmapped
>>>> and thus below sbrk(0) and sbrk is a posix api not a linux
>>>> syscall, the libc can implement it with mmap or whatever.
>>>>
>>>> i'm not sure what the right term for 'heap area' is
>>>> (the address range between syscall(__NR_brk,0) at
>>>> program startup and its current value?)
>>>>
>>>
>>> I used sbrk(0) with the meaning of "end of the process's data segment" not
>>> implying that this is a syscall, but just as a useful way to identify the mapping.
>>> I agree that it is a posix function implemented by libc but when it is used with
>>> 0 finds the current location of the program break, which can be changed by brk()
>>> and depending on the new address passed to this syscall can have the effect of
>>> allocating or deallocating memory.
>>>
>>> Will changing sbrk(0) with "end of the process's data segment" make it more clear?
>>
>> i don't understand what's the relevance of the *end*
>> of the data segment.
>>
>> i'd expect the text to say something about the address
>> range of the data segment.
>>
>> i can do
>>
>> mmap((void*)65536, 65536, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_SHARED|MAP_ANON, -1, 0);
>>
>> and it will be below the end of the data segment.
>>
>
> As far as I understand the data segment "lives" below the program break, hence
> it is a way of describing the range from which the user can obtain a valid
> tagged pointer.>
> Said that, I am not really sure on how do you want me to document this (my aim
> is for this to be clear to the userspace developers). Could you please propose
> something?
[...], it is in the memory ranges privately owned by a
userspace process and it is obtained in one of the
following ways:
- mmap done by the process itself, [...]
- brk syscall done by the process itself.
(i.e. the heap area between the initial location
of the program break at process creation and its
current location.)
- any memory mapped by the kernel [...]
the data segment that's part of the process image is
already covered by the last point.
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 15:32 ` Szabolcs Nagy
2019-06-13 15:32 ` Szabolcs Nagy
@ 2019-06-13 15:35 ` Vincenzo Frascino
2019-06-13 15:35 ` Vincenzo Frascino
1 sibling, 1 reply; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-13 15:35 UTC (permalink / raw)
To: Szabolcs Nagy, Catalin Marinas
Cc: nd, linux-arm-kernel@lists.infradead.org,
linux-doc@vger.kernel.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, Will Deacon, Andrey Konovalov,
Alexander Viro
On 13/06/2019 16:32, Szabolcs Nagy wrote:
> On 13/06/2019 15:03, Vincenzo Frascino wrote:
>> On 13/06/2019 13:28, Szabolcs Nagy wrote:
>>> On 13/06/2019 12:16, Vincenzo Frascino wrote:
>>>> On 13/06/2019 11:14, Szabolcs Nagy wrote:
>>>>> On 13/06/2019 10:20, Catalin Marinas wrote:
>>>>>> On Wed, Jun 12, 2019 at 05:30:34PM +0100, Szabolcs Nagy wrote:
>>>>>>> On 12/06/2019 15:21, Vincenzo Frascino wrote:
>>>>>>>> + - a mapping below sbrk(0) done by the process itself
>>>>>>>
>>>>>>> doesn't the mmap rule cover this?
>>>>>>
>>>>>> IIUC it doesn't cover it as that's memory mapped by the kernel
>>>>>> automatically on access vs a pointer returned by mmap(). The statement
>>>>>> above talks about how the address is obtained by the user.
>>>>>
>>>>> ok i read 'mapping below sbrk' as an mmap (possibly MAP_FIXED)
>>>>> that happens to be below the heap area.
>>>>>
>>>>> i think "below sbrk(0)" is not the best term to use: there
>>>>> may be address range below the heap area that can be mmapped
>>>>> and thus below sbrk(0) and sbrk is a posix api not a linux
>>>>> syscall, the libc can implement it with mmap or whatever.
>>>>>
>>>>> i'm not sure what the right term for 'heap area' is
>>>>> (the address range between syscall(__NR_brk,0) at
>>>>> program startup and its current value?)
>>>>>
>>>>
>>>> I used sbrk(0) with the meaning of "end of the process's data segment" not
>>>> implying that this is a syscall, but just as a useful way to identify the mapping.
>>>> I agree that it is a posix function implemented by libc but when it is used with
>>>> 0 finds the current location of the program break, which can be changed by brk()
>>>> and depending on the new address passed to this syscall can have the effect of
>>>> allocating or deallocating memory.
>>>>
>>>> Will changing sbrk(0) with "end of the process's data segment" make it more clear?
>>>
>>> i don't understand what's the relevance of the *end*
>>> of the data segment.
>>>
>>> i'd expect the text to say something about the address
>>> range of the data segment.
>>>
>>> i can do
>>>
>>> mmap((void*)65536, 65536, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_SHARED|MAP_ANON, -1, 0);
>>>
>>> and it will be below the end of the data segment.
>>>
>>
>> As far as I understand the data segment "lives" below the program break, hence
>> it is a way of describing the range from which the user can obtain a valid
>> tagged pointer.>
>> Said that, I am not really sure on how do you want me to document this (my aim
>> is for this to be clear to the userspace developers). Could you please propose
>> something?
>
> [...], it is in the memory ranges privately owned by a
> userspace process and it is obtained in one of the
> following ways:
>
> - mmap done by the process itself, [...]
>
> - brk syscall done by the process itself.
> (i.e. the heap area between the initial location
> of the program break at process creation and its
> current location.)
>
> - any memory mapped by the kernel [...]
>
> the data segment that's part of the process image is
> already covered by the last point.
>
Thanks Szabolcs, I will update the document accordingly.
--
Regards,
Vincenzo
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 15:35 ` Vincenzo Frascino
@ 2019-06-13 15:35 ` Vincenzo Frascino
0 siblings, 0 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-13 15:35 UTC (permalink / raw)
To: Szabolcs Nagy, Catalin Marinas
Cc: nd, linux-arm-kernel@lists.infradead.org,
linux-doc@vger.kernel.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, Will Deacon, Andrey Konovalov,
Alexander Viro
On 13/06/2019 16:32, Szabolcs Nagy wrote:
> On 13/06/2019 15:03, Vincenzo Frascino wrote:
>> On 13/06/2019 13:28, Szabolcs Nagy wrote:
>>> On 13/06/2019 12:16, Vincenzo Frascino wrote:
>>>> On 13/06/2019 11:14, Szabolcs Nagy wrote:
>>>>> On 13/06/2019 10:20, Catalin Marinas wrote:
>>>>>> On Wed, Jun 12, 2019 at 05:30:34PM +0100, Szabolcs Nagy wrote:
>>>>>>> On 12/06/2019 15:21, Vincenzo Frascino wrote:
>>>>>>>> + - a mapping below sbrk(0) done by the process itself
>>>>>>>
>>>>>>> doesn't the mmap rule cover this?
>>>>>>
>>>>>> IIUC it doesn't cover it as that's memory mapped by the kernel
>>>>>> automatically on access vs a pointer returned by mmap(). The statement
>>>>>> above talks about how the address is obtained by the user.
>>>>>
>>>>> ok i read 'mapping below sbrk' as an mmap (possibly MAP_FIXED)
>>>>> that happens to be below the heap area.
>>>>>
>>>>> i think "below sbrk(0)" is not the best term to use: there
>>>>> may be address range below the heap area that can be mmapped
>>>>> and thus below sbrk(0) and sbrk is a posix api not a linux
>>>>> syscall, the libc can implement it with mmap or whatever.
>>>>>
>>>>> i'm not sure what the right term for 'heap area' is
>>>>> (the address range between syscall(__NR_brk,0) at
>>>>> program startup and its current value?)
>>>>>
>>>>
>>>> I used sbrk(0) with the meaning of "end of the process's data segment" not
>>>> implying that this is a syscall, but just as a useful way to identify the mapping.
>>>> I agree that it is a posix function implemented by libc but when it is used with
>>>> 0 finds the current location of the program break, which can be changed by brk()
>>>> and depending on the new address passed to this syscall can have the effect of
>>>> allocating or deallocating memory.
>>>>
>>>> Will changing sbrk(0) with "end of the process's data segment" make it more clear?
>>>
>>> i don't understand what's the relevance of the *end*
>>> of the data segment.
>>>
>>> i'd expect the text to say something about the address
>>> range of the data segment.
>>>
>>> i can do
>>>
>>> mmap((void*)65536, 65536, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_SHARED|MAP_ANON, -1, 0);
>>>
>>> and it will be below the end of the data segment.
>>>
>>
>> As far as I understand the data segment "lives" below the program break, hence
>> it is a way of describing the range from which the user can obtain a valid
>> tagged pointer.>
>> Said that, I am not really sure on how do you want me to document this (my aim
>> is for this to be clear to the userspace developers). Could you please propose
>> something?
>
> [...], it is in the memory ranges privately owned by a
> userspace process and it is obtained in one of the
> following ways:
>
> - mmap done by the process itself, [...]
>
> - brk syscall done by the process itself.
> (i.e. the heap area between the initial location
> of the program break at process creation and its
> current location.)
>
> - any memory mapped by the kernel [...]
>
> the data segment that's part of the process image is
> already covered by the last point.
>
Thanks Szabolcs, I will update the document accordingly.
--
Regards,
Vincenzo
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 13:23 ` Dave Martin
2019-06-13 13:23 ` Dave Martin
@ 2019-06-13 15:39 ` Catalin Marinas
2019-06-13 15:39 ` Catalin Marinas
1 sibling, 1 reply; 50+ messages in thread
From: Catalin Marinas @ 2019-06-13 15:39 UTC (permalink / raw)
To: Dave Martin
Cc: linux-arch, linux-doc, Szabolcs Nagy, Andrey Konovalov,
Will Deacon, linux-kernel, linux-mm, Alexander Viro,
linux-kselftest, Vincenzo Frascino, linux-arm-kernel
On Thu, Jun 13, 2019 at 02:23:43PM +0100, Dave P Martin wrote:
> On Thu, Jun 13, 2019 at 01:28:21PM +0100, Catalin Marinas wrote:
> > On Thu, Jun 13, 2019 at 12:37:32PM +0100, Dave P Martin wrote:
> > > On Thu, Jun 13, 2019 at 11:15:34AM +0100, Vincenzo Frascino wrote:
> > > > On 12/06/2019 16:35, Catalin Marinas wrote:
> > > > > On Wed, Jun 12, 2019 at 03:21:10PM +0100, Vincenzo Frascino wrote:
> > > > >> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> > > > >> + Address ABI.
> > [...]
> > > Is there a canonical way to detect whether this whole API/ABI is
> > > available? (i.e., try to call this prctl / check for an HWCAP bit,
> > > etc.)
> >
> > The canonical way is a prctl() call. HWCAP doesn't make sense since it's
> > not a hardware feature. If you really want a different way of detecting
> > this (which I don't think it's worth), we can reinstate the AT_FLAGS
> > bit.
>
> Sure, I think this probably makes sense -- I'm still getting my around
> which parts of the design are directly related to MTE and which aren't.
>
> I was a bit concerned about the interaction between
> PR_SET_TAGGED_ADDR_CTRL and the sysctl: the caller might conclude that
> this API is unavailable when actually tagged addresses are stuck on.
>
> I'm not sure whether this matters, but it's a bit weird.
>
> One option would be to change the semantics, so that the sysctl just
> forbids turning tagging from off to on. Alternatively, we could return
> a different error code to distinguish this case.
This is the intention, just to forbid turning tagging on. We could
return -EPERM instead, though my original intent was to simply pretend
that the prctl does not exist like in an older kernel version.
--
Catalin
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 15:39 ` Catalin Marinas
@ 2019-06-13 15:39 ` Catalin Marinas
0 siblings, 0 replies; 50+ messages in thread
From: Catalin Marinas @ 2019-06-13 15:39 UTC (permalink / raw)
To: Dave Martin
Cc: linux-arch, linux-doc, Szabolcs Nagy, Andrey Konovalov,
Will Deacon, linux-kernel, linux-mm, Alexander Viro,
linux-kselftest, Vincenzo Frascino, linux-arm-kernel
On Thu, Jun 13, 2019 at 02:23:43PM +0100, Dave P Martin wrote:
> On Thu, Jun 13, 2019 at 01:28:21PM +0100, Catalin Marinas wrote:
> > On Thu, Jun 13, 2019 at 12:37:32PM +0100, Dave P Martin wrote:
> > > On Thu, Jun 13, 2019 at 11:15:34AM +0100, Vincenzo Frascino wrote:
> > > > On 12/06/2019 16:35, Catalin Marinas wrote:
> > > > > On Wed, Jun 12, 2019 at 03:21:10PM +0100, Vincenzo Frascino wrote:
> > > > >> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> > > > >> + Address ABI.
> > [...]
> > > Is there a canonical way to detect whether this whole API/ABI is
> > > available? (i.e., try to call this prctl / check for an HWCAP bit,
> > > etc.)
> >
> > The canonical way is a prctl() call. HWCAP doesn't make sense since it's
> > not a hardware feature. If you really want a different way of detecting
> > this (which I don't think it's worth), we can reinstate the AT_FLAGS
> > bit.
>
> Sure, I think this probably makes sense -- I'm still getting my around
> which parts of the design are directly related to MTE and which aren't.
>
> I was a bit concerned about the interaction between
> PR_SET_TAGGED_ADDR_CTRL and the sysctl: the caller might conclude that
> this API is unavailable when actually tagged addresses are stuck on.
>
> I'm not sure whether this matters, but it's a bit weird.
>
> One option would be to change the semantics, so that the sysctl just
> forbids turning tagging from off to on. Alternatively, we could return
> a different error code to distinguish this case.
This is the intention, just to forbid turning tagging on. We could
return -EPERM instead, though my original intent was to simply pretend
that the prctl does not exist like in an older kernel version.
--
Catalin
^ permalink raw reply [flat|nested] 50+ messages in thread
* [PATCH v5 0/2] arm64 relaxed ABI
[not found] <cover.1560339705.git.andreyknvl@google.com>
2019-06-12 14:21 ` [PATCH v4 0/2] arm64 relaxed ABI Vincenzo Frascino
@ 2019-06-13 15:51 ` Vincenzo Frascino
2019-06-13 15:51 ` Vincenzo Frascino
` (2 more replies)
1 sibling, 3 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-13 15:51 UTC (permalink / raw)
To: linux-arm-kernel, linux-doc, linux-mm, linux-arch,
linux-kselftest, linux-kernel
Cc: Catalin Marinas, Will Deacon, Alexander Viro, Andrey Konovalov
On arm64 the TCR_EL1.TBI0 bit has been always enabled on the arm64 kernel,
hence the userspace (EL0) is allowed to set a non-zero value in the top
byte but the resulting pointers are not allowed at the user-kernel syscall
ABI boundary.
This patchset proposes a relaxation of the ABI with which it is possible
to pass tagged tagged pointers to the syscalls, when these pointers are in
memory ranges obtained as described in tagged-address-abi.txt contained in
this patch series.
Since it is not desirable to relax the ABI to allow tagged user addresses
into the kernel indiscriminately, this patchset documents a new sysctl
interface (/proc/sys/abi/tagged_addr) that is used to prevent the applications
from enabling the relaxed ABI and a new prctl() interface that can be used to
enable or disable the relaxed ABI.
This patchset should be merged together with [1].
[1] https://patchwork.kernel.org/cover/10674351/
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
CC: Andrey Konovalov <andreyknvl@google.com>
CC: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Vincenzo Frascino (2):
arm64: Define Documentation/arm64/tagged-address-abi.txt
arm64: Relax Documentation/arm64/tagged-pointers.txt
Documentation/arm64/tagged-address-abi.txt | 134 +++++++++++++++++++++
Documentation/arm64/tagged-pointers.txt | 23 ++--
2 files changed, 150 insertions(+), 7 deletions(-)
create mode 100644 Documentation/arm64/tagged-address-abi.txt
--
2.21.0
^ permalink raw reply [flat|nested] 50+ messages in thread
* [PATCH v5 0/2] arm64 relaxed ABI
2019-06-13 15:51 ` [PATCH v5 0/2] arm64 relaxed ABI Vincenzo Frascino
@ 2019-06-13 15:51 ` Vincenzo Frascino
2019-06-13 15:51 ` [PATCH v5 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt Vincenzo Frascino
2019-06-13 15:51 ` [PATCH v5 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt Vincenzo Frascino
2 siblings, 0 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-13 15:51 UTC (permalink / raw)
To: linux-arm-kernel, linux-doc, linux-mm, linux-arch,
linux-kselftest, linux-kernel
Cc: Catalin Marinas, Will Deacon, Andrey Konovalov, Alexander Viro
On arm64 the TCR_EL1.TBI0 bit has been always enabled on the arm64 kernel,
hence the userspace (EL0) is allowed to set a non-zero value in the top
byte but the resulting pointers are not allowed at the user-kernel syscall
ABI boundary.
This patchset proposes a relaxation of the ABI with which it is possible
to pass tagged tagged pointers to the syscalls, when these pointers are in
memory ranges obtained as described in tagged-address-abi.txt contained in
this patch series.
Since it is not desirable to relax the ABI to allow tagged user addresses
into the kernel indiscriminately, this patchset documents a new sysctl
interface (/proc/sys/abi/tagged_addr) that is used to prevent the applications
from enabling the relaxed ABI and a new prctl() interface that can be used to
enable or disable the relaxed ABI.
This patchset should be merged together with [1].
[1] https://patchwork.kernel.org/cover/10674351/
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
CC: Andrey Konovalov <andreyknvl@google.com>
CC: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Vincenzo Frascino (2):
arm64: Define Documentation/arm64/tagged-address-abi.txt
arm64: Relax Documentation/arm64/tagged-pointers.txt
Documentation/arm64/tagged-address-abi.txt | 134 +++++++++++++++++++++
Documentation/arm64/tagged-pointers.txt | 23 ++--
2 files changed, 150 insertions(+), 7 deletions(-)
create mode 100644 Documentation/arm64/tagged-address-abi.txt
--
2.21.0
^ permalink raw reply [flat|nested] 50+ messages in thread
* [PATCH v5 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 15:51 ` [PATCH v5 0/2] arm64 relaxed ABI Vincenzo Frascino
2019-06-13 15:51 ` Vincenzo Frascino
@ 2019-06-13 15:51 ` Vincenzo Frascino
2019-06-13 15:51 ` Vincenzo Frascino
` (2 more replies)
2019-06-13 15:51 ` [PATCH v5 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt Vincenzo Frascino
2 siblings, 3 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-13 15:51 UTC (permalink / raw)
To: linux-arm-kernel, linux-doc, linux-mm, linux-arch,
linux-kselftest, linux-kernel
Cc: Catalin Marinas, Will Deacon, Andrey Konovalov, Alexander Viro
On arm64 the TCR_EL1.TBI0 bit has been always enabled hence
the userspace (EL0) is allowed to set a non-zero value in the
top byte but the resulting pointers are not allowed at the
user-kernel syscall ABI boundary.
With the relaxed ABI proposed through this document, it is now possible
to pass tagged pointers to the syscalls, when these pointers are in
memory ranges obtained by an anonymous (MAP_ANONYMOUS) mmap().
This change in the ABI requires a mechanism to requires the userspace
to opt-in to such an option.
Specify and document the way in which sysctl and prctl() can be used
in combination to allow the userspace to opt-in this feature.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
CC: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
Documentation/arm64/tagged-address-abi.txt | 134 +++++++++++++++++++++
1 file changed, 134 insertions(+)
create mode 100644 Documentation/arm64/tagged-address-abi.txt
diff --git a/Documentation/arm64/tagged-address-abi.txt b/Documentation/arm64/tagged-address-abi.txt
new file mode 100644
index 000000000000..0ae900d4bb2d
--- /dev/null
+++ b/Documentation/arm64/tagged-address-abi.txt
@@ -0,0 +1,134 @@
+ARM64 TAGGED ADDRESS ABI
+========================
+
+This document describes the usage and semantics of the Tagged Address
+ABI on arm64.
+
+1. Introduction
+---------------
+
+On arm64 the TCR_EL1.TBI0 bit has been always enabled on the kernel, hence
+the userspace (EL0) is entitled to perform a user memory access through a
+64-bit pointer with a non-zero top byte but the resulting pointers are not
+allowed at the user-kernel syscall ABI boundary.
+
+This document describes a relaxation of the ABI that makes it possible to
+to pass tagged pointers to the syscalls, when these pointers are in memory
+ranges obtained as described in section 2.
+
+Since it is not desirable to relax the ABI to allow tagged user addresses
+into the kernel indiscriminately, arm64 provides a new sysctl interface
+(/proc/sys/abi/tagged_addr) that is used to prevent the applications from
+enabling the relaxed ABI and a new prctl() interface that can be used to
+enable or disable the relaxed ABI.
+A detailed description of the newly introduced mechanisms will be provided
+in section 2.
+
+2. ARM64 Tagged Address ABI
+---------------------------
+
+From the kernel syscall interface perspective, we define, for the purposes
+of this document, a "valid tagged pointer" as a pointer that either has a
+zero value set in the top byte or has a non-zero value, it is in memory
+ranges privately owned by a userspace process and it is obtained in one of
+the following ways:
+ - mmap() done by the process itself, where either:
+ * flags have MAP_PRIVATE and MAP_ANONYMOUS
+ * flags have MAP_PRIVATE and the file descriptor refers to a regular
+ file or "/dev/zero"
+ - brk() system call done by the process itself (i.e. the heap area between
+ the initial location of the program break at process creation and its
+ current location).
+ - any memory mapped by the kernel in the process's address space during
+ creation and following the restrictions presented above (i.e. data, bss,
+ stack).
+
+The ARM64 Tagged Address ABI is an opt-in feature, and an application can
+control it using the following:
+ - /proc/sys/abi/tagged_addr: a new sysctl interface that can be used to
+ prevent the applications from enabling the relaxed ABI.
+ The sysctl is meant also for testing purposes in order to provide a
+ simple way for the userspace to verify the return error checking of
+ the prctl() commands without having to reconfigure the kernel.
+ The sysctl supports the following configuration options:
+ - 0: Disable ARM64 Tagged Address ABI for all the applications.
+ - 1 (Default): Enable ARM64 Tagged Address ABI for all the
+ applications.
+ If the ARM64 Tagged Address ABI is disabled at a certain point in
+ time, all the applications that were using tagging before this event
+ occurs, will continue to use tagging.
+
+ - prctl()s:
+ - PR_SET_TAGGED_ADDR_CTRL: can be used to enable or disable the Tagged
+ Address ABI.
+ The (unsigned int) arg2 argument is a bit mask describing the
+ control mode used:
+ - PR_TAGGED_ADDR_ENABLE: Enable ARM64 Tagged Address ABI.
+ The arguments arg3, arg4, and arg5 are ignored.
+
+ - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
+ Address ABI.
+ The arguments arg2, arg3, arg4, and arg5 are ignored.
+
+The ABI properties set by the mechanisms described above are inherited by threads
+of the same application and fork()'ed children but cleared by execve().
+
+As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
+the ABI guarantees the following behaviours:
+
+ - Every current or newly introduced syscall can accept any valid tagged
+ pointers.
+
+ - If a non valid tagged pointer is passed to a syscall then the behaviour
+ is undefined.
+
+ - Every valid tagged pointer is expected to work as an untagged one.
+
+ - The kernel preserves any valid tagged pointers and returns them to the
+ userspace unchanged (i.e. on syscall return) in all the cases except the
+ ones documented in the "Preserving tags" section of tagged-pointers.txt.
+
+A definition of the meaning of tagged pointers on arm64 can be found in:
+Documentation/arm64/tagged-pointers.txt.
+
+3. ARM64 Tagged Address ABI Exceptions
+--------------------------------------
+
+The behaviours described in section 2, with particular reference to the
+acceptance by the syscalls of any valid tagged pointer are not applicable
+to the following cases:
+ - mmap() addr parameter.
+ - mremap() new_address parameter.
+ - prctl_set_mm() struct prctl_map fields.
+ - prctl_set_mm_map() struct prctl_map fields.
+
+Any attempt to use non-zero tagged pointers will lead to undefined behaviour.
+
+4. Example of correct usage
+---------------------------
+
+void main(void)
+{
+ static int tbi_enabled = 0;
+ unsigned long tag = 0;
+
+ char *ptr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
+ MAP_ANONYMOUS, -1, 0);
+
+ if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE,
+ 0, 0, 0) == 0)
+ tbi_enabled = 1;
+
+ if (ptr == (void *)-1) /* MAP_FAILED */
+ return -1;
+
+ if (tbi_enabled)
+ tag = rand() & 0xff;
+
+ ptr = (char *)((unsigned long)ptr | (tag << TAG_SHIFT));
+
+ *ptr = 'a';
+
+ ...
+}
+
--
2.21.0
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v5 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 15:51 ` [PATCH v5 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt Vincenzo Frascino
@ 2019-06-13 15:51 ` Vincenzo Frascino
2019-06-18 11:02 ` Szabolcs Nagy
2019-06-18 13:13 ` Kevin Brodsky
2 siblings, 0 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-13 15:51 UTC (permalink / raw)
To: linux-arm-kernel, linux-doc, linux-mm, linux-arch,
linux-kselftest, linux-kernel
Cc: Catalin Marinas, Will Deacon, Andrey Konovalov, Alexander Viro
On arm64 the TCR_EL1.TBI0 bit has been always enabled hence
the userspace (EL0) is allowed to set a non-zero value in the
top byte but the resulting pointers are not allowed at the
user-kernel syscall ABI boundary.
With the relaxed ABI proposed through this document, it is now possible
to pass tagged pointers to the syscalls, when these pointers are in
memory ranges obtained by an anonymous (MAP_ANONYMOUS) mmap().
This change in the ABI requires a mechanism to requires the userspace
to opt-in to such an option.
Specify and document the way in which sysctl and prctl() can be used
in combination to allow the userspace to opt-in this feature.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
CC: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
Documentation/arm64/tagged-address-abi.txt | 134 +++++++++++++++++++++
1 file changed, 134 insertions(+)
create mode 100644 Documentation/arm64/tagged-address-abi.txt
diff --git a/Documentation/arm64/tagged-address-abi.txt b/Documentation/arm64/tagged-address-abi.txt
new file mode 100644
index 000000000000..0ae900d4bb2d
--- /dev/null
+++ b/Documentation/arm64/tagged-address-abi.txt
@@ -0,0 +1,134 @@
+ARM64 TAGGED ADDRESS ABI
+========================
+
+This document describes the usage and semantics of the Tagged Address
+ABI on arm64.
+
+1. Introduction
+---------------
+
+On arm64 the TCR_EL1.TBI0 bit has been always enabled on the kernel, hence
+the userspace (EL0) is entitled to perform a user memory access through a
+64-bit pointer with a non-zero top byte but the resulting pointers are not
+allowed at the user-kernel syscall ABI boundary.
+
+This document describes a relaxation of the ABI that makes it possible to
+to pass tagged pointers to the syscalls, when these pointers are in memory
+ranges obtained as described in section 2.
+
+Since it is not desirable to relax the ABI to allow tagged user addresses
+into the kernel indiscriminately, arm64 provides a new sysctl interface
+(/proc/sys/abi/tagged_addr) that is used to prevent the applications from
+enabling the relaxed ABI and a new prctl() interface that can be used to
+enable or disable the relaxed ABI.
+A detailed description of the newly introduced mechanisms will be provided
+in section 2.
+
+2. ARM64 Tagged Address ABI
+---------------------------
+
+From the kernel syscall interface perspective, we define, for the purposes
+of this document, a "valid tagged pointer" as a pointer that either has a
+zero value set in the top byte or has a non-zero value, it is in memory
+ranges privately owned by a userspace process and it is obtained in one of
+the following ways:
+ - mmap() done by the process itself, where either:
+ * flags have MAP_PRIVATE and MAP_ANONYMOUS
+ * flags have MAP_PRIVATE and the file descriptor refers to a regular
+ file or "/dev/zero"
+ - brk() system call done by the process itself (i.e. the heap area between
+ the initial location of the program break at process creation and its
+ current location).
+ - any memory mapped by the kernel in the process's address space during
+ creation and following the restrictions presented above (i.e. data, bss,
+ stack).
+
+The ARM64 Tagged Address ABI is an opt-in feature, and an application can
+control it using the following:
+ - /proc/sys/abi/tagged_addr: a new sysctl interface that can be used to
+ prevent the applications from enabling the relaxed ABI.
+ The sysctl is meant also for testing purposes in order to provide a
+ simple way for the userspace to verify the return error checking of
+ the prctl() commands without having to reconfigure the kernel.
+ The sysctl supports the following configuration options:
+ - 0: Disable ARM64 Tagged Address ABI for all the applications.
+ - 1 (Default): Enable ARM64 Tagged Address ABI for all the
+ applications.
+ If the ARM64 Tagged Address ABI is disabled at a certain point in
+ time, all the applications that were using tagging before this event
+ occurs, will continue to use tagging.
+
+ - prctl()s:
+ - PR_SET_TAGGED_ADDR_CTRL: can be used to enable or disable the Tagged
+ Address ABI.
+ The (unsigned int) arg2 argument is a bit mask describing the
+ control mode used:
+ - PR_TAGGED_ADDR_ENABLE: Enable ARM64 Tagged Address ABI.
+ The arguments arg3, arg4, and arg5 are ignored.
+
+ - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
+ Address ABI.
+ The arguments arg2, arg3, arg4, and arg5 are ignored.
+
+The ABI properties set by the mechanisms described above are inherited by threads
+of the same application and fork()'ed children but cleared by execve().
+
+As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
+the ABI guarantees the following behaviours:
+
+ - Every current or newly introduced syscall can accept any valid tagged
+ pointers.
+
+ - If a non valid tagged pointer is passed to a syscall then the behaviour
+ is undefined.
+
+ - Every valid tagged pointer is expected to work as an untagged one.
+
+ - The kernel preserves any valid tagged pointers and returns them to the
+ userspace unchanged (i.e. on syscall return) in all the cases except the
+ ones documented in the "Preserving tags" section of tagged-pointers.txt.
+
+A definition of the meaning of tagged pointers on arm64 can be found in:
+Documentation/arm64/tagged-pointers.txt.
+
+3. ARM64 Tagged Address ABI Exceptions
+--------------------------------------
+
+The behaviours described in section 2, with particular reference to the
+acceptance by the syscalls of any valid tagged pointer are not applicable
+to the following cases:
+ - mmap() addr parameter.
+ - mremap() new_address parameter.
+ - prctl_set_mm() struct prctl_map fields.
+ - prctl_set_mm_map() struct prctl_map fields.
+
+Any attempt to use non-zero tagged pointers will lead to undefined behaviour.
+
+4. Example of correct usage
+---------------------------
+
+void main(void)
+{
+ static int tbi_enabled = 0;
+ unsigned long tag = 0;
+
+ char *ptr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
+ MAP_ANONYMOUS, -1, 0);
+
+ if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE,
+ 0, 0, 0) == 0)
+ tbi_enabled = 1;
+
+ if (ptr == (void *)-1) /* MAP_FAILED */
+ return -1;
+
+ if (tbi_enabled)
+ tag = rand() & 0xff;
+
+ ptr = (char *)((unsigned long)ptr | (tag << TAG_SHIFT));
+
+ *ptr = 'a';
+
+ ...
+}
+
--
2.21.0
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v5 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt
2019-06-13 15:51 ` [PATCH v5 0/2] arm64 relaxed ABI Vincenzo Frascino
2019-06-13 15:51 ` Vincenzo Frascino
2019-06-13 15:51 ` [PATCH v5 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt Vincenzo Frascino
@ 2019-06-13 15:51 ` Vincenzo Frascino
2019-06-13 15:51 ` Vincenzo Frascino
2 siblings, 1 reply; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-13 15:51 UTC (permalink / raw)
To: linux-arm-kernel, linux-doc, linux-mm, linux-arch,
linux-kselftest, linux-kernel
Cc: Catalin Marinas, Will Deacon, Andrey Konovalov, Alexander Viro
On arm64 the TCR_EL1.TBI0 bit has been always enabled hence
the userspace (EL0) is allowed to set a non-zero value in the
top byte but the resulting pointers are not allowed at the
user-kernel syscall ABI boundary.
With the relaxed ABI proposed in this set, it is now possible to pass
tagged pointers to the syscalls, when these pointers are in memory
ranges obtained by an anonymous (MAP_ANONYMOUS) mmap().
Relax the requirements described in tagged-pointers.txt to be compliant
with the behaviours guaranteed by the ARM64 Tagged Address ABI.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
CC: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
Documentation/arm64/tagged-pointers.txt | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/Documentation/arm64/tagged-pointers.txt b/Documentation/arm64/tagged-pointers.txt
index a25a99e82bb1..e33af14478e3 100644
--- a/Documentation/arm64/tagged-pointers.txt
+++ b/Documentation/arm64/tagged-pointers.txt
@@ -18,7 +18,8 @@ Passing tagged addresses to the kernel
--------------------------------------
All interpretation of userspace memory addresses by the kernel assumes
-an address tag of 0x00.
+an address tag of 0x00, unless the userspace opts-in the ARM64 Tagged
+Address ABI via the PR_SET_TAGGED_ADDR_CTRL prctl().
This includes, but is not limited to, addresses found in:
@@ -31,18 +32,23 @@ This includes, but is not limited to, addresses found in:
- the frame pointer (x29) and frame records, e.g. when interpreting
them to generate a backtrace or call graph.
-Using non-zero address tags in any of these locations may result in an
-error code being returned, a (fatal) signal being raised, or other modes
-of failure.
+Using non-zero address tags in any of these locations when the
+userspace application did not opt-in to the ARM64 Tagged Address ABI
+may result in an error code being returned, a (fatal) signal being raised,
+or other modes of failure.
-For these reasons, passing non-zero address tags to the kernel via
-system calls is forbidden, and using a non-zero address tag for sp is
-strongly discouraged.
+For these reasons, when the userspace application did not opt-in, passing
+non-zero address tags to the kernel via system calls is forbidden, and using
+a non-zero address tag for sp is strongly discouraged.
Programs maintaining a frame pointer and frame records that use non-zero
address tags may suffer impaired or inaccurate debug and profiling
visibility.
+A definition of the meaning of ARM64 Tagged Address ABI and of the
+guarantees that the ABI provides when the userspace opts-in via prctl()
+can be found in: Documentation/arm64/tagged-address-abi.txt.
+
Preserving tags
---------------
@@ -57,6 +63,9 @@ be preserved.
The architecture prevents the use of a tagged PC, so the upper byte will
be set to a sign-extension of bit 55 on exception return.
+These behaviours are preserved even when the userspace opts-in to the ARM64
+Tagged Address ABI via the PR_SET_TAGGED_ADDR_CTRL prctl().
+
Other considerations
--------------------
--
2.21.0
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v5 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt
2019-06-13 15:51 ` [PATCH v5 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt Vincenzo Frascino
@ 2019-06-13 15:51 ` Vincenzo Frascino
0 siblings, 0 replies; 50+ messages in thread
From: Vincenzo Frascino @ 2019-06-13 15:51 UTC (permalink / raw)
To: linux-arm-kernel, linux-doc, linux-mm, linux-arch,
linux-kselftest, linux-kernel
Cc: Catalin Marinas, Will Deacon, Andrey Konovalov, Alexander Viro
On arm64 the TCR_EL1.TBI0 bit has been always enabled hence
the userspace (EL0) is allowed to set a non-zero value in the
top byte but the resulting pointers are not allowed at the
user-kernel syscall ABI boundary.
With the relaxed ABI proposed in this set, it is now possible to pass
tagged pointers to the syscalls, when these pointers are in memory
ranges obtained by an anonymous (MAP_ANONYMOUS) mmap().
Relax the requirements described in tagged-pointers.txt to be compliant
with the behaviours guaranteed by the ARM64 Tagged Address ABI.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
CC: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
Documentation/arm64/tagged-pointers.txt | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/Documentation/arm64/tagged-pointers.txt b/Documentation/arm64/tagged-pointers.txt
index a25a99e82bb1..e33af14478e3 100644
--- a/Documentation/arm64/tagged-pointers.txt
+++ b/Documentation/arm64/tagged-pointers.txt
@@ -18,7 +18,8 @@ Passing tagged addresses to the kernel
--------------------------------------
All interpretation of userspace memory addresses by the kernel assumes
-an address tag of 0x00.
+an address tag of 0x00, unless the userspace opts-in the ARM64 Tagged
+Address ABI via the PR_SET_TAGGED_ADDR_CTRL prctl().
This includes, but is not limited to, addresses found in:
@@ -31,18 +32,23 @@ This includes, but is not limited to, addresses found in:
- the frame pointer (x29) and frame records, e.g. when interpreting
them to generate a backtrace or call graph.
-Using non-zero address tags in any of these locations may result in an
-error code being returned, a (fatal) signal being raised, or other modes
-of failure.
+Using non-zero address tags in any of these locations when the
+userspace application did not opt-in to the ARM64 Tagged Address ABI
+may result in an error code being returned, a (fatal) signal being raised,
+or other modes of failure.
-For these reasons, passing non-zero address tags to the kernel via
-system calls is forbidden, and using a non-zero address tag for sp is
-strongly discouraged.
+For these reasons, when the userspace application did not opt-in, passing
+non-zero address tags to the kernel via system calls is forbidden, and using
+a non-zero address tag for sp is strongly discouraged.
Programs maintaining a frame pointer and frame records that use non-zero
address tags may suffer impaired or inaccurate debug and profiling
visibility.
+A definition of the meaning of ARM64 Tagged Address ABI and of the
+guarantees that the ABI provides when the userspace opts-in via prctl()
+can be found in: Documentation/arm64/tagged-address-abi.txt.
+
Preserving tags
---------------
@@ -57,6 +63,9 @@ be preserved.
The architecture prevents the use of a tagged PC, so the upper byte will
be set to a sign-extension of bit 55 on exception return.
+These behaviours are preserved even when the userspace opts-in to the ARM64
+Tagged Address ABI via the PR_SET_TAGGED_ADDR_CTRL prctl().
+
Other considerations
--------------------
--
2.21.0
^ permalink raw reply related [flat|nested] 50+ messages in thread
* Re: [PATCH v5 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 15:51 ` [PATCH v5 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt Vincenzo Frascino
2019-06-13 15:51 ` Vincenzo Frascino
@ 2019-06-18 11:02 ` Szabolcs Nagy
2019-06-18 11:02 ` Szabolcs Nagy
2019-06-18 13:13 ` Kevin Brodsky
2 siblings, 1 reply; 50+ messages in thread
From: Szabolcs Nagy @ 2019-06-18 11:02 UTC (permalink / raw)
To: Vincenzo Frascino, linux-arm-kernel@lists.infradead.org,
linux-doc@vger.kernel.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: nd, Catalin Marinas, Will Deacon, Andrey Konovalov,
Alexander Viro
On 13/06/2019 16:51, Vincenzo Frascino wrote:
> On arm64 the TCR_EL1.TBI0 bit has been always enabled hence
> the userspace (EL0) is allowed to set a non-zero value in the
> top byte but the resulting pointers are not allowed at the
> user-kernel syscall ABI boundary.
>
> With the relaxed ABI proposed through this document, it is now possible
> to pass tagged pointers to the syscalls, when these pointers are in
> memory ranges obtained by an anonymous (MAP_ANONYMOUS) mmap().
>
> This change in the ABI requires a mechanism to requires the userspace
> to opt-in to such an option.
>
> Specify and document the way in which sysctl and prctl() can be used
> in combination to allow the userspace to opt-in this feature.
>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> CC: Andrey Konovalov <andreyknvl@google.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Acked-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
> ---
> Documentation/arm64/tagged-address-abi.txt | 134 +++++++++++++++++++++
> 1 file changed, 134 insertions(+)
> create mode 100644 Documentation/arm64/tagged-address-abi.txt
>
> diff --git a/Documentation/arm64/tagged-address-abi.txt b/Documentation/arm64/tagged-address-abi.txt
> new file mode 100644
> index 000000000000..0ae900d4bb2d
> --- /dev/null
> +++ b/Documentation/arm64/tagged-address-abi.txt
> @@ -0,0 +1,134 @@
> +ARM64 TAGGED ADDRESS ABI
> +========================
> +
> +This document describes the usage and semantics of the Tagged Address
> +ABI on arm64.
> +
> +1. Introduction
> +---------------
> +
> +On arm64 the TCR_EL1.TBI0 bit has been always enabled on the kernel, hence
> +the userspace (EL0) is entitled to perform a user memory access through a
> +64-bit pointer with a non-zero top byte but the resulting pointers are not
> +allowed at the user-kernel syscall ABI boundary.
> +
> +This document describes a relaxation of the ABI that makes it possible to
> +to pass tagged pointers to the syscalls, when these pointers are in memory
> +ranges obtained as described in section 2.
> +
> +Since it is not desirable to relax the ABI to allow tagged user addresses
> +into the kernel indiscriminately, arm64 provides a new sysctl interface
> +(/proc/sys/abi/tagged_addr) that is used to prevent the applications from
> +enabling the relaxed ABI and a new prctl() interface that can be used to
> +enable or disable the relaxed ABI.
> +A detailed description of the newly introduced mechanisms will be provided
> +in section 2.
> +
> +2. ARM64 Tagged Address ABI
> +---------------------------
> +
> +From the kernel syscall interface perspective, we define, for the purposes
> +of this document, a "valid tagged pointer" as a pointer that either has a
> +zero value set in the top byte or has a non-zero value, it is in memory
> +ranges privately owned by a userspace process and it is obtained in one of
> +the following ways:
> + - mmap() done by the process itself, where either:
> + * flags have MAP_PRIVATE and MAP_ANONYMOUS
> + * flags have MAP_PRIVATE and the file descriptor refers to a regular
> + file or "/dev/zero"
> + - brk() system call done by the process itself (i.e. the heap area between
> + the initial location of the program break at process creation and its
> + current location).
> + - any memory mapped by the kernel in the process's address space during
> + creation and following the restrictions presented above (i.e. data, bss,
> + stack).
> +
> +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
> +control it using the following:
> + - /proc/sys/abi/tagged_addr: a new sysctl interface that can be used to
> + prevent the applications from enabling the relaxed ABI.
> + The sysctl is meant also for testing purposes in order to provide a
> + simple way for the userspace to verify the return error checking of
> + the prctl() commands without having to reconfigure the kernel.
> + The sysctl supports the following configuration options:
> + - 0: Disable ARM64 Tagged Address ABI for all the applications.
> + - 1 (Default): Enable ARM64 Tagged Address ABI for all the
> + applications.
> + If the ARM64 Tagged Address ABI is disabled at a certain point in
> + time, all the applications that were using tagging before this event
> + occurs, will continue to use tagging.
> +
> + - prctl()s:
> + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable or disable the Tagged
> + Address ABI.
> + The (unsigned int) arg2 argument is a bit mask describing the
> + control mode used:
> + - PR_TAGGED_ADDR_ENABLE: Enable ARM64 Tagged Address ABI.
> + The arguments arg3, arg4, and arg5 are ignored.
> +
> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> + Address ABI.
> + The arguments arg2, arg3, arg4, and arg5 are ignored.
> +
> +The ABI properties set by the mechanisms described above are inherited by threads
> +of the same application and fork()'ed children but cleared by execve().
> +
> +As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
> +the ABI guarantees the following behaviours:
> +
> + - Every current or newly introduced syscall can accept any valid tagged
> + pointers.
> +
> + - If a non valid tagged pointer is passed to a syscall then the behaviour
> + is undefined.
> +
> + - Every valid tagged pointer is expected to work as an untagged one.
> +
> + - The kernel preserves any valid tagged pointers and returns them to the
> + userspace unchanged (i.e. on syscall return) in all the cases except the
> + ones documented in the "Preserving tags" section of tagged-pointers.txt.
> +
> +A definition of the meaning of tagged pointers on arm64 can be found in:
> +Documentation/arm64/tagged-pointers.txt.
> +
> +3. ARM64 Tagged Address ABI Exceptions
> +--------------------------------------
> +
> +The behaviours described in section 2, with particular reference to the
> +acceptance by the syscalls of any valid tagged pointer are not applicable
> +to the following cases:
> + - mmap() addr parameter.
> + - mremap() new_address parameter.
> + - prctl_set_mm() struct prctl_map fields.
> + - prctl_set_mm_map() struct prctl_map fields.
> +
> +Any attempt to use non-zero tagged pointers will lead to undefined behaviour.
> +
> +4. Example of correct usage
> +---------------------------
> +
> +void main(void)
> +{
> + static int tbi_enabled = 0;
> + unsigned long tag = 0;
> +
> + char *ptr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
> + MAP_ANONYMOUS, -1, 0);
> +
> + if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE,
> + 0, 0, 0) == 0)
> + tbi_enabled = 1;
> +
> + if (ptr == (void *)-1) /* MAP_FAILED */
> + return -1;
> +
> + if (tbi_enabled)
> + tag = rand() & 0xff;
> +
> + ptr = (char *)((unsigned long)ptr | (tag << TAG_SHIFT));
> +
> + *ptr = 'a';
> +
> + ...
> +}
> +
>
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v5 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-18 11:02 ` Szabolcs Nagy
@ 2019-06-18 11:02 ` Szabolcs Nagy
0 siblings, 0 replies; 50+ messages in thread
From: Szabolcs Nagy @ 2019-06-18 11:02 UTC (permalink / raw)
To: Vincenzo Frascino, linux-arm-kernel@lists.infradead.org,
linux-doc@vger.kernel.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: nd, Catalin Marinas, Will Deacon, Andrey Konovalov,
Alexander Viro
On 13/06/2019 16:51, Vincenzo Frascino wrote:
> On arm64 the TCR_EL1.TBI0 bit has been always enabled hence
> the userspace (EL0) is allowed to set a non-zero value in the
> top byte but the resulting pointers are not allowed at the
> user-kernel syscall ABI boundary.
>
> With the relaxed ABI proposed through this document, it is now possible
> to pass tagged pointers to the syscalls, when these pointers are in
> memory ranges obtained by an anonymous (MAP_ANONYMOUS) mmap().
>
> This change in the ABI requires a mechanism to requires the userspace
> to opt-in to such an option.
>
> Specify and document the way in which sysctl and prctl() can be used
> in combination to allow the userspace to opt-in this feature.
>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> CC: Andrey Konovalov <andreyknvl@google.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Acked-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
> ---
> Documentation/arm64/tagged-address-abi.txt | 134 +++++++++++++++++++++
> 1 file changed, 134 insertions(+)
> create mode 100644 Documentation/arm64/tagged-address-abi.txt
>
> diff --git a/Documentation/arm64/tagged-address-abi.txt b/Documentation/arm64/tagged-address-abi.txt
> new file mode 100644
> index 000000000000..0ae900d4bb2d
> --- /dev/null
> +++ b/Documentation/arm64/tagged-address-abi.txt
> @@ -0,0 +1,134 @@
> +ARM64 TAGGED ADDRESS ABI
> +========================
> +
> +This document describes the usage and semantics of the Tagged Address
> +ABI on arm64.
> +
> +1. Introduction
> +---------------
> +
> +On arm64 the TCR_EL1.TBI0 bit has been always enabled on the kernel, hence
> +the userspace (EL0) is entitled to perform a user memory access through a
> +64-bit pointer with a non-zero top byte but the resulting pointers are not
> +allowed at the user-kernel syscall ABI boundary.
> +
> +This document describes a relaxation of the ABI that makes it possible to
> +to pass tagged pointers to the syscalls, when these pointers are in memory
> +ranges obtained as described in section 2.
> +
> +Since it is not desirable to relax the ABI to allow tagged user addresses
> +into the kernel indiscriminately, arm64 provides a new sysctl interface
> +(/proc/sys/abi/tagged_addr) that is used to prevent the applications from
> +enabling the relaxed ABI and a new prctl() interface that can be used to
> +enable or disable the relaxed ABI.
> +A detailed description of the newly introduced mechanisms will be provided
> +in section 2.
> +
> +2. ARM64 Tagged Address ABI
> +---------------------------
> +
> +From the kernel syscall interface perspective, we define, for the purposes
> +of this document, a "valid tagged pointer" as a pointer that either has a
> +zero value set in the top byte or has a non-zero value, it is in memory
> +ranges privately owned by a userspace process and it is obtained in one of
> +the following ways:
> + - mmap() done by the process itself, where either:
> + * flags have MAP_PRIVATE and MAP_ANONYMOUS
> + * flags have MAP_PRIVATE and the file descriptor refers to a regular
> + file or "/dev/zero"
> + - brk() system call done by the process itself (i.e. the heap area between
> + the initial location of the program break at process creation and its
> + current location).
> + - any memory mapped by the kernel in the process's address space during
> + creation and following the restrictions presented above (i.e. data, bss,
> + stack).
> +
> +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
> +control it using the following:
> + - /proc/sys/abi/tagged_addr: a new sysctl interface that can be used to
> + prevent the applications from enabling the relaxed ABI.
> + The sysctl is meant also for testing purposes in order to provide a
> + simple way for the userspace to verify the return error checking of
> + the prctl() commands without having to reconfigure the kernel.
> + The sysctl supports the following configuration options:
> + - 0: Disable ARM64 Tagged Address ABI for all the applications.
> + - 1 (Default): Enable ARM64 Tagged Address ABI for all the
> + applications.
> + If the ARM64 Tagged Address ABI is disabled at a certain point in
> + time, all the applications that were using tagging before this event
> + occurs, will continue to use tagging.
> +
> + - prctl()s:
> + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable or disable the Tagged
> + Address ABI.
> + The (unsigned int) arg2 argument is a bit mask describing the
> + control mode used:
> + - PR_TAGGED_ADDR_ENABLE: Enable ARM64 Tagged Address ABI.
> + The arguments arg3, arg4, and arg5 are ignored.
> +
> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> + Address ABI.
> + The arguments arg2, arg3, arg4, and arg5 are ignored.
> +
> +The ABI properties set by the mechanisms described above are inherited by threads
> +of the same application and fork()'ed children but cleared by execve().
> +
> +As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
> +the ABI guarantees the following behaviours:
> +
> + - Every current or newly introduced syscall can accept any valid tagged
> + pointers.
> +
> + - If a non valid tagged pointer is passed to a syscall then the behaviour
> + is undefined.
> +
> + - Every valid tagged pointer is expected to work as an untagged one.
> +
> + - The kernel preserves any valid tagged pointers and returns them to the
> + userspace unchanged (i.e. on syscall return) in all the cases except the
> + ones documented in the "Preserving tags" section of tagged-pointers.txt.
> +
> +A definition of the meaning of tagged pointers on arm64 can be found in:
> +Documentation/arm64/tagged-pointers.txt.
> +
> +3. ARM64 Tagged Address ABI Exceptions
> +--------------------------------------
> +
> +The behaviours described in section 2, with particular reference to the
> +acceptance by the syscalls of any valid tagged pointer are not applicable
> +to the following cases:
> + - mmap() addr parameter.
> + - mremap() new_address parameter.
> + - prctl_set_mm() struct prctl_map fields.
> + - prctl_set_mm_map() struct prctl_map fields.
> +
> +Any attempt to use non-zero tagged pointers will lead to undefined behaviour.
> +
> +4. Example of correct usage
> +---------------------------
> +
> +void main(void)
> +{
> + static int tbi_enabled = 0;
> + unsigned long tag = 0;
> +
> + char *ptr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
> + MAP_ANONYMOUS, -1, 0);
> +
> + if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE,
> + 0, 0, 0) == 0)
> + tbi_enabled = 1;
> +
> + if (ptr == (void *)-1) /* MAP_FAILED */
> + return -1;
> +
> + if (tbi_enabled)
> + tag = rand() & 0xff;
> +
> + ptr = (char *)((unsigned long)ptr | (tag << TAG_SHIFT));
> +
> + *ptr = 'a';
> +
> + ...
> +}
> +
>
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v5 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-13 15:51 ` [PATCH v5 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt Vincenzo Frascino
2019-06-13 15:51 ` Vincenzo Frascino
2019-06-18 11:02 ` Szabolcs Nagy
@ 2019-06-18 13:13 ` Kevin Brodsky
2019-06-18 13:13 ` Kevin Brodsky
2019-06-21 15:16 ` Catalin Marinas
2 siblings, 2 replies; 50+ messages in thread
From: Kevin Brodsky @ 2019-06-18 13:13 UTC (permalink / raw)
To: Vincenzo Frascino, linux-arm-kernel, linux-doc, linux-mm,
linux-arch, linux-kselftest, linux-kernel
Cc: Catalin Marinas, Will Deacon, Andrey Konovalov, Alexander Viro
I'm happy with the ABI overall, but I think we need a few more tweaks.
On 13/06/2019 16:51, Vincenzo Frascino wrote:
> On arm64 the TCR_EL1.TBI0 bit has been always enabled hence
> the userspace (EL0) is allowed to set a non-zero value in the
> top byte but the resulting pointers are not allowed at the
> user-kernel syscall ABI boundary.
>
> With the relaxed ABI proposed through this document, it is now possible
> to pass tagged pointers to the syscalls, when these pointers are in
> memory ranges obtained by an anonymous (MAP_ANONYMOUS) mmap().
>
> This change in the ABI requires a mechanism to requires the userspace
> to opt-in to such an option.
>
> Specify and document the way in which sysctl and prctl() can be used
> in combination to allow the userspace to opt-in this feature.
>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> CC: Andrey Konovalov <andreyknvl@google.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
> Documentation/arm64/tagged-address-abi.txt | 134 +++++++++++++++++++++
> 1 file changed, 134 insertions(+)
> create mode 100644 Documentation/arm64/tagged-address-abi.txt
>
> diff --git a/Documentation/arm64/tagged-address-abi.txt b/Documentation/arm64/tagged-address-abi.txt
> new file mode 100644
> index 000000000000..0ae900d4bb2d
> --- /dev/null
> +++ b/Documentation/arm64/tagged-address-abi.txt
> @@ -0,0 +1,134 @@
> +ARM64 TAGGED ADDRESS ABI
> +========================
> +
> +This document describes the usage and semantics of the Tagged Address
> +ABI on arm64.
> +
> +1. Introduction
> +---------------
> +
> +On arm64 the TCR_EL1.TBI0 bit has been always enabled on the kernel, hence
"been always" -> "always been"
> +the userspace (EL0) is entitled to perform a user memory access through a
> +64-bit pointer with a non-zero top byte but the resulting pointers are not
> +allowed at the user-kernel syscall ABI boundary.
> +
> +This document describes a relaxation of the ABI that makes it possible to
> +to pass tagged pointers to the syscalls, when these pointers are in memory
> +ranges obtained as described in section 2.
> +
> +Since it is not desirable to relax the ABI to allow tagged user addresses
> +into the kernel indiscriminately, arm64 provides a new sysctl interface
> +(/proc/sys/abi/tagged_addr) that is used to prevent the applications from
> +enabling the relaxed ABI and a new prctl() interface that can be used to
> +enable or disable the relaxed ABI.
> +A detailed description of the newly introduced mechanisms will be provided
> +in section 2.
> +
> +2. ARM64 Tagged Address ABI
> +---------------------------
> +
> +From the kernel syscall interface perspective, we define, for the purposes
> +of this document, a "valid tagged pointer" as a pointer that either has a
> +zero value set in the top byte or has a non-zero value, it is in memory
> +ranges privately owned by a userspace process and it is obtained in one of
Remove all the remaining "it": "a pointer that either [...], is in memory ranges
[...] and is obtained..."
> +the following ways:
> + - mmap() done by the process itself, where either:
> + * flags have MAP_PRIVATE and MAP_ANONYMOUS
> + * flags have MAP_PRIVATE and the file descriptor refers to a regular
> + file or "/dev/zero"
> + - brk() system call done by the process itself (i.e. the heap area between
> + the initial location of the program break at process creation and its
> + current location).
> + - any memory mapped by the kernel in the process's address space during
> + creation and following the restrictions presented above (i.e. data, bss,
> + stack).
As I commented on v2, the "i.e." is not correct: these 3 sections are not the only
ones that are covered by this ABI (.text also is, for instance). Replacing "i.e."
with "e.g." would work.
Also, since the rules above say explicitly "done by the process itself", it might be
clearer to replace "following the restrictions presented above" with "with the same
restrictions as for mmap()".
> +
> +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
> +control it using the following:
> + - /proc/sys/abi/tagged_addr: a new sysctl interface that can be used to
> + prevent the applications from enabling the relaxed ABI.
> + The sysctl is meant also for testing purposes in order to provide a
> + simple way for the userspace to verify the return error checking of
> + the prctl() commands without having to reconfigure the kernel.
> + The sysctl supports the following configuration options:
> + - 0: Disable ARM64 Tagged Address ABI for all the applications.
> + - 1 (Default): Enable ARM64 Tagged Address ABI for all the
> + applications.
I find this very confusing, because it suggests that the default value of
PR_GET_TAGGED_ADDR_CTRL for new processes will be set to the value of this sysctl,
when in fact this sysctl is about restricting the *availability* of the new ABI.
Instead of disabling the ABI, I would talk about disabling access to the new ABI here.
> + If the ARM64 Tagged Address ABI is disabled at a certain point in
> + time, all the applications that were using tagging before this event
> + occurs, will continue to use tagging.
> +
> + - prctl()s:
> + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable or disable the Tagged
> + Address ABI.
> + The (unsigned int) arg2 argument is a bit mask describing the
> + control mode used:
> + - PR_TAGGED_ADDR_ENABLE: Enable ARM64 Tagged Address ABI.
> + The arguments arg3, arg4, and arg5 are ignored.
Have we definitely decided that arg{3,4,5} are ignored? Catalin?
> +
> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> + Address ABI.
> + The arguments arg2, arg3, arg4, and arg5 are ignored.
> +
> +The ABI properties set by the mechanisms described above are inherited by threads
> +of the same application and fork()'ed children but cleared by execve().
> +
> +As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
I think this is too vague, you can use this prctl() to disable the new ABI, and it
can also fail. Maybe it's best to simply say that the process has successfully opted
into the new ABI.
> +the ABI guarantees the following behaviours:
> +
> + - Every current or newly introduced syscall can accept any valid tagged
> + pointers.
"pointer". Also, is it really useful to talk about newly introduced syscall? New from
which point of view?
> +
> + - If a non valid tagged pointer is passed to a syscall then the behaviour
> + is undefined.
> +
> + - Every valid tagged pointer is expected to work as an untagged one.
> +
> + - The kernel preserves any valid tagged pointers and returns them to the
"pointer", "returns it"
> + userspace unchanged (i.e. on syscall return) in all the cases except the
> + ones documented in the "Preserving tags" section of tagged-pointers.txt.
> +
> +A definition of the meaning of tagged pointers on arm64 can be found in:
> +Documentation/arm64/tagged-pointers.txt.
> +
> +3. ARM64 Tagged Address ABI Exceptions
> +--------------------------------------
> +
> +The behaviours described in section 2, with particular reference to the
> +acceptance by the syscalls of any valid tagged pointer are not applicable
> +to the following cases:
> + - mmap() addr parameter.
> + - mremap() new_address parameter.
> + - prctl_set_mm() struct prctl_map fields.
> + - prctl_set_mm_map() struct prctl_map fields.
prctl_set_mm() and prctl_set_mm_map() are internal kernel functions, not syscall
names. IIUC, we don't want to allow any address field settable via the PR_SET_MM
prctl() to be tagged. Catalin, is that correct? I think this needs rephrasing.
Kevin
> +
> +Any attempt to use non-zero tagged pointers will lead to undefined behaviour.
> +
> +4. Example of correct usage
> +---------------------------
> +
> +void main(void)
> +{
> + static int tbi_enabled = 0;
> + unsigned long tag = 0;
> +
> + char *ptr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
> + MAP_ANONYMOUS, -1, 0);
> +
> + if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE,
> + 0, 0, 0) == 0)
> + tbi_enabled = 1;
> +
> + if (ptr == (void *)-1) /* MAP_FAILED */
> + return -1;
> +
> + if (tbi_enabled)
> + tag = rand() & 0xff;
> +
> + ptr = (char *)((unsigned long)ptr | (tag << TAG_SHIFT));
> +
> + *ptr = 'a';
> +
> + ...
> +}
> +
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v5 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-18 13:13 ` Kevin Brodsky
@ 2019-06-18 13:13 ` Kevin Brodsky
2019-06-21 15:16 ` Catalin Marinas
1 sibling, 0 replies; 50+ messages in thread
From: Kevin Brodsky @ 2019-06-18 13:13 UTC (permalink / raw)
To: Vincenzo Frascino, linux-arm-kernel, linux-doc, linux-mm,
linux-arch, linux-kselftest, linux-kernel
Cc: Catalin Marinas, Will Deacon, Andrey Konovalov, Alexander Viro
I'm happy with the ABI overall, but I think we need a few more tweaks.
On 13/06/2019 16:51, Vincenzo Frascino wrote:
> On arm64 the TCR_EL1.TBI0 bit has been always enabled hence
> the userspace (EL0) is allowed to set a non-zero value in the
> top byte but the resulting pointers are not allowed at the
> user-kernel syscall ABI boundary.
>
> With the relaxed ABI proposed through this document, it is now possible
> to pass tagged pointers to the syscalls, when these pointers are in
> memory ranges obtained by an anonymous (MAP_ANONYMOUS) mmap().
>
> This change in the ABI requires a mechanism to requires the userspace
> to opt-in to such an option.
>
> Specify and document the way in which sysctl and prctl() can be used
> in combination to allow the userspace to opt-in this feature.
>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> CC: Andrey Konovalov <andreyknvl@google.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
> Documentation/arm64/tagged-address-abi.txt | 134 +++++++++++++++++++++
> 1 file changed, 134 insertions(+)
> create mode 100644 Documentation/arm64/tagged-address-abi.txt
>
> diff --git a/Documentation/arm64/tagged-address-abi.txt b/Documentation/arm64/tagged-address-abi.txt
> new file mode 100644
> index 000000000000..0ae900d4bb2d
> --- /dev/null
> +++ b/Documentation/arm64/tagged-address-abi.txt
> @@ -0,0 +1,134 @@
> +ARM64 TAGGED ADDRESS ABI
> +========================
> +
> +This document describes the usage and semantics of the Tagged Address
> +ABI on arm64.
> +
> +1. Introduction
> +---------------
> +
> +On arm64 the TCR_EL1.TBI0 bit has been always enabled on the kernel, hence
"been always" -> "always been"
> +the userspace (EL0) is entitled to perform a user memory access through a
> +64-bit pointer with a non-zero top byte but the resulting pointers are not
> +allowed at the user-kernel syscall ABI boundary.
> +
> +This document describes a relaxation of the ABI that makes it possible to
> +to pass tagged pointers to the syscalls, when these pointers are in memory
> +ranges obtained as described in section 2.
> +
> +Since it is not desirable to relax the ABI to allow tagged user addresses
> +into the kernel indiscriminately, arm64 provides a new sysctl interface
> +(/proc/sys/abi/tagged_addr) that is used to prevent the applications from
> +enabling the relaxed ABI and a new prctl() interface that can be used to
> +enable or disable the relaxed ABI.
> +A detailed description of the newly introduced mechanisms will be provided
> +in section 2.
> +
> +2. ARM64 Tagged Address ABI
> +---------------------------
> +
> +From the kernel syscall interface perspective, we define, for the purposes
> +of this document, a "valid tagged pointer" as a pointer that either has a
> +zero value set in the top byte or has a non-zero value, it is in memory
> +ranges privately owned by a userspace process and it is obtained in one of
Remove all the remaining "it": "a pointer that either [...], is in memory ranges
[...] and is obtained..."
> +the following ways:
> + - mmap() done by the process itself, where either:
> + * flags have MAP_PRIVATE and MAP_ANONYMOUS
> + * flags have MAP_PRIVATE and the file descriptor refers to a regular
> + file or "/dev/zero"
> + - brk() system call done by the process itself (i.e. the heap area between
> + the initial location of the program break at process creation and its
> + current location).
> + - any memory mapped by the kernel in the process's address space during
> + creation and following the restrictions presented above (i.e. data, bss,
> + stack).
As I commented on v2, the "i.e." is not correct: these 3 sections are not the only
ones that are covered by this ABI (.text also is, for instance). Replacing "i.e."
with "e.g." would work.
Also, since the rules above say explicitly "done by the process itself", it might be
clearer to replace "following the restrictions presented above" with "with the same
restrictions as for mmap()".
> +
> +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
> +control it using the following:
> + - /proc/sys/abi/tagged_addr: a new sysctl interface that can be used to
> + prevent the applications from enabling the relaxed ABI.
> + The sysctl is meant also for testing purposes in order to provide a
> + simple way for the userspace to verify the return error checking of
> + the prctl() commands without having to reconfigure the kernel.
> + The sysctl supports the following configuration options:
> + - 0: Disable ARM64 Tagged Address ABI for all the applications.
> + - 1 (Default): Enable ARM64 Tagged Address ABI for all the
> + applications.
I find this very confusing, because it suggests that the default value of
PR_GET_TAGGED_ADDR_CTRL for new processes will be set to the value of this sysctl,
when in fact this sysctl is about restricting the *availability* of the new ABI.
Instead of disabling the ABI, I would talk about disabling access to the new ABI here.
> + If the ARM64 Tagged Address ABI is disabled at a certain point in
> + time, all the applications that were using tagging before this event
> + occurs, will continue to use tagging.
> +
> + - prctl()s:
> + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable or disable the Tagged
> + Address ABI.
> + The (unsigned int) arg2 argument is a bit mask describing the
> + control mode used:
> + - PR_TAGGED_ADDR_ENABLE: Enable ARM64 Tagged Address ABI.
> + The arguments arg3, arg4, and arg5 are ignored.
Have we definitely decided that arg{3,4,5} are ignored? Catalin?
> +
> + - PR_GET_TAGGED_ADDR_CTRL: can be used to check the status of the Tagged
> + Address ABI.
> + The arguments arg2, arg3, arg4, and arg5 are ignored.
> +
> +The ABI properties set by the mechanisms described above are inherited by threads
> +of the same application and fork()'ed children but cleared by execve().
> +
> +As a consequence of invoking PR_SET_TAGGED_ADDR_CTRL prctl() by an applications,
I think this is too vague, you can use this prctl() to disable the new ABI, and it
can also fail. Maybe it's best to simply say that the process has successfully opted
into the new ABI.
> +the ABI guarantees the following behaviours:
> +
> + - Every current or newly introduced syscall can accept any valid tagged
> + pointers.
"pointer". Also, is it really useful to talk about newly introduced syscall? New from
which point of view?
> +
> + - If a non valid tagged pointer is passed to a syscall then the behaviour
> + is undefined.
> +
> + - Every valid tagged pointer is expected to work as an untagged one.
> +
> + - The kernel preserves any valid tagged pointers and returns them to the
"pointer", "returns it"
> + userspace unchanged (i.e. on syscall return) in all the cases except the
> + ones documented in the "Preserving tags" section of tagged-pointers.txt.
> +
> +A definition of the meaning of tagged pointers on arm64 can be found in:
> +Documentation/arm64/tagged-pointers.txt.
> +
> +3. ARM64 Tagged Address ABI Exceptions
> +--------------------------------------
> +
> +The behaviours described in section 2, with particular reference to the
> +acceptance by the syscalls of any valid tagged pointer are not applicable
> +to the following cases:
> + - mmap() addr parameter.
> + - mremap() new_address parameter.
> + - prctl_set_mm() struct prctl_map fields.
> + - prctl_set_mm_map() struct prctl_map fields.
prctl_set_mm() and prctl_set_mm_map() are internal kernel functions, not syscall
names. IIUC, we don't want to allow any address field settable via the PR_SET_MM
prctl() to be tagged. Catalin, is that correct? I think this needs rephrasing.
Kevin
> +
> +Any attempt to use non-zero tagged pointers will lead to undefined behaviour.
> +
> +4. Example of correct usage
> +---------------------------
> +
> +void main(void)
> +{
> + static int tbi_enabled = 0;
> + unsigned long tag = 0;
> +
> + char *ptr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
> + MAP_ANONYMOUS, -1, 0);
> +
> + if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE,
> + 0, 0, 0) == 0)
> + tbi_enabled = 1;
> +
> + if (ptr == (void *)-1) /* MAP_FAILED */
> + return -1;
> +
> + if (tbi_enabled)
> + tag = rand() & 0xff;
> +
> + ptr = (char *)((unsigned long)ptr | (tag << TAG_SHIFT));
> +
> + *ptr = 'a';
> +
> + ...
> +}
> +
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v5 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-18 13:13 ` Kevin Brodsky
2019-06-18 13:13 ` Kevin Brodsky
@ 2019-06-21 15:16 ` Catalin Marinas
2019-06-21 15:16 ` Catalin Marinas
1 sibling, 1 reply; 50+ messages in thread
From: Catalin Marinas @ 2019-06-21 15:16 UTC (permalink / raw)
To: Kevin Brodsky
Cc: linux-arch, linux-doc, Andrey Konovalov, Will Deacon,
linux-kernel, linux-mm, Alexander Viro, linux-kselftest,
Vincenzo Frascino, linux-arm-kernel
On Tue, Jun 18, 2019 at 02:13:01PM +0100, Kevin Brodsky wrote:
> On 13/06/2019 16:51, Vincenzo Frascino wrote:
> > +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
> > +control it using the following:
> > + - /proc/sys/abi/tagged_addr: a new sysctl interface that can be used to
> > + prevent the applications from enabling the relaxed ABI.
> > + The sysctl is meant also for testing purposes in order to provide a
> > + simple way for the userspace to verify the return error checking of
> > + the prctl() commands without having to reconfigure the kernel.
> > + The sysctl supports the following configuration options:
> > + - 0: Disable ARM64 Tagged Address ABI for all the applications.
> > + - 1 (Default): Enable ARM64 Tagged Address ABI for all the
> > + applications.
>
> I find this very confusing, because it suggests that the default value of
> PR_GET_TAGGED_ADDR_CTRL for new processes will be set to the value of this
> sysctl, when in fact this sysctl is about restricting the *availability* of
> the new ABI. Instead of disabling the ABI, I would talk about disabling
> access to the new ABI here.
This bullet point needs to be re-written. The sysctl is meant to disable
opting in to the ABI. I'd also drop the "meant for testing" part. I put
it in my commit log as justification but I don't think it should be part
of the ABI document.
> > + - prctl()s:
> > + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable or disable the Tagged
> > + Address ABI.
> > + The (unsigned int) arg2 argument is a bit mask describing the
> > + control mode used:
> > + - PR_TAGGED_ADDR_ENABLE: Enable ARM64 Tagged Address ABI.
> > + The arguments arg3, arg4, and arg5 are ignored.
>
> Have we definitely decided that arg{3,4,5} are ignored? Catalin?
I don't have a strong preference either way. If it's simpler for the
user to ignore them, fine by me. I can see in the current prctl commands
a mix if ignore vs forced zero.
> > +the ABI guarantees the following behaviours:
> > +
> > + - Every current or newly introduced syscall can accept any valid tagged
> > + pointers.
> "pointer". Also, is it really useful to talk about newly introduced syscall?
> New from which point of view?
I think we should drop this guarantee. It would have made sense if we
allowed tagged pointers everywhere but we already have some exceptions.
> > +3. ARM64 Tagged Address ABI Exceptions
> > +--------------------------------------
> > +
> > +The behaviours described in section 2, with particular reference to the
> > +acceptance by the syscalls of any valid tagged pointer are not applicable
> > +to the following cases:
> > + - mmap() addr parameter.
> > + - mremap() new_address parameter.
> > + - prctl_set_mm() struct prctl_map fields.
> > + - prctl_set_mm_map() struct prctl_map fields.
>
> prctl_set_mm() and prctl_set_mm_map() are internal kernel functions, not
> syscall names. IIUC, we don't want to allow any address field settable via
> the PR_SET_MM prctl() to be tagged. Catalin, is that correct? I think this
> needs rephrasing.
I fully agree. It should talk about PR_SET_MM, PR_SET_MM_MAP,
PR_SET_MM_MAP_SIZE.
--
Catalin
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v5 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt
2019-06-21 15:16 ` Catalin Marinas
@ 2019-06-21 15:16 ` Catalin Marinas
0 siblings, 0 replies; 50+ messages in thread
From: Catalin Marinas @ 2019-06-21 15:16 UTC (permalink / raw)
To: Kevin Brodsky
Cc: Vincenzo Frascino, linux-arm-kernel, linux-doc, linux-mm,
linux-arch, linux-kselftest, linux-kernel, Will Deacon,
Andrey Konovalov, Alexander Viro
On Tue, Jun 18, 2019 at 02:13:01PM +0100, Kevin Brodsky wrote:
> On 13/06/2019 16:51, Vincenzo Frascino wrote:
> > +The ARM64 Tagged Address ABI is an opt-in feature, and an application can
> > +control it using the following:
> > + - /proc/sys/abi/tagged_addr: a new sysctl interface that can be used to
> > + prevent the applications from enabling the relaxed ABI.
> > + The sysctl is meant also for testing purposes in order to provide a
> > + simple way for the userspace to verify the return error checking of
> > + the prctl() commands without having to reconfigure the kernel.
> > + The sysctl supports the following configuration options:
> > + - 0: Disable ARM64 Tagged Address ABI for all the applications.
> > + - 1 (Default): Enable ARM64 Tagged Address ABI for all the
> > + applications.
>
> I find this very confusing, because it suggests that the default value of
> PR_GET_TAGGED_ADDR_CTRL for new processes will be set to the value of this
> sysctl, when in fact this sysctl is about restricting the *availability* of
> the new ABI. Instead of disabling the ABI, I would talk about disabling
> access to the new ABI here.
This bullet point needs to be re-written. The sysctl is meant to disable
opting in to the ABI. I'd also drop the "meant for testing" part. I put
it in my commit log as justification but I don't think it should be part
of the ABI document.
> > + - prctl()s:
> > + - PR_SET_TAGGED_ADDR_CTRL: can be used to enable or disable the Tagged
> > + Address ABI.
> > + The (unsigned int) arg2 argument is a bit mask describing the
> > + control mode used:
> > + - PR_TAGGED_ADDR_ENABLE: Enable ARM64 Tagged Address ABI.
> > + The arguments arg3, arg4, and arg5 are ignored.
>
> Have we definitely decided that arg{3,4,5} are ignored? Catalin?
I don't have a strong preference either way. If it's simpler for the
user to ignore them, fine by me. I can see in the current prctl commands
a mix if ignore vs forced zero.
> > +the ABI guarantees the following behaviours:
> > +
> > + - Every current or newly introduced syscall can accept any valid tagged
> > + pointers.
> "pointer". Also, is it really useful to talk about newly introduced syscall?
> New from which point of view?
I think we should drop this guarantee. It would have made sense if we
allowed tagged pointers everywhere but we already have some exceptions.
> > +3. ARM64 Tagged Address ABI Exceptions
> > +--------------------------------------
> > +
> > +The behaviours described in section 2, with particular reference to the
> > +acceptance by the syscalls of any valid tagged pointer are not applicable
> > +to the following cases:
> > + - mmap() addr parameter.
> > + - mremap() new_address parameter.
> > + - prctl_set_mm() struct prctl_map fields.
> > + - prctl_set_mm_map() struct prctl_map fields.
>
> prctl_set_mm() and prctl_set_mm_map() are internal kernel functions, not
> syscall names. IIUC, we don't want to allow any address field settable via
> the PR_SET_MM prctl() to be tagged. Catalin, is that correct? I think this
> needs rephrasing.
I fully agree. It should talk about PR_SET_MM, PR_SET_MM_MAP,
PR_SET_MM_MAP_SIZE.
--
Catalin
^ permalink raw reply [flat|nested] 50+ messages in thread
end of thread, other threads:[~2019-06-21 15:16 UTC | newest]
Thread overview: 50+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1560339705.git.andreyknvl@google.com>
2019-06-12 14:21 ` [PATCH v4 0/2] arm64 relaxed ABI Vincenzo Frascino
2019-06-12 14:21 ` Vincenzo Frascino
2019-06-12 14:21 ` [PATCH v4 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt Vincenzo Frascino
2019-06-12 14:21 ` Vincenzo Frascino
2019-06-12 15:35 ` Catalin Marinas
2019-06-12 15:35 ` Catalin Marinas
2019-06-13 10:15 ` Vincenzo Frascino
2019-06-13 10:15 ` Vincenzo Frascino
2019-06-13 11:37 ` Dave Martin
2019-06-13 11:37 ` Dave Martin
2019-06-13 12:28 ` Catalin Marinas
2019-06-13 12:28 ` Catalin Marinas
2019-06-13 13:23 ` Dave Martin
2019-06-13 13:23 ` Dave Martin
2019-06-13 15:39 ` Catalin Marinas
2019-06-13 15:39 ` Catalin Marinas
2019-06-12 16:30 ` Szabolcs Nagy
2019-06-12 16:30 ` Szabolcs Nagy
2019-06-13 9:20 ` Catalin Marinas
2019-06-13 9:20 ` Catalin Marinas
2019-06-13 10:14 ` Szabolcs Nagy
2019-06-13 10:14 ` Szabolcs Nagy
2019-06-13 11:16 ` Vincenzo Frascino
2019-06-13 11:16 ` Vincenzo Frascino
2019-06-13 12:28 ` Szabolcs Nagy
2019-06-13 12:28 ` Szabolcs Nagy
2019-06-13 14:03 ` Vincenzo Frascino
2019-06-13 14:03 ` Vincenzo Frascino
2019-06-13 15:32 ` Szabolcs Nagy
2019-06-13 15:32 ` Szabolcs Nagy
2019-06-13 15:35 ` Vincenzo Frascino
2019-06-13 15:35 ` Vincenzo Frascino
2019-06-12 14:21 ` [PATCH v4 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt Vincenzo Frascino
2019-06-12 14:21 ` Vincenzo Frascino
2019-06-12 15:56 ` Catalin Marinas
2019-06-12 15:56 ` Catalin Marinas
2019-06-12 16:37 ` Szabolcs Nagy
2019-06-12 16:37 ` Szabolcs Nagy
2019-06-13 15:51 ` [PATCH v5 0/2] arm64 relaxed ABI Vincenzo Frascino
2019-06-13 15:51 ` Vincenzo Frascino
2019-06-13 15:51 ` [PATCH v5 1/2] arm64: Define Documentation/arm64/tagged-address-abi.txt Vincenzo Frascino
2019-06-13 15:51 ` Vincenzo Frascino
2019-06-18 11:02 ` Szabolcs Nagy
2019-06-18 11:02 ` Szabolcs Nagy
2019-06-18 13:13 ` Kevin Brodsky
2019-06-18 13:13 ` Kevin Brodsky
2019-06-21 15:16 ` Catalin Marinas
2019-06-21 15:16 ` Catalin Marinas
2019-06-13 15:51 ` [PATCH v5 2/2] arm64: Relax Documentation/arm64/tagged-pointers.txt Vincenzo Frascino
2019-06-13 15:51 ` Vincenzo Frascino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox