From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3BDEC2D0A3 for ; Tue, 27 Oct 2020 00:11:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9788420709 for ; Tue, 27 Oct 2020 00:11:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603757482; bh=i7JPtbEiXAS705p4PMda+eMSdKJ4qDNXLXWfIebaYWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Q2YNZwk3tF6rpVpPY2cLyoDCrDUMt1SeqhZFi61DDPBS+hzAueiru/JT0hOsP4sVp 5131K6tYLycr6/h7n+JrjlZzsB7isWdbM1L8mrlNxOkx8Lu4u2Ibnb/melunEBo42Y ED4BFxFYV5L1D4bXgOm5H0H9L0KthwEnybWSIc3s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2411724AbgJ0ALU (ORCPT ); Mon, 26 Oct 2020 20:11:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:59740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2411582AbgJ0AKm (ORCPT ); Mon, 26 Oct 2020 20:10:42 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BEE6C216FD; Tue, 27 Oct 2020 00:10:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603757441; bh=i7JPtbEiXAS705p4PMda+eMSdKJ4qDNXLXWfIebaYWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2wjJWXAFTcoSEiYgnF4rjBFJqN3uB79+/6bdHQ+eBpxTaU6Svuhg3XBhpNikL8ETr 4vXvyj4KMFXu8Z9nhyVGKPeItiLPt3TUhHC+xyGfmz5tG1pjJDAas++PzMDI9/JXG3 E5fYOWHwSRE2nmJ+4cOq58tb4nVaFVIEccDujPCg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Chao Leng , Sagi Grimberg , Christoph Hellwig , Sasha Levin , linux-nvme@lists.infradead.org Subject: [PATCH AUTOSEL 4.14 46/46] nvme-rdma: fix crash when connect rejected Date: Mon, 26 Oct 2020 20:09:45 -0400 Message-Id: <20201027000946.1026923-46-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201027000946.1026923-1-sashal@kernel.org> References: <20201027000946.1026923-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chao Leng [ Upstream commit 43efdb8e870ee0f58633fd579aa5b5185bf5d39e ] A crash can happened when a connect is rejected. The host establishes the connection after received ConnectReply, and then continues to send the fabrics Connect command. If the controller does not receive the ReadyToUse capsule, host may receive a ConnectReject reply. Call nvme_rdma_destroy_queue_ib after the host received the RDMA_CM_EVENT_REJECTED event. Then when the fabrics Connect command times out, nvme_rdma_timeout calls nvme_rdma_complete_rq to fail the request. A crash happenes due to use after free in nvme_rdma_complete_rq. nvme_rdma_destroy_queue_ib is redundant when handling the RDMA_CM_EVENT_REJECTED event as nvme_rdma_destroy_queue_ib is already called in connection failure handler. Signed-off-by: Chao Leng Reviewed-by: Sagi Grimberg Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/rdma.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index c91bfd839cabe..564e457f1345e 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -1545,7 +1545,6 @@ static int nvme_rdma_cm_handler(struct rdma_cm_id *cm_id, complete(&queue->cm_done); return 0; case RDMA_CM_EVENT_REJECTED: - nvme_rdma_destroy_queue_ib(queue); cm_error = nvme_rdma_conn_rejected(queue, ev); break; case RDMA_CM_EVENT_ROUTE_ERROR: -- 2.25.1