From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90F3F264627; Tue, 8 Apr 2025 12:05:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744113937; cv=none; b=buUU8fbSvq5upOX+uJlCKd5FyyF4kVKIF149ZrWeiRJfhSo8XStTOQ0GPDIykQ6ibYl/FQsS/R1aBBSHhndnpL4Sw3krHvDVyWDqCidEBVCeJ5yGtiPJM6IVHUZfShm/fQY2dSPJrUELHUK7fCCGmpRLQT0tWirFVlHaVizLk0k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744113937; c=relaxed/simple; bh=ySCqwnznISe2IutyBngFhcxFXg3KoGZE6AOnIww5khU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KgwXfXucY4hhB+D5pQB5skuWuTtGWg4be6Qd9Aw7Tg+CndbxE5xO79WKmnSn8B0Njx0i2Su7v902qG5FZDVaF1H9AamhfTiTyZTpMqBKQX8RiRx2J6rewPcLqb6yBwx+NsVGppzq6bl4ObrzOo/1F/FyY6hOUHCppoCe6/JVmvA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=MKGAXtDT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="MKGAXtDT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21089C4CEE5; Tue, 8 Apr 2025 12:05:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744113937; bh=ySCqwnznISe2IutyBngFhcxFXg3KoGZE6AOnIww5khU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MKGAXtDTDXrrPdl5X13mEeGZ4MSUJCn5phtvD4Bo25uygbwc0eKyhFX+GNzHEUo7U dnp/kXiNwGKezCOso+PLEHz+axNidOHtbnVBWB+/sOJoYGNJ0hraqU2kwH6z/RZ63t zwNcVU63sjDKBAa3e4J48/gwg4V5SjIs2QjzBZ3Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mark Brown , "Russell King (Oracle)" , Ard Biesheuvel , Wang Kefeng , Andrew Morton , Ben Hutchings , linux-arm-kernel@lists.infradead.org, Kees Cook Subject: [PATCH 5.4 069/154] ARM: 9350/1: fault: Implement copy_from_kernel_nofault_allowed() Date: Tue, 8 Apr 2025 12:50:10 +0200 Message-ID: <20250408104817.512995785@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408104815.295196624@linuxfoundation.org> References: <20250408104815.295196624@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kees Cook commit 169f9102f9198b04afffa6164372a4ba4070f412 upstream. 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 Suggested-by: Russell King (Oracle) Reviewed-by: Ard Biesheuvel Tested-by: Mark Brown Cc: Wang Kefeng Cc: Andrew Morton Cc: Ben Hutchings Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Kees Cook Signed-off-by: Russell King (Oracle) Signed-off-by: Greg Kroah-Hartman --- arch/arm/mm/fault.c | 7 +++++++ 1 file changed, 7 insertions(+) --- 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 /*