[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210127122456.13939-1-misono.tomohiro@jp.fujitsu.com>
Date: Wed, 27 Jan 2021 21:24:56 +0900
From: Misono Tomohiro <misono.tomohiro@...fujitsu.com>
To: <linux-kernel@...r.kernel.org>
CC: <x86@...nel.org>, <hpa@...or.com>, <tglx@...utronix.de>,
<mingo@...hat.com>, <bp@...en8.de>,
<misono.tomohiro@...fujitsu.com>
Subject: [PATCH] x86/msr: Filter msr write by X86_IOC_WRMSR_REGS ioctl
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@...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
Powered by blists - more mailing lists