diff options
author | Christophe Leroy | 2022-02-23 10:01:00 +0100 |
---|---|---|
committer | Luis Chamberlain | 2022-04-05 08:43:04 -0700 |
commit | ef505058dc5524488a84423b4d5e8a7598a23a2e (patch) | |
tree | 335a6a86daae4db2d7bf305df6439fa4bf53dbb6 /kernel/module/main.c | |
parent | 32a08c17d8096f0fd2c6600bc5fe8464aaf68ea7 (diff) |
module: Rework layout alignment to avoid BUG_ON()s
Perform layout alignment verification up front and WARN_ON()
and fail module loading instead of crashing the machine.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Diffstat (limited to 'kernel/module/main.c')
-rw-r--r-- | kernel/module/main.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/kernel/module/main.c b/kernel/module/main.c index 7175b44ba88a..55e710bc7f46 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2550,6 +2550,9 @@ static int complete_formation(struct module *mod, struct load_info *info) /* This relies on module_mutex for list integrity. */ module_bug_finalize(info->hdr, info->sechdrs, mod); + if (module_check_misalignment(mod)) + goto out_misaligned; + module_enable_ro(mod, false); module_enable_nx(mod); module_enable_x(mod); @@ -2563,6 +2566,8 @@ static int complete_formation(struct module *mod, struct load_info *info) return 0; +out_misaligned: + err = -EINVAL; out: mutex_unlock(&module_mutex); return err; |