Skip to content

Commit

Permalink
fs/ntfs3: Fix slab-out-of-bounds read in ntfs_trim_fs
Browse files Browse the repository at this point in the history
[ Upstream commit 557d196 ]

Syzbot reports an out of bound access in ntfs_trim_fs.
The cause of this is using a loop termination condition that compares
window index (iw) with wnd->nbits instead of wnd->nwnd, due to which the
index used for wnd->free_bits exceeds the size of the array allocated.

Fix the loop condition.

Fixes: 3f3b442 ("fs/ntfs3: Add bitmap")
Link: https://syzkaller.appspot.com/bug?extid=b892240eac461e488d51
Reported-by: syzbot+b892240eac461e488d51@syzkaller.appspotmail.com
Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
nifey authored and gregkh committed Dec 31, 2022
1 parent cf66351 commit f2e58e9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/ntfs3/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ int ntfs_trim_fs(struct ntfs_sb_info *sbi, struct fstrim_range *range)

down_read_nested(&wnd->rw_lock, BITMAP_MUTEX_CLUSTERS);

for (; iw < wnd->nbits; iw++, wbit = 0) {
for (; iw < wnd->nwnd; iw++, wbit = 0) {
CLST lcn_wnd = iw * wbits;
struct buffer_head *bh;

Expand Down

0 comments on commit f2e58e9

Please sign in to comment.