From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TsMqyc7v; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id 432465A061A for ; Wed, 19 Feb 2025 08:37:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739950635; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=adrm/gMqrEgo5NnxhPqMii9ee1YYwfnGxxdFzG0ZIZY=; b=TsMqyc7vDL/4NEmViTHhIoDMYwGGIYb8CDLMEzW/DQ0IxTqBCNRsE4pD6RF661B4fsheOf J5sqaCCHhsBi0K+KL3zxs4lYG7pexW9NIqAqDHfMJxDuW18C680/0WBW3ET4JMqlyObVQg 2g5Ptrw6at/z+m7S/4qMeJWBiClVIKQ= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-117-h6Tuh7prPlKqBKM1tSedFA-1; Wed, 19 Feb 2025 02:37:13 -0500 X-MC-Unique: h6Tuh7prPlKqBKM1tSedFA-1 X-Mimecast-MFC-AGG-ID: h6Tuh7prPlKqBKM1tSedFA_1739950632 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-ab7fa2b5be0so703521166b.3 for ; Tue, 18 Feb 2025 23:37:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739950632; x=1740555432; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=adrm/gMqrEgo5NnxhPqMii9ee1YYwfnGxxdFzG0ZIZY=; b=O9qF2EZ3m82h9oQIhZk+EAiQbg4cUGs+w0KVQUUK8goCVDRPj7ot5xexELJ2vtX7EG BZ8YyxH/aDHKiEY9ky5JfGc08TFgoz0nAlBMu6imMk3KX8gbAQ//WLNgkZDEE22O3PZN 1saQVTUCsXapFHSXaFLcjG8YtFAHFOQVB/WvECK0pl+723b+EJXw36xaL/awNPQ8rsa8 IEeAor3xmuhTQmVSN9Yhfs6xP46w39xm6sV6yZ3pP8TB4xmHlHw7qe3od12TmQM0qLya BoOe8MC/gxmzN70jZRsD2UKE7jAlpHZ2PXht3/8JFO94/QctSUCDSLN6CQ+/3YXWVUuJ d8yA== X-Forwarded-Encrypted: i=1; AJvYcCXR9u/fjqcWpBxMPQj9/BEhim2uWAgN4q8Ek2wT6zRMIzJyX/P/LJ76qyB6vi8p8nCDEMqAkPLU+Po=@passt.top X-Gm-Message-State: AOJu0YzJ2/JZ4994VNfIFffF4lt4zQTazc6d4FEnsNWmhUBMB6Av7JwB SJ3hXh2I/NjBGFDu3PppRizoPQ/ullJXPqjfxTnHSqZs+DbI00jyZgKNALamV+gPMVRvqZoH+2d 3xH4WHjI/02fwCiJ4+dbJyJYEdtH02TjV/PonytBxk5TnDnP/5eeao0QpvePPn5eFTNGurpjpMG I/QQeTanEfRkK55gtQ6u2HgKY2 X-Gm-Gg: ASbGncuEPeX9P/Iy7Tszk/NuoekhJi8uGggOAC8I0pS8Wup75qubzlgdVDcvwl83DvT tkfVhADK4VadFhAiDHZZ5pn/SLXQNfZlMbWhV+TRqHfYjtWbCB/BBXx77uiHHcKc= X-Received: by 2002:a17:906:32c4:b0:ab6:6018:df18 with SMTP id a640c23a62f3a-abbccd0052emr212215166b.6.1739950632046; Tue, 18 Feb 2025 23:37:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHEx2da771i1tWmv4GXIOWym13UnL8N1QFZtry26lXAt5+GiBXm2BMhZMk7umf4o7asepPGtV5K6bkWHriKlFA= X-Received: by 2002:a17:906:32c4:b0:ab6:6018:df18 with SMTP id a640c23a62f3a-abbccd0052emr212214066b.6.1739950631669; Tue, 18 Feb 2025 23:37:11 -0800 (PST) MIME-Version: 1.0 References: <20250218085231.407699-1-sbrivio@redhat.com> In-Reply-To: From: Enrique Llorente Pastora Date: Wed, 19 Feb 2025 08:37:00 +0100 X-Gm-Features: AWEUYZksnSMdSGt5oSEQIaXd3wKe2qJfA6lTCiG_KgDDtDFsYTyafu9f_KlJMY4 Message-ID: Subject: Re: [PATCH] dhcp: Add option code byte in calculation for OPT_MAX boundary check To: David Gibson X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: e3Zx9x-lNY0D6BTpNeStQFmitfWiQPdmIJuiscf-h8g_1739950632 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 3MWX7D7GUCIJPJKJOB4Y5ZG2BYLDADBI X-Message-ID-Hash: 3MWX7D7GUCIJPJKJOB4Y5ZG2BYLDADBI X-MailFrom: ellorent@redhat.com 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: Stefano Brivio , 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: On Wed, Feb 19, 2025 at 12:21=E2=80=AFAM David Gibson wrote: > > 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: > > > > $ fqdn=3D"thirtytwocharactersforeachlabel.thirtytwocharactersforeachl= abel.thirtytwocharactersforeachlabel.thirtytwocharactersforeachlabel.thirty= twocharactersforeachlabel.thirtytwocharactersforeachlabel.thirtytwocharacte= rsforeachlabel.then_make_it_251_with_this" > > $ hostname=3D"__eighteen_bytes__" > > $ ./pasta --fqdn ${fqdn} -H ${hostname} -p dhcp.pcap -- /sbin/dhclien= t -4 > > Saving packet capture to dhcp.pcap > > $ tshark -r dhcp.pcap -V -Y 'dhcp.option.value =3D=3D 5' | grep "Tota= l Length" > > Total Length: 577 > > > > This was hidden by the issue fixed by commit bcc4908c2b4a ("dhcp > > Remove option 255 length byte") until now. > > > > 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(-) > > > > 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 *off= set) > > size_t slen =3D opts[o].slen; > > > > /* 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; > > > > m->o[*offset] =3D o; > > -- > 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 wa= y > | around. > http://www.ozlabs.org/~dgibson I see "+ 2" better since it is explicit than the alternative of ">=3D OPT_MAX", so LGTM. Reviewed-by: Enrique Llorente --=20 Quique Llorente CNV networking Senior Software Engineer Red Hat EMEA ellorent@redhat.com @RedHat Red Hat Red Hat