# git rev-parse -q --verify 7685cf1a7140d1cd184e43c747012fa14cb3dd14^{commit} 7685cf1a7140d1cd184e43c747012fa14cb3dd14 already have revision, skipping fetch # git checkout -q -f -B kisskb 7685cf1a7140d1cd184e43c747012fa14cb3dd14 # git clean -qxdf # < git log -1 # commit 7685cf1a7140d1cd184e43c747012fa14cb3dd14 # Author: Alexey Kardashevskiy # Date: Wed Jul 11 21:00:44 2018 +1000 # # KVM: PPC: Check if IOMMU page is contained in the pinned physical page # # A VM which has: # - a DMA capable device passed through to it (eg. network card); # - running a malicious kernel that ignores H_PUT_TCE failure; # - capability of using IOMMU pages bigger that physical pages # can create an IOMMU mapping that exposes (for example) 16MB of # the host physical memory to the device when only 64K was allocated to the VM. # # The remaining 16MB - 64K will be some other content of host memory, possibly # including pages of the VM, but also pages of host kernel memory, host # programs or other VMs. # # The attacking VM does not control the location of the page it can map, # and is only allowed to map as many pages as it has pages of RAM. # # We already have a check in drivers/vfio/vfio_iommu_spapr_tce.c that # an IOMMU page is contained in the physical page so the PCI hardware won't # get access to unassigned host memory; however this check is missing in # the KVM fastpath (H_PUT_TCE accelerated code). We were lucky so far and # did not hit this yet as the very first time when the mapping happens # we do not have tbl::it_userspace allocated yet and fall back to # the userspace which in turn calls VFIO IOMMU driver, this fails and # the guest does not retry, # # This stores the smallest preregistered page size in the preregistered # region descriptor and changes the mm_iommu_xxx API to check this against # the IOMMU page size. # # This calculates maximum page size as a minimum of the natural region # alignment and compound page size. For the page shift this uses the shift # returned by find_linux_pte() which indicates how the page is mapped to # the current userspace - if the page is huge and this is not a zero, then # it is a leaf pte and the page is mapped within the range. # # Signed-off-by: Alexey Kardashevskiy # Reviewed-by: Nicholas Piggin # Reviewed-by: David Gibson # Signed-off-by: Michael Ellerman # < /opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux-gcc --version # < git log --format=%s --max-count=1 7685cf1a7140d1cd184e43c747012fa14cb3dd14 # < make -s -j 120 ARCH=powerpc O=/kisskb/build/powerpc-fixes_powerpc-randconfig_powerpc CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- randconfig KCONFIG_SEED=0x7193ABA4 # Added to kconfig CONFIG_STANDALONE=y # Added to kconfig CONFIG_BUILD_DOCSRC=n # Added to kconfig CONFIG_MODULE_SIG=n # Added to kconfig CONFIG_CPU_BIG_ENDIAN=y # Added to kconfig CONFIG_PPC64=y # Added to kconfig CONFIG_PPC_DISABLE_WERROR=y # Added to kconfig CONFIG_SECTION_MISMATCH_WARN_ONLY=y # Added to kconfig CONFIG_PREVENT_FIRMWARE_BUILD=y # Added to kconfig CONFIG_CC_STACKPROTECTOR_STRONG=n # Added to kconfig CONFIG_GCC_PLUGINS=n # Added to kconfig CONFIG_LD_HEAD_STUB_CATCH=y # Added to kconfig # yes \n | make -s -j 120 ARCH=powerpc O=/kisskb/build/powerpc-fixes_powerpc-randconfig_powerpc CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- oldconfig yes: standard output: Broken pipe yes: write error # make -s -j 120 ARCH=powerpc O=/kisskb/build/powerpc-fixes_powerpc-randconfig_powerpc CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- /kisskb/src/kernel/rcu/srcutree.c: In function 'init_srcu_struct_fields': /kisskb/src/kernel/rcu/srcutree.c:146:32: warning: 'levelspread[]' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/kernel/rcu/srcutree.c:94:6: note: 'levelspread[]' was declared here /kisskb/src/kernel/printk/printk.c: In function 'devkmsg_sysctl_set_loglvl': /kisskb/src/kernel/printk/printk.c:183:16: warning: 'old' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/kernel/cgroup/cgroup-v1.c: In function 'cgroup1_mount': /kisskb/src/kernel/cgroup/cgroup-v1.c:1256:20: warning: 'root' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/ata/ahci_qoriq.c: In function 'ahci_qoriq_hardreset': /kisskb/src/arch/powerpc/include/asm/io.h:177:1: warning: 'px_is' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/ata/ahci_qoriq.c:86:14: note: 'px_is' was declared here /kisskb/src/arch/powerpc/include/asm/io.h:177:1: warning: 'px_cmd' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/ata/ahci_qoriq.c:86:6: note: 'px_cmd' was declared here /kisskb/src/net/Makefile:24: CC cannot link executables. Skipping bpfilter. /kisskb/src/drivers/bus/fsl-mc/mc-sys.c: In function 'mc_send_command': /kisskb/src/drivers/bus/fsl-mc/mc-sys.c:88:2: warning: 'status' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/bus/fsl-mc/mc-sys.c:247:21: note: 'status' was declared here /kisskb/src/sound/hda/hdac_regmap.c: In function 'hda_reg_write': /kisskb/src/sound/hda/hdac_regmap.c:282:16: warning: 'err' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/base/regmap/regmap.c: In function '_regmap_raw_write': /kisskb/src/drivers/base/regmap/regmap.c:1819:6: warning: 'ret' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/base/regmap/regmap.c: In function 'regmap_raw_read': /kisskb/src/drivers/base/regmap/regmap.c:2497:6: warning: 'ret' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/fs/f2fs/file.c: In function 'f2fs_precache_extents': /kisskb/src/fs/f2fs/file.c:2823:6: warning: 'err' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/fs/proc/inode.c: In function 'proc_reg_open': /kisskb/src/include/linux/list.h:65:12: warning: 'pdeo' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/fs/proc/inode.c:339:21: note: 'pdeo' was declared here /kisskb/src/fs/f2fs/node.c: In function '__set_nat_cache_dirty': /kisskb/src/include/linux/list.h:93:12: warning: 'head' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/fs/f2fs/node.c:225:24: note: 'head' was declared here /kisskb/src/fs/f2fs/segment.c: In function 'f2fs_flush_sit_entries': /kisskb/src/fs/f2fs/segment.c:3461:5: warning: array subscript is below array bounds [-Warray-bounds] /kisskb/src/fs/jffs2/xattr.c: In function 'jffs2_build_xattr_subsystem': /kisskb/src/fs/jffs2/xattr.c:887:1: warning: the frame size of 1072 bytes is larger than 1024 bytes [-Wframe-larger-than=] /kisskb/src/drivers/dma-buf/reservation.c: In function 'reservation_object_add_shared_fence': /kisskb/src/drivers/dma-buf/reservation.c:207:2: warning: 'k' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/dma-buf/reservation.c:160:17: note: 'k' was declared here /kisskb/src/sound/soc/codecs/arizona.c: In function 'arizona_hw_params': /kisskb/src/sound/soc/codecs/arizona.c:1893:3: warning: 'aif_rx_state' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/sound/soc/codecs/arizona.c:1890:3: warning: 'aif_tx_state' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/sound/soc/codecs/da7219-aad.c: In function 'da7219_aad_hptest_work': /kisskb/src/sound/soc/codecs/da7219-aad.c:318:17: warning: 'pll_ctrl' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/mfd/arizona-core.c: In function 'arizona_dev_init': /kisskb/src/drivers/mfd/arizona-core.c:1404:6: warning: 'n_subdevs' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/tty/serial/8250/8250_core.c: In function 'univ8250_release_irq': /kisskb/src/drivers/tty/serial/8250/8250_core.c:251:18: warning: 'i' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/tty/serial/8250/8250_core.c:231:19: note: 'i' was declared here /kisskb/src/sound/soc/codecs/rt5665.c: In function 'rt5665_i2s_pin_event': /kisskb/src/sound/soc/codecs/rt5665.c:2666:33: warning: 'val2' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/sound/soc/codecs/rt5665.c:2663:33: warning: 'val1' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/sound/soc/codecs/wm8960.c: In function 'wm8960_configure_clocking': /kisskb/src/sound/soc/codecs/wm8960.c:803:70: warning: 'j' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/sound/soc/codecs/wm8960.c:800:68: warning: 'i' may be used uninitialized in this function [-Wuninitialized] Completed OK # rm -rf /kisskb/build/powerpc-fixes_powerpc-randconfig_powerpc # Build took: 0:01:09.254644