Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4879616ioo; Tue, 31 May 2022 13:55:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxs3ofiaqPZQcPqLPzwJbBs39418CD5yQc70sopVHAHrnb5BMfGINZj4+3fRbK0+sc/ROhD X-Received: by 2002:a05:6402:5412:b0:42d:cf78:6479 with SMTP id ev18-20020a056402541200b0042dcf786479mr14630013edb.18.1654030505653; Tue, 31 May 2022 13:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654030505; cv=none; d=google.com; s=arc-20160816; b=NrYaldQmsHLMDTSVROFRPUNEPp09/HeHMSO2flM4aF4wdU4oQvk/ewp2NbFJOeDUuW WAg7asSkLiCBxnRY6egau9zKp5EUE+Wfr6yQnjYfMxk1ErHu5y/kLHZmso/tfaNU4M+L RGtNNc7dXy45/6B7UtSEpfWSgZzITygKrCxlh59rU8eyFvzonvyDo25QQrz5HSAkzy7D 1OK8yun4Ag9uP7byZWKC5tlnrgqhXtpkPgFX79+zKJYT+PZI4PR7eze1aI9s4DUES3Cg JZ1j8pFEkzidsiGknq4WhfGHy8/lsPcRfjRjCnW1zZBxbWeZkLwY6RVnJR+J67w+XAL/ KrmQ== 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=PJPhfAbK6+gsRvnGC4F9hauZ8MP3r3HqidyjuA0n/fk=; b=tBZvNynwugKezGAv5xZdz2/ha445hjrAmqcQ+noQ24RL5wlnAanKthoXIyp+Onq5Ls JTF9YRSxz+OS6k1itumPIvd+GEeQyQMUASrzpiT7zNS2oE04Xqay0hpcKugOqBAntY6x 0FuvNLfoQCc1Of2KFjePMBPowz+0NVncMehha1mv+KZjJJr2ux5PEDIaDaerkrscSWXX 7u7H3RcnFCHyiVDPZaEYLHLt8xqt7QF/qaBEAM0ZDsm+opqzDIXLxo4TvCOx2DCVL/bL xcGrNFwF0KScF7nGabqe9xx+JBvF8FnUqG9Dom7BQWIhqD7/KDpG8dQ82Ksze1DtUFJk VhGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C8JNStLe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bd24-20020a056402207800b0042dd4776068si337704edb.382.2022.05.31.13.54.30; Tue, 31 May 2022 13:55:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C8JNStLe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240676AbiE3On5 (ORCPT + 99 others); Mon, 30 May 2022 10:43:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242193AbiE3OSa (ORCPT ); Mon, 30 May 2022 10:18:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BABA811CA14; Mon, 30 May 2022 06:49:21 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 219AB60FEC; Mon, 30 May 2022 13:49:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CE40C36AE7; Mon, 30 May 2022 13:49:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653918556; bh=xnuZ9XK+CKLdG2vQFls8v7LSP74HMjNzXx226U2PVTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C8JNStLeChN2VPvUlFp2dHUjK2ZzLaGy1q8qIzwOHLrKhXdhoH/0JDaXWYbVblkNH pzVHz1I1SVqHAkfhpGamvrXEMop4aeNICvd8e4UN42fdcH0znbji/fQWn61iQO5u8g sVOWWlrXvujAXyCJUJRs805j+5KecUgibISfW3XstkPEkHRA9Kk9kBqNyM+gB6o1ii vfFhxrPLJqDkGQdVxwmKAyOar+mUU8kfwKn3R/zLnqxJOiEHVAzkeEXNs0tOmje9mE zCO+uJhItQL5CpDYzSdUsG/JnUedLGBwRQbparLj+ALUpssq3P3DcoNRKMZL384c+F nfSVjtWL5LFyw== 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 5.4 53/55] rxrpc: Return an error to sendmsg if call failed Date: Mon, 30 May 2022 09:46:59 -0400 Message-Id: <20220530134701.1935933-53-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220530134701.1935933-1-sashal@kernel.org> References: <20220530134701.1935933-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 1a340eb0abf7..22f020099214 100644 --- a/net/rxrpc/sendmsg.c +++ b/net/rxrpc/sendmsg.c @@ -463,6 +463,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