Skip to contentSkip to conversation

carl9170: Replace zero-length array of trailing structs with flex-array

PATCH In review Kees Cook 4 participants 6 messages Nov 18, 2022 – Nov 25, 2022

Subsystems (3)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 carl9170: Replace zero-length array of trailing structs with flex-array

Zero-length arrays 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 zero-length array with flexible-array member.

This results in no differences in binary output.

[1] https://github.com/KSPP/linux/issues/78

Cc Christian Lamparter <[email protected]>
Cc Kalle Valo <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
---
 drivers/net/wireless/ath/carl9170/fwcmd.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/carl9170/fwcmd.h +2 -2
index 4a500095555c..ff4b3b50250c 100644
@@ -118,10 +118,10 @@ struct carl9170_reg_list {
 } __packed;
 
 struct carl9170_write_reg {
-	struct {
+	DECLARE_FLEX_ARRAY(struct {
 		__le32		addr;
 		__le32		val;
-	} regs[0] __packed;
+	} __packed, regs);
 } __packed;
 
 struct carl9170_write_reg_byte {
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Kees Cook

Zero-length arrays 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 zero-length array with flexible-array member.

This results in no differences in binary output.

[1] https://github.com/KSPP/linux/issues/78

Quoted 10 lines
Cc Christian Lamparter <[email protected]>
Cc Kalle Valo <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>

Another sneaky one. :p

Thanks!
--
Gustavo

Quoted 24 lines
---
 drivers/net/wireless/ath/carl9170/fwcmd.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/carl9170/fwcmd.h +2 -2
index 4a500095555c..ff4b3b50250c 100644
@@ -118,10 +118,10 @@ struct carl9170_reg_list {
 } __packed;
 
 struct carl9170_write_reg {
-	struct {
+	DECLARE_FLEX_ARRAY(struct {
 		__le32		addr;
 		__le32		val;
-	} regs[0] __packed;
+	} __packed, regs);
 } __packed;
 
 struct carl9170_write_reg_byte {
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#2 lore raw
In reply to Kees Cook
Quoted 11 lines · Kees Cook

Zero-length arrays 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 zero-length array with flexible-array member.

This results in no differences in binary output.

[1] https://github.com/KSPP/linux/issues/78

Quoted 10 lines
Cc Christian Lamparter <[email protected]>
Cc Kalle Valo <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Quoted 21 lines
---
  drivers/net/wireless/ath/carl9170/fwcmd.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/carl9170/fwcmd.h +2 -2
index 4a500095555c..ff4b3b50250c 100644
@@ -118,10 +118,10 @@ struct carl9170_reg_list {
  } __packed;
 
  struct carl9170_write_reg {
-	struct {
+	DECLARE_FLEX_ARRAY(struct {
  		__le32		addr;
  		__le32		val;
-	} regs[0] __packed;
+	} __packed, regs);
  } __packed;
 
  struct carl9170_write_reg_byte {
#3 lore raw
In reply to Kees Cook
Quoted 11 lines · Kees Cook

Zero-length arrays 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 zero-length array with flexible-array member.

This results in no differences in binary output.

[1] https://github.com/KSPP/linux/issues/78

Quoted 10 lines
Cc Christian Lamparter <[email protected]>
Cc Kalle Valo <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>

Nowadays we include "wifi:" in the subject, but I can add that. But please use this in the future for all wireless patches.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
author
#4 lore raw
Quoted 24 lines · Kalle Valo
Quoted 11 lines · Kees Cook

Zero-length arrays 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 zero-length array with flexible-array member.

This results in no differences in binary output.

[1] https://github.com/KSPP/linux/issues/78

Quoted 10 lines
Cc Christian Lamparter <[email protected]>
Cc Kalle Valo <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Quoted 2 lines

Nowadays we include "wifi:" in the subject, but I can add that. But please use this in the future for all wireless patches.

Okay, thanks! I use a recency/frequency prefix guesser, but I've updated it to include "wifi: " if "[email protected]" is in CC. :)

Signature · 1 line
Kees Cook
#5 lore raw
In reply to Kees Cook
Quoted 11 lines · Kees Cook

Zero-length arrays 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 zero-length array with flexible-array member.

This results in no differences in binary output.

[1] https://github.com/KSPP/linux/issues/78

Quoted 13 lines

Patch applied to ath-next branch of ath.git, thanks.

7256f28767fa wifi: carl9170: Replace zero-length array of trailing structs with flex-array

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches