|
|
Message-ID: <2d9aad2a-a677-40d2-c179-379fb6e9f194@zytor.com>
Date: Tue, 14 Mar 2017 02:40:51 -0700
From: "H. Peter Anvin" <hpa@...or.com>
To: Ingo Molnar <mingo@...nel.org>, Thomas Garnier <thgarnie@...gle.com>
Cc: Martin Schwidefsky <schwidefsky@...ibm.com>,
Heiko Carstens <heiko.carstens@...ibm.com>,
David Howells <dhowells@...hat.com>, Arnd Bergmann <arnd@...db.de>,
Al Viro <viro@...iv.linux.org.uk>, Dave Hansen <dave.hansen@...el.com>,
René Nyffenegger <mail@...enyffenegger.ch>,
Andrew Morton <akpm@...ux-foundation.org>,
Kees Cook
<keescook@...omium.org>,
"Paul E . McKenney" <paulmck@...ux.vnet.ibm.com>,
Andy Lutomirski <luto@...nel.org>,
Ard Biesheuvel
<ard.biesheuvel@...aro.org>,
Nicolas Pitre <nicolas.pitre@...aro.org>,
Petr Mladek <pmladek@...e.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
Helge Deller <deller@....de>, Rik van Riel <riel@...hat.com>,
John Stultz <john.stultz@...aro.org>,
Thomas Gleixner <tglx@...utronix.de>, Oleg Nesterov <oleg@...hat.com>,
Stephen Smalley <sds@...ho.nsa.gov>,
Pavel Tikhomirov <ptikhomirov@...tuozzo.com>,
Frederic Weisbecker <fweisbec@...il.com>,
Stanislav Kinsburskiy <skinsbursky@...tuozzo.com>,
Ingo Molnar <mingo@...hat.com>, Paolo Bonzini <pbonzini@...hat.com>,
Dmitry Safonov <dsafonov@...tuozzo.com>,
Borislav Petkov <bp@...en8.de>, Josh Poimboeuf <jpoimboe@...hat.com>,
Brian Gerst <brgerst@...il.com>, Jan Beulich <JBeulich@...e.com>,
Christian Borntraeger <borntraeger@...ibm.com>,
Fenghua Yu <fenghua.yu@...el.com>, He Chen <he.chen@...ux.intel.com>,
Russell King <linux@...linux.org.uk>,
Vladimir Murzin <vladimir.murzin@....com>,
Will Deacon
<will.deacon@....com>,
Catalin Marinas <catalin.marinas@....com>,
Mark Rutland <mark.rutland@....com>, James Morse <james.morse@....com>,
"David A . Long" <dave.long@...aro.org>,
Pratyush Anand <panand@...hat.com>, Laura Abbott <labbott@...hat.com>,
Andre Przywara <andre.przywara@....com>,
Chris Metcalf <cmetcalf@...lanox.com>, linux-s390@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-api@...r.kernel.org,
x86@...nel.org, linux-arm-kernel@...ts.infradead.org,
kernel-hardening@...ts.openwall.com
Subject: Re: [PATCH v3 2/4] x86/syscalls: Specific usage of
verify_pre_usermode_state
On 03/13/17 17:04, H. Peter Anvin wrote:
> On 03/11/17 01:42, Ingo Molnar wrote:
>>>
>>> + /*
>>> + * Check user-mode state on fast path return, the same check is done
>>> + * under the slow path through syscall_return_slowpath.
>>> + */
>>> +#ifdef CONFIG_BUG_ON_DATA_CORRUPTION
>>> + call verify_pre_usermode_state
>>> +#else
>>> + /*
>>> + * Similar to set_fs(USER_DS) in verify_pre_usermode_state without a
>>> + * warning.
>>> + */
>>> + movq PER_CPU_VAR(current_task), %rax
>>> + movq $TASK_SIZE_MAX, %rcx
>>> + cmp %rcx, TASK_addr_limit(%rax)
>>> + jz 1f
>>> + movq %rcx, TASK_addr_limit(%rax)
>>> +1:
>>> +#endif
>>> +
>
> How about simply doing...
>
> movq PER_CPU_VAR(current_task), %rax
> movq $TASK_SIZE_MAX, %rcx
> #ifdef CONFIG_BUG_ON_DATA_CORRUPTION
> cmpq %rcx, TASK_addr_limit(%rax)
> jne syscall_return_slowpath
> #else
> movq %rcx, TASK_addr_limit(%rax)
> #endif
>
> ... and let the slow path take care of BUG. This should be much faster,
> even with the BUG, and is simpler to boot.
>
In fact, we could even to the cmpq/jne unconditionally. I'm guessing
the occasional branch mispredict will be offset by occasionally touching
a clean cacheline in the case of an unconditional store.
Since this is something that should never happen, performance doesn't
matter.
-hpa
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.