Subject: Re: NetBSD, apple fibre-channel card & 2.8TB Xserve-RAID
To: NetBSD Kernel Technical Discussion List <tech-kern@NetBSD.ORG>
From: Greg A. Woods <woods@weird.com>
List: tech-kern
Date: 12/06/2004 15:17:21
Just to clarify note the fix below is not needed on the netbsd-1-6
branch. "nb" was defined as a daddr_t before the FFS snapshots feature
was introduced in rev. 1.33 of ffs_balloc.c (and is actually a
ufs_daddr_t in 1.6.x).
Also note that it appears this _might_ have been caught if the and
'-Wconversion' warnings were turned on, assuming the warning wasn't
just suppressed by an incorrect cast.... (I get fewer warnings after
applying the patch than I did beforehand)
('-W' and '-Wmissing-declarations' might be good for the kernel too :-)
[ On Monday, December 6, 2004 at 04:16:16 (+0000), Charles M. Hannum wrote: ]
> Subject: Re: NetBSD, apple fibre-channel card & 2.8TB Xserve-RAID
>
> You didn't say whether you're using a FFS v1 or v2 file system, and I don't
> recall whether you specified the block and fragment sizes, but I did a very
> quick audit of the FFS code and found what looks like a serious truncation
> problem. Attached is a diff that I think will fix it.
>
> (The problem is the usage of fsbtodb(nb) in getblk() calls. It needs to be
> expanded to 64 bits somewhere, and fsbtodb() doesn't do it.)
>
> Index: ffs_balloc.c
> ===================================================================
> RCS file: /cvsroot/src/sys/ufs/ffs/ffs_balloc.c,v
> retrieving revision 1.36
> diff -u -r1.36 ffs_balloc.c
> --- ffs_balloc.c 14 Aug 2004 01:30:56 -0000 1.36
> +++ ffs_balloc.c 6 Dec 2004 04:11:09 -0000
> @@ -103,13 +103,12 @@
> int size;
> struct ucred *cred;
> int flags;
> - int32_t nb;
> struct buf *bp, *nbp;
> struct vnode *vp = ap->a_vp;
> struct inode *ip = VTOI(vp);
> struct fs *fs = ip->i_fs;
> struct indir indirs[NIADDR + 2];
> - daddr_t newb, pref;
> + daddr_t newb, pref, nb;
> int32_t *bap; /* XXX ondisk32 */
> int deallocated, osize, nsize, num, i, error;
> int32_t *blkp, *allocblk, allociblk[NIADDR + 1];
--
Greg A. Woods
+1 416 218-0098 VE3TCP RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com> Secrets of the Weird <woods@weird.com>