diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index e8ba4fecf55c..2953752b744f 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -2070,13 +2070,11 @@ fdrop_locked(fp, td) FILE_UNLOCK(fp); if (fp->f_count < 0) panic("fdrop: count < 0"); - mtx_lock(&Giant); if (fp->f_ops != &badfileops) error = fo_close(fp, td); else error = 0; ffree(fp); - mtx_unlock(&Giant); return (error); } diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 29491d7527be..4d3870e748d1 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -906,7 +906,7 @@ kqueue_close(struct file *fp, struct thread *td) struct knote **knp, *kn, *kn0; int i; - GIANT_REQUIRED; + mtx_lock(&Giant); FILEDESC_LOCK(fdp); for (i = 0; i < fdp->fd_knlistsize; i++) { @@ -957,6 +957,7 @@ kqueue_close(struct file *fp, struct thread *td) free(kq, M_KQUEUE); fp->f_data = NULL; + mtx_unlock(&Giant); return (0); } diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index e59823cb0621..e1de4b79702d 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -262,11 +262,13 @@ soo_close(fp, td) int error = 0; struct socket *so; + NET_LOCK_GIANT(); so = fp->f_data; fp->f_ops = &badfileops; fp->f_data = NULL; if (so) error = soclose(so); + NET_UNLOCK_GIANT(); return (error); } diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 319835d7c6c1..107feeb6378a 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -915,11 +915,11 @@ vn_closefile(fp, td) { struct vnode *vp; struct flock lf; - - GIANT_REQUIRED; + int error; vp = fp->f_vnode; + mtx_lock(&Giant); if (fp->f_type == DTYPE_VNODE && fp->f_flag & FHASLOCK) { lf.l_whence = SEEK_SET; lf.l_start = 0; @@ -930,7 +930,9 @@ vn_closefile(fp, td) fp->f_ops = &badfileops; - return (vn_close(vp, fp->f_flag, fp->f_cred, td)); + error = vn_close(vp, fp->f_flag, fp->f_cred, td); + mtx_unlock(&Giant); + return (error); } /* diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index 9b0da7ce3026..26b24477be77 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -623,12 +623,19 @@ cryptof_close(struct file *fp, struct thread *td) struct fcrypt *fcr = fp->f_data; struct csession *cse; + /* + * XXXRW: The cryptodev and called code all appears to be + * MPSAFE, but I'm not set up to test it. Acquire Giant + * for now. + */ + mtx_lock(&Giant); while ((cse = TAILQ_FIRST(&fcr->csessions))) { TAILQ_REMOVE(&fcr->csessions, cse, next); (void)csefree(cse); } FREE(fcr, M_XDATA); fp->f_data = NULL; + mtx_unlock(&Giant); return 0; }