diff options
author | Stephen Smalley <sds@tycho.nsa.gov> | 2008-02-07 11:21:04 -0500 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2008-02-11 04:30:02 -0500 |
commit | b68e418c445e8a468634d0a7ca2fb63bbaa74028 (patch) | |
tree | e49b4a94ef28a9288ed6735a994387205b7cc5bd /security/selinux/hooks.c | |
parent | 19af35546de68c872dcb687613e0902a602cb20e (diff) |
selinux: support 64-bit capabilities
Fix SELinux to handle 64-bit capabilities correctly, and to catch
future extensions of capabilities beyond 64 bits to ensure that SELinux
is properly updated.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r-- | security/selinux/hooks.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index e5ed07510309..44f16d9041e3 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -1272,12 +1272,18 @@ static int task_has_perm(struct task_struct *tsk1, | |||
1272 | SECCLASS_PROCESS, perms, NULL); | 1272 | SECCLASS_PROCESS, perms, NULL); |
1273 | } | 1273 | } |
1274 | 1274 | ||
1275 | #if CAP_LAST_CAP > 63 | ||
1276 | #error Fix SELinux to handle capabilities > 63. | ||
1277 | #endif | ||
1278 | |||
1275 | /* Check whether a task is allowed to use a capability. */ | 1279 | /* Check whether a task is allowed to use a capability. */ |
1276 | static int task_has_capability(struct task_struct *tsk, | 1280 | static int task_has_capability(struct task_struct *tsk, |
1277 | int cap) | 1281 | int cap) |
1278 | { | 1282 | { |
1279 | struct task_security_struct *tsec; | 1283 | struct task_security_struct *tsec; |
1280 | struct avc_audit_data ad; | 1284 | struct avc_audit_data ad; |
1285 | u16 sclass; | ||
1286 | u32 av = CAP_TO_MASK(cap); | ||
1281 | 1287 | ||
1282 | tsec = tsk->security; | 1288 | tsec = tsk->security; |
1283 | 1289 | ||
@@ -1285,8 +1291,19 @@ static int task_has_capability(struct task_struct *tsk, | |||
1285 | ad.tsk = tsk; | 1291 | ad.tsk = tsk; |
1286 | ad.u.cap = cap; | 1292 | ad.u.cap = cap; |
1287 | 1293 | ||
1288 | return avc_has_perm(tsec->sid, tsec->sid, | 1294 | switch (CAP_TO_INDEX(cap)) { |
1289 | SECCLASS_CAPABILITY, CAP_TO_MASK(cap), &ad); | 1295 | case 0: |
1296 | sclass = SECCLASS_CAPABILITY; | ||
1297 | break; | ||
1298 | case 1: | ||
1299 | sclass = SECCLASS_CAPABILITY2; | ||
1300 | break; | ||
1301 | default: | ||
1302 | printk(KERN_ERR | ||
1303 | "SELinux: out of range capability %d\n", cap); | ||
1304 | BUG(); | ||
1305 | } | ||
1306 | return avc_has_perm(tsec->sid, tsec->sid, sclass, av, &ad); | ||
1290 | } | 1307 | } |
1291 | 1308 | ||
1292 | /* Check whether a task is allowed to use a system operation. */ | 1309 | /* Check whether a task is allowed to use a system operation. */ |