aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux/hooks.c
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2011-02-01 11:05:40 -0500
committerEric Paris <eparis@redhat.com>2011-02-01 11:12:30 -0500
commit652bb9b0d6ce007f37c098947b2cc0c45efa3f66 (patch)
tree7bf76f04a1fcaa401761a9a734b94682e2ac8b8c /security/selinux/hooks.c
parent2a7dba391e5628ad665ce84ef9a6648da541ebab (diff)
SELinux: Use dentry name in new object labeling
Currently SELinux has rules which label new objects according to 3 criteria. The label of the process creating the object, the label of the parent directory, and the type of object (reg, dir, char, block, etc.) This patch adds a 4th criteria, the dentry name, thus we can distinguish between creating a file in an etc_t directory called shadow and one called motd. There is no file globbing, regex parsing, or anything mystical. Either the policy exactly (strcmp) matches the dentry name of the object or it doesn't. This patch has no changes from today if policy does not implement the new rules. Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r--security/selinux/hooks.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 099bbd07732f..6ae19fd28be5 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -1301,10 +1301,8 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
1301 1301
1302 /* Try to obtain a transition SID. */ 1302 /* Try to obtain a transition SID. */
1303 isec->sclass = inode_mode_to_security_class(inode->i_mode); 1303 isec->sclass = inode_mode_to_security_class(inode->i_mode);
1304 rc = security_transition_sid(isec->task_sid, 1304 rc = security_transition_sid(isec->task_sid, sbsec->sid,
1305 sbsec->sid, 1305 isec->sclass, NULL, &sid);
1306 isec->sclass,
1307 &sid);
1308 if (rc) 1306 if (rc)
1309 goto out_unlock; 1307 goto out_unlock;
1310 isec->sid = sid; 1308 isec->sid = sid;
@@ -1579,7 +1577,7 @@ static int may_create(struct inode *dir,
1579 return rc; 1577 return rc;
1580 1578
1581 if (!newsid || !(sbsec->flags & SE_SBLABELSUPP)) { 1579 if (!newsid || !(sbsec->flags & SE_SBLABELSUPP)) {
1582 rc = security_transition_sid(sid, dsec->sid, tclass, &newsid); 1580 rc = security_transition_sid(sid, dsec->sid, tclass, NULL, &newsid);
1583 if (rc) 1581 if (rc)
1584 return rc; 1582 return rc;
1585 } 1583 }
@@ -2061,7 +2059,8 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm)
2061 } else { 2059 } else {
2062 /* Check for a default transition on this program. */ 2060 /* Check for a default transition on this program. */
2063 rc = security_transition_sid(old_tsec->sid, isec->sid, 2061 rc = security_transition_sid(old_tsec->sid, isec->sid,
2064 SECCLASS_PROCESS, &new_tsec->sid); 2062 SECCLASS_PROCESS, NULL,
2063 &new_tsec->sid);
2065 if (rc) 2064 if (rc)
2066 return rc; 2065 return rc;
2067 } 2066 }
@@ -2532,7 +2531,7 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir,
2532 else if (!newsid || !(sbsec->flags & SE_SBLABELSUPP)) { 2531 else if (!newsid || !(sbsec->flags & SE_SBLABELSUPP)) {
2533 rc = security_transition_sid(sid, dsec->sid, 2532 rc = security_transition_sid(sid, dsec->sid,
2534 inode_mode_to_security_class(inode->i_mode), 2533 inode_mode_to_security_class(inode->i_mode),
2535 &newsid); 2534 qstr, &newsid);
2536 if (rc) { 2535 if (rc) {
2537 printk(KERN_WARNING "%s: " 2536 printk(KERN_WARNING "%s: "
2538 "security_transition_sid failed, rc=%d (dev=%s " 2537 "security_transition_sid failed, rc=%d (dev=%s "
@@ -4845,7 +4844,7 @@ static int selinux_msg_queue_msgsnd(struct msg_queue *msq, struct msg_msg *msg,
4845 * message queue this message will be stored in 4844 * message queue this message will be stored in
4846 */ 4845 */
4847 rc = security_transition_sid(sid, isec->sid, SECCLASS_MSG, 4846 rc = security_transition_sid(sid, isec->sid, SECCLASS_MSG,
4848 &msec->sid); 4847 NULL, &msec->sid);
4849 if (rc) 4848 if (rc)
4850 return rc; 4849 return rc;
4851 } 4850 }