Skip to contentSkip to conversation

be2iscsi: set the boot_kset pointer to NULL in case of failure

PATCH Applied Maurizio Lombardi 4 participants 6 messages Mar 4, 2016 – Mar 9, 2016

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

PATCH 1/1 be2iscsi: set the boot_kset pointer to NULL in case of failure

In beiscsi_setup_boot_info(), the boot_kset pointer should be set to NULL in case of failure otherwise an invalid pointer dereference may occur later.

---
 drivers/scsi/be2iscsi/be_main.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/be2iscsi/be_main.c +1 -0
index cb9072a..069e5c5 100644
@@ -4468,6 +4468,7 @@ put_shost:
 	scsi_host_put(phba->shost);
 free_kset:
 	iscsi_boot_destroy_kset(phba->boot_kset);
+	phba->boot_kset = NULL;
 	return -ENOMEM;
 }
 
Signature · 1 line
Maurizio Lombardi
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Maurizio Lombardi

In beiscsi_setup_boot_info(), the boot_kset pointer should be set to NULL in case of failure otherwise an invalid pointer dereference may occur later.

Btw, should this go to stable as well?

Signature · 10 lines
Johannes Thumshirn                                          Storage
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reviewed-by on v1 1/1
#2 lore raw
In reply to Maurizio Lombardi
Quoted 8 lines

-----Original Message-----
From: [email protected] [mailto:linux-scsi- [email protected]] On Behalf Of Maurizio Lombardi
Sent: Friday, March 04, 2016 3:12 PM
To: [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: [PATCH] be2iscsi: set the boot_kset pointer to NULL in case of

failure

Quoted 2 lines

In beiscsi_setup_boot_info(), the boot_kset pointer should be set to NULL

in case

Review

Quoted 8 lines

of failure otherwise an invalid pointer dereference may occur later.

---
drivers/scsi/be2iscsi/be_main.c | 1 +

1 file changed, 1 insertion(+)
(quoted diff) +0 -0

b/drivers/scsi/be2iscsi/be_main.c

Quoted 11 lines

index cb9072a..069e5c5 100644

drivers/scsi/be2iscsi/be_main.c +0 -0
@@ -4468,6 +4468,7 @@ put_shost:
 	scsi_host_put(phba->shost);

free_kset:

	iscsi_boot_destroy_kset(phba->boot_kset);
drivers/scsi/be2iscsi/be_main.c +1 -0
+	phba->boot_kset = NULL;
	return -ENOMEM;
}
Quoted 5 lines

--
Maurizio Lombardi

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in

the body of

Quoted 2 lines

a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html

Thanks,

JB

#3 lore raw
In reply to Maurizio Lombardi
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Maurizio" == Maurizio Lombardi <[email protected]> writes:

Maurizio,

Maurizio> In beiscsi_setup_boot_info(), the boot_kset pointer should be Maurizio> set to NULL in case of failure otherwise an invalid pointer Maurizio> dereference may occur later.

iscsi_boot_destroy_kset() checks before deref and the other use location just checks to see whether it's NULL. Are there places in the core iSCSI code that use this without checking?

No particular problem with your patch. Just trying to decide whether it's 4.5 material or not...

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#4 lore raw
Quoted 11 lines · Martin K. Petersen
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Maurizio" == Maurizio Lombardi <[email protected]> writes:

Maurizio,

Maurizio> In beiscsi_setup_boot_info(), the boot_kset pointer should be Maurizio> set to NULL in case of failure otherwise an invalid pointer Maurizio> dereference may occur later.

iscsi_boot_destroy_kset() checks before deref and the other use location just checks to see whether it's NULL. Are there places in the core iSCSI code that use this without checking?

1) At the beginning of the beiscsi_setup_boot_info() function there is the following check:

----------
/* it has been created previously */
if (phba->boot_kset)

        return 0;

----------

If the function fails and the boot_kset pointer is not set to NULL, subsequent calls to beiscsi_setup_boot_info() will incorrectly return success because it assumes that the boot_kset pointer is valid.

2) it is true that iscsi_boot_destroy_kset() checks whether the pointer is NULL or not, but it the kset has been already destroyed and the pointer is not set to NULL, then it will dereference an invalid pointer.

Regards,
Maurizio

#5 lore raw
In reply to Maurizio Lombardi
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Maurizio" == Maurizio Lombardi <[email protected]> writes:

Maurizio> In beiscsi_setup_boot_info(), the boot_kset pointer should be Maurizio> set to NULL in case of failure otherwise an invalid pointer Maurizio> dereference may occur later.

Applied to 4.5/scsi-fixes.

Thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering