From patchwork Fri May 28 07:15:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Feldman X-Patchwork-Id: 53864 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 07F9BB7D27 for ; Fri, 28 May 2010 17:15:58 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753911Ab0E1HPw (ORCPT ); Fri, 28 May 2010 03:15:52 -0400 Received: from sj-iport-6.cisco.com ([171.71.176.117]:41639 "EHLO sj-iport-6.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753321Ab0E1HPw (ORCPT ); Fri, 28 May 2010 03:15:52 -0400 Authentication-Results: sj-iport-6.cisco.com; dkim=neutral (message not signed) header.i=none X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjIFAAcL/0urR7H+/2dsb2JhbACDGI8DjBBxpCeJDZEQgSWDBWoEg0I X-IronPort-AV: E=Sophos;i="4.53,317,1272844800"; d="scan'208";a="536512637" Received: from sj-core-2.cisco.com ([171.71.177.254]) by sj-iport-6.cisco.com with ESMTP; 28 May 2010 07:15:51 +0000 Received: from localhost.localdomain (savbu-dvr-c1b2.cisco.com [10.193.164.127]) by sj-core-2.cisco.com (8.13.8/8.14.3) with ESMTP id o4S7FpFe008607; Fri, 28 May 2010 07:15:51 GMT Subject: [net-2.6 PATCH 2/2] netlink: bug fix: wrong size was calculated for vfinfo list blob To: davem@davemloft.net From: Scott Feldman Cc: chrisw@redhat.com, netdev@vger.kernel.org, kaber@trash.net, arnd@arndb.de Date: Fri, 28 May 2010 00:15:51 -0700 Message-ID: <20100528071551.4058.24521.stgit@localhost.localdomain> In-Reply-To: <20100528071546.4058.1332.stgit@localhost.localdomain> References: <20100528071546.4058.1332.stgit@localhost.localdomain> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Scott Feldman 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 --- net/core/rtnetlink.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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;