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=EcA6GtoC; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 879485A0265 for ; Fri, 10 Jul 2026 03:37:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202606; t=1783647461; bh=NcDmmYXMxxK0z5pXSKmAdm2MOoBmV3EPgrGgVlK46BA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EcA6GtoCY7BhqBWbz79gU26R62XGGbx0Q/mMRsQ6izyPeh8pQTvxSaz9NkQIouomB Hi3DCKMv9i6aZzsQJDSyfNFFbpl9LZRo1971JuCe6F1QjFxslyeNkWaDFHzVaJb573 b1XWbcN4FYIs2QsNdgdmpeRJtwaNbPyEJVdDxTj3/ABx0oLHsKAQ8SEW5kfltLYlqg aHE3uz9znFtETnP2RRIRYum8WWugQk9d36B3ZULB7/3bJWyFsI+ruETWjH4IRs5NMa ozrEzTv/ELOWMzOLFCc9cZQGy+xGuH0Hq1ojGNuASmkMD2M+UJANmVf4RpczaKLVGZ L1Yp+Me/xvChA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gxDwj0ywcz58dS; Fri, 10 Jul 2026 11:37:41 +1000 (AEST) Date: Fri, 10 Jul 2026 11:36:07 +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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="fcQ+1UIpXANfIQhg" Content-Disposition: inline In-Reply-To: <20260709215656.1351549-4-jmaloy@redhat.com> Message-ID-Hash: VUGAXHJEBZGY2SVBTHXWHDGUTWHTVMSQ X-Message-ID-Hash: VUGAXHJEBZGY2SVBTHXWHDGUTWHTVMSQ 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: --fcQ+1UIpXANfIQhg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 unsigned > 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 logic. Why would the if be cheaper than an assert()? The IOV_PEEK_HEADER() already checks the length, so this check is definitely redundant - it exists only for the benefit of static checkers. > --- > tap.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) >=20 > diff --git a/tap.c b/tap.c > index 6d93c7ce..6fd5f595 100644 > --- a/tap.c > +++ b/tap.c > @@ -986,7 +986,10 @@ resume: > if (!ip6h) > continue; > =20 > - check =3D iov_tail_size(&data) - sizeof(*ip6h); > + check =3D iov_tail_size(&data); > + if (check < sizeof(*ip6h)) > + continue; > + 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 --fcQ+1UIpXANfIQhg Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmpQTH4ACgkQzQJF27ox 2GfiEA/6Aoa5ESHyrUG4CGSU/R4QG19ccUzP+7gB1SLPvauafPI4yw9RevFfjdCf gfZh4WGC/+TL6aAgEhVI6VM9VYgPTqhUES4qT8dsXfgLMQEySrsy0f/PFresEurP mETu6I79jUI9iNrky4KRVVaVdGmiJZFAm9bSE96JZcguaK43PNUoOkywO3jq2egb 38+L3O49QScoyb6ANer3ctbjyO+IJigl3rTfj9bSfdDYXPHF5Cspwe7SaK17hHlS MR1wckQJ8XnBhXGWTA8q9THflEy/0C9JE3hHKW9BgpehTBUuPiHi13gVnu6mDQvO vQGmle0Fg4RgOuUj4kFEknGr5h4LO54SBymII/SbIFElrKjUN/iv+176Y1BpEjus W6MzEr/x3r7VDXVMH05xcwZUf8lQX58uWXMELZqRhCfUwOj2HuSfpBD3VxBUywze GE3Y0bj/Um18VGoYuaKk8aZ5Szhb3Maf9hQyBMJywZSGVJ53ua70VIb0hBm67ns/ kd16XOki9pWxZwGoozXmAhtt4vho2R59ngtOs3/Y7HV64KmE9BuVq0mZ9eqROj/y hZtt5/dpJUikYAX5IYck215qNzjh3vEesASLonzbCp1f7FWD4PxCabL1hdg5rv6o JLKCxkMxA7xUMINmv4yIXTLriHE8FLq71LstJthp5VAU8lJqgFo= =2Lb+ -----END PGP SIGNATURE----- --fcQ+1UIpXANfIQhg--