Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1518057ybb; Sat, 11 Apr 2020 05:28:55 -0700 (PDT) X-Google-Smtp-Source: APiQypLicjXPu2buEVQRLTVzelk4o13YV4g06clw2zGCHDG2DcX87OTY8VgHL0dc68MuHB/gHfF8 X-Received: by 2002:a0c:a8c4:: with SMTP id h4mr9285593qvc.72.1586608135605; Sat, 11 Apr 2020 05:28:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586608135; cv=none; d=google.com; s=arc-20160816; b=ouCyQWvjvSiJ9hXlvQBWlJIlL6vdtmVnFshyEDtLYXdyBzwj6iXHGJ0tIyAdBJSZUF oP66mFIZviB6DPh7s+SYc2ip1ixpii7JmyJF8SG4+7Vbm0I7DTIObSIeFbwSPOf74fCm GbaLAGdVU1ELx+BH1Nui8wFYpB2eAnhQc2Vz5Evu7WDEEV3UxF189498TyPLjN2KS/dG zZ2M+yc0cXb8xZCNLKza09EHpFth25tPmv+NLutuJPH7wXwbnnoBQuf+Ptv3OktO+3Dc zleWRAeMxkHLUSxjBXrs4AeSOKqyqC+hWsGUCbCxku02LDL+cxBQAPXW9d4w/ZDlIBv2 +B5g== 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=JZXGU3qyfY/thRaA+2eZNYY6CJnTmreT6p6v0hr1vn4=; b=ZYvHA9KAabcgX8g+NJ/+/P0Bg8RBhoSHPE/m1bn0lqlHrBOAoFquth3R07lc+j2Vzk am1LClcX9HEdRtot9k2hXzFuSyr9Xve1ehW6N3wVzWdvw2DFedY1+Brv/zVvD4EwU3Rg 3eXDK8ZQqnLtW5el4bro3viR4x17p1nmTLw+y+mmFYklBxm1E+LYliRorPSWb7BO4trS 0YiNFgzxd4K9mPTll8GjEZHZnlAYT3TsYq0MidxjZox/k9aP3Y/HeQ0vW3+ARZfxpwqN N33E1VFXGgQvEkA4XllMaqgsnnelwsFkdDalnTTqiP0QhGXvaNqh+M+pEFEVGC5VSS3o PLKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="U/FexROF"; 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 b2si2959330qke.119.2020.04.11.05.28.41; Sat, 11 Apr 2020 05:28:55 -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="U/FexROF"; 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 S1727367AbgDKMPH (ORCPT + 99 others); Sat, 11 Apr 2020 08:15:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:48776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726713AbgDKMPE (ORCPT ); Sat, 11 Apr 2020 08:15:04 -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 CDE1120787; Sat, 11 Apr 2020 12:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586607303; bh=JZq8dE2HemhgAxsq2NlZiZMCv5IuL2FpwL7FfIstci0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U/FexROFfZiScO1hssSr0+G3nzNDcKbOPwfCuKSHazym7Sj09vpf7yXwC7tWF47xq VLBK1OxUq629t0wB14qOgUY4eWnxJq50jsCYT403B0NI6wPRjbtHhkPrzrgqVV0jOi IcXzPMskIycGItjZ1rOVRLU5qZBOUszUh+ax0YFo= 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 4.19 05/54] nvme-rdma: Avoid double freeing of async event data Date: Sat, 11 Apr 2020 14:08:47 +0200 Message-Id: <20200411115508.766563409@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200411115508.284500414@linuxfoundation.org> References: <20200411115508.284500414@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 e4f167e35353f..9711bfbdf4316 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -815,9 +815,11 @@ out_free_tagset: if (new) nvme_rdma_free_tagset(&ctrl->ctrl, 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