Subject: Re: Maximum filehandle size
To: Martin Husemann <martin@duskware.de>
From: Jason Thorpe <thorpej@shagadelic.org>
List: tech-kern
Date: 03/27/2006 10:10:13
On Mar 26, 2006, at 1:21 PM, Martin Husemann wrote:
> I just ran accross a case where (eroneously) a filesystem exeeded
> the maximum file id size _VFS_MAXFIDSIZ. This truncates the values
> returned by the getfh() syscall at least - maybe has other
> consequences
> in NFS.
>
> Since _VFS_MAXFIDSIZ is defined to be the maximum possible size,
> should we enforce it a bit, like in this change?
Yes, I think this is a good change.
>
> Index: vfs_syscalls.c
> ===================================================================
> RCS file: /cvsroot/src/sys/kern/vfs_syscalls.c,v
> retrieving revision 1.238
> diff -p -U5 -r1.238 vfs_syscalls.c
> --- vfs_syscalls.c 1 Mar 2006 12:38:21 -0000 1.238
> +++ vfs_syscalls.c 26 Mar 2006 21:16:22 -0000
> @@ -1218,10 +1218,11 @@ sys_getfh(struct lwp *l, void *v, regist
> fh.fh_fsid = vp->v_mount->mnt_stat.f_fsidx;
> error = VFS_VPTOFH(vp, &fh.fh_fid);
> vput(vp);
> if (error)
> return (error);
> + KASSERT(fh.fh_fid.len <= _VFS_MAXFIDSIZ);
> error = copyout(&fh, (caddr_t)SCARG(uap, fhp), sizeof (fh));
> return (error);
> }
>
>
> Should this be a KDASSERT instead?
> Should I add this, and equivalent changes to the NFS code (guarding
> each VFS_VPTOFH)?
>
> Martin
-- thorpej