Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1281955lfc; Wed, 1 Jun 2022 14:07:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAIyJ2qZL0Zgv2hDul2/pYgzkut3Bu7C0X77gcJDqOlS2zezk7rLJWZHc7f8SL4dPIwdZJ X-Received: by 2002:a05:6a00:15c2:b0:518:9911:4952 with SMTP id o2-20020a056a0015c200b0051899114952mr1488680pfu.64.1654117639109; Wed, 01 Jun 2022 14:07:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654117639; cv=none; d=google.com; s=arc-20160816; b=HMqS1n2qBHT+brZGj8Ue+vq01Ai1IlsEzXV4NnhhO/ZWZuMZxgxnTiCtq1mt1pK79v Z6ulOM8KlPzpOGeXlJBwgnMWftxhYKQ33gewzcuOr2G+sd8/ScxJSz6SNO9AnDK5pAFO FyZq55KwwKBIs0z038xtACkQpIfA5B4DhAp2es7nVmnR9tYyroTZDbYCb4m4o6GhOdWY O5IS02ewZiU0g7+usByFc29VxH7KiIgZNQzfJdni+6aUVzF9QxJKNvY7+YjCO4Pufk44 0RbS6RSCWc5jsZ+AKUzb3+fCnD3XmFj/M9OZe2Kwi+ya/C7cuyj2Og+nnh9kkIt0m+m5 Uf3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mM7/V8YlrXQMCbG2KtucHOFvO84b+n7Od+wUMxZCuSw=; b=V1Hd8ygFwbJgxnodFB6VQ6GrdX4PYvSvum3ma7MC6tptDnOijhG3+jx7H2VnuPF/yY FQQjclRK2UqyeFGLXodFCCOlnh0pc++YMtyqinQiHv8kPx4EUx3AOAAdmnuuuhcaIPxm eHIQ+8M8dPrEuVfyzZONExwuENe7Plc7h6PJ74Tk5Yho/UHQ6MiNPt+O+R0xbqZE9wWn W3ZuoCN5S8YKmVTQIklUkCqVkkkIlddJVZTGUQT/Qm9gPz07EgZYdah725EPF8Xw2Yw5 5HSvaZB5MLPw8eLPAZoDEsgv55vc2VBaExH+u/HjgP2d+ZXj9atTtkP58a3x/RQgl/by ZTew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mChWiFyI; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id a17-20020a056a000c9100b00510979e5adbsi3499614pfv.304.2022.06.01.14.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 14:07:19 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mChWiFyI; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 148B830AB4E; Wed, 1 Jun 2022 13:16:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241771AbiE3Ow6 (ORCPT + 99 others); Mon, 30 May 2022 10:52:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239947AbiE3Ob5 (ORCPT ); Mon, 30 May 2022 10:31:57 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 756441312B0; Mon, 30 May 2022 06:53:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id EFBCBCE1024; Mon, 30 May 2022 13:53:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38F4CC341C0; Mon, 30 May 2022 13:53:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653918791; bh=08EMK0gOc1s8fDqsa5otPCkfPEWHoIcvRbnM1fHm79s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mChWiFyIToYMWLiu3y0fe3iJF0W77ynG2SaTwXNwm15wWcBzKR4ZISQoFHrsKpLzu WOr17+ZV/3PH0tZl3Ugn2niw/ndi8JltwN7gWEtDGa67P+cssRAPszDMf5BlFuL+C9 gvZlN7tOG2/C0r9vQtJlqEVzkdH4acKACgqQD6cpfPuNpcuEGySa4RM3aROyERvmk9 JvJ4JrEankxw7xfoZvSVx27j6vCTU9j7B9x/ljAeFVz/H3FVxmoTwEBigm3Fqf5162 b63a1NfSZAQqR0jlEoC8e7TKk7nnF/B7Ekywky9RIjFipInudkWAVu/Dqroa0yeojR zRpHEm7w6q7pg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, "David S . Miller" , Sasha Levin , edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 23/24] rxrpc: Return an error to sendmsg if call failed Date: Mon, 30 May 2022 09:52:10 -0400 Message-Id: <20220530135211.1937674-23-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220530135211.1937674-1-sashal@kernel.org> References: <20220530135211.1937674-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Howells [ 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 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 Signed-off-by: David Howells 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 Signed-off-by: Sasha Levin --- net/rxrpc/sendmsg.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c index 2ec1c29eeba4..b8e87804296c 100644 --- a/net/rxrpc/sendmsg.c +++ b/net/rxrpc/sendmsg.c @@ -336,6 +336,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