aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Bottomley <James.Bottomley@HansenPartnership.com>2015-12-11 12:16:38 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2015-12-11 14:05:57 -0500
commit5e1033561da1152c57b97ee84371dba2b3d64c25 (patch)
treeabae723dc0851525794fcfa5d75691fbdb33ff09
parent3417c1b5cb1fdc10261dbed42b05cc93166a78fd (diff)
ses: fix additional element traversal bug
KASAN found that our additional element processing scripts drop off the end of the VPD page into unallocated space. The reason is that not every element has additional information but our traversal routines think they do, leading to them expecting far more additional information than is present. Fix this by adding a gate to the traversal routine so that it only processes elements that are expected to have additional information (list is in SES-2 section 6.1.13.1: Additional Element Status diagnostic page overview) Reported-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com> Tested-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com> Cc: stable@vger.kernel.org Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r--drivers/scsi/ses.c10
-rw-r--r--include/linux/enclosure.h4
2 files changed, 13 insertions, 1 deletions
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index 7d9cec50b77d..044d06410d4c 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -559,7 +559,15 @@ static void ses_enclosure_data_process(struct enclosure_device *edev,
559 if (desc_ptr) 559 if (desc_ptr)
560 desc_ptr += len; 560 desc_ptr += len;
561 561
562 if (addl_desc_ptr) 562 if (addl_desc_ptr &&
563 /* only find additional descriptions for specific devices */
564 (type_ptr[0] == ENCLOSURE_COMPONENT_DEVICE ||
565 type_ptr[0] == ENCLOSURE_COMPONENT_ARRAY_DEVICE ||
566 type_ptr[0] == ENCLOSURE_COMPONENT_SAS_EXPANDER ||
567 /* these elements are optional */
568 type_ptr[0] == ENCLOSURE_COMPONENT_SCSI_TARGET_PORT ||
569 type_ptr[0] == ENCLOSURE_COMPONENT_SCSI_INITIATOR_PORT ||
570 type_ptr[0] == ENCLOSURE_COMPONENT_CONTROLLER_ELECTRONICS))
563 addl_desc_ptr += addl_desc_ptr[1] + 2; 571 addl_desc_ptr += addl_desc_ptr[1] + 2;
564 572
565 } 573 }
diff --git a/include/linux/enclosure.h b/include/linux/enclosure.h
index 7be22da321f3..a4cf57cd0f75 100644
--- a/include/linux/enclosure.h
+++ b/include/linux/enclosure.h
@@ -29,7 +29,11 @@
29/* A few generic types ... taken from ses-2 */ 29/* A few generic types ... taken from ses-2 */
30enum enclosure_component_type { 30enum enclosure_component_type {
31 ENCLOSURE_COMPONENT_DEVICE = 0x01, 31 ENCLOSURE_COMPONENT_DEVICE = 0x01,
32 ENCLOSURE_COMPONENT_CONTROLLER_ELECTRONICS = 0x07,
33 ENCLOSURE_COMPONENT_SCSI_TARGET_PORT = 0x14,
34 ENCLOSURE_COMPONENT_SCSI_INITIATOR_PORT = 0x15,
32 ENCLOSURE_COMPONENT_ARRAY_DEVICE = 0x17, 35 ENCLOSURE_COMPONENT_ARRAY_DEVICE = 0x17,
36 ENCLOSURE_COMPONENT_SAS_EXPANDER = 0x18,
33}; 37};
34 38
35/* ses-2 common element status */ 39/* ses-2 common element status */