Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2505107rdb; Tue, 12 Sep 2023 04:13:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFi+baoLaSvkPc6vTzabsbecGGK4r3I8V+/FEBxbwIVOAdk8eq5DD0JW47tgvYZi9mrO0Br X-Received: by 2002:a17:902:db09:b0:1bf:8132:d1a5 with SMTP id m9-20020a170902db0900b001bf8132d1a5mr12650871plx.26.1694517204727; Tue, 12 Sep 2023 04:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694517204; cv=none; d=google.com; s=arc-20160816; b=B+DwkqEufQHF3N5yComJiLhCnIkG5s+/6fCUKhDI+hp+xxXUCIhZ2M3zca3pKjR/Xu IL5Klw4w9YJhA6QILiNhKS3+vscVmR+xrX9rj2tipkQJfDPASc2ak+vsz9dRlwPYAaga 6DiC7UNDeXvDUDd8jhCdzbvDPtCxZRsdieRTfMqhVrcKFPkScOK1vaE0tOqU4IYM8TU8 S9ahFYFFiWqr4jPh4KMEv23fCUGd022bIOqC5lxwWYMuDXszAhoMj/WFXsVZiJ6TUhTJ rJFp4LE0crQP0T3FEEwC71X2xYSvcdySYaOr+QsgcWXU7ByLpe2NqN2i5gnfvmQEIAX6 qPWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=w4iWy4H04gKoxDxbBdcXl1DLzwa8M24xJYhbSoNX0o4=; fh=u57tXYamzTrJA+Ht8n1u7SfTMptrQaIb6LVW+jsaYf4=; b=nnqjSf76JabOI97AcAUKbs0AlE4/OlgoCxIkfdDWRFZWHUEhQLvbh/ztgRgQpSBeQE jBINFNojS9JGz60cDIzzaNPwGp91McMCuuBMQojmbcCllgSEU6PCJtU2OCtBCf/D1WCH +qLZaudMPvna+VXjZWsfPuYW0oBrC0SzGCJDkeWEkVrZxu5D/GB3rHpRrF68uy4wYjdS RMwUD4mGNEdnZwOISTeB4E6UlwdvpByrq8SVvgQnhyoo0J0CumhKOwQLo0CAuGr05edy KBToGCVvd9uBn9+akm2+kUoJRkY9oOL9dbrUyORprYQNPhXuQV7m9VMddPO0jZkYuw2r Ozcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=QVS7DXoH; dkim=neutral (no key) header.i=@linutronix.de; 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 z3-20020a1709027e8300b001a94b91f402si7794963pla.218.2023.09.12.04.13.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 04:13:24 -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=QVS7DXoH; dkim=neutral (no key) header.i=@linutronix.de; 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 8BC7A80298A0; Tue, 12 Sep 2023 00:58:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231883AbjILH57 (ORCPT + 99 others); Tue, 12 Sep 2023 03:57:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231571AbjILH5w (ORCPT ); Tue, 12 Sep 2023 03:57:52 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D808E7C for ; Tue, 12 Sep 2023 00:57:48 -0700 (PDT) Message-ID: <20230912065500.886599632@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694505467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=w4iWy4H04gKoxDxbBdcXl1DLzwa8M24xJYhbSoNX0o4=; b=QVS7DXoHfiAtIMT7nPbf0KrP6V5vPE3x1jqj17hq83l58q7P0CiBSeqOYOSAgszoPRRM9J civFqb+6Pwy9vMgNKeOBngH+zSSwDoNC3ehWh2/r0E9Ek2LswhofmNnOanwBawgZN+WppN 4z0EyFvWIDdcTtbAZr8VTNinktpYQTJ3+rkO0eyI5dIMcCcJTl6t1ZN7xeRxgSpL+AycIp wwDP4veUqz305eFXyzEeWoOs4gN4zU8yJZfYjqOX/+o1vMfhW1U1MMFpo5xv1Z6eLQXRG5 SocWvTc/gCFwxStw5A7ApDzS5l6PNIva4RzMoR3CptQyOQbBDDBLrWY8k6UPgQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694505467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=w4iWy4H04gKoxDxbBdcXl1DLzwa8M24xJYhbSoNX0o4=; b=fR4UnP7Rrd5eP0Du3qjVv8dtgpIH2R/xhVPFAjUnYJjXBL58MlfMA73V6Yj0AMk1m+0KcZ S9mGLs/V6hqSRBCQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Borislav Petkov , "Chang S. Bae" , Arjan van de Ven , Nikolay Borisov Subject: [patch V3 02/30] x86/boot/32: Disable stackprotector and tracing for mk_early_pgtbl_32() References: <20230912065249.695681286@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Tue, 12 Sep 2023 09:57:46 +0200 (CEST) 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]); Tue, 12 Sep 2023 00:58:27 -0700 (PDT) X-Spam-Status: No, score=-0.9 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 groat.vger.email 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 physcial address mode which again might work by chance. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/Makefile | 1 + arch/x86/kernel/head32.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) --- 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 --- a/arch/x86/kernel/head32.c +++ b/arch/x86/kernel/head32.c @@ -73,7 +73,8 @@ asmlinkage __visible void __init __noret * 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