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=202502 header.b=fuVJURhO; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 37A8F5A0271 for ; Wed, 19 Feb 2025 00:21:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202502; t=1739920907; bh=Gaff2Mgkd8hsjiMAWRgYam1ZTptC+HNmljr0+j3OEXI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fuVJURhOoPZjSrNP18LhtYLY6tJgVcQZdegootWIh4BIHCdh886tqvuvO/hnDt/YF LmWpIhua/Nv+lL7E9yOY4IsQJUQX7ZnntGIzQdHe9fwBPe6bCYiycTL0T2hXUOpTmF 5uqKtXjrJO+VMvZ1+qKQwMe7qNNFxGbsLtfU3c+6JSo//+dOhF1t98awjXptb1AxMy eHCcOsuhX4H700oIj8wlC02/nARMP8oQCj7t26fFsc3bz8hdazgAH1JRRBdYus8zf8 6HTtgIk0dyoCSNL9inI7/zjhZrdvAWglBLbaJe1n0odD/ZMqO3kbeK8RPF8q+s41jy fpC/SOKv9Q9/Q== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4YyFsR35qCz4wyh; Wed, 19 Feb 2025 10:21:47 +1100 (AEDT) Date: Wed, 19 Feb 2025 10:20:07 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] dhcp: Add option code byte in calculation for OPT_MAX boundary check Message-ID: References: <20250218085231.407699-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="URAB8NqDYzUYLc5P" Content-Disposition: inline In-Reply-To: <20250218085231.407699-1-sbrivio@redhat.com> Message-ID-Hash: PMFKOUZKFXG62OA3CIHLHSWY33BOIB4S X-Message-ID-Hash: PMFKOUZKFXG62OA3CIHLHSWY33BOIB4S 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: passt-dev@passt.top, Enrique Llorente 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: --URAB8NqDYzUYLc5P Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Feb 18, 2025 at 09:52:31AM +0100, Stefano Brivio wrote: > Otherwise we'll limit messages to 577 bytes, instead of 576 bytes as > intended: >=20 > $ fqdn=3D"thirtytwocharactersforeachlabel.thirtytwocharactersforeachlab= el.thirtytwocharactersforeachlabel.thirtytwocharactersforeachlabel.thirtytw= ocharactersforeachlabel.thirtytwocharactersforeachlabel.thirtytwocharacters= foreachlabel.then_make_it_251_with_this" > $ hostname=3D"__eighteen_bytes__" > $ ./pasta --fqdn ${fqdn} -H ${hostname} -p dhcp.pcap -- /sbin/dhclient = -4 > Saving packet capture to dhcp.pcap > $ tshark -r dhcp.pcap -V -Y 'dhcp.option.value =3D=3D 5' | grep "Total = Length" > Total Length: 577 >=20 > This was hidden by the issue fixed by commit bcc4908c2b4a ("dhcp > Remove option 255 length byte") until now. >=20 > Fixes: 31e8109a86ee ("dhcp, dhcpv6: Add hostname and client fqdn ops") > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > dhcp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/dhcp.c b/dhcp.c > index 4a209f1..b7d5ea3 100644 > --- a/dhcp.c > +++ b/dhcp.c > @@ -143,7 +143,7 @@ static bool fill_one(struct msg *m, int o, int *offse= t) > size_t slen =3D opts[o].slen; > =20 > /* If we don't have space to write the option, then just skip */ > - if (*offset + 1 /* length of option */ + slen > OPT_MAX) > + if (*offset + 2 /* code and length of option */ + slen > OPT_MAX) > return true; > =20 > m->o[*offset] =3D o; --=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 --URAB8NqDYzUYLc5P Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAme1FZcACgkQzQJF27ox 2Ge2HBAAia5SNtzgNpjFVPzKsfqQ4242laz0NK0m9U6TwoWpaTmmjvKprIZAFAa+ VmQJjeRcL/qCTjSBG4nt/wfWE3iJ8cqhqtUKkr3QG+AjxjPX8nGfs283/mkdqx6L 6GqPcVbOcN1pBjpzF13dgvMTSgIZxBkgAp6PGy9y9wn97PMt6N6DNdSzPSfATYjr qF9tbkf8FgYqvfttfOiDX/FBgyxuuDV/WReupGW4u6oyoegMEsIaESFlEXlVjkql 0XjWQt9IuwHE3Fej7awpRsk/7UcupZl+TiGxlaHVvMuzstdROmc9fP6pEra+oFqO THfLy93lnqmvWjSzjFD6iA0a4/aYId+yWpxiM3lc6e4NTXuUIge6TCvQ3O17lcnI 8Hw36ftJR91oepy2OTSbE2yY5irbEJ59KG7iJuv9O5SovBa3OJML2i+vAZ/RAaWi zKAUoZV3TUm0NObYE5EGVGJQIbF/+rZfvsiWGutqkDpjmtet6Nr83X+avHPfnqs3 +vq5Lcl7N1xl69P5N15Xn5Jc+Eyic5607v7jX8qeCqzXETV6DtMR9pYiYwVqERLE cv4nJ52J4gEAQVIjkMA9/0yQzgUPDM9bPWFOliQ00nwczuc7i0BEPU/L51Qg607q I/6E6wTc3RurFbw5qRUW0bq8K+S6+KWRwctGiUeduDyf5J/B3fQ= =jxaf -----END PGP SIGNATURE----- --URAB8NqDYzUYLc5P--