From nobody@FreeBSD.org  Thu Jan 11 19:32:32 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 0397716A40F
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 11 Jan 2007 19:32:32 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id DCD0B13C428
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 11 Jan 2007 19:32:31 +0000 (UTC)
	(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 l0BJWVv6047745
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 11 Jan 2007 19:32:31 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id l0BJWVBZ047744;
	Thu, 11 Jan 2007 19:32:31 GMT
	(envelope-from nobody)
Message-Id: <200701111932.l0BJWVBZ047744@www.freebsd.org>
Date: Thu, 11 Jan 2007 19:32:31 GMT
From: Jo Rhett<jrhett@svcolo.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: invalid boundary checking in fdisk / wraps value of > 2TB filesystem.
X-Send-Pr-Version: www-3.0

>Number:         107829
>Category:       bin
>Synopsis:       [2TB] fdisk(8): invalid boundary checking in fdisk / wraps value of > 2TB filesystem.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-fs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 11 19:40:15 GMT 2007
>Closed-Date:    
>Last-Modified:  Mon May 18 04:33:42 UTC 2009
>Originator:     Jo Rhett
>Release:        6.0-REL
>Organization:
Silicon Valley Colocation
>Environment:
FreeBSD arran 6.0-RELEASE FreeBSD 6.0-RELEASE #4
>Description:
Fdisk doesn't handle partition sizes greater than 2TB, no problem.  But
it should either complain appropriately or just truncate numbers which
exceed this limit.

Trying to create a 2.4TB partition gave me (without any warning) the
following result.  This is consistent and repeatable at will.


[root@backup0 ~]# fdisk /dev/da0
******* Working on device /dev/da0 *******
parameters extracted from in-core disklabel are:
cylinders=303934 heads=255 sectors/track=63 (16065 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=303934 heads=255 sectors/track=63 (16065 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
    start 63, size 587732351 (286978 Meg), flag 80 (active)
        beg: cyl 0/ head 1/ sector 1;
        end: cyl 1023/ head 165/ sector 59
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
<UNUSED>

The same problem can be observed in interactive mode, where it actually shows negative numbers.



>How-To-Repeat:
root@arran 4# fdisk -u da0
******* Working on device /dev/da0 *******
parameters extracted from in-core disklabel are:
cylinders=9724 heads=255 sectors/track=63 (16065 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=9724 heads=255 sectors/track=63 (16065 blks/cyl)

Do you want to change our idea of what BIOS thinks ? [n] 
Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
    start 63, size 156215997 (76277 Meg), flag 80 (active)
        beg: cyl 0/ head 1/ sector 1;
        end: cyl 1023/ head 254/ sector 63
Do you want to change it? [n] y
Supply a decimal value for "sysid (165=FreeBSD)" [165] 
Supply a decimal value for "start" [63] 
Supply a decimal value for "size" [156215997] 15621599700
fdisk: WARNING: partition does not end on a cylinder boundary
fdisk: WARNING: this may confuse the BIOS or some operating systems
Correct this automatically? [n] y
fdisk: WARNING: adjusting size of partition to 2736688752
Explicitly specify beg/end address ? [n] 
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
    start 63, size 2736688752 (1336273 Meg), flag 80 (active)
        beg: cyl 0/ head 1/ sector 1;
        end: cyl 366/ head 254/ sector 63
Are we happy with this entry? [n] 
Supply a decimal value for "sysid (165=FreeBSD)" [165] 
Supply a decimal value for "start" [63] 
Supply a decimal value for "size" [-1558278544] 
>Fix:
Since fdisk is known to only handle 2tb partitions, the values input
should be checked for validity and either rejected or simply truncated to 2tb.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-i386->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue Feb 13 01:01:42 UTC 2007 
Responsible-Changed-Why:  
This is not i386-specific. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=107829 
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon May 18 04:33:35 UTC 2009 
Responsible-Changed-Why:  
Over to maintainer(s). 

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