Go to file
Sean Christopherson 228f45b39f Revert "KVM: x86: mmu: Add guest physical address check in translate_gpa()"
commit e7177339d7b5f9594b316842122b5fda9513d5e2 upstream.

Revert a misguided illegal GPA check when "translating" a non-nested GPA.
The check is woefully incomplete as it does not fill in @exception as
expected by all callers, which leads to KVM attempting to inject a bogus
exception, potentially exposing kernel stack information in the process.

 WARNING: CPU: 0 PID: 8469 at arch/x86/kvm/x86.c:525 exception_type+0x98/0xb0 arch/x86/kvm/x86.c:525
 CPU: 1 PID: 8469 Comm: syz-executor531 Not tainted 5.14.0-rc7-syzkaller #0
 RIP: 0010:exception_type+0x98/0xb0 arch/x86/kvm/x86.c:525
 Call Trace:
  x86_emulate_instruction+0xef6/0x1460 arch/x86/kvm/x86.c:7853
  kvm_mmu_page_fault+0x2f0/0x1810 arch/x86/kvm/mmu/mmu.c:5199
  handle_ept_misconfig+0xdf/0x3e0 arch/x86/kvm/vmx/vmx.c:5336
  __vmx_handle_exit arch/x86/kvm/vmx/vmx.c:6021 [inline]
  vmx_handle_exit+0x336/0x1800 arch/x86/kvm/vmx/vmx.c:6038
  vcpu_enter_guest+0x2a1c/0x4430 arch/x86/kvm/x86.c:9712
  vcpu_run arch/x86/kvm/x86.c:9779 [inline]
  kvm_arch_vcpu_ioctl_run+0x47d/0x1b20 arch/x86/kvm/x86.c:10010
  kvm_vcpu_ioctl+0x49e/0xe50 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3652

The bug has escaped notice because practically speaking the GPA check is
useless.  The GPA check in question only comes into play when KVM is
walking guest page tables (or "translating" CR3), and KVM already handles
illegal GPA checks by setting reserved bits in rsvd_bits_mask for each
PxE, or in the case of CR3 for loading PTDPTRs, manually checks for an
illegal CR3.  This particular failure doesn't hit the existing reserved
bits checks because syzbot sets guest.MAXPHYADDR=1, and IA32 architecture
simply doesn't allow for such an absurd MAXPHYADDR, e.g. 32-bit paging
doesn't define any reserved PA bits checks, which KVM emulates by only
incorporating the reserved PA bits into the "high" bits, i.e. bits 63:32.

Simply remove the bogus check.  There is zero meaningful value and no
architectural justification for supporting guest.MAXPHYADDR < 32, and
properly filling the exception would introduce non-trivial complexity.

This reverts commit ec7771ab47.

Fixes: ec7771ab47 ("KVM: x86: mmu: Add guest physical address check in translate_gpa()")
Cc: stable@vger.kernel.org
Reported-by: syzbot+200c08e88ae818f849ce@syzkaller.appspotmail.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210831164224.1119728-2-seanjc@google.com>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-07-05 19:13:47 +02:00
arch Revert "KVM: x86: mmu: Add guest physical address check in translate_gpa()" 2024-07-05 19:13:47 +02:00
block bio: fix page leak bio_add_hw_page failure 2024-07-05 19:13:40 +02:00
certs certs: Trigger creation of RSA module signing key if it's not an RSA key 2024-07-05 19:10:21 +02:00
crypto init: add dsm gpl source 2024-07-05 18:00:04 +02:00
Documentation lkdtm: replace SCSI_DISPATCH_CMD with SCSI_QUEUE_RQ 2024-07-05 19:12:05 +02:00
drivers tty: Fix data race between tiocsti() and flush_to_ldisc() 2024-07-05 19:13:40 +02:00
fs io_uring: IORING_OP_WRITE needs hash_reg_file set 2024-07-05 19:13:40 +02:00
include time: Handle negative seconds correctly in timespec64_to_ns() 2024-07-05 19:13:39 +02:00
init init: add dsm gpl source 2024-07-05 18:00:04 +02:00
ipc ipc/mqueue, msg, sem: avoid relying on a stack reference past its expiry 2021-05-26 12:06:54 +02:00
kernel bpf: Fix possible out of bound write in narrow load handling 2024-07-05 19:12:23 +02:00
lib lib/mpi: use kcalloc in mpi_resize 2024-07-05 19:10:07 +02:00
LICENSES LICENSES/deprecated: add Zlib license text 2020-09-16 14:33:49 +02:00
mm mm/page_alloc: speed up the iteration of max_order 2024-07-05 19:06:11 +02:00
net ipv4: fix endianness issue in inet_rtm_getroute_build_skb() 2024-07-05 19:13:33 +02:00
samples samples: pktgen: add missing IPv6 option to pktgen scripts 2024-07-05 19:11:56 +02:00
scripts scripts/tracing: fix the bug that can't parse raw_trace_func 2024-07-05 18:52:27 +02:00
security bpf: Add lockdown check for probe_write_user helper 2024-07-05 18:53:10 +02:00
sound ASoC: rt5682: Remove unused variable in rt5682_i2c_remove() 2024-07-05 19:13:39 +02:00
SynoBuildConf init: add dsm gpl source 2024-07-05 18:00:04 +02:00
synology init: add dsm gpl source 2024-07-05 18:00:04 +02:00
tools libbpf: Re-build libbpf.so when libbpf.map changes 2024-07-05 19:11:56 +02:00
usr Merge branch 'work.fdpic' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2020-08-07 13:29:39 -07:00
virt KVM: Do not leak memory for duplicate debugfs directories 2024-07-05 18:52:31 +02:00
.clang-format init: add dsm gpl source 2024-07-05 18:00:04 +02:00
.cocciconfig scripts: add Linux .cocciconfig for coccinelle 2016-07-22 12:13:39 +02:00
.get_maintainer.ignore Opt out of scripts/get_maintainer.pl 2019-05-16 10:53:40 -07:00
.gitattributes .gitattributes: use 'dts' diff driver for dts files 2019-12-04 19:44:11 -08:00
.gitignore kbuild: generate Module.symvers only when vmlinux exists 2021-05-19 10:12:59 +02:00
.mailmap mailmap: add two more addresses of Uwe Kleine-König 2020-12-06 10:19:07 -08:00
COPYING COPYING: state that all contributions really are covered by this file 2020-02-10 13:32:20 -08:00
CREDITS MAINTAINERS: Move Jason Cooper to CREDITS 2020-11-30 10:20:34 +01:00
Kbuild kbuild: rename hostprogs-y/always to hostprogs/always-y 2020-02-04 01:53:07 +09:00
Kconfig kbuild: ensure full rebuild when the compiler is updated 2020-05-12 13:28:33 +09:00
MAINTAINERS init: add dsm gpl source 2024-07-05 18:00:04 +02:00
Makefile init: add dsm gpl source 2024-07-05 18:00:04 +02:00
README Drop all 00-INDEX files from Documentation/ 2018-09-09 15:08:58 -06:00

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.