diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-05-24 19:56:43 -0400 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-08-15 00:49:56 -0400 |
commit | c336d148adc4181f31741ae066df41429be64b67 (patch) | |
tree | b1393fa0bd2782c4f41f14c6d1d4390b480057cf /include/net/sock.h | |
parent | 3fbc290540a1ed1a8a076ed8f53bee7a38a9f408 (diff) |
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.h | 9 |
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, | |||
604 | #define sk_for_each_bound(__sk, node, list) \ | 604 | #define sk_for_each_bound(__sk, node, list) \ |
605 | hlist_for_each_entry(__sk, node, list, sk_bind_node) | 605 | hlist_for_each_entry(__sk, node, list, sk_bind_node) |
606 | 606 | ||
607 | static inline struct user_namespace *sk_user_ns(struct sock *sk) | ||
608 | { | ||
609 | /* Careful only use this in a context where these parameters | ||
610 | * can not change and must all be valid, such as recvmsg from | ||
611 | * userspace. | ||
612 | */ | ||
613 | return sk->sk_socket->file->f_cred->user_ns; | ||
614 | } | ||
615 | |||
607 | /* Sock flags */ | 616 | /* Sock flags */ |
608 | enum sock_flags { | 617 | enum sock_flags { |
609 | SOCK_DEAD, | 618 | SOCK_DEAD, |