]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
fs/ntfs3: Fix OOB read in indx_insert_into_buffer
authorZhangPeng <zhangpeng362@huawei.com>
Wed, 7 Dec 2022 09:46:10 +0000 (09:46 +0000)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 7 Jul 2023 10:17:08 +0000 (12:17 +0200)
commit2ed8cfe96e67c0138033cc55ec52461b24fcde3f
treeb8dde7be20dc847c49acf79240c6a01d2b64c5c6
parentf9e83322c027cc5b1fb279b2a5945a00905c2ae0
fs/ntfs3: Fix OOB read in indx_insert_into_buffer

BugLink: https://bugs.launchpad.net/bugs/2025067
[ Upstream commit b8c44949044e5f7f864525fdffe8e95135ce9ce5 ]

Syzbot reported a OOB read bug:

BUG: KASAN: slab-out-of-bounds in indx_insert_into_buffer+0xaa3/0x13b0
fs/ntfs3/index.c:1755
Read of size 17168 at addr ffff8880255e06c0 by task syz-executor308/3630

Call Trace:
 <TASK>
 memmove+0x25/0x60 mm/kasan/shadow.c:54
 indx_insert_into_buffer+0xaa3/0x13b0 fs/ntfs3/index.c:1755
 indx_insert_entry+0x446/0x6b0 fs/ntfs3/index.c:1863
 ntfs_create_inode+0x1d3f/0x35c0 fs/ntfs3/inode.c:1548
 ntfs_create+0x3e/0x60 fs/ntfs3/namei.c:100
 lookup_open fs/namei.c:3413 [inline]

If the member struct INDEX_BUFFER *index of struct indx_node is
incorrect, that is, the value of __le32 used is greater than the value
of __le32 total in struct INDEX_HDR. Therefore, OOB read occurs when
memmove is called in indx_insert_into_buffer().
Fix this by adding a check in hdr_find_e().

Fixes: 82cae269cfa9 ("fs/ntfs3: Add initialization of super block")
Reported-by: syzbot+d882d57193079e379309@syzkaller.appspotmail.com
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/ntfs3/index.c