Skip to contentSkip to conversation

scsi: pm8001: Replace one-element array with flexible-array member

PATCH Applied Gustavo A. R. Silva 4 participants 4 messages Sep 22, 2022 – Sep 25, 2022

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

PATCH 1/1 scsi: pm8001: Replace one-element array with flexible-array member

One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct fw_control_info.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [1].

---
 drivers/scsi/pm8001/pm8001_sas.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/pm8001/pm8001_sas.h +1 -1
index c5e3f380a01c..b08f52673889 100644
@@ -612,7 +612,7 @@ struct fw_control_info {
 	operations.*/
 	u32			reserved;/* padding required for 64 bit
 	alignment */
-	u8			buffer[1];/* Start of buffer */
+	u8			buffer[];/* Start of buffer */
 };
 struct fw_control_ex {
 	struct fw_control_info *fw_control;
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Gustavo A. R. Silva

One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct fw_control_info.

Quoted 8 lines

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [1].

Quoted 20 lines
---
 drivers/scsi/pm8001/pm8001_sas.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/pm8001/pm8001_sas.h +1 -2
index c5e3f380a01c..b08f52673889 100644
@@ -612,7 +612,7 @@ struct fw_control_info {
        operations.*/
        u32                     reserved;/* padding required for 64 bit
        alignment */
-       u8                      buffer[1];/* Start of buffer */
+       u8                      buffer[];/* Start of buffer */
 };
 struct fw_control_ex {
        struct fw_control_info *fw_control;
--

2.34.1

Reviewed-by on v1 1/1
#2 lore raw
In reply to Gustavo A. R. Silva
Quoted 3 lines · Gustavo A. R. Silva

One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct fw_control_info.

I think this changelog should include some explanation of why this change is safe. As far as I can see, it would be:

This is the only change needed; struct fw_control_info is only ever used for casting to existing allocations. No sizeof() is used on any of the resulting variables.

Quoted 8 lines

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [1].

Another one down! :)

Signature · 1 line
Kees Cook
#3 lore raw
In reply to Gustavo A. R. Silva

Gustavo,

Quoted 3 lines

One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct fw_control_info.

Applied to 6.1/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering