]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
fs: prevent doing FALLOC_FL_ZERO_RANGE on append only file
authorLukas Czerner <lczerner@redhat.com>
Sat, 12 Apr 2014 13:51:34 +0000 (09:51 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 12 Apr 2014 13:51:34 +0000 (09:51 -0400)
Currently punch hole and collapse range fallocate operation are not
allowed on append only file. This should be case for zero range as well.
Fix it by allowing only pure fallocate (possibly with keep size set).

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/open.c

index 631aea815def32946433b8aebed9a312d0fc872c..3a83253d33731e65436ea5965f1645c658789aac 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -254,11 +254,9 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
                return -EBADF;
 
        /*
-        * It's not possible to punch hole or perform collapse range
-        * on append only file
+        * We can only allow pure fallocate on append only files
         */
-       if (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE)
-           && IS_APPEND(inode))
+       if ((mode & ~FALLOC_FL_KEEP_SIZE) && IS_APPEND(inode))
                return -EPERM;
 
        if (IS_IMMUTABLE(inode))