OSDN Git Service

rds: cancel send/recv work before queuing connection shutdown
authorSowmini Varadhan <sowmini.varadhan@oracle.com>
Sun, 16 Jul 2017 23:43:46 +0000 (16:43 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 Jul 2017 02:07:35 +0000 (19:07 -0700)
commitaed20a53a7d91e45c6a8cb8920c77aaaa88f76ee
tree78bdb7167413d66c08f14ec1056cffd85fa0bc7d
parentce3dbe29749e3a3ef25540b394a68215e3113462
rds: cancel send/recv work before queuing connection shutdown

We could end up executing rds_conn_shutdown before the rds_recv_worker
thread, then rds_conn_shutdown -> rds_tcp_conn_shutdown can do a
sock_release and set sock->sk to null, which may interleave in bad
ways with rds_recv_worker, e.g., it could result in:

"BUG: unable to handle kernel NULL pointer dereference at 0000000000000078"
    [ffff881769f6fd70] release_sock at ffffffff815f337b
    [ffff881769f6fd90] rds_tcp_recv at ffffffffa043c888 [rds_tcp]
    [ffff881769f6fdb0] rds_recv_worker at ffffffffa04a4810 [rds]
    [ffff881769f6fde0] process_one_work at ffffffff810a14c1
    [ffff881769f6fe40] worker_thread at ffffffff810a1940
    [ffff881769f6fec0] kthread at ffffffff810a6b1e

Also, do not enqueue any new shutdown workq items when the connection is
shutting down (this may happen for rds-tcp in softirq mode, if a FIN
or CLOSE is received while the modules is in the middle of an unload)

Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/rds/connection.c
net/rds/rds.h
net/rds/tcp.c
net/rds/tcp_connect.c
net/rds/tcp_send.c
net/rds/threads.c