aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChia-chi Yeh <chiachi@android.com>2009-06-30 11:23:04 +0800
committerColin Cross <ccross@android.com>2011-06-14 09:09:14 -0700
commitebd4673cf669673567d8e5990fc45bfc12fe69ac (patch)
tree835e9aa9cfeb61acfc45bb2f47e1bf200b3573d3
parent622495a5adf75911922749bb10ba7b1b8c6b8639 (diff)
downloadkernel_samsung_tuna-ebd4673cf669673567d8e5990fc45bfc12fe69ac.zip
kernel_samsung_tuna-ebd4673cf669673567d8e5990fc45bfc12fe69ac.tar.gz
kernel_samsung_tuna-ebd4673cf669673567d8e5990fc45bfc12fe69ac.tar.bz2
net: Replace AID_NET_RAW checks with capable(CAP_NET_RAW).
Signed-off-by: Chia-chi Yeh <chiachi@android.com>
-rw-r--r--net/ipv4/af_inet.c34
-rw-r--r--net/ipv6/af_inet6.c35
2 files changed, 22 insertions, 47 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 49f024f..3af16ba 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -120,6 +120,16 @@
#ifdef CONFIG_ANDROID_PARANOID_NETWORK
#include <linux/android_aid.h>
+
+static inline int current_has_network(void)
+{
+ return in_egroup_p(AID_INET) || capable(CAP_NET_RAW);
+}
+#else
+static inline int current_has_network(void)
+{
+ return 1;
+}
#endif
/* The inetsw table contains everything that inet_create needs to
@@ -261,28 +271,6 @@ static inline int inet_netns_ok(struct net *net, int protocol)
return ipprot->netns_ok;
}
-#ifdef CONFIG_ANDROID_PARANOID_NETWORK
-static inline int current_has_network(void)
-{
- return (!current_euid() || in_egroup_p(AID_INET) ||
- in_egroup_p(AID_NET_RAW));
-}
-static inline int current_has_cap(int cap)
-{
- if (cap == CAP_NET_RAW && in_egroup_p(AID_NET_RAW))
- return 1;
- return capable(cap);
-}
-# else
-static inline int current_has_network(void)
-{
- return 1;
-}
-static inline int current_has_cap(int cap)
-{
- return capable(cap);
-}
-#endif
/*
* Create an inet socket.
@@ -355,7 +343,7 @@ lookup_protocol:
}
err = -EPERM;
- if (sock->type == SOCK_RAW && !kern && !current_has_cap(CAP_NET_RAW))
+ if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
goto out_rcu_unlock;
err = -EAFNOSUPPORT;
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 4384e2b..cd43666 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -65,6 +65,16 @@
#ifdef CONFIG_ANDROID_PARANOID_NETWORK
#include <linux/android_aid.h>
+
+static inline int current_has_network(void)
+{
+ return in_egroup_p(AID_INET) || capable(CAP_NET_RAW);
+}
+#else
+static inline int current_has_network(void)
+{
+ return 1;
+}
#endif
MODULE_AUTHOR("Cast of dozens");
@@ -100,29 +110,6 @@ static __inline__ struct ipv6_pinfo *inet6_sk_generic(struct sock *sk)
return (struct ipv6_pinfo *)(((u8 *)sk) + offset);
}
-#ifdef CONFIG_ANDROID_PARANOID_NETWORK
-static inline int current_has_network(void)
-{
- return (!current_euid() || in_egroup_p(AID_INET) ||
- in_egroup_p(AID_NET_RAW));
-}
-static inline int current_has_cap(int cap)
-{
- if (cap == CAP_NET_RAW && in_egroup_p(AID_NET_RAW))
- return 1;
- return capable(cap);
-}
-# else
-static inline int current_has_network(void)
-{
- return 1;
-}
-static inline int current_has_cap(int cap)
-{
- return capable(cap);
-}
-#endif
-
static int inet6_create(struct net *net, struct socket *sock, int protocol,
int kern)
{
@@ -190,7 +177,7 @@ lookup_protocol:
}
err = -EPERM;
- if (sock->type == SOCK_RAW && !kern && !current_has_cap(CAP_NET_RAW))
+ if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
goto out_rcu_unlock;
sock->ops = answer->ops;