Skip to content

Commit

Permalink
fs/ntfs3: fix negative shift size in true_sectors_per_clst()
Browse files Browse the repository at this point in the history
syzbot is reporting shift-out-of-bounds in true_sectors_per_clst() [1],
for commit a3b7743 ("fs/ntfs3: validate BOOT
sectors_per_clusters") did not address that (0 -
boot->sectors_per_clusters) < 0 because "u8" was chosen for type of
boot->sectors_per_clusters because 0x80 needs to be positive in order to
support 64K clusters.  Use "s8" cast in order to make sure that (0 - (s8)
boot->sectors_per_clusters) > 0.

Link: https://syzkaller.appspot.com/bug?extid=1631f09646bc214d2e76 [1]
Link: https://lkml.kernel.org/r/4b37f037-3b10-b4e4-0644-73441c8fa0af@I-love.SAKURA.ne.jp
Fixes: a3b7743 ("fs/ntfs3: validate BOOT sectors_per_clusters")
Reported-by: syzbot <syzbot+1631f09646bc214d2e76@syzkaller.appspotmail.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Tested-by: syzbot <syzbot+1631f09646bc214d2e76@syzkaller.appspotmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Tetsuo Handa authored and Andrew Morton committed Sep 27, 2022
1 parent 8928c99 commit 344f44d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/ntfs3/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ static u32 true_sectors_per_clst(const struct NTFS_BOOT *boot)
if (boot->sectors_per_clusters <= 0x80)
return boot->sectors_per_clusters;
if (boot->sectors_per_clusters >= 0xf4) /* limit shift to 2MB max */
return 1U << (0 - boot->sectors_per_clusters);
return 1U << (0 - (s8) boot->sectors_per_clusters);
return -EINVAL;
}

Expand Down

0 comments on commit 344f44d

Please sign in to comment.