lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <200707272327.57356.jesper.juhl@gmail.com>
Date:	Fri, 27 Jul 2007 23:27:57 +0200
From:	Jesper Juhl <jesper.juhl@...il.com>
To:	linux-scsi@...r.kernel.org
Cc:	Luben Tuikov <luben_tuikov@...ptec.com>,
	James Bottomley <James.Bottomley@...eleye.com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Jesper Juhl <jesper.juhl@...il.com>
Subject: [PATCH][sas] Fix potential NULL pointer dereference bug in sas_smp_get_phy_events()

Hello,

In sas_smp_get_phy_events() we never test if the call to 
alloc_smp_req(RPEL_REQ_SIZE) succeeds or fails. That means we run 
the risk of dereferencing a NULL pointer if it does fail. Far 
better to test if we got NULL back and in that case return -ENOMEM 
just as we already do for the other memory allocation in that 
function.
This patch reworks the memory allocation a bit to deal with it 
(compile tested only).


Signed-off-by: Jesper Juhl <jesper.juhl@...il.com>
---

 drivers/scsi/libsas/sas_expander.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index b500f0c..85f5145 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -507,14 +507,21 @@ static int sas_dev_present_in_domain(struct asd_sas_port *port,
 int sas_smp_get_phy_events(struct sas_phy *phy)
 {
 	int res;
+	u8 *req;
+	u8 *resp;
 	struct sas_rphy *rphy = dev_to_rphy(phy->dev.parent);
 	struct domain_device *dev = sas_find_dev_by_rphy(rphy);
-	u8 *req = alloc_smp_req(RPEL_REQ_SIZE);
-	u8 *resp = kzalloc(RPEL_RESP_SIZE, GFP_KERNEL);
 
+	resp = kzalloc(RPEL_RESP_SIZE, GFP_KERNEL);
 	if (!resp)
 		return -ENOMEM;
 
+	req = alloc_smp_req(RPEL_REQ_SIZE);
+	if (!req) {
+        	res = -ENOMEM;
+		goto out;
+	}
+
 	req[1] = SMP_REPORT_PHY_ERR_LOG;
 	req[9] = phy->number;
 





  PS. Please keep me on Cc when replying.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ