Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1287494 > unrolled thread
| Started by | Xie XiuQi <xiexiuqi@huawei.com> |
|---|---|
| First post | 2015-12-09 14:40 +0100 |
| Last post | 2015-12-10 06:00 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] module: check vermagic match exactly when load modules Xie XiuQi <xiexiuqi@huawei.com> - 2015-12-09 14:40 +0100
Re: [PATCH] module: check vermagic match exactly when load modules Rusty Russell <rusty@rustcorp.com.au> - 2015-12-10 06:00 +0100
| From | Xie XiuQi <xiexiuqi@huawei.com> |
|---|---|
| Date | 2015-12-09 14:40 +0100 |
| Subject | [PATCH] module: check vermagic match exactly when load modules |
| Message-ID | <qDN8l-xe-5@gated-at.bofh.it> |
Usually, checking kernel version will be ignore when loading
modules if CONFIG_MODVERSIONS option is enable. This could
potentially lead to a mismatch with the running kernel.
With this option, we prevent to load the modules which vermagic
is not match exactly with the running kernel.
It could be set to N by default.
Signed-off-by: Xie XiuQi <xiexiuqi@huawei.com>
---
init/Kconfig | 11 +++++++++++
kernel/module.c | 2 ++
2 files changed, 13 insertions(+)
diff --git a/init/Kconfig b/init/Kconfig
index c24b6f7..ce9c23e 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1889,6 +1889,17 @@ config MODVERSIONS
make them incompatible with the kernel you are running. If
unsure, say N.
+config MODULE_VERMAGIC_FORCE
+ bool "Require vermagic match exactly"
+ default n
+ depends on MODVERSIONS
+ help
+ Usually, checking kernel version will be ignore when loading
+ modules if CONFIG_MODVERSIONS option is enable. This could
+ potentially lead to a mismatch with the running kernel.
+ With this option, we prevent to load the modules which vermagic
+ is not match exactly with the running kernel. If unsure, say N.
+
config MODULE_SRCVERSION_ALL
bool "Source checksum for all modules"
help
diff --git a/kernel/module.c b/kernel/module.c
index 8f051a1..cf350d5 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1350,10 +1350,12 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,
static inline int same_magic(const char *amagic, const char *bmagic,
bool has_crcs)
{
+#ifndef CONFIG_MODULE_VERMAGIC_FORCE
if (has_crcs) {
amagic += strcspn(amagic, " ");
bmagic += strcspn(bmagic, " ");
}
+#endif
return strcmp(amagic, bmagic) == 0;
}
#else
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Rusty Russell <rusty@rustcorp.com.au> |
|---|---|
| Date | 2015-12-10 06:00 +0100 |
| Message-ID | <qE1uF-1j4-11@gated-at.bofh.it> |
| In reply to | #1287494 |
Xie XiuQi <xiexiuqi@huawei.com> writes:
> Usually, checking kernel version will be ignore when loading
> modules if CONFIG_MODVERSIONS option is enable. This could
> potentially lead to a mismatch with the running kernel.
>
> With this option, we prevent to load the modules which vermagic
> is not match exactly with the running kernel.
>
> It could be set to N by default.
Hi Xie!
I don't understand this patch. The purpose of
CONFIG_MODVERSIONS is so that you can combine modules from different
kernel versions. If you don't want to do that, I suggest not setting
CONFIG_MODVERSIONS.
Cheers,
Rusty.
>
> Signed-off-by: Xie XiuQi <xiexiuqi@huawei.com>
> ---
> init/Kconfig | 11 +++++++++++
> kernel/module.c | 2 ++
> 2 files changed, 13 insertions(+)
>
> diff --git a/init/Kconfig b/init/Kconfig
> index c24b6f7..ce9c23e 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -1889,6 +1889,17 @@ config MODVERSIONS
> make them incompatible with the kernel you are running. If
> unsure, say N.
>
> +config MODULE_VERMAGIC_FORCE
> + bool "Require vermagic match exactly"
> + default n
> + depends on MODVERSIONS
> + help
> + Usually, checking kernel version will be ignore when loading
> + modules if CONFIG_MODVERSIONS option is enable. This could
> + potentially lead to a mismatch with the running kernel.
> + With this option, we prevent to load the modules which vermagic
> + is not match exactly with the running kernel. If unsure, say N.
> +
> config MODULE_SRCVERSION_ALL
> bool "Source checksum for all modules"
> help
> diff --git a/kernel/module.c b/kernel/module.c
> index 8f051a1..cf350d5 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -1350,10 +1350,12 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,
> static inline int same_magic(const char *amagic, const char *bmagic,
> bool has_crcs)
> {
> +#ifndef CONFIG_MODULE_VERMAGIC_FORCE
> if (has_crcs) {
> amagic += strcspn(amagic, " ");
> bmagic += strcspn(bmagic, " ");
> }
> +#endif
> return strcmp(amagic, bmagic) == 0;
> }
> #else
> --
> 1.8.3.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web