Go to file
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
android ANDROID: fix up abi issue with struct snd_pcm_runtime 2022-05-18 14:50:41 +02:00
arch UPSTREAM: lib/crypto: blake2s: avoid indirect calls to compression function for Clang CFI 2022-07-07 17:14:19 +00:00
block This is the 4.19.247 stable release 2022-06-14 17:16:36 +02:00
certs certs: Trigger creation of RSA module signing key if it's not an RSA key 2021-09-22 11:47:51 +02:00
crypto UPSTREAM: lib/crypto: blake2s: avoid indirect calls to compression function for Clang CFI 2022-07-07 17:14:19 +00:00
Documentation This is the 4.19.248 stable release 2022-06-30 10:17:46 +02:00
drivers BACKPORT: lib/crypto: blake2s: include as built-in 2022-07-07 17:14:19 +00:00
firmware Fix built-in early-load Intel microcode alignment 2020-01-23 08:21:29 +01:00
fs UPSTREAM: ext4: verify dir block before splitting it 2022-06-30 08:11:00 +00:00
include UPSTREAM: lib/crypto: blake2s: avoid indirect calls to compression function for Clang CFI 2022-07-07 17:14:19 +00:00
init This is the 4.19.238 stable release 2022-04-18 09:57:50 +02:00
ipc shm: extend forced shm destroy to support objects from several IPC nses 2021-12-08 08:50:11 +01:00
kernel This is the 4.19.247 stable release 2022-06-14 17:16:36 +02:00
lib UPSTREAM: lib/crypto: blake2s: avoid indirect calls to compression function for Clang CFI 2022-07-07 17:14:19 +00:00
LICENSES LICENSES: Remove CC-BY-SA-4.0 license text 2018-10-18 11:28:50 +02:00
mm UPSTREAM: mm: fix misplaced unlock_page in do_wp_page() 2022-07-06 18:47:22 -07:00
net This is the 4.19.247 stable release 2022-06-14 17:16:36 +02:00
samples This is the 4.19.218 stable release 2021-11-26 15:19:33 +01:00
scripts This is the 4.19.247 stable release 2022-06-14 17:16:36 +02:00
security This is the 4.19.238 stable release 2022-04-18 09:57:50 +02:00
sound Revert "ALSA: jack: Access input_dev under mutex" 2022-06-21 20:47:34 +02:00
tools This is the 4.19.247 stable release 2022-06-14 17:16:36 +02:00
usr initramfs: restore default compression behavior 2020-04-13 10:44:59 +02:00
virt KVM: Prevent module exit until all VMs are freed 2022-04-15 14:14:57 +02:00
.clang-format clang-format: Set IndentWrappedFunctionNames false 2018-08-01 18:38:51 +02:00
.cocciconfig
.get_maintainer.ignore
.gitattributes .gitattributes: set git diff driver for C source code files 2016-10-07 18:46:30 -07:00
.gitignore Kbuild updates for v4.17 (2nd) 2018-04-15 17:21:30 -07:00
.mailmap libnvdimm-for-4.19_misc 2018-08-25 18:13:10 -07:00
build.config.aarch64 ANDROID: enable LLVM_IAS=1 for clang's integrated assembler for aarch64 2021-01-11 17:34:43 -08:00
build.config.allmodconfig ANDROID: Different fix for KABI breakage in 4.19.209 in struct sock 2021-10-11 19:44:01 +00:00
build.config.allmodconfig.aarch64 ANDROID: drop KERNEL_DIR setting in build.config.common 2020-09-25 15:14:51 +08:00
build.config.allmodconfig.arm ANDROID: drop KERNEL_DIR setting in build.config.common 2020-09-25 15:14:51 +08:00
build.config.allmodconfig.x86_64 ANDROID: drop KERNEL_DIR setting in build.config.common 2020-09-25 15:14:51 +08:00
build.config.arm Revert "ANDROID: Kbuild, LLVMLinux: allow overriding clang target triple" 2020-11-10 11:47:24 -08:00
build.config.common ANDROID: clang: update to 12.0.5 2021-04-19 19:40:51 +00:00
build.config.gki ANDROID: gki: Removed cf modules from gki_defconfig 2020-01-31 16:23:38 -08:00
build.config.gki_kasan ANDROID: build_config: drop CONFIG_KASAN_PANIC_ON_WARN 2021-02-15 18:29:34 +00:00
build.config.gki_kasan.aarch64 ANDROID: drop KERNEL_DIR setting in build.config.common 2020-09-25 15:14:51 +08:00
build.config.gki_kasan.x86_64 ANDROID: drop KERNEL_DIR setting in build.config.common 2020-09-25 15:14:51 +08:00
build.config.gki_kprobes ANDROID: Adding kprobes build configs for Cuttlefish 2021-02-28 05:19:39 +00:00
build.config.gki_kprobes.aarch64 ANDROID: Adding kprobes build configs for Cuttlefish 2021-02-28 05:19:39 +00:00
build.config.gki_kprobes.x86_64 ANDROID: Adding kprobes build configs for Cuttlefish 2021-02-28 05:19:39 +00:00
build.config.gki-debug.aarch64 ANDROID: drop KERNEL_DIR setting in build.config.common 2020-09-25 15:14:51 +08:00
build.config.gki-debug.x86_64 ANDROID: drop KERNEL_DIR setting in build.config.common 2020-09-25 15:14:51 +08:00
build.config.gki.aarch64 ANDROID: GKI: prevent removal of monitored symbols 2020-09-29 11:48:43 +01:00
build.config.gki.x86_64 ANDROID: drop KERNEL_DIR setting in build.config.common 2020-09-25 15:14:51 +08:00
build.config.x86_64 Revert "Revert "ANDROID: enable LLVM_IAS=1 for clang's integrated assembler for x86_64"" 2021-02-03 13:34:51 -08:00
COPYING COPYING: use the new text with points to the license files 2018-03-23 12:41:45 -06:00
CREDITS 9p: remove Ron Minnich from MAINTAINERS 2018-08-17 16:20:26 -07:00
Kbuild Kbuild updates for v4.15 2017-11-17 17:45:29 -08:00
Kconfig kconfig: move the "Executable file formats" menu to fs/Kconfig.binfmt 2018-08-02 08:06:55 +09:00
MAINTAINERS UPSTREAM: net: WireGuard secure network tunnel 2020-10-25 11:48:12 +01:00
Makefile This is the 4.19.248 stable release 2022-06-30 10:17:46 +02:00
OWNERS ANDROID: Add OWNERS files referring to the respective android-mainline OWNERS 2021-04-03 14:09:44 +00:00
README Docs: Added a pointer to the formatted docs to README 2018-03-21 09:02:53 -06:00

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.
See Documentation/00-INDEX for a list of what is contained in each file.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.