From patchwork Fri May 26 20:17:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9751111 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 3387560246 for ; Fri, 26 May 2017 20:20:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 267DA28334 for ; Fri, 26 May 2017 20:20:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B35328347; Fri, 26 May 2017 20:20:40 +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 50F0228334 for ; Fri, 26 May 2017 20:20:39 +0000 (UTC) Received: (qmail 9454 invoked by uid 550); 26 May 2017 20:18:46 -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 9306 invoked from network); 26 May 2017 20:18:43 -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=d00goxOpxU2Fs/ms2irgFKC0m53VRH+1Ub/trNeiWAI=; b=f6KI0RFXbnlVpmsWUAzf+JIXKQ1T6X1w8MVySAi5sNsCdsZlpjFVe4kE9jJL3UCxfU fCNWbXTTByBs9TSjuS2ZCabbaZxwAwJBJep5y5I98dRItSrO1vNhH1ADY9ccAmxjolfB Ka1qRvxTxj4sNq7ZGBvmHIGhBEYC/qYgFXDkg= 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=d00goxOpxU2Fs/ms2irgFKC0m53VRH+1Ub/trNeiWAI=; b=jqqNT+T7/HJHP3Hdlimq3NpGARMCLuWEYCPXgAQhVCEAVXAOKm/GUdPB2QdiBkrNC0 DQZJfRZ9scoCUhqhnKXTpiV9LEajXmjbaLnq8j56BKBS0NdgN3vhGWXDqGLHlbLfUb2L kNyoHhOMasRrNGy4dyN7LsoGkXGhNiGG5MKNeEP3r0LiNXw4E0zUleiQyESd5N9DCiFn 9UnsEVy1FYacG3+kLyViVCcp66Kx2GM6DNYHwrfBP1hgFTZmnrHN16xITy5b3ZfMq3pZ YFUabgG9nGO3Yc0PTPlinQSfb/LxUsgT64EYh9wqugKJTADYnvhFJs/j87i/o4pdTus7 lk2w== X-Gm-Message-State: AODbwcDUa/Y3ivIII5s7ZOe5RXImwpDRye6GRN1qvAoDfQ3IfKxIvHEw UQUdhhKUFfkqgOyg X-Received: by 10.84.208.236 with SMTP id c41mr60413551plj.95.1495829911301; Fri, 26 May 2017 13:18:31 -0700 (PDT) From: Kees Cook To: kernel-hardening@lists.openwall.com Cc: Kees Cook , Laura Abbott , x86@kernel.org, linux-kernel@vger.kernel.org Date: Fri, 26 May 2017 13:17:22 -0700 Message-Id: <1495829844-69341-19-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495829844-69341-1-git-send-email-keescook@chromium.org> References: <1495829844-69341-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH v2 18/20] 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 3eac97a4c7b3..f4597dbd0631 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);