Skip to content

Commit 0bf13a8

Browse files
committed
Merge tag 'kernel-hardening-v5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull kernel hardening updates from Kees Cook: - usercopy hardening expanded to check other allocation types (Matthew Wilcox, Yuanzheng Song) - arm64 stackleak behavioral improvements (Mark Rutland) - arm64 CFI code gen improvement (Sami Tolvanen) - LoadPin LSM block dev API adjustment (Christoph Hellwig) - Clang randstruct support (Bill Wendling, Kees Cook) * tag 'kernel-hardening-v5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: (34 commits) loadpin: stop using bdevname mm: usercopy: move the virt_addr_valid() below the is_vmalloc_addr() gcc-plugins: randstruct: Remove cast exception handling af_unix: Silence randstruct GCC plugin warning niu: Silence randstruct warnings big_keys: Use struct for internal payload gcc-plugins: Change all version strings match kernel randomize_kstack: Improve docs on requirements/rationale lkdtm/stackleak: fix CONFIG_GCC_PLUGIN_STACKLEAK=n arm64: entry: use stackleak_erase_on_task_stack() stackleak: add on/off stack variants lkdtm/stackleak: check stack boundaries lkdtm/stackleak: prevent unexpected stack usage lkdtm/stackleak: rework boundary management lkdtm/stackleak: avoid spurious failure stackleak: rework poison scanning stackleak: rework stack high bound handling stackleak: clarify variable names stackleak: rework stack low bound handling stackleak: remove redundant check ...
2 parents 51518aa + ed5edd5 commit 0bf13a8

46 files changed

Lines changed: 539 additions & 449 deletions

Some content is hidden

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

Documentation/dontdiff

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ r200_reg_safe.h
211211
r300_reg_safe.h
212212
r420_reg_safe.h
213213
r600_reg_safe.h
214+
randstruct.seed
214215
randomize_layout_hash.h
215216
randomize_layout_seed.h
216217
recordmcount

Documentation/kbuild/reproducible-builds.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ unreproducible parts can be treated as sources:
9999
Structure randomisation
100100
-----------------------
101101

102-
If you enable ``CONFIG_GCC_PLUGIN_RANDSTRUCT``, you will need to
103-
pre-generate the random seed in
104-
``scripts/gcc-plugins/randomize_layout_seed.h`` so the same value
105-
is used in rebuilds.
102+
If you enable ``CONFIG_RANDSTRUCT``, you will need to pre-generate
103+
the random seed in ``scripts/basic/randstruct.seed`` so the same
104+
value is used by each build. See ``scripts/gen-randstruct-seed.sh``
105+
for details.
106106

107107
Debug info conflicts
108108
--------------------

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,7 @@ include-$(CONFIG_KASAN) += scripts/Makefile.kasan
10111011
include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
10121012
include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan
10131013
include-$(CONFIG_KCOV) += scripts/Makefile.kcov
1014+
include-$(CONFIG_RANDSTRUCT) += scripts/Makefile.randstruct
10141015
include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
10151016

10161017
include $(addprefix $(srctree)/, $(include-y))

arch/Kconfig

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -732,10 +732,7 @@ config ARCH_SUPPORTS_CFI_CLANG
732732
config CFI_CLANG
733733
bool "Use Clang's Control Flow Integrity (CFI)"
734734
depends on LTO_CLANG && ARCH_SUPPORTS_CFI_CLANG
735-
# Clang >= 12:
736-
# - https://bugs.llvm.org/show_bug.cgi?id=46258
737-
# - https://bugs.llvm.org/show_bug.cgi?id=47479
738-
depends on CLANG_VERSION >= 120000
735+
depends on CLANG_VERSION >= 140000
739736
select KALLSYMS
740737
help
741738
This option enables Clang’s forward-edge Control Flow Integrity

arch/arm/vdso/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
2828
CFLAGS_REMOVE_vdso.o = -pg
2929

3030
# Force -O2 to avoid libgcc dependencies
31-
CFLAGS_REMOVE_vgettimeofday.o = -pg -Os $(GCC_PLUGINS_CFLAGS)
31+
CFLAGS_REMOVE_vgettimeofday.o = -pg -Os $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS)
3232
ifeq ($(c-gettimeofday-y),)
3333
CFLAGS_vgettimeofday.o = -O2
3434
else

arch/arm64/include/asm/compiler.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,4 @@
2323
#define __builtin_return_address(val) \
2424
(void *)(ptrauth_clear_pac((unsigned long)__builtin_return_address(val)))
2525

26-
#ifdef CONFIG_CFI_CLANG
27-
/*
28-
* With CONFIG_CFI_CLANG, the compiler replaces function address
29-
* references with the address of the function's CFI jump table
30-
* entry. The function_nocfi macro always returns the address of the
31-
* actual function instead.
32-
*/
33-
#define function_nocfi(x) ({ \
34-
void *addr; \
35-
asm("adrp %0, " __stringify(x) "\n\t" \
36-
"add %0, %0, :lo12:" __stringify(x) \
37-
: "=r" (addr)); \
38-
addr; \
39-
})
40-
#endif
41-
4226
#endif /* __ASM_COMPILER_H */

arch/arm64/include/asm/processor.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,10 @@ long get_tagged_addr_ctrl(struct task_struct *task);
405405
* of header definitions for the use of task_stack_page.
406406
*/
407407

408-
#define current_top_of_stack() \
409-
({ \
410-
struct stack_info _info; \
411-
BUG_ON(!on_accessible_stack(current, current_stack_pointer, 1, &_info)); \
412-
_info.high; \
413-
})
408+
/*
409+
* The top of the current task's task stack
410+
*/
411+
#define current_top_of_stack() ((unsigned long)current->stack + THREAD_SIZE)
414412
#define on_thread_stack() (on_task_stack(current, current_stack_pointer, 1, NULL))
415413

416414
#endif /* __ASSEMBLY__ */

arch/arm64/kernel/entry.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ SYM_CODE_START_LOCAL(ret_to_user)
596596
ldr x19, [tsk, #TSK_TI_FLAGS] // re-check for single-step
597597
enable_step_tsk x19, x2
598598
#ifdef CONFIG_GCC_PLUGIN_STACKLEAK
599-
bl stackleak_erase
599+
bl stackleak_erase_on_task_stack
600600
#endif
601601
kernel_exit 0
602602
SYM_CODE_END(ret_to_user)

arch/arm64/kernel/vdso/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ ccflags-y += -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
3232
# -Wmissing-prototypes and -Wmissing-declarations are removed from
3333
# the CFLAGS of vgettimeofday.c to make possible to build the
3434
# kernel with CONFIG_WERROR enabled.
35-
CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_SCS) $(GCC_PLUGINS_CFLAGS) \
35+
CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_SCS) \
36+
$(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) \
3637
$(CC_FLAGS_LTO) -Wmissing-prototypes -Wmissing-declarations
3738
KASAN_SANITIZE := n
3839
KCSAN_SANITIZE := n

arch/riscv/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ config CC_HAVE_STACKPROTECTOR_TLS
468468

469469
config STACKPROTECTOR_PER_TASK
470470
def_bool y
471-
depends on !GCC_PLUGIN_RANDSTRUCT
471+
depends on !RANDSTRUCT
472472
depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS
473473

474474
config PHYS_RAM_BASE_FIXED

0 commit comments

Comments
 (0)