- Move crfree() outside MNT_ILOCK()/MNT_IUNLOCK() to eliminate a LOR:

1st 0xc4cea568 struct mount mtx (struct mount mtx) @ /usr/src/sys/modules/zfs/../../compat/opensolaris/kern/opensolaris_vfs.c:209
  2nd 0xc3ee9010 sleep mtxpool (sleep mtxpool) @ /usr/src/sys/kern/kern_resource.c:1266
- Move crdup() outside MNT_ILOCK()/MNT_IUNLOCK(), as it can sleep.

Reported by:	Olli Hauer <ohauer@gmx.de>
MFC after:	3 days
This commit is contained in:
Pawel Jakub Dawidek 2007-11-01 08:58:29 +00:00
parent 70e7b0732a
commit 4f2398ea17
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=173247
2 changed files with 12 additions and 4 deletions

View File

@ -163,6 +163,7 @@ domount(kthread_t *td, vnode_t *vp, const char *fstype, char *fspath,
{
struct mount *mp;
struct vfsconf *vfsp;
struct ucred *newcr, *oldcr;
int error;
/*
@ -202,7 +203,9 @@ domount(kthread_t *td, vnode_t *vp, const char *fstype, char *fspath,
/*
* Set the mount level flags.
* crdup() can sleep, so do it before acquiring a mutex.
*/
newcr = crdup(kcred);
MNT_ILOCK(mp);
if (fsflags & MNT_RDONLY)
mp->mnt_flag |= MNT_RDONLY;
@ -212,10 +215,11 @@ domount(kthread_t *td, vnode_t *vp, const char *fstype, char *fspath,
* Unprivileged user can trigger mounting a snapshot, but we don't want
* him to unmount it, so we switch to privileged credentials.
*/
crfree(mp->mnt_cred);
mp->mnt_cred = crdup(kcred);
oldcr = mp->mnt_cred;
mp->mnt_cred = newcr;
mp->mnt_stat.f_owner = mp->mnt_cred->cr_uid;
MNT_IUNLOCK(mp);
crfree(oldcr);
/*
* Mount the filesystem.
* XXX The final recipients of VFS_MOUNT just overwrite the ndp they

View File

@ -163,6 +163,7 @@ domount(kthread_t *td, vnode_t *vp, const char *fstype, char *fspath,
{
struct mount *mp;
struct vfsconf *vfsp;
struct ucred *newcr, *oldcr;
int error;
/*
@ -202,7 +203,9 @@ domount(kthread_t *td, vnode_t *vp, const char *fstype, char *fspath,
/*
* Set the mount level flags.
* crdup() can sleep, so do it before acquiring a mutex.
*/
newcr = crdup(kcred);
MNT_ILOCK(mp);
if (fsflags & MNT_RDONLY)
mp->mnt_flag |= MNT_RDONLY;
@ -212,10 +215,11 @@ domount(kthread_t *td, vnode_t *vp, const char *fstype, char *fspath,
* Unprivileged user can trigger mounting a snapshot, but we don't want
* him to unmount it, so we switch to privileged credentials.
*/
crfree(mp->mnt_cred);
mp->mnt_cred = crdup(kcred);
oldcr = mp->mnt_cred;
mp->mnt_cred = newcr;
mp->mnt_stat.f_owner = mp->mnt_cred->cr_uid;
MNT_IUNLOCK(mp);
crfree(oldcr);
/*
* Mount the filesystem.
* XXX The final recipients of VFS_MOUNT just overwrite the ndp they