Re: [PATCH] x86/msr: Filter MSR writes

2020-11-26 Thread Borislav Petkov
On Thu, Nov 19, 2020 at 11:53:44AM +0100, Mathieu Chouquet-Stringer wrote: > --- > TAINT_CPU_OUT_OF_SPEC now means what a bit more than what it implies as s/now means what a bit/now means a bit/ > the flag isn't set just because of a CPU misconfiguration or mismatch. > Historically it was for SMP

Re: [PATCH] x86/msr: Filter MSR writes

2020-11-25 Thread Mathieu Chouquet-Stringer
Hey Borislav, On Thu, Nov 19, 2020 at 11:53:44AM +0100, Mathieu Chouquet-Stringer wrote: > On Wed, Nov 18, 2020 at 06:50:48PM +0100, Borislav Petkov wrote: > > Please fix the text in Documentation/admin-guide/sysctl/kernel.rst also. > > Done. I haven't heard from you, what did you think

Re: [PATCH] x86/msr: Filter MSR writes

2020-11-19 Thread Mathieu Chouquet-Stringer
On Wed, Nov 18, 2020 at 06:50:48PM +0100, Borislav Petkov wrote: > Please fix the text in Documentation/admin-guide/sysctl/kernel.rst also. Done. > People might wonder what "out of specifications" means. I'd say > something along the lines of "the CPU has been put into a not supported > configura

Re: [PATCH] x86/msr: Filter MSR writes

2020-11-18 Thread Borislav Petkov
On Wed, Nov 18, 2020 at 03:04:27PM +0100, Mathieu Chouquet-Stringer wrote: > TAINT_CPU_OUT_OF_SPEC now means what it says. Historically it was for > SMP kernel oops on an officially SMP incapable processor but now it also > covers CPUs whose MSRs have been incorrectly poked at. Update > documentati

[PATCH] x86/msr: Filter MSR writes

2020-11-18 Thread Mathieu Chouquet-Stringer
On Wed, Nov 18, 2020 at 12:50:27PM +0100, Borislav Petkov wrote: > On Wed, Nov 18, 2020 at 10:09:29AM +0100, Mathieu Chouquet-Stringer wrote: > > Speaking of doc, looking at the patches you submitted, I didn't see any > > update to the documentation. Would you like me to create a patch for > > that

Re: [RFC PATCH] x86/msr: Filter MSR writes

2020-06-13 Thread Borislav Petkov
On Fri, Jun 12, 2020 at 10:39:35PM +0200, Peter Zijlstra wrote: > On Fri, Jun 12, 2020 at 07:48:01PM +0200, Borislav Petkov wrote: > > On Fri, Jun 12, 2020 at 10:20:03AM -0700, Linus Torvalds wrote: > > > Since you already added the filtering, this looks fairly sane. > > > > > > IOW, what MSR's do

Re: [RFC PATCH] x86/msr: Filter MSR writes

2020-06-12 Thread Tony Luck
On Fri, Jun 12, 2020 at 1:41 PM Peter Zijlstra wrote: > > On Fri, Jun 12, 2020 at 07:48:01PM +0200, Borislav Petkov wrote: > > On Fri, Jun 12, 2020 at 10:20:03AM -0700, Linus Torvalds wrote: > > > Since you already added the filtering, this looks fairly sane. > > > > > > IOW, what MSR's do we expe

Re: [RFC PATCH] x86/msr: Filter MSR writes

2020-06-12 Thread Peter Zijlstra
On Fri, Jun 12, 2020 at 07:48:01PM +0200, Borislav Petkov wrote: > On Fri, Jun 12, 2020 at 10:20:03AM -0700, Linus Torvalds wrote: > > Since you already added the filtering, this looks fairly sane. > > > > IOW, what MSR's do we expect people to maybe write to normally? You > > added MSR_IA32_ENERG

Re: [RFC PATCH] x86/msr: Filter MSR writes

2020-06-12 Thread Borislav Petkov
On Fri, Jun 12, 2020 at 07:48:01PM +0200, Borislav Petkov wrote: > > So the first phase might be to introduce this, but have the default > > for non-recognized MSR's be "log", not "deny". > > Ok. How are we going to "learn" about those non-recognized MSRs? Ask > people to send us a note to lkml so

Re: [RFC PATCH] x86/msr: Filter MSR writes

2020-06-12 Thread Borislav Petkov
On Fri, Jun 12, 2020 at 10:43:07AM -0700, Sean Christopherson wrote: > The problem is a fault on WRMSR doesn't mean the MSR doesn't exist, it only > means WRMSR faulted. WRMSR can for all intents and purpose trigger completely > arbitrary microcode flows, e.g. WRMSR 0x79 can fundamentally change t

Re: [RFC PATCH] x86/msr: Filter MSR writes

2020-06-12 Thread Borislav Petkov
On Fri, Jun 12, 2020 at 10:20:03AM -0700, Linus Torvalds wrote: > Since you already added the filtering, this looks fairly sane. > > IOW, what MSR's do we expect people to maybe write to normally? You > added MSR_IA32_ENERGY_PERF_BIAS as an allowed MST, maybe there are > others? Right, this MSR i

Re: [RFC PATCH] x86/msr: Filter MSR writes

2020-06-12 Thread Sean Christopherson
On Fri, Jun 12, 2020 at 07:03:03PM +0200, Borislav Petkov wrote: > On Fri, Jun 12, 2020 at 09:57:09AM -0700, Sean Christopherson wrote: > > DS_AREA takes a virtual (linear) address, i.e. the address can be legal from > > the CPUs perspective but still lead to a #PF due to the address not being > >

Re: [RFC PATCH] x86/msr: Filter MSR writes

2020-06-12 Thread Linus Torvalds
On Fri, Jun 12, 2020 at 3:50 AM Borislav Petkov wrote: > > Disable writing to MSRs from userspace by default. Writes can still be > allowed by supplying the allow_writes=1 module parameter and the kernel > will be tainted so that it shows in oopses. Since you already added the filtering, this loo

Re: [RFC PATCH] x86/msr: Filter MSR writes

2020-06-12 Thread Borislav Petkov
On Fri, Jun 12, 2020 at 09:57:09AM -0700, Sean Christopherson wrote: > DS_AREA takes a virtual (linear) address, i.e. the address can be legal from > the CPUs perspective but still lead to a #PF due to the address not being > mapped in the page tables. It's not that - peterz and tglx - and I assum

Re: [RFC PATCH] x86/msr: Filter MSR writes

2020-06-12 Thread Sean Christopherson
On Fri, Jun 12, 2020 at 06:46:02PM +0200, Borislav Petkov wrote: > On Fri, Jun 12, 2020 at 09:34:06AM -0700, Sean Christopherson wrote: > > The kernel should be tainted if the WRMSR is attempted, regardless of > > whether it succeeds, and it should happen before the WRMSR. E.g. pointing > > MSR_IA

Re: [RFC PATCH] x86/msr: Filter MSR writes

2020-06-12 Thread Borislav Petkov
On Fri, Jun 12, 2020 at 09:34:06AM -0700, Sean Christopherson wrote: > The kernel should be tainted if the WRMSR is attempted, regardless of > whether it succeeds, and it should happen before the WRMSR. E.g. pointing > MSR_IA32_DS_AREA at a bad address will likely cause an OOPS on the #PF If the

Re: [RFC PATCH] x86/msr: Filter MSR writes

2020-06-12 Thread Sean Christopherson
On Fri, Jun 12, 2020 at 12:50:26PM +0200, Borislav Petkov wrote: > @@ -95,11 +114,18 @@ static ssize_t msr_write(struct file *file, const char > __user *buf, > err = wrmsr_safe_on_cpu(cpu, reg, data[0], data[1]); > if (err) > break; > + >

[RFC PATCH] x86/msr: Filter MSR writes

2020-06-12 Thread Borislav Petkov
Hi, so this has been popping up from time to time in the last couple of years so let's have a go at it. The reason for it is explained in the commit message below but basically the goal is to have MSR writes disabled by default on distros and on the general Linux setup and only those who know what