]> git.ipfire.org Git - people/ms/linux.git/commitdiff
arm64: uaccess: rename privileged uaccess routines
authorMark Rutland <mark.rutland@arm.com>
Wed, 2 Dec 2020 13:15:50 +0000 (13:15 +0000)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 2 Dec 2020 19:49:10 +0000 (19:49 +0000)
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: Christoph Hellwig <hch@lst.de>
Cc: James Morse <james.morse@arm.com>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20201202131558.39270-5-mark.rutland@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/futex.h
arch/arm64/include/asm/uaccess.h
arch/arm64/kernel/armv8_deprecated.c

index 97f6a63810ecbf7a8d803b6eaaba3b4884a2bd3f..8e41faa37c691cdcc35eb658ca4f4005d6c74698 100644 (file)
@@ -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;
index 991dd5f031e4613cdfceab311d37aec32ee4d60a..d6a4e496ebc64110d8b63f7be91606aee98a9fe2 100644 (file)
@@ -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);
 }
index 7364de008bab395762358fdfddf5aa8d8e2c13c5..0e86e8b9ceddf246a459d48cacbc0ac421faa4a8 100644 (file)
@@ -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) \