summaryrefslogtreecommitdiffstats
path: root/include/net/sock.h
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-05-25 01:56:43 +0200
committerEric W. Biederman <ebiederm@xmission.com>2012-08-15 06:49:56 +0200
commitc336d148adc4181f31741ae066df41429be64b67 (patch)
treeb1393fa0bd2782c4f41f14c6d1d4390b480057cf /include/net/sock.h
parentnetlink: Make the sending netlink socket availabe in NETLINK_CB (diff)
downloadlinux-c336d148adc4181f31741ae066df41429be64b67.tar.xz
linux-c336d148adc4181f31741ae066df41429be64b67.zip
userns: Implement sk_user_ns
Add a helper sk_user_ns to make it easy to find the user namespace of the process that opened a socket. Acked-by: David S. Miller <davem@davemloft.net> Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'include/net/sock.h')
-rw-r--r--include/net/sock.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 65c3d62bfa5a..9d43736a869d 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -604,6 +604,15 @@ static inline void sk_add_bind_node(struct sock *sk,
#define sk_for_each_bound(__sk, node, list) \
hlist_for_each_entry(__sk, node, list, sk_bind_node)
+static inline struct user_namespace *sk_user_ns(struct sock *sk)
+{
+ /* Careful only use this in a context where these parameters
+ * can not change and must all be valid, such as recvmsg from
+ * userspace.
+ */
+ return sk->sk_socket->file->f_cred->user_ns;
+}
+
/* Sock flags */
enum sock_flags {
SOCK_DEAD,