diff options
author | Tom Gundersen <teg@jklm.no> | 2018-05-04 10:28:22 -0400 |
---|---|---|
committer | James Morris <james.morris@microsoft.com> | 2018-05-04 15:48:54 -0400 |
commit | 5859cdf55063943192f316b3d6c673fd6fcbee46 (patch) | |
tree | 0e54055d2dedb3c8f958de14be63fc3f7b47a263 | |
parent | 0b811db2cb2aabc910e53d34ebb95a15997c33e7 (diff) |
smack: provide socketpair callback
Make sure to implement the new socketpair callback so the SO_PEERSEC
call on socketpair(2)s will return correct information.
Signed-off-by: Tom Gundersen <teg@jklm.no>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: James Morris <james.morris@microsoft.com>
-rw-r--r-- | security/smack/smack_lsm.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 0b414836bebd..dcb976f98df2 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c | |||
@@ -2842,6 +2842,27 @@ static int smack_socket_post_create(struct socket *sock, int family, | |||
2842 | return smack_netlabel(sock->sk, SMACK_CIPSO_SOCKET); | 2842 | return smack_netlabel(sock->sk, SMACK_CIPSO_SOCKET); |
2843 | } | 2843 | } |
2844 | 2844 | ||
2845 | /** | ||
2846 | * smack_socket_socketpair - create socket pair | ||
2847 | * @socka: one socket | ||
2848 | * @sockb: another socket | ||
2849 | * | ||
2850 | * Cross reference the peer labels for SO_PEERSEC | ||
2851 | * | ||
2852 | * Returns 0 on success, and error code otherwise | ||
2853 | */ | ||
2854 | static int smack_socket_socketpair(struct socket *socka, | ||
2855 | struct socket *sockb) | ||
2856 | { | ||
2857 | struct socket_smack *asp = socka->sk->sk_security; | ||
2858 | struct socket_smack *bsp = sockb->sk->sk_security; | ||
2859 | |||
2860 | asp->smk_packet = bsp->smk_out; | ||
2861 | bsp->smk_packet = asp->smk_out; | ||
2862 | |||
2863 | return 0; | ||
2864 | } | ||
2865 | |||
2845 | #ifdef SMACK_IPV6_PORT_LABELING | 2866 | #ifdef SMACK_IPV6_PORT_LABELING |
2846 | /** | 2867 | /** |
2847 | * smack_socket_bind - record port binding information. | 2868 | * smack_socket_bind - record port binding information. |
@@ -4724,6 +4745,7 @@ static struct security_hook_list smack_hooks[] __lsm_ro_after_init = { | |||
4724 | LSM_HOOK_INIT(unix_may_send, smack_unix_may_send), | 4745 | LSM_HOOK_INIT(unix_may_send, smack_unix_may_send), |
4725 | 4746 | ||
4726 | LSM_HOOK_INIT(socket_post_create, smack_socket_post_create), | 4747 | LSM_HOOK_INIT(socket_post_create, smack_socket_post_create), |
4748 | LSM_HOOK_INIT(socket_socketpair, smack_socket_socketpair), | ||
4727 | #ifdef SMACK_IPV6_PORT_LABELING | 4749 | #ifdef SMACK_IPV6_PORT_LABELING |
4728 | LSM_HOOK_INIT(socket_bind, smack_socket_bind), | 4750 | LSM_HOOK_INIT(socket_bind, smack_socket_bind), |
4729 | #endif | 4751 | #endif |