From: Jon Maloy <jmaloy@redhat.com>
To: sbrivio@redhat.com, david@gibson.dropbear.id.au,
jmaloy@redhat.com, passt-dev@passt.top
Subject: [PATCH] udp: Provide dummy iov in udp_peek_addr() to avoid Coverity warning
Date: Sun, 31 May 2026 16:20:27 -0400 [thread overview]
Message-ID: <20260531202027.1721248-1-jmaloy@redhat.com> (raw)
udp_peek_addr() initialises struct msghdr without setting msg_iov,
leaving it implicitly NULL. Coverity flags this as FORWARD_NULL,
believing recvmsg() will dereference the NULL pointer.
In practice, msg_iovlen being zero means the kernel never touches
msg_iov, so the warning is a false positive. We now provide a
one-byte dummy iov to make msg_iov non-NULL, hence suppressing this
warning without changing the function's behaviour.
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
---
udp.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/udp.c b/udp.c
index c28d6ee2..f648cb8b 100644
--- a/udp.c
+++ b/udp.c
@@ -734,9 +734,16 @@ static int udp_peek_addr(int s, union sockaddr_inany *src,
{
char sastr[SOCKADDR_STRLEN], dstr[INANY_ADDRSTRLEN];
char cmsg[PKTINFO_SPACE];
+ char dummy;
+ struct iovec iov = {
+ .iov_base = &dummy,
+ .iov_len = sizeof(dummy),
+ };
struct msghdr msg = {
.msg_name = src,
.msg_namelen = sizeof(*src),
+ .msg_iov = &iov,
+ .msg_iovlen = 1,
.msg_control = cmsg,
.msg_controllen = sizeof(cmsg),
};
--
2.52.0
next reply other threads:[~2026-05-31 20:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-31 20:20 Jon Maloy [this message]
2026-06-02 1:55 ` David Gibson
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=20260531202027.1721248-1-jmaloy@redhat.com \
--to=jmaloy@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/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.
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).