summaryrefslogtreecommitdiffstats
path: root/fs/open.c
diff options
context:
space:
mode:
authorLukas Czerner <lczerner@redhat.com>2014-04-12 09:51:34 -0400
committerTheodore Ts'o <tytso@mit.edu>2014-04-12 09:51:34 -0400
commit8fc61d92630d1c96057a94c61e1643475045b25b (patch)
tree92a35f28bac2ae3893db6fc7be39e461eabfd588 /fs/open.c
parent9ef06cec7c96f6bf59f1dd8b64b9645820099051 (diff)
fs: prevent doing FALLOC_FL_ZERO_RANGE on append only file
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>
Diffstat (limited to 'fs/open.c')
-rw-r--r--fs/open.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/fs/open.c b/fs/open.c
index 631aea815def..3a83253d3373 100644
--- 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)
254 return -EBADF; 254 return -EBADF;
255 255
256 /* 256 /*
257 * It's not possible to punch hole or perform collapse range 257 * We can only allow pure fallocate on append only files
258 * on append only file
259 */ 258 */
260 if (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE) 259 if ((mode & ~FALLOC_FL_KEEP_SIZE) && IS_APPEND(inode))
261 && IS_APPEND(inode))
262 return -EPERM; 260 return -EPERM;
263 261
264 if (IS_IMMUTABLE(inode)) 262 if (IS_IMMUTABLE(inode))