aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/af_alg.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-03-05 12:09:55 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-03-05 12:09:55 -0500
commit63bdf4284c38a48af21745ceb148a087b190cd21 (patch)
treeffbf9e69ed457e776db0317903ccb0addbd1b276 /crypto/af_alg.c
parent6456300356433873309a1cae6aa05e77d6b59153 (diff)
parent0918f18c7179e8cdf718d01531a81b28130b4217 (diff)
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto update from Herbert Xu: "API: - Add helper for simple skcipher modes. - Add helper to register multiple templates. - Set CRYPTO_TFM_NEED_KEY when setkey fails. - Require neither or both of export/import in shash. - AEAD decryption test vectors are now generated from encryption ones. - New option CONFIG_CRYPTO_MANAGER_EXTRA_TESTS that includes random fuzzing. Algorithms: - Conversions to skcipher and helper for many templates. - Add more test vectors for nhpoly1305 and adiantum. Drivers: - Add crypto4xx prng support. - Add xcbc/cmac/ecb support in caam. - Add AES support for Exynos5433 in s5p. - Remove sha384/sha512 from artpec7 as hardware cannot do partial hash" [ There is a merge of the Freescale SoC tree in order to pull in changes required by patches to the caam/qi2 driver. ] * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (174 commits) crypto: s5p - add AES support for Exynos5433 dt-bindings: crypto: document Exynos5433 SlimSSS crypto: crypto4xx - add missing of_node_put after of_device_is_available crypto: cavium/zip - fix collision with generic cra_driver_name crypto: af_alg - use struct_size() in sock_kfree_s() crypto: caam - remove redundant likely/unlikely annotation crypto: s5p - update iv after AES-CBC op end crypto: x86/poly1305 - Clear key material from stack in SSE2 variant crypto: caam - generate hash keys in-place crypto: caam - fix DMA mapping xcbc key twice crypto: caam - fix hash context DMA unmap size hwrng: bcm2835 - fix probe as platform device crypto: s5p-sss - Use AES_BLOCK_SIZE define instead of number crypto: stm32 - drop pointless static qualifier in stm32_hash_remove() crypto: chelsio - Fixed Traffic Stall crypto: marvell - Remove set but not used variable 'ivsize' crypto: ccp - Update driver messages to remove some confusion crypto: adiantum - add 1536 and 4096-byte test vectors crypto: nhpoly1305 - add a test vector with len % 16 != 0 crypto: arm/aes-ce - update IV after partial final CTR block ...
Diffstat (limited to 'crypto/af_alg.c')
-rw-r--r--crypto/af_alg.c36
1 files changed, 13 insertions, 23 deletions
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index ec78a04eb136..edca0998b2a4 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -304,8 +304,6 @@ int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern)
304 if (err) 304 if (err)
305 goto unlock; 305 goto unlock;
306 306
307 sk2->sk_family = PF_ALG;
308
309 if (nokey || !ask->refcnt++) 307 if (nokey || !ask->refcnt++)
310 sock_hold(sk); 308 sock_hold(sk);
311 ask->nokey_refcnt += nokey; 309 ask->nokey_refcnt += nokey;
@@ -382,7 +380,6 @@ static int alg_create(struct net *net, struct socket *sock, int protocol,
382 sock->ops = &alg_proto_ops; 380 sock->ops = &alg_proto_ops;
383 sock_init_data(sock, sk); 381 sock_init_data(sock, sk);
384 382
385 sk->sk_family = PF_ALG;
386 sk->sk_destruct = alg_sock_destruct; 383 sk->sk_destruct = alg_sock_destruct;
387 384
388 return 0; 385 return 0;
@@ -427,12 +424,12 @@ int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len)
427} 424}
428EXPORT_SYMBOL_GPL(af_alg_make_sg); 425EXPORT_SYMBOL_GPL(af_alg_make_sg);
429 426
430void af_alg_link_sg(struct af_alg_sgl *sgl_prev, struct af_alg_sgl *sgl_new) 427static void af_alg_link_sg(struct af_alg_sgl *sgl_prev,
428 struct af_alg_sgl *sgl_new)
431{ 429{
432 sg_unmark_end(sgl_prev->sg + sgl_prev->npages - 1); 430 sg_unmark_end(sgl_prev->sg + sgl_prev->npages - 1);
433 sg_chain(sgl_prev->sg, sgl_prev->npages + 1, sgl_new->sg); 431 sg_chain(sgl_prev->sg, sgl_prev->npages + 1, sgl_new->sg);
434} 432}
435EXPORT_SYMBOL_GPL(af_alg_link_sg);
436 433
437void af_alg_free_sg(struct af_alg_sgl *sgl) 434void af_alg_free_sg(struct af_alg_sgl *sgl)
438{ 435{
@@ -443,7 +440,7 @@ void af_alg_free_sg(struct af_alg_sgl *sgl)
443} 440}
444EXPORT_SYMBOL_GPL(af_alg_free_sg); 441EXPORT_SYMBOL_GPL(af_alg_free_sg);
445 442
446int af_alg_cmsg_send(struct msghdr *msg, struct af_alg_control *con) 443static int af_alg_cmsg_send(struct msghdr *msg, struct af_alg_control *con)
447{ 444{
448 struct cmsghdr *cmsg; 445 struct cmsghdr *cmsg;
449 446
@@ -482,7 +479,6 @@ int af_alg_cmsg_send(struct msghdr *msg, struct af_alg_control *con)
482 479
483 return 0; 480 return 0;
484} 481}
485EXPORT_SYMBOL_GPL(af_alg_cmsg_send);
486 482
487/** 483/**
488 * af_alg_alloc_tsgl - allocate the TX SGL 484 * af_alg_alloc_tsgl - allocate the TX SGL
@@ -490,7 +486,7 @@ EXPORT_SYMBOL_GPL(af_alg_cmsg_send);
490 * @sk socket of connection to user space 486 * @sk socket of connection to user space
491 * @return: 0 upon success, < 0 upon error 487 * @return: 0 upon success, < 0 upon error
492 */ 488 */
493int af_alg_alloc_tsgl(struct sock *sk) 489static int af_alg_alloc_tsgl(struct sock *sk)
494{ 490{
495 struct alg_sock *ask = alg_sk(sk); 491 struct alg_sock *ask = alg_sk(sk);
496 struct af_alg_ctx *ctx = ask->private; 492 struct af_alg_ctx *ctx = ask->private;
@@ -519,7 +515,6 @@ int af_alg_alloc_tsgl(struct sock *sk)
519 515
520 return 0; 516 return 0;
521} 517}
522EXPORT_SYMBOL_GPL(af_alg_alloc_tsgl);
523 518
524/** 519/**
525 * aead_count_tsgl - Count number of TX SG entries 520 * aead_count_tsgl - Count number of TX SG entries
@@ -534,17 +529,17 @@ EXPORT_SYMBOL_GPL(af_alg_alloc_tsgl);
534 */ 529 */
535unsigned int af_alg_count_tsgl(struct sock *sk, size_t bytes, size_t offset) 530unsigned int af_alg_count_tsgl(struct sock *sk, size_t bytes, size_t offset)
536{ 531{
537 struct alg_sock *ask = alg_sk(sk); 532 const struct alg_sock *ask = alg_sk(sk);
538 struct af_alg_ctx *ctx = ask->private; 533 const struct af_alg_ctx *ctx = ask->private;
539 struct af_alg_tsgl *sgl, *tmp; 534 const struct af_alg_tsgl *sgl;
540 unsigned int i; 535 unsigned int i;
541 unsigned int sgl_count = 0; 536 unsigned int sgl_count = 0;
542 537
543 if (!bytes) 538 if (!bytes)
544 return 0; 539 return 0;
545 540
546 list_for_each_entry_safe(sgl, tmp, &ctx->tsgl_list, list) { 541 list_for_each_entry(sgl, &ctx->tsgl_list, list) {
547 struct scatterlist *sg = sgl->sg; 542 const struct scatterlist *sg = sgl->sg;
548 543
549 for (i = 0; i < sgl->cur; i++) { 544 for (i = 0; i < sgl->cur; i++) {
550 size_t bytes_count; 545 size_t bytes_count;
@@ -642,8 +637,7 @@ void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst,
642 } 637 }
643 638
644 list_del(&sgl->list); 639 list_del(&sgl->list);
645 sock_kfree_s(sk, sgl, sizeof(*sgl) + sizeof(sgl->sg[0]) * 640 sock_kfree_s(sk, sgl, struct_size(sgl, sg, MAX_SGL_ENTS + 1));
646 (MAX_SGL_ENTS + 1));
647 } 641 }
648 642
649 if (!ctx->used) 643 if (!ctx->used)
@@ -656,7 +650,7 @@ EXPORT_SYMBOL_GPL(af_alg_pull_tsgl);
656 * 650 *
657 * @areq Request holding the TX and RX SGL 651 * @areq Request holding the TX and RX SGL
658 */ 652 */
659void af_alg_free_areq_sgls(struct af_alg_async_req *areq) 653static void af_alg_free_areq_sgls(struct af_alg_async_req *areq)
660{ 654{
661 struct sock *sk = areq->sk; 655 struct sock *sk = areq->sk;
662 struct alg_sock *ask = alg_sk(sk); 656 struct alg_sock *ask = alg_sk(sk);
@@ -685,7 +679,6 @@ void af_alg_free_areq_sgls(struct af_alg_async_req *areq)
685 sock_kfree_s(sk, tsgl, areq->tsgl_entries * sizeof(*tsgl)); 679 sock_kfree_s(sk, tsgl, areq->tsgl_entries * sizeof(*tsgl));
686 } 680 }
687} 681}
688EXPORT_SYMBOL_GPL(af_alg_free_areq_sgls);
689 682
690/** 683/**
691 * af_alg_wait_for_wmem - wait for availability of writable memory 684 * af_alg_wait_for_wmem - wait for availability of writable memory
@@ -694,7 +687,7 @@ EXPORT_SYMBOL_GPL(af_alg_free_areq_sgls);
694 * @flags If MSG_DONTWAIT is set, then only report if function would sleep 687 * @flags If MSG_DONTWAIT is set, then only report if function would sleep
695 * @return 0 when writable memory is available, < 0 upon error 688 * @return 0 when writable memory is available, < 0 upon error
696 */ 689 */
697int af_alg_wait_for_wmem(struct sock *sk, unsigned int flags) 690static int af_alg_wait_for_wmem(struct sock *sk, unsigned int flags)
698{ 691{
699 DEFINE_WAIT_FUNC(wait, woken_wake_function); 692 DEFINE_WAIT_FUNC(wait, woken_wake_function);
700 int err = -ERESTARTSYS; 693 int err = -ERESTARTSYS;
@@ -719,7 +712,6 @@ int af_alg_wait_for_wmem(struct sock *sk, unsigned int flags)
719 712
720 return err; 713 return err;
721} 714}
722EXPORT_SYMBOL_GPL(af_alg_wait_for_wmem);
723 715
724/** 716/**
725 * af_alg_wmem_wakeup - wakeup caller when writable memory is available 717 * af_alg_wmem_wakeup - wakeup caller when writable memory is available
@@ -788,8 +780,7 @@ EXPORT_SYMBOL_GPL(af_alg_wait_for_data);
788 * 780 *
789 * @sk socket of connection to user space 781 * @sk socket of connection to user space
790 */ 782 */
791 783static void af_alg_data_wakeup(struct sock *sk)
792void af_alg_data_wakeup(struct sock *sk)
793{ 784{
794 struct alg_sock *ask = alg_sk(sk); 785 struct alg_sock *ask = alg_sk(sk);
795 struct af_alg_ctx *ctx = ask->private; 786 struct af_alg_ctx *ctx = ask->private;
@@ -807,7 +798,6 @@ void af_alg_data_wakeup(struct sock *sk)
807 sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); 798 sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT);
808 rcu_read_unlock(); 799 rcu_read_unlock();
809} 800}
810EXPORT_SYMBOL_GPL(af_alg_data_wakeup);
811 801
812/** 802/**
813 * af_alg_sendmsg - implementation of sendmsg system call handler 803 * af_alg_sendmsg - implementation of sendmsg system call handler