add patch fix-block_validity-documentation
[ext4-patch-queue.git] / fix-stack-corruption-with-64k-blocksize
blob961db43e249fe5905a6673df1ba8c4aac1d995f6
1 ext4: fix stack memory corruption with 64k block size
3 From: Chandan Rajendra <chandan@linux.vnet.ibm.com>
5 The number of 'counters' elements needed in 'struct sg' is
6 super_block->s_blocksize_bits + 2. Presently we have 16 'counters'
7 elements in the array. This is insufficient for block sizes >= 32k. In
8 such cases the memcpy operation performed in ext4_mb_seq_groups_show()
9 would cause stack memory corruption.
11 Fixes: c9de560ded61f
12 Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
13 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
14 Reviewed-by: Jan Kara <jack@suse.cz>
15 Cc: stable@vger.kernel.org
16 ---
17 Changelog: 
18 v1->v2: Use EXT4_MAX_BLOCK_LOG_SIZE instead of the integer constant 16.
20  fs/ext4/mballoc.c | 2 +-
21  1 file changed, 1 insertion(+), 1 deletion(-)
23 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
24 index a937ac7..7ae43c5 100644
25 --- a/fs/ext4/mballoc.c
26 +++ b/fs/ext4/mballoc.c
27 @@ -2287,7 +2287,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
28         struct ext4_group_info *grinfo;
29         struct sg {
30                 struct ext4_group_info info;
31 -               ext4_grpblk_t counters[16];
32 +               ext4_grpblk_t counters[EXT4_MAX_BLOCK_LOG_SIZE + 2];
33         } sg;
35         group--;
36 -- 
37 2.5.5