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]
Message-ID: <CALMp9eR9n6N5EB-nUEJPM=e2YtE3_tQBDHj0uP3T2dcGsutSCQ@mail.gmail.com>
Date:   Fri, 18 Jun 2021 09:53:53 -0700
From:   Jim Mattson <jmattson@...gle.com>
To:     Michal Hocko <mhocko@...e.com>
Cc:     Denis Efremov <efremov@...ux.com>,
        Paolo Bonzini <pbonzini@...hat.com>, joe@...ches.com,
        kvm list <kvm@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] KVM: Use vmemdup_user()

On Thu, Jun 17, 2021 at 11:00 PM Michal Hocko <mhocko@...e.com> wrote:
>
> On Thu 17-06-21 17:25:04, Jim Mattson wrote:
> > On Wed, Jun 3, 2020 at 3:10 AM Denis Efremov <efremov@...ux.com> wrote:
> > >
> > > Replace opencoded alloc and copy with vmemdup_user().
> > >
> > > Signed-off-by: Denis Efremov <efremov@...ux.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.
>
> What do you mean by that? The original code uses plain vmalloc so the
> allocation is not memcg accounted (please note that __GFP_ACCOUNT needs
> to be specified explicitly). vmemdup_user is the same in that regards.

I asked, because I wasn't sure if plain vmalloc was accounted or not.

In any case, these allocations *should* be accounted, shouldn't they?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ