diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2016-04-27 19:54:01 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2016-07-26 23:08:00 -0400 |
commit | bca014caaa6130e57f69b5bf527967aa8ee70fdd (patch) | |
tree | a9f4b7fc841def5ac3dd4c872084fa7bef7a38c0 /kernel/module.c | |
parent | 3205c36cf7d96024626f92d65f560035df1abcb2 (diff) |
module: Invalidate signatures on force-loaded modules
Signing a module should only make it trusted by the specific kernel it
was built for, not anything else. Loading a signed module meant for a
kernel with a different ABI could have interesting effects.
Therefore, treat all signatures as invalid when a module is
force-loaded.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: stable@vger.kernel.org
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/kernel/module.c b/kernel/module.c index 0b4f3a85d4fc..7f21ab238aa7 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -2686,13 +2686,18 @@ static inline void kmemleak_load_module(const struct module *mod, | |||
2686 | #endif | 2686 | #endif |
2687 | 2687 | ||
2688 | #ifdef CONFIG_MODULE_SIG | 2688 | #ifdef CONFIG_MODULE_SIG |
2689 | static int module_sig_check(struct load_info *info) | 2689 | static int module_sig_check(struct load_info *info, int flags) |
2690 | { | 2690 | { |
2691 | int err = -ENOKEY; | 2691 | int err = -ENOKEY; |
2692 | const unsigned long markerlen = sizeof(MODULE_SIG_STRING) - 1; | 2692 | const unsigned long markerlen = sizeof(MODULE_SIG_STRING) - 1; |
2693 | const void *mod = info->hdr; | 2693 | const void *mod = info->hdr; |
2694 | 2694 | ||
2695 | if (info->len > markerlen && | 2695 | /* |
2696 | * Require flags == 0, as a module with version information | ||
2697 | * removed is no longer the module that was signed | ||
2698 | */ | ||
2699 | if (flags == 0 && | ||
2700 | info->len > markerlen && | ||
2696 | memcmp(mod + info->len - markerlen, MODULE_SIG_STRING, markerlen) == 0) { | 2701 | memcmp(mod + info->len - markerlen, MODULE_SIG_STRING, markerlen) == 0) { |
2697 | /* We truncate the module to discard the signature */ | 2702 | /* We truncate the module to discard the signature */ |
2698 | info->len -= markerlen; | 2703 | info->len -= markerlen; |
@@ -2711,7 +2716,7 @@ static int module_sig_check(struct load_info *info) | |||
2711 | return err; | 2716 | return err; |
2712 | } | 2717 | } |
2713 | #else /* !CONFIG_MODULE_SIG */ | 2718 | #else /* !CONFIG_MODULE_SIG */ |
2714 | static int module_sig_check(struct load_info *info) | 2719 | static int module_sig_check(struct load_info *info, int flags) |
2715 | { | 2720 | { |
2716 | return 0; | 2721 | return 0; |
2717 | } | 2722 | } |
@@ -3506,7 +3511,7 @@ static int load_module(struct load_info *info, const char __user *uargs, | |||
3506 | long err; | 3511 | long err; |
3507 | char *after_dashes; | 3512 | char *after_dashes; |
3508 | 3513 | ||
3509 | err = module_sig_check(info); | 3514 | err = module_sig_check(info, flags); |
3510 | if (err) | 3515 | if (err) |
3511 | goto free_copy; | 3516 | goto free_copy; |
3512 | 3517 | ||