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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <DB8PR04MB6985C93B234BE22BDB4E30FFECE20@DB8PR04MB6985.eurprd04.prod.outlook.com>
Date:   Thu, 5 Mar 2020 17:01:46 +0000
From:   "Madalin Bucur (OSS)" <madalin.bucur@....nxp.com>
To:     Sascha Hauer <s.hauer@...gutronix.de>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: RE: [PATCH v2] fsl/fman: Use random MAC address when none is given

> -----Original Message-----
> From: netdev-owner@...r.kernel.org <netdev-owner@...r.kernel.org> On
> Behalf Of Sascha Hauer
> Sent: Thursday, March 5, 2020 5:36 PM
> To: Madalin Bucur <madalin.bucur@....com>
> Cc: netdev@...r.kernel.org
> Subject: Re: [PATCH v2] fsl/fman: Use random MAC address when none is
> given
> 
> On Thu, Mar 05, 2020 at 03:03:48PM +0000, Madalin Bucur wrote:
> > > -----Original Message-----
> > > From: Sascha Hauer <s.hauer@...gutronix.de>
> > > Sent: Thursday, March 5, 2020 4:48 PM
> > > To: Madalin Bucur <madalin.bucur@....com>
> > > Cc: netdev@...r.kernel.org
> > > Subject: Re: [PATCH v2] fsl/fman: Use random MAC address when none is
> > > given
> > >
> > > On Thu, Mar 05, 2020 at 01:38:01PM +0000, Madalin Bucur wrote:
> > > > > -----Original Message-----
> > > > > From: Sascha Hauer <s.hauer@...gutronix.de>
> > > > > Sent: Thursday, March 5, 2020 2:34 PM
> > > > > To: netdev@...r.kernel.org
> > > > > Cc: Madalin Bucur <madalin.bucur@....com>; Sascha Hauer
> > > > > <s.hauer@...gutronix.de>
> > > > > Subject: [PATCH v2] fsl/fman: Use random MAC address when none is
> > > given
> > > > >
> > > > > There's no need to fail probing when no MAC address is given in
> the
> > > > > device tree, just use a random MAC address.
> > > > >
> > > > > Signed-off-by: Sascha Hauer <s.hauer@...gutronix.de>
> > > > > ---
> > > > >
> > > > > Changes since v1:
> > > > > - Remove printing of permanent MAC address
> > > > >
> > > > >  drivers/net/ethernet/freescale/dpaa/dpaa_eth.c   | 11 +++++++++-
> -
> > > > >  drivers/net/ethernet/freescale/fman/fman_memac.c |  4 ----
> > > > >  drivers/net/ethernet/freescale/fman/mac.c        | 10 ++--------
> > > > >  3 files changed, 11 insertions(+), 14 deletions(-)
> > > > >
> > > > > diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> > > > > b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> > > > > index fd93d542f497..fc117eab788d 100644
> > > > > --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> > > > > +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> > > > > @@ -233,8 +233,15 @@ static int dpaa_netdev_init(struct
> net_device
> > > > > *net_dev,
> > > > >  	net_dev->features |= net_dev->hw_features;
> > > > >  	net_dev->vlan_features = net_dev->features;
> > > > >
> > > > > -	memcpy(net_dev->perm_addr, mac_addr, net_dev->addr_len);
> > > > > -	memcpy(net_dev->dev_addr, mac_addr, net_dev->addr_len);
> > > > > +	if (is_valid_ether_addr(mac_addr)) {
> > > > > +		dev_info(dev, "FMan MAC address: %pM\n", mac_addr);
> > > > > +		memcpy(net_dev->perm_addr, mac_addr, net_dev-
> >addr_len);
> > > > > +		memcpy(net_dev->dev_addr, mac_addr, net_dev->addr_len);
> > > > > +	} else {
> > > > > +		eth_hw_addr_random(net_dev);
> > > > > +		dev_info(dev, "Using random MAC address: %pM\n",
> > > > > +			 net_dev->dev_addr);
> > > > > +	}
> > > >
> > > > To make the HW MAC aware of the new random address you set in the
> > > dpaa_eth,
> > > > you also need to call mac_dev->change_addr() after
> > > eth_hw_addr_random(), like
> > > > it's done in dpaa_set_mac_address():
> > > >
> > > >         err = mac_dev->change_addr(mac_dev->fman_mac,
> > > >                                    (enet_addr_t *)net_dev-
> >dev_addr);
> > > >
> > > > This will write the new MAC address in the MAC HW registers.
> > >
> > > Ok, I see.
> > >
> > > So when I call mac_dev->change_addr() here in dpaa_netdev_init() it
> > > means I can remove all the code setting the MAC address in hardware
> > > before this point, right?
> >
> > It's not an issue if you just write it here for the random address and
> leave
> > the previous functionality in place.
> 
> No, it's not. It's only that the code becomes rather useless once we
> overwrite the MAC address here anyway.
> 
> > Do you have a board to validate your changes?
> 
> I have a LS1046a based board, yes.
> 
> Sascha

I'll send a v3 addressing all MAC types.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ