android_kernel_motorola_sm6375/fs/ext4
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Artem Sadovnikov b96bd2c3db ext4: fix off-by-one error in do_split
commit 94824ac9a8aaf2fb3c54b4bdde842db80ffa555d upstream.

Syzkaller detected a use-after-free issue in ext4_insert_dentry that was
caused by out-of-bounds access due to incorrect splitting in do_split.

BUG: KASAN: use-after-free in ext4_insert_dentry+0x36a/0x6d0 fs/ext4/namei.c:2109
Write of size 251 at addr ffff888074572f14 by task syz-executor335/5847

CPU: 0 UID: 0 PID: 5847 Comm: syz-executor335 Not tainted 6.12.0-rc6-syzkaller-00318-ga9cda7c0ffed #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/30/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report+0x143/0x180 mm/kasan/report.c:601
 kasan_check_range+0x282/0x290 mm/kasan/generic.c:189
 __asan_memcpy+0x40/0x70 mm/kasan/shadow.c:106
 ext4_insert_dentry+0x36a/0x6d0 fs/ext4/namei.c:2109
 add_dirent_to_buf+0x3d9/0x750 fs/ext4/namei.c:2154
 make_indexed_dir+0xf98/0x1600 fs/ext4/namei.c:2351
 ext4_add_entry+0x222a/0x25d0 fs/ext4/namei.c:2455
 ext4_add_nondir+0x8d/0x290 fs/ext4/namei.c:2796
 ext4_symlink+0x920/0xb50 fs/ext4/namei.c:3431
 vfs_symlink+0x137/0x2e0 fs/namei.c:4615
 do_symlinkat+0x222/0x3a0 fs/namei.c:4641
 __do_sys_symlink fs/namei.c:4662 [inline]
 __se_sys_symlink fs/namei.c:4660 [inline]
 __x64_sys_symlink+0x7a/0x90 fs/namei.c:4660
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
 </TASK>

The following loop is located right above 'if' statement.

for (i = count-1; i >= 0; i--) {
	/* is more than half of this entry in 2nd half of the block? */
	if (size + map[i].size/2 > blocksize/2)
		break;
	size += map[i].size;
	move++;
}

'i' in this case could go down to -1, in which case sum of active entries
wouldn't exceed half the block size, but previous behaviour would also do
split in half if sum would exceed at the very last block, which in case of
having too many long name files in a single block could lead to
out-of-bounds access and following use-after-free.

Found by Linux Verification Center (linuxtesting.org) with Syzkaller.

Cc: stable@vger.kernel.org
Fixes: 5872331b3d91 ("ext4: fix potential negative array index in do_split()")
Signed-off-by: Artem Sadovnikov <a.sadovnikov@ispras.ru>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20250404082804.2567-3-a.sadovnikov@ispras.ru
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-05-02 07:39:15 +02:00
..
acl.c
acl.h ext4: apply umask if ACL support is disabled 2023-11-28 16:50:21 +00:00
balloc.c ext4: fix WARNING in mb_find_extent 2023-05-17 11:36:02 +02:00
bitmap.c
block_validity.c
dir.c
ext4.h ext4: avoid ext4_error()'s caused by ENOMEM in the truncate path 2025-02-01 18:18:53 +01:00
ext4_extents.h
ext4_jbd2.c
ext4_jbd2.h
extents.c ext4: fix slab-use-after-free in ext4_split_extent_at() 2025-02-01 18:18:53 +01:00
extents_status.c ext4: make sure allocate pending entry not fail 2023-12-08 08:44:24 +01:00
extents_status.h
file.c
fsmap.c ext4: fix FS_IOC_GETFSMAP handling 2024-12-14 19:44:35 +01:00
fsmap.h
fsync.c
hash.c
ialloc.c ext4: avoid negative min_clusters in find_group_orlov() 2024-11-08 16:20:30 +01:00
indirect.c ext4: only update i_reserved_data_blocks on successful block allocation 2023-07-27 08:37:35 +02:00
inline.c ext4: avoid OOB when system.data xattr changes underneath the filesystem 2024-11-08 16:20:30 +01:00
inode.c ext4: don't treat fhandle lookup of ea_inode as FS corruption 2025-05-02 07:39:13 +02:00
ioctl.c ext4: fix to check return value of freeze_bdev() in ext4_shutdown() 2023-08-11 11:53:47 +02:00
Kconfig
Makefile
mballoc.c ext4: fix FS_IOC_GETFSMAP handling 2024-12-14 19:44:35 +01:00
mballoc.h ext4: fix FS_IOC_GETFSMAP handling 2024-12-14 19:44:35 +01:00
migrate.c ext4: fix i_data_sem unlock order in ext4_ind_migrate() 2024-11-08 16:20:39 +01:00
mmp.c
move_extent.c ext4: fix double-free of blocks due to wrong extents moved_len 2024-02-23 08:25:11 +01:00
namei.c ext4: fix off-by-one error in do_split 2025-05-02 07:39:15 +02:00
page-io.c
readpage.c
resize.c ext4: fix corruption during on-line resize 2024-04-13 12:51:26 +02:00
super.c ext4: protect ext4_release_dquot against freezing 2025-05-02 07:39:11 +02:00
symlink.c
sysfs.c
truncate.h
verity.c
xattr.c ext4: ignore xattrs past end 2025-05-02 07:39:11 +02:00
xattr.h ext4: remove duplicate definition of ext4_xattr_ibody_inline_set() 2023-04-26 11:24:05 +02:00
xattr_security.c
xattr_trusted.c
xattr_user.c