Re: [Patch v2] vmalloc: check CONFIG_EXECMEM in is_vmalloc_or_module_addr()

From
Mike Rapoport <rppt@kernel.org>
Date
2024-05-28 16:24:25
Also in
bpf, linux-mm
Reply to
Cong Wang, 2024-05-28
On Tue, May 28, 2024 at 09:08:38AM -0700, Cong Wang wrote:
From: Cong Wang <redacted>

After commit 2c9e5d4a0082 ("bpf: remove CONFIG_BPF_JIT dependency on CONFIG_MODULES of")
CONFIG_BPF_JIT does not depend on CONFIG_MODULES any more and bpf jit
also uses the [MODULES_VADDR, MODULES_END] memory region. But
is_vmalloc_or_module_addr() still checks CONFIG_MODULES, which then
returns false for a bpf jit memory region when CONFIG_MODULES is not
defined. It leads to the following kernel BUG:
...
Fix this by checking CONFIG_EXECMEM instead.

Fixes: 2c9e5d4a0082 ("bpf: remove CONFIG_BPF_JIT dependency on CONFIG_MODULES of")
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Mike Rapoport (IBM) <rppt@kernel.org>
Signed-off-by: Cong Wang <redacted>
Acked-by: Mike Rapoport (IBM) <rppt@kernel.org>
quoted hunk ↗ jump to hunk
---
 mm/vmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 6641be0ca80b..94e1d2dbdec0 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -722,7 +722,7 @@ int is_vmalloc_or_module_addr(const void *x)
 	 * and fall back on vmalloc() if that fails. Others
 	 * just put it in the vmalloc space.
 	 */
-#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
+#if defined(CONFIG_EXECMEM) && defined(MODULES_VADDR)
 	unsigned long addr = (unsigned long)kasan_reset_tag(x);
 	if (addr >= MODULES_VADDR && addr < MODULES_END)
 		return 1;
-- 
2.34.1
-- 
Sincerely yours,
Mike.
Thread (2 messages) 2 messages, 2 authors, last reply 2024-05-28
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help