From bd690a3f314893040876db9ffa623058ce2e9164 Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 7 Sep 2012 07:22:06 -0200 Subject: ARM: 7527/1: uaccess: explicitly check __user pointer when !CPU_USE_DOMAINS commit 8404663 upstream. The {get,put}_user macros don't perform range checking on the provided __user address when !CPU_HAS_DOMAINS. This patch reworks the out-of-line assembly accessors to check the user address against a specified limit, returning -EFAULT if is is out of range. [will: changed get_user register allocation to match put_user] [rmk: fixed building on older ARM architectures] Reported-by: Catalin Marinas Signed-off-by: Will Deacon Signed-off-by: Russell King [bwh: Backported to 3.2: TUSER() was called T()] Signed-off-by: Ben Hutchings [steven@steven676.net: make apply to 3.0] Tested-by: Moritz Bandemer --- arch/arm/include/asm/assembler.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'arch/arm/include/asm/assembler.h') diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h index 7bb8bf9..456649e 100644 --- a/arch/arm/include/asm/assembler.h +++ b/arch/arm/include/asm/assembler.h @@ -299,6 +299,14 @@ usracc ldr, \reg, \ptr, \inc, \cond, \rept, \abort .endm + .macro check_uaccess, addr:req, size:req, limit:req, tmp:req, bad:req +#ifndef CONFIG_CPU_USE_DOMAINS + adds \tmp, \addr, #\size - 1 + sbcccs \tmp, \tmp, \limit + bcs \bad +#endif + .endm + /* Utility macro for declaring string literals */ .macro string name:req, string .type \name , #object -- cgit v1.1