Skip to content

Commit caad9dd

Browse files
Shigeru Yoshidaaalexandrovich
authored andcommitted
fs/ntfs3: Avoid UBSAN error on true_sectors_per_clst()
syzbot reported UBSAN error as below: [ 76.901829][ T6677] ================================================================================ [ 76.903908][ T6677] UBSAN: shift-out-of-bounds in fs/ntfs3/super.c:675:13 [ 76.905363][ T6677] shift exponent -247 is negative This patch avoid this error. Link: https://syzkaller.appspot.com/bug?id=b0299c09a14aababf0f1c862dd4ebc8ab9eb0179 Fixes: a3b7743 (fs/ntfs3: validate BOOT sectors_per_clusters) Cc: Author: Randy Dunlap <rdunlap@infradead.org> Reported-by: syzbot+35b87c668935bb55e666@syzkaller.appspotmail.com Signed-off-by: Shigeru Yoshida <syoshida@redhat.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
1 parent 51e76a2 commit caad9dd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/ntfs3/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ static u32 true_sectors_per_clst(const struct NTFS_BOOT *boot)
697697
if (boot->sectors_per_clusters <= 0x80)
698698
return boot->sectors_per_clusters;
699699
if (boot->sectors_per_clusters >= 0xf4) /* limit shift to 2MB max */
700-
return 1U << (0 - boot->sectors_per_clusters);
700+
return 1U << -(s8)boot->sectors_per_clusters;
701701
return -EINVAL;
702702
}
703703

0 commit comments

Comments
 (0)