Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5280595rwl; Sun, 8 Jan 2023 12:00:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXuhGNXb0KIkK0vcxom3IMQeRQXrzc1GR2weuoYa2DTJ/1tkuA/y6AnYq8xn8BAU6M24tZtb X-Received: by 2002:a05:6a20:e61a:b0:ac:a4fd:f5bf with SMTP id my26-20020a056a20e61a00b000aca4fdf5bfmr78432715pzb.50.1673208052322; Sun, 08 Jan 2023 12:00:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673208052; cv=none; d=google.com; s=arc-20160816; b=Dl+3jywXRuLECywmeN/eonwSGDb+UCuXkXgwaW1GSwtTLcVLOd2E4nzdGKo9wxz7AT VLiN8fD7vhUU0u3JvJybRHwG2bcet/tfulDU+d7FBmzrDicmZiCDeE/LEmlqsgqBaK4e 5jurioykmH39sSFl8Gk16l0MLJXKj2yKC71w+g+ipP+9F8aI9yY9hnZIsZ+qcX3Tg3f7 u87xT0f8JfVHNWyo7DiLMl3WoQ5NadaNuMw8Vbmz3P1nBSLjybTODVefK02ok+1i5Cit sT8Qe6lGpJpFLbpKYKO8OPBPCaJI4ry20lcbaNObBXkEv1QEgcbplUFpLKo/AKAJKxKJ B6Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=l0nCsBNrWj9vAboob2vechNm6FWmLtGGGL1Lz4ZbOTw=; b=FgAtoPTVotC9y2gho1XuoJGA/fDFYonks2WIsyw8Cl6RC04FFd9/iRx/OuA8DcB6ML 4mo8pnp8+mMrrWmX/gljuDS81cpxUdyHSYfpQ931Q6avWmqR08wPH6swLeEJ9vXb4u0V 3Yeji+04Rvk5DeaamMFaLx/GZwa66c7VUYw2iTcLF+WsBlXO/Qco94g75lTwZsZV+StU Jrnhdm6i+VCU4L5tlPuGTiTOspWxIdIdsbikD9kDnXWr3fWgypr1J+OcOd3hrB37Ljiy 7heqMpFrZ0QroQyuKJRa6IphIlHzbCHcHwI76nC59FlFWC0HauAgpC1CWSOPe/kdoLLt dw9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=jEupqBhf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b10-20020a6541ca000000b004822e22082esi7967735pgq.249.2023.01.08.12.00.45; Sun, 08 Jan 2023 12:00:52 -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; dkim=pass header.i=@alien8.de header.s=dkim header.b=jEupqBhf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233826AbjAHTzr (ORCPT + 53 others); Sun, 8 Jan 2023 14:55:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236241AbjAHTzO (ORCPT ); Sun, 8 Jan 2023 14:55:14 -0500 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02854DF69 for ; Sun, 8 Jan 2023 11:55:12 -0800 (PST) Received: from zn.tnic (p5de8e9fe.dip0.t-ipconnect.de [93.232.233.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 567B21EC01A9; Sun, 8 Jan 2023 20:55:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1673207711; 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: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=l0nCsBNrWj9vAboob2vechNm6FWmLtGGGL1Lz4ZbOTw=; b=jEupqBhfuoh0K9NtIt5sp0uwSvH6VI2N16UQtBg5JEUUWEYI1JtaNd/ykMwPP7hgpCs4y0 EPTr+pmlCEPN8CfZMw4Dcj4o39t3dd9MMwbXcgENzCjy0agunzMES3ftrHrZe2SirPEa5m 58ueIV1MyxtoTTaHKuCDUWVlBaVAOqU= Date: Sun, 8 Jan 2023 20:55:06 +0100 From: Borislav Petkov To: "Maciej W. Rozycki" Cc: Thomas Gleixner , Ingo Molnar , Dave Hansen , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, Kees Cook Subject: Re: [PATCH] x86: Disable kernel stack offset randomization for !TSC Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 On Sun, Jan 08, 2023 at 07:42:54PM +0000, Maciej W. Rozycki wrote: > For x86 kernel stack offset randomization uses the RDTSC instruction, > which causes an invalid opcode exception with hardware that does not > implement this instruction: Out of pure curiosity, what hw is that? Also, I guess the fix should be something like this instead: --- diff --git a/arch/x86/include/asm/entry-common.h b/arch/x86/include/asm/entry-common.h index 117903881fe4..57b372ca6ce7 100644 --- a/arch/x86/include/asm/entry-common.h +++ b/arch/x86/include/asm/entry-common.h @@ -85,7 +85,8 @@ static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs, * Therefore, final stack offset entropy will be 5 (x86_64) or * 6 (ia32) bits. */ - choose_random_kstack_offset(rdtsc() & 0xFF); + if (cpu_feature_enabled(X86_FEATURE_TSC)) + choose_random_kstack_offset(rdtsc() & 0xFF); } #define arch_exit_to_user_mode_prepare arch_exit_to_user_mode_prepare -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette