lkml.org 
[lkml]   [2019]   [Dec]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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

\
 
 \ /
  Last update: 2019-12-24 19:20    [W:0.178 / U:4.908 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site