diff options
Diffstat (limited to 'security')
-rw-r--r-- | security/apparmor/lsm.c | 5 | ||||
-rw-r--r-- | security/capability.c | 2 | ||||
-rw-r--r-- | security/commoncap.c | 83 | ||||
-rw-r--r-- | security/security.c | 25 | ||||
-rw-r--r-- | security/selinux/hooks.c | 23 | ||||
-rw-r--r-- | security/selinux/include/xfrm.h | 2 | ||||
-rw-r--r-- | security/selinux/ss/services.c | 2 | ||||
-rw-r--r-- | security/selinux/xfrm.c | 6 |
8 files changed, 103 insertions, 45 deletions
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c index d21a427a35ae..ae3a698415e6 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/ctype.h> | 22 | #include <linux/ctype.h> |
23 | #include <linux/sysctl.h> | 23 | #include <linux/sysctl.h> |
24 | #include <linux/audit.h> | 24 | #include <linux/audit.h> |
25 | #include <linux/user_namespace.h> | ||
25 | #include <net/sock.h> | 26 | #include <net/sock.h> |
26 | 27 | ||
27 | #include "include/apparmor.h" | 28 | #include "include/apparmor.h" |
@@ -136,11 +137,11 @@ static int apparmor_capget(struct task_struct *target, kernel_cap_t *effective, | |||
136 | } | 137 | } |
137 | 138 | ||
138 | static int apparmor_capable(struct task_struct *task, const struct cred *cred, | 139 | static int apparmor_capable(struct task_struct *task, const struct cred *cred, |
139 | int cap, int audit) | 140 | struct user_namespace *ns, int cap, int audit) |
140 | { | 141 | { |
141 | struct aa_profile *profile; | 142 | struct aa_profile *profile; |
142 | /* cap_capable returns 0 on success, else -EPERM */ | 143 | /* cap_capable returns 0 on success, else -EPERM */ |
143 | int error = cap_capable(task, cred, cap, audit); | 144 | int error = cap_capable(task, cred, ns, cap, audit); |
144 | if (!error) { | 145 | if (!error) { |
145 | profile = aa_cred_profile(cred); | 146 | profile = aa_cred_profile(cred); |
146 | if (!unconfined(profile)) | 147 | if (!unconfined(profile)) |
diff --git a/security/capability.c b/security/capability.c index ab3d807accc3..2984ea4f776f 100644 --- a/security/capability.c +++ b/security/capability.c | |||
@@ -761,7 +761,7 @@ static int cap_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 sk_sid, u8 dir) | |||
761 | 761 | ||
762 | static int cap_xfrm_state_pol_flow_match(struct xfrm_state *x, | 762 | static int cap_xfrm_state_pol_flow_match(struct xfrm_state *x, |
763 | struct xfrm_policy *xp, | 763 | struct xfrm_policy *xp, |
764 | struct flowi *fl) | 764 | const struct flowi *fl) |
765 | { | 765 | { |
766 | return 1; | 766 | return 1; |
767 | } | 767 | } |
diff --git a/security/commoncap.c b/security/commoncap.c index 64c2ed9c9015..f20e984ccfb4 100644 --- a/security/commoncap.c +++ b/security/commoncap.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/sched.h> | 27 | #include <linux/sched.h> |
28 | #include <linux/prctl.h> | 28 | #include <linux/prctl.h> |
29 | #include <linux/securebits.h> | 29 | #include <linux/securebits.h> |
30 | #include <linux/user_namespace.h> | ||
30 | 31 | ||
31 | /* | 32 | /* |
32 | * If a non-root user executes a setuid-root binary in | 33 | * If a non-root user executes a setuid-root binary in |
@@ -52,13 +53,12 @@ static void warn_setuid_and_fcaps_mixed(const char *fname) | |||
52 | 53 | ||
53 | int cap_netlink_send(struct sock *sk, struct sk_buff *skb) | 54 | int cap_netlink_send(struct sock *sk, struct sk_buff *skb) |
54 | { | 55 | { |
55 | NETLINK_CB(skb).eff_cap = current_cap(); | ||
56 | return 0; | 56 | return 0; |
57 | } | 57 | } |
58 | 58 | ||
59 | int cap_netlink_recv(struct sk_buff *skb, int cap) | 59 | int cap_netlink_recv(struct sk_buff *skb, int cap) |
60 | { | 60 | { |
61 | if (!cap_raised(NETLINK_CB(skb).eff_cap, cap)) | 61 | if (!cap_raised(current_cap(), cap)) |
62 | return -EPERM; | 62 | return -EPERM; |
63 | return 0; | 63 | return 0; |
64 | } | 64 | } |
@@ -68,6 +68,7 @@ EXPORT_SYMBOL(cap_netlink_recv); | |||
68 | * cap_capable - Determine whether a task has a particular effective capability | 68 | * cap_capable - Determine whether a task has a particular effective capability |
69 | * @tsk: The task to query | 69 | * @tsk: The task to query |
70 | * @cred: The credentials to use | 70 | * @cred: The credentials to use |
71 | * @ns: The user namespace in which we need the capability | ||
71 | * @cap: The capability to check for | 72 | * @cap: The capability to check for |
72 | * @audit: Whether to write an audit message or not | 73 | * @audit: Whether to write an audit message or not |
73 | * | 74 | * |
@@ -79,10 +80,30 @@ EXPORT_SYMBOL(cap_netlink_recv); | |||
79 | * cap_has_capability() returns 0 when a task has a capability, but the | 80 | * cap_has_capability() returns 0 when a task has a capability, but the |
80 | * kernel's capable() and has_capability() returns 1 for this case. | 81 | * kernel's capable() and has_capability() returns 1 for this case. |
81 | */ | 82 | */ |
82 | int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap, | 83 | int cap_capable(struct task_struct *tsk, const struct cred *cred, |
83 | int audit) | 84 | struct user_namespace *targ_ns, int cap, int audit) |
84 | { | 85 | { |
85 | return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM; | 86 | for (;;) { |
87 | /* The creator of the user namespace has all caps. */ | ||
88 | if (targ_ns != &init_user_ns && targ_ns->creator == cred->user) | ||
89 | return 0; | ||
90 | |||
91 | /* Do we have the necessary capabilities? */ | ||
92 | if (targ_ns == cred->user->user_ns) | ||
93 | return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM; | ||
94 | |||
95 | /* Have we tried all of the parent namespaces? */ | ||
96 | if (targ_ns == &init_user_ns) | ||
97 | return -EPERM; | ||
98 | |||
99 | /* | ||
100 | *If you have a capability in a parent user ns, then you have | ||
101 | * it over all children user namespaces as well. | ||
102 | */ | ||
103 | targ_ns = targ_ns->creator->user_ns; | ||
104 | } | ||
105 | |||
106 | /* We never get here */ | ||
86 | } | 107 | } |
87 | 108 | ||
88 | /** | 109 | /** |
@@ -93,7 +114,7 @@ int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap, | |||
93 | * Determine whether the current process may set the system clock and timezone | 114 | * Determine whether the current process may set the system clock and timezone |
94 | * information, returning 0 if permission granted, -ve if denied. | 115 | * information, returning 0 if permission granted, -ve if denied. |
95 | */ | 116 | */ |
96 | int cap_settime(struct timespec *ts, struct timezone *tz) | 117 | int cap_settime(const struct timespec *ts, const struct timezone *tz) |
97 | { | 118 | { |
98 | if (!capable(CAP_SYS_TIME)) | 119 | if (!capable(CAP_SYS_TIME)) |
99 | return -EPERM; | 120 | return -EPERM; |
@@ -106,18 +127,30 @@ int cap_settime(struct timespec *ts, struct timezone *tz) | |||
106 | * @child: The process to be accessed | 127 | * @child: The process to be accessed |
107 | * @mode: The mode of attachment. | 128 | * @mode: The mode of attachment. |
108 | * | 129 | * |
130 | * If we are in the same or an ancestor user_ns and have all the target | ||
131 | * task's capabilities, then ptrace access is allowed. | ||
132 | * If we have the ptrace capability to the target user_ns, then ptrace | ||
133 | * access is allowed. | ||
134 | * Else denied. | ||
135 | * | ||
109 | * Determine whether a process may access another, returning 0 if permission | 136 | * Determine whether a process may access another, returning 0 if permission |
110 | * granted, -ve if denied. | 137 | * granted, -ve if denied. |
111 | */ | 138 | */ |
112 | int cap_ptrace_access_check(struct task_struct *child, unsigned int mode) | 139 | int cap_ptrace_access_check(struct task_struct *child, unsigned int mode) |
113 | { | 140 | { |
114 | int ret = 0; | 141 | int ret = 0; |
142 | const struct cred *cred, *child_cred; | ||
115 | 143 | ||
116 | rcu_read_lock(); | 144 | rcu_read_lock(); |
117 | if (!cap_issubset(__task_cred(child)->cap_permitted, | 145 | cred = current_cred(); |
118 | current_cred()->cap_permitted) && | 146 | child_cred = __task_cred(child); |
119 | !capable(CAP_SYS_PTRACE)) | 147 | if (cred->user->user_ns == child_cred->user->user_ns && |
120 | ret = -EPERM; | 148 | cap_issubset(child_cred->cap_permitted, cred->cap_permitted)) |
149 | goto out; | ||
150 | if (ns_capable(child_cred->user->user_ns, CAP_SYS_PTRACE)) | ||
151 | goto out; | ||
152 | ret = -EPERM; | ||
153 | out: | ||
121 | rcu_read_unlock(); | 154 | rcu_read_unlock(); |
122 | return ret; | 155 | return ret; |
123 | } | 156 | } |
@@ -126,18 +159,30 @@ int cap_ptrace_access_check(struct task_struct *child, unsigned int mode) | |||
126 | * cap_ptrace_traceme - Determine whether another process may trace the current | 159 | * cap_ptrace_traceme - Determine whether another process may trace the current |
127 | * @parent: The task proposed to be the tracer | 160 | * @parent: The task proposed to be the tracer |
128 | * | 161 | * |
162 | * If parent is in the same or an ancestor user_ns and has all current's | ||
163 | * capabilities, then ptrace access is allowed. | ||
164 | * If parent has the ptrace capability to current's user_ns, then ptrace | ||
165 | * access is allowed. | ||
166 | * Else denied. | ||
167 | * | ||
129 | * Determine whether the nominated task is permitted to trace the current | 168 | * Determine whether the nominated task is permitted to trace the current |
130 | * process, returning 0 if permission is granted, -ve if denied. | 169 | * process, returning 0 if permission is granted, -ve if denied. |
131 | */ | 170 | */ |
132 | int cap_ptrace_traceme(struct task_struct *parent) | 171 | int cap_ptrace_traceme(struct task_struct *parent) |
133 | { | 172 | { |
134 | int ret = 0; | 173 | int ret = 0; |
174 | const struct cred *cred, *child_cred; | ||
135 | 175 | ||
136 | rcu_read_lock(); | 176 | rcu_read_lock(); |
137 | if (!cap_issubset(current_cred()->cap_permitted, | 177 | cred = __task_cred(parent); |
138 | __task_cred(parent)->cap_permitted) && | 178 | child_cred = current_cred(); |
139 | !has_capability(parent, CAP_SYS_PTRACE)) | 179 | if (cred->user->user_ns == child_cred->user->user_ns && |
140 | ret = -EPERM; | 180 | cap_issubset(child_cred->cap_permitted, cred->cap_permitted)) |
181 | goto out; | ||
182 | if (has_ns_capability(parent, child_cred->user->user_ns, CAP_SYS_PTRACE)) | ||
183 | goto out; | ||
184 | ret = -EPERM; | ||
185 | out: | ||
141 | rcu_read_unlock(); | 186 | rcu_read_unlock(); |
142 | return ret; | 187 | return ret; |
143 | } | 188 | } |
@@ -177,7 +222,8 @@ static inline int cap_inh_is_capped(void) | |||
177 | /* they are so limited unless the current task has the CAP_SETPCAP | 222 | /* they are so limited unless the current task has the CAP_SETPCAP |
178 | * capability | 223 | * capability |
179 | */ | 224 | */ |
180 | if (cap_capable(current, current_cred(), CAP_SETPCAP, | 225 | if (cap_capable(current, current_cred(), |
226 | current_cred()->user->user_ns, CAP_SETPCAP, | ||
181 | SECURITY_CAP_AUDIT) == 0) | 227 | SECURITY_CAP_AUDIT) == 0) |
182 | return 0; | 228 | return 0; |
183 | return 1; | 229 | return 1; |
@@ -829,7 +875,8 @@ int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3, | |||
829 | & (new->securebits ^ arg2)) /*[1]*/ | 875 | & (new->securebits ^ arg2)) /*[1]*/ |
830 | || ((new->securebits & SECURE_ALL_LOCKS & ~arg2)) /*[2]*/ | 876 | || ((new->securebits & SECURE_ALL_LOCKS & ~arg2)) /*[2]*/ |
831 | || (arg2 & ~(SECURE_ALL_LOCKS | SECURE_ALL_BITS)) /*[3]*/ | 877 | || (arg2 & ~(SECURE_ALL_LOCKS | SECURE_ALL_BITS)) /*[3]*/ |
832 | || (cap_capable(current, current_cred(), CAP_SETPCAP, | 878 | || (cap_capable(current, current_cred(), |
879 | current_cred()->user->user_ns, CAP_SETPCAP, | ||
833 | SECURITY_CAP_AUDIT) != 0) /*[4]*/ | 880 | SECURITY_CAP_AUDIT) != 0) /*[4]*/ |
834 | /* | 881 | /* |
835 | * [1] no changing of bits that are locked | 882 | * [1] no changing of bits that are locked |
@@ -894,7 +941,7 @@ int cap_vm_enough_memory(struct mm_struct *mm, long pages) | |||
894 | { | 941 | { |
895 | int cap_sys_admin = 0; | 942 | int cap_sys_admin = 0; |
896 | 943 | ||
897 | if (cap_capable(current, current_cred(), CAP_SYS_ADMIN, | 944 | if (cap_capable(current, current_cred(), &init_user_ns, CAP_SYS_ADMIN, |
898 | SECURITY_CAP_NOAUDIT) == 0) | 945 | SECURITY_CAP_NOAUDIT) == 0) |
899 | cap_sys_admin = 1; | 946 | cap_sys_admin = 1; |
900 | return __vm_enough_memory(mm, pages, cap_sys_admin); | 947 | return __vm_enough_memory(mm, pages, cap_sys_admin); |
@@ -921,7 +968,7 @@ int cap_file_mmap(struct file *file, unsigned long reqprot, | |||
921 | int ret = 0; | 968 | int ret = 0; |
922 | 969 | ||
923 | if (addr < dac_mmap_min_addr) { | 970 | if (addr < dac_mmap_min_addr) { |
924 | ret = cap_capable(current, current_cred(), CAP_SYS_RAWIO, | 971 | ret = cap_capable(current, current_cred(), &init_user_ns, CAP_SYS_RAWIO, |
925 | SECURITY_CAP_AUDIT); | 972 | SECURITY_CAP_AUDIT); |
926 | /* set PF_SUPERPRIV if it turns out we allow the low mmap */ | 973 | /* set PF_SUPERPRIV if it turns out we allow the low mmap */ |
927 | if (ret == 0) | 974 | if (ret == 0) |
diff --git a/security/security.c b/security/security.c index 47b8a447118f..101142369db4 100644 --- a/security/security.c +++ b/security/security.c | |||
@@ -154,29 +154,33 @@ int security_capset(struct cred *new, const struct cred *old, | |||
154 | effective, inheritable, permitted); | 154 | effective, inheritable, permitted); |
155 | } | 155 | } |
156 | 156 | ||
157 | int security_capable(const struct cred *cred, int cap) | 157 | int security_capable(struct user_namespace *ns, const struct cred *cred, |
158 | int cap) | ||
158 | { | 159 | { |
159 | return security_ops->capable(current, cred, cap, SECURITY_CAP_AUDIT); | 160 | return security_ops->capable(current, cred, ns, cap, |
161 | SECURITY_CAP_AUDIT); | ||
160 | } | 162 | } |
161 | 163 | ||
162 | int security_real_capable(struct task_struct *tsk, int cap) | 164 | int security_real_capable(struct task_struct *tsk, struct user_namespace *ns, |
165 | int cap) | ||
163 | { | 166 | { |
164 | const struct cred *cred; | 167 | const struct cred *cred; |
165 | int ret; | 168 | int ret; |
166 | 169 | ||
167 | cred = get_task_cred(tsk); | 170 | cred = get_task_cred(tsk); |
168 | ret = security_ops->capable(tsk, cred, cap, SECURITY_CAP_AUDIT); | 171 | ret = security_ops->capable(tsk, cred, ns, cap, SECURITY_CAP_AUDIT); |
169 | put_cred(cred); | 172 | put_cred(cred); |
170 | return ret; | 173 | return ret; |
171 | } | 174 | } |
172 | 175 | ||
173 | int security_real_capable_noaudit(struct task_struct *tsk, int cap) | 176 | int security_real_capable_noaudit(struct task_struct *tsk, |
177 | struct user_namespace *ns, int cap) | ||
174 | { | 178 | { |
175 | const struct cred *cred; | 179 | const struct cred *cred; |
176 | int ret; | 180 | int ret; |
177 | 181 | ||
178 | cred = get_task_cred(tsk); | 182 | cred = get_task_cred(tsk); |
179 | ret = security_ops->capable(tsk, cred, cap, SECURITY_CAP_NOAUDIT); | 183 | ret = security_ops->capable(tsk, cred, ns, cap, SECURITY_CAP_NOAUDIT); |
180 | put_cred(cred); | 184 | put_cred(cred); |
181 | return ret; | 185 | return ret; |
182 | } | 186 | } |
@@ -196,7 +200,7 @@ int security_syslog(int type) | |||
196 | return security_ops->syslog(type); | 200 | return security_ops->syslog(type); |
197 | } | 201 | } |
198 | 202 | ||
199 | int security_settime(struct timespec *ts, struct timezone *tz) | 203 | int security_settime(const struct timespec *ts, const struct timezone *tz) |
200 | { | 204 | { |
201 | return security_ops->settime(ts, tz); | 205 | return security_ops->settime(ts, tz); |
202 | } | 206 | } |
@@ -1105,7 +1109,7 @@ void security_sk_clone(const struct sock *sk, struct sock *newsk) | |||
1105 | 1109 | ||
1106 | void security_sk_classify_flow(struct sock *sk, struct flowi *fl) | 1110 | void security_sk_classify_flow(struct sock *sk, struct flowi *fl) |
1107 | { | 1111 | { |
1108 | security_ops->sk_getsecid(sk, &fl->secid); | 1112 | security_ops->sk_getsecid(sk, &fl->flowi_secid); |
1109 | } | 1113 | } |
1110 | EXPORT_SYMBOL(security_sk_classify_flow); | 1114 | EXPORT_SYMBOL(security_sk_classify_flow); |
1111 | 1115 | ||
@@ -1238,7 +1242,8 @@ int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir) | |||
1238 | } | 1242 | } |
1239 | 1243 | ||
1240 | int security_xfrm_state_pol_flow_match(struct xfrm_state *x, | 1244 | int security_xfrm_state_pol_flow_match(struct xfrm_state *x, |
1241 | struct xfrm_policy *xp, struct flowi *fl) | 1245 | struct xfrm_policy *xp, |
1246 | const struct flowi *fl) | ||
1242 | { | 1247 | { |
1243 | return security_ops->xfrm_state_pol_flow_match(x, xp, fl); | 1248 | return security_ops->xfrm_state_pol_flow_match(x, xp, fl); |
1244 | } | 1249 | } |
@@ -1250,7 +1255,7 @@ int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid) | |||
1250 | 1255 | ||
1251 | void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl) | 1256 | void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl) |
1252 | { | 1257 | { |
1253 | int rc = security_ops->xfrm_decode_session(skb, &fl->secid, 0); | 1258 | int rc = security_ops->xfrm_decode_session(skb, &fl->flowi_secid, 0); |
1254 | 1259 | ||
1255 | BUG_ON(rc); | 1260 | BUG_ON(rc); |
1256 | } | 1261 | } |
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index d52a92507412..f9c3764e4859 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" |
@@ -1846,11 +1847,11 @@ static int selinux_capset(struct cred *new, const struct cred *old, | |||
1846 | */ | 1847 | */ |
1847 | 1848 | ||
1848 | static int selinux_capable(struct task_struct *tsk, const struct cred *cred, | 1849 | static int selinux_capable(struct task_struct *tsk, const struct cred *cred, |
1849 | int cap, int audit) | 1850 | struct user_namespace *ns, int cap, int audit) |
1850 | { | 1851 | { |
1851 | int rc; | 1852 | int rc; |
1852 | 1853 | ||
1853 | rc = cap_capable(tsk, cred, cap, audit); | 1854 | rc = cap_capable(tsk, cred, ns, cap, audit); |
1854 | if (rc) | 1855 | if (rc) |
1855 | return rc; | 1856 | return rc; |
1856 | 1857 | ||
@@ -1931,7 +1932,8 @@ static int selinux_vm_enough_memory(struct mm_struct *mm, long pages) | |||
1931 | { | 1932 | { |
1932 | int rc, cap_sys_admin = 0; | 1933 | int rc, cap_sys_admin = 0; |
1933 | 1934 | ||
1934 | rc = selinux_capable(current, current_cred(), CAP_SYS_ADMIN, | 1935 | rc = selinux_capable(current, current_cred(), |
1936 | &init_user_ns, CAP_SYS_ADMIN, | ||
1935 | SECURITY_CAP_NOAUDIT); | 1937 | SECURITY_CAP_NOAUDIT); |
1936 | if (rc == 0) | 1938 | if (rc == 0) |
1937 | cap_sys_admin = 1; | 1939 | cap_sys_admin = 1; |
@@ -2723,7 +2725,7 @@ static int selinux_inode_setxattr(struct dentry *dentry, const char *name, | |||
2723 | if (!(sbsec->flags & SE_SBLABELSUPP)) | 2725 | if (!(sbsec->flags & SE_SBLABELSUPP)) |
2724 | return -EOPNOTSUPP; | 2726 | return -EOPNOTSUPP; |
2725 | 2727 | ||
2726 | if (!is_owner_or_cap(inode)) | 2728 | if (!inode_owner_or_capable(inode)) |
2727 | return -EPERM; | 2729 | return -EPERM; |
2728 | 2730 | ||
2729 | COMMON_AUDIT_DATA_INIT(&ad, FS); | 2731 | COMMON_AUDIT_DATA_INIT(&ad, FS); |
@@ -2834,7 +2836,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 | 2836 | * and lack of permission just means that we fall back to the |
2835 | * in-core context value, not a denial. | 2837 | * in-core context value, not a denial. |
2836 | */ | 2838 | */ |
2837 | error = selinux_capable(current, current_cred(), CAP_MAC_ADMIN, | 2839 | error = selinux_capable(current, current_cred(), |
2840 | &init_user_ns, CAP_MAC_ADMIN, | ||
2838 | SECURITY_CAP_NOAUDIT); | 2841 | SECURITY_CAP_NOAUDIT); |
2839 | if (!error) | 2842 | if (!error) |
2840 | error = security_sid_to_context_force(isec->sid, &context, | 2843 | error = security_sid_to_context_force(isec->sid, &context, |
@@ -2968,7 +2971,7 @@ static int selinux_file_ioctl(struct file *file, unsigned int cmd, | |||
2968 | case KDSKBENT: | 2971 | case KDSKBENT: |
2969 | case KDSKBSENT: | 2972 | case KDSKBSENT: |
2970 | error = task_has_capability(current, cred, CAP_SYS_TTY_CONFIG, | 2973 | error = task_has_capability(current, cred, CAP_SYS_TTY_CONFIG, |
2971 | SECURITY_CAP_AUDIT); | 2974 | SECURITY_CAP_AUDIT); |
2972 | break; | 2975 | break; |
2973 | 2976 | ||
2974 | /* default case assumes that the command will go | 2977 | /* default case assumes that the command will go |
@@ -4346,7 +4349,7 @@ static void selinux_secmark_refcount_dec(void) | |||
4346 | static void selinux_req_classify_flow(const struct request_sock *req, | 4349 | static void selinux_req_classify_flow(const struct request_sock *req, |
4347 | struct flowi *fl) | 4350 | struct flowi *fl) |
4348 | { | 4351 | { |
4349 | fl->secid = req->secid; | 4352 | fl->flowi_secid = req->secid; |
4350 | } | 4353 | } |
4351 | 4354 | ||
4352 | static int selinux_tun_dev_create(void) | 4355 | static int selinux_tun_dev_create(void) |
@@ -4695,6 +4698,7 @@ static int selinux_netlink_recv(struct sk_buff *skb, int capability) | |||
4695 | { | 4698 | { |
4696 | int err; | 4699 | int err; |
4697 | struct common_audit_data ad; | 4700 | struct common_audit_data ad; |
4701 | u32 sid; | ||
4698 | 4702 | ||
4699 | err = cap_netlink_recv(skb, capability); | 4703 | err = cap_netlink_recv(skb, capability); |
4700 | if (err) | 4704 | if (err) |
@@ -4703,8 +4707,9 @@ static int selinux_netlink_recv(struct sk_buff *skb, int capability) | |||
4703 | COMMON_AUDIT_DATA_INIT(&ad, CAP); | 4707 | COMMON_AUDIT_DATA_INIT(&ad, CAP); |
4704 | ad.u.cap = capability; | 4708 | ad.u.cap = capability; |
4705 | 4709 | ||
4706 | return avc_has_perm(NETLINK_CB(skb).sid, NETLINK_CB(skb).sid, | 4710 | security_task_getsecid(current, &sid); |
4707 | SECCLASS_CAPABILITY, CAP_TO_MASK(capability), &ad); | 4711 | return avc_has_perm(sid, sid, SECCLASS_CAPABILITY, |
4712 | CAP_TO_MASK(capability), &ad); | ||
4708 | } | 4713 | } |
4709 | 4714 | ||
4710 | static int ipc_alloc_security(struct task_struct *task, | 4715 | static 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); | |||
19 | int selinux_xfrm_state_delete(struct xfrm_state *x); | 19 | int selinux_xfrm_state_delete(struct xfrm_state *x); |
20 | int selinux_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir); | 20 | int selinux_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir); |
21 | int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x, | 21 | int 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/ss/services.c b/security/selinux/ss/services.c index 3e7544d2a07b..ea7c01f4a2bf 100644 --- a/security/selinux/ss/services.c +++ b/security/selinux/ss/services.c | |||
@@ -213,7 +213,7 @@ static u16 map_class(u16 pol_value) | |||
213 | return i; | 213 | return i; |
214 | } | 214 | } |
215 | 215 | ||
216 | return pol_value; | 216 | return SECCLASS_NULL; |
217 | } | 217 | } |
218 | 218 | ||
219 | static void map_decision(u16 tclass, struct av_decision *avd, | 219 | static void map_decision(u16 tclass, struct av_decision *avd, |
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 | ||
114 | int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x, struct xfrm_policy *xp, | 114 | int 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 | ||