summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/ablkcipher.c2
-rw-r--r--crypto/ahash.c3
-rw-r--r--crypto/algapi.c2
-rw-r--r--crypto/api.c6
-rw-r--r--crypto/asymmetric_keys/asymmetric_keys.h5
-rw-r--r--crypto/asymmetric_keys/asymmetric_type.c44
-rw-r--r--crypto/asymmetric_keys/public_key.c4
-rw-r--r--crypto/asymmetric_keys/signature.c2
-rw-r--r--crypto/asymmetric_keys/x509_parser.h1
-rw-r--r--crypto/asymmetric_keys/x509_public_key.c13
-rw-r--r--crypto/crypto_user.c2
11 files changed, 43 insertions, 41 deletions
diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c
index b788f169cc98..b4ffc5be1a93 100644
--- a/crypto/ablkcipher.c
+++ b/crypto/ablkcipher.c
@@ -706,7 +706,7 @@ struct crypto_ablkcipher *crypto_alloc_ablkcipher(const char *alg_name,
706err: 706err:
707 if (err != -EAGAIN) 707 if (err != -EAGAIN)
708 break; 708 break;
709 if (signal_pending(current)) { 709 if (fatal_signal_pending(current)) {
710 err = -EINTR; 710 err = -EINTR;
711 break; 711 break;
712 } 712 }
diff --git a/crypto/ahash.c b/crypto/ahash.c
index 8acb886032ae..9c1dc8d6106a 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -544,7 +544,8 @@ static int ahash_prepare_alg(struct ahash_alg *alg)
544 struct crypto_alg *base = &alg->halg.base; 544 struct crypto_alg *base = &alg->halg.base;
545 545
546 if (alg->halg.digestsize > PAGE_SIZE / 8 || 546 if (alg->halg.digestsize > PAGE_SIZE / 8 ||
547 alg->halg.statesize > PAGE_SIZE / 8) 547 alg->halg.statesize > PAGE_SIZE / 8 ||
548 alg->halg.statesize == 0)
548 return -EINVAL; 549 return -EINVAL;
549 550
550 base->cra_type = &crypto_ahash_type; 551 base->cra_type = &crypto_ahash_type;
diff --git a/crypto/algapi.c b/crypto/algapi.c
index d130b41dbaea..59bf491fe3d8 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -345,7 +345,7 @@ static void crypto_wait_for_test(struct crypto_larval *larval)
345 crypto_alg_tested(larval->alg.cra_driver_name, 0); 345 crypto_alg_tested(larval->alg.cra_driver_name, 0);
346 } 346 }
347 347
348 err = wait_for_completion_interruptible(&larval->completion); 348 err = wait_for_completion_killable(&larval->completion);
349 WARN_ON(err); 349 WARN_ON(err);
350 350
351out: 351out:
diff --git a/crypto/api.c b/crypto/api.c
index afe4610afc4b..bbc147cb5dec 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -172,7 +172,7 @@ static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg)
172 struct crypto_larval *larval = (void *)alg; 172 struct crypto_larval *larval = (void *)alg;
173 long timeout; 173 long timeout;
174 174
175 timeout = wait_for_completion_interruptible_timeout( 175 timeout = wait_for_completion_killable_timeout(
176 &larval->completion, 60 * HZ); 176 &larval->completion, 60 * HZ);
177 177
178 alg = larval->adult; 178 alg = larval->adult;
@@ -445,7 +445,7 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask)
445err: 445err:
446 if (err != -EAGAIN) 446 if (err != -EAGAIN)
447 break; 447 break;
448 if (signal_pending(current)) { 448 if (fatal_signal_pending(current)) {
449 err = -EINTR; 449 err = -EINTR;
450 break; 450 break;
451 } 451 }
@@ -562,7 +562,7 @@ void *crypto_alloc_tfm(const char *alg_name,
562err: 562err:
563 if (err != -EAGAIN) 563 if (err != -EAGAIN)
564 break; 564 break;
565 if (signal_pending(current)) { 565 if (fatal_signal_pending(current)) {
566 err = -EINTR; 566 err = -EINTR;
567 break; 567 break;
568 } 568 }
diff --git a/crypto/asymmetric_keys/asymmetric_keys.h b/crypto/asymmetric_keys/asymmetric_keys.h
index 3f5b537ab33e..1d450b580245 100644
--- a/crypto/asymmetric_keys/asymmetric_keys.h
+++ b/crypto/asymmetric_keys/asymmetric_keys.h
@@ -14,8 +14,3 @@ extern struct asymmetric_key_id *asymmetric_key_hex_to_key_id(const char *id);
14extern int __asymmetric_key_hex_to_key_id(const char *id, 14extern int __asymmetric_key_hex_to_key_id(const char *id,
15 struct asymmetric_key_id *match_id, 15 struct asymmetric_key_id *match_id,
16 size_t hexlen); 16 size_t hexlen);
17static inline
18const struct asymmetric_key_ids *asymmetric_key_ids(const struct key *key)
19{
20 return key->type_data.p[1];
21}
diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
index 1916680ad81b..9f2165b27d52 100644
--- a/crypto/asymmetric_keys/asymmetric_type.c
+++ b/crypto/asymmetric_keys/asymmetric_type.c
@@ -307,25 +307,34 @@ static int asymmetric_key_preparse(struct key_preparsed_payload *prep)
307} 307}
308 308
309/* 309/*
310 * Clean up the key ID list
311 */
312static void asymmetric_key_free_kids(struct asymmetric_key_ids *kids)
313{
314 int i;
315
316 if (kids) {
317 for (i = 0; i < ARRAY_SIZE(kids->id); i++)
318 kfree(kids->id[i]);
319 kfree(kids);
320 }
321}
322
323/*
310 * Clean up the preparse data 324 * Clean up the preparse data
311 */ 325 */
312static void asymmetric_key_free_preparse(struct key_preparsed_payload *prep) 326static void asymmetric_key_free_preparse(struct key_preparsed_payload *prep)
313{ 327{
314 struct asymmetric_key_subtype *subtype = prep->type_data[0]; 328 struct asymmetric_key_subtype *subtype = prep->payload.data[asym_subtype];
315 struct asymmetric_key_ids *kids = prep->type_data[1]; 329 struct asymmetric_key_ids *kids = prep->payload.data[asym_key_ids];
316 int i;
317 330
318 pr_devel("==>%s()\n", __func__); 331 pr_devel("==>%s()\n", __func__);
319 332
320 if (subtype) { 333 if (subtype) {
321 subtype->destroy(prep->payload[0]); 334 subtype->destroy(prep->payload.data[asym_crypto]);
322 module_put(subtype->owner); 335 module_put(subtype->owner);
323 } 336 }
324 if (kids) { 337 asymmetric_key_free_kids(kids);
325 for (i = 0; i < ARRAY_SIZE(kids->id); i++)
326 kfree(kids->id[i]);
327 kfree(kids);
328 }
329 kfree(prep->description); 338 kfree(prep->description);
330} 339}
331 340
@@ -335,20 +344,19 @@ static void asymmetric_key_free_preparse(struct key_preparsed_payload *prep)
335static void asymmetric_key_destroy(struct key *key) 344static void asymmetric_key_destroy(struct key *key)
336{ 345{
337 struct asymmetric_key_subtype *subtype = asymmetric_key_subtype(key); 346 struct asymmetric_key_subtype *subtype = asymmetric_key_subtype(key);
338 struct asymmetric_key_ids *kids = key->type_data.p[1]; 347 struct asymmetric_key_ids *kids = key->payload.data[asym_key_ids];
348 void *data = key->payload.data[asym_crypto];
349
350 key->payload.data[asym_crypto] = NULL;
351 key->payload.data[asym_subtype] = NULL;
352 key->payload.data[asym_key_ids] = NULL;
339 353
340 if (subtype) { 354 if (subtype) {
341 subtype->destroy(key->payload.data); 355 subtype->destroy(data);
342 module_put(subtype->owner); 356 module_put(subtype->owner);
343 key->type_data.p[0] = NULL;
344 } 357 }
345 358
346 if (kids) { 359 asymmetric_key_free_kids(kids);
347 kfree(kids->id[0]);
348 kfree(kids->id[1]);
349 kfree(kids);
350 key->type_data.p[1] = NULL;
351 }
352} 360}
353 361
354struct key_type key_type_asymmetric = { 362struct key_type key_type_asymmetric = {
diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
index 81efccbe22d5..6db4c01c6503 100644
--- a/crypto/asymmetric_keys/public_key.c
+++ b/crypto/asymmetric_keys/public_key.c
@@ -49,7 +49,7 @@ EXPORT_SYMBOL_GPL(pkey_id_type_name);
49static void public_key_describe(const struct key *asymmetric_key, 49static void public_key_describe(const struct key *asymmetric_key,
50 struct seq_file *m) 50 struct seq_file *m)
51{ 51{
52 struct public_key *key = asymmetric_key->payload.data; 52 struct public_key *key = asymmetric_key->payload.data[asym_crypto];
53 53
54 if (key) 54 if (key)
55 seq_printf(m, "%s.%s", 55 seq_printf(m, "%s.%s",
@@ -112,7 +112,7 @@ EXPORT_SYMBOL_GPL(public_key_verify_signature);
112static int public_key_verify_signature_2(const struct key *key, 112static int public_key_verify_signature_2(const struct key *key,
113 const struct public_key_signature *sig) 113 const struct public_key_signature *sig)
114{ 114{
115 const struct public_key *pk = key->payload.data; 115 const struct public_key *pk = key->payload.data[asym_crypto];
116 return public_key_verify_signature(pk, sig); 116 return public_key_verify_signature(pk, sig);
117} 117}
118 118
diff --git a/crypto/asymmetric_keys/signature.c b/crypto/asymmetric_keys/signature.c
index 7525fd183574..9441240f7d2a 100644
--- a/crypto/asymmetric_keys/signature.c
+++ b/crypto/asymmetric_keys/signature.c
@@ -37,7 +37,7 @@ int verify_signature(const struct key *key,
37 return -EINVAL; 37 return -EINVAL;
38 subtype = asymmetric_key_subtype(key); 38 subtype = asymmetric_key_subtype(key);
39 if (!subtype || 39 if (!subtype ||
40 !key->payload.data) 40 !key->payload.data[0])
41 return -EINVAL; 41 return -EINVAL;
42 if (!subtype->verify_signature) 42 if (!subtype->verify_signature)
43 return -ENOTSUPP; 43 return -ENOTSUPP;
diff --git a/crypto/asymmetric_keys/x509_parser.h b/crypto/asymmetric_keys/x509_parser.h
index 1de01eaec884..dbeed6018e63 100644
--- a/crypto/asymmetric_keys/x509_parser.h
+++ b/crypto/asymmetric_keys/x509_parser.h
@@ -11,6 +11,7 @@
11 11
12#include <linux/time.h> 12#include <linux/time.h>
13#include <crypto/public_key.h> 13#include <crypto/public_key.h>
14#include <keys/asymmetric-type.h>
14 15
15struct x509_certificate { 16struct x509_certificate {
16 struct x509_certificate *next; 17 struct x509_certificate *next;
diff --git a/crypto/asymmetric_keys/x509_public_key.c b/crypto/asymmetric_keys/x509_public_key.c
index 6451d1848a7d..2a44b3752471 100644
--- a/crypto/asymmetric_keys/x509_public_key.c
+++ b/crypto/asymmetric_keys/x509_public_key.c
@@ -267,7 +267,8 @@ static int x509_validate_trust(struct x509_certificate *cert,
267 if (!IS_ERR(key)) { 267 if (!IS_ERR(key)) {
268 if (!use_builtin_keys 268 if (!use_builtin_keys
269 || test_bit(KEY_FLAG_BUILTIN, &key->flags)) 269 || test_bit(KEY_FLAG_BUILTIN, &key->flags))
270 ret = x509_check_signature(key->payload.data, cert); 270 ret = x509_check_signature(key->payload.data[asym_crypto],
271 cert);
271 key_put(key); 272 key_put(key);
272 } 273 }
273 return ret; 274 return ret;
@@ -333,10 +334,6 @@ static int x509_key_preparse(struct key_preparsed_payload *prep)
333 srlen = cert->raw_serial_size; 334 srlen = cert->raw_serial_size;
334 q = cert->raw_serial; 335 q = cert->raw_serial;
335 } 336 }
336 if (srlen > 1 && *q == 0) {
337 srlen--;
338 q++;
339 }
340 337
341 ret = -ENOMEM; 338 ret = -ENOMEM;
342 desc = kmalloc(sulen + 2 + srlen * 2 + 1, GFP_KERNEL); 339 desc = kmalloc(sulen + 2 + srlen * 2 + 1, GFP_KERNEL);
@@ -357,9 +354,9 @@ static int x509_key_preparse(struct key_preparsed_payload *prep)
357 354
358 /* We're pinning the module by being linked against it */ 355 /* We're pinning the module by being linked against it */
359 __module_get(public_key_subtype.owner); 356 __module_get(public_key_subtype.owner);
360 prep->type_data[0] = &public_key_subtype; 357 prep->payload.data[asym_subtype] = &public_key_subtype;
361 prep->type_data[1] = kids; 358 prep->payload.data[asym_key_ids] = kids;
362 prep->payload[0] = cert->pub; 359 prep->payload.data[asym_crypto] = cert->pub;
363 prep->description = desc; 360 prep->description = desc;
364 prep->quotalen = 100; 361 prep->quotalen = 100;
365 362
diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
index d94d99ffe8b9..237f3795cfaa 100644
--- a/crypto/crypto_user.c
+++ b/crypto/crypto_user.c
@@ -375,7 +375,7 @@ static struct crypto_alg *crypto_user_skcipher_alg(const char *name, u32 type,
375 err = PTR_ERR(alg); 375 err = PTR_ERR(alg);
376 if (err != -EAGAIN) 376 if (err != -EAGAIN)
377 break; 377 break;
378 if (signal_pending(current)) { 378 if (fatal_signal_pending(current)) {
379 err = -EINTR; 379 err = -EINTR;
380 break; 380 break;
381 } 381 }