From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F3F65C3600C for ; Thu, 3 Apr 2025 15:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=s2y5ebmgaRNnSet/J37AzDoIkBYRq56Yd7coUHIOxvE=; b=GRHb6/utLFhESaUZmRJiesufXH jA6eJcP3/6JLR5qeqNMpTd3lMD6KrW7Xvbg4BC0q2Yr39HUOIxQRxSwgQeE4T9WYa4g6cxKZnNISZ 2BX2B/QsP6gIe1dZF6FMbDOXST8dMIIwghK9kcClb/4IAhgRIULK2Ud6Urn1tGaJMWlnvbb3oXCBP 75yGhKphvQDiOtwa96b6HXPy0/CWBAg6Y0FX5cpMPOmlobqW2S5HaUkrj4AEjdFhoKJUm/TLB4YRx 3gXHamFKCZmsFAabgwJr6keIpOrg8LXpMzNLMjRap3MibYDP3lqNLpnrPmdrCFoVZ3UfkayMT/l9J TpJrKo4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1u0MUw-00000009ESf-456k; Thu, 03 Apr 2025 15:28:54 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1u0MT9-00000009EDU-0BId for linux-arm-kernel@lists.infradead.org; Thu, 03 Apr 2025 15:27:04 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 5B1B443DDB; Thu, 3 Apr 2025 15:27:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DBFAC4CEE3; Thu, 3 Apr 2025 15:27:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1743694021; bh=kjYe3Efpepfsnv/dl7n86aP47rLOVYOWZwcmApiikYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f3wtWsyYT3oILFBi98oYA69XS5/LWk9PHDwAtvItDk6m66+diWQ5OkNgLZWf9cm0p AecJOgm0Kn5sASxKgGD0YEV0YlL0iKNppgjvhRsMCRiF2eUrf7xTOeJ6GbTXD2+VA7 1zuLJSfw5mkgCxNPqQxI/r1sPUiNzmSxytK/Bi18= 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 6.6 04/26] ARM: 9350/1: fault: Implement copy_from_kernel_nofault_allowed() Date: Thu, 3 Apr 2025 16:20:25 +0100 Message-ID: <20250403151622.542513914@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250403151622.415201055@linuxfoundation.org> References: <20250403151622.415201055@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250403_082703_106107_B1DCC2C6 X-CRM114-Status: GOOD ( 10.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 6.6-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 /*