diff options
author | Mark Rutland <mark.rutland@arm.com> | 2017-05-03 11:09:35 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-05-25 09:44:45 -0400 |
commit | e817a7fb2f31c2fafc8e6e2dbf649bbd65b2f604 (patch) | |
tree | ea2e47d70acc038b2fb945b721daec15d3af7053 | |
parent | 4775fbcc92d79be414046dd208beb767ed5168e2 (diff) |
arm64: uaccess: ensure extension of access_ok() addr
commit a06040d7a791a9177581dcf7293941bd92400856 upstream.
Our access_ok() simply hands its arguments over to __range_ok(), which
implicitly assummes that the addr parameter is 64 bits wide. This isn't
necessarily true for compat code, which might pass down a 32-bit address
parameter.
In these cases, we don't have a guarantee that the address has been zero
extended to 64 bits, and the upper bits of the register may contain
unknown values, potentially resulting in a suprious failure.
Avoid this by explicitly casting the addr parameter to an unsigned long
(as is done on other architectures), ensuring that the parameter is
widened appropriately.
Fixes: 0aea86a2176c ("arm64: User access library functions")
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | arch/arm64/include/asm/uaccess.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index 55d0adbf6509..14cca10aeb4e 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h | |||
@@ -93,11 +93,12 @@ static inline void set_fs(mm_segment_t fs) | |||
93 | */ | 93 | */ |
94 | #define __range_ok(addr, size) \ | 94 | #define __range_ok(addr, size) \ |
95 | ({ \ | 95 | ({ \ |
96 | unsigned long __addr = (unsigned long __force)(addr); \ | ||
96 | unsigned long flag, roksum; \ | 97 | unsigned long flag, roksum; \ |
97 | __chk_user_ptr(addr); \ | 98 | __chk_user_ptr(addr); \ |
98 | asm("adds %1, %1, %3; ccmp %1, %4, #2, cc; cset %0, ls" \ | 99 | asm("adds %1, %1, %3; ccmp %1, %4, #2, cc; cset %0, ls" \ |
99 | : "=&r" (flag), "=&r" (roksum) \ | 100 | : "=&r" (flag), "=&r" (roksum) \ |
100 | : "1" (addr), "Ir" (size), \ | 101 | : "1" (__addr), "Ir" (size), \ |
101 | "r" (current_thread_info()->addr_limit) \ | 102 | "r" (current_thread_info()->addr_limit) \ |
102 | : "cc"); \ | 103 | : "cc"); \ |
103 | flag; \ | 104 | flag; \ |