提交 e47776a0 编写于 作者: J Jan Kara 提交者: Linus Torvalds

Forbid user to change file flags on quota files

Forbid user from changing file flags on quota files.  User has no bussiness
in playing with these flags when quota is on.  Furthermore there is a
remote possibility of deadlock due to a lock inversion between quota file's
i_mutex and transaction's start (i_mutex for quota file is locked only when
trasaction is started in quota operations) in ext3 and ext4.
Signed-off-by: NJan Kara <jack@suse.cz>
Cc: LIOU Payphone <lioupayphone@gmail.com>
Cc: <linux-ext4@vger.kernel.org>
Acked-by: NDave Kleikamp <shaggy@austin.ibm.com>
Cc: <reiserfs-dev@namesys.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 28822f22
...@@ -47,6 +47,11 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, ...@@ -47,6 +47,11 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
flags &= ~EXT2_DIRSYNC_FL; flags &= ~EXT2_DIRSYNC_FL;
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
/* Is it quota file? Do not allow user to mess with it */
if (IS_NOQUOTA(inode)) {
mutex_unlock(&inode->i_mutex);
return -EPERM;
}
oldflags = ei->i_flags; oldflags = ei->i_flags;
/* /*
......
...@@ -51,6 +51,11 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, ...@@ -51,6 +51,11 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
flags &= ~EXT3_DIRSYNC_FL; flags &= ~EXT3_DIRSYNC_FL;
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
/* Is it quota file? Do not allow user to mess with it */
if (IS_NOQUOTA(inode)) {
mutex_unlock(&inode->i_mutex);
return -EPERM;
}
oldflags = ei->i_flags; oldflags = ei->i_flags;
/* The JOURNAL_DATA flag is modifiable only by root */ /* The JOURNAL_DATA flag is modifiable only by root */
......
...@@ -51,6 +51,11 @@ int ext4_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, ...@@ -51,6 +51,11 @@ int ext4_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
flags &= ~EXT4_DIRSYNC_FL; flags &= ~EXT4_DIRSYNC_FL;
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
/* Is it quota file? Do not allow user to mess with it */
if (IS_NOQUOTA(inode)) {
mutex_unlock(&inode->i_mutex);
return -EPERM;
}
oldflags = ei->i_flags; oldflags = ei->i_flags;
/* The JOURNAL_DATA flag is modifiable only by root */ /* The JOURNAL_DATA flag is modifiable only by root */
......
...@@ -79,6 +79,9 @@ int jfs_ioctl(struct inode * inode, struct file * filp, unsigned int cmd, ...@@ -79,6 +79,9 @@ int jfs_ioctl(struct inode * inode, struct file * filp, unsigned int cmd,
if (!S_ISDIR(inode->i_mode)) if (!S_ISDIR(inode->i_mode))
flags &= ~JFS_DIRSYNC_FL; flags &= ~JFS_DIRSYNC_FL;
/* Is it quota file? Do not allow user to mess with it */
if (IS_NOQUOTA(inode))
return -EPERM;
jfs_get_inode_flags(jfs_inode); jfs_get_inode_flags(jfs_inode);
oldflags = jfs_inode->mode2; oldflags = jfs_inode->mode2;
......
...@@ -57,6 +57,9 @@ int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -57,6 +57,9 @@ int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
if (get_user(flags, (int __user *)arg)) if (get_user(flags, (int __user *)arg))
return -EFAULT; return -EFAULT;
/* Is it quota file? Do not allow user to mess with it. */
if (IS_NOQUOTA(inode))
return -EPERM;
if (((flags ^ REISERFS_I(inode)-> if (((flags ^ REISERFS_I(inode)->
i_attrs) & (REISERFS_IMMUTABLE_FL | i_attrs) & (REISERFS_IMMUTABLE_FL |
REISERFS_APPEND_FL)) REISERFS_APPEND_FL))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册