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 76FA41FBCB2; Tue, 8 Apr 2025 10:58:22 +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=1744109902; cv=none; b=BKMTGGNeThk/uGH+vVf+KrZZbj5Go+OIxaR2Ec+vBnvllHzplS7L9IHbh6/zIK1ReL6DvjowosH8equOBoMJfQaHnW9qKulio3AojSJaPWGZNLFPgV/e3rfe+35ttVLaJEKTDFM5vb6yVu/23OXYOp2DtD8MdRAynqRmvgESVek= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744109902; c=relaxed/simple; bh=Y5VEI/UG5r532eHoiAqv0zvrNjcPUnXEZbNrf1uZIWI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gUEG/o8A8Bq85B2uwCcWfmMfW2I38MmevYdnNmlyyATS4Xl6W3UwNP3sPFIRPNzNFcGkn4FHhhxUbdkZVHrm0zJnwUH8VFw2CD8CkljjD8PQ1FdKAQuUjKqnvn/8FF7mnR6q9j0XQViQu0WkAcssY+yb73h+sH2mvLEe+IfPyEw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=VMNkUFMA; 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="VMNkUFMA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06B9DC4CEE5; Tue, 8 Apr 2025 10:58:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744109902; bh=Y5VEI/UG5r532eHoiAqv0zvrNjcPUnXEZbNrf1uZIWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VMNkUFMAjSaIhmSIwCR3R8y1jj8wJcnPQqOkNKGIp0aTlEVlfORJdqBztV2/N/yRM 79SI27nOurhiEz7zuKneVrqvYzbYTGK2AYg8v3u84zAuPBowZAKmUEKDd1hK7UzqWV rpdQF70IHgG2fJEy+0wrX3KmoA4L3hmpXJRSqWEQ= 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.10 096/227] ARM: 9350/1: fault: Implement copy_from_kernel_nofault_allowed() Date: Tue, 8 Apr 2025 12:47:54 +0200 Message-ID: <20250408104823.246309861@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408104820.353768086@linuxfoundation.org> References: <20250408104820.353768086@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-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 @@ -24,6 +24,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 /*