summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_subr.c
diff options
context:
space:
mode:
authorjamie <jamie@FreeBSD.org>2009-05-27 14:11:23 +0000
committerjamie <jamie@FreeBSD.org>2009-05-27 14:11:23 +0000
commita013e0afcbb44052a86a7977277d669d8883b7e7 (patch)
treeb7f782d79e61a1bd80655a068684cb0fd9f39922 /sys/kern/vfs_subr.c
parent6e53147404a7f4fb4173694bc812d9d23efd9fef (diff)
downloadFreeBSD-src-a013e0afcbb44052a86a7977277d669d8883b7e7.zip
FreeBSD-src-a013e0afcbb44052a86a7977277d669d8883b7e7.tar.gz
Add hierarchical jails. A jail may further virtualize its environment
by creating a child jail, which is visible to that jail and to any parent jails. Child jails may be restricted more than their parents, but never less. Jail names reflect this hierarchy, being MIB-style dot-separated strings. Every thread now points to a jail, the default being prison0, which contains information about the physical system. Prison0's root directory is the same as rootvnode; its hostname is the same as the global hostname, and its securelevel replaces the global securelevel. Note that the variable "securelevel" has actually gone away, which should not cause any problems for code that properly uses securelevel_gt() and securelevel_ge(). Some jail-related permissions that were kept in global variables and set via sysctls are now per-jail settings. The sysctls still exist for backward compatibility, used only by the now-deprecated jail(2) system call. Approved by: bz (mentor)
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r--sys/kern/vfs_subr.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 8c26b131..05d9de5 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -467,22 +467,14 @@ vfs_suser(struct mount *mp, struct thread *td)
return (EPERM);
/*
- * If the file system was mounted outside a jail and a jailed thread
- * tries to access it, deny immediately.
+ * If the file system was mounted outside the jail of the calling
+ * thread, deny immediately.
*/
- if (!jailed(mp->mnt_cred) && jailed(td->td_ucred))
+ if (mp->mnt_cred->cr_prison != td->td_ucred->cr_prison &&
+ !prison_ischild(td->td_ucred->cr_prison, mp->mnt_cred->cr_prison))
return (EPERM);
/*
- * If the file system was mounted inside different jail that the jail of
- * the calling thread, deny immediately.
- */
- if (jailed(mp->mnt_cred) && jailed(td->td_ucred) &&
- mp->mnt_cred->cr_prison != td->td_ucred->cr_prison) {
- return (EPERM);
- }
-
- /*
* If file system supports delegated administration, we don't check
* for the PRIV_VFS_MOUNT_OWNER privilege - it will be better verified
* by the file system itself.
@@ -2900,7 +2892,7 @@ DB_SHOW_COMMAND(mount, db_show_mount)
db_printf(" mnt_cred = { uid=%u ruid=%u",
(u_int)mp->mnt_cred->cr_uid, (u_int)mp->mnt_cred->cr_ruid);
- if (mp->mnt_cred->cr_prison != NULL)
+ if (jailed(mp->mnt_cred))
db_printf(", jail=%d", mp->mnt_cred->cr_prison->pr_id);
db_printf(" }\n");
db_printf(" mnt_ref = %d\n", mp->mnt_ref);
OpenPOWER on IntegriCloud