diff options
-rw-r--r-- | crypto/ablkcipher.c | 4 | ||||
-rw-r--r-- | crypto/aead.c | 4 | ||||
-rw-r--r-- | crypto/crypto_user.c | 80 | ||||
-rw-r--r-- | crypto/pcrypt.c | 8 | ||||
-rw-r--r-- | include/crypto/internal/aead.h | 2 | ||||
-rw-r--r-- | include/crypto/internal/skcipher.h | 2 | ||||
-rw-r--r-- | include/linux/cryptouser.h | 3 | ||||
-rw-r--r-- | kernel/padata.c | 13 |
8 files changed, 103 insertions, 13 deletions
diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c index a0f768c1d9aa..8d3a056ebeea 100644 --- a/crypto/ablkcipher.c +++ b/crypto/ablkcipher.c | |||
@@ -613,8 +613,7 @@ out: | |||
613 | return err; | 613 | return err; |
614 | } | 614 | } |
615 | 615 | ||
616 | static struct crypto_alg *crypto_lookup_skcipher(const char *name, u32 type, | 616 | struct crypto_alg *crypto_lookup_skcipher(const char *name, u32 type, u32 mask) |
617 | u32 mask) | ||
618 | { | 617 | { |
619 | struct crypto_alg *alg; | 618 | struct crypto_alg *alg; |
620 | 619 | ||
@@ -652,6 +651,7 @@ static struct crypto_alg *crypto_lookup_skcipher(const char *name, u32 type, | |||
652 | 651 | ||
653 | return ERR_PTR(crypto_givcipher_default(alg, type, mask)); | 652 | return ERR_PTR(crypto_givcipher_default(alg, type, mask)); |
654 | } | 653 | } |
654 | EXPORT_SYMBOL_GPL(crypto_lookup_skcipher); | ||
655 | 655 | ||
656 | int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name, | 656 | int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name, |
657 | u32 type, u32 mask) | 657 | u32 type, u32 mask) |
diff --git a/crypto/aead.c b/crypto/aead.c index 04add3dca6fe..e4cb35159be4 100644 --- a/crypto/aead.c +++ b/crypto/aead.c | |||
@@ -470,8 +470,7 @@ out: | |||
470 | return err; | 470 | return err; |
471 | } | 471 | } |
472 | 472 | ||
473 | static struct crypto_alg *crypto_lookup_aead(const char *name, u32 type, | 473 | struct crypto_alg *crypto_lookup_aead(const char *name, u32 type, u32 mask) |
474 | u32 mask) | ||
475 | { | 474 | { |
476 | struct crypto_alg *alg; | 475 | struct crypto_alg *alg; |
477 | 476 | ||
@@ -503,6 +502,7 @@ static struct crypto_alg *crypto_lookup_aead(const char *name, u32 type, | |||
503 | 502 | ||
504 | return ERR_PTR(crypto_nivaead_default(alg, type, mask)); | 503 | return ERR_PTR(crypto_nivaead_default(alg, type, mask)); |
505 | } | 504 | } |
505 | EXPORT_SYMBOL_GPL(crypto_lookup_aead); | ||
506 | 506 | ||
507 | int crypto_grab_aead(struct crypto_aead_spawn *spawn, const char *name, | 507 | int crypto_grab_aead(struct crypto_aead_spawn *spawn, const char *name, |
508 | u32 type, u32 mask) | 508 | u32 type, u32 mask) |
diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c index f76e42bcc6e7..f1ea0a064135 100644 --- a/crypto/crypto_user.c +++ b/crypto/crypto_user.c | |||
@@ -21,9 +21,13 @@ | |||
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <linux/crypto.h> | 22 | #include <linux/crypto.h> |
23 | #include <linux/cryptouser.h> | 23 | #include <linux/cryptouser.h> |
24 | #include <linux/sched.h> | ||
24 | #include <net/netlink.h> | 25 | #include <net/netlink.h> |
25 | #include <linux/security.h> | 26 | #include <linux/security.h> |
26 | #include <net/net_namespace.h> | 27 | #include <net/net_namespace.h> |
28 | #include <crypto/internal/aead.h> | ||
29 | #include <crypto/internal/skcipher.h> | ||
30 | |||
27 | #include "internal.h" | 31 | #include "internal.h" |
28 | 32 | ||
29 | DEFINE_MUTEX(crypto_cfg_mutex); | 33 | DEFINE_MUTEX(crypto_cfg_mutex); |
@@ -301,6 +305,60 @@ static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
301 | return crypto_unregister_instance(alg); | 305 | return crypto_unregister_instance(alg); |
302 | } | 306 | } |
303 | 307 | ||
308 | static struct crypto_alg *crypto_user_skcipher_alg(const char *name, u32 type, | ||
309 | u32 mask) | ||
310 | { | ||
311 | int err; | ||
312 | struct crypto_alg *alg; | ||
313 | |||
314 | type = crypto_skcipher_type(type); | ||
315 | mask = crypto_skcipher_mask(mask); | ||
316 | |||
317 | for (;;) { | ||
318 | alg = crypto_lookup_skcipher(name, type, mask); | ||
319 | if (!IS_ERR(alg)) | ||
320 | return alg; | ||
321 | |||
322 | err = PTR_ERR(alg); | ||
323 | if (err != -EAGAIN) | ||
324 | break; | ||
325 | if (signal_pending(current)) { | ||
326 | err = -EINTR; | ||
327 | break; | ||
328 | } | ||
329 | } | ||
330 | |||
331 | return ERR_PTR(err); | ||
332 | } | ||
333 | |||
334 | static struct crypto_alg *crypto_user_aead_alg(const char *name, u32 type, | ||
335 | u32 mask) | ||
336 | { | ||
337 | int err; | ||
338 | struct crypto_alg *alg; | ||
339 | |||
340 | type &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_GENIV); | ||
341 | type |= CRYPTO_ALG_TYPE_AEAD; | ||
342 | mask &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_GENIV); | ||
343 | mask |= CRYPTO_ALG_TYPE_MASK; | ||
344 | |||
345 | for (;;) { | ||
346 | alg = crypto_lookup_aead(name, type, mask); | ||
347 | if (!IS_ERR(alg)) | ||
348 | return alg; | ||
349 | |||
350 | err = PTR_ERR(alg); | ||
351 | if (err != -EAGAIN) | ||
352 | break; | ||
353 | if (signal_pending(current)) { | ||
354 | err = -EINTR; | ||
355 | break; | ||
356 | } | ||
357 | } | ||
358 | |||
359 | return ERR_PTR(err); | ||
360 | } | ||
361 | |||
304 | static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh, | 362 | static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh, |
305 | struct nlattr **attrs) | 363 | struct nlattr **attrs) |
306 | { | 364 | { |
@@ -325,7 +383,19 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
325 | else | 383 | else |
326 | name = p->cru_name; | 384 | name = p->cru_name; |
327 | 385 | ||
328 | alg = crypto_alg_mod_lookup(name, p->cru_type, p->cru_mask); | 386 | switch (p->cru_type & p->cru_mask & CRYPTO_ALG_TYPE_MASK) { |
387 | case CRYPTO_ALG_TYPE_AEAD: | ||
388 | alg = crypto_user_aead_alg(name, p->cru_type, p->cru_mask); | ||
389 | break; | ||
390 | case CRYPTO_ALG_TYPE_GIVCIPHER: | ||
391 | case CRYPTO_ALG_TYPE_BLKCIPHER: | ||
392 | case CRYPTO_ALG_TYPE_ABLKCIPHER: | ||
393 | alg = crypto_user_skcipher_alg(name, p->cru_type, p->cru_mask); | ||
394 | break; | ||
395 | default: | ||
396 | alg = crypto_alg_mod_lookup(name, p->cru_type, p->cru_mask); | ||
397 | } | ||
398 | |||
329 | if (IS_ERR(alg)) | 399 | if (IS_ERR(alg)) |
330 | return PTR_ERR(alg); | 400 | return PTR_ERR(alg); |
331 | 401 | ||
@@ -387,12 +457,20 @@ static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
387 | 457 | ||
388 | if ((type == (CRYPTO_MSG_GETALG - CRYPTO_MSG_BASE) && | 458 | if ((type == (CRYPTO_MSG_GETALG - CRYPTO_MSG_BASE) && |
389 | (nlh->nlmsg_flags & NLM_F_DUMP))) { | 459 | (nlh->nlmsg_flags & NLM_F_DUMP))) { |
460 | struct crypto_alg *alg; | ||
461 | u16 dump_alloc = 0; | ||
462 | |||
390 | if (link->dump == NULL) | 463 | if (link->dump == NULL) |
391 | return -EINVAL; | 464 | return -EINVAL; |
465 | |||
466 | list_for_each_entry(alg, &crypto_alg_list, cra_list) | ||
467 | dump_alloc += CRYPTO_REPORT_MAXSIZE; | ||
468 | |||
392 | { | 469 | { |
393 | struct netlink_dump_control c = { | 470 | struct netlink_dump_control c = { |
394 | .dump = link->dump, | 471 | .dump = link->dump, |
395 | .done = link->done, | 472 | .done = link->done, |
473 | .min_dump_alloc = dump_alloc, | ||
396 | }; | 474 | }; |
397 | return netlink_dump_start(crypto_nlsk, skb, nlh, &c); | 475 | return netlink_dump_start(crypto_nlsk, skb, nlh, &c); |
398 | } | 476 | } |
diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c index 29a89dad68b6..b2c99dc1c5e2 100644 --- a/crypto/pcrypt.c +++ b/crypto/pcrypt.c | |||
@@ -280,11 +280,11 @@ static int pcrypt_aead_init_tfm(struct crypto_tfm *tfm) | |||
280 | 280 | ||
281 | ictx->tfm_count++; | 281 | ictx->tfm_count++; |
282 | 282 | ||
283 | cpu_index = ictx->tfm_count % cpumask_weight(cpu_active_mask); | 283 | cpu_index = ictx->tfm_count % cpumask_weight(cpu_online_mask); |
284 | 284 | ||
285 | ctx->cb_cpu = cpumask_first(cpu_active_mask); | 285 | ctx->cb_cpu = cpumask_first(cpu_online_mask); |
286 | for (cpu = 0; cpu < cpu_index; cpu++) | 286 | for (cpu = 0; cpu < cpu_index; cpu++) |
287 | ctx->cb_cpu = cpumask_next(ctx->cb_cpu, cpu_active_mask); | 287 | ctx->cb_cpu = cpumask_next(ctx->cb_cpu, cpu_online_mask); |
288 | 288 | ||
289 | cipher = crypto_spawn_aead(crypto_instance_ctx(inst)); | 289 | cipher = crypto_spawn_aead(crypto_instance_ctx(inst)); |
290 | 290 | ||
@@ -472,7 +472,7 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt, | |||
472 | goto err_free_padata; | 472 | goto err_free_padata; |
473 | } | 473 | } |
474 | 474 | ||
475 | cpumask_and(mask->mask, cpu_possible_mask, cpu_active_mask); | 475 | cpumask_and(mask->mask, cpu_possible_mask, cpu_online_mask); |
476 | rcu_assign_pointer(pcrypt->cb_cpumask, mask); | 476 | rcu_assign_pointer(pcrypt->cb_cpumask, mask); |
477 | 477 | ||
478 | pcrypt->nblock.notifier_call = pcrypt_cpumask_change_notify; | 478 | pcrypt->nblock.notifier_call = pcrypt_cpumask_change_notify; |
diff --git a/include/crypto/internal/aead.h b/include/crypto/internal/aead.h index d838c945575a..2eba340230a7 100644 --- a/include/crypto/internal/aead.h +++ b/include/crypto/internal/aead.h | |||
@@ -31,6 +31,8 @@ static inline void crypto_set_aead_spawn( | |||
31 | crypto_set_spawn(&spawn->base, inst); | 31 | crypto_set_spawn(&spawn->base, inst); |
32 | } | 32 | } |
33 | 33 | ||
34 | struct crypto_alg *crypto_lookup_aead(const char *name, u32 type, u32 mask); | ||
35 | |||
34 | int crypto_grab_aead(struct crypto_aead_spawn *spawn, const char *name, | 36 | int crypto_grab_aead(struct crypto_aead_spawn *spawn, const char *name, |
35 | u32 type, u32 mask); | 37 | u32 type, u32 mask); |
36 | 38 | ||
diff --git a/include/crypto/internal/skcipher.h b/include/crypto/internal/skcipher.h index 3a748a6bf772..06e8b32d541c 100644 --- a/include/crypto/internal/skcipher.h +++ b/include/crypto/internal/skcipher.h | |||
@@ -34,6 +34,8 @@ static inline void crypto_set_skcipher_spawn( | |||
34 | int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name, | 34 | int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name, |
35 | u32 type, u32 mask); | 35 | u32 type, u32 mask); |
36 | 36 | ||
37 | struct crypto_alg *crypto_lookup_skcipher(const char *name, u32 type, u32 mask); | ||
38 | |||
37 | static inline void crypto_drop_skcipher(struct crypto_skcipher_spawn *spawn) | 39 | static inline void crypto_drop_skcipher(struct crypto_skcipher_spawn *spawn) |
38 | { | 40 | { |
39 | crypto_drop_spawn(&spawn->base); | 41 | crypto_drop_spawn(&spawn->base); |
diff --git a/include/linux/cryptouser.h b/include/linux/cryptouser.h index 532fb58f16bf..4abf2ea6a887 100644 --- a/include/linux/cryptouser.h +++ b/include/linux/cryptouser.h | |||
@@ -100,3 +100,6 @@ struct crypto_report_rng { | |||
100 | char type[CRYPTO_MAX_NAME]; | 100 | char type[CRYPTO_MAX_NAME]; |
101 | unsigned int seedsize; | 101 | unsigned int seedsize; |
102 | }; | 102 | }; |
103 | |||
104 | #define CRYPTO_REPORT_MAXSIZE (sizeof(struct crypto_user_alg) + \ | ||
105 | sizeof(struct crypto_report_blkcipher)) | ||
diff --git a/kernel/padata.c b/kernel/padata.c index 6f10eb285ece..89fe3d1b9efb 100644 --- a/kernel/padata.c +++ b/kernel/padata.c | |||
@@ -1,6 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * padata.c - generic interface to process data streams in parallel | 2 | * padata.c - generic interface to process data streams in parallel |
3 | * | 3 | * |
4 | * See Documentation/padata.txt for an api documentation. | ||
5 | * | ||
4 | * Copyright (C) 2008, 2009 secunet Security Networks AG | 6 | * Copyright (C) 2008, 2009 secunet Security Networks AG |
5 | * Copyright (C) 2008, 2009 Steffen Klassert <steffen.klassert@secunet.com> | 7 | * Copyright (C) 2008, 2009 Steffen Klassert <steffen.klassert@secunet.com> |
6 | * | 8 | * |
@@ -354,13 +356,13 @@ static int padata_setup_cpumasks(struct parallel_data *pd, | |||
354 | if (!alloc_cpumask_var(&pd->cpumask.pcpu, GFP_KERNEL)) | 356 | if (!alloc_cpumask_var(&pd->cpumask.pcpu, GFP_KERNEL)) |
355 | return -ENOMEM; | 357 | return -ENOMEM; |
356 | 358 | ||
357 | cpumask_and(pd->cpumask.pcpu, pcpumask, cpu_active_mask); | 359 | cpumask_and(pd->cpumask.pcpu, pcpumask, cpu_online_mask); |
358 | if (!alloc_cpumask_var(&pd->cpumask.cbcpu, GFP_KERNEL)) { | 360 | if (!alloc_cpumask_var(&pd->cpumask.cbcpu, GFP_KERNEL)) { |
359 | free_cpumask_var(pd->cpumask.cbcpu); | 361 | free_cpumask_var(pd->cpumask.cbcpu); |
360 | return -ENOMEM; | 362 | return -ENOMEM; |
361 | } | 363 | } |
362 | 364 | ||
363 | cpumask_and(pd->cpumask.cbcpu, cbcpumask, cpu_active_mask); | 365 | cpumask_and(pd->cpumask.cbcpu, cbcpumask, cpu_online_mask); |
364 | return 0; | 366 | return 0; |
365 | } | 367 | } |
366 | 368 | ||
@@ -564,7 +566,7 @@ EXPORT_SYMBOL(padata_unregister_cpumask_notifier); | |||
564 | static bool padata_validate_cpumask(struct padata_instance *pinst, | 566 | static bool padata_validate_cpumask(struct padata_instance *pinst, |
565 | const struct cpumask *cpumask) | 567 | const struct cpumask *cpumask) |
566 | { | 568 | { |
567 | if (!cpumask_intersects(cpumask, cpu_active_mask)) { | 569 | if (!cpumask_intersects(cpumask, cpu_online_mask)) { |
568 | pinst->flags |= PADATA_INVALID; | 570 | pinst->flags |= PADATA_INVALID; |
569 | return false; | 571 | return false; |
570 | } | 572 | } |
@@ -678,7 +680,7 @@ static int __padata_add_cpu(struct padata_instance *pinst, int cpu) | |||
678 | { | 680 | { |
679 | struct parallel_data *pd; | 681 | struct parallel_data *pd; |
680 | 682 | ||
681 | if (cpumask_test_cpu(cpu, cpu_active_mask)) { | 683 | if (cpumask_test_cpu(cpu, cpu_online_mask)) { |
682 | pd = padata_alloc_pd(pinst, pinst->cpumask.pcpu, | 684 | pd = padata_alloc_pd(pinst, pinst->cpumask.pcpu, |
683 | pinst->cpumask.cbcpu); | 685 | pinst->cpumask.cbcpu); |
684 | if (!pd) | 686 | if (!pd) |
@@ -746,6 +748,9 @@ static int __padata_remove_cpu(struct padata_instance *pinst, int cpu) | |||
746 | return -ENOMEM; | 748 | return -ENOMEM; |
747 | 749 | ||
748 | padata_replace(pinst, pd); | 750 | padata_replace(pinst, pd); |
751 | |||
752 | cpumask_clear_cpu(cpu, pd->cpumask.cbcpu); | ||
753 | cpumask_clear_cpu(cpu, pd->cpumask.pcpu); | ||
749 | } | 754 | } |
750 | 755 | ||
751 | return 0; | 756 | return 0; |