linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: Lock down MSR writing in secure boot
@ 2013-02-08 19:12 Kees Cook
  2013-02-08 19:17 ` H. Peter Anvin
  2013-02-08 19:17 ` Matthew Garrett
  0 siblings, 2 replies; 49+ messages in thread
From: Kees Cook @ 2013-02-08 19:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: Matthew Garrett, H. Peter Anvin, Thomas Gleixner, Ingo Molnar,
	x86, linux-efi, linux-security-module

Writing to MSRs should not be allowed unless CAP_COMPROMISE_KERNEL is
set since it could lead to execution of arbitrary code in kernel mode.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
This would be used on top of Matthew Garrett's existing "Secure boot
policy support" patch series.
---
 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 4929502..adaab3d 100644
--- a/arch/x86/kernel/msr.c
+++ b/arch/x86/kernel/msr.c
@@ -103,6 +103,9 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
 	int err = 0;
 	ssize_t bytes = 0;
 
+	if (!capable(CAP_COMPROMISE_KERNEL))
+		return -EPERM;
+
 	if (count % 8)
 		return -EINVAL;	/* Invalid chunk size */
 
@@ -150,6 +153,10 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg)
 			err = -EBADF;
 			break;
 		}
+		if (!capable(CAP_COMPROMISE_KERNEL)) {
+			err = -EPERM;
+			break;
+		}
 		if (copy_from_user(&regs, uregs, sizeof regs)) {
 			err = -EFAULT;
 			break;
-- 
1.7.9.5


-- 
Kees Cook
Chrome OS Security

^ permalink raw reply related	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2013-02-14  2:46 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-08 19:12 [PATCH] x86: Lock down MSR writing in secure boot Kees Cook
2013-02-08 19:17 ` H. Peter Anvin
     [not found]   ` <00780235-deac-4f80-b936-867834e05661-2ueSQiBKiTY7tOexoI0I+QC/G2K4zDHf@public.gmane.org>
2013-02-08 19:18     ` Kees Cook
2013-02-08 19:42       ` H. Peter Anvin
2013-02-08 20:14         ` Kees Cook
     [not found]           ` <CAGXu5j+_mGzR+72YqORhErMUY1aF1H2urczZ8SwuJHZK-oZL6g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-02-08 20:18             ` H. Peter Anvin
2013-02-08 20:28               ` Kees Cook
     [not found]                 ` <CAGXu5jLAufTRm=sDST0br_WEkn4o0Hpjv2jDP2Na=cCvuM+MGg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-02-08 20:34                   ` Matthew Garrett
2013-02-08 21:02                     ` Kees Cook
     [not found]                       ` <CAGXu5jKo2PfMBO4A0ZgQcrPuj8OHNaff+CjAesOAWkZc0vB9+Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-02-08 21:07                         ` Matthew Garrett
     [not found]                           ` <1360357636.18083.19.camel-+5W/JHIUVxg@public.gmane.org>
2013-02-08 21:14                             ` Josh Boyer
2013-02-08 23:09                               ` Andy Lutomirski
2013-02-08 22:30                         ` H. Peter Anvin
2013-02-08 23:06                           ` Borislav Petkov
2013-02-08 23:26                             ` Matthew Garrett
     [not found]                               ` <1360366012.18083.21.camel-+5W/JHIUVxg@public.gmane.org>
2013-02-09  1:22                                 ` H. Peter Anvin
2013-02-09  1:29                                   ` Matthew Garrett
     [not found]                                     ` <1360373383.18083.23.camel-+5W/JHIUVxg@public.gmane.org>
2013-02-09  6:45                                       ` Kees Cook
     [not found]                                         ` <CAGXu5j+xvJ3L5ejxtZ-Jw3F6rV7OsrE0_HZCGu_er0rH2_PwKA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-02-09  9:29                                           ` Borislav Petkov
2013-02-09 15:10                                             ` Kees Cook
     [not found]                                             ` <20130209092925.GA17728-fF5Pk5pvG8Y@public.gmane.org>
2013-02-09 15:11                                               ` Matthew Garrett
2013-02-13  0:48                                                 ` H. Peter Anvin
2013-02-13  5:39                                                   ` Matthew Garrett
     [not found]                                                     ` <1360733962.18083.30.camel-+5W/JHIUVxg@public.gmane.org>
2013-02-13  6:12                                                       ` H. Peter Anvin
2013-02-13  6:27                                                         ` Matthew Garrett
2013-02-13  6:33                                                           ` H. Peter Anvin
     [not found]                                                             ` <511B33BC.9080307-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2013-02-13  6:41                                                               ` Matthew Garrett
     [not found]                                                                 ` <1360737709.18083.36.camel-+5W/JHIUVxg@public.gmane.org>
2013-02-13 17:20                                                                   ` H. Peter Anvin
2013-02-13 17:26                                                                     ` Matthew Garrett
2013-02-13 17:51                                                                       ` Casey Schaufler
     [not found]                                                                         ` <511BD291.1040003-iSGtlc1asvQWG2LlvL+J4A@public.gmane.org>
2013-02-13 17:56                                                                           ` Matthew Garrett
2013-02-13 18:44                                                                             ` H. Peter Anvin
2013-02-13 18:51                                                                               ` Matthew Garrett
2013-02-13 22:26                                                                         ` H. Peter Anvin
2013-02-13 22:58                                                                           ` Casey Schaufler
     [not found]                                                                             ` <511C1A94.8020804-iSGtlc1asvQWG2LlvL+J4A@public.gmane.org>
2013-02-14  0:25                                                                               ` H. Peter Anvin
2013-02-14  0:44                                                                                 ` Casey Schaufler
     [not found]                                                                                   ` <511C3389.5090604-iSGtlc1asvQWG2LlvL+J4A@public.gmane.org>
2013-02-14  1:04                                                                                     ` Matthew Garrett
     [not found]                                                                                       ` <1360803872.18083.46.camel-+5W/JHIUVxg@public.gmane.org>
2013-02-14  1:08                                                                                         ` H. Peter Anvin
     [not found]                                                                                           ` <511C3927.90603-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2013-02-14  2:46                                                                                             ` Matthew Garrett
2013-02-14  1:34                                                                                       ` Casey Schaufler
2013-02-13  8:27                                                             ` Paolo Bonzini
2013-02-13 17:21                                                               ` H. Peter Anvin
     [not found]                                                               ` <511B4E61.1040604-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-02-13 17:22                                                                 ` H. Peter Anvin
2013-02-13 19:55                                                                   ` Paolo Bonzini
     [not found]                                                                   ` <511B EFAD.1050206@redhat.com>
     [not found]                                                                     ` <511BEFAD.1050206-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-02-13 22:24                                                                       ` H. Peter Anvin
2013-02-08 19:17 ` Matthew Garrett
2013-02-08 19:21   ` Kees Cook
     [not found]     ` <CAGXu5j+aXxQb_Jyn6G+JUdjNOF2EGo9pTw8dBYuZUTb+S1vWow-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-02-08 19:27       ` Matthew Garrett

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).