Skip to contentSkip to conversation

Realtime LSM

PATCH In review Jack O'Quin 2 participants 6 messages Nov 9, 2004 – Nov 24, 2004 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 Realtime LSM

The realtime-lsm Linux Security Module, written by Torben Hohn and Jack O'Quin with significant help from Chris Wright and Jody McIntyre, selectively grants realtime capabilities to specific user groups or applications. One typical use is low latency audio, and the patch has been extensively field tested by Linux audio users.

We developed this LSM in response to a serious need. Audio developers have been struggling for years with having to apply specialized kernel patches to get reliable realtime operation. Audio is very intolerant of scheduling glitches. They cause nasty pops in the output. Also, large audio applications should not run as `root'. The 2.4 "capabilities patch" was never a satisfactory solution for this problem, but it was the best we could do at the time.

Now, thanks to the good work being done on 2.6, we are now close to being able to do serious realtime work with standard kernels available everywhere. The LSM framework is an important element of that solution with the realtime LSM a small but essential component, because it makes these features available without excessive administrative burden. Many musicians have a Mac or Windows background, systems which grant realtime privileges to all tasks indiscriminantly. The realtime LSM allows us to grant similar privileges while maintaining better control over who gets them.

This version was originally applied against linux-2.6.10-rc1-mm2, and retested with linux-2.6.10-rc1-mm4.

Documentation/realtime-lsm.txt +39 -0
diff -ruN -X /home/joq/bin/kdiff.exclude linux-2.6.10-rc1-mm2/Documentation/realtime-lsm.txt linux-2.6.10-rc1-mm2-rt1/Documentation/realtime-lsm.txt
@@ -0,0 +1,39 @@
+
+		    Realtime Linux Security Module
+
+
+This Linux Security Module (LSM) enables realtime capabilities.  It
+was written by Torben Hohn and Jack O'Quin, under the provisions of
+the GPL (see the COPYING file).  We make no warranty concerning the
+safety, security or even stability of your system when using it.  But,
+we will fix problems if you report them.
+
+Once the LSM has been installed and the kernel for which it was built
+is running, the root user can load it and pass parameters as follows:
+
+  # modprobe realtime any=1
+
+  Any program can request realtime privileges.  This allows any local
+  user to crash the system by hogging the CPU in a tight loop or
+  locking down too much memory.  But, it is simple to administer.  :-)
+
+  # modprobe realtime gid=29
+
+  All users belonging to group 29 and programs that are setgid to that
+  group have realtime privileges.  Use any group number you like.  A
+  `gid' of -1 disables group access.
+
+  # modprobe realtime mlock=0
+
+  Grants realtime scheduling privileges without the ability to lock
+  memory using mlock() or mlockall() system calls.  This option can be
+  used in conjunction with any of the other options.
+
+After the module is loaded, its parameters can be changed dynamically
+via sysfs.
+
+  # echo 1  > /sys/module/realtime/parameters/any
+  # echo 29 > /sys/module/realtime/parameters/gid
+  # echo 1  > /sys/module/realtime/parameters/mlock
+
+Jack O'Quin, [email protected]
security/Kconfig +11 -0
diff -ruN -X /home/joq/bin/kdiff.exclude linux-2.6.10-rc1-mm2/security/Kconfig linux-2.6.10-rc1-mm2-rt1/security/Kconfig
@@ -84,6 +84,17 @@
 
 	  If you are unsure how to answer this question, answer N.
 
+config SECURITY_REALTIME
+	tristate "Realtime Capabilities"
+	depends on SECURITY && SECURITY_CAPABILITIES!=y
+	default n
+	help
+	  This module selectively grants realtime privileges
+	  controlled by parameters set at load time or via files in
+	  /sys/module/realtime/parameters.
+
+	  If you are unsure how to answer this question, answer N.
+
 source security/selinux/Kconfig
 
 endmenu
security/Makefile +1 -0
diff -ruN -X /home/joq/bin/kdiff.exclude linux-2.6.10-rc1-mm2/security/Makefile linux-2.6.10-rc1-mm2-rt1/security/Makefile
@@ -17,3 +17,4 @@
 obj-$(CONFIG_SECURITY_CAPABILITIES)	+= commoncap.o capability.o
 obj-$(CONFIG_SECURITY_ROOTPLUG)		+= commoncap.o root_plug.o
 obj-$(CONFIG_SECURITY_SECLVL)		+= seclvl.o
+obj-$(CONFIG_SECURITY_REALTIME)		+= commoncap.o realtime.o
security/realtime.c +161 -0

161 lines not on this page · raw message

Signature · 1 line
  joq
#2 lore raw
Quoted 4 lines · Jack O'Quin

The realtime-lsm Linux Security Module, written by Torben Hohn and Jack O'Quin with significant help from Chris Wright and Jody McIntyre, selectively grants realtime capabilities to specific user groups or applications.

Hmm, are all these includes necessary for this small patch?

+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/security.h>
+#include <linux/file.h>
+#include <linux/mm.h>
+#include <linux/mman.h>
+#include <linux/pagemap.h>
+#include <linux/swap.h>
+#include <linux/smp_lock.h>
+#include <linux/skbuff.h>
+#include <linux/netlink.h>
+#include <linux/ptrace.h>
+#include <linux/sysctl.h>
+#include <linux/moduleparam.h>

Lee

#3 lore raw
In reply to Jack O'Quin

security/realtime.c line 18

Quoted 2 lines · Jack O'Quin
security/realtime.c +2 -0
+#include <linux/module.h>
+#include <linux/security.h>

These seem to be the only two includes that are needed.

Any other objections to the patch?

Lee

#4 lore raw
Quoted 7 lines · Lee Revell

security/realtime.c line 18

Quoted 2 lines · Jack O'Quin
security/realtime.c +2 -0
+#include <linux/module.h>
+#include <linux/security.h>

These seem to be the only two includes that are needed.

Any other objections to the patch?

Fine with me, as long as you're certain. I'll be away for a few days, so I can't make that change and test it right now, myself.

Signature · 1 line
  joq
#5 lore raw
Quoted 9 lines · Jack O'Quin
Quoted 6 lines

security/realtime.c line 18

Quoted 2 lines
security/realtime.c +2 -0
+#include <linux/module.h>
+#include <linux/security.h>

These seem to be the only two includes that are needed.

Any other objections to the patch?

Fine with me, as long as you're certain. I'll be away for a few days, so I can't make that change and test it right now, myself.

Well I am certain it works with the current kernel.

The change could break older kernels, so I did not commit anything.

Lee

#6 lore raw

Re: [PATCH] Realtime LSM updated patch 2.6.10-rc2-mm3-rt2

In reply to Lee Revell

To save time, here is the original announcement...

http://lkml.org/lkml/2004/11/9/288

Quoted 5 lines · Lee Revell

Review

Quoted 2 lines · Jack O'Quin
(quoted diff) +2 -0
+#include <linux/module.h>
+#include <linux/security.h>

These seem to be the only two includes that are needed.

This updated patch removes the unnecessary includes. There are no other changes. It was applied against 2.6.10-rc2-mm3.

Documentation/realtime-lsm.txt +39 -0
diff -ruN -X /home/joq/bin/kdiff.exclude linux-2.6.10-rc2-mm3/Documentation/realtime-lsm.txt linux-2.6.10-rc2-mm3-rt2/Documentation/realtime-lsm.txt
@@ -0,0 +1,39 @@
+
+		    Realtime Linux Security Module
+
+
+This Linux Security Module (LSM) enables realtime capabilities.  It
+was written by Torben Hohn and Jack O'Quin, under the provisions of
+the GPL (see the COPYING file).  We make no warranty concerning the
+safety, security or even stability of your system when using it.  But,
+we will fix problems if you report them.
+
+Once the LSM has been installed and the kernel for which it was built
+is running, the root user can load it and pass parameters as follows:
+
+  # modprobe realtime any=1
+
+  Any program can request realtime privileges.  This allows any local
+  user to crash the system by hogging the CPU in a tight loop or
+  locking down too much memory.  But, it is simple to administer.  :-)
+
+  # modprobe realtime gid=29
+
+  All users belonging to group 29 and programs that are setgid to that
+  group have realtime privileges.  Use any group number you like.  A
+  `gid' of -1 disables group access.
+
+  # modprobe realtime mlock=0
+
+  Grants realtime scheduling privileges without the ability to lock
+  memory using mlock() or mlockall() system calls.  This option can be
+  used in conjunction with any of the other options.
+
+After the module is loaded, its parameters can be changed dynamically
+via sysfs.
+
+  # echo 1  > /sys/module/realtime/parameters/any
+  # echo 29 > /sys/module/realtime/parameters/gid
+  # echo 1  > /sys/module/realtime/parameters/mlock
+
+Jack O'Quin, [email protected]
security/Kconfig +11 -0
diff -ruN -X /home/joq/bin/kdiff.exclude linux-2.6.10-rc2-mm3/security/Kconfig linux-2.6.10-rc2-mm3-rt2/security/Kconfig
@@ -84,6 +84,17 @@
 
 	  If you are unsure how to answer this question, answer N.
 
+config SECURITY_REALTIME
+	tristate "Realtime Capabilities"
+	depends on SECURITY && SECURITY_CAPABILITIES!=y
+	default n
+	help
+	  This module selectively grants realtime privileges
+	  controlled by parameters set at load time or via files in
+	  /sys/module/realtime/parameters.
+
+	  If you are unsure how to answer this question, answer N.
+
 source security/selinux/Kconfig
 
 endmenu
security/Makefile +1 -0
diff -ruN -X /home/joq/bin/kdiff.exclude linux-2.6.10-rc2-mm3/security/Makefile linux-2.6.10-rc2-mm3-rt2/security/Makefile
@@ -17,3 +17,4 @@
 obj-$(CONFIG_SECURITY_CAPABILITIES)	+= commoncap.o capability.o
 obj-$(CONFIG_SECURITY_ROOTPLUG)		+= commoncap.o root_plug.o
 obj-$(CONFIG_SECURITY_SECLVL)		+= seclvl.o
+obj-$(CONFIG_SECURITY_REALTIME)		+= commoncap.o realtime.o
security/realtime.c +147 -0

147 lines not on this page · raw message

Signature · 1 line
  joq