selinux: allow multiple opens of /sys/fs/selinux/policy
Stephen Smalley
maintainerPATCH 1/1 selinux: allow multiple opens of /sys/fs/selinux/policy
Currently there can only be a single open of /sys/fs/selinux/policy at any time. This allows any process to block any other process from reading the kernel policy. The original motivation seems to have been a mix of preventing an inconsistent view of the policy size and preventing userspace from allocating kernel memory without bound, but this is arguably equally bad.
Signed-off-by Stephen Smalley <[email protected]>
--- security/selinux/selinuxfs.c | 11 ----------- 1 file changed, 11 deletions(-)
security/selinux/selinuxfs.c +0 -11
@@ -76,7 +76,6 @@ struct selinux_fs_info {int *bool_pending_values;struct dentry *class_dir;unsigned long last_class_ino; -bool policy_opened;unsigned long last_ino;struct super_block *sb; };
@@ -360,7 +359,6 @@ struct policy_load_memory {static int sel_open_policy (struct inode *inode,struct file *filp) { -struct selinux_fs_info *fsi = inode->i_sb->s_fs_info;struct policy_load_memory *plm =NULL ;int rc;
@@ -373,10 +371,6 @@ static int sel_open_policy(struct inode *inode, struct file *filp)if (rc) goto err; - rc = -EBUSY ; -if (fsi->policy_opened) - goto err; - rc = -ENOMEM ; plm =kzalloc_obj (*plm);if (!plm)
@@ -392,8 +386,6 @@ static int sel_open_policy(struct inode *inode, struct file *filp)inode_unlock (inode); } - fsi->policy_opened =1 ; - filp->private_data = plm;mutex_unlock (&selinux_state.policy_mutex);
@@ -410,13 +402,10 @@ static int sel_open_policy(struct inode *inode, struct file *filp)static int sel_release_policy (struct inode *inode,struct file *filp) { -struct selinux_fs_info *fsi = inode->i_sb->s_fs_info;struct policy_load_memory *plm = filp->private_data;BUG_ON (!plm); - fsi->policy_opened =0 ; -vfree (plm->data);kfree (plm);
Signature · 1 line
2.54.0