Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: sun8i-ss - Use kfree_sensitive

The kfree_sensitive is a kernel API to clear sensitive information
that should not be leaked to other future users of the same memory
objects and free the memory. Its function is the same as the
combination of memzero_explicit and kfree. Thus, we can replace the
combination APIs with the single kfree_sensitive API.

Signed-off-by: Jason Wang <wangborong@cdjrlc.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Jason Wang and committed by
Herbert Xu
192b722f ec2088b6

+3 -6
+3 -6
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-prng.c
··· 20 20 struct sun8i_ss_rng_tfm_ctx *ctx = crypto_rng_ctx(tfm); 21 21 22 22 if (ctx->seed && ctx->slen != slen) { 23 - memzero_explicit(ctx->seed, ctx->slen); 24 - kfree(ctx->seed); 23 + kfree_sensitive(ctx->seed); 25 24 ctx->slen = 0; 26 25 ctx->seed = NULL; 27 26 } ··· 47 48 { 48 49 struct sun8i_ss_rng_tfm_ctx *ctx = crypto_tfm_ctx(tfm); 49 50 50 - memzero_explicit(ctx->seed, ctx->slen); 51 - kfree(ctx->seed); 51 + kfree_sensitive(ctx->seed); 52 52 ctx->seed = NULL; 53 53 ctx->slen = 0; 54 54 } ··· 165 167 /* Update seed */ 166 168 memcpy(ctx->seed, d + dlen, ctx->slen); 167 169 } 168 - memzero_explicit(d, todo); 169 170 err_free: 170 - kfree(d); 171 + kfree_sensitive(d); 171 172 172 173 return err; 173 174 }