44 #include <sys/cdefs.h>
47 #include "opt_compat.h"
49 #include "opt_inet6.h"
51 #include <sys/param.h>
52 #include <sys/systm.h>
55 #include <sys/kernel.h>
57 #include <sys/loginclass.h>
58 #include <sys/malloc.h>
59 #include <sys/mutex.h>
60 #include <sys/refcount.h>
64 #include <sys/sysproto.h>
66 #include <sys/pioctl.h>
67 #include <sys/racct.h>
68 #include <sys/resourcevar.h>
69 #include <sys/socket.h>
70 #include <sys/socketvar.h>
71 #include <sys/syscallsubr.h>
72 #include <sys/sysctl.h>
76 "Kernel support for interfaces nessesary for regression testing (SECURITY RISK!)");
79 #if defined(INET) || defined(INET6)
80 #include <netinet/in.h>
81 #include <netinet/in_pcb.h>
84 #include <security/audit/audit.h>
85 #include <security/mac/mac_framework.h>
89 SYSCTL_NODE(_security, OID_AUTO, bsd, CTLFLAG_RW, 0,
"BSD security policy");
94 #ifndef _SYS_SYSPROTO_H_
103 struct proc *p = td->td_proc;
105 td->td_retval[0] = p->p_pid;
106 #if defined(COMPAT_43)
108 td->td_retval[1] = p->p_pptr->p_pid;
114 #ifndef _SYS_SYSPROTO_H_
123 struct proc *p = td->td_proc;
126 td->td_retval[0] = p->p_pptr->p_pid;
134 #ifndef _SYS_SYSPROTO_H_
142 struct proc *p = td->td_proc;
145 td->td_retval[0] = p->p_pgrp->pg_id;
151 #ifndef _SYS_SYSPROTO_H_
175 td->td_retval[0] = p->p_pgrp->pg_id;
183 #ifndef _SYS_SYSPROTO_H_
207 td->td_retval[0] = p->p_session->s_sid;
212 #ifndef _SYS_SYSPROTO_H_
222 td->td_retval[0] = td->td_ucred->cr_ruid;
223 #if defined(COMPAT_43)
224 td->td_retval[1] = td->td_ucred->cr_uid;
229 #ifndef _SYS_SYSPROTO_H_
239 td->td_retval[0] = td->td_ucred->cr_uid;
243 #ifndef _SYS_SYSPROTO_H_
253 td->td_retval[0] = td->td_ucred->cr_rgid;
254 #if defined(COMPAT_43)
255 td->td_retval[1] = td->td_ucred->cr_groups[0];
265 #ifndef _SYS_SYSPROTO_H_
275 td->td_retval[0] = td->td_ucred->cr_groups[0];
279 #ifndef _SYS_SYSPROTO_H_
292 if (uap->
gidsetsize < td->td_ucred->cr_ngroups) {
298 ngrp = td->td_ucred->cr_ngroups;
299 groups =
malloc(ngrp *
sizeof(*groups), M_TEMP, M_WAITOK);
304 error = copyout(groups, uap->
gidset, ngrp *
sizeof(gid_t));
306 td->td_retval[0] = ngrp;
308 free(groups, M_TEMP);
319 *ngrp = cred->cr_ngroups;
322 if (*ngrp < cred->cr_ngroups)
324 *ngrp = cred->cr_ngroups;
325 bcopy(cred->cr_groups, groups, *ngrp *
sizeof(gid_t));
329 #ifndef _SYS_SYSPROTO_H_
340 struct proc *p = td->td_proc;
341 struct pgrp *newpgrp;
342 struct session *newsess;
347 newpgrp =
malloc(
sizeof(
struct pgrp), M_PGRP, M_WAITOK | M_ZERO);
348 newsess =
malloc(
sizeof(
struct session), M_SESSION, M_WAITOK | M_ZERO);
352 if (p->p_pgid == p->p_pid || (pgrp =
pgfind(p->p_pid)) != NULL) {
357 (void)
enterpgrp(p, p->p_pid, newpgrp, newsess);
358 td->td_retval[0] = p->p_pid;
366 free(newpgrp, M_PGRP);
368 free(newsess, M_SESSION);
386 #ifndef _SYS_SYSPROTO_H_
396 struct proc *curp = td->td_proc;
397 register struct proc *targp;
398 register struct pgrp *pgrp;
400 struct pgrp *newpgrp;
407 newpgrp =
malloc(
sizeof(
struct pgrp), M_PGRP, M_WAITOK | M_ZERO);
410 if (uap->
pid != 0 && uap->
pid != curp->p_pid) {
411 if ((targp =
pfind(uap->
pid)) == NULL) {
420 if ((error =
p_cansee(td, targp))) {
424 if (targp->p_pgrp == NULL ||
425 targp->p_session != curp->p_session) {
430 if (targp->p_flag & P_EXEC) {
438 if (SESS_LEADER(targp)) {
443 uap->
pgid = targp->p_pid;
445 if (uap->
pgid == targp->p_pid) {
453 if (pgrp == targp->p_pgrp) {
457 if (pgrp->pg_id != targp->p_pid &&
458 pgrp->pg_session != curp->p_session) {
468 KASSERT((error == 0) || (newpgrp != NULL),
469 (
"setpgid failed and newpgrp is NULL"));
471 free(newpgrp, M_PGRP);
485 #define POSIX_APPENDIX_B_4_2_2
487 #ifndef _SYS_SYSPROTO_H_
496 struct proc *p = td->td_proc;
497 struct ucred *newcred, *oldcred;
513 error = mac_cred_check_setuid(oldcred, uid);
535 if (uid != oldcred->cr_ruid &&
536 #ifdef _POSIX_SAVED_IDS
537 uid != oldcred->cr_svuid &&
540 uid != oldcred->cr_uid &&
545 #ifdef _POSIX_SAVED_IDS
552 uid == oldcred->cr_uid ||
561 if (uid != oldcred->cr_ruid) {
572 if (uid != oldcred->cr_svuid) {
581 if (uid != oldcred->cr_uid) {
585 p->p_ucred = newcred;
588 racct_proc_ucred_changed(p, oldcred, newcred);
601 #ifndef _SYS_SYSPROTO_H_
610 struct proc *p = td->td_proc;
611 struct ucred *newcred, *oldcred;
613 struct uidinfo *euip;
617 AUDIT_ARG_EUID(euid);
627 error = mac_cred_check_seteuid(oldcred, euid);
632 if (euid != oldcred->cr_ruid &&
633 euid != oldcred->cr_svuid &&
640 if (oldcred->cr_uid != euid) {
644 p->p_ucred = newcred;
657 #ifndef _SYS_SYSPROTO_H_
666 struct proc *p = td->td_proc;
667 struct ucred *newcred, *oldcred;
678 error = mac_cred_check_setgid(oldcred, gid);
694 if (gid != oldcred->cr_rgid &&
695 #ifdef _POSIX_SAVED_IDS
696 gid != oldcred->cr_svgid &&
699 gid != oldcred->cr_groups[0] &&
704 #ifdef _POSIX_SAVED_IDS
711 gid == oldcred->cr_groups[0] ||
720 if (oldcred->cr_rgid != gid) {
731 if (oldcred->cr_svgid != gid) {
740 if (oldcred->cr_groups[0] != gid) {
744 p->p_ucred = newcred;
755 #ifndef _SYS_SYSPROTO_H_
764 struct proc *p = td->td_proc;
765 struct ucred *newcred, *oldcred;
770 AUDIT_ARG_EGID(egid);
776 error = mac_cred_check_setegid(oldcred, egid);
781 if (egid != oldcred->cr_rgid &&
782 egid != oldcred->cr_svgid &&
786 if (oldcred->cr_groups[0] != egid) {
790 p->p_ucred = newcred;
801 #ifndef _SYS_SYSPROTO_H_
811 gid_t *groups = NULL;
822 free(groups, M_TEMP);
829 struct proc *p = td->td_proc;
830 struct ucred *newcred, *oldcred;
835 AUDIT_ARG_GROUPSET(groups, ngrp);
842 error = mac_cred_check_setgroups(oldcred, ngrp, groups);
858 newcred->cr_ngroups = 1;
863 p->p_ucred = newcred;
874 #ifndef _SYS_SYSPROTO_H_
884 struct proc *p = td->td_proc;
885 struct ucred *newcred, *oldcred;
887 struct uidinfo *euip, *ruip;
892 AUDIT_ARG_EUID(euid);
893 AUDIT_ARG_RUID(ruid);
901 error = mac_cred_check_setreuid(oldcred, ruid, euid);
906 if (((ruid != (uid_t)-1 && ruid != oldcred->cr_ruid &&
907 ruid != oldcred->cr_svuid) ||
908 (euid != (uid_t)-1 && euid != oldcred->cr_uid &&
909 euid != oldcred->cr_ruid && euid != oldcred->cr_svuid)) &&
913 if (euid != (uid_t)-1 && oldcred->cr_uid != euid) {
917 if (ruid != (uid_t)-1 && oldcred->cr_ruid != ruid) {
921 if ((ruid != (uid_t)-1 || newcred->cr_uid != newcred->cr_ruid) &&
922 newcred->cr_svuid != newcred->cr_uid) {
926 p->p_ucred = newcred;
929 racct_proc_ucred_changed(p, oldcred, newcred);
944 #ifndef _SYS_SYSPROTO_H_
954 struct proc *p = td->td_proc;
955 struct ucred *newcred, *oldcred;
961 AUDIT_ARG_EGID(egid);
962 AUDIT_ARG_RGID(rgid);
968 error = mac_cred_check_setregid(oldcred, rgid, egid);
973 if (((rgid != (gid_t)-1 && rgid != oldcred->cr_rgid &&
974 rgid != oldcred->cr_svgid) ||
975 (egid != (gid_t)-1 && egid != oldcred->cr_groups[0] &&
976 egid != oldcred->cr_rgid && egid != oldcred->cr_svgid)) &&
980 if (egid != (gid_t)-1 && oldcred->cr_groups[0] != egid) {
984 if (rgid != (gid_t)-1 && oldcred->cr_rgid != rgid) {
988 if ((rgid != (gid_t)-1 || newcred->cr_groups[0] != newcred->cr_rgid) &&
989 newcred->cr_svgid != newcred->cr_groups[0]) {
993 p->p_ucred = newcred;
1008 #ifndef _SYS_SYSPROTO_H_
1019 struct proc *p = td->td_proc;
1020 struct ucred *newcred, *oldcred;
1021 uid_t euid, ruid, suid;
1022 struct uidinfo *euip, *ruip;
1028 AUDIT_ARG_EUID(euid);
1029 AUDIT_ARG_RUID(ruid);
1030 AUDIT_ARG_SUID(suid);
1038 error = mac_cred_check_setresuid(oldcred, ruid, euid, suid);
1043 if (((ruid != (uid_t)-1 && ruid != oldcred->cr_ruid &&
1044 ruid != oldcred->cr_svuid &&
1045 ruid != oldcred->cr_uid) ||
1046 (euid != (uid_t)-1 && euid != oldcred->cr_ruid &&
1047 euid != oldcred->cr_svuid &&
1048 euid != oldcred->cr_uid) ||
1049 (suid != (uid_t)-1 && suid != oldcred->cr_ruid &&
1050 suid != oldcred->cr_svuid &&
1051 suid != oldcred->cr_uid)) &&
1055 if (euid != (uid_t)-1 && oldcred->cr_uid != euid) {
1059 if (ruid != (uid_t)-1 && oldcred->cr_ruid != ruid) {
1063 if (suid != (uid_t)-1 && oldcred->cr_svuid != suid) {
1067 p->p_ucred = newcred;
1070 racct_proc_ucred_changed(p, oldcred, newcred);
1090 #ifndef _SYS_SYSPROTO_H_
1101 struct proc *p = td->td_proc;
1102 struct ucred *newcred, *oldcred;
1103 gid_t egid, rgid, sgid;
1109 AUDIT_ARG_EGID(egid);
1110 AUDIT_ARG_RGID(rgid);
1111 AUDIT_ARG_SGID(sgid);
1117 error = mac_cred_check_setresgid(oldcred, rgid, egid, sgid);
1122 if (((rgid != (gid_t)-1 && rgid != oldcred->cr_rgid &&
1123 rgid != oldcred->cr_svgid &&
1124 rgid != oldcred->cr_groups[0]) ||
1125 (egid != (gid_t)-1 && egid != oldcred->cr_rgid &&
1126 egid != oldcred->cr_svgid &&
1127 egid != oldcred->cr_groups[0]) ||
1128 (sgid != (gid_t)-1 && sgid != oldcred->cr_rgid &&
1129 sgid != oldcred->cr_svgid &&
1130 sgid != oldcred->cr_groups[0])) &&
1134 if (egid != (gid_t)-1 && oldcred->cr_groups[0] != egid) {
1138 if (rgid != (gid_t)-1 && oldcred->cr_rgid != rgid) {
1142 if (sgid != (gid_t)-1 && oldcred->cr_svgid != sgid) {
1146 p->p_ucred = newcred;
1157 #ifndef _SYS_SYSPROTO_H_
1169 int error1 = 0, error2 = 0, error3 = 0;
1171 cred = td->td_ucred;
1173 error1 = copyout(&cred->cr_ruid,
1174 uap->
ruid,
sizeof(cred->cr_ruid));
1176 error2 = copyout(&cred->cr_uid,
1177 uap->
euid,
sizeof(cred->cr_uid));
1179 error3 = copyout(&cred->cr_svuid,
1180 uap->
suid,
sizeof(cred->cr_svuid));
1181 return (error1 ? error1 : error2 ? error2 : error3);
1184 #ifndef _SYS_SYSPROTO_H_
1196 int error1 = 0, error2 = 0, error3 = 0;
1198 cred = td->td_ucred;
1200 error1 = copyout(&cred->cr_rgid,
1201 uap->
rgid,
sizeof(cred->cr_rgid));
1203 error2 = copyout(&cred->cr_groups[0],
1204 uap->
egid,
sizeof(cred->cr_groups[0]));
1206 error3 = copyout(&cred->cr_svgid,
1207 uap->
sgid,
sizeof(cred->cr_svgid));
1208 return (error1 ? error1 : error2 ? error2 : error3);
1211 #ifndef _SYS_SYSPROTO_H_
1220 struct proc *p = td->td_proc;
1231 td->td_retval[0] = (p->p_flag & P_SUGID) ? 1 : 0;
1243 switch (uap->flag) {
1246 p->p_flag &= ~P_SUGID;
1251 p->p_flag |= P_SUGID;
1273 if (cred->cr_groups[0] == gid)
1282 h = cred->cr_ngroups;
1284 m = l + ((h - l) / 2);
1285 if (cred->cr_groups[m] < gid)
1290 if ((l < cred->cr_ngroups) && (cred->cr_groups[l] == gid))
1313 return (cr->cr_prison->pr_securelevel > level ? EPERM : 0);
1320 return (cr->cr_prison->pr_securelevel >= level ? EPERM : 0);
1332 "Unprivileged processes may see subjects/objects with different real uid");
1362 "Unprivileged processes may see subjects/objects with different real gid");
1379 for (i = 0; i < u1->cr_ngroups; i++) {
1408 if ((error = mac_cred_check_visible(u1, u2)))
1430 KASSERT(td == curthread, (
"%s: td not curthread", __func__));
1431 PROC_LOCK_ASSERT(p, MA_OWNED);
1432 return (
cr_cansee(td->td_ucred, p->p_ucred));
1448 "sending certain signals to processes whose credentials have changed");
1460 PROC_LOCK_ASSERT(proc, MA_OWNED);
1469 if ((error = mac_proc_check_signal(cred, proc, signum)))
1513 if (cred->cr_ruid != proc->p_ucred->cr_ruid &&
1514 cred->cr_ruid != proc->p_ucred->cr_svuid &&
1515 cred->cr_uid != proc->p_ucred->cr_ruid &&
1516 cred->cr_uid != proc->p_ucred->cr_svuid) {
1537 KASSERT(td == curthread, (
"%s: td not curthread", __func__));
1538 PROC_LOCK_ASSERT(p, MA_OWNED);
1539 if (td->td_proc == p)
1548 if (signum == SIGCONT && td->td_proc->p_session == p->p_session)
1559 if (td->td_proc->p_leader != NULL && signum >= SIGTHR &&
1560 signum < SIGTHR + 4 && td->td_proc->p_leader == p->p_leader)
1579 KASSERT(td == curthread, (
"%s: td not curthread", __func__));
1580 PROC_LOCK_ASSERT(p, MA_OWNED);
1581 if (td->td_proc == p)
1586 if ((error = mac_proc_check_sched(td->td_ucred, p)))
1593 if (td->td_ucred->cr_ruid != p->p_ucred->cr_ruid &&
1594 td->td_ucred->cr_uid != p->p_ucred->cr_ruid) {
1616 "Unprivileged processes may use process debugging facilities");
1629 int credentialchanged, error, grpsubset, i, uidsubset;
1631 KASSERT(td == curthread, (
"%s: td not curthread", __func__));
1632 PROC_LOCK_ASSERT(p, MA_OWNED);
1638 if (td->td_proc == p)
1643 if ((error = mac_proc_check_debug(td->td_ucred, p)))
1656 for (i = 0; i < p->p_ucred->cr_ngroups; i++) {
1657 if (!
groupmember(p->p_ucred->cr_groups[i], td->td_ucred)) {
1662 grpsubset = grpsubset &&
1670 uidsubset = (td->td_ucred->cr_uid == p->p_ucred->cr_uid &&
1671 td->td_ucred->cr_uid == p->p_ucred->cr_svuid &&
1672 td->td_ucred->cr_uid == p->p_ucred->cr_ruid);
1677 credentialchanged = (p->p_flag & P_SUGID);
1684 if (!grpsubset || !uidsubset) {
1690 if (credentialchanged) {
1710 if ((p->p_flag & P_INEXEC) != 0)
1729 error = mac_socket_check_visible(cred, so);
1741 #if defined(INET) || defined(INET6)
1747 cr_canseeinpcb(
struct ucred *cred,
struct inpcb *inp)
1755 INP_LOCK_ASSERT(inp);
1756 error = mac_inpcb_check_visible(cred, inp);
1783 KASSERT(td == curthread, (
"%s: td not curthread", __func__));
1784 PROC_LOCK_ASSERT(p, MA_OWNED);
1788 if ((error = mac_proc_check_wait(td->td_ucred, p)))
1806 register struct ucred *cr;
1808 cr =
malloc(
sizeof(*cr), M_CRED, M_WAITOK | M_ZERO);
1809 refcount_init(&cr->cr_ref, 1);
1811 audit_cred_init(cr);
1827 refcount_acquire(&cr->cr_ref);
1838 KASSERT(cr->cr_ref > 0, (
"bad ucred refcount: %d", cr->cr_ref));
1839 KASSERT(cr->cr_ref != 0xdeadc0de, (
"dangling reference to ucred"));
1840 if (refcount_release(&cr->cr_ref)) {
1846 if (cr->cr_uidinfo != NULL)
1848 if (cr->cr_ruidinfo != NULL)
1853 if (cr->cr_prison != NULL)
1855 if (cr->cr_loginclass != NULL)
1858 audit_cred_destroy(cr);
1861 mac_cred_destroy(cr);
1863 free(cr->cr_groups, M_CRED);
1875 return (cr->cr_ref > 1);
1882 crcopy(
struct ucred *dest,
struct ucred *src)
1885 KASSERT(
crshared(dest) == 0, (
"crcopy of shared ucred"));
1886 bcopy(&src->cr_startcopy, &dest->cr_startcopy,
1887 (
unsigned)((caddr_t)&src->cr_endcopy -
1888 (caddr_t)&src->cr_startcopy));
1889 crsetgroups(dest, src->cr_ngroups, src->cr_groups);
1890 uihold(dest->cr_uidinfo);
1891 uihold(dest->cr_ruidinfo);
1893 loginclass_hold(dest->cr_loginclass);
1895 audit_cred_copy(src, dest);
1898 mac_cred_copy(src, dest);
1908 struct ucred *newcr;
1919 cru2x(
struct ucred *cr,
struct xucred *xcr)
1923 bzero(xcr,
sizeof(*xcr));
1924 xcr->cr_version = XUCRED_VERSION;
1925 xcr->cr_uid = cr->cr_uid;
1927 ngroups = MIN(cr->cr_ngroups, XU_NGROUPS);
1928 xcr->cr_ngroups = ngroups;
1929 bcopy(cr->cr_groups, xcr->cr_groups,
1930 ngroups *
sizeof(*cr->cr_groups));
1944 cred = td->td_ucred;
1946 td->td_ucred =
crhold(p->p_ucred);
1955 struct ucred *oldcred;
1958 PROC_LOCK_ASSERT(p, MA_OWNED);
1960 oldcred = p->p_ucred;
1961 while (cr->cr_agroups < oldcred->cr_agroups) {
1962 groups = oldcred->cr_agroups;
1966 oldcred = p->p_ucred;
1982 if (n <= cr->cr_agroups)
1994 if ( n < PAGE_SIZE /
sizeof(gid_t) ) {
1995 if (cr->cr_agroups == 0)
1996 cnt = MINALLOCSIZE /
sizeof(gid_t);
1998 cnt = cr->cr_agroups * 2;
2003 cnt = roundup2(n, PAGE_SIZE /
sizeof(gid_t));
2007 free(cr->cr_groups, M_CRED);
2009 cr->cr_groups =
malloc(cnt *
sizeof(gid_t), M_CRED, M_WAITOK | M_ZERO);
2010 cr->cr_agroups = cnt;
2026 KASSERT(cr->cr_agroups >= ngrp, (
"cr_ngroups is too small"));
2028 bcopy(groups, cr->cr_groups, ngrp *
sizeof(gid_t));
2029 cr->cr_ngroups = ngrp;
2039 for (i = 2; i < ngrp; i++) {
2040 g = cr->cr_groups[i];
2041 for (j = i-1; j >= 1 && g < cr->cr_groups[j]; j--)
2042 cr->cr_groups[j + 1] = cr->cr_groups[j];
2043 cr->cr_groups[j + 1] = g;
2065 #ifndef _SYS_SYSPROTO_H_
2075 char login[MAXLOGNAME];
2076 struct proc *p = td->td_proc;
2079 if (uap->
namelen > MAXLOGNAME)
2082 SESS_LOCK(p->p_session);
2083 len = strlcpy(login, p->p_session->s_login, uap->
namelen) + 1;
2084 SESS_UNLOCK(p->p_session);
2088 return (copyout(login, uap->
namebuf, len));
2094 #ifndef _SYS_SYSPROTO_H_
2103 struct proc *p = td->td_proc;
2105 char logintmp[MAXLOGNAME];
2107 CTASSERT(
sizeof(p->p_session->s_login) >=
sizeof(logintmp));
2112 error = copyinstr(uap->
namebuf, logintmp,
sizeof(logintmp), NULL);
2114 if (error == ENAMETOOLONG)
2119 SESS_LOCK(p->p_session);
2120 strcpy(p->p_session->s_login, logintmp);
2121 SESS_UNLOCK(p->p_session);
2130 PROC_LOCK_ASSERT(p, MA_OWNED);
2131 p->p_flag |= P_SUGID;
2132 if (!(p->p_pfsflags & PF_ISUGID))
2146 newcred->cr_uid = euip->ui_uid;
2148 uifree(newcred->cr_uidinfo);
2149 newcred->cr_uidinfo = euip;
2162 newcred->cr_groups[0] = egid;
2177 (void)
chgproccnt(newcred->cr_ruidinfo, -1, 0);
2178 newcred->cr_ruid = ruip->ui_uid;
2180 uifree(newcred->cr_ruidinfo);
2181 newcred->cr_ruidinfo = ruip;
2182 (void)
chgproccnt(newcred->cr_ruidinfo, 1, 0);
2195 newcred->cr_rgid = rgid;
2208 newcred->cr_svuid = svuid;
2221 newcred->cr_svgid = svgid;
int sys_setuid(struct thread *td, struct setuid_args *uap)
int cr_cansee(struct ucred *u1, struct ucred *u2)
int p_canwait(struct thread *td, struct proc *p)
void change_svgid(struct ucred *newcred, gid_t svgid)
int enterpgrp(struct proc *p, pid_t pgid, struct pgrp *pgrp, struct session *sess)
void cred_update_thread(struct thread *td)
void uifree(struct uidinfo *uip)
static int conservative_signals
void cru2x(struct ucred *cr, struct xucred *xcr)
int priv_check_cred(struct ucred *cred, int priv, int flags)
void change_svuid(struct ucred *newcred, uid_t svuid)
int sys_getegid(struct thread *td, struct getegid_args *uap)
int sys_getsid(struct thread *td, struct getsid_args *uap)
int p_candebug(struct thread *td, struct proc *p)
SYSCTL_NODE(_security, OID_AUTO, bsd, CTLFLAG_RW, 0,"BSD security policy")
void * malloc(unsigned long size, struct malloc_type *mtp, int flags)
int sys_setregid(register struct thread *td, struct setregid_args *uap)
int p_cansignal(struct thread *td, struct proc *p, int signum)
int sys_getgid(struct thread *td, struct getgid_args *uap)
struct uidinfo * uifind(uid_t uid)
int sys_geteuid(struct thread *td, struct geteuid_args *uap)
CTASSERT(MAXSHELLCMDLEN >=MAXINTERP+3)
int kern_setgroups(struct thread *td, u_int ngrp, gid_t *groups)
int sys_getpid(struct thread *td, struct getpid_args *uap)
int sys_setresgid(register struct thread *td, struct setresgid_args *uap)
int prison_check(struct ucred *cred1, struct ucred *cred2)
static int see_other_gids
static MALLOC_DEFINE(M_CRED,"cred","credentials")
int sys_getgroups(struct thread *td, register struct getgroups_args *uap)
int sys_getresgid(register struct thread *td, struct getresgid_args *uap)
void setsugid(struct proc *p)
struct ucred * crcopysafe(struct proc *p, struct ucred *cr)
int sys_getppid(struct thread *td, struct getppid_args *uap)
int sys_issetugid(register struct thread *td, struct issetugid_args *uap)
#define POSIX_APPENDIX_B_4_2_2
int crshared(struct ucred *cr)
void uihold(struct uidinfo *uip)
void change_rgid(struct ucred *newcred, gid_t rgid)
int priv_check(struct thread *td, int priv)
struct proc * pfind(pid_t pid)
int inferior(struct proc *p)
int enterthispgrp(struct proc *p, struct pgrp *pgrp)
int securelevel_ge(struct ucred *cr, int level)
void change_ruid(struct ucred *newcred, struct uidinfo *ruip)
static int unprivileged_proc_debug
int chgproccnt(struct uidinfo *uip, int diff, rlim_t max)
void crfree(struct ucred *cr)
void prison_hold(struct prison *pr)
int sys_getpgrp(struct thread *td, struct getpgrp_args *uap)
int sys_getresuid(register struct thread *td, struct getresuid_args *uap)
int cr_cansignal(struct ucred *cred, struct proc *proc, int signum)
static int cr_seeothergids(struct ucred *u1, struct ucred *u2)
struct pgrp * pgfind(pid_t pgid)
SYSCTL_INT(_security_bsd, OID_AUTO, see_other_uids, CTLFLAG_RW,&see_other_uids, 0,"Unprivileged processes may see subjects/objects with different real uid")
int sys_setsid(register struct thread *td, struct setsid_args *uap)
int sys_setresuid(register struct thread *td, struct setresuid_args *uap)
static void crsetgroups_locked(struct ucred *cr, int ngrp, gid_t *groups)
int sys_setgroups(struct thread *td, struct setgroups_args *uap)
struct ucred * crhold(struct ucred *cr)
int groupmember(gid_t gid, struct ucred *cred)
void prison_free(struct prison *pr)
void free(void *addr, struct malloc_type *mtp)
void crsetgroups(struct ucred *cr, int ngrp, gid_t *groups)
struct ucred * crdup(struct ucred *cr)
int sys_getpgid(struct thread *td, struct getpgid_args *uap)
int sys_setlogin(struct thread *td, struct setlogin_args *uap)
int sys_setreuid(register struct thread *td, struct setreuid_args *uap)
int sys_setpgid(struct thread *td, register struct setpgid_args *uap)
static int see_other_uids
void change_euid(struct ucred *newcred, struct uidinfo *euip)
void crextend(struct ucred *cr, int n)
int kern_getgroups(struct thread *td, u_int *ngrp, gid_t *groups)
int sys_setegid(struct thread *td, struct setegid_args *uap)
int sys_seteuid(struct thread *td, struct seteuid_args *uap)
int sys_getuid(struct thread *td, struct getuid_args *uap)
int sys_getlogin(struct thread *td, struct getlogin_args *uap)
int securelevel_gt(struct ucred *cr, int level)
void crcopy(struct ucred *dest, struct ucred *src)
FEATURE(kdtrace_hooks,"Kernel DTrace hooks which are required to load DTrace kernel modules")
void loginclass_free(struct loginclass *lc)
void change_egid(struct ucred *newcred, gid_t egid)
static int cr_seeotheruids(struct ucred *u1, struct ucred *u2)
struct ucred * crget(void)
int cr_canseesocket(struct ucred *cred, struct socket *so)
int sys___setugid(struct thread *td, struct __setugid_args *uap)
int p_cansee(struct thread *td, struct proc *p)
int sys_setgid(struct thread *td, struct setgid_args *uap)
int p_cansched(struct thread *td, struct proc *p)
const struct cf_level * level