Forbid user to change file flags on quota files
Subsystems (3)
PATCH 22/120 Forbid user to change file flags on quota files
From: Jan Kara <[email protected]>
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 Jan Kara <[email protected]>
Cc LIOU Payphone <[email protected]>
Cc <[email protected]>
Acked-by Dave Kleikamp <[email protected]>
Cc <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
fs/ext2/ioctl.c | 5 +++++ fs/ext3/ioctl.c | 5 +++++ fs/ext4/ioctl.c | 5 +++++ fs/jfs/ioctl.c | 3 +++ fs/reiserfs/ioctl.c | 3 +++ 5 files changed, 21 insertions(+)
fs/ext2/ioctl.c renamed from fs/ext2/ioctl.c~forbid-user-to-change-file-flags-on-quota-files +5 -0
@@ -47,6 +47,11 @@ int ext2_ioctl (struct inode * inode, st flags &= ~EXT2_DIRSYNC_FL ;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;/*
fs/ext3/ioctl.c renamed from fs/ext3/ioctl.c~forbid-user-to-change-file-flags-on-quota-files +5 -0
@@ -51,6 +51,11 @@ int ext3_ioctl (struct inode * inode, st flags &= ~EXT3_DIRSYNC_FL ;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;/* The JOURNAL_DATA flag is modifiable only by root */
fs/ext4/ioctl.c renamed from fs/ext4/ioctl.c~forbid-user-to-change-file-flags-on-quota-files +5 -0
@@ -51,6 +51,11 @@ int ext4_ioctl (struct inode * inode, st flags &= ~EXT4_DIRSYNC_FL ;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;/* The JOURNAL_DATA flag is modifiable only by root */
fs/jfs/ioctl.c renamed from fs/jfs/ioctl.c~forbid-user-to-change-file-flags-on-quota-files +3 -0
@@ -79,6 +79,9 @@ int jfs_ioctl(struct inode * inode, struif (!S_ISDIR (inode->i_mode)) 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); oldflags = jfs_inode->mode2;
fs/reiserfs/ioctl.c renamed from fs/reiserfs/ioctl.c~forbid-user-to-change-file-flags-on-quota-files +3 -0
@@ -57,6 +57,9 @@ int reiserfs_ioctl(struct inode *inode,if (get_user (flags, (int __user *)arg))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)-> i_attrs) & (REISERFS_IMMUTABLE_FL | REISERFS_APPEND_FL))
_