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] [day] [month] [year] [list]
Message-ID: <20171225080351.GN2443@xz-mi>
Date:   Mon, 25 Dec 2017 16:03:51 +0800
From:   Peter Xu <peterx@...hat.com>
To:     Paolo Bonzini <pbonzini@...hat.com>
Cc:     David Hildenbrand <david@...hat.com>,
        Lan Tianyu <tianyu.lan@...el.com>, rkrcmar@...hat.com,
        kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
        dvyukov@...gle.com, kernellwp@...il.com
Subject: Re: [PATCH] KVM/Eventfd: Avoid crash when assign and deassign same
 eventfd in parallel.

On Mon, Dec 18, 2017 at 09:50:04AM +0100, Paolo Bonzini wrote:
> On 18/12/2017 09:30, David Hildenbrand wrote:
> > The ugly thing in kvm_irqfd_assign() is that we access irqfd without
> > holding a lock. I think that should rather be fixed than working around
> > that issue. (e.g. lock() -> lookup again -> verify still in list ->
> > unlock())
> 
> I wonder if it's even simpler:
> 
> diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
> index f2ac53ab8243..17ed298bd66f 100644
> --- a/virt/kvm/eventfd.c
> +++ b/virt/kvm/eventfd.c
> @@ -387,7 +387,6 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
>  
>  	idx = srcu_read_lock(&kvm->irq_srcu);
>  	irqfd_update(kvm, irqfd);
> -	srcu_read_unlock(&kvm->irq_srcu, idx);
>  
>  	list_add_tail(&irqfd->list, &kvm->irqfds.items);
>  
> @@ -420,10 +419,12 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
>  				irqfd->consumer.token, ret);
>  	}
>  #endif
> +	srcu_read_unlock(&kvm->irq_srcu, idx);
>  
>  	return 0;
>  
>  fail:
> +	/* irq_srcu is *not* held here.  */
>  	if (irqfd->resampler)
>  		irqfd_resampler_shutdown(irqfd);

Sorry if I miss anything important, but... should we extend the unlock
of kvm->irqfds.lock instead of kvm->irq_srcu here? AFAIU kvm->irq_srcu
is protecting accesses to kvm->irq_routing, while kvm->irqfds.lock is
the one that really protects kvm->irqfds?  Thanks,

-- 
Peter Xu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ