* [PATCH net] wifi: ath12k: fix build vs old compiler
@ 2024-07-16 11:06 Paolo Abeni
2024-07-16 14:00 ` Jeff Johnson
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Paolo Abeni @ 2024-07-16 11:06 UTC (permalink / raw)
To: netdev
Cc: Kalle Valo, Jeff Johnson, Baochen Qiang, linux-wireless, ath12k,
Jakub Kicinski, David S. Miller, Eric Dumazet
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: 4a3c212eee0e ("wifi: ath12k: add basic WoW functionalities")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
Only built tested. Sending directly to net to reduce the RTT, but no
objections to go through the WiFi tree first
---
drivers/net/wireless/ath/ath12k/wow.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/wow.c b/drivers/net/wireless/ath/ath12k/wow.c
index c5cba825a84a..bead19db2c9a 100644
--- a/drivers/net/wireless/ath/ath12k/wow.c
+++ b/drivers/net/wireless/ath/ath12k/wow.c
@@ -186,7 +186,7 @@ ath12k_wow_convert_8023_to_80211(struct ath12k *ar,
if (eth_pkt_ofs < ETH_ALEN) {
pkt_ofs = eth_pkt_ofs + a1_ofs;
- if (eth_pkt_ofs + eth_pat_len < ETH_ALEN) {
+ if (size_add(eth_pkt_ofs, eth_pat_len) < ETH_ALEN) {
memcpy(pat, eth_pat, eth_pat_len);
memcpy(bytemask, eth_bytemask, eth_pat_len);
@@ -228,7 +228,7 @@ ath12k_wow_convert_8023_to_80211(struct ath12k *ar,
} else if (eth_pkt_ofs < prot_ofs) {
pkt_ofs = eth_pkt_ofs - ETH_ALEN + a3_ofs;
- if (eth_pkt_ofs + eth_pat_len < prot_ofs) {
+ if (size_add(eth_pkt_ofs, eth_pat_len) < prot_ofs) {
memcpy(pat, eth_pat, eth_pat_len);
memcpy(bytemask, eth_bytemask, eth_pat_len);
--
2.45.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net] wifi: ath12k: fix build vs old compiler
2024-07-16 11:06 [PATCH net] wifi: ath12k: fix build vs old compiler Paolo Abeni
@ 2024-07-16 14:00 ` Jeff Johnson
2024-07-16 14:03 ` Jeff Johnson
2024-07-16 14:11 ` Paolo Abeni
2024-07-16 14:40 ` Jeff Johnson
2024-07-16 15:00 ` patchwork-bot+netdevbpf
2 siblings, 2 replies; 9+ messages in thread
From: Jeff Johnson @ 2024-07-16 14:00 UTC (permalink / raw)
To: Paolo Abeni, netdev
Cc: Kalle Valo, Jeff Johnson, Baochen Qiang, linux-wireless, ath12k,
Jakub Kicinski, David S. Miller, Eric Dumazet
On 7/16/2024 4:06 AM, Paolo Abeni wrote:
> 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: 4a3c212eee0e ("wifi: ath12k: add basic WoW functionalities")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---
> Only built tested. Sending directly to net to reduce the RTT, but no
> objections to go through the WiFi tree first
> ---
> drivers/net/wireless/ath/ath12k/wow.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath12k/wow.c b/drivers/net/wireless/ath/ath12k/wow.c
> index c5cba825a84a..bead19db2c9a 100644
> --- a/drivers/net/wireless/ath/ath12k/wow.c
> +++ b/drivers/net/wireless/ath/ath12k/wow.c
> @@ -186,7 +186,7 @@ ath12k_wow_convert_8023_to_80211(struct ath12k *ar,
> if (eth_pkt_ofs < ETH_ALEN) {
> pkt_ofs = eth_pkt_ofs + a1_ofs;
>
> - if (eth_pkt_ofs + eth_pat_len < ETH_ALEN) {
> + if (size_add(eth_pkt_ofs, eth_pat_len) < ETH_ALEN) {
> memcpy(pat, eth_pat, eth_pat_len);
> memcpy(bytemask, eth_bytemask, eth_pat_len);
>
> @@ -228,7 +228,7 @@ ath12k_wow_convert_8023_to_80211(struct ath12k *ar,
> } else if (eth_pkt_ofs < prot_ofs) {
> pkt_ofs = eth_pkt_ofs - ETH_ALEN + a3_ofs;
>
> - if (eth_pkt_ofs + eth_pat_len < prot_ofs) {
> + if (size_add(eth_pkt_ofs, eth_pat_len) < prot_ofs) {
> memcpy(pat, eth_pat, eth_pat_len);
> memcpy(bytemask, eth_bytemask, eth_pat_len);
>
Duplicate of https://msgid.link/20240704144341.207317-1-kvalo@kernel.org ??
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net] wifi: ath12k: fix build vs old compiler
2024-07-16 14:00 ` Jeff Johnson
@ 2024-07-16 14:03 ` Jeff Johnson
2024-07-16 14:36 ` Kees Cook
2024-07-16 14:11 ` Paolo Abeni
1 sibling, 1 reply; 9+ messages in thread
From: Jeff Johnson @ 2024-07-16 14:03 UTC (permalink / raw)
To: Paolo Abeni, netdev, Kees Cook, Paul E . McKenney
Cc: Kalle Valo, Jeff Johnson, Baochen Qiang, linux-wireless, ath12k,
Jakub Kicinski, David S. Miller, Eric Dumazet
On 7/16/2024 7:00 AM, Jeff Johnson wrote:
> On 7/16/2024 4:06 AM, Paolo Abeni wrote:
>> 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: 4a3c212eee0e ("wifi: ath12k: add basic WoW functionalities")
>> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
>> ---
>> Only built tested. Sending directly to net to reduce the RTT, but no
>> objections to go through the WiFi tree first
>> ---
>> drivers/net/wireless/ath/ath12k/wow.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath12k/wow.c b/drivers/net/wireless/ath/ath12k/wow.c
>> index c5cba825a84a..bead19db2c9a 100644
>> --- a/drivers/net/wireless/ath/ath12k/wow.c
>> +++ b/drivers/net/wireless/ath/ath12k/wow.c
>> @@ -186,7 +186,7 @@ ath12k_wow_convert_8023_to_80211(struct ath12k *ar,
>> if (eth_pkt_ofs < ETH_ALEN) {
>> pkt_ofs = eth_pkt_ofs + a1_ofs;
>>
>> - if (eth_pkt_ofs + eth_pat_len < ETH_ALEN) {
>> + if (size_add(eth_pkt_ofs, eth_pat_len) < ETH_ALEN) {
>> memcpy(pat, eth_pat, eth_pat_len);
>> memcpy(bytemask, eth_bytemask, eth_pat_len);
>>
>> @@ -228,7 +228,7 @@ ath12k_wow_convert_8023_to_80211(struct ath12k *ar,
>> } else if (eth_pkt_ofs < prot_ofs) {
>> pkt_ofs = eth_pkt_ofs - ETH_ALEN + a3_ofs;
>>
>> - if (eth_pkt_ofs + eth_pat_len < prot_ofs) {
>> + if (size_add(eth_pkt_ofs, eth_pat_len) < prot_ofs) {
>> memcpy(pat, eth_pat, eth_pat_len);
>> memcpy(bytemask, eth_bytemask, eth_pat_len);
>>
>
> Duplicate of https://msgid.link/20240704144341.207317-1-kvalo@kernel.org ??
Let me add Kees & Paul to see if they prefer your solution
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net] wifi: ath12k: fix build vs old compiler
2024-07-16 14:00 ` Jeff Johnson
2024-07-16 14:03 ` Jeff Johnson
@ 2024-07-16 14:11 ` Paolo Abeni
1 sibling, 0 replies; 9+ messages in thread
From: Paolo Abeni @ 2024-07-16 14:11 UTC (permalink / raw)
To: Jeff Johnson, netdev
Cc: Kalle Valo, Jeff Johnson, Baochen Qiang, linux-wireless, ath12k,
Jakub Kicinski, David S. Miller, Eric Dumazet
On 7/16/24 16:00, Jeff Johnson wrote:
> On 7/16/2024 4:06 AM, Paolo Abeni wrote:
>> 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: 4a3c212eee0e ("wifi: ath12k: add basic WoW functionalities")
>> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
>> ---
>> Only built tested. Sending directly to net to reduce the RTT, but no
>> objections to go through the WiFi tree first
>> ---
>> drivers/net/wireless/ath/ath12k/wow.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath12k/wow.c b/drivers/net/wireless/ath/ath12k/wow.c
>> index c5cba825a84a..bead19db2c9a 100644
>> --- a/drivers/net/wireless/ath/ath12k/wow.c
>> +++ b/drivers/net/wireless/ath/ath12k/wow.c
>> @@ -186,7 +186,7 @@ ath12k_wow_convert_8023_to_80211(struct ath12k *ar,
>> if (eth_pkt_ofs < ETH_ALEN) {
>> pkt_ofs = eth_pkt_ofs + a1_ofs;
>>
>> - if (eth_pkt_ofs + eth_pat_len < ETH_ALEN) {
>> + if (size_add(eth_pkt_ofs, eth_pat_len) < ETH_ALEN) {
>> memcpy(pat, eth_pat, eth_pat_len);
>> memcpy(bytemask, eth_bytemask, eth_pat_len);
>>
>> @@ -228,7 +228,7 @@ ath12k_wow_convert_8023_to_80211(struct ath12k *ar,
>> } else if (eth_pkt_ofs < prot_ofs) {
>> pkt_ofs = eth_pkt_ofs - ETH_ALEN + a3_ofs;
>>
>> - if (eth_pkt_ofs + eth_pat_len < prot_ofs) {
>> + if (size_add(eth_pkt_ofs, eth_pat_len) < prot_ofs) {
>> memcpy(pat, eth_pat, eth_pat_len);
>> memcpy(bytemask, eth_bytemask, eth_pat_len);
>>
>
> Duplicate of https://msgid.link/20240704144341.207317-1-kvalo@kernel.org ??
Indeed. Anything addressing the issue WFM.
Thanks,
Paolo
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net] wifi: ath12k: fix build vs old compiler
2024-07-16 14:03 ` Jeff Johnson
@ 2024-07-16 14:36 ` Kees Cook
2024-07-16 15:39 ` Paul E. McKenney
0 siblings, 1 reply; 9+ messages in thread
From: Kees Cook @ 2024-07-16 14:36 UTC (permalink / raw)
To: Jeff Johnson, Paolo Abeni, netdev, Kees Cook, Paul E . McKenney
Cc: Kalle Valo, Jeff Johnson, Baochen Qiang, linux-wireless, ath12k,
Jakub Kicinski, David S. Miller, Eric Dumazet
On July 16, 2024 7:03:55 AM PDT, Jeff Johnson <quic_jjohnson@quicinc.com> wrote:
>On 7/16/2024 7:00 AM, Jeff Johnson wrote:
>> On 7/16/2024 4:06 AM, Paolo Abeni wrote:
>>> 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: 4a3c212eee0e ("wifi: ath12k: add basic WoW functionalities")
>>> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
>>> ---
>>> Only built tested. Sending directly to net to reduce the RTT, but no
>>> objections to go through the WiFi tree first
>>> ---
>>> drivers/net/wireless/ath/ath12k/wow.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/net/wireless/ath/ath12k/wow.c b/drivers/net/wireless/ath/ath12k/wow.c
>>> index c5cba825a84a..bead19db2c9a 100644
>>> --- a/drivers/net/wireless/ath/ath12k/wow.c
>>> +++ b/drivers/net/wireless/ath/ath12k/wow.c
>>> @@ -186,7 +186,7 @@ ath12k_wow_convert_8023_to_80211(struct ath12k *ar,
>>> if (eth_pkt_ofs < ETH_ALEN) {
>>> pkt_ofs = eth_pkt_ofs + a1_ofs;
>>>
>>> - if (eth_pkt_ofs + eth_pat_len < ETH_ALEN) {
>>> + if (size_add(eth_pkt_ofs, eth_pat_len) < ETH_ALEN) {
>>> memcpy(pat, eth_pat, eth_pat_len);
>>> memcpy(bytemask, eth_bytemask, eth_pat_len);
>>>
>>> @@ -228,7 +228,7 @@ ath12k_wow_convert_8023_to_80211(struct ath12k *ar,
>>> } else if (eth_pkt_ofs < prot_ofs) {
>>> pkt_ofs = eth_pkt_ofs - ETH_ALEN + a3_ofs;
>>>
>>> - if (eth_pkt_ofs + eth_pat_len < prot_ofs) {
>>> + if (size_add(eth_pkt_ofs, eth_pat_len) < prot_ofs) {
>>> memcpy(pat, eth_pat, eth_pat_len);
>>> memcpy(bytemask, eth_bytemask, eth_pat_len);
>>>
>>
>> Duplicate of https://msgid.link/20240704144341.207317-1-kvalo@kernel.org ??
>
>Let me add Kees & Paul to see if they prefer your solution
Heh, yeah, that works too! Avoid the overflow via saturating addition.
Reviewed-by: Kees Cook<kees@kernel.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net] wifi: ath12k: fix build vs old compiler
2024-07-16 11:06 [PATCH net] wifi: ath12k: fix build vs old compiler Paolo Abeni
2024-07-16 14:00 ` Jeff Johnson
@ 2024-07-16 14:40 ` Jeff Johnson
2024-07-31 16:11 ` Kalle Valo
2024-07-16 15:00 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 9+ messages in thread
From: Jeff Johnson @ 2024-07-16 14:40 UTC (permalink / raw)
To: Paolo Abeni, netdev
Cc: Kalle Valo, Jeff Johnson, Baochen Qiang, linux-wireless, ath12k,
Jakub Kicinski, David S. Miller, Eric Dumazet
On 7/16/2024 4:06 AM, Paolo Abeni wrote:
> 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: 4a3c212eee0e ("wifi: ath12k: add basic WoW functionalities")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---
> Only built tested. Sending directly to net to reduce the RTT, but no
> objections to go through the WiFi tree first
Since Kalle is on holiday please go ahead and take this via net.
This looks nicer than Kalle's version :)
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net] wifi: ath12k: fix build vs old compiler
2024-07-16 11:06 [PATCH net] wifi: ath12k: fix build vs old compiler Paolo Abeni
2024-07-16 14:00 ` Jeff Johnson
2024-07-16 14:40 ` Jeff Johnson
@ 2024-07-16 15:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 9+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-07-16 15:00 UTC (permalink / raw)
To: Paolo Abeni
Cc: netdev, kvalo, jjohnson, quic_bqiang, linux-wireless, ath12k,
kuba, davem, edumazet
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 16 Jul 2024 13:06:39 +0200 you wrote:
> 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);
> | ^~~~~~
>
> [...]
Here is the summary with links:
- [net] wifi: ath12k: fix build vs old compiler
https://git.kernel.org/netdev/net-next/c/b49991d83bba
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net] wifi: ath12k: fix build vs old compiler
2024-07-16 14:36 ` Kees Cook
@ 2024-07-16 15:39 ` Paul E. McKenney
0 siblings, 0 replies; 9+ messages in thread
From: Paul E. McKenney @ 2024-07-16 15:39 UTC (permalink / raw)
To: Kees Cook
Cc: Jeff Johnson, Paolo Abeni, netdev, Kees Cook, Kalle Valo,
Jeff Johnson, Baochen Qiang, linux-wireless, ath12k,
Jakub Kicinski, David S. Miller, Eric Dumazet
On Tue, Jul 16, 2024 at 07:36:40AM -0700, Kees Cook wrote:
>
>
> On July 16, 2024 7:03:55 AM PDT, Jeff Johnson <quic_jjohnson@quicinc.com> wrote:
> >On 7/16/2024 7:00 AM, Jeff Johnson wrote:
> >> On 7/16/2024 4:06 AM, Paolo Abeni wrote:
> >>> 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: 4a3c212eee0e ("wifi: ath12k: add basic WoW functionalities")
> >>> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> >>> ---
> >>> Only built tested. Sending directly to net to reduce the RTT, but no
> >>> objections to go through the WiFi tree first
> >>> ---
> >>> drivers/net/wireless/ath/ath12k/wow.c | 4 ++--
> >>> 1 file changed, 2 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/drivers/net/wireless/ath/ath12k/wow.c b/drivers/net/wireless/ath/ath12k/wow.c
> >>> index c5cba825a84a..bead19db2c9a 100644
> >>> --- a/drivers/net/wireless/ath/ath12k/wow.c
> >>> +++ b/drivers/net/wireless/ath/ath12k/wow.c
> >>> @@ -186,7 +186,7 @@ ath12k_wow_convert_8023_to_80211(struct ath12k *ar,
> >>> if (eth_pkt_ofs < ETH_ALEN) {
> >>> pkt_ofs = eth_pkt_ofs + a1_ofs;
> >>>
> >>> - if (eth_pkt_ofs + eth_pat_len < ETH_ALEN) {
> >>> + if (size_add(eth_pkt_ofs, eth_pat_len) < ETH_ALEN) {
> >>> memcpy(pat, eth_pat, eth_pat_len);
> >>> memcpy(bytemask, eth_bytemask, eth_pat_len);
> >>>
> >>> @@ -228,7 +228,7 @@ ath12k_wow_convert_8023_to_80211(struct ath12k *ar,
> >>> } else if (eth_pkt_ofs < prot_ofs) {
> >>> pkt_ofs = eth_pkt_ofs - ETH_ALEN + a3_ofs;
> >>>
> >>> - if (eth_pkt_ofs + eth_pat_len < prot_ofs) {
> >>> + if (size_add(eth_pkt_ofs, eth_pat_len) < prot_ofs) {
> >>> memcpy(pat, eth_pat, eth_pat_len);
> >>> memcpy(bytemask, eth_bytemask, eth_pat_len);
> >>>
> >>
> >> Duplicate of https://msgid.link/20240704144341.207317-1-kvalo@kernel.org ??
> >
> >Let me add Kees & Paul to see if they prefer your solution
>
> Heh, yeah, that works too! Avoid the overflow via saturating addition.
>
> Reviewed-by: Kees Cook<kees@kernel.org>
Tested-by: Paul E. McKenney <paulmck@kernel.org>
I have no preference between the two, but it would be really nice if a
fix were to hit both -next and mainline sooner rather than later. ;-)
Thanx, Paul
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net] wifi: ath12k: fix build vs old compiler
2024-07-16 14:40 ` Jeff Johnson
@ 2024-07-31 16:11 ` Kalle Valo
0 siblings, 0 replies; 9+ messages in thread
From: Kalle Valo @ 2024-07-31 16:11 UTC (permalink / raw)
To: Jeff Johnson
Cc: Paolo Abeni, netdev, Jeff Johnson, Baochen Qiang, linux-wireless,
ath12k, Jakub Kicinski, David S. Miller, Eric Dumazet
Jeff Johnson <quic_jjohnson@quicinc.com> writes:
> On 7/16/2024 4:06 AM, Paolo Abeni wrote:
>
>> 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: 4a3c212eee0e ("wifi: ath12k: add basic WoW functionalities")
>> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
>> ---
>> Only built tested. Sending directly to net to reduce the RTT, but no
>> objections to go through the WiFi tree first
>
> Since Kalle is on holiday please go ahead and take this via net.
> This looks nicer than Kalle's version :)
Indeed, this is nicer. Thanks Paolo!
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-07-31 16:11 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-16 11:06 [PATCH net] wifi: ath12k: fix build vs old compiler Paolo Abeni
2024-07-16 14:00 ` Jeff Johnson
2024-07-16 14:03 ` Jeff Johnson
2024-07-16 14:36 ` Kees Cook
2024-07-16 15:39 ` Paul E. McKenney
2024-07-16 14:11 ` Paolo Abeni
2024-07-16 14:40 ` Jeff Johnson
2024-07-31 16:11 ` Kalle Valo
2024-07-16 15:00 ` patchwork-bot+netdevbpf
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).