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=202606 header.b=HmqwBKAv; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id B5BAB5A0274 for ; Fri, 10 Jul 2026 03:37:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202606; t=1783647461; bh=igqVrjweRgGBfIByp76w/vvxUikPwtcg4IjQ7ZAjyGA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HmqwBKAvcCT86oy7qXL4k7zx7Sz4cBl+8GdWKIy9L9CQnOtfxxsxKxEEBCd36zYQr Mdjni3ST6Hk+XUfndRQ4konwUDGaHr7ZTVqrrh2cpkXAYJ+Nk2ytOD+ZAMzSYGoFw9 vKTwcLslKWzq/m79cdv8HNrXGcej/LpTAABGZ0wXHlW9YthOxYr7W+hO6G0d7uFz5Z Cm2ZatYHLs1VLCAyjXPc/J7tVTeYDbSRjqiV7xVEjG2oyrOcErm2pkny7fj9st6FxW 4e+zEVM9DACRt+MaB8H2Szj0zBowVd8i8dB3p88R5RiPCHCeJhlgmSPXlzFpBisg9E j4horONtJaGdQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gxDwj0rWWz58dT; Fri, 10 Jul 2026 11:37:41 +1000 (AEST) Date: Fri, 10 Jul 2026 11:32:06 +1000 From: David Gibson To: Jon Maloy Subject: Re: [PATCH v2 2/6] udp_vu: Check iov_tail_clone() return before assigning to msg_iovlen Message-ID: References: <20260709215656.1351549-1-jmaloy@redhat.com> <20260709215656.1351549-3-jmaloy@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Uj2S7Dn07GXTUibe" Content-Disposition: inline In-Reply-To: <20260709215656.1351549-3-jmaloy@redhat.com> Message-ID-Hash: KMHAPBPZCTU6YOTGF7HGJEVUIGQBXEKP X-Message-ID-Hash: KMHAPBPZCTU6YOTGF7HGJEVUIGQBXEKP 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: --Uj2S7Dn07GXTUibe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 09, 2026 at 05:56:52PM -0400, Jon Maloy wrote: > iov_tail_clone() returns ssize_t and can return -1 if the destination > iov array is too small. Its return value was assigned directly to > msg.msg_iovlen which is size_t, wrapping a negative value to a large > unsigned number passed to recvmsg(). >=20 > Check for failure and return early, letting the caller rewind the > virtqueue. >=20 > Signed-off-by: Jon Maloy Reviewed-by: David Gibson >=20 > --- > v2: Use if-guard instead of assert(), since the error path is > a legitimate (if unlikely) condition handled by the caller. > --- > udp_vu.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) >=20 > diff --git a/udp_vu.c b/udp_vu.c > index e4fb1057..edd9cae7 100644 > --- a/udp_vu.c > +++ b/udp_vu.c > @@ -67,11 +67,15 @@ static ssize_t udp_vu_sock_recv(struct iov_tail *payl= oad, size_t *cnt, int s) > struct iovec msg_iov[VIRTQUEUE_MAX_SIZE]; > struct msghdr msg =3D { 0 }; > size_t iov_used; > + ssize_t iovlen; > ssize_t dlen; > =20 > + iovlen =3D iov_tail_clone(msg_iov, ARRAY_SIZE(msg_iov), payload); > + if (iovlen < 0) > + return -1; > + > msg.msg_iov =3D msg_iov; > - msg.msg_iovlen =3D iov_tail_clone(msg.msg_iov, ARRAY_SIZE(msg_iov), > - payload); > + msg.msg_iovlen =3D iovlen; > =20 > /* read data from the socket */ > dlen =3D recvmsg(s, &msg, 0); > --=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 --Uj2S7Dn07GXTUibe Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmpQS5EACgkQzQJF27ox 2GcOcRAAqoTo4dnYuyaHt29eF9JYX9gZVFjeRJK4VurEC69LbXuKBTBYkaY24uko 2KzlKHSV3kphtnYvFkU9PmeWnGiDHPBGOeaGnvEjpbtKiu2aql4Uo4ISGoQ0xQB4 JLHS1Y6yKviijE5foXJp4md+g8zLBe5Pd4ml6mXbljIzpcTOO8jQALcr/wVJ2GE4 5oF2JdR2Tf8zt/u3Gx/1fQ2XVwjhrHluX8xVsPyPMygGqj720/kWTLBg8aouowUo 3It8/5xIT4hO+J2V21gEnUHF0hCdMT5DjoOtATjcChBXmEzo7A7bHFjA6JyhFjuN F8RjQYf9ShUFio3rdESkxNK2sXd8+CYeNbB6YqqwSRH6n/yCGibFaNFSJX5UzrsX /O+UPAZ217wOOmVdl/ixCkY8nBk5WUOnwJ6ugNIrrozR+XmfIJbnZih549CpJMeG a4LZY0w3D3gpN7xvThVK9f4giG1JizW5c1td8JdpHfOws1gAKUeksbHFJXv2OeZT Z/zMvR3K8594aBbKWC68CNDNGOTHR3hjybl24RcMYvVa7auscDV2K4Iw9KvGU24E T7kHJbEvg9AGY59GvmK26ULwmR85xXzkejf/jccAqJuUg54gXfLfbLqL6DIetBe4 IuUDxh8XmYC9LQyepbHtmKvEyQ5nPeV5n1djPA6T9sO1OOO1Va8= =B2YD -----END PGP SIGNATURE----- --Uj2S7Dn07GXTUibe--