Skip to contentSkip to conversation

scsi: uapi: Replace 0-length array with flexible array

PATCH Applied Kees Cook 3 participants 4 messages Jan 5, 2023 – Jan 19, 2023 SCSI

v1 of 3 Applied Latest is v3 →

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 scsi: uapi: Replace 0-length array with flexible array

Zero-length arrays are deprecated[1]. Replace struct fc_bsg_host_vendor_reply's "vendor_rsp" 0-length array with a flexible array. Detected with GCC 13, using -fstrict-flex-arrays=3:

drivers/scsi/qla2xxx/qla_isr.c: In function 'qla25xx_process_bidir_status_iocb.isra':
drivers/scsi/qla2xxx/qla_isr.c:3117:54: warning: array subscript 0 is outside array bounds of '__u32[0]' {aka 'unsigned int[]'} [-Warray-bounds=]

 3117 |         bsg_reply->reply_data.vendor_reply.vendor_rsp[0] = rval;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from drivers/scsi/qla2xxx/qla_def.h:34,
                 from drivers/scsi/qla2xxx/qla_isr.c:6:
include/uapi/scsi/scsi_bsg_fc.h:219:15: note: while referencing 'vendor_rsp'
  219 |         __u32 vendor_rsp[0];
      |               ^~~~~~~~~~

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays

Cc Martin K. Petersen <[email protected]>
Cc Dan Williams <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
---
 include/uapi/scsi/scsi_bsg_fc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/scsi/scsi_bsg_fc.h +1 -1
index 7f5930801f72..5e46cf1054af 100644
@@ -216,7 +216,7 @@ struct fc_bsg_host_vendor {
  */
 struct fc_bsg_host_vendor_reply {
 	/* start of vendor response area */
-	__u32 vendor_rsp[0];
+	__DECLARE_FLEX_ARRAY(__u32, vendor_rsp);
 };
 
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Kees Cook

Zero-length arrays are deprecated[1]. Replace struct fc_bsg_host_vendor_reply's "vendor_rsp" 0-length array with a flexible array. Detected with GCC 13, using -fstrict-flex-arrays=3:

drivers/scsi/qla2xxx/qla_isr.c: In function 'qla25xx_process_bidir_status_iocb.isra':
drivers/scsi/qla2xxx/qla_isr.c:3117:54: warning: array subscript 0 is outside array bounds of '__u32[0]' {aka 'unsigned int[]'} [-Warray-bounds=]

 3117 |         bsg_reply->reply_data.vendor_reply.vendor_rsp[0] = rval;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from drivers/scsi/qla2xxx/qla_def.h:34,
                 from drivers/scsi/qla2xxx/qla_isr.c:6:
include/uapi/scsi/scsi_bsg_fc.h:219:15: note: while referencing 'vendor_rsp'
  219 |         __u32 vendor_rsp[0];
      |               ^~~~~~~~~~
Quoted 6 lines

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays

Cc Martin K. Petersen <[email protected]>
Cc Dan Williams <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>

Thanks!
--
Gustavo

Quoted 20 lines
---
 include/uapi/scsi/scsi_bsg_fc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/scsi/scsi_bsg_fc.h +1 -1
index 7f5930801f72..5e46cf1054af 100644
@@ -216,7 +216,7 @@ struct fc_bsg_host_vendor {
  */
 struct fc_bsg_host_vendor_reply {
 	/* start of vendor response area */
-	__u32 vendor_rsp[0];
+	__DECLARE_FLEX_ARRAY(__u32, vendor_rsp);
 };
 
 
Signature · 1 line
2.34.1
#2 lore raw
In reply to Kees Cook

Kees,

Quoted 3 lines

Zero-length arrays are deprecated[1]. Replace struct fc_bsg_host_vendor_reply's "vendor_rsp" 0-length array with a flexible array. Detected with GCC 13, using -fstrict-flex-arrays=3:

Applied to 6.3/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#3 lore raw
In reply to Kees Cook
Quoted 14 lines · Kees Cook

Zero-length arrays are deprecated[1]. Replace struct fc_bsg_host_vendor_reply's "vendor_rsp" 0-length array with a flexible array. Detected with GCC 13, using -fstrict-flex-arrays=3:

drivers/scsi/qla2xxx/qla_isr.c: In function 'qla25xx_process_bidir_status_iocb.isra':
drivers/scsi/qla2xxx/qla_isr.c:3117:54: warning: array subscript 0 is outside array bounds of '__u32[0]' {aka 'unsigned int[]'} [-Warray-bounds=]

 3117 |         bsg_reply->reply_data.vendor_reply.vendor_rsp[0] = rval;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from drivers/scsi/qla2xxx/qla_def.h:34,
                 from drivers/scsi/qla2xxx/qla_isr.c:6:
include/uapi/scsi/scsi_bsg_fc.h:219:15: note: while referencing 'vendor_rsp'
  219 |         __u32 vendor_rsp[0];
      |               ^~~~~~~~~~
Quoted 1 line

[...]

Applied to 6.3/scsi-queue, thanks!

[1/1] scsi: uapi: Replace 0-length array with flexible array

      https://git.kernel.org/mkp/scsi/c/64b6deadc938
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering