37#include "opt_capsicum.h"
40#include "opt_ktrace.h"
44#include <sys/capsicum.h>
45#include <sys/kernel.h>
48#include <sys/sysproto.h>
49#include <sys/malloc.h>
50#include <sys/filedesc.h>
55#include <sys/protosw.h>
56#include <sys/rwlock.h>
57#include <sys/socket.h>
58#include <sys/socketvar.h>
59#include <sys/syscallsubr.h>
60#include <sys/sysent.h>
65#include <sys/ktrace.h>
67#ifdef COMPAT_FREEBSD32
68#include <compat/freebsd32/freebsd32_util.h>
73#include <security/audit/audit.h>
74#include <security/mac/mac_framework.h>
76static int sendit(
struct thread *td,
int s,
struct msghdr *mp,
int flags);
77static int recvit(
struct thread *td,
int s,
struct msghdr *mp,
void *namelenp);
79static int accept1(
struct thread *td,
int s,
struct sockaddr *uname,
80 socklen_t *anamelen,
int flags);
81static int sockargs(
struct mbuf **,
char *, socklen_t,
int);
91 struct file **fpp, u_int *fflagp,
struct filecaps *havecapsp)
96 error =
fget_cap(td,
fd, rightsp, &fp, havecapsp);
99 if (fp->f_type != DTYPE_SOCKET) {
101 if (havecapsp != NULL)
106 *fflagp = fp->f_flag;
114#if defined(COMPAT_43)
115#define COMPAT_OLDSOCK
122 return (
kern_socket(td, uap->domain, uap->type, uap->protocol));
130 int fd, error, oflag, fflag;
136 if ((
type & SOCK_CLOEXEC) != 0) {
137 type &= ~SOCK_CLOEXEC;
140 if ((
type & SOCK_NONBLOCK) != 0) {
141 type &= ~SOCK_NONBLOCK;
146 error = mac_socket_check_create(td->td_ucred,
domain,
type, protocol);
150 error = falloc(td, &fp, &
fd, oflag);
159 if ((fflag & FNONBLOCK) != 0)
160 (void) fo_ioctl(fp, FIONBIO, &fflag, td->td_ucred, td);
161 td->td_retval[0] =
fd;
188#ifdef CAPABILITY_MODE
189 if (IN_CAPABILITY_MODE(td) && (
dirfd == AT_FDCWD))
194 AUDIT_ARG_SOCKADDR(td,
dirfd, sa);
201 if (KTRPOINT(td, KTR_STRUCT))
205 error = mac_socket_check_bind(td->td_ucred, so, sa);
208 if (
dirfd == AT_FDCWD)
209 error =
sobind(so, sa, td);
253 error = mac_socket_check_listen(td->td_ucred, so);
269 struct sockaddr *uname;
273 struct sockaddr *
name;
281 error = copyin(anamelen, &namelen,
sizeof (namelen));
290 if (error == 0 && uname != NULL) {
292 if (SV_PROC_FLAG(td->td_proc, SV_AOUT) &&
293 (
flags & ACCEPT4_COMPAT) != 0)
294 ((
struct osockaddr *)
name)->sa_family =
297 error = copyout(
name, uname, namelen);
300 error = copyout(&namelen, anamelen,
303 fdclose(td, fp, td->td_retval[0]);
311 socklen_t *namelen,
struct file **fp)
318 socklen_t *namelen,
int flags,
struct file **fp)
320 struct file *headfp, *nfp = NULL;
321 struct sockaddr *sa = NULL;
322 struct socket *head, *so;
323 struct filecaps fcaps;
333 &headfp, &fflag, &fcaps);
336 head = headfp->f_data;
337 if (!SOLISTENING(head)) {
342 error = mac_socket_check_accept(td->td_ucred, head);
347 (
flags & SOCK_CLOEXEC) ? O_CLOEXEC : 0, &fcaps);
351 if (!SOLISTENING(head)) {
362 td->td_retval[0] =
fd;
365 KNOTE_UNLOCKED(&head->so_rdsel.si_note, 0);
367 if (
flags & ACCEPT4_INHERIT) {
368 pgid =
fgetown(&head->so_sigio);
372 fflag &= ~(FNONBLOCK | FASYNC);
373 if (
flags & SOCK_NONBLOCK)
379 tmp = fflag & FNONBLOCK;
380 (void) fo_ioctl(nfp, FIONBIO, &tmp, td->td_ucred, td);
381 tmp = fflag & FASYNC;
382 (void) fo_ioctl(nfp, FIOASYNC, &tmp, td->td_ucred, td);
391 AUDIT_ARG_SOCKADDR(td, AT_FDCWD, sa);
394 if (*namelen > sa->sa_len)
395 *namelen = sa->sa_len;
397 if (KTRPOINT(td, KTR_STRUCT))
436 struct accept_args *uap;
439 return (
accept1(td, uap->s, uap->name, uap->anamelen, ACCEPT4_INHERIT));
445 struct accept4_args *uap;
448 if (uap->flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK))
451 return (
accept1(td, uap->s, uap->name, uap->anamelen, uap->flags));
456oaccept(
struct thread *td,
struct oaccept_args *uap)
459 return (
accept1(td, uap->s, uap->name, uap->anamelen,
460 ACCEPT4_INHERIT | ACCEPT4_COMPAT));
485#ifdef CAPABILITY_MODE
486 if (IN_CAPABILITY_MODE(td) && (
dirfd == AT_FDCWD))
491 AUDIT_ARG_SOCKADDR(td,
dirfd, sa);
497 if (so->so_state & SS_ISCONNECTING) {
502 if (KTRPOINT(td, KTR_STRUCT))
506 error = mac_socket_check_connect(td->td_ucred, so, sa);
513 if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) {
518 while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
519 error = msleep(&so->so_timeo, &so->so_lock, PSOCK | PCATCH,
525 error = so->so_error;
530 if (error == ERESTART)
555 struct file *fp1, *fp2;
556 struct socket *so1, *so2;
557 int fd, error, oflag, fflag;
563 if ((
type & SOCK_CLOEXEC) != 0) {
564 type &= ~SOCK_CLOEXEC;
567 if ((
type & SOCK_NONBLOCK) != 0) {
568 type &= ~SOCK_NONBLOCK;
573 error = mac_socket_check_create(td->td_ucred,
domain,
type,
585 error = falloc(td, &fp1, &
fd, oflag);
590 error = falloc(td, &fp2, &
fd, oflag);
598 if (
type == SOCK_DGRAM) {
605 }
else if (so1->so_proto->pr_flags & PR_CONNREQUIRED) {
606 struct unpcb *unp, *unp2;
607 unp = sotounpcb(so1);
608 unp2 = sotounpcb(so2);
615 finit(fp1, FREAD | FWRITE | fflag, DTYPE_SOCKET, fp1->f_data,
617 finit(fp2, FREAD | FWRITE | fflag, DTYPE_SOCKET, fp2->f_data,
619 if ((fflag & FNONBLOCK) != 0) {
620 (void) fo_ioctl(fp1, FIONBIO, &fflag, td->td_ucred, td);
621 (void) fo_ioctl(fp2, FIONBIO, &fflag, td->td_ucred, td);
650 error = copyout(sv, uap->rsv, 2 *
sizeof(
int));
661 struct mbuf *control;
665#ifdef CAPABILITY_MODE
666 if (IN_CAPABILITY_MODE(td) && (mp->msg_name != NULL))
670 if (mp->msg_name != NULL) {
671 error =
getsockaddr(&to, mp->msg_name, mp->msg_namelen);
681 if (mp->msg_control) {
682 if (mp->msg_controllen <
sizeof(
struct cmsghdr)
684 && (mp->msg_flags != MSG_COMPAT ||
685 !SV_PROC_FLAG(td->td_proc, SV_AOUT))
691 error =
sockargs(&control, mp->msg_control,
692 mp->msg_controllen, MT_CONTROL);
696 if (mp->msg_flags == MSG_COMPAT &&
697 SV_PROC_FLAG(td->td_proc, SV_AOUT)) {
700 M_PREPEND(control,
sizeof(*cm), M_WAITOK);
701 cm = mtod(control,
struct cmsghdr *);
702 cm->cmsg_len = control->m_len;
703 cm->cmsg_level = SOL_SOCKET;
704 cm->cmsg_type = SCM_RIGHTS;
720 struct mbuf *control,
enum uio_seg segflg)
726 cap_rights_t *rights;
728 struct uio *ktruio = NULL;
735 if (mp->msg_name != NULL) {
736 AUDIT_ARG_SOCKADDR(td, AT_FDCWD, mp->msg_name);
739 error =
getsock_cap(td, s, rights, &fp, NULL, NULL);
744 so = (
struct socket *)fp->f_data;
747 if (mp->msg_name != NULL && KTRPOINT(td, KTR_STRUCT))
748 ktrsockaddr(mp->msg_name);
751 if (mp->msg_name != NULL) {
752 error = mac_socket_check_connect(td->td_ucred, so,
759 error = mac_socket_check_send(td->td_ucred, so);
766 auio.uio_iov = mp->msg_iov;
767 auio.uio_iovcnt = mp->msg_iovlen;
768 auio.uio_segflg = segflg;
769 auio.uio_rw = UIO_WRITE;
774 for (i = 0; i < mp->msg_iovlen; i++, iov++) {
775 if ((auio.uio_resid += iov->iov_len) < 0) {
782 if (KTRPOINT(td, KTR_GENIO))
785 len = auio.uio_resid;
786 error =
sosend(so, mp->msg_name, &auio, 0, control,
flags, td);
788 if (auio.uio_resid != len &&
789 (so->so_proto->pr_flags & PR_ATOMIC) == 0 &&
790 (error == ERESTART || error == EINTR ||
791 error == EWOULDBLOCK))
794 if (error == EPIPE && !(so->so_options & SO_NOSIGPIPE) &&
795 !(
flags & MSG_NOSIGNAL)) {
796 PROC_LOCK(td->td_proc);
798 PROC_UNLOCK(td->td_proc);
802 td->td_retval[0] = len - auio.uio_resid;
804 if (ktruio != NULL) {
805 ktruio->uio_resid = td->td_retval[0];
806 ktrgenio(s, UIO_WRITE, ktruio, error);
820 msg.msg_name = __DECONST(
void *, uap->to);
821 msg.msg_namelen = uap->tolen;
826 if (SV_PROC_FLAG(td->td_proc, SV_AOUT))
829 aiov.iov_base = __DECONST(
void *, uap->buf);
830 aiov.iov_len = uap->len;
831 return (
sendit(td, uap->s, &msg, uap->flags));
836osend(
struct thread *td,
struct osend_args *uap)
845 aiov.iov_base = __DECONST(
void *, uap->buf);
846 aiov.iov_len = uap->len;
849 return (
sendit(td, uap->s, &msg, uap->flags));
853osendmsg(
struct thread *td,
struct osendmsg_args *uap)
859 error = copyin(uap->msg, &msg, sizeof (
struct omsghdr));
862 error =
copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE);
866 msg.msg_flags = MSG_COMPAT;
867 error =
sendit(td, uap->s, &msg, uap->flags);
880 error = copyin(uap->msg, &msg, sizeof (msg));
883 error =
copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE);
888 if (SV_PROC_FLAG(td->td_proc, SV_AOUT))
891 error =
sendit(td, uap->s, &msg, uap->flags);
897kern_recvit(
struct thread *td,
int s,
struct msghdr *mp,
enum uio_seg fromseg,
898 struct mbuf **controlp)
902 struct mbuf *control, *m;
906 struct sockaddr *fromsa = NULL;
908 struct uio *ktruio = NULL;
913 if (controlp != NULL)
924 error = mac_socket_check_receive(td->td_ucred, so);
931 auio.uio_iov = mp->msg_iov;
932 auio.uio_iovcnt = mp->msg_iovlen;
933 auio.uio_segflg = UIO_USERSPACE;
934 auio.uio_rw = UIO_READ;
939 for (i = 0; i < mp->msg_iovlen; i++, iov++) {
940 if ((auio.uio_resid += iov->iov_len) < 0) {
946 if (KTRPOINT(td, KTR_GENIO))
950 len = auio.uio_resid;
951 error =
soreceive(so, &fromsa, &auio, NULL,
952 (mp->msg_control || controlp) ? &control : NULL,
955 if (auio.uio_resid != len && (error == ERESTART ||
956 error == EINTR || error == EWOULDBLOCK))
960 AUDIT_ARG_SOCKADDR(td, AT_FDCWD, fromsa);
962 if (ktruio != NULL) {
963 ktruio->uio_resid = len - auio.uio_resid;
964 ktrgenio(s, UIO_READ, ktruio, error);
969 td->td_retval[0] = len - auio.uio_resid;
971 len = mp->msg_namelen;
972 if (len <= 0 || fromsa == NULL)
976 len = MIN(len, fromsa->sa_len);
978 if ((mp->msg_flags & MSG_COMPAT) != 0 &&
979 SV_PROC_FLAG(td->td_proc, SV_AOUT))
980 ((
struct osockaddr *)fromsa)->sa_family =
983 if (fromseg == UIO_USERSPACE) {
984 error = copyout(fromsa, mp->msg_name,
989 bcopy(fromsa, mp->msg_name, len);
991 mp->msg_namelen = len;
993 if (mp->msg_control && controlp == NULL) {
1002 if (control && (mp->msg_flags & MSG_COMPAT) != 0 &&
1003 SV_PROC_FLAG(td->td_proc, SV_AOUT)) {
1004 if (mtod(control,
struct cmsghdr *)->cmsg_level !=
1006 mtod(control,
struct cmsghdr *)->cmsg_type !=
1008 mp->msg_controllen = 0;
1011 control->m_len -=
sizeof (
struct cmsghdr);
1012 control->m_data +=
sizeof (
struct cmsghdr);
1015 ctlbuf = mp->msg_control;
1016 len = mp->msg_controllen;
1017 mp->msg_controllen = 0;
1018 for (m = control; m != NULL && len >= m->m_len; m = m->m_next) {
1019 if ((error = copyout(mtod(m, caddr_t), ctlbuf,
1025 mp->msg_controllen += m->m_len;
1028 mp->msg_flags |= MSG_CTRUNC;
1035 if (fromsa && KTRPOINT(td, KTR_STRUCT))
1036 ktrsockaddr(fromsa);
1038 free(fromsa, M_SONAME);
1040 if (error == 0 && controlp != NULL)
1041 *controlp = control;
1042 else if (control != NULL) {
1052recvit(
struct thread *td,
int s,
struct msghdr *mp,
void *namelenp)
1056 error =
kern_recvit(td, s, mp, UIO_USERSPACE, NULL);
1059 if (namelenp != NULL) {
1060 error = copyout(&mp->msg_namelen, namelenp, sizeof (socklen_t));
1061#ifdef COMPAT_OLDSOCK
1062 if ((mp->msg_flags & MSG_COMPAT) != 0 &&
1063 SV_PROC_FLAG(td->td_proc, SV_AOUT))
1072 struct sockaddr *from, socklen_t *fromlenaddr)
1078 if (fromlenaddr != NULL) {
1079 error = copyin(fromlenaddr, &msg.msg_namelen,
1080 sizeof (msg.msg_namelen));
1084 msg.msg_namelen = 0;
1086 msg.msg_name = from;
1087 msg.msg_iov = &aiov;
1089 aiov.iov_base =
buf;
1091 msg.msg_control = 0;
1092 msg.msg_flags =
flags;
1093 error =
recvit(td, s, &msg, fromlenaddr);
1102 uap->flags, uap->from, uap->fromlenaddr));
1106#ifdef COMPAT_OLDSOCK
1108orecvfrom(
struct thread *td,
struct orecvfrom_args *uap)
1111 uap->flags | MSG_COMPAT, uap->from, uap->fromlenaddr));
1115#ifdef COMPAT_OLDSOCK
1117orecv(
struct thread *td,
struct orecv_args *uap)
1123 msg.msg_namelen = 0;
1124 msg.msg_iov = &aiov;
1126 aiov.iov_base = uap->buf;
1127 aiov.iov_len = uap->len;
1128 msg.msg_control = 0;
1129 msg.msg_flags = uap->flags;
1130 return (
recvit(td, uap->s, &msg, NULL));
1139orecvmsg(
struct thread *td,
struct orecvmsg_args *uap)
1145 error = copyin(uap->msg, &msg, sizeof (
struct omsghdr));
1148 error =
copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE);
1151 msg.msg_flags = uap->flags | MSG_COMPAT;
1153 error =
recvit(td, uap->s, &msg, &uap->msg->msg_namelen);
1154 if (msg.msg_controllen && error == 0)
1155 error = copyout(&msg.msg_controllen,
1156 &uap->msg->msg_accrightslen, sizeof (
int));
1166 struct iovec *uiov, *iov;
1169 error = copyin(uap->msg, &msg, sizeof (msg));
1172 error =
copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE);
1175 msg.msg_flags = uap->flags;
1176#ifdef COMPAT_OLDSOCK
1177 if (SV_PROC_FLAG(td->td_proc, SV_AOUT))
1178 msg.msg_flags &= ~MSG_COMPAT;
1182 error =
recvit(td, uap->s, &msg, NULL);
1185 error = copyout(&msg, uap->msg,
sizeof(msg));
1217 if (error == ENOTCONN &&
1218 td->td_proc->p_osrel < P_OSREL_SHUTDOWN_ENOTCONN)
1230 uap->val, UIO_USERSPACE, uap->valsize));
1235 enum uio_seg valseg, socklen_t valsize)
1239 struct sockopt sopt;
1242 if (val == NULL && valsize != 0)
1244 if ((
int)valsize < 0)
1247 sopt.sopt_dir = SOPT_SET;
1248 sopt.sopt_level =
level;
1249 sopt.sopt_name =
name;
1250 sopt.sopt_val = __DECONST(
void *, val);
1251 sopt.sopt_valsize = valsize;
1257 sopt.sopt_td = NULL;
1260 panic(
"kern_setsockopt called with bad valseg");
1281 error = copyin(uap->avalsize, &valsize, sizeof (valsize));
1287 uap->val, UIO_USERSPACE, &valsize);
1290 error = copyout(&valsize, uap->avalsize, sizeof (valsize));
1300 enum uio_seg valseg, socklen_t *valsize)
1304 struct sockopt sopt;
1309 if ((
int)*valsize < 0)
1312 sopt.sopt_dir = SOPT_GET;
1313 sopt.sopt_level =
level;
1314 sopt.sopt_name =
name;
1315 sopt.sopt_val = val;
1316 sopt.sopt_valsize = (size_t)*valsize;
1322 sopt.sopt_td = NULL;
1325 panic(
"kern_getsockopt called with bad valseg");
1334 *valsize = sopt.sopt_valsize;
1342 socklen_t *alen,
bool compat)
1344 struct sockaddr *sa;
1348 error = copyin(alen, &len,
sizeof(len));
1357#ifdef COMPAT_OLDSOCK
1358 if (
compat && SV_PROC_FLAG(td->td_proc, SV_AOUT))
1359 ((
struct osockaddr *)sa)->sa_family = sa->sa_family;
1361 error = copyout(sa, asa, len);
1365 error = copyout(&len, alen,
sizeof(len));
1385 CURVNET_SET(so->so_vnet);
1386 error = (*so->so_proto->pr_usrreqs->pru_sockaddr)(so, sa);
1393 len = MIN(*alen, (*sa)->sa_len);
1396 if (KTRPOINT(td, KTR_STRUCT))
1401 if (error != 0 && *sa != NULL) {
1402 free(*sa, M_SONAME);
1414#ifdef COMPAT_OLDSOCK
1416ogetsockname(
struct thread *td,
struct ogetsockname_args *uap)
1424 socklen_t *alen,
bool compat)
1426 struct sockaddr *sa;
1430 error = copyin(alen, &len,
sizeof (len));
1439#ifdef COMPAT_OLDSOCK
1440 if (
compat && SV_PROC_FLAG(td->td_proc, SV_AOUT))
1441 ((
struct osockaddr *)sa)->sa_family = sa->sa_family;
1443 error = copyout(sa, asa, len);
1447 error = copyout(&len, alen,
sizeof(len));
1466 if ((so->so_state & (SS_ISCONNECTED|SS_ISCONFIRMING)) == 0) {
1471 CURVNET_SET(so->so_vnet);
1472 error = (*so->so_proto->pr_usrreqs->pru_peeraddr)(so, sa);
1479 len = MIN(*alen, (*sa)->sa_len);
1482 if (KTRPOINT(td, KTR_STRUCT))
1486 if (error != 0 && *sa != NULL) {
1487 free(*sa, M_SONAME);
1501#ifdef COMPAT_OLDSOCK
1503ogetpeername(
struct thread *td,
struct ogetpeername_args *uap)
1512 struct sockaddr *sa;
1516 if (buflen > MLEN) {
1517#ifdef COMPAT_OLDSOCK
1518 if (
type == MT_SONAME && buflen <= 112 &&
1519 SV_CURPROC_FLAG(SV_AOUT))
1523 if (buflen > MCLBYTES)
1528 error = copyin(
buf, mtod(m,
void *), buflen);
1533 if (
type == MT_SONAME) {
1534 sa = mtod(m,
struct sockaddr *);
1536#if defined(COMPAT_OLDSOCK) && BYTE_ORDER != BIG_ENDIAN
1537 if (sa->sa_family == 0 && sa->sa_len < AF_MAX &&
1538 SV_CURPROC_FLAG(SV_AOUT))
1539 sa->sa_family = sa->sa_len;
1541 sa->sa_len = buflen;
1548getsockaddr(
struct sockaddr **namp,
const struct sockaddr *uaddr,
size_t len)
1550 struct sockaddr *sa;
1553 if (len > SOCK_MAXADDRLEN)
1554 return (ENAMETOOLONG);
1555 if (len < offsetof(
struct sockaddr, sa_data[0]))
1557 sa =
malloc(len, M_SONAME, M_WAITOK);
1558 error = copyin(uaddr, sa, len);
1562#if defined(COMPAT_OLDSOCK) && BYTE_ORDER != BIG_ENDIAN
1563 if (sa->sa_family == 0 && sa->sa_len < AF_MAX &&
1564 SV_CURPROC_FLAG(SV_AOUT))
1565 sa->sa_family = sa->sa_len;
1584 socklen_t clen, datalen;
1585 int error,
fd, *fds, nfd;
1588 for (; m != NULL; m = m->m_next) {
1589 if (m->m_type != MT_EXTCONTROL)
1591 cm = mtod(m,
struct cmsghdr *);
1594 if (clen <
sizeof(*cm))
1595 panic(
"%s: truncated mbuf %p", __func__, m);
1596 datalen = CMSG_SPACE(cm->cmsg_len - CMSG_SPACE(0));
1598 panic(
"%s: truncated mbuf %p", __func__, m);
1600 if (cm->cmsg_level == SOL_SOCKET &&
1601 cm->cmsg_type == SCM_RIGHTS) {
1602 fds = (
int *)CMSG_DATA(cm);
1603 nfd = (cm->cmsg_len - CMSG_SPACE(0)) /
1617 cm = (
struct cmsghdr *)((uint8_t *)cm + datalen);
1619 m_chtype(m, MT_CONTROL);
const struct cf_level * level
device_property_type_t type
int fsetown(pid_t pgid, struct sigio **sigiop)
int fget_cap(struct thread *td, int fd, cap_rights_t *needrightsp, struct file **fpp, struct filecaps *havecapsp)
pid_t fgetown(struct sigio **sigiop)
void fdclose(struct thread *td, struct file *fp, int idx)
void filecaps_free(struct filecaps *fcaps)
int kern_close(struct thread *td, int fd)
int fget(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp)
void finit(struct file *fp, u_int flag, short type, void *data, struct fileops *ops)
int falloc_caps(struct thread *td, struct file **resultfp, int *resultfd, int flags, struct filecaps *fcaps)
void *() malloc(size_t size, struct malloc_type *mtp, int flags)
void free(void *addr, struct malloc_type *mtp)
void m_freem(struct mbuf *mb)
struct mbuf * m_get2(int size, int how, short type, int flags)
void panic(const char *fmt,...)
void tdsignal(struct thread *td, int sig)
struct iommu_domain ** domain
__read_mostly cap_rights_t cap_send_connect_rights
__read_mostly cap_rights_t cap_connect_rights
__read_mostly cap_rights_t cap_recv_rights
__read_mostly cap_rights_t cap_bind_rights
__read_mostly cap_rights_t cap_setsockopt_rights
__read_mostly cap_rights_t cap_accept_rights
__read_mostly cap_rights_t cap_getpeername_rights
__read_mostly cap_rights_t cap_no_rights
__read_mostly cap_rights_t cap_listen_rights
__read_mostly cap_rights_t cap_shutdown_rights
__read_mostly cap_rights_t cap_getsockname_rights
__read_mostly cap_rights_t cap_getsockopt_rights
__read_mostly cap_rights_t cap_send_rights
int copyiniov(const struct iovec *iovp, u_int iovcnt, struct iovec **iov, int error)
struct uio * cloneuio(struct uio *uiop)
int sosetopt(struct socket *so, struct sockopt *sopt)
int solisten(struct socket *so, int backlog, struct thread *td)
int solisten_dequeue(struct socket *head, struct socket **ret, int flags)
int sobind(struct socket *so, struct sockaddr *nam, struct thread *td)
int soconnect2(struct socket *so1, struct socket *so2)
int socreate(int dom, struct socket **aso, int type, int proto, struct ucred *cred, struct thread *td)
int soclose(struct socket *so)
int sogetopt(struct socket *so, struct sockopt *sopt)
int sobindat(int fd, struct socket *so, struct sockaddr *nam, struct thread *td)
int soconnectat(int fd, struct socket *so, struct sockaddr *nam, struct thread *td)
int soshutdown(struct socket *so, int how)
int soreceive(struct socket *so, struct sockaddr **psa, struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp)
int soaccept(struct socket *so, struct sockaddr **nam)
int sosend(struct socket *so, struct sockaddr *addr, struct uio *uio, struct mbuf *top, struct mbuf *control, int flags, struct thread *td)
int sys_sendto(struct thread *td, struct sendto_args *uap)
int kern_recvit(struct thread *td, int s, struct msghdr *mp, enum uio_seg fromseg, struct mbuf **controlp)
int sys_sendmsg(struct thread *td, struct sendmsg_args *uap)
int kern_shutdown(struct thread *td, int s, int how)
int sys_listen(struct thread *td, struct listen_args *uap)
int sys_shutdown(struct thread *td, struct shutdown_args *uap)
int sys_socketpair(struct thread *td, struct socketpair_args *uap)
int kern_sendit(struct thread *td, int s, struct msghdr *mp, int flags, struct mbuf *control, enum uio_seg segflg)
static int user_getsockname(struct thread *td, int fdes, struct sockaddr *asa, socklen_t *alen, bool compat)
int kern_setsockopt(struct thread *td, int s, int level, int name, const void *val, enum uio_seg valseg, socklen_t valsize)
static int sendit(struct thread *td, int s, struct msghdr *mp, int flags)
static int accept1(struct thread *td, int s, struct sockaddr *uname, socklen_t *anamelen, int flags)
int kern_socket(struct thread *td, int domain, int type, int protocol)
int sys_recvfrom(struct thread *td, struct recvfrom_args *uap)
int kern_connectat(struct thread *td, int dirfd, int fd, struct sockaddr *sa)
int getsock_cap(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp, u_int *fflagp, struct filecaps *havecapsp)
int sys_accept4(struct thread *td, struct accept4_args *uap)
int sys_setsockopt(struct thread *td, struct setsockopt_args *uap)
int kern_getsockopt(struct thread *td, int s, int level, int name, void *val, enum uio_seg valseg, socklen_t *valsize)
int kern_socketpair(struct thread *td, int domain, int type, int protocol, int *rsv)
int getsockaddr(struct sockaddr **namp, const struct sockaddr *uaddr, size_t len)
static int user_getpeername(struct thread *td, int fdes, struct sockaddr *asa, socklen_t *alen, bool compat)
void m_dispose_extcontrolm(struct mbuf *m)
int sys_bindat(struct thread *td, struct bindat_args *uap)
int sys_recvmsg(struct thread *td, struct recvmsg_args *uap)
int kern_accept4(struct thread *td, int s, struct sockaddr **name, socklen_t *namelen, int flags, struct file **fp)
int sys_getsockopt(struct thread *td, struct getsockopt_args *uap)
int sys_connect(struct thread *td, struct connect_args *uap)
int sys_accept(struct thread *td, struct accept_args *uap)
int kern_getsockname(struct thread *td, int fd, struct sockaddr **sa, socklen_t *alen)
int kern_accept(struct thread *td, int s, struct sockaddr **name, socklen_t *namelen, struct file **fp)
static int recvit(struct thread *td, int s, struct msghdr *mp, void *namelenp)
int sys_getpeername(struct thread *td, struct getpeername_args *uap)
int kern_bindat(struct thread *td, int dirfd, int fd, struct sockaddr *sa)
int kern_listen(struct thread *td, int s, int backlog)
int sys_bind(struct thread *td, struct bind_args *uap)
int sys_socket(struct thread *td, struct socket_args *uap)
int sys_getsockname(struct thread *td, struct getsockname_args *uap)
int kern_getpeername(struct thread *td, int fd, struct sockaddr **sa, socklen_t *alen)
static int sockargs(struct mbuf **, char *, socklen_t, int)
int sys_connectat(struct thread *td, struct connectat_args *uap)
static int kern_recvfrom(struct thread *td, int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlenaddr)
void unp_copy_peercred(struct thread *td, struct unpcb *client_unp, struct unpcb *server_unp, struct unpcb *listen_unp)