NetBSD Problem Report #7889
Received: (qmail 14060 invoked from network); 1 Jul 1999 16:38:26 -0000
Message-Id: <199907011638.SAA01127@mulet.e.kth.se>
Date: Thu, 1 Jul 1999 18:38:24 +0200 (CEST)
From: Assar Westerlund <assar@sics.se>
To: gnats-bugs@gnats.netbsd.org
Cc: Bill Studenmund <wrstuden@nas.nasa.gov>
Subject: sys_fhopen doesn't do FILE_UNUSE
X-Send-Pr-Version: 3.95
>Number: 7889
>Category: kern
>Synopsis: sys_fhopen doesn't do FILE_UNUSE
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jul 01 09:50:00 +0000 1999
>Closed-Date: Thu Jul 01 18:58:23 +0000 1999
>Last-Modified: Thu Jul 01 18:59:44 +0000 1999
>Originator: Assar Westerlund
>Release: 1999-07-01
>Organization:
none
>Environment:
System: NetBSD mulet.e.kth.se 1.4D NetBSD 1.4D (MULET) #1: Thu Jul 1 17:33:09 CEST 1999 root@mulet.e.kth.se:/usr/src/sys/arch/i386/compile/MULET i386
>Description:
since fhopen() doesn't FILE_UNUSE the fd, that fd is still marked
as being in use and when trying to close it, close will sleep and
your process will hang in diskwait
>How-To-Repeat:
try calling fhopen() and see your process getting stuck in `closef'
>Fix:
--- vfs_syscalls.c.orig Thu Jul 1 17:27:54 1999
+++ vfs_syscalls.c Thu Jul 1 17:32:45 1999
@@ -1083,13 +1083,25 @@
if ((error = falloc(p, &nfp, &indx)) != 0)
return (error);
fp = nfp;
- if ((error = copyin(SCARG(uap, fhp), &fh, sizeof(fhandle_t))) != 0)
+ if ((error = copyin(SCARG(uap, fhp), &fh, sizeof(fhandle_t))) != 0) {
+ FILE_UNUSE(fp, p);
+ ffree(fp);
+ fdp->fd_ofiles[indx] = NULL;
return (error);
+ }
- if ((mp = vfs_getvfs(&fh.fh_fsid)) == NULL)
+ if ((mp = vfs_getvfs(&fh.fh_fsid)) == NULL) {
+ FILE_UNUSE(fp, p);
+ ffree(fp);
+ fdp->fd_ofiles[indx] = NULL;
return (ESTALE);
- if ((error = VFS_FHTOVP(mp, &fh.fh_fid, &vp)))
+ }
+ if ((error = VFS_FHTOVP(mp, &fh.fh_fid, &vp))) {
+ FILE_UNUSE(fp, p);
+ ffree(fp);
+ fdp->fd_ofiles[indx] = NULL;
return (error);
+ }
/* Now do an effective vn_open */
@@ -1145,6 +1157,7 @@
error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type);
if (error) {
(void) vn_close(vp, fp->f_flag, fp->f_cred, p);
+ FILE_UNUSE(fp, p);
ffree(fp);
fdp->fd_ofiles[indx] = NULL;
return (error);
@@ -1153,9 +1166,13 @@
fp->f_flag |= FHASLOCK;
}
VOP_UNLOCK(vp, 0);
+ FILE_UNUSE(fp, p);
*retval = indx;
return (0);
bad:
+ FILE_UNUSE(fp, p);
+ ffree(fp);
+ fdp->fd_ofiles[indx] = NULL;
vput(vp);
return (error);
}
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: wrstuden
State-Changed-When: Thu Jul 1 11:58:23 PDT 1999
State-Changed-Why:
Should be fixed in vfs_syscalls.c 1.139. Jason had sent me a slightly
different fix which routes everything through bad:. Let me know if this
doesn't work.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.