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=202508 header.b=F/H8aCyK; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 874735A0279 for ; Wed, 13 Aug 2025 04:29:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202508; t=1755052167; bh=TlGT8MxSBInPQtmmmeByrh2pVBzlCmlNOjjz+TvDPZM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=F/H8aCyKz7EpSk8z10og5+cWFNJd+HQa9VXdTQ83fD8xTWCrDRaMxs6GHrDaaRe6w ncP9EoSarZlI4GUy1U/6xcQRqUQ/TsE35M/yA2o1EnHmiUAtIRF8kpwXOTxS+zlt92 LYIMPo93LJZiz4NUF6y7+akoY616IS+XaG82cmYQCKzzAcO/SbtI2tZ8ADAR6+P6wU xrIyj5vUuZ2h4BVHCcOv2WRg1rvfVsyb3UNdPubk1QE08Tk7u+7q+Og3/uCY3g1swE PW9TcpSUH48wuZHNst+Hwt8kvWDW5CTUN/DHYJfvpS/q8ZJituLMxkhUmur66yndgy pHDQ54+uU8N5w== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4c1slC4s0Nz4xPG; Wed, 13 Aug 2025 12:29:27 +1000 (AEST) Date: Wed, 13 Aug 2025 12:21:28 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v8 07/30] arp: Convert to iov_tail Message-ID: References: <20250805154628.301343-1-lvivier@redhat.com> <20250805154628.301343-8-lvivier@redhat.com> <6e7993ce-e668-42dd-83ef-45907e1e66fa@redhat.com> <20250807151132.07d1a154@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="rXWMGVtRuHP7g9w/" Content-Disposition: inline In-Reply-To: <20250807151132.07d1a154@elisabeth> Message-ID-Hash: GXTTU7CEL6AKRDIQ2MCOJSJZJVOFAXZQ X-Message-ID-Hash: GXTTU7CEL6AKRDIQ2MCOJSJZJVOFAXZQ 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: Laurent Vivier , 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: --rXWMGVtRuHP7g9w/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Aug 07, 2025 at 03:11:32PM +0200, Stefano Brivio wrote: > On Thu, 7 Aug 2025 14:58:34 +0200 > Laurent Vivier wrote: >=20 > > On 06/08/2025 04:17, David Gibson wrote: > > > On Tue, Aug 05, 2025 at 05:46:05PM +0200, Laurent Vivier wrote: =20 > > >> Use packet_data() and extract headers using IOV_REMOVE_HEADER() > > >> rather than packet_get(). > > >> > > >> Signed-off-by: Laurent Vivier > > >> Reviewed-by: David Gibson =20 > > >=20 > > > Still R-b, but making an observation below that's perhaps more > > > relevant to the previous patch. > > > =20 > > >> --- > > >> arp.c | 12 +++++++++--- > > >> packet.c | 1 - > > >> 2 files changed, 9 insertions(+), 4 deletions(-) > > >> > > >> diff --git a/arp.c b/arp.c > > >> index 9f1fedeafec0..b3ac42082841 100644 > > >> --- a/arp.c > > >> +++ b/arp.c > > >> @@ -74,14 +74,20 @@ int arp(const struct ctx *c, const struct pool *= p) > > >> struct arphdr ah; > > >> struct arpmsg am; > > >> } __attribute__((__packed__)) resp; > > >> + struct arphdr ah_storage; > > >> + struct ethhdr eh_storage; > > >> + struct arpmsg am_storage; > > >> const struct ethhdr *eh; > > >> const struct arphdr *ah; > > >> const struct arpmsg *am; > > >> + struct iov_tail data; > > >> =20 > > >> - eh =3D packet_get(p, 0, 0, sizeof(*eh), NULL); > > >> - ah =3D packet_get(p, 0, sizeof(*eh), sizeof(*ah), NULL); > > >> - am =3D packet_get(p, 0, sizeof(*eh) + sizeof(*ah), sizeof(*am), NU= LL); > > >> + if (!packet_data(p, 0, &data)) > > >> + return -1; =20 > > >=20 > > > The only case where packet_data() will return false is if you give it > > > a bad packet index. That should never happen, by construction. So > > > I'm wondering if that should be an ASSSERT() in packet_data() rather > > > than a return value. > >=20 > > Stefano, why do you think of this idea? >=20 > Well, yes, it *should* be by construction, but somewhere we might > eventually calculate that index (indirectly) using data we receive, and > I don't think we want to ASSERT() if somebody finds a way to make us > calculate a bad index. I really can't imagine a scenario where we'd want to do that. The order of things in the packet pool is entirely arbitrary, so anything =66rom outside can't have any data that would be relevant to finding an index. So, in all cases we're either passing a (valid) index from one part of our code to another, or scanning the entire pool. Any failure in either case would represent a pretty unlikely bug on our side, which makes ASSERT() the appropriate choice IMO. > It's not a strong objection against ASSERT(), though. It makes the code > marginally more terse and might help us find issues, too. I just have a > slight preference for a return value in this case anyway (better to > dodge a security issue and hide a functional issue than risking hitting > both, I think). >=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 --rXWMGVtRuHP7g9w/ Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmib9qcACgkQzQJF27ox 2GcqKg/+LVAZgKk7iL7JZX2iZCzbPLEzg6wedX3DrGyVBUYt1wAwwQ77vtcVhNVw IZ/kLTRWM0DVtMxfKiBF8UMBG5AbdKYpXcI5H/njG/at70e1n6k7374MUqHCvTbW 4kvpDoJpeJX/ZgRHPT07iBAsYsn2wtsBHUzoMEGsBLPGOmE3UPs4DqxUkSBmZkAo zWEDGglIj1Btl7M7C6Lq/qqMRXHQl79aUou1TwEwh5rwOHmEmSHyjlPXqUbp5ARD pQPDC65LgKwOTwxjzyDqdOMh6SFVlZslQVorSj8LPwVASeJVxgtBV3Sn7pbhtTdK 5B/o4OwMjQ1L+XClscrtwq1LVoJZSphaG/ryU5iBUJiKQ6RIk4EW+B3mtj5G75dE udUc+XcaQncpbGApgbXf48UpazPmToJw/k1TgCQeeyGZi0DjRm6tM7LauK1x0YT8 OcpNFszxHT6lmlrYEvgpILo+s9fRCQmx9UFvgjHxDLCVPJbekuMgDY0d28BrFo8m cceZEQWJqSiNx7+l+HwEHC10UvNhbM/ZZ9S/jJO/6OV3+c0c/I2fOWDJlG8qjbqm cjAN2Y0ne8Kk8oT2qqfmMdoG68ahrrZ2TL7wFzLYBYYyoF272qzoxldWAjC49wEE Xrdq+jSSxIZ9UMUsaCvYXkCUm6tizO6U+LEU4KvSeWEyYfhwf4c= =kgt2 -----END PGP SIGNATURE----- --rXWMGVtRuHP7g9w/--