Skip to contentSkip to conversation

fat-fix-possible-overflow-for-fat_clusters.patch removed from -mm tree

merged [email protected] 1 participant 1 message May 28, 2013 VFAT/FAT/msdos filesystem

lore
Share & tools
lore
#0 lore raw

Subject: [merged] fat-fix-possible-overflow-for-fat_clusters.patch removed from -mm tree
To: [email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Tue, 28 May 2013 12:36:37 -0700

The patch titled
Subject: fat: fix possible overflow for fat_clusters
has been removed from the -mm tree. Its filename was
fat-fix-possible-overflow-for-fat_clusters.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: OGAWA Hirofumi <[email protected]>
Subject: fat: fix possible overflow for fat_clusters

Intermediate value of fat_clusters can be overflowed on 32bits arch.

---

 fs/fat/inode.c |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
fs/fat/inode.c renamed from fs/fat/inode.c~fat-fix-possible-overflow-for-fat_clusters +14 -1
diff -puN fs/fat/inode.c~fat-fix-possible-overflow-for-fat_clusters fs/fat/inode.c
@@ -1229,6 +1229,19 @@ static int fat_read_root(struct inode *i
 	return 0;
 }
 
+static unsigned long calc_fat_clusters(struct super_block *sb)
+{
+	struct msdos_sb_info *sbi = MSDOS_SB(sb);
+
+	/* Divide first to avoid overflow */
+	if (sbi->fat_bits != 12) {
+		unsigned long ent_per_sec = sb->s_blocksize * 8 / sbi->fat_bits;
+		return ent_per_sec * sbi->fat_length;
+	}
+
+	return sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits;
+}
+
 /*
  * Read the super block of an MS-DOS FS.
  */
@@ -1434,7 +1447,7 @@ int fat_fill_super(struct super_block *s
 		sbi->dirty = b->fat16.state & FAT_STATE_DIRTY;
 
 	/* check that FAT table does not overflow */
-	fat_clusters = sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits;
+	fat_clusters = calc_fat_clusters(sb);
 	total_clusters = min(total_clusters, fat_clusters - FAT_START_ENT);
 	if (total_clusters > MAX_FAT(sb)) {
 		if (!silent)

_

Patches currently in -mm which might be from [email protected] are

fs-fat-use-fat_msg-to-replace-printk-in-__fat_fs_error.patch fat-additions-to-support-fat_fallocate.patch fat-additions-to-support-fat_fallocate-fix.patch