diff --git a/module/os/freebsd/spl/spl_vfs.c b/module/os/freebsd/spl/spl_vfs.c index 60ea627e9..3f4feb140 100644 --- a/module/os/freebsd/spl/spl_vfs.c +++ b/module/os/freebsd/spl/spl_vfs.c @@ -125,7 +125,7 @@ mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype, char *fspath, struct vfsconf *vfsp; struct mount *mp; vnode_t *vp, *mvp; - struct ucred *cr; + struct ucred *pcr, *tcr; int error; ASSERT_VOP_ELOCKED(*vpp, "mount_snapshot"); @@ -194,14 +194,18 @@ mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype, char *fspath, * mount(8) and df(1) output. */ mp->mnt_flag |= MNT_IGNORE; + /* * XXX: This is evil, but we can't mount a snapshot as a regular user. * XXX: Is is safe when snapshot is mounted from within a jail? */ - cr = td->td_ucred; + tcr = td->td_ucred; + pcr = td->td_proc->p_ucred; td->td_ucred = kcred; + td->td_proc->p_ucred = kcred; error = VFS_MOUNT(mp); - td->td_ucred = cr; + td->td_ucred = tcr; + td->td_proc->p_ucred = pcr; if (error != 0) { /*