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: <20200708123656.GA13635@chelsio.com>
Date:   Wed, 8 Jul 2020 18:06:57 +0530
From:   Rahul Lakkireddy <rahul.lakkireddy@...lsio.com>
To:     Pavel Machek <pavel@...x.de>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-kernel@...r.kernel.org, stable@...r.kernel.org,
        "David S. Miller" <davem@...emloft.net>,
        Sasha Levin <sashal@...nel.org>, nirranjan@...lsio.com
Subject: Re: [PATCH 4.19 17/36] cxgb4: use correct type for all-mask IP
 address comparison

On Tuesday, July 07/07/20, 2020 at 23:33:26 +0200, Pavel Machek wrote:
> Hi!
> 
> > From: Rahul Lakkireddy <rahul.lakkireddy@...lsio.com>
> > 
> > [ Upstream commit f286dd8eaad5a2758750f407ab079298e0bcc8a5 ]
> > 
> > Use correct type to check for all-mask exact match IP addresses.
> > 
> > Fixes following sparse warnings due to big endian value checks
> > against 0xffffffff in is_addr_all_mask():
> > cxgb4_filter.c:977:25: warning: restricted __be32 degrades to integer
> > cxgb4_filter.c:983:37: warning: restricted __be32 degrades to integer
> > cxgb4_filter.c:984:37: warning: restricted __be32 degrades to integer
> > cxgb4_filter.c:985:37: warning: restricted __be32 degrades to integer
> > cxgb4_filter.c:986:37: warning: restricted __be32 degrades to integer
> 
> > diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
> > index 7dddb9e748b81..86745f33a252d 100644
> > --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
> > +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
> > @@ -810,16 +810,16 @@ static bool is_addr_all_mask(u8 *ipmask, int family)
> >  		struct in_addr *addr;
> >  
> >  		addr = (struct in_addr *)ipmask;
> > -		if (addr->s_addr == 0xffffffff)
> > +		if (ntohl(addr->s_addr) == 0xffffffff)
> 
> Endianity does not really matter for ~0, but can compiler figure it
> out?
> 
> would it be better to do these tests as 
> 
>       if (foo == htonl(0xffffffff))
> 
> to make it clear to the compiler?
> 

Sure, I'll update all checks to follow above approach. Will send a
patch.

> 
> >  	} else if (family == AF_INET6) {
> >  		struct in6_addr *addr6;
> >  
> >  		addr6 = (struct in6_addr *)ipmask;
> > -		if (addr6->s6_addr32[0] == 0xffffffff &&
> > -		    addr6->s6_addr32[1] == 0xffffffff &&
> > -		    addr6->s6_addr32[2] == 0xffffffff &&
> > -		    addr6->s6_addr32[3] == 0xffffffff)
> > +		if (ntohl(addr6->s6_addr32[0]) == 0xffffffff &&
> > +		    ntohl(addr6->s6_addr32[1]) == 0xffffffff &&
> > +		    ntohl(addr6->s6_addr32[2]) == 0xffffffff &&
> > +		    ntohl(addr6->s6_addr32[3]) == 0xffffffff)
> >  			return true;
> >  	}
> >  	return false;
> 

Thanks,
Rahul

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ