scsi: vmw_pvscsi: add boundary check for cmd_map access.
Subsystems (2)
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.
--- drivers/scsi/vmw_pvscsi.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/scsi/vmw_pvscsi.c +8 -0
@@ -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);
Signature · 1 line
2.52.0
Matt,
Quoted 4 lines
The context value provided by the device in a completion is used to index into
cmd_mapto 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.
Applied to 7.5/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen
Quoted 4 lines · Matt Wang
The context value provided by the device in a completion is used to index into
cmd_mapto 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.
Applied to 7.5/scsi-queue, thanks!
[1/1] scsi: vmw_pvscsi: add boundary check for cmd_map access.
https://git.kernel.org/mkp/scsi/c/6e862335a8d3
Signature · 1 line
Martin K. Petersen