Skip to content

Commit f5779b5

Browse files
Justin Teemartinkpetersen
authored andcommitted
scsi: lpfc: Fix possible file string name overflow when updating firmware
Because file_name and phba->ModelName are both declared a size 80 bytes, the extra ".grp" file extension could cause an overflow into file_name. Define a ELX_FW_NAME_SIZE macro with value 84. 84 incorporates the 4 extra characters from ".grp". file_name is changed to be declared as a char and initialized to zeros i.e. null chars. Signed-off-by: Justin Tee <justin.tee@broadcom.com> Link: https://lore.kernel.org/r/20231031191224.150862-3-justintee8345@gmail.com Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 2fe4b6a commit f5779b5

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/scsi/lpfc/lpfc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
struct lpfc_sli2_slim;
3434

3535
#define ELX_MODEL_NAME_SIZE 80
36+
#define ELX_FW_NAME_SIZE 84
3637

3738
#define LPFC_PCI_DEV_LP 0x1
3839
#define LPFC_PCI_DEV_OC 0x2

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14721,7 +14721,7 @@ lpfc_write_firmware(const struct firmware *fw, void *context)
1472114721
int
1472214722
lpfc_sli4_request_firmware_update(struct lpfc_hba *phba, uint8_t fw_upgrade)
1472314723
{
14724-
uint8_t file_name[ELX_MODEL_NAME_SIZE];
14724+
char file_name[ELX_FW_NAME_SIZE] = {0};
1472514725
int ret;
1472614726
const struct firmware *fw;
1472714727

@@ -14730,7 +14730,7 @@ lpfc_sli4_request_firmware_update(struct lpfc_hba *phba, uint8_t fw_upgrade)
1473014730
LPFC_SLI_INTF_IF_TYPE_2)
1473114731
return -EPERM;
1473214732

14733-
snprintf(file_name, ELX_MODEL_NAME_SIZE, "%s.grp", phba->ModelName);
14733+
scnprintf(file_name, sizeof(file_name), "%s.grp", phba->ModelName);
1473414734

1473514735
if (fw_upgrade == INT_FW_UPGRADE) {
1473614736
ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_UEVENT,

0 commit comments

Comments
 (0)