Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2644290rwr; Fri, 28 Apr 2023 13:30:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ405q8wrjz8GLdkLK7yKTBFNu3HQ9e805FCQai1kSY6id+ok1SBPkbrQ+iDF6wnhyrpAQfH X-Received: by 2002:a05:6a21:33a0:b0:e8:dcca:d9cb with SMTP id yy32-20020a056a2133a000b000e8dccad9cbmr8669260pzb.5.1682713837190; Fri, 28 Apr 2023 13:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682713837; cv=none; d=google.com; s=arc-20160816; b=NjjXj5MZIVeKsdEWwhIKEWLFAHgqr5HmaIRQUJSykWNhXDavE/gwbKDbhvGJ1hJ+kE L4xP7Ijs1DwCjIOFKjxQWYBOjdWLfsDs7H5uXu9d11p93DKafqwx2yC6aAFBwDLnSwOW h+gvCCK9U2dHjaMWsMs2cha4zEPAmj5EIdDvBfI5s0Bmsbt4p/VUB6Za+wZltJylADGH 1LAwlniwsfThibVpBxbkl3gQBk7YXzGcQWTOMLJGXrqIrZ0pwgKXce4k+UZGRX4lZIEu AnTGnLqFUE3m4Qw3NEH2FjjUwn9PZh82Dd3PpuI8m+AHrPuTjq240YFwziln+C2x/Mii TXcw== 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=PTrMz2PfIMAWZjqyClwi15SoJPR6XaGnAtPZVNp1hQw=; b=UDXcMsZi9eM6fJaG6IUCxaqNxENdeyfZIMmCiIPcby+h5O02pWurZByuBMXKX3D3HL gEfXSXy9NLeAsMDBRxO8bVwiQ2fCBqSnJXwOsal0k/ahE10uL2H8HmoD0M7yckbi3HNn 5dOHDd8ZBacl9J8iEp+gFiz2S+Y31dc8ub0pfkwGhtBAOg94pMrY1NAxC1pWV5lp6QB2 MquHbLNY2C7l98K+C8lrgnHsADH2mo6yDsq73+pC47KjDPyZyAbhQr0TWuf9nL9M4PcR 4AMMcTrTQUbJBHk+cSHKJWt3d5ERvVMOhvVNF2HEVyT4J/8dwZTfVXIU3UKWUnOZpMIs U6yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cRb8iZru; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t6-20020a654b86000000b00514314780easi22719263pgq.34.2023.04.28.13.30.22; Fri, 28 Apr 2023 13:30:37 -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=@redhat.com header.s=mimecast20190719 header.b=cRb8iZru; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346538AbjD1U3J (ORCPT + 99 others); Fri, 28 Apr 2023 16:29:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346125AbjD1U27 (ORCPT ); Fri, 28 Apr 2023 16:28:59 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E4D52D58 for ; Fri, 28 Apr 2023 13:28:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682713688; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PTrMz2PfIMAWZjqyClwi15SoJPR6XaGnAtPZVNp1hQw=; b=cRb8iZrubaXwQ+Hox2P8PS7zYGIPHdkY9nBch8AybCRZHQrjaTqDruBxeY6J0tBFkSAPMN LA07StmZp+T/NfDBbijqHhsjMssBdh9nk0fE0Zh9m0FpqRPsAtEl+AczTIxJxx7L3RVpv/ JYHrmn8fNgFwSV0SOLqN3Pk3tJlFfq8= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-124-ghjhwPmqPYmD68ydMSPiVw-1; Fri, 28 Apr 2023 16:28:05 -0400 X-MC-Unique: ghjhwPmqPYmD68ydMSPiVw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DF31F3C025D3; Fri, 28 Apr 2023 20:28:04 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id B559DC15BA0; Fri, 28 Apr 2023 20:28:03 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Marc Dionne , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net 2/3] rxrpc: Make it so that a waiting process can be aborted Date: Fri, 28 Apr 2023 21:27:55 +0100 Message-Id: <20230428202756.1186269-3-dhowells@redhat.com> In-Reply-To: <20230428202756.1186269-1-dhowells@redhat.com> References: <20230428202756.1186269-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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 When sendmsg() creates an rxrpc call, it queues it to wait for a connection and channel to be assigned and then waits before it can start shovelling data as the encrypted DATA packet content includes a summary of the connection parameters. However, sendmsg() may get interrupted before a connection gets assigned and further sendmsg() calls will fail with EBUSY until an assignment is made. Fix this so that the call can at least be aborted without failing on EBUSY. We have to be careful here as sendmsg() mustn't be allowed to start the call timer if the call doesn't yet have a connection assigned as an oops may follow shortly thereafter. Fixes: 540b1c48c37a ("rxrpc: Fix deadlock between call creation and sendmsg/recvmsg") Reported-by: Marc Dionne Signed-off-by: David Howells cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: linux-afs@lists.infradead.org cc: netdev@vger.kernel.org cc: linux-kernel@vger.kernel.org --- net/rxrpc/sendmsg.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c index 7498a77b5d39..c1b074c17b33 100644 --- a/net/rxrpc/sendmsg.c +++ b/net/rxrpc/sendmsg.c @@ -656,10 +656,13 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len) goto out_put_unlock; } else { switch (rxrpc_call_state(call)) { - case RXRPC_CALL_UNINITIALISED: case RXRPC_CALL_CLIENT_AWAIT_CONN: - case RXRPC_CALL_SERVER_PREALLOC: case RXRPC_CALL_SERVER_SECURING: + if (p.command == RXRPC_CMD_SEND_ABORT) + break; + fallthrough; + case RXRPC_CALL_UNINITIALISED: + case RXRPC_CALL_SERVER_PREALLOC: rxrpc_put_call(call, rxrpc_call_put_sendmsg); ret = -EBUSY; goto error_release_sock;