Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp956187rdb; Fri, 20 Oct 2023 04:43:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZ/NxIhgidxktvBIV6YE0w2g8sTjcmEPt3QuRgEzAHd59R/VyTcQU+QW+0+l18Plm60t/k X-Received: by 2002:a17:902:db06:b0:1c6:23fd:fb18 with SMTP id m6-20020a170902db0600b001c623fdfb18mr6758586plx.0.1697802200256; Fri, 20 Oct 2023 04:43:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697802200; cv=none; d=google.com; s=arc-20160816; b=QfRcKi5RpjKXRltn0xKrb+JINGCgFOYUctNZVS5sWjGLaVKcjUx5UgcxbuI/cXzpRk Xu/dsswg7wFdtG07KlebqYdqMEBABBJ9v5Mp31x+ZQNRJetALBdqyDxk5ugqatxEE92i 5grgwrLk8IIhRZ4hTugmsC8TNTmmKr2z156ClDHTY82qwQCHmmomvQQc+MwKW9mJ7OKA +1KMlPlylUGGiv3dYya3EI+TQ+VOkAetcWQrFDJ0zE55TAoGdVzTqLDMcLJCtkseReiN d4zAKwwFohQFE9sn6stNYniqZwWZkV7aLvWX6+w8ukkkBJkBD1ea4ckSwZCp2Y09bkll CG8g== 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=/r6TKfAIPF4DGJsQq1QWq5Z7B0tfCqdwYnDmLEgikdw=; fh=LWlv3U+xZ3+vQt4tlJRIlKl5VzN7iFjjE/bzRmlxKDA=; b=BqbXfvxNQoSLH6sNZSwI5zu8CTxGuwKD6G22lrmz5C5lhoYE0WWMJrsC14HmEDNNIE tZwRw9sQeXXDhv+8/eVaZVSyc5DbRV9eZChf9/qXObqGUDCsFPAz/8Rj7PAFm6TZtdlp 7ThNg4tbF9pTUHFGjqilzVFJ6/aV29g/lnWN0wciP7paXnMdvvq78XSFmH/0ubr69/yH 9fRU4IBXidjp6ttZJD3lP0TnIQ7gGLeTYYfZSUk2XG/OVnCi+1DVquH0oUx+btqdLTyt W4Re+q5F2IWUfzbPrr8+rWr5apeb8+TVBDZr8VJk7/tHuUDxC4F/yW1csRGvxo4lo3vU LVMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Tp5Rah7f; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id m5-20020a170902db8500b001c753d6b95fsi1541119pld.315.2023.10.20.04.43.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 04:43:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Tp5Rah7f; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id A30AC831A486; Fri, 20 Oct 2023 04:43:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377335AbjJTLm2 (ORCPT + 99 others); Fri, 20 Oct 2023 07:42:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377274AbjJTLmG (ORCPT ); Fri, 20 Oct 2023 07:42: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 0FF9E1BD8; Fri, 20 Oct 2023 04:39:01 -0700 (PDT) Date: Fri, 20 Oct 2023 11:38:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697801886; 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=/r6TKfAIPF4DGJsQq1QWq5Z7B0tfCqdwYnDmLEgikdw=; b=Tp5Rah7f6feNE2r4Oj3mkhFPPjRsjoJdGkkt4V/0Dr92ZQMO3OdLRttMQU8z0o3XFAwE6+ 01zfnIH56+tpFzvFK1kp8gVVd7Ksw1Gr54n1JxBikQ848pg1JlUuslhKjhe9D13GM0bxKP avhfXLZ6qDHSo5P7XCZpNZoKqij/o3wWLdz8fE4HTAG+ZKdD4VZDhYAsTELciwxcmPmrG2 r8dGAYQLK5aCa5EML5+6R598Pb6jzhuaEFncif2fH4+DXNIm/4qrEd/o3iLeYQQvw7Zu0p 0lach3D1StsrbDdjSYMEA/9Lw23iSHbWNtPZV1clvbkoKMrD7Q86vE+S8KAaYQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697801886; 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=/r6TKfAIPF4DGJsQq1QWq5Z7B0tfCqdwYnDmLEgikdw=; b=KvxXJTJXy4FouC170ttL2MVUGbzZ0drlbwj1hlP7xYVw3LNFLV2+ZoJAIorT5wrXa0Am6n MwysuABAG2BytsBw== 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: <169780188598.3135.13135735219422593841.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=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Fri, 20 Oct 2023 04:43:04 -0700 (PDT) The following commit has been merged into the x86/microcode branch of tip: Commit-ID: 242db7589460ca94e28c51ffbddd621756f97e11 Gitweb: https://git.kernel.org/tip/242db7589460ca94e28c51ffbddd621756f97e11 Author: Thomas Gleixner AuthorDate: Mon, 02 Oct 2023 13:59:36 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Wed, 18 Oct 2023 11:11:43 +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 246a609..bf678d6 100644 --- a/arch/x86/kernel/head32.c +++ b/arch/x86/kernel/head32.c @@ -70,7 +70,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