Skip to contentSkip to conversation

Fix lpfc oops when parsing dodgy VPD

PATCH In review Anton Blanchard 2 participants 2 messages Mar 21, 2007 – Mar 22, 2007

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

PATCH 1/1 Fix lpfc oops when parsing dodgy VPD

We have seen two cases where VPD on an emulex card has been incorrect and we end up walking off the end of memory. It looks like someone made an update (increased the length of a string) without increasing the Length field. Then we do:

	Length -= (3+i);

And since Length is unsigned it becomes very large and we loop forever in the encapsulating:

	while (Length > 0) {

If we make Length signed then we fall out of the loop and proceed on.

Its important to note we have only seen this in the lab and it may be the only two cases of this in existence, but since the rest of the code has been written to be resilient against bad VPD we may as well fix this too.

---

drivers/scsi/lpfc/lpfc_init.c +1 -1
Index: kernel/drivers/scsi/lpfc/lpfc_init.c
===================================================================
@@ -662,7 +662,7 @@
 lpfc_parse_vpd(struct lpfc_hba * phba, uint8_t * vpd, int len)
 {
 	uint8_t lenlo, lenhi;
-	uint32_t Length;
+	int Length;
 	int i, j;
 	int finished = 0;
 	int index = 0;
#1 lore raw

ACK.

To my knowledge bad VPD data had only been found on early prototypes, as they avoided the typical "manufacturing process". Regardless, we do try to be preventative about this type of thing, just in case.

Thanks

-- james s

Quoted 36 lines · Anton Blanchard

We have seen two cases where VPD on an emulex card has been incorrect and we end up walking off the end of memory. It looks like someone made an update (increased the length of a string) without increasing the Length field. Then we do:

	Length -= (3+i);

And since Length is unsigned it becomes very large and we loop forever in the encapsulating:

	while (Length > 0) {

If we make Length signed then we fall out of the loop and proceed on.

Its important to note we have only seen this in the lab and it may be the only two cases of this in existence, but since the rest of the code has been written to be resilient against bad VPD we may as well fix this too.

---

Index: kernel/drivers/scsi/lpfc/lpfc_init.c
===================================================================

drivers/scsi/lpfc/lpfc_init.c +1 -1
@@ -662,7 +662,7 @@
 lpfc_parse_vpd(struct lpfc_hba * phba, uint8_t * vpd, int len)
 {
 	uint8_t lenlo, lenhi;
-	uint32_t Length;
+	int Length;
 	int i, j;
 	int finished = 0;
 	int index = 0;