From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202602 header.b=cKyh8knt; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 8DAB05A0265 for ; Tue, 02 Jun 2026 03:55:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1780365332; bh=Vk8yrwoRSHh8YYV1iBgTzAAb+6tGsnpujMhZaOikIho=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cKyh8kntgrFXd9TI1ZlhEcJiEaBtCOghNCTytdQ9U45IoEx/QynpnyF8VdI/QDXjj mD0AABOddraZz8sA7+nNEslk6+RCCzgFfby9keawtNN44W+CoLLCNSezN7AuaI2t+7 KT/3yVWn5FMYgUIaZkJl3WV3CNBfugUrISNbJK2t++LxkqCAweGsD4jaH3Nq4w6L3B gHZi8Va2a79u7gr60qQXdFNz/1ggfXY8mfkDCD748LzoU2aWW19O0fUnU5HFrreej0 hNiataLfU9knfvKiJCXqtrXheEfOglcYPE3aoKYzq1mCOJY+7iFw3H/G45nRdBNOJ1 b19RaXkUkEGZA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gTv6r3rTgz4wJj; Tue, 02 Jun 2026 11:55:32 +1000 (AEST) Date: Tue, 2 Jun 2026 11:55:23 +1000 From: David Gibson To: Jon Maloy Subject: Re: [PATCH] udp: Provide dummy iov in udp_peek_addr() to avoid Coverity warning Message-ID: References: <20260531202027.1721248-1-jmaloy@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Kr4r+NE9MtxHT9eB" Content-Disposition: inline In-Reply-To: <20260531202027.1721248-1-jmaloy@redhat.com> Message-ID-Hash: N2OKXQRRDLTXE6RPEFR2O5RJSPBKOS27 X-Message-ID-Hash: N2OKXQRRDLTXE6RPEFR2O5RJSPBKOS27 X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: sbrivio@redhat.com, passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --Kr4r+NE9MtxHT9eB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, May 31, 2026 at 04:20:27PM -0400, Jon Maloy wrote: > 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. >=20 > 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. >=20 > Signed-off-by: Jon Maloy Oof. I mean, yes, it's worth some amount of code ugliness to prevent Coverity warnings, but this is definitely on the high end of that ugliness. This doesn't have zero runtime cost, since it requires extra stack jiggery pokery to set up. The question is how to do it better without explicit Coverity suppressions or at least mentioning Coverity in line. This isn't quite as similar to an existing workaround as I initially thought. The triggering situation is similar the one handled by #ifdef VALGRIND in tcp.c + test/valgrind.supp, but that doesn't really help us Arguably this is a Coverity defect - it should be able to see that msg_iovlen is statically zero and accept this. So there's some hope of the error just going away in future. Not sure whether that's likely, or if we can do anything to expedite it. Hrm. We don't want to reference Coverity in the code for an explicit suppression, so I guess using a #if conditional on coverity would have the same problem. Could we use a conditional but not refer specifically to which static checker it's working around? > --- > udp.c | 7 +++++++ > 1 file changed, 7 insertions(+) >=20 > 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 =3D { > + .iov_base =3D &dummy, > + .iov_len =3D sizeof(dummy), > + }; > struct msghdr msg =3D { > .msg_name =3D src, > .msg_namelen =3D sizeof(*src), > + .msg_iov =3D &iov, > + .msg_iovlen =3D 1, > .msg_control =3D cmsg, > .msg_controllen =3D sizeof(cmsg), > }; > --=20 > 2.52.0 >=20 --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --Kr4r+NE9MtxHT9eB Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmoeOAoACgkQzQJF27ox 2GexPA//eQsp4GBXnYc9LvmJECfULyNRwwpIQliJdpOsFXw4FekCYgJV059rNWC+ TviTWJiF0jhjWt8RhPwi3pCBvEcj6SdaFi/5smCxa1Qa5BRbclQyVuYhKIrwsu+l JoBPDRsbiSeSorQ4IYBQqZdl7q0EH3E2gKMrywqtaNIxayGvhs4moOxQxqFTsNTI 42TwPkdBD3eStVw2GQJse8PrxzZJYhn60Uxsn1DHp8EBPI4tHWefSAVs02VgrpeY ecFtp3Yw8vWlO3WDMA21UCnZF/Zt0XQ3Fdcc+HowFSGBMNBckVOLUoInFCGG/tIn Uv1hcyfhUmjkKs+8LEdkf+RV7TolFYg14B+p1/VAvAdb+zmgASZbyD7w1H9hN9wv chW+s0Ew8CTd5wNRpiW5p4UY3S+4IUVgIu8j/XvlZlSuqKSLu7k5Ekgzq4BR4Evc XQldvY7BEKq98RDr5xv3mA3EKYSt0wG5LAKZsbT15GDFMCwln9tYijZUrI5CmEfZ PM81BwwqdYFMKd4vlGrH/DLk56vh5ccU8TVHAcpC81D7h2cBUZ7uPHYlp6ammraT DfwLewfTM18ZsGQhBC3ljTwaYu3QPeuuQQCQiUTTinkMCguWARfq/i11AmR87XFU GKPxFv30eVVxLv4Ro3olQorNe6EDANCJ8Iks9cXPuFo6QuyX0ck= =pyak -----END PGP SIGNATURE----- --Kr4r+NE9MtxHT9eB--