Skip to content

Commit 06dd828

Browse files
mrutland-armgregkh
authored andcommitted
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: 0aea86a ("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>
1 parent c23fee6 commit 06dd828

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

arch/arm64/include/asm/uaccess.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,12 @@ static inline void set_fs(mm_segment_t fs)
9292
*/
9393
#define __range_ok(addr, size) \
9494
({ \
95+
unsigned long __addr = (unsigned long __force)(addr); \
9596
unsigned long flag, roksum; \
9697
__chk_user_ptr(addr); \
9798
asm("adds %1, %1, %3; ccmp %1, %4, #2, cc; cset %0, ls" \
9899
: "=&r" (flag), "=&r" (roksum) \
99-
: "1" (addr), "Ir" (size), \
100+
: "1" (__addr), "Ir" (size), \
100101
"r" (current_thread_info()->addr_limit) \
101102
: "cc"); \
102103
flag; \

0 commit comments

Comments
 (0)