alistair23-linux/net/rds
Sowmini Varadhan eb19284026 RDS:TCP: Synchronize rds_tcp_accept_one with rds_send_xmit when resetting t_sock
There is a race condition between rds_send_xmit -> rds_tcp_xmit
and the code that deals with resolution of duelling syns added
by commit 241b271952 ("RDS-TCP: Reset tcp callbacks if re-using an
outgoing socket in rds_tcp_accept_one()").

Specifically, we may end up derefencing a null pointer in rds_send_xmit
if we have the interleaving sequence:
           rds_tcp_accept_one                  rds_send_xmit

                                             conn is RDS_CONN_UP, so
    					 invoke rds_tcp_xmit

                                             tc = conn->c_transport_data
        rds_tcp_restore_callbacks
            /* reset t_sock */
    					 null ptr deref from tc->t_sock

The race condition can be avoided without adding the overhead of
additional locking in the xmit path: have rds_tcp_accept_one wait
for rds_tcp_xmit threads to complete before resetting callbacks.
The synchronization can be done in the same manner as rds_conn_shutdown().
First set the rds_conn_state to something other than RDS_CONN_UP
(so that new threads cannot get into rds_tcp_xmit()), then wait for
RDS_IN_XMIT to be cleared in the conn->c_flags indicating that any
threads in rds_tcp_xmit are done.

Fixes: 241b271952 ("RDS-TCP: Reset tcp callbacks if re-using an
outgoing socket in rds_tcp_accept_one()")
Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-05-03 16:03:44 -04:00
..
af_rds.c RDS: Add support for SO_TIMESTAMP for incoming messages 2016-03-02 14:13:17 -05:00
bind.c RDS: convert bind hash table to re-sizable hashtable 2015-11-02 15:36:23 -05:00
cong.c RDS: Fix the atomicity for congestion map update 2016-04-16 19:01:05 -04:00
connection.c RDS: fix race condition when sending a message on unbound socket 2015-11-24 17:20:09 -05:00
ib.c RDS: IB: add Fastreg MR (FRMR) detection support 2016-03-02 14:13:19 -05:00
ib.h RDS: IB: Support Fastreg MR (FRMR) memory registration mode 2016-03-02 14:13:19 -05:00
ib_cm.c RDS: fix endianness for dp_ack_seq 2016-04-16 19:01:05 -04:00
ib_fmr.c RDS: IB: move FMR code to its own file 2016-03-02 14:13:18 -05:00
ib_frmr.c RDS: IB: Support Fastreg MR (FRMR) memory registration mode 2016-03-02 14:13:19 -05:00
ib_mr.h RDS: IB: Support Fastreg MR (FRMR) memory registration mode 2016-03-02 14:13:19 -05:00
ib_rdma.c RDS: IB: Support Fastreg MR (FRMR) memory registration mode 2016-03-02 14:13:19 -05:00
ib_recv.c RDS: fix congestion map corruption for PAGE_SIZE > 4k 2016-04-07 16:58:28 -04:00
ib_ring.c
ib_send.c RDS: IB: Remove the RDS_IB_SEND_OP dependency 2016-03-02 14:13:17 -05:00
ib_stats.c RDS: IB: add mr reused stats 2016-03-02 14:13:19 -05:00
ib_sysctl.c
info.c
info.h
Kconfig RDS: Drop stale iWARP RDMA transport 2016-03-02 14:13:17 -05:00
loop.c
loop.h
Makefile RDS: IB: Support Fastreg MR (FRMR) memory registration mode 2016-03-02 14:13:19 -05:00
message.c
page.c RDS: memory allocated must be align to 8 2016-04-07 16:58:27 -04:00
rdma.c RDS: Fix rds MR reference count in rds_rdma_unuse() 2015-08-25 16:28:10 -07:00
rdma_transport.c RDS: IB: handle the RDMA CM time wait event 2016-03-02 14:13:19 -05:00
rdma_transport.h RDS: Drop stale iWARP RDMA transport 2016-03-02 14:13:17 -05:00
rds.h RDS: Add support for SO_TIMESTAMP for incoming messages 2016-03-02 14:13:17 -05:00
recv.c RDS: Add support for SO_TIMESTAMP for incoming messages 2016-03-02 14:13:17 -05:00
send.c RDS: fix race condition when sending a message on unbound socket 2015-11-24 17:20:09 -05:00
stats.c
sysctl.c
tcp.c RDS:TCP: Synchronize rds_tcp_accept_one with rds_send_xmit when resetting t_sock 2016-05-03 16:03:44 -04:00
tcp.h
tcp_connect.c RDS-TCP: Support multiple RDS-TCP listen endpoints, one per netns. 2015-08-07 11:29:58 -07:00
tcp_listen.c RDS:TCP: Synchronize rds_tcp_accept_one with rds_send_xmit when resetting t_sock 2016-05-03 16:03:44 -04:00
tcp_recv.c RDS-TCP: Recover correctly from pskb_pull()/pksb_trim() failure in rds_tcp_data_recv 2015-10-27 19:46:34 -07:00
tcp_send.c RDS-TCP: Set up MSG_MORE and MSG_SENDPAGE_NOTLAST as appropriate in rds_tcp_xmit 2015-10-05 03:34:53 -07:00
tcp_stats.c
threads.c RDS: use rds_send_xmit() state instead of RDS_LL_SEND_FULL 2015-10-05 11:19:01 -07:00
transport.c