1854c19c | 26-May-2017 |
Kees Cook <keescook@chromium.org> |
randstruct: Whitelist NIU struct page overloading
The NIU ethernet driver intentionally stores a page struct pointer on top of the "mapping" field. Whitelist this case:
drivers/net/ethernet/sun/niu
randstruct: Whitelist NIU struct page overloading
The NIU ethernet driver intentionally stores a page struct pointer on top of the "mapping" field. Whitelist this case:
drivers/net/ethernet/sun/niu.c: In function ‘niu_rx_pkt_ignore’: drivers/net/ethernet/sun/niu.c:3402:10: note: found mismatched ssa struct pointer types: ‘struct page’ and ‘struct address_space’
*link = (struct page *) page->mapping; ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Cc: David S. Miller <davem@davemloft.net> Signed-off-by: Kees Cook <keescook@chromium.org>
show more ...
|
802762cd | 26-May-2017 |
Kees Cook <keescook@chromium.org> |
randstruct: Whitelist big_key path struct overloading
The big_key payload structure intentionally stores a struct path in two void pointers to avoid header soup. Whitelist this case:
security/keys/
randstruct: Whitelist big_key path struct overloading
The big_key payload structure intentionally stores a struct path in two void pointers to avoid header soup. Whitelist this case:
security/keys/big_key.c: In function ‘big_key_read’: security/keys/big_key.c:293:16: note: found mismatched rhs struct pointer types: ‘struct path’ and ‘void *’
struct path *path = (struct path *)&key->payload.data[big_key_path]; ^~~~
Cc: David Howells <dhowells@redhat.com> Signed-off-by: Kees Cook <keescook@chromium.org>
show more ...
|
b07b6584 | 05-Apr-2017 |
Kees Cook <keescook@chromium.org> |
randstruct: Whitelist UNIXCB cast
This is another false positive in bad cast detection:
net/unix/af_unix.c: In function ‘unix_skb_scm_eq’: net/unix/af_unix.c:1621:31: note: found mismatched rhs str
randstruct: Whitelist UNIXCB cast
This is another false positive in bad cast detection:
net/unix/af_unix.c: In function ‘unix_skb_scm_eq’: net/unix/af_unix.c:1621:31: note: found mismatched rhs struct pointer types: ‘struct unix_skb_parms’ and ‘char’
const struct unix_skb_parms *u = &UNIXCB(skb); ^
UNIXCB is:
#define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb))
And ->cb is:
char cb[48] __aligned(8);
This is a rather crazy cast, but appears to be safe in the face of randomization, so whitelist it in the plugin.
Cc: Hannes Frederic Sowa <hannes@stressinduktion.org> Cc: David S. Miller <davem@davemloft.net> Signed-off-by: Kees Cook <keescook@chromium.org>
show more ...
|
fd466e06 | 05-Apr-2017 |
Kees Cook <keescook@chromium.org> |
randstruct: Whitelist struct security_hook_heads cast
The LSM initialization routines walk security_hook_heads as an array of struct list_head instead of via names to avoid a ton of needless source.
randstruct: Whitelist struct security_hook_heads cast
The LSM initialization routines walk security_hook_heads as an array of struct list_head instead of via names to avoid a ton of needless source. Whitelist this to avoid the false positive warning from the plugin:
security/security.c: In function ‘security_init’: security/security.c:59:20: note: found mismatched op0 struct pointer types: ‘struct list_head’ and ‘struct security_hook_heads’
struct list_head *list = (struct list_head *) &security_hook_heads; ^
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: James Morris <james.l.morris@oracle.com> Signed-off-by: Kees Cook <keescook@chromium.org>
show more ...
|
313dd1b6 | 06-May-2017 |
Kees Cook <keescook@chromium.org> |
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
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>
show more ...
|
dcc23527 | 27-Feb-2017 |
Arnd Bergmann <arnd@arndb.de> |
gcc-plugins: fix sancov_plugin for gcc-5
The name of the local variable was inadvertantly changed from sancov_plugin_pass_info to sancov_pass_info:
scripts/gcc-plugins/sancov_plugin.c: In function
gcc-plugins: fix sancov_plugin for gcc-5
The name of the local variable was inadvertantly changed from sancov_plugin_pass_info to sancov_pass_info:
scripts/gcc-plugins/sancov_plugin.c: In function ‘int plugin_init(plugin_name_args*, plugin_gcc_version*)’: scripts/gcc-plugins/sancov_plugin.c:136:67: error: ‘sancov_plugin_pass_info’ was not declared in this scope
This changes the conditional reference to this variable as well.
Fixes: 5a45a4c5c3f5 ("gcc-plugins: consolidate on PASS_INFO macro") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Kees Cook <keescook@chromium.org>
show more ...
|
c61f13ea | 13-Jan-2017 |
Kees Cook <keescook@chromium.org> |
gcc-plugins: Add structleak for more stack initialization
This plugin detects any structures that contain __user attributes and makes sure it is being fully initialized so that a specific class of i
gcc-plugins: Add structleak for more stack initialization
This plugin detects any structures that contain __user attributes and makes sure it is being fully initialized so that a specific class of information exposure is eliminated. (This plugin was originally designed to block the exposure of siginfo in CVE-2013-2141.)
Ported from grsecurity/PaX. This version adds a verbose option to the plugin and the Kconfig.
Signed-off-by: Kees Cook <keescook@chromium.org>
show more ...
|
5a45a4c5 | 13-Jan-2017 |
Kees Cook <keescook@chromium.org> |
gcc-plugins: consolidate on PASS_INFO macro
Now that PASS_INFO() exists, use it in the other existing gcc plugins, instead of always open coding the same thing.
Based on updates to the grsecurity/P
gcc-plugins: consolidate on PASS_INFO macro
Now that PASS_INFO() exists, use it in the other existing gcc plugins, instead of always open coding the same thing.
Based on updates to the grsecurity/PaX gcc plugins.
Signed-off-by: Kees Cook <keescook@chromium.org>
show more ...
|
8d4973a1 | 11-Jan-2017 |
Kees Cook <keescook@chromium.org> |
gcc-plugins: add PASS_INFO and build_const_char_string()
This updates the GCC plugins gcc-common.h from PaX Team to include more helpers and header files, specifically adds the PASS_INFO() macro to
gcc-plugins: add PASS_INFO and build_const_char_string()
This updates the GCC plugins gcc-common.h from PaX Team to include more helpers and header files, specifically adds the PASS_INFO() macro to make plugin declarations nicer and a helper for proper const string building.
Signed-off-by: Kees Cook <keescook@chromium.org>
show more ...
|
81d873a8 | 16-Dec-2016 |
Kees Cook <keescook@chromium.org> |
gcc-plugins: update gcc-common.h for gcc-7
This updates gcc-common.h from Emese Revfy for gcc 7. This fixes issues seen by Kugan and Arnd. Build tested with gcc 5.4 and 7 snapshot.
Cc: stable@vger.
gcc-plugins: update gcc-common.h for gcc-7
This updates gcc-common.h from Emese Revfy for gcc 7. This fixes issues seen by Kugan and Arnd. Build tested with gcc 5.4 and 7 snapshot.
Cc: stable@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org>
show more ...
|
58bea414 | 19-Oct-2016 |
Kees Cook <keescook@chromium.org> |
latent_entropy: Fix wrong gcc code generation with 64 bit variables
The stack frame size could grow too large when the plugin used long long on 32-bit architectures when the given function had too m
latent_entropy: Fix wrong gcc code generation with 64 bit variables
The stack frame size could grow too large when the plugin used long long on 32-bit architectures when the given function had too many basic blocks.
The gcc warning was:
drivers/pci/hotplug/ibmphp_ebda.c: In function 'ibmphp_access_ebda': drivers/pci/hotplug/ibmphp_ebda.c:409:1: warning: the frame size of 1108 bytes is larger than 1024 bytes [-Wframe-larger-than=]
This switches latent_entropy from u64 to unsigned long.
Thanks to PaX Team and Emese Revfy for the patch.
Signed-off-by: Kees Cook <keescook@chromium.org>
show more ...
|
caefd8c9 | 26-Jun-2016 |
Emese Revfy <re.emese@gmail.com> |
gcc-plugins: Add support for plugin subdirectories
This adds support for building more complex gcc plugins that live in a subdirectory instead of just in a single source file.
Reported-by: PaX Team
gcc-plugins: Add support for plugin subdirectories
This adds support for building more complex gcc plugins that live in a subdirectory instead of just in a single source file.
Reported-by: PaX Team <pageexec@freemail.hu> Signed-off-by: Emese Revfy <re.emese@gmail.com> [kees: clarified commit message] Signed-off-by: Kees Cook <keescook@chromium.org>
show more ...
|
0dae776c | 24-May-2016 |
Emese Revfy <re.emese@gmail.com> |
Add Cyclomatic complexity GCC plugin
Add a very simple plugin to demonstrate the GCC plugin infrastructure. This GCC plugin computes the cyclomatic complexity of each function.
The complexity M of
Add Cyclomatic complexity GCC plugin
Add a very simple plugin to demonstrate the GCC plugin infrastructure. This GCC plugin computes the cyclomatic complexity of each function.
The complexity M of a function's control flow graph is defined as: M = E - N + 2P where E = the number of edges N = the number of nodes P = the number of connected components (exit nodes).
Signed-off-by: Emese Revfy <re.emese@gmail.com> Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: Michal Marek <mmarek@suse.com>
show more ...
|