All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Cc: <davem@davemloft.net>,
	John Fastabend <john.r.fastabend@intel.com>,
	<netdev@vger.kernel.org>, <gospo@redhat.com>,
	<sassmann@redhat.com>
Subject: Re: [net 8/8] ixgbe: ethtool: stats user buffer overrun
Date: Wed, 8 Feb 2012 15:17:09 +0000	[thread overview]
Message-ID: <1328714229.12637.43.camel@deadeye> (raw)
In-Reply-To: <1328693798-27323-9-git-send-email-jeffrey.t.kirsher@intel.com>

On Wed, 2012-02-08 at 01:36 -0800, Jeff Kirsher wrote:
> From: John Fastabend <john.r.fastabend@intel.com>
> 
> If the number of tx/rx queues changes the ethtool ioctl
> ETHTOOL_GSTATS may overrun the userspace buffer. This
> occurs because the general practice in user space to
> query stats is to issue a ETHTOOL_GSSET cmd to learn the
> buffer size needed, allocate the buffer, then call
> ETHTOOL_GSTIRNGS and ETHTOOL_GSTATS. If the number of
> real_num_queues is changed or flow control attributes
> are changed after ETHTOOL_GSSET but before the
> ETHTOOL_GSTRINGS/ETHTOOL_GSTATS a user space buffer
> overrun occurs.

This is a problem with several ethtool operations - the user buffer size
is implicit.

> To fix the overrun always return the max buffer size
> needed from get_sset_count() then return all strings
> and stats from get_strings()/get_ethtool_stats().
> 
> This _will_ change the output from the ioctl() call
> which could break applications and script parsing in
> theory. I believe these changes should not break existing
> tools because the only changes will be more {tx|rx}_queues
> and the {tx|rx}_pb_* stats will always be returned.
[...]

Yes, this sounds perfectly reasonable.  And this change is definitely
worth making.

However, even if the number of stats (or other attributes) for a device
never change at run-time, devices can be renamed concurrently so that
the second operation runs on a different device!

Perhaps we could change dev_ioctl so that if ifreq::ifr_name is an empty
string then the socket's bound device is used.  However, setting
SO_BINDTODEVICE currently requires CAP_NET_RAW.  Alternately, there
could be some sort of union between ifr_name and an ifindex.

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

  reply	other threads:[~2012-02-08 15:17 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-08  9:36 [net 0/8][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
2012-02-08  9:36 ` [net 1/8] e1000: add dropped DMA receive enable back in for WoL Jeff Kirsher
2012-02-08  9:36 ` [net 2/8] igb: fix vf lookup Jeff Kirsher
2012-02-08 23:42   ` Rose, Gregory V
2012-02-08 23:49     ` Joe Perches
2012-02-08 23:52       ` David Miller
2012-02-08 23:55         ` Rose, Gregory V
2012-02-09  9:10       ` Jeff Kirsher
2012-02-08  9:36 ` [net 3/8] ixgbe: " Jeff Kirsher
2012-02-08 23:33   ` David Miller
2012-02-08 23:39     ` Rose, Gregory V
2012-02-09  9:06     ` Jeff Kirsher
2012-02-08  9:36 ` [net 4/8] ixgbe: Fix case of Tx Hang in PF with 32 VFs Jeff Kirsher
2012-02-08  9:36 ` [net 5/8] ixgbe: Fix broken dependency on MAX_SKB_FRAGS being related to page size Jeff Kirsher
2012-02-08  9:36 ` [net 6/8] ixgbe: do not update real num queues when netdev is going away Jeff Kirsher
2012-02-08  9:36 ` [net 7/8] ixgbe: dcb: up2tc mapping lost on disable/enable CEE DCB state Jeff Kirsher
2012-02-08  9:36 ` [net 8/8] ixgbe: ethtool: stats user buffer overrun Jeff Kirsher
2012-02-08 15:17   ` Ben Hutchings [this message]
2012-02-09  9:34 [net v2 0/8][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
2012-02-09  9:34 ` [net 8/8] ixgbe: ethtool: stats user buffer overrun Jeff Kirsher

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=1328714229.12637.43.camel@deadeye \
    --to=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=gospo@redhat.com \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=john.r.fastabend@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=sassmann@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.