netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: Anirban Chakraborty <anirban.chakraborty@qlogic.com>
Cc: netdev@vger.kernel.org, David Miller <davem@davemloft.net>
Subject: Re: [PATCHv3 net-next-2.6 2/3] qlcnic: Take FW dump via ethtool
Date: Thu, 12 May 2011 18:27:22 +0100	[thread overview]
Message-ID: <1305221242.5214.36.camel@bwh-desktop> (raw)
In-Reply-To: <1305154448-9687-4-git-send-email-anirban.chakraborty@qlogic.com>

On Wed, 2011-05-11 at 15:54 -0700, Anirban Chakraborty wrote:
> Driver checks if the previous dump has been cleared before taking the dump.
> It doesn't take the dump if it is not cleared.
> 
> Changes from v2:
> Added lock to protect dump data structures from being mangled while
> dumping or setting them via ethtool.

Unfortunately it still seems to be possible for the dump length to
change between the ethtool core calling qlcnic_get_dump_flag() and
qlcnic_get_dump_data().

So I think qlcnic_get_dump_data() will need to double-check the length
after taking the internal lock:

[...]
> +static int
> +qlcnic_get_dump_data(struct net_device *netdev, struct ethtool_dump *dump,
> +                       void *buffer)
> +{
> +       int i, copy_sz;
> +       u32 *hdr_ptr, *data;
> +       struct qlcnic_adapter *adapter = netdev_priv(netdev);
> +       struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
> +
> +       if (qlcnic_api_lock(adapter))
> +               return -EIO;
[...]

	if (dump->len < fw_dump->tmpl_hdr->size + fw_dump->size) {
		qlcnic_api_unlock(adapter);
		return -EINVAL;
	}

I'm not sure about the error code... and I'm really not happy about the
need to check lengths in both the ethtool core and the driver.

Can't you change the function that actually makes a dump to acquire the
RTNL lock?  (You'll need to do that *before* acquiring the driver's own
lock.)

Ben.

-- 
Ben Hutchings, Senior Software 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:[~2011-05-12 17:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-11 22:54 [PATCHv3] ethtool: Added FW dump support Anirban Chakraborty
2011-05-11 22:54 ` [PATCHv3 net-next-2.6] ethtool: Added support for FW dump Anirban Chakraborty
2011-05-12 17:04   ` Ben Hutchings
2011-05-12 18:53     ` Anirban Chakraborty
2011-05-11 22:54 ` [PATCHv3 net-next-2.6 1/3] qlcnic: FW dump support Anirban Chakraborty
2011-05-11 22:54 ` [PATCHv3 net-next-2.6 2/3] qlcnic: Take FW dump via ethtool Anirban Chakraborty
2011-05-12 17:27   ` Ben Hutchings [this message]
2011-05-12 18:53     ` Anirban Chakraborty
2011-05-12 19:18       ` Ben Hutchings
2011-05-12 20:54         ` Anirban Chakraborty
2011-05-12 21:02           ` Ben Hutchings
2011-05-11 22:54 ` [PATCHv3 net-next-2.6 3/3] qlcnic: Bumped up version number to 5.0.18 Anirban Chakraborty
  -- strict thread matches above, loose matches on Subject: below --
2011-05-12 22:48 [PATCHv4] ethtool: Added FW dump support Anirban Chakraborty
2011-05-12 22:48 ` [PATCHv3 net-next-2.6 2/3] qlcnic: Take FW dump via ethtool Anirban Chakraborty
2011-05-13 18:44   ` David Miller

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=1305221242.5214.36.camel@bwh-desktop \
    --to=bhutchings@solarflare.com \
    --cc=anirban.chakraborty@qlogic.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /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).