"tcp: secure_seq: add back ports to TS offset" and deps
cover "tcp: secure_seq: add back ports to TS offset" and deps
From: Heiko Stuebner <[email protected]>
tcp: secure_seq: add back ports to TS offset needed two dependencies to apply cleanly. With them just being the IPV6-specific symbol EXPORT change.
I've tested these on top of 6.12.93 with all of
- CONFIG_IPV6 = y
- CONFIG_IPV6 = m
- CONFIG_IPV6 is not set
Eric Dumazet (3):
net: introduce EXPORT_IPV6_MOD() and EXPORT_IPV6_MOD_GPL()
tcp: use EXPORT_IPV6_MOD[_GPL]()
tcp: secure_seq: add back ports to TS offset
include/net/ip.h | 8 ++++ include/net/secure_seq.h | 45 +++++++++++++++++---- include/net/tcp.h | 6 ++- net/core/secure_seq.c | 80 ++++++++++++++------------------------ net/ipv4/syncookies.c | 19 +++++---- net/ipv4/tcp.c | 44 ++++++++++----------- net/ipv4/tcp_fastopen.c | 2 +- net/ipv4/tcp_input.c | 22 ++++++----- net/ipv4/tcp_ipv4.c | 84 +++++++++++++++++++--------------------- net/ipv4/tcp_minisocks.c | 11 +++--- net/ipv4/tcp_output.c | 12 +++--- net/ipv4/tcp_timer.c | 4 +- net/ipv6/syncookies.c | 11 ++++-- net/ipv6/tcp_ipv6.c | 37 ++++++++---------- 14 files changed, 205 insertions(+), 180 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/3 net: introduce EXPORT_IPV6_MOD() and EXPORT_IPV6_MOD_GPL()
From: Eric Dumazet <[email protected]>
[ Upstream commit 54568a84c95bdea20227cf48d41f198d083e78dd ]
We have many EXPORT_SYMBOL(x) in networking tree because IPv6 can be built as a module.
CONFIG_IPV6=y is becoming the norm.
Define a EXPORT_IPV6_MOD(x) which only exports x
for modular IPv6.
Same principle applies to EXPORT_IPV6_MOD_GPL()
--- include/net/ip.h | 8 ++++++++ 1 file changed, 8 insertions(+)
include/net/ip.h +8 -0
@@ -675,6 +675,14 @@ static inline void ip_ipgre_mc_map(__be32 naddr, const unsigned char *broadcast,memcpy (buf, &naddr,sizeof (naddr)); } +#if IS_MODULE (CONFIG_IPV6 ) +#define EXPORT_IPV6_MOD (X ) EXPORT_SYMBOL(X) +#define EXPORT_IPV6_MOD_GPL (X ) EXPORT_SYMBOL_GPL(X) +#else +#define EXPORT_IPV6_MOD (X ) +#define EXPORT_IPV6_MOD_GPL (X ) +#endif +#if IS_ENABLED (CONFIG_IPV6 )#include <linux/ipv6.h> #endif
Signature · 1 line
2.53.0
PATCH 2/3 tcp: use EXPORT_IPV6_MOD[_GPL]()
In reply to Heiko StuebnerFrom: Eric Dumazet <[email protected]>
[ Upstream commit 6dc4c2526f6d11f36c4e26d0231b345eabab584c ]
Use EXPORT_IPV6_MOD[_GPL]() for symbols that don't need to be exported unless CONFIG_IPV6=m
tcp_hashinfo and tcp_openreq_init_rwin() are no longer used from any module anyway.
--- net/core/secure_seq.c | 2 +- net/ipv4/syncookies.c | 8 +++---- net/ipv4/tcp.c | 44 ++++++++++++++++++------------------- net/ipv4/tcp_fastopen.c | 2 +- net/ipv4/tcp_input.c | 14 ++++++------ net/ipv4/tcp_ipv4.c | 47 ++++++++++++++++++++-------------------- net/ipv4/tcp_minisocks.c | 11 +++++----- net/ipv4/tcp_output.c | 12 +++++----- net/ipv4/tcp_timer.c | 4 ++-- 9 files changed, 71 insertions(+), 73 deletions(-)
net/core/secure_seq.c +1 -1
@@ -71,7 +71,7 @@ u32 secure_tcpv6_ts_off(const struct net *net,return siphash (&combined,offsetofend (typeof (combined), daddr), &ts_secret); } -EXPORT_SYMBOL (secure_tcpv6_ts_off); +EXPORT_IPV6_MOD (secure_tcpv6_ts_off);u32 secure_tcpv6_seq (const __be32 *saddr,const __be32 *daddr,__be16 sport,__be16 dport)
net/ipv4/syncookies.c +4 -4
@@ -222,7 +222,7 @@ struct sock *tcp_get_cookie_sock(struct sock *sk, struct sk_buff *skb,return NULL ; } -EXPORT_SYMBOL (tcp_get_cookie_sock); +EXPORT_IPV6_MOD (tcp_get_cookie_sock);/* * when syncookies are in effect and tcp timestamps are enabled we stored
@@ -259,7 +259,7 @@ bool cookie_timestamp_decode(const struct net *net,return READ_ONCE (net->ipv4.sysctl_tcp_window_scaling) !=0 ; } -EXPORT_SYMBOL (cookie_timestamp_decode); +EXPORT_IPV6_MOD (cookie_timestamp_decode);static int cookie_tcp_reqsk_init (struct sock *sk,struct sk_buff *skb,struct request_sock *req)
@@ -309,7 +309,7 @@ struct request_sock *cookie_bpf_check(struct sock *sk, struct sk_buff *skb)return req; } -EXPORT_SYMBOL_GPL (cookie_bpf_check); +EXPORT_IPV6_MOD_GPL (cookie_bpf_check);#endif struct request_sock *cookie_tcp_reqsk_alloc(const struct request_sock_ops *ops,
@@ -351,7 +351,7 @@ struct request_sock *cookie_tcp_reqsk_alloc(const struct request_sock_ops *ops,return req; } -EXPORT_SYMBOL_GPL (cookie_tcp_reqsk_alloc); +EXPORT_IPV6_MOD_GPL (cookie_tcp_reqsk_alloc);static struct request_sock *cookie_tcp_check (struct net *net,struct sock *sk,struct sk_buff *skb)
net/ipv4/tcp.c +22 -22
169 lines not on this page · raw message
net/ipv4/tcp_fastopen.c +1 -1
@@ -471,7 +471,7 @@ bool tcp_fastopen_defer_connect(struct sock *sk, int *err) }return false; } -EXPORT_SYMBOL (tcp_fastopen_defer_connect); +EXPORT_IPV6_MOD (tcp_fastopen_defer_connect);/* * The following code block is to deal with middle box issues with TFO:
net/ipv4/tcp_input.c +7 -7
@@ -649,7 +649,7 @@ void tcp_initialize_rcv_mss(struct sock *sk)inet_csk (sk)->icsk_ack.rcv_mss = hint; } -EXPORT_SYMBOL (tcp_initialize_rcv_mss); +EXPORT_IPV6_MOD (tcp_initialize_rcv_mss);/* Receiver "autotuning" code. *
@@ -2911,7 +2911,7 @@ void tcp_simple_retransmit(struct sock *sk)*/ tcp_non_congestion_loss_retransmit (sk); } -EXPORT_SYMBOL (tcp_simple_retransmit); +EXPORT_IPV6_MOD (tcp_simple_retransmit);void tcp_enter_recovery (struct sock *sk,bool ece_ack) {
@@ -4540,7 +4540,7 @@ void tcp_done_with_error(struct sock *sk, int err)if (!sock_flag (sk,SOCK_DEAD ))sk_error_report (sk); } -EXPORT_SYMBOL (tcp_done_with_error); +EXPORT_IPV6_MOD (tcp_done_with_error);/* When we get a reset we do this. */ void tcp_reset (struct sock *sk,struct sk_buff *skb)
@@ -6302,7 +6302,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) discard:tcp_drop_reason (sk, skb, reason); } -EXPORT_SYMBOL (tcp_rcv_established); +EXPORT_IPV6_MOD (tcp_rcv_established);void tcp_init_transfer (struct sock *sk,int bpf_op,struct sk_buff *skb) {
@@ -7016,7 +7016,7 @@ tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)__kfree_skb (skb);return 0 ; } -EXPORT_SYMBOL (tcp_rcv_state_process); +EXPORT_IPV6_MOD (tcp_rcv_state_process);static inline void pr_drop_req (struct request_sock *req,__u16 port,int family) {
@@ -7198,7 +7198,7 @@ u16 tcp_get_syncookie_mss(struct request_sock_ops *rsk_ops,return mss; } -EXPORT_SYMBOL_GPL (tcp_get_syncookie_mss); +EXPORT_IPV6_MOD_GPL (tcp_get_syncookie_mss); int tcp_conn_request(struct request_sock_ops *rsk_ops, const struct tcp_request_sock_ops *af_ops,
@@ -7378,4 +7378,4 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,tcp_listendrop (sk);return 0 ; } -EXPORT_SYMBOL (tcp_conn_request); +EXPORT_IPV6_MOD (tcp_conn_request);
net/ipv4/tcp_ipv4.c +23 -24
191 lines not on this page · raw message
net/ipv4/tcp_minisocks.c +5 -6
@@ -261,7 +261,7 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb,inet_twsk_put (tw);return TCP_TW_SUCCESS ; } -EXPORT_SYMBOL (tcp_timewait_state_process); +EXPORT_IPV6_MOD (tcp_timewait_state_process);static void tcp_time_wait_init (struct sock *sk,struct tcp_timewait_sock *tcptw) {
@@ -389,7 +389,7 @@ void tcp_twsk_destructor(struct sock *sk)#endif tcp_ao_destroy_sock (sk, true); } -EXPORT_SYMBOL_GPL (tcp_twsk_destructor); +EXPORT_IPV6_MOD_GPL (tcp_twsk_destructor);void tcp_twsk_purge (struct list_head *net_exit_list) {
@@ -448,7 +448,6 @@ void tcp_openreq_init_rwin(struct request_sock *req, rcv_wnd); ireq->rcv_wscale = rcv_wscale; } -EXPORT_SYMBOL (tcp_openreq_init_rwin);static void tcp_ecn_openreq_child (struct tcp_sock *tp,const struct request_sock *req)
@@ -483,7 +482,7 @@ void tcp_ca_openreq_child(struct sock *sk, const struct dst_entry *dst)tcp_set_ca_state (sk, TCP_CA_Open); } -EXPORT_SYMBOL_GPL (tcp_ca_openreq_child); +EXPORT_IPV6_MOD_GPL (tcp_ca_openreq_child); static void smc_check_reset_syn_req(const struct tcp_sock *oldtp, struct request_sock *req,
@@ -899,7 +898,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, }return NULL ; } -EXPORT_SYMBOL (tcp_check_req); +EXPORT_IPV6_MOD (tcp_check_req);/* * Queue segment on the new socket if the new socket is active,
@@ -941,4 +940,4 @@ enum skb_drop_reason tcp_child_process(struct sock *parent, struct sock *child,sock_put (child);return reason; } -EXPORT_SYMBOL (tcp_child_process); +EXPORT_IPV6_MOD (tcp_child_process);
net/ipv4/tcp_output.c +6 -6
@@ -250,7 +250,7 @@ void tcp_select_initial_window(const struct sock *sk, int __space, __u32 mss,WRITE_ONCE (*__window_clamp,min_t (__u32,U16_MAX << (*rcv_wscale), window_clamp)); } -EXPORT_SYMBOL (tcp_select_initial_window); +EXPORT_IPV6_MOD (tcp_select_initial_window);/* Chose a new window to advertise, update state in tcp_sock for the * socket, and return result with RFC1323 scaling applied. The return
@@ -1171,7 +1171,7 @@ void tcp_release_cb(struct sock *sk)if ((flags &TCPF_ACK_DEFERRED ) &&inet_csk_ack_scheduled (sk))tcp_send_ack (sk); } -EXPORT_SYMBOL (tcp_release_cb); +EXPORT_IPV6_MOD (tcp_release_cb);void __init tcp_tasklet_init (void ) {
@@ -1785,7 +1785,7 @@ int tcp_mtu_to_mss(struct sock *sk, int pmtu)return __tcp_mtu_to_mss (sk, pmtu) - (tcp_sk (sk)->tcp_header_len -sizeof (struct tcphdr )); } -EXPORT_SYMBOL (tcp_mtu_to_mss); +EXPORT_IPV6_MOD (tcp_mtu_to_mss);/* Inverse of above */ int tcp_mss_to_mtu (struct sock *sk,int mss)
@@ -1859,7 +1859,7 @@ unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu)return mss_now; } -EXPORT_SYMBOL (tcp_sync_mss); +EXPORT_IPV6_MOD (tcp_sync_mss);/* Compute the current effective MSS, taking SACKs and IP options, * and even PMTU discovery events into account.
@@ -3869,7 +3869,7 @@ struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst,return skb; } -EXPORT_SYMBOL (tcp_make_synack); +EXPORT_IPV6_MOD (tcp_make_synack);static void tcp_ca_dst_init (struct sock *sk,const struct dst_entry *dst) {
@@ -4443,4 +4443,4 @@ int tcp_rtx_synack(const struct sock *sk, struct request_sock *req) }return res; } -EXPORT_SYMBOL (tcp_rtx_synack); +EXPORT_IPV6_MOD (tcp_rtx_synack);
net/ipv4/tcp_timer.c +2 -2
@@ -736,7 +736,7 @@ void tcp_syn_ack_timeout(const struct request_sock *req)__NET_INC_STATS (net,LINUX_MIB_TCPTIMEOUTS ); } -EXPORT_SYMBOL (tcp_syn_ack_timeout); +EXPORT_IPV6_MOD (tcp_syn_ack_timeout);void tcp_set_keepalive (struct sock *sk,int val) {
@@ -748,7 +748,7 @@ void tcp_set_keepalive(struct sock *sk, int val)else if (!val)inet_csk_delete_keepalive_timer (sk); } -EXPORT_SYMBOL_GPL (tcp_set_keepalive); +EXPORT_IPV6_MOD_GPL (tcp_set_keepalive);static void tcp_keepalive_timer (struct timer_list *t)
Signature · 1 line
2.53.0
PATCH 3/3 tcp: secure_seq: add back ports to TS offset
In reply to Heiko StuebnerFrom: Eric Dumazet <[email protected]>
[ Upstream commit 165573e41f2f66ef98940cf65f838b2cb575d9d1 ]
This reverts 28ee1b746f49 ("secure_seq: downgrade to per-host timestamp offsets")
tcp_tw_recycle went away in 2017.
Zhouyan Deng reported off-path TCP source port leakage via SYN cookie side-channel that can be fixed in multiple ways.
One of them is to bring back TCP ports in TS offset randomization.
As a bonus, we perform a single siphash() computation to provide both an ISN and a TS offset.
[kept the DCCP functions in the header, as DCCP was not retired yet
in 6.12]
--- include/net/secure_seq.h | 45 ++++++++++++++++++---- include/net/tcp.h | 6 ++- net/core/secure_seq.c | 80 +++++++++++++++------------------------- net/ipv4/syncookies.c | 11 ++++-- net/ipv4/tcp_input.c | 8 +++- net/ipv4/tcp_ipv4.c | 37 +++++++++---------- net/ipv6/syncookies.c | 11 ++++-- net/ipv6/tcp_ipv6.c | 37 +++++++++---------- 8 files changed, 127 insertions(+), 108 deletions(-)
include/net/secure_seq.h +38 -7
@@ -5,20 +5,51 @@#include <linux/types.h> struct net ; +extern struct net init_net; + +union tcp_seq_and_ts_off { +struct { +u32 seq; +u32 ts_off; + }; +u64 hash64; +};u64 secure_ipv4_port_ephemeral (__be32 saddr,__be32 daddr,__be16 dport);u64 secure_ipv6_port_ephemeral (const __be32 *saddr,const __be32 *daddr,__be16 dport); -u32 secure_tcp_seq (__be32 saddr,__be32 daddr, -__be16 sport,__be16 dport); -u32 secure_tcp_ts_off (const struct net *net,__be32 saddr,__be32 daddr); -u32 secure_tcpv6_seq (const __be32 *saddr,const __be32 *daddr, -__be16 sport,__be16 dport); -u32 secure_tcpv6_ts_off (const struct net *net, -const __be32 *saddr,const __be32 *daddr); +union tcp_seq_and_ts_off +secure_tcp_seq_and_ts_off (const struct net *net,__be32 saddr,__be32 daddr, +__be16 sport,__be16 dport);u64 secure_dccp_sequence_number (__be32 saddr,__be32 daddr,__be16 sport,__be16 dport);u64 secure_dccpv6_sequence_number (__be32 *saddr,__be32 *daddr,__be16 sport,__be16 dport); +static inline u32 secure_tcp_seq (__be32 saddr,__be32 daddr, +__be16 sport,__be16 dport) +{ +union tcp_seq_and_ts_off ts; + + ts =secure_tcp_seq_and_ts_off (&init_net, saddr, daddr, + sport, dport); + +return ts.seq; +} + +union tcp_seq_and_ts_off +secure_tcpv6_seq_and_ts_off (const struct net *net,const __be32 *saddr, +const __be32 *daddr, +__be16 sport,__be16 dport); + +static inline u32 secure_tcpv6_seq (const __be32 *saddr,const __be32 *daddr, +__be16 sport,__be16 dport) +{ +union tcp_seq_and_ts_off ts; + + ts =secure_tcpv6_seq_and_ts_off (&init_net, saddr, daddr, + sport, dport); + +return ts.seq; +}#endif /* _NET_SECURE_SEQ */
include/net/tcp.h +4 -2
@@ -42,6 +42,7 @@#include <net/dst.h> #include <net/mptcp.h> #include <net/xfrm.h> +#include <net/secure_seq.h> #include <linux/seq_file.h> #include <linux/memcontrol.h>
@@ -2307,8 +2308,9 @@ struct tcp_request_sock_ops {struct flowi *fl, struct request_sock *req, u32 tw_isn); -u32 (*init_seq)(const struct sk_buff *skb); -u32 (*init_ts_off)(const struct net *net,const struct sk_buff *skb); +union tcp_seq_and_ts_off (*init_seq_and_ts_off)( +const struct net *net, +const struct sk_buff *skb); int (*send_synack)(const struct sock *sk, struct dst_entry *dst, struct flowi *fl, struct request_sock *req, struct tcp_fastopen_cookie *foc,
net/core/secure_seq.c +29 -51
122 lines not on this page · raw message
net/ipv4/syncookies.c +8 -3
@@ -376,9 +376,14 @@ static struct request_sock *cookie_tcp_check(struct net *net, struct sock *sk,tcp_parse_options (net, skb, &tcp_opt,0 ,NULL );if (tcp_opt.saw_tstamp && tcp_opt.rcv_tsecr) { - tsoff =secure_tcp_ts_off (net, -ip_hdr (skb)->daddr, -ip_hdr (skb)->saddr); +union tcp_seq_and_ts_off st; + + st =secure_tcp_seq_and_ts_off (net, +ip_hdr (skb)->daddr, +ip_hdr (skb)->saddr, +tcp_hdr (skb)->dest, +tcp_hdr (skb)->source); + tsoff = st.ts_off; tcp_opt.rcv_tsecr -= tsoff; }
net/ipv4/tcp_input.c +6 -2
@@ -7209,6 +7209,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,struct tcp_sock *tp =tcp_sk (sk);struct net *net =sock_net (sk);struct sock *fastopen_sk =NULL ; +union tcp_seq_and_ts_off st;struct request_sock *req;bool want_cookie = false;struct dst_entry *dst;
@@ -7278,9 +7279,12 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,if (!dst) goto drop_and_free; +if (tmp_opt.tstamp_ok || (!want_cookie && !isn)) + st = af_ops->init_seq_and_ts_off (net, skb); +if (tmp_opt.tstamp_ok) {tcp_rsk (req)->req_usec_ts =dst_tcp_usec_ts (dst); -tcp_rsk (req)->ts_off = af_ops->init_ts_off (net, skb); +tcp_rsk (req)->ts_off = st.ts_off; }if (!want_cookie && !isn) {int max_syn_backlog =READ_ONCE (net->ipv4.sysctl_max_syn_backlog);
@@ -7302,7 +7306,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops, goto drop_and_release; } - isn = af_ops->init_seq (skb); + isn = st.seq; }tcp_ecn_create_request (req, skb, sk, dst);
net/ipv4/tcp_ipv4.c +17 -20
@@ -100,17 +100,14 @@ static DEFINE_PER_CPU(struct sock_bh_locked, ipv4_tcp_sk) = {static DEFINE_MUTEX (tcp_exit_batch_mutex); -static u32 tcp_v4_init_seq (const struct sk_buff *skb) +static union tcp_seq_and_ts_off +tcp_v4_init_seq_and_ts_off (const struct net *net,const struct sk_buff *skb) { -return secure_tcp_seq (ip_hdr (skb)->daddr, -ip_hdr (skb)->saddr, -tcp_hdr (skb)->dest, -tcp_hdr (skb)->source); -} - -static u32 tcp_v4_init_ts_off (const struct net *net,const struct sk_buff *skb) -{ -return secure_tcp_ts_off (net,ip_hdr (skb)->daddr,ip_hdr (skb)->saddr); +return secure_tcp_seq_and_ts_off (net, +ip_hdr (skb)->daddr, +ip_hdr (skb)->saddr, +tcp_hdr (skb)->dest, +tcp_hdr (skb)->source); }int tcp_twsk_unique (struct sock *sk,struct sock *sktw,void *twp)
@@ -320,15 +317,16 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) rt =NULL ;if (likely (!tp->repair)) { +union tcp_seq_and_ts_off st; + + st =secure_tcp_seq_and_ts_off (net, + inet->inet_saddr, + inet->inet_daddr, + inet->inet_sport, + usin->sin_port);if (!tp->write_seq) -WRITE_ONCE (tp->write_seq, -secure_tcp_seq (inet->inet_saddr, - inet->inet_daddr, - inet->inet_sport, - usin->sin_port)); -WRITE_ONCE (tp->tsoffset, -secure_tcp_ts_off (net, inet->inet_saddr, - inet->inet_daddr)); +WRITE_ONCE (tp->write_seq, st.seq); +WRITE_ONCE (tp->tsoffset, st.ts_off); }atomic_set (&inet->inet_id,get_random_u16 ());
@@ -1712,8 +1710,7 @@ const struct tcp_request_sock_ops tcp_request_sock_ipv4_ops = { .cookie_init_seq = cookie_v4_init_sequence, #endif .route_req = tcp_v4_route_req, - .init_seq = tcp_v4_init_seq, - .init_ts_off = tcp_v4_init_ts_off, + .init_seq_and_ts_off = tcp_v4_init_seq_and_ts_off, .send_synack = tcp_v4_send_synack, };
net/ipv6/syncookies.c +8 -3
@@ -150,9 +150,14 @@ static struct request_sock *cookie_tcp_check(struct net *net, struct sock *sk,tcp_parse_options (net, skb, &tcp_opt,0 ,NULL );if (tcp_opt.saw_tstamp && tcp_opt.rcv_tsecr) { - tsoff =secure_tcpv6_ts_off (net, -ipv6_hdr (skb)->daddr.s6_addr32, -ipv6_hdr (skb)->saddr.s6_addr32); +union tcp_seq_and_ts_off st; + + st =secure_tcpv6_seq_and_ts_off (net, +ipv6_hdr (skb)->daddr.s6_addr32, +ipv6_hdr (skb)->saddr.s6_addr32, +tcp_hdr (skb)->dest, +tcp_hdr (skb)->source); + tsoff = st.ts_off; tcp_opt.rcv_tsecr -= tsoff; }
net/ipv6/tcp_ipv6.c +17 -20
@@ -104,18 +104,14 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb) } } -static u32 tcp_v6_init_seq (const struct sk_buff *skb) +static union tcp_seq_and_ts_off +tcp_v6_init_seq_and_ts_off (const struct net *net,const struct sk_buff *skb) { -return secure_tcpv6_seq (ipv6_hdr (skb)->daddr.s6_addr32, -ipv6_hdr (skb)->saddr.s6_addr32, -tcp_hdr (skb)->dest, -tcp_hdr (skb)->source); -} - -static u32 tcp_v6_init_ts_off (const struct net *net,const struct sk_buff *skb) -{ -return secure_tcpv6_ts_off (net,ipv6_hdr (skb)->daddr.s6_addr32, -ipv6_hdr (skb)->saddr.s6_addr32); +return secure_tcpv6_seq_and_ts_off (net, +ipv6_hdr (skb)->daddr.s6_addr32, +ipv6_hdr (skb)->saddr.s6_addr32, +tcp_hdr (skb)->dest, +tcp_hdr (skb)->source); } static int tcp_v6_pre_connect(struct sock *sk, struct sockaddr *uaddr,
@@ -316,14 +312,16 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,sk_set_txhash (sk);if (likely (!tp->repair)) { +union tcp_seq_and_ts_off st; + + st =secure_tcpv6_seq_and_ts_off (net, + np->saddr.s6_addr32, + sk->sk_v6_daddr.s6_addr32, + inet->inet_sport, + inet->inet_dport);if (!tp->write_seq) -WRITE_ONCE (tp->write_seq, -secure_tcpv6_seq (np->saddr.s6_addr32, - sk->sk_v6_daddr.s6_addr32, - inet->inet_sport, - inet->inet_dport)); - tp->tsoffset =secure_tcpv6_ts_off (net, np->saddr.s6_addr32, - sk->sk_v6_daddr.s6_addr32); +WRITE_ONCE (tp->write_seq, st.seq); + tp->tsoffset = st.ts_off; }if (tcp_fastopen_defer_connect (sk, &err))
@@ -855,8 +853,7 @@ const struct tcp_request_sock_ops tcp_request_sock_ipv6_ops = { .cookie_init_seq = cookie_v6_init_sequence, #endif .route_req = tcp_v6_route_req, - .init_seq = tcp_v6_init_seq, - .init_ts_off = tcp_v6_init_ts_off, + .init_seq_and_ts_off = tcp_v6_init_seq_and_ts_off, .send_synack = tcp_v6_send_synack, };
Signature · 1 line
2.53.0