Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1012761pxj; Thu, 17 Jun 2021 20:09:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4EuUDpYRZ5b8RqpcAx2At6RWFtjAP4dMBXabjYrLT9WAI9GMonRvhPo6dFUgV+SjxHLy4 X-Received: by 2002:a5d:960b:: with SMTP id w11mr6412323iol.138.1623985773388; Thu, 17 Jun 2021 20:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623985773; cv=none; d=google.com; s=arc-20160816; b=RlcikRLgvpN/QjcMXbalgNVvVHb+Xr3Ca4JEv7jDP12l5ivGcZWYfT53ovb9xVLNYW kmdZph9QEkkggOu0nnXya67mYUHM7B+CVBshOHwh904yIlBUag7OIH+KrQld8Nj3HaXv UmGORm/0i2p0VOk6M2+ccHM6FxeTaeIKjNpYOsQ7eA8BL9fu+coaXacwbME+Bg95fF4i qo7a/4moFsuMOi3CP9awomf432TO4iISw88bSgwxQPq986fRxWpzwzJDJVNI/NO7YhUD m2R2MKHfIU5QQbR+7lYegUc+CxXf9TiuMc5iXg5J2AaJTiFm5BJnVoqQlL76cJvrC6Vd 7B+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ZfOxy6B9936aDr3FkxCQBFdYz6SUIfbRHNLIvfYjoy8=; b=NWengs0pyWJ7tY94jyLT1bjwZIVcdXIRgT/TNMQeMbL9Qfu3rCef55vXDmPgM/Ib2a cA7VjlcVJsM+1xBW6gjhMcFVo5jcXZkX8k2SJ64hJSta0USiPZ4wT4GNm++mTWrL/bQ8 AagaF+VgTeoLu/5LQbhmi0h1u9O0KziVsp+pL7f8mEMYugyvyjmzsDXxOw7QwSl27NSn Rb6l6+yo9si9nB/bEMjlgnxFiwnnjAlBIGY+7u0MaOJnVAK4DZ0o7nPvtgriubldJw1K viYcbFCRoc7hGn/dUXhRcwKi+xe4LWXpkVXx6Tl0jI+3+6bFJSHHC9tspWwy663fhT3U AZ7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nJM4kjVH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i12si953619ilv.108.2021.06.17.20.09.20; Thu, 17 Jun 2021 20:09:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nJM4kjVH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233294AbhFRA13 (ORCPT + 99 others); Thu, 17 Jun 2021 20:27:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231431AbhFRA10 (ORCPT ); Thu, 17 Jun 2021 20:27:26 -0400 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19DBEC061574 for ; Thu, 17 Jun 2021 17:25:17 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id 6-20020a9d07860000b02903e83bf8f8fcso7957537oto.12 for ; Thu, 17 Jun 2021 17:25:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZfOxy6B9936aDr3FkxCQBFdYz6SUIfbRHNLIvfYjoy8=; b=nJM4kjVHo2pgFfFtO4EXrsUY7f1ptG1r+askYt8B9fLkJ0t5FtpfVarXxb0G4RvNbm 3IUVG4Tffdah3RRkw5pNSysZ9wc5VptbdR/s0lzR3B+pAXpSEH/Kqpd+1mF0Lbn2BVv0 d+4mAdo5uNNXZfFkcxkDWBG//jldV55Z3BKWj15ievJreu4qz84JVzZCuQhjafgbR2Mn 2JBkPsriy8GCg4IMaOqHIt44+9RZosuAoGT3aRQNgQYPrZWge8ef5RuxT3rLFQjYJFKI daPILzWMOKtNrcPI8wN36kS9erz9Zg3U6YSPF2+rGyxYwRXQ1OW1H58DXT1Ewz9S3c28 YYAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZfOxy6B9936aDr3FkxCQBFdYz6SUIfbRHNLIvfYjoy8=; b=qIQp9E8PmZs3cpOxstWbhgKr8tDuy7dnlI5Ye+jTlgC6NKoB8rts/wy15yQsaEmzfO Cw8NECbJ3kfFaJ9S65FIPKjlEhIze2/8gkAbWcWU6p9RaS1QtvohlFK4X/DrtcIv//kz 3yTOBzR4VBLkXC3IzZ0Fenswj7a59ELcXlfjgnG+6CHlvOVX5Mm7NDisACwULpn6wp5G yvIrNoMcVKxK2OSw92ggRdy5nMT7XcpPJO2EUfk0rn3mm83QC1N1yVDipUQJcrrp3Ui1 oQFWxkJIjqEeCzNOl3Q8EpsrDmHbwGTBLQPN/p1zujPHaosZyyeqqHPNrNWFbcPJY2MC LFbg== X-Gm-Message-State: AOAM532i5AObgSppHAVztO2C3RuuD9Ch2W8jgc8+DpgcV9fPluH/fYcO 18PENn7Xl0naoh0SIBXXtN7lGcHSXnkUnFRXdmJryA== X-Received: by 2002:a05:6830:2011:: with SMTP id e17mr6825485otp.295.1623975916039; Thu, 17 Jun 2021 17:25:16 -0700 (PDT) MIME-Version: 1.0 References: <0c00d96c46d34d69f5f459baebf3c89a507730fc.camel@perches.com> <20200603101131.2107303-1-efremov@linux.com> In-Reply-To: <20200603101131.2107303-1-efremov@linux.com> From: Jim Mattson Date: Thu, 17 Jun 2021 17:25:04 -0700 Message-ID: Subject: Re: [PATCH] KVM: Use vmemdup_user() To: Denis Efremov Cc: Paolo Bonzini , joe@perches.com, kvm list , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 3, 2020 at 3:10 AM Denis Efremov wrote: > > Replace opencoded alloc and copy with vmemdup_user(). > > Signed-off-by: Denis Efremov > --- > 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.