All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Gonda <pgonda@google.com>
To: kvm@vger.kernel.org
Cc: Peter Gonda <pgonda@google.com>, Greg Thelen <gthelen@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Sean Christopherson <seanjc@google.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] KVM: SEV: Clear the pages pointer in sev_unpin_memory
Date: Mon, 27 Jun 2022 09:11:23 -0700	[thread overview]
Message-ID: <20220627161123.1386853-1-pgonda@google.com> (raw)

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@google.com>
Cc: Greg Thelen <gthelen@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: kvm@vger.kernel.org
Cc: linux-kernel@vger.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;
 }
 
 static void sev_clflush_pages(struct page *pages[], unsigned long npages)
-- 
2.37.0.rc0.161.g10f37bed90-goog


             reply	other threads:[~2022-06-27 16:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-27 16:11 Peter Gonda [this message]
2022-06-27 18:10 ` [PATCH] KVM: SEV: Clear the pages pointer in sev_unpin_memory Sean Christopherson
2022-06-27 18:39   ` Peter Gonda
2022-06-27 20:57   ` Mingwei Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220627161123.1386853-1-pgonda@google.com \
    --to=pgonda@google.com \
    --cc=gthelen@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=thomas.lendacky@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.