Commit 20510f2f authored by James Morris's avatar James Morris Committed by Linus Torvalds

security: Convert LSM into a static interface

Convert LSM into a static interface, as the ability to unload a security
module is not required by in-tree users and potentially complicates the
overall security architecture.

Needlessly exported LSM symbols have been unexported, to help reduce API
abuse.

Parameters for the capability and root_plug modules are now specified
at boot.

The SECURITY_FRAMEWORK_VERSION macro has also been removed.

In a nutshell, there is no safe way to unload an LSM.  The modular interface
is thus unecessary and broken infrastructure.  It is used only by out-of-tree
modules, which are often binary-only, illegal, abusive of the API and
dangerous, e.g.  silently re-vectoring SELinux.

[akpm@linux-foundation.org: cleanups]
[akpm@linux-foundation.org: USB Kconfig fix]
[randy.dunlap@oracle.com: fix LSM kernel-doc]
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
Acked-by: default avatarChris Wright <chrisw@sous-sol.org>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: "Serge E. Hallyn" <serue@us.ibm.com>
Acked-by: default avatarArjan van de Ven <arjan@infradead.org>
Signed-off-by: default avatarRandy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5c3b4474
...@@ -340,7 +340,7 @@ X!Earch/x86/kernel/mca_32.c ...@@ -340,7 +340,7 @@ X!Earch/x86/kernel/mca_32.c
<chapter id="security"> <chapter id="security">
<title>Security Framework</title> <title>Security Framework</title>
!Esecurity/security.c !Isecurity/security.c
</chapter> </chapter>
<chapter id="audit"> <chapter id="audit">
......
...@@ -75,10 +75,12 @@ parameter is applicable: ...@@ -75,10 +75,12 @@ parameter is applicable:
PPT Parallel port support is enabled. PPT Parallel port support is enabled.
PS2 Appropriate PS/2 support is enabled. PS2 Appropriate PS/2 support is enabled.
RAM RAM disk support is enabled. RAM RAM disk support is enabled.
ROOTPLUG The example Root Plug LSM is enabled.
S390 S390 architecture is enabled. S390 S390 architecture is enabled.
SCSI Appropriate SCSI support is enabled. SCSI Appropriate SCSI support is enabled.
A lot of drivers has their options described inside of A lot of drivers has their options described inside of
Documentation/scsi/. Documentation/scsi/.
SECURITY Different security models are enabled.
SELINUX SELinux support is enabled. SELINUX SELinux support is enabled.
SERIAL Serial support is enabled. SERIAL Serial support is enabled.
SH SuperH architecture is enabled. SH SuperH architecture is enabled.
...@@ -373,6 +375,12 @@ and is between 256 and 4096 characters. It is defined in the file ...@@ -373,6 +375,12 @@ and is between 256 and 4096 characters. It is defined in the file
possible to determine what the correct size should be. possible to determine what the correct size should be.
This option provides an override for these situations. This option provides an override for these situations.
capability.disable=
[SECURITY] Disable capabilities. This would normally
be used only if an alternative security model is to be
configured. Potentially dangerous and should only be
used if you are entirely sure of the consequences.
chandev= [HW,NET] Generic channel device initialisation chandev= [HW,NET] Generic channel device initialisation
checkreqprot [SELINUX] Set initial checkreqprot flag value. checkreqprot [SELINUX] Set initial checkreqprot flag value.
...@@ -1539,6 +1547,15 @@ and is between 256 and 4096 characters. It is defined in the file ...@@ -1539,6 +1547,15 @@ and is between 256 and 4096 characters. It is defined in the file
Useful for devices that are detected asynchronously Useful for devices that are detected asynchronously
(e.g. USB and MMC devices). (e.g. USB and MMC devices).
root_plug.vendor_id=
[ROOTPLUG] Override the default vendor ID
root_plug.product_id=
[ROOTPLUG] Override the default product ID
root_plug.debug=
[ROOTPLUG] Enable debugging output
rw [KNL] Mount root device read-write on boot rw [KNL] Mount root device read-write on boot
S [KNL] Run init in single mode S [KNL] Run init in single mode
......
This diff is collapsed.
...@@ -74,15 +74,15 @@ config SECURITY_NETWORK_XFRM ...@@ -74,15 +74,15 @@ config SECURITY_NETWORK_XFRM
If you are unsure how to answer this question, answer N. If you are unsure how to answer this question, answer N.
config SECURITY_CAPABILITIES config SECURITY_CAPABILITIES
tristate "Default Linux Capabilities" bool "Default Linux Capabilities"
depends on SECURITY depends on SECURITY
help help
This enables the "default" Linux capabilities functionality. This enables the "default" Linux capabilities functionality.
If you are unsure how to answer this question, answer Y. If you are unsure how to answer this question, answer Y.
config SECURITY_ROOTPLUG config SECURITY_ROOTPLUG
tristate "Root Plug Support" bool "Root Plug Support"
depends on USB && SECURITY depends on USB=y && SECURITY
help help
This is a sample LSM module that should only be used as such. This is a sample LSM module that should only be used as such.
It prevents any programs running with egid == 0 if a specific It prevents any programs running with egid == 0 if a specific
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
* *
*/ */
#include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/security.h> #include <linux/security.h>
...@@ -52,7 +51,6 @@ static int secondary; ...@@ -52,7 +51,6 @@ static int secondary;
static int capability_disable; static int capability_disable;
module_param_named(disable, capability_disable, int, 0); module_param_named(disable, capability_disable, int, 0);
MODULE_PARM_DESC(disable, "To disable capabilities module set disable = 1");
static int __init capability_init (void) static int __init capability_init (void)
{ {
...@@ -75,26 +73,4 @@ static int __init capability_init (void) ...@@ -75,26 +73,4 @@ static int __init capability_init (void)
return 0; return 0;
} }
static void __exit capability_exit (void)
{
if (capability_disable)
return;
/* remove ourselves from the security framework */
if (secondary) {
if (mod_unreg_security (KBUILD_MODNAME, &capability_ops))
printk (KERN_INFO "Failure unregistering capabilities "
"with primary module.\n");
return;
}
if (unregister_security (&capability_ops)) {
printk (KERN_INFO
"Failure unregistering capabilities with the kernel\n");
}
}
security_initcall (capability_init); security_initcall (capability_init);
module_exit (capability_exit);
MODULE_DESCRIPTION("Standard Linux Capabilities Security Module");
MODULE_LICENSE("GPL");
...@@ -339,6 +339,3 @@ EXPORT_SYMBOL(cap_task_post_setuid); ...@@ -339,6 +339,3 @@ EXPORT_SYMBOL(cap_task_post_setuid);
EXPORT_SYMBOL(cap_task_reparent_to_init); EXPORT_SYMBOL(cap_task_reparent_to_init);
EXPORT_SYMBOL(cap_syslog); EXPORT_SYMBOL(cap_syslog);
EXPORT_SYMBOL(cap_vm_enough_memory); EXPORT_SYMBOL(cap_vm_enough_memory);
MODULE_DESCRIPTION("Standard Linux Common Capabilities Security Module");
MODULE_LICENSE("GPL");
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#undef DEBUG #undef DEBUG
#include <linux/capability.h> #include <linux/capability.h>
#include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/mman.h> #include <linux/mman.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
......
...@@ -22,11 +22,11 @@ ...@@ -22,11 +22,11 @@
* License. * License.
*/ */
#include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/moduleparam.h>
/* flag to keep track of how we were registered */ /* flag to keep track of how we were registered */
static int secondary; static int secondary;
...@@ -36,22 +36,14 @@ static int vendor_id = 0x0557; ...@@ -36,22 +36,14 @@ static int vendor_id = 0x0557;
static int product_id = 0x2008; static int product_id = 0x2008;
module_param(vendor_id, uint, 0400); module_param(vendor_id, uint, 0400);
MODULE_PARM_DESC(vendor_id, "USB Vendor ID of device to look for");
module_param(product_id, uint, 0400); module_param(product_id, uint, 0400);
MODULE_PARM_DESC(product_id, "USB Product ID of device to look for");
/* should we print out debug messages */ /* should we print out debug messages */
static int debug = 0; static int debug = 0;
module_param(debug, bool, 0600); module_param(debug, bool, 0600);
MODULE_PARM_DESC(debug, "Debug enabled or not");
#if defined(CONFIG_SECURITY_ROOTPLUG_MODULE)
#define MY_NAME THIS_MODULE->name
#else
#define MY_NAME "root_plug" #define MY_NAME "root_plug"
#endif
#define root_dbg(fmt, arg...) \ #define root_dbg(fmt, arg...) \
do { \ do { \
...@@ -117,25 +109,4 @@ static int __init rootplug_init (void) ...@@ -117,25 +109,4 @@ static int __init rootplug_init (void)
return 0; return 0;
} }
static void __exit rootplug_exit (void)
{
/* remove ourselves from the security framework */
if (secondary) {
if (mod_unreg_security (MY_NAME, &rootplug_security_ops))
printk (KERN_INFO "Failure unregistering Root Plug "
" module with primary module.\n");
} else {
if (unregister_security (&rootplug_security_ops)) {
printk (KERN_INFO "Failure unregistering Root Plug "
"module with the kernel\n");
}
}
printk (KERN_INFO "Root Plug module removed\n");
}
security_initcall (rootplug_init); security_initcall (rootplug_init);
module_exit (rootplug_exit);
MODULE_DESCRIPTION("Root Plug sample LSM module, written for Linux Journal article");
MODULE_LICENSE("GPL");
This diff is collapsed.
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
* as published by the Free Software Foundation. * as published by the Free Software Foundation.
*/ */
#include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
...@@ -86,6 +85,7 @@ ...@@ -86,6 +85,7 @@
extern unsigned int policydb_loaded_version; extern unsigned int policydb_loaded_version;
extern int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm); extern int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm);
extern int selinux_compat_net; extern int selinux_compat_net;
extern struct security_operations *security_ops;
#ifdef CONFIG_SECURITY_SELINUX_DEVELOP #ifdef CONFIG_SECURITY_SELINUX_DEVELOP
int selinux_enforcing = 0; int selinux_enforcing = 0;
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
* 2. Emulating a reasonable SO_PEERSEC across machines * 2. Emulating a reasonable SO_PEERSEC across machines
* 3. Testing addition of sk_policy's with security context via setsockopt * 3. Testing addition of sk_policy's with security context via setsockopt
*/ */
#include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/security.h> #include <linux/security.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment