Skip to content

Commit 201e0a7

Browse files
keesmartinkpetersen
authored andcommitted
scsi: mvumi: Replace 1-element arrays with flexible array members
One-element arrays (and multi-element arrays being treated as dynamically sized) are deprecated[1] and are being replaced with flexible array members in support of the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3. Replace one-element arrays with flexible-array member in struct mvumi_msg_frame, struct mvumi_rsp_frame, and struct mvumi_hs_header, adjusting the explicit sizing calculations at the same time. This results in no functional differences in binary output. An explicit add is now folded into the size calculation: │ mov 0x1070(%r14),%eax │ - add $0x4,%eax │ - movabs $0xfffffffdc,%rbx │ + movabs $0xfffffffe0,%rbx │ add %rax,%rbx [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays Cc: "James E.J. Bottomley" <[email protected]> Cc: "Martin K. Petersen" <[email protected]> Cc: "Gustavo A. R. Silva" <[email protected]> Cc: [email protected] Signed-off-by: Kees Cook <[email protected]> Reviewed-by: Gustavo A. R. Silva <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 45b379f commit 201e0a7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

drivers/scsi/mvumi.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1841,7 +1841,7 @@ static enum mvumi_qc_result mvumi_send_command(struct mvumi_hba *mhba,
18411841
cmd->frame->request_id = mhba->io_seq++;
18421842
cmd->request_id = cmd->frame->request_id;
18431843
mhba->tag_cmd[cmd->frame->tag] = cmd;
1844-
frame_len = sizeof(*ib_frame) - 4 +
1844+
frame_len = sizeof(*ib_frame) +
18451845
ib_frame->sg_counts * sizeof(struct mvumi_sgl);
18461846
if (mhba->hba_capability & HS_CAPABILITY_SUPPORT_DYN_SRC) {
18471847
struct mvumi_dyn_list_entry *dle;
@@ -2387,7 +2387,7 @@ static int mvumi_io_attach(struct mvumi_hba *mhba)
23872387
struct Scsi_Host *host = mhba->shost;
23882388
struct scsi_device *sdev = NULL;
23892389
int ret;
2390-
unsigned int max_sg = (mhba->ib_max_size + 4 -
2390+
unsigned int max_sg = (mhba->ib_max_size -
23912391
sizeof(struct mvumi_msg_frame)) / sizeof(struct mvumi_sgl);
23922392

23932393
host->irq = mhba->pdev->irq;

drivers/scsi/mvumi.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ struct mvumi_msg_frame {
279279
u16 request_id;
280280
u16 reserved1;
281281
u8 cdb[MAX_COMMAND_SIZE];
282-
u32 payload[1];
282+
u32 payload[];
283283
};
284284

285285
/*
@@ -294,7 +294,7 @@ struct mvumi_rsp_frame {
294294
u8 req_status;
295295
u8 rsp_flag; /* Indicates the type of Data_Payload.*/
296296
u16 request_id;
297-
u32 payload[1];
297+
u32 payload[];
298298
};
299299

300300
struct mvumi_ob_data {
@@ -380,7 +380,7 @@ struct mvumi_hs_header {
380380
u8 page_code;
381381
u8 checksum;
382382
u16 frame_length;
383-
u32 frame_content[1];
383+
u32 frame_content[];
384384
};
385385

386386
/*

0 commit comments

Comments
 (0)