diff --git a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c index d87a57ad514b..f375a184d1cc 100644 --- a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c +++ b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c @@ -478,7 +478,12 @@ rpc_gss_svc_getcred(struct svc_req *req, struct ucred **crp, int *flavorp) cr->cr_uid = cr->cr_ruid = cr->cr_svuid = uc->uid; cr->cr_rgid = cr->cr_svgid = uc->gid; crsetgroups(cr, uc->gidlen, uc->gidlist); - cr->cr_prison = &prison0; +#ifdef VNET_NFSD + if (jailed(curthread->td_ucred)) + cr->cr_prison = curthread->td_ucred->cr_prison; + else +#endif + cr->cr_prison = &prison0; prison_hold(cr->cr_prison); *crp = crhold(cr); diff --git a/sys/rpc/svc.c b/sys/rpc/svc.c index be0f08ebca9d..065da0cc23a4 100644 --- a/sys/rpc/svc.c +++ b/sys/rpc/svc.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); */ #include +#include #include #include #include @@ -126,7 +127,7 @@ svcpool_create(const char *name, struct sysctl_oid_list *sysctl_base) pool->sp_space_low = (pool->sp_space_high / 3) * 2; sysctl_ctx_init(&pool->sp_sysctl); - if (sysctl_base) { + if (!jailed(curthread->td_ucred) && sysctl_base) { SYSCTL_ADD_PROC(&pool->sp_sysctl, sysctl_base, OID_AUTO, "minthreads", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, pool, 0, svcpool_minthread_sysctl, "I", diff --git a/sys/rpc/svc_auth.c b/sys/rpc/svc_auth.c index 21149139b5a5..a5c9753c4fde 100644 --- a/sys/rpc/svc_auth.c +++ b/sys/rpc/svc_auth.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -197,7 +198,12 @@ svc_getcred(struct svc_req *rqst, struct ucred **crp, int *flavorp) cr->cr_uid = cr->cr_ruid = cr->cr_svuid = xprt->xp_uid; crsetgroups(cr, xprt->xp_ngrps, xprt->xp_gidp); cr->cr_rgid = cr->cr_svgid = xprt->xp_gidp[0]; - cr->cr_prison = &prison0; +#ifdef VNET_NFSD + if (jailed(curthread->td_ucred)) + cr->cr_prison = curthread->td_ucred->cr_prison; + else +#endif + cr->cr_prison = &prison0; prison_hold(cr->cr_prison); *crp = cr; return (TRUE); @@ -210,7 +216,12 @@ svc_getcred(struct svc_req *rqst, struct ucred **crp, int *flavorp) cr->cr_uid = cr->cr_ruid = cr->cr_svuid = xcr->cr_uid; crsetgroups(cr, xcr->cr_ngroups, xcr->cr_groups); cr->cr_rgid = cr->cr_svgid = cr->cr_groups[0]; - cr->cr_prison = &prison0; +#ifdef VNET_NFSD + if (jailed(curthread->td_ucred)) + cr->cr_prison = curthread->td_ucred->cr_prison; + else +#endif + cr->cr_prison = &prison0; prison_hold(cr->cr_prison); *crp = cr; return (TRUE); diff --git a/sys/rpc/svc_dg.c b/sys/rpc/svc_dg.c index 4ab86bb5904a..bf3cbd2a6137 100644 --- a/sys/rpc/svc_dg.c +++ b/sys/rpc/svc_dg.c @@ -45,11 +45,13 @@ __FBSDID("$FreeBSD$"); */ #include +#include #include #include #include #include #include +#include #include #include #include @@ -104,6 +106,8 @@ svc_dg_create(SVCPOOL *pool, struct socket *so, size_t sendsize, struct sockaddr* sa; int error; + if (jailed(curthread->td_ucred)) + return (NULL); if (!__rpc_socket2sockinfo(so, &si)) { printf(svc_dg_str, svc_dg_err1); return (NULL);