Skip to content

Commit 7fb3224

Browse files
committed
icp: Use explicit_memset() exclusively in gcm_clear_ctx()
d634d20 fixed an information leak issue where GCC's optimization passes had removed `memset()` operations meant to sanitize sensitive data before memory is freed for use by the rest of the kernel. When I wrote it, I had assumed that the compiler would not remove the other `memset()` operations, but upon reflection, I have realized that this was a bad assumption to make. I would rather have a very slight amount of additional overhead when calling `gcm_clear_ctx()` than risk a future compiler remove `memset()` calls. This is likely to happen if someone decides to try doing link time optimization and the person will not think to audit the assembly output for issues like this, so it is best to preempt the possibility before it happens. Signed-off-by: Richard Yao <[email protected]>
1 parent d5616ad commit 7fb3224

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

module/icp/algs/modes/modes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,12 @@ gcm_clear_ctx(gcm_ctx_t *ctx)
173173
#if defined(CAN_USE_GCM_ASM)
174174
if (ctx->gcm_use_avx == B_TRUE) {
175175
ASSERT3P(ctx->gcm_Htable, !=, NULL);
176-
memset(ctx->gcm_Htable, 0, ctx->gcm_htab_len);
176+
explicit_memset(ctx->gcm_Htable, 0, ctx->gcm_htab_len);
177177
kmem_free(ctx->gcm_Htable, ctx->gcm_htab_len);
178178
}
179179
#endif
180180
if (ctx->gcm_pt_buf != NULL) {
181-
memset(ctx->gcm_pt_buf, 0, ctx->gcm_pt_buf_len);
181+
explicit_memset(ctx->gcm_pt_buf, 0, ctx->gcm_pt_buf_len);
182182
vmem_free(ctx->gcm_pt_buf, ctx->gcm_pt_buf_len);
183183
}
184184
/* Optional */

0 commit comments

Comments
 (0)