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:	Wed, 28 Nov 2012 22:04:28 -0200
From:	Marcelo Tosatti <mtosatti@...hat.com>
To:	Xiao Guangrong <xiaoguangrong@...ux.vnet.ibm.com>
Cc:	Avi Kivity <avi@...hat.com>, Gleb Natapov <gleb@...hat.com>,
	LKML <linux-kernel@...r.kernel.org>, KVM <kvm@...r.kernel.org>
Subject: Re: [PATCH 2/2] KVM: VMX: fix memory order between loading vmcs and
 clearing vmcs

On Wed, Nov 28, 2012 at 08:54:14PM +0800, Xiao Guangrong wrote:
> vmcs->cpu indicates whether it exists on the target cpu, -1 means the vmcs
> does not exist on any vcpu
> 
> If vcpu load vmcs with vmcs.cpu = -1, it can be directly added to cpu's percpu
> list. The list can be corrupted if the cpu prefetch the vmcs's list before
> reading vmcs->cpu. Meanwhile, we should remove vmcs from the list before
> making vmcs->vcpu == -1 be visible
> 
> Signed-off-by: Xiao Guangrong <xiaoguangrong@...ux.vnet.ibm.com>
> ---
>  arch/x86/kvm/vmx.c |   17 +++++++++++++++++
>  1 files changed, 17 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 29e8f42..6056d88 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -1002,6 +1002,15 @@ static void __loaded_vmcs_clear(void *arg)
>  	if (per_cpu(current_vmcs, cpu) == loaded_vmcs->vmcs)
>  		per_cpu(current_vmcs, cpu) = NULL;
>  	list_del(&loaded_vmcs->loaded_vmcss_on_cpu_link);
> +
> +	/*
> +	 * we should ensure updating loaded_vmcs->loaded_vmcss_on_cpu_link
> +	 * is before setting loaded_vmcs->vcpu to -1 which is done in
> +	 * loaded_vmcs_init. Otherwise, other cpu can see vcpu = -1 fist
> +	 * then adds the vmcs into percpu list before it is deleted.
> +	 */
> +	smp_wmb();
> +

Neither loads nor stores are reordered with like operations (see
section 8.2.3.2 of intel's volume 3). This behaviour makes the barrier
not necessary.

However, i agree access to loaded_vmcs is not obviously safe. I can't
tell its safe with vmm_exclusive = 0 (where vcpu->cpu can change at any
time).

--
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