From: David Ahern Subject: Re: [RFC net 1/1] rtnetlink: require unique netns identifier Date: Fri, 2 Feb 2018 16:27:13 -0700 Message-ID: References: <20180202085115.17229-1-christian.brauner@ubuntu.com> <20180202085115.17229-2-christian.brauner@ubuntu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: ebiederm@xmission.com, jbenc@redhat.com, nicolas.dichtel@6wind.com, linux-kernel@vger.kernel.org To: Christian Brauner , netdev@vger.kernel.org Return-path: Received: from mail-pf0-f195.google.com ([209.85.192.195]:34961 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751702AbeBBX1Q (ORCPT ); Fri, 2 Feb 2018 18:27:16 -0500 In-Reply-To: <20180202085115.17229-2-christian.brauner@ubuntu.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 2/2/18 1:51 AM, Christian Brauner wrote: > diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c > index 56af8e41abfc..d0b7ab22eff4 100644 > --- a/net/core/rtnetlink.c > +++ b/net/core/rtnetlink.c > @@ -1951,6 +1951,18 @@ static struct net *rtnl_link_get_net_capable(const struct sk_buff *skb, > return net; > } > > +/* Verify that rtnetlink requests that support network namespace ids do not pass > + * additional properties that allow to identify a network namespace as they > + * might conflict. > + */ > +static int rtnl_ensure_unique_netns_attr(struct nlattr *tb[]) > +{ > + if (tb[IFLA_IF_NETNSID] && (tb[IFLA_NET_NS_PID] || tb[IFLA_NET_NS_FD])) > + return -EINVAL; The days of just returning EINVAL are over; please plumb extack arg to this message and add a string describing the problem. There are plenty of examples in rtnetlink.c Also, what if those NSID's all point to the same namespace? That should not fail right?