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=dl2ZuH19; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 5F7E85A026D for ; Thu, 09 Jul 2026 04:42:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202606; t=1783564946; bh=unkNXrAd11ny0T98pLv6aacsSQCEd60n1M6XRFKltfs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dl2ZuH19IRqEx9C3b/dOOWccVaAhyBleWZyYqT8vqcbCnw1vvkracguYXjvsYd433 yEhextQj1PiEYZVq7OD4etBEmKe3JP3hLk8NFVRbgC7T3plgOUYlcsuhUL5Pkp7Ikr /Q0viF67mRMTHotWDAnlkcxZF66o2DtScFX0/3eiGi3G7DkEpLulG/jxv4EHjux/nO Lra2CEhxwR3AniHxM4w/KydUVZiAKyrKpSuhicfbS1BbiT44iVMHFEPXpEuzR5yfBs CE78b32d8QF/jQai0nJRf39an3fed0l5canAPtQKXqcetmF7TNkucF+c5EJJ5LGa7V HOKlP29ZN/57Q== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gwfPt6ssHz4wCh; Thu, 09 Jul 2026 12:42:26 +1000 (AEST) Date: Thu, 9 Jul 2026 12:11:18 +1000 From: David Gibson To: Jon Maloy Subject: Re: [PATCH 2/7] udp_vu: Assert iov_tail_clone() return before assigning to msg_iovlen Message-ID: References: <20260708223203.885345-1-jmaloy@redhat.com> <20260708223203.885345-3-jmaloy@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="N634KHefiEVuDyb1" Content-Disposition: inline In-Reply-To: <20260708223203.885345-3-jmaloy@redhat.com> Message-ID-Hash: LGJJHJPXB46RY7QTCZNHTLVY6M3ERMAA X-Message-ID-Hash: LGJJHJPXB46RY7QTCZNHTLVY6M3ERMAA 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: --N634KHefiEVuDyb1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 08, 2026 at 06:31:58PM -0400, Jon Maloy wrote: > iov_tail_clone() returns ssize_t, but its return value was assigned > directly to msg.msg_iovlen which is size_t. Add an assert to document > the invariant that the clone into a VIRTQUEUE_MAX_SIZE array cannot Nit: I think s/invariant/assumption/ would be clearer. > fail. >=20 > Signed-off-by: Jon Maloy Reviewed-by: David Gibson > --- > udp_vu.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) >=20 > diff --git a/udp_vu.c b/udp_vu.c > index e4fb1057..5d6f45ec 100644 > --- a/udp_vu.c > +++ b/udp_vu.c > @@ -67,11 +67,14 @@ 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); > + assert(iovlen >=3D 0); > + > 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 --N634KHefiEVuDyb1 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmpPA0UACgkQzQJF27ox 2Gezqg//ZdCLzy7jfGAiF71aoCazj49xMlz8zmVxkWYEh8Gt2OF2G9b0lubSmorO KKp9fSswQfrPlcXKIqwGiTee3K5kMLjusyLZKKqSPhpW//nXaZOP55OpAZNAwWGI f47WcwjNdtejRBimmDSJQz3AR/Q2EOGpq8wA8O4AQu0GrnfnwcjTr2ZakF25Pv8Q gPHHxrKoKeIRFu6whw3pbRMrL5GVE6603QHd04PcqF2gfpfFl98PHk2cHsuKZtDU wy7K25Ze5FJy52ov2OyLHjWspiNoQR6r13cr7igYcAOrksfNG128S9n60wLVb2Cb nrlanmDNNPRqNTKKU2eTnI3M2cI5nRVR9b2dRwhNB6etHtmPRbM0tl+i71O2IxuB SdtnM7jHiPa7rEz6K9cVqG6kExzJa3ZFdKyzTS/oFLBYlDeRfSoNC2g7rB9GT8+b MjVMI9zBPeCiC/EqCNIqwOQ4b3RND2fuzvpHsSxxfGUMxViiSfsO2O5X5Yr+14hm CSGGqWj0p7KCB3R6dKe1XpvE4vpy9SLRLfpVIPlxr0IcFHfY5Cgwl3Zt/e5U0Uya YSMhpXIN1p/4llTu0iDhIuNiEFEffcOTZg+43kRRKIw2ENfY/2U2FzsZ3XuHcWZn iDolGxhQmwpJkVJlW5VZs63tI4fPTkzMfEnvYpsj9gUTr7jrDlg= =tJXe -----END PGP SIGNATURE----- --N634KHefiEVuDyb1--