Unverified Commit 0e7e8fac authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!15630 Fix CVE-2022-49553

Merge Pull Request from: @ci-robot 
 
PR sync from: Zizhi Wo <wozizhi@huawei.com>
https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/MFMYU4YZ55IBTYYOL64HMM23TJHYBYWH/ 
Randy Dunlap (1):
  fs/ntfs3: validate BOOT sectors_per_clusters

Shigeru Yoshida (1):
  fs/ntfs3: Avoid UBSAN error on true_sectors_per_clst()

 
https://gitee.com/src-openeuler/kernel/issues/IBP6TI 
 
Link:https://gitee.com/openeuler/kernel/pulls/15630

 

Reviewed-by: default avatarLi Nan <linan122@huawei.com>
Signed-off-by: default avatarLi Nan <linan122@huawei.com>
parents 12846ebb 84e8dcf2
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -668,9 +668,11 @@ static u32 format_size_gb(const u64 bytes, u32 *mb)

static u32 true_sectors_per_clst(const struct NTFS_BOOT *boot)
{
	return boot->sectors_per_clusters <= 0x80
		       ? boot->sectors_per_clusters
		       : (1u << (0 - boot->sectors_per_clusters));
	if (boot->sectors_per_clusters <= 0x80)
		return boot->sectors_per_clusters;
	if (boot->sectors_per_clusters >= 0xf4) /* limit shift to 2MB max */
		return 1U << -(s8)boot->sectors_per_clusters;
	return -EINVAL;
}

/*
@@ -713,6 +715,8 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,

	/* cluster size: 512, 1K, 2K, 4K, ... 2M */
	sct_per_clst = true_sectors_per_clst(boot);
	if ((int)sct_per_clst < 0)
		goto out;
	if (!is_power_of_2(sct_per_clst))
		goto out;