[PW_SID:995285] kcfi: Prepare for GCC support - #831
Conversation
Prepare for GCC KCFI support and move the __nocfi attribute from compiler-clang.h to compiler_types.h. This was already effectively gated by CONFIG_CFI_CLANG, so this remains safe for non-KCFI GCC builds. Signed-off-by: Kees Cook <kees@outflux.net> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Just a nit-picky change to the KCFI indirect call check instruction documentation. The addl offset isn't always -4 (it depends on patchable function entry configuration). Signed-off-by: Kees Cook <kees@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add "debug" option for "cfi=" bootparam to get details on early CFI initialization steps. Standardize CFI pr_info() lines to use "CFI:" prefix. Standardize "CFI: Using ..." to always report which CFI mode is being used, regardless of CONFIG_FINEIBT. Document all the "cfi=" options. Signed-off-by: Kees Cook <kees@outflux.net> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Commit 66f7930 ("x86/retpoline: Avoid retpolines for built-in __init functions") disabled retpolines in __init sections (__noinitretpoline) as a precaution against potential issues with retpolines in early boot, but it has not been a problem in practice (i.e. see Clang below). Commit 8735871 ("x86/retpoline: Support retpoline builds with Clang") narrowed this to only GCC, as Clang doesn't have per-function control over retpoline emission. As such, Clang has been booting with retpolines in __init since retpoline support was introduced. Clang KCFI has been instrumenting __init since CFI was introduced. With the introduction of KCFI for GCC, KCFI instrumentation with retpolines disabled means that objtool does not construct .retpoline_sites section entries for the non-retpoline KCFI calls. At boot, the KCFI rehashing code, via __apply_fineibt(), misses all __init KCFI calls (since they are not retpolines), resulting in immediate hash mismatches: all preambles are rehashed (via .cfi_sites) and none of the __init call sites are rehashed. Remove __noinitretpoline since it provides no meaningful utility and creates problems with CFI. Additionally remove __noretpoline since it is now unused. Alternatively, cfi_rand_callers() could walk the .kcfi_traps section which is exactly the list of KCFI instrumentation sites. But it seems better to have as few differences in common instruction sequences between compilers as possible, so better to remove the special handling of retpolines in __init for GCC. Signed-off-by: Kees Cook <kees@outflux.net> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The kernel's CFI implementation uses the KCFI ABI specifically, and is not strictly tied to a particular compiler. In preparation for GCC supporting KCFI[1], rename CONFIG_CFI_CLANG to CONFIG_CFI (along with associated options). Link: https://lore.kernel.org/linux-hardening/20250821064202.work.893-kees@kernel.org [1] Signed-off-by: Kees Cook <kees@outflux.net> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[1/5] compiler_types.h: Move __nocfi out of compiler-specific header" |
|
Patch 1: "[1/5] compiler_types.h: Move __nocfi out of compiler-specific header" |
|
Patch 1: "[1/5] compiler_types.h: Move __nocfi out of compiler-specific header" |
|
Patch 1: "[1/5] compiler_types.h: Move __nocfi out of compiler-specific header" |
|
Patch 1: "[1/5] compiler_types.h: Move __nocfi out of compiler-specific header" |
|
Patch 1: "[1/5] compiler_types.h: Move __nocfi out of compiler-specific header" |
|
Patch 1: "[1/5] compiler_types.h: Move __nocfi out of compiler-specific header" |
|
Patch 1: "[1/5] compiler_types.h: Move __nocfi out of compiler-specific header" |
|
Patch 1: "[1/5] compiler_types.h: Move __nocfi out of compiler-specific header" |
|
Patch 1: "[1/5] compiler_types.h: Move __nocfi out of compiler-specific header" |
|
Patch 1: "[1/5] compiler_types.h: Move __nocfi out of compiler-specific header" |
|
Patch 1: "[1/5] compiler_types.h: Move __nocfi out of compiler-specific header" |
|
Patch 2: "[2/5] x86/traps: Clarify KCFI instruction layout" |
|
Patch 2: "[2/5] x86/traps: Clarify KCFI instruction layout" |
|
Patch 2: "[2/5] x86/traps: Clarify KCFI instruction layout" |
|
Patch 2: "[2/5] x86/traps: Clarify KCFI instruction layout" |
|
Patch 2: "[2/5] x86/traps: Clarify KCFI instruction layout" |
|
Patch 2: "[2/5] x86/traps: Clarify KCFI instruction layout" |
|
Patch 2: "[2/5] x86/traps: Clarify KCFI instruction layout" |
|
Patch 2: "[2/5] x86/traps: Clarify KCFI instruction layout" |
|
Patch 2: "[2/5] x86/traps: Clarify KCFI instruction layout" |
|
Patch 2: "[2/5] x86/traps: Clarify KCFI instruction layout" |
|
Patch 2: "[2/5] x86/traps: Clarify KCFI instruction layout" |
|
Patch 2: "[2/5] x86/traps: Clarify KCFI instruction layout" |
|
Patch 3: "[3/5] x86/cfi: Add option for cfi=debug bootparam" |
|
Patch 3: "[3/5] x86/cfi: Add option for cfi=debug bootparam" |
|
Patch 3: "[3/5] x86/cfi: Add option for cfi=debug bootparam" |
|
Patch 3: "[3/5] x86/cfi: Add option for cfi=debug bootparam" |
|
Patch 3: "[3/5] x86/cfi: Add option for cfi=debug bootparam" |
|
Patch 4: "[4/5] x86/cfi: Remove __noinitretpoline and __noretpoline" |
|
Patch 4: "[4/5] x86/cfi: Remove __noinitretpoline and __noretpoline" |
|
Patch 4: "[4/5] x86/cfi: Remove __noinitretpoline and __noretpoline" |
|
Patch 4: "[4/5] x86/cfi: Remove __noinitretpoline and __noretpoline" |
|
Patch 4: "[4/5] x86/cfi: Remove __noinitretpoline and __noretpoline" |
|
Patch 4: "[4/5] x86/cfi: Remove __noinitretpoline and __noretpoline" |
|
Patch 4: "[4/5] x86/cfi: Remove __noinitretpoline and __noretpoline" |
|
Patch 4: "[4/5] x86/cfi: Remove __noinitretpoline and __noretpoline" |
|
Patch 4: "[4/5] x86/cfi: Remove __noinitretpoline and __noretpoline" |
|
Patch 4: "[4/5] x86/cfi: Remove __noinitretpoline and __noretpoline" |
|
Patch 4: "[4/5] x86/cfi: Remove __noinitretpoline and __noretpoline" |
|
Patch 4: "[4/5] x86/cfi: Remove __noinitretpoline and __noretpoline" |
|
Patch 5: "[5/5] kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI" |
|
Patch 5: "[5/5] kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI" |
|
Patch 5: "[5/5] kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI" |
|
Patch 5: "[5/5] kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI" |
|
Patch 5: "[5/5] kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI" |
|
Patch 5: "[5/5] kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI" |
|
Patch 5: "[5/5] kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI" |
|
Patch 5: "[5/5] kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI" |
|
Patch 5: "[5/5] kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI" |
|
Patch 5: "[5/5] kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI" |
|
Patch 5: "[5/5] kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI" |
|
Patch 5: "[5/5] kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI" |
PR for series 995285 applied to workflow__riscv__fixes
Name: kcfi: Prepare for GCC support
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=995285
Version: 1