add patch use-EXT_MAX_BLOCKS-in-ext4_es_can_be_merged
[ext4-patch-queue.git] / prevent-doing-ZERO-RANGE-on-append-only-file
blob2f549b23465330868503ebbf65afd31b69e6af51
1 fs: prevent doing FALLOC_FL_ZERO_RANGE on append only file
3 From: Lukas Czerner <lczerner@redhat.com>
5 Currently punch hole and collapse range fallocate operation are not
6 allowed on append only file. This should be case for zero range as well.
7 Fix it by allowing only pure fallocate (possibly with keep size set).
9 Signed-off-by: Lukas Czerner <lczerner@redhat.com>
10 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
11 ---
12 v2: Change the condition to be future proof as suggested by hch
14  fs/open.c | 6 ++----
15  1 file changed, 2 insertions(+), 4 deletions(-)
17 diff --git a/fs/open.c b/fs/open.c
18 index 631aea81..fe48b2f 100644
19 --- a/fs/open.c
20 +++ b/fs/open.c
21 @@ -254,11 +254,9 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
22                 return -EBADF;
24         /*
25 -        * It's not possible to punch hole or perform collapse range
26 -        * on append only file
27 +        * We can only allow pure fallocate on append only files
28          */
29 -       if (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE)
30 -           && IS_APPEND(inode))
31 +       if ((mode & ~FALLOC_FL_KEEP_SIZE) && IS_APPEND(inode))
32                 return -EPERM;
34         if (IS_IMMUTABLE(inode))
35 -- 
36 1.8.3.1
39 To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
40 the body of a message to majordomo@vger.kernel.org
41 More majordomo info at  http://vger.kernel.org/majordomo-info.html