linux-stable/fs/ntfs
Hawkins Jiawei 86f36de14d ntfs: check overflow when iterating ATTR_RECORDs
commit 63095f4f3a upstream.

Kernel iterates over ATTR_RECORDs in mft record in ntfs_attr_find().
Because the ATTR_RECORDs are next to each other, kernel can get the next
ATTR_RECORD from end address of current ATTR_RECORD, through current
ATTR_RECORD length field.

The problem is that during iteration, when kernel calculates the end
address of current ATTR_RECORD, kernel may trigger an integer overflow bug
in executing `a = (ATTR_RECORD*)((u8*)a + le32_to_cpu(a->length))`.  This
may wrap, leading to a forever iteration on 32bit systems.

This patch solves it by adding some checks on calculating end address
of current ATTR_RECORD during iteration.

Link: https://lkml.kernel.org/r/20220831160935.3409-4-yin31149@gmail.com
Link: https://lore.kernel.org/all/20220827105842.GM2030@kadam/
Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Anton Altaparmakov <anton@tuxera.com>
Cc: chenxiaosong (A) <chenxiaosong2@huawei.com>
Cc: syzkaller-bugs <syzkaller-bugs@googlegroups.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-11-25 17:36:55 +01:00
..
Kconfig
Makefile
aops.c
aops.h
attrib.c ntfs: check overflow when iterating ATTR_RECORDs 2022-11-25 17:36:55 +01:00
attrib.h
bitmap.c
bitmap.h
collate.c
collate.h
compress.c
debug.c
debug.h
dir.c
dir.h
endian.h
file.c
index.c
index.h
inode.c ntfs: fix use-after-free in ntfs_attr_find() 2022-11-25 17:36:55 +01:00
inode.h
layout.h
lcnalloc.c
lcnalloc.h
logfile.c
logfile.h
malloc.h
mft.c
mft.h
mst.c
namei.c
ntfs.h
quota.c
quota.h
runlist.c
runlist.h
super.c ntfs: fix BUG_ON in ntfs_lookup_inode_by_name() 2022-10-26 13:16:49 +02:00
sysctl.c
sysctl.h
time.h
types.h
unistr.c
upcase.c
usnjrnl.c
usnjrnl.h
volume.h