]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: x86: Use __try_cmpxchg_user() to update guest PTE A/D bits
authorSean Christopherson <seanjc@google.com>
Wed, 2 Feb 2022 00:49:43 +0000 (00:49 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Jun 2022 06:48:55 +0000 (08:48 +0200)
commit8089e5e1d18402fb8152d6b6815450a36fffa9b0
treed1aff688ca989dc18ef2b60a8efa21495c476217
parent256ded2dbf0edcbaf4591dca64a0886dc4610b91
KVM: x86: Use __try_cmpxchg_user() to update guest PTE A/D bits

commit f122dfe4476890d60b8c679128cd2259ec96a24c upstream.

Use the recently introduced __try_cmpxchg_user() to update guest PTE A/D
bits instead of mapping the PTE into kernel address space.  The VM_PFNMAP
path is broken as it assumes that vm_pgoff is the base pfn of the mapped
VMA range, which is conceptually wrong as vm_pgoff is the offset relative
to the file and has nothing to do with the pfn.  The horrific hack worked
for the original use case (backing guest memory with /dev/mem), but leads
to accessing "random" pfns for pretty much any other VM_PFNMAP case.

Fixes: bd53cb35a3e9 ("X86/KVM: Handle PFNs outside of kernel reach when touching GPTEs")
Debugged-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Tested-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Reported-by: syzbot+6cde2282daa792c49ab8@syzkaller.appspotmail.com
Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20220202004945.2540433-4-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/mmu/paging_tmpl.h