]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.44/ext2-fix-a-block-leak.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.44 / ext2-fix-a-block-leak.patch
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
5
6 From: Al Viro <viro@zeniv.linux.org.uk>
7
8 commit 5aa1437d2d9a068c0334bd7c9dafa8ec4f97f13b upstream.
9
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...
12
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().
17
18 Cc: stable@kernel.org
19 Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21
22 ---
23 fs/ext2/inode.c | 10 ----------
24 1 file changed, 10 deletions(-)
25
26 --- a/fs/ext2/inode.c
27 +++ b/fs/ext2/inode.c
28 @@ -1261,21 +1261,11 @@ do_indirects:
29
30 static void ext2_truncate_blocks(struct inode *inode, loff_t offset)
31 {
32 - /*
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.
36 - *
37 - * Also would be nice to be able to handle IO errors and such,
38 - * but that's probably too much to ask.
39 - */
40 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
41 S_ISLNK(inode->i_mode)))
42 return;
43 if (ext2_inode_is_fast_symlink(inode))
44 return;
45 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
46 - return;
47
48 dax_sem_down_write(EXT2_I(inode));
49 __ext2_truncate_blocks(inode, offset);