rtnetlink: release net refcnt on error in do_setlink()
authorNicolas Dichtel <nicolas.dichtel@6wind.com>
Thu, 27 Nov 2014 09:16:15 +0000 (10:16 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 30 Nov 2014 05:05:43 +0000 (21:05 -0800)
rtnl_link_get_net() holds a reference on the 'struct net', we need to release
it in case of error.

CC: Eric W. Biederman <ebiederm@xmission.com>
Fixes: b51642f6d77b ("net: Enable a userns root rtnl calls that are safe for unprivilged users")
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Reviewed-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/rtnetlink.c

index b9b7dfaf202b9be668bf29153593aa2c7dba86ee..76321ea442c3e06c289e86184c5c4e513cbad7ff 100644 (file)
@@ -1498,6 +1498,7 @@ static int do_setlink(const struct sk_buff *skb,
                        goto errout;
                }
                if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) {
+                       put_net(net);
                        err = -EPERM;
                        goto errout;
                }