Skip to contentSkip to conversation

arm64: untag user pointers passed to the kernel

PATCH Superseded Andrey Konovalov 2 participants 18 messages Nov 8, 2018 – Dec 6, 2018

Subsystems (8)

v8 of 19 Superseded Latest is v19 →

lore
Share & tools
lore
#0 lore raw

v8 cover arm64: untag user pointers passed to the kernel

arm64 has a feature called Top Byte Ignore, which allows to embed pointer tags into the top byte of each pointer. Userspace programs (such as HWASan, a memory debugging tool [1]) might use this feature and pass tagged user pointers to the kernel through syscalls or other interfaces.

Right now the kernel is already able to handle user faults with tagged pointers, due to these patches:

1. 81cddd65 ("arm64: traps: fix userspace cache maintenance emulation on a tagged pointer")
2. 7dcd9dd8 ("arm64: hw_breakpoint: fix watchpoint matching for tagged pointers")
3. 276e9327 ("arm64: entry: improve data abort handling of tagged pointers")

When passing tagged pointers to syscalls, there's a special case of such a pointer being passed to one of the memory syscalls (mmap, mprotect, etc.). These syscalls don't do memory accesses but rather deal with memory ranges, hence an untagged pointer is better suited.

This patchset extends tagged pointer support to non-memory syscalls. This is done by reusing the untagged_addr macro to untag user pointers when the kernel performs pointer checking to find out whether the pointer comes from userspace (most notably in access_ok). The untagging is done only when the pointer is being checked, the tag is preserved as the pointer makes its way through the kernel.

One of the alternative approaches to untagging that was considered is to completely strip the pointer tag as the pointer enters the kernel with some kind of a syscall wrapper, but that won't work with the countless number of different ioctl calls. With this approach we would need a custom wrapper for each ioctl variation, which doesn't seem practical.

The following testing approaches has been taken to find potential issues with user pointer untagging:

1. Static testing (with sparse [2] and separately with a custom static analyzer based on Clang) to track casts of __user pointers to integer types to find places where untagging needs to be done.

2. Dynamic testing: adding BUG_ON(has_tag(addr)) to find_vma() and running a modified syzkaller version that passes tagged pointers to the kernel.

Based on the results of the testing the requried patches have been added to the patchset.

This patchset has been merged into the Pixel 2 kernel tree and is now being used to enable testing of Pixel 2 phones with HWASan.

This patchset is a prerequisite for ARM's memory tagging hardware feature support [3].

Thanks!

[1] http://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html

[2] https://github.com/lucvoo/sparse-dev/commit/5f960cb10f56ec2017c128ef9d16060e0145f292

[3] https://community.arm.com/processors/b/blog/posts/arm-a-profile-architecture-2018-developments-armv85a

Changes in v8:
- Rebased onto 65102238 (4.20-rc1).
- Added a note to the cover letter on why syscall wrappers/shims that untag user pointers won't work.
- Added a note to the cover letter that this patchset has been merged into the Pixel 2 kernel tree.
- Documentation fixes, in particular added a list of syscalls that don't support tagged user pointers.

Changes in v7:
- Rebased onto 17b57b18 (4.19-rc6).
- Dropped the "arm64: untag user address in __do_user_fault" patch, since the existing patches already handle user faults properly.
- Dropped the "usb, arm64: untag user addresses in devio" patch, since the passed pointer must come from a vma and therefore be untagged.
- Dropped the "arm64: annotate user pointers casts detected by sparse" patch (see the discussion to the replies of the v6 of this patchset).
- Added more context to the cover letter.
- Updated Documentation/arm64/tagged-pointers.txt.

Changes in v6:
- Added annotations for user pointer casts found by sparse.
- Rebased onto 050cdc6c (4.19-rc1+).

Changes in v5:
- Added 3 new patches that add untagging to places found with static analysis.
- Rebased onto 44c929e1 (4.18-rc8).

Changes in v4:
- Added a selftest for checking that passing tagged pointers to the kernel succeeds.
- Rebased onto 81e97f013 (4.18-rc1+).

Changes in v3:
- Rebased onto e5c51f30 (4.17-rc6+).
- Added linux-arch@ to the list of recipients.

Changes in v2:
- Rebased onto 2d618bdf (4.17-rc3+).
- Removed excessive untagging in gup.c.
- Removed untagging pointers returned from __uaccess_mask_ptr.

Changes in v1:
- Rebased onto 4.17-rc1.

Changes in RFC v2:
- Added "#ifndef untagged_addr..." fallback in linux/uaccess.h instead of defining it for each arch individually.
- Updated Documentation/arm64/tagged-pointers.txt.
- Dropped "mm, arm64: untag user addresses in memory syscalls".
- Rebased onto 3eb2ce82 (4.16-rc7).

Andrey Konovalov (8):
arm64: add type casts to untagged_addr macro
uaccess: add untagged_addr definition for other arches
arm64: untag user addresses in access_ok and __uaccess_mask_ptr mm, arm64: untag user addresses in mm/gup.c
lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user fs, arm64: untag user address in copy_mount_options
arm64: update Documentation/arm64/tagged-pointers.txt selftests, arm64: add a selftest for passing tagged pointers to kernel

 Documentation/arm64/tagged-pointers.txt       | 25 +++++++++++--------
 arch/arm64/include/asm/uaccess.h              | 14 +++++++----
 fs/namespace.c                                |  2 +-
 include/linux/uaccess.h                       |  4 +++
 lib/strncpy_from_user.c                       |  2 ++
 lib/strnlen_user.c                            |  2 ++
 mm/gup.c                                      |  4 +++
 tools/testing/selftests/arm64/.gitignore      |  1 +
 tools/testing/selftests/arm64/Makefile        | 11 ++++++++
 .../testing/selftests/arm64/run_tags_test.sh  | 12 +++++++++
 tools/testing/selftests/arm64/tags_test.c     | 19 ++++++++++++++
 11 files changed, 80 insertions(+), 16 deletions(-)
 create mode 100644 tools/testing/selftests/arm64/.gitignore
 create mode 100644 tools/testing/selftests/arm64/Makefile
 create mode 100755 tools/testing/selftests/arm64/run_tags_test.sh
 create mode 100644 tools/testing/selftests/arm64/tags_test.c
Signature · 1 line
2.19.1.930.g4563a0d9d0-goog
#1 lore raw

PATCH v8 1/8 arm64: add type casts to untagged_addr macro

This patch makes the untagged_addr macro accept all kinds of address types (void *, unsigned long, etc.) and allows not to specify type casts in each place where it is used. This is done by using __typeof__.

---
 arch/arm64/include/asm/uaccess.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/include/asm/uaccess.h +2 -1
index 07c34087bd5e..c1325271e368 100644
@@ -101,7 +101,8 @@ static inline unsigned long __range_ok(const void __user *addr, unsigned long si
  * up with a tagged userland pointer. Clear the tag to get a sane pointer to
  * pass on to access_ok(), for instance.
  */
-#define untagged_addr(addr)		sign_extend64(addr, 55)
+#define untagged_addr(addr)		\
+	((__typeof__(addr))sign_extend64((__u64)(addr), 55))
 
 #define access_ok(type, addr, size)	__range_ok(addr, size)
 #define user_addr_max			get_fs
Signature · 1 line
2.19.1.930.g4563a0d9d0-goog
maintainer Acked-by on v8 1/8
#2 lore raw

Re: [PATCH v8 1/8] arm64: add type casts to untagged_addr macro

Quoted 14 lines · Andrey Konovalov

This patch makes the untagged_addr macro accept all kinds of address types (void *, unsigned long, etc.) and allows not to specify type casts in each place where it is used. This is done by using __typeof__.

---
 arch/arm64/include/asm/uaccess.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/include/asm/uaccess.h +0 -0
index 07c34087bd5e..c1325271e368 100644

arch/arm64/include/asm/uaccess.h static inline unsigned long __range_ok(const void __user *addr, unsigned long si · line 105

Quoted 6 lines
arch/arm64/include/asm/uaccess.h +2 -1
@@ -101,7 +101,8 @@ static inline unsigned long __range_ok(const void __user *addr, unsigned long si
  * up with a tagged userland pointer. Clear the tag to get a sane pointer to
  * pass on to access_ok(), for instance.
  */
-#define untagged_addr(addr)		sign_extend64(addr, 55)
+#define untagged_addr(addr)		\
+	((__typeof__(addr))sign_extend64((__u64)(addr), 55))

Nitpick: same comment as here (use u64):

http://lkml.kernel.org/r/[email protected]

(not acking the whole series just yet, only specific patches to remember what I reviewed)

#3 lore raw

Re: [PATCH v8 1/8] arm64: add type casts to untagged_addr macro

Quoted 25 lines · Catalin Marinas
Quoted 14 lines · Andrey Konovalov

This patch makes the untagged_addr macro accept all kinds of address types (void *, unsigned long, etc.) and allows not to specify type casts in each place where it is used. This is done by using __typeof__.

---
 arch/arm64/include/asm/uaccess.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/include/asm/uaccess.h +0 -0
index 07c34087bd5e..c1325271e368 100644

arch/arm64/include/asm/uaccess.h static inline unsigned long __range_ok(const void __user *addr, unsigned long si · line 105

Quoted 6 lines
arch/arm64/include/asm/uaccess.h +2 -1
@@ -101,7 +101,8 @@ static inline unsigned long __range_ok(const void __user *addr, unsigned long si
  * up with a tagged userland pointer. Clear the tag to get a sane pointer to
  * pass on to access_ok(), for instance.
  */
-#define untagged_addr(addr)          sign_extend64(addr, 55)
+#define untagged_addr(addr)          \
+     ((__typeof__(addr))sign_extend64((__u64)(addr), 55))

Nitpick: same comment as here (use u64):

Quoted 1 line

http://lkml.kernel.org/r/[email protected]

Will do in v9.

Quoted 5 lines

(not acking the whole series just yet, only specific patches to remember what I reviewed)

OK.

Thanks!

#4 lore raw

PATCH v8 2/8 uaccess: add untagged_addr definition for other arches

In reply to Andrey Konovalov

To allow arm64 syscalls accept tagged pointers from userspace, we must untag them when they are passed to the kernel. Since untagging is done in generic parts of the kernel, the untagged_addr macro needs to be defined for all architectures.

Define it as a noop for other architectures besides arm64.

---
 include/linux/uaccess.h | 4 ++++
 1 file changed, 4 insertions(+)
include/linux/uaccess.h +4 -0
index efe79c1cdd47..c045b4eff95e 100644
@@ -13,6 +13,10 @@
 
 #include <asm/uaccess.h>
 
+#ifndef untagged_addr
+#define untagged_addr(addr) addr
+#endif
+
 /*
  * Architectures should provide two primitives (raw_copy_{to,from}_user())
  * and get rid of their private instances of copy_{to,from}_user() and
Signature · 1 line
2.19.1.930.g4563a0d9d0-goog
maintainer Acked-by on v8 2/8
#5 lore raw

Re: [PATCH v8 2/8] uaccess: add untagged_addr definition for other arches

include/linux/uaccess.h line 18

Quoted 11 lines · Andrey Konovalov
include/linux/uaccess.h +3 -0
index efe79c1cdd47..c045b4eff95e 100644
@@ -13,6 +13,10 @@
 
 #include <asm/uaccess.h>
 
+#ifndef untagged_addr
+#define untagged_addr(addr) addr
+#endif

Nitpick: add braces around (addr). Otherwise:

#6 lore raw

Re: [PATCH v8 2/8] uaccess: add untagged_addr definition for other arches

Quoted 8 lines · Catalin Marinas
Quoted 6 lines · Andrey Konovalov
include/linux/uaccess.h +0 -0
index efe79c1cdd47..c045b4eff95e 100644
@@ -13,6 +13,10 @@
 
Quoted 7 lines

include/linux/uaccess.h line 18

Quoted 5 lines
include/linux/uaccess.h +3 -0
 #include <asm/uaccess.h>
 
+#ifndef untagged_addr
+#define untagged_addr(addr) addr
+#endif

Nitpick: add braces around (addr). Otherwise:

Will do in v9, thanks!

Quoted 2 lines
#7 lore raw

PATCH v8 3/8 arm64: untag user addresses in access_ok and __uaccess_mask_ptr

In reply to Andrey Konovalov

copy_from_user (and a few other similar functions) are used to copy data from user memory into the kernel memory or vice versa. Since a user can provided a tagged pointer to one of the syscalls that use copy_from_user, we need to correctly handle such pointers.

Do this by untagging user pointers in access_ok and in __uaccess_mask_ptr, before performing access validity checks.

---
 arch/arm64/include/asm/uaccess.h | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
arch/arm64/include/asm/uaccess.h +7 -4
index c1325271e368..abc35cba134b 100644
@@ -104,7 +104,8 @@ static inline unsigned long __range_ok(const void __user *addr, unsigned long si
 #define untagged_addr(addr)		\
 	((__typeof__(addr))sign_extend64((__u64)(addr), 55))
 
-#define access_ok(type, addr, size)	__range_ok(addr, size)
+#define access_ok(type, addr, size)	\
+	__range_ok(untagged_addr(addr), size)
 #define user_addr_max			get_fs
 
 #define _ASM_EXTABLE(from, to)						\
@@ -236,7 +237,8 @@ static inline void uaccess_enable_not_uao(void)
 
 /*
  * Sanitise a uaccess pointer such that it becomes NULL if above the
- * current addr_limit.
+ * current addr_limit. In case the pointer is tagged (has the top byte set),
+ * untag the pointer before checking.
  */
 #define uaccess_mask_ptr(ptr) (__typeof__(ptr))__uaccess_mask_ptr(ptr)
 static inline void __user *__uaccess_mask_ptr(const void __user *ptr)
@@ -244,10 +246,11 @@ static inline void __user *__uaccess_mask_ptr(const void __user *ptr)
 	void __user *safe_ptr;
 
 	asm volatile(
-	"	bics	xzr, %1, %2\n"
+	"	bics	xzr, %3, %2\n"
 	"	csel	%0, %1, xzr, eq\n"
 	: "=&r" (safe_ptr)
-	: "r" (ptr), "r" (current_thread_info()->addr_limit)
+	: "r" (ptr), "r" (current_thread_info()->addr_limit),
+	  "r" (untagged_addr(ptr))
 	: "cc");
 
 	csdb();
Signature · 1 line
2.19.1.930.g4563a0d9d0-goog
maintainer Reviewed-by on v8 3/8
#8 lore raw

Re: [PATCH v8 3/8] arm64: untag user addresses in access_ok and __uaccess_mask_ptr

Quoted 9 lines · Andrey Konovalov

copy_from_user (and a few other similar functions) are used to copy data from user memory into the kernel memory or vice versa. Since a user can provided a tagged pointer to one of the syscalls that use copy_from_user, we need to correctly handle such pointers.

Do this by untagging user pointers in access_ok and in __uaccess_mask_ptr, before performing access validity checks.

#9 lore raw

PATCH v8 4/8 mm, arm64: untag user addresses in mm/gup.c

In reply to Andrey Konovalov

mm/gup.c provides a kernel interface that accepts user addresses and manipulates user pages directly (for example get_user_pages, that is used by the futex syscall). Since a user can provided tagged addresses, we need to handle such case.

Add untagging to gup.c functions that use user addresses for vma lookup.

---
 mm/gup.c | 4 ++++
 1 file changed, 4 insertions(+)
mm/gup.c +4 -0
index f76e77a2d34b..6ff310818616 100644
@@ -677,6 +677,8 @@ static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
 	if (!nr_pages)
 		return 0;
 
+	start = untagged_addr(start);
+
 	VM_BUG_ON(!!pages != !!(gup_flags & FOLL_GET));
 
 	/*
@@ -840,6 +842,8 @@ int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm,
 	struct vm_area_struct *vma;
 	vm_fault_t ret, major = 0;
 
+	address = untagged_addr(address);
+
 	if (unlocked)
 		fault_flags |= FAULT_FLAG_ALLOW_RETRY;
 
Signature · 1 line
2.19.1.930.g4563a0d9d0-goog
#10 lore raw

PATCH v8 5/8 lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user

In reply to Andrey Konovalov

strncpy_from_user and strnlen_user accept user addresses as arguments, and do not go through the same path as copy_from_user and others, so here we need to handle the case of tagged user addresses separately.

Untag user pointers passed to these functions.

---
 lib/strncpy_from_user.c | 2 ++
 lib/strnlen_user.c      | 2 ++
 2 files changed, 4 insertions(+)
lib/strncpy_from_user.c +2 -0
index b53e1b5d80f4..97467cd2bc59 100644
@@ -106,6 +106,8 @@ long strncpy_from_user(char *dst, const char __user *src, long count)
 	if (unlikely(count <= 0))
 		return 0;
 
+	src = untagged_addr(src);
+
 	max_addr = user_addr_max();
 	src_addr = (unsigned long)src;
 	if (likely(src_addr < max_addr)) {
lib/strnlen_user.c +2 -0
index 60d0bbda8f5e..8b5f56466e00 100644
@@ -108,6 +108,8 @@ long strnlen_user(const char __user *str, long count)
 	if (unlikely(count <= 0))
 		return 0;
 
+	str = untagged_addr(str);
+
 	max_addr = user_addr_max();
 	src_addr = (unsigned long)str;
 	if (likely(src_addr < max_addr)) {
Signature · 1 line
2.19.1.930.g4563a0d9d0-goog
#11 lore raw

PATCH v8 6/8 fs, arm64: untag user address in copy_mount_options

In reply to Andrey Konovalov

In copy_mount_options a user address is being subtracted from TASK_SIZE. If the address is lower than TASK_SIZE, the size is calculated to not allow the exact_copy_from_user() call to cross TASK_SIZE boundary. However if the address is tagged, then the size will be calculated incorrectly.

Untag the address before subtracting.

---
 fs/namespace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/namespace.c +1 -1
index 98d27da43304..1f1f998d15ed 100644
@@ -2674,7 +2674,7 @@ void *copy_mount_options(const void __user * data)
 	 * the remainder of the page.
 	 */
 	/* copy_from_user cannot cross TASK_SIZE ! */
-	size = TASK_SIZE - (unsigned long)data;
+	size = TASK_SIZE - (unsigned long)untagged_addr(data);
 	if (size > PAGE_SIZE)
 		size = PAGE_SIZE;
 
Signature · 1 line
2.19.1.930.g4563a0d9d0-goog
#12 lore raw

PATCH v8 7/8 arm64: update Documentation/arm64/tagged-pointers.txt

In reply to Andrey Konovalov

Document the changes in Documentation/arm64/tagged-pointers.txt.

---
 Documentation/arm64/tagged-pointers.txt | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)
Documentation/arm64/tagged-pointers.txt +15 -10
index a25a99e82bb1..f4cf1f5cf362 100644
@@ -17,13 +17,22 @@ this byte for application use.
 Passing tagged addresses to the kernel
 --------------------------------------
 
-All interpretation of userspace memory addresses by the kernel assumes
-an address tag of 0x00.
+The kernel supports tags in pointer arguments (including pointers in
+structures) for a limited set of syscalls, the exceptions are:
 
-This includes, but is not limited to, addresses found in:
+ - memory syscalls: brk, madvise, mbind, mincore, mlock, mlock2, move_pages,
+   mprotect, mremap, msync, munlock, munmap, pkey_mprotect, process_vm_readv,
+   process_vm_writev, remap_file_pages;
 
- - pointer arguments to system calls, including pointers in structures
-   passed to system calls,
+ - ioctls that accept user pointers that describe virtual memory ranges;
+
+ - TCP_ZEROCOPY_RECEIVE setsockopt.
+
+The kernel supports tags in user fault addresses. However the fault_address
+field in the sigcontext struct will contain an untagged address.
+
+All other interpretations of userspace memory addresses by the kernel
+assume an address tag of 0x00, in particular:
 
  - the stack pointer (sp), e.g. when interpreting it to deliver a
    signal,
@@ -33,11 +42,7 @@ This includes, but is not limited to, addresses found in:
 
 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.
-
-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.
+of failure. 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
Signature · 1 line
2.19.1.930.g4563a0d9d0-goog
#13 lore raw

PATCH v8 8/8 selftests, arm64: add a selftest for passing tagged pointers to kernel

In reply to Andrey Konovalov

This patch adds a simple test, that calls the uname syscall with a tagged user pointer as an argument. Without the kernel accepting tagged user pointers the test fails with EFAULT.

---
 tools/testing/selftests/arm64/.gitignore      |  1 +
 tools/testing/selftests/arm64/Makefile        | 11 +++++++++++
 .../testing/selftests/arm64/run_tags_test.sh  | 12 ++++++++++++
 tools/testing/selftests/arm64/tags_test.c     | 19 +++++++++++++++++++
 4 files changed, 43 insertions(+)
 create mode 100644 tools/testing/selftests/arm64/.gitignore
 create mode 100644 tools/testing/selftests/arm64/Makefile
 create mode 100755 tools/testing/selftests/arm64/run_tags_test.sh
 create mode 100644 tools/testing/selftests/arm64/tags_test.c
tools/testing/selftests/arm64/.gitignore new file +1 -0
new file mode 100644
index 000000000000..e8fae8d61ed6
@@ -0,0 +1 @@
+tags_test
tools/testing/selftests/arm64/Makefile new file +11 -0
new file mode 100644
index 000000000000..a61b2e743e99
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0
+
+# ARCH can be overridden by the user for cross compiling
+ARCH ?= $(shell uname -m 2>/dev/null || echo not)
+
+ifneq (,$(filter $(ARCH),aarch64 arm64))
+TEST_GEN_PROGS := tags_test
+TEST_PROGS := run_tags_test.sh
+endif
+
+include ../lib.mk
tools/testing/selftests/arm64/run_tags_test.sh new file +12 -0
new file mode 100755
index 000000000000..745f11379930
@@ -0,0 +1,12 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+
+echo "--------------------"
+echo "running tags test"
+echo "--------------------"
+./tags_test
+if [ $? -ne 0 ]; then
+	echo "[FAIL]"
+else
+	echo "[PASS]"
+fi
tools/testing/selftests/arm64/tags_test.c new file +19 -0
new file mode 100644
index 000000000000..1452ed7d33f9
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <sys/utsname.h>
+
+#define SHIFT_TAG(tag)		((uint64_t)(tag) << 56)
+#define SET_TAG(ptr, tag)	(((uint64_t)(ptr) & ~SHIFT_TAG(0xff)) | \
+					SHIFT_TAG(tag))
+
+int main(void)
+{
+	struct utsname utsname;
+	void *ptr = &utsname;
+	void *tagged_ptr = (void *)SET_TAG(ptr, 0x42);
+	int err = uname(tagged_ptr);
+	return err;
+}
Signature · 1 line
2.19.1.930.g4563a0d9d0-goog
#14 lore raw
In reply to Andrey Konovalov

On Thu, Nov 8, 2018 at 3:36 PM, Andrey Konovalov <[email protected]> wrote:

[...]

Quoted 8 lines

Changes in v8:
- Rebased onto 65102238 (4.20-rc1).
- Added a note to the cover letter on why syscall wrappers/shims that untag user pointers won't work.
- Added a note to the cover letter that this patchset has been merged into the Pixel 2 kernel tree.
- Documentation fixes, in particular added a list of syscalls that don't support tagged user pointers.

Hi Catalin,

I've changed the documentation to be more specific, please take a look.

I haven't done anything about adding a way for the user to find out that the kernel supports this ABI extension. I don't know what would the the preferred way to do this, and we haven't received any comments on that from anybody else. Probing "on some innocuous syscall currently returning -EFAULT on tagged pointer arguments" works though, as you mentioned.

As mentioned in the cover letter, this patchset has been merged into the Pixel 2 kernel tree.

Thanks!

maintainer
#15 lore raw

Hi Andrey,

Quoted 10 lines · Andrey Konovalov
Quoted 8 lines · Andrey Konovalov

Changes in v8:
- Rebased onto 65102238 (4.20-rc1).
- Added a note to the cover letter on why syscall wrappers/shims that untag user pointers won't work.
- Added a note to the cover letter that this patchset has been merged into the Pixel 2 kernel tree.
- Documentation fixes, in particular added a list of syscalls that don't support tagged user pointers.

Quoted 8 lines

I've changed the documentation to be more specific, please take a look.

I haven't done anything about adding a way for the user to find out that the kernel supports this ABI extension. I don't know what would the the preferred way to do this, and we haven't received any comments on that from anybody else. Probing "on some innocuous syscall currently returning -EFAULT on tagged pointer arguments" works though, as you mentioned.

We've had some internal discussions and also talked to some people at Plumbers. I think the best option is to introduce an AT_FLAGS bit to describe the ABI relaxation on tagged pointers. Vincenzo is going to propose a patch on top of this series.

Quoted 2 lines

As mentioned in the cover letter, this patchset has been merged into the Pixel 2 kernel tree.

I just hope it's not enabled on production kernels, it would introduce a user ABI that may differ from what ends up upstream.

Signature · 1 line
Catalin
#16 lore raw
Quoted 23 lines · Catalin Marinas

Hi Andrey,

Quoted 10 lines · Andrey Konovalov
Quoted 8 lines · Andrey Konovalov

Changes in v8:
- Rebased onto 65102238 (4.20-rc1).
- Added a note to the cover letter on why syscall wrappers/shims that untag user pointers won't work.
- Added a note to the cover letter that this patchset has been merged into the Pixel 2 kernel tree.
- Documentation fixes, in particular added a list of syscalls that don't support tagged user pointers.

Quoted 8 lines

I've changed the documentation to be more specific, please take a look.

I haven't done anything about adding a way for the user to find out that the kernel supports this ABI extension. I don't know what would the the preferred way to do this, and we haven't received any comments on that from anybody else. Probing "on some innocuous syscall currently returning -EFAULT on tagged pointer arguments" works though, as you mentioned.

Quoted 4 lines

We've had some internal discussions and also talked to some people at Plumbers. I think the best option is to introduce an AT_FLAGS bit to describe the ABI relaxation on tagged pointers. Vincenzo is going to propose a patch on top of this series.

So should I wait for a patch from Vincenzo before posting v9 or post it as is? Or try to develop this patch myself?

Quoted 9 lines
Quoted 3 lines

As mentioned in the cover letter, this patchset has been merged into the Pixel 2 kernel tree.

I just hope it's not enabled on production kernels, it would introduce a user ABI that may differ from what ends up upstream.

--
Catalin

maintainer
#17 lore raw
Quoted 21 lines · Andrey Konovalov
Quoted 20 lines · Catalin Marinas
Quoted 18 lines · Andrey Konovalov
Quoted 8 lines · Andrey Konovalov

Changes in v8:
- Rebased onto 65102238 (4.20-rc1).
- Added a note to the cover letter on why syscall wrappers/shims that untag user pointers won't work.
- Added a note to the cover letter that this patchset has been merged into the Pixel 2 kernel tree.
- Documentation fixes, in particular added a list of syscalls that don't support tagged user pointers.

I've changed the documentation to be more specific, please take a look.

I haven't done anything about adding a way for the user to find out that the kernel supports this ABI extension. I don't know what would the the preferred way to do this, and we haven't received any comments on that from anybody else. Probing "on some innocuous syscall currently returning -EFAULT on tagged pointer arguments" works though, as you mentioned.

Quoted 7 lines
Quoted 4 lines

We've had some internal discussions and also talked to some people at Plumbers. I think the best option is to introduce an AT_FLAGS bit to describe the ABI relaxation on tagged pointers. Vincenzo is going to propose a patch on top of this series.

So should I wait for a patch from Vincenzo before posting v9 or post it as is? Or try to develop this patch myself?

The reason Vincenzo hasn't posted his patches yet is that we are still debating internally how to document which syscalls accept non-zero top-byte, what to do with future syscalls for which we don't know the semantics.

Happy to take the discussion to the public list if Vincenzo posts his patches. The conclusion of the ABI discussion may have an impact on the actual implementation that you are proposing in this series.

Signature · 1 line
Catalin