1 From 5aa1437d2d9a068c0334bd7c9dafa8ec4f97f13b Mon Sep 17 00:00:00 2001
2 From: Al Viro <viro@zeniv.linux.org.uk>
3 Date: Thu, 17 May 2018 17:18:30 -0400
4 Subject: ext2: fix a block leak
6 From: Al Viro <viro@zeniv.linux.org.uk>
8 commit 5aa1437d2d9a068c0334bd7c9dafa8ec4f97f13b upstream.
10 open file, unlink it, then use ioctl(2) to make it immutable or
11 append only. Now close it and watch the blocks *not* freed...
13 Immutable/append-only checks belong in ->setattr().
14 Note: the bug is old and backport to anything prior to 737f2e93b972
15 ("ext2: convert to use the new truncate convention") will need
16 these checks lifted into ext2_setattr().
19 Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23 fs/ext2/inode.c | 10 ----------
24 1 file changed, 10 deletions(-)
28 @@ -1261,21 +1261,11 @@ do_indirects:
30 static void ext2_truncate_blocks(struct inode *inode, loff_t offset)
33 - * XXX: it seems like a bug here that we don't allow
34 - * IS_APPEND inode to have blocks-past-i_size trimmed off.
35 - * review and fix this.
37 - * Also would be nice to be able to handle IO errors and such,
38 - * but that's probably too much to ask.
40 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
41 S_ISLNK(inode->i_mode)))
43 if (ext2_inode_is_fast_symlink(inode))
45 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
48 dax_sem_down_write(EXT2_I(inode));
49 __ext2_truncate_blocks(inode, offset);