lkml.org 
[lkml]   [2000]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] fs/fat/inode.c, kernel 2.4.0-test6
When writing to a >64GB FAT32 partition, file system panic can occur:
.... kernel: attempt to access beyond end of device
.... kernel: 09:01: rw=0, want=2081825939, limit=103317504
.... kernel: dev = 09:01, ino = -2101046686
.... kernel: Filesystem panic (dev 09:01).
.... kernel: msdos_write_inode: unable to read i-node block
.... kernel: File system has been set read-only

Fix: (unified diff is attached)
- if (!(bh = fat_bread(sb, i_pos >> MSDOS_DPB_BITS))) {
+ if (!(bh = fat_bread(sb, ((unsigned int)i_pos) >> MSDOS_DPB_BITS))) {

i_pos is signed int. When reading a block at offset >64GB, overflow
occurs. Shifting a negative number to the right gives a bad result in this
case (1's insert in high bits). By casting the number to unsigned, this
problem will not occur and the limit is raised to 128GB (assumed). In
order to get 2TB FAT32 partitions, 64 bit datatypes should be introduced.

64GB limit: (2*1024*1024*1024)/(16*(1024/512)) = 67108864 1k blocks
2*1024*1024*1024: (32-bit signed int maximum)+1
16: directory entries per 512byte sector (1<<MSDOS_DPB_BITS)
1024/512: Treat sector as 1k block (strange emulation)

Regards,

- Oivind H. Danielsen

Fix >64GB fat32 filesystem problem (2.4.0-test6). <Oivind.Danielsen@fast.no>
--- linux-2.4.0-test6_orig/linux/fs/fat/inode.c Wed Jul 19 20:27:45 2000
+++ linux-2.4.0-test6/fs/fat/inode.c Fri Aug 25 18:07:19 2000
@@ -860,7 +860,7 @@
return;
}
lock_kernel();
- if (!(bh = fat_bread(sb, i_pos >> MSDOS_DPB_BITS))) {
+ if (!(bh = fat_bread(sb, ((unsigned int)i_pos) >> MSDOS_DPB_BITS))) {
printk("dev = %s, ino = %d\n", kdevname(inode->i_dev), i_pos);
fat_fs_panic(sb, "msdos_write_inode: unable to read i-node block");
unlock_kernel();
\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.025 / U:22.828 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site