Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp804105pxb; Tue, 3 Nov 2020 13:01:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTchcLy0dYn/RD8DO6TzS/faffSUof8WAigHB2onbNsnr4/XEQG7WE6t0E/KnU32EWKNTM X-Received: by 2002:a05:6402:b45:: with SMTP id bx5mr22738255edb.193.1604437268888; Tue, 03 Nov 2020 13:01:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604437268; cv=none; d=google.com; s=arc-20160816; b=k6trS0d/yXneEhaBTM9MStgZfGJ18WqmcydgZfna2g8lUkfr68SsN1RL7OqaA0qq+W us/JYbCpltByyQd2vAg31xl7XkJEp0b/pbD5RZbtkq5wlYl9ruT2Tw1bEVh9Yjhhao0D X5TXTYEO3QMMyXTIrfat0TVXLHIqivkqmbslrjaChQEsoDJtDjXiGnGKGuXccg7JpkvJ kSwoTymPp9dNqtKRlZIrM+WZmKmN2XX6HRHJ8ghBMXSRb8/41RNskqgEHg/f/KOgunor +PeOzF2PcDZpX5IQOIvcB0AnhNjBoJ8FpKo/tGrvejJxfIng4sMeJkDqk5+QqsNS6ouD wuQA== 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=9Tw1zlbXQMCApAFkNbsTn2pR55bZXPD+2XJASKWoWnQ=; b=YYgkg0M4nHH6FriDs2n9+snsVz5NGz+PC7fzISP+aymH7OuoFxyAHEHMbYCUQu33v0 1Ex/l41jOZjHdQC309jOZ8i8UDUCYlaeTtMThyfHx9Fc2O9aWjjG+gDQBLwJDHYCyvub 55q0exnW5otgIPcMgkgJt2REoQuXktKIxLFJtqVgZwz3U8gOElH/PBl+mNQaE7u6Ai58 mRjyIBc9pSdmYv72EotkyQH0QFBGIlUQQXSHL7wQ2hGQHsH6ITQKFT9ZFr4b8/64Vb9T f0cJS5vZlf7/OGlj3dqnJAGSuHEUB4K4Ef3CDMTcSDifjfuimP8G+UMgLrczDJg2waAL FCqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MWHpjFtc; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si14060140edm.295.2020.11.03.13.00.45; Tue, 03 Nov 2020 13:01:08 -0800 (PST) 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=MWHpjFtc; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732716AbgKCU4Z (ORCPT + 99 others); Tue, 3 Nov 2020 15:56:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:58010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732704AbgKCU4W (ORCPT ); Tue, 3 Nov 2020 15:56:22 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 120C220732; Tue, 3 Nov 2020 20:56:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436981; bh=b80ZqhqdTXMhpSjNBOcQ1Npvl5wJCznX/xJqg7NreZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MWHpjFtcwbT2xljQOgHu/snjl8h1ImlvV6I0/s11Mvd+I+A3ZUFu7321E6AlXyL75 LO6QSoe1+9F2zPM83jgc7aSzKoMVJI8jmiP87mGreFg3Gez6CSdMB3BzLulANVVKzH cKmforeHYsnAeh6STHHT7CMVEZKmlEmX+nlsQLFo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chao Leng , Sagi Grimberg , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.4 095/214] nvme-rdma: fix crash when connect rejected Date: Tue, 3 Nov 2020 21:35:43 +0100 Message-Id: <20201103203259.398546550@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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.27.0