Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1487821rda; Mon, 23 Oct 2023 14:17:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3iF0G/l1GeO3apn1VPohb9lPYTyMnfoWWg6KfIxrxccO393568QdizyYUIp3LVcDsGpYj X-Received: by 2002:a05:6a20:7349:b0:17b:7dda:c0fc with SMTP id v9-20020a056a20734900b0017b7ddac0fcmr929182pzc.8.1698095876259; Mon, 23 Oct 2023 14:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698095876; cv=none; d=google.com; s=arc-20160816; b=oMwFJe67O9/mkyAIRrfeyvD56UQzcWx4DS1zecyxAs9VcPCjyYDEsekOq4vFOJmbR4 SgAlKFcg5rj8yvamP9/wx3ZxuRBjH2vRi19zJEzzUKYNwxGrMUKoghi5WaioFkRDAXOB 79wkxG/Sg1cKezW0qFWf5v/LEiAvBeO69OYsjA/FD1olX7TZ6uV2FQnc7828dsR98jJ9 3MagWi7caUSAcPM1tiMo0RopE4+/GpYiZFz4eEAzfbr43jwbkcbRjntHFOmXdCe4y7Ww zR2iEE6GSdjb3ZbtSYgzD/JH1BD0TRb6M/0TjutqNWxPIk85b8g2NKNc6TAooIw1ZU/R Mr8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lsKN0vAWTPkRoeR+0eW+M/Vw4EKK+fkuLodskFQx/7g=; fh=kGpLZLNLRje3BV+NP+TIHFvhQuUJy2o1P7WKpXu8DOs=; b=lR5kr0dPXBSjPZWVSjHoJTw5qmBqfhV0LLqw7Iy6vKIvSi2WWr+LiZjhEfG5QW7050 Ih78mXg08f28F6vONGS23tOOUj7dQKe1JedLw1tCjvNRcBpsUhQdTQD1L73y6ZpAiL3b dssVMZngUkdJR9rx0PHpc2cUUDgJD2bxHairwUO0d7pYY8aeJWbX342zJcgk8BBQBbg4 NkAtNKQg6FzavgDe4NvPAaTdL1D+dpalp6B12kMRHVqogpZYpSIIzFuZAqBk2I7NVdE8 cTG6eHLzsDf6rIaCMRzQtQnWYHmj2j4K837TSzj2O1dS+ZfA2/K56CaDKcPZHr7Cq+Rd KFHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="gb/vSNEg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id z18-20020aa78892000000b006b8b194005fsi7365434pfe.256.2023.10.23.14.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 14:17:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="gb/vSNEg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 65834804E7B3; Mon, 23 Oct 2023 14:17:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231506AbjJWVRr (ORCPT + 99 others); Mon, 23 Oct 2023 17:17:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231396AbjJWVRl (ORCPT ); Mon, 23 Oct 2023 17:17:41 -0400 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A7C3DD for ; Mon, 23 Oct 2023 14:17:40 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6ce2cf67be2so2554492a34.2 for ; Mon, 23 Oct 2023 14:17:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698095859; x=1698700659; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lsKN0vAWTPkRoeR+0eW+M/Vw4EKK+fkuLodskFQx/7g=; b=gb/vSNEg2Q3s9/RrpcxJ/PtZ+1dOQPa4zedcpnbt85vl6tkTXAscaEzDw4hBWiF26O yiAdYXpvedx6LZkLrQRPBlD/iuoyg+5uy8Qp0NCiB0AAaDvROCn5FpL1p2d6KU9JLiRh bd5Ymt3CHFzb1Il5M/JJCYLBr26SAKYsRFCpwPfXQuJ56xvpsxy74IsN3nGTxxu0mkXs F0vNG/wZAADbvRTWHdllufTyTZO2qOgPp+lUNhYM+vs26DuZjCqg/gJVIVck7eCcWjnE 1zzeL+LJrAZ8o6iF9gHxuvxwfu1Lpcy8bcnWmfi9MQRk5sbMvcX3/mkLX5aR/l05RGD6 KpoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698095859; x=1698700659; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lsKN0vAWTPkRoeR+0eW+M/Vw4EKK+fkuLodskFQx/7g=; b=MwQQ8CYUTLQzQCWa/6nXyYj1HrnkRRrss7BzXUfIOZWFi3PskjmJ3VQCxhinAqXxCj s6e16O8glXNdeKsN89W4pYv1nmSfHFcF0iHXsZ3PMTthjvu/Wf2Z3WLd3jNFvl0qQZDX RAKc1UgFpBHkSeLOj9xv8iVFmTDByh/v2r+Y/M9LxLVy+2utn9ysQgq31fj3hBombVj9 oJTSQhFXbtx528HNIef+E6YuEdMLJADEKYkfEo87FajwGK/vo4ad1nYta/Li+uXN9yvk WOI6nVC6a1EnO0TX0EAP74e/PZC9WL/Wb7vMdZE8GseJxOXXkuv9DfqyTVqXjEh/AJLG QcNA== X-Gm-Message-State: AOJu0YzEakWl3WAte0wf8AX+4aEQfa2r6bBUzMsw+FmGaywD7mEkIe7r djdda5+P0zr4M74GmTTds3P3ajmZTw== X-Received: by 2002:a05:6830:2b23:b0:6be:fe1e:c13 with SMTP id l35-20020a0568302b2300b006befe1e0c13mr14809191otv.0.1698095859110; Mon, 23 Oct 2023 14:17:39 -0700 (PDT) Received: from citadel.lan ([2600:6c4a:4d3f:6d5c::1019]) by smtp.gmail.com with ESMTPSA id o139-20020a0dcc91000000b00583e52232f1sm3485430ywd.112.2023.10.23.14.17.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 14:17:38 -0700 (PDT) From: Brian Gerst To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Ingo Molnar , Thomas Gleixner , Borislav Petkov , "H . Peter Anvin" , Peter Zijlstra , Uros Bizjak , Brian Gerst Subject: [PATCH 2/9] x86/boot: Disable stack protector for early boot code Date: Mon, 23 Oct 2023 17:17:23 -0400 Message-ID: <20231023211730.40566-3-brgerst@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231023211730.40566-1-brgerst@gmail.com> References: <20231023211730.40566-1-brgerst@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 23 Oct 2023 14:17:55 -0700 (PDT) On 64-bit, this will prevent crashes when the canary access is changed from %gs:40 to %gs:__stack_chk_guard(%rip). RIP-relative addresses from the identity-mapped early boot code will target the wrong address with zero-based percpu. KASLR could then shift that address to an unmapped page causing a crash on boot. This early boot code runs well before userspace is active and does not need stack protector enabled. Signed-off-by: Brian Gerst --- arch/x86/kernel/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index 0000325ab98f..aff619054e17 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -39,6 +39,8 @@ KMSAN_SANITIZE_nmi.o := n KCOV_INSTRUMENT_head$(BITS).o := n KCOV_INSTRUMENT_sev.o := n +CFLAGS_head32.o := -fno-stack-protector +CFLAGS_head64.o := -fno-stack-protector CFLAGS_irq.o := -I $(srctree)/$(src)/../include/asm/trace obj-y += head_$(BITS).o -- 2.41.0