Commit 4cb9e1dd authored by James Smart's avatar James Smart Committed by Martin K. Petersen

scsi: lpfc: Fix coverity errors in fmdi attribute handling

Coverity reported a memory corruption error for the fdmi attributes
routines:

  CID 15768 [Memory Corruption] Out-of-bounds access on FDMI

Sloppy coding of the fmdi structures. In both the lpfc_fdmi_attr_def and
lpfc_fdmi_reg_port_list structures, a field was placed at the start of
payload that may have variable content. The field was given an arbitrary
type (uint32_t). The code then uses the field name to derive an address,
which it used in things such as memset and memcpy. The memset sizes or
memcpy lengths were larger than the arbitrary type, thus coverity reported
an error.

Fix by replacing the arbitrary fields with the real field structures
describing the payload.

Link: https://lore.kernel.org/r/20200128002312.16346-8-jsmart2021@gmail.comSigned-off-by: default avatarDick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: default avatarJames Smart <jsmart2021@gmail.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent a99c8074
This diff is collapsed.
......@@ -1340,25 +1340,8 @@ struct fc_rdp_res_frame {
/* lpfc_sli_ct_request defines the CT_IU preamble for FDMI commands */
#define SLI_CT_FDMI_Subtypes 0x10 /* Management Service Subtype */
/*
* Registered Port List Format
*/
struct lpfc_fdmi_reg_port_list {
uint32_t EntryCnt;
uint32_t pe; /* Variable-length array */
};
/* Definitions for HBA / Port attribute entries */
struct lpfc_fdmi_attr_def { /* Defined in TLV format */
/* Structure is in Big Endian format */
uint32_t AttrType:16;
uint32_t AttrLen:16;
uint32_t AttrValue; /* Marks start of Value (ATTRIBUTE_ENTRY) */
};
/* Attribute Entry */
struct lpfc_fdmi_attr_entry {
union {
......@@ -1369,7 +1352,13 @@ struct lpfc_fdmi_attr_entry {
} un;
};
#define LPFC_FDMI_MAX_AE_SIZE sizeof(struct lpfc_fdmi_attr_entry)
struct lpfc_fdmi_attr_def { /* Defined in TLV format */
/* Structure is in Big Endian format */
uint32_t AttrType:16;
uint32_t AttrLen:16;
/* Marks start of Value (ATTRIBUTE_ENTRY) */
struct lpfc_fdmi_attr_entry AttrValue;
} __packed;
/*
* HBA Attribute Block
......@@ -1393,13 +1382,20 @@ struct lpfc_fdmi_hba_ident {
struct lpfc_name PortName;
};
/*
* Registered Port List Format
*/
struct lpfc_fdmi_reg_port_list {
uint32_t EntryCnt;
struct lpfc_fdmi_port_entry pe;
} __packed;
/*
* Register HBA(RHBA)
*/
struct lpfc_fdmi_reg_hba {
struct lpfc_fdmi_hba_ident hi;
struct lpfc_fdmi_reg_port_list rpl; /* variable-length array */
/* struct lpfc_fdmi_attr_block ab; */
struct lpfc_fdmi_reg_port_list rpl;
};
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment