No description
Find a file
Eric Ren dc2654a2e8 KVM: arm64: vgic: Fix exit condition in scan_its_table()
commit c000a26071 upstream.

With some PCIe topologies, restoring a guest fails while
parsing the ITS device tables.

Reproducer hints:
1. Create ARM virt VM with pxb-pcie bus which adds
   extra host bridges, with qemu command like:

```
  -device pxb-pcie,bus_nr=8,id=pci.x,numa_node=0,bus=pcie.0 \
  -device pcie-root-port,..,bus=pci.x \
  ...
  -device pxb-pcie,bus_nr=37,id=pci.y,numa_node=1,bus=pcie.0 \
  -device pcie-root-port,..,bus=pci.y \
  ...

```
2. Ensure the guest uses 2-level device table
3. Perform VM migration which calls save/restore device tables

In that setup, we get a big "offset" between 2 device_ids,
which makes unsigned "len" round up a big positive number,
causing the scan loop to continue with a bad GPA. For example:

1. L1 table has 2 entries;
2. and we are now scanning at L2 table entry index 2075 (pointed
   to by L1 first entry)
3. if next device id is 9472, we will get a big offset: 7397;
4. with unsigned 'len', 'len -= offset * esz', len will underflow to a
   positive number, mistakenly into next iteration with a bad GPA;
   (It should break out of the current L2 table scanning, and jump
   into the next L1 table entry)
5. that bad GPA fails the guest read.

Fix it by stopping the L2 table scan when the next device id is
outside of the current table, allowing the scan to continue from
the next L1 table entry.

Thanks to Eric Auger for the fix suggestion.

Fixes: 920a7a8fa9 ("KVM: arm64: vgic-its: Add infrastructure for tableookup")
Suggested-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Eric Ren <renzhengeek@gmail.com>
[maz: commit message tidy-up]
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/d9c3a564af9e2c5bf63f48a7dcbf08cd593c5c0b.1665802985.git.renzhengeek@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-10-29 10:08:30 +02:00
arch KVM: arm64: vgic: Fix exit condition in scan_its_table() 2022-10-29 10:08:30 +02:00
block blk-wbt: fix that 'rwb->wc' is always set to 1 in wbt_init() 2022-10-21 12:39:28 +02:00
certs
crypto
Documentation x86/apic: Don't disable x2APIC if locked 2022-10-21 12:39:07 +02:00
drivers drm/amdgpu: fix sdma doorbell init ordering on APUs 2022-10-29 10:08:30 +02:00
fs smb3: interface count displayed incorrectly 2022-10-29 10:08:29 +02:00
include kvm: Add support for arch compat vm ioctls 2022-10-29 10:08:30 +02:00
init
io_uring io-wq: Fix memory leak in worker creation 2022-10-26 12:22:57 +02:00
ipc
kernel gcov: support GCC 12.1 and newer compilers 2022-10-26 12:22:57 +02:00
lib lib/Kconfig.debug: Add check for non-constant .{s,u}leb128 support to DWARF5 2022-10-21 12:39:29 +02:00
LICENSES
mm mm,hugetlb: take hugetlb_lock before decrementing h->resv_huge_pages 2022-10-29 10:08:30 +02:00
net net: flag sockets supporting msghdr originated zerocopy 2022-10-26 12:22:56 +02:00
samples
scripts kbuild: rpm-pkg: fix breakage when V=1 is used 2022-10-21 12:39:01 +02:00
security selinux: enable use of both GFP_KERNEL and GFP_ATOMIC in convert_context() 2022-10-29 10:08:29 +02:00
sound Revert "ALSA: hda: Fix page fault in snd_hda_codec_shutdown()" 2022-10-26 12:22:57 +02:00
tools perf intel-pt: Fix system_wide dummy event for hybrid 2022-10-21 12:39:26 +02:00
usr
virt kvm: Add support for arch compat vm ioctls 2022-10-29 10:08:30 +02:00
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile Linux 6.0.5 2022-10-26 12:53:32 +02:00
README

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.