]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - arch/s390/crypto/aes_s390.c
s390/crypto: Don't panic after crypto instruction failures
[mirror_ubuntu-artful-kernel.git] / arch / s390 / crypto / aes_s390.c
index e402a9dd4eda67944893eeef40fa8d67a3066008..b4dbade8ca247c52106ecd72036983c850369431 100644 (file)
@@ -216,7 +216,6 @@ static struct crypto_alg aes_alg = {
        .cra_blocksize          =       AES_BLOCK_SIZE,
        .cra_ctxsize            =       sizeof(struct s390_aes_ctx),
        .cra_module             =       THIS_MODULE,
-       .cra_list               =       LIST_HEAD_INIT(aes_alg.cra_list),
        .cra_init               =       fallback_init_cip,
        .cra_exit               =       fallback_exit_cip,
        .cra_u                  =       {
@@ -326,7 +325,8 @@ static int ecb_aes_crypt(struct blkcipher_desc *desc, long func, void *param,
                u8 *in = walk->src.virt.addr;
 
                ret = crypt_s390_km(func, param, out, in, n);
-               BUG_ON((ret < 0) || (ret != n));
+               if (ret < 0 || ret != n)
+                       return -EIO;
 
                nbytes &= AES_BLOCK_SIZE - 1;
                ret = blkcipher_walk_done(desc, walk, nbytes);
@@ -398,7 +398,6 @@ static struct crypto_alg ecb_aes_alg = {
        .cra_ctxsize            =       sizeof(struct s390_aes_ctx),
        .cra_type               =       &crypto_blkcipher_type,
        .cra_module             =       THIS_MODULE,
-       .cra_list               =       LIST_HEAD_INIT(ecb_aes_alg.cra_list),
        .cra_init               =       fallback_init_blk,
        .cra_exit               =       fallback_exit_blk,
        .cra_u                  =       {
@@ -459,7 +458,8 @@ static int cbc_aes_crypt(struct blkcipher_desc *desc, long func, void *param,
                u8 *in = walk->src.virt.addr;
 
                ret = crypt_s390_kmc(func, param, out, in, n);
-               BUG_ON((ret < 0) || (ret != n));
+               if (ret < 0 || ret != n)
+                       return -EIO;
 
                nbytes &= AES_BLOCK_SIZE - 1;
                ret = blkcipher_walk_done(desc, walk, nbytes);
@@ -508,7 +508,6 @@ static struct crypto_alg cbc_aes_alg = {
        .cra_ctxsize            =       sizeof(struct s390_aes_ctx),
        .cra_type               =       &crypto_blkcipher_type,
        .cra_module             =       THIS_MODULE,
-       .cra_list               =       LIST_HEAD_INIT(cbc_aes_alg.cra_list),
        .cra_init               =       fallback_init_blk,
        .cra_exit               =       fallback_exit_blk,
        .cra_u                  =       {
@@ -628,7 +627,8 @@ static int xts_aes_crypt(struct blkcipher_desc *desc, long func,
        memcpy(xts_ctx->pcc.tweak, walk->iv, sizeof(xts_ctx->pcc.tweak));
        param = xts_ctx->pcc.key + offset;
        ret = crypt_s390_pcc(func, param);
-       BUG_ON(ret < 0);
+       if (ret < 0)
+               return -EIO;
 
        memcpy(xts_ctx->xts_param, xts_ctx->pcc.xts, 16);
        param = xts_ctx->key + offset;
@@ -639,7 +639,8 @@ static int xts_aes_crypt(struct blkcipher_desc *desc, long func,
                in = walk->src.virt.addr;
 
                ret = crypt_s390_km(func, param, out, in, n);
-               BUG_ON(ret < 0 || ret != n);
+               if (ret < 0 || ret != n)
+                       return -EIO;
 
                nbytes &= AES_BLOCK_SIZE - 1;
                ret = blkcipher_walk_done(desc, walk, nbytes);
@@ -710,7 +711,6 @@ static struct crypto_alg xts_aes_alg = {
        .cra_ctxsize            =       sizeof(struct s390_xts_ctx),
        .cra_type               =       &crypto_blkcipher_type,
        .cra_module             =       THIS_MODULE,
-       .cra_list               =       LIST_HEAD_INIT(xts_aes_alg.cra_list),
        .cra_init               =       xts_fallback_init,
        .cra_exit               =       xts_fallback_exit,
        .cra_u                  =       {
@@ -773,7 +773,8 @@ static int ctr_aes_crypt(struct blkcipher_desc *desc, long func,
                                crypto_inc(ctrblk + i, AES_BLOCK_SIZE);
                        }
                        ret = crypt_s390_kmctr(func, sctx->key, out, in, n, ctrblk);
-                       BUG_ON(ret < 0 || ret != n);
+                       if (ret < 0 || ret != n)
+                               return -EIO;
                        if (n > AES_BLOCK_SIZE)
                                memcpy(ctrblk, ctrblk + n - AES_BLOCK_SIZE,
                                       AES_BLOCK_SIZE);
@@ -792,7 +793,8 @@ static int ctr_aes_crypt(struct blkcipher_desc *desc, long func,
                in = walk->src.virt.addr;
                ret = crypt_s390_kmctr(func, sctx->key, buf, in,
                                       AES_BLOCK_SIZE, ctrblk);
-               BUG_ON(ret < 0 || ret != AES_BLOCK_SIZE);
+               if (ret < 0 || ret != AES_BLOCK_SIZE)
+                       return -EIO;
                memcpy(out, buf, nbytes);
                crypto_inc(ctrblk, AES_BLOCK_SIZE);
                ret = blkcipher_walk_done(desc, walk, 0);
@@ -832,7 +834,6 @@ static struct crypto_alg ctr_aes_alg = {
        .cra_ctxsize            =       sizeof(struct s390_aes_ctx),
        .cra_type               =       &crypto_blkcipher_type,
        .cra_module             =       THIS_MODULE,
-       .cra_list               =       LIST_HEAD_INIT(ctr_aes_alg.cra_list),
        .cra_u                  =       {
                .blkcipher = {
                        .min_keysize            =       AES_MIN_KEY_SIZE,