summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_jail.c
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2009-12-13 13:57:32 +0000
committerbz <bz@FreeBSD.org>2009-12-13 13:57:32 +0000
commit932cbdbe4d3c405e08edd47627e620e9ad1b07d0 (patch)
tree8d2708fb3455d0829b95b1ddc69d4a072486bf2d /sys/kern/kern_jail.c
parent1ba3a5e4e0b1a21dd0c00df2e5223a60984e3de6 (diff)
downloadFreeBSD-src-932cbdbe4d3c405e08edd47627e620e9ad1b07d0.zip
FreeBSD-src-932cbdbe4d3c405e08edd47627e620e9ad1b07d0.tar.gz
Throughout the network stack we have a few places of
if (jailed(cred)) left. If you are running with a vnet (virtual network stack) those will return true and defer you to classic IP-jails handling and thus things will be "denied" or returned with an error. Work around this problem by introducing another "jailed()" function, jailed_without_vnet(), that also takes vnets into account, and permits the calls, should the jail from the given cred have its own virtual network stack. We cannot change the classic jailed() call to do that, as it is used outside the network stack as well. Discussed with: julian, zec, jamie, rwatson (back in Sept) MFC after: 5 days
Diffstat (limited to 'sys/kern/kern_jail.c')
-rw-r--r--sys/kern/kern_jail.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c
index 0cc330c..0900541 100644
--- a/sys/kern/kern_jail.c
+++ b/sys/kern/kern_jail.c
@@ -3161,7 +3161,7 @@ prison_check_af(struct ucred *cred, int af)
pr = cred->cr_prison;
#ifdef VIMAGE
/* Prisons with their own network stack are not limited. */
- if (pr->pr_flags & PR_VNET)
+ if (prison_owns_vnet(cred))
return (0);
#endif
@@ -3222,6 +3222,11 @@ prison_if(struct ucred *cred, struct sockaddr *sa)
KASSERT(cred != NULL, ("%s: cred is NULL", __func__));
KASSERT(sa != NULL, ("%s: sa is NULL", __func__));
+#ifdef VIMAGE
+ if (prison_owns_vnet(cred))
+ return (0);
+#endif
+
error = 0;
switch (sa->sa_family)
{
@@ -3279,6 +3284,24 @@ jailed(struct ucred *cred)
}
/*
+ * Return 1 if the passed credential is in a jail and that jail does not
+ * have its own virtual network stack, otherwise 0.
+ */
+int
+jailed_without_vnet(struct ucred *cred)
+{
+
+ if (!jailed(cred))
+ return (0);
+#ifdef VIMAGE
+ if (prison_owns_vnet(cred))
+ return (0);
+#endif
+
+ return (1);
+}
+
+/*
* Return the correct hostname (domainname, et al) for the passed credential.
*/
void
OpenPOWER on IntegriCloud