提交 20137ff2 编写于 作者: A Alexander Lochmann 提交者: Xie XiuQi

Abort file_remove_privs() for non-reg. files

commit f69e749a upstream.

file_remove_privs() might be called for non-regular files, e.g.
blkdev inode. There is no reason to do its job on things
like blkdev inodes, pipes, or cdevs. Hence, abort if
file does not refer to a regular inode.

AV: more to the point, for devices there might be any number of
inodes refering to given device.  Which one to strip the permissions
from, even if that made any sense in the first place?  All of them
will be observed with contents modified, after all.

Found by LockDoc (Alexander Lochmann, Horst Schirmeier and Olaf
Spinczyk)
Reviewed-by: NJan Kara <jack@suse.cz>
Signed-off-by: NAlexander Lochmann <alexander.lochmann@tu-dortmund.de>
Signed-off-by: NHorst Schirmeier <horst.schirmeier@tu-dortmund.de>
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
Cc: Zubin Mithra <zsm@chromium.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 b22a445a
...@@ -1817,8 +1817,13 @@ int file_remove_privs(struct file *file) ...@@ -1817,8 +1817,13 @@ int file_remove_privs(struct file *file)
int kill; int kill;
int error = 0; int error = 0;
/* Fast path for nothing security related */ /*
if (IS_NOSEC(inode)) * Fast path for nothing security related.
* As well for non-regular files, e.g. blkdev inodes.
* For example, blkdev_write_iter() might get here
* trying to remove privs which it is not allowed to.
*/
if (IS_NOSEC(inode) || !S_ISREG(inode->i_mode))
return 0; return 0;
kill = dentry_needs_remove_privs(dentry); kill = dentry_needs_remove_privs(dentry);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册