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: <20150304062552.GA16111@gmail.com>
Date:	Wed, 4 Mar 2015 07:25:52 +0100
From:	Ingo Molnar <mingo@...nel.org>
To:	Borislav Petkov <bp@...en8.de>
Cc:	X86 ML <x86@...nel.org>, Andy Lutomirski <luto@...capital.net>,
	LKML <linux-kernel@...r.kernel.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH v2 07/15] x86/lib/copy_user_64.S: Convert to ALTERNATIVE_2


* Borislav Petkov <bp@...en8.de> wrote:

> From: Borislav Petkov <bp@...e.de>
> 
> Use the asm macro and drop the locally grown version.

> @@ -73,9 +49,11 @@ ENTRY(_copy_to_user)
>  	jc bad_to_user
>  	cmpq TI_addr_limit(%rax),%rcx
>  	ja bad_to_user
> +	ALTERNATIVE_2 "jmp copy_user_generic_unrolled",		\
> +		      "jmp copy_user_generic_string",		\
> +		      X86_FEATURE_REP_GOOD,			\
> +		      "jmp copy_user_enhanced_fast_string",	\
> +		      X86_FEATURE_ERMS

Btw., as a future optimization, wouldn't it be useful to patch this 
function at its first instruction, i.e. to have three fully functional 
copy_user_generic_ variants and choose to jmp to one of them in the 
first instruction of the original function?

The advantage would be two-fold:

 1) right now: smart microarchitectures that are able to optimize
    jump-after-jump (and jump-after-call) targets in their branch
    target cache can do so in this case, reducing the overhead of the
    patching, possibly close to zero in the cached case.

 2) in the future: we could actually do a (limited) re-link of the
    kernel during bootup, and patch up the original copy_to_user call
    sites directly to one of the three variants. Alternatives patching
    done at the symbol level. Does current tooling allow something
    like this already?

Thanks,

	Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ