From: Josh Poimboeuf Date: Wed, 29 Apr 2020 15:24:43 +0000 (-0500) Subject: livepatch: Disallow vmlinux.ko X-Git-Tag: v5.8-rc1~149^2~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dcf550e52f567cb7a421169d2522869f9188aca5;p=thirdparty%2Flinux.git livepatch: Disallow vmlinux.ko This is purely a theoretical issue, but if there were a module named vmlinux.ko, the livepatch relocation code wouldn't be able to distinguish between vmlinux-specific and vmlinux.o-specific KLP relocations. If CONFIG_LIVEPATCH is enabled, don't allow a module named vmlinux.ko. Suggested-by: Peter Zijlstra Signed-off-by: Josh Poimboeuf Acked-by: Miroslav Benes Acked-by: Joe Lawrence Signed-off-by: Jiri Kosina --- diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index c3512e7e08012..40cfac8156fd3 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -1139,6 +1139,11 @@ int klp_module_coming(struct module *mod) if (WARN_ON(mod->state != MODULE_STATE_COMING)) return -EINVAL; + if (!strcmp(mod->name, "vmlinux")) { + pr_err("vmlinux.ko: invalid module name"); + return -EINVAL; + } + mutex_lock(&klp_mutex); /* * Each module has to know that klp_module_coming()