* [PATCH] x86/msr: Filter msr write by X86_IOC_WRMSR_REGS ioctl
@ 2021-01-27 12:24 Misono Tomohiro
2021-01-27 14:30 ` Borislav Petkov
2021-01-27 19:31 ` [tip: x86/misc] x86/MSR: Filter MSR writes through X86_IOC_WRMSR_REGS ioctl too tip-bot2 for Misono Tomohiro
0 siblings, 2 replies; 3+ messages in thread
From: Misono Tomohiro @ 2021-01-27 12:24 UTC (permalink / raw)
To: linux-kernel; +Cc: x86, hpa, tglx, mingo, bp, misono.tomohiro
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/msr: Filter msr write by X86_IOC_WRMSR_REGS ioctl
2021-01-27 12:24 [PATCH] x86/msr: Filter msr write by X86_IOC_WRMSR_REGS ioctl Misono Tomohiro
@ 2021-01-27 14:30 ` Borislav Petkov
2021-01-27 19:31 ` [tip: x86/misc] x86/MSR: Filter MSR writes through X86_IOC_WRMSR_REGS ioctl too tip-bot2 for Misono Tomohiro
1 sibling, 0 replies; 3+ messages in thread
From: Borislav Petkov @ 2021-01-27 14:30 UTC (permalink / raw)
To: Misono Tomohiro; +Cc: linux-kernel, x86, hpa, tglx, mingo
On Wed, Jan 27, 2021 at 09:24:56PM +0900, Misono Tomohiro wrote:
> 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.
Blergh, I missed that. :-\
> 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.
Yeah, I'm sure once this hits people's kernels, someone will complain.
In any case, good catch, thanks!
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip: x86/misc] x86/MSR: Filter MSR writes through X86_IOC_WRMSR_REGS ioctl too
2021-01-27 12:24 [PATCH] x86/msr: Filter msr write by X86_IOC_WRMSR_REGS ioctl Misono Tomohiro
2021-01-27 14:30 ` Borislav Petkov
@ 2021-01-27 19:31 ` tip-bot2 for Misono Tomohiro
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Misono Tomohiro @ 2021-01-27 19:31 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Misono Tomohiro, Borislav Petkov, x86, linux-kernel
The following commit has been merged into the x86/misc branch of tip:
Commit-ID: 02a16aa13574c8526beadfc9ae8cc9b66315fa2d
Gitweb: https://git.kernel.org/tip/02a16aa13574c8526beadfc9ae8cc9b66315fa2d
Author: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
AuthorDate: Wed, 27 Jan 2021 21:24:56 +09:00
Committer: Borislav Petkov <bp@suse.de>
CommitterDate: Wed, 27 Jan 2021 19:06:47 +01:00
x86/MSR: Filter MSR writes through X86_IOC_WRMSR_REGS ioctl too
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
---
arch/x86/kernel/msr.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
index 8a67d1f..ed8ac6b 100644
--- a/arch/x86/kernel/msr.c
+++ b/arch/x86/kernel/msr.c
@@ -182,6 +182,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;
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-27 19:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-27 12:24 [PATCH] x86/msr: Filter msr write by X86_IOC_WRMSR_REGS ioctl Misono Tomohiro
2021-01-27 14:30 ` Borislav Petkov
2021-01-27 19:31 ` [tip: x86/misc] x86/MSR: Filter MSR writes through X86_IOC_WRMSR_REGS ioctl too tip-bot2 for Misono Tomohiro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).