android_kernel_xiaomi_sm7250/arch/arm
Jason A. Donenfeld 107101e75a UPSTREAM: 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: 6048fdcc5f26 ("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>

(cherry picked from commit d2a02e3c8bb6b347818518edff5a4b40ff52d6d8)
Change-Id: I3a6461e3f05f57cd898f8a4f46e73fb0214037ef
Signed-off-by: Eric Biggers <ebiggers@google.com>
2022-07-07 17:14:19 +00:00
..
boot This is the 4.19.247 stable release 2022-06-14 17:16:36 +02:00
common
configs UPSTREAM: ARM: bcm2835_defconfig: Explicitly restore CONFIG_DEBUG_FS 2020-11-16 07:43:08 +01:00
crypto UPSTREAM: lib/crypto: blake2s: avoid indirect calls to compression function for Clang CFI 2022-07-07 17:14:19 +00:00
firmware
include This is the 4.19.236 stable release 2022-03-23 12:26:14 +01:00
kernel This is the 4.19.245 stable release 2022-05-25 10:36:58 +02:00
kvm
lib
mach-actions
mach-alpine
mach-artpec
mach-asm9260
mach-aspeed
mach-at91
mach-axxia
mach-bcm
mach-berlin
mach-clps711x
mach-cns3xxx
mach-davinci ARM: davinci: da850-evm: Avoid NULL pointer dereference 2022-04-20 09:12:50 +02:00
mach-digicolor
mach-dove
mach-ebsa110
mach-efm32
mach-ep93xx
mach-exynos
mach-footbridge ARM: footbridge: fix PCI interrupt mapping 2021-04-28 13:16:51 +02:00
mach-gemini
mach-highbank
mach-hisi ARM: hisi: Add missing of_node_put after of_find_compatible_node 2022-06-14 16:59:18 +02:00
mach-imx ARM: imx6: disable the GIC CPU interface before calling stby-poweroff sequence 2021-10-13 10:10:51 +02:00
mach-integrator
mach-iop13xx
mach-iop32x
mach-iop33x
mach-ixp4xx
mach-keystone ARM: keystone: fix integer overflow warning 2021-04-28 13:16:49 +02:00
mach-ks8695
mach-lpc18xx
mach-lpc32xx
mach-mediatek
mach-meson
mach-mmp ARM: mmp: Fix failure to remove sram device 2022-04-15 14:14:56 +02:00
mach-moxart
mach-mv78xx0
mach-mvebu
mach-mxs
mach-netx
mach-nomadik
mach-npcm
mach-nspire
mach-omap1 ARM: OMAP1: clock: Fix UART rate reporting algorithm 2022-06-14 16:59:18 +02:00
mach-omap2 This is the 4.19.242 stable release 2022-05-12 13:22:32 +02:00
mach-orion5x
mach-oxnas
mach-picoxcell
mach-prima2
mach-pxa
mach-qcom
mach-realview
mach-rockchip
mach-rpc
mach-s3c24xx ARM: 9187/1: JIVE: fix return value of __setup handler 2022-04-15 14:15:00 +02:00
mach-s3c64xx
mach-s5pv210
mach-sa1100
mach-shmobile soc: renesas: rmobile-sysc: Fix some leaks in rmobile_init_pm_domains() 2020-12-30 11:25:49 +01:00
mach-socfpga ARM: socfpga: Fix crash with CONFIG_FORTIRY_SOURCE 2021-12-01 09:27:42 +01:00
mach-spear
mach-sti
mach-stm32
mach-sunxi ARM: sunxi: Add machine match for the Allwinner V3 SoC 2020-12-30 11:26:06 +01:00
mach-tango
mach-tegra
mach-u300
mach-uniphier
mach-ux500
mach-versatile
mach-vexpress ARM: versatile: Add missing of_node_put in dcscb_init 2022-06-14 16:59:18 +02:00
mach-vt8500
mach-w90x900
mach-zx
mach-zynq
mm This is the 4.19.245 stable release 2022-05-25 10:36:58 +02:00
net bpf, arm: Fix register clobbering in div/mod implementation 2021-10-13 10:10:51 +02:00
nwfpe
oprofile
plat-iop
plat-omap
plat-orion
plat-pxa
plat-samsung ARM: samsung: fix PM debug build with DEBUG_LL but !MMU 2020-11-05 11:08:55 +01:00
plat-versatile
probes ARM: 9139/1: kprobes: fix arch_init_kprobes() prototype 2021-11-02 18:26:43 +01:00
tools
vdso ARM: 8867/1: vdso: pass --be8 to linker if necessary 2020-10-17 10:12:56 +02:00
vfp
xen Xen/gnttab: handle p2m update errors on a per-slot basis 2021-03-07 12:19:01 +01:00
Kconfig Merge 4.19.214 into android-4.19-stable 2021-11-02 17:58:57 +01:00
Kconfig-nommu
Kconfig.debug Revert "ARM: 8800/1: use choice for kernel unwinders" 2021-12-28 13:39:06 +01:00
Makefile This is the 4.19.218 stable release 2021-11-26 15:19:33 +01:00
OWNERS ANDROID: Add OWNERS files referring to the respective android-mainline OWNERS 2021-04-03 14:09:44 +00:00