linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] FS: ext4: fix integer overflow in alloc_flex_gd()
@ 2012-02-20 22:41 Haogang Chen
  2012-02-20 23:47 ` Eric Sandeen
  2012-05-28 18:24 ` Ted Ts'o
  0 siblings, 2 replies; 6+ messages in thread
From: Haogang Chen @ 2012-02-20 22:41 UTC (permalink / raw)
  To: Theodore Tso, Andreas Dilger, linux-ext4; +Cc: linux-kernel, haogangchen

In alloc_flex_gd(), when flexbg_size is large, kmalloc size would
overflow and flex_gd->groups would point to a buffer smaller than
expected, causing OOB accesses when it is used.

Note that in ext4_resize_fs(), flexbg_size is calculated using
sbi->s_log_groups_per_flex, which is read from the disk and only bounded
to [1, 31]. The patch returns NULL for too large flexbg_size.

Signed-off-by: Haogang Chen <haogangchen@gmail.com>
---
 fs/ext4/resize.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index f9d948f..8601f4b 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -161,6 +161,8 @@ static struct ext4_new_flex_group_data *alloc_flex_gd(unsigned long flexbg_size)
 	if (flex_gd == NULL)
 		goto out3;
 
+	if (flexbg_size >= UINT_MAX / sizeof(struct ext4_new_flex_group_data))
+		goto out2;
 	flex_gd->count = flexbg_size;
 
 	flex_gd->groups = kmalloc(sizeof(struct ext4_new_group_data) *
-- 
1.7.5.4


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

end of thread, other threads:[~2012-05-28 18:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-20 22:41 [PATCH] FS: ext4: fix integer overflow in alloc_flex_gd() Haogang Chen
2012-02-20 23:47 ` Eric Sandeen
2012-02-21 13:55   ` Xi Wang
2012-02-21 16:36     ` Eric Sandeen
2012-02-21 17:19       ` Andreas Dilger
2012-05-28 18:24 ` Ted Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).