diff options
-rw-r--r-- | include/linux/integrity.h | 13 | ||||
-rw-r--r-- | security/integrity/digsig_asymmetric.c | 23 | ||||
-rw-r--r-- | security/security.c | 7 |
3 files changed, 42 insertions, 1 deletions
diff --git a/include/linux/integrity.h b/include/linux/integrity.h index 858d3f4a2241..54c853ec2fd1 100644 --- a/include/linux/integrity.h +++ b/include/linux/integrity.h | |||
@@ -44,4 +44,17 @@ static inline void integrity_load_keys(void) | |||
44 | } | 44 | } |
45 | #endif /* CONFIG_INTEGRITY */ | 45 | #endif /* CONFIG_INTEGRITY */ |
46 | 46 | ||
47 | #ifdef CONFIG_INTEGRITY_ASYMMETRIC_KEYS | ||
48 | |||
49 | extern int integrity_kernel_module_request(char *kmod_name); | ||
50 | |||
51 | #else | ||
52 | |||
53 | static inline int integrity_kernel_module_request(char *kmod_name) | ||
54 | { | ||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | #endif /* CONFIG_INTEGRITY_ASYMMETRIC_KEYS */ | ||
59 | |||
47 | #endif /* _LINUX_INTEGRITY_H */ | 60 | #endif /* _LINUX_INTEGRITY_H */ |
diff --git a/security/integrity/digsig_asymmetric.c b/security/integrity/digsig_asymmetric.c index ab6a029062a1..6dc075144508 100644 --- a/security/integrity/digsig_asymmetric.c +++ b/security/integrity/digsig_asymmetric.c | |||
@@ -115,3 +115,26 @@ int asymmetric_verify(struct key *keyring, const char *sig, | |||
115 | pr_debug("%s() = %d\n", __func__, ret); | 115 | pr_debug("%s() = %d\n", __func__, ret); |
116 | return ret; | 116 | return ret; |
117 | } | 117 | } |
118 | |||
119 | /** | ||
120 | * integrity_kernel_module_request - prevent crypto-pkcs1pad(rsa,*) requests | ||
121 | * @kmod_name: kernel module name | ||
122 | * | ||
123 | * We have situation, when public_key_verify_signature() in case of RSA | ||
124 | * algorithm use alg_name to store internal information in order to | ||
125 | * construct an algorithm on the fly, but crypto_larval_lookup() will try | ||
126 | * to use alg_name in order to load kernel module with same name. | ||
127 | * Since we don't have any real "crypto-pkcs1pad(rsa,*)" kernel modules, | ||
128 | * we are safe to fail such module request from crypto_larval_lookup(). | ||
129 | * | ||
130 | * In this way we prevent modprobe execution during digsig verification | ||
131 | * and avoid possible deadlock if modprobe and/or it's dependencies | ||
132 | * also signed with digsig. | ||
133 | */ | ||
134 | int integrity_kernel_module_request(char *kmod_name) | ||
135 | { | ||
136 | if (strncmp(kmod_name, "crypto-pkcs1pad(rsa,", 20) == 0) | ||
137 | return -EINVAL; | ||
138 | |||
139 | return 0; | ||
140 | } | ||
diff --git a/security/security.c b/security/security.c index b49ee810371b..dbca03d3629b 100644 --- a/security/security.c +++ b/security/security.c | |||
@@ -1032,7 +1032,12 @@ int security_kernel_create_files_as(struct cred *new, struct inode *inode) | |||
1032 | 1032 | ||
1033 | int security_kernel_module_request(char *kmod_name) | 1033 | int security_kernel_module_request(char *kmod_name) |
1034 | { | 1034 | { |
1035 | return call_int_hook(kernel_module_request, 0, kmod_name); | 1035 | int ret; |
1036 | |||
1037 | ret = call_int_hook(kernel_module_request, 0, kmod_name); | ||
1038 | if (ret) | ||
1039 | return ret; | ||
1040 | return integrity_kernel_module_request(kmod_name); | ||
1036 | } | 1041 | } |
1037 | 1042 | ||
1038 | int security_kernel_read_file(struct file *file, enum kernel_read_file_id id) | 1043 | int security_kernel_read_file(struct file *file, enum kernel_read_file_id id) |