From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Kirsher Subject: [PATCH 2/3] netlink: nal_parse_nested_compat was not parsing nested attributes Date: Thu, 21 Aug 2008 17:51:26 -0700 Message-ID: <20080822005126.4697.16602.stgit@jtkirshe-mobile.jf.intel.com> References: <20080822005122.4697.26953.stgit@jtkirshe-mobile.jf.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Cc: jeff@garzik.org, netdev@vger.kernel.org, Alexander Duyck , Jeff Kirsher To: davem@davemloft.net Return-path: Received: from rv-out-0506.google.com ([209.85.198.228]:45062 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754801AbYHVAv1 (ORCPT ); Thu, 21 Aug 2008 20:51:27 -0400 Received: by rv-out-0506.google.com with SMTP id k40so202523rvb.1 for ; Thu, 21 Aug 2008 17:51:27 -0700 (PDT) In-Reply-To: <20080822005122.4697.26953.stgit@jtkirshe-mobile.jf.intel.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Alexander Duyck This patch reverts previous commit: b9a2f2e450b0f770bb4347ae8d48eb2dea701e24 netlink: Fix nla_parse_nested_compat() to call nla_parse() directly The purpose of nla_parse_nested_compat is to parse attributes which contain a struct followed by a container attribute with a stream of nested attributes. This patch reverts the previous patch which assumed that there was no container attribute due to a malformed string of attributes being generated by netem_parse_opts Signed-off-by: Alexander Duyck Signed-off-by: Jeff Kirsher --- include/net/netlink.h | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/net/netlink.h b/include/net/netlink.h index 18024b8..b295cd1 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h @@ -770,13 +770,12 @@ static inline int __nla_parse_nested_compat(struct nlattr *tb[], int maxtype, const struct nla_policy *policy, int len) { - int nested_len = nla_len(nla) - NLA_ALIGN(len); - - if (nested_len < 0) + if (nla_len(nla) < len) return -EINVAL; - if (nested_len >= nla_attr_size(0)) - return nla_parse(tb, maxtype, nla_data(nla) + NLA_ALIGN(len), - nested_len, policy); + if (nla_len(nla) >= NLA_ALIGN(len) + sizeof(struct nlattr)) + return nla_parse_nested(tb, maxtype, + nla_data(nla) + NLA_ALIGN(len), + policy); memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1)); return 0; }