[lkml]   [2018]   [Sep]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] x86: use WRITE_ONCE() when setting PTEs
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.

 \ /
  Last update: 2018-09-07 16:11    [W:0.076 / U:2.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site