diff options
author | Andrew Morgan <morgan@kernel.org> | 2008-02-05 01:29:42 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-05 12:44:20 -0500 |
commit | e338d263a76af78fe8f38a72131188b58fceb591 (patch) | |
tree | f3f046fc6fd66de43de7191830f0daf3bc4ec8eb /security/dummy.c | |
parent | 8f6936f4d29aa14e54a2470b954a2e1f96322988 (diff) |
Add 64-bit capability support to the kernel
The patch supports legacy (32-bit) capability userspace, and where possible
translates 32-bit capabilities to/from userspace and the VFS to 64-bit
kernel space capabilities. If a capability set cannot be compressed into
32-bits for consumption by user space, the system call fails, with -ERANGE.
FWIW libcap-2.00 supports this change (and earlier capability formats)
http://www.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.6/
[akpm@linux-foundation.org: coding-syle fixes]
[akpm@linux-foundation.org: use get_task_comm()]
[ezk@cs.sunysb.edu: build fix]
[akpm@linux-foundation.org: do not initialise statics to 0 or NULL]
[akpm@linux-foundation.org: unused var]
[serue@us.ibm.com: export __cap_ symbols]
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Cc: Chris Wright <chrisw@sous-sol.org>
Cc: James Morris <jmorris@namei.org>
Cc: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'security/dummy.c')
-rw-r--r-- | security/dummy.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/security/dummy.c b/security/dummy.c index c505122e22db..649326bf64ea 100644 --- a/security/dummy.c +++ b/security/dummy.c | |||
@@ -36,14 +36,19 @@ static int dummy_ptrace (struct task_struct *parent, struct task_struct *child) | |||
36 | static int dummy_capget (struct task_struct *target, kernel_cap_t * effective, | 36 | static int dummy_capget (struct task_struct *target, kernel_cap_t * effective, |
37 | kernel_cap_t * inheritable, kernel_cap_t * permitted) | 37 | kernel_cap_t * inheritable, kernel_cap_t * permitted) |
38 | { | 38 | { |
39 | *effective = *inheritable = *permitted = 0; | ||
40 | if (target->euid == 0) { | 39 | if (target->euid == 0) { |
41 | *permitted |= (~0 & ~CAP_FS_MASK); | 40 | cap_set_full(*permitted); |
42 | *effective |= (~0 & ~CAP_TO_MASK(CAP_SETPCAP) & ~CAP_FS_MASK); | 41 | cap_set_init_eff(*effective); |
42 | } else { | ||
43 | cap_clear(*permitted); | ||
44 | cap_clear(*effective); | ||
43 | } | 45 | } |
44 | if (target->fsuid == 0) { | 46 | |
45 | *permitted |= CAP_FS_MASK; | 47 | cap_clear(*inheritable); |
46 | *effective |= CAP_FS_MASK; | 48 | |
49 | if (target->fsuid != 0) { | ||
50 | *permitted = cap_drop_fs_set(*permitted); | ||
51 | *effective = cap_drop_fs_set(*effective); | ||
47 | } | 52 | } |
48 | return 0; | 53 | return 0; |
49 | } | 54 | } |