scsi: ufs: core: Improve SCSI abort handling
Subsystems (2)
PATCH 1/1 scsi: ufs: core: Improve SCSI abort handling
From: Bart Van Assche <[email protected]>
commit 3ff1f6b6ba6f97f50862aa50e79959cc8ddc2566 upstream.
The following has been observed on a test setup:
WARNING: CPU: 4 PID: 250 at drivers/scsi/ufs/ufshcd.c:2737 ufshcd_queuecommand+0x468/0x65c Call trace: ufshcd_queuecommand+0x468/0x65c scsi_send_eh_cmnd+0x224/0x6a0 scsi_eh_test_devices+0x248/0x418 scsi_eh_ready_devs+0xc34/0xe58 scsi_error_handler+0x204/0x80c kthread+0x150/0x1b4 ret_from_fork+0x10/0x30
That warning is triggered by the following statement:
WARN_ON(lrbp->cmd);
Fix this warning by clearing lrbp->cmd from the abort handler.
[ kovalev: bp to fix CVE-2021-47188; adapted placement of
lrbp->cmd = NULL for 5.10 function structure ]
--- drivers/scsi/ufs/ufshcd.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/ufs/ufshcd.c +1 -0
@@ -6788,6 +6788,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)__ufshcd_transfer_req_compl (hba, (1UL << tag));spin_unlock_irqrestore (host->host_lock, flags); out: + lrbp->cmd =NULL ; err =SUCCESS ; }else {dev_err (hba->dev,"%s: failed with err %d\n" , __func__, err);
Signature · 1 line
2.50.1
Hi Sasha,
Quoted 22 lines · Vasiliy Kovalev
From: Bart Van Assche <[email protected]>
commit
3ff1f6b6ba6f97f50862aa50e79959cc8ddc2566upstream.The following has been observed on a test setup:
WARNING: CPU: 4 PID: 250 at drivers/scsi/ufs/ufshcd.c:2737 ufshcd_queuecommand+0x468/0x65c Call trace: ufshcd_queuecommand+0x468/0x65c scsi_send_eh_cmnd+0x224/0x6a0 scsi_eh_test_devices+0x248/0x418 scsi_eh_ready_devs+0xc34/0xe58 scsi_error_handler+0x204/0x80c kthread+0x150/0x1b4 ret_from_fork+0x10/0x30That warning is triggered by the following statement:
WARN_ON(lrbp->cmd);Fix this warning by clearing
lrbp->cmdfrom the abort handler.
Quoted 8 lines
Fixes 7a3e97b0dc4b ("[SCSI] ufshcd: UFS Host controller driver")Reviewed-by Bean Huo <[email protected]>Reviewed-by Stanley Chu <[email protected]>Signed-off-by Bart Van Assche <[email protected]>Signed-off-by Martin K. Petersen <[email protected]>[ kovalev: bp to fix CVE-2021-47188; adapted placement of
lrbp->cmd= NULL for 5.10 function structure ]
Please drop this backport from the 5.10 queue — it is not needed.
After review feedback from Fedor Pchelkin, we verified that 5.10 is not affected by this bug. The upstream commit 3ff1f6b6ba6f carries an incorrect Fixes tag:
The actual regression was introduced by:
64180742605f ("scsi: ufs: Fix the SCSI abort handler") [v5.15-rc1]
which restructured ufshcd_abort() and removed the __ufshcd_transfer_req_compl() call from the successful abort path. Before that commit — and in 5.10 to this day — __ufshcd_transfer_req_compl() is always called on the successful path via the cleanup: label, and it clears lrbp->cmd. So the WARN_ON(lrbp->cmd) in ufshcd_queuecommand() cannot trigger on 5.10, and the lrbp->cmd = NULL; added by this patch would be dead code there.
64180742605f is not present in 5.10.y, therefore CVE-2021-47188 does not apply to 5.10.y.
Sorry for the noise.
Quoted 17 lines
Signed-off-by Vasiliy Kovalev <[email protected]>--- drivers/scsi/ufs/ufshcd.c | 1 + 1 file changed, 1 insertion(+)drivers/scsi/ufs/ufshcd.c +1
-0@@ -6788,6 +6788,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)__ufshcd_transfer_req_compl (hba, (1UL << tag));spin_unlock_irqrestore (host->host_lock, flags); out: + lrbp->cmd =NULL ; err =SUCCESS ; }else {dev_err (hba->dev,"%s: failed with err %d\n" , __func__, err);
Signature · 2 lines
Thanks, Vasiliy
Sasha Levin
maintainerQuoted 7 lines · Vasiliy Kovalev
Please drop this backport from the 5.10 queue — it is not needed.
After review feedback from Fedor Pchelkin, we verified that 5.10 is not affected by this bug. The upstream commit
3ff1f6b6ba6fcarries an incorrect Fixes tag [...] The actual regression was introduced by64180742605f("scsi: ufs: Fix the SCSI abort handler") [v5.15-rc1], which is not present in 5.10.
Dropped from the 5.10 queue, thanks for the heads-up and the detailed analysis.
--
Thanks,
Sasha