Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1949808ima; Thu, 25 Oct 2018 07:27:29 -0700 (PDT) X-Google-Smtp-Source: AJdET5c/UK8kxw1cCzawdHMpNE95U1FiX733UqYu3Y+lRpoH6H/Duj+qUfl69QTQo83u0wEx23X5 X-Received: by 2002:a17:902:9a94:: with SMTP id w20-v6mr1721593plp.115.1540477649109; Thu, 25 Oct 2018 07:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540477649; cv=none; d=google.com; s=arc-20160816; b=a7rH5MYP7efKMwoeKlO6X573VObNrN4OynL3NlWrG3mybmy92BEiByapaa2BOcxbJK jL1KpQ8b8fj4NcrYvAwvq07Mhx6csgGLAmoOm4HEVelAeaP34X486e7aItDOZWbStXzJ TgXE3Y7NwMdYRQE3wbBioS06+SUf+7Icijp7ce47XsNMwoJv8EvdyprGJzh0c4LiFiyK y8xJphfdN7IjdUlwReRt82ziyPDpixH7+rqkBi/Q2LqiMrvKTGzVbUVoo+vuI2isPVOc 5av0ivRBehOmeQtvIf303NBoXFPrGq91mLoNsvPNbmihmyH37ohxw6HKetdXvQsC0XHW /DBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=x7/ypWqXoyZtTNuW80CSWL3b24dmziOJSjDq3Zm6NK0=; b=eglQ9dJ1Gd5CF10i0iOm4jQgmpNf6DD//o1T6kmOobnHyoAIoTVhouWs8Jy618r2RE WO7FWNOp77CixKcu46PB8eqXWOBqv4fmW7UGzcDu5wnLHbjEzq4WJ1gKftip3tBHu5zF av3fR8O/V1ao0e/g8rUXBP/lvQbJhgzQl8qWt9JFCUs/vowLJ6dY2ieUMPH+FLNlBEYV dMMmE5WiWkkLH0945DrSEO2QKYxguu1XeT3gesq2vjAjr1HzizoKBU5JJRZjtEIqY52l n1UdtSKmh7hz7C2YTbeHF2Va6Hy0Z8lKyzjudcM3wlOKfffo49fCHLBcdZomBB4q+fPS UYPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FnqZB+eW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k33-v6si7954331pld.151.2018.10.25.07.26.39; Thu, 25 Oct 2018 07:27:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FnqZB+eW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730935AbeJYWxN (ORCPT + 99 others); Thu, 25 Oct 2018 18:53:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:35620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730875AbeJYWxM (ORCPT ); Thu, 25 Oct 2018 18:53:12 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CF64220870; Thu, 25 Oct 2018 14:20:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540477214; bh=2HoZ0JijPGowB7r0pEZ4DzNssaTZNBYMFVwf00fhVoY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FnqZB+eWpT0RBcTfnzFleT7kEVinoEz36TS6wccveKCWK1XsKsYjorHft/AZItW8b vv5c4O30AzeIH9qMZpKs5VO8VXKRKth4f3IDR6tQondoKKMY5CiS706OP3RzsuFt1w mWCsGC/4t6wG1GzaMXZILGya4oGy+kiuYC2vIZ/c= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Daniel Borkmann , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 3.18 53/98] rtnl: don't account unused struct ifla_port_vsi in rtnl_port_size Date: Thu, 25 Oct 2018 10:18:08 -0400 Message-Id: <20181025141853.214051-53-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141853.214051-1-sashal@kernel.org> References: <20181025141853.214051-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Borkmann [ Upstream commit 025331df34f6722f86b467cb13a69326444ab1bc ] When allocating rtnl dump messages, struct ifla_port_vsi is never dumped, so we can save header plus payload in rtnl_port_size(). Infact, attribute IFLA_PORT_VSI_TYPE and struct ifla_port_vsi are not used anywhere in the kernel. We only need to keep the nla policy should applications in user space be filling this out. Same NLA_BINARY issue exists as was fixed in 364d5716a7ad ("rtnetlink: ifla_vf_policy: fix misuses of NLA_BINARY") and others, but then again IFLA_PORT_VSI_TYPE is not used anywhere, so just add a comment that it's unused. Signed-off-by: Daniel Borkmann Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/core/rtnetlink.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 51301ad3c2d9..cd09f85ba8d6 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -817,8 +817,6 @@ static size_t rtnl_port_size(const struct net_device *dev, { size_t port_size = nla_total_size(4) /* PORT_VF */ + nla_total_size(PORT_PROFILE_MAX) /* PORT_PROFILE */ - + nla_total_size(sizeof(struct ifla_port_vsi)) - /* PORT_VSI_TYPE */ + nla_total_size(PORT_UUID_MAX) /* PORT_INSTANCE_UUID */ + nla_total_size(PORT_UUID_MAX) /* PORT_HOST_UUID */ + nla_total_size(1) /* PROT_VDP_REQUEST */ @@ -1231,14 +1229,19 @@ static const struct nla_policy ifla_port_policy[IFLA_PORT_MAX+1] = { [IFLA_PORT_VF] = { .type = NLA_U32 }, [IFLA_PORT_PROFILE] = { .type = NLA_STRING, .len = PORT_PROFILE_MAX }, - [IFLA_PORT_VSI_TYPE] = { .type = NLA_BINARY, - .len = sizeof(struct ifla_port_vsi)}, [IFLA_PORT_INSTANCE_UUID] = { .type = NLA_BINARY, .len = PORT_UUID_MAX }, [IFLA_PORT_HOST_UUID] = { .type = NLA_STRING, .len = PORT_UUID_MAX }, [IFLA_PORT_REQUEST] = { .type = NLA_U8, }, [IFLA_PORT_RESPONSE] = { .type = NLA_U16, }, + + /* Unused, but we need to keep it here since user space could + * fill it. It's also broken with regard to NLA_BINARY use in + * combination with structs. + */ + [IFLA_PORT_VSI_TYPE] = { .type = NLA_BINARY, + .len = sizeof(struct ifla_port_vsi) }, }; static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) -- 2.17.1