From patchwork Mon Jun 19 20:56:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9797821 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 8FC5E6020B for ; Mon, 19 Jun 2017 20:58:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AD1D28459 for ; Mon, 19 Jun 2017 20:58:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FB2F2846B; Mon, 19 Jun 2017 20:58:29 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 AF5A728459 for ; Mon, 19 Jun 2017 20:58:28 +0000 (UTC) Received: (qmail 30060 invoked by uid 550); 19 Jun 2017 20:58:18 -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 Delivered-To: moderator for kernel-hardening@lists.openwall.com Received: (qmail 25665 invoked from network); 19 Jun 2017 20:57:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yX1alZ+mo9dMw4B6Lspq2WdHaiAWss3xJjDDv9w+n5M=; b=j7MmGabtTAIvmiAKE0/2D3kW1iva7Qpm72VqezEpTjXQN5Qrs57QW1JEePNQ79KD9O DoSrxRMJ++OZtgKtWSzM5wTnSAGEpKmBrH8m76XKKD9jZelY/O2o+y2ZpRShVafsmBhi MJPGyk2yPUsKHQqhMxD9YxIL2hDDGGnUY8CXw= 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=yX1alZ+mo9dMw4B6Lspq2WdHaiAWss3xJjDDv9w+n5M=; b=pcGLodRHdD3KYsWNJ0FxA+A0Hpm3tcpLSEJ1+DZTGSfJtmUhxVt8tBdzQ1imxdC6TS QVvhGH8agVM8IennIshwruzzkNdrKJ+1yW2WvKvg3zatW0aVqmmRs4dT5FgpTIpoifHK 6fEfKDOcp+SQietZjNX1qonhozHxUU8qQcAfbgWS1TYV4YmVT91rpvRPzuGOwV2xxlbi GJ/hnZxOp1HEitKHftDVXHntuYmGOSqOR3N05B53tsNlKFct93nqPFHPoc+pQELw/TA9 VbE0bvFv3ssHqMhksEK8qtqf7MFHX5xr2oKckYSHteqAl3LKBws1V3XFClc4nDxwE1Yw ebpw== X-Gm-Message-State: AKS2vOxbIyyXo+SKHMcSotuo5tY0kCBLAWFecaF/lq5TYXhhFDftFHC1 NVuCV143fCdQhBZEdGpDJA== X-Received: by 10.84.241.132 with SMTP id b4mr31750397pll.107.1497905816433; Mon, 19 Jun 2017 13:56:56 -0700 (PDT) From: Kees Cook To: kernel-hardening@lists.openwall.com Cc: Kees Cook , linux-kernel@vger.kernel.org Date: Mon, 19 Jun 2017 13:56:41 -0700 Message-Id: <1497905801-69164-5-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497905801-69164-1-git-send-email-keescook@chromium.org> References: <1497905801-69164-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH 4/4] randstruct: Enable function pointer struct detection X-Virus-Scanned: ClamAV using ClamSMTP This enables the automatic structure selection logic in the randstruct GCC plugin. The selection logic randomizes all structures that contain only function pointers, unless marked with __no_randomize_layout. Signed-off-by: Kees Cook --- arch/Kconfig | 12 +++++++----- scripts/gcc-plugins/randomize_layout_plugin.c | 3 --- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 810bf206f221..d8e57d6216b4 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -448,11 +448,13 @@ config GCC_PLUGIN_RANDSTRUCT depends on GCC_PLUGINS select MODVERSIONS if MODULES help - If you say Y here, the layouts of structures explicitly - marked by __randomize_layout will be randomized at - compile-time. This can introduce the requirement of an - additional information exposure vulnerability for exploits - targeting these structure types. + If you say Y here, the layouts of structures that are entirely + function pointers (and have not been manually annotated with + __no_randomize_layout), or structures that have been explicitly + marked with __randomize_layout, will be randomized at compile-time. + This can introduce the requirement of an additional information + exposure vulnerability for exploits targeting these structure + types. Enabling this feature will introduce some performance impact, slightly increase memory usage, and prevent the use of forensic diff --git a/scripts/gcc-plugins/randomize_layout_plugin.c b/scripts/gcc-plugins/randomize_layout_plugin.c index e6e02a40d522..bb2c6789c4b7 100644 --- a/scripts/gcc-plugins/randomize_layout_plugin.c +++ b/scripts/gcc-plugins/randomize_layout_plugin.c @@ -437,9 +437,6 @@ static int is_pure_ops_struct(const_tree node) gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE); - /* XXX: Do not apply randomization to all-ftpr structs yet. */ - return 0; - for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) { const_tree fieldtype = get_field_type(field); enum tree_code code = TREE_CODE(fieldtype);