WSL2-Linux-Kernel/net/rxrpc
David Howells 1a025028d4 rxrpc: Fix handling of call quietly cancelled out on server
Sometimes an in-progress call will stop responding on the fileserver when
the fileserver quietly cancels the call with an internally marked abort
(RX_CALL_DEAD), without sending an ABORT to the client.

This causes the client's call to eventually expire from lack of incoming
packets directed its way, which currently leads to it being cancelled
locally with ETIME.  Note that it's not currently clear as to why this
happens as it's really hard to reproduce.

The rotation policy implement by kAFS, however, doesn't differentiate
between ETIME meaning we didn't get any response from the server and ETIME
meaning the call got cancelled mid-flow.  The latter leads to an oops when
fetching data as the rotation partially resets the afs_read descriptor,
which can result in a cleared page pointer being dereferenced because that
page has already been filled.

Handle this by the following means:

 (1) Set a flag on a call when we receive a packet for it.

 (2) Store the highest packet serial number so far received for a call
     (bearing in mind this may wrap).

 (3) If, when the "not received anything recently" timeout expires on a
     call, we've received at least one packet for a call and the connection
     as a whole has received packets more recently than that call, then
     cancel the call locally with ECONNRESET rather than ETIME.

     This indicates that the call was definitely in progress on the server.

 (4) In kAFS, if the rotation algorithm sees ECONNRESET rather than ETIME,
     don't try the next server, but rather abort the call.

     This avoids the oops as we don't try to reuse the afs_read struct.
     Rather, as-yet ungotten pages will be reread at a later data.

Also:

 (5) Add an rxrpc tracepoint to log detection of the call being reset.

Without this, I occasionally see an oops like the following:

    general protection fault: 0000 [#1] SMP PTI
    ...
    RIP: 0010:_copy_to_iter+0x204/0x310
    RSP: 0018:ffff8800cae0f828 EFLAGS: 00010206
    RAX: 0000000000000560 RBX: 0000000000000560 RCX: 0000000000000560
    RDX: ffff8800cae0f968 RSI: ffff8800d58b3312 RDI: 0005080000000000
    RBP: ffff8800cae0f968 R08: 0000000000000560 R09: ffff8800ca00f400
    R10: ffff8800c36f28d4 R11: 00000000000008c4 R12: ffff8800cae0f958
    R13: 0000000000000560 R14: ffff8800d58b3312 R15: 0000000000000560
    FS:  00007fdaef108080(0000) GS:ffff8800ca680000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007fb28a8fa000 CR3: 00000000d2a76002 CR4: 00000000001606e0
    Call Trace:
     skb_copy_datagram_iter+0x14e/0x289
     rxrpc_recvmsg_data.isra.0+0x6f3/0xf68
     ? trace_buffer_unlock_commit_regs+0x4f/0x89
     rxrpc_kernel_recv_data+0x149/0x421
     afs_extract_data+0x1e0/0x798
     ? afs_wait_for_call_to_complete+0xc9/0x52e
     afs_deliver_fs_fetch_data+0x33a/0x5ab
     afs_deliver_to_call+0x1ee/0x5e0
     ? afs_wait_for_call_to_complete+0xc9/0x52e
     afs_wait_for_call_to_complete+0x12b/0x52e
     ? wake_up_q+0x54/0x54
     afs_make_call+0x287/0x462
     ? afs_fs_fetch_data+0x3e6/0x3ed
     ? rcu_read_lock_sched_held+0x5d/0x63
     afs_fs_fetch_data+0x3e6/0x3ed
     afs_fetch_data+0xbb/0x14a
     afs_readpages+0x317/0x40d
     __do_page_cache_readahead+0x203/0x2ba
     ? ondemand_readahead+0x3a7/0x3c1
     ondemand_readahead+0x3a7/0x3c1
     generic_file_buffered_read+0x18b/0x62f
     __vfs_read+0xdb/0xfe
     vfs_read+0xb2/0x137
     ksys_read+0x50/0x8c
     do_syscall_64+0x7d/0x1a0
     entry_SYSCALL_64_after_hwframe+0x49/0xbe

Note the weird value in RDI which is a result of trying to kmap() a NULL
page pointer.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-06-04 16:06:26 -04:00
..
Kconfig rxrpc: Add config to inject packet loss 2016-09-17 11:24:04 +01:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
af_rxrpc.c rxrpc: Fix the min security level for kernel calls 2018-05-10 23:26:01 +01:00
ar-internal.h rxrpc: Fix handling of call quietly cancelled out on server 2018-06-04 16:06:26 -04:00
call_accept.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2018-04-03 14:04:18 -07:00
call_event.c rxrpc: Fix handling of call quietly cancelled out on server 2018-06-04 16:06:26 -04:00
call_object.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2018-04-03 14:04:18 -07:00
conn_client.c rxrpc: Fix apparent leak of rxrpc_local objects 2018-03-30 21:05:33 +01:00
conn_event.c rxrpc: Trace UDP transmission failure 2018-05-10 23:26:01 +01:00
conn_object.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2018-04-03 14:04:18 -07:00
conn_service.c rxrpc: Fix apparent leak of rxrpc_local objects 2018-03-30 21:05:33 +01:00
input.c rxrpc: Fix handling of call quietly cancelled out on server 2018-06-04 16:06:26 -04:00
insecure.c rxrpc: Trace protocol errors in received packets 2017-04-06 11:09:39 +01:00
key.c rxrpc: Use correct timestamp from Kerberos 5 ticket 2017-08-29 10:55:06 +01:00
local_event.c rxrpc: Trace UDP transmission failure 2018-05-10 23:26:01 +01:00
local_object.c rxrpc: Fix error reception on AF_INET6 sockets 2018-05-10 23:26:00 +01:00
misc.c rxrpc: Fix call timeouts 2017-11-24 10:18:41 +00:00
net_ns.c rxrpc: Fix leak of rxrpc_peer objects 2018-03-30 21:05:44 +01:00
output.c rxrpc: Trace UDP transmission failure 2018-05-10 23:26:01 +01:00
peer_event.c rxrpc: Add a tracepoint to log ICMP/ICMP6 and error messages 2018-05-10 23:26:01 +01:00
peer_object.c rxrpc: Fix leak of rxrpc_peer objects 2018-03-30 21:05:44 +01:00
proc.c rxrpc: Fix checker warnings and errors 2018-03-30 21:05:17 +01:00
protocol.h rxrpc: Fix undefined packet handling 2018-04-04 11:04:08 -04:00
recvmsg.c rxrpc: remove redundant initialization of variable 'len' 2018-03-16 09:48:39 -04:00
rxkad.c rxrpc: Trace UDP transmission failure 2018-05-10 23:26:01 +01:00
security.c rxrpc: remove unused static variables 2018-03-30 21:04:44 +01:00
sendmsg.c rxrpc: Fix missing start of call timeout 2018-05-10 23:26:00 +01:00
skbuff.c net: convert sk_buff.users from atomic_t to refcount_t 2017-07-01 07:39:07 -07:00
sysctl.c rxrpc: Fix call timeouts 2017-11-24 10:18:41 +00:00
utils.c rxrpc: Fix IPv6 support 2017-08-29 10:55:20 +01:00