[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191224181930.GC17176@xz-x1>
Date: Tue, 24 Dec 2019 13:19:30 -0500
From: Peter Xu <peterx@...hat.com>
To: Sean Christopherson <sean.j.christopherson@...el.com>
Cc: James Hogan <jhogan@...nel.org>,
Paul Mackerras <paulus@...abs.org>,
Christian Borntraeger <borntraeger@...ibm.com>,
Janosch Frank <frankja@...ux.ibm.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Marc Zyngier <maz@...nel.org>,
linux-arm-kernel@...ts.infradead.org,
Wanpeng Li <wanpengli@...cent.com>,
Philippe Mathieu-Daudé <f4bug@...at.org>,
kvm@...r.kernel.org, David Hildenbrand <david@...hat.com>,
Joerg Roedel <joro@...tes.org>,
Cornelia Huck <cohuck@...hat.com>, linux-mips@...r.kernel.org,
linux-kernel@...r.kernel.org, kvm-ppc@...r.kernel.org,
Vitaly Kuznetsov <vkuznets@...hat.com>,
kvmarm@...ts.cs.columbia.edu, Jim Mattson <jmattson@...gle.com>
Subject: Re: [PATCH v4 16/19] KVM: Ensure validity of memslot with respect to
kvm_get_dirty_log()
On Tue, Dec 17, 2019 at 12:40:38PM -0800, Sean Christopherson wrote:
> +int kvm_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log,
> + int *is_dirty, struct kvm_memory_slot **memslot)
> {
> struct kvm_memslots *slots;
> - struct kvm_memory_slot *memslot;
> int i, as_id, id;
> unsigned long n;
> unsigned long any = 0;
>
> + *memslot = NULL;
> + *is_dirty = 0;
> +
> as_id = log->slot >> 16;
> id = (u16)log->slot;
> if (as_id >= KVM_ADDRESS_SPACE_NUM || id >= KVM_USER_MEM_SLOTS)
> return -EINVAL;
>
> slots = __kvm_memslots(kvm, as_id);
> - memslot = id_to_memslot(slots, id);
> - if (!memslot->dirty_bitmap)
> + *memslot = id_to_memslot(slots, id);
> + if (!(*memslot)->dirty_bitmap)
> return -ENOENT;
>
> - n = kvm_dirty_bitmap_bytes(memslot);
> + kvm_arch_sync_dirty_log(kvm, *memslot);
Should this line belong to previous patch?
> +
> + n = kvm_dirty_bitmap_bytes(*memslot);
>
> for (i = 0; !any && i < n/sizeof(long); ++i)
> - any = memslot->dirty_bitmap[i];
> + any = (*memslot)->dirty_bitmap[i];
>
> - if (copy_to_user(log->dirty_bitmap, memslot->dirty_bitmap, n))
> + if (copy_to_user(log->dirty_bitmap, (*memslot)->dirty_bitmap, n))
> return -EFAULT;
>
> if (any)
> --
> 2.24.1
--
Peter Xu
Powered by blists - more mailing lists