[dm-devel] [PATCH 2/2] arm aes: fix encryption of unaligned data

Ard Biesheuvel ard.biesheuvel at linaro.org
Sat Jul 26 13:24:22 UTC 2014


On 26 July 2014 01:42, Mikulas Patocka <mpatocka at redhat.com> wrote:
> Fix the same alignment bug as in arm64 - we need to pass residue
> unprocessed bytes as the last argument to blkcipher_walk_done.
>
> Signed-off-by: Mikulas Patocka <mpatocka at redhat.com>
> Cc: stable at vger.kernel.org      # 3.13+
>

Acked-by: Ard Biesheuvel <ard.biesheuvel at linaro.org>

As for the previous patch, this correctly fixes a thinko on my part
regarding the guarantees offered by the blkcipher API.

@Russell: could you please indicate whether you prefer to take this
yourself or ack it so we can ask Herbert to take both ARM and arm64
patches as a set.

Regards,
Ard.

> Index: linux-3.16.0-0.rc6.git1.1.fc21.aarch64/arch/arm/crypto/aesbs-glue.c
> ===================================================================
> --- linux-3.16.0-0.rc6.git1.1.fc21.aarch64.orig/arch/arm/crypto/aesbs-glue.c
> +++ linux-3.16.0-0.rc6.git1.1.fc21.aarch64/arch/arm/crypto/aesbs-glue.c
> @@ -137,7 +137,7 @@ static int aesbs_cbc_encrypt(struct blkc
>                                 dst += AES_BLOCK_SIZE;
>                         } while (--blocks);
>                 }
> -               err = blkcipher_walk_done(desc, &walk, 0);
> +               err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);
>         }
>         return err;
>  }
> @@ -158,7 +158,7 @@ static int aesbs_cbc_decrypt(struct blkc
>                 bsaes_cbc_encrypt(walk.src.virt.addr, walk.dst.virt.addr,
>                                   walk.nbytes, &ctx->dec, walk.iv);
>                 kernel_neon_end();
> -               err = blkcipher_walk_done(desc, &walk, 0);
> +               err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);
>         }
>         while (walk.nbytes) {
>                 u32 blocks = walk.nbytes / AES_BLOCK_SIZE;
> @@ -182,7 +182,7 @@ static int aesbs_cbc_decrypt(struct blkc
>                         dst += AES_BLOCK_SIZE;
>                         src += AES_BLOCK_SIZE;
>                 } while (--blocks);
> -               err = blkcipher_walk_done(desc, &walk, 0);
> +               err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);
>         }
>         return err;
>  }
> @@ -268,7 +268,7 @@ static int aesbs_xts_encrypt(struct blkc
>                 bsaes_xts_encrypt(walk.src.virt.addr, walk.dst.virt.addr,
>                                   walk.nbytes, &ctx->enc, walk.iv);
>                 kernel_neon_end();
> -               err = blkcipher_walk_done(desc, &walk, 0);
> +               err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);
>         }
>         return err;
>  }
> @@ -292,7 +292,7 @@ static int aesbs_xts_decrypt(struct blkc
>                 bsaes_xts_decrypt(walk.src.virt.addr, walk.dst.virt.addr,
>                                   walk.nbytes, &ctx->dec, walk.iv);
>                 kernel_neon_end();
> -               err = blkcipher_walk_done(desc, &walk, 0);
> +               err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);
>         }
>         return err;
>  }




More information about the dm-devel mailing list