Skip to content

Commit 01d5b16

Browse files
committed
Merge tag 'modules-6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux
Pull modules updates from Petr Pavlu: - Use RCU instead of RCU-sched The mix of rcu_read_lock(), rcu_read_lock_sched() and preempt_disable() in the module code and its users has been replaced with just rcu_read_lock() - The rest of changes are smaller fixes and updates * tag 'modules-6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux: (32 commits) MAINTAINERS: Update the MODULE SUPPORT section module: Remove unnecessary size argument when calling strscpy() module: Replace deprecated strncpy() with strscpy() params: Annotate struct module_param_attrs with __counted_by() bug: Use RCU instead RCU-sched to protect module_bug_list. static_call: Use RCU in all users of __module_text_address(). kprobes: Use RCU in all users of __module_text_address(). bpf: Use RCU in all users of __module_text_address(). jump_label: Use RCU in all users of __module_text_address(). jump_label: Use RCU in all users of __module_address(). x86: Use RCU in all users of __module_address(). cfi: Use RCU while invoking __module_address(). powerpc/ftrace: Use RCU in all users of __module_text_address(). LoongArch: ftrace: Use RCU in all users of __module_text_address(). LoongArch/orc: Use RCU in all users of __module_address(). arm64: module: Use RCU in all users of __module_text_address(). ARM: module: Use RCU in all users of __module_text_address(). module: Use RCU in all users of __module_text_address(). module: Use RCU in all users of __module_address(). module: Use RCU in search_module_extables(). ...
2 parents 7405c0f + 897c0b4 commit 01d5b16

File tree

27 files changed

+160
-250
lines changed

27 files changed

+160
-250
lines changed

MAINTAINERS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16210,7 +16210,7 @@ F: include/dt-bindings/clock/mobileye,eyeq5-clk.h
1621016210

1621116211
MODULE SUPPORT
1621216212
M: Luis Chamberlain <mcgrof@kernel.org>
16213-
R: Petr Pavlu <petr.pavlu@suse.com>
16213+
M: Petr Pavlu <petr.pavlu@suse.com>
1621416214
R: Sami Tolvanen <samitolvanen@google.com>
1621516215
R: Daniel Gomez <da.gomez@samsung.com>
1621616216
L: linux-modules@vger.kernel.org
@@ -16221,8 +16221,10 @@ F: include/linux/kmod.h
1622116221
F: include/linux/module*.h
1622216222
F: kernel/module/
1622316223
F: lib/test_kmod.c
16224+
F: lib/tests/module/
1622416225
F: scripts/module*
1622516226
F: tools/testing/selftests/kmod/
16227+
F: tools/testing/selftests/module/
1622616228

1622716229
MONOLITHIC POWER SYSTEM PMIC DRIVER
1622816230
M: Saravanan Sekar <sravanhome@gmail.com>

arch/arm/kernel/module-plts.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,9 @@ bool in_module_plt(unsigned long loc)
285285
struct module *mod;
286286
bool ret;
287287

288-
preempt_disable();
288+
guard(rcu)();
289289
mod = __module_text_address(loc);
290290
ret = mod && (loc - (u32)mod->arch.core.plt_ent < mod->arch.core.plt_count * PLT_ENT_SIZE ||
291291
loc - (u32)mod->arch.init.plt_ent < mod->arch.init.plt_count * PLT_ENT_SIZE);
292-
preempt_enable();
293-
294292
return ret;
295293
}

arch/arm64/kernel/ftrace.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,13 @@ static bool ftrace_find_callable_addr(struct dyn_ftrace *rec,
320320
* dealing with an out-of-range condition, we can assume it
321321
* is due to a module being loaded far away from the kernel.
322322
*
323-
* NOTE: __module_text_address() must be called with preemption
324-
* disabled, but we can rely on ftrace_lock to ensure that 'mod'
323+
* NOTE: __module_text_address() must be called within a RCU read
324+
* section, but we can rely on ftrace_lock to ensure that 'mod'
325325
* retains its validity throughout the remainder of this code.
326326
*/
327327
if (!mod) {
328-
preempt_disable();
328+
guard(rcu)();
329329
mod = __module_text_address(pc);
330-
preempt_enable();
331330
}
332331

333332
if (WARN_ON(!mod))

arch/loongarch/kernel/ftrace_dyn.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,13 @@ static bool ftrace_find_callable_addr(struct dyn_ftrace *rec, struct module *mod
8585
* dealing with an out-of-range condition, we can assume it
8686
* is due to a module being loaded far away from the kernel.
8787
*
88-
* NOTE: __module_text_address() must be called with preemption
89-
* disabled, but we can rely on ftrace_lock to ensure that 'mod'
88+
* NOTE: __module_text_address() must be called within a RCU read
89+
* section, but we can rely on ftrace_lock to ensure that 'mod'
9090
* retains its validity throughout the remainder of this code.
9191
*/
9292
if (!mod) {
93-
preempt_disable();
94-
mod = __module_text_address(pc);
95-
preempt_enable();
93+
scoped_guard(rcu)
94+
mod = __module_text_address(pc);
9695
}
9796

9897
if (WARN_ON(!mod))

arch/loongarch/kernel/unwind_orc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ bool unwind_next_frame(struct unwind_state *state)
399399
return false;
400400

401401
/* Don't let modules unload while we're reading their ORC data. */
402-
preempt_disable();
402+
guard(rcu)();
403403

404404
if (is_entry_func(state->pc))
405405
goto end;
@@ -514,14 +514,12 @@ bool unwind_next_frame(struct unwind_state *state)
514514
if (!__kernel_text_address(state->pc))
515515
goto err;
516516

517-
preempt_enable();
518517
return true;
519518

520519
err:
521520
state->error = true;
522521

523522
end:
524-
preempt_enable();
525523
state->stack_info.type = STACK_TYPE_UNKNOWN;
526524
return false;
527525
}

arch/powerpc/kernel/trace/ftrace.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,8 @@ static unsigned long ftrace_lookup_module_stub(unsigned long ip, unsigned long a
115115
{
116116
struct module *mod = NULL;
117117

118-
preempt_disable();
119-
mod = __module_text_address(ip);
120-
preempt_enable();
121-
118+
scoped_guard(rcu)
119+
mod = __module_text_address(ip);
122120
if (!mod)
123121
pr_err("No module loaded at addr=%lx\n", ip);
124122

arch/powerpc/kernel/trace/ftrace_64_pg.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,8 @@ static struct module *ftrace_lookup_module(struct dyn_ftrace *rec)
120120
{
121121
struct module *mod;
122122

123-
preempt_disable();
124-
mod = __module_text_address(rec->ip);
125-
preempt_enable();
126-
123+
scoped_guard(rcu)
124+
mod = __module_text_address(rec->ip);
127125
if (!mod)
128126
pr_err("No module loaded at addr=%lx\n", rec->ip);
129127

arch/x86/kernel/callthunks.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,10 @@ static inline bool within_module_coretext(void *addr)
9898
#ifdef CONFIG_MODULES
9999
struct module *mod;
100100

101-
preempt_disable();
101+
guard(rcu)();
102102
mod = __module_address((unsigned long)addr);
103103
if (mod && within_module_core((unsigned long)addr, mod))
104104
ret = true;
105-
preempt_enable();
106105
#endif
107106
return ret;
108107
}

arch/x86/kernel/unwind_orc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ bool unwind_next_frame(struct unwind_state *state)
476476
return false;
477477

478478
/* Don't let modules unload while we're reading their ORC data. */
479-
preempt_disable();
479+
guard(rcu)();
480480

481481
/* End-of-stack check for user tasks: */
482482
if (state->regs && user_mode(state->regs))
@@ -669,14 +669,12 @@ bool unwind_next_frame(struct unwind_state *state)
669669
goto err;
670670
}
671671

672-
preempt_enable();
673672
return true;
674673

675674
err:
676675
state->error = true;
677676

678677
the_end:
679-
preempt_enable();
680678
state->stack_info.type = STACK_TYPE_UNKNOWN;
681679
return false;
682680
}

include/linux/kallsyms.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,11 @@ static inline void *dereference_symbol_descriptor(void *ptr)
5555
if (is_ksym_addr((unsigned long)ptr))
5656
return ptr;
5757

58-
preempt_disable();
58+
guard(rcu)();
5959
mod = __module_address((unsigned long)ptr);
6060

6161
if (mod)
6262
ptr = dereference_module_function_descriptor(mod, ptr);
63-
preempt_enable();
6463
#endif
6564
return ptr;
6665
}

0 commit comments

Comments
 (0)