kernel_samsung_a53x/drivers/infiniband/hw
Chengfeng Ye 9bf65b3f0d IB/hfi1: Fix potential deadlock on &irq_src_lock and &dd->uctxt_lock
[ Upstream commit 2f19c4b8395ccb6eb25ccafee883c8cfbe3fc193 ]

handle_receive_interrupt_napi_sp() running inside interrupt handler
could introduce inverse lock ordering between &dd->irq_src_lock
and &dd->uctxt_lock, if read_mod_write() is preempted by the isr.

          [CPU0]                                        |          [CPU1]
hfi1_ipoib_dev_open()                                   |
--> hfi1_netdev_enable_queues()                         |
--> enable_queues(rx)                                   |
--> hfi1_rcvctrl()                                      |
--> set_intr_bits()                                     |
--> read_mod_write()                                    |
--> spin_lock(&dd->irq_src_lock)                        |
                                                        | hfi1_poll()
                                                        | --> poll_next()
                                                        | --> spin_lock_irq(&dd->uctxt_lock)
                                                        |
                                                        | --> hfi1_rcvctrl()
                                                        | --> set_intr_bits()
                                                        | --> read_mod_write()
                                                        | --> spin_lock(&dd->irq_src_lock)
<interrupt>                                             |
   --> handle_receive_interrupt_napi_sp()               |
   --> set_all_fastpath()                               |
   --> hfi1_rcd_get_by_index()                          |
   --> spin_lock_irqsave(&dd->uctxt_lock)               |

This flaw was found by an experimental static analysis tool I am
developing for irq-related deadlock.

To prevent the potential deadlock, the patch use spin_lock_irqsave()
on &dd->irq_src_lock inside read_mod_write() to prevent the possible
deadlock scenario.

Signed-off-by: Chengfeng Ye <dg573847474@gmail.com>
Link: https://lore.kernel.org/r/20230926101116.2797-1-dg573847474@gmail.com
Acked-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-23 23:20:45 +01:00
..
bnxt_re bnxt_re: Fix imm_data endianness 2024-11-23 23:20:11 +01:00
cxgb4 RDMA/cxgb4: Check skb value for failure to allocate 2024-11-08 11:24:52 +01:00
efa Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hfi1 IB/hfi1: Fix potential deadlock on &irq_src_lock and &dd->uctxt_lock 2024-11-23 23:20:45 +01:00
hns RDMA/hns: Fix missing pagesize and alignment check in FRMR 2024-11-23 23:20:11 +01:00
i40iw RDMA/irdma: Prevent zero-length STAG registration 2024-11-18 12:10:54 +01:00
mlx4 RDMA/mlx4: Fix truncated output warning in alias_GUID.c 2024-11-23 23:20:10 +01:00
mlx5 RDMA/mlx5: Add check for srq max_sge attribute 2024-11-19 14:19:09 +01:00
mthca RDMA/usnic: Silence uninitialized symbol smatch warnings 2024-11-18 12:12:38 +01:00
ocrdma Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
qedr RDMA/qedr: Fix qedr_create_user_qp error flow 2024-11-18 22:25:39 +01:00
qib Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
usnic Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vmw_pvrdma Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00