kernel_optimize_test/arch
Oleksandr Tyshchenko 43c8d33ce3 xen/arm: Fix race in RB-tree based P2M accounting
commit b75cd218274e01d026dc5240e86fdeb44bbed0c8 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:52:23 +02:00
..
alpha
arc
arm xen/arm: Fix race in RB-tree based P2M accounting 2022-07-07 17:52:23 +02:00
arm64 arm64: mm: Don't invalidate FROM_DEVICE buffers at start of DMA transfer 2022-06-25 15:16:09 +02:00
c6x
csky
h8300
hexagon
ia64
m68k m68knommu: fix undefined reference to `_init_sp' 2022-06-14 18:32:38 +02:00
microblaze
mips MIPS: Remove repetitive increase irq_err_count 2022-06-29 08:59:48 +02:00
nds32
nios2
openrisc
parisc parisc: Enable ARCH_HAS_STRICT_MODULE_RWX 2022-06-29 08:59:53 +02:00
powerpc powerpc/bpf: Fix use of user_pt_regs in uapi 2022-07-07 17:52:15 +02:00
riscv riscv: read-only pages should not be writable 2022-06-14 18:32:36 +02:00
s390 s390: remove unneeded 'select BUILD_BIN2C' 2022-07-07 17:52:18 +02:00
sh
sparc
um
x86 bpf, x86: Fix tail call count offset calculation on bpf2bpf call 2022-06-29 08:59:47 +02:00
xtensa xtensa: Fix refcount leak bug in time.c 2022-06-29 08:59:53 +02:00
.gitignore
Kconfig