public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Enrique Llorente Pastora <ellorent@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: Stefano Brivio <sbrivio@redhat.com>, passt-dev@passt.top
Subject: Re: [PATCH] dhcp: Add option code byte in calculation for OPT_MAX boundary check
Date: Wed, 19 Feb 2025 08:37:00 +0100	[thread overview]
Message-ID: <CAHVoYmJVPQ6rMjML1D+bbOAwmUJk54ZN6wQUeYbnu+yVT-yiJw@mail.gmail.com> (raw)
In-Reply-To: <Z7UVp0Bl3mwmT_ZR@zatzit>

On Wed, Feb 19, 2025 at 12:21 AM David Gibson
<david@gibson.dropbear.id.au> 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="thirtytwocharactersforeachlabel.thirtytwocharactersforeachlabel.thirtytwocharactersforeachlabel.thirtytwocharactersforeachlabel.thirtytwocharactersforeachlabel.thirtytwocharactersforeachlabel.thirtytwocharactersforeachlabel.then_make_it_251_with_this"
> >   $ hostname="__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 == 5' | grep "Total 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 <sbrivio@redhat.com>
>
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
>
> > ---
> >  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 *offset)
> >       size_t slen = 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] = 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 way
>                                 | around.
> http://www.ozlabs.org/~dgibson

I see  "+ 2" better since it is explicit than the alternative of ">=
OPT_MAX", so LGTM.

Reviewed-by: Enrique Llorente <ellorent@redhat.com>

-- 
Quique Llorente

CNV networking Senior Software Engineer

Red Hat EMEA

ellorent@redhat.com

@RedHat   Red Hat  Red Hat


      reply	other threads:[~2025-02-19  7:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-18  8:52 [PATCH] dhcp: Add option code byte in calculation for OPT_MAX boundary check Stefano Brivio
2025-02-18 23:20 ` David Gibson
2025-02-19  7:37   ` Enrique Llorente Pastora [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHVoYmJVPQ6rMjML1D+bbOAwmUJk54ZN6wQUeYbnu+yVT-yiJw@mail.gmail.com \
    --to=ellorent@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).