Skip to content

Commit 216532e

Browse files
committed
Merge tag 'hardening-v6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull hardening updates from Kees Cook: "As is pretty normal for this tree, there are changes all over the place, especially for small fixes, selftest improvements, and improved macro usability. Some header changes ended up landing via this tree as they depended on the string header cleanups. Also, a notable set of changes is the work for the reintroduction of the UBSAN signed integer overflow sanitizer so that we can continue to make improvements on the compiler side to make this sanitizer a more viable future security hardening option. Summary: - string.h and related header cleanups (Tanzir Hasan, Andy Shevchenko) - VMCI memcpy() usage and struct_size() cleanups (Vasiliy Kovalev, Harshit Mogalapalli) - selftests/powerpc: Fix load_unaligned_zeropad build failure (Michael Ellerman) - hardened Kconfig fragment updates (Marco Elver, Lukas Bulwahn) - Handle tail call optimization better in LKDTM (Douglas Anderson) - Use long form types in overflow.h (Andy Shevchenko) - Add flags param to string_get_size() (Andy Shevchenko) - Add Coccinelle script for potential struct_size() use (Jacob Keller) - Fix objtool corner case under KCFI (Josh Poimboeuf) - Drop 13 year old backward compat CAP_SYS_ADMIN check (Jingzi Meng) - Add str_plural() helper (Michal Wajdeczko, Kees Cook) - Ignore relocations in .notes section - Add comments to explain how __is_constexpr() works - Fix m68k stack alignment expectations in stackinit Kunit test - Convert string selftests to KUnit - Add KUnit tests for fortified string functions - Improve reporting during fortified string warnings - Allow non-type arg to type_max() and type_min() - Allow strscpy() to be called with only 2 arguments - Add binary mode to leaking_addresses scanner - Various small cleanups to leaking_addresses scanner - Adding wrapping_*() arithmetic helper - Annotate initial signed integer wrap-around in refcount_t - Add explicit UBSAN section to MAINTAINERS - Fix UBSAN self-test warnings - Simplify UBSAN build via removal of CONFIG_UBSAN_SANITIZE_ALL - Reintroduce UBSAN's signed overflow sanitizer" * tag 'hardening-v6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: (51 commits) selftests/powerpc: Fix load_unaligned_zeropad build failure string: Convert helpers selftest to KUnit string: Convert selftest to KUnit sh: Fix build with CONFIG_UBSAN=y compiler.h: Explain how __is_constexpr() works overflow: Allow non-type arg to type_max() and type_min() VMCI: Fix possible memcpy() run-time warning in vmci_datagram_invoke_guest_handler() lib/string_helpers: Add flags param to string_get_size() x86, relocs: Ignore relocations in .notes section objtool: Fix UNWIND_HINT_{SAVE,RESTORE} across basic blocks overflow: Use POD in check_shl_overflow() lib: stackinit: Adjust target string to 8 bytes for m68k sparc: vdso: Disable UBSAN instrumentation kernel.h: Move lib/cmdline.c prototypes to string.h leaking_addresses: Provide mechanism to scan binary files leaking_addresses: Ignore input device status lines leaking_addresses: Use File::Temp for /tmp files MAINTAINERS: Update LEAKING_ADDRESSES details fortify: Improve buffer overflow reporting fortify: Add KUnit tests for runtime overflows ...
2 parents b32273e + 3fe1eb4 commit 216532e

Some content is hidden

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

71 files changed

+1949
-688
lines changed

Documentation/dev-tools/ubsan.rst

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,22 @@ Report example
4949
Usage
5050
-----
5151

52-
To enable UBSAN configure kernel with::
52+
To enable UBSAN, configure the kernel with::
5353

54-
CONFIG_UBSAN=y
54+
CONFIG_UBSAN=y
5555

56-
and to check the entire kernel::
57-
58-
CONFIG_UBSAN_SANITIZE_ALL=y
59-
60-
To enable instrumentation for specific files or directories, add a line
61-
similar to the following to the respective kernel Makefile:
62-
63-
- For a single file (e.g. main.o)::
64-
65-
UBSAN_SANITIZE_main.o := y
66-
67-
- For all files in one directory::
68-
69-
UBSAN_SANITIZE := y
70-
71-
To exclude files from being instrumented even if
72-
``CONFIG_UBSAN_SANITIZE_ALL=y``, use::
56+
To exclude files from being instrumented use::
7357

7458
UBSAN_SANITIZE_main.o := n
7559

76-
and::
60+
and to exclude all targets in one directory use::
7761

7862
UBSAN_SANITIZE := n
7963

64+
When disabled for all targets, specific files can be enabled using::
65+
66+
UBSAN_SANITIZE_main.o := y
67+
8068
Detection of unaligned accesses controlled through the separate option -
8169
CONFIG_UBSAN_ALIGNMENT. It's off by default on architectures that support
8270
unaligned accesses (CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y). One could

MAINTAINERS

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8989,9 +8989,10 @@ F: include/linux/string.h
89898989
F: include/linux/string_choices.h
89908990
F: include/linux/string_helpers.h
89918991
F: lib/string.c
8992+
F: lib/string_kunit.c
89928993
F: lib/string_helpers.c
8993-
F: lib/test-string_helpers.c
8994-
F: lib/test_string.c
8994+
F: lib/string_helpers_kunit.c
8995+
F: scripts/coccinelle/api/string_choices.cocci
89958996

89968997
GENERIC UIO DRIVER FOR PCI DEVICES
89978998
M: "Michael S. Tsirkin" <[email protected]>
@@ -12178,11 +12179,11 @@ F: Documentation/scsi/53c700.rst
1217812179
F: drivers/scsi/53c700*
1217912180

1218012181
LEAKING_ADDRESSES
12181-
M: Tobin C. Harding <[email protected]>
1218212182
M: Tycho Andersen <[email protected]>
12183+
R: Kees Cook <[email protected]>
1218312184
1218412185
S: Maintained
12185-
T: git git://git.kernel.org/pub/scm/linux/kernel/git/tobin/leaks.git
12186+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening
1218612187
F: scripts/leaking_addresses.pl
1218712188

1218812189
LED SUBSYSTEM
@@ -22503,6 +22504,23 @@ F: Documentation/block/ublk.rst
2250322504
F: drivers/block/ublk_drv.c
2250422505
F: include/uapi/linux/ublk_cmd.h
2250522506

22507+
UBSAN
22508+
M: Kees Cook <[email protected]>
22509+
R: Marco Elver <[email protected]>
22510+
R: Andrey Konovalov <[email protected]>
22511+
R: Andrey Ryabinin <[email protected]>
22512+
22513+
22514+
S: Supported
22515+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening
22516+
F: Documentation/dev-tools/ubsan.rst
22517+
F: include/linux/ubsan.h
22518+
F: lib/Kconfig.ubsan
22519+
F: lib/test_ubsan.c
22520+
F: lib/ubsan.c
22521+
F: scripts/Makefile.ubsan
22522+
K: \bARCH_HAS_UBSAN\b
22523+
2250622524
UCLINUX (M68KNOMMU AND COLDFIRE)
2250722525
M: Greg Ungerer <[email protected]>
2250822526

arch/arm/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ config ARM
2929
select ARCH_HAVE_NMI_SAFE_CMPXCHG if CPU_V7 || CPU_V7M || CPU_V6K
3030
select ARCH_HAS_GCOV_PROFILE_ALL
3131
select ARCH_KEEP_MEMBLOCK
32-
select ARCH_HAS_UBSAN_SANITIZE_ALL
32+
select ARCH_HAS_UBSAN
3333
select ARCH_MIGHT_HAVE_PC_PARPORT
3434
select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
3535
select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7

arch/arm/boot/compressed/misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p,
154154
putstr(" done, booting the kernel.\n");
155155
}
156156

157-
void fortify_panic(const char *name)
157+
void __fortify_panic(const u8 reason, size_t avail, size_t size)
158158
{
159159
error("detected buffer overflow");
160160
}

arch/arm/boot/compressed/misc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void __div0(void);
1010
void
1111
decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p,
1212
unsigned long free_mem_ptr_end_p, int arch_id);
13-
void fortify_panic(const char *name);
13+
void __fortify_panic(const u8 reason, size_t avail, size_t size);
1414
int atags_to_fdt(void *atag_list, void *fdt, int total_space);
1515
uint32_t fdt_check_mem_start(uint32_t mem_start, const void *fdt);
1616
int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x));

arch/arm/include/asm/word-at-a-time.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
* Little-endian word-at-a-time zero byte handling.
99
* Heavily based on the x86 algorithm.
1010
*/
11-
#include <linux/kernel.h>
11+
#include <linux/bitops.h>
12+
#include <linux/wordpart.h>
1213

1314
struct word_at_a_time {
1415
const unsigned long one_bits, high_bits;

arch/arm64/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ config ARM64
107107
select ARCH_WANT_LD_ORPHAN_WARN
108108
select ARCH_WANTS_NO_INSTR
109109
select ARCH_WANTS_THP_SWAP if ARM64_4K_PAGES
110-
select ARCH_HAS_UBSAN_SANITIZE_ALL
110+
select ARCH_HAS_UBSAN
111111
select ARM_AMBA
112112
select ARM_ARCH_TIMER
113113
select ARM_GIC

arch/arm64/include/asm/word-at-a-time.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
#ifndef __AARCH64EB__
1111

12-
#include <linux/kernel.h>
12+
#include <linux/bitops.h>
13+
#include <linux/wordpart.h>
1314

1415
struct word_at_a_time {
1516
const unsigned long one_bits, high_bits;

arch/mips/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ config MIPS
1414
select ARCH_HAS_STRNCPY_FROM_USER
1515
select ARCH_HAS_STRNLEN_USER
1616
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
17-
select ARCH_HAS_UBSAN_SANITIZE_ALL
17+
select ARCH_HAS_UBSAN
1818
select ARCH_HAS_GCOV_PROFILE_ALL
1919
select ARCH_KEEP_MEMBLOCK
2020
select ARCH_USE_BUILTIN_BSWAP

arch/parisc/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ config PARISC
1212
select ARCH_HAS_ELF_RANDOMIZE
1313
select ARCH_HAS_STRICT_KERNEL_RWX
1414
select ARCH_HAS_STRICT_MODULE_RWX
15-
select ARCH_HAS_UBSAN_SANITIZE_ALL
15+
select ARCH_HAS_UBSAN
1616
select ARCH_HAS_PTE_SPECIAL
1717
select ARCH_NO_SG_CHAIN
1818
select ARCH_SUPPORTS_HUGETLBFS if PA20

0 commit comments

Comments
 (0)