diff options
author | Ingo Molnar <mingo@elte.hu> | 2011-05-07 04:51:38 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-05-07 04:51:48 -0400 |
commit | 4cb1f43ce8c72ee453c00fcb9f6ee9c4ebd03f98 (patch) | |
tree | 15e64f192b54ea01fd640d69eed0cabed2baaaa9 /security/selinux/hooks.c | |
parent | 9de4966a4d218f29c68e96e8e7b4d2840dedec79 (diff) | |
parent | 0ee5623f9a6e52df90a78bd21179f8ab370e102e (diff) |
Merge commit 'v2.6.39-rc6' into x86/cleanups
Merge reason: move to a (much) newer upstream base.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r-- | security/selinux/hooks.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 6475e1f0223e..f7cf0ea6faea 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" |
@@ -1445,8 +1446,11 @@ static int task_has_capability(struct task_struct *tsk, | |||
1445 | } | 1446 | } |
1446 | 1447 | ||
1447 | rc = avc_has_perm_noaudit(sid, sid, sclass, av, 0, &avd); | 1448 | rc = avc_has_perm_noaudit(sid, sid, sclass, av, 0, &avd); |
1448 | if (audit == SECURITY_CAP_AUDIT) | 1449 | if (audit == SECURITY_CAP_AUDIT) { |
1449 | avc_audit(sid, sid, sclass, av, &avd, rc, &ad); | 1450 | int rc2 = avc_audit(sid, sid, sclass, av, &avd, rc, &ad, 0); |
1451 | if (rc2) | ||
1452 | return rc2; | ||
1453 | } | ||
1450 | return rc; | 1454 | return rc; |
1451 | } | 1455 | } |
1452 | 1456 | ||
@@ -1466,7 +1470,8 @@ static int task_has_system(struct task_struct *tsk, | |||
1466 | static int inode_has_perm(const struct cred *cred, | 1470 | static int inode_has_perm(const struct cred *cred, |
1467 | struct inode *inode, | 1471 | struct inode *inode, |
1468 | u32 perms, | 1472 | u32 perms, |
1469 | struct common_audit_data *adp) | 1473 | struct common_audit_data *adp, |
1474 | unsigned flags) | ||
1470 | { | 1475 | { |
1471 | struct inode_security_struct *isec; | 1476 | struct inode_security_struct *isec; |
1472 | struct common_audit_data ad; | 1477 | struct common_audit_data ad; |
@@ -1486,7 +1491,7 @@ static int inode_has_perm(const struct cred *cred, | |||
1486 | ad.u.fs.inode = inode; | 1491 | ad.u.fs.inode = inode; |
1487 | } | 1492 | } |
1488 | 1493 | ||
1489 | return avc_has_perm(sid, isec->sid, isec->sclass, perms, adp); | 1494 | return avc_has_perm_flags(sid, isec->sid, isec->sclass, perms, adp, flags); |
1490 | } | 1495 | } |
1491 | 1496 | ||
1492 | /* Same as inode_has_perm, but pass explicit audit data containing | 1497 | /* Same as inode_has_perm, but pass explicit audit data containing |
@@ -1503,7 +1508,7 @@ static inline int dentry_has_perm(const struct cred *cred, | |||
1503 | COMMON_AUDIT_DATA_INIT(&ad, FS); | 1508 | COMMON_AUDIT_DATA_INIT(&ad, FS); |
1504 | ad.u.fs.path.mnt = mnt; | 1509 | ad.u.fs.path.mnt = mnt; |
1505 | ad.u.fs.path.dentry = dentry; | 1510 | ad.u.fs.path.dentry = dentry; |
1506 | return inode_has_perm(cred, inode, av, &ad); | 1511 | return inode_has_perm(cred, inode, av, &ad, 0); |
1507 | } | 1512 | } |
1508 | 1513 | ||
1509 | /* Check whether a task can use an open file descriptor to | 1514 | /* Check whether a task can use an open file descriptor to |
@@ -1539,7 +1544,7 @@ static int file_has_perm(const struct cred *cred, | |||
1539 | /* av is zero if only checking access to the descriptor. */ | 1544 | /* av is zero if only checking access to the descriptor. */ |
1540 | rc = 0; | 1545 | rc = 0; |
1541 | if (av) | 1546 | if (av) |
1542 | rc = inode_has_perm(cred, inode, av, &ad); | 1547 | rc = inode_has_perm(cred, inode, av, &ad, 0); |
1543 | 1548 | ||
1544 | out: | 1549 | out: |
1545 | return rc; | 1550 | return rc; |
@@ -1846,11 +1851,11 @@ static int selinux_capset(struct cred *new, const struct cred *old, | |||
1846 | */ | 1851 | */ |
1847 | 1852 | ||
1848 | static int selinux_capable(struct task_struct *tsk, const struct cred *cred, | 1853 | static int selinux_capable(struct task_struct *tsk, const struct cred *cred, |
1849 | int cap, int audit) | 1854 | struct user_namespace *ns, int cap, int audit) |
1850 | { | 1855 | { |
1851 | int rc; | 1856 | int rc; |
1852 | 1857 | ||
1853 | rc = cap_capable(tsk, cred, cap, audit); | 1858 | rc = cap_capable(tsk, cred, ns, cap, audit); |
1854 | if (rc) | 1859 | if (rc) |
1855 | return rc; | 1860 | return rc; |
1856 | 1861 | ||
@@ -1931,7 +1936,8 @@ static int selinux_vm_enough_memory(struct mm_struct *mm, long pages) | |||
1931 | { | 1936 | { |
1932 | int rc, cap_sys_admin = 0; | 1937 | int rc, cap_sys_admin = 0; |
1933 | 1938 | ||
1934 | rc = selinux_capable(current, current_cred(), CAP_SYS_ADMIN, | 1939 | rc = selinux_capable(current, current_cred(), |
1940 | &init_user_ns, CAP_SYS_ADMIN, | ||
1935 | SECURITY_CAP_NOAUDIT); | 1941 | SECURITY_CAP_NOAUDIT); |
1936 | if (rc == 0) | 1942 | if (rc == 0) |
1937 | cap_sys_admin = 1; | 1943 | cap_sys_admin = 1; |
@@ -2101,7 +2107,7 @@ static inline void flush_unauthorized_files(const struct cred *cred, | |||
2101 | file = file_priv->file; | 2107 | file = file_priv->file; |
2102 | inode = file->f_path.dentry->d_inode; | 2108 | inode = file->f_path.dentry->d_inode; |
2103 | if (inode_has_perm(cred, inode, | 2109 | if (inode_has_perm(cred, inode, |
2104 | FILE__READ | FILE__WRITE, NULL)) { | 2110 | FILE__READ | FILE__WRITE, NULL, 0)) { |
2105 | drop_tty = 1; | 2111 | drop_tty = 1; |
2106 | } | 2112 | } |
2107 | } | 2113 | } |
@@ -2633,7 +2639,7 @@ static int selinux_inode_follow_link(struct dentry *dentry, struct nameidata *na | |||
2633 | return dentry_has_perm(cred, NULL, dentry, FILE__READ); | 2639 | return dentry_has_perm(cred, NULL, dentry, FILE__READ); |
2634 | } | 2640 | } |
2635 | 2641 | ||
2636 | static int selinux_inode_permission(struct inode *inode, int mask) | 2642 | static int selinux_inode_permission(struct inode *inode, int mask, unsigned flags) |
2637 | { | 2643 | { |
2638 | const struct cred *cred = current_cred(); | 2644 | const struct cred *cred = current_cred(); |
2639 | struct common_audit_data ad; | 2645 | struct common_audit_data ad; |
@@ -2655,7 +2661,7 @@ static int selinux_inode_permission(struct inode *inode, int mask) | |||
2655 | 2661 | ||
2656 | perms = file_mask_to_av(inode->i_mode, mask); | 2662 | perms = file_mask_to_av(inode->i_mode, mask); |
2657 | 2663 | ||
2658 | return inode_has_perm(cred, inode, perms, &ad); | 2664 | return inode_has_perm(cred, inode, perms, &ad, flags); |
2659 | } | 2665 | } |
2660 | 2666 | ||
2661 | static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr) | 2667 | static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr) |
@@ -2723,7 +2729,7 @@ static int selinux_inode_setxattr(struct dentry *dentry, const char *name, | |||
2723 | if (!(sbsec->flags & SE_SBLABELSUPP)) | 2729 | if (!(sbsec->flags & SE_SBLABELSUPP)) |
2724 | return -EOPNOTSUPP; | 2730 | return -EOPNOTSUPP; |
2725 | 2731 | ||
2726 | if (!is_owner_or_cap(inode)) | 2732 | if (!inode_owner_or_capable(inode)) |
2727 | return -EPERM; | 2733 | return -EPERM; |
2728 | 2734 | ||
2729 | COMMON_AUDIT_DATA_INIT(&ad, FS); | 2735 | COMMON_AUDIT_DATA_INIT(&ad, FS); |
@@ -2834,7 +2840,8 @@ static int selinux_inode_getsecurity(const struct inode *inode, const char *name | |||
2834 | * and lack of permission just means that we fall back to the | 2840 | * and lack of permission just means that we fall back to the |
2835 | * in-core context value, not a denial. | 2841 | * in-core context value, not a denial. |
2836 | */ | 2842 | */ |
2837 | error = selinux_capable(current, current_cred(), CAP_MAC_ADMIN, | 2843 | error = selinux_capable(current, current_cred(), |
2844 | &init_user_ns, CAP_MAC_ADMIN, | ||
2838 | SECURITY_CAP_NOAUDIT); | 2845 | SECURITY_CAP_NOAUDIT); |
2839 | if (!error) | 2846 | if (!error) |
2840 | error = security_sid_to_context_force(isec->sid, &context, | 2847 | error = security_sid_to_context_force(isec->sid, &context, |
@@ -2968,7 +2975,7 @@ static int selinux_file_ioctl(struct file *file, unsigned int cmd, | |||
2968 | case KDSKBENT: | 2975 | case KDSKBENT: |
2969 | case KDSKBSENT: | 2976 | case KDSKBSENT: |
2970 | error = task_has_capability(current, cred, CAP_SYS_TTY_CONFIG, | 2977 | error = task_has_capability(current, cred, CAP_SYS_TTY_CONFIG, |
2971 | SECURITY_CAP_AUDIT); | 2978 | SECURITY_CAP_AUDIT); |
2972 | break; | 2979 | break; |
2973 | 2980 | ||
2974 | /* default case assumes that the command will go | 2981 | /* default case assumes that the command will go |
@@ -3202,7 +3209,7 @@ static int selinux_dentry_open(struct file *file, const struct cred *cred) | |||
3202 | * new inode label or new policy. | 3209 | * new inode label or new policy. |
3203 | * This check is not redundant - do not remove. | 3210 | * This check is not redundant - do not remove. |
3204 | */ | 3211 | */ |
3205 | return inode_has_perm(cred, inode, open_file_to_av(file), NULL); | 3212 | return inode_has_perm(cred, inode, open_file_to_av(file), NULL, 0); |
3206 | } | 3213 | } |
3207 | 3214 | ||
3208 | /* task security operations */ | 3215 | /* task security operations */ |