From: Matt Wang <matt.wang@broadcom.com>
To: vishal.bhakta@broadcom.com,
bcm-kernel-feedback-list@broadcom.com,
linux-scsi@vger.kernel.org
Cc: Matt Wang <matt.wang@broadcom.com>
Subject: scsi: vmw_pvscsi: add boundary check for cmd_map access.
Date: Wed, 30 Sep 2026 07:14:59 +0800 [thread overview]
Message-ID: <20260929231459.630938-1-matt.wang@broadcom.com> (raw)
The context value provided by the device in a completion is used to
index into cmd_map to find the command that was completed. To prevent
out of bounds access or completion of an inactive context, check that
the context value is in-bounds and that it maps to an active context.
Signed-off-by: Matt Wang <matt.wang@broadcom.com>
---
drivers/scsi/vmw_pvscsi.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
index 151cac9f9..49d1950a7 100644
--- a/drivers/scsi/vmw_pvscsi.c
+++ b/drivers/scsi/vmw_pvscsi.c
@@ -201,6 +201,9 @@ static u64 pvscsi_map_context(const struct pvscsi_adapter *adapter,
static struct pvscsi_ctx *
pvscsi_get_context(const struct pvscsi_adapter *adapter, u64 context)
{
+ if (unlikely(context == 0 || context > adapter->req_depth)) {
+ return NULL;
+ }
return &adapter->cmd_map[context - 1];
}
@@ -550,6 +553,11 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter,
u32 sdstat = e->scsiStatus;
ctx = pvscsi_get_context(adapter, e->context);
+ if (ctx == NULL || ctx->cmd == NULL) {
+ dev_err_ratelimited(&adapter->dev->dev,
+ "Can not find mapping for context %llu", e->context);
+ return;
+ }
cmd = ctx->cmd;
abort_cmp = ctx->abort_cmp;
pvscsi_unmap_buffers(adapter, ctx);
--
2.52.0
reply other threads:[~2026-09-29 23:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260929231459.630938-1-matt.wang@broadcom.com \
--to=matt.wang@broadcom.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=linux-scsi@vger.kernel.org \
--cc=vishal.bhakta@broadcom.com \
/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