Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2148605iof; Tue, 7 Jun 2022 21:22:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyORADj3xIn26dvvWZmvKpXXGyPorVW7SEuwmAEUe0NXHfDfCqGiYpWFpHMFc+E0ErcjY3f X-Received: by 2002:a63:8741:0:b0:3fe:ac5:ef28 with SMTP id i62-20020a638741000000b003fe0ac5ef28mr4946669pge.386.1654662136209; Tue, 07 Jun 2022 21:22:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654662136; cv=none; d=google.com; s=arc-20160816; b=t00j8iNlwYoSrN6lwISWhonVIc4tiiN6uVN/RDRf6sr8eo2dYRLadobIawgE5IpsAG WbIHm751TKTFWiQgpJikOnYaKIrCTwWUdBj8GpRZGUXalsFPhx2HbF4jslCl+JDP9rN/ zL82u6UVeDcD8hyS9F77qpKhcY4MxqCgQEztoLddbEfgVw28mOU6nXvvSdfQ95JUElZe LE06Knn4EM0ZLKv+G4c+LV6src7G6UF21QePZGImrUledWWay4O6CqjED40cWvnHYBvD OfoegXVPIXtkKoWQtH7oMA6+7i443z/1NGTs+GUr9auo/J2B284ERFLs0EH6/pgQppTS q9Tw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2Fp6lqBl+VToZfuH8DzxEIPfMYNjJipGkfQR6eiJwLk=; b=WM3EnPS1l3hXa2HM+aseoTRqxGfsJqz94E1nY77tk1uj9SbSmMDQVcIvbd4o5od1M1 XzYvbAJP9ndXu4PteAtYg3btSzgV1Gn05+EvwbDYuP6kLYVqITlW7GD4106vJ5zapvuv m/3ljSo503saXH90nS08JHOc5h2LATPrjBZO/Yn+KphMzQzHQx8Dy1u6KDVOrVyfjMnj F5z3BF2veM1erULl2/LeGOurBPZGRy4L1ysDx/jnm62pzUDar2bt2lHDBDVhRM1NiWzq XsCSjQeWFvP1HH1/vgnRf0zjpvm5VgPOrY5uNDQF7RVfXky7TIcCFvbXydlUxeR0u2Cg RIaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dChu9tR9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t190-20020a6381c7000000b003fba940188dsi27463969pgd.323.2022.06.07.21.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:22:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dChu9tR9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E4F31405D88; Tue, 7 Jun 2022 20:53:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385026AbiFGW0P (ORCPT + 99 others); Tue, 7 Jun 2022 18:26:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380715AbiFGVQt (ORCPT ); Tue, 7 Jun 2022 17:16:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D561521F9C5; Tue, 7 Jun 2022 11:56:36 -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 ams.source.kernel.org (Postfix) with ESMTPS id 67C28B8220B; Tue, 7 Jun 2022 18:56:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C76CAC385A2; Tue, 7 Jun 2022 18:56:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628194; bh=s4KO1UgUY/B996K+l2DBDtuWNiu3YWMyS23OqCyZMqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dChu9tR9YvUg0HCi9mBz1PQnZyV4ubTVx9AqJRbaTtxUDVSnLsvQyUM8Mmgz20UoV 96r6Fq8xNZRKCCdbDs5ljk8QUt8Mme8rqz476eL1IOgzbA+t7ON51CqsbCR4Q8kOdU g6mc4rSn7R2QePEF9cVYIPTpXFMVAt2ulUFgbId4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Dionne , David Howells , linux-afs@lists.infradead.org, "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 199/879] rxrpc: Return an error to sendmsg if call failed Date: Tue, 7 Jun 2022 18:55:17 +0200 Message-Id: <20220607165008.621633343@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 af8ad6c30b9f..1d38e279e2ef 100644 --- a/net/rxrpc/sendmsg.c +++ b/net/rxrpc/sendmsg.c @@ -444,6 +444,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