ext4: fix potential integer overflow in alloc_flex_gd()
ext4: fix potential integer overflow in alloc_flex_gd()

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.

Reviewed-by: Eric Sandeen <d55521028c14e0f378be5444e4ea388161c0d7e7@redhat.com>
Signed-off-by: Haogang Chen <a43c3c780b4ed6eb73b773e57587039c18c08a28@gmail.com>
Signed-off-by: "Theodore Ts'o" <4ed386e0495d3e109932df055831d9ec2f824927@mit.edu>
Cc: 4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@kernel.org

KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs,KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas