From: Laura Abbott <labbott@redhat.com>
To: Kees Cook <keescook@chromium.org>, Alex Popov <alex.popov@linux.com>
Cc: Laura Abbott <labbott@redhat.com>,
kernel-hardening@lists.openwall.com,
Mark Rutland <mark.rutland@arm.com>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [kernel-hardening] [RFC][PATCH 1/2] stackleak: Update for arm64
Date: Mon, 10 Jul 2017 15:04:42 -0700 [thread overview]
Message-ID: <1499724283-30719-2-git-send-email-labbott@redhat.com> (raw)
In-Reply-To: <1499724283-30719-1-git-send-email-labbott@redhat.com>
- The arm64 rtl has another layer of indirection in the RTL
- Drop x86 check model check
- Add disable option
Signed-off-by: Laura Abbott <labbott@redhat.com>
---
This can potentially be folded into the existing patch set if there is
agreement.
I still strongly dislike the disable flag approach but it might be cleaner than
the approach for e.g. KASAN. Each plugin has a unique name and arguments so
there ends up being an explosion of items that need to be filtered out. I'm
also not an expert in Makefiles so it might actually be easier than I'm making
it out to be.
---
scripts/gcc-plugins/stackleak_plugin.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/scripts/gcc-plugins/stackleak_plugin.c b/scripts/gcc-plugins/stackleak_plugin.c
index 2ee49c4..0cf4c5d 100644
--- a/scripts/gcc-plugins/stackleak_plugin.c
+++ b/scripts/gcc-plugins/stackleak_plugin.c
@@ -176,8 +176,14 @@ static unsigned int stackleak_final_execute(void)
if (!CALL_P(insn))
continue;
body = PATTERN(insn);
+ /* arm64 is different */
+ if (GET_CODE(body) == PARALLEL) {
+ body = XEXP(body, 0);
+ body = XEXP(body, 0);
+ }
if (GET_CODE(body) != CALL)
continue;
+
body = XEXP(body, 0);
if (GET_CODE(body) != MEM)
continue;
@@ -187,7 +193,7 @@ static unsigned int stackleak_final_execute(void)
// if (strcmp(XSTR(body, 0), track_function))
if (SYMBOL_REF_DECL(body) != track_function_decl)
continue;
-// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
+ //warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
// 2. delete call
delete_insn_and_edges(insn);
#if BUILDING_GCC_VERSION >= 4007
@@ -210,8 +216,10 @@ static bool stackleak_track_stack_gate(void)
{
tree section;
+#if 0
if (ix86_cmodel != CM_KERNEL)
return false;
+#endif
section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
if (section && TREE_VALUE(section)) {
@@ -277,6 +285,7 @@ static bool stackleak_final_gate(void)
__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
{
+ bool enabled = true;
const char * const plugin_name = plugin_info->base_name;
const int argc = plugin_info->argc;
const struct plugin_argument * const argv = plugin_info->argv;
@@ -330,13 +339,19 @@ __visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gc
init_locals = true;
continue;
}
+ if (!(strcmp(argv[i].key, "disable"))) {
+ enabled = false;
+ continue;
+ }
error(G_("unknown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
}
- register_callback(plugin_name, PLUGIN_START_UNIT, &stackleak_start_unit, NULL);
- register_callback(plugin_name, PLUGIN_REGISTER_GGC_ROOTS, NULL, (void *)>_ggc_r_gt_stackleak);
- register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
- register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
+ if (enabled) {
+ register_callback(plugin_name, PLUGIN_START_UNIT, &stackleak_start_unit, NULL);
+ register_callback(plugin_name, PLUGIN_REGISTER_GGC_ROOTS, NULL, (void *)>_ggc_r_gt_stackleak);
+ register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
+ register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
+ }
return 0;
}
--
2.7.5
next prev parent reply other threads:[~2017-07-10 22:04 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-09 14:30 [kernel-hardening] [PATCH RFC v2 1/1] gcc-plugins: Add stackleak feature erasing the kernel stack at the end of syscalls Alexander Popov
2017-06-09 17:28 ` [kernel-hardening] " Kees Cook
2017-06-09 23:00 ` Alexander Popov
2017-06-20 19:20 ` Kees Cook
2017-06-13 21:51 ` Laura Abbott
2017-06-20 11:20 ` Mark Rutland
2017-06-20 14:13 ` Ard Biesheuvel
2017-06-20 19:11 ` Kees Cook
2017-06-21 9:24 ` Mark Rutland
2017-06-21 15:54 ` Laura Abbott
2017-07-10 22:04 ` [kernel-hardening] [RFC][PATCH 0/2] draft of stack clearing for arm64 Laura Abbott
2017-07-10 22:04 ` Laura Abbott [this message]
2017-07-10 22:04 ` [kernel-hardening] [RFC][PATCH 2/2] arm64: Clear the stack Laura Abbott
2017-07-11 19:51 ` [kernel-hardening] " Mark Rutland
2017-07-11 20:04 ` Mark Rutland
2017-07-12 6:01 ` Alexander Popov
2017-07-14 20:51 ` Laura Abbott
2017-07-21 16:56 ` Alexander Popov
2017-07-22 0:23 ` Laura Abbott
2017-07-24 8:19 ` Alexander Popov
2017-07-25 3:34 ` Kees Cook
2017-08-18 8:07 ` Alexander Popov
2017-07-11 22:56 ` [kernel-hardening] Re: [RFC][PATCH 0/2] draft of stack clearing for arm64 Alexander Popov
2017-06-23 22:48 ` [kernel-hardening] Re: [PATCH RFC v2 1/1] gcc-plugins: Add stackleak feature erasing the kernel stack at the end of syscalls Tycho Andersen
2017-06-29 21:33 ` Kees Cook
2017-06-29 22:13 ` Tycho Andersen
2017-06-20 9:06 ` [kernel-hardening] " Hector Martin "marcan"
2017-06-20 19:07 ` Kees Cook
2017-06-20 20:22 ` Hector Martin "marcan"
2017-06-20 19:14 ` [kernel-hardening] " Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1499724283-30719-2-git-send-email-labbott@redhat.com \
--to=labbott@redhat.com \
--cc=alex.popov@linux.com \
--cc=ard.biesheuvel@linaro.org \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=mark.rutland@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).