public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* File sizes > 2 GB on isofs?
@ 2004-08-10 17:37 Jeff Mahoney
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff Mahoney @ 2004-08-10 17:37 UTC (permalink / raw)
  To: Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 1496 bytes --]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


I recently received a bug report regarding files on an iso9660
filesystem with sizes > 2 GB. mkisofs is apparently capable of creating
these filesystems, so I did a bit of research into if this was actually
valid or not.

It seems the iso9660/ecma119 spec doesn't specify the signedness of the
"32-bit number" for which they assign space to contain the file size.
There are tests in the kernel code to disallow file sizes > 2 GB, with
the apparent reason that there was, at some point, invalid CDs floating
around that hijacked the high byte of the file size field for some other
purpose.

With DVDs becoming widely popular for personal data storage, this 2 GB
limit will probably become more and more of an issue.

Currently, if a file is > 2 GB, 'cruft mode' is enabled which strips the
high byte off a file size. Attached is a patch that adds another
condition to that test: In order to enable 'cruft mode', the file size
must be larger than the volume size. A 3 GB file on a 700 MB CD is
certainly invalid, but a 3 GB file on a 4.7 GB DVD should be valid.

Might someone with a bit more familiarity with the spec be able to
comment on this?

Thanks.

- -Jeff

- --
Jeff Mahoney
SuSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBGQfULPWxlyuTD7IRAqc3AJ9YC8Rg+GGmzm1V5SbHkDumkLKCvQCfSOoJ
NhagL+eCKXGugHcuFFCgZjQ=
=ToTR
-----END PGP SIGNATURE-----

[-- Attachment #2: isofs-4GB.diff --]
[-- Type: text/plain, Size: 2049 bytes --]

diff -rup linux-2.6.5-7.97/fs/isofs/inode.c linux-2.6.5-7.97.devel/fs/isofs/inode.c
--- linux-2.6.5-7.97/fs/isofs/inode.c	2004-07-02 10:41:26.000000000 -0400
+++ linux-2.6.5-7.97.devel/fs/isofs/inode.c	2004-08-10 13:26:51.796563112 -0400
@@ -1158,7 +1158,7 @@ static int isofs_read_level3_size(struct
 			de = tmpde;
 		}
 
-		inode->i_size += isonum_733(de->size);
+		inode->i_size += (unsigned)isonum_733(de->size);
 		if (i == 1)
 			ei->i_next_section_ino = f_pos;
 
@@ -1267,23 +1267,25 @@ static void isofs_read_inode(struct inod
 	ei->i_format_parm[1] = 0;
 	ei->i_format_parm[2] = 0;
 
-	ei->i_section_size = isonum_733 (de->size);
+	ei->i_section_size = (unsigned)isonum_733 (de->size);
 	if(de->flags[-high_sierra] & 0x80) {
 		if(isofs_read_level3_size(inode)) goto fail;
 	} else {
 		ei->i_next_section_ino = 0;
-		inode->i_size = isonum_733 (de->size);
+		inode->i_size = (unsigned)isonum_733 (de->size);
 	}
 
-	/*
-	 * The ISO-9660 filesystem only stores 32 bits for file size.
-	 * mkisofs handles files up to 2GB-2 = 2147483646 = 0x7FFFFFFE bytes
-	 * in size. This is according to the large file summit paper from 1996.
-	 * WARNING: ISO-9660 filesystems > 1 GB and even > 2 GB are fully
-	 *	    legal. Do not prevent to use DVD's schilling@fokus.gmd.de
-	 */
+	/* The ISO-9660 filesystem only stores 32 bits for file size.
+	 * mkisofs handles files up to 4 GB-1 = 0xFFFFFFFF bytes in size.
+	 * There used to be issues with some implementations hijacking the
+	 * high byte of the size field for some other purpose. In order to
+	 * allow for the full range of file sizes, yet still protect against
+	 * this, we check and see if the file size is larger than the size
+	 * of the entire volume.
+	 */
 	if ((inode->i_size < 0 || inode->i_size > 0x7FFFFFFE) &&
-	    sbi->s_cruft == 'n') {
+	    inode->i_size > (ISOFS_SB(sb)->s_nzones <<
+	    ISOFS_SB(sb)->s_log_zone_size) && sbi->s_cruft == 'n') {
 		printk(KERN_WARNING "Warning: defective CD-ROM.  "
 		       "Enabling \"cruft\" mount option.\n");
 		sbi->s_cruft = 'y';

^ permalink raw reply	[flat|nested] 3+ messages in thread
[parent not found: <2rIVi-16U-45@gated-at.bofh.it>]

end of thread, other threads:[~2004-08-10 18:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-10 17:37 File sizes > 2 GB on isofs? Jeff Mahoney
     [not found] <2rIVi-16U-45@gated-at.bofh.it>
2004-08-10 17:55 ` Andi Kleen
2004-08-10 18:17   ` Jeff Mahoney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox