Skip to content

Commit 48cfc57

Browse files
committed
Merge tag 'hardening-v6.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull hardening updates from Kees Cook: - Update overflow helpers to ease refactoring of on-stack flex array instances (Gustavo A. R. Silva, Kees Cook) - lkdtm: Use SLAB_NO_MERGE instead of constructors (Harry Yoo) - Simplify CONFIG_CC_HAS_COUNTED_BY (Jan Hendrik Farr) - Disable u64 usercopy KUnit test on 32-bit SPARC (Thomas Weißschuh) - Add missed designated initializers now exposed by fixed randstruct (Nathan Chancellor, Kees Cook) - Document compilers versions for __builtin_dynamic_object_size - Remove ARM_SSP_PER_TASK GCC plugin - Fix GCC plugin randstruct, add selftests, and restore COMPILE_TEST builds - Kbuild: induce full rebuilds when dependencies change with GCC plugins, the Clang sanitizer .scl file, or the randstruct seed. - Kbuild: Switch from -Wvla to -Wvla-larger-than=1 - Correct several __nonstring uses for -Wunterminated-string-initialization * tag 'hardening-v6.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: (23 commits) Revert "hardening: Disable GCC randstruct for COMPILE_TEST" lib/tests: randstruct: Add deep function pointer layout test lib/tests: Add randstruct KUnit test randstruct: gcc-plugin: Remove bogus void member net: qede: Initialize qede_ll_ops with designated initializer scsi: qedf: Use designated initializer for struct qed_fcoe_cb_ops md/bcache: Mark __nonstring look-up table integer-wrap: Force full rebuild when .scl file changes randstruct: Force full rebuild when seed changes gcc-plugins: Force full rebuild when plugins change kbuild: Switch from -Wvla to -Wvla-larger-than=1 hardening: simplify CONFIG_CC_HAS_COUNTED_BY overflow: Fix direct struct member initialization in _DEFINE_FLEX() kunit/overflow: Add tests for STACK_FLEX_ARRAY_SIZE() helper overflow: Add STACK_FLEX_ARRAY_SIZE() helper input/joystick: magellan: Mark __nonstring look-up table const watchdog: exar: Shorten identity name to fit correctly mod_devicetable: Enlarge the maximum platform_device_id name length overflow: Clarify expectations for getting DEFINE_FLEX variable sizes compiler_types: Identify compiler versions for __builtin_dynamic_object_size ...
2 parents 96d4079 + f0cd601 commit 48cfc57

30 files changed

Lines changed: 459 additions & 169 deletions

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12935,6 +12935,7 @@ F: include/linux/overflow.h
1293512935
F: include/linux/randomize_kstack.h
1293612936
F: include/linux/ucopysize.h
1293712937
F: kernel/configs/hardening.config
12938+
F: lib/tests/randstruct_kunit.c
1293812939
F: lib/tests/usercopy_kunit.c
1293912940
F: mm/usercopy.c
1294012941
F: security/Kconfig.hardening

arch/arm/Kconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,8 +1380,7 @@ config CC_HAVE_STACKPROTECTOR_TLS
13801380
config STACKPROTECTOR_PER_TASK
13811381
bool "Use a unique stack canary value for each task"
13821382
depends on STACKPROTECTOR && CURRENT_POINTER_IN_TPIDRURO && !XIP_DEFLATED_DATA
1383-
depends on GCC_PLUGINS || CC_HAVE_STACKPROTECTOR_TLS
1384-
select GCC_PLUGIN_ARM_SSP_PER_TASK if !CC_HAVE_STACKPROTECTOR_TLS
1383+
depends on CC_HAVE_STACKPROTECTOR_TLS
13851384
default y
13861385
help
13871386
Due to the fact that GCC uses an ordinary symbol reference from

arch/arm/boot/compressed/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
9696

9797
ccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \
9898
-I$(srctree)/scripts/dtc/libfdt -fno-stack-protector \
99-
-I$(obj) $(DISABLE_ARM_SSP_PER_TASK_PLUGIN)
99+
-I$(obj)
100100
ccflags-remove-$(CONFIG_FUNCTION_TRACER) += -pg
101101
asflags-y := -DZIMAGE
102102

drivers/md/bcache/super.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,8 @@ static struct uuid_entry *uuid_find(struct cache_set *c, const char *uuid)
545545

546546
static struct uuid_entry *uuid_find_empty(struct cache_set *c)
547547
{
548-
static const char zero_uuid[16] = { 0 };
548+
static const char zero_uuid[16] __nonstring =
549+
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
549550

550551
return uuid_find(c, zero_uuid);
551552
}

drivers/misc/lkdtm/heap.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -355,23 +355,12 @@ static void lkdtm_SLAB_FREE_PAGE(void)
355355
free_page(p);
356356
}
357357

358-
/*
359-
* We have constructors to keep the caches distinctly separated without
360-
* needing to boot with "slab_nomerge".
361-
*/
362-
static void ctor_double_free(void *region)
363-
{ }
364-
static void ctor_a(void *region)
365-
{ }
366-
static void ctor_b(void *region)
367-
{ }
368-
369358
void __init lkdtm_heap_init(void)
370359
{
371360
double_free_cache = kmem_cache_create("lkdtm-heap-double_free",
372-
64, 0, 0, ctor_double_free);
373-
a_cache = kmem_cache_create("lkdtm-heap-a", 64, 0, 0, ctor_a);
374-
b_cache = kmem_cache_create("lkdtm-heap-b", 64, 0, 0, ctor_b);
361+
64, 0, SLAB_NO_MERGE, NULL);
362+
a_cache = kmem_cache_create("lkdtm-heap-a", 64, 0, SLAB_NO_MERGE, NULL);
363+
b_cache = kmem_cache_create("lkdtm-heap-b", 64, 0, SLAB_NO_MERGE, NULL);
375364
}
376365

377366
void __exit lkdtm_heap_exit(void)

drivers/scsi/qedf/qedf_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ static u32 qedf_get_login_failures(void *cookie)
699699
}
700700

701701
static struct qed_fcoe_cb_ops qedf_cb_ops = {
702-
{
702+
.common = {
703703
.link_update = qedf_link_update,
704704
.bw_update = qedf_bw_update,
705705
.schedule_recovery_handler = qedf_schedule_recovery_handler,

drivers/watchdog/exar_wdt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ static const struct watchdog_info exar_wdt_info = {
221221
.options = WDIOF_KEEPALIVEPING |
222222
WDIOF_SETTIMEOUT |
223223
WDIOF_MAGICCLOSE,
224-
.identity = "Exar/MaxLinear XR28V38x Watchdog",
224+
.identity = "Exar XR28V38x Watchdog",
225225
};
226226

227227
static const struct watchdog_ops exar_wdt_ops = {

include/linux/compiler-version.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,33 @@
1212
* and add dependency on include/config/CC_VERSION_TEXT, which is touched
1313
* by Kconfig when the version string from the compiler changes.
1414
*/
15+
16+
/* Additional tree-wide dependencies start here. */
17+
18+
/*
19+
* If any of the GCC plugins change, we need to rebuild everything that
20+
* was built with them, as they may have changed their behavior and those
21+
* behaviors may need to be synchronized across all translation units.
22+
*/
23+
#ifdef GCC_PLUGINS
24+
#include <generated/gcc-plugins.h>
25+
#endif
26+
27+
/*
28+
* If the randstruct seed itself changes (whether for GCC plugins or
29+
* Clang), the entire tree needs to be rebuilt since the randomization of
30+
* structures may change between compilation units if not.
31+
*/
32+
#ifdef RANDSTRUCT
33+
#include <generated/randstruct_hash.h>
34+
#endif
35+
36+
/*
37+
* If any external changes affect Clang's integer wrapping sanitizer
38+
* behavior, a full rebuild is needed as the coverage for wrapping types
39+
* may have changed, which may impact the expected behaviors that should
40+
* not differ between compilation units.
41+
*/
42+
#ifdef INTEGER_WRAP
43+
#include <generated/integer-wrap.h>
44+
#endif

include/linux/compiler_types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ struct ftrace_likely_data {
449449
/*
450450
* When the size of an allocated object is needed, use the best available
451451
* mechanism to find it. (For cases where sizeof() cannot be used.)
452+
*
453+
* Optional: only supported since gcc >= 12
454+
*
455+
* gcc: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
456+
* clang: https://clang.llvm.org/docs/LanguageExtensions.html#evaluating-object-size
452457
*/
453458
#if __has_builtin(__builtin_dynamic_object_size)
454459
#define __struct_size(p) __builtin_dynamic_object_size(p, 0)

include/linux/mod_devicetable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ struct dmi_system_id {
601601
#define DMI_MATCH(a, b) { .slot = a, .substr = b }
602602
#define DMI_EXACT_MATCH(a, b) { .slot = a, .substr = b, .exact_match = 1 }
603603

604-
#define PLATFORM_NAME_SIZE 20
604+
#define PLATFORM_NAME_SIZE 24
605605
#define PLATFORM_MODULE_PREFIX "platform:"
606606

607607
struct platform_device_id {

0 commit comments

Comments
 (0)