lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241114014641.pmpdpq7gsowadpqs@jpoimboe>
Date: Wed, 13 Nov 2024 17:46:41 -0800
From: jpoimboe <jpoimboe@...nel.org>
To: David Woodhouse <dwmw2@...radead.org>
Cc: Peter Zijlstra <peterz@...radead.org>, "H. Peter Anvin" <hpa@...or.com>,
	kexec@...ts.infradead.org, Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
	Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
	"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
	Kai Huang <kai.huang@...el.com>,
	Nikolay Borisov <nik.borisov@...e.com>,
	linux-kernel@...r.kernel.org, Simon Horman <horms@...nel.org>
Subject: Re: [RFC PATCH 2/2] x86/kexec: Add data section to relocate_kernel

On Tue, Nov 12, 2024 at 10:45:05AM +0000, David Woodhouse wrote:
> On Tue, 2024-11-12 at 11:14 +0100, Peter Zijlstra wrote:
> > On Tue, Nov 12, 2024 at 08:44:33AM +0000, David Woodhouse wrote:
> > > On Fri, 2024-11-08 at 12:26 +0100, H. Peter Anvin wrote:
> > > > 
> > > > > --- a/arch/x86/kernel/vmlinux.lds.S
> > > > > +++ b/arch/x86/kernel/vmlinux.lds.S
> > > > > @@ -100,7 +100,7 @@ const_pcpu_hot = pcpu_hot;
> > > > >         . = ALIGN(PAGE_SIZE);                                   \
> > > > >         __relocate_kernel_start = .;                            \
> > > > >         *(.text.relocate_kernel);                               \
> > > > > -       *(.rodata.relocate_kernel);                             \
> > > > > +       *(.data.relocate_kernel);                               \
> > 
> > Why are we having data in the middle of the text section?
> 
> This is the relocate_kernel() page. It's the last thing the kernel
> calls on kexec.
> 
> The kernel first takes a *copy* of it and places it into the identity
> mapping page tables which are set up for kexec.
> 
> The relocate_kernel() function is then called at its *original*
> location in the kernel text. Before reloading %cr3, it stores some
> information which is going to become unavailable into its own page
> (currently using a bit of a nasty hack based on a hard-coded
> KEXEC_CONTROL_CODE_MAX_SIZE because we can't just use data symbol
> references).
> 
> Then it reloads %cr3 and jumps to the identity-mapped copy of itself.
> 
> Could we put .text.relocate_kernel and .data.relocate_kernel somewhere
> *other* than the main kernel text segment? Probably... it use use
> alternative instructions, but we could deal with that. And if we call
> from machine_kexec() directly into the *copy* (having marked it
> executable), maybe...?

I fetched your branch and only saw a "RET before UNTRAIN" warning, did
you happen to already fix the other warnings up?

Something like the below fixes the warning I saw.

Though, maybe it's better to just tell objtool to keep its paws off of
the problematic functions by use of the STACK_FRAME_NON_STANDARD macro?
Then you could get rid of all the unwind hints and annotations.


diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 6604f5d038aa..9ba10530b9c7 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -4012,8 +4012,11 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn)
 			return 0;
 
 		case INSN_RETURN:
-			WARN_INSN(insn, "RET before UNTRAIN");
-			return 1;
+			if (!insn->retpoline_safe) {
+				WARN_INSN(insn, "RET before UNTRAIN");
+				return 1;
+			}
+			break;
 
 		case INSN_NOP:
 			if (insn->retpoline_safe)


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ