summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2022-04-25 08:07:48 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2022-04-27 10:57:33 -0700
commite5be15767e7e284351853cbaba80cde8620341fb (patch)
tree1e6b72cefe3c46ea6a61ea625aa425e5b0dbd592 /crypto
parent211ed5480aff457ac1a9e333e68522ef4a0c6ce9 (diff)
downloadlinux-e5be15767e7e284351853cbaba80cde8620341fb.tar.bz2
hex2bin: make the function hex_to_bin constant-time
The function hex2bin is used to load cryptographic keys into device mapper targets dm-crypt and dm-integrity. It should take constant time independent on the processed data, so that concurrently running unprivileged code can't infer any information about the keys via microarchitectural convert channels. This patch changes the function hex_to_bin so that it contains no branches and no memory accesses. Note that this shouldn't cause performance degradation because the size of the new function is the same as the size of the old function (on x86-64) - and the new function causes no branch misprediction penalties. I compile-tested this function with gcc on aarch64 alpha arm hppa hppa64 i386 ia64 m68k mips32 mips64 powerpc powerpc64 riscv sh4 s390x sparc32 sparc64 x86_64 and with clang on aarch64 arm hexagon i386 mips32 mips64 powerpc powerpc64 s390x sparc32 sparc64 x86_64 to verify that there are no branches in the generated code. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Cc: stable@vger.kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'crypto')
0 files changed, 0 insertions, 0 deletions