From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta0.migadu.com (out-249.mta0.migadu.com [91.218.175.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C86AB2F39C2 for ; Thu, 13 Aug 2026 09:33:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.249 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786613642; cv=none; b=sGJjxjj1v0LIMOkBeotHkGkxfLTgNGC38XfBorToYC326k09yACOm9ndQ+PJEduwfDTbN6Qurnagj3gTkuxfYkq9SbF9l/34TkuEpX3aHhs3KeEkVfXNEQOC2ulb8J0Xf3B+mKnkiO10RmiAY7BwomYe+lbxdu0eZgYim8KXsMA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786613642; c=relaxed/simple; bh=jNvhERYY3D7nKb/kjhXp0MERCjoO21xs9MSBXRaSNT4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=IivYkQ68blgqYLuSEdpmThb6kgo3jMOFOYmdx/oMp4EViqi/l8AKYQ9HI+Xotntgx6TrqohQEo4x4Lp4eeGmGZGsk+LzIgiqyyVvhIWvRt95rTRHcS8FmTN0eEPB3Zr66TySy6xLmq1Q25OflkKFBj7a73ZXfSAwmyDCHmXIVb8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=IQBImNWf; arc=none smtp.client-ip=91.218.175.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="IQBImNWf" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=jNvhERYY3D7nKb/kjhXp0MERCjoO21xs9MSBXRaSNT4=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1786613637; v=1; x=1787218437; b=IQBImNWfFr6ozuuVC2ZVgZzs39gEF6LO5Pa1yKmx0U5xflvPbRiUUhbHwRxvc5M6xpbBgztM 5wUNWYEBqtHQofMPfJWx7PheiAtro/za6ktpgOlfYajbEDIABM9xzQURdCdPZG8gVBUhfwDiILq ad7r9XQXZZBDSkxiZROm2B/E= X-Envelope-To: linux-kernel@vger.kernel.org Received: from localhost.localdomain (116.128.244.169) by smtp.migadu.com with ESMTPS id a0f3be38e7db4446; Thu, 13 Aug 2026 09:33:57 +0000 X-Migadu-Flow: FLOW_OUT From: Hao Ge To: Suren Baghdasaryan , Andrew Morton , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Hao Ge 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 Message-Id: <20260813093421.135230-1-hao.ge@linux.dev> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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