mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-26 05:34:13 +08:00
582c161cf3
- Fix KMSAN vs FORTIFY in strlcpy/strlcat (Alexander Potapenko) - Convert strreplace() to return string start (Andy Shevchenko) - Flexible array conversions (Arnd Bergmann, Wyes Karny, Kees Cook) - Add missing function prototypes seen with W=1 (Arnd Bergmann) - Fix strscpy() kerndoc typo (Arne Welzel) - Replace strlcpy() with strscpy() across many subsystems which were either Acked by respective maintainers or were trivial changes that went ignored for multiple weeks (Azeem Shaikh) - Remove unneeded cc-option test for UBSAN_TRAP (Nick Desaulniers) - Add KUnit tests for strcat()-family - Enable KUnit tests of FORTIFY wrappers under UML - Add more complete FORTIFY protections for strlcat() - Add missed disabling of FORTIFY for all arch purgatories. - Enable -fstrict-flex-arrays=3 globally - Tightening UBSAN_BOUNDS when using GCC - Improve checkpatch to check for strcpy, strncpy, and fake flex arrays - Improve use of const variables in FORTIFY - Add requested struct_size_t() helper for types not pointers - Add __counted_by macro for annotating flexible array size members -----BEGIN PGP SIGNATURE----- iQJKBAABCgA0FiEEpcP2jyKd1g9yPm4TiXL039xtwCYFAmSbftQWHGtlZXNjb29r QGNocm9taXVtLm9yZwAKCRCJcvTf3G3AJj0MD/9X9jzJzCmsAU+yNldeoAzC84Sk GVU3RBxGcTNysL1gZXynkIgigw7DWc4htMGeSABHHwQRVP65JCH1Kw/VqIkyumbx 9LdX6IklMJb4pRT4PVU3azebV4eNmSjlur2UxMeW54Czm91/6I8RHbJOyAPnOUmo 2oomGdP/hpEHtKR7hgy8Axc6w5ySwQixh2V5sVZG3VbvCS5WKTmTXbs6puuRT5hz iHt7v+7VtEg/Qf1W7J2oxfoghvVBsaRrSLrExWT/oZYh1ZxM7DsCAAoG/IsDgHGA 9LBXiRECgAFThbHVxLvvKZQMXdVk0i8iXLX43XMKC0wTA+NTyH7wlcQQ4RWNMuo8 sfA9Qm9gMArXaf64aymr3Uwn20Zan0391HdlbhOJZAE6v3PPJbleUnM58AzD2d3r 5Lz6AIFBxDImy+3f9iDWgacCT5/PkeiXTHzk9QnKhJyKKtRA58XJxj4q2+rPnGJP n4haXqoxD5FJbxdXiGKk31RS0U5HBug7wkOcUrTqDHUbc/QNU2b7dxTKUx+zYtCU uV5emPzpF4H4z+91WpO47n9gkMAfwV0lt9S2dwS8pxsgqctbmIan+Jgip7rsqZ2G OgLXBsb43eEs+6WgO8tVt/ZHYj9ivGMdrcNcsIfikzNs/xweUJ53k2xSEn2xEa5J cwANDmkL6QQK7yfeeg== =s0j1 -----END PGP SIGNATURE----- Merge tag 'hardening-v6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux Pull hardening updates from Kees Cook: "There are three areas of note: A bunch of strlcpy()->strscpy() conversions ended up living in my tree since they were either Acked by maintainers for me to carry, or got ignored for multiple weeks (and were trivial changes). The compiler option '-fstrict-flex-arrays=3' has been enabled globally, and has been in -next for the entire devel cycle. This changes compiler diagnostics (though mainly just -Warray-bounds which is disabled) and potential UBSAN_BOUNDS and FORTIFY _warning_ coverage. In other words, there are no new restrictions, just potentially new warnings. Any new FORTIFY warnings we've seen have been fixed (usually in their respective subsystem trees). For more details, see commitdf8fc4e934
. The under-development compiler attribute __counted_by has been added so that we can start annotating flexible array members with their associated structure member that tracks the count of flexible array elements at run-time. It is possible (likely?) that the exact syntax of the attribute will change before it is finalized, but GCC and Clang are working together to sort it out. Any changes can be made to the macro while we continue to add annotations. As an example of that last case, I have a treewide commit waiting with such annotations found via Coccinelle: https://git.kernel.org/linus/adc5b3cb48a049563dc673f348eab7b6beba8a9b Also see commitdd06e72e68
for more details. Summary: - Fix KMSAN vs FORTIFY in strlcpy/strlcat (Alexander Potapenko) - Convert strreplace() to return string start (Andy Shevchenko) - Flexible array conversions (Arnd Bergmann, Wyes Karny, Kees Cook) - Add missing function prototypes seen with W=1 (Arnd Bergmann) - Fix strscpy() kerndoc typo (Arne Welzel) - Replace strlcpy() with strscpy() across many subsystems which were either Acked by respective maintainers or were trivial changes that went ignored for multiple weeks (Azeem Shaikh) - Remove unneeded cc-option test for UBSAN_TRAP (Nick Desaulniers) - Add KUnit tests for strcat()-family - Enable KUnit tests of FORTIFY wrappers under UML - Add more complete FORTIFY protections for strlcat() - Add missed disabling of FORTIFY for all arch purgatories. - Enable -fstrict-flex-arrays=3 globally - Tightening UBSAN_BOUNDS when using GCC - Improve checkpatch to check for strcpy, strncpy, and fake flex arrays - Improve use of const variables in FORTIFY - Add requested struct_size_t() helper for types not pointers - Add __counted_by macro for annotating flexible array size members" * tag 'hardening-v6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: (54 commits) netfilter: ipset: Replace strlcpy with strscpy uml: Replace strlcpy with strscpy um: Use HOST_DIR for mrproper kallsyms: Replace all non-returning strlcpy with strscpy sh: Replace all non-returning strlcpy with strscpy of/flattree: Replace all non-returning strlcpy with strscpy sparc64: Replace all non-returning strlcpy with strscpy Hexagon: Replace all non-returning strlcpy with strscpy kobject: Use return value of strreplace() lib/string_helpers: Change returned value of the strreplace() jbd2: Avoid printing outside the boundary of the buffer checkpatch: Check for 0-length and 1-element arrays riscv/purgatory: Do not use fortified string functions s390/purgatory: Do not use fortified string functions x86/purgatory: Do not use fortified string functions acpi: Replace struct acpi_table_slit 1-element array with flex-array clocksource: Replace all non-returning strlcpy with strscpy string: use __builtin_memcpy() in strlcpy/strlcat staging: most: Replace all non-returning strlcpy with strscpy drm/i2c: tda998x: Replace all non-returning strlcpy with strscpy ...
88 lines
2.7 KiB
Makefile
88 lines
2.7 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
OBJECT_FILES_NON_STANDARD := y
|
|
|
|
purgatory-y := purgatory.o stack.o setup-x86_$(BITS).o sha256.o entry64.o string.o
|
|
|
|
targets += $(purgatory-y)
|
|
PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y))
|
|
|
|
$(obj)/string.o: $(srctree)/arch/x86/boot/compressed/string.c FORCE
|
|
$(call if_changed_rule,cc_o_c)
|
|
|
|
$(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE
|
|
$(call if_changed_rule,cc_o_c)
|
|
|
|
CFLAGS_sha256.o := -D__DISABLE_EXPORTS -D__NO_FORTIFY
|
|
|
|
# When profile-guided optimization is enabled, llvm emits two different
|
|
# overlapping text sections, which is not supported by kexec. Remove profile
|
|
# optimization flags.
|
|
KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%,$(KBUILD_CFLAGS))
|
|
|
|
# When linking purgatory.ro with -r unresolved symbols are not checked,
|
|
# also link a purgatory.chk binary without -r to check for unresolved symbols.
|
|
PURGATORY_LDFLAGS := -e purgatory_start -z nodefaultlib
|
|
LDFLAGS_purgatory.ro := -r $(PURGATORY_LDFLAGS)
|
|
LDFLAGS_purgatory.chk := $(PURGATORY_LDFLAGS)
|
|
targets += purgatory.ro purgatory.chk
|
|
|
|
# Sanitizer, etc. runtimes are unavailable and cannot be linked here.
|
|
GCOV_PROFILE := n
|
|
KASAN_SANITIZE := n
|
|
UBSAN_SANITIZE := n
|
|
KCSAN_SANITIZE := n
|
|
KMSAN_SANITIZE := n
|
|
KCOV_INSTRUMENT := n
|
|
|
|
# These are adjustments to the compiler flags used for objects that
|
|
# make up the standalone purgatory.ro
|
|
|
|
PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel
|
|
PURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss -g0
|
|
PURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING
|
|
PURGATORY_CFLAGS += -fno-stack-protector
|
|
|
|
# Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That
|
|
# in turn leaves some undefined symbols like __fentry__ in purgatory and not
|
|
# sure how to relocate those.
|
|
ifdef CONFIG_FUNCTION_TRACER
|
|
PURGATORY_CFLAGS_REMOVE += $(CC_FLAGS_FTRACE)
|
|
endif
|
|
|
|
ifdef CONFIG_STACKPROTECTOR
|
|
PURGATORY_CFLAGS_REMOVE += -fstack-protector
|
|
endif
|
|
|
|
ifdef CONFIG_STACKPROTECTOR_STRONG
|
|
PURGATORY_CFLAGS_REMOVE += -fstack-protector-strong
|
|
endif
|
|
|
|
ifdef CONFIG_RETPOLINE
|
|
PURGATORY_CFLAGS_REMOVE += $(RETPOLINE_CFLAGS)
|
|
endif
|
|
|
|
ifdef CONFIG_CFI_CLANG
|
|
PURGATORY_CFLAGS_REMOVE += $(CC_FLAGS_CFI)
|
|
endif
|
|
|
|
CFLAGS_REMOVE_purgatory.o += $(PURGATORY_CFLAGS_REMOVE)
|
|
CFLAGS_purgatory.o += $(PURGATORY_CFLAGS)
|
|
|
|
CFLAGS_REMOVE_sha256.o += $(PURGATORY_CFLAGS_REMOVE)
|
|
CFLAGS_sha256.o += $(PURGATORY_CFLAGS)
|
|
|
|
CFLAGS_REMOVE_string.o += $(PURGATORY_CFLAGS_REMOVE)
|
|
CFLAGS_string.o += $(PURGATORY_CFLAGS)
|
|
|
|
asflags-remove-y += $(foreach x, -g -gdwarf-4 -gdwarf-5, $(x) -Wa,$(x))
|
|
|
|
$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
|
|
$(call if_changed,ld)
|
|
|
|
$(obj)/purgatory.chk: $(obj)/purgatory.ro FORCE
|
|
$(call if_changed,ld)
|
|
|
|
$(obj)/kexec-purgatory.o: $(obj)/purgatory.ro $(obj)/purgatory.chk
|
|
|
|
obj-y += kexec-purgatory.o
|