Commit f47d2a3f authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Petr Pavlu
Browse files

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: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250108090457.512198-29-bigeasy@linutronix.de


Signed-off-by: default avatarPetr Pavlu <petr.pavlu@suse.com>
parent 3983da39
Loading
Loading
Loading
Loading
+9 −13
Original line number Diff line number Diff line
@@ -66,24 +66,20 @@ static LIST_HEAD(module_bug_list);

static struct bug_entry *module_find_bug(unsigned long bugaddr)
{
	struct bug_entry *bug;
	struct module *mod;
	struct bug_entry *bug = NULL;

	rcu_read_lock_sched();
	guard(rcu)();
	list_for_each_entry_rcu(mod, &module_bug_list, bug_list) {
		unsigned i;

		bug = mod->bug_table;
		for (i = 0; i < mod->num_bugs; ++i, ++bug)
			if (bugaddr == bug_addr(bug))
				goto out;
	}
	bug = NULL;
out:
	rcu_read_unlock_sched();

				return bug;
	}
	return NULL;
}

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

	rcu_read_lock_sched();
	scoped_guard(rcu) {
		list_for_each_entry_rcu(mod, &module_bug_list, bug_list)
			clear_once_table(mod->bug_table,
					 mod->bug_table + mod->num_bugs);
	rcu_read_unlock_sched();
	}
#endif

	clear_once_table(__start___bug_table, __stop___bug_table);