aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorJames Morris <jmorris@namei.org>2011-01-09 17:46:24 -0500
committerJames Morris <jmorris@namei.org>2011-01-09 17:46:24 -0500
commitd2e7ad19229f982fc1eb731827d82ceac90abfb3 (patch)
tree98a3741b4d4b27a48b3c7ea9babe331e539416a8 /security
parentd03a5d888fb688c832d470b749acc5ed38e0bc1d (diff)
parent0c21e3aaf6ae85bee804a325aa29c325209180fd (diff)
Merge branch 'master' into next
Conflicts: security/smack/smack_lsm.c Verified and added fix by Stephen Rothwell <sfr@canb.auug.org.au> Ok'd by Casey Schaufler <casey@schaufler-ca.com> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security')
-rw-r--r--security/capability.c2
-rw-r--r--security/integrity/ima/ima_policy.c2
-rw-r--r--security/keys/request_key.c1
-rw-r--r--security/security.c12
-rw-r--r--security/selinux/hooks.c22
-rw-r--r--security/selinux/selinuxfs.c16
-rw-r--r--security/smack/smack_lsm.c14
-rw-r--r--security/tomoyo/realpath.c1
8 files changed, 42 insertions, 28 deletions
diff --git a/security/capability.c b/security/capability.c
index c773635ca3a0..2a5df2b7da83 100644
--- a/security/capability.c
+++ b/security/capability.c
@@ -548,7 +548,7 @@ static int cap_sem_semop(struct sem_array *sma, struct sembuf *sops,
548} 548}
549 549
550#ifdef CONFIG_SECURITY_NETWORK 550#ifdef CONFIG_SECURITY_NETWORK
551static int cap_unix_stream_connect(struct socket *sock, struct socket *other, 551static int cap_unix_stream_connect(struct sock *sock, struct sock *other,
552 struct sock *newsk) 552 struct sock *newsk)
553{ 553{
554 return 0; 554 return 0;
diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
index aef8c0a923ab..d661afbe474c 100644
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -253,6 +253,8 @@ static int ima_lsm_rule_init(struct ima_measure_rule_entry *entry,
253 result = security_filter_rule_init(entry->lsm[lsm_rule].type, 253 result = security_filter_rule_init(entry->lsm[lsm_rule].type,
254 Audit_equal, args, 254 Audit_equal, args,
255 &entry->lsm[lsm_rule].rule); 255 &entry->lsm[lsm_rule].rule);
256 if (!entry->lsm[lsm_rule].rule)
257 return -EINVAL;
256 return result; 258 return result;
257} 259}
258 260
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 0088dd8bf68a..0ea52d25a6bd 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -403,7 +403,6 @@ link_check_failed:
403 return ret; 403 return ret;
404 404
405link_prealloc_failed: 405link_prealloc_failed:
406 up_write(&dest_keyring->sem);
407 mutex_unlock(&user->cons_lock); 406 mutex_unlock(&user->cons_lock);
408 kleave(" = %d [prelink]", ret); 407 kleave(" = %d [prelink]", ret);
409 return ret; 408 return ret;
diff --git a/security/security.c b/security/security.c
index 1b798d3df710..739e40362f44 100644
--- a/security/security.c
+++ b/security/security.c
@@ -513,6 +513,15 @@ int security_inode_permission(struct inode *inode, int mask)
513 return security_ops->inode_permission(inode, mask); 513 return security_ops->inode_permission(inode, mask);
514} 514}
515 515
516int security_inode_exec_permission(struct inode *inode, unsigned int flags)
517{
518 if (unlikely(IS_PRIVATE(inode)))
519 return 0;
520 if (flags)
521 return -ECHILD;
522 return security_ops->inode_permission(inode, MAY_EXEC);
523}
524
516int security_inode_setattr(struct dentry *dentry, struct iattr *attr) 525int security_inode_setattr(struct dentry *dentry, struct iattr *attr)
517{ 526{
518 if (unlikely(IS_PRIVATE(dentry->d_inode))) 527 if (unlikely(IS_PRIVATE(dentry->d_inode)))
@@ -977,8 +986,7 @@ EXPORT_SYMBOL(security_inode_getsecctx);
977 986
978#ifdef CONFIG_SECURITY_NETWORK 987#ifdef CONFIG_SECURITY_NETWORK
979 988
980int security_unix_stream_connect(struct socket *sock, struct socket *other, 989int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk)
981 struct sock *newsk)
982{ 990{
983 return security_ops->unix_stream_connect(sock, other, newsk); 991 return security_ops->unix_stream_connect(sock, other, newsk);
984} 992}
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 65fa8bf596f5..6f637d2678ac 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3921,18 +3921,18 @@ static int selinux_socket_shutdown(struct socket *sock, int how)
3921 return sock_has_perm(current, sock->sk, SOCKET__SHUTDOWN); 3921 return sock_has_perm(current, sock->sk, SOCKET__SHUTDOWN);
3922} 3922}
3923 3923
3924static int selinux_socket_unix_stream_connect(struct socket *sock, 3924static int selinux_socket_unix_stream_connect(struct sock *sock,
3925 struct socket *other, 3925 struct sock *other,
3926 struct sock *newsk) 3926 struct sock *newsk)
3927{ 3927{
3928 struct sk_security_struct *sksec_sock = sock->sk->sk_security; 3928 struct sk_security_struct *sksec_sock = sock->sk_security;
3929 struct sk_security_struct *sksec_other = other->sk->sk_security; 3929 struct sk_security_struct *sksec_other = other->sk_security;
3930 struct sk_security_struct *sksec_new = newsk->sk_security; 3930 struct sk_security_struct *sksec_new = newsk->sk_security;
3931 struct common_audit_data ad; 3931 struct common_audit_data ad;
3932 int err; 3932 int err;
3933 3933
3934 COMMON_AUDIT_DATA_INIT(&ad, NET); 3934 COMMON_AUDIT_DATA_INIT(&ad, NET);
3935 ad.u.net.sk = other->sk; 3935 ad.u.net.sk = other;
3936 3936
3937 err = avc_has_perm(sksec_sock->sid, sksec_other->sid, 3937 err = avc_has_perm(sksec_sock->sid, sksec_other->sid,
3938 sksec_other->sclass, 3938 sksec_other->sclass,
@@ -4520,11 +4520,11 @@ static unsigned int selinux_ip_postroute_compat(struct sk_buff *skb,
4520 if (selinux_secmark_enabled()) 4520 if (selinux_secmark_enabled())
4521 if (avc_has_perm(sksec->sid, skb->secmark, 4521 if (avc_has_perm(sksec->sid, skb->secmark,
4522 SECCLASS_PACKET, PACKET__SEND, &ad)) 4522 SECCLASS_PACKET, PACKET__SEND, &ad))
4523 return NF_DROP; 4523 return NF_DROP_ERR(-ECONNREFUSED);
4524 4524
4525 if (selinux_policycap_netpeer) 4525 if (selinux_policycap_netpeer)
4526 if (selinux_xfrm_postroute_last(sksec->sid, skb, &ad, proto)) 4526 if (selinux_xfrm_postroute_last(sksec->sid, skb, &ad, proto))
4527 return NF_DROP; 4527 return NF_DROP_ERR(-ECONNREFUSED);
4528 4528
4529 return NF_ACCEPT; 4529 return NF_ACCEPT;
4530} 4530}
@@ -4581,7 +4581,7 @@ static unsigned int selinux_ip_postroute(struct sk_buff *skb, int ifindex,
4581 secmark_perm = PACKET__SEND; 4581 secmark_perm = PACKET__SEND;
4582 break; 4582 break;
4583 default: 4583 default:
4584 return NF_DROP; 4584 return NF_DROP_ERR(-ECONNREFUSED);
4585 } 4585 }
4586 if (secmark_perm == PACKET__FORWARD_OUT) { 4586 if (secmark_perm == PACKET__FORWARD_OUT) {
4587 if (selinux_skb_peerlbl_sid(skb, family, &peer_sid)) 4587 if (selinux_skb_peerlbl_sid(skb, family, &peer_sid))
@@ -4603,7 +4603,7 @@ static unsigned int selinux_ip_postroute(struct sk_buff *skb, int ifindex,
4603 if (secmark_active) 4603 if (secmark_active)
4604 if (avc_has_perm(peer_sid, skb->secmark, 4604 if (avc_has_perm(peer_sid, skb->secmark,
4605 SECCLASS_PACKET, secmark_perm, &ad)) 4605 SECCLASS_PACKET, secmark_perm, &ad))
4606 return NF_DROP; 4606 return NF_DROP_ERR(-ECONNREFUSED);
4607 4607
4608 if (peerlbl_active) { 4608 if (peerlbl_active) {
4609 u32 if_sid; 4609 u32 if_sid;
@@ -4613,13 +4613,13 @@ static unsigned int selinux_ip_postroute(struct sk_buff *skb, int ifindex,
4613 return NF_DROP; 4613 return NF_DROP;
4614 if (avc_has_perm(peer_sid, if_sid, 4614 if (avc_has_perm(peer_sid, if_sid,
4615 SECCLASS_NETIF, NETIF__EGRESS, &ad)) 4615 SECCLASS_NETIF, NETIF__EGRESS, &ad))
4616 return NF_DROP; 4616 return NF_DROP_ERR(-ECONNREFUSED);
4617 4617
4618 if (sel_netnode_sid(addrp, family, &node_sid)) 4618 if (sel_netnode_sid(addrp, family, &node_sid))
4619 return NF_DROP; 4619 return NF_DROP;
4620 if (avc_has_perm(peer_sid, node_sid, 4620 if (avc_has_perm(peer_sid, node_sid,
4621 SECCLASS_NODE, NODE__SENDTO, &ad)) 4621 SECCLASS_NODE, NODE__SENDTO, &ad))
4622 return NF_DROP; 4622 return NF_DROP_ERR(-ECONNREFUSED);
4623 } 4623 }
4624 4624
4625 return NF_ACCEPT; 4625 return NF_ACCEPT;
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 073fd5b0a53a..43deac219491 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -1145,24 +1145,28 @@ static void sel_remove_entries(struct dentry *de)
1145{ 1145{
1146 struct list_head *node; 1146 struct list_head *node;
1147 1147
1148 spin_lock(&dcache_lock); 1148 spin_lock(&de->d_lock);
1149 node = de->d_subdirs.next; 1149 node = de->d_subdirs.next;
1150 while (node != &de->d_subdirs) { 1150 while (node != &de->d_subdirs) {
1151 struct dentry *d = list_entry(node, struct dentry, d_u.d_child); 1151 struct dentry *d = list_entry(node, struct dentry, d_u.d_child);
1152
1153 spin_lock_nested(&d->d_lock, DENTRY_D_LOCK_NESTED);
1152 list_del_init(node); 1154 list_del_init(node);
1153 1155
1154 if (d->d_inode) { 1156 if (d->d_inode) {
1155 d = dget_locked(d); 1157 dget_dlock(d);
1156 spin_unlock(&dcache_lock); 1158 spin_unlock(&de->d_lock);
1159 spin_unlock(&d->d_lock);
1157 d_delete(d); 1160 d_delete(d);
1158 simple_unlink(de->d_inode, d); 1161 simple_unlink(de->d_inode, d);
1159 dput(d); 1162 dput(d);
1160 spin_lock(&dcache_lock); 1163 spin_lock(&de->d_lock);
1161 } 1164 } else
1165 spin_unlock(&d->d_lock);
1162 node = de->d_subdirs.next; 1166 node = de->d_subdirs.next;
1163 } 1167 }
1164 1168
1165 spin_unlock(&dcache_lock); 1169 spin_unlock(&de->d_lock);
1166} 1170}
1167 1171
1168#define BOOL_DIR_NAME "booleans" 1172#define BOOL_DIR_NAME "booleans"
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 05dc4da2e25f..533bf3255d7f 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -2527,23 +2527,23 @@ static int smack_setprocattr(struct task_struct *p, char *name,
2527 2527
2528/** 2528/**
2529 * smack_unix_stream_connect - Smack access on UDS 2529 * smack_unix_stream_connect - Smack access on UDS
2530 * @sock: one socket 2530 * @sock: one sock
2531 * @other: the other socket 2531 * @other: the other sock
2532 * @newsk: unused 2532 * @newsk: unused
2533 * 2533 *
2534 * Return 0 if a subject with the smack of sock could access 2534 * Return 0 if a subject with the smack of sock could access
2535 * an object with the smack of other, otherwise an error code 2535 * an object with the smack of other, otherwise an error code
2536 */ 2536 */
2537static int smack_unix_stream_connect(struct socket *sock, 2537static int smack_unix_stream_connect(struct sock *sock,
2538 struct socket *other, struct sock *newsk) 2538 struct sock *other, struct sock *newsk)
2539{ 2539{
2540 struct socket_smack *ssp = sock->sk->sk_security; 2540 struct socket_smack *ssp = sock->sk_security;
2541 struct socket_smack *osp = other->sk->sk_security; 2541 struct socket_smack *osp = other->sk_security;
2542 struct smk_audit_info ad; 2542 struct smk_audit_info ad;
2543 int rc = 0; 2543 int rc = 0;
2544 2544
2545 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_NET); 2545 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_NET);
2546 smk_ad_setfield_u_net_sk(&ad, other->sk); 2546 smk_ad_setfield_u_net_sk(&ad, other);
2547 2547
2548 if (!capable(CAP_MAC_OVERRIDE)) 2548 if (!capable(CAP_MAC_OVERRIDE))
2549 rc = smk_access(ssp->smk_out, osp->smk_in, MAY_WRITE, &ad); 2549 rc = smk_access(ssp->smk_out, osp->smk_in, MAY_WRITE, &ad);
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c
index 1d0bf8fa1922..d1e05b047715 100644
--- a/security/tomoyo/realpath.c
+++ b/security/tomoyo/realpath.c
@@ -14,6 +14,7 @@
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <net/sock.h> 15#include <net/sock.h>
16#include "common.h" 16#include "common.h"
17#include "../../fs/internal.h"
17 18
18/** 19/**
19 * tomoyo_encode: Convert binary string to ascii string. 20 * tomoyo_encode: Convert binary string to ascii string.