Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp886704pxx; Tue, 27 Oct 2020 03:04:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgSMVKgwYle7TPWRELkJe81wIBcCtehn9M/894DIy3CDtwiJDidqd4IT0n8Lkg7zt9AgDE X-Received: by 2002:aa7:c1d9:: with SMTP id d25mr1321114edp.309.1603793070240; Tue, 27 Oct 2020 03:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603793070; cv=none; d=google.com; s=arc-20160816; b=iVvdiB/m917D4JToGhME45F+B0rZ2o82ZNN+I3E8oaCOB2CWmLjJN5YFpfQJHjRct+ YjNFNKJRyVn90NREp6zP5+ue9ns+njinHjr8xbfda34VwbVwnNRRqOGc5a4aYpKZ2uIz Vy9iyIDhhvch9pZrxHcIFsNogKku1wKV1KUFoXKvhnI3anFGV1VgVPfjsZSQThw3UHEC bqKcp6+/1wNhgM47MGyQ4WP7sV2pokHXOZn3DOcpdwwMnNRqRPg7l+4b5IMclHLWhaf6 e6Orv2SFwE0ZDC1LMn2vtVYP+yMMdOF8/c9MmOr/lF9ccY7W9FIfcH1xL+XJUOmfYozf dH8g== 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=Mclxc0SYejG3o5yksaUmEpG9EYW0VkQbcfgJpdUkojM=; b=L/qYfVerJegHgy9FRmhxrY3VKrr6DNgb1hpBfSuD6LMGdE7uB6OPghcWSrObXfs9/B cVOvuPai9k5ecZuALgFfQfWIu0xOrUHJzwrZcyQ7/OrQRM3e9txpIyrk7J8dUArtHrQT J93JaC4chV5TOokXea9mNJH27OGVMOQjbd423wHtoH0RTxzVLOYyleJQd/sbnoOLfcl2 8M+bKPAKSm51hh0BsUZw/Pj788jS6qyOPTL+F+pkvRpytc14qqD7Ai6sotyfELmqyld9 UDAWIP2plgcoTS13eIhzBh0NEC389jwC+GRmPbL2XfHKBNegn6Kb3qvT1RybQOTWUzFZ aVsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LNZ57PDg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb6si486252edb.533.2020.10.27.03.03.37; Tue, 27 Oct 2020 03:04:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LNZ57PDg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2410555AbgJZX7h (ORCPT + 99 others); Mon, 26 Oct 2020 19:59:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:37336 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436633AbgJZX4y (ORCPT ); Mon, 26 Oct 2020 19:56:54 -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 BE21120770; Mon, 26 Oct 2020 23:56:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756613; bh=cCVgGMe5hoIQ+QFz+qgGojy6g3g+wPwt63Y5/vZUW0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LNZ57PDg6tQ8tF+AM7jHI41/PE8CfMhXrflkKYIrdMkTA4H6I6KZ/Q4xvAnjqwH1X dK6wX6pbK7Kdl0Rm1/XOowwiYj8vkeXwSBWOGZVGdwYtnDWTISD19d6RyAb9PFh6e9 hUfp5yWmDdXACr0aVLg0A/ocdJOLrM7aIVaBn8Q8= 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 5.4 80/80] nvme-rdma: fix crash when connect rejected Date: Mon, 26 Oct 2020 19:55:16 -0400 Message-Id: <20201026235516.1025100-80-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026235516.1025100-1-sashal@kernel.org> References: <20201026235516.1025100-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 abe4fe496d05c..a41ee9feab8e7 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -1679,7 +1679,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