[PATCH] fs/fat/inode.c, kernel 2.4.0-test6

From: Oivind Hardy Danielsen (Oivind.Danielsen@fast.no)
Date: Mon Aug 28 2000 - 14:46:03 EST


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





-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Aug 31 2000 - 21:00:22 EST