Skip to content

Commit 3e92c1e

Browse files
committed
Merge tag 'selinux-pr-20240402' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux
Pull selinux fix from Paul Moore: "A single patch for SELinux to fix a problem where we could potentially dereference an error pointer if we failed to successfully mount selinuxfs" * tag 'selinux-pr-20240402' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux: selinux: avoid dereference of garbage after mount failure
2 parents b1e6ec0 + 37801a3 commit 3e92c1e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

security/selinux/selinuxfs.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,7 +2123,6 @@ static struct file_system_type sel_fs_type = {
21232123
.kill_sb = sel_kill_sb,
21242124
};
21252125

2126-
static struct vfsmount *selinuxfs_mount __ro_after_init;
21272126
struct path selinux_null __ro_after_init;
21282127

21292128
static int __init init_sel_fs(void)
@@ -2145,18 +2144,21 @@ static int __init init_sel_fs(void)
21452144
return err;
21462145
}
21472146

2148-
selinux_null.mnt = selinuxfs_mount = kern_mount(&sel_fs_type);
2149-
if (IS_ERR(selinuxfs_mount)) {
2147+
selinux_null.mnt = kern_mount(&sel_fs_type);
2148+
if (IS_ERR(selinux_null.mnt)) {
21502149
pr_err("selinuxfs: could not mount!\n");
2151-
err = PTR_ERR(selinuxfs_mount);
2152-
selinuxfs_mount = NULL;
2150+
err = PTR_ERR(selinux_null.mnt);
2151+
selinux_null.mnt = NULL;
2152+
return err;
21532153
}
2154+
21542155
selinux_null.dentry = d_hash_and_lookup(selinux_null.mnt->mnt_root,
21552156
&null_name);
21562157
if (IS_ERR(selinux_null.dentry)) {
21572158
pr_err("selinuxfs: could not lookup null!\n");
21582159
err = PTR_ERR(selinux_null.dentry);
21592160
selinux_null.dentry = NULL;
2161+
return err;
21602162
}
21612163

21622164
return err;

0 commit comments

Comments
 (0)