aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisono Tomohiro <misono.tomohiro@jp.fujitsu.com>2021-01-27 21:24:56 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-03-04 11:37:26 +0100
commitad71e4decf494cc34f2b8ec6f68c8d71f1548bc3 (patch)
tree05684cf678198575e6c45e202afd4ebfdd823488
parent56ef08902f0dcc77a28e0c75ed28357b3ead074b (diff)
downloadkernel_replicant_linux-ad71e4decf494cc34f2b8ec6f68c8d71f1548bc3.tar.gz
kernel_replicant_linux-ad71e4decf494cc34f2b8ec6f68c8d71f1548bc3.tar.bz2
kernel_replicant_linux-ad71e4decf494cc34f2b8ec6f68c8d71f1548bc3.zip
x86/MSR: Filter MSR writes through X86_IOC_WRMSR_REGS ioctl too
[ Upstream commit 02a16aa13574c8526beadfc9ae8cc9b66315fa2d ] Commit a7e1f67ed29f ("x86/msr: Filter MSR writes") introduced a module parameter to disable writing to the MSR device file and tainted the kernel upon writing. As MSR registers can be written by the X86_IOC_WRMSR_REGS ioctl too, the same filtering and tainting should be applied to the ioctl as well. [ bp: Massage commit message and space out statements. ] Fixes: a7e1f67ed29f ("x86/msr: Filter MSR writes") Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lkml.kernel.org/r/20210127122456.13939-1-misono.tomohiro@jp.fujitsu.com Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--arch/x86/kernel/msr.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
index c0d409810658..79f900ffde4c 100644
--- a/arch/x86/kernel/msr.c
+++ b/arch/x86/kernel/msr.c
@@ -184,6 +184,13 @@ 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;