1
0
Fork 0
alistair23-linux/scripts
Kees Cook 313dd1b629 gcc-plugins: Add the randstruct plugin
This randstruct plugin is modified from Brad Spengler/PaX Team's code
in the last public patch of grsecurity/PaX based on my understanding
of the code. Changes or omissions from the original code are mine and
don't reflect the original grsecurity/PaX code.

The randstruct GCC plugin randomizes the layout of selected structures
at compile time, as a probabilistic defense against attacks that need to
know the layout of structures within the kernel. This is most useful for
"in-house" kernel builds where neither the randomization seed nor other
build artifacts are made available to an attacker. While less useful for
distribution kernels (where the randomization seed must be exposed for
third party kernel module builds), it still has some value there since now
all kernel builds would need to be tracked by an attacker.

In more performance sensitive scenarios, GCC_PLUGIN_RANDSTRUCT_PERFORMANCE
can be selected to make a best effort to restrict randomization to
cacheline-sized groups of elements, and will not randomize bitfields. This
comes at the cost of reduced randomization.

Two annotations are defined,__randomize_layout and __no_randomize_layout,
which respectively tell the plugin to either randomize or not to
randomize instances of the struct in question. Follow-on patches enable
the auto-detection logic for selecting structures for randomization
that contain only function pointers. It is disabled here to assist with
bisection.

Since any randomized structs must be initialized using designated
initializers, __randomize_layout includes the __designated_init annotation
even when the plugin is disabled so that all builds will require
the needed initialization. (With the plugin enabled, annotations for
automatically chosen structures are marked as well.)

The main differences between this implemenation and grsecurity are:
- disable automatic struct selection (to be enabled in follow-up patch)
- add designated_init attribute at runtime and for manual marking
- clarify debugging output to differentiate bad cast warnings
- add whitelisting infrastructure
- support gcc 7's DECL_ALIGN and DECL_MODE changes (Laura Abbott)
- raise minimum required GCC version to 4.7

Earlier versions of this patch series were ported by Michael Leibowitz.

Signed-off-by: Kees Cook <keescook@chromium.org>
2017-06-22 16:15:45 -07:00
..
basic fixdep: faster CONFIG_ search 2016-08-24 22:34:19 +02:00
coccinelle drm: Introduce drm_property_blob_{get,put}() 2017-02-28 16:16:46 +01:00
dtc DeviceTree fixes for 4.12-rc: 2017-05-19 15:03:24 -07:00
gcc-plugins gcc-plugins: Add the randstruct plugin 2017-06-22 16:15:45 -07:00
gdb Revert "scripts/gdb: add a Radix Tree Parser" 2016-07-15 14:54:27 +09:00
genksyms Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild 2017-03-11 01:18:25 +09:00
kconfig gconfig: remove misleading parentheses around a condition 2017-03-22 02:56:33 +09:00
ksymoops Fix dead URLs to ftp.kernel.org 2017-03-28 16:16:52 +02:00
mod kbuild: Consolidate header generation from ASM offset information 2017-04-13 05:43:37 +09:00
package Kbuild misc updates for 4.12 2017-05-10 20:41:43 -07:00
selinux selinux: include sys/socket.h in host programs to have PF_MAX 2017-03-10 15:09:27 -05:00
tracing ftrace/scripts: Add helper script to bisect function tracing problem functions 2016-09-21 13:56:55 -04:00
.gitignore KEYS: Reserve an extra certificate symbol for inserting without recompiling 2016-02-26 15:30:20 +00:00
Kbuild.include Kbuild updates for v4.12 2017-05-10 20:11:05 -07:00
Lindent scripts/Lindent: clean up and optimize 2017-02-22 16:41:26 -08:00
Makefile GCC plugin infrastructure 2016-06-07 22:57:10 +02:00
Makefile.asm-generic kbuild: Remove stale asm-generic wrappers 2016-07-07 15:58:45 +02:00
Makefile.build objtool: make it visible in make V=1 output 2017-05-03 13:39:37 +09:00
Makefile.clean Shared library support 2016-06-07 22:57:10 +02:00
Makefile.dtbinst kbuild: dtbinst: remove unnecessary __dtbs_install_prep target 2017-05-08 07:26:06 +09:00
Makefile.extrawarn kbuild: drop -Wno-unknown-warning-option from clang options 2017-04-23 16:09:15 +09:00
Makefile.fwinst kbuild: include $(src)/Makefile rather than $(obj)/Makefile 2015-04-02 16:42:08 +02:00
Makefile.gcc-plugins gcc-plugins: Add the randstruct plugin 2017-06-22 16:15:45 -07:00
Makefile.headersinst kbuild: skip install/check of headers right under uapi directories 2017-05-18 02:17:45 +09:00
Makefile.help
Makefile.host Shared library support 2016-06-07 22:57:10 +02:00
Makefile.kasan kasan: turn on -fsanitize-address-use-after-scope 2016-12-12 18:55:09 -08:00
Makefile.lib devicetree: Move include prefixes from arch to separate directory 2017-05-18 23:55:48 -07:00
Makefile.modbuiltin
Makefile.modinst modsign: Abort modules_install when signing fails 2015-08-07 16:26:13 +01:00
Makefile.modpost kbuild: add arch specific post-link Makefile 2016-09-09 10:47:00 +02:00
Makefile.modsign modsign: lookup lines ending in .ko in .mod files 2014-08-27 21:54:11 +09:30
Makefile.ubsan Kbuild: enable -Wmaybe-uninitialized warning for "make W=1" 2016-11-11 08:45:08 -08:00
adjust_autoksyms.sh kbuild: fix scripts/adjust_autoksyms.sh* for the no modules case 2016-12-11 22:30:10 +01:00
asn1_compiler.c ASN.1: fix open failure check on headername 2016-04-06 14:06:48 +01:00
bloat-o-meter scripts/bloat-o-meter: compile .NUMBER regex 2016-12-12 18:55:06 -08:00
bootgraph.pl kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
check-lc_ctype.c DocBook: Use a fixed encoding for output 2015-09-28 01:31:48 -06:00
check_00index.sh scripts: add a script to check if Documentation/00-INDEX is sane 2016-12-05 14:21:24 -07:00
check_extable.sh scripts: add check_extable.sh script. 2015-04-13 21:03:02 +09:30
checkincludes.pl scripts/checkincludes.pl: add exit message for no duplicates found 2017-02-22 16:41:26 -08:00
checkkconfigsymbols.py checkkconfigsymbols.py: support Kconfig's 'imply' statement 2017-02-03 11:49:06 +01:00
checkpatch.pl checkpatch: improve the SUSPECT_CODE_INDENT test 2017-05-08 17:15:11 -07:00
checkstack.pl scripts: remove AVR32 support from checkstack.pl 2017-05-01 09:27:15 +02:00
checksyscalls.sh x86/syscalls/32: Ignore arch_prctl for other architectures 2017-03-24 14:13:55 +01:00
checkversion.pl
cleanfile
cleanpatch
coccicheck scripts/coccicheck: Update reference for the corresponding documentation 2016-10-11 09:50:43 +02:00
config kbuild: trivial - remove trailing empty lines 2014-06-10 00:04:06 +02:00
conmakehash.c kbuild: trivial - remove trailing spaces 2014-04-30 17:34:32 +02:00
const_structs.checkpatch const_structs.checkpatch: add frequently used from Julia Lawall's list 2016-10-11 15:06:30 -07:00
decode_stacktrace.sh scripts/decode_stacktrace.sh: Fix address line detection on x86 2016-11-29 14:19:50 +01:00
decodecode scripts/decodecode: make faulting insn ptr more robust 2013-04-29 15:54:27 -07:00
depmod.sh depmod: pass -P $CONFIG_SYMBOL_PREFIX 2013-02-22 11:52:31 +01:00
diffconfig vfs,ext2: remove CONFIG_EXT2_FS_XIP and rename CONFIG_FS_XIP to CONFIG_FS_DAX 2015-02-16 17:56:04 -08:00
docproc.c docproc: print a comment about autogeneration for rst output 2016-05-14 09:56:56 -06:00
export_report.pl kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
extract-cert.c KEYS: Remove unnecessary header #inclusions from extract-cert.c 2015-09-25 16:31:45 +01:00
extract-ikconfig scripts/extract-ikconfig: Support LZ4-compressed images. 2015-04-15 14:01:12 +02:00
extract-module-sig.pl KEYS: Provide a script to extract a module signature 2015-10-21 15:18:36 +01:00
extract-sys-certs.pl KEYS: Use the symbol value for list size, updated by scripts/insert-sys-cert 2016-02-26 15:32:05 +00:00
extract-vmlinux
extract_xc3028.pl [media] extract_xc3028.pl: move it to scripts/dir 2016-07-17 14:08:12 -03:00
faddr2line scripts/faddr2line: Fix "size mismatch" error 2016-10-25 18:40:37 +02:00
gcc-goto.sh kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
gcc-ld kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
gcc-plugin.sh gcc-plugins: abort builds cleanly when not supported 2016-08-08 17:49:05 -07:00
gcc-version.sh kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
gcc-x86_32-has-stack-protector.sh kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
gcc-x86_64-has-stack-protector.sh scripts/has-stack-protector: add -fno-PIE 2016-11-09 22:28:05 +01:00
gen_initramfs_list.sh initramfs: Escape colons in depfile 2016-09-23 10:35:32 +02:00
get_dvb_firmware [media] doc-rst: move DVB avulse docs to Documentation/media 2016-07-17 14:02:45 -03:00
get_maintainer.pl get_maintainer: look for arbitrary letter prefixes in sections 2016-12-12 18:55:09 -08:00
gfp-translate chmod +x scripts/gfp-translate 2012-06-27 12:44:29 -07:00
headerdep.pl
headers.sh CRIS: Fix headers_install 2014-12-20 00:01:12 +01:00
headers_check.pl headers_check: don't warn about c++ guards 2016-05-24 14:12:48 +10:00
headers_install.sh Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild 2014-10-14 09:22:26 +02:00
insert-sys-cert.c KEYS: Reserve an extra certificate symbol for inserting without recompiling 2016-02-26 15:30:20 +00:00
kallsyms.c kbuild: modversions: add infrastructure for emitting relative CRCs 2017-02-03 08:28:25 -08:00
kernel-doc scripts/kernel-doc: fix handling of parameters with parenthesis 2017-04-02 14:06:56 -06:00
kernel-doc-xml-ref scripts/kernel-doc: Adding cross-reference links to html documentation. 2015-08-16 22:11:16 -06:00
ld-version.sh ld-version: Drop the 4th and 5th version components 2016-05-13 14:02:05 +02:00
link-vmlinux.sh kbuild: minor improvement for thin archives build 2016-11-29 15:58:57 +01:00
makelst
markup_oops.pl kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
mkcompile_h kbuild: trivial - remove trailing spaces 2014-04-30 17:34:32 +02:00
mkmakefile kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
mksysmap mksysmap: Add h8300 local symbol pattern 2015-06-23 13:35:47 +09:00
mkuboot.sh
mkversion
module-common.lds module: set .init_array alignment to 8 2017-03-13 09:40:28 -07:00
namespace.pl kallsyms: add support for relative offsets in kallsyms address table 2016-03-15 16:55:16 -07:00
objdiff scripts: objdiff: Ignore debug info when comparing 2017-03-11 11:13:38 +09:00
patch-kernel kbuild: trivial - remove trailing spaces 2014-04-30 17:34:32 +02:00
pnmtologo.c kbuild: trivial - remove trailing empty lines 2014-06-10 00:04:06 +02:00
profile2linkerlist.pl kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
prune-kernel scripts: add "prune-kernel" script to clean up old kernel images 2016-02-09 10:09:52 -08:00
recordmcount.c ftrace: Allow for function tracing to record init functions on boot up 2017-03-24 20:51:49 -04:00
recordmcount.h recordmcount: Fix endianness handling bug for nop_mcount 2015-11-03 10:45:26 -05:00
recordmcount.pl ftrace: Allow for function tracing to record init functions on boot up 2017-03-24 20:51:49 -04:00
setlocalversion kbuild: setlocalversion: print error to STDERR 2016-06-20 17:37:45 +02:00
show_delta kbuild: trivial - remove trailing empty lines 2014-06-10 00:04:06 +02:00
sign-file.c sign-file: fix build error in sign-file.c with libressl 2017-02-10 12:43:47 +11:00
sortextable.c powerpc: Build-time sort the exception table 2016-11-14 11:11:51 +11:00
sortextable.h scripts/sortextable: suppress warning: `relocs_size' may be used uninitialized 2014-10-14 02:18:23 +02:00
spelling.txt treewide: spelling: correct diffrent[iate] and banlance typos 2017-05-08 17:15:13 -07:00
stackdelta scripts: add stackdelta script 2015-08-28 17:04:40 +02:00
stackusage scripts: add stackusage script 2015-08-28 17:04:40 +02:00
tags.sh scripts/tags.sh: include arch/Kconfig* for tags generation 2017-02-22 16:41:26 -08:00
unifdef.c
ver_linux ver_linux: Use /usr/bin/awk instead of /bin/awk 2017-04-08 18:03:42 +02:00
xen-hypercalls.sh xen: build infrastructure for generating hypercall depending symbols 2015-03-16 14:49:13 +00:00
xz_wrap.sh kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00