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=fgx7TlQv; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 432865A0269 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=1783564947; bh=Go/GNTj+wM+8Uq7Vz/UUbbgXR1aH1nJ/hVropF2KapM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fgx7TlQv7P8+BzrjiXUpzsLyhnHYDDZp3cY3DH1nVbs7/3RRxkoLcYSL6U/UGyGhs NKPaZ6mIYyYiMwBXDLhxN2yVVwFssKaXbRFmrmLs+/1evMd1wOJLcoNX4GNfIXjY+e bU6YN3Sxab2xqVSnWJTIMA1Cv4eOlrTeS3eShmcm3eVF3NCs07e88c3P/rPb2eJ1Zf gNmPZAWi9WacLwIijMcq6hpW7pYYngtcNcJvzyZz7L5yc1ee+lAR0DhJ/xWmVqEAJC 1VuCFHHZQZtkNsFrKeTXCyRwHK3GlkRjXzqMtY4ImaQgUymVBHOQgLHpmo0f18qTii FJQZGeeUoChLA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gwfPt72hzz4xGg; Thu, 09 Jul 2026 12:42:26 +1000 (AEST) Date: Thu, 9 Jul 2026 12:13:06 +1000 From: David Gibson To: Jon Maloy Subject: Re: [PATCH 3/7] tap: Assert IPv6 tail size before subtracting header length Message-ID: References: <20260708223203.885345-1-jmaloy@redhat.com> <20260708223203.885345-4-jmaloy@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="q5m3nuUTzWHM8wiM" Content-Disposition: inline In-Reply-To: <20260708223203.885345-4-jmaloy@redhat.com> Message-ID-Hash: EIK3FM6MUXUBJA5ZVPYQUX5IEW5OG7UK X-Message-ID-Hash: EIK3FM6MUXUBJA5ZVPYQUX5IEW5OG7UK 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: --q5m3nuUTzWHM8wiM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 08, 2026 at 06:31:59PM -0400, Jon Maloy wrote: > In tap6_handler(), iov_tail_size(&data) - sizeof(*ip6h) is used to > compute the expected payload length. The subtraction is safe because > IOV_PEEK_HEADER() already verified that the tail contains at least > sizeof(*ip6h) bytes, but add an assert to make the invariant > explicit. Again, I think "assumption" would be clearer. I think of "invariant" as something that applies at every iteration of a loop, or to a data structure at all times, rather than just to a particular variable at a particular point >=20 > Signed-off-by: Jon Maloy Reviewed-by: David Gibson > --- > tap.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) >=20 > diff --git a/tap.c b/tap.c > index 6d93c7ce..d0d5148e 100644 > --- a/tap.c > +++ b/tap.c > @@ -986,7 +986,9 @@ resume: > if (!ip6h) > continue; > =20 > - check =3D iov_tail_size(&data) - sizeof(*ip6h); > + check =3D iov_tail_size(&data); > + assert(check >=3D sizeof(*ip6h)); > + check -=3D sizeof(*ip6h); > =20 > saddr =3D &ip6h->saddr; > daddr =3D &ip6h->daddr; > --=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 --q5m3nuUTzWHM8wiM Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmpPA7EACgkQzQJF27ox 2Gd9kA/7B/0D5b74hW2XZcGRngeBU5fLa6ujTlKMeDhfiEp8SWKkiyOaRWtBieO7 tjkw/Dc+S1BfYSBi3WHb19jOdPu1solTovFG8pcrWEzMY+bqjh2rP/xGa6nSxCC2 NegHaypjs5+rgaO2zE1Yt+PA0tnuhV4410jKNfFxinbC9LxMcZgIOYeosjAvxpWn tM52AbWDv+jTTaBi5mXPYsh/tMBVWtNFFtV5FWclaP4aresCKDQP6ie79ENJa6UV a+Y8STfTZh+XzTmkK9Q+6r2+3Rd+dsjE8cAH3XzuwE5vdVsPUMqwyTt/g2+OqcBP SOFTPNwoQVCR/OI8g1DojP4OzW/CIMZQQwawdQ2SR5gmyZGzmjEwigjCBmGWrDww I4728iC8Xm0EwWD2OuyGeXb64p1TGyGfRkdJqOlvSej4bR4fUgsgw+6mP5VfeX+6 v1CcSCTAWEdIaZrR8r3Wlc9uXMjusBz5vFKwbmJNsEG1Qs6z/NU1SwwehE7qJpTk rROdw9x519j/Cc9ONQ2aeeSNPvy1O8GyOYEzK7fF6cCuqk0yb8oMmxBYPkWOuf7r oJLIrM8AxHeK/Hk2XnyHu8nrVbpWGfrQhIzfPCgCPgNglAEpJs+nEEVsVyYVi8rz NitwEW52FU89Vk/GWoaA9dMk1g4uBJxv/9xBQ5S+D34q85t+hoU= =Jhxi -----END PGP SIGNATURE----- --q5m3nuUTzWHM8wiM--