* [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
2025-02-15 10:56 ` [tip: x86/core] " tip-bot2 for Mike Rapoport (Microsoft)
0 siblings, 2 replies; 3+ 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] 3+ 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
2025-02-15 10:56 ` [tip: x86/core] " tip-bot2 for Mike Rapoport (Microsoft)
1 sibling, 0 replies; 3+ 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] 3+ messages in thread
* [tip: x86/core] 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
@ 2025-02-15 10:56 ` tip-bot2 for Mike Rapoport (Microsoft)
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Mike Rapoport (Microsoft) @ 2025-02-15 10:56 UTC (permalink / raw)
To: linux-tip-commits
Cc: Borah, Chaitanya Kumar, Mike Rapoport (Microsoft),
Peter Zijlstra (Intel), x86, linux-kernel
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 675204778c69c2b3e0f6a4e2dbfeb4f3e89194ba
Gitweb: https://git.kernel.org/tip/675204778c69c2b3e0f6a4e2dbfeb4f3e89194ba
Author: Mike Rapoport (Microsoft) <rppt@kernel.org>
AuthorDate: Fri, 14 Feb 2025 10:45:31 +02:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 14 Feb 2025 10:32:02 +01:00
module: don't annotate ROX memory as kmemleak_not_leak()
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>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20250214084531.3299390-1-rppt@kernel.org
---
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 5c127be..a256cc9 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -1260,7 +1260,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;
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-15 10:56 UTC | newest]
Thread overview: 3+ 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
2025-02-15 10:56 ` [tip: x86/core] " tip-bot2 for Mike Rapoport (Microsoft)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox