From patchwork Mon May 15 16:24:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 94235 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp7082705vqo; Mon, 15 May 2023 10:33:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6SEKWM/3oQaOxdZvvU/tfr+nxeJ4+rkACswh8QNf6ZFPCBc0D0E2o1kU/Gtsjb6RuuNlj3 X-Received: by 2002:a05:6a00:2da8:b0:647:776c:d19c with SMTP id fb40-20020a056a002da800b00647776cd19cmr28158744pfb.13.1684171992747; Mon, 15 May 2023 10:33:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684171992; cv=none; d=google.com; s=arc-20160816; b=XTt67FB6EX6EQKExN69R5d87A8rYiC0Huef6SILOHTStiG8gr3KizXjhESGAnf2tWq 0/2LvZ2vsZgcG9f/bXcwA1X1dgLDUjqzRJZXKkrpwa+rPr6pydlv256orgXYGZ1Eva0g 7zfUXzH65kSt61d5irRdLiLxsrPqeAPFViGY7yUh1A5jo/WUrbLBrmEH/LksD+chdVYa e4GQOemcO7wymAJ/U77ue0hLPFcGvSC7n4AQNNKHeu1FUem/o4/4fRzQe2wPP0B2dc+o u9b1UnSQR1EKxfns7vpUlEVR61j2RiUWFWvdzgFSx1/s6jNKp/d2PMxIQy2DLfWtAzjO a0uA== 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=M/TwYp5UKQC2RpmAGPOscHqgja+MF9HXWG5kbECG0Wk=; b=h+8cwweLsZ1E9EahIoMLF590wwmIAtgwHH8qCUGLgC6Mnvo8h6XLY1Zfq35iqKx/ou nb/Rt5gR1oFpAfSDoc4i1PtQbpNZSVOhu41N3yP+RHxkitgJdtGDYSzxkpSfJvg+Anrn kfsDfbgEdC0orybeFm0l6CkqbkeMoBaxE/sdzd517Z3NfXP1XWnEpX1Wx073XY6seWrt lDPxsiokM1p3VRlOas5cO3kzgkPg3ItF1IEcWiStBwitCZ1epN6K6UMfnVcPv0LNI2h4 QZd/cv4pmSo51Og/CCyAi+qh6thYelYOt9bR9hPmmyKl1QoixlGT9DzEVnDMQLD676Ar +KFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k8ywxX3V; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m184-20020a6258c1000000b006456f83ea4dsi17110058pfb.201.2023.05.15.10.33.00; Mon, 15 May 2023 10:33:12 -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=@linuxfoundation.org header.s=korg header.b=k8ywxX3V; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243060AbjEOQut (ORCPT + 99 others); Mon, 15 May 2023 12:50:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243105AbjEOQuh (ORCPT ); Mon, 15 May 2023 12:50:37 -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 0631E5FE6; Mon, 15 May 2023 09:50:28 -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 8FFCD62974; Mon, 15 May 2023 16:50:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A391C4339C; Mon, 15 May 2023 16:50:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1684169426; bh=tlJPUuUVRpEZGnrbkGEflL2jwDkHI9CNFTJwvu+RQuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k8ywxX3Vi5XspSkFT3UOVNyTy1jHM5Jks06jrR6OrtaTta6hyTzaA4WlWo7GaurJk FockyaiYZSbLxTy953Q9d46aTU73/Ql/C8ZjFcBbwhecIsCEla/uQ4ufx+I6CI0fJy NfclnELAZZjc0e61ts0OiVeVtlMjoIko6f9NQG00= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Marc Dionne , David Howells , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-afs@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Sasha Levin Subject: [PATCH 6.3 052/246] rxrpc: Make it so that a waiting process can be aborted Date: Mon, 15 May 2023 18:24:24 +0200 Message-Id: <20230515161724.142586697@linuxfoundation.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515161722.610123835@linuxfoundation.org> References: <20230515161722.610123835@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765982331823080816?= X-GMAIL-MSGID: =?utf-8?q?1765982331823080816?= From: David Howells [ Upstream commit 0eb362d254814ce04848730bf32e75b8ee1a4d6c ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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 7498a77b5d397..c1b074c17b33e 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;