net: Replace AID_NET_RAW checks with capable(CAP_NET_RAW).
Signed-off-by: Chia-chi Yeh <chiachi@android.com>
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 73a3845..0b71165 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -121,6 +121,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
@@ -262,28 +272,6 @@
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.
@@ -356,7 +344,7 @@
}
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;