Skip to content

Commit b49991d

Browse files
Paolo Abenikuba-moo
authored andcommitted
wifi: ath12k: fix build vs old compiler
gcc 11.4.1-3 warns about memcpy() with overlapping pointers: drivers/net/wireless/ath/ath12k/wow.c: In function ‘ath12k_wow_convert_8023_to_80211.constprop’: ./include/linux/fortify-string.h:114:33: error: ‘__builtin_memcpy’ accessing 18446744073709551611 or more bytes at offsets 0 and 0 overlaps 9223372036854775799 bytes at offset -9223372036854775804 [-Werror=restrict] 114 | #define __underlying_memcpy __builtin_memcpy | ^ ./include/linux/fortify-string.h:637:9: note: in expansion of macro ‘__underlying_memcpy’ 637 | __underlying_##op(p, q, __fortify_size); \ | ^~~~~~~~~~~~~ ./include/linux/fortify-string.h:682:26: note: in expansion of macro ‘__fortify_memcpy_chk’ 682 | #define memcpy(p, q, s) __fortify_memcpy_chk(p, q, s, \ | ^~~~~~~~~~~~~~~~~~~~ drivers/net/wireless/ath/ath12k/wow.c:190:25: note: in expansion of macro ‘memcpy’ 190 | memcpy(pat, eth_pat, eth_pat_len); | ^~~~~~ ./include/linux/fortify-string.h:114:33: error: ‘__builtin_memcpy’ accessing 18446744073709551605 or more bytes at offsets 0 and 0 overlaps 9223372036854775787 bytes at offset -9223372036854775798 [-Werror=restrict] 114 | #define __underlying_memcpy __builtin_memcpy | ^ ./include/linux/fortify-string.h:637:9: note: in expansion of macro ‘__underlying_memcpy’ 637 | __underlying_##op(p, q, __fortify_size); \ | ^~~~~~~~~~~~~ ./include/linux/fortify-string.h:682:26: note: in expansion of macro ‘__fortify_memcpy_chk’ 682 | #define memcpy(p, q, s) __fortify_memcpy_chk(p, q, s, \ | ^~~~~~~~~~~~~~~~~~~~ drivers/net/wireless/ath/ath12k/wow.c:232:25: note: in expansion of macro ‘memcpy’ 232 | memcpy(pat, eth_pat, eth_pat_len); | ^~~~~~ The sum of size_t operands can overflow SIZE_MAX, triggering the warning. Address the issue using the suitable helper. Fixes: 4a3c212 ("wifi: ath12k: add basic WoW functionalities") Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: Kees Cook <kees@kernel.org> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> Link: https://patch.msgid.link/3175f87d7227e395b330fd88fb840c1645084ea7.1721127979.git.pabeni@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 3f45181 commit b49991d

File tree

1 file changed

+2
-2
lines changed
  • drivers/net/wireless/ath/ath12k

1 file changed

+2
-2
lines changed

drivers/net/wireless/ath/ath12k/wow.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ ath12k_wow_convert_8023_to_80211(struct ath12k *ar,
186186
if (eth_pkt_ofs < ETH_ALEN) {
187187
pkt_ofs = eth_pkt_ofs + a1_ofs;
188188

189-
if (eth_pkt_ofs + eth_pat_len < ETH_ALEN) {
189+
if (size_add(eth_pkt_ofs, eth_pat_len) < ETH_ALEN) {
190190
memcpy(pat, eth_pat, eth_pat_len);
191191
memcpy(bytemask, eth_bytemask, eth_pat_len);
192192

@@ -228,7 +228,7 @@ ath12k_wow_convert_8023_to_80211(struct ath12k *ar,
228228
} else if (eth_pkt_ofs < prot_ofs) {
229229
pkt_ofs = eth_pkt_ofs - ETH_ALEN + a3_ofs;
230230

231-
if (eth_pkt_ofs + eth_pat_len < prot_ofs) {
231+
if (size_add(eth_pkt_ofs, eth_pat_len) < prot_ofs) {
232232
memcpy(pat, eth_pat, eth_pat_len);
233233
memcpy(bytemask, eth_bytemask, eth_pat_len);
234234

0 commit comments

Comments
 (0)