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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171027200715.GB12039@nazgul.tnic>
Date:   Fri, 27 Oct 2017 22:07:15 +0200
From:   Borislav Petkov <bp@...e.de>
To:     Andy Lutomirski <luto@...nel.org>
Cc:     X86 ML <x86@...nel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Brian Gerst <brgerst@...il.com>,
        Dave Hansen <dave.hansen@...el.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH 05/18] x86/asm/64: Shrink paranoid_exit_restore and make
 labels local

On Thu, Oct 26, 2017 at 01:26:37AM -0700, Andy Lutomirski wrote:
> paranoid_exit_restore was a copy of
> restore_regs_and_return_to_kernel.  Merge them and make the
> paranoid_exit internal labels local.
> 
> Keeping .Lparanoid_exit makes the code a bit shorter because it
> allows a 2-byte jnz instead of a 5-byte jnz.
> 
> Saves 96 bytes of text.
> 
> (This is still a bit suboptimal in a non-CONFIG_TRACE_IRQFLAGS
>  kernel, but fixing that would make the code rather messy.)
> 
> Signed-off-by: Andy Lutomirski <luto@...nel.org>
> ---
>  arch/x86/entry/entry_64.S | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> index 4ad40067162a..d6404a613df4 100644
> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -1119,17 +1119,14 @@ ENTRY(paranoid_exit)
>  	DISABLE_INTERRUPTS(CLBR_ANY)
>  	TRACE_IRQS_OFF_DEBUG
>  	testl	%ebx, %ebx			/* swapgs needed? */
> -	jnz	paranoid_exit_no_swapgs
> +	jnz	.Lparanoid_exit_no_swapgs
>  	TRACE_IRQS_IRETQ
>  	SWAPGS_UNSAFE_STACK
> -	jmp	paranoid_exit_restore
> -paranoid_exit_no_swapgs:
> +	jmp	.Lparanoid_exit_restore

Kill that paranoid_exit_restore too and save everybody a jump:

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 1b9e8079ca3a..b88e17e120fa 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -1122,10 +1122,9 @@ ENTRY(paranoid_exit)
 	jnz	.Lparanoid_exit_no_swapgs
 	TRACE_IRQS_IRETQ
 	SWAPGS_UNSAFE_STACK
-	jmp	.Lparanoid_exit_restore
+	jmp restore_regs_and_return_to_kernel
 .Lparanoid_exit_no_swapgs:
 	TRACE_IRQS_IRETQ_DEBUG
-.Lparanoid_exit_restore:
 	jmp restore_regs_and_return_to_kernel
 END(paranoid_exit)
 

-- 
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ