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: <3bc71e9a-8e6d-abef-708b-704e3b78c3d7@marvell.com>
Date:   Mon, 18 Oct 2021 21:20:21 +0300
From:   Taras Chornyi <tchornyi@...vell.com>
To:     Jakub Kicinski <kuba@...nel.org>
Cc:     Vladimir Oltean <olteanv@...il.com>,
        "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 Mon, 18 Oct 2021 16:54:00 +0000 Taras Chornyi [C] wrote:
>>> @@ -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
> 
> Thanks for the reply, does it mean we can assume base_mac will be valid
> or should we add a check like below?
> 
We can assume that base mac is always valid in production environment(stored in eeprom),
however if can we can not get base mac it will be generated.

> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c
> index b667f560b931..966f94c6c7a6 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera_main.c
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c
> @@ -338,11 +338,14 @@ static int prestera_port_create(struct prestera_switch *sw, u32 id)
>                 goto err_port_init;
>         }
>  
> -       /* 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;
> +       eth_hw_addr_set_port(dev, sw->base_mac, port->fp_id);
> +       if (memcmp(dev->dev_addr, sw->base_mac, ETH_ALEN - 1)) {
> +               /* firmware requires that port's MAC address consists
> +                * of the first 5 bytes of the base MAC address
> +                */
> +               dev_warn(prestera_dev(sw), "Port MAC address overflows the base for port(%u)\n", id);
> +               dev_addr_mod(dev, 0, sw->base_mac, ETH_ALEN - 1);
> +       }
>  
>         err = prestera_hw_port_mac_set(port, dev->dev_addr);
>         if (err) {
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ