Skip to contentSkip to conversation

selinux: initialize sock security class to default value

PATCH Applied Stephen Smalley 2 participants 2 messages Jun 15, 2015 – Jun 18, 2015 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selinux: initialize sock security class to default value

Initialize the security class of sock security structures to the generic socket class. This is similar to what is already done in inode_alloc_security for files. Generally the sclass field will later by set by socket_post_create or sk_clone or sock_graft, but for protocol implementations that fail to call any of these for newly accepted sockets, we want some sane default that will yield a legitimate avc denied message with non-garbage values for class and permission.

---
 security/selinux/hooks.c | 1 +
 1 file changed, 1 insertion(+)
security/selinux/hooks.c +1 -0
index 312537d..90e6cdc 100644
@@ -4507,6 +4507,7 @@ static int selinux_sk_alloc_security(struct sock *sk, int family, gfp_t priority
 
 	sksec->peer_sid = SECINITSID_UNLABELED;
 	sksec->sid = SECINITSID_UNLABELED;
+	sksec->sclass = SECCLASS_SOCKET;
 	selinux_netlbl_sk_security_reset(sksec);
 	sk->sk_security = sksec;
 
Signature · 1 line
2.1.0
maintainer Applied
#1 lore raw
Quoted 10 lines · Stephen Smalley

Initialize the security class of sock security structures to the generic socket class. This is similar to what is already done in inode_alloc_security for files. Generally the sclass field will later by set by socket_post_create or sk_clone or sock_graft, but for protocol implementations that fail to call any of these for newly accepted sockets, we want some sane default that will yield a legitimate avc denied message with non-garbage values for class and permission.

Quoted 4 lines
---
 security/selinux/hooks.c | 1 +
 1 file changed, 1 insertion(+)

Applied to the SELinux next-queue, thanks.

Quoted 12 lines
security/selinux/hooks.c +0 -0
index 312537d..90e6cdc 100644
@@ -4507,6 +4507,7 @@ static int selinux_sk_alloc_security(struct sock *sk,

int family, gfp_t priority

security/selinux/hooks.c +1 -0
 	sksec->peer_sid = SECINITSID_UNLABELED;
 	sksec->sid = SECINITSID_UNLABELED;
+	sksec->sclass = SECCLASS_SOCKET;
 	selinux_netlbl_sk_security_reset(sksec);
 	sk->sk_security = sksec;
Signature · 2 lines
paul moore
www.paul-moore.com