]> git.baikalelectronics.ru Git - kernel.git/commit
crypto: sha512 - remove imaginary and mystifying clearing of variables
authorLukas Bulwahn <lukas.bulwahn@gmail.com>
Sun, 22 Aug 2021 10:31:07 +0000 (12:31 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 27 Aug 2021 08:30:19 +0000 (16:30 +0800)
commitb112ce94edf438ae3cac1e1ab08d49d90fd9b126
treec1f294b6673237f11a715d152831b6975d3b9b49
parent50e24a9ab36502c8d6fb91788f25006771b488a6
crypto: sha512 - remove imaginary and mystifying clearing of variables

The function sha512_transform() assigns all local variables to 0 before
returning to its caller with the intent to erase sensitive data.

However, make clang-analyzer warns that all these assignments are dead
stores, and as commit f163d60a4140 ("crypto: lib/sha256 - Don't clear
temporary variables") already points out for sha256_transform():

  The assignments to clear a through h and t1/t2 are optimized out by the
  compiler because they are unused after the assignments.

  Clearing individual scalar variables is unlikely to be useful, as they
  may have been assigned to registers, and even if stack spilling was
  required, there may be compiler-generated temporaries that are
  impossible to clear in any case.

This applies here again as well. Drop meaningless clearing of local
variables and avoid this way that the code suggests that data is erased,
which simply does not happen.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/sha512_generic.c