FreeBSD kernel kern code
uipc_syscalls.c File Reference
#include <sys/cdefs.h>
#include "opt_capsicum.h"
#include "opt_inet.h"
#include "opt_inet6.h"
#include "opt_ktrace.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/capsicum.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/sysproto.h>
#include <sys/malloc.h>
#include <sys/filedesc.h>
#include <sys/proc.h>
#include <sys/filio.h>
#include <sys/jail.h>
#include <sys/mbuf.h>
#include <sys/protosw.h>
#include <sys/rwlock.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/syscallsubr.h>
#include <sys/sysent.h>
#include <sys/uio.h>
#include <sys/un.h>
#include <sys/unpcb.h>
#include <net/vnet.h>
#include <security/audit/audit.h>
#include <security/mac/mac_framework.h>
Include dependency graph for uipc_syscalls.c:

Go to the source code of this file.

Functions

 __FBSDID ("$FreeBSD$")
 
static int sendit (struct thread *td, int s, struct msghdr *mp, int flags)
 
static int recvit (struct thread *td, int s, struct msghdr *mp, void *namelenp)
 
static int accept1 (struct thread *td, int s, struct sockaddr *uname, socklen_t *anamelen, int flags)
 
static int sockargs (struct mbuf **, char *, socklen_t, int)
 
int getsock_cap (struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp, u_int *fflagp, struct filecaps *havecapsp)
 
int sys_socket (struct thread *td, struct socket_args *uap)
 
int kern_socket (struct thread *td, int domain, int type, int protocol)
 
int sys_bind (struct thread *td, struct bind_args *uap)
 
int kern_bindat (struct thread *td, int dirfd, int fd, struct sockaddr *sa)
 
int sys_bindat (struct thread *td, struct bindat_args *uap)
 
int sys_listen (struct thread *td, struct listen_args *uap)
 
int kern_listen (struct thread *td, int s, int backlog)
 
int kern_accept (struct thread *td, int s, struct sockaddr **name, socklen_t *namelen, struct file **fp)
 
int kern_accept4 (struct thread *td, int s, struct sockaddr **name, socklen_t *namelen, int flags, struct file **fp)
 
int sys_accept (struct thread *td, struct accept_args *uap)
 
int sys_accept4 (struct thread *td, struct accept4_args *uap)
 
int sys_connect (struct thread *td, struct connect_args *uap)
 
int kern_connectat (struct thread *td, int dirfd, int fd, struct sockaddr *sa)
 
int sys_connectat (struct thread *td, struct connectat_args *uap)
 
int kern_socketpair (struct thread *td, int domain, int type, int protocol, int *rsv)
 
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)
 
int sys_sendto (struct thread *td, struct sendto_args *uap)
 
int sys_sendmsg (struct thread *td, struct sendmsg_args *uap)
 
int kern_recvit (struct thread *td, int s, struct msghdr *mp, enum uio_seg fromseg, struct mbuf **controlp)
 
static int kern_recvfrom (struct thread *td, int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlenaddr)
 
int sys_recvfrom (struct thread *td, struct recvfrom_args *uap)
 
int sys_recvmsg (struct thread *td, struct recvmsg_args *uap)
 
int sys_shutdown (struct thread *td, struct shutdown_args *uap)
 
int kern_shutdown (struct thread *td, int s, int how)
 
int sys_setsockopt (struct thread *td, struct setsockopt_args *uap)
 
int kern_setsockopt (struct thread *td, int s, int level, int name, const void *val, enum uio_seg valseg, socklen_t valsize)
 
int sys_getsockopt (struct thread *td, struct getsockopt_args *uap)
 
int kern_getsockopt (struct thread *td, int s, int level, int name, void *val, enum uio_seg valseg, socklen_t *valsize)
 
static int user_getsockname (struct thread *td, int fdes, struct sockaddr *asa, socklen_t *alen, bool compat)
 
int kern_getsockname (struct thread *td, int fd, struct sockaddr **sa, socklen_t *alen)
 
int sys_getsockname (struct thread *td, struct getsockname_args *uap)
 
static int user_getpeername (struct thread *td, int fdes, struct sockaddr *asa, socklen_t *alen, bool compat)
 
int kern_getpeername (struct thread *td, int fd, struct sockaddr **sa, socklen_t *alen)
 
int sys_getpeername (struct thread *td, struct getpeername_args *uap)
 
int getsockaddr (struct sockaddr **namp, const struct sockaddr *uaddr, size_t len)
 
void m_dispose_extcontrolm (struct mbuf *m)
 

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ accept1()

static int accept1 ( struct thread *  td,
int  s,
struct sockaddr *  uname,
socklen_t *  anamelen,
int  flags 
)
static

Definition at line 266 of file uipc_syscalls.c.

References fdclose(), flags, free(), kern_accept4(), and name.

Referenced by sys_accept(), and sys_accept4().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getsock_cap()

int getsock_cap ( struct thread *  td,
int  fd,
cap_rights_t *  rightsp,
struct file **  fpp,
u_int *  fflagp,
struct filecaps *  havecapsp 
)

Definition at line 90 of file uipc_syscalls.c.

References fd, fget_cap(), and filecaps_free().

Referenced by kern_accept4(), kern_bindat(), kern_connectat(), kern_getpeername(), kern_getsockname(), kern_getsockopt(), kern_listen(), kern_recvit(), kern_sendit(), kern_setsockopt(), kern_shutdown(), and sendfile_getsock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getsockaddr()

int getsockaddr ( struct sockaddr **  namp,
const struct sockaddr *  uaddr,
size_t  len 
)

Definition at line 1548 of file uipc_syscalls.c.

References free(), and malloc().

Referenced by sendit(), sys_bind(), sys_bindat(), sys_connect(), and sys_connectat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_accept()

int kern_accept ( struct thread *  td,
int  s,
struct sockaddr **  name,
socklen_t *  namelen,
struct file **  fp 
)

Definition at line 310 of file uipc_syscalls.c.

References kern_accept4(), and name.

Here is the call graph for this function:

◆ kern_accept4()

int kern_accept4 ( struct thread *  td,
int  s,
struct sockaddr **  name,
socklen_t *  namelen,
int  flags,
struct file **  fp 
)

Definition at line 317 of file uipc_syscalls.c.

References cap_accept_rights, falloc_caps(), fd, fdclose(), fgetown(), filecaps_free(), finit(), flags, free(), fsetown(), getsock_cap(), name, soaccept(), socketops, and solisten_dequeue().

Referenced by accept1(), and kern_accept().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_bindat()

int kern_bindat ( struct thread *  td,
int  dirfd,
int  fd,
struct sockaddr *  sa 
)

Definition at line 182 of file uipc_syscalls.c.

References cap_bind_rights, dirfd, fd, getsock_cap(), sobind(), and sobindat().

Referenced by sys_bind(), and sys_bindat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_connectat()

int kern_connectat ( struct thread *  td,
int  dirfd,
int  fd,
struct sockaddr *  sa 
)

Definition at line 479 of file uipc_syscalls.c.

References cap_connect_rights, dirfd, fd, getsock_cap(), and soconnectat().

Referenced by sys_connect(), and sys_connectat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_getpeername()

int kern_getpeername ( struct thread *  td,
int  fd,
struct sockaddr **  sa,
socklen_t *  alen 
)

Definition at line 1452 of file uipc_syscalls.c.

References cap_getpeername_rights, fd, free(), and getsock_cap().

Referenced by user_getpeername().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_getsockname()

int kern_getsockname ( struct thread *  td,
int  fd,
struct sockaddr **  sa,
socklen_t *  alen 
)

Definition at line 1370 of file uipc_syscalls.c.

References cap_getsockname_rights, fd, free(), and getsock_cap().

Referenced by user_getsockname().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_getsockopt()

int kern_getsockopt ( struct thread *  td,
int  s,
int  level,
int  name,
void *  val,
enum uio_seg  valseg,
socklen_t *  valsize 
)

Definition at line 1299 of file uipc_syscalls.c.

References cap_getsockopt_rights, getsock_cap(), level, name, panic(), and sogetopt().

Referenced by sys_getsockopt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_listen()

int kern_listen ( struct thread *  td,
int  s,
int  backlog 
)

Definition at line 241 of file uipc_syscalls.c.

References cap_listen_rights, getsock_cap(), and solisten().

Referenced by sys_listen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_recvfrom()

static int kern_recvfrom ( struct thread *  td,
int  s,
void *  buf,
size_t  len,
int  flags,
struct sockaddr *  from,
socklen_t *  fromlenaddr 
)
static

Definition at line 1071 of file uipc_syscalls.c.

References buf, flags, and recvit().

Referenced by sys_recvfrom().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_recvit()

int kern_recvit ( struct thread *  td,
int  s,
struct msghdr *  mp,
enum uio_seg  fromseg,
struct mbuf **  controlp 
)

Definition at line 897 of file uipc_syscalls.c.

References cap_recv_rights, cloneuio(), free(), getsock_cap(), m_dispose_extcontrolm(), m_freem(), and soreceive().

Referenced by recvit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_sendit()

int kern_sendit ( struct thread *  td,
int  s,
struct msghdr *  mp,
int  flags,
struct mbuf *  control,
enum uio_seg  segflg 
)

Definition at line 719 of file uipc_syscalls.c.

References cap_send_connect_rights, cap_send_rights, cloneuio(), flags, getsock_cap(), m_freem(), sosend(), and tdsignal().

Referenced by sendit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_setsockopt()

int kern_setsockopt ( struct thread *  td,
int  s,
int  level,
int  name,
const void *  val,
enum uio_seg  valseg,
socklen_t  valsize 
)

Definition at line 1234 of file uipc_syscalls.c.

References cap_setsockopt_rights, getsock_cap(), level, name, panic(), and sosetopt().

Referenced by sys_setsockopt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_shutdown()

int kern_shutdown ( struct thread *  td,
int  s,
int  how 
)

Definition at line 1199 of file uipc_syscalls.c.

References cap_shutdown_rights, getsock_cap(), and soshutdown().

Referenced by sys_shutdown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_socket()

int kern_socket ( struct thread *  td,
int  domain,
int  type,
int  protocol 
)

Definition at line 126 of file uipc_syscalls.c.

References domain, fd, fdclose(), finit(), socketops, socreate(), and type.

Referenced by sys_socket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kern_socketpair()

int kern_socketpair ( struct thread *  td,
int  domain,
int  type,
int  protocol,
int *  rsv 
)

Definition at line 552 of file uipc_syscalls.c.

References domain, fd, fdclose(), finit(), socketops, soclose(), soconnect2(), socreate(), type, and unp_copy_peercred().

Referenced by sys_socketpair().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m_dispose_extcontrolm()

void m_dispose_extcontrolm ( struct mbuf *  m)

Definition at line 1579 of file uipc_syscalls.c.

References cap_no_rights, fd, fdclose(), fget(), and panic().

Referenced by kern_recvit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ recvit()

static int recvit ( struct thread *  td,
int  s,
struct msghdr *  mp,
void *  namelenp 
)
static

Definition at line 1052 of file uipc_syscalls.c.

References kern_recvit().

Referenced by kern_recvfrom(), and sys_recvmsg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendit()

static int sendit ( struct thread *  td,
int  s,
struct msghdr *  mp,
int  flags 
)
static

Definition at line 659 of file uipc_syscalls.c.

References flags, free(), getsockaddr(), kern_sendit(), and sockargs().

Referenced by sys_sendmsg(), and sys_sendto().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sockargs()

static int sockargs ( struct mbuf **  mp,
char *  buf,
socklen_t  buflen,
int  type 
)
static

Definition at line 1510 of file uipc_syscalls.c.

References buf, m_get2(), and type.

Referenced by sendit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sys_accept()

int sys_accept ( struct thread *  td,
struct accept_args *  uap 
)

Definition at line 434 of file uipc_syscalls.c.

References accept1().

Here is the call graph for this function:

◆ sys_accept4()

int sys_accept4 ( struct thread *  td,
struct accept4_args *  uap 
)

Definition at line 443 of file uipc_syscalls.c.

References accept1().

Here is the call graph for this function:

◆ sys_bind()

int sys_bind ( struct thread *  td,
struct bind_args *  uap 
)

Definition at line 168 of file uipc_syscalls.c.

References free(), getsockaddr(), and kern_bindat().

Here is the call graph for this function:

◆ sys_bindat()

int sys_bindat ( struct thread *  td,
struct bindat_args *  uap 
)

Definition at line 220 of file uipc_syscalls.c.

References free(), getsockaddr(), and kern_bindat().

Here is the call graph for this function:

◆ sys_connect()

int sys_connect ( struct thread *  td,
struct connect_args *  uap 
)

Definition at line 465 of file uipc_syscalls.c.

References free(), getsockaddr(), and kern_connectat().

Here is the call graph for this function:

◆ sys_connectat()

int sys_connectat ( struct thread *  td,
struct connectat_args *  uap 
)

Definition at line 538 of file uipc_syscalls.c.

References free(), getsockaddr(), and kern_connectat().

Here is the call graph for this function:

◆ sys_getpeername()

int sys_getpeername ( struct thread *  td,
struct getpeername_args *  uap 
)

Definition at line 1496 of file uipc_syscalls.c.

References user_getpeername().

Here is the call graph for this function:

◆ sys_getsockname()

int sys_getsockname ( struct thread *  td,
struct getsockname_args *  uap 
)

Definition at line 1409 of file uipc_syscalls.c.

References user_getsockname().

Here is the call graph for this function:

◆ sys_getsockopt()

int sys_getsockopt ( struct thread *  td,
struct getsockopt_args *  uap 
)

Definition at line 1275 of file uipc_syscalls.c.

References kern_getsockopt().

Here is the call graph for this function:

◆ sys_listen()

int sys_listen ( struct thread *  td,
struct listen_args *  uap 
)

Definition at line 234 of file uipc_syscalls.c.

References kern_listen().

Here is the call graph for this function:

◆ sys_recvfrom()

int sys_recvfrom ( struct thread *  td,
struct recvfrom_args *  uap 
)

Definition at line 1099 of file uipc_syscalls.c.

References kern_recvfrom().

Here is the call graph for this function:

◆ sys_recvmsg()

int sys_recvmsg ( struct thread *  td,
struct recvmsg_args *  uap 
)

Definition at line 1163 of file uipc_syscalls.c.

References copyiniov(), free(), and recvit().

Here is the call graph for this function:

◆ sys_sendmsg()

int sys_sendmsg ( struct thread *  td,
struct sendmsg_args *  uap 
)

Definition at line 874 of file uipc_syscalls.c.

References copyiniov(), free(), and sendit().

Here is the call graph for this function:

◆ sys_sendto()

int sys_sendto ( struct thread *  td,
struct sendto_args *  uap 
)

Definition at line 815 of file uipc_syscalls.c.

References sendit().

Here is the call graph for this function:

◆ sys_setsockopt()

int sys_setsockopt ( struct thread *  td,
struct setsockopt_args *  uap 
)

Definition at line 1226 of file uipc_syscalls.c.

References kern_setsockopt().

Here is the call graph for this function:

◆ sys_shutdown()

int sys_shutdown ( struct thread *  td,
struct shutdown_args *  uap 
)

Definition at line 1192 of file uipc_syscalls.c.

References kern_shutdown().

Here is the call graph for this function:

◆ sys_socket()

int sys_socket ( struct thread *  td,
struct socket_args *  uap 
)

Definition at line 119 of file uipc_syscalls.c.

References kern_socket().

Here is the call graph for this function:

◆ sys_socketpair()

int sys_socketpair ( struct thread *  td,
struct socketpair_args *  uap 
)

Definition at line 642 of file uipc_syscalls.c.

References kern_close(), and kern_socketpair().

Here is the call graph for this function:

◆ user_getpeername()

static int user_getpeername ( struct thread *  td,
int  fdes,
struct sockaddr *  asa,
socklen_t *  alen,
bool  compat 
)
static

Definition at line 1423 of file uipc_syscalls.c.

References compat, free(), and kern_getpeername().

Referenced by sys_getpeername().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ user_getsockname()

static int user_getsockname ( struct thread *  td,
int  fdes,
struct sockaddr *  asa,
socklen_t *  alen,
bool  compat 
)
static

Definition at line 1341 of file uipc_syscalls.c.

References compat, free(), and kern_getsockname().

Referenced by sys_getsockname().

Here is the call graph for this function:
Here is the caller graph for this function: