From: Misono Tomohiro Date: Wed, 27 Jan 2021 12:24:56 +0000 (+0900) Subject: x86/MSR: Filter MSR writes through X86_IOC_WRMSR_REGS ioctl too X-Git-Tag: v5.10.25~1085 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ad71e4decf494cc34f2b8ec6f68c8d71f1548bc3;p=platform%2Fkernel%2Flinux-rpi.git 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 Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20210127122456.13939-1-misono.tomohiro@jp.fujitsu.com Signed-off-by: Sasha Levin --- diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c index c0d4098..79f900f 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;