Patch "scsi: libsas: Fix use-after-free bug in smp_execute_task_sg()" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    scsi: libsas: Fix use-after-free bug in smp_execute_task_sg()

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     scsi-libsas-fix-use-after-free-bug-in-smp_execute_ta.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 8f4409a7756215adc8c9e08884326e5249917a68
Author: Duoming Zhou <duoming@xxxxxxxxxx>
Date:   Tue Sep 20 22:42:13 2022 +0800

    scsi: libsas: Fix use-after-free bug in smp_execute_task_sg()
    
    [ Upstream commit 46ba53c30666717cb06c2b3c5d896301cd00d0c0 ]
    
    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/20220920144213.10536-1-duoming@xxxxxxxxxx
    Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver")
    Reviewed-by: Jason Yan <yanaijie@xxxxxxxxxx>
    Signed-off-by: Duoming Zhou <duoming@xxxxxxxxxx>
    Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index c2150a818423..9ae35631135d 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -85,7 +85,7 @@ static int smp_execute_task_sg(struct domain_device *dev,
 		res = i->dft->lldd_execute_task(task, GFP_KERNEL);
 
 		if (res) {
-			del_timer(&task->slow_task->timer);
+			del_timer_sync(&task->slow_task->timer);
 			pr_notice("executing SMP task failed:%d\n", res);
 			break;
 		}



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux