Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4232625ybb; Tue, 7 Apr 2020 03:29:32 -0700 (PDT) X-Google-Smtp-Source: APiQypLwc4u8LU/TYTeCCbCujLAKmiTmOe/N5191TJyACQCrXm/7Kx1xe77F+HZ8xBx9mqmE7ZED X-Received: by 2002:aca:56c2:: with SMTP id k185mr1027266oib.141.1586255372450; Tue, 07 Apr 2020 03:29:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586255372; cv=none; d=google.com; s=arc-20160816; b=C2kipuIMLgkmuKwoKUbly5TVKZotJ4cwvaCHbzNJCP8asZFblQxLwETW/IvCzWK54w VRjef5CbQDOVNoeb8WtE1/+A72VI5133SKBYlcKF2Rk9IR+NNpCtmt9gdvDCRHZaoiPh yM+PQ769Z7wvi4UWuo0++M3Kb5DmW3Br5H3h7delzDlogBaHzIXgQjE1/U7Slnexm9Cu j5eZ/MZEcsm/+16FjyX/IuU+kPqgrtnv+G59Kf97HPpy6wwjP+QDbccXFNUqKBbix/5k 30BTqyXbSqY9Qb2emUB6jVISLzvBFQAQfAHfvm6eBYk+78bkfY0Aq1AJWS95poyxSmv8 s3aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2T9VsoxrwlDhSrX+JzAoKW/C6nXnZ5Wt/cUjgbcb1Ok=; b=sot3+YtGrtKBoKvQHgpYN7bCdjT1gZiSyMkSZ4YhdYCoOJBS6SfI+cmbqwPCpkZCqA 4xTk3J6riPdMsCWDFlOtojKSCX80AuC0h8BZUr0I8h6p81qYoe6bxDRaw3yCwhi742gb jGxVnRS2p6C88ACpFK//gu1Ka7JWUaUrv13orcx4fmN+cMALwVVB7edfHAeC1/1i2Eqt JG9aKle0Te1oqjVq7DUG6qsz5/xxcsJUpN2yI/ejv0QHznifFk2Z595AR3VPMbkDJ50t XF7JeeiOS8fKeEJAqApCqWFG2HNNp0jQhANwTbzeXTNpfDoakrjNfE4AW4HbpaKt8v56 LVQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ah5OOGzK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q206si538770oig.71.2020.04.07.03.29.21; Tue, 07 Apr 2020 03:29:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ah5OOGzK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728879AbgDGKZI (ORCPT + 99 others); Tue, 7 Apr 2020 06:25:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:35528 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728843AbgDGKZF (ORCPT ); Tue, 7 Apr 2020 06:25:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 85C4820644; Tue, 7 Apr 2020 10:25:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586255105; bh=Fs02QOeqFeunLDhAhOWC8FGhC42gEBQwFYKZQ5UAcC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ah5OOGzKCvaOOTCZmFdvapXOu8pnIaRaSR2cv8yPfuvLJETfcFMfJZkO2Z7wHYxQD aG+PieNbP+bPwszG3AXemGhIy7GTpWnFp6CwvtFVCbIjF9wVf3qZKjAE+PhMVv3O+x 5lrbyNL9AHjsMiIIkgHinzCDg8vQb7TDuumH03rc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roland Dreier , Max Gurtovoy , Christoph Hellwig , Prabhath Sajeepa , Keith Busch , Sasha Levin Subject: [PATCH 5.5 07/46] nvme-rdma: Avoid double freeing of async event data Date: Tue, 7 Apr 2020 12:21:38 +0200 Message-Id: <20200407101500.273308750@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200407101459.502593074@linuxfoundation.org> References: <20200407101459.502593074@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Prabhath Sajeepa [ Upstream commit 9134ae2a2546cb96abddcd4469a79c77ee3a4480 ] The timeout of identify cmd, which is invoked as part of admin queue creation, can result in freeing of async event data both in nvme_rdma_timeout handler and error handling path of nvme_rdma_configure_admin queue thus causing NULL pointer reference. Call Trace: ? nvme_rdma_setup_ctrl+0x223/0x800 [nvme_rdma] nvme_rdma_create_ctrl+0x2ba/0x3f7 [nvme_rdma] nvmf_dev_write+0xa54/0xcc6 [nvme_fabrics] __vfs_write+0x1b/0x40 vfs_write+0xb2/0x1b0 ksys_write+0x61/0xd0 __x64_sys_write+0x1a/0x20 do_syscall_64+0x60/0x1e0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Reviewed-by: Roland Dreier Reviewed-by: Max Gurtovoy Reviewed-by: Christoph Hellwig Signed-off-by: Prabhath Sajeepa Signed-off-by: Keith Busch Signed-off-by: Sasha Levin --- drivers/nvme/host/rdma.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 3e85c5cacefd2..0fe08c4dfd2f1 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -850,9 +850,11 @@ out_free_tagset: if (new) blk_mq_free_tag_set(ctrl->ctrl.admin_tagset); out_free_async_qe: - nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe, - sizeof(struct nvme_command), DMA_TO_DEVICE); - ctrl->async_event_sqe.data = NULL; + if (ctrl->async_event_sqe.data) { + nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe, + sizeof(struct nvme_command), DMA_TO_DEVICE); + ctrl->async_event_sqe.data = NULL; + } out_free_queue: nvme_rdma_free_queue(&ctrl->queues[0]); return error; -- 2.20.1