]> git.baikalelectronics.ru Git - kernel.git/commit
xen/virtio: Fix potential deadlock when accessing xen_grant_dma_devices
authorOleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Wed, 5 Oct 2022 17:48:23 +0000 (20:48 +0300)
committerJuergen Gross <jgross@suse.com>
Thu, 6 Oct 2022 06:30:13 +0000 (08:30 +0200)
commit5b105ca1b0a4da9f53a53000f347d82d86e58686
tree3237742d79ae30d18df367d2d3ce788c528f800c
parente2c732b8319b2d5061555e587ae9a74b2c8ad0df
xen/virtio: Fix potential deadlock when accessing xen_grant_dma_devices

As find_xen_grant_dma_data() is called from both interrupt and process
contexts, the access to xen_grant_dma_devices XArray must be protected
by xa_lock_irqsave to avoid deadlock scenario.
As XArray API doesn't provide xa_store_irqsave helper, call lockless
__xa_store directly and guard it externally.

Also move the storage of the XArray's entry to a separate helper.

Fixes: 47c544275c6d ("xen/grant-dma-ops: Add option to restrict memory access under Xen")
Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/20221005174823.1800761-3-olekstysh@gmail.com
Signed-off-by: Juergen Gross <jgross@suse.com>
drivers/xen/grant-dma-ops.c