linux-sg2042/include
Mikulas Patocka e5be15767e 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>
2022-04-27 10:57:33 -07:00
..
acpi ACPI: bus: Eliminate acpi_bus_get_device() 2022-04-05 19:49:26 +02:00
asm-generic block-5.18-2022-04-15 2022-04-15 11:38:55 -07:00
clocksource clocksource/drivers/arm_arch_timer: Use event stream scaling when available 2022-03-07 18:27:22 +01:00
crypto Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2022-03-21 16:02:36 -07:00
drm
dt-bindings RTC for 5.18 2022-04-01 09:37:18 -07:00
keys KEYS: Introduce link restriction for machine keys 2022-03-08 13:55:52 +02:00
kunit
kvm
linux hex2bin: make the function hex_to_bin constant-time 2022-04-27 10:57:33 -07:00
math-emu
media
memory
misc
net ipv6: make ip6_rt_gc_expire an atomic_t 2022-04-15 14:28:50 -07:00
pcmcia
ras mm/memory-failure.c: fix race with changing page compound again 2022-03-22 15:57:07 -07:00
rdma
scsi scsi: iscsi: Fix NOP handling during conn recovery 2022-04-11 22:09:35 -04:00
soc drm for 5.18-rc1 2022-03-24 16:19:43 -07:00
sound ASoC: Fixes for v5.18 2022-04-19 17:26:01 +02:00
target scsi: target: Add iscsi/cpus_allowed_list in configfs 2022-03-14 23:40:36 -04:00
trace NFSD bug fixes for 5.18-rc: 2022-04-12 14:23:19 -10:00
uapi fbdev fixes and updates for kernel v5.18-rc5 2022-04-26 11:32:01 -07:00
vdso
video
xen xen/grant-table: remove readonly parameter from functions 2022-03-15 20:34:40 -05:00