linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] module: don't annotate ROX memory as kmemleak_not_leak()
@ 2025-02-14  8:45 Mike Rapoport
  2025-02-14  9:19 ` Peter Zijlstra
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Rapoport @ 2025-02-14  8:45 UTC (permalink / raw)
  To: Luis Chamberlain, Peter Zijlstra
  Cc: Borah, Chaitanya Kumar, Daniel Gomez, Mike Rapoport, Petr Pavlu,
	Sami Tolvanen, linux-kernel, linux-modules, x86

From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>

The ROX memory allocations are part of a larger vmalloc allocation and
annotating them with kmemleak_not_leak() confuses kmemleak.

Skip kmemleak_not_leak() annotations for the ROX areas.

Fixes: c287c0723329 ("module: switch to execmem API for remapping as RW and restoring ROX")
Fixes: 64f6a4e10c05 ("x86: re-enable EXECMEM_ROX support")
Reported-by: "Borah, Chaitanya Kumar" <chaitanya.kumar.borah@intel.com>
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---

Peter, can you take it via tip tree?
Or you prefer for Luis to pick this up?

 kernel/module/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/module/main.c b/kernel/module/main.c
index 974821d6e85a..3dbe23098433 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -1250,7 +1250,8 @@ static int module_memory_alloc(struct module *mod, enum mod_mem_type type)
 	 * *do* eventually get freed, but let's just keep things simple
 	 * and avoid *any* false positives.
 	 */
-	kmemleak_not_leak(ptr);
+	if (!mod->mem[type].is_rox)
+		kmemleak_not_leak(ptr);
 
 	memset(ptr, 0, size);
 	mod->mem[type].base = ptr;
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] module: don't annotate ROX memory as kmemleak_not_leak()
  2025-02-14  8:45 [PATCH] module: don't annotate ROX memory as kmemleak_not_leak() Mike Rapoport
@ 2025-02-14  9:19 ` Peter Zijlstra
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2025-02-14  9:19 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: Luis Chamberlain, Borah, Chaitanya Kumar, Daniel Gomez,
	Petr Pavlu, Sami Tolvanen, linux-kernel, linux-modules, x86

On Fri, Feb 14, 2025 at 10:45:31AM +0200, Mike Rapoport wrote:
> From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
> 
> The ROX memory allocations are part of a larger vmalloc allocation and
> annotating them with kmemleak_not_leak() confuses kmemleak.
> 
> Skip kmemleak_not_leak() annotations for the ROX areas.
> 
> Fixes: c287c0723329 ("module: switch to execmem API for remapping as RW and restoring ROX")
> Fixes: 64f6a4e10c05 ("x86: re-enable EXECMEM_ROX support")
> Reported-by: "Borah, Chaitanya Kumar" <chaitanya.kumar.borah@intel.com>
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---
> 
> Peter, can you take it via tip tree?
> Or you prefer for Luis to pick this up?

Less of a head-ache overall if these things stay together I recon.
So I'll stick it in tip/x86/mm along with the rest of those patches.

Thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-14  9:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-14  8:45 [PATCH] module: don't annotate ROX memory as kmemleak_not_leak() Mike Rapoport
2025-02-14  9:19 ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).