From: Vlastimil Babka <vbabka@suse.cz>
To: Dave Hansen <dave.hansen@intel.com>,
Nadav Amit <namit@vmware.com>,
Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
x86@kernel.org, Dave Hansen <dave.hansen@linux.intel.com>,
Nadav Amit <nadav.amit@gmail.com>,
Andi Kleen <ak@linux.intel.com>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Michal Hocko <mhocko@suse.com>,
Sean Christopherson <sean.j.christopherson@intel.com>,
Andy Lutomirski <luto@kernel.org>
Subject: Re: [PATCH] x86: use WRITE_ONCE() when setting PTEs
Date: Fri, 7 Sep 2018 16:10:57 +0200 [thread overview]
Message-ID: <a7ce97d5-5907-25a2-da14-9b2a60321677@suse.cz> (raw)
In-Reply-To: <8aef58c7-c27c-5df8-69b3-b188dd5f64e8@intel.com>
On 09/06/2018 07:21 PM, Dave Hansen wrote:
> On 09/02/2018 11:14 AM, Nadav Amit wrote:
>> When page-table entries are set, the compiler might optimize their
>> assignment by using multiple instructions to set the PTE. This might
>> turn into a security hazard if the user somehow manages to use the
>> interim PTE. L1TF does not make our lives easier, making even an interim
>> non-present PTE a security hazard.
>>
>> Using WRITE_ONCE() to set PTEs and friends should prevent this potential
>> security hazard.
>
> But, our types are already 64-bit, and we're doing a 64-bit pointer
> write. Our WRITE_ONCE() implementation boils down to:
>
> static __always_inline void __write_once_size(...
> {
> switch (size) {
> ...
> case 8: *(volatile __u64 *)p = *(__u64 *)res; break;
>
>
> For 64-bit types, which is precisely the same thing. Right?
Notice the volatile cast. While the CPU write itself is fine, the
*compiler* can decide to do partial updates; volatile forbids it.
next prev parent reply other threads:[~2018-09-07 14:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-02 18:14 [PATCH] x86: use WRITE_ONCE() when setting PTEs Nadav Amit
2018-09-06 17:21 ` Dave Hansen
2018-09-06 19:28 ` Peter Zijlstra
2018-09-07 14:10 ` Vlastimil Babka [this message]
2018-09-06 19:57 ` Peter Zijlstra
2018-09-06 20:12 ` Nadav Amit
2018-09-06 20:27 ` Peter Zijlstra
2018-09-08 10:34 ` [tip:x86/urgent] x86/mm: Use " tip-bot for Nadav Amit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a7ce97d5-5907-25a2-da14-9b2a60321677@suse.cz \
--to=vbabka@suse.cz \
--cc=ak@linux.intel.com \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=nadav.amit@gmail.com \
--cc=namit@vmware.com \
--cc=sean.j.christopherson@intel.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).