Skip to contentSkip to conversation

wifi: rtw89: coex: Fix __write_overflow_field error

PATCH In review Gustavo A. R. Silva 3 participants 3 messages May 24, 2023 Realtek wireless driver (rtw89)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: rtw89: coex: Fix __write_overflow_field error

One-element arrays as fake flexible arrays are deprecated, and we are moving towards adopting C99 flexible-array members instead.

Fix the following error seen under GCC-13 and -fstrict-flex-arrays=3:
In function ‘fortify_memcpy_chk’,
inlined from ‘_append_tdma’ at drivers/net/wireless/realtek/rtw89/coex.c:1579:3:
include/linux/fortify-string.h:583:25: error: call to ‘__write_overflow_field’ declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]

  583 |                         __write_overflow_field(p_size_field, size);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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].

This results in no differences in binary output.

---
 drivers/net/wireless/realtek/rtw89/coex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw89/coex.c +1 -1
index 3a586a971e8f..bda0e1e99a8c 100644
@@ -206,7 +206,7 @@ static const struct rtw89_btc_ver rtw89_btc_ver_defs[] = {
 struct rtw89_btc_btf_tlv {
 	u8 type;
 	u8 len;
-	u8 val[1];
+	u8 val[];
 } __packed;
 
 enum btc_btf_set_report_en {
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 41 lines

-----Original Message-----
From: Gustavo A. R. Silva <[email protected]>
Sent: Wednesday, May 24, 2023 10:13 AM
To: Ping-Ke Shih <[email protected]>; Kalle Valo <[email protected]>
Cc: [email protected]; [email protected]; Gustavo A. R. Silva <[email protected]>; [email protected]
Subject: [PATCH][next] wifi: rtw89: coex: Fix __write_overflow_field error

One-element arrays as fake flexible arrays are deprecated, and we are moving towards adopting C99 flexible-array members instead.

Fix the following error seen under GCC-13 and -fstrict-flex-arrays=3:
In function ‘fortify_memcpy_chk’,
inlined from ‘_append_tdma’ at drivers/net/wireless/realtek/rtw89/coex.c:1579:3:
include/linux/fortify-string.h:583:25: error: call to ‘__write_overflow_field’ declared with attribute
warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]

  583 |                         __write_overflow_field(p_size_field, size);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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].

This results in no differences in binary output.

---
 drivers/net/wireless/realtek/rtw89/coex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw89/coex.c +0 -0
index 3a586a971e8f..bda0e1e99a8c 100644

drivers/net/wireless/realtek/rtw89/coex.c static const struct rtw89_btc_ver rtw89_btc_ver_defs[] = { · line 212

Quoted 8 lines
drivers/net/wireless/realtek/rtw89/coex.c +1 -1
@@ -206,7 +206,7 @@ static const struct rtw89_btc_ver rtw89_btc_ver_defs[] = {
 struct rtw89_btc_btf_tlv {
        u8 type;
        u8 len;
-       u8 val[1];
+       u8 val[];
 } __packed;
 
 enum btc_btf_set_report_en {

Arnd has sent the same patch [1] as yours.

[1] https://lore.kernel.org/linux-wireless/[email protected]/T/#mca619c8261b87b88eedd391ceafb34c40d513ce5

#2 lore raw
Quoted 48 lines · Ping-Ke Shih
Quoted 48 lines

-----Original Message-----
From: Gustavo A. R. Silva <[email protected]>
Sent: Wednesday, May 24, 2023 10:13 AM
To: Ping-Ke Shih <[email protected]>; Kalle Valo <[email protected]>
Cc: [email protected]; [email protected]; Gustavo A. R. Silva <[email protected]>; [email protected]
Subject: [PATCH][next] wifi: rtw89: coex: Fix __write_overflow_field error

One-element arrays as fake flexible arrays are deprecated, and we are moving towards adopting C99 flexible-array members instead.

Fix the following error seen under GCC-13 and -fstrict-flex-arrays=3:
In function ‘fortify_memcpy_chk’,
inlined from ‘_append_tdma’ at drivers/net/wireless/realtek/rtw89/coex.c:1579:3:
include/linux/fortify-string.h:583:25: error: call to ‘__write_overflow_field’ declared with attribute
warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]

   583 |                         __write_overflow_field(p_size_field, size);
       |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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].

This results in no differences in binary output.

---
  drivers/net/wireless/realtek/rtw89/coex.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw89/coex.c +1 -1
index 3a586a971e8f..bda0e1e99a8c 100644
@@ -206,7 +206,7 @@ static const struct rtw89_btc_ver rtw89_btc_ver_defs[] = {
  struct rtw89_btc_btf_tlv {
         u8 type;
         u8 len;
-       u8 val[1];
+       u8 val[];
  } __packed;
 
Quoted 3 lines

drivers/net/wireless/realtek/rtw89/coex.c static const struct rtw89_btc_ver rtw89_btc_ver_defs[] = { · line 212

Quoted 1 line
drivers/net/wireless/realtek/rtw89/coex.c +0 -0
  enum btc_btf_set_report_en {

Arnd has sent the same patch [1] as yours.

Oh that's great! What a coincidence. :)

Thanks for letting me know.
--
Gustavo

Quoted 3 lines

[1] https://lore.kernel.org/linux-wireless/[email protected]/T/#mca619c8261b87b88eedd391ceafb34c40d513ce5