Unionfs: check for immutable files before read-only branches 2.6.23-rc1-u2
authorErez_Zadok <ezk@cs.sunysb.edu>
Wed, 1 Aug 2007 14:29:42 +0000 (10:29 -0400)
committerErez_Zadok <ezk@cs.sunysb.edu>
Wed, 1 Aug 2007 15:39:11 +0000 (11:39 -0400)
Immutable files should never be allowed to be copied-up on write, even if
they're on read-only file systems or branches.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/unionfs/inode.c

index 53d373a13d854ec9129aeb33b27f8125f8a93cfe..c772fbd83407da497fd473477f61cfa5a14c8930 100644 (file)
@@ -984,6 +984,11 @@ static int inode_permission(struct super_block *sb, struct inode *inode, int mas
                    IS_RDONLY(inode) &&
                    (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
                        return -EROFS;
+               /*
+                * Nobody gets write access to an immutable file.
+                */
+               if (IS_IMMUTABLE(inode))
+                       return -EACCES;
                /*
                 * For all other branches than the first one, we ignore
                 * EROFS or if the branch is mounted as readonly, to let
@@ -993,11 +998,6 @@ static int inode_permission(struct super_block *sb, struct inode *inode, int mas
                    is_robranch_super(sb, bindex) &&
                    (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
                        return 0;
-               /*
-                * Nobody gets write access to an immutable file.
-                */
-               if (IS_IMMUTABLE(inode))
-                       return -EACCES;
        }
 
        /* Ordinary permission routines do not understand MAY_APPEND. */