Skip to contentSkip to conversation

mm-cma_debug-fix-invalid-accesses-for-inactive-cma-areas.patch removed from -mm tree

merged mm-hotfixes-stable Andrew Morton 1 participant 1 message May 29 Stable branch

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/cma_debug: fix invalid accesses for inactive CMA areas
has been removed from the -mm tree. Its filename was
mm-cma_debug-fix-invalid-accesses-for-inactive-cma-areas.patch

This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Muchun Song <[email protected]>
Subject: mm/cma_debug: fix invalid accesses for inactive CMA areas
Date: Wed, 20 May 2026 14:10:25 +0800

cma_activate_area() can fail after allocating range bitmaps. Its cleanup path frees those bitmaps, but only clears cma->count and cma->available_count. It leaves cma->nranges and each range's count in place, so cma_debugfs_init() can still register debugfs files for an area that never activated successfully.

That exposes two problems. Reading the bitmap file can make debugfs walk a freed range bitmap and trigger an invalid memory access. Reading maxchunk can also take cma->lock even though that lock is initialized only on the successful activation path.

Fix this by creating debugfs entries only for CMA areas that reached CMA_ACTIVATED.

c009da4258f9 introduced the invalid access to bitmap file. 2e32b947606d introduced the invalid access to cma->lock. This change applies to both issues. So I added two Fixes tags.

Fixes c009da4258f9 ("mm, cma: support multiple contiguous ranges, if requested")
Fixes 2e32b947606d ("mm: cma: add functions to get region pages counters")
Cc Dmitry Safonov <[email protected]>
Cc Frank van der Linden <[email protected]>
Cc Liam R. Howlett <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Michal Nazarewicz <[email protected]>
Cc Stefan Strogin <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Vlastimil Babka <[email protected]>

---

 mm/cma_debug.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/cma_debug.c renamed from mm/cma_debug.c~mm-cma_debug-fix-invalid-accesses-for-inactive-cma-areas +2 -1
@@ -205,7 +205,8 @@ static int __init cma_debugfs_init(void)
 	cma_debugfs_root = debugfs_create_dir("cma", NULL);
 
 	for (i = 0; i < cma_area_count; i++)
-		cma_debugfs_add_one(&cma_areas[i], cma_debugfs_root);
+		if (test_bit(CMA_ACTIVATED, &cma_areas[i].flags))
+			cma_debugfs_add_one(&cma_areas[i], cma_debugfs_root);
 
 	return 0;
 }

_

Patches currently in -mm which might be from [email protected] are

mm-hugetlb_vmemmap-fix-incorrect-vmemmap-restore-in-rollback.patch mm-sparse-remove-sparse-buffer-pre-allocation-mechanism.patch mm-sparse-vmemmap-fix-vmemmap-accounting-underflow.patch mm-memory_hotplug-fix-incorrect-altmap-passing-in-error-path.patch mm-sparse-vmemmap-pass-pgmap-argument-to-memory-deactivation-paths.patch mm-sparse-vmemmap-fix-dax-vmemmap-accounting-with-optimization.patch mm-mm_init-fix-pageblock-migratetype-for-zone_device-compound-pages.patch mm-mm_init-fix-uninitialized-struct-pages-for-zone_device.patch mm-memory_hotplug-factor-out-altmap-freeing-checks.patch drivers-base-memory-make-memory-block-get-put-explicit.patch