Received: by 2002:a05:6622:f08:0:0:0:0 with SMTP id l8csp4479578ivc; Tue, 3 Nov 2020 13:07:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNK6KsHS4XS5YWXDWaFqQpO9s60dl8MXdJFMfExOW4y4uDefga/mz3otsrWUbqE8iuSJNZ X-Received: by 2002:a17:907:2712:: with SMTP id w18mr12396986ejk.130.1604437625198; Tue, 03 Nov 2020 13:07:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604437625; cv=none; d=google.com; s=arc-20160816; b=cGIE2D1ITvi9h8cB1yqfZ5SbrLAOqTHP/FPyL2ojd3sQMrmjm26pC2CViq/7JRt+UA ya+R8UzypbOfaxGNlQ3OuajafjzqqivdqfAVMCTWFpqEqEld9zIV6DByY/puxVh4CbJ2 F+ZAc3FDcTyyqwQIxpag8XgCn9uexBy+ge9jYBywm88cikMovnOkfnnRzBZixOd45qVS 4MWijjXqPg/fgXaOk3KuUgkKRgeQc+vMZqr1CoNGjral3mU4IEOKEF82PeF28gjRIL5L tYGm+5ruu1njv7qG9sx7L4FOIg5f1pQ66HhTuaENQz6b/yd3PvuR/SfgpTCDkDQowlMn NRCQ== 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=ZABvk53rLc05EqM8ogcd1JqfhLMNvi7CtGeEImKzJhM=; b=03ATrR+MuDPSZmUEhFg+imtAwV6hJyOWSdIvoJ1OE1lfub2qVL+A0kxezFtalNzV6f U+qwgkI1jlnyU7PgQXPk2MurnphZ4VwRdXMadWLR2QewxaZXRXy+Xd9GxzxsWGBeMrlw W7iYDBvjetLNy46I1PRHlssPqNnGkK/KPmI0m95Zm9/tmUabmcsQXbD1TP74zWUvSDjE FspZt/AIigyhVx3swoK9y7gUxYLDUYbuHMqI2JYpqn47R+X976Uijb1M0il2zsycK7Qg vh84o+2VePsyx7aKaPqX5vzCQ3Wy5hZ4ETI6f79LSAUImqVGnR7CFlt496TvHQ/c5ziH Ic/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fcj9yFbS; 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 z22si6531ejx.130.2020.11.03.13.06.42; Tue, 03 Nov 2020 13:07:05 -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=fcj9yFbS; 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 S2387811AbgKCVF1 (ORCPT + 99 others); Tue, 3 Nov 2020 16:05:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:43798 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732586AbgKCVFT (ORCPT ); Tue, 3 Nov 2020 16:05:19 -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 AA816205ED; Tue, 3 Nov 2020 21:05:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437519; bh=YYkLz3QUm+o8MytFs130s7j/6j4iqNUfVefHb36a7ss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fcj9yFbSETZlILwVfbNBFdN4Dj2sUIgUq/wKKRsj5YJXXu3Itopu9ib14ScSyidht jq1cLGSmjS7wH4xza/mcyJKzPtlr+JPOoRH7qy2j6Bd/eJXc4zXQfgUIu8p/zKudUU F2jDBc4Z4R63Y1tNuHgklh1rwQ0cP3zBCs/oZhps= 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 4.19 111/191] nvme-rdma: fix crash when connect rejected Date: Tue, 3 Nov 2020 21:36:43 +0100 Message-Id: <20201103203243.872525339@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@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 077c678166651..134e14e778f8e 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -1640,7 +1640,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