github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/linux/socket_inet.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 include <linux/ip.h> 5 include <linux/ipv6.h> 6 include <linux/route.h> 7 include <uapi/linux/if_arp.h> 8 include <uapi/linux/netfilter_ipv6/ip6_tables.h> 9 include <uapi/linux/wireless.h> 10 include <uapi/linux/in.h> 11 12 # IP sockets 13 14 resource sock_in[sock] 15 16 sockaddr_in { 17 family const[AF_INET, int16] 18 port sock_port 19 addr ipv4_addr 20 } [size[16]] 21 22 sockaddr_storage_in { 23 addr sockaddr_in 24 } [size[SOCKADDR_STORAGE_SIZE], align[PTR_SIZE]] 25 26 socket$inet(domain const[AF_INET], type flags[socket_type], proto int32) sock_in 27 accept$inet(fd sock_in, peer ptr[out, sockaddr_in, opt], peerlen ptr[inout, len[peer, int32]]) sock_in 28 accept4$inet(fd sock_in, peer ptr[out, sockaddr_in, opt], peerlen ptr[inout, len[peer, int32]], flags flags[accept_flags]) sock_in 29 bind$inet(fd sock_in, addr ptr[in, sockaddr_in], addrlen len[addr]) 30 connect$inet(fd sock_in, addr ptr[in, sockaddr_in], addrlen len[addr]) 31 sendto$inet(fd sock_in, buf buffer[in], len len[buf], f flags[send_flags], addr ptr[in, sockaddr_in, opt], addrlen len[addr]) 32 recvfrom$inet(fd sock_in, buf buffer[out], len len[buf], f flags[recv_flags], addr ptr[in, sockaddr_in, opt], addrlen len[addr]) 33 getsockname$inet(fd sock_in, addr ptr[out, sockaddr_in], addrlen ptr[inout, len[addr, int32]]) 34 getpeername$inet(fd sock_in, peer ptr[out, sockaddr_in], peerlen ptr[inout, len[peer, int32]]) 35 36 # Generic IP options 37 38 inet_option_types_int = IP_TOS, IP_TTL, IP_HDRINCL, IP_ROUTER_ALERT, IP_RECVOPTS, IP_RETOPTS, IP_PKTINFO, IP_MTU_DISCOVER, IP_RECVERR, IP_RECVTTL, IP_RECVTOS, IP_MTU, IP_FREEBIND, IP_PASSSEC, IP_TRANSPARENT, IP_RECVORIGDSTADDR, IP_MINTTL, IP_NODEFRAG, IP_CHECKSUM, IP_BIND_ADDRESS_NO_PORT, IP_MULTICAST_TTL, IP_MULTICAST_LOOP, IP_MULTICAST_ALL, IP_UNICAST_IF 39 40 inet_option_types_buf = IP_OPTIONS, IP_PKTOPTIONS, IP_IPSEC_POLICY, IP_XFRM_POLICY, IP_MSFILTER, MCAST_JOIN_GROUP, MCAST_LEAVE_SOURCE_GROUP, MCAST_MSFILTER, sockopt_opt_ip_mreq, sockopt_opt_ip_mreqsrc, sockopt_opt_group_source_req 41 42 getsockopt$inet_int(fd sock_in, level const[IPPROTO_IP], optname flags[inet_option_types_int], optval ptr[out, int32], optlen ptr[inout, len[optval, int32]]) 43 setsockopt$inet_int(fd sock_in, level const[IPPROTO_IP], optname flags[inet_option_types_int], optval ptr[in, int32], optlen len[optval]) 44 getsockopt$inet_buf(fd sock_in, level const[IPPROTO_IP], optname flags[inet_option_types_buf], optval buffer[out], optlen ptr[inout, len[optval, int32]]) 45 setsockopt$inet_buf(fd sock_in, level const[IPPROTO_IP], optname flags[inet_option_types_buf], optval buffer[in], optlen len[optval]) 46 47 # Specific IP options 48 49 sockopt_opt_ip_opts = IP_OPTIONS, IP_PKTOPTIONS 50 51 getsockopt$inet_opts(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_ip_opts], optval buffer[out], optlen ptr[inout, len[optval, int32]]) 52 setsockopt$inet_opts(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_ip_opts], optval buffer[in], optlen len[optval]) 53 54 getsockopt$inet_IP_IPSEC_POLICY(fd sock_in, level const[IPPROTO_IP], optname const[IP_IPSEC_POLICY], optval ptr[out, xfrm_filter], optlen ptr[inout, len[optval, int32]]) 55 setsockopt$inet_IP_IPSEC_POLICY(fd sock_in, level const[IPPROTO_IP], optname const[IP_IPSEC_POLICY], optval ptr[in, xfrm_filter], optlen len[optval]) 56 getsockopt$inet_IP_XFRM_POLICY(fd sock_in, level const[IPPROTO_IP], optname const[IP_XFRM_POLICY], optval ptr[out, xfrm_filter], optlen ptr[inout, len[optval, int32]]) 57 setsockopt$inet_IP_XFRM_POLICY(fd sock_in, level const[IPPROTO_IP], optname const[IP_XFRM_POLICY], optval ptr[in, xfrm_filter], optlen len[optval]) 58 59 sockopt_opt_ip_mreq = IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_MULTICAST_IF 60 61 getsockopt$inet_mreq(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_ip_mreq], optval ptr[out, ip_mreq], optlen ptr[inout, len[optval, int32]]) 62 setsockopt$inet_mreq(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_ip_mreq], optval ptr[in, ip_mreq], optlen len[optval]) 63 getsockopt$inet_mreqn(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_ip_mreq], optval ptr[out, ip_mreqn], optlen ptr[inout, len[optval, int32]]) 64 setsockopt$inet_mreqn(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_ip_mreq], optval ptr[in, ip_mreqn], optlen len[optval]) 65 66 sockopt_opt_ip_mreqsrc = IP_ADD_SOURCE_MEMBERSHIP, IP_BLOCK_SOURCE, IP_DROP_SOURCE_MEMBERSHIP, IP_UNBLOCK_SOURCE 67 68 getsockopt$inet_mreqsrc(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_ip_mreqsrc], optval ptr[out, ip_mreq_source], optlen ptr[inout, len[optval, int32]]) 69 setsockopt$inet_mreqsrc(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_ip_mreqsrc], optval ptr[in, ip_mreq_source], optlen len[optval]) 70 71 setsockopt$inet_msfilter(fd sock_in, level const[IPPROTO_IP], optname const[IP_MSFILTER], optval ptr[in, ip_msfilter], optlen len[optval]) 72 73 setsockopt$inet_MCAST_JOIN_GROUP(fd sock_in, level const[IPPROTO_IP], optname const[MCAST_JOIN_GROUP], optval ptr[in, group_req_in], optlen len[optval]) 74 setsockopt$inet_MCAST_LEAVE_GROUP(fd sock_in, level const[IPPROTO_IP], optname const[MCAST_LEAVE_GROUP], optval ptr[in, group_req_in], optlen len[optval]) 75 76 sockopt_opt_group_source_req = MCAST_JOIN_SOURCE_GROUP, MCAST_LEAVE_SOURCE_GROUP, MCAST_BLOCK_SOURCE, MCAST_UNBLOCK_SOURCE 77 78 setsockopt$inet_group_source_req(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_group_source_req], optval ptr[in, group_source_req_in], optlen len[optval]) 79 80 setsockopt$inet_MCAST_MSFILTER(fd sock_in, level const[IPPROTO_IP], optname const[MCAST_MSFILTER], optval ptr[in, group_filter_in], optlen len[optval]) 81 82 getsockopt$inet_pktinfo(fd sock_in, level const[IPPROTO_IP], optname const[IP_PKTINFO], optval ptr[out, in_pktinfo], optlen ptr[inout, len[optval, int32]]) 83 setsockopt$inet_pktinfo(fd sock_in, level const[IPPROTO_IP], optname const[IP_PKTINFO], optval ptr[in, in_pktinfo], optlen len[optval]) 84 85 getsockopt$inet_mtu(fd sock_in, level const[IPPROTO_IP], optname const[IP_MTU_DISCOVER], optval ptr[out, flags[ip_mtu_discover, int32]], optlen ptr[inout, len[optval, int32]]) 86 setsockopt$inet_mtu(fd sock_in, level const[IPPROTO_IP], optname const[IP_MTU_DISCOVER], optval ptr[in, flags[ip_mtu_discover, int32]], optlen len[optval]) 87 88 ip_mreq { 89 imr_multiaddr ipv4_addr 90 imr_interface ipv4_addr 91 } 92 93 ip_mreqn { 94 imr_multiaddr ipv4_addr 95 imr_address ipv4_addr 96 imr_ifindex ifindex 97 } 98 99 ip_mreq_source { 100 imr_multiaddr ipv4_addr 101 imr_interface ipv4_addr 102 imr_sourceaddr ipv4_addr 103 } 104 105 ip_msfilter { 106 imsf_multiaddr ipv4_addr 107 imsf_interface ipv4_addr 108 imsf_fmode flags[ip_msfilter_mode, int32] 109 imsf_numsrc len[imsf_slist, int32] 110 imsf_slist array[ipv4_addr] 111 } 112 113 ip_msfilter_mode = MCAST_INCLUDE, MCAST_EXCLUDE 114 115 in_pktinfo { 116 ipi_ifindex ifindex 117 ipi_spec_dst ipv4_addr 118 ipi_addr ipv4_addr 119 } 120 121 group_req_in { 122 gr_interface int32 123 gr_group sockaddr_storage_in 124 } 125 126 group_source_req_in { 127 gsr_interface int32 128 gsr_group sockaddr_storage_in 129 gsr_source sockaddr_storage_in 130 } 131 132 group_filter_in { 133 gf_interface int32 134 gf_group sockaddr_storage_in 135 gf_fmode flags[ip_msfilter_mode, int32] 136 gf_numsrc len[gf_slist, int32] 137 gf_slist array[sockaddr_storage_in] 138 } 139 140 ip_mtu_discover = IP_PMTUDISC_DONT, IP_PMTUDISC_WANT, IP_PMTUDISC_DO, IP_PMTUDISC_PROBE, IP_PMTUDISC_INTERFACE, IP_PMTUDISC_OMIT 141 142 # IP ioctls 143 144 # http://lxr.free-electrons.com/ident?i=inet_ioctl 145 146 ioctl$sock_inet_SIOCADDRT(fd sock_in, cmd const[SIOCADDRT], arg ptr[in, rtentry_in]) 147 ioctl$sock_inet_SIOCDELRT(fd sock_in, cmd const[SIOCDELRT], arg ptr[in, rtentry_in]) 148 ioctl$sock_inet_SIOCRTMSG(fd sock_in, cmd const[SIOCRTMSG], arg ptr[in, rtentry_in]) 149 150 ioctl$sock_inet_SIOCDARP(fd sock_in, cmd const[SIOCDARP], arg ptr[in, arpreq_in]) 151 ioctl$sock_inet_SIOCGARP(fd sock_in, cmd const[SIOCGARP], arg ptr[inout, arpreq_in]) 152 ioctl$sock_inet_SIOCSARP(fd sock_in, cmd const[SIOCSARP], arg ptr[in, arpreq_in]) 153 154 ioctl$sock_inet_SIOCGIFADDR(fd sock, cmd const[SIOCGIFADDR], arg ptr[out, ifreq_t[sockaddr_in]]) 155 ioctl$sock_inet_SIOCSIFADDR(fd sock, cmd const[SIOCSIFADDR], arg ptr[in, ifreq_t[sockaddr_in]]) 156 157 ioctl$sock_inet_SIOCGIFBRDADDR(fd sock, cmd const[SIOCGIFBRDADDR], arg ptr[out, ifreq_t[sockaddr_in]]) 158 ioctl$sock_inet_SIOCSIFBRDADDR(fd sock, cmd const[SIOCSIFBRDADDR], arg ptr[in, ifreq_t[sockaddr_in]]) 159 160 ioctl$sock_inet_SIOCGIFNETMASK(fd sock, cmd const[SIOCGIFNETMASK], arg ptr[out, ifreq_t[sockaddr_in]]) 161 ioctl$sock_inet_SIOCSIFNETMASK(fd sock, cmd const[SIOCSIFNETMASK], arg ptr[inout, ifreq_t[sockaddr_in]]) 162 163 ioctl$sock_inet_SIOCGIFDSTADDR(fd sock, cmd const[SIOCGIFDSTADDR], arg ptr[out, ifreq_t[sockaddr_in]]) 164 ioctl$sock_inet_SIOCSIFDSTADDR(fd sock, cmd const[SIOCSIFDSTADDR], arg ptr[in, ifreq_t[sockaddr_in]]) 165 166 ioctl$sock_inet_SIOCGIFPFLAGS(fd sock, cmd const[SIOCGIFPFLAGS], arg ptr[out, ifreq_t[int32]]) 167 ioctl$sock_inet_SIOCSIFPFLAGS(fd sock, cmd const[SIOCSIFPFLAGS], arg ptr[in, ifreq_t[int32]]) 168 169 ioctl$sock_inet_SIOCSIFFLAGS(fd sock, cmd const[SIOCSIFFLAGS], arg ptr[in, ifreq_t[flags[ifru_flags, int16]]]) 170 171 rt_flags = RTF_UP, RTF_GATEWAY, RTF_HOST, RTF_REINSTATE, RTF_DYNAMIC, RTF_MODIFIED, RTF_MTU, RTF_WINDOW, RTF_IRTT, RTF_REJECT 172 173 # TODO: add descriptions 174 _ = SIOCSIWNWID, SIOCGIWNWID, SIOCSIWFREQ, SIOCGIWFREQ, SIOCSIWMODE, SIOCGIWMODE, SIOCSIWSENS, SIOCGIWSENS 175 176 rtentry_in { 177 rt_pad1 const[0, int64] 178 rt_dst sockaddr_in 179 rt_gateway sockaddr_in 180 rt_genmask sockaddr_in 181 rt_flags flags[rt_flags, int16] 182 rt_pad2 const[0, int16] 183 rt_pad3 const[0, int64] 184 rt_pad4 const[0, intptr] 185 rt_metric int16 186 rt_dev ptr[in, devname, opt] 187 rt_mtu int64 188 rt_window int64 189 rt_irtt int16 190 } 191 192 sockaddr_ethernet_family = ARPHRD_ETHER, ARPHRD_FDDI, ARPHRD_IEEE802 193 194 sockaddr_ethernet { 195 sa_family flags[sockaddr_ethernet_family, int16] 196 sa_data mac_addr 197 } [size[SOCKADDR_SIZE]] 198 199 arp_flags = ATF_COM, ATF_PERM, ATF_PUBL, ATF_USETRAILERS, ATF_NETMASK, ATF_DONTPUB 200 201 arpreq_in { 202 arp_pa sockaddr_in 203 arp_ha sockaddr_ethernet 204 arp_flags flags[arp_flags, int32] 205 arp_netmask sockaddr_in 206 arp_dev devname 207 } 208 209 # sendmsg for ip_cmsg_send 210 211 msghdr_inet { 212 msg_name ptr[in, sockaddr_in, opt] 213 msg_namelen len[msg_name, int32] 214 msg_iov ptr[in, array[iovec_in]] 215 msg_iovlen len[msg_iov, intptr] 216 msg_control ptr[in, array[cmsghdr_inet], opt] 217 msg_controllen bytesize[msg_control, intptr] 218 msg_flags const[0, int32] 219 } 220 221 mmsghdr_inet { 222 msg_hdr msghdr_inet 223 msg_len const[0, int32] 224 } 225 226 cmsghdr_inet [ 227 ip_retopts cmsghdr_t[SOL_IP, IP_RETOPTS, ipv4_options] 228 ip_pktinfo cmsghdr_t[SOL_IP, IP_PKTINFO, in_pktinfo] 229 ip_ttl cmsghdr_t[SOL_IP, IP_TTL, int32] 230 ip_tos_int cmsghdr_t[SOL_IP, IP_TOS, int32] 231 ip_tos_u8 cmsghdr_t[SOL_IP, IP_TOS, int8] 232 ] [varlen] 233 234 sendmsg$inet(fd sock, msg ptr[in, msghdr_inet], f flags[send_flags]) 235 sendmmsg$inet(fd sock, mmsg ptr[in, array[mmsghdr_inet]], vlen len[mmsg], f flags[send_flags])