From patchwork Fri Apr 29 13:13:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 12832000 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 22D69C433F5 for ; Fri, 29 Apr 2022 13:15:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=U9ARorQ6m9ONnRRq/dkz001q+mLIQOQF98NoWzf1RZs=; b=F4C3nERyAfL9uC sJg9gDBvoWwVS2wN2VIugy9cbI2y1FS39gcrWJivNesMNy9jb83rFfL6FjRnFvST7bsCIZAFs+K57 x0d2uzrQ8bTrBmJT0nVwUyCmZmrYpqhu7NsObV+nJLaWLqMjOyiqVYq+dskNHP2g8ZJ0+hTkKURWD MloSpAoGemkz25R8scXx44Pq+QPsPYTXKcXJgDLsQkElec+rBHBl1pDYSSze6TV2wQ7QlOCEsNECh 7O65k+iyEN7BnUfaYXwei0SNAvuOkEbYLMzC3oqf/Pmygtod9ItE1ev/cpg/GIGVxEcKaOEtpNW6r peXCN5UyC1Ge/1P9teUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nkQRz-00BKLP-Re; Fri, 29 Apr 2022 13:14:23 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nkQRe-00BKIX-AX for linux-arm-kernel@lists.infradead.org; Fri, 29 Apr 2022 13:14:03 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 01AABB83549; Fri, 29 Apr 2022 13:14:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57E68C385AF; Fri, 29 Apr 2022 13:13:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651238040; bh=ta4kqeRaLw1HQ1KB+sWtcjfX2do2iJpkhRPxnNE9cRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XFhs42W5LF9HH5zzYE9UZtwUsU97pWE/YvZrOgDjNEXHexwdXHh7HVy5A/WbIbYgR NQivF6wrPsQ5Uhm4HVKuN6nsdeZSyTs5ee9rBabtvH+RKScA6UqUAT+7oxewKjW1RH jccDzFi1d30rBlxiWvwukeZ6WoVcwr0YlRSg1+qbDiZce9E9dHbQdq+uyl9KvUJ288 UTNFPIiSaX3e9tDmI6fgjKWL9QHETA5OdjbV6/yAKZv9qslZRPOAv/NIfQIHBuD07X 9Ss12/4G9dHZCjYNePhfwm/plkK2eG9OTZyBE5XtZqUM5wjgU4SoW7XyboSU9zA62M YwPNcyAxBgAoA== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, mark.rutland@arm.com, Ard Biesheuvel Subject: [PATCH 2/2] arm64: mm: avoid writable executable mappings in kexec/hibernate code Date: Fri, 29 Apr 2022 15:13:47 +0200 Message-Id: <20220429131347.3621090-3-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220429131347.3621090-1-ardb@kernel.org> References: <20220429131347.3621090-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=972; h=from:subject; bh=ta4kqeRaLw1HQ1KB+sWtcjfX2do2iJpkhRPxnNE9cRg=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBia+SLH7bpNSHP9KCOx+PaHI8WOyz8aXa0avcdXoN/ 52t1QuuJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYmvkiwAKCRDDTyI5ktmPJG/LC/ 4ud/BzYiJ/KhlBIBWF4gWnIoiYIsB3kocfIK2VFOTs0MC1PBHkPn6GfTcuU5Q366BofzCzpIvgEZ8Z FM8HO27evYKm5CPdQdLsMI/mYt5UZUp0QUcfIGbno+i/bTt6Wd+0BcjaAtBHxDBO9CYOvZgbY4kXl3 UIL97mIgwg7gsUXrye9iFsgeye0ebLHwnm4Euy2T4zOiUkw09jIhB7ZdeLZN5m3qnn01LXY7HW+7pw C2CCmnxMbtLiE2pogNsY2jSjY5NgFOGiC4VNG9/OIGMKuHG3sIJYqx5ENwhaZDmB24vnoeCTFPHPbM u19mosRyXhjVKftIHbji4KMmazZDo/Eij+XSw2vVFIA8hEZkkE3zNlsWAtrnQtAj4w1b1Py7klCByy PoGAqKmKJ32pMfET/Y2BeWS3EbCIrnuUn6ZyL45pJkY2QW/UKxRNlaXDIh4lXKvBObfURdV+but4wP 3+3GDOBADmqiMhjRK8NSuBiVkST4uO+Gjyz8ihSX7oN8Q= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220429_061402_549648_3096C6BB X-CRM114-Status: GOOD ( 11.82 ) 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 The temporary mappings of the low-level kexec and hibernate helpers are created with both writable and executable attributes, which is not necessary here, and generally best avoided. So use read-only, executable attributes instead. Signed-off-by: Ard Biesheuvel --- arch/arm64/mm/trans_pgd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/mm/trans_pgd.c b/arch/arm64/mm/trans_pgd.c index d7da8ca40d2e..4ea2eefbc053 100644 --- a/arch/arm64/mm/trans_pgd.c +++ b/arch/arm64/mm/trans_pgd.c @@ -238,7 +238,7 @@ int trans_pgd_idmap_page(struct trans_pgd_info *info, phys_addr_t *trans_ttbr0, int this_level, index, level_lsb, level_msb; dst_addr &= PAGE_MASK; - prev_level_entry = pte_val(pfn_pte(pfn, PAGE_KERNEL_EXEC)); + prev_level_entry = pte_val(pfn_pte(pfn, PAGE_KERNEL_ROX)); for (this_level = 3; this_level >= 0; this_level--) { levels[this_level] = trans_alloc(info);