From patchwork Thu May 18 11:08:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 95786 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp407794vqo; Thu, 18 May 2023 04:12:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ofBuyKnJrsiYZ92MBd2GGRcNEjRVTZSLG2/T27gDCJ3AZx9vpj8YLz4yTBqL19FtKjt9v X-Received: by 2002:a17:903:441:b0:19d:1bc1:ce22 with SMTP id iw1-20020a170903044100b0019d1bc1ce22mr1777332plb.5.1684408320158; Thu, 18 May 2023 04:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684408320; cv=none; d=google.com; s=arc-20160816; b=GBLs45FWc1qf5DJd6WKu+FCRy8TKG/DDG+hmHlPkZ8TmljBfBRvL2EguIH4qVbLo+y vhw3dQYE/ljDuFUuH4vhCI3EDjBOEnEdG9Y+KrrBpm6vFbOF4UHCj4HuUh3LITqb5aBY wWMqRZmcVCtZbm9xzN5eIFWBB93E6R8US5iq9DXnuCGMdM0VlLj5nBUHBU81WKo3Odwx +yqnMoXMi1aPLk9d9Kx7y6e1Cyu7Z2dy9VCGvZaXbqmAehGYD5hHu7jGPK64cUciW0Lh bCF0IRgPTqfNXljXMIQLxnXycXKC6ZR89QvVU3yBmdkY/MsyEYXT0Rtgn94f1LAmqFVM Saxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=lfkepp8n9DFZjIdQo9gJbfuMIUEXsMOcfYyoO10MrH8=; b=lu/EF6WIziYGoCfFgxvSPciQFkjA+xAO4H0b0cKSAV/R6behw1t73rQq7CWRDODY// d7WMzBrKGddWIgpH69HNIs47wGd+0iOAsltQxLPoOkPkrOvpkQk5va5744RpumMud10r VqJBziExhXH9HKPb9IS4Dxtmt1T7gjBhsNaqgjI2Bwt6CuuW6iv5voeZaV2yhQZ/bsep Sj+z1mjsSlkilUvmhN0ROLWWHak1pDXH21x/tQNo3mSX+XiKGm2w+Rqgq94wh+fhz4il /hSvXOmkzspaJjHWcExxvvEv42Eb8IZh7JzmqIu+c0Uy3XcfudGLdNqxb48Gc2mDjNcE 3d3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=BwJNbCj0; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z23-20020a1709028f9700b001a95c413f7csi927717plo.550.2023.05.18.04.11.44; Thu, 18 May 2023 04:12:00 -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=@linutronix.de header.s=2020 header.b=BwJNbCj0; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231207AbjERLJY (ORCPT + 99 others); Thu, 18 May 2023 07:09:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231187AbjERLJS (ORCPT ); Thu, 18 May 2023 07:09:18 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4088213D; Thu, 18 May 2023 04:08:36 -0700 (PDT) Date: Thu, 18 May 2023 11:08:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684408084; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lfkepp8n9DFZjIdQo9gJbfuMIUEXsMOcfYyoO10MrH8=; b=BwJNbCj0VN6R7V2EHWwIaBgGkZCJ95UoaCEk8mvrYaJ5zA5tpyLHz7CizyzexXxYX/pWdv G+taMZXycG50/IB9gQ1iPaqPyRW/4o4GFfEhmPU5ceq4GLjc8//JwU+Ov5VJ0cPsDl0WXN m36wRpoXaCCm/HZs5ARVtvohuleFZk31ANN5ceiqBCBb5ZsxwfjFNG2CdNQ94qS7GD6AFR YNlUVJ7Spd6SFrfZ1ZZKMaiK2Oa/j08MXIMnbIDoy11KKdDQpoAeGytGSN0B5x6ESC5K+I GvZDkNcn+PR59BVuwx/myRABeF8JnOTOhETUFWY2Dvunor8osV0d0PtonkWV/g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684408084; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lfkepp8n9DFZjIdQo9gJbfuMIUEXsMOcfYyoO10MrH8=; b=/Wdj8QuvCS4oklEpE+zW91Cg8CTx3OU92Thcu2KWbfVmU0JW9h9V+3D6TMYhGoOp5evMKF DqyI5ruMsslOT6BA== From: "tip-bot2 for ndesaulniers@google.com" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] start_kernel: Omit prevent_tail_call_optimization() for newer toolchains Cc: Nathan Chancellor , "Peter Zijlstra (Intel)" , Nick Desaulniers , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230412-no_stackp-v2-2-116f9fe4bbe7@google.com> References: <20230412-no_stackp-v2-2-116f9fe4bbe7@google.com> MIME-Version: 1.0 Message-ID: <168440808364.404.15005624206596163176.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766230138700995688?= X-GMAIL-MSGID: =?utf-8?q?1766230138700995688?= The following commit has been merged into the objtool/core branch of tip: Commit-ID: dc1d05536f44cee16e46e86316e6718b2c0d8872 Gitweb: https://git.kernel.org/tip/dc1d05536f44cee16e46e86316e6718b2c0d8872 Author: ndesaulniers@google.com AuthorDate: Mon, 17 Apr 2023 15:00:06 -07:00 Committer: Josh Poimboeuf CommitterDate: Tue, 16 May 2023 06:28:24 -07:00 start_kernel: Omit prevent_tail_call_optimization() for newer toolchains 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. Reviewed-by: Nathan Chancellor Acked-by: Peter Zijlstra (Intel) Signed-off-by: Nick Desaulniers Link: https://lore.kernel.org/r/20230412-no_stackp-v2-2-116f9fe4bbe7@google.com Signed-off-by: Josh Poimboeuf --- init/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/init/main.c b/init/main.c index c445c1f..c0b6499 100644 --- a/init/main.c +++ b/init/main.c @@ -1088,7 +1088,13 @@ 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. */