lkml.org 
[lkml]   [2021]   [Jun]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] KVM: Use vmemdup_user()
On Wed, Jun 3, 2020 at 3:10 AM Denis Efremov <efremov@linux.com> wrote:
>
> Replace opencoded alloc and copy with vmemdup_user().
>
> Signed-off-by: Denis Efremov <efremov@linux.com>
> ---
> Looks like these are the only places in KVM that are suitable for
> vmemdup_user().
>
> arch/x86/kvm/cpuid.c | 17 +++++++----------
> virt/kvm/kvm_main.c | 19 ++++++++-----------
> 2 files changed, 15 insertions(+), 21 deletions(-)
>
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 901cd1fdecd9..27438a2bdb62 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -182,17 +182,14 @@ int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,
> r = -E2BIG;
> if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
> goto out;
> - r = -ENOMEM;
> if (cpuid->nent) {
> - cpuid_entries =
> - vmalloc(array_size(sizeof(struct kvm_cpuid_entry),
> - cpuid->nent));
> - if (!cpuid_entries)
> - goto out;
> - r = -EFAULT;
> - if (copy_from_user(cpuid_entries, entries,
> - cpuid->nent * sizeof(struct kvm_cpuid_entry)))
> + cpuid_entries = vmemdup_user(entries,
> + array_size(sizeof(struct kvm_cpuid_entry),
> + cpuid->nent));

Does this break memcg accounting? I ask, because I'm really not sure.

\
 
 \ /
  Last update: 2021-06-18 02:26    [W:0.176 / U:2.612 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site