History

module: statically initialize init section freeing data

Corentin hit the following workqueue warning when running with CRYPTO_MANAGER_EXTRA_TESTS: WARNING: CPU: 2 PID: 147 at kernel/workqueue.c:1473 __queue_work+0x3b8/0x3d0 Modules linked in: ghash_generic CPU: 2 PID: 147 Comm: modprobe Not tainted 5.6.0-rc1-next-20200214-00068-g166c9264f0b1-dirty #545 Hardware name: Pine H64 model A (DT) pc : __queue_work+0x3b8/0x3d0 Call trace: __queue_work+0x3b8/0x3d0 queue_work_on+0x6c/0x90 do_init_module+0x188/0x1f0 load_module+0x1d00/0x22b0 I wasn't able to reproduce on x86 or rpi 3b+. This is WARN_ON(!list_empty(&work->entry)) from __queue_work(), and it happens because the init_free_wq work item isn't initialized in time for a crypto test that requests the gcm module. Some crypto tests were recently moved earlier in boot as explained in commit c4741b230597 ("crypto: run initcalls for generic implementations earlier"), which went into mainline less than two weeks before the Fixes commit. Avoid the warning by statically initializing init_free_wq and the corresponding llist.

Daniel Jordan committed 6 years ago

Commit fdf09ab1 parent 14721ad1 file · +3 −10Browse files

Showing the changes to kernel/module.c (1 of 1 file). Show all

Unified · Split

kernel/module.c+3−10
@@ -91,8 +91,9 @@ EXPORT_SYMBOL_GPL(module_mutex); · 90 unmodified lines
91static LIST_HEAD(modules);91static LIST_HEAD(modules);
92 92
93/* Work queue for freeing init sections in success case */93/* Work queue for freeing init sections in success case */
94static struct work_struct init_free_wq;94static void do_free_init(struct work_struct *w);
95static struct llist_head init_free_list;95static DECLARE_WORK(init_free_wq, do_free_init);
96static LLIST_HEAD(init_free_list);
96 97
97#ifdef CONFIG_MODULES_TREE_LOOKUP98#ifdef CONFIG_MODULES_TREE_LOOKUP
98 99
@@ -3582,14 +3583,6 @@ static void do_free_init(struct work_struct *w) · 3483 unmodified lines
3582 }3583 }
3583}3584}
3584 3585
3585static int __init modules_wq_init(void)
3586{
3587 INIT_WORK(&init_free_wq, do_free_init);
3588 init_llist_head(&init_free_list);
3589 return 0;
3590}
3591module_init(modules_wq_init);
3592
3593/*3586/*
3594 * This is where the real work happens.3587 * This is where the real work happens.
3595 *3588 *