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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,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 AF5A5C43464 for ; Fri, 18 Sep 2020 21:29:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6448A222BB for ; Fri, 18 Sep 2020 21:29:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="W+/RKJ9p" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726344AbgIRV3k (ORCPT ); Fri, 18 Sep 2020 17:29:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726250AbgIRV3j (ORCPT ); Fri, 18 Sep 2020 17:29:39 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 419F5C0613D1 for ; Fri, 18 Sep 2020 14:29:39 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id d19so3671122pld.0 for ; Fri, 18 Sep 2020 14:29:39 -0700 (PDT) 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=GaeOhHfh8L1DCmfaELuYzcrF6n6HIXLIYRNTzqsV79Y=; b=W+/RKJ9pTVfHlLkwso1szh6HtM1ljwgfll2m1S7UpWBfhGNOhcAgS0vcics0UCB6P6 dN86cdQ1w9MJuw6LvS3fM80dVq9dvH5tMXxpAqqbGZHk658zN870WIKFcsCTayCfDtNQ T7NafpHvlBEzNZ5MQFycOCV7aKSjbwjKdKCPc= 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=GaeOhHfh8L1DCmfaELuYzcrF6n6HIXLIYRNTzqsV79Y=; b=aB4Y6R7hXBu/SlVNvRougLHsB4rnMxxnfMGN/Q4XNw3u3A/mY1whyTTLZ7d+Arm4xd AmzvqsdTHgAZ0wtTUTghxR8rloH/vy3bjlp7VI/aTTOsFFY3vVXB+ouSDN5Y+X6LYA55 J/WHsqPKh24dqpwucAoYREmVVlzcSGfFVdks38dHq+0TGISQt3RTfGA1KawprAfLH+kO YNJ4EFMm3zzSJbBpRk1H+1d6AHnW1qd97jUa2af6kVA2M6UkHWEGIDoSfD0viIEpXe+3 TMpXDIpqc8rsJVVnriVrDMY2E4IJnpzdZC0zPn/xKJYn3lhAowt2oWkef0/7vBpDYxZO oSrg== X-Gm-Message-State: AOAM531mlt7bTmrZQHWDAZug23OmacirUklYa9fS0sVjnHSq7z48XaGc xrfosXBkIJeNcnDHOW+fUXu5/g== X-Google-Smtp-Source: ABdhPJyRQsmmFdjwcGkpqBzOOW1CFrolZnNpgZgaeJg1rXVSbKFTb9+lQpAZIZvZVlks1h2iMqNz4w== X-Received: by 2002:a17:90a:ad48:: with SMTP id w8mr14636473pjv.179.1600464578722; Fri, 18 Sep 2020 14:29:38 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id l188sm4167409pfl.200.2020.09.18.14.29.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 14:29:37 -0700 (PDT) Date: Fri, 18 Sep 2020 14:29:37 -0700 From: Kees Cook To: Sami Tolvanen Cc: Masahiro Yamada , Will Deacon , Peter Zijlstra , Steven Rostedt , 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, x86@kernel.org Subject: Re: [PATCH v3 17/30] init: lto: ensure initcall ordering Message-ID: <202009181428.3C45B57DA@keescook> References: <20200918201436.2932360-1-samitolvanen@google.com> <20200918201436.2932360-18-samitolvanen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200918201436.2932360-18-samitolvanen@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 18, 2020 at 01:14:23PM -0700, Sami Tolvanen wrote: > With LTO, the compiler doesn't necessarily obey the link order for > initcalls, and initcall variables need globally unique names to avoid > collisions at link time. > > This change exports __KBUILD_MODNAME and adds the initcall_id() macro, > which uses it together with __COUNTER__ and __LINE__ to help ensure > these variables have unique names, and moves each variable to its own > section when LTO is enabled, so the correct order can be specified using > a linker script. > > The generate_initcall_ordering.pl script uses nm to find initcalls from > the object files passed to the linker, and generates a linker script > that specifies the same order for initcalls that we would have without > LTO. With LTO enabled, the script is called in link-vmlinux.sh through > jobserver-exec to limit the number of jobs spawned. > > Signed-off-by: Sami Tolvanen Thanks for the update; using jobserver-exec looks much better for controlling the build resources. :) Reviewed-by: Kees Cook -- Kees Cook