aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux/hooks.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-14 21:36:33 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-14 21:36:33 -0500
commitc49c41a4134679cecb77362e7f6b59acb6320aa7 (patch)
tree45e690c036ca5846a48c8be67945d1d841b2d96d /security/selinux/hooks.c
parent892d208bcf79e4e1058707786a7b6d486697cd78 (diff)
parentf423e5ba76e7e4a6fcb4836b4f072d1fdebba8b5 (diff)
Merge branch 'for-linus' of git://selinuxproject.org/~jmorris/linux-security
* 'for-linus' of git://selinuxproject.org/~jmorris/linux-security: capabilities: remove __cap_full_set definition security: remove the security_netlink_recv hook as it is equivalent to capable() ptrace: do not audit capability check when outputing /proc/pid/stat capabilities: remove task_ns_* functions capabitlies: ns_capable can use the cap helpers rather than lsm call capabilities: style only - move capable below ns_capable capabilites: introduce new has_ns_capabilities_noaudit capabilities: call has_ns_capability from has_capability capabilities: remove all _real_ interfaces capabilities: introduce security_capable_noaudit capabilities: reverse arguments to security_capable capabilities: remove the task from capable LSM hook entirely selinux: sparse fix: fix several warnings in the security server cod selinux: sparse fix: fix warnings in netlink code selinux: sparse fix: eliminate warnings for selinuxfs selinux: sparse fix: declare selinux_disable() in security.h selinux: sparse fix: move selinux_complete_init selinux: sparse fix: make selinux_secmark_refcount static SELinux: Fix RCU deref check warning in sel_netport_insert() Manually fix up a semantic mis-merge wrt security_netlink_recv(): - the interface was removed in commit fd7784615248 ("security: remove the security_netlink_recv hook as it is equivalent to capable()") - a new user of it appeared in commit a38f7907b926 ("crypto: Add userspace configuration API") causing no automatic merge conflict, but Eric Paris pointed out the issue.
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r--security/selinux/hooks.c44
1 files changed, 11 insertions, 33 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 7cd4c3affac8..6a3683e28426 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -1415,8 +1415,7 @@ static int current_has_perm(const struct task_struct *tsk,
1415#endif 1415#endif
1416 1416
1417/* Check whether a task is allowed to use a capability. */ 1417/* Check whether a task is allowed to use a capability. */
1418static int task_has_capability(struct task_struct *tsk, 1418static int cred_has_capability(const struct cred *cred,
1419 const struct cred *cred,
1420 int cap, int audit) 1419 int cap, int audit)
1421{ 1420{
1422 struct common_audit_data ad; 1421 struct common_audit_data ad;
@@ -1427,7 +1426,7 @@ static int task_has_capability(struct task_struct *tsk,
1427 int rc; 1426 int rc;
1428 1427
1429 COMMON_AUDIT_DATA_INIT(&ad, CAP); 1428 COMMON_AUDIT_DATA_INIT(&ad, CAP);
1430 ad.tsk = tsk; 1429 ad.tsk = current;
1431 ad.u.cap = cap; 1430 ad.u.cap = cap;
1432 1431
1433 switch (CAP_TO_INDEX(cap)) { 1432 switch (CAP_TO_INDEX(cap)) {
@@ -1811,7 +1810,7 @@ static int selinux_ptrace_access_check(struct task_struct *child,
1811 if (rc) 1810 if (rc)
1812 return rc; 1811 return rc;
1813 1812
1814 if (mode == PTRACE_MODE_READ) { 1813 if (mode & PTRACE_MODE_READ) {
1815 u32 sid = current_sid(); 1814 u32 sid = current_sid();
1816 u32 csid = task_sid(child); 1815 u32 csid = task_sid(child);
1817 return avc_has_perm(sid, csid, SECCLASS_FILE, FILE__READ, NULL); 1816 return avc_has_perm(sid, csid, SECCLASS_FILE, FILE__READ, NULL);
@@ -1868,16 +1867,16 @@ static int selinux_capset(struct cred *new, const struct cred *old,
1868 * the CAP_SETUID and CAP_SETGID capabilities using the capable hook. 1867 * the CAP_SETUID and CAP_SETGID capabilities using the capable hook.
1869 */ 1868 */
1870 1869
1871static int selinux_capable(struct task_struct *tsk, const struct cred *cred, 1870static int selinux_capable(const struct cred *cred, struct user_namespace *ns,
1872 struct user_namespace *ns, int cap, int audit) 1871 int cap, int audit)
1873{ 1872{
1874 int rc; 1873 int rc;
1875 1874
1876 rc = cap_capable(tsk, cred, ns, cap, audit); 1875 rc = cap_capable(cred, ns, cap, audit);
1877 if (rc) 1876 if (rc)
1878 return rc; 1877 return rc;
1879 1878
1880 return task_has_capability(tsk, cred, cap, audit); 1879 return cred_has_capability(cred, cap, audit);
1881} 1880}
1882 1881
1883static int selinux_quotactl(int cmds, int type, int id, struct super_block *sb) 1882static int selinux_quotactl(int cmds, int type, int id, struct super_block *sb)
@@ -1954,8 +1953,7 @@ static int selinux_vm_enough_memory(struct mm_struct *mm, long pages)
1954{ 1953{
1955 int rc, cap_sys_admin = 0; 1954 int rc, cap_sys_admin = 0;
1956 1955
1957 rc = selinux_capable(current, current_cred(), 1956 rc = selinux_capable(current_cred(), &init_user_ns, CAP_SYS_ADMIN,
1958 &init_user_ns, CAP_SYS_ADMIN,
1959 SECURITY_CAP_NOAUDIT); 1957 SECURITY_CAP_NOAUDIT);
1960 if (rc == 0) 1958 if (rc == 0)
1961 cap_sys_admin = 1; 1959 cap_sys_admin = 1;
@@ -2859,8 +2857,7 @@ static int selinux_inode_getsecurity(const struct inode *inode, const char *name
2859 * and lack of permission just means that we fall back to the 2857 * and lack of permission just means that we fall back to the
2860 * in-core context value, not a denial. 2858 * in-core context value, not a denial.
2861 */ 2859 */
2862 error = selinux_capable(current, current_cred(), 2860 error = selinux_capable(current_cred(), &init_user_ns, CAP_MAC_ADMIN,
2863 &init_user_ns, CAP_MAC_ADMIN,
2864 SECURITY_CAP_NOAUDIT); 2861 SECURITY_CAP_NOAUDIT);
2865 if (!error) 2862 if (!error)
2866 error = security_sid_to_context_force(isec->sid, &context, 2863 error = security_sid_to_context_force(isec->sid, &context,
@@ -2993,8 +2990,8 @@ static int selinux_file_ioctl(struct file *file, unsigned int cmd,
2993 2990
2994 case KDSKBENT: 2991 case KDSKBENT:
2995 case KDSKBSENT: 2992 case KDSKBSENT:
2996 error = task_has_capability(current, cred, CAP_SYS_TTY_CONFIG, 2993 error = cred_has_capability(cred, CAP_SYS_TTY_CONFIG,
2997 SECURITY_CAP_AUDIT); 2994 SECURITY_CAP_AUDIT);
2998 break; 2995 break;
2999 2996
3000 /* default case assumes that the command will go 2997 /* default case assumes that the command will go
@@ -4718,24 +4715,6 @@ static int selinux_netlink_send(struct sock *sk, struct sk_buff *skb)
4718 return selinux_nlmsg_perm(sk, skb); 4715 return selinux_nlmsg_perm(sk, skb);
4719} 4716}
4720 4717
4721static int selinux_netlink_recv(struct sk_buff *skb, int capability)
4722{
4723 int err;
4724 struct common_audit_data ad;
4725 u32 sid;
4726
4727 err = cap_netlink_recv(skb, capability);
4728 if (err)
4729 return err;
4730
4731 COMMON_AUDIT_DATA_INIT(&ad, CAP);
4732 ad.u.cap = capability;
4733
4734 security_task_getsecid(current, &sid);
4735 return avc_has_perm(sid, sid, SECCLASS_CAPABILITY,
4736 CAP_TO_MASK(capability), &ad);
4737}
4738
4739static int ipc_alloc_security(struct task_struct *task, 4718static int ipc_alloc_security(struct task_struct *task,
4740 struct kern_ipc_perm *perm, 4719 struct kern_ipc_perm *perm,
4741 u16 sclass) 4720 u16 sclass)
@@ -5464,7 +5443,6 @@ static struct security_operations selinux_ops = {
5464 .vm_enough_memory = selinux_vm_enough_memory, 5443 .vm_enough_memory = selinux_vm_enough_memory,
5465 5444
5466 .netlink_send = selinux_netlink_send, 5445 .netlink_send = selinux_netlink_send,
5467 .netlink_recv = selinux_netlink_recv,
5468 5446
5469 .bprm_set_creds = selinux_bprm_set_creds, 5447 .bprm_set_creds = selinux_bprm_set_creds,
5470 .bprm_committing_creds = selinux_bprm_committing_creds, 5448 .bprm_committing_creds = selinux_bprm_committing_creds,