20510f2f4e
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: James Morris <jmorris@namei.org> Acked-by: Chris Wright <chrisw@sous-sol.org> Cc: Stephen Smalley <sds@tycho.nsa.gov> Cc: "Serge E. Hallyn" <serue@us.ibm.com> Acked-by: Arjan van de Ven <arjan@infradead.org> Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
76 lines
2.1 KiB
C
76 lines
2.1 KiB
C
/*
|
|
* Capabilities Linux Security Module
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
*/
|
|
|
|
#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/skbuff.h>
|
|
#include <linux/netlink.h>
|
|
#include <linux/ptrace.h>
|
|
#include <linux/moduleparam.h>
|
|
|
|
static struct security_operations capability_ops = {
|
|
.ptrace = cap_ptrace,
|
|
.capget = cap_capget,
|
|
.capset_check = cap_capset_check,
|
|
.capset_set = cap_capset_set,
|
|
.capable = cap_capable,
|
|
.settime = cap_settime,
|
|
.netlink_send = cap_netlink_send,
|
|
.netlink_recv = cap_netlink_recv,
|
|
|
|
.bprm_apply_creds = cap_bprm_apply_creds,
|
|
.bprm_set_security = cap_bprm_set_security,
|
|
.bprm_secureexec = cap_bprm_secureexec,
|
|
|
|
.inode_setxattr = cap_inode_setxattr,
|
|
.inode_removexattr = cap_inode_removexattr,
|
|
|
|
.task_post_setuid = cap_task_post_setuid,
|
|
.task_reparent_to_init = cap_task_reparent_to_init,
|
|
|
|
.syslog = cap_syslog,
|
|
|
|
.vm_enough_memory = cap_vm_enough_memory,
|
|
};
|
|
|
|
/* flag to keep track of how we were registered */
|
|
static int secondary;
|
|
|
|
static int capability_disable;
|
|
module_param_named(disable, capability_disable, int, 0);
|
|
|
|
static int __init capability_init (void)
|
|
{
|
|
if (capability_disable) {
|
|
printk(KERN_INFO "Capabilities disabled at initialization\n");
|
|
return 0;
|
|
}
|
|
/* register ourselves with the security framework */
|
|
if (register_security (&capability_ops)) {
|
|
/* try registering with primary module */
|
|
if (mod_reg_security (KBUILD_MODNAME, &capability_ops)) {
|
|
printk (KERN_INFO "Failure registering capabilities "
|
|
"with primary security module.\n");
|
|
return -EINVAL;
|
|
}
|
|
secondary = 1;
|
|
}
|
|
printk (KERN_INFO "Capability LSM initialized%s\n",
|
|
secondary ? " as secondary" : "");
|
|
return 0;
|
|
}
|
|
|
|
security_initcall (capability_init);
|