Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3763917pxv; Mon, 19 Jul 2021 08:12:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx86Dn30hHsVLaAUYs4IBXUL9Q7RgksFGKIxk9fXBDYGm1ufQ2j0eOFI3oBdvpJmHU5Y4Dz X-Received: by 2002:a05:6e02:4d2:: with SMTP id f18mr17414584ils.21.1626707558913; Mon, 19 Jul 2021 08:12:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626707558; cv=none; d=google.com; s=arc-20160816; b=yNXsoj0//heu/JngthoZKA3Hlqz4QePneuB+ddnnv8vyR1ogBggNoMGNJ1RiHBIoCK r84lRhLpmEpWSC/k/dJ6RQAi0xzj9nlqgM5I+1nA6KSlWy6RKHrbRv9/+e2m/6Q20UmK MhKeTtWUD1FiMsf2GPHwwUGTkqwhBo9mxWfwrAdDnNIE1q6mpbYAt72YHwW3c883Lz46 sDTy0JQ0PsII8nhKAVrd36x/e681Zq8VfWaLMJpTqwxhdbPwwEOjTrgkBUX1FJcm/jli MS1HdbY8g2zTNjmeqYoit1UPB/QL/dzPIPxuf7DGY6NXUJ5g4NeIq3B1lpJWa9cwAdJD EDtg== 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=S7KTp3yanRiTkkKxATQDnKJprztG/jjFdjjQTgrDpgk=; b=PPciMEJ8dryOX75M+hOBxOLXNK9AdLPIT0OQUKzBY96x7wEmt0qJUwngmA/gAEJMNU imkaT/mr8e3Q5960ggq7CKzAqIb0L9hmCqUlTyzGoK2+y2H9qTsxT9PnBmcAi6QrMebz cW4l+6KUPsjNvXb9CHeO/hF3TGBWmKBjfiA4FGVi3qpMX2yMkxuKHCQ4JyAyUsYqKdhn 2ixV7k4MYvE0o9xIhI/HLTpqdYqg48pRgOK6XjIBSgnsamGUXp44pMAB0W1SrrvgqMJB 1Nki8rZYS8JPBksRl7CRlX1LFEVHs+XGciFJQ2XSy1suSvLZgBqcNJnTe0Dfe80Tv+H2 jM4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kezUV9vW; 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 h4si4336079ilj.137.2021.07.19.08.12.26; Mon, 19 Jul 2021 08:12:38 -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=kezUV9vW; 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 S242704AbhGSOao (ORCPT + 99 others); Mon, 19 Jul 2021 10:30:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:38112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242810AbhGSOZW (ORCPT ); Mon, 19 Jul 2021 10:25:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 07BC06024A; Mon, 19 Jul 2021 15:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707161; bh=YQqC+kuQ824pfnGx0FiZRw+KqiQr83Qr104Ugy1swkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kezUV9vWDNNJbWiEMiIqbKgimboazCvCrS5BakZldEms6hFsNelDqZF4K8cAczrDZ fgxLo5IAaQJ4CX1v0JPX1xl5DDlxqaLbDk2ThapvUc1gExyiqC4qURHikU42D+aZC1 No37STgq9I1I1oyc6i9/Gk0gfL1fO0vm8Jr0Pe8U= 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 4.9 052/245] fs: dlm: fix memory leak when fenced Date: Mon, 19 Jul 2021 16:49:54 +0200 Message-Id: <20210719144942.083082226@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.288257948@linuxfoundation.org> References: <20210719144940.288257948@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 6def89d2209d..10d25b7830bf 100644 --- a/fs/dlm/config.c +++ b/fs/dlm/config.c @@ -80,6 +80,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) @@ -356,6 +359,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); @@ -405,6 +411,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