From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27003C433F5 for ; Mon, 3 Jan 2022 09:46:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B4C56B0072; Mon, 3 Jan 2022 04:46:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 93D3D6B0073; Mon, 3 Jan 2022 04:46:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82C336B0074; Mon, 3 Jan 2022 04:46:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0003.hostedemail.com [216.40.44.3]) by kanga.kvack.org (Postfix) with ESMTP id 6F7836B0072 for ; Mon, 3 Jan 2022 04:46:13 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2133A8A3F2 for ; Mon, 3 Jan 2022 09:46:13 +0000 (UTC) X-FDA: 78988495026.24.C60779F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id DD2F012000A for ; Mon, 3 Jan 2022 09:46:05 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D279E60FDF; Mon, 3 Jan 2022 09:46:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B162AC36AE9; Mon, 3 Jan 2022 09:46:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1641203171; bh=WyDTdExxTsqLjt9MtswmMyXYXYhiT7+KODkoSqxm+HU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KeI3nF7MRTNO6zbcnE6fa6N/nLNh/cHF5lYTFb82G7491NKM4gzRMGwA9w761Fpv7 UQAwnOVxC5wqs/KOP+RKZh0epP1anYeqv1M3umiwQGmBC8Jay3BFeH7JreVsD/6mZF shQxtgL34m2NXbHHvA1QH+lzDfEFMXgfRlN6ZSsI= Date: Mon, 3 Jan 2022 10:46:08 +0100 From: Greg KH To: SeongJae Park Cc: stable@vger.kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Linus Torvalds Subject: Re: [PATCH for-v5.15.x] mm/damon/dbgfs: fix 'struct pid' leaks in 'dbgfs_target_ids_write()' Message-ID: References: <20220102112141.12281-1-sj@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220102112141.12281-1-sj@kernel.org> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: DD2F012000A X-Stat-Signature: 496jpgjggwed66wniq6zs9n3w6qrj9at Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=KeI3nF7M; spf=pass (imf29.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org X-HE-Tag: 1641203165-755528 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, Jan 02, 2022 at 11:21:41AM +0000, SeongJae Park wrote: > commit ebb3f994dd92f8fb4d70c7541091216c1e10cb71 upstream. > > DAMON debugfs interface increases the reference counts of 'struct pid's > for targets from the 'target_ids' file write callback > ('dbgfs_target_ids_write()'), but decreases the counts only in DAMON > monitoring termination callback ('dbgfs_before_terminate()'). > > Therefore, when 'target_ids' file is repeatedly written without DAMON > monitoring start/termination, the reference count is not decreased and > therefore memory for the 'struct pid' cannot be freed. This commit > fixes this issue by decreasing the reference counts when 'target_ids' is > written. > > Link: https://lkml.kernel.org/r/20211229124029.23348-1-sj@kernel.org > Fixes: 4bc05954d007 ("mm/damon: implement a debugfs-based user space interface") > Signed-off-by: SeongJae Park > Cc: # 5.15.x > Signed-off-by: Andrew Morton > Signed-off-by: Linus Torvalds > --- > This is a backport of a DAMON fix that merged in the mainline, for > v5.15.x stable series. Now queued up, thanks. greg k-h