Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1861681rdb; Mon, 9 Oct 2023 05:32:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzjxIKTWqaf/oyQkVvW7aMCmT/JOBLHifpRCQxE7B3lzHTbACj/PmQ9pChFPxc/mbGNQSt X-Received: by 2002:a05:6808:190a:b0:3af:9851:4d32 with SMTP id bf10-20020a056808190a00b003af98514d32mr21289582oib.7.1696854730231; Mon, 09 Oct 2023 05:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696854730; cv=none; d=google.com; s=arc-20160816; b=SHZJ0CQnUF2+MGY8cfQ9m9yEtPdiGZ2wnfTN5TPfQleMA/z8u07EzTUGqz6OAUn6wQ LC1ETWQUkTiK3Zt2C7L8DnE41cik8HjPc/hUjlLfqyodOj8eAsHJBSCEqTRdLkZZCPn4 Ikfa2B/whBVA5NMHOIMBl8oSVhCscH6iO2BN+Lc87jxMl+sZhShkO4gO5UD3x6WwgtuY 9r0ps8x49/A2cweN09036s/vnsR02zjxQyw82Z2ojO0Weaw4ad19PeYSTGUN/tLMc5L+ 3tra6BGT9nk1/OscgpQ4IKnllUOJWr2/Wb2z2yefVLBHNJ6uxaPupaOOMurVy4Bjs96Y 1/pQ== 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=Z8ksFlmH8l12KjEXC71P0Q65qAQVpeKQXFiaMDA686k=; fh=LWlv3U+xZ3+vQt4tlJRIlKl5VzN7iFjjE/bzRmlxKDA=; b=RBlppVJot5NsOw4tqErJ5Wh7EJp6KHcrlCAkwPHKjF0EjVvYvKJDThK0h9Alih8oNZ +j6r4Zb8MlrrVQv86654uQMj0N6cqRJLhN27wOGz/FPGR5AxNQOX9Vjnihmc/MuowM6a Rx7nNid+n+p746ki6ShmhFIc5MyxJf63CqPkc6eDvP3sRfPW6X1fIum5en3pdUDoj+Z+ HQ7/uZiz6urfEtB0F8+yiKHtpIpV3VS97W735EkUel/E0oEQ7Ft7pVelK1IZEC36367Q b7KC1s46jyvACjR5pBdniGZ0MG39cLyYYuODYf/q8QKRVSG4qMRyfQlw5m8v9AYE2sxK nBYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=FsZLYOtj; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=IHxzndGT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id e2-20020a636902000000b00585a45417absi9125013pgc.267.2023.10.09.05.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 05:32:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=FsZLYOtj; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=IHxzndGT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 58A4980A9F4D; Mon, 9 Oct 2023 05:31:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376681AbjJIMbV (ORCPT + 99 others); Mon, 9 Oct 2023 08:31:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346597AbjJIMaG (ORCPT ); Mon, 9 Oct 2023 08:30:06 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F6ED115; Mon, 9 Oct 2023 05:29:58 -0700 (PDT) Date: Mon, 09 Oct 2023 12:29:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696854597; 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=Z8ksFlmH8l12KjEXC71P0Q65qAQVpeKQXFiaMDA686k=; b=FsZLYOtjwo06nspYDw/Ak6qHTQciRNgRUGSpSfe0CPvMl+q/aRQPGfwikFjVS+dFN0iDXD Vhm7Q9k+jy5xynjpXP73/5KB6O/n6RWU+wzxCSn/yejabJhNLNO1rRmnWQZA4T6wc97Lmd zKK7IaSk2UoWpepugE0EALshZcGZC8BlHkHvmgcMnnEbuuM+vzllK3HrhYUuLC6IjiY1kF SK+vJ5FidbkmDz6e7CBggprTb6n5I9VVUFQLcY3nbo2qF45tydtXeLPCm3ivh5kOx63+Zx KJOUVPTy1NM+BnqLcBUlFwBZcgpDNTmDvYNyCksjhGNJzFBW1H7H0J07N70KEw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696854597; 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=Z8ksFlmH8l12KjEXC71P0Q65qAQVpeKQXFiaMDA686k=; b=IHxzndGTYbxNMdwTZjDvK5ZaHcOT1TN1MjyxdwY8g/keh48DpIh6eIor+6xt3HJK2rKdHE amJ31ZLYP+bmYfAA== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/microcode] x86/boot/32: Disable stackprotector and tracing for mk_early_pgtbl_32() Cc: Thomas Gleixner , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231002115902.156063939@linutronix.de> References: <20231002115902.156063939@linutronix.de> MIME-Version: 1.0 Message-ID: <169685459633.3135.10588556494903023033.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 09 Oct 2023 05:31:57 -0700 (PDT) X-Spam-Level: ** The following commit has been merged into the x86/microcode branch of tip: Commit-ID: b6bedf0825b8a74edef6fa7100cb078e879bbce7 Gitweb: https://git.kernel.org/tip/b6bedf0825b8a74edef6fa7100cb078e879bbce7 Author: Thomas Gleixner AuthorDate: Mon, 02 Oct 2023 13:59:36 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Mon, 02 Oct 2023 18:25:49 +02:00 x86/boot/32: Disable stackprotector and tracing for mk_early_pgtbl_32() Stackprotector cannot work before paging is enabled. The read from the per CPU variable __stack_chk_guard is always accessing the virtual address either directly on UP or via FS on SMP. In physical address mode this results in an access to memory above 3GB. So this works by chance as the hardware returns the same value when there is no RAM at this physical address. When there is RAM populated above 3G then the read is by chance the same as nothing changes that memory during the very early boot stage. Stop relying on pure luck and disable the stack protector for the only C function which is called during early boot before paging is enabled. Remove function tracing from the whole source file as there is no way to trace this at all, but in case of CONFIG_DYNAMIC_FTRACE=n mk_early_pgtbl_32() would access global function tracer variables in physical address mode which again might work by chance. Signed-off-by: Thomas Gleixner Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20231002115902.156063939@linutronix.de --- arch/x86/kernel/Makefile | 1 + arch/x86/kernel/head32.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index 3269a0e..0000325 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -16,6 +16,7 @@ CFLAGS_REMOVE_kvmclock.o = -pg CFLAGS_REMOVE_ftrace.o = -pg CFLAGS_REMOVE_early_printk.o = -pg CFLAGS_REMOVE_head64.o = -pg +CFLAGS_REMOVE_head32.o = -pg CFLAGS_REMOVE_sev.o = -pg CFLAGS_REMOVE_rethook.o = -pg endif diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c index bde27a3..f34b15c 100644 --- a/arch/x86/kernel/head32.c +++ b/arch/x86/kernel/head32.c @@ -73,7 +73,8 @@ asmlinkage __visible void __init __noreturn i386_start_kernel(void) * always zero at this stage. */ void __init mk_early_pgtbl_32(void); -void __init mk_early_pgtbl_32(void) + +void __init __no_stack_protector mk_early_pgtbl_32(void) { #ifdef __pa #undef __pa