github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/freebsd/socket_unix.txt (about)

     1  # Copyright 2017 syzkaller project authors. All rights reserved.
     2  # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  # AF_UNIX support.
     5  
     6  include <sys/types.h>
     7  include <sys/socket.h>
     8  include <netinet/in.h>
     9  
    10  resource sock_unix[sock]
    11  
    12  socket$unix(domain const[AF_UNIX], type flags[unix_socket_type], proto const[0]) sock_unix
    13  socketpair$unix(domain const[AF_UNIX], type flags[unix_socket_type], proto const[0], fds ptr[out, unix_pair])
    14  bind$unix(fd sock_unix, addr ptr[in, sockaddr_un], addrlen len[addr])
    15  bindat$unix(dirfd fd, fd sock_unix, addr ptr[in, sockaddr_un], addrlen len[addr])
    16  connect$unix(fd sock_unix, addr ptr[in, sockaddr_un], addrlen len[addr])
    17  connectat$unix(dirfd fd, fd sock_unix, addr ptr[in, sockaddr_un], addrlen len[addr])
    18  accept$unix(fd sock_unix, peer ptr[out, sockaddr_un, opt], peerlen ptr[inout, len[peer, int32]]) sock_unix
    19  accept4$unix(fd sock_unix, peer ptr[out, sockaddr_un, opt], peerlen ptr[inout, len[peer, int32]], flags flags[accept_flags]) sock_unix
    20  
    21  sendto$unix(fd sock_unix, buf buffer[in], len len[buf], f flags[send_flags], addr ptr[in, sockaddr_un, opt], addrlen len[addr])
    22  sendmsg$unix(fd sock_unix, msg ptr[in, msghdr_un], f flags[send_flags])
    23  recvfrom$unix(fd sock_unix, buf buffer[out], len len[buf], f flags[recv_flags], addr ptr[in, sockaddr_un, opt], addrlen len[addr])
    24  getsockname$unix(fd sock_unix, addr ptr[out, sockaddr_un], addrlen ptr[inout, len[addr, int32]])
    25  getpeername$unix(fd sock_unix, peer ptr[out, sockaddr_un], peerlen ptr[inout, len[peer, int32]])
    26  
    27  unix_socket_type = SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET
    28  unix_socket_family = AF_UNIX, AF_UNSPEC
    29  
    30  unix_pair {
    31  	fd0	sock_unix
    32  	fd1	sock_unix
    33  }
    34  
    35  sockaddr_un [
    36  	file	sockaddr_un_file
    37  	abs	sockaddr_un_abstract
    38  ] [varlen]
    39  
    40  sockaddr_un_file {
    41  	len	len[parent, int8]
    42  	family	flags[unix_socket_family, int8]
    43  	path	filename
    44  } [packed]
    45  
    46  sockaddr_un_abstract {
    47  	len	len[parent, int8]
    48  	family	flags[unix_socket_family, int8]
    49  	ind	const[0, int8]
    50  	id	proc[20000, 4, int32]
    51  }
    52  
    53  msghdr_un {
    54  	addr	ptr[in, sockaddr_un]
    55  	addrlen	len[addr, int32]
    56  	vec	ptr[in, array[iovec_in]]
    57  	vlen	len[vec, intptr]
    58  	ctrl	ptr[in, array[cmsghdr_un], opt]
    59  	ctrllen	bytesize[ctrl, intptr]
    60  	f	flags[send_flags, int32]
    61  }
    62  
    63  cmsghdr_un [
    64  	rights	cmsghdr_un_rights
    65  	cred	cmsghdr_un_cred
    66  ] [varlen]
    67  
    68  cmsghdr_un_rights {
    69  	len	len[parent, intptr]
    70  	level	const[SOL_SOCKET, int32]
    71  	type	const[SCM_RIGHTS, int32]
    72  	fds	array[fd]
    73  } [align[PTR_SIZE]]
    74  
    75  cmsghdr_un_cred {
    76  	len	len[parent, intptr]
    77  	level	const[SOL_SOCKET, int32]
    78  	type	const[SCM_CREDS, int32]
    79  	pid	pid
    80  	uid	uid
    81  	euid	uid
    82  	gid	gid
    83  	ngroups	len[groups, int16]
    84  	groups	array[gid, CMGROUP_MAX]
    85  } [align[PTR_SIZE]]