提交 c703d7d5 编写于 作者: T Tianyue Ren 提交者: Yang Yingliang

selinux: fix error initialization in inode_doinit_with_dentry()

stable inclusion
from linux-4.19.164
commit bd7223dda090c9246b290a0b901c112d6484466a

--------------------------------

[ Upstream commit 83370b31 ]

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: 9287aed2 ("selinux: Convert isec->lock into a spinlock")
Signed-off-by: NTianyue Ren <rentianyue@kylinos.cn>
[PM: minor comment tweaks]
Signed-off-by: NPaul Moore <paul@paul-moore.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 a9b39560
......@@ -1618,7 +1618,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;
......@@ -1733,8 +1739,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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册