linux/arch
Oleksandr Tyshchenko 9f83c8f6ab 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>
2022-07-07 17:53:32 +02:00
..
alpha alpha: fix alloc_zeroed_user_highpage_movable() 2022-06-09 10:22:43 +02:00
arc ARC: entry: fix syscall_trace_exit argument 2022-04-27 14:39:00 +02:00
arm xen/arm: Fix race in RB-tree based P2M accounting 2022-07-07 17:53:32 +02:00
arm64 arm64: dts: ti: k3-am64-main: Remove support for HS400 speed mode 2022-06-29 09:03:30 +02:00
csky csky: patch_text: Fixup last cpu should be master 2022-06-09 10:23:26 +02:00
h8300 Merge branch 'akpm' (patches from Andrew) 2021-09-08 12:55:35 -07:00
hexagon uaccess: fix integer overflow on access_ok() 2022-03-28 09:58:45 +02:00
ia64 ia64: define get_cycles macro for arch-override 2022-05-30 09:29:12 +02:00
m68k m68knommu: fix undefined reference to `mach_get_rtc_pll' 2022-06-14 18:36:15 +02:00
microblaze uaccess: fix nios2 and microblaze get_user_8() 2022-04-08 14:23:18 +02:00
mips MIPS: Remove repetitive increase irq_err_count 2022-06-29 09:03:24 +02:00
nds32 nds32: fix access_ok() checks in get/put_user 2022-03-28 09:58:46 +02:00
nios2 nios2: use fallback for random_get_entropy() instead of zero 2022-05-30 09:29:14 +02:00
openrisc openrisc: start CPU timer early in boot 2022-06-09 10:22:38 +02:00
parisc parisc: Enable ARCH_HAS_STRICT_MODULE_RWX 2022-06-29 09:03:30 +02:00
powerpc powerpc/memhotplug: Add add_pages override for PPC 2022-07-07 17:53:28 +02:00
riscv RISC-V: use memcpy for kexec_file mode 2022-06-14 18:36:15 +02:00
s390 s390: remove unneeded 'select BUILD_BIN2C' 2022-07-07 17:53:27 +02:00
sh Documentation, arch: Remove leftovers from CIFS_WEAK_PW_HASH 2022-01-27 11:05:21 +01:00
sparc signal: Deliver SIGTRAP on perf event asynchronously if blocked 2022-06-09 10:22:48 +02:00
um um: line: Use separate IRQs per line 2022-06-14 18:36:23 +02:00
x86 x86, kvm: use proper ASM macros for kvm_vcpu_is_preempted 2022-07-02 16:41:12 +02:00
xtensa xtensa: Fix refcount leak bug in time.c 2022-06-29 09:03:29 +02:00
.gitignore
Kconfig stack: Constrain and fix stack offset randomization with Clang builds 2022-04-08 14:23:06 +02:00