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>
12 v2: Change the condition to be future proof as suggested by hch
15 1 file changed, 2 insertions(+), 4 deletions(-)
17 diff --git a/fs/open.c b/fs/open.c
18 index 631aea81..fe48b2f 100644
21 @@ -254,11 +254,9 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
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
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))
34 if (IS_IMMUTABLE(inode))
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