* ath12k: memcpy() source buffer overread
@ 2023-06-20 6:18 Dmitry Antipov
2023-08-03 13:54 ` Kalle Valo
0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Antipov @ 2023-06-20 6:18 UTC (permalink / raw)
To: Kalle Valo; +Cc: linux-wireless
When compiling with gcc 13.1 and CONFIG_FORTIFY_SOURCE=y, I've noticed the following:
...
In function ‘fortify_memcpy_chk’,
inlined from ‘ath12k_peer_assoc_h_he’ at drivers/net/wireless/ath/ath12k/mac.c:1640:2,
inlined from ‘ath12k_peer_assoc_prepare’ at drivers/net/wireless/ath/ath12k/mac.c:2027:2:
./include/linux/fortify-string.h:529:25: warning: call to ‘__read_overflow2_field’ declared with
attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()?
[-Wattribute-warning]
529 | __read_overflow2_field(q_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘fortify_memcpy_chk’,
inlined from ‘ath12k_peer_assoc_h_he’ at drivers/net/wireless/ath/ath12k/mac.c:1643:2,
inlined from ‘ath12k_peer_assoc_prepare’ at drivers/net/wireless/ath/ath12k/mac.c:2027:2:
./include/linux/fortify-string.h:529:25: warning: call to ‘__read_overflow2_field’ declared with
attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()?
[-Wattribute-warning]
529 | __read_overflow2_field(q_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
And this seems correct because:
/* dst: u32[2], src: u8[6], size: 8 so 2 byte source overread */
memcpy(&arg->peer_he_cap_macinfo, he_cap->he_cap_elem.mac_cap_info,
sizeof(arg->peer_he_cap_macinfo));
and:
/* dst: u32[3], src: u8[11], size: 12 so 1 byte source overread */
memcpy(&arg->peer_he_cap_phyinfo, he_cap->he_cap_elem.phy_cap_info,
sizeof(arg->peer_he_cap_phyinfo));
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: ath12k: memcpy() source buffer overread
2023-06-20 6:18 ath12k: memcpy() source buffer overread Dmitry Antipov
@ 2023-08-03 13:54 ` Kalle Valo
0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2023-08-03 13:54 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: linux-wireless, ath12k
+ ath12k list
Dmitry Antipov <dmantipov@yandex.ru> writes:
> When compiling with gcc 13.1 and CONFIG_FORTIFY_SOURCE=y, I've noticed the following:
>
> ...
> In function ‘fortify_memcpy_chk’,
> inlined from ‘ath12k_peer_assoc_h_he’ at drivers/net/wireless/ath/ath12k/mac.c:1640:2,
> inlined from ‘ath12k_peer_assoc_prepare’ at drivers/net/wireless/ath/ath12k/mac.c:2027:2:
> ./include/linux/fortify-string.h:529:25: warning: call to ‘__read_overflow2_field’ declared with
> attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()?
> [-Wattribute-warning]
> 529 | __read_overflow2_field(q_size_field, size);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In function ‘fortify_memcpy_chk’,
> inlined from ‘ath12k_peer_assoc_h_he’ at drivers/net/wireless/ath/ath12k/mac.c:1643:2,
> inlined from ‘ath12k_peer_assoc_prepare’ at drivers/net/wireless/ath/ath12k/mac.c:2027:2:
> ./include/linux/fortify-string.h:529:25: warning: call to ‘__read_overflow2_field’ declared with
> attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()?
> [-Wattribute-warning]
> 529 | __read_overflow2_field(q_size_field, size);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ...
>
> And this seems correct because:
>
> /* dst: u32[2], src: u8[6], size: 8 so 2 byte source overread */
> memcpy(&arg->peer_he_cap_macinfo, he_cap->he_cap_elem.mac_cap_info,
> sizeof(arg->peer_he_cap_macinfo));
>
> and:
>
> /* dst: u32[3], src: u8[11], size: 12 so 1 byte source overread */
> memcpy(&arg->peer_he_cap_phyinfo, he_cap->he_cap_elem.phy_cap_info,
> sizeof(arg->peer_he_cap_phyinfo));
Arnd fixed this:
https://git.kernel.org/kvalo/ath/c/603cf6c2fcdc
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-03 13:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-20 6:18 ath12k: memcpy() source buffer overread Dmitry Antipov
2023-08-03 13:54 ` Kalle Valo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).