From patchwork Mon Jan 16 12:26:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 9518595 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 9B891600C5 for ; Mon, 16 Jan 2017 12:27:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82D8E28388 for ; Mon, 16 Jan 2017 12:27:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77C0E28490; Mon, 16 Jan 2017 12:27:37 +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 8D03D28388 for ; Mon, 16 Jan 2017 12:27:36 +0000 (UTC) Received: (qmail 17740 invoked by uid 550); 16 Jan 2017 12:27:34 -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: Reply-To: kernel-hardening@lists.openwall.com Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 17721 invoked from network); 16 Jan 2017 12:27:33 -0000 Date: Mon, 16 Jan 2017 12:26:22 +0000 From: Mark Rutland To: Kees Cook Cc: kernel-hardening@lists.openwall.com, PaX Team , Emese Revfy , "AKASHI, Takahiro" , park jinbum , Daniel Micay , linux-kernel@vger.kernel.org, dave.martin@arm.com Message-ID: <20170116122622.GF5908@leverpostej> References: <20170113220256.GA57663@beast> <20170116115435.GB5908@leverpostej> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170116115435.GB5908@leverpostej> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [kernel-hardening] Re: [PATCH] gcc-plugins: Add structleak for more stack initialization X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Jan 16, 2017 at 11:54:35AM +0000, Mark Rutland wrote: > Hi, > > [adding Dave, so retaining full context below] > > On Fri, Jan 13, 2017 at 02:02:56PM -0800, Kees Cook wrote: > > This plugin detects any structures that contain __user attributes and > > makes sure it is being fulling initialized so that a specific class of > > Nit: s/fulling/fully/ > > > information exposure is eliminated. (For example, the exposure of siginfo > > in CVE-2013-2141 would have been blocked by this plugin.) > > > > Ported from grsecurity/PaX. This version adds a verbose option to the > > plugin and the Kconfig. > > > > Signed-off-by: Kees Cook > > --- > > arch/Kconfig | 22 +++ > > include/linux/compiler.h | 6 +- > > scripts/Makefile.gcc-plugins | 4 + > > scripts/gcc-plugins/structleak_plugin.c | 246 ++++++++++++++++++++++++++++++++ > > 4 files changed, 277 insertions(+), 1 deletion(-) > > create mode 100644 scripts/gcc-plugins/structleak_plugin.c > > I tried giving this a go, but I got the build failure below: Looking again, I see that there was another patch to add PASS_INFO() and other bits that the patch required. Sorry for the noise there. In the mean time, I cribbed from the latent entropy plugin, and built with the below applied: ---- ---- With verbose mode, I see quite a few initializations, mostly in signal handling. Something to add to the queue of things to investigate... Mark. diff --git a/scripts/gcc-plugins/structleak_plugin.c b/scripts/gcc-plugins/structleak_plugin.c index deddb72..1e01763 100644 --- a/scripts/gcc-plugins/structleak_plugin.c +++ b/scripts/gcc-plugins/structleak_plugin.c @@ -210,8 +210,12 @@ __visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gc const int argc = plugin_info->argc; const struct plugin_argument * const argv = plugin_info->argv; bool enable = true; - - PASS_INFO(structleak, "early_optimizations", 1, PASS_POS_INSERT_BEFORE); + struct register_pass_info structleak_pass_info = { + .pass = make_structleak_pass(), + .reference_pass_name = "early_optimizations", + .ref_pass_instance_number = 1, + .pos_op = PASS_POS_INSERT_BEFORE, + }; if (!plugin_default_version_check(version, &gcc_version)) { error(G_("incompatible gcc/plugin versions"));