Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3300297ybb; Tue, 31 Mar 2020 02:24:57 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuuAuF8j6Nlzb8F2ZPNX4cRvuN/I5AyzmHSfzf/W6Lu1Ol1VIQQwSI5x3EutkuHULG5sJAw X-Received: by 2002:a9d:6ad9:: with SMTP id m25mr12737090otq.160.1585646696884; Tue, 31 Mar 2020 02:24:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585646696; cv=none; d=google.com; s=arc-20160816; b=0/mKm8EbqbFLjpjoh/Ww9VFShMOMBGbuDYLZZObiwCNYDrwEHZevIUSbOiLWfBqD2C Dztn4WqsFYKp4LrkqoZqxWtVeahA4TLNj5oIaCSizjnSQYIFSP3KhKHROO3sY6Bf7VMo gnmR+Fdim+UVDOeYR2EEz+zsG0B7QQQ7mIDjiFJXqx8XcaQHTjEBCST9t3lP5Foyk6OG 85mY2kDIlFFQA4uBo5h4aqCjJPuHmSl4PWAiIO0eCiz/hn7Dru2hDUOfXWWiSTVmcflC TtGrBlOPRfTktvsTaB30Jzb7O0LfvoBJncmZTShJMWL/L0eZQUkBEwwxBWcV1pYWiYNG pfWA== 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=UdZYua28oWLDBFm2eBNEEL3RMzqSHtExZdV+fr8P5gk=; b=RLtoLBhOKFrTf8mfj3c7dXxTW2FOe1b1zKRGsc7JfWz1y08eV/jK6at5ukUVMCYAkG nMBegjQfSXQNicbXvEqJhFf/C+97skQPOWRvLzytomz3tls2q4HOaVORSa5TF/BB/Dw6 rcOO6yfCdqy1youP6HZik9TXEppDYfbpuAG6Z2aPlu551N2ra+R4dGDszIGdi48Z+isY Fubn7K3hefF+vUgr/2iGIQN1ObHaWja2vIM78UimizzT4846ENSHkS9aGtZTMo8rTyKy t34z4/2mJR2+kHDGqI6t9PtwKp6FX/rkPL98E5J9AJvANdQ9z2rDkLFeltC4uFcmeR/Y 4v7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cV4oSBT3; 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 j192si6610936oih.233.2020.03.31.02.24.45; Tue, 31 Mar 2020 02:24:56 -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=cV4oSBT3; 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 S1730932AbgCaJFr (ORCPT + 99 others); Tue, 31 Mar 2020 05:05:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:46928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730541AbgCaJFo (ORCPT ); Tue, 31 Mar 2020 05:05:44 -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 DDA3120B1F; Tue, 31 Mar 2020 09:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645544; bh=HUwnqrq5NS8Aru7Yr1JHV40ZkH6FV4vAeoA/+O9P3og=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cV4oSBT3Maph4aYQm7V9qxbrYprFy1c7TkQoj64/DI89cgeltPTOwoUaywC2mvNu1 wsiQh6Zmi1D3qaxraf+H13QzI3mQ+rD9Q+X1zA72loiaicwYpYF6rXgN73sCWBKmNn 0X6AG3u5H2TsiOy0FjY3S30kz07BU1jr/eMKAOy4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yi Zhang , Mike Marciniszyn , Dennis Dalessandro , Kaike Wan , Jason Gunthorpe Subject: [PATCH 5.5 086/170] IB/rdmavt: Free kernel completion queue when done Date: Tue, 31 Mar 2020 10:58:20 +0200 Message-Id: <20200331085433.419979338@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085423.990189598@linuxfoundation.org> References: <20200331085423.990189598@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: Kaike Wan commit 941224e09483ea3428ffc6402de56a4a2e2cb6da upstream. When a kernel ULP requests the rdmavt to create a completion queue, it allocated the queue and set cq->kqueue to point to it. However, when the completion queue is destroyed, cq->queue is freed instead, leading to a memory leak: https://lore.kernel.org/r/215235485.15264050.1583334487658.JavaMail.zimbra@redhat.com unreferenced object 0xffffc90006639000 (size 12288): comm "kworker/u128:0", pid 8, jiffies 4295777598 (age 589.085s) hex dump (first 32 bytes): 4d 00 00 00 4d 00 00 00 00 c0 08 ac 8b 88 ff ff M...M........... 00 00 00 00 80 00 00 00 00 00 00 00 10 00 00 00 ................ backtrace: [<0000000035a3d625>] __vmalloc_node_range+0x361/0x720 [<000000002942ce4f>] __vmalloc_node.constprop.30+0x63/0xb0 [<00000000f228f784>] rvt_create_cq+0x98a/0xd80 [rdmavt] [<00000000b84aec66>] __ib_alloc_cq_user+0x281/0x1260 [ib_core] [<00000000ef3764be>] nvme_rdma_cm_handler+0xdb7/0x1b80 [nvme_rdma] [<00000000936b401c>] cma_cm_event_handler+0xb7/0x550 [rdma_cm] [<00000000d9c40b7b>] addr_handler+0x195/0x310 [rdma_cm] [<00000000c7398a03>] process_one_req+0xdd/0x600 [ib_core] [<000000004d29675b>] process_one_work+0x920/0x1740 [<00000000efedcdb5>] worker_thread+0x87/0xb40 [<000000005688b340>] kthread+0x327/0x3f0 [<0000000043a168d6>] ret_from_fork+0x3a/0x50 This patch fixes the issue by freeing cq->kqueue instead. Fixes: 239b0e52d8aa ("IB/hfi1: Move rvt_cq_wc struct into uapi directory") Link: https://lore.kernel.org/r/20200313123957.14343.43879.stgit@awfm-01.aw.intel.com Cc: # 5.4.x Reported-by: Yi Zhang Reviewed-by: Mike Marciniszyn Reviewed-by: Dennis Dalessandro Signed-off-by: Kaike Wan Signed-off-by: Dennis Dalessandro Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/sw/rdmavt/cq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/infiniband/sw/rdmavt/cq.c +++ b/drivers/infiniband/sw/rdmavt/cq.c @@ -327,7 +327,7 @@ void rvt_destroy_cq(struct ib_cq *ibcq, if (cq->ip) kref_put(&cq->ip->ref, rvt_release_mmap_info); else - vfree(cq->queue); + vfree(cq->kqueue); } /**