All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] ext4: ext4_mb_seq_groups_show: Fix stack memory corruption
@ 2016-11-10  5:46 Chandan Rajendra
  2016-11-10 17:13 ` Jan Kara
  0 siblings, 1 reply; 3+ messages in thread
From: Chandan Rajendra @ 2016-11-10  5:46 UTC (permalink / raw)
  To: linux-ext4; +Cc: Chandan Rajendra, tytso, jack, adilger

The number of 'counters' elements needed in 'struct sg' is
super_block->s_blocksize_bits + 2. Presently we have 16 'counters'
elements in the array. This is insufficient for block sizes >= 32k. In
such cases the memcpy operation performed in ext4_mb_seq_groups_show()
would cause stack memory corruption.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
---
Changelog: 
v1->v2: Use EXT4_MAX_BLOCK_LOG_SIZE instead of the integer constant 16.

 fs/ext4/mballoc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index a937ac7..7ae43c5 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2287,7 +2287,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
 	struct ext4_group_info *grinfo;
 	struct sg {
 		struct ext4_group_info info;
-		ext4_grpblk_t counters[16];
+		ext4_grpblk_t counters[EXT4_MAX_BLOCK_LOG_SIZE + 2];
 	} sg;
 
 	group--;
-- 
2.5.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] ext4: ext4_mb_seq_groups_show: Fix stack memory corruption
  2016-11-10  5:46 [PATCH V2] ext4: ext4_mb_seq_groups_show: Fix stack memory corruption Chandan Rajendra
@ 2016-11-10 17:13 ` Jan Kara
  2016-11-15  2:35   ` Theodore Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2016-11-10 17:13 UTC (permalink / raw)
  To: Chandan Rajendra; +Cc: linux-ext4, tytso, jack, adilger

On Thu 10-11-16 11:16:04, Chandan Rajendra wrote:
> The number of 'counters' elements needed in 'struct sg' is
> super_block->s_blocksize_bits + 2. Presently we have 16 'counters'
> elements in the array. This is insufficient for block sizes >= 32k. In
> such cases the memcpy operation performed in ext4_mb_seq_groups_show()
> would cause stack memory corruption.
> 
> Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>

Looks good. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
> Changelog: 
> v1->v2: Use EXT4_MAX_BLOCK_LOG_SIZE instead of the integer constant 16.
> 
>  fs/ext4/mballoc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index a937ac7..7ae43c5 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -2287,7 +2287,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
>  	struct ext4_group_info *grinfo;
>  	struct sg {
>  		struct ext4_group_info info;
> -		ext4_grpblk_t counters[16];
> +		ext4_grpblk_t counters[EXT4_MAX_BLOCK_LOG_SIZE + 2];
>  	} sg;
>  
>  	group--;
> -- 
> 2.5.5
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] ext4: ext4_mb_seq_groups_show: Fix stack memory corruption
  2016-11-10 17:13 ` Jan Kara
@ 2016-11-15  2:35   ` Theodore Ts'o
  0 siblings, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2016-11-15  2:35 UTC (permalink / raw)
  To: Jan Kara; +Cc: Chandan Rajendra, linux-ext4, adilger

On Thu, Nov 10, 2016 at 06:13:46PM +0100, Jan Kara wrote:
> On Thu 10-11-16 11:16:04, Chandan Rajendra wrote:
> > The number of 'counters' elements needed in 'struct sg' is
> > super_block->s_blocksize_bits + 2. Presently we have 16 'counters'
> > elements in the array. This is insufficient for block sizes >= 32k. In
> > such cases the memcpy operation performed in ext4_mb_seq_groups_show()
> > would cause stack memory corruption.
> > 
> > Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
> 
> Looks good. You can add:
> 
> Reviewed-by: Jan Kara <jack@suse.cz>

Applied, thanks!

					- Ted

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-15  2:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-10  5:46 [PATCH V2] ext4: ext4_mb_seq_groups_show: Fix stack memory corruption Chandan Rajendra
2016-11-10 17:13 ` Jan Kara
2016-11-15  2:35   ` Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.