2005-02-13 21:05:44

by Kurt Garloff

[permalink] [raw]
Subject: [PATCH] 0/5: LSM hooks rework

Hi,

this goes back to a discussion in August last year:
http://www.ussg.iu.edu/hypermail/linux/kernel/0408.1/0623.html

The following patchset addresses three issues of the security.h stub
collection:
* All the functions are implemented twice, once for
CONFIG_SECURITY enabled and once for disabled.
Makes it harder than necessary to keep in sync
and the file much longer than needed.
* We do lots of indirect (and thus non-inlined) calls to
mostly noop functions, which has a performance impact.
By using a branch (as suggested by David Mosberger and
implemented by Brian Baker) we can save a number of cycles.
Especially visible on IA64, where we can get > 3% improvement
on netperf -t TCP_RR
* The default of dummy if CONFIG_SECURITY is enabled is not
desirable as it does differ from the CONFIG_SECURITY disabled
default. Thus make capabilities the default.

Patches are against 2.6.11-rc4 and follow in subsequent mails.
--
Kurt Garloff, Director SUSE Labs, Novell Inc.


Attachments:
(No filename) (998.00 B)
(No filename) (189.00 B)
Download all attachments

2005-02-13 21:12:29

by Kurt Garloff

[permalink] [raw]
Subject: [PATCH] 1/5: LSM hooks rework

From: Kurt Garloff <[email protected]>
Subject: Default to capability rather than dummy if no LSM is loaded
References: 40217, 39439

If a kernel is compiled with CONFIG_SECURITY to enable LSM, the
default behaviour changes unless a user load capability.
This is undesirable. This patch makes capability the default.
capability can still be compiled as module and be loaded as LSM.
If loaded as primary LSM, it won't change anything. But it can
also be loaded as secondary LSM.
Note that we could think of getting rid of dummy; however, it's
still used as fallback for stubs that are not implemented by an
LSM. I did not want to change this with this patch set, though
I'd like to see it done if everyone agrees it's a good idea.

This is patch 1/5 of the LSM overhaul.

Makefile | 8 +++-----
capability.c | 38 ++++++++++++++------------------------
commoncap.c | 37 +++++++++++++++++++++++++++++++++++++
security.c | 21 ++++++++++++---------
4 files changed, 66 insertions(+), 38 deletions(-)

Signed-off-by: Kurt Garloff <[email protected]>

Index: linux-2.6.10/security/security.c
===================================================================
--- linux-2.6.10.orig/security/security.c
+++ linux-2.6.10/security/security.c
@@ -20,10 +20,11 @@

#define SECURITY_FRAMEWORK_VERSION "1.0.0"

/* things that live in dummy.c */
-extern struct security_operations dummy_security_ops;
-extern void security_fixup_ops(struct security_operations *ops);
+extern void security_fixup_ops (struct security_operations *ops);
+/* default security ops */
+extern struct security_operations capability_security_ops;

struct security_operations *security_ops; /* Initialized to NULL */

static inline int verify(struct security_operations *ops)
@@ -54,15 +55,17 @@ int __init security_init(void)
{
printk(KERN_INFO "Security Framework v" SECURITY_FRAMEWORK_VERSION
" initialized\n");

- if (verify(&dummy_security_ops)) {
+ if (verify(&capability_security_ops)) {
printk(KERN_ERR "%s could not verify "
- "dummy_security_ops structure.\n", __FUNCTION__);
+ "capability_security_ops structure.\n", __FUNCTION__);
return -EIO;
}

- security_ops = &dummy_security_ops;
+ security_ops = &capability_security_ops;
+
+ /* Initialize compiled-in security modules */
do_security_initcalls();

return 0;
}
@@ -86,9 +89,9 @@ int register_security(struct security_op
"security_operations structure.\n", __FUNCTION__);
return -EINVAL;
}

- if (security_ops != &dummy_security_ops)
+ if (security_ops != &capability_security_ops)
return -EAGAIN;

security_ops = ops;

@@ -103,20 +106,20 @@ int register_security(struct security_op
* previously been registered with a successful call to register_security().
*
* If @ops does not match the valued previously passed to register_security()
* an error is returned. Otherwise the default security options is set to the
- * the dummy_security_ops structure, and 0 is returned.
+ * the capability_security_ops structure, and 0 is returned.
*/
int unregister_security(struct security_operations *ops)
{
if (ops != security_ops) {
printk(KERN_INFO "%s: trying to unregister "
- "a security_opts structure that is not "
+ "a security_ops structure that is not "
"registered, failing.\n", __FUNCTION__);
return -EINVAL;
}

- security_ops = &dummy_security_ops;
+ security_ops = &capability_security_ops;

return 0;
}

Index: linux-2.6.10/security/commoncap.c
===================================================================
--- linux-2.6.10.orig/security/commoncap.c
+++ linux-2.6.10/security/commoncap.c
@@ -324,8 +324,45 @@ int cap_vm_enough_memory(long pages)
cap_sys_admin = 1;
return __vm_enough_memory(pages, cap_sys_admin);
}

+#ifdef CONFIG_SECURITY
+struct security_operations capability_security_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,
+};
+
+EXPORT_SYMBOL(capability_security_ops);
+/* Note: If the capability security module is loaded, we do NOT register
+ * the capability_security_ops but a second structure that has the
+ * identical entries. The reason is that this way,
+ * - we could stack on top of capability if it was stackable
+ * - a loaded capability module will prevent others to register, which
+ * is the previous behaviour; if capabilities are used as default (not
+ * because the module has been loaded), we allow the replacement.
+ */
+#endif
+
EXPORT_SYMBOL(cap_capable);
EXPORT_SYMBOL(cap_settime);
EXPORT_SYMBOL(cap_ptrace);
EXPORT_SYMBOL(cap_capget);
Index: linux-2.6.10/security/Makefile
===================================================================
--- linux-2.6.10.orig/security/Makefile
+++ linux-2.6.10/security/Makefile
@@ -4,16 +4,14 @@

obj-$(CONFIG_KEYS) += keys/
subdir-$(CONFIG_SECURITY_SELINUX) += selinux

-# if we don't select a security model, use the default capabilities
-ifneq ($(CONFIG_SECURITY),y)
+# We always need commoncap as it's default
obj-y += commoncap.o
-endif

# Object file lists
obj-$(CONFIG_SECURITY) += security.o dummy.o
# Must precede capability.o in order to stack properly.
obj-$(CONFIG_SECURITY_SELINUX) += selinux/built-in.o
-obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o
-obj-$(CONFIG_SECURITY_ROOTPLUG) += commoncap.o root_plug.o
+obj-$(CONFIG_SECURITY_CAPABILITIES) += capability.o
+obj-$(CONFIG_SECURITY_ROOTPLUG) += root_plug.o
obj-$(CONFIG_SECURITY_SECLVL) += seclvl.o
Index: linux-2.6.10/security/capability.c
===================================================================
--- linux-2.6.10.orig/security/capability.c
+++ linux-2.6.10/security/capability.c
@@ -23,32 +23,21 @@
#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,
-};
+/* Note: If the capability security module is loaded, we do NOT register
+ * the capability_security_ops but a second structure capability_ops
+ * that has the identical entries. The reasons:
+ * - we could stack on top of capability if it was stackable
+ * - a loaded capability module will prevent others to register, which
+ * is the previous behaviour; if capabilities are used as default (not
+ * because the module has been loaded), we allow the replacement.
+ */
+
+/* Struct from commoncaps */
+extern struct security_operations capability_security_ops;
+/* Struct to hold the copy */
+static struct security_operations capability_ops;

#define MY_NAME __stringify(KBUILD_MODNAME)

/* flag to keep track of how we were registered */
@@ -59,8 +48,9 @@ module_param_named(disable, capability_d
MODULE_PARM_DESC(disable, "To disable capabilities module set disable = 1");

static int __init capability_init (void)
{
+ memcpy(&capability_ops, &capability_security_ops, sizeof(capability_ops));
if (capability_disable) {
printk(KERN_INFO "Capabilities disabled at initialization\n");
return 0;
}
--
Kurt Garloff, Director SUSE Labs, Novell Inc.


Attachments:
(No filename) (8.16 kB)
(No filename) (189.00 B)
Download all attachments

2005-02-13 21:17:59

by Kurt Garloff

[permalink] [raw]
Subject: [PATCH] 3/5: LSM hooks rework

From: Kurt Garloff <[email protected]>
Subject: Replace indirect calls by a branch
References: 40217, 39439

In the LSM stub collection, rather do a branch than an indirect
call. Many of the functions called do only return 0 or do nothing
for the default (capability) case.
This is a fast-path optimization; a branch is faster than an
indirect call, even more so if correctly predicted.
This shows a >3% perf. increase in netperf -t TCP_RR benchmark on IA64.
(More exactly: The benchmark was taken with the next two patches
applied as well, but I attribute the main effect to this patch.)

This is patch 3/5 of the LSM overhaul.

include/linux/security.h | 6 +++++-
security/security.c | 2 --
2 files changed, 5 insertions(+), 3 deletions(-)

Signed-off-by: Kurt Garloff <[email protected]>

Index: linux-2.6.10/include/linux/security.h
===================================================================
--- linux-2.6.10.orig/include/linux/security.h
+++ linux-2.6.10/include/linux/security.h
@@ -1241,17 +1241,21 @@ struct security_operations {
};

/* global variables */
extern struct security_operations *security_ops;
+/* default security ops */
+extern struct security_operations capability_security_ops;

/* prototypes */
extern int security_init (void);
extern int register_security (struct security_operations *ops);
extern int unregister_security (struct security_operations *ops);
extern int mod_reg_security (const char *name, struct security_operations *ops);
extern int mod_unreg_security (const char *name, struct security_operations *ops);

-#define COND_SECURITY(seop, def) security_ops->seop
+/* Condition for invocation of non-default security_op */
+#define COND_SECURITY(seop, def) \
+ (security_ops == &capability_security_ops)? def: security_ops->seop

#else /* CONFIG_SECURITY */
static inline int security_init(void)
{
Index: linux-2.6.10/security/security.c
===================================================================
--- linux-2.6.10.orig/security/security.c
+++ linux-2.6.10/security/security.c
@@ -21,10 +21,8 @@
#define SECURITY_FRAMEWORK_VERSION "1.0.0"

/* things that live in dummy.c */
extern void security_fixup_ops (struct security_operations *ops);
-/* default security ops */
-extern struct security_operations capability_security_ops;

struct security_operations *security_ops; /* Initialized to NULL */

static inline int verify(struct security_operations *ops)
--
Kurt Garloff, Director SUSE Labs, Novell Inc.


Attachments:
(No filename) (2.44 kB)
(No filename) (189.00 B)
Download all attachments

2005-02-13 21:17:49

by Kurt Garloff

[permalink] [raw]
Subject: [PATCH] 2/5: LSM hooks rework

From: Kurt Garloff <[email protected]>
Subject: Clean LSM stub file
References: 40217, 39439

Rather than having every LSM hook twice, once for the case with
CONFIG_SECURITY enabled and once for the disabled case, put
everything in one inline function. This reduces the chance of
the two to go out of sync immensely.

This is patch 2/5 of the LSM overhaul.

security.h | 1268 ++++++++++++++++---------------------------------------------
1 files changed, 337 insertions(+), 931 deletions(-)

Signed-off-by: Kurt Garloff <[email protected]>

Index: linux-2.6.10/include/linux/security.h
===================================================================
--- linux-2.6.10.orig/include/linux/security.h
+++ linux-2.6.10/include/linux/security.h
@@ -1242,1543 +1242,949 @@ struct security_operations {

/* global variables */
extern struct security_operations *security_ops;

+/* prototypes */
+extern int security_init (void);
+extern int register_security (struct security_operations *ops);
+extern int unregister_security (struct security_operations *ops);
+extern int mod_reg_security (const char *name, struct security_operations *ops);
+extern int mod_unreg_security (const char *name, struct security_operations *ops);
+
+#define COND_SECURITY(seop, def) security_ops->seop
+
+#else /* CONFIG_SECURITY */
+static inline int security_init(void)
+{
+ return 0;
+}
+
+# define COND_SECURITY(seop, def) def
+#endif
+
+/* SELinux noop */
+#define SE_NOP ({})
+
/* inline stuff */
static inline int security_ptrace (struct task_struct * parent, struct task_struct * child)
{
- return security_ops->ptrace (parent, child);
+ return COND_SECURITY(ptrace (parent, child),
+ cap_ptrace (parent, child));
}

static inline int security_capget (struct task_struct *target,
kernel_cap_t *effective,
kernel_cap_t *inheritable,
kernel_cap_t *permitted)
{
- return security_ops->capget (target, effective, inheritable, permitted);
+ return COND_SECURITY(capget (target, effective, inheritable, permitted),
+ cap_capget (target, effective, inheritable, permitted));
}

static inline int security_capset_check (struct task_struct *target,
kernel_cap_t *effective,
kernel_cap_t *inheritable,
kernel_cap_t *permitted)
{
- return security_ops->capset_check (target, effective, inheritable, permitted);
+ return COND_SECURITY(capset_check (target, effective, inheritable, permitted),
+ cap_capset_check (target, effective, inheritable, permitted));
}

static inline void security_capset_set (struct task_struct *target,
kernel_cap_t *effective,
kernel_cap_t *inheritable,
kernel_cap_t *permitted)
{
- security_ops->capset_set (target, effective, inheritable, permitted);
+ COND_SECURITY(capset_set (target, effective, inheritable, permitted),
+ cap_capset_set (target, effective, inheritable, permitted));
}

static inline int security_acct (struct file *file)
{
- return security_ops->acct (file);
+ return COND_SECURITY(acct (file),
+ 0);
}

static inline int security_sysctl(struct ctl_table *table, int op)
{
- return security_ops->sysctl(table, op);
+ return COND_SECURITY(sysctl(table, op),
+ 0);
}

static inline int security_quotactl (int cmds, int type, int id,
struct super_block *sb)
{
- return security_ops->quotactl (cmds, type, id, sb);
+ return COND_SECURITY(quotactl (cmds, type, id, sb),
+ 0);
}

static inline int security_quota_on (struct dentry * dentry)
{
- return security_ops->quota_on (dentry);
+ return COND_SECURITY(quota_on (dentry),
+ 0);
}

static inline int security_syslog(int type)
{
- return security_ops->syslog(type);
+ return COND_SECURITY(syslog(type),
+ cap_syslog(type));
}

static inline int security_settime(struct timespec *ts, struct timezone *tz)
{
- return security_ops->settime(ts, tz);
+ return COND_SECURITY(settime(ts, tz),
+ cap_settime(ts, tz));
}


static inline int security_vm_enough_memory(long pages)
{
- return security_ops->vm_enough_memory(pages);
+ return COND_SECURITY(vm_enough_memory(pages),
+ cap_vm_enough_memory(pages));
}

static inline int security_bprm_alloc (struct linux_binprm *bprm)
{
- return security_ops->bprm_alloc_security (bprm);
+ return COND_SECURITY(bprm_alloc_security (bprm),
+ 0);
}
static inline void security_bprm_free (struct linux_binprm *bprm)
{
- security_ops->bprm_free_security (bprm);
+ COND_SECURITY(bprm_free_security (bprm),
+ SE_NOP);
}
static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
{
- security_ops->bprm_apply_creds (bprm, unsafe);
+ COND_SECURITY(bprm_apply_creds (bprm, unsafe),
+ cap_bprm_apply_creds (bprm, unsafe));
}
static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
{
- security_ops->bprm_post_apply_creds (bprm);
+ COND_SECURITY(bprm_post_apply_creds (bprm),
+ SE_NOP);
}
static inline int security_bprm_set (struct linux_binprm *bprm)
{
- return security_ops->bprm_set_security (bprm);
+ return COND_SECURITY(bprm_set_security (bprm),
+ cap_bprm_set_security (bprm));
}

static inline int security_bprm_check (struct linux_binprm *bprm)
{
- return security_ops->bprm_check_security (bprm);
+ return COND_SECURITY(bprm_check_security (bprm),
+ 0);
}

static inline int security_bprm_secureexec (struct linux_binprm *bprm)
{
- return security_ops->bprm_secureexec (bprm);
+ return COND_SECURITY(bprm_secureexec (bprm),
+ cap_bprm_secureexec (bprm));
}

static inline int security_sb_alloc (struct super_block *sb)
{
- return security_ops->sb_alloc_security (sb);
+ return COND_SECURITY(sb_alloc_security (sb),
+ 0);
}

static inline void security_sb_free (struct super_block *sb)
{
- security_ops->sb_free_security (sb);
+ COND_SECURITY(sb_free_security (sb),
+ SE_NOP);
}

static inline int security_sb_copy_data (struct file_system_type *type,
void *orig, void *copy)
{
- return security_ops->sb_copy_data (type, orig, copy);
+ return COND_SECURITY(sb_copy_data (type, orig, copy),
+ 0);
}

static inline int security_sb_kern_mount (struct super_block *sb, void *data)
{
- return security_ops->sb_kern_mount (sb, data);
+ return COND_SECURITY(sb_kern_mount (sb, data),
+ 0);
}

static inline int security_sb_statfs (struct super_block *sb)
{
- return security_ops->sb_statfs (sb);
+ return COND_SECURITY(sb_statfs (sb),
+ 0);
}

static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
char *type, unsigned long flags,
void *data)
{
- return security_ops->sb_mount (dev_name, nd, type, flags, data);
+ return COND_SECURITY(sb_mount (dev_name, nd, type, flags, data),
+ 0);
}

static inline int security_sb_check_sb (struct vfsmount *mnt,
struct nameidata *nd)
{
- return security_ops->sb_check_sb (mnt, nd);
+ return COND_SECURITY(sb_check_sb (mnt, nd),
+ 0);
}

static inline int security_sb_umount (struct vfsmount *mnt, int flags)
{
- return security_ops->sb_umount (mnt, flags);
+ return COND_SECURITY(sb_umount (mnt, flags),
+ 0);
}

static inline void security_sb_umount_close (struct vfsmount *mnt)
{
- security_ops->sb_umount_close (mnt);
+ COND_SECURITY(sb_umount_close (mnt),
+ SE_NOP);
}

static inline void security_sb_umount_busy (struct vfsmount *mnt)
{
- security_ops->sb_umount_busy (mnt);
+ COND_SECURITY(sb_umount_busy (mnt),
+ SE_NOP);
}

static inline void security_sb_post_remount (struct vfsmount *mnt,
unsigned long flags, void *data)
{
- security_ops->sb_post_remount (mnt, flags, data);
+ COND_SECURITY(sb_post_remount (mnt, flags, data),
+ SE_NOP);
}

static inline void security_sb_post_mountroot (void)
{
- security_ops->sb_post_mountroot ();
+ COND_SECURITY(sb_post_mountroot (),
+ SE_NOP);
}

static inline void security_sb_post_addmount (struct vfsmount *mnt,
struct nameidata *mountpoint_nd)
{
- security_ops->sb_post_addmount (mnt, mountpoint_nd);
+ COND_SECURITY(sb_post_addmount (mnt, mountpoint_nd),
+ SE_NOP);
}

static inline int security_sb_pivotroot (struct nameidata *old_nd,
struct nameidata *new_nd)
{
- return security_ops->sb_pivotroot (old_nd, new_nd);
+ return COND_SECURITY(sb_pivotroot (old_nd, new_nd),
+ 0);
}

static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
struct nameidata *new_nd)
{
- security_ops->sb_post_pivotroot (old_nd, new_nd);
+ COND_SECURITY(sb_post_pivotroot (old_nd, new_nd),
+ SE_NOP);
}

static inline int security_inode_alloc (struct inode *inode)
{
- return security_ops->inode_alloc_security (inode);
+ return COND_SECURITY(inode_alloc_security (inode),
+ 0);
}

static inline void security_inode_free (struct inode *inode)
{
- security_ops->inode_free_security (inode);
+ COND_SECURITY(inode_free_security (inode),
+ SE_NOP);
}

static inline int security_inode_create (struct inode *dir,
struct dentry *dentry,
int mode)
{
- return security_ops->inode_create (dir, dentry, mode);
+ return COND_SECURITY(inode_create (dir, dentry, mode),
+ 0);
}

static inline void security_inode_post_create (struct inode *dir,
struct dentry *dentry,
int mode)
{
- security_ops->inode_post_create (dir, dentry, mode);
+ COND_SECURITY(inode_post_create (dir, dentry, mode),
+ SE_NOP);
}

static inline int security_inode_link (struct dentry *old_dentry,
struct inode *dir,
struct dentry *new_dentry)
{
- return security_ops->inode_link (old_dentry, dir, new_dentry);
+ return COND_SECURITY(inode_link (old_dentry, dir, new_dentry),
+ 0);
}

static inline void security_inode_post_link (struct dentry *old_dentry,
struct inode *dir,
struct dentry *new_dentry)
{
- security_ops->inode_post_link (old_dentry, dir, new_dentry);
+ COND_SECURITY(inode_post_link (old_dentry, dir, new_dentry),
+ SE_NOP);
}

static inline int security_inode_unlink (struct inode *dir,
struct dentry *dentry)
{
- return security_ops->inode_unlink (dir, dentry);
+ return COND_SECURITY(inode_unlink (dir, dentry),
+ 0);
}

static inline int security_inode_symlink (struct inode *dir,
struct dentry *dentry,
const char *old_name)
{
- return security_ops->inode_symlink (dir, dentry, old_name);
+ return COND_SECURITY(inode_symlink (dir, dentry, old_name),
+ 0);
}

static inline void security_inode_post_symlink (struct inode *dir,
struct dentry *dentry,
const char *old_name)
{
- security_ops->inode_post_symlink (dir, dentry, old_name);
+ COND_SECURITY(inode_post_symlink (dir, dentry, old_name),
+ SE_NOP);
}

static inline int security_inode_mkdir (struct inode *dir,
struct dentry *dentry,
int mode)
{
- return security_ops->inode_mkdir (dir, dentry, mode);
+ return COND_SECURITY(inode_mkdir (dir, dentry, mode),
+ 0);
}

static inline void security_inode_post_mkdir (struct inode *dir,
struct dentry *dentry,
int mode)
{
- security_ops->inode_post_mkdir (dir, dentry, mode);
+ COND_SECURITY(inode_post_mkdir (dir, dentry, mode),
+ SE_NOP);
}

static inline int security_inode_rmdir (struct inode *dir,
struct dentry *dentry)
{
- return security_ops->inode_rmdir (dir, dentry);
+ return COND_SECURITY(inode_rmdir (dir, dentry),
+ 0);
}

static inline int security_inode_mknod (struct inode *dir,
struct dentry *dentry,
int mode, dev_t dev)
{
- return security_ops->inode_mknod (dir, dentry, mode, dev);
+ return COND_SECURITY(inode_mknod (dir, dentry, mode, dev),
+ 0);
}

static inline void security_inode_post_mknod (struct inode *dir,
struct dentry *dentry,
int mode, dev_t dev)
{
- security_ops->inode_post_mknod (dir, dentry, mode, dev);
+ COND_SECURITY(inode_post_mknod (dir, dentry, mode, dev),
+ SE_NOP);
}

static inline int security_inode_rename (struct inode *old_dir,
struct dentry *old_dentry,
struct inode *new_dir,
struct dentry *new_dentry)
{
- return security_ops->inode_rename (old_dir, old_dentry,
- new_dir, new_dentry);
+ return COND_SECURITY(inode_rename (old_dir, old_dentry,
+ new_dir, new_dentry),
+ 0);
}

static inline void security_inode_post_rename (struct inode *old_dir,
struct dentry *old_dentry,
struct inode *new_dir,
struct dentry *new_dentry)
{
- security_ops->inode_post_rename (old_dir, old_dentry,
- new_dir, new_dentry);
+ COND_SECURITY(inode_post_rename (old_dir, old_dentry,
+ new_dir, new_dentry),
+ SE_NOP);
}

static inline int security_inode_readlink (struct dentry *dentry)
{
- return security_ops->inode_readlink (dentry);
+ return COND_SECURITY(inode_readlink (dentry),
+ 0);
}

static inline int security_inode_follow_link (struct dentry *dentry,
struct nameidata *nd)
{
- return security_ops->inode_follow_link (dentry, nd);
+ return COND_SECURITY(inode_follow_link (dentry, nd),
+ 0);
}

static inline int security_inode_permission (struct inode *inode, int mask,
struct nameidata *nd)
{
- return security_ops->inode_permission (inode, mask, nd);
+ return COND_SECURITY(inode_permission (inode, mask, nd),
+ 0);
}

static inline int security_inode_setattr (struct dentry *dentry,
struct iattr *attr)
{
- return security_ops->inode_setattr (dentry, attr);
+ return COND_SECURITY(inode_setattr (dentry, attr),
+ 0);
}

static inline int security_inode_getattr (struct vfsmount *mnt,
struct dentry *dentry)
{
- return security_ops->inode_getattr (mnt, dentry);
+ return COND_SECURITY(inode_getattr (mnt, dentry),
+ 0);
}

static inline void security_inode_delete (struct inode *inode)
{
- security_ops->inode_delete (inode);
+ COND_SECURITY(inode_delete (inode),
+ SE_NOP);
}

static inline int security_inode_setxattr (struct dentry *dentry, char *name,
void *value, size_t size, int flags)
{
- return security_ops->inode_setxattr (dentry, name, value, size, flags);
+ return COND_SECURITY(inode_setxattr (dentry, name, value, size, flags),
+ cap_inode_setxattr (dentry, name, value, size, flags));
}

static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
void *value, size_t size, int flags)
{
- security_ops->inode_post_setxattr (dentry, name, value, size, flags);
+ COND_SECURITY(inode_post_setxattr (dentry, name, value, size, flags),
+ SE_NOP);
}

static inline int security_inode_getxattr (struct dentry *dentry, char *name)
{
- return security_ops->inode_getxattr (dentry, name);
+ return COND_SECURITY(inode_getxattr (dentry, name),
+ 0);
}

static inline int security_inode_listxattr (struct dentry *dentry)
{
- return security_ops->inode_listxattr (dentry);
+ return COND_SECURITY(inode_listxattr (dentry),
+ 0);
}

static inline int security_inode_removexattr (struct dentry *dentry, char *name)
{
- return security_ops->inode_removexattr (dentry, name);
+ return COND_SECURITY(inode_removexattr (dentry, name),
+ cap_inode_removexattr (dentry, name));
}

static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size)
{
- return security_ops->inode_getsecurity(inode, name, buffer, size);
+ return COND_SECURITY(inode_getsecurity(inode, name, buffer, size),
+ -EOPNOTSUPP);
}

static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
{
- return security_ops->inode_setsecurity(inode, name, value, size, flags);
+ return COND_SECURITY(inode_setsecurity(inode, name, value, size, flags),
+ -EOPNOTSUPP);
}

static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
{
- return security_ops->inode_listsecurity(inode, buffer, buffer_size);
+ return COND_SECURITY(inode_listsecurity(inode, buffer, buffer_size),
+ 0);
}

static inline int security_file_permission (struct file *file, int mask)
{
- return security_ops->file_permission (file, mask);
+ return COND_SECURITY(file_permission (file, mask),
+ 0);
}

static inline int security_file_alloc (struct file *file)
{
- return security_ops->file_alloc_security (file);
+ return COND_SECURITY(file_alloc_security (file),
+ 0);
}

static inline void security_file_free (struct file *file)
{
- security_ops->file_free_security (file);
+ COND_SECURITY(file_free_security (file),
+ SE_NOP);
}

static inline int security_file_ioctl (struct file *file, unsigned int cmd,
unsigned long arg)
{
- return security_ops->file_ioctl (file, cmd, arg);
+ return COND_SECURITY(file_ioctl (file, cmd, arg),
+ 0);
}

static inline int security_file_mmap (struct file *file, unsigned long prot,
unsigned long flags)
{
- return security_ops->file_mmap (file, prot, flags);
+ return COND_SECURITY(file_mmap (file, prot, flags),
+ 0);
}

static inline int security_file_mprotect (struct vm_area_struct *vma,
unsigned long prot)
{
- return security_ops->file_mprotect (vma, prot);
+ return COND_SECURITY(file_mprotect (vma, prot),
+ 0);
}

static inline int security_file_lock (struct file *file, unsigned int cmd)
{
- return security_ops->file_lock (file, cmd);
+ return COND_SECURITY(file_lock (file, cmd),
+ 0);
}

static inline int security_file_fcntl (struct file *file, unsigned int cmd,
unsigned long arg)
{
- return security_ops->file_fcntl (file, cmd, arg);
+ return COND_SECURITY(file_fcntl (file, cmd, arg),
+ 0);
}

static inline int security_file_set_fowner (struct file *file)
{
- return security_ops->file_set_fowner (file);
+ return COND_SECURITY(file_set_fowner (file),
+ 0);
}

static inline int security_file_send_sigiotask (struct task_struct *tsk,
struct fown_struct *fown,
int sig)
{
- return security_ops->file_send_sigiotask (tsk, fown, sig);
+ return COND_SECURITY(file_send_sigiotask (tsk, fown, sig),
+ 0);
}

static inline int security_file_receive (struct file *file)
{
- return security_ops->file_receive (file);
+ return COND_SECURITY(file_receive (file),
+ 0);
}

static inline int security_task_create (unsigned long clone_flags)
{
- return security_ops->task_create (clone_flags);
+ return COND_SECURITY(task_create (clone_flags),
+ 0);
}

static inline int security_task_alloc (struct task_struct *p)
{
- return security_ops->task_alloc_security (p);
+ return COND_SECURITY(task_alloc_security (p),
+ 0);
}

static inline void security_task_free (struct task_struct *p)
{
- security_ops->task_free_security (p);
+ COND_SECURITY(task_free_security (p),
+ SE_NOP);
}

static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
int flags)
{
- return security_ops->task_setuid (id0, id1, id2, flags);
+ return COND_SECURITY(task_setuid (id0, id1, id2, flags),
+ 0);
}

static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
uid_t old_suid, int flags)
{
- return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags);
+ return COND_SECURITY(task_post_setuid (old_ruid, old_euid, old_suid, flags),
+ cap_task_post_setuid (old_ruid, old_euid, old_suid, flags));
}

static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
int flags)
{
- return security_ops->task_setgid (id0, id1, id2, flags);
+ return COND_SECURITY(task_setgid (id0, id1, id2, flags),
+ 0);
}

static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
{
- return security_ops->task_setpgid (p, pgid);
+ return COND_SECURITY(task_setpgid (p, pgid),
+ 0);
}

static inline int security_task_getpgid (struct task_struct *p)
{
- return security_ops->task_getpgid (p);
+ return COND_SECURITY(task_getpgid (p),
+ 0);
}

static inline int security_task_getsid (struct task_struct *p)
{
- return security_ops->task_getsid (p);
+ return COND_SECURITY(task_getsid (p),
+ 0);
}

static inline int security_task_setgroups (struct group_info *group_info)
{
- return security_ops->task_setgroups (group_info);
+ return COND_SECURITY(task_setgroups (group_info),
+ 0);
}

static inline int security_task_setnice (struct task_struct *p, int nice)
{
- return security_ops->task_setnice (p, nice);
+ return COND_SECURITY(task_setnice (p, nice),
+ 0);
}

static inline int security_task_setrlimit (unsigned int resource,
struct rlimit *new_rlim)
{
- return security_ops->task_setrlimit (resource, new_rlim);
+ return COND_SECURITY(task_setrlimit (resource, new_rlim),
+ 0);
}

static inline int security_task_setscheduler (struct task_struct *p,
int policy,
struct sched_param *lp)
{
- return security_ops->task_setscheduler (p, policy, lp);
+ return COND_SECURITY(task_setscheduler (p, policy, lp),
+ 0);
}

static inline int security_task_getscheduler (struct task_struct *p)
{
- return security_ops->task_getscheduler (p);
+ return COND_SECURITY(task_getscheduler (p),
+ 0);
}

static inline int security_task_kill (struct task_struct *p,
struct siginfo *info, int sig)
{
- return security_ops->task_kill (p, info, sig);
+ return COND_SECURITY(task_kill (p, info, sig),
+ 0);
}

static inline int security_task_wait (struct task_struct *p)
{
- return security_ops->task_wait (p);
+ return COND_SECURITY(task_wait (p),
+ 0);
}

static inline int security_task_prctl (int option, unsigned long arg2,
unsigned long arg3,
unsigned long arg4,
unsigned long arg5)
{
- return security_ops->task_prctl (option, arg2, arg3, arg4, arg5);
+ return COND_SECURITY(task_prctl (option, arg2, arg3, arg4, arg5),
+ 0);
}

static inline void security_task_reparent_to_init (struct task_struct *p)
{
- security_ops->task_reparent_to_init (p);
+ COND_SECURITY(task_reparent_to_init (p),
+ cap_task_reparent_to_init (p));
}

static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
{
- security_ops->task_to_inode(p, inode);
+ COND_SECURITY(task_to_inode(p, inode),
+ SE_NOP);
}

static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
short flag)
{
- return security_ops->ipc_permission (ipcp, flag);
+ return COND_SECURITY(ipc_permission (ipcp, flag),
+ 0);
}

static inline int security_msg_msg_alloc (struct msg_msg * msg)
{
- return security_ops->msg_msg_alloc_security (msg);
+ return COND_SECURITY(msg_msg_alloc_security (msg),
+ 0);
}

static inline void security_msg_msg_free (struct msg_msg * msg)
{
- security_ops->msg_msg_free_security(msg);
+ COND_SECURITY(msg_msg_free_security(msg),
+ SE_NOP);
}

static inline int security_msg_queue_alloc (struct msg_queue *msq)
{
- return security_ops->msg_queue_alloc_security (msq);
+ return COND_SECURITY(msg_queue_alloc_security (msq),
+ 0);
}

static inline void security_msg_queue_free (struct msg_queue *msq)
{
- security_ops->msg_queue_free_security (msq);
+ COND_SECURITY(msg_queue_free_security (msq),
+ SE_NOP);
}

static inline int security_msg_queue_associate (struct msg_queue * msq,
int msqflg)
{
- return security_ops->msg_queue_associate (msq, msqflg);
+ return COND_SECURITY(msg_queue_associate (msq, msqflg),
+ 0);
}

static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
{
- return security_ops->msg_queue_msgctl (msq, cmd);
+ return COND_SECURITY(msg_queue_msgctl (msq, cmd),
+ 0);
}

static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
struct msg_msg * msg, int msqflg)
{
- return security_ops->msg_queue_msgsnd (msq, msg, msqflg);
+ return COND_SECURITY(msg_queue_msgsnd (msq, msg, msqflg),
+ 0);
}

static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
struct msg_msg * msg,
struct task_struct * target,
long type, int mode)
{
- return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode);
+ return COND_SECURITY(msg_queue_msgrcv (msq, msg, target, type, mode),
+ 0);
}

static inline int security_shm_alloc (struct shmid_kernel *shp)
{
- return security_ops->shm_alloc_security (shp);
+ return COND_SECURITY(shm_alloc_security (shp),
+ 0);
}

static inline void security_shm_free (struct shmid_kernel *shp)
{
- security_ops->shm_free_security (shp);
+ COND_SECURITY(shm_free_security (shp),
+ SE_NOP);
}

static inline int security_shm_associate (struct shmid_kernel * shp,
int shmflg)
{
- return security_ops->shm_associate(shp, shmflg);
+ return COND_SECURITY(shm_associate (shp, shmflg),
+ 0);
}

static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
{
- return security_ops->shm_shmctl (shp, cmd);
+ return COND_SECURITY(shm_shmctl (shp, cmd),
+ 0);
}

static inline int security_shm_shmat (struct shmid_kernel * shp,
char __user *shmaddr, int shmflg)
{
- return security_ops->shm_shmat(shp, shmaddr, shmflg);
+ return COND_SECURITY(shm_shmat (shp, shmaddr, shmflg),
+ 0);
}

static inline int security_sem_alloc (struct sem_array *sma)
{
- return security_ops->sem_alloc_security (sma);
+ return COND_SECURITY(sem_alloc_security (sma),
+ 0);
}

static inline void security_sem_free (struct sem_array *sma)
{
- security_ops->sem_free_security (sma);
+ COND_SECURITY(sem_free_security (sma),
+ SE_NOP);
}

static inline int security_sem_associate (struct sem_array * sma, int semflg)
{
- return security_ops->sem_associate (sma, semflg);
+ return COND_SECURITY(sem_associate (sma, semflg),
+ 0);
}

static inline int security_sem_semctl (struct sem_array * sma, int cmd)
{
- return security_ops->sem_semctl(sma, cmd);
+ return COND_SECURITY(sem_semctl (sma, cmd),
+ 0);
}

static inline int security_sem_semop (struct sem_array * sma,
struct sembuf * sops, unsigned nsops,
int alter)
{
- return security_ops->sem_semop(sma, sops, nsops, alter);
+ return COND_SECURITY(sem_semop (sma, sops, nsops, alter),
+ 0);
}

static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
{
- security_ops->d_instantiate (dentry, inode);
+ COND_SECURITY(d_instantiate (dentry, inode),
+ SE_NOP);
}

static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
{
- return security_ops->getprocattr(p, name, value, size);
+ return COND_SECURITY(getprocattr (p, name, value, size),
+ -EINVAL);
}

static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
{
- return security_ops->setprocattr(p, name, value, size);
+ return COND_SECURITY(setprocattr (p, name, value, size),
+ -EINVAL);
}

static inline int security_netlink_send(struct sock *sk, struct sk_buff * skb)
{
- return security_ops->netlink_send(sk, skb);
+ return COND_SECURITY(netlink_send (sk, skb),
+ cap_netlink_send (sk, skb));
}

static inline int security_netlink_recv(struct sk_buff * skb)
{
- return security_ops->netlink_recv(skb);
-}
-
-/* prototypes */
-extern int security_init (void);
-extern int register_security (struct security_operations *ops);
-extern int unregister_security (struct security_operations *ops);
-extern int mod_reg_security (const char *name, struct security_operations *ops);
-extern int mod_unreg_security (const char *name, struct security_operations *ops);
-
-
-#else /* CONFIG_SECURITY */
-
-/*
- * This is the default capabilities functionality. Most of these functions
- * are just stubbed out, but a few must call the proper capable code.
- */
-
-static inline int security_init(void)
-{
- return 0;
-}
-
-static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
-{
- return cap_ptrace (parent, child);
-}
-
-static inline int security_capget (struct task_struct *target,
- kernel_cap_t *effective,
- kernel_cap_t *inheritable,
- kernel_cap_t *permitted)
-{
- return cap_capget (target, effective, inheritable, permitted);
-}
-
-static inline int security_capset_check (struct task_struct *target,
- kernel_cap_t *effective,
- kernel_cap_t *inheritable,
- kernel_cap_t *permitted)
-{
- return cap_capset_check (target, effective, inheritable, permitted);
-}
-
-static inline void security_capset_set (struct task_struct *target,
- kernel_cap_t *effective,
- kernel_cap_t *inheritable,
- kernel_cap_t *permitted)
-{
- cap_capset_set (target, effective, inheritable, permitted);
-}
-
-static inline int security_acct (struct file *file)
-{
- return 0;
-}
-
-static inline int security_sysctl(struct ctl_table *table, int op)
-{
- return 0;
-}
-
-static inline int security_quotactl (int cmds, int type, int id,
- struct super_block * sb)
-{
- return 0;
-}
-
-static inline int security_quota_on (struct dentry * dentry)
-{
- return 0;
-}
-
-static inline int security_syslog(int type)
-{
- return cap_syslog(type);
-}
-
-static inline int security_settime(struct timespec *ts, struct timezone *tz)
-{
- return cap_settime(ts, tz);
-}
-
-static inline int security_vm_enough_memory(long pages)
-{
- return cap_vm_enough_memory(pages);
-}
-
-static inline int security_bprm_alloc (struct linux_binprm *bprm)
-{
- return 0;
-}
-
-static inline void security_bprm_free (struct linux_binprm *bprm)
-{ }
-
-static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
-{
- cap_bprm_apply_creds (bprm, unsafe);
-}
-
-static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
-{
- return;
-}
-
-static inline int security_bprm_set (struct linux_binprm *bprm)
-{
- return cap_bprm_set_security (bprm);
-}
-
-static inline int security_bprm_check (struct linux_binprm *bprm)
-{
- return 0;
-}
-
-static inline int security_bprm_secureexec (struct linux_binprm *bprm)
-{
- return cap_bprm_secureexec(bprm);
+ return COND_SECURITY(netlink_recv (skb),
+ cap_netlink_recv (skb));
}

-static inline int security_sb_alloc (struct super_block *sb)
+#ifdef CONFIG_SECURITY_NETWORK
+static inline int security_unix_stream_connect(struct socket * sock,
+ struct socket * other,
+ struct sock * newsk)
{
- return 0;
+ return COND_SECURITY(unix_stream_connect(sock, other, newsk),
+ 0);
}

-static inline void security_sb_free (struct super_block *sb)
-{ }

-static inline int security_sb_copy_data (struct file_system_type *type,
- void *orig, void *copy)
+static inline int security_unix_may_send(struct socket * sock,
+ struct socket * other)
{
- return 0;
+ return COND_SECURITY(unix_may_send(sock, other),
+ 0);
}

-static inline int security_sb_kern_mount (struct super_block *sb, void *data)
+static inline int security_socket_create (int family, int type,
+ int protocol, int kern)
{
- return 0;
+ return COND_SECURITY(socket_create(family, type, protocol, kern),
+ 0);
}

-static inline int security_sb_statfs (struct super_block *sb)
+static inline void security_socket_post_create(struct socket * sock,
+ int family,
+ int type,
+ int protocol, int kern)
{
- return 0;
+ COND_SECURITY(socket_post_create(sock, family, type, protocol, kern),
+ SE_NOP);
}

-static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
- char *type, unsigned long flags,
- void *data)
+static inline int security_socket_bind(struct socket * sock,
+ struct sockaddr * address,
+ int addrlen)
{
- return 0;
+ return COND_SECURITY(socket_bind(sock, address, addrlen),
+ 0);
}

-static inline int security_sb_check_sb (struct vfsmount *mnt,
- struct nameidata *nd)
+static inline int security_socket_connect(struct socket * sock,
+ struct sockaddr * address,
+ int addrlen)
{
- return 0;
+ return COND_SECURITY(socket_connect(sock, address, addrlen),
+ 0);
}

-static inline int security_sb_umount (struct vfsmount *mnt, int flags)
+static inline int security_socket_listen(struct socket * sock, int backlog)
{
- return 0;
+ return COND_SECURITY(socket_listen(sock, backlog),
+ 0);
}

-static inline void security_sb_umount_close (struct vfsmount *mnt)
-{ }
-
-static inline void security_sb_umount_busy (struct vfsmount *mnt)
-{ }
-
-static inline void security_sb_post_remount (struct vfsmount *mnt,
- unsigned long flags, void *data)
-{ }
-
-static inline void security_sb_post_mountroot (void)
-{ }
-
-static inline void security_sb_post_addmount (struct vfsmount *mnt,
- struct nameidata *mountpoint_nd)
-{ }
-
-static inline int security_sb_pivotroot (struct nameidata *old_nd,
- struct nameidata *new_nd)
+static inline int security_socket_accept(struct socket * sock,
+ struct socket * newsock)
{
- return 0;
+ return COND_SECURITY(socket_accept(sock, newsock),
+ 0);
}

-static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
- struct nameidata *new_nd)
-{ }
-
-static inline int security_inode_alloc (struct inode *inode)
+static inline void security_socket_post_accept(struct socket * sock,
+ struct socket * newsock)
{
- return 0;
+ COND_SECURITY(socket_post_accept(sock, newsock),
+ SE_NOP);
}

-static inline void security_inode_free (struct inode *inode)
-{ }
-
-static inline int security_inode_create (struct inode *dir,
- struct dentry *dentry,
- int mode)
+static inline int security_socket_sendmsg(struct socket * sock,
+ struct msghdr * msg, int size)
{
- return 0;
+ return COND_SECURITY(socket_sendmsg(sock, msg, size),
+ 0);
}

-static inline void security_inode_post_create (struct inode *dir,
- struct dentry *dentry,
- int mode)
-{ }
-
-static inline int security_inode_link (struct dentry *old_dentry,
- struct inode *dir,
- struct dentry *new_dentry)
+static inline int security_socket_recvmsg(struct socket * sock,
+ struct msghdr * msg, int size,
+ int flags)
{
- return 0;
+ return COND_SECURITY(socket_recvmsg(sock, msg, size, flags),
+ 0);
}

-static inline void security_inode_post_link (struct dentry *old_dentry,
- struct inode *dir,
- struct dentry *new_dentry)
-{ }
-
-static inline int security_inode_unlink (struct inode *dir,
- struct dentry *dentry)
+static inline int security_socket_getsockname(struct socket * sock)
{
- return 0;
+ return COND_SECURITY(socket_getsockname(sock),
+ 0);
}

-static inline int security_inode_symlink (struct inode *dir,
- struct dentry *dentry,
- const char *old_name)
+static inline int security_socket_getpeername(struct socket * sock)
{
- return 0;
+ return COND_SECURITY(socket_getpeername(sock),
+ 0);
}

-static inline void security_inode_post_symlink (struct inode *dir,
- struct dentry *dentry,
- const char *old_name)
-{ }
-
-static inline int security_inode_mkdir (struct inode *dir,
- struct dentry *dentry,
- int mode)
+static inline int security_socket_getsockopt(struct socket * sock,
+ int level, int optname)
{
- return 0;
+ return COND_SECURITY(socket_getsockopt(sock, level, optname),
+ 0);
}

-static inline void security_inode_post_mkdir (struct inode *dir,
- struct dentry *dentry,
- int mode)
-{ }
-
-static inline int security_inode_rmdir (struct inode *dir,
- struct dentry *dentry)
+static inline int security_socket_setsockopt(struct socket * sock,
+ int level, int optname)
{
- return 0;
+ return COND_SECURITY(socket_setsockopt(sock, level, optname),
+ 0);
}

-static inline int security_inode_mknod (struct inode *dir,
- struct dentry *dentry,
- int mode, dev_t dev)
+static inline int security_socket_shutdown(struct socket * sock, int how)
{
- return 0;
+ return COND_SECURITY(socket_shutdown(sock, how),
+ 0);
}

-static inline void security_inode_post_mknod (struct inode *dir,
- struct dentry *dentry,
- int mode, dev_t dev)
-{ }
-
-static inline int security_inode_rename (struct inode *old_dir,
- struct dentry *old_dentry,
- struct inode *new_dir,
- struct dentry *new_dentry)
+static inline int security_sock_rcv_skb (struct sock * sk,
+ struct sk_buff * skb)
{
- return 0;
+ return COND_SECURITY(socket_sock_rcv_skb(sk, skb),
+ 0);
}

-static inline void security_inode_post_rename (struct inode *old_dir,
- struct dentry *old_dentry,
- struct inode *new_dir,
- struct dentry *new_dentry)
-{ }
-
-static inline int security_inode_readlink (struct dentry *dentry)
+static inline int security_socket_getpeersec(struct socket *sock, char __user *optval,
+ int __user *optlen, unsigned len)
{
- return 0;
+ return COND_SECURITY(socket_getpeersec(sock, optval, optlen, len),
+ -ENOPROTOOPT);
}

-static inline int security_inode_follow_link (struct dentry *dentry,
- struct nameidata *nd)
+static inline int security_sk_alloc(struct sock *sk, int family, int priority)
{
- return 0;
-}
-
-static inline int security_inode_permission (struct inode *inode, int mask,
- struct nameidata *nd)
-{
- return 0;
-}
-
-static inline int security_inode_setattr (struct dentry *dentry,
- struct iattr *attr)
-{
- return 0;
-}
-
-static inline int security_inode_getattr (struct vfsmount *mnt,
- struct dentry *dentry)
-{
- return 0;
-}
-
-static inline void security_inode_delete (struct inode *inode)
-{ }
-
-static inline int security_inode_setxattr (struct dentry *dentry, char *name,
- void *value, size_t size, int flags)
-{
- return cap_inode_setxattr(dentry, name, value, size, flags);
-}
-
-static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
- void *value, size_t size, int flags)
-{ }
-
-static inline int security_inode_getxattr (struct dentry *dentry, char *name)
-{
- return 0;
-}
-
-static inline int security_inode_listxattr (struct dentry *dentry)
-{
- return 0;
-}
-
-static inline int security_inode_removexattr (struct dentry *dentry, char *name)
-{
- return cap_inode_removexattr(dentry, name);
-}
-
-static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size)
-{
- return -EOPNOTSUPP;
-}
-
-static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
-{
- return -EOPNOTSUPP;
-}
-
-static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
-{
- return 0;
-}
-
-static inline int security_file_permission (struct file *file, int mask)
-{
- return 0;
-}
-
-static inline int security_file_alloc (struct file *file)
-{
- return 0;
-}
-
-static inline void security_file_free (struct file *file)
-{ }
-
-static inline int security_file_ioctl (struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- return 0;
-}
-
-static inline int security_file_mmap (struct file *file, unsigned long prot,
- unsigned long flags)
-{
- return 0;
-}
-
-static inline int security_file_mprotect (struct vm_area_struct *vma,
- unsigned long prot)
-{
- return 0;
-}
-
-static inline int security_file_lock (struct file *file, unsigned int cmd)
-{
- return 0;
-}
-
-static inline int security_file_fcntl (struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- return 0;
-}
-
-static inline int security_file_set_fowner (struct file *file)
-{
- return 0;
-}
-
-static inline int security_file_send_sigiotask (struct task_struct *tsk,
- struct fown_struct *fown,
- int sig)
-{
- return 0;
-}
-
-static inline int security_file_receive (struct file *file)
-{
- return 0;
-}
-
-static inline int security_task_create (unsigned long clone_flags)
-{
- return 0;
-}
-
-static inline int security_task_alloc (struct task_struct *p)
-{
- return 0;
-}
-
-static inline void security_task_free (struct task_struct *p)
-{ }
-
-static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
- int flags)
-{
- return 0;
-}
-
-static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
- uid_t old_suid, int flags)
-{
- return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
-}
-
-static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
- int flags)
-{
- return 0;
-}
-
-static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
-{
- return 0;
-}
-
-static inline int security_task_getpgid (struct task_struct *p)
-{
- return 0;
-}
-
-static inline int security_task_getsid (struct task_struct *p)
-{
- return 0;
-}
-
-static inline int security_task_setgroups (struct group_info *group_info)
-{
- return 0;
-}
-
-static inline int security_task_setnice (struct task_struct *p, int nice)
-{
- return 0;
-}
-
-static inline int security_task_setrlimit (unsigned int resource,
- struct rlimit *new_rlim)
-{
- return 0;
-}
-
-static inline int security_task_setscheduler (struct task_struct *p,
- int policy,
- struct sched_param *lp)
-{
- return 0;
-}
-
-static inline int security_task_getscheduler (struct task_struct *p)
-{
- return 0;
-}
-
-static inline int security_task_kill (struct task_struct *p,
- struct siginfo *info, int sig)
-{
- return 0;
-}
-
-static inline int security_task_wait (struct task_struct *p)
-{
- return 0;
-}
-
-static inline int security_task_prctl (int option, unsigned long arg2,
- unsigned long arg3,
- unsigned long arg4,
- unsigned long arg5)
-{
- return 0;
-}
-
-static inline void security_task_reparent_to_init (struct task_struct *p)
-{
- cap_task_reparent_to_init (p);
-}
-
-static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
-{ }
-
-static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
- short flag)
-{
- return 0;
-}
-
-static inline int security_msg_msg_alloc (struct msg_msg * msg)
-{
- return 0;
-}
-
-static inline void security_msg_msg_free (struct msg_msg * msg)
-{ }
-
-static inline int security_msg_queue_alloc (struct msg_queue *msq)
-{
- return 0;
-}
-
-static inline void security_msg_queue_free (struct msg_queue *msq)
-{ }
-
-static inline int security_msg_queue_associate (struct msg_queue * msq,
- int msqflg)
-{
- return 0;
-}
-
-static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
-{
- return 0;
-}
-
-static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
- struct msg_msg * msg, int msqflg)
-{
- return 0;
-}
-
-static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
- struct msg_msg * msg,
- struct task_struct * target,
- long type, int mode)
-{
- return 0;
-}
-
-static inline int security_shm_alloc (struct shmid_kernel *shp)
-{
- return 0;
-}
-
-static inline void security_shm_free (struct shmid_kernel *shp)
-{ }
-
-static inline int security_shm_associate (struct shmid_kernel * shp,
- int shmflg)
-{
- return 0;
-}
-
-static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
-{
- return 0;
-}
-
-static inline int security_shm_shmat (struct shmid_kernel * shp,
- char __user *shmaddr, int shmflg)
-{
- return 0;
-}
-
-static inline int security_sem_alloc (struct sem_array *sma)
-{
- return 0;
-}
-
-static inline void security_sem_free (struct sem_array *sma)
-{ }
-
-static inline int security_sem_associate (struct sem_array * sma, int semflg)
-{
- return 0;
-}
-
-static inline int security_sem_semctl (struct sem_array * sma, int cmd)
-{
- return 0;
-}
-
-static inline int security_sem_semop (struct sem_array * sma,
- struct sembuf * sops, unsigned nsops,
- int alter)
-{
- return 0;
-}
-
-static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
-{ }
-
-static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
-{
- return -EINVAL;
-}
-
-static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
-{
- return -EINVAL;
-}
-
-static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
-{
- return cap_netlink_send (sk, skb);
-}
-
-static inline int security_netlink_recv (struct sk_buff *skb)
-{
- return cap_netlink_recv (skb);
-}
-
-#endif /* CONFIG_SECURITY */
-
-#ifdef CONFIG_SECURITY_NETWORK
-static inline int security_unix_stream_connect(struct socket * sock,
- struct socket * other,
- struct sock * newsk)
-{
- return security_ops->unix_stream_connect(sock, other, newsk);
-}
-
-
-static inline int security_unix_may_send(struct socket * sock,
- struct socket * other)
-{
- return security_ops->unix_may_send(sock, other);
-}
-
-static inline int security_socket_create (int family, int type,
- int protocol, int kern)
-{
- return security_ops->socket_create(family, type, protocol, kern);
-}
-
-static inline void security_socket_post_create(struct socket * sock,
- int family,
- int type,
- int protocol, int kern)
-{
- security_ops->socket_post_create(sock, family, type,
- protocol, kern);
-}
-
-static inline int security_socket_bind(struct socket * sock,
- struct sockaddr * address,
- int addrlen)
-{
- return security_ops->socket_bind(sock, address, addrlen);
-}
-
-static inline int security_socket_connect(struct socket * sock,
- struct sockaddr * address,
- int addrlen)
-{
- return security_ops->socket_connect(sock, address, addrlen);
-}
-
-static inline int security_socket_listen(struct socket * sock, int backlog)
-{
- return security_ops->socket_listen(sock, backlog);
-}
-
-static inline int security_socket_accept(struct socket * sock,
- struct socket * newsock)
-{
- return security_ops->socket_accept(sock, newsock);
-}
-
-static inline void security_socket_post_accept(struct socket * sock,
- struct socket * newsock)
-{
- security_ops->socket_post_accept(sock, newsock);
-}
-
-static inline int security_socket_sendmsg(struct socket * sock,
- struct msghdr * msg, int size)
-{
- return security_ops->socket_sendmsg(sock, msg, size);
-}
-
-static inline int security_socket_recvmsg(struct socket * sock,
- struct msghdr * msg, int size,
- int flags)
-{
- return security_ops->socket_recvmsg(sock, msg, size, flags);
-}
-
-static inline int security_socket_getsockname(struct socket * sock)
-{
- return security_ops->socket_getsockname(sock);
-}
-
-static inline int security_socket_getpeername(struct socket * sock)
-{
- return security_ops->socket_getpeername(sock);
-}
-
-static inline int security_socket_getsockopt(struct socket * sock,
- int level, int optname)
-{
- return security_ops->socket_getsockopt(sock, level, optname);
-}
-
-static inline int security_socket_setsockopt(struct socket * sock,
- int level, int optname)
-{
- return security_ops->socket_setsockopt(sock, level, optname);
-}
-
-static inline int security_socket_shutdown(struct socket * sock, int how)
-{
- return security_ops->socket_shutdown(sock, how);
-}
-
-static inline int security_sock_rcv_skb (struct sock * sk,
- struct sk_buff * skb)
-{
- return security_ops->socket_sock_rcv_skb (sk, skb);
-}
-
-static inline int security_socket_getpeersec(struct socket *sock, char __user *optval,
- int __user *optlen, unsigned len)
-{
- return security_ops->socket_getpeersec(sock, optval, optlen, len);
-}
-
-static inline int security_sk_alloc(struct sock *sk, int family, int priority)
-{
- return security_ops->sk_alloc_security(sk, family, priority);
-}
-
-static inline void security_sk_free(struct sock *sk)
-{
- return security_ops->sk_free_security(sk);
-}
-#else /* CONFIG_SECURITY_NETWORK */
-static inline int security_unix_stream_connect(struct socket * sock,
- struct socket * other,
- struct sock * newsk)
-{
- return 0;
-}
-
-static inline int security_unix_may_send(struct socket * sock,
- struct socket * other)
-{
- return 0;
-}
-
-static inline int security_socket_create (int family, int type,
- int protocol, int kern)
-{
- return 0;
-}
-
-static inline void security_socket_post_create(struct socket * sock,
- int family,
- int type,
- int protocol, int kern)
-{
-}
-
-static inline int security_socket_bind(struct socket * sock,
- struct sockaddr * address,
- int addrlen)
-{
- return 0;
-}
-
-static inline int security_socket_connect(struct socket * sock,
- struct sockaddr * address,
- int addrlen)
-{
- return 0;
-}
-
-static inline int security_socket_listen(struct socket * sock, int backlog)
-{
- return 0;
-}
-
-static inline int security_socket_accept(struct socket * sock,
- struct socket * newsock)
-{
- return 0;
-}
-
-static inline void security_socket_post_accept(struct socket * sock,
- struct socket * newsock)
-{
-}
-
-static inline int security_socket_sendmsg(struct socket * sock,
- struct msghdr * msg, int size)
-{
- return 0;
-}
-
-static inline int security_socket_recvmsg(struct socket * sock,
- struct msghdr * msg, int size,
- int flags)
-{
- return 0;
-}
-
-static inline int security_socket_getsockname(struct socket * sock)
-{
- return 0;
-}
-
-static inline int security_socket_getpeername(struct socket * sock)
-{
- return 0;
-}
-
-static inline int security_socket_getsockopt(struct socket * sock,
- int level, int optname)
-{
- return 0;
-}
-
-static inline int security_socket_setsockopt(struct socket * sock,
- int level, int optname)
-{
- return 0;
-}
-
-static inline int security_socket_shutdown(struct socket * sock, int how)
-{
- return 0;
-}
-static inline int security_sock_rcv_skb (struct sock * sk,
- struct sk_buff * skb)
-{
- return 0;
-}
-
-static inline int security_socket_getpeersec(struct socket *sock, char __user *optval,
- int __user *optlen, unsigned len)
-{
- return -ENOPROTOOPT;
-}
-
-static inline int security_sk_alloc(struct sock *sk, int family, int priority)
-{
- return 0;
+ return COND_SECURITY(sk_alloc_security(sk, family, priority),
+ 0);
}

static inline void security_sk_free(struct sock *sk)
{
+ return COND_SECURITY(sk_free_security(sk),
+ 0);
}
#endif /* CONFIG_SECURITY_NETWORK */

#endif /* ! __LINUX_SECURITY_H */
--
Kurt Garloff, Director SUSE Labs, Novell Inc.


Attachments:
(No filename) (49.45 kB)
(No filename) (189.00 B)
Download all attachments

2005-02-13 21:19:46

by Kurt Garloff

[permalink] [raw]
Subject: [PATCH] 4/5: LSM hooks rework

From: Kurt Garloff <[email protected]>
Subject: Consider the capability case the likely one
References: 40217, 39439

The case that security_ops points to the default capability_
security_ops is the fast path and arguably the more likely one
on most systems. So mark it likely to tell the compiler to
optimize accordingly and increase the chances of having this
predicted correctly by the CPU.

This is patch 4/5 of the LSM overhaul.

security.h | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)

Signed-off-by: Kurt Garloff <[email protected]>

Index: linux-2.6.10/include/linux/security.h
===================================================================
--- linux-2.6.10.orig/include/linux/security.h
+++ linux-2.6.10/include/linux/security.h
@@ -1253,9 +1253,9 @@ extern int mod_reg_security (const char
extern int mod_unreg_security (const char *name, struct security_operations *ops);

/* Condition for invocation of non-default security_op */
#define COND_SECURITY(seop, def) \
- (security_ops == &capability_security_ops)? def: security_ops->seop
+ (likely(security_ops == &capability_security_ops))? def: security_ops->seop

#else /* CONFIG_SECURITY */
static inline int security_init(void)
{
--
Kurt Garloff, Director SUSE Labs, Novell Inc.


Attachments:
(No filename) (1.24 kB)
(No filename) (189.00 B)
Download all attachments

2005-02-13 21:19:46

by Kurt Garloff

[permalink] [raw]
Subject: [PATCH] 5/5: LSM hooks rework

From: Kurt Garloff <[email protected]>
Subject: Test security_enabled var rather than security_ops pointer
References: 40217, 39439

Rather than doing a pointer comparison, test an integer var
for being null. Should be slightly faster.
I consider this patch as optional.

Note that it does not introduce a (new) race, as we still set
the security_ops pointer to the capability_security_ops. So no
wmb() is needed for the module unload case.

Sidenote: A wmb() in the module load and unload cases might
actually be useful to ensure that the other CPUs start using the
new LSM pointer ASAP. It's still racy, but that's by design of
LSM. Introducing locks would hurt performance tremendously.
One could do RCU ... but that's not for this patchset.

This is patch 5/5 of the LSM overhaul.

include/linux/security.h | 7 ++++---
security/security.c | 7 +++++++
2 files changed, 11 insertions(+), 3 deletions(-)

Signed-off-by: Kurt Garloff <[email protected]>

Index: linux-2.6.10/include/linux/security.h
===================================================================
--- linux-2.6.10.orig/include/linux/security.h
+++ linux-2.6.10/include/linux/security.h
@@ -1241,10 +1241,10 @@ struct security_operations {
};

/* global variables */
extern struct security_operations *security_ops;
-/* default security ops */
-extern struct security_operations capability_security_ops;
+/* Security enabled? */
+extern int security_enabled;

/* prototypes */
extern int security_init (void);
extern int register_security (struct security_operations *ops);
@@ -1253,16 +1253,17 @@ extern int mod_reg_security (const char
extern int mod_unreg_security (const char *name, struct security_operations *ops);

/* Condition for invocation of non-default security_op */
#define COND_SECURITY(seop, def) \
- (likely(security_ops == &capability_security_ops))? def: security_ops->seop
+ (unlikely(security_enabled))? security_ops->seop: def

#else /* CONFIG_SECURITY */
static inline int security_init(void)
{
return 0;
}

+# define security_enabled 0
# define COND_SECURITY(seop, def) def
#endif

/* SELinux noop */
Index: linux-2.6.10/security/security.c
===================================================================
--- linux-2.6.10.orig/security/security.c
+++ linux-2.6.10/security/security.c
@@ -21,10 +21,14 @@
#define SECURITY_FRAMEWORK_VERSION "1.0.0"

/* things that live in dummy.c */
extern void security_fixup_ops (struct security_operations *ops);
+/* default security ops */
+extern struct security_operations capability_security_ops;

struct security_operations *security_ops; /* Initialized to NULL */
+int security_enabled; /* ditto */
+EXPORT_SYMBOL(security_enabled);

static inline int verify(struct security_operations *ops)
{
/* verify the security_operations structure exists */
@@ -59,8 +63,9 @@ int __init security_init(void)
"capability_security_ops structure.\n", __FUNCTION__);
return -EIO;
}

+ security_enabled = 0;
security_ops = &capability_security_ops;

/* Initialize compiled-in security modules */
do_security_initcalls();
@@ -91,8 +96,9 @@ int register_security(struct security_op
if (security_ops != &capability_security_ops)
return -EAGAIN;

security_ops = ops;
+ security_enabled = 1;

return 0;
}

@@ -115,8 +121,9 @@ int unregister_security(struct security_
"registered, failing.\n", __FUNCTION__);
return -EINVAL;
}

+ security_enabled = 0;
security_ops = &capability_security_ops;

return 0;
}
--
Kurt Garloff, Director SUSE Labs, Novell Inc.


Attachments:
(No filename) (3.50 kB)
(No filename) (189.00 B)
Download all attachments

2005-02-14 14:31:12

by Andreas Gruenbacher

[permalink] [raw]
Subject: Re: [PATCH] 2/5: LSM hooks rework

On Sun, 2005-02-13 at 22:11, Kurt Garloff wrote:
> From: Kurt Garloff <[email protected]>
> Subject: Clean LSM stub file
> References: 40217, 39439
>
> Rather than having every LSM hook twice, once for the case with
> CONFIG_SECURITY enabled and once for the disabled case, put
> everything in one inline function.

The attached patch fixes compilation if CONFIG_SECURITY_NETWORK is
turned off.

> This reduces the chance of the two to go out of sync immensely.

... as it already happened with security_sk_free(). Also fixed in the
attached patch.


Regards,
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX GMBH


Attachments:
CONFIG_SECURITY_NETWORK=n.diff (5.92 kB)

2005-02-14 16:50:26

by James Morris

[permalink] [raw]
Subject: Re: [PATCH] 5/5: LSM hooks rework

On Sun, 13 Feb 2005, Kurt Garloff wrote:

> /* Condition for invocation of non-default security_op */
> #define COND_SECURITY(seop, def) \
> - (likely(security_ops == &capability_security_ops))? def: security_ops->seop
> + (unlikely(security_enabled))? security_ops->seop: def

So this will cause a false unlikely() for every single SELinux hook,
again. This was rejected last year. The thread you pointed to has some
discussion of dealing with the problematic ia64 case, although there's no
evidence in these patches that anything has progressed in that area since
then.


- James
--
James Morris
<[email protected]>



2005-02-14 16:54:19

by Rik van Riel

[permalink] [raw]
Subject: Re: [PATCH] 4/5: LSM hooks rework

On Sun, 13 Feb 2005, Kurt Garloff wrote:

> The case that security_ops points to the default capability_
> security_ops is the fast path and arguably the more likely one
> on most systems.

Quite a few distributions ship with other security modules
enabled by default, so I'm not sure we should add a "likely"
here - let the CPU's branch prediction sort things out.

--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan

2005-02-14 18:30:20

by Kurt Garloff

[permalink] [raw]
Subject: Re: [PATCH] 2/5: LSM hooks rework

Hi Andreas,

On Mon, Feb 14, 2005 at 03:30:33PM +0100, Andreas Gruenbacher wrote:
> On Sun, 2005-02-13 at 22:11, Kurt Garloff wrote:
> > Rather than having every LSM hook twice, once for the case with
> > CONFIG_SECURITY enabled and once for the disabled case, put
> > everything in one inline function.
>
> The attached patch fixes compilation if CONFIG_SECURITY_NETWORK is
> turned off.
>
> > This reduces the chance of the two to go out of sync immensely.
>
> ... as it already happened with security_sk_free(). Also fixed in the
> attached patch.

Indeed. Though harmless fortunately ...

Thanks for fixing this up, I had overlooked the CONFIG_SECURITY_NETWORK
disabled case :(

Regards,
--
Kurt Garloff, Director SUSE Labs, Novell Inc.


Attachments:
(No filename) (745.00 B)
(No filename) (189.00 B)
Download all attachments

2005-02-14 23:24:11

by Kurt Garloff

[permalink] [raw]
Subject: Re: [PATCH] 5/5: LSM hooks rework

Hi James,

On Mon, Feb 14, 2005 at 11:50:01AM -0500, James Morris wrote:
> On Sun, 13 Feb 2005, Kurt Garloff wrote:
>
> > /* Condition for invocation of non-default security_op */
> > #define COND_SECURITY(seop, def) \
> > - (likely(security_ops == &capability_security_ops))? def: security_ops->seop
> > + (unlikely(security_enabled))? security_ops->seop: def
>
> So this will cause a false unlikely() for every single SELinux hook,
> again.

A correct unlikely() in my book.

Yes, that was one of the reasons that I split up the patches.

There are people who believe that we should optimize for the
slow path (SELinux) or at least not penalize it.
Fine with me, feel free to ignore patches 4, 5 then.

> This was rejected last year.

It wasn't. The discussion did not come to a conclusion.

Best regards,
--
Kurt Garloff, Director SUSE Labs, Novell Inc.


Attachments:
(No filename) (865.00 B)
(No filename) (189.00 B)
Download all attachments

2005-02-14 23:29:08

by Kurt Garloff

[permalink] [raw]
Subject: Re: [PATCH] 4/5: LSM hooks rework

Hi Rik,

On Mon, Feb 14, 2005 at 11:54:07AM -0500, Rik van Riel wrote:
> On Sun, 13 Feb 2005, Kurt Garloff wrote:
>
> >The case that security_ops points to the default capability_
> >security_ops is the fast path and arguably the more likely one
> >on most systems.
>
> Quite a few distributions ship with other security modules
> enabled by default, so I'm not sure we should add a "likely"
> here - let the CPU's branch prediction sort things out.

Fine with me. I had the fast path in mind, but with some
luck, CPU branch prediction will work for us.

I sent out the full patch set, which moves the code from
vanilla to the code we've been shipping since 7 months.
And I made the changes in the order to make the ones that I
expect the least controversial come first.

If we can't find consensus for patches 4 and 5, I'd still
think applying 1 -- 3 is useful.

Regards,
--
Kurt Garloff, Director SUSE Labs, Novell Inc.


Attachments:
(No filename) (925.00 B)
(No filename) (189.00 B)
Download all attachments

2005-02-14 23:36:53

by Rik van Riel

[permalink] [raw]
Subject: Re: [PATCH] 4/5: LSM hooks rework

On Tue, 15 Feb 2005, Kurt Garloff wrote:

> I sent out the full patch set, which moves the code from
> vanilla to the code we've been shipping since 7 months.

Heh, it sounds like such a step back when it's said like that ;)

> If we can't find consensus for patches 4 and 5, I'd still
> think applying 1 -- 3 is useful.

I'll take a look at the other patches.

--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan

2005-02-15 04:50:57

by Chris Wright

[permalink] [raw]
Subject: Re: [PATCH] 0/5: LSM hooks rework

* Kurt Garloff ([email protected]) wrote:
> this goes back to a discussion in August last year:
> http://www.ussg.iu.edu/hypermail/linux/kernel/0408.1/0623.html

Thanks for follow up Kurt. I'm travelling at the moment so bear with me
if my response time is slow. In short, I don't mind switching over to
default capabilities and the consolidation of inline functions. The
last optimization is pessimistic for case where module is in use, so let's
hold on that one at least as we work out any minor nits with the first
three patches.

thanks,
-chris
--
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net

2005-02-15 05:50:45

by Kurt Garloff

[permalink] [raw]
Subject: [PATCH] New 2/5: LSM hooks rework

Hi,

On Sun, Feb 13, 2005 at 04:11:09PM -0500, Kurt Garloff wrote:
> From: Kurt Garloff <[email protected]>
> Subject: Clean LSM stub file
[...]

So, for convenience, I merged Andreas' fix on top
of this patch into a new patch 2, which is attached.
So CONFIG_SECURITY_NETWORK disabled should work again.

Regards,
--
Kurt Garloff, Director SUSE Labs, Novell Inc.


Attachments:
(No filename) (0.00 B)
(No filename) (189.00 B)
Download all attachments