aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2011-05-26 17:20:14 -0400
committerEric Paris <eparis@redhat.com>2011-05-26 17:20:14 -0400
commitea77f7a2e8561012cf100c530170f12351c3b53e (patch)
tree7302ac1064f4e364aadda84020a176804fb86e22 /security/selinux
parent7a627e3b9a2bd0f06945bbe64bcf403e788ecf6e (diff)
parent61c4f2c81c61f73549928dfd9f3e8f26aa36a8cf (diff)
Merge commit 'v2.6.39' into 20110526
Conflicts: lib/flex_array.c security/selinux/avc.c security/selinux/hooks.c security/selinux/ss/policydb.c security/smack/smack_lsm.c
Diffstat (limited to 'security/selinux')
-rw-r--r--security/selinux/hooks.c23
-rw-r--r--security/selinux/include/xfrm.h2
-rw-r--r--security/selinux/netlabel.c2
-rw-r--r--security/selinux/ss/services.c4
-rw-r--r--security/selinux/xfrm.c6
5 files changed, 21 insertions, 16 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 9f426b8a12b5..a0d38459d650 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -79,6 +79,7 @@
79#include <linux/mutex.h> 79#include <linux/mutex.h>
80#include <linux/posix-timers.h> 80#include <linux/posix-timers.h>
81#include <linux/syslog.h> 81#include <linux/syslog.h>
82#include <linux/user_namespace.h>
82 83
83#include "avc.h" 84#include "avc.h"
84#include "objsec.h" 85#include "objsec.h"
@@ -1866,11 +1867,11 @@ static int selinux_capset(struct cred *new, const struct cred *old,
1866 */ 1867 */
1867 1868
1868static int selinux_capable(struct task_struct *tsk, const struct cred *cred, 1869static int selinux_capable(struct task_struct *tsk, const struct cred *cred,
1869 int cap, int audit) 1870 struct user_namespace *ns, int cap, int audit)
1870{ 1871{
1871 int rc; 1872 int rc;
1872 1873
1873 rc = cap_capable(tsk, cred, cap, audit); 1874 rc = cap_capable(tsk, cred, ns, cap, audit);
1874 if (rc) 1875 if (rc)
1875 return rc; 1876 return rc;
1876 1877
@@ -1951,7 +1952,8 @@ static int selinux_vm_enough_memory(struct mm_struct *mm, long pages)
1951{ 1952{
1952 int rc, cap_sys_admin = 0; 1953 int rc, cap_sys_admin = 0;
1953 1954
1954 rc = selinux_capable(current, current_cred(), CAP_SYS_ADMIN, 1955 rc = selinux_capable(current, current_cred(),
1956 &init_user_ns, CAP_SYS_ADMIN,
1955 SECURITY_CAP_NOAUDIT); 1957 SECURITY_CAP_NOAUDIT);
1956 if (rc == 0) 1958 if (rc == 0)
1957 cap_sys_admin = 1; 1959 cap_sys_admin = 1;
@@ -2746,7 +2748,7 @@ static int selinux_inode_setxattr(struct dentry *dentry, const char *name,
2746 if (!(sbsec->flags & SE_SBLABELSUPP)) 2748 if (!(sbsec->flags & SE_SBLABELSUPP))
2747 return -EOPNOTSUPP; 2749 return -EOPNOTSUPP;
2748 2750
2749 if (!is_owner_or_cap(inode)) 2751 if (!inode_owner_or_capable(inode))
2750 return -EPERM; 2752 return -EPERM;
2751 2753
2752 COMMON_AUDIT_DATA_INIT(&ad, DENTRY); 2754 COMMON_AUDIT_DATA_INIT(&ad, DENTRY);
@@ -2857,7 +2859,8 @@ static int selinux_inode_getsecurity(const struct inode *inode, const char *name
2857 * and lack of permission just means that we fall back to the 2859 * and lack of permission just means that we fall back to the
2858 * in-core context value, not a denial. 2860 * in-core context value, not a denial.
2859 */ 2861 */
2860 error = selinux_capable(current, current_cred(), CAP_MAC_ADMIN, 2862 error = selinux_capable(current, current_cred(),
2863 &init_user_ns, CAP_MAC_ADMIN,
2861 SECURITY_CAP_NOAUDIT); 2864 SECURITY_CAP_NOAUDIT);
2862 if (!error) 2865 if (!error)
2863 error = security_sid_to_context_force(isec->sid, &context, 2866 error = security_sid_to_context_force(isec->sid, &context,
@@ -2991,7 +2994,7 @@ static int selinux_file_ioctl(struct file *file, unsigned int cmd,
2991 case KDSKBENT: 2994 case KDSKBENT:
2992 case KDSKBSENT: 2995 case KDSKBSENT:
2993 error = task_has_capability(current, cred, CAP_SYS_TTY_CONFIG, 2996 error = task_has_capability(current, cred, CAP_SYS_TTY_CONFIG,
2994 SECURITY_CAP_AUDIT); 2997 SECURITY_CAP_AUDIT);
2995 break; 2998 break;
2996 2999
2997 /* default case assumes that the command will go 3000 /* default case assumes that the command will go
@@ -4369,7 +4372,7 @@ static void selinux_secmark_refcount_dec(void)
4369static void selinux_req_classify_flow(const struct request_sock *req, 4372static void selinux_req_classify_flow(const struct request_sock *req,
4370 struct flowi *fl) 4373 struct flowi *fl)
4371{ 4374{
4372 fl->secid = req->secid; 4375 fl->flowi_secid = req->secid;
4373} 4376}
4374 4377
4375static int selinux_tun_dev_create(void) 4378static int selinux_tun_dev_create(void)
@@ -4718,6 +4721,7 @@ static int selinux_netlink_recv(struct sk_buff *skb, int capability)
4718{ 4721{
4719 int err; 4722 int err;
4720 struct common_audit_data ad; 4723 struct common_audit_data ad;
4724 u32 sid;
4721 4725
4722 err = cap_netlink_recv(skb, capability); 4726 err = cap_netlink_recv(skb, capability);
4723 if (err) 4727 if (err)
@@ -4726,8 +4730,9 @@ static int selinux_netlink_recv(struct sk_buff *skb, int capability)
4726 COMMON_AUDIT_DATA_INIT(&ad, CAP); 4730 COMMON_AUDIT_DATA_INIT(&ad, CAP);
4727 ad.u.cap = capability; 4731 ad.u.cap = capability;
4728 4732
4729 return avc_has_perm(NETLINK_CB(skb).sid, NETLINK_CB(skb).sid, 4733 security_task_getsecid(current, &sid);
4730 SECCLASS_CAPABILITY, CAP_TO_MASK(capability), &ad); 4734 return avc_has_perm(sid, sid, SECCLASS_CAPABILITY,
4735 CAP_TO_MASK(capability), &ad);
4731} 4736}
4732 4737
4733static int ipc_alloc_security(struct task_struct *task, 4738static int ipc_alloc_security(struct task_struct *task,
diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
index 13128f9a3e5a..b43813c9e049 100644
--- a/security/selinux/include/xfrm.h
+++ b/security/selinux/include/xfrm.h
@@ -19,7 +19,7 @@ void selinux_xfrm_state_free(struct xfrm_state *x);
19int selinux_xfrm_state_delete(struct xfrm_state *x); 19int selinux_xfrm_state_delete(struct xfrm_state *x);
20int selinux_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir); 20int selinux_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
21int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x, 21int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x,
22 struct xfrm_policy *xp, struct flowi *fl); 22 struct xfrm_policy *xp, const struct flowi *fl);
23 23
24/* 24/*
25 * Extract the security blob from the sock (it's actually on the socket) 25 * Extract the security blob from the sock (it's actually on the socket)
diff --git a/security/selinux/netlabel.c b/security/selinux/netlabel.c
index 1c2fc46544bf..c3bf3ed07b06 100644
--- a/security/selinux/netlabel.c
+++ b/security/selinux/netlabel.c
@@ -151,7 +151,7 @@ void selinux_netlbl_sk_security_free(struct sk_security_struct *sksec)
151 * 151 *
152 * Description: 152 * Description:
153 * Called when the NetLabel state of a sk_security_struct needs to be reset. 153 * Called when the NetLabel state of a sk_security_struct needs to be reset.
154 * The caller is responsibile for all the NetLabel sk_security_struct locking. 154 * The caller is responsible for all the NetLabel sk_security_struct locking.
155 * 155 *
156 */ 156 */
157void selinux_netlbl_sk_security_reset(struct sk_security_struct *sksec) 157void selinux_netlbl_sk_security_reset(struct sk_security_struct *sksec)
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index e11b4b038f4a..c3e4b52699f4 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -2814,7 +2814,7 @@ int selinux_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule)
2814 case AUDIT_SUBJ_CLR: 2814 case AUDIT_SUBJ_CLR:
2815 case AUDIT_OBJ_LEV_LOW: 2815 case AUDIT_OBJ_LEV_LOW:
2816 case AUDIT_OBJ_LEV_HIGH: 2816 case AUDIT_OBJ_LEV_HIGH:
2817 /* we do not allow a range, indicated by the presense of '-' */ 2817 /* we do not allow a range, indicated by the presence of '-' */
2818 if (strchr(rulestr, '-')) 2818 if (strchr(rulestr, '-'))
2819 return -EINVAL; 2819 return -EINVAL;
2820 break; 2820 break;
@@ -3083,7 +3083,7 @@ static void security_netlbl_cache_add(struct netlbl_lsm_secattr *secattr,
3083 * Description: 3083 * Description:
3084 * Convert the given NetLabel security attributes in @secattr into a 3084 * Convert the given NetLabel security attributes in @secattr into a
3085 * SELinux SID. If the @secattr field does not contain a full SELinux 3085 * SELinux SID. If the @secattr field does not contain a full SELinux
3086 * SID/context then use SECINITSID_NETMSG as the foundation. If possibile the 3086 * SID/context then use SECINITSID_NETMSG as the foundation. If possible the
3087 * 'cache' field of @secattr is set and the CACHE flag is set; this is to 3087 * 'cache' field of @secattr is set and the CACHE flag is set; this is to
3088 * allow the @secattr to be used by NetLabel to cache the secattr to SID 3088 * allow the @secattr to be used by NetLabel to cache the secattr to SID
3089 * conversion for future lookups. Returns zero on success, negative values on 3089 * conversion for future lookups. Returns zero on success, negative values on
diff --git a/security/selinux/xfrm.c b/security/selinux/xfrm.c
index 728c57e3d65d..68178b76a2b3 100644
--- a/security/selinux/xfrm.c
+++ b/security/selinux/xfrm.c
@@ -112,7 +112,7 @@ int selinux_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir)
112 */ 112 */
113 113
114int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x, struct xfrm_policy *xp, 114int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x, struct xfrm_policy *xp,
115 struct flowi *fl) 115 const struct flowi *fl)
116{ 116{
117 u32 state_sid; 117 u32 state_sid;
118 int rc; 118 int rc;
@@ -135,10 +135,10 @@ int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x, struct xfrm_policy *
135 135
136 state_sid = x->security->ctx_sid; 136 state_sid = x->security->ctx_sid;
137 137
138 if (fl->secid != state_sid) 138 if (fl->flowi_secid != state_sid)
139 return 0; 139 return 0;
140 140
141 rc = avc_has_perm(fl->secid, state_sid, SECCLASS_ASSOCIATION, 141 rc = avc_has_perm(fl->flowi_secid, state_sid, SECCLASS_ASSOCIATION,
142 ASSOCIATION__SENDTO, 142 ASSOCIATION__SENDTO,
143 NULL)? 0:1; 143 NULL)? 0:1;
144 144