public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "arnd at linaro dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/97490] New: [10/11 Regression] false-positive -Wstringop-overflow= with address sanitizer Date: Mon, 19 Oct 2020 11:15:49 +0000 [thread overview] Message-ID: <bug-97490-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97490 Bug ID: 97490 Summary: [10/11 Regression] false-positive -Wstringop-overflow= with address sanitizer Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: arnd at linaro dot org CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at gcc dot gnu.org Target Milestone: --- Building the Linux kernel with gcc-10.1 or higher shows a couple of warnings in one file: drivers/net/wireless/ath/ath9k/dynack.c:209:14: warning: writing 4 bytes into a region of size 0 [-Wstringop-overflow=] I manually created a reduced test case: typedef unsigned int u32; typedef unsigned short u16; typedef unsigned char u8; typedef _Bool bool; static inline void _ether_addr_copy(u8 *dst, const u8 *src) { *(u32 *)dst = *(const u32 *)src; *(u16 *)(dst + 4) = *(const u16 *)(src + 4); } struct _ieee80211_hdr { u8 addr1[6]; }; struct _haddr_pair { u8 h_dest[6]; }; struct _ath_dyn_txbuf { u16 t_rb; struct _haddr_pair addr[64]; }; struct _ath_dynack { bool enabled; struct _ath_dyn_txbuf st_rbf; }; struct _ath_hw { int reg_ops; struct _ath_dynack dynack; }; void _ath_dynack_sample_tx_ts(struct _ath_hw *ah, struct _ieee80211_hdr *hdr) { struct _ath_dynack *da = &ah->dynack; struct _haddr_pair *addr; if (!da->enabled) return; addr = &da->st_rbf.addr[da->st_rbf.t_rb]; _ether_addr_copy(addr->h_dest, hdr->addr1); } $ gcc-10 -O2 -Wall -fsanitize=kernel-address -c dynack.c test.c: In function '_ath_dynack_sample_tx_ts': test.c:8:21: warning: writing 4 bytes into a region of size 0 [-Wstringop-overflow=] 8 | *(u32 *)dst = *(const u32 *)src; | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ test.c:26:14: note: at offset 0 to object 'enabled' with size 1 declared here 26 | bool enabled; | ^~~~~~~ test.c:9:27: warning: writing 2 bytes into a region of size 0 [-Wstringop-overflow=] 9 | *(u16 *)(dst + 4) = *(const u16 *)(src + 4); | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ test.c:26:14: note: at offset 0 to object 'enabled' with size 1 declared here 26 | bool enabled; | ^~~~~~~ See also https://godbolt.org/z/K5jcM8 I checked locally that this happens on all target architectures I tried, but not with gcc-9. The code in the kernel only produces a warning on architectures that are assumed to allow unaligned load/store instructions, otherwise a different ether_addr_copy() function is used.
next reply other threads:[~2020-10-19 11:15 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-19 11:15 arnd at linaro dot org [this message] 2020-10-19 12:05 ` [Bug sanitizer/97490] " rguenth at gcc dot gnu.org 2020-10-19 12:07 ` [Bug sanitizer/97490] [10/11 Regression] false-positive -Wstringop-overflow= with address sanitizer since r10-5451-gef29b12cfbb4979a marxin at gcc dot gnu.org 2021-02-26 12:13 ` rguenth at gcc dot gnu.org 2021-04-08 12:02 ` rguenth at gcc dot gnu.org 2022-06-28 10:42 ` [Bug sanitizer/97490] [10/11/12/13 " jakub at gcc dot gnu.org 2023-07-07 10:38 ` [Bug sanitizer/97490] [11/12/13/14 " rguenth at gcc dot gnu.org
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=bug-97490-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.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: linkBe 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 read-only IMAP folder(s) and NNTP newsgroup(s).