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=e7figOsN; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id F29C85A0265 for ; Tue, 14 Jul 2026 02:05:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202606; t=1783987509; bh=gbeVAV3fmfTiDDHQn/aiLLa4zGmRokUn4/eIe88Vup4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=e7figOsNvUMCBABLkN2K2P+UsdWPxJ7aXIfKCcx4KoISqsFZzCtzd/CXnIxEJknvX rcRxK5XIttUxNgJ+dvI+/cUSzPhPwPnmG7AGG7pdhblkkf/kD+ne8gCsFNCnnTGAKq 9lkKabBFOn+esJSZn8QniBH1968qBjoHEcXPnGjOXJpFVKnkRRDWnsRiv4HNCVlJ8L CSraf4h61WHJttYM915N84SrbiRjKS4fbr3ckD3yF12TN8hiOFAqDOKO6dUjWdn9TM f5CpIKLph0gj3jKbdc7sKpg2bLHt422mOic6Le5sQk24loZ0yt4cV9EYA81tLAPFmL k2v+j3GEHbjDQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gzfh53SB1z4w2B; Tue, 14 Jul 2026 10:05:09 +1000 (AEST) Date: Tue, 14 Jul 2026 10:00:21 +1000 From: David Gibson To: Jon Maloy Subject: Re: [PATCH v2 3/6] tap: Guard IPv6 tail size subtraction against underflow Message-ID: References: <20260709215656.1351549-1-jmaloy@redhat.com> <20260709215656.1351549-4-jmaloy@redhat.com> <88c01537-385f-40ed-821c-ef02f4c742b8@redhat.com> <85b1fb9a-bfee-4f4f-9fda-0beb26f490db@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="NFkl04IMLh9EKgq/" Content-Disposition: inline In-Reply-To: <85b1fb9a-bfee-4f4f-9fda-0beb26f490db@redhat.com> Message-ID-Hash: ZRQAC7B7Q6GNA46TDFXUQIHNO5KJG5DM X-Message-ID-Hash: ZRQAC7B7Q6GNA46TDFXUQIHNO5KJG5DM 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: --NFkl04IMLh9EKgq/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 13, 2026 at 06:17:17AM -0400, Jon Maloy wrote: >=20 >=20 > On 2026-07-13 00:09, David Gibson wrote: > > On Fri, Jul 10, 2026 at 09:40:03AM -0400, Jon Maloy wrote: > > >=20 > > >=20 > > > On 2026-07-09 21:36, David Gibson wrote: > > > > On Thu, Jul 09, 2026 at 05:56:53PM -0400, Jon Maloy wrote: > > > > > In tap6_handler(), iov_tail_size(&data) - sizeof(*ip6h) computes > > > > > the expected payload length. IOV_PEEK_HEADER() guarantees at least > > > > > sizeof(*ip6h) bytes, but add an explicit check to guard the unsig= ned > > > > > subtraction. A too-small tail would indicate a malformed packet, = so > > > > > skip it. > > > > >=20 > > > > > Signed-off-by: Jon Maloy > > > > >=20 > > > > > --- > > > > > v2: Use if-guard instead of assert(), to avoid runtime cost in > > > > > per-packet path and to let the static checker follow the lo= gic. > > >=20 > > > I had the idea that the compiler may be smart enough to optimize it o= ut, > > > since it is logically redundant, as you note. > >=20 > > I mean, maybe, although I think that's moderately unlikely. But > > assert() is nothing but a macro that says essentially > > if (!condition) abort(); > > So if the compiler can optimise away the if, it can optimise away the > > assert() as well. >=20 > Yes. But the analyzer will still mark it as an issue, which it won't if > there is an if-clause. Um.. what? I'm struggling to think of any circumstance in which that would be the case. --=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 --NFkl04IMLh9EKgq/ Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmpVfAoACgkQzQJF27ox 2GcepA/+KqKzJTQlPY83uRv3J+dnM9JKjSZkhC1fHfsuhcPQHuqkfSQjCj50DALG DvtMr+pASFY48i0VldX1Q7U/4mHCNDlBmt6vxWFtbg4TLVUxaDVgSO8gfOcTI4dh TihzDk4AkER7YCgtzu81R0IjjP6ccNHFjiQCqTH8l0qSLFD0qXiQKlEmdjpIGHzs Wc8ffF2JElEuvEbmS5IIJJ6RJ+mByRSZupMwCgFOFUFxBeOt5wpYVO5EqEZThsNr zAWsmvTXBTJMN+cSuLAGhSFkOodMZXQt/36zOnco3zH08h1aeCLf6N6nQJVbePHv utYWI2SysOrnElGazyWvQO05+QbkjSIWTzJsJjBGPZ2GydjLSe3uC+bbei9AXWd1 iURsVWhBV1Nv91qTdPv6Mv+9y5SZcCXKKLiSr7unQhR13y69DouDCPR6oqcUmDTE n3Gw9M7obNiSOmgp9FpMuf18hr1bFVDjU3RMWNiwONvNNAbF6q5afopZ/gtVTZ/c GTwOeL7e3SGy9XfVx+fVDpRJFBmX0MsUlCoLbDixroexbCcT2JuOlDpKezYZDsm9 /rarzNvTQ27vKOoiJ3EhvQX91+8TNzQe9ZdP6fvKfTFQsJiKtA76ASGQny8oqNj7 IZfgGGw/18ihuzf+jsKgbz7IgYKuVpXoW2uTcVbSQ6PYrhmbA60= =WPzA -----END PGP SIGNATURE----- --NFkl04IMLh9EKgq/--