Patch "scsi: scsi_debug: Fix possible UAF in sdebug_add_host_helper()" has been added to the 5.10-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: scsi_debug: Fix possible UAF in sdebug_add_host_helper()

to the 5.10-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-scsi_debug-fix-possible-uaf-in-sdebug_add_host_.patch
and it can be found in the queue-5.10 subdirectory.

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



commit c90d2940b92e49636babe1f48200bf6096c21de3
Author: Yuan Can <yuancan@xxxxxxxxxx>
Date:   Thu Nov 17 08:44:21 2022 +0000

    scsi: scsi_debug: Fix possible UAF in sdebug_add_host_helper()
    
    [ Upstream commit e208a1d795a08d1ac0398c79ad9c58106531bcc5 ]
    
    If device_register() fails in sdebug_add_host_helper(), it will goto clean
    and sdbg_host will be freed, but sdbg_host->host_list will not be removed
    from sdebug_host_list, then list traversal may cause UAF. Fix it.
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Yuan Can <yuancan@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20221117084421.58918-1-yuancan@xxxxxxxxxx
    Acked-by: Douglas Gilbert <dgilbert@xxxxxxxxxxxx>
    Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 5eb959b5f701..261b915835b4 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -7079,8 +7079,12 @@ static int sdebug_add_host_helper(int per_host_idx)
 	dev_set_name(&sdbg_host->dev, "adapter%d", sdebug_num_hosts);
 
 	error = device_register(&sdbg_host->dev);
-	if (error)
+	if (error) {
+		spin_lock(&sdebug_host_list_lock);
+		list_del(&sdbg_host->host_list);
+		spin_unlock(&sdebug_host_list_lock);
 		goto clean;
+	}
 
 	++sdebug_num_hosts;
 	return 0;



[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