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]
Date:   Mon, 30 Nov 2020 14:17:48 +0100
From:   Steen Hegelund <steen.hegelund@...rochip.com>
To:     Andrew Lunn <andrew@...n.ch>
CC:     "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Masahiro Yamada <masahiroy@...nel.org>,
        Lars Povlsen <lars.povlsen@...rochip.com>,
        Bjarni Jonasson <bjarni.jonasson@...rochip.com>,
        Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Microsemi List <microsemi@...ts.bootlin.com>,
        <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH 2/3] net: sparx5: Add Sparx5 switchdev driver

On 28.11.2020 19:45, Andrew Lunn wrote:
>EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
>> +/* Add a potentially wrapping 32 bit value to a 64 bit counter */
>> +static inline void sparx5_update_counter(u64 *cnt, u32 val)
>> +{
>> +     if (val < (*cnt & U32_MAX))
>> +             *cnt += (u64)1 << 32; /* value has wrapped */
>> +
>> +     *cnt = (*cnt & ~(u64)U32_MAX) + val;
>> +}
>
>I don't follow what this is doing. Could you give some examples?

The statistics counters comes from different sources, and unfortunately
have different layouts: Some are 32 bit and some a 40 bit, so this
function is a wrapper to be able to handle them in the same way, polling
the counters often enough to be able to catch overruns.

>
>> +static const char *const sparx5_stats_layout[] = {
>> +     "rx_in_bytes",
>> +     "rx_symbol_err",
>> +     "rx_pause",
>> +     "rx_unsup_opcode",
>
>> +static void sparx5_update_port_stats(struct sparx5 *sparx5, int portno)
>> +{
>> +     struct sparx5_port *spx5_port = sparx5->ports[portno];
>> +     bool high_speed_dev = sparx5_is_high_speed_device(&spx5_port->conf);
>
>Reverse christmas tree. Which in this case, means you need to move the
>assignment into the body of the code.

OK.
>
>> +static void sparx5_get_sset_strings(struct net_device *ndev, u32 sset, u8 *data)
>> +{
>> +     struct sparx5_port *port = netdev_priv(ndev);
>> +     struct sparx5  *sparx5 = port->sparx5;
>> +     int idx;
>> +
>> +     if (sset != ETH_SS_STATS)
>> +             return;
>> +
>> +     for (idx = 0; idx < sparx5->num_stats; idx++)
>> +             memcpy(data + idx * ETH_GSTRING_LEN,
>> +                    sparx5->stats_layout[idx], ETH_GSTRING_LEN);
>
>You cannot use memcpy here, because the strings you have defined are
>not ETH_GSTRING_LEN long. We once had a driver which happened to have
>its strings at the end of a page. The memcpy would copy the string,
>but keep going passed the end of string, over the page boundary, and
>trigger a segmentation fault.

Yes, I see that.

Thanks for the comments
/Steen
>
>        Andrew

BR
Steen

---------------------------------------
Steen Hegelund
steen.hegelund@...rochip.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ