From nobody Thu Dec 18 09:44:01 2025 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 B3C30218853 for ; Thu, 5 Dec 2024 15:34:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733412842; cv=none; b=a3flha5XH/Rl6OQsoFw3GVm77w1y1fOnmErMufHgx8Jo8szMbwLM9OGl64vpMB59w/A/oSR6/AXC0AhxMV2jkAIJurpxKfw4OECQdN511LRJSpY89S8PUibbwOR9NY/iDS776n0H9PCn4pB5AIFRVvTr3JpWj4sGVc9jUHFrCPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733412842; c=relaxed/simple; bh=HZMzJO0ERgKBSdgHCinISLLLJ2P1/lAUKPmv9/37Fgs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OXoKhIwzF/8VUy82U3VkOFB4xr8wi5QBSBBGHCEbHue4f0pFmUDLA/k6qRl3qmhUgMvv2y/BYUhOJS2kvgUg6ij2AyOtJOXzVAD7nFKchFeNgz9og/l3Lp6GgtNV+5Fgkv7nVt/6LrjFIyIs/i8kCi+CaqFGGHRxDs1JwYABVpY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=desiato.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=CkB6djfx; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=desiato.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="CkB6djfx" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=Bu60bcDvZzloSAXCkbCegV/lwySuet3eE7e1Gl1k8gk=; b=CkB6djfxb2i/nBcty/k29j9iYo 05TH4F/vPDZ2oa8ty5fjQ6lL/1bwy/z4U9M+893zGXsW6fWWxwxxgD/uCJVBU/bgClKacjyispcQM J+KpPp2tUAssYeS3imPo3Y7A24JTLL3FVVnWtIkPvjsP74yek6XeJRSRu8TbJlFAMphNGLv50YVdZ 8vxSAfD3SQPzmltzv4dkvPfJ7l0A/n5f3HjwtS0fpRBg0NhhG7+Jf5ocFInSXheOQi7BoDmeRXECN 2ae/QhrNtX6sHObuZfwznprkF54TOM1jLnvj27s45yZjiRAWxYwcrRVsmFLlgPTVb1YQnFrKErnVS UOTi7mHw==; Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by desiato.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tJDrO-00000002wEy-0jg5; Thu, 05 Dec 2024 15:33:46 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJDrN-0000000DyM3-319d; Thu, 05 Dec 2024 15:33:45 +0000 From: David Woodhouse To: kexec@lists.infradead.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , David Woodhouse , "Kirill A. Shutemov" , Kai Huang , Nikolay Borisov , linux-kernel@vger.kernel.org, Simon Horman , Dave Young , Peter Zijlstra , jpoimboe@kernel.org, bsz@amazon.de Subject: [PATCH v5 13/20] x86/kexec: Mark relocate_kernel page as ROX instead of RWX Date: Thu, 5 Dec 2024 15:05:19 +0000 Message-ID: <20241205153343.3275139-14-dwmw2@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205153343.3275139-1-dwmw2@infradead.org> References: <20241205153343.3275139-1-dwmw2@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by desiato.infradead.org. See http://www.infradead.org/rpr.html Content-Type: text/plain; charset="utf-8" From: David Woodhouse All writes to the page now happen before it gets marked as executable (or after it's already switched to the identmap page tables where it's OK to be RWX). Signed-off-by: David Woodhouse --- arch/x86/kernel/machine_kexec_64.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_k= exec_64.c index c9fd60f8f806..9232ad1562c8 100644 --- a/arch/x86/kernel/machine_kexec_64.c +++ b/arch/x86/kernel/machine_kexec_64.c @@ -323,7 +323,7 @@ int machine_kexec_prepare(struct kimage *image) =20 __memcpy(control_page, __relocate_kernel_start, reloc_end - reloc_start); =20 - set_memory_x((unsigned long)control_page, 1); + set_memory_rox((unsigned long)control_page, 1); =20 return 0; } @@ -333,6 +333,7 @@ void machine_kexec_cleanup(struct kimage *image) void *control_page =3D page_address(image->control_code_page); =20 set_memory_nx((unsigned long)control_page, 1); + set_memory_rw((unsigned long)control_page, 1); =20 free_transition_pgtable(image); } --=20 2.47.0