All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] wifi: rtw89: coex: Fix __write_overflow_field error
@ 2023-05-24  2:12 Gustavo A. R. Silva
  2023-05-24  2:21 ` Ping-Ke Shih
  0 siblings, 1 reply; 3+ messages in thread
From: Gustavo A. R. Silva @ 2023-05-24  2:12 UTC (permalink / raw)
  To: Ping-Ke Shih, Kalle Valo
  Cc: linux-wireless, linux-kernel, Gustavo A. R. Silva,
	linux-hardening

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.

Link: https://github.com/KSPP/linux/issues/21
Link: https://github.com/KSPP/linux/issues/299
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 drivers/net/wireless/realtek/rtw89/coex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtw89/coex.c b/drivers/net/wireless/realtek/rtw89/coex.c
index 3a586a971e8f..bda0e1e99a8c 100644
--- a/drivers/net/wireless/realtek/rtw89/coex.c
+++ b/drivers/net/wireless/realtek/rtw89/coex.c
@@ -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 {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH][next] wifi: rtw89: coex: Fix __write_overflow_field error
  2023-05-24  2:12 [PATCH][next] wifi: rtw89: coex: Fix __write_overflow_field error Gustavo A. R. Silva
@ 2023-05-24  2:21 ` Ping-Ke Shih
  2023-05-24  2:31   ` Gustavo A. R. Silva
  0 siblings, 1 reply; 3+ messages in thread
From: Ping-Ke Shih @ 2023-05-24  2:21 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Kalle Valo
  Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org



> -----Original Message-----
> From: Gustavo A. R. Silva <gustavoars@kernel.org>
> Sent: Wednesday, May 24, 2023 10:13 AM
> To: Ping-Ke Shih <pkshih@realtek.com>; Kalle Valo <kvalo@kernel.org>
> Cc: linux-wireless@vger.kernel.org; linux-kernel@vger.kernel.org; Gustavo A. R. Silva
> <gustavoars@kernel.org>; linux-hardening@vger.kernel.org
> 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.
> 
> Link: https://github.com/KSPP/linux/issues/21
> Link: https://github.com/KSPP/linux/issues/299
> Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> ---
>  drivers/net/wireless/realtek/rtw89/coex.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtw89/coex.c b/drivers/net/wireless/realtek/rtw89/coex.c
> index 3a586a971e8f..bda0e1e99a8c 100644
> --- a/drivers/net/wireless/realtek/rtw89/coex.c
> +++ b/drivers/net/wireless/realtek/rtw89/coex.c
> @@ -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/27a7010de8be4006a3e4b95e851781c6@realtek.com/T/#mca619c8261b87b88eedd391ceafb34c40d513ce5


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] wifi: rtw89: coex: Fix __write_overflow_field error
  2023-05-24  2:21 ` Ping-Ke Shih
@ 2023-05-24  2:31   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2023-05-24  2:31 UTC (permalink / raw)
  To: Ping-Ke Shih, Gustavo A. R. Silva, Kalle Valo
  Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org



On 5/23/23 20:21, Ping-Ke Shih wrote:
> 
> 
>> -----Original Message-----
>> From: Gustavo A. R. Silva <gustavoars@kernel.org>
>> Sent: Wednesday, May 24, 2023 10:13 AM
>> To: Ping-Ke Shih <pkshih@realtek.com>; Kalle Valo <kvalo@kernel.org>
>> Cc: linux-wireless@vger.kernel.org; linux-kernel@vger.kernel.org; Gustavo A. R. Silva
>> <gustavoars@kernel.org>; linux-hardening@vger.kernel.org
>> 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.
>>
>> Link: https://github.com/KSPP/linux/issues/21
>> Link: https://github.com/KSPP/linux/issues/299
>> Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
>> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
>> ---
>>   drivers/net/wireless/realtek/rtw89/coex.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/wireless/realtek/rtw89/coex.c b/drivers/net/wireless/realtek/rtw89/coex.c
>> index 3a586a971e8f..bda0e1e99a8c 100644
>> --- a/drivers/net/wireless/realtek/rtw89/coex.c
>> +++ b/drivers/net/wireless/realtek/rtw89/coex.c
>> @@ -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.

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

Thanks for letting me know.
--
Gustavo

> 
> [1] https://lore.kernel.org/linux-wireless/27a7010de8be4006a3e4b95e851781c6@realtek.com/T/#mca619c8261b87b88eedd391ceafb34c40d513ce5
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-24  2:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-24  2:12 [PATCH][next] wifi: rtw89: coex: Fix __write_overflow_field error Gustavo A. R. Silva
2023-05-24  2:21 ` Ping-Ke Shih
2023-05-24  2:31   ` Gustavo A. R. Silva

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.