WSL2-Linux-Kernel/arch/arm
Jason A. Donenfeld d2a02e3c8b lib/crypto: blake2s: avoid indirect calls to compression function for Clang CFI
blake2s_compress_generic is weakly aliased by blake2s_compress. The
current harness for function selection uses a function pointer, which is
ordinarily inlined and resolved at compile time. But when Clang's CFI is
enabled, CFI still triggers when making an indirect call via a weak
symbol. This seems like a bug in Clang's CFI, as though it's bucketing
weak symbols and strong symbols differently. It also only seems to
trigger when "full LTO" mode is used, rather than "thin LTO".

[    0.000000][    T0] Kernel panic - not syncing: CFI failure (target: blake2s_compress_generic+0x0/0x1444)
[    0.000000][    T0] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.16.0-mainline-06981-g076c855b846e #1
[    0.000000][    T0] Hardware name: MT6873 (DT)
[    0.000000][    T0] Call trace:
[    0.000000][    T0]  dump_backtrace+0xfc/0x1dc
[    0.000000][    T0]  dump_stack_lvl+0xa8/0x11c
[    0.000000][    T0]  panic+0x194/0x464
[    0.000000][    T0]  __cfi_check_fail+0x54/0x58
[    0.000000][    T0]  __cfi_slowpath_diag+0x354/0x4b0
[    0.000000][    T0]  blake2s_update+0x14c/0x178
[    0.000000][    T0]  _extract_entropy+0xf4/0x29c
[    0.000000][    T0]  crng_initialize_primary+0x24/0x94
[    0.000000][    T0]  rand_initialize+0x2c/0x6c
[    0.000000][    T0]  start_kernel+0x2f8/0x65c
[    0.000000][    T0]  __primary_switched+0xc4/0x7be4
[    0.000000][    T0] Rebooting in 5 seconds..

Nonetheless, the function pointer method isn't so terrific anyway, so
this patch replaces it with a simple boolean, which also gets inlined
away. This successfully works around the Clang bug.

In general, I'm not too keen on all of the indirection involved here; it
clearly does more harm than good. Hopefully the whole thing can get
cleaned up down the road when lib/crypto is overhauled more
comprehensively. But for now, we go with a simple bandaid.

Fixes: 6048fdcc5f ("lib/crypto: blake2s: include as built-in")
Link: https://github.com/ClangBuiltLinux/linux/issues/1567
Reported-by: Miles Chen <miles.chen@mediatek.com>
Tested-by: Miles Chen <miles.chen@mediatek.com>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: John Stultz <john.stultz@linaro.org>
Acked-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2022-02-04 19:22:32 +01:00
..
boot Kbuild updates for v5.17 2022-01-19 11:15:19 +02:00
common Merge branches 'devel-stable' and 'misc' into for-linus 2021-11-02 09:04:22 +00:00
configs mm: remove cleancache 2022-01-22 08:33:38 +02:00
crypto lib/crypto: blake2s: avoid indirect calls to compression function for Clang CFI 2022-02-04 19:22:32 +01:00
include ARM fixes for 5.17-rc: 2022-01-25 08:02:46 +02:00
kernel proc: remove PDE_DATA() completely 2022-01-22 08:33:37 +02:00
lib
mach-actions
mach-alpine
mach-artpec
mach-asm9260
mach-aspeed
mach-at91 ARM: at91: pm: Add of_node_put() before goto 2021-12-08 14:01:16 +01:00
mach-axxia
mach-bcm Devicetree updates for v5.16: 2021-11-02 22:22:13 -07:00
mach-berlin
mach-clps711x
mach-cns3xxx
mach-davinci
mach-digicolor
mach-dove arm: ioremap: Replace pci_ioremap_io() usage by pci_remap_iospace() 2021-12-07 17:36:16 +00:00
mach-ep93xx ep93xx: clock: convert in-place to COMMON_CLK 2021-10-20 17:46:36 +02:00
mach-exynos ARM: samsung: Remove HAVE_S3C2410_I2C and use direct dependencies 2021-11-21 17:46:18 +01:00
mach-footbridge
mach-gemini
mach-highbank
mach-hisi memblock: rename memblock_free to memblock_phys_free 2021-11-06 13:30:41 -07:00
mach-imx ARM: imx: remove dead left-over from i.MX{27,31,35} removal 2021-11-21 16:38:41 +08:00
mach-integrator clk: versatile: Rename ICST to CLK_ICST 2021-10-14 18:00:25 -07:00
mach-iop32x arm: ioremap: Replace pci_ioremap_io() usage by pci_remap_iospace() 2021-12-07 17:36:16 +00:00
mach-ixp4xx ARM: ixp4xx: remove dead configs CPU_IXP43X and CPU_IXP46X 2021-12-06 02:18:25 +01:00
mach-keystone
mach-lpc18xx
mach-lpc32xx
mach-mediatek
mach-meson
mach-milbeaut
mach-mmp
mach-moxart
mach-mstar
mach-mv78xx0 arm: ioremap: Replace pci_ioremap_io() usage by pci_remap_iospace() 2021-12-07 17:36:16 +00:00
mach-mvebu
mach-mxs
mach-nomadik
mach-npcm
mach-nspire
mach-omap1 Updates for the interrupt subsystem: 2021-11-01 13:09:10 -07:00
mach-omap2 ARM: SoC updates for v5.16 2021-11-03 16:48:32 -07:00
mach-orion5x arm: ioremap: Replace pci_ioremap_io() usage by pci_remap_iospace() 2021-12-07 17:36:16 +00:00
mach-oxnas
mach-pxa spi: pxa2xx: Get rid of unused ->cs_control() 2021-11-29 12:19:59 +00:00
mach-qcom ARM: SoC drivers for 5.16 2021-11-03 17:00:52 -07:00
mach-rda
mach-realtek
mach-realview clk: versatile: Rename ICST to CLK_ICST 2021-10-14 18:00:25 -07:00
mach-rockchip ARM: rockchip: Use memcpy_toio instead of memcpy on smp bring-up 2021-11-21 18:24:31 +01:00
mach-rpc
mach-s3c ARM: samsung: Remove HAVE_S3C2410_I2C and use direct dependencies 2021-11-21 17:46:18 +01:00
mach-s5pv210 ARM: samsung: Remove HAVE_S3C2410_I2C and use direct dependencies 2021-11-21 17:46:18 +01:00
mach-sa1100 ARM: 9101/1: sa1100/assabet: convert LEDs to gpiod APIs 2021-10-25 13:11:54 +01:00
mach-shmobile ARM: shmobile: rcar-gen2: Add missing of_node_put() 2021-11-15 09:58:53 +01:00
mach-socfpga ARM: socfpga: Fix crash with CONFIG_FORTIRY_SOURCE 2021-11-18 16:19:40 -06:00
mach-spear
mach-sti
mach-stm32
mach-sunxi
mach-tegra
mach-uniphier
mach-ux500 clk: ux500: Add driver for the reset portions of PRCC 2021-10-26 18:06:05 -07:00
mach-versatile clk: versatile: Rename ICST to CLK_ICST 2021-10-14 18:00:25 -07:00
mach-vexpress clk: versatile: Rename ICST to CLK_ICST 2021-10-14 18:00:25 -07:00
mach-vt8500
mach-zynq
mm kernel/sysctl.c: rename sysctl_init() to sysctl_init_bases() 2022-01-22 08:33:36 +02:00
net bpf, docs: Prune all references to "internal BPF" 2021-11-30 10:52:11 -08:00
nwfpe
plat-omap
plat-orion
plat-pxa
plat-versatile
probes ARM: 9170/1: fix panic when kasan and kprobe are enabled 2022-01-19 11:10:53 +00:00
tools mm/mempolicy: wire up syscall set_mempolicy_home_node 2022-01-15 16:30:30 +02:00
vdso
vfp
xen arm/xen: Read extended regions from DT and init Xen resource 2022-01-06 09:53:41 +01:00
Kbuild kbuild: use more subdir- for visiting subdirectories while cleaning 2021-10-24 13:49:46 +09:00
Kconfig ftrace: Have architectures opt-in for mcount build time sorting 2022-01-27 19:15:44 -05:00
Kconfig-nommu
Kconfig.assembler
Kconfig.debug Kbuild updates for v5.17 2022-01-19 11:15:19 +02:00
Makefile ARM fixes for 5.16-rc1: 2021-11-14 11:30:50 -08:00