@@ -139,9 +139,9 @@ static noinstr void clean_dcache_range_nopatch(u64 start, u64 end)
139139 } while (cur += d_size , cur < end );
140140}
141141
142- static void __apply_alternatives (const struct alt_region * region ,
143- bool is_module ,
144- unsigned long * cpucap_mask )
142+ static int __apply_alternatives (const struct alt_region * region ,
143+ bool is_module ,
144+ unsigned long * cpucap_mask )
145145{
146146 struct alt_instr * alt ;
147147 __le32 * origptr , * updptr ;
@@ -166,10 +166,13 @@ static void __apply_alternatives(const struct alt_region *region,
166166 updptr = is_module ? origptr : lm_alias (origptr );
167167 nr_inst = alt -> orig_len / AARCH64_INSN_SIZE ;
168168
169- if (ALT_HAS_CB (alt ))
169+ if (ALT_HAS_CB (alt )) {
170170 alt_cb = ALT_REPL_PTR (alt );
171- else
171+ if (is_module && !core_kernel_text ((unsigned long )alt_cb ))
172+ return - ENOEXEC ;
173+ } else {
172174 alt_cb = patch_alternative ;
175+ }
173176
174177 alt_cb (alt , origptr , updptr , nr_inst );
175178
@@ -193,6 +196,8 @@ static void __apply_alternatives(const struct alt_region *region,
193196 bitmap_and (applied_alternatives , applied_alternatives ,
194197 system_cpucaps , ARM64_NCAPS );
195198 }
199+
200+ return 0 ;
196201}
197202
198203static void __init apply_alternatives_vdso (void )
@@ -277,7 +282,7 @@ void __init apply_boot_alternatives(void)
277282}
278283
279284#ifdef CONFIG_MODULES
280- void apply_alternatives_module (void * start , size_t length )
285+ int apply_alternatives_module (void * start , size_t length )
281286{
282287 struct alt_region region = {
283288 .begin = start ,
@@ -287,7 +292,7 @@ void apply_alternatives_module(void *start, size_t length)
287292
288293 bitmap_fill (all_capabilities , ARM64_NCAPS );
289294
290- __apply_alternatives (& region , true, & all_capabilities [0 ]);
295+ return __apply_alternatives (& region , true, & all_capabilities [0 ]);
291296}
292297#endif
293298
0 commit comments