Skip to content

Commit f89f103

Browse files
ea1davisvijay-suman
authored andcommitted
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: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=e37dd1dfc814b10caa55 Signed-off-by: Edward Adam Davis <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 423e146ed630f5c0586069a2aa60b86d90be94cc) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent d034b67 commit f89f103

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/ntfs3/file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ static int ntfs_extend(struct inode *inode, loff_t pos, size_t count,
435435
}
436436

437437
if (extend_init && !is_compressed(ni)) {
438+
WARN_ON(ni->i_valid >= pos);
438439
err = ntfs_extend_initialized_size(file, ni, ni->i_valid, pos);
439440
if (err)
440441
goto out;

0 commit comments

Comments
 (0)