Re: [RFC PATCH] x86: Filter MSR writes from luserspace

From: Borislav Petkov
Date: Tue Nov 26 2019 - 15:33:55 EST


On Tue, Nov 26, 2019 at 12:15:10PM -0800, Andi Kleen wrote:
> This will break a bazillion of tools that rely on programing many of
> those MSRs from user space.

Userspace has no deal to poke into random MSRs. End of story.

The next version will switch to a whitelist and I've added the ones
which are used by turbostat and powertop:

int msr_filter_write(u32 reg)
{
switch (reg) {
case MSR_IA32_ENERGY_PERF_BIAS:
case MSR_RAPL_POWER_UNIT:
case MSR_DRAM_POWER_LIMIT:
case MSR_PP0_POWER_LIMIT:
case MSR_PP1_POWER_LIMIT:
return 0;

I guess adding other, non-critical MSRs to that list is fine.

But if people really wanna program the hardware, a proper interface
needs to be designed. This patch has an example for why poking at random
MSRs from userspace is simply not going to work in the long run.

And if they still wanna poke at MSRs and if you look at the patch in
more detail, you'll see there's msr.allow_writes=1 and we'll taint the
kernel.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette