lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240123011238.work.301-kees@kernel.org>
Date: Mon, 22 Jan 2024 17:12:38 -0800
From: Kees Cook <keescook@...omium.org>
To: Russell King <linux@...linux.org.uk>
Cc: Kees Cook <keescook@...omium.org>,
	Mark Brown <broonie@...nel.org>,
	Ard Biesheuvel <ardb@...nel.org>,
	Wang Kefeng <wangkefeng.wang@...wei.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Ben Hutchings <ben@...adent.org.uk>,
	linux-arm-kernel@...ts.infradead.org,
	"Russell King (Oracle)" <rmk+kernel@...linux.org.uk>,
	Hugh Dickins <hughd@...gle.com>,
	linux-kernel@...r.kernel.org,
	linux-hardening@...r.kernel.org
Subject: [PATCH] ARM: 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.

Reported-by: Mark Brown <broonie@...nel.org>
Link: https://lore.kernel.org/all/202401181125.D48DCB4C@keescook/ [1]
Suggested-by: "Russell King (Oracle)" <linux@...linux.org.uk>
Cc: Russell King <linux@...linux.org.uk>
Cc: Ard Biesheuvel <ardb@...nel.org>
Cc: Wang Kefeng <wangkefeng.wang@...wei.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Ben Hutchings <ben@...adent.org.uk>
Cc: linux-arm-kernel@...ts.infradead.org
Signed-off-by: Kees Cook <keescook@...omium.org>
---
 arch/arm/mm/fault.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index e804432e905e..bc5b959b6f90 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
 
 /*
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ