* [PATCH] udp: Ignore bogus -Wstringop-overread for write() from gcc 12.1
@ 2022-05-19 11:32 Stefano Brivio
0 siblings, 0 replies; only message in thread
From: Stefano Brivio @ 2022-05-19 11:32 UTC (permalink / raw)
To: passt-dev
[-- Attachment #1: Type: text/plain, Size: 1617 bytes --]
With current OpenSUSE Tumbleweed on aarch64 (gcc-12-1.3.aarch64) and
on x86_64 (gcc-12-1.4.x86_64), but curiously not on armv7hl
(gcc-12-1.3.armv7hl), gcc warns about using the _pointer_ to the
802.3 header to write the whole frame to the tap descriptor:
reading between 62 and 4294967357 bytes from a region of size 14
which is bogus:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103483
Probably declaring udp_sock_fill_data_v{4,6}() as noinline would
"fix" this, but that's on the data path, so I'd rather not. Use
a gcc pragma instead.
Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>
---
udp.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/udp.c b/udp.c
index f425d14..dd7119e 100644
--- a/udp.c
+++ b/udp.c
@@ -714,8 +714,10 @@ static void udp_sock_fill_data_v4(const struct ctx *c, int n,
b->uh.len = htons(udp4_l2_mh_sock[n].msg_len + sizeof(b->uh));
if (c->mode == MODE_PASTA) {
+#pragma GCC diagnostic ignored "-Wstringop-overread"
if (write(c->fd_tap, &b->eh, sizeof(b->eh) + ip_len) < 0)
debug("tap write: %s", strerror(errno));
+#pragma GCC diagnostic pop
pcap((char *)&b->eh, sizeof(b->eh) + ip_len);
return;
@@ -813,8 +815,10 @@ static void udp_sock_fill_data_v6(const struct ctx *c, int n,
b->ip6h.hop_limit = 255;
if (c->mode == MODE_PASTA) {
+#pragma GCC diagnostic ignored "-Wstringop-overread"
if (write(c->fd_tap, &b->eh, sizeof(b->eh) + ip_len) < 0)
debug("tap write: %s", strerror(errno));
+#pragma GCC diagnostic pop
pcap((char *)&b->eh, sizeof(b->eh) + ip_len);
return;
--
@@ -714,8 +714,10 @@ static void udp_sock_fill_data_v4(const struct ctx *c, int n,
b->uh.len = htons(udp4_l2_mh_sock[n].msg_len + sizeof(b->uh));
if (c->mode == MODE_PASTA) {
+#pragma GCC diagnostic ignored "-Wstringop-overread"
if (write(c->fd_tap, &b->eh, sizeof(b->eh) + ip_len) < 0)
debug("tap write: %s", strerror(errno));
+#pragma GCC diagnostic pop
pcap((char *)&b->eh, sizeof(b->eh) + ip_len);
return;
@@ -813,8 +815,10 @@ static void udp_sock_fill_data_v6(const struct ctx *c, int n,
b->ip6h.hop_limit = 255;
if (c->mode == MODE_PASTA) {
+#pragma GCC diagnostic ignored "-Wstringop-overread"
if (write(c->fd_tap, &b->eh, sizeof(b->eh) + ip_len) < 0)
debug("tap write: %s", strerror(errno));
+#pragma GCC diagnostic pop
pcap((char *)&b->eh, sizeof(b->eh) + ip_len);
return;
--
2.35.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-19 11:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19 11:32 [PATCH] udp: Ignore bogus -Wstringop-overread for write() from gcc 12.1 Stefano Brivio
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
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 IMAP folder(s).