]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
fs/ntfs3: Fix WARNING in ntfs_extend_initialized_size
authorEdward Adam Davis <eadavis@qq.com>
Mon, 14 Oct 2024 12:16:38 +0000 (20:16 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 May 2025 05:50:54 +0000 (07:50 +0200)
commitdb56636beb3e687c761dbf5e52d6b17d74f95de2
treeb3fdae76947a11ba803f483ffeb131c030d8d058
parent46a150788e16923e8fefd103ffa5a2745648d18c
fs/ntfs3: Fix WARNING in ntfs_extend_initialized_size

[ Upstream commit ff355926445897cc9fdea3b00611e514232c213c ]

Syzbot reported a WARNING in ntfs_extend_initialized_size.
The data type of in->i_valid and to is u64 in ntfs_file_mmap().
If their values are greater than LLONG_MAX, overflow will occur because
the data types of the parameters valid and new_valid corresponding to
the function ntfs_extend_initialized_size() are loff_t.

Before calling ntfs_extend_initialized_size() in the ntfs_file_mmap(),
the "ni->i_valid < to" has been determined, so the same WARN_ON determination
is not required in ntfs_extend_initialized_size().
Just execute the ntfs_extend_initialized_size() in ntfs_extend() to make
a WARN_ON check.

Reported-and-tested-by: syzbot+e37dd1dfc814b10caa55@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e37dd1dfc814b10caa55
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ntfs3/file.c