]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
rtnetlink: Fail dump if target netnsid is invalid
authorDavid Ahern <dsahern@gmail.com>
Fri, 28 Sep 2018 19:28:41 +0000 (12:28 -0700)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:54:08 +0000 (19:54 -0600)
BugLink: https://bugs.launchpad.net/bugs/1836426
[ Upstream commit 893626d6a353d1356528f94e081246ecf233d77a ]

Link dumps can return results from a target namespace. If the namespace id
is invalid, then the dump request should fail if get_target_net fails
rather than continuing with a dump of the current namespace.

Fixes: 79e1ad148c844 ("rtnetlink: use netnsid to query interface")
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
net/core/rtnetlink.c

index e51ee079c395b2be4800f75b5b1d03421abc886d..c786a385b12b04c1dcd739f64e54b1cde42284ce 100644 (file)
@@ -1749,10 +1749,8 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
                if (tb[IFLA_IF_NETNSID]) {
                        netnsid = nla_get_s32(tb[IFLA_IF_NETNSID]);
                        tgt_net = get_target_net(skb->sk, netnsid);
-                       if (IS_ERR(tgt_net)) {
-                               tgt_net = net;
-                               netnsid = -1;
-                       }
+                       if (IS_ERR(tgt_net))
+                               return PTR_ERR(tgt_net);
                }
 
                if (tb[IFLA_EXT_MASK])