Skip to content

Commit 9a0351d

Browse files
committed
Merge branch 'rds-conn-spamming'
Sowmini Varadhan says: ==================== RDS: TCP: connection spamming fixes We have been testing the RDS-TCP code with a connection spammer that sends incoming SYNs to the RDS listen port well after an rds-tcp connection has been established, and found a few race-windows that are fixed by this patch series. Patch 1 avoids a null pointer deref when an incoming SYN shows up when a netns is being dismantled, or when the rds-tcp module is being unloaded. Patch 2 addresses the case when a SYN is received after the connection arbitration algorithm has converged: the incoming SYN should not needlessly quiesce the transmit path, and it should not result in needless TCP connection resets due to re-execution of the connection arbitration logic. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents fc64869 + c948bb5 commit 9a0351d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

net/rds/tcp_listen.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ int rds_tcp_accept_one(struct socket *sock)
8080
int conn_state;
8181
struct sock *nsk;
8282

83+
if (!sock) /* module unload or netns delete in progress */
84+
return -ENETUNREACH;
85+
8386
ret = sock_create_kern(sock_net(sock->sk), sock->sk->sk_family,
8487
sock->sk->sk_type, sock->sk->sk_protocol,
8588
&new_sock);
@@ -129,11 +132,13 @@ int rds_tcp_accept_one(struct socket *sock)
129132
* so we must quiesce any send threads before resetting
130133
* c_transport_data.
131134
*/
132-
wait_event(conn->c_waitq,
133-
!test_bit(RDS_IN_XMIT, &conn->c_flags));
134-
if (ntohl(inet->inet_saddr) < ntohl(inet->inet_daddr)) {
135+
if (ntohl(inet->inet_saddr) < ntohl(inet->inet_daddr) ||
136+
!conn->c_outgoing) {
135137
goto rst_nsk;
136-
} else if (rs_tcp->t_sock) {
138+
} else {
139+
atomic_set(&conn->c_state, RDS_CONN_CONNECTING);
140+
wait_event(conn->c_waitq,
141+
!test_bit(RDS_IN_XMIT, &conn->c_flags));
137142
rds_tcp_restore_callbacks(rs_tcp->t_sock, rs_tcp);
138143
conn->c_outgoing = 0;
139144
}

0 commit comments

Comments
 (0)