mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-20 07:09:58 +00:00
tcp: Fix data-races around sysctl_tcp_syn(ack)?_retries.
While reading sysctl_tcp_syn(ack)?_retries, they can be changed concurrently. Thus, we need to add READ_ONCE() to their readers. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
f2f316e287
commit
20a3b1c0f6
@ -833,7 +833,8 @@ static void reqsk_timer_handler(struct timer_list *t)
|
|||||||
|
|
||||||
icsk = inet_csk(sk_listener);
|
icsk = inet_csk(sk_listener);
|
||||||
net = sock_net(sk_listener);
|
net = sock_net(sk_listener);
|
||||||
max_syn_ack_retries = icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_synack_retries;
|
max_syn_ack_retries = icsk->icsk_syn_retries ? :
|
||||||
|
READ_ONCE(net->ipv4.sysctl_tcp_synack_retries);
|
||||||
/* Normally all the openreqs are young and become mature
|
/* Normally all the openreqs are young and become mature
|
||||||
* (i.e. converted to established socket) for first timeout.
|
* (i.e. converted to established socket) for first timeout.
|
||||||
* If synack was not acknowledged for 1 second, it means
|
* If synack was not acknowledged for 1 second, it means
|
||||||
|
@ -3967,7 +3967,8 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
|
|||||||
val = keepalive_probes(tp);
|
val = keepalive_probes(tp);
|
||||||
break;
|
break;
|
||||||
case TCP_SYNCNT:
|
case TCP_SYNCNT:
|
||||||
val = icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_syn_retries;
|
val = icsk->icsk_syn_retries ? :
|
||||||
|
READ_ONCE(net->ipv4.sysctl_tcp_syn_retries);
|
||||||
break;
|
break;
|
||||||
case TCP_LINGER2:
|
case TCP_LINGER2:
|
||||||
val = tp->linger2;
|
val = tp->linger2;
|
||||||
|
@ -239,7 +239,8 @@ static int tcp_write_timeout(struct sock *sk)
|
|||||||
if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) {
|
if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) {
|
||||||
if (icsk->icsk_retransmits)
|
if (icsk->icsk_retransmits)
|
||||||
__dst_negative_advice(sk);
|
__dst_negative_advice(sk);
|
||||||
retry_until = icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_syn_retries;
|
retry_until = icsk->icsk_syn_retries ? :
|
||||||
|
READ_ONCE(net->ipv4.sysctl_tcp_syn_retries);
|
||||||
expired = icsk->icsk_retransmits >= retry_until;
|
expired = icsk->icsk_retransmits >= retry_until;
|
||||||
} else {
|
} else {
|
||||||
if (retransmits_timed_out(sk, net->ipv4.sysctl_tcp_retries1, 0)) {
|
if (retransmits_timed_out(sk, net->ipv4.sysctl_tcp_retries1, 0)) {
|
||||||
@ -406,12 +407,15 @@ abort: tcp_write_err(sk);
|
|||||||
static void tcp_fastopen_synack_timer(struct sock *sk, struct request_sock *req)
|
static void tcp_fastopen_synack_timer(struct sock *sk, struct request_sock *req)
|
||||||
{
|
{
|
||||||
struct inet_connection_sock *icsk = inet_csk(sk);
|
struct inet_connection_sock *icsk = inet_csk(sk);
|
||||||
int max_retries = icsk->icsk_syn_retries ? :
|
|
||||||
sock_net(sk)->ipv4.sysctl_tcp_synack_retries + 1; /* add one more retry for fastopen */
|
|
||||||
struct tcp_sock *tp = tcp_sk(sk);
|
struct tcp_sock *tp = tcp_sk(sk);
|
||||||
|
int max_retries;
|
||||||
|
|
||||||
req->rsk_ops->syn_ack_timeout(req);
|
req->rsk_ops->syn_ack_timeout(req);
|
||||||
|
|
||||||
|
/* add one more retry for fastopen */
|
||||||
|
max_retries = icsk->icsk_syn_retries ? :
|
||||||
|
READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_synack_retries) + 1;
|
||||||
|
|
||||||
if (req->num_timeout >= max_retries) {
|
if (req->num_timeout >= max_retries) {
|
||||||
tcp_write_err(sk);
|
tcp_write_err(sk);
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user