From: Kalle Valo <kvalo@kernel.org>
To: ath12k@lists.infradead.org
Cc: linux-wireless@vger.kernel.org, kees@kernel.org
Subject: [PATCH RFC] wifi: ath12k: workaround fortify warnings in ath12k_wow_convert_8023_to_80211()
Date: Thu, 4 Jul 2024 17:43:41 +0300 [thread overview]
Message-ID: <20240704144341.207317-1-kvalo@kernel.org> (raw)
From: Kalle Valo <quic_kvalo@quicinc.com>
Johannes reported with GCC 11.4 there's a fortify warning below. The warning is
not seen with GCC 12.1 nor 13.2. Weirdly moving the other operand of sum to the
other side the warning goes away. This is safe to do as the value of the
operand is check earlier. But the code looks worse with this so I'm not sure
what to do.
In file included from ./include/linux/string.h:374,
from ./include/linux/bitmap.h:13,
from ./include/linux/cpumask.h:13,
from ./include/linux/sched.h:16,
from ./include/linux/delay.h:23,
from drivers/net/wireless/ath/ath12k/wow.c:7:
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);
| ^~~~~~
Compile tested only.
Reported-by: Johannes Berg <johannes@sipsolutions.net>
Fixes: 4a3c212eee0e ("wifi: ath12k: add basic WoW functionalities")
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
---
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..e9588bb7561c 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 (eth_pat_len < ETH_ALEN - eth_pkt_ofs) {
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 (eth_pat_len < prot_ofs - eth_pkt_ofs) {
memcpy(pat, eth_pat, eth_pat_len);
memcpy(bytemask, eth_bytemask, eth_pat_len);
base-commit: c1cacb01f35589bd41360cdb7535afc792c08a7c
--
2.39.2
next reply other threads:[~2024-07-04 14:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-04 14:43 Kalle Valo [this message]
2024-07-04 23:25 ` [PATCH RFC] wifi: ath12k: workaround fortify warnings in ath12k_wow_convert_8023_to_80211() Kees Cook
2024-07-08 15:51 ` Kalle Valo
2024-07-08 19:31 ` Kees Cook
2024-07-08 19:47 ` Arnd Bergmann
2024-07-10 17:57 ` Kalle Valo
2024-07-31 16:14 ` Kalle Valo
2024-07-09 17:27 ` Paul E. McKenney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240704144341.207317-1-kvalo@kernel.org \
--to=kvalo@kernel.org \
--cc=ath12k@lists.infradead.org \
--cc=kees@kernel.org \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).