View | Details | Raw Unified | Return to bug 275200 | Differences between
and this patch

Collapse All | Expand All

(-)sys/contrib/openzfs/include/os/freebsd/spl/sys/vfs.h (-1 / +1 lines)
Lines 101-107 void vfs_setmntopt(vfs_t *vfsp, const char *name, cons Link Here
101
void vfs_clearmntopt(vfs_t *vfsp, const char *name);
101
void vfs_clearmntopt(vfs_t *vfsp, const char *name);
102
int vfs_optionisset(const vfs_t *vfsp, const char *opt, char **argp);
102
int vfs_optionisset(const vfs_t *vfsp, const char *opt, char **argp);
103
int mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype,
103
int mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype,
104
    char *fspath, char *fspec, int fsflags);
104
    char *fspath, char *fspec, int fsflags, vfs_t *parent_vfsp);
105
105
106
typedef	uint64_t	vfs_feature_t;
106
typedef	uint64_t	vfs_feature_t;
107
107
(-)sys/contrib/openzfs/module/os/freebsd/spl/spl_vfs.c (-1 / +8 lines)
Lines 120-126 vfs_optionisset(const vfs_t *vfsp, const char *opt, ch Link Here
120
120
121
int
121
int
122
mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype, char *fspath,
122
mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype, char *fspath,
123
    char *fspec, int fsflags)
123
    char *fspec, int fsflags, vfs_t *parent_vfsp)
124
{
124
{
125
	struct vfsconf *vfsp;
125
	struct vfsconf *vfsp;
126
	struct mount *mp;
126
	struct mount *mp;
Lines 219-224 mount_snapshot(kthread_t *td, vnode_t **vpp, const cha Link Here
219
		vfs_freeopts(mp->mnt_opt);
219
		vfs_freeopts(mp->mnt_opt);
220
	mp->mnt_opt = mp->mnt_optnew;
220
	mp->mnt_opt = mp->mnt_optnew;
221
	(void) VFS_STATFS(mp, &mp->mnt_stat);
221
	(void) VFS_STATFS(mp, &mp->mnt_stat);
222
223
#ifdef VFS_SUPPORTS_EXJAIL_CLONE
224
	/*
225
	 * Clone the mnt_exjail credentials of the parent, as required.
226
	 */
227
	vfs_exjail_clone(parent_vfsp, mp);
228
#endif
222
229
223
	/*
230
	/*
224
	 * Prevent external consumers of mount options from reading
231
	 * Prevent external consumers of mount options from reading
(-)sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c (-1 / +2 lines)
Lines 1026-1032 zfsctl_snapdir_lookup(struct vop_lookup_args *ap) Link Here
1026
	    "%s/" ZFS_CTLDIR_NAME "/snapshot/%s",
1026
	    "%s/" ZFS_CTLDIR_NAME "/snapshot/%s",
1027
	    dvp->v_vfsp->mnt_stat.f_mntonname, name);
1027
	    dvp->v_vfsp->mnt_stat.f_mntonname, name);
1028
1028
1029
	err = mount_snapshot(curthread, vpp, "zfs", mountpoint, fullname, 0);
1029
	err = mount_snapshot(curthread, vpp, "zfs", mountpoint, fullname, 0,
1030
	    dvp->v_vfsp);
1030
	kmem_free(mountpoint, mountpoint_len);
1031
	kmem_free(mountpoint, mountpoint_len);
1031
	if (err == 0) {
1032
	if (err == 0) {
1032
		/*
1033
		/*
(-)sys/kern/vfs_mount.c (+35 lines)
Lines 3141-3143 resume_all_fs(void) Link Here
3141
	}
3141
	}
3142
	mtx_unlock(&mountlist_mtx);
3142
	mtx_unlock(&mountlist_mtx);
3143
}
3143
}
3144
3145
/*
3146
 * Clone the mnt_exjail field to a new mount point.
3147
 */
3148
void
3149
vfs_exjail_clone(struct mount *inmp, struct mount *outmp)
3150
{
3151
	struct ucred *cr;
3152
	struct prison *pr;
3153
3154
	MNT_ILOCK(inmp);
3155
	cr = inmp->mnt_exjail;
3156
	if (cr != NULL) {
3157
		crhold(cr);
3158
		MNT_IUNLOCK(inmp);
3159
		pr = cr->cr_prison;
3160
		sx_slock(&allprison_lock);
3161
		if (!prison_isalive(pr)) {
3162
			sx_sunlock(&allprison_lock);
3163
			crfree(cr);
3164
			return;
3165
		}
3166
		MNT_ILOCK(outmp);
3167
		if (outmp->mnt_exjail == NULL) {
3168
			outmp->mnt_exjail = cr;
3169
			atomic_add_int(&pr->pr_exportcnt, 1);
3170
			cr = NULL;
3171
		}
3172
		MNT_IUNLOCK(outmp);
3173
		sx_sunlock(&allprison_lock);
3174
		if (cr != NULL)
3175
			crfree(cr);
3176
	} else
3177
		MNT_IUNLOCK(inmp);
3178
}
(-)sys/sys/mount.h (+4 lines)
Lines 981-986 enum vfs_notify_upper_type { Link Here
981
 * exported vnode operations
981
 * exported vnode operations
982
 */
982
 */
983
983
984
/* Define this to indicate that vfs_exjail_clone() exists for ZFS to use. */
985
#define	VFS_SUPPORTS_EXJAIL_CLONE	1
986
984
int	dounmount(struct mount *, uint64_t, struct thread *);
987
int	dounmount(struct mount *, uint64_t, struct thread *);
985
988
986
int	kernel_mount(struct mntarg *ma, uint64_t flags);
989
int	kernel_mount(struct mntarg *ma, uint64_t flags);
Lines 1017-1022 int vfs_setpublicfs /* set publicly exported fs Link Here
1017
	    (struct mount *, struct netexport *, struct export_args *);
1020
	    (struct mount *, struct netexport *, struct export_args *);
1018
void	vfs_periodic(struct mount *, int);
1021
void	vfs_periodic(struct mount *, int);
1019
int	vfs_busy(struct mount *, int);
1022
int	vfs_busy(struct mount *, int);
1023
void	vfs_exjail_clone(struct mount *, struct mount *);
1020
void	vfs_exjail_delete(struct prison *);
1024
void	vfs_exjail_delete(struct prison *);
1021
int	vfs_export			 /* process mount export info */
1025
int	vfs_export			 /* process mount export info */
1022
	    (struct mount *, struct export_args *, bool);
1026
	    (struct mount *, struct export_args *, bool);

Return to bug 275200