mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09:00
selinux: fix error initialization in inode_doinit_with_dentry()
commit83370b31a9upstream. Mark the inode security label as invalid if we cannot find a dentry so that we will retry later rather than marking it initialized with the unlabeled SID. Fixes:9287aed2ad("selinux: Convert isec->lock into a spinlock") Signed-off-by: Tianyue Ren <rentianyue@kylinos.cn> [PM: minor comment tweaks] Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Alexander Grund <theflamefire89@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
@@ -1453,7 +1453,13 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
|
||||
* inode_doinit with a dentry, before these inodes could
|
||||
* be used again by userspace.
|
||||
*/
|
||||
goto out;
|
||||
isec->initialized = LABEL_INVALID;
|
||||
/*
|
||||
* There is nothing useful to jump to the "out"
|
||||
* label, except a needless spin lock/unlock
|
||||
* cycle.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = INITCONTEXTLEN;
|
||||
@@ -1561,8 +1567,15 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
|
||||
* inode_doinit() with a dentry, before these inodes
|
||||
* could be used again by userspace.
|
||||
*/
|
||||
if (!dentry)
|
||||
goto out;
|
||||
if (!dentry) {
|
||||
isec->initialized = LABEL_INVALID;
|
||||
/*
|
||||
* There is nothing useful to jump to the "out"
|
||||
* label, except a needless spin lock/unlock
|
||||
* cycle.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
rc = selinux_genfs_get_sid(dentry, sclass,
|
||||
sbsec->flags, &sid);
|
||||
dput(dentry);
|
||||
|
||||
Reference in New Issue
Block a user