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:	Fri, 03 Jun 2016 18:57:48 +0100
From:	Ben Hutchings <ben@...adent.org.uk>
To:	Florian Fainelli <f.fainelli@...il.com>, netdev@...r.kernel.org
Cc:	davem@...emloft.net, zajec5@...il.com, nbd@....name,
	hauke@...ke-m.de, jon.mason@...adcom.com
Subject: Re: [PATCH net-next 2/2] bgmac: Add support for ethtool statistics

On Fri, 2016-06-03 at 10:07 -0700, Florian Fainelli wrote:
[...]
> +static void bgmac_get_strings(struct net_device *dev, u32 stringset,
> +			      u8 *data)
> +{
> +	int i;
> +
> +	if (stringset != ETH_SS_STATS)
> +		return;
> +
> +	for (i = 0; i < BGMAC_STATS_LEN; i++)
> +		memcpy(data + i * ETH_GSTRING_LEN,
> +		       bgmac_get_strings_stats[i].name,
> +		       ETH_GSTRING_LEN);

These strings are null-terminated, not padded to ETH_GSTRING_LEN.  So
here you should be using strlcpy() instead of memcpy().

> +}
> +
> +static void bgmac_get_ethtool_stats(struct net_device *dev,
> +				    struct ethtool_stats *ss, uint64_t *data)
> +{
> +	struct bgmac *bgmac = netdev_priv(dev);
> +	const struct bgmac_stat *s;
> +	unsigned int i;
> +	u64 val;
> +
> +	if (!netif_running(dev))
> +		return;
> +
> +	for (i = 0; i < BGMAC_STATS_LEN; i++) {
> +		s = &bgmac_get_strings_stats[i];
> +		val = 0;
> +		if (s->size == 8)
> +			val = (u64)bgmac_read(bgmac, s->offset + 4);

Isn't this missing a << 32?

Does reading the high 32 bits latch the value of the low 32 bits?  If
not, you need to read the high bits again after the low bits and retry
if they changed.

> +		val |= bgmac_read(bgmac, s->offset);
> +		data[i] = (u64)val;

Redundant cast.

Ben.

> +	}
> +}
[...]

-- 
Ben Hutchings
Nothing is ever a complete failure; it can always serve as a bad
example.

Download attachment "signature.asc" of type "application/pgp-signature" (820 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ