diff options
author | Attila Fülöp <[email protected]> | 2019-12-06 18:36:19 +0100 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-12-06 09:36:19 -0800 |
commit | 3ac34ca375732df26871faba9ff6a4b79571a4c2 (patch) | |
tree | 18d1904d8a2d27f6bd10a73cc9c7d5b0c6786282 /module/icp/algs | |
parent | f784828416ca1beb3c3bbf62a55a0a85cf417d10 (diff) |
ICP: Fix out of bounds write
If gcm_mode_encrypt_contiguous_blocks() is called more than once
in succession, with the accumulated lengths being less than
blocksize, ctx->copy_to will be incorrectly advanced. Later, if
out is NULL, the bcopy at line 114 will overflow
ctx->gcm_copy_to since ctx->gcm_remainder_len is larger than the
ctx->gcm_copy_to buffer can hold.
The fix is to set ctx->copy_to only if it's not already set.
For ZoL the issue may be academic, since in all my testing I wasn't
able to hit neither of both conditions needed to trigger it, but
other consumers can easily do so.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Tom Caputi <[email protected]>
Signed-off-by: Attila Fülöp <[email protected]>
Closes #9660
Diffstat (limited to 'module/icp/algs')
-rw-r--r-- | module/icp/algs/modes/gcm.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/module/icp/algs/modes/gcm.c b/module/icp/algs/modes/gcm.c index 339ffb86f..71ea16d24 100644 --- a/module/icp/algs/modes/gcm.c +++ b/module/icp/algs/modes/gcm.c @@ -67,7 +67,9 @@ gcm_mode_encrypt_contiguous_blocks(gcm_ctx_t *ctx, char *data, size_t length, (uint8_t *)ctx->gcm_remainder + ctx->gcm_remainder_len, length); ctx->gcm_remainder_len += length; - ctx->gcm_copy_to = datap; + if (ctx->gcm_copy_to == NULL) { + ctx->gcm_copy_to = datap; + } return (CRYPTO_SUCCESS); } |