summaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorTyler Hicks <tyhicks@canonical.com>2018-07-20 21:56:53 +0000
committerDavid S. Miller <davem@davemloft.net>2018-07-20 23:44:36 -0700
commitfbdeaed408cf2728c62640c10848ddb1b67e63d3 (patch)
tree4c06f4a43d4516e7f1f83db877f4f4c49b01077f /include/net
parentb0e37c0d8a6abed0cd1b611314a7ebf50b0a8ed4 (diff)
downloadblackbird-obmc-linux-fbdeaed408cf2728c62640c10848ddb1b67e63d3.tar.gz
blackbird-obmc-linux-fbdeaed408cf2728c62640c10848ddb1b67e63d3.zip
net: create reusable function for getting ownership info of sysfs inodes
Make net_ns_get_ownership() reusable by networking code outside of core. This is useful, for example, to allow bridge related sysfs files to be owned by container root. Add a function comment since this is a potentially dangerous function to use given the way that kobject_get_ownership() works by initializing uid and gid before calling .get_ownership(). Signed-off-by: Tyler Hicks <tyhicks@canonical.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/net_namespace.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index a71264d75d7f..9b5fdc50519a 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -10,6 +10,7 @@
#include <linux/workqueue.h>
#include <linux/list.h>
#include <linux/sysctl.h>
+#include <linux/uidgid.h>
#include <net/flow.h>
#include <net/netns/core.h>
@@ -170,6 +171,8 @@ extern struct net init_net;
struct net *copy_net_ns(unsigned long flags, struct user_namespace *user_ns,
struct net *old_net);
+void net_ns_get_ownership(const struct net *net, kuid_t *uid, kgid_t *gid);
+
void net_ns_barrier(void);
#else /* CONFIG_NET_NS */
#include <linux/sched.h>
@@ -182,6 +185,13 @@ static inline struct net *copy_net_ns(unsigned long flags,
return old_net;
}
+static inline void net_ns_get_ownership(const struct net *net,
+ kuid_t *uid, kgid_t *gid)
+{
+ *uid = GLOBAL_ROOT_UID;
+ *gid = GLOBAL_ROOT_GID;
+}
+
static inline void net_ns_barrier(void) {}
#endif /* CONFIG_NET_NS */
OpenPOWER on IntegriCloud