github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/linux/socket_inet_tcp.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_INET and AF_INET6: TCP support
     5  
     6  include <asm/ioctls.h>
     7  include <linux/tcp.h>
     8  include <linux/mptcp.h>
     9  include <net/tcp.h>
    10  include <uapi/linux/sockios.h>
    11  include <uapi/linux/tls.h>
    12  
    13  resource sock_tcp[sock_in]
    14  
    15  socket$inet_tcp(domain const[AF_INET], type const[SOCK_STREAM], proto const[0]) sock_tcp
    16  
    17  resource sock_mptcp[sock_tcp]
    18  socket$inet_mptcp(domain const[AF_INET], type const[SOCK_STREAM], proto const[IPPROTO_MPTCP]) sock_mptcp
    19  
    20  # From interface point of view SMC sockets seem to be the same as TCP.
    21  socket$inet_smc(domain const[AF_SMC], type const[SOCK_STREAM], proto const[0]) sock_tcp
    22  
    23  resource sock_tcp6[sock_in6]
    24  
    25  socket$inet6_tcp(domain const[AF_INET6], type const[SOCK_STREAM], proto const[0]) sock_tcp6
    26  
    27  resource sock_mptcp6[sock_tcp6]
    28  socket$inet6_mptcp(domain const[AF_INET6], type const[SOCK_STREAM], proto const[IPPROTO_MPTCP]) sock_mptcp6
    29  
    30  # Generic TCP socket options
    31  
    32  tcp_option_types_int = TCP_NODELAY, TCP_MAXSEG, TCP_CORK, TCP_KEEPIDLE, TCP_KEEPINTVL, TCP_KEEPCNT, TCP_SYNCNT, TCP_LINGER2, TCP_DEFER_ACCEPT, TCP_WINDOW_CLAMP, TCP_QUICKACK, TCP_THIN_LINEAR_TIMEOUTS, TCP_THIN_DUPACK, TCP_USER_TIMEOUT, TCP_FASTOPEN, TCP_FASTOPEN_CONNECT, TCP_FASTOPEN_NO_COOKIE, TCP_TIMESTAMP, TCP_NOTSENT_LOWAT, TCP_SAVE_SYN, TCP_INQ
    33  
    34  tcp_option_types_buf = TCP_INFO, TCP_CONGESTION, TCP_ULP, TCP_MD5SIG, TCP_CC_INFO, TCP_SAVED_SYN, TCP_FASTOPEN_KEY
    35  
    36  getsockopt$inet_tcp_int(fd sock_tcp, level const[IPPROTO_TCP], optname flags[tcp_option_types_int], optval ptr[out, int32], optlen ptr[inout, len[optval, int32]])
    37  setsockopt$inet_tcp_int(fd sock_tcp, level const[IPPROTO_TCP], optname flags[tcp_option_types_int], optval ptr[in, int32], optlen len[optval])
    38  getsockopt$inet6_tcp_int(fd sock_tcp6, level const[IPPROTO_TCP], optname flags[tcp_option_types_int], optval ptr[out, int32], optlen ptr[inout, len[optval, int32]])
    39  setsockopt$inet6_tcp_int(fd sock_tcp6, level const[IPPROTO_TCP], optname flags[tcp_option_types_int], optval ptr[in, int32], optlen len[optval])
    40  
    41  getsockopt$inet_tcp_buf(fd sock_tcp, level const[IPPROTO_TCP], optname flags[tcp_option_types_buf], optval buffer[out], optlen ptr[inout, len[optval, int32]])
    42  setsockopt$inet_tcp_buf(fd sock_tcp, level const[IPPROTO_TCP], optname flags[tcp_option_types_buf], optval buffer[in], optlen len[optval])
    43  getsockopt$inet6_tcp_buf(fd sock_tcp6, level const[IPPROTO_TCP], optname flags[tcp_option_types_buf], optval buffer[out], optlen ptr[inout, len[optval, int32]])
    44  setsockopt$inet6_tcp_buf(fd sock_tcp6, level const[IPPROTO_TCP], optname flags[tcp_option_types_buf], optval buffer[in], optlen len[optval])
    45  
    46  # Generic MPTCP socket options
    47  
    48  mptcp_option_types_buf = MPTCP_INFO, MPTCP_FULL_INFO, MPTCP_TCPINFO, MPTCP_SUBFLOW_ADDRS
    49  
    50  getsockopt$inet_mptcp_buf(fd sock_mptcp, level const[SOL_MPTCP], optname flags[mptcp_option_types_buf], optval buffer[out], optlen ptr[inout, len[optval, int32]])
    51  getsockopt$inet6_mptcp_buf(fd sock_mptcp6, level const[SOL_MPTCP], optname flags[mptcp_option_types_buf], optval buffer[out], optlen ptr[inout, len[optval, int32]])
    52  
    53  # Specific TCP socket options
    54  
    55  getsockopt$inet_tcp_TCP_ZEROCOPY_RECEIVE(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_ZEROCOPY_RECEIVE], optval ptr[in, tcp_zerocopy_receive], optlen ptr[inout, len[optval, int32]])
    56  getsockopt$inet6_tcp_TCP_ZEROCOPY_RECEIVE(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TCP_ZEROCOPY_RECEIVE], optval ptr[in, tcp_zerocopy_receive], optlen ptr[inout, len[optval, int32]])
    57  
    58  tcp_zerocopy_receive {
    59  	address		vma64
    60  	length		len[address, int32]
    61  	recv_skip_hint	int32	(out)
    62  	inq		int32	(out)
    63  	err		int32	(out)
    64  	copybuf_address	ptr64[out, array[int8]]
    65  	copybuf_len	bytesize[copybuf_address, int32]
    66  	flags		flags[tcp_zerocopy_receive_flags, int32]
    67  	msg_control	ptr64[out, array[int8]]
    68  	msg_controllen	bytesize[msg_control, int64]
    69  	msg_flags	int32	(out)
    70  	reserved	const[0, int32]
    71  }
    72  
    73  tcp_zerocopy_receive_flags = TCP_RECEIVE_ZEROCOPY_FLAG_TLB_CLEAN_HINT
    74  
    75  # Specific TCP socket options
    76  
    77  # TODO: use TCP_SAVED_SYN to extract sequence numbers
    78  
    79  setsockopt$inet_tcp_TCP_CONGESTION(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_CONGESTION], optval ptr[in, string[tcp_congestion_control_alg_names]], optlen len[optval])
    80  setsockopt$inet6_tcp_TCP_CONGESTION(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TCP_CONGESTION], optval ptr[in, string[tcp_congestion_control_alg_names]], optlen len[optval])
    81  
    82  setsockopt$inet_tcp_TCP_ULP(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_ULP], optval ptr[in, string[tcp_ulp_names]], optlen len[optval])
    83  setsockopt$inet6_tcp_TCP_ULP(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TCP_ULP], optval ptr[in, string[tcp_ulp_names]], optlen len[optval])
    84  
    85  setsockopt$inet_tcp_TCP_MD5SIG(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_MD5SIG], optval ptr[in, tcp_md5sig], optlen len[optval])
    86  setsockopt$inet6_tcp_TCP_MD5SIG(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TCP_MD5SIG], optval ptr[in, tcp_md5sig], optlen len[optval])
    87  
    88  setsockopt$inet_tcp_TCP_REPAIR(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_REPAIR], optval ptr[in, flags[tcp_repair_modes, int32]], optlen len[optval])
    89  setsockopt$inet6_tcp_TCP_REPAIR(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TCP_REPAIR], optval ptr[in, flags[tcp_repair_modes, int32]], optlen len[optval])
    90  
    91  tcp_repair_modes = TCP_REPAIR_ON, TCP_REPAIR_OFF, TCP_REPAIR_OFF_NO_WP
    92  
    93  setsockopt$inet_tcp_TCP_REPAIR_QUEUE(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_REPAIR_QUEUE], optval ptr[in, flags[tcp_repair_queue_modes, int32]], optlen len[optval])
    94  setsockopt$inet6_tcp_TCP_REPAIR_QUEUE(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TCP_REPAIR_QUEUE], optval ptr[in, flags[tcp_repair_queue_modes, int32]], optlen len[optval])
    95  
    96  tcp_repair_queue_modes = TCP_NO_QUEUE, TCP_RECV_QUEUE, TCP_SEND_QUEUE
    97  
    98  setsockopt$inet_tcp_TCP_QUEUE_SEQ(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_QUEUE_SEQ], optval ptr[in, int32], optlen len[optval])
    99  setsockopt$inet6_tcp_TCP_QUEUE_SEQ(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TCP_QUEUE_SEQ], optval ptr[in, int32], optlen len[optval])
   100  
   101  setsockopt$inet_tcp_TCP_REPAIR_OPTIONS(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_REPAIR_OPTIONS], optval ptr[in, array[tcp_repair_opt]], optlen len[optval])
   102  setsockopt$inet6_tcp_TCP_REPAIR_OPTIONS(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TCP_REPAIR_OPTIONS], optval ptr[in, array[tcp_repair_opt]], optlen len[optval])
   103  
   104  getsockopt$inet_tcp_TCP_REPAIR_WINDOW(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_REPAIR_WINDOW], optval ptr[out, tcp_repair_window], optlen ptr[inout, len[optval, int32]])
   105  setsockopt$inet_tcp_TCP_REPAIR_WINDOW(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_REPAIR_WINDOW], optval ptr[in, tcp_repair_window], optlen len[optval])
   106  getsockopt$inet6_tcp_TCP_REPAIR_WINDOW(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TCP_REPAIR_WINDOW], optval ptr[out, tcp_repair_window], optlen ptr[inout, len[optval, int32]])
   107  setsockopt$inet6_tcp_TCP_REPAIR_WINDOW(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TCP_REPAIR_WINDOW], optval ptr[in, tcp_repair_window], optlen len[optval])
   108  
   109  setsockopt$inet_tcp_TCP_FASTOPEN_KEY(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_FASTOPEN_KEY], optval ptr[in, array[int8, TCP_FASTOPEN_KEY_LENGTH]], optlen len[optval])
   110  setsockopt$inet6_tcp_TCP_FASTOPEN_KEY(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TCP_FASTOPEN_KEY], optval ptr[in, array[int8, TCP_FASTOPEN_KEY_LENGTH]], optlen len[optval])
   111  
   112  setsockopt$inet_tcp_TLS_TX(fd sock_tcp, level const[IPPROTO_TCP], optname const[TLS_TX], optval ptr[in, tls_crypto_info_u], optlen len[optval])
   113  setsockopt$inet6_tcp_TLS_TX(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TLS_TX], optval ptr[in, tls_crypto_info_u], optlen len[optval])
   114  setsockopt$inet_tcp_TLS_RX(fd sock_tcp, level const[IPPROTO_TCP], optname const[TLS_RX], optval ptr[in, tls_crypto_info_u], optlen len[optval])
   115  setsockopt$inet6_tcp_TLS_RX(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TLS_RX], optval ptr[in, tls_crypto_info_u], optlen len[optval])
   116  
   117  tcp_congestion_control_alg_names = "cubic", "reno", "bic", "cdg", "dctcp", "westwood", "highspeed", "hybla", "htcp", "vegas", "nv", "veno", "scalable", "lp", "yeah", "illinois", "dctcp-reno", "bbr"
   118  
   119  tcp_ulp_names = "tls"
   120  
   121  tcp_repair_window {
   122  	snd_wl1		int32
   123  	snd_wnd		int32
   124  	max_window	int32
   125  	rcv_wnd		int32
   126  	rcv_wup		int32
   127  }
   128  
   129  sockaddr_storage_tcp [
   130  	in	sockaddr_storage_in
   131  	in6	sockaddr_storage_in6
   132  ]
   133  
   134  tcp_md5sig {
   135  	tcpm_addr	sockaddr_storage_tcp
   136  	tcpm_flags	const[0, int8]
   137  	tcpm_prefixlen	const[0, int8]
   138  	tcpm_keylen	int16[0:TCP_MD5SIG_MAXKEYLEN]
   139  	__tcpm_pad	const[0, int32]
   140  	tcpm_key	array[int8, TCP_MD5SIG_MAXKEYLEN]
   141  }
   142  
   143  tcp_repair_opt [
   144  	mss		tcp_repair_opt_mss
   145  	window		tcp_repair_opt_window
   146  	sack_perm	tcp_repair_opt_sack_perm
   147  	timestamp	tcp_repair_opt_timestamp
   148  ]
   149  
   150  tcp_repair_opt_mss {
   151  	opt_code	const[TCPOPT_MSS, int32]
   152  	opt_val		int32
   153  }
   154  
   155  tcp_repair_opt_window {
   156  	opt_code	const[TCPOPT_WINDOW, int32]
   157  	snd_wscale	int16
   158  	rcv_wscale	int16
   159  }
   160  
   161  tcp_repair_opt_sack_perm {
   162  	opt_code	const[TCPOPT_SACK_PERM, int32]
   163  	opt_val		const[0, int32]
   164  }
   165  
   166  tcp_repair_opt_timestamp {
   167  	opt_code	const[TCPOPT_TIMESTAMP, int32]
   168  	opt_val		const[0, int32]
   169  }
   170  
   171  type tls_crypto_info[TYP] {
   172  	version		flags[tls_crypto_version, int16]
   173  	cipher_type	const[TYP, int16]
   174  }
   175  
   176  tls_crypto_version = TLS_1_2_VERSION, TLS_1_3_VERSION
   177  
   178  tls_crypto_info_u [
   179  	gcm_128	tls12_crypto_info_aes_gcm_128
   180  	gcm_256	tls12_crypto_info_aes_gcm_256
   181  	ccm_128	tls12_crypto_info_aes_ccm_128
   182  ] [varlen]
   183  
   184  tls12_crypto_info_aes_gcm_128 {
   185  	info	tls_crypto_info[TLS_CIPHER_AES_GCM_128]
   186  	iv	array[int8, TLS_CIPHER_AES_GCM_128_IV_SIZE]
   187  	key	array[int8, TLS_CIPHER_AES_GCM_128_KEY_SIZE]
   188  	salt	array[int8, TLS_CIPHER_AES_GCM_128_SALT_SIZE]
   189  	rec_seq	array[int8, TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE]
   190  }
   191  
   192  tls12_crypto_info_aes_gcm_256 {
   193  	info	tls_crypto_info[TLS_CIPHER_AES_GCM_256]
   194  	iv	array[int8, TLS_CIPHER_AES_GCM_256_IV_SIZE]
   195  	key	array[int8, TLS_CIPHER_AES_GCM_256_KEY_SIZE]
   196  	salt	array[int8, TLS_CIPHER_AES_GCM_256_SALT_SIZE]
   197  	rec_seq	array[int8, TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE]
   198  }
   199  
   200  tls12_crypto_info_aes_ccm_128 {
   201  	info	tls_crypto_info[TLS_CIPHER_AES_CCM_128]
   202  	iv	array[int8, TLS_CIPHER_AES_CCM_128_IV_SIZE]
   203  	key	array[int8, TLS_CIPHER_AES_CCM_128_KEY_SIZE]
   204  	salt	array[int8, TLS_CIPHER_AES_CCM_128_SALT_SIZE]
   205  	rec_seq	array[int8, TLS_CIPHER_AES_CCM_128_REC_SEQ_SIZE]
   206  }
   207  
   208  # TCP ioctls
   209  
   210  # http://lxr.free-electrons.com/ident?i=tcp_ioctl
   211  
   212  ioctl$sock_inet_tcp_SIOCINQ(fd sock_tcp, cmd const[SIOCINQ], arg ptr[out, int32])
   213  ioctl$sock_inet6_tcp_SIOCINQ(fd sock_tcp6, cmd const[SIOCINQ], arg ptr[out, int32])
   214  
   215  ioctl$sock_inet_tcp_SIOCATMARK(fd sock_tcp, cmd const[SIOCATMARK], arg ptr[out, int32])
   216  ioctl$sock_inet6_tcp_SIOCATMARK(fd sock_tcp6, cmd const[SIOCATMARK], arg ptr[out, int32])
   217  
   218  ioctl$sock_inet_tcp_SIOCOUTQ(fd sock_tcp, cmd const[SIOCOUTQ], arg ptr[out, int32])
   219  ioctl$sock_inet6_tcp_SIOCOUTQ(fd sock_tcp6, cmd const[SIOCOUTQ], arg ptr[out, int32])
   220  
   221  ioctl$sock_inet_tcp_SIOCOUTQNSD(fd sock_tcp, cmd const[SIOCOUTQNSD], arg ptr[out, int32])
   222  ioctl$sock_inet6_tcp_SIOCOUTQNSD(fd sock_tcp6, cmd const[SIOCOUTQNSD], arg ptr[out, int32])