From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932316AbdJWOts convert rfc822-to-8bit (ORCPT ); Mon, 23 Oct 2017 10:49:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52338 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932237AbdJWOtq (ORCPT ); Mon, 23 Oct 2017 10:49:46 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8CB34C070134 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dhowells@redhat.com Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20171020190939.569cedd2@alans-desktop> References: <20171020190939.569cedd2@alans-desktop> <150842463163.7923.11081723749106843698.stgit@warthog.procyon.org.uk> <150842472452.7923.2592278090192179002.stgit@warthog.procyon.org.uk> To: Alan Cox , jlee@suse.com Cc: dhowells@redhat.com, linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, jforbes@redhat.com Subject: Re: [PATCH 12/27] x86/msr: Restrict MSR access when the kernel is locked down MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21022.1508770184.1@warthog.procyon.org.uk> Content-Transfer-Encoding: 8BIT Date: Mon, 23 Oct 2017 15:49:44 +0100 Message-ID: <21023.1508770184@warthog.procyon.org.uk> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 23 Oct 2017 14:49:46 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Alan Cox wrote: > There are a load of standard tools that use this so I think you are going > to need a whitelist. Can you at least log *which* MSR in the failing case > so a whitelist can be built over time ? Will the attached change work for you? David --- diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c index a05a97863286..f18cadbc31ce 100644 --- a/arch/x86/kernel/msr.c +++ b/arch/x86/kernel/msr.c @@ -84,8 +84,10 @@ static ssize_t msr_write(struct file *file, const char __user *buf, int err = 0; ssize_t bytes = 0; - if (kernel_is_locked_down("Direct MSR access")) + if (kernel_is_locked_down("Direct MSR access")) { + pr_info("Direct access to MSR %x\n", reg); return -EPERM; + } if (count % 8) return -EINVAL; /* Invalid chunk size */ @@ -135,6 +137,7 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg) break; } if (kernel_is_locked_down("Direct MSR access")) { + pr_info("Direct access to MSR %x\n", reg[1]); /* Display %ecx */ err = -EPERM; break; }