Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F163277606
D37637.id114060.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D37637.id114060.diff
View Options
diff --git a/sys/kern/kern_jail.c.vnet b/sys/kern/kern_jail.c
--- a/sys/kern/kern_jail.c.vnet
+++ b/sys/kern/kern_jail.c
@@ -34,6 +34,7 @@
#include "opt_ddb.h"
#include "opt_inet.h"
#include "opt_inet6.h"
+#include "opt_nfs.h"
#include <sys/param.h>
#include <sys/types.h>
@@ -218,6 +219,9 @@
{"allow.unprivileged_proc_debug", "allow.nounprivileged_proc_debug",
PR_ALLOW_UNPRIV_DEBUG},
{"allow.suser", "allow.nosuser", PR_ALLOW_SUSER},
+#if defined(VNET_NFSD) && defined(VIMAGE) && defined(NFSD)
+ {"allow.nfsd", "allow.nonfsd", PR_ALLOW_NFSD},
+#endif
};
static unsigned pr_allow_all = PR_ALLOW_ALL_STATIC;
const size_t pr_flag_allow_size = sizeof(pr_flag_allow);
@@ -2102,6 +2106,13 @@
}
#endif
+#ifdef VNET_NFSD
+ if (born && pr != &prison0 && (pr->pr_allow & PR_ALLOW_NFSD) != 0 &&
+ (pr->pr_root->v_vflag & VV_ROOT) == 0)
+ printf("Warning jail jid=%d: mountd/nfsd requires a separate"
+ " file system\n", pr->pr_id);
+#endif
+
drflags &= ~PD_KILL;
td->td_retval[0] = pr->pr_id;
@@ -3464,6 +3475,29 @@
}
/*
+ * For mountd/nfsd to run within a prison, it must be:
+ * - A vnet prison.
+ * - PR_ALLOW_NFSD must be set on it.
+ * - The root directory (pr_root) of the prison must be
+ * a file system mount point, so the mountd can hang
+ * export information on it.
+ */
+bool
+prison_check_nfsd(struct ucred *cred)
+{
+
+ if (!jailed(cred))
+ return (false);
+ if (jailed_without_vnet(cred))
+ return (false);
+ if (!prison_allow(cred, PR_ALLOW_NFSD))
+ return (false);
+ if ((cred->cr_prison->pr_root->v_vflag & VV_ROOT) == 0)
+ return (false);
+ return (true);
+}
+
+/*
* Return 1 if p2 is a child of p1, otherwise 0.
*/
int
@@ -3717,11 +3751,20 @@
* is only granted conditionally in the legacy jail case.
*/
switch (priv) {
-#ifdef notyet
/*
* NFS-specific privileges.
*/
case PRIV_NFS_DAEMON:
+ case PRIV_VFS_GETFH:
+#ifdef VNET_NFSD
+ if (!prison_allow(cred, PR_ALLOW_NFSD) ||
+ (cred->cr_prison->pr_root->v_vflag & VV_ROOT) == 0)
+#else
+ printf("running nfsd in a prison requires a kernel "
+ "built with ''options VNET_NFSD''\n");
+#endif
+ return (EPERM);
+#ifdef notyet
case PRIV_NFS_LOCKD:
#endif
/*
@@ -4472,6 +4515,10 @@
"B", "Unprivileged processes may use process debugging facilities");
SYSCTL_JAIL_PARAM(_allow, suser, CTLTYPE_INT | CTLFLAG_RW,
"B", "Processes in jail with uid 0 have privilege");
+#if defined(VNET_NFSD) && defined(VIMAGE) && defined(NFSD)
+SYSCTL_JAIL_PARAM(_allow, nfsd, CTLTYPE_INT | CTLFLAG_RW,
+ "B", "Mountd/nfsd may run in the jail");
+#endif
SYSCTL_JAIL_PARAM_SUBNODE(allow, mount, "Jail mount/unmount permission flags");
SYSCTL_JAIL_PARAM(_allow_mount, , CTLTYPE_INT | CTLFLAG_RW,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jul 22, 4:22 PM (16 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35371890
Default Alt Text
D37637.id114060.diff (2 KB)
Attached To
Mode
D37637: Patch jail so that it can support mountd/nfsd in a vnet jail
Attached
Detach File
Event Timeline
Log In to Comment