Subject: kern/36556: sys/dev/biovar.h defines bv_size and bd_size as size_t which can be only 32 bits
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <mhitch@NetBSD.msu.montana.edu>
List: netbsd-bugs
Date: 06/25/2007 19:20:00
>Number:         36556
>Category:       kern
>Synopsis:       bd_size and bv_size in sys/dev/biovar.h is size_t, which may be only 32 bits.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 25 19:20:00 +0000 2007
>Originator:     Michael L. Hitch
>Release:        NetBSD 4.99.20 and NetBSD-4.0_BETA2
>Organization:
	
>Environment:
	
	
System: NetBSD net4.msu.montana.edu 4.99.20 NetBSD 4.99.20 (GENERIC) #35: Fri Jun 22 11:10:28 MDT 2007 mhitch@tarus.msu.montana.edu:/home/mhitch/NetBSD-current/OBJ/i386/home/mhitch/NetBSD-current/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
  The definitions of bd_size (device size) and bv_size (volume size) in
  sys/dev/biovar.h are defined as size_t.  However, size_t may only be
  32 bits on many architectures and limits the disk/volume size to 4GB.
>How-To-Repeat:
  Run bioctl on NetBSD/i386 (currently only supports the mfi(4) raid
  adapter, and note that the reported sizes are incorrect if the disk
  or raid volume exceeds 4GB.
>Fix:
  The bd_size and bv_size fields should be defined as ssize_t or off_t
  (I'm not sure what the correct definition of ssize_t is, but off_t
  is used for 64 bit offsets).

  This could cause compatibility problems (Manuel Bouyer suggested
  keeping compat ioctls for COMPAT_40).  I'm not sure that compatibilty
  is that much of an issue.  There (currently) is no relase using bio(4)
  with the existing definitions of bd_size and bv_size (although that
  could change if nothing is done about this before 4.0 gets released).
  Also, biovar.h is only used in the kernel and the bioctl(1) program
  and bio(4) currently only supports mfi(4).  [I've been working on
  adding ciss(4) support as well as amr(4) support, which is how I
  ran into this problem.]  If anyone was currently using bioctl with
  mfi raid volumes, they would either be builing -current or
  NetBSD-4.0_BETA2 themselve, and can easily replace bioctl(1) if they
  update the kernel without updating userland.  The same thing could
  be done if using the autobuilds of -current or netbsd-4.


Index: sys/dev/biovar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/biovar.h,v
retrieving revision 1.1
diff -u -r1.1 biovar.h
--- sys/dev/biovar.h	1 May 2007 17:20:11 -0000	1.1
+++ sys/dev/biovar.h	25 Jun 2007 18:14:46 -0000
@@ -90,7 +90,7 @@
 #define BIOC_SDSCRUB_S		"Scrubbing"
 #define BIOC_SDINVALID		0xff
 #define BIOC_SDINVALID_S	"Invalid"
-	size_t		bd_size;	/* size of the disk */
+	off_t		bd_size;	/* size of the disk */
 
 	char		bd_vendor[32];	/* scsi string */
 	char		bd_serial[32];	/* serial number */
@@ -121,7 +121,7 @@
 #define BIOC_SVREBUILD_S	"Rebuild"
 #define BIOC_SVINVALID		0xff
 #define BIOC_SVINVALID_S	"Invalid"
-	size_t		bv_size;	/* size of the disk */
+	off_t		bv_size;	/* size of the disk */
 	int		bv_level;	/* raid level */
 	int		bv_nodisk;	/* nr of drives */