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=-23.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, 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,USER_IN_DEF_DKIM_WL 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 ACCE0C4361B for ; Fri, 11 Dec 2020 21:12:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BC7C2405A for ; Fri, 11 Dec 2020 21:12:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394151AbgLKTl6 (ORCPT ); Fri, 11 Dec 2020 14:41:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394065AbgLKTlP (ORCPT ); Fri, 11 Dec 2020 14:41:15 -0500 Received: from mail-vs1-xe44.google.com (mail-vs1-xe44.google.com [IPv6:2607:f8b0:4864:20::e44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C508C061793 for ; Fri, 11 Dec 2020 11:40:35 -0800 (PST) Received: by mail-vs1-xe44.google.com with SMTP id z16so5408506vsp.5 for ; Fri, 11 Dec 2020 11:40:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1nS5LJe0V9gmSV6AI/CjiJWRU085g+HSabHeZYnNbME=; b=qsqg3dEZdz6yTY0b8lWmwlvvFlCl6x/6RcbpcNM5RjlQi43vCEWHYEvpvNFMgtwSJf 92LLLXxQ2DMnh4n9P483SaIxEmprkCDc/K+JgapPX/ZZKy6aK5r4eyyfdBCtEQJhwn4x ouvYwbD1s6MDLHCs5KHgP2Xw3/OELzfJnu8FvoDrq3GDDw87fJYBXVbaSaOYc+0Nu1UD fiQbuk0q8gz7/5IDoWj0ON2iPNs+pAeF9Qty6DbvjfFV/8Wzmt8DsLQLeqTz1ozLVtyQ R0+WXz2Fbj8SqfTG7PiaJGfy0Ipx3UtxFa3GxMJFuDwuXo9nyWaQPdc+rxYInzhIXbQ8 nCbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1nS5LJe0V9gmSV6AI/CjiJWRU085g+HSabHeZYnNbME=; b=ndBYzWbfsh9MLRqh0CGEmogiuOsUHghczKiGsXeCTKAWi7G9eEJEu8HccXIeSwZ9b7 LoOcd3PDhnX+2JwycZXlmlkxhklxxJWMIUoZC5mBlov6EJj0Uo82YLVzAx0Fas0AnIBs DPxrztT6pezLZnFqS9hf/1s5zrrfIs8rMl3f8NoAn5XePNzseq2aXesIDlwQc8PWX1lu 8zRYwcQn0zmADEFWEMGh0l/Ppo4tw5LQpQ/LSJbP3iU97Kg2NJ4Cbt7hm3CVB7VmXUP4 +1IrK7NFW8dzS1uVmaeU+dcmBZfxwZlGs9m1oBvJuSGdg+hJMvuXobxF74nCMH37ijR1 0+gg== X-Gm-Message-State: AOAM533rY3cDWGA1alVTSm6OttXxdK4JztBWDis8ggGqswuKaFfB98YD 2JqZm2kDFu9x2bBhqqqYJUUohvopntpBa1AzA2TEbA== X-Google-Smtp-Source: ABdhPJwTNai3fHjKtb9PFnSMalWQiVwNiqLsoEASGl1SfmNeaqyA+50KfMn1XqggqOylimJDfCS3u1qZ+Mz6kJGjBMs= X-Received: by 2002:a67:80c8:: with SMTP id b191mr15432571vsd.36.1607715634310; Fri, 11 Dec 2020 11:40:34 -0800 (PST) MIME-Version: 1.0 References: <20201211184633.3213045-1-samitolvanen@google.com> <20201211184633.3213045-7-samitolvanen@google.com> <202012111131.E41AFFCDB@keescook> In-Reply-To: <202012111131.E41AFFCDB@keescook> From: Sami Tolvanen Date: Fri, 11 Dec 2020 11:40:23 -0800 Message-ID: Subject: Re: [PATCH v9 06/16] kbuild: lto: add a default list of used symbols To: Kees Cook Cc: Masahiro Yamada , Steven Rostedt , Will Deacon , Josh Poimboeuf , Peter Zijlstra , Greg Kroah-Hartman , "Paul E. McKenney" , Nick Desaulniers , clang-built-linux , Kernel Hardening , linux-arch , linux-arm-kernel , linux-kbuild , LKML , PCI Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 11, 2020 at 11:32 AM Kees Cook wrote: > > 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? Sure, I can rename this in the next version. Does anyone have strong opinions about the name and/or extension? Sami 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.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,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 30DC6C4361B for ; Fri, 11 Dec 2020 19:41:51 +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 D4B1623D5A for ; Fri, 11 Dec 2020 19:41:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D4B1623D5A Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com 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:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5mhPkd6EBokQJoLVNdL4CI1qu9pgDzU1cXzuNvSVmAY=; b=GplKffMAH/Pkm0cnI7H6LvZAV Q0cfTR6kwPNoFMOT7O454Fj+EFhU6TCRd50bXetKt0Mj2o45TbvMOtXPj/4WCtHSjIZT2NQgnM5ZY l8tRFO2vH35/gYsF52bNHSLSN7zRBrka/SpatjtY/m/dOWRxo2ompvEGjKfIaEy/yUQBAZB9wbziw UoJpoiaFI7tyPrCAu3TPF0W6cjv6jXgF7Vw2iMklz5jtE+GxNVNeJrYNwaJ7gtfhORCx8Xx2/vZCb +iei4VntoLVX95dh+iyc4pucw0Dg8YBnvPONe5cOdVw5M0lWgImwUAkGCgqe/tG1VWy2kkEqR1xEj 0M0GuvDrQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1knoHQ-0007c1-PQ; Fri, 11 Dec 2020 19:40:40 +0000 Received: from mail-vs1-xe42.google.com ([2607:f8b0:4864:20::e42]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1knoHO-0007ar-4p for linux-arm-kernel@lists.infradead.org; Fri, 11 Dec 2020 19:40:39 +0000 Received: by mail-vs1-xe42.google.com with SMTP id p7so5416447vsf.8 for ; Fri, 11 Dec 2020 11:40:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1nS5LJe0V9gmSV6AI/CjiJWRU085g+HSabHeZYnNbME=; b=qsqg3dEZdz6yTY0b8lWmwlvvFlCl6x/6RcbpcNM5RjlQi43vCEWHYEvpvNFMgtwSJf 92LLLXxQ2DMnh4n9P483SaIxEmprkCDc/K+JgapPX/ZZKy6aK5r4eyyfdBCtEQJhwn4x ouvYwbD1s6MDLHCs5KHgP2Xw3/OELzfJnu8FvoDrq3GDDw87fJYBXVbaSaOYc+0Nu1UD fiQbuk0q8gz7/5IDoWj0ON2iPNs+pAeF9Qty6DbvjfFV/8Wzmt8DsLQLeqTz1ozLVtyQ R0+WXz2Fbj8SqfTG7PiaJGfy0Ipx3UtxFa3GxMJFuDwuXo9nyWaQPdc+rxYInzhIXbQ8 nCbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1nS5LJe0V9gmSV6AI/CjiJWRU085g+HSabHeZYnNbME=; b=AX9APe4IVKE/ruQHli5aFaa4Wpe/OpZ6Ezk7B/eS2DiZUmO+56OYNEXSJK3vwK39em myHGZ+midfwPokN0TrJp+FD1tvMaLb1jvhfiBKaZtvOzYYjwOIM6nv15168DvvEkjyMz FvrJXPbNk3NDKLHtFv0mcpA4XXjrwzlcwxEDAFwLcQewtGSFkAnXwMlmKRpn2wtweRx/ 8LMxnySILpISdjgXdS5iDiYgpum1jK+Co4AFDTkPICWso4vb8CQ8lijJDx5HUQbZd4Wc sUpU2orCOOP+9Zkr/PkXbnzm+kqAhCiASK4nA1EA0XjPe2ZP+tyjwgtTN60981XYN++1 2suw== X-Gm-Message-State: AOAM533whcvglHp//VJ7KAdFjeNfoCVDEcIoNxSmcB3jtXUbIgJ1OLka nzexRirO6gYhxMY8BFu/NsxblomGi/zc4O4UPEAbAA== X-Google-Smtp-Source: ABdhPJwTNai3fHjKtb9PFnSMalWQiVwNiqLsoEASGl1SfmNeaqyA+50KfMn1XqggqOylimJDfCS3u1qZ+Mz6kJGjBMs= X-Received: by 2002:a67:80c8:: with SMTP id b191mr15432571vsd.36.1607715634310; Fri, 11 Dec 2020 11:40:34 -0800 (PST) MIME-Version: 1.0 References: <20201211184633.3213045-1-samitolvanen@google.com> <20201211184633.3213045-7-samitolvanen@google.com> <202012111131.E41AFFCDB@keescook> In-Reply-To: <202012111131.E41AFFCDB@keescook> From: Sami Tolvanen Date: Fri, 11 Dec 2020 11:40:23 -0800 Message-ID: Subject: Re: [PATCH v9 06/16] kbuild: lto: add a default list of used symbols To: Kees Cook X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201211_144038_254826_4C40F194 X-CRM114-Status: GOOD ( 26.71 ) 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 , "Paul E. McKenney" , Kernel Hardening , Peter Zijlstra , Greg Kroah-Hartman , Masahiro Yamada , linux-kbuild , Nick Desaulniers , LKML , Steven Rostedt , clang-built-linux , PCI , Josh Poimboeuf , Will Deacon , linux-arm-kernel 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 11:32 AM Kees Cook wrote: > > 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? Sure, I can rename this in the next version. Does anyone have strong opinions about the name and/or extension? Sami _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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=-23.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, 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,USER_IN_DEF_DKIM_WL 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 5E3E1C433FE for ; Fri, 11 Dec 2020 19:40:55 +0000 (UTC) Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.kernel.org (Postfix) with SMTP id 84BB523EB1 for ; Fri, 11 Dec 2020 19:40:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 84BB523EB1 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernel-hardening-return-20601-kernel-hardening=archiver.kernel.org@lists.openwall.com Received: (qmail 5174 invoked by uid 550); 11 Dec 2020 19:40:47 -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: Received: (qmail 5146 invoked from network); 11 Dec 2020 19:40:46 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1nS5LJe0V9gmSV6AI/CjiJWRU085g+HSabHeZYnNbME=; b=qsqg3dEZdz6yTY0b8lWmwlvvFlCl6x/6RcbpcNM5RjlQi43vCEWHYEvpvNFMgtwSJf 92LLLXxQ2DMnh4n9P483SaIxEmprkCDc/K+JgapPX/ZZKy6aK5r4eyyfdBCtEQJhwn4x ouvYwbD1s6MDLHCs5KHgP2Xw3/OELzfJnu8FvoDrq3GDDw87fJYBXVbaSaOYc+0Nu1UD fiQbuk0q8gz7/5IDoWj0ON2iPNs+pAeF9Qty6DbvjfFV/8Wzmt8DsLQLeqTz1ozLVtyQ R0+WXz2Fbj8SqfTG7PiaJGfy0Ipx3UtxFa3GxMJFuDwuXo9nyWaQPdc+rxYInzhIXbQ8 nCbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1nS5LJe0V9gmSV6AI/CjiJWRU085g+HSabHeZYnNbME=; b=Lsp4yDhKMB0WB4o/uhSuzOlNFE030Qr/vtKnCYiIpFGcNCUaHIdKkPZ76HQzqBg96p 5Dx36PIuSntI53EGs9X0ltdrs+lzRd6qniqSJQxgObZ49N75LpVldvuWoPZ6c/d9z06o wW6VI6jTCuQAtzAbBWgmW+xAfnzgkvGYOnIE5Ri7T87HW7BCn8wnDDojpVZhIfakIANj Lbdo729+kO0Gjlblxxm5ecwUb8b3Lghh1ytlE5r6XMW4H7SAzbd6z1q9jOgSM2Wge1zV J07LMVzV2LxW9dQnhP6VnAQgYrKNSAUrAhrNaJjEKXbNsMT0nCKMUgwhkchiop6k/dOY 5Lgg== X-Gm-Message-State: AOAM533XEw0nLtB0VfK0rykd49fNLFwlENpUjyhXlidb7sqoWgTuWw/5 yUCdYTKrMa2kh2ILYl3LwnPDC93ULycoLTaO1D/o3w== X-Google-Smtp-Source: ABdhPJwTNai3fHjKtb9PFnSMalWQiVwNiqLsoEASGl1SfmNeaqyA+50KfMn1XqggqOylimJDfCS3u1qZ+Mz6kJGjBMs= X-Received: by 2002:a67:80c8:: with SMTP id b191mr15432571vsd.36.1607715634310; Fri, 11 Dec 2020 11:40:34 -0800 (PST) MIME-Version: 1.0 References: <20201211184633.3213045-1-samitolvanen@google.com> <20201211184633.3213045-7-samitolvanen@google.com> <202012111131.E41AFFCDB@keescook> In-Reply-To: <202012111131.E41AFFCDB@keescook> From: Sami Tolvanen Date: Fri, 11 Dec 2020 11:40:23 -0800 Message-ID: Subject: Re: [PATCH v9 06/16] kbuild: lto: add a default list of used symbols To: Kees Cook Cc: Masahiro Yamada , Steven Rostedt , Will Deacon , Josh Poimboeuf , Peter Zijlstra , Greg Kroah-Hartman , "Paul E. McKenney" , Nick Desaulniers , clang-built-linux , Kernel Hardening , linux-arch , linux-arm-kernel , linux-kbuild , LKML , PCI Content-Type: text/plain; charset="UTF-8" On Fri, Dec 11, 2020 at 11:32 AM Kees Cook wrote: > > 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? Sure, I can rename this in the next version. Does anyone have strong opinions about the name and/or extension? Sami