Skip to content

Commit 2e12ce2

Browse files
stonezdmgregkh
authored andcommitted
scsi: libsas: Fix use-after-free bug in smp_execute_task_sg()
[ Upstream commit 46ba53c ] When executing SMP task failed, the smp_execute_task_sg() calls del_timer() to delete "slow_task->timer". However, if the timer handler sas_task_internal_timedout() is running, the del_timer() in smp_execute_task_sg() will not stop it and a UAF will happen. The process is shown below: (thread 1) | (thread 2) smp_execute_task_sg() | sas_task_internal_timedout() ... | del_timer() | ... | ... sas_free_task(task) | kfree(task->slow_task) //FREE| | task->slow_task->... //USE Fix by calling del_timer_sync() in smp_execute_task_sg(), which makes sure the timer handler have finished before the "task->slow_task" is deallocated. Link: https://lore.kernel.org/r/[email protected] Fixes: 2908d77 ("[SCSI] aic94xx: new driver") Reviewed-by: Jason Yan <[email protected]> Signed-off-by: Duoming Zhou <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent c74b3d4 commit 2e12ce2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/scsi/libsas/sas_expander.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static int smp_execute_task_sg(struct domain_device *dev,
6767
res = i->dft->lldd_execute_task(task, GFP_KERNEL);
6868

6969
if (res) {
70-
del_timer(&task->slow_task->timer);
70+
del_timer_sync(&task->slow_task->timer);
7171
pr_notice("executing SMP task failed:%d\n", res);
7272
break;
7373
}

0 commit comments

Comments
 (0)