Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: Fix __range_ok macro

Without this, the following scenario is incorrectly determined
to be invalid.

addr 0x7f_ffffe000 size 8192 addr_limit 0x80_00000000

This behavior was observed while trying to vmsplice the stack
as part of a CRIU dump of a process on a system started with the
norandmaps kernel parameter.

Signed-off-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

Christopher Covington and committed by
Catalin Marinas
31b1e940 74397174

+2 -2
+2 -2
arch/arm64/include/asm/uaccess.h
··· 83 83 * Returns 1 if the range is valid, 0 otherwise. 84 84 * 85 85 * This is equivalent to the following test: 86 - * (u65)addr + (u65)size < (u65)current->addr_limit 86 + * (u65)addr + (u65)size <= current->addr_limit 87 87 * 88 88 * This needs 65-bit arithmetic. 89 89 */ ··· 91 91 ({ \ 92 92 unsigned long flag, roksum; \ 93 93 __chk_user_ptr(addr); \ 94 - asm("adds %1, %1, %3; ccmp %1, %4, #2, cc; cset %0, cc" \ 94 + asm("adds %1, %1, %3; ccmp %1, %4, #2, cc; cset %0, ls" \ 95 95 : "=&r" (flag), "=&r" (roksum) \ 96 96 : "1" (addr), "Ir" (size), \ 97 97 "r" (current_thread_info()->addr_limit) \