511f256
Bugzilla: 1094270
511f256
Upstream-status: 3.15 and queued for stable
511f256
511f256
From a7e6a36c02e8a4c6547bfc2b789bfbfcc95072f9 Mon Sep 17 00:00:00 2001
511f256
From: "Eric W. Biederman" <ebiederm@xmission.com>
511f256
Date: Wed, 23 Apr 2014 14:25:48 -0700
511f256
Subject: [PATCH 2/6] netlink: Rename netlink_capable netlink_allowed
511f256
511f256
netlink_capable is a static internal function in af_netlink.c and we
511f256
have better uses for the name netlink_capable.
511f256
511f256
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
511f256
---
511f256
 net/netlink/af_netlink.c | 10 +++++-----
511f256
 1 file changed, 5 insertions(+), 5 deletions(-)
511f256
511f256
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
511f256
index 04748ab649c2..28d66fbc7cef 100644
511f256
--- a/net/netlink/af_netlink.c
511f256
+++ b/net/netlink/af_netlink.c
511f256
@@ -1360,7 +1360,7 @@ retry:
511f256
 	return err;
511f256
 }
511f256
 
511f256
-static inline int netlink_capable(const struct socket *sock, unsigned int flag)
511f256
+static inline int netlink_allowed(const struct socket *sock, unsigned int flag)
511f256
 {
511f256
 	return (nl_table[sock->sk->sk_protocol].flags & flag) ||
511f256
 		ns_capable(sock_net(sock->sk)->user_ns, CAP_NET_ADMIN);
511f256
@@ -1428,7 +1428,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
511f256
 
511f256
 	/* Only superuser is allowed to listen multicasts */
511f256
 	if (nladdr->nl_groups) {
511f256
-		if (!netlink_capable(sock, NL_CFG_F_NONROOT_RECV))
511f256
+		if (!netlink_allowed(sock, NL_CFG_F_NONROOT_RECV))
511f256
 			return -EPERM;
511f256
 		err = netlink_realloc_groups(sk);
511f256
 		if (err)
511f256
@@ -1490,7 +1490,7 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr,
511f256
 		return -EINVAL;
511f256
 
511f256
 	if ((nladdr->nl_groups || nladdr->nl_pid) &&
511f256
-	    !netlink_capable(sock, NL_CFG_F_NONROOT_SEND))
511f256
+	    !netlink_allowed(sock, NL_CFG_F_NONROOT_SEND))
511f256
 		return -EPERM;
511f256
 
511f256
 	if (!nlk->portid)
511f256
@@ -2096,7 +2096,7 @@ static int netlink_setsockopt(struct socket *sock, int level, int optname,
511f256
 		break;
511f256
 	case NETLINK_ADD_MEMBERSHIP:
511f256
 	case NETLINK_DROP_MEMBERSHIP: {
511f256
-		if (!netlink_capable(sock, NL_CFG_F_NONROOT_RECV))
511f256
+		if (!netlink_allowed(sock, NL_CFG_F_NONROOT_RECV))
511f256
 			return -EPERM;
511f256
 		err = netlink_realloc_groups(sk);
511f256
 		if (err)
511f256
@@ -2247,7 +2247,7 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock,
511f256
 		dst_group = ffs(addr->nl_groups);
511f256
 		err =  -EPERM;
511f256
 		if ((dst_group || dst_portid) &&
511f256
-		    !netlink_capable(sock, NL_CFG_F_NONROOT_SEND))
511f256
+		    !netlink_allowed(sock, NL_CFG_F_NONROOT_SEND))
511f256
 			goto out;
511f256
 	} else {
511f256
 		dst_portid = nlk->dst_portid;
511f256
-- 
511f256
1.9.0
511f256