Skip to content

Commit 8fc61d9

Browse files
Lukas Czernertytso
authored andcommitted
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 <[email protected]> Signed-off-by: "Theodore Ts'o" <[email protected]>
1 parent 9ef06ce commit 8fc61d9

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

fs/open.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,9 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
254254
return -EBADF;
255255

256256
/*
257-
* It's not possible to punch hole or perform collapse range
258-
* on append only file
257+
* We can only allow pure fallocate on append only files
259258
*/
260-
if (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE)
261-
&& IS_APPEND(inode))
259+
if ((mode & ~FALLOC_FL_KEEP_SIZE) && IS_APPEND(inode))
262260
return -EPERM;
263261

264262
if (IS_IMMUTABLE(inode))

0 commit comments

Comments
 (0)