[PATCH 3.16.y-ckt 158/168] rtnetlink: release net refcnt on error in do_setlink()
Luis Henriques
luis.henriques at canonical.com
Mon Dec 15 14:26:52 UTC 2014
3.16.7-ckt3 -stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Dichtel <nicolas.dichtel at 6wind.com>
commit e0ebde0e131b529fd721b24f62872def5ec3718c upstream.
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 at xmission.com>
Fixes: b51642f6d77b ("net: Enable a userns root rtnl calls that are safe for unprivilged users")
Signed-off-by: Nicolas Dichtel <nicolas.dichtel at 6wind.com>
Reviewed-by: "Eric W. Biederman" <ebiederm at xmission.com>
Signed-off-by: David S. Miller <davem at davemloft.net>
Signed-off-by: Luis Henriques <luis.henriques at canonical.com>
---
net/core/rtnetlink.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index e0b5ca349049..48c2be43f856 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1490,6 +1490,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;
}
--
2.1.3
More information about the kernel-team
mailing list