* + mm-kmemleak-do-not-hex-dump-objects-once-free-tracking-has-stopped.patch added to mm-new branch
[not found] <20261203152515.2270778-3-catalin.marinas@arm.com>
@ 2026-12-03 18:40 ` Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-12-03 18:40 UTC (permalink / raw)
To: mm-commits, tongweilin, stable, leitao, david, catalin.marinas,
akpm
The patch titled
Subject: mm: kmemleak: do not hex dump objects once free tracking has stopped
has been added to the -mm mm-new branch. Its filename is
mm-kmemleak-do-not-hex-dump-objects-once-free-tracking-has-stopped.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-kmemleak-do-not-hex-dump-objects-once-free-tracking-has-stopped.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
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: Catalin Marinas <catalin.marinas@arm.com>
Subject: mm: kmemleak: do not hex dump objects once free tracking has stopped
Date: Thu, 03 Dec 2026 15:25:13 +0000
If kmemleak is disabled after reporting leaks, the metadata is kept so
that the report can still be read, but kmemleak_free_enabled is cleared.
kmemleak_free() then no longer clears OBJECT_ALLOCATED, which the report
checks under object->lock before hex dumping an object. Reading the
report can therefore hex dump memory that has been freed, or unmapped in
the case of vmalloc and percpu areas.
Skip the hex dump once kmemleak_free_enabled is cleared. The callers
hold scan_mutex, under which kmemleak_do_cleanup() clears the flag.
Link: https://patch.msgid.link/20261203152515.2270778-3-catalin.marinas@arm.com
Fixes: 74341703edca ("kmemleak: Report previously found leaks even after an error")
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Weilin Tong <tongweilin@linux.alibaba.com>
Cc: Breno Leitao <leitao@debian.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: <stable@vger.kernel.org>
mm/kmemleak.c | 7 +++++++
1 file changed, 7 insertions(+)
--- a/mm/kmemleak.c~mm-kmemleak-do-not-hex-dump-objects-once-free-tracking-has-stopped
+++ a/mm/kmemleak.c
@@ -312,6 +312,13 @@ static void hex_dump_object(struct seq_f
if (WARN_ON_ONCE(object->flags & OBJECT_PHYS))
return;
+ /*
+ * Frees are no longer tracked, so the object may have been freed or
+ * unmapped. The callers hold scan_mutex, under which the flag is cleared.
+ */
+ if (!kmemleak_free_enabled)
+ return;
+
if (object->flags & OBJECT_PERCPU)
ptr = (const u8 *)this_cpu_ptr((void __percpu *)object->pointer);
_
Patches currently in -mm which might be from catalin.marinas@arm.com are
mm-kmemleak-take-kmemleak_lock-in-the-disable-time-object-cleanup.patch
mm-kmemleak-do-not-hex-dump-objects-once-free-tracking-has-stopped.patch
mm-kmemleak-annotate-the-lockless-accesses-to-the-enable-flags.patch
^ permalink raw reply [flat|nested] only message in thread