Message ID | 20201209124818.25122-1-ruc_zhangxiaohui@163.com |
---|---|
State | New |
Headers | show |
Series | [v2,1/1] hisi_sas: Fix possible buffer overflows in prep_ssp_v3_hw | expand |
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 7133ca859..d02831c17 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -1267,7 +1267,9 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba, memcpy(buf_cmd, &task->ssp_task.LUN, 8); if (!tmf) { buf_cmd[9] = ssp_task->task_attr | (ssp_task->task_prio << 3); - memcpy(buf_cmd + 12, scsi_cmnd->cmnd, scsi_cmnd->cmd_len); + memcpy(buf_cmd + 12, scsi_cmnd->cmnd, + min_t(unsigned short, scsi_cmnd->cmd_len, + sizeof(__be16) + sizeof(u8) * 14)); } else { buf_cmd[10] = tmf->tmf; switch (tmf->tmf) {