Skip to contentSkip to conversation

scsi/sym53c8xx_2: Fix NULL pointer dereference in slave_destroy

PATCH In review [email protected] 1 participant 4 messages Dec 4, 2011 – Dec 24, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi/sym53c8xx_2: Fix NULL pointer dereference in slave_destroy

From: Stratos Psomadakis <[email protected]>

sym53c8xx_slave_destroy unconditionally assumes that sym53c8xx_slave_alloc has succesesfully allocated a sym_lcb. This can lead to a NULL pointer dereference (exposed by commit 4e6c82b).

---

 drivers/scsi/sym53c8xx_2/sym_glue.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/scsi/sym53c8xx_2/sym_glue.c +4 -0
index b4543f5..76432f8 100644
@@ -839,6 +839,10 @@ static void sym53c8xx_slave_destroy(struct scsi_device *sdev)
 	struct sym_lcb *lp = sym_lp(tp, sdev->lun);
 	unsigned long flags;
 
+	/* if slave_alloc returned before allocating a sym_lcb, return */
+	if (!lp)
+		return;
+
 	spin_lock_irqsave(np->s.host->host_lock, flags);
 
 	if (lp->busy_itlq || lp->busy_itl) {
Signature · 1 line
1.7.8.rc1
author Tested-by Martin von Gagern on v1 1/1
#1 lore raw
Quoted 8 lines · On 12/04/2011 02:23 AM, [email protected] wrote:

From: Stratos Psomadakis <[email protected]>

sym53c8xx_slave_destroy unconditionally assumes that sym53c8xx_slave_alloc has succesesfully allocated a sym_lcb. This can lead to a NULL pointer dereference (exposed by commit 4e6c82b).

Quoted 20 lines

---

 drivers/scsi/sym53c8xx_2/sym_glue.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/scsi/sym53c8xx_2/sym_glue.c +4 -0
index b4543f5..76432f8 100644
@@ -839,6 +839,10 @@ static void sym53c8xx_slave_destroy(struct scsi_device *sdev)
 	struct sym_lcb *lp = sym_lp(tp, sdev->lun);
 	unsigned long flags;
 
+	/* if slave_alloc returned before allocating a sym_lcb, return */
+	if (!lp)
+		return;
+
 	spin_lock_irqsave(np->s.host->host_lock, flags);
 
 	if (lp->busy_itlq || lp->busy_itl) {
Signature · 2 lines
Stratos Psomadakis
<[email protected]>
#2 lore raw
In reply to [email protected]
Quoted 18 lines · On 12/04/2011 02:23 AM, [email protected] wrote:

From: Stratos Psomadakis <[email protected]>

sym53c8xx_slave_destroy unconditionally assumes that sym53c8xx_slave_alloc has succesesfully allocated a sym_lcb. This can lead to a NULL pointer dereference (exposed by commit 4e6c82b).

---

 drivers/scsi/sym53c8xx_2/sym_glue.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/scsi/sym53c8xx_2/sym_glue.c +0 -0
index b4543f5..76432f8 100644

drivers/scsi/sym53c8xx_2/sym_glue.c static void sym53c8xx_slave_destroy(struct scsi_device *sdev) · line 848

Quoted 10 lines
drivers/scsi/sym53c8xx_2/sym_glue.c +4 -0
@@ -839,6 +839,10 @@ static void sym53c8xx_slave_destroy(struct scsi_device *sdev)
 	struct sym_lcb *lp = sym_lp(tp, sdev->lun);
 	unsigned long flags;
 
+	/* if slave_alloc returned before allocating a sym_lcb, return */
+	if (!lp)
+		return;
+
 	spin_lock_irqsave(np->s.host->host_lock, flags);
 
 	if (lp->busy_itlq || lp->busy_itl) {

Any comments/ack/nack on the patch?

Thanks,

Signature · 2 lines
Stratos Psomadakis
<[email protected]>
#3 lore raw
In reply to [email protected]
Quoted 18 lines · On 12/04/2011 02:23 AM, [email protected] wrote:

From: Stratos Psomadakis <[email protected]>

sym53c8xx_slave_destroy unconditionally assumes that sym53c8xx_slave_alloc has succesesfully allocated a sym_lcb. This can lead to a NULL pointer dereference (exposed by commit 4e6c82b).

---

 drivers/scsi/sym53c8xx_2/sym_glue.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/scsi/sym53c8xx_2/sym_glue.c +0 -0
index b4543f5..76432f8 100644

drivers/scsi/sym53c8xx_2/sym_glue.c static void sym53c8xx_slave_destroy(struct scsi_device *sdev) · line 848

Quoted 10 lines
drivers/scsi/sym53c8xx_2/sym_glue.c +4 -0
@@ -839,6 +839,10 @@ static void sym53c8xx_slave_destroy(struct scsi_device *sdev)
 	struct sym_lcb *lp = sym_lp(tp, sdev->lun);
 	unsigned long flags;
 
+	/* if slave_alloc returned before allocating a sym_lcb, return */
+	if (!lp)
+		return;
+
 	spin_lock_irqsave(np->s.host->host_lock, flags);
 
 	if (lp->busy_itlq || lp->busy_itl) {

resent (directly to the SCSI and sym53c8xx_2 maintainers)

Signature · 2 lines
Stratos Psomadakis
<[email protected]>