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: <20200508094218.260acc03@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
Date:   Fri, 8 May 2020 09:42:18 -0700
From:   Jakub Kicinski <kuba@...nel.org>
To:     Igor Russkikh <irusskikh@...vell.com>
Cc:     <netdev@...r.kernel.org>, "David S . Miller" <davem@...emloft.net>,
        "Mark Starovoytov" <mstarovoitov@...vell.com>
Subject: Re: [PATCH net-next 7/7] net: atlantic: unify get_mac_permanent

On Fri, 8 May 2020 12:14:51 +0300 Igor Russkikh wrote:
> >> This patch moves MAC generation into a separate function, which is called  
> >> from both places to reduce the amount of copy/paste.  
> > 
> > Right, but why do you have your own mac generation rather than using
> > eth_hw_addr_random(). You need to set NET_ADDR_RANDOM for example,
> > just use standard helpers, please.  
> 
> We want this still be an Aquantia vendor id MAC, not a fully random mac.
> Thats why the logic below randomizes only low three octets.

Are there any other drivers in tree which do that? I think the standard
operating procedure is:

if (!valid) {
	netdev_warn(dev, "Invalid MAC using random\n");
	eth_hw_addr_random(dev);
}

Please see all the eth_hw_addr_random() calls in drivers.

> >> +static inline bool aq_hw_is_zero_ether_addr(const u8 *addr)  
> > 
> > No static inlines in C files, please. Let compiler decide inlineing &
> > generate a warning when function becomes unused.  
> 
> Ok, will fix.
> 
> >> +	get_random_bytes(&rnd, sizeof(unsigned int));
> >> +	l = 0xE300 0000U | (0xFFFFU & rnd) | (0x00 << 16);
> >> +	h = 0x8001300EU;
> >> +
> >> +	mac[5] = (u8)(0xFFU & l);
> >> +	l >>= 8;
> >> +	mac[4] = (u8)(0xFFU & l);
> >> +	l >>= 8;
> >> +	mac[3] = (u8)(0xFFU & l);
> >> +	l >>= 8;
> >> +	mac[2] = (u8)(0xFFU & l);
> >> +	mac[1] = (u8)(0xFFU & h);
> >> +	h >>= 8;
> >> +	mac[0] = (u8)(0xFFU & h);  
> > 
> > This can be greatly simplified using helpers from etherdevice.h, if
> > it's really needed.  
> 
> This is the exact place where we put Aquantia vendor id, even if mac is random.
> 
> eth_hw_addr_random is more suitable for software devices like bridges, which
> are not related to any vendor.

What's the basis for this statement? 

Please look around the existing drivers.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ