linux-stable/arch
Oleksandr Tyshchenko efd9826d4c 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:55:01 +02:00
..
alpha alpha: fix alloc_zeroed_user_highpage_movable() 2022-06-09 10:29:51 +02:00
arc ARC: remove redundant READ_ONCE() in cmpxchg loop 2022-04-18 14:47:05 -07:00
arm xen/arm: Fix race in RB-tree based P2M accounting 2022-07-07 17:55:01 +02:00
arm64 arm64: dts: exynos: Correct UART clocks on Exynos7885 2022-06-29 09:04:42 +02:00
csky csky: patch_text: Fixup last cpu should be master 2022-06-09 10:30:50 +02:00
h8300 Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2022-04-01 19:57:03 -07:00
hexagon ptrace: Cleanups for v5.18 2022-03-28 17:29:53 -07:00
ia64 vmcore: convert copy_oldmem_page() to take an iov_iter 2022-06-29 09:04:36 +02:00
m68k m68knommu: fix undefined reference to `mach_get_rtc_pll' 2022-06-14 18:45:03 +02:00
microblaze Kbuild updates for v5.18 2022-03-31 11:59:03 -07:00
mips vmcore: convert copy_oldmem_page() to take an iov_iter 2022-06-29 09:04:36 +02:00
nios2 nios2: use fallback for random_get_entropy() instead of zero 2022-05-30 09:24:05 +02:00
openrisc openrisc: start CPU timer early in boot 2022-06-09 10:29:44 +02:00
parisc parisc/unaligned: Fix emulate_ldw() breakage 2022-07-07 17:54:46 +02:00
powerpc powerpc/memhotplug: Add add_pages override for PPC 2022-07-07 17:54:55 +02:00
riscv vmcore: convert copy_oldmem_page() to take an iov_iter 2022-06-29 09:04:36 +02:00
s390 s390: remove unneeded 'select BUILD_BIN2C' 2022-07-07 17:54:53 +02:00
sh vmcore: convert copy_oldmem_page() to take an iov_iter 2022-06-29 09:04:36 +02:00
sparc signal: Deliver SIGTRAP on perf event asynchronously if blocked 2022-06-09 10:30:00 +02:00
um um: line: Use separate IRQs per line 2022-06-14 18:45:13 +02:00
x86 vmcore: convert copy_oldmem_page() to take an iov_iter 2022-06-29 09:04:36 +02:00
xtensa xtensa: Fix refcount leak bug in time.c 2022-06-29 09:04:40 +02:00
.gitignore
Kconfig vmalloc: replace VM_NO_HUGE_VMAP with VM_ALLOW_HUGE_VMAP 2022-04-19 12:08:57 -07:00