From: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
To: leonro@nvidia.com, jgg@nvidia.com
Cc: linux-rdma@vger.kernel.org,
Douglas Miller <doug.miller@cornelisnetworks.com>
Subject: [PATCH for-next 2/6] RDMA/hfi1: Prevent panic when SDMA is disabled
Date: Fri, 20 May 2022 14:37:06 -0400 [thread overview]
Message-ID: <20220520183706.48973.79803.stgit@awfm-01.cornelisnetworks.com> (raw)
In-Reply-To: <20220520183516.48973.565.stgit@awfm-01.cornelisnetworks.com>
From: Douglas Miller <doug.miller@cornelisnetworks.com>
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.
Signed-off-by: Douglas Miller <doug.miller@cornelisnetworks.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
---
drivers/infiniband/hw/hfi1/file_ops.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/infiniband/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c
index 1783a6e..cb65f31 100644
--- a/drivers/infiniband/hw/hfi1/file_ops.c
+++ b/drivers/infiniband/hw/hfi1/file_ops.c
@@ -265,6 +265,9 @@ static ssize_t hfi1_write_iter(struct kiocb *kiocb, struct iov_iter *from)
unsigned long dim = from->nr_segs;
int idx;
+ if (!HFI1_CAP_IS_KSET(SDMA)) {
+ return -EINVAL;
+ }
idx = srcu_read_lock(&fd->pq_srcu);
pq = srcu_dereference(fd->pq, &fd->pq_srcu);
if (!cq || !pq) {
next prev parent reply other threads:[~2022-05-20 18:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-20 18:36 [PATCH for-next 0/6] Updates for 5.19 Dennis Dalessandro
2022-05-20 18:37 ` [PATCH for-next 1/6] RDMA/hfi1: Prevent use of lock before it is initialized Dennis Dalessandro
2022-05-20 18:37 ` Dennis Dalessandro [this message]
2022-05-20 18:37 ` [PATCH for-next 3/6] RDMA/hfi1: Fix potential integer multiplication overflow errors Dennis Dalessandro
2022-05-20 18:37 ` [PATCH for-next 4/6] RDMA/hfi1: Remove pointless driver version Dennis Dalessandro
2022-05-20 18:37 ` [PATCH for-next 5/6] RDMA/hfi1: Consolidate software versions Dennis Dalessandro
2022-05-20 18:37 ` [PATCH for-next 6/6] RDMA/hfi1: Remove all traces of diagpkt support Dennis Dalessandro
2022-05-24 18:43 ` [PATCH for-next 0/6] Updates for 5.19 Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220520183706.48973.79803.stgit@awfm-01.cornelisnetworks.com \
--to=dennis.dalessandro@cornelisnetworks.com \
--cc=doug.miller@cornelisnetworks.com \
--cc=jgg@nvidia.com \
--cc=leonro@nvidia.com \
--cc=linux-rdma@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox