LSM: Stacking for major security modules
Subsystems (11)
Casey Schaufler
maintainercover LSM: Stacking for major security modules
Subject: [PATCH RFC 00/11] LSM: Stacking for major security modules
I am again sending this as an RFC. If you stop at patch 04 you can use any combination of modules so long as you use only one of SELinux and Smack. Patches 05-10 take you most of the way to complete stacking, but cannot be said to completely address all the issues. Patch 11 provides for management of the yet unused task blob.
This patch set implements stacking for "major" security modules that use cred and file blobs. Management of security blobs is moved from the security modules and into the LSM infrastructure. This has been proposed in the past by Serge Hallyn and David Howells. This implementation owes much to their work.
The bulk of the change is in abstracting use of blobs within the security modules. This allows the modules to share a single blob and hides the details from the code. There is
Modules are required to declare the amount of space they require for each blob they use. Because modules deal with blobs during their initialization the blob sizes must be declared prior to module initialization. The module initialization becomes a two step process.
Security module stacking is optional. If stacking is not configured, the CONFIG_DEFAULT_SECURITY value is used, just as before. If stacking is configured using CONFIG_SECURITY_STACKING the modules desired for the stack are selected individually. AppArmor would be selected by specifying CONFIG_SECURITY_APPARMOR_STACKED. The CONFIG_DEFAULT_SECURITY is ignored. The security= boot option is still respected and has the same behavior as before, allowing a single module to be used instead of the specified stack.
To accommodate multiple active modules a security "context" is defined to use a regular format:
lsmname='lsmvalue'[,lsmname='lsmvalue']...
This is not supported by any existing user space run time code.
I have tested these patches in various configurations of Ubuntu and Fedora. I have had much better success with SELinux in permissive mode than enforcing, but that appears to be a result of user space code issues. Smack and SELinux together have limited success, again because of the context format.
Patch 01 Adds a smack subdirectory in /proc/.../attr (proposed separately) Patch 02 Move management of the cred blob to the LSM infrastructure. Patch 03 Move management of the file blob to the LSM infrastructure. Patch 04 Change how the security modules get selected.
Patch 05 Infrastructure blob management for IPC, keys, sockets. Patch 06 Fixes Smack's sk_free hook.
Patch 07 Support mount options for multiple security modules. Patch 08 Change secids from a u32 to a structure.
Patch 09 Netlabel consistency enforcment in sendmsg.
Patch 10 Fixes a compile issue in one Smack configuration. Patch 11 Infrastructure blob management for the new task blob.
These patches can be found in git at:
https://github.com/cschaufler/smack-next.git#stacking-4.11-rc4
---
Documentation/security/LSM.txt | 33 +- drivers/usb/core/devio.c | 13 +- fs/btrfs/super.c | 10 +- fs/proc/base.c | 96 ++- fs/proc/internal.h | 1 + fs/xattr.c | 6 +- include/linux/audit.h | 10 +- include/linux/cred.h | 3 +- include/linux/lsm_hooks.h | 76 ++- include/linux/sched/signal.h | 2 +- include/linux/security.h | 227 +++++-- include/net/flow.h | 5 +- include/net/netlabel.h | 16 +- include/net/scm.h | 4 +- kernel/audit.c | 25 +- kernel/audit.h | 9 +- kernel/auditfilter.c | 4 +- kernel/auditsc.c | 42 +- kernel/cred.c | 19 +- kernel/signal.c | 6 +- net/ipv4/cipso_ipv4.c | 5 +- net/ipv4/ip_sockglue.c | 6 +- net/netfilter/nf_conntrack_netlink.c | 12 +- net/netfilter/nf_conntrack_standalone.c | 6 +- net/netfilter/nfnetlink_queue.c | 9 +- net/netfilter/xt_AUDIT.c | 9 +- net/netfilter/xt_SECMARK.c | 6 +- net/netlabel/netlabel_kapi.c | 56 +- net/netlabel/netlabel_unlabeled.c | 30 +- net/netlabel/netlabel_unlabeled.h | 2 +- net/netlabel/netlabel_user.c | 4 +- net/unix/af_unix.c | 6 +- net/xfrm/xfrm_policy.c | 6 +- net/xfrm/xfrm_state.c | 3 +- security/Kconfig | 86 +++ security/apparmor/context.c | 2 - security/apparmor/include/context.h | 25 +- security/apparmor/lsm.c | 111 ++-- security/integrity/ima/ima_policy.c | 7 +- security/security.c | 1046 +++++++++++++++++++++++++++++-- security/selinux/hooks.c | 720 +++++++++------------ security/selinux/include/audit.h | 2 +- security/selinux/include/objsec.h | 87 ++- security/selinux/include/xfrm.h | 9 +- security/selinux/netlabel.c | 17 +- security/selinux/selinuxfs.c | 5 +- security/selinux/ss/services.c | 13 +- security/selinux/xfrm.c | 29 +- security/smack/smack.h | 95 ++- security/smack/smack_access.c | 2 +- security/smack/smack_lsm.c | 751 +++++++++------------- security/smack/smack_netfilter.c | 28 +- security/smack/smackfs.c | 28 +- security/tomoyo/common.h | 25 +- security/tomoyo/domain.c | 4 +- security/tomoyo/securityfs_if.c | 13 +- security/tomoyo/tomoyo.c | 55 +- 57 files changed, 2647 insertions(+), 1280 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Casey Schaufler
maintainerRFC PATCH 1/11 procfs: add smack subdir to attrs
Subject: [PATCH RFC 01/11] procfs: add smack subdir to attrs
Back in 2007 I made what turned out to be a rather serious mistake in the implementation of the Smack security module. The SELinux module used an interface in /proc to manipulate the security context on processes. Rather than use a similar interface, I used the same interface. The AppArmor team did likewise. Now /proc/.../attr/current will tell you the security "context" of the process, but it will be different depending on the security module you're using.
This patch provides a subdirectory in /proc/.../attr for Smack. Smack user space can use the "current" file in this subdirectory and never have to worry about getting SELinux attributes by mistake. Programs that use the old interface will continue to work (or fail, as the case may be) as before.
This patch does not include subdirectories for SELinux or AppArmor. I do have a patch that provides those, and will happily make it available should anyone see value in it.
The original implementation is by Kees Cook.
--- Documentation/security/LSM.txt | 19 +++++++++---- fs/proc/base.c | 63 ++++++++++++++++++++++++++++++++++++------ fs/proc/internal.h | 1 + include/linux/security.h | 15 ++++++---- security/security.c | 30 +++++++++++++++++--- 5 files changed, 104 insertions(+), 24 deletions(-)
Documentation/security/LSM.txt +13 -6
@@ -16,11 +16,10 @@ MAC extensions, other extensions can be built using the LSM to provide specific changes to system operation when these tweaks are not available in the core functionality of Linux itself. -Without a specific LSM built into the kernel, the default LSM will be the -Linux capabilities system. Most LSMs choose to extend the capabilities -system, building their checks on top of the defined capability hooks. -For more details on capabilities, see capabilities(7) in the Linux -man-pages project. +The Linux capabilities modules will always be included. For more details +on capabilities, see capabilities(7) in the Linux man-pages project. +This may be followed by any number of "minor" modules and at most one +"major" module. A list of the active security modules can be found by reading /sys/kernel/security/lsm. This is a comma separated list, and
@@ -29,6 +28,14 @@ order in which checks are made. The capability module will always be first, followed by any "minor" modules (e.g. Yama) and then the one "major" module (e.g. SELinux) if there is one configured. +Process attributes associated with "major" security modules should +be accessed and maintained using the special files in /proc/.../attr. +A security module may maintain a module specific subdirectory there, +named after the module. /proc/.../attr/smack is provided by the Smack +security module and contains all its special files. The files directly +in /proc/.../attr remain as legacy interfaces for modules that provide +subdirectories. + Based on https://lkml.org/lkml/2007/10/26/215, a new LSM is accepted into the kernel when its intent (a description of what it tries to protect against and in what cases one would expect to
@@ -38,4 +45,4 @@ that end users and distros can make a more informed decision about which LSMs suit their requirements. For extensive documentation on the available LSM hook interfaces, please -see include/linux/security.h. +see include/linux/lsm_hooks.h.
fs/proc/base.c +54 -9
90 lines not on this page · raw message
fs/proc/internal.h +1 -0
@@ -58,6 +58,7 @@ union proc_op {int (*proc_show)(struct seq_file *m,struct pid_namespace *ns,struct pid *pid,struct task_struct *task); +const char *lsm; };struct proc_inode {
include/linux/security.h +10 -5
@@ -365,8 +365,10 @@ int security_sem_semctl(struct sem_array *sma, int cmd);int security_sem_semop (struct sem_array *sma,struct sembuf *sops,unsigned nsops,int alter);void security_d_instantiate (struct dentry *dentry,struct inode *inode); -int security_getprocattr (struct task_struct *p,char *name,char **value); -int security_setprocattr (const char *name,void *value,size_t size); +int security_getprocattr (struct task_struct *p,const char *lsm,char *name, +char **value); +int security_setprocattr (const char *lsm,const char *name,void *value, +size_t size);int security_netlink_send (struct sock *sk,struct sk_buff *skb);int security_ismaclabel (const char *name);int security_secid_to_secctx (u32 secid,char **secdata,u32 *seclen);
@@ -1111,15 +1113,18 @@ static inline int security_sem_semop(struct sem_array *sma,return 0 ; } -static inline void security_d_instantiate (struct dentry *dentry,struct inode *inode) +static inline void security_d_instantiate (struct dentry *dentry, +struct inode *inode) { } -static inline int security_getprocattr (struct task_struct *p,char *name,char **value) +static inline int security_getprocattr (struct task_struct *p,const char *lsm, +char *name,char **value) {return -EINVAL ; } -static inline int security_setprocattr (char *name,void *value,size_t size) +static inline int security_setprocattr (const char *lsm,char *name, +void *value,size_t size) {return -EINVAL ; }
security/security.c +26 -4
@@ -1216,14 +1216,36 @@ void security_d_instantiate(struct dentry *dentry, struct inode *inode) }EXPORT_SYMBOL (security_d_instantiate); -int security_getprocattr (struct task_struct *p,char *name,char **value) +int security_getprocattr (struct task_struct *p,const char *lsm,char *name, +char **value) { -return call_int_hook (getprocattr, -EINVAL , p, name, value); +struct security_hook_list *hp; +int rc; + +list_for_each_entry (hp, &security_hook_heads.getprocattr, list) { +if (lsm !=NULL &&strcmp (lsm, hp->lsm)) +continue ; + rc = hp->hook.getprocattr (p, name, value); +if (rc != -ENOENT ) +return rc; + } +return -EINVAL ; } -int security_setprocattr (const char *name,void *value,size_t size) +int security_setprocattr (const char *lsm,const char *name,void *value, +size_t size) { -return call_int_hook (setprocattr, -EINVAL , name, value, size); +struct security_hook_list *hp; +int rc; + +list_for_each_entry (hp, &security_hook_heads.setprocattr, list) { +if (lsm !=NULL &&strcmp (lsm, hp->lsm)) +continue ; + rc = hp->hook.setprocattr (name, value, size); +if (rc != -ENOENT ) +return rc; + } +return -EINVAL ; }int security_netlink_send (struct sock *sk,struct sk_buff *skb)
Signature · 7 lines
2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Casey Schaufler
maintainerRFC PATCH 2/11 LSM: manage credential security blobs
In reply to Casey SchauflerSubject: [PATCH RFC 02/11] LSM: manage credential security blobs
Move the management of credential security blobs from the individual security modules to the security infrastructure. The security modules using credential blobs have been updated accordingly. Modules are required to identify the space they require at module initialization. In some cases a module no longer needs to supply blob management hook, in which case the hook has been removed.
--- include/linux/lsm_hooks.h | 14 ++++ kernel/cred.c | 13 ---- security/Kconfig | 11 +++ security/apparmor/context.c | 2 - security/apparmor/include/context.h | 9 ++- security/apparmor/lsm.c | 44 ++++-------- security/security.c | 98 +++++++++++++++++++++++++- security/selinux/hooks.c | 115 ++++++++++++------------------- security/selinux/include/objsec.h | 9 +++ security/selinux/selinuxfs.c | 1 + security/selinux/xfrm.c | 4 +- security/smack/smack.h | 15 +++- security/smack/smack_access.c | 2 +- security/smack/smack_lsm.c | 134 +++++++++++++++--------------------- security/smack/smackfs.c | 18 ++--- security/tomoyo/common.h | 20 +++++- security/tomoyo/domain.c | 4 +- security/tomoyo/securityfs_if.c | 13 ++-- security/tomoyo/tomoyo.c | 49 ++++++++++--- 19 files changed, 346 insertions(+), 229 deletions(-)
include/linux/lsm_hooks.h +14 -0
@@ -1890,6 +1890,13 @@ struct security_hook_list { };/* +* Security blob size or offset data. +*/ +struct lsm_blob_sizes { +int lbs_cred; +}; + +/* * Initializing a security_hook_list structure takes * up a lot of space in a source file. This macro takes * care of the common case and reduces the amount of
@@ -1901,6 +1908,7 @@ struct security_hook_list {extern struct security_hook_heads security_hook_heads;extern char *lsm_names; +extern void security_add_blobs (struct lsm_blob_sizes *needed);extern void security_add_hooks (struct security_hook_list *hooks,int count,char *lsm);
@@ -1947,4 +1955,10 @@ void __init loadpin_add_hooks(void);static inline void loadpin_add_hooks (void ) { };#endif +extern int lsm_cred_alloc (struct cred *cred,gfp_t gfp); + +#ifdef CONFIG_SECURITY +void lsm_early_cred (struct cred *cred); +#endif +#endif /* ! __LINUX_LSM_HOOKS_H */
kernel/cred.c +0 -13
@@ -704,19 +704,6 @@ bool creds_are_invalid(const struct cred *cred) {if (cred->magic !=CRED_MAGIC )return true; -#ifdef CONFIG_SECURITY_SELINUX -/* -* cred->security == NULL if security_cred_alloc_blank() or -* security_prepare_creds() returned an error. -*/ -if (selinux_is_enabled () && cred->security) { -if ((unsigned long ) cred->security <PAGE_SIZE ) -return true; -if ((*(u32 *)cred->security &0xffffff00 ) == - (POISON_FREE <<24 |POISON_FREE <<16 |POISON_FREE <<8 )) -return true; - } -#endif return false; }EXPORT_SYMBOL (creds_are_invalid);
security/Kconfig +11 -0
@@ -36,6 +36,17 @@ config SECURITY_WRITABLE_HOOKS bool default n +config SECURITY_LSM_DEBUG + bool "Enable debugging of the LSM infrastructure" + depends on SECURITY + help + This allows you to choose debug messages related to + security modules configured into your kernel. These + messages may be helpful in determining how a security + module is using security blobs. + + If you are unsure how to answer this question, answer N. + config SECURITYFS bool "Enable the securityfs filesystem" help
security/apparmor/context.c +0 -2
@@ -50,8 +50,6 @@ void aa_free_task_context(struct aa_task_ctx *ctx)aa_put_profile (ctx->profile);aa_put_profile (ctx->previous);aa_put_profile (ctx->onexec); - -kzfree (ctx); } }
security/apparmor/include/context.h +7 -2
@@ -18,11 +18,12 @@#include <linux/cred.h> #include <linux/slab.h> #include <linux/sched.h> +#include <linux/lsm_hooks.h> #include "policy.h" #include "policy_ns.h" -#define cred_ctx (X ) ((X)->security) +#define cred_ctx (X ) apparmor_cred(X)#define current_ctx () cred_ctx(current_cred())/* struct aa_file_ctx - the AppArmor context the file was opened in
@@ -86,6 +87,10 @@ int aa_set_current_hat(struct aa_profile *profile, u64 token);int aa_restore_previous_profile (u64 cookie);struct aa_profile *aa_get_task_profile (struct task_struct *task); +static inline struct aa_task_ctx *apparmor_cred (const struct cred *cred) +{ +return cred->security; +}/** * aa_cred_profile - obtain cred's profiles
@@ -97,7 +102,7 @@ struct aa_profile *aa_get_task_profile(struct task_struct *task);*/ static inline struct aa_profile *aa_cred_profile (const struct cred *cred) { -struct aa_task_ctx *ctx =cred_ctx (cred); +struct aa_task_ctx *ctx =apparmor_cred (cred);AA_BUG (!ctx || !ctx->profile);return ctx->profile;
security/apparmor/lsm.c +15 -29
84 lines not on this page · raw message
security/security.c +97 -1
135 lines not on this page · raw message
security/selinux/hooks.c +43 -72
302 lines not on this page · raw message
security/selinux/include/objsec.h +9 -0
@@ -24,6 +24,9 @@#include <linux/binfmts.h> #include <linux/in.h> #include <linux/spinlock.h> +#include <linux/lsm_hooks.h> +#include <linux/msg.h> +#include <net/sock.h> #include <net/net_namespace.h> #include "flask.h" #include "avc.h"
@@ -140,5 +143,11 @@ struct key_security_struct { };extern unsigned int selinux_checkreqprot; +extern struct lsm_blob_sizes selinux_blob_sizes; + +static inline struct task_security_struct *selinux_cred (const struct cred *cred) +{ +return cred->security; +}#endif /* _SELINUX_OBJSEC_H_ */
security/selinux/selinuxfs.c +1 -0
@@ -30,6 +30,7 @@#include <linux/uaccess.h> #include <linux/kobject.h> #include <linux/ctype.h> +#include <linux/lsm_hooks.h> /* selinuxfs pseudo filesystem for exporting the security policy API. Based on the proc code and the fs/nfsd/nfsctl.c code. */
security/selinux/xfrm.c +2 -2
@@ -79,7 +79,7 @@ static int selinux_xfrm_alloc_user(struct xfrm_sec_ctx **ctxp, gfp_t gfp) {int rc; -const struct task_security_struct *tsec =current_security (); +const struct task_security_struct *tsec =selinux_cred (current_cred ());struct xfrm_sec_ctx *ctx =NULL ;u32 str_len;
@@ -136,7 +136,7 @@ static void selinux_xfrm_free(struct xfrm_sec_ctx *ctx)*/ static int selinux_xfrm_delete (struct xfrm_sec_ctx *ctx) { -const struct task_security_struct *tsec =current_security (); +const struct task_security_struct *tsec =selinux_cred (current_cred ());if (!ctx)return 0 ;
security/smack/smack.h +12 -3
@@ -24,6 +24,7 @@#include <linux/list.h> #include <linux/rculist.h> #include <linux/lsm_audit.h> +#include <linux/msg.h> /* * Use IPv6 port labeling if IPv6 is enabled and secmarks
@@ -355,6 +356,11 @@ extern struct list_head smack_onlycap_list;#define SMACK_HASH_SLOTS 16extern struct hlist_head smack_known_hash[SMACK_HASH_SLOTS ]; +static inline struct task_smack *smack_cred (const struct cred *cred) +{ +return cred->security; +} +/* * Is the directory transmuting? */
@@ -381,13 +387,16 @@ static inline struct smack_known *smk_of_task(const struct task_smack *tsp)return tsp->smk_task; } -static inline struct smack_known *smk_of_task_struct (const struct task_struct *t) +static inline struct smack_known *smk_of_task_struct ( +const struct task_struct *t) {struct smack_known *skp; +const struct cred *cred;rcu_read_lock (); - skp =smk_of_task (__task_cred (t)->security); + cred =__task_cred (t);rcu_read_unlock (); + skp =smk_of_task (smack_cred (cred));return skp; }
@@ -404,7 +413,7 @@ static inline struct smack_known *smk_of_forked(const struct task_smack *tsp)*/ static inline struct smack_known *smk_of_current (void ) { -return smk_of_task (current_security ()); +return smk_of_task (smack_cred (current_cred ())); }/*
security/smack/smack_access.c +1 -1
@@ -275,7 +275,7 @@ int smk_tskacc(struct task_smack *tsp, struct smack_known *obj_known,int smk_curacc (struct smack_known *obj_known,u32 mode,struct smk_audit_info *a) { -struct task_smack *tsp =current_security (); +struct task_smack *tsp =smack_cred (current_cred ());return smk_tskacc (tsp, obj_known, mode, a); }
security/smack/smack_lsm.c +55 -79
349 lines not on this page · raw message
security/smack/smackfs.c +9 -9
@@ -2208,14 +2208,14 @@ static const struct file_operations smk_logging_ops = {static void *load_self_seq_start (struct seq_file *s,loff_t *pos) { -struct task_smack *tsp =current_security (); +struct task_smack *tsp =smack_cred (current_cred ());return smk_seq_start (s, pos, &tsp->smk_rules); }static void *load_self_seq_next (struct seq_file *s,void *v,loff_t *pos) { -struct task_smack *tsp =current_security (); +struct task_smack *tsp =smack_cred (current_cred ());return smk_seq_next (s, v, pos, &tsp->smk_rules); }
@@ -2262,7 +2262,7 @@ static int smk_open_load_self(struct inode *inode, struct file *file)static ssize_t smk_write_load_self (struct file *file,const char __user *buf,size_t count,loff_t *ppos) { -struct task_smack *tsp =current_security (); +struct task_smack *tsp =smack_cred (current_cred ());return smk_write_rules_list (file, buf, count, ppos, &tsp->smk_rules, &tsp->smk_rules_lock,SMK_FIXED24_FMT );
@@ -2414,14 +2414,14 @@ static const struct file_operations smk_load2_ops = {static void *load_self2_seq_start (struct seq_file *s,loff_t *pos) { -struct task_smack *tsp =current_security (); +struct task_smack *tsp =smack_cred (current_cred ());return smk_seq_start (s, pos, &tsp->smk_rules); }static void *load_self2_seq_next (struct seq_file *s,void *v,loff_t *pos) { -struct task_smack *tsp =current_security (); +struct task_smack *tsp =smack_cred (current_cred ());return smk_seq_next (s, v, pos, &tsp->smk_rules); }
@@ -2467,7 +2467,7 @@ static int smk_open_load_self2(struct inode *inode, struct file *file)static ssize_t smk_write_load_self2 (struct file *file,const char __user *buf,size_t count,loff_t *ppos) { -struct task_smack *tsp =current_security (); +struct task_smack *tsp =smack_cred (current_cred ());return smk_write_rules_list (file, buf, count, ppos, &tsp->smk_rules, &tsp->smk_rules_lock,SMK_LONG_FMT );
@@ -2681,14 +2681,14 @@ static const struct file_operations smk_syslog_ops = {static void *relabel_self_seq_start (struct seq_file *s,loff_t *pos) { -struct task_smack *tsp =current_security (); +struct task_smack *tsp =smack_cred (current_cred ());return smk_seq_start (s, pos, &tsp->smk_relabel); }static void *relabel_self_seq_next (struct seq_file *s,void *v,loff_t *pos) { -struct task_smack *tsp =current_security (); +struct task_smack *tsp =smack_cred (current_cred ());return smk_seq_next (s, v, pos, &tsp->smk_relabel); }
@@ -2736,7 +2736,7 @@ static int smk_open_relabel_self(struct inode *inode, struct file *file)static ssize_t smk_write_relabel_self (struct file *file,const char __user *buf,size_t count,loff_t *ppos) { -struct task_smack *tsp =current_security (); +struct task_smack *tsp =smack_cred (current_cred ());char *data;int rc;LIST_HEAD (list_tmp);
security/tomoyo/common.h +18 -2
@@ -28,6 +28,7 @@#include <linux/in.h> #include <linux/in6.h> #include <linux/un.h> +#include <linux/lsm_hooks.h> #include <net/sock.h> #include <net/af_unix.h> #include <net/ip.h>
@@ -1196,13 +1197,26 @@ static inline void tomoyo_put_group(struct tomoyo_group *group) }/** +* tomoyo_cred - Get a pointer to the tomoyo cred security blob +* @cred - the relevant cred +* +* Returns pointer to the tomoyo cred blob. +*/ +static inline struct tomoyo_domain_info **tomoyo_cred (const struct cred *cred) +{ +return cred->security; +} + +/** * tomoyo_domain - Get "struct tomoyo_domain_info" for current thread. * * Returns pointer to "struct tomoyo_domain_info" for current thread. */ static inline struct tomoyo_domain_info *tomoyo_domain (void ) { -return current_cred ()->security; +struct tomoyo_domain_info **blob =tomoyo_cred (current_cred ()); + +return *blob; }/**
@@ -1215,7 +1229,9 @@ static inline struct tomoyo_domain_info *tomoyo_domain(void)static inline struct tomoyo_domain_info *tomoyo_real_domain (struct task_struct *task) { -return task_cred_xxx (task, security); +struct tomoyo_domain_info **blob =tomoyo_cred (get_task_cred (task)); + +return *blob; }/**
security/tomoyo/domain.c +3 -1
@@ -677,6 +677,7 @@ static int tomoyo_environ(struct tomoyo_execve *ee)*/ int tomoyo_find_next_domain (struct linux_binprm *bprm) { +struct tomoyo_domain_info **blob;struct tomoyo_domain_info *old_domain =tomoyo_domain ();struct tomoyo_domain_info *domain =NULL ;const char *original_name = bprm->filename;
@@ -842,7 +843,8 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm) domain = old_domain;/* Update reference count on "struct tomoyo_domain_info". */ atomic_inc (&domain->users); - bprm->cred->security = domain; + blob =tomoyo_cred (bprm->cred); + *blob = domain;kfree (exename.name);if (!retval) { ee->r.domain = domain;
security/tomoyo/securityfs_if.c +9 -4
@@ -70,9 +70,12 @@ static ssize_t tomoyo_write_self(struct file *file, const char __user *buf,if (!cred) { error = -ENOMEM ; }else { -struct tomoyo_domain_info *old_domain = - cred->security; - cred->security = new_domain; +struct tomoyo_domain_info **blob; +struct tomoyo_domain_info *old_domain; + + blob =tomoyo_cred (cred); + old_domain = *blob; + *blob = new_domain;atomic_inc (&new_domain->users);atomic_dec (&old_domain->users);commit_creds (cred);
@@ -233,10 +236,12 @@ static void __init tomoyo_create_entry(const char *name, const umode_t mode,*/ static int __init tomoyo_initerface_init (void ) { +struct tomoyo_domain_info *domain;struct dentry *tomoyo_dir; + domain =tomoyo_domain ();/* Don't create securityfs entries unless registered. */ -if (current_cred ()->security != &tomoyo_kernel_domain) +if (domain != &tomoyo_kernel_domain)return 0 ; tomoyo_dir =securityfs_create_dir ("tomoyo" ,NULL );
security/tomoyo/tomoyo.c +40 -9
109 lines not on this page · raw message
Signature · 7 lines
2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Casey Schaufler
maintainerRFC PATCH 3/11 LSM: Manage file security blobs
In reply to Casey SchauflerSubject: [PATCH RFC 03/11] LSM: Manage file security blobs
Move the management of file security blobs from the individual security modules to the security infrastructure. The security modules using file blobs have been updated accordingly. Modules are required to identify the space they need at module initialization. In some cases a module no longer needs to supply a blob management hook, in which case the hook has been removed.
--- include/linux/lsm_hooks.h | 1 + security/apparmor/include/context.h | 6 ++++++ security/apparmor/lsm.c | 26 ++++------------------- security/security.c | 32 +++++++++++++++++++++++++++++ security/selinux/hooks.c | 41 +++++++++---------------------------- security/selinux/include/objsec.h | 5 +++++ security/smack/smack.h | 5 +++++ security/smack/smack_lsm.c | 26 ++++++++--------------- 8 files changed, 72 insertions(+), 70 deletions(-)
include/linux/lsm_hooks.h +1 -0
@@ -1894,6 +1894,7 @@ struct security_hook_list {*/ struct lsm_blob_sizes {int lbs_cred; +int lbs_file; };/*
security/apparmor/include/context.h +6 -0
@@ -25,6 +25,7 @@#define cred_ctx (X ) apparmor_cred(X)#define current_ctx () cred_ctx(current_cred()) +#define file_ctx (X ) apparmor_file(X)/* struct aa_file_ctx - the AppArmor context the file was opened in * @perms: the permission the file was opened with
@@ -92,6 +93,11 @@ static inline struct aa_task_ctx *apparmor_cred(const struct cred *cred)return cred->security; } +static inline struct aa_file_ctx *apparmor_file (const struct file *file) +{ +return file->f_security; +} +/** * aa_cred_profile - obtain cred's profiles * @cred: cred to obtain profiles from (NOT NULL)
security/apparmor/lsm.c +4 -22
@@ -329,7 +329,7 @@ static int apparmor_inode_getattr(const struct path *path)static int apparmor_file_open (struct file *file,const struct cred *cred) { -struct aa_file_ctx *fctx = file->f_security; +struct aa_file_ctx *fctx =file_ctx (file);struct aa_profile *profile;int error =0 ;
@@ -360,26 +360,9 @@ static int apparmor_file_open(struct file *file, const struct cred *cred)return error; } -static int apparmor_file_alloc_security (struct file *file) -{ -/* freed by apparmor_file_free_security */ - file->f_security =aa_alloc_file_context (GFP_KERNEL ); -if (!file->f_security) -return -ENOMEM ; -return 0 ; - -} - -static void apparmor_file_free_security (struct file *file) -{ -struct aa_file_ctx *ctx = file->f_security; - -aa_free_file_context (ctx); -} -static int common_file_perm (const char *op,struct file *file,u32 mask) { -struct aa_file_ctx *fctx = file->f_security; +struct aa_file_ctx *fctx =file_ctx (file);struct aa_profile *profile, *fprofile =aa_cred_profile (file->f_cred);int error =0 ;
@@ -425,7 +408,7 @@ static int common_mmap(const char *op, struct file *file, unsigned long prot, {int mask =0 ; -if (!file || !file->f_security) +if (!file ||file_ctx (file) ==NULL )return 0 ;if (prot &PROT_READ )
@@ -566,6 +549,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,struct lsm_blob_sizes apparmor_blob_sizes = { .lbs_cred =sizeof (struct aa_task_ctx ), + .lbs_file =sizeof (struct aa_file_ctx ), }; static struct security_hook_list apparmor_hooks[] __lsm_ro_after_init = {
@@ -588,8 +572,6 @@ static struct security_hook_list apparmor_hooks[] __lsm_ro_after_init = {LSM_HOOK_INIT (file_open, apparmor_file_open),LSM_HOOK_INIT (file_permission, apparmor_file_permission), -LSM_HOOK_INIT (file_alloc_security, apparmor_file_alloc_security), -LSM_HOOK_INIT (file_free_security, apparmor_file_free_security),LSM_HOOK_INIT (mmap_file, apparmor_mmap_file),LSM_HOOK_INIT (file_mprotect, apparmor_file_mprotect), LSM_HOOK_INIT(file_lock, apparmor_file_lock),
security/security.c +32 -0
@@ -87,6 +87,7 @@ int __init security_init(void)#ifdef CONFIG_SECURITY_LSM_DEBUG pr_info ("LSM: cred blob size = %d\n" , blob_sizes.lbs_cred); +pr_info ("LSM: file blob size = %d\n" , blob_sizes.lbs_file);#endif return 0 ;
@@ -223,6 +224,30 @@ static void __init lsm_set_size(int *need, int *lbs)void __init security_add_blobs (struct lsm_blob_sizes *needed) {lsm_set_size (&needed->lbs_cred, &blob_sizes.lbs_cred); +lsm_set_size (&needed->lbs_file, &blob_sizes.lbs_file); +} + +/** +* lsm_file_alloc - allocate a composite file blob +* @file: the file that needs a blob +* +* Allocate the file blob for all the modules +* +* Returns 0, or -ENOMEM if memory can't be allocated. +*/ +int lsm_file_alloc (struct file *file) +{ +#ifdef CONFIG_SECURITY_LSM_DEBUG +if (file->f_security) +pr_info ("%s: Inbound file blob is not NULL.\n" , __func__); +#endif +if (blob_sizes.lbs_file ==0 ) +return 0 ; + + file->f_security =kzalloc (blob_sizes.lbs_file,GFP_KERNEL ); +if (file->f_security ==NULL ) +return -ENOMEM ; +return 0 ; }/*
@@ -910,12 +935,19 @@ int security_file_permission(struct file *file, int mask)int security_file_alloc (struct file *file) { +int rc =lsm_file_alloc (file); + +if (rc) +return rc;return call_int_hook (file_alloc_security,0 , file); }void security_file_free (struct file *file) {call_void_hook (file_free_security, file); + +kfree (file->f_security); + file->f_security =NULL ; }int security_file_ioctl (struct file *file,unsigned int cmd,unsigned long arg)
security/selinux/hooks.c +10 -31
133 lines not on this page · raw message
security/selinux/include/objsec.h +5 -0
@@ -150,4 +150,9 @@ static inline struct task_security_struct *selinux_cred(const struct cred *cred) return cred->security; } +static inline struct file_security_struct *selinux_file (const struct file *file) +{ +return file->f_security; +} +#endif /* _SELINUX_OBJSEC_H_ */
security/smack/smack.h +5 -0
@@ -361,6 +361,11 @@ static inline struct task_smack *smack_cred(const struct cred *cred)return cred->security; } +static inline struct smack_known **smack_file (const struct file *file) +{ +return file->f_security; +} +/* * Is the directory transmuting? */
security/smack/smack_lsm.c +9 -17
@@ -1603,25 +1603,13 @@ static void smack_inode_getsecid(struct inode *inode, u32 *secid)*/ static int smack_file_alloc_security (struct file *file) { -struct smack_known *skp =smk_of_current (); +struct smack_known **blob =smack_file (file); - file->f_security = skp; + *blob =smk_of_current ();return 0 ; }/** -* smack_file_free_security - clear a file security blob -* @file: the object -* -* The security blob for a file is a pointer to the master -* label list, so no memory is freed. -*/ -static void smack_file_free_security (struct file *file) -{ - file->f_security =NULL ; -} - -/** * smack_file_ioctl - Smack check on ioctls * @file: the object * @cmd: what to do
@@ -1845,7 +1833,9 @@ static int smack_mmap_file(struct file *file,*/ static void smack_file_set_fowner (struct file *file) { - file->f_security =smk_of_current (); +struct smack_known **blob =smack_file (file); + + *blob =smk_of_current (); }/**
@@ -1862,6 +1852,7 @@ static void smack_file_set_fowner(struct file *file)static int smack_file_send_sigiotask (struct task_struct *tsk,struct fown_struct *fown,int signum) { +struct smack_known **blob;struct smack_known *skp;struct smack_known *tkp =smk_of_task (smack_cred (tsk->cred));struct file *file;
@@ -1874,7 +1865,8 @@ static int smack_file_send_sigiotask(struct task_struct *tsk, file = container_of(fown, struct file, f_owner);/* we don't log here as rc can be overriden */ - skp = file->f_security; + blob =smack_file (file); + skp = *blob; rc =smk_access (skp, tkp,MAY_DELIVER ,NULL ); rc =smk_bu_note ("sigiotask" , skp, tkp,MAY_DELIVER , rc);if (rc !=0 &&has_capability (tsk,CAP_MAC_OVERRIDE ))
@@ -4606,6 +4598,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)struct lsm_blob_sizes smack_blob_sizes = { .lbs_cred =sizeof (struct task_smack ), + .lbs_file =sizeof (struct smack_known *), }; static struct security_hook_list smack_hooks[] __lsm_ro_after_init = {
@@ -4645,7 +4638,6 @@ static struct security_hook_list smack_hooks[] __lsm_ro_after_init = {LSM_HOOK_INIT (inode_getsecid, smack_inode_getsecid),LSM_HOOK_INIT (file_alloc_security, smack_file_alloc_security), -LSM_HOOK_INIT (file_free_security, smack_file_free_security),LSM_HOOK_INIT (file_ioctl, smack_file_ioctl),LSM_HOOK_INIT (file_lock, smack_file_lock), LSM_HOOK_INIT(file_fcntl, smack_file_fcntl),
Signature · 7 lines
2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Casey Schaufler
maintainerRFC PATCH 4/11 LSM: general but not extreme module stacking
In reply to Casey SchauflerSubject: [PATCH RFC 04/11] LSM: general but not extreme module stacking
Leverage the infrastructure management of the credential and file security blobs to allow stacking of security modules in all but the most extreme case. Security modules are informed of the location of their data within the blobs at module initialization.
Stacking is optional. If stacking is not configured the old limit of one "major" security module applies. If stacking is configured any combination that does not include both SELinux and Smack is allowed.
A subdirectory has been added to /proc/.../attr for each of SELinux and AppArmor (Smack introduced such a subdirectory earlier) to disambiguate what data is provided in the proc/.../attr interfaces. An entry "context" is added to /proc/.../attr and to each of the subdirectories. The "context" entry provides process attribute information in the form:
lsm-name='lsm-data'[,lsm-name='lsm-data']...
Data returned with SO_PEERSEC and SCM_SECURITY will be in "context" format when stacking is configured.
--- Documentation/security/LSM.txt | 18 ++++- fs/proc/base.c | 33 +++++++++ include/linux/lsm_hooks.h | 2 +- security/Kconfig | 94 ++++++++++++++++++++++++ security/apparmor/include/context.h | 10 +++ security/apparmor/lsm.c | 43 +++++++++-- security/security.c | 142 +++++++++++++++++++++++++++++++++++- security/selinux/hooks.c | 24 +++++- security/selinux/include/objsec.h | 8 ++ security/smack/smack.h | 9 +++ security/smack/smack_lsm.c | 23 +++--- security/tomoyo/common.h | 5 ++ security/tomoyo/tomoyo.c | 3 +- 13 files changed, 389 insertions(+), 25 deletions(-)
Documentation/security/LSM.txt +16 -2
@@ -18,8 +18,14 @@ in the core functionality of Linux itself. The Linux capabilities modules will always be included. For more details on capabilities, see capabilities(7) in the Linux man-pages project. -This may be followed by any number of "minor" modules and at most one -"major" module. + +Security modules that do not use the security data blobs maintained +by the LSM infrastructure are considered "minor" modules. These may be +included at compile time and stacked explicitly. Security modules that +use the LSM maintained security blobs are considered "major" modules. +These may only be stacked if the CONFIG_LSM_STACKED configuration +option is used. If this is chosen all of the security modules selected +will be used. A list of the active security modules can be found by reading /sys/kernel/security/lsm. This is a comma separated list, and
@@ -36,6 +42,14 @@ security module and contains all its special files. The files directly in /proc/.../attr remain as legacy interfaces for modules that provide subdirectories. +The files named "context" in the attr directories contain the +same information as the "current" files, but formatted to +identify the module it comes from. + +if selinux is the active security module: + /proc/self/attr/context could contain selinux='unconfined_t' + /proc/self/attr/selinux/context could contain selinux='unconfined_t' + Based on https://lkml.org/lkml/2007/10/26/215, a new LSM is accepted into the kernel when its intent (a description of what it tries to protect against and in what cases one would expect to
fs/proc/base.c +33 -0
@@ -2552,13 +2552,37 @@ static const struct inode_operations proc_##LSM##_attr_dir_inode_ops = { \ .setattr = proc_setattr, \ } +#ifdef CONFIG_SECURITY_SELINUX +static const struct pid_entry selinux_attr_dir_stuff[] = { +ATTR ("selinux" ,"current" ,0666 ), +ATTR ("selinux" ,"prev" ,0444 ), +ATTR ("selinux" ,"exec" ,0666 ), +ATTR ("selinux" ,"fscreate" ,0666 ), +ATTR ("selinux" ,"keycreate" ,0666 ), +ATTR ("selinux" ,"sockcreate" ,0666 ), +ATTR ("selinux" ,"context" ,0666 ), +}; +LSM_DIR_OPS (selinux); +#endif +#ifdef CONFIG_SECURITY_SMACK static const struct pid_entry smack_attr_dir_stuff[] = {ATTR ("smack" ,"current" ,0666 ), +ATTR ("smack" ,"context" ,0666 ), };LSM_DIR_OPS (smack);#endif +#ifdef CONFIG_SECURITY_APPARMOR +static const struct pid_entry apparmor_attr_dir_stuff[] = { +ATTR ("apparmor" ,"current" ,0666 ), +ATTR ("apparmor" ,"prev" ,0444 ), +ATTR ("apparmor" ,"exec" ,0666 ), +ATTR ("apparmor" ,"context" ,0666 ), +}; +LSM_DIR_OPS (apparmor); +#endif +static const struct pid_entry attr_dir_stuff[] = {ATTR (NULL ,"current" ,0666 ),ATTR (NULL ,"prev" ,0444 ),
@@ -2566,10 +2590,19 @@ static const struct pid_entry attr_dir_stuff[] = {ATTR (NULL ,"fscreate" ,0666 ),ATTR (NULL ,"keycreate" ,0666 ),ATTR (NULL ,"sockcreate" ,0666 ), +ATTR (NULL ,"context" ,0666 ), +#ifdef CONFIG_SECURITY_SELINUX +DIR ("selinux" ,0555 , + proc_selinux_attr_dir_inode_ops, proc_selinux_attr_dir_ops), +#endif #ifdef CONFIG_SECURITY_SMACKDIR ("smack" ,0555 , proc_smack_attr_dir_inode_ops, proc_smack_attr_dir_ops), #endif +#ifdef CONFIG_SECURITY_APPARMOR +DIR ("apparmor" ,0555 , + proc_apparmor_attr_dir_inode_ops, proc_apparmor_attr_dir_ops), +#endif };static int proc_attr_dir_readdir (struct file *file,struct dir_context *ctx)
include/linux/lsm_hooks.h +1 -1
@@ -1943,7 +1943,7 @@ static inline void security_delete_hooks(struct security_hook_list *hooks,#define __lsm_ro_after_init __ro_after_init#endif /* CONFIG_SECURITY_WRITABLE_HOOKS */ -extern int __init security_module_enable (const char *module); +extern bool __init security_module_enable (const char *lsm,const bool stacked);extern void __init capability_add_hooks (void );#ifdef CONFIG_SECURITY_YAMA extern void __init yama_add_hooks (void );
security/Kconfig +94 -0
109 lines not on this page · raw message
security/apparmor/include/context.h +10 -0
@@ -88,14 +88,24 @@ int aa_set_current_hat(struct aa_profile *profile, u64 token);int aa_restore_previous_profile (u64 cookie);struct aa_profile *aa_get_task_profile (struct task_struct *task); +extern struct lsm_blob_sizes apparmor_blob_sizes; +static inline struct aa_task_ctx *apparmor_cred (const struct cred *cred) { +#ifdef CONFIG_SECURITY_STACKING +return cred->security + apparmor_blob_sizes.lbs_cred; +#else return cred->security; +#endif }static inline struct aa_file_ctx *apparmor_file (const struct file *file) { +#ifdef CONFIG_SECURITY_STACKING +return file->f_security + apparmor_blob_sizes.lbs_file; +#else return file->f_security; +#endif }/**
security/apparmor/lsm.c +37 -6
82 lines not on this page · raw message
security/security.c +140 -2
182 lines not on this page · raw message
security/selinux/hooks.c +21 -3
@@ -5785,6 +5785,8 @@ static int selinux_getprocattr(struct task_struct *p,if (!strcmp (name,"current" )) sid = __tsec->sid; +else if (!strcmp (name,"context" )) + sid = __tsec->sid;else if (!strcmp (name,"prev" )) sid = __tsec->osid;else if (!strcmp (name,"exec" ))
@@ -5804,7 +5806,19 @@ static int selinux_getprocattr(struct task_struct *p,if (!sid)return 0 ; - error =security_sid_to_context (sid, value, &len); +if (strcmp (name,"context" )) { + error =security_sid_to_context (sid, value, &len); + }else { +char *vp; + + error =security_sid_to_context (sid, &vp, &len); +if (!error) { + *value =kasprintf (GFP_KERNEL ,"selinux='%s'" , vp); +if (*value ==NULL ) + error = -ENOMEM ; + } + } +if (error)return error;return len;
@@ -5840,6 +5854,9 @@ static int selinux_setprocattr(const char *name, void *value, size_t size)else if (!strcmp (name,"current" )) error =avc_has_perm (mysid, mysid,SECCLASS_PROCESS ,PROCESS__SETCURRENT ,NULL ); +else if (!strcmp (name,"context" )) + error =avc_has_perm (mysid, mysid,SECCLASS_PROCESS , +PROCESS__SETCURRENT ,NULL );else error = -EINVAL ;if (error)
@@ -5900,7 +5917,7 @@ static int selinux_setprocattr(const char *name, void *value, size_t size) tsec->keycreate_sid = sid; }else if (!strcmp (name,"sockcreate" )) { tsec->sockcreate_sid = sid; - }else if (!strcmp (name,"current" )) { + }else if (!strcmp (name,"current" ) || !strcmp (name,"context" )) { error = -EINVAL ;if (sid ==0 ) goto abort_change;
@@ -6288,7 +6305,8 @@ static __init int selinux_init(void) {static int finish; -if (!security_module_enable ("selinux" )) { +if (!security_module_enable ("selinux" , +IS_ENABLED (CONFIG_SECURITY_SELINUX_STACKED ))) { selinux_enabled =0 ;return 0 ; }
security/selinux/include/objsec.h +8 -0
@@ -147,12 +147,20 @@ extern struct lsm_blob_sizes selinux_blob_sizes;static inline struct task_security_struct *selinux_cred (const struct cred *cred) { +#ifdef CONFIG_SECURITY_STACKING +return cred->security + selinux_blob_sizes.lbs_cred; +#else return cred->security; +#endif }static inline struct file_security_struct *selinux_file (const struct file *file) { +#ifdef CONFIG_SECURITY_STACKING +return file->f_security + selinux_blob_sizes.lbs_file; +#else return file->f_security; +#endif }#endif /* _SELINUX_OBJSEC_H_ */
security/smack/smack.h +9 -0
@@ -336,6 +336,7 @@ extern struct smack_known *smack_syslog_label;extern struct smack_known *smack_unconfined;#endif extern int smack_ptrace_rule; +extern struct lsm_blob_sizes smack_blob_sizes;extern struct smack_known smack_known_floor;extern struct smack_known smack_known_hat;
@@ -358,12 +359,20 @@ extern struct hlist_head smack_known_hash[SMACK_HASH_SLOTS];static inline struct task_smack *smack_cred (const struct cred *cred) { +#ifdef CONFIG_SECURITY_STACKING +return cred->security + smack_blob_sizes.lbs_cred; +#else return cred->security; +#endif }static inline struct smack_known **smack_file (const struct file *file) { +#ifdef CONFIG_SECURITY_STACKING +return file->f_security + smack_blob_sizes.lbs_file; +#else return file->f_security; +#endif }/*
security/smack/smack_lsm.c +13 -10
@@ -3608,18 +3608,20 @@ static int smack_getprocattr(struct task_struct *p, char *name, char **value) {struct smack_known *skp =smk_of_task_struct (p);char *cp; -int slen; -if (strcmp (name,"current" ) !=0 ) +if (strcmp (name,"current" ) ==0 ) { + cp =kstrdup (skp->smk_known,GFP_KERNEL ); +if (cp ==NULL ) +return -ENOMEM ; + }else if (strcmp (name,"context" ) ==0 ) { + cp =kasprintf (GFP_KERNEL ,"smack='%s'" , skp->smk_known); +if (cp ==NULL ) +return -ENOMEM ; + }else return -EINVAL ; - cp =kstrdup (skp->smk_known,GFP_KERNEL ); -if (cp ==NULL ) -return -ENOMEM ; - - slen =strlen (cp); *value = cp; -return slen; +return strlen (cp); }/**
@@ -3647,7 +3649,7 @@ static int smack_setprocattr(const char *name, void *value, size_t size)if (value ==NULL || size ==0 || size >=SMK_LONGLABEL )return -EINVAL ; -if (strcmp (name,"current" ) !=0 ) +if (strcmp (name,"current" ) !=0 &&strcmp (name,"context" ) !=0 )return -EINVAL ; skp =smk_import_entry (value, size);
@@ -4779,7 +4781,8 @@ static __init int smack_init(void)struct cred *cred = (struct cred *) current->cred;struct task_smack *tsp; -if (!security_module_enable ("smack" )) +if (!security_module_enable ("smack" , +IS_ENABLED (CONFIG_SECURITY_SMACK_STACKED )))return 0 ;if (!finish) {
security/tomoyo/common.h +5 -0
@@ -1085,6 +1085,7 @@ extern struct tomoyo_domain_info tomoyo_kernel_domain;extern struct tomoyo_policy_namespace tomoyo_kernel_namespace;extern unsigned int tomoyo_memory_quota[TOMOYO_MAX_MEMORY_STAT ];extern unsigned int tomoyo_memory_used[TOMOYO_MAX_MEMORY_STAT ]; +extern struct lsm_blob_sizes tomoyo_blob_sizes;/********** Inlined functions. **********/
@@ -1204,7 +1205,11 @@ static inline void tomoyo_put_group(struct tomoyo_group *group)*/ static inline struct tomoyo_domain_info **tomoyo_cred (const struct cred *cred) { +#ifdef CONFIG_SECURITY_STACKING +return cred->security + tomoyo_blob_sizes.lbs_cred; +#else return cred->security; +#endif }/**
security/tomoyo/tomoyo.c +2 -1
@@ -561,7 +561,8 @@ static int __init tomoyo_init(void)struct cred *cred = (struct cred *)current_cred ();struct tomoyo_domain_info **blob; -if (!security_module_enable ("tomoyo" )) +if (!security_module_enable ("tomoyo" , +IS_ENABLED (CONFIG_SECURITY_TOMOYO_STACKED )))return 0 ;if (!finish) {
Signature · 7 lines
2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Tetsuo Handa
maintainerRFC PATCH 4/11 LSM: general but not extreme module stacking
Quoted 55 lines · Casey Schaufler
security/security.c +51
-0@@ -1365,6 +1432,77 @@ int security_setprocattr(const char *lsm, const char *name, void *value, {struct security_hook_list *hp;int rc; +char *local; +char *cp; +int slen; +int failed =0 ; + +/* +* If lsm is NULL look at all the modules to find one +* that processes name. If lsm is not NULL only look at +* that module. +* +* "context" is handled directly here. +*/ +if (strcmp (name,"context" ) ==0 ) { +/* +* First verify that the input is acceptable. +* lsm1='v1'lsm2='v2'lsm3='v3' +* +* A note on the use of strncmp() below. +* The check is for the substring at the beginning of cp. +* The kzalloc of size + 1 ensures a terminated string. +*/ + rc = -EINVAL ; + local =kzalloc (size +1 ,GFP_KERNEL ); +memcpy (local, value, size); + cp = local; +list_for_each_entry (hp, &security_hook_heads.setprocattr, + list) { +if (lsm !=NULL &&strcmp (lsm, hp->lsm)) +continue ; +if (cp[0 ] ==',' ) { +if (cp == local) + goto free_out; + cp++; + } + slen =strlen (hp->lsm); +if (strncmp (cp, hp->lsm, slen)) + goto free_out; + cp += slen; +if (cp[0 ] !='=' || cp[1 ] !='\'' || cp[2 ] =='\'' ) + goto free_out; +for (cp +=2 ; cp[0 ] !='\'' ; cp++) +if (cp[0 ] =='\0' ) + goto free_out; + cp++; + } + + cp = local; +list_for_each_entry (hp, &security_hook_heads.setprocattr, + list) { +if (lsm !=NULL &&strcmp (lsm, hp->lsm)) +continue ;
security/security.c int security_setprocattr(const char *lsm, const char *name, void *value, · line 1495
Quoted 10 lines
security/security.c +10
-0+if (cp[0 ] ==',' ) + cp++; + cp +=strlen (hp->lsm) +2 ; +for (slen =0 ; cp[slen] !='\'' ; slen++) + ; + cp[slen] ='\0' ; + + rc = hp->hook.setprocattr ("context" , cp, slen); +if (rc <0 ) + failed = rc;
I did not find your answer to my question.
When
valid_lsmname1='valid_value_for_lsmname1'valid_lsmname2='valid_value_for_lsmname2'valid_lsmname3='invalid_value_for_lsmname3'
is given, there is no way to undo already committed
valid_lsmname1='valid_value_for_lsmname1'valid_lsmname2='valid_value_for_lsmname2'
changes while return value tells failure at
valid_lsmname3='invalid_value_for_lsmname3'
. If you want to allow updating multiple values, you need to make them a transaction.
security/security.c int security_setprocattr(const char *lsm, const char *name, void *value, · line 1508
Quoted 13 lines
security/security.c +10
-0+ cp += slen +1 ; + } +if (failed !=0 ) + rc = failed; +else + rc = size; +free_out: +kfree (local); +return rc; + }list_for_each_entry (hp, &security_hook_heads.setprocattr, list) {if (lsm !=NULL &&strcmp (lsm, hp->lsm))
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Casey Schaufler
maintainerRFC PATCH 5/11 LSM: Infrastructure management of the remaining blobs
In reply to Casey SchauflerSubject: [PATCH RFC 05/11] LSM: Infrastructure management of the remaining blobs
Move management of the inode, ipc, key, msg_msg, sock and superblock security blobs from the security modules to the infrastructure. Use of the blob pointers is abstracted in the security modules.
--- include/linux/lsm_hooks.h | 8 + security/security.c | 259 ++++++++++++++++++++++++++++- security/selinux/hooks.c | 333 ++++++++++++------------------------- security/selinux/include/objsec.h | 65 +++++++- security/selinux/netlabel.c | 15 +- security/selinux/selinuxfs.c | 4 +- security/selinux/ss/services.c | 3 +- security/smack/smack.h | 61 ++++++- security/smack/smack_lsm.c | 342 +++++++++++--------------------------- security/smack/smack_netfilter.c | 8 +- 10 files changed, 599 insertions(+), 499 deletions(-)
include/linux/lsm_hooks.h +8 -0
@@ -1895,6 +1895,12 @@ struct security_hook_list {struct lsm_blob_sizes {int lbs_cred;int lbs_file; +int lbs_inode; +int lbs_ipc; +int lbs_key; +int lbs_msg_msg; +int lbs_sock; +int lbs_superblock; };/*
@@ -1957,9 +1963,11 @@ static inline void loadpin_add_hooks(void) { };#endif extern int lsm_cred_alloc (struct cred *cred,gfp_t gfp); +extern int lsm_inode_alloc (struct inode *inode);#ifdef CONFIG_SECURITY void lsm_early_cred (struct cred *cred); +void lsm_early_inode (struct inode *inode);#endif #endif /* ! __LINUX_LSM_HOOKS_H */
security/security.c +257 -2
379 lines not on this page · raw message
security/selinux/hooks.c +104 -229
874 lines not on this page · raw message
security/selinux/include/objsec.h +61 -4
75 lines not on this page · raw message
security/selinux/netlabel.c +8 -7
@@ -32,6 +32,7 @@#include <linux/gfp.h> #include <linux/ip.h> #include <linux/ipv6.h> +#include <linux/lsm_hooks.h> #include <net/sock.h> #include <net/netlabel.h> #include <net/ip.h>
@@ -82,7 +83,7 @@ static int selinux_netlbl_sidlookup_cached(struct sk_buff *skb,static struct netlbl_lsm_secattr *selinux_netlbl_sock_genattr (struct sock *sk) {int rc; -struct sk_security_struct *sksec = sk->sk_security; +struct sk_security_struct *sksec =selinux_sock (sk);struct netlbl_lsm_secattr *secattr;if (sksec->nlbl_secattr !=NULL )
@@ -114,7 +115,7 @@ static struct netlbl_lsm_secattr *selinux_netlbl_sock_getattr( const struct sock *sk, u32 sid) { -struct sk_security_struct *sksec = sk->sk_security; +struct sk_security_struct *sksec =selinux_sock (sk);struct netlbl_lsm_secattr *secattr = sksec->nlbl_secattr;if (secattr ==NULL )
@@ -249,7 +250,7 @@ int selinux_netlbl_skbuff_setsid(struct sk_buff *skb,* being labeled by it's parent socket, if it is just exit */ sk =skb_to_full_sk (skb);if (sk !=NULL ) { -struct sk_security_struct *sksec = sk->sk_security; +struct sk_security_struct *sksec =selinux_sock (sk);if (sksec->nlbl_state !=NLBL_REQSKB )return 0 ; secattr =selinux_netlbl_sock_getattr (sk, sid);
@@ -311,7 +312,7 @@ int selinux_netlbl_inet_conn_request(struct request_sock *req, u16 family)*/ void selinux_netlbl_inet_csk_clone (struct sock *sk,u16 family) { -struct sk_security_struct *sksec = sk->sk_security; +struct sk_security_struct *sksec =selinux_sock (sk);if (family ==PF_INET ) sksec->nlbl_state =NLBL_LABELED ;
@@ -332,7 +333,7 @@ void selinux_netlbl_inet_csk_clone(struct sock *sk, u16 family)int selinux_netlbl_socket_post_create (struct sock *sk,u16 family) {int rc; -struct sk_security_struct *sksec = sk->sk_security; +struct sk_security_struct *sksec =selinux_sock (sk);struct netlbl_lsm_secattr *secattr;if (family !=PF_INET && family !=PF_INET6 )
@@ -446,7 +447,7 @@ int selinux_netlbl_socket_setsockopt(struct socket *sock, {int rc =0 ;struct sock *sk = sock->sk; -struct sk_security_struct *sksec = sk->sk_security; +struct sk_security_struct *sksec =selinux_sock (sk);struct netlbl_lsm_secattr secattr; if (selinux_netlbl_option(level, optname) &&
@@ -482,7 +483,7 @@ int selinux_netlbl_socket_setsockopt(struct socket *sock,int selinux_netlbl_socket_connect (struct sock *sk,struct sockaddr *addr) {int rc; -struct sk_security_struct *sksec = sk->sk_security; +struct sk_security_struct *sksec =selinux_sock (sk);struct netlbl_lsm_secattr *secattr; if (sksec->nlbl_state != NLBL_REQSKB &&
security/selinux/selinuxfs.c +2 -2
@@ -1309,7 +1309,7 @@ static int sel_make_bools(void)if (len >=PAGE_SIZE ) goto out; - isec = (struct inode_security_struct *)inode->i_security; + isec = (struct inode_security_struct *)selinux_inode (inode); ret =security_genfs_sid ("selinuxfs" , page,SECCLASS_FILE , &sid);if (ret) { pr_warn_ratelimited("SELinux: no sid found, defaulting to security isid for %s\n",
@@ -1850,7 +1850,7 @@ static int sel_fill_super(struct super_block *sb, void *data, int silent) goto err; inode->i_ino = ++sel_last_ino; - isec = (struct inode_security_struct *)inode->i_security; + isec = (struct inode_security_struct *)selinux_inode (inode); isec->sid =SECINITSID_DEVNULL ; isec->sclass =SECCLASS_CHR_FILE ; isec->initialized =LABEL_INITIALIZED ;
security/selinux/ss/services.c +2 -1
@@ -52,6 +52,7 @@#include <linux/selinux.h> #include <linux/flex_array.h> #include <linux/vmalloc.h> +#include <linux/lsm_hooks.h> #include <net/netlabel.h> #include "flask.h"
@@ -2546,7 +2547,7 @@ int security_fs_use(struct super_block *sb) {int rc =0 ;struct ocontext *c; -struct superblock_security_struct *sbsec = sb->s_security; +struct superblock_security_struct *sbsec =selinux_superblock (sb);const char *fstype = sb->s_type->name;read_lock (&policy_rwlock);
security/smack/smack.h +59 -2
78 lines not on this page · raw message
security/smack/smack_lsm.c +94 -248
808 lines not on this page · raw message
security/smack/smack_netfilter.c +4 -4
@@ -30,8 +30,8 @@ static unsigned int smack_ipv6_output(void *priv,struct socket_smack *ssp;struct smack_known *skp; -if (sk && sk->sk_security) { - ssp = sk->sk_security; +if (sk &&smack_sock (sk)) { + ssp =smack_sock (sk); skp = ssp->smk_out; skb->secmark = skp->smk_secid; }
@@ -48,8 +48,8 @@ static unsigned int smack_ipv4_output(void *priv,struct socket_smack *ssp;struct smack_known *skp; -if (sk && sk->sk_security) { - ssp = sk->sk_security; +if (sk &&smack_sock (sk)) { + ssp =smack_sock (sk); skp = ssp->smk_out; skb->secmark = skp->smk_secid; }
Signature · 7 lines
2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Casey Schaufler
maintainerRFC PATCH 6/11 Smack: remove socket blob free
In reply to Casey SchauflerSubject: [PATCH RFC 06/11] Smack: remove socket blob free.
With stacking in place the infrastructure releases the socket blob, so the module shouldn't.
--- security/smack/smack_lsm.c | 1 - 1 file changed, 1 deletion(-)
security/smack/smack_lsm.c +0 -1
@@ -2272,7 +2272,6 @@ static void smack_sk_free_security(struct sock *sk) }rcu_read_unlock (); } -kfree (sk->sk_security); }#endif
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Casey Schaufler
maintainerRFC PATCH 7/11 LSM: Mount option data for extreme stacking
In reply to Casey SchauflerSubject: [PATCH RFC 07/11] LSM: Mount option data for extreme stacking
Each security module that supports mount options needs its own instance of the semi-processed data. The two security modules that support this, SELinux and Smack, are provided their own instance when necessary.
--- fs/btrfs/super.c | 10 ++--- include/linux/security.h | 69 ++++++++++++++++++++++++++++------ security/security.c | 15 ++++++-- security/selinux/hooks.c | 93 +++++++++++++++++++++++----------------------- security/smack/smack_lsm.c | 51 ++++++++++++------------- 5 files changed, 147 insertions(+), 91 deletions(-)
fs/btrfs/super.c +5 -5
@@ -1501,15 +1501,15 @@ static int setup_security_options(struct btrfs_fs_info *fs_info,return ret;#ifdef CONFIG_SECURITY -if (!fs_info->security_opts.num_mnt_opts) { +if (fs_info->security_opts.selinux.num_mnt_opts !=0 || + fs_info->security_opts.smack.num_mnt_opts !=0 ) {/* first time security setup, copy sec_opts to fs_info */ memcpy (&fs_info->security_opts, sec_opts,sizeof (*sec_opts)); }else {/* -* Since SELinux (the only one supporting security_mnt_opts) -* does NOT support changing context during remount/mount of -* the same sb, this must be the same or part of the same -* security options, just free it. +* Since no modules support changing context during +* remount/mount of the same sb, this must be the same +* or part of the same security options, just free it. */ security_free_mnt_opts (sec_opts); }
include/linux/security.h +57 -12
93 lines not on this page · raw message
security/security.c +12 -3
@@ -691,9 +691,18 @@ int security_sb_set_mnt_opts(struct super_block *sb,unsigned long kern_flags, unsigned long *set_kern_flags) { - return call_int_hook(sb_set_mnt_opts, - opts->num_mnt_opts ? -EOPNOTSUPP : 0, sb, -opts ,kern_flags ,set_kern_flags ); + int nobody = 0; + +#ifdef SECURITY_EXTREME_STACKING +if (opts->selinux.num_mnt_opts !=0 || opts->smack.num_mnt_opts !=0 ) + nobody = -EOPNOTSUPP ; +#else +if (opts->selinux.num_mnt_opts !=0 ) + nobody = -EOPNOTSUPP ; +#endif + +return call_int_hook (sb_set_mnt_opts, nobody, sb, opts, kern_flags, + set_kern_flags); }EXPORT_SYMBOL (security_sb_set_mnt_opts);
security/selinux/hooks.c +47 -46
196 lines not on this page · raw message
security/smack/smack_lsm.c +26 -25
112 lines not on this page · raw message
Signature · 7 lines
2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Casey Schaufler
maintainerRFC PATCH 9/11 netlabel agreement checking
In reply to Casey SchauflerSubject: [PATCH RFC 09/11] netlabel agreement checking
If multiple security modules are using netlabel to pass security attributes they must agree on the labeling for each packet. Because a module may decide on the labeling based on a number of factors the check needs to be done at send time.
--- include/linux/lsm_hooks.h | 5 +++- include/net/netlabel.h | 8 +++++++ net/netlabel/netlabel_kapi.c | 54 ++++++++++++++++++++++++++++++++++++++++++++ security/security.c | 23 ++++++++++++++++++- security/selinux/hooks.c | 7 +++++- security/smack/smack_lsm.c | 4 +++- security/tomoyo/tomoyo.c | 3 ++- 7 files changed, 99 insertions(+), 5 deletions(-)
include/linux/lsm_hooks.h +4 -1
@@ -28,6 +28,8 @@#include <linux/init.h> #include <linux/rculist.h> +struct netlbl_lsm_secattr ; +/** * Security hooks for program execution operations. *
@@ -789,6 +791,7 @@* @sock contains the socket structure. * @msg contains the message to be transmitted. * @size contains the size of message. +* @attrs points to the network attributes on return. * Return 0 if permission is granted. * @socket_recvmsg: * Check permission before receiving a message from a socket.
@@ -1584,7 +1587,7 @@ union security_list_options {int (*socket_listen)(struct socket *sock,int backlog);int (*socket_accept)(struct socket *sock,struct socket *newsock);int (*socket_sendmsg)(struct socket *sock,struct msghdr *msg, -int size); +int size,struct netlbl_lsm_secattr **attrs);int (*socket_recvmsg)(struct socket *sock,struct msghdr *msg,int size,int flags);int (*socket_getsockname)(struct socket *sock);
include/net/netlabel.h +8 -0
@@ -472,6 +472,8 @@ int netlbl_catmap_setlong(struct netlbl_lsm_catmap **catmap,u32 offset, unsigned long bitmap, gfp_t flags); +bool netlbl_secattr_equal (const struct netlbl_lsm_secattr *secattr_a, +const struct netlbl_lsm_secattr *secattr_b);/* Bitmap functions */
@@ -623,6 +625,12 @@ static inline int netlbl_catmap_setlong(struct netlbl_lsm_catmap **catmap, {return 0 ; } +static inline bool netlbl_secattr_equal ( +const struct netlbl_lsm_secattr *secattr_a, +const struct netlbl_lsm_secattr *secattr_b) +{ +return true; +}static inline int netlbl_enabled (void ) {return 0 ;
net/netlabel/netlabel_kapi.c +54 -0
60 lines not on this page · raw message
security/security.c +22 -1
@@ -28,6 +28,7 @@#include <linux/msg.h> #include <net/flow.h> #include <net/sock.h> +#include <net/netlabel.h> #define MAX_LSM_EVM_XATTR 2
@@ -2134,7 +2135,27 @@ int security_socket_accept(struct socket *sock, struct socket *newsock)int security_socket_sendmsg (struct socket *sock,struct msghdr *msg,int size) { -return call_int_hook (socket_sendmsg,0 , sock, msg, size); +struct security_hook_list *hp; +int rc; +struct netlbl_lsm_secattr *pattrs =NULL ; +struct netlbl_lsm_secattr *attrs =NULL ; + +list_for_each_entry (hp, &security_hook_heads.socket_sendmsg, list) { + rc = hp->hook.socket_sendmsg (sock, msg, size, &attrs); +if (rc) +return rc; +/* +* Only do the check if the current module reports +* an attribute, and there is something to compare it to. +*/ +if (attrs) { +if (!pattrs) + pattrs = attrs; +else if (!netlbl_secattr_equal (pattrs, attrs)) +return -EACCES ; + } + } +return 0 ; } int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
security/selinux/hooks.c +6 -1
@@ -4437,8 +4437,13 @@ static int selinux_socket_accept(struct socket *sock, struct socket *newsock) }static int selinux_socket_sendmsg (struct socket *sock,struct msghdr *msg, -int size) +int size,struct netlbl_lsm_secattr **attrs) { +#ifdef CONFIG_NETLABEL +struct sk_security_struct *sksec =selinux_sock (sock->sk); + + *attrs = sksec->nlbl_secattr; +#endif return sock_has_perm (sock->sk,SOCKET__WRITE ); }
security/smack/smack_lsm.c +3 -1
@@ -3635,7 +3635,7 @@ static int smack_unix_may_send(struct socket *sock, struct socket *other)* For IPv6 this is a check against the label of the port. */ static int smack_socket_sendmsg (struct socket *sock,struct msghdr *msg, -int size) +int size,struct netlbl_lsm_secattr **attrs) {struct sockaddr_in *sip = (struct sockaddr_in *) msg->msg_name;#if IS_ENABLED (CONFIG_IPV6 )
@@ -3647,6 +3647,7 @@ static int smack_socket_sendmsg(struct socket *sock, struct msghdr *msg,#endif int rc =0 ; + *attrs =NULL ;/* * Perfectly reasonable for this to be NULL */
@@ -3656,6 +3657,7 @@ static int smack_socket_sendmsg(struct socket *sock, struct msghdr *msg,switch (sock->sk->sk_family) {case AF_INET : rc =smack_netlabel_send (sock->sk, sip); + *attrs = &ssp->smk_out->smk_netlabel;break ;case AF_INET6 :#ifdef SMACK_IPV6_SECMARK_LABELING
security/tomoyo/tomoyo.c +2 -1
@@ -499,11 +499,12 @@ static int tomoyo_socket_bind(struct socket *sock, struct sockaddr *addr,* @sock: Pointer to "struct socket". * @msg: Pointer to "struct msghdr". * @size: Size of message. +* @attrs: unused * * Returns 0 on success, negative value otherwise. */ static int tomoyo_socket_sendmsg (struct socket *sock,struct msghdr *msg, -int size) +int size,struct netlbl_lsm_secattr **attrs) {return tomoyo_socket_sendmsg_permission (sock, msg, size); }
Signature · 7 lines
2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Casey Schaufler
maintainerRFC PATCH 10/11 Smack: sendmsg compile error fix
In reply to Casey SchauflerSubject: [PATCH RFC 10/11] Smack: sendmsg compile error fix
Move the declaration of ssp out of ifdefs as it's now always required.
--- security/smack/smack_lsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/smack/smack_lsm.c +1 -1
@@ -3637,11 +3637,11 @@ static int smack_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size, struct netlbl_lsm_secattr **attrs) { struct sockaddr_in *sip = (struct sockaddr_in *) msg->msg_name; +struct socket_smack *ssp =smack_sock (sock->sk);#if IS_ENABLED (CONFIG_IPV6 )struct sockaddr_in6 *sap = (struct sockaddr_in6 *) msg->msg_name;#endif #ifdef SMACK_IPV6_SECMARK_LABELING -struct socket_smack *ssp =smack_sock (sock->sk);struct smack_known *rsp;#endif int rc =0 ;
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Casey Schaufler
maintainerRFC PATCH 11/11 LSM: manage task security blobs
In reply to Casey SchauflerSubject: [PATCH RFC 11/11] LSM: manage task security blobs
Move management of task security blobs into the security infrastructure. Modules are required to identify the space they require. At this time there are no modules that use task blobs.
--- include/linux/lsm_hooks.h | 1 + security/security.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)
include/linux/lsm_hooks.h +1 -0
@@ -1907,6 +1907,7 @@ struct lsm_blob_sizes {int lbs_msg_msg;int lbs_sock;int lbs_superblock; +int lbs_task; };/*
security/security.c +28 -0
@@ -104,6 +104,7 @@ int __init security_init(void)pr_info ("LSM: msg_msg blob size = %d\n" , blob_sizes.lbs_msg_msg);pr_info ("LSM: sock blob size = %d\n" , blob_sizes.lbs_sock);pr_info ("LSM: superblock blob size = %d\n" , blob_sizes.lbs_superblock); +pr_info ("LSM: task blob size = %d\n" , blob_sizes.lbs_task);pr_info ("LSM: secid size = %zu\n" ,sizeof (struct secids ));#endif /* CONFIG_SECURITY_LSM_DEBUG */
@@ -268,6 +269,7 @@ void __init security_add_blobs(struct lsm_blob_sizes *needed)lsm_set_size (&needed->lbs_msg_msg, &blob_sizes.lbs_msg_msg);lsm_set_size (&needed->lbs_sock, &blob_sizes.lbs_sock);lsm_set_size (&needed->lbs_superblock, &blob_sizes.lbs_superblock); +lsm_set_size (&needed->lbs_task, &blob_sizes.lbs_task);/* * The inode blob gets an rcu_head in addition to * what the modules might need.
@@ -460,6 +462,29 @@ int lsm_superblock_alloc(struct super_block *sb)return 0 ; } +/** +* lsm_task_alloc - allocate a composite task blob +* @task: the task that needs a blob +* +* Allocate the task blob for all the modules +* +* Returns 0, or -ENOMEM if memory can't be allocated. +*/ +int lsm_task_alloc (struct task_struct *task) +{ +#ifdef CONFIG_SECURITY_LSM_DEBUG +if (task->security) +pr_info ("%s: Inbound task blob is not NULL.\n" , __func__); +#endif +if (blob_sizes.lbs_task ==0 ) +return 0 ; + + task->security =kzalloc (blob_sizes.lbs_task,GFP_KERNEL ); +if (task->security ==NULL ) +return -ENOMEM ; +return 0 ; +} +/* * A secids structure contains all of the modules specific * secids and the secmark used to represent the combination
@@ -1422,6 +1447,9 @@ int security_task_alloc(struct task_struct *task, unsigned long clone_flags)void security_task_free (struct task_struct *task) {call_void_hook (task_free, task); + +kfree (task->security); + task->security =NULL ; }int security_cred_alloc_blank (struct cred *cred,gfp_t gfp)
Signature · 7 lines
2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
cover LSM: Stacking for major security modules
In reply to Casey SchauflerQuoted 42 lines · Casey Schaufler
Subject: [PATCH RFC 00/11] LSM: Stacking for major security modules
I am again sending this as an RFC. If you stop at patch 04 you can use any combination of modules so long as you use only one of SELinux and Smack. Patches 05-10 take you most of the way to complete stacking, but cannot be said to completely address all the issues. Patch 11 provides for management of the yet unused task blob.
This patch set implements stacking for "major" security modules that use cred and file blobs. Management of security blobs is moved from the security modules and into the LSM infrastructure. This has been proposed in the past by Serge Hallyn and David Howells. This implementation owes much to their work.
The bulk of the change is in abstracting use of blobs within the security modules. This allows the modules to share a single blob and hides the details from the code. There is?
Modules are required to declare the amount of space they require for each blob they use. Because modules deal with blobs during their initialization the blob sizes must be declared prior to module initialization. The module initialization becomes a two step process.
Security module stacking is optional. If stacking is not configured, the
CONFIG_DEFAULT_SECURITYvalue is used, just as before. If stacking
is configured usingCONFIG_SECURITY_STACKINGthe modules desired for the stack are selected individually. AppArmor would be selected by specifyingCONFIG_SECURITY_APPARMOR_STACKED. TheCONFIG_DEFAULT_SECURITY
is ignored. The security= boot option is still respected and has the same behavior as before, allowing a single module to be used instead of
the specified stack.To accommodate multiple active modules a security "context" is defined to use a regular format:
lsmname='lsmvalue'[,lsmname='lsmvalue']...This is not supported by any existing user space run time code.
Quoted 7 lines
I have tested these patches in various configurations of Ubuntu and Fedora. I have had much better success with SELinux in permissive mode
than enforcing, but that appears to be a result of user space code issues. Smack and SELinux together have limited success, again because
of the context format.
I think in order for this to be viable, it must not break existing userspace if CONFIG_SECURITY_STACKING=y if only one module is enabled.
Ideally, it wouldn't even break existing userspace with multiple
modules, so long as they do not conflict in their usage of userspace APIs (e.g. if only one implements getpeersec_stream, why mutate its result and break userspace?).
At present, it breaks the selinux-testsuite even with CONFIG_SECURITY_STACKING=n, all in the inet_socket tests; looks like network labeling is broken. FWIW, output was:
inet_socket/test ............ getsockopt: SO_PEERSEC: Protocol not available
read: Connection reset by peer
inet_socket/test ............ 1/33?
#???Failed test at inet_socket/test line 27. inet_socket/client:??expected unconfined_u:unconfined_r:test_inet_client_t:s0-s0:c0.c1023, got? inet_socket/test ............ 3/33?
#???Failed test at inet_socket/test line 45. inet_socket/test ............ 26/33?
#???Failed test at inet_socket/test line 219.
#???Failed test at inet_socket/test line 227.
inet_socket/test ............ 30/33?
#???Failed test at inet_socket/test line 245.
#???Failed test at inet_socket/test line 253.
# Looks like you failed 6 tests of 33.
inet_socket/test ............ Dubious, test returned 6 (wstat 1536, 0x600)
Failed 6/33 subtests
These all pass on security-next and on v4.11-rc4, so it is definitely something in your patches.?
Quoted 80 lines
Patch 01 Adds a smack subdirectory in
/proc/.../attr(proposed separately)
Patch 02 Move management of the cred blob to the LSM infrastructure. Patch 03 Move management of the file blob to the LSM infrastructure. Patch 04 Change how the security modules get selected. Patch 05 Infrastructure blob management for IPC, keys, sockets. Patch 06 Fixes Smack'ssk_freehook.
Patch 07 Support mount options for multiple security modules. Patch 08 Change secids from a u32 to a structure.
Patch 09 Netlabel consistency enforcment in sendmsg. Patch 10 Fixes a compile issue in one Smack configuration. Patch 11 Infrastructure blob management for the new task blob.These patches can be found in git at:
https://github.com/cschaufler/smack-next.git#stacking-4.11-rc4Signed-off-by Casey Schaufler <[email protected]>---
?Documentation/security/LSM.txt??????????|???33 +- ?drivers/usb/core/devio.c????????????????|???13 +- ?fs/btrfs/super.c????????????????????????|???10 +- ?fs/proc/base.c??????????????????????????|???96 ++- ?fs/proc/internal.h??????????????????????|????1 + ?fs/xattr.c??????????????????????????????|????6 +- ?include/linux/audit.h???????????????????|???10 +- ?include/linux/cred.h????????????????????|????3 +- ?include/linux/lsm_hooks.h???????????????|???76 ++- ?include/linux/sched/signal.h????????????|????2 +- ?include/linux/security.h????????????????|??227 +++++-- ?include/net/flow.h??????????????????????|????5 +- ?include/net/netlabel.h??????????????????|???16 +- ?include/net/scm.h???????????????????????|????4 +- ?kernel/audit.c??????????????????????????|???25 +- ?kernel/audit.h??????????????????????????|????9 +- ?kernel/auditfilter.c????????????????????|????4 +- ?kernel/auditsc.c????????????????????????|???42 +- ?kernel/cred.c???????????????????????????|???19 +- ?kernel/signal.c?????????????????????????|????6 +- ?net/ipv4/cipso_ipv4.c???????????????????|????5 +- ?net/ipv4/ip_sockglue.c??????????????????|????6 +- ?net/netfilter/nf_conntrack_netlink.c????|???12 +- ?net/netfilter/nf_conntrack_standalone.c |????6 +- ?net/netfilter/nfnetlink_queue.c?????????|????9 +- ?net/netfilter/xt_AUDIT.c????????????????|????9 +- ?net/netfilter/xt_SECMARK.c??????????????|????6 +- ?net/netlabel/netlabel_kapi.c????????????|???56 +- ?net/netlabel/netlabel_unlabeled.c???????|???30 +- ?net/netlabel/netlabel_unlabeled.h???????|????2 +- ?net/netlabel/netlabel_user.c????????????|????4 +- ?net/unix/af_unix.c??????????????????????|????6 +- ?net/xfrm/xfrm_policy.c??????????????????|????6 +- ?net/xfrm/xfrm_state.c???????????????????|????3 +- ?security/Kconfig????????????????????????|???86 +++ ?security/apparmor/context.c?????????????|????2 - ?security/apparmor/include/context.h?????|???25 +- ?security/apparmor/lsm.c?????????????????|??111 ++-- ?security/integrity/ima/ima_policy.c?????|????7 +- ?security/security.c?????????????????????| 1046 +++++++++++++++++++++++++++++-- ?security/selinux/hooks.c????????????????|??720 +++++++++------------ ?security/selinux/include/audit.h????????|????2 +- ?security/selinux/include/objsec.h???????|???87 ++- ?security/selinux/include/xfrm.h?????????|????9 +- ?security/selinux/netlabel.c?????????????|???17 +- ?security/selinux/selinuxfs.c????????????|????5 +- ?security/selinux/ss/services.c??????????|???13 +- ?security/selinux/xfrm.c?????????????????|???29 +- ?security/smack/smack.h??????????????????|???95 ++- ?security/smack/smack_access.c???????????|????2 +- ?security/smack/smack_lsm.c??????????????|??751 +++++++++---------- --- ?security/smack/smack_netfilter.c????????|???28 +- ?security/smack/smackfs.c????????????????|???28 +- ?security/tomoyo/common.h????????????????|???25 +- ?security/tomoyo/domain.c????????????????|????4 +- ?security/tomoyo/securityfs_if.c?????????|???13 +- ?security/tomoyo/tomoyo.c????????????????|???55 +-
Quoted 1 line
?57 files changed, 2647 insertions(+), 1280 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Casey Schaufler
maintainercover LSM: Stacking for major security modules
Quoted 50 lines · Stephen Smalley
Quoted 42 lines · Casey Schaufler
Subject: [PATCH RFC 00/11] LSM: Stacking for major security modules
I am again sending this as an RFC. If you stop at patch 04 you can use any combination of modules so long as you use only one of SELinux and Smack. Patches 05-10 take you most of the way to complete stacking, but cannot be said to completely address all the issues. Patch 11 provides for management of the yet unused task blob.
This patch set implements stacking for "major" security modules that use cred and file blobs. Management of security blobs is moved from the security modules and into the LSM infrastructure. This has been proposed in the past by Serge Hallyn and David Howells. This implementation owes much to their work.
The bulk of the change is in abstracting use of blobs within the security modules. This allows the modules to share a single blob and hides the details from the code. There is
Modules are required to declare the amount of space they require for each blob they use. Because modules deal with blobs during their initialization the blob sizes must be declared prior to module initialization. The module initialization becomes a two step process.
Security module stacking is optional. If stacking is not configured, the
CONFIG_DEFAULT_SECURITYvalue is used, just as before. If stacking
is configured usingCONFIG_SECURITY_STACKINGthe modules desired for the stack are selected individually. AppArmor would be selected by specifyingCONFIG_SECURITY_APPARMOR_STACKED. TheCONFIG_DEFAULT_SECURITY
is ignored. The security= boot option is still respected and has the same behavior as before, allowing a single module to be used instead of
the specified stack.To accommodate multiple active modules a security "context" is defined to use a regular format:
lsmname='lsmvalue'[,lsmname='lsmvalue']...This is not supported by any existing user space run time code.
Quoted 7 lines
I have tested these patches in various configurations of Ubuntu and Fedora. I have had much better success with SELinux in permissive mode
than enforcing, but that appears to be a result of user space code issues. Smack and SELinux together have limited success, again because
of the context format.
Quoted 2 lines
I think in order for this to be viable, it must not break existing userspace if
CONFIG_SECURITY_STACKING=yif only one module is enabled.
If there's only one module enabled you don't need CONFIG_SECURITY_STACKING=y. Nonetheless, I see the point. It's lots cleaner if this can be a compile time difference rather than something detected at run time, but I'll factor that in to the next version.
Quoted 4 lines
Ideally, it wouldn't even break existing userspace with multiple
modules, so long as they do not conflict in their usage of userspace APIs (e.g. if only one implementsgetpeersec_stream, why mutate its result and break userspace?).
Remember that
"system_u:object_r:netlabel_peer_t:s0" is a legitimate Smack label.
I don't think doing "System" vs "selinux='system_u:object_r:netlabel_peer_t:s0',smack='System'" on a per-API granularity is a good idea. The author of user space code oughtn't be compelled to figure out which APIs will identity the components and when they don't which security module will provide the unadorned data.
At some point it would be a good idea to have a liblsm that would make varying and/or multiple security modules easier to deal with. I know systemd and dbus could use such a library to good effect.
Quoted 3 lines
At present, it breaks the selinux-testsuite even with
CONFIG_SECURITY_STACKING=n, all in theinet_sockettests; looks like network labeling is broken. FWIW, output was:
Thanks for running the tests. I'll be looking into this soonest.
Quoted 8 lines
inet_socket/test ............ getsockopt:
SO_PEERSEC: Protocol not available
read: Connection reset by peer
inet_socket/test ............ 1/33
# Failed test at inet_socket/test line 27.
inet_socket/client: expected unconfined_u:unconfined_r:test_inet_client_t:s0-s0:c0.c1023, got
I'd be interested to see what it got.
Quoted 98 lines
inet_socket/test ............ 3/33
# Failed test at inet_socket/test line 45.
inet_socket/test ............ 26/33
# Failed test at inet_socket/test line 219.# Failed test at inet_socket/test line 227.
inet_socket/test ............ 30/33
# Failed test at inet_socket/test line 245.# Failed test at inet_socket/test line 253.
# Looks like you failed 6 tests of 33.
inet_socket/test ............ Dubious, test returned 6 (wstat 1536,0x600)
Failed 6/33 subtestsThese all pass on security-next and on v4.11-rc4, so it is definitely something in your patches.
Quoted 72 lines
Patch 01 Adds a smack subdirectory in
/proc/.../attr(proposed separately)
Patch 02 Move management of the cred blob to the LSM infrastructure. Patch 03 Move management of the file blob to the LSM infrastructure. Patch 04 Change how the security modules get selected. Patch 05 Infrastructure blob management for IPC, keys, sockets. Patch 06 Fixes Smack'ssk_freehook.
Patch 07 Support mount options for multiple security modules. Patch 08 Change secids from a u32 to a structure.
Patch 09 Netlabel consistency enforcment in sendmsg. Patch 10 Fixes a compile issue in one Smack configuration. Patch 11 Infrastructure blob management for the new task blob.These patches can be found in git at:
https://github.com/cschaufler/smack-next.git#stacking-4.11-rc4Signed-off-by Casey Schaufler <[email protected]>---
Documentation/security/LSM.txt | 33 +- drivers/usb/core/devio.c | 13 +- fs/btrfs/super.c | 10 +- fs/proc/base.c | 96 ++- fs/proc/internal.h | 1 + fs/xattr.c | 6 +- include/linux/audit.h | 10 +- include/linux/cred.h | 3 +- include/linux/lsm_hooks.h | 76 ++- include/linux/sched/signal.h | 2 +- include/linux/security.h | 227 +++++-- include/net/flow.h | 5 +- include/net/netlabel.h | 16 +- include/net/scm.h | 4 +- kernel/audit.c | 25 +- kernel/audit.h | 9 +- kernel/auditfilter.c | 4 +- kernel/auditsc.c | 42 +- kernel/cred.c | 19 +- kernel/signal.c | 6 +- net/ipv4/cipso_ipv4.c | 5 +- net/ipv4/ip_sockglue.c | 6 +- net/netfilter/nf_conntrack_netlink.c | 12 +- net/netfilter/nf_conntrack_standalone.c | 6 +- net/netfilter/nfnetlink_queue.c | 9 +- net/netfilter/xt_AUDIT.c | 9 +- net/netfilter/xt_SECMARK.c | 6 +- net/netlabel/netlabel_kapi.c | 56 +- net/netlabel/netlabel_unlabeled.c | 30 +- net/netlabel/netlabel_unlabeled.h | 2 +- net/netlabel/netlabel_user.c | 4 +- net/unix/af_unix.c | 6 +- net/xfrm/xfrm_policy.c | 6 +- net/xfrm/xfrm_state.c | 3 +- security/Kconfig | 86 +++ security/apparmor/context.c | 2 - security/apparmor/include/context.h | 25 +- security/apparmor/lsm.c | 111 ++-- security/integrity/ima/ima_policy.c | 7 +- security/security.c | 1046 +++++++++++++++++++++++++++++-- security/selinux/hooks.c | 720 +++++++++------------ security/selinux/include/audit.h | 2 +- security/selinux/include/objsec.h | 87 ++- security/selinux/include/xfrm.h | 9 +- security/selinux/netlabel.c | 17 +- security/selinux/selinuxfs.c | 5 +- security/selinux/ss/services.c | 13 +- security/selinux/xfrm.c | 29 +- security/smack/smack.h | 95 ++- security/smack/smack_access.c | 2 +- security/smack/smack_lsm.c | 751 +++++++++----------Quoted 8 lines
--- security/smack/smack_netfilter.c | 28 +- security/smack/smackfs.c | 28 +- security/tomoyo/common.h | 25 +- security/tomoyo/domain.c | 4 +- security/tomoyo/securityfs_if.c | 13 +- security/tomoyo/tomoyo.c | 55 +- 57 files changed, 2647 insertions(+), 1280 deletions(-)
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
cover LSM: Stacking for major security modules
Quoted 76 lines · Casey Schaufler
Quoted 65 lines · Stephen Smalley
Quoted 54 lines · Casey Schaufler
Subject: [PATCH RFC 00/11] LSM: Stacking for major security modules
I am again sending this as an RFC. If you stop at patch 04 you can
use any combination of modules so long as you use only one of SELinux and Smack. Patches 05-10 take you most of the way to complete
stacking, but cannot be said to completely address all the issues.
Patch 11 provides for management of the yet unused task blob.This patch set implements stacking for "major" security modules that use cred and file blobs. Management of security blobs is moved from the security modules and into the LSM infrastructure. This has been proposed in the past by Serge Hallyn and David Howells.
This implementation owes much to their work.The bulk of the change is in abstracting use of blobs within the security modules. This allows the modules to share a single blob and hides the details from the code. There is?
Modules are required to declare the amount of space they require for each blob they use. Because modules deal with blobs during their
initialization the blob sizes must be declared prior to module initialization. The module initialization becomes a two step process.Security module stacking is optional. If stacking is not configured,
theCONFIG_DEFAULT_SECURITYvalue is used, just as before. If stacking
is configured usingCONFIG_SECURITY_STACKINGthe modules desired for
the stack are selected individually. AppArmor would be selected by
specifyingCONFIG_SECURITY_APPARMOR_STACKED. TheCONFIG_DEFAULT_SECURITY
is ignored. The security= boot option is still respected and has the
same behavior as before, allowing a single module to be used instead
of
the specified stack.To accommodate multiple active modules a security "context" is defined to use a regular format:
lsmname='lsmvalue'[,lsmname='lsmvalue']...This is not supported by any existing user space run time code.
Quoted 9 lines
I have tested these patches in various configurations of Ubuntu and
Fedora. I have had much better success with SELinux in permissive mode
than enforcing, but that appears to be a result of user space code
issues. Smack and SELinux together have limited success, again because
of the context format.Quoted 3 lines
I think in order for this to be viable, it must not break existing userspace if
CONFIG_SECURITY_STACKING=yif only one module is enabled.If there's only one module enabled you don't need
CONFIG_SECURITY_STACKING=y. Nonetheless, I see the point. It's lots cleaner if this can be a compile time difference rather than something detected at run time, but I'll factor that in to the next version.
Quoted 8 lines
Quoted 5 lines
?Ideally, it wouldn't even break existing userspace with multiple modules, so long as they do not conflict in their usage of userspace
APIs (e.g. if only one implementsgetpeersec_stream, why mutate its result and break userspace?).Remember that
"system_u:object_r:netlabel_peer_t:s0" is a legitimate Smack label.
That's only a problem if they both return a result from getpeersec_stream (true for Smack+SELinux, false for Smack+TOMOYO). So determining whether there is more than one enabled module that implements getpeersec_stream is sufficient to decide whether you need to disambiguate the label for SO_PEERSEC.
Quoted 6 lines
I don't think doing "System" vs "selinux='system_u:object_r:netlabel_peer_t:s0',smack='System'" on a per-API granularity is a good idea. The author of user space code oughtn't be compelled to figure out which APIs will identity the components and when they don't which security module will provide the unadorned data.
You're already leaving /proc/self/attr/current alone for compatibility reasons, so not clear this is fundamentally different (except maybe you don't think you can introduce a new socket option to get the "full" context as easily as you can add a new proc node). If you don't want to do it piecemeal, then you could just specify which module gets ownership of all of the userspace APIs via a config option or something.
Quoted 4 lines
At some point it would be a good idea to have a liblsm that would make varying and/or multiple security modules easier to deal with. I know systemd and dbus could use such a library to good effect.
Yes, but in the meantime, if you want to be able to test CONFIG_SECURITY_STACKING=y with modules in enforcing mode on distributions that enable a major security module, it seems like you need to provide some way of handling this compatibly.
Quoted 17 lines
Quoted 5 lines
At present, it breaks the selinux-testsuite even with
CONFIG_SECURITY_STACKING=n, all in theinet_sockettests; looks like
network labeling is broken.??FWIW, output was:Thanks for running the tests. I'll be looking into this soonest.
Quoted 8 lines
inet_socket/test ............ getsockopt:
SO_PEERSEC: Protocol not available
read: Connection reset by peer
inet_socket/test ............ 1/33?
#???Failed test at inet_socket/test line 27. inet_socket/client:??expected unconfined_u:unconfined_r:test_inet_client_t:s0-s0:c0.c1023, got?
Quoted 1 line
I'd be interested to see what it got.
It was an empty string, because the server didn't get a label.
Quoted 105 lines
Quoted 105 lines
inet_socket/test ............ 3/33?
#???Failed test at inet_socket/test line 45.
inet_socket/test ............ 26/33?
#???Failed test at inet_socket/test line 219.#???Failed test at inet_socket/test line 227.
inet_socket/test ............ 30/33?
#???Failed test at inet_socket/test line 245.#???Failed test at inet_socket/test line 253.
# Looks like you failed 6 tests of 33.
inet_socket/test ............ Dubious, test returned 6 (wstat 1536,0x600)
Failed 6/33 subtestsThese all pass on security-next and on v4.11-rc4, so it is definitely
something in your patches.?Quoted 84 lines
Patch 01 Adds a smack subdirectory in
/proc/.../attr(proposed separately)
Patch 02 Move management of the cred blob to the LSM infrastructure.
Patch 03 Move management of the file blob to the LSM infrastructure.
Patch 04 Change how the security modules get selected. Patch 05 Infrastructure blob management for IPC, keys, sockets. Patch 06 Fixes Smack'ssk_freehook.
Patch 07 Support mount options for multiple security modules. Patch 08 Change secids from a u32 to a structure. Patch 09 Netlabel consistency enforcment in sendmsg. Patch 10 Fixes a compile issue in one Smack configuration. Patch 11 Infrastructure blob management for the new task blob.These patches can be found in git at:
https://github.com/cschaufler/smack-next.git#stacking-4.11-rc4Signed-off-by Casey Schaufler <[email protected]>---
?Documentation/security/LSM.txt??????????|???33 +- ?drivers/usb/core/devio.c????????????????|???13 +- ?fs/btrfs/super.c????????????????????????|???10 +- ?fs/proc/base.c??????????????????????????|???96 ++- ?fs/proc/internal.h??????????????????????|????1 + ?fs/xattr.c??????????????????????????????|????6 +- ?include/linux/audit.h???????????????????|???10 +- ?include/linux/cred.h????????????????????|????3 +- ?include/linux/lsm_hooks.h???????????????|???76 ++- ?include/linux/sched/signal.h????????????|????2 +- ?include/linux/security.h????????????????|??227 +++++-- ?include/net/flow.h??????????????????????|????5 +- ?include/net/netlabel.h??????????????????|???16 +- ?include/net/scm.h???????????????????????|????4 +- ?kernel/audit.c??????????????????????????|???25 +- ?kernel/audit.h??????????????????????????|????9 +- ?kernel/auditfilter.c????????????????????|????4 +- ?kernel/auditsc.c????????????????????????|???42 +- ?kernel/cred.c???????????????????????????|???19 +- ?kernel/signal.c?????????????????????????|????6 +- ?net/ipv4/cipso_ipv4.c???????????????????|????5 +- ?net/ipv4/ip_sockglue.c??????????????????|????6 +- ?net/netfilter/nf_conntrack_netlink.c????|???12 +- ?net/netfilter/nf_conntrack_standalone.c |????6 +- ?net/netfilter/nfnetlink_queue.c?????????|????9 +- ?net/netfilter/xt_AUDIT.c????????????????|????9 +- ?net/netfilter/xt_SECMARK.c??????????????|????6 +- ?net/netlabel/netlabel_kapi.c????????????|???56 +- ?net/netlabel/netlabel_unlabeled.c???????|???30 +- ?net/netlabel/netlabel_unlabeled.h???????|????2 +- ?net/netlabel/netlabel_user.c????????????|????4 +- ?net/unix/af_unix.c??????????????????????|????6 +- ?net/xfrm/xfrm_policy.c??????????????????|????6 +- ?net/xfrm/xfrm_state.c???????????????????|????3 +- ?security/Kconfig????????????????????????|???86 +++ ?security/apparmor/context.c?????????????|????2 - ?security/apparmor/include/context.h?????|???25 +- ?security/apparmor/lsm.c?????????????????|??111 ++-- ?security/integrity/ima/ima_policy.c?????|????7 +- ?security/security.c?????????????????????| 1046 +++++++++++++++++++++++++++++-- ?security/selinux/hooks.c????????????????|??720 +++++++++------ ------ ?security/selinux/include/audit.h????????|????2 +- ?security/selinux/include/objsec.h???????|???87 ++- ?security/selinux/include/xfrm.h?????????|????9 +- ?security/selinux/netlabel.c?????????????|???17 +- ?security/selinux/selinuxfs.c????????????|????5 +- ?security/selinux/ss/services.c??????????|???13 +- ?security/selinux/xfrm.c?????????????????|???29 +- ?security/smack/smack.h??????????????????|???95 ++- ?security/smack/smack_access.c???????????|????2 +- ?security/smack/smack_lsm.c??????????????|??751 +++++++++------ ---- --- ?security/smack/smack_netfilter.c????????|???28 +- ?security/smack/smackfs.c????????????????|???28 +- ?security/tomoyo/common.h????????????????|???25 +- ?security/tomoyo/domain.c????????????????|????4 +- ?security/tomoyo/securityfs_if.c?????????|???13 +- ?security/tomoyo/tomoyo.c????????????????|???55 +-?57 files changed, 2647 insertions(+), 1280 deletions(-)
Quoted 6 lines
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe linux- security-module" in
the body of a message to majordomo at vger.kernel.org More majordomo info at??http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
James Morris
maintainercover LSM: Stacking for major security modules
Quoted 4 lines · Stephen Smalley
Yes, but in the meantime, if you want to be able to test
CONFIG_SECURITY_STACKING=ywith modules in enforcing mode on distributions that enable a major security module, it seems like you need to provide some way of handling this compatibly.
Regardless of the config option, we can't break existing userspace. This is a long-standing Linux kernel development rule.
You'll need to implement new interfaces for any changes.
Signature · 7 lines
James Morris <[email protected]> -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Casey Schaufler
maintainercover LSM: Stacking for major security modules
Quoted 10 lines · James Morris
Quoted 4 lines · Stephen Smalley
Yes, but in the meantime, if you want to be able to test
CONFIG_SECURITY_STACKING=ywith modules in enforcing mode on distributions that enable a major security module, it seems like you need to provide some way of handling this compatibly.Regardless of the config option, we can't break existing userspace. This is a long-standing Linux kernel development rule.
You'll need to implement new interfaces for any changes.
The big question is SO_PEERSEC. SO_PEERSEC provides undefined "security credentials". You don't need to define a new interface here because the interface allows different configurations (e.g. Smack active, SELinux active, both active) to provide different information. The basic argument today is over whether
"System"
is preferred over
"smack='System'"
in the case where only Smack is enabled, and to what extent. The majority opinion seems to be that the self-identifying attribute should *never* be used unless there are in fact multiple modules providing data. I personally believe that this is short sighted and will discourage the development of run time environments that are capable of dealing with multiple concurrent security modules. But, I'm not going to let my own stubborn streak get in the way of progress.
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Paul Moore
maintainercover LSM: Stacking for major security modules
Quoted 10 lines · Casey Schaufler
Quoted 9 lines · James Morris
Quoted 4 lines · Stephen Smalley
Yes, but in the meantime, if you want to be able to test
CONFIG_SECURITY_STACKING=ywith modules in enforcing mode on distributions that enable a major security module, it seems like you need to provide some way of handling this compatibly.Regardless of the config option, we can't break existing userspace. This is a long-standing Linux kernel development rule.
Quoted 7 lines
Quoted 1 line
You'll need to implement new interfaces for any changes.
The big question is
SO_PEERSEC.SO_PEERSECprovides undefined "security credentials". You don't need to define a new interface here because the interface allows different configurations (e.g. Smack active, SELinux active, both active) to provide different information.
Just a gentle reminder that ignoring existing conventions because the formal (?) specification declares the interface as "undefined" is a really good way to break userspace :)
In all seriousness, a new interface with a well defined specification that could support multiple labels/LSM might not be a bad idea if for no other reason that what we currently have is a bit broken, but works due to dumb luck (see the discussion in the GH issue below).
https://github.com/SELinuxProject/selinux-kernel/issues/24
Signature · 6 lines
paul moore www.paul-moore.com -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Casey Schaufler
maintainercover LSM: Stacking for major security modules
Quoted 12 lines · Paul Moore
Quoted 11 lines · Casey Schaufler
Quoted 10 lines · James Morris
Quoted 4 lines · Stephen Smalley
Yes, but in the meantime, if you want to be able to test
CONFIG_SECURITY_STACKING=ywith modules in enforcing mode on distributions that enable a major security module, it seems like you need to provide some way of handling this compatibly.Regardless of the config option, we can't break existing userspace. This is a long-standing Linux kernel development rule.
You'll need to implement new interfaces for any changes.
Quoted 8 lines
Quoted 5 lines
The big question is
SO_PEERSEC.SO_PEERSECprovides undefined "security credentials". You don't need to define a new interface here because the interface allows different configurations (e.g. Smack active, SELinux active, both active) to provide different information.Just a gentle reminder that ignoring existing conventions because the formal (?) specification declares the interface as "undefined" is a really good way to break userspace :)
Indeed. That's the lesson of /proc/.../attr/current. I should *never* have reused that for Smack. Even the rationale that "id wouldn't have to change" was flawed because that program checks to see if SELinux is active and refuses to even look if it isn't.
Alas, there is going to be a balance between "break old" and "enable new". Of course we can create all new everything, but I'm not a fan of API bloat. It's good to keep getting feedback, even when I don't like it.
Quoted 7 lines
In all seriousness, a new interface with a well defined specification that could support multiple labels/LSM might not be a bad idea if for no other reason that what we currently have is a bit broken, but works due to dumb luck (see the discussion in the GH issue below).
Oh my. I thought the mechanism was sort of peculiar, but I wasn't really aware of all the details.
lsm_setsockattr(sock, "lsmname", "attrname", attr, attrlen);
lsm_getsockattr(sock, "lsmname" "attrname", attr, &attrlen);
These could be based on the current mechanisms or purpose written for a new world order. There'd also have to be something network magic-like for sendmsg() and recvmsg(). That's starting to sound like a lot of work.
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html