]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
um: init cpu_tasks[] earlier
authorJohannes Berg <johannes.berg@intel.com>
Wed, 24 Sep 2025 09:32:13 +0000 (11:32 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 27 Oct 2025 14:05:50 +0000 (15:05 +0100)
This is currently done in uml_finishsetup(), but e.g. with
KCOV enabled we'll crash because some init code can call
into e.g. memparse(), which has coverage annotations, and
then the checks in check_kcov_mode() crash because current
is NULL.

Simply initialize the cpu_tasks[] array statically, which
fixes the crash. For the later SMP work, it seems to have
not really caused any problems yet, but initialize all of
the entries anyway.

Link: https://patch.msgid.link/20250924113214.c76cd74d0583.I974f691ebb1a2b47915bd2b04cc38e5263b9447f@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
arch/um/kernel/process.c
arch/um/kernel/um_arch.c

index 9c9c66dc45f054375b1c3851d8ea833f7650e7eb..13d461712c997288c8274d3b47a101f7efb20b43 100644 (file)
@@ -43,7 +43,9 @@
  * cares about its entry, so it's OK if another processor is modifying its
  * entry.
  */
-struct task_struct *cpu_tasks[NR_CPUS];
+struct task_struct *cpu_tasks[NR_CPUS] = {
+       [0 ... NR_CPUS - 1] = &init_task,
+};
 EXPORT_SYMBOL(cpu_tasks);
 
 void free_stack(unsigned long stack, int order)
index cfbbbf8500c345bcbfba6eabff24fb747773b0a5..ed2f67848a50e7d35306d6beda0fe439593e5082 100644 (file)
@@ -239,8 +239,6 @@ static struct notifier_block panic_exit_notifier = {
 
 void uml_finishsetup(void)
 {
-       cpu_tasks[0] = &init_task;
-
        atomic_notifier_chain_register(&panic_notifier_list,
                                       &panic_exit_notifier);