Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1570166rwl; Wed, 12 Apr 2023 15:21:26 -0700 (PDT) X-Google-Smtp-Source: AKy350ZgbDmXbwfuQbK4TJIAWEn4LJ+8Fylr8bsgq21Iwxi0jYbLXNF/rts2impZPjnRg5XRsbGN X-Received: by 2002:a05:6402:8c2:b0:506:6c6a:f6d9 with SMTP id d2-20020a05640208c200b005066c6af6d9mr224141edz.3.1681338086686; Wed, 12 Apr 2023 15:21:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681338086; cv=none; d=google.com; s=arc-20160816; b=hNDb12f0503hf0fmnTsB7nAvA+/cY8r2+dSsJBS0NpQ7C5NAanhB2WKityDYS7hFm5 /vEeR/KGTVgbqFBTzKMCTTGuiWE2GIZU2fFhq65t5RZUss94PjtRnqui9Xu4+3XQ9oQ8 nBqb6XmGTRuNhjvOqJ/wivrZFRt5e+vTW+XBnfZve6Ndy481D1xPS+uaosUfwYjQpIJO UATPD/tKLcaq4ajA5M1JiL97CJEer7nSx6F0TUW2bZ8pPn8nKmMwTnsOc19YPJ88diNt 1DUoQIbb3NPE5FFQdh9m3USwMIEPPtKPesXfb+oBzRXepWMeID+CoFhr4l9BtnjfcBuF freA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QCj8bxup79BuXDH8AwqpZXzWulEn5h5LSEvlDNJXX+Q=; b=mR/DpZ6pUMScwXzKnAF4ubJWPRj4wWzVU20HlTdGwQLlrQJX9axvPAWKnOHtT7ezq7 SA+/sAoTIismt1ylYsMfUrODriMU+EF/y4x+gApe33b5iKMU6jLbuvyqU0n6KpM5L77M vcH2qcrPGs+bk4J5SbuxKgsQA4HJ/0F0HG+yENws0VHgFGQ0v3ajIPvTIiI9tYi24JFK 0i9fgmvhB76fZZE+5rNU6cR5f9MM8wmwWBbe6OT36lgZqErTRnX/JWqy39Wo1Iv9Zjlb j0rrMnJ/MtDj1LRVwP0pH3iptoKQi8i3QK+MQe3XDBHvzHWBJQjAVRMqPg/d1LtTUpdV TwPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Tus0xjha; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w14-20020aa7dcce000000b00504dfdca0f9si11114edu.234.2023.04.12.15.21.01; Wed, 12 Apr 2023 15:21:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Tus0xjha; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229679AbjDLWEY (ORCPT + 99 others); Wed, 12 Apr 2023 18:04:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbjDLWEW (ORCPT ); Wed, 12 Apr 2023 18:04:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25F947ED1 for ; Wed, 12 Apr 2023 15:04:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0A3F5639C0 for ; Wed, 12 Apr 2023 22:04:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB858C433EF; Wed, 12 Apr 2023 22:04:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681337050; bh=Cs/RuiAtC+xFvrRq6kd7R2610WkOAe2Z5xGdxRo0amU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Tus0xjhaLSMviaeNmpHYGDKK7PkRXSG0vHz7VRFdjrWVsrhlEMcbKx0GJn3xYbSM6 4yc+DfrcpaLtZrqCf1iBTsRQapO26DLSFhIMrw2ZwLj0qbUssI3m2bvVyNrLnVRzf7 kaMQsmUhyiI+rWemFnhCdHsYwQvZ7V+cKFXqWllMBEDNvvASD7mN2aMtNVinXClYv/ zPxKkmVCnr0Ah0YVuhcs0U5HGgsI3EhpFadofHyKGgmZBeCVWRY5c59Sk4vNBY9ArZ 368y6dvXiL+ub+7fe5stf+IlPVDumwBxF9X5ngSlP0NUebMsZkgUddRpz8/wF4pGww q8zy96u4IVlWA== Date: Wed, 12 Apr 2023 15:04:08 -0700 From: Nathan Chancellor To: ndesaulniers@google.com Cc: "Borislav Petkov (AMD)" , Peter Zijlstra , Josh Poimboeuf , x86@kernel.org, Michael Ellerman , Nicholas Piggin , Christophe Leroy , Miguel Ojeda , Tom Rix , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH 2/2] start_kernel: omit prevent_tail_call_optimization for newer toolchains Message-ID: <20230412220408.GB1120303@dev-arch.thelio-3990X> References: <20230412-no_stackp-v1-0-46a69b507a4b@google.com> <20230412-no_stackp-v1-2-46a69b507a4b@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230412-no_stackp-v1-2-46a69b507a4b@google.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 12, 2023 at 11:32:13AM -0700, ndesaulniers@google.com wrote: > prevent_tail_call_optimization was added in > commit a9a3ed1eff36 ("x86: Fix early boot crash on gcc-10, third try") > to work around stack canaries getting inserted into functions that would > initialize the stack canary in the first place. > > Now that we have no_stack_protector function attribute (gcc-11+, > clang-7+) and use it on start_kernel, remove the call to > prevent_tail_call_optimization such that we may one day remove it > outright. > > Signed-off-by: Nick Desaulniers Reviewed-by: Nathan Chancellor > --- > init/main.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/init/main.c b/init/main.c > index 213baf7b8cb1..c8503d02dfa6 100644 > --- a/init/main.c > +++ b/init/main.c > @@ -1152,7 +1152,12 @@ void start_kernel(void) > /* Do the rest non-__init'ed, we're now alive */ > arch_call_rest_init(); > > + /* Avoid stack canaries in callers of boot_init_stack_canary for gcc-10 > + * and older. > + */ > +#if !__has_attribute(__no_stack_protector__) > prevent_tail_call_optimization(); > +#endif > } > > /* Call all constructor functions linked into the kernel. */ > > -- > 2.40.0.577.gac1e443424-goog >