lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zpf9mlUXHZfgV+74@debian>
Date: Wed, 17 Jul 2024 19:21:30 +0200
From: Guillaume Nault <gnault@...hat.com>
To: Stephen Hemminger <stephen@...workplumber.org>
Cc: Maks Mishin <maks.mishinfz@...il.com>, netdev@...r.kernel.org
Subject: Re: [PATCH] f_flower: Remove always zero checks

On Wed, Jul 10, 2024 at 04:11:39PM -0700, Stephen Hemminger wrote:
> On Sun,  7 Jul 2024 20:27:41 +0300
> Maks Mishin <maks.mishinfz@...il.com> wrote:
> 
> > Expression 'ttl & ~(255 >> 0)' is always zero, because right operand
> > has 8 trailing zero bits, which is greater or equal than the size
> > of the left operand == 8 bits.
> > 
> > Found by RASU JSC.
> > 
> > Signed-off-by: Maks Mishin <maks.mishinFZ@...il.com>
> > ---
> >  tc/f_flower.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tc/f_flower.c b/tc/f_flower.c
> > index 08c1001a..244f0f7e 100644
> > --- a/tc/f_flower.c
> > +++ b/tc/f_flower.c
> > @@ -1523,7 +1523,7 @@ static int flower_parse_mpls_lse(int *argc_p, char ***argv_p,
> >  
> >  			NEXT_ARG();
> >  			ret = get_u8(&ttl, *argv, 10);
> > -			if (ret < 0 || ttl & ~(MPLS_LS_TTL_MASK >> MPLS_LS_TTL_SHIFT)) {
> > +			if (ret < 0) {
> >  				fprintf(stderr, "Illegal \"ttl\"\n");
> >  				return -1;
> >  			}
> > @@ -1936,7 +1936,7 @@ static int flower_parse_opt(const struct filter_util *qu, char *handle,
> >  			}
> >  			mpls_format_old = true;
> >  			ret = get_u8(&ttl, *argv, 10);
> > -			if (ret < 0 || ttl & ~(MPLS_LS_TTL_MASK >> MPLS_LS_TTL_SHIFT)) {
> > +			if (ret < 0) {
> >  				fprintf(stderr, "Illegal \"mpls_ttl\"\n");
> >  				return -1;
> >  			}
> 
> That is correct mathematically, but perhaps the original author had different idea.
> Could we have review from someone familiar with MPLS support please.

The MPLS TTL field is an 8 bits value. Therefore any successful return
of get_u8() should be valid and this test is indeed not needed.

I guess the original intent was to keep consistency with how the other
MPLS parameters are validated. But TTL is indeed a special case as it's
the only parameter with a "common" length.

Reviewed-by: Guillaume Nault <gnault@...hat.com>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ