Skip to content

Commit 629e052

Browse files
drmiller-cnijgunthorpe
authored andcommitted
RDMA/hfi1: Prevent panic when SDMA is disabled
If the hfi1 module is loaded with HFI1_CAP_SDMA off, a call to hfi1_write_iter() will dereference a NULL pointer and panic. A typical stack frame is: sdma_select_user_engine [hfi1] hfi1_user_sdma_process_request [hfi1] hfi1_write_iter [hfi1] do_iter_readv_writev do_iter_write vfs_writev do_writev do_syscall_64 The fix is to test for SDMA in hfi1_write_iter() and fail the I/O with EINVAL. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Douglas Miller <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 05c03df commit 629e052

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/infiniband/hw/hfi1/file_ops.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ static ssize_t hfi1_write_iter(struct kiocb *kiocb, struct iov_iter *from)
265265
unsigned long dim = from->nr_segs;
266266
int idx;
267267

268+
if (!HFI1_CAP_IS_KSET(SDMA))
269+
return -EINVAL;
268270
idx = srcu_read_lock(&fd->pq_srcu);
269271
pq = srcu_dereference(fd->pq, &fd->pq_srcu);
270272
if (!cq || !pq) {

0 commit comments

Comments
 (0)