From patchwork Mon Jul 10 22:04:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 9833817 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 51852602A0 for ; Mon, 10 Jul 2017 22:05:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43E2D28403 for ; Mon, 10 Jul 2017 22:05:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3801128516; Mon, 10 Jul 2017 22:05:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 4F5E928403 for ; Mon, 10 Jul 2017 22:05:11 +0000 (UTC) Received: (qmail 9377 invoked by uid 550); 10 Jul 2017 22:05:05 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 9238 invoked from network); 10 Jul 2017 22:05:04 -0000 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oN5mAxrSP0y976eeA8k4F4PnhUHDoSELfhGoOYP2IL4=; b=r+eVGVk8wZV2UBfD6FZdRs6YdZrlY3joL1XBfLdJwlfB+0tF0AnbiZNEG/B1lwu+nB TlGf8GiwEmD2abPEBGfElNzthkKrdXMGXXaZsH6DDzWCYgO18YOevYEzh8HaB8u+yZbR 0HumEit3e5/2e8NVLI02i66sKLLugK3uovF2EsQeypqCtXThTWqXrGIB4eDEL3M1uaDA OMyWctHtqhyNWah0EoiLl8SNuZwDWZFhF9VqgJnMMZib83X/DgstkneyKZGMKMEEylS1 8UMgI25vs7wj5Psx6J2+FMw82smOeKEcJBDQ52B20SAUssMY6mh0uxaa43bWQ06l4wbr wmMQ== X-Gm-Message-State: AIVw112F2ek6DD8vaSGTCpibDb259dS1ISE/cspoVwg9aOBPY3f1PocX 1XShsu1z7kby/jm1rImH1A== X-Received: by 10.200.3.98 with SMTP id w34mr6993004qtg.203.1499724292765; Mon, 10 Jul 2017 15:04:52 -0700 (PDT) From: Laura Abbott To: Kees Cook , Alex Popov Cc: Laura Abbott , kernel-hardening@lists.openwall.com, Mark Rutland , Ard Biesheuvel Date: Mon, 10 Jul 2017 15:04:42 -0700 Message-Id: <1499724283-30719-2-git-send-email-labbott@redhat.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1499724283-30719-1-git-send-email-labbott@redhat.com> References: <1499724283-30719-1-git-send-email-labbott@redhat.com> Subject: [kernel-hardening] [RFC][PATCH 1/2] stackleak: Update for arm64 X-Virus-Scanned: ClamAV using ClamSMTP - The arm64 rtl has another layer of indirection in the RTL - Drop x86 check model check - Add disable option Signed-off-by: Laura Abbott --- 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; }