[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20231225063613.9829-1-dinghao.liu@zju.edu.cn>
Date: Mon, 25 Dec 2023 14:36:12 +0800
From: Dinghao Liu <dinghao.liu@....edu.cn>
To: dinghao.liu@....edu.cn
Cc: Sathya Prakash <sathya.prakash@...adcom.com>,
Sreekanth Reddy <sreekanth.reddy@...adcom.com>,
Suganath Prabu Subramani <suganath-prabu.subramani@...adcom.com>,
"James E.J. Bottomley" <jejb@...ux.ibm.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
MPT-FusionLinux.pdl@...adcom.com,
linux-scsi@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] scsi: mpt3sas: fix potential use-after-free in mpt3sas_base_attach
_base_allocate_memory_pools() calls _base_release_memory_pools()
to clean up memory in several error paths. However,
mpt3sas_base_attach() calls _base_release_memory_pools() again
on failure of _base_allocate_memory_pools(), which may lead to
use-after-free.
Signed-off-by: Dinghao Liu <dinghao.liu@....edu.cn>
---
drivers/scsi/mpt3sas/mpt3sas_base.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
index a75f670bf551..9be7e493e56c 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -5844,6 +5844,7 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc)
}
dma_pool_destroy(ioc->reply_post_free_array_dma_pool);
kfree(ioc->reply_post);
+ ioc->reply_post = NULL;
}
if (ioc->pcie_sgl_dma_pool) {
@@ -5854,6 +5855,7 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc)
ioc->pcie_sg_lookup[i].pcie_sgl = NULL;
}
dma_pool_destroy(ioc->pcie_sgl_dma_pool);
+ ioc->pcie_sgl_dma_pool = NULL;
}
kfree(ioc->pcie_sg_lookup);
ioc->pcie_sg_lookup = NULL;
@@ -5864,6 +5866,7 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc)
ioc->config_page));
dma_free_coherent(&ioc->pdev->dev, ioc->config_page_sz,
ioc->config_page, ioc->config_page_dma);
+ ioc->config_page = NULL;
}
kfree(ioc->hpr_lookup);
--
2.17.1
Powered by blists - more mailing lists