> On 11 Apr 2024, at 19:05, Mike Rapoport <r...@kernel.org> wrote: > > @@ -2440,7 +2479,24 @@ static int post_relocation(struct module *mod, const > struct load_info *info) > add_kallsyms(mod, info); > > /* Arch-specific module finalizing. */ > - return module_finalize(info->hdr, info->sechdrs, mod); > + ret = module_finalize(info->hdr, info->sechdrs, mod); > + if (ret) > + return ret; > + > + for_each_mod_mem_type(type) { > + struct module_memory *mem = &mod->mem[type]; > + > + if (mem->is_rox) { > + if (!execmem_update_copy(mem->base, mem->rw_copy, > + mem->size)) > + return -ENOMEM; > + > + vfree(mem->rw_copy); > + mem->rw_copy = NULL; > + } > + } > + > + return 0; > } I might be missing something, but it seems a bit racy. IIUC, module_finalize() calls alternatives_smp_module_add(). At this point, since you don’t hold the text_mutex, some might do text_poke(), e.g., by enabling/disabling static-key, and the update would be overwritten. No?
- [RFC PATCH 0/7] x86/module: use large ROX pages for text ... Mike Rapoport
- [RFC PATCH 1/7] asm-generic: introduce text-patching... Mike Rapoport
- [RFC PATCH 2/7] mm: vmalloc: don't account for numbe... Mike Rapoport
- Re: [RFC PATCH 2/7] mm: vmalloc: don't account f... Christophe Leroy
- Re: [RFC PATCH 2/7] mm: vmalloc: don't accou... Mike Rapoport
- [RFC PATCH 3/7] module: prepare to handle ROX alloca... Mike Rapoport
- Re: [RFC PATCH 3/7] module: prepare to handle RO... Nadav Amit
- Re: [RFC PATCH 3/7] module: prepare to handl... Mike Rapoport
- Re: [RFC PATCH 3/7] module: [ Nadav Amit
- Re: [RFC PATCH 3/7] module: [ Mike Rapoport
- [RFC PATCH 4/7] ftrace: Add swap_func to ftrace_proc... Mike Rapoport
- [RFC PATCH 5/7] x86/module: perpare module loading f... Mike Rapoport
- Re: [RFC PATCH 5/7] x86/module: perpare module l... Ingo Molnar
- Re: [RFC PATCH 5/7] x86/module: perpare modu... Mike Rapoport
- Re: [RFC PATCH 5/7] x86/module: perpare module l... Peter Zijlstra
- Re: [RFC PATCH 5/7] x86/module: perpare modu... Mike Rapoport
- [RFC PATCH 6/7] execmem: add support for cache of la... Mike Rapoport