Skip to content
/ linux Public

Commit b97e371

Browse files
ea1davisSasha Levin
authored andcommitted
fs/ntfs3: prevent infinite loops caused by the next valid being the same
[ Upstream commit 27b75ca ] When processing valid within the range [valid : pos), if valid cannot be retrieved correctly, for example, if the retrieved valid value is always the same, this can trigger a potential infinite loop, similar to the hung problem reported by syzbot [1]. Adding a check for the valid value within the loop body, and terminating the loop and returning -EINVAL if the value is the same as the current value, can prevent this. [1] INFO: task syz.4.21:6056 blocked for more than 143 seconds. Call Trace: rwbase_write_lock+0x14f/0x750 kernel/locking/rwbase_rt.c:244 inode_lock include/linux/fs.h:1027 [inline] ntfs_file_write_iter+0xe6/0x870 fs/ntfs3/file.c:1284 Fixes: 4342306 ("fs/ntfs3: Add file operations and implementation") Reported-by: syzbot+bcf9e1868c1a0c7e04f1@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=bcf9e1868c1a0c7e04f1 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>
1 parent dd6c815 commit b97e371

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/ntfs3/file.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,8 +1045,12 @@ static ssize_t ntfs_compress_write(struct kiocb *iocb, struct iov_iter *from)
10451045
goto out;
10461046

10471047
if (lcn == SPARSE_LCN) {
1048-
ni->i_valid = valid =
1049-
frame_vbo + ((u64)clen << sbi->cluster_bits);
1048+
valid = frame_vbo + ((u64)clen << sbi->cluster_bits);
1049+
if (ni->i_valid == valid) {
1050+
err = -EINVAL;
1051+
goto out;
1052+
}
1053+
ni->i_valid = valid;
10501054
continue;
10511055
}
10521056

0 commit comments

Comments
 (0)