Skip to content

Commit

Permalink
module: don't annotate ROX memory as kmemleak_not_leak()
Browse files Browse the repository at this point in the history
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: c287c07 ("module: switch to execmem API for remapping as RW and restoring ROX")
Fixes: 64f6a4e ("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
  • Loading branch information
Mike Rapoport (Microsoft) authored and Peter Zijlstra committed Feb 14, 2025
1 parent 63887c9 commit 6752047
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/module/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6752047

Please sign in to comment.