All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: David Howells <dhowells@redhat.com>,
	Marc Dionne <marc.dionne@auristor.com>,
	linux-afs@lists.infradead.org,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 28/29] rxrpc: Return an error to sendmsg if call failed
Date: Mon, 30 May 2022 09:50:55 -0400	[thread overview]
Message-ID: <20220530135057.1937286-28-sashal@kernel.org> (raw)
In-Reply-To: <20220530135057.1937286-1-sashal@kernel.org>

From: David Howells <dhowells@redhat.com>

[ Upstream commit 4ba68c5192554876bd8c3afd904e3064d2915341 ]

If at the end of rxrpc sendmsg() or rxrpc_kernel_send_data() the call that
was being given data was aborted remotely or otherwise failed, return an
error rather than returning the amount of data buffered for transmission.

The call (presumably) did not complete, so there's not much point
continuing with it.  AF_RXRPC considers it "complete" and so will be
unwilling to do anything else with it - and won't send a notification for
it, deeming the return from sendmsg sufficient.

Not returning an error causes afs to incorrectly handle a StoreData
operation that gets interrupted by a change of address due to NAT
reconfiguration.

This doesn't normally affect most operations since their request parameters
tend to fit into a single UDP packet and afs_make_call() returns before the
server responds; StoreData is different as it involves transmission of a
lot of data.

This can be triggered on a client by doing something like:

	dd if=/dev/zero of=/afs/example.com/foo bs=1M count=512

at one prompt, and then changing the network address at another prompt,
e.g.:

	ifconfig enp6s0 inet 192.168.6.2 && route add 192.168.6.1 dev enp6s0

Tracing packets on an Auristor fileserver looks something like:

192.168.6.1 -> 192.168.6.3  RX 107 ACK Idle  Seq: 0  Call: 4  Source Port: 7000  Destination Port: 7001
192.168.6.3 -> 192.168.6.1  AFS (RX) 1482 FS Request: Unknown(64538) (64538)
192.168.6.3 -> 192.168.6.1  AFS (RX) 1482 FS Request: Unknown(64538) (64538)
192.168.6.1 -> 192.168.6.3  RX 107 ACK Idle  Seq: 0  Call: 4  Source Port: 7000  Destination Port: 7001
<ARP exchange for 192.168.6.2>
192.168.6.2 -> 192.168.6.1  AFS (RX) 1482 FS Request: Unknown(0) (0)
192.168.6.2 -> 192.168.6.1  AFS (RX) 1482 FS Request: Unknown(0) (0)
192.168.6.1 -> 192.168.6.2  RX 107 ACK Exceeds Window  Seq: 0  Call: 4  Source Port: 7000  Destination Port: 7001
192.168.6.1 -> 192.168.6.2  RX 74 ABORT  Seq: 0  Call: 4  Source Port: 7000  Destination Port: 7001
192.168.6.1 -> 192.168.6.2  RX 74 ABORT  Seq: 29321  Call: 4  Source Port: 7000  Destination Port: 7001

The Auristor fileserver logs code -453 (RXGEN_SS_UNMARSHAL), but the abort
code received by kafs is -5 (RX_PROTOCOL_ERROR) as the rx layer sees the
condition and generates an abort first and the unmarshal error is a
consequence of that at the application layer.

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/004810.html # v1
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/rxrpc/sendmsg.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c
index 8f9a2a7eeb7c..de73c2effc89 100644
--- a/net/rxrpc/sendmsg.c
+++ b/net/rxrpc/sendmsg.c
@@ -383,6 +383,12 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
 
 success:
 	ret = copied;
+	if (READ_ONCE(call->state) == RXRPC_CALL_COMPLETE) {
+		read_lock_bh(&call->state_lock);
+		if (call->error < 0)
+			ret = call->error;
+		read_unlock_bh(&call->state_lock);
+	}
 out:
 	call->tx_pending = skb;
 	_leave(" = %d", ret);
-- 
2.35.1


  parent reply	other threads:[~2022-05-30 14:49 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-30 13:50 [PATCH AUTOSEL 4.14 01/29] drm/virtio: fix NULL pointer dereference in virtio_gpu_conn_get_modes Sasha Levin
2022-05-30 13:50 ` Sasha Levin
2022-05-30 13:50 ` Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 02/29] mwifiex: add mutex lock for call in mwifiex_dfs_chan_sw_work_queue Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 03/29] b43legacy: Fix assigning negative value to unsigned variable Sasha Levin
2022-05-30 13:50   ` Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 04/29] b43: " Sasha Levin
2022-05-30 13:50   ` Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 05/29] ipw2x00: Fix potential NULL dereference in libipw_xmit() Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 06/29] ACPICA: Avoid cache flush inside virtual machines Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 07/29] ALSA: jack: Access input_dev under mutex Sasha Levin
2022-05-30 13:50   ` Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 08/29] drm/amd/pm: fix double free in si_parse_power_table() Sasha Levin
2022-05-30 13:50   ` Sasha Levin
2022-05-30 13:50   ` Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 09/29] ath9k: fix QCA9561 PA bias level Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 10/29] media: venus: hfi: avoid null dereference in deinit Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 11/29] media: pci: cx23885: Fix the error handling in cx23885_initdev() Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 12/29] media: cx25821: Fix the warning when removing the module Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 13/29] scsi: megaraid: Fix error check return value of register_chrdev() Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 14/29] drm/amd/pm: fix the compile warning Sasha Levin
2022-05-30 13:50   ` Sasha Levin
2022-05-30 13:50   ` Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 15/29] ipv6: Don't send rs packets to the interface of ARPHRD_TUNNEL Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 16/29] ASoC: dapm: Don't fold register value changes into notifications Sasha Levin
2022-05-30 13:50   ` Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 17/29] net: remove two BUG() from skb_checksum_help() Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 18/29] s390/preempt: disable __preempt_count_add() optimization for PROFILE_ALL_BRANCHES Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 19/29] dma-debug: change allocation mode from GFP_NOWAIT to GFP_ATIOMIC Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 20/29] ipmi:ssif: Check for NULL msg when handling events and messages Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 21/29] rtlwifi: Use pr_warn instead of WARN_ONCE Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 22/29] openrisc: start CPU timer early in boot Sasha Levin
2022-05-30 13:50   ` Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 23/29] nvme-pci: fix a NULL pointer dereference in nvme_alloc_admin_tags Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 24/29] ASoC: rt5645: Fix errorenous cleanup order Sasha Levin
2022-05-30 13:50   ` Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 25/29] net: phy: micrel: Allow probing without .driver_data Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 26/29] media: exynos4-is: Fix compile warning Sasha Levin
2022-05-30 13:50   ` Sasha Levin
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 27/29] ARM: 9201/1: spectre-bhb: rely on linker to emit cross-section literal loads Sasha Levin
2022-05-30 13:50   ` Sasha Levin
2022-05-30 13:52   ` Ard Biesheuvel
2022-05-30 13:52     ` Ard Biesheuvel
2022-05-30 13:50 ` Sasha Levin [this message]
2022-05-30 13:50 ` [PATCH AUTOSEL 4.14 29/29] eth: tg3: silence the GCC 12 array-bounds warning Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220530135057.1937286-28-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.dionne@auristor.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.