Skip to content
Permalink
Browse files

Assert against issue #9661

Signed-off-by: Attila Fülöp <attila@fueloep.org>
  • Loading branch information
AttilaFueloep committed Jan 13, 2020
1 parent 0366890 commit ba7a6b6c76d379c9d13550543864aef8e0a6ae9e
Showing with 17 additions and 11 deletions.
  1. +17 −11 module/icp/algs/modes/gcm.c
@@ -151,8 +151,15 @@ gcm_mode_encrypt_contiguous_blocks(gcm_ctx_t *ctx, char *data, size_t length,

ctx->gcm_processed_data_len += block_size;

/*
* The following copies a complete GCM block back to where it
* came from if there was a remainder in the last call and out
* is NULL. That doesn't seem to make sense. So we assert this
* can't happen and leave the code in for reference.
* See https://github.com/zfsonlinux/zfs/issues/9661
*/
ASSERT(out != NULL);
if (out == NULL) {
/* FIXME: See issue #9661 */
if (ctx->gcm_remainder_len > 0) {
bcopy(blockp, ctx->gcm_copy_to,
ctx->gcm_remainder_len);
@@ -1161,16 +1168,15 @@ gcm_mode_encrypt_contiguous_blocks_avx(gcm_ctx_t *ctx, char *data,
GHASH_AVX(ctx, tmp, block_size);
clear_fpu_regs();
kfpu_end();
if (out != NULL) {
rv = crypto_put_output_data(tmp, out, block_size);
out->cd_offset += block_size;
} else {
/* FIXME: See issue #9661 */
bcopy(ctx->gcm_remainder, ctx->gcm_copy_to,
ctx->gcm_remainder_len);
bcopy(ctx->gcm_remainder + ctx->gcm_remainder_len,
datap, need);
}
/*
* We don't follow gcm_mode_encrypt_contiguous_blocks() here
* but assert that out is not null.
* See gcm_mode_encrypt_contiguous_blocks() above and
* https://github.com/zfsonlinux/zfs/issues/9661
*/
ASSERT(out != NULL);
rv = crypto_put_output_data(tmp, out, block_size);
out->cd_offset += block_size;
gcm_incr_counter_block(ctx);
ctx->gcm_processed_data_len += block_size;
bleft -= need;

0 comments on commit ba7a6b6

Please sign in to comment.
You can’t perform that action at this time.