mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mike Waychison <mikew@google.com>
To: Greg Kroah-Hartman <gregkh@suse.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	Mike Waychison <mikew@google.com>
Subject: [PATCH 2/2] x86: Allow disabling of sys_iopl, sys_ioperm
Date: Thu, 14 Jul 2011 13:34:53 -0700	[thread overview]
Message-ID: <1310675693-9204-2-git-send-email-mikew@google.com> (raw)
In-Reply-To: <1310675693-9204-1-git-send-email-mikew@google.com>

In some build environments, it is useful to allow disabling of IO
accesses to hardware, without having to rely on CAP_SYS_RAWIO (which is
already overloaded to mean many other things).  One way that userland
has access to IO accesses is via the iopl(2) and ioperm(2) system calls.

Allow disabling of these system calls from ever being available via a
configuration option, X86_SYS_IOPL.   This is implemented by simply
stubbing out the system calls and having them return ENOSYS when their
functionality is disabled.

Note that we default this option to 'y', so that existing kernel configs
will continue to support sys_iopl and sys_ioperm as before.

Google-Bug-Id: 3177114
Signed-off-by: Mike Waychison <mikew@google.com>
---
 arch/x86/Kconfig         |   12 ++++++++++++
 arch/x86/kernel/ioport.c |   12 ++++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index da34972..295ae4d 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1497,6 +1497,18 @@ config CC_STACKPROTECTOR
 	  detected and for those versions, this configuration option is
 	  ignored. (and a warning is printed during bootup)
 
+config X86_SYS_IOPL
+	bool "Enable use of sys_iopl and sys_ioperm system calls"
+	default y
+	---help---
+	  The sys_iopl and sys_ioperm allow applications that have the
+	  CAP_SYS_RAWIO to elevate their priviledge level so that they
+	  can perform IO accesses directly from userland.  This
+	  functionality is often used by userland drivers to drive
+	  hardware directly, bypassing the kernel.  Disabling this
+	  option may break certain hardware functions, so if in doubt,
+	  say yes.
+
 source kernel/Kconfig.hz
 
 config KEXEC
diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
index 8c96897..709db2f 100644
--- a/arch/x86/kernel/ioport.c
+++ b/arch/x86/kernel/ioport.c
@@ -17,6 +17,7 @@
 #include <linux/bitmap.h>
 #include <asm/syscalls.h>
 
+#ifdef CONFIG_X86_SYS_IOPL
 /*
  * this changes the io permissions bitmap in the current task.
  */
@@ -111,3 +112,14 @@ long sys_iopl(unsigned int level, struct pt_regs *regs)
 
 	return 0;
 }
+
+#else /* CONFIG_X86_SYS_IOPL */
+
+asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on) {
+	return -ENOSYS;
+}
+
+long sys_iopl(unsigned int level, struct pt_regs *regs) {
+	return -ENOSYS;
+}
+#endif /* CONFIG_X86_SYS_IOPL */
-- 
1.7.3.1


  reply	other threads:[~2011-07-14 20:35 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-14 20:34 [PATCH 1/2] Kconfig: Allow disabling of CONFIG_DEVPORT Mike Waychison
2011-07-14 20:34 ` Mike Waychison [this message]
2011-07-14 20:37   ` [PATCH 2/2] x86: Allow disabling of sys_iopl, sys_ioperm H. Peter Anvin
2011-07-14 20:38     ` Mike Waychison
2011-07-14 20:40       ` H. Peter Anvin
2011-07-18 14:35         ` Jiri Kosina
2011-07-14 22:31   ` Andrew Morton
2011-07-14 22:35     ` H. Peter Anvin
2011-07-14 22:40       ` Mike Waychison
2011-07-14 22:45         ` H. Peter Anvin
2011-07-14 23:03           ` Alan Cox
2011-07-14 23:04         ` Alan Cox
2011-07-20 19:42         ` Ingo Molnar
2011-07-14 22:42   ` Alan Cox
2011-07-14 22:48     ` Mike Waychison
2011-07-14 23:00       ` Alan Cox
2011-07-14 23:20         ` Mike Waychison
2011-07-14 23:39           ` Alan Cox
2011-07-15  0:48             ` Mike Waychison
2011-07-15  9:55               ` Alan Cox
2011-07-15 18:13               ` Mike Waychison
2011-07-15 18:14                 ` H. Peter Anvin
2011-07-15 22:30                   ` Andrew G. Morgan
2011-07-15 22:42                     ` Mike Waychison
2011-07-17 23:19                       ` Eric Paris
2011-07-18  0:04                         ` H. Peter Anvin
2011-07-14 21:21 ` [PATCH 1/2] Kconfig: Allow disabling of CONFIG_DEVPORT Greg KH
2011-07-14 22:17   ` Mike Waychison
2011-07-15  6:41     ` Greg KH
2011-07-15 13:13       ` Theodore Tso
2011-07-15 14:51         ` Greg KH
2011-07-15 14:58           ` Alan Cox
2011-07-15 15:19             ` Greg KH
2011-07-15 16:45               ` Mike Waychison
2011-07-15 17:01                 ` Greg KH
2011-07-15 17:51                   ` Mike Waychison
2011-07-15 18:10                     ` H. Peter Anvin
2011-07-15 18:50             ` Andrew Morton
2011-07-15 18:55           ` Ted Ts'o
2011-07-16  7:56             ` Greg KH
2011-07-16 13:05               ` Ted Ts'o
2011-07-16 16:38                 ` Christoph Hellwig

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=1310675693-9204-2-git-send-email-mikew@google.com \
    --to=mikew@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@suse.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@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

Powered by JetHome