mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
scsi: scsi_debug: Fix possible UAF in sdebug_add_host_helper()
[ Upstream commite208a1d795] 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:1da177e4c3("Linux-2.6.12-rc2") Signed-off-by: Yuan Can <yuancan@huawei.com> Link: https://lore.kernel.org/r/20221117084421.58918-1-yuancan@huawei.com Acked-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
dce0589a3f
commit
aa5b8170b2
@@ -7316,8 +7316,12 @@ static int sdebug_add_host_helper(int per_host_idx)
|
|||||||
dev_set_name(&sdbg_host->dev, "adapter%d", sdebug_num_hosts);
|
dev_set_name(&sdbg_host->dev, "adapter%d", sdebug_num_hosts);
|
||||||
|
|
||||||
error = device_register(&sdbg_host->dev);
|
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;
|
goto clean;
|
||||||
|
}
|
||||||
|
|
||||||
++sdebug_num_hosts;
|
++sdebug_num_hosts;
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user