]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
module: don't annotate ROX memory as kmemleak_not_leak()
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Fri, 14 Feb 2025 08:45:31 +0000 (10:45 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 14 Feb 2025 09:32:02 +0000 (10:32 +0100)
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

index 5c127bedd3f07fa6f7d6fb5efa7233fffb0cdb91..a256cc919ad745bbfae47f0495de129f64d87147 100644 (file)
@@ -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;