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: <CO6PR18MB4083DDE34183B96B4D882D60C4BC9@CO6PR18MB4083.namprd18.prod.outlook.com>
Date:   Mon, 18 Oct 2021 16:54:00 +0000
From:   "Taras Chornyi [C]" <tchornyi@...vell.com>
To:     Vladimir Oltean <olteanv@...il.com>,
        Jakub Kicinski <kuba@...nel.org>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "andrew@...n.ch" <andrew@...n.ch>,
        "idosch@...sch.org" <idosch@...sch.org>,
        "f.fainelli@...il.com" <f.fainelli@...il.com>,
        "Vadym Kochan [C]" <vkochan@...vell.com>
Subject: Re: Re: [RFC net-next 3/6] ethernet: prestera: use
 eth_hw_addr_set_port()


----------------------------------------------------------------------
On Fri, Oct 15, 2021 at 12:38:45PM -0700, Jakub Kicinski wrote:
> Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
> of VLANs...") introduced a rbtree for faster Ethernet address look
> up. To maintain netdev->dev_addr in this tree we need to make all
> the writes to it got through appropriate helpers.
>
> We need to make sure the last byte is zeroed.
>
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
> CC: vkochan@...vell.com
> CC: tchornyi@...vell.com
> ---
>  drivers/net/ethernet/marvell/prestera/prestera_main.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c
> index b667f560b931..7d179927dabe 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera_main.c
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c
> @@ -290,6 +290,7 @@ static int prestera_port_create(struct prestera_switch *sw, u32 id)
>  {
>       struct prestera_port *port;
>       struct net_device *dev;
> +     u8 addr[ETH_ALEN] = {};
>       int err;
>
>       dev = alloc_etherdev(sizeof(*port));
> @@ -341,8 +342,8 @@ static int prestera_port_create(struct prestera_switch *sw, u32 id)
>       /* firmware requires that port's MAC address consist of the first
>        * 5 bytes of the base MAC address
>        */
> -     memcpy(dev->dev_addr, sw->base_mac, dev->addr_len - 1);
> -     dev->dev_addr[dev->addr_len - 1] = port->fp_id;
> +     memcpy(addr, sw->base_mac, dev->addr_len - 1);

This code is a bit buggy.  We do care about the last byte of the base mac address.
For example if base mac is xx:xx:xx:xx:xx:10 first port mac should be  xx:xx:xx:xx:xx:11

> +     eth_hw_addr_set_port(dev, addr, port->fp_id);

Instead of having yet another temporary copy, can't we zero out
sw->base_mac[ETH_ALEN - 1] in prestera_switch_set_base_mac_addr()?

>
>       err = prestera_hw_port_mac_set(port, dev->dev_addr);
>       if (err) {
> --
> 2.31.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ