Subject: Maximum filehandle size
To: None <>
From: Martin Husemann <>
List: tech-kern
Date: 03/26/2006 23:21:54
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?

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);
 	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