android_kernel_samsung_a7y1.../fs/ext4
Dan Carpenter 6fef7d52e3 ext4: potential crash on allocation error in ext4_alloc_flex_bg_array()
commit 37b0b6b8b99c0e1c1f11abbe7cf49b6d03795b3f upstream.

If sbi->s_flex_groups_allocated is zero and the first allocation fails
then this code will crash.  The problem is that "i--" will set "i" to
-1 but when we compare "i >= sbi->s_flex_groups_allocated" then the -1
is type promoted to unsigned and becomes UINT_MAX.  Since UINT_MAX
is more than zero, the condition is true so we call kvfree(new_groups[-1]).
The loop will carry on freeing invalid memory until it crashes.

Fixes: 7c990728b99e ("ext4: fix potential race between s_flex_groups online resizing and access")
Reviewed-by: Suraj Jitindar Singh <surajjs@amazon.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable@kernel.org
Link: https://lore.kernel.org/r/20200228092142.7irbc44yaz3by7nb@kili.mountain
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-07 14:04:41 +02:00
..
sdp
acl.c
acl.h
balloc.c ext4: fix potential race between online resizing and write operations 2020-04-07 14:04:09 +02:00
bitmap.c
block_validity.c
crypto_fname.c
crypto_key.c
crypto_policy.c fscrypt: don't set policy for a dead directory 2020-04-06 19:29:02 +02:00
crypto.c
dir.c ext4: fix checksum errors with indexed dirs 2020-04-07 13:55:12 +02:00
ext4_crypto.h
ext4_extents.h
ext4_jbd2.c
ext4_jbd2.h
ext4.h ext4: fix potential race between s_group_info online resizing and access 2020-04-07 14:04:13 +02:00
extents_status.c
extents_status.h
extents.c
file.c
fscrypt_knox_private.h
fsync.c
hash.c
ialloc.c ext4: fix potential race between s_flex_groups online resizing and access 2020-04-07 14:04:11 +02:00
indirect.c
inline.c ext4: set error return correctly when ext4_htree_store_dirent fails 2020-04-07 13:42:46 +02:00
inode.c ext4: fix a data race in EXT4_I(inode)->i_disksize 2020-04-07 14:03:41 +02:00
ioctl.c ext4: actually request zeroing of inode table after grow 2020-04-06 18:12:36 +02:00
Kconfig
Makefile
mballoc.c ext4: fix potential race between s_group_info online resizing and access 2020-04-07 14:04:13 +02:00
mballoc.h
migrate.c
mmp.c
move_extent.c
namei.c ext4: add cond_resched() to __ext4_find_entry() 2020-04-07 14:03:43 +02:00
page-io.c
readpage.c
resize.c ext4: fix potential race between s_flex_groups online resizing and access 2020-04-07 14:04:11 +02:00
super.c ext4: potential crash on allocation error in ext4_alloc_flex_bg_array() 2020-04-07 14:04:41 +02:00
symlink.c
sysfs.c
truncate.h
xattr_security.c
xattr_trusted.c
xattr_user.c
xattr.c
xattr.h