github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/openbsd/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  connect$unix(fd sock_unix, addr ptr[in, sockaddr_un], addrlen len[addr])
    16  accept$unix(fd sock_unix, peer ptr[out, sockaddr_un, opt], peerlen ptr[inout, len[peer, int32]]) sock_unix
    17  
    18  sendto$unix(fd sock_unix, buf buffer[in], len len[buf], f flags[send_flags], addr ptr[in, sockaddr_un, opt], addrlen len[addr])
    19  sendmsg$unix(fd sock_unix, msg ptr[in, msghdr_un], f flags[send_flags])
    20  recvfrom$unix(fd sock_unix, buf buffer[out], len len[buf], f flags[recv_flags], addr ptr[in, sockaddr_un, opt], addrlen len[addr])
    21  getsockname$unix(fd sock_unix, addr ptr[out, sockaddr_un], addrlen ptr[inout, len[addr, int32]])
    22  getpeername$unix(fd sock_unix, peer ptr[out, sockaddr_un], peerlen ptr[inout, len[peer, int32]])
    23  
    24  unix_socket_type = SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET
    25  unix_socket_family = AF_UNIX, AF_UNSPEC
    26  
    27  unix_pair {
    28  	fd0	sock_unix
    29  	fd1	sock_unix
    30  }
    31  
    32  sockaddr_un [
    33  	file	sockaddr_un_file
    34  	abs	sockaddr_un_abstract
    35  ] [varlen]
    36  
    37  sockaddr_un_file {
    38  	family	flags[unix_socket_family, int16]
    39  	path	filename
    40  } [packed]
    41  
    42  sockaddr_un_abstract {
    43  	family	flags[unix_socket_family, int16]
    44  	ind	const[0, int8]
    45  	id	proc[20000, 4, int32]
    46  }
    47  
    48  msghdr_un {
    49  	addr	ptr[in, sockaddr_un]
    50  	addrlen	len[addr, int32]
    51  	vec	ptr[in, array[iovec_in]]
    52  	vlen	len[vec, intptr]
    53  	ctrl	ptr[in, array[cmsghdr_un], opt]
    54  	ctrllen	bytesize[ctrl, intptr]
    55  	f	flags[send_flags, int32]
    56  }
    57  
    58  cmsghdr_un [
    59  	rights	cmsghdr_un_rights
    60  	cred	cmsghdr_un_cred
    61  ] [varlen]
    62  
    63  cmsghdr_un_rights {
    64  	len	len[parent, intptr]
    65  	level	const[SOL_SOCKET, int32]
    66  	type	const[SCM_RIGHTS, int32]
    67  	fds	array[fd]
    68  } [align[PTR_SIZE]]
    69  
    70  cmsghdr_un_cred {
    71  	len	len[parent, intptr]
    72  	level	const[SOL_SOCKET, int32]
    73  # XXX type	const[LINUX_SCM_CREDENTIALS, int32]
    74  	type	const[0, int32]
    75  	pid	pid
    76  	uid	uid
    77  	gid	gid
    78  } [align[PTR_SIZE]]