]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
Forbid user to change file flags on quota files
authorJan Kara <jack@suse.cz>
Thu, 15 Nov 2007 00:58:56 +0000 (16:58 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Thu, 15 Nov 2007 02:45:38 +0000 (18:45 -0800)
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 <jack@suse.cz>
Cc: LIOU Payphone <lioupayphone@gmail.com>
Cc: <linux-ext4@vger.kernel.org>
Acked-by: Dave Kleikamp <shaggy@austin.ibm.com>
Cc: <reiserfs-dev@namesys.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ext2/ioctl.c
fs/ext3/ioctl.c
fs/ext4/ioctl.c
fs/jfs/ioctl.c
fs/reiserfs/ioctl.c

index c2324d5fe4ac149a5672bad13134d4775c815100..320b2cb3d4d22eddf610d7a27d043eeef0437d5e 100644 (file)
@@ -47,6 +47,11 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
                        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;
 
                /*
index 4a2a02c95bf94b98fc4534d870f3546a45442c8e..023a070f55f18fac29cfddafa08557085ad6b2fa 100644 (file)
@@ -51,6 +51,11 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
                        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 */
index c04c7ccba9e3f140ed5243a6ccdcc58d6afcaa15..e7f894bdb4202359974088ba5c1f14585a43fc03 100644 (file)
@@ -51,6 +51,11 @@ int ext4_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
                        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 */
index 3c8663bea98ca3bf373f3ea83260b33d67548f3a..dfda12a073e1985fb28b798df2e9088a9a996be4 100644 (file)
@@ -79,6 +79,9 @@ int jfs_ioctl(struct inode * inode, struct file * filp, unsigned int cmd,
                if (!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;
 
index c438a8f83f26f7ad3412f5fd2f3af69e582ad02d..e0f0f098a523a8d1c3a41099ab76b411989a23a0 100644 (file)
@@ -57,6 +57,9 @@ int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
                        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))