From: Hao Ge <hao.ge@linux.dev>
To: Suren Baghdasaryan <surenb@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Daniel Gomez <da.gomez@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>,
Aaron Tomlin <atomlin@atomlin.com>
Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, Hao Ge <hao.ge@linux.dev>
Subject: [RFC PATCH 0/3] alloc_tag: fix races and a leak around shutdown_mem_profiling()
Date: Thu, 13 Aug 2026 17:34:18 +0800 [thread overview]
Message-ID: <20260813093421.135230-1-hao.ge@linux.dev> (raw)
Three fixes for races and a leak in how allocation profiling meets the
module loader, reported by sashiko.
1. percpu counter leak on modules loaded after profiling is disabled.
2. layout/move TOCTOU that can silently overwrite module memory when
profiling disabled between layout_sections() and move_module().
Additionally, the retry logic here depends on [1].
3. AB-BA deadlock between module load and /proc/allocinfo readers.
Patch 1 adds CODETAG_MODULE_EXCLUDED so profiling-disabled modules are
dropped from the tag list instead of half-registered, and frees the
section reservation unconditionally on unload. Patch 2 makes
layout_sections() the sole authority for codetag placement. Patch 3
defers remove_proc_entry() to a workqueue.
Feedback and suggestions are warmly welcomed; I would greatly appreciate
any input.
Remaining sashiko-reported bugs will be fixed in follow-up patches.
[1]: https://lore.kernel.org/all/20260812054105.102637-3-hao.ge@linux.dev/
Hao Ge (3):
alloc_tag: skip percpu counter allocation when profiling is disabled
module: move codetag section placement decision to layout_sections()
alloc_tag: remove /proc/allocinfo outside of mod_lock
include/linux/codetag.h | 4 ++++
include/linux/module.h | 11 +++++++++++
kernel/module/main.c | 17 ++++++-----------
lib/codetag.c | 8 +++++---
mm/alloc_tag.c | 25 ++++++++++++++++++++++---
5 files changed, 48 insertions(+), 17 deletions(-)
--
2.25.1
next reply other threads:[~2026-08-13 9:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 9:34 Hao Ge [this message]
2026-08-13 9:34 ` [RFC PATCH 1/3] alloc_tag: skip percpu counter allocation when profiling is disabled Hao Ge
2026-08-13 9:34 ` [RFC PATCH 2/3] module: move codetag section placement decision to layout_sections() Hao Ge
2026-08-13 9:34 ` [RFC PATCH 3/3] alloc_tag: remove /proc/allocinfo outside of mod_lock Hao Ge
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260813093421.135230-1-hao.ge@linux.dev \
--to=hao.ge@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=atomlin@atomlin.com \
--cc=da.gomez@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=samitolvanen@google.com \
--cc=surenb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox