From: Greg KH <greg@kroah.com>
To: Ovidiu Panait <ovidiu.panait@windriver.com>
Cc: stable@vger.kernel.org, pbonzini@redhat.com
Subject: Re: [PATCH 4.14 1/3] KVM: do not assume PTE is writable after follow_pfn
Date: Fri, 6 Aug 2021 08:26:41 +0200 [thread overview]
Message-ID: <YQzWIULC3KZkAcO9@kroah.com> (raw)
In-Reply-To: <20210803135521.2603575-1-ovidiu.panait@windriver.com>
On Tue, Aug 03, 2021 at 04:55:19PM +0300, Ovidiu Panait wrote:
> From: Paolo Bonzini <pbonzini@redhat.com>
>
> commit bd2fae8da794b55bf2ac02632da3a151b10e664c upstream.
>
> In order to convert an HVA to a PFN, KVM usually tries to use
> the get_user_pages family of functinso. This however is not
> possible for VM_IO vmas; in that case, KVM instead uses follow_pfn.
>
> In doing this however KVM loses the information on whether the
> PFN is writable. That is usually not a problem because the main
> use of VM_IO vmas with KVM is for BARs in PCI device assignment,
> however it is a bug. To fix it, use follow_pte and check pte_write
> while under the protection of the PTE lock. The information can
> be used to fail hva_to_pfn_remapped or passed back to the
> caller via *writable.
>
> Usage of follow_pfn was introduced in commit add6a0cd1c5b ("KVM: MMU: try to fix
> up page faults before giving up", 2016-07-05); however, even older version
> have the same issue, all the way back to commit 2e2e3738af33 ("KVM:
> Handle vma regions with no backing page", 2008-07-20), as they also did
> not check whether the PFN was writable.
>
> Fixes: 2e2e3738af33 ("KVM: Handle vma regions with no backing page")
> Reported-by: David Stevens <stevensd@google.com>
> Cc: 3pvd@google.com
> Cc: Jann Horn <jannh@google.com>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: stable@vger.kernel.org
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> [OP: backport to 4.14, adjust follow_pte() -> follow_pte_pmd()]
> Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
> ---
> virt/kvm/kvm_main.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
All now queued up, thanks.
greg k-h
prev parent reply other threads:[~2021-08-06 6:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-03 13:55 [PATCH 4.14 1/3] KVM: do not assume PTE is writable after follow_pfn Ovidiu Panait
2021-08-03 13:55 ` [PATCH 4.14 2/3] KVM: do not allow mapping valid but non-reference-counted pages Ovidiu Panait
2021-08-04 8:51 ` Paolo Bonzini
2021-08-03 13:55 ` [PATCH 4.14 3/3] KVM: Use kvm_pfn_t for local PFN variable in hva_to_pfn_remapped() Ovidiu Panait
2021-08-04 8:51 ` Paolo Bonzini
2021-08-04 8:51 ` [PATCH 4.14 1/3] KVM: do not assume PTE is writable after follow_pfn Paolo Bonzini
2021-08-06 6:26 ` Greg KH [this message]
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=YQzWIULC3KZkAcO9@kroah.com \
--to=greg@kroah.com \
--cc=ovidiu.panait@windriver.com \
--cc=pbonzini@redhat.com \
--cc=stable@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox