Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2825336pxv; Mon, 12 Jul 2021 02:52:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweTE5S2C8Asdq6WP9WbQnsZgUHVZdwS0KAraBtU5BjR1GUMaB5Wid5Ok/rGBg/jM1wEOD8 X-Received: by 2002:a02:cce6:: with SMTP id l6mr8210315jaq.114.1626083563998; Mon, 12 Jul 2021 02:52:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626083563; cv=none; d=google.com; s=arc-20160816; b=IDQ9ezuY4VMWKo5hfAmaYN40A328p8Lkb/Jv+fBby4qOGZZ2dwr2escgzIDn4BpZks YZBfDq+RSxqVW2XGK0YPkVSCCBYjPTEajDg9/BM7EjywBLPlurfDWhCh2rH8EZlSuQSq x20uxg2P5JCNTO31wD2XFP7mx7wLUNblC66ls7I/INDMf3IEsz32BsTjSiLL8MvCIqVr TVI9xWsqzcqdZNLrGTVBwK0OX91+Et+taKQPqtruw1xxBS9Sg53wjDjl1SoWV5NwqvGC ix69fFfnPzi2H3YwjfogZZpUVhuHBVxt+brKIhaaiqArUNI77xMg/flpiJjlFyMiISph XYvg== 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=78BY2xFUViDgbhBwdr05pNkm3yjrAw5nk3d2bPJEsP4=; b=TfZYINWkq2a+4hL387VC+eXvmd3ftGduDmQolRpV/pUAIY89aPugf4jD1/agQjCD92 vsskZ2owYmbtgXj8Uc0agDCH8dsygV4V/bpOtaCAGCdVyNxsQF4bZ6CNfvazD2AREphR NZt0kmW39sKIWLMc4hQQ+LemYAM0SRFnEEc/2SBY8ODUqqr4EN8QTVPrM8CMpZAZ3hQl 0kIIIGLAdcFLmbD/IaEjrkTdG1iqRFeAvySGuVP8JFXVBpUVKPIE5H9EN4ZYLeNzh1ur oQ/98mJDbsC581GQCyoNEi4e3AzwJgnkag3Yf06FdkoLcqvGn/Uz89GEy0w3fST4F2ik rWCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zChmchVt; 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=pass (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 t7si17447906jam.62.2021.07.12.02.52.32; Mon, 12 Jul 2021 02:52:43 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=zChmchVt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238825AbhGLGtS (ORCPT + 99 others); Mon, 12 Jul 2021 02:49:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:34844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237347AbhGLGjY (ORCPT ); Mon, 12 Jul 2021 02:39:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6935661183; Mon, 12 Jul 2021 06:35:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071707; bh=OIm63ihj85oBO1+j6fX/cBWdO9IRft/Qb4k7jt+4G1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zChmchVtgeQXSCZqLY1qpQZ46QRU6m2JpyodQ4TSS5FbWh/6bSayP1iMrggvHrJVr 0+KPI6Elaux+579hkAiVHr2UWrlsZ4UzGM0tz/FmdAun/ROyeLoBcBf93dmkR/9sBD ED+e0Hq7fRgBD9LEEJwe3VpjfMk5S3xDM28R4UHk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Aring , David Teigland , Sasha Levin Subject: [PATCH 5.10 184/593] fs: dlm: fix memory leak when fenced Date: Mon, 12 Jul 2021 08:05:44 +0200 Message-Id: <20210712060903.256522723@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@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: Alexander Aring [ Upstream commit 700ab1c363c7b54c9ea3222379b33fc00ab02f7b ] I got some kmemleak report when a node was fenced. The user space tool dlm_controld will therefore run some rmdir() in dlm configfs which was triggering some memleaks. This patch stores the sps and cms attributes which stores some handling for subdirectories of the configfs cluster entry and free them if they get released as the parent directory gets freed. unreferenced object 0xffff88810d9e3e00 (size 192): comm "dlm_controld", pid 342, jiffies 4294698126 (age 55438.801s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 73 70 61 63 65 73 00 00 ........spaces.. 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<00000000db8b640b>] make_cluster+0x5d/0x360 [<000000006a571db4>] configfs_mkdir+0x274/0x730 [<00000000b094501c>] vfs_mkdir+0x27e/0x340 [<0000000058b0adaf>] do_mkdirat+0xff/0x1b0 [<00000000d1ffd156>] do_syscall_64+0x40/0x80 [<00000000ab1408c8>] entry_SYSCALL_64_after_hwframe+0x44/0xae unreferenced object 0xffff88810d9e3a00 (size 192): comm "dlm_controld", pid 342, jiffies 4294698126 (age 55438.801s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 63 6f 6d 6d 73 00 00 00 ........comms... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<00000000a7ef6ad2>] make_cluster+0x82/0x360 [<000000006a571db4>] configfs_mkdir+0x274/0x730 [<00000000b094501c>] vfs_mkdir+0x27e/0x340 [<0000000058b0adaf>] do_mkdirat+0xff/0x1b0 [<00000000d1ffd156>] do_syscall_64+0x40/0x80 [<00000000ab1408c8>] entry_SYSCALL_64_after_hwframe+0x44/0xae Signed-off-by: Alexander Aring Signed-off-by: David Teigland Signed-off-by: Sasha Levin --- fs/dlm/config.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/dlm/config.c b/fs/dlm/config.c index 73e6643903af..18a8ffcea0aa 100644 --- a/fs/dlm/config.c +++ b/fs/dlm/config.c @@ -79,6 +79,9 @@ struct dlm_cluster { unsigned int cl_new_rsb_count; unsigned int cl_recover_callbacks; char cl_cluster_name[DLM_LOCKSPACE_LEN]; + + struct dlm_spaces *sps; + struct dlm_comms *cms; }; static struct dlm_cluster *config_item_to_cluster(struct config_item *i) @@ -379,6 +382,9 @@ static struct config_group *make_cluster(struct config_group *g, if (!cl || !sps || !cms) goto fail; + cl->sps = sps; + cl->cms = cms; + config_group_init_type_name(&cl->group, name, &cluster_type); config_group_init_type_name(&sps->ss_group, "spaces", &spaces_type); config_group_init_type_name(&cms->cs_group, "comms", &comms_type); @@ -428,6 +434,9 @@ static void drop_cluster(struct config_group *g, struct config_item *i) static void release_cluster(struct config_item *i) { struct dlm_cluster *cl = config_item_to_cluster(i); + + kfree(cl->sps); + kfree(cl->cms); kfree(cl); } -- 2.30.2