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

From: Borislav Petkov
Date: Tue Nov 26 2019 - 06:36:38 EST


On Tue, Nov 26, 2019 at 12:22:34PM +0100, Borislav Petkov wrote:
> Hi,
>
> so this has been on my TODO list for a while. I'd like to disable writes
> to certain MSRs and MSR ranges because luserspace has no job poking at
> those at all. If there's a need for poking at MSRs, a proper userspace
> interface needs to be designed instead of plain writes into the MSRs.
>
> There's a "msr.allow_writes" root-only param for the use case where CPU
> folks want to be poking at MSRs. And yes, that is a valid use case -
> they wanna be poking at their MSRs.
>
> In any case, writes do taint the kernel now so that it is known that
> something has been poking at the MSRs.
>
> Thoughts?
>
> ---
>
> ... to certain important MSRs.
>
> v0: add allow_writes param for root.
>
> Not-yet-signed-off-by: Borislav Petkov <bp@xxxxxxx>
> ---
> arch/x86/events/amd/power.c | 4 -
> arch/x86/events/intel/knc.c | 4 -
> arch/x86/include/asm/msr-index.h | 8 ++
> arch/x86/include/asm/processor.h | 2 +
> arch/x86/kernel/cpu/bugs.c | 2 +-
> arch/x86/kernel/cpu/common.c | 165 +++++++++++++++++++++++++++++++
> arch/x86/kernel/msr.c | 20 +++-
> drivers/hwmon/fam15h_power.c | 4 -
> 8 files changed, 195 insertions(+), 14 deletions(-)

Note to self for next version:

- turn the list into a whitelist of MSRs instead, for obvious reasons (Ingo).

--
Regards/Gruss,
Boris.

SUSE Software Solutions Germany GmbH, GF: Felix ImendÃrffer, HRB 36809, AG NÃrnberg
--