Subject: Re: kern/34004: compat_netbsd32 fhstat and fhstatvfs seem broken
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Quentin Garnier <cube@cubidou.net>
List: netbsd-bugs
Date: 07/14/2006 17:15:05
The following reply was made to PR kern/34004; it has been noted by GNATS.

From: Quentin Garnier <cube@cubidou.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/34004: compat_netbsd32 fhstat and fhstatvfs seem broken
Date: Fri, 14 Jul 2006 19:13:21 +0200

 --uk6W7isEeLAaRh3S
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On Fri, Jul 14, 2006 at 04:40:01PM +0000, yamt@mwd.biglobe.ne.jp wrote:
 > >Number:         34004
 > >Category:       kern
 > >Synopsis:       compat_netbsd32 fhstat and fhstatvfs seem broken
 > >Confidential:   no
 > >Severity:       serious
 > >Priority:       medium
 > >Responsible:    kern-bug-people
 > >State:          open
 > >Class:          sw-bug
 > >Submitter-Id:   net
 > >Arrival-Date:   Fri Jul 14 16:40:00 +0000 2006
 > >Originator:     YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
 > >Release:        NetBSD 3.99.21
 > >Organization:
 >=20
 > >Environment:
 > =09
 > =09
 > >Description:
 > 	netbsd32_sys___fhstat30 should be able to handle
 > 	variable sized fhandle_t as sys___fhstat30 does.
 > 	the same for fhstatvfs.
 > >How-To-Repeat:
 > 	code inspection.
 
 The following patch should fix that, although my knowledge of how the
 whole file handle stuff works is limited.
 
 I cannot test it currently (and I mean not even compile-test it);  it's
 way too hot here in Paris to merely power on the compile host, let alone
 actually do a compilation.
 
 Thanks for the helpers anyway, Yamamoto-san.  misc/style says that there
 should not be brackets around one-statement blocks, though ;)
 
 Index: netbsd32_fs.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /rep/NetBSD-src/cvs/src/sys/compat/netbsd32/netbsd32_fs.c,v
 retrieving revision 1.28
 diff -u -r1.28 netbsd32_fs.c
 --- netbsd32_fs.c	2006/07/13 12:00:25	1.28
 +++ netbsd32_fs.c	2006/07/14 17:06:25
 @@ -785,33 +785,33 @@
  	struct stat sb;
  	struct netbsd32_stat sb32;
  	int error;
 -	struct compat_30_fhandle fh;
 -	struct mount *mp;
 +	fhandle_t *fh;
  	struct vnode *vp;
 =20
  	/*
  	 * Must be super user
  	 */
  	if ((error =3D kauth_authorize_generic(p->p_cred, KAUTH_GENERIC_ISSUSER,
 -	    &p->p_acflag)))
 +				       &p->p_acflag)))
  		return (error);
 =20
 -	if ((error =3D copyin(NETBSD32PTR64(SCARG(uap, fhp)), &fh,
 -	    sizeof(fh))) !=3D 0)
 -		return (error);
 -
 -	if ((mp =3D vfs_getvfs(&fh.fh_fsid)) =3D=3D NULL)
 -		return (ESTALE);
 -	if (mp->mnt_op->vfs_fhtovp =3D=3D NULL)
 -		return EOPNOTSUPP;
 -	if ((error =3D VFS_FHTOVP(mp, (struct fid*)&fh.fh_fid, &vp)))
 -		return (error);
 +	error =3D vfs_copyinfh(NETBSD32PTR64(SCARG(uap, fhp)), &fh);
 +	if (error !=3D 0) {
 +		goto bad;
 +	}
 +	error =3D vfs_fhtovp(fh, &vp);
 +	if (error !=3D 0) {
 +		goto bad;
 +	}
  	error =3D vn_stat(vp, &sb, l);
  	vput(vp);
 -	if (error)
 -		return (error);
 +	if (error) {
 +		goto bad;
 +	}
  	netbsd32_from___stat30(&sb, &sb32);
  	error =3D copyout(&sb32, NETBSD32PTR64(SCARG(uap, sb)), sizeof(sb));
 +bad:
 +	vfs_copyinfh_free(fh);
  	return (error);
  }
 =20
 --=20
 Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
 "When I find the controls, I'll go where I like, I'll know where I want
 to be, but maybe for now I'll stay right here on a silent sea."
 KT Tunstall, Silent Sea, Eye to the Telescope, 2004.
 
 --uk6W7isEeLAaRh3S
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.3 (NetBSD)
 
 iQEVAwUBRLfQsdgoQloHrPnoAQJ+aAf/cr7oS00JaYfg1SoAdJ3lcEIZfjTICGDq
 AOu0xRk9XZKZibfNV0v0AwHzP2yvx0IcwDwzHl4XAKPWUMkrfWz6BvyxCO30fc10
 aIKU12WAVQH8FbuDf2sIoI/QXtXuSB6+6sesap3Pqh9XftjXcyCxONYJwwBQseI6
 Y2sqtoL3NYhM1oKDRVocC+GQnDuiv8ZHPiD1HTIurndRBeDFgcFxagB0B+qwrIq6
 F66mNj/R6JdY79xblHmoR5SCKut/BT6K5DZ3vmAIF0s9PcgWOujSO35ul9avIiu8
 E48EpcTB6rnqWlh/kmWi64UktWqMj7nz4q2YvVev8Jimi33HOB0SsA==
 =5zmI
 -----END PGP SIGNATURE-----
 
 --uk6W7isEeLAaRh3S--