summaryrefslogtreecommitdiffstats
path: root/security/security.c
diff options
context:
space:
mode:
authorCasey Schaufler <casey@schaufler-ca.com>2018-09-21 20:16:59 -0400
committerKees Cook <keescook@chromium.org>2019-01-08 16:18:44 -0500
commit6d9c939dbe4d0bcea09cd4b410f624cde1acb678 (patch)
tree1388ba40fc9bf6a8274fb807fe83c8a8e225b4c5 /security/security.c
parentd117a154e6128abac5409d3f173584e7b25981a2 (diff)
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. The proposed S.A.R.A security module is dependent on the mechanism to create its own attr subdirectory. The original implementation is by Kees Cook. Signed-off-by: Casey Schaufler <casey@schaufler-ca.com> Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'security/security.c')
-rw-r--r--security/security.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/security/security.c b/security/security.c
index 9411f659454b..60b39db95c2f 100644
--- a/security/security.c
+++ b/security/security.c
@@ -1485,14 +1485,30 @@ void security_d_instantiate(struct dentry *dentry, struct inode *inode)
1485} 1485}
1486EXPORT_SYMBOL(security_d_instantiate); 1486EXPORT_SYMBOL(security_d_instantiate);
1487 1487
1488int security_getprocattr(struct task_struct *p, char *name, char **value) 1488int security_getprocattr(struct task_struct *p, const char *lsm, char *name,
1489 char **value)
1489{ 1490{
1490 return call_int_hook(getprocattr, -EINVAL, p, name, value); 1491 struct security_hook_list *hp;
1492
1493 hlist_for_each_entry(hp, &security_hook_heads.getprocattr, list) {
1494 if (lsm != NULL && strcmp(lsm, hp->lsm))
1495 continue;
1496 return hp->hook.getprocattr(p, name, value);
1497 }
1498 return -EINVAL;
1491} 1499}
1492 1500
1493int security_setprocattr(const char *name, void *value, size_t size) 1501int security_setprocattr(const char *lsm, const char *name, void *value,
1502 size_t size)
1494{ 1503{
1495 return call_int_hook(setprocattr, -EINVAL, name, value, size); 1504 struct security_hook_list *hp;
1505
1506 hlist_for_each_entry(hp, &security_hook_heads.setprocattr, list) {
1507 if (lsm != NULL && strcmp(lsm, hp->lsm))
1508 continue;
1509 return hp->hook.setprocattr(name, value, size);
1510 }
1511 return -EINVAL;
1496} 1512}
1497 1513
1498int security_netlink_send(struct sock *sk, struct sk_buff *skb) 1514int security_netlink_send(struct sock *sk, struct sk_buff *skb)