aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux/netlabel.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/selinux/netlabel.c')
-rw-r--r--security/selinux/netlabel.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/security/selinux/netlabel.c b/security/selinux/netlabel.c
index 8192e8bc9f5a..e64eca246f1a 100644
--- a/security/selinux/netlabel.c
+++ b/security/selinux/netlabel.c
@@ -158,7 +158,9 @@ int selinux_netlbl_skbuff_getsid(struct sk_buff *skb, u32 base_sid, u32 *sid)
158 netlbl_secattr_init(&secattr); 158 netlbl_secattr_init(&secattr);
159 rc = netlbl_skbuff_getattr(skb, &secattr); 159 rc = netlbl_skbuff_getattr(skb, &secattr);
160 if (rc == 0 && secattr.flags != NETLBL_SECATTR_NONE) 160 if (rc == 0 && secattr.flags != NETLBL_SECATTR_NONE)
161 rc = security_netlbl_secattr_to_sid(&secattr, base_sid, sid); 161 rc = security_netlbl_secattr_to_sid(&secattr,
162 base_sid,
163 sid);
162 else 164 else
163 *sid = SECSID_NULL; 165 *sid = SECSID_NULL;
164 netlbl_secattr_destroy(&secattr); 166 netlbl_secattr_destroy(&secattr);
@@ -196,7 +198,7 @@ void selinux_netlbl_sock_graft(struct sock *sk, struct socket *sock)
196 if (netlbl_sock_getattr(sk, &secattr) == 0 && 198 if (netlbl_sock_getattr(sk, &secattr) == 0 &&
197 secattr.flags != NETLBL_SECATTR_NONE && 199 secattr.flags != NETLBL_SECATTR_NONE &&
198 security_netlbl_secattr_to_sid(&secattr, 200 security_netlbl_secattr_to_sid(&secattr,
199 SECINITSID_NETMSG, 201 SECINITSID_UNLABELED,
200 &nlbl_peer_sid) == 0) 202 &nlbl_peer_sid) == 0)
201 sksec->peer_sid = nlbl_peer_sid; 203 sksec->peer_sid = nlbl_peer_sid;
202 netlbl_secattr_destroy(&secattr); 204 netlbl_secattr_destroy(&secattr);
@@ -293,32 +295,38 @@ int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
293 struct avc_audit_data *ad) 295 struct avc_audit_data *ad)
294{ 296{
295 int rc; 297 int rc;
296 u32 nlbl_sid; 298 u32 netlbl_sid;
297 u32 perm; 299 u32 recv_perm;
298 300
299 rc = selinux_netlbl_skbuff_getsid(skb, SECINITSID_NETMSG, &nlbl_sid); 301 rc = selinux_netlbl_skbuff_getsid(skb,
302 SECINITSID_UNLABELED,
303 &netlbl_sid);
300 if (rc != 0) 304 if (rc != 0)
301 return rc; 305 return rc;
302 if (nlbl_sid == SECSID_NULL) 306
303 nlbl_sid = SECINITSID_UNLABELED; 307 if (netlbl_sid == SECSID_NULL)
308 return 0;
304 309
305 switch (sksec->sclass) { 310 switch (sksec->sclass) {
306 case SECCLASS_UDP_SOCKET: 311 case SECCLASS_UDP_SOCKET:
307 perm = UDP_SOCKET__RECVFROM; 312 recv_perm = UDP_SOCKET__RECVFROM;
308 break; 313 break;
309 case SECCLASS_TCP_SOCKET: 314 case SECCLASS_TCP_SOCKET:
310 perm = TCP_SOCKET__RECVFROM; 315 recv_perm = TCP_SOCKET__RECVFROM;
311 break; 316 break;
312 default: 317 default:
313 perm = RAWIP_SOCKET__RECVFROM; 318 recv_perm = RAWIP_SOCKET__RECVFROM;
314 } 319 }
315 320
316 rc = avc_has_perm(sksec->sid, nlbl_sid, sksec->sclass, perm, ad); 321 rc = avc_has_perm(sksec->sid,
322 netlbl_sid,
323 sksec->sclass,
324 recv_perm,
325 ad);
317 if (rc == 0) 326 if (rc == 0)
318 return 0; 327 return 0;
319 328
320 if (nlbl_sid != SECINITSID_UNLABELED) 329 netlbl_skbuff_err(skb, rc);
321 netlbl_skbuff_err(skb, rc);
322 return rc; 330 return rc;
323} 331}
324 332