1
0
Fork 0

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 <keescook@chromium.org>
hifive-unleashed-5.1
Kees Cook 2017-05-05 23:56:07 -07:00
parent 3598f5d087
commit 9225331b31
2 changed files with 7 additions and 8 deletions

View File

@ -473,11 +473,13 @@ config GCC_PLUGIN_RANDSTRUCT
depends on GCC_PLUGINS depends on GCC_PLUGINS
select MODVERSIONS if MODULES select MODVERSIONS if MODULES
help help
If you say Y here, the layouts of structures explicitly If you say Y here, the layouts of structures that are entirely
marked by __randomize_layout will be randomized at function pointers (and have not been manually annotated with
compile-time. This can introduce the requirement of an __no_randomize_layout), or structures that have been explicitly
additional information exposure vulnerability for exploits marked with __randomize_layout, will be randomized at compile-time.
targeting these structure types. This can introduce the requirement of an additional information
exposure vulnerability for exploits targeting these structure
types.
Enabling this feature will introduce some performance impact, Enabling this feature will introduce some performance impact,
slightly increase memory usage, and prevent the use of forensic slightly increase memory usage, and prevent the use of forensic

View File

@ -436,9 +436,6 @@ static int is_pure_ops_struct(const_tree node)
gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE); gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
/* XXX: Do not apply randomization to all-ftpr structs yet. */
return 0;
for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) { for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
const_tree fieldtype = get_field_type(field); const_tree fieldtype = get_field_type(field);
enum tree_code code = TREE_CODE(fieldtype); enum tree_code code = TREE_CODE(fieldtype);