mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-30 23:54:04 +08:00
selinux: avoid dereference of garbage after mount failure
commit37801a36b4
upstream. In case kern_mount() fails and returns an error pointer return in the error branch instead of continuing and dereferencing the error pointer. While on it drop the never read static variable selinuxfs_mount. Cc: stable@vger.kernel.org Fixes:0619f0f5e3
("selinux: wrap selinuxfs state") Signed-off-by: Christian Göttsche <cgzones@googlemail.com> Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
9e2af26c29
commit
477ed6789e
@ -2135,7 +2135,6 @@ static struct file_system_type sel_fs_type = {
|
|||||||
.kill_sb = sel_kill_sb,
|
.kill_sb = sel_kill_sb,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct vfsmount *selinuxfs_mount __ro_after_init;
|
|
||||||
struct path selinux_null __ro_after_init;
|
struct path selinux_null __ro_after_init;
|
||||||
|
|
||||||
static int __init init_sel_fs(void)
|
static int __init init_sel_fs(void)
|
||||||
@ -2157,18 +2156,21 @@ static int __init init_sel_fs(void)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
selinux_null.mnt = selinuxfs_mount = kern_mount(&sel_fs_type);
|
selinux_null.mnt = kern_mount(&sel_fs_type);
|
||||||
if (IS_ERR(selinuxfs_mount)) {
|
if (IS_ERR(selinux_null.mnt)) {
|
||||||
pr_err("selinuxfs: could not mount!\n");
|
pr_err("selinuxfs: could not mount!\n");
|
||||||
err = PTR_ERR(selinuxfs_mount);
|
err = PTR_ERR(selinux_null.mnt);
|
||||||
selinuxfs_mount = NULL;
|
selinux_null.mnt = NULL;
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
selinux_null.dentry = d_hash_and_lookup(selinux_null.mnt->mnt_root,
|
selinux_null.dentry = d_hash_and_lookup(selinux_null.mnt->mnt_root,
|
||||||
&null_name);
|
&null_name);
|
||||||
if (IS_ERR(selinux_null.dentry)) {
|
if (IS_ERR(selinux_null.dentry)) {
|
||||||
pr_err("selinuxfs: could not lookup null!\n");
|
pr_err("selinuxfs: could not lookup null!\n");
|
||||||
err = PTR_ERR(selinux_null.dentry);
|
err = PTR_ERR(selinux_null.dentry);
|
||||||
selinux_null.dentry = NULL;
|
selinux_null.dentry = NULL;
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
Loading…
Reference in New Issue
Block a user