diff options
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r-- | security/selinux/hooks.c | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 975c0dfb5a11..a29d78d3f44c 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -3574,27 +3574,16 @@ static int selinux_socket_getpeersec_stream(struct socket *sock, char __user *op | |||
3574 | u32 scontext_len; | 3574 | u32 scontext_len; |
3575 | struct sk_security_struct *ssec; | 3575 | struct sk_security_struct *ssec; |
3576 | struct inode_security_struct *isec; | 3576 | struct inode_security_struct *isec; |
3577 | u32 peer_sid = 0; | 3577 | u32 peer_sid = SECSID_NULL; |
3578 | 3578 | ||
3579 | isec = SOCK_INODE(sock)->i_security; | 3579 | isec = SOCK_INODE(sock)->i_security; |
3580 | 3580 | ||
3581 | /* if UNIX_STREAM check peer_sid, if TCP check dst for labelled sa */ | 3581 | if (isec->sclass == SECCLASS_UNIX_STREAM_SOCKET || |
3582 | if (isec->sclass == SECCLASS_UNIX_STREAM_SOCKET) { | 3582 | isec->sclass == SECCLASS_TCP_SOCKET) { |
3583 | ssec = sock->sk->sk_security; | 3583 | ssec = sock->sk->sk_security; |
3584 | peer_sid = ssec->peer_sid; | 3584 | peer_sid = ssec->peer_sid; |
3585 | } | 3585 | } |
3586 | else if (isec->sclass == SECCLASS_TCP_SOCKET) { | 3586 | if (peer_sid == SECSID_NULL) { |
3587 | peer_sid = selinux_netlbl_socket_getpeersec_stream(sock); | ||
3588 | if (peer_sid == SECSID_NULL) { | ||
3589 | ssec = sock->sk->sk_security; | ||
3590 | peer_sid = ssec->peer_sid; | ||
3591 | } | ||
3592 | if (peer_sid == SECSID_NULL) { | ||
3593 | err = -ENOPROTOOPT; | ||
3594 | goto out; | ||
3595 | } | ||
3596 | } | ||
3597 | else { | ||
3598 | err = -ENOPROTOOPT; | 3587 | err = -ENOPROTOOPT; |
3599 | goto out; | 3588 | goto out; |
3600 | } | 3589 | } |
@@ -3626,13 +3615,12 @@ static int selinux_socket_getpeersec_dgram(struct socket *sock, struct sk_buff * | |||
3626 | u32 peer_secid = SECSID_NULL; | 3615 | u32 peer_secid = SECSID_NULL; |
3627 | int err = 0; | 3616 | int err = 0; |
3628 | 3617 | ||
3629 | if (sock && (sock->sk->sk_family == PF_UNIX)) | 3618 | if (sock && sock->sk->sk_family == PF_UNIX) |
3630 | selinux_get_inode_sid(SOCK_INODE(sock), &peer_secid); | 3619 | selinux_get_inode_sid(SOCK_INODE(sock), &peer_secid); |
3631 | else if (skb) { | 3620 | else if (skb) |
3632 | peer_secid = selinux_netlbl_socket_getpeersec_dgram(skb); | 3621 | security_skb_extlbl_sid(skb, |
3633 | if (peer_secid == SECSID_NULL) | 3622 | SECINITSID_UNLABELED, |
3634 | peer_secid = selinux_socket_getpeer_dgram(skb); | 3623 | &peer_secid); |
3635 | } | ||
3636 | 3624 | ||
3637 | if (peer_secid == SECSID_NULL) | 3625 | if (peer_secid == SECSID_NULL) |
3638 | err = -EINVAL; | 3626 | err = -EINVAL; |
@@ -3693,17 +3681,10 @@ static int selinux_inet_conn_request(struct sock *sk, struct sk_buff *skb, | |||
3693 | u32 newsid; | 3681 | u32 newsid; |
3694 | u32 peersid; | 3682 | u32 peersid; |
3695 | 3683 | ||
3696 | newsid = selinux_netlbl_inet_conn_request(skb, sksec->sid); | 3684 | security_skb_extlbl_sid(skb, SECINITSID_UNLABELED, &peersid); |
3697 | if (newsid != SECSID_NULL) { | ||
3698 | req->secid = newsid; | ||
3699 | return 0; | ||
3700 | } | ||
3701 | |||
3702 | selinux_skb_xfrm_sid(skb, &peersid); | ||
3703 | |||
3704 | if (peersid == SECSID_NULL) { | 3685 | if (peersid == SECSID_NULL) { |
3705 | req->secid = sksec->sid; | 3686 | req->secid = sksec->sid; |
3706 | req->peer_secid = 0; | 3687 | req->peer_secid = SECSID_NULL; |
3707 | return 0; | 3688 | return 0; |
3708 | } | 3689 | } |
3709 | 3690 | ||
@@ -3738,7 +3719,7 @@ static void selinux_inet_conn_established(struct sock *sk, | |||
3738 | { | 3719 | { |
3739 | struct sk_security_struct *sksec = sk->sk_security; | 3720 | struct sk_security_struct *sksec = sk->sk_security; |
3740 | 3721 | ||
3741 | selinux_skb_xfrm_sid(skb, &sksec->peer_sid); | 3722 | security_skb_extlbl_sid(skb, SECINITSID_UNLABELED, &sksec->peer_sid); |
3742 | } | 3723 | } |
3743 | 3724 | ||
3744 | static void selinux_req_classify_flow(const struct request_sock *req, | 3725 | static void selinux_req_classify_flow(const struct request_sock *req, |