Commit 4b51f27d authored by Shigeru Yoshida's avatar Shigeru Yoshida Committed by Greg Kroah-Hartman
Browse files

fs/ntfs3: Avoid UBSAN error on true_sectors_per_clst()

[ Upstream commit caad9dd8 ]

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: a3b77434 (fs/ntfs3: validate BOOT sectors_per_clusters)
Cc: Author: Randy Dunlap <rdunlap@infradead.org>
Reported-by: default avatar <syzbot+35b87c668935bb55e666@syzkaller.appspotmail.com>
Signed-off-by: default avatarShigeru Yoshida <syoshida@redhat.com>
Signed-off-by: default avatarKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 28f345be
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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 << -(s8)boot->sectors_per_clusters;
	return -EINVAL;
}