Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp866465ybb; Wed, 8 Apr 2020 11:25:06 -0700 (PDT) X-Google-Smtp-Source: APiQypKLHLC0hTWlqEuLRr6KPk4A8mL6djX6PU9+wsLaJMYzIquw5Wj7HYNb0FMNLA4J6C+AZMdv X-Received: by 2002:a9d:12b1:: with SMTP id g46mr2211601otg.10.1586370305922; Wed, 08 Apr 2020 11:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586370305; cv=none; d=google.com; s=arc-20160816; b=uOFIJnt9Xir810yn7Miyr7packKR4ZYnFGmPDT7hjVN9NK2lyf943CBCuzD0v3aa9p 8FhCflOfQHXrTHeDK+lQGYE/d+1di0f99XW1TpfV6j4Z3AR0BZpjcE+/tLAqq7utqbKq ficV6z/RY8MwWJTUf9ICBjyxz7hEdKqrNAzMTcAeTYo1K2RqYNR48dhCfLVVl4D4Z2Xz 2zVOLqjlWqWXq5ADdm0SjLWawASQepA/7e89+JgaDJez5IBKYhvmaihUupRltqr9w14B raIf805HvKDUgmAdXX1qTjOeBduDBykAEE+XIyufpfqQHxkW2b7aA5lVioeOuD9PJUdL cWkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=WEYnwT/wJA+31h8cc6/y+qf2EeGd3KlfZF16lphHlZU=; b=sy2feHykwLAUteiB2pqn0h0r5lvw/hruEBNY9LLG5sp9UU3GadKnoZh8cUlCJXwjo+ OlgigpWOCZUhUFFtimCOXUOSpw3g9fJFZFKN3Drj5Okp6qteFyPqcYx+3JQJk6xwgaqk c/YJKjKJ8cqAeq/dDWX9IT9F9ZhESzXMs+P5zv1maNWwTHxLZZvDTgZs3PmdcjNNyNPn lDaqb2DcLQ5/iV7JI0Tbp301r/SmfvPZlRYnXOW90JfxXn4J0txUBNZeXIYw9gE1V/ZK HLGLIbnSlrPsDRN/lOjGN1RYiBuNDyO7aeiTO/hTZ1r+XdUr6Pnyd3iB/BvgDMb8MCWK gtMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q16si2810701otn.111.2020.04.08.11.24.53; Wed, 08 Apr 2020 11:25:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730118AbgDHQDA (ORCPT + 99 others); Wed, 8 Apr 2020 12:03:00 -0400 Received: from mga07.intel.com ([134.134.136.100]:28384 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730113AbgDHQDA (ORCPT ); Wed, 8 Apr 2020 12:03:00 -0400 IronPort-SDR: UYcoLh5xYCPG6aq0jxgPSOHaW63ko6YuEHtCMvPJOXokuM0asCgzmmoqPpIH7r63090kKdXPiP IymLaEpsOvsw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2020 09:02:58 -0700 IronPort-SDR: krJHKQ7pS0QJRJBq0YdxLpoAcDLTKiCB2PTLscsZzEN4Mthr3EwZQN9Lc8NII8IaSY5/IE6Bh8 XDXsofpRYovw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,359,1580803200"; d="scan'208";a="269790350" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.202]) by orsmga002.jf.intel.com with ESMTP; 08 Apr 2020 09:02:57 -0700 Date: Wed, 8 Apr 2020 09:02:57 -0700 From: Sean Christopherson To: Christoph Hellwig Cc: Peter Zijlstra , Steven Rostedt , tglx@linutronix.de, linux-kernel@vger.kernel.org, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, kenny@panix.com, jeyu@kernel.org, rasmus.villemoes@prevas.dk, pbonzini@redhat.com, fenghua.yu@intel.com, xiaoyao.li@intel.com, nadav.amit@gmail.com, thellstrom@vmware.com, tony.luck@intel.com, gregkh@linuxfoundation.org, jannh@google.com, keescook@chromium.org, David.Laight@aculab.com, dcovelli@vmware.com, mhiramat@kernel.org Subject: Re: [PATCH 4/4] x86,module: Detect CRn and DRn manipulation Message-ID: <20200408160257.GB11322@linux.intel.com> References: <20200407110236.930134290@infradead.org> <20200407111007.429362016@infradead.org> <20200408092726.7c2bda01@gandalf.local.home> <20200408154419.GP20730@hirez.programming.kicks-ass.net> <20200408154602.GA24869@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200408154602.GA24869@infradead.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 08, 2020 at 08:46:02AM -0700, Christoph Hellwig wrote: > On Wed, Apr 08, 2020 at 05:44:19PM +0200, Peter Zijlstra wrote: > > On Wed, Apr 08, 2020 at 09:27:26AM -0400, Steven Rostedt wrote: > > > On Tue, 07 Apr 2020 13:02:40 +0200 > > > Peter Zijlstra wrote: > > > > > > + if (insn_is_mov_CRn(&insn) || insn_is_mov_DRn(&insn)) { > > > > + pr_err("Module writes to CRn or DRn, please use the proper accessors: %s\n", mod->name); > > > > + return -ENOEXEC; > > > > + } > > > > + > > > > > > Something like this should be done for all modules, not just out of tree > > > modules. > > > > I'm all for it; but people were worried scanning all modules was too > > expensive (I don't really believe it is, module loading just can't be a > > hot-path). Also, in-tree modules are audited a lot more than out of tree > > magic voodoo crap. > > Scanning all modules seems safer. While we're at it - can be move the > kvm bits using VMX to be always in the core kernel and just forbid > modules from using those instructions entirely? Practically speaking, no. Turning VMX on and off (literally VMXON/VMXOFF) could be moved to helpers in the kernel, but KVM relies on inlining all post-VMXON instructions (except for VMLAUNCH/VMRESUME) for performance. VMLAUNCH/VMRESUME have their own caveats, moving them out of KVM would be messy, to say the least.