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:   Fri, 3 Jul 2020 15:02:47 -0400
From:   Peter Xu <peterx@...hat.com>
To:     Sean Christopherson <sean.j.christopherson@...el.com>
Cc:     kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
        "Dr . David Alan Gilbert" <dgilbert@...hat.com>,
        Andrew Jones <drjones@...hat.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        "Michael S . Tsirkin" <mst@...hat.com>,
        Jason Wang <jasowang@...hat.com>,
        Kevin Tian <kevin.tian@...el.com>
Subject: Re: [PATCH v10 03/14] KVM: X86: Don't track dirty for
 KVM_SET_[TSS_ADDR|IDENTITY_MAP_ADDR]

On Thu, Jul 02, 2020 at 05:05:57PM -0700, Sean Christopherson wrote:
> >  	/* Set up identity-mapping pagetable for EPT in real mode */
> >  	for (i = 0; i < PT32_ENT_PER_PAGE; i++) {
> >  		tmp = (i << 22) + (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER |
> >  			_PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_PSE);
> > -		r = kvm_write_guest_page(kvm, identity_map_pfn,
> > -				&tmp, i * sizeof(tmp), sizeof(tmp));
> > -		if (r < 0)
> > +		r = __copy_to_user(uaddr + i * sizeof(tmp), &tmp, sizeof(tmp));
> > +		if (r) {
> > +			r = -EFAULT;
> 
> Another case where capturing the result is unnecessary.  I don't have a
> preference as to whether the result of __copy_{to,from}_user() is returned
> directly or morphed to -EFAULT, but we should be consistent, especially
> within a single patch.

OK, I'll clean all these __copy_to_user() callers in the next version.

> 
> >  			goto out;
> > +		}
> >  	}
> >  	kvm_vmx->ept_identity_pagetable_done = true;
> >  
> > @@ -3532,19 +3525,22 @@ static void seg_setup(int seg)
> >  static int alloc_apic_access_page(struct kvm *kvm)
> >  {
> >  	struct page *page;
> > -	int r = 0;
> > +	void __user *r;
> > +	int ret = 0;
> >  
> >  	mutex_lock(&kvm->slots_lock);
> >  	if (kvm->arch.apic_access_page_done)
> >  		goto out;
> >  	r = __x86_set_memory_region(kvm, APIC_ACCESS_PAGE_PRIVATE_MEMSLOT,
> >  				    APIC_DEFAULT_PHYS_BASE, PAGE_SIZE);
> 
> Naming the new 'void __user *hva' would yield a smaller differ and would
> probably help readers in the future.

OK.

> >  	} else {
> > -		if (!slot || !slot->npages)
> > -			return 0;
> > -
> >  		/*
> >  		 * Stuff a non-canonical value to catch use-after-delete.  This
> >  		 * ends up being 0 on 32-bit KVM, but there's no better
> >  		 * alternative.
> >  		 */
> >  		hva = (unsigned long)(0xdeadull << 48);
> > +
> > +		if (!slot || !slot->npages)
> > +			return (void __user *)hva;
> 
> My clever shenanigans got discarded, so this weirdness happily is gone. 

I'll see what I get when I rebase.  This series is easy to encounter conflicts
during previous rebases for misterious reasons.  I guess I'll just repost less
frequently so I suffer less from rebase too. :)

Thanks.

-- 
Peter Xu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ