netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Scott Feldman <scofeldm@cisco.com>
To: davem@davemloft.net
Cc: chrisw@redhat.com, netdev@vger.kernel.org, kaber@trash.net,
	arnd@arndb.de
Subject: [net-2.6 PATCH 2/2] netlink: bug fix: wrong size was calculated for vfinfo list blob
Date: Fri, 28 May 2010 00:15:51 -0700	[thread overview]
Message-ID: <20100528071551.4058.24521.stgit@localhost.localdomain> (raw)
In-Reply-To: <20100528071546.4058.1332.stgit@localhost.localdomain>

From: Scott Feldman <scofeldm@cisco.com>

The wrong size was being calculated for vfinfo.  In one case, it was over-
calculating using nlmsg_total_size on attrs, in another case, it was
under-calculating by assuming ifla_vf_* structs are packed together, but
each struct is it's own attr w/ hdr (and padding).

Signed-off-by: Scott Feldman <scofeldm@cisco.com>
---
 net/core/rtnetlink.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)


diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 7331bb2..1a2af24 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -650,11 +650,12 @@ static inline int rtnl_vfinfo_size(const struct net_device *dev)
 	if (dev->dev.parent && dev_is_pci(dev->dev.parent)) {
 
 		int num_vfs = dev_num_vf(dev->dev.parent);
-		size_t size = nlmsg_total_size(sizeof(struct nlattr));
-		size += nlmsg_total_size(num_vfs * sizeof(struct nlattr));
-		size += num_vfs * (sizeof(struct ifla_vf_mac) +
-				  sizeof(struct ifla_vf_vlan) +
-				  sizeof(struct ifla_vf_tx_rate));
+		size_t size = nla_total_size(sizeof(struct nlattr));
+		size += nla_total_size(num_vfs * sizeof(struct nlattr));
+		size += num_vfs *
+			(nla_total_size(sizeof(struct ifla_vf_mac)) +
+			 nla_total_size(sizeof(struct ifla_vf_vlan)) +
+			 nla_total_size(sizeof(struct ifla_vf_tx_rate)));
 		return size;
 	} else
 		return 0;


  reply	other threads:[~2010-05-28  7:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-28  7:15 [net-2.6 PATCH 1/2] netlink: bug fix: don't overrun skbs on vf_port dump Scott Feldman
2010-05-28  7:15 ` Scott Feldman [this message]
2010-05-28 10:42   ` [net-2.6 PATCH 2/2] netlink: bug fix: wrong size was calculated for vfinfo list blob David Miller
2010-05-28 10:42 ` [net-2.6 PATCH 1/2] netlink: bug fix: don't overrun skbs on vf_port dump 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=20100528071551.4058.24521.stgit@localhost.localdomain \
    --to=scofeldm@cisco.com \
    --cc=arnd@arndb.de \
    --cc=chrisw@redhat.com \
    --cc=davem@davemloft.net \
    --cc=kaber@trash.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).