Skip to contentSkip to conversation

selinux: remove noop secondary_ops calls

RFC PATCH In review James Morris 4 participants 31 messages Jan 29, 2009 – Jan 30, 2009 SELinux security module

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 selinux: remove noop secondary_ops calls

These patches remove calls to secondary_ops where there is no real capability hook, and a couple of SELinux hooks which only called these noop hooks.

(Following this, the noop capabilities hooks should also be removed).

Please review.

James Morris (18):
selinux: remove unused bprm_check_security hook
selinux: remove secondary ops call to bprm_committing_creds
selinux: remove secondary ops call to bprm_committed_creds
selinux: remove secondary ops call to sb_mount
selinux: remove secondary ops call to sb_umount
selinux: remove secondary ops call to inode_link
selinux: remove secondary ops call to inode_unlink
selinux: remove secondary ops call to inode_mknod
selinux: remove secondary ops call to inode_follow_link
selinux: remove secondary ops call to inode_permission
selinux: remove secondary ops call to inode_setattr
selinux: remove secondary ops call to file_mprotect
selinux: remove secondary ops call to task_create
selinux: remove unused cred_commit hook
selinux: remove secondary ops call to task_setrlimit
selinux: remove secondary ops call to task_kill
selinux: remove secondary ops call to unix_stream_connect
selinux: remove secondary ops call to shm_shmat

 security/selinux/hooks.c |   92 +---------------------------------------------
 1 files changed, 2 insertions(+), 90 deletions(-)
Signature · 4 lines
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#1 lore raw

PATCH 1/18 selinux: remove unused bprm_check_security hook

Remove unused bprm_check_security hook from SELinux. This
currently calls into the capabilities hook, which is a noop.

(The capabilities hook should also be removed at some point).

---
 security/selinux/hooks.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
security/selinux/hooks.c +0 -6
index 3bb4942..8251c6b 100644
@@ -2182,11 +2182,6 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm)
 	return 0;
 }
 
-static int selinux_bprm_check_security(struct linux_binprm *bprm)
-{
-	return secondary_ops->bprm_check_security(bprm);
-}
-
 static int selinux_bprm_secureexec(struct linux_binprm *bprm)
 {
 	const struct cred *cred = current_cred();
@@ -5608,7 +5603,6 @@ static struct security_operations selinux_ops = {
 	.netlink_recv =			selinux_netlink_recv,
 
 	.bprm_set_creds =		selinux_bprm_set_creds,
-	.bprm_check_security =		selinux_bprm_check_security,
 	.bprm_committing_creds =	selinux_bprm_committing_creds,
 	.bprm_committed_creds =		selinux_bprm_committed_creds,
 	.bprm_secureexec =		selinux_bprm_secureexec,
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw

PATCH 2/18 selinux: remove secondary ops call to bprm_committing_creds

Remove secondary ops call to bprm_committing_creds, which is a noop in capabilities.

---
 security/selinux/hooks.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
security/selinux/hooks.c +0 -2
index 8251c6b..fc01ffa 100644
@@ -2311,8 +2311,6 @@ static void selinux_bprm_committing_creds(struct linux_binprm *bprm)
 	struct rlimit *rlim, *initrlim;
 	int rc, i;
 
-	secondary_ops->bprm_committing_creds(bprm);
-
 	new_tsec = bprm->cred->security;
 	if (new_tsec->sid == new_tsec->osid)
 		return;
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#3 lore raw

PATCH 3/18 selinux: remove secondary ops call to bprm_committed_creds

Remove secondary ops call to bprm_committed_creds, which is a noop in capabilities.

---
 security/selinux/hooks.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
security/selinux/hooks.c +0 -2
index fc01ffa..516058f 100644
@@ -2356,8 +2356,6 @@ static void selinux_bprm_committed_creds(struct linux_binprm *bprm)
 	int rc, i;
 	unsigned long flags;
 
-	secondary_ops->bprm_committed_creds(bprm);
-
 	osid = tsec->osid;
 	sid = tsec->sid;
 
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#4 lore raw

PATCH 4/18 selinux: remove secondary ops call to sb_mount

Remove secondary ops call to sb_mount, which is
a noop in capabilities.

---
 security/selinux/hooks.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
security/selinux/hooks.c +0 -5
index 516058f..bdd4830 100644
@@ -2531,11 +2531,6 @@ static int selinux_mount(char *dev_name,
 			 void *data)
 {
 	const struct cred *cred = current_cred();
-	int rc;
-
-	rc = secondary_ops->sb_mount(dev_name, path, type, flags, data);
-	if (rc)
-		return rc;
 
 	if (flags & MS_REMOUNT)
 		return superblock_has_perm(cred, path->mnt->mnt_sb,
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#5 lore raw

PATCH 5/18 selinux: remove secondary ops call to sb_umount

Remove secondary ops call to sb_umount, which is
a noop in capabilities.

---
 security/selinux/hooks.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
security/selinux/hooks.c +0 -5
index bdd4830..42aa8de 100644
@@ -2543,11 +2543,6 @@ static int selinux_mount(char *dev_name,
 static int selinux_umount(struct vfsmount *mnt, int flags)
 {
 	const struct cred *cred = current_cred();
-	int rc;
-
-	rc = secondary_ops->sb_umount(mnt, flags);
-	if (rc)
-		return rc;
 
 	return superblock_has_perm(cred, mnt->mnt_sb,
 				   FILESYSTEM__UNMOUNT, NULL);
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#6 lore raw

PATCH 6/18 selinux: remove secondary ops call to inode_link

Remove secondary ops call to inode_link, which is
a noop in capabilities.

---
 security/selinux/hooks.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
security/selinux/hooks.c +0 -5
index 42aa8de..da0e523 100644
@@ -2630,11 +2630,6 @@ static int selinux_inode_create(struct inode *dir, struct dentry *dentry, int ma
 
 static int selinux_inode_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry)
 {
-	int rc;
-
-	rc = secondary_ops->inode_link(old_dentry, dir, new_dentry);
-	if (rc)
-		return rc;
 	return may_link(dir, old_dentry, MAY_LINK);
 }
 
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#7 lore raw

PATCH 7/18 selinux: remove secondary ops call to inode_unlink

Remove secondary ops call to inode_unlink, which is a noop in capabilities.

---
 security/selinux/hooks.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
security/selinux/hooks.c +0 -5
index da0e523..ec834dc 100644
@@ -2635,11 +2635,6 @@ static int selinux_inode_link(struct dentry *old_dentry, struct inode *dir, stru
 
 static int selinux_inode_unlink(struct inode *dir, struct dentry *dentry)
 {
-	int rc;
-
-	rc = secondary_ops->inode_unlink(dir, dentry);
-	if (rc)
-		return rc;
 	return may_link(dir, dentry, MAY_UNLINK);
 }
 
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#8 lore raw

PATCH 8/18 selinux: remove secondary ops call to inode_mknod

Remove secondary ops call to inode_mknod, which is a noop in capabilities.

---
 security/selinux/hooks.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
security/selinux/hooks.c +0 -6
index ec834dc..0362192 100644
@@ -2655,12 +2655,6 @@ static int selinux_inode_rmdir(struct inode *dir, struct dentry *dentry)
 
 static int selinux_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
 {
-	int rc;
-
-	rc = secondary_ops->inode_mknod(dir, dentry, mode, dev);
-	if (rc)
-		return rc;
-
 	return may_create(dir, dentry, inode_mode_to_security_class(mode));
 }
 
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#9 lore raw

PATCH 9/18 selinux: remove secondary ops call to inode_follow_link

Remove secondary ops call to inode_follow_link, which is a noop in capabilities.

---
 security/selinux/hooks.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)
security/selinux/hooks.c +1 -5
index 0362192..e96cce3 100644
@@ -2674,11 +2674,7 @@ static int selinux_inode_readlink(struct dentry *dentry)
 static int selinux_inode_follow_link(struct dentry *dentry, struct nameidata *nameidata)
 {
 	const struct cred *cred = current_cred();
-	int rc;
-
-	rc = secondary_ops->inode_follow_link(dentry, nameidata);
-	if (rc)
-		return rc;
+	
 	return dentry_has_perm(cred, NULL, dentry, FILE__READ);
 }
 
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#10 lore raw

PATCH 10/18 selinux: remove secondary ops call to inode_permission

Remove secondary ops call to inode_permission, which is a noop in capabilities.

---
 security/selinux/hooks.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
security/selinux/hooks.c +0 -5
index e96cce3..3e043af 100644
@@ -2681,11 +2681,6 @@ static int selinux_inode_follow_link(struct dentry *dentry, struct nameidata *na
 static int selinux_inode_permission(struct inode *inode, int mask)
 {
 	const struct cred *cred = current_cred();
-	int rc;
-
-	rc = secondary_ops->inode_permission(inode, mask);
-	if (rc)
-		return rc;
 
 	if (!mask) {
 		/* No permission to check.  Existence test. */
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#11 lore raw

PATCH 11/18 selinux: remove secondary ops call to inode_setattr

Remove secondary ops call to inode_setattr, which is a noop in capabilities.

---
 security/selinux/hooks.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
security/selinux/hooks.c +0 -5
index 3e043af..7207e47 100644
@@ -2694,11 +2694,6 @@ static int selinux_inode_permission(struct inode *inode, int mask)
 static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr)
 {
 	const struct cred *cred = current_cred();
-	int rc;
-
-	rc = secondary_ops->inode_setattr(dentry, iattr);
-	if (rc)
-		return rc;
 
 	if (iattr->ia_valid & ATTR_FORCE)
 		return 0;
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#12 lore raw

PATCH 12/18 selinux: remove secondary ops call to file_mprotect

Remove secondary ops call to file_mprotect, which is a noop in capabilities.

---
 security/selinux/hooks.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)
security/selinux/hooks.c +1 -6
index 7207e47..7056570 100644
@@ -3056,18 +3056,13 @@ static int selinux_file_mprotect(struct vm_area_struct *vma,
 				 unsigned long prot)
 {
 	const struct cred *cred = current_cred();
-	int rc;
-
-	rc = secondary_ops->file_mprotect(vma, reqprot, prot);
-	if (rc)
-		return rc;
 
 	if (selinux_checkreqprot)
 		prot = reqprot;
 
 #ifndef CONFIG_PPC32
 	if ((prot & PROT_EXEC) && !(vma->vm_flags & VM_EXEC)) {
-		rc = 0;
+		int rc = 0;
 		if (vma->vm_start >= vma->vm_mm->start_brk &&
 		    vma->vm_end <= vma->vm_mm->brk) {
 			rc = cred_has_perm(cred, cred, PROCESS__EXECHEAP);
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#13 lore raw

PATCH 13/13 selinux: remove secondary ops call to file_mprotect

Remove secondary ops call to file_mprotect, which is a noop in capabilities.

---
 security/selinux/hooks.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
security/selinux/hooks.c +0 -6
index 7056570..99758ca 100644
@@ -3212,12 +3212,6 @@ static int selinux_dentry_open(struct file *file, const struct cred *cred)
 
 static int selinux_task_create(unsigned long clone_flags)
 {
-	int rc;
-
-	rc = secondary_ops->task_create(clone_flags);
-	if (rc)
-		return rc;
-
 	return current_has_perm(current, PROCESS__FORK);
 }
 
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#14 lore raw

PATCH 13/18 selinux: remove secondary ops call to task_create

Remove secondary ops call to task_create, which is a noop in capabilities.

---
 security/selinux/hooks.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
security/selinux/hooks.c +0 -6
index 7056570..99758ca 100644
@@ -3212,12 +3212,6 @@ static int selinux_dentry_open(struct file *file, const struct cred *cred)
 
 static int selinux_task_create(unsigned long clone_flags)
 {
-	int rc;
-
-	rc = secondary_ops->task_create(clone_flags);
-	if (rc)
-		return rc;
-
 	return current_has_perm(current, PROCESS__FORK);
 }
 
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#15 lore raw

PATCH 14/18 selinux: remove unused cred_commit hook

Remove unused cred_commit hook from SELinux. This
currently calls into the capabilities hook, which is a noop.

---
 security/selinux/hooks.c |    9 ---------
 1 files changed, 0 insertions(+), 9 deletions(-)
security/selinux/hooks.c +0 -9
index 99758ca..357be4a 100644
@@ -3245,14 +3245,6 @@ static int selinux_cred_prepare(struct cred *new, const struct cred *old,
 }
 
 /*
- * commit new credentials
- */
-static void selinux_cred_commit(struct cred *new, const struct cred *old)
-{
-	secondary_ops->cred_commit(new, old);
-}
-
-/*
  * set the security data for a kernel service
  * - all the creation contexts are set to unlabelled
  */
@@ -5610,7 +5602,6 @@ static struct security_operations selinux_ops = {
 	.task_create =			selinux_task_create,
 	.cred_free =			selinux_cred_free,
 	.cred_prepare =			selinux_cred_prepare,
-	.cred_commit =			selinux_cred_commit,
 	.kernel_act_as =		selinux_kernel_act_as,
 	.kernel_create_files_as =	selinux_kernel_create_files_as,
 	.task_setuid =			selinux_task_setuid,
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#16 lore raw

PATCH 15/18 selinux: remove secondary ops call to task_setrlimit

Remove secondary ops call to task_setrlimit, which is a noop in capabilities.

---
 security/selinux/hooks.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
security/selinux/hooks.c +0 -5
index 357be4a..6633196 100644
@@ -3367,11 +3367,6 @@ static int selinux_task_getioprio(struct task_struct *p)
 static int selinux_task_setrlimit(unsigned int resource, struct rlimit *new_rlim)
 {
 	struct rlimit *old_rlim = current->signal->rlim + resource;
-	int rc;
-
-	rc = secondary_ops->task_setrlimit(resource, new_rlim);
-	if (rc)
-		return rc;
 
 	/* Control the ability to change the hard limit (whether
 	   lowering or raising it), so that the hard limit can
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#17 lore raw

PATCH 16/18 selinux: remove secondary ops call to task_kill

Remove secondary ops call to task_kill, which is
a noop in capabilities.

---
 security/selinux/hooks.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
security/selinux/hooks.c +0 -4
index 6633196..e8f616a 100644
@@ -3405,10 +3405,6 @@ static int selinux_task_kill(struct task_struct *p, struct siginfo *info,
 	u32 perm;
 	int rc;
 
-	rc = secondary_ops->task_kill(p, info, sig, secid);
-	if (rc)
-		return rc;
-
 	if (!sig)
 		perm = PROCESS__SIGNULL; /* null signal; existence test */
 	else
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#18 lore raw

PATCH 17/18 selinux: remove secondary ops call to unix_stream_connect

Remove secondary ops call to unix_stream_connect, which is a noop in capabilities.

---
 security/selinux/hooks.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
security/selinux/hooks.c +0 -4
index e8f616a..086eb14 100644
@@ -3997,10 +3997,6 @@ static int selinux_socket_unix_stream_connect(struct socket *sock,
 	struct avc_audit_data ad;
 	int err;
 
-	err = secondary_ops->unix_stream_connect(sock, other, newsk);
-	if (err)
-		return err;
-
 	isec = SOCK_INODE(sock)->i_security;
 	other_isec = SOCK_INODE(other)->i_security;
 
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#19 lore raw

PATCH 18/18 selinux: remove secondary ops call to shm_shmat

Remove secondary ops call to shm_shmat, which is
a noop in capabilities.

---
 security/selinux/hooks.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
security/selinux/hooks.c +0 -5
index 086eb14..e574c28 100644
@@ -5113,11 +5113,6 @@ static int selinux_shm_shmat(struct shmid_kernel *shp,
 			     char __user *shmaddr, int shmflg)
 {
 	u32 perms;
-	int rc;
-
-	rc = secondary_ops->shm_shmat(shp, shmaddr, shmflg);
-	if (rc)
-		return rc;
 
 	if (shmflg & SHM_RDONLY)
 		perms = SHM__READ;
Signature · 7 lines
1.6.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#20 lore raw

Re: [PATCH 13/13] selinux: remove secondary ops call to file_mprotect

In reply to James Morris
Quoted 3 lines · James Morris

Remove secondary ops call to file_mprotect, which is a noop in capabilities.

Wrong patch?

Quoted 29 lines
---
 security/selinux/hooks.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
security/selinux/hooks.c +0 -6
index 7056570..99758ca 100644
@@ -3212,12 +3212,6 @@ static int selinux_dentry_open(struct file *file, const struct cred *cred)
 
 static int selinux_task_create(unsigned long clone_flags)
 {
-	int rc;
-
-	rc = secondary_ops->task_create(clone_flags);
-	if (rc)
-		return rc;
-
 	return current_has_perm(current, PROCESS__FORK);
 }
 
Signature · 6 lines
1.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#21 lore raw

Re: [PATCH 13/13] selinux: remove secondary ops call to file_mprotect

Quoted 6 lines · Serge E. Hallyn
Quoted 3 lines · James Morris

Remove secondary ops call to file_mprotect, which is a noop in capabilities.

Wrong patch?

Ahh, older version of a wrongly described patch which ended up in the directory from where the patchset was sent (it's not in the local git repo).

Quoted 31 lines
Quoted 30 lines
---
 security/selinux/hooks.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
security/selinux/hooks.c +0 -6
index 7056570..99758ca 100644
@@ -3212,12 +3212,6 @@ static int selinux_dentry_open(struct file *file, const struct cred *cred)
 
 static int selinux_task_create(unsigned long clone_flags)
 {
-	int rc;
-
-	rc = secondary_ops->task_create(clone_flags);
-	if (rc)
-		return rc;
-
 	return current_has_perm(current, PROCESS__FORK);
 }
 
Signature · 6 lines
1.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 7 lines
James Morris
<[email protected]>

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#22 lore raw

Re: [PATCH 09/18] selinux: remove secondary ops call to inode_follow_link

In reply to James Morris
Quoted 7 lines · James Morris

Remove secondary ops call to inode_follow_link, which is a noop in capabilities.

---
 security/selinux/hooks.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

NAK looks like white space damage.

Quoted 7 lines
security/selinux/hooks.c +0 -0
index 0362192..e96cce3 100644
@@ -2674,11 +2674,7 @@ static int selinux_inode_readlink(struct dentry *dentry)
 static int selinux_inode_follow_link(struct dentry *dentry, struct nameidata *nameidata)
 {

security/selinux/hooks.c static int selinux_inode_readlink(struct dentry *dentry) · line 2680

Quoted 10 lines
security/selinux/hooks.c +1 -5
 	const struct cred *cred = current_cred();
-	int rc;
-
-	rc = secondary_ops->inode_follow_link(dentry, nameidata);
-	if (rc)
-		return rc;
+	
 	return dentry_has_perm(cred, NULL, dentry, FILE__READ);
 }
 

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#23 lore raw

Re: [PATCH 09/18] selinux: remove secondary ops call to inode_follow_link

Quoted 10 lines · Eric Paris
Quoted 7 lines · James Morris

Remove secondary ops call to inode_follow_link, which is a noop in capabilities.

---
 security/selinux/hooks.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

NAK looks like white space damage.

Indeed. It'll disappear when I apply it via git-am --whitespace=strip.

Quoted 20 lines
Quoted 18 lines
security/selinux/hooks.c +1 -5
index 0362192..e96cce3 100644
@@ -2674,11 +2674,7 @@ static int selinux_inode_readlink(struct dentry *dentry)
 static int selinux_inode_follow_link(struct dentry *dentry, struct nameidata *nameidata)
 {
 	const struct cred *cred = current_cred();
-	int rc;
-
-	rc = secondary_ops->inode_follow_link(dentry, nameidata);
-	if (rc)
-		return rc;
+	
 	return dentry_has_perm(cred, NULL, dentry, FILE__READ);
 }
 
Signature · 7 lines
James Morris
<[email protected]>

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
Acked-by on v1 1/1
#24 lore raw
In reply to James Morris
Quoted 19 lines · James Morris

These patches remove calls to secondary_ops where there is no real capability hook, and a couple of SELinux hooks which only called these noop hooks.

(Following this, the noop capabilities hooks should also be removed).

Please review.

James Morris (18):
selinux: remove unused bprm_check_security hook
selinux: remove secondary ops call to bprm_committing_creds
selinux: remove secondary ops call to bprm_committed_creds
selinux: remove secondary ops call to sb_mount
selinux: remove secondary ops call to sb_umount
selinux: remove secondary ops call to inode_link
selinux: remove secondary ops call to inode_unlink
selinux: remove secondary ops call to inode_mknod
selinux: remove secondary ops call to inode_follow_link
selinux: remove secondary ops call to inode_permission

Quoted 8 lines

selinux: remove secondary ops call to inode_setattr
selinux: remove secondary ops call to file_mprotect
selinux: remove secondary ops call to task_create
selinux: remove unused cred_commit hook
selinux: remove secondary ops call to task_setrlimit
selinux: remove secondary ops call to task_kill
selinux: remove secondary ops call to unix_stream_connect
selinux: remove secondary ops call to shm_shmat

For the entire series EXCEPT #9 inode_follow_link:

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#25 lore raw
Quoted 29 lines · Eric Paris
Quoted 19 lines · James Morris

These patches remove calls to secondary_ops where there is no real capability hook, and a couple of SELinux hooks which only called these noop hooks.

(Following this, the noop capabilities hooks should also be removed).

Please review.

James Morris (18):
selinux: remove unused bprm_check_security hook
selinux: remove secondary ops call to bprm_committing_creds
selinux: remove secondary ops call to bprm_committed_creds
selinux: remove secondary ops call to sb_mount
selinux: remove secondary ops call to sb_umount
selinux: remove secondary ops call to inode_link
selinux: remove secondary ops call to inode_unlink
selinux: remove secondary ops call to inode_mknod
selinux: remove secondary ops call to inode_follow_link
selinux: remove secondary ops call to inode_permission

Quoted 8 lines

selinux: remove secondary ops call to inode_setattr
selinux: remove secondary ops call to file_mprotect
selinux: remove secondary ops call to task_create
selinux: remove unused cred_commit hook
selinux: remove secondary ops call to task_setrlimit
selinux: remove secondary ops call to task_kill
selinux: remove secondary ops call to unix_stream_connect
selinux: remove secondary ops call to shm_shmat

Quoted 2 lines

For the entire series EXCEPT #9 inode_follow_link:

Yup, all looks reasonable, except for the wrong patch attached to the mprotect description :)

fwiw...

-serge

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#26 lore raw
In reply to James Morris
Quoted 5 lines · James Morris

These patches remove calls to secondary_ops where there is no real capability hook, and a couple of SELinux hooks which only called these noop hooks.

(Following this, the noop capabilities hooks should also be removed).

I don't think you can - the capability stubs now serve as the default/dummy hooks used by security_fixup_ops(), so it has to define a stub for every hook.

Quoted 26 lines

Please review.

James Morris (18):
selinux: remove unused bprm_check_security hook
selinux: remove secondary ops call to bprm_committing_creds
selinux: remove secondary ops call to bprm_committed_creds
selinux: remove secondary ops call to sb_mount
selinux: remove secondary ops call to sb_umount
selinux: remove secondary ops call to inode_link
selinux: remove secondary ops call to inode_unlink
selinux: remove secondary ops call to inode_mknod
selinux: remove secondary ops call to inode_follow_link
selinux: remove secondary ops call to inode_permission
selinux: remove secondary ops call to inode_setattr
selinux: remove secondary ops call to file_mprotect
selinux: remove secondary ops call to task_create
selinux: remove unused cred_commit hook
selinux: remove secondary ops call to task_setrlimit
selinux: remove secondary ops call to task_kill
selinux: remove secondary ops call to unix_stream_connect
selinux: remove secondary ops call to shm_shmat

 security/selinux/hooks.c |   92 +---------------------------------------------
 1 files changed, 2 insertions(+), 90 deletions(-)
Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#27 lore raw
In reply to James Morris
Quoted 3 lines · James Morris

These patches remove calls to secondary_ops where there is no real capability hook, and a couple of SELinux hooks which only called these noop hooks.

These look fine to me, modulo the comments already made by Eric and Serge.

You could further replace the remaining secondary_ops calls with direct cap_ calls, since the dummy module is gone and the secondary module can only be the capability module. Smack and AppArmor already do this, I believe.

At that point secondary_ops would only be used by selinux_init() to save the original security_ops pointer for use by selinux_disable() to restore the original pointer, which ideally would be handled by the security framework instead (possibly by restoring a limited unregister_security() that resets to the default_security_ops).

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#28 lore raw
Quoted 13 lines · Stephen Smalley
Quoted 3 lines · James Morris

These patches remove calls to secondary_ops where there is no real capability hook, and a couple of SELinux hooks which only called these noop hooks.

These look fine to me, modulo the comments already made by Eric and Serge.

You could further replace the remaining secondary_ops calls with direct cap_ calls, since the dummy module is gone and the secondary module can only be the capability module. Smack and AppArmor already do this, I believe.

Quoted 5 lines

At that point secondary_ops would only be used by selinux_init() to save the original security_ops pointer for use by selinux_disable() to restore the original pointer, which ideally would be handled by the security framework instead (possibly by restoring a limited unregister_security() that resets to the default_security_ops).

Other tidying:
- drop selinux_inode*killpriv
- drop selinux_task*setuid
- drop selinux_task_prctl
since the hooks will default to the capability functions if SELinux doesn't define them.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#29 lore raw

RFC PATCH 1/1 selinux: remove hooks which simply defer to capabilities

Quoted 6 lines · Stephen Smalley

Other tidying:
- drop selinux_inode*killpriv
- drop selinux_task*setuid
- drop selinux_task_prctl
since the hooks will default to the capability functions if SELinux doesn't define them.

Ok, see below. (I also removed task_setgroups).

Please review.

---

commit 4d51a060468068b8db48883301c9318547aec454

Author: James Morris <[email protected]>
Date:   Fri Jan 30 10:05:06 2009 +1100

selinux: remove hooks which simply defer to capabilities

Remove SELinux hooks which do nothing except defer to the capabilites hooks (or in one case, replicates the function).

security/selinux/hooks.c +10 -58
index d960479..a69d6f8 100644
@@ -1892,6 +1892,16 @@ static int selinux_capset(struct cred *new, const struct cred *old,
 	return cred_has_perm(old, new, PROCESS__SETCAP);
 }
 
+/*
+ * (This comment used to live with the selinux_task_setuid hook,
+ * which was removed).
+ *
+ * Since setuid only affects the current process, and since the SELinux
+ * controls are not based on the Linux identity attributes, SELinux does not
+ * need to control this operation.  However, SELinux does control the use of
+ * the CAP_SETUID and CAP_SETGID capabilities using the capable hook.
+ */
+
 static int selinux_capable(struct task_struct *tsk, const struct cred *cred,
 			   int cap, int audit)
 {
@@ -2909,16 +2919,6 @@ static int selinux_inode_listsecurity(struct inode *inode, char *buffer, size_t
 	return len;
 }
 
-static int selinux_inode_need_killpriv(struct dentry *dentry)
-{
-	return secondary_ops->inode_need_killpriv(dentry);
-}
-
-static int selinux_inode_killpriv(struct dentry *dentry)
-{
-	return secondary_ops->inode_killpriv(dentry);
-}
-
 static void selinux_inode_getsecid(const struct inode *inode, u32 *secid)
 {
 	struct inode_security_struct *isec = inode->i_security;
@@ -3288,29 +3288,6 @@ static int selinux_kernel_create_files_as(struct cred *new, struct inode *inode)
 	return 0;
 }
 
-static int selinux_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags)
-{
-	/* Since setuid only affects the current process, and
-	   since the SELinux controls are not based on the Linux
-	   identity attributes, SELinux does not need to control
-	   this operation.  However, SELinux does control the use
-	   of the CAP_SETUID and CAP_SETGID capabilities using the
-	   capable hook. */
-	return 0;
-}
-
-static int selinux_task_fix_setuid(struct cred *new, const struct cred *old,
-				   int flags)
-{
-	return secondary_ops->task_fix_setuid(new, old, flags);
-}
-
-static int selinux_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags)
-{
-	/* See the comment for setuid above. */
-	return 0;
-}
-
 static int selinux_task_setpgid(struct task_struct *p, pid_t pgid)
 {
 	return current_has_perm(p, PROCESS__SETPGID);
@@ -3331,12 +3308,6 @@ static void selinux_task_getsecid(struct task_struct *p, u32 *secid)
 	*secid = task_sid(p);
 }
 
-static int selinux_task_setgroups(struct group_info *group_info)
-{
-	/* See the comment for setuid above. */
-	return 0;
-}
-
 static int selinux_task_setnice(struct task_struct *p, int nice)
 {
 	int rc;
@@ -3417,18 +3388,6 @@ static int selinux_task_kill(struct task_struct *p, struct siginfo *info,
 	return rc;
 }
 
-static int selinux_task_prctl(int option,
-			      unsigned long arg2,
-			      unsigned long arg3,
-			      unsigned long arg4,
-			      unsigned long arg5)
-{
-	/* The current prctl operations do not appear to require
-	   any SELinux controls since they merely observe or modify
-	   the state of the current process. */
-	return secondary_ops->task_prctl(option, arg2, arg3, arg4, arg5);
-}
-
 static int selinux_task_wait(struct task_struct *p)
 {
 	return task_has_perm(p, current, PROCESS__SIGCHLD);
@@ -5563,8 +5522,6 @@ static struct security_operations selinux_ops = {
 	.inode_getsecurity =		selinux_inode_getsecurity,
 	.inode_setsecurity =		selinux_inode_setsecurity,
 	.inode_listsecurity =		selinux_inode_listsecurity,
-	.inode_need_killpriv =		selinux_inode_need_killpriv,
-	.inode_killpriv =		selinux_inode_killpriv,
 	.inode_getsecid =		selinux_inode_getsecid,
 
 	.file_permission =		selinux_file_permission,
@@ -5586,14 +5543,10 @@ static struct security_operations selinux_ops = {
 	.cred_prepare =			selinux_cred_prepare,
 	.kernel_act_as =		selinux_kernel_act_as,
 	.kernel_create_files_as =	selinux_kernel_create_files_as,
-	.task_setuid =			selinux_task_setuid,
-	.task_fix_setuid =		selinux_task_fix_setuid,
-	.task_setgid =			selinux_task_setgid,
 	.task_setpgid =			selinux_task_setpgid,
 	.task_getpgid =			selinux_task_getpgid,
 	.task_getsid =			selinux_task_getsid,
 	.task_getsecid =		selinux_task_getsecid,
-	.task_setgroups =		selinux_task_setgroups,
 	.task_setnice =			selinux_task_setnice,
 	.task_setioprio =		selinux_task_setioprio,
 	.task_getioprio =		selinux_task_getioprio,
@@ -5603,7 +5556,6 @@ static struct security_operations selinux_ops = {
 	.task_movememory =		selinux_task_movememory,
 	.task_kill =			selinux_task_kill,
 	.task_wait =			selinux_task_wait,
-	.task_prctl =			selinux_task_prctl,
 	.task_to_inode =		selinux_task_to_inode,
 
 	.ipc_permission =		selinux_ipc_permission,

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

Acked-by on v1 1/1
#30 lore raw

Re: [PATCH][RFC] selinux: remove hooks which simply defer to capabilities

Quoted 19 lines · James Morris
Quoted 6 lines · Stephen Smalley

Other tidying:
- drop selinux_inode*killpriv
- drop selinux_task*setuid
- drop selinux_task_prctl
since the hooks will default to the capability functions if SELinux doesn't define them.

Ok, see below. (I also removed task_setgroups).

Please review.

---

commit 4d51a060468068b8db48883301c9318547aec454

Author: James Morris <[email protected]>
Date:   Fri Jan 30 10:05:06 2009 +1100
Quoted 6 lines

selinux: remove hooks which simply defer to capabilities

Remove SELinux hooks which do nothing except defer to the capabilites hooks (or in one case, replicates the function).

Quoted 133 lines
security/selinux/hooks.c +10 -58
index d960479..a69d6f8 100644
@@ -1892,6 +1892,16 @@ static int selinux_capset(struct cred *new, const struct cred *old,
 	return cred_has_perm(old, new, PROCESS__SETCAP);
 }
 
+/*
+ * (This comment used to live with the selinux_task_setuid hook,
+ * which was removed).
+ *
+ * Since setuid only affects the current process, and since the SELinux
+ * controls are not based on the Linux identity attributes, SELinux does not
+ * need to control this operation.  However, SELinux does control the use of
+ * the CAP_SETUID and CAP_SETGID capabilities using the capable hook.
+ */
+
 static int selinux_capable(struct task_struct *tsk, const struct cred *cred,
 			   int cap, int audit)
 {
@@ -2909,16 +2919,6 @@ static int selinux_inode_listsecurity(struct inode *inode, char *buffer, size_t
 	return len;
 }
 
-static int selinux_inode_need_killpriv(struct dentry *dentry)
-{
-	return secondary_ops->inode_need_killpriv(dentry);
-}
-
-static int selinux_inode_killpriv(struct dentry *dentry)
-{
-	return secondary_ops->inode_killpriv(dentry);
-}
-
 static void selinux_inode_getsecid(const struct inode *inode, u32 *secid)
 {
 	struct inode_security_struct *isec = inode->i_security;
@@ -3288,29 +3288,6 @@ static int selinux_kernel_create_files_as(struct cred *new, struct inode *inode)
 	return 0;
 }
 
-static int selinux_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags)
-{
-	/* Since setuid only affects the current process, and
-	   since the SELinux controls are not based on the Linux
-	   identity attributes, SELinux does not need to control
-	   this operation.  However, SELinux does control the use
-	   of the CAP_SETUID and CAP_SETGID capabilities using the
-	   capable hook. */
-	return 0;
-}
-
-static int selinux_task_fix_setuid(struct cred *new, const struct cred *old,
-				   int flags)
-{
-	return secondary_ops->task_fix_setuid(new, old, flags);
-}
-
-static int selinux_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags)
-{
-	/* See the comment for setuid above. */
-	return 0;
-}
-
 static int selinux_task_setpgid(struct task_struct *p, pid_t pgid)
 {
 	return current_has_perm(p, PROCESS__SETPGID);
@@ -3331,12 +3308,6 @@ static void selinux_task_getsecid(struct task_struct *p, u32 *secid)
 	*secid = task_sid(p);
 }
 
-static int selinux_task_setgroups(struct group_info *group_info)
-{
-	/* See the comment for setuid above. */
-	return 0;
-}
-
 static int selinux_task_setnice(struct task_struct *p, int nice)
 {
 	int rc;
@@ -3417,18 +3388,6 @@ static int selinux_task_kill(struct task_struct *p, struct siginfo *info,
 	return rc;
 }
 
-static int selinux_task_prctl(int option,
-			      unsigned long arg2,
-			      unsigned long arg3,
-			      unsigned long arg4,
-			      unsigned long arg5)
-{
-	/* The current prctl operations do not appear to require
-	   any SELinux controls since they merely observe or modify
-	   the state of the current process. */
-	return secondary_ops->task_prctl(option, arg2, arg3, arg4, arg5);
-}
-
 static int selinux_task_wait(struct task_struct *p)
 {
 	return task_has_perm(p, current, PROCESS__SIGCHLD);
@@ -5563,8 +5522,6 @@ static struct security_operations selinux_ops = {
 	.inode_getsecurity =		selinux_inode_getsecurity,
 	.inode_setsecurity =		selinux_inode_setsecurity,
 	.inode_listsecurity =		selinux_inode_listsecurity,
-	.inode_need_killpriv =		selinux_inode_need_killpriv,
-	.inode_killpriv =		selinux_inode_killpriv,
 	.inode_getsecid =		selinux_inode_getsecid,
 
 	.file_permission =		selinux_file_permission,
@@ -5586,14 +5543,10 @@ static struct security_operations selinux_ops = {
 	.cred_prepare =			selinux_cred_prepare,
 	.kernel_act_as =		selinux_kernel_act_as,
 	.kernel_create_files_as =	selinux_kernel_create_files_as,
-	.task_setuid =			selinux_task_setuid,
-	.task_fix_setuid =		selinux_task_fix_setuid,
-	.task_setgid =			selinux_task_setgid,
 	.task_setpgid =			selinux_task_setpgid,
 	.task_getpgid =			selinux_task_getpgid,
 	.task_getsid =			selinux_task_getsid,
 	.task_getsecid =		selinux_task_getsecid,
-	.task_setgroups =		selinux_task_setgroups,
 	.task_setnice =			selinux_task_setnice,
 	.task_setioprio =		selinux_task_setioprio,
 	.task_getioprio =		selinux_task_getioprio,
@@ -5603,7 +5556,6 @@ static struct security_operations selinux_ops = {
 	.task_movememory =		selinux_task_movememory,
 	.task_kill =			selinux_task_kill,
 	.task_wait =			selinux_task_wait,
-	.task_prctl =			selinux_task_prctl,
 	.task_to_inode =		selinux_task_to_inode,
 
 	.ipc_permission =		selinux_ipc_permission,
Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.