]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.45/ext4-make-sanity-check-in-mballoc-more-strict.patch
Linux 4.19.45
[thirdparty/kernel/stable-queue.git] / releases / 4.19.45 / ext4-make-sanity-check-in-mballoc-more-strict.patch
CommitLineData
d074880a
GKH
1From 31562b954b60f02acb91b7349dc6432d3f8c3c5f Mon Sep 17 00:00:00 2001
2From: Jan Kara <jack@suse.cz>
3Date: Sat, 6 Apr 2019 18:33:06 -0400
4Subject: ext4: make sanity check in mballoc more strict
5
6From: Jan Kara <jack@suse.cz>
7
8commit 31562b954b60f02acb91b7349dc6432d3f8c3c5f upstream.
9
10The sanity check in mb_find_extent() only checked that returned extent
11does not extend past blocksize * 8, however it should not extend past
12EXT4_CLUSTERS_PER_GROUP(sb). This can happen when clusters_per_group <
13blocksize * 8 and the tail of the bitmap is not properly filled by 1s
14which happened e.g. when ancient kernels have grown the filesystem.
15
16Signed-off-by: Jan Kara <jack@suse.cz>
17Signed-off-by: Theodore Ts'o <tytso@mit.edu>
18Cc: stable@kernel.org
19Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20
21---
22 fs/ext4/mballoc.c | 2 +-
23 1 file changed, 1 insertion(+), 1 deletion(-)
24
25--- a/fs/ext4/mballoc.c
26+++ b/fs/ext4/mballoc.c
27@@ -1539,7 +1539,7 @@ static int mb_find_extent(struct ext4_bu
28 ex->fe_len += 1 << order;
29 }
30
31- if (ex->fe_start + ex->fe_len > (1 << (e4b->bd_blkbits + 3))) {
32+ if (ex->fe_start + ex->fe_len > EXT4_CLUSTERS_PER_GROUP(e4b->bd_sb)) {
33 /* Should never happen! (but apparently sometimes does?!?) */
34 WARN_ON(1);
35 ext4_error(e4b->bd_sb, "corruption or bug in mb_find_extent "