Skip to content

Commit 2b71482

Browse files
committed
Merge tag 'modules-for-v5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux
Pull modules updates from Jessica Yu: "Code cleanups: more informative error messages and statically initialize init_free_wq to avoid a workqueue warning" * tag 'modules-for-v5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux: module: statically initialize init section freeing data module: Add more error message for failed kernel module loading
2 parents fc996db + fdf09ab commit 2b71482

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

‎kernel/module.c‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ EXPORT_SYMBOL_GPL(module_mutex);
9292
static LIST_HEAD(modules);
9393

9494
/* Work queue for freeing init sections in success case */
95-
static struct work_struct init_free_wq;
96-
static struct llist_head init_free_list;
95+
static void do_free_init(struct work_struct *w);
96+
static DECLARE_WORK(init_free_wq, do_free_init);
97+
static LLIST_HEAD(init_free_list);
9798

9899
#ifdef CONFIG_MODULES_TREE_LOOKUP
99100

@@ -2097,8 +2098,11 @@ static int module_enforce_rwx_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
20972098
int i;
20982099

20992100
for (i = 0; i < hdr->e_shnum; i++) {
2100-
if ((sechdrs[i].sh_flags & shf_wx) == shf_wx)
2101+
if ((sechdrs[i].sh_flags & shf_wx) == shf_wx) {
2102+
pr_err("%s: section %s (index %d) has invalid WRITE|EXEC flags\n",
2103+
mod->name, secstrings + sechdrs[i].sh_name, i);
21012104
return -ENOEXEC;
2105+
}
21022106
}
21032107

21042108
return 0;
@@ -3591,14 +3595,6 @@ static void do_free_init(struct work_struct *w)
35913595
}
35923596
}
35933597

3594-
static int __init modules_wq_init(void)
3595-
{
3596-
INIT_WORK(&init_free_wq, do_free_init);
3597-
init_llist_head(&init_free_list);
3598-
return 0;
3599-
}
3600-
module_init(modules_wq_init);
3601-
36023598
/*
36033599
* This is where the real work happens.
36043600
*
@@ -3841,15 +3837,18 @@ static int load_module(struct load_info *info, const char __user *uargs,
38413837
char *after_dashes;
38423838

38433839
err = elf_header_check(info);
3844-
if (err)
3840+
if (err) {
3841+
pr_err("Module has invalid ELF header\n");
38453842
goto free_copy;
3843+
}
38463844

38473845
err = setup_load_info(info, flags);
38483846
if (err)
38493847
goto free_copy;
38503848

38513849
if (blacklisted(info->name)) {
38523850
err = -EPERM;
3851+
pr_err("Module %s is blacklisted\n", info->name);
38533852
goto free_copy;
38543853
}
38553854

0 commit comments

Comments
 (0)