OpenCloudOS-Kernel/arch/arm
Oleksandr Tyshchenko c205cd0c5c xen/arm: Fix race in RB-tree based P2M accounting
commit b75cd21827 upstream.

During the PV driver life cycle the mappings are added to
the RB-tree by set_foreign_p2m_mapping(), which is called from
gnttab_map_refs() and are removed by clear_foreign_p2m_mapping()
which is called from gnttab_unmap_refs(). As both functions end
up calling __set_phys_to_machine_multi() which updates the RB-tree,
this function can be called concurrently.

There is already a "p2m_lock" to protect against concurrent accesses,
but the problem is that the first read of "phys_to_mach.rb_node"
in __set_phys_to_machine_multi() is not covered by it, so this might
lead to the incorrect mappings update (removing in our case) in RB-tree.

In my environment the related issue happens rarely and only when
PV net backend is running, the xen_add_phys_to_mach_entry() claims
that it cannot add new pfn <-> mfn mapping to the tree since it is
already exists which results in a failure when mapping foreign pages.

But there might be other bad consequences related to the non-protected
root reads such use-after-free, etc.

While at it, also fix the similar usage in __pfn_to_mfn(), so
initialize "struct rb_node *n" with the "p2m_lock" held in both
functions to avoid possible bad consequences.

This is CVE-2022-33744 / XSA-406.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
Reviewed-by: Alex Shi <alexsshi@tencent.com>
Reviewed-by: samuelliao <samuelliao@tencent.com>
2024-06-11 20:41:09 +08:00
..
boot ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
common ARM: scoop: Use the right include 2019-09-03 22:09:46 +02:00
configs ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
crypto ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
include ARM: report Spectre v2 status through sysfs 2024-06-11 20:41:08 +08:00
kernel ARM: fix build error when BPF_SYSCALL is disabled 2024-06-11 20:41:08 +08:00
kvm ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
lib tkernel: add base tlinux kernel interfaces 2024-06-11 20:09:33 +08:00
mach-actions
mach-alpine
mach-artpec
mach-asm9260
mach-aspeed ARM: SoC fixes 2019-09-30 10:04:28 -07:00
mach-at91 ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
mach-axxia
mach-bcm
mach-berlin
mach-clps711x
mach-cns3xxx
mach-davinci tkernel: add base tlinux kernel interfaces 2024-06-11 20:09:33 +08:00
mach-digicolor
mach-dove ARM: orion/mvebu: unify debug-ll virtual addresses 2019-08-14 19:24:58 +02:00
mach-ebsa110
mach-efm32
mach-ep93xx Merge branch 'spi-5.4' into spi-next 2019-09-15 10:32:06 +01:00
mach-exynos ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
mach-footbridge ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
mach-gemini
mach-highbank
mach-hisi
mach-imx ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
mach-integrator ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
mach-iop32x ARM: iop32x: merge everything into mach-iop32x/ 2019-08-14 15:36:22 +02:00
mach-ixp4xx ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
mach-keystone ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
mach-lpc18xx
mach-lpc32xx ARM: lpc32xx: allow multiplatform build 2019-08-15 21:34:08 +02:00
mach-mediatek
mach-meson
mach-milbeaut
mach-mmp irqchip/mmp: Mask off interrupts from other cores 2019-08-30 15:23:30 +01:00
mach-moxart
mach-mv78xx0 ARM: orion/mvebu: unify debug-ll virtual addresses 2019-08-14 19:24:58 +02:00
mach-mvebu
mach-mxs
mach-nomadik
mach-npcm tkernel: add base tlinux kernel interfaces 2024-06-11 20:09:33 +08:00
mach-nspire ARM: mach-nspire: Kill off CLCD auxdata 2019-08-13 15:48:23 +02:00
mach-omap1 ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
mach-omap2 ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
mach-orion5x ARM: orion/mvebu: unify debug-ll virtual addresses 2019-08-14 19:24:58 +02:00
mach-oxnas
mach-picoxcell
mach-prima2
mach-pxa
mach-qcom
mach-rda
mach-realview
mach-rockchip
mach-rpc ARM: riscpc: Mark expected switch fall-through 2019-08-20 19:42:48 -05:00
mach-s3c24xx ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
mach-s3c64xx ARM: s3c64xx: squash samsung_usb_phy.h into setup-usb-phy.c 2019-08-21 19:50:40 +02:00
mach-s5pv210
mach-sa1100
mach-shmobile
mach-socfpga ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
mach-spear
mach-sti
mach-stm32
mach-sunxi ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
mach-tango
mach-tegra ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
mach-u300
mach-uniphier
mach-ux500
mach-versatile
mach-vexpress tkernel: add base tlinux kernel interfaces 2024-06-11 20:09:33 +08:00
mach-vt8500
mach-zx
mach-zynq ARM: zynq: Use memcpy_toio instead of memcpy on smp bring-up 2019-08-14 09:40:43 +02:00
mm ARM: report Spectre v2 status through sysfs 2024-06-11 20:41:08 +08:00
net ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
nwfpe
oprofile
plat-omap ARM: OMAP: dma: Mark expected switch fall-throughs 2019-08-13 04:53:37 -07:00
plat-orion
plat-pxa
plat-samsung ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
plat-versatile
probes ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
tools
vdso
vfp ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
xen xen/arm: Fix race in RB-tree based P2M accounting 2024-06-11 20:41:09 +08:00
Kconfig ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
Kconfig-nommu
Kconfig.debug ARM updates for 5.4-rc1: 2019-09-22 09:39:09 -07:00
Makefile tkernel: add base tlinux kernel interfaces 2024-06-11 20:09:33 +08:00