Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5276467rwl; Sun, 8 Jan 2023 11:54:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXvuV+OMV47Kzq+GxmKB+4etLOVha//v4ULpUewh4gZRquYcd0oGr+gx3XJNDBZCQhs4alr/ X-Received: by 2002:a05:6a21:158a:b0:a4:64c7:a7f1 with SMTP id nr10-20020a056a21158a00b000a464c7a7f1mr49675699pzb.14.1673207699209; Sun, 08 Jan 2023 11:54:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673207699; cv=none; d=google.com; s=arc-20160816; b=QZSpZd42k+WdbqAYvktuXI7q/DO1F1s5DlhhCGXTCvF7o5sHmCtiH3+W0bMHygKFhI 3jAZjyVCuymUpY6BZrlmlU3r6EkKO2IAGzVbThOt2czkOjPu5QyIoYqhj2hhKSwfhtTn FSw+U+lRVVt9Lpo5HUaNBP22rieDYK0r2mKN+3n6ssmJWz4axb54D4HZEQVBQM9YNU76 IXuD8e9fuZwbrzs2K4viMaqARCoTo222YKTlwQLW9/hQHtBUrKILNVC0XrB/JZ7kHY6d z/rHC7Q818WJsAYeCB7I0MMJGULlFR6z3IS/wDoc+4o2ETd9Z5N5h4PJ0JP7JYWyTPAy BS5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:subject:cc:to :from:date; bh=h815jb+y78TcHgEmdy3iwlcqwBlw3G7MnNgOHa3ukFU=; b=EXKZmymN5mdemULryYJbAvNFB/gRS3eYIxq83EGDto7/NeZXom2KlwM2R13bp77GdV EFGYlgo+K1V3ccexy2rka2d5IIaJNPmHIS6j9EUhrWsElB14NcJbKyWk6pIflh5xctIq zfUpboJsc6uLBnu7yZbSC7ZWOKJ4ik+sjYdKnI6lVzwHZTwbUralpPfeyQ74fiE4/PvK x9HA9aeqaju1dMXEMjfxPy3ENXCbwkWUqzDODUf82acYEj93vuslLP1qyaf/iMzZyUCL ZQk19eWnqfuD+++DJZS/rAyQG786YCk1dDqdh0VpcLoZF0iG4r0aC+I1B6AtGqM04nPc Q0Dw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 33-20020a631461000000b0046f5808167asi7870186pgu.812.2023.01.08.11.54.50; Sun, 08 Jan 2023 11:54:59 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233253AbjAHTnE (ORCPT + 53 others); Sun, 8 Jan 2023 14:43:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233724AbjAHTm6 (ORCPT ); Sun, 8 Jan 2023 14:42:58 -0500 Received: from angie.orcam.me.uk (angie.orcam.me.uk [78.133.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6D361324 for ; Sun, 8 Jan 2023 11:42:56 -0800 (PST) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 0D1CC92009C; Sun, 8 Jan 2023 20:42:55 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 08EF392009B; Sun, 8 Jan 2023 19:42:55 +0000 (GMT) Date: Sun, 8 Jan 2023 19:42:54 +0000 (GMT) From: "Maciej W. Rozycki" To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" cc: x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] x86: Disable kernel stack offset randomization for !TSC Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_HDRS_LCASE 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 For x86 kernel stack offset randomization uses the RDTSC instruction, which causes an invalid opcode exception with hardware that does not implement this instruction: process '/sbin/init' started with executable stack invalid opcode: 0000 [#1] CPU: 0 PID: 1 Comm: init Not tainted 6.1.0-rc4+ #1 EIP: exit_to_user_mode_prepare+0x90/0xe1 Code: 30 02 00 75 ad 0f ba e3 16 73 05 e8 a7 a5 fc ff 0f ba e3 0e 73 05 e8 3e af fc ff a1 c4 c6 51 c0 85 c0 7e 13 8b 0d ac 01 53 c0 <0f> 31 0f b6 c0 31 c1 89 0d ac 01 53 c0 83 3d 30 ed 62 c0 00 75 33 EAX: 00000001 EBX: 00004000 ECX: 00000000 EDX: 000004ff ESI: c10253c0 EDI: 00000000 EBP: c1027f98 ESP: c1027f8c DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068 EFLAGS: 00010002 CR0: 80050033 CR2: bfe8659b CR3: 012e0000 CR4: 00000000 Call Trace: ? rest_init+0x72/0x72 syscall_exit_to_user_mode+0x15/0x27 ret_from_fork+0x10/0x30 EIP: 0xb7f74800 Code: Unable to access opcode bytes at 0xb7f747d6. EAX: 00000000 EBX: 00000000 ECX: 00000000 EDX: 00000000 ESI: 00000000 EDI: 00000000 EBP: 00000000 ESP: bfe864b0 DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 007b EFLAGS: 00000200 ---[ end trace 0000000000000000 ]--- EIP: exit_to_user_mode_prepare+0x90/0xe1 Code: 30 02 00 75 ad 0f ba e3 16 73 05 e8 a7 a5 fc ff 0f ba e3 0e 73 05 e8 3e af fc ff a1 c4 c6 51 c0 85 c0 7e 13 8b 0d ac 01 53 c0 <0f> 31 0f b6 c0 31 c1 89 0d ac 01 53 c0 83 3d 30 ed 62 c0 00 75 33 EAX: 00000001 EBX: 00004000 ECX: 00000000 EDX: 000004ff ESI: c10253c0 EDI: 00000000 EBP: c1027f98 ESP: c1027f8c DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068 EFLAGS: 00010002 CR0: 80050033 CR2: b7f747d6 CR3: 012e0000 CR4: 00000000 Kernel panic - not syncing: Fatal exception Therefore do not offer the option for CPU configurations that do not guarantee the presence of this instruction. Signed-off-by: Maciej W. Rozycki --- arch/x86/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) linux-x86-randomize-kstack-offset-tsc.diff Index: linux-macro/arch/x86/Kconfig =================================================================== --- linux-macro.orig/arch/x86/Kconfig +++ linux-macro/arch/x86/Kconfig @@ -186,7 +186,7 @@ config X86 select HAVE_ARCH_USERFAULTFD_WP if X86_64 && USERFAULTFD select HAVE_ARCH_USERFAULTFD_MINOR if X86_64 && USERFAULTFD select HAVE_ARCH_VMAP_STACK if X86_64 - select HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET + select HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET if X86_TSC select HAVE_ARCH_WITHIN_STACK_FRAMES select HAVE_ASM_MODVERSIONS select HAVE_CMPXCHG_DOUBLE