From nobody@FreeBSD.org  Sun Jan  8 00:15:06 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id E536E16A41F
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  8 Jan 2006 00:15:06 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 9240743D48
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  8 Jan 2006 00:15:06 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k080F6Ru032530
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 8 Jan 2006 00:15:06 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k080F6Mr032529;
	Sun, 8 Jan 2006 00:15:06 GMT
	(envelope-from nobody)
Message-Id: <200601080015.k080F6Mr032529@www.freebsd.org>
Date: Sun, 8 Jan 2006 00:15:06 GMT
From: Carl Drougge <freebsd-cd9660-bug@z42.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] cd9660 filesystem cannot handle files larger than 2GB
X-Send-Pr-Version: www-2.3

>Number:         91488
>Category:       kern
>Synopsis:       [isofs] [patch] cd9660 filesystem cannot handle files larger than 2GB
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kientzle
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 08 00:20:02 GMT 2006
>Closed-Date:    Sun Dec 23 18:12:55 UTC 2007
>Last-Modified:  Sun Dec 23 18:12:55 UTC 2007
>Originator:     Carl Drougge
>Release:        6.0-RELEASE
>Organization:
>Environment:
FreeBSD k6.lundagatan.com 6.0-RELEASE FreeBSD 6.0-RELEASE #1: Sun Jan  8 00:15:19 CET 2006     root@k6.lundagatan.com:/usr/src/sys/i386/compile/K6  i386
>Description:
The cd9660 filesystem can not handle files of more than 2147483647 bytes, 
while the specification of the filesystem arguably allows for files up to 
4294967295 bytes. (Specifically, the "32 bit quantity" is not specified as 
signed or unsigned. In my opinion, since negative file sizes are not 
meaningfull, it should be interpreted as unsigned.)
>How-To-Repeat:
Mount an iso9660 filesystem containing a file of more than 2147483647 
bytes, and try to access this file.

ls gives "ls: large_file: Value too large to be stored in data type", 
attempts to read the file return EOF at once.
>Fix:
I have not tested this patch much, but it seems to work.

--- sys/isofs/cd9660/cd9660_node.h.org	Wed Mar 16 09:09:52 2005
+++ sys/isofs/cd9660/cd9660_node.h	Sun Jan  8 00:14:54 2006
@@ -69,7 +69,7 @@
	ino_t	i_ino;		/* inode number of found directory */
 
	long iso_extent;	/* extent of file */
-	long i_size;
+	u_long i_size;
	long iso_start;		/* actual start of data of file (may be different */
				/* from iso_extent, if file has extended attributes) */
	ISO_RRIP_INODE	inode;

>Release-Note:
>Audit-Trail:

From: Jeff Anton <antonfb@hesiod.org>
To: bug-followup@FreeBSD.org, freebsd-cd9660-bug@z42.net
Cc:  
Subject: Re: kern/91488: [isofs] [patch] cd9660 filesystem cannot handle files
 larger than 2GB
Date: Mon, 20 Feb 2006 13:42:33 -0800

 The initial patch is not enough for the amd64 platform and any other
 platform where the long and unsigned long types have more bits than
 the int types.
 
 I also needed...
 
 --- cd9660_vfsops.c.org Thu Aug 18 04:32:06 2005
 +++ cd9660_vfsops.c     Mon Feb 20 13:32:54 2006
 @@ -756,7 +756,7 @@
         }
  
         ip->iso_extent = isonum_733(isodir->extent);
 -       ip->i_size = isonum_733(isodir->size);
 +       ip->i_size = (u_int32_t) isonum_733(isodir->size);
         ip->iso_start = isonum_711(isodir->ext_attr_length) + ip->iso_extent;
  
         /*
 
 I hope this gets into the main code path.  I'm going to have many files in the
 multi Gbyte size range (hence the 64 bit platform) for a long time to come.

From: =?ISO-8859-1?Q?Jo=E3o_Carlos_Mendes_Luis?= <jonny@jonny.eng.br>
To: bug-followup@FreeBSD.org,  freebsd-cd9660-bug@z42.net
Cc:  
Subject: Re: kern/91488: [isofs] [patch] cd9660 filesystem cannot handle files
 larger than 2GB
Date: Sat, 25 Feb 2006 17:56:34 -0300

 The real patches should be a little more refined than these.  For 
 example, I would expect that iso_extent and iso_start have the same type 
 of i_size.
 
 Anothe good approach could be to change the inline definition of 
 isonum_733 to be u_int32_t, instead of putting a cast somewhere else.
 
 So, these would be my patches:
 
 diff -ru /tmp/cd9660/cd9660_node.h /sys/isofs/cd9660/cd9660_node.h
 --- /tmp/cd9660/cd9660_node.h   Thu Jun 17 14:16:48 2004
 +++ /sys/isofs/cd9660/cd9660_node.h     Sat Feb 25 17:45:34 2006
 @@ -71,9 +71,9 @@
         doff_t  i_offset;       /* offset of free space in directory */
         ino_t   i_ino;          /* inode number of found directory */
  
 -       long iso_extent;        /* extent of file */
 -       long i_size;
 -       long iso_start;         /* actual start of data of file (may be 
 different */
 +       u_int32_t iso_extent;   /* extent of file */
 +       u_int32_t i_size;
 +       u_int32_t iso_start;            /* actual start of data of file 
 (may be different */
                                 /* from iso_extent, if file has extended 
 attributes) */
         ISO_RRIP_INODE  inode;
  };
 diff -ru /tmp/cd9660/iso.h /sys/isofs/cd9660/iso.h
 --- /tmp/cd9660/iso.h   Wed Jun 16 06:47:12 2004
 +++ /sys/isofs/cd9660/iso.h     Sat Feb 25 17:47:59 2006
 @@ -295,16 +295,16 @@
  
  #ifndef UNALIGNED_ACCESS
  
 -static __inline int isonum_723(u_char *);
 -static __inline int
 +static __inline u_int16_t isonum_723(u_char *);
 +static __inline u_int16_t
  isonum_723(p)
         u_char *p;
  {
         return *p|(p[1] << 8);
  }
  
 -static __inline int isonum_733(u_char *);
 -static __inline int
 +static __inline u_int32_t isonum_733(u_char *);
 +static __inline u_int32_t
  isonum_733(p)
         u_char *p;
  {
 
 
 I am using these patches in FreeBSD 5-STABLE, so far without problems.  
 Please remember to MFC them...
 
 
State-Changed-From-To: open->analyzed 
State-Changed-By: kientzle 
State-Changed-When: Fri Dec 8 16:53:10 UTC 2006 
State-Changed-Why:  
I committed a partial fix without seeing this PR. 
There are additional details here that I'll commit soon. 



Responsible-Changed-From-To: freebsd-bugs->kientzle 
Responsible-Changed-By: kientzle 
Responsible-Changed-When: Fri Dec 8 16:53:10 UTC 2006 
Responsible-Changed-Why:  
I committed a partial fix without seeing this PR. 
I'll work through the additional details here soon. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=91488 
State-Changed-From-To: analyzed->closed 
State-Changed-By: kientzle 
State-Changed-When: Sun Dec 23 18:06:50 UTC 2007 
State-Changed-Why:  
In RELENG_6, I believe this issue is completely resolved by 
v 1.31.2.1 of cd9660_node.h (commmitted on 11 Mar 2007), which 
incorporated the first patch listed for this bug.  The change 
to the return type for isonum_733 was done on 18 Oct 2005 by 
des (v 1.31). 

The other changes proposed here are unnecessary; in particular, 
iso_extent and iso_start are sector counts (not byte counts) 
and are thus not susceptible to overflow until the media 
is over 4TB (assuming 2k sector size). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=91488 
>Unformatted:
