aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKees Cook <[email protected]>2024-02-01 18:32:58 +0100
committerRussell King (Oracle) <[email protected]>2024-02-24 16:47:20 +0000
commit169f9102f9198b04afffa6164372a4ba4070f412 (patch)
treec6f6b01f8900066b45c8730e03fd7a8284b4abc1
parentdaa559570d4b81e98e5a77a5c0f2a88879a9f245 (diff)
ARM: 9350/1: fault: Implement copy_from_kernel_nofault_allowed()
Under PAN emulation when dumping backtraces from things like the LKDTM EXEC_USERSPACE test[1], a double fault (which would hang a CPU) would happen because of dump_instr() attempting to read a userspace address. Make sure copy_from_kernel_nofault() does not attempt this any more. Closes: https://lava.sirena.org.uk/scheduler/job/497571 Link: https://lore.kernel.org/all/202401181125.D48DCB4C@keescook/ [1] Reported-by: Mark Brown <[email protected]> Suggested-by: Russell King (Oracle) <[email protected]> Reviewed-by: Ard Biesheuvel <[email protected]> Tested-by: Mark Brown <[email protected]> Cc: Wang Kefeng <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Ben Hutchings <[email protected]> Cc: [email protected] Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]>
-rw-r--r--arch/arm/mm/fault.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index e96fb40b9cc3..ec16907a551c 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -25,6 +25,13 @@
#include "fault.h"
+bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
+{
+ unsigned long addr = (unsigned long)unsafe_src;
+
+ return addr >= TASK_SIZE && ULONG_MAX - addr >= size;
+}
+
#ifdef CONFIG_MMU
/*