From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 272C43D75D7; Thu, 18 Jun 2026 18:58:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781809111; cv=none; b=aMxtF3oZmnvO7eYKGZtD1bS/hbMlRbUt5m8TFrgxwXqdKJzbLz6jHCxUjYJfVA1C8vu71BJLQiKcsLUDvjPmsOlaONl2uZCOF9hJW2mWwHMwYrfNRGxDM4BdVLGMXQsJCSqSTLxa2UivXSiBi8VkAjvF5JXqsRQPnhNAfUyVNjY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781809111; c=relaxed/simple; bh=WXCCPqxvfl6oxsasf1KzwUKCxNz5rxUrKGph8eCpvqw=; h=Date:To:From:Subject:Message-Id; b=VPH8fAkUybB5nExbrPCKucK9A485jvrGtp9Q3Z7sRO8DsIc1TNX7DKIMFIL8Z2vMliA4S2ByuXLn8ClTfEiFJEvP5IaABFR1PyfE9pGGp1zkTlFs0zinHatC3tf+VgAb74qOHyhf2VUpnjn9qDW09iFpVyQMKiUlEOY0tYiiCLQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=KG1+k6AP; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="KG1+k6AP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D0F91F000E9; Thu, 18 Jun 2026 18:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1781809109; bh=Zp5yQzbkPORtILFUCqfrNAGU7etrAWh2Cy5K5XQI6FU=; h=Date:To:From:Subject; b=KG1+k6APPrban5Duc0eiOTYuCppVjuTJyswQzbZsOzhTkkg25Kxf2UU5Q5ktfQf/n NSiGRvnYluKsDKt5EEqLnBN2I84KbtGQM6MAjV74dVZLvnuFgAAFyRr5UX81kEZgv8 KoX12u2iwu0tfvG6afx2t0qzZYx9uHvwC5v0ACdo= Date: Thu, 18 Jun 2026 11:58:29 -0700 To: mm-commits@vger.kernel.org,stable@vger.kernel.org,sj@kernel.org,akpm@linux-foundation.org From: Andrew Morton Subject: + mm-damon-sysfs-schemes-fix-dir-put-orders-in-access_pattern_add_dirs.patch added to mm-hotfixes-unstable branch Message-Id: <20260618185829.7D0F91F000E9@smtp.kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: mm/damon/sysfs-schemes: fix dir put orders in access_pattern_add_dirs() has been added to the -mm mm-hotfixes-unstable branch. Its filename is mm-damon-sysfs-schemes-fix-dir-put-orders-in-access_pattern_add_dirs.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-damon-sysfs-schemes-fix-dir-put-orders-in-access_pattern_add_dirs.patch This patch will later appear in the mm-hotfixes-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: SeongJae Park Subject: mm/damon/sysfs-schemes: fix dir put orders in access_pattern_add_dirs() Date: Wed, 17 Jun 2026 17:56:47 -0700 Patch series "mm/damon/sysfs-schemes: fix wrong directories put orders in error paths". Error paths of damon_sysfs_access_pattern_add_dirs() and damon_sysfs_scheme_add_dirs() functions put references to directories in wrong orders. As a result, uninitialized memory dereference and/or memory leak can happen. Fix those. This patch (of 2): In access_pattern_add_dirs(), error handling path puts references starting from setup failed directories. If the failure happpened from the initial allication in the setup functions, uninitialized memory dereference happen. The allocation failures will not commonly happen, but the consequence is quite bad. Fix the wrong reference put orders. The issue was discovered [1] by Sashiko. Link: https://lore.kernel.org/20260618005650.83868-2-sj@kernel.org Link: https://lore.kernel.org/20260617060005.86852-1-sj@kernel.org [1] Fixes: 7e84b1f8212a ("mm/damon/sysfs: support DAMON-based Operation Schemes") Signed-off-by: SeongJae Park Cc: # 5.18.x Signed-off-by: Andrew Morton --- mm/damon/sysfs-schemes.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) --- a/mm/damon/sysfs-schemes.c~mm-damon-sysfs-schemes-fix-dir-put-orders-in-access_pattern_add_dirs +++ a/mm/damon/sysfs-schemes.c @@ -1767,22 +1767,19 @@ static int damon_sysfs_access_pattern_ad err = damon_sysfs_access_pattern_add_range_dir(access_pattern, &access_pattern->sz, "sz"); if (err) - goto put_sz_out; + return err; err = damon_sysfs_access_pattern_add_range_dir(access_pattern, &access_pattern->nr_accesses, "nr_accesses"); if (err) - goto put_nr_accesses_sz_out; + goto put_sz_out; err = damon_sysfs_access_pattern_add_range_dir(access_pattern, &access_pattern->age, "age"); if (err) - goto put_age_nr_accesses_sz_out; + goto put_nr_accesses_sz_out; return 0; -put_age_nr_accesses_sz_out: - kobject_put(&access_pattern->age->kobj); - access_pattern->age = NULL; put_nr_accesses_sz_out: kobject_put(&access_pattern->nr_accesses->kobj); access_pattern->nr_accesses = NULL; _ Patches currently in -mm which might be from sj@kernel.org are mm-damon-sysfs-schemes-fix-dir-put-orders-in-access_pattern_add_dirs.patch mm-damon-sysfs-schemes-put-stats-for-scheme_add_dirs-internal-error.patch mm-damon-core-always-put-unsuccessfully-committed-target-pids.patch