History

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.

Ben Hutchings committed 10 years ago

Commit bca014c1 parent 3205c361 file · +9 −4Browse files

Unified · Split

kernel/module.c+9−4
@@ -2686,13 +2686,18 @@ static inline void kmemleak_load_module(const struct module *mod, · 2685 unmodified lines
26862686 #endif
26872687
26882688 #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)
26902690 {
26912691 int err = -ENOKEY;
26922692 const unsigned long markerlen = sizeof(MODULE_SIG_STRING) - 1;
26932693 const void *mod = info->hdr;
26942694
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 &&
26962701 memcmp(mod + info->len - markerlen, MODULE_SIG_STRING, markerlen) == 0) {
26972702 /* We truncate the module to discard the signature */
26982703 info->len -= markerlen;
@@ -2711,7 +2716,7 @@ static int module_sig_check(struct load_info *info) · 12 unmodified lines
27112716 return err;
27122717 }
27132718 #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)
27152720 {
27162721 return 0;
27172722 }
@@ -3506,7 +3511,7 @@ static int load_module(struct load_info *info, const char __user *uargs, · 788 unmodified lines
35063511 long err;
35073512 char *after_dashes;
35083513
3509− err = module_sig_check(info);
3514+ err = module_sig_check(info, flags);
35103515 if (err)
35113516 goto free_copy;
35123517

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t