rxrpc: Fix lack of conn cleanup when local endpoint is cleaned up [ver #2]
authorDavid Howells <dhowells@redhat.com>
Thu, 29 Aug 2019 13:12:11 +0000 (14:12 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 30 Aug 2019 22:06:52 +0000 (15:06 -0700)
commitd12040b6933f684a26773afad46dbba9778608d7
treea6a3bb4f3075037b6b557d681bcabcfc62975fff
parenta285c1fa39ccc6f04b1af025ec00b1aae52e6814
rxrpc: Fix lack of conn cleanup when local endpoint is cleaned up [ver #2]

When a local endpoint is ceases to be in use, such as when the kafs module
is unloaded, the kernel will emit an assertion failure if there are any
outstanding client connections:

rxrpc: Assertion failed
------------[ cut here ]------------
kernel BUG at net/rxrpc/local_object.c:433!

and even beyond that, will evince other oopses if there are service
connections still present.

Fix this by:

 (1) Removing the triggering of connection reaping when an rxrpc socket is
     released.  These don't actually clean up the connections anyway - and
     further, the local endpoint may still be in use through another
     socket.

 (2) Mark the local endpoint as dead when we start the process of tearing
     it down.

 (3) When destroying a local endpoint, strip all of its client connections
     from the idle list and discard the ref on each that the list was
     holding.

 (4) When destroying a local endpoint, call the service connection reaper
     directly (rather than through a workqueue) to immediately kill off all
     outstanding service connections.

 (5) Make the service connection reaper reap connections for which the
     local endpoint is marked dead.

Only after destroying the connections can we close the socket lest we get
an oops in a workqueue that's looking at a connection or a peer.

Fixes: 3d18cbb7fd0c ("rxrpc: Fix conn expiry timers")
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/rxrpc/af_rxrpc.c
net/rxrpc/ar-internal.h
net/rxrpc/conn_client.c
net/rxrpc/conn_object.c
net/rxrpc/local_object.c