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]
Date:   Thu, 4 Jan 2018 00:42:30 +0100
From:   Paolo Bonzini <pbonzini@...hat.com>
To:     Andy Lutomirski <luto@...nel.org>
Cc:     LKML <linux-kernel@...r.kernel.org>, kvm list <kvm@...r.kernel.org>
Subject: Re: [PATCH v2] KVM: x86: do not read FS/GS base MSRs when saving them

On 03/01/2018 23:20, Andy Lutomirski wrote:
>> On Jan 2, 2018, at 5:59 AM, Paolo Bonzini <pbonzini@...hat.com> wrote:
>>
>> The FS and userspace GS bases are available in current->thread, while the
>> kernel GS base is a percpu variable.  Skip the expensive rdmsr and just
>> get the values from memory.
> 
> That fsbase change is wrong: thread->fsbase is not guaranteed to be
> correct for current.

Note that the value I'm storing in HOST_FS_BASE and HOST_GS_BASE is only
used if FS/GS selector is zero.  If FS/GS selector is not zero, it is
not used.  Does that avoid this issue?

Certainly worth a comment or clearer code though.

>> +#ifdef CONFIG_X86_64
>> +/* Provide the current kernel GS base.  */
>> +static inline void *get_current_kernel_gs_base(void)
>> +{
>> +    return this_cpu_ptr(irq_stack_union.gs_base);
>> +}
>> +#endif
> 
> This is an awful name because MSR_KERNEL_GS_BASE means the user gs
> base.  How about calling it something like
> get_this_cpu_kernelmode_gs_base() or similar?

True, I'll adopt your name.

Paolo

>> #ifdef CONFIG_X86_64
>> -    vmcs_writel(HOST_FS_BASE, read_msr(MSR_FS_BASE));
>> -    vmcs_writel(HOST_GS_BASE, read_msr(MSR_GS_BASE));
>> +    vmcs_writel(HOST_FS_BASE, current->thread.fsbase);
> 
> That's wrong.  thread->fsbase isn't kept up to date while the thread
> is running.  You could potentially try to expose an interface to get
> save_base_legacy() called to update it.
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ