Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2709150pxv; Sun, 11 Jul 2021 23:25:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxL625Z6T+KdmpPOne84pWLZOts+pfgS9QEa2t6m+Ybv63A/mNjPnLKXmtNqCNdSleuyvSc X-Received: by 2002:a92:b74d:: with SMTP id c13mr8725059ilm.176.1626071120590; Sun, 11 Jul 2021 23:25:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071120; cv=none; d=google.com; s=arc-20160816; b=E4kzOD2Hww+PJ4xaHUXQvSD9DRRv/8vZUYFQ4/VaEW4SOccpECd7AWD36WSP3rRqNx 7jdJi0KlcWVhR/0OIGL/V2oENS3EV9Xbhi5L1MC86RijzWGt3cqjdbsF/m3jxY9oOrSj pKjqGSveuMniyzWt2zYFZUe5OyimnjeQD7TkD6c2YxeRAHe6z3EeMMCsTcNQGZ+JPPa9 I8bqzQhobaHVpSAjxp6qIhMcy6NYDCnHzSk+gvYAM8hz/EUiCbujNeL1r09q6BGru+Qw gsF/V3kOi+CPX1MLc/m912GGtb3zqD10wcq/1QN6PnTONX0uD04whOakzr4SXvAm46pY wx1g== 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=U/g9OMpOGoBDm7Xz/thwhvLZQEahrS21QOTqPD719qk=; b=o/bcR2IcDraIekUy2ewJj1orGYahGLASf5A8epzpZp3zDDoPgzWq8Akkp2uUktfdmb QztnhBqQRx+EwH1+9h1kW2DnlUL3R6+LGwiLTfg+mjaPfk45M/SW3JUEAz8GvrehuS1R T5tZZs/l96aDFdGwOyy/+oLbqMP1RVpEfTTJsqNovhPoqhKzwil129hKJ7rEevg5K2vs s5YNmQZ8LLa44Y/RziTAGWDtIo7oq0veHG9OKAKMD7orYHDp0U10aCnXPg4Nta/2yHUH l8T5sVRf72/WsX+bRuQX8w/9+ySAZuXtb/wObZvSoD2C87mv+XtMrA2r5dA7+bQjJiHF 30pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T5k13hmq; 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 q15si11039873ile.132.2021.07.11.23.25.09; Sun, 11 Jul 2021 23:25:20 -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=T5k13hmq; 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 S235010AbhGLG0n (ORCPT + 99 others); Mon, 12 Jul 2021 02:26:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:39694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234934AbhGLGYS (ORCPT ); Mon, 12 Jul 2021 02:24:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E08F56113A; Mon, 12 Jul 2021 06:20:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626070843; bh=GbL7MFSqlv376g2z4kHSDVV2whdrPQVE5GcGVl3q+Ik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T5k13hmqDCZaKZeEDBfU90Kjr3SqhtU7oV+8EB8MIf4D3pC6G2MbiPv4GZeP0aTHB QK+26cGVJmpbhRX57psEOtDdr2I7yloDlFewdeOJaLjQCRux32of3GYU2v3GGG6PC8 cugpo+Qe1X9qnnDC2LewqcXnuKVBdB+Mcizf97j0= 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.4 121/348] fs: dlm: fix memory leak when fenced Date: Mon, 12 Jul 2021 08:08:25 +0200 Message-Id: <20210712060717.484057616@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060659.886176320@linuxfoundation.org> References: <20210712060659.886176320@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 3b1012a3c439..b7e288cf3f5f 100644 --- a/fs/dlm/config.c +++ b/fs/dlm/config.c @@ -78,6 +78,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) @@ -354,6 +357,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); @@ -403,6 +409,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