From patchwork Wed May 18 08:51:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Donnellan X-Patchwork-Id: 9117451 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 333889F37F for ; Wed, 18 May 2016 08:54:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 46DE4201FA for ; Wed, 18 May 2016 08:54:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5BB0F20165 for ; Wed, 18 May 2016 08:54:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751958AbcERIyK (ORCPT ); Wed, 18 May 2016 04:54:10 -0400 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:38103 "EHLO e23smtp01.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751546AbcERIyG (ORCPT ); Wed, 18 May 2016 04:54:06 -0400 Received: from localhost by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 18 May 2016 18:54:03 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 18 May 2016 18:54:01 +1000 X-IBM-Helo: d23dlp03.au.ibm.com X-IBM-MailFrom: andrew.donnellan@au1.ibm.com X-IBM-RcptTo: linux-kbuild@vger.kernel.org;linux-kernel@vger.kernel.org Received: from d23relay10.au.ibm.com (d23relay10.au.ibm.com [9.190.26.77]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 1FBF83578075; Wed, 18 May 2016 18:53:34 +1000 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u4I8r5i263242240; Wed, 18 May 2016 18:53:13 +1000 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u4I8qPnS025021; Wed, 18 May 2016 18:52:27 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u4I8qPPx024018; Wed, 18 May 2016 18:52:25 +1000 Received: from [10.61.2.248] (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 4CBBCA0224; Wed, 18 May 2016 18:51:15 +1000 (AEST) Subject: Re: [kernel-hardening] [PATCH v8 2/4] GCC plugin infrastructure To: kernel-hardening@lists.openwall.com, linux-kbuild@vger.kernel.org References: <20160513015456.01415979f20a68eb7d2d9290@gmail.com> <20160513015725.30223ee16a2a3860b4392b90@gmail.com> Cc: pageexec@freemail.hu, spender@grsecurity.net, mmarek@suse.com, keescook@chromium.org, linux@rasmusvillemoes.dk, fengguang.wu@intel.com, dvyukov@google.com, linux-kernel@vger.kernel.org, david.brown@linaro.org, yamada.masahiro@socionext.com, linuxppc-dev , Michael Ellerman , Daniel Axtens From: Andrew Donnellan Message-ID: <573C2CFE.8060305@au1.ibm.com> Date: Wed, 18 May 2016 18:51:10 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.8.0 MIME-Version: 1.0 In-Reply-To: <20160513015725.30223ee16a2a3860b4392b90@gmail.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16051808-1618-0000-0000-000045DEA22A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 13/05/16 09:57, Emese Revfy wrote: > This patch allows to build the whole kernel with GCC plugins. It was ported from > grsecurity/PaX. The infrastructure supports building out-of-tree modules and > building in a separate directory. Cross-compilation is supported too. > Currently the x86, arm, arm64 and uml architectures enable plugins. > > The directory of the gcc plugins is scripts/gcc-plugins. You can use a file or a directory > there. The plugins compile with these options: > * -fno-rtti: gcc is compiled with this option so the plugins must use it too > * -fno-exceptions: this is inherited from gcc too > * -fasynchronous-unwind-tables: this is inherited from gcc too > * -ggdb: it is useful for debugging a plugin (better backtrace on internal > errors) > * -Wno-narrowing: to suppress warnings from gcc headers (ipa-utils.h) > * -Wno-unused-variable: to suppress warnings from gcc headers (gcc_version > variable, plugin-version.h) > > The infrastructure introduces a new Makefile target called gcc-plugins. It > supports all gcc versions from 4.5 to 6.0. The scripts/gcc-plugin.sh script > chooses the proper host compiler (gcc-4.7 can be built by either gcc or g++). > This script also checks the availability of the included headers in > scripts/gcc-plugins/gcc-common.h. > > The gcc-common.h header contains frequently included headers for GCC plugins > and it has a compatibility layer for the supported gcc versions. > > The gcc-generate-*-pass.h headers automatically generate the registration > structures for GIMPLE, SIMPLE_IPA, IPA and RTL passes. > > Note that 'make clean' keeps the *.so files (only the distclean or mrproper > targets clean all) because they are needed for out-of-tree modules. > > The arm and arm64 architectures were tested by David Brown . > > Signed-off-by: Emese Revfy I've done some basic sanity testing on powerpc with the cyclomatic complexity plugin (with LE native + cross-compilers) and it seems to work with the patch below. Signed-off-by: Andrew Donnellan diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index a18a0dc..0cfed5b 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -97,6 +97,7 @@ config PPC select HAVE_DYNAMIC_FTRACE_WITH_REGS if MPROFILE_KERNEL select HAVE_FUNCTION_TRACER select HAVE_FUNCTION_GRAPH_TRACER + select HAVE_GCC_PLUGINS select SYSCTL_EXCEPTION_TRACE select ARCH_WANT_OPTIONAL_GPIOLIB select VIRT_TO_BUS if !PPC64