linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Garrett <mjg@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org,
	Matthew Garrett <mjg@redhat.com>
Subject: [PATCH 03/11] x86: Lock down IO port access in secure boot environments
Date: Tue,  4 Sep 2012 11:55:09 -0400	[thread overview]
Message-ID: <1346774117-2277-4-git-send-email-mjg@redhat.com> (raw)
In-Reply-To: <1346774117-2277-1-git-send-email-mjg@redhat.com>

IO port access would permit users to gain access to PCI configuration
registers, which in turn (on a lot of hardware) give access to MMIO register
space. This would potentially permit root to trigger arbitrary DMA, so lock
it down by default.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
---
 arch/x86/kernel/ioport.c | 4 ++--
 drivers/char/mem.c       | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
index 8c96897..c3a1bb2 100644
--- a/arch/x86/kernel/ioport.c
+++ b/arch/x86/kernel/ioport.c
@@ -28,7 +28,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
 
 	if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
 		return -EINVAL;
-	if (turn_on && !capable(CAP_SYS_RAWIO))
+	if (turn_on && (!capable(CAP_SYS_RAWIO) || !capable(CAP_SECURE_FIRMWARE)))
 		return -EPERM;
 
 	/*
@@ -102,7 +102,7 @@ long sys_iopl(unsigned int level, struct pt_regs *regs)
 		return -EINVAL;
 	/* Trying to gain more privileges? */
 	if (level > old) {
-		if (!capable(CAP_SYS_RAWIO))
+		if (!capable(CAP_SYS_RAWIO) || !capable(CAP_SECURE_FIRMWARE))
 			return -EPERM;
 	}
 	regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | (level << 12);
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index e5eedfa2..8f5f872 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -597,6 +597,9 @@ static ssize_t write_port(struct file *file, const char __user *buf,
 	unsigned long i = *ppos;
 	const char __user * tmp = buf;
 
+	if (!capable(CAP_SECURE_FIRMWARE))
+		return -EPERM;
+
 	if (!access_ok(VERIFY_READ, buf, count))
 		return -EFAULT;
 	while (count-- > 0 && i < 65536) {
-- 
1.7.11.4


  parent reply	other threads:[~2012-09-04 15:55 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-04 15:55 [RFC] First attempt at kernel secure boot support Matthew Garrett
2012-09-04 15:55 ` [PATCH 01/11] Secure boot: Add new capability Matthew Garrett
2012-09-04 15:55 ` [PATCH 02/11] PCI: Lock down BAR access in secure boot environments Matthew Garrett
2012-10-01 21:00   ` Pavel Machek
2012-09-04 15:55 ` Matthew Garrett [this message]
2012-09-04 16:16   ` [PATCH 03/11] x86: Lock down IO port " Alan Cox
2012-09-04 16:16     ` Matthew Garrett
2012-09-04 15:55 ` [PATCH 04/11] ACPI: Limit access to custom_method Matthew Garrett
2012-09-04 15:55 ` [PATCH 05/11] asus-wmi: Restrict debugfs interface Matthew Garrett
2012-09-04 16:12   ` Alan Cox
2012-09-04 16:13     ` Matthew Garrett
2012-09-04 15:55 ` [PATCH 06/11] Restrict /dev/mem and /dev/kmem in secure boot setups Matthew Garrett
2012-09-04 15:55 ` [PATCH 07/11] kexec: Disable in a secure boot environment Matthew Garrett
2012-09-04 20:13   ` Eric W. Biederman
2012-09-04 20:22     ` Matthew Garrett
2012-09-04 21:13       ` Eric W. Biederman
2012-09-04 21:27         ` Matthew Garrett
2012-09-04 22:12           ` Eric W. Biederman
2012-09-04 23:25             ` Matthew Garrett
2012-09-05  4:33               ` Eric W. Biederman
2012-09-05  5:16                 ` Matthew Garrett
2012-09-05  7:00                   ` Eric W. Biederman
2012-09-05  7:03                     ` Matthew Garrett
2012-09-04 21:39         ` Alan Cox
2012-09-04 21:40           ` Matthew Garrett
2012-09-05 15:43             ` Roland Eggner
2012-09-05 15:46               ` Matthew Garrett
2012-09-05 21:13   ` Mimi Zohar
2012-09-05 21:41     ` Matthew Garrett
2012-09-05 21:49       ` Eric Paris
2012-09-04 15:55 ` [PATCH 08/11] Secure boot: Add a dummy kernel parameter that will switch on Secure Boot mode Matthew Garrett
2012-09-04 15:55 ` [PATCH 09/11] efi: Enable secure boot lockdown automatically when enabled in firmware Matthew Garrett
2012-09-04 15:55 ` [PATCH 10/11] acpi: Ignore acpi_rsdp kernel parameter in a secure boot environment Matthew Garrett
2012-09-04 16:30   ` Shuah Khan
2012-09-04 16:38     ` Matthew Garrett
2012-09-04 16:44       ` Shuah Khan
2012-09-04 20:37         ` Alan Cox
2012-09-04 20:37           ` Matthew Garrett
2012-09-04 20:50             ` Josh Boyer
2012-09-04 15:55 ` [PATCH 11/11] SELinux: define mapping for new Secure Boot capability Matthew Garrett
2012-09-04 16:08 ` [RFC] First attempt at kernel secure boot support Alan Cox
2012-09-04 16:12   ` Matthew Garrett
2012-10-01 21:07     ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1346774117-2277-4-git-send-email-mjg@redhat.com \
    --to=mjg@redhat.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).