linux-stable/net/rxrpc
David Howells 38eb28cc26 afs: Adjust ACK interpretation to try and cope with NAT
[ Upstream commit adc9613ff6 ]

If a client's address changes, say if it is NAT'd, this can disrupt an in
progress operation.  For most operations, this is not much of a problem,
but StoreData can be different as some servers modify the target file as
the data comes in, so if a store request is disrupted, the file can get
corrupted on the server.

The problem is that the server doesn't recognise packets that come after
the change of address as belonging to the original client and will bounce
them, either by sending an OUT_OF_SEQUENCE ACK to the apparent new call if
the packet number falls within the initial sequence number window of a call
or by sending an EXCEEDS_WINDOW ACK if it falls outside and then aborting
it.  In both cases, firstPacket will be 1 and previousPacket will be 0 in
the ACK information.

Fix this by the following means:

 (1) If a client call receives an EXCEEDS_WINDOW ACK with firstPacket as 1
     and previousPacket as 0, assume this indicates that the server saw the
     incoming packets from a different peer and thus as a different call.
     Fail the call with error -ENETRESET.

 (2) Also fail the call if a similar OUT_OF_SEQUENCE ACK occurs if the
     first packet has been hard-ACK'd.  If it hasn't been hard-ACK'd, the
     ACK packet will cause it to get retransmitted, so the call will just
     be repeated.

 (3) Make afs_select_fileserver() treat -ENETRESET as a straight fail of
     the operation.

 (4) Prioritise the error code over things like -ECONNRESET as the server
     did actually respond.

 (5) Make writeback treat -ENETRESET as a retryable error and make it
     redirty all the pages involved in a write so that the VM will retry.

Note that there is still a circumstance that I can't easily deal with: if
the operation is fully received and processed by the server, but the reply
is lost due to address change.  There's no way to know if the op happened.
We can examine the server, but a conflicting change could have been made by
a third party - and we can't tell the difference.  In such a case, a
message like:

    kAFS: vnode modified {100058:146266} b7->b8 YFS.StoreData64 (op=2646a)

will be logged to dmesg on the next op to touch the file and the client
will reset the inode state, including invalidating clean parts of the
pagecache.

Reported-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-afs@lists.infradead.org
Link: http://lists.infradead.org/pipermail/linux-afs/2021-December/004811.html # v1
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-06-09 10:25:30 +02:00
..
af_rxrpc.c rxrpc: Fix fall-through warnings for Clang 2021-06-04 17:40:04 -05:00
ar-internal.h rxrpc: Fix call timer start racing with call destruction 2022-04-08 13:58:55 +02:00
call_accept.c rxrpc: Fix memory leak in rxrpc_lookup_local 2021-01-28 13:12:14 -08:00
call_event.c rxrpc, afs: Fix selection of abort codes 2022-06-09 10:25:30 +02:00
call_object.c rxrpc: Fix call timer start racing with call destruction 2022-04-08 13:58:55 +02:00
conn_client.c rxrpc: Fix rxrpc_peer leak in rxrpc_look_up_bundle() 2021-11-29 15:39:40 +00:00
conn_event.c rxrpc: Merge prime_packet_security into init_connection_security 2020-11-23 18:09:30 +00:00
conn_object.c rxrpc, afs: Fix selection of abort codes 2022-06-09 10:25:30 +02:00
conn_service.c
input.c afs: Adjust ACK interpretation to try and cope with NAT 2022-06-09 10:25:30 +02:00
insecure.c rxrpc: Ask the security class how much space to allow in a packet 2020-11-23 19:53:11 +00:00
Kconfig net: RxRPC: make dependent Kconfig symbols be shown indented 2021-08-18 10:12:11 +01:00
key.c rxrpc: Fix handling of an unsupported token type in rxrpc_read() 2021-01-13 10:38:00 -08:00
local_event.c rxrpc: Fix a typo 2021-06-02 14:01:55 -07:00
local_object.c rxrpc: Enable IPv6 checksums on transport socket 2022-05-12 12:32:37 +02:00
Makefile
misc.c
net_ns.c rxrpc: Restore removed timer deletion 2022-04-27 14:40:59 +02:00
output.c rxrpc: Adjust retransmission backoff 2022-01-22 02:03:24 +00:00
peer_event.c
peer_object.c rxrpc: Fix rxrpc_local leak in rxrpc_lookup_peer() 2021-11-29 15:40:02 +00:00
proc.c
protocol.h
recvmsg.c afs: Don't truncate iter during data fetch 2021-04-23 10:17:26 +01:00
rtt.c rxrpc: Fix _usecs_to_jiffies() by using usecs_to_jiffies() 2021-09-24 14:18:34 +01:00
rxkad.c rxrpc: rxkad: Remove redundant variable offset 2021-04-27 14:05:06 -07:00
security.c rxrpc: Hand server key parsing off to the security class 2020-11-23 18:09:29 +00:00
sendmsg.c rxrpc: Return an error to sendmsg if call failed 2022-06-09 10:25:30 +02:00
server_key.c rxrpc: fix some null-ptr-deref bugs in server_key.c 2022-04-08 13:58:55 +02:00
skbuff.c
sysctl.c
utils.c