kernel-fxtec-pro1x/net/rxrpc
David Howells fdd36abd9d rxrpc: Fix net namespace cleanup
[ Upstream commit b13023421b5179413421333f602850914f6a7ad8 ]

In rxrpc_destroy_all_calls(), there are two phases: (1) make sure the
->calls list is empty, emitting error messages if not, and (2) wait for the
RCU cleanup to happen on outstanding calls (ie. ->nr_calls becomes 0).

To avoid taking the call_lock, the function prechecks ->calls and if empty,
it returns to avoid taking the lock - this is wrong, however: it still
needs to go and do the second phase and wait for ->nr_calls to become 0.

Without this, the rxrpc_net struct may get deallocated before we get to the
RCU cleanup for the last calls.  This can lead to:

  Slab corruption (Not tainted): kmalloc-16k start=ffff88802b178000, len=16384
  050: 6b 6b 6b 6b 6b 6b 6b 6b 61 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkakkkkkkk

Note the "61" at offset 0x58.  This corresponds to the ->nr_calls member of
struct rxrpc_net (which is >9k in size, and thus allocated out of the 16k
slab).

Fix this by flipping the condition on the if-statement, putting the locked
section inside the if-body and dropping the return from there.  The
function will then always go on to wait for the RCU cleanup on outstanding
calls.

Fixes: 2baec2c3f8 ("rxrpc: Support network namespacing")
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-05 14:42:38 +02:00
..
af_rxrpc.c
ar-internal.h
call_accept.c
call_event.c
call_object.c rxrpc: Fix net namespace cleanup 2019-05-05 14:42:38 +02:00
conn_client.c rxrpc: Fix client call connect/disconnect race 2019-04-20 09:16:05 +02:00
conn_event.c
conn_object.c
conn_service.c
input.c rxrpc: fix race condition in rxrpc_input_packet() 2019-05-02 09:58:57 +02:00
insecure.c
Kconfig
key.c
local_event.c
local_object.c rxrpc: fix race condition in rxrpc_input_packet() 2019-05-02 09:58:57 +02:00
Makefile
misc.c
net_ns.c
output.c
peer_event.c
peer_object.c
proc.c
protocol.h
recvmsg.c rxrpc: bad unlock balance in rxrpc_recvmsg 2019-02-12 19:47:22 +01:00
rxkad.c
security.c
sendmsg.c
skbuff.c
sysctl.c
utils.c