public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: mark.rutland@arm.com, catalin.marinas@arm.com,
	robin.murphy@arm.com, james.morse@arm.com, will@kernel.org,
	hch@lst.de
Subject: [PATCHv3 09/17] arm64: uaccess: rename privileged uaccess routines
Date: Mon, 26 Oct 2020 13:31:48 +0000	[thread overview]
Message-ID: <20201026133156.44186-10-mark.rutland@arm.com> (raw)
In-Reply-To: <20201026133156.44186-1-mark.rutland@arm.com>

We currently have many uaccess_*{enable,disable}*() variants, which
subsequent patches will cut down as part of removing set_fs() and
friends. Once this simplification is made, most uaccess routines will
only need to ensure that the user page tables are mapped in TTBR0, as is
currently dealt with by uaccess_ttbr0_{enable,disable}().

The existing uaccess_{enable,disable}() routines ensure that user page
tables are mapped in TTBR0, and also disable PAN protections, which is
necessary to be able to use atomics on user memory, but also permit
unrelated privileged accesses to access user memory.

As preparatory step, let's rename uaccess_{enable,disable}() to
uaccess_{enable,disable}_privileged(), highlighting this caveat and
discouraging wider misuse. Subsequent patches can reuse the
uaccess_{enable,disable}() naming for the common case of ensuring the
user page tables are mapped in TTBR0.

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: James Morse <james.morse@arm.com>
Cc: Will Deacon <will@kernel.org>
---
 arch/arm64/include/asm/futex.h       | 8 ++++----
 arch/arm64/include/asm/uaccess.h     | 4 ++--
 arch/arm64/kernel/armv8_deprecated.c | 4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/arm64/include/asm/futex.h b/arch/arm64/include/asm/futex.h
index 97f6a63810ecb..8e41faa37c691 100644
--- a/arch/arm64/include/asm/futex.h
+++ b/arch/arm64/include/asm/futex.h
@@ -16,7 +16,7 @@
 do {									\
 	unsigned int loops = FUTEX_MAX_LOOPS;				\
 									\
-	uaccess_enable();						\
+	uaccess_enable_privileged();					\
 	asm volatile(							\
 "	prfm	pstl1strm, %2\n"					\
 "1:	ldxr	%w1, %2\n"						\
@@ -39,7 +39,7 @@ do {									\
 	  "+r" (loops)							\
 	: "r" (oparg), "Ir" (-EFAULT), "Ir" (-EAGAIN)			\
 	: "memory");							\
-	uaccess_disable();						\
+	uaccess_disable_privileged();					\
 } while (0)
 
 static inline int
@@ -95,7 +95,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *_uaddr,
 		return -EFAULT;
 
 	uaddr = __uaccess_mask_ptr(_uaddr);
-	uaccess_enable();
+	uaccess_enable_privileged();
 	asm volatile("// futex_atomic_cmpxchg_inatomic\n"
 "	prfm	pstl1strm, %2\n"
 "1:	ldxr	%w1, %2\n"
@@ -118,7 +118,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *_uaddr,
 	: "+r" (ret), "=&r" (val), "+Q" (*uaddr), "=&r" (tmp), "+r" (loops)
 	: "r" (oldval), "r" (newval), "Ir" (-EFAULT), "Ir" (-EAGAIN)
 	: "memory");
-	uaccess_disable();
+	uaccess_disable_privileged();
 
 	if (!ret)
 		*uval = val;
diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
index 991dd5f031e46..d6a4e496ebc64 100644
--- a/arch/arm64/include/asm/uaccess.h
+++ b/arch/arm64/include/asm/uaccess.h
@@ -200,12 +200,12 @@ do {									\
 				CONFIG_ARM64_PAN));			\
 } while (0)
 
-static inline void uaccess_disable(void)
+static inline void uaccess_disable_privileged(void)
 {
 	__uaccess_disable(ARM64_HAS_PAN);
 }
 
-static inline void uaccess_enable(void)
+static inline void uaccess_enable_privileged(void)
 {
 	__uaccess_enable(ARM64_HAS_PAN);
 }
diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c
index 7364de008bab3..0e86e8b9ceddf 100644
--- a/arch/arm64/kernel/armv8_deprecated.c
+++ b/arch/arm64/kernel/armv8_deprecated.c
@@ -277,7 +277,7 @@ static void __init register_insn_emulation_sysctl(void)
 
 #define __user_swpX_asm(data, addr, res, temp, temp2, B)	\
 do {								\
-	uaccess_enable();					\
+	uaccess_enable_privileged();				\
 	__asm__ __volatile__(					\
 	"	mov		%w3, %w7\n"			\
 	"0:	ldxr"B"		%w2, [%4]\n"			\
@@ -302,7 +302,7 @@ do {								\
 	  "i" (-EFAULT),					\
 	  "i" (__SWP_LL_SC_LOOPS)				\
 	: "memory");						\
-	uaccess_disable();					\
+	uaccess_disable_privileged();				\
 } while (0)
 
 #define __user_swp_asm(data, addr, res, temp, temp2) \
-- 
2.11.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-10-26 13:36 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26 13:31 [PATCHv3 00/17] arm64: remove set_fs() and friends Mark Rutland
2020-10-26 13:31 ` [PATCHv3 01/17] arm64: ensure ERET from kthread is illegal Mark Rutland
2020-10-26 13:31 ` [PATCHv3 02/17] arm64: add C wrappers for SET_PSTATE_*() Mark Rutland
2020-10-26 13:31 ` [PATCHv3 03/17] arm64: head.S: rename el2_setup -> init_kernel_el Mark Rutland
2020-10-26 13:31 ` [PATCHv3 04/17] arm64: head.S: cleanup SCTLR_ELx initialization Mark Rutland
2020-10-26 13:31 ` [PATCHv3 05/17] arm64: head.S: always initialize PSTATE Mark Rutland
2020-10-26 13:31 ` [PATCHv3 06/17] arm64: sdei: move uaccess logic to arch/arm64/ Mark Rutland
2020-10-26 13:31 ` [PATCHv3 07/17] arm64: sdei: explicitly simulate PAN/UAO entry Mark Rutland
2020-10-26 13:31 ` [PATCHv3 08/17] arm64: uaccess: move uao_* alternatives to asm-uaccess.h Mark Rutland
2020-11-03 14:26   ` Will Deacon
2020-11-03 14:41     ` Mark Rutland
2020-10-26 13:31 ` Mark Rutland [this message]
2020-10-26 13:31 ` [PATCHv3 10/17] arm64: uaccess: simplify __copy_user_flushcache() Mark Rutland
2020-10-27 17:33   ` Robin Murphy
2020-11-02 10:14     ` Mark Rutland
2020-10-26 13:31 ` [PATCHv3 11/17] arm64: uaccess: refactor __{get,put}_user Mark Rutland
2020-10-27 18:03   ` Robin Murphy
2020-11-02 10:25     ` Mark Rutland
2020-10-26 13:31 ` [PATCHv3 12/17] arm64: uaccess: split user/kernel routines Mark Rutland
2020-11-02 10:48   ` Mark Rutland
2020-10-26 13:31 ` [PATCHv3 13/17] arm64: uaccess cleanup macro naming Mark Rutland
2020-10-27 18:45   ` Robin Murphy
2020-11-02 10:35     ` Mark Rutland
2020-10-26 13:31 ` [PATCHv3 14/17] arm64: uaccess: remove set_fs() Mark Rutland
2020-10-26 13:31 ` [PATCHv3 15/17] arm64: uaccess: remove addr_limit_user_check() Mark Rutland
2020-10-26 13:31 ` [PATCHv3 16/17] arm64: uaccess: remove redundant PAN toggling Mark Rutland
2020-10-26 13:31 ` [PATCHv3 17/17] arm64: uaccess: remove vestigal UAO support Mark Rutland

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20201026133156.44186-10-mark.rutland@arm.com \
    --to=mark.rutland@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=hch@lst.de \
    --cc=james.morse@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

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

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