From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2274C433FE for ; Fri, 11 Dec 2020 21:06:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 664D224078 for ; Fri, 11 Dec 2020 21:06:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393786AbgLKTdb (ORCPT ); Fri, 11 Dec 2020 14:33:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387585AbgLKTdQ (ORCPT ); Fri, 11 Dec 2020 14:33:16 -0500 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13BC7C0613CF for ; Fri, 11 Dec 2020 11:32:36 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id bj5so5089594plb.4 for ; Fri, 11 Dec 2020 11:32:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=9QrTgvGnEakPURCqXO9kVzpnI7sAnsn5QLKAoF8jKto=; b=YlRVVR0J3SWrOJLo/jmkZifU0GgnWNus/X2mN9j9Dpcm7OnTYCv0w8dDeiXJOhRtKq qntCWLVR/OxbTujk2vmdnbE+xvAC7RGanwD7OUpSCuC6myv5NZOsA1/lV5o5GCQIcu3w ysXWmzmxZxCXJMR5DqDqZeAn155foWYOHtnKY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=9QrTgvGnEakPURCqXO9kVzpnI7sAnsn5QLKAoF8jKto=; b=gHI32rzcEDUh2Hhw4s0fIZQ1FheBHIGY2c7s90aBWMl5P3bL/qYsiGPhqcWr8wI+yF 0tHCV04ci0vwl3TaHUHFZqBU70ZZp0iZffpGV+DPxRawmmLh/mM6j9YkSBqm0l4q1mIy ANJdZ0VNN8iBvRhypJetJYUO6tSNUVhNzeAdXrKZQeRuuio5hhNyLLXZlO8G7pg9gNI+ T5g97vVXf5iSP2SLEOEyruM9Q/OVvrstY8bq2VjKEgkimuKIblhBLRpsxCjIZddkqoT9 bCzDz4UKuTxrK8G0KRNFwjEqFVadK7mC97a0Xs4g1TBg0JSowovJuEaVkiiORZdz+Y2J 1BkA== X-Gm-Message-State: AOAM530CKz4LrGF90k21i88ukWeCh62zvhtc3jy66kzY0RxDzWq5OXmk Y79Cj44+4B6sV2i6Mi8vqxlGvA== X-Google-Smtp-Source: ABdhPJxsthqMVhRTxK9zln6OgOykAvCX/6nw+GaT6GPANSQFH6ft5S0zc7PNaBcACeYW35bsdNRUig== X-Received: by 2002:a17:902:123:b029:da:420e:aab0 with SMTP id 32-20020a1709020123b02900da420eaab0mr12377208plb.30.1607715155648; Fri, 11 Dec 2020 11:32:35 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id s65sm10821175pgb.78.2020.12.11.11.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Dec 2020 11:32:34 -0800 (PST) Date: Fri, 11 Dec 2020 11:32:33 -0800 From: Kees Cook To: Sami Tolvanen Cc: Masahiro Yamada , Steven Rostedt , Will Deacon , Josh Poimboeuf , Peter Zijlstra , Greg Kroah-Hartman , "Paul E. McKenney" , Nick Desaulniers , clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH v9 06/16] kbuild: lto: add a default list of used symbols Message-ID: <202012111131.E41AFFCDB@keescook> References: <20201211184633.3213045-1-samitolvanen@google.com> <20201211184633.3213045-7-samitolvanen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201211184633.3213045-7-samitolvanen@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 11, 2020 at 10:46:23AM -0800, Sami Tolvanen wrote: > With CONFIG_LTO_CLANG, LLVM bitcode has not yet been compiled into a > binary when the .mod files are generated, which means they don't yet > contain references to certain symbols that will be present in the final > binaries. This includes intrinsic functions, such as memcpy, memmove, > and memset [1], and stack protector symbols [2]. This change adds a > default symbol list to use with CONFIG_TRIM_UNUSED_KSYMS when Clang's > LTO is used. > > [1] https://llvm.org/docs/LangRef.html#standard-c-c-library-intrinsics > [2] https://llvm.org/docs/LangRef.html#llvm-stackprotector-intrinsic > > Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook > --- > init/Kconfig | 1 + > scripts/lto-used-symbollist | 5 +++++ > 2 files changed, 6 insertions(+) > create mode 100644 scripts/lto-used-symbollist > > diff --git a/init/Kconfig b/init/Kconfig > index 0872a5a2e759..e88c919c1bf1 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -2297,6 +2297,7 @@ config TRIM_UNUSED_KSYMS > config UNUSED_KSYMS_WHITELIST > string "Whitelist of symbols to keep in ksymtab" > depends on TRIM_UNUSED_KSYMS > + default "scripts/lto-used-symbollist" if LTO_CLANG > help > By default, all unused exported symbols will be un-exported from the > build when TRIM_UNUSED_KSYMS is selected. > diff --git a/scripts/lto-used-symbollist b/scripts/lto-used-symbollist > new file mode 100644 > index 000000000000..38e7bb9ebaae > --- /dev/null > +++ b/scripts/lto-used-symbollist > @@ -0,0 +1,5 @@ > +memcpy > +memmove > +memset > +__stack_chk_fail > +__stack_chk_guard > -- > 2.29.2.576.ga3fc446d84-goog > bikeshed: Should this filename use some kind of extension, like lto-user-symbols.txt or .list, to make it more human-friendly? -- Kees Cook From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 033A5C433FE for ; Fri, 11 Dec 2020 19:34:04 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9D4E322E00 for ; Fri, 11 Dec 2020 19:34:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D4E322E00 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zuHMMI1g9iM2ZPHQ0jj0WkWTR/czWW8wYT+aNUPKgu8=; b=znxPn+12i+0mxM6pExFgJrw2u lwQiblj8lV1dwCmBfY2gVkuiqXy5kSH+pRx2RhJ3ssuw1EIL/IE2WUrua1lP07QO4O2Q7dafFS2CF tHZcv7bjEf9nnOUlgNFTNcEQh5EPPYOas5/Ys9Ku+ne6ozLwL/gUfrr+MiXt8kCqbtcpN8/xmJb/M E6FA2mo6AFapl5JIltG9IUAacTP1IRozCF9FuH/qqbmb5vbcXsY3eU0cORTWsc3Kune7+mVwukhps 6Sl6t6gqLaU1rtEAubkSLcnnppQ078a9Fs8OR/LCxAiIkS1RggTwbuaKQdY1mrGBoOvhd0ZSUf3dt rE+PkZXLw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kno9h-0006jq-G5; Fri, 11 Dec 2020 19:32:41 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kno9f-0006ij-FL for linux-arm-kernel@lists.infradead.org; Fri, 11 Dec 2020 19:32:40 +0000 Received: by mail-pl1-x643.google.com with SMTP id u4so5071321plr.12 for ; Fri, 11 Dec 2020 11:32:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=9QrTgvGnEakPURCqXO9kVzpnI7sAnsn5QLKAoF8jKto=; b=YlRVVR0J3SWrOJLo/jmkZifU0GgnWNus/X2mN9j9Dpcm7OnTYCv0w8dDeiXJOhRtKq qntCWLVR/OxbTujk2vmdnbE+xvAC7RGanwD7OUpSCuC6myv5NZOsA1/lV5o5GCQIcu3w ysXWmzmxZxCXJMR5DqDqZeAn155foWYOHtnKY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=9QrTgvGnEakPURCqXO9kVzpnI7sAnsn5QLKAoF8jKto=; b=B6hMILF3L3En9wslRT/8Sir5/kdw3UsVI4K3SNeRpPJJNCmwT237uYDJkxWVbVsqdb TIua9/IQBfCI5d3PiwuToFfbNWlTKCx1PVrOx/R4bUMxvIKtGLpFEUsutXxy9EvR5VFY 4osOY5y8pRWuNODxqk1gtZm+KXW1tUYDWDW36Gr6N6rcId/NnXcP23ItfKZdfclwRNIz 9gKefZyJNNYMTsvxGrdWaYwqcmu/+oxm9fEUaNNw+qJB6f3uHEhIvu0L93gYXVbrIUyc lvOIu+p2bcrSulDJN4TTs7BEa+3fw2SiEv6i/xmYHFPU6IAY4PnbxKPuTI3m+lx20mke FVcw== X-Gm-Message-State: AOAM532W7kraIEd+wN6283zWcGSuZgsVJrC3oWcLrHqmoEApNooC5uR0 1s0Mwv+GyjxVV78+iGFUaAzqzw== X-Google-Smtp-Source: ABdhPJxsthqMVhRTxK9zln6OgOykAvCX/6nw+GaT6GPANSQFH6ft5S0zc7PNaBcACeYW35bsdNRUig== X-Received: by 2002:a17:902:123:b029:da:420e:aab0 with SMTP id 32-20020a1709020123b02900da420eaab0mr12377208plb.30.1607715155648; Fri, 11 Dec 2020 11:32:35 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id s65sm10821175pgb.78.2020.12.11.11.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Dec 2020 11:32:34 -0800 (PST) Date: Fri, 11 Dec 2020 11:32:33 -0800 From: Kees Cook To: Sami Tolvanen Subject: Re: [PATCH v9 06/16] kbuild: lto: add a default list of used symbols Message-ID: <202012111131.E41AFFCDB@keescook> References: <20201211184633.3213045-1-samitolvanen@google.com> <20201211184633.3213045-7-samitolvanen@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201211184633.3213045-7-samitolvanen@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201211_143239_588300_D385D8BB X-CRM114-Status: GOOD ( 24.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, "Paul E. McKenney" , kernel-hardening@lists.openwall.com, Peter Zijlstra , Greg Kroah-Hartman , Masahiro Yamada , linux-kbuild@vger.kernel.org, Nick Desaulniers , linux-kernel@vger.kernel.org, Steven Rostedt , clang-built-linux@googlegroups.com, linux-pci@vger.kernel.org, Josh Poimboeuf , Will Deacon , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Dec 11, 2020 at 10:46:23AM -0800, Sami Tolvanen wrote: > With CONFIG_LTO_CLANG, LLVM bitcode has not yet been compiled into a > binary when the .mod files are generated, which means they don't yet > contain references to certain symbols that will be present in the final > binaries. This includes intrinsic functions, such as memcpy, memmove, > and memset [1], and stack protector symbols [2]. This change adds a > default symbol list to use with CONFIG_TRIM_UNUSED_KSYMS when Clang's > LTO is used. > > [1] https://llvm.org/docs/LangRef.html#standard-c-c-library-intrinsics > [2] https://llvm.org/docs/LangRef.html#llvm-stackprotector-intrinsic > > Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook > --- > init/Kconfig | 1 + > scripts/lto-used-symbollist | 5 +++++ > 2 files changed, 6 insertions(+) > create mode 100644 scripts/lto-used-symbollist > > diff --git a/init/Kconfig b/init/Kconfig > index 0872a5a2e759..e88c919c1bf1 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -2297,6 +2297,7 @@ config TRIM_UNUSED_KSYMS > config UNUSED_KSYMS_WHITELIST > string "Whitelist of symbols to keep in ksymtab" > depends on TRIM_UNUSED_KSYMS > + default "scripts/lto-used-symbollist" if LTO_CLANG > help > By default, all unused exported symbols will be un-exported from the > build when TRIM_UNUSED_KSYMS is selected. > diff --git a/scripts/lto-used-symbollist b/scripts/lto-used-symbollist > new file mode 100644 > index 000000000000..38e7bb9ebaae > --- /dev/null > +++ b/scripts/lto-used-symbollist > @@ -0,0 +1,5 @@ > +memcpy > +memmove > +memset > +__stack_chk_fail > +__stack_chk_guard > -- > 2.29.2.576.ga3fc446d84-goog > bikeshed: Should this filename use some kind of extension, like lto-user-symbols.txt or .list, to make it more human-friendly? -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel