lkml.org 
[lkml]   [2021]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] x86/msr: Filter msr write by X86_IOC_WRMSR_REGS ioctl
Date
commit a7e1f67ed29f ("x86/msr: Filter MSR writes") introduces a
module parameter to disable writing to msr device file (and add_taint()
upon writing). As msr register can be written by X86_IOC_WRMSR_REGS
ioctl too, they should be applied to the ioctl as well.

Fixes: a7e1f67ed29f ("x86/msr: Filter MSR writes")
Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
---
Hello,

I just noticed this when I read the code.
I'm not sure if anyone uses ioctl interface now, but I tested this
by resetting IA32_MPERF by X86_IOC_WRMSR_REGS ioctl.

Thanks,

arch/x86/kernel/msr.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
index 8a67d1fa8dc5..d774618e75b8 100644
--- a/arch/x86/kernel/msr.c
+++ b/arch/x86/kernel/msr.c
@@ -182,6 +182,10 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg)
err = security_locked_down(LOCKDOWN_MSR);
if (err)
break;
+ err = filter_write(regs[1]);
+ if (err)
+ return err;
+ add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK);
err = wrmsr_safe_regs_on_cpu(cpu, regs);
if (err)
break;
--
2.26.2
\
 
 \ /
  Last update: 2021-01-27 13:25    [W:0.083 / U:0.936 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site