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: <20230811070123.GD220434@hirez.programming.kicks-ass.net>
Date:   Fri, 11 Aug 2023 09:01:23 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Borislav Petkov <bp@...en8.de>
Cc:     x86@...nel.org, linux-kernel@...r.kernel.org, David.Kaplan@....com,
        Andrew.Cooper3@...rix.com, jpoimboe@...nel.org,
        gregkh@...uxfoundation.org, matz@...e.de,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        joao.moreira@...el.com, samitolvanen@...gle.com
Subject: Re: [RFC][PATCH 02/17] x86/cpu: Clean up SRSO return thunk mess

On Thu, Aug 10, 2023 at 02:37:56PM +0200, Peter Zijlstra wrote:

> After this patch things look equivalent to:
> 
> SYM_FUNC_START(foo)
> 	...
> 	ALTERNATIVE "ret; int3"
> 		    "jmp __x86_return_thunk", X86_FEATURE_RETHUNK
> 		    "jmp srso_return_thunk, X86_FEATURE_SRSO
> 		    "jmp srsi_alias_return_thunk", X86_FEATURE_SRSO_ALIAS
> SYM_FUNC_END(foo)
> 
> SYM_CODE_START(srso_return_thunk)
> 	UNWIND_HINT_FUNC
> 	ANNOTATE_NOENDBR
> 	call srso_safe_ret;
> 	ud2
> SYM_CODE_END(srso_return_thunk)
> 
> SYM_CODE_START(srso_alias_return_thunk)
> 	UNWIND_HINT_FUNC
> 	ANNOTATE_NOENDBR
> 	call srso_alias_safe_ret;
> 	ud2
> SYM_CODE_END(srso_alias_return_thunk)
> 

So it looks like the compilers are still not emitting int3 after jmp,
even with the SLS options enabled :/

This means the tail end of functions compiled with:

  -mharden-sls=all -mfunction-return=thunk-extern

Is still a regular: jmp __x86_return_thunk, no trailing trap.

  https://godbolt.org/z/Ecqv76YbE

If we all could please finally fix that, then I can rewrite the above to
effectively be:

SYM_FUNC_START(foo)
	...
	ALTERNATIVE "ret; int3"
		    "jmp __x86_return_thunk", X86_FEATURE_RETHUNK
		    "call srso_safe_ret, X86_FEATURE_SRSO
		    "call srso_alias_safe_ret", X86_FEATURE_SRSO_ALIAS
	int3 //  <--- *MISSING*
SYM_FUNC_END(foo)

Bonus points if I can compile time tell if a compiler DTRT, feature flag
or what have you in the preprocessor would be awesome.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ