diff options
| author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-11 12:21:26 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-11 12:21:26 -0500 |
| commit | 0faa90880331386ac86ca78d52692c7a94051eab (patch) | |
| tree | 7cb9311c118a2e766ae378a433421130bac32e8c /security/selinux/hooks.c | |
| parent | 1f07e988290fc45932f5028c9e2a862c37a57336 (diff) | |
| parent | b68e418c445e8a468634d0a7ca2fb63bbaa74028 (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/selinux-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/selinux-2.6:
selinux: support 64-bit capabilities
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. */ |
