Skip to content

Commit f47d2a3

Browse files
Sebastian Andrzej Siewiorpetrpavlu
authored andcommitted
bug: Use RCU instead RCU-sched to protect module_bug_list.
The list module_bug_list relies on module_mutex for writer synchronisation. The list is already RCU style. The list removal is synchronized with modules' synchronize_rcu() in free_module(). Use RCU read lock protection instead of RCU-sched. Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20250108090457.512198-29-bigeasy@linutronix.de Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
1 parent 3983da3 commit f47d2a3

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

lib/bug.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,19 @@ static LIST_HEAD(module_bug_list);
6666

6767
static struct bug_entry *module_find_bug(unsigned long bugaddr)
6868
{
69+
struct bug_entry *bug;
6970
struct module *mod;
70-
struct bug_entry *bug = NULL;
7171

72-
rcu_read_lock_sched();
72+
guard(rcu)();
7373
list_for_each_entry_rcu(mod, &module_bug_list, bug_list) {
7474
unsigned i;
7575

7676
bug = mod->bug_table;
7777
for (i = 0; i < mod->num_bugs; ++i, ++bug)
7878
if (bugaddr == bug_addr(bug))
79-
goto out;
79+
return bug;
8080
}
81-
bug = NULL;
82-
out:
83-
rcu_read_unlock_sched();
84-
85-
return bug;
81+
return NULL;
8682
}
8783

8884
void module_bug_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
@@ -235,11 +231,11 @@ void generic_bug_clear_once(void)
235231
#ifdef CONFIG_MODULES
236232
struct module *mod;
237233

238-
rcu_read_lock_sched();
239-
list_for_each_entry_rcu(mod, &module_bug_list, bug_list)
240-
clear_once_table(mod->bug_table,
241-
mod->bug_table + mod->num_bugs);
242-
rcu_read_unlock_sched();
234+
scoped_guard(rcu) {
235+
list_for_each_entry_rcu(mod, &module_bug_list, bug_list)
236+
clear_once_table(mod->bug_table,
237+
mod->bug_table + mod->num_bugs);
238+
}
243239
#endif
244240

245241
clear_once_table(__start___bug_table, __stop___bug_table);

0 commit comments

Comments
 (0)