From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH v2 net-next 17/23] net/namespace: Update rtnl_net_dumpid for strict data checking Date: Mon, 8 Oct 2018 07:28:33 -0600 Message-ID: References: <20181008031644.15989-1-dsahern@kernel.org> <20181008031644.15989-18-dsahern@kernel.org> <20181008105430.cnpflmfwhkn3u2lq@brauner.io> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, davem@davemloft.net, jbenc@redhat.com, stephen@networkplumber.org To: Christian Brauner , David Ahern Return-path: Received: from mail-io1-f66.google.com ([209.85.166.66]:44355 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726065AbeJHUkT (ORCPT ); Mon, 8 Oct 2018 16:40:19 -0400 Received: by mail-io1-f66.google.com with SMTP id x26-v6so15821308iog.11 for ; Mon, 08 Oct 2018 06:28:35 -0700 (PDT) In-Reply-To: <20181008105430.cnpflmfwhkn3u2lq@brauner.io> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 10/8/18 4:54 AM, Christian Brauner wrote: > On Sun, Oct 07, 2018 at 08:16:38PM -0700, David Ahern wrote: >> From: David Ahern >> >> Update rtnl_net_dumpid for strict data checking. If the flag is set, >> the dump request is expected to have an rtgenmsg struct as the header >> which has the family as the only element. No data may be appended. >> >> Signed-off-by: David Ahern >> --- >> net/core/net_namespace.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c >> index 670c84b1bfc2..fefe72774aeb 100644 >> --- a/net/core/net_namespace.c >> +++ b/net/core/net_namespace.c >> @@ -853,6 +853,12 @@ static int rtnl_net_dumpid(struct sk_buff *skb, struct netlink_callback *cb) >> .s_idx = cb->args[0], >> }; >> >> + if (cb->strict_check && > > Hm, shouldn't this also verify that the passed header is indeed struct > rtgenmsg before checking whether there are any attributes? rtgenmsg is only a struct with only the family as an element. rtnetlink_rcv_msg has already verified that the nl msg header contains at least the rtgenmsg struct. > >> + nlmsg_attrlen(cb->nlh, sizeof(struct rtgenmsg))) { >> + NL_SET_ERR_MSG(cb->extack, "Unknown data in network namespace id dump request"); >> + return -EINVAL; >> + } >> + >> spin_lock_bh(&net->nsid_lock); >> idr_for_each(&net->netns_ids, rtnl_net_dumpid_one, &net_cb); >> spin_unlock_bh(&net->nsid_lock); >> -- >> 2.11.0 >>