Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6

Pull crypto fix from Herbert Xu:
"This fixes a bug in the algif_skcipher interface that can trigger a
kernel WARN_ON from user-space. It does so by using the new skcipher
interface which unlike the previous ablkcipher does not need to create
extra geniv objects which is what was used to trigger the WARN_ON"

* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
crypto: algif_skcipher - Use new skcipher interface

+30 -31
+30 -31
crypto/algif_skcipher.c
··· 47 47 bool merge; 48 48 bool enc; 49 49 50 - struct ablkcipher_request req; 50 + struct skcipher_request req; 51 51 }; 52 52 53 53 struct skcipher_async_rsgl { ··· 64 64 }; 65 65 66 66 #define GET_SREQ(areq, ctx) (struct skcipher_async_req *)((char *)areq + \ 67 - crypto_ablkcipher_reqsize(crypto_ablkcipher_reqtfm(&ctx->req))) 67 + crypto_skcipher_reqsize(crypto_skcipher_reqtfm(&ctx->req))) 68 68 69 69 #define GET_REQ_SIZE(ctx) \ 70 - crypto_ablkcipher_reqsize(crypto_ablkcipher_reqtfm(&ctx->req)) 70 + crypto_skcipher_reqsize(crypto_skcipher_reqtfm(&ctx->req)) 71 71 72 72 #define GET_IV_SIZE(ctx) \ 73 - crypto_ablkcipher_ivsize(crypto_ablkcipher_reqtfm(&ctx->req)) 73 + crypto_skcipher_ivsize(crypto_skcipher_reqtfm(&ctx->req)) 74 74 75 75 #define MAX_SGL_ENTS ((4096 - sizeof(struct skcipher_sg_list)) / \ 76 76 sizeof(struct scatterlist) - 1) ··· 302 302 struct sock *sk = sock->sk; 303 303 struct alg_sock *ask = alg_sk(sk); 304 304 struct skcipher_ctx *ctx = ask->private; 305 - struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(&ctx->req); 306 - unsigned ivsize = crypto_ablkcipher_ivsize(tfm); 305 + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(&ctx->req); 306 + unsigned ivsize = crypto_skcipher_ivsize(tfm); 307 307 struct skcipher_sg_list *sgl; 308 308 struct af_alg_control con = {}; 309 309 long copied = 0; ··· 507 507 struct skcipher_sg_list *sgl; 508 508 struct scatterlist *sg; 509 509 struct skcipher_async_req *sreq; 510 - struct ablkcipher_request *req; 510 + struct skcipher_request *req; 511 511 struct skcipher_async_rsgl *last_rsgl = NULL; 512 512 unsigned int txbufs = 0, len = 0, tx_nents = skcipher_all_sg_nents(ctx); 513 513 unsigned int reqlen = sizeof(struct skcipher_async_req) + ··· 531 531 } 532 532 sg_init_table(sreq->tsg, tx_nents); 533 533 memcpy(sreq->iv, ctx->iv, GET_IV_SIZE(ctx)); 534 - ablkcipher_request_set_tfm(req, crypto_ablkcipher_reqtfm(&ctx->req)); 535 - ablkcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, 536 - skcipher_async_cb, sk); 534 + skcipher_request_set_tfm(req, crypto_skcipher_reqtfm(&ctx->req)); 535 + skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, 536 + skcipher_async_cb, sk); 537 537 538 538 while (iov_iter_count(&msg->msg_iter)) { 539 539 struct skcipher_async_rsgl *rsgl; ··· 608 608 if (mark) 609 609 sg_mark_end(sreq->tsg + txbufs - 1); 610 610 611 - ablkcipher_request_set_crypt(req, sreq->tsg, sreq->first_sgl.sgl.sg, 612 - len, sreq->iv); 613 - err = ctx->enc ? crypto_ablkcipher_encrypt(req) : 614 - crypto_ablkcipher_decrypt(req); 611 + skcipher_request_set_crypt(req, sreq->tsg, sreq->first_sgl.sgl.sg, 612 + len, sreq->iv); 613 + err = ctx->enc ? crypto_skcipher_encrypt(req) : 614 + crypto_skcipher_decrypt(req); 615 615 if (err == -EINPROGRESS) { 616 616 atomic_inc(&ctx->inflight); 617 617 err = -EIOCBQUEUED; ··· 632 632 struct sock *sk = sock->sk; 633 633 struct alg_sock *ask = alg_sk(sk); 634 634 struct skcipher_ctx *ctx = ask->private; 635 - unsigned bs = crypto_ablkcipher_blocksize(crypto_ablkcipher_reqtfm( 635 + unsigned bs = crypto_skcipher_blocksize(crypto_skcipher_reqtfm( 636 636 &ctx->req)); 637 637 struct skcipher_sg_list *sgl; 638 638 struct scatterlist *sg; ··· 669 669 if (!used) 670 670 goto free; 671 671 672 - ablkcipher_request_set_crypt(&ctx->req, sg, 673 - ctx->rsgl.sg, used, 674 - ctx->iv); 672 + skcipher_request_set_crypt(&ctx->req, sg, ctx->rsgl.sg, used, 673 + ctx->iv); 675 674 676 675 err = af_alg_wait_for_completion( 677 676 ctx->enc ? 678 - crypto_ablkcipher_encrypt(&ctx->req) : 679 - crypto_ablkcipher_decrypt(&ctx->req), 677 + crypto_skcipher_encrypt(&ctx->req) : 678 + crypto_skcipher_decrypt(&ctx->req), 680 679 &ctx->completion); 681 680 682 681 free: ··· 750 751 751 752 static void *skcipher_bind(const char *name, u32 type, u32 mask) 752 753 { 753 - return crypto_alloc_ablkcipher(name, type, mask); 754 + return crypto_alloc_skcipher(name, type, mask); 754 755 } 755 756 756 757 static void skcipher_release(void *private) 757 758 { 758 - crypto_free_ablkcipher(private); 759 + crypto_free_skcipher(private); 759 760 } 760 761 761 762 static int skcipher_setkey(void *private, const u8 *key, unsigned int keylen) 762 763 { 763 - return crypto_ablkcipher_setkey(private, key, keylen); 764 + return crypto_skcipher_setkey(private, key, keylen); 764 765 } 765 766 766 767 static void skcipher_wait(struct sock *sk) ··· 777 778 { 778 779 struct alg_sock *ask = alg_sk(sk); 779 780 struct skcipher_ctx *ctx = ask->private; 780 - struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(&ctx->req); 781 + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(&ctx->req); 781 782 782 783 if (atomic_read(&ctx->inflight)) 783 784 skcipher_wait(sk); 784 785 785 786 skcipher_free_sgl(sk); 786 - sock_kzfree_s(sk, ctx->iv, crypto_ablkcipher_ivsize(tfm)); 787 + sock_kzfree_s(sk, ctx->iv, crypto_skcipher_ivsize(tfm)); 787 788 sock_kfree_s(sk, ctx, ctx->len); 788 789 af_alg_release_parent(sk); 789 790 } ··· 792 793 { 793 794 struct skcipher_ctx *ctx; 794 795 struct alg_sock *ask = alg_sk(sk); 795 - unsigned int len = sizeof(*ctx) + crypto_ablkcipher_reqsize(private); 796 + unsigned int len = sizeof(*ctx) + crypto_skcipher_reqsize(private); 796 797 797 798 ctx = sock_kmalloc(sk, len, GFP_KERNEL); 798 799 if (!ctx) 799 800 return -ENOMEM; 800 801 801 - ctx->iv = sock_kmalloc(sk, crypto_ablkcipher_ivsize(private), 802 + ctx->iv = sock_kmalloc(sk, crypto_skcipher_ivsize(private), 802 803 GFP_KERNEL); 803 804 if (!ctx->iv) { 804 805 sock_kfree_s(sk, ctx, len); 805 806 return -ENOMEM; 806 807 } 807 808 808 - memset(ctx->iv, 0, crypto_ablkcipher_ivsize(private)); 809 + memset(ctx->iv, 0, crypto_skcipher_ivsize(private)); 809 810 810 811 INIT_LIST_HEAD(&ctx->tsgl); 811 812 ctx->len = len; ··· 818 819 819 820 ask->private = ctx; 820 821 821 - ablkcipher_request_set_tfm(&ctx->req, private); 822 - ablkcipher_request_set_callback(&ctx->req, CRYPTO_TFM_REQ_MAY_BACKLOG, 823 - af_alg_complete, &ctx->completion); 822 + skcipher_request_set_tfm(&ctx->req, private); 823 + skcipher_request_set_callback(&ctx->req, CRYPTO_TFM_REQ_MAY_BACKLOG, 824 + af_alg_complete, &ctx->completion); 824 825 825 826 sk->sk_destruct = skcipher_sock_destruct; 826 827