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] [day] [month] [year] [list]
Message-ID: <CAL715WKEUYRFf2n9Gjx_n7oD1gRUVG1t73CNrS416YDWyKtV1A@mail.gmail.com>
Date:   Mon, 27 Jun 2022 13:57:48 -0700
From:   Mingwei Zhang <mizhang@...gle.com>
To:     Sean Christopherson <seanjc@...gle.com>
Cc:     Peter Gonda <pgonda@...gle.com>, kvm <kvm@...r.kernel.org>,
        Greg Thelen <gthelen@...gle.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Tom Lendacky <thomas.lendacky@....com>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] KVM: SEV: Clear the pages pointer in sev_unpin_memory

On Mon, Jun 27, 2022 at 1:37 PM Sean Christopherson <seanjc@...gle.com> wrote:
>
> On Mon, Jun 27, 2022, Peter Gonda wrote:
> > Clear to the @pages array pointer in sev_unpin_memory to avoid leaving a
> > dangling pointer to invalid memory.
> >
> > Signed-off-by: Peter Gonda <pgonda@...gle.com>
> > Cc: Greg Thelen <gthelen@...gle.com>
> > Cc: Paolo Bonzini <pbonzini@...hat.com>
> > Cc: Sean Christopherson <seanjc@...gle.com>
> > Cc: Tom Lendacky <thomas.lendacky@....com>
> > Cc: kvm@...r.kernel.org
> > Cc: linux-kernel@...r.kernel.org
> > ---
> >  arch/x86/kvm/svm/sev.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> > index 309bcdb2f929..485ad86c01c6 100644
> > --- a/arch/x86/kvm/svm/sev.c
> > +++ b/arch/x86/kvm/svm/sev.c
> > @@ -452,6 +452,7 @@ static void sev_unpin_memory(struct kvm *kvm, struct page **pages,
> >       unpin_user_pages(pages, npages);
> >       kvfree(pages);
> >       sev->pages_locked -= npages;
> > +     *pages = NULL;
>
> Would this have helped detect a real bug?  I generally like cleaning up, but this
> leaves things in a somewhat inconsistent state, e.g. when unpinning a kvm_enc_region,
> pages will be NULL but npages will be non-zero.  It's somewhat moot because the
> region is immediately freed in that case, but that begs the question of what real
> benefit this provides.  sev_dbg_crypt() is the only flow where there's much danger
> of a use-after-free.

+1

We could send thousands of patches like this. But I think none of them
would be directly helpful. Sometimes, things could be even worse,
i.e., imagine when those NULL pointers got deferenced, they become
BUG_ON(true).

If there are bugs related with those pointers, better to fix those bugs instead.

Thanks.
-Mingwei

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ