Skip to contentSkip to conversation

fat: Fix potential shift wrap with FITRIM ioctl on FAT

PATCH New OGAWA Hirofumi 1 participant 1 message Jul 13, 2018 1 message not in the archive VFAT/FAT/msdos filesystem

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

OGAWA Hirofumi

author maintainer
#1 lore raw

PATCH 1/1 fat: Fix potential shift wrap with FITRIM ioctl on FAT

This patch is the fix of fat-add-fitrim-ioctl-for-fat-file-system.patch. Maybe better to merge with it (if it is easy).

Anyway, please apply this with above patch.

--------
From: Wentao Wang <[email protected]>

If we keep "trimmed" as an u32, there will be a potential shift wrap.

It would be a problem on a larger than 4GB partition with FAT32. Though most tools who call this ioctl would ignore this value, it would be great to fix it.

---

 fs/fat/fatent.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/fat/fatent.c renamed from fs/fat/fatent.c~fat-fitrim-fix +2 -2
diff -puN fs/fat/fatent.c~fat-fitrim-fix fs/fat/fatent.c
@@ -705,8 +705,8 @@ int fat_trim_fs(struct inode *inode, str
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	const struct fatent_operations *ops = sbi->fatent_ops;
 	struct fat_entry fatent;
-	u64 ent_start, ent_end, minlen;
-	u32 free = 0, trimmed = 0;
+	u64 ent_start, ent_end, minlen, trimmed = 0;
+	u32 free = 0;
 	unsigned long reada_blocks, reada_mask, cur_block = 0;
 	int err = 0;
 

_

Signature · 1 line
OGAWA Hirofumi <[email protected]>