diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs.8 b/cddl/contrib/opensolaris/cmd/zfs/zfs.8 index 58e986f0adcb..8ff2f367e559 100644 --- a/cddl/contrib/opensolaris/cmd/zfs/zfs.8 +++ b/cddl/contrib/opensolaris/cmd/zfs/zfs.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 26, 2011 +.Dd February 26, 2012 .Dt ZFS 8 .Os .Sh NAME @@ -413,9 +413,15 @@ subcommand. You cannot attach a dataset to one jail and the children of the same dataset to another jails. To allow management of the dataset from within a jail, the .Sy jailed -property has to be set. The +property has to be set and the jail needs access to the +.Pa /dev/zfs +device. The .Sy quota -property cannot be changed from within a jail. +property cannot be changed from within a jail. See +.Xr jail 8 +for information on how to allow mounting +.Tn ZFS +datasets from within a jail. .Pp .No A Tn ZFS dataset can be detached from a jail using the @@ -2715,13 +2721,12 @@ to the jail identified by JID From now on this file system tree can be managed from within a jail if the .Sy jailed property has been set. To use this functionality, the jail needs the -.Va enforce_statfs -parameter set to -.Sy 0 -and the .Va allow.mount -parameter set to -.Sy 1 . +and +.Va allow.mount.zfs +parameters set to 1 and the +.Va enforce_statfs +parameter set to a value lower than 2. .Pp See .Xr jail 8 diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c index 211d73f6699d..467b6a64e5e8 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c @@ -60,6 +60,7 @@ #include #include #include +#include #include "zfs_comutil.h" struct mtx zfs_debug_mtx; @@ -1533,6 +1534,9 @@ zfs_mount(vfs_t *vfsp) int error = 0; int canwrite; + if (!prison_allow(td->td_ucred, PR_ALLOW_MOUNT_ZFS)) + return (EPERM); + if (vfs_getopt(vfsp->mnt_optnew, "from", (void **)&osname, NULL)) return (EINVAL); diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index 3ba565b55892..372e0b8626f8 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -203,6 +203,7 @@ static char *pr_allow_names[] = { "allow.socket_af", "allow.mount.devfs", "allow.mount.nullfs", + "allow.mount.zfs", }; const size_t pr_allow_names_size = sizeof(pr_allow_names); @@ -216,6 +217,7 @@ static char *pr_allow_nonames[] = { "allow.nosocket_af", "allow.mount.nodevfs", "allow.mount.nonullfs", + "allow.mount.nozfs", }; const size_t pr_allow_nonames_size = sizeof(pr_allow_nonames); @@ -4199,11 +4201,15 @@ SYSCTL_PROC(_security_jail, OID_AUTO, mount_allowed, SYSCTL_PROC(_security_jail, OID_AUTO, mount_devfs_allowed, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, PR_ALLOW_MOUNT_DEVFS, sysctl_jail_default_allow, "I", - "Processes in jail can mount/unmount the devfs file system"); + "Processes in jail can mount the devfs file system"); SYSCTL_PROC(_security_jail, OID_AUTO, mount_nullfs_allowed, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, PR_ALLOW_MOUNT_NULLFS, sysctl_jail_default_allow, "I", - "Processes in jail can mount/unmount the nullfs file system"); + "Processes in jail can mount the nullfs file system"); +SYSCTL_PROC(_security_jail, OID_AUTO, mount_zfs_allowed, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, + NULL, PR_ALLOW_MOUNT_ZFS, sysctl_jail_default_allow, "I", + "Processes in jail can mount the zfs file system"); static int sysctl_jail_default_level(SYSCTL_HANDLER_ARGS) @@ -4347,9 +4353,11 @@ SYSCTL_JAIL_PARAM_SUBNODE(allow, mount, "Jail mount/unmount permission flags"); SYSCTL_JAIL_PARAM(_allow_mount, , CTLTYPE_INT | CTLFLAG_RW, "B", "Jail may mount/unmount jail-friendly file systems in general"); SYSCTL_JAIL_PARAM(_allow_mount, devfs, CTLTYPE_INT | CTLFLAG_RW, - "B", "Jail may mount/unmount the devfs file system"); + "B", "Jail may mount the devfs file system"); SYSCTL_JAIL_PARAM(_allow_mount, nullfs, CTLTYPE_INT | CTLFLAG_RW, - "B", "Jail may mount/unmount the nullfs file system"); + "B", "Jail may mount the nullfs file system"); +SYSCTL_JAIL_PARAM(_allow_mount, zfs, CTLTYPE_INT | CTLFLAG_RW, + "B", "Jail may mount the zfs file system"); void prison_racct_foreach(void (*callback)(struct racct *racct, diff --git a/sys/sys/jail.h b/sys/sys/jail.h index 7d87b84bc0d4..2e8edc654b8f 100644 --- a/sys/sys/jail.h +++ b/sys/sys/jail.h @@ -225,7 +225,8 @@ struct prison_racct { #define PR_ALLOW_SOCKET_AF 0x0040 #define PR_ALLOW_MOUNT_DEVFS 0x0080 #define PR_ALLOW_MOUNT_NULLFS 0x0100 -#define PR_ALLOW_ALL 0x01ff +#define PR_ALLOW_MOUNT_ZFS 0x0200 +#define PR_ALLOW_ALL 0x03ff /* * OSD methods diff --git a/usr.sbin/jail/jail.8 b/usr.sbin/jail/jail.8 index e1d3b2d2b79c..89910bae92a7 100644 --- a/usr.sbin/jail/jail.8 +++ b/usr.sbin/jail/jail.8 @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 23, 2012 +.Dd February 26, 2012 .Dt JAIL 8 .Os .Sh NAME @@ -427,6 +427,17 @@ This permission is effective only together with and if .Va enforce_statfs is set to a value lower than 2. +.It Va allow.mount.zfs +privileged users inside the jail will be able to mount and unmount the +ZFS file system. +This permission is effective only together with +.Va allow.mount +and if +.Va enforce_statfs +is set to a value lower than 2. See +.Xr zfs 8 +for information on how to configure the ZFS filesystem to operate from +within a jail. .It Va allow.quotas The prison root may administer quotas on the jail's filesystem(s). This includes filesystems that the jail may share with other jails or