summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--security/selinux/selinuxfs.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 292302eb60f3..0941ce79ea0b 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -247,11 +247,6 @@ static int sel_mmap_handle_status(struct file *filp,
/* only allows one page from the head */
if (vma->vm_pgoff > 0 || size != PAGE_SIZE)
return -EIO;
- /* disallow writable mapping */
- if (vma->vm_flags & VM_WRITE)
- return -EPERM;
- /* disallow mprotect() turns it into writable */
- vm_flags_clear(vma, VM_MAYWRITE);
return remap_pfn_range(vma, vma->vm_start,
page_to_pfn(status),
@@ -1818,6 +1813,17 @@ static struct dentry *sel_make_swapover_dir(struct super_block *sb, u64 *ino)
#define NULL_FILE_NAME "null"
+static void sel_mark_immutable(struct dentry *root, const char *name)
+{
+ struct qstr q = QSTR(name);
+ struct dentry *dentry = try_lookup_noperm(&q, root);
+
+ if (!IS_ERR_OR_NULL(dentry)) {
+ d_inode(dentry)->i_flags |= S_IMMUTABLE;
+ dput(dentry);
+ }
+}
+
static int sel_fill_super(struct super_block *sb, struct fs_context *fc)
{
struct selinux_fs_info *fsi;
@@ -1857,6 +1863,9 @@ static int sel_fill_super(struct super_block *sb, struct fs_context *fc)
if (ret)
goto err;
+ sel_mark_immutable(sb->s_root, "status");
+ sel_mark_immutable(sb->s_root, "policy");
+
fsi = sb->s_fs_info;
fsi->bool_dir = sel_make_dir(sb->s_root, BOOL_DIR_NAME, &fsi->last_ino);
if (IS_ERR(fsi->bool_dir)) {