From: Joe Perches <joe@perches.com>
To: madalin.bucur@freescale.com
Cc: netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-kernel@vger.kernel.org, davem@davemloft.net,
scottwood@freescale.com, igal.liberman@freescale.com,
roy.pledge@freescale.com, ppc@mindchasers.com,
pebolle@tiscali.nl, joakim.tjernlund@transmode.se,
gregkh@linuxfoundation.org,
Ioana Ciornei <ioana.ciornei@freescale.com>
Subject: Re: [net-next v4 6/8] dpaa_eth: add ethtool statistics
Date: Mon, 02 Nov 2015 12:39:48 -0800 [thread overview]
Message-ID: <1446496788.24485.69.camel@perches.com> (raw)
In-Reply-To: <1446485500-9782-7-git-send-email-madalin.bucur@freescale.com>
On Mon, 2015-11-02 at 19:31 +0200, Madalin Bucur wrote:
> Add a series of counters to be exported through ethtool:
> - add detailed counters for reception errors;
> - add detailed counters for QMan enqueue reject events;
> - count the number of fragmented skbs received from the stack;
> - count all frames received on the Tx confirmation path;
> - add congestion group statistics;
> - count the number of interrupts for each CPU.
[]
> diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c
[]
> +static void dpa_get_strings(struct net_device *net_dev, u32 stringset, u8 *data)
> +{
> + unsigned int i, j, num_cpus, size;
> + char string_cpu[ETH_GSTRING_LEN];
> + u8 *strings;
> +
> + strings = data;
> + num_cpus = num_online_cpus();
> + size = DPA_STATS_GLOBAL_LEN * ETH_GSTRING_LEN;
> +
> + for (i = 0; i < DPA_STATS_PERCPU_LEN; i++) {
> + for (j = 0; j < num_cpus; j++) {
> + snprintf(string_cpu, ETH_GSTRING_LEN, "%s [CPU %d]",
> + dpa_stats_percpu[i], j);
> + memcpy(strings, string_cpu, ETH_GSTRING_LEN);
> + strings += ETH_GSTRING_LEN;
> + }
> + snprintf(string_cpu, ETH_GSTRING_LEN, "%s [TOTAL]",
> + dpa_stats_percpu[i]);
> + memcpy(strings, string_cpu, ETH_GSTRING_LEN);
> + strings += ETH_GSTRING_LEN;
> + }
> + memcpy(strings, dpa_stats_global, size);
> +}
This leaks uninitialized stack via a memcpy of uninitialized
string_cpu bytes into user-space.
Using
char string_cpu[ETH_GSTRING_LEN] = {};
or a memset before each snprintf would fix it.
next prev parent reply other threads:[~2015-11-02 20:39 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-02 17:31 [net-next v4 0/8] dpaa_eth: Add the Freescale DPAA Ethernet driver Madalin Bucur
2015-11-02 17:31 ` [net-next v4 1/8] devres: add devm_alloc_percpu() Madalin Bucur
2015-11-02 19:51 ` Joe Perches
2015-11-02 17:31 ` [net-next v4 2/8] dpaa_eth: add support for DPAA Ethernet Madalin Bucur
2015-11-02 19:51 ` Joe Perches
2015-11-03 7:55 ` Joakim Tjernlund
2015-11-03 9:37 ` Madalin-Cristian Bucur
2015-11-03 11:23 ` Joakim Tjernlund
2015-11-03 13:21 ` Madalin-Cristian Bucur
2015-11-11 3:35 ` Scott Wood
2015-11-02 17:31 ` [net-next v4 3/8] dpaa_eth: add support for S/G frames Madalin Bucur
2015-11-02 20:07 ` Joe Perches
2015-11-03 9:41 ` Madalin-Cristian Bucur
2015-11-02 21:03 ` Joe Perches
2015-11-02 17:31 ` [net-next v4 4/8] dpaa_eth: add driver's Tx queue selection Madalin Bucur
2015-12-02 21:40 ` Scott Wood
2015-12-03 10:02 ` Madalin-Cristian Bucur
2015-12-03 19:37 ` Scott Wood
2015-11-02 17:31 ` [net-next v4 5/8] dpaa_eth: add ethtool functionality Madalin Bucur
2015-11-02 17:31 ` [net-next v4 6/8] dpaa_eth: add ethtool statistics Madalin Bucur
2015-11-02 20:39 ` Joe Perches [this message]
2015-11-02 17:31 ` [net-next v4 7/8] dpaa_eth: add sysfs exports Madalin Bucur
2015-11-02 17:31 ` [net-next v4 8/8] dpaa_eth: add trace points Madalin Bucur
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1446496788.24485.69.camel@perches.com \
--to=joe@perches.com \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=igal.liberman@freescale.com \
--cc=ioana.ciornei@freescale.com \
--cc=joakim.tjernlund@transmode.se \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=madalin.bucur@freescale.com \
--cc=netdev@vger.kernel.org \
--cc=pebolle@tiscali.nl \
--cc=ppc@mindchasers.com \
--cc=roy.pledge@freescale.com \
--cc=scottwood@freescale.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).