Skip to content

Commit 9225331

Browse files
committed
randstruct: Enable function pointer struct detection
This enables the automatic structure selection logic in the randstruct GCC plugin. The selection logic randomizes all structures that contain only function pointers, unless marked with __no_randomize_layout. Signed-off-by: Kees Cook <[email protected]>
1 parent 3598f5d commit 9225331

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

arch/Kconfig

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,13 @@ config GCC_PLUGIN_RANDSTRUCT
473473
depends on GCC_PLUGINS
474474
select MODVERSIONS if MODULES
475475
help
476-
If you say Y here, the layouts of structures explicitly
477-
marked by __randomize_layout will be randomized at
478-
compile-time. This can introduce the requirement of an
479-
additional information exposure vulnerability for exploits
480-
targeting these structure types.
476+
If you say Y here, the layouts of structures that are entirely
477+
function pointers (and have not been manually annotated with
478+
__no_randomize_layout), or structures that have been explicitly
479+
marked with __randomize_layout, will be randomized at compile-time.
480+
This can introduce the requirement of an additional information
481+
exposure vulnerability for exploits targeting these structure
482+
types.
481483

482484
Enabling this feature will introduce some performance impact,
483485
slightly increase memory usage, and prevent the use of forensic

scripts/gcc-plugins/randomize_layout_plugin.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,6 @@ static int is_pure_ops_struct(const_tree node)
436436

437437
gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
438438

439-
/* XXX: Do not apply randomization to all-ftpr structs yet. */
440-
return 0;
441-
442439
for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
443440
const_tree fieldtype = get_field_type(field);
444441
enum tree_code code = TREE_CODE(fieldtype);

0 commit comments

Comments
 (0)