summaryrefslogtreecommitdiffstats
path: root/fs/inode.c
diff options
context:
space:
mode:
authorAlexander Lochmann <alexander.lochmann@tu-dortmund.de>2018-12-14 05:55:52 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2019-04-28 21:46:57 -0400
commitf69e749a49353d96af1a293f56b5b56de59c668a (patch)
treeccf6a64b148cfc4102dade591f0139a597bbbb34 /fs/inode.c
parentee948837d7fa89127373c139766aacf6b02a9225 (diff)
Abort file_remove_privs() for non-reg. files
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: Jan Kara <jack@suse.cz> Signed-off-by: Alexander Lochmann <alexander.lochmann@tu-dortmund.de> Signed-off-by: Horst Schirmeier <horst.schirmeier@tu-dortmund.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/inode.c')
-rw-r--r--fs/inode.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/inode.c b/fs/inode.c
index e9d97add2b36..9a453f3637f8 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1817,8 +1817,13 @@ int file_remove_privs(struct file *file)
1817 int kill; 1817 int kill;
1818 int error = 0; 1818 int error = 0;
1819 1819
1820 /* Fast path for nothing security related */ 1820 /*
1821 if (IS_NOSEC(inode)) 1821 * Fast path for nothing security related.
1822 * As well for non-regular files, e.g. blkdev inodes.
1823 * For example, blkdev_write_iter() might get here
1824 * trying to remove privs which it is not allowed to.
1825 */
1826 if (IS_NOSEC(inode) || !S_ISREG(inode->i_mode))
1822 return 0; 1827 return 0;
1823 1828
1824 kill = dentry_needs_remove_privs(dentry); 1829 kill = dentry_needs_remove_privs(dentry);