Skip to content

Commit 0955dc0

Browse files
stephensmalleyJames Morris
authored andcommitted
SELinux: do not clear f_op when removing entries
Do not clear f_op when removing entries since it isn't safe to do. Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: James Morris <jmorris@namei.org>
1 parent e3c0ac0 commit 0955dc0

File tree

1 file changed

+1
-27
lines changed

1 file changed

+1
-27
lines changed

security/selinux/selinuxfs.c

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -838,10 +838,6 @@ static ssize_t sel_read_bool(struct file *filep, char __user *buf,
838838

839839
ret = -EFAULT;
840840

841-
/* check to see if this file has been deleted */
842-
if (!filep->f_op)
843-
goto out;
844-
845841
if (count > PAGE_SIZE) {
846842
ret = -EINVAL;
847843
goto out;
@@ -882,10 +878,6 @@ static ssize_t sel_write_bool(struct file *filep, const char __user *buf,
882878
if (length)
883879
goto out;
884880

885-
/* check to see if this file has been deleted */
886-
if (!filep->f_op)
887-
goto out;
888-
889881
if (count >= PAGE_SIZE) {
890882
length = -ENOMEM;
891883
goto out;
@@ -940,10 +932,6 @@ static ssize_t sel_commit_bools_write(struct file *filep,
940932
if (length)
941933
goto out;
942934

943-
/* check to see if this file has been deleted */
944-
if (!filep->f_op)
945-
goto out;
946-
947935
if (count >= PAGE_SIZE) {
948936
length = -ENOMEM;
949937
goto out;
@@ -982,11 +970,9 @@ static const struct file_operations sel_commit_bools_ops = {
982970
.write = sel_commit_bools_write,
983971
};
984972

985-
/* partial revoke() from fs/proc/generic.c proc_kill_inodes */
986973
static void sel_remove_entries(struct dentry *de)
987974
{
988-
struct list_head *p, *node;
989-
struct super_block *sb = de->d_sb;
975+
struct list_head *node;
990976

991977
spin_lock(&dcache_lock);
992978
node = de->d_subdirs.next;
@@ -1006,18 +992,6 @@ static void sel_remove_entries(struct dentry *de)
1006992
}
1007993

1008994
spin_unlock(&dcache_lock);
1009-
1010-
file_list_lock();
1011-
list_for_each(p, &sb->s_files) {
1012-
struct file * filp = list_entry(p, struct file, f_u.fu_list);
1013-
struct dentry * dentry = filp->f_path.dentry;
1014-
1015-
if (dentry->d_parent != de) {
1016-
continue;
1017-
}
1018-
filp->f_op = NULL;
1019-
}
1020-
file_list_unlock();
1021995
}
1022996

1023997
#define BOOL_DIR_NAME "booleans"

0 commit comments

Comments
 (0)