Skip to content

Commit a5ba183

Browse files
committed
Merge tag 'hardening-v6.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull hardening updates from Kees Cook: "One notable addition is the creation of the 'transitional' keyword for kconfig so CONFIG renaming can go more smoothly. This has been a long-standing deficiency, and with the renaming of CONFIG_CFI_CLANG to CONFIG_CFI (since GCC will soon have KCFI support), this came up again. The breadth of the diffstat is mainly this renaming. - Clean up usage of TRAILING_OVERLAP() (Gustavo A. R. Silva) - lkdtm: fortify: Fix potential NULL dereference on kmalloc failure (Junjie Cao) - Add str_assert_deassert() helper (Lad Prabhakar) - gcc-plugins: Remove TODO_verify_il for GCC >= 16 - kconfig: Fix BrokenPipeError warnings in selftests - kconfig: Add transitional symbol attribute for migration support - kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI" * tag 'hardening-v6.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: lib/string_choices: Add str_assert_deassert() helper kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI kconfig: Add transitional symbol attribute for migration support kconfig: Fix BrokenPipeError warnings in selftests gcc-plugins: Remove TODO_verify_il for GCC >= 16 stddef: Introduce __TRAILING_OVERLAP() stddef: Remove token-pasting in TRAILING_OVERLAP() lkdtm: fortify: Fix potential NULL dereference on kmalloc failure
2 parents a240a79 + c8a935a commit a5ba183

72 files changed

Lines changed: 461 additions & 96 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Documentation/kbuild/kconfig-language.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,38 @@ applicable everywhere (see syntax).
232232
enables the third modular state for all config symbols.
233233
At most one symbol may have the "modules" option set.
234234

235+
- transitional attribute: "transitional"
236+
This declares the symbol as transitional, meaning it should be processed
237+
during configuration but omitted from newly written .config files.
238+
Transitional symbols are useful for backward compatibility during config
239+
option migrations - they allow olddefconfig to process existing .config
240+
files while ensuring the old option doesn't appear in new configurations.
241+
242+
A transitional symbol:
243+
- Has no prompt (is not visible to users in menus)
244+
- Is processed normally during configuration (values are read and used)
245+
- Can be referenced in default expressions of other symbols
246+
- Is not written to new .config files
247+
- Cannot have any other properties (it is a pass-through option)
248+
249+
Example migration from OLD_NAME to NEW_NAME::
250+
251+
config NEW_NAME
252+
bool "New option name"
253+
default OLD_NAME
254+
help
255+
This replaces the old CONFIG_OLD_NAME option.
256+
257+
config OLD_NAME
258+
bool
259+
transitional
260+
help
261+
Transitional config for OLD_NAME to NEW_NAME migration.
262+
263+
With this setup, existing .config files with "CONFIG_OLD_NAME=y" will
264+
result in "CONFIG_NEW_NAME=y" being set, while CONFIG_OLD_NAME will be
265+
omitted from newly written .config files.
266+
235267
Menu dependencies
236268
-----------------
237269

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ KBUILD_AFLAGS += -fno-lto
10201020
export CC_FLAGS_LTO
10211021
endif
10221022

1023-
ifdef CONFIG_CFI_CLANG
1023+
ifdef CONFIG_CFI
10241024
CC_FLAGS_CFI := -fsanitize=kcfi
10251025
ifdef CONFIG_CFI_ICALL_NORMALIZE_INTEGERS
10261026
CC_FLAGS_CFI += -fsanitize-cfi-icall-experimental-normalize-integers

arch/Kconfig

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -867,22 +867,26 @@ config PROPELLER_CLANG
867867

868868
If unsure, say N.
869869

870-
config ARCH_SUPPORTS_CFI_CLANG
870+
config ARCH_SUPPORTS_CFI
871871
bool
872872
help
873-
An architecture should select this option if it can support Clang's
874-
Control-Flow Integrity (CFI) checking.
873+
An architecture should select this option if it can support Kernel
874+
Control-Flow Integrity (CFI) checking (-fsanitize=kcfi).
875875

876876
config ARCH_USES_CFI_TRAPS
877877
bool
878+
help
879+
An architecture should select this option if it requires the
880+
.kcfi_traps section for KCFI trap handling.
878881

879-
config CFI_CLANG
880-
bool "Use Clang's Control Flow Integrity (CFI)"
881-
depends on ARCH_SUPPORTS_CFI_CLANG
882+
config CFI
883+
bool "Use Kernel Control Flow Integrity (kCFI)"
884+
default CFI_CLANG
885+
depends on ARCH_SUPPORTS_CFI
882886
depends on $(cc-option,-fsanitize=kcfi)
883887
help
884-
This option enables Clang's forward-edge Control Flow Integrity
885-
(CFI) checking, where the compiler injects a runtime check to each
888+
This option enables forward-edge Control Flow Integrity (CFI)
889+
checking, where the compiler injects a runtime check to each
886890
indirect function call to ensure the target is a valid function with
887891
the correct static type. This restricts possible call targets and
888892
makes it more difficult for an attacker to exploit bugs that allow
@@ -891,10 +895,16 @@ config CFI_CLANG
891895

892896
https://clang.llvm.org/docs/ControlFlowIntegrity.html
893897

898+
config CFI_CLANG
899+
bool
900+
transitional
901+
help
902+
Transitional config for CFI_CLANG to CFI migration.
903+
894904
config CFI_ICALL_NORMALIZE_INTEGERS
895905
bool "Normalize CFI tags for integers"
896-
depends on CFI_CLANG
897-
depends on HAVE_CFI_ICALL_NORMALIZE_INTEGERS_CLANG
906+
depends on CFI
907+
depends on HAVE_CFI_ICALL_NORMALIZE_INTEGERS
898908
help
899909
This option normalizes the CFI tags for integer types so that all
900910
integer types of the same size and signedness receive the same CFI
@@ -907,23 +917,23 @@ config CFI_ICALL_NORMALIZE_INTEGERS
907917

908918
This option is necessary for using CFI with Rust. If unsure, say N.
909919

910-
config HAVE_CFI_ICALL_NORMALIZE_INTEGERS_CLANG
920+
config HAVE_CFI_ICALL_NORMALIZE_INTEGERS
911921
def_bool y
912922
depends on $(cc-option,-fsanitize=kcfi -fsanitize-cfi-icall-experimental-normalize-integers)
913923
# With GCOV/KASAN we need this fix: https://github.com/llvm/llvm-project/pull/104826
914924
depends on CLANG_VERSION >= 190103 || (!GCOV_KERNEL && !KASAN_GENERIC && !KASAN_SW_TAGS)
915925

916926
config HAVE_CFI_ICALL_NORMALIZE_INTEGERS_RUSTC
917927
def_bool y
918-
depends on HAVE_CFI_ICALL_NORMALIZE_INTEGERS_CLANG
928+
depends on HAVE_CFI_ICALL_NORMALIZE_INTEGERS
919929
depends on RUSTC_VERSION >= 107900
920930
# With GCOV/KASAN we need this fix: https://github.com/rust-lang/rust/pull/129373
921931
depends on (RUSTC_LLVM_VERSION >= 190103 && RUSTC_VERSION >= 108200) || \
922932
(!GCOV_KERNEL && !KASAN_GENERIC && !KASAN_SW_TAGS)
923933

924934
config CFI_PERMISSIVE
925935
bool "Use CFI in permissive mode"
926-
depends on CFI_CLANG
936+
depends on CFI
927937
help
928938
When selected, Control Flow Integrity (CFI) violations result in a
929939
warning instead of a kernel panic. This option should only be used

arch/arm/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ config ARM
3838
select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7
3939
select ARCH_NEED_CMPXCHG_1_EMU if CPU_V6
4040
select ARCH_SUPPORTS_ATOMIC_RMW
41-
select ARCH_SUPPORTS_CFI_CLANG
41+
select ARCH_SUPPORTS_CFI
4242
select ARCH_SUPPORTS_HUGETLBFS if ARM_LPAE
4343
select ARCH_SUPPORTS_PER_VMA_LOCK
4444
select ARCH_USE_BUILTIN_BSWAP

arch/arm/kernel/hw_breakpoint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ static void breakpoint_handler(unsigned long unknown, struct pt_regs *regs)
904904
watchpoint_single_step_handler(addr);
905905
}
906906

907-
#ifdef CONFIG_CFI_CLANG
907+
#ifdef CONFIG_CFI
908908
static void hw_breakpoint_cfi_handler(struct pt_regs *regs)
909909
{
910910
/*

arch/arm/mm/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ obj-$(CONFIG_CPU_V6) += proc-v6.o
8989
obj-$(CONFIG_CPU_V6K) += proc-v6.o
9090
obj-$(CONFIG_CPU_V7) += proc-v7.o proc-v7-bugs.o
9191
obj-$(CONFIG_CPU_V7M) += proc-v7m.o
92-
obj-$(CONFIG_CFI_CLANG) += proc.o
92+
obj-$(CONFIG_CFI) += proc.o
9393

9494
obj-$(CONFIG_OUTER_CACHE) += l2c-common.o
9595
obj-$(CONFIG_CACHE_B15_RAC) += cache-b15-rac.o

arch/arm/mm/cache-fa.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ SYM_FUNC_END(fa_flush_user_cache_range)
112112
* - end - virtual end address
113113
*/
114114
SYM_TYPED_FUNC_START(fa_coherent_kern_range)
115-
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
115+
#ifdef CONFIG_CFI /* Fallthrough if !CFI */
116116
b fa_coherent_user_range
117117
#endif
118118
SYM_FUNC_END(fa_coherent_kern_range)

arch/arm/mm/cache-v4.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ SYM_FUNC_END(v4_coherent_user_range)
104104
* - size - region size
105105
*/
106106
SYM_TYPED_FUNC_START(v4_flush_kern_dcache_area)
107-
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
107+
#ifdef CONFIG_CFI /* Fallthrough if !CFI */
108108
b v4_dma_flush_range
109109
#endif
110110
SYM_FUNC_END(v4_flush_kern_dcache_area)

arch/arm/mm/cache-v4wb.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ SYM_FUNC_END(v4wb_flush_user_cache_range)
136136
*/
137137
SYM_TYPED_FUNC_START(v4wb_flush_kern_dcache_area)
138138
add r1, r0, r1
139-
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
139+
#ifdef CONFIG_CFI /* Fallthrough if !CFI */
140140
b v4wb_coherent_user_range
141141
#endif
142142
SYM_FUNC_END(v4wb_flush_kern_dcache_area)
@@ -152,7 +152,7 @@ SYM_FUNC_END(v4wb_flush_kern_dcache_area)
152152
* - end - virtual end address
153153
*/
154154
SYM_TYPED_FUNC_START(v4wb_coherent_kern_range)
155-
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
155+
#ifdef CONFIG_CFI /* Fallthrough if !CFI */
156156
b v4wb_coherent_user_range
157157
#endif
158158
SYM_FUNC_END(v4wb_coherent_kern_range)

arch/arm/mm/cache-v4wt.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ SYM_FUNC_END(v4wt_flush_user_cache_range)
108108
* - end - virtual end address
109109
*/
110110
SYM_TYPED_FUNC_START(v4wt_coherent_kern_range)
111-
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
111+
#ifdef CONFIG_CFI /* Fallthrough if !CFI */
112112
b v4wt_coherent_user_range
113113
#endif
114114
SYM_FUNC_END(v4wt_coherent_kern_range)

0 commit comments

Comments
 (0)